aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore30
-rw-r--r--CREDITS26
-rw-r--r--Documentation/Changes10
-rw-r--r--Documentation/CodingStyle21
-rw-r--r--Documentation/DocBook/kernel-hacking.tmpl2
-rw-r--r--Documentation/SubmittingPatches86
-rw-r--r--Documentation/connector/connector.txt44
-rw-r--r--Documentation/dell_rbu.txt50
-rw-r--r--Documentation/device-mapper/snapshot.txt73
-rw-r--r--Documentation/filesystems/relayfs.txt2
-rw-r--r--Documentation/ia64/mca.txt194
-rw-r--r--Documentation/kernel-parameters.txt496
-rw-r--r--Documentation/keys-request-key.txt161
-rw-r--r--Documentation/keys.txt92
-rw-r--r--Documentation/networking/ip-sysctl.txt10
-rw-r--r--Documentation/sparse.txt4
-rw-r--r--Documentation/usb/URB.txt74
-rw-r--r--MAINTAINERS73
-rw-r--r--Makefile8
-rw-r--r--README9
-rw-r--r--arch/alpha/kernel/entry.S1
-rw-r--r--arch/alpha/kernel/osf_sys.c7
-rw-r--r--arch/alpha/kernel/process.c4
-rw-r--r--arch/alpha/kernel/sys_dp264.c41
-rw-r--r--arch/alpha/kernel/traps.c15
-rw-r--r--arch/arm/Makefile6
-rw-r--r--arch/arm/boot/compressed/ofw-shark.c2
-rw-r--r--arch/arm/common/gic.c2
-rw-r--r--arch/arm/common/locomo.c3
-rw-r--r--arch/arm/common/scoop.c20
-rw-r--r--arch/arm/configs/collie_defconfig888
-rw-r--r--arch/arm/configs/corgi_defconfig1523
-rw-r--r--arch/arm/configs/ixp4xx_defconfig577
-rw-r--r--arch/arm/configs/poodle_defconfig1015
-rw-r--r--arch/arm/configs/spitz_defconfig1401
-rw-r--r--arch/arm/kernel/armksyms.c4
-rw-r--r--arch/arm/kernel/entry-armv.S2
-rw-r--r--arch/arm/kernel/entry-common.S7
-rw-r--r--arch/arm/kernel/io.c6
-rw-r--r--arch/arm/kernel/semaphore.c2
-rw-r--r--arch/arm/kernel/sys_arm.c2
-rw-r--r--arch/arm/kernel/traps.c5
-rw-r--r--arch/arm/kernel/vmlinux.lds.S23
-rw-r--r--arch/arm/mach-clps711x/fortunet.c2
-rw-r--r--arch/arm/mach-imx/generic.c23
-rw-r--r--arch/arm/mach-imx/leds-mx1ads.c1
-rw-r--r--arch/arm/mach-imx/mx1ads.c2
-rw-r--r--arch/arm/mach-integrator/impd1.c15
-rw-r--r--arch/arm/mach-iop3xx/common.c1
-rw-r--r--arch/arm/mach-iop3xx/iop321-time.c1
-rw-r--r--arch/arm/mach-iop3xx/iop331-time.c1
-rw-r--r--arch/arm/mach-iop3xx/iq31244-mm.c1
-rw-r--r--arch/arm/mach-iop3xx/iq80321-mm.c1
-rw-r--r--arch/arm/mach-iop3xx/iq80331-mm.c1
-rw-r--r--arch/arm/mach-iop3xx/iq80332-mm.c1
-rw-r--r--arch/arm/mach-ixp2000/core.c3
-rw-r--r--arch/arm/mach-ixp2000/pci.c1
-rw-r--r--arch/arm/mach-ixp4xx/common.c5
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-setup.c6
-rw-r--r--arch/arm/mach-l7200/core.c21
-rw-r--r--arch/arm/mach-pxa/corgi.c1
-rw-r--r--arch/arm/mach-pxa/corgi_lcd.c23
-rw-r--r--arch/arm/mach-pxa/generic.c26
-rw-r--r--arch/arm/mach-pxa/spitz.c4
-rw-r--r--arch/arm/mach-s3c2410/Kconfig1
-rw-r--r--arch/arm/mach-s3c2410/clock.c5
-rw-r--r--arch/arm/mach-s3c2410/mach-anubis.c5
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c13
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c7
-rw-r--r--arch/arm/mach-s3c2410/mach-n30.c6
-rw-r--r--arch/arm/mach-s3c2410/mach-nexcoder.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-otom.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-rx3715.c5
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2410.c5
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2440.c5
-rw-r--r--arch/arm/mach-s3c2410/mach-vr1000.c5
-rw-r--r--arch/arm/mach-s3c2410/s3c2410.c3
-rw-r--r--arch/arm/mach-s3c2410/s3c2440.c4
-rw-r--r--arch/arm/mach-s3c2410/time.c1
-rw-r--r--arch/arm/mach-s3c2410/usb-simtec.c1
-rw-r--r--arch/arm/mach-sa1100/collie.c6
-rw-r--r--arch/arm/mach-sa1100/generic.h3
-rw-r--r--arch/arm/mach-versatile/core.c44
-rw-r--r--arch/arm/mach-versatile/pci.c1
-rw-r--r--arch/arm/mm/Kconfig8
-rw-r--r--arch/arm/mm/abort-ev6.S5
-rw-r--r--arch/arm/mm/alignment.c55
-rw-r--r--arch/arm/mm/cache-v6.S9
-rw-r--r--arch/arm/mm/fault.c12
-rw-r--r--arch/arm/mm/flush.c36
-rw-r--r--arch/arm/mm/proc-arm1020.S2
-rw-r--r--arch/arm/mm/proc-arm1020e.S2
-rw-r--r--arch/arm/mm/proc-arm1022.S2
-rw-r--r--arch/arm/mm/proc-arm1026.S2
-rw-r--r--arch/arm/mm/proc-arm6_7.S2
-rw-r--r--arch/arm/mm/proc-arm720.S2
-rw-r--r--arch/arm/mm/proc-arm920.S2
-rw-r--r--arch/arm/mm/proc-arm922.S2
-rw-r--r--arch/arm/mm/proc-arm925.S2
-rw-r--r--arch/arm/mm/proc-arm926.S2
-rw-r--r--arch/arm/mm/proc-sa110.S2
-rw-r--r--arch/arm/mm/proc-sa1100.S2
-rw-r--r--arch/arm/mm/proc-v6.S11
-rw-r--r--arch/arm/mm/proc-xscale.S2
-rw-r--r--arch/arm/nwfpe/fpa11.c5
-rw-r--r--arch/arm/nwfpe/fpa11.h20
-rw-r--r--arch/arm/nwfpe/fpa11_cprt.c3
-rw-r--r--arch/arm/nwfpe/fpopcode.h6
-rw-r--r--arch/arm/nwfpe/softfloat.h3
-rw-r--r--arch/arm/plat-omap/common.c1
-rw-r--r--arch/arm/plat-omap/cpu-omap.c1
-rw-r--r--arch/arm/plat-omap/usb.c1
-rw-r--r--arch/arm/tools/mach-types90
-rw-r--r--arch/arm26/boot/compressed/hw-bse.c74
-rw-r--r--arch/cris/arch-v32/drivers/pci/dma.c2
-rw-r--r--arch/cris/arch-v32/kernel/smp.c2
-rw-r--r--arch/i386/kernel/acpi/boot.c3
-rw-r--r--arch/i386/kernel/apic.c1
-rw-r--r--arch/i386/kernel/cpu/amd.c16
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c30
-rw-r--r--arch/i386/kernel/cpu/mcheck/k7.c1
-rw-r--r--arch/i386/kernel/cpu/mcheck/non-fatal.c1
-rw-r--r--arch/i386/kernel/cpu/mcheck/p4.c1
-rw-r--r--arch/i386/kernel/cpu/mcheck/p5.c1
-rw-r--r--arch/i386/kernel/cpu/mcheck/p6.c1
-rw-r--r--arch/i386/kernel/cpu/mcheck/winchip.c1
-rw-r--r--arch/i386/kernel/crash.c2
-rw-r--r--arch/i386/kernel/i8259.c3
-rw-r--r--arch/i386/kernel/io_apic.c1
-rw-r--r--arch/i386/kernel/mpparse.c1
-rw-r--r--arch/i386/kernel/nmi.c1
-rw-r--r--arch/i386/kernel/pci-dma.c2
-rw-r--r--arch/i386/kernel/process.c2
-rw-r--r--arch/i386/kernel/signal.c6
-rw-r--r--arch/i386/kernel/smp.c1
-rw-r--r--arch/i386/kernel/smpboot.c1
-rw-r--r--arch/i386/kernel/timers/timer_pit.c1
-rw-r--r--arch/i386/kernel/traps.c1
-rw-r--r--arch/i386/mach-default/setup.c1
-rw-r--r--arch/i386/mach-visws/setup.c1
-rw-r--r--arch/i386/mach-visws/visws_apic.c1
-rw-r--r--arch/i386/mach-voyager/setup.c1
-rw-r--r--arch/i386/mach-voyager/voyager_basic.c1
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c2
-rw-r--r--arch/i386/mach-voyager/voyager_thread.c2
-rw-r--r--arch/i386/oprofile/nmi_timer_int.c2
-rw-r--r--arch/i386/pci/acpi.c1
-rw-r--r--arch/i386/pci/irq.c3
-rw-r--r--arch/i386/power/cpu.c17
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c13
-rw-r--r--arch/ia64/hp/common/sba_iommu.c45
-rw-r--r--arch/ia64/hp/sim/simscsi.c29
-rw-r--r--arch/ia64/kernel/acpi.c2
-rw-r--r--arch/ia64/kernel/entry.S2
-rw-r--r--arch/ia64/kernel/mca.c5
-rw-r--r--arch/ia64/kernel/mca_asm.S96
-rw-r--r--arch/ia64/kernel/mca_drv.c135
-rw-r--r--arch/ia64/kernel/mca_drv.h2
-rw-r--r--arch/ia64/kernel/mca_drv_asm.S48
-rw-r--r--arch/ia64/kernel/perfmon.c5
-rw-r--r--arch/ia64/lib/swiotlb.c106
-rw-r--r--arch/ia64/sn/kernel/tiocx.c62
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_reg.c59
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c32
-rw-r--r--arch/ia64/sn/pci/tioce_provider.c30
-rw-r--r--arch/m32r/Makefile2
-rw-r--r--arch/m32r/kernel/entry.S9
-rw-r--r--arch/m32r/kernel/smp.c12
-rw-r--r--arch/m32r/kernel/traps.c33
-rw-r--r--arch/m32r/lib/usercopy.c16
-rw-r--r--arch/mips/pci/fixup-tb0226.c33
-rw-r--r--arch/ppc/boot/ld.script2
-rw-r--r--arch/ppc/kernel/Makefile3
-rw-r--r--arch/ppc/kernel/cputable.c5
-rw-r--r--arch/ppc/kernel/dma-mapping.c4
-rw-r--r--arch/ppc/kernel/perfmon.c7
-rw-r--r--arch/ppc/platforms/4xx/bamboo.c1
-rw-r--r--arch/ppc/platforms/4xx/ebony.c1
-rw-r--r--arch/ppc/platforms/4xx/luan.c1
-rw-r--r--arch/ppc/platforms/4xx/ocotea.c1
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.c1
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.c1
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.c1
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.c1
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.c1
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.c1
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.c1
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.c1
-rw-r--r--arch/ppc/platforms/chestnut.c1
-rw-r--r--arch/ppc/platforms/chrp_setup.c1
-rw-r--r--arch/ppc/platforms/gemini_setup.c1
-rw-r--r--arch/ppc/platforms/mvme5100.c1
-rw-r--r--arch/ppc/platforms/pmac_cpufreq.c7
-rw-r--r--arch/ppc/platforms/pmac_feature.c4
-rw-r--r--arch/ppc/platforms/pmac_setup.c11
-rw-r--r--arch/ppc/platforms/pmac_time.c2
-rw-r--r--arch/ppc/platforms/powerpmc250.c1
-rw-r--r--arch/ppc/platforms/pplus.c1
-rw-r--r--arch/ppc/platforms/prpmc750.c1
-rw-r--r--arch/ppc/platforms/prpmc800.c1
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.c2
-rw-r--r--arch/ppc/platforms/sandpoint.c1
-rw-r--r--arch/ppc/syslib/Makefile3
-rw-r--r--arch/ppc/syslib/mpc8xx_devices.c224
-rw-r--r--arch/ppc/syslib/mpc8xx_sys.c61
-rw-r--r--arch/ppc/syslib/mv64x60.c4
-rw-r--r--arch/ppc/syslib/of_device.c6
-rw-r--r--arch/ppc/syslib/open_pic.c1
-rw-r--r--arch/ppc/syslib/open_pic2.c3
-rw-r--r--arch/ppc/syslib/ppc4xx_setup.c1
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.c8
-rw-r--r--arch/ppc64/Makefile2
-rw-r--r--arch/ppc64/configs/bpa_defconfig79
-rw-r--r--arch/ppc64/configs/g5_defconfig124
-rw-r--r--arch/ppc64/configs/iSeries_defconfig78
-rw-r--r--arch/ppc64/configs/maple_defconfig67
-rw-r--r--arch/ppc64/configs/pSeries_defconfig95
-rw-r--r--arch/ppc64/defconfig100
-rw-r--r--arch/ppc64/kernel/bpa_iommu.c8
-rw-r--r--arch/ppc64/kernel/dma.c2
-rw-r--r--arch/ppc64/kernel/iSeries_htab.c2
-rw-r--r--arch/ppc64/kernel/iommu.c2
-rw-r--r--arch/ppc64/kernel/kprobes.c8
-rw-r--r--arch/ppc64/kernel/machine_kexec.c1
-rw-r--r--arch/ppc64/kernel/module.c13
-rw-r--r--arch/ppc64/kernel/mpic.c4
-rw-r--r--arch/ppc64/kernel/of_device.c7
-rw-r--r--arch/ppc64/kernel/pSeries_iommu.c181
-rw-r--r--arch/ppc64/kernel/pSeries_pci.c4
-rw-r--r--arch/ppc64/kernel/pci.c9
-rw-r--r--arch/ppc64/kernel/pci_direct_iommu.c2
-rw-r--r--arch/ppc64/kernel/pci_iommu.c2
-rw-r--r--arch/ppc64/kernel/pmac_setup.c21
-rw-r--r--arch/ppc64/kernel/pmac_time.c4
-rw-r--r--arch/ppc64/kernel/prom_init.c3
-rw-r--r--arch/ppc64/kernel/ptrace.c1
-rw-r--r--arch/ppc64/kernel/time.c2
-rw-r--r--arch/ppc64/kernel/vdso32/gettimeofday.S2
-rw-r--r--arch/ppc64/kernel/vio.c2
-rw-r--r--arch/ppc64/mm/fault.c1
-rw-r--r--arch/ppc64/mm/hash_native.c6
-rw-r--r--arch/ppc64/mm/hugetlbpage.c7
-rw-r--r--arch/ppc64/mm/init.c3
-rw-r--r--arch/ppc64/mm/tlb.c4
-rw-r--r--arch/s390/defconfig36
-rw-r--r--arch/s390/kernel/Makefile2
-rw-r--r--arch/s390/kernel/compat_signal.c6
-rw-r--r--arch/s390/kernel/entry.S2
-rw-r--r--arch/s390/kernel/entry64.S2
-rw-r--r--arch/s390/kernel/reipl_diag.c39
-rw-r--r--arch/s390/kernel/setup.c5
-rw-r--r--arch/s390/kernel/signal.c4
-rw-r--r--arch/s390/kernel/smp.c3
-rw-r--r--arch/sh/kernel/smp.c3
-rw-r--r--arch/sparc/Kconfig56
-rw-r--r--arch/sparc/kernel/setup.c2
-rw-r--r--arch/sparc/kernel/time.c2
-rw-r--r--arch/sparc/mm/srmmu.c2
-rw-r--r--arch/sparc64/Kconfig.debug8
-rw-r--r--arch/sparc64/kernel/cpu.c4
-rw-r--r--arch/sparc64/kernel/devices.c22
-rw-r--r--arch/sparc64/kernel/dtlb_backend.S13
-rw-r--r--arch/sparc64/kernel/dtlb_base.S18
-rw-r--r--arch/sparc64/kernel/dtlb_prot.S12
-rw-r--r--arch/sparc64/kernel/entry.S263
-rw-r--r--arch/sparc64/kernel/etrap.S51
-rw-r--r--arch/sparc64/kernel/head.S748
-rw-r--r--arch/sparc64/kernel/irq.c1
-rw-r--r--arch/sparc64/kernel/itlb_base.S26
-rw-r--r--arch/sparc64/kernel/ktlb.S194
-rw-r--r--arch/sparc64/kernel/pci_iommu.c363
-rw-r--r--arch/sparc64/kernel/pci_psycho.c44
-rw-r--r--arch/sparc64/kernel/pci_sabre.c39
-rw-r--r--arch/sparc64/kernel/pci_schizo.c59
-rw-r--r--arch/sparc64/kernel/power.c64
-rw-r--r--arch/sparc64/kernel/ptrace.c21
-rw-r--r--arch/sparc64/kernel/rtrap.S30
-rw-r--r--arch/sparc64/kernel/setup.c58
-rw-r--r--arch/sparc64/kernel/smp.c28
-rw-r--r--arch/sparc64/kernel/sys32.S170
-rw-r--r--arch/sparc64/kernel/trampoline.S31
-rw-r--r--arch/sparc64/kernel/traps.c100
-rw-r--r--arch/sparc64/kernel/una_asm.S67
-rw-r--r--arch/sparc64/kernel/unaligned.c101
-rw-r--r--arch/sparc64/kernel/us3_cpufreq.c5
-rw-r--r--arch/sparc64/kernel/vmlinux.lds.S3
-rw-r--r--arch/sparc64/kernel/winfixup.S33
-rw-r--r--arch/sparc64/lib/VISsave.S8
-rw-r--r--arch/sparc64/lib/strncpy_from_user.S16
-rw-r--r--arch/sparc64/lib/user_fixup.c63
-rw-r--r--arch/sparc64/mm/Makefile2
-rw-r--r--arch/sparc64/mm/extable.c80
-rw-r--r--arch/sparc64/mm/fault.c69
-rw-r--r--arch/sparc64/mm/init.c868
-rw-r--r--arch/sparc64/mm/ultra.S112
-rw-r--r--arch/sparc64/prom/Makefile4
-rw-r--r--arch/sparc64/prom/console.c2
-rw-r--r--arch/sparc64/prom/devops.c2
-rw-r--r--arch/sparc64/prom/init.c5
-rw-r--r--arch/sparc64/prom/map.S72
-rw-r--r--arch/sparc64/prom/memory.c152
-rw-r--r--arch/sparc64/prom/misc.c46
-rw-r--r--arch/sparc64/prom/p1275.c2
-rw-r--r--arch/sparc64/prom/printf.c2
-rw-r--r--arch/sparc64/prom/tree.c50
-rw-r--r--arch/um/Kconfig.i3864
-rw-r--r--arch/um/Makefile76
-rw-r--r--arch/um/Makefile-i38622
-rw-r--r--arch/um/Makefile-skas2
-rw-r--r--arch/um/Makefile-x86_6421
-rw-r--r--arch/um/drivers/Makefile2
-rw-r--r--arch/um/drivers/chan_kern.c60
-rw-r--r--arch/um/drivers/cow.h39
-rw-r--r--arch/um/drivers/cow_user.c1
-rw-r--r--arch/um/drivers/mcast_user.c12
-rw-r--r--arch/um/drivers/mconsole_kern.c52
-rw-r--r--arch/um/drivers/mconsole_user.c7
-rw-r--r--arch/um/drivers/port_kern.c1
-rw-r--r--arch/um/drivers/pty.c3
-rw-r--r--arch/um/drivers/ubd_kern.c556
-rw-r--r--arch/um/drivers/xterm.c6
-rw-r--r--arch/um/include/aio.h18
-rw-r--r--arch/um/include/common-offsets.h8
-rw-r--r--arch/um/include/mconsole.h1
-rw-r--r--arch/um/include/mem_user.h15
-rw-r--r--arch/um/include/os.h14
-rw-r--r--arch/um/include/registers.h12
-rw-r--r--arch/um/include/skas_ptregs.h6
-rw-r--r--arch/um/include/sysdep-i386/sc.h44
-rw-r--r--arch/um/include/sysdep-i386/sigcontext.h10
-rw-r--r--arch/um/include/sysdep-i386/thread.h11
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h8
-rw-r--r--arch/um/include/sysdep-x86_64/sc.h45
-rw-r--r--arch/um/include/sysdep-x86_64/sigcontext.h5
-rw-r--r--arch/um/include/sysdep-x86_64/thread.h10
-rw-r--r--arch/um/include/task.h9
-rw-r--r--arch/um/include/user.h4
-rw-r--r--arch/um/kernel/Makefile16
-rw-r--r--arch/um/kernel/helper.c12
-rw-r--r--arch/um/kernel/init_task.c5
-rw-r--r--arch/um/kernel/irq.c1
-rw-r--r--arch/um/kernel/mem.c16
-rw-r--r--arch/um/kernel/mem_user.c273
-rw-r--r--arch/um/kernel/process_kern.c22
-rw-r--r--arch/um/kernel/sigio_user.c2
-rw-r--r--arch/um/kernel/skas/Makefile2
-rw-r--r--arch/um/kernel/skas/include/mode_kern-skas.h2
-rw-r--r--arch/um/kernel/skas/include/uaccess-skas.h6
-rw-r--r--arch/um/kernel/skas/process_kern.c7
-rw-r--r--arch/um/kernel/skas/util/Makefile5
-rw-r--r--arch/um/kernel/skas/util/mk_ptregs-i386.c49
-rw-r--r--arch/um/kernel/skas/util/mk_ptregs-x86_64.c66
-rw-r--r--arch/um/kernel/sysrq.c8
-rw-r--r--arch/um/kernel/tempfile.c82
-rw-r--r--arch/um/kernel/tlb.c14
-rw-r--r--arch/um/kernel/trap_kern.c21
-rw-r--r--arch/um/kernel/tt/include/mode_kern-tt.h2
-rw-r--r--arch/um/kernel/tt/include/uaccess-tt.h6
-rw-r--r--arch/um/kernel/tt/mem_user.c1
-rw-r--r--arch/um/kernel/tt/process_kern.c8
-rw-r--r--arch/um/kernel/tt/uaccess_user.c11
-rw-r--r--arch/um/kernel/um_arch.c7
-rw-r--r--arch/um/kernel/umid.c41
-rw-r--r--arch/um/kernel/user_util.c18
-rw-r--r--arch/um/os-Linux/Makefile8
-rw-r--r--arch/um/os-Linux/aio.c211
-rw-r--r--arch/um/os-Linux/drivers/tuntap_user.c8
-rw-r--r--arch/um/os-Linux/elf_aux.c8
-rw-r--r--arch/um/os-Linux/file.c82
-rw-r--r--arch/um/os-Linux/mem.c161
-rw-r--r--arch/um/os-Linux/process.c1
-rw-r--r--arch/um/os-Linux/start_up.c120
-rw-r--r--arch/um/os-Linux/sys-i386/registers.c19
-rw-r--r--arch/um/os-Linux/sys-x86_64/registers.c19
-rw-r--r--arch/um/os-Linux/tt.c14
-rw-r--r--arch/um/os-Linux/util/Makefile4
-rw-r--r--arch/um/os-Linux/util/mk_user_constants.c23
-rw-r--r--arch/um/scripts/Makefile.rules4
-rw-r--r--arch/um/sys-i386/Makefile2
-rw-r--r--arch/um/sys-i386/kernel-offsets.c4
-rw-r--r--arch/um/sys-i386/ldt.c1
-rw-r--r--arch/um/sys-i386/sysrq.c13
-rw-r--r--arch/um/sys-i386/user-offsets.c71
-rw-r--r--arch/um/sys-i386/util/Makefile5
-rw-r--r--arch/um/sys-i386/util/mk_sc.c51
-rw-r--r--arch/um/sys-i386/util/mk_thread.c22
-rw-r--r--arch/um/sys-x86_64/Makefile2
-rw-r--r--arch/um/sys-x86_64/kernel-offsets.c2
-rw-r--r--arch/um/sys-x86_64/stub_segv.c37
-rw-r--r--arch/um/sys-x86_64/user-offsets.c117
-rw-r--r--arch/um/sys-x86_64/util/Makefile8
-rw-r--r--arch/um/sys-x86_64/util/mk_sc.c47
-rw-r--r--arch/um/sys-x86_64/util/mk_thread.c20
-rw-r--r--arch/um/util/Makefile5
-rw-r--r--arch/um/util/mk_constants.c32
-rw-r--r--arch/um/util/mk_task.c30
-rw-r--r--arch/x86_64/Kconfig2
-rw-r--r--arch/x86_64/ia32/ia32_signal.c6
-rw-r--r--arch/x86_64/kernel/e820.c2
-rw-r--r--arch/x86_64/kernel/head.S40
-rw-r--r--arch/x86_64/kernel/kprobes.c8
-rw-r--r--arch/x86_64/kernel/mce.c10
-rw-r--r--arch/x86_64/kernel/setup.c22
-rw-r--r--arch/x86_64/kernel/setup64.c4
-rw-r--r--arch/x86_64/kernel/smpboot.c6
-rw-r--r--arch/x86_64/kernel/suspend.c127
-rw-r--r--arch/x86_64/kernel/suspend_asm.S17
-rw-r--r--arch/x86_64/kernel/time.c3
-rw-r--r--arch/x86_64/mm/numa.c10
-rw-r--r--arch/x86_64/mm/pageattr.c2
-rw-r--r--arch/xtensa/kernel/pci.c4
-rw-r--r--arch/xtensa/kernel/platform.c2
-rw-r--r--arch/xtensa/kernel/process.c2
-rw-r--r--arch/xtensa/kernel/setup.c2
-rw-r--r--arch/xtensa/kernel/signal.c2
-rw-r--r--arch/xtensa/kernel/time.c2
-rw-r--r--arch/xtensa/mm/init.c2
-rw-r--r--drivers/acorn/char/pcf8583.c3
-rw-r--r--drivers/acpi/event.c5
-rw-r--r--drivers/acpi/glue.c8
-rw-r--r--drivers/atm/ambassador.c2
-rw-r--r--drivers/atm/firestream.c5
-rw-r--r--drivers/atm/fore200e.c10
-rw-r--r--drivers/base/class.c13
-rw-r--r--drivers/base/dd.c3
-rw-r--r--drivers/base/dmapool.c5
-rw-r--r--drivers/block/cciss.c5
-rw-r--r--drivers/block/ll_rw_blk.c38
-rw-r--r--drivers/block/paride/pf.c22
-rw-r--r--drivers/block/pktcdvd.c4
-rw-r--r--drivers/block/scsi_ioctl.c9
-rw-r--r--drivers/block/ub.c55
-rw-r--r--drivers/bluetooth/bpa10x.c2
-rw-r--r--drivers/bluetooth/hci_usb.c2
-rw-r--r--drivers/char/.gitignore3
-rw-r--r--drivers/char/agp/hp-agp.c2
-rw-r--r--drivers/char/agp/sgi-agp.c1
-rw-r--r--drivers/char/drm/drm_drv.c2
-rw-r--r--drivers/char/drm/drm_proc.c2
-rw-r--r--drivers/char/drm/drm_stub.c2
-rw-r--r--drivers/char/drm/drm_vm.c3
-rw-r--r--drivers/char/drm/mga_dma.c22
-rw-r--r--drivers/char/drm/mga_drv.h2
-rw-r--r--drivers/char/drm/mga_state.c2
-rw-r--r--drivers/char/drm/radeon_cp.c11
-rw-r--r--drivers/char/hpet.c1
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c6
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c2
-rw-r--r--drivers/char/mbcs.c3
-rw-r--r--drivers/char/n_r3964.c92
-rw-r--r--drivers/char/s3c2410-rtc.c1
-rw-r--r--drivers/char/watchdog/mv64x60_wdt.c14
-rw-r--r--drivers/char/watchdog/pcwd_pci.c239
-rw-r--r--drivers/connector/cn_queue.c32
-rw-r--r--drivers/connector/connector.c76
-rw-r--r--drivers/firmware/dell_rbu.c361
-rw-r--r--drivers/hwmon/Kconfig9
-rw-r--r--drivers/hwmon/hdaps.c369
-rw-r--r--drivers/i2c/busses/Kconfig12
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-pmac-smu.c316
-rw-r--r--drivers/ide/ide-io.c8
-rw-r--r--drivers/ide/ide-taskfile.c1
-rw-r--r--drivers/ide/legacy/ide-cs.c2
-rw-r--r--drivers/ieee1394/amdtp.c1
-rw-r--r--drivers/ieee1394/csr1212.h1
-rw-r--r--drivers/ieee1394/dv1394.c1
-rw-r--r--drivers/ieee1394/eth1394.c12
-rw-r--r--drivers/ieee1394/eth1394.h6
-rw-r--r--drivers/ieee1394/hosts.c3
-rw-r--r--drivers/ieee1394/hosts.h8
-rw-r--r--drivers/ieee1394/ieee1394_core.c32
-rw-r--r--drivers/ieee1394/nodemgr.c23
-rw-r--r--drivers/ieee1394/ohci1394.c10
-rw-r--r--drivers/ieee1394/raw1394.c103
-rw-r--r--drivers/ieee1394/sbp2.c107
-rw-r--r--drivers/ieee1394/video1394.c1
-rw-r--r--drivers/infiniband/core/mad.c2
-rw-r--r--drivers/infiniband/core/mad_rmpp.c19
-rw-r--r--drivers/infiniband/core/sa_query.c6
-rw-r--r--drivers/infiniband/core/user_mad.c5
-rw-r--r--drivers/infiniband/core/uverbs.h1
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c120
-rw-r--r--drivers/infiniband/core/uverbs_main.c27
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c39
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c45
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c19
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c51
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c25
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c13
-rw-r--r--drivers/input/input.c1
-rw-r--r--drivers/input/keyboard/Kconfig2
-rw-r--r--drivers/input/keyboard/spitzkbd.c2
-rw-r--r--drivers/input/misc/uinput.c4
-rw-r--r--drivers/isdn/divert/divert_procfs.c6
-rw-r--r--drivers/isdn/hardware/eicon/diva_didd.c6
-rw-r--r--drivers/isdn/hardware/eicon/divasproc.c2
-rw-r--r--drivers/isdn/hisax/st5481.h4
-rw-r--r--drivers/isdn/hisax/st5481_b.c20
-rw-r--r--drivers/isdn/hisax/st5481_d.c26
-rw-r--r--drivers/isdn/hisax/st5481_init.c4
-rw-r--r--drivers/isdn/hisax/st5481_usb.c68
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c2
-rw-r--r--drivers/macintosh/smu.c1032
-rw-r--r--drivers/macintosh/therm_adt746x.c2
-rw-r--r--drivers/macintosh/therm_pm72.c2
-rw-r--r--drivers/macintosh/therm_windtunnel.c2
-rw-r--r--drivers/md/dm-crypt.c2
-rw-r--r--drivers/md/dm-io.c2
-rw-r--r--drivers/md/dm-ioctl.c9
-rw-r--r--drivers/md/dm-mpath.c16
-rw-r--r--drivers/md/dm-raid1.c2
-rw-r--r--drivers/md/md.c14
-rw-r--r--drivers/md/multipath.c2
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/md/raid6.h4
-rw-r--r--drivers/md/raid6algos.c1
-rw-r--r--drivers/md/raid6altivec.uc18
-rw-r--r--drivers/md/raid6test/Makefile27
-rw-r--r--drivers/media/dvb/frontends/tda10021.c4
-rw-r--r--drivers/media/radio/radio-cadet.c2
-rw-r--r--drivers/media/video/Kconfig1
-rw-r--r--drivers/media/video/bttv-cards.c6
-rw-r--r--drivers/media/video/bttv-driver.c14
-rw-r--r--drivers/media/video/bttvp.h2
-rw-r--r--drivers/media/video/cpia.c2
-rw-r--r--drivers/media/video/rds.h2
-rw-r--r--drivers/media/video/saa6588.c4
-rw-r--r--drivers/media/video/vpx3220.c32
-rw-r--r--drivers/message/fusion/Kconfig17
-rw-r--r--drivers/message/fusion/Makefile1
-rw-r--r--drivers/message/fusion/mptbase.c963
-rw-r--r--drivers/message/fusion/mptbase.h56
-rw-r--r--drivers/message/fusion/mptctl.c4
-rw-r--r--drivers/message/fusion/mptfc.c2
-rw-r--r--drivers/message/fusion/mptlan.c7
-rw-r--r--drivers/message/fusion/mptsas.c1239
-rw-r--r--drivers/message/fusion/mptscsih.c463
-rw-r--r--drivers/message/fusion/mptscsih.h7
-rw-r--r--drivers/message/fusion/mptspi.c2
-rw-r--r--drivers/message/i2o/config-osm.c5
-rw-r--r--drivers/mfd/ucb1x00-core.c24
-rw-r--r--drivers/mfd/ucb1x00-ts.c4
-rw-r--r--drivers/mfd/ucb1x00.h2
-rw-r--r--drivers/mtd/devices/docecc.c8
-rw-r--r--drivers/mtd/maps/bast-flash.c1
-rw-r--r--drivers/mtd/maps/ixp2000.c1
-rw-r--r--drivers/mtd/maps/ixp4xx.c3
-rw-r--r--drivers/mtd/maps/omap_nor.c1
-rw-r--r--drivers/mtd/maps/sa1100-flash.c1
-rw-r--r--drivers/mtd/maps/sharpsl-flash.c2
-rw-r--r--drivers/mtd/nand/s3c2410.c1
-rw-r--r--drivers/mtd/nand/sharpsl.c10
-rw-r--r--drivers/net/8390.c2
-rw-r--r--drivers/net/Kconfig16
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/arm/am79c961a.c22
-rw-r--r--drivers/net/bmac.c2
-rw-r--r--drivers/net/bonding/bond_main.c298
-rw-r--r--drivers/net/bonding/bonding.h4
-rw-r--r--drivers/net/cassini.c5237
-rw-r--r--drivers/net/cassini.h4425
-rw-r--r--drivers/net/cs89x0.c1
-rw-r--r--drivers/net/e100.c224
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c31
-rw-r--r--drivers/net/ibmveth.c6
-rw-r--r--drivers/net/irda/vlsi_ir.c4
-rw-r--r--drivers/net/ns83820.c2
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c2
-rw-r--r--drivers/net/pppoe.c4
-rw-r--r--drivers/net/r8169.c7
-rw-r--r--drivers/net/sk98lin/skge.c8
-rw-r--r--drivers/net/skge.c240
-rw-r--r--drivers/net/skge.h2
-rw-r--r--drivers/net/starfire.c46
-rw-r--r--drivers/net/sungem.h3
-rw-r--r--drivers/net/tg3.c215
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/tokenring/ibmtr.c5
-rw-r--r--drivers/net/tulip/21142.c2
-rw-r--r--drivers/net/wan/hdlc_cisco.c2
-rw-r--r--drivers/net/wan/sdlamain.c23
-rw-r--r--drivers/net/wan/syncppp.c2
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/orinoco.c21
-rw-r--r--drivers/net/wireless/strip.c4
-rw-r--r--drivers/parisc/led.c5
-rw-r--r--drivers/pci/.gitignore4
-rw-r--r--drivers/pci/hotplug.c4
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c2
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c4
-rw-r--r--drivers/pci/hotplug/rpadlpar_sysfs.c4
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c6
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c3
-rw-r--r--drivers/pci/pci-sysfs.c2
-rw-r--r--drivers/pci/probe.c22
-rw-r--r--drivers/pci/quirks.c105
-rw-r--r--drivers/pci/setup-bus.c2
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/pcmcia/cardbus.c5
-rw-r--r--drivers/pcmcia/cs.c3
-rw-r--r--drivers/pcmcia/omap_cf.c1
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c10
-rw-r--r--drivers/pcmcia/soc_common.c14
-rw-r--r--drivers/pcmcia/ti113x.h118
-rw-r--r--drivers/pcmcia/yenta_socket.c62
-rw-r--r--drivers/s390/cio/blacklist.c4
-rw-r--r--drivers/s390/cio/ccwgroup.c2
-rw-r--r--drivers/s390/cio/device.c2
-rw-r--r--drivers/s390/crypto/z90main.c3
-rw-r--r--drivers/s390/net/qeth.h2
-rw-r--r--drivers/s390/net/qeth_main.c41
-rw-r--r--drivers/s390/scsi/Makefile2
-rw-r--r--drivers/s390/scsi/zfcp_aux.c186
-rw-r--r--drivers/s390/scsi/zfcp_ccw.c10
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c995
-rw-r--r--drivers/s390/scsi/zfcp_def.h307
-rw-r--r--drivers/s390/scsi/zfcp_erp.c135
-rw-r--r--drivers/s390/scsi/zfcp_ext.h30
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c769
-rw-r--r--drivers/s390/scsi/zfcp_fsf.h54
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c30
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c297
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_adapter.c14
-rw-r--r--drivers/scsi/3w-9xxx.c55
-rw-r--r--drivers/scsi/3w-9xxx.h17
-rw-r--r--drivers/scsi/Kconfig5
-rw-r--r--drivers/scsi/Makefile1
-rw-r--r--drivers/scsi/NCR5380.c2
-rw-r--r--drivers/scsi/aacraid/aachba.c283
-rw-r--r--drivers/scsi/aacraid/aacraid.h19
-rw-r--r--drivers/scsi/aacraid/comminit.c17
-rw-r--r--drivers/scsi/aacraid/commsup.c581
-rw-r--r--drivers/scsi/aacraid/linit.c14
-rw-r--r--drivers/scsi/aic7xxx/aic7770_osm.c3
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c8
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c3
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c17
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm_pci.c11
-rw-r--r--drivers/scsi/ata_piix.c1
-rw-r--r--drivers/scsi/atp870u.c6
-rw-r--r--drivers/scsi/atp870u.h5
-rw-r--r--drivers/scsi/fd_mcs.c2
-rw-r--r--drivers/scsi/hosts.c37
-rw-r--r--drivers/scsi/ibmmca.c2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c10
-rw-r--r--drivers/scsi/libata-core.c81
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c8
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c6
-rw-r--r--drivers/scsi/megaraid.c70
-rw-r--r--drivers/scsi/megaraid/Kconfig.megaraid9
-rw-r--r--drivers/scsi/megaraid/Makefile1
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c2806
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.h1142
-rw-r--r--drivers/scsi/mesh.c29
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c21
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_rscn.c2
-rw-r--r--drivers/scsi/qlogicpti.c39
-rw-r--r--drivers/scsi/sata_nv.c14
-rw-r--r--drivers/scsi/scsi.c5
-rw-r--r--drivers/scsi/scsi_devinfo.c2
-rw-r--r--drivers/scsi/scsi_error.c80
-rw-r--r--drivers/scsi/scsi_ioctl.c2
-rw-r--r--drivers/scsi/scsi_lib.c19
-rw-r--r--drivers/scsi/scsi_scan.c116
-rw-r--r--drivers/scsi/scsi_sysfs.c17
-rw-r--r--drivers/scsi/scsi_transport_fc.c13
-rw-r--r--drivers/scsi/scsi_transport_sas.c9
-rw-r--r--drivers/scsi/sd.c1
-rw-r--r--drivers/scsi/sg.c5
-rw-r--r--drivers/scsi/sr.c1
-rw-r--r--drivers/scsi/st.c1
-rw-r--r--drivers/serial/8250_pci.c26
-rw-r--r--drivers/serial/8250_pnp.c4
-rw-r--r--drivers/serial/clps711x.c2
-rw-r--r--drivers/serial/imx.c50
-rw-r--r--drivers/serial/ioc4_serial.c12
-rw-r--r--drivers/serial/mpc52xx_uart.c2
-rw-r--r--drivers/serial/pxa.c2
-rw-r--r--drivers/serial/s3c2410.c24
-rw-r--r--drivers/serial/serial_cs.c1
-rw-r--r--drivers/serial/sh-sci.c2
-rw-r--r--drivers/serial/sunsab.c1
-rw-r--r--drivers/serial/sunsu.c4
-rw-r--r--drivers/serial/sunzilog.c5
-rw-r--r--drivers/usb/core/devio.c16
-rw-r--r--drivers/usb/core/hcd-pci.c9
-rw-r--r--drivers/usb/core/inode.c2
-rw-r--r--drivers/usb/core/message.c2
-rw-r--r--drivers/usb/core/usb.c6
-rw-r--r--drivers/usb/core/usb.h3
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c4
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.h8
-rw-r--r--drivers/usb/host/isp116x-hcd.c3
-rw-r--r--drivers/usb/host/ohci-lh7a404.c2
-rw-r--r--drivers/usb/host/ohci-omap.c1
-rw-r--r--drivers/usb/host/ohci-s3c2410.c1
-rw-r--r--drivers/usb/host/sl811-hcd.c16
-rw-r--r--drivers/usb/input/hid-core.c3
-rw-r--r--drivers/usb/media/vicam.c4
-rw-r--r--drivers/usb/net/pegasus.c29
-rw-r--r--drivers/usb/serial/airprime.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c8
-rw-r--r--drivers/usb/serial/generic.c2
-rw-r--r--drivers/usb/serial/option.c11
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/aty/radeon_base.c2
-rw-r--r--drivers/video/aty/radeon_pm.c14
-rw-r--r--drivers/video/aty/radeonfb.h2
-rw-r--r--drivers/video/aty/xlinit.c11
-rw-r--r--drivers/video/backlight/corgi_bl.c8
-rw-r--r--drivers/video/console/vgacon.c9
-rw-r--r--drivers/video/cyblafb.c11
-rw-r--r--drivers/video/fbcvt.c8
-rw-r--r--drivers/video/fbsysfs.c8
-rw-r--r--drivers/video/i810/i810-i2c.c16
-rw-r--r--drivers/video/imxfb.c3
-rw-r--r--drivers/video/intelfb/intelfbdrv.c21
-rw-r--r--drivers/video/logo/.gitignore7
-rw-r--r--drivers/video/nvidia/nvidia.c5
-rw-r--r--drivers/video/p9100.c4
-rw-r--r--drivers/video/pxafb.c108
-rw-r--r--drivers/video/pxafb.h9
-rw-r--r--drivers/video/s3c2410fb.c4
-rw-r--r--drivers/video/sa1100fb.c2
-rw-r--r--drivers/video/vesafb.c6
-rw-r--r--drivers/w1/w1.c3
-rw-r--r--fs/9p/conv.c157
-rw-r--r--fs/9p/fid.c176
-rw-r--r--fs/9p/fid.h7
-rw-r--r--fs/9p/v9fs.c8
-rw-r--r--fs/9p/vfs_dentry.c2
-rw-r--r--fs/9p/vfs_dir.c11
-rw-r--r--fs/9p/vfs_file.c202
-rw-r--r--fs/9p/vfs_inode.c95
-rw-r--r--fs/9p/vfs_super.c39
-rw-r--r--fs/Kconfig3
-rw-r--r--fs/aio.c129
-rw-r--r--fs/bfs/dir.c2
-rw-r--r--fs/bfs/inode.c44
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--fs/bio.c10
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/cifs/cifsfs.c2
-rw-r--r--fs/cifs/connect.c2
-rw-r--r--fs/dcache.c3
-rw-r--r--fs/eventpoll.c48
-rw-r--r--fs/ext2/ialloc.c25
-rw-r--r--fs/ext3/balloc.c6
-rw-r--r--fs/ext3/ialloc.c29
-rw-r--r--fs/ext3/resize.c6
-rw-r--r--fs/ext3/super.c11
-rw-r--r--fs/fat/file.c37
-rw-r--r--fs/fat/inode.c26
-rw-r--r--fs/fuse/dir.c6
-rw-r--r--fs/fuse/file.c4
-rw-r--r--fs/hfsplus/super.c1
-rw-r--r--fs/hostfs/hostfs_kern.c7
-rw-r--r--fs/inotify.c1
-rw-r--r--fs/jfs/inode.c3
-rw-r--r--fs/jfs/jfs_dmap.c2
-rw-r--r--fs/jfs/jfs_txnmgr.c15
-rw-r--r--fs/jfs/jfs_txnmgr.h1
-rw-r--r--fs/locks.c3
-rw-r--r--fs/mpage.c2
-rw-r--r--fs/namei.c6
-rw-r--r--fs/nfs/delegation.c4
-rw-r--r--fs/nfs/file.c3
-rw-r--r--fs/nfs/inode.c9
-rw-r--r--fs/nfs/read.c5
-rw-r--r--fs/nfs_common/nfsacl.c70
-rw-r--r--fs/ntfs/ChangeLog15
-rw-r--r--fs/ntfs/aops.c122
-rw-r--r--fs/ntfs/bitmap.c5
-rw-r--r--fs/ntfs/inode.c9
-rw-r--r--fs/ntfs/layout.h8
-rw-r--r--fs/ntfs/lcnalloc.c31
-rw-r--r--fs/ntfs/lcnalloc.h27
-rw-r--r--fs/ntfs/logfile.c30
-rw-r--r--fs/ntfs/logfile.h2
-rw-r--r--fs/ntfs/malloc.h4
-rw-r--r--fs/ntfs/mft.c5
-rw-r--r--fs/ntfs/runlist.c169
-rw-r--r--fs/ntfs/unistr.c2
-rw-r--r--fs/posix_acl.c6
-rw-r--r--fs/proc/array.c3
-rw-r--r--fs/proc/base.c98
-rw-r--r--fs/proc/nommu.c1
-rw-r--r--fs/read_write.c3
-rw-r--r--fs/relayfs/buffers.c2
-rw-r--r--fs/xfs/linux-2.6/kmem.c10
-rw-r--r--fs/xfs/linux-2.6/kmem.h13
-rw-r--r--include/asm-alpha/atomic.h14
-rw-r--r--include/asm-alpha/barrier.h34
-rw-r--r--include/asm-alpha/compiler.h5
-rw-r--r--include/asm-alpha/futex.h2
-rw-r--r--include/asm-alpha/system.h31
-rw-r--r--include/asm-arm/arch-h720x/system.h8
-rw-r--r--include/asm-arm/arch-imx/imx-regs.h48
-rw-r--r--include/asm-arm/arch-ixp4xx/entry-macro.S9
-rw-r--r--include/asm-arm/arch-ixp4xx/hardware.h2
-rw-r--r--include/asm-arm/arch-ixp4xx/platform.h2
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h9
-rw-r--r--include/asm-arm/arch-pxa/pxafb.h1
-rw-r--r--include/asm-arm/arch-rpc/hardware.h4
-rw-r--r--include/asm-arm/arch-s3c2410/anubis-map.h10
-rw-r--r--include/asm-arm/arch-s3c2410/hardware.h7
-rw-r--r--include/asm-arm/arch-s3c2410/io.h58
-rw-r--r--include/asm-arm/arch-s3c2410/regs-clock.h21
-rw-r--r--include/asm-arm/arch-versatile/io.h6
-rw-r--r--include/asm-arm/bitops.h1
-rw-r--r--include/asm-arm/elf.h2
-rw-r--r--include/asm-arm/futex.h2
-rw-r--r--include/asm-arm/hardware/scoop.h2
-rw-r--r--include/asm-arm/io.h6
-rw-r--r--include/asm-arm/locks.h4
-rw-r--r--include/asm-arm/mach/arch.h2
-rw-r--r--include/asm-arm/setup.h4
-rw-r--r--include/asm-arm/signal.h1
-rw-r--r--include/asm-arm26/futex.h2
-rw-r--r--include/asm-cris/futex.h2
-rw-r--r--include/asm-frv/futex.h2
-rw-r--r--include/asm-generic/dma-mapping.h4
-rw-r--r--include/asm-generic/pgtable.h13
-rw-r--r--include/asm-h8300/futex.h2
-rw-r--r--include/asm-i386/dma-mapping.h2
-rw-r--r--include/asm-i386/futex.h2
-rw-r--r--include/asm-i386/hw_irq.h2
-rw-r--r--include/asm-ia64/futex.h2
-rw-r--r--include/asm-ia64/machvec_hpzx1.h21
-rw-r--r--include/asm-ia64/machvec_hpzx1_swiotlb.h3
-rw-r--r--include/asm-ia64/mca.h5
-rw-r--r--include/asm-ia64/sn/io.h9
-rw-r--r--include/asm-ia64/sn/l1.h12
-rw-r--r--include/asm-ia64/sn/sn_sal.h43
-rw-r--r--include/asm-ia64/sn/tioca_provider.h14
-rw-r--r--include/asm-ia64/sn/tiocx.h3
-rw-r--r--include/asm-ia64/uaccess.h12
-rw-r--r--include/asm-m32r/futex.h2
-rw-r--r--include/asm-m32r/io.h2
-rw-r--r--include/asm-m32r/uaccess.h10
-rw-r--r--include/asm-m68k/futex.h2
-rw-r--r--include/asm-m68knommu/futex.h2
-rw-r--r--include/asm-mips/pgtable.h2
-rw-r--r--include/asm-parisc/futex.h2
-rw-r--r--include/asm-powerpc/timex.h2
-rw-r--r--include/asm-ppc/cputable.h1
-rw-r--r--include/asm-ppc/dma-mapping.h2
-rw-r--r--include/asm-ppc/futex.h2
-rw-r--r--include/asm-ppc/io.h20
-rw-r--r--include/asm-ppc/irq.h10
-rw-r--r--include/asm-ppc/macio.h1
-rw-r--r--include/asm-ppc/mpc8xx.h16
-rw-r--r--include/asm-ppc/mv64x60.h4
-rw-r--r--include/asm-ppc/of_device.h5
-rw-r--r--include/asm-ppc/ppc_sys.h2
-rw-r--r--include/asm-ppc64/dma-mapping.h4
-rw-r--r--include/asm-ppc64/iommu.h2
-rw-r--r--include/asm-ppc64/smu.h365
-rw-r--r--include/asm-ppc64/tlbflush.h1
-rw-r--r--include/asm-ppc64/uaccess.h6
-rw-r--r--include/asm-s390/futex.h2
-rw-r--r--include/asm-s390/sigcontext.h2
-rw-r--r--include/asm-s390/signal.h2
-rw-r--r--include/asm-sh/futex.h2
-rw-r--r--include/asm-sh64/futex.h2
-rw-r--r--include/asm-sparc/btfixup.h24
-rw-r--r--include/asm-sparc/cache.h18
-rw-r--r--include/asm-sparc/cypress.h8
-rw-r--r--include/asm-sparc/delay.h2
-rw-r--r--include/asm-sparc/dma.h2
-rw-r--r--include/asm-sparc/futex.h2
-rw-r--r--include/asm-sparc/iommu.h4
-rw-r--r--include/asm-sparc/kdebug.h2
-rw-r--r--include/asm-sparc/mbus.h4
-rw-r--r--include/asm-sparc/msi.h2
-rw-r--r--include/asm-sparc/mxcc.h8
-rw-r--r--include/asm-sparc/obio.h30
-rw-r--r--include/asm-sparc/pci.h6
-rw-r--r--include/asm-sparc/pgtable.h46
-rw-r--r--include/asm-sparc/pgtsrmmu.h30
-rw-r--r--include/asm-sparc/processor.h2
-rw-r--r--include/asm-sparc/psr.h6
-rw-r--r--include/asm-sparc/sbi.h10
-rw-r--r--include/asm-sparc/sbus.h6
-rw-r--r--include/asm-sparc/smp.h26
-rw-r--r--include/asm-sparc/smpprim.h8
-rw-r--r--include/asm-sparc/spinlock.h10
-rw-r--r--include/asm-sparc/system.h2
-rw-r--r--include/asm-sparc/traps.h2
-rw-r--r--include/asm-sparc64/cacheflush.h12
-rw-r--r--include/asm-sparc64/cpudata.h10
-rw-r--r--include/asm-sparc64/futex.h2
-rw-r--r--include/asm-sparc64/head.h9
-rw-r--r--include/asm-sparc64/ide.h1
-rw-r--r--include/asm-sparc64/openprom.h4
-rw-r--r--include/asm-sparc64/oplib.h66
-rw-r--r--include/asm-sparc64/page.h24
-rw-r--r--include/asm-sparc64/pbm.h30
-rw-r--r--include/asm-sparc64/pgalloc.h1
-rw-r--r--include/asm-sparc64/pgtable.h34
-rw-r--r--include/asm-sparc64/uaccess.h24
-rw-r--r--include/asm-um/futex.h51
-rw-r--r--include/asm-um/pgtable.h1
-rw-r--r--include/asm-um/processor-generic.h24
-rw-r--r--include/asm-um/processor-i386.h15
-rw-r--r--include/asm-um/processor-x86_64.h14
-rw-r--r--include/asm-um/system-i386.h2
-rw-r--r--include/asm-um/uaccess.h2
-rw-r--r--include/asm-v850/futex.h2
-rw-r--r--include/asm-x86_64/desc.h2
-rw-r--r--include/asm-x86_64/msr.h1
-rw-r--r--include/asm-x86_64/pgtable.h2
-rw-r--r--include/asm-x86_64/smp.h1
-rw-r--r--include/asm-xtensa/atomic.h2
-rw-r--r--include/asm-xtensa/bitops.h2
-rw-r--r--include/asm-xtensa/hardirq.h1
-rw-r--r--include/asm-xtensa/semaphore.h49
-rw-r--r--include/asm-xtensa/system.h16
-rw-r--r--include/linux/acct.h4
-rw-r--r--include/linux/aio.h41
-rw-r--r--include/linux/atmdev.h12
-rw-r--r--include/linux/bfs_fs.h42
-rw-r--r--include/linux/bio.h6
-rw-r--r--include/linux/bootmem.h32
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/byteorder/generic.h4
-rw-r--r--include/linux/connector.h23
-rw-r--r--include/linux/cpumask.h10
-rw-r--r--include/linux/cpuset.h5
-rw-r--r--include/linux/dccp.h59
-rw-r--r--include/linux/device.h5
-rw-r--r--include/linux/dmapool.h2
-rw-r--r--include/linux/gfp.h14
-rw-r--r--include/linux/hugetlb.h3
-rw-r--r--include/linux/i2c.h5
-rw-r--r--include/linux/idr.h1
-rw-r--r--include/linux/if_ether.h2
-rw-r--r--include/linux/if_vlan.h8
-rw-r--r--include/linux/inetdevice.h12
-rw-r--r--include/linux/ipv6.h5
-rw-r--r--include/linux/jbd.h2
-rw-r--r--include/linux/joystick.h24
-rw-r--r--include/linux/key-ui.h87
-rw-r--r--include/linux/key.h78
-rw-r--r--include/linux/kfifo.h4
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/list.h39
-rw-r--r--include/linux/mempool.h9
-rw-r--r--include/linux/mm.h10
-rw-r--r--include/linux/mod_devicetable.h7
-rw-r--r--include/linux/netdevice.h89
-rw-r--r--include/linux/netfilter/nfnetlink.h12
-rw-r--r--include/linux/netfilter/nfnetlink_conntrack.h15
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack.h47
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_pptp.h325
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h114
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_protocol.h3
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_tuple.h11
-rw-r--r--include/linux/netfilter_ipv4/ip_nat.h4
-rw-r--r--include/linux/netfilter_ipv4/ip_nat_core.h12
-rw-r--r--include/linux/netfilter_ipv4/ip_nat_pptp.h11
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h3
-rw-r--r--include/linux/netlink.h2
-rw-r--r--include/linux/netpoll.h2
-rw-r--r--include/linux/pagemap.h2
-rw-r--r--include/linux/pci_ids.h22
-rw-r--r--include/linux/posix_acl.h6
-rw-r--r--include/linux/radix-tree.h2
-rw-r--r--include/linux/rcupdate.h1
-rw-r--r--include/linux/reboot.h4
-rw-r--r--include/linux/sched.h13
-rw-r--r--include/linux/security.h6
-rw-r--r--include/linux/skbuff.h40
-rw-r--r--include/linux/slab.h19
-rw-r--r--include/linux/string.h2
-rw-r--r--include/linux/suspend.h2
-rw-r--r--include/linux/swap.h2
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--include/linux/sysctl.h26
-rw-r--r--include/linux/tc_ematch/tc_em_meta.h2
-rw-r--r--include/linux/textsearch.h3
-rw-r--r--include/linux/tfrc.h35
-rw-r--r--include/linux/types.h4
-rw-r--r--include/linux/vmalloc.h4
-rw-r--r--include/net/ax25.h2
-rw-r--r--include/net/bluetooth/bluetooth.h2
-rw-r--r--include/net/bluetooth/rfcomm.h2
-rw-r--r--include/net/dn_nsp.h8
-rw-r--r--include/net/dn_route.h2
-rw-r--r--include/net/inet6_hashtables.h21
-rw-r--r--include/net/inet_connection_sock.h2
-rw-r--r--include/net/inet_hashtables.h66
-rw-r--r--include/net/inet_timewait_sock.h5
-rw-r--r--include/net/ip_vs.h2
-rw-r--r--include/net/llc.h30
-rw-r--r--include/net/llc_conn.h15
-rw-r--r--include/net/llc_pdu.h4
-rw-r--r--include/net/llc_sap.h8
-rw-r--r--include/net/sctp/sctp.h2
-rw-r--r--include/net/sctp/sm.h10
-rw-r--r--include/net/sctp/structs.h24
-rw-r--r--include/net/sctp/ulpevent.h16
-rw-r--r--include/net/sctp/ulpqueue.h11
-rw-r--r--include/net/sctp/user.h33
-rw-r--r--include/net/sock.h21
-rw-r--r--include/net/tcp.h3
-rw-r--r--include/net/xfrm.h7
-rw-r--r--include/pcmcia/ss.h9
-rw-r--r--include/rdma/ib_mad.h17
-rw-r--r--include/rdma/ib_sa.h10
-rw-r--r--include/rdma/ib_verbs.h1
-rw-r--r--include/rxrpc/call.h2
-rw-r--r--include/rxrpc/message.h2
-rw-r--r--include/scsi/scsi_device.h1
-rw-r--r--include/scsi/scsi_host.h11
-rw-r--r--include/scsi/scsi_transport_fc.h4
-rw-r--r--include/sound/ac97_codec.h2
-rw-r--r--include/sound/core.h8
-rw-r--r--include/sound/driver.h2
-rw-r--r--include/sound/emu10k1.h2
-rw-r--r--ipc/mqueue.c1
-rw-r--r--kernel/audit.c2
-rw-r--r--kernel/cpuset.c13
-rw-r--r--kernel/exit.c9
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/kfifo.c4
-rw-r--r--kernel/params.c10
-rw-r--r--kernel/posix-cpu-timers.c91
-rw-r--r--kernel/posix-timers.c2
-rw-r--r--kernel/power/Kconfig2
-rw-r--r--kernel/power/disk.c6
-rw-r--r--kernel/power/power.h7
-rw-r--r--kernel/power/swsusp.c36
-rw-r--r--kernel/printk.c7
-rw-r--r--kernel/rcupdate.c13
-rw-r--r--kernel/sched.c1
-rw-r--r--kernel/signal.c87
-rw-r--r--kernel/sys.c55
-rw-r--r--kernel/time.c1
-rw-r--r--lib/.gitignore6
-rw-r--r--lib/idr.c13
-rw-r--r--lib/radix-tree.c2
-rw-r--r--lib/ts_bm.c2
-rw-r--r--lib/ts_fsm.c2
-rw-r--r--lib/ts_kmp.c2
-rw-r--r--mm/Kconfig4
-rw-r--r--mm/bootmem.c45
-rw-r--r--mm/fremap.c3
-rw-r--r--mm/highmem.c2
-rw-r--r--mm/hugetlb.c57
-rw-r--r--mm/madvise.c11
-rw-r--r--mm/memory.c4
-rw-r--r--mm/mempolicy.c8
-rw-r--r--mm/mempool.c6
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/mprotect.c3
-rw-r--r--mm/mremap.c6
-rw-r--r--mm/nommu.c3
-rw-r--r--mm/oom_kill.c2
-rw-r--r--mm/page_alloc.c14
-rw-r--r--mm/page_io.c2
-rw-r--r--mm/shmem.c3
-rw-r--r--mm/slab.c100
-rw-r--r--mm/swap_state.c2
-rw-r--r--mm/swapfile.c1
-rw-r--r--mm/vmalloc.c4
-rw-r--r--mm/vmscan.c13
-rw-r--r--net/802/p8022.c2
-rw-r--r--net/802/psnap.c2
-rw-r--r--net/802/tr.c7
-rw-r--r--net/8021q/vlan_dev.c2
-rw-r--r--net/Kconfig3
-rw-r--r--net/appletalk/ddp.c31
-rw-r--r--net/atm/addr.c55
-rw-r--r--net/atm/addr.h12
-rw-r--r--net/atm/atm_misc.c2
-rw-r--r--net/atm/br2684.c2
-rw-r--r--net/atm/clip.c2
-rw-r--r--net/atm/common.c6
-rw-r--r--net/atm/ioctl.c34
-rw-r--r--net/atm/lec.c43
-rw-r--r--net/atm/resources.c20
-rw-r--r--net/atm/signaling.c8
-rw-r--r--net/atm/svc.c1
-rw-r--r--net/ax25/ax25_in.c2
-rw-r--r--net/bluetooth/l2cap.c2
-rw-r--r--net/bluetooth/rfcomm/core.c2
-rw-r--r--net/bluetooth/rfcomm/sock.c2
-rw-r--r--net/bluetooth/rfcomm/tty.c2
-rw-r--r--net/bluetooth/sco.c2
-rw-r--r--net/bridge/br_forward.c3
-rw-r--r--net/bridge/br_if.c2
-rw-r--r--net/bridge/netfilter/ebtables.c27
-rw-r--r--net/core/datagram.c81
-rw-r--r--net/core/dev.c6
-rw-r--r--net/core/neighbour.c71
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/core/pktgen.c26
-rw-r--r--net/core/skbuff.c25
-rw-r--r--net/core/sock.c30
-rw-r--r--net/core/wireless.c9
-rw-r--r--net/dccp/Makefile2
-rw-r--r--net/dccp/ackvec.c419
-rw-r--r--net/dccp/ackvec.h133
-rw-r--r--net/dccp/ccid.h35
-rw-r--r--net/dccp/ccids/ccid3.c56
-rw-r--r--net/dccp/ccids/ccid3.h23
-rw-r--r--net/dccp/ccids/lib/loss_interval.h2
-rw-r--r--net/dccp/ccids/lib/packet_history.h4
-rw-r--r--net/dccp/dccp.h91
-rw-r--r--net/dccp/input.c95
-rw-r--r--net/dccp/ipv4.c115
-rw-r--r--net/dccp/minisocks.c19
-rw-r--r--net/dccp/options.c443
-rw-r--r--net/dccp/output.c36
-rw-r--r--net/dccp/proto.c96
-rw-r--r--net/decnet/af_decnet.c4
-rw-r--r--net/decnet/dn_nsp_out.c21
-rw-r--r--net/econet/af_econet.c2
-rw-r--r--net/ethernet/eth.c31
-rw-r--r--net/ieee80211/ieee80211_module.c2
-rw-r--r--net/ieee80211/ieee80211_tx.c2
-rw-r--r--net/ipv4/arp.c21
-rw-r--r--net/ipv4/devinet.c22
-rw-r--r--net/ipv4/esp4.c17
-rw-r--r--net/ipv4/fib_frontend.c4
-rw-r--r--net/ipv4/fib_semantics.c4
-rw-r--r--net/ipv4/fib_trie.c72
-rw-r--r--net/ipv4/icmp.c2
-rw-r--r--net/ipv4/igmp.c2
-rw-r--r--net/ipv4/inet_connection_sock.c2
-rw-r--r--net/ipv4/inet_timewait_sock.c7
-rw-r--r--net/ipv4/ip_gre.c4
-rw-r--r--net/ipv4/ip_output.c3
-rw-r--r--net/ipv4/ipmr.c6
-rw-r--r--net/ipv4/ipvs/ip_vs_app.c2
-rw-r--r--net/ipv4/netfilter/Kconfig55
-rw-r--r--net/ipv4/netfilter/Makefile12
-rw-r--r--net/ipv4/netfilter/arp_tables.c14
-rw-r--r--net/ipv4/netfilter/ip_conntrack_amanda.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c51
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_pptp.c806
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netbios_ns.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c52
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_gre.c328
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_icmp.c3
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_sctp.c1
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c30
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c6
-rw-r--r--net/ipv4/netfilter/ip_nat_core.c37
-rw-r--r--net/ipv4/netfilter/ip_nat_helper.c4
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_pptp.c401
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_gre.c214
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c25
-rw-r--r--net/ipv4/netfilter/ip_queue.c4
-rw-r--r--net/ipv4/netfilter/ip_tables.c17
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c223
-rw-r--r--net/ipv4/netfilter/ipt_REDIRECT.c2
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c4
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/route.c6
-rw-r--r--net/ipv4/tcp_bic.c2
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/tcp_ipv4.c11
-rw-r--r--net/ipv4/tcp_minisocks.c2
-rw-r--r--net/ipv4/tcp_output.c26
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/esp6.c18
-rw-r--r--net/ipv6/ip6_flowlabel.c2
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/mcast.c2
-rw-r--r--net/ipv6/ndisc.c2
-rw-r--r--net/ipv6/netfilter/Kconfig11
-rw-r--r--net/ipv6/netfilter/Makefile2
-rw-r--r--net/ipv6/netfilter/ip6_queue.c4
-rw-r--r--net/ipv6/netfilter/ip6_tables.c69
-rw-r--r--net/ipv6/netfilter/ip6t_ah.c81
-rw-r--r--net/ipv6/netfilter/ip6t_dst.c88
-rw-r--r--net/ipv6/netfilter/ip6t_esp.c73
-rw-r--r--net/ipv6/netfilter/ip6t_frag.c90
-rw-r--r--net/ipv6/netfilter/ip6t_hbh.c88
-rw-r--r--net/ipv6/netfilter/ip6t_rt.c83
-rw-r--r--net/ipv6/raw.c2
-rw-r--r--net/ipv6/tcp_ipv6.c18
-rw-r--r--net/ipv6/udp.c26
-rw-r--r--net/irda/irlan/irlan_eth.c2
-rw-r--r--net/irda/irttp.c16
-rw-r--r--net/key/af_key.c18
-rw-r--r--net/llc/Makefile1
-rw-r--r--net/llc/af_llc.c501
-rw-r--r--net/llc/llc_c_ac.c271
-rw-r--r--net/llc/llc_c_ev.c157
-rw-r--r--net/llc/llc_conn.c211
-rw-r--r--net/llc/llc_core.c34
-rw-r--r--net/llc/llc_if.c11
-rw-r--r--net/llc/llc_input.c19
-rw-r--r--net/llc/llc_output.c2
-rw-r--r--net/llc/llc_proc.c2
-rw-r--r--net/llc/llc_s_ac.c16
-rw-r--r--net/llc/llc_sap.c20
-rw-r--r--net/llc/llc_station.c25
-rw-r--r--net/llc/sysctl_net_llc.c131
-rw-r--r--net/netfilter/nfnetlink.c6
-rw-r--r--net/netfilter/nfnetlink_log.c4
-rw-r--r--net/netfilter/nfnetlink_queue.c4
-rw-r--r--net/netlink/af_netlink.c4
-rw-r--r--net/netrom/nr_dev.c2
-rw-r--r--net/packet/af_packet.c63
-rw-r--r--net/rose/af_rose.c26
-rw-r--r--net/rxrpc/call.c2
-rw-r--r--net/rxrpc/connection.c2
-rw-r--r--net/sched/Kconfig4
-rw-r--r--net/sched/em_meta.c6
-rw-r--r--net/sctp/associola.c10
-rw-r--r--net/sctp/bind_addr.c12
-rw-r--r--net/sctp/chunk.c2
-rw-r--r--net/sctp/endpointola.c5
-rw-r--r--net/sctp/protocol.c4
-rw-r--r--net/sctp/sm_make_chunk.c14
-rw-r--r--net/sctp/sm_sideeffect.c12
-rw-r--r--net/sctp/sm_statefuns.c22
-rw-r--r--net/sctp/socket.c252
-rw-r--r--net/sctp/ssnmap.c2
-rw-r--r--net/sctp/transport.c4
-rw-r--r--net/sctp/ulpevent.c18
-rw-r--r--net/sctp/ulpqueue.c8
-rw-r--r--net/socket.c20
-rw-r--r--net/sunrpc/sched.c2
-rw-r--r--net/sunrpc/svcsock.c2
-rw-r--r--net/sysctl_net.c2
-rw-r--r--net/xfrm/xfrm_policy.c6
-rw-r--r--scripts/.gitignore4
-rw-r--r--scripts/basic/.gitignore3
-rw-r--r--scripts/kconfig/.gitignore16
-rw-r--r--scripts/mod/.gitignore4
-rw-r--r--scripts/mod/file2alias.c2
-rw-r--r--security/keys/Makefile1
-rw-r--r--security/keys/internal.h26
-rw-r--r--security/keys/key.c81
-rw-r--r--security/keys/keyctl.c301
-rw-r--r--security/keys/keyring.c86
-rw-r--r--security/keys/permission.c70
-rw-r--r--security/keys/proc.c2
-rw-r--r--security/keys/process_keys.c164
-rw-r--r--security/keys/request_key.c38
-rw-r--r--security/keys/request_key_auth.c5
-rw-r--r--security/seclvl.c17
-rw-r--r--security/selinux/hooks.c30
-rw-r--r--security/selinux/selinuxfs.c4
-rw-r--r--security/selinux/ss/policydb.c6
-rw-r--r--sound/arm/aaci.c2
-rw-r--r--sound/arm/pxa2xx-ac97.c2
-rw-r--r--sound/core/init.c6
-rw-r--r--sound/core/memalloc.c2
-rw-r--r--sound/core/memory.c10
-rw-r--r--sound/core/seq/instr/ainstr_iw.c2
-rw-r--r--sound/core/wrappers.c2
-rw-r--r--sound/isa/opl3sa2.c2
-rw-r--r--sound/oss/au1000.c2
-rw-r--r--sound/oss/ite8172.c2
-rw-r--r--sound/pci/ac97/ac97_bus.c23
-rw-r--r--sound/pci/ac97/ac97_codec.c3
-rw-r--r--sound/pci/ac97/ac97_patch.c6
-rw-r--r--sound/pci/ali5451/ali5451.c6
-rw-r--r--sound/pci/atiixp_modem.c16
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c5
-rw-r--r--sound/pci/emu10k1/emumixer.c11
-rw-r--r--sound/pci/hda/hda_generic.c6
-rw-r--r--sound/pci/hda/hda_intel.c5
-rw-r--r--sound/pci/hda/patch_realtek.c22
-rw-r--r--sound/pci/korg1212/korg1212.c2
-rw-r--r--sound/pci/via82xx.c2
-rw-r--r--sound/ppc/pmac.c1
-rw-r--r--sound/sparc/cs4231.c323
-rw-r--r--sound/usb/usbaudio.c8
-rw-r--r--sound/usb/usbmixer_maps.c10
-rw-r--r--sound/usb/usbquirks.h50
-rw-r--r--usr/.gitignore7
1289 files changed, 43428 insertions, 15299 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..5014bfa48ac1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,30 @@
1#
2# NOTE! Don't add files that are generated in specific
3# subdirectories here. Add them in the ".gitignore" file
4# in that subdirectory instead.
5#
6# Normal rules
7#
8.*
9*.o
10*.a
11*.s
12*.ko
13*.mod.c
14
15#
16# Top-level generic files
17#
18vmlinux*
19System.map
20Module.symvers
21
22#
23# Generated include files
24#
25include/asm
26include/config
27include/linux/autoconf.h
28include/linux/compile.h
29include/linux/version.h
30
diff --git a/CREDITS b/CREDITS
index f553f8cfaa62..a347520bef2d 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2211,6 +2211,15 @@ D: OV511 driver
2211S: (address available on request) 2211S: (address available on request)
2212S: USA 2212S: USA
2213 2213
2214N: Ian McDonald
2215E: iam4@cs.waikato.ac.nz
2216E: imcdnzl@gmail.com
2217W: http://wand.net.nz/~iam4
2218W: http://imcdnzl.blogspot.com
2219D: DCCP, CCID3
2220S: Hamilton
2221S: New Zealand
2222
2214N: Patrick McHardy 2223N: Patrick McHardy
2215E: kaber@trash.net 2224E: kaber@trash.net
2216P: 1024D/12155E80 B128 7DE6 FF0A C2B2 48BE AB4C C9D4 964E 1215 5E80 2225P: 1024D/12155E80 B128 7DE6 FF0A C2B2 48BE AB4C C9D4 964E 1215 5E80
@@ -2246,19 +2255,12 @@ S: D-90453 Nuernberg
2246S: Germany 2255S: Germany
2247 2256
2248N: Arnaldo Carvalho de Melo 2257N: Arnaldo Carvalho de Melo
2249E: acme@conectiva.com.br 2258E: acme@mandriva.com
2250E: acme@kernel.org 2259E: acme@ghostprotocols.net
2251E: acme@gnu.org 2260W: http://oops.ghostprotocols.net:81/blog/
2252W: http://bazar2.conectiva.com.br/~acme
2253W: http://advogato.org/person/acme
2254P: 1024D/9224DF01 D5DF E3BB E3C8 BCBB F8AD 841A B6AB 4681 9224 DF01 2261P: 1024D/9224DF01 D5DF E3BB E3C8 BCBB F8AD 841A B6AB 4681 9224 DF01
2255D: wanrouter hacking 2262D: IPX, LLC, DCCP, cyc2x, wl3501_cs, net/ hacks
2256D: misc Makefile, Config.in, drivers and network stacks fixes 2263S: Mandriva
2257D: IPX & LLC network stacks maintainer
2258D: Cyclom 2X synchronous card driver
2259D: wl3501 PCMCIA wireless card driver
2260D: i18n for minicom, net-tools, util-linux, fetchmail, etc
2261S: Conectiva S.A.
2262S: R. Tocantins, 89 - Cristo Rei 2264S: R. Tocantins, 89 - Cristo Rei
2263S: 80050-430 - Curitiba - Paraná 2265S: 80050-430 - Curitiba - Paraná
2264S: Brazil 2266S: Brazil
diff --git a/Documentation/Changes b/Documentation/Changes
index 5eaab0441d76..27232be26e1a 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -237,6 +237,12 @@ udev
237udev is a userspace application for populating /dev dynamically with 237udev is a userspace application for populating /dev dynamically with
238only entries for devices actually present. udev replaces devfs. 238only entries for devices actually present. udev replaces devfs.
239 239
240FUSE
241----
242
243Needs libfuse 2.4.0 or later. Absolute minimum is 2.3.0 but mount
244options 'direct_io' and 'kernel_cache' won't work.
245
240Networking 246Networking
241========== 247==========
242 248
@@ -390,6 +396,10 @@ udev
390---- 396----
391o <http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html> 397o <http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html>
392 398
399FUSE
400----
401o <http://sourceforge.net/projects/fuse>
402
393Networking 403Networking
394********** 404**********
395 405
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 22e5f9036f3c..eb7db3c19227 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -410,7 +410,26 @@ Kernel messages do not have to be terminated with a period.
410Printing numbers in parentheses (%d) adds no value and should be avoided. 410Printing numbers in parentheses (%d) adds no value and should be avoided.
411 411
412 412
413 Chapter 13: References 413 Chapter 13: Allocating memory
414
415The kernel provides the following general purpose memory allocators:
416kmalloc(), kzalloc(), kcalloc(), and vmalloc(). Please refer to the API
417documentation for further information about them.
418
419The preferred form for passing a size of a struct is the following:
420
421 p = kmalloc(sizeof(*p), ...);
422
423The alternative form where struct name is spelled out hurts readability and
424introduces an opportunity for a bug when the pointer variable type is changed
425but the corresponding sizeof that is passed to a memory allocator is not.
426
427Casting the return value which is a void pointer is redundant. The conversion
428from void pointer to any other pointer type is guaranteed by the C programming
429language.
430
431
432 Chapter 14: References
414 433
415The C Programming Language, Second Edition 434The C Programming Language, Second Edition
416by Brian W. Kernighan and Dennis M. Ritchie. 435by Brian W. Kernighan and Dennis M. Ritchie.
diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
index 6367bba32d22..582032eea872 100644
--- a/Documentation/DocBook/kernel-hacking.tmpl
+++ b/Documentation/DocBook/kernel-hacking.tmpl
@@ -1105,7 +1105,7 @@ static struct block_device_operations opt_fops = {
1105 </listitem> 1105 </listitem>
1106 <listitem> 1106 <listitem>
1107 <para> 1107 <para>
1108 Function names as strings (__func__). 1108 Function names as strings (__FUNCTION__).
1109 </para> 1109 </para>
1110 </listitem> 1110 </listitem>
1111 <listitem> 1111 <listitem>
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 7f43b040311e..237d54c44bc5 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -301,8 +301,84 @@ now, but you can do this to mark internal company procedures or just
301point out some special detail about the sign-off. 301point out some special detail about the sign-off.
302 302
303 303
30412) The canonical patch format
304 305
30512) More references for submitting patches 306The canonical patch subject line is:
307
308 Subject: [PATCH 001/123] subsystem: summary phrase
309
310The canonical patch message body contains the following:
311
312 - A "from" line specifying the patch author.
313
314 - An empty line.
315
316 - The body of the explanation, which will be copied to the
317 permanent changelog to describe this patch.
318
319 - The "Signed-off-by:" lines, described above, which will
320 also go in the changelog.
321
322 - A marker line containing simply "---".
323
324 - Any additional comments not suitable for the changelog.
325
326 - The actual patch (diff output).
327
328The Subject line format makes it very easy to sort the emails
329alphabetically by subject line - pretty much any email reader will
330support that - since because the sequence number is zero-padded,
331the numerical and alphabetic sort is the same.
332
333The "subsystem" in the email's Subject should identify which
334area or subsystem of the kernel is being patched.
335
336The "summary phrase" in the email's Subject should concisely
337describe the patch which that email contains. The "summary
338phrase" should not be a filename. Do not use the same "summary
339phrase" for every patch in a whole patch series.
340
341Bear in mind that the "summary phrase" of your email becomes
342a globally-unique identifier for that patch. It propagates
343all the way into the git changelog. The "summary phrase" may
344later be used in developer discussions which refer to the patch.
345People will want to google for the "summary phrase" to read
346discussion regarding that patch.
347
348A couple of example Subjects:
349
350 Subject: [patch 2/5] ext2: improve scalability of bitmap searching
351 Subject: [PATCHv2 001/207] x86: fix eflags tracking
352
353The "from" line must be the very first line in the message body,
354and has the form:
355
356 From: Original Author <author@example.com>
357
358The "from" line specifies who will be credited as the author of the
359patch in the permanent changelog. If the "from" line is missing,
360then the "From:" line from the email header will be used to determine
361the patch author in the changelog.
362
363The explanation body will be committed to the permanent source
364changelog, so should make sense to a competent reader who has long
365since forgotten the immediate details of the discussion that might
366have led to this patch.
367
368The "---" marker line serves the essential purpose of marking for patch
369handling tools where the changelog message ends.
370
371One good use for the additional comments after the "---" marker is for
372a diffstat, to show what files have changed, and the number of inserted
373and deleted lines per file. A diffstat is especially useful on bigger
374patches. Other comments relevant only to the moment or the maintainer,
375not suitable for the permanent changelog, should also go here.
376
377See more details on the proper patch format in the following
378references.
379
380
38113) More references for submitting patches
306 382
307Andrew Morton, "The perfect patch" (tpp). 383Andrew Morton, "The perfect patch" (tpp).
308 <http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt> 384 <http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt>
@@ -310,6 +386,14 @@ Andrew Morton, "The perfect patch" (tpp).
310Jeff Garzik, "Linux kernel patch submission format." 386Jeff Garzik, "Linux kernel patch submission format."
311 <http://linux.yyz.us/patch-format.html> 387 <http://linux.yyz.us/patch-format.html>
312 388
389Greg KH, "How to piss off a kernel subsystem maintainer"
390 <http://www.kroah.com/log/2005/03/31/>
391
392Kernel Documentation/CodingStyle
393 <http://sosdg.org/~coywolf/lxr/source/Documentation/CodingStyle>
394
395Linus Torvald's mail on the canonical patch format:
396 <http://lkml.org/lkml/2005/4/7/183>
313 397
314 398
315----------------------------------- 399-----------------------------------
diff --git a/Documentation/connector/connector.txt b/Documentation/connector/connector.txt
index 54a0a14bfbe3..57a314b14cf8 100644
--- a/Documentation/connector/connector.txt
+++ b/Documentation/connector/connector.txt
@@ -131,3 +131,47 @@ Netlink itself is not reliable protocol, that means that messages can
131be lost due to memory pressure or process' receiving queue overflowed, 131be lost due to memory pressure or process' receiving queue overflowed,
132so caller is warned must be prepared. That is why struct cn_msg [main 132so caller is warned must be prepared. That is why struct cn_msg [main
133connector's message header] contains u32 seq and u32 ack fields. 133connector's message header] contains u32 seq and u32 ack fields.
134
135/*****************************************/
136Userspace usage.
137/*****************************************/
1382.6.14 has a new netlink socket implementation, which by default does not
139allow to send data to netlink groups other than 1.
140So, if to use netlink socket (for example using connector)
141with different group number userspace application must subscribe to
142that group. It can be achieved by following pseudocode:
143
144s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
145
146l_local.nl_family = AF_NETLINK;
147l_local.nl_groups = 12345;
148l_local.nl_pid = 0;
149
150if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == -1) {
151 perror("bind");
152 close(s);
153 return -1;
154}
155
156{
157 int on = l_local.nl_groups;
158 setsockopt(s, 270, 1, &on, sizeof(on));
159}
160
161Where 270 above is SOL_NETLINK, and 1 is a NETLINK_ADD_MEMBERSHIP socket
162option. To drop multicast subscription one should call above socket option
163with NETLINK_DROP_MEMBERSHIP parameter which is defined as 0.
164
1652.6.14 netlink code only allows to select a group which is less or equal to
166the maximum group number, which is used at netlink_kernel_create() time.
167In case of connector it is CN_NETLINK_USERS + 0xf, so if you want to use
168group number 12345, you must increment CN_NETLINK_USERS to that number.
169Additional 0xf numbers are allocated to be used by non-in-kernel users.
170
171Due to this limitation, group 0xffffffff does not work now, so one can
172not use add/remove connector's group notifications, but as far as I know,
173only cn_test.c test module used it.
174
175Some work in netlink area is still being done, so things can be changed in
1762.6.15 timeframe, if it will happen, documentation will be updated for that
177kernel.
diff --git a/Documentation/dell_rbu.txt b/Documentation/dell_rbu.txt
index bcfa5c35036b..941343a7a265 100644
--- a/Documentation/dell_rbu.txt
+++ b/Documentation/dell_rbu.txt
@@ -13,6 +13,8 @@ the BIOS on Dell servers (starting from servers sold since 1999), desktops
13and notebooks (starting from those sold in 2005). 13and notebooks (starting from those sold in 2005).
14Please go to http://support.dell.com register and you can find info on 14Please go to http://support.dell.com register and you can find info on
15OpenManage and Dell Update packages (DUP). 15OpenManage and Dell Update packages (DUP).
16Libsmbios can also be used to update BIOS on Dell systems go to
17http://linux.dell.com/libsmbios/ for details.
16 18
17Dell_RBU driver supports BIOS update using the monilothic image and packetized 19Dell_RBU driver supports BIOS update using the monilothic image and packetized
18image methods. In case of moniolithic the driver allocates a contiguous chunk 20image methods. In case of moniolithic the driver allocates a contiguous chunk
@@ -22,8 +24,8 @@ would place each packet in contiguous physical memory. The driver also
22maintains a link list of packets for reading them back. 24maintains a link list of packets for reading them back.
23If the dell_rbu driver is unloaded all the allocated memory is freed. 25If the dell_rbu driver is unloaded all the allocated memory is freed.
24 26
25The rbu driver needs to have an application which will inform the BIOS to 27The rbu driver needs to have an application (as mentioned above)which will
26enable the update in the next system reboot. 28inform the BIOS to enable the update in the next system reboot.
27 29
28The user should not unload the rbu driver after downloading the BIOS image 30The user should not unload the rbu driver after downloading the BIOS image
29or updating. 31or updating.
@@ -33,6 +35,7 @@ The driver load creates the following directories under the /sys file system.
33/sys/class/firmware/dell_rbu/data 35/sys/class/firmware/dell_rbu/data
34/sys/devices/platform/dell_rbu/image_type 36/sys/devices/platform/dell_rbu/image_type
35/sys/devices/platform/dell_rbu/data 37/sys/devices/platform/dell_rbu/data
38/sys/devices/platform/dell_rbu/packet_size
36 39
37The driver supports two types of update mechanism; monolithic and packetized. 40The driver supports two types of update mechanism; monolithic and packetized.
38These update mechanism depends upon the BIOS currently running on the system. 41These update mechanism depends upon the BIOS currently running on the system.
@@ -42,10 +45,30 @@ In case of packet mechanism the single memory can be broken in smaller chuks
42of contiguous memory and the BIOS image is scattered in these packets. 45of contiguous memory and the BIOS image is scattered in these packets.
43 46
44By default the driver uses monolithic memory for the update type. This can be 47By default the driver uses monolithic memory for the update type. This can be
45changed to contiguous during the driver load time by specifying the load 48changed to packets during the driver load time by specifying the load
46parameter image_type=packet. This can also be changed later as below 49parameter image_type=packet. This can also be changed later as below
47echo packet > /sys/devices/platform/dell_rbu/image_type 50echo packet > /sys/devices/platform/dell_rbu/image_type
48 51
52In packet update mode the packet size has to be given before any packets can
53be downloaded. It is done as below
54echo XXXX > /sys/devices/platform/dell_rbu/packet_size
55In the packet update mechanism, the user neesd to create a new file having
56packets of data arranged back to back. It can be done as follows
57The user creates packets header, gets the chunk of the BIOS image and
58placs it next to the packetheader; now, the packetheader + BIOS image chunk
59added to geather should match the specified packet_size. This makes one
60packet, the user needs to create more such packets out of the entire BIOS
61image file and then arrange all these packets back to back in to one single
62file.
63This file is then copied to /sys/class/firmware/dell_rbu/data.
64Once this file gets to the driver, the driver extracts packet_size data from
65the file and spreads it accross the physical memory in contiguous packet_sized
66space.
67This method makes sure that all the packets get to the driver in a single operation.
68
69In monolithic update the user simply get the BIOS image (.hdr file) and copies
70to the data file as is without any change to the BIOS image itself.
71
49Do the steps below to download the BIOS image. 72Do the steps below to download the BIOS image.
501) echo 1 > /sys/class/firmware/dell_rbu/loading 731) echo 1 > /sys/class/firmware/dell_rbu/loading
512) cp bios_image.hdr /sys/class/firmware/dell_rbu/data 742) cp bios_image.hdr /sys/class/firmware/dell_rbu/data
@@ -53,20 +76,23 @@ Do the steps below to download the BIOS image.
53 76
54The /sys/class/firmware/dell_rbu/ entries will remain till the following is 77The /sys/class/firmware/dell_rbu/ entries will remain till the following is
55done. 78done.
56echo -1 > /sys/class/firmware/dell_rbu/loading 79echo -1 > /sys/class/firmware/dell_rbu/loading.
80Until this step is completed the driver cannot be unloaded.
81Also echoing either mono ,packet or init in to image_type will free up the
82memory allocated by the driver.
57 83
58Until this step is completed the drivr cannot be unloaded. 84If an user by accident executes steps 1 and 3 above without executing step 2;
85it will make the /sys/class/firmware/dell_rbu/ entries to disappear.
86The entries can be recreated by doing the following
87echo init > /sys/devices/platform/dell_rbu/image_type
88NOTE: echoing init in image_type does not change it original value.
59 89
60Also the driver provides /sys/devices/platform/dell_rbu/data readonly file to 90Also the driver provides /sys/devices/platform/dell_rbu/data readonly file to
61read back the image downloaded. This is useful in case of packet update 91read back the image downloaded.
62mechanism where the above steps 1,2,3 will repeated for every packet.
63By reading the /sys/devices/platform/dell_rbu/data file all packet data
64downloaded can be verified in a single file.
65The packets are arranged in this file one after the other in a FIFO order.
66 92
67NOTE: 93NOTE:
68This driver requires a patch for firmware_class.c which has the addition 94This driver requires a patch for firmware_class.c which has the modified
69of request_firmware_nowait_nohotplug function to wortk 95request_firmware_nowait function.
70Also after updating the BIOS image an user mdoe application neeeds to execute 96Also after updating the BIOS image an user mdoe application neeeds to execute
71code which message the BIOS update request to the BIOS. So on the next reboot 97code which message the BIOS update request to the BIOS. So on the next reboot
72the BIOS knows about the new image downloaded and it updates it self. 98the BIOS knows about the new image downloaded and it updates it self.
diff --git a/Documentation/device-mapper/snapshot.txt b/Documentation/device-mapper/snapshot.txt
new file mode 100644
index 000000000000..dca274ff4005
--- /dev/null
+++ b/Documentation/device-mapper/snapshot.txt
@@ -0,0 +1,73 @@
1Device-mapper snapshot support
2==============================
3
4Device-mapper allows you, without massive data copying:
5
6*) To create snapshots of any block device i.e. mountable, saved states of
7the block device which are also writable without interfering with the
8original content;
9*) To create device "forks", i.e. multiple different versions of the
10same data stream.
11
12
13In both cases, dm copies only the chunks of data that get changed and
14uses a separate copy-on-write (COW) block device for storage.
15
16
17There are two dm targets available: snapshot and snapshot-origin.
18
19*) snapshot-origin <origin>
20
21which will normally have one or more snapshots based on it.
22You must create the snapshot-origin device before you can create snapshots.
23Reads will be mapped directly to the backing device. For each write, the
24original data will be saved in the <COW device> of each snapshot to keep
25its visible content unchanged, at least until the <COW device> fills up.
26
27
28*) snapshot <origin> <COW device> <persistent?> <chunksize>
29
30A snapshot is created of the <origin> block device. Changed chunks of
31<chunksize> sectors will be stored on the <COW device>. Writes will
32only go to the <COW device>. Reads will come from the <COW device> or
33from <origin> for unchanged data. <COW device> will often be
34smaller than the origin and if it fills up the snapshot will become
35useless and be disabled, returning errors. So it is important to monitor
36the amount of free space and expand the <COW device> before it fills up.
37
38<persistent?> is P (Persistent) or N (Not persistent - will not survive
39after reboot).
40
41
42How this is used by LVM2
43========================
44When you create the first LVM2 snapshot of a volume, four dm devices are used:
45
461) a device containing the original mapping table of the source volume;
472) a device used as the <COW device>;
483) a "snapshot" device, combining #1 and #2, which is the visible snapshot
49 volume;
504) the "original" volume (which uses the device number used by the original
51 source volume), whose table is replaced by a "snapshot-origin" mapping
52 from device #1.
53
54A fixed naming scheme is used, so with the following commands:
55
56lvcreate -L 1G -n base volumeGroup
57lvcreate -L 100M --snapshot -n snap volumeGroup/base
58
59we'll have this situation (with volumes in above order):
60
61# dmsetup table|grep volumeGroup
62
63volumeGroup-base-real: 0 2097152 linear 8:19 384
64volumeGroup-snap-cow: 0 204800 linear 8:19 2097536
65volumeGroup-snap: 0 2097152 snapshot 254:11 254:12 P 16
66volumeGroup-base: 0 2097152 snapshot-origin 254:11
67
68# ls -lL /dev/mapper/volumeGroup-*
69brw------- 1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
70brw------- 1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow
71brw------- 1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap
72brw------- 1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base
73
diff --git a/Documentation/filesystems/relayfs.txt b/Documentation/filesystems/relayfs.txt
index d24e1b0d4f39..d803abed29f0 100644
--- a/Documentation/filesystems/relayfs.txt
+++ b/Documentation/filesystems/relayfs.txt
@@ -15,7 +15,7 @@ retrieve the data as it becomes available.
15 15
16The format of the data logged into the channel buffers is completely 16The format of the data logged into the channel buffers is completely
17up to the relayfs client; relayfs does however provide hooks which 17up to the relayfs client; relayfs does however provide hooks which
18allow clients to impose some stucture on the buffer data. Nor does 18allow clients to impose some structure on the buffer data. Nor does
19relayfs implement any form of data filtering - this also is left to 19relayfs implement any form of data filtering - this also is left to
20the client. The purpose is to keep relayfs as simple as possible. 20the client. The purpose is to keep relayfs as simple as possible.
21 21
diff --git a/Documentation/ia64/mca.txt b/Documentation/ia64/mca.txt
new file mode 100644
index 000000000000..a71cc6a67ef7
--- /dev/null
+++ b/Documentation/ia64/mca.txt
@@ -0,0 +1,194 @@
1An ad-hoc collection of notes on IA64 MCA and INIT processing. Feel
2free to update it with notes about any area that is not clear.
3
4---
5
6MCA/INIT are completely asynchronous. They can occur at any time, when
7the OS is in any state. Including when one of the cpus is already
8holding a spinlock. Trying to get any lock from MCA/INIT state is
9asking for deadlock. Also the state of structures that are protected
10by locks is indeterminate, including linked lists.
11
12---
13
14The complicated ia64 MCA process. All of this is mandated by Intel's
15specification for ia64 SAL, error recovery and and unwind, it is not as
16if we have a choice here.
17
18* MCA occurs on one cpu, usually due to a double bit memory error.
19 This is the monarch cpu.
20
21* SAL sends an MCA rendezvous interrupt (which is a normal interrupt)
22 to all the other cpus, the slaves.
23
24* Slave cpus that receive the MCA interrupt call down into SAL, they
25 end up spinning disabled while the MCA is being serviced.
26
27* If any slave cpu was already spinning disabled when the MCA occurred
28 then it cannot service the MCA interrupt. SAL waits ~20 seconds then
29 sends an unmaskable INIT event to the slave cpus that have not
30 already rendezvoused.
31
32* Because MCA/INIT can be delivered at any time, including when the cpu
33 is down in PAL in physical mode, the registers at the time of the
34 event are _completely_ undefined. In particular the MCA/INIT
35 handlers cannot rely on the thread pointer, PAL physical mode can
36 (and does) modify TP. It is allowed to do that as long as it resets
37 TP on return. However MCA/INIT events expose us to these PAL
38 internal TP changes. Hence curr_task().
39
40* If an MCA/INIT event occurs while the kernel was running (not user
41 space) and the kernel has called PAL then the MCA/INIT handler cannot
42 assume that the kernel stack is in a fit state to be used. Mainly
43 because PAL may or may not maintain the stack pointer internally.
44 Because the MCA/INIT handlers cannot trust the kernel stack, they
45 have to use their own, per-cpu stacks. The MCA/INIT stacks are
46 preformatted with just enough task state to let the relevant handlers
47 do their job.
48
49* Unlike most other architectures, the ia64 struct task is embedded in
50 the kernel stack[1]. So switching to a new kernel stack means that
51 we switch to a new task as well. Because various bits of the kernel
52 assume that current points into the struct task, switching to a new
53 stack also means a new value for current.
54
55* Once all slaves have rendezvoused and are spinning disabled, the
56 monarch is entered. The monarch now tries to diagnose the problem
57 and decide if it can recover or not.
58
59* Part of the monarch's job is to look at the state of all the other
60 tasks. The only way to do that on ia64 is to call the unwinder,
61 as mandated by Intel.
62
63* The starting point for the unwind depends on whether a task is
64 running or not. That is, whether it is on a cpu or is blocked. The
65 monarch has to determine whether or not a task is on a cpu before it
66 knows how to start unwinding it. The tasks that received an MCA or
67 INIT event are no longer running, they have been converted to blocked
68 tasks. But (and its a big but), the cpus that received the MCA
69 rendezvous interrupt are still running on their normal kernel stacks!
70
71* To distinguish between these two cases, the monarch must know which
72 tasks are on a cpu and which are not. Hence each slave cpu that
73 switches to an MCA/INIT stack, registers its new stack using
74 set_curr_task(), so the monarch can tell that the _original_ task is
75 no longer running on that cpu. That gives us a decent chance of
76 getting a valid backtrace of the _original_ task.
77
78* MCA/INIT can be nested, to a depth of 2 on any cpu. In the case of a
79 nested error, we want diagnostics on the MCA/INIT handler that
80 failed, not on the task that was originally running. Again this
81 requires set_curr_task() so the MCA/INIT handlers can register their
82 own stack as running on that cpu. Then a recursive error gets a
83 trace of the failing handler's "task".
84
85[1] My (Keith Owens) original design called for ia64 to separate its
86 struct task and the kernel stacks. Then the MCA/INIT data would be
87 chained stacks like i386 interrupt stacks. But that required
88 radical surgery on the rest of ia64, plus extra hard wired TLB
89 entries with its associated performance degradation. David
90 Mosberger vetoed that approach. Which meant that separate kernel
91 stacks meant separate "tasks" for the MCA/INIT handlers.
92
93---
94
95INIT is less complicated than MCA. Pressing the nmi button or using
96the equivalent command on the management console sends INIT to all
97cpus. SAL picks one one of the cpus as the monarch and the rest are
98slaves. All the OS INIT handlers are entered at approximately the same
99time. The OS monarch prints the state of all tasks and returns, after
100which the slaves return and the system resumes.
101
102At least that is what is supposed to happen. Alas there are broken
103versions of SAL out there. Some drive all the cpus as monarchs. Some
104drive them all as slaves. Some drive one cpu as monarch, wait for that
105cpu to return from the OS then drive the rest as slaves. Some versions
106of SAL cannot even cope with returning from the OS, they spin inside
107SAL on resume. The OS INIT code has workarounds for some of these
108broken SAL symptoms, but some simply cannot be fixed from the OS side.
109
110---
111
112The scheduler hooks used by ia64 (curr_task, set_curr_task) are layer
113violations. Unfortunately MCA/INIT start off as massive layer
114violations (can occur at _any_ time) and they build from there.
115
116At least ia64 makes an attempt at recovering from hardware errors, but
117it is a difficult problem because of the asynchronous nature of these
118errors. When processing an unmaskable interrupt we sometimes need
119special code to cope with our inability to take any locks.
120
121---
122
123How is ia64 MCA/INIT different from x86 NMI?
124
125* x86 NMI typically gets delivered to one cpu. MCA/INIT gets sent to
126 all cpus.
127
128* x86 NMI cannot be nested. MCA/INIT can be nested, to a depth of 2
129 per cpu.
130
131* x86 has a separate struct task which points to one of multiple kernel
132 stacks. ia64 has the struct task embedded in the single kernel
133 stack, so switching stack means switching task.
134
135* x86 does not call the BIOS so the NMI handler does not have to worry
136 about any registers having changed. MCA/INIT can occur while the cpu
137 is in PAL in physical mode, with undefined registers and an undefined
138 kernel stack.
139
140* i386 backtrace is not very sensitive to whether a process is running
141 or not. ia64 unwind is very, very sensitive to whether a process is
142 running or not.
143
144---
145
146What happens when MCA/INIT is delivered what a cpu is running user
147space code?
148
149The user mode registers are stored in the RSE area of the MCA/INIT on
150entry to the OS and are restored from there on return to SAL, so user
151mode registers are preserved across a recoverable MCA/INIT. Since the
152OS has no idea what unwind data is available for the user space stack,
153MCA/INIT never tries to backtrace user space. Which means that the OS
154does not bother making the user space process look like a blocked task,
155i.e. the OS does not copy pt_regs and switch_stack to the user space
156stack. Also the OS has no idea how big the user space RSE and memory
157stacks are, which makes it too risky to copy the saved state to a user
158mode stack.
159
160---
161
162How do we get a backtrace on the tasks that were running when MCA/INIT
163was delivered?
164
165mca.c:::ia64_mca_modify_original_stack(). That identifies and
166verifies the original kernel stack, copies the dirty registers from
167the MCA/INIT stack's RSE to the original stack's RSE, copies the
168skeleton struct pt_regs and switch_stack to the original stack, fills
169in the skeleton structures from the PAL minstate area and updates the
170original stack's thread.ksp. That makes the original stack look
171exactly like any other blocked task, i.e. it now appears to be
172sleeping. To get a backtrace, just start with thread.ksp for the
173original task and unwind like any other sleeping task.
174
175---
176
177How do we identify the tasks that were running when MCA/INIT was
178delivered?
179
180If the previous task has been verified and converted to a blocked
181state, then sos->prev_task on the MCA/INIT stack is updated to point to
182the previous task. You can look at that field in dumps or debuggers.
183To help distinguish between the handler and the original tasks,
184handlers have _TIF_MCA_INIT set in thread_info.flags.
185
186The sos data is always in the MCA/INIT handler stack, at offset
187MCA_SOS_OFFSET. You can get that value from mca_asm.h or calculate it
188as KERNEL_STACK_SIZE - sizeof(struct pt_regs) - sizeof(struct
189ia64_sal_os_state), with 16 byte alignment for all structures.
190
191Also the comm field of the MCA/INIT task is modified to include the pid
192of the original task, for humans to use. For example, a comm field of
193'MCA 12159' means that pid 12159 was running when the MCA was
194delivered.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 7086f0a90d14..971589a9752d 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -17,7 +17,7 @@ are specified on the kernel command line with the module name plus
17 17
18 usbcore.blinkenlights=1 18 usbcore.blinkenlights=1
19 19
20The text in square brackets at the beginning of the description state the 20The text in square brackets at the beginning of the description states the
21restrictions on the kernel for the said kernel parameter to be valid. The 21restrictions on the kernel for the said kernel parameter to be valid. The
22restrictions referred to are that the relevant option is valid if: 22restrictions referred to are that the relevant option is valid if:
23 23
@@ -27,8 +27,8 @@ restrictions referred to are that the relevant option is valid if:
27 APM Advanced Power Management support is enabled. 27 APM Advanced Power Management support is enabled.
28 AX25 Appropriate AX.25 support is enabled. 28 AX25 Appropriate AX.25 support is enabled.
29 CD Appropriate CD support is enabled. 29 CD Appropriate CD support is enabled.
30 DEVFS devfs support is enabled. 30 DEVFS devfs support is enabled.
31 DRM Direct Rendering Management support is enabled. 31 DRM Direct Rendering Management support is enabled.
32 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled 32 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled
33 EFI EFI Partitioning (GPT) is enabled 33 EFI EFI Partitioning (GPT) is enabled
34 EIDE EIDE/ATAPI support is enabled. 34 EIDE EIDE/ATAPI support is enabled.
@@ -71,7 +71,7 @@ restrictions referred to are that the relevant option is valid if:
71 SERIAL Serial support is enabled. 71 SERIAL Serial support is enabled.
72 SMP The kernel is an SMP kernel. 72 SMP The kernel is an SMP kernel.
73 SPARC Sparc architecture is enabled. 73 SPARC Sparc architecture is enabled.
74 SWSUSP Software suspension is enabled. 74 SWSUSP Software suspend is enabled.
75 TS Appropriate touchscreen support is enabled. 75 TS Appropriate touchscreen support is enabled.
76 USB USB support is enabled. 76 USB USB support is enabled.
77 USBHID USB Human Interface Device support is enabled. 77 USBHID USB Human Interface Device support is enabled.
@@ -105,13 +105,13 @@ running once the system is up.
105 See header of drivers/scsi/53c7xx.c. 105 See header of drivers/scsi/53c7xx.c.
106 See also Documentation/scsi/ncr53c7xx.txt. 106 See also Documentation/scsi/ncr53c7xx.txt.
107 107
108 acpi= [HW,ACPI] Advanced Configuration and Power Interface 108 acpi= [HW,ACPI] Advanced Configuration and Power Interface
109 Format: { force | off | ht | strict } 109 Format: { force | off | ht | strict | noirq }
110 force -- enable ACPI if default was off 110 force -- enable ACPI if default was off
111 off -- disable ACPI if default was on 111 off -- disable ACPI if default was on
112 noirq -- do not use ACPI for IRQ routing 112 noirq -- do not use ACPI for IRQ routing
113 ht -- run only enough ACPI to enable Hyper Threading 113 ht -- run only enough ACPI to enable Hyper Threading
114 strict -- Be less tolerant of platforms that are not 114 strict -- Be less tolerant of platforms that are not
115 strictly ACPI specification compliant. 115 strictly ACPI specification compliant.
116 116
117 See also Documentation/pm.txt, pci=noacpi 117 See also Documentation/pm.txt, pci=noacpi
@@ -119,20 +119,23 @@ running once the system is up.
119 acpi_sleep= [HW,ACPI] Sleep options 119 acpi_sleep= [HW,ACPI] Sleep options
120 Format: { s3_bios, s3_mode } 120 Format: { s3_bios, s3_mode }
121 See Documentation/power/video.txt 121 See Documentation/power/video.txt
122 122
123 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode 123 acpi_sci= [HW,ACPI] ACPI System Control Interrupt trigger mode
124 Format: { level | edge | high | low } 124 Format: { level | edge | high | low }
125 125
126 acpi_irq_balance [HW,ACPI] ACPI will balance active IRQs 126 acpi_irq_balance [HW,ACPI]
127 default in APIC mode 127 ACPI will balance active IRQs
128 default in APIC mode
128 129
129 acpi_irq_nobalance [HW,ACPI] ACPI will not move active IRQs (default) 130 acpi_irq_nobalance [HW,ACPI]
130 default in PIC mode 131 ACPI will not move active IRQs (default)
132 default in PIC mode
131 133
132 acpi_irq_pci= [HW,ACPI] If irq_balance, Clear listed IRQs for use by PCI 134 acpi_irq_pci= [HW,ACPI] If irq_balance, clear listed IRQs for
135 use by PCI
133 Format: <irq>,<irq>... 136 Format: <irq>,<irq>...
134 137
135 acpi_irq_isa= [HW,ACPI] If irq_balance, Mark listed IRQs used by ISA 138 acpi_irq_isa= [HW,ACPI] If irq_balance, mark listed IRQs used by ISA
136 Format: <irq>,<irq>... 139 Format: <irq>,<irq>...
137 140
138 acpi_osi= [HW,ACPI] empty param disables _OSI 141 acpi_osi= [HW,ACPI] empty param disables _OSI
@@ -145,14 +148,14 @@ running once the system is up.
145 148
146 acpi_dbg_layer= [HW,ACPI] 149 acpi_dbg_layer= [HW,ACPI]
147 Format: <int> 150 Format: <int>
148 Each bit of the <int> indicates an acpi debug layer, 151 Each bit of the <int> indicates an ACPI debug layer,
149 1: enable, 0: disable. It is useful for boot time 152 1: enable, 0: disable. It is useful for boot time
150 debugging. After system has booted up, it can be set 153 debugging. After system has booted up, it can be set
151 via /proc/acpi/debug_layer. 154 via /proc/acpi/debug_layer.
152 155
153 acpi_dbg_level= [HW,ACPI] 156 acpi_dbg_level= [HW,ACPI]
154 Format: <int> 157 Format: <int>
155 Each bit of the <int> indicates an acpi debug level, 158 Each bit of the <int> indicates an ACPI debug level,
156 1: enable, 0: disable. It is useful for boot time 159 1: enable, 0: disable. It is useful for boot time
157 debugging. After system has booted up, it can be set 160 debugging. After system has booted up, it can be set
158 via /proc/acpi/debug_level. 161 via /proc/acpi/debug_level.
@@ -161,12 +164,13 @@ running once the system is up.
161 164
162 acpi_generic_hotkey [HW,ACPI] 165 acpi_generic_hotkey [HW,ACPI]
163 Allow consolidated generic hotkey driver to 166 Allow consolidated generic hotkey driver to
164 over-ride platform specific driver. 167 override platform specific driver.
165 See also Documentation/acpi-hotkey.txt. 168 See also Documentation/acpi-hotkey.txt.
166 169
167 enable_timer_pin_1 [i386,x86-64] 170 enable_timer_pin_1 [i386,x86-64]
168 Enable PIN 1 of APIC timer 171 Enable PIN 1 of APIC timer
169 Can be useful to work around chipset bugs (in particular on some ATI chipsets) 172 Can be useful to work around chipset bugs
173 (in particular on some ATI chipsets).
170 The kernel tries to set a reasonable default. 174 The kernel tries to set a reasonable default.
171 175
172 disable_timer_pin_1 [i386,x86-64] 176 disable_timer_pin_1 [i386,x86-64]
@@ -182,7 +186,7 @@ running once the system is up.
182 186
183 adlib= [HW,OSS] 187 adlib= [HW,OSS]
184 Format: <io> 188 Format: <io>
185 189
186 advansys= [HW,SCSI] 190 advansys= [HW,SCSI]
187 See header of drivers/scsi/advansys.c. 191 See header of drivers/scsi/advansys.c.
188 192
@@ -192,7 +196,7 @@ running once the system is up.
192 aedsp16= [HW,OSS] Audio Excel DSP 16 196 aedsp16= [HW,OSS] Audio Excel DSP 16
193 Format: <io>,<irq>,<dma>,<mss_io>,<mpu_io>,<mpu_irq> 197 Format: <io>,<irq>,<dma>,<mss_io>,<mpu_io>,<mpu_irq>
194 See also header of sound/oss/aedsp16.c. 198 See also header of sound/oss/aedsp16.c.
195 199
196 aha152x= [HW,SCSI] 200 aha152x= [HW,SCSI]
197 See Documentation/scsi/aha152x.txt. 201 See Documentation/scsi/aha152x.txt.
198 202
@@ -205,10 +209,6 @@ running once the system is up.
205 aic79xx= [HW,SCSI] 209 aic79xx= [HW,SCSI]
206 See Documentation/scsi/aic79xx.txt. 210 See Documentation/scsi/aic79xx.txt.
207 211
208 AM53C974= [HW,SCSI]
209 Format: <host-scsi-id>,<target-scsi-id>,<max-rate>,<max-offset>
210 See also header of drivers/scsi/AM53C974.c.
211
212 amijoy.map= [HW,JOY] Amiga joystick support 212 amijoy.map= [HW,JOY] Amiga joystick support
213 Map of devices attached to JOY0DAT and JOY1DAT 213 Map of devices attached to JOY0DAT and JOY1DAT
214 Format: <a>,<b> 214 Format: <a>,<b>
@@ -219,23 +219,24 @@ running once the system is up.
219 connected to one of 16 gameports 219 connected to one of 16 gameports
220 Format: <type1>,<type2>,..<type16> 220 Format: <type1>,<type2>,..<type16>
221 221
222 apc= [HW,SPARC] Power management functions (SPARCstation-4/5 + deriv.) 222 apc= [HW,SPARC]
223 Power management functions (SPARCstation-4/5 + deriv.)
223 Format: noidle 224 Format: noidle
224 Disable APC CPU standby support. SPARCstation-Fox does 225 Disable APC CPU standby support. SPARCstation-Fox does
225 not play well with APC CPU idle - disable it if you have 226 not play well with APC CPU idle - disable it if you have
226 APC and your system crashes randomly. 227 APC and your system crashes randomly.
227 228
228 apic= [APIC,i386] Change the output verbosity whilst booting 229 apic= [APIC,i386] Change the output verbosity whilst booting
229 Format: { quiet (default) | verbose | debug } 230 Format: { quiet (default) | verbose | debug }
230 Change the amount of debugging information output 231 Change the amount of debugging information output
231 when initialising the APIC and IO-APIC components. 232 when initialising the APIC and IO-APIC components.
232 233
233 apm= [APM] Advanced Power Management 234 apm= [APM] Advanced Power Management
234 See header of arch/i386/kernel/apm.c. 235 See header of arch/i386/kernel/apm.c.
235 236
236 applicom= [HW] 237 applicom= [HW]
237 Format: <mem>,<irq> 238 Format: <mem>,<irq>
238 239
239 arcrimi= [HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards 240 arcrimi= [HW,NET] ARCnet - "RIM I" (entirely mem-mapped) cards
240 Format: <io>,<irq>,<nodeID> 241 Format: <io>,<irq>,<nodeID>
241 242
@@ -250,38 +251,40 @@ running once the system is up.
250 251
251 atkbd.reset= [HW] Reset keyboard during initialization 252 atkbd.reset= [HW] Reset keyboard during initialization
252 253
253 atkbd.set= [HW] Select keyboard code set 254 atkbd.set= [HW] Select keyboard code set
254 Format: <int> (2 = AT (default) 3 = PS/2) 255 Format: <int> (2 = AT (default), 3 = PS/2)
255 256
256 atkbd.scroll= [HW] Enable scroll wheel on MS Office and similar 257 atkbd.scroll= [HW] Enable scroll wheel on MS Office and similar
257 keyboards 258 keyboards
258 259
259 atkbd.softraw= [HW] Choose between synthetic and real raw mode 260 atkbd.softraw= [HW] Choose between synthetic and real raw mode
260 Format: <bool> (0 = real, 1 = synthetic (default)) 261 Format: <bool> (0 = real, 1 = synthetic (default))
261 262
262 atkbd.softrepeat= 263 atkbd.softrepeat= [HW]
263 [HW] Use software keyboard repeat 264 Use software keyboard repeat
264 265
265 autotest [IA64] 266 autotest [IA64]
266 267
267 awe= [HW,OSS] AWE32/SB32/AWE64 wave table synth 268 awe= [HW,OSS] AWE32/SB32/AWE64 wave table synth
268 Format: <io>,<memsize>,<isapnp> 269 Format: <io>,<memsize>,<isapnp>
269 270
270 aztcd= [HW,CD] Aztech CD268 CDROM driver 271 aztcd= [HW,CD] Aztech CD268 CDROM driver
271 Format: <io>,0x79 (?) 272 Format: <io>,0x79 (?)
272 273
273 baycom_epp= [HW,AX25] 274 baycom_epp= [HW,AX25]
274 Format: <io>,<mode> 275 Format: <io>,<mode>
275 276
276 baycom_par= [HW,AX25] BayCom Parallel Port AX.25 Modem 277 baycom_par= [HW,AX25] BayCom Parallel Port AX.25 Modem
277 Format: <io>,<mode> 278 Format: <io>,<mode>
278 See header of drivers/net/hamradio/baycom_par.c. 279 See header of drivers/net/hamradio/baycom_par.c.
279 280
280 baycom_ser_fdx= [HW,AX25] BayCom Serial Port AX.25 Modem (Full Duplex Mode) 281 baycom_ser_fdx= [HW,AX25]
282 BayCom Serial Port AX.25 Modem (Full Duplex Mode)
281 Format: <io>,<irq>,<mode>[,<baud>] 283 Format: <io>,<irq>,<mode>[,<baud>]
282 See header of drivers/net/hamradio/baycom_ser_fdx.c. 284 See header of drivers/net/hamradio/baycom_ser_fdx.c.
283 285
284 baycom_ser_hdx= [HW,AX25] BayCom Serial Port AX.25 Modem (Half Duplex Mode) 286 baycom_ser_hdx= [HW,AX25]
287 BayCom Serial Port AX.25 Modem (Half Duplex Mode)
285 Format: <io>,<irq>,<mode> 288 Format: <io>,<irq>,<mode>
286 See header of drivers/net/hamradio/baycom_ser_hdx.c. 289 See header of drivers/net/hamradio/baycom_ser_hdx.c.
287 290
@@ -292,7 +295,8 @@ running once the system is up.
292 blkmtd_count= 295 blkmtd_count=
293 296
294 bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards) 297 bttv.card= [HW,V4L] bttv (bt848 + bt878 based grabber cards)
295 bttv.radio= Most important insmod options are available as kernel args too. 298 bttv.radio= Most important insmod options are available as
299 kernel args too.
296 bttv.pll= See Documentation/video4linux/bttv/Insmod-options 300 bttv.pll= See Documentation/video4linux/bttv/Insmod-options
297 bttv.tuner= and Documentation/video4linux/bttv/CARDLIST 301 bttv.tuner= and Documentation/video4linux/bttv/CARDLIST
298 302
@@ -318,15 +322,17 @@ running once the system is up.
318 checkreqprot [SELINUX] Set initial checkreqprot flag value. 322 checkreqprot [SELINUX] Set initial checkreqprot flag value.
319 Format: { "0" | "1" } 323 Format: { "0" | "1" }
320 See security/selinux/Kconfig help text. 324 See security/selinux/Kconfig help text.
321 0 -- check protection applied by kernel (includes any implied execute protection). 325 0 -- check protection applied by kernel (includes
326 any implied execute protection).
322 1 -- check protection requested by application. 327 1 -- check protection requested by application.
323 Default value is set via a kernel config option. 328 Default value is set via a kernel config option.
324 Value can be changed at runtime via /selinux/checkreqprot. 329 Value can be changed at runtime via
325 330 /selinux/checkreqprot.
326 clock= [BUGS=IA-32, HW] gettimeofday timesource override. 331
332 clock= [BUGS=IA-32,HW] gettimeofday timesource override.
327 Forces specified timesource (if avaliable) to be used 333 Forces specified timesource (if avaliable) to be used
328 when calculating gettimeofday(). If specicified timesource 334 when calculating gettimeofday(). If specicified
329 is not avalible, it defaults to PIT. 335 timesource is not avalible, it defaults to PIT.
330 Format: { pit | tsc | cyclone | pmtmr } 336 Format: { pit | tsc | cyclone | pmtmr }
331 337
332 hpet= [IA-32,HPET] option to disable HPET and use PIT. 338 hpet= [IA-32,HPET] option to disable HPET and use PIT.
@@ -336,17 +342,19 @@ running once the system is up.
336 Format: { auto | [<io>,][<irq>] } 342 Format: { auto | [<io>,][<irq>] }
337 343
338 com20020= [HW,NET] ARCnet - COM20020 chipset 344 com20020= [HW,NET] ARCnet - COM20020 chipset
339 Format: <io>[,<irq>[,<nodeID>[,<backplane>[,<ckp>[,<timeout>]]]]] 345 Format:
346 <io>[,<irq>[,<nodeID>[,<backplane>[,<ckp>[,<timeout>]]]]]
340 347
341 com90io= [HW,NET] ARCnet - COM90xx chipset (IO-mapped buffers) 348 com90io= [HW,NET] ARCnet - COM90xx chipset (IO-mapped buffers)
342 Format: <io>[,<irq>] 349 Format: <io>[,<irq>]
343 350
344 com90xx= [HW,NET] ARCnet - COM90xx chipset (memory-mapped buffers) 351 com90xx= [HW,NET]
352 ARCnet - COM90xx chipset (memory-mapped buffers)
345 Format: <io>[,<irq>[,<memstart>]] 353 Format: <io>[,<irq>[,<memstart>]]
346 354
347 condev= [HW,S390] console device 355 condev= [HW,S390] console device
348 conmode= 356 conmode=
349 357
350 console= [KNL] Output console device and options. 358 console= [KNL] Output console device and options.
351 359
352 tty<n> Use the virtual console device <n>. 360 tty<n> Use the virtual console device <n>.
@@ -367,7 +375,8 @@ running once the system is up.
367 options are the same as for ttyS, above. 375 options are the same as for ttyS, above.
368 376
369 cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver 377 cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver
370 Format: <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>] 378 Format:
379 <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
371 380
372 cpia_pp= [HW,PPT] 381 cpia_pp= [HW,PPT]
373 Format: { parport<nr> | auto | none } 382 Format: { parport<nr> | auto | none }
@@ -384,10 +393,10 @@ running once the system is up.
384 393
385 cs89x0_media= [HW,NET] 394 cs89x0_media= [HW,NET]
386 Format: { rj45 | aui | bnc } 395 Format: { rj45 | aui | bnc }
387 396
388 cyclades= [HW,SERIAL] Cyclades multi-serial port adapter. 397 cyclades= [HW,SERIAL] Cyclades multi-serial port adapter.
389 398
390 dasd= [HW,NET] 399 dasd= [HW,NET]
391 See header of drivers/s390/block/dasd_devmap.c. 400 See header of drivers/s390/block/dasd_devmap.c.
392 401
393 db9.dev[2|3]= [HW,JOY] Multisystem joystick support via parallel port 402 db9.dev[2|3]= [HW,JOY] Multisystem joystick support via parallel port
@@ -406,7 +415,7 @@ running once the system is up.
406 415
407 dhash_entries= [KNL] 416 dhash_entries= [KNL]
408 Set number of hash buckets for dentry cache. 417 Set number of hash buckets for dentry cache.
409 418
410 digi= [HW,SERIAL] 419 digi= [HW,SERIAL]
411 IO parameters + enable/disable command. 420 IO parameters + enable/disable command.
412 421
@@ -424,11 +433,11 @@ running once the system is up.
424 433
425 dtc3181e= [HW,SCSI] 434 dtc3181e= [HW,SCSI]
426 435
427 earlyprintk= [IA-32, X86-64] 436 earlyprintk= [IA-32,X86-64]
428 earlyprintk=vga 437 earlyprintk=vga
429 earlyprintk=serial[,ttySn[,baudrate]] 438 earlyprintk=serial[,ttySn[,baudrate]]
430 439
431 Append ,keep to not disable it when the real console 440 Append ",keep" to not disable it when the real console
432 takes over. 441 takes over.
433 442
434 Only vga or serial at a time, not both. 443 Only vga or serial at a time, not both.
@@ -451,7 +460,7 @@ running once the system is up.
451 Format: {"of[f]" | "sk[ipmbr]"} 460 Format: {"of[f]" | "sk[ipmbr]"}
452 See comment in arch/i386/boot/edd.S 461 See comment in arch/i386/boot/edd.S
453 462
454 eicon= [HW,ISDN] 463 eicon= [HW,ISDN]
455 Format: <id>,<membase>,<irq> 464 Format: <id>,<membase>,<irq>
456 465
457 eisa_irq_edge= [PARISC,HW] 466 eisa_irq_edge= [PARISC,HW]
@@ -462,12 +471,13 @@ running once the system is up.
462 arch/i386/kernel/cpu/cpufreq/elanfreq.c. 471 arch/i386/kernel/cpu/cpufreq/elanfreq.c.
463 472
464 elevator= [IOSCHED] 473 elevator= [IOSCHED]
465 Format: {"as"|"cfq"|"deadline"|"noop"} 474 Format: {"as" | "cfq" | "deadline" | "noop"}
466 See Documentation/block/as-iosched.txt 475 See Documentation/block/as-iosched.txt and
467 and Documentation/block/deadline-iosched.txt for details. 476 Documentation/block/deadline-iosched.txt for details.
477
468 elfcorehdr= [IA-32] 478 elfcorehdr= [IA-32]
469 Specifies physical address of start of kernel core image 479 Specifies physical address of start of kernel core
470 elf header. 480 image elf header.
471 See Documentation/kdump.txt for details. 481 See Documentation/kdump.txt for details.
472 482
473 enforcing [SELINUX] Set initial enforcing status. 483 enforcing [SELINUX] Set initial enforcing status.
@@ -485,7 +495,7 @@ running once the system is up.
485 es1371= [HW,OSS] 495 es1371= [HW,OSS]
486 Format: <spdif>,[<nomix>,[<amplifier>]] 496 Format: <spdif>,[<nomix>,[<amplifier>]]
487 See also header of sound/oss/es1371.c. 497 See also header of sound/oss/es1371.c.
488 498
489 ether= [HW,NET] Ethernet cards parameters 499 ether= [HW,NET] Ethernet cards parameters
490 This option is obsoleted by the "netdev=" option, which 500 This option is obsoleted by the "netdev=" option, which
491 has equivalent usage. See its documentation for details. 501 has equivalent usage. See its documentation for details.
@@ -526,12 +536,13 @@ running once the system is up.
526 536
527 gus= [HW,OSS] 537 gus= [HW,OSS]
528 Format: <io>,<irq>,<dma>,<dma16> 538 Format: <io>,<irq>,<dma>,<dma16>
529 539
530 gvp11= [HW,SCSI] 540 gvp11= [HW,SCSI]
531 541
532 hashdist= [KNL,NUMA] Large hashes allocated during boot 542 hashdist= [KNL,NUMA] Large hashes allocated during boot
533 are distributed across NUMA nodes. Defaults on 543 are distributed across NUMA nodes. Defaults on
534 for IA-64, off otherwise. 544 for IA-64, off otherwise.
545 Format: 0 | 1 (for off | on)
535 546
536 hcl= [IA-64] SGI's Hardware Graph compatibility layer 547 hcl= [IA-64] SGI's Hardware Graph compatibility layer
537 548
@@ -595,13 +606,13 @@ running once the system is up.
595 ide?= [HW] (E)IDE subsystem 606 ide?= [HW] (E)IDE subsystem
596 Format: ide?=noprobe or chipset specific parameters. 607 Format: ide?=noprobe or chipset specific parameters.
597 See Documentation/ide.txt. 608 See Documentation/ide.txt.
598 609
599 idebus= [HW] (E)IDE subsystem - VLB/PCI bus speed 610 idebus= [HW] (E)IDE subsystem - VLB/PCI bus speed
600 See Documentation/ide.txt. 611 See Documentation/ide.txt.
601 612
602 idle= [HW] 613 idle= [HW]
603 Format: idle=poll or idle=halt 614 Format: idle=poll or idle=halt
604 615
605 ihash_entries= [KNL] 616 ihash_entries= [KNL]
606 Set number of hash buckets for inode cache. 617 Set number of hash buckets for inode cache.
607 618
@@ -649,7 +660,7 @@ running once the system is up.
649 firmware running. 660 firmware running.
650 661
651 isapnp= [ISAPNP] 662 isapnp= [ISAPNP]
652 Format: <RDP>, <reset>, <pci_scan>, <verbosity> 663 Format: <RDP>,<reset>,<pci_scan>,<verbosity>
653 664
654 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler. 665 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler.
655 Format: <cpu number>,...,<cpu number> 666 Format: <cpu number>,...,<cpu number>
@@ -661,32 +672,33 @@ running once the system is up.
661 "number of CPUs in system - 1". 672 "number of CPUs in system - 1".
662 673
663 This option is the preferred way to isolate CPUs. The 674 This option is the preferred way to isolate CPUs. The
664 alternative - manually setting the CPU mask of all tasks 675 alternative -- manually setting the CPU mask of all
665 in the system can cause problems and suboptimal load 676 tasks in the system -- can cause problems and
666 balancer performance. 677 suboptimal load balancer performance.
667 678
668 isp16= [HW,CD] 679 isp16= [HW,CD]
669 Format: <io>,<irq>,<dma>,<setup> 680 Format: <io>,<irq>,<dma>,<setup>
670 681
671 iucv= [HW,NET] 682 iucv= [HW,NET]
672 683
673 js= [HW,JOY] Analog joystick 684 js= [HW,JOY] Analog joystick
674 See Documentation/input/joystick.txt. 685 See Documentation/input/joystick.txt.
675 686
676 keepinitrd [HW,ARM] 687 keepinitrd [HW,ARM]
677 688
678 kstack=N [IA-32, X86-64] Print N words from the kernel stack 689 kstack=N [IA-32,X86-64] Print N words from the kernel stack
679 in oops dumps. 690 in oops dumps.
680 691
681 l2cr= [PPC] 692 l2cr= [PPC]
682 693
683 lapic [IA-32,APIC] Enable the local APIC even if BIOS disabled it. 694 lapic [IA-32,APIC] Enable the local APIC even if BIOS
695 disabled it.
684 696
685 lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip 697 lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip
686 Format: addr:<io>,irq:<irq> 698 Format: addr:<io>,irq:<irq>
687 699
688 llsc*= [IA64] 700 llsc*= [IA64] See function print_params() in
689 See function print_params() in arch/ia64/sn/kernel/llsc4.c. 701 arch/ia64/sn/kernel/llsc4.c.
690 702
691 load_ramdisk= [RAM] List of ramdisks to load from floppy 703 load_ramdisk= [RAM] List of ramdisks to load from floppy
692 See Documentation/ramdisk.txt. 704 See Documentation/ramdisk.txt.
@@ -713,8 +725,9 @@ running once the system is up.
713 7 (KERN_DEBUG) debug-level messages 725 7 (KERN_DEBUG) debug-level messages
714 726
715 log_buf_len=n Sets the size of the printk ring buffer, in bytes. 727 log_buf_len=n Sets the size of the printk ring buffer, in bytes.
716 Format is n, nk, nM. n must be a power of two. The 728 Format: { n | nk | nM }
717 default is set in kernel config. 729 n must be a power of two. The default size
730 is set in the kernel config file.
718 731
719 lp=0 [LP] Specify parallel ports to use, e.g, 732 lp=0 [LP] Specify parallel ports to use, e.g,
720 lp=port[,port...] lp=none,parport0 (lp0 not configured, lp1 uses 733 lp=port[,port...] lp=none,parport0 (lp0 not configured, lp1 uses
@@ -750,23 +763,23 @@ running once the system is up.
750 ltpc= [NET] 763 ltpc= [NET]
751 Format: <io>,<irq>,<dma> 764 Format: <io>,<irq>,<dma>
752 765
753 mac5380= [HW,SCSI] 766 mac5380= [HW,SCSI] Format:
754 Format: <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> 767 <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
755 768
756 mac53c9x= [HW,SCSI] 769 mac53c9x= [HW,SCSI] Format:
757 Format: <num_esps>,<disconnect>,<nosync>,<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> 770 <num_esps>,<disconnect>,<nosync>,<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
758 771
759 machvec= [IA64] 772 machvec= [IA64] Force the use of a particular machine-vector
760 Force the use of a particular machine-vector (machvec) in a generic 773 (machvec) in a generic kernel.
761 kernel. Example: machvec=hpzx1_swiotlb 774 Example: machvec=hpzx1_swiotlb
762 775
763 mad16= [HW,OSS] 776 mad16= [HW,OSS] Format:
764 Format: <io>,<irq>,<dma>,<dma16>,<mpu_io>,<mpu_irq>,<joystick> 777 <io>,<irq>,<dma>,<dma16>,<mpu_io>,<mpu_irq>,<joystick>
765 778
766 maui= [HW,OSS] 779 maui= [HW,OSS]
767 Format: <io>,<irq> 780 Format: <io>,<irq>
768 781
769 max_loop= [LOOP] Maximum number of loopback devices that can 782 max_loop= [LOOP] Maximum number of loopback devices that can
770 be mounted 783 be mounted
771 Format: <1-256> 784 Format: <1-256>
772 785
@@ -776,11 +789,11 @@ running once the system is up.
776 max_addr=[KMG] [KNL,BOOT,ia64] All physical memory greater than or 789 max_addr=[KMG] [KNL,BOOT,ia64] All physical memory greater than or
777 equal to this physical address is ignored. 790 equal to this physical address is ignored.
778 791
779 max_luns= [SCSI] Maximum number of LUNs to probe 792 max_luns= [SCSI] Maximum number of LUNs to probe.
780 Should be between 1 and 2^32-1. 793 Should be between 1 and 2^32-1.
781 794
782 max_report_luns= 795 max_report_luns=
783 [SCSI] Maximum number of LUNs received 796 [SCSI] Maximum number of LUNs received.
784 Should be between 1 and 16384. 797 Should be between 1 and 16384.
785 798
786 mca-pentium [BUGS=IA-32] 799 mca-pentium [BUGS=IA-32]
@@ -796,11 +809,11 @@ running once the system is up.
796 809
797 md= [HW] RAID subsystems devices and level 810 md= [HW] RAID subsystems devices and level
798 See Documentation/md.txt. 811 See Documentation/md.txt.
799 812
800 mdacon= [MDA] 813 mdacon= [MDA]
801 Format: <first>,<last> 814 Format: <first>,<last>
802 Specifies range of consoles to be captured by the MDA. 815 Specifies range of consoles to be captured by the MDA.
803 816
804 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory 817 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
805 Amount of memory to be used when the kernel is not able 818 Amount of memory to be used when the kernel is not able
806 to see the whole system memory or for test. 819 to see the whole system memory or for test.
@@ -851,15 +864,15 @@ running once the system is up.
851 MTD_Partition= [MTD] 864 MTD_Partition= [MTD]
852 Format: <name>,<region-number>,<size>,<offset> 865 Format: <name>,<region-number>,<size>,<offset>
853 866
854 MTD_Region= [MTD] 867 MTD_Region= [MTD] Format:
855 Format: <name>,<region-number>[,<base>,<size>,<buswidth>,<altbuswidth>] 868 <name>,<region-number>[,<base>,<size>,<buswidth>,<altbuswidth>]
856 869
857 mtdparts= [MTD] 870 mtdparts= [MTD]
858 See drivers/mtd/cmdline.c. 871 See drivers/mtd/cmdline.c.
859 872
860 mtouchusb.raw_coordinates= 873 mtouchusb.raw_coordinates=
861 [HW] Make the MicroTouch USB driver use raw coordinates ('y', default) 874 [HW] Make the MicroTouch USB driver use raw coordinates
862 or cooked coordinates ('n') 875 ('y', default) or cooked coordinates ('n')
863 876
864 n2= [NET] SDL Inc. RISCom/N2 synchronous serial card 877 n2= [NET] SDL Inc. RISCom/N2 synchronous serial card
865 878
@@ -880,7 +893,9 @@ running once the system is up.
880 Format: <irq>,<io>,<mem_start>,<mem_end>,<name> 893 Format: <irq>,<io>,<mem_start>,<mem_end>,<name>
881 Note that mem_start is often overloaded to mean 894 Note that mem_start is often overloaded to mean
882 something different and driver-specific. 895 something different and driver-specific.
883 896 This usage is only documented in each driver source
897 file if at all.
898
884 nfsaddrs= [NFS] 899 nfsaddrs= [NFS]
885 See Documentation/nfsroot.txt. 900 See Documentation/nfsroot.txt.
886 901
@@ -893,8 +908,8 @@ running once the system is up.
893 emulation library even if a 387 maths coprocessor 908 emulation library even if a 387 maths coprocessor
894 is present. 909 is present.
895 910
896 noalign [KNL,ARM] 911 noalign [KNL,ARM]
897 912
898 noapic [SMP,APIC] Tells the kernel to not make use of any 913 noapic [SMP,APIC] Tells the kernel to not make use of any
899 IOAPICs that may be present in the system. 914 IOAPICs that may be present in the system.
900 915
@@ -905,19 +920,19 @@ running once the system is up.
905 on "Classic" PPC cores. 920 on "Classic" PPC cores.
906 921
907 nocache [ARM] 922 nocache [ARM]
908 923
909 nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects. 924 nodisconnect [HW,SCSI,M68K] Disables SCSI disconnects.
910 925
911 noexec [IA-64] 926 noexec [IA-64]
912 927
913 noexec [IA-32, X86-64] 928 noexec [IA-32,X86-64]
914 noexec=on: enable non-executable mappings (default) 929 noexec=on: enable non-executable mappings (default)
915 noexec=off: disable nn-executable mappings 930 noexec=off: disable nn-executable mappings
916 931
917 nofxsr [BUGS=IA-32] 932 nofxsr [BUGS=IA-32]
918 933
919 nohlt [BUGS=ARM] 934 nohlt [BUGS=ARM]
920 935
921 no-hlt [BUGS=IA-32] Tells the kernel that the hlt 936 no-hlt [BUGS=IA-32] Tells the kernel that the hlt
922 instruction doesn't work correctly and not to 937 instruction doesn't work correctly and not to
923 use it. 938 use it.
@@ -948,8 +963,9 @@ running once the system is up.
948 963
949 noresidual [PPC] Don't use residual data on PReP machines. 964 noresidual [PPC] Don't use residual data on PReP machines.
950 965
951 noresume [SWSUSP] Disables resume and restore original swap space. 966 noresume [SWSUSP] Disables resume and restores original swap
952 967 space.
968
953 no-scroll [VGA] Disables scrollback. 969 no-scroll [VGA] Disables scrollback.
954 This is required for the Braillex ib80-piezo Braille 970 This is required for the Braillex ib80-piezo Braille
955 reader made by F.H. Papenmeier (Germany). 971 reader made by F.H. Papenmeier (Germany).
@@ -965,16 +981,16 @@ running once the system is up.
965 nousb [USB] Disable the USB subsystem 981 nousb [USB] Disable the USB subsystem
966 982
967 nowb [ARM] 983 nowb [ARM]
968 984
969 opl3= [HW,OSS] 985 opl3= [HW,OSS]
970 Format: <io> 986 Format: <io>
971 987
972 opl3sa= [HW,OSS] 988 opl3sa= [HW,OSS]
973 Format: <io>,<irq>,<dma>,<dma2>,<mpu_io>,<mpu_irq> 989 Format: <io>,<irq>,<dma>,<dma2>,<mpu_io>,<mpu_irq>
974 990
975 opl3sa2= [HW,OSS] 991 opl3sa2= [HW,OSS] Format:
976 Format: <io>,<irq>,<dma>,<dma2>,<mss_io>,<mpu_io>,<ymode>,<loopback>[,<isapnp>,<multiple] 992 <io>,<irq>,<dma>,<dma2>,<mss_io>,<mpu_io>,<ymode>,<loopback>[,<isapnp>,<multiple]
977 993
978 oprofile.timer= [HW] 994 oprofile.timer= [HW]
979 Use timer interrupt instead of performance counters 995 Use timer interrupt instead of performance counters
980 996
@@ -993,36 +1009,33 @@ running once the system is up.
993 Format: <parport#> 1009 Format: <parport#>
994 parkbd.mode= [HW] Parallel port keyboard adapter mode of operation, 1010 parkbd.mode= [HW] Parallel port keyboard adapter mode of operation,
995 0 for XT, 1 for AT (default is AT). 1011 0 for XT, 1 for AT (default is AT).
996 Format: <mode> 1012 Format: <mode>
997 1013
998 parport=0 [HW,PPT] Specify parallel ports. 0 disables. 1014 parport= [HW,PPT] Specify parallel ports. 0 disables.
999 parport=auto Use 'auto' to force the driver to use 1015 Format: { 0 | auto | 0xBBB[,IRQ[,DMA]] }
1000 parport=0xBBB[,IRQ[,DMA]] any IRQ/DMA settings detected (the 1016 Use 'auto' to force the driver to use any
1001 default is to ignore detected IRQ/DMA 1017 IRQ/DMA settings detected (the default is to
1002 settings because of possible 1018 ignore detected IRQ/DMA settings because of
1003 conflicts). You can specify the base 1019 possible conflicts). You can specify the base
1004 address, IRQ, and DMA settings; IRQ and 1020 address, IRQ, and DMA settings; IRQ and DMA
1005 DMA should be numbers, or 'auto' (for 1021 should be numbers, or 'auto' (for using detected
1006 using detected settings on that 1022 settings on that particular port), or 'nofifo'
1007 particular port), or 'nofifo' (to avoid 1023 (to avoid using a FIFO even if it is detected).
1008 using a FIFO even if it is detected). 1024 Parallel ports are assigned in the order they
1009 Parallel ports are assigned in the 1025 are specified on the command line, starting
1010 order they are specified on the command 1026 with parport0.
1011 line, starting with parport0. 1027
1012 1028 parport_init_mode= [HW,PPT]
1013 parport_init_mode= 1029 Configure VIA parallel port to operate in
1014 [HW,PPT] Configure VIA parallel port to 1030 a specific mode. This is necessary on Pegasos
1015 operate in specific mode. This is 1031 computer where firmware has no options for setting
1016 necessary on Pegasos computer where 1032 up parallel port mode and sets it to spp.
1017 firmware has no options for setting up 1033 Currently this function knows 686a and 8231 chips.
1018 parallel port mode and sets it to
1019 spp. Currently this function knows
1020 686a and 8231 chips.
1021 Format: [spp|ps2|epp|ecp|ecpepp] 1034 Format: [spp|ps2|epp|ecp|ecpepp]
1022 1035
1023 pas2= [HW,OSS] 1036 pas2= [HW,OSS] Format:
1024 Format: <io>,<irq>,<dma>,<dma16>,<sb_io>,<sb_irq>,<sb_dma>,<sb_dma16> 1037 <io>,<irq>,<dma>,<dma16>,<sb_io>,<sb_irq>,<sb_dma>,<sb_dma16>
1025 1038
1026 pas16= [HW,SCSI] 1039 pas16= [HW,SCSI]
1027 See header of drivers/scsi/pas16.c. 1040 See header of drivers/scsi/pas16.c.
1028 1041
@@ -1032,64 +1045,67 @@ running once the system is up.
1032 See header of drivers/block/paride/pcd.c. 1045 See header of drivers/block/paride/pcd.c.
1033 See also Documentation/paride.txt. 1046 See also Documentation/paride.txt.
1034 1047
1035 pci=option[,option...] [PCI] various PCI subsystem options: 1048 pci=option[,option...] [PCI] various PCI subsystem options:
1036 off [IA-32] don't probe for the PCI bus 1049 off [IA-32] don't probe for the PCI bus
1037 bios [IA-32] force use of PCI BIOS, don't access 1050 bios [IA-32] force use of PCI BIOS, don't access
1038 the hardware directly. Use this if your machine 1051 the hardware directly. Use this if your machine
1039 has a non-standard PCI host bridge. 1052 has a non-standard PCI host bridge.
1040 nobios [IA-32] disallow use of PCI BIOS, only direct 1053 nobios [IA-32] disallow use of PCI BIOS, only direct
1041 hardware access methods are allowed. Use this 1054 hardware access methods are allowed. Use this
1042 if you experience crashes upon bootup and you 1055 if you experience crashes upon bootup and you
1043 suspect they are caused by the BIOS. 1056 suspect they are caused by the BIOS.
1044 conf1 [IA-32] Force use of PCI Configuration Mechanism 1. 1057 conf1 [IA-32] Force use of PCI Configuration
1045 conf2 [IA-32] Force use of PCI Configuration Mechanism 2. 1058 Mechanism 1.
1046 nosort [IA-32] Don't sort PCI devices according to 1059 conf2 [IA-32] Force use of PCI Configuration
1047 order given by the PCI BIOS. This sorting is done 1060 Mechanism 2.
1048 to get a device order compatible with older kernels. 1061 nosort [IA-32] Don't sort PCI devices according to
1049 biosirq [IA-32] Use PCI BIOS calls to get the interrupt 1062 order given by the PCI BIOS. This sorting is
1050 routing table. These calls are known to be buggy 1063 done to get a device order compatible with
1051 on several machines and they hang the machine when used, 1064 older kernels.
1052 but on other computers it's the only way to get the 1065 biosirq [IA-32] Use PCI BIOS calls to get the interrupt
1053 interrupt routing table. Try this option if the kernel 1066 routing table. These calls are known to be buggy
1054 is unable to allocate IRQs or discover secondary PCI 1067 on several machines and they hang the machine
1055 buses on your motherboard. 1068 when used, but on other computers it's the only
1056 rom [IA-32] Assign address space to expansion ROMs. 1069 way to get the interrupt routing table. Try
1057 Use with caution as certain devices share address 1070 this option if the kernel is unable to allocate
1058 decoders between ROMs and other resources. 1071 IRQs or discover secondary PCI buses on your
1059 irqmask=0xMMMM [IA-32] Set a bit mask of IRQs allowed to be assigned 1072 motherboard.
1060 automatically to PCI devices. You can make the kernel 1073 rom [IA-32] Assign address space to expansion ROMs.
1061 exclude IRQs of your ISA cards this way. 1074 Use with caution as certain devices share
1075 address decoders between ROMs and other
1076 resources.
1077 irqmask=0xMMMM [IA-32] Set a bit mask of IRQs allowed to be
1078 assigned automatically to PCI devices. You can
1079 make the kernel exclude IRQs of your ISA cards
1080 this way.
1062 pirqaddr=0xAAAAA [IA-32] Specify the physical address 1081 pirqaddr=0xAAAAA [IA-32] Specify the physical address
1063 of the PIRQ table (normally generated 1082 of the PIRQ table (normally generated
1064 by the BIOS) if it is outside the 1083 by the BIOS) if it is outside the
1065 F0000h-100000h range. 1084 F0000h-100000h range.
1066 lastbus=N [IA-32] Scan all buses till bus #N. Can be useful 1085 lastbus=N [IA-32] Scan all buses thru bus #N. Can be
1067 if the kernel is unable to find your secondary buses 1086 useful if the kernel is unable to find your
1068 and you want to tell it explicitly which ones they are. 1087 secondary buses and you want to tell it
1069 assign-busses [IA-32] Always assign all PCI bus 1088 explicitly which ones they are.
1070 numbers ourselves, overriding 1089 assign-busses [IA-32] Always assign all PCI bus
1071 whatever the firmware may have 1090 numbers ourselves, overriding
1072 done. 1091 whatever the firmware may have done.
1073 usepirqmask [IA-32] Honor the possible IRQ mask 1092 usepirqmask [IA-32] Honor the possible IRQ mask stored
1074 stored in the BIOS $PIR table. This is 1093 in the BIOS $PIR table. This is needed on
1075 needed on some systems with broken 1094 some systems with broken BIOSes, notably
1076 BIOSes, notably some HP Pavilion N5400 1095 some HP Pavilion N5400 and Omnibook XE3
1077 and Omnibook XE3 notebooks. This will 1096 notebooks. This will have no effect if ACPI
1078 have no effect if ACPI IRQ routing is 1097 IRQ routing is enabled.
1079 enabled. 1098 noacpi [IA-32] Do not use ACPI for IRQ routing
1080 noacpi [IA-32] Do not use ACPI for IRQ routing 1099 or for PCI scanning.
1081 or for PCI scanning. 1100 routeirq Do IRQ routing for all PCI devices.
1082 routeirq Do IRQ routing for all PCI devices. 1101 This is normally done in pci_enable_device(),
1083 This is normally done in pci_enable_device(), 1102 so this option is a temporary workaround
1084 so this option is a temporary workaround 1103 for broken drivers that don't call it.
1085 for broken drivers that don't call it. 1104 firmware [ARM] Do not re-enumerate the bus but instead
1086 1105 just use the configuration from the
1087 firmware [ARM] Do not re-enumerate the bus but 1106 bootloader. This is currently used on
1088 instead just use the configuration 1107 IXP2000 systems where the bus has to be
1089 from the bootloader. This is currently 1108 configured a certain way for adjunct CPUs.
1090 used on IXP2000 systems where the
1091 bus has to be configured a certain way
1092 for adjunct CPUs.
1093 1109
1094 pcmv= [HW,PCMCIA] BadgePAD 4 1110 pcmv= [HW,PCMCIA] BadgePAD 4
1095 1111
@@ -1127,19 +1143,20 @@ running once the system is up.
1127 [ISAPNP] Exclude DMAs for the autoconfiguration 1143 [ISAPNP] Exclude DMAs for the autoconfiguration
1128 1144
1129 pnp_reserve_io= [ISAPNP] Exclude I/O ports for the autoconfiguration 1145 pnp_reserve_io= [ISAPNP] Exclude I/O ports for the autoconfiguration
1130 Ranges are in pairs (I/O port base and size). 1146 Ranges are in pairs (I/O port base and size).
1131 1147
1132 pnp_reserve_mem= 1148 pnp_reserve_mem=
1133 [ISAPNP] Exclude memory regions for the autoconfiguration 1149 [ISAPNP] Exclude memory regions for the
1150 autoconfiguration.
1134 Ranges are in pairs (memory base and size). 1151 Ranges are in pairs (memory base and size).
1135 1152
1136 profile= [KNL] Enable kernel profiling via /proc/profile 1153 profile= [KNL] Enable kernel profiling via /proc/profile
1137 { schedule | <number> } 1154 Format: [schedule,]<number>
1138 (param: schedule - profile schedule points} 1155 Param: "schedule" - profile schedule points.
1139 (param: profile step/bucket size as a power of 2 for 1156 Param: <number> - step/bucket size as a power of 2 for
1140 statistical time based profiling) 1157 statistical time based profiling.
1141 1158
1142 processor.max_cstate= [HW, ACPI] 1159 processor.max_cstate= [HW,ACPI]
1143 Limit processor to maximum C-state 1160 Limit processor to maximum C-state
1144 max_cstate=9 overrides any DMI blacklist limit. 1161 max_cstate=9 overrides any DMI blacklist limit.
1145 1162
@@ -1147,27 +1164,28 @@ running once the system is up.
1147 before loading. 1164 before loading.
1148 See Documentation/ramdisk.txt. 1165 See Documentation/ramdisk.txt.
1149 1166
1150 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to 1167 psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to
1151 probe for (bare|imps|exps|lifebook|any). 1168 probe for; one of (bare|imps|exps|lifebook|any).
1152 psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports 1169 psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports
1153 per second. 1170 per second.
1154 psmouse.resetafter= 1171 psmouse.resetafter= [HW,MOUSE]
1155 [HW,MOUSE] Try to reset the device after so many bad packets 1172 Try to reset the device after so many bad packets
1156 (0 = never). 1173 (0 = never).
1157 psmouse.resolution= 1174 psmouse.resolution=
1158 [HW,MOUSE] Set desired mouse resolution, in dpi. 1175 [HW,MOUSE] Set desired mouse resolution, in dpi.
1159 psmouse.smartscroll= 1176 psmouse.smartscroll=
1160 [HW,MOUSE] Controls Logitech smartscroll autorepeat, 1177 [HW,MOUSE] Controls Logitech smartscroll autorepeat.
1161 0 = disabled, 1 = enabled (default). 1178 0 = disabled, 1 = enabled (default).
1162 1179
1163 pss= [HW,OSS] Personal Sound System (ECHO ESC614) 1180 pss= [HW,OSS] Personal Sound System (ECHO ESC614)
1164 Format: <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq> 1181 Format:
1182 <io>,<mss_io>,<mss_irq>,<mss_dma>,<mpu_io>,<mpu_irq>
1165 1183
1166 pt. [PARIDE] 1184 pt. [PARIDE]
1167 See Documentation/paride.txt. 1185 See Documentation/paride.txt.
1168 1186
1169 quiet= [KNL] Disable log messages 1187 quiet= [KNL] Disable log messages
1170 1188
1171 r128= [HW,DRM] 1189 r128= [HW,DRM]
1172 1190
1173 raid= [HW,RAID] 1191 raid= [HW,RAID]
@@ -1176,10 +1194,9 @@ running once the system is up.
1176 ramdisk= [RAM] Sizes of RAM disks in kilobytes [deprecated] 1194 ramdisk= [RAM] Sizes of RAM disks in kilobytes [deprecated]
1177 See Documentation/ramdisk.txt. 1195 See Documentation/ramdisk.txt.
1178 1196
1179 ramdisk_blocksize= 1197 ramdisk_blocksize= [RAM]
1180 [RAM]
1181 See Documentation/ramdisk.txt. 1198 See Documentation/ramdisk.txt.
1182 1199
1183 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes 1200 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
1184 New name for the ramdisk parameter. 1201 New name for the ramdisk parameter.
1185 See Documentation/ramdisk.txt. 1202 See Documentation/ramdisk.txt.
@@ -1195,7 +1212,8 @@ running once the system is up.
1195 1212
1196 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area 1213 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area
1197 1214
1198 resume= [SWSUSP] Specify the partition device for software suspension 1215 resume= [SWSUSP]
1216 Specify the partition device for software suspend
1199 1217
1200 rhash_entries= [KNL,NET] 1218 rhash_entries= [KNL,NET]
1201 Set number of hash buckets for route cache 1219 Set number of hash buckets for route cache
@@ -1225,7 +1243,7 @@ running once the system is up.
1225 Format: <io>,<irq>,<dma>,<dma2> 1243 Format: <io>,<irq>,<dma>,<dma2>
1226 1244
1227 sbni= [NET] Granch SBNI12 leased line adapter 1245 sbni= [NET] Granch SBNI12 leased line adapter
1228 1246
1229 sbpcd= [HW,CD] Soundblaster CD adapter 1247 sbpcd= [HW,CD] Soundblaster CD adapter
1230 Format: <io>,<type> 1248 Format: <io>,<type>
1231 See a comment before function sbpcd_setup() in 1249 See a comment before function sbpcd_setup() in
@@ -1258,21 +1276,20 @@ running once the system is up.
1258 1276
1259 serialnumber [BUGS=IA-32] 1277 serialnumber [BUGS=IA-32]
1260 1278
1261 sg_def_reserved_size= 1279 sg_def_reserved_size= [SCSI]
1262 [SCSI] 1280
1263
1264 sgalaxy= [HW,OSS] 1281 sgalaxy= [HW,OSS]
1265 Format: <io>,<irq>,<dma>,<dma2>,<sgbase> 1282 Format: <io>,<irq>,<dma>,<dma2>,<sgbase>
1266 1283
1267 shapers= [NET] 1284 shapers= [NET]
1268 Maximal number of shapers. 1285 Maximal number of shapers.
1269 1286
1270 sim710= [SCSI,HW] 1287 sim710= [SCSI,HW]
1271 See header of drivers/scsi/sim710.c. 1288 See header of drivers/scsi/sim710.c.
1272 1289
1273 simeth= [IA-64] 1290 simeth= [IA-64]
1274 simscsi= 1291 simscsi=
1275 1292
1276 sjcd= [HW,CD] 1293 sjcd= [HW,CD]
1277 Format: <io>,<irq>,<dma> 1294 Format: <io>,<irq>,<dma>
1278 See header of drivers/cdrom/sjcd.c. 1295 See header of drivers/cdrom/sjcd.c.
@@ -1403,10 +1420,10 @@ running once the system is up.
1403 snd-wavefront= [HW,ALSA] 1420 snd-wavefront= [HW,ALSA]
1404 1421
1405 snd-ymfpci= [HW,ALSA] 1422 snd-ymfpci= [HW,ALSA]
1406 1423
1407 sonicvibes= [HW,OSS] 1424 sonicvibes= [HW,OSS]
1408 Format: <reverb> 1425 Format: <reverb>
1409 1426
1410 sonycd535= [HW,CD] 1427 sonycd535= [HW,CD]
1411 Format: <io>[,<irq>] 1428 Format: <io>[,<irq>]
1412 1429
@@ -1423,7 +1440,7 @@ running once the system is up.
1423 1440
1424 sscape= [HW,OSS] 1441 sscape= [HW,OSS]
1425 Format: <io>,<irq>,<dma>,<mpu_io>,<mpu_irq> 1442 Format: <io>,<irq>,<dma>,<mpu_io>,<mpu_irq>
1426 1443
1427 st= [HW,SCSI] SCSI tape parameters (buffers, etc.) 1444 st= [HW,SCSI] SCSI tape parameters (buffers, etc.)
1428 See Documentation/scsi/st.txt. 1445 See Documentation/scsi/st.txt.
1429 1446
@@ -1446,7 +1463,7 @@ running once the system is up.
1446 stram_swap= [HW,M68k] 1463 stram_swap= [HW,M68k]
1447 1464
1448 swiotlb= [IA-64] Number of I/O TLB slabs 1465 swiotlb= [IA-64] Number of I/O TLB slabs
1449 1466
1450 switches= [HW,M68k] 1467 switches= [HW,M68k]
1451 1468
1452 sym53c416= [HW,SCSI] 1469 sym53c416= [HW,SCSI]
@@ -1479,14 +1496,16 @@ running once the system is up.
1479 tp720= [HW,PS2] 1496 tp720= [HW,PS2]
1480 1497
1481 trix= [HW,OSS] MediaTrix AudioTrix Pro 1498 trix= [HW,OSS] MediaTrix AudioTrix Pro
1482 Format: <io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq> 1499 Format:
1483 1500 <io>,<irq>,<dma>,<dma2>,<sb_io>,<sb_irq>,<sb_dma>,<mpu_io>,<mpu_irq>
1501
1484 tsdev.xres= [TS] Horizontal screen resolution. 1502 tsdev.xres= [TS] Horizontal screen resolution.
1485 tsdev.yres= [TS] Vertical screen resolution. 1503 tsdev.yres= [TS] Vertical screen resolution.
1486 1504
1487 turbografx.map[2|3]= 1505 turbografx.map[2|3]= [HW,JOY]
1488 [HW,JOY] TurboGraFX parallel port interface 1506 TurboGraFX parallel port interface
1489 Format: <port#>,<js1>,<js2>,<js3>,<js4>,<js5>,<js6>,<js7> 1507 Format:
1508 <port#>,<js1>,<js2>,<js3>,<js4>,<js5>,<js6>,<js7>
1490 See also Documentation/input/joystick-parport.txt 1509 See also Documentation/input/joystick-parport.txt
1491 1510
1492 u14-34f= [HW,SCSI] UltraStor 14F/34F SCSI host adapter 1511 u14-34f= [HW,SCSI] UltraStor 14F/34F SCSI host adapter
@@ -1502,17 +1521,18 @@ running once the system is up.
1502 1521
1503 usbhid.mousepoll= 1522 usbhid.mousepoll=
1504 [USBHID] The interval which mice are to be polled at. 1523 [USBHID] The interval which mice are to be polled at.
1505 1524
1506 video= [FB] Frame buffer configuration 1525 video= [FB] Frame buffer configuration
1507 See Documentation/fb/modedb.txt. 1526 See Documentation/fb/modedb.txt.
1508 1527
1509 vga= [BOOT,IA-32] Select a particular video mode 1528 vga= [BOOT,IA-32] Select a particular video mode
1510 See Documentation/i386/boot.txt and Documentation/svga.txt. 1529 See Documentation/i386/boot.txt and
1530 Documentation/svga.txt.
1511 Use vga=ask for menu. 1531 Use vga=ask for menu.
1512 This is actually a boot loader parameter; the value is 1532 This is actually a boot loader parameter; the value is
1513 passed to the kernel using a special protocol. 1533 passed to the kernel using a special protocol.
1514 1534
1515 vmalloc=nn[KMG] [KNL,BOOT] forces the vmalloc area to have an exact 1535 vmalloc=nn[KMG] [KNL,BOOT] Forces the vmalloc area to have an exact
1516 size of <nn>. This can be used to increase the 1536 size of <nn>. This can be used to increase the
1517 minimum size (128MB on x86). It can also be used to 1537 minimum size (128MB on x86). It can also be used to
1518 decrease the size and leave more room for directly 1538 decrease the size and leave more room for directly
@@ -1520,11 +1540,11 @@ running once the system is up.
1520 1540
1521 vmhalt= [KNL,S390] 1541 vmhalt= [KNL,S390]
1522 1542
1523 vmpoff= [KNL,S390] 1543 vmpoff= [KNL,S390]
1524 1544
1525 waveartist= [HW,OSS] 1545 waveartist= [HW,OSS]
1526 Format: <io>,<irq>,<dma>,<dma2> 1546 Format: <io>,<irq>,<dma>,<dma2>
1527 1547
1528 wd33c93= [HW,SCSI] 1548 wd33c93= [HW,SCSI]
1529 See header of drivers/scsi/wd33c93.c. 1549 See header of drivers/scsi/wd33c93.c.
1530 1550
@@ -1538,21 +1558,25 @@ running once the system is up.
1538 xd_geo= See header of drivers/block/xd.c. 1558 xd_geo= See header of drivers/block/xd.c.
1539 1559
1540 xirc2ps_cs= [NET,PCMCIA] 1560 xirc2ps_cs= [NET,PCMCIA]
1541 Format: <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] 1561 Format:
1542 1562 <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]]
1543 1563
1544 1564
1565______________________________________________________________________
1545Changelog: 1566Changelog:
1546 1567
15682000-06-?? Mr. Unknown
1547 The last known update (for 2.4.0) - the changelog was not kept before. 1569 The last known update (for 2.4.0) - the changelog was not kept before.
1548 2000-06-?? Mr. Unknown
1549 1570
15712002-11-24 Petr Baudis <pasky@ucw.cz>
1572 Randy Dunlap <randy.dunlap@verizon.net>
1550 Update for 2.5.49, description for most of the options introduced, 1573 Update for 2.5.49, description for most of the options introduced,
1551 references to other documentation (C files, READMEs, ..), added S390, 1574 references to other documentation (C files, READMEs, ..), added S390,
1552 PPC, SPARC, MTD, ALSA and OSS category. Minor corrections and 1575 PPC, SPARC, MTD, ALSA and OSS category. Minor corrections and
1553 reformatting. 1576 reformatting.
1554 2002-11-24 Petr Baudis <pasky@ucw.cz> 1577
1555 Randy Dunlap <randy.dunlap@verizon.net> 15782005-10-19 Randy Dunlap <rdunlap@xenotime.net>
1579 Lots of typos, whitespace, some reformatting.
1556 1580
1557TODO: 1581TODO:
1558 1582
diff --git a/Documentation/keys-request-key.txt b/Documentation/keys-request-key.txt
new file mode 100644
index 000000000000..5f2b9c5edbb5
--- /dev/null
+++ b/Documentation/keys-request-key.txt
@@ -0,0 +1,161 @@
1 ===================
2 KEY REQUEST SERVICE
3 ===================
4
5The key request service is part of the key retention service (refer to
6Documentation/keys.txt). This document explains more fully how that the
7requesting algorithm works.
8
9The process starts by either the kernel requesting a service by calling
10request_key():
11
12 struct key *request_key(const struct key_type *type,
13 const char *description,
14 const char *callout_string);
15
16Or by userspace invoking the request_key system call:
17
18 key_serial_t request_key(const char *type,
19 const char *description,
20 const char *callout_info,
21 key_serial_t dest_keyring);
22
23The main difference between the two access points is that the in-kernel
24interface does not need to link the key to a keyring to prevent it from being
25immediately destroyed. The kernel interface returns a pointer directly to the
26key, and it's up to the caller to destroy the key.
27
28The userspace interface links the key to a keyring associated with the process
29to prevent the key from going away, and returns the serial number of the key to
30the caller.
31
32
33===========
34THE PROCESS
35===========
36
37A request proceeds in the following manner:
38
39 (1) Process A calls request_key() [the userspace syscall calls the kernel
40 interface].
41
42 (2) request_key() searches the process's subscribed keyrings to see if there's
43 a suitable key there. If there is, it returns the key. If there isn't, and
44 callout_info is not set, an error is returned. Otherwise the process
45 proceeds to the next step.
46
47 (3) request_key() sees that A doesn't have the desired key yet, so it creates
48 two things:
49
50 (a) An uninstantiated key U of requested type and description.
51
52 (b) An authorisation key V that refers to key U and notes that process A
53 is the context in which key U should be instantiated and secured, and
54 from which associated key requests may be satisfied.
55
56 (4) request_key() then forks and executes /sbin/request-key with a new session
57 keyring that contains a link to auth key V.
58
59 (5) /sbin/request-key execs an appropriate program to perform the actual
60 instantiation.
61
62 (6) The program may want to access another key from A's context (say a
63 Kerberos TGT key). It just requests the appropriate key, and the keyring
64 search notes that the session keyring has auth key V in its bottom level.
65
66 This will permit it to then search the keyrings of process A with the
67 UID, GID, groups and security info of process A as if it was process A,
68 and come up with key W.
69
70 (7) The program then does what it must to get the data with which to
71 instantiate key U, using key W as a reference (perhaps it contacts a
72 Kerberos server using the TGT) and then instantiates key U.
73
74 (8) Upon instantiating key U, auth key V is automatically revoked so that it
75 may not be used again.
76
77 (9) The program then exits 0 and request_key() deletes key V and returns key
78 U to the caller.
79
80This also extends further. If key W (step 5 above) didn't exist, key W would be
81created uninstantiated, another auth key (X) would be created [as per step 3]
82and another copy of /sbin/request-key spawned [as per step 4]; but the context
83specified by auth key X will still be process A, as it was in auth key V.
84
85This is because process A's keyrings can't simply be attached to
86/sbin/request-key at the appropriate places because (a) execve will discard two
87of them, and (b) it requires the same UID/GID/Groups all the way through.
88
89
90======================
91NEGATIVE INSTANTIATION
92======================
93
94Rather than instantiating a key, it is possible for the possessor of an
95authorisation key to negatively instantiate a key that's under construction.
96This is a short duration placeholder that causes any attempt at re-requesting
97the key whilst it exists to fail with error ENOKEY.
98
99This is provided to prevent excessive repeated spawning of /sbin/request-key
100processes for a key that will never be obtainable.
101
102Should the /sbin/request-key process exit anything other than 0 or die on a
103signal, the key under construction will be automatically negatively
104instantiated for a short amount of time.
105
106
107====================
108THE SEARCH ALGORITHM
109====================
110
111A search of any particular keyring proceeds in the following fashion:
112
113 (1) When the key management code searches for a key (keyring_search_aux) it
114 firstly calls key_permission(SEARCH) on the keyring it's starting with,
115 if this denies permission, it doesn't search further.
116
117 (2) It considers all the non-keyring keys within that keyring and, if any key
118 matches the criteria specified, calls key_permission(SEARCH) on it to see
119 if the key is allowed to be found. If it is, that key is returned; if
120 not, the search continues, and the error code is retained if of higher
121 priority than the one currently set.
122
123 (3) It then considers all the keyring-type keys in the keyring it's currently
124 searching. It calls key_permission(SEARCH) on each keyring, and if this
125 grants permission, it recurses, executing steps (2) and (3) on that
126 keyring.
127
128The process stops immediately a valid key is found with permission granted to
129use it. Any error from a previous match attempt is discarded and the key is
130returned.
131
132When search_process_keyrings() is invoked, it performs the following searches
133until one succeeds:
134
135 (1) If extant, the process's thread keyring is searched.
136
137 (2) If extant, the process's process keyring is searched.
138
139 (3) The process's session keyring is searched.
140
141 (4) If the process has a request_key() authorisation key in its session
142 keyring then:
143
144 (a) If extant, the calling process's thread keyring is searched.
145
146 (b) If extant, the calling process's process keyring is searched.
147
148 (c) The calling process's session keyring is searched.
149
150The moment one succeeds, all pending errors are discarded and the found key is
151returned.
152
153Only if all these fail does the whole thing fail with the highest priority
154error. Note that several errors may have come from LSM.
155
156The error priority is:
157
158 EKEYREVOKED > EKEYEXPIRED > ENOKEY
159
160EACCES/EPERM are only returned on a direct search of a specific keyring where
161the basal keyring does not grant Search permission.
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index 0321ded4b9ae..4afe03a58c5b 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -195,8 +195,8 @@ KEY ACCESS PERMISSIONS
195====================== 195======================
196 196
197Keys have an owner user ID, a group access ID, and a permissions mask. The mask 197Keys have an owner user ID, a group access ID, and a permissions mask. The mask
198has up to eight bits each for user, group and other access. Only five of each 198has up to eight bits each for possessor, user, group and other access. Only
199set of eight bits are defined. These permissions granted are: 199five of each set of eight bits are defined. These permissions granted are:
200 200
201 (*) View 201 (*) View
202 202
@@ -241,16 +241,16 @@ about the status of the key service:
241 type, description and permissions. The payload of the key is not available 241 type, description and permissions. The payload of the key is not available
242 this way: 242 this way:
243 243
244 SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY 244 SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY
245 00000001 I----- 39 perm 1f0000 0 0 keyring _uid_ses.0: 1/4 245 00000001 I----- 39 perm 1f1f0000 0 0 keyring _uid_ses.0: 1/4
246 00000002 I----- 2 perm 1f0000 0 0 keyring _uid.0: empty 246 00000002 I----- 2 perm 1f1f0000 0 0 keyring _uid.0: empty
247 00000007 I----- 1 perm 1f0000 0 0 keyring _pid.1: empty 247 00000007 I----- 1 perm 1f1f0000 0 0 keyring _pid.1: empty
248 0000018d I----- 1 perm 1f0000 0 0 keyring _pid.412: empty 248 0000018d I----- 1 perm 1f1f0000 0 0 keyring _pid.412: empty
249 000004d2 I--Q-- 1 perm 1f0000 32 -1 keyring _uid.32: 1/4 249 000004d2 I--Q-- 1 perm 1f1f0000 32 -1 keyring _uid.32: 1/4
250 000004d3 I--Q-- 3 perm 1f0000 32 -1 keyring _uid_ses.32: empty 250 000004d3 I--Q-- 3 perm 1f1f0000 32 -1 keyring _uid_ses.32: empty
251 00000892 I--QU- 1 perm 1f0000 0 0 user metal:copper: 0 251 00000892 I--QU- 1 perm 1f000000 0 0 user metal:copper: 0
252 00000893 I--Q-N 1 35s 1f0000 0 0 user metal:silver: 0 252 00000893 I--Q-N 1 35s 1f1f0000 0 0 user metal:silver: 0
253 00000894 I--Q-- 1 10h 1f0000 0 0 user metal:gold: 0 253 00000894 I--Q-- 1 10h 001f0000 0 0 user metal:gold: 0
254 254
255 The flags are: 255 The flags are:
256 256
@@ -361,6 +361,8 @@ The main syscalls are:
361 /sbin/request-key will be invoked in an attempt to obtain a key. The 361 /sbin/request-key will be invoked in an attempt to obtain a key. The
362 callout_info string will be passed as an argument to the program. 362 callout_info string will be passed as an argument to the program.
363 363
364 See also Documentation/keys-request-key.txt.
365
364 366
365The keyctl syscall functions are: 367The keyctl syscall functions are:
366 368
@@ -533,8 +535,8 @@ The keyctl syscall functions are:
533 535
534 (*) Read the payload data from a key: 536 (*) Read the payload data from a key:
535 537
536 key_serial_t keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer, 538 long keyctl(KEYCTL_READ, key_serial_t keyring, char *buffer,
537 size_t buflen); 539 size_t buflen);
538 540
539 This function attempts to read the payload data from the specified key 541 This function attempts to read the payload data from the specified key
540 into the buffer. The process must have read permission on the key to 542 into the buffer. The process must have read permission on the key to
@@ -555,9 +557,9 @@ The keyctl syscall functions are:
555 557
556 (*) Instantiate a partially constructed key. 558 (*) Instantiate a partially constructed key.
557 559
558 key_serial_t keyctl(KEYCTL_INSTANTIATE, key_serial_t key, 560 long keyctl(KEYCTL_INSTANTIATE, key_serial_t key,
559 const void *payload, size_t plen, 561 const void *payload, size_t plen,
560 key_serial_t keyring); 562 key_serial_t keyring);
561 563
562 If the kernel calls back to userspace to complete the instantiation of a 564 If the kernel calls back to userspace to complete the instantiation of a
563 key, userspace should use this call to supply data for the key before the 565 key, userspace should use this call to supply data for the key before the
@@ -576,8 +578,8 @@ The keyctl syscall functions are:
576 578
577 (*) Negatively instantiate a partially constructed key. 579 (*) Negatively instantiate a partially constructed key.
578 580
579 key_serial_t keyctl(KEYCTL_NEGATE, key_serial_t key, 581 long keyctl(KEYCTL_NEGATE, key_serial_t key,
580 unsigned timeout, key_serial_t keyring); 582 unsigned timeout, key_serial_t keyring);
581 583
582 If the kernel calls back to userspace to complete the instantiation of a 584 If the kernel calls back to userspace to complete the instantiation of a
583 key, userspace should use this call mark the key as negative before the 585 key, userspace should use this call mark the key as negative before the
@@ -637,6 +639,34 @@ call, and the key released upon close. How to deal with conflicting keys due to
637two different users opening the same file is left to the filesystem author to 639two different users opening the same file is left to the filesystem author to
638solve. 640solve.
639 641
642Note that there are two different types of pointers to keys that may be
643encountered:
644
645 (*) struct key *
646
647 This simply points to the key structure itself. Key structures will be at
648 least four-byte aligned.
649
650 (*) key_ref_t
651
652 This is equivalent to a struct key *, but the least significant bit is set
653 if the caller "possesses" the key. By "possession" it is meant that the
654 calling processes has a searchable link to the key from one of its
655 keyrings. There are three functions for dealing with these:
656
657 key_ref_t make_key_ref(const struct key *key,
658 unsigned long possession);
659
660 struct key *key_ref_to_ptr(const key_ref_t key_ref);
661
662 unsigned long is_key_possessed(const key_ref_t key_ref);
663
664 The first function constructs a key reference from a key pointer and
665 possession information (which must be 0 or 1 and not any other value).
666
667 The second function retrieves the key pointer from a reference and the
668 third retrieves the possession flag.
669
640When accessing a key's payload contents, certain precautions must be taken to 670When accessing a key's payload contents, certain precautions must be taken to
641prevent access vs modification races. See the section "Notes on accessing 671prevent access vs modification races. See the section "Notes on accessing
642payload contents" for more information. 672payload contents" for more information.
@@ -660,12 +690,18 @@ payload contents" for more information.
660 If successful, the key will have been attached to the default keyring for 690 If successful, the key will have been attached to the default keyring for
661 implicitly obtained request-key keys, as set by KEYCTL_SET_REQKEY_KEYRING. 691 implicitly obtained request-key keys, as set by KEYCTL_SET_REQKEY_KEYRING.
662 692
693 See also Documentation/keys-request-key.txt.
694
663 695
664(*) When it is no longer required, the key should be released using: 696(*) When it is no longer required, the key should be released using:
665 697
666 void key_put(struct key *key); 698 void key_put(struct key *key);
667 699
668 This can be called from interrupt context. If CONFIG_KEYS is not set then 700 Or:
701
702 void key_ref_put(key_ref_t key_ref);
703
704 These can be called from interrupt context. If CONFIG_KEYS is not set then
669 the argument will not be parsed. 705 the argument will not be parsed.
670 706
671 707
@@ -689,13 +725,17 @@ payload contents" for more information.
689 725
690(*) If a keyring was found in the search, this can be further searched by: 726(*) If a keyring was found in the search, this can be further searched by:
691 727
692 struct key *keyring_search(struct key *keyring, 728 key_ref_t keyring_search(key_ref_t keyring_ref,
693 const struct key_type *type, 729 const struct key_type *type,
694 const char *description) 730 const char *description)
695 731
696 This searches the keyring tree specified for a matching key. Error ENOKEY 732 This searches the keyring tree specified for a matching key. Error ENOKEY
697 is returned upon failure. If successful, the returned key will need to be 733 is returned upon failure (use IS_ERR/PTR_ERR to determine). If successful,
698 released. 734 the returned key will need to be released.
735
736 The possession attribute from the keyring reference is used to control
737 access through the permissions mask and is propagated to the returned key
738 reference pointer if successful.
699 739
700 740
701(*) To check the validity of a key, this function can be called: 741(*) To check the validity of a key, this function can be called:
@@ -732,7 +772,7 @@ More complex payload contents must be allocated and a pointer to them set in
732key->payload.data. One of the following ways must be selected to access the 772key->payload.data. One of the following ways must be selected to access the
733data: 773data:
734 774
735 (1) Unmodifyable key type. 775 (1) Unmodifiable key type.
736 776
737 If the key type does not have a modify method, then the key's payload can 777 If the key type does not have a modify method, then the key's payload can
738 be accessed without any form of locking, provided that it's known to be 778 be accessed without any form of locking, provided that it's known to be
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index ab65714d95fc..b433c8a27e2d 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -355,10 +355,14 @@ ip_dynaddr - BOOLEAN
355 Default: 0 355 Default: 0
356 356
357icmp_echo_ignore_all - BOOLEAN 357icmp_echo_ignore_all - BOOLEAN
358 If set non-zero, then the kernel will ignore all ICMP ECHO
359 requests sent to it.
360 Default: 0
361
358icmp_echo_ignore_broadcasts - BOOLEAN 362icmp_echo_ignore_broadcasts - BOOLEAN
359 If either is set to true, then the kernel will ignore either all 363 If set non-zero, then the kernel will ignore all ICMP ECHO and
360 ICMP ECHO requests sent to it or just those to broadcast/multicast 364 TIMESTAMP requests sent to it via broadcast/multicast.
361 addresses, respectively. 365 Default: 1
362 366
363icmp_ratelimit - INTEGER 367icmp_ratelimit - INTEGER
364 Limit the maximal rates for sending ICMP packets whose type matches 368 Limit the maximal rates for sending ICMP packets whose type matches
diff --git a/Documentation/sparse.txt b/Documentation/sparse.txt
index 5df44dc894e5..1829009db771 100644
--- a/Documentation/sparse.txt
+++ b/Documentation/sparse.txt
@@ -51,9 +51,9 @@ or you don't get any checking at all.
51Where to get sparse 51Where to get sparse
52~~~~~~~~~~~~~~~~~~~ 52~~~~~~~~~~~~~~~~~~~
53 53
54With BK, you can just get it from 54With git, you can just get it from
55 55
56 bk://sparse.bkbits.net/sparse 56 rsync://rsync.kernel.org/pub/scm/devel/sparse/sparse.git
57 57
58and DaveJ has tar-balls at 58and DaveJ has tar-balls at
59 59
diff --git a/Documentation/usb/URB.txt b/Documentation/usb/URB.txt
index d59b95cc6f1b..a49e5f2c2b46 100644
--- a/Documentation/usb/URB.txt
+++ b/Documentation/usb/URB.txt
@@ -1,5 +1,6 @@
1Revised: 2000-Dec-05. 1Revised: 2000-Dec-05.
2Again: 2002-Jul-06 2Again: 2002-Jul-06
3Again: 2005-Sep-19
3 4
4 NOTE: 5 NOTE:
5 6
@@ -18,8 +19,8 @@ called USB Request Block, or URB for short.
18 and deliver the data and status back. 19 and deliver the data and status back.
19 20
20- Execution of an URB is inherently an asynchronous operation, i.e. the 21- Execution of an URB is inherently an asynchronous operation, i.e. the
21 usb_submit_urb(urb) call returns immediately after it has successfully queued 22 usb_submit_urb(urb) call returns immediately after it has successfully
22 the requested action. 23 queued the requested action.
23 24
24- Transfers for one URB can be canceled with usb_unlink_urb(urb) at any time. 25- Transfers for one URB can be canceled with usb_unlink_urb(urb) at any time.
25 26
@@ -94,8 +95,9 @@ To free an URB, use
94 95
95 void usb_free_urb(struct urb *urb) 96 void usb_free_urb(struct urb *urb)
96 97
97You may not free an urb that you've submitted, but which hasn't yet been 98You may free an urb that you've submitted, but which hasn't yet been
98returned to you in a completion callback. 99returned to you in a completion callback. It will automatically be
100deallocated when it is no longer in use.
99 101
100 102
1011.4. What has to be filled in? 1031.4. What has to be filled in?
@@ -145,30 +147,36 @@ to get seamless ISO streaming.
145 147
1461.6. How to cancel an already running URB? 1481.6. How to cancel an already running URB?
147 149
148For an URB which you've submitted, but which hasn't been returned to 150There are two ways to cancel an URB you've submitted but which hasn't
149your driver by the host controller, call 151been returned to your driver yet. For an asynchronous cancel, call
150 152
151 int usb_unlink_urb(struct urb *urb) 153 int usb_unlink_urb(struct urb *urb)
152 154
153It removes the urb from the internal list and frees all allocated 155It removes the urb from the internal list and frees all allocated
154HW descriptors. The status is changed to reflect unlinking. After 156HW descriptors. The status is changed to reflect unlinking. Note
155usb_unlink_urb() returns with that status code, you can free the URB 157that the URB will not normally have finished when usb_unlink_urb()
156with usb_free_urb(). 158returns; you must still wait for the completion handler to be called.
157 159
158There is also an asynchronous unlink mode. To use this, set the 160To cancel an URB synchronously, call
159the URB_ASYNC_UNLINK flag in urb->transfer flags before calling 161
160usb_unlink_urb(). When using async unlinking, the URB will not 162 void usb_kill_urb(struct urb *urb)
161normally be unlinked when usb_unlink_urb() returns. Instead, wait 163
162for the completion handler to be called. 164It does everything usb_unlink_urb does, and in addition it waits
165until after the URB has been returned and the completion handler
166has finished. It also marks the URB as temporarily unusable, so
167that if the completion handler or anyone else tries to resubmit it
168they will get a -EPERM error. Thus you can be sure that when
169usb_kill_urb() returns, the URB is totally idle.
163 170
164 171
1651.7. What about the completion handler? 1721.7. What about the completion handler?
166 173
167The handler is of the following type: 174The handler is of the following type:
168 175
169 typedef void (*usb_complete_t)(struct urb *); 176 typedef void (*usb_complete_t)(struct urb *, struct pt_regs *)
170 177
171i.e. it gets just the URB that caused the completion call. 178I.e., it gets the URB that caused the completion call, plus the
179register values at the time of the corresponding interrupt (if any).
172In the completion handler, you should have a look at urb->status to 180In the completion handler, you should have a look at urb->status to
173detect any USB errors. Since the context parameter is included in the URB, 181detect any USB errors. Since the context parameter is included in the URB,
174you can pass information to the completion handler. 182you can pass information to the completion handler.
@@ -176,17 +184,11 @@ you can pass information to the completion handler.
176Note that even when an error (or unlink) is reported, data may have been 184Note that even when an error (or unlink) is reported, data may have been
177transferred. That's because USB transfers are packetized; it might take 185transferred. That's because USB transfers are packetized; it might take
178sixteen packets to transfer your 1KByte buffer, and ten of them might 186sixteen packets to transfer your 1KByte buffer, and ten of them might
179have transferred succesfully before the completion is called. 187have transferred succesfully before the completion was called.
180 188
181 189
182NOTE: ***** WARNING ***** 190NOTE: ***** WARNING *****
183Don't use urb->dev field in your completion handler; it's cleared 191NEVER SLEEP IN A COMPLETION HANDLER. These are normally called
184as part of giving urbs back to drivers. (Addressing an issue with
185ownership of periodic URBs, which was otherwise ambiguous.) Instead,
186use urb->context to hold all the data your driver needs.
187
188NOTE: ***** WARNING *****
189Also, NEVER SLEEP IN A COMPLETION HANDLER. These are normally called
190during hardware interrupt processing. If you can, defer substantial 192during hardware interrupt processing. If you can, defer substantial
191work to a tasklet (bottom half) to keep system latencies low. You'll 193work to a tasklet (bottom half) to keep system latencies low. You'll
192probably need to use spinlocks to protect data structures you manipulate 194probably need to use spinlocks to protect data structures you manipulate
@@ -229,24 +231,10 @@ ISO data with some other event stream.
229Interrupt transfers, like isochronous transfers, are periodic, and happen 231Interrupt transfers, like isochronous transfers, are periodic, and happen
230in intervals that are powers of two (1, 2, 4 etc) units. Units are frames 232in intervals that are powers of two (1, 2, 4 etc) units. Units are frames
231for full and low speed devices, and microframes for high speed ones. 233for full and low speed devices, and microframes for high speed ones.
232
233Currently, after you submit one interrupt URB, that urb is owned by the
234host controller driver until you cancel it with usb_unlink_urb(). You
235may unlink interrupt urbs in their completion handlers, if you need to.
236
237After a transfer completion is called, the URB is automagically resubmitted.
238THIS BEHAVIOR IS EXPECTED TO BE REMOVED!!
239
240Interrupt transfers may only send (or receive) the "maxpacket" value for
241the given interrupt endpoint; if you need more data, you will need to
242copy that data out of (or into) another buffer. Similarly, you can't
243queue interrupt transfers.
244THESE RESTRICTIONS ARE EXPECTED TO BE REMOVED!!
245
246Note that this automagic resubmission model does make it awkward to use
247interrupt OUT transfers. The portable solution involves unlinking those
248OUT urbs after the data is transferred, and perhaps submitting a final
249URB for a short packet.
250
251The usb_submit_urb() call modifies urb->interval to the implemented interval 234The usb_submit_urb() call modifies urb->interval to the implemented interval
252value that is less than or equal to the requested interval value. 235value that is less than or equal to the requested interval value.
236
237In Linux 2.6, unlike earlier versions, interrupt URBs are not automagically
238restarted when they complete. They end when the completion handler is
239called, just like other URBs. If you want an interrupt URB to be restarted,
240your completion handler must resubmit it.
diff --git a/MAINTAINERS b/MAINTAINERS
index d1e0eb46d201..767fb610963e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -604,6 +604,15 @@ P: H. Peter Anvin
604M: hpa@zytor.com 604M: hpa@zytor.com
605S: Maintained 605S: Maintained
606 606
607CPUSETS
608P: Paul Jackson
609P: Simon Derr
610M: pj@sgi.com
611M: simon.derr@bull.net
612L: linux-kernel@vger.kernel.org
613W: http://www.bullopensource.org/cpuset/
614S: Supported
615
607CRAMFS FILESYSTEM 616CRAMFS FILESYSTEM
608W: http://sourceforge.net/projects/cramfs/ 617W: http://sourceforge.net/projects/cramfs/
609S: Orphan 618S: Orphan
@@ -686,6 +695,13 @@ P: Guennadi Liakhovetski
686M: g.liakhovetski@gmx.de 695M: g.liakhovetski@gmx.de
687S: Maintained 696S: Maintained
688 697
698DCCP PROTOCOL
699P: Arnaldo Carvalho de Melo
700M: acme@mandriva.com
701L: dccp@vger.kernel.org
702W: http://www.wlug.org.nz/DCCP
703S: Maintained
704
689DECnet NETWORK LAYER 705DECnet NETWORK LAYER
690P: Patrick Caulfield 706P: Patrick Caulfield
691M: patrick@tykepenguin.com 707M: patrick@tykepenguin.com
@@ -1056,8 +1072,6 @@ M: wli@holomorphy.com
1056S: Maintained 1072S: Maintained
1057 1073
1058I2C SUBSYSTEM 1074I2C SUBSYSTEM
1059P: Greg Kroah-Hartman
1060M: greg@kroah.com
1061P: Jean Delvare 1075P: Jean Delvare
1062M: khali@linux-fr.org 1076M: khali@linux-fr.org
1063L: lm-sensors@lm-sensors.org 1077L: lm-sensors@lm-sensors.org
@@ -1154,11 +1168,6 @@ L: linux1394-devel@lists.sourceforge.net
1154W: http://www.linux1394.org/ 1168W: http://www.linux1394.org/
1155S: Orphan 1169S: Orphan
1156 1170
1157IEEE 1394 SBP2
1158L: linux1394-devel@lists.sourceforge.net
1159W: http://www.linux1394.org/
1160S: Orphan
1161
1162IEEE 1394 SUBSYSTEM 1171IEEE 1394 SUBSYSTEM
1163P: Ben Collins 1172P: Ben Collins
1164M: bcollins@debian.org 1173M: bcollins@debian.org
@@ -1193,6 +1202,15 @@ L: linux1394-devel@lists.sourceforge.net
1193W: http://www.linux1394.org/ 1202W: http://www.linux1394.org/
1194S: Maintained 1203S: Maintained
1195 1204
1205IEEE 1394 SBP2
1206P: Ben Collins
1207M: bcollins@debian.org
1208P: Stefan Richter
1209M: stefanr@s5r6.in-berlin.de
1210L: linux1394-devel@lists.sourceforge.net
1211W: http://www.linux1394.org/
1212S: Maintained
1213
1196IMS TWINTURBO FRAMEBUFFER DRIVER 1214IMS TWINTURBO FRAMEBUFFER DRIVER
1197P: Paul Mundt 1215P: Paul Mundt
1198M: lethal@chaoticdreams.org 1216M: lethal@chaoticdreams.org
@@ -1397,6 +1415,18 @@ L: linux-kernel@vger.kernel.org
1397L: fastboot@osdl.org 1415L: fastboot@osdl.org
1398S: Maintained 1416S: Maintained
1399 1417
1418KPROBES
1419P: Prasanna S Panchamukhi
1420M: prasanna@in.ibm.com
1421P: Ananth N Mavinakayanahalli
1422M: ananth@in.ibm.com
1423P: Anil S Keshavamurthy
1424M: anil.s.keshavamurthy@intel.com
1425P: David S. Miller
1426M: davem@davemloft.net
1427L: linux-kernel@vger.kernel.org
1428S: Maintained
1429
1400LANMEDIA WAN CARD DRIVER 1430LANMEDIA WAN CARD DRIVER
1401P: Andrew Stanley-Jones 1431P: Andrew Stanley-Jones
1402M: asj@lanmedia.com 1432M: asj@lanmedia.com
@@ -1588,6 +1618,13 @@ M: vandrove@vc.cvut.cz
1588L: linux-fbdev-devel@lists.sourceforge.net 1618L: linux-fbdev-devel@lists.sourceforge.net
1589S: Maintained 1619S: Maintained
1590 1620
1621MEGARAID SCSI DRIVERS
1622P: Neela Syam Kolli
1623M: Neela.Kolli@engenio.com
1624S: linux-scsi@vger.kernel.org
1625W: http://megaraid.lsilogic.com
1626S: Maintained
1627
1591MEMORY TECHNOLOGY DEVICES 1628MEMORY TECHNOLOGY DEVICES
1592P: David Woodhouse 1629P: David Woodhouse
1593M: dwmw2@infradead.org 1630M: dwmw2@infradead.org
@@ -1717,8 +1754,11 @@ S: Maintained
1717IPVS 1754IPVS
1718P: Wensong Zhang 1755P: Wensong Zhang
1719M: wensong@linux-vs.org 1756M: wensong@linux-vs.org
1757P: Simon Horman
1758M: horms@verge.net.au
1720P: Julian Anastasov 1759P: Julian Anastasov
1721M: ja@ssi.bg 1760M: ja@ssi.bg
1761L: netdev@vger.kernel.org
1722S: Maintained 1762S: Maintained
1723 1763
1724NFS CLIENT 1764NFS CLIENT
@@ -1889,6 +1929,13 @@ M: joern@wh.fh-wedel.de
1889L: linux-mtd@lists.infradead.org 1929L: linux-mtd@lists.infradead.org
1890S: Maintained 1930S: Maintained
1891 1931
1932PKTCDVD DRIVER
1933P: Peter Osterlund
1934M: petero2@telia.com
1935L: linux-kernel@vger.kernel.org
1936L: packet-writing@suse.com
1937S: Maintained
1938
1892POSIX CLOCKS and TIMERS 1939POSIX CLOCKS and TIMERS
1893P: George Anzinger 1940P: George Anzinger
1894M: george@mvista.com 1941M: george@mvista.com
@@ -2259,6 +2306,12 @@ M: kristen.c.accardi@intel.com
2259L: pcihpd-discuss@lists.sourceforge.net 2306L: pcihpd-discuss@lists.sourceforge.net
2260S: Maintained 2307S: Maintained
2261 2308
2309SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS
2310P: Stephen Hemminger
2311M: shemminger@osdl.org
2312L: netdev@vger.kernel.org
2313S: Maintained
2314
2262SPARC (sparc32): 2315SPARC (sparc32):
2263P: William L. Irwin 2316P: William L. Irwin
2264M: wli@holomorphy.com 2317M: wli@holomorphy.com
@@ -2271,12 +2324,6 @@ M: R.E.Wolff@BitWizard.nl
2271L: linux-kernel@vger.kernel.org ? 2324L: linux-kernel@vger.kernel.org ?
2272S: Supported 2325S: Supported
2273 2326
2274SPX NETWORK LAYER
2275P: Jay Schulist
2276M: jschlst@samba.org
2277L: netdev@vger.kernel.org
2278S: Supported
2279
2280SRM (Alpha) environment access 2327SRM (Alpha) environment access
2281P: Jan-Benedict Glaw 2328P: Jan-Benedict Glaw
2282M: jbglaw@lug-owl.de 2329M: jbglaw@lug-owl.de
diff --git a/Makefile b/Makefile
index 4e0d7c68d223..4a7000e353b5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 14 3SUBLEVEL = 14
4EXTRAVERSION =-rc1 4EXTRAVERSION =-rc5
5NAME=Affluent Albatross 5NAME=Affluent Albatross
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -372,7 +372,7 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
372# Files to ignore in find ... statements 372# Files to ignore in find ... statements
373 373
374RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg \) -prune -o 374RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg \) -prune -o
375RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg 375export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg
376 376
377# =========================================================================== 377# ===========================================================================
378# Rules shared between *config targets and build targets 378# Rules shared between *config targets and build targets
@@ -660,8 +660,10 @@ quiet_cmd_sysmap = SYSMAP
660# Link of vmlinux 660# Link of vmlinux
661# If CONFIG_KALLSYMS is set .version is already updated 661# If CONFIG_KALLSYMS is set .version is already updated
662# Generate System.map and verify that the content is consistent 662# Generate System.map and verify that the content is consistent
663 663# Use + in front of the vmlinux_version rule to silent warning with make -j2
664# First command is ':' to allow us to use + in front of the rule
664define rule_vmlinux__ 665define rule_vmlinux__
666 :
665 $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version)) 667 $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version))
666 668
667 $(call cmd,vmlinux__) 669 $(call cmd,vmlinux__)
diff --git a/README b/README
index 76dd780d88ed..d1edcc7adabe 100644
--- a/README
+++ b/README
@@ -149,6 +149,9 @@ CONFIGURING the kernel:
149 "make gconfig" X windows (Gtk) based configuration tool. 149 "make gconfig" X windows (Gtk) based configuration tool.
150 "make oldconfig" Default all questions based on the contents of 150 "make oldconfig" Default all questions based on the contents of
151 your existing ./.config file. 151 your existing ./.config file.
152 "make silentoldconfig"
153 Like above, but avoids cluttering the screen
154 with questions already answered.
152 155
153 NOTES on "make config": 156 NOTES on "make config":
154 - having unnecessary drivers will make the kernel bigger, and can 157 - having unnecessary drivers will make the kernel bigger, and can
@@ -169,9 +172,6 @@ CONFIGURING the kernel:
169 should probably answer 'n' to the questions for 172 should probably answer 'n' to the questions for
170 "development", "experimental", or "debugging" features. 173 "development", "experimental", or "debugging" features.
171 174
172 - Check the top Makefile for further site-dependent configuration
173 (default SVGA mode etc).
174
175COMPILING the kernel: 175COMPILING the kernel:
176 176
177 - Make sure you have gcc 2.95.3 available. 177 - Make sure you have gcc 2.95.3 available.
@@ -199,6 +199,9 @@ COMPILING the kernel:
199 are installing a new kernel with the same version number as your 199 are installing a new kernel with the same version number as your
200 working kernel, make a backup of your modules directory before you 200 working kernel, make a backup of your modules directory before you
201 do a "make modules_install". 201 do a "make modules_install".
202 Alternatively, before compiling, use the kernel config option
203 "LOCALVERSION" to append a unique suffix to the regular kernel version.
204 LOCALVERSION can be set in the "General Setup" menu.
202 205
203 - In order to boot your new kernel, you'll need to copy the kernel 206 - In order to boot your new kernel, you'll need to copy the kernel
204 image (e.g. .../linux/arch/i386/boot/bzImage after compilation) 207 image (e.g. .../linux/arch/i386/boot/bzImage after compilation)
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index 76cc0cb5fc2e..e38671c922bc 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -196,6 +196,7 @@ entUna:
196 stq $26, 208($sp) 196 stq $26, 208($sp)
197 stq $27, 216($sp) 197 stq $27, 216($sp)
198 stq $28, 224($sp) 198 stq $28, 224($sp)
199 mov $sp, $19
199 stq $gp, 232($sp) 200 stq $gp, 232($sp)
200 lda $8, 0x3fff 201 lda $8, 0x3fff
201 stq $31, 248($sp) 202 stq $31, 248($sp)
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 0636116210d2..01fe990d3e54 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -37,6 +37,7 @@
37#include <linux/namei.h> 37#include <linux/namei.h>
38#include <linux/uio.h> 38#include <linux/uio.h>
39#include <linux/vfs.h> 39#include <linux/vfs.h>
40#include <linux/rcupdate.h>
40 41
41#include <asm/fpu.h> 42#include <asm/fpu.h>
42#include <asm/io.h> 43#include <asm/io.h>
@@ -975,6 +976,7 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp,
975 long timeout; 976 long timeout;
976 int ret = -EINVAL; 977 int ret = -EINVAL;
977 struct fdtable *fdt; 978 struct fdtable *fdt;
979 int max_fdset;
978 980
979 timeout = MAX_SCHEDULE_TIMEOUT; 981 timeout = MAX_SCHEDULE_TIMEOUT;
980 if (tvp) { 982 if (tvp) {
@@ -996,8 +998,11 @@ osf_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp,
996 } 998 }
997 } 999 }
998 1000
1001 rcu_read_lock();
999 fdt = files_fdtable(current->files); 1002 fdt = files_fdtable(current->files);
1000 if (n < 0 || n > fdt->max_fdset) 1003 max_fdset = fdt->max_fdset;
1004 rcu_read_unlock();
1005 if (n < 0 || n > max_fdset)
1001 goto out_nofds; 1006 goto out_nofds;
1002 1007
1003 /* 1008 /*
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index fa98dae3cd98..eb20c3afff58 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -127,6 +127,10 @@ common_shutdown_1(void *generic_ptr)
127 /* If booted from SRM, reset some of the original environment. */ 127 /* If booted from SRM, reset some of the original environment. */
128 if (alpha_using_srm) { 128 if (alpha_using_srm) {
129#ifdef CONFIG_DUMMY_CONSOLE 129#ifdef CONFIG_DUMMY_CONSOLE
130 /* If we've gotten here after SysRq-b, leave interrupt
131 context before taking over the console. */
132 if (in_interrupt())
133 irq_exit();
130 /* This has the effect of resetting the VGA video origin. */ 134 /* This has the effect of resetting the VGA video origin. */
131 take_over_console(&dummy_con, 0, MAX_NR_CONSOLES-1, 1); 135 take_over_console(&dummy_con, 0, MAX_NR_CONSOLES-1, 1);
132#endif 136#endif
diff --git a/arch/alpha/kernel/sys_dp264.c b/arch/alpha/kernel/sys_dp264.c
index 9e36b07fa940..d5da6b1b28ee 100644
--- a/arch/alpha/kernel/sys_dp264.c
+++ b/arch/alpha/kernel/sys_dp264.c
@@ -395,6 +395,22 @@ clipper_init_irq(void)
395 */ 395 */
396 396
397static int __init 397static int __init
398isa_irq_fixup(struct pci_dev *dev, int irq)
399{
400 u8 irq8;
401
402 if (irq > 0)
403 return irq;
404
405 /* This interrupt is routed via ISA bridge, so we'll
406 just have to trust whatever value the console might
407 have assigned. */
408 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq8);
409
410 return irq8 & 0xf;
411}
412
413static int __init
398dp264_map_irq(struct pci_dev *dev, u8 slot, u8 pin) 414dp264_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
399{ 415{
400 static char irq_tab[6][5] __initdata = { 416 static char irq_tab[6][5] __initdata = {
@@ -407,25 +423,13 @@ dp264_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
407 { 16+ 3, 16+ 3, 16+ 2, 16+ 1, 16+ 0} /* IdSel 10 slot 3 */ 423 { 16+ 3, 16+ 3, 16+ 2, 16+ 1, 16+ 0} /* IdSel 10 slot 3 */
408 }; 424 };
409 const long min_idsel = 5, max_idsel = 10, irqs_per_slot = 5; 425 const long min_idsel = 5, max_idsel = 10, irqs_per_slot = 5;
410
411 struct pci_controller *hose = dev->sysdata; 426 struct pci_controller *hose = dev->sysdata;
412 int irq = COMMON_TABLE_LOOKUP; 427 int irq = COMMON_TABLE_LOOKUP;
413 428
414 if (irq > 0) { 429 if (irq > 0)
415 irq += 16 * hose->index; 430 irq += 16 * hose->index;
416 } else {
417 /* ??? The Contaq IDE controller on the ISA bridge uses
418 "legacy" interrupts 14 and 15. I don't know if anything
419 can wind up at the same slot+pin on hose1, so we'll
420 just have to trust whatever value the console might
421 have assigned. */
422
423 u8 irq8;
424 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq8);
425 irq = irq8;
426 }
427 431
428 return irq; 432 return isa_irq_fixup(dev, irq);
429} 433}
430 434
431static int __init 435static int __init
@@ -453,7 +457,8 @@ monet_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
453 { 24, 24, 25, 26, 27} /* IdSel 15 slot 5 PCI2*/ 457 { 24, 24, 25, 26, 27} /* IdSel 15 slot 5 PCI2*/
454 }; 458 };
455 const long min_idsel = 3, max_idsel = 15, irqs_per_slot = 5; 459 const long min_idsel = 3, max_idsel = 15, irqs_per_slot = 5;
456 return COMMON_TABLE_LOOKUP; 460
461 return isa_irq_fixup(dev, COMMON_TABLE_LOOKUP);
457} 462}
458 463
459static u8 __init 464static u8 __init
@@ -507,7 +512,8 @@ webbrick_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
507 { 47, 47, 46, 45, 44}, /* IdSel 17 slot 3 */ 512 { 47, 47, 46, 45, 44}, /* IdSel 17 slot 3 */
508 }; 513 };
509 const long min_idsel = 7, max_idsel = 17, irqs_per_slot = 5; 514 const long min_idsel = 7, max_idsel = 17, irqs_per_slot = 5;
510 return COMMON_TABLE_LOOKUP; 515
516 return isa_irq_fixup(dev, COMMON_TABLE_LOOKUP);
511} 517}
512 518
513static int __init 519static int __init
@@ -524,14 +530,13 @@ clipper_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
524 { -1, -1, -1, -1, -1} /* IdSel 7 ISA Bridge */ 530 { -1, -1, -1, -1, -1} /* IdSel 7 ISA Bridge */
525 }; 531 };
526 const long min_idsel = 1, max_idsel = 7, irqs_per_slot = 5; 532 const long min_idsel = 1, max_idsel = 7, irqs_per_slot = 5;
527
528 struct pci_controller *hose = dev->sysdata; 533 struct pci_controller *hose = dev->sysdata;
529 int irq = COMMON_TABLE_LOOKUP; 534 int irq = COMMON_TABLE_LOOKUP;
530 535
531 if (irq > 0) 536 if (irq > 0)
532 irq += 16 * hose->index; 537 irq += 16 * hose->index;
533 538
534 return irq; 539 return isa_irq_fixup(dev, irq);
535} 540}
536 541
537static void __init 542static void __init
diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index 6f509a644bdd..f9d12319e0fb 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -446,16 +446,15 @@ struct unaligned_stat {
446 446
447 447
448/* Macro for exception fixup code to access integer registers. */ 448/* Macro for exception fixup code to access integer registers. */
449#define una_reg(r) (regs.regs[(r) >= 16 && (r) <= 18 ? (r)+19 : (r)]) 449#define una_reg(r) (regs->regs[(r) >= 16 && (r) <= 18 ? (r)+19 : (r)])
450 450
451 451
452asmlinkage void 452asmlinkage void
453do_entUna(void * va, unsigned long opcode, unsigned long reg, 453do_entUna(void * va, unsigned long opcode, unsigned long reg,
454 unsigned long a3, unsigned long a4, unsigned long a5, 454 struct allregs *regs)
455 struct allregs regs)
456{ 455{
457 long error, tmp1, tmp2, tmp3, tmp4; 456 long error, tmp1, tmp2, tmp3, tmp4;
458 unsigned long pc = regs.pc - 4; 457 unsigned long pc = regs->pc - 4;
459 const struct exception_table_entry *fixup; 458 const struct exception_table_entry *fixup;
460 459
461 unaligned[0].count++; 460 unaligned[0].count++;
@@ -636,7 +635,7 @@ got_exception:
636 printk("Forwarding unaligned exception at %lx (%lx)\n", 635 printk("Forwarding unaligned exception at %lx (%lx)\n",
637 pc, newpc); 636 pc, newpc);
638 637
639 (&regs)->pc = newpc; 638 regs->pc = newpc;
640 return; 639 return;
641 } 640 }
642 641
@@ -650,7 +649,7 @@ got_exception:
650 current->comm, current->pid); 649 current->comm, current->pid);
651 650
652 printk("pc = [<%016lx>] ra = [<%016lx>] ps = %04lx\n", 651 printk("pc = [<%016lx>] ra = [<%016lx>] ps = %04lx\n",
653 pc, una_reg(26), regs.ps); 652 pc, una_reg(26), regs->ps);
654 printk("r0 = %016lx r1 = %016lx r2 = %016lx\n", 653 printk("r0 = %016lx r1 = %016lx r2 = %016lx\n",
655 una_reg(0), una_reg(1), una_reg(2)); 654 una_reg(0), una_reg(1), una_reg(2));
656 printk("r3 = %016lx r4 = %016lx r5 = %016lx\n", 655 printk("r3 = %016lx r4 = %016lx r5 = %016lx\n",
@@ -670,10 +669,10 @@ got_exception:
670 una_reg(22), una_reg(23), una_reg(24)); 669 una_reg(22), una_reg(23), una_reg(24));
671 printk("r25= %016lx r27= %016lx r28= %016lx\n", 670 printk("r25= %016lx r27= %016lx r28= %016lx\n",
672 una_reg(25), una_reg(27), una_reg(28)); 671 una_reg(25), una_reg(27), una_reg(28));
673 printk("gp = %016lx sp = %p\n", regs.gp, &regs+1); 672 printk("gp = %016lx sp = %p\n", regs->gp, regs+1);
674 673
675 dik_show_code((unsigned int *)pc); 674 dik_show_code((unsigned int *)pc);
676 dik_show_trace((unsigned long *)(&regs+1)); 675 dik_show_trace((unsigned long *)(regs+1));
677 676
678 if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) { 677 if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
679 printk("die_if_kernel recursion detected.\n"); 678 printk("die_if_kernel recursion detected.\n");
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 130e6228b587..299bc0468702 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -53,7 +53,7 @@ tune-$(CONFIG_CPU_ARM926T) :=-mtune=arm9tdmi
53tune-$(CONFIG_CPU_SA110) :=-mtune=strongarm110 53tune-$(CONFIG_CPU_SA110) :=-mtune=strongarm110
54tune-$(CONFIG_CPU_SA1100) :=-mtune=strongarm1100 54tune-$(CONFIG_CPU_SA1100) :=-mtune=strongarm1100
55tune-$(CONFIG_CPU_XSCALE) :=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale 55tune-$(CONFIG_CPU_XSCALE) :=$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
56tune-$(CONFIG_CPU_V6) :=-mtune=strongarm 56tune-$(CONFIG_CPU_V6) :=$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
57 57
58# Need -Uarm for gcc < 3.x 58# Need -Uarm for gcc < 3.x
59CFLAGS_ABI :=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,) 59CFLAGS_ABI :=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
@@ -175,10 +175,10 @@ else
175endif 175endif
176 @touch $@ 176 @touch $@
177 177
178archprepare: maketools include/asm-arm/.arch 178archprepare: maketools
179 179
180.PHONY: maketools FORCE 180.PHONY: maketools FORCE
181maketools: include/linux/version.h FORCE 181maketools: include/linux/version.h include/asm-arm/.arch FORCE
182 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h 182 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
183 183
184# Convert bzImage to zImage 184# Convert bzImage to zImage
diff --git a/arch/arm/boot/compressed/ofw-shark.c b/arch/arm/boot/compressed/ofw-shark.c
index 7f6f5db0d060..465c54b6b128 100644
--- a/arch/arm/boot/compressed/ofw-shark.c
+++ b/arch/arm/boot/compressed/ofw-shark.c
@@ -256,5 +256,5 @@ asmlinkage void ofw_init(ofw_handle_t o, int *nomr, int *pointer)
256 temp[11]='\0'; 256 temp[11]='\0';
257 mem_len = OF_getproplen(o,phandle, temp); 257 mem_len = OF_getproplen(o,phandle, temp);
258 OF_getprop(o,phandle, temp, buffer, mem_len); 258 OF_getprop(o,phandle, temp, buffer, mem_len);
259 (unsigned char) pointer[32] = ((unsigned char *) buffer)[mem_len-2]; 259 * ((unsigned char *) &pointer[32]) = ((unsigned char *) buffer)[mem_len-2];
260} 260}
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index d74990717559..c02dc8116a18 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -68,6 +68,7 @@ static void gic_unmask_irq(unsigned int irq)
68 writel(mask, gic_dist_base + GIC_DIST_ENABLE_SET + (irq / 32) * 4); 68 writel(mask, gic_dist_base + GIC_DIST_ENABLE_SET + (irq / 32) * 4);
69} 69}
70 70
71#ifdef CONFIG_SMP
71static void gic_set_cpu(struct irqdesc *desc, unsigned int irq, unsigned int cpu) 72static void gic_set_cpu(struct irqdesc *desc, unsigned int irq, unsigned int cpu)
72{ 73{
73 void __iomem *reg = gic_dist_base + GIC_DIST_TARGET + (irq & ~3); 74 void __iomem *reg = gic_dist_base + GIC_DIST_TARGET + (irq & ~3);
@@ -78,6 +79,7 @@ static void gic_set_cpu(struct irqdesc *desc, unsigned int irq, unsigned int cpu
78 val |= 1 << (cpu + shift); 79 val |= 1 << (cpu + shift);
79 writel(val, reg); 80 writel(val, reg);
80} 81}
82#endif
81 83
82static struct irqchip gic_chip = { 84static struct irqchip gic_chip = {
83 .ack = gic_ack_irq, 85 .ack = gic_ack_irq,
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index 2786f7c34b3f..e8053d16829b 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -27,7 +27,6 @@
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28 28
29#include <asm/hardware.h> 29#include <asm/hardware.h>
30#include <asm/mach-types.h>
31#include <asm/io.h> 30#include <asm/io.h>
32#include <asm/irq.h> 31#include <asm/irq.h>
33#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
@@ -551,7 +550,7 @@ struct locomo_save_data {
551 u16 LCM_SPIMD; 550 u16 LCM_SPIMD;
552}; 551};
553 552
554static int locomo_suspend(struct device *dev, u32 pm_message_t, u32 level) 553static int locomo_suspend(struct device *dev, pm_message_t state, u32 level)
555{ 554{
556 struct locomo *lchip = dev_get_drvdata(dev); 555 struct locomo *lchip = dev_get_drvdata(dev);
557 struct locomo_save_data *save; 556 struct locomo_save_data *save;
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index d3a04c2a2c85..9e5245c702de 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -26,6 +26,8 @@ struct scoop_pcmcia_dev *scoop_devs;
26struct scoop_dev { 26struct scoop_dev {
27 void *base; 27 void *base;
28 spinlock_t scoop_lock; 28 spinlock_t scoop_lock;
29 unsigned short suspend_clr;
30 unsigned short suspend_set;
29 u32 scoop_gpwr; 31 u32 scoop_gpwr;
30}; 32};
31 33
@@ -90,14 +92,24 @@ EXPORT_SYMBOL(reset_scoop);
90EXPORT_SYMBOL(read_scoop_reg); 92EXPORT_SYMBOL(read_scoop_reg);
91EXPORT_SYMBOL(write_scoop_reg); 93EXPORT_SYMBOL(write_scoop_reg);
92 94
95static void check_scoop_reg(struct scoop_dev *sdev)
96{
97 unsigned short mcr;
98
99 mcr = SCOOP_REG(sdev->base, SCOOP_MCR);
100 if ((mcr & 0x100) == 0)
101 SCOOP_REG(sdev->base, SCOOP_MCR) = 0x0101;
102}
103
93#ifdef CONFIG_PM 104#ifdef CONFIG_PM
94static int scoop_suspend(struct device *dev, pm_message_t state, uint32_t level) 105static int scoop_suspend(struct device *dev, pm_message_t state, uint32_t level)
95{ 106{
96 if (level == SUSPEND_POWER_DOWN) { 107 if (level == SUSPEND_POWER_DOWN) {
97 struct scoop_dev *sdev = dev_get_drvdata(dev); 108 struct scoop_dev *sdev = dev_get_drvdata(dev);
98 109
99 sdev->scoop_gpwr = SCOOP_REG(sdev->base,SCOOP_GPWR); 110 check_scoop_reg(sdev);
100 SCOOP_REG(sdev->base,SCOOP_GPWR) = 0; 111 sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR);
112 SCOOP_REG(sdev->base, SCOOP_GPWR) = (sdev->scoop_gpwr & ~sdev->suspend_clr) | sdev->suspend_set;
101 } 113 }
102 return 0; 114 return 0;
103} 115}
@@ -107,6 +119,7 @@ static int scoop_resume(struct device *dev, uint32_t level)
107 if (level == RESUME_POWER_ON) { 119 if (level == RESUME_POWER_ON) {
108 struct scoop_dev *sdev = dev_get_drvdata(dev); 120 struct scoop_dev *sdev = dev_get_drvdata(dev);
109 121
122 check_scoop_reg(sdev);
110 SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr; 123 SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr;
111 } 124 }
112 return 0; 125 return 0;
@@ -151,6 +164,9 @@ int __init scoop_probe(struct device *dev)
151 SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff; 164 SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff;
152 SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff; 165 SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff;
153 166
167 devptr->suspend_clr = inf->suspend_clr;
168 devptr->suspend_set = inf->suspend_set;
169
154 return 0; 170 return 0;
155} 171}
156 172
diff --git a/arch/arm/configs/collie_defconfig b/arch/arm/configs/collie_defconfig
new file mode 100644
index 000000000000..40dfe07a8bce
--- /dev/null
+++ b/arch/arm/configs/collie_defconfig
@@ -0,0 +1,888 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc3
4# Sun Oct 9 16:55:14 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16# CONFIG_CLEAN_COMPILE is not set
17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27CONFIG_SWAP=y
28CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set
30CONFIG_BSD_PROCESS_ACCT=y
31# CONFIG_BSD_PROCESS_ACCT_V3 is not set
32CONFIG_SYSCTL=y
33# CONFIG_AUDIT is not set
34CONFIG_HOTPLUG=y
35CONFIG_KOBJECT_UEVENT=y
36# CONFIG_IKCONFIG is not set
37CONFIG_INITRAMFS_SOURCE=""
38CONFIG_EMBEDDED=y
39CONFIG_KALLSYMS=y
40# CONFIG_KALLSYMS_ALL is not set
41# CONFIG_KALLSYMS_EXTRA_PASS is not set
42CONFIG_PRINTK=y
43CONFIG_BUG=y
44CONFIG_BASE_FULL=y
45CONFIG_FUTEX=y
46CONFIG_EPOLL=y
47# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
48CONFIG_SHMEM=y
49CONFIG_CC_ALIGN_FUNCTIONS=0
50CONFIG_CC_ALIGN_LABELS=0
51CONFIG_CC_ALIGN_LOOPS=0
52CONFIG_CC_ALIGN_JUMPS=0
53# CONFIG_TINY_SHMEM is not set
54CONFIG_BASE_SMALL=0
55
56#
57# Loadable module support
58#
59CONFIG_MODULES=y
60CONFIG_MODULE_UNLOAD=y
61CONFIG_MODULE_FORCE_UNLOAD=y
62CONFIG_OBSOLETE_MODPARM=y
63CONFIG_MODVERSIONS=y
64# CONFIG_MODULE_SRCVERSION_ALL is not set
65CONFIG_KMOD=y
66
67#
68# System Type
69#
70# CONFIG_ARCH_CLPS7500 is not set
71# CONFIG_ARCH_CLPS711X is not set
72# CONFIG_ARCH_CO285 is not set
73# CONFIG_ARCH_EBSA110 is not set
74# CONFIG_ARCH_CAMELOT is not set
75# CONFIG_ARCH_FOOTBRIDGE is not set
76# CONFIG_ARCH_INTEGRATOR is not set
77# CONFIG_ARCH_IOP3XX is not set
78# CONFIG_ARCH_IXP4XX is not set
79# CONFIG_ARCH_IXP2000 is not set
80# CONFIG_ARCH_L7200 is not set
81# CONFIG_ARCH_PXA is not set
82# CONFIG_ARCH_RPC is not set
83CONFIG_ARCH_SA1100=y
84# CONFIG_ARCH_S3C2410 is not set
85# CONFIG_ARCH_SHARK is not set
86# CONFIG_ARCH_LH7A40X is not set
87# CONFIG_ARCH_OMAP is not set
88# CONFIG_ARCH_VERSATILE is not set
89# CONFIG_ARCH_IMX is not set
90# CONFIG_ARCH_H720X is not set
91# CONFIG_ARCH_AAEC2000 is not set
92
93#
94# SA11x0 Implementations
95#
96# CONFIG_SA1100_ASSABET is not set
97# CONFIG_SA1100_CERF is not set
98CONFIG_SA1100_COLLIE=y
99# CONFIG_SA1100_H3100 is not set
100# CONFIG_SA1100_H3600 is not set
101# CONFIG_SA1100_H3800 is not set
102# CONFIG_SA1100_BADGE4 is not set
103# CONFIG_SA1100_JORNADA720 is not set
104# CONFIG_SA1100_HACKKIT is not set
105# CONFIG_SA1100_LART is not set
106# CONFIG_SA1100_PLEB is not set
107# CONFIG_SA1100_SHANNON is not set
108# CONFIG_SA1100_SIMPAD is not set
109# CONFIG_SA1100_SSP is not set
110
111#
112# Processor Type
113#
114CONFIG_CPU_32=y
115CONFIG_CPU_SA1100=y
116CONFIG_CPU_32v4=y
117CONFIG_CPU_ABRT_EV4=y
118CONFIG_CPU_CACHE_V4WB=y
119CONFIG_CPU_CACHE_VIVT=y
120CONFIG_CPU_TLB_V4WB=y
121
122#
123# Processor Features
124#
125CONFIG_SHARP_LOCOMO=y
126CONFIG_SHARP_PARAM=y
127CONFIG_SHARP_SCOOP=y
128
129#
130# Bus support
131#
132CONFIG_ISA=y
133CONFIG_ISA_DMA_API=y
134
135#
136# PCCARD (PCMCIA/CardBus) support
137#
138# CONFIG_PCCARD is not set
139
140#
141# Kernel Features
142#
143# CONFIG_SMP is not set
144CONFIG_PREEMPT=y
145# CONFIG_NO_IDLE_HZ is not set
146CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
147CONFIG_SELECT_MEMORY_MODEL=y
148# CONFIG_FLATMEM_MANUAL is not set
149CONFIG_DISCONTIGMEM_MANUAL=y
150# CONFIG_SPARSEMEM_MANUAL is not set
151CONFIG_DISCONTIGMEM=y
152CONFIG_FLAT_NODE_MEM_MAP=y
153CONFIG_NEED_MULTIPLE_NODES=y
154# CONFIG_SPARSEMEM_STATIC is not set
155# CONFIG_LEDS is not set
156CONFIG_ALIGNMENT_TRAP=y
157
158#
159# Boot options
160#
161CONFIG_ZBOOT_ROM_TEXT=0x0
162CONFIG_ZBOOT_ROM_BSS=0x0
163CONFIG_CMDLINE="console=ttyS0,115200n8 console=tty1 noinitrd root=/dev/mtdblock2 rootfstype=jffs2 debug"
164# CONFIG_XIP_KERNEL is not set
165
166#
167# CPU Frequency scaling
168#
169# CONFIG_CPU_FREQ is not set
170
171#
172# Floating point emulation
173#
174
175#
176# At least one emulation must be selected
177#
178CONFIG_FPE_NWFPE=y
179# CONFIG_FPE_NWFPE_XP is not set
180# CONFIG_FPE_FASTFPE is not set
181
182#
183# Userspace binary formats
184#
185CONFIG_BINFMT_ELF=y
186CONFIG_BINFMT_AOUT=m
187CONFIG_BINFMT_MISC=m
188# CONFIG_ARTHUR is not set
189
190#
191# Power management options
192#
193CONFIG_PM=y
194CONFIG_APM=y
195
196#
197# Networking
198#
199CONFIG_NET=y
200
201#
202# Networking options
203#
204CONFIG_PACKET=y
205CONFIG_PACKET_MMAP=y
206CONFIG_UNIX=y
207# CONFIG_NET_KEY is not set
208CONFIG_INET=y
209# CONFIG_IP_MULTICAST is not set
210# CONFIG_IP_ADVANCED_ROUTER is not set
211CONFIG_IP_FIB_HASH=y
212# CONFIG_IP_PNP is not set
213# CONFIG_NET_IPIP is not set
214# CONFIG_NET_IPGRE is not set
215# CONFIG_ARPD is not set
216CONFIG_SYN_COOKIES=y
217# CONFIG_INET_AH is not set
218# CONFIG_INET_ESP is not set
219# CONFIG_INET_IPCOMP is not set
220# CONFIG_INET_TUNNEL is not set
221CONFIG_INET_DIAG=y
222CONFIG_INET_TCP_DIAG=y
223# CONFIG_TCP_CONG_ADVANCED is not set
224CONFIG_TCP_CONG_BIC=y
225# CONFIG_IPV6 is not set
226# CONFIG_NETFILTER is not set
227
228#
229# DCCP Configuration (EXPERIMENTAL)
230#
231# CONFIG_IP_DCCP is not set
232
233#
234# SCTP Configuration (EXPERIMENTAL)
235#
236# CONFIG_IP_SCTP is not set
237# CONFIG_ATM is not set
238# CONFIG_BRIDGE is not set
239# CONFIG_VLAN_8021Q is not set
240# CONFIG_DECNET is not set
241# CONFIG_LLC2 is not set
242# CONFIG_IPX is not set
243# CONFIG_ATALK is not set
244# CONFIG_X25 is not set
245# CONFIG_LAPB is not set
246# CONFIG_NET_DIVERT is not set
247# CONFIG_ECONET is not set
248# CONFIG_WAN_ROUTER is not set
249# CONFIG_NET_SCHED is not set
250# CONFIG_NET_CLS_ROUTE is not set
251
252#
253# Network testing
254#
255# CONFIG_NET_PKTGEN is not set
256# CONFIG_HAMRADIO is not set
257# CONFIG_IRDA is not set
258# CONFIG_BT is not set
259# CONFIG_IEEE80211 is not set
260
261#
262# Device Drivers
263#
264
265#
266# Generic Driver Options
267#
268CONFIG_STANDALONE=y
269CONFIG_PREVENT_FIRMWARE_BUILD=y
270CONFIG_FW_LOADER=m
271# CONFIG_DEBUG_DRIVER is not set
272
273#
274# Memory Technology Devices (MTD)
275#
276CONFIG_MTD=y
277# CONFIG_MTD_DEBUG is not set
278# CONFIG_MTD_CONCAT is not set
279CONFIG_MTD_PARTITIONS=y
280# CONFIG_MTD_REDBOOT_PARTS is not set
281# CONFIG_MTD_CMDLINE_PARTS is not set
282# CONFIG_MTD_AFS_PARTS is not set
283
284#
285# User Modules And Translation Layers
286#
287CONFIG_MTD_CHAR=y
288CONFIG_MTD_BLOCK=y
289# CONFIG_FTL is not set
290# CONFIG_NFTL is not set
291# CONFIG_INFTL is not set
292
293#
294# RAM/ROM/Flash chip drivers
295#
296# CONFIG_MTD_CFI is not set
297# CONFIG_MTD_JEDECPROBE is not set
298CONFIG_MTD_MAP_BANK_WIDTH_1=y
299CONFIG_MTD_MAP_BANK_WIDTH_2=y
300CONFIG_MTD_MAP_BANK_WIDTH_4=y
301# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
302# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
303# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
304CONFIG_MTD_CFI_I1=y
305CONFIG_MTD_CFI_I2=y
306# CONFIG_MTD_CFI_I4 is not set
307# CONFIG_MTD_CFI_I8 is not set
308# CONFIG_MTD_RAM is not set
309# CONFIG_MTD_ROM is not set
310# CONFIG_MTD_ABSENT is not set
311CONFIG_MTD_OBSOLETE_CHIPS=y
312# CONFIG_MTD_AMDSTD is not set
313CONFIG_MTD_SHARP=y
314# CONFIG_MTD_JEDEC is not set
315
316#
317# Mapping drivers for chip access
318#
319# CONFIG_MTD_COMPLEX_MAPPINGS is not set
320# CONFIG_MTD_PLATRAM is not set
321
322#
323# Self-contained MTD device drivers
324#
325# CONFIG_MTD_SLRAM is not set
326# CONFIG_MTD_PHRAM is not set
327# CONFIG_MTD_MTDRAM is not set
328# CONFIG_MTD_BLKMTD is not set
329# CONFIG_MTD_BLOCK2MTD is not set
330
331#
332# Disk-On-Chip Device Drivers
333#
334# CONFIG_MTD_DOC2000 is not set
335# CONFIG_MTD_DOC2001 is not set
336# CONFIG_MTD_DOC2001PLUS is not set
337
338#
339# NAND Flash Device Drivers
340#
341# CONFIG_MTD_NAND is not set
342
343#
344# Parallel port support
345#
346# CONFIG_PARPORT is not set
347
348#
349# Plug and Play support
350#
351# CONFIG_PNP is not set
352
353#
354# Block devices
355#
356# CONFIG_BLK_DEV_XD is not set
357# CONFIG_BLK_DEV_COW_COMMON is not set
358CONFIG_BLK_DEV_LOOP=y
359# CONFIG_BLK_DEV_CRYPTOLOOP is not set
360# CONFIG_BLK_DEV_NBD is not set
361CONFIG_BLK_DEV_RAM=y
362CONFIG_BLK_DEV_RAM_COUNT=16
363CONFIG_BLK_DEV_RAM_SIZE=1024
364CONFIG_BLK_DEV_INITRD=y
365# CONFIG_CDROM_PKTCDVD is not set
366
367#
368# IO Schedulers
369#
370CONFIG_IOSCHED_NOOP=y
371CONFIG_IOSCHED_AS=y
372CONFIG_IOSCHED_DEADLINE=y
373CONFIG_IOSCHED_CFQ=y
374CONFIG_ATA_OVER_ETH=m
375
376#
377# ATA/ATAPI/MFM/RLL support
378#
379# CONFIG_IDE is not set
380
381#
382# SCSI device support
383#
384# CONFIG_RAID_ATTRS is not set
385# CONFIG_SCSI is not set
386
387#
388# Multi-device support (RAID and LVM)
389#
390# CONFIG_MD is not set
391
392#
393# Fusion MPT device support
394#
395# CONFIG_FUSION is not set
396
397#
398# IEEE 1394 (FireWire) support
399#
400# CONFIG_IEEE1394 is not set
401
402#
403# I2O device support
404#
405
406#
407# Network device support
408#
409# CONFIG_NETDEVICES is not set
410# CONFIG_NETPOLL is not set
411# CONFIG_NET_POLL_CONTROLLER is not set
412
413#
414# ISDN subsystem
415#
416# CONFIG_ISDN is not set
417
418#
419# Input device support
420#
421CONFIG_INPUT=y
422
423#
424# Userland interfaces
425#
426# CONFIG_INPUT_MOUSEDEV is not set
427# CONFIG_INPUT_JOYDEV is not set
428CONFIG_INPUT_TSDEV=y
429CONFIG_INPUT_TSDEV_SCREEN_X=240
430CONFIG_INPUT_TSDEV_SCREEN_Y=320
431CONFIG_INPUT_EVDEV=y
432CONFIG_INPUT_EVBUG=y
433
434#
435# Input Device Drivers
436#
437CONFIG_INPUT_KEYBOARD=y
438# CONFIG_KEYBOARD_ATKBD is not set
439# CONFIG_KEYBOARD_SUNKBD is not set
440# CONFIG_KEYBOARD_LKKBD is not set
441CONFIG_KEYBOARD_LOCOMO=y
442# CONFIG_KEYBOARD_XTKBD is not set
443# CONFIG_KEYBOARD_NEWTON is not set
444# CONFIG_INPUT_MOUSE is not set
445# CONFIG_INPUT_JOYSTICK is not set
446# CONFIG_INPUT_TOUCHSCREEN is not set
447# CONFIG_INPUT_MISC is not set
448
449#
450# Hardware I/O ports
451#
452CONFIG_SERIO=y
453# CONFIG_SERIO_SERPORT is not set
454# CONFIG_SERIO_LIBPS2 is not set
455# CONFIG_SERIO_RAW is not set
456# CONFIG_GAMEPORT is not set
457
458#
459# Character devices
460#
461CONFIG_VT=y
462CONFIG_VT_CONSOLE=y
463CONFIG_HW_CONSOLE=y
464# CONFIG_SERIAL_NONSTANDARD is not set
465
466#
467# Serial drivers
468#
469# CONFIG_SERIAL_8250 is not set
470
471#
472# Non-8250 serial port support
473#
474CONFIG_SERIAL_SA1100=y
475CONFIG_SERIAL_SA1100_CONSOLE=y
476CONFIG_SERIAL_CORE=y
477CONFIG_SERIAL_CORE_CONSOLE=y
478CONFIG_UNIX98_PTYS=y
479# CONFIG_LEGACY_PTYS is not set
480
481#
482# IPMI
483#
484# CONFIG_IPMI_HANDLER is not set
485
486#
487# Watchdog Cards
488#
489# CONFIG_WATCHDOG is not set
490# CONFIG_NVRAM is not set
491# CONFIG_RTC is not set
492# CONFIG_DTLK is not set
493# CONFIG_R3964 is not set
494
495#
496# Ftape, the floppy tape device driver
497#
498# CONFIG_RAW_DRIVER is not set
499
500#
501# TPM devices
502#
503
504#
505# I2C support
506#
507CONFIG_I2C=m
508# CONFIG_I2C_CHARDEV is not set
509
510#
511# I2C Algorithms
512#
513CONFIG_I2C_ALGOBIT=m
514# CONFIG_I2C_ALGOPCF is not set
515# CONFIG_I2C_ALGOPCA is not set
516
517#
518# I2C Hardware Bus support
519#
520# CONFIG_I2C_ELEKTOR is not set
521# CONFIG_I2C_PARPORT_LIGHT is not set
522# CONFIG_I2C_STUB is not set
523# CONFIG_I2C_PCA_ISA is not set
524
525#
526# Miscellaneous I2C Chip support
527#
528# CONFIG_SENSORS_DS1337 is not set
529# CONFIG_SENSORS_DS1374 is not set
530# CONFIG_SENSORS_EEPROM is not set
531# CONFIG_SENSORS_PCF8574 is not set
532# CONFIG_SENSORS_PCA9539 is not set
533# CONFIG_SENSORS_PCF8591 is not set
534# CONFIG_SENSORS_RTC8564 is not set
535# CONFIG_SENSORS_MAX6875 is not set
536# CONFIG_I2C_DEBUG_CORE is not set
537# CONFIG_I2C_DEBUG_ALGO is not set
538# CONFIG_I2C_DEBUG_BUS is not set
539# CONFIG_I2C_DEBUG_CHIP is not set
540
541#
542# Hardware Monitoring support
543#
544CONFIG_HWMON=y
545# CONFIG_HWMON_VID is not set
546# CONFIG_SENSORS_ADM1021 is not set
547# CONFIG_SENSORS_ADM1025 is not set
548# CONFIG_SENSORS_ADM1026 is not set
549# CONFIG_SENSORS_ADM1031 is not set
550# CONFIG_SENSORS_ADM9240 is not set
551# CONFIG_SENSORS_ASB100 is not set
552# CONFIG_SENSORS_ATXP1 is not set
553# CONFIG_SENSORS_DS1621 is not set
554# CONFIG_SENSORS_FSCHER is not set
555# CONFIG_SENSORS_FSCPOS is not set
556# CONFIG_SENSORS_GL518SM is not set
557# CONFIG_SENSORS_GL520SM is not set
558# CONFIG_SENSORS_IT87 is not set
559# CONFIG_SENSORS_LM63 is not set
560# CONFIG_SENSORS_LM75 is not set
561# CONFIG_SENSORS_LM77 is not set
562# CONFIG_SENSORS_LM78 is not set
563# CONFIG_SENSORS_LM80 is not set
564# CONFIG_SENSORS_LM83 is not set
565# CONFIG_SENSORS_LM85 is not set
566# CONFIG_SENSORS_LM87 is not set
567# CONFIG_SENSORS_LM90 is not set
568# CONFIG_SENSORS_LM92 is not set
569# CONFIG_SENSORS_MAX1619 is not set
570# CONFIG_SENSORS_PC87360 is not set
571# CONFIG_SENSORS_SMSC47M1 is not set
572# CONFIG_SENSORS_SMSC47B397 is not set
573# CONFIG_SENSORS_W83781D is not set
574# CONFIG_SENSORS_W83792D is not set
575# CONFIG_SENSORS_W83L785TS is not set
576# CONFIG_SENSORS_W83627HF is not set
577# CONFIG_SENSORS_W83627EHF is not set
578# CONFIG_HWMON_DEBUG_CHIP is not set
579
580#
581# Misc devices
582#
583
584#
585# Multimedia Capabilities Port drivers
586#
587# CONFIG_MCP_SA11X0 is not set
588
589#
590# Multimedia devices
591#
592CONFIG_VIDEO_DEV=m
593
594#
595# Video For Linux
596#
597
598#
599# Video Adapters
600#
601# CONFIG_VIDEO_PMS is not set
602# CONFIG_VIDEO_CPIA is not set
603# CONFIG_VIDEO_SAA5246A is not set
604# CONFIG_VIDEO_SAA5249 is not set
605# CONFIG_TUNER_3036 is not set
606# CONFIG_VIDEO_OVCAMCHIP is not set
607
608#
609# Radio Adapters
610#
611# CONFIG_RADIO_CADET is not set
612# CONFIG_RADIO_RTRACK is not set
613# CONFIG_RADIO_RTRACK2 is not set
614# CONFIG_RADIO_AZTECH is not set
615# CONFIG_RADIO_GEMTEK is not set
616# CONFIG_RADIO_MAESTRO is not set
617# CONFIG_RADIO_SF16FMI is not set
618# CONFIG_RADIO_SF16FMR2 is not set
619# CONFIG_RADIO_TERRATEC is not set
620# CONFIG_RADIO_TRUST is not set
621# CONFIG_RADIO_TYPHOON is not set
622# CONFIG_RADIO_ZOLTRIX is not set
623
624#
625# Digital Video Broadcasting Devices
626#
627# CONFIG_DVB is not set
628
629#
630# Graphics support
631#
632CONFIG_FB=y
633CONFIG_FB_CFB_FILLRECT=y
634CONFIG_FB_CFB_COPYAREA=y
635CONFIG_FB_CFB_IMAGEBLIT=y
636CONFIG_FB_SOFT_CURSOR=y
637# CONFIG_FB_MACMODES is not set
638CONFIG_FB_MODE_HELPERS=y
639# CONFIG_FB_TILEBLITTING is not set
640CONFIG_FB_SA1100=y
641# CONFIG_FB_S1D13XXX is not set
642# CONFIG_FB_VIRTUAL is not set
643
644#
645# Console display driver support
646#
647# CONFIG_VGA_CONSOLE is not set
648# CONFIG_MDA_CONSOLE is not set
649CONFIG_DUMMY_CONSOLE=y
650CONFIG_FRAMEBUFFER_CONSOLE=y
651CONFIG_FONTS=y
652CONFIG_FONT_8x8=y
653# CONFIG_FONT_8x16 is not set
654# CONFIG_FONT_6x11 is not set
655# CONFIG_FONT_7x14 is not set
656# CONFIG_FONT_PEARL_8x8 is not set
657# CONFIG_FONT_ACORN_8x8 is not set
658# CONFIG_FONT_MINI_4x6 is not set
659# CONFIG_FONT_SUN8x16 is not set
660# CONFIG_FONT_SUN12x22 is not set
661# CONFIG_FONT_10x18 is not set
662
663#
664# Logo configuration
665#
666# CONFIG_LOGO is not set
667# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
668
669#
670# Sound
671#
672# CONFIG_SOUND is not set
673
674#
675# USB support
676#
677CONFIG_USB_ARCH_HAS_HCD=y
678# CONFIG_USB_ARCH_HAS_OHCI is not set
679# CONFIG_USB is not set
680
681#
682# USB Gadget Support
683#
684CONFIG_USB_GADGET=y
685# CONFIG_USB_GADGET_DEBUG_FILES is not set
686# CONFIG_USB_GADGET_NET2280 is not set
687# CONFIG_USB_GADGET_PXA2XX is not set
688# CONFIG_USB_GADGET_GOKU is not set
689# CONFIG_USB_GADGET_LH7A40X is not set
690# CONFIG_USB_GADGET_OMAP is not set
691# CONFIG_USB_GADGET_DUMMY_HCD is not set
692# CONFIG_USB_GADGET_DUALSPEED is not set
693
694#
695# MMC/SD Card support
696#
697# CONFIG_MMC is not set
698
699#
700# File systems
701#
702CONFIG_EXT2_FS=y
703CONFIG_EXT2_FS_XATTR=y
704CONFIG_EXT2_FS_POSIX_ACL=y
705CONFIG_EXT2_FS_SECURITY=y
706# CONFIG_EXT2_FS_XIP is not set
707# CONFIG_EXT3_FS is not set
708# CONFIG_JBD is not set
709CONFIG_FS_MBCACHE=y
710# CONFIG_REISERFS_FS is not set
711# CONFIG_JFS_FS is not set
712CONFIG_FS_POSIX_ACL=y
713# CONFIG_XFS_FS is not set
714# CONFIG_MINIX_FS is not set
715CONFIG_ROMFS_FS=y
716CONFIG_INOTIFY=y
717# CONFIG_QUOTA is not set
718# CONFIG_DNOTIFY is not set
719# CONFIG_AUTOFS_FS is not set
720# CONFIG_AUTOFS4_FS is not set
721# CONFIG_FUSE_FS is not set
722
723#
724# CD-ROM/DVD Filesystems
725#
726# CONFIG_ISO9660_FS is not set
727# CONFIG_UDF_FS is not set
728
729#
730# DOS/FAT/NT Filesystems
731#
732CONFIG_FAT_FS=y
733CONFIG_MSDOS_FS=y
734CONFIG_VFAT_FS=y
735CONFIG_FAT_DEFAULT_CODEPAGE=437
736CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
737# CONFIG_NTFS_FS is not set
738
739#
740# Pseudo filesystems
741#
742CONFIG_PROC_FS=y
743CONFIG_SYSFS=y
744CONFIG_TMPFS=y
745# CONFIG_HUGETLBFS is not set
746# CONFIG_HUGETLB_PAGE is not set
747CONFIG_RAMFS=y
748# CONFIG_RELAYFS_FS is not set
749
750#
751# Miscellaneous filesystems
752#
753# CONFIG_ADFS_FS is not set
754# CONFIG_AFFS_FS is not set
755# CONFIG_HFS_FS is not set
756# CONFIG_HFSPLUS_FS is not set
757# CONFIG_BEFS_FS is not set
758# CONFIG_BFS_FS is not set
759# CONFIG_EFS_FS is not set
760# CONFIG_JFFS_FS is not set
761CONFIG_JFFS2_FS=y
762CONFIG_JFFS2_FS_DEBUG=0
763CONFIG_JFFS2_FS_WRITEBUFFER=y
764# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
765CONFIG_JFFS2_ZLIB=y
766CONFIG_JFFS2_RTIME=y
767# CONFIG_JFFS2_RUBIN is not set
768CONFIG_CRAMFS=y
769# CONFIG_VXFS_FS is not set
770# CONFIG_HPFS_FS is not set
771# CONFIG_QNX4FS_FS is not set
772# CONFIG_SYSV_FS is not set
773# CONFIG_UFS_FS is not set
774
775#
776# Network File Systems
777#
778# CONFIG_NFS_FS is not set
779# CONFIG_NFSD is not set
780# CONFIG_SMB_FS is not set
781# CONFIG_CIFS is not set
782# CONFIG_NCP_FS is not set
783# CONFIG_CODA_FS is not set
784# CONFIG_AFS_FS is not set
785# CONFIG_9P_FS is not set
786
787#
788# Partition Types
789#
790# CONFIG_PARTITION_ADVANCED is not set
791CONFIG_MSDOS_PARTITION=y
792
793#
794# Native Language Support
795#
796CONFIG_NLS=y
797CONFIG_NLS_DEFAULT="cp437"
798CONFIG_NLS_CODEPAGE_437=m
799# CONFIG_NLS_CODEPAGE_737 is not set
800# CONFIG_NLS_CODEPAGE_775 is not set
801# CONFIG_NLS_CODEPAGE_850 is not set
802# CONFIG_NLS_CODEPAGE_852 is not set
803# CONFIG_NLS_CODEPAGE_855 is not set
804# CONFIG_NLS_CODEPAGE_857 is not set
805# CONFIG_NLS_CODEPAGE_860 is not set
806# CONFIG_NLS_CODEPAGE_861 is not set
807# CONFIG_NLS_CODEPAGE_862 is not set
808# CONFIG_NLS_CODEPAGE_863 is not set
809# CONFIG_NLS_CODEPAGE_864 is not set
810# CONFIG_NLS_CODEPAGE_865 is not set
811# CONFIG_NLS_CODEPAGE_866 is not set
812# CONFIG_NLS_CODEPAGE_869 is not set
813# CONFIG_NLS_CODEPAGE_936 is not set
814# CONFIG_NLS_CODEPAGE_950 is not set
815# CONFIG_NLS_CODEPAGE_932 is not set
816# CONFIG_NLS_CODEPAGE_949 is not set
817# CONFIG_NLS_CODEPAGE_874 is not set
818# CONFIG_NLS_ISO8859_8 is not set
819# CONFIG_NLS_CODEPAGE_1250 is not set
820# CONFIG_NLS_CODEPAGE_1251 is not set
821# CONFIG_NLS_ASCII is not set
822CONFIG_NLS_ISO8859_1=m
823# CONFIG_NLS_ISO8859_2 is not set
824# CONFIG_NLS_ISO8859_3 is not set
825# CONFIG_NLS_ISO8859_4 is not set
826# CONFIG_NLS_ISO8859_5 is not set
827# CONFIG_NLS_ISO8859_6 is not set
828# CONFIG_NLS_ISO8859_7 is not set
829# CONFIG_NLS_ISO8859_9 is not set
830# CONFIG_NLS_ISO8859_13 is not set
831# CONFIG_NLS_ISO8859_14 is not set
832# CONFIG_NLS_ISO8859_15 is not set
833# CONFIG_NLS_KOI8_R is not set
834# CONFIG_NLS_KOI8_U is not set
835CONFIG_NLS_UTF8=m
836
837#
838# Profiling support
839#
840# CONFIG_PROFILING is not set
841
842#
843# Kernel hacking
844#
845# CONFIG_PRINTK_TIME is not set
846CONFIG_DEBUG_KERNEL=y
847CONFIG_MAGIC_SYSRQ=y
848CONFIG_LOG_BUF_SHIFT=14
849CONFIG_DETECT_SOFTLOCKUP=y
850# CONFIG_SCHEDSTATS is not set
851# CONFIG_DEBUG_SLAB is not set
852CONFIG_DEBUG_PREEMPT=y
853# CONFIG_DEBUG_SPINLOCK is not set
854# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
855# CONFIG_DEBUG_KOBJECT is not set
856# CONFIG_DEBUG_BUGVERBOSE is not set
857# CONFIG_DEBUG_INFO is not set
858# CONFIG_DEBUG_FS is not set
859CONFIG_FRAME_POINTER=y
860# CONFIG_DEBUG_USER is not set
861# CONFIG_DEBUG_WAITQ is not set
862CONFIG_DEBUG_ERRORS=y
863# CONFIG_DEBUG_LL is not set
864
865#
866# Security options
867#
868# CONFIG_KEYS is not set
869# CONFIG_SECURITY is not set
870
871#
872# Cryptographic options
873#
874# CONFIG_CRYPTO is not set
875
876#
877# Hardware crypto devices
878#
879
880#
881# Library routines
882#
883# CONFIG_CRC_CCITT is not set
884# CONFIG_CRC16 is not set
885CONFIG_CRC32=y
886# CONFIG_LIBCRC32C is not set
887CONFIG_ZLIB_INFLATE=y
888CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/corgi_defconfig b/arch/arm/configs/corgi_defconfig
new file mode 100644
index 000000000000..24987c89609a
--- /dev/null
+++ b/arch/arm/configs/corgi_defconfig
@@ -0,0 +1,1523 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc3
4# Sun Oct 9 15:46:42 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
20
21#
22# General setup
23#
24CONFIG_LOCALVERSION=""
25CONFIG_LOCALVERSION_AUTO=y
26CONFIG_SWAP=y
27CONFIG_SYSVIPC=y
28# CONFIG_POSIX_MQUEUE is not set
29CONFIG_BSD_PROCESS_ACCT=y
30# CONFIG_BSD_PROCESS_ACCT_V3 is not set
31CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set
33CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y
35# CONFIG_IKCONFIG is not set
36CONFIG_INITRAMFS_SOURCE=""
37CONFIG_EMBEDDED=y
38CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_ALL is not set
40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_BASE_FULL=y
44CONFIG_FUTEX=y
45CONFIG_EPOLL=y
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SHMEM=y
48CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
54
55#
56# Loadable module support
57#
58CONFIG_MODULES=y
59CONFIG_MODULE_UNLOAD=y
60CONFIG_MODULE_FORCE_UNLOAD=y
61CONFIG_OBSOLETE_MODPARM=y
62# CONFIG_MODVERSIONS is not set
63# CONFIG_MODULE_SRCVERSION_ALL is not set
64CONFIG_KMOD=y
65
66#
67# System Type
68#
69# CONFIG_ARCH_CLPS7500 is not set
70# CONFIG_ARCH_CLPS711X is not set
71# CONFIG_ARCH_CO285 is not set
72# CONFIG_ARCH_EBSA110 is not set
73# CONFIG_ARCH_CAMELOT is not set
74# CONFIG_ARCH_FOOTBRIDGE is not set
75# CONFIG_ARCH_INTEGRATOR is not set
76# CONFIG_ARCH_IOP3XX is not set
77# CONFIG_ARCH_IXP4XX is not set
78# CONFIG_ARCH_IXP2000 is not set
79# CONFIG_ARCH_L7200 is not set
80CONFIG_ARCH_PXA=y
81# CONFIG_ARCH_RPC is not set
82# CONFIG_ARCH_SA1100 is not set
83# CONFIG_ARCH_S3C2410 is not set
84# CONFIG_ARCH_SHARK is not set
85# CONFIG_ARCH_LH7A40X is not set
86# CONFIG_ARCH_OMAP is not set
87# CONFIG_ARCH_VERSATILE is not set
88# CONFIG_ARCH_IMX is not set
89# CONFIG_ARCH_H720X is not set
90# CONFIG_ARCH_AAEC2000 is not set
91
92#
93# Intel PXA2xx Implementations
94#
95# CONFIG_ARCH_LUBBOCK is not set
96# CONFIG_MACH_MAINSTONE is not set
97# CONFIG_ARCH_PXA_IDP is not set
98CONFIG_PXA_SHARPSL=y
99CONFIG_PXA_SHARPSL_25x=y
100# CONFIG_PXA_SHARPSL_27x is not set
101# CONFIG_MACH_POODLE is not set
102CONFIG_MACH_CORGI=y
103CONFIG_MACH_SHEPHERD=y
104CONFIG_MACH_HUSKY=y
105CONFIG_PXA25x=y
106CONFIG_PXA_SHARP_C7xx=y
107
108#
109# Processor Type
110#
111CONFIG_CPU_32=y
112CONFIG_CPU_XSCALE=y
113CONFIG_CPU_32v5=y
114CONFIG_CPU_ABRT_EV5T=y
115CONFIG_CPU_CACHE_VIVT=y
116CONFIG_CPU_TLB_V4WBI=y
117
118#
119# Processor Features
120#
121CONFIG_ARM_THUMB=y
122CONFIG_XSCALE_PMU=y
123CONFIG_SHARP_PARAM=y
124CONFIG_SHARP_SCOOP=y
125
126#
127# Bus support
128#
129CONFIG_ISA_DMA_API=y
130
131#
132# PCCARD (PCMCIA/CardBus) support
133#
134CONFIG_PCCARD=y
135# CONFIG_PCMCIA_DEBUG is not set
136CONFIG_PCMCIA=y
137CONFIG_PCMCIA_LOAD_CIS=y
138CONFIG_PCMCIA_IOCTL=y
139
140#
141# PC-card bridges
142#
143CONFIG_PCMCIA_PXA2XX=y
144
145#
146# Kernel Features
147#
148CONFIG_PREEMPT=y
149# CONFIG_NO_IDLE_HZ is not set
150# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
151CONFIG_SELECT_MEMORY_MODEL=y
152CONFIG_FLATMEM_MANUAL=y
153# CONFIG_DISCONTIGMEM_MANUAL is not set
154# CONFIG_SPARSEMEM_MANUAL is not set
155CONFIG_FLATMEM=y
156CONFIG_FLAT_NODE_MEM_MAP=y
157# CONFIG_SPARSEMEM_STATIC is not set
158CONFIG_ALIGNMENT_TRAP=y
159
160#
161# Boot options
162#
163CONFIG_ZBOOT_ROM_TEXT=0x0
164CONFIG_ZBOOT_ROM_BSS=0x0
165CONFIG_CMDLINE="console=ttyS0,115200n8 console=tty1 noinitrd root=/dev/mtdblock2 rootfstype=jffs2 debug"
166# CONFIG_XIP_KERNEL is not set
167
168#
169# Floating point emulation
170#
171
172#
173# At least one emulation must be selected
174#
175CONFIG_FPE_NWFPE=y
176# CONFIG_FPE_NWFPE_XP is not set
177# CONFIG_FPE_FASTFPE is not set
178
179#
180# Userspace binary formats
181#
182CONFIG_BINFMT_ELF=y
183CONFIG_BINFMT_AOUT=m
184CONFIG_BINFMT_MISC=m
185# CONFIG_ARTHUR is not set
186
187#
188# Power management options
189#
190CONFIG_PM=y
191CONFIG_APM=y
192
193#
194# Networking
195#
196CONFIG_NET=y
197
198#
199# Networking options
200#
201CONFIG_PACKET=y
202CONFIG_PACKET_MMAP=y
203CONFIG_UNIX=y
204CONFIG_XFRM=y
205CONFIG_XFRM_USER=m
206# CONFIG_NET_KEY is not set
207CONFIG_INET=y
208# CONFIG_IP_MULTICAST is not set
209# CONFIG_IP_ADVANCED_ROUTER is not set
210CONFIG_IP_FIB_HASH=y
211# CONFIG_IP_PNP is not set
212# CONFIG_NET_IPIP is not set
213# CONFIG_NET_IPGRE is not set
214# CONFIG_ARPD is not set
215CONFIG_SYN_COOKIES=y
216# CONFIG_INET_AH is not set
217# CONFIG_INET_ESP is not set
218# CONFIG_INET_IPCOMP is not set
219# CONFIG_INET_TUNNEL is not set
220CONFIG_INET_DIAG=y
221CONFIG_INET_TCP_DIAG=y
222# CONFIG_TCP_CONG_ADVANCED is not set
223CONFIG_TCP_CONG_BIC=y
224
225#
226# IP: Virtual Server Configuration
227#
228# CONFIG_IP_VS is not set
229CONFIG_IPV6=m
230# CONFIG_IPV6_PRIVACY is not set
231CONFIG_INET6_AH=m
232CONFIG_INET6_ESP=m
233CONFIG_INET6_IPCOMP=m
234CONFIG_INET6_TUNNEL=m
235CONFIG_IPV6_TUNNEL=m
236CONFIG_NETFILTER=y
237# CONFIG_NETFILTER_DEBUG is not set
238# CONFIG_NETFILTER_NETLINK is not set
239
240#
241# IP: Netfilter Configuration
242#
243CONFIG_IP_NF_CONNTRACK=m
244# CONFIG_IP_NF_CT_ACCT is not set
245# CONFIG_IP_NF_CONNTRACK_MARK is not set
246# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
247CONFIG_IP_NF_CT_PROTO_SCTP=m
248CONFIG_IP_NF_FTP=m
249CONFIG_IP_NF_IRC=m
250# CONFIG_IP_NF_NETBIOS_NS is not set
251CONFIG_IP_NF_TFTP=m
252CONFIG_IP_NF_AMANDA=m
253# CONFIG_IP_NF_PPTP is not set
254CONFIG_IP_NF_QUEUE=m
255CONFIG_IP_NF_IPTABLES=m
256CONFIG_IP_NF_MATCH_LIMIT=m
257CONFIG_IP_NF_MATCH_IPRANGE=m
258CONFIG_IP_NF_MATCH_MAC=m
259CONFIG_IP_NF_MATCH_PKTTYPE=m
260CONFIG_IP_NF_MATCH_MARK=m
261CONFIG_IP_NF_MATCH_MULTIPORT=m
262CONFIG_IP_NF_MATCH_TOS=m
263CONFIG_IP_NF_MATCH_RECENT=m
264CONFIG_IP_NF_MATCH_ECN=m
265CONFIG_IP_NF_MATCH_DSCP=m
266CONFIG_IP_NF_MATCH_AH_ESP=m
267CONFIG_IP_NF_MATCH_LENGTH=m
268CONFIG_IP_NF_MATCH_TTL=m
269CONFIG_IP_NF_MATCH_TCPMSS=m
270CONFIG_IP_NF_MATCH_HELPER=m
271CONFIG_IP_NF_MATCH_STATE=m
272CONFIG_IP_NF_MATCH_CONNTRACK=m
273CONFIG_IP_NF_MATCH_OWNER=m
274CONFIG_IP_NF_MATCH_ADDRTYPE=m
275CONFIG_IP_NF_MATCH_REALM=m
276CONFIG_IP_NF_MATCH_SCTP=m
277# CONFIG_IP_NF_MATCH_DCCP is not set
278CONFIG_IP_NF_MATCH_COMMENT=m
279CONFIG_IP_NF_MATCH_HASHLIMIT=m
280# CONFIG_IP_NF_MATCH_STRING is not set
281CONFIG_IP_NF_FILTER=m
282# CONFIG_IP_NF_TARGET_REJECT is not set
283CONFIG_IP_NF_TARGET_LOG=m
284CONFIG_IP_NF_TARGET_ULOG=m
285CONFIG_IP_NF_TARGET_TCPMSS=m
286# CONFIG_IP_NF_TARGET_NFQUEUE is not set
287CONFIG_IP_NF_NAT=m
288CONFIG_IP_NF_NAT_NEEDED=y
289# CONFIG_IP_NF_TARGET_MASQUERADE is not set
290# CONFIG_IP_NF_TARGET_REDIRECT is not set
291# CONFIG_IP_NF_TARGET_NETMAP is not set
292# CONFIG_IP_NF_TARGET_SAME is not set
293# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
294CONFIG_IP_NF_NAT_IRC=m
295CONFIG_IP_NF_NAT_FTP=m
296CONFIG_IP_NF_NAT_TFTP=m
297CONFIG_IP_NF_NAT_AMANDA=m
298CONFIG_IP_NF_MANGLE=m
299# CONFIG_IP_NF_TARGET_TOS is not set
300# CONFIG_IP_NF_TARGET_ECN is not set
301# CONFIG_IP_NF_TARGET_DSCP is not set
302# CONFIG_IP_NF_TARGET_MARK is not set
303# CONFIG_IP_NF_TARGET_CLASSIFY is not set
304# CONFIG_IP_NF_TARGET_TTL is not set
305CONFIG_IP_NF_RAW=m
306# CONFIG_IP_NF_TARGET_NOTRACK is not set
307CONFIG_IP_NF_ARPTABLES=m
308CONFIG_IP_NF_ARPFILTER=m
309CONFIG_IP_NF_ARP_MANGLE=m
310
311#
312# IPv6: Netfilter Configuration (EXPERIMENTAL)
313#
314CONFIG_IP6_NF_QUEUE=m
315CONFIG_IP6_NF_IPTABLES=m
316CONFIG_IP6_NF_MATCH_LIMIT=m
317CONFIG_IP6_NF_MATCH_MAC=m
318CONFIG_IP6_NF_MATCH_RT=m
319CONFIG_IP6_NF_MATCH_OPTS=m
320CONFIG_IP6_NF_MATCH_FRAG=m
321CONFIG_IP6_NF_MATCH_HL=m
322CONFIG_IP6_NF_MATCH_MULTIPORT=m
323CONFIG_IP6_NF_MATCH_OWNER=m
324CONFIG_IP6_NF_MATCH_MARK=m
325CONFIG_IP6_NF_MATCH_IPV6HEADER=m
326CONFIG_IP6_NF_MATCH_AHESP=m
327CONFIG_IP6_NF_MATCH_LENGTH=m
328CONFIG_IP6_NF_MATCH_EUI64=m
329CONFIG_IP6_NF_FILTER=m
330# CONFIG_IP6_NF_TARGET_LOG is not set
331# CONFIG_IP6_NF_TARGET_REJECT is not set
332# CONFIG_IP6_NF_TARGET_NFQUEUE is not set
333CONFIG_IP6_NF_MANGLE=m
334# CONFIG_IP6_NF_TARGET_MARK is not set
335# CONFIG_IP6_NF_TARGET_HL is not set
336CONFIG_IP6_NF_RAW=m
337
338#
339# DCCP Configuration (EXPERIMENTAL)
340#
341# CONFIG_IP_DCCP is not set
342
343#
344# SCTP Configuration (EXPERIMENTAL)
345#
346# CONFIG_IP_SCTP is not set
347# CONFIG_ATM is not set
348# CONFIG_BRIDGE is not set
349# CONFIG_VLAN_8021Q is not set
350# CONFIG_DECNET is not set
351# CONFIG_LLC2 is not set
352# CONFIG_IPX is not set
353# CONFIG_ATALK is not set
354# CONFIG_X25 is not set
355# CONFIG_LAPB is not set
356# CONFIG_NET_DIVERT is not set
357# CONFIG_ECONET is not set
358# CONFIG_WAN_ROUTER is not set
359# CONFIG_NET_SCHED is not set
360CONFIG_NET_CLS_ROUTE=y
361
362#
363# Network testing
364#
365# CONFIG_NET_PKTGEN is not set
366# CONFIG_HAMRADIO is not set
367CONFIG_IRDA=m
368
369#
370# IrDA protocols
371#
372CONFIG_IRLAN=m
373CONFIG_IRNET=m
374CONFIG_IRCOMM=m
375# CONFIG_IRDA_ULTRA is not set
376
377#
378# IrDA options
379#
380# CONFIG_IRDA_CACHE_LAST_LSAP is not set
381# CONFIG_IRDA_FAST_RR is not set
382# CONFIG_IRDA_DEBUG is not set
383
384#
385# Infrared-port device drivers
386#
387
388#
389# SIR device drivers
390#
391# CONFIG_IRTTY_SIR is not set
392
393#
394# Dongle support
395#
396
397#
398# Old SIR device drivers
399#
400# CONFIG_IRPORT_SIR is not set
401
402#
403# Old Serial dongle support
404#
405
406#
407# FIR device drivers
408#
409# CONFIG_USB_IRDA is not set
410# CONFIG_SIGMATEL_FIR is not set
411# CONFIG_NSC_FIR is not set
412# CONFIG_WINBOND_FIR is not set
413# CONFIG_SMC_IRCC_FIR is not set
414# CONFIG_ALI_FIR is not set
415# CONFIG_VIA_FIR is not set
416CONFIG_BT=m
417CONFIG_BT_L2CAP=m
418CONFIG_BT_SCO=m
419CONFIG_BT_RFCOMM=m
420CONFIG_BT_RFCOMM_TTY=y
421CONFIG_BT_BNEP=m
422CONFIG_BT_BNEP_MC_FILTER=y
423CONFIG_BT_BNEP_PROTO_FILTER=y
424CONFIG_BT_HIDP=m
425
426#
427# Bluetooth device drivers
428#
429CONFIG_BT_HCIUSB=m
430# CONFIG_BT_HCIUSB_SCO is not set
431CONFIG_BT_HCIUART=m
432CONFIG_BT_HCIUART_H4=y
433CONFIG_BT_HCIUART_BCSP=y
434CONFIG_BT_HCIUART_BCSP_TXCRC=y
435CONFIG_BT_HCIBCM203X=m
436CONFIG_BT_HCIBPA10X=m
437CONFIG_BT_HCIBFUSB=m
438CONFIG_BT_HCIDTL1=m
439CONFIG_BT_HCIBT3C=m
440CONFIG_BT_HCIBLUECARD=m
441CONFIG_BT_HCIBTUART=m
442CONFIG_BT_HCIVHCI=m
443CONFIG_IEEE80211=m
444# CONFIG_IEEE80211_DEBUG is not set
445CONFIG_IEEE80211_CRYPT_WEP=m
446# CONFIG_IEEE80211_CRYPT_CCMP is not set
447# CONFIG_IEEE80211_CRYPT_TKIP is not set
448
449#
450# Device Drivers
451#
452
453#
454# Generic Driver Options
455#
456CONFIG_STANDALONE=y
457CONFIG_PREVENT_FIRMWARE_BUILD=y
458CONFIG_FW_LOADER=y
459# CONFIG_DEBUG_DRIVER is not set
460
461#
462# Memory Technology Devices (MTD)
463#
464CONFIG_MTD=y
465# CONFIG_MTD_DEBUG is not set
466# CONFIG_MTD_CONCAT is not set
467CONFIG_MTD_PARTITIONS=y
468# CONFIG_MTD_REDBOOT_PARTS is not set
469CONFIG_MTD_CMDLINE_PARTS=y
470# CONFIG_MTD_AFS_PARTS is not set
471
472#
473# User Modules And Translation Layers
474#
475CONFIG_MTD_CHAR=y
476CONFIG_MTD_BLOCK=y
477# CONFIG_FTL is not set
478# CONFIG_NFTL is not set
479# CONFIG_INFTL is not set
480
481#
482# RAM/ROM/Flash chip drivers
483#
484# CONFIG_MTD_CFI is not set
485# CONFIG_MTD_JEDECPROBE is not set
486CONFIG_MTD_MAP_BANK_WIDTH_1=y
487CONFIG_MTD_MAP_BANK_WIDTH_2=y
488CONFIG_MTD_MAP_BANK_WIDTH_4=y
489# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
490# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
491# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
492CONFIG_MTD_CFI_I1=y
493CONFIG_MTD_CFI_I2=y
494# CONFIG_MTD_CFI_I4 is not set
495# CONFIG_MTD_CFI_I8 is not set
496# CONFIG_MTD_RAM is not set
497CONFIG_MTD_ROM=y
498# CONFIG_MTD_ABSENT is not set
499
500#
501# Mapping drivers for chip access
502#
503CONFIG_MTD_COMPLEX_MAPPINGS=y
504CONFIG_MTD_SHARP_SL=y
505# CONFIG_MTD_PLATRAM is not set
506
507#
508# Self-contained MTD device drivers
509#
510# CONFIG_MTD_SLRAM is not set
511# CONFIG_MTD_PHRAM is not set
512# CONFIG_MTD_MTDRAM is not set
513# CONFIG_MTD_BLKMTD is not set
514# CONFIG_MTD_BLOCK2MTD is not set
515
516#
517# Disk-On-Chip Device Drivers
518#
519# CONFIG_MTD_DOC2000 is not set
520# CONFIG_MTD_DOC2001 is not set
521# CONFIG_MTD_DOC2001PLUS is not set
522
523#
524# NAND Flash Device Drivers
525#
526CONFIG_MTD_NAND=y
527CONFIG_MTD_NAND_VERIFY_WRITE=y
528# CONFIG_MTD_NAND_H1900 is not set
529CONFIG_MTD_NAND_IDS=y
530# CONFIG_MTD_NAND_DISKONCHIP is not set
531CONFIG_MTD_NAND_SHARPSL=y
532# CONFIG_MTD_NAND_NANDSIM is not set
533
534#
535# Parallel port support
536#
537# CONFIG_PARPORT is not set
538
539#
540# Plug and Play support
541#
542
543#
544# Block devices
545#
546# CONFIG_BLK_DEV_COW_COMMON is not set
547CONFIG_BLK_DEV_LOOP=y
548# CONFIG_BLK_DEV_CRYPTOLOOP is not set
549# CONFIG_BLK_DEV_NBD is not set
550# CONFIG_BLK_DEV_UB is not set
551# CONFIG_BLK_DEV_RAM is not set
552CONFIG_BLK_DEV_RAM_COUNT=16
553# CONFIG_CDROM_PKTCDVD is not set
554
555#
556# IO Schedulers
557#
558CONFIG_IOSCHED_NOOP=y
559CONFIG_IOSCHED_AS=y
560CONFIG_IOSCHED_DEADLINE=y
561CONFIG_IOSCHED_CFQ=y
562# CONFIG_ATA_OVER_ETH is not set
563
564#
565# ATA/ATAPI/MFM/RLL support
566#
567CONFIG_IDE=y
568CONFIG_BLK_DEV_IDE=y
569
570#
571# Please see Documentation/ide.txt for help/info on IDE drives
572#
573# CONFIG_BLK_DEV_IDE_SATA is not set
574CONFIG_BLK_DEV_IDEDISK=y
575# CONFIG_IDEDISK_MULTI_MODE is not set
576CONFIG_BLK_DEV_IDECS=y
577# CONFIG_BLK_DEV_IDECD is not set
578# CONFIG_BLK_DEV_IDETAPE is not set
579# CONFIG_BLK_DEV_IDEFLOPPY is not set
580# CONFIG_BLK_DEV_IDESCSI is not set
581# CONFIG_IDE_TASK_IOCTL is not set
582
583#
584# IDE chipset support/bugfixes
585#
586CONFIG_IDE_GENERIC=y
587# CONFIG_IDE_ARM is not set
588# CONFIG_BLK_DEV_IDEDMA is not set
589# CONFIG_IDEDMA_AUTO is not set
590# CONFIG_BLK_DEV_HD is not set
591
592#
593# SCSI device support
594#
595# CONFIG_RAID_ATTRS is not set
596CONFIG_SCSI=m
597CONFIG_SCSI_PROC_FS=y
598
599#
600# SCSI support type (disk, tape, CD-ROM)
601#
602CONFIG_BLK_DEV_SD=m
603CONFIG_CHR_DEV_ST=m
604CONFIG_CHR_DEV_OSST=m
605CONFIG_BLK_DEV_SR=m
606# CONFIG_BLK_DEV_SR_VENDOR is not set
607CONFIG_CHR_DEV_SG=m
608# CONFIG_CHR_DEV_SCH is not set
609
610#
611# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
612#
613CONFIG_SCSI_MULTI_LUN=y
614# CONFIG_SCSI_CONSTANTS is not set
615# CONFIG_SCSI_LOGGING is not set
616
617#
618# SCSI Transport Attributes
619#
620# CONFIG_SCSI_SPI_ATTRS is not set
621# CONFIG_SCSI_FC_ATTRS is not set
622# CONFIG_SCSI_ISCSI_ATTRS is not set
623# CONFIG_SCSI_SAS_ATTRS is not set
624
625#
626# SCSI low-level drivers
627#
628# CONFIG_SCSI_SATA is not set
629# CONFIG_SCSI_DEBUG is not set
630
631#
632# PCMCIA SCSI adapter support
633#
634# CONFIG_PCMCIA_AHA152X is not set
635# CONFIG_PCMCIA_FDOMAIN is not set
636# CONFIG_PCMCIA_NINJA_SCSI is not set
637# CONFIG_PCMCIA_QLOGIC is not set
638# CONFIG_PCMCIA_SYM53C500 is not set
639
640#
641# Multi-device support (RAID and LVM)
642#
643# CONFIG_MD is not set
644
645#
646# Fusion MPT device support
647#
648# CONFIG_FUSION is not set
649
650#
651# IEEE 1394 (FireWire) support
652#
653
654#
655# I2O device support
656#
657
658#
659# Network device support
660#
661CONFIG_NETDEVICES=y
662# CONFIG_DUMMY is not set
663# CONFIG_BONDING is not set
664# CONFIG_EQUALIZER is not set
665# CONFIG_TUN is not set
666
667#
668# PHY device support
669#
670# CONFIG_PHYLIB is not set
671
672#
673# Ethernet (10 or 100Mbit)
674#
675CONFIG_NET_ETHERNET=y
676CONFIG_MII=m
677# CONFIG_SMC91X is not set
678# CONFIG_DM9000 is not set
679
680#
681# Ethernet (1000 Mbit)
682#
683
684#
685# Ethernet (10000 Mbit)
686#
687
688#
689# Token Ring devices
690#
691
692#
693# Wireless LAN (non-hamradio)
694#
695CONFIG_NET_RADIO=y
696
697#
698# Obsolete Wireless cards support (pre-802.11)
699#
700# CONFIG_STRIP is not set
701# CONFIG_PCMCIA_WAVELAN is not set
702# CONFIG_PCMCIA_NETWAVE is not set
703
704#
705# Wireless 802.11 Frequency Hopping cards support
706#
707# CONFIG_PCMCIA_RAYCS is not set
708
709#
710# Wireless 802.11b ISA/PCI cards support
711#
712CONFIG_HERMES=m
713# CONFIG_ATMEL is not set
714
715#
716# Wireless 802.11b Pcmcia/Cardbus cards support
717#
718CONFIG_PCMCIA_HERMES=m
719CONFIG_PCMCIA_SPECTRUM=m
720# CONFIG_AIRO_CS is not set
721# CONFIG_PCMCIA_WL3501 is not set
722CONFIG_HOSTAP=m
723CONFIG_HOSTAP_FIRMWARE=y
724CONFIG_HOSTAP_CS=m
725CONFIG_NET_WIRELESS=y
726
727#
728# PCMCIA network device support
729#
730CONFIG_NET_PCMCIA=y
731# CONFIG_PCMCIA_3C589 is not set
732# CONFIG_PCMCIA_3C574 is not set
733# CONFIG_PCMCIA_FMVJ18X is not set
734CONFIG_PCMCIA_PCNET=m
735# CONFIG_PCMCIA_NMCLAN is not set
736# CONFIG_PCMCIA_SMC91C92 is not set
737# CONFIG_PCMCIA_XIRC2PS is not set
738# CONFIG_PCMCIA_AXNET is not set
739
740#
741# Wan interfaces
742#
743# CONFIG_WAN is not set
744CONFIG_PPP=m
745# CONFIG_PPP_MULTILINK is not set
746# CONFIG_PPP_FILTER is not set
747CONFIG_PPP_ASYNC=m
748# CONFIG_PPP_SYNC_TTY is not set
749# CONFIG_PPP_DEFLATE is not set
750CONFIG_PPP_BSDCOMP=m
751# CONFIG_PPPOE is not set
752# CONFIG_SLIP is not set
753# CONFIG_SHAPER is not set
754# CONFIG_NETCONSOLE is not set
755# CONFIG_NETPOLL is not set
756# CONFIG_NET_POLL_CONTROLLER is not set
757
758#
759# ISDN subsystem
760#
761# CONFIG_ISDN is not set
762
763#
764# Input device support
765#
766CONFIG_INPUT=y
767
768#
769# Userland interfaces
770#
771# CONFIG_INPUT_MOUSEDEV is not set
772# CONFIG_INPUT_JOYDEV is not set
773# CONFIG_INPUT_TSDEV is not set
774CONFIG_INPUT_EVDEV=y
775# CONFIG_INPUT_EVBUG is not set
776
777#
778# Input Device Drivers
779#
780CONFIG_INPUT_KEYBOARD=y
781# CONFIG_KEYBOARD_ATKBD is not set
782# CONFIG_KEYBOARD_SUNKBD is not set
783# CONFIG_KEYBOARD_LKKBD is not set
784# CONFIG_KEYBOARD_XTKBD is not set
785# CONFIG_KEYBOARD_NEWTON is not set
786CONFIG_KEYBOARD_CORGI=y
787CONFIG_KEYBOARD_SPITZ=y
788# CONFIG_INPUT_MOUSE is not set
789# CONFIG_INPUT_JOYSTICK is not set
790CONFIG_INPUT_TOUCHSCREEN=y
791CONFIG_TOUCHSCREEN_CORGI=y
792# CONFIG_TOUCHSCREEN_GUNZE is not set
793# CONFIG_TOUCHSCREEN_ELO is not set
794# CONFIG_TOUCHSCREEN_MTOUCH is not set
795# CONFIG_TOUCHSCREEN_MK712 is not set
796CONFIG_INPUT_MISC=y
797CONFIG_INPUT_UINPUT=m
798
799#
800# Hardware I/O ports
801#
802# CONFIG_SERIO is not set
803# CONFIG_GAMEPORT is not set
804
805#
806# Character devices
807#
808CONFIG_VT=y
809CONFIG_VT_CONSOLE=y
810CONFIG_HW_CONSOLE=y
811# CONFIG_SERIAL_NONSTANDARD is not set
812
813#
814# Serial drivers
815#
816CONFIG_SERIAL_8250=m
817CONFIG_SERIAL_8250_CS=m
818CONFIG_SERIAL_8250_NR_UARTS=4
819# CONFIG_SERIAL_8250_EXTENDED is not set
820
821#
822# Non-8250 serial port support
823#
824CONFIG_SERIAL_PXA=y
825CONFIG_SERIAL_PXA_CONSOLE=y
826CONFIG_SERIAL_CORE=y
827CONFIG_SERIAL_CORE_CONSOLE=y
828CONFIG_UNIX98_PTYS=y
829# CONFIG_LEGACY_PTYS is not set
830
831#
832# IPMI
833#
834# CONFIG_IPMI_HANDLER is not set
835
836#
837# Watchdog Cards
838#
839# CONFIG_WATCHDOG is not set
840# CONFIG_NVRAM is not set
841# CONFIG_RTC is not set
842# CONFIG_DTLK is not set
843# CONFIG_R3964 is not set
844
845#
846# Ftape, the floppy tape device driver
847#
848
849#
850# PCMCIA character devices
851#
852# CONFIG_SYNCLINK_CS is not set
853# CONFIG_RAW_DRIVER is not set
854
855#
856# TPM devices
857#
858
859#
860# I2C support
861#
862CONFIG_I2C=y
863# CONFIG_I2C_CHARDEV is not set
864
865#
866# I2C Algorithms
867#
868CONFIG_I2C_ALGOBIT=y
869# CONFIG_I2C_ALGOPCF is not set
870# CONFIG_I2C_ALGOPCA is not set
871
872#
873# I2C Hardware Bus support
874#
875CONFIG_I2C_PXA=y
876# CONFIG_I2C_PXA_SLAVE is not set
877# CONFIG_I2C_PARPORT_LIGHT is not set
878# CONFIG_I2C_STUB is not set
879# CONFIG_I2C_PCA_ISA is not set
880
881#
882# Miscellaneous I2C Chip support
883#
884# CONFIG_SENSORS_DS1337 is not set
885# CONFIG_SENSORS_DS1374 is not set
886# CONFIG_SENSORS_EEPROM is not set
887# CONFIG_SENSORS_PCF8574 is not set
888# CONFIG_SENSORS_PCA9539 is not set
889# CONFIG_SENSORS_PCF8591 is not set
890# CONFIG_SENSORS_RTC8564 is not set
891# CONFIG_SENSORS_MAX6875 is not set
892# CONFIG_I2C_DEBUG_CORE is not set
893# CONFIG_I2C_DEBUG_ALGO is not set
894# CONFIG_I2C_DEBUG_BUS is not set
895# CONFIG_I2C_DEBUG_CHIP is not set
896
897#
898# Hardware Monitoring support
899#
900CONFIG_HWMON=y
901# CONFIG_HWMON_VID is not set
902# CONFIG_SENSORS_ADM1021 is not set
903# CONFIG_SENSORS_ADM1025 is not set
904# CONFIG_SENSORS_ADM1026 is not set
905# CONFIG_SENSORS_ADM1031 is not set
906# CONFIG_SENSORS_ADM9240 is not set
907# CONFIG_SENSORS_ASB100 is not set
908# CONFIG_SENSORS_ATXP1 is not set
909# CONFIG_SENSORS_DS1621 is not set
910# CONFIG_SENSORS_FSCHER is not set
911# CONFIG_SENSORS_FSCPOS is not set
912# CONFIG_SENSORS_GL518SM is not set
913# CONFIG_SENSORS_GL520SM is not set
914# CONFIG_SENSORS_IT87 is not set
915# CONFIG_SENSORS_LM63 is not set
916# CONFIG_SENSORS_LM75 is not set
917# CONFIG_SENSORS_LM77 is not set
918# CONFIG_SENSORS_LM78 is not set
919# CONFIG_SENSORS_LM80 is not set
920# CONFIG_SENSORS_LM83 is not set
921# CONFIG_SENSORS_LM85 is not set
922# CONFIG_SENSORS_LM87 is not set
923# CONFIG_SENSORS_LM90 is not set
924# CONFIG_SENSORS_LM92 is not set
925# CONFIG_SENSORS_MAX1619 is not set
926# CONFIG_SENSORS_PC87360 is not set
927# CONFIG_SENSORS_SMSC47M1 is not set
928# CONFIG_SENSORS_SMSC47B397 is not set
929# CONFIG_SENSORS_W83781D is not set
930# CONFIG_SENSORS_W83792D is not set
931# CONFIG_SENSORS_W83L785TS is not set
932# CONFIG_SENSORS_W83627HF is not set
933# CONFIG_SENSORS_W83627EHF is not set
934# CONFIG_HWMON_DEBUG_CHIP is not set
935
936#
937# Misc devices
938#
939
940#
941# Multimedia Capabilities Port drivers
942#
943
944#
945# Multimedia devices
946#
947CONFIG_VIDEO_DEV=m
948
949#
950# Video For Linux
951#
952
953#
954# Video Adapters
955#
956# CONFIG_VIDEO_CPIA is not set
957# CONFIG_VIDEO_SAA5246A is not set
958# CONFIG_VIDEO_SAA5249 is not set
959# CONFIG_TUNER_3036 is not set
960# CONFIG_VIDEO_OVCAMCHIP is not set
961
962#
963# Radio Adapters
964#
965# CONFIG_RADIO_MAESTRO is not set
966
967#
968# Digital Video Broadcasting Devices
969#
970# CONFIG_DVB is not set
971
972#
973# Graphics support
974#
975CONFIG_FB=y
976CONFIG_FB_CFB_FILLRECT=y
977CONFIG_FB_CFB_COPYAREA=y
978CONFIG_FB_CFB_IMAGEBLIT=y
979CONFIG_FB_SOFT_CURSOR=y
980# CONFIG_FB_MACMODES is not set
981# CONFIG_FB_MODE_HELPERS is not set
982# CONFIG_FB_TILEBLITTING is not set
983# CONFIG_FB_PXA is not set
984CONFIG_FB_W100=y
985# CONFIG_FB_S1D13XXX is not set
986# CONFIG_FB_VIRTUAL is not set
987
988#
989# Console display driver support
990#
991# CONFIG_VGA_CONSOLE is not set
992CONFIG_DUMMY_CONSOLE=y
993CONFIG_FRAMEBUFFER_CONSOLE=y
994CONFIG_FONTS=y
995CONFIG_FONT_8x8=y
996CONFIG_FONT_8x16=y
997# CONFIG_FONT_6x11 is not set
998# CONFIG_FONT_7x14 is not set
999# CONFIG_FONT_PEARL_8x8 is not set
1000# CONFIG_FONT_ACORN_8x8 is not set
1001# CONFIG_FONT_MINI_4x6 is not set
1002# CONFIG_FONT_SUN8x16 is not set
1003# CONFIG_FONT_SUN12x22 is not set
1004# CONFIG_FONT_10x18 is not set
1005
1006#
1007# Logo configuration
1008#
1009# CONFIG_LOGO is not set
1010CONFIG_BACKLIGHT_LCD_SUPPORT=y
1011CONFIG_BACKLIGHT_CLASS_DEVICE=y
1012CONFIG_BACKLIGHT_DEVICE=y
1013# CONFIG_LCD_CLASS_DEVICE is not set
1014CONFIG_BACKLIGHT_CORGI=y
1015
1016#
1017# Sound
1018#
1019CONFIG_SOUND=y
1020
1021#
1022# Advanced Linux Sound Architecture
1023#
1024# CONFIG_SND is not set
1025
1026#
1027# Open Sound System
1028#
1029CONFIG_SOUND_PRIME=y
1030# CONFIG_SOUND_MSNDCLAS is not set
1031# CONFIG_SOUND_MSNDPIN is not set
1032CONFIG_SOUND_OSS=y
1033# CONFIG_SOUND_TRACEINIT is not set
1034# CONFIG_SOUND_DMAP is not set
1035# CONFIG_SOUND_AD1816 is not set
1036# CONFIG_SOUND_SGALAXY is not set
1037# CONFIG_SOUND_ADLIB is not set
1038# CONFIG_SOUND_ACI_MIXER is not set
1039# CONFIG_SOUND_CS4232 is not set
1040# CONFIG_SOUND_SSCAPE is not set
1041# CONFIG_SOUND_GUS is not set
1042# CONFIG_SOUND_VMIDI is not set
1043# CONFIG_SOUND_TRIX is not set
1044# CONFIG_SOUND_MSS is not set
1045# CONFIG_SOUND_MPU401 is not set
1046# CONFIG_SOUND_NM256 is not set
1047# CONFIG_SOUND_MAD16 is not set
1048# CONFIG_SOUND_PAS is not set
1049# CONFIG_SOUND_PSS is not set
1050# CONFIG_SOUND_SB is not set
1051# CONFIG_SOUND_AWE32_SYNTH is not set
1052# CONFIG_SOUND_WAVEFRONT is not set
1053# CONFIG_SOUND_MAUI is not set
1054# CONFIG_SOUND_YM3812 is not set
1055# CONFIG_SOUND_OPL3SA1 is not set
1056# CONFIG_SOUND_OPL3SA2 is not set
1057# CONFIG_SOUND_UART6850 is not set
1058# CONFIG_SOUND_AEDSP16 is not set
1059# CONFIG_SOUND_TVMIXER is not set
1060# CONFIG_SOUND_AD1980 is not set
1061
1062#
1063# USB support
1064#
1065CONFIG_USB_ARCH_HAS_HCD=y
1066# CONFIG_USB_ARCH_HAS_OHCI is not set
1067CONFIG_USB=m
1068# CONFIG_USB_DEBUG is not set
1069
1070#
1071# Miscellaneous USB options
1072#
1073CONFIG_USB_DEVICEFS=y
1074# CONFIG_USB_BANDWIDTH is not set
1075# CONFIG_USB_DYNAMIC_MINORS is not set
1076# CONFIG_USB_SUSPEND is not set
1077# CONFIG_USB_OTG is not set
1078
1079#
1080# USB Host Controller Drivers
1081#
1082# CONFIG_USB_ISP116X_HCD is not set
1083CONFIG_USB_SL811_HCD=m
1084CONFIG_USB_SL811_CS=m
1085
1086#
1087# USB Device Class drivers
1088#
1089# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
1090
1091#
1092# USB Bluetooth TTY can only be used with disabled Bluetooth subsystem
1093#
1094CONFIG_USB_ACM=m
1095CONFIG_USB_PRINTER=m
1096
1097#
1098# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
1099#
1100CONFIG_USB_STORAGE=m
1101# CONFIG_USB_STORAGE_DEBUG is not set
1102# CONFIG_USB_STORAGE_DATAFAB is not set
1103# CONFIG_USB_STORAGE_FREECOM is not set
1104# CONFIG_USB_STORAGE_ISD200 is not set
1105# CONFIG_USB_STORAGE_DPCM is not set
1106# CONFIG_USB_STORAGE_USBAT is not set
1107# CONFIG_USB_STORAGE_SDDR09 is not set
1108# CONFIG_USB_STORAGE_SDDR55 is not set
1109# CONFIG_USB_STORAGE_JUMPSHOT is not set
1110# CONFIG_USB_STORAGE_ONETOUCH is not set
1111
1112#
1113# USB Input Devices
1114#
1115CONFIG_USB_HID=m
1116CONFIG_USB_HIDINPUT=y
1117# CONFIG_HID_FF is not set
1118# CONFIG_USB_HIDDEV is not set
1119
1120#
1121# USB HID Boot Protocol drivers
1122#
1123CONFIG_USB_KBD=m
1124CONFIG_USB_MOUSE=m
1125CONFIG_USB_AIPTEK=m
1126CONFIG_USB_WACOM=m
1127# CONFIG_USB_ACECAD is not set
1128CONFIG_USB_KBTAB=m
1129CONFIG_USB_POWERMATE=m
1130CONFIG_USB_MTOUCH=m
1131# CONFIG_USB_ITMTOUCH is not set
1132CONFIG_USB_EGALAX=m
1133# CONFIG_USB_YEALINK is not set
1134CONFIG_USB_XPAD=m
1135CONFIG_USB_ATI_REMOTE=m
1136# CONFIG_USB_KEYSPAN_REMOTE is not set
1137# CONFIG_USB_APPLETOUCH is not set
1138
1139#
1140# USB Imaging devices
1141#
1142CONFIG_USB_MDC800=m
1143CONFIG_USB_MICROTEK=m
1144
1145#
1146# USB Multimedia devices
1147#
1148CONFIG_USB_DABUSB=m
1149CONFIG_USB_VICAM=m
1150CONFIG_USB_DSBR=m
1151CONFIG_USB_IBMCAM=m
1152CONFIG_USB_KONICAWC=m
1153CONFIG_USB_OV511=m
1154CONFIG_USB_SE401=m
1155CONFIG_USB_SN9C102=m
1156CONFIG_USB_STV680=m
1157# CONFIG_USB_PWC is not set
1158
1159#
1160# USB Network Adapters
1161#
1162CONFIG_USB_CATC=m
1163CONFIG_USB_KAWETH=m
1164CONFIG_USB_PEGASUS=m
1165CONFIG_USB_RTL8150=m
1166CONFIG_USB_USBNET=m
1167CONFIG_USB_NET_AX8817X=m
1168CONFIG_USB_NET_CDCETHER=m
1169# CONFIG_USB_NET_GL620A is not set
1170CONFIG_USB_NET_NET1080=m
1171# CONFIG_USB_NET_PLUSB is not set
1172# CONFIG_USB_NET_RNDIS_HOST is not set
1173# CONFIG_USB_NET_CDC_SUBSET is not set
1174CONFIG_USB_NET_ZAURUS=m
1175# CONFIG_USB_ZD1201 is not set
1176CONFIG_USB_MON=y
1177
1178#
1179# USB port drivers
1180#
1181
1182#
1183# USB Serial Converter support
1184#
1185CONFIG_USB_SERIAL=m
1186CONFIG_USB_SERIAL_GENERIC=y
1187# CONFIG_USB_SERIAL_AIRPRIME is not set
1188CONFIG_USB_SERIAL_BELKIN=m
1189# CONFIG_USB_SERIAL_WHITEHEAT is not set
1190CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
1191# CONFIG_USB_SERIAL_CP2101 is not set
1192CONFIG_USB_SERIAL_CYPRESS_M8=m
1193CONFIG_USB_SERIAL_EMPEG=m
1194CONFIG_USB_SERIAL_FTDI_SIO=m
1195CONFIG_USB_SERIAL_VISOR=m
1196CONFIG_USB_SERIAL_IPAQ=m
1197CONFIG_USB_SERIAL_IR=m
1198CONFIG_USB_SERIAL_EDGEPORT=m
1199CONFIG_USB_SERIAL_EDGEPORT_TI=m
1200CONFIG_USB_SERIAL_GARMIN=m
1201CONFIG_USB_SERIAL_IPW=m
1202CONFIG_USB_SERIAL_KEYSPAN_PDA=m
1203CONFIG_USB_SERIAL_KEYSPAN=m
1204# CONFIG_USB_SERIAL_KEYSPAN_MPR is not set
1205# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
1206# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
1207# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set
1208# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set
1209# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
1210# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
1211# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
1212# CONFIG_USB_SERIAL_KEYSPAN_USA19QW is not set
1213# CONFIG_USB_SERIAL_KEYSPAN_USA19QI is not set
1214# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
1215# CONFIG_USB_SERIAL_KEYSPAN_USA49WLC is not set
1216CONFIG_USB_SERIAL_KLSI=m
1217CONFIG_USB_SERIAL_KOBIL_SCT=m
1218CONFIG_USB_SERIAL_MCT_U232=m
1219CONFIG_USB_SERIAL_PL2303=m
1220# CONFIG_USB_SERIAL_HP4X is not set
1221CONFIG_USB_SERIAL_SAFE=m
1222# CONFIG_USB_SERIAL_SAFE_PADDED is not set
1223CONFIG_USB_SERIAL_TI=m
1224CONFIG_USB_SERIAL_CYBERJACK=m
1225CONFIG_USB_SERIAL_XIRCOM=m
1226CONFIG_USB_SERIAL_OMNINET=m
1227CONFIG_USB_EZUSB=y
1228
1229#
1230# USB Miscellaneous drivers
1231#
1232CONFIG_USB_EMI62=m
1233CONFIG_USB_EMI26=m
1234CONFIG_USB_AUERSWALD=m
1235CONFIG_USB_RIO500=m
1236CONFIG_USB_LEGOTOWER=m
1237CONFIG_USB_LCD=m
1238CONFIG_USB_LED=m
1239CONFIG_USB_CYTHERM=m
1240CONFIG_USB_PHIDGETKIT=m
1241CONFIG_USB_PHIDGETSERVO=m
1242CONFIG_USB_IDMOUSE=m
1243# CONFIG_USB_LD is not set
1244# CONFIG_USB_TEST is not set
1245
1246#
1247# USB DSL modem support
1248#
1249
1250#
1251# USB Gadget Support
1252#
1253CONFIG_USB_GADGET=y
1254# CONFIG_USB_GADGET_DEBUG_FILES is not set
1255CONFIG_USB_GADGET_SELECTED=y
1256# CONFIG_USB_GADGET_NET2280 is not set
1257CONFIG_USB_GADGET_PXA2XX=y
1258CONFIG_USB_PXA2XX=y
1259# CONFIG_USB_PXA2XX_SMALL is not set
1260# CONFIG_USB_GADGET_GOKU is not set
1261# CONFIG_USB_GADGET_LH7A40X is not set
1262# CONFIG_USB_GADGET_OMAP is not set
1263# CONFIG_USB_GADGET_DUMMY_HCD is not set
1264# CONFIG_USB_GADGET_DUALSPEED is not set
1265CONFIG_USB_ZERO=m
1266CONFIG_USB_ETH=m
1267CONFIG_USB_ETH_RNDIS=y
1268CONFIG_USB_GADGETFS=m
1269CONFIG_USB_FILE_STORAGE=m
1270# CONFIG_USB_FILE_STORAGE_TEST is not set
1271CONFIG_USB_G_SERIAL=m
1272
1273#
1274# MMC/SD Card support
1275#
1276CONFIG_MMC=y
1277# CONFIG_MMC_DEBUG is not set
1278CONFIG_MMC_BLOCK=y
1279CONFIG_MMC_PXA=y
1280# CONFIG_MMC_WBSD is not set
1281
1282#
1283# File systems
1284#
1285CONFIG_EXT2_FS=y
1286# CONFIG_EXT2_FS_XATTR is not set
1287# CONFIG_EXT2_FS_XIP is not set
1288# CONFIG_EXT3_FS is not set
1289# CONFIG_JBD is not set
1290# CONFIG_REISERFS_FS is not set
1291# CONFIG_JFS_FS is not set
1292# CONFIG_FS_POSIX_ACL is not set
1293# CONFIG_XFS_FS is not set
1294# CONFIG_MINIX_FS is not set
1295# CONFIG_ROMFS_FS is not set
1296CONFIG_INOTIFY=y
1297# CONFIG_QUOTA is not set
1298CONFIG_DNOTIFY=y
1299# CONFIG_AUTOFS_FS is not set
1300# CONFIG_AUTOFS4_FS is not set
1301# CONFIG_FUSE_FS is not set
1302
1303#
1304# CD-ROM/DVD Filesystems
1305#
1306# CONFIG_ISO9660_FS is not set
1307# CONFIG_UDF_FS is not set
1308
1309#
1310# DOS/FAT/NT Filesystems
1311#
1312CONFIG_FAT_FS=y
1313CONFIG_MSDOS_FS=y
1314CONFIG_VFAT_FS=y
1315CONFIG_FAT_DEFAULT_CODEPAGE=437
1316CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1317# CONFIG_NTFS_FS is not set
1318
1319#
1320# Pseudo filesystems
1321#
1322CONFIG_PROC_FS=y
1323CONFIG_SYSFS=y
1324CONFIG_TMPFS=y
1325# CONFIG_HUGETLB_PAGE is not set
1326CONFIG_RAMFS=y
1327# CONFIG_RELAYFS_FS is not set
1328
1329#
1330# Miscellaneous filesystems
1331#
1332# CONFIG_ADFS_FS is not set
1333# CONFIG_AFFS_FS is not set
1334# CONFIG_HFS_FS is not set
1335# CONFIG_HFSPLUS_FS is not set
1336# CONFIG_BEFS_FS is not set
1337# CONFIG_BFS_FS is not set
1338# CONFIG_EFS_FS is not set
1339# CONFIG_JFFS_FS is not set
1340CONFIG_JFFS2_FS=y
1341CONFIG_JFFS2_FS_DEBUG=0
1342CONFIG_JFFS2_FS_WRITEBUFFER=y
1343CONFIG_JFFS2_COMPRESSION_OPTIONS=y
1344CONFIG_JFFS2_ZLIB=y
1345CONFIG_JFFS2_RTIME=y
1346CONFIG_JFFS2_RUBIN=y
1347# CONFIG_JFFS2_CMODE_NONE is not set
1348CONFIG_JFFS2_CMODE_PRIORITY=y
1349# CONFIG_JFFS2_CMODE_SIZE is not set
1350CONFIG_CRAMFS=m
1351# CONFIG_VXFS_FS is not set
1352# CONFIG_HPFS_FS is not set
1353# CONFIG_QNX4FS_FS is not set
1354# CONFIG_SYSV_FS is not set
1355# CONFIG_UFS_FS is not set
1356
1357#
1358# Network File Systems
1359#
1360CONFIG_NFS_FS=m
1361CONFIG_NFS_V3=y
1362# CONFIG_NFS_V3_ACL is not set
1363CONFIG_NFS_V4=y
1364# CONFIG_NFS_DIRECTIO is not set
1365# CONFIG_NFSD is not set
1366CONFIG_LOCKD=m
1367CONFIG_LOCKD_V4=y
1368CONFIG_NFS_COMMON=y
1369CONFIG_SUNRPC=m
1370CONFIG_SUNRPC_GSS=m
1371CONFIG_RPCSEC_GSS_KRB5=m
1372# CONFIG_RPCSEC_GSS_SPKM3 is not set
1373CONFIG_SMB_FS=m
1374CONFIG_SMB_NLS_DEFAULT=y
1375CONFIG_SMB_NLS_REMOTE="cp437"
1376# CONFIG_CIFS is not set
1377# CONFIG_NCP_FS is not set
1378# CONFIG_CODA_FS is not set
1379# CONFIG_AFS_FS is not set
1380# CONFIG_9P_FS is not set
1381
1382#
1383# Partition Types
1384#
1385CONFIG_PARTITION_ADVANCED=y
1386# CONFIG_ACORN_PARTITION is not set
1387# CONFIG_OSF_PARTITION is not set
1388# CONFIG_AMIGA_PARTITION is not set
1389# CONFIG_ATARI_PARTITION is not set
1390# CONFIG_MAC_PARTITION is not set
1391CONFIG_MSDOS_PARTITION=y
1392# CONFIG_BSD_DISKLABEL is not set
1393# CONFIG_MINIX_SUBPARTITION is not set
1394# CONFIG_SOLARIS_X86_PARTITION is not set
1395# CONFIG_UNIXWARE_DISKLABEL is not set
1396# CONFIG_LDM_PARTITION is not set
1397# CONFIG_SGI_PARTITION is not set
1398# CONFIG_ULTRIX_PARTITION is not set
1399# CONFIG_SUN_PARTITION is not set
1400# CONFIG_EFI_PARTITION is not set
1401
1402#
1403# Native Language Support
1404#
1405CONFIG_NLS=y
1406CONFIG_NLS_DEFAULT="cp437"
1407CONFIG_NLS_CODEPAGE_437=y
1408# CONFIG_NLS_CODEPAGE_737 is not set
1409# CONFIG_NLS_CODEPAGE_775 is not set
1410# CONFIG_NLS_CODEPAGE_850 is not set
1411# CONFIG_NLS_CODEPAGE_852 is not set
1412# CONFIG_NLS_CODEPAGE_855 is not set
1413# CONFIG_NLS_CODEPAGE_857 is not set
1414# CONFIG_NLS_CODEPAGE_860 is not set
1415# CONFIG_NLS_CODEPAGE_861 is not set
1416# CONFIG_NLS_CODEPAGE_862 is not set
1417# CONFIG_NLS_CODEPAGE_863 is not set
1418# CONFIG_NLS_CODEPAGE_864 is not set
1419# CONFIG_NLS_CODEPAGE_865 is not set
1420# CONFIG_NLS_CODEPAGE_866 is not set
1421# CONFIG_NLS_CODEPAGE_869 is not set
1422# CONFIG_NLS_CODEPAGE_936 is not set
1423# CONFIG_NLS_CODEPAGE_950 is not set
1424# CONFIG_NLS_CODEPAGE_932 is not set
1425# CONFIG_NLS_CODEPAGE_949 is not set
1426# CONFIG_NLS_CODEPAGE_874 is not set
1427# CONFIG_NLS_ISO8859_8 is not set
1428# CONFIG_NLS_CODEPAGE_1250 is not set
1429# CONFIG_NLS_CODEPAGE_1251 is not set
1430# CONFIG_NLS_ASCII is not set
1431CONFIG_NLS_ISO8859_1=y
1432# CONFIG_NLS_ISO8859_2 is not set
1433# CONFIG_NLS_ISO8859_3 is not set
1434# CONFIG_NLS_ISO8859_4 is not set
1435# CONFIG_NLS_ISO8859_5 is not set
1436# CONFIG_NLS_ISO8859_6 is not set
1437# CONFIG_NLS_ISO8859_7 is not set
1438# CONFIG_NLS_ISO8859_9 is not set
1439# CONFIG_NLS_ISO8859_13 is not set
1440# CONFIG_NLS_ISO8859_14 is not set
1441# CONFIG_NLS_ISO8859_15 is not set
1442# CONFIG_NLS_KOI8_R is not set
1443# CONFIG_NLS_KOI8_U is not set
1444CONFIG_NLS_UTF8=y
1445
1446#
1447# Profiling support
1448#
1449CONFIG_PROFILING=y
1450CONFIG_OPROFILE=m
1451
1452#
1453# Kernel hacking
1454#
1455# CONFIG_PRINTK_TIME is not set
1456CONFIG_DEBUG_KERNEL=y
1457CONFIG_MAGIC_SYSRQ=y
1458CONFIG_LOG_BUF_SHIFT=14
1459CONFIG_DETECT_SOFTLOCKUP=y
1460# CONFIG_SCHEDSTATS is not set
1461# CONFIG_DEBUG_SLAB is not set
1462# CONFIG_DEBUG_PREEMPT is not set
1463# CONFIG_DEBUG_SPINLOCK is not set
1464# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1465# CONFIG_DEBUG_KOBJECT is not set
1466CONFIG_DEBUG_BUGVERBOSE=y
1467# CONFIG_DEBUG_INFO is not set
1468# CONFIG_DEBUG_FS is not set
1469CONFIG_FRAME_POINTER=y
1470# CONFIG_DEBUG_USER is not set
1471# CONFIG_DEBUG_WAITQ is not set
1472CONFIG_DEBUG_ERRORS=y
1473CONFIG_DEBUG_LL=y
1474# CONFIG_DEBUG_ICEDCC is not set
1475
1476#
1477# Security options
1478#
1479# CONFIG_KEYS is not set
1480# CONFIG_SECURITY is not set
1481
1482#
1483# Cryptographic options
1484#
1485CONFIG_CRYPTO=y
1486CONFIG_CRYPTO_HMAC=y
1487CONFIG_CRYPTO_NULL=m
1488CONFIG_CRYPTO_MD4=m
1489CONFIG_CRYPTO_MD5=m
1490CONFIG_CRYPTO_SHA1=m
1491CONFIG_CRYPTO_SHA256=m
1492CONFIG_CRYPTO_SHA512=m
1493CONFIG_CRYPTO_WP512=m
1494# CONFIG_CRYPTO_TGR192 is not set
1495CONFIG_CRYPTO_DES=m
1496CONFIG_CRYPTO_BLOWFISH=m
1497CONFIG_CRYPTO_TWOFISH=m
1498CONFIG_CRYPTO_SERPENT=m
1499CONFIG_CRYPTO_AES=m
1500CONFIG_CRYPTO_CAST5=m
1501CONFIG_CRYPTO_CAST6=m
1502CONFIG_CRYPTO_TEA=m
1503CONFIG_CRYPTO_ARC4=m
1504CONFIG_CRYPTO_KHAZAD=m
1505CONFIG_CRYPTO_ANUBIS=m
1506CONFIG_CRYPTO_DEFLATE=m
1507CONFIG_CRYPTO_MICHAEL_MIC=m
1508CONFIG_CRYPTO_CRC32C=m
1509CONFIG_CRYPTO_TEST=m
1510
1511#
1512# Hardware crypto devices
1513#
1514
1515#
1516# Library routines
1517#
1518CONFIG_CRC_CCITT=y
1519# CONFIG_CRC16 is not set
1520CONFIG_CRC32=y
1521CONFIG_LIBCRC32C=m
1522CONFIG_ZLIB_INFLATE=y
1523CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig
index 94aafec5fb46..c279e41ed10e 100644
--- a/arch/arm/configs/ixp4xx_defconfig
+++ b/arch/arm/configs/ixp4xx_defconfig
@@ -1,14 +1,13 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12-rc1-bk2 3# Linux kernel version: 2.6.14-rc1-git5
4# Sun Mar 27 22:53:40 2005 4# Tue Sep 20 17:26:28 2005
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_UID16=y 8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_IOMAP=y
12 11
13# 12#
14# Code maturity level options 13# Code maturity level options
@@ -16,11 +15,13 @@ CONFIG_GENERIC_IOMAP=y
16CONFIG_EXPERIMENTAL=y 15CONFIG_EXPERIMENTAL=y
17CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
18CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
19 19
20# 20#
21# General setup 21# General setup
22# 22#
23CONFIG_LOCALVERSION="" 23CONFIG_LOCALVERSION=""
24CONFIG_LOCALVERSION_AUTO=y
24CONFIG_SWAP=y 25CONFIG_SWAP=y
25CONFIG_SYSVIPC=y 26CONFIG_SYSVIPC=y
26# CONFIG_POSIX_MQUEUE is not set 27# CONFIG_POSIX_MQUEUE is not set
@@ -31,10 +32,13 @@ CONFIG_SYSCTL=y
31# CONFIG_HOTPLUG is not set 32# CONFIG_HOTPLUG is not set
32CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
33# CONFIG_IKCONFIG is not set 34# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE=""
34CONFIG_EMBEDDED=y 36CONFIG_EMBEDDED=y
35CONFIG_KALLSYMS=y 37CONFIG_KALLSYMS=y
36# CONFIG_KALLSYMS_ALL is not set 38# CONFIG_KALLSYMS_ALL is not set
37# CONFIG_KALLSYMS_EXTRA_PASS is not set 39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_PRINTK=y
41CONFIG_BUG=y
38CONFIG_BASE_FULL=y 42CONFIG_BASE_FULL=y
39CONFIG_FUTEX=y 43CONFIG_FUTEX=y
40CONFIG_EPOLL=y 44CONFIG_EPOLL=y
@@ -81,6 +85,7 @@ CONFIG_ARCH_IXP4XX=y
81# CONFIG_ARCH_VERSATILE is not set 85# CONFIG_ARCH_VERSATILE is not set
82# CONFIG_ARCH_IMX is not set 86# CONFIG_ARCH_IMX is not set
83# CONFIG_ARCH_H720X is not set 87# CONFIG_ARCH_H720X is not set
88# CONFIG_ARCH_AAEC2000 is not set
84CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y 89CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
85 90
86# 91#
@@ -90,15 +95,16 @@ CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
90# 95#
91# IXP4xx Platforms 96# IXP4xx Platforms
92# 97#
93# CONFIG_ARCH_AVILA is not set 98CONFIG_ARCH_AVILA=y
94CONFIG_ARCH_ADI_COYOTE=y 99CONFIG_ARCH_ADI_COYOTE=y
95CONFIG_ARCH_IXDP425=y 100CONFIG_ARCH_IXDP425=y
96# CONFIG_MACH_IXDPG425 is not set 101CONFIG_MACH_IXDPG425=y
97# CONFIG_MACH_IXDP465 is not set 102CONFIG_MACH_IXDP465=y
98CONFIG_ARCH_IXCDP1100=y 103CONFIG_ARCH_IXCDP1100=y
99CONFIG_ARCH_PRPMC1100=y 104CONFIG_ARCH_PRPMC1100=y
100CONFIG_ARCH_IXDP4XX=y 105CONFIG_ARCH_IXDP4XX=y
101# CONFIG_MACH_GTWX5715 is not set 106CONFIG_CPU_IXP46X=y
107CONFIG_MACH_GTWX5715=y
102 108
103# 109#
104# IXP4xx Options 110# IXP4xx Options
@@ -114,7 +120,6 @@ CONFIG_CPU_32v5=y
114CONFIG_CPU_ABRT_EV5T=y 120CONFIG_CPU_ABRT_EV5T=y
115CONFIG_CPU_CACHE_VIVT=y 121CONFIG_CPU_CACHE_VIVT=y
116CONFIG_CPU_TLB_V4WBI=y 122CONFIG_CPU_TLB_V4WBI=y
117CONFIG_CPU_MINICACHE=y
118 123
119# 124#
120# Processor Features 125# Processor Features
@@ -127,9 +132,10 @@ CONFIG_DMABOUNCE=y
127# 132#
128# Bus support 133# Bus support
129# 134#
135CONFIG_ISA_DMA_API=y
130CONFIG_PCI=y 136CONFIG_PCI=y
131CONFIG_PCI_LEGACY_PROC=y 137CONFIG_PCI_LEGACY_PROC=y
132CONFIG_PCI_NAMES=y 138# CONFIG_PCI_DEBUG is not set
133 139
134# 140#
135# PCCARD (PCMCIA/CardBus) support 141# PCCARD (PCMCIA/CardBus) support
@@ -140,6 +146,15 @@ CONFIG_PCI_NAMES=y
140# Kernel Features 146# Kernel Features
141# 147#
142# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
149# CONFIG_NO_IDLE_HZ is not set
150# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
151CONFIG_SELECT_MEMORY_MODEL=y
152CONFIG_FLATMEM_MANUAL=y
153# CONFIG_DISCONTIGMEM_MANUAL is not set
154# CONFIG_SPARSEMEM_MANUAL is not set
155CONFIG_FLATMEM=y
156CONFIG_FLAT_NODE_MEM_MAP=y
157# CONFIG_SPARSEMEM_STATIC is not set
143CONFIG_ALIGNMENT_TRAP=y 158CONFIG_ALIGNMENT_TRAP=y
144 159
145# 160#
@@ -175,6 +190,241 @@ CONFIG_PM=y
175CONFIG_APM=y 190CONFIG_APM=y
176 191
177# 192#
193# Networking
194#
195CONFIG_NET=y
196
197#
198# Networking options
199#
200CONFIG_PACKET=m
201CONFIG_PACKET_MMAP=y
202CONFIG_UNIX=y
203CONFIG_XFRM=y
204# CONFIG_XFRM_USER is not set
205# CONFIG_NET_KEY is not set
206CONFIG_INET=y
207CONFIG_IP_MULTICAST=y
208CONFIG_IP_ADVANCED_ROUTER=y
209CONFIG_ASK_IP_FIB_HASH=y
210# CONFIG_IP_FIB_TRIE is not set
211CONFIG_IP_FIB_HASH=y
212CONFIG_IP_MULTIPLE_TABLES=y
213CONFIG_IP_ROUTE_FWMARK=y
214CONFIG_IP_ROUTE_MULTIPATH=y
215# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
216CONFIG_IP_ROUTE_VERBOSE=y
217CONFIG_IP_PNP=y
218CONFIG_IP_PNP_DHCP=y
219CONFIG_IP_PNP_BOOTP=y
220# CONFIG_IP_PNP_RARP is not set
221# CONFIG_NET_IPIP is not set
222CONFIG_NET_IPGRE=m
223CONFIG_NET_IPGRE_BROADCAST=y
224CONFIG_IP_MROUTE=y
225CONFIG_IP_PIMSM_V1=y
226CONFIG_IP_PIMSM_V2=y
227# CONFIG_ARPD is not set
228CONFIG_SYN_COOKIES=y
229# CONFIG_INET_AH is not set
230# CONFIG_INET_ESP is not set
231# CONFIG_INET_IPCOMP is not set
232CONFIG_INET_TUNNEL=m
233CONFIG_INET_DIAG=y
234CONFIG_INET_TCP_DIAG=y
235# CONFIG_TCP_CONG_ADVANCED is not set
236CONFIG_TCP_CONG_BIC=y
237
238#
239# IP: Virtual Server Configuration
240#
241CONFIG_IP_VS=m
242CONFIG_IP_VS_DEBUG=y
243CONFIG_IP_VS_TAB_BITS=12
244
245#
246# IPVS transport protocol load balancing support
247#
248# CONFIG_IP_VS_PROTO_TCP is not set
249# CONFIG_IP_VS_PROTO_UDP is not set
250# CONFIG_IP_VS_PROTO_ESP is not set
251# CONFIG_IP_VS_PROTO_AH is not set
252
253#
254# IPVS scheduler
255#
256CONFIG_IP_VS_RR=m
257CONFIG_IP_VS_WRR=m
258CONFIG_IP_VS_LC=m
259CONFIG_IP_VS_WLC=m
260CONFIG_IP_VS_LBLC=m
261CONFIG_IP_VS_LBLCR=m
262CONFIG_IP_VS_DH=m
263CONFIG_IP_VS_SH=m
264# CONFIG_IP_VS_SED is not set
265# CONFIG_IP_VS_NQ is not set
266
267#
268# IPVS application helper
269#
270# CONFIG_IPV6 is not set
271CONFIG_NETFILTER=y
272# CONFIG_NETFILTER_DEBUG is not set
273CONFIG_BRIDGE_NETFILTER=y
274# CONFIG_NETFILTER_NETLINK is not set
275
276#
277# IP: Netfilter Configuration
278#
279CONFIG_IP_NF_CONNTRACK=m
280# CONFIG_IP_NF_CT_ACCT is not set
281# CONFIG_IP_NF_CONNTRACK_MARK is not set
282# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
283# CONFIG_IP_NF_CT_PROTO_SCTP is not set
284CONFIG_IP_NF_FTP=m
285CONFIG_IP_NF_IRC=m
286# CONFIG_IP_NF_NETBIOS_NS is not set
287# CONFIG_IP_NF_TFTP is not set
288# CONFIG_IP_NF_AMANDA is not set
289CONFIG_IP_NF_QUEUE=m
290CONFIG_IP_NF_IPTABLES=m
291CONFIG_IP_NF_MATCH_LIMIT=m
292# CONFIG_IP_NF_MATCH_IPRANGE is not set
293CONFIG_IP_NF_MATCH_MAC=m
294# CONFIG_IP_NF_MATCH_PKTTYPE is not set
295CONFIG_IP_NF_MATCH_MARK=m
296CONFIG_IP_NF_MATCH_MULTIPORT=m
297CONFIG_IP_NF_MATCH_TOS=m
298# CONFIG_IP_NF_MATCH_RECENT is not set
299# CONFIG_IP_NF_MATCH_ECN is not set
300# CONFIG_IP_NF_MATCH_DSCP is not set
301CONFIG_IP_NF_MATCH_AH_ESP=m
302CONFIG_IP_NF_MATCH_LENGTH=m
303CONFIG_IP_NF_MATCH_TTL=m
304CONFIG_IP_NF_MATCH_TCPMSS=m
305# CONFIG_IP_NF_MATCH_HELPER is not set
306CONFIG_IP_NF_MATCH_STATE=m
307# CONFIG_IP_NF_MATCH_CONNTRACK is not set
308CONFIG_IP_NF_MATCH_OWNER=m
309# CONFIG_IP_NF_MATCH_PHYSDEV is not set
310# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
311# CONFIG_IP_NF_MATCH_REALM is not set
312# CONFIG_IP_NF_MATCH_SCTP is not set
313# CONFIG_IP_NF_MATCH_DCCP is not set
314# CONFIG_IP_NF_MATCH_COMMENT is not set
315# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
316# CONFIG_IP_NF_MATCH_STRING is not set
317CONFIG_IP_NF_FILTER=m
318CONFIG_IP_NF_TARGET_REJECT=m
319CONFIG_IP_NF_TARGET_LOG=m
320CONFIG_IP_NF_TARGET_ULOG=m
321CONFIG_IP_NF_TARGET_TCPMSS=m
322CONFIG_IP_NF_NAT=m
323CONFIG_IP_NF_NAT_NEEDED=y
324CONFIG_IP_NF_TARGET_MASQUERADE=m
325CONFIG_IP_NF_TARGET_REDIRECT=m
326# CONFIG_IP_NF_TARGET_NETMAP is not set
327# CONFIG_IP_NF_TARGET_SAME is not set
328CONFIG_IP_NF_NAT_SNMP_BASIC=m
329CONFIG_IP_NF_NAT_IRC=m
330CONFIG_IP_NF_NAT_FTP=m
331CONFIG_IP_NF_MANGLE=m
332CONFIG_IP_NF_TARGET_TOS=m
333# CONFIG_IP_NF_TARGET_ECN is not set
334# CONFIG_IP_NF_TARGET_DSCP is not set
335CONFIG_IP_NF_TARGET_MARK=m
336# CONFIG_IP_NF_TARGET_CLASSIFY is not set
337# CONFIG_IP_NF_TARGET_TTL is not set
338# CONFIG_IP_NF_RAW is not set
339CONFIG_IP_NF_ARPTABLES=m
340CONFIG_IP_NF_ARPFILTER=m
341# CONFIG_IP_NF_ARP_MANGLE is not set
342
343#
344# Bridge: Netfilter Configuration
345#
346# CONFIG_BRIDGE_NF_EBTABLES is not set
347
348#
349# DCCP Configuration (EXPERIMENTAL)
350#
351# CONFIG_IP_DCCP is not set
352
353#
354# SCTP Configuration (EXPERIMENTAL)
355#
356# CONFIG_IP_SCTP is not set
357CONFIG_ATM=y
358CONFIG_ATM_CLIP=y
359# CONFIG_ATM_CLIP_NO_ICMP is not set
360CONFIG_ATM_LANE=m
361CONFIG_ATM_MPOA=m
362CONFIG_ATM_BR2684=m
363# CONFIG_ATM_BR2684_IPFILTER is not set
364CONFIG_BRIDGE=m
365CONFIG_VLAN_8021Q=m
366# CONFIG_DECNET is not set
367CONFIG_LLC=m
368# CONFIG_LLC2 is not set
369CONFIG_IPX=m
370# CONFIG_IPX_INTERN is not set
371CONFIG_ATALK=m
372CONFIG_DEV_APPLETALK=y
373CONFIG_IPDDP=m
374CONFIG_IPDDP_ENCAP=y
375CONFIG_IPDDP_DECAP=y
376CONFIG_X25=m
377CONFIG_LAPB=m
378# CONFIG_NET_DIVERT is not set
379CONFIG_ECONET=m
380CONFIG_ECONET_AUNUDP=y
381CONFIG_ECONET_NATIVE=y
382CONFIG_WAN_ROUTER=m
383CONFIG_NET_SCHED=y
384CONFIG_NET_SCH_CLK_JIFFIES=y
385# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
386# CONFIG_NET_SCH_CLK_CPU is not set
387CONFIG_NET_SCH_CBQ=m
388CONFIG_NET_SCH_HTB=m
389# CONFIG_NET_SCH_HFSC is not set
390# CONFIG_NET_SCH_ATM is not set
391CONFIG_NET_SCH_PRIO=m
392CONFIG_NET_SCH_RED=m
393CONFIG_NET_SCH_SFQ=m
394CONFIG_NET_SCH_TEQL=m
395CONFIG_NET_SCH_TBF=m
396CONFIG_NET_SCH_GRED=m
397CONFIG_NET_SCH_DSMARK=m
398# CONFIG_NET_SCH_NETEM is not set
399CONFIG_NET_SCH_INGRESS=m
400CONFIG_NET_QOS=y
401CONFIG_NET_ESTIMATOR=y
402CONFIG_NET_CLS=y
403# CONFIG_NET_CLS_BASIC is not set
404CONFIG_NET_CLS_TCINDEX=m
405CONFIG_NET_CLS_ROUTE4=m
406CONFIG_NET_CLS_ROUTE=y
407CONFIG_NET_CLS_FW=m
408CONFIG_NET_CLS_U32=m
409# CONFIG_CLS_U32_PERF is not set
410# CONFIG_NET_CLS_IND is not set
411# CONFIG_CLS_U32_MARK is not set
412CONFIG_NET_CLS_RSVP=m
413CONFIG_NET_CLS_RSVP6=m
414# CONFIG_NET_EMATCH is not set
415# CONFIG_NET_CLS_ACT is not set
416CONFIG_NET_CLS_POLICE=y
417
418#
419# Network testing
420#
421CONFIG_NET_PKTGEN=m
422# CONFIG_HAMRADIO is not set
423# CONFIG_IRDA is not set
424# CONFIG_BT is not set
425# CONFIG_IEEE80211 is not set
426
427#
178# Device Drivers 428# Device Drivers
179# 429#
180 430
@@ -244,6 +494,7 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y
244CONFIG_MTD_IXP4XX=y 494CONFIG_MTD_IXP4XX=y
245# CONFIG_MTD_EDB7312 is not set 495# CONFIG_MTD_EDB7312 is not set
246# CONFIG_MTD_PCI is not set 496# CONFIG_MTD_PCI is not set
497# CONFIG_MTD_PLATRAM is not set
247 498
248# 499#
249# Self-contained MTD device drivers 500# Self-contained MTD device drivers
@@ -283,7 +534,6 @@ CONFIG_MTD_NAND_IDS=m
283# 534#
284# Block devices 535# Block devices
285# 536#
286# CONFIG_BLK_DEV_FD is not set
287# CONFIG_BLK_CPQ_DA is not set 537# CONFIG_BLK_CPQ_DA is not set
288# CONFIG_BLK_CPQ_CISS_DA is not set 538# CONFIG_BLK_CPQ_CISS_DA is not set
289# CONFIG_BLK_DEV_DAC960 is not set 539# CONFIG_BLK_DEV_DAC960 is not set
@@ -297,7 +547,6 @@ CONFIG_BLK_DEV_RAM=y
297CONFIG_BLK_DEV_RAM_COUNT=16 547CONFIG_BLK_DEV_RAM_COUNT=16
298CONFIG_BLK_DEV_RAM_SIZE=8192 548CONFIG_BLK_DEV_RAM_SIZE=8192
299CONFIG_BLK_DEV_INITRD=y 549CONFIG_BLK_DEV_INITRD=y
300CONFIG_INITRAMFS_SOURCE=""
301# CONFIG_CDROM_PKTCDVD is not set 550# CONFIG_CDROM_PKTCDVD is not set
302 551
303# 552#
@@ -351,6 +600,7 @@ CONFIG_BLK_DEV_CMD64X=y
351CONFIG_BLK_DEV_HPT366=y 600CONFIG_BLK_DEV_HPT366=y
352# CONFIG_BLK_DEV_SC1200 is not set 601# CONFIG_BLK_DEV_SC1200 is not set
353# CONFIG_BLK_DEV_PIIX is not set 602# CONFIG_BLK_DEV_PIIX is not set
603# CONFIG_BLK_DEV_IT821X is not set
354# CONFIG_BLK_DEV_NS87415 is not set 604# CONFIG_BLK_DEV_NS87415 is not set
355# CONFIG_BLK_DEV_PDC202XX_OLD is not set 605# CONFIG_BLK_DEV_PDC202XX_OLD is not set
356CONFIG_BLK_DEV_PDC202XX_NEW=y 606CONFIG_BLK_DEV_PDC202XX_NEW=y
@@ -369,6 +619,7 @@ CONFIG_BLK_DEV_IDEDMA=y
369# 619#
370# SCSI device support 620# SCSI device support
371# 621#
622# CONFIG_RAID_ATTRS is not set
372# CONFIG_SCSI is not set 623# CONFIG_SCSI is not set
373 624
374# 625#
@@ -379,6 +630,7 @@ CONFIG_BLK_DEV_IDEDMA=y
379# 630#
380# Fusion MPT device support 631# Fusion MPT device support
381# 632#
633# CONFIG_FUSION is not set
382 634
383# 635#
384# IEEE 1394 (FireWire) support 636# IEEE 1394 (FireWire) support
@@ -391,235 +643,13 @@ CONFIG_BLK_DEV_IDEDMA=y
391# CONFIG_I2O is not set 643# CONFIG_I2O is not set
392 644
393# 645#
394# Networking support 646# Network device support
395#
396CONFIG_NET=y
397
398#
399# Networking options
400#
401CONFIG_PACKET=m
402CONFIG_PACKET_MMAP=y
403CONFIG_NETLINK_DEV=m
404CONFIG_UNIX=y
405# CONFIG_NET_KEY is not set
406CONFIG_INET=y
407CONFIG_IP_MULTICAST=y
408CONFIG_IP_ADVANCED_ROUTER=y
409CONFIG_IP_MULTIPLE_TABLES=y
410CONFIG_IP_ROUTE_FWMARK=y
411CONFIG_IP_ROUTE_MULTIPATH=y
412# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
413CONFIG_IP_ROUTE_VERBOSE=y
414CONFIG_IP_PNP=y
415CONFIG_IP_PNP_DHCP=y
416CONFIG_IP_PNP_BOOTP=y
417# CONFIG_IP_PNP_RARP is not set
418# CONFIG_NET_IPIP is not set
419CONFIG_NET_IPGRE=m
420CONFIG_NET_IPGRE_BROADCAST=y
421CONFIG_IP_MROUTE=y
422CONFIG_IP_PIMSM_V1=y
423CONFIG_IP_PIMSM_V2=y
424# CONFIG_ARPD is not set
425CONFIG_SYN_COOKIES=y
426# CONFIG_INET_AH is not set
427# CONFIG_INET_ESP is not set
428# CONFIG_INET_IPCOMP is not set
429CONFIG_INET_TUNNEL=m
430# CONFIG_IP_TCPDIAG is not set
431# CONFIG_IP_TCPDIAG_IPV6 is not set
432
433#
434# IP: Virtual Server Configuration
435#
436CONFIG_IP_VS=m
437CONFIG_IP_VS_DEBUG=y
438CONFIG_IP_VS_TAB_BITS=12
439
440#
441# IPVS transport protocol load balancing support
442#
443# CONFIG_IP_VS_PROTO_TCP is not set
444# CONFIG_IP_VS_PROTO_UDP is not set
445# CONFIG_IP_VS_PROTO_ESP is not set
446# CONFIG_IP_VS_PROTO_AH is not set
447
448#
449# IPVS scheduler
450#
451CONFIG_IP_VS_RR=m
452CONFIG_IP_VS_WRR=m
453CONFIG_IP_VS_LC=m
454CONFIG_IP_VS_WLC=m
455CONFIG_IP_VS_LBLC=m
456CONFIG_IP_VS_LBLCR=m
457CONFIG_IP_VS_DH=m
458CONFIG_IP_VS_SH=m
459# CONFIG_IP_VS_SED is not set
460# CONFIG_IP_VS_NQ is not set
461
462#
463# IPVS application helper
464#
465# CONFIG_IPV6 is not set
466CONFIG_NETFILTER=y
467# CONFIG_NETFILTER_DEBUG is not set
468CONFIG_BRIDGE_NETFILTER=y
469
470#
471# IP: Netfilter Configuration
472# 647#
473CONFIG_IP_NF_CONNTRACK=m
474# CONFIG_IP_NF_CT_ACCT is not set
475# CONFIG_IP_NF_CONNTRACK_MARK is not set
476# CONFIG_IP_NF_CT_PROTO_SCTP is not set
477CONFIG_IP_NF_FTP=m
478CONFIG_IP_NF_IRC=m
479# CONFIG_IP_NF_TFTP is not set
480# CONFIG_IP_NF_AMANDA is not set
481CONFIG_IP_NF_QUEUE=m
482CONFIG_IP_NF_IPTABLES=m
483CONFIG_IP_NF_MATCH_LIMIT=m
484# CONFIG_IP_NF_MATCH_IPRANGE is not set
485CONFIG_IP_NF_MATCH_MAC=m
486# CONFIG_IP_NF_MATCH_PKTTYPE is not set
487CONFIG_IP_NF_MATCH_MARK=m
488CONFIG_IP_NF_MATCH_MULTIPORT=m
489CONFIG_IP_NF_MATCH_TOS=m
490# CONFIG_IP_NF_MATCH_RECENT is not set
491# CONFIG_IP_NF_MATCH_ECN is not set
492# CONFIG_IP_NF_MATCH_DSCP is not set
493CONFIG_IP_NF_MATCH_AH_ESP=m
494CONFIG_IP_NF_MATCH_LENGTH=m
495CONFIG_IP_NF_MATCH_TTL=m
496CONFIG_IP_NF_MATCH_TCPMSS=m
497# CONFIG_IP_NF_MATCH_HELPER is not set
498CONFIG_IP_NF_MATCH_STATE=m
499# CONFIG_IP_NF_MATCH_CONNTRACK is not set
500CONFIG_IP_NF_MATCH_OWNER=m
501# CONFIG_IP_NF_MATCH_PHYSDEV is not set
502# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
503# CONFIG_IP_NF_MATCH_REALM is not set
504# CONFIG_IP_NF_MATCH_SCTP is not set
505# CONFIG_IP_NF_MATCH_COMMENT is not set
506# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
507CONFIG_IP_NF_FILTER=m
508CONFIG_IP_NF_TARGET_REJECT=m
509CONFIG_IP_NF_TARGET_LOG=m
510CONFIG_IP_NF_TARGET_ULOG=m
511CONFIG_IP_NF_TARGET_TCPMSS=m
512CONFIG_IP_NF_NAT=m
513CONFIG_IP_NF_NAT_NEEDED=y
514CONFIG_IP_NF_TARGET_MASQUERADE=m
515CONFIG_IP_NF_TARGET_REDIRECT=m
516# CONFIG_IP_NF_TARGET_NETMAP is not set
517# CONFIG_IP_NF_TARGET_SAME is not set
518CONFIG_IP_NF_NAT_SNMP_BASIC=m
519CONFIG_IP_NF_NAT_IRC=m
520CONFIG_IP_NF_NAT_FTP=m
521CONFIG_IP_NF_MANGLE=m
522CONFIG_IP_NF_TARGET_TOS=m
523# CONFIG_IP_NF_TARGET_ECN is not set
524# CONFIG_IP_NF_TARGET_DSCP is not set
525CONFIG_IP_NF_TARGET_MARK=m
526# CONFIG_IP_NF_TARGET_CLASSIFY is not set
527# CONFIG_IP_NF_RAW is not set
528CONFIG_IP_NF_ARPTABLES=m
529CONFIG_IP_NF_ARPFILTER=m
530# CONFIG_IP_NF_ARP_MANGLE is not set
531
532#
533# Bridge: Netfilter Configuration
534#
535# CONFIG_BRIDGE_NF_EBTABLES is not set
536CONFIG_XFRM=y
537# CONFIG_XFRM_USER is not set
538
539#
540# SCTP Configuration (EXPERIMENTAL)
541#
542# CONFIG_IP_SCTP is not set
543CONFIG_ATM=y
544CONFIG_ATM_CLIP=y
545# CONFIG_ATM_CLIP_NO_ICMP is not set
546CONFIG_ATM_LANE=m
547CONFIG_ATM_MPOA=m
548CONFIG_ATM_BR2684=m
549# CONFIG_ATM_BR2684_IPFILTER is not set
550CONFIG_BRIDGE=m
551CONFIG_VLAN_8021Q=m
552# CONFIG_DECNET is not set
553CONFIG_LLC=m
554# CONFIG_LLC2 is not set
555CONFIG_IPX=m
556# CONFIG_IPX_INTERN is not set
557CONFIG_ATALK=m
558CONFIG_DEV_APPLETALK=y
559CONFIG_IPDDP=m
560CONFIG_IPDDP_ENCAP=y
561CONFIG_IPDDP_DECAP=y
562CONFIG_X25=m
563CONFIG_LAPB=m
564# CONFIG_NET_DIVERT is not set
565CONFIG_ECONET=m
566CONFIG_ECONET_AUNUDP=y
567CONFIG_ECONET_NATIVE=y
568CONFIG_WAN_ROUTER=m
569
570#
571# QoS and/or fair queueing
572#
573CONFIG_NET_SCHED=y
574CONFIG_NET_SCH_CLK_JIFFIES=y
575# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
576# CONFIG_NET_SCH_CLK_CPU is not set
577CONFIG_NET_SCH_CBQ=m
578CONFIG_NET_SCH_HTB=m
579# CONFIG_NET_SCH_HFSC is not set
580# CONFIG_NET_SCH_ATM is not set
581CONFIG_NET_SCH_PRIO=m
582CONFIG_NET_SCH_RED=m
583CONFIG_NET_SCH_SFQ=m
584CONFIG_NET_SCH_TEQL=m
585CONFIG_NET_SCH_TBF=m
586CONFIG_NET_SCH_GRED=m
587CONFIG_NET_SCH_DSMARK=m
588# CONFIG_NET_SCH_NETEM is not set
589CONFIG_NET_SCH_INGRESS=m
590CONFIG_NET_QOS=y
591CONFIG_NET_ESTIMATOR=y
592CONFIG_NET_CLS=y
593# CONFIG_NET_CLS_BASIC is not set
594CONFIG_NET_CLS_TCINDEX=m
595CONFIG_NET_CLS_ROUTE4=m
596CONFIG_NET_CLS_ROUTE=y
597CONFIG_NET_CLS_FW=m
598CONFIG_NET_CLS_U32=m
599# CONFIG_CLS_U32_PERF is not set
600# CONFIG_NET_CLS_IND is not set
601# CONFIG_CLS_U32_MARK is not set
602CONFIG_NET_CLS_RSVP=m
603CONFIG_NET_CLS_RSVP6=m
604# CONFIG_NET_EMATCH is not set
605# CONFIG_NET_CLS_ACT is not set
606CONFIG_NET_CLS_POLICE=y
607
608#
609# Network testing
610#
611CONFIG_NET_PKTGEN=m
612# CONFIG_NETPOLL is not set
613# CONFIG_NET_POLL_CONTROLLER is not set
614# CONFIG_HAMRADIO is not set
615# CONFIG_IRDA is not set
616# CONFIG_BT is not set
617CONFIG_NETDEVICES=y 648CONFIG_NETDEVICES=y
618CONFIG_DUMMY=y 649CONFIG_DUMMY=y
619# CONFIG_BONDING is not set 650# CONFIG_BONDING is not set
620# CONFIG_EQUALIZER is not set 651# CONFIG_EQUALIZER is not set
621# CONFIG_TUN is not set 652# CONFIG_TUN is not set
622# CONFIG_ETHERTAP is not set
623 653
624# 654#
625# ARCnet devices 655# ARCnet devices
@@ -627,6 +657,11 @@ CONFIG_DUMMY=y
627# CONFIG_ARCNET is not set 657# CONFIG_ARCNET is not set
628 658
629# 659#
660# PHY device support
661#
662# CONFIG_PHYLIB is not set
663
664#
630# Ethernet (10 or 100Mbit) 665# Ethernet (10 or 100Mbit)
631# 666#
632CONFIG_NET_ETHERNET=y 667CONFIG_NET_ETHERNET=y
@@ -635,6 +670,7 @@ CONFIG_MII=y
635# CONFIG_SUNGEM is not set 670# CONFIG_SUNGEM is not set
636# CONFIG_NET_VENDOR_3COM is not set 671# CONFIG_NET_VENDOR_3COM is not set
637# CONFIG_SMC91X is not set 672# CONFIG_SMC91X is not set
673# CONFIG_DM9000 is not set
638 674
639# 675#
640# Tulip family network device support 676# Tulip family network device support
@@ -671,13 +707,17 @@ CONFIG_EEPRO100=y
671# CONFIG_HAMACHI is not set 707# CONFIG_HAMACHI is not set
672# CONFIG_YELLOWFIN is not set 708# CONFIG_YELLOWFIN is not set
673# CONFIG_R8169 is not set 709# CONFIG_R8169 is not set
710# CONFIG_SIS190 is not set
711# CONFIG_SKGE is not set
674# CONFIG_SK98LIN is not set 712# CONFIG_SK98LIN is not set
675# CONFIG_VIA_VELOCITY is not set 713# CONFIG_VIA_VELOCITY is not set
676# CONFIG_TIGON3 is not set 714# CONFIG_TIGON3 is not set
715# CONFIG_BNX2 is not set
677 716
678# 717#
679# Ethernet (10000 Mbit) 718# Ethernet (10000 Mbit)
680# 719#
720# CONFIG_CHELSIO_T1 is not set
681# CONFIG_IXGB is not set 721# CONFIG_IXGB is not set
682# CONFIG_S2IO is not set 722# CONFIG_S2IO is not set
683 723
@@ -702,6 +742,7 @@ CONFIG_NET_RADIO=y
702CONFIG_HERMES=y 742CONFIG_HERMES=y
703# CONFIG_PLX_HERMES is not set 743# CONFIG_PLX_HERMES is not set
704# CONFIG_TMD_HERMES is not set 744# CONFIG_TMD_HERMES is not set
745# CONFIG_NORTEL_HERMES is not set
705CONFIG_PCI_HERMES=y 746CONFIG_PCI_HERMES=y
706# CONFIG_ATMEL is not set 747# CONFIG_ATMEL is not set
707 748
@@ -709,6 +750,7 @@ CONFIG_PCI_HERMES=y
709# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support 750# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
710# 751#
711# CONFIG_PRISM54 is not set 752# CONFIG_PRISM54 is not set
753# CONFIG_HOSTAP is not set
712CONFIG_NET_WIRELESS=y 754CONFIG_NET_WIRELESS=y
713 755
714# 756#
@@ -758,6 +800,8 @@ CONFIG_ATM_TCP=m
758# CONFIG_SLIP is not set 800# CONFIG_SLIP is not set
759# CONFIG_SHAPER is not set 801# CONFIG_SHAPER is not set
760# CONFIG_NETCONSOLE is not set 802# CONFIG_NETCONSOLE is not set
803# CONFIG_NETPOLL is not set
804# CONFIG_NET_POLL_CONTROLLER is not set
761 805
762# 806#
763# ISDN subsystem 807# ISDN subsystem
@@ -795,7 +839,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
795# 839#
796# CONFIG_SERIO is not set 840# CONFIG_SERIO is not set
797# CONFIG_GAMEPORT is not set 841# CONFIG_GAMEPORT is not set
798CONFIG_SOUND_GAMEPORT=y
799 842
800# 843#
801# Character devices 844# Character devices
@@ -816,6 +859,7 @@ CONFIG_SERIAL_8250_NR_UARTS=2
816# 859#
817CONFIG_SERIAL_CORE=y 860CONFIG_SERIAL_CORE=y
818CONFIG_SERIAL_CORE_CONSOLE=y 861CONFIG_SERIAL_CORE_CONSOLE=y
862# CONFIG_SERIAL_JSM is not set
819CONFIG_UNIX98_PTYS=y 863CONFIG_UNIX98_PTYS=y
820CONFIG_LEGACY_PTYS=y 864CONFIG_LEGACY_PTYS=y
821CONFIG_LEGACY_PTY_COUNT=256 865CONFIG_LEGACY_PTY_COUNT=256
@@ -882,12 +926,11 @@ CONFIG_I2C_ALGOBIT=y
882# CONFIG_I2C_AMD8111 is not set 926# CONFIG_I2C_AMD8111 is not set
883# CONFIG_I2C_I801 is not set 927# CONFIG_I2C_I801 is not set
884# CONFIG_I2C_I810 is not set 928# CONFIG_I2C_I810 is not set
929# CONFIG_I2C_PIIX4 is not set
885# CONFIG_I2C_IOP3XX is not set 930# CONFIG_I2C_IOP3XX is not set
886# CONFIG_I2C_ISA is not set
887CONFIG_I2C_IXP4XX=y 931CONFIG_I2C_IXP4XX=y
888# CONFIG_I2C_NFORCE2 is not set 932# CONFIG_I2C_NFORCE2 is not set
889# CONFIG_I2C_PARPORT_LIGHT is not set 933# CONFIG_I2C_PARPORT_LIGHT is not set
890# CONFIG_I2C_PIIX4 is not set
891# CONFIG_I2C_PROSAVAGE is not set 934# CONFIG_I2C_PROSAVAGE is not set
892# CONFIG_I2C_SAVAGE4 is not set 935# CONFIG_I2C_SAVAGE4 is not set
893# CONFIG_SCx200_ACB is not set 936# CONFIG_SCx200_ACB is not set
@@ -901,14 +944,33 @@ CONFIG_I2C_IXP4XX=y
901# CONFIG_I2C_PCA_ISA is not set 944# CONFIG_I2C_PCA_ISA is not set
902 945
903# 946#
904# Hardware Sensors Chip support 947# Miscellaneous I2C Chip support
905# 948#
906CONFIG_I2C_SENSOR=y 949# CONFIG_SENSORS_DS1337 is not set
950# CONFIG_SENSORS_DS1374 is not set
951CONFIG_SENSORS_EEPROM=y
952# CONFIG_SENSORS_PCF8574 is not set
953# CONFIG_SENSORS_PCA9539 is not set
954# CONFIG_SENSORS_PCF8591 is not set
955# CONFIG_SENSORS_RTC8564 is not set
956# CONFIG_SENSORS_MAX6875 is not set
957# CONFIG_I2C_DEBUG_CORE is not set
958# CONFIG_I2C_DEBUG_ALGO is not set
959# CONFIG_I2C_DEBUG_BUS is not set
960# CONFIG_I2C_DEBUG_CHIP is not set
961
962#
963# Hardware Monitoring support
964#
965CONFIG_HWMON=y
966# CONFIG_HWMON_VID is not set
907# CONFIG_SENSORS_ADM1021 is not set 967# CONFIG_SENSORS_ADM1021 is not set
908# CONFIG_SENSORS_ADM1025 is not set 968# CONFIG_SENSORS_ADM1025 is not set
909# CONFIG_SENSORS_ADM1026 is not set 969# CONFIG_SENSORS_ADM1026 is not set
910# CONFIG_SENSORS_ADM1031 is not set 970# CONFIG_SENSORS_ADM1031 is not set
971# CONFIG_SENSORS_ADM9240 is not set
911# CONFIG_SENSORS_ASB100 is not set 972# CONFIG_SENSORS_ASB100 is not set
973# CONFIG_SENSORS_ATXP1 is not set
912# CONFIG_SENSORS_DS1621 is not set 974# CONFIG_SENSORS_DS1621 is not set
913# CONFIG_SENSORS_FSCHER is not set 975# CONFIG_SENSORS_FSCHER is not set
914# CONFIG_SENSORS_FSCPOS is not set 976# CONFIG_SENSORS_FSCPOS is not set
@@ -924,30 +986,26 @@ CONFIG_I2C_SENSOR=y
924# CONFIG_SENSORS_LM85 is not set 986# CONFIG_SENSORS_LM85 is not set
925# CONFIG_SENSORS_LM87 is not set 987# CONFIG_SENSORS_LM87 is not set
926# CONFIG_SENSORS_LM90 is not set 988# CONFIG_SENSORS_LM90 is not set
989# CONFIG_SENSORS_LM92 is not set
927# CONFIG_SENSORS_MAX1619 is not set 990# CONFIG_SENSORS_MAX1619 is not set
928# CONFIG_SENSORS_PC87360 is not set 991# CONFIG_SENSORS_PC87360 is not set
929# CONFIG_SENSORS_SMSC47B397 is not set
930# CONFIG_SENSORS_SIS5595 is not set 992# CONFIG_SENSORS_SIS5595 is not set
931# CONFIG_SENSORS_SMSC47M1 is not set 993# CONFIG_SENSORS_SMSC47M1 is not set
994# CONFIG_SENSORS_SMSC47B397 is not set
932# CONFIG_SENSORS_VIA686A is not set 995# CONFIG_SENSORS_VIA686A is not set
933# CONFIG_SENSORS_W83781D is not set 996# CONFIG_SENSORS_W83781D is not set
997# CONFIG_SENSORS_W83792D is not set
934# CONFIG_SENSORS_W83L785TS is not set 998# CONFIG_SENSORS_W83L785TS is not set
935# CONFIG_SENSORS_W83627HF is not set 999# CONFIG_SENSORS_W83627HF is not set
1000# CONFIG_SENSORS_W83627EHF is not set
1001# CONFIG_HWMON_DEBUG_CHIP is not set
936 1002
937# 1003#
938# Other I2C Chip support 1004# Misc devices
939# 1005#
940CONFIG_SENSORS_EEPROM=y
941# CONFIG_SENSORS_PCF8574 is not set
942# CONFIG_SENSORS_PCF8591 is not set
943# CONFIG_SENSORS_RTC8564 is not set
944# CONFIG_I2C_DEBUG_CORE is not set
945# CONFIG_I2C_DEBUG_ALGO is not set
946# CONFIG_I2C_DEBUG_BUS is not set
947# CONFIG_I2C_DEBUG_CHIP is not set
948 1006
949# 1007#
950# Misc devices 1008# Multimedia Capabilities Port drivers
951# 1009#
952 1010
953# 1011#
@@ -994,6 +1052,7 @@ CONFIG_EXT2_FS=y
994CONFIG_EXT2_FS_XATTR=y 1052CONFIG_EXT2_FS_XATTR=y
995CONFIG_EXT2_FS_POSIX_ACL=y 1053CONFIG_EXT2_FS_POSIX_ACL=y
996# CONFIG_EXT2_FS_SECURITY is not set 1054# CONFIG_EXT2_FS_SECURITY is not set
1055# CONFIG_EXT2_FS_XIP is not set
997CONFIG_EXT3_FS=y 1056CONFIG_EXT3_FS=y
998CONFIG_EXT3_FS_XATTR=y 1057CONFIG_EXT3_FS_XATTR=y
999CONFIG_EXT3_FS_POSIX_ACL=y 1058CONFIG_EXT3_FS_POSIX_ACL=y
@@ -1004,17 +1063,15 @@ CONFIG_FS_MBCACHE=y
1004# CONFIG_REISERFS_FS is not set 1063# CONFIG_REISERFS_FS is not set
1005# CONFIG_JFS_FS is not set 1064# CONFIG_JFS_FS is not set
1006CONFIG_FS_POSIX_ACL=y 1065CONFIG_FS_POSIX_ACL=y
1007
1008#
1009# XFS support
1010#
1011# CONFIG_XFS_FS is not set 1066# CONFIG_XFS_FS is not set
1012# CONFIG_MINIX_FS is not set 1067# CONFIG_MINIX_FS is not set
1013# CONFIG_ROMFS_FS is not set 1068# CONFIG_ROMFS_FS is not set
1069CONFIG_INOTIFY=y
1014# CONFIG_QUOTA is not set 1070# CONFIG_QUOTA is not set
1015CONFIG_DNOTIFY=y 1071CONFIG_DNOTIFY=y
1016# CONFIG_AUTOFS_FS is not set 1072# CONFIG_AUTOFS_FS is not set
1017# CONFIG_AUTOFS4_FS is not set 1073# CONFIG_AUTOFS4_FS is not set
1074# CONFIG_FUSE_FS is not set
1018 1075
1019# 1076#
1020# CD-ROM/DVD Filesystems 1077# CD-ROM/DVD Filesystems
@@ -1034,12 +1091,10 @@ CONFIG_DNOTIFY=y
1034# 1091#
1035CONFIG_PROC_FS=y 1092CONFIG_PROC_FS=y
1036CONFIG_SYSFS=y 1093CONFIG_SYSFS=y
1037# CONFIG_DEVFS_FS is not set
1038# CONFIG_DEVPTS_FS_XATTR is not set
1039CONFIG_TMPFS=y 1094CONFIG_TMPFS=y
1040# CONFIG_TMPFS_XATTR is not set
1041# CONFIG_HUGETLB_PAGE is not set 1095# CONFIG_HUGETLB_PAGE is not set
1042CONFIG_RAMFS=y 1096CONFIG_RAMFS=y
1097# CONFIG_RELAYFS_FS is not set
1043 1098
1044# 1099#
1045# Miscellaneous filesystems 1100# Miscellaneous filesystems
@@ -1054,8 +1109,7 @@ CONFIG_RAMFS=y
1054# CONFIG_JFFS_FS is not set 1109# CONFIG_JFFS_FS is not set
1055CONFIG_JFFS2_FS=y 1110CONFIG_JFFS2_FS=y
1056CONFIG_JFFS2_FS_DEBUG=0 1111CONFIG_JFFS2_FS_DEBUG=0
1057# CONFIG_JFFS2_FS_NAND is not set 1112CONFIG_JFFS2_FS_WRITEBUFFER=y
1058# CONFIG_JFFS2_FS_NOR_ECC is not set
1059# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 1113# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1060CONFIG_JFFS2_ZLIB=y 1114CONFIG_JFFS2_ZLIB=y
1061CONFIG_JFFS2_RTIME=y 1115CONFIG_JFFS2_RTIME=y
@@ -1072,12 +1126,14 @@ CONFIG_JFFS2_RTIME=y
1072# 1126#
1073CONFIG_NFS_FS=y 1127CONFIG_NFS_FS=y
1074CONFIG_NFS_V3=y 1128CONFIG_NFS_V3=y
1129# CONFIG_NFS_V3_ACL is not set
1075# CONFIG_NFS_V4 is not set 1130# CONFIG_NFS_V4 is not set
1076# CONFIG_NFS_DIRECTIO is not set 1131# CONFIG_NFS_DIRECTIO is not set
1077# CONFIG_NFSD is not set 1132# CONFIG_NFSD is not set
1078CONFIG_ROOT_NFS=y 1133CONFIG_ROOT_NFS=y
1079CONFIG_LOCKD=y 1134CONFIG_LOCKD=y
1080CONFIG_LOCKD_V4=y 1135CONFIG_LOCKD_V4=y
1136CONFIG_NFS_COMMON=y
1081CONFIG_SUNRPC=y 1137CONFIG_SUNRPC=y
1082# CONFIG_RPCSEC_GSS_KRB5 is not set 1138# CONFIG_RPCSEC_GSS_KRB5 is not set
1083# CONFIG_RPCSEC_GSS_SPKM3 is not set 1139# CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -1086,6 +1142,7 @@ CONFIG_SUNRPC=y
1086# CONFIG_NCP_FS is not set 1142# CONFIG_NCP_FS is not set
1087# CONFIG_CODA_FS is not set 1143# CONFIG_CODA_FS is not set
1088# CONFIG_AFS_FS is not set 1144# CONFIG_AFS_FS is not set
1145# CONFIG_9P_FS is not set
1089 1146
1090# 1147#
1091# Partition Types 1148# Partition Types
@@ -1124,6 +1181,7 @@ CONFIG_MSDOS_PARTITION=y
1124CONFIG_DEBUG_KERNEL=y 1181CONFIG_DEBUG_KERNEL=y
1125CONFIG_MAGIC_SYSRQ=y 1182CONFIG_MAGIC_SYSRQ=y
1126CONFIG_LOG_BUF_SHIFT=14 1183CONFIG_LOG_BUF_SHIFT=14
1184CONFIG_DETECT_SOFTLOCKUP=y
1127# CONFIG_SCHEDSTATS is not set 1185# CONFIG_SCHEDSTATS is not set
1128# CONFIG_DEBUG_SLAB is not set 1186# CONFIG_DEBUG_SLAB is not set
1129# CONFIG_DEBUG_SPINLOCK is not set 1187# CONFIG_DEBUG_SPINLOCK is not set
@@ -1158,6 +1216,7 @@ CONFIG_DEBUG_LL=y
1158# Library routines 1216# Library routines
1159# 1217#
1160# CONFIG_CRC_CCITT is not set 1218# CONFIG_CRC_CCITT is not set
1219# CONFIG_CRC16 is not set
1161CONFIG_CRC32=y 1220CONFIG_CRC32=y
1162# CONFIG_LIBCRC32C is not set 1221# CONFIG_LIBCRC32C is not set
1163CONFIG_ZLIB_INFLATE=y 1222CONFIG_ZLIB_INFLATE=y
diff --git a/arch/arm/configs/poodle_defconfig b/arch/arm/configs/poodle_defconfig
new file mode 100644
index 000000000000..72822907759f
--- /dev/null
+++ b/arch/arm/configs/poodle_defconfig
@@ -0,0 +1,1015 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc3
4# Sun Oct 9 17:04:29 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
20
21#
22# General setup
23#
24CONFIG_LOCALVERSION=""
25CONFIG_LOCALVERSION_AUTO=y
26CONFIG_SWAP=y
27CONFIG_SYSVIPC=y
28# CONFIG_POSIX_MQUEUE is not set
29CONFIG_BSD_PROCESS_ACCT=y
30# CONFIG_BSD_PROCESS_ACCT_V3 is not set
31CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set
33CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y
35# CONFIG_IKCONFIG is not set
36CONFIG_INITRAMFS_SOURCE=""
37CONFIG_EMBEDDED=y
38CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_ALL is not set
40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_BASE_FULL=y
44CONFIG_FUTEX=y
45CONFIG_EPOLL=y
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SHMEM=y
48CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
54
55#
56# Loadable module support
57#
58CONFIG_MODULES=y
59CONFIG_MODULE_UNLOAD=y
60CONFIG_MODULE_FORCE_UNLOAD=y
61CONFIG_OBSOLETE_MODPARM=y
62CONFIG_MODVERSIONS=y
63# CONFIG_MODULE_SRCVERSION_ALL is not set
64CONFIG_KMOD=y
65
66#
67# System Type
68#
69# CONFIG_ARCH_CLPS7500 is not set
70# CONFIG_ARCH_CLPS711X is not set
71# CONFIG_ARCH_CO285 is not set
72# CONFIG_ARCH_EBSA110 is not set
73# CONFIG_ARCH_CAMELOT is not set
74# CONFIG_ARCH_FOOTBRIDGE is not set
75# CONFIG_ARCH_INTEGRATOR is not set
76# CONFIG_ARCH_IOP3XX is not set
77# CONFIG_ARCH_IXP4XX is not set
78# CONFIG_ARCH_IXP2000 is not set
79# CONFIG_ARCH_L7200 is not set
80CONFIG_ARCH_PXA=y
81# CONFIG_ARCH_RPC is not set
82# CONFIG_ARCH_SA1100 is not set
83# CONFIG_ARCH_S3C2410 is not set
84# CONFIG_ARCH_SHARK is not set
85# CONFIG_ARCH_LH7A40X is not set
86# CONFIG_ARCH_OMAP is not set
87# CONFIG_ARCH_VERSATILE is not set
88# CONFIG_ARCH_IMX is not set
89# CONFIG_ARCH_H720X is not set
90# CONFIG_ARCH_AAEC2000 is not set
91
92#
93# Intel PXA2xx Implementations
94#
95# CONFIG_ARCH_LUBBOCK is not set
96# CONFIG_MACH_MAINSTONE is not set
97# CONFIG_ARCH_PXA_IDP is not set
98CONFIG_PXA_SHARPSL=y
99CONFIG_PXA_SHARPSL_25x=y
100# CONFIG_PXA_SHARPSL_27x is not set
101CONFIG_MACH_POODLE=y
102# CONFIG_MACH_CORGI is not set
103# CONFIG_MACH_SHEPHERD is not set
104# CONFIG_MACH_HUSKY is not set
105CONFIG_PXA25x=y
106
107#
108# Processor Type
109#
110CONFIG_CPU_32=y
111CONFIG_CPU_XSCALE=y
112CONFIG_CPU_32v5=y
113CONFIG_CPU_ABRT_EV5T=y
114CONFIG_CPU_CACHE_VIVT=y
115CONFIG_CPU_TLB_V4WBI=y
116
117#
118# Processor Features
119#
120CONFIG_ARM_THUMB=y
121CONFIG_XSCALE_PMU=y
122CONFIG_SHARP_LOCOMO=y
123CONFIG_SHARP_PARAM=y
124CONFIG_SHARP_SCOOP=y
125
126#
127# Bus support
128#
129CONFIG_ISA_DMA_API=y
130
131#
132# PCCARD (PCMCIA/CardBus) support
133#
134CONFIG_PCCARD=y
135# CONFIG_PCMCIA_DEBUG is not set
136CONFIG_PCMCIA=y
137CONFIG_PCMCIA_LOAD_CIS=y
138CONFIG_PCMCIA_IOCTL=y
139
140#
141# PC-card bridges
142#
143CONFIG_PCMCIA_PXA2XX=y
144
145#
146# Kernel Features
147#
148CONFIG_PREEMPT=y
149# CONFIG_NO_IDLE_HZ is not set
150# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
151CONFIG_SELECT_MEMORY_MODEL=y
152CONFIG_FLATMEM_MANUAL=y
153# CONFIG_DISCONTIGMEM_MANUAL is not set
154# CONFIG_SPARSEMEM_MANUAL is not set
155CONFIG_FLATMEM=y
156CONFIG_FLAT_NODE_MEM_MAP=y
157# CONFIG_SPARSEMEM_STATIC is not set
158CONFIG_ALIGNMENT_TRAP=y
159
160#
161# Boot options
162#
163CONFIG_ZBOOT_ROM_TEXT=0x0
164CONFIG_ZBOOT_ROM_BSS=0x0
165CONFIG_CMDLINE="console=ttyS0,115200n8 console=tty1 noinitrd root=/dev/mtdblock2 rootfstype=jffs2 debug"
166# CONFIG_XIP_KERNEL is not set
167
168#
169# Floating point emulation
170#
171
172#
173# At least one emulation must be selected
174#
175CONFIG_FPE_NWFPE=y
176# CONFIG_FPE_NWFPE_XP is not set
177# CONFIG_FPE_FASTFPE is not set
178
179#
180# Userspace binary formats
181#
182CONFIG_BINFMT_ELF=y
183CONFIG_BINFMT_AOUT=m
184CONFIG_BINFMT_MISC=m
185# CONFIG_ARTHUR is not set
186
187#
188# Power management options
189#
190CONFIG_PM=y
191CONFIG_APM=y
192
193#
194# Networking
195#
196CONFIG_NET=y
197
198#
199# Networking options
200#
201CONFIG_PACKET=y
202CONFIG_PACKET_MMAP=y
203CONFIG_UNIX=y
204# CONFIG_NET_KEY is not set
205CONFIG_INET=y
206# CONFIG_IP_MULTICAST is not set
207# CONFIG_IP_ADVANCED_ROUTER is not set
208CONFIG_IP_FIB_HASH=y
209# CONFIG_IP_PNP is not set
210# CONFIG_NET_IPIP is not set
211# CONFIG_NET_IPGRE is not set
212# CONFIG_ARPD is not set
213CONFIG_SYN_COOKIES=y
214# CONFIG_INET_AH is not set
215# CONFIG_INET_ESP is not set
216# CONFIG_INET_IPCOMP is not set
217# CONFIG_INET_TUNNEL is not set
218CONFIG_INET_DIAG=y
219CONFIG_INET_TCP_DIAG=y
220# CONFIG_TCP_CONG_ADVANCED is not set
221CONFIG_TCP_CONG_BIC=y
222# CONFIG_IPV6 is not set
223# CONFIG_NETFILTER is not set
224
225#
226# DCCP Configuration (EXPERIMENTAL)
227#
228# CONFIG_IP_DCCP is not set
229
230#
231# SCTP Configuration (EXPERIMENTAL)
232#
233# CONFIG_IP_SCTP is not set
234# CONFIG_ATM is not set
235# CONFIG_BRIDGE is not set
236# CONFIG_VLAN_8021Q is not set
237# CONFIG_DECNET is not set
238# CONFIG_LLC2 is not set
239# CONFIG_IPX is not set
240# CONFIG_ATALK is not set
241# CONFIG_X25 is not set
242# CONFIG_LAPB is not set
243# CONFIG_NET_DIVERT is not set
244# CONFIG_ECONET is not set
245# CONFIG_WAN_ROUTER is not set
246# CONFIG_NET_SCHED is not set
247# CONFIG_NET_CLS_ROUTE is not set
248
249#
250# Network testing
251#
252# CONFIG_NET_PKTGEN is not set
253# CONFIG_HAMRADIO is not set
254# CONFIG_IRDA is not set
255# CONFIG_BT is not set
256# CONFIG_IEEE80211 is not set
257
258#
259# Device Drivers
260#
261
262#
263# Generic Driver Options
264#
265CONFIG_STANDALONE=y
266CONFIG_PREVENT_FIRMWARE_BUILD=y
267CONFIG_FW_LOADER=y
268# CONFIG_DEBUG_DRIVER is not set
269
270#
271# Memory Technology Devices (MTD)
272#
273CONFIG_MTD=y
274# CONFIG_MTD_DEBUG is not set
275# CONFIG_MTD_CONCAT is not set
276CONFIG_MTD_PARTITIONS=y
277# CONFIG_MTD_REDBOOT_PARTS is not set
278# CONFIG_MTD_CMDLINE_PARTS is not set
279# CONFIG_MTD_AFS_PARTS is not set
280
281#
282# User Modules And Translation Layers
283#
284CONFIG_MTD_CHAR=y
285CONFIG_MTD_BLOCK=y
286# CONFIG_FTL is not set
287# CONFIG_NFTL is not set
288# CONFIG_INFTL is not set
289
290#
291# RAM/ROM/Flash chip drivers
292#
293# CONFIG_MTD_CFI is not set
294# CONFIG_MTD_JEDECPROBE is not set
295CONFIG_MTD_MAP_BANK_WIDTH_1=y
296CONFIG_MTD_MAP_BANK_WIDTH_2=y
297CONFIG_MTD_MAP_BANK_WIDTH_4=y
298# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
299# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
300# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
301CONFIG_MTD_CFI_I1=y
302CONFIG_MTD_CFI_I2=y
303# CONFIG_MTD_CFI_I4 is not set
304# CONFIG_MTD_CFI_I8 is not set
305# CONFIG_MTD_RAM is not set
306# CONFIG_MTD_ROM is not set
307# CONFIG_MTD_ABSENT is not set
308
309#
310# Mapping drivers for chip access
311#
312CONFIG_MTD_COMPLEX_MAPPINGS=y
313CONFIG_MTD_SHARP_SL=y
314# CONFIG_MTD_PLATRAM is not set
315
316#
317# Self-contained MTD device drivers
318#
319# CONFIG_MTD_SLRAM is not set
320# CONFIG_MTD_PHRAM is not set
321# CONFIG_MTD_MTDRAM is not set
322# CONFIG_MTD_BLKMTD is not set
323# CONFIG_MTD_BLOCK2MTD is not set
324
325#
326# Disk-On-Chip Device Drivers
327#
328# CONFIG_MTD_DOC2000 is not set
329# CONFIG_MTD_DOC2001 is not set
330# CONFIG_MTD_DOC2001PLUS is not set
331
332#
333# NAND Flash Device Drivers
334#
335CONFIG_MTD_NAND=y
336CONFIG_MTD_NAND_VERIFY_WRITE=y
337# CONFIG_MTD_NAND_H1900 is not set
338CONFIG_MTD_NAND_IDS=y
339# CONFIG_MTD_NAND_DISKONCHIP is not set
340CONFIG_MTD_NAND_SHARPSL=y
341# CONFIG_MTD_NAND_NANDSIM is not set
342
343#
344# Parallel port support
345#
346# CONFIG_PARPORT is not set
347
348#
349# Plug and Play support
350#
351
352#
353# Block devices
354#
355# CONFIG_BLK_DEV_COW_COMMON is not set
356CONFIG_BLK_DEV_LOOP=y
357# CONFIG_BLK_DEV_CRYPTOLOOP is not set
358# CONFIG_BLK_DEV_NBD is not set
359# CONFIG_BLK_DEV_RAM is not set
360CONFIG_BLK_DEV_RAM_COUNT=16
361# CONFIG_CDROM_PKTCDVD is not set
362
363#
364# IO Schedulers
365#
366CONFIG_IOSCHED_NOOP=y
367CONFIG_IOSCHED_AS=y
368CONFIG_IOSCHED_DEADLINE=y
369CONFIG_IOSCHED_CFQ=y
370# CONFIG_ATA_OVER_ETH is not set
371
372#
373# ATA/ATAPI/MFM/RLL support
374#
375CONFIG_IDE=y
376CONFIG_BLK_DEV_IDE=y
377
378#
379# Please see Documentation/ide.txt for help/info on IDE drives
380#
381# CONFIG_BLK_DEV_IDE_SATA is not set
382CONFIG_BLK_DEV_IDEDISK=y
383# CONFIG_IDEDISK_MULTI_MODE is not set
384CONFIG_BLK_DEV_IDECS=y
385# CONFIG_BLK_DEV_IDECD is not set
386# CONFIG_BLK_DEV_IDETAPE is not set
387# CONFIG_BLK_DEV_IDEFLOPPY is not set
388# CONFIG_IDE_TASK_IOCTL is not set
389
390#
391# IDE chipset support/bugfixes
392#
393CONFIG_IDE_GENERIC=y
394# CONFIG_IDE_ARM is not set
395# CONFIG_BLK_DEV_IDEDMA is not set
396# CONFIG_IDEDMA_AUTO is not set
397# CONFIG_BLK_DEV_HD is not set
398
399#
400# SCSI device support
401#
402# CONFIG_RAID_ATTRS is not set
403# CONFIG_SCSI is not set
404
405#
406# Multi-device support (RAID and LVM)
407#
408# CONFIG_MD is not set
409
410#
411# Fusion MPT device support
412#
413# CONFIG_FUSION is not set
414
415#
416# IEEE 1394 (FireWire) support
417#
418
419#
420# I2O device support
421#
422
423#
424# Network device support
425#
426CONFIG_NETDEVICES=y
427# CONFIG_DUMMY is not set
428# CONFIG_BONDING is not set
429# CONFIG_EQUALIZER is not set
430# CONFIG_TUN is not set
431
432#
433# PHY device support
434#
435# CONFIG_PHYLIB is not set
436
437#
438# Ethernet (10 or 100Mbit)
439#
440CONFIG_NET_ETHERNET=y
441# CONFIG_MII is not set
442# CONFIG_SMC91X is not set
443# CONFIG_DM9000 is not set
444
445#
446# Ethernet (1000 Mbit)
447#
448
449#
450# Ethernet (10000 Mbit)
451#
452
453#
454# Token Ring devices
455#
456
457#
458# Wireless LAN (non-hamradio)
459#
460CONFIG_NET_RADIO=y
461
462#
463# Obsolete Wireless cards support (pre-802.11)
464#
465# CONFIG_STRIP is not set
466# CONFIG_PCMCIA_WAVELAN is not set
467# CONFIG_PCMCIA_NETWAVE is not set
468
469#
470# Wireless 802.11 Frequency Hopping cards support
471#
472# CONFIG_PCMCIA_RAYCS is not set
473
474#
475# Wireless 802.11b ISA/PCI cards support
476#
477# CONFIG_HERMES is not set
478# CONFIG_ATMEL is not set
479
480#
481# Wireless 802.11b Pcmcia/Cardbus cards support
482#
483# CONFIG_AIRO_CS is not set
484# CONFIG_PCMCIA_WL3501 is not set
485# CONFIG_HOSTAP is not set
486CONFIG_NET_WIRELESS=y
487
488#
489# PCMCIA network device support
490#
491CONFIG_NET_PCMCIA=y
492# CONFIG_PCMCIA_3C589 is not set
493# CONFIG_PCMCIA_3C574 is not set
494# CONFIG_PCMCIA_FMVJ18X is not set
495CONFIG_PCMCIA_PCNET=y
496# CONFIG_PCMCIA_NMCLAN is not set
497# CONFIG_PCMCIA_SMC91C92 is not set
498# CONFIG_PCMCIA_XIRC2PS is not set
499# CONFIG_PCMCIA_AXNET is not set
500
501#
502# Wan interfaces
503#
504# CONFIG_WAN is not set
505CONFIG_PPP=m
506# CONFIG_PPP_MULTILINK is not set
507# CONFIG_PPP_FILTER is not set
508CONFIG_PPP_ASYNC=m
509# CONFIG_PPP_SYNC_TTY is not set
510# CONFIG_PPP_DEFLATE is not set
511CONFIG_PPP_BSDCOMP=m
512# CONFIG_PPPOE is not set
513# CONFIG_SLIP is not set
514# CONFIG_SHAPER is not set
515# CONFIG_NETCONSOLE is not set
516# CONFIG_NETPOLL is not set
517# CONFIG_NET_POLL_CONTROLLER is not set
518
519#
520# ISDN subsystem
521#
522# CONFIG_ISDN is not set
523
524#
525# Input device support
526#
527CONFIG_INPUT=y
528
529#
530# Userland interfaces
531#
532# CONFIG_INPUT_MOUSEDEV is not set
533# CONFIG_INPUT_JOYDEV is not set
534CONFIG_INPUT_TSDEV=y
535CONFIG_INPUT_TSDEV_SCREEN_X=240
536CONFIG_INPUT_TSDEV_SCREEN_Y=320
537CONFIG_INPUT_EVDEV=y
538CONFIG_INPUT_EVBUG=y
539
540#
541# Input Device Drivers
542#
543CONFIG_INPUT_KEYBOARD=y
544# CONFIG_KEYBOARD_ATKBD is not set
545# CONFIG_KEYBOARD_SUNKBD is not set
546# CONFIG_KEYBOARD_LKKBD is not set
547CONFIG_KEYBOARD_LOCOMO=y
548# CONFIG_KEYBOARD_XTKBD is not set
549# CONFIG_KEYBOARD_NEWTON is not set
550# CONFIG_KEYBOARD_CORGI is not set
551CONFIG_KEYBOARD_SPITZ=y
552# CONFIG_INPUT_MOUSE is not set
553# CONFIG_INPUT_JOYSTICK is not set
554# CONFIG_INPUT_TOUCHSCREEN is not set
555# CONFIG_INPUT_MISC is not set
556
557#
558# Hardware I/O ports
559#
560# CONFIG_SERIO is not set
561# CONFIG_GAMEPORT is not set
562
563#
564# Character devices
565#
566CONFIG_VT=y
567CONFIG_VT_CONSOLE=y
568CONFIG_HW_CONSOLE=y
569# CONFIG_SERIAL_NONSTANDARD is not set
570
571#
572# Serial drivers
573#
574# CONFIG_SERIAL_8250 is not set
575
576#
577# Non-8250 serial port support
578#
579CONFIG_SERIAL_PXA=y
580CONFIG_SERIAL_PXA_CONSOLE=y
581CONFIG_SERIAL_CORE=y
582CONFIG_SERIAL_CORE_CONSOLE=y
583CONFIG_UNIX98_PTYS=y
584# CONFIG_LEGACY_PTYS is not set
585
586#
587# IPMI
588#
589# CONFIG_IPMI_HANDLER is not set
590
591#
592# Watchdog Cards
593#
594# CONFIG_WATCHDOG is not set
595# CONFIG_NVRAM is not set
596# CONFIG_RTC is not set
597# CONFIG_DTLK is not set
598# CONFIG_R3964 is not set
599
600#
601# Ftape, the floppy tape device driver
602#
603
604#
605# PCMCIA character devices
606#
607# CONFIG_SYNCLINK_CS is not set
608# CONFIG_RAW_DRIVER is not set
609
610#
611# TPM devices
612#
613
614#
615# I2C support
616#
617CONFIG_I2C=y
618# CONFIG_I2C_CHARDEV is not set
619
620#
621# I2C Algorithms
622#
623CONFIG_I2C_ALGOBIT=y
624# CONFIG_I2C_ALGOPCF is not set
625# CONFIG_I2C_ALGOPCA is not set
626
627#
628# I2C Hardware Bus support
629#
630# CONFIG_I2C_PXA is not set
631# CONFIG_I2C_PARPORT_LIGHT is not set
632# CONFIG_I2C_STUB is not set
633# CONFIG_I2C_PCA_ISA is not set
634
635#
636# Miscellaneous I2C Chip support
637#
638# CONFIG_SENSORS_DS1337 is not set
639# CONFIG_SENSORS_DS1374 is not set
640# CONFIG_SENSORS_EEPROM is not set
641# CONFIG_SENSORS_PCF8574 is not set
642# CONFIG_SENSORS_PCA9539 is not set
643# CONFIG_SENSORS_PCF8591 is not set
644# CONFIG_SENSORS_RTC8564 is not set
645# CONFIG_SENSORS_MAX6875 is not set
646CONFIG_I2C_DEBUG_CORE=y
647CONFIG_I2C_DEBUG_ALGO=y
648CONFIG_I2C_DEBUG_BUS=y
649# CONFIG_I2C_DEBUG_CHIP is not set
650
651#
652# Hardware Monitoring support
653#
654CONFIG_HWMON=y
655# CONFIG_HWMON_VID is not set
656# CONFIG_SENSORS_ADM1021 is not set
657# CONFIG_SENSORS_ADM1025 is not set
658# CONFIG_SENSORS_ADM1026 is not set
659# CONFIG_SENSORS_ADM1031 is not set
660# CONFIG_SENSORS_ADM9240 is not set
661# CONFIG_SENSORS_ASB100 is not set
662# CONFIG_SENSORS_ATXP1 is not set
663# CONFIG_SENSORS_DS1621 is not set
664# CONFIG_SENSORS_FSCHER is not set
665# CONFIG_SENSORS_FSCPOS is not set
666# CONFIG_SENSORS_GL518SM is not set
667# CONFIG_SENSORS_GL520SM is not set
668# CONFIG_SENSORS_IT87 is not set
669# CONFIG_SENSORS_LM63 is not set
670# CONFIG_SENSORS_LM75 is not set
671# CONFIG_SENSORS_LM77 is not set
672# CONFIG_SENSORS_LM78 is not set
673# CONFIG_SENSORS_LM80 is not set
674# CONFIG_SENSORS_LM83 is not set
675# CONFIG_SENSORS_LM85 is not set
676# CONFIG_SENSORS_LM87 is not set
677# CONFIG_SENSORS_LM90 is not set
678# CONFIG_SENSORS_LM92 is not set
679# CONFIG_SENSORS_MAX1619 is not set
680# CONFIG_SENSORS_PC87360 is not set
681# CONFIG_SENSORS_SMSC47M1 is not set
682# CONFIG_SENSORS_SMSC47B397 is not set
683# CONFIG_SENSORS_W83781D is not set
684# CONFIG_SENSORS_W83792D is not set
685# CONFIG_SENSORS_W83L785TS is not set
686# CONFIG_SENSORS_W83627HF is not set
687# CONFIG_SENSORS_W83627EHF is not set
688# CONFIG_HWMON_DEBUG_CHIP is not set
689
690#
691# Misc devices
692#
693
694#
695# Multimedia Capabilities Port drivers
696#
697
698#
699# Multimedia devices
700#
701CONFIG_VIDEO_DEV=m
702
703#
704# Video For Linux
705#
706
707#
708# Video Adapters
709#
710# CONFIG_VIDEO_CPIA is not set
711# CONFIG_VIDEO_SAA5246A is not set
712# CONFIG_VIDEO_SAA5249 is not set
713# CONFIG_TUNER_3036 is not set
714# CONFIG_VIDEO_OVCAMCHIP is not set
715
716#
717# Radio Adapters
718#
719# CONFIG_RADIO_MAESTRO is not set
720
721#
722# Digital Video Broadcasting Devices
723#
724# CONFIG_DVB is not set
725
726#
727# Graphics support
728#
729CONFIG_FB=y
730CONFIG_FB_CFB_FILLRECT=y
731CONFIG_FB_CFB_COPYAREA=y
732CONFIG_FB_CFB_IMAGEBLIT=y
733CONFIG_FB_SOFT_CURSOR=y
734# CONFIG_FB_MACMODES is not set
735CONFIG_FB_MODE_HELPERS=y
736# CONFIG_FB_TILEBLITTING is not set
737CONFIG_FB_PXA=y
738# CONFIG_FB_W100 is not set
739# CONFIG_FB_PXA_PARAMETERS is not set
740# CONFIG_FB_S1D13XXX is not set
741# CONFIG_FB_VIRTUAL is not set
742
743#
744# Console display driver support
745#
746# CONFIG_VGA_CONSOLE is not set
747CONFIG_DUMMY_CONSOLE=y
748CONFIG_FRAMEBUFFER_CONSOLE=y
749CONFIG_FONTS=y
750CONFIG_FONT_8x8=y
751# CONFIG_FONT_8x16 is not set
752# CONFIG_FONT_6x11 is not set
753# CONFIG_FONT_7x14 is not set
754# CONFIG_FONT_PEARL_8x8 is not set
755# CONFIG_FONT_ACORN_8x8 is not set
756# CONFIG_FONT_MINI_4x6 is not set
757# CONFIG_FONT_SUN8x16 is not set
758# CONFIG_FONT_SUN12x22 is not set
759# CONFIG_FONT_10x18 is not set
760
761#
762# Logo configuration
763#
764# CONFIG_LOGO is not set
765# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
766
767#
768# Sound
769#
770# CONFIG_SOUND is not set
771
772#
773# USB support
774#
775CONFIG_USB_ARCH_HAS_HCD=y
776# CONFIG_USB_ARCH_HAS_OHCI is not set
777# CONFIG_USB is not set
778
779#
780# USB Gadget Support
781#
782CONFIG_USB_GADGET=y
783# CONFIG_USB_GADGET_DEBUG_FILES is not set
784CONFIG_USB_GADGET_SELECTED=y
785# CONFIG_USB_GADGET_NET2280 is not set
786CONFIG_USB_GADGET_PXA2XX=y
787CONFIG_USB_PXA2XX=y
788# CONFIG_USB_PXA2XX_SMALL is not set
789# CONFIG_USB_GADGET_GOKU is not set
790# CONFIG_USB_GADGET_LH7A40X is not set
791# CONFIG_USB_GADGET_OMAP is not set
792# CONFIG_USB_GADGET_DUMMY_HCD is not set
793# CONFIG_USB_GADGET_DUALSPEED is not set
794# CONFIG_USB_ZERO is not set
795CONFIG_USB_ETH=y
796CONFIG_USB_ETH_RNDIS=y
797# CONFIG_USB_GADGETFS is not set
798# CONFIG_USB_FILE_STORAGE is not set
799# CONFIG_USB_G_SERIAL is not set
800
801#
802# MMC/SD Card support
803#
804CONFIG_MMC=y
805CONFIG_MMC_DEBUG=y
806CONFIG_MMC_BLOCK=y
807CONFIG_MMC_PXA=y
808# CONFIG_MMC_WBSD is not set
809
810#
811# File systems
812#
813CONFIG_EXT2_FS=y
814CONFIG_EXT2_FS_XATTR=y
815CONFIG_EXT2_FS_POSIX_ACL=y
816CONFIG_EXT2_FS_SECURITY=y
817# CONFIG_EXT2_FS_XIP is not set
818# CONFIG_EXT3_FS is not set
819# CONFIG_JBD is not set
820CONFIG_FS_MBCACHE=y
821# CONFIG_REISERFS_FS is not set
822# CONFIG_JFS_FS is not set
823CONFIG_FS_POSIX_ACL=y
824# CONFIG_XFS_FS is not set
825# CONFIG_MINIX_FS is not set
826# CONFIG_ROMFS_FS is not set
827CONFIG_INOTIFY=y
828# CONFIG_QUOTA is not set
829CONFIG_DNOTIFY=y
830# CONFIG_AUTOFS_FS is not set
831# CONFIG_AUTOFS4_FS is not set
832# CONFIG_FUSE_FS is not set
833
834#
835# CD-ROM/DVD Filesystems
836#
837# CONFIG_ISO9660_FS is not set
838# CONFIG_UDF_FS is not set
839
840#
841# DOS/FAT/NT Filesystems
842#
843CONFIG_FAT_FS=y
844CONFIG_MSDOS_FS=y
845CONFIG_VFAT_FS=y
846CONFIG_FAT_DEFAULT_CODEPAGE=437
847CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
848# CONFIG_NTFS_FS is not set
849
850#
851# Pseudo filesystems
852#
853CONFIG_PROC_FS=y
854CONFIG_SYSFS=y
855CONFIG_TMPFS=y
856# CONFIG_HUGETLB_PAGE is not set
857CONFIG_RAMFS=y
858# CONFIG_RELAYFS_FS is not set
859
860#
861# Miscellaneous filesystems
862#
863# CONFIG_ADFS_FS is not set
864# CONFIG_AFFS_FS is not set
865# CONFIG_HFS_FS is not set
866# CONFIG_HFSPLUS_FS is not set
867# CONFIG_BEFS_FS is not set
868# CONFIG_BFS_FS is not set
869# CONFIG_EFS_FS is not set
870# CONFIG_JFFS_FS is not set
871CONFIG_JFFS2_FS=y
872CONFIG_JFFS2_FS_DEBUG=0
873CONFIG_JFFS2_FS_WRITEBUFFER=y
874CONFIG_JFFS2_COMPRESSION_OPTIONS=y
875CONFIG_JFFS2_ZLIB=y
876CONFIG_JFFS2_RTIME=y
877CONFIG_JFFS2_RUBIN=y
878# CONFIG_JFFS2_CMODE_NONE is not set
879CONFIG_JFFS2_CMODE_PRIORITY=y
880# CONFIG_JFFS2_CMODE_SIZE is not set
881CONFIG_CRAMFS=m
882# CONFIG_VXFS_FS is not set
883# CONFIG_HPFS_FS is not set
884# CONFIG_QNX4FS_FS is not set
885# CONFIG_SYSV_FS is not set
886# CONFIG_UFS_FS is not set
887
888#
889# Network File Systems
890#
891# CONFIG_NFS_FS is not set
892# CONFIG_NFSD is not set
893# CONFIG_SMB_FS is not set
894# CONFIG_CIFS is not set
895# CONFIG_NCP_FS is not set
896# CONFIG_CODA_FS is not set
897# CONFIG_AFS_FS is not set
898# CONFIG_9P_FS is not set
899
900#
901# Partition Types
902#
903CONFIG_PARTITION_ADVANCED=y
904# CONFIG_ACORN_PARTITION is not set
905# CONFIG_OSF_PARTITION is not set
906# CONFIG_AMIGA_PARTITION is not set
907# CONFIG_ATARI_PARTITION is not set
908# CONFIG_MAC_PARTITION is not set
909CONFIG_MSDOS_PARTITION=y
910# CONFIG_BSD_DISKLABEL is not set
911# CONFIG_MINIX_SUBPARTITION is not set
912# CONFIG_SOLARIS_X86_PARTITION is not set
913# CONFIG_UNIXWARE_DISKLABEL is not set
914# CONFIG_LDM_PARTITION is not set
915# CONFIG_SGI_PARTITION is not set
916# CONFIG_ULTRIX_PARTITION is not set
917# CONFIG_SUN_PARTITION is not set
918# CONFIG_EFI_PARTITION is not set
919
920#
921# Native Language Support
922#
923CONFIG_NLS=y
924CONFIG_NLS_DEFAULT="cp437"
925CONFIG_NLS_CODEPAGE_437=y
926# CONFIG_NLS_CODEPAGE_737 is not set
927# CONFIG_NLS_CODEPAGE_775 is not set
928# CONFIG_NLS_CODEPAGE_850 is not set
929# CONFIG_NLS_CODEPAGE_852 is not set
930# CONFIG_NLS_CODEPAGE_855 is not set
931# CONFIG_NLS_CODEPAGE_857 is not set
932# CONFIG_NLS_CODEPAGE_860 is not set
933# CONFIG_NLS_CODEPAGE_861 is not set
934# CONFIG_NLS_CODEPAGE_862 is not set
935# CONFIG_NLS_CODEPAGE_863 is not set
936# CONFIG_NLS_CODEPAGE_864 is not set
937# CONFIG_NLS_CODEPAGE_865 is not set
938# CONFIG_NLS_CODEPAGE_866 is not set
939# CONFIG_NLS_CODEPAGE_869 is not set
940# CONFIG_NLS_CODEPAGE_936 is not set
941# CONFIG_NLS_CODEPAGE_950 is not set
942# CONFIG_NLS_CODEPAGE_932 is not set
943# CONFIG_NLS_CODEPAGE_949 is not set
944# CONFIG_NLS_CODEPAGE_874 is not set
945# CONFIG_NLS_ISO8859_8 is not set
946# CONFIG_NLS_CODEPAGE_1250 is not set
947# CONFIG_NLS_CODEPAGE_1251 is not set
948CONFIG_NLS_ASCII=y
949CONFIG_NLS_ISO8859_1=y
950# CONFIG_NLS_ISO8859_2 is not set
951# CONFIG_NLS_ISO8859_3 is not set
952# CONFIG_NLS_ISO8859_4 is not set
953# CONFIG_NLS_ISO8859_5 is not set
954# CONFIG_NLS_ISO8859_6 is not set
955# CONFIG_NLS_ISO8859_7 is not set
956# CONFIG_NLS_ISO8859_9 is not set
957# CONFIG_NLS_ISO8859_13 is not set
958# CONFIG_NLS_ISO8859_14 is not set
959# CONFIG_NLS_ISO8859_15 is not set
960# CONFIG_NLS_KOI8_R is not set
961# CONFIG_NLS_KOI8_U is not set
962CONFIG_NLS_UTF8=y
963
964#
965# Profiling support
966#
967# CONFIG_PROFILING is not set
968
969#
970# Kernel hacking
971#
972# CONFIG_PRINTK_TIME is not set
973CONFIG_DEBUG_KERNEL=y
974CONFIG_MAGIC_SYSRQ=y
975CONFIG_LOG_BUF_SHIFT=14
976CONFIG_DETECT_SOFTLOCKUP=y
977# CONFIG_SCHEDSTATS is not set
978# CONFIG_DEBUG_SLAB is not set
979CONFIG_DEBUG_PREEMPT=y
980# CONFIG_DEBUG_SPINLOCK is not set
981# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
982# CONFIG_DEBUG_KOBJECT is not set
983# CONFIG_DEBUG_BUGVERBOSE is not set
984# CONFIG_DEBUG_INFO is not set
985# CONFIG_DEBUG_FS is not set
986CONFIG_FRAME_POINTER=y
987# CONFIG_DEBUG_USER is not set
988# CONFIG_DEBUG_WAITQ is not set
989CONFIG_DEBUG_ERRORS=y
990# CONFIG_DEBUG_LL is not set
991
992#
993# Security options
994#
995# CONFIG_KEYS is not set
996# CONFIG_SECURITY is not set
997
998#
999# Cryptographic options
1000#
1001# CONFIG_CRYPTO is not set
1002
1003#
1004# Hardware crypto devices
1005#
1006
1007#
1008# Library routines
1009#
1010CONFIG_CRC_CCITT=y
1011# CONFIG_CRC16 is not set
1012CONFIG_CRC32=y
1013# CONFIG_LIBCRC32C is not set
1014CONFIG_ZLIB_INFLATE=y
1015CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/spitz_defconfig b/arch/arm/configs/spitz_defconfig
new file mode 100644
index 000000000000..900e04f8e38c
--- /dev/null
+++ b/arch/arm/configs/spitz_defconfig
@@ -0,0 +1,1401 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc3
4# Sun Oct 9 17:11:19 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
20
21#
22# General setup
23#
24CONFIG_LOCALVERSION=""
25CONFIG_LOCALVERSION_AUTO=y
26CONFIG_SWAP=y
27CONFIG_SYSVIPC=y
28# CONFIG_POSIX_MQUEUE is not set
29CONFIG_BSD_PROCESS_ACCT=y
30# CONFIG_BSD_PROCESS_ACCT_V3 is not set
31CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set
33CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y
35# CONFIG_IKCONFIG is not set
36CONFIG_INITRAMFS_SOURCE=""
37CONFIG_EMBEDDED=y
38CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_ALL is not set
40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_BASE_FULL=y
44CONFIG_FUTEX=y
45CONFIG_EPOLL=y
46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
47CONFIG_SHMEM=y
48CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
54
55#
56# Loadable module support
57#
58CONFIG_MODULES=y
59CONFIG_MODULE_UNLOAD=y
60CONFIG_MODULE_FORCE_UNLOAD=y
61CONFIG_OBSOLETE_MODPARM=y
62# CONFIG_MODVERSIONS is not set
63# CONFIG_MODULE_SRCVERSION_ALL is not set
64CONFIG_KMOD=y
65
66#
67# System Type
68#
69# CONFIG_ARCH_CLPS7500 is not set
70# CONFIG_ARCH_CLPS711X is not set
71# CONFIG_ARCH_CO285 is not set
72# CONFIG_ARCH_EBSA110 is not set
73# CONFIG_ARCH_CAMELOT is not set
74# CONFIG_ARCH_FOOTBRIDGE is not set
75# CONFIG_ARCH_INTEGRATOR is not set
76# CONFIG_ARCH_IOP3XX is not set
77# CONFIG_ARCH_IXP4XX is not set
78# CONFIG_ARCH_IXP2000 is not set
79# CONFIG_ARCH_L7200 is not set
80CONFIG_ARCH_PXA=y
81# CONFIG_ARCH_RPC is not set
82# CONFIG_ARCH_SA1100 is not set
83# CONFIG_ARCH_S3C2410 is not set
84# CONFIG_ARCH_SHARK is not set
85# CONFIG_ARCH_LH7A40X is not set
86# CONFIG_ARCH_OMAP is not set
87# CONFIG_ARCH_VERSATILE is not set
88# CONFIG_ARCH_IMX is not set
89# CONFIG_ARCH_H720X is not set
90# CONFIG_ARCH_AAEC2000 is not set
91
92#
93# Intel PXA2xx Implementations
94#
95# CONFIG_ARCH_LUBBOCK is not set
96# CONFIG_MACH_MAINSTONE is not set
97# CONFIG_ARCH_PXA_IDP is not set
98CONFIG_PXA_SHARPSL=y
99# CONFIG_PXA_SHARPSL_25x is not set
100CONFIG_PXA_SHARPSL_27x=y
101CONFIG_MACH_SPITZ=y
102CONFIG_MACH_BORZOI=y
103CONFIG_PXA27x=y
104CONFIG_PXA_SHARP_Cxx00=y
105
106#
107# Processor Type
108#
109CONFIG_CPU_32=y
110CONFIG_CPU_XSCALE=y
111CONFIG_CPU_32v5=y
112CONFIG_CPU_ABRT_EV5T=y
113CONFIG_CPU_CACHE_VIVT=y
114CONFIG_CPU_TLB_V4WBI=y
115
116#
117# Processor Features
118#
119CONFIG_ARM_THUMB=y
120CONFIG_XSCALE_PMU=y
121CONFIG_SHARP_PARAM=y
122CONFIG_SHARP_SCOOP=y
123
124#
125# Bus support
126#
127CONFIG_ISA_DMA_API=y
128
129#
130# PCCARD (PCMCIA/CardBus) support
131#
132CONFIG_PCCARD=y
133# CONFIG_PCMCIA_DEBUG is not set
134CONFIG_PCMCIA=y
135CONFIG_PCMCIA_LOAD_CIS=y
136CONFIG_PCMCIA_IOCTL=y
137
138#
139# PC-card bridges
140#
141CONFIG_PCMCIA_PXA2XX=y
142
143#
144# Kernel Features
145#
146CONFIG_PREEMPT=y
147# CONFIG_NO_IDLE_HZ is not set
148# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
149CONFIG_SELECT_MEMORY_MODEL=y
150CONFIG_FLATMEM_MANUAL=y
151# CONFIG_DISCONTIGMEM_MANUAL is not set
152# CONFIG_SPARSEMEM_MANUAL is not set
153CONFIG_FLATMEM=y
154CONFIG_FLAT_NODE_MEM_MAP=y
155# CONFIG_SPARSEMEM_STATIC is not set
156CONFIG_ALIGNMENT_TRAP=y
157
158#
159# Boot options
160#
161CONFIG_ZBOOT_ROM_TEXT=0x0
162CONFIG_ZBOOT_ROM_BSS=0x0
163CONFIG_CMDLINE="console=ttyS0,115200n8 console=tty1 noinitrd root=/dev/mtdblock2 rootfstype=jffs2 debug"
164# CONFIG_XIP_KERNEL is not set
165
166#
167# Floating point emulation
168#
169
170#
171# At least one emulation must be selected
172#
173CONFIG_FPE_NWFPE=y
174# CONFIG_FPE_NWFPE_XP is not set
175# CONFIG_FPE_FASTFPE is not set
176
177#
178# Userspace binary formats
179#
180CONFIG_BINFMT_ELF=y
181CONFIG_BINFMT_AOUT=m
182CONFIG_BINFMT_MISC=m
183# CONFIG_ARTHUR is not set
184
185#
186# Power management options
187#
188CONFIG_PM=y
189CONFIG_APM=y
190
191#
192# Networking
193#
194CONFIG_NET=y
195
196#
197# Networking options
198#
199CONFIG_PACKET=y
200CONFIG_PACKET_MMAP=y
201CONFIG_UNIX=y
202CONFIG_XFRM=y
203# CONFIG_XFRM_USER is not set
204# CONFIG_NET_KEY is not set
205CONFIG_INET=y
206# CONFIG_IP_MULTICAST is not set
207# CONFIG_IP_ADVANCED_ROUTER is not set
208CONFIG_IP_FIB_HASH=y
209# CONFIG_IP_PNP is not set
210# CONFIG_NET_IPIP is not set
211# CONFIG_NET_IPGRE is not set
212# CONFIG_ARPD is not set
213CONFIG_SYN_COOKIES=y
214# CONFIG_INET_AH is not set
215# CONFIG_INET_ESP is not set
216# CONFIG_INET_IPCOMP is not set
217# CONFIG_INET_TUNNEL is not set
218CONFIG_INET_DIAG=y
219CONFIG_INET_TCP_DIAG=y
220# CONFIG_TCP_CONG_ADVANCED is not set
221CONFIG_TCP_CONG_BIC=y
222
223#
224# IP: Virtual Server Configuration
225#
226# CONFIG_IP_VS is not set
227CONFIG_IPV6=m
228# CONFIG_IPV6_PRIVACY is not set
229CONFIG_INET6_AH=m
230CONFIG_INET6_ESP=m
231CONFIG_INET6_IPCOMP=m
232CONFIG_INET6_TUNNEL=m
233CONFIG_IPV6_TUNNEL=m
234CONFIG_NETFILTER=y
235# CONFIG_NETFILTER_DEBUG is not set
236# CONFIG_NETFILTER_NETLINK is not set
237
238#
239# IP: Netfilter Configuration
240#
241CONFIG_IP_NF_CONNTRACK=m
242# CONFIG_IP_NF_CT_ACCT is not set
243# CONFIG_IP_NF_CONNTRACK_MARK is not set
244# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
245CONFIG_IP_NF_CT_PROTO_SCTP=m
246CONFIG_IP_NF_FTP=m
247CONFIG_IP_NF_IRC=m
248# CONFIG_IP_NF_NETBIOS_NS is not set
249CONFIG_IP_NF_TFTP=m
250CONFIG_IP_NF_AMANDA=m
251# CONFIG_IP_NF_PPTP is not set
252CONFIG_IP_NF_QUEUE=m
253CONFIG_IP_NF_IPTABLES=m
254CONFIG_IP_NF_MATCH_LIMIT=m
255CONFIG_IP_NF_MATCH_IPRANGE=m
256CONFIG_IP_NF_MATCH_MAC=m
257CONFIG_IP_NF_MATCH_PKTTYPE=m
258CONFIG_IP_NF_MATCH_MARK=m
259CONFIG_IP_NF_MATCH_MULTIPORT=m
260CONFIG_IP_NF_MATCH_TOS=m
261CONFIG_IP_NF_MATCH_RECENT=m
262CONFIG_IP_NF_MATCH_ECN=m
263CONFIG_IP_NF_MATCH_DSCP=m
264CONFIG_IP_NF_MATCH_AH_ESP=m
265CONFIG_IP_NF_MATCH_LENGTH=m
266CONFIG_IP_NF_MATCH_TTL=m
267CONFIG_IP_NF_MATCH_TCPMSS=m
268CONFIG_IP_NF_MATCH_HELPER=m
269CONFIG_IP_NF_MATCH_STATE=m
270CONFIG_IP_NF_MATCH_CONNTRACK=m
271CONFIG_IP_NF_MATCH_OWNER=m
272CONFIG_IP_NF_MATCH_ADDRTYPE=m
273CONFIG_IP_NF_MATCH_REALM=m
274CONFIG_IP_NF_MATCH_SCTP=m
275# CONFIG_IP_NF_MATCH_DCCP is not set
276CONFIG_IP_NF_MATCH_COMMENT=m
277CONFIG_IP_NF_MATCH_HASHLIMIT=m
278# CONFIG_IP_NF_MATCH_STRING is not set
279CONFIG_IP_NF_FILTER=m
280# CONFIG_IP_NF_TARGET_REJECT is not set
281CONFIG_IP_NF_TARGET_LOG=m
282CONFIG_IP_NF_TARGET_ULOG=m
283CONFIG_IP_NF_TARGET_TCPMSS=m
284# CONFIG_IP_NF_TARGET_NFQUEUE is not set
285CONFIG_IP_NF_NAT=m
286CONFIG_IP_NF_NAT_NEEDED=y
287# CONFIG_IP_NF_TARGET_MASQUERADE is not set
288# CONFIG_IP_NF_TARGET_REDIRECT is not set
289# CONFIG_IP_NF_TARGET_NETMAP is not set
290# CONFIG_IP_NF_TARGET_SAME is not set
291# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
292CONFIG_IP_NF_NAT_IRC=m
293CONFIG_IP_NF_NAT_FTP=m
294CONFIG_IP_NF_NAT_TFTP=m
295CONFIG_IP_NF_NAT_AMANDA=m
296CONFIG_IP_NF_MANGLE=m
297# CONFIG_IP_NF_TARGET_TOS is not set
298# CONFIG_IP_NF_TARGET_ECN is not set
299# CONFIG_IP_NF_TARGET_DSCP is not set
300# CONFIG_IP_NF_TARGET_MARK is not set
301# CONFIG_IP_NF_TARGET_CLASSIFY is not set
302# CONFIG_IP_NF_TARGET_TTL is not set
303CONFIG_IP_NF_RAW=m
304# CONFIG_IP_NF_TARGET_NOTRACK is not set
305CONFIG_IP_NF_ARPTABLES=m
306CONFIG_IP_NF_ARPFILTER=m
307CONFIG_IP_NF_ARP_MANGLE=m
308
309#
310# IPv6: Netfilter Configuration (EXPERIMENTAL)
311#
312CONFIG_IP6_NF_QUEUE=m
313CONFIG_IP6_NF_IPTABLES=m
314CONFIG_IP6_NF_MATCH_LIMIT=m
315CONFIG_IP6_NF_MATCH_MAC=m
316CONFIG_IP6_NF_MATCH_RT=m
317CONFIG_IP6_NF_MATCH_OPTS=m
318CONFIG_IP6_NF_MATCH_FRAG=m
319CONFIG_IP6_NF_MATCH_HL=m
320CONFIG_IP6_NF_MATCH_MULTIPORT=m
321CONFIG_IP6_NF_MATCH_OWNER=m
322CONFIG_IP6_NF_MATCH_MARK=m
323CONFIG_IP6_NF_MATCH_IPV6HEADER=m
324CONFIG_IP6_NF_MATCH_AHESP=m
325CONFIG_IP6_NF_MATCH_LENGTH=m
326CONFIG_IP6_NF_MATCH_EUI64=m
327CONFIG_IP6_NF_FILTER=m
328# CONFIG_IP6_NF_TARGET_LOG is not set
329# CONFIG_IP6_NF_TARGET_REJECT is not set
330# CONFIG_IP6_NF_TARGET_NFQUEUE is not set
331CONFIG_IP6_NF_MANGLE=m
332# CONFIG_IP6_NF_TARGET_MARK is not set
333# CONFIG_IP6_NF_TARGET_HL is not set
334CONFIG_IP6_NF_RAW=m
335
336#
337# DCCP Configuration (EXPERIMENTAL)
338#
339# CONFIG_IP_DCCP is not set
340
341#
342# SCTP Configuration (EXPERIMENTAL)
343#
344# CONFIG_IP_SCTP is not set
345# CONFIG_ATM is not set
346# CONFIG_BRIDGE is not set
347# CONFIG_VLAN_8021Q is not set
348# CONFIG_DECNET is not set
349# CONFIG_LLC2 is not set
350# CONFIG_IPX is not set
351# CONFIG_ATALK is not set
352# CONFIG_X25 is not set
353# CONFIG_LAPB is not set
354# CONFIG_NET_DIVERT is not set
355# CONFIG_ECONET is not set
356# CONFIG_WAN_ROUTER is not set
357# CONFIG_NET_SCHED is not set
358CONFIG_NET_CLS_ROUTE=y
359
360#
361# Network testing
362#
363# CONFIG_NET_PKTGEN is not set
364# CONFIG_HAMRADIO is not set
365CONFIG_IRDA=m
366
367#
368# IrDA protocols
369#
370CONFIG_IRLAN=m
371CONFIG_IRNET=m
372CONFIG_IRCOMM=m
373# CONFIG_IRDA_ULTRA is not set
374
375#
376# IrDA options
377#
378# CONFIG_IRDA_CACHE_LAST_LSAP is not set
379# CONFIG_IRDA_FAST_RR is not set
380# CONFIG_IRDA_DEBUG is not set
381
382#
383# Infrared-port device drivers
384#
385
386#
387# SIR device drivers
388#
389# CONFIG_IRTTY_SIR is not set
390
391#
392# Dongle support
393#
394
395#
396# Old SIR device drivers
397#
398# CONFIG_IRPORT_SIR is not set
399
400#
401# Old Serial dongle support
402#
403
404#
405# FIR device drivers
406#
407# CONFIG_USB_IRDA is not set
408# CONFIG_SIGMATEL_FIR is not set
409# CONFIG_NSC_FIR is not set
410# CONFIG_WINBOND_FIR is not set
411# CONFIG_SMC_IRCC_FIR is not set
412# CONFIG_ALI_FIR is not set
413# CONFIG_VIA_FIR is not set
414CONFIG_BT=m
415CONFIG_BT_L2CAP=m
416CONFIG_BT_SCO=m
417CONFIG_BT_RFCOMM=m
418CONFIG_BT_RFCOMM_TTY=y
419CONFIG_BT_BNEP=m
420CONFIG_BT_BNEP_MC_FILTER=y
421CONFIG_BT_BNEP_PROTO_FILTER=y
422CONFIG_BT_HIDP=m
423
424#
425# Bluetooth device drivers
426#
427CONFIG_BT_HCIUSB=m
428# CONFIG_BT_HCIUSB_SCO is not set
429CONFIG_BT_HCIUART=m
430CONFIG_BT_HCIUART_H4=y
431CONFIG_BT_HCIUART_BCSP=y
432CONFIG_BT_HCIUART_BCSP_TXCRC=y
433CONFIG_BT_HCIBCM203X=m
434CONFIG_BT_HCIBPA10X=m
435CONFIG_BT_HCIBFUSB=m
436CONFIG_BT_HCIDTL1=m
437CONFIG_BT_HCIBT3C=m
438CONFIG_BT_HCIBLUECARD=m
439CONFIG_BT_HCIBTUART=m
440CONFIG_BT_HCIVHCI=m
441CONFIG_IEEE80211=m
442# CONFIG_IEEE80211_DEBUG is not set
443CONFIG_IEEE80211_CRYPT_WEP=m
444# CONFIG_IEEE80211_CRYPT_CCMP is not set
445# CONFIG_IEEE80211_CRYPT_TKIP is not set
446
447#
448# Device Drivers
449#
450
451#
452# Generic Driver Options
453#
454CONFIG_STANDALONE=y
455CONFIG_PREVENT_FIRMWARE_BUILD=y
456CONFIG_FW_LOADER=y
457# CONFIG_DEBUG_DRIVER is not set
458
459#
460# Memory Technology Devices (MTD)
461#
462CONFIG_MTD=y
463# CONFIG_MTD_DEBUG is not set
464# CONFIG_MTD_CONCAT is not set
465CONFIG_MTD_PARTITIONS=y
466# CONFIG_MTD_REDBOOT_PARTS is not set
467CONFIG_MTD_CMDLINE_PARTS=y
468# CONFIG_MTD_AFS_PARTS is not set
469
470#
471# User Modules And Translation Layers
472#
473CONFIG_MTD_CHAR=y
474CONFIG_MTD_BLOCK=y
475# CONFIG_FTL is not set
476# CONFIG_NFTL is not set
477# CONFIG_INFTL is not set
478
479#
480# RAM/ROM/Flash chip drivers
481#
482# CONFIG_MTD_CFI is not set
483# CONFIG_MTD_JEDECPROBE is not set
484CONFIG_MTD_MAP_BANK_WIDTH_1=y
485CONFIG_MTD_MAP_BANK_WIDTH_2=y
486CONFIG_MTD_MAP_BANK_WIDTH_4=y
487# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
488# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
489# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
490CONFIG_MTD_CFI_I1=y
491CONFIG_MTD_CFI_I2=y
492# CONFIG_MTD_CFI_I4 is not set
493# CONFIG_MTD_CFI_I8 is not set
494# CONFIG_MTD_RAM is not set
495CONFIG_MTD_ROM=y
496# CONFIG_MTD_ABSENT is not set
497
498#
499# Mapping drivers for chip access
500#
501CONFIG_MTD_COMPLEX_MAPPINGS=y
502CONFIG_MTD_SHARP_SL=y
503# CONFIG_MTD_PLATRAM is not set
504
505#
506# Self-contained MTD device drivers
507#
508# CONFIG_MTD_SLRAM is not set
509# CONFIG_MTD_PHRAM is not set
510# CONFIG_MTD_MTDRAM is not set
511# CONFIG_MTD_BLKMTD is not set
512# CONFIG_MTD_BLOCK2MTD is not set
513
514#
515# Disk-On-Chip Device Drivers
516#
517# CONFIG_MTD_DOC2000 is not set
518# CONFIG_MTD_DOC2001 is not set
519# CONFIG_MTD_DOC2001PLUS is not set
520
521#
522# NAND Flash Device Drivers
523#
524CONFIG_MTD_NAND=y
525CONFIG_MTD_NAND_VERIFY_WRITE=y
526# CONFIG_MTD_NAND_H1900 is not set
527CONFIG_MTD_NAND_IDS=y
528# CONFIG_MTD_NAND_DISKONCHIP is not set
529CONFIG_MTD_NAND_SHARPSL=y
530# CONFIG_MTD_NAND_NANDSIM is not set
531
532#
533# Parallel port support
534#
535# CONFIG_PARPORT is not set
536
537#
538# Plug and Play support
539#
540
541#
542# Block devices
543#
544# CONFIG_BLK_DEV_COW_COMMON is not set
545CONFIG_BLK_DEV_LOOP=y
546# CONFIG_BLK_DEV_CRYPTOLOOP is not set
547# CONFIG_BLK_DEV_NBD is not set
548# CONFIG_BLK_DEV_UB is not set
549# CONFIG_BLK_DEV_RAM is not set
550CONFIG_BLK_DEV_RAM_COUNT=16
551# CONFIG_CDROM_PKTCDVD is not set
552
553#
554# IO Schedulers
555#
556CONFIG_IOSCHED_NOOP=y
557CONFIG_IOSCHED_AS=y
558CONFIG_IOSCHED_DEADLINE=y
559CONFIG_IOSCHED_CFQ=y
560# CONFIG_ATA_OVER_ETH is not set
561
562#
563# ATA/ATAPI/MFM/RLL support
564#
565CONFIG_IDE=y
566CONFIG_BLK_DEV_IDE=y
567
568#
569# Please see Documentation/ide.txt for help/info on IDE drives
570#
571# CONFIG_BLK_DEV_IDE_SATA is not set
572CONFIG_BLK_DEV_IDEDISK=y
573# CONFIG_IDEDISK_MULTI_MODE is not set
574CONFIG_BLK_DEV_IDECS=y
575# CONFIG_BLK_DEV_IDECD is not set
576# CONFIG_BLK_DEV_IDETAPE is not set
577# CONFIG_BLK_DEV_IDEFLOPPY is not set
578# CONFIG_BLK_DEV_IDESCSI is not set
579# CONFIG_IDE_TASK_IOCTL is not set
580
581#
582# IDE chipset support/bugfixes
583#
584CONFIG_IDE_GENERIC=y
585# CONFIG_IDE_ARM is not set
586# CONFIG_BLK_DEV_IDEDMA is not set
587# CONFIG_IDEDMA_AUTO is not set
588# CONFIG_BLK_DEV_HD is not set
589
590#
591# SCSI device support
592#
593# CONFIG_RAID_ATTRS is not set
594CONFIG_SCSI=m
595CONFIG_SCSI_PROC_FS=y
596
597#
598# SCSI support type (disk, tape, CD-ROM)
599#
600CONFIG_BLK_DEV_SD=m
601CONFIG_CHR_DEV_ST=m
602CONFIG_CHR_DEV_OSST=m
603CONFIG_BLK_DEV_SR=m
604# CONFIG_BLK_DEV_SR_VENDOR is not set
605CONFIG_CHR_DEV_SG=m
606# CONFIG_CHR_DEV_SCH is not set
607
608#
609# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
610#
611CONFIG_SCSI_MULTI_LUN=y
612# CONFIG_SCSI_CONSTANTS is not set
613# CONFIG_SCSI_LOGGING is not set
614
615#
616# SCSI Transport Attributes
617#
618# CONFIG_SCSI_SPI_ATTRS is not set
619# CONFIG_SCSI_FC_ATTRS is not set
620# CONFIG_SCSI_ISCSI_ATTRS is not set
621# CONFIG_SCSI_SAS_ATTRS is not set
622
623#
624# SCSI low-level drivers
625#
626# CONFIG_SCSI_SATA is not set
627# CONFIG_SCSI_DEBUG is not set
628
629#
630# PCMCIA SCSI adapter support
631#
632# CONFIG_PCMCIA_AHA152X is not set
633# CONFIG_PCMCIA_FDOMAIN is not set
634# CONFIG_PCMCIA_NINJA_SCSI is not set
635# CONFIG_PCMCIA_QLOGIC is not set
636# CONFIG_PCMCIA_SYM53C500 is not set
637
638#
639# Multi-device support (RAID and LVM)
640#
641# CONFIG_MD is not set
642
643#
644# Fusion MPT device support
645#
646# CONFIG_FUSION is not set
647
648#
649# IEEE 1394 (FireWire) support
650#
651
652#
653# I2O device support
654#
655
656#
657# Network device support
658#
659CONFIG_NETDEVICES=y
660# CONFIG_DUMMY is not set
661# CONFIG_BONDING is not set
662# CONFIG_EQUALIZER is not set
663# CONFIG_TUN is not set
664
665#
666# PHY device support
667#
668# CONFIG_PHYLIB is not set
669
670#
671# Ethernet (10 or 100Mbit)
672#
673CONFIG_NET_ETHERNET=y
674CONFIG_MII=m
675# CONFIG_SMC91X is not set
676# CONFIG_DM9000 is not set
677
678#
679# Ethernet (1000 Mbit)
680#
681
682#
683# Ethernet (10000 Mbit)
684#
685
686#
687# Token Ring devices
688#
689
690#
691# Wireless LAN (non-hamradio)
692#
693CONFIG_NET_RADIO=y
694
695#
696# Obsolete Wireless cards support (pre-802.11)
697#
698# CONFIG_STRIP is not set
699# CONFIG_PCMCIA_WAVELAN is not set
700# CONFIG_PCMCIA_NETWAVE is not set
701
702#
703# Wireless 802.11 Frequency Hopping cards support
704#
705# CONFIG_PCMCIA_RAYCS is not set
706
707#
708# Wireless 802.11b ISA/PCI cards support
709#
710CONFIG_HERMES=m
711# CONFIG_ATMEL is not set
712
713#
714# Wireless 802.11b Pcmcia/Cardbus cards support
715#
716CONFIG_PCMCIA_HERMES=m
717CONFIG_PCMCIA_SPECTRUM=m
718# CONFIG_AIRO_CS is not set
719# CONFIG_PCMCIA_WL3501 is not set
720CONFIG_HOSTAP=m
721CONFIG_HOSTAP_FIRMWARE=y
722CONFIG_HOSTAP_CS=m
723CONFIG_NET_WIRELESS=y
724
725#
726# PCMCIA network device support
727#
728CONFIG_NET_PCMCIA=y
729# CONFIG_PCMCIA_3C589 is not set
730# CONFIG_PCMCIA_3C574 is not set
731# CONFIG_PCMCIA_FMVJ18X is not set
732CONFIG_PCMCIA_PCNET=m
733# CONFIG_PCMCIA_NMCLAN is not set
734# CONFIG_PCMCIA_SMC91C92 is not set
735# CONFIG_PCMCIA_XIRC2PS is not set
736# CONFIG_PCMCIA_AXNET is not set
737
738#
739# Wan interfaces
740#
741# CONFIG_WAN is not set
742CONFIG_PPP=m
743# CONFIG_PPP_MULTILINK is not set
744# CONFIG_PPP_FILTER is not set
745CONFIG_PPP_ASYNC=m
746# CONFIG_PPP_SYNC_TTY is not set
747# CONFIG_PPP_DEFLATE is not set
748CONFIG_PPP_BSDCOMP=m
749# CONFIG_PPPOE is not set
750# CONFIG_SLIP is not set
751# CONFIG_SHAPER is not set
752# CONFIG_NETCONSOLE is not set
753# CONFIG_NETPOLL is not set
754# CONFIG_NET_POLL_CONTROLLER is not set
755
756#
757# ISDN subsystem
758#
759# CONFIG_ISDN is not set
760
761#
762# Input device support
763#
764CONFIG_INPUT=y
765
766#
767# Userland interfaces
768#
769# CONFIG_INPUT_MOUSEDEV is not set
770# CONFIG_INPUT_JOYDEV is not set
771# CONFIG_INPUT_TSDEV is not set
772CONFIG_INPUT_EVDEV=y
773# CONFIG_INPUT_EVBUG is not set
774
775#
776# Input Device Drivers
777#
778CONFIG_INPUT_KEYBOARD=y
779# CONFIG_KEYBOARD_ATKBD is not set
780# CONFIG_KEYBOARD_SUNKBD is not set
781# CONFIG_KEYBOARD_LKKBD is not set
782# CONFIG_KEYBOARD_XTKBD is not set
783# CONFIG_KEYBOARD_NEWTON is not set
784# CONFIG_KEYBOARD_CORGI is not set
785CONFIG_KEYBOARD_SPITZ=y
786# CONFIG_INPUT_MOUSE is not set
787# CONFIG_INPUT_JOYSTICK is not set
788CONFIG_INPUT_TOUCHSCREEN=y
789CONFIG_TOUCHSCREEN_CORGI=y
790# CONFIG_TOUCHSCREEN_GUNZE is not set
791# CONFIG_TOUCHSCREEN_ELO is not set
792# CONFIG_TOUCHSCREEN_MTOUCH is not set
793# CONFIG_TOUCHSCREEN_MK712 is not set
794CONFIG_INPUT_MISC=y
795CONFIG_INPUT_UINPUT=m
796
797#
798# Hardware I/O ports
799#
800# CONFIG_SERIO is not set
801# CONFIG_GAMEPORT is not set
802
803#
804# Character devices
805#
806CONFIG_VT=y
807CONFIG_VT_CONSOLE=y
808CONFIG_HW_CONSOLE=y
809# CONFIG_SERIAL_NONSTANDARD is not set
810
811#
812# Serial drivers
813#
814CONFIG_SERIAL_8250=m
815CONFIG_SERIAL_8250_CS=m
816CONFIG_SERIAL_8250_NR_UARTS=4
817# CONFIG_SERIAL_8250_EXTENDED is not set
818
819#
820# Non-8250 serial port support
821#
822CONFIG_SERIAL_PXA=y
823CONFIG_SERIAL_PXA_CONSOLE=y
824CONFIG_SERIAL_CORE=y
825CONFIG_SERIAL_CORE_CONSOLE=y
826CONFIG_UNIX98_PTYS=y
827# CONFIG_LEGACY_PTYS is not set
828
829#
830# IPMI
831#
832# CONFIG_IPMI_HANDLER is not set
833
834#
835# Watchdog Cards
836#
837# CONFIG_WATCHDOG is not set
838# CONFIG_NVRAM is not set
839# CONFIG_RTC is not set
840# CONFIG_DTLK is not set
841# CONFIG_R3964 is not set
842
843#
844# Ftape, the floppy tape device driver
845#
846
847#
848# PCMCIA character devices
849#
850# CONFIG_SYNCLINK_CS is not set
851# CONFIG_RAW_DRIVER is not set
852
853#
854# TPM devices
855#
856
857#
858# I2C support
859#
860# CONFIG_I2C is not set
861
862#
863# Hardware Monitoring support
864#
865CONFIG_HWMON=y
866# CONFIG_HWMON_VID is not set
867# CONFIG_HWMON_DEBUG_CHIP is not set
868
869#
870# Misc devices
871#
872
873#
874# Multimedia Capabilities Port drivers
875#
876
877#
878# Multimedia devices
879#
880# CONFIG_VIDEO_DEV is not set
881
882#
883# Digital Video Broadcasting Devices
884#
885# CONFIG_DVB is not set
886
887#
888# Graphics support
889#
890CONFIG_FB=y
891CONFIG_FB_CFB_FILLRECT=y
892CONFIG_FB_CFB_COPYAREA=y
893CONFIG_FB_CFB_IMAGEBLIT=y
894CONFIG_FB_SOFT_CURSOR=y
895# CONFIG_FB_MACMODES is not set
896# CONFIG_FB_MODE_HELPERS is not set
897# CONFIG_FB_TILEBLITTING is not set
898CONFIG_FB_PXA=y
899# CONFIG_FB_W100 is not set
900# CONFIG_FB_PXA_PARAMETERS is not set
901# CONFIG_FB_S1D13XXX is not set
902# CONFIG_FB_VIRTUAL is not set
903
904#
905# Console display driver support
906#
907# CONFIG_VGA_CONSOLE is not set
908CONFIG_DUMMY_CONSOLE=y
909CONFIG_FRAMEBUFFER_CONSOLE=y
910CONFIG_FONTS=y
911CONFIG_FONT_8x8=y
912CONFIG_FONT_8x16=y
913# CONFIG_FONT_6x11 is not set
914# CONFIG_FONT_7x14 is not set
915# CONFIG_FONT_PEARL_8x8 is not set
916# CONFIG_FONT_ACORN_8x8 is not set
917# CONFIG_FONT_MINI_4x6 is not set
918# CONFIG_FONT_SUN8x16 is not set
919# CONFIG_FONT_SUN12x22 is not set
920# CONFIG_FONT_10x18 is not set
921
922#
923# Logo configuration
924#
925# CONFIG_LOGO is not set
926CONFIG_BACKLIGHT_LCD_SUPPORT=y
927CONFIG_BACKLIGHT_CLASS_DEVICE=y
928CONFIG_BACKLIGHT_DEVICE=y
929CONFIG_LCD_CLASS_DEVICE=y
930CONFIG_LCD_DEVICE=y
931CONFIG_BACKLIGHT_CORGI=y
932
933#
934# Sound
935#
936# CONFIG_SOUND is not set
937
938#
939# USB support
940#
941CONFIG_USB_ARCH_HAS_HCD=y
942CONFIG_USB_ARCH_HAS_OHCI=y
943CONFIG_USB=m
944# CONFIG_USB_DEBUG is not set
945
946#
947# Miscellaneous USB options
948#
949CONFIG_USB_DEVICEFS=y
950# CONFIG_USB_BANDWIDTH is not set
951# CONFIG_USB_DYNAMIC_MINORS is not set
952# CONFIG_USB_SUSPEND is not set
953# CONFIG_USB_OTG is not set
954
955#
956# USB Host Controller Drivers
957#
958# CONFIG_USB_ISP116X_HCD is not set
959CONFIG_USB_OHCI_HCD=m
960# CONFIG_USB_OHCI_BIG_ENDIAN is not set
961CONFIG_USB_OHCI_LITTLE_ENDIAN=y
962CONFIG_USB_SL811_HCD=m
963CONFIG_USB_SL811_CS=m
964
965#
966# USB Device Class drivers
967#
968
969#
970# USB Bluetooth TTY can only be used with disabled Bluetooth subsystem
971#
972CONFIG_USB_ACM=m
973CONFIG_USB_PRINTER=m
974
975#
976# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
977#
978CONFIG_USB_STORAGE=m
979# CONFIG_USB_STORAGE_DEBUG is not set
980# CONFIG_USB_STORAGE_DATAFAB is not set
981# CONFIG_USB_STORAGE_FREECOM is not set
982# CONFIG_USB_STORAGE_ISD200 is not set
983# CONFIG_USB_STORAGE_DPCM is not set
984# CONFIG_USB_STORAGE_USBAT is not set
985# CONFIG_USB_STORAGE_SDDR09 is not set
986# CONFIG_USB_STORAGE_SDDR55 is not set
987# CONFIG_USB_STORAGE_JUMPSHOT is not set
988# CONFIG_USB_STORAGE_ONETOUCH is not set
989
990#
991# USB Input Devices
992#
993CONFIG_USB_HID=m
994CONFIG_USB_HIDINPUT=y
995# CONFIG_HID_FF is not set
996# CONFIG_USB_HIDDEV is not set
997
998#
999# USB HID Boot Protocol drivers
1000#
1001CONFIG_USB_KBD=m
1002CONFIG_USB_MOUSE=m
1003CONFIG_USB_AIPTEK=m
1004CONFIG_USB_WACOM=m
1005# CONFIG_USB_ACECAD is not set
1006CONFIG_USB_KBTAB=m
1007CONFIG_USB_POWERMATE=m
1008CONFIG_USB_MTOUCH=m
1009# CONFIG_USB_ITMTOUCH is not set
1010CONFIG_USB_EGALAX=m
1011# CONFIG_USB_YEALINK is not set
1012CONFIG_USB_XPAD=m
1013CONFIG_USB_ATI_REMOTE=m
1014# CONFIG_USB_KEYSPAN_REMOTE is not set
1015# CONFIG_USB_APPLETOUCH is not set
1016
1017#
1018# USB Imaging devices
1019#
1020CONFIG_USB_MDC800=m
1021CONFIG_USB_MICROTEK=m
1022
1023#
1024# USB Multimedia devices
1025#
1026CONFIG_USB_DABUSB=m
1027
1028#
1029# Video4Linux support is needed for USB Multimedia device support
1030#
1031
1032#
1033# USB Network Adapters
1034#
1035CONFIG_USB_CATC=m
1036CONFIG_USB_KAWETH=m
1037CONFIG_USB_PEGASUS=m
1038CONFIG_USB_RTL8150=m
1039CONFIG_USB_USBNET=m
1040CONFIG_USB_NET_AX8817X=m
1041CONFIG_USB_NET_CDCETHER=m
1042# CONFIG_USB_NET_GL620A is not set
1043CONFIG_USB_NET_NET1080=m
1044# CONFIG_USB_NET_PLUSB is not set
1045# CONFIG_USB_NET_RNDIS_HOST is not set
1046# CONFIG_USB_NET_CDC_SUBSET is not set
1047CONFIG_USB_NET_ZAURUS=m
1048# CONFIG_USB_ZD1201 is not set
1049CONFIG_USB_MON=y
1050
1051#
1052# USB port drivers
1053#
1054
1055#
1056# USB Serial Converter support
1057#
1058CONFIG_USB_SERIAL=m
1059CONFIG_USB_SERIAL_GENERIC=y
1060# CONFIG_USB_SERIAL_AIRPRIME is not set
1061CONFIG_USB_SERIAL_BELKIN=m
1062# CONFIG_USB_SERIAL_WHITEHEAT is not set
1063CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
1064# CONFIG_USB_SERIAL_CP2101 is not set
1065CONFIG_USB_SERIAL_CYPRESS_M8=m
1066CONFIG_USB_SERIAL_EMPEG=m
1067CONFIG_USB_SERIAL_FTDI_SIO=m
1068CONFIG_USB_SERIAL_VISOR=m
1069CONFIG_USB_SERIAL_IPAQ=m
1070CONFIG_USB_SERIAL_IR=m
1071CONFIG_USB_SERIAL_EDGEPORT=m
1072CONFIG_USB_SERIAL_EDGEPORT_TI=m
1073CONFIG_USB_SERIAL_GARMIN=m
1074CONFIG_USB_SERIAL_IPW=m
1075CONFIG_USB_SERIAL_KEYSPAN_PDA=m
1076CONFIG_USB_SERIAL_KEYSPAN=m
1077# CONFIG_USB_SERIAL_KEYSPAN_MPR is not set
1078# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
1079# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
1080# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set
1081# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set
1082# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
1083# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
1084# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
1085# CONFIG_USB_SERIAL_KEYSPAN_USA19QW is not set
1086# CONFIG_USB_SERIAL_KEYSPAN_USA19QI is not set
1087# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
1088# CONFIG_USB_SERIAL_KEYSPAN_USA49WLC is not set
1089CONFIG_USB_SERIAL_KLSI=m
1090CONFIG_USB_SERIAL_KOBIL_SCT=m
1091CONFIG_USB_SERIAL_MCT_U232=m
1092CONFIG_USB_SERIAL_PL2303=m
1093# CONFIG_USB_SERIAL_HP4X is not set
1094CONFIG_USB_SERIAL_SAFE=m
1095# CONFIG_USB_SERIAL_SAFE_PADDED is not set
1096CONFIG_USB_SERIAL_TI=m
1097CONFIG_USB_SERIAL_CYBERJACK=m
1098CONFIG_USB_SERIAL_XIRCOM=m
1099# CONFIG_USB_SERIAL_OPTION is not set
1100CONFIG_USB_SERIAL_OMNINET=m
1101CONFIG_USB_EZUSB=y
1102
1103#
1104# USB Miscellaneous drivers
1105#
1106CONFIG_USB_EMI62=m
1107CONFIG_USB_EMI26=m
1108CONFIG_USB_AUERSWALD=m
1109CONFIG_USB_RIO500=m
1110CONFIG_USB_LEGOTOWER=m
1111CONFIG_USB_LCD=m
1112CONFIG_USB_LED=m
1113CONFIG_USB_CYTHERM=m
1114CONFIG_USB_PHIDGETKIT=m
1115CONFIG_USB_PHIDGETSERVO=m
1116CONFIG_USB_IDMOUSE=m
1117# CONFIG_USB_LD is not set
1118# CONFIG_USB_TEST is not set
1119
1120#
1121# USB DSL modem support
1122#
1123
1124#
1125# USB Gadget Support
1126#
1127CONFIG_USB_GADGET=m
1128# CONFIG_USB_GADGET_DEBUG_FILES is not set
1129CONFIG_USB_GADGET_SELECTED=y
1130# CONFIG_USB_GADGET_NET2280 is not set
1131# CONFIG_USB_GADGET_PXA2XX is not set
1132# CONFIG_USB_GADGET_GOKU is not set
1133# CONFIG_USB_GADGET_LH7A40X is not set
1134# CONFIG_USB_GADGET_OMAP is not set
1135CONFIG_USB_GADGET_DUMMY_HCD=y
1136CONFIG_USB_DUMMY_HCD=m
1137CONFIG_USB_GADGET_DUALSPEED=y
1138CONFIG_USB_ZERO=m
1139CONFIG_USB_ETH=m
1140CONFIG_USB_ETH_RNDIS=y
1141CONFIG_USB_GADGETFS=m
1142CONFIG_USB_FILE_STORAGE=m
1143# CONFIG_USB_FILE_STORAGE_TEST is not set
1144CONFIG_USB_G_SERIAL=m
1145
1146#
1147# MMC/SD Card support
1148#
1149CONFIG_MMC=y
1150# CONFIG_MMC_DEBUG is not set
1151CONFIG_MMC_BLOCK=y
1152CONFIG_MMC_PXA=y
1153# CONFIG_MMC_WBSD is not set
1154
1155#
1156# File systems
1157#
1158CONFIG_EXT2_FS=y
1159CONFIG_EXT2_FS_XATTR=y
1160CONFIG_EXT2_FS_POSIX_ACL=y
1161CONFIG_EXT2_FS_SECURITY=y
1162# CONFIG_EXT2_FS_XIP is not set
1163CONFIG_EXT3_FS=y
1164# CONFIG_EXT3_FS_XATTR is not set
1165CONFIG_JBD=y
1166# CONFIG_JBD_DEBUG is not set
1167CONFIG_FS_MBCACHE=y
1168# CONFIG_REISERFS_FS is not set
1169# CONFIG_JFS_FS is not set
1170CONFIG_FS_POSIX_ACL=y
1171# CONFIG_XFS_FS is not set
1172# CONFIG_MINIX_FS is not set
1173# CONFIG_ROMFS_FS is not set
1174CONFIG_INOTIFY=y
1175# CONFIG_QUOTA is not set
1176CONFIG_DNOTIFY=y
1177# CONFIG_AUTOFS_FS is not set
1178# CONFIG_AUTOFS4_FS is not set
1179# CONFIG_FUSE_FS is not set
1180
1181#
1182# CD-ROM/DVD Filesystems
1183#
1184# CONFIG_ISO9660_FS is not set
1185# CONFIG_UDF_FS is not set
1186
1187#
1188# DOS/FAT/NT Filesystems
1189#
1190CONFIG_FAT_FS=y
1191CONFIG_MSDOS_FS=y
1192CONFIG_VFAT_FS=y
1193CONFIG_FAT_DEFAULT_CODEPAGE=437
1194CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1195# CONFIG_NTFS_FS is not set
1196
1197#
1198# Pseudo filesystems
1199#
1200CONFIG_PROC_FS=y
1201CONFIG_SYSFS=y
1202CONFIG_TMPFS=y
1203# CONFIG_HUGETLB_PAGE is not set
1204CONFIG_RAMFS=y
1205# CONFIG_RELAYFS_FS is not set
1206
1207#
1208# Miscellaneous filesystems
1209#
1210# CONFIG_ADFS_FS is not set
1211# CONFIG_AFFS_FS is not set
1212# CONFIG_HFS_FS is not set
1213# CONFIG_HFSPLUS_FS is not set
1214# CONFIG_BEFS_FS is not set
1215# CONFIG_BFS_FS is not set
1216# CONFIG_EFS_FS is not set
1217# CONFIG_JFFS_FS is not set
1218CONFIG_JFFS2_FS=y
1219CONFIG_JFFS2_FS_DEBUG=0
1220CONFIG_JFFS2_FS_WRITEBUFFER=y
1221CONFIG_JFFS2_COMPRESSION_OPTIONS=y
1222CONFIG_JFFS2_ZLIB=y
1223CONFIG_JFFS2_RTIME=y
1224CONFIG_JFFS2_RUBIN=y
1225# CONFIG_JFFS2_CMODE_NONE is not set
1226CONFIG_JFFS2_CMODE_PRIORITY=y
1227# CONFIG_JFFS2_CMODE_SIZE is not set
1228CONFIG_CRAMFS=m
1229# CONFIG_VXFS_FS is not set
1230# CONFIG_HPFS_FS is not set
1231# CONFIG_QNX4FS_FS is not set
1232# CONFIG_SYSV_FS is not set
1233# CONFIG_UFS_FS is not set
1234
1235#
1236# Network File Systems
1237#
1238CONFIG_NFS_FS=m
1239CONFIG_NFS_V3=y
1240# CONFIG_NFS_V3_ACL is not set
1241CONFIG_NFS_V4=y
1242# CONFIG_NFS_DIRECTIO is not set
1243# CONFIG_NFSD is not set
1244CONFIG_LOCKD=m
1245CONFIG_LOCKD_V4=y
1246CONFIG_NFS_COMMON=y
1247CONFIG_SUNRPC=m
1248CONFIG_SUNRPC_GSS=m
1249CONFIG_RPCSEC_GSS_KRB5=m
1250# CONFIG_RPCSEC_GSS_SPKM3 is not set
1251CONFIG_SMB_FS=m
1252CONFIG_SMB_NLS_DEFAULT=y
1253CONFIG_SMB_NLS_REMOTE="cp437"
1254# CONFIG_CIFS is not set
1255# CONFIG_NCP_FS is not set
1256# CONFIG_CODA_FS is not set
1257# CONFIG_AFS_FS is not set
1258# CONFIG_9P_FS is not set
1259
1260#
1261# Partition Types
1262#
1263CONFIG_PARTITION_ADVANCED=y
1264# CONFIG_ACORN_PARTITION is not set
1265# CONFIG_OSF_PARTITION is not set
1266# CONFIG_AMIGA_PARTITION is not set
1267# CONFIG_ATARI_PARTITION is not set
1268# CONFIG_MAC_PARTITION is not set
1269CONFIG_MSDOS_PARTITION=y
1270# CONFIG_BSD_DISKLABEL is not set
1271# CONFIG_MINIX_SUBPARTITION is not set
1272# CONFIG_SOLARIS_X86_PARTITION is not set
1273# CONFIG_UNIXWARE_DISKLABEL is not set
1274# CONFIG_LDM_PARTITION is not set
1275# CONFIG_SGI_PARTITION is not set
1276# CONFIG_ULTRIX_PARTITION is not set
1277# CONFIG_SUN_PARTITION is not set
1278# CONFIG_EFI_PARTITION is not set
1279
1280#
1281# Native Language Support
1282#
1283CONFIG_NLS=y
1284CONFIG_NLS_DEFAULT="cp437"
1285CONFIG_NLS_CODEPAGE_437=y
1286# CONFIG_NLS_CODEPAGE_737 is not set
1287# CONFIG_NLS_CODEPAGE_775 is not set
1288# CONFIG_NLS_CODEPAGE_850 is not set
1289# CONFIG_NLS_CODEPAGE_852 is not set
1290# CONFIG_NLS_CODEPAGE_855 is not set
1291# CONFIG_NLS_CODEPAGE_857 is not set
1292# CONFIG_NLS_CODEPAGE_860 is not set
1293# CONFIG_NLS_CODEPAGE_861 is not set
1294# CONFIG_NLS_CODEPAGE_862 is not set
1295# CONFIG_NLS_CODEPAGE_863 is not set
1296# CONFIG_NLS_CODEPAGE_864 is not set
1297# CONFIG_NLS_CODEPAGE_865 is not set
1298# CONFIG_NLS_CODEPAGE_866 is not set
1299# CONFIG_NLS_CODEPAGE_869 is not set
1300# CONFIG_NLS_CODEPAGE_936 is not set
1301# CONFIG_NLS_CODEPAGE_950 is not set
1302# CONFIG_NLS_CODEPAGE_932 is not set
1303# CONFIG_NLS_CODEPAGE_949 is not set
1304# CONFIG_NLS_CODEPAGE_874 is not set
1305# CONFIG_NLS_ISO8859_8 is not set
1306# CONFIG_NLS_CODEPAGE_1250 is not set
1307# CONFIG_NLS_CODEPAGE_1251 is not set
1308# CONFIG_NLS_ASCII is not set
1309CONFIG_NLS_ISO8859_1=y
1310# CONFIG_NLS_ISO8859_2 is not set
1311# CONFIG_NLS_ISO8859_3 is not set
1312# CONFIG_NLS_ISO8859_4 is not set
1313# CONFIG_NLS_ISO8859_5 is not set
1314# CONFIG_NLS_ISO8859_6 is not set
1315# CONFIG_NLS_ISO8859_7 is not set
1316# CONFIG_NLS_ISO8859_9 is not set
1317# CONFIG_NLS_ISO8859_13 is not set
1318# CONFIG_NLS_ISO8859_14 is not set
1319# CONFIG_NLS_ISO8859_15 is not set
1320# CONFIG_NLS_KOI8_R is not set
1321# CONFIG_NLS_KOI8_U is not set
1322CONFIG_NLS_UTF8=y
1323
1324#
1325# Profiling support
1326#
1327CONFIG_PROFILING=y
1328CONFIG_OPROFILE=m
1329
1330#
1331# Kernel hacking
1332#
1333# CONFIG_PRINTK_TIME is not set
1334CONFIG_DEBUG_KERNEL=y
1335CONFIG_MAGIC_SYSRQ=y
1336CONFIG_LOG_BUF_SHIFT=14
1337CONFIG_DETECT_SOFTLOCKUP=y
1338# CONFIG_SCHEDSTATS is not set
1339# CONFIG_DEBUG_SLAB is not set
1340# CONFIG_DEBUG_PREEMPT is not set
1341# CONFIG_DEBUG_SPINLOCK is not set
1342# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1343# CONFIG_DEBUG_KOBJECT is not set
1344CONFIG_DEBUG_BUGVERBOSE=y
1345# CONFIG_DEBUG_INFO is not set
1346# CONFIG_DEBUG_FS is not set
1347CONFIG_FRAME_POINTER=y
1348# CONFIG_DEBUG_USER is not set
1349# CONFIG_DEBUG_WAITQ is not set
1350CONFIG_DEBUG_ERRORS=y
1351CONFIG_DEBUG_LL=y
1352# CONFIG_DEBUG_ICEDCC is not set
1353
1354#
1355# Security options
1356#
1357# CONFIG_KEYS is not set
1358# CONFIG_SECURITY is not set
1359
1360#
1361# Cryptographic options
1362#
1363CONFIG_CRYPTO=y
1364CONFIG_CRYPTO_HMAC=y
1365CONFIG_CRYPTO_NULL=m
1366CONFIG_CRYPTO_MD4=m
1367CONFIG_CRYPTO_MD5=m
1368CONFIG_CRYPTO_SHA1=m
1369CONFIG_CRYPTO_SHA256=m
1370CONFIG_CRYPTO_SHA512=m
1371CONFIG_CRYPTO_WP512=m
1372# CONFIG_CRYPTO_TGR192 is not set
1373CONFIG_CRYPTO_DES=m
1374CONFIG_CRYPTO_BLOWFISH=m
1375CONFIG_CRYPTO_TWOFISH=m
1376CONFIG_CRYPTO_SERPENT=m
1377CONFIG_CRYPTO_AES=m
1378CONFIG_CRYPTO_CAST5=m
1379CONFIG_CRYPTO_CAST6=m
1380CONFIG_CRYPTO_TEA=m
1381CONFIG_CRYPTO_ARC4=m
1382CONFIG_CRYPTO_KHAZAD=m
1383CONFIG_CRYPTO_ANUBIS=m
1384CONFIG_CRYPTO_DEFLATE=m
1385CONFIG_CRYPTO_MICHAEL_MIC=m
1386CONFIG_CRYPTO_CRC32C=m
1387CONFIG_CRYPTO_TEST=m
1388
1389#
1390# Hardware crypto devices
1391#
1392
1393#
1394# Library routines
1395#
1396CONFIG_CRC_CCITT=y
1397# CONFIG_CRC16 is not set
1398CONFIG_CRC32=y
1399CONFIG_LIBCRC32C=m
1400CONFIG_ZLIB_INFLATE=y
1401CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index 835d450797a1..7b17a87a3311 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -45,8 +45,8 @@ extern void fp_enter(void);
45 45
46#define EXPORT_SYMBOL_ALIAS(sym,orig) \ 46#define EXPORT_SYMBOL_ALIAS(sym,orig) \
47 EXPORT_CRC_ALIAS(sym) \ 47 EXPORT_CRC_ALIAS(sym) \
48 const struct kernel_symbol __ksymtab_##sym \ 48 static const struct kernel_symbol __ksymtab_##sym \
49 __attribute__((section("__ksymtab"))) = \ 49 __attribute_used__ __attribute__((section("__ksymtab"))) = \
50 { (unsigned long)&orig, #sym }; 50 { (unsigned long)&orig, #sym };
51 51
52/* 52/*
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 7152bfbee581..93b5e8e5292e 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -537,7 +537,7 @@ ENTRY(__switch_to)
537#ifdef CONFIG_CPU_MPCORE 537#ifdef CONFIG_CPU_MPCORE
538 clrex 538 clrex
539#else 539#else
540 strex r3, r4, [ip] @ Clear exclusive monitor 540 strex r5, r4, [ip] @ Clear exclusive monitor
541#endif 541#endif
542#endif 542#endif
543#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT) 543#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT)
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 81d450ac3fab..066597f4345a 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -106,15 +106,10 @@ ENTRY(ret_from_fork)
106 .endm 106 .endm
107 107
108.Larm700bug: 108.Larm700bug:
109 ldr r0, [sp, #S_PSR] @ Get calling cpsr
110 sub lr, lr, #4
111 str lr, [r8]
112 msr spsr_cxsf, r0
113 ldmia sp, {r0 - lr}^ @ Get calling r0 - lr 109 ldmia sp, {r0 - lr}^ @ Get calling r0 - lr
114 mov r0, r0 110 mov r0, r0
115 ldr lr, [sp, #S_PC] @ Get PC
116 add sp, sp, #S_FRAME_SIZE 111 add sp, sp, #S_FRAME_SIZE
117 movs pc, lr 112 subs pc, lr, #4
118#else 113#else
119 .macro arm710_bug_check, instr, temp 114 .macro arm710_bug_check, instr, temp
120 .endm 115 .endm
diff --git a/arch/arm/kernel/io.c b/arch/arm/kernel/io.c
index 6c20c1188b60..1f6822dfae74 100644
--- a/arch/arm/kernel/io.c
+++ b/arch/arm/kernel/io.c
@@ -7,7 +7,7 @@
7 * Copy data from IO memory space to "real" memory space. 7 * Copy data from IO memory space to "real" memory space.
8 * This needs to be optimized. 8 * This needs to be optimized.
9 */ 9 */
10void _memcpy_fromio(void *to, void __iomem *from, size_t count) 10void _memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
11{ 11{
12 unsigned char *t = to; 12 unsigned char *t = to;
13 while (count) { 13 while (count) {
@@ -22,7 +22,7 @@ void _memcpy_fromio(void *to, void __iomem *from, size_t count)
22 * Copy data from "real" memory space to IO memory space. 22 * Copy data from "real" memory space to IO memory space.
23 * This needs to be optimized. 23 * This needs to be optimized.
24 */ 24 */
25void _memcpy_toio(void __iomem *to, const void *from, size_t count) 25void _memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
26{ 26{
27 const unsigned char *f = from; 27 const unsigned char *f = from;
28 while (count) { 28 while (count) {
@@ -37,7 +37,7 @@ void _memcpy_toio(void __iomem *to, const void *from, size_t count)
37 * "memset" on IO memory space. 37 * "memset" on IO memory space.
38 * This needs to be optimized. 38 * This needs to be optimized.
39 */ 39 */
40void _memset_io(void __iomem *dst, int c, size_t count) 40void _memset_io(volatile void __iomem *dst, int c, size_t count)
41{ 41{
42 while (count) { 42 while (count) {
43 count--; 43 count--;
diff --git a/arch/arm/kernel/semaphore.c b/arch/arm/kernel/semaphore.c
index ac423e3e224b..4c31f2923055 100644
--- a/arch/arm/kernel/semaphore.c
+++ b/arch/arm/kernel/semaphore.c
@@ -178,7 +178,7 @@ int __down_trylock(struct semaphore * sem)
178 * registers (r0 to r3 and lr), but not ip, as we use it as a return 178 * registers (r0 to r3 and lr), but not ip, as we use it as a return
179 * value in some cases.. 179 * value in some cases..
180 */ 180 */
181asm(" .section .sched.text,\"ax\" \n\ 181asm(" .section .sched.text,\"ax\",%progbits \n\
182 .align 5 \n\ 182 .align 5 \n\
183 .globl __down_failed \n\ 183 .globl __down_failed \n\
184__down_failed: \n\ 184__down_failed: \n\
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 42629ff84f5a..ea569ba482b1 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -305,7 +305,7 @@ long execve(const char *filename, char **argv, char **envp)
305 "Ir" (THREAD_START_SP - sizeof(regs)), 305 "Ir" (THREAD_START_SP - sizeof(regs)),
306 "r" (&regs), 306 "r" (&regs),
307 "Ir" (sizeof(regs)) 307 "Ir" (sizeof(regs))
308 : "r0", "r1", "r2", "r3", "ip", "memory"); 308 : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
309 309
310 out: 310 out:
311 return ret; 311 return ret;
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 4554c961251c..f6de76e0a45d 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -504,7 +504,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
504 504
505 bad_access: 505 bad_access:
506 spin_unlock(&mm->page_table_lock); 506 spin_unlock(&mm->page_table_lock);
507 /* simulate a read access fault */ 507 /* simulate a write access fault */
508 do_DataAbort(addr, 15 + (1 << 11), regs); 508 do_DataAbort(addr, 15 + (1 << 11), regs);
509 return -1; 509 return -1;
510 } 510 }
@@ -624,6 +624,9 @@ void __attribute__((noreturn)) __bug(const char *file, int line, void *data)
624 printk(" - extra data = %p", data); 624 printk(" - extra data = %p", data);
625 printk("\n"); 625 printk("\n");
626 *(int *)0 = 0; 626 *(int *)0 = 0;
627
628 /* Avoid "noreturn function does return" */
629 for (;;);
627} 630}
628EXPORT_SYMBOL(__bug); 631EXPORT_SYMBOL(__bug);
629 632
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index ad2d66c93a5c..0d5db5279c5c 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -23,20 +23,20 @@ SECTIONS
23 *(.init.text) 23 *(.init.text)
24 _einittext = .; 24 _einittext = .;
25 __proc_info_begin = .; 25 __proc_info_begin = .;
26 *(.proc.info) 26 *(.proc.info.init)
27 __proc_info_end = .; 27 __proc_info_end = .;
28 __arch_info_begin = .; 28 __arch_info_begin = .;
29 *(.arch.info) 29 *(.arch.info.init)
30 __arch_info_end = .; 30 __arch_info_end = .;
31 __tagtable_begin = .; 31 __tagtable_begin = .;
32 *(.taglist) 32 *(.taglist.init)
33 __tagtable_end = .; 33 __tagtable_end = .;
34 . = ALIGN(16); 34 . = ALIGN(16);
35 __setup_start = .; 35 __setup_start = .;
36 *(.init.setup) 36 *(.init.setup)
37 __setup_end = .; 37 __setup_end = .;
38 __early_begin = .; 38 __early_begin = .;
39 *(__early_param) 39 *(.early_param.init)
40 __early_end = .; 40 __early_end = .;
41 __initcall_start = .; 41 __initcall_start = .;
42 *(.initcall1.init) 42 *(.initcall1.init)
@@ -89,13 +89,6 @@ SECTIONS
89 *(.got) /* Global offset table */ 89 *(.got) /* Global offset table */
90 } 90 }
91 91
92 . = ALIGN(16);
93 __ex_table : { /* Exception table */
94 __start___ex_table = .;
95 *(__ex_table)
96 __stop___ex_table = .;
97 }
98
99 RODATA 92 RODATA
100 93
101 _etext = .; /* End of text and rodata section */ 94 _etext = .; /* End of text and rodata section */
@@ -138,6 +131,14 @@ SECTIONS
138 *(.data.cacheline_aligned) 131 *(.data.cacheline_aligned)
139 132
140 /* 133 /*
134 * The exception fixup table (might need resorting at runtime)
135 */
136 . = ALIGN(32);
137 __start___ex_table = .;
138 *(__ex_table)
139 __stop___ex_table = .;
140
141 /*
141 * and the usual data section 142 * and the usual data section
142 */ 143 */
143 *(.data) 144 *(.data)
diff --git a/arch/arm/mach-clps711x/fortunet.c b/arch/arm/mach-clps711x/fortunet.c
index f83a59761e02..3d88da0c287b 100644
--- a/arch/arm/mach-clps711x/fortunet.c
+++ b/arch/arm/mach-clps711x/fortunet.c
@@ -31,6 +31,8 @@
31 31
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
33 33
34#include <asm/memory.h>
35
34#include "common.h" 36#include "common.h"
35 37
36struct meminfo memmap = { 38struct meminfo memmap = {
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index 41e5849ae8da..f8a742bb2d5b 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -28,14 +28,15 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <asm/arch/imxfb.h> 29#include <asm/arch/imxfb.h>
30#include <asm/hardware.h> 30#include <asm/hardware.h>
31#include <asm/arch/imx-regs.h>
31 32
32#include <asm/mach/map.h> 33#include <asm/mach/map.h>
33 34
34void imx_gpio_mode(int gpio_mode) 35void imx_gpio_mode(int gpio_mode)
35{ 36{
36 unsigned int pin = gpio_mode & GPIO_PIN_MASK; 37 unsigned int pin = gpio_mode & GPIO_PIN_MASK;
37 unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> 5; 38 unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
38 unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> 10; 39 unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT;
39 unsigned int tmp; 40 unsigned int tmp;
40 41
41 /* Pullup enable */ 42 /* Pullup enable */
@@ -57,7 +58,7 @@ void imx_gpio_mode(int gpio_mode)
57 GPR(port) &= ~(1<<pin); 58 GPR(port) &= ~(1<<pin);
58 59
59 /* use as gpio? */ 60 /* use as gpio? */
60 if( ocr == 3 ) 61 if(gpio_mode & GPIO_GIUS)
61 GIUS(port) |= (1<<pin); 62 GIUS(port) |= (1<<pin);
62 else 63 else
63 GIUS(port) &= ~(1<<pin); 64 GIUS(port) &= ~(1<<pin);
@@ -72,20 +73,20 @@ void imx_gpio_mode(int gpio_mode)
72 tmp |= (ocr << (pin*2)); 73 tmp |= (ocr << (pin*2));
73 OCR1(port) = tmp; 74 OCR1(port) = tmp;
74 75
75 if( gpio_mode & GPIO_AOUT ) 76 ICONFA1(port) &= ~( 3<<(pin*2));
76 ICONFA1(port) &= ~( 3<<(pin*2)); 77 ICONFA1(port) |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2);
77 if( gpio_mode & GPIO_BOUT ) 78 ICONFB1(port) &= ~( 3<<(pin*2));
78 ICONFB1(port) &= ~( 3<<(pin*2)); 79 ICONFB1(port) |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << (pin * 2);
79 } else { 80 } else {
80 tmp = OCR2(port); 81 tmp = OCR2(port);
81 tmp &= ~( 3<<((pin-16)*2)); 82 tmp &= ~( 3<<((pin-16)*2));
82 tmp |= (ocr << ((pin-16)*2)); 83 tmp |= (ocr << ((pin-16)*2));
83 OCR2(port) = tmp; 84 OCR2(port) = tmp;
84 85
85 if( gpio_mode & GPIO_AOUT ) 86 ICONFA2(port) &= ~( 3<<((pin-16)*2));
86 ICONFA2(port) &= ~( 3<<((pin-16)*2)); 87 ICONFA2(port) |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << ((pin-16) * 2);
87 if( gpio_mode & GPIO_BOUT ) 88 ICONFB2(port) &= ~( 3<<((pin-16)*2));
88 ICONFB2(port) &= ~( 3<<((pin-16)*2)); 89 ICONFB2(port) |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << ((pin-16) * 2);
89 } 90 }
90} 91}
91 92
diff --git a/arch/arm/mach-imx/leds-mx1ads.c b/arch/arm/mach-imx/leds-mx1ads.c
index e6399b06e4a4..79236404aec2 100644
--- a/arch/arm/mach-imx/leds-mx1ads.c
+++ b/arch/arm/mach-imx/leds-mx1ads.c
@@ -17,7 +17,6 @@
17#include <asm/system.h> 17#include <asm/system.h>
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/leds.h> 19#include <asm/leds.h>
20#include <asm/mach-types.h>
21#include "leds.h" 20#include "leds.h"
22 21
23/* 22/*
diff --git a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c
index 5d25434d332c..a7511ddfe364 100644
--- a/arch/arm/mach-imx/mx1ads.c
+++ b/arch/arm/mach-imx/mx1ads.c
@@ -55,7 +55,7 @@ static void __init
55mx1ads_init(void) 55mx1ads_init(void)
56{ 56{
57#ifdef CONFIG_LEDS 57#ifdef CONFIG_LEDS
58 imx_gpio_mode(GPIO_PORTA | GPIO_OUT | GPIO_GPIO | 2); 58 imx_gpio_mode(GPIO_PORTA | GPIO_OUT | 2);
59#endif 59#endif
60 platform_add_devices(devices, ARRAY_SIZE(devices)); 60 platform_add_devices(devices, ARRAY_SIZE(devices));
61} 61}
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index c3c2f17d030e..a1b153d1626c 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -67,7 +67,7 @@ static void impd1_setvco(struct clk *clk, struct icst525_vco vco)
67 } 67 }
68 writel(0, impd1->base + IMPD1_LOCK); 68 writel(0, impd1->base + IMPD1_LOCK);
69 69
70#if DEBUG 70#ifdef DEBUG
71 vco.v = val & 0x1ff; 71 vco.v = val & 0x1ff;
72 vco.r = (val >> 9) & 0x7f; 72 vco.r = (val >> 9) & 0x7f;
73 vco.s = (val >> 16) & 7; 73 vco.s = (val >> 16) & 7;
@@ -427,17 +427,18 @@ static int impd1_probe(struct lm_device *dev)
427 return ret; 427 return ret;
428} 428}
429 429
430static int impd1_remove_one(struct device *dev, void *data)
431{
432 device_unregister(dev);
433 return 0;
434}
435
430static void impd1_remove(struct lm_device *dev) 436static void impd1_remove(struct lm_device *dev)
431{ 437{
432 struct impd1_module *impd1 = lm_get_drvdata(dev); 438 struct impd1_module *impd1 = lm_get_drvdata(dev);
433 struct list_head *l, *n;
434 int i; 439 int i;
435 440
436 list_for_each_safe(l, n, &dev->dev.children) { 441 device_for_each_child(&dev->dev, NULL, impd1_remove_one);
437 struct device *d = list_to_dev(l);
438
439 device_unregister(d);
440 }
441 442
442 for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++) 443 for (i = 0; i < ARRAY_SIZE(impd1->vcos); i++)
443 clk_unregister(&impd1->vcos[i]); 444 clk_unregister(&impd1->vcos[i]);
diff --git a/arch/arm/mach-iop3xx/common.c b/arch/arm/mach-iop3xx/common.c
index bda7394ec06c..fdeeef489a73 100644
--- a/arch/arm/mach-iop3xx/common.c
+++ b/arch/arm/mach-iop3xx/common.c
@@ -27,7 +27,6 @@ unsigned long iop3xx_pcibios_min_mem = 0;
27/* 27/*
28 * Default power-off for EP80219 28 * Default power-off for EP80219
29 */ 29 */
30#include <asm/mach-types.h>
31 30
32static inline void ep80219_send_to_pic(__u8 c) { 31static inline void ep80219_send_to_pic(__u8 c) {
33} 32}
diff --git a/arch/arm/mach-iop3xx/iop321-time.c b/arch/arm/mach-iop3xx/iop321-time.c
index 0039793b694a..d67ac0e5d438 100644
--- a/arch/arm/mach-iop3xx/iop321-time.c
+++ b/arch/arm/mach-iop3xx/iop321-time.c
@@ -23,7 +23,6 @@
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/irq.h> 24#include <asm/irq.h>
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26#include <asm/mach-types.h>
27#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
28#include <asm/mach/time.h> 27#include <asm/mach/time.h>
29 28
diff --git a/arch/arm/mach-iop3xx/iop331-time.c b/arch/arm/mach-iop3xx/iop331-time.c
index 8eddfac7e2b0..3c1f0ebbd636 100644
--- a/arch/arm/mach-iop3xx/iop331-time.c
+++ b/arch/arm/mach-iop3xx/iop331-time.c
@@ -23,7 +23,6 @@
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/irq.h> 24#include <asm/irq.h>
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26#include <asm/mach-types.h>
27#include <asm/mach/irq.h> 26#include <asm/mach/irq.h>
28#include <asm/mach/time.h> 27#include <asm/mach/time.h>
29 28
diff --git a/arch/arm/mach-iop3xx/iq31244-mm.c b/arch/arm/mach-iop3xx/iq31244-mm.c
index b01042f7de71..55992ab586ba 100644
--- a/arch/arm/mach-iop3xx/iq31244-mm.c
+++ b/arch/arm/mach-iop3xx/iq31244-mm.c
@@ -21,7 +21,6 @@
21#include <asm/page.h> 21#include <asm/page.h>
22 22
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
24#include <asm/mach-types.h>
25 24
26 25
27/* 26/*
diff --git a/arch/arm/mach-iop3xx/iq80321-mm.c b/arch/arm/mach-iop3xx/iq80321-mm.c
index 1580c7ed2b9d..bb3e9e5a9aff 100644
--- a/arch/arm/mach-iop3xx/iq80321-mm.c
+++ b/arch/arm/mach-iop3xx/iq80321-mm.c
@@ -21,7 +21,6 @@
21#include <asm/page.h> 21#include <asm/page.h>
22 22
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
24#include <asm/mach-types.h>
25 24
26 25
27/* 26/*
diff --git a/arch/arm/mach-iop3xx/iq80331-mm.c b/arch/arm/mach-iop3xx/iq80331-mm.c
index ee8c333e115f..129eb49b0670 100644
--- a/arch/arm/mach-iop3xx/iq80331-mm.c
+++ b/arch/arm/mach-iop3xx/iq80331-mm.c
@@ -21,7 +21,6 @@
21#include <asm/page.h> 21#include <asm/page.h>
22 22
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
24#include <asm/mach-types.h>
25 24
26 25
27/* 26/*
diff --git a/arch/arm/mach-iop3xx/iq80332-mm.c b/arch/arm/mach-iop3xx/iq80332-mm.c
index 084afcdfb1eb..2feaf7591f53 100644
--- a/arch/arm/mach-iop3xx/iq80332-mm.c
+++ b/arch/arm/mach-iop3xx/iq80332-mm.c
@@ -21,7 +21,6 @@
21#include <asm/page.h> 21#include <asm/page.h>
22 22
23#include <asm/mach/map.h> 23#include <asm/mach/map.h>
24#include <asm/mach-types.h>
25 24
26 25
27/* 26/*
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index 74bd2fd602d4..f4d7f1f6ef85 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -30,7 +30,6 @@
30#include <asm/setup.h> 30#include <asm/setup.h>
31#include <asm/memory.h> 31#include <asm/memory.h>
32#include <asm/hardware.h> 32#include <asm/hardware.h>
33#include <asm/mach-types.h>
34#include <asm/irq.h> 33#include <asm/irq.h>
35#include <asm/system.h> 34#include <asm/system.h>
36#include <asm/tlbflush.h> 35#include <asm/tlbflush.h>
@@ -168,7 +167,7 @@ static struct plat_serial8250_port ixp2000_serial_port[] = {
168 167
169static struct resource ixp2000_uart_resource = { 168static struct resource ixp2000_uart_resource = {
170 .start = IXP2000_UART_PHYS_BASE, 169 .start = IXP2000_UART_PHYS_BASE,
171 .end = IXP2000_UART_PHYS_BASE + 0xffff, 170 .end = IXP2000_UART_PHYS_BASE + 0x1f,
172 .flags = IORESOURCE_MEM, 171 .flags = IORESOURCE_MEM,
173}; 172};
174 173
diff --git a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
index 0788fb2b5c10..522205acb316 100644
--- a/arch/arm/mach-ixp2000/pci.c
+++ b/arch/arm/mach-ixp2000/pci.c
@@ -28,7 +28,6 @@
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/system.h> 30#include <asm/system.h>
31#include <asm/mach-types.h>
32#include <asm/hardware.h> 31#include <asm/hardware.h>
33 32
34#include <asm/mach/pci.h> 33#include <asm/mach/pci.h>
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 52ad11328e96..36b6045213ee 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -125,7 +125,8 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
125 } else if (type & IRQT_LOW) { 125 } else if (type & IRQT_LOW) {
126 int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW; 126 int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW;
127 irq_type = IXP4XX_IRQ_LEVEL; 127 irq_type = IXP4XX_IRQ_LEVEL;
128 } 128 } else
129 return -EINVAL;
129 130
130 ixp4xx_config_irq(irq, irq_type); 131 ixp4xx_config_irq(irq, irq_type);
131 132
@@ -142,6 +143,8 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
142 143
143 /* Set the new style */ 144 /* Set the new style */
144 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE)); 145 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
146
147 return 0;
145} 148}
146 149
147static void ixp4xx_irq_mask(unsigned int irq) 150static void ixp4xx_irq_mask(unsigned int irq)
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index ae1fa099d5fa..0a41080d2266 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -123,6 +123,7 @@ static void __init ixdp425_init(void)
123 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices)); 123 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
124} 124}
125 125
126#ifdef CONFIG_ARCH_IXDP425
126MACHINE_START(IXDP425, "Intel IXDP425 Development Platform") 127MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
127 /* Maintainer: MontaVista Software, Inc. */ 128 /* Maintainer: MontaVista Software, Inc. */
128 .phys_ram = PHYS_OFFSET, 129 .phys_ram = PHYS_OFFSET,
@@ -134,7 +135,9 @@ MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
134 .boot_params = 0x0100, 135 .boot_params = 0x0100,
135 .init_machine = ixdp425_init, 136 .init_machine = ixdp425_init,
136MACHINE_END 137MACHINE_END
138#endif
137 139
140#ifdef CONFIG_MACH_IXDP465
138MACHINE_START(IXDP465, "Intel IXDP465 Development Platform") 141MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
139 /* Maintainer: MontaVista Software, Inc. */ 142 /* Maintainer: MontaVista Software, Inc. */
140 .phys_ram = PHYS_OFFSET, 143 .phys_ram = PHYS_OFFSET,
@@ -146,7 +149,9 @@ MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
146 .boot_params = 0x0100, 149 .boot_params = 0x0100,
147 .init_machine = ixdp425_init, 150 .init_machine = ixdp425_init,
148MACHINE_END 151MACHINE_END
152#endif
149 153
154#ifdef CONFIG_ARCH_PRPMC1100
150MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform") 155MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
151 /* Maintainer: MontaVista Software, Inc. */ 156 /* Maintainer: MontaVista Software, Inc. */
152 .phys_ram = PHYS_OFFSET, 157 .phys_ram = PHYS_OFFSET,
@@ -158,6 +163,7 @@ MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
158 .boot_params = 0x0100, 163 .boot_params = 0x0100,
159 .init_machine = ixdp425_init, 164 .init_machine = ixdp425_init,
160MACHINE_END 165MACHINE_END
166#endif
161 167
162/* 168/*
163 * Avila is functionally equivalent to IXDP425 except that it adds 169 * Avila is functionally equivalent to IXDP425 except that it adds
diff --git a/arch/arm/mach-l7200/core.c b/arch/arm/mach-l7200/core.c
index 2a7fee2a7635..03ed742ae2be 100644
--- a/arch/arm/mach-l7200/core.c
+++ b/arch/arm/mach-l7200/core.c
@@ -7,12 +7,17 @@
7 */ 7 */
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/device.h>
10 11
12#include <asm/types.h>
13#include <asm/irq.h>
14#include <asm/mach-types.h>
11#include <asm/hardware.h> 15#include <asm/hardware.h>
12#include <asm/page.h> 16#include <asm/page.h>
13 17
18#include <asm/mach/arch.h>
14#include <asm/mach/map.h> 19#include <asm/mach/map.h>
15#include <asm/arch/hardware.h> 20#include <asm/mach/irq.h>
16 21
17/* 22/*
18 * IRQ base register 23 * IRQ base register
@@ -48,6 +53,12 @@ static void l7200_unmask_irq(unsigned int irq)
48{ 53{
49 IRQ_ENABLE = 1 << irq; 54 IRQ_ENABLE = 1 << irq;
50} 55}
56
57static struct irqchip l7200_irq_chip = {
58 .ack = l7200_mask_irq,
59 .mask = l7200_mask_irq,
60 .unmask = l7200_unmask_irq
61};
51 62
52static void __init l7200_init_irq(void) 63static void __init l7200_init_irq(void)
53{ 64{
@@ -57,11 +68,9 @@ static void __init l7200_init_irq(void)
57 FIQ_ENABLECLEAR = 0xffffffff; /* clear all fast interrupt enables */ 68 FIQ_ENABLECLEAR = 0xffffffff; /* clear all fast interrupt enables */
58 69
59 for (irq = 0; irq < NR_IRQS; irq++) { 70 for (irq = 0; irq < NR_IRQS; irq++) {
60 irq_desc[irq].valid = 1; 71 set_irq_chip(irq, &l7200_irq_chip);
61 irq_desc[irq].probe_ok = 1; 72 set_irq_flags(irq, IRQF_VALID);
62 irq_desc[irq].mask_ack = l7200_mask_irq; 73 set_irq_handler(irq, do_level_IRQ);
63 irq_desc[irq].mask = l7200_mask_irq;
64 irq_desc[irq].unmask = l7200_unmask_irq;
65 } 74 }
66 75
67 init_FIQ(); 76 init_FIQ();
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index be37586cb1b0..60c8b9d8bb9c 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -36,6 +36,7 @@
36#include <asm/arch/mmc.h> 36#include <asm/arch/mmc.h>
37#include <asm/arch/udc.h> 37#include <asm/arch/udc.h>
38#include <asm/arch/corgi.h> 38#include <asm/arch/corgi.h>
39#include <asm/arch/sharpsl.h>
39 40
40#include <asm/mach/sharpsl_param.h> 41#include <asm/mach/sharpsl_param.h>
41#include <asm/hardware/scoop.h> 42#include <asm/hardware/scoop.h>
diff --git a/arch/arm/mach-pxa/corgi_lcd.c b/arch/arm/mach-pxa/corgi_lcd.c
index c5efcd04fcbc..370df113dc06 100644
--- a/arch/arm/mach-pxa/corgi_lcd.c
+++ b/arch/arm/mach-pxa/corgi_lcd.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <asm/mach-types.h>
23#include <asm/arch/akita.h> 22#include <asm/arch/akita.h>
24#include <asm/arch/corgi.h> 23#include <asm/arch/corgi.h>
25#include <asm/arch/hardware.h> 24#include <asm/arch/hardware.h>
@@ -468,6 +467,7 @@ void corgi_put_hsync(void)
468{ 467{
469 if (get_hsync_time) 468 if (get_hsync_time)
470 symbol_put(w100fb_get_hsynclen); 469 symbol_put(w100fb_get_hsynclen);
470 get_hsync_time = NULL;
471} 471}
472 472
473void corgi_wait_hsync(void) 473void corgi_wait_hsync(void)
@@ -477,20 +477,39 @@ void corgi_wait_hsync(void)
477#endif 477#endif
478 478
479#ifdef CONFIG_PXA_SHARP_Cxx00 479#ifdef CONFIG_PXA_SHARP_Cxx00
480static struct device *spitz_pxafb_dev;
481
482static int is_pxafb_device(struct device * dev, void * data)
483{
484 struct platform_device *pdev = container_of(dev, struct platform_device, dev);
485
486 return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0);
487}
488
480unsigned long spitz_get_hsync_len(void) 489unsigned long spitz_get_hsync_len(void)
481{ 490{
491#ifdef CONFIG_FB_PXA
492 if (!spitz_pxafb_dev) {
493 spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device);
494 if (!spitz_pxafb_dev)
495 return 0;
496 }
482 if (!get_hsync_time) 497 if (!get_hsync_time)
483 get_hsync_time = symbol_get(pxafb_get_hsync_time); 498 get_hsync_time = symbol_get(pxafb_get_hsync_time);
484 if (!get_hsync_time) 499 if (!get_hsync_time)
500#endif
485 return 0; 501 return 0;
486 502
487 return pxafb_get_hsync_time(&pxafb_device.dev); 503 return pxafb_get_hsync_time(spitz_pxafb_dev);
488} 504}
489 505
490void spitz_put_hsync(void) 506void spitz_put_hsync(void)
491{ 507{
508 put_device(spitz_pxafb_dev);
492 if (get_hsync_time) 509 if (get_hsync_time)
493 symbol_put(pxafb_get_hsync_time); 510 symbol_put(pxafb_get_hsync_time);
511 spitz_pxafb_dev = NULL;
512 get_hsync_time = NULL;
494} 513}
495 514
496void spitz_wait_hsync(void) 515void spitz_wait_hsync(void)
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index a45aaa115a76..1d7677669a76 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -34,6 +34,7 @@
34#include <asm/arch/udc.h> 34#include <asm/arch/udc.h>
35#include <asm/arch/pxafb.h> 35#include <asm/arch/pxafb.h>
36#include <asm/arch/mmc.h> 36#include <asm/arch/mmc.h>
37#include <asm/arch/i2c.h>
37 38
38#include "generic.h" 39#include "generic.h"
39 40
@@ -207,6 +208,11 @@ static struct platform_device pxafb_device = {
207 .resource = pxafb_resources, 208 .resource = pxafb_resources,
208}; 209};
209 210
211void __init set_pxa_fb_parent(struct device *parent_dev)
212{
213 pxafb_device.dev.parent = parent_dev;
214}
215
210static struct platform_device ffuart_device = { 216static struct platform_device ffuart_device = {
211 .name = "pxa2xx-uart", 217 .name = "pxa2xx-uart",
212 .id = 0, 218 .id = 0,
@@ -244,6 +250,25 @@ void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
244 i2c_device.dev.platform_data = info; 250 i2c_device.dev.platform_data = info;
245} 251}
246 252
253static struct resource i2s_resources[] = {
254 {
255 .start = 0x40400000,
256 .end = 0x40400083,
257 .flags = IORESOURCE_MEM,
258 }, {
259 .start = IRQ_I2S,
260 .end = IRQ_I2S,
261 .flags = IORESOURCE_IRQ,
262 },
263};
264
265static struct platform_device i2s_device = {
266 .name = "pxa2xx-i2s",
267 .id = -1,
268 .resource = i2c_resources,
269 .num_resources = ARRAY_SIZE(i2s_resources),
270};
271
247static struct platform_device *devices[] __initdata = { 272static struct platform_device *devices[] __initdata = {
248 &pxamci_device, 273 &pxamci_device,
249 &udc_device, 274 &udc_device,
@@ -252,6 +277,7 @@ static struct platform_device *devices[] __initdata = {
252 &btuart_device, 277 &btuart_device,
253 &stuart_device, 278 &stuart_device,
254 &i2c_device, 279 &i2c_device,
280 &i2s_device,
255}; 281};
256 282
257static int __init pxa_init(void) 283static int __init pxa_init(void)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 568afe3d6e1a..d0ab428c2d7d 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -36,7 +36,6 @@
36#include <asm/arch/irq.h> 36#include <asm/arch/irq.h>
37#include <asm/arch/mmc.h> 37#include <asm/arch/mmc.h>
38#include <asm/arch/udc.h> 38#include <asm/arch/udc.h>
39#include <asm/arch/ohci.h>
40#include <asm/arch/pxafb.h> 39#include <asm/arch/pxafb.h>
41#include <asm/arch/akita.h> 40#include <asm/arch/akita.h>
42#include <asm/arch/spitz.h> 41#include <asm/arch/spitz.h>
@@ -304,7 +303,6 @@ static struct platform_device *devices[] __initdata = {
304 &spitzkbd_device, 303 &spitzkbd_device,
305 &spitzts_device, 304 &spitzts_device,
306 &spitzbl_device, 305 &spitzbl_device,
307 &spitzbattery_device,
308}; 306};
309 307
310static void __init common_init(void) 308static void __init common_init(void)
@@ -328,7 +326,7 @@ static void __init common_init(void)
328 326
329 platform_add_devices(devices, ARRAY_SIZE(devices)); 327 platform_add_devices(devices, ARRAY_SIZE(devices));
330 pxa_set_mci_info(&spitz_mci_platform_data); 328 pxa_set_mci_info(&spitz_mci_platform_data);
331 pxafb_device.dev.parent = &spitzssp_device.dev; 329 set_pxa_fb_parent(&spitzssp_device.dev);
332 set_pxa_fb_info(&spitz_pxafb_info); 330 set_pxa_fb_info(&spitz_pxafb_info);
333} 331}
334 332
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index 06807c6ee68a..c796bcdd6158 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -12,6 +12,7 @@ config MACH_ANUBIS
12config ARCH_BAST 12config ARCH_BAST
13 bool "Simtec Electronics BAST (EB2410ITX)" 13 bool "Simtec Electronics BAST (EB2410ITX)"
14 select CPU_S3C2410 14 select CPU_S3C2410
15 select ISA
15 help 16 help
16 Say Y here if you are using the Simtec Electronics EB2410ITX 17 Say Y here if you are using the Simtec Electronics EB2410ITX
17 development board (also known as BAST) 18 development board (also known as BAST)
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index f59608268751..8b3d5dc35de5 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -98,7 +98,10 @@ struct clk *clk_get(struct device *dev, const char *id)
98 struct clk *clk = ERR_PTR(-ENOENT); 98 struct clk *clk = ERR_PTR(-ENOENT);
99 int idno; 99 int idno;
100 100
101 idno = (dev == NULL) ? -1 : to_platform_device(dev)->id; 101 if (dev == NULL || dev->bus != &platform_bus_type)
102 idno = -1;
103 else
104 idno = to_platform_device(dev)->id;
102 105
103 down(&clocks_sem); 106 down(&clocks_sem);
104 107
diff --git a/arch/arm/mach-s3c2410/mach-anubis.c b/arch/arm/mach-s3c2410/mach-anubis.c
index f87aa0b669ad..5ae80f4e3e67 100644
--- a/arch/arm/mach-s3c2410/mach-anubis.c
+++ b/arch/arm/mach-s3c2410/mach-anubis.c
@@ -12,6 +12,7 @@
12 * 12 *
13 * Modifications: 13 * Modifications:
14 * 02-May-2005 BJD Copied from mach-bast.c 14 * 02-May-2005 BJD Copied from mach-bast.c
15 * 20-Sep-2005 BJD Added static to non-exported items
15*/ 16*/
16 17
17#include <linux/kernel.h> 18#include <linux/kernel.h>
@@ -124,7 +125,7 @@ static int external_map[] = { 2 };
124static int chip0_map[] = { 0 }; 125static int chip0_map[] = { 0 };
125static int chip1_map[] = { 1 }; 126static int chip1_map[] = { 1 };
126 127
127struct mtd_partition anubis_default_nand_part[] = { 128static struct mtd_partition anubis_default_nand_part[] = {
128 [0] = { 129 [0] = {
129 .name = "Boot Agent", 130 .name = "Boot Agent",
130 .size = SZ_16K, 131 .size = SZ_16K,
@@ -232,7 +233,7 @@ static struct s3c24xx_board anubis_board __initdata = {
232 .clocks_count = ARRAY_SIZE(anubis_clocks) 233 .clocks_count = ARRAY_SIZE(anubis_clocks)
233}; 234};
234 235
235void __init anubis_map_io(void) 236static void __init anubis_map_io(void)
236{ 237{
237 /* initialise the clocks */ 238 /* initialise the clocks */
238 239
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index 1a3367da6408..7b51bfd0ba6d 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -31,6 +31,7 @@
31 * 17-Jul-2005 BJD Changed to platform device for SuperIO 16550s 31 * 17-Jul-2005 BJD Changed to platform device for SuperIO 16550s
32 * 25-Jul-2005 BJD Removed ASIX static mappings 32 * 25-Jul-2005 BJD Removed ASIX static mappings
33 * 27-Jul-2005 BJD Ensure maximum frequency of i2c bus 33 * 27-Jul-2005 BJD Ensure maximum frequency of i2c bus
34 * 20-Sep-2005 BJD Added static to non-exported items
34*/ 35*/
35 36
36#include <linux/kernel.h> 37#include <linux/kernel.h>
@@ -229,7 +230,7 @@ static int chip0_map[] = { 1 };
229static int chip1_map[] = { 2 }; 230static int chip1_map[] = { 2 };
230static int chip2_map[] = { 3 }; 231static int chip2_map[] = { 3 };
231 232
232struct mtd_partition bast_default_nand_part[] = { 233static struct mtd_partition bast_default_nand_part[] = {
233 [0] = { 234 [0] = {
234 .name = "Boot Agent", 235 .name = "Boot Agent",
235 .size = SZ_16K, 236 .size = SZ_16K,
@@ -306,9 +307,9 @@ static void bast_nand_select(struct s3c2410_nand_set *set, int slot)
306} 307}
307 308
308static struct s3c2410_platform_nand bast_nand_info = { 309static struct s3c2410_platform_nand bast_nand_info = {
309 .tacls = 40, 310 .tacls = 30,
310 .twrph0 = 80, 311 .twrph0 = 60,
311 .twrph1 = 80, 312 .twrph1 = 60,
312 .nr_sets = ARRAY_SIZE(bast_nand_sets), 313 .nr_sets = ARRAY_SIZE(bast_nand_sets),
313 .sets = bast_nand_sets, 314 .sets = bast_nand_sets,
314 .select_chip = bast_nand_select, 315 .select_chip = bast_nand_select,
@@ -339,7 +340,7 @@ static struct resource bast_dm9k_resource[] = {
339 * better IO routines can be written and tested 340 * better IO routines can be written and tested
340*/ 341*/
341 342
342struct dm9000_plat_data bast_dm9k_platdata = { 343static struct dm9000_plat_data bast_dm9k_platdata = {
343 .flags = DM9000_PLATF_16BITONLY 344 .flags = DM9000_PLATF_16BITONLY
344}; 345};
345 346
@@ -428,7 +429,7 @@ static struct s3c24xx_board bast_board __initdata = {
428 .clocks_count = ARRAY_SIZE(bast_clocks) 429 .clocks_count = ARRAY_SIZE(bast_clocks)
429}; 430};
430 431
431void __init bast_map_io(void) 432static void __init bast_map_io(void)
432{ 433{
433 /* initialise the clocks */ 434 /* initialise the clocks */
434 435
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 6ff1889fbd21..fb3cb01266e5 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -24,6 +24,7 @@
24 * 10-Jan-2005 BJD Removed include of s3c2410.h 24 * 10-Jan-2005 BJD Removed include of s3c2410.h
25 * 14-Jan-2005 BJD Added clock init 25 * 14-Jan-2005 BJD Added clock init
26 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 26 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
27 * 20-Sep-2005 BJD Added static to non-exported items
27*/ 28*/
28 29
29#include <linux/kernel.h> 30#include <linux/kernel.h>
@@ -147,7 +148,7 @@ static struct s3c24xx_board h1940_board __initdata = {
147 .devices_count = ARRAY_SIZE(h1940_devices) 148 .devices_count = ARRAY_SIZE(h1940_devices)
148}; 149};
149 150
150void __init h1940_map_io(void) 151static void __init h1940_map_io(void)
151{ 152{
152 s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc)); 153 s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
153 s3c24xx_init_clocks(0); 154 s3c24xx_init_clocks(0);
@@ -155,13 +156,13 @@ void __init h1940_map_io(void)
155 s3c24xx_set_board(&h1940_board); 156 s3c24xx_set_board(&h1940_board);
156} 157}
157 158
158void __init h1940_init_irq(void) 159static void __init h1940_init_irq(void)
159{ 160{
160 s3c24xx_init_irq(); 161 s3c24xx_init_irq();
161 162
162} 163}
163 164
164void __init h1940_init(void) 165static void __init h1940_init(void)
165{ 166{
166 set_s3c2410fb_info(&h1940_lcdcfg); 167 set_s3c2410fb_info(&h1940_lcdcfg);
167} 168}
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 66bf5bb2b3db..5c0f2b091f95 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -97,7 +97,7 @@ static struct s3c24xx_board n30_board __initdata = {
97 .devices_count = ARRAY_SIZE(n30_devices) 97 .devices_count = ARRAY_SIZE(n30_devices)
98}; 98};
99 99
100void __init n30_map_io(void) 100static void __init n30_map_io(void)
101{ 101{
102 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc)); 102 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
103 s3c24xx_init_clocks(0); 103 s3c24xx_init_clocks(0);
@@ -105,14 +105,14 @@ void __init n30_map_io(void)
105 s3c24xx_set_board(&n30_board); 105 s3c24xx_set_board(&n30_board);
106} 106}
107 107
108void __init n30_init_irq(void) 108static void __init n30_init_irq(void)
109{ 109{
110 s3c24xx_init_irq(); 110 s3c24xx_init_irq();
111} 111}
112 112
113/* GPB3 is the line that controls the pull-up for the USB D+ line */ 113/* GPB3 is the line that controls the pull-up for the USB D+ line */
114 114
115void __init n30_init(void) 115static void __init n30_init(void)
116{ 116{
117 s3c_device_i2c.dev.platform_data = &n30_i2ccfg; 117 s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
118 118
diff --git a/arch/arm/mach-s3c2410/mach-nexcoder.c b/arch/arm/mach-s3c2410/mach-nexcoder.c
index d24c242414ca..c22f8216032d 100644
--- a/arch/arm/mach-s3c2410/mach-nexcoder.c
+++ b/arch/arm/mach-s3c2410/mach-nexcoder.c
@@ -136,7 +136,7 @@ static void __init nexcoder_sensorboard_init(void)
136 s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_OUTP); // CAM_GPIO6 => CAM_PWRDN 136 s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_OUTP); // CAM_GPIO6 => CAM_PWRDN
137} 137}
138 138
139void __init nexcoder_map_io(void) 139static void __init nexcoder_map_io(void)
140{ 140{
141 s3c24xx_init_io(nexcoder_iodesc, ARRAY_SIZE(nexcoder_iodesc)); 141 s3c24xx_init_io(nexcoder_iodesc, ARRAY_SIZE(nexcoder_iodesc));
142 s3c24xx_init_clocks(0); 142 s3c24xx_init_clocks(0);
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c2410/mach-otom.c
index d901ed492ff5..ad1459e402e2 100644
--- a/arch/arm/mach-s3c2410/mach-otom.c
+++ b/arch/arm/mach-s3c2410/mach-otom.c
@@ -105,7 +105,7 @@ static struct s3c24xx_board otom11_board __initdata = {
105}; 105};
106 106
107 107
108void __init otom11_map_io(void) 108static void __init otom11_map_io(void)
109{ 109{
110 s3c24xx_init_io(otom11_iodesc, ARRAY_SIZE(otom11_iodesc)); 110 s3c24xx_init_io(otom11_iodesc, ARRAY_SIZE(otom11_iodesc));
111 s3c24xx_init_clocks(0); 111 s3c24xx_init_clocks(0);
diff --git a/arch/arm/mach-s3c2410/mach-rx3715.c b/arch/arm/mach-s3c2410/mach-rx3715.c
index a73d61c1de46..22d9e070fd68 100644
--- a/arch/arm/mach-s3c2410/mach-rx3715.c
+++ b/arch/arm/mach-s3c2410/mach-rx3715.c
@@ -16,6 +16,7 @@
16 * 14-Jan-2005 BJD Added new clock init 16 * 14-Jan-2005 BJD Added new clock init
17 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 17 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
18 * 14-Mar-2005 BJD Fixed __iomem warnings 18 * 14-Mar-2005 BJD Fixed __iomem warnings
19 * 20-Sep-2005 BJD Added static to non-exported items
19*/ 20*/
20 21
21#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -108,7 +109,7 @@ static struct s3c24xx_board rx3715_board __initdata = {
108 .devices_count = ARRAY_SIZE(rx3715_devices) 109 .devices_count = ARRAY_SIZE(rx3715_devices)
109}; 110};
110 111
111void __init rx3715_map_io(void) 112static void __init rx3715_map_io(void)
112{ 113{
113 s3c24xx_init_io(rx3715_iodesc, ARRAY_SIZE(rx3715_iodesc)); 114 s3c24xx_init_io(rx3715_iodesc, ARRAY_SIZE(rx3715_iodesc));
114 s3c24xx_init_clocks(16934000); 115 s3c24xx_init_clocks(16934000);
@@ -116,7 +117,7 @@ void __init rx3715_map_io(void)
116 s3c24xx_set_board(&rx3715_board); 117 s3c24xx_set_board(&rx3715_board);
117} 118}
118 119
119void __init rx3715_init_irq(void) 120static void __init rx3715_init_irq(void)
120{ 121{
121 s3c24xx_init_irq(); 122 s3c24xx_init_irq();
122} 123}
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
index 67e903a700d3..2eda55a6b678 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c
@@ -28,6 +28,7 @@
28 * Ben Dooks <ben@simtec.co.uk> 28 * Ben Dooks <ben@simtec.co.uk>
29 * 29 *
30 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 30 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
31 * 20-Sep-2005 BJD Added static to non-exported items
31 * 32 *
32 ***********************************************************************/ 33 ***********************************************************************/
33 34
@@ -97,7 +98,7 @@ static struct s3c24xx_board smdk2410_board __initdata = {
97 .devices_count = ARRAY_SIZE(smdk2410_devices) 98 .devices_count = ARRAY_SIZE(smdk2410_devices)
98}; 99};
99 100
100void __init smdk2410_map_io(void) 101static void __init smdk2410_map_io(void)
101{ 102{
102 s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc)); 103 s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
103 s3c24xx_init_clocks(0); 104 s3c24xx_init_clocks(0);
@@ -105,7 +106,7 @@ void __init smdk2410_map_io(void)
105 s3c24xx_set_board(&smdk2410_board); 106 s3c24xx_set_board(&smdk2410_board);
106} 107}
107 108
108void __init smdk2410_init_irq(void) 109static void __init smdk2410_init_irq(void)
109{ 110{
110 s3c24xx_init_irq(); 111 s3c24xx_init_irq();
111} 112}
diff --git a/arch/arm/mach-s3c2410/mach-smdk2440.c b/arch/arm/mach-s3c2410/mach-smdk2440.c
index 357522106f68..722ef46b630a 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2440.c
@@ -18,6 +18,7 @@
18 * 22-Feb-2005 BJD Updated for 2.6.11-rc5 relesa 18 * 22-Feb-2005 BJD Updated for 2.6.11-rc5 relesa
19 * 10-Mar-2005 LCVR Replaced S3C2410_VA by S3C24XX_VA 19 * 10-Mar-2005 LCVR Replaced S3C2410_VA by S3C24XX_VA
20 * 14-Mar-2005 BJD void __iomem fixes 20 * 14-Mar-2005 BJD void __iomem fixes
21 * 20-Sep-2005 BJD Added static to non-exported items
21*/ 22*/
22 23
23#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -98,7 +99,7 @@ static struct s3c24xx_board smdk2440_board __initdata = {
98 .devices_count = ARRAY_SIZE(smdk2440_devices) 99 .devices_count = ARRAY_SIZE(smdk2440_devices)
99}; 100};
100 101
101void __init smdk2440_map_io(void) 102static void __init smdk2440_map_io(void)
102{ 103{
103 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc)); 104 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
104 s3c24xx_init_clocks(16934400); 105 s3c24xx_init_clocks(16934400);
@@ -106,7 +107,7 @@ void __init smdk2440_map_io(void)
106 s3c24xx_set_board(&smdk2440_board); 107 s3c24xx_set_board(&smdk2440_board);
107} 108}
108 109
109void __init smdk2440_machine_init(void) 110static void __init smdk2440_machine_init(void)
110{ 111{
111 /* Configure the LEDs (even if we have no LED support)*/ 112 /* Configure the LEDs (even if we have no LED support)*/
112 113
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
index 8f9ab2893df4..46b259673c18 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c
@@ -28,6 +28,7 @@
28 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 28 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
29 * 14-Mar-2006 BJD void __iomem fixes 29 * 14-Mar-2006 BJD void __iomem fixes
30 * 22-Jun-2006 BJD Added DM9000 platform information 30 * 22-Jun-2006 BJD Added DM9000 platform information
31 * 20-Sep-2005 BJD Added static to non-exported items
31*/ 32*/
32 33
33#include <linux/kernel.h> 34#include <linux/kernel.h>
@@ -287,7 +288,7 @@ static struct resource vr1000_dm9k1_resource[] = {
287 * better IO routines can be written and tested 288 * better IO routines can be written and tested
288*/ 289*/
289 290
290struct dm9000_plat_data vr1000_dm9k_platdata = { 291static struct dm9000_plat_data vr1000_dm9k_platdata = {
291 .flags = DM9000_PLATF_16BITONLY, 292 .flags = DM9000_PLATF_16BITONLY,
292}; 293};
293 294
@@ -347,7 +348,7 @@ static void vr1000_power_off(void)
347 s3c2410_gpio_setpin(S3C2410_GPB9, 1); 348 s3c2410_gpio_setpin(S3C2410_GPB9, 1);
348} 349}
349 350
350void __init vr1000_map_io(void) 351static void __init vr1000_map_io(void)
351{ 352{
352 /* initialise clock sources */ 353 /* initialise clock sources */
353 354
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
index 0b88993dfd27..a8bf5ec82602 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c2410/s3c2410.c
@@ -125,9 +125,6 @@ static struct platform_device *uart_devices[] __initdata = {
125 &s3c_uart2 125 &s3c_uart2
126}; 126};
127 127
128/* store our uart devices for the serial driver console */
129struct platform_device *s3c2410_uart_devices[3];
130
131static int s3c2410_uart_count = 0; 128static int s3c2410_uart_count = 0;
132 129
133/* uart registration process */ 130/* uart registration process */
diff --git a/arch/arm/mach-s3c2410/s3c2440.c b/arch/arm/mach-s3c2410/s3c2440.c
index d4c8281b55f6..833fa36bce05 100644
--- a/arch/arm/mach-s3c2410/s3c2440.c
+++ b/arch/arm/mach-s3c2410/s3c2440.c
@@ -151,7 +151,7 @@ void __init s3c2440_init_uarts(struct s3c2410_uartcfg *cfg, int no)
151 151
152#ifdef CONFIG_PM 152#ifdef CONFIG_PM
153 153
154struct sleep_save s3c2440_sleep[] = { 154static struct sleep_save s3c2440_sleep[] = {
155 SAVE_ITEM(S3C2440_DSC0), 155 SAVE_ITEM(S3C2440_DSC0),
156 SAVE_ITEM(S3C2440_DSC1), 156 SAVE_ITEM(S3C2440_DSC1),
157 SAVE_ITEM(S3C2440_GPJDAT), 157 SAVE_ITEM(S3C2440_GPJDAT),
@@ -260,7 +260,7 @@ void __init s3c2440_init_clocks(int xtal)
260 * as a driver which may support both 2410 and 2440 may try and use it. 260 * as a driver which may support both 2410 and 2440 may try and use it.
261*/ 261*/
262 262
263int __init s3c2440_core_init(void) 263static int __init s3c2440_core_init(void)
264{ 264{
265 return sysdev_class_register(&s3c2440_sysclass); 265 return sysdev_class_register(&s3c2440_sysclass);
266} 266}
diff --git a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c
index c0acfb2ad790..8a00e3c3cd08 100644
--- a/arch/arm/mach-s3c2410/time.c
+++ b/arch/arm/mach-s3c2410/time.c
@@ -38,6 +38,7 @@
38#include <asm/hardware/clock.h> 38#include <asm/hardware/clock.h>
39 39
40#include "clock.h" 40#include "clock.h"
41#include "cpu.h"
41 42
42static unsigned long timer_startval; 43static unsigned long timer_startval;
43static unsigned long timer_usec_ticks; 44static unsigned long timer_usec_ticks;
diff --git a/arch/arm/mach-s3c2410/usb-simtec.c b/arch/arm/mach-s3c2410/usb-simtec.c
index f021fd82be52..5098b50158a3 100644
--- a/arch/arm/mach-s3c2410/usb-simtec.c
+++ b/arch/arm/mach-s3c2410/usb-simtec.c
@@ -40,7 +40,6 @@
40#include <asm/hardware.h> 40#include <asm/hardware.h>
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/irq.h> 42#include <asm/irq.h>
43#include <asm/mach-types.h>
44 43
45#include "devs.h" 44#include "devs.h"
46#include "usb-simtec.h" 45#include "usb-simtec.h"
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 25d6a4e27533..6ecab7e2c238 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -111,11 +111,11 @@ static struct mtd_partition collie_partitions[] = {
111 111
112static void collie_set_vpp(int vpp) 112static void collie_set_vpp(int vpp)
113{ 113{
114 write_scoop_reg(&colliescoop_device.dev, SCOOP_GPCR, read_scoop_reg(SCOOP_GPCR) | COLLIE_SCP_VPEN); 114 write_scoop_reg(&colliescoop_device.dev, SCOOP_GPCR, read_scoop_reg(&colliescoop_device.dev, SCOOP_GPCR) | COLLIE_SCP_VPEN);
115 if (vpp) 115 if (vpp)
116 write_scoop_reg(&colliescoop_device.dev, SCOOP_GPWR, read_scoop_reg(SCOOP_GPWR) | COLLIE_SCP_VPEN); 116 write_scoop_reg(&colliescoop_device.dev, SCOOP_GPWR, read_scoop_reg(&colliescoop_device.dev, SCOOP_GPWR) | COLLIE_SCP_VPEN);
117 else 117 else
118 write_scoop_reg(&colliescoop_device.dev, SCOOP_GPWR, read_scoop_reg(SCOOP_GPWR) & ~COLLIE_SCP_VPEN); 118 write_scoop_reg(&colliescoop_device.dev, SCOOP_GPWR, read_scoop_reg(&colliescoop_device.dev, SCOOP_GPWR) & ~COLLIE_SCP_VPEN);
119} 119}
120 120
121static struct flash_platform_data collie_flash_data = { 121static struct flash_platform_data collie_flash_data = {
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 279e3afa3c39..f085d68e568e 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -39,3 +39,6 @@ extern void sa11x0_set_ssp_data(struct sa11x0_ssp_plat_ops *ops);
39 39
40struct irda_platform_data; 40struct irda_platform_data;
41void sa11x0_set_irda_data(struct irda_platform_data *irda); 41void sa11x0_set_irda_data(struct irda_platform_data *irda);
42
43struct mcp_plat_data;
44void sa11x0_set_mcp_data(struct mcp_plat_data *data);
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 3c8862fde51a..a30e0451df72 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -30,7 +30,6 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/leds.h> 32#include <asm/leds.h>
33#include <asm/mach-types.h>
34#include <asm/hardware/amba.h> 33#include <asm/hardware/amba.h>
35#include <asm/hardware/amba_clcd.h> 34#include <asm/hardware/amba_clcd.h>
36#include <asm/hardware/arm_timer.h> 35#include <asm/hardware/arm_timer.h>
@@ -52,8 +51,9 @@
52 * 51 *
53 * Setup a VA for the Versatile Vectored Interrupt Controller. 52 * Setup a VA for the Versatile Vectored Interrupt Controller.
54 */ 53 */
55#define VA_VIC_BASE IO_ADDRESS(VERSATILE_VIC_BASE) 54#define __io_address(n) __io(IO_ADDRESS(n))
56#define VA_SIC_BASE IO_ADDRESS(VERSATILE_SIC_BASE) 55#define VA_VIC_BASE __io_address(VERSATILE_VIC_BASE)
56#define VA_SIC_BASE __io_address(VERSATILE_SIC_BASE)
57 57
58static void vic_mask_irq(unsigned int irq) 58static void vic_mask_irq(unsigned int irq)
59{ 59{
@@ -214,7 +214,7 @@ void __init versatile_map_io(void)
214 iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc)); 214 iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc));
215} 215}
216 216
217#define VERSATILE_REFCOUNTER (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET) 217#define VERSATILE_REFCOUNTER (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET)
218 218
219/* 219/*
220 * This is the Versatile sched_clock implementation. This has 220 * This is the Versatile sched_clock implementation. This has
@@ -231,7 +231,7 @@ unsigned long long sched_clock(void)
231} 231}
232 232
233 233
234#define VERSATILE_FLASHCTRL (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET) 234#define VERSATILE_FLASHCTRL (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
235 235
236static int versatile_flash_init(void) 236static int versatile_flash_init(void)
237{ 237{
@@ -309,7 +309,7 @@ static struct platform_device smc91x_device = {
309 .resource = smc91x_resources, 309 .resource = smc91x_resources,
310}; 310};
311 311
312#define VERSATILE_SYSMCI (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) 312#define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
313 313
314unsigned int mmc_status(struct device *dev) 314unsigned int mmc_status(struct device *dev)
315{ 315{
@@ -343,11 +343,11 @@ static const struct icst307_params versatile_oscvco_params = {
343 343
344static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco) 344static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco)
345{ 345{
346 unsigned long sys_lock = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET; 346 void __iomem *sys_lock = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET;
347#if defined(CONFIG_ARCH_VERSATILE_PB) 347#if defined(CONFIG_ARCH_VERSATILE_PB)
348 unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET; 348 void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET;
349#elif defined(CONFIG_MACH_VERSATILE_AB) 349#elif defined(CONFIG_MACH_VERSATILE_AB)
350 unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET; 350 void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET;
351#endif 351#endif
352 u32 val; 352 u32 val;
353 353
@@ -483,7 +483,7 @@ static struct clcd_panel epson_2_2_in = {
483 */ 483 */
484static struct clcd_panel *versatile_clcd_panel(void) 484static struct clcd_panel *versatile_clcd_panel(void)
485{ 485{
486 unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; 486 void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
487 struct clcd_panel *panel = &vga; 487 struct clcd_panel *panel = &vga;
488 u32 val; 488 u32 val;
489 489
@@ -510,7 +510,7 @@ static struct clcd_panel *versatile_clcd_panel(void)
510 */ 510 */
511static void versatile_clcd_disable(struct clcd_fb *fb) 511static void versatile_clcd_disable(struct clcd_fb *fb)
512{ 512{
513 unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; 513 void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
514 u32 val; 514 u32 val;
515 515
516 val = readl(sys_clcd); 516 val = readl(sys_clcd);
@@ -522,7 +522,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb)
522 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off 522 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off
523 */ 523 */
524 if (fb->panel == &sanyo_2_5_in) { 524 if (fb->panel == &sanyo_2_5_in) {
525 unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL); 525 void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL);
526 unsigned long ctrl; 526 unsigned long ctrl;
527 527
528 ctrl = readl(versatile_ib2_ctrl); 528 ctrl = readl(versatile_ib2_ctrl);
@@ -537,7 +537,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb)
537 */ 537 */
538static void versatile_clcd_enable(struct clcd_fb *fb) 538static void versatile_clcd_enable(struct clcd_fb *fb)
539{ 539{
540 unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; 540 void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET;
541 u32 val; 541 u32 val;
542 542
543 val = readl(sys_clcd); 543 val = readl(sys_clcd);
@@ -571,7 +571,7 @@ static void versatile_clcd_enable(struct clcd_fb *fb)
571 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on 571 * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on
572 */ 572 */
573 if (fb->panel == &sanyo_2_5_in) { 573 if (fb->panel == &sanyo_2_5_in) {
574 unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL); 574 void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL);
575 unsigned long ctrl; 575 unsigned long ctrl;
576 576
577 ctrl = readl(versatile_ib2_ctrl); 577 ctrl = readl(versatile_ib2_ctrl);
@@ -720,7 +720,7 @@ static struct amba_device *amba_devs[] __initdata = {
720}; 720};
721 721
722#ifdef CONFIG_LEDS 722#ifdef CONFIG_LEDS
723#define VA_LEDS_BASE (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET) 723#define VA_LEDS_BASE (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET)
724 724
725static void versatile_leds_event(led_event_t ledevt) 725static void versatile_leds_event(led_event_t ledevt)
726{ 726{
@@ -778,11 +778,11 @@ void __init versatile_init(void)
778/* 778/*
779 * Where is the timer (VA)? 779 * Where is the timer (VA)?
780 */ 780 */
781#define TIMER0_VA_BASE IO_ADDRESS(VERSATILE_TIMER0_1_BASE) 781#define TIMER0_VA_BASE __io_address(VERSATILE_TIMER0_1_BASE)
782#define TIMER1_VA_BASE (IO_ADDRESS(VERSATILE_TIMER0_1_BASE) + 0x20) 782#define TIMER1_VA_BASE (__io_address(VERSATILE_TIMER0_1_BASE) + 0x20)
783#define TIMER2_VA_BASE IO_ADDRESS(VERSATILE_TIMER2_3_BASE) 783#define TIMER2_VA_BASE __io_address(VERSATILE_TIMER2_3_BASE)
784#define TIMER3_VA_BASE (IO_ADDRESS(VERSATILE_TIMER2_3_BASE) + 0x20) 784#define TIMER3_VA_BASE (__io_address(VERSATILE_TIMER2_3_BASE) + 0x20)
785#define VA_IC_BASE IO_ADDRESS(VERSATILE_VIC_BASE) 785#define VA_IC_BASE __io_address(VERSATILE_VIC_BASE)
786 786
787/* 787/*
788 * How long is the timer interval? 788 * How long is the timer interval?
@@ -877,12 +877,12 @@ static void __init versatile_timer_init(void)
877 * VERSATILE_REFCLK is 32KHz 877 * VERSATILE_REFCLK is 32KHz
878 * VERSATILE_TIMCLK is 1MHz 878 * VERSATILE_TIMCLK is 1MHz
879 */ 879 */
880 val = readl(IO_ADDRESS(VERSATILE_SCTL_BASE)); 880 val = readl(__io_address(VERSATILE_SCTL_BASE));
881 writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | 881 writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) |
882 (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | 882 (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) |
883 (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | 883 (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) |
884 (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, 884 (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val,
885 IO_ADDRESS(VERSATILE_SCTL_BASE)); 885 __io_address(VERSATILE_SCTL_BASE));
886 886
887 /* 887 /*
888 * Initialise to a known state (all timers off) 888 * Initialise to a known state (all timers off)
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index d1565e851f0e..b80d57d51699 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -29,7 +29,6 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/system.h> 30#include <asm/system.h>
31#include <asm/mach/pci.h> 31#include <asm/mach/pci.h>
32#include <asm/mach-types.h>
33 32
34/* 33/*
35 * these spaces are mapped using the following base registers: 34 * these spaces are mapped using the following base registers:
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index db5e47dfc303..c54e04c995ee 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -370,21 +370,21 @@ config CPU_BIG_ENDIAN
370 370
371config CPU_ICACHE_DISABLE 371config CPU_ICACHE_DISABLE
372 bool "Disable I-Cache" 372 bool "Disable I-Cache"
373 depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 373 depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_V6
374 help 374 help
375 Say Y here to disable the processor instruction cache. Unless 375 Say Y here to disable the processor instruction cache. Unless
376 you have a reason not to or are unsure, say N. 376 you have a reason not to or are unsure, say N.
377 377
378config CPU_DCACHE_DISABLE 378config CPU_DCACHE_DISABLE
379 bool "Disable D-Cache" 379 bool "Disable D-Cache"
380 depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 380 depends on CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_V6
381 help 381 help
382 Say Y here to disable the processor data cache. Unless 382 Say Y here to disable the processor data cache. Unless
383 you have a reason not to or are unsure, say N. 383 you have a reason not to or are unsure, say N.
384 384
385config CPU_DCACHE_WRITETHROUGH 385config CPU_DCACHE_WRITETHROUGH
386 bool "Force write through D-cache" 386 bool "Force write through D-cache"
387 depends on (CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020) && !CPU_DCACHE_DISABLE 387 depends on (CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM1020 || CPU_V6) && !CPU_DCACHE_DISABLE
388 default y if CPU_ARM925T 388 default y if CPU_ARM925T
389 help 389 help
390 Say Y here to use the data cache in writethrough mode. Unless you 390 Say Y here to use the data cache in writethrough mode. Unless you
@@ -399,7 +399,7 @@ config CPU_CACHE_ROUND_ROBIN
399 399
400config CPU_BPREDICT_DISABLE 400config CPU_BPREDICT_DISABLE
401 bool "Disable branch prediction" 401 bool "Disable branch prediction"
402 depends on CPU_ARM1020 402 depends on CPU_ARM1020 || CPU_V6
403 help 403 help
404 Say Y here to disable branch prediction. If unsure, say N. 404 Say Y here to disable branch prediction. If unsure, say N.
405 405
diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
index 8f76f3df7b4c..dbd346033122 100644
--- a/arch/arm/mm/abort-ev6.S
+++ b/arch/arm/mm/abort-ev6.S
@@ -20,6 +20,11 @@
20 */ 20 */
21 .align 5 21 .align 5
22ENTRY(v6_early_abort) 22ENTRY(v6_early_abort)
23#ifdef CONFIG_CPU_MPCORE
24 clrex
25#else
26 strex r0, r1, [sp] @ Clear the exclusive monitor
27#endif
23 mrc p15, 0, r1, c5, c0, 0 @ get FSR 28 mrc p15, 0, r1, c5, c0, 0 @ get FSR
24 mrc p15, 0, r0, c6, c0, 0 @ get FAR 29 mrc p15, 0, r0, c6, c0, 0 @ get FAR
25/* 30/*
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 4b39d867ac14..705c98921c37 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -111,7 +111,7 @@ proc_alignment_read(char *page, char **start, off_t off, int count, int *eof,
111} 111}
112 112
113static int proc_alignment_write(struct file *file, const char __user *buffer, 113static int proc_alignment_write(struct file *file, const char __user *buffer,
114 unsigned long count, void *data) 114 unsigned long count, void *data)
115{ 115{
116 char mode; 116 char mode;
117 117
@@ -119,7 +119,7 @@ static int proc_alignment_write(struct file *file, const char __user *buffer,
119 if (get_user(mode, buffer)) 119 if (get_user(mode, buffer))
120 return -EFAULT; 120 return -EFAULT;
121 if (mode >= '0' && mode <= '5') 121 if (mode >= '0' && mode <= '5')
122 ai_usermode = mode - '0'; 122 ai_usermode = mode - '0';
123 } 123 }
124 return count; 124 return count;
125} 125}
@@ -262,7 +262,7 @@ union offset_union {
262 goto fault; \ 262 goto fault; \
263 } while (0) 263 } while (0)
264 264
265#define put32_unaligned_check(val,addr) \ 265#define put32_unaligned_check(val,addr) \
266 __put32_unaligned_check("strb", val, addr) 266 __put32_unaligned_check("strb", val, addr)
267 267
268#define put32t_unaligned_check(val,addr) \ 268#define put32t_unaligned_check(val,addr) \
@@ -306,19 +306,19 @@ do_alignment_ldrhstrh(unsigned long addr, unsigned long instr, struct pt_regs *r
306 return TYPE_LDST; 306 return TYPE_LDST;
307 307
308 user: 308 user:
309 if (LDST_L_BIT(instr)) { 309 if (LDST_L_BIT(instr)) {
310 unsigned long val; 310 unsigned long val;
311 get16t_unaligned_check(val, addr); 311 get16t_unaligned_check(val, addr);
312 312
313 /* signed half-word? */ 313 /* signed half-word? */
314 if (instr & 0x40) 314 if (instr & 0x40)
315 val = (signed long)((signed short) val); 315 val = (signed long)((signed short) val);
316 316
317 regs->uregs[rd] = val; 317 regs->uregs[rd] = val;
318 } else 318 } else
319 put16t_unaligned_check(regs->uregs[rd], addr); 319 put16t_unaligned_check(regs->uregs[rd], addr);
320 320
321 return TYPE_LDST; 321 return TYPE_LDST;
322 322
323 fault: 323 fault:
324 return TYPE_FAULT; 324 return TYPE_FAULT;
@@ -330,6 +330,9 @@ do_alignment_ldrdstrd(unsigned long addr, unsigned long instr,
330{ 330{
331 unsigned int rd = RD_BITS(instr); 331 unsigned int rd = RD_BITS(instr);
332 332
333 if (((rd & 1) == 1) || (rd == 14))
334 goto bad;
335
333 ai_dword += 1; 336 ai_dword += 1;
334 337
335 if (user_mode(regs)) 338 if (user_mode(regs))
@@ -339,11 +342,11 @@ do_alignment_ldrdstrd(unsigned long addr, unsigned long instr,
339 unsigned long val; 342 unsigned long val;
340 get32_unaligned_check(val, addr); 343 get32_unaligned_check(val, addr);
341 regs->uregs[rd] = val; 344 regs->uregs[rd] = val;
342 get32_unaligned_check(val, addr+4); 345 get32_unaligned_check(val, addr + 4);
343 regs->uregs[rd+1] = val; 346 regs->uregs[rd + 1] = val;
344 } else { 347 } else {
345 put32_unaligned_check(regs->uregs[rd], addr); 348 put32_unaligned_check(regs->uregs[rd], addr);
346 put32_unaligned_check(regs->uregs[rd+1], addr+4); 349 put32_unaligned_check(regs->uregs[rd + 1], addr + 4);
347 } 350 }
348 351
349 return TYPE_LDST; 352 return TYPE_LDST;
@@ -353,15 +356,16 @@ do_alignment_ldrdstrd(unsigned long addr, unsigned long instr,
353 unsigned long val; 356 unsigned long val;
354 get32t_unaligned_check(val, addr); 357 get32t_unaligned_check(val, addr);
355 regs->uregs[rd] = val; 358 regs->uregs[rd] = val;
356 get32t_unaligned_check(val, addr+4); 359 get32t_unaligned_check(val, addr + 4);
357 regs->uregs[rd+1] = val; 360 regs->uregs[rd + 1] = val;
358 } else { 361 } else {
359 put32t_unaligned_check(regs->uregs[rd], addr); 362 put32t_unaligned_check(regs->uregs[rd], addr);
360 put32t_unaligned_check(regs->uregs[rd+1], addr+4); 363 put32t_unaligned_check(regs->uregs[rd + 1], addr + 4);
361 } 364 }
362 365
363 return TYPE_LDST; 366 return TYPE_LDST;
364 367 bad:
368 return TYPE_ERROR;
365 fault: 369 fault:
366 return TYPE_FAULT; 370 return TYPE_FAULT;
367} 371}
@@ -439,7 +443,7 @@ do_alignment_ldmstm(unsigned long addr, unsigned long instr, struct pt_regs *reg
439 if (LDST_P_EQ_U(instr)) /* U = P */ 443 if (LDST_P_EQ_U(instr)) /* U = P */
440 eaddr += 4; 444 eaddr += 4;
441 445
442 /* 446 /*
443 * For alignment faults on the ARM922T/ARM920T the MMU makes 447 * For alignment faults on the ARM922T/ARM920T the MMU makes
444 * the FSR (and hence addr) equal to the updated base address 448 * the FSR (and hence addr) equal to the updated base address
445 * of the multiple access rather than the restored value. 449 * of the multiple access rather than the restored value.
@@ -566,7 +570,7 @@ thumb2arm(u16 tinstr)
566 /* 6.5.1 Format 3: */ 570 /* 6.5.1 Format 3: */
567 case 0x4800 >> 11: /* 7.1.28 LDR(3) */ 571 case 0x4800 >> 11: /* 7.1.28 LDR(3) */
568 /* NOTE: This case is not technically possible. We're 572 /* NOTE: This case is not technically possible. We're
569 * loading 32-bit memory data via PC relative 573 * loading 32-bit memory data via PC relative
570 * addressing mode. So we can and should eliminate 574 * addressing mode. So we can and should eliminate
571 * this case. But I'll leave it here for now. 575 * this case. But I'll leave it here for now.
572 */ 576 */
@@ -638,7 +642,7 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
638 642
639 if (fault) { 643 if (fault) {
640 type = TYPE_FAULT; 644 type = TYPE_FAULT;
641 goto bad_or_fault; 645 goto bad_or_fault;
642 } 646 }
643 647
644 if (user_mode(regs)) 648 if (user_mode(regs))
@@ -663,6 +667,8 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
663 else if ((instr & 0x001000f0) == 0x000000d0 || /* LDRD */ 667 else if ((instr & 0x001000f0) == 0x000000d0 || /* LDRD */
664 (instr & 0x001000f0) == 0x000000f0) /* STRD */ 668 (instr & 0x001000f0) == 0x000000f0) /* STRD */
665 handler = do_alignment_ldrdstrd; 669 handler = do_alignment_ldrdstrd;
670 else if ((instr & 0x01f00ff0) == 0x01000090) /* SWP */
671 goto swp;
666 else 672 else
667 goto bad; 673 goto bad;
668 break; 674 break;
@@ -733,6 +739,9 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
733 do_bad_area(current, current->mm, addr, fsr, regs); 739 do_bad_area(current, current->mm, addr, fsr, regs);
734 return 0; 740 return 0;
735 741
742 swp:
743 printk(KERN_ERR "Alignment trap: not handling swp instruction\n");
744
736 bad: 745 bad:
737 /* 746 /*
738 * Oops, we didn't handle the instruction. 747 * Oops, we didn't handle the instruction.
diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S
index 85c10a71e7c6..72966d90e956 100644
--- a/arch/arm/mm/cache-v6.S
+++ b/arch/arm/mm/cache-v6.S
@@ -18,6 +18,7 @@
18#define HARVARD_CACHE 18#define HARVARD_CACHE
19#define CACHE_LINE_SIZE 32 19#define CACHE_LINE_SIZE 32
20#define D_CACHE_LINE_SIZE 32 20#define D_CACHE_LINE_SIZE 32
21#define BTB_FLUSH_SIZE 8
21 22
22/* 23/*
23 * v6_flush_cache_all() 24 * v6_flush_cache_all()
@@ -98,7 +99,13 @@ ENTRY(v6_coherent_user_range)
98 mcr p15, 0, r0, c7, c5, 1 @ invalidate I line 99 mcr p15, 0, r0, c7, c5, 1 @ invalidate I line
99#endif 100#endif
100 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry 101 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
101 add r0, r0, #CACHE_LINE_SIZE 102 add r0, r0, #BTB_FLUSH_SIZE
103 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
104 add r0, r0, #BTB_FLUSH_SIZE
105 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
106 add r0, r0, #BTB_FLUSH_SIZE
107 mcr p15, 0, r0, c7, c5, 7 @ invalidate BTB entry
108 add r0, r0, #BTB_FLUSH_SIZE
102 cmp r0, r1 109 cmp r0, r1
103 blo 1b 110 blo 1b
104#ifdef HARVARD_CACHE 111#ifdef HARVARD_CACHE
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 0b6c4db44e08..4a884baf3b9c 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -233,7 +233,17 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
233 if (in_interrupt() || !mm) 233 if (in_interrupt() || !mm)
234 goto no_context; 234 goto no_context;
235 235
236 down_read(&mm->mmap_sem); 236 /*
237 * As per x86, we may deadlock here. However, since the kernel only
238 * validly references user space from well defined areas of the code,
239 * we can bug out early if this is from code which shouldn't.
240 */
241 if (!down_read_trylock(&mm->mmap_sem)) {
242 if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
243 goto no_context;
244 down_read(&mm->mmap_sem);
245 }
246
237 fault = __do_page_fault(mm, addr, fsr, tsk); 247 fault = __do_page_fault(mm, addr, fsr, tsk);
238 up_read(&mm->mmap_sem); 248 up_read(&mm->mmap_sem);
239 249
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index b0208c992576..c9a03981b785 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -17,6 +17,24 @@
17 17
18#ifdef CONFIG_CPU_CACHE_VIPT 18#ifdef CONFIG_CPU_CACHE_VIPT
19 19
20#define ALIAS_FLUSH_START 0xffff4000
21
22#define TOP_PTE(x) pte_offset_kernel(top_pmd, x)
23
24static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
25{
26 unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
27
28 set_pte(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL));
29 flush_tlb_kernel_page(to);
30
31 asm( "mcrr p15, 0, %1, %0, c14\n"
32 " mcrr p15, 0, %1, %0, c5\n"
33 :
34 : "r" (to), "r" (to + PAGE_SIZE - L1_CACHE_BYTES)
35 : "cc");
36}
37
20void flush_cache_mm(struct mm_struct *mm) 38void flush_cache_mm(struct mm_struct *mm)
21{ 39{
22 if (cache_is_vivt()) { 40 if (cache_is_vivt()) {
@@ -67,24 +85,6 @@ void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsig
67 if (cache_is_vipt_aliasing()) 85 if (cache_is_vipt_aliasing())
68 flush_pfn_alias(pfn, user_addr); 86 flush_pfn_alias(pfn, user_addr);
69} 87}
70
71#define ALIAS_FLUSH_START 0xffff4000
72
73#define TOP_PTE(x) pte_offset_kernel(top_pmd, x)
74
75static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
76{
77 unsigned long to = ALIAS_FLUSH_START + (CACHE_COLOUR(vaddr) << PAGE_SHIFT);
78
79 set_pte(TOP_PTE(to), pfn_pte(pfn, PAGE_KERNEL));
80 flush_tlb_kernel_page(to);
81
82 asm( "mcrr p15, 0, %1, %0, c14\n"
83 " mcrr p15, 0, %1, %0, c5\n"
84 :
85 : "r" (to), "r" (to + PAGE_SIZE - L1_CACHE_BYTES)
86 : "cc");
87}
88#else 88#else
89#define flush_pfn_alias(pfn,vaddr) do { } while (0) 89#define flush_pfn_alias(pfn,vaddr) do { } while (0)
90#endif 90#endif
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 1d739d282a45..82ec954e45b6 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -509,7 +509,7 @@ cpu_arm1020_name:
509 509
510 .align 510 .align
511 511
512 .section ".proc.info", #alloc, #execinstr 512 .section ".proc.info.init", #alloc, #execinstr
513 513
514 .type __arm1020_proc_info,#object 514 .type __arm1020_proc_info,#object
515__arm1020_proc_info: 515__arm1020_proc_info:
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index 9b725665b5c7..7375fe930f72 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -491,7 +491,7 @@ cpu_arm1020e_name:
491 491
492 .align 492 .align
493 493
494 .section ".proc.info", #alloc, #execinstr 494 .section ".proc.info.init", #alloc, #execinstr
495 495
496 .type __arm1020e_proc_info,#object 496 .type __arm1020e_proc_info,#object
497__arm1020e_proc_info: 497__arm1020e_proc_info:
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index 37b70fa21c76..6ca639094d6f 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -473,7 +473,7 @@ cpu_arm1022_name:
473 473
474 .align 474 .align
475 475
476 .section ".proc.info", #alloc, #execinstr 476 .section ".proc.info.init", #alloc, #execinstr
477 477
478 .type __arm1022_proc_info,#object 478 .type __arm1022_proc_info,#object
479__arm1022_proc_info: 479__arm1022_proc_info:
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index 931b690d1be2..10317e4f55d2 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -469,7 +469,7 @@ cpu_arm1026_name:
469 469
470 .align 470 .align
471 471
472 .section ".proc.info", #alloc, #execinstr 472 .section ".proc.info.init", #alloc, #execinstr
473 473
474 .type __arm1026_proc_info,#object 474 .type __arm1026_proc_info,#object
475__arm1026_proc_info: 475__arm1026_proc_info:
diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
index d0f1bbb48f6c..8e7e1e70ab05 100644
--- a/arch/arm/mm/proc-arm6_7.S
+++ b/arch/arm/mm/proc-arm6_7.S
@@ -332,7 +332,7 @@ cpu_arm710_name:
332 332
333 .align 333 .align
334 334
335 .section ".proc.info", #alloc, #execinstr 335 .section ".proc.info.init", #alloc, #execinstr
336 336
337 .type __arm6_proc_info, #object 337 .type __arm6_proc_info, #object
338__arm6_proc_info: 338__arm6_proc_info:
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index c69c9de32391..a13e0184d343 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -222,7 +222,7 @@ cpu_arm720_name:
222 * See linux/include/asm-arm/procinfo.h for a definition of this structure. 222 * See linux/include/asm-arm/procinfo.h for a definition of this structure.
223 */ 223 */
224 224
225 .section ".proc.info", #alloc, #execinstr 225 .section ".proc.info.init", #alloc, #execinstr
226 226
227 .type __arm710_proc_info, #object 227 .type __arm710_proc_info, #object
228__arm710_proc_info: 228__arm710_proc_info:
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index 0f490a0fcb71..d16513899999 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -452,7 +452,7 @@ cpu_arm920_name:
452 452
453 .align 453 .align
454 454
455 .section ".proc.info", #alloc, #execinstr 455 .section ".proc.info.init", #alloc, #execinstr
456 456
457 .type __arm920_proc_info,#object 457 .type __arm920_proc_info,#object
458__arm920_proc_info: 458__arm920_proc_info:
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index 62bc34a139ee..23b8ed97f4e3 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -456,7 +456,7 @@ cpu_arm922_name:
456 456
457 .align 457 .align
458 458
459 .section ".proc.info", #alloc, #execinstr 459 .section ".proc.info.init", #alloc, #execinstr
460 460
461 .type __arm922_proc_info,#object 461 .type __arm922_proc_info,#object
462__arm922_proc_info: 462__arm922_proc_info:
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index ee49aa2ca781..ee95c52db513 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -521,7 +521,7 @@ cpu_arm925_name:
521 521
522 .align 522 .align
523 523
524 .section ".proc.info", #alloc, #execinstr 524 .section ".proc.info.init", #alloc, #execinstr
525 525
526 .type __arm925_proc_info,#object 526 .type __arm925_proc_info,#object
527__arm925_proc_info: 527__arm925_proc_info:
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index bb95cc9fed03..7d042dc20c47 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -471,7 +471,7 @@ cpu_arm926_name:
471 471
472 .align 472 .align
473 473
474 .section ".proc.info", #alloc, #execinstr 474 .section ".proc.info.init", #alloc, #execinstr
475 475
476 .type __arm926_proc_info,#object 476 .type __arm926_proc_info,#object
477__arm926_proc_info: 477__arm926_proc_info:
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index 34f7e7d3f419..bd330c4075a1 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -249,7 +249,7 @@ cpu_sa110_name:
249 249
250 .align 250 .align
251 251
252 .section ".proc.info", #alloc, #execinstr 252 .section ".proc.info.init", #alloc, #execinstr
253 253
254 .type __sa110_proc_info,#object 254 .type __sa110_proc_info,#object
255__sa110_proc_info: 255__sa110_proc_info:
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index ca14f80d5ab4..91b89124c0d7 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -280,7 +280,7 @@ cpu_sa1110_name:
280 280
281 .align 281 .align
282 282
283 .section ".proc.info", #alloc, #execinstr 283 .section ".proc.info.init", #alloc, #execinstr
284 284
285 .type __sa1100_proc_info,#object 285 .type __sa1100_proc_info,#object
286__sa1100_proc_info: 286__sa1100_proc_info:
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index eb34823c9dbf..9bb5fff406fb 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -55,7 +55,14 @@ ENTRY(cpu_v6_proc_init)
55 mov pc, lr 55 mov pc, lr
56 56
57ENTRY(cpu_v6_proc_fin) 57ENTRY(cpu_v6_proc_fin)
58 mov pc, lr 58 stmfd sp!, {lr}
59 cpsid if @ disable interrupts
60 bl v6_flush_kern_cache_all
61 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
62 bic r0, r0, #0x1000 @ ...i............
63 bic r0, r0, #0x0006 @ .............ca.
64 mcr p15, 0, r0, c1, c0, 0 @ disable caches
65 ldmfd sp!, {pc}
59 66
60/* 67/*
61 * cpu_v6_reset(loc) 68 * cpu_v6_reset(loc)
@@ -240,7 +247,7 @@ cpu_elf_name:
240 .size cpu_elf_name, . - cpu_elf_name 247 .size cpu_elf_name, . - cpu_elf_name
241 .align 248 .align
242 249
243 .section ".proc.info", #alloc, #execinstr 250 .section ".proc.info.init", #alloc, #execinstr
244 251
245 /* 252 /*
246 * Match any ARMv6 processor core. 253 * Match any ARMv6 processor core.
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index b88de2700146..861b35947280 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -578,7 +578,7 @@ cpu_pxa270_name:
578 578
579 .align 579 .align
580 580
581 .section ".proc.info", #alloc, #execinstr 581 .section ".proc.info.init", #alloc, #execinstr
582 582
583 .type __80200_proc_info,#object 583 .type __80200_proc_info,#object
584__80200_proc_info: 584__80200_proc_info:
diff --git a/arch/arm/nwfpe/fpa11.c b/arch/arm/nwfpe/fpa11.c
index 7690f731ee87..7b3d74d73c80 100644
--- a/arch/arm/nwfpe/fpa11.c
+++ b/arch/arm/nwfpe/fpa11.c
@@ -31,11 +31,6 @@
31#include <linux/string.h> 31#include <linux/string.h>
32#include <asm/system.h> 32#include <asm/system.h>
33 33
34/* forward declarations */
35unsigned int EmulateCPDO(const unsigned int);
36unsigned int EmulateCPDT(const unsigned int);
37unsigned int EmulateCPRT(const unsigned int);
38
39/* Reset the FPA11 chip. Called to initialize and reset the emulator. */ 34/* Reset the FPA11 chip. Called to initialize and reset the emulator. */
40static void resetFPA11(void) 35static void resetFPA11(void)
41{ 36{
diff --git a/arch/arm/nwfpe/fpa11.h b/arch/arm/nwfpe/fpa11.h
index 93523ae4b7a1..9677ae8448e8 100644
--- a/arch/arm/nwfpe/fpa11.h
+++ b/arch/arm/nwfpe/fpa11.h
@@ -95,4 +95,24 @@ extern int8 SetRoundingMode(const unsigned int);
95extern int8 SetRoundingPrecision(const unsigned int); 95extern int8 SetRoundingPrecision(const unsigned int);
96extern void nwfpe_init_fpa(union fp_state *fp); 96extern void nwfpe_init_fpa(union fp_state *fp);
97 97
98extern unsigned int EmulateAll(unsigned int opcode);
99
100extern unsigned int EmulateCPDT(const unsigned int opcode);
101extern unsigned int EmulateCPDO(const unsigned int opcode);
102extern unsigned int EmulateCPRT(const unsigned int opcode);
103
104/* fpa11_cpdt.c */
105extern unsigned int PerformLDF(const unsigned int opcode);
106extern unsigned int PerformSTF(const unsigned int opcode);
107extern unsigned int PerformLFM(const unsigned int opcode);
108extern unsigned int PerformSFM(const unsigned int opcode);
109
110/* single_cpdo.c */
111
112extern unsigned int SingleCPDO(struct roundingData *roundData,
113 const unsigned int opcode, FPREG * rFd);
114/* double_cpdo.c */
115extern unsigned int DoubleCPDO(struct roundingData *roundData,
116 const unsigned int opcode, FPREG * rFd);
117
98#endif 118#endif
diff --git a/arch/arm/nwfpe/fpa11_cprt.c b/arch/arm/nwfpe/fpa11_cprt.c
index adf8d3000540..7c67023655e4 100644
--- a/arch/arm/nwfpe/fpa11_cprt.c
+++ b/arch/arm/nwfpe/fpa11_cprt.c
@@ -26,12 +26,11 @@
26#include "fpa11.inl" 26#include "fpa11.inl"
27#include "fpmodule.h" 27#include "fpmodule.h"
28#include "fpmodule.inl" 28#include "fpmodule.inl"
29#include "softfloat.h"
29 30
30#ifdef CONFIG_FPE_NWFPE_XP 31#ifdef CONFIG_FPE_NWFPE_XP
31extern flag floatx80_is_nan(floatx80); 32extern flag floatx80_is_nan(floatx80);
32#endif 33#endif
33extern flag float64_is_nan(float64);
34extern flag float32_is_nan(float32);
35 34
36unsigned int PerformFLT(const unsigned int opcode); 35unsigned int PerformFLT(const unsigned int opcode);
37unsigned int PerformFIX(const unsigned int opcode); 36unsigned int PerformFIX(const unsigned int opcode);
diff --git a/arch/arm/nwfpe/fpopcode.h b/arch/arm/nwfpe/fpopcode.h
index 1777e92a88e6..6528e081c83f 100644
--- a/arch/arm/nwfpe/fpopcode.h
+++ b/arch/arm/nwfpe/fpopcode.h
@@ -476,4 +476,10 @@ static inline unsigned int getDestinationSize(const unsigned int opcode)
476 return (nRc); 476 return (nRc);
477} 477}
478 478
479extern unsigned int checkCondition(const unsigned int opcode,
480 const unsigned int ccodes);
481
482extern const float64 float64Constant[];
483extern const float32 float32Constant[];
484
479#endif 485#endif
diff --git a/arch/arm/nwfpe/softfloat.h b/arch/arm/nwfpe/softfloat.h
index 1c8799b9ee4d..14151700b6b2 100644
--- a/arch/arm/nwfpe/softfloat.h
+++ b/arch/arm/nwfpe/softfloat.h
@@ -265,4 +265,7 @@ static inline flag float64_lt_nocheck(float64 a, float64 b)
265 return (a != b) && (aSign ^ (a < b)); 265 return (a != b) && (aSign ^ (a < b));
266} 266}
267 267
268extern flag float32_is_nan( float32 a );
269extern flag float64_is_nan( float64 a );
270
268#endif 271#endif
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 6cb20aea7f51..02bcc6c1cd1b 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -25,7 +25,6 @@
25#include <asm/mach/map.h> 25#include <asm/mach/map.h>
26#include <asm/hardware/clock.h> 26#include <asm/hardware/clock.h>
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/mach-types.h>
29#include <asm/setup.h> 28#include <asm/setup.h>
30 29
31#include <asm/arch/board.h> 30#include <asm/arch/board.h>
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index 409aac2c4b9d..fd894bb00107 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -21,7 +21,6 @@
21#include <linux/err.h> 21#include <linux/err.h>
22 22
23#include <asm/hardware.h> 23#include <asm/hardware.h>
24#include <asm/mach-types.h>
25#include <asm/io.h> 24#include <asm/io.h>
26#include <asm/system.h> 25#include <asm/system.h>
27 26
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index 98f1c76f8660..14a836d7ac25 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -33,7 +33,6 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/system.h> 34#include <asm/system.h>
35#include <asm/hardware.h> 35#include <asm/hardware.h>
36#include <asm/mach-types.h>
37 36
38#include <asm/arch/mux.h> 37#include <asm/arch/mux.h>
39#include <asm/arch/usb.h> 38#include <asm/arch/usb.h>
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 6d3a79e5fef8..ae7c64b8cec3 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -2,11 +2,17 @@
2# 2#
3# This file is linux/arch/arm/tools/mach-types 3# This file is linux/arch/arm/tools/mach-types
4# 4#
5# Up to date versions of this file can be obtained from:
6#
7# http://www.arm.linux.org.uk/developer/machines/?action=download
8#
5# Please do not send patches to this file; it is automatically generated! 9# Please do not send patches to this file; it is automatically generated!
6# To add an entry into this database, please see Documentation/arm/README, 10# To add an entry into this database, please see Documentation/arm/README,
7# or contact rmk@arm.linux.org.uk 11# or visit:
12#
13# http://www.arm.linux.org.uk/developer/machines/?action=new
8# 14#
9# Last update: Thu Jun 23 20:19:33 2005 15# Last update: Mon Oct 10 09:46:25 2005
10# 16#
11# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number 17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
12# 18#
@@ -421,7 +427,7 @@ mt02 MACH_MT02 MT02 410
421mport3s MACH_MPORT3S MPORT3S 411 427mport3s MACH_MPORT3S MPORT3S 411
422ra_alpha MACH_RA_ALPHA RA_ALPHA 412 428ra_alpha MACH_RA_ALPHA RA_ALPHA 412
423xcep MACH_XCEP XCEP 413 429xcep MACH_XCEP XCEP 413
424arcom_mercury MACH_ARCOM_MERCURY ARCOM_MERCURY 414 430arcom_vulcan MACH_ARCOM_VULCAN ARCOM_VULCAN 414
425stargate MACH_STARGATE STARGATE 415 431stargate MACH_STARGATE STARGATE 415
426armadilloj MACH_ARMADILLOJ ARMADILLOJ 416 432armadilloj MACH_ARMADILLOJ ARMADILLOJ 416
427elroy_jack MACH_ELROY_JACK ELROY_JACK 417 433elroy_jack MACH_ELROY_JACK ELROY_JACK 417
@@ -454,7 +460,7 @@ esl_sarva MACH_ESL_SARVA ESL_SARVA 443
454xm250 MACH_XM250 XM250 444 460xm250 MACH_XM250 XM250 444
455t6tc1xb MACH_T6TC1XB T6TC1XB 445 461t6tc1xb MACH_T6TC1XB T6TC1XB 445
456ess710 MACH_ESS710 ESS710 446 462ess710 MACH_ESS710 ESS710 446
457mx3ads MACH_MX3ADS MX3ADS 447 463mx31ads MACH_MX3ADS MX3ADS 447
458himalaya MACH_HIMALAYA HIMALAYA 448 464himalaya MACH_HIMALAYA HIMALAYA 448
459bolfenk MACH_BOLFENK BOLFENK 449 465bolfenk MACH_BOLFENK BOLFENK 449
460at91rm9200kr MACH_AT91RM9200KR AT91RM9200KR 450 466at91rm9200kr MACH_AT91RM9200KR AT91RM9200KR 450
@@ -787,3 +793,79 @@ ez_ixp42x MACH_EZ_IXP42X EZ_IXP42X 778
787tapwave_zodiac MACH_TAPWAVE_ZODIAC TAPWAVE_ZODIAC 779 793tapwave_zodiac MACH_TAPWAVE_ZODIAC TAPWAVE_ZODIAC 779
788universalmeter MACH_UNIVERSALMETER UNIVERSALMETER 780 794universalmeter MACH_UNIVERSALMETER UNIVERSALMETER 780
789hicoarm9 MACH_HICOARM9 HICOARM9 781 795hicoarm9 MACH_HICOARM9 HICOARM9 781
796pnx4008 MACH_PNX4008 PNX4008 782
797kws6000 MACH_KWS6000 KWS6000 783
798portux920t MACH_PORTUX920T PORTUX920T 784
799ez_x5 MACH_EZ_X5 EZ_X5 785
800omap_rudolph MACH_OMAP_RUDOLPH OMAP_RUDOLPH 786
801cpuat91 MACH_CPUAT91 CPUAT91 787
802rea9200 MACH_REA9200 REA9200 788
803acts_pune_sa1110 MACH_ACTS_PUNE_SA1110 ACTS_PUNE_SA1110 789
804ixp425 MACH_IXP425 IXP425 790
805argonplusodyssey MACH_ODYSSEY ODYSSEY 791
806perch MACH_PERCH PERCH 792
807eis05r1 MACH_EIS05R1 EIS05R1 793
808pepperpad MACH_PEPPERPAD PEPPERPAD 794
809sb3010 MACH_SB3010 SB3010 795
810rm9200 MACH_RM9200 RM9200 796
811dma03 MACH_DMA03 DMA03 797
812road_s101 MACH_ROAD_S101 ROAD_S101 798
813iq_nextgen_a MACH_IQ_NEXTGEN_A IQ_NEXTGEN_A 799
814iq_nextgen_b MACH_IQ_NEXTGEN_B IQ_NEXTGEN_B 800
815iq_nextgen_c MACH_IQ_NEXTGEN_C IQ_NEXTGEN_C 801
816iq_nextgen_d MACH_IQ_NEXTGEN_D IQ_NEXTGEN_D 802
817iq_nextgen_e MACH_IQ_NEXTGEN_E IQ_NEXTGEN_E 803
818mallow_at91 MACH_MALLOW_AT91 MALLOW_AT91 804
819cybertracker MACH_CYBERTRACKER CYBERTRACKER 805
820gesbc931x MACH_GESBC931X GESBC931X 806
821centipad MACH_CENTIPAD CENTIPAD 807
822armsoc MACH_ARMSOC ARMSOC 808
823se4200 MACH_SE4200 SE4200 809
824ems197a MACH_EMS197A EMS197A 810
825micro9 MACH_MICRO9 MICRO9 811
826micro9l MACH_MICRO9L MICRO9L 812
827uc5471dsp MACH_UC5471DSP UC5471DSP 813
828sj5471eng MACH_SJ5471ENG SJ5471ENG 814
829none MACH_CMPXA26X CMPXA26X 815
830nc MACH_NC NC 816
831omap_palmte MACH_OMAP_PALMTE OMAP_PALMTE 817
832ajax52x MACH_AJAX52X AJAX52X 818
833siriustar MACH_SIRIUSTAR SIRIUSTAR 819
834iodata_hdlg MACH_IODATA_HDLG IODATA_HDLG 820
835at91rm9200utl MACH_AT91RM9200UTL AT91RM9200UTL 821
836biosafe MACH_BIOSAFE BIOSAFE 822
837mp1000 MACH_MP1000 MP1000 823
838parsy MACH_PARSY PARSY 824
839ccxp270 MACH_CCXP CCXP 825
840omap_gsample MACH_OMAP_GSAMPLE OMAP_GSAMPLE 826
841realview_eb MACH_REALVIEW_EB REALVIEW_EB 827
842samoa MACH_SAMOA SAMOA 828
843t3xscale MACH_T3XSCALE T3XSCALE 829
844i878 MACH_I878 I878 830
845borzoi MACH_BORZOI BORZOI 831
846gecko MACH_GECKO GECKO 832
847ds101 MACH_DS101 DS101 833
848omap_palmtt2 MACH_OMAP_PALMTT2 OMAP_PALMTT2 834
849xscale_palmld MACH_XSCALE_PALMLD XSCALE_PALMLD 835
850cc9c MACH_CC9C CC9C 836
851sbc1670 MACH_SBC1670 SBC1670 837
852ixdp28x5 MACH_IXDP28X5 IXDP28X5 838
853omap_palmtt MACH_OMAP_PALMTT OMAP_PALMTT 839
854ml696k MACH_ML696K ML696K 840
855arcom_zeus MACH_ARCOM_ZEUS ARCOM_ZEUS 841
856osiris MACH_OSIRIS OSIRIS 842
857maestro MACH_MAESTRO MAESTRO 843
858tunge2 MACH_TUNGE2 TUNGE2 844
859ixbbm MACH_IXBBM IXBBM 845
860mx27 MACH_MX27 MX27 846
861ax8004 MACH_AX8004 AX8004 847
862at91sam9261ek MACH_AT91SAM9261EK AT91SAM9261EK 848
863loft MACH_LOFT LOFT 849
864magpie MACH_MAGPIE MAGPIE 850
865mx21 MACH_MX21 MX21 851
866mb87m3400 MACH_MB87M3400 MB87M3400 852
867mguard_delta MACH_MGUARD_DELTA MGUARD_DELTA 853
868davinci_dvdp MACH_DAVINCI_DVDP DAVINCI_DVDP 854
869htcuniversal MACH_HTCUNIVERSAL HTCUNIVERSAL 855
870tpad MACH_TPAD TPAD 856
871roverp3 MACH_ROVERP3 ROVERP3 857
diff --git a/arch/arm26/boot/compressed/hw-bse.c b/arch/arm26/boot/compressed/hw-bse.c
deleted file mode 100644
index 3e8f07f8e08a..000000000000
--- a/arch/arm26/boot/compressed/hw-bse.c
+++ /dev/null
@@ -1,74 +0,0 @@
1/*
2 * Bright Star Engineering Inc.
3 *
4 * code for readng parameters from the
5 * parameter blocks of the boot block
6 * flash memory
7 *
8 */
9
10static int strcmp(const char *s1, const char *s2)
11{
12 while (*s1 != '\0' && *s1 == *s2)
13 {
14 s1++;
15 s2++;
16 }
17
18 return (*(unsigned char *) s1) - (*(unsigned char *) s2);
19}
20
21struct pblk_t {
22 char type;
23 unsigned short size;
24};
25
26static char *bse_getflashparam(char *name) {
27 unsigned int esize;
28 char *q,*r;
29 unsigned char *p,*e;
30 struct pblk_t *thepb = (struct pblk_t *) 0x00004000;
31 struct pblk_t *altpb = (struct pblk_t *) 0x00006000;
32 if (thepb->type&1) {
33 if (altpb->type&1) {
34 /* no valid param block */
35 return (char*)0;
36 } else {
37 /* altpb is valid */
38 struct pblk_t *tmp;
39 tmp = thepb;
40 thepb = altpb;
41 altpb = tmp;
42 }
43 }
44 p = (char*)thepb + sizeof(struct pblk_t);
45 e = p + thepb->size;
46 while (p < e) {
47 q = p;
48 esize = *p;
49 if (esize == 0xFF) break;
50 if (esize == 0) break;
51 if (esize > 127) {
52 esize = (esize&0x7F)<<8 | p[1];
53 q++;
54 }
55 q++;
56 r=q;
57 if (*r && ((name == 0) || (!strcmp(name,r)))) {
58 while (*q++) ;
59 return q;
60 }
61 p+=esize;
62 }
63 return (char*)0;
64}
65
66void bse_setup(void) {
67 /* extract the linux cmdline from flash */
68 char *name=bse_getflashparam("linuxboot");
69 char *x = (char *)0xc0000100;
70 if (name) {
71 while (*name) *x++=*name++;
72 }
73 *x=0;
74}
diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c
index 10329306d23c..426b09878a05 100644
--- a/arch/cris/arch-v32/drivers/pci/dma.c
+++ b/arch/cris/arch-v32/drivers/pci/dma.c
@@ -24,7 +24,7 @@ struct dma_coherent_mem {
24}; 24};
25 25
26void *dma_alloc_coherent(struct device *dev, size_t size, 26void *dma_alloc_coherent(struct device *dev, size_t size,
27 dma_addr_t *dma_handle, unsigned int __nocast gfp) 27 dma_addr_t *dma_handle, gfp_t gfp)
28{ 28{
29 void *ret; 29 void *ret;
30 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; 30 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index 2c5cae04a95c..957f551ba5ce 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/cpumask.h> 16#include <linux/cpumask.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/module.h>
18 19
19#define IPI_SCHEDULE 1 20#define IPI_SCHEDULE 1
20#define IPI_CALL 2 21#define IPI_CALL 2
@@ -28,6 +29,7 @@ spinlock_t cris_atomic_locks[] = { [0 ... LOCK_COUNT - 1] = SPIN_LOCK_UNLOCKED};
28/* CPU masks */ 29/* CPU masks */
29cpumask_t cpu_online_map = CPU_MASK_NONE; 30cpumask_t cpu_online_map = CPU_MASK_NONE;
30cpumask_t phys_cpu_present_map = CPU_MASK_NONE; 31cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
32EXPORT_SYMBOL(phys_cpu_present_map);
31 33
32/* Variables used during SMP boot */ 34/* Variables used during SMP boot */
33volatile int cpu_now_booting = 0; 35volatile int cpu_now_booting = 0;
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index a63351c085c6..b66c13c0cc0f 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -27,15 +27,14 @@
27#include <linux/config.h> 27#include <linux/config.h>
28#include <linux/acpi.h> 28#include <linux/acpi.h>
29#include <linux/efi.h> 29#include <linux/efi.h>
30#include <linux/irq.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/dmi.h> 31#include <linux/dmi.h>
32#include <linux/irq.h>
33 33
34#include <asm/pgtable.h> 34#include <asm/pgtable.h>
35#include <asm/io_apic.h> 35#include <asm/io_apic.h>
36#include <asm/apic.h> 36#include <asm/apic.h>
37#include <asm/io.h> 37#include <asm/io.h>
38#include <asm/irq.h>
39#include <asm/mpspec.h> 38#include <asm/mpspec.h>
40 39
41#ifdef CONFIG_X86_64 40#ifdef CONFIG_X86_64
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index a22a866de8f9..5546ddebec33 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -18,7 +18,6 @@
18#include <linux/init.h> 18#include <linux/init.h>
19 19
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/irq.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/bootmem.h> 22#include <linux/bootmem.h>
24#include <linux/smp_lock.h> 23#include <linux/smp_lock.h>
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 73aeaf5a9d4e..53a1681cd964 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -28,6 +28,22 @@ static void __init init_amd(struct cpuinfo_x86 *c)
28 int mbytes = num_physpages >> (20-PAGE_SHIFT); 28 int mbytes = num_physpages >> (20-PAGE_SHIFT);
29 int r; 29 int r;
30 30
31#ifdef CONFIG_SMP
32 unsigned long long value;
33
34 /* Disable TLB flush filter by setting HWCR.FFDIS on K8
35 * bit 6 of msr C001_0015
36 *
37 * Errata 63 for SH-B3 steppings
38 * Errata 122 for all steppings (F+ have it disabled by default)
39 */
40 if (c->x86 == 15) {
41 rdmsrl(MSR_K7_HWCR, value);
42 value |= 1 << 6;
43 wrmsrl(MSR_K7_HWCR, value);
44 }
45#endif
46
31 /* 47 /*
32 * FIXME: We should handle the K5 here. Set up the write 48 * FIXME: We should handle the K5 here. Set up the write
33 * range and also turn on MSR 83 bits 4 and 31 (write alloc, 49 * range and also turn on MSR 83 bits 4 and 31 (write alloc,
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index ab6e0611303d..58ca98fdc2ca 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -44,7 +44,7 @@
44 44
45#define PFX "powernow-k8: " 45#define PFX "powernow-k8: "
46#define BFX PFX "BIOS error: " 46#define BFX PFX "BIOS error: "
47#define VERSION "version 1.50.3" 47#define VERSION "version 1.50.4"
48#include "powernow-k8.h" 48#include "powernow-k8.h"
49 49
50/* serialize freq changes */ 50/* serialize freq changes */
@@ -111,8 +111,8 @@ static int query_current_values_with_pending_wait(struct powernow_k8_data *data)
111 u32 i = 0; 111 u32 i = 0;
112 112
113 do { 113 do {
114 if (i++ > 0x1000000) { 114 if (i++ > 10000) {
115 printk(KERN_ERR PFX "detected change pending stuck\n"); 115 dprintk("detected change pending stuck\n");
116 return 1; 116 return 1;
117 } 117 }
118 rdmsr(MSR_FIDVID_STATUS, lo, hi); 118 rdmsr(MSR_FIDVID_STATUS, lo, hi);
@@ -159,6 +159,7 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid)
159{ 159{
160 u32 lo; 160 u32 lo;
161 u32 savevid = data->currvid; 161 u32 savevid = data->currvid;
162 u32 i = 0;
162 163
163 if ((fid & INVALID_FID_MASK) || (data->currvid & INVALID_VID_MASK)) { 164 if ((fid & INVALID_FID_MASK) || (data->currvid & INVALID_VID_MASK)) {
164 printk(KERN_ERR PFX "internal error - overflow on fid write\n"); 165 printk(KERN_ERR PFX "internal error - overflow on fid write\n");
@@ -170,10 +171,13 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid)
170 dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n", 171 dprintk("writing fid 0x%x, lo 0x%x, hi 0x%x\n",
171 fid, lo, data->plllock * PLL_LOCK_CONVERSION); 172 fid, lo, data->plllock * PLL_LOCK_CONVERSION);
172 173
173 wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); 174 do {
174 175 wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION);
175 if (query_current_values_with_pending_wait(data)) 176 if (i++ > 100) {
176 return 1; 177 printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n");
178 return 1;
179 }
180 } while (query_current_values_with_pending_wait(data));
177 181
178 count_off_irt(data); 182 count_off_irt(data);
179 183
@@ -197,6 +201,7 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid)
197{ 201{
198 u32 lo; 202 u32 lo;
199 u32 savefid = data->currfid; 203 u32 savefid = data->currfid;
204 int i = 0;
200 205
201 if ((data->currfid & INVALID_FID_MASK) || (vid & INVALID_VID_MASK)) { 206 if ((data->currfid & INVALID_FID_MASK) || (vid & INVALID_VID_MASK)) {
202 printk(KERN_ERR PFX "internal error - overflow on vid write\n"); 207 printk(KERN_ERR PFX "internal error - overflow on vid write\n");
@@ -208,10 +213,13 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid)
208 dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n", 213 dprintk("writing vid 0x%x, lo 0x%x, hi 0x%x\n",
209 vid, lo, STOP_GRANT_5NS); 214 vid, lo, STOP_GRANT_5NS);
210 215
211 wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS); 216 do {
212 217 wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS);
213 if (query_current_values_with_pending_wait(data)) 218 if (i++ > 100) {
214 return 1; 219 printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n");
220 return 1;
221 }
222 } while (query_current_values_with_pending_wait(data));
215 223
216 if (savefid != data->currfid) { 224 if (savefid != data->currfid) {
217 printk(KERN_ERR PFX "fid changed on vid trans, old 0x%x new 0x%x\n", 225 printk(KERN_ERR PFX "fid changed on vid trans, old 0x%x new 0x%x\n",
diff --git a/arch/i386/kernel/cpu/mcheck/k7.c b/arch/i386/kernel/cpu/mcheck/k7.c
index c4abe7657397..7c6b9c73522f 100644
--- a/arch/i386/kernel/cpu/mcheck/k7.c
+++ b/arch/i386/kernel/cpu/mcheck/k7.c
@@ -7,7 +7,6 @@
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/config.h> 9#include <linux/config.h>
10#include <linux/irq.h>
11#include <linux/interrupt.h> 10#include <linux/interrupt.h>
12#include <linux/smp.h> 11#include <linux/smp.h>
13 12
diff --git a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
index 7864ddfccf07..82dffe0d4954 100644
--- a/arch/i386/kernel/cpu/mcheck/non-fatal.c
+++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c
@@ -12,7 +12,6 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/jiffies.h> 13#include <linux/jiffies.h>
14#include <linux/config.h> 14#include <linux/config.h>
15#include <linux/irq.h>
16#include <linux/workqueue.h> 15#include <linux/workqueue.h>
17#include <linux/interrupt.h> 16#include <linux/interrupt.h>
18#include <linux/smp.h> 17#include <linux/smp.h>
diff --git a/arch/i386/kernel/cpu/mcheck/p4.c b/arch/i386/kernel/cpu/mcheck/p4.c
index 0abccb6fdf9e..1d1e885f500a 100644
--- a/arch/i386/kernel/cpu/mcheck/p4.c
+++ b/arch/i386/kernel/cpu/mcheck/p4.c
@@ -6,7 +6,6 @@
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/irq.h>
10#include <linux/interrupt.h> 9#include <linux/interrupt.h>
11#include <linux/smp.h> 10#include <linux/smp.h>
12 11
diff --git a/arch/i386/kernel/cpu/mcheck/p5.c b/arch/i386/kernel/cpu/mcheck/p5.c
index ec0614cd2925..3a2e24baddc7 100644
--- a/arch/i386/kernel/cpu/mcheck/p5.c
+++ b/arch/i386/kernel/cpu/mcheck/p5.c
@@ -6,7 +6,6 @@
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/irq.h>
10#include <linux/interrupt.h> 9#include <linux/interrupt.h>
11#include <linux/smp.h> 10#include <linux/smp.h>
12 11
diff --git a/arch/i386/kernel/cpu/mcheck/p6.c b/arch/i386/kernel/cpu/mcheck/p6.c
index f01b73f947e1..3c035b8fa3d9 100644
--- a/arch/i386/kernel/cpu/mcheck/p6.c
+++ b/arch/i386/kernel/cpu/mcheck/p6.c
@@ -6,7 +6,6 @@
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/irq.h>
10#include <linux/interrupt.h> 9#include <linux/interrupt.h>
11#include <linux/smp.h> 10#include <linux/smp.h>
12 11
diff --git a/arch/i386/kernel/cpu/mcheck/winchip.c b/arch/i386/kernel/cpu/mcheck/winchip.c
index 7bae68fa168f..5b9d2dd411d3 100644
--- a/arch/i386/kernel/cpu/mcheck/winchip.c
+++ b/arch/i386/kernel/cpu/mcheck/winchip.c
@@ -6,7 +6,6 @@
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/irq.h>
10#include <linux/interrupt.h> 9#include <linux/interrupt.h>
11 10
12#include <asm/processor.h> 11#include <asm/processor.h>
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 913be77bb844..0248e084017c 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -11,10 +11,8 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/irq.h>
15#include <linux/reboot.h> 14#include <linux/reboot.h>
16#include <linux/kexec.h> 15#include <linux/kexec.h>
17#include <linux/irq.h>
18#include <linux/delay.h> 16#include <linux/delay.h>
19#include <linux/elf.h> 17#include <linux/elf.h>
20#include <linux/elfcore.h> 18#include <linux/elfcore.h>
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
index 178f4e9bac9d..323ef8ab3244 100644
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -16,7 +16,6 @@
16#include <asm/atomic.h> 16#include <asm/atomic.h>
17#include <asm/system.h> 17#include <asm/system.h>
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/irq.h>
20#include <asm/timer.h> 19#include <asm/timer.h>
21#include <asm/pgtable.h> 20#include <asm/pgtable.h>
22#include <asm/delay.h> 21#include <asm/delay.h>
@@ -25,8 +24,6 @@
25#include <asm/arch_hooks.h> 24#include <asm/arch_hooks.h>
26#include <asm/i8259.h> 25#include <asm/i8259.h>
27 26
28#include <linux/irq.h>
29
30#include <io_ports.h> 27#include <io_ports.h>
31 28
32/* 29/*
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 378313b0cce9..fb3991e8229e 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/irq.h>
25#include <linux/interrupt.h> 24#include <linux/interrupt.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index 15949fd08109..27aabfceb67e 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/irq.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/acpi.h> 18#include <linux/acpi.h>
20#include <linux/delay.h> 19#include <linux/delay.h>
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 0178457db721..72515b8a1b12 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -15,7 +15,6 @@
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/irq.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/bootmem.h> 19#include <linux/bootmem.h>
21#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
index 1e51427cc9eb..25fe66853934 100644
--- a/arch/i386/kernel/pci-dma.c
+++ b/arch/i386/kernel/pci-dma.c
@@ -23,7 +23,7 @@ struct dma_coherent_mem {
23}; 23};
24 24
25void *dma_alloc_coherent(struct device *dev, size_t size, 25void *dma_alloc_coherent(struct device *dev, size_t size,
26 dma_addr_t *dma_handle, unsigned int __nocast gfp) 26 dma_addr_t *dma_handle, gfp_t gfp)
27{ 27{
28 void *ret; 28 void *ret;
29 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; 29 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index b45cbf93d439..7a14fdfd3af9 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -47,13 +47,11 @@
47#include <asm/ldt.h> 47#include <asm/ldt.h>
48#include <asm/processor.h> 48#include <asm/processor.h>
49#include <asm/i387.h> 49#include <asm/i387.h>
50#include <asm/irq.h>
51#include <asm/desc.h> 50#include <asm/desc.h>
52#ifdef CONFIG_MATH_EMULATION 51#ifdef CONFIG_MATH_EMULATION
53#include <asm/math_emu.h> 52#include <asm/math_emu.h>
54#endif 53#endif
55 54
56#include <linux/irq.h>
57#include <linux/err.h> 55#include <linux/err.h>
58 56
59#include <asm/tlbflush.h> 57#include <asm/tlbflush.h>
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index 61eb0c8a6e47..adcd069db91e 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -338,7 +338,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
338 esp = (unsigned long) ka->sa.sa_restorer; 338 esp = (unsigned long) ka->sa.sa_restorer;
339 } 339 }
340 340
341 return (void __user *)((esp - frame_size) & -8ul); 341 esp -= frame_size;
342 /* Align the stack pointer according to the i386 ABI,
343 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
344 esp = ((esp + 4) & -16ul) - 4;
345 return (void __user *) esp;
342} 346}
343 347
344/* These symbols are defined with the addresses in the vsyscall page. 348/* These symbols are defined with the addresses in the vsyscall page.
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 48b55db3680f..218d725a5a1e 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -11,7 +11,6 @@
11#include <linux/init.h> 11#include <linux/init.h>
12 12
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/irq.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/spinlock.h> 15#include <linux/spinlock.h>
17#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 5f0a95d76a4f..1fb26d0e30b6 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -42,7 +42,6 @@
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/kernel_stat.h> 43#include <linux/kernel_stat.h>
44#include <linux/smp_lock.h> 44#include <linux/smp_lock.h>
45#include <linux/irq.h>
46#include <linux/bootmem.h> 45#include <linux/bootmem.h>
47#include <linux/notifier.h> 46#include <linux/notifier.h>
48#include <linux/cpu.h> 47#include <linux/cpu.h>
diff --git a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c
index eddb64038234..e42e46d35159 100644
--- a/arch/i386/kernel/timers/timer_pit.c
+++ b/arch/i386/kernel/timers/timer_pit.c
@@ -6,7 +6,6 @@
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/device.h> 8#include <linux/device.h>
9#include <linux/irq.h>
10#include <linux/sysdev.h> 9#include <linux/sysdev.h>
11#include <linux/timex.h> 10#include <linux/timex.h>
12#include <asm/delay.h> 11#include <asm/delay.h>
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 431a551e46ea..19e90bdd84ea 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -52,7 +52,6 @@
52#include <asm/arch_hooks.h> 52#include <asm/arch_hooks.h>
53#include <asm/kdebug.h> 53#include <asm/kdebug.h>
54 54
55#include <linux/irq.h>
56#include <linux/module.h> 55#include <linux/module.h>
57 56
58#include "mach_traps.h" 57#include "mach_traps.h"
diff --git a/arch/i386/mach-default/setup.c b/arch/i386/mach-default/setup.c
index e5a1a83d09ef..b4a7455c6993 100644
--- a/arch/i386/mach-default/setup.c
+++ b/arch/i386/mach-default/setup.c
@@ -5,7 +5,6 @@
5#include <linux/config.h> 5#include <linux/config.h>
6#include <linux/smp.h> 6#include <linux/smp.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/irq.h>
9#include <linux/interrupt.h> 8#include <linux/interrupt.h>
10#include <asm/acpi.h> 9#include <asm/acpi.h>
11#include <asm/arch_hooks.h> 10#include <asm/arch_hooks.h>
diff --git a/arch/i386/mach-visws/setup.c b/arch/i386/mach-visws/setup.c
index 26ada6fc0d77..07fac7e749c7 100644
--- a/arch/i386/mach-visws/setup.c
+++ b/arch/i386/mach-visws/setup.c
@@ -5,7 +5,6 @@
5 5
6#include <linux/smp.h> 6#include <linux/smp.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/irq.h>
9#include <linux/interrupt.h> 8#include <linux/interrupt.h>
10 9
11#include <asm/fixmap.h> 10#include <asm/fixmap.h>
diff --git a/arch/i386/mach-visws/visws_apic.c b/arch/i386/mach-visws/visws_apic.c
index 04e6585849a2..3e64fb721291 100644
--- a/arch/i386/mach-visws/visws_apic.c
+++ b/arch/i386/mach-visws/visws_apic.c
@@ -19,7 +19,6 @@
19#include <linux/config.h> 19#include <linux/config.h>
20#include <linux/kernel_stat.h> 20#include <linux/kernel_stat.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
24#include <linux/init.h> 23#include <linux/init.h>
25 24
diff --git a/arch/i386/mach-voyager/setup.c b/arch/i386/mach-voyager/setup.c
index df123fc487bb..7d8a3acb9441 100644
--- a/arch/i386/mach-voyager/setup.c
+++ b/arch/i386/mach-voyager/setup.c
@@ -4,7 +4,6 @@
4 4
5#include <linux/config.h> 5#include <linux/config.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/irq.h>
8#include <linux/interrupt.h> 7#include <linux/interrupt.h>
9#include <asm/acpi.h> 8#include <asm/acpi.h>
10#include <asm/arch_hooks.h> 9#include <asm/arch_hooks.h>
diff --git a/arch/i386/mach-voyager/voyager_basic.c b/arch/i386/mach-voyager/voyager_basic.c
index cc69875d979b..aa49a33a572c 100644
--- a/arch/i386/mach-voyager/voyager_basic.c
+++ b/arch/i386/mach-voyager/voyager_basic.c
@@ -27,7 +27,6 @@
27#include <asm/voyager.h> 27#include <asm/voyager.h>
28#include <asm/vic.h> 28#include <asm/vic.h>
29#include <linux/pm.h> 29#include <linux/pm.h>
30#include <linux/irq.h>
31#include <asm/tlbflush.h> 30#include <asm/tlbflush.h>
32#include <asm/arch_hooks.h> 31#include <asm/arch_hooks.h>
33#include <asm/i8253.h> 32#include <asm/i8253.h>
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index 46b0cf4a31e0..72a1b9cae2e4 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -30,8 +30,6 @@
30#include <asm/tlbflush.h> 30#include <asm/tlbflush.h>
31#include <asm/arch_hooks.h> 31#include <asm/arch_hooks.h>
32 32
33#include <linux/irq.h>
34
35/* TLB state -- visible externally, indexed physically */ 33/* TLB state -- visible externally, indexed physically */
36DEFINE_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 };
37 35
diff --git a/arch/i386/mach-voyager/voyager_thread.c b/arch/i386/mach-voyager/voyager_thread.c
index a9341b0eebff..2b03884fdb2a 100644
--- a/arch/i386/mach-voyager/voyager_thread.c
+++ b/arch/i386/mach-voyager/voyager_thread.c
@@ -31,8 +31,6 @@
31#include <asm/mtrr.h> 31#include <asm/mtrr.h>
32#include <asm/msr.h> 32#include <asm/msr.h>
33 33
34#include <linux/irq.h>
35
36#define THREAD_NAME "kvoyagerd" 34#define THREAD_NAME "kvoyagerd"
37 35
38/* external variables */ 36/* external variables */
diff --git a/arch/i386/oprofile/nmi_timer_int.c b/arch/i386/oprofile/nmi_timer_int.c
index ad93cdd55d63..930a1127bb30 100644
--- a/arch/i386/oprofile/nmi_timer_int.c
+++ b/arch/i386/oprofile/nmi_timer_int.c
@@ -9,7 +9,7 @@
9 9
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/irq.h> 12#include <linux/errno.h>
13#include <linux/oprofile.h> 13#include <linux/oprofile.h>
14#include <linux/rcupdate.h> 14#include <linux/rcupdate.h>
15 15
diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
index 2941674f35eb..4c4522b43be5 100644
--- a/arch/i386/pci/acpi.c
+++ b/arch/i386/pci/acpi.c
@@ -2,7 +2,6 @@
2#include <linux/acpi.h> 2#include <linux/acpi.h>
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/irq.h> 4#include <linux/irq.h>
5#include <asm/hw_irq.h>
6#include <asm/numa.h> 5#include <asm/numa.h>
7#include "pci.h" 6#include "pci.h"
8 7
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index 326a2edc3834..cddafe33ff7c 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -11,12 +11,11 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h>
15#include <linux/dmi.h> 14#include <linux/dmi.h>
16#include <asm/io.h> 15#include <asm/io.h>
17#include <asm/smp.h> 16#include <asm/smp.h>
18#include <asm/io_apic.h> 17#include <asm/io_apic.h>
19#include <asm/hw_irq.h> 18#include <linux/irq.h>
20#include <linux/acpi.h> 19#include <linux/acpi.h>
21 20
22#include "pci.h" 21#include "pci.h"
diff --git a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
index 7b0b9ad848e5..b27c5acc79d0 100644
--- a/arch/i386/power/cpu.c
+++ b/arch/i386/power/cpu.c
@@ -8,25 +8,8 @@
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/kernel.h>
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/types.h>
15#include <linux/spinlock.h>
16#include <linux/poll.h>
17#include <linux/delay.h>
18#include <linux/sysrq.h>
19#include <linux/proc_fs.h>
20#include <linux/irq.h>
21#include <linux/pm.h>
22#include <linux/device.h>
23#include <linux/suspend.h> 12#include <linux/suspend.h>
24#include <linux/acpi.h>
25
26#include <asm/uaccess.h>
27#include <asm/acpi.h>
28#include <asm/tlbflush.h>
29#include <asm/processor.h>
30 13
31static struct saved_context saved_context; 14static struct saved_context saved_context;
32 15
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index 80f8ef013939..317c334c5a18 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -17,7 +17,7 @@
17#include <asm/machvec.h> 17#include <asm/machvec.h>
18 18
19/* swiotlb declarations & definitions: */ 19/* swiotlb declarations & definitions: */
20extern void swiotlb_init_with_default_size (size_t size); 20extern int swiotlb_late_init_with_default_size (size_t size);
21extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent; 21extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent;
22extern ia64_mv_dma_free_coherent swiotlb_free_coherent; 22extern ia64_mv_dma_free_coherent swiotlb_free_coherent;
23extern ia64_mv_dma_map_single swiotlb_map_single; 23extern ia64_mv_dma_map_single swiotlb_map_single;
@@ -67,7 +67,16 @@ void
67hwsw_init (void) 67hwsw_init (void)
68{ 68{
69 /* default to a smallish 2MB sw I/O TLB */ 69 /* default to a smallish 2MB sw I/O TLB */
70 swiotlb_init_with_default_size (2 * (1<<20)); 70 if (swiotlb_late_init_with_default_size (2 * (1<<20)) != 0) {
71#ifdef CONFIG_IA64_GENERIC
72 /* Better to have normal DMA than panic */
73 printk(KERN_WARNING "%s: Failed to initialize software I/O TLB,"
74 " reverting to hpzx1 platform vector\n", __FUNCTION__);
75 machvec_init("hpzx1");
76#else
77 panic("Unable to initialize software I/O TLB services");
78#endif
79 }
71} 80}
72 81
73void * 82void *
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 11957598a8b9..e64ca04ace89 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2028,9 +2028,40 @@ static struct acpi_driver acpi_sba_ioc_driver = {
2028static int __init 2028static int __init
2029sba_init(void) 2029sba_init(void)
2030{ 2030{
2031 if (!ia64_platform_is("hpzx1") && !ia64_platform_is("hpzx1_swiotlb"))
2032 return 0;
2033
2031 acpi_bus_register_driver(&acpi_sba_ioc_driver); 2034 acpi_bus_register_driver(&acpi_sba_ioc_driver);
2032 if (!ioc_list) 2035 if (!ioc_list) {
2036#ifdef CONFIG_IA64_GENERIC
2037 extern int swiotlb_late_init_with_default_size (size_t size);
2038
2039 /*
2040 * If we didn't find something sba_iommu can claim, we
2041 * need to setup the swiotlb and switch to the dig machvec.
2042 */
2043 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
2044 panic("Unable to find SBA IOMMU or initialize "
2045 "software I/O TLB: Try machvec=dig boot option");
2046 machvec_init("dig");
2047#else
2048 panic("Unable to find SBA IOMMU: Try a generic or DIG kernel");
2049#endif
2033 return 0; 2050 return 0;
2051 }
2052
2053#if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_HP_ZX1_SWIOTLB)
2054 /*
2055 * hpzx1_swiotlb needs to have a fairly small swiotlb bounce
2056 * buffer setup to support devices with smaller DMA masks than
2057 * sba_iommu can handle.
2058 */
2059 if (ia64_platform_is("hpzx1_swiotlb")) {
2060 extern void hwsw_init(void);
2061
2062 hwsw_init();
2063 }
2064#endif
2034 2065
2035#ifdef CONFIG_PCI 2066#ifdef CONFIG_PCI
2036 { 2067 {
@@ -2048,18 +2079,6 @@ sba_init(void)
2048 2079
2049subsys_initcall(sba_init); /* must be initialized after ACPI etc., but before any drivers... */ 2080subsys_initcall(sba_init); /* must be initialized after ACPI etc., but before any drivers... */
2050 2081
2051extern void dig_setup(char**);
2052/*
2053 * MAX_DMA_ADDRESS needs to be setup prior to paging_init to do any good,
2054 * so we use the platform_setup hook to fix it up.
2055 */
2056void __init
2057sba_setup(char **cmdline_p)
2058{
2059 MAX_DMA_ADDRESS = ~0UL;
2060 dig_setup(cmdline_p);
2061}
2062
2063static int __init 2082static int __init
2064nosbagart(char *str) 2083nosbagart(char *str)
2065{ 2084{
diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
index 56405dbfd739..a18983a3c934 100644
--- a/arch/ia64/hp/sim/simscsi.c
+++ b/arch/ia64/hp/sim/simscsi.c
@@ -233,6 +233,23 @@ simscsi_readwrite10 (struct scsi_cmnd *sc, int mode)
233 simscsi_readwrite(sc, mode, offset, ((sc->cmnd[7] << 8) | sc->cmnd[8])*512); 233 simscsi_readwrite(sc, mode, offset, ((sc->cmnd[7] << 8) | sc->cmnd[8])*512);
234} 234}
235 235
236static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len)
237{
238
239 int scatterlen = sc->use_sg;
240 struct scatterlist *slp;
241
242 if (scatterlen == 0)
243 memcpy(sc->request_buffer, buf, len);
244 else for (slp = (struct scatterlist *)sc->buffer; scatterlen-- > 0 && len > 0; slp++) {
245 unsigned thislen = min(len, slp->length);
246
247 memcpy(page_address(slp->page) + slp->offset, buf, thislen);
248 slp++;
249 len -= thislen;
250 }
251}
252
236static int 253static int
237simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 254simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
238{ 255{
@@ -240,6 +257,7 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
240 char fname[MAX_ROOT_LEN+16]; 257 char fname[MAX_ROOT_LEN+16];
241 size_t disk_size; 258 size_t disk_size;
242 char *buf; 259 char *buf;
260 char localbuf[36];
243#if DEBUG_SIMSCSI 261#if DEBUG_SIMSCSI
244 register long sp asm ("sp"); 262 register long sp asm ("sp");
245 263
@@ -263,7 +281,7 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
263 /* disk doesn't exist... */ 281 /* disk doesn't exist... */
264 break; 282 break;
265 } 283 }
266 buf = sc->request_buffer; 284 buf = localbuf;
267 buf[0] = 0; /* magnetic disk */ 285 buf[0] = 0; /* magnetic disk */
268 buf[1] = 0; /* not a removable medium */ 286 buf[1] = 0; /* not a removable medium */
269 buf[2] = 2; /* SCSI-2 compliant device */ 287 buf[2] = 2; /* SCSI-2 compliant device */
@@ -273,6 +291,7 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
273 buf[6] = 0; /* reserved */ 291 buf[6] = 0; /* reserved */
274 buf[7] = 0; /* various flags */ 292 buf[7] = 0; /* various flags */
275 memcpy(buf + 8, "HP SIMULATED DISK 0.00", 28); 293 memcpy(buf + 8, "HP SIMULATED DISK 0.00", 28);
294 simscsi_fillresult(sc, buf, 36);
276 sc->result = GOOD; 295 sc->result = GOOD;
277 break; 296 break;
278 297
@@ -304,16 +323,13 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
304 simscsi_readwrite10(sc, SSC_WRITE); 323 simscsi_readwrite10(sc, SSC_WRITE);
305 break; 324 break;
306 325
307
308 case READ_CAPACITY: 326 case READ_CAPACITY:
309 if (desc[target_id] < 0 || sc->request_bufflen < 8) { 327 if (desc[target_id] < 0 || sc->request_bufflen < 8) {
310 break; 328 break;
311 } 329 }
312 buf = sc->request_buffer; 330 buf = localbuf;
313
314 disk_size = simscsi_get_disk_size(desc[target_id]); 331 disk_size = simscsi_get_disk_size(desc[target_id]);
315 332
316 /* pretend to be a 1GB disk (partition table contains real stuff): */
317 buf[0] = (disk_size >> 24) & 0xff; 333 buf[0] = (disk_size >> 24) & 0xff;
318 buf[1] = (disk_size >> 16) & 0xff; 334 buf[1] = (disk_size >> 16) & 0xff;
319 buf[2] = (disk_size >> 8) & 0xff; 335 buf[2] = (disk_size >> 8) & 0xff;
@@ -323,13 +339,14 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
323 buf[5] = 0; 339 buf[5] = 0;
324 buf[6] = 2; 340 buf[6] = 2;
325 buf[7] = 0; 341 buf[7] = 0;
342 simscsi_fillresult(sc, buf, 8);
326 sc->result = GOOD; 343 sc->result = GOOD;
327 break; 344 break;
328 345
329 case MODE_SENSE: 346 case MODE_SENSE:
330 case MODE_SENSE_10: 347 case MODE_SENSE_10:
331 /* sd.c uses this to determine whether disk does write-caching. */ 348 /* sd.c uses this to determine whether disk does write-caching. */
332 memset(sc->request_buffer, 0, 128); 349 simscsi_fillresult(sc, (char *)empty_zero_page, sc->request_bufflen);
333 sc->result = GOOD; 350 sc->result = GOOD;
334 break; 351 break;
335 352
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 28a4529fdd60..7e926471e4ec 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -899,7 +899,7 @@ int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
899 if ((err = iosapic_init(phys_addr, gsi_base))) 899 if ((err = iosapic_init(phys_addr, gsi_base)))
900 return err; 900 return err;
901 901
902#if CONFIG_ACPI_NUMA 902#ifdef CONFIG_ACPI_NUMA
903 acpi_map_iosapic(handle, 0, NULL, NULL); 903 acpi_map_iosapic(handle, 0, NULL, NULL);
904#endif /* CONFIG_ACPI_NUMA */ 904#endif /* CONFIG_ACPI_NUMA */
905 905
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index ba0b6a1f429f..0741b066b98f 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -491,7 +491,7 @@ GLOBAL_ENTRY(prefetch_stack)
491 ;; 491 ;;
492 lfetch.fault [r16], 128 492 lfetch.fault [r16], 128
493 br.ret.sptk.many rp 493 br.ret.sptk.many rp
494END(prefetch_switch_stack) 494END(prefetch_stack)
495 495
496GLOBAL_ENTRY(execve) 496GLOBAL_ENTRY(execve)
497 mov r15=__NR_execve // put syscall number in place 497 mov r15=__NR_execve // put syscall number in place
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 6dc726ad7137..d0a5106fba24 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1016,6 +1016,11 @@ ia64_mca_cmc_int_handler(int cmc_irq, void *arg, struct pt_regs *ptregs)
1016 1016
1017 cmc_polling_enabled = 1; 1017 cmc_polling_enabled = 1;
1018 spin_unlock(&cmc_history_lock); 1018 spin_unlock(&cmc_history_lock);
1019 /* If we're being hit with CMC interrupts, we won't
1020 * ever execute the schedule_work() below. Need to
1021 * disable CMC interrupts on this processor now.
1022 */
1023 ia64_mca_cmc_vector_disable(NULL);
1019 schedule_work(&cmc_disable_work); 1024 schedule_work(&cmc_disable_work);
1020 1025
1021 /* 1026 /*
diff --git a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
index 499a065f4e60..db32fc1d3935 100644
--- a/arch/ia64/kernel/mca_asm.S
+++ b/arch/ia64/kernel/mca_asm.S
@@ -489,24 +489,27 @@ ia64_state_save:
489 ;; 489 ;;
490 st8 [temp1]=r17,16 // pal_min_state 490 st8 [temp1]=r17,16 // pal_min_state
491 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT 491 st8 [temp2]=r6,16 // prev_IA64_KR_CURRENT
492 mov r6=IA64_KR(CURRENT_STACK)
493 ;;
494 st8 [temp1]=r6,16 // prev_IA64_KR_CURRENT_STACK
495 st8 [temp2]=r0,16 // prev_task, starts off as NULL
492 mov r6=cr.ifa 496 mov r6=cr.ifa
493 ;; 497 ;;
494 st8 [temp1]=r0,16 // prev_task, starts off as NULL 498 st8 [temp1]=r12,16 // cr.isr
495 st8 [temp2]=r12,16 // cr.isr 499 st8 [temp2]=r6,16 // cr.ifa
496 mov r12=cr.itir 500 mov r12=cr.itir
497 ;; 501 ;;
498 st8 [temp1]=r6,16 // cr.ifa 502 st8 [temp1]=r12,16 // cr.itir
499 st8 [temp2]=r12,16 // cr.itir 503 st8 [temp2]=r11,16 // cr.iipa
500 mov r12=cr.iim 504 mov r12=cr.iim
501 ;; 505 ;;
502 st8 [temp1]=r11,16 // cr.iipa 506 st8 [temp1]=r12,16 // cr.iim
503 st8 [temp2]=r12,16 // cr.iim
504 mov r6=cr.iha
505(p1) mov r12=IA64_MCA_COLD_BOOT 507(p1) mov r12=IA64_MCA_COLD_BOOT
506(p2) mov r12=IA64_INIT_WARM_BOOT 508(p2) mov r12=IA64_INIT_WARM_BOOT
509 mov r6=cr.iha
507 ;; 510 ;;
508 st8 [temp1]=r6,16 // cr.iha 511 st8 [temp2]=r6,16 // cr.iha
509 st8 [temp2]=r12 // os_status, default is cold boot 512 st8 [temp1]=r12 // os_status, default is cold boot
510 mov r6=IA64_MCA_SAME_CONTEXT 513 mov r6=IA64_MCA_SAME_CONTEXT
511 ;; 514 ;;
512 st8 [temp1]=r6 // context, default is same context 515 st8 [temp1]=r6 // context, default is same context
@@ -823,9 +826,12 @@ ia64_state_restore:
823 ld8 r12=[temp1],16 // sal_ra 826 ld8 r12=[temp1],16 // sal_ra
824 ld8 r9=[temp2],16 // sal_gp 827 ld8 r9=[temp2],16 // sal_gp
825 ;; 828 ;;
826 ld8 r22=[temp1],24 // pal_min_state, virtual. skip prev_task 829 ld8 r22=[temp1],16 // pal_min_state, virtual
827 ld8 r21=[temp2],16 // prev_IA64_KR_CURRENT 830 ld8 r21=[temp2],16 // prev_IA64_KR_CURRENT
828 ;; 831 ;;
832 ld8 r16=[temp1],16 // prev_IA64_KR_CURRENT_STACK
833 ld8 r20=[temp2],16 // prev_task
834 ;;
829 ld8 temp3=[temp1],16 // cr.isr 835 ld8 temp3=[temp1],16 // cr.isr
830 ld8 temp4=[temp2],16 // cr.ifa 836 ld8 temp4=[temp2],16 // cr.ifa
831 ;; 837 ;;
@@ -846,6 +852,45 @@ ia64_state_restore:
846 ld8 r8=[temp1] // os_status 852 ld8 r8=[temp1] // os_status
847 ld8 r10=[temp2] // context 853 ld8 r10=[temp2] // context
848 854
855 /* Wire IA64_TR_CURRENT_STACK to the stack that we are resuming to. To
856 * avoid any dependencies on the algorithm in ia64_switch_to(), just
857 * purge any existing CURRENT_STACK mapping and insert the new one.
858 *
859 * r16 contains prev_IA64_KR_CURRENT_STACK, r21 contains
860 * prev_IA64_KR_CURRENT, these values may have been changed by the C
861 * code. Do not use r8, r9, r10, r22, they contain values ready for
862 * the return to SAL.
863 */
864
865 mov r15=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
866 ;;
867 shl r15=r15,IA64_GRANULE_SHIFT
868 ;;
869 dep r15=-1,r15,61,3 // virtual granule
870 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
871 ;;
872 ptr.d r15,r18
873 ;;
874 srlz.d
875
876 extr.u r19=r21,61,3 // r21 = prev_IA64_KR_CURRENT
877 shl r20=r16,IA64_GRANULE_SHIFT // r16 = prev_IA64_KR_CURRENT_STACK
878 movl r21=PAGE_KERNEL // page properties
879 ;;
880 mov IA64_KR(CURRENT_STACK)=r16
881 cmp.ne p6,p0=RGN_KERNEL,r19 // new stack is in the kernel region?
882 or r21=r20,r21 // construct PA | page properties
883(p6) br.spnt 1f // the dreaded cpu 0 idle task in region 5:(
884 ;;
885 mov cr.itir=r18
886 mov cr.ifa=r21
887 mov r20=IA64_TR_CURRENT_STACK
888 ;;
889 itr.d dtr[r20]=r21
890 ;;
891 srlz.d
8921:
893
849 br.sptk b0 894 br.sptk b0
850 895
851//EndStub////////////////////////////////////////////////////////////////////// 896//EndStub//////////////////////////////////////////////////////////////////////
@@ -982,6 +1027,7 @@ ia64_set_kernel_registers:
982 add temp4=temp4, temp1 // &struct ia64_sal_os_state.os_gp 1027 add temp4=temp4, temp1 // &struct ia64_sal_os_state.os_gp
983 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack 1028 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack
984 add r13=temp1, r3 // set current to start of MCA/INIT stack 1029 add r13=temp1, r3 // set current to start of MCA/INIT stack
1030 add r20=temp1, r3 // physical start of MCA/INIT stack
985 ;; 1031 ;;
986 ld8 r1=[temp4] // OS GP from SAL OS state 1032 ld8 r1=[temp4] // OS GP from SAL OS state
987 ;; 1033 ;;
@@ -991,7 +1037,35 @@ ia64_set_kernel_registers:
991 ;; 1037 ;;
992 mov IA64_KR(CURRENT)=r13 1038 mov IA64_KR(CURRENT)=r13
993 1039
994 // FIXME: do I need to wire IA64_KR_CURRENT_STACK and IA64_TR_CURRENT_STACK? 1040 /* Wire IA64_TR_CURRENT_STACK to the MCA/INIT handler stack. To avoid
1041 * any dependencies on the algorithm in ia64_switch_to(), just purge
1042 * any existing CURRENT_STACK mapping and insert the new one.
1043 */
1044
1045 mov r16=IA64_KR(CURRENT_STACK) // physical granule mapped by IA64_TR_CURRENT_STACK
1046 ;;
1047 shl r16=r16,IA64_GRANULE_SHIFT
1048 ;;
1049 dep r16=-1,r16,61,3 // virtual granule
1050 mov r18=IA64_GRANULE_SHIFT<<2 // for cr.itir.ps
1051 ;;
1052 ptr.d r16,r18
1053 ;;
1054 srlz.d
1055
1056 shr.u r16=r20,IA64_GRANULE_SHIFT // r20 = physical start of MCA/INIT stack
1057 movl r21=PAGE_KERNEL // page properties
1058 ;;
1059 mov IA64_KR(CURRENT_STACK)=r16
1060 or r21=r20,r21 // construct PA | page properties
1061 ;;
1062 mov cr.itir=r18
1063 mov cr.ifa=r13
1064 mov r20=IA64_TR_CURRENT_STACK
1065 ;;
1066 itr.d dtr[r20]=r21
1067 ;;
1068 srlz.d
995 1069
996 br.sptk b0 1070 br.sptk b0
997 1071
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index 6e683745af49..f081c60ab206 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -56,8 +56,9 @@ static struct page *page_isolate[MAX_PAGE_ISOLATE];
56static int num_page_isolate = 0; 56static int num_page_isolate = 0;
57 57
58typedef enum { 58typedef enum {
59 ISOLATE_NG = 0, 59 ISOLATE_NG,
60 ISOLATE_OK = 1 60 ISOLATE_OK,
61 ISOLATE_NONE
61} isolate_status_t; 62} isolate_status_t;
62 63
63/* 64/*
@@ -74,7 +75,7 @@ static struct {
74 * @paddr: poisoned memory location 75 * @paddr: poisoned memory location
75 * 76 *
76 * Return value: 77 * Return value:
77 * ISOLATE_OK / ISOLATE_NG 78 * one of isolate_status_t, ISOLATE_OK/NG/NONE.
78 */ 79 */
79 80
80static isolate_status_t 81static isolate_status_t
@@ -84,23 +85,26 @@ mca_page_isolate(unsigned long paddr)
84 struct page *p; 85 struct page *p;
85 86
86 /* whether physical address is valid or not */ 87 /* whether physical address is valid or not */
87 if ( !ia64_phys_addr_valid(paddr) ) 88 if (!ia64_phys_addr_valid(paddr))
88 return ISOLATE_NG; 89 return ISOLATE_NONE;
90
91 if (!pfn_valid(paddr))
92 return ISOLATE_NONE;
89 93
90 /* convert physical address to physical page number */ 94 /* convert physical address to physical page number */
91 p = pfn_to_page(paddr>>PAGE_SHIFT); 95 p = pfn_to_page(paddr>>PAGE_SHIFT);
92 96
93 /* check whether a page number have been already registered or not */ 97 /* check whether a page number have been already registered or not */
94 for( i = 0; i < num_page_isolate; i++ ) 98 for (i = 0; i < num_page_isolate; i++)
95 if( page_isolate[i] == p ) 99 if (page_isolate[i] == p)
96 return ISOLATE_OK; /* already listed */ 100 return ISOLATE_OK; /* already listed */
97 101
98 /* limitation check */ 102 /* limitation check */
99 if( num_page_isolate == MAX_PAGE_ISOLATE ) 103 if (num_page_isolate == MAX_PAGE_ISOLATE)
100 return ISOLATE_NG; 104 return ISOLATE_NG;
101 105
102 /* kick pages having attribute 'SLAB' or 'Reserved' */ 106 /* kick pages having attribute 'SLAB' or 'Reserved' */
103 if( PageSlab(p) || PageReserved(p) ) 107 if (PageSlab(p) || PageReserved(p))
104 return ISOLATE_NG; 108 return ISOLATE_NG;
105 109
106 /* add attribute 'Reserved' and register the page */ 110 /* add attribute 'Reserved' and register the page */
@@ -122,10 +126,15 @@ mca_handler_bh(unsigned long paddr)
122 current->pid, current->comm); 126 current->pid, current->comm);
123 127
124 spin_lock(&mca_bh_lock); 128 spin_lock(&mca_bh_lock);
125 if (mca_page_isolate(paddr) == ISOLATE_OK) { 129 switch (mca_page_isolate(paddr)) {
130 case ISOLATE_OK:
126 printk(KERN_DEBUG "Page isolation: ( %lx ) success.\n", paddr); 131 printk(KERN_DEBUG "Page isolation: ( %lx ) success.\n", paddr);
127 } else { 132 break;
133 case ISOLATE_NG:
128 printk(KERN_DEBUG "Page isolation: ( %lx ) failure.\n", paddr); 134 printk(KERN_DEBUG "Page isolation: ( %lx ) failure.\n", paddr);
135 break;
136 default:
137 break;
129 } 138 }
130 spin_unlock(&mca_bh_lock); 139 spin_unlock(&mca_bh_lock);
131 140
@@ -139,10 +148,10 @@ mca_handler_bh(unsigned long paddr)
139 * @peidx: pointer to index of processor error section 148 * @peidx: pointer to index of processor error section
140 */ 149 */
141 150
142static void 151static void
143mca_make_peidx(sal_log_processor_info_t *slpi, peidx_table_t *peidx) 152mca_make_peidx(sal_log_processor_info_t *slpi, peidx_table_t *peidx)
144{ 153{
145 /* 154 /*
146 * calculate the start address of 155 * calculate the start address of
147 * "struct cpuid_info" and "sal_processor_static_info_t". 156 * "struct cpuid_info" and "sal_processor_static_info_t".
148 */ 157 */
@@ -164,7 +173,7 @@ mca_make_peidx(sal_log_processor_info_t *slpi, peidx_table_t *peidx)
164} 173}
165 174
166/** 175/**
167 * mca_make_slidx - Make index of SAL error record 176 * mca_make_slidx - Make index of SAL error record
168 * @buffer: pointer to SAL error record 177 * @buffer: pointer to SAL error record
169 * @slidx: pointer to index of SAL error record 178 * @slidx: pointer to index of SAL error record
170 * 179 *
@@ -172,12 +181,12 @@ mca_make_peidx(sal_log_processor_info_t *slpi, peidx_table_t *peidx)
172 * 1 if record has platform error / 0 if not 181 * 1 if record has platform error / 0 if not
173 */ 182 */
174#define LOG_INDEX_ADD_SECT_PTR(sect, ptr) \ 183#define LOG_INDEX_ADD_SECT_PTR(sect, ptr) \
175 { slidx_list_t *hl = &slidx_pool.buffer[slidx_pool.cur_idx]; \ 184 {slidx_list_t *hl = &slidx_pool.buffer[slidx_pool.cur_idx]; \
176 hl->hdr = ptr; \ 185 hl->hdr = ptr; \
177 list_add(&hl->list, &(sect)); \ 186 list_add(&hl->list, &(sect)); \
178 slidx_pool.cur_idx = (slidx_pool.cur_idx + 1)%slidx_pool.max_idx; } 187 slidx_pool.cur_idx = (slidx_pool.cur_idx + 1)%slidx_pool.max_idx; }
179 188
180static int 189static int
181mca_make_slidx(void *buffer, slidx_table_t *slidx) 190mca_make_slidx(void *buffer, slidx_table_t *slidx)
182{ 191{
183 int platform_err = 0; 192 int platform_err = 0;
@@ -214,28 +223,36 @@ mca_make_slidx(void *buffer, slidx_table_t *slidx)
214 sp = (sal_log_section_hdr_t *)((char*)buffer + ercd_pos); 223 sp = (sal_log_section_hdr_t *)((char*)buffer + ercd_pos);
215 if (!efi_guidcmp(sp->guid, SAL_PROC_DEV_ERR_SECT_GUID)) { 224 if (!efi_guidcmp(sp->guid, SAL_PROC_DEV_ERR_SECT_GUID)) {
216 LOG_INDEX_ADD_SECT_PTR(slidx->proc_err, sp); 225 LOG_INDEX_ADD_SECT_PTR(slidx->proc_err, sp);
217 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_MEM_DEV_ERR_SECT_GUID)) { 226 } else if (!efi_guidcmp(sp->guid,
227 SAL_PLAT_MEM_DEV_ERR_SECT_GUID)) {
218 platform_err = 1; 228 platform_err = 1;
219 LOG_INDEX_ADD_SECT_PTR(slidx->mem_dev_err, sp); 229 LOG_INDEX_ADD_SECT_PTR(slidx->mem_dev_err, sp);
220 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_SEL_DEV_ERR_SECT_GUID)) { 230 } else if (!efi_guidcmp(sp->guid,
231 SAL_PLAT_SEL_DEV_ERR_SECT_GUID)) {
221 platform_err = 1; 232 platform_err = 1;
222 LOG_INDEX_ADD_SECT_PTR(slidx->sel_dev_err, sp); 233 LOG_INDEX_ADD_SECT_PTR(slidx->sel_dev_err, sp);
223 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_PCI_BUS_ERR_SECT_GUID)) { 234 } else if (!efi_guidcmp(sp->guid,
235 SAL_PLAT_PCI_BUS_ERR_SECT_GUID)) {
224 platform_err = 1; 236 platform_err = 1;
225 LOG_INDEX_ADD_SECT_PTR(slidx->pci_bus_err, sp); 237 LOG_INDEX_ADD_SECT_PTR(slidx->pci_bus_err, sp);
226 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_SMBIOS_DEV_ERR_SECT_GUID)) { 238 } else if (!efi_guidcmp(sp->guid,
239 SAL_PLAT_SMBIOS_DEV_ERR_SECT_GUID)) {
227 platform_err = 1; 240 platform_err = 1;
228 LOG_INDEX_ADD_SECT_PTR(slidx->smbios_dev_err, sp); 241 LOG_INDEX_ADD_SECT_PTR(slidx->smbios_dev_err, sp);
229 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_PCI_COMP_ERR_SECT_GUID)) { 242 } else if (!efi_guidcmp(sp->guid,
243 SAL_PLAT_PCI_COMP_ERR_SECT_GUID)) {
230 platform_err = 1; 244 platform_err = 1;
231 LOG_INDEX_ADD_SECT_PTR(slidx->pci_comp_err, sp); 245 LOG_INDEX_ADD_SECT_PTR(slidx->pci_comp_err, sp);
232 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_SPECIFIC_ERR_SECT_GUID)) { 246 } else if (!efi_guidcmp(sp->guid,
247 SAL_PLAT_SPECIFIC_ERR_SECT_GUID)) {
233 platform_err = 1; 248 platform_err = 1;
234 LOG_INDEX_ADD_SECT_PTR(slidx->plat_specific_err, sp); 249 LOG_INDEX_ADD_SECT_PTR(slidx->plat_specific_err, sp);
235 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_HOST_CTLR_ERR_SECT_GUID)) { 250 } else if (!efi_guidcmp(sp->guid,
251 SAL_PLAT_HOST_CTLR_ERR_SECT_GUID)) {
236 platform_err = 1; 252 platform_err = 1;
237 LOG_INDEX_ADD_SECT_PTR(slidx->host_ctlr_err, sp); 253 LOG_INDEX_ADD_SECT_PTR(slidx->host_ctlr_err, sp);
238 } else if (!efi_guidcmp(sp->guid, SAL_PLAT_BUS_ERR_SECT_GUID)) { 254 } else if (!efi_guidcmp(sp->guid,
255 SAL_PLAT_BUS_ERR_SECT_GUID)) {
239 platform_err = 1; 256 platform_err = 1;
240 LOG_INDEX_ADD_SECT_PTR(slidx->plat_bus_err, sp); 257 LOG_INDEX_ADD_SECT_PTR(slidx->plat_bus_err, sp);
241 } else { 258 } else {
@@ -253,15 +270,16 @@ mca_make_slidx(void *buffer, slidx_table_t *slidx)
253 * Return value: 270 * Return value:
254 * 0 on Success / -ENOMEM on Failure 271 * 0 on Success / -ENOMEM on Failure
255 */ 272 */
256static int 273static int
257init_record_index_pools(void) 274init_record_index_pools(void)
258{ 275{
259 int i; 276 int i;
260 int rec_max_size; /* Maximum size of SAL error records */ 277 int rec_max_size; /* Maximum size of SAL error records */
261 int sect_min_size; /* Minimum size of SAL error sections */ 278 int sect_min_size; /* Minimum size of SAL error sections */
262 /* minimum size table of each section */ 279 /* minimum size table of each section */
263 static int sal_log_sect_min_sizes[] = { 280 static int sal_log_sect_min_sizes[] = {
264 sizeof(sal_log_processor_info_t) + sizeof(sal_processor_static_info_t), 281 sizeof(sal_log_processor_info_t)
282 + sizeof(sal_processor_static_info_t),
265 sizeof(sal_log_mem_dev_err_info_t), 283 sizeof(sal_log_mem_dev_err_info_t),
266 sizeof(sal_log_sel_dev_err_info_t), 284 sizeof(sal_log_sel_dev_err_info_t),
267 sizeof(sal_log_pci_bus_err_info_t), 285 sizeof(sal_log_pci_bus_err_info_t),
@@ -294,7 +312,8 @@ init_record_index_pools(void)
294 312
295 /* - 3 - */ 313 /* - 3 - */
296 slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1; 314 slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
297 slidx_pool.buffer = (slidx_list_t *) kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL); 315 slidx_pool.buffer = (slidx_list_t *)
316 kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
298 317
299 return slidx_pool.buffer ? 0 : -ENOMEM; 318 return slidx_pool.buffer ? 0 : -ENOMEM;
300} 319}
@@ -308,6 +327,7 @@ init_record_index_pools(void)
308 * is_mca_global - Check whether this MCA is global or not 327 * is_mca_global - Check whether this MCA is global or not
309 * @peidx: pointer of index of processor error section 328 * @peidx: pointer of index of processor error section
310 * @pbci: pointer to pal_bus_check_info_t 329 * @pbci: pointer to pal_bus_check_info_t
330 * @sos: pointer to hand off struct between SAL and OS
311 * 331 *
312 * Return value: 332 * Return value:
313 * MCA_IS_LOCAL / MCA_IS_GLOBAL 333 * MCA_IS_LOCAL / MCA_IS_GLOBAL
@@ -317,11 +337,12 @@ static mca_type_t
317is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci, 337is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci,
318 struct ia64_sal_os_state *sos) 338 struct ia64_sal_os_state *sos)
319{ 339{
320 pal_processor_state_info_t *psp = (pal_processor_state_info_t*)peidx_psp(peidx); 340 pal_processor_state_info_t *psp =
341 (pal_processor_state_info_t*)peidx_psp(peidx);
321 342
322 /* 343 /*
323 * PAL can request a rendezvous, if the MCA has a global scope. 344 * PAL can request a rendezvous, if the MCA has a global scope.
324 * If "rz_always" flag is set, SAL requests MCA rendezvous 345 * If "rz_always" flag is set, SAL requests MCA rendezvous
325 * in spite of global MCA. 346 * in spite of global MCA.
326 * Therefore it is local MCA when rendezvous has not been requested. 347 * Therefore it is local MCA when rendezvous has not been requested.
327 * Failed to rendezvous, the system must be down. 348 * Failed to rendezvous, the system must be down.
@@ -381,13 +402,15 @@ is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci,
381 * @slidx: pointer of index of SAL error record 402 * @slidx: pointer of index of SAL error record
382 * @peidx: pointer of index of processor error section 403 * @peidx: pointer of index of processor error section
383 * @pbci: pointer of pal_bus_check_info 404 * @pbci: pointer of pal_bus_check_info
405 * @sos: pointer to hand off struct between SAL and OS
384 * 406 *
385 * Return value: 407 * Return value:
386 * 1 on Success / 0 on Failure 408 * 1 on Success / 0 on Failure
387 */ 409 */
388 410
389static int 411static int
390recover_from_read_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_check_info_t *pbci, 412recover_from_read_error(slidx_table_t *slidx,
413 peidx_table_t *peidx, pal_bus_check_info_t *pbci,
391 struct ia64_sal_os_state *sos) 414 struct ia64_sal_os_state *sos)
392{ 415{
393 sal_log_mod_error_info_t *smei; 416 sal_log_mod_error_info_t *smei;
@@ -453,24 +476,28 @@ recover_from_read_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_chec
453 * @slidx: pointer of index of SAL error record 476 * @slidx: pointer of index of SAL error record
454 * @peidx: pointer of index of processor error section 477 * @peidx: pointer of index of processor error section
455 * @pbci: pointer of pal_bus_check_info 478 * @pbci: pointer of pal_bus_check_info
479 * @sos: pointer to hand off struct between SAL and OS
456 * 480 *
457 * Return value: 481 * Return value:
458 * 1 on Success / 0 on Failure 482 * 1 on Success / 0 on Failure
459 */ 483 */
460 484
461static int 485static int
462recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_check_info_t *pbci, 486recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx,
487 pal_bus_check_info_t *pbci,
463 struct ia64_sal_os_state *sos) 488 struct ia64_sal_os_state *sos)
464{ 489{
465 int status = 0; 490 int status = 0;
466 pal_processor_state_info_t *psp = (pal_processor_state_info_t*)peidx_psp(peidx); 491 pal_processor_state_info_t *psp =
492 (pal_processor_state_info_t*)peidx_psp(peidx);
467 493
468 if (psp->bc && pbci->eb && pbci->bsi == 0) { 494 if (psp->bc && pbci->eb && pbci->bsi == 0) {
469 switch(pbci->type) { 495 switch(pbci->type) {
470 case 1: /* partial read */ 496 case 1: /* partial read */
471 case 3: /* full line(cpu) read */ 497 case 3: /* full line(cpu) read */
472 case 9: /* I/O space read */ 498 case 9: /* I/O space read */
473 status = recover_from_read_error(slidx, peidx, pbci, sos); 499 status = recover_from_read_error(slidx, peidx, pbci,
500 sos);
474 break; 501 break;
475 case 0: /* unknown */ 502 case 0: /* unknown */
476 case 2: /* partial write */ 503 case 2: /* partial write */
@@ -481,7 +508,8 @@ recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_
481 case 8: /* write coalescing transactions */ 508 case 8: /* write coalescing transactions */
482 case 10: /* I/O space write */ 509 case 10: /* I/O space write */
483 case 11: /* inter-processor interrupt message(IPI) */ 510 case 11: /* inter-processor interrupt message(IPI) */
484 case 12: /* interrupt acknowledge or external task priority cycle */ 511 case 12: /* interrupt acknowledge or
512 external task priority cycle */
485 default: 513 default:
486 break; 514 break;
487 } 515 }
@@ -496,6 +524,7 @@ recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_
496 * @slidx: pointer of index of SAL error record 524 * @slidx: pointer of index of SAL error record
497 * @peidx: pointer of index of processor error section 525 * @peidx: pointer of index of processor error section
498 * @pbci: pointer of pal_bus_check_info 526 * @pbci: pointer of pal_bus_check_info
527 * @sos: pointer to hand off struct between SAL and OS
499 * 528 *
500 * Return value: 529 * Return value:
501 * 1 on Success / 0 on Failure 530 * 1 on Success / 0 on Failure
@@ -509,15 +538,17 @@ recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_
509 */ 538 */
510 539
511static int 540static int
512recover_from_processor_error(int platform, slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_check_info_t *pbci, 541recover_from_processor_error(int platform, slidx_table_t *slidx,
542 peidx_table_t *peidx, pal_bus_check_info_t *pbci,
513 struct ia64_sal_os_state *sos) 543 struct ia64_sal_os_state *sos)
514{ 544{
515 pal_processor_state_info_t *psp = (pal_processor_state_info_t*)peidx_psp(peidx); 545 pal_processor_state_info_t *psp =
546 (pal_processor_state_info_t*)peidx_psp(peidx);
516 547
517 /* 548 /*
518 * We cannot recover errors with other than bus_check. 549 * We cannot recover errors with other than bus_check.
519 */ 550 */
520 if (psp->cc || psp->rc || psp->uc) 551 if (psp->cc || psp->rc || psp->uc)
521 return 0; 552 return 0;
522 553
523 /* 554 /*
@@ -546,10 +577,10 @@ recover_from_processor_error(int platform, slidx_table_t *slidx, peidx_table_t *
546 * (e.g. a load from poisoned memory) 577 * (e.g. a load from poisoned memory)
547 * This means "there are some platform errors". 578 * This means "there are some platform errors".
548 */ 579 */
549 if (platform) 580 if (platform)
550 return recover_from_platform_error(slidx, peidx, pbci, sos); 581 return recover_from_platform_error(slidx, peidx, pbci, sos);
551 /* 582 /*
552 * On account of strange SAL error record, we cannot recover. 583 * On account of strange SAL error record, we cannot recover.
553 */ 584 */
554 return 0; 585 return 0;
555} 586}
@@ -557,14 +588,14 @@ recover_from_processor_error(int platform, slidx_table_t *slidx, peidx_table_t *
557/** 588/**
558 * mca_try_to_recover - Try to recover from MCA 589 * mca_try_to_recover - Try to recover from MCA
559 * @rec: pointer to a SAL error record 590 * @rec: pointer to a SAL error record
591 * @sos: pointer to hand off struct between SAL and OS
560 * 592 *
561 * Return value: 593 * Return value:
562 * 1 on Success / 0 on Failure 594 * 1 on Success / 0 on Failure
563 */ 595 */
564 596
565static int 597static int
566mca_try_to_recover(void *rec, 598mca_try_to_recover(void *rec, struct ia64_sal_os_state *sos)
567 struct ia64_sal_os_state *sos)
568{ 599{
569 int platform_err; 600 int platform_err;
570 int n_proc_err; 601 int n_proc_err;
@@ -588,7 +619,8 @@ mca_try_to_recover(void *rec,
588 } 619 }
589 620
590 /* Make index of processor error section */ 621 /* Make index of processor error section */
591 mca_make_peidx((sal_log_processor_info_t*)slidx_first_entry(&slidx.proc_err)->hdr, &peidx); 622 mca_make_peidx((sal_log_processor_info_t*)
623 slidx_first_entry(&slidx.proc_err)->hdr, &peidx);
592 624
593 /* Extract Processor BUS_CHECK[0] */ 625 /* Extract Processor BUS_CHECK[0] */
594 *((u64*)&pbci) = peidx_check_info(&peidx, bus_check, 0); 626 *((u64*)&pbci) = peidx_check_info(&peidx, bus_check, 0);
@@ -598,7 +630,8 @@ mca_try_to_recover(void *rec,
598 return 0; 630 return 0;
599 631
600 /* Try to recover a processor error */ 632 /* Try to recover a processor error */
601 return recover_from_processor_error(platform_err, &slidx, &peidx, &pbci, sos); 633 return recover_from_processor_error(platform_err, &slidx, &peidx,
634 &pbci, sos);
602} 635}
603 636
604/* 637/*
@@ -611,7 +644,7 @@ int __init mca_external_handler_init(void)
611 return -ENOMEM; 644 return -ENOMEM;
612 645
613 /* register external mca handlers */ 646 /* register external mca handlers */
614 if (ia64_reg_MCA_extension(mca_try_to_recover)){ 647 if (ia64_reg_MCA_extension(mca_try_to_recover)) {
615 printk(KERN_ERR "ia64_reg_MCA_extension failed.\n"); 648 printk(KERN_ERR "ia64_reg_MCA_extension failed.\n");
616 kfree(slidx_pool.buffer); 649 kfree(slidx_pool.buffer);
617 return -EFAULT; 650 return -EFAULT;
diff --git a/arch/ia64/kernel/mca_drv.h b/arch/ia64/kernel/mca_drv.h
index 0227b761f2c4..e2f6fa1e0ef6 100644
--- a/arch/ia64/kernel/mca_drv.h
+++ b/arch/ia64/kernel/mca_drv.h
@@ -6,7 +6,7 @@
6 * Copyright (C) Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com) 6 * Copyright (C) Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com)
7 */ 7 */
8/* 8/*
9 * Processor error section: 9 * Processor error section:
10 * 10 *
11 * +-sal_log_processor_info_t *info-------------+ 11 * +-sal_log_processor_info_t *info-------------+
12 * | sal_log_section_hdr_t header; | 12 * | sal_log_section_hdr_t header; |
diff --git a/arch/ia64/kernel/mca_drv_asm.S b/arch/ia64/kernel/mca_drv_asm.S
index 2d7e0217638d..3f298ee4d00c 100644
--- a/arch/ia64/kernel/mca_drv_asm.S
+++ b/arch/ia64/kernel/mca_drv_asm.S
@@ -13,45 +13,45 @@
13#include <asm/ptrace.h> 13#include <asm/ptrace.h>
14 14
15GLOBAL_ENTRY(mca_handler_bhhook) 15GLOBAL_ENTRY(mca_handler_bhhook)
16 invala // clear RSE ? 16 invala // clear RSE ?
17 ;; // 17 ;;
18 cover // 18 cover
19 ;; // 19 ;;
20 clrrrb // 20 clrrrb
21 ;; 21 ;;
22 alloc r16=ar.pfs,0,2,1,0 // make a new frame 22 alloc r16=ar.pfs,0,2,1,0 // make a new frame
23 ;; 23 ;;
24 mov ar.rsc=0 24 mov ar.rsc=0
25 ;; 25 ;;
26 mov r13=IA64_KR(CURRENT) // current task pointer 26 mov r13=IA64_KR(CURRENT) // current task pointer
27 ;; 27 ;;
28 mov r2=r13 28 mov r2=r13
29 ;; 29 ;;
30 addl r22=IA64_RBS_OFFSET,r2 30 addl r22=IA64_RBS_OFFSET,r2
31 ;; 31 ;;
32 mov ar.bspstore=r22 32 mov ar.bspstore=r22
33 ;; 33 ;;
34 addl sp=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r2 34 addl sp=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r2
35 ;; 35 ;;
36 adds r2=IA64_TASK_THREAD_ON_USTACK_OFFSET,r13 36 adds r2=IA64_TASK_THREAD_ON_USTACK_OFFSET,r13
37 ;; 37 ;;
38 st1 [r2]=r0 // clear current->thread.on_ustack flag 38 st1 [r2]=r0 // clear current->thread.on_ustack flag
39 mov loc0=r16 39 mov loc0=r16
40 movl loc1=mca_handler_bh // recovery C function 40 movl loc1=mca_handler_bh // recovery C function
41 ;; 41 ;;
42 mov out0=r8 // poisoned address 42 mov out0=r8 // poisoned address
43 mov b6=loc1 43 mov b6=loc1
44 ;; 44 ;;
45 mov loc1=rp 45 mov loc1=rp
46 ;; 46 ;;
47 ssm psr.i 47 ssm psr.i
48 ;; 48 ;;
49 br.call.sptk.many rp=b6 // does not return ... 49 br.call.sptk.many rp=b6 // does not return ...
50 ;; 50 ;;
51 mov ar.pfs=loc0 51 mov ar.pfs=loc0
52 mov rp=loc1 52 mov rp=loc1
53 ;; 53 ;;
54 mov r8=r0 54 mov r8=r0
55 br.ret.sptk.many rp 55 br.ret.sptk.many rp
56 ;; 56 ;;
57END(mca_handler_bhhook) 57END(mca_handler_bhhook)
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 1650353e3f77..d71731ee5b61 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -574,7 +574,7 @@ pfm_protect_ctx_ctxsw(pfm_context_t *x)
574 return 0UL; 574 return 0UL;
575} 575}
576 576
577static inline unsigned long 577static inline void
578pfm_unprotect_ctx_ctxsw(pfm_context_t *x, unsigned long f) 578pfm_unprotect_ctx_ctxsw(pfm_context_t *x, unsigned long f)
579{ 579{
580 spin_unlock(&(x)->ctx_lock); 580 spin_unlock(&(x)->ctx_lock);
@@ -2218,12 +2218,13 @@ static void
2218pfm_free_fd(int fd, struct file *file) 2218pfm_free_fd(int fd, struct file *file)
2219{ 2219{
2220 struct files_struct *files = current->files; 2220 struct files_struct *files = current->files;
2221 struct fdtable *fdt = files_fdtable(files); 2221 struct fdtable *fdt;
2222 2222
2223 /* 2223 /*
2224 * there ie no fd_uninstall(), so we do it here 2224 * there ie no fd_uninstall(), so we do it here
2225 */ 2225 */
2226 spin_lock(&files->file_lock); 2226 spin_lock(&files->file_lock);
2227 fdt = files_fdtable(files);
2227 rcu_assign_pointer(fdt->fd[fd], NULL); 2228 rcu_assign_pointer(fdt->fd[fd], NULL);
2228 spin_unlock(&files->file_lock); 2229 spin_unlock(&files->file_lock);
2229 2230
diff --git a/arch/ia64/lib/swiotlb.c b/arch/ia64/lib/swiotlb.c
index dbc0b3e449c5..48e5ff26eb1d 100644
--- a/arch/ia64/lib/swiotlb.c
+++ b/arch/ia64/lib/swiotlb.c
@@ -49,6 +49,15 @@
49 */ 49 */
50#define IO_TLB_SHIFT 11 50#define IO_TLB_SHIFT 11
51 51
52#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
53
54/*
55 * Minimum IO TLB size to bother booting with. Systems with mainly
56 * 64bit capable cards will only lightly use the swiotlb. If we can't
57 * allocate a contiguous 1MB, we're probably in trouble anyway.
58 */
59#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
60
52int swiotlb_force; 61int swiotlb_force;
53 62
54/* 63/*
@@ -123,8 +132,8 @@ swiotlb_init_with_default_size (size_t default_size)
123 /* 132 /*
124 * Get IO TLB memory from the low pages 133 * Get IO TLB memory from the low pages
125 */ 134 */
126 io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs * 135 io_tlb_start = alloc_bootmem_low_pages_limit(io_tlb_nslabs *
127 (1 << IO_TLB_SHIFT)); 136 (1 << IO_TLB_SHIFT), 0x100000000);
128 if (!io_tlb_start) 137 if (!io_tlb_start)
129 panic("Cannot allocate SWIOTLB buffer"); 138 panic("Cannot allocate SWIOTLB buffer");
130 io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT); 139 io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
@@ -154,6 +163,99 @@ swiotlb_init (void)
154 swiotlb_init_with_default_size(64 * (1<<20)); /* default to 64MB */ 163 swiotlb_init_with_default_size(64 * (1<<20)); /* default to 64MB */
155} 164}
156 165
166/*
167 * Systems with larger DMA zones (those that don't support ISA) can
168 * initialize the swiotlb later using the slab allocator if needed.
169 * This should be just like above, but with some error catching.
170 */
171int
172swiotlb_late_init_with_default_size (size_t default_size)
173{
174 unsigned long i, req_nslabs = io_tlb_nslabs;
175 unsigned int order;
176
177 if (!io_tlb_nslabs) {
178 io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
179 io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
180 }
181
182 /*
183 * Get IO TLB memory from the low pages
184 */
185 order = get_order(io_tlb_nslabs * (1 << IO_TLB_SHIFT));
186 io_tlb_nslabs = SLABS_PER_PAGE << order;
187
188 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
189 io_tlb_start = (char *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
190 order);
191 if (io_tlb_start)
192 break;
193 order--;
194 }
195
196 if (!io_tlb_start)
197 goto cleanup1;
198
199 if (order != get_order(io_tlb_nslabs * (1 << IO_TLB_SHIFT))) {
200 printk(KERN_WARNING "Warning: only able to allocate %ld MB "
201 "for software IO TLB\n", (PAGE_SIZE << order) >> 20);
202 io_tlb_nslabs = SLABS_PER_PAGE << order;
203 }
204 io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT);
205 memset(io_tlb_start, 0, io_tlb_nslabs * (1 << IO_TLB_SHIFT));
206
207 /*
208 * Allocate and initialize the free list array. This array is used
209 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
210 * between io_tlb_start and io_tlb_end.
211 */
212 io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL,
213 get_order(io_tlb_nslabs * sizeof(int)));
214 if (!io_tlb_list)
215 goto cleanup2;
216
217 for (i = 0; i < io_tlb_nslabs; i++)
218 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE);
219 io_tlb_index = 0;
220
221 io_tlb_orig_addr = (unsigned char **)__get_free_pages(GFP_KERNEL,
222 get_order(io_tlb_nslabs * sizeof(char *)));
223 if (!io_tlb_orig_addr)
224 goto cleanup3;
225
226 memset(io_tlb_orig_addr, 0, io_tlb_nslabs * sizeof(char *));
227
228 /*
229 * Get the overflow emergency buffer
230 */
231 io_tlb_overflow_buffer = (void *)__get_free_pages(GFP_DMA,
232 get_order(io_tlb_overflow));
233 if (!io_tlb_overflow_buffer)
234 goto cleanup4;
235
236 printk(KERN_INFO "Placing %ldMB software IO TLB between 0x%lx - "
237 "0x%lx\n", (io_tlb_nslabs * (1 << IO_TLB_SHIFT)) >> 20,
238 virt_to_phys(io_tlb_start), virt_to_phys(io_tlb_end));
239
240 return 0;
241
242cleanup4:
243 free_pages((unsigned long)io_tlb_orig_addr, get_order(io_tlb_nslabs *
244 sizeof(char *)));
245 io_tlb_orig_addr = NULL;
246cleanup3:
247 free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs *
248 sizeof(int)));
249 io_tlb_list = NULL;
250 io_tlb_end = NULL;
251cleanup2:
252 free_pages((unsigned long)io_tlb_start, order);
253 io_tlb_start = NULL;
254cleanup1:
255 io_tlb_nslabs = req_nslabs;
256 return -ENOMEM;
257}
258
157static inline int 259static inline int
158address_needs_mapping(struct device *hwdev, dma_addr_t addr) 260address_needs_mapping(struct device *hwdev, dma_addr_t addr)
159{ 261{
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index b45db5133f55..e0819ec53116 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -183,11 +183,12 @@ int cx_driver_unregister(struct cx_drv *cx_driver)
183 * @part_num: device's part number 183 * @part_num: device's part number
184 * @mfg_num: device's manufacturer number 184 * @mfg_num: device's manufacturer number
185 * @hubdev: hub info associated with this device 185 * @hubdev: hub info associated with this device
186 * @bt: board type of the device
186 * 187 *
187 */ 188 */
188int 189int
189cx_device_register(nasid_t nasid, int part_num, int mfg_num, 190cx_device_register(nasid_t nasid, int part_num, int mfg_num,
190 struct hubdev_info *hubdev) 191 struct hubdev_info *hubdev, int bt)
191{ 192{
192 struct cx_dev *cx_dev; 193 struct cx_dev *cx_dev;
193 194
@@ -200,6 +201,7 @@ cx_device_register(nasid_t nasid, int part_num, int mfg_num,
200 cx_dev->cx_id.mfg_num = mfg_num; 201 cx_dev->cx_id.mfg_num = mfg_num;
201 cx_dev->cx_id.nasid = nasid; 202 cx_dev->cx_id.nasid = nasid;
202 cx_dev->hubdev = hubdev; 203 cx_dev->hubdev = hubdev;
204 cx_dev->bt = bt;
203 205
204 cx_dev->dev.parent = NULL; 206 cx_dev->dev.parent = NULL;
205 cx_dev->dev.bus = &tiocx_bus_type; 207 cx_dev->dev.bus = &tiocx_bus_type;
@@ -238,7 +240,8 @@ static int cx_device_reload(struct cx_dev *cx_dev)
238{ 240{
239 cx_device_unregister(cx_dev); 241 cx_device_unregister(cx_dev);
240 return cx_device_register(cx_dev->cx_id.nasid, cx_dev->cx_id.part_num, 242 return cx_device_register(cx_dev->cx_id.nasid, cx_dev->cx_id.part_num,
241 cx_dev->cx_id.mfg_num, cx_dev->hubdev); 243 cx_dev->cx_id.mfg_num, cx_dev->hubdev,
244 cx_dev->bt);
242} 245}
243 246
244static inline uint64_t tiocx_intr_alloc(nasid_t nasid, int widget, 247static inline uint64_t tiocx_intr_alloc(nasid_t nasid, int widget,
@@ -365,26 +368,20 @@ static void tio_corelet_reset(nasid_t nasid, int corelet)
365 udelay(2000); 368 udelay(2000);
366} 369}
367 370
368static int tiocx_btchar_get(int nasid) 371static int is_fpga_tio(int nasid, int *bt)
369{ 372{
370 moduleid_t module_id; 373 int ioboard_type;
371 geoid_t geoid;
372 int cnodeid;
373
374 cnodeid = nasid_to_cnodeid(nasid);
375 geoid = cnodeid_get_geoid(cnodeid);
376 module_id = geo_module(geoid);
377 return MODULE_GET_BTCHAR(module_id);
378}
379 374
380static int is_fpga_brick(int nasid) 375 ioboard_type = ia64_sn_sysctl_ioboard_get(nasid);
381{ 376
382 switch (tiocx_btchar_get(nasid)) { 377 switch (ioboard_type) {
383 case L1_BRICKTYPE_SA: 378 case L1_BRICKTYPE_SA:
384 case L1_BRICKTYPE_ATHENA: 379 case L1_BRICKTYPE_ATHENA:
385 case L1_BRICKTYPE_DAYTONA: 380 case L1_BOARDTYPE_DAYTONA:
381 *bt = ioboard_type;
386 return 1; 382 return 1;
387 } 383 }
384
388 return 0; 385 return 0;
389} 386}
390 387
@@ -407,16 +404,22 @@ static int tiocx_reload(struct cx_dev *cx_dev)
407 404
408 if (bitstream_loaded(nasid)) { 405 if (bitstream_loaded(nasid)) {
409 uint64_t cx_id; 406 uint64_t cx_id;
410 407 int rv;
411 cx_id = 408
412 *(volatile uint64_t *)(TIO_SWIN_BASE(nasid, TIOCX_CORELET) + 409 rv = ia64_sn_sysctl_tio_clock_reset(nasid);
410 if (rv) {
411 printk(KERN_ALERT "CX port JTAG reset failed.\n");
412 } else {
413 cx_id = *(volatile uint64_t *)
414 (TIO_SWIN_BASE(nasid, TIOCX_CORELET) +
413 WIDGET_ID); 415 WIDGET_ID);
414 part_num = XWIDGET_PART_NUM(cx_id); 416 part_num = XWIDGET_PART_NUM(cx_id);
415 mfg_num = XWIDGET_MFG_NUM(cx_id); 417 mfg_num = XWIDGET_MFG_NUM(cx_id);
416 DBG("part= 0x%x, mfg= 0x%x\n", part_num, mfg_num); 418 DBG("part= 0x%x, mfg= 0x%x\n", part_num, mfg_num);
417 /* just ignore it if it's a CE */ 419 /* just ignore it if it's a CE */
418 if (part_num == TIO_CE_ASIC_PARTNUM) 420 if (part_num == TIO_CE_ASIC_PARTNUM)
419 return 0; 421 return 0;
422 }
420 } 423 }
421 424
422 cx_dev->cx_id.part_num = part_num; 425 cx_dev->cx_id.part_num = part_num;
@@ -436,10 +439,10 @@ static ssize_t show_cxdev_control(struct device *dev, struct device_attribute *a
436{ 439{
437 struct cx_dev *cx_dev = to_cx_dev(dev); 440 struct cx_dev *cx_dev = to_cx_dev(dev);
438 441
439 return sprintf(buf, "0x%x 0x%x 0x%x %d\n", 442 return sprintf(buf, "0x%x 0x%x 0x%x 0x%x\n",
440 cx_dev->cx_id.nasid, 443 cx_dev->cx_id.nasid,
441 cx_dev->cx_id.part_num, cx_dev->cx_id.mfg_num, 444 cx_dev->cx_id.part_num, cx_dev->cx_id.mfg_num,
442 tiocx_btchar_get(cx_dev->cx_id.nasid)); 445 cx_dev->bt);
443} 446}
444 447
445static ssize_t store_cxdev_control(struct device *dev, struct device_attribute *attr, const char *buf, 448static ssize_t store_cxdev_control(struct device *dev, struct device_attribute *attr, const char *buf,
@@ -488,11 +491,12 @@ static int __init tiocx_init(void)
488 491
489 for (cnodeid = 0; cnodeid < MAX_COMPACT_NODES; cnodeid++) { 492 for (cnodeid = 0; cnodeid < MAX_COMPACT_NODES; cnodeid++) {
490 nasid_t nasid; 493 nasid_t nasid;
494 int bt;
491 495
492 if ((nasid = cnodeid_to_nasid(cnodeid)) < 0) 496 if ((nasid = cnodeid_to_nasid(cnodeid)) < 0)
493 break; /* No more nasids .. bail out of loop */ 497 break; /* No more nasids .. bail out of loop */
494 498
495 if ((nasid & 0x1) && is_fpga_brick(nasid)) { 499 if ((nasid & 0x1) && is_fpga_tio(nasid, &bt)) {
496 struct hubdev_info *hubdev; 500 struct hubdev_info *hubdev;
497 struct xwidget_info *widgetp; 501 struct xwidget_info *widgetp;
498 502
@@ -512,7 +516,7 @@ static int __init tiocx_init(void)
512 516
513 if (cx_device_register 517 if (cx_device_register
514 (nasid, widgetp->xwi_hwid.part_num, 518 (nasid, widgetp->xwi_hwid.part_num,
515 widgetp->xwi_hwid.mfg_num, hubdev) < 0) 519 widgetp->xwi_hwid.mfg_num, hubdev, bt) < 0)
516 return -ENXIO; 520 return -ENXIO;
517 else 521 else
518 found_tiocx_device++; 522 found_tiocx_device++;
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_reg.c b/arch/ia64/sn/pci/pcibr/pcibr_reg.c
index 21426d02fbe6..4f718c3e93d3 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_reg.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_reg.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/types.h> 10#include <linux/types.h>
11#include <asm/sn/io.h>
11#include <asm/sn/pcibr_provider.h> 12#include <asm/sn/pcibr_provider.h>
12#include <asm/sn/pcibus_provider_defs.h> 13#include <asm/sn/pcibus_provider_defs.h>
13#include <asm/sn/pcidev.h> 14#include <asm/sn/pcidev.h>
@@ -29,10 +30,10 @@ void pcireg_control_bit_clr(struct pcibus_info *pcibus_info, uint64_t bits)
29 if (pcibus_info) { 30 if (pcibus_info) {
30 switch (pcibus_info->pbi_bridge_type) { 31 switch (pcibus_info->pbi_bridge_type) {
31 case PCIBR_BRIDGETYPE_TIOCP: 32 case PCIBR_BRIDGETYPE_TIOCP:
32 ptr->tio.cp_control &= ~bits; 33 __sn_clrq_relaxed(&ptr->tio.cp_control, bits);
33 break; 34 break;
34 case PCIBR_BRIDGETYPE_PIC: 35 case PCIBR_BRIDGETYPE_PIC:
35 ptr->pic.p_wid_control &= ~bits; 36 __sn_clrq_relaxed(&ptr->pic.p_wid_control, bits);
36 break; 37 break;
37 default: 38 default:
38 panic 39 panic
@@ -49,10 +50,10 @@ void pcireg_control_bit_set(struct pcibus_info *pcibus_info, uint64_t bits)
49 if (pcibus_info) { 50 if (pcibus_info) {
50 switch (pcibus_info->pbi_bridge_type) { 51 switch (pcibus_info->pbi_bridge_type) {
51 case PCIBR_BRIDGETYPE_TIOCP: 52 case PCIBR_BRIDGETYPE_TIOCP:
52 ptr->tio.cp_control |= bits; 53 __sn_setq_relaxed(&ptr->tio.cp_control, bits);
53 break; 54 break;
54 case PCIBR_BRIDGETYPE_PIC: 55 case PCIBR_BRIDGETYPE_PIC:
55 ptr->pic.p_wid_control |= bits; 56 __sn_setq_relaxed(&ptr->pic.p_wid_control, bits);
56 break; 57 break;
57 default: 58 default:
58 panic 59 panic
@@ -73,10 +74,10 @@ uint64_t pcireg_tflush_get(struct pcibus_info *pcibus_info)
73 if (pcibus_info) { 74 if (pcibus_info) {
74 switch (pcibus_info->pbi_bridge_type) { 75 switch (pcibus_info->pbi_bridge_type) {
75 case PCIBR_BRIDGETYPE_TIOCP: 76 case PCIBR_BRIDGETYPE_TIOCP:
76 ret = ptr->tio.cp_tflush; 77 ret = __sn_readq_relaxed(&ptr->tio.cp_tflush);
77 break; 78 break;
78 case PCIBR_BRIDGETYPE_PIC: 79 case PCIBR_BRIDGETYPE_PIC:
79 ret = ptr->pic.p_wid_tflush; 80 ret = __sn_readq_relaxed(&ptr->pic.p_wid_tflush);
80 break; 81 break;
81 default: 82 default:
82 panic 83 panic
@@ -103,10 +104,10 @@ uint64_t pcireg_intr_status_get(struct pcibus_info * pcibus_info)
103 if (pcibus_info) { 104 if (pcibus_info) {
104 switch (pcibus_info->pbi_bridge_type) { 105 switch (pcibus_info->pbi_bridge_type) {
105 case PCIBR_BRIDGETYPE_TIOCP: 106 case PCIBR_BRIDGETYPE_TIOCP:
106 ret = ptr->tio.cp_int_status; 107 ret = __sn_readq_relaxed(&ptr->tio.cp_int_status);
107 break; 108 break;
108 case PCIBR_BRIDGETYPE_PIC: 109 case PCIBR_BRIDGETYPE_PIC:
109 ret = ptr->pic.p_int_status; 110 ret = __sn_readq_relaxed(&ptr->pic.p_int_status);
110 break; 111 break;
111 default: 112 default:
112 panic 113 panic
@@ -127,10 +128,10 @@ void pcireg_intr_enable_bit_clr(struct pcibus_info *pcibus_info, uint64_t bits)
127 if (pcibus_info) { 128 if (pcibus_info) {
128 switch (pcibus_info->pbi_bridge_type) { 129 switch (pcibus_info->pbi_bridge_type) {
129 case PCIBR_BRIDGETYPE_TIOCP: 130 case PCIBR_BRIDGETYPE_TIOCP:
130 ptr->tio.cp_int_enable &= ~bits; 131 __sn_clrq_relaxed(&ptr->tio.cp_int_enable, bits);
131 break; 132 break;
132 case PCIBR_BRIDGETYPE_PIC: 133 case PCIBR_BRIDGETYPE_PIC:
133 ptr->pic.p_int_enable &= ~bits; 134 __sn_clrq_relaxed(&ptr->pic.p_int_enable, ~bits);
134 break; 135 break;
135 default: 136 default:
136 panic 137 panic
@@ -147,10 +148,10 @@ void pcireg_intr_enable_bit_set(struct pcibus_info *pcibus_info, uint64_t bits)
147 if (pcibus_info) { 148 if (pcibus_info) {
148 switch (pcibus_info->pbi_bridge_type) { 149 switch (pcibus_info->pbi_bridge_type) {
149 case PCIBR_BRIDGETYPE_TIOCP: 150 case PCIBR_BRIDGETYPE_TIOCP:
150 ptr->tio.cp_int_enable |= bits; 151 __sn_setq_relaxed(&ptr->tio.cp_int_enable, bits);
151 break; 152 break;
152 case PCIBR_BRIDGETYPE_PIC: 153 case PCIBR_BRIDGETYPE_PIC:
153 ptr->pic.p_int_enable |= bits; 154 __sn_setq_relaxed(&ptr->pic.p_int_enable, bits);
154 break; 155 break;
155 default: 156 default:
156 panic 157 panic
@@ -171,14 +172,16 @@ void pcireg_intr_addr_addr_set(struct pcibus_info *pcibus_info, int int_n,
171 if (pcibus_info) { 172 if (pcibus_info) {
172 switch (pcibus_info->pbi_bridge_type) { 173 switch (pcibus_info->pbi_bridge_type) {
173 case PCIBR_BRIDGETYPE_TIOCP: 174 case PCIBR_BRIDGETYPE_TIOCP:
174 ptr->tio.cp_int_addr[int_n] &= ~TIOCP_HOST_INTR_ADDR; 175 __sn_clrq_relaxed(&ptr->tio.cp_int_addr[int_n],
175 ptr->tio.cp_int_addr[int_n] |= 176 TIOCP_HOST_INTR_ADDR);
176 (addr & TIOCP_HOST_INTR_ADDR); 177 __sn_setq_relaxed(&ptr->tio.cp_int_addr[int_n],
178 (addr & TIOCP_HOST_INTR_ADDR));
177 break; 179 break;
178 case PCIBR_BRIDGETYPE_PIC: 180 case PCIBR_BRIDGETYPE_PIC:
179 ptr->pic.p_int_addr[int_n] &= ~PIC_HOST_INTR_ADDR; 181 __sn_clrq_relaxed(&ptr->pic.p_int_addr[int_n],
180 ptr->pic.p_int_addr[int_n] |= 182 PIC_HOST_INTR_ADDR);
181 (addr & PIC_HOST_INTR_ADDR); 183 __sn_setq_relaxed(&ptr->pic.p_int_addr[int_n],
184 (addr & PIC_HOST_INTR_ADDR));
182 break; 185 break;
183 default: 186 default:
184 panic 187 panic
@@ -198,10 +201,10 @@ void pcireg_force_intr_set(struct pcibus_info *pcibus_info, int int_n)
198 if (pcibus_info) { 201 if (pcibus_info) {
199 switch (pcibus_info->pbi_bridge_type) { 202 switch (pcibus_info->pbi_bridge_type) {
200 case PCIBR_BRIDGETYPE_TIOCP: 203 case PCIBR_BRIDGETYPE_TIOCP:
201 ptr->tio.cp_force_pin[int_n] = 1; 204 writeq(1, &ptr->tio.cp_force_pin[int_n]);
202 break; 205 break;
203 case PCIBR_BRIDGETYPE_PIC: 206 case PCIBR_BRIDGETYPE_PIC:
204 ptr->pic.p_force_pin[int_n] = 1; 207 writeq(1, &ptr->pic.p_force_pin[int_n]);
205 break; 208 break;
206 default: 209 default:
207 panic 210 panic
@@ -222,10 +225,12 @@ uint64_t pcireg_wrb_flush_get(struct pcibus_info *pcibus_info, int device)
222 if (pcibus_info) { 225 if (pcibus_info) {
223 switch (pcibus_info->pbi_bridge_type) { 226 switch (pcibus_info->pbi_bridge_type) {
224 case PCIBR_BRIDGETYPE_TIOCP: 227 case PCIBR_BRIDGETYPE_TIOCP:
225 ret = ptr->tio.cp_wr_req_buf[device]; 228 ret =
229 __sn_readq_relaxed(&ptr->tio.cp_wr_req_buf[device]);
226 break; 230 break;
227 case PCIBR_BRIDGETYPE_PIC: 231 case PCIBR_BRIDGETYPE_PIC:
228 ret = ptr->pic.p_wr_req_buf[device]; 232 ret =
233 __sn_readq_relaxed(&ptr->pic.p_wr_req_buf[device]);
229 break; 234 break;
230 default: 235 default:
231 panic("pcireg_wrb_flush_get: unknown bridgetype bridge 0x%p", (void *)ptr); 236 panic("pcireg_wrb_flush_get: unknown bridgetype bridge 0x%p", (void *)ptr);
@@ -244,10 +249,10 @@ void pcireg_int_ate_set(struct pcibus_info *pcibus_info, int ate_index,
244 if (pcibus_info) { 249 if (pcibus_info) {
245 switch (pcibus_info->pbi_bridge_type) { 250 switch (pcibus_info->pbi_bridge_type) {
246 case PCIBR_BRIDGETYPE_TIOCP: 251 case PCIBR_BRIDGETYPE_TIOCP:
247 ptr->tio.cp_int_ate_ram[ate_index] = (uint64_t) val; 252 writeq(val, &ptr->tio.cp_int_ate_ram[ate_index]);
248 break; 253 break;
249 case PCIBR_BRIDGETYPE_PIC: 254 case PCIBR_BRIDGETYPE_PIC:
250 ptr->pic.p_int_ate_ram[ate_index] = (uint64_t) val; 255 writeq(val, &ptr->pic.p_int_ate_ram[ate_index]);
251 break; 256 break;
252 default: 257 default:
253 panic 258 panic
@@ -265,12 +270,10 @@ uint64_t *pcireg_int_ate_addr(struct pcibus_info *pcibus_info, int ate_index)
265 if (pcibus_info) { 270 if (pcibus_info) {
266 switch (pcibus_info->pbi_bridge_type) { 271 switch (pcibus_info->pbi_bridge_type) {
267 case PCIBR_BRIDGETYPE_TIOCP: 272 case PCIBR_BRIDGETYPE_TIOCP:
268 ret = 273 ret = &ptr->tio.cp_int_ate_ram[ate_index];
269 (uint64_t *) & (ptr->tio.cp_int_ate_ram[ate_index]);
270 break; 274 break;
271 case PCIBR_BRIDGETYPE_PIC: 275 case PCIBR_BRIDGETYPE_PIC:
272 ret = 276 ret = &ptr->pic.p_int_ate_ram[ate_index];
273 (uint64_t *) & (ptr->pic.p_int_ate_ram[ate_index]);
274 break; 277 break;
275 default: 278 default:
276 panic 279 panic
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index 19bced34d5f1..46b646a6d345 100644
--- a/arch/ia64/sn/pci/tioca_provider.c
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -11,6 +11,7 @@
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <asm/sn/sn_sal.h> 12#include <asm/sn/sn_sal.h>
13#include <asm/sn/addrs.h> 13#include <asm/sn/addrs.h>
14#include <asm/sn/io.h>
14#include <asm/sn/pcidev.h> 15#include <asm/sn/pcidev.h>
15#include <asm/sn/pcibus_provider_defs.h> 16#include <asm/sn/pcibus_provider_defs.h>
16#include <asm/sn/tioca_provider.h> 17#include <asm/sn/tioca_provider.h>
@@ -37,7 +38,7 @@ tioca_gart_init(struct tioca_kernel *tioca_kern)
37 uint64_t offset; 38 uint64_t offset;
38 struct page *tmp; 39 struct page *tmp;
39 struct tioca_common *tioca_common; 40 struct tioca_common *tioca_common;
40 volatile struct tioca *ca_base; 41 struct tioca *ca_base;
41 42
42 tioca_common = tioca_kern->ca_common; 43 tioca_common = tioca_kern->ca_common;
43 ca_base = (struct tioca *)tioca_common->ca_common.bs_base; 44 ca_base = (struct tioca *)tioca_common->ca_common.bs_base;
@@ -174,27 +175,29 @@ tioca_gart_init(struct tioca_kernel *tioca_kern)
174 * DISABLE GART PREFETCHING due to hw bug tracked in SGI PV930029 175 * DISABLE GART PREFETCHING due to hw bug tracked in SGI PV930029
175 */ 176 */
176 177
177 ca_base->ca_control1 |= CA_AGPDMA_OP_ENB_COMBDELAY; /* PV895469 ? */ 178 __sn_setq_relaxed(&ca_base->ca_control1,
178 ca_base->ca_control2 &= ~(CA_GART_MEM_PARAM); 179 CA_AGPDMA_OP_ENB_COMBDELAY); /* PV895469 ? */
179 ca_base->ca_control2 |= (0x2ull << CA_GART_MEM_PARAM_SHFT); 180 __sn_clrq_relaxed(&ca_base->ca_control2, CA_GART_MEM_PARAM);
181 __sn_setq_relaxed(&ca_base->ca_control2,
182 (0x2ull << CA_GART_MEM_PARAM_SHFT));
180 tioca_kern->ca_gart_iscoherent = 1; 183 tioca_kern->ca_gart_iscoherent = 1;
181 ca_base->ca_control2 &= 184 __sn_clrq_relaxed(&ca_base->ca_control2,
182 ~(CA_GART_WR_PREFETCH_ENB | CA_GART_RD_PREFETCH_ENB); 185 (CA_GART_WR_PREFETCH_ENB | CA_GART_RD_PREFETCH_ENB));
183 186
184 /* 187 /*
185 * Unmask GART fetch error interrupts. Clear residual errors first. 188 * Unmask GART fetch error interrupts. Clear residual errors first.
186 */ 189 */
187 190
188 ca_base->ca_int_status_alias = CA_GART_FETCH_ERR; 191 writeq(CA_GART_FETCH_ERR, &ca_base->ca_int_status_alias);
189 ca_base->ca_mult_error_alias = CA_GART_FETCH_ERR; 192 writeq(CA_GART_FETCH_ERR, &ca_base->ca_mult_error_alias);
190 ca_base->ca_int_mask &= ~CA_GART_FETCH_ERR; 193 __sn_clrq_relaxed(&ca_base->ca_int_mask, CA_GART_FETCH_ERR);
191 194
192 /* 195 /*
193 * Program the aperature and gart registers in TIOCA 196 * Program the aperature and gart registers in TIOCA
194 */ 197 */
195 198
196 ca_base->ca_gart_aperature = ap_reg; 199 writeq(ap_reg, &ca_base->ca_gart_aperature);
197 ca_base->ca_gart_ptr_table = tioca_kern->ca_gart_coretalk_addr | 1; 200 writeq(tioca_kern->ca_gart_coretalk_addr|1, &ca_base->ca_gart_ptr_table);
198 201
199 return 0; 202 return 0;
200} 203}
@@ -211,7 +214,6 @@ void
211tioca_fastwrite_enable(struct tioca_kernel *tioca_kern) 214tioca_fastwrite_enable(struct tioca_kernel *tioca_kern)
212{ 215{
213 int cap_ptr; 216 int cap_ptr;
214 uint64_t ca_control1;
215 uint32_t reg; 217 uint32_t reg;
216 struct tioca *tioca_base; 218 struct tioca *tioca_base;
217 struct pci_dev *pdev; 219 struct pci_dev *pdev;
@@ -256,9 +258,7 @@ tioca_fastwrite_enable(struct tioca_kernel *tioca_kern)
256 */ 258 */
257 259
258 tioca_base = (struct tioca *)common->ca_common.bs_base; 260 tioca_base = (struct tioca *)common->ca_common.bs_base;
259 ca_control1 = tioca_base->ca_control1; 261 __sn_setq_relaxed(&tioca_base->ca_control1, CA_AGP_FW_ENABLE);
260 ca_control1 |= CA_AGP_FW_ENABLE;
261 tioca_base->ca_control1 = ca_control1;
262} 262}
263 263
264EXPORT_SYMBOL(tioca_fastwrite_enable); /* used by agp-sgi */ 264EXPORT_SYMBOL(tioca_fastwrite_enable); /* used by agp-sgi */
@@ -345,7 +345,7 @@ tioca_dma_d48(struct pci_dev *pdev, uint64_t paddr)
345 return 0; 345 return 0;
346 } 346 }
347 347
348 agp_dma_extn = ca_base->ca_agp_dma_addr_extn; 348 agp_dma_extn = __sn_readq_relaxed(&ca_base->ca_agp_dma_addr_extn);
349 if (node_upper != (agp_dma_extn >> CA_AGP_DMA_NODE_ID_SHFT)) { 349 if (node_upper != (agp_dma_extn >> CA_AGP_DMA_NODE_ID_SHFT)) {
350 printk(KERN_ERR "%s: coretalk upper node (%u) " 350 printk(KERN_ERR "%s: coretalk upper node (%u) "
351 "mismatch with ca_agp_dma_addr_extn (%lu)\n", 351 "mismatch with ca_agp_dma_addr_extn (%lu)\n",
diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
index 8e75db2b825d..9f03d4e5121c 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -11,6 +11,7 @@
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <asm/sn/sn_sal.h> 12#include <asm/sn/sn_sal.h>
13#include <asm/sn/addrs.h> 13#include <asm/sn/addrs.h>
14#include <asm/sn/io.h>
14#include <asm/sn/pcidev.h> 15#include <asm/sn/pcidev.h>
15#include <asm/sn/pcibus_provider_defs.h> 16#include <asm/sn/pcibus_provider_defs.h>
16#include <asm/sn/tioce_provider.h> 17#include <asm/sn/tioce_provider.h>
@@ -227,7 +228,7 @@ tioce_alloc_map(struct tioce_kernel *ce_kern, int type, int port,
227 228
228 ate = ATE_MAKE(addr, pagesize); 229 ate = ATE_MAKE(addr, pagesize);
229 ate_shadow[i + j] = ate; 230 ate_shadow[i + j] = ate;
230 ate_reg[i + j] = ate; 231 writeq(ate, &ate_reg[i + j]);
231 addr += pagesize; 232 addr += pagesize;
232 } 233 }
233 234
@@ -268,10 +269,10 @@ tioce_dma_d32(struct pci_dev *pdev, uint64_t ct_addr)
268 pcidev_to_tioce(pdev, &ce_mmr, &ce_kern, &port); 269 pcidev_to_tioce(pdev, &ce_mmr, &ce_kern, &port);
269 270
270 if (ce_kern->ce_port[port].dirmap_refcnt == 0) { 271 if (ce_kern->ce_port[port].dirmap_refcnt == 0) {
271 volatile uint64_t tmp; 272 uint64_t tmp;
272 273
273 ce_kern->ce_port[port].dirmap_shadow = ct_upper; 274 ce_kern->ce_port[port].dirmap_shadow = ct_upper;
274 ce_mmr->ce_ure_dir_map[port] = ct_upper; 275 writeq(ct_upper, &ce_mmr->ce_ure_dir_map[port]);
275 tmp = ce_mmr->ce_ure_dir_map[port]; 276 tmp = ce_mmr->ce_ure_dir_map[port];
276 dma_ok = 1; 277 dma_ok = 1;
277 } else 278 } else
@@ -343,7 +344,7 @@ tioce_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr, int dir)
343 if (TIOCE_D32_ADDR(bus_addr)) { 344 if (TIOCE_D32_ADDR(bus_addr)) {
344 if (--ce_kern->ce_port[port].dirmap_refcnt == 0) { 345 if (--ce_kern->ce_port[port].dirmap_refcnt == 0) {
345 ce_kern->ce_port[port].dirmap_shadow = 0; 346 ce_kern->ce_port[port].dirmap_shadow = 0;
346 ce_mmr->ce_ure_dir_map[port] = 0; 347 writeq(0, &ce_mmr->ce_ure_dir_map[port]);
347 } 348 }
348 } else { 349 } else {
349 struct tioce_dmamap *map; 350 struct tioce_dmamap *map;
@@ -582,18 +583,18 @@ tioce_kern_init(struct tioce_common *tioce_common)
582 */ 583 */
583 584
584 tioce_mmr = (struct tioce *)tioce_common->ce_pcibus.bs_base; 585 tioce_mmr = (struct tioce *)tioce_common->ce_pcibus.bs_base;
585 tioce_mmr->ce_ure_page_map &= ~CE_URE_PAGESIZE_MASK; 586 __sn_clrq_relaxed(&tioce_mmr->ce_ure_page_map, CE_URE_PAGESIZE_MASK);
586 tioce_mmr->ce_ure_page_map |= CE_URE_256K_PAGESIZE; 587 __sn_setq_relaxed(&tioce_mmr->ce_ure_page_map, CE_URE_256K_PAGESIZE);
587 tioce_kern->ce_ate3240_pagesize = KB(256); 588 tioce_kern->ce_ate3240_pagesize = KB(256);
588 589
589 for (i = 0; i < TIOCE_NUM_M40_ATES; i++) { 590 for (i = 0; i < TIOCE_NUM_M40_ATES; i++) {
590 tioce_kern->ce_ate40_shadow[i] = 0; 591 tioce_kern->ce_ate40_shadow[i] = 0;
591 tioce_mmr->ce_ure_ate40[i] = 0; 592 writeq(0, &tioce_mmr->ce_ure_ate40[i]);
592 } 593 }
593 594
594 for (i = 0; i < TIOCE_NUM_M3240_ATES; i++) { 595 for (i = 0; i < TIOCE_NUM_M3240_ATES; i++) {
595 tioce_kern->ce_ate3240_shadow[i] = 0; 596 tioce_kern->ce_ate3240_shadow[i] = 0;
596 tioce_mmr->ce_ure_ate3240[i] = 0; 597 writeq(0, &tioce_mmr->ce_ure_ate3240[i]);
597 } 598 }
598 599
599 return tioce_kern; 600 return tioce_kern;
@@ -665,7 +666,7 @@ tioce_force_interrupt(struct sn_irq_info *sn_irq_info)
665 default: 666 default:
666 return; 667 return;
667 } 668 }
668 ce_mmr->ce_adm_force_int = force_int_val; 669 writeq(force_int_val, &ce_mmr->ce_adm_force_int);
669} 670}
670 671
671/** 672/**
@@ -686,6 +687,7 @@ tioce_target_interrupt(struct sn_irq_info *sn_irq_info)
686 struct tioce_common *ce_common; 687 struct tioce_common *ce_common;
687 struct tioce *ce_mmr; 688 struct tioce *ce_mmr;
688 int bit; 689 int bit;
690 uint64_t vector;
689 691
690 pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo; 692 pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
691 if (!pcidev_info) 693 if (!pcidev_info)
@@ -696,11 +698,11 @@ tioce_target_interrupt(struct sn_irq_info *sn_irq_info)
696 698
697 bit = sn_irq_info->irq_int_bit; 699 bit = sn_irq_info->irq_int_bit;
698 700
699 ce_mmr->ce_adm_int_mask |= (1UL << bit); 701 __sn_setq_relaxed(&ce_mmr->ce_adm_int_mask, (1UL << bit));
700 ce_mmr->ce_adm_int_dest[bit] = 702 vector = (uint64_t)sn_irq_info->irq_irq << INTR_VECTOR_SHFT;
701 ((uint64_t)sn_irq_info->irq_irq << INTR_VECTOR_SHFT) | 703 vector |= sn_irq_info->irq_xtalkaddr;
702 sn_irq_info->irq_xtalkaddr; 704 writeq(vector, &ce_mmr->ce_adm_int_dest[bit]);
703 ce_mmr->ce_adm_int_mask &= ~(1UL << bit); 705 __sn_clrq_relaxed(&ce_mmr->ce_adm_int_mask, (1UL << bit));
704 706
705 tioce_force_interrupt(sn_irq_info); 707 tioce_force_interrupt(sn_irq_info);
706} 708}
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index dd4418d846e9..983d438b14b6 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -24,7 +24,7 @@ aflags-$(CONFIG_ISA_M32R) += -DNO_FPU -Wa,-no-bitinst
24CFLAGS += $(cflags-y) 24CFLAGS += $(cflags-y)
25AFLAGS += $(aflags-y) 25AFLAGS += $(aflags-y)
26 26
27CHECKFLAGS := $(CHECK) -D__m32r__ 27CHECKFLAGS += -D__m32r__ -D__BIG_ENDIAN__=1
28 28
29head-y := arch/m32r/kernel/head.o arch/m32r/kernel/init_task.o 29head-y := arch/m32r/kernel/head.o arch/m32r/kernel/init_task.o
30 30
diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S
index dddbf6b5ed2c..85920fb8d08c 100644
--- a/arch/m32r/kernel/entry.S
+++ b/arch/m32r/kernel/entry.S
@@ -681,6 +681,15 @@ ENTRY(debug_trap)
681 bl do_debug_trap 681 bl do_debug_trap
682 bra error_code 682 bra error_code
683 683
684ENTRY(ill_trap)
685 /* void ill_trap(void) */
686 SWITCH_TO_KERNEL_STACK
687 SAVE_ALL
688 ldi r1, #0 ; error_code ; FIXME
689 mv r0, sp ; pt_regs
690 bl do_ill_trap
691 bra error_code
692
684 693
685/* Cache flushing handler */ 694/* Cache flushing handler */
686ENTRY(cache_flushing_handler) 695ENTRY(cache_flushing_handler)
diff --git a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c
index a4576ac7e870..8b1f6eb76870 100644
--- a/arch/m32r/kernel/smp.c
+++ b/arch/m32r/kernel/smp.c
@@ -275,12 +275,14 @@ static void flush_tlb_all_ipi(void *info)
275 *==========================================================================*/ 275 *==========================================================================*/
276void smp_flush_tlb_mm(struct mm_struct *mm) 276void smp_flush_tlb_mm(struct mm_struct *mm)
277{ 277{
278 int cpu_id = smp_processor_id(); 278 int cpu_id;
279 cpumask_t cpu_mask; 279 cpumask_t cpu_mask;
280 unsigned long *mmc = &mm->context[cpu_id]; 280 unsigned long *mmc;
281 unsigned long flags; 281 unsigned long flags;
282 282
283 preempt_disable(); 283 preempt_disable();
284 cpu_id = smp_processor_id();
285 mmc = &mm->context[cpu_id];
284 cpu_mask = mm->cpu_vm_mask; 286 cpu_mask = mm->cpu_vm_mask;
285 cpu_clear(cpu_id, cpu_mask); 287 cpu_clear(cpu_id, cpu_mask);
286 288
@@ -343,12 +345,14 @@ void smp_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
343void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long va) 345void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long va)
344{ 346{
345 struct mm_struct *mm = vma->vm_mm; 347 struct mm_struct *mm = vma->vm_mm;
346 int cpu_id = smp_processor_id(); 348 int cpu_id;
347 cpumask_t cpu_mask; 349 cpumask_t cpu_mask;
348 unsigned long *mmc = &mm->context[cpu_id]; 350 unsigned long *mmc;
349 unsigned long flags; 351 unsigned long flags;
350 352
351 preempt_disable(); 353 preempt_disable();
354 cpu_id = smp_processor_id();
355 mmc = &mm->context[cpu_id];
352 cpu_mask = mm->cpu_vm_mask; 356 cpu_mask = mm->cpu_vm_mask;
353 cpu_clear(cpu_id, cpu_mask); 357 cpu_clear(cpu_id, cpu_mask);
354 358
diff --git a/arch/m32r/kernel/traps.c b/arch/m32r/kernel/traps.c
index 01922271d17e..5fe8ed6d62dc 100644
--- a/arch/m32r/kernel/traps.c
+++ b/arch/m32r/kernel/traps.c
@@ -5,8 +5,6 @@
5 * Hitoshi Yamamoto 5 * Hitoshi Yamamoto
6 */ 6 */
7 7
8/* $Id$ */
9
10/* 8/*
11 * 'traps.c' handles hardware traps and faults after we have saved some 9 * 'traps.c' handles hardware traps and faults after we have saved some
12 * state in 'entry.S'. 10 * state in 'entry.S'.
@@ -35,6 +33,7 @@ asmlinkage void ei_handler(void);
35asmlinkage void rie_handler(void); 33asmlinkage void rie_handler(void);
36asmlinkage void debug_trap(void); 34asmlinkage void debug_trap(void);
37asmlinkage void cache_flushing_handler(void); 35asmlinkage void cache_flushing_handler(void);
36asmlinkage void ill_trap(void);
38 37
39#ifdef CONFIG_SMP 38#ifdef CONFIG_SMP
40extern void smp_reschedule_interrupt(void); 39extern void smp_reschedule_interrupt(void);
@@ -77,22 +76,22 @@ void set_eit_vector_entries(void)
77 eit_vector[5] = BRA_INSN(default_eit_handler, 5); 76 eit_vector[5] = BRA_INSN(default_eit_handler, 5);
78 eit_vector[8] = BRA_INSN(rie_handler, 8); 77 eit_vector[8] = BRA_INSN(rie_handler, 8);
79 eit_vector[12] = BRA_INSN(alignment_check, 12); 78 eit_vector[12] = BRA_INSN(alignment_check, 12);
80 eit_vector[16] = 0xff000000UL; 79 eit_vector[16] = BRA_INSN(ill_trap, 16);
81 eit_vector[17] = BRA_INSN(debug_trap, 17); 80 eit_vector[17] = BRA_INSN(debug_trap, 17);
82 eit_vector[18] = BRA_INSN(system_call, 18); 81 eit_vector[18] = BRA_INSN(system_call, 18);
83 eit_vector[19] = 0xff000000UL; 82 eit_vector[19] = BRA_INSN(ill_trap, 19);
84 eit_vector[20] = 0xff000000UL; 83 eit_vector[20] = BRA_INSN(ill_trap, 20);
85 eit_vector[21] = 0xff000000UL; 84 eit_vector[21] = BRA_INSN(ill_trap, 21);
86 eit_vector[22] = 0xff000000UL; 85 eit_vector[22] = BRA_INSN(ill_trap, 22);
87 eit_vector[23] = 0xff000000UL; 86 eit_vector[23] = BRA_INSN(ill_trap, 23);
88 eit_vector[24] = 0xff000000UL; 87 eit_vector[24] = BRA_INSN(ill_trap, 24);
89 eit_vector[25] = 0xff000000UL; 88 eit_vector[25] = BRA_INSN(ill_trap, 25);
90 eit_vector[26] = 0xff000000UL; 89 eit_vector[26] = BRA_INSN(ill_trap, 26);
91 eit_vector[27] = 0xff000000UL; 90 eit_vector[27] = BRA_INSN(ill_trap, 27);
92 eit_vector[28] = BRA_INSN(cache_flushing_handler, 28); 91 eit_vector[28] = BRA_INSN(cache_flushing_handler, 28);
93 eit_vector[29] = 0xff000000UL; 92 eit_vector[29] = BRA_INSN(ill_trap, 29);
94 eit_vector[30] = 0xff000000UL; 93 eit_vector[30] = BRA_INSN(ill_trap, 30);
95 eit_vector[31] = 0xff000000UL; 94 eit_vector[31] = BRA_INSN(ill_trap, 31);
96 eit_vector[32] = BRA_INSN(ei_handler, 32); 95 eit_vector[32] = BRA_INSN(ei_handler, 32);
97 eit_vector[64] = BRA_INSN(pie_handler, 64); 96 eit_vector[64] = BRA_INSN(pie_handler, 64);
98#ifdef CONFIG_MMU 97#ifdef CONFIG_MMU
@@ -286,7 +285,8 @@ asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
286 285
287DO_ERROR( 1, SIGTRAP, "debug trap", debug_trap) 286DO_ERROR( 1, SIGTRAP, "debug trap", debug_trap)
288DO_ERROR_INFO(0x20, SIGILL, "reserved instruction ", rie_handler, ILL_ILLOPC, regs->bpc) 287DO_ERROR_INFO(0x20, SIGILL, "reserved instruction ", rie_handler, ILL_ILLOPC, regs->bpc)
289DO_ERROR_INFO(0x100, SIGILL, "privilege instruction", pie_handler, ILL_PRVOPC, regs->bpc) 288DO_ERROR_INFO(0x100, SIGILL, "privileged instruction", pie_handler, ILL_PRVOPC, regs->bpc)
289DO_ERROR_INFO(-1, SIGILL, "illegal trap", ill_trap, ILL_ILLTRP, regs->bpc)
290 290
291extern int handle_unaligned_access(unsigned long, struct pt_regs *); 291extern int handle_unaligned_access(unsigned long, struct pt_regs *);
292 292
@@ -329,4 +329,3 @@ asmlinkage void do_alignment_check(struct pt_regs *regs, long error_code)
329 set_fs(oldfs); 329 set_fs(oldfs);
330 } 330 }
331} 331}
332
diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
index 6c6855f1aa05..ce16bbe26a52 100644
--- a/arch/m32r/lib/usercopy.c
+++ b/arch/m32r/lib/usercopy.c
@@ -13,7 +13,7 @@
13#include <asm/uaccess.h> 13#include <asm/uaccess.h>
14 14
15unsigned long 15unsigned long
16__generic_copy_to_user(void *to, const void *from, unsigned long n) 16__generic_copy_to_user(void __user *to, const void *from, unsigned long n)
17{ 17{
18 prefetch(from); 18 prefetch(from);
19 if (access_ok(VERIFY_WRITE, to, n)) 19 if (access_ok(VERIFY_WRITE, to, n))
@@ -22,7 +22,7 @@ __generic_copy_to_user(void *to, const void *from, unsigned long n)
22} 22}
23 23
24unsigned long 24unsigned long
25__generic_copy_from_user(void *to, const void *from, unsigned long n) 25__generic_copy_from_user(void *to, const void __user *from, unsigned long n)
26{ 26{
27 prefetchw(to); 27 prefetchw(to);
28 if (access_ok(VERIFY_READ, from, n)) 28 if (access_ok(VERIFY_READ, from, n))
@@ -111,7 +111,7 @@ do { \
111#endif /* CONFIG_ISA_DUAL_ISSUE */ 111#endif /* CONFIG_ISA_DUAL_ISSUE */
112 112
113long 113long
114__strncpy_from_user(char *dst, const char *src, long count) 114__strncpy_from_user(char *dst, const char __user *src, long count)
115{ 115{
116 long res; 116 long res;
117 __do_strncpy_from_user(dst, src, count, res); 117 __do_strncpy_from_user(dst, src, count, res);
@@ -119,7 +119,7 @@ __strncpy_from_user(char *dst, const char *src, long count)
119} 119}
120 120
121long 121long
122strncpy_from_user(char *dst, const char *src, long count) 122strncpy_from_user(char *dst, const char __user *src, long count)
123{ 123{
124 long res = -EFAULT; 124 long res = -EFAULT;
125 if (access_ok(VERIFY_READ, src, 1)) 125 if (access_ok(VERIFY_READ, src, 1))
@@ -222,7 +222,7 @@ do { \
222#endif /* not CONFIG_ISA_DUAL_ISSUE */ 222#endif /* not CONFIG_ISA_DUAL_ISSUE */
223 223
224unsigned long 224unsigned long
225clear_user(void *to, unsigned long n) 225clear_user(void __user *to, unsigned long n)
226{ 226{
227 if (access_ok(VERIFY_WRITE, to, n)) 227 if (access_ok(VERIFY_WRITE, to, n))
228 __do_clear_user(to, n); 228 __do_clear_user(to, n);
@@ -230,7 +230,7 @@ clear_user(void *to, unsigned long n)
230} 230}
231 231
232unsigned long 232unsigned long
233__clear_user(void *to, unsigned long n) 233__clear_user(void __user *to, unsigned long n)
234{ 234{
235 __do_clear_user(to, n); 235 __do_clear_user(to, n);
236 return n; 236 return n;
@@ -244,7 +244,7 @@ __clear_user(void *to, unsigned long n)
244 244
245#ifdef CONFIG_ISA_DUAL_ISSUE 245#ifdef CONFIG_ISA_DUAL_ISSUE
246 246
247long strnlen_user(const char *s, long n) 247long strnlen_user(const char __user *s, long n)
248{ 248{
249 unsigned long mask = -__addr_ok(s); 249 unsigned long mask = -__addr_ok(s);
250 unsigned long res; 250 unsigned long res;
@@ -313,7 +313,7 @@ long strnlen_user(const char *s, long n)
313 313
314#else /* not CONFIG_ISA_DUAL_ISSUE */ 314#else /* not CONFIG_ISA_DUAL_ISSUE */
315 315
316long strnlen_user(const char *s, long n) 316long strnlen_user(const char __user *s, long n)
317{ 317{
318 unsigned long mask = -__addr_ok(s); 318 unsigned long mask = -__addr_ok(s);
319 unsigned long res; 319 unsigned long res;
diff --git a/arch/mips/pci/fixup-tb0226.c b/arch/mips/pci/fixup-tb0226.c
index 61513d5d97da..b5d42b12de10 100644
--- a/arch/mips/pci/fixup-tb0226.c
+++ b/arch/mips/pci/fixup-tb0226.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-tb0226.c, The TANBAC TB0226 specific PCI fixups. 2 * fixup-tb0226.c, The TANBAC TB0226 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 4 * Copyright (C) 2002-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22 22
23#include <asm/vr41xx/giu.h>
23#include <asm/vr41xx/tb0226.h> 24#include <asm/vr41xx/tb0226.h>
24 25
25int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin) 26int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
@@ -29,42 +30,42 @@ int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
29 switch (slot) { 30 switch (slot) {
30 case 12: 31 case 12:
31 vr41xx_set_irq_trigger(GD82559_1_PIN, 32 vr41xx_set_irq_trigger(GD82559_1_PIN,
32 TRIGGER_LEVEL, 33 IRQ_TRIGGER_LEVEL,
33 SIGNAL_THROUGH); 34 IRQ_SIGNAL_THROUGH);
34 vr41xx_set_irq_level(GD82559_1_PIN, LEVEL_LOW); 35 vr41xx_set_irq_level(GD82559_1_PIN, IRQ_LEVEL_LOW);
35 irq = GD82559_1_IRQ; 36 irq = GD82559_1_IRQ;
36 break; 37 break;
37 case 13: 38 case 13:
38 vr41xx_set_irq_trigger(GD82559_2_PIN, 39 vr41xx_set_irq_trigger(GD82559_2_PIN,
39 TRIGGER_LEVEL, 40 IRQ_TRIGGER_LEVEL,
40 SIGNAL_THROUGH); 41 IRQ_SIGNAL_THROUGH);
41 vr41xx_set_irq_level(GD82559_2_PIN, LEVEL_LOW); 42 vr41xx_set_irq_level(GD82559_2_PIN, IRQ_LEVEL_LOW);
42 irq = GD82559_2_IRQ; 43 irq = GD82559_2_IRQ;
43 break; 44 break;
44 case 14: 45 case 14:
45 switch (pin) { 46 switch (pin) {
46 case 1: 47 case 1:
47 vr41xx_set_irq_trigger(UPD720100_INTA_PIN, 48 vr41xx_set_irq_trigger(UPD720100_INTA_PIN,
48 TRIGGER_LEVEL, 49 IRQ_TRIGGER_LEVEL,
49 SIGNAL_THROUGH); 50 IRQ_SIGNAL_THROUGH);
50 vr41xx_set_irq_level(UPD720100_INTA_PIN, 51 vr41xx_set_irq_level(UPD720100_INTA_PIN,
51 LEVEL_LOW); 52 IRQ_LEVEL_LOW);
52 irq = UPD720100_INTA_IRQ; 53 irq = UPD720100_INTA_IRQ;
53 break; 54 break;
54 case 2: 55 case 2:
55 vr41xx_set_irq_trigger(UPD720100_INTB_PIN, 56 vr41xx_set_irq_trigger(UPD720100_INTB_PIN,
56 TRIGGER_LEVEL, 57 IRQ_TRIGGER_LEVEL,
57 SIGNAL_THROUGH); 58 IRQ_SIGNAL_THROUGH);
58 vr41xx_set_irq_level(UPD720100_INTB_PIN, 59 vr41xx_set_irq_level(UPD720100_INTB_PIN,
59 LEVEL_LOW); 60 IRQ_LEVEL_LOW);
60 irq = UPD720100_INTB_IRQ; 61 irq = UPD720100_INTB_IRQ;
61 break; 62 break;
62 case 3: 63 case 3:
63 vr41xx_set_irq_trigger(UPD720100_INTC_PIN, 64 vr41xx_set_irq_trigger(UPD720100_INTC_PIN,
64 TRIGGER_LEVEL, 65 IRQ_TRIGGER_LEVEL,
65 SIGNAL_THROUGH); 66 IRQ_SIGNAL_THROUGH);
66 vr41xx_set_irq_level(UPD720100_INTC_PIN, 67 vr41xx_set_irq_level(UPD720100_INTC_PIN,
67 LEVEL_LOW); 68 IRQ_LEVEL_LOW);
68 irq = UPD720100_INTC_IRQ; 69 irq = UPD720100_INTC_IRQ;
69 break; 70 break;
70 default: 71 default:
diff --git a/arch/ppc/boot/ld.script b/arch/ppc/boot/ld.script
index 9362193742ac..d4dd8f15395e 100644
--- a/arch/ppc/boot/ld.script
+++ b/arch/ppc/boot/ld.script
@@ -1,4 +1,4 @@
1OUTPUT_ARCH(powerpc) 1OUTPUT_ARCH(powerpc:common)
2SECTIONS 2SECTIONS
3{ 3{
4 /* Read-only sections, merged into text segment: */ 4 /* Read-only sections, merged into text segment: */
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
index 1fb92f16acd6..b1457a8a9c0f 100644
--- a/arch/ppc/kernel/Makefile
+++ b/arch/ppc/kernel/Makefile
@@ -15,9 +15,8 @@ extra-y += vmlinux.lds
15obj-y := entry.o traps.o irq.o idle.o time.o misc.o \ 15obj-y := entry.o traps.o irq.o idle.o time.o misc.o \
16 process.o signal.o ptrace.o align.o \ 16 process.o signal.o ptrace.o align.o \
17 semaphore.o syscalls.o setup.o \ 17 semaphore.o syscalls.o setup.o \
18 cputable.o ppc_htab.o 18 cputable.o ppc_htab.o perfmon.o
19obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o 19obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o
20obj-$(CONFIG_E500) += perfmon.o
21obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o 20obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o
22obj-$(CONFIG_POWER4) += cpu_setup_power4.o 21obj-$(CONFIG_POWER4) += cpu_setup_power4.o
23obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o 22obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o
diff --git a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
index 546e1ea4cafa..6b76cf58d9e0 100644
--- a/arch/ppc/kernel/cputable.c
+++ b/arch/ppc/kernel/cputable.c
@@ -91,7 +91,7 @@ struct cpu_spec cpu_specs[] = {
91 .cpu_features = CPU_FTR_COMMON | CPU_FTR_601 | 91 .cpu_features = CPU_FTR_COMMON | CPU_FTR_601 |
92 CPU_FTR_HPTE_TABLE, 92 CPU_FTR_HPTE_TABLE,
93 .cpu_user_features = COMMON_PPC | PPC_FEATURE_601_INSTR | 93 .cpu_user_features = COMMON_PPC | PPC_FEATURE_601_INSTR |
94 PPC_FEATURE_UNIFIED_CACHE, 94 PPC_FEATURE_UNIFIED_CACHE | PPC_FEATURE_NO_TB,
95 .icache_bsize = 32, 95 .icache_bsize = 32,
96 .dcache_bsize = 32, 96 .dcache_bsize = 32,
97 .cpu_setup = __setup_cpu_601 97 .cpu_setup = __setup_cpu_601
@@ -745,7 +745,8 @@ struct cpu_spec cpu_specs[] = {
745 .cpu_name = "403GCX", 745 .cpu_name = "403GCX",
746 .cpu_features = CPU_FTR_SPLIT_ID_CACHE | 746 .cpu_features = CPU_FTR_SPLIT_ID_CACHE |
747 CPU_FTR_USE_TB, 747 CPU_FTR_USE_TB,
748 .cpu_user_features = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU, 748 .cpu_user_features = PPC_FEATURE_32 |
749 PPC_FEATURE_HAS_MMU | PPC_FEATURE_NO_TB,
749 .icache_bsize = 16, 750 .icache_bsize = 16,
750 .dcache_bsize = 16, 751 .dcache_bsize = 16,
751 }, 752 },
diff --git a/arch/ppc/kernel/dma-mapping.c b/arch/ppc/kernel/dma-mapping.c
index b566d982806c..8edee806dae7 100644
--- a/arch/ppc/kernel/dma-mapping.c
+++ b/arch/ppc/kernel/dma-mapping.c
@@ -401,10 +401,10 @@ EXPORT_SYMBOL(__dma_sync);
401static inline void __dma_sync_page_highmem(struct page *page, 401static inline void __dma_sync_page_highmem(struct page *page,
402 unsigned long offset, size_t size, int direction) 402 unsigned long offset, size_t size, int direction)
403{ 403{
404 size_t seg_size = min((size_t)PAGE_SIZE, size) - offset; 404 size_t seg_size = min((size_t)(PAGE_SIZE - offset), size);
405 size_t cur_size = seg_size; 405 size_t cur_size = seg_size;
406 unsigned long flags, start, seg_offset = offset; 406 unsigned long flags, start, seg_offset = offset;
407 int nr_segs = PAGE_ALIGN(size + (PAGE_SIZE - offset))/PAGE_SIZE; 407 int nr_segs = 1 + ((size - seg_size) + PAGE_SIZE - 1)/PAGE_SIZE;
408 int seg_nr = 0; 408 int seg_nr = 0;
409 409
410 local_irq_save(flags); 410 local_irq_save(flags);
diff --git a/arch/ppc/kernel/perfmon.c b/arch/ppc/kernel/perfmon.c
index fa1dad96b830..22df9a596a0f 100644
--- a/arch/ppc/kernel/perfmon.c
+++ b/arch/ppc/kernel/perfmon.c
@@ -45,9 +45,8 @@ static void dummy_perf(struct pt_regs *regs)
45 mtpmr(PMRN_PMGC0, pmgc0); 45 mtpmr(PMRN_PMGC0, pmgc0);
46} 46}
47 47
48#else 48#elif defined(CONFIG_6xx)
49/* Ensure exceptions are disabled */ 49/* Ensure exceptions are disabled */
50
51static void dummy_perf(struct pt_regs *regs) 50static void dummy_perf(struct pt_regs *regs)
52{ 51{
53 unsigned int mmcr0 = mfspr(SPRN_MMCR0); 52 unsigned int mmcr0 = mfspr(SPRN_MMCR0);
@@ -55,6 +54,10 @@ static void dummy_perf(struct pt_regs *regs)
55 mmcr0 &= ~MMCR0_PMXE; 54 mmcr0 &= ~MMCR0_PMXE;
56 mtspr(SPRN_MMCR0, mmcr0); 55 mtspr(SPRN_MMCR0, mmcr0);
57} 56}
57#else
58static void dummy_perf(struct pt_regs *regs)
59{
60}
58#endif 61#endif
59 62
60void (*perf_irq)(struct pt_regs *) = dummy_perf; 63void (*perf_irq)(struct pt_regs *) = dummy_perf;
diff --git a/arch/ppc/platforms/4xx/bamboo.c b/arch/ppc/platforms/4xx/bamboo.c
index ac391d463d78..78a403b48dba 100644
--- a/arch/ppc/platforms/4xx/bamboo.c
+++ b/arch/ppc/platforms/4xx/bamboo.c
@@ -27,7 +27,6 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/ide.h> 28#include <linux/ide.h>
29#include <linux/initrd.h> 29#include <linux/initrd.h>
30#include <linux/irq.h>
31#include <linux/seq_file.h> 30#include <linux/seq_file.h>
32#include <linux/root_dev.h> 31#include <linux/root_dev.h>
33#include <linux/tty.h> 32#include <linux/tty.h>
diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
index d6b2b1965dcb..27b778ab903b 100644
--- a/arch/ppc/platforms/4xx/ebony.c
+++ b/arch/ppc/platforms/4xx/ebony.c
@@ -30,7 +30,6 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/ide.h> 31#include <linux/ide.h>
32#include <linux/initrd.h> 32#include <linux/initrd.h>
33#include <linux/irq.h>
34#include <linux/seq_file.h> 33#include <linux/seq_file.h>
35#include <linux/root_dev.h> 34#include <linux/root_dev.h>
36#include <linux/tty.h> 35#include <linux/tty.h>
diff --git a/arch/ppc/platforms/4xx/luan.c b/arch/ppc/platforms/4xx/luan.c
index a38e6f9ef858..16d953bda22c 100644
--- a/arch/ppc/platforms/4xx/luan.c
+++ b/arch/ppc/platforms/4xx/luan.c
@@ -28,7 +28,6 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/ide.h> 29#include <linux/ide.h>
30#include <linux/initrd.h> 30#include <linux/initrd.h>
31#include <linux/irq.h>
32#include <linux/seq_file.h> 31#include <linux/seq_file.h>
33#include <linux/root_dev.h> 32#include <linux/root_dev.h>
34#include <linux/tty.h> 33#include <linux/tty.h>
diff --git a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
index 80028df1b445..506949c5dd29 100644
--- a/arch/ppc/platforms/4xx/ocotea.c
+++ b/arch/ppc/platforms/4xx/ocotea.c
@@ -28,7 +28,6 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/ide.h> 29#include <linux/ide.h>
30#include <linux/initrd.h> 30#include <linux/initrd.h>
31#include <linux/irq.h>
32#include <linux/seq_file.h> 31#include <linux/seq_file.h>
33#include <linux/root_dev.h> 32#include <linux/root_dev.h>
34#include <linux/tty.h> 33#include <linux/tty.h>
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.c b/arch/ppc/platforms/83xx/mpc834x_sys.c
index b38a851a64ec..79b3f533d0a3 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.c
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/root_dev.h> 28#include <linux/root_dev.h>
30#include <linux/serial.h> 29#include <linux/serial.h>
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c
index f761fdf160db..7dc8a68acfd0 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/root_dev.h> 28#include <linux/root_dev.h>
30#include <linux/serial.h> 29#include <linux/serial.h>
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
index f2748c88665a..8841fd7da6ee 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/root_dev.h> 28#include <linux/root_dev.h>
30#include <linux/serial.h> 29#include <linux/serial.h>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
index 18e952d1767c..bd3ac0136756 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/serial.h> 28#include <linux/serial.h>
30#include <linux/module.h> 29#include <linux/module.h>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
index 6267b294f704..9f9039498ae5 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/serial.h> 28#include <linux/serial.h>
30#include <linux/module.h> 29#include <linux/module.h>
diff --git a/arch/ppc/platforms/85xx/sbc8560.c b/arch/ppc/platforms/85xx/sbc8560.c
index 165df94d4aa6..c76760a781c1 100644
--- a/arch/ppc/platforms/85xx/sbc8560.c
+++ b/arch/ppc/platforms/85xx/sbc8560.c
@@ -24,7 +24,6 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/root_dev.h> 28#include <linux/root_dev.h>
30#include <linux/serial.h> 29#include <linux/serial.h>
diff --git a/arch/ppc/platforms/85xx/sbc85xx.c b/arch/ppc/platforms/85xx/sbc85xx.c
index 4f6d1ddd6fb8..c02f110219f5 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.c
+++ b/arch/ppc/platforms/85xx/sbc85xx.c
@@ -23,7 +23,6 @@
23#include <linux/major.h> 23#include <linux/major.h>
24#include <linux/console.h> 24#include <linux/console.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/irq.h>
27#include <linux/seq_file.h> 26#include <linux/seq_file.h>
28#include <linux/serial.h> 27#include <linux/serial.h>
29#include <linux/module.h> 28#include <linux/module.h>
diff --git a/arch/ppc/platforms/85xx/stx_gp3.c b/arch/ppc/platforms/85xx/stx_gp3.c
index c99b365d6110..20940f4044f4 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.c
+++ b/arch/ppc/platforms/85xx/stx_gp3.c
@@ -30,7 +30,6 @@
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/console.h> 31#include <linux/console.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/irq.h>
34#include <linux/root_dev.h> 33#include <linux/root_dev.h>
35#include <linux/seq_file.h> 34#include <linux/seq_file.h>
36#include <linux/serial.h> 35#include <linux/serial.h>
diff --git a/arch/ppc/platforms/chestnut.c b/arch/ppc/platforms/chestnut.c
index 7786818bd9d0..df6ff98c023a 100644
--- a/arch/ppc/platforms/chestnut.c
+++ b/arch/ppc/platforms/chestnut.c
@@ -35,7 +35,6 @@
35#include <asm/time.h> 35#include <asm/time.h>
36#include <asm/dma.h> 36#include <asm/dma.h>
37#include <asm/io.h> 37#include <asm/io.h>
38#include <linux/irq.h>
39#include <asm/hw_irq.h> 38#include <asm/hw_irq.h>
40#include <asm/machdep.h> 39#include <asm/machdep.h>
41#include <asm/kgdb.h> 40#include <asm/kgdb.h>
diff --git a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
index 57f29ab29bda..66346f0de7ec 100644
--- a/arch/ppc/platforms/chrp_setup.c
+++ b/arch/ppc/platforms/chrp_setup.c
@@ -32,7 +32,6 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/ide.h> 34#include <linux/ide.h>
35#include <linux/irq.h>
36#include <linux/console.h> 35#include <linux/console.h>
37#include <linux/seq_file.h> 36#include <linux/seq_file.h>
38#include <linux/root_dev.h> 37#include <linux/root_dev.h>
diff --git a/arch/ppc/platforms/gemini_setup.c b/arch/ppc/platforms/gemini_setup.c
index e391e52383c7..3a5ff9fb71d6 100644
--- a/arch/ppc/platforms/gemini_setup.c
+++ b/arch/ppc/platforms/gemini_setup.c
@@ -21,7 +21,6 @@
21#include <linux/major.h> 21#include <linux/major.h>
22#include <linux/initrd.h> 22#include <linux/initrd.h>
23#include <linux/console.h> 23#include <linux/console.h>
24#include <linux/irq.h>
25#include <linux/seq_file.h> 24#include <linux/seq_file.h>
26#include <linux/root_dev.h> 25#include <linux/root_dev.h>
27#include <linux/bcd.h> 26#include <linux/bcd.h>
diff --git a/arch/ppc/platforms/mvme5100.c b/arch/ppc/platforms/mvme5100.c
index b292b44b760c..ce2ce88c8033 100644
--- a/arch/ppc/platforms/mvme5100.c
+++ b/arch/ppc/platforms/mvme5100.c
@@ -20,7 +20,6 @@
20#include <linux/initrd.h> 20#include <linux/initrd.h>
21#include <linux/console.h> 21#include <linux/console.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/irq.h>
24#include <linux/ide.h> 23#include <linux/ide.h>
25#include <linux/seq_file.h> 24#include <linux/seq_file.h>
26#include <linux/kdev_t.h> 25#include <linux/kdev_t.h>
diff --git a/arch/ppc/platforms/pmac_cpufreq.c b/arch/ppc/platforms/pmac_cpufreq.c
index c0605244edda..d4bc5f67ec53 100644
--- a/arch/ppc/platforms/pmac_cpufreq.c
+++ b/arch/ppc/platforms/pmac_cpufreq.c
@@ -695,6 +695,13 @@ static int __init pmac_cpufreq_setup(void)
695 set_speed_proc = pmu_set_cpu_speed; 695 set_speed_proc = pmu_set_cpu_speed;
696 is_pmu_based = 1; 696 is_pmu_based = 1;
697 } 697 }
698 /* Else check for TiPb 550 */
699 else if (machine_is_compatible("PowerBook3,3") && cur_freq == 550000) {
700 hi_freq = cur_freq;
701 low_freq = 500000;
702 set_speed_proc = pmu_set_cpu_speed;
703 is_pmu_based = 1;
704 }
698 /* Else check for TiPb 400 & 500 */ 705 /* Else check for TiPb 400 & 500 */
699 else if (machine_is_compatible("PowerBook3,2")) { 706 else if (machine_is_compatible("PowerBook3,2")) {
700 /* We only know about the 400 MHz and the 500Mhz model 707 /* We only know about the 400 MHz and the 500Mhz model
diff --git a/arch/ppc/platforms/pmac_feature.c b/arch/ppc/platforms/pmac_feature.c
index 867336ad5d36..dd6d45ae0501 100644
--- a/arch/ppc/platforms/pmac_feature.c
+++ b/arch/ppc/platforms/pmac_feature.c
@@ -2337,6 +2337,10 @@ static struct pmac_mb_def pmac_mb_defs[] __pmacdata = {
2337 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features, 2337 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2338 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE, 2338 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2339 }, 2339 },
2340 { "PowerBook6,7", "iBook G4",
2341 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2342 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2343 },
2340 { "PowerBook6,8", "PowerBook G4 12\"", 2344 { "PowerBook6,8", "PowerBook G4 12\"",
2341 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features, 2345 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2342 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE, 2346 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
diff --git a/arch/ppc/platforms/pmac_setup.c b/arch/ppc/platforms/pmac_setup.c
index b392b9a15987..d6356f480d90 100644
--- a/arch/ppc/platforms/pmac_setup.c
+++ b/arch/ppc/platforms/pmac_setup.c
@@ -48,7 +48,6 @@
48#include <linux/adb.h> 48#include <linux/adb.h>
49#include <linux/cuda.h> 49#include <linux/cuda.h>
50#include <linux/pmu.h> 50#include <linux/pmu.h>
51#include <linux/irq.h>
52#include <linux/seq_file.h> 51#include <linux/seq_file.h>
53#include <linux/root_dev.h> 52#include <linux/root_dev.h>
54#include <linux/bitops.h> 53#include <linux/bitops.h>
@@ -719,7 +718,8 @@ pmac_declare_of_platform_devices(void)
719 if (np) { 718 if (np) {
720 for (np = np->child; np != NULL; np = np->sibling) 719 for (np = np->child; np != NULL; np = np->sibling)
721 if (strncmp(np->name, "i2c", 3) == 0) { 720 if (strncmp(np->name, "i2c", 3) == 0) {
722 of_platform_device_create(np, "uni-n-i2c"); 721 of_platform_device_create(np, "uni-n-i2c",
722 NULL);
723 break; 723 break;
724 } 724 }
725 } 725 }
@@ -727,17 +727,18 @@ pmac_declare_of_platform_devices(void)
727 if (np) { 727 if (np) {
728 for (np = np->child; np != NULL; np = np->sibling) 728 for (np = np->child; np != NULL; np = np->sibling)
729 if (strncmp(np->name, "i2c", 3) == 0) { 729 if (strncmp(np->name, "i2c", 3) == 0) {
730 of_platform_device_create(np, "u3-i2c"); 730 of_platform_device_create(np, "u3-i2c",
731 NULL);
731 break; 732 break;
732 } 733 }
733 } 734 }
734 735
735 np = find_devices("valkyrie"); 736 np = find_devices("valkyrie");
736 if (np) 737 if (np)
737 of_platform_device_create(np, "valkyrie"); 738 of_platform_device_create(np, "valkyrie", NULL);
738 np = find_devices("platinum"); 739 np = find_devices("platinum");
739 if (np) 740 if (np)
740 of_platform_device_create(np, "platinum"); 741 of_platform_device_create(np, "platinum", NULL);
741 742
742 return 0; 743 return 0;
743} 744}
diff --git a/arch/ppc/platforms/pmac_time.c b/arch/ppc/platforms/pmac_time.c
index 778ce4fec368..efb819f9490d 100644
--- a/arch/ppc/platforms/pmac_time.c
+++ b/arch/ppc/platforms/pmac_time.c
@@ -195,7 +195,7 @@ via_calibrate_decr(void)
195 ; 195 ;
196 dend = get_dec(); 196 dend = get_dec();
197 197
198 tb_ticks_per_jiffy = (dstart - dend) / (6 * (HZ/100)); 198 tb_ticks_per_jiffy = (dstart - dend) / ((6 * HZ)/100);
199 tb_to_us = mulhwu_scale_factor(dstart - dend, 60000); 199 tb_to_us = mulhwu_scale_factor(dstart - dend, 60000);
200 200
201 printk(KERN_INFO "via_calibrate_decr: ticks per jiffy = %u (%u ticks)\n", 201 printk(KERN_INFO "via_calibrate_decr: ticks per jiffy = %u (%u ticks)\n",
diff --git a/arch/ppc/platforms/powerpmc250.c b/arch/ppc/platforms/powerpmc250.c
index 0abe15159e6c..e6b520e6e13f 100644
--- a/arch/ppc/platforms/powerpmc250.c
+++ b/arch/ppc/platforms/powerpmc250.c
@@ -26,7 +26,6 @@
26#include <linux/initrd.h> 26#include <linux/initrd.h>
27#include <linux/console.h> 27#include <linux/console.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/irq.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31#include <linux/seq_file.h> 30#include <linux/seq_file.h>
32#include <linux/ide.h> 31#include <linux/ide.h>
diff --git a/arch/ppc/platforms/pplus.c b/arch/ppc/platforms/pplus.c
index 65705c911795..e70aae20d6f9 100644
--- a/arch/ppc/platforms/pplus.c
+++ b/arch/ppc/platforms/pplus.c
@@ -22,7 +22,6 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/console.h> 23#include <linux/console.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/irq.h>
26#include <linux/ide.h> 25#include <linux/ide.h>
27#include <linux/seq_file.h> 26#include <linux/seq_file.h>
28#include <linux/root_dev.h> 27#include <linux/root_dev.h>
diff --git a/arch/ppc/platforms/prpmc750.c b/arch/ppc/platforms/prpmc750.c
index 24ae1caafc61..0bb14a5e824c 100644
--- a/arch/ppc/platforms/prpmc750.c
+++ b/arch/ppc/platforms/prpmc750.c
@@ -24,7 +24,6 @@
24#include <linux/initrd.h> 24#include <linux/initrd.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/seq_file.h> 27#include <linux/seq_file.h>
29#include <linux/ide.h> 28#include <linux/ide.h>
30#include <linux/root_dev.h> 29#include <linux/root_dev.h>
diff --git a/arch/ppc/platforms/prpmc800.c b/arch/ppc/platforms/prpmc800.c
index 8b09fa69b35b..de7baefacd3a 100644
--- a/arch/ppc/platforms/prpmc800.c
+++ b/arch/ppc/platforms/prpmc800.c
@@ -22,7 +22,6 @@
22#include <linux/initrd.h> 22#include <linux/initrd.h>
23#include <linux/console.h> 23#include <linux/console.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/irq.h>
26#include <linux/seq_file.h> 25#include <linux/seq_file.h>
27#include <linux/ide.h> 26#include <linux/ide.h>
28#include <linux/root_dev.h> 27#include <linux/root_dev.h>
diff --git a/arch/ppc/platforms/radstone_ppc7d.c b/arch/ppc/platforms/radstone_ppc7d.c
index c30607a972d8..0376c8cff5d1 100644
--- a/arch/ppc/platforms/radstone_ppc7d.c
+++ b/arch/ppc/platforms/radstone_ppc7d.c
@@ -32,7 +32,6 @@
32#include <linux/initrd.h> 32#include <linux/initrd.h>
33#include <linux/console.h> 33#include <linux/console.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/irq.h>
36#include <linux/ide.h> 35#include <linux/ide.h>
37#include <linux/seq_file.h> 36#include <linux/seq_file.h>
38#include <linux/root_dev.h> 37#include <linux/root_dev.h>
@@ -59,7 +58,6 @@
59#include <asm/mpc10x.h> 58#include <asm/mpc10x.h>
60#include <asm/pci-bridge.h> 59#include <asm/pci-bridge.h>
61#include <asm/mv64x60.h> 60#include <asm/mv64x60.h>
62#include <asm/i8259.h>
63 61
64#include "radstone_ppc7d.h" 62#include "radstone_ppc7d.h"
65 63
diff --git a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
index 21e31346b12b..5232283c1974 100644
--- a/arch/ppc/platforms/sandpoint.c
+++ b/arch/ppc/platforms/sandpoint.c
@@ -74,7 +74,6 @@
74#include <linux/initrd.h> 74#include <linux/initrd.h>
75#include <linux/console.h> 75#include <linux/console.h>
76#include <linux/delay.h> 76#include <linux/delay.h>
77#include <linux/irq.h>
78#include <linux/ide.h> 77#include <linux/ide.h>
79#include <linux/seq_file.h> 78#include <linux/seq_file.h>
80#include <linux/root_dev.h> 79#include <linux/root_dev.h>
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index 8b9b226005d1..b8d08f33f7ee 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -34,7 +34,8 @@ ifeq ($(CONFIG_40x),y)
34obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o ppc405_pci.o 34obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o ppc405_pci.o
35endif 35endif
36endif 36endif
37obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) 37obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \
38 ppc_sys.o mpc8xx_devices.o mpc8xx_sys.o
38ifeq ($(CONFIG_8xx),y) 39ifeq ($(CONFIG_8xx),y)
39obj-$(CONFIG_PCI) += qspan_pci.o i8259.o 40obj-$(CONFIG_PCI) += qspan_pci.o i8259.o
40endif 41endif
diff --git a/arch/ppc/syslib/mpc8xx_devices.c b/arch/ppc/syslib/mpc8xx_devices.c
new file mode 100644
index 000000000000..2b5f0e701687
--- /dev/null
+++ b/arch/ppc/syslib/mpc8xx_devices.c
@@ -0,0 +1,224 @@
1/*
2 * arch/ppc/syslib/mpc8xx_devices.c
3 *
4 * MPC8xx Device descriptions
5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7 *
8 * Copyright 2005 MontaVista Software, Inc. by Vitaly Bordug<vbordug@ru.mvista.com>
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
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/device.h>
19#include <linux/serial_8250.h>
20#include <linux/mii.h>
21#include <asm/commproc.h>
22#include <asm/mpc8xx.h>
23#include <asm/irq.h>
24#include <asm/ppc_sys.h>
25
26/* We use offsets for IORESOURCE_MEM to do not set dependences at compile time.
27 * They will get fixed up by mach_mpc8xx_fixup
28 */
29
30struct platform_device ppc_sys_platform_devices[] = {
31 [MPC8xx_CPM_FEC1] = {
32 .name = "fsl-cpm-fec",
33 .id = 1,
34 .num_resources = 2,
35 .resource = (struct resource[]) {
36 {
37 .name = "regs",
38 .start = 0xe00,
39 .end = 0xe88,
40 .flags = IORESOURCE_MEM,
41 },
42 {
43 .name = "interrupt",
44 .start = MPC8xx_INT_FEC1,
45 .end = MPC8xx_INT_FEC1,
46 .flags = IORESOURCE_IRQ,
47 },
48 },
49 },
50 [MPC8xx_CPM_FEC2] = {
51 .name = "fsl-cpm-fec",
52 .id = 2,
53 .num_resources = 2,
54 .resource = (struct resource[]) {
55 {
56 .name = "regs",
57 .start = 0x1e00,
58 .end = 0x1e88,
59 .flags = IORESOURCE_MEM,
60 },
61 {
62 .name = "interrupt",
63 .start = MPC8xx_INT_FEC2,
64 .end = MPC8xx_INT_FEC2,
65 .flags = IORESOURCE_IRQ,
66 },
67 },
68 },
69 [MPC8xx_CPM_SCC1] = {
70 .name = "fsl-cpm-scc",
71 .id = 1,
72 .num_resources = 3,
73 .resource = (struct resource[]) {
74 {
75 .name = "regs",
76 .start = 0xa00,
77 .end = 0xa18,
78 .flags = IORESOURCE_MEM,
79 },
80 {
81 .name = "pram",
82 .start = 0x3c00,
83 .end = 0x3c80,
84 .flags = IORESOURCE_MEM,
85 },
86 {
87 .name = "interrupt",
88 .start = MPC8xx_INT_SCC1,
89 .end = MPC8xx_INT_SCC1,
90 .flags = IORESOURCE_IRQ,
91 },
92 },
93 },
94 [MPC8xx_CPM_SCC2] = {
95 .name = "fsl-cpm-scc",
96 .id = 2,
97 .num_resources = 3,
98 .resource = (struct resource[]) {
99 {
100 .name = "regs",
101 .start = 0xa20,
102 .end = 0xa38,
103 .flags = IORESOURCE_MEM,
104 },
105 {
106 .name = "pram",
107 .start = 0x3d00,
108 .end = 0x3d80,
109 .flags = IORESOURCE_MEM,
110 },
111
112 {
113 .name = "interrupt",
114 .start = MPC8xx_INT_SCC2,
115 .end = MPC8xx_INT_SCC2,
116 .flags = IORESOURCE_IRQ,
117 },
118 },
119 },
120 [MPC8xx_CPM_SCC3] = {
121 .name = "fsl-cpm-scc",
122 .id = 3,
123 .num_resources = 3,
124 .resource = (struct resource[]) {
125 {
126 .name = "regs",
127 .start = 0xa40,
128 .end = 0xa58,
129 .flags = IORESOURCE_MEM,
130 },
131 {
132 .name = "pram",
133 .start = 0x3e00,
134 .end = 0x3e80,
135 .flags = IORESOURCE_MEM,
136 },
137
138 {
139 .name = "interrupt",
140 .start = MPC8xx_INT_SCC3,
141 .end = MPC8xx_INT_SCC3,
142 .flags = IORESOURCE_IRQ,
143 },
144 },
145 },
146 [MPC8xx_CPM_SCC4] = {
147 .name = "fsl-cpm-scc",
148 .id = 4,
149 .num_resources = 3,
150 .resource = (struct resource[]) {
151 {
152 .name = "regs",
153 .start = 0xa60,
154 .end = 0xa78,
155 .flags = IORESOURCE_MEM,
156 },
157 {
158 .name = "pram",
159 .start = 0x3f00,
160 .end = 0x3f80,
161 .flags = IORESOURCE_MEM,
162 },
163
164 {
165 .name = "interrupt",
166 .start = MPC8xx_INT_SCC4,
167 .end = MPC8xx_INT_SCC4,
168 .flags = IORESOURCE_IRQ,
169 },
170 },
171 },
172 [MPC8xx_CPM_SMC1] = {
173 .name = "fsl-cpm-smc",
174 .id = 1,
175 .num_resources = 2,
176 .resource = (struct resource[]) {
177 {
178 .name = "regs",
179 .start = 0xa82,
180 .end = 0xa91,
181 .flags = IORESOURCE_MEM,
182 },
183 {
184 .name = "interrupt",
185 .start = MPC8xx_INT_SMC1,
186 .end = MPC8xx_INT_SMC1,
187 .flags = IORESOURCE_IRQ,
188 },
189 },
190 },
191 [MPC8xx_CPM_SMC2] = {
192 .name = "fsl-cpm-smc",
193 .id = 2,
194 .num_resources = 2,
195 .resource = (struct resource[]) {
196 {
197 .name = "regs",
198 .start = 0xa92,
199 .end = 0xaa1,
200 .flags = IORESOURCE_MEM,
201 },
202 {
203 .name = "interrupt",
204 .start = MPC8xx_INT_SMC2,
205 .end = MPC8xx_INT_SMC2,
206 .flags = IORESOURCE_IRQ,
207 },
208 },
209 },
210};
211
212static int __init mach_mpc8xx_fixup(struct platform_device *pdev)
213{
214 ppc_sys_fixup_mem_resource (pdev, IMAP_ADDR);
215 return 0;
216}
217
218static int __init mach_mpc8xx_init(void)
219{
220 ppc_sys_device_fixup = mach_mpc8xx_fixup;
221 return 0;
222}
223
224postcore_initcall(mach_mpc8xx_init);
diff --git a/arch/ppc/syslib/mpc8xx_sys.c b/arch/ppc/syslib/mpc8xx_sys.c
new file mode 100644
index 000000000000..a532ccc861c0
--- /dev/null
+++ b/arch/ppc/syslib/mpc8xx_sys.c
@@ -0,0 +1,61 @@
1/*
2 * arch/ppc/platforms/mpc8xx_sys.c
3 *
4 * MPC8xx System descriptions
5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7 *
8 * Copyright 2005 MontaVista Software, Inc. by Vitaly Bordug <vbordug@ru.mvista.com>
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
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/device.h>
19#include <asm/ppc_sys.h>
20
21struct ppc_sys_spec *cur_ppc_sys_spec;
22struct ppc_sys_spec ppc_sys_specs[] = {
23 {
24 .ppc_sys_name = "MPC86X",
25 .mask = 0xFFFFFFFF,
26 .value = 0x00000000,
27 .num_devices = 2,
28 .device_list = (enum ppc_sys_devices[])
29 {
30 MPC8xx_CPM_FEC1,
31 MPC8xx_CPM_SCC1,
32 MPC8xx_CPM_SCC2,
33 MPC8xx_CPM_SCC3,
34 MPC8xx_CPM_SCC4,
35 MPC8xx_CPM_SMC1,
36 MPC8xx_CPM_SMC2,
37 },
38 },
39 {
40 .ppc_sys_name = "MPC885",
41 .mask = 0xFFFFFFFF,
42 .value = 0x00000000,
43 .num_devices = 3,
44 .device_list = (enum ppc_sys_devices[])
45 {
46 MPC8xx_CPM_FEC1,
47 MPC8xx_CPM_FEC2,
48 MPC8xx_CPM_SCC1,
49 MPC8xx_CPM_SCC2,
50 MPC8xx_CPM_SCC3,
51 MPC8xx_CPM_SCC4,
52 MPC8xx_CPM_SMC1,
53 MPC8xx_CPM_SMC2,
54 },
55 },
56 { /* default match */
57 .ppc_sys_name = "",
58 .mask = 0x00000000,
59 .value = 0x00000000,
60 },
61};
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index 839f8872826f..4849850a59ed 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -34,7 +34,7 @@ u8 mv64x60_pci_exclude_bridge = 1;
34DEFINE_SPINLOCK(mv64x60_lock); 34DEFINE_SPINLOCK(mv64x60_lock);
35 35
36static phys_addr_t mv64x60_bridge_pbase; 36static phys_addr_t mv64x60_bridge_pbase;
37static void *mv64x60_bridge_vbase; 37static void __iomem *mv64x60_bridge_vbase;
38static u32 mv64x60_bridge_type = MV64x60_TYPE_INVALID; 38static u32 mv64x60_bridge_type = MV64x60_TYPE_INVALID;
39static u32 mv64x60_bridge_rev; 39static u32 mv64x60_bridge_rev;
40#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260) 40#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
@@ -938,7 +938,7 @@ mv64x60_setup_for_chip(struct mv64x60_handle *bh)
938 * 938 *
939 * Return the virtual address of the bridge's registers. 939 * Return the virtual address of the bridge's registers.
940 */ 940 */
941void * 941void __iomem *
942mv64x60_get_bridge_vbase(void) 942mv64x60_get_bridge_vbase(void)
943{ 943{
944 return mv64x60_bridge_vbase; 944 return mv64x60_bridge_vbase;
diff --git a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c
index da8a0f2128dc..93c7231ea709 100644
--- a/arch/ppc/syslib/of_device.c
+++ b/arch/ppc/syslib/of_device.c
@@ -234,7 +234,9 @@ void of_device_unregister(struct of_device *ofdev)
234 device_unregister(&ofdev->dev); 234 device_unregister(&ofdev->dev);
235} 235}
236 236
237struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id) 237struct of_device* of_platform_device_create(struct device_node *np,
238 const char *bus_id,
239 struct device *parent)
238{ 240{
239 struct of_device *dev; 241 struct of_device *dev;
240 u32 *reg; 242 u32 *reg;
@@ -247,7 +249,7 @@ struct of_device* of_platform_device_create(struct device_node *np, const char *
247 dev->node = of_node_get(np); 249 dev->node = of_node_get(np);
248 dev->dma_mask = 0xffffffffUL; 250 dev->dma_mask = 0xffffffffUL;
249 dev->dev.dma_mask = &dev->dma_mask; 251 dev->dev.dma_mask = &dev->dma_mask;
250 dev->dev.parent = NULL; 252 dev->dev.parent = parent;
251 dev->dev.bus = &of_platform_bus_type; 253 dev->dev.bus = &of_platform_bus_type;
252 dev->dev.release = of_release_dev; 254 dev->dev.release = of_release_dev;
253 255
diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
index 53da58523e39..1cf5de21a3fd 100644
--- a/arch/ppc/syslib/open_pic.c
+++ b/arch/ppc/syslib/open_pic.c
@@ -13,7 +13,6 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irq.h>
17#include <linux/interrupt.h> 16#include <linux/interrupt.h>
18#include <linux/sysdev.h> 17#include <linux/sysdev.h>
19#include <linux/errno.h> 18#include <linux/errno.h>
diff --git a/arch/ppc/syslib/open_pic2.c b/arch/ppc/syslib/open_pic2.c
index 2e0ea92144f6..16cff91d9f41 100644
--- a/arch/ppc/syslib/open_pic2.c
+++ b/arch/ppc/syslib/open_pic2.c
@@ -17,7 +17,6 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/irq.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/sysdev.h> 21#include <linux/sysdev.h>
23#include <linux/errno.h> 22#include <linux/errno.h>
@@ -575,7 +574,7 @@ static void openpic2_cached_disable_irq(u_int irq)
575 * we need something better to deal with that... Maybe switch to S1 for 574 * we need something better to deal with that... Maybe switch to S1 for
576 * cpufreq changes 575 * cpufreq changes
577 */ 576 */
578int openpic2_suspend(struct sys_device *sysdev, u32 state) 577int openpic2_suspend(struct sys_device *sysdev, pm_message_t state)
579{ 578{
580 int i; 579 int i;
581 unsigned long flags; 580 unsigned long flags;
diff --git a/arch/ppc/syslib/ppc4xx_setup.c b/arch/ppc/syslib/ppc4xx_setup.c
index b843c4fef25e..bf83240689dc 100644
--- a/arch/ppc/syslib/ppc4xx_setup.c
+++ b/arch/ppc/syslib/ppc4xx_setup.c
@@ -18,7 +18,6 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/threads.h> 19#include <linux/threads.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/irq.h>
22#include <linux/reboot.h> 21#include <linux/reboot.h>
23#include <linux/param.h> 22#include <linux/param.h>
24#include <linux/string.h> 23#include <linux/string.h>
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
index b7242f1bd931..832b8bf99ae7 100644
--- a/arch/ppc/syslib/ppc85xx_setup.c
+++ b/arch/ppc/syslib/ppc85xx_setup.c
@@ -184,8 +184,8 @@ mpc85xx_setup_pci1(struct pci_controller *hose)
184 pci->powar1 = 0x80044000 | 184 pci->powar1 = 0x80044000 |
185 (__ilog2(MPC85XX_PCI1_UPPER_MEM - MPC85XX_PCI1_LOWER_MEM + 1) - 1); 185 (__ilog2(MPC85XX_PCI1_UPPER_MEM - MPC85XX_PCI1_LOWER_MEM + 1) - 1);
186 186
187 /* Setup outboud IO windows @ MPC85XX_PCI1_IO_BASE */ 187 /* Setup outbound IO windows @ MPC85XX_PCI1_IO_BASE */
188 pci->potar2 = 0x00000000; 188 pci->potar2 = (MPC85XX_PCI1_LOWER_IO >> 12) & 0x000fffff;
189 pci->potear2 = 0x00000000; 189 pci->potear2 = 0x00000000;
190 pci->powbar2 = (MPC85XX_PCI1_IO_BASE >> 12) & 0x000fffff; 190 pci->powbar2 = (MPC85XX_PCI1_IO_BASE >> 12) & 0x000fffff;
191 /* Enable, IO R/W */ 191 /* Enable, IO R/W */
@@ -235,8 +235,8 @@ mpc85xx_setup_pci2(struct pci_controller *hose)
235 pci->powar1 = 0x80044000 | 235 pci->powar1 = 0x80044000 |
236 (__ilog2(MPC85XX_PCI2_UPPER_MEM - MPC85XX_PCI2_LOWER_MEM + 1) - 1); 236 (__ilog2(MPC85XX_PCI2_UPPER_MEM - MPC85XX_PCI2_LOWER_MEM + 1) - 1);
237 237
238 /* Setup outboud IO windows @ MPC85XX_PCI2_IO_BASE */ 238 /* Setup outbound IO windows @ MPC85XX_PCI2_IO_BASE */
239 pci->potar2 = 0x00000000; 239 pci->potar2 = (MPC85XX_PCI2_LOWER_IO >> 12) & 0x000fffff;;
240 pci->potear2 = 0x00000000; 240 pci->potear2 = 0x00000000;
241 pci->powbar2 = (MPC85XX_PCI2_IO_BASE >> 12) & 0x000fffff; 241 pci->powbar2 = (MPC85XX_PCI2_IO_BASE >> 12) & 0x000fffff;
242 /* Enable, IO R/W */ 242 /* Enable, IO R/W */
diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile
index 17d2c1eac3b8..521c2a5a2862 100644
--- a/arch/ppc64/Makefile
+++ b/arch/ppc64/Makefile
@@ -107,7 +107,7 @@ install: vmlinux
107 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@ 107 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(BOOTIMAGE) $@
108 108
109defaultimage-$(CONFIG_PPC_PSERIES) := zImage 109defaultimage-$(CONFIG_PPC_PSERIES) := zImage
110defaultimage-$(CONFIG_PPC_PMAC) := vmlinux 110defaultimage-$(CONFIG_PPC_PMAC) := zImage.vmode
111defaultimage-$(CONFIG_PPC_MAPLE) := zImage 111defaultimage-$(CONFIG_PPC_MAPLE) := zImage
112defaultimage-$(CONFIG_PPC_ISERIES) := vmlinux 112defaultimage-$(CONFIG_PPC_ISERIES) := vmlinux
113KBUILD_IMAGE := $(defaultimage-y) 113KBUILD_IMAGE := $(defaultimage-y)
diff --git a/arch/ppc64/configs/bpa_defconfig b/arch/ppc64/configs/bpa_defconfig
index 46c5da41c3ae..67ffecbc05cb 100644
--- a/arch/ppc64/configs/bpa_defconfig
+++ b/arch/ppc64/configs/bpa_defconfig
@@ -1,17 +1,17 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6 3# Linux kernel version: 2.6.14-rc4
4# Mon Aug 8 14:12:19 2005 4# Thu Oct 20 08:29:10 2005
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_GENERIC_ISA_DMA=y 10CONFIG_GENERIC_ISA_DMA=y
11CONFIG_HAVE_DEC_LOCK=y
12CONFIG_EARLY_PRINTK=y 11CONFIG_EARLY_PRINTK=y
13CONFIG_COMPAT=y 12CONFIG_COMPAT=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15CONFIG_FORCE_MAX_ZONEORDER=13 15CONFIG_FORCE_MAX_ZONEORDER=13
16 16
17# 17#
@@ -26,6 +26,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 26# General setup
27# 27#
28CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 30CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
31# CONFIG_POSIX_MQUEUE is not set 32# CONFIG_POSIX_MQUEUE is not set
@@ -36,6 +37,7 @@ CONFIG_HOTPLUG=y
36CONFIG_KOBJECT_UEVENT=y 37CONFIG_KOBJECT_UEVENT=y
37# CONFIG_IKCONFIG is not set 38# CONFIG_IKCONFIG is not set
38# CONFIG_CPUSETS is not set 39# CONFIG_CPUSETS is not set
40CONFIG_INITRAMFS_SOURCE=""
39# CONFIG_EMBEDDED is not set 41# CONFIG_EMBEDDED is not set
40CONFIG_KALLSYMS=y 42CONFIG_KALLSYMS=y
41# CONFIG_KALLSYMS_ALL is not set 43# CONFIG_KALLSYMS_ALL is not set
@@ -95,6 +97,7 @@ CONFIG_FLATMEM_MANUAL=y
95# CONFIG_SPARSEMEM_MANUAL is not set 97# CONFIG_SPARSEMEM_MANUAL is not set
96CONFIG_FLATMEM=y 98CONFIG_FLATMEM=y
97CONFIG_FLAT_NODE_MEM_MAP=y 99CONFIG_FLAT_NODE_MEM_MAP=y
100# CONFIG_SPARSEMEM_STATIC is not set
98# CONFIG_NUMA is not set 101# CONFIG_NUMA is not set
99CONFIG_SCHED_SMT=y 102CONFIG_SCHED_SMT=y
100CONFIG_PREEMPT_NONE=y 103CONFIG_PREEMPT_NONE=y
@@ -110,17 +113,18 @@ CONFIG_PPC_RTAS=y
110CONFIG_RTAS_PROC=y 113CONFIG_RTAS_PROC=y
111CONFIG_RTAS_FLASH=y 114CONFIG_RTAS_FLASH=y
112CONFIG_SECCOMP=y 115CONFIG_SECCOMP=y
116CONFIG_BINFMT_ELF=y
117# CONFIG_BINFMT_MISC is not set
118CONFIG_PROC_DEVICETREE=y
119# CONFIG_CMDLINE_BOOL is not set
113CONFIG_ISA_DMA_API=y 120CONFIG_ISA_DMA_API=y
114 121
115# 122#
116# General setup 123# Bus Options
117# 124#
118CONFIG_PCI=y 125CONFIG_PCI=y
119CONFIG_PCI_DOMAINS=y 126CONFIG_PCI_DOMAINS=y
120CONFIG_BINFMT_ELF=y
121# CONFIG_BINFMT_MISC is not set
122CONFIG_PCI_LEGACY_PROC=y 127CONFIG_PCI_LEGACY_PROC=y
123CONFIG_PCI_NAMES=y
124# CONFIG_PCI_DEBUG is not set 128# CONFIG_PCI_DEBUG is not set
125 129
126# 130#
@@ -132,8 +136,6 @@ CONFIG_PCI_NAMES=y
132# PCI Hotplug Support 136# PCI Hotplug Support
133# 137#
134# CONFIG_HOTPLUG_PCI is not set 138# CONFIG_HOTPLUG_PCI is not set
135CONFIG_PROC_DEVICETREE=y
136# CONFIG_CMDLINE_BOOL is not set
137 139
138# 140#
139# Networking 141# Networking
@@ -163,8 +165,8 @@ CONFIG_SYN_COOKIES=y
163# CONFIG_INET_ESP is not set 165# CONFIG_INET_ESP is not set
164# CONFIG_INET_IPCOMP is not set 166# CONFIG_INET_IPCOMP is not set
165CONFIG_INET_TUNNEL=y 167CONFIG_INET_TUNNEL=y
166CONFIG_IP_TCPDIAG=y 168CONFIG_INET_DIAG=y
167CONFIG_IP_TCPDIAG_IPV6=y 169CONFIG_INET_TCP_DIAG=y
168# CONFIG_TCP_CONG_ADVANCED is not set 170# CONFIG_TCP_CONG_ADVANCED is not set
169CONFIG_TCP_CONG_BIC=y 171CONFIG_TCP_CONG_BIC=y
170 172
@@ -181,6 +183,7 @@ CONFIG_INET6_TUNNEL=m
181CONFIG_IPV6_TUNNEL=m 183CONFIG_IPV6_TUNNEL=m
182CONFIG_NETFILTER=y 184CONFIG_NETFILTER=y
183# CONFIG_NETFILTER_DEBUG is not set 185# CONFIG_NETFILTER_DEBUG is not set
186# CONFIG_NETFILTER_NETLINK is not set
184 187
185# 188#
186# IP: Netfilter Configuration 189# IP: Netfilter Configuration
@@ -188,11 +191,14 @@ CONFIG_NETFILTER=y
188CONFIG_IP_NF_CONNTRACK=y 191CONFIG_IP_NF_CONNTRACK=y
189# CONFIG_IP_NF_CT_ACCT is not set 192# CONFIG_IP_NF_CT_ACCT is not set
190# CONFIG_IP_NF_CONNTRACK_MARK is not set 193# CONFIG_IP_NF_CONNTRACK_MARK is not set
194# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
191CONFIG_IP_NF_CT_PROTO_SCTP=y 195CONFIG_IP_NF_CT_PROTO_SCTP=y
192CONFIG_IP_NF_FTP=m 196CONFIG_IP_NF_FTP=m
193CONFIG_IP_NF_IRC=m 197CONFIG_IP_NF_IRC=m
198# CONFIG_IP_NF_NETBIOS_NS is not set
194CONFIG_IP_NF_TFTP=m 199CONFIG_IP_NF_TFTP=m
195CONFIG_IP_NF_AMANDA=m 200CONFIG_IP_NF_AMANDA=m
201# CONFIG_IP_NF_PPTP is not set
196CONFIG_IP_NF_QUEUE=m 202CONFIG_IP_NF_QUEUE=m
197CONFIG_IP_NF_IPTABLES=m 203CONFIG_IP_NF_IPTABLES=m
198CONFIG_IP_NF_MATCH_LIMIT=m 204CONFIG_IP_NF_MATCH_LIMIT=m
@@ -216,13 +222,16 @@ CONFIG_IP_NF_MATCH_OWNER=m
216CONFIG_IP_NF_MATCH_ADDRTYPE=m 222CONFIG_IP_NF_MATCH_ADDRTYPE=m
217CONFIG_IP_NF_MATCH_REALM=m 223CONFIG_IP_NF_MATCH_REALM=m
218CONFIG_IP_NF_MATCH_SCTP=m 224CONFIG_IP_NF_MATCH_SCTP=m
225# CONFIG_IP_NF_MATCH_DCCP is not set
219CONFIG_IP_NF_MATCH_COMMENT=m 226CONFIG_IP_NF_MATCH_COMMENT=m
220CONFIG_IP_NF_MATCH_HASHLIMIT=m 227CONFIG_IP_NF_MATCH_HASHLIMIT=m
228CONFIG_IP_NF_MATCH_STRING=m
221CONFIG_IP_NF_FILTER=m 229CONFIG_IP_NF_FILTER=m
222CONFIG_IP_NF_TARGET_REJECT=m 230CONFIG_IP_NF_TARGET_REJECT=m
223CONFIG_IP_NF_TARGET_LOG=m 231CONFIG_IP_NF_TARGET_LOG=m
224CONFIG_IP_NF_TARGET_ULOG=m 232CONFIG_IP_NF_TARGET_ULOG=m
225CONFIG_IP_NF_TARGET_TCPMSS=m 233CONFIG_IP_NF_TARGET_TCPMSS=m
234CONFIG_IP_NF_TARGET_NFQUEUE=m
226CONFIG_IP_NF_NAT=m 235CONFIG_IP_NF_NAT=m
227CONFIG_IP_NF_NAT_NEEDED=y 236CONFIG_IP_NF_NAT_NEEDED=y
228CONFIG_IP_NF_TARGET_MASQUERADE=m 237CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -240,6 +249,7 @@ CONFIG_IP_NF_TARGET_ECN=m
240CONFIG_IP_NF_TARGET_DSCP=m 249CONFIG_IP_NF_TARGET_DSCP=m
241CONFIG_IP_NF_TARGET_MARK=m 250CONFIG_IP_NF_TARGET_MARK=m
242CONFIG_IP_NF_TARGET_CLASSIFY=m 251CONFIG_IP_NF_TARGET_CLASSIFY=m
252CONFIG_IP_NF_TARGET_TTL=m
243CONFIG_IP_NF_RAW=m 253CONFIG_IP_NF_RAW=m
244CONFIG_IP_NF_TARGET_NOTRACK=m 254CONFIG_IP_NF_TARGET_NOTRACK=m
245CONFIG_IP_NF_ARPTABLES=m 255CONFIG_IP_NF_ARPTABLES=m
@@ -251,6 +261,12 @@ CONFIG_IP_NF_ARP_MANGLE=m
251# 261#
252# CONFIG_IP6_NF_QUEUE is not set 262# CONFIG_IP6_NF_QUEUE is not set
253# CONFIG_IP6_NF_IPTABLES is not set 263# CONFIG_IP6_NF_IPTABLES is not set
264# CONFIG_IP6_NF_TARGET_NFQUEUE is not set
265
266#
267# DCCP Configuration (EXPERIMENTAL)
268#
269# CONFIG_IP_DCCP is not set
254 270
255# 271#
256# SCTP Configuration (EXPERIMENTAL) 272# SCTP Configuration (EXPERIMENTAL)
@@ -278,6 +294,7 @@ CONFIG_NET_CLS_ROUTE=y
278# CONFIG_HAMRADIO is not set 294# CONFIG_HAMRADIO is not set
279# CONFIG_IRDA is not set 295# CONFIG_IRDA is not set
280# CONFIG_BT is not set 296# CONFIG_BT is not set
297# CONFIG_IEEE80211 is not set
281 298
282# 299#
283# Device Drivers 300# Device Drivers
@@ -292,6 +309,11 @@ CONFIG_FW_LOADER=y
292# CONFIG_DEBUG_DRIVER is not set 309# CONFIG_DEBUG_DRIVER is not set
293 310
294# 311#
312# Connector - unified userspace <-> kernelspace linker
313#
314# CONFIG_CONNECTOR is not set
315
316#
295# Memory Technology Devices (MTD) 317# Memory Technology Devices (MTD)
296# 318#
297# CONFIG_MTD is not set 319# CONFIG_MTD is not set
@@ -322,7 +344,6 @@ CONFIG_BLK_DEV_RAM=y
322CONFIG_BLK_DEV_RAM_COUNT=16 344CONFIG_BLK_DEV_RAM_COUNT=16
323CONFIG_BLK_DEV_RAM_SIZE=131072 345CONFIG_BLK_DEV_RAM_SIZE=131072
324CONFIG_BLK_DEV_INITRD=y 346CONFIG_BLK_DEV_INITRD=y
325CONFIG_INITRAMFS_SOURCE=""
326# CONFIG_CDROM_PKTCDVD is not set 347# CONFIG_CDROM_PKTCDVD is not set
327 348
328# 349#
@@ -395,6 +416,7 @@ CONFIG_IDEDMA_AUTO=y
395# 416#
396# SCSI device support 417# SCSI device support
397# 418#
419# CONFIG_RAID_ATTRS is not set
398# CONFIG_SCSI is not set 420# CONFIG_SCSI is not set
399 421
400# 422#
@@ -436,12 +458,18 @@ CONFIG_NETDEVICES=y
436# CONFIG_ARCNET is not set 458# CONFIG_ARCNET is not set
437 459
438# 460#
461# PHY device support
462#
463# CONFIG_PHYLIB is not set
464
465#
439# Ethernet (10 or 100Mbit) 466# Ethernet (10 or 100Mbit)
440# 467#
441CONFIG_NET_ETHERNET=y 468CONFIG_NET_ETHERNET=y
442CONFIG_MII=y 469CONFIG_MII=y
443# CONFIG_HAPPYMEAL is not set 470# CONFIG_HAPPYMEAL is not set
444# CONFIG_SUNGEM is not set 471# CONFIG_SUNGEM is not set
472# CONFIG_CASSINI is not set
445# CONFIG_NET_VENDOR_3COM is not set 473# CONFIG_NET_VENDOR_3COM is not set
446 474
447# 475#
@@ -462,15 +490,18 @@ CONFIG_E1000=m
462# CONFIG_HAMACHI is not set 490# CONFIG_HAMACHI is not set
463# CONFIG_YELLOWFIN is not set 491# CONFIG_YELLOWFIN is not set
464# CONFIG_R8169 is not set 492# CONFIG_R8169 is not set
493# CONFIG_SIS190 is not set
465CONFIG_SKGE=m 494CONFIG_SKGE=m
466# CONFIG_SK98LIN is not set 495# CONFIG_SK98LIN is not set
467# CONFIG_TIGON3 is not set 496# CONFIG_TIGON3 is not set
468# CONFIG_BNX2 is not set 497# CONFIG_BNX2 is not set
498# CONFIG_SPIDER_NET is not set
469# CONFIG_MV643XX_ETH is not set 499# CONFIG_MV643XX_ETH is not set
470 500
471# 501#
472# Ethernet (10000 Mbit) 502# Ethernet (10000 Mbit)
473# 503#
504# CONFIG_CHELSIO_T1 is not set
474# CONFIG_IXGB is not set 505# CONFIG_IXGB is not set
475# CONFIG_S2IO is not set 506# CONFIG_S2IO is not set
476 507
@@ -552,6 +583,7 @@ CONFIG_HW_CONSOLE=y
552CONFIG_SERIAL_NONSTANDARD=y 583CONFIG_SERIAL_NONSTANDARD=y
553# CONFIG_ROCKETPORT is not set 584# CONFIG_ROCKETPORT is not set
554# CONFIG_CYCLADES is not set 585# CONFIG_CYCLADES is not set
586# CONFIG_DIGIEPCA is not set
555# CONFIG_MOXA_SMARTIO is not set 587# CONFIG_MOXA_SMARTIO is not set
556# CONFIG_ISI is not set 588# CONFIG_ISI is not set
557# CONFIG_SYNCLINK is not set 589# CONFIG_SYNCLINK is not set
@@ -642,7 +674,6 @@ CONFIG_I2C_ALGOBIT=y
642# CONFIG_I2C_I801 is not set 674# CONFIG_I2C_I801 is not set
643# CONFIG_I2C_I810 is not set 675# CONFIG_I2C_I810 is not set
644# CONFIG_I2C_PIIX4 is not set 676# CONFIG_I2C_PIIX4 is not set
645# CONFIG_I2C_ISA is not set
646# CONFIG_I2C_NFORCE2 is not set 677# CONFIG_I2C_NFORCE2 is not set
647# CONFIG_I2C_PARPORT_LIGHT is not set 678# CONFIG_I2C_PARPORT_LIGHT is not set
648# CONFIG_I2C_PROSAVAGE is not set 679# CONFIG_I2C_PROSAVAGE is not set
@@ -656,7 +687,6 @@ CONFIG_I2C_ALGOBIT=y
656# CONFIG_I2C_VIAPRO is not set 687# CONFIG_I2C_VIAPRO is not set
657# CONFIG_I2C_VOODOO3 is not set 688# CONFIG_I2C_VOODOO3 is not set
658# CONFIG_I2C_PCA_ISA is not set 689# CONFIG_I2C_PCA_ISA is not set
659# CONFIG_I2C_SENSOR is not set
660 690
661# 691#
662# Miscellaneous I2C Chip support 692# Miscellaneous I2C Chip support
@@ -683,12 +713,17 @@ CONFIG_I2C_ALGOBIT=y
683# Hardware Monitoring support 713# Hardware Monitoring support
684# 714#
685# CONFIG_HWMON is not set 715# CONFIG_HWMON is not set
716# CONFIG_HWMON_VID is not set
686 717
687# 718#
688# Misc devices 719# Misc devices
689# 720#
690 721
691# 722#
723# Multimedia Capabilities Port drivers
724#
725
726#
692# Multimedia devices 727# Multimedia devices
693# 728#
694# CONFIG_VIDEO_DEV is not set 729# CONFIG_VIDEO_DEV is not set
@@ -756,10 +791,6 @@ CONFIG_FS_MBCACHE=y
756# CONFIG_REISERFS_FS is not set 791# CONFIG_REISERFS_FS is not set
757# CONFIG_JFS_FS is not set 792# CONFIG_JFS_FS is not set
758CONFIG_FS_POSIX_ACL=y 793CONFIG_FS_POSIX_ACL=y
759
760#
761# XFS support
762#
763# CONFIG_XFS_FS is not set 794# CONFIG_XFS_FS is not set
764# CONFIG_MINIX_FS is not set 795# CONFIG_MINIX_FS is not set
765# CONFIG_ROMFS_FS is not set 796# CONFIG_ROMFS_FS is not set
@@ -768,6 +799,7 @@ CONFIG_INOTIFY=y
768CONFIG_DNOTIFY=y 799CONFIG_DNOTIFY=y
769# CONFIG_AUTOFS_FS is not set 800# CONFIG_AUTOFS_FS is not set
770# CONFIG_AUTOFS4_FS is not set 801# CONFIG_AUTOFS4_FS is not set
802# CONFIG_FUSE_FS is not set
771 803
772# 804#
773# CD-ROM/DVD Filesystems 805# CD-ROM/DVD Filesystems
@@ -794,13 +826,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
794CONFIG_PROC_FS=y 826CONFIG_PROC_FS=y
795CONFIG_PROC_KCORE=y 827CONFIG_PROC_KCORE=y
796CONFIG_SYSFS=y 828CONFIG_SYSFS=y
797# CONFIG_DEVPTS_FS_XATTR is not set
798CONFIG_TMPFS=y 829CONFIG_TMPFS=y
799CONFIG_TMPFS_XATTR=y
800# CONFIG_TMPFS_SECURITY is not set
801CONFIG_HUGETLBFS=y 830CONFIG_HUGETLBFS=y
802CONFIG_HUGETLB_PAGE=y 831CONFIG_HUGETLB_PAGE=y
803CONFIG_RAMFS=y 832CONFIG_RAMFS=y
833# CONFIG_RELAYFS_FS is not set
804 834
805# 835#
806# Miscellaneous filesystems 836# Miscellaneous filesystems
@@ -846,6 +876,7 @@ CONFIG_SUNRPC=m
846# CONFIG_NCP_FS is not set 876# CONFIG_NCP_FS is not set
847# CONFIG_CODA_FS is not set 877# CONFIG_CODA_FS is not set
848# CONFIG_AFS_FS is not set 878# CONFIG_AFS_FS is not set
879# CONFIG_9P_FS is not set
849 880
850# 881#
851# Partition Types 882# Partition Types
@@ -923,6 +954,7 @@ CONFIG_NLS_ISO8859_15=m
923CONFIG_DEBUG_KERNEL=y 954CONFIG_DEBUG_KERNEL=y
924CONFIG_MAGIC_SYSRQ=y 955CONFIG_MAGIC_SYSRQ=y
925CONFIG_LOG_BUF_SHIFT=15 956CONFIG_LOG_BUF_SHIFT=15
957CONFIG_DETECT_SOFTLOCKUP=y
926# CONFIG_SCHEDSTATS is not set 958# CONFIG_SCHEDSTATS is not set
927# CONFIG_DEBUG_SLAB is not set 959# CONFIG_DEBUG_SLAB is not set
928# CONFIG_DEBUG_SPINLOCK is not set 960# CONFIG_DEBUG_SPINLOCK is not set
@@ -981,7 +1013,12 @@ CONFIG_CRYPTO_DEFLATE=m
981# Library routines 1013# Library routines
982# 1014#
983# CONFIG_CRC_CCITT is not set 1015# CONFIG_CRC_CCITT is not set
1016# CONFIG_CRC16 is not set
984CONFIG_CRC32=y 1017CONFIG_CRC32=y
985# CONFIG_LIBCRC32C is not set 1018# CONFIG_LIBCRC32C is not set
986CONFIG_ZLIB_INFLATE=m 1019CONFIG_ZLIB_INFLATE=m
987CONFIG_ZLIB_DEFLATE=m 1020CONFIG_ZLIB_DEFLATE=m
1021CONFIG_TEXTSEARCH=y
1022CONFIG_TEXTSEARCH_KMP=m
1023CONFIG_TEXTSEARCH_BM=m
1024CONFIG_TEXTSEARCH_FSM=m
diff --git a/arch/ppc64/configs/g5_defconfig b/arch/ppc64/configs/g5_defconfig
index fc83d9330282..6323065fbf2c 100644
--- a/arch/ppc64/configs/g5_defconfig
+++ b/arch/ppc64/configs/g5_defconfig
@@ -1,17 +1,17 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6 3# Linux kernel version: 2.6.14-rc4
4# Mon Aug 8 14:16:59 2005 4# Thu Oct 20 08:30:23 2005
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_GENERIC_ISA_DMA=y 10CONFIG_GENERIC_ISA_DMA=y
11CONFIG_HAVE_DEC_LOCK=y
12CONFIG_EARLY_PRINTK=y 11CONFIG_EARLY_PRINTK=y
13CONFIG_COMPAT=y 12CONFIG_COMPAT=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15CONFIG_FORCE_MAX_ZONEORDER=13 15CONFIG_FORCE_MAX_ZONEORDER=13
16 16
17# 17#
@@ -26,6 +26,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 26# General setup
27# 27#
28CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 30CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
31CONFIG_POSIX_MQUEUE=y 32CONFIG_POSIX_MQUEUE=y
@@ -37,6 +38,7 @@ CONFIG_KOBJECT_UEVENT=y
37CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
38CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
39# CONFIG_CPUSETS is not set 40# CONFIG_CPUSETS is not set
41CONFIG_INITRAMFS_SOURCE=""
40# CONFIG_EMBEDDED is not set 42# CONFIG_EMBEDDED is not set
41CONFIG_KALLSYMS=y 43CONFIG_KALLSYMS=y
42# CONFIG_KALLSYMS_ALL is not set 44# CONFIG_KALLSYMS_ALL is not set
@@ -97,6 +99,7 @@ CONFIG_FLATMEM_MANUAL=y
97# CONFIG_SPARSEMEM_MANUAL is not set 99# CONFIG_SPARSEMEM_MANUAL is not set
98CONFIG_FLATMEM=y 100CONFIG_FLATMEM=y
99CONFIG_FLAT_NODE_MEM_MAP=y 101CONFIG_FLAT_NODE_MEM_MAP=y
102# CONFIG_SPARSEMEM_STATIC is not set
100# CONFIG_NUMA is not set 103# CONFIG_NUMA is not set
101# CONFIG_SCHED_SMT is not set 104# CONFIG_SCHED_SMT is not set
102CONFIG_PREEMPT_NONE=y 105CONFIG_PREEMPT_NONE=y
@@ -109,19 +112,20 @@ CONFIG_HZ_250=y
109CONFIG_HZ=250 112CONFIG_HZ=250
110CONFIG_GENERIC_HARDIRQS=y 113CONFIG_GENERIC_HARDIRQS=y
111CONFIG_SECCOMP=y 114CONFIG_SECCOMP=y
115CONFIG_BINFMT_ELF=y
116# CONFIG_BINFMT_MISC is not set
117# CONFIG_HOTPLUG_CPU is not set
118CONFIG_PROC_DEVICETREE=y
119# CONFIG_CMDLINE_BOOL is not set
112CONFIG_ISA_DMA_API=y 120CONFIG_ISA_DMA_API=y
113 121
114# 122#
115# General setup 123# Bus Options
116# 124#
117CONFIG_PCI=y 125CONFIG_PCI=y
118CONFIG_PCI_DOMAINS=y 126CONFIG_PCI_DOMAINS=y
119CONFIG_BINFMT_ELF=y
120# CONFIG_BINFMT_MISC is not set
121CONFIG_PCI_LEGACY_PROC=y 127CONFIG_PCI_LEGACY_PROC=y
122CONFIG_PCI_NAMES=y
123# CONFIG_PCI_DEBUG is not set 128# CONFIG_PCI_DEBUG is not set
124# CONFIG_HOTPLUG_CPU is not set
125 129
126# 130#
127# PCCARD (PCMCIA/CardBus) support 131# PCCARD (PCMCIA/CardBus) support
@@ -132,8 +136,6 @@ CONFIG_PCI_NAMES=y
132# PCI Hotplug Support 136# PCI Hotplug Support
133# 137#
134# CONFIG_HOTPLUG_PCI is not set 138# CONFIG_HOTPLUG_PCI is not set
135CONFIG_PROC_DEVICETREE=y
136# CONFIG_CMDLINE_BOOL is not set
137 139
138# 140#
139# Networking 141# Networking
@@ -163,8 +165,8 @@ CONFIG_INET_AH=m
163CONFIG_INET_ESP=m 165CONFIG_INET_ESP=m
164CONFIG_INET_IPCOMP=m 166CONFIG_INET_IPCOMP=m
165CONFIG_INET_TUNNEL=y 167CONFIG_INET_TUNNEL=y
166CONFIG_IP_TCPDIAG=m 168CONFIG_INET_DIAG=y
167# CONFIG_IP_TCPDIAG_IPV6 is not set 169CONFIG_INET_TCP_DIAG=y
168# CONFIG_TCP_CONG_ADVANCED is not set 170# CONFIG_TCP_CONG_ADVANCED is not set
169CONFIG_TCP_CONG_BIC=y 171CONFIG_TCP_CONG_BIC=y
170 172
@@ -175,6 +177,7 @@ CONFIG_TCP_CONG_BIC=y
175# CONFIG_IPV6 is not set 177# CONFIG_IPV6 is not set
176CONFIG_NETFILTER=y 178CONFIG_NETFILTER=y
177# CONFIG_NETFILTER_DEBUG is not set 179# CONFIG_NETFILTER_DEBUG is not set
180# CONFIG_NETFILTER_NETLINK is not set
178 181
179# 182#
180# IP: Netfilter Configuration 183# IP: Netfilter Configuration
@@ -182,11 +185,14 @@ CONFIG_NETFILTER=y
182CONFIG_IP_NF_CONNTRACK=m 185CONFIG_IP_NF_CONNTRACK=m
183CONFIG_IP_NF_CT_ACCT=y 186CONFIG_IP_NF_CT_ACCT=y
184CONFIG_IP_NF_CONNTRACK_MARK=y 187CONFIG_IP_NF_CONNTRACK_MARK=y
188CONFIG_IP_NF_CONNTRACK_EVENTS=y
185CONFIG_IP_NF_CT_PROTO_SCTP=m 189CONFIG_IP_NF_CT_PROTO_SCTP=m
186CONFIG_IP_NF_FTP=m 190CONFIG_IP_NF_FTP=m
187CONFIG_IP_NF_IRC=m 191CONFIG_IP_NF_IRC=m
192# CONFIG_IP_NF_NETBIOS_NS is not set
188CONFIG_IP_NF_TFTP=m 193CONFIG_IP_NF_TFTP=m
189CONFIG_IP_NF_AMANDA=m 194CONFIG_IP_NF_AMANDA=m
195# CONFIG_IP_NF_PPTP is not set
190CONFIG_IP_NF_QUEUE=m 196CONFIG_IP_NF_QUEUE=m
191CONFIG_IP_NF_IPTABLES=m 197CONFIG_IP_NF_IPTABLES=m
192CONFIG_IP_NF_MATCH_LIMIT=m 198CONFIG_IP_NF_MATCH_LIMIT=m
@@ -210,14 +216,18 @@ CONFIG_IP_NF_MATCH_OWNER=m
210CONFIG_IP_NF_MATCH_ADDRTYPE=m 216CONFIG_IP_NF_MATCH_ADDRTYPE=m
211CONFIG_IP_NF_MATCH_REALM=m 217CONFIG_IP_NF_MATCH_REALM=m
212CONFIG_IP_NF_MATCH_SCTP=m 218CONFIG_IP_NF_MATCH_SCTP=m
219# CONFIG_IP_NF_MATCH_DCCP is not set
213CONFIG_IP_NF_MATCH_COMMENT=m 220CONFIG_IP_NF_MATCH_COMMENT=m
214CONFIG_IP_NF_MATCH_CONNMARK=m 221CONFIG_IP_NF_MATCH_CONNMARK=m
222CONFIG_IP_NF_MATCH_CONNBYTES=m
215CONFIG_IP_NF_MATCH_HASHLIMIT=m 223CONFIG_IP_NF_MATCH_HASHLIMIT=m
224CONFIG_IP_NF_MATCH_STRING=m
216CONFIG_IP_NF_FILTER=m 225CONFIG_IP_NF_FILTER=m
217CONFIG_IP_NF_TARGET_REJECT=m 226CONFIG_IP_NF_TARGET_REJECT=m
218CONFIG_IP_NF_TARGET_LOG=m 227CONFIG_IP_NF_TARGET_LOG=m
219CONFIG_IP_NF_TARGET_ULOG=m 228CONFIG_IP_NF_TARGET_ULOG=m
220CONFIG_IP_NF_TARGET_TCPMSS=m 229CONFIG_IP_NF_TARGET_TCPMSS=m
230CONFIG_IP_NF_TARGET_NFQUEUE=m
221CONFIG_IP_NF_NAT=m 231CONFIG_IP_NF_NAT=m
222CONFIG_IP_NF_NAT_NEEDED=y 232CONFIG_IP_NF_NAT_NEEDED=y
223CONFIG_IP_NF_TARGET_MASQUERADE=m 233CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -235,6 +245,7 @@ CONFIG_IP_NF_TARGET_ECN=m
235CONFIG_IP_NF_TARGET_DSCP=m 245CONFIG_IP_NF_TARGET_DSCP=m
236CONFIG_IP_NF_TARGET_MARK=m 246CONFIG_IP_NF_TARGET_MARK=m
237CONFIG_IP_NF_TARGET_CLASSIFY=m 247CONFIG_IP_NF_TARGET_CLASSIFY=m
248CONFIG_IP_NF_TARGET_TTL=m
238CONFIG_IP_NF_TARGET_CONNMARK=m 249CONFIG_IP_NF_TARGET_CONNMARK=m
239CONFIG_IP_NF_TARGET_CLUSTERIP=m 250CONFIG_IP_NF_TARGET_CLUSTERIP=m
240CONFIG_IP_NF_RAW=m 251CONFIG_IP_NF_RAW=m
@@ -244,6 +255,11 @@ CONFIG_IP_NF_ARPFILTER=m
244CONFIG_IP_NF_ARP_MANGLE=m 255CONFIG_IP_NF_ARP_MANGLE=m
245 256
246# 257#
258# DCCP Configuration (EXPERIMENTAL)
259#
260# CONFIG_IP_DCCP is not set
261
262#
247# SCTP Configuration (EXPERIMENTAL) 263# SCTP Configuration (EXPERIMENTAL)
248# 264#
249# CONFIG_IP_SCTP is not set 265# CONFIG_IP_SCTP is not set
@@ -270,6 +286,7 @@ CONFIG_NET_CLS_ROUTE=y
270# CONFIG_HAMRADIO is not set 286# CONFIG_HAMRADIO is not set
271# CONFIG_IRDA is not set 287# CONFIG_IRDA is not set
272# CONFIG_BT is not set 288# CONFIG_BT is not set
289# CONFIG_IEEE80211 is not set
273 290
274# 291#
275# Device Drivers 292# Device Drivers
@@ -284,6 +301,11 @@ CONFIG_FW_LOADER=y
284# CONFIG_DEBUG_DRIVER is not set 301# CONFIG_DEBUG_DRIVER is not set
285 302
286# 303#
304# Connector - unified userspace <-> kernelspace linker
305#
306# CONFIG_CONNECTOR is not set
307
308#
287# Memory Technology Devices (MTD) 309# Memory Technology Devices (MTD)
288# 310#
289# CONFIG_MTD is not set 311# CONFIG_MTD is not set
@@ -315,7 +337,6 @@ CONFIG_BLK_DEV_RAM=y
315CONFIG_BLK_DEV_RAM_COUNT=16 337CONFIG_BLK_DEV_RAM_COUNT=16
316CONFIG_BLK_DEV_RAM_SIZE=65536 338CONFIG_BLK_DEV_RAM_SIZE=65536
317CONFIG_BLK_DEV_INITRD=y 339CONFIG_BLK_DEV_INITRD=y
318CONFIG_INITRAMFS_SOURCE=""
319CONFIG_CDROM_PKTCDVD=m 340CONFIG_CDROM_PKTCDVD=m
320CONFIG_CDROM_PKTCDVD_BUFFERS=8 341CONFIG_CDROM_PKTCDVD_BUFFERS=8
321# CONFIG_CDROM_PKTCDVD_WCACHE is not set 342# CONFIG_CDROM_PKTCDVD_WCACHE is not set
@@ -395,6 +416,7 @@ CONFIG_IDEDMA_AUTO=y
395# 416#
396# SCSI device support 417# SCSI device support
397# 418#
419# CONFIG_RAID_ATTRS is not set
398CONFIG_SCSI=y 420CONFIG_SCSI=y
399CONFIG_SCSI_PROC_FS=y 421CONFIG_SCSI_PROC_FS=y
400 422
@@ -422,6 +444,7 @@ CONFIG_SCSI_CONSTANTS=y
422CONFIG_SCSI_SPI_ATTRS=y 444CONFIG_SCSI_SPI_ATTRS=y
423# CONFIG_SCSI_FC_ATTRS is not set 445# CONFIG_SCSI_FC_ATTRS is not set
424# CONFIG_SCSI_ISCSI_ATTRS is not set 446# CONFIG_SCSI_ISCSI_ATTRS is not set
447# CONFIG_SCSI_SAS_ATTRS is not set
425 448
426# 449#
427# SCSI low-level drivers 450# SCSI low-level drivers
@@ -435,10 +458,12 @@ CONFIG_SCSI_SPI_ATTRS=y
435# CONFIG_SCSI_AIC79XX is not set 458# CONFIG_SCSI_AIC79XX is not set
436# CONFIG_MEGARAID_NEWGEN is not set 459# CONFIG_MEGARAID_NEWGEN is not set
437# CONFIG_MEGARAID_LEGACY is not set 460# CONFIG_MEGARAID_LEGACY is not set
461# CONFIG_MEGARAID_SAS is not set
438CONFIG_SCSI_SATA=y 462CONFIG_SCSI_SATA=y
439# CONFIG_SCSI_SATA_AHCI is not set 463# CONFIG_SCSI_SATA_AHCI is not set
440CONFIG_SCSI_SATA_SVW=y 464CONFIG_SCSI_SATA_SVW=y
441# CONFIG_SCSI_ATA_PIIX is not set 465# CONFIG_SCSI_ATA_PIIX is not set
466# CONFIG_SCSI_SATA_MV is not set
442# CONFIG_SCSI_SATA_NV is not set 467# CONFIG_SCSI_SATA_NV is not set
443# CONFIG_SCSI_SATA_PROMISE is not set 468# CONFIG_SCSI_SATA_PROMISE is not set
444# CONFIG_SCSI_SATA_QSTOR is not set 469# CONFIG_SCSI_SATA_QSTOR is not set
@@ -498,6 +523,7 @@ CONFIG_DM_ZERO=m
498# CONFIG_FUSION is not set 523# CONFIG_FUSION is not set
499# CONFIG_FUSION_SPI is not set 524# CONFIG_FUSION_SPI is not set
500# CONFIG_FUSION_FC is not set 525# CONFIG_FUSION_FC is not set
526# CONFIG_FUSION_SAS is not set
501 527
502# 528#
503# IEEE 1394 (FireWire) support 529# IEEE 1394 (FireWire) support
@@ -540,7 +566,6 @@ CONFIG_IEEE1394_RAWIO=y
540# 566#
541CONFIG_ADB_PMU=y 567CONFIG_ADB_PMU=y
542CONFIG_PMAC_SMU=y 568CONFIG_PMAC_SMU=y
543# CONFIG_PMAC_BACKLIGHT is not set
544CONFIG_THERM_PM72=y 569CONFIG_THERM_PM72=y
545 570
546# 571#
@@ -558,12 +583,18 @@ CONFIG_TUN=m
558# CONFIG_ARCNET is not set 583# CONFIG_ARCNET is not set
559 584
560# 585#
586# PHY device support
587#
588# CONFIG_PHYLIB is not set
589
590#
561# Ethernet (10 or 100Mbit) 591# Ethernet (10 or 100Mbit)
562# 592#
563CONFIG_NET_ETHERNET=y 593CONFIG_NET_ETHERNET=y
564CONFIG_MII=y 594CONFIG_MII=y
565# CONFIG_HAPPYMEAL is not set 595# CONFIG_HAPPYMEAL is not set
566CONFIG_SUNGEM=y 596CONFIG_SUNGEM=y
597# CONFIG_CASSINI is not set
567# CONFIG_NET_VENDOR_3COM is not set 598# CONFIG_NET_VENDOR_3COM is not set
568 599
569# 600#
@@ -585,6 +616,7 @@ CONFIG_E1000=y
585# CONFIG_HAMACHI is not set 616# CONFIG_HAMACHI is not set
586# CONFIG_YELLOWFIN is not set 617# CONFIG_YELLOWFIN is not set
587# CONFIG_R8169 is not set 618# CONFIG_R8169 is not set
619# CONFIG_SIS190 is not set
588# CONFIG_SKGE is not set 620# CONFIG_SKGE is not set
589# CONFIG_SK98LIN is not set 621# CONFIG_SK98LIN is not set
590CONFIG_TIGON3=m 622CONFIG_TIGON3=m
@@ -594,6 +626,7 @@ CONFIG_TIGON3=m
594# 626#
595# Ethernet (10000 Mbit) 627# Ethernet (10000 Mbit)
596# 628#
629# CONFIG_CHELSIO_T1 is not set
597# CONFIG_IXGB is not set 630# CONFIG_IXGB is not set
598# CONFIG_S2IO is not set 631# CONFIG_S2IO is not set
599 632
@@ -760,8 +793,8 @@ CONFIG_I2C_ALGOBIT=y
760# CONFIG_I2C_I801 is not set 793# CONFIG_I2C_I801 is not set
761# CONFIG_I2C_I810 is not set 794# CONFIG_I2C_I810 is not set
762# CONFIG_I2C_PIIX4 is not set 795# CONFIG_I2C_PIIX4 is not set
763# CONFIG_I2C_ISA is not set
764CONFIG_I2C_KEYWEST=y 796CONFIG_I2C_KEYWEST=y
797CONFIG_I2C_PMAC_SMU=y
765# CONFIG_I2C_NFORCE2 is not set 798# CONFIG_I2C_NFORCE2 is not set
766# CONFIG_I2C_PARPORT_LIGHT is not set 799# CONFIG_I2C_PARPORT_LIGHT is not set
767# CONFIG_I2C_PROSAVAGE is not set 800# CONFIG_I2C_PROSAVAGE is not set
@@ -775,7 +808,6 @@ CONFIG_I2C_KEYWEST=y
775# CONFIG_I2C_VIAPRO is not set 808# CONFIG_I2C_VIAPRO is not set
776# CONFIG_I2C_VOODOO3 is not set 809# CONFIG_I2C_VOODOO3 is not set
777# CONFIG_I2C_PCA_ISA is not set 810# CONFIG_I2C_PCA_ISA is not set
778# CONFIG_I2C_SENSOR is not set
779 811
780# 812#
781# Miscellaneous I2C Chip support 813# Miscellaneous I2C Chip support
@@ -802,12 +834,17 @@ CONFIG_I2C_KEYWEST=y
802# Hardware Monitoring support 834# Hardware Monitoring support
803# 835#
804# CONFIG_HWMON is not set 836# CONFIG_HWMON is not set
837# CONFIG_HWMON_VID is not set
805 838
806# 839#
807# Misc devices 840# Misc devices
808# 841#
809 842
810# 843#
844# Multimedia Capabilities Port drivers
845#
846
847#
811# Multimedia devices 848# Multimedia devices
812# 849#
813# CONFIG_VIDEO_DEV is not set 850# CONFIG_VIDEO_DEV is not set
@@ -856,6 +893,7 @@ CONFIG_FB_RADEON_I2C=y
856# CONFIG_FB_KYRO is not set 893# CONFIG_FB_KYRO is not set
857# CONFIG_FB_3DFX is not set 894# CONFIG_FB_3DFX is not set
858# CONFIG_FB_VOODOO1 is not set 895# CONFIG_FB_VOODOO1 is not set
896# CONFIG_FB_CYBLA is not set
859# CONFIG_FB_TRIDENT is not set 897# CONFIG_FB_TRIDENT is not set
860# CONFIG_FB_S1D13XXX is not set 898# CONFIG_FB_S1D13XXX is not set
861# CONFIG_FB_VIRTUAL is not set 899# CONFIG_FB_VIRTUAL is not set
@@ -937,6 +975,7 @@ CONFIG_USB_STORAGE_DPCM=y
937CONFIG_USB_STORAGE_SDDR09=y 975CONFIG_USB_STORAGE_SDDR09=y
938CONFIG_USB_STORAGE_SDDR55=y 976CONFIG_USB_STORAGE_SDDR55=y
939CONFIG_USB_STORAGE_JUMPSHOT=y 977CONFIG_USB_STORAGE_JUMPSHOT=y
978# CONFIG_USB_STORAGE_ONETOUCH is not set
940 979
941# 980#
942# USB Input Devices 981# USB Input Devices
@@ -956,9 +995,11 @@ CONFIG_USB_HIDDEV=y
956# CONFIG_USB_MTOUCH is not set 995# CONFIG_USB_MTOUCH is not set
957# CONFIG_USB_ITMTOUCH is not set 996# CONFIG_USB_ITMTOUCH is not set
958# CONFIG_USB_EGALAX is not set 997# CONFIG_USB_EGALAX is not set
998# CONFIG_USB_YEALINK is not set
959# CONFIG_USB_XPAD is not set 999# CONFIG_USB_XPAD is not set
960# CONFIG_USB_ATI_REMOTE is not set 1000# CONFIG_USB_ATI_REMOTE is not set
961# CONFIG_USB_KEYSPAN_REMOTE is not set 1001# CONFIG_USB_KEYSPAN_REMOTE is not set
1002# CONFIG_USB_APPLETOUCH is not set
962 1003
963# 1004#
964# USB Imaging devices 1005# USB Imaging devices
@@ -983,30 +1024,14 @@ CONFIG_USB_KAWETH=m
983CONFIG_USB_PEGASUS=m 1024CONFIG_USB_PEGASUS=m
984CONFIG_USB_RTL8150=m 1025CONFIG_USB_RTL8150=m
985CONFIG_USB_USBNET=m 1026CONFIG_USB_USBNET=m
986 1027# CONFIG_USB_NET_AX8817X is not set
987# 1028CONFIG_USB_NET_CDCETHER=m
988# USB Host-to-Host Cables 1029# CONFIG_USB_NET_GL620A is not set
989# 1030# CONFIG_USB_NET_NET1080 is not set
990CONFIG_USB_ALI_M5632=y 1031# CONFIG_USB_NET_PLUSB is not set
991CONFIG_USB_AN2720=y 1032# CONFIG_USB_NET_RNDIS_HOST is not set
992CONFIG_USB_BELKIN=y 1033# CONFIG_USB_NET_CDC_SUBSET is not set
993CONFIG_USB_GENESYS=y 1034# CONFIG_USB_NET_ZAURUS is not set
994CONFIG_USB_NET1080=y
995CONFIG_USB_PL2301=y
996CONFIG_USB_KC2190=y
997
998#
999# Intelligent USB Devices/Gadgets
1000#
1001CONFIG_USB_ARMLINUX=y
1002CONFIG_USB_EPSON2888=y
1003CONFIG_USB_ZAURUS=y
1004CONFIG_USB_CDCETHER=y
1005
1006#
1007# USB Network Adapters
1008#
1009CONFIG_USB_AX8817X=y
1010CONFIG_USB_MON=y 1035CONFIG_USB_MON=y
1011 1036
1012# 1037#
@@ -1124,16 +1149,12 @@ CONFIG_REISERFS_FS_POSIX_ACL=y
1124CONFIG_REISERFS_FS_SECURITY=y 1149CONFIG_REISERFS_FS_SECURITY=y
1125# CONFIG_JFS_FS is not set 1150# CONFIG_JFS_FS is not set
1126CONFIG_FS_POSIX_ACL=y 1151CONFIG_FS_POSIX_ACL=y
1127
1128#
1129# XFS support
1130#
1131CONFIG_XFS_FS=m 1152CONFIG_XFS_FS=m
1132CONFIG_XFS_EXPORT=y 1153CONFIG_XFS_EXPORT=y
1133# CONFIG_XFS_RT is not set
1134# CONFIG_XFS_QUOTA is not set 1154# CONFIG_XFS_QUOTA is not set
1135CONFIG_XFS_SECURITY=y 1155CONFIG_XFS_SECURITY=y
1136CONFIG_XFS_POSIX_ACL=y 1156CONFIG_XFS_POSIX_ACL=y
1157# CONFIG_XFS_RT is not set
1137# CONFIG_MINIX_FS is not set 1158# CONFIG_MINIX_FS is not set
1138# CONFIG_ROMFS_FS is not set 1159# CONFIG_ROMFS_FS is not set
1139CONFIG_INOTIFY=y 1160CONFIG_INOTIFY=y
@@ -1141,6 +1162,7 @@ CONFIG_INOTIFY=y
1141CONFIG_DNOTIFY=y 1162CONFIG_DNOTIFY=y
1142CONFIG_AUTOFS_FS=m 1163CONFIG_AUTOFS_FS=m
1143# CONFIG_AUTOFS4_FS is not set 1164# CONFIG_AUTOFS4_FS is not set
1165# CONFIG_FUSE_FS is not set
1144 1166
1145# 1167#
1146# CD-ROM/DVD Filesystems 1168# CD-ROM/DVD Filesystems
@@ -1168,14 +1190,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1168CONFIG_PROC_FS=y 1190CONFIG_PROC_FS=y
1169CONFIG_PROC_KCORE=y 1191CONFIG_PROC_KCORE=y
1170CONFIG_SYSFS=y 1192CONFIG_SYSFS=y
1171CONFIG_DEVPTS_FS_XATTR=y
1172# CONFIG_DEVPTS_FS_SECURITY is not set
1173CONFIG_TMPFS=y 1193CONFIG_TMPFS=y
1174CONFIG_TMPFS_XATTR=y
1175CONFIG_TMPFS_SECURITY=y
1176CONFIG_HUGETLBFS=y 1194CONFIG_HUGETLBFS=y
1177CONFIG_HUGETLB_PAGE=y 1195CONFIG_HUGETLB_PAGE=y
1178CONFIG_RAMFS=y 1196CONFIG_RAMFS=y
1197# CONFIG_RELAYFS_FS is not set
1179 1198
1180# 1199#
1181# Miscellaneous filesystems 1200# Miscellaneous filesystems
@@ -1225,6 +1244,7 @@ CONFIG_CIFS=m
1225# CONFIG_NCP_FS is not set 1244# CONFIG_NCP_FS is not set
1226# CONFIG_CODA_FS is not set 1245# CONFIG_CODA_FS is not set
1227# CONFIG_AFS_FS is not set 1246# CONFIG_AFS_FS is not set
1247# CONFIG_9P_FS is not set
1228 1248
1229# 1249#
1230# Partition Types 1250# Partition Types
@@ -1303,6 +1323,7 @@ CONFIG_OPROFILE=y
1303CONFIG_DEBUG_KERNEL=y 1323CONFIG_DEBUG_KERNEL=y
1304CONFIG_MAGIC_SYSRQ=y 1324CONFIG_MAGIC_SYSRQ=y
1305CONFIG_LOG_BUF_SHIFT=17 1325CONFIG_LOG_BUF_SHIFT=17
1326CONFIG_DETECT_SOFTLOCKUP=y
1306# CONFIG_SCHEDSTATS is not set 1327# CONFIG_SCHEDSTATS is not set
1307# CONFIG_DEBUG_SLAB is not set 1328# CONFIG_DEBUG_SLAB is not set
1308# CONFIG_DEBUG_SPINLOCK is not set 1329# CONFIG_DEBUG_SPINLOCK is not set
@@ -1360,7 +1381,12 @@ CONFIG_CRYPTO_TEST=m
1360# Library routines 1381# Library routines
1361# 1382#
1362CONFIG_CRC_CCITT=m 1383CONFIG_CRC_CCITT=m
1384# CONFIG_CRC16 is not set
1363CONFIG_CRC32=y 1385CONFIG_CRC32=y
1364CONFIG_LIBCRC32C=m 1386CONFIG_LIBCRC32C=m
1365CONFIG_ZLIB_INFLATE=y 1387CONFIG_ZLIB_INFLATE=y
1366CONFIG_ZLIB_DEFLATE=m 1388CONFIG_ZLIB_DEFLATE=m
1389CONFIG_TEXTSEARCH=y
1390CONFIG_TEXTSEARCH_KMP=m
1391CONFIG_TEXTSEARCH_BM=m
1392CONFIG_TEXTSEARCH_FSM=m
diff --git a/arch/ppc64/configs/iSeries_defconfig b/arch/ppc64/configs/iSeries_defconfig
index 013d4e0e4003..62e92c7e9e27 100644
--- a/arch/ppc64/configs/iSeries_defconfig
+++ b/arch/ppc64/configs/iSeries_defconfig
@@ -1,17 +1,17 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6 3# Linux kernel version: 2.6.14-rc4
4# Mon Aug 8 14:17:02 2005 4# Thu Oct 20 08:30:56 2005
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_GENERIC_ISA_DMA=y 10CONFIG_GENERIC_ISA_DMA=y
11CONFIG_HAVE_DEC_LOCK=y
12CONFIG_EARLY_PRINTK=y 11CONFIG_EARLY_PRINTK=y
13CONFIG_COMPAT=y 12CONFIG_COMPAT=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15CONFIG_FORCE_MAX_ZONEORDER=13 15CONFIG_FORCE_MAX_ZONEORDER=13
16 16
17# 17#
@@ -26,6 +26,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 26# General setup
27# 27#
28CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 30CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
31CONFIG_POSIX_MQUEUE=y 32CONFIG_POSIX_MQUEUE=y
@@ -38,6 +39,7 @@ CONFIG_KOBJECT_UEVENT=y
38CONFIG_IKCONFIG=y 39CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y 40CONFIG_IKCONFIG_PROC=y
40# CONFIG_CPUSETS is not set 41# CONFIG_CPUSETS is not set
42CONFIG_INITRAMFS_SOURCE=""
41# CONFIG_EMBEDDED is not set 43# CONFIG_EMBEDDED is not set
42CONFIG_KALLSYMS=y 44CONFIG_KALLSYMS=y
43# CONFIG_KALLSYMS_ALL is not set 45# CONFIG_KALLSYMS_ALL is not set
@@ -88,6 +90,7 @@ CONFIG_FLATMEM_MANUAL=y
88# CONFIG_SPARSEMEM_MANUAL is not set 90# CONFIG_SPARSEMEM_MANUAL is not set
89CONFIG_FLATMEM=y 91CONFIG_FLATMEM=y
90CONFIG_FLAT_NODE_MEM_MAP=y 92CONFIG_FLAT_NODE_MEM_MAP=y
93# CONFIG_SPARSEMEM_STATIC is not set
91# CONFIG_NUMA is not set 94# CONFIG_NUMA is not set
92# CONFIG_SCHED_SMT is not set 95# CONFIG_SCHED_SMT is not set
93CONFIG_PREEMPT_NONE=y 96CONFIG_PREEMPT_NONE=y
@@ -101,17 +104,16 @@ CONFIG_HZ=250
101CONFIG_GENERIC_HARDIRQS=y 104CONFIG_GENERIC_HARDIRQS=y
102CONFIG_LPARCFG=y 105CONFIG_LPARCFG=y
103CONFIG_SECCOMP=y 106CONFIG_SECCOMP=y
107CONFIG_BINFMT_ELF=y
108# CONFIG_BINFMT_MISC is not set
104CONFIG_ISA_DMA_API=y 109CONFIG_ISA_DMA_API=y
105 110
106# 111#
107# General setup 112# Bus Options
108# 113#
109CONFIG_PCI=y 114CONFIG_PCI=y
110CONFIG_PCI_DOMAINS=y 115CONFIG_PCI_DOMAINS=y
111CONFIG_BINFMT_ELF=y
112# CONFIG_BINFMT_MISC is not set
113CONFIG_PCI_LEGACY_PROC=y 116CONFIG_PCI_LEGACY_PROC=y
114CONFIG_PCI_NAMES=y
115# CONFIG_PCI_DEBUG is not set 117# CONFIG_PCI_DEBUG is not set
116 118
117# 119#
@@ -152,8 +154,8 @@ CONFIG_INET_AH=m
152CONFIG_INET_ESP=m 154CONFIG_INET_ESP=m
153CONFIG_INET_IPCOMP=m 155CONFIG_INET_IPCOMP=m
154CONFIG_INET_TUNNEL=y 156CONFIG_INET_TUNNEL=y
155CONFIG_IP_TCPDIAG=m 157CONFIG_INET_DIAG=y
156# CONFIG_IP_TCPDIAG_IPV6 is not set 158CONFIG_INET_TCP_DIAG=y
157# CONFIG_TCP_CONG_ADVANCED is not set 159# CONFIG_TCP_CONG_ADVANCED is not set
158CONFIG_TCP_CONG_BIC=y 160CONFIG_TCP_CONG_BIC=y
159 161
@@ -164,6 +166,7 @@ CONFIG_TCP_CONG_BIC=y
164# CONFIG_IPV6 is not set 166# CONFIG_IPV6 is not set
165CONFIG_NETFILTER=y 167CONFIG_NETFILTER=y
166# CONFIG_NETFILTER_DEBUG is not set 168# CONFIG_NETFILTER_DEBUG is not set
169# CONFIG_NETFILTER_NETLINK is not set
167 170
168# 171#
169# IP: Netfilter Configuration 172# IP: Netfilter Configuration
@@ -171,11 +174,14 @@ CONFIG_NETFILTER=y
171CONFIG_IP_NF_CONNTRACK=m 174CONFIG_IP_NF_CONNTRACK=m
172CONFIG_IP_NF_CT_ACCT=y 175CONFIG_IP_NF_CT_ACCT=y
173CONFIG_IP_NF_CONNTRACK_MARK=y 176CONFIG_IP_NF_CONNTRACK_MARK=y
177CONFIG_IP_NF_CONNTRACK_EVENTS=y
174CONFIG_IP_NF_CT_PROTO_SCTP=m 178CONFIG_IP_NF_CT_PROTO_SCTP=m
175CONFIG_IP_NF_FTP=m 179CONFIG_IP_NF_FTP=m
176CONFIG_IP_NF_IRC=m 180CONFIG_IP_NF_IRC=m
181# CONFIG_IP_NF_NETBIOS_NS is not set
177CONFIG_IP_NF_TFTP=m 182CONFIG_IP_NF_TFTP=m
178CONFIG_IP_NF_AMANDA=m 183CONFIG_IP_NF_AMANDA=m
184# CONFIG_IP_NF_PPTP is not set
179CONFIG_IP_NF_QUEUE=m 185CONFIG_IP_NF_QUEUE=m
180CONFIG_IP_NF_IPTABLES=m 186CONFIG_IP_NF_IPTABLES=m
181CONFIG_IP_NF_MATCH_LIMIT=m 187CONFIG_IP_NF_MATCH_LIMIT=m
@@ -199,14 +205,18 @@ CONFIG_IP_NF_MATCH_OWNER=m
199CONFIG_IP_NF_MATCH_ADDRTYPE=m 205CONFIG_IP_NF_MATCH_ADDRTYPE=m
200CONFIG_IP_NF_MATCH_REALM=m 206CONFIG_IP_NF_MATCH_REALM=m
201CONFIG_IP_NF_MATCH_SCTP=m 207CONFIG_IP_NF_MATCH_SCTP=m
208# CONFIG_IP_NF_MATCH_DCCP is not set
202CONFIG_IP_NF_MATCH_COMMENT=m 209CONFIG_IP_NF_MATCH_COMMENT=m
203CONFIG_IP_NF_MATCH_CONNMARK=m 210CONFIG_IP_NF_MATCH_CONNMARK=m
211CONFIG_IP_NF_MATCH_CONNBYTES=m
204CONFIG_IP_NF_MATCH_HASHLIMIT=m 212CONFIG_IP_NF_MATCH_HASHLIMIT=m
213CONFIG_IP_NF_MATCH_STRING=m
205CONFIG_IP_NF_FILTER=m 214CONFIG_IP_NF_FILTER=m
206CONFIG_IP_NF_TARGET_REJECT=m 215CONFIG_IP_NF_TARGET_REJECT=m
207CONFIG_IP_NF_TARGET_LOG=m 216CONFIG_IP_NF_TARGET_LOG=m
208CONFIG_IP_NF_TARGET_ULOG=m 217CONFIG_IP_NF_TARGET_ULOG=m
209CONFIG_IP_NF_TARGET_TCPMSS=m 218CONFIG_IP_NF_TARGET_TCPMSS=m
219CONFIG_IP_NF_TARGET_NFQUEUE=m
210CONFIG_IP_NF_NAT=m 220CONFIG_IP_NF_NAT=m
211CONFIG_IP_NF_NAT_NEEDED=y 221CONFIG_IP_NF_NAT_NEEDED=y
212CONFIG_IP_NF_TARGET_MASQUERADE=m 222CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -224,6 +234,7 @@ CONFIG_IP_NF_TARGET_ECN=m
224CONFIG_IP_NF_TARGET_DSCP=m 234CONFIG_IP_NF_TARGET_DSCP=m
225CONFIG_IP_NF_TARGET_MARK=m 235CONFIG_IP_NF_TARGET_MARK=m
226CONFIG_IP_NF_TARGET_CLASSIFY=m 236CONFIG_IP_NF_TARGET_CLASSIFY=m
237CONFIG_IP_NF_TARGET_TTL=m
227CONFIG_IP_NF_TARGET_CONNMARK=m 238CONFIG_IP_NF_TARGET_CONNMARK=m
228CONFIG_IP_NF_TARGET_CLUSTERIP=m 239CONFIG_IP_NF_TARGET_CLUSTERIP=m
229CONFIG_IP_NF_RAW=m 240CONFIG_IP_NF_RAW=m
@@ -233,6 +244,11 @@ CONFIG_IP_NF_ARPFILTER=m
233CONFIG_IP_NF_ARP_MANGLE=m 244CONFIG_IP_NF_ARP_MANGLE=m
234 245
235# 246#
247# DCCP Configuration (EXPERIMENTAL)
248#
249# CONFIG_IP_DCCP is not set
250
251#
236# SCTP Configuration (EXPERIMENTAL) 252# SCTP Configuration (EXPERIMENTAL)
237# 253#
238# CONFIG_IP_SCTP is not set 254# CONFIG_IP_SCTP is not set
@@ -259,6 +275,7 @@ CONFIG_NET_CLS_ROUTE=y
259# CONFIG_HAMRADIO is not set 275# CONFIG_HAMRADIO is not set
260# CONFIG_IRDA is not set 276# CONFIG_IRDA is not set
261# CONFIG_BT is not set 277# CONFIG_BT is not set
278# CONFIG_IEEE80211 is not set
262 279
263# 280#
264# Device Drivers 281# Device Drivers
@@ -273,6 +290,11 @@ CONFIG_FW_LOADER=m
273# CONFIG_DEBUG_DRIVER is not set 290# CONFIG_DEBUG_DRIVER is not set
274 291
275# 292#
293# Connector - unified userspace <-> kernelspace linker
294#
295# CONFIG_CONNECTOR is not set
296
297#
276# Memory Technology Devices (MTD) 298# Memory Technology Devices (MTD)
277# 299#
278# CONFIG_MTD is not set 300# CONFIG_MTD is not set
@@ -303,7 +325,6 @@ CONFIG_BLK_DEV_RAM=y
303CONFIG_BLK_DEV_RAM_COUNT=16 325CONFIG_BLK_DEV_RAM_COUNT=16
304CONFIG_BLK_DEV_RAM_SIZE=65536 326CONFIG_BLK_DEV_RAM_SIZE=65536
305CONFIG_BLK_DEV_INITRD=y 327CONFIG_BLK_DEV_INITRD=y
306CONFIG_INITRAMFS_SOURCE=""
307# CONFIG_CDROM_PKTCDVD is not set 328# CONFIG_CDROM_PKTCDVD is not set
308 329
309# 330#
@@ -323,6 +344,7 @@ CONFIG_IOSCHED_CFQ=y
323# 344#
324# SCSI device support 345# SCSI device support
325# 346#
347# CONFIG_RAID_ATTRS is not set
326CONFIG_SCSI=y 348CONFIG_SCSI=y
327CONFIG_SCSI_PROC_FS=y 349CONFIG_SCSI_PROC_FS=y
328 350
@@ -350,6 +372,7 @@ CONFIG_SCSI_CONSTANTS=y
350CONFIG_SCSI_SPI_ATTRS=y 372CONFIG_SCSI_SPI_ATTRS=y
351CONFIG_SCSI_FC_ATTRS=y 373CONFIG_SCSI_FC_ATTRS=y
352# CONFIG_SCSI_ISCSI_ATTRS is not set 374# CONFIG_SCSI_ISCSI_ATTRS is not set
375# CONFIG_SCSI_SAS_ATTRS is not set
353 376
354# 377#
355# SCSI low-level drivers 378# SCSI low-level drivers
@@ -363,6 +386,7 @@ CONFIG_SCSI_FC_ATTRS=y
363# CONFIG_SCSI_AIC79XX is not set 386# CONFIG_SCSI_AIC79XX is not set
364# CONFIG_MEGARAID_NEWGEN is not set 387# CONFIG_MEGARAID_NEWGEN is not set
365# CONFIG_MEGARAID_LEGACY is not set 388# CONFIG_MEGARAID_LEGACY is not set
389# CONFIG_MEGARAID_SAS is not set
366# CONFIG_SCSI_SATA is not set 390# CONFIG_SCSI_SATA is not set
367# CONFIG_SCSI_BUSLOGIC is not set 391# CONFIG_SCSI_BUSLOGIC is not set
368# CONFIG_SCSI_DMX3191D is not set 392# CONFIG_SCSI_DMX3191D is not set
@@ -415,6 +439,7 @@ CONFIG_DM_ZERO=m
415# CONFIG_FUSION is not set 439# CONFIG_FUSION is not set
416# CONFIG_FUSION_SPI is not set 440# CONFIG_FUSION_SPI is not set
417# CONFIG_FUSION_FC is not set 441# CONFIG_FUSION_FC is not set
442# CONFIG_FUSION_SAS is not set
418 443
419# 444#
420# IEEE 1394 (FireWire) support 445# IEEE 1394 (FireWire) support
@@ -445,12 +470,18 @@ CONFIG_TUN=m
445# CONFIG_ARCNET is not set 470# CONFIG_ARCNET is not set
446 471
447# 472#
473# PHY device support
474#
475# CONFIG_PHYLIB is not set
476
477#
448# Ethernet (10 or 100Mbit) 478# Ethernet (10 or 100Mbit)
449# 479#
450CONFIG_NET_ETHERNET=y 480CONFIG_NET_ETHERNET=y
451CONFIG_MII=y 481CONFIG_MII=y
452# CONFIG_HAPPYMEAL is not set 482# CONFIG_HAPPYMEAL is not set
453# CONFIG_SUNGEM is not set 483# CONFIG_SUNGEM is not set
484# CONFIG_CASSINI is not set
454# CONFIG_NET_VENDOR_3COM is not set 485# CONFIG_NET_VENDOR_3COM is not set
455 486
456# 487#
@@ -489,6 +520,7 @@ CONFIG_E1000=m
489# CONFIG_HAMACHI is not set 520# CONFIG_HAMACHI is not set
490# CONFIG_YELLOWFIN is not set 521# CONFIG_YELLOWFIN is not set
491# CONFIG_R8169 is not set 522# CONFIG_R8169 is not set
523# CONFIG_SIS190 is not set
492# CONFIG_SKGE is not set 524# CONFIG_SKGE is not set
493# CONFIG_SK98LIN is not set 525# CONFIG_SK98LIN is not set
494# CONFIG_VIA_VELOCITY is not set 526# CONFIG_VIA_VELOCITY is not set
@@ -498,6 +530,7 @@ CONFIG_E1000=m
498# 530#
499# Ethernet (10000 Mbit) 531# Ethernet (10000 Mbit)
500# 532#
533# CONFIG_CHELSIO_T1 is not set
501# CONFIG_IXGB is not set 534# CONFIG_IXGB is not set
502# CONFIG_S2IO is not set 535# CONFIG_S2IO is not set
503 536
@@ -632,7 +665,6 @@ CONFIG_MAX_RAW_DEVS=256
632# I2C support 665# I2C support
633# 666#
634# CONFIG_I2C is not set 667# CONFIG_I2C is not set
635# CONFIG_I2C_SENSOR is not set
636 668
637# 669#
638# Dallas's 1-wire bus 670# Dallas's 1-wire bus
@@ -643,12 +675,17 @@ CONFIG_MAX_RAW_DEVS=256
643# Hardware Monitoring support 675# Hardware Monitoring support
644# 676#
645# CONFIG_HWMON is not set 677# CONFIG_HWMON is not set
678# CONFIG_HWMON_VID is not set
646 679
647# 680#
648# Misc devices 681# Misc devices
649# 682#
650 683
651# 684#
685# Multimedia Capabilities Port drivers
686#
687
688#
652# Multimedia devices 689# Multimedia devices
653# 690#
654# CONFIG_VIDEO_DEV is not set 691# CONFIG_VIDEO_DEV is not set
@@ -722,16 +759,12 @@ CONFIG_JFS_SECURITY=y
722# CONFIG_JFS_DEBUG is not set 759# CONFIG_JFS_DEBUG is not set
723# CONFIG_JFS_STATISTICS is not set 760# CONFIG_JFS_STATISTICS is not set
724CONFIG_FS_POSIX_ACL=y 761CONFIG_FS_POSIX_ACL=y
725
726#
727# XFS support
728#
729CONFIG_XFS_FS=m 762CONFIG_XFS_FS=m
730CONFIG_XFS_EXPORT=y 763CONFIG_XFS_EXPORT=y
731# CONFIG_XFS_RT is not set
732# CONFIG_XFS_QUOTA is not set 764# CONFIG_XFS_QUOTA is not set
733CONFIG_XFS_SECURITY=y 765CONFIG_XFS_SECURITY=y
734CONFIG_XFS_POSIX_ACL=y 766CONFIG_XFS_POSIX_ACL=y
767# CONFIG_XFS_RT is not set
735# CONFIG_MINIX_FS is not set 768# CONFIG_MINIX_FS is not set
736# CONFIG_ROMFS_FS is not set 769# CONFIG_ROMFS_FS is not set
737CONFIG_INOTIFY=y 770CONFIG_INOTIFY=y
@@ -739,6 +772,7 @@ CONFIG_INOTIFY=y
739CONFIG_DNOTIFY=y 772CONFIG_DNOTIFY=y
740CONFIG_AUTOFS_FS=m 773CONFIG_AUTOFS_FS=m
741# CONFIG_AUTOFS4_FS is not set 774# CONFIG_AUTOFS4_FS is not set
775# CONFIG_FUSE_FS is not set
742 776
743# 777#
744# CD-ROM/DVD Filesystems 778# CD-ROM/DVD Filesystems
@@ -766,14 +800,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
766CONFIG_PROC_FS=y 800CONFIG_PROC_FS=y
767CONFIG_PROC_KCORE=y 801CONFIG_PROC_KCORE=y
768CONFIG_SYSFS=y 802CONFIG_SYSFS=y
769CONFIG_DEVPTS_FS_XATTR=y
770CONFIG_DEVPTS_FS_SECURITY=y
771CONFIG_TMPFS=y 803CONFIG_TMPFS=y
772CONFIG_TMPFS_XATTR=y
773CONFIG_TMPFS_SECURITY=y
774# CONFIG_HUGETLBFS is not set 804# CONFIG_HUGETLBFS is not set
775# CONFIG_HUGETLB_PAGE is not set 805# CONFIG_HUGETLB_PAGE is not set
776CONFIG_RAMFS=y 806CONFIG_RAMFS=y
807# CONFIG_RELAYFS_FS is not set
777 808
778# 809#
779# Miscellaneous filesystems 810# Miscellaneous filesystems
@@ -824,6 +855,7 @@ CONFIG_CIFS_POSIX=y
824# CONFIG_NCP_FS is not set 855# CONFIG_NCP_FS is not set
825# CONFIG_CODA_FS is not set 856# CONFIG_CODA_FS is not set
826# CONFIG_AFS_FS is not set 857# CONFIG_AFS_FS is not set
858# CONFIG_9P_FS is not set
827 859
828# 860#
829# Partition Types 861# Partition Types
@@ -897,6 +929,7 @@ CONFIG_OPROFILE=y
897CONFIG_DEBUG_KERNEL=y 929CONFIG_DEBUG_KERNEL=y
898CONFIG_MAGIC_SYSRQ=y 930CONFIG_MAGIC_SYSRQ=y
899CONFIG_LOG_BUF_SHIFT=17 931CONFIG_LOG_BUF_SHIFT=17
932CONFIG_DETECT_SOFTLOCKUP=y
900# CONFIG_SCHEDSTATS is not set 933# CONFIG_SCHEDSTATS is not set
901# CONFIG_DEBUG_SLAB is not set 934# CONFIG_DEBUG_SLAB is not set
902# CONFIG_DEBUG_SPINLOCK is not set 935# CONFIG_DEBUG_SPINLOCK is not set
@@ -954,7 +987,12 @@ CONFIG_CRYPTO_TEST=m
954# Library routines 987# Library routines
955# 988#
956CONFIG_CRC_CCITT=m 989CONFIG_CRC_CCITT=m
990# CONFIG_CRC16 is not set
957CONFIG_CRC32=y 991CONFIG_CRC32=y
958CONFIG_LIBCRC32C=m 992CONFIG_LIBCRC32C=m
959CONFIG_ZLIB_INFLATE=y 993CONFIG_ZLIB_INFLATE=y
960CONFIG_ZLIB_DEFLATE=m 994CONFIG_ZLIB_DEFLATE=m
995CONFIG_TEXTSEARCH=y
996CONFIG_TEXTSEARCH_KMP=m
997CONFIG_TEXTSEARCH_BM=m
998CONFIG_TEXTSEARCH_FSM=m
diff --git a/arch/ppc64/configs/maple_defconfig b/arch/ppc64/configs/maple_defconfig
index dd42892cd873..7b480f3d1406 100644
--- a/arch/ppc64/configs/maple_defconfig
+++ b/arch/ppc64/configs/maple_defconfig
@@ -1,17 +1,17 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6 3# Linux kernel version: 2.6.14-rc4
4# Mon Aug 8 14:17:04 2005 4# Thu Oct 20 08:31:24 2005
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_GENERIC_ISA_DMA=y 10CONFIG_GENERIC_ISA_DMA=y
11CONFIG_HAVE_DEC_LOCK=y
12CONFIG_EARLY_PRINTK=y 11CONFIG_EARLY_PRINTK=y
13CONFIG_COMPAT=y 12CONFIG_COMPAT=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15CONFIG_FORCE_MAX_ZONEORDER=13 15CONFIG_FORCE_MAX_ZONEORDER=13
16 16
17# 17#
@@ -26,6 +26,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 26# General setup
27# 27#
28CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 30CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
31CONFIG_POSIX_MQUEUE=y 32CONFIG_POSIX_MQUEUE=y
@@ -37,6 +38,7 @@ CONFIG_KOBJECT_UEVENT=y
37CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
38CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
39# CONFIG_CPUSETS is not set 40# CONFIG_CPUSETS is not set
41CONFIG_INITRAMFS_SOURCE=""
40# CONFIG_EMBEDDED is not set 42# CONFIG_EMBEDDED is not set
41CONFIG_KALLSYMS=y 43CONFIG_KALLSYMS=y
42CONFIG_KALLSYMS_ALL=y 44CONFIG_KALLSYMS_ALL=y
@@ -97,6 +99,7 @@ CONFIG_FLATMEM_MANUAL=y
97# CONFIG_SPARSEMEM_MANUAL is not set 99# CONFIG_SPARSEMEM_MANUAL is not set
98CONFIG_FLATMEM=y 100CONFIG_FLATMEM=y
99CONFIG_FLAT_NODE_MEM_MAP=y 101CONFIG_FLAT_NODE_MEM_MAP=y
102# CONFIG_SPARSEMEM_STATIC is not set
100# CONFIG_NUMA is not set 103# CONFIG_NUMA is not set
101# CONFIG_SCHED_SMT is not set 104# CONFIG_SCHED_SMT is not set
102CONFIG_PREEMPT_NONE=y 105CONFIG_PREEMPT_NONE=y
@@ -109,17 +112,18 @@ CONFIG_HZ_250=y
109CONFIG_HZ=250 112CONFIG_HZ=250
110CONFIG_GENERIC_HARDIRQS=y 113CONFIG_GENERIC_HARDIRQS=y
111CONFIG_SECCOMP=y 114CONFIG_SECCOMP=y
115CONFIG_BINFMT_ELF=y
116# CONFIG_BINFMT_MISC is not set
117CONFIG_PROC_DEVICETREE=y
118# CONFIG_CMDLINE_BOOL is not set
112CONFIG_ISA_DMA_API=y 119CONFIG_ISA_DMA_API=y
113 120
114# 121#
115# General setup 122# Bus Options
116# 123#
117CONFIG_PCI=y 124CONFIG_PCI=y
118CONFIG_PCI_DOMAINS=y 125CONFIG_PCI_DOMAINS=y
119CONFIG_BINFMT_ELF=y
120# CONFIG_BINFMT_MISC is not set
121CONFIG_PCI_LEGACY_PROC=y 126CONFIG_PCI_LEGACY_PROC=y
122CONFIG_PCI_NAMES=y
123# CONFIG_PCI_DEBUG is not set 127# CONFIG_PCI_DEBUG is not set
124 128
125# 129#
@@ -131,8 +135,6 @@ CONFIG_PCI_NAMES=y
131# PCI Hotplug Support 135# PCI Hotplug Support
132# 136#
133# CONFIG_HOTPLUG_PCI is not set 137# CONFIG_HOTPLUG_PCI is not set
134CONFIG_PROC_DEVICETREE=y
135# CONFIG_CMDLINE_BOOL is not set
136 138
137# 139#
138# Networking 140# Networking
@@ -163,14 +165,19 @@ CONFIG_IP_PNP_DHCP=y
163# CONFIG_INET_ESP is not set 165# CONFIG_INET_ESP is not set
164# CONFIG_INET_IPCOMP is not set 166# CONFIG_INET_IPCOMP is not set
165# CONFIG_INET_TUNNEL is not set 167# CONFIG_INET_TUNNEL is not set
166CONFIG_IP_TCPDIAG=y 168CONFIG_INET_DIAG=y
167# CONFIG_IP_TCPDIAG_IPV6 is not set 169CONFIG_INET_TCP_DIAG=y
168# CONFIG_TCP_CONG_ADVANCED is not set 170# CONFIG_TCP_CONG_ADVANCED is not set
169CONFIG_TCP_CONG_BIC=y 171CONFIG_TCP_CONG_BIC=y
170# CONFIG_IPV6 is not set 172# CONFIG_IPV6 is not set
171# CONFIG_NETFILTER is not set 173# CONFIG_NETFILTER is not set
172 174
173# 175#
176# DCCP Configuration (EXPERIMENTAL)
177#
178# CONFIG_IP_DCCP is not set
179
180#
174# SCTP Configuration (EXPERIMENTAL) 181# SCTP Configuration (EXPERIMENTAL)
175# 182#
176# CONFIG_IP_SCTP is not set 183# CONFIG_IP_SCTP is not set
@@ -196,6 +203,7 @@ CONFIG_TCP_CONG_BIC=y
196# CONFIG_HAMRADIO is not set 203# CONFIG_HAMRADIO is not set
197# CONFIG_IRDA is not set 204# CONFIG_IRDA is not set
198# CONFIG_BT is not set 205# CONFIG_BT is not set
206# CONFIG_IEEE80211 is not set
199 207
200# 208#
201# Device Drivers 209# Device Drivers
@@ -210,6 +218,11 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
210# CONFIG_DEBUG_DRIVER is not set 218# CONFIG_DEBUG_DRIVER is not set
211 219
212# 220#
221# Connector - unified userspace <-> kernelspace linker
222#
223# CONFIG_CONNECTOR is not set
224
225#
213# Memory Technology Devices (MTD) 226# Memory Technology Devices (MTD)
214# 227#
215# CONFIG_MTD is not set 228# CONFIG_MTD is not set
@@ -240,7 +253,6 @@ CONFIG_BLK_DEV_RAM=y
240CONFIG_BLK_DEV_RAM_COUNT=16 253CONFIG_BLK_DEV_RAM_COUNT=16
241CONFIG_BLK_DEV_RAM_SIZE=8192 254CONFIG_BLK_DEV_RAM_SIZE=8192
242# CONFIG_BLK_DEV_INITRD is not set 255# CONFIG_BLK_DEV_INITRD is not set
243CONFIG_INITRAMFS_SOURCE=""
244# CONFIG_CDROM_PKTCDVD is not set 256# CONFIG_CDROM_PKTCDVD is not set
245 257
246# 258#
@@ -313,6 +325,7 @@ CONFIG_IDEDMA_AUTO=y
313# 325#
314# SCSI device support 326# SCSI device support
315# 327#
328# CONFIG_RAID_ATTRS is not set
316# CONFIG_SCSI is not set 329# CONFIG_SCSI is not set
317 330
318# 331#
@@ -354,12 +367,18 @@ CONFIG_NETDEVICES=y
354# CONFIG_ARCNET is not set 367# CONFIG_ARCNET is not set
355 368
356# 369#
370# PHY device support
371#
372# CONFIG_PHYLIB is not set
373
374#
357# Ethernet (10 or 100Mbit) 375# Ethernet (10 or 100Mbit)
358# 376#
359CONFIG_NET_ETHERNET=y 377CONFIG_NET_ETHERNET=y
360CONFIG_MII=y 378CONFIG_MII=y
361# CONFIG_HAPPYMEAL is not set 379# CONFIG_HAPPYMEAL is not set
362# CONFIG_SUNGEM is not set 380# CONFIG_SUNGEM is not set
381# CONFIG_CASSINI is not set
363# CONFIG_NET_VENDOR_3COM is not set 382# CONFIG_NET_VENDOR_3COM is not set
364 383
365# 384#
@@ -398,6 +417,7 @@ CONFIG_E1000=y
398# CONFIG_HAMACHI is not set 417# CONFIG_HAMACHI is not set
399# CONFIG_YELLOWFIN is not set 418# CONFIG_YELLOWFIN is not set
400# CONFIG_R8169 is not set 419# CONFIG_R8169 is not set
420# CONFIG_SIS190 is not set
401# CONFIG_SKGE is not set 421# CONFIG_SKGE is not set
402# CONFIG_SK98LIN is not set 422# CONFIG_SK98LIN is not set
403# CONFIG_VIA_VELOCITY is not set 423# CONFIG_VIA_VELOCITY is not set
@@ -408,6 +428,7 @@ CONFIG_E1000=y
408# 428#
409# Ethernet (10000 Mbit) 429# Ethernet (10000 Mbit)
410# 430#
431# CONFIG_CHELSIO_T1 is not set
411# CONFIG_IXGB is not set 432# CONFIG_IXGB is not set
412# CONFIG_S2IO is not set 433# CONFIG_S2IO is not set
413 434
@@ -553,7 +574,6 @@ CONFIG_I2C_AMD8111=y
553# CONFIG_I2C_I801 is not set 574# CONFIG_I2C_I801 is not set
554# CONFIG_I2C_I810 is not set 575# CONFIG_I2C_I810 is not set
555# CONFIG_I2C_PIIX4 is not set 576# CONFIG_I2C_PIIX4 is not set
556# CONFIG_I2C_ISA is not set
557# CONFIG_I2C_NFORCE2 is not set 577# CONFIG_I2C_NFORCE2 is not set
558# CONFIG_I2C_PARPORT_LIGHT is not set 578# CONFIG_I2C_PARPORT_LIGHT is not set
559# CONFIG_I2C_PROSAVAGE is not set 579# CONFIG_I2C_PROSAVAGE is not set
@@ -567,7 +587,6 @@ CONFIG_I2C_AMD8111=y
567# CONFIG_I2C_VIAPRO is not set 587# CONFIG_I2C_VIAPRO is not set
568# CONFIG_I2C_VOODOO3 is not set 588# CONFIG_I2C_VOODOO3 is not set
569# CONFIG_I2C_PCA_ISA is not set 589# CONFIG_I2C_PCA_ISA is not set
570# CONFIG_I2C_SENSOR is not set
571 590
572# 591#
573# Miscellaneous I2C Chip support 592# Miscellaneous I2C Chip support
@@ -594,12 +613,17 @@ CONFIG_I2C_AMD8111=y
594# Hardware Monitoring support 613# Hardware Monitoring support
595# 614#
596# CONFIG_HWMON is not set 615# CONFIG_HWMON is not set
616# CONFIG_HWMON_VID is not set
597 617
598# 618#
599# Misc devices 619# Misc devices
600# 620#
601 621
602# 622#
623# Multimedia Capabilities Port drivers
624#
625
626#
603# Multimedia devices 627# Multimedia devices
604# 628#
605# CONFIG_VIDEO_DEV is not set 629# CONFIG_VIDEO_DEV is not set
@@ -681,9 +705,11 @@ CONFIG_USB_HIDINPUT=y
681# CONFIG_USB_MTOUCH is not set 705# CONFIG_USB_MTOUCH is not set
682# CONFIG_USB_ITMTOUCH is not set 706# CONFIG_USB_ITMTOUCH is not set
683# CONFIG_USB_EGALAX is not set 707# CONFIG_USB_EGALAX is not set
708# CONFIG_USB_YEALINK is not set
684# CONFIG_USB_XPAD is not set 709# CONFIG_USB_XPAD is not set
685# CONFIG_USB_ATI_REMOTE is not set 710# CONFIG_USB_ATI_REMOTE is not set
686# CONFIG_USB_KEYSPAN_REMOTE is not set 711# CONFIG_USB_KEYSPAN_REMOTE is not set
712# CONFIG_USB_APPLETOUCH is not set
687 713
688# 714#
689# USB Imaging devices 715# USB Imaging devices
@@ -814,10 +840,6 @@ CONFIG_JBD=y
814# CONFIG_REISERFS_FS is not set 840# CONFIG_REISERFS_FS is not set
815# CONFIG_JFS_FS is not set 841# CONFIG_JFS_FS is not set
816CONFIG_FS_POSIX_ACL=y 842CONFIG_FS_POSIX_ACL=y
817
818#
819# XFS support
820#
821# CONFIG_XFS_FS is not set 843# CONFIG_XFS_FS is not set
822# CONFIG_MINIX_FS is not set 844# CONFIG_MINIX_FS is not set
823# CONFIG_ROMFS_FS is not set 845# CONFIG_ROMFS_FS is not set
@@ -826,6 +848,7 @@ CONFIG_INOTIFY=y
826CONFIG_DNOTIFY=y 848CONFIG_DNOTIFY=y
827# CONFIG_AUTOFS_FS is not set 849# CONFIG_AUTOFS_FS is not set
828# CONFIG_AUTOFS4_FS is not set 850# CONFIG_AUTOFS4_FS is not set
851# CONFIG_FUSE_FS is not set
829 852
830# 853#
831# CD-ROM/DVD Filesystems 854# CD-ROM/DVD Filesystems
@@ -849,14 +872,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
849CONFIG_PROC_FS=y 872CONFIG_PROC_FS=y
850CONFIG_PROC_KCORE=y 873CONFIG_PROC_KCORE=y
851CONFIG_SYSFS=y 874CONFIG_SYSFS=y
852CONFIG_DEVPTS_FS_XATTR=y
853# CONFIG_DEVPTS_FS_SECURITY is not set
854CONFIG_TMPFS=y 875CONFIG_TMPFS=y
855CONFIG_TMPFS_XATTR=y
856CONFIG_TMPFS_SECURITY=y
857CONFIG_HUGETLBFS=y 876CONFIG_HUGETLBFS=y
858CONFIG_HUGETLB_PAGE=y 877CONFIG_HUGETLB_PAGE=y
859CONFIG_RAMFS=y 878CONFIG_RAMFS=y
879# CONFIG_RELAYFS_FS is not set
860 880
861# 881#
862# Miscellaneous filesystems 882# Miscellaneous filesystems
@@ -898,6 +918,7 @@ CONFIG_RPCSEC_GSS_KRB5=y
898# CONFIG_NCP_FS is not set 918# CONFIG_NCP_FS is not set
899# CONFIG_CODA_FS is not set 919# CONFIG_CODA_FS is not set
900# CONFIG_AFS_FS is not set 920# CONFIG_AFS_FS is not set
921# CONFIG_9P_FS is not set
901 922
902# 923#
903# Partition Types 924# Partition Types
@@ -975,6 +996,7 @@ CONFIG_NLS_UTF8=y
975CONFIG_DEBUG_KERNEL=y 996CONFIG_DEBUG_KERNEL=y
976CONFIG_MAGIC_SYSRQ=y 997CONFIG_MAGIC_SYSRQ=y
977CONFIG_LOG_BUF_SHIFT=17 998CONFIG_LOG_BUF_SHIFT=17
999CONFIG_DETECT_SOFTLOCKUP=y
978# CONFIG_SCHEDSTATS is not set 1000# CONFIG_SCHEDSTATS is not set
979CONFIG_DEBUG_SLAB=y 1001CONFIG_DEBUG_SLAB=y
980# CONFIG_DEBUG_SPINLOCK is not set 1002# CONFIG_DEBUG_SPINLOCK is not set
@@ -1034,6 +1056,7 @@ CONFIG_CRYPTO_DES=y
1034# Library routines 1056# Library routines
1035# 1057#
1036CONFIG_CRC_CCITT=y 1058CONFIG_CRC_CCITT=y
1059# CONFIG_CRC16 is not set
1037CONFIG_CRC32=y 1060CONFIG_CRC32=y
1038# CONFIG_LIBCRC32C is not set 1061# CONFIG_LIBCRC32C is not set
1039CONFIG_ZLIB_INFLATE=y 1062CONFIG_ZLIB_INFLATE=y
diff --git a/arch/ppc64/configs/pSeries_defconfig b/arch/ppc64/configs/pSeries_defconfig
index 29f7b80b0efc..9f09dff9e11a 100644
--- a/arch/ppc64/configs/pSeries_defconfig
+++ b/arch/ppc64/configs/pSeries_defconfig
@@ -1,17 +1,17 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6 3# Linux kernel version: 2.6.14-rc4
4# Mon Aug 8 14:17:07 2005 4# Thu Oct 20 08:32:17 2005
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_GENERIC_ISA_DMA=y 10CONFIG_GENERIC_ISA_DMA=y
11CONFIG_HAVE_DEC_LOCK=y
12CONFIG_EARLY_PRINTK=y 11CONFIG_EARLY_PRINTK=y
13CONFIG_COMPAT=y 12CONFIG_COMPAT=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15CONFIG_FORCE_MAX_ZONEORDER=13 15CONFIG_FORCE_MAX_ZONEORDER=13
16 16
17# 17#
@@ -26,6 +26,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 26# General setup
27# 27#
28CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 30CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
31CONFIG_POSIX_MQUEUE=y 32CONFIG_POSIX_MQUEUE=y
@@ -38,6 +39,7 @@ CONFIG_KOBJECT_UEVENT=y
38CONFIG_IKCONFIG=y 39CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y 40CONFIG_IKCONFIG_PROC=y
40CONFIG_CPUSETS=y 41CONFIG_CPUSETS=y
42CONFIG_INITRAMFS_SOURCE=""
41# CONFIG_EMBEDDED is not set 43# CONFIG_EMBEDDED is not set
42CONFIG_KALLSYMS=y 44CONFIG_KALLSYMS=y
43CONFIG_KALLSYMS_ALL=y 45CONFIG_KALLSYMS_ALL=y
@@ -104,6 +106,7 @@ CONFIG_DISCONTIGMEM_MANUAL=y
104CONFIG_DISCONTIGMEM=y 106CONFIG_DISCONTIGMEM=y
105CONFIG_FLAT_NODE_MEM_MAP=y 107CONFIG_FLAT_NODE_MEM_MAP=y
106CONFIG_NEED_MULTIPLE_NODES=y 108CONFIG_NEED_MULTIPLE_NODES=y
109# CONFIG_SPARSEMEM_STATIC is not set
107CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 110CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
108CONFIG_NODES_SPAN_OTHER_NODES=y 111CONFIG_NODES_SPAN_OTHER_NODES=y
109CONFIG_NUMA=y 112CONFIG_NUMA=y
@@ -124,19 +127,20 @@ CONFIG_RTAS_FLASH=m
124CONFIG_SCANLOG=m 127CONFIG_SCANLOG=m
125CONFIG_LPARCFG=y 128CONFIG_LPARCFG=y
126CONFIG_SECCOMP=y 129CONFIG_SECCOMP=y
130CONFIG_BINFMT_ELF=y
131# CONFIG_BINFMT_MISC is not set
132CONFIG_HOTPLUG_CPU=y
133CONFIG_PROC_DEVICETREE=y
134# CONFIG_CMDLINE_BOOL is not set
127CONFIG_ISA_DMA_API=y 135CONFIG_ISA_DMA_API=y
128 136
129# 137#
130# General setup 138# Bus Options
131# 139#
132CONFIG_PCI=y 140CONFIG_PCI=y
133CONFIG_PCI_DOMAINS=y 141CONFIG_PCI_DOMAINS=y
134CONFIG_BINFMT_ELF=y
135# CONFIG_BINFMT_MISC is not set
136CONFIG_PCI_LEGACY_PROC=y 142CONFIG_PCI_LEGACY_PROC=y
137CONFIG_PCI_NAMES=y
138# CONFIG_PCI_DEBUG is not set 143# CONFIG_PCI_DEBUG is not set
139CONFIG_HOTPLUG_CPU=y
140 144
141# 145#
142# PCCARD (PCMCIA/CardBus) support 146# PCCARD (PCMCIA/CardBus) support
@@ -152,8 +156,6 @@ CONFIG_HOTPLUG_PCI=m
152# CONFIG_HOTPLUG_PCI_SHPC is not set 156# CONFIG_HOTPLUG_PCI_SHPC is not set
153CONFIG_HOTPLUG_PCI_RPA=m 157CONFIG_HOTPLUG_PCI_RPA=m
154CONFIG_HOTPLUG_PCI_RPA_DLPAR=m 158CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
155CONFIG_PROC_DEVICETREE=y
156# CONFIG_CMDLINE_BOOL is not set
157 159
158# 160#
159# Networking 161# Networking
@@ -183,8 +185,8 @@ CONFIG_INET_AH=m
183CONFIG_INET_ESP=m 185CONFIG_INET_ESP=m
184CONFIG_INET_IPCOMP=m 186CONFIG_INET_IPCOMP=m
185CONFIG_INET_TUNNEL=y 187CONFIG_INET_TUNNEL=y
186CONFIG_IP_TCPDIAG=m 188CONFIG_INET_DIAG=y
187# CONFIG_IP_TCPDIAG_IPV6 is not set 189CONFIG_INET_TCP_DIAG=y
188# CONFIG_TCP_CONG_ADVANCED is not set 190# CONFIG_TCP_CONG_ADVANCED is not set
189CONFIG_TCP_CONG_BIC=y 191CONFIG_TCP_CONG_BIC=y
190 192
@@ -195,6 +197,9 @@ CONFIG_TCP_CONG_BIC=y
195# CONFIG_IPV6 is not set 197# CONFIG_IPV6 is not set
196CONFIG_NETFILTER=y 198CONFIG_NETFILTER=y
197# CONFIG_NETFILTER_DEBUG is not set 199# CONFIG_NETFILTER_DEBUG is not set
200CONFIG_NETFILTER_NETLINK=y
201CONFIG_NETFILTER_NETLINK_QUEUE=m
202CONFIG_NETFILTER_NETLINK_LOG=m
198 203
199# 204#
200# IP: Netfilter Configuration 205# IP: Netfilter Configuration
@@ -202,11 +207,15 @@ CONFIG_NETFILTER=y
202CONFIG_IP_NF_CONNTRACK=m 207CONFIG_IP_NF_CONNTRACK=m
203CONFIG_IP_NF_CT_ACCT=y 208CONFIG_IP_NF_CT_ACCT=y
204CONFIG_IP_NF_CONNTRACK_MARK=y 209CONFIG_IP_NF_CONNTRACK_MARK=y
210CONFIG_IP_NF_CONNTRACK_EVENTS=y
211CONFIG_IP_NF_CONNTRACK_NETLINK=m
205CONFIG_IP_NF_CT_PROTO_SCTP=m 212CONFIG_IP_NF_CT_PROTO_SCTP=m
206CONFIG_IP_NF_FTP=m 213CONFIG_IP_NF_FTP=m
207CONFIG_IP_NF_IRC=m 214CONFIG_IP_NF_IRC=m
215# CONFIG_IP_NF_NETBIOS_NS is not set
208CONFIG_IP_NF_TFTP=m 216CONFIG_IP_NF_TFTP=m
209CONFIG_IP_NF_AMANDA=m 217CONFIG_IP_NF_AMANDA=m
218# CONFIG_IP_NF_PPTP is not set
210CONFIG_IP_NF_QUEUE=m 219CONFIG_IP_NF_QUEUE=m
211CONFIG_IP_NF_IPTABLES=m 220CONFIG_IP_NF_IPTABLES=m
212CONFIG_IP_NF_MATCH_LIMIT=m 221CONFIG_IP_NF_MATCH_LIMIT=m
@@ -230,14 +239,18 @@ CONFIG_IP_NF_MATCH_OWNER=m
230CONFIG_IP_NF_MATCH_ADDRTYPE=m 239CONFIG_IP_NF_MATCH_ADDRTYPE=m
231CONFIG_IP_NF_MATCH_REALM=m 240CONFIG_IP_NF_MATCH_REALM=m
232CONFIG_IP_NF_MATCH_SCTP=m 241CONFIG_IP_NF_MATCH_SCTP=m
242# CONFIG_IP_NF_MATCH_DCCP is not set
233CONFIG_IP_NF_MATCH_COMMENT=m 243CONFIG_IP_NF_MATCH_COMMENT=m
234CONFIG_IP_NF_MATCH_CONNMARK=m 244CONFIG_IP_NF_MATCH_CONNMARK=m
245CONFIG_IP_NF_MATCH_CONNBYTES=m
235CONFIG_IP_NF_MATCH_HASHLIMIT=m 246CONFIG_IP_NF_MATCH_HASHLIMIT=m
247CONFIG_IP_NF_MATCH_STRING=m
236CONFIG_IP_NF_FILTER=m 248CONFIG_IP_NF_FILTER=m
237CONFIG_IP_NF_TARGET_REJECT=m 249CONFIG_IP_NF_TARGET_REJECT=m
238CONFIG_IP_NF_TARGET_LOG=m 250CONFIG_IP_NF_TARGET_LOG=m
239CONFIG_IP_NF_TARGET_ULOG=m 251CONFIG_IP_NF_TARGET_ULOG=m
240CONFIG_IP_NF_TARGET_TCPMSS=m 252CONFIG_IP_NF_TARGET_TCPMSS=m
253CONFIG_IP_NF_TARGET_NFQUEUE=m
241CONFIG_IP_NF_NAT=m 254CONFIG_IP_NF_NAT=m
242CONFIG_IP_NF_NAT_NEEDED=y 255CONFIG_IP_NF_NAT_NEEDED=y
243CONFIG_IP_NF_TARGET_MASQUERADE=m 256CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -255,6 +268,7 @@ CONFIG_IP_NF_TARGET_ECN=m
255CONFIG_IP_NF_TARGET_DSCP=m 268CONFIG_IP_NF_TARGET_DSCP=m
256CONFIG_IP_NF_TARGET_MARK=m 269CONFIG_IP_NF_TARGET_MARK=m
257CONFIG_IP_NF_TARGET_CLASSIFY=m 270CONFIG_IP_NF_TARGET_CLASSIFY=m
271CONFIG_IP_NF_TARGET_TTL=m
258CONFIG_IP_NF_TARGET_CONNMARK=m 272CONFIG_IP_NF_TARGET_CONNMARK=m
259CONFIG_IP_NF_TARGET_CLUSTERIP=m 273CONFIG_IP_NF_TARGET_CLUSTERIP=m
260CONFIG_IP_NF_RAW=m 274CONFIG_IP_NF_RAW=m
@@ -264,6 +278,11 @@ CONFIG_IP_NF_ARPFILTER=m
264CONFIG_IP_NF_ARP_MANGLE=m 278CONFIG_IP_NF_ARP_MANGLE=m
265 279
266# 280#
281# DCCP Configuration (EXPERIMENTAL)
282#
283# CONFIG_IP_DCCP is not set
284
285#
267# SCTP Configuration (EXPERIMENTAL) 286# SCTP Configuration (EXPERIMENTAL)
268# 287#
269# CONFIG_IP_SCTP is not set 288# CONFIG_IP_SCTP is not set
@@ -290,6 +309,7 @@ CONFIG_NET_CLS_ROUTE=y
290# CONFIG_HAMRADIO is not set 309# CONFIG_HAMRADIO is not set
291# CONFIG_IRDA is not set 310# CONFIG_IRDA is not set
292# CONFIG_BT is not set 311# CONFIG_BT is not set
312# CONFIG_IEEE80211 is not set
293 313
294# 314#
295# Device Drivers 315# Device Drivers
@@ -304,6 +324,11 @@ CONFIG_FW_LOADER=y
304# CONFIG_DEBUG_DRIVER is not set 324# CONFIG_DEBUG_DRIVER is not set
305 325
306# 326#
327# Connector - unified userspace <-> kernelspace linker
328#
329# CONFIG_CONNECTOR is not set
330
331#
307# Memory Technology Devices (MTD) 332# Memory Technology Devices (MTD)
308# 333#
309# CONFIG_MTD is not set 334# CONFIG_MTD is not set
@@ -342,7 +367,6 @@ CONFIG_BLK_DEV_RAM=y
342CONFIG_BLK_DEV_RAM_COUNT=16 367CONFIG_BLK_DEV_RAM_COUNT=16
343CONFIG_BLK_DEV_RAM_SIZE=65536 368CONFIG_BLK_DEV_RAM_SIZE=65536
344CONFIG_BLK_DEV_INITRD=y 369CONFIG_BLK_DEV_INITRD=y
345CONFIG_INITRAMFS_SOURCE=""
346# CONFIG_CDROM_PKTCDVD is not set 370# CONFIG_CDROM_PKTCDVD is not set
347 371
348# 372#
@@ -416,6 +440,7 @@ CONFIG_IDEDMA_AUTO=y
416# 440#
417# SCSI device support 441# SCSI device support
418# 442#
443# CONFIG_RAID_ATTRS is not set
419CONFIG_SCSI=y 444CONFIG_SCSI=y
420CONFIG_SCSI_PROC_FS=y 445CONFIG_SCSI_PROC_FS=y
421 446
@@ -443,6 +468,7 @@ CONFIG_SCSI_CONSTANTS=y
443CONFIG_SCSI_SPI_ATTRS=y 468CONFIG_SCSI_SPI_ATTRS=y
444CONFIG_SCSI_FC_ATTRS=y 469CONFIG_SCSI_FC_ATTRS=y
445CONFIG_SCSI_ISCSI_ATTRS=m 470CONFIG_SCSI_ISCSI_ATTRS=m
471# CONFIG_SCSI_SAS_ATTRS is not set
446 472
447# 473#
448# SCSI low-level drivers 474# SCSI low-level drivers
@@ -456,6 +482,7 @@ CONFIG_SCSI_ISCSI_ATTRS=m
456# CONFIG_SCSI_AIC79XX is not set 482# CONFIG_SCSI_AIC79XX is not set
457# CONFIG_MEGARAID_NEWGEN is not set 483# CONFIG_MEGARAID_NEWGEN is not set
458# CONFIG_MEGARAID_LEGACY is not set 484# CONFIG_MEGARAID_LEGACY is not set
485# CONFIG_MEGARAID_SAS is not set
459# CONFIG_SCSI_SATA is not set 486# CONFIG_SCSI_SATA is not set
460# CONFIG_SCSI_BUSLOGIC is not set 487# CONFIG_SCSI_BUSLOGIC is not set
461# CONFIG_SCSI_DMX3191D is not set 488# CONFIG_SCSI_DMX3191D is not set
@@ -517,6 +544,7 @@ CONFIG_DM_MULTIPATH_EMC=m
517# CONFIG_FUSION is not set 544# CONFIG_FUSION is not set
518# CONFIG_FUSION_SPI is not set 545# CONFIG_FUSION_SPI is not set
519# CONFIG_FUSION_FC is not set 546# CONFIG_FUSION_FC is not set
547# CONFIG_FUSION_SAS is not set
520 548
521# 549#
522# IEEE 1394 (FireWire) support 550# IEEE 1394 (FireWire) support
@@ -547,12 +575,18 @@ CONFIG_TUN=m
547# CONFIG_ARCNET is not set 575# CONFIG_ARCNET is not set
548 576
549# 577#
578# PHY device support
579#
580# CONFIG_PHYLIB is not set
581
582#
550# Ethernet (10 or 100Mbit) 583# Ethernet (10 or 100Mbit)
551# 584#
552CONFIG_NET_ETHERNET=y 585CONFIG_NET_ETHERNET=y
553CONFIG_MII=y 586CONFIG_MII=y
554# CONFIG_HAPPYMEAL is not set 587# CONFIG_HAPPYMEAL is not set
555# CONFIG_SUNGEM is not set 588# CONFIG_SUNGEM is not set
589# CONFIG_CASSINI is not set
556CONFIG_NET_VENDOR_3COM=y 590CONFIG_NET_VENDOR_3COM=y
557CONFIG_VORTEX=y 591CONFIG_VORTEX=y
558# CONFIG_TYPHOON is not set 592# CONFIG_TYPHOON is not set
@@ -581,6 +615,7 @@ CONFIG_E100=y
581# CONFIG_EPIC100 is not set 615# CONFIG_EPIC100 is not set
582# CONFIG_SUNDANCE is not set 616# CONFIG_SUNDANCE is not set
583# CONFIG_VIA_RHINE is not set 617# CONFIG_VIA_RHINE is not set
618# CONFIG_NET_POCKET is not set
584 619
585# 620#
586# Ethernet (1000 Mbit) 621# Ethernet (1000 Mbit)
@@ -594,6 +629,7 @@ CONFIG_E1000=y
594# CONFIG_HAMACHI is not set 629# CONFIG_HAMACHI is not set
595# CONFIG_YELLOWFIN is not set 630# CONFIG_YELLOWFIN is not set
596# CONFIG_R8169 is not set 631# CONFIG_R8169 is not set
632# CONFIG_SIS190 is not set
597# CONFIG_SKGE is not set 633# CONFIG_SKGE is not set
598# CONFIG_SK98LIN is not set 634# CONFIG_SK98LIN is not set
599# CONFIG_VIA_VELOCITY is not set 635# CONFIG_VIA_VELOCITY is not set
@@ -604,6 +640,7 @@ CONFIG_TIGON3=y
604# 640#
605# Ethernet (10000 Mbit) 641# Ethernet (10000 Mbit)
606# 642#
643# CONFIG_CHELSIO_T1 is not set
607CONFIG_IXGB=m 644CONFIG_IXGB=m
608# CONFIG_IXGB_NAPI is not set 645# CONFIG_IXGB_NAPI is not set
609CONFIG_S2IO=m 646CONFIG_S2IO=m
@@ -789,7 +826,6 @@ CONFIG_I2C_ALGOBIT=y
789# CONFIG_I2C_I801 is not set 826# CONFIG_I2C_I801 is not set
790# CONFIG_I2C_I810 is not set 827# CONFIG_I2C_I810 is not set
791# CONFIG_I2C_PIIX4 is not set 828# CONFIG_I2C_PIIX4 is not set
792# CONFIG_I2C_ISA is not set
793# CONFIG_I2C_NFORCE2 is not set 829# CONFIG_I2C_NFORCE2 is not set
794# CONFIG_I2C_PARPORT is not set 830# CONFIG_I2C_PARPORT is not set
795# CONFIG_I2C_PARPORT_LIGHT is not set 831# CONFIG_I2C_PARPORT_LIGHT is not set
@@ -804,7 +840,6 @@ CONFIG_I2C_ALGOBIT=y
804# CONFIG_I2C_VIAPRO is not set 840# CONFIG_I2C_VIAPRO is not set
805# CONFIG_I2C_VOODOO3 is not set 841# CONFIG_I2C_VOODOO3 is not set
806# CONFIG_I2C_PCA_ISA is not set 842# CONFIG_I2C_PCA_ISA is not set
807# CONFIG_I2C_SENSOR is not set
808 843
809# 844#
810# Miscellaneous I2C Chip support 845# Miscellaneous I2C Chip support
@@ -831,12 +866,17 @@ CONFIG_I2C_ALGOBIT=y
831# Hardware Monitoring support 866# Hardware Monitoring support
832# 867#
833# CONFIG_HWMON is not set 868# CONFIG_HWMON is not set
869# CONFIG_HWMON_VID is not set
834 870
835# 871#
836# Misc devices 872# Misc devices
837# 873#
838 874
839# 875#
876# Multimedia Capabilities Port drivers
877#
878
879#
840# Multimedia devices 880# Multimedia devices
841# 881#
842# CONFIG_VIDEO_DEV is not set 882# CONFIG_VIDEO_DEV is not set
@@ -885,6 +925,7 @@ CONFIG_FB_RADEON_I2C=y
885# CONFIG_FB_KYRO is not set 925# CONFIG_FB_KYRO is not set
886# CONFIG_FB_3DFX is not set 926# CONFIG_FB_3DFX is not set
887# CONFIG_FB_VOODOO1 is not set 927# CONFIG_FB_VOODOO1 is not set
928# CONFIG_FB_CYBLA is not set
888# CONFIG_FB_TRIDENT is not set 929# CONFIG_FB_TRIDENT is not set
889# CONFIG_FB_S1D13XXX is not set 930# CONFIG_FB_S1D13XXX is not set
890# CONFIG_FB_VIRTUAL is not set 931# CONFIG_FB_VIRTUAL is not set
@@ -982,9 +1023,11 @@ CONFIG_USB_HIDDEV=y
982# CONFIG_USB_MTOUCH is not set 1023# CONFIG_USB_MTOUCH is not set
983# CONFIG_USB_ITMTOUCH is not set 1024# CONFIG_USB_ITMTOUCH is not set
984# CONFIG_USB_EGALAX is not set 1025# CONFIG_USB_EGALAX is not set
1026# CONFIG_USB_YEALINK is not set
985# CONFIG_USB_XPAD is not set 1027# CONFIG_USB_XPAD is not set
986# CONFIG_USB_ATI_REMOTE is not set 1028# CONFIG_USB_ATI_REMOTE is not set
987# CONFIG_USB_KEYSPAN_REMOTE is not set 1029# CONFIG_USB_KEYSPAN_REMOTE is not set
1030# CONFIG_USB_APPLETOUCH is not set
988 1031
989# 1032#
990# USB Imaging devices 1033# USB Imaging devices
@@ -1057,7 +1100,8 @@ CONFIG_USB_MON=y
1057# InfiniBand support 1100# InfiniBand support
1058# 1101#
1059CONFIG_INFINIBAND=m 1102CONFIG_INFINIBAND=m
1060CONFIG_INFINIBAND_USER_VERBS=m 1103# CONFIG_INFINIBAND_USER_MAD is not set
1104# CONFIG_INFINIBAND_USER_ACCESS is not set
1061CONFIG_INFINIBAND_MTHCA=m 1105CONFIG_INFINIBAND_MTHCA=m
1062# CONFIG_INFINIBAND_MTHCA_DEBUG is not set 1106# CONFIG_INFINIBAND_MTHCA_DEBUG is not set
1063CONFIG_INFINIBAND_IPOIB=m 1107CONFIG_INFINIBAND_IPOIB=m
@@ -1095,16 +1139,12 @@ CONFIG_JFS_SECURITY=y
1095# CONFIG_JFS_DEBUG is not set 1139# CONFIG_JFS_DEBUG is not set
1096# CONFIG_JFS_STATISTICS is not set 1140# CONFIG_JFS_STATISTICS is not set
1097CONFIG_FS_POSIX_ACL=y 1141CONFIG_FS_POSIX_ACL=y
1098
1099#
1100# XFS support
1101#
1102CONFIG_XFS_FS=m 1142CONFIG_XFS_FS=m
1103CONFIG_XFS_EXPORT=y 1143CONFIG_XFS_EXPORT=y
1104# CONFIG_XFS_RT is not set
1105# CONFIG_XFS_QUOTA is not set 1144# CONFIG_XFS_QUOTA is not set
1106CONFIG_XFS_SECURITY=y 1145CONFIG_XFS_SECURITY=y
1107CONFIG_XFS_POSIX_ACL=y 1146CONFIG_XFS_POSIX_ACL=y
1147# CONFIG_XFS_RT is not set
1108# CONFIG_MINIX_FS is not set 1148# CONFIG_MINIX_FS is not set
1109# CONFIG_ROMFS_FS is not set 1149# CONFIG_ROMFS_FS is not set
1110CONFIG_INOTIFY=y 1150CONFIG_INOTIFY=y
@@ -1112,6 +1152,7 @@ CONFIG_INOTIFY=y
1112CONFIG_DNOTIFY=y 1152CONFIG_DNOTIFY=y
1113CONFIG_AUTOFS_FS=m 1153CONFIG_AUTOFS_FS=m
1114# CONFIG_AUTOFS4_FS is not set 1154# CONFIG_AUTOFS4_FS is not set
1155# CONFIG_FUSE_FS is not set
1115 1156
1116# 1157#
1117# CD-ROM/DVD Filesystems 1158# CD-ROM/DVD Filesystems
@@ -1139,14 +1180,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1139CONFIG_PROC_FS=y 1180CONFIG_PROC_FS=y
1140CONFIG_PROC_KCORE=y 1181CONFIG_PROC_KCORE=y
1141CONFIG_SYSFS=y 1182CONFIG_SYSFS=y
1142CONFIG_DEVPTS_FS_XATTR=y
1143CONFIG_DEVPTS_FS_SECURITY=y
1144CONFIG_TMPFS=y 1183CONFIG_TMPFS=y
1145CONFIG_TMPFS_XATTR=y
1146CONFIG_TMPFS_SECURITY=y
1147CONFIG_HUGETLBFS=y 1184CONFIG_HUGETLBFS=y
1148CONFIG_HUGETLB_PAGE=y 1185CONFIG_HUGETLB_PAGE=y
1149CONFIG_RAMFS=y 1186CONFIG_RAMFS=y
1187# CONFIG_RELAYFS_FS is not set
1150 1188
1151# 1189#
1152# Miscellaneous filesystems 1190# Miscellaneous filesystems
@@ -1197,6 +1235,7 @@ CONFIG_CIFS_POSIX=y
1197# CONFIG_NCP_FS is not set 1235# CONFIG_NCP_FS is not set
1198# CONFIG_CODA_FS is not set 1236# CONFIG_CODA_FS is not set
1199# CONFIG_AFS_FS is not set 1237# CONFIG_AFS_FS is not set
1238# CONFIG_9P_FS is not set
1200 1239
1201# 1240#
1202# Partition Types 1241# Partition Types
@@ -1261,6 +1300,7 @@ CONFIG_OPROFILE=y
1261CONFIG_DEBUG_KERNEL=y 1300CONFIG_DEBUG_KERNEL=y
1262CONFIG_MAGIC_SYSRQ=y 1301CONFIG_MAGIC_SYSRQ=y
1263CONFIG_LOG_BUF_SHIFT=17 1302CONFIG_LOG_BUF_SHIFT=17
1303CONFIG_DETECT_SOFTLOCKUP=y
1264# CONFIG_SCHEDSTATS is not set 1304# CONFIG_SCHEDSTATS is not set
1265# CONFIG_DEBUG_SLAB is not set 1305# CONFIG_DEBUG_SLAB is not set
1266# CONFIG_DEBUG_SPINLOCK is not set 1306# CONFIG_DEBUG_SPINLOCK is not set
@@ -1320,7 +1360,12 @@ CONFIG_CRYPTO_TEST=m
1320# Library routines 1360# Library routines
1321# 1361#
1322CONFIG_CRC_CCITT=m 1362CONFIG_CRC_CCITT=m
1363# CONFIG_CRC16 is not set
1323CONFIG_CRC32=y 1364CONFIG_CRC32=y
1324CONFIG_LIBCRC32C=m 1365CONFIG_LIBCRC32C=m
1325CONFIG_ZLIB_INFLATE=y 1366CONFIG_ZLIB_INFLATE=y
1326CONFIG_ZLIB_DEFLATE=m 1367CONFIG_ZLIB_DEFLATE=m
1368CONFIG_TEXTSEARCH=y
1369CONFIG_TEXTSEARCH_KMP=m
1370CONFIG_TEXTSEARCH_BM=m
1371CONFIG_TEXTSEARCH_FSM=m
diff --git a/arch/ppc64/defconfig b/arch/ppc64/defconfig
index 7cb4750bb7a9..37c157c93cef 100644
--- a/arch/ppc64/defconfig
+++ b/arch/ppc64/defconfig
@@ -1,17 +1,17 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc6 3# Linux kernel version: 2.6.14-rc4
4# Mon Aug 8 14:16:54 2005 4# Thu Oct 20 08:28:33 2005
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y 8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y 9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_GENERIC_ISA_DMA=y 10CONFIG_GENERIC_ISA_DMA=y
11CONFIG_HAVE_DEC_LOCK=y
12CONFIG_EARLY_PRINTK=y 11CONFIG_EARLY_PRINTK=y
13CONFIG_COMPAT=y 12CONFIG_COMPAT=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 13CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y
15CONFIG_FORCE_MAX_ZONEORDER=13 15CONFIG_FORCE_MAX_ZONEORDER=13
16 16
17# 17#
@@ -26,6 +26,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
26# General setup 26# General setup
27# 27#
28CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29CONFIG_LOCALVERSION_AUTO=y
29CONFIG_SWAP=y 30CONFIG_SWAP=y
30CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
31CONFIG_POSIX_MQUEUE=y 32CONFIG_POSIX_MQUEUE=y
@@ -37,6 +38,7 @@ CONFIG_KOBJECT_UEVENT=y
37CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
38CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
39CONFIG_CPUSETS=y 40CONFIG_CPUSETS=y
41CONFIG_INITRAMFS_SOURCE=""
40# CONFIG_EMBEDDED is not set 42# CONFIG_EMBEDDED is not set
41CONFIG_KALLSYMS=y 43CONFIG_KALLSYMS=y
42# CONFIG_KALLSYMS_ALL is not set 44# CONFIG_KALLSYMS_ALL is not set
@@ -106,6 +108,7 @@ CONFIG_DISCONTIGMEM_MANUAL=y
106CONFIG_DISCONTIGMEM=y 108CONFIG_DISCONTIGMEM=y
107CONFIG_FLAT_NODE_MEM_MAP=y 109CONFIG_FLAT_NODE_MEM_MAP=y
108CONFIG_NEED_MULTIPLE_NODES=y 110CONFIG_NEED_MULTIPLE_NODES=y
111# CONFIG_SPARSEMEM_STATIC is not set
109CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 112CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
110CONFIG_NODES_SPAN_OTHER_NODES=y 113CONFIG_NODES_SPAN_OTHER_NODES=y
111# CONFIG_NUMA is not set 114# CONFIG_NUMA is not set
@@ -126,19 +129,20 @@ CONFIG_RTAS_FLASH=m
126CONFIG_SCANLOG=m 129CONFIG_SCANLOG=m
127CONFIG_LPARCFG=y 130CONFIG_LPARCFG=y
128CONFIG_SECCOMP=y 131CONFIG_SECCOMP=y
132CONFIG_BINFMT_ELF=y
133CONFIG_BINFMT_MISC=m
134CONFIG_HOTPLUG_CPU=y
135CONFIG_PROC_DEVICETREE=y
136# CONFIG_CMDLINE_BOOL is not set
129CONFIG_ISA_DMA_API=y 137CONFIG_ISA_DMA_API=y
130 138
131# 139#
132# General setup 140# Bus Options
133# 141#
134CONFIG_PCI=y 142CONFIG_PCI=y
135CONFIG_PCI_DOMAINS=y 143CONFIG_PCI_DOMAINS=y
136CONFIG_BINFMT_ELF=y
137CONFIG_BINFMT_MISC=m
138# CONFIG_PCI_LEGACY_PROC is not set 144# CONFIG_PCI_LEGACY_PROC is not set
139# CONFIG_PCI_NAMES is not set
140# CONFIG_PCI_DEBUG is not set 145# CONFIG_PCI_DEBUG is not set
141CONFIG_HOTPLUG_CPU=y
142 146
143# 147#
144# PCCARD (PCMCIA/CardBus) support 148# PCCARD (PCMCIA/CardBus) support
@@ -154,8 +158,6 @@ CONFIG_HOTPLUG_PCI=m
154# CONFIG_HOTPLUG_PCI_SHPC is not set 158# CONFIG_HOTPLUG_PCI_SHPC is not set
155CONFIG_HOTPLUG_PCI_RPA=m 159CONFIG_HOTPLUG_PCI_RPA=m
156CONFIG_HOTPLUG_PCI_RPA_DLPAR=m 160CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
157CONFIG_PROC_DEVICETREE=y
158# CONFIG_CMDLINE_BOOL is not set
159 161
160# 162#
161# Networking 163# Networking
@@ -185,8 +187,8 @@ CONFIG_INET_AH=m
185CONFIG_INET_ESP=m 187CONFIG_INET_ESP=m
186CONFIG_INET_IPCOMP=m 188CONFIG_INET_IPCOMP=m
187CONFIG_INET_TUNNEL=y 189CONFIG_INET_TUNNEL=y
188# CONFIG_IP_TCPDIAG is not set 190CONFIG_INET_DIAG=y
189# CONFIG_IP_TCPDIAG_IPV6 is not set 191CONFIG_INET_TCP_DIAG=y
190# CONFIG_TCP_CONG_ADVANCED is not set 192# CONFIG_TCP_CONG_ADVANCED is not set
191CONFIG_TCP_CONG_BIC=y 193CONFIG_TCP_CONG_BIC=y
192 194
@@ -197,6 +199,9 @@ CONFIG_TCP_CONG_BIC=y
197# CONFIG_IPV6 is not set 199# CONFIG_IPV6 is not set
198CONFIG_NETFILTER=y 200CONFIG_NETFILTER=y
199# CONFIG_NETFILTER_DEBUG is not set 201# CONFIG_NETFILTER_DEBUG is not set
202CONFIG_NETFILTER_NETLINK=y
203CONFIG_NETFILTER_NETLINK_QUEUE=m
204CONFIG_NETFILTER_NETLINK_LOG=m
200 205
201# 206#
202# IP: Netfilter Configuration 207# IP: Netfilter Configuration
@@ -204,11 +209,15 @@ CONFIG_NETFILTER=y
204CONFIG_IP_NF_CONNTRACK=m 209CONFIG_IP_NF_CONNTRACK=m
205CONFIG_IP_NF_CT_ACCT=y 210CONFIG_IP_NF_CT_ACCT=y
206CONFIG_IP_NF_CONNTRACK_MARK=y 211CONFIG_IP_NF_CONNTRACK_MARK=y
212CONFIG_IP_NF_CONNTRACK_EVENTS=y
213CONFIG_IP_NF_CONNTRACK_NETLINK=m
207CONFIG_IP_NF_CT_PROTO_SCTP=m 214CONFIG_IP_NF_CT_PROTO_SCTP=m
208CONFIG_IP_NF_FTP=m 215CONFIG_IP_NF_FTP=m
209CONFIG_IP_NF_IRC=m 216CONFIG_IP_NF_IRC=m
217# CONFIG_IP_NF_NETBIOS_NS is not set
210CONFIG_IP_NF_TFTP=m 218CONFIG_IP_NF_TFTP=m
211CONFIG_IP_NF_AMANDA=m 219CONFIG_IP_NF_AMANDA=m
220# CONFIG_IP_NF_PPTP is not set
212CONFIG_IP_NF_QUEUE=m 221CONFIG_IP_NF_QUEUE=m
213CONFIG_IP_NF_IPTABLES=m 222CONFIG_IP_NF_IPTABLES=m
214CONFIG_IP_NF_MATCH_LIMIT=m 223CONFIG_IP_NF_MATCH_LIMIT=m
@@ -232,14 +241,18 @@ CONFIG_IP_NF_MATCH_OWNER=m
232CONFIG_IP_NF_MATCH_ADDRTYPE=m 241CONFIG_IP_NF_MATCH_ADDRTYPE=m
233CONFIG_IP_NF_MATCH_REALM=m 242CONFIG_IP_NF_MATCH_REALM=m
234CONFIG_IP_NF_MATCH_SCTP=m 243CONFIG_IP_NF_MATCH_SCTP=m
244CONFIG_IP_NF_MATCH_DCCP=m
235CONFIG_IP_NF_MATCH_COMMENT=m 245CONFIG_IP_NF_MATCH_COMMENT=m
236CONFIG_IP_NF_MATCH_CONNMARK=m 246CONFIG_IP_NF_MATCH_CONNMARK=m
247CONFIG_IP_NF_MATCH_CONNBYTES=m
237CONFIG_IP_NF_MATCH_HASHLIMIT=m 248CONFIG_IP_NF_MATCH_HASHLIMIT=m
249CONFIG_IP_NF_MATCH_STRING=m
238CONFIG_IP_NF_FILTER=m 250CONFIG_IP_NF_FILTER=m
239CONFIG_IP_NF_TARGET_REJECT=m 251CONFIG_IP_NF_TARGET_REJECT=m
240CONFIG_IP_NF_TARGET_LOG=m 252CONFIG_IP_NF_TARGET_LOG=m
241CONFIG_IP_NF_TARGET_ULOG=m 253CONFIG_IP_NF_TARGET_ULOG=m
242CONFIG_IP_NF_TARGET_TCPMSS=m 254CONFIG_IP_NF_TARGET_TCPMSS=m
255CONFIG_IP_NF_TARGET_NFQUEUE=m
243CONFIG_IP_NF_NAT=m 256CONFIG_IP_NF_NAT=m
244CONFIG_IP_NF_NAT_NEEDED=y 257CONFIG_IP_NF_NAT_NEEDED=y
245CONFIG_IP_NF_TARGET_MASQUERADE=m 258CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -257,6 +270,7 @@ CONFIG_IP_NF_TARGET_ECN=m
257CONFIG_IP_NF_TARGET_DSCP=m 270CONFIG_IP_NF_TARGET_DSCP=m
258CONFIG_IP_NF_TARGET_MARK=m 271CONFIG_IP_NF_TARGET_MARK=m
259CONFIG_IP_NF_TARGET_CLASSIFY=m 272CONFIG_IP_NF_TARGET_CLASSIFY=m
273CONFIG_IP_NF_TARGET_TTL=m
260CONFIG_IP_NF_TARGET_CONNMARK=m 274CONFIG_IP_NF_TARGET_CONNMARK=m
261CONFIG_IP_NF_TARGET_CLUSTERIP=m 275CONFIG_IP_NF_TARGET_CLUSTERIP=m
262CONFIG_IP_NF_RAW=m 276CONFIG_IP_NF_RAW=m
@@ -266,6 +280,11 @@ CONFIG_IP_NF_ARPFILTER=m
266CONFIG_IP_NF_ARP_MANGLE=m 280CONFIG_IP_NF_ARP_MANGLE=m
267 281
268# 282#
283# DCCP Configuration (EXPERIMENTAL)
284#
285# CONFIG_IP_DCCP is not set
286
287#
269# SCTP Configuration (EXPERIMENTAL) 288# SCTP Configuration (EXPERIMENTAL)
270# 289#
271# CONFIG_IP_SCTP is not set 290# CONFIG_IP_SCTP is not set
@@ -292,6 +311,7 @@ CONFIG_NET_CLS_ROUTE=y
292# CONFIG_HAMRADIO is not set 311# CONFIG_HAMRADIO is not set
293# CONFIG_IRDA is not set 312# CONFIG_IRDA is not set
294# CONFIG_BT is not set 313# CONFIG_BT is not set
314# CONFIG_IEEE80211 is not set
295 315
296# 316#
297# Device Drivers 317# Device Drivers
@@ -306,6 +326,11 @@ CONFIG_FW_LOADER=y
306# CONFIG_DEBUG_DRIVER is not set 326# CONFIG_DEBUG_DRIVER is not set
307 327
308# 328#
329# Connector - unified userspace <-> kernelspace linker
330#
331# CONFIG_CONNECTOR is not set
332
333#
309# Memory Technology Devices (MTD) 334# Memory Technology Devices (MTD)
310# 335#
311# CONFIG_MTD is not set 336# CONFIG_MTD is not set
@@ -344,7 +369,6 @@ CONFIG_BLK_DEV_RAM=y
344CONFIG_BLK_DEV_RAM_COUNT=16 369CONFIG_BLK_DEV_RAM_COUNT=16
345CONFIG_BLK_DEV_RAM_SIZE=65536 370CONFIG_BLK_DEV_RAM_SIZE=65536
346CONFIG_BLK_DEV_INITRD=y 371CONFIG_BLK_DEV_INITRD=y
347CONFIG_INITRAMFS_SOURCE=""
348# CONFIG_CDROM_PKTCDVD is not set 372# CONFIG_CDROM_PKTCDVD is not set
349 373
350# 374#
@@ -422,6 +446,7 @@ CONFIG_IDEDMA_AUTO=y
422# 446#
423# SCSI device support 447# SCSI device support
424# 448#
449# CONFIG_RAID_ATTRS is not set
425CONFIG_SCSI=y 450CONFIG_SCSI=y
426CONFIG_SCSI_PROC_FS=y 451CONFIG_SCSI_PROC_FS=y
427 452
@@ -449,6 +474,7 @@ CONFIG_SCSI_CONSTANTS=y
449CONFIG_SCSI_SPI_ATTRS=y 474CONFIG_SCSI_SPI_ATTRS=y
450CONFIG_SCSI_FC_ATTRS=y 475CONFIG_SCSI_FC_ATTRS=y
451CONFIG_SCSI_ISCSI_ATTRS=m 476CONFIG_SCSI_ISCSI_ATTRS=m
477# CONFIG_SCSI_SAS_ATTRS is not set
452 478
453# 479#
454# SCSI low-level drivers 480# SCSI low-level drivers
@@ -462,10 +488,12 @@ CONFIG_SCSI_ISCSI_ATTRS=m
462# CONFIG_SCSI_AIC79XX is not set 488# CONFIG_SCSI_AIC79XX is not set
463# CONFIG_MEGARAID_NEWGEN is not set 489# CONFIG_MEGARAID_NEWGEN is not set
464# CONFIG_MEGARAID_LEGACY is not set 490# CONFIG_MEGARAID_LEGACY is not set
491# CONFIG_MEGARAID_SAS is not set
465CONFIG_SCSI_SATA=y 492CONFIG_SCSI_SATA=y
466# CONFIG_SCSI_SATA_AHCI is not set 493# CONFIG_SCSI_SATA_AHCI is not set
467CONFIG_SCSI_SATA_SVW=y 494CONFIG_SCSI_SATA_SVW=y
468# CONFIG_SCSI_ATA_PIIX is not set 495# CONFIG_SCSI_ATA_PIIX is not set
496# CONFIG_SCSI_SATA_MV is not set
469# CONFIG_SCSI_SATA_NV is not set 497# CONFIG_SCSI_SATA_NV is not set
470# CONFIG_SCSI_SATA_PROMISE is not set 498# CONFIG_SCSI_SATA_PROMISE is not set
471# CONFIG_SCSI_SATA_QSTOR is not set 499# CONFIG_SCSI_SATA_QSTOR is not set
@@ -535,6 +563,7 @@ CONFIG_DM_MULTIPATH_EMC=m
535# CONFIG_FUSION is not set 563# CONFIG_FUSION is not set
536# CONFIG_FUSION_SPI is not set 564# CONFIG_FUSION_SPI is not set
537# CONFIG_FUSION_FC is not set 565# CONFIG_FUSION_FC is not set
566# CONFIG_FUSION_SAS is not set
538 567
539# 568#
540# IEEE 1394 (FireWire) support 569# IEEE 1394 (FireWire) support
@@ -578,7 +607,6 @@ CONFIG_IEEE1394_AMDTP=m
578# 607#
579CONFIG_ADB_PMU=y 608CONFIG_ADB_PMU=y
580CONFIG_PMAC_SMU=y 609CONFIG_PMAC_SMU=y
581# CONFIG_PMAC_BACKLIGHT is not set
582CONFIG_THERM_PM72=y 610CONFIG_THERM_PM72=y
583 611
584# 612#
@@ -596,12 +624,18 @@ CONFIG_TUN=m
596# CONFIG_ARCNET is not set 624# CONFIG_ARCNET is not set
597 625
598# 626#
627# PHY device support
628#
629# CONFIG_PHYLIB is not set
630
631#
599# Ethernet (10 or 100Mbit) 632# Ethernet (10 or 100Mbit)
600# 633#
601CONFIG_NET_ETHERNET=y 634CONFIG_NET_ETHERNET=y
602CONFIG_MII=y 635CONFIG_MII=y
603# CONFIG_HAPPYMEAL is not set 636# CONFIG_HAPPYMEAL is not set
604CONFIG_SUNGEM=y 637CONFIG_SUNGEM=y
638# CONFIG_CASSINI is not set
605CONFIG_NET_VENDOR_3COM=y 639CONFIG_NET_VENDOR_3COM=y
606CONFIG_VORTEX=y 640CONFIG_VORTEX=y
607# CONFIG_TYPHOON is not set 641# CONFIG_TYPHOON is not set
@@ -630,6 +664,7 @@ CONFIG_E100=y
630# CONFIG_EPIC100 is not set 664# CONFIG_EPIC100 is not set
631# CONFIG_SUNDANCE is not set 665# CONFIG_SUNDANCE is not set
632# CONFIG_VIA_RHINE is not set 666# CONFIG_VIA_RHINE is not set
667# CONFIG_NET_POCKET is not set
633 668
634# 669#
635# Ethernet (1000 Mbit) 670# Ethernet (1000 Mbit)
@@ -643,16 +678,19 @@ CONFIG_E1000=y
643# CONFIG_HAMACHI is not set 678# CONFIG_HAMACHI is not set
644# CONFIG_YELLOWFIN is not set 679# CONFIG_YELLOWFIN is not set
645# CONFIG_R8169 is not set 680# CONFIG_R8169 is not set
681# CONFIG_SIS190 is not set
646# CONFIG_SKGE is not set 682# CONFIG_SKGE is not set
647# CONFIG_SK98LIN is not set 683# CONFIG_SK98LIN is not set
648# CONFIG_VIA_VELOCITY is not set 684# CONFIG_VIA_VELOCITY is not set
649CONFIG_TIGON3=y 685CONFIG_TIGON3=y
650# CONFIG_BNX2 is not set 686# CONFIG_BNX2 is not set
687# CONFIG_SPIDER_NET is not set
651# CONFIG_MV643XX_ETH is not set 688# CONFIG_MV643XX_ETH is not set
652 689
653# 690#
654# Ethernet (10000 Mbit) 691# Ethernet (10000 Mbit)
655# 692#
693# CONFIG_CHELSIO_T1 is not set
656CONFIG_IXGB=m 694CONFIG_IXGB=m
657# CONFIG_IXGB_NAPI is not set 695# CONFIG_IXGB_NAPI is not set
658# CONFIG_S2IO is not set 696# CONFIG_S2IO is not set
@@ -838,8 +876,8 @@ CONFIG_I2C_AMD8111=y
838# CONFIG_I2C_I801 is not set 876# CONFIG_I2C_I801 is not set
839# CONFIG_I2C_I810 is not set 877# CONFIG_I2C_I810 is not set
840# CONFIG_I2C_PIIX4 is not set 878# CONFIG_I2C_PIIX4 is not set
841# CONFIG_I2C_ISA is not set
842CONFIG_I2C_KEYWEST=y 879CONFIG_I2C_KEYWEST=y
880CONFIG_I2C_PMAC_SMU=y
843# CONFIG_I2C_NFORCE2 is not set 881# CONFIG_I2C_NFORCE2 is not set
844# CONFIG_I2C_PARPORT is not set 882# CONFIG_I2C_PARPORT is not set
845# CONFIG_I2C_PARPORT_LIGHT is not set 883# CONFIG_I2C_PARPORT_LIGHT is not set
@@ -854,7 +892,6 @@ CONFIG_I2C_KEYWEST=y
854# CONFIG_I2C_VIAPRO is not set 892# CONFIG_I2C_VIAPRO is not set
855# CONFIG_I2C_VOODOO3 is not set 893# CONFIG_I2C_VOODOO3 is not set
856# CONFIG_I2C_PCA_ISA is not set 894# CONFIG_I2C_PCA_ISA is not set
857# CONFIG_I2C_SENSOR is not set
858 895
859# 896#
860# Miscellaneous I2C Chip support 897# Miscellaneous I2C Chip support
@@ -881,12 +918,17 @@ CONFIG_I2C_KEYWEST=y
881# Hardware Monitoring support 918# Hardware Monitoring support
882# 919#
883# CONFIG_HWMON is not set 920# CONFIG_HWMON is not set
921# CONFIG_HWMON_VID is not set
884 922
885# 923#
886# Misc devices 924# Misc devices
887# 925#
888 926
889# 927#
928# Multimedia Capabilities Port drivers
929#
930
931#
890# Multimedia devices 932# Multimedia devices
891# 933#
892# CONFIG_VIDEO_DEV is not set 934# CONFIG_VIDEO_DEV is not set
@@ -939,6 +981,7 @@ CONFIG_FB_RADEON_I2C=y
939# CONFIG_FB_KYRO is not set 981# CONFIG_FB_KYRO is not set
940# CONFIG_FB_3DFX is not set 982# CONFIG_FB_3DFX is not set
941# CONFIG_FB_VOODOO1 is not set 983# CONFIG_FB_VOODOO1 is not set
984# CONFIG_FB_CYBLA is not set
942# CONFIG_FB_TRIDENT is not set 985# CONFIG_FB_TRIDENT is not set
943# CONFIG_FB_S1D13XXX is not set 986# CONFIG_FB_S1D13XXX is not set
944# CONFIG_FB_VIRTUAL is not set 987# CONFIG_FB_VIRTUAL is not set
@@ -1020,6 +1063,7 @@ CONFIG_USB_STORAGE=m
1020# CONFIG_USB_STORAGE_SDDR09 is not set 1063# CONFIG_USB_STORAGE_SDDR09 is not set
1021# CONFIG_USB_STORAGE_SDDR55 is not set 1064# CONFIG_USB_STORAGE_SDDR55 is not set
1022# CONFIG_USB_STORAGE_JUMPSHOT is not set 1065# CONFIG_USB_STORAGE_JUMPSHOT is not set
1066# CONFIG_USB_STORAGE_ONETOUCH is not set
1023 1067
1024# 1068#
1025# USB Input Devices 1069# USB Input Devices
@@ -1036,9 +1080,11 @@ CONFIG_USB_HIDDEV=y
1036# CONFIG_USB_MTOUCH is not set 1080# CONFIG_USB_MTOUCH is not set
1037# CONFIG_USB_ITMTOUCH is not set 1081# CONFIG_USB_ITMTOUCH is not set
1038# CONFIG_USB_EGALAX is not set 1082# CONFIG_USB_EGALAX is not set
1083# CONFIG_USB_YEALINK is not set
1039# CONFIG_USB_XPAD is not set 1084# CONFIG_USB_XPAD is not set
1040# CONFIG_USB_ATI_REMOTE is not set 1085# CONFIG_USB_ATI_REMOTE is not set
1041# CONFIG_USB_KEYSPAN_REMOTE is not set 1086# CONFIG_USB_KEYSPAN_REMOTE is not set
1087# CONFIG_USB_APPLETOUCH is not set
1042 1088
1043# 1089#
1044# USB Imaging devices 1090# USB Imaging devices
@@ -1111,7 +1157,8 @@ CONFIG_USB_PEGASUS=y
1111# InfiniBand support 1157# InfiniBand support
1112# 1158#
1113CONFIG_INFINIBAND=m 1159CONFIG_INFINIBAND=m
1114CONFIG_INFINIBAND_USER_VERBS=m 1160# CONFIG_INFINIBAND_USER_MAD is not set
1161# CONFIG_INFINIBAND_USER_ACCESS is not set
1115CONFIG_INFINIBAND_MTHCA=m 1162CONFIG_INFINIBAND_MTHCA=m
1116# CONFIG_INFINIBAND_MTHCA_DEBUG is not set 1163# CONFIG_INFINIBAND_MTHCA_DEBUG is not set
1117CONFIG_INFINIBAND_IPOIB=m 1164CONFIG_INFINIBAND_IPOIB=m
@@ -1149,16 +1196,12 @@ CONFIG_JFS_SECURITY=y
1149# CONFIG_JFS_DEBUG is not set 1196# CONFIG_JFS_DEBUG is not set
1150# CONFIG_JFS_STATISTICS is not set 1197# CONFIG_JFS_STATISTICS is not set
1151CONFIG_FS_POSIX_ACL=y 1198CONFIG_FS_POSIX_ACL=y
1152
1153#
1154# XFS support
1155#
1156CONFIG_XFS_FS=m 1199CONFIG_XFS_FS=m
1157CONFIG_XFS_EXPORT=y 1200CONFIG_XFS_EXPORT=y
1158# CONFIG_XFS_RT is not set
1159# CONFIG_XFS_QUOTA is not set 1201# CONFIG_XFS_QUOTA is not set
1160CONFIG_XFS_SECURITY=y 1202CONFIG_XFS_SECURITY=y
1161CONFIG_XFS_POSIX_ACL=y 1203CONFIG_XFS_POSIX_ACL=y
1204# CONFIG_XFS_RT is not set
1162# CONFIG_MINIX_FS is not set 1205# CONFIG_MINIX_FS is not set
1163# CONFIG_ROMFS_FS is not set 1206# CONFIG_ROMFS_FS is not set
1164CONFIG_INOTIFY=y 1207CONFIG_INOTIFY=y
@@ -1166,6 +1209,7 @@ CONFIG_INOTIFY=y
1166CONFIG_DNOTIFY=y 1209CONFIG_DNOTIFY=y
1167CONFIG_AUTOFS_FS=y 1210CONFIG_AUTOFS_FS=y
1168# CONFIG_AUTOFS4_FS is not set 1211# CONFIG_AUTOFS4_FS is not set
1212# CONFIG_FUSE_FS is not set
1169 1213
1170# 1214#
1171# CD-ROM/DVD Filesystems 1215# CD-ROM/DVD Filesystems
@@ -1192,14 +1236,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1192CONFIG_PROC_FS=y 1236CONFIG_PROC_FS=y
1193CONFIG_PROC_KCORE=y 1237CONFIG_PROC_KCORE=y
1194CONFIG_SYSFS=y 1238CONFIG_SYSFS=y
1195CONFIG_DEVPTS_FS_XATTR=y
1196CONFIG_DEVPTS_FS_SECURITY=y
1197CONFIG_TMPFS=y 1239CONFIG_TMPFS=y
1198CONFIG_TMPFS_XATTR=y
1199CONFIG_TMPFS_SECURITY=y
1200CONFIG_HUGETLBFS=y 1240CONFIG_HUGETLBFS=y
1201CONFIG_HUGETLB_PAGE=y 1241CONFIG_HUGETLB_PAGE=y
1202CONFIG_RAMFS=y 1242CONFIG_RAMFS=y
1243# CONFIG_RELAYFS_FS is not set
1203 1244
1204# 1245#
1205# Miscellaneous filesystems 1246# Miscellaneous filesystems
@@ -1250,6 +1291,7 @@ CONFIG_CIFS_POSIX=y
1250# CONFIG_NCP_FS is not set 1291# CONFIG_NCP_FS is not set
1251# CONFIG_CODA_FS is not set 1292# CONFIG_CODA_FS is not set
1252# CONFIG_AFS_FS is not set 1293# CONFIG_AFS_FS is not set
1294# CONFIG_9P_FS is not set
1253 1295
1254# 1296#
1255# Partition Types 1297# Partition Types
@@ -1328,6 +1370,7 @@ CONFIG_OPROFILE=y
1328CONFIG_DEBUG_KERNEL=y 1370CONFIG_DEBUG_KERNEL=y
1329CONFIG_MAGIC_SYSRQ=y 1371CONFIG_MAGIC_SYSRQ=y
1330CONFIG_LOG_BUF_SHIFT=17 1372CONFIG_LOG_BUF_SHIFT=17
1373CONFIG_DETECT_SOFTLOCKUP=y
1331# CONFIG_SCHEDSTATS is not set 1374# CONFIG_SCHEDSTATS is not set
1332# CONFIG_DEBUG_SLAB is not set 1375# CONFIG_DEBUG_SLAB is not set
1333# CONFIG_DEBUG_SPINLOCK is not set 1376# CONFIG_DEBUG_SPINLOCK is not set
@@ -1387,7 +1430,12 @@ CONFIG_CRYPTO_TEST=m
1387# Library routines 1430# Library routines
1388# 1431#
1389CONFIG_CRC_CCITT=m 1432CONFIG_CRC_CCITT=m
1433# CONFIG_CRC16 is not set
1390CONFIG_CRC32=y 1434CONFIG_CRC32=y
1391CONFIG_LIBCRC32C=m 1435CONFIG_LIBCRC32C=m
1392CONFIG_ZLIB_INFLATE=y 1436CONFIG_ZLIB_INFLATE=y
1393CONFIG_ZLIB_DEFLATE=m 1437CONFIG_ZLIB_DEFLATE=m
1438CONFIG_TEXTSEARCH=y
1439CONFIG_TEXTSEARCH_KMP=m
1440CONFIG_TEXTSEARCH_BM=m
1441CONFIG_TEXTSEARCH_FSM=m
diff --git a/arch/ppc64/kernel/bpa_iommu.c b/arch/ppc64/kernel/bpa_iommu.c
index f33a7bccb0d7..5f2460090e03 100644
--- a/arch/ppc64/kernel/bpa_iommu.c
+++ b/arch/ppc64/kernel/bpa_iommu.c
@@ -99,7 +99,11 @@ get_iost_entry(unsigned long iopt_base, unsigned long io_address, unsigned page_
99 break; 99 break;
100 100
101 default: /* not a known compile time constant */ 101 default: /* not a known compile time constant */
102 BUILD_BUG_ON(1); 102 {
103 /* BUILD_BUG_ON() is not usable here */
104 extern void __get_iost_entry_bad_page_size(void);
105 __get_iost_entry_bad_page_size();
106 }
103 break; 107 break;
104 } 108 }
105 109
@@ -306,7 +310,7 @@ static void bpa_map_iommu(void)
306 310
307 311
308static void *bpa_alloc_coherent(struct device *hwdev, size_t size, 312static void *bpa_alloc_coherent(struct device *hwdev, size_t size,
309 dma_addr_t *dma_handle, unsigned int __nocast flag) 313 dma_addr_t *dma_handle, gfp_t flag)
310{ 314{
311 void *ret; 315 void *ret;
312 316
diff --git a/arch/ppc64/kernel/dma.c b/arch/ppc64/kernel/dma.c
index 4da8e31b2b61..7c3419656ccc 100644
--- a/arch/ppc64/kernel/dma.c
+++ b/arch/ppc64/kernel/dma.c
@@ -53,7 +53,7 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
53EXPORT_SYMBOL(dma_set_mask); 53EXPORT_SYMBOL(dma_set_mask);
54 54
55void *dma_alloc_coherent(struct device *dev, size_t size, 55void *dma_alloc_coherent(struct device *dev, size_t size,
56 dma_addr_t *dma_handle, unsigned int __nocast flag) 56 dma_addr_t *dma_handle, gfp_t flag)
57{ 57{
58 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 58 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
59 59
diff --git a/arch/ppc64/kernel/iSeries_htab.c b/arch/ppc64/kernel/iSeries_htab.c
index 2192055a90a0..073b76661747 100644
--- a/arch/ppc64/kernel/iSeries_htab.c
+++ b/arch/ppc64/kernel/iSeries_htab.c
@@ -66,7 +66,7 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
66 } 66 }
67 67
68 if (slot < 0) { /* MSB set means secondary group */ 68 if (slot < 0) { /* MSB set means secondary group */
69 vflags |= HPTE_V_VALID; 69 vflags |= HPTE_V_SECONDARY;
70 secondary = 1; 70 secondary = 1;
71 slot &= 0x7fffffffffffffff; 71 slot &= 0x7fffffffffffffff;
72 } 72 }
diff --git a/arch/ppc64/kernel/iommu.c b/arch/ppc64/kernel/iommu.c
index 9032b6bfe036..4d9b4388918b 100644
--- a/arch/ppc64/kernel/iommu.c
+++ b/arch/ppc64/kernel/iommu.c
@@ -519,7 +519,7 @@ void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
519 * to the dma address (mapping) of the first page. 519 * to the dma address (mapping) of the first page.
520 */ 520 */
521void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size, 521void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
522 dma_addr_t *dma_handle, unsigned int __nocast flag) 522 dma_addr_t *dma_handle, gfp_t flag)
523{ 523{
524 void *ret = NULL; 524 void *ret = NULL;
525 dma_addr_t mapping; 525 dma_addr_t mapping;
diff --git a/arch/ppc64/kernel/kprobes.c b/arch/ppc64/kernel/kprobes.c
index 7e80d49c589a..9c6facc24f70 100644
--- a/arch/ppc64/kernel/kprobes.c
+++ b/arch/ppc64/kernel/kprobes.c
@@ -59,9 +59,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
59 59
60 /* insn must be on a special executable page on ppc64 */ 60 /* insn must be on a special executable page on ppc64 */
61 if (!ret) { 61 if (!ret) {
62 up(&kprobe_mutex);
63 p->ainsn.insn = get_insn_slot();
64 down(&kprobe_mutex); 62 down(&kprobe_mutex);
63 p->ainsn.insn = get_insn_slot();
64 up(&kprobe_mutex);
65 if (!p->ainsn.insn) 65 if (!p->ainsn.insn)
66 ret = -ENOMEM; 66 ret = -ENOMEM;
67 } 67 }
@@ -90,9 +90,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
90 90
91void __kprobes arch_remove_kprobe(struct kprobe *p) 91void __kprobes arch_remove_kprobe(struct kprobe *p)
92{ 92{
93 up(&kprobe_mutex);
94 free_insn_slot(p->ainsn.insn);
95 down(&kprobe_mutex); 93 down(&kprobe_mutex);
94 free_insn_slot(p->ainsn.insn);
95 up(&kprobe_mutex);
96} 96}
97 97
98static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 98static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
diff --git a/arch/ppc64/kernel/machine_kexec.c b/arch/ppc64/kernel/machine_kexec.c
index 4775f12a013c..bf7cc4f8210f 100644
--- a/arch/ppc64/kernel/machine_kexec.c
+++ b/arch/ppc64/kernel/machine_kexec.c
@@ -205,6 +205,7 @@ static void kexec_prepare_cpus(void)
205 continue; 205 continue;
206 206
207 while (paca[i].hw_cpu_id != -1) { 207 while (paca[i].hw_cpu_id != -1) {
208 barrier();
208 if (!cpu_possible(i)) { 209 if (!cpu_possible(i)) {
209 printk("kexec: cpu %d hw_cpu_id %d is not" 210 printk("kexec: cpu %d hw_cpu_id %d is not"
210 " possible, ignoring\n", 211 " possible, ignoring\n",
diff --git a/arch/ppc64/kernel/module.c b/arch/ppc64/kernel/module.c
index c683bf88e690..928b8581fcb0 100644
--- a/arch/ppc64/kernel/module.c
+++ b/arch/ppc64/kernel/module.c
@@ -341,6 +341,19 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
341 *(unsigned long *)location = my_r2(sechdrs, me); 341 *(unsigned long *)location = my_r2(sechdrs, me);
342 break; 342 break;
343 343
344 case R_PPC64_TOC16:
345 /* Subtact TOC pointer */
346 value -= my_r2(sechdrs, me);
347 if (value + 0x8000 > 0xffff) {
348 printk("%s: bad TOC16 relocation (%lu)\n",
349 me->name, value);
350 return -ENOEXEC;
351 }
352 *((uint16_t *) location)
353 = (*((uint16_t *) location) & ~0xffff)
354 | (value & 0xffff);
355 break;
356
344 case R_PPC64_TOC16_DS: 357 case R_PPC64_TOC16_DS:
345 /* Subtact TOC pointer */ 358 /* Subtact TOC pointer */
346 value -= my_r2(sechdrs, me); 359 value -= my_r2(sechdrs, me);
diff --git a/arch/ppc64/kernel/mpic.c b/arch/ppc64/kernel/mpic.c
index cc262a05ddb4..5f5bc73754d9 100644
--- a/arch/ppc64/kernel/mpic.c
+++ b/arch/ppc64/kernel/mpic.c
@@ -506,8 +506,8 @@ struct mpic * __init mpic_alloc(unsigned long phys_addr,
506 mpic->senses_count = senses_count; 506 mpic->senses_count = senses_count;
507 507
508 /* Map the global registers */ 508 /* Map the global registers */
509 mpic->gregs = ioremap(phys_addr + MPIC_GREG_BASE, 0x1000); 509 mpic->gregs = ioremap(phys_addr + MPIC_GREG_BASE, 0x2000);
510 mpic->tmregs = mpic->gregs + (MPIC_TIMER_BASE >> 2); 510 mpic->tmregs = mpic->gregs + ((MPIC_TIMER_BASE - MPIC_GREG_BASE) >> 2);
511 BUG_ON(mpic->gregs == NULL); 511 BUG_ON(mpic->gregs == NULL);
512 512
513 /* Reset */ 513 /* Reset */
diff --git a/arch/ppc64/kernel/of_device.c b/arch/ppc64/kernel/of_device.c
index da580812ddfe..9f200f0f2ad5 100644
--- a/arch/ppc64/kernel/of_device.c
+++ b/arch/ppc64/kernel/of_device.c
@@ -233,7 +233,9 @@ void of_device_unregister(struct of_device *ofdev)
233 device_unregister(&ofdev->dev); 233 device_unregister(&ofdev->dev);
234} 234}
235 235
236struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id) 236struct of_device* of_platform_device_create(struct device_node *np,
237 const char *bus_id,
238 struct device *parent)
237{ 239{
238 struct of_device *dev; 240 struct of_device *dev;
239 241
@@ -245,7 +247,7 @@ struct of_device* of_platform_device_create(struct device_node *np, const char *
245 dev->node = np; 247 dev->node = np;
246 dev->dma_mask = 0xffffffffUL; 248 dev->dma_mask = 0xffffffffUL;
247 dev->dev.dma_mask = &dev->dma_mask; 249 dev->dev.dma_mask = &dev->dma_mask;
248 dev->dev.parent = NULL; 250 dev->dev.parent = parent;
249 dev->dev.bus = &of_platform_bus_type; 251 dev->dev.bus = &of_platform_bus_type;
250 dev->dev.release = of_release_dev; 252 dev->dev.release = of_release_dev;
251 253
@@ -259,6 +261,7 @@ struct of_device* of_platform_device_create(struct device_node *np, const char *
259 return dev; 261 return dev;
260} 262}
261 263
264
262EXPORT_SYMBOL(of_match_device); 265EXPORT_SYMBOL(of_match_device);
263EXPORT_SYMBOL(of_platform_bus_type); 266EXPORT_SYMBOL(of_platform_bus_type);
264EXPORT_SYMBOL(of_register_driver); 267EXPORT_SYMBOL(of_register_driver);
diff --git a/arch/ppc64/kernel/pSeries_iommu.c b/arch/ppc64/kernel/pSeries_iommu.c
index f0fd7fbd6531..d17f0108a032 100644
--- a/arch/ppc64/kernel/pSeries_iommu.c
+++ b/arch/ppc64/kernel/pSeries_iommu.c
@@ -265,8 +265,10 @@ static void iommu_table_setparms(struct pci_controller *phb,
265 tbl->it_offset = phb->dma_window_base_cur >> PAGE_SHIFT; 265 tbl->it_offset = phb->dma_window_base_cur >> PAGE_SHIFT;
266 266
267 /* Test if we are going over 2GB of DMA space */ 267 /* Test if we are going over 2GB of DMA space */
268 if (phb->dma_window_base_cur + phb->dma_window_size > (1L << 31)) 268 if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) {
269 udbg_printf("PCI_DMA: Unexpected number of IOAs under this PHB.\n");
269 panic("PCI_DMA: Unexpected number of IOAs under this PHB.\n"); 270 panic("PCI_DMA: Unexpected number of IOAs under this PHB.\n");
271 }
270 272
271 phb->dma_window_base_cur += phb->dma_window_size; 273 phb->dma_window_base_cur += phb->dma_window_size;
272 274
@@ -310,92 +312,85 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb,
310 312
311static void iommu_bus_setup_pSeries(struct pci_bus *bus) 313static void iommu_bus_setup_pSeries(struct pci_bus *bus)
312{ 314{
313 struct device_node *dn, *pdn; 315 struct device_node *dn;
314 struct pci_dn *pci;
315 struct iommu_table *tbl; 316 struct iommu_table *tbl;
317 struct device_node *isa_dn, *isa_dn_orig;
318 struct device_node *tmp;
319 struct pci_dn *pci;
320 int children;
316 321
317 DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self); 322 DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self);
318 323
319 /* For each (root) bus, we carve up the available DMA space in 256MB 324 dn = pci_bus_to_OF_node(bus);
320 * pieces. Since each piece is used by one (sub) bus/device, that would 325 pci = PCI_DN(dn);
321 * give a maximum of 7 devices per PHB. In most cases, this is plenty. 326
322 * 327 if (bus->self) {
323 * The exception is on Python PHBs (pre-POWER4). Here we don't have EADS 328 /* This is not a root bus, any setup will be done for the
324 * bridges below the PHB to allocate the sectioned tables to, so instead 329 * device-side of the bridge in iommu_dev_setup_pSeries().
325 * we allocate a 1GB table at the PHB level. 330 */
331 return;
332 }
333
334 /* Check if the ISA bus on the system is under
335 * this PHB.
326 */ 336 */
337 isa_dn = isa_dn_orig = of_find_node_by_type(NULL, "isa");
327 338
328 dn = pci_bus_to_OF_node(bus); 339 while (isa_dn && isa_dn != dn)
329 pci = dn->data; 340 isa_dn = isa_dn->parent;
330 341
331 if (!bus->self) { 342 if (isa_dn_orig)
332 /* Root bus */ 343 of_node_put(isa_dn_orig);
333 if (is_python(dn)) {
334 unsigned int *iohole;
335
336 DBG("Python root bus %s\n", bus->name);
337
338 iohole = (unsigned int *)get_property(dn, "io-hole", 0);
339
340 if (iohole) {
341 /* On first bus we need to leave room for the
342 * ISA address space. Just skip the first 256MB
343 * alltogether. This leaves 768MB for the window.
344 */
345 DBG("PHB has io-hole, reserving 256MB\n");
346 pci->phb->dma_window_size = 3 << 28;
347 pci->phb->dma_window_base_cur = 1 << 28;
348 } else {
349 /* 1GB window by default */
350 pci->phb->dma_window_size = 1 << 30;
351 pci->phb->dma_window_base_cur = 0;
352 }
353
354 tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
355
356 iommu_table_setparms(pci->phb, dn, tbl);
357 pci->iommu_table = iommu_init_table(tbl);
358 } else {
359 /* Do a 128MB table at root. This is used for the IDE
360 * controller on some SMP-mode POWER4 machines. It
361 * doesn't hurt to allocate it on other machines
362 * -- it'll just be unused since new tables are
363 * allocated on the EADS level.
364 *
365 * Allocate at offset 128MB to avoid having to deal
366 * with ISA holes; 128MB table for IDE is plenty.
367 */
368 pci->phb->dma_window_size = 1 << 27;
369 pci->phb->dma_window_base_cur = 1 << 27;
370
371 tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
372
373 iommu_table_setparms(pci->phb, dn, tbl);
374 pci->iommu_table = iommu_init_table(tbl);
375
376 /* All child buses have 256MB tables */
377 pci->phb->dma_window_size = 1 << 28;
378 }
379 } else {
380 pdn = pci_bus_to_OF_node(bus->parent);
381 344
382 if (!bus->parent->self && !is_python(pdn)) { 345 /* Count number of direct PCI children of the PHB.
383 struct iommu_table *tbl; 346 * All PCI device nodes have class-code property, so it's
384 /* First child and not python means this is the EADS 347 * an easy way to find them.
385 * level. Allocate new table for this slot with 256MB 348 */
386 * window. 349 for (children = 0, tmp = dn->child; tmp; tmp = tmp->sibling)
387 */ 350 if (get_property(tmp, "class-code", NULL))
351 children++;
388 352
389 tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); 353 DBG("Children: %d\n", children);
390 354
391 iommu_table_setparms(pci->phb, dn, tbl); 355 /* Calculate amount of DMA window per slot. Each window must be
356 * a power of two (due to pci_alloc_consistent requirements).
357 *
358 * Keep 256MB aside for PHBs with ISA.
359 */
392 360
393 pci->iommu_table = iommu_init_table(tbl); 361 if (!isa_dn) {
394 } else { 362 /* No ISA/IDE - just set window size and return */
395 /* Lower than first child or under python, use parent table */ 363 pci->phb->dma_window_size = 0x80000000ul; /* To be divided */
396 pci->iommu_table = PCI_DN(pdn)->iommu_table; 364
397 } 365 while (pci->phb->dma_window_size * children > 0x80000000ul)
366 pci->phb->dma_window_size >>= 1;
367 DBG("No ISA/IDE, window size is 0x%lx\n",
368 pci->phb->dma_window_size);
369 pci->phb->dma_window_base_cur = 0;
370
371 return;
398 } 372 }
373
374 /* If we have ISA, then we probably have an IDE
375 * controller too. Allocate a 128MB table but
376 * skip the first 128MB to avoid stepping on ISA
377 * space.
378 */
379 pci->phb->dma_window_size = 0x8000000ul;
380 pci->phb->dma_window_base_cur = 0x8000000ul;
381
382 tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
383
384 iommu_table_setparms(pci->phb, dn, tbl);
385 pci->iommu_table = iommu_init_table(tbl);
386
387 /* Divide the rest (1.75GB) among the children */
388 pci->phb->dma_window_size = 0x80000000ul;
389 while (pci->phb->dma_window_size * children > 0x70000000ul)
390 pci->phb->dma_window_size >>= 1;
391
392 DBG("ISA/IDE, window size is 0x%lx\n", pci->phb->dma_window_size);
393
399} 394}
400 395
401 396
@@ -446,21 +441,36 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
446static void iommu_dev_setup_pSeries(struct pci_dev *dev) 441static void iommu_dev_setup_pSeries(struct pci_dev *dev)
447{ 442{
448 struct device_node *dn, *mydn; 443 struct device_node *dn, *mydn;
444 struct iommu_table *tbl;
445
446 DBG("iommu_dev_setup_pSeries, dev %p (%s)\n", dev, pci_name(dev));
449 447
450 DBG("iommu_dev_setup_pSeries, dev %p (%s)\n", dev, dev->pretty_name);
451 /* Now copy the iommu_table ptr from the bus device down to the
452 * pci device_node. This means get_iommu_table() won't need to search
453 * up the device tree to find it.
454 */
455 mydn = dn = pci_device_to_OF_node(dev); 448 mydn = dn = pci_device_to_OF_node(dev);
456 449
450 /* If we're the direct child of a root bus, then we need to allocate
451 * an iommu table ourselves. The bus setup code should have setup
452 * the window sizes already.
453 */
454 if (!dev->bus->self) {
455 DBG(" --> first child, no bridge. Allocating iommu table.\n");
456 tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
457 iommu_table_setparms(PCI_DN(dn)->phb, dn, tbl);
458 PCI_DN(mydn)->iommu_table = iommu_init_table(tbl);
459
460 return;
461 }
462
463 /* If this device is further down the bus tree, search upwards until
464 * an already allocated iommu table is found and use that.
465 */
466
457 while (dn && dn->data && PCI_DN(dn)->iommu_table == NULL) 467 while (dn && dn->data && PCI_DN(dn)->iommu_table == NULL)
458 dn = dn->parent; 468 dn = dn->parent;
459 469
460 if (dn && dn->data) { 470 if (dn && dn->data) {
461 PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table; 471 PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table;
462 } else { 472 } else {
463 DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, dev->pretty_name); 473 DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, pci_name(dev));
464 } 474 }
465} 475}
466 476
@@ -494,7 +504,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
494 int *dma_window = NULL; 504 int *dma_window = NULL;
495 struct pci_dn *pci; 505 struct pci_dn *pci;
496 506
497 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, dev->pretty_name); 507 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev));
498 508
499 /* dev setup for LPAR is a little tricky, since the device tree might 509 /* dev setup for LPAR is a little tricky, since the device tree might
500 * contain the dma-window properties per-device and not neccesarily 510 * contain the dma-window properties per-device and not neccesarily
@@ -516,9 +526,8 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
516 * slots on POWER4 machines. 526 * slots on POWER4 machines.
517 */ 527 */
518 if (dma_window == NULL || pdn->parent == NULL) { 528 if (dma_window == NULL || pdn->parent == NULL) {
519 /* Fall back to regular (non-LPAR) dev setup */ 529 DBG("No dma window for device, linking to parent\n");
520 DBG("No dma window for device, falling back to regular setup\n"); 530 PCI_DN(dn)->iommu_table = PCI_DN(pdn)->iommu_table;
521 iommu_dev_setup_pSeries(dev);
522 return; 531 return;
523 } else { 532 } else {
524 DBG("Found DMA window, allocating table\n"); 533 DBG("Found DMA window, allocating table\n");
diff --git a/arch/ppc64/kernel/pSeries_pci.c b/arch/ppc64/kernel/pSeries_pci.c
index 1f5f141fb7a1..928f8febdb3b 100644
--- a/arch/ppc64/kernel/pSeries_pci.c
+++ b/arch/ppc64/kernel/pSeries_pci.c
@@ -32,7 +32,7 @@
32 32
33#include "pci.h" 33#include "pci.h"
34 34
35static int __initdata s7a_workaround = -1; 35static int __devinitdata s7a_workaround = -1;
36 36
37#if 0 37#if 0
38void pcibios_name_device(struct pci_dev *dev) 38void pcibios_name_device(struct pci_dev *dev)
@@ -60,7 +60,7 @@ void pcibios_name_device(struct pci_dev *dev)
60DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device); 60DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);
61#endif 61#endif
62 62
63static void __init check_s7a(void) 63static void __devinit check_s7a(void)
64{ 64{
65 struct device_node *root; 65 struct device_node *root;
66 char *model; 66 char *model;
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
index 861138ad092c..ff4be1da69d5 100644
--- a/arch/ppc64/kernel/pci.c
+++ b/arch/ppc64/kernel/pci.c
@@ -246,11 +246,14 @@ static unsigned int pci_parse_of_flags(u32 addr0)
246 unsigned int flags = 0; 246 unsigned int flags = 0;
247 247
248 if (addr0 & 0x02000000) { 248 if (addr0 & 0x02000000) {
249 flags |= IORESOURCE_MEM; 249 flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY;
250 flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64;
251 flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M;
250 if (addr0 & 0x40000000) 252 if (addr0 & 0x40000000)
251 flags |= IORESOURCE_PREFETCH; 253 flags |= IORESOURCE_PREFETCH
254 | PCI_BASE_ADDRESS_MEM_PREFETCH;
252 } else if (addr0 & 0x01000000) 255 } else if (addr0 & 0x01000000)
253 flags |= IORESOURCE_IO; 256 flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO;
254 return flags; 257 return flags;
255} 258}
256 259
diff --git a/arch/ppc64/kernel/pci_direct_iommu.c b/arch/ppc64/kernel/pci_direct_iommu.c
index b8f7f58824f4..54055c81017a 100644
--- a/arch/ppc64/kernel/pci_direct_iommu.c
+++ b/arch/ppc64/kernel/pci_direct_iommu.c
@@ -31,7 +31,7 @@
31#include "pci.h" 31#include "pci.h"
32 32
33static void *pci_direct_alloc_coherent(struct device *hwdev, size_t size, 33static void *pci_direct_alloc_coherent(struct device *hwdev, size_t size,
34 dma_addr_t *dma_handle, unsigned int __nocast flag) 34 dma_addr_t *dma_handle, gfp_t flag)
35{ 35{
36 void *ret; 36 void *ret;
37 37
diff --git a/arch/ppc64/kernel/pci_iommu.c b/arch/ppc64/kernel/pci_iommu.c
index 14647e09c9cd..d9e33b7d4203 100644
--- a/arch/ppc64/kernel/pci_iommu.c
+++ b/arch/ppc64/kernel/pci_iommu.c
@@ -76,7 +76,7 @@ static inline struct iommu_table *devnode_table(struct device *dev)
76 * to the dma address (mapping) of the first page. 76 * to the dma address (mapping) of the first page.
77 */ 77 */
78static void *pci_iommu_alloc_coherent(struct device *hwdev, size_t size, 78static void *pci_iommu_alloc_coherent(struct device *hwdev, size_t size,
79 dma_addr_t *dma_handle, unsigned int __nocast flag) 79 dma_addr_t *dma_handle, gfp_t flag)
80{ 80{
81 return iommu_alloc_coherent(devnode_table(hwdev), size, dma_handle, 81 return iommu_alloc_coherent(devnode_table(hwdev), size, dma_handle,
82 flag); 82 flag);
diff --git a/arch/ppc64/kernel/pmac_setup.c b/arch/ppc64/kernel/pmac_setup.c
index 325426c7bed0..fa8121d53b89 100644
--- a/arch/ppc64/kernel/pmac_setup.c
+++ b/arch/ppc64/kernel/pmac_setup.c
@@ -115,7 +115,7 @@ static void __pmac pmac_show_cpuinfo(struct seq_file *m)
115 115
116 /* find motherboard type */ 116 /* find motherboard type */
117 seq_printf(m, "machine\t\t: "); 117 seq_printf(m, "machine\t\t: ");
118 np = find_devices("device-tree"); 118 np = of_find_node_by_path("/");
119 if (np != NULL) { 119 if (np != NULL) {
120 pp = (char *) get_property(np, "model", NULL); 120 pp = (char *) get_property(np, "model", NULL);
121 if (pp != NULL) 121 if (pp != NULL)
@@ -133,6 +133,7 @@ static void __pmac pmac_show_cpuinfo(struct seq_file *m)
133 } 133 }
134 seq_printf(m, "\n"); 134 seq_printf(m, "\n");
135 } 135 }
136 of_node_put(np);
136 } else 137 } else
137 seq_printf(m, "PowerMac\n"); 138 seq_printf(m, "PowerMac\n");
138 139
@@ -434,15 +435,23 @@ static int pmac_check_legacy_ioport(unsigned int baseport)
434 435
435static int __init pmac_declare_of_platform_devices(void) 436static int __init pmac_declare_of_platform_devices(void)
436{ 437{
437 struct device_node *np; 438 struct device_node *np, *npp;
438 439
439 np = find_devices("u3"); 440 npp = of_find_node_by_name(NULL, "u3");
440 if (np) { 441 if (npp) {
441 for (np = np->child; np != NULL; np = np->sibling) 442 for (np = NULL; (np = of_get_next_child(npp, np)) != NULL;) {
442 if (strncmp(np->name, "i2c", 3) == 0) { 443 if (strncmp(np->name, "i2c", 3) == 0) {
443 of_platform_device_create(np, "u3-i2c"); 444 of_platform_device_create(np, "u3-i2c", NULL);
445 of_node_put(np);
444 break; 446 break;
445 } 447 }
448 }
449 of_node_put(npp);
450 }
451 npp = of_find_node_by_type(NULL, "smu");
452 if (npp) {
453 of_platform_device_create(npp, "smu", NULL);
454 of_node_put(npp);
446 } 455 }
447 456
448 return 0; 457 return 0;
diff --git a/arch/ppc64/kernel/pmac_time.c b/arch/ppc64/kernel/pmac_time.c
index 3059edb09cc8..41bbb8c59697 100644
--- a/arch/ppc64/kernel/pmac_time.c
+++ b/arch/ppc64/kernel/pmac_time.c
@@ -84,7 +84,7 @@ void __pmac pmac_get_rtc_time(struct rtc_time *tm)
84 84
85#ifdef CONFIG_PMAC_SMU 85#ifdef CONFIG_PMAC_SMU
86 case SYS_CTRLER_SMU: 86 case SYS_CTRLER_SMU:
87 smu_get_rtc_time(tm); 87 smu_get_rtc_time(tm, 1);
88 break; 88 break;
89#endif /* CONFIG_PMAC_SMU */ 89#endif /* CONFIG_PMAC_SMU */
90 default: 90 default:
@@ -128,7 +128,7 @@ int __pmac pmac_set_rtc_time(struct rtc_time *tm)
128 128
129#ifdef CONFIG_PMAC_SMU 129#ifdef CONFIG_PMAC_SMU
130 case SYS_CTRLER_SMU: 130 case SYS_CTRLER_SMU:
131 return smu_set_rtc_time(tm); 131 return smu_set_rtc_time(tm, 1);
132#endif /* CONFIG_PMAC_SMU */ 132#endif /* CONFIG_PMAC_SMU */
133 default: 133 default:
134 return -ENODEV; 134 return -ENODEV;
diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c
index 9979919cdf92..f252670874a4 100644
--- a/arch/ppc64/kernel/prom_init.c
+++ b/arch/ppc64/kernel/prom_init.c
@@ -1711,6 +1711,7 @@ static void __init flatten_device_tree(void)
1711 unsigned long offset = reloc_offset(); 1711 unsigned long offset = reloc_offset();
1712 unsigned long mem_start, mem_end, room; 1712 unsigned long mem_start, mem_end, room;
1713 struct boot_param_header *hdr; 1713 struct boot_param_header *hdr;
1714 struct prom_t *_prom = PTRRELOC(&prom);
1714 char *namep; 1715 char *namep;
1715 u64 *rsvmap; 1716 u64 *rsvmap;
1716 1717
@@ -1765,6 +1766,7 @@ static void __init flatten_device_tree(void)
1765 RELOC(dt_struct_end) = PAGE_ALIGN(mem_start); 1766 RELOC(dt_struct_end) = PAGE_ALIGN(mem_start);
1766 1767
1767 /* Finish header */ 1768 /* Finish header */
1769 hdr->boot_cpuid_phys = _prom->cpu;
1768 hdr->magic = OF_DT_HEADER; 1770 hdr->magic = OF_DT_HEADER;
1769 hdr->totalsize = RELOC(dt_struct_end) - RELOC(dt_header_start); 1771 hdr->totalsize = RELOC(dt_struct_end) - RELOC(dt_header_start);
1770 hdr->off_dt_struct = RELOC(dt_struct_start) - RELOC(dt_header_start); 1772 hdr->off_dt_struct = RELOC(dt_struct_start) - RELOC(dt_header_start);
@@ -1854,7 +1856,6 @@ static void __init prom_find_boot_cpu(void)
1854 1856
1855 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu); 1857 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
1856 1858
1857 prom_setprop(cpu_pkg, "linux,boot-cpu", NULL, 0);
1858 prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval)); 1859 prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval));
1859 _prom->cpu = getprop_rval; 1860 _prom->cpu = getprop_rval;
1860 1861
diff --git a/arch/ppc64/kernel/ptrace.c b/arch/ppc64/kernel/ptrace.c
index 85ed3188a91d..b1c044ca5756 100644
--- a/arch/ppc64/kernel/ptrace.c
+++ b/arch/ppc64/kernel/ptrace.c
@@ -219,6 +219,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
219 219
220 case PTRACE_SET_DEBUGREG: 220 case PTRACE_SET_DEBUGREG:
221 ret = ptrace_set_debugreg(child, addr, data); 221 ret = ptrace_set_debugreg(child, addr, data);
222 break;
222 223
223 case PTRACE_DETACH: 224 case PTRACE_DETACH:
224 ret = ptrace_detach(child, data); 225 ret = ptrace_detach(child, data);
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c
index 9939c206afa4..b56c6a324e17 100644
--- a/arch/ppc64/kernel/time.c
+++ b/arch/ppc64/kernel/time.c
@@ -870,7 +870,7 @@ void div128_by_32( unsigned long dividend_high, unsigned long dividend_low,
870 rb = ((ra + b) - (x * divisor)) << 32; 870 rb = ((ra + b) - (x * divisor)) << 32;
871 871
872 y = (rb + c)/divisor; 872 y = (rb + c)/divisor;
873 rc = ((rb + b) - (y * divisor)) << 32; 873 rc = ((rb + c) - (y * divisor)) << 32;
874 874
875 z = (rc + d)/divisor; 875 z = (rc + d)/divisor;
876 876
diff --git a/arch/ppc64/kernel/vdso32/gettimeofday.S b/arch/ppc64/kernel/vdso32/gettimeofday.S
index 07f1c1c650c8..e243c1d24af7 100644
--- a/arch/ppc64/kernel/vdso32/gettimeofday.S
+++ b/arch/ppc64/kernel/vdso32/gettimeofday.S
@@ -109,7 +109,7 @@ __do_get_xsec:
109 lwz r6,(CFG_TB_TO_XS+4)(r9) 109 lwz r6,(CFG_TB_TO_XS+4)(r9)
110 mulhwu r4,r7,r5 110 mulhwu r4,r7,r5
111 mulhwu r6,r7,r6 111 mulhwu r6,r7,r6
112 mullw r6,r7,r5 112 mullw r0,r7,r5
113 addc r6,r6,r0 113 addc r6,r6,r0
114 114
115 /* At this point, we have the scaled xsec value in r4 + XER:CA 115 /* At this point, we have the scaled xsec value in r4 + XER:CA
diff --git a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c
index c90e1dd875ce..0e555b7a6587 100644
--- a/arch/ppc64/kernel/vio.c
+++ b/arch/ppc64/kernel/vio.c
@@ -218,7 +218,7 @@ static void vio_unmap_sg(struct device *dev, struct scatterlist *sglist,
218} 218}
219 219
220static void *vio_alloc_coherent(struct device *dev, size_t size, 220static void *vio_alloc_coherent(struct device *dev, size_t size,
221 dma_addr_t *dma_handle, unsigned int __nocast flag) 221 dma_addr_t *dma_handle, gfp_t flag)
222{ 222{
223 return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size, 223 return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size,
224 dma_handle, flag); 224 dma_handle, flag);
diff --git a/arch/ppc64/mm/fault.c b/arch/ppc64/mm/fault.c
index 7fbc68bbb739..be3f25cf3e9f 100644
--- a/arch/ppc64/mm/fault.c
+++ b/arch/ppc64/mm/fault.c
@@ -38,6 +38,7 @@
38#include <asm/system.h> 38#include <asm/system.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40#include <asm/kdebug.h> 40#include <asm/kdebug.h>
41#include <asm/siginfo.h>
41 42
42/* 43/*
43 * Check whether the instruction at regs->nip is a store using 44 * Check whether the instruction at regs->nip is a store using
diff --git a/arch/ppc64/mm/hash_native.c b/arch/ppc64/mm/hash_native.c
index 7626bb59954d..bfd385b7713c 100644
--- a/arch/ppc64/mm/hash_native.c
+++ b/arch/ppc64/mm/hash_native.c
@@ -343,9 +343,7 @@ static void native_flush_hash_range(unsigned long context,
343 hpte_t *hptep; 343 hpte_t *hptep;
344 unsigned long hpte_v; 344 unsigned long hpte_v;
345 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 345 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
346 346 unsigned long large = batch->large;
347 /* XXX fix for large ptes */
348 unsigned long large = 0;
349 347
350 local_irq_save(flags); 348 local_irq_save(flags);
351 349
@@ -407,7 +405,7 @@ static void native_flush_hash_range(unsigned long context,
407 asm volatile("ptesync":::"memory"); 405 asm volatile("ptesync":::"memory");
408 406
409 for (i = 0; i < j; i++) 407 for (i = 0; i < j; i++)
410 __tlbie(batch->vaddr[i], 0); 408 __tlbie(batch->vaddr[i], large);
411 409
412 asm volatile("eieio; tlbsync; ptesync":::"memory"); 410 asm volatile("eieio; tlbsync; ptesync":::"memory");
413 411
diff --git a/arch/ppc64/mm/hugetlbpage.c b/arch/ppc64/mm/hugetlbpage.c
index 338771ec70d7..0ea0994ed974 100644
--- a/arch/ppc64/mm/hugetlbpage.c
+++ b/arch/ppc64/mm/hugetlbpage.c
@@ -710,10 +710,13 @@ repeat:
710 hpte_group = ((~hash & htab_hash_mask) * 710 hpte_group = ((~hash & htab_hash_mask) *
711 HPTES_PER_GROUP) & ~0x7UL; 711 HPTES_PER_GROUP) & ~0x7UL;
712 slot = ppc_md.hpte_insert(hpte_group, va, prpn, 712 slot = ppc_md.hpte_insert(hpte_group, va, prpn,
713 HPTE_V_LARGE, rflags); 713 HPTE_V_LARGE |
714 HPTE_V_SECONDARY,
715 rflags);
714 if (slot == -1) { 716 if (slot == -1) {
715 if (mftb() & 0x1) 717 if (mftb() & 0x1)
716 hpte_group = ((hash & htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL; 718 hpte_group = ((hash & htab_hash_mask) *
719 HPTES_PER_GROUP)&~0x7UL;
717 720
718 ppc_md.hpte_remove(hpte_group); 721 ppc_md.hpte_remove(hpte_group);
719 goto repeat; 722 goto repeat;
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
index c2157c9c3acb..be64b157afce 100644
--- a/arch/ppc64/mm/init.c
+++ b/arch/ppc64/mm/init.c
@@ -799,8 +799,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long ea,
799 if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp)) 799 if (cpus_equal(vma->vm_mm->cpu_vm_mask, tmp))
800 local = 1; 800 local = 1;
801 801
802 __hash_page(ea, pte_val(pte) & (_PAGE_USER|_PAGE_RW), vsid, ptep, 802 __hash_page(ea, 0, vsid, ptep, 0x300, local);
803 0x300, local);
804 local_irq_restore(flags); 803 local_irq_restore(flags);
805} 804}
806 805
diff --git a/arch/ppc64/mm/tlb.c b/arch/ppc64/mm/tlb.c
index d8a6593a13f0..21fbffb23a43 100644
--- a/arch/ppc64/mm/tlb.c
+++ b/arch/ppc64/mm/tlb.c
@@ -143,7 +143,8 @@ void hpte_update(struct mm_struct *mm, unsigned long addr,
143 * up scanning and resetting referenced bits then our batch context 143 * up scanning and resetting referenced bits then our batch context
144 * will change mid stream. 144 * will change mid stream.
145 */ 145 */
146 if (unlikely(i != 0 && context != batch->context)) { 146 if (i != 0 && (context != batch->context ||
147 batch->large != pte_huge(pte))) {
147 flush_tlb_pending(); 148 flush_tlb_pending();
148 i = 0; 149 i = 0;
149 } 150 }
@@ -151,6 +152,7 @@ void hpte_update(struct mm_struct *mm, unsigned long addr,
151 if (i == 0) { 152 if (i == 0) {
152 batch->context = context; 153 batch->context = context;
153 batch->mm = mm; 154 batch->mm = mm;
155 batch->large = pte_huge(pte);
154 } 156 }
155 batch->pte[i] = __pte(pte); 157 batch->pte[i] = __pte(pte);
156 batch->addr[i] = addr; 158 batch->addr[i] = addr;
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 0865251a3f44..45d44c6bb39d 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/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.13-rc4 3# Linux kernel version: 2.6.14-rc1
4# Fri Jul 29 14:49:30 2005 4# Wed Sep 14 16:46:19 2005
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_RWSEM_XCHGADD_ALGORITHM=y 7CONFIG_RWSEM_XCHGADD_ALGORITHM=y
@@ -21,6 +21,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
21# General setup 21# General setup
22# 22#
23CONFIG_LOCALVERSION="" 23CONFIG_LOCALVERSION=""
24CONFIG_LOCALVERSION_AUTO=y
24CONFIG_SWAP=y 25CONFIG_SWAP=y
25CONFIG_SYSVIPC=y 26CONFIG_SYSVIPC=y
26CONFIG_POSIX_MQUEUE=y 27CONFIG_POSIX_MQUEUE=y
@@ -33,6 +34,7 @@ CONFIG_KOBJECT_UEVENT=y
33CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
34CONFIG_IKCONFIG_PROC=y 35CONFIG_IKCONFIG_PROC=y
35# CONFIG_CPUSETS is not set 36# CONFIG_CPUSETS is not set
37CONFIG_INITRAMFS_SOURCE=""
36# CONFIG_EMBEDDED is not set 38# CONFIG_EMBEDDED is not set
37CONFIG_KALLSYMS=y 39CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set 40# CONFIG_KALLSYMS_ALL is not set
@@ -94,6 +96,7 @@ CONFIG_FLATMEM_MANUAL=y
94# CONFIG_SPARSEMEM_MANUAL is not set 96# CONFIG_SPARSEMEM_MANUAL is not set
95CONFIG_FLATMEM=y 97CONFIG_FLATMEM=y
96CONFIG_FLAT_NODE_MEM_MAP=y 98CONFIG_FLAT_NODE_MEM_MAP=y
99# CONFIG_SPARSEMEM_STATIC is not set
97 100
98# 101#
99# I/O subsystem configuration 102# I/O subsystem configuration
@@ -151,8 +154,8 @@ CONFIG_IP_FIB_HASH=y
151# CONFIG_INET_ESP is not set 154# CONFIG_INET_ESP is not set
152# CONFIG_INET_IPCOMP is not set 155# CONFIG_INET_IPCOMP is not set
153# CONFIG_INET_TUNNEL is not set 156# CONFIG_INET_TUNNEL is not set
154CONFIG_IP_TCPDIAG=y 157CONFIG_INET_DIAG=y
155CONFIG_IP_TCPDIAG_IPV6=y 158CONFIG_INET_TCP_DIAG=y
156# CONFIG_TCP_CONG_ADVANCED is not set 159# CONFIG_TCP_CONG_ADVANCED is not set
157CONFIG_TCP_CONG_BIC=y 160CONFIG_TCP_CONG_BIC=y
158CONFIG_IPV6=y 161CONFIG_IPV6=y
@@ -165,6 +168,11 @@ CONFIG_IPV6=y
165# CONFIG_NETFILTER is not set 168# CONFIG_NETFILTER is not set
166 169
167# 170#
171# DCCP Configuration (EXPERIMENTAL)
172#
173# CONFIG_IP_DCCP is not set
174
175#
168# SCTP Configuration (EXPERIMENTAL) 176# SCTP Configuration (EXPERIMENTAL)
169# 177#
170# CONFIG_IP_SCTP is not set 178# CONFIG_IP_SCTP is not set
@@ -217,9 +225,11 @@ CONFIG_NET_CLS_POLICE=y
217# Network testing 225# Network testing
218# 226#
219# CONFIG_NET_PKTGEN is not set 227# CONFIG_NET_PKTGEN is not set
228# CONFIG_NETFILTER_NETLINK is not set
220# CONFIG_HAMRADIO is not set 229# CONFIG_HAMRADIO is not set
221# CONFIG_IRDA is not set 230# CONFIG_IRDA is not set
222# CONFIG_BT is not set 231# CONFIG_BT is not set
232# CONFIG_IEEE80211 is not set
223# CONFIG_PCMCIA is not set 233# CONFIG_PCMCIA is not set
224 234
225# 235#
@@ -233,6 +243,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
233# 243#
234# SCSI device support 244# SCSI device support
235# 245#
246# CONFIG_RAID_ATTRS is not set
236CONFIG_SCSI=y 247CONFIG_SCSI=y
237CONFIG_SCSI_PROC_FS=y 248CONFIG_SCSI_PROC_FS=y
238 249
@@ -260,6 +271,7 @@ CONFIG_SCSI_LOGGING=y
260# CONFIG_SCSI_SPI_ATTRS is not set 271# CONFIG_SCSI_SPI_ATTRS is not set
261CONFIG_SCSI_FC_ATTRS=y 272CONFIG_SCSI_FC_ATTRS=y
262# CONFIG_SCSI_ISCSI_ATTRS is not set 273# CONFIG_SCSI_ISCSI_ATTRS is not set
274# CONFIG_SCSI_SAS_ATTRS is not set
263 275
264# 276#
265# SCSI low-level drivers 277# SCSI low-level drivers
@@ -280,7 +292,6 @@ CONFIG_BLK_DEV_RAM=y
280CONFIG_BLK_DEV_RAM_COUNT=16 292CONFIG_BLK_DEV_RAM_COUNT=16
281CONFIG_BLK_DEV_RAM_SIZE=4096 293CONFIG_BLK_DEV_RAM_SIZE=4096
282CONFIG_BLK_DEV_INITRD=y 294CONFIG_BLK_DEV_INITRD=y
283CONFIG_INITRAMFS_SOURCE=""
284# CONFIG_LBD is not set 295# CONFIG_LBD is not set
285# CONFIG_CDROM_PKTCDVD is not set 296# CONFIG_CDROM_PKTCDVD is not set
286 297
@@ -384,6 +395,10 @@ CONFIG_EQUALIZER=m
384CONFIG_TUN=m 395CONFIG_TUN=m
385 396
386# 397#
398# PHY device support
399#
400
401#
387# Ethernet (10 or 100Mbit) 402# Ethernet (10 or 100Mbit)
388# 403#
389CONFIG_NET_ETHERNET=y 404CONFIG_NET_ETHERNET=y
@@ -453,10 +468,6 @@ CONFIG_FS_MBCACHE=y
453# CONFIG_REISERFS_FS is not set 468# CONFIG_REISERFS_FS is not set
454# CONFIG_JFS_FS is not set 469# CONFIG_JFS_FS is not set
455# CONFIG_FS_POSIX_ACL is not set 470# CONFIG_FS_POSIX_ACL is not set
456
457#
458# XFS support
459#
460# CONFIG_XFS_FS is not set 471# CONFIG_XFS_FS is not set
461# CONFIG_MINIX_FS is not set 472# CONFIG_MINIX_FS is not set
462# CONFIG_ROMFS_FS is not set 473# CONFIG_ROMFS_FS is not set
@@ -465,6 +476,7 @@ CONFIG_INOTIFY=y
465CONFIG_DNOTIFY=y 476CONFIG_DNOTIFY=y
466# CONFIG_AUTOFS_FS is not set 477# CONFIG_AUTOFS_FS is not set
467# CONFIG_AUTOFS4_FS is not set 478# CONFIG_AUTOFS4_FS is not set
479# CONFIG_FUSE_FS is not set
468 480
469# 481#
470# CD-ROM/DVD Filesystems 482# CD-ROM/DVD Filesystems
@@ -485,11 +497,10 @@ CONFIG_DNOTIFY=y
485CONFIG_PROC_FS=y 497CONFIG_PROC_FS=y
486CONFIG_PROC_KCORE=y 498CONFIG_PROC_KCORE=y
487CONFIG_SYSFS=y 499CONFIG_SYSFS=y
488# CONFIG_DEVPTS_FS_XATTR is not set
489CONFIG_TMPFS=y 500CONFIG_TMPFS=y
490# CONFIG_TMPFS_XATTR is not set
491# CONFIG_HUGETLB_PAGE is not set 501# CONFIG_HUGETLB_PAGE is not set
492CONFIG_RAMFS=y 502CONFIG_RAMFS=y
503# CONFIG_RELAYFS_FS is not set
493 504
494# 505#
495# Miscellaneous filesystems 506# Miscellaneous filesystems
@@ -533,6 +544,7 @@ CONFIG_SUNRPC=y
533# CONFIG_NCP_FS is not set 544# CONFIG_NCP_FS is not set
534# CONFIG_CODA_FS is not set 545# CONFIG_CODA_FS is not set
535# CONFIG_AFS_FS is not set 546# CONFIG_AFS_FS is not set
547# CONFIG_9P_FS is not set
536 548
537# 549#
538# Partition Types 550# Partition Types
@@ -572,6 +584,7 @@ CONFIG_MSDOS_PARTITION=y
572CONFIG_DEBUG_KERNEL=y 584CONFIG_DEBUG_KERNEL=y
573CONFIG_MAGIC_SYSRQ=y 585CONFIG_MAGIC_SYSRQ=y
574CONFIG_LOG_BUF_SHIFT=17 586CONFIG_LOG_BUF_SHIFT=17
587CONFIG_DETECT_SOFTLOCKUP=y
575# CONFIG_SCHEDSTATS is not set 588# CONFIG_SCHEDSTATS is not set
576# CONFIG_DEBUG_SLAB is not set 589# CONFIG_DEBUG_SLAB is not set
577CONFIG_DEBUG_PREEMPT=y 590CONFIG_DEBUG_PREEMPT=y
@@ -626,5 +639,6 @@ CONFIG_CRYPTO=y
626# Library routines 639# Library routines
627# 640#
628# CONFIG_CRC_CCITT is not set 641# CONFIG_CRC_CCITT is not set
642# CONFIG_CRC16 is not set
629CONFIG_CRC32=m 643CONFIG_CRC32=m
630# CONFIG_LIBCRC32C is not set 644# CONFIG_LIBCRC32C is not set
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index ab1e49d2e518..8584dd823218 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -6,7 +6,7 @@ EXTRA_AFLAGS := -traditional
6 6
7obj-y := bitmap.o traps.o time.o process.o \ 7obj-y := bitmap.o traps.o time.o process.o \
8 setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \ 8 setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \
9 semaphore.o s390_ext.o debug.o profile.o irq.o 9 semaphore.o s390_ext.o debug.o profile.o irq.o reipl_diag.o
10 10
11extra-$(CONFIG_ARCH_S390_31) += head.o 11extra-$(CONFIG_ARCH_S390_31) += head.o
12extra-$(CONFIG_ARCH_S390X) += head64.o 12extra-$(CONFIG_ARCH_S390X) += head64.o
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index 7358cdb8441f..4ff6808456ea 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -143,7 +143,7 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
143 break; 143 break;
144 case __SI_FAULT >> 16: 144 case __SI_FAULT >> 16:
145 err |= __get_user(tmp, &from->si_addr); 145 err |= __get_user(tmp, &from->si_addr);
146 to->si_addr = (void *)(u64) (tmp & PSW32_ADDR_INSN); 146 to->si_addr = (void __user *)(u64) (tmp & PSW32_ADDR_INSN);
147 break; 147 break;
148 case __SI_POLL >> 16: 148 case __SI_POLL >> 16:
149 err |= __get_user(to->si_band, &from->si_band); 149 err |= __get_user(to->si_band, &from->si_band);
@@ -338,7 +338,7 @@ sys32_sigaltstack(const stack_t32 __user *uss, stack_t32 __user *uoss,
338 err |= __get_user(kss.ss_flags, &uss->ss_flags); 338 err |= __get_user(kss.ss_flags, &uss->ss_flags);
339 if (err) 339 if (err)
340 return -EFAULT; 340 return -EFAULT;
341 kss.ss_sp = (void *) ss_sp; 341 kss.ss_sp = (void __user *) ss_sp;
342 } 342 }
343 343
344 set_fs (KERNEL_DS); 344 set_fs (KERNEL_DS);
@@ -461,7 +461,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
461 goto badframe; 461 goto badframe;
462 462
463 err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp); 463 err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp);
464 st.ss_sp = (void *) A((unsigned long)ss_sp); 464 st.ss_sp = compat_ptr(ss_sp);
465 err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size); 465 err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size);
466 err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags); 466 err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags);
467 if (err) 467 if (err)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 58fc7fbcb40e..9b30f4cf32c4 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -108,7 +108,7 @@ STACK_SIZE = 1 << STACK_SHIFT
108 bl BASED(0f) 108 bl BASED(0f)
109 l %r14,BASED(.Lcleanup_critical) 109 l %r14,BASED(.Lcleanup_critical)
110 basr %r14,%r14 110 basr %r14,%r14
111 tm 0(%r12),0x01 # retest problem state after cleanup 111 tm 1(%r12),0x01 # retest problem state after cleanup
112 bnz BASED(1f) 112 bnz BASED(1f)
1130: l %r14,__LC_ASYNC_STACK # are we already on the async stack ? 1130: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
114 slr %r14,%r15 114 slr %r14,%r15
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index d0c9ffaa25db..7b9b4a2ba1d7 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -101,7 +101,7 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
101 clc \psworg+8(8),BASED(.Lcritical_start) 101 clc \psworg+8(8),BASED(.Lcritical_start)
102 jl 0f 102 jl 0f
103 brasl %r14,cleanup_critical 103 brasl %r14,cleanup_critical
104 tm 0(%r12),0x01 # retest problem state after cleanup 104 tm 1(%r12),0x01 # retest problem state after cleanup
105 jnz 1f 105 jnz 1f
1060: lg %r14,__LC_ASYNC_STACK # are we already on the async. stack ? 1060: lg %r14,__LC_ASYNC_STACK # are we already on the async. stack ?
107 slgr %r14,%r15 107 slgr %r14,%r15
diff --git a/arch/s390/kernel/reipl_diag.c b/arch/s390/kernel/reipl_diag.c
new file mode 100644
index 000000000000..83cb42bc0b76
--- /dev/null
+++ b/arch/s390/kernel/reipl_diag.c
@@ -0,0 +1,39 @@
1/*
2 * This file contains the implementation of the
3 * Linux re-IPL support
4 *
5 * (C) Copyright IBM Corp. 2005
6 *
7 * Author(s): Volker Sameske (sameske@de.ibm.com)
8 *
9 */
10
11#include <linux/kernel.h>
12
13static unsigned int reipl_diag_rc1;
14static unsigned int reipl_diag_rc2;
15
16/*
17 * re-IPL the system using the last used IPL parameters
18 */
19void reipl_diag(void)
20{
21 asm volatile (
22 " la %%r4,0\n"
23 " la %%r5,0\n"
24 " diag %%r4,%2,0x308\n"
25 "0:\n"
26 " st %%r4,%0\n"
27 " st %%r5,%1\n"
28 ".section __ex_table,\"a\"\n"
29#ifdef __s390x__
30 " .align 8\n"
31 " .quad 0b, 0b\n"
32#else
33 " .align 4\n"
34 " .long 0b, 0b\n"
35#endif
36 ".previous\n"
37 : "=m" (reipl_diag_rc1), "=m" (reipl_diag_rc2)
38 : "d" (3) : "cc", "4", "5" );
39}
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 5ba5a5485da9..5204778b8e5e 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -261,8 +261,11 @@ void (*_machine_power_off)(void) = machine_power_off_smp;
261 * Reboot, halt and power_off routines for non SMP. 261 * Reboot, halt and power_off routines for non SMP.
262 */ 262 */
263extern void reipl(unsigned long devno); 263extern void reipl(unsigned long devno);
264extern void reipl_diag(void);
264static void do_machine_restart_nonsmp(char * __unused) 265static void do_machine_restart_nonsmp(char * __unused)
265{ 266{
267 reipl_diag();
268
266 if (MACHINE_IS_VM) 269 if (MACHINE_IS_VM)
267 cpcmd ("IPL", NULL, 0); 270 cpcmd ("IPL", NULL, 0);
268 else 271 else
@@ -634,6 +637,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
634 struct cpuinfo_S390 *cpuinfo; 637 struct cpuinfo_S390 *cpuinfo;
635 unsigned long n = (unsigned long) v - 1; 638 unsigned long n = (unsigned long) v - 1;
636 639
640 preempt_disable();
637 if (!n) { 641 if (!n) {
638 seq_printf(m, "vendor_id : IBM/S390\n" 642 seq_printf(m, "vendor_id : IBM/S390\n"
639 "# processors : %i\n" 643 "# processors : %i\n"
@@ -658,6 +662,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
658 cpuinfo->cpu_id.ident, 662 cpuinfo->cpu_id.ident,
659 cpuinfo->cpu_id.machine); 663 cpuinfo->cpu_id.machine);
660 } 664 }
665 preempt_enable();
661 return 0; 666 return 0;
662} 667}
663 668
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index 6a3f5b7473a9..6e0110d71191 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -376,8 +376,8 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
376 376
377 /* Create the ucontext. */ 377 /* Create the ucontext. */
378 err |= __put_user(0, &frame->uc.uc_flags); 378 err |= __put_user(0, &frame->uc.uc_flags);
379 err |= __put_user(0, &frame->uc.uc_link); 379 err |= __put_user(NULL, &frame->uc.uc_link);
380 err |= __put_user((void *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 380 err |= __put_user((void __user *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
381 err |= __put_user(sas_ss_flags(regs->gprs[15]), 381 err |= __put_user(sas_ss_flags(regs->gprs[15]),
382 &frame->uc.uc_stack.ss_flags); 382 &frame->uc.uc_stack.ss_flags);
383 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); 383 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 85222fee4361..e13c87b446b2 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -65,6 +65,7 @@ extern char vmhalt_cmd[];
65extern char vmpoff_cmd[]; 65extern char vmpoff_cmd[];
66 66
67extern void reipl(unsigned long devno); 67extern void reipl(unsigned long devno);
68extern void reipl_diag(void);
68 69
69static void smp_ext_bitcall(int, ec_bit_sig); 70static void smp_ext_bitcall(int, ec_bit_sig);
70static void smp_ext_bitcall_others(ec_bit_sig); 71static void smp_ext_bitcall_others(ec_bit_sig);
@@ -283,6 +284,8 @@ static void do_machine_restart(void * __unused)
283 * interrupted by an external interrupt and s390irq 284 * interrupted by an external interrupt and s390irq
284 * locks are always held disabled). 285 * locks are always held disabled).
285 */ 286 */
287 reipl_diag();
288
286 if (MACHINE_IS_VM) 289 if (MACHINE_IS_VM)
287 cpcmd ("IPL", NULL, 0, NULL); 290 cpcmd ("IPL", NULL, 0, NULL);
288 else 291 else
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 56a39d69e080..5ecefc02896a 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -22,6 +22,7 @@
22#include <linux/time.h> 22#include <linux/time.h>
23#include <linux/timex.h> 23#include <linux/timex.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/module.h>
25 26
26#include <asm/atomic.h> 27#include <asm/atomic.h>
27#include <asm/processor.h> 28#include <asm/processor.h>
@@ -39,6 +40,8 @@ struct sh_cpuinfo cpu_data[NR_CPUS];
39extern void per_cpu_trap_init(void); 40extern void per_cpu_trap_init(void);
40 41
41cpumask_t cpu_possible_map; 42cpumask_t cpu_possible_map;
43EXPORT_SYMBOL(cpu_possible_map);
44
42cpumask_t cpu_online_map; 45cpumask_t cpu_online_map;
43static atomic_t cpus_booted = ATOMIC_INIT(0); 46static atomic_t cpus_booted = ATOMIC_INIT(0);
44 47
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index aba05394d30a..6537445dac0e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -25,62 +25,6 @@ source "init/Kconfig"
25 25
26menu "General machine setup" 26menu "General machine setup"
27 27
28config VT
29 bool
30 select INPUT
31 default y
32 ---help---
33 If you say Y here, you will get support for terminal devices with
34 display and keyboard devices. These are called "virtual" because you
35 can run several virtual terminals (also called virtual consoles) on
36 one physical terminal. This is rather useful, for example one
37 virtual terminal can collect system messages and warnings, another
38 one can be used for a text-mode user session, and a third could run
39 an X session, all in parallel. Switching between virtual terminals
40 is done with certain key combinations, usually Alt-<function key>.
41
42 The setterm command ("man setterm") can be used to change the
43 properties (such as colors or beeping) of a virtual terminal. The
44 man page console_codes(4) ("man console_codes") contains the special
45 character sequences that can be used to change those properties
46 directly. The fonts used on virtual terminals can be changed with
47 the setfont ("man setfont") command and the key bindings are defined
48 with the loadkeys ("man loadkeys") command.
49
50 You need at least one virtual terminal device in order to make use
51 of your keyboard and monitor. Therefore, only people configuring an
52 embedded system would want to say N here in order to save some
53 memory; the only way to log into such a system is then via a serial
54 or network connection.
55
56 If unsure, say Y, or else you won't be able to do much with your new
57 shiny Linux system :-)
58
59config VT_CONSOLE
60 bool
61 default y
62 ---help---
63 The system console is the device which receives all kernel messages
64 and warnings and which allows logins in single user mode. If you
65 answer Y here, a virtual terminal (the device used to interact with
66 a physical terminal) can be used as system console. This is the most
67 common mode of operations, so you should say Y here unless you want
68 the kernel messages be output only to a serial port (in which case
69 you should say Y to "Console on serial port", below).
70
71 If you do say Y here, by default the currently visible virtual
72 terminal (/dev/tty0) will be used as system console. You can change
73 that with a kernel command line option such as "console=tty3" which
74 would use the third virtual terminal as system console. (Try "man
75 bootparam" or see the documentation of your boot loader (lilo or
76 loadlin) about how to pass options to the kernel at boot time.)
77
78 If unsure, say Y.
79
80config HW_CONSOLE
81 bool
82 default y
83
84config SMP 28config SMP
85 bool "Symmetric multi-processing support (does not work on sun4/sun4c)" 29 bool "Symmetric multi-processing support (does not work on sun4/sun4c)"
86 depends on BROKEN 30 depends on BROKEN
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 53c192a4982f..3509e4305532 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -249,8 +249,6 @@ struct tt_entry *sparc_ttable;
249 249
250struct pt_regs fake_swapper_regs; 250struct pt_regs fake_swapper_regs;
251 251
252extern void paging_init(void);
253
254void __init setup_arch(char **cmdline_p) 252void __init setup_arch(char **cmdline_p)
255{ 253{
256 int i; 254 int i;
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index bc015e980341..279a62627c10 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -457,7 +457,7 @@ void __init time_init(void)
457 sbus_time_init(); 457 sbus_time_init();
458} 458}
459 459
460extern __inline__ unsigned long do_gettimeoffset(void) 460static inline unsigned long do_gettimeoffset(void)
461{ 461{
462 return (*master_l10_counter >> 10) & 0x1fffff; 462 return (*master_l10_counter >> 10) & 0x1fffff;
463} 463}
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index c89a803cbc20..c664b962987c 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -260,7 +260,7 @@ static inline pte_t srmmu_pte_modify(pte_t pte, pgprot_t newprot)
260{ return __pte((pte_val(pte) & SRMMU_CHG_MASK) | pgprot_val(newprot)); } 260{ return __pte((pte_val(pte) & SRMMU_CHG_MASK) | pgprot_val(newprot)); }
261 261
262/* to find an entry in a top-level page table... */ 262/* to find an entry in a top-level page table... */
263extern inline pgd_t *srmmu_pgd_offset(struct mm_struct * mm, unsigned long address) 263static inline pgd_t *srmmu_pgd_offset(struct mm_struct * mm, unsigned long address)
264{ return mm->pgd + (address >> SRMMU_PGDIR_SHIFT); } 264{ return mm->pgd + (address >> SRMMU_PGDIR_SHIFT); }
265 265
266/* Find an entry in the second-level page table.. */ 266/* Find an entry in the second-level page table.. */
diff --git a/arch/sparc64/Kconfig.debug b/arch/sparc64/Kconfig.debug
index af0e9411b83e..fa06ea04837b 100644
--- a/arch/sparc64/Kconfig.debug
+++ b/arch/sparc64/Kconfig.debug
@@ -33,6 +33,14 @@ config DEBUG_BOOTMEM
33 depends on DEBUG_KERNEL 33 depends on DEBUG_KERNEL
34 bool "Debug BOOTMEM initialization" 34 bool "Debug BOOTMEM initialization"
35 35
36config DEBUG_PAGEALLOC
37 bool "Page alloc debugging"
38 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND
39 help
40 Unmap pages from the kernel linear mapping after free_pages().
41 This results in a large slowdown, but helps to find certain types
42 of memory corruptions.
43
36config MCOUNT 44config MCOUNT
37 bool 45 bool
38 depends on STACK_DEBUG 46 depends on STACK_DEBUG
diff --git a/arch/sparc64/kernel/cpu.c b/arch/sparc64/kernel/cpu.c
index 48756958116b..77ef5df4e5a7 100644
--- a/arch/sparc64/kernel/cpu.c
+++ b/arch/sparc64/kernel/cpu.c
@@ -39,6 +39,8 @@ struct cpu_fp_info linux_sparc_fpu[] = {
39 { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"}, 39 { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"},
40 { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"}, 40 { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"},
41 { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"}, 41 { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"},
42 { 0x3e, 0x19, 0, "UltraSparc IV+ integrated FPU"},
43 { 0x3e, 0x22, 0, "UltraSparc IIIi+ integrated FPU"},
42}; 44};
43 45
44#define NSPARCFPU (sizeof(linux_sparc_fpu)/sizeof(struct cpu_fp_info)) 46#define NSPARCFPU (sizeof(linux_sparc_fpu)/sizeof(struct cpu_fp_info))
@@ -53,6 +55,8 @@ struct cpu_iu_info linux_sparc_chips[] = {
53 { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"}, 55 { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"},
54 { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"}, 56 { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"},
55 { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"}, 57 { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"},
58 { 0x3e, 0x19, "TI UltraSparc IV+ (Panther)"},
59 { 0x3e, 0x22, "TI UltraSparc IIIi+ (Serrano)"},
56}; 60};
57 61
58#define NSPARCCHIPS (sizeof(linux_sparc_chips)/sizeof(struct cpu_iu_info)) 62#define NSPARCCHIPS (sizeof(linux_sparc_chips)/sizeof(struct cpu_iu_info))
diff --git a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c
index d710274e516b..df9a1ca8fd77 100644
--- a/arch/sparc64/kernel/devices.c
+++ b/arch/sparc64/kernel/devices.c
@@ -135,6 +135,28 @@ void __init device_scan(void)
135 cpu_data(0).clock_tick = prom_getintdefault(cpu_node, 135 cpu_data(0).clock_tick = prom_getintdefault(cpu_node,
136 "clock-frequency", 136 "clock-frequency",
137 0); 137 0);
138 cpu_data(0).dcache_size = prom_getintdefault(cpu_node,
139 "dcache-size",
140 16 * 1024);
141 cpu_data(0).dcache_line_size =
142 prom_getintdefault(cpu_node, "dcache-line-size", 32);
143 cpu_data(0).icache_size = prom_getintdefault(cpu_node,
144 "icache-size",
145 16 * 1024);
146 cpu_data(0).icache_line_size =
147 prom_getintdefault(cpu_node, "icache-line-size", 32);
148 cpu_data(0).ecache_size = prom_getintdefault(cpu_node,
149 "ecache-size",
150 4 * 1024 * 1024);
151 cpu_data(0).ecache_line_size =
152 prom_getintdefault(cpu_node, "ecache-line-size", 64);
153 printk("CPU[0]: Caches "
154 "D[sz(%d):line_sz(%d)] "
155 "I[sz(%d):line_sz(%d)] "
156 "E[sz(%d):line_sz(%d)]\n",
157 cpu_data(0).dcache_size, cpu_data(0).dcache_line_size,
158 cpu_data(0).icache_size, cpu_data(0).icache_line_size,
159 cpu_data(0).ecache_size, cpu_data(0).ecache_line_size);
138 } 160 }
139#endif 161#endif
140 162
diff --git a/arch/sparc64/kernel/dtlb_backend.S b/arch/sparc64/kernel/dtlb_backend.S
index 538522848ad4..acc889a7f9c1 100644
--- a/arch/sparc64/kernel/dtlb_backend.S
+++ b/arch/sparc64/kernel/dtlb_backend.S
@@ -9,17 +9,7 @@
9#include <asm/pgtable.h> 9#include <asm/pgtable.h>
10#include <asm/mmu.h> 10#include <asm/mmu.h>
11 11
12#if PAGE_SHIFT == 13 12#define VALID_SZ_BITS (_PAGE_VALID | _PAGE_SZBITS)
13#define SZ_BITS _PAGE_SZ8K
14#elif PAGE_SHIFT == 16
15#define SZ_BITS _PAGE_SZ64K
16#elif PAGE_SHIFT == 19
17#define SZ_BITS _PAGE_SZ512K
18#elif PAGE_SHIFT == 22
19#define SZ_BITS _PAGE_SZ4MB
20#endif
21
22#define VALID_SZ_BITS (_PAGE_VALID | SZ_BITS)
23 13
24#define VPTE_BITS (_PAGE_CP | _PAGE_CV | _PAGE_P ) 14#define VPTE_BITS (_PAGE_CP | _PAGE_CV | _PAGE_P )
25#define VPTE_SHIFT (PAGE_SHIFT - 3) 15#define VPTE_SHIFT (PAGE_SHIFT - 3)
@@ -163,7 +153,6 @@ sparc64_vpte_continue:
163 stxa %g4, [%g1 + %g1] ASI_DMMU ! Restore previous TAG_ACCESS 153 stxa %g4, [%g1 + %g1] ASI_DMMU ! Restore previous TAG_ACCESS
164 retry ! Load PTE once again 154 retry ! Load PTE once again
165 155
166#undef SZ_BITS
167#undef VALID_SZ_BITS 156#undef VALID_SZ_BITS
168#undef VPTE_SHIFT 157#undef VPTE_SHIFT
169#undef VPTE_BITS 158#undef VPTE_BITS
diff --git a/arch/sparc64/kernel/dtlb_base.S b/arch/sparc64/kernel/dtlb_base.S
index ded2fed23fcc..6528786840c0 100644
--- a/arch/sparc64/kernel/dtlb_base.S
+++ b/arch/sparc64/kernel/dtlb_base.S
@@ -53,39 +53,36 @@
53 * be guaranteed to be 0 ... mmu_context.h does guarantee this 53 * be guaranteed to be 0 ... mmu_context.h does guarantee this
54 * by only using 10 bits in the hwcontext value. 54 * by only using 10 bits in the hwcontext value.
55 */ 55 */
56#define CREATE_VPTE_OFFSET1(r1, r2) 56#define CREATE_VPTE_OFFSET1(r1, r2) nop
57#define CREATE_VPTE_OFFSET2(r1, r2) \ 57#define CREATE_VPTE_OFFSET2(r1, r2) \
58 srax r1, 10, r2 58 srax r1, 10, r2
59#define CREATE_VPTE_NOP nop
60#else 59#else
61#define CREATE_VPTE_OFFSET1(r1, r2) \ 60#define CREATE_VPTE_OFFSET1(r1, r2) \
62 srax r1, PAGE_SHIFT, r2 61 srax r1, PAGE_SHIFT, r2
63#define CREATE_VPTE_OFFSET2(r1, r2) \ 62#define CREATE_VPTE_OFFSET2(r1, r2) \
64 sllx r2, 3, r2 63 sllx r2, 3, r2
65#define CREATE_VPTE_NOP
66#endif 64#endif
67 65
68/* DTLB ** ICACHE line 1: Quick user TLB misses */ 66/* DTLB ** ICACHE line 1: Quick user TLB misses */
67 mov TLB_SFSR, %g1
69 ldxa [%g1 + %g1] ASI_DMMU, %g4 ! Get TAG_ACCESS 68 ldxa [%g1 + %g1] ASI_DMMU, %g4 ! Get TAG_ACCESS
70 andcc %g4, TAG_CONTEXT_BITS, %g0 ! From Nucleus? 69 andcc %g4, TAG_CONTEXT_BITS, %g0 ! From Nucleus?
71from_tl1_trap: 70from_tl1_trap:
72 rdpr %tl, %g5 ! For TL==3 test 71 rdpr %tl, %g5 ! For TL==3 test
73 CREATE_VPTE_OFFSET1(%g4, %g6) ! Create VPTE offset 72 CREATE_VPTE_OFFSET1(%g4, %g6) ! Create VPTE offset
74 be,pn %xcc, 3f ! Yep, special processing 73 be,pn %xcc, kvmap ! Yep, special processing
75 CREATE_VPTE_OFFSET2(%g4, %g6) ! Create VPTE offset 74 CREATE_VPTE_OFFSET2(%g4, %g6) ! Create VPTE offset
76 cmp %g5, 4 ! Last trap level? 75 cmp %g5, 4 ! Last trap level?
77 be,pn %xcc, longpath ! Yep, cannot risk VPTE miss
78 nop ! delay slot
79 76
80/* DTLB ** ICACHE line 2: User finish + quick kernel TLB misses */ 77/* DTLB ** ICACHE line 2: User finish + quick kernel TLB misses */
78 be,pn %xcc, longpath ! Yep, cannot risk VPTE miss
79 nop ! delay slot
81 ldxa [%g3 + %g6] ASI_S, %g5 ! Load VPTE 80 ldxa [%g3 + %g6] ASI_S, %g5 ! Load VPTE
821: brgez,pn %g5, longpath ! Invalid, branch out 811: brgez,pn %g5, longpath ! Invalid, branch out
83 nop ! Delay-slot 82 nop ! Delay-slot
849: stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB 839: stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
85 retry ! Trap return 84 retry ! Trap return
863: brlz,pt %g4, 9b ! Kernel virtual map? 85 nop
87 xor %g2, %g4, %g5 ! Finish bit twiddles
88 ba,a,pt %xcc, kvmap ! Yep, go check for obp/vmalloc
89 86
90/* DTLB ** ICACHE line 3: winfixups+real_faults */ 87/* DTLB ** ICACHE line 3: winfixups+real_faults */
91longpath: 88longpath:
@@ -106,8 +103,7 @@ longpath:
106 nop 103 nop
107 nop 104 nop
108 nop 105 nop
109 CREATE_VPTE_NOP 106 nop
110 107
111#undef CREATE_VPTE_OFFSET1 108#undef CREATE_VPTE_OFFSET1
112#undef CREATE_VPTE_OFFSET2 109#undef CREATE_VPTE_OFFSET2
113#undef CREATE_VPTE_NOP
diff --git a/arch/sparc64/kernel/dtlb_prot.S b/arch/sparc64/kernel/dtlb_prot.S
index d848bb7374bb..e0a920162604 100644
--- a/arch/sparc64/kernel/dtlb_prot.S
+++ b/arch/sparc64/kernel/dtlb_prot.S
@@ -14,14 +14,14 @@
14 */ 14 */
15 15
16/* PROT ** ICACHE line 1: User DTLB protection trap */ 16/* PROT ** ICACHE line 1: User DTLB protection trap */
17 stxa %g0, [%g1] ASI_DMMU ! Clear SFSR FaultValid bit 17 mov TLB_SFSR, %g1
18 membar #Sync ! Synchronize ASI stores 18 stxa %g0, [%g1] ASI_DMMU ! Clear FaultValid bit
19 rdpr %pstate, %g5 ! Move into alternate globals 19 membar #Sync ! Synchronize stores
20 rdpr %pstate, %g5 ! Move into alt-globals
20 wrpr %g5, PSTATE_AG|PSTATE_MG, %pstate 21 wrpr %g5, PSTATE_AG|PSTATE_MG, %pstate
21 rdpr %tl, %g1 ! Need to do a winfixup? 22 rdpr %tl, %g1 ! Need a winfixup?
22 cmp %g1, 1 ! Trap level >1? 23 cmp %g1, 1 ! Trap level >1?
23 mov TLB_TAG_ACCESS, %g4 ! Prepare reload of vaddr 24 mov TLB_TAG_ACCESS, %g4 ! For reload of vaddr
24 nop
25 25
26/* PROT ** ICACHE line 2: More real fault processing */ 26/* PROT ** ICACHE line 2: More real fault processing */
27 bgu,pn %xcc, winfix_trampoline ! Yes, perform winfixup 27 bgu,pn %xcc, winfix_trampoline ! Yes, perform winfixup
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index 3e0badb820c5..11a848402fb1 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -30,164 +30,10 @@
30 .text 30 .text
31 .align 32 31 .align 32
32 32
33 .globl sparc64_vpte_patchme1
34 .globl sparc64_vpte_patchme2
35/*
36 * On a second level vpte miss, check whether the original fault is to the OBP
37 * range (note that this is only possible for instruction miss, data misses to
38 * obp range do not use vpte). If so, go back directly to the faulting address.
39 * This is because we want to read the tpc, otherwise we have no way of knowing
40 * the 8k aligned faulting address if we are using >8k kernel pagesize. This
41 * also ensures no vpte range addresses are dropped into tlb while obp is
42 * executing (see inherit_locked_prom_mappings() rant).
43 */
44sparc64_vpte_nucleus:
45 /* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
46 mov 0xf, %g5
47 sllx %g5, 28, %g5
48
49 /* Is addr >= LOW_OBP_ADDRESS? */
50 cmp %g4, %g5
51 blu,pn %xcc, sparc64_vpte_patchme1
52 mov 0x1, %g5
53
54 /* Load 0x100000000, which is HI_OBP_ADDRESS. */
55 sllx %g5, 32, %g5
56
57 /* Is addr < HI_OBP_ADDRESS? */
58 cmp %g4, %g5
59 blu,pn %xcc, obp_iaddr_patch
60 nop
61
62 /* These two instructions are patched by paginig_init(). */
63sparc64_vpte_patchme1:
64 sethi %hi(0), %g5
65sparc64_vpte_patchme2:
66 or %g5, %lo(0), %g5
67
68 /* With kernel PGD in %g5, branch back into dtlb_backend. */
69 ba,pt %xcc, sparc64_kpte_continue
70 andn %g1, 0x3, %g1 /* Finish PMD offset adjustment. */
71
72vpte_noent:
73 /* Restore previous TAG_ACCESS, %g5 is zero, and we will
74 * skip over the trap instruction so that the top level
75 * TLB miss handler will thing this %g5 value is just an
76 * invalid PTE, thus branching to full fault processing.
77 */
78 mov TLB_SFSR, %g1
79 stxa %g4, [%g1 + %g1] ASI_DMMU
80 done
81
82 .globl obp_iaddr_patch
83obp_iaddr_patch:
84 /* These two instructions patched by inherit_prom_mappings(). */
85 sethi %hi(0), %g5
86 or %g5, %lo(0), %g5
87
88 /* Behave as if we are at TL0. */
89 wrpr %g0, 1, %tl
90 rdpr %tpc, %g4 /* Find original faulting iaddr */
91 srlx %g4, 13, %g4 /* Throw out context bits */
92 sllx %g4, 13, %g4 /* g4 has vpn + ctx0 now */
93
94 /* Restore previous TAG_ACCESS. */
95 mov TLB_SFSR, %g1
96 stxa %g4, [%g1 + %g1] ASI_IMMU
97
98 /* Get PMD offset. */
99 srlx %g4, 23, %g6
100 and %g6, 0x7ff, %g6
101 sllx %g6, 2, %g6
102
103 /* Load PMD, is it valid? */
104 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
105 brz,pn %g5, longpath
106 sllx %g5, 11, %g5
107
108 /* Get PTE offset. */
109 srlx %g4, 13, %g6
110 and %g6, 0x3ff, %g6
111 sllx %g6, 3, %g6
112
113 /* Load PTE. */
114 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
115 brgez,pn %g5, longpath
116 nop
117
118 /* TLB load and return from trap. */
119 stxa %g5, [%g0] ASI_ITLB_DATA_IN
120 retry
121
122 .globl obp_daddr_patch
123obp_daddr_patch:
124 /* These two instructions patched by inherit_prom_mappings(). */
125 sethi %hi(0), %g5
126 or %g5, %lo(0), %g5
127
128 /* Get PMD offset. */
129 srlx %g4, 23, %g6
130 and %g6, 0x7ff, %g6
131 sllx %g6, 2, %g6
132
133 /* Load PMD, is it valid? */
134 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
135 brz,pn %g5, longpath
136 sllx %g5, 11, %g5
137
138 /* Get PTE offset. */
139 srlx %g4, 13, %g6
140 and %g6, 0x3ff, %g6
141 sllx %g6, 3, %g6
142
143 /* Load PTE. */
144 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
145 brgez,pn %g5, longpath
146 nop
147
148 /* TLB load and return from trap. */
149 stxa %g5, [%g0] ASI_DTLB_DATA_IN
150 retry
151
152/*
153 * On a first level data miss, check whether this is to the OBP range (note
154 * that such accesses can be made by prom, as well as by kernel using
155 * prom_getproperty on "address"), and if so, do not use vpte access ...
156 * rather, use information saved during inherit_prom_mappings() using 8k
157 * pagesize.
158 */
159kvmap:
160 /* Load 0xf0000000, which is LOW_OBP_ADDRESS. */
161 mov 0xf, %g5
162 sllx %g5, 28, %g5
163
164 /* Is addr >= LOW_OBP_ADDRESS? */
165 cmp %g4, %g5
166 blu,pn %xcc, vmalloc_addr
167 mov 0x1, %g5
168
169 /* Load 0x100000000, which is HI_OBP_ADDRESS. */
170 sllx %g5, 32, %g5
171
172 /* Is addr < HI_OBP_ADDRESS? */
173 cmp %g4, %g5
174 blu,pn %xcc, obp_daddr_patch
175 nop
176
177vmalloc_addr:
178 /* If we get here, a vmalloc addr accessed, load kernel VPTE. */
179 ldxa [%g3 + %g6] ASI_N, %g5
180 brgez,pn %g5, longpath
181 nop
182
183 /* PTE is valid, load into TLB and return from trap. */
184 stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
185 retry
186
187 /* This is trivial with the new code... */ 33 /* This is trivial with the new code... */
188 .globl do_fpdis 34 .globl do_fpdis
189do_fpdis: 35do_fpdis:
190 sethi %hi(TSTATE_PEF), %g4 ! IEU0 36 sethi %hi(TSTATE_PEF), %g4
191 rdpr %tstate, %g5 37 rdpr %tstate, %g5
192 andcc %g5, %g4, %g0 38 andcc %g5, %g4, %g0
193 be,pt %xcc, 1f 39 be,pt %xcc, 1f
@@ -204,18 +50,18 @@ do_fpdis:
204 add %g0, %g0, %g0 50 add %g0, %g0, %g0
205 ba,a,pt %xcc, rtrap_clr_l6 51 ba,a,pt %xcc, rtrap_clr_l6
206 52
2071: ldub [%g6 + TI_FPSAVED], %g5 ! Load Group 531: ldub [%g6 + TI_FPSAVED], %g5
208 wr %g0, FPRS_FEF, %fprs ! LSU Group+4bubbles 54 wr %g0, FPRS_FEF, %fprs
209 andcc %g5, FPRS_FEF, %g0 ! IEU1 Group 55 andcc %g5, FPRS_FEF, %g0
210 be,a,pt %icc, 1f ! CTI 56 be,a,pt %icc, 1f
211 clr %g7 ! IEU0 57 clr %g7
212 ldx [%g6 + TI_GSR], %g7 ! Load Group 58 ldx [%g6 + TI_GSR], %g7
2131: andcc %g5, FPRS_DL, %g0 ! IEU1 591: andcc %g5, FPRS_DL, %g0
214 bne,pn %icc, 2f ! CTI 60 bne,pn %icc, 2f
215 fzero %f0 ! FPA 61 fzero %f0
216 andcc %g5, FPRS_DU, %g0 ! IEU1 Group 62 andcc %g5, FPRS_DU, %g0
217 bne,pn %icc, 1f ! CTI 63 bne,pn %icc, 1f
218 fzero %f2 ! FPA 64 fzero %f2
219 faddd %f0, %f2, %f4 65 faddd %f0, %f2, %f4
220 fmuld %f0, %f2, %f6 66 fmuld %f0, %f2, %f6
221 faddd %f0, %f2, %f8 67 faddd %f0, %f2, %f8
@@ -251,15 +97,17 @@ do_fpdis:
251 faddd %f0, %f2, %f4 97 faddd %f0, %f2, %f4
252 fmuld %f0, %f2, %f6 98 fmuld %f0, %f2, %f6
253 ldxa [%g3] ASI_DMMU, %g5 99 ldxa [%g3] ASI_DMMU, %g5
254cplus_fptrap_insn_1: 100 sethi %hi(sparc64_kern_sec_context), %g2
255 sethi %hi(0), %g2 101 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
256 stxa %g2, [%g3] ASI_DMMU 102 stxa %g2, [%g3] ASI_DMMU
257 membar #Sync 103 membar #Sync
258 add %g6, TI_FPREGS + 0xc0, %g2 104 add %g6, TI_FPREGS + 0xc0, %g2
259 faddd %f0, %f2, %f8 105 faddd %f0, %f2, %f8
260 fmuld %f0, %f2, %f10 106 fmuld %f0, %f2, %f10
261 ldda [%g1] ASI_BLK_S, %f32 ! grrr, where is ASI_BLK_NUCLEUS 8-( 107 membar #Sync
108 ldda [%g1] ASI_BLK_S, %f32
262 ldda [%g2] ASI_BLK_S, %f48 109 ldda [%g2] ASI_BLK_S, %f48
110 membar #Sync
263 faddd %f0, %f2, %f12 111 faddd %f0, %f2, %f12
264 fmuld %f0, %f2, %f14 112 fmuld %f0, %f2, %f14
265 faddd %f0, %f2, %f16 113 faddd %f0, %f2, %f16
@@ -270,7 +118,6 @@ cplus_fptrap_insn_1:
270 fmuld %f0, %f2, %f26 118 fmuld %f0, %f2, %f26
271 faddd %f0, %f2, %f28 119 faddd %f0, %f2, %f28
272 fmuld %f0, %f2, %f30 120 fmuld %f0, %f2, %f30
273 membar #Sync
274 b,pt %xcc, fpdis_exit 121 b,pt %xcc, fpdis_exit
275 nop 122 nop
2762: andcc %g5, FPRS_DU, %g0 1232: andcc %g5, FPRS_DU, %g0
@@ -280,15 +127,17 @@ cplus_fptrap_insn_1:
280 fzero %f34 127 fzero %f34
281 ldxa [%g3] ASI_DMMU, %g5 128 ldxa [%g3] ASI_DMMU, %g5
282 add %g6, TI_FPREGS, %g1 129 add %g6, TI_FPREGS, %g1
283cplus_fptrap_insn_2: 130 sethi %hi(sparc64_kern_sec_context), %g2
284 sethi %hi(0), %g2 131 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
285 stxa %g2, [%g3] ASI_DMMU 132 stxa %g2, [%g3] ASI_DMMU
286 membar #Sync 133 membar #Sync
287 add %g6, TI_FPREGS + 0x40, %g2 134 add %g6, TI_FPREGS + 0x40, %g2
288 faddd %f32, %f34, %f36 135 faddd %f32, %f34, %f36
289 fmuld %f32, %f34, %f38 136 fmuld %f32, %f34, %f38
290 ldda [%g1] ASI_BLK_S, %f0 ! grrr, where is ASI_BLK_NUCLEUS 8-( 137 membar #Sync
138 ldda [%g1] ASI_BLK_S, %f0
291 ldda [%g2] ASI_BLK_S, %f16 139 ldda [%g2] ASI_BLK_S, %f16
140 membar #Sync
292 faddd %f32, %f34, %f40 141 faddd %f32, %f34, %f40
293 fmuld %f32, %f34, %f42 142 fmuld %f32, %f34, %f42
294 faddd %f32, %f34, %f44 143 faddd %f32, %f34, %f44
@@ -301,18 +150,18 @@ cplus_fptrap_insn_2:
301 fmuld %f32, %f34, %f58 150 fmuld %f32, %f34, %f58
302 faddd %f32, %f34, %f60 151 faddd %f32, %f34, %f60
303 fmuld %f32, %f34, %f62 152 fmuld %f32, %f34, %f62
304 membar #Sync
305 ba,pt %xcc, fpdis_exit 153 ba,pt %xcc, fpdis_exit
306 nop 154 nop
3073: mov SECONDARY_CONTEXT, %g3 1553: mov SECONDARY_CONTEXT, %g3
308 add %g6, TI_FPREGS, %g1 156 add %g6, TI_FPREGS, %g1
309 ldxa [%g3] ASI_DMMU, %g5 157 ldxa [%g3] ASI_DMMU, %g5
310cplus_fptrap_insn_3: 158 sethi %hi(sparc64_kern_sec_context), %g2
311 sethi %hi(0), %g2 159 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
312 stxa %g2, [%g3] ASI_DMMU 160 stxa %g2, [%g3] ASI_DMMU
313 membar #Sync 161 membar #Sync
314 mov 0x40, %g2 162 mov 0x40, %g2
315 ldda [%g1] ASI_BLK_S, %f0 ! grrr, where is ASI_BLK_NUCLEUS 8-( 163 membar #Sync
164 ldda [%g1] ASI_BLK_S, %f0
316 ldda [%g1 + %g2] ASI_BLK_S, %f16 165 ldda [%g1 + %g2] ASI_BLK_S, %f16
317 add %g1, 0x80, %g1 166 add %g1, 0x80, %g1
318 ldda [%g1] ASI_BLK_S, %f32 167 ldda [%g1] ASI_BLK_S, %f32
@@ -473,8 +322,8 @@ do_fptrap_after_fsr:
473 stx %g3, [%g6 + TI_GSR] 322 stx %g3, [%g6 + TI_GSR]
474 mov SECONDARY_CONTEXT, %g3 323 mov SECONDARY_CONTEXT, %g3
475 ldxa [%g3] ASI_DMMU, %g5 324 ldxa [%g3] ASI_DMMU, %g5
476cplus_fptrap_insn_4: 325 sethi %hi(sparc64_kern_sec_context), %g2
477 sethi %hi(0), %g2 326 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
478 stxa %g2, [%g3] ASI_DMMU 327 stxa %g2, [%g3] ASI_DMMU
479 membar #Sync 328 membar #Sync
480 add %g6, TI_FPREGS, %g2 329 add %g6, TI_FPREGS, %g2
@@ -495,45 +344,17 @@ cplus_fptrap_insn_4:
495 ba,pt %xcc, etrap 344 ba,pt %xcc, etrap
496 wr %g0, 0, %fprs 345 wr %g0, 0, %fprs
497 346
498cplus_fptrap_1:
499 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
500
501 .globl cheetah_plus_patch_fpdis
502cheetah_plus_patch_fpdis:
503 /* We configure the dTLB512_0 for 4MB pages and the
504 * dTLB512_1 for 8K pages when in context zero.
505 */
506 sethi %hi(cplus_fptrap_1), %o0
507 lduw [%o0 + %lo(cplus_fptrap_1)], %o1
508
509 set cplus_fptrap_insn_1, %o2
510 stw %o1, [%o2]
511 flush %o2
512 set cplus_fptrap_insn_2, %o2
513 stw %o1, [%o2]
514 flush %o2
515 set cplus_fptrap_insn_3, %o2
516 stw %o1, [%o2]
517 flush %o2
518 set cplus_fptrap_insn_4, %o2
519 stw %o1, [%o2]
520 flush %o2
521
522 retl
523 nop
524
525 /* The registers for cross calls will be: 347 /* The registers for cross calls will be:
526 * 348 *
527 * DATA 0: [low 32-bits] Address of function to call, jmp to this 349 * DATA 0: [low 32-bits] Address of function to call, jmp to this
528 * [high 32-bits] MMU Context Argument 0, place in %g5 350 * [high 32-bits] MMU Context Argument 0, place in %g5
529 * DATA 1: Address Argument 1, place in %g6 351 * DATA 1: Address Argument 1, place in %g1
530 * DATA 2: Address Argument 2, place in %g7 352 * DATA 2: Address Argument 2, place in %g7
531 * 353 *
532 * With this method we can do most of the cross-call tlb/cache 354 * With this method we can do most of the cross-call tlb/cache
533 * flushing very quickly. 355 * flushing very quickly.
534 * 356 *
535 * Current CPU's IRQ worklist table is locked into %g1, 357 * Current CPU's IRQ worklist table is locked into %g6, don't touch.
536 * don't touch.
537 */ 358 */
538 .text 359 .text
539 .align 32 360 .align 32
@@ -1007,13 +828,14 @@ cheetah_plus_dcpe_trap_vector:
1007 nop 828 nop
1008 829
1009do_cheetah_plus_data_parity: 830do_cheetah_plus_data_parity:
1010 ba,pt %xcc, etrap 831 rdpr %pil, %g2
832 wrpr %g0, 15, %pil
833 ba,pt %xcc, etrap_irq
1011 rd %pc, %g7 834 rd %pc, %g7
1012 mov 0x0, %o0 835 mov 0x0, %o0
1013 call cheetah_plus_parity_error 836 call cheetah_plus_parity_error
1014 add %sp, PTREGS_OFF, %o1 837 add %sp, PTREGS_OFF, %o1
1015 ba,pt %xcc, rtrap 838 ba,a,pt %xcc, rtrap_irq
1016 clr %l6
1017 839
1018cheetah_plus_dcpe_trap_vector_tl1: 840cheetah_plus_dcpe_trap_vector_tl1:
1019 membar #Sync 841 membar #Sync
@@ -1037,13 +859,14 @@ cheetah_plus_icpe_trap_vector:
1037 nop 859 nop
1038 860
1039do_cheetah_plus_insn_parity: 861do_cheetah_plus_insn_parity:
1040 ba,pt %xcc, etrap 862 rdpr %pil, %g2
863 wrpr %g0, 15, %pil
864 ba,pt %xcc, etrap_irq
1041 rd %pc, %g7 865 rd %pc, %g7
1042 mov 0x1, %o0 866 mov 0x1, %o0
1043 call cheetah_plus_parity_error 867 call cheetah_plus_parity_error
1044 add %sp, PTREGS_OFF, %o1 868 add %sp, PTREGS_OFF, %o1
1045 ba,pt %xcc, rtrap 869 ba,a,pt %xcc, rtrap_irq
1046 clr %l6
1047 870
1048cheetah_plus_icpe_trap_vector_tl1: 871cheetah_plus_icpe_trap_vector_tl1:
1049 membar #Sync 872 membar #Sync
@@ -1076,6 +899,10 @@ do_dcpe_tl1:
1076 nop 899 nop
1077 wrpr %g1, %tl ! Restore original trap level 900 wrpr %g1, %tl ! Restore original trap level
1078do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */ 901do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
902 sethi %hi(dcache_parity_tl1_occurred), %g2
903 lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
904 add %g1, 1, %g1
905 stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
1079 /* Reset D-cache parity */ 906 /* Reset D-cache parity */
1080 sethi %hi(1 << 16), %g1 ! D-cache size 907 sethi %hi(1 << 16), %g1 ! D-cache size
1081 mov (1 << 5), %g2 ! D-cache line size 908 mov (1 << 5), %g2 ! D-cache line size
@@ -1122,6 +949,10 @@ do_icpe_tl1:
1122 nop 949 nop
1123 wrpr %g1, %tl ! Restore original trap level 950 wrpr %g1, %tl ! Restore original trap level
1124do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */ 951do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
952 sethi %hi(icache_parity_tl1_occurred), %g2
953 lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
954 add %g1, 1, %g1
955 stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
1125 /* Flush I-cache */ 956 /* Flush I-cache */
1126 sethi %hi(1 << 15), %g1 ! I-cache size 957 sethi %hi(1 << 15), %g1 ! I-cache size
1127 mov (1 << 5), %g2 ! I-cache line size 958 mov (1 << 5), %g2 ! I-cache line size
diff --git a/arch/sparc64/kernel/etrap.S b/arch/sparc64/kernel/etrap.S
index 50d2af1d98ae..0d8eba21111b 100644
--- a/arch/sparc64/kernel/etrap.S
+++ b/arch/sparc64/kernel/etrap.S
@@ -68,12 +68,8 @@ etrap_irq:
68 68
69 wrpr %g3, 0, %otherwin 69 wrpr %g3, 0, %otherwin
70 wrpr %g2, 0, %wstate 70 wrpr %g2, 0, %wstate
71cplus_etrap_insn_1: 71 sethi %hi(sparc64_kern_pri_context), %g2
72 sethi %hi(0), %g3 72 ldx [%g2 + %lo(sparc64_kern_pri_context)], %g3
73 sllx %g3, 32, %g3
74cplus_etrap_insn_2:
75 sethi %hi(0), %g2
76 or %g3, %g2, %g3
77 stxa %g3, [%l4] ASI_DMMU 73 stxa %g3, [%l4] ASI_DMMU
78 flush %l6 74 flush %l6
79 wr %g0, ASI_AIUS, %asi 75 wr %g0, ASI_AIUS, %asi
@@ -215,12 +211,8 @@ scetrap: rdpr %pil, %g2
215 mov PRIMARY_CONTEXT, %l4 211 mov PRIMARY_CONTEXT, %l4
216 wrpr %g3, 0, %otherwin 212 wrpr %g3, 0, %otherwin
217 wrpr %g2, 0, %wstate 213 wrpr %g2, 0, %wstate
218cplus_etrap_insn_3: 214 sethi %hi(sparc64_kern_pri_context), %g2
219 sethi %hi(0), %g3 215 ldx [%g2 + %lo(sparc64_kern_pri_context)], %g3
220 sllx %g3, 32, %g3
221cplus_etrap_insn_4:
222 sethi %hi(0), %g2
223 or %g3, %g2, %g3
224 stxa %g3, [%l4] ASI_DMMU 216 stxa %g3, [%l4] ASI_DMMU
225 flush %l6 217 flush %l6
226 218
@@ -264,38 +256,3 @@ cplus_etrap_insn_4:
264 256
265#undef TASK_REGOFF 257#undef TASK_REGOFF
266#undef ETRAP_PSTATE1 258#undef ETRAP_PSTATE1
267
268cplus_einsn_1:
269 sethi %uhi(CTX_CHEETAH_PLUS_NUC), %g3
270cplus_einsn_2:
271 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
272
273 .globl cheetah_plus_patch_etrap
274cheetah_plus_patch_etrap:
275 /* We configure the dTLB512_0 for 4MB pages and the
276 * dTLB512_1 for 8K pages when in context zero.
277 */
278 sethi %hi(cplus_einsn_1), %o0
279 sethi %hi(cplus_etrap_insn_1), %o2
280 lduw [%o0 + %lo(cplus_einsn_1)], %o1
281 or %o2, %lo(cplus_etrap_insn_1), %o2
282 stw %o1, [%o2]
283 flush %o2
284 sethi %hi(cplus_etrap_insn_3), %o2
285 or %o2, %lo(cplus_etrap_insn_3), %o2
286 stw %o1, [%o2]
287 flush %o2
288
289 sethi %hi(cplus_einsn_2), %o0
290 sethi %hi(cplus_etrap_insn_2), %o2
291 lduw [%o0 + %lo(cplus_einsn_2)], %o1
292 or %o2, %lo(cplus_etrap_insn_2), %o2
293 stw %o1, [%o2]
294 flush %o2
295 sethi %hi(cplus_etrap_insn_4), %o2
296 or %o2, %lo(cplus_etrap_insn_4), %o2
297 stw %o1, [%o2]
298 flush %o2
299
300 retl
301 nop
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index 1fa06c4e3bdb..b49dcd4504b0 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -28,19 +28,14 @@
28#include <asm/mmu.h> 28#include <asm/mmu.h>
29 29
30/* This section from from _start to sparc64_boot_end should fit into 30/* This section from from _start to sparc64_boot_end should fit into
31 * 0x0000.0000.0040.4000 to 0x0000.0000.0040.8000 and will be sharing space 31 * 0x0000000000404000 to 0x0000000000408000.
32 * with bootup_user_stack, which is from 0x0000.0000.0040.4000 to
33 * 0x0000.0000.0040.6000 and empty_bad_page, which is from
34 * 0x0000.0000.0040.6000 to 0x0000.0000.0040.8000.
35 */ 32 */
36
37 .text 33 .text
38 .globl start, _start, stext, _stext 34 .globl start, _start, stext, _stext
39_start: 35_start:
40start: 36start:
41_stext: 37_stext:
42stext: 38stext:
43bootup_user_stack:
44! 0x0000000000404000 39! 0x0000000000404000
45 b sparc64_boot 40 b sparc64_boot
46 flushw /* Flush register file. */ 41 flushw /* Flush register file. */
@@ -80,15 +75,169 @@ sparc_ramdisk_image64:
80 .xword 0 75 .xword 0
81 .word _end 76 .word _end
82 77
83 /* We must be careful, 32-bit OpenBOOT will get confused if it 78 /* PROM cif handler code address is in %o4. */
84 * tries to save away a register window to a 64-bit kernel 79sparc64_boot:
85 * stack address. Flush all windows, disable interrupts, 801: rd %pc, %g7
86 * remap if necessary, jump onto kernel trap table, then kernel 81 set 1b, %g1
87 * stack, or else we die. 82 cmp %g1, %g7
83 be,pn %xcc, sparc64_boot_after_remap
84 mov %o4, %l7
85
86 /* We need to remap the kernel. Use position independant
87 * code to remap us to KERNBASE.
88 * 88 *
89 * PROM entry point is on %o4 89 * SILO can invoke us with 32-bit address masking enabled,
90 * so make sure that's clear.
90 */ 91 */
91sparc64_boot: 92 rdpr %pstate, %g1
93 andn %g1, PSTATE_AM, %g1
94 wrpr %g1, 0x0, %pstate
95 ba,a,pt %xcc, 1f
96
97 .globl prom_finddev_name, prom_chosen_path
98 .globl prom_getprop_name, prom_mmu_name
99 .globl prom_callmethod_name, prom_translate_name
100 .globl prom_map_name, prom_unmap_name, prom_mmu_ihandle_cache
101 .globl prom_boot_mapped_pc, prom_boot_mapping_mode
102 .globl prom_boot_mapping_phys_high, prom_boot_mapping_phys_low
103prom_finddev_name:
104 .asciz "finddevice"
105prom_chosen_path:
106 .asciz "/chosen"
107prom_getprop_name:
108 .asciz "getprop"
109prom_mmu_name:
110 .asciz "mmu"
111prom_callmethod_name:
112 .asciz "call-method"
113prom_translate_name:
114 .asciz "translate"
115prom_map_name:
116 .asciz "map"
117prom_unmap_name:
118 .asciz "unmap"
119 .align 4
120prom_mmu_ihandle_cache:
121 .word 0
122prom_boot_mapped_pc:
123 .word 0
124prom_boot_mapping_mode:
125 .word 0
126 .align 8
127prom_boot_mapping_phys_high:
128 .xword 0
129prom_boot_mapping_phys_low:
130 .xword 0
1311:
132 rd %pc, %l0
133 mov (1b - prom_finddev_name), %l1
134 mov (1b - prom_chosen_path), %l2
135 mov (1b - prom_boot_mapped_pc), %l3
136 sub %l0, %l1, %l1
137 sub %l0, %l2, %l2
138 sub %l0, %l3, %l3
139 stw %l0, [%l3]
140 sub %sp, (192 + 128), %sp
141
142 /* chosen_node = prom_finddevice("/chosen") */
143 stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "finddevice"
144 mov 1, %l3
145 stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 1
146 stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
147 stx %l2, [%sp + 2047 + 128 + 0x18] ! arg1, "/chosen"
148 stx %g0, [%sp + 2047 + 128 + 0x20] ! ret1
149 call %l7
150 add %sp, (2047 + 128), %o0 ! argument array
151
152 ldx [%sp + 2047 + 128 + 0x20], %l4 ! chosen device node
153
154 mov (1b - prom_getprop_name), %l1
155 mov (1b - prom_mmu_name), %l2
156 mov (1b - prom_mmu_ihandle_cache), %l5
157 sub %l0, %l1, %l1
158 sub %l0, %l2, %l2
159 sub %l0, %l5, %l5
160
161 /* prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu") */
162 stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "getprop"
163 mov 4, %l3
164 stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 4
165 mov 1, %l3
166 stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
167 stx %l4, [%sp + 2047 + 128 + 0x18] ! arg1, chosen_node
168 stx %l2, [%sp + 2047 + 128 + 0x20] ! arg2, "mmu"
169 stx %l5, [%sp + 2047 + 128 + 0x28] ! arg3, &prom_mmu_ihandle_cache
170 mov 4, %l3
171 stx %l3, [%sp + 2047 + 128 + 0x30] ! arg4, sizeof(arg3)
172 stx %g0, [%sp + 2047 + 128 + 0x38] ! ret1
173 call %l7
174 add %sp, (2047 + 128), %o0 ! argument array
175
176 mov (1b - prom_callmethod_name), %l1
177 mov (1b - prom_translate_name), %l2
178 sub %l0, %l1, %l1
179 sub %l0, %l2, %l2
180 lduw [%l5], %l5 ! prom_mmu_ihandle_cache
181
182 stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "call-method"
183 mov 3, %l3
184 stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 3
185 mov 5, %l3
186 stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 5
187 stx %l2, [%sp + 2047 + 128 + 0x18] ! arg1: "translate"
188 stx %l5, [%sp + 2047 + 128 + 0x20] ! arg2: prom_mmu_ihandle_cache
189 /* PAGE align */
190 srlx %l0, 13, %l3
191 sllx %l3, 13, %l3
192 stx %l3, [%sp + 2047 + 128 + 0x28] ! arg3: vaddr, our PC
193 stx %g0, [%sp + 2047 + 128 + 0x30] ! res1
194 stx %g0, [%sp + 2047 + 128 + 0x38] ! res2
195 stx %g0, [%sp + 2047 + 128 + 0x40] ! res3
196 stx %g0, [%sp + 2047 + 128 + 0x48] ! res4
197 stx %g0, [%sp + 2047 + 128 + 0x50] ! res5
198 call %l7
199 add %sp, (2047 + 128), %o0 ! argument array
200
201 ldx [%sp + 2047 + 128 + 0x40], %l1 ! translation mode
202 mov (1b - prom_boot_mapping_mode), %l4
203 sub %l0, %l4, %l4
204 stw %l1, [%l4]
205 mov (1b - prom_boot_mapping_phys_high), %l4
206 sub %l0, %l4, %l4
207 ldx [%sp + 2047 + 128 + 0x48], %l2 ! physaddr high
208 stx %l2, [%l4 + 0x0]
209 ldx [%sp + 2047 + 128 + 0x50], %l3 ! physaddr low
210 /* 4MB align */
211 srlx %l3, 22, %l3
212 sllx %l3, 22, %l3
213 stx %l3, [%l4 + 0x8]
214
215 /* Leave service as-is, "call-method" */
216 mov 7, %l3
217 stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 7
218 mov 1, %l3
219 stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
220 mov (1b - prom_map_name), %l3
221 sub %l0, %l3, %l3
222 stx %l3, [%sp + 2047 + 128 + 0x18] ! arg1: "map"
223 /* Leave arg2 as-is, prom_mmu_ihandle_cache */
224 mov -1, %l3
225 stx %l3, [%sp + 2047 + 128 + 0x28] ! arg3: mode (-1 default)
226 sethi %hi(8 * 1024 * 1024), %l3
227 stx %l3, [%sp + 2047 + 128 + 0x30] ! arg4: size (8MB)
228 sethi %hi(KERNBASE), %l3
229 stx %l3, [%sp + 2047 + 128 + 0x38] ! arg5: vaddr (KERNBASE)
230 stx %g0, [%sp + 2047 + 128 + 0x40] ! arg6: empty
231 mov (1b - prom_boot_mapping_phys_low), %l3
232 sub %l0, %l3, %l3
233 ldx [%l3], %l3
234 stx %l3, [%sp + 2047 + 128 + 0x48] ! arg7: phys addr
235 call %l7
236 add %sp, (2047 + 128), %o0 ! argument array
237
238 add %sp, (192 + 128), %sp
239
240sparc64_boot_after_remap:
92 BRANCH_IF_CHEETAH_BASE(g1,g7,cheetah_boot) 241 BRANCH_IF_CHEETAH_BASE(g1,g7,cheetah_boot)
93 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,cheetah_plus_boot) 242 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,cheetah_plus_boot)
94 ba,pt %xcc, spitfire_boot 243 ba,pt %xcc, spitfire_boot
@@ -125,185 +274,7 @@ cheetah_generic_boot:
125 stxa %g0, [%g3] ASI_IMMU 274 stxa %g0, [%g3] ASI_IMMU
126 membar #Sync 275 membar #Sync
127 276
128 wrpr %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate 277 ba,a,pt %xcc, jump_to_sun4u_init
129 wr %g0, 0, %fprs
130
131 /* Just like for Spitfire, we probe itlb-2 for a mapping which
132 * matches our current %pc. We take the physical address in
133 * that mapping and use it to make our own.
134 */
135
136 /* %g5 holds the tlb data */
137 sethi %uhi(_PAGE_VALID | _PAGE_SZ4MB), %g5
138 sllx %g5, 32, %g5
139 or %g5, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W | _PAGE_G), %g5
140
141 /* Put PADDR tlb data mask into %g3. */
142 sethi %uhi(_PAGE_PADDR), %g3
143 or %g3, %ulo(_PAGE_PADDR), %g3
144 sllx %g3, 32, %g3
145 sethi %hi(_PAGE_PADDR), %g7
146 or %g7, %lo(_PAGE_PADDR), %g7
147 or %g3, %g7, %g3
148
149 set 2 << 16, %l0 /* TLB entry walker. */
150 set 0x1fff, %l2 /* Page mask. */
151 rd %pc, %l3
152 andn %l3, %l2, %g2 /* vaddr comparator */
153
1541: ldxa [%l0] ASI_ITLB_TAG_READ, %g1
155 membar #Sync
156 andn %g1, %l2, %g1
157 cmp %g1, %g2
158 be,pn %xcc, cheetah_got_tlbentry
159 nop
160 and %l0, (127 << 3), %g1
161 cmp %g1, (127 << 3)
162 blu,pt %xcc, 1b
163 add %l0, (1 << 3), %l0
164
165 /* Search the small TLB. OBP never maps us like that but
166 * newer SILO can.
167 */
168 clr %l0
169
1701: ldxa [%l0] ASI_ITLB_TAG_READ, %g1
171 membar #Sync
172 andn %g1, %l2, %g1
173 cmp %g1, %g2
174 be,pn %xcc, cheetah_got_tlbentry
175 nop
176 cmp %l0, (15 << 3)
177 blu,pt %xcc, 1b
178 add %l0, (1 << 3), %l0
179
180 /* BUG() if we get here... */
181 ta 0x5
182
183cheetah_got_tlbentry:
184 ldxa [%l0] ASI_ITLB_DATA_ACCESS, %g0
185 ldxa [%l0] ASI_ITLB_DATA_ACCESS, %g1
186 membar #Sync
187 and %g1, %g3, %g1
188 set 0x5fff, %l0
189 andn %g1, %l0, %g1
190 or %g5, %g1, %g5
191
192 /* Clear out any KERNBASE area entries. */
193 set 2 << 16, %l0
194 sethi %hi(KERNBASE), %g3
195 sethi %hi(KERNBASE<<1), %g7
196 mov TLB_TAG_ACCESS, %l7
197
198 /* First, check ITLB */
1991: ldxa [%l0] ASI_ITLB_TAG_READ, %g1
200 membar #Sync
201 andn %g1, %l2, %g1
202 cmp %g1, %g3
203 blu,pn %xcc, 2f
204 cmp %g1, %g7
205 bgeu,pn %xcc, 2f
206 nop
207 stxa %g0, [%l7] ASI_IMMU
208 membar #Sync
209 stxa %g0, [%l0] ASI_ITLB_DATA_ACCESS
210 membar #Sync
211
2122: and %l0, (127 << 3), %g1
213 cmp %g1, (127 << 3)
214 blu,pt %xcc, 1b
215 add %l0, (1 << 3), %l0
216
217 /* Next, check DTLB */
218 set 2 << 16, %l0
2191: ldxa [%l0] ASI_DTLB_TAG_READ, %g1
220 membar #Sync
221 andn %g1, %l2, %g1
222 cmp %g1, %g3
223 blu,pn %xcc, 2f
224 cmp %g1, %g7
225 bgeu,pn %xcc, 2f
226 nop
227 stxa %g0, [%l7] ASI_DMMU
228 membar #Sync
229 stxa %g0, [%l0] ASI_DTLB_DATA_ACCESS
230 membar #Sync
231
2322: and %l0, (511 << 3), %g1
233 cmp %g1, (511 << 3)
234 blu,pt %xcc, 1b
235 add %l0, (1 << 3), %l0
236
237 /* On Cheetah+, have to check second DTLB. */
238 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,l0,2f)
239 ba,pt %xcc, 9f
240 nop
241
2422: set 3 << 16, %l0
2431: ldxa [%l0] ASI_DTLB_TAG_READ, %g1
244 membar #Sync
245 andn %g1, %l2, %g1
246 cmp %g1, %g3
247 blu,pn %xcc, 2f
248 cmp %g1, %g7
249 bgeu,pn %xcc, 2f
250 nop
251 stxa %g0, [%l7] ASI_DMMU
252 membar #Sync
253 stxa %g0, [%l0] ASI_DTLB_DATA_ACCESS
254 membar #Sync
255
2562: and %l0, (511 << 3), %g1
257 cmp %g1, (511 << 3)
258 blu,pt %xcc, 1b
259 add %l0, (1 << 3), %l0
260
2619:
262
263 /* Now lock the TTE we created into ITLB-0 and DTLB-0,
264 * entry 15 (and maybe 14 too).
265 */
266 sethi %hi(KERNBASE), %g3
267 set (0 << 16) | (15 << 3), %g7
268 stxa %g3, [%l7] ASI_DMMU
269 membar #Sync
270 stxa %g5, [%g7] ASI_DTLB_DATA_ACCESS
271 membar #Sync
272 stxa %g3, [%l7] ASI_IMMU
273 membar #Sync
274 stxa %g5, [%g7] ASI_ITLB_DATA_ACCESS
275 membar #Sync
276 flush %g3
277 membar #Sync
278 sethi %hi(_end), %g3 /* Check for bigkernel case */
279 or %g3, %lo(_end), %g3
280 srl %g3, 23, %g3 /* Check if _end > 8M */
281 brz,pt %g3, 1f
282 sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */
283 sethi %hi(0x400000), %g3
284 or %g3, %lo(0x400000), %g3
285 add %g5, %g3, %g5 /* New tte data */
286 andn %g5, (_PAGE_G), %g5
287 sethi %hi(KERNBASE+0x400000), %g3
288 or %g3, %lo(KERNBASE+0x400000), %g3
289 set (0 << 16) | (14 << 3), %g7
290 stxa %g3, [%l7] ASI_DMMU
291 membar #Sync
292 stxa %g5, [%g7] ASI_DTLB_DATA_ACCESS
293 membar #Sync
294 stxa %g3, [%l7] ASI_IMMU
295 membar #Sync
296 stxa %g5, [%g7] ASI_ITLB_DATA_ACCESS
297 membar #Sync
298 flush %g3
299 membar #Sync
300 sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */
301 ba,pt %xcc, 1f
302 nop
303
3041: set sun4u_init, %g2
305 jmpl %g2 + %g0, %g0
306 nop
307 278
308spitfire_boot: 279spitfire_boot:
309 /* Typically PROM has already enabled both MMU's and both on-chip 280 /* Typically PROM has already enabled both MMU's and both on-chip
@@ -313,6 +284,7 @@ spitfire_boot:
313 stxa %g1, [%g0] ASI_LSU_CONTROL 284 stxa %g1, [%g0] ASI_LSU_CONTROL
314 membar #Sync 285 membar #Sync
315 286
287jump_to_sun4u_init:
316 /* 288 /*
317 * Make sure we are in privileged mode, have address masking, 289 * Make sure we are in privileged mode, have address masking,
318 * using the ordinary globals and have enabled floating 290 * using the ordinary globals and have enabled floating
@@ -324,151 +296,6 @@ spitfire_boot:
324 wrpr %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate 296 wrpr %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate
325 wr %g0, 0, %fprs 297 wr %g0, 0, %fprs
326 298
327spitfire_create_mappings:
328 /* %g5 holds the tlb data */
329 sethi %uhi(_PAGE_VALID | _PAGE_SZ4MB), %g5
330 sllx %g5, 32, %g5
331 or %g5, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W | _PAGE_G), %g5
332
333 /* Base of physical memory cannot reliably be assumed to be
334 * at 0x0! Figure out where it happens to be. -DaveM
335 */
336
337 /* Put PADDR tlb data mask into %g3. */
338 sethi %uhi(_PAGE_PADDR_SF), %g3
339 or %g3, %ulo(_PAGE_PADDR_SF), %g3
340 sllx %g3, 32, %g3
341 sethi %hi(_PAGE_PADDR_SF), %g7
342 or %g7, %lo(_PAGE_PADDR_SF), %g7
343 or %g3, %g7, %g3
344
345 /* Walk through entire ITLB, looking for entry which maps
346 * our %pc currently, stick PADDR from there into %g5 tlb data.
347 */
348 clr %l0 /* TLB entry walker. */
349 set 0x1fff, %l2 /* Page mask. */
350 rd %pc, %l3
351 andn %l3, %l2, %g2 /* vaddr comparator */
3521:
353 /* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */
354 ldxa [%l0] ASI_ITLB_TAG_READ, %g1
355 nop
356 nop
357 nop
358 andn %g1, %l2, %g1 /* Get vaddr */
359 cmp %g1, %g2
360 be,a,pn %xcc, spitfire_got_tlbentry
361 ldxa [%l0] ASI_ITLB_DATA_ACCESS, %g1
362 cmp %l0, (63 << 3)
363 blu,pt %xcc, 1b
364 add %l0, (1 << 3), %l0
365
366 /* BUG() if we get here... */
367 ta 0x5
368
369spitfire_got_tlbentry:
370 /* Nops here again, perhaps Cheetah/Blackbird are better behaved... */
371 nop
372 nop
373 nop
374 and %g1, %g3, %g1 /* Mask to just get paddr bits. */
375 set 0x5fff, %l3 /* Mask offset to get phys base. */
376 andn %g1, %l3, %g1
377
378 /* NOTE: We hold on to %g1 paddr base as we need it below to lock
379 * NOTE: the PROM cif code into the TLB.
380 */
381
382 or %g5, %g1, %g5 /* Or it into TAG being built. */
383
384 clr %l0 /* TLB entry walker. */
385 sethi %hi(KERNBASE), %g3 /* 4M lower limit */
386 sethi %hi(KERNBASE<<1), %g7 /* 8M upper limit */
387 mov TLB_TAG_ACCESS, %l7
3881:
389 /* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */
390 ldxa [%l0] ASI_ITLB_TAG_READ, %g1
391 nop
392 nop
393 nop
394 andn %g1, %l2, %g1 /* Get vaddr */
395 cmp %g1, %g3
396 blu,pn %xcc, 2f
397 cmp %g1, %g7
398 bgeu,pn %xcc, 2f
399 nop
400 stxa %g0, [%l7] ASI_IMMU
401 stxa %g0, [%l0] ASI_ITLB_DATA_ACCESS
402 membar #Sync
4032:
404 cmp %l0, (63 << 3)
405 blu,pt %xcc, 1b
406 add %l0, (1 << 3), %l0
407
408 nop; nop; nop
409
410 clr %l0 /* TLB entry walker. */
4111:
412 /* Yes, the nops seem to be necessary for now, don't ask me why. -DaveM */
413 ldxa [%l0] ASI_DTLB_TAG_READ, %g1
414 nop
415 nop
416 nop
417 andn %g1, %l2, %g1 /* Get vaddr */
418 cmp %g1, %g3
419 blu,pn %xcc, 2f
420 cmp %g1, %g7
421 bgeu,pn %xcc, 2f
422 nop
423 stxa %g0, [%l7] ASI_DMMU
424 stxa %g0, [%l0] ASI_DTLB_DATA_ACCESS
425 membar #Sync
4262:
427 cmp %l0, (63 << 3)
428 blu,pt %xcc, 1b
429 add %l0, (1 << 3), %l0
430
431 nop; nop; nop
432
433
434 /* PROM never puts any TLB entries into the MMU with the lock bit
435 * set. So we gladly use tlb entry 63 for KERNBASE. And maybe 62 too.
436 */
437
438 sethi %hi(KERNBASE), %g3
439 mov (63 << 3), %g7
440 stxa %g3, [%l7] ASI_DMMU /* KERNBASE into TLB TAG */
441 stxa %g5, [%g7] ASI_DTLB_DATA_ACCESS /* TTE into TLB DATA */
442 membar #Sync
443 stxa %g3, [%l7] ASI_IMMU /* KERNBASE into TLB TAG */
444 stxa %g5, [%g7] ASI_ITLB_DATA_ACCESS /* TTE into TLB DATA */
445 membar #Sync
446 flush %g3
447 membar #Sync
448 sethi %hi(_end), %g3 /* Check for bigkernel case */
449 or %g3, %lo(_end), %g3
450 srl %g3, 23, %g3 /* Check if _end > 8M */
451 brz,pt %g3, 2f
452 sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */
453 sethi %hi(0x400000), %g3
454 or %g3, %lo(0x400000), %g3
455 add %g5, %g3, %g5 /* New tte data */
456 andn %g5, (_PAGE_G), %g5
457 sethi %hi(KERNBASE+0x400000), %g3
458 or %g3, %lo(KERNBASE+0x400000), %g3
459 mov (62 << 3), %g7
460 stxa %g3, [%l7] ASI_DMMU
461 stxa %g5, [%g7] ASI_DTLB_DATA_ACCESS
462 membar #Sync
463 stxa %g3, [%l7] ASI_IMMU
464 stxa %g5, [%g7] ASI_ITLB_DATA_ACCESS
465 membar #Sync
466 flush %g3
467 membar #Sync
468 sethi %hi(KERNBASE), %g3 /* Restore for fixup code below */
4692: ba,pt %xcc, 1f
470 nop
4711:
472 set sun4u_init, %g2 299 set sun4u_init, %g2
473 jmpl %g2 + %g0, %g0 300 jmpl %g2 + %g0, %g0
474 nop 301 nop
@@ -483,38 +310,12 @@ sun4u_init:
483 stxa %g0, [%g7] ASI_DMMU 310 stxa %g0, [%g7] ASI_DMMU
484 membar #Sync 311 membar #Sync
485 312
486 /* We are now safely (we hope) in Nucleus context (0), rewrite
487 * the KERNBASE TTE's so they no longer have the global bit set.
488 * Don't forget to setup TAG_ACCESS first 8-)
489 */
490 mov TLB_TAG_ACCESS, %g2
491 stxa %g3, [%g2] ASI_IMMU
492 stxa %g3, [%g2] ASI_DMMU
493 membar #Sync
494
495 BRANCH_IF_ANY_CHEETAH(g1,g7,cheetah_tlb_fixup) 313 BRANCH_IF_ANY_CHEETAH(g1,g7,cheetah_tlb_fixup)
496 314
497 ba,pt %xcc, spitfire_tlb_fixup 315 ba,pt %xcc, spitfire_tlb_fixup
498 nop 316 nop
499 317
500cheetah_tlb_fixup: 318cheetah_tlb_fixup:
501 set (0 << 16) | (15 << 3), %g7
502 ldxa [%g7] ASI_ITLB_DATA_ACCESS, %g0
503 ldxa [%g7] ASI_ITLB_DATA_ACCESS, %g1
504 andn %g1, (_PAGE_G), %g1
505 stxa %g1, [%g7] ASI_ITLB_DATA_ACCESS
506 membar #Sync
507
508 ldxa [%g7] ASI_DTLB_DATA_ACCESS, %g0
509 ldxa [%g7] ASI_DTLB_DATA_ACCESS, %g1
510 andn %g1, (_PAGE_G), %g1
511 stxa %g1, [%g7] ASI_DTLB_DATA_ACCESS
512 membar #Sync
513
514 /* Kill instruction prefetch queues. */
515 flush %g3
516 membar #Sync
517
518 mov 2, %g2 /* Set TLB type to cheetah+. */ 319 mov 2, %g2 /* Set TLB type to cheetah+. */
519 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,1f) 320 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,1f)
520 321
@@ -523,23 +324,7 @@ cheetah_tlb_fixup:
5231: sethi %hi(tlb_type), %g1 3241: sethi %hi(tlb_type), %g1
524 stw %g2, [%g1 + %lo(tlb_type)] 325 stw %g2, [%g1 + %lo(tlb_type)]
525 326
526 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,1f) 327 /* Patch copy/page operations to cheetah optimized versions. */
527 ba,pt %xcc, 2f
528 nop
529
5301: /* Patch context register writes to support nucleus page
531 * size correctly.
532 */
533 call cheetah_plus_patch_etrap
534 nop
535 call cheetah_plus_patch_rtrap
536 nop
537 call cheetah_plus_patch_fpdis
538 nop
539 call cheetah_plus_patch_winfixup
540 nop
541
5422: /* Patch copy/page operations to cheetah optimized versions. */
543 call cheetah_patch_copyops 328 call cheetah_patch_copyops
544 nop 329 nop
545 call cheetah_patch_copy_page 330 call cheetah_patch_copy_page
@@ -551,21 +336,6 @@ cheetah_tlb_fixup:
551 nop 336 nop
552 337
553spitfire_tlb_fixup: 338spitfire_tlb_fixup:
554 mov (63 << 3), %g7
555 ldxa [%g7] ASI_ITLB_DATA_ACCESS, %g1
556 andn %g1, (_PAGE_G), %g1
557 stxa %g1, [%g7] ASI_ITLB_DATA_ACCESS
558 membar #Sync
559
560 ldxa [%g7] ASI_DTLB_DATA_ACCESS, %g1
561 andn %g1, (_PAGE_G), %g1
562 stxa %g1, [%g7] ASI_DTLB_DATA_ACCESS
563 membar #Sync
564
565 /* Kill instruction prefetch queues. */
566 flush %g3
567 membar #Sync
568
569 /* Set TLB type to spitfire. */ 339 /* Set TLB type to spitfire. */
570 mov 0, %g2 340 mov 0, %g2
571 sethi %hi(tlb_type), %g1 341 sethi %hi(tlb_type), %g1
@@ -578,24 +348,6 @@ tlb_fixup_done:
578 mov %sp, %l6 348 mov %sp, %l6
579 mov %o4, %l7 349 mov %o4, %l7
580 350
581#if 0 /* We don't do it like this anymore, but for historical hack value
582 * I leave this snippet here to show how crazy we can be sometimes. 8-)
583 */
584
585 /* Setup "Linux Current Register", thanks Sun 8-) */
586 wr %g0, 0x1, %pcr
587
588 /* Blackbird errata workaround. See commentary in
589 * smp.c:smp_percpu_timer_interrupt() for more
590 * information.
591 */
592 ba,pt %xcc, 99f
593 nop
594 .align 64
59599: wr %g6, %g0, %pic
596 rd %pic, %g0
597#endif
598
599 wr %g0, ASI_P, %asi 351 wr %g0, ASI_P, %asi
600 mov 1, %g1 352 mov 1, %g1
601 sllx %g1, THREAD_SHIFT, %g1 353 sllx %g1, THREAD_SHIFT, %g1
@@ -629,32 +381,78 @@ tlb_fixup_done:
629 nop 381 nop
630 /* Not reached... */ 382 /* Not reached... */
631 383
632/* IMPORTANT NOTE: Whenever making changes here, check 384 /* This is meant to allow the sharing of this code between
633 * trampoline.S as well. -jj */ 385 * boot processor invocation (via setup_tba() below) and
634 .globl setup_tba 386 * secondary processor startup (via trampoline.S). The
635setup_tba: /* i0 = is_starfire */ 387 * former does use this code, the latter does not yet due
636 save %sp, -160, %sp 388 * to some complexities. That should be fixed up at some
389 * point.
390 *
391 * There used to be enormous complexity wrt. transferring
392 * over from the firwmare's trap table to the Linux kernel's.
393 * For example, there was a chicken & egg problem wrt. building
394 * the OBP page tables, yet needing to be on the Linux kernel
395 * trap table (to translate PAGE_OFFSET addresses) in order to
396 * do that.
397 *
398 * We now handle OBP tlb misses differently, via linear lookups
399 * into the prom_trans[] array. So that specific problem no
400 * longer exists. Yet, unfortunately there are still some issues
401 * preventing trampoline.S from using this code... ho hum.
402 */
403 .globl setup_trap_table
404setup_trap_table:
405 save %sp, -192, %sp
637 406
638 rdpr %tba, %g7 407 /* Force interrupts to be disabled. */
639 sethi %hi(prom_tba), %o1 408 rdpr %pstate, %o1
640 or %o1, %lo(prom_tba), %o1 409 andn %o1, PSTATE_IE, %o1
641 stx %g7, [%o1] 410 wrpr %o1, 0x0, %pstate
411 wrpr %g0, 15, %pil
412
413 /* Make the firmware call to jump over to the Linux trap table. */
414 call prom_set_trap_table
415 sethi %hi(sparc64_ttable_tl0), %o0
416
417 /* Start using proper page size encodings in ctx register. */
418 sethi %hi(sparc64_kern_pri_context), %g3
419 ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
420 mov PRIMARY_CONTEXT, %g1
421 stxa %g2, [%g1] ASI_DMMU
422 membar #Sync
423
424 /* The Linux trap handlers expect various trap global registers
425 * to be setup with some fixed values. So here we set these
426 * up very carefully. These globals are:
427 *
428 * Alternate Globals (PSTATE_AG):
429 *
430 * %g6 --> current_thread_info()
431 *
432 * MMU Globals (PSTATE_MG):
433 *
434 * %g1 --> TLB_SFSR
435 * %g2 --> ((_PAGE_VALID | _PAGE_SZ4MB |
436 * _PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
437 * ^ 0xfffff80000000000)
438 * (this %g2 value is used for computing the PAGE_OFFSET kernel
439 * TLB entries quickly, the virtual address of the fault XOR'd
440 * with this %g2 value is the PTE to load into the TLB)
441 * %g3 --> VPTE_BASE_CHEETAH or VPTE_BASE_SPITFIRE
442 *
443 * Interrupt Globals (PSTATE_IG, setup by init_irqwork_curcpu()):
444 *
445 * %g6 --> __irq_work[smp_processor_id()]
446 */
642 447
643 /* Setup "Linux" globals 8-) */
644 rdpr %pstate, %o1 448 rdpr %pstate, %o1
645 mov %g6, %o2 449 mov %g6, %o2
646 wrpr %o1, (PSTATE_AG|PSTATE_IE), %pstate 450 wrpr %o1, PSTATE_AG, %pstate
647 sethi %hi(sparc64_ttable_tl0), %g1
648 wrpr %g1, %tba
649 mov %o2, %g6 451 mov %o2, %g6
650 452
651 /* Set up MMU globals */
652 wrpr %o1, (PSTATE_MG|PSTATE_IE), %pstate
653
654 /* Set fixed globals used by dTLB miss handler. */
655#define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000) 453#define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
656#define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W) 454#define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
657 455 wrpr %o1, PSTATE_MG, %pstate
658 mov TSB_REG, %g1 456 mov TSB_REG, %g1
659 stxa %g0, [%g1] ASI_DMMU 457 stxa %g0, [%g1] ASI_DMMU
660 membar #Sync 458 membar #Sync
@@ -666,17 +464,17 @@ setup_tba: /* i0 = is_starfire */
666 sllx %g2, 32, %g2 464 sllx %g2, 32, %g2
667 or %g2, KERN_LOWBITS, %g2 465 or %g2, KERN_LOWBITS, %g2
668 466
669 BRANCH_IF_ANY_CHEETAH(g3,g7,cheetah_vpte_base) 467 BRANCH_IF_ANY_CHEETAH(g3,g7,8f)
670 ba,pt %xcc, spitfire_vpte_base 468 ba,pt %xcc, 9f
671 nop 469 nop
672 470
673cheetah_vpte_base: 4718:
674 sethi %uhi(VPTE_BASE_CHEETAH), %g3 472 sethi %uhi(VPTE_BASE_CHEETAH), %g3
675 or %g3, %ulo(VPTE_BASE_CHEETAH), %g3 473 or %g3, %ulo(VPTE_BASE_CHEETAH), %g3
676 ba,pt %xcc, 2f 474 ba,pt %xcc, 2f
677 sllx %g3, 32, %g3 475 sllx %g3, 32, %g3
678 476
679spitfire_vpte_base: 4779:
680 sethi %uhi(VPTE_BASE_SPITFIRE), %g3 478 sethi %uhi(VPTE_BASE_SPITFIRE), %g3
681 or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3 479 or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3
682 sllx %g3, 32, %g3 480 sllx %g3, 32, %g3
@@ -702,48 +500,55 @@ spitfire_vpte_base:
702 sllx %o2, 32, %o2 500 sllx %o2, 32, %o2
703 wr %o2, %asr25 501 wr %o2, %asr25
704 502
705 /* Ok, we're done setting up all the state our trap mechanims needs,
706 * now get back into normal globals and let the PROM know what is up.
707 */
7082: 5032:
709 wrpr %g0, %g0, %wstate 504 wrpr %g0, %g0, %wstate
710 wrpr %o1, PSTATE_IE, %pstate 505 wrpr %o1, 0x0, %pstate
711 506
712 call init_irqwork_curcpu 507 call init_irqwork_curcpu
713 nop 508 nop
714 509
715 call prom_set_trap_table 510 /* Now we can turn interrupts back on. */
716 sethi %hi(sparc64_ttable_tl0), %o0
717
718 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f)
719 ba,pt %xcc, 2f
720 nop
721
7221: /* Start using proper page size encodings in ctx register. */
723 sethi %uhi(CTX_CHEETAH_PLUS_NUC), %g3
724 mov PRIMARY_CONTEXT, %g1
725 sllx %g3, 32, %g3
726 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
727 or %g3, %g2, %g3
728 stxa %g3, [%g1] ASI_DMMU
729 membar #Sync
730
7312:
732 rdpr %pstate, %o1 511 rdpr %pstate, %o1
733 or %o1, PSTATE_IE, %o1 512 or %o1, PSTATE_IE, %o1
734 wrpr %o1, 0, %pstate 513 wrpr %o1, 0, %pstate
514 wrpr %g0, 0x0, %pil
515
516 ret
517 restore
518
519 .globl setup_tba
520setup_tba: /* i0 = is_starfire */
521 save %sp, -192, %sp
522
523 /* The boot processor is the only cpu which invokes this
524 * routine, the other cpus set things up via trampoline.S.
525 * So save the OBP trap table address here.
526 */
527 rdpr %tba, %g7
528 sethi %hi(prom_tba), %o1
529 or %o1, %lo(prom_tba), %o1
530 stx %g7, [%o1]
531
532 call setup_trap_table
533 nop
735 534
736 ret 535 ret
737 restore 536 restore
537sparc64_boot_end:
538
539#include "systbls.S"
540#include "ktlb.S"
541#include "etrap.S"
542#include "rtrap.S"
543#include "winfixup.S"
544#include "entry.S"
738 545
739/* 546/*
740 * The following skips make sure the trap table in ttable.S is aligned 547 * The following skip makes sure the trap table in ttable.S is aligned
741 * on a 32K boundary as required by the v9 specs for TBA register. 548 * on a 32K boundary as required by the v9 specs for TBA register.
742 */ 549 */
743sparc64_boot_end: 5501:
744 .skip 0x2000 + _start - sparc64_boot_end 551 .skip 0x4000 + _start - 1b
745bootup_user_stack_end:
746 .skip 0x2000
747 552
748#ifdef CONFIG_SBUS 553#ifdef CONFIG_SBUS
749/* This is just a hack to fool make depend config.h discovering 554/* This is just a hack to fool make depend config.h discovering
@@ -755,20 +560,6 @@ bootup_user_stack_end:
755! 0x0000000000408000 560! 0x0000000000408000
756 561
757#include "ttable.S" 562#include "ttable.S"
758#include "systbls.S"
759
760 .align 1024
761 .globl swapper_pg_dir
762swapper_pg_dir:
763 .word 0
764
765#include "etrap.S"
766#include "rtrap.S"
767#include "winfixup.S"
768#include "entry.S"
769
770 /* This is just anal retentiveness on my part... */
771 .align 16384
772 563
773 .data 564 .data
774 .align 8 565 .align 8
@@ -776,8 +567,11 @@ swapper_pg_dir:
776prom_tba: .xword 0 567prom_tba: .xword 0
777tlb_type: .word 0 /* Must NOT end up in BSS */ 568tlb_type: .word 0 /* Must NOT end up in BSS */
778 .section ".fixup",#alloc,#execinstr 569 .section ".fixup",#alloc,#execinstr
779 .globl __ret_efault 570
571 .globl __ret_efault, __retl_efault
780__ret_efault: 572__ret_efault:
781 ret 573 ret
782 restore %g0, -EFAULT, %o0 574 restore %g0, -EFAULT, %o0
783 575__retl_efault:
576 retl
577 mov -EFAULT, %o0
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index c9b69167632a..233526ba3abe 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -27,6 +27,7 @@
27#include <asm/atomic.h> 27#include <asm/atomic.h>
28#include <asm/system.h> 28#include <asm/system.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/io.h>
30#include <asm/sbus.h> 31#include <asm/sbus.h>
31#include <asm/iommu.h> 32#include <asm/iommu.h>
32#include <asm/upa.h> 33#include <asm/upa.h>
diff --git a/arch/sparc64/kernel/itlb_base.S b/arch/sparc64/kernel/itlb_base.S
index b5e32dfa4fbc..4951ff8f6877 100644
--- a/arch/sparc64/kernel/itlb_base.S
+++ b/arch/sparc64/kernel/itlb_base.S
@@ -15,14 +15,12 @@
15 */ 15 */
16#define CREATE_VPTE_OFFSET1(r1, r2) \ 16#define CREATE_VPTE_OFFSET1(r1, r2) \
17 srax r1, 10, r2 17 srax r1, 10, r2
18#define CREATE_VPTE_OFFSET2(r1, r2) 18#define CREATE_VPTE_OFFSET2(r1, r2) nop
19#define CREATE_VPTE_NOP nop
20#else /* PAGE_SHIFT */ 19#else /* PAGE_SHIFT */
21#define CREATE_VPTE_OFFSET1(r1, r2) \ 20#define CREATE_VPTE_OFFSET1(r1, r2) \
22 srax r1, PAGE_SHIFT, r2 21 srax r1, PAGE_SHIFT, r2
23#define CREATE_VPTE_OFFSET2(r1, r2) \ 22#define CREATE_VPTE_OFFSET2(r1, r2) \
24 sllx r2, 3, r2 23 sllx r2, 3, r2
25#define CREATE_VPTE_NOP
26#endif /* PAGE_SHIFT */ 24#endif /* PAGE_SHIFT */
27 25
28 26
@@ -36,6 +34,7 @@
36 */ 34 */
37 35
38/* ITLB ** ICACHE line 1: Quick user TLB misses */ 36/* ITLB ** ICACHE line 1: Quick user TLB misses */
37 mov TLB_SFSR, %g1
39 ldxa [%g1 + %g1] ASI_IMMU, %g4 ! Get TAG_ACCESS 38 ldxa [%g1 + %g1] ASI_IMMU, %g4 ! Get TAG_ACCESS
40 CREATE_VPTE_OFFSET1(%g4, %g6) ! Create VPTE offset 39 CREATE_VPTE_OFFSET1(%g4, %g6) ! Create VPTE offset
41 CREATE_VPTE_OFFSET2(%g4, %g6) ! Create VPTE offset 40 CREATE_VPTE_OFFSET2(%g4, %g6) ! Create VPTE offset
@@ -43,41 +42,38 @@
431: brgez,pn %g5, 3f ! Not valid, branch out 421: brgez,pn %g5, 3f ! Not valid, branch out
44 sethi %hi(_PAGE_EXEC), %g4 ! Delay-slot 43 sethi %hi(_PAGE_EXEC), %g4 ! Delay-slot
45 andcc %g5, %g4, %g0 ! Executable? 44 andcc %g5, %g4, %g0 ! Executable?
45
46/* ITLB ** ICACHE line 2: Real faults */
46 be,pn %xcc, 3f ! Nope, branch. 47 be,pn %xcc, 3f ! Nope, branch.
47 nop ! Delay-slot 48 nop ! Delay-slot
482: stxa %g5, [%g0] ASI_ITLB_DATA_IN ! Load PTE into TLB 492: stxa %g5, [%g0] ASI_ITLB_DATA_IN ! Load PTE into TLB
49 retry ! Trap return 50 retry ! Trap return
503: rdpr %pstate, %g4 ! Move into alternate globals 513: rdpr %pstate, %g4 ! Move into alt-globals
51
52/* ITLB ** ICACHE line 2: Real faults */
53 wrpr %g4, PSTATE_AG|PSTATE_MG, %pstate 52 wrpr %g4, PSTATE_AG|PSTATE_MG, %pstate
54 rdpr %tpc, %g5 ! And load faulting VA 53 rdpr %tpc, %g5 ! And load faulting VA
55 mov FAULT_CODE_ITLB, %g4 ! It was read from ITLB 54 mov FAULT_CODE_ITLB, %g4 ! It was read from ITLB
56sparc64_realfault_common: ! Called by TL0 dtlb_miss too 55
56/* ITLB ** ICACHE line 3: Finish faults */
57sparc64_realfault_common: ! Called by dtlb_miss
57 stb %g4, [%g6 + TI_FAULT_CODE] 58 stb %g4, [%g6 + TI_FAULT_CODE]
58 stx %g5, [%g6 + TI_FAULT_ADDR] 59 stx %g5, [%g6 + TI_FAULT_ADDR]
59 ba,pt %xcc, etrap ! Save state 60 ba,pt %xcc, etrap ! Save state
601: rd %pc, %g7 ! ... 611: rd %pc, %g7 ! ...
61 nop
62
63/* ITLB ** ICACHE line 3: Finish faults + window fixups */
64 call do_sparc64_fault ! Call fault handler 62 call do_sparc64_fault ! Call fault handler
65 add %sp, PTREGS_OFF, %o0! Compute pt_regs arg 63 add %sp, PTREGS_OFF, %o0! Compute pt_regs arg
66 ba,pt %xcc, rtrap_clr_l6 ! Restore cpu state 64 ba,pt %xcc, rtrap_clr_l6 ! Restore cpu state
67 nop 65 nop
66
67/* ITLB ** ICACHE line 4: Window fixups */
68winfix_trampoline: 68winfix_trampoline:
69 rdpr %tpc, %g3 ! Prepare winfixup TNPC 69 rdpr %tpc, %g3 ! Prepare winfixup TNPC
70 or %g3, 0x7c, %g3 ! Compute offset to branch 70 or %g3, 0x7c, %g3 ! Compute branch offset
71 wrpr %g3, %tnpc ! Write it into TNPC 71 wrpr %g3, %tnpc ! Write it into TNPC
72 done ! Do it to it 72 done ! Do it to it
73
74/* ITLB ** ICACHE line 4: Unused... */
75 nop 73 nop
76 nop 74 nop
77 nop 75 nop
78 nop 76 nop
79 CREATE_VPTE_NOP
80 77
81#undef CREATE_VPTE_OFFSET1 78#undef CREATE_VPTE_OFFSET1
82#undef CREATE_VPTE_OFFSET2 79#undef CREATE_VPTE_OFFSET2
83#undef CREATE_VPTE_NOP
diff --git a/arch/sparc64/kernel/ktlb.S b/arch/sparc64/kernel/ktlb.S
new file mode 100644
index 000000000000..d9244d3c9f73
--- /dev/null
+++ b/arch/sparc64/kernel/ktlb.S
@@ -0,0 +1,194 @@
1/* arch/sparc64/kernel/ktlb.S: Kernel mapping TLB miss handling.
2 *
3 * Copyright (C) 1995, 1997, 2005 David S. Miller <davem@davemloft.net>
4 * Copyright (C) 1996 Eddie C. Dost (ecd@brainaid.de)
5 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
6 * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7*/
8
9#include <linux/config.h>
10#include <asm/head.h>
11#include <asm/asi.h>
12#include <asm/page.h>
13#include <asm/pgtable.h>
14
15 .text
16 .align 32
17
18/*
19 * On a second level vpte miss, check whether the original fault is to the OBP
20 * range (note that this is only possible for instruction miss, data misses to
21 * obp range do not use vpte). If so, go back directly to the faulting address.
22 * This is because we want to read the tpc, otherwise we have no way of knowing
23 * the 8k aligned faulting address if we are using >8k kernel pagesize. This
24 * also ensures no vpte range addresses are dropped into tlb while obp is
25 * executing (see inherit_locked_prom_mappings() rant).
26 */
27sparc64_vpte_nucleus:
28 /* Note that kvmap below has verified that the address is
29 * in the range MODULES_VADDR --> VMALLOC_END already. So
30 * here we need only check if it is an OBP address or not.
31 */
32 sethi %hi(LOW_OBP_ADDRESS), %g5
33 cmp %g4, %g5
34 blu,pn %xcc, kern_vpte
35 mov 0x1, %g5
36 sllx %g5, 32, %g5
37 cmp %g4, %g5
38 blu,pn %xcc, vpte_insn_obp
39 nop
40
41 /* These two instructions are patched by paginig_init(). */
42kern_vpte:
43 sethi %hi(swapper_pgd_zero), %g5
44 lduw [%g5 + %lo(swapper_pgd_zero)], %g5
45
46 /* With kernel PGD in %g5, branch back into dtlb_backend. */
47 ba,pt %xcc, sparc64_kpte_continue
48 andn %g1, 0x3, %g1 /* Finish PMD offset adjustment. */
49
50vpte_noent:
51 /* Restore previous TAG_ACCESS, %g5 is zero, and we will
52 * skip over the trap instruction so that the top level
53 * TLB miss handler will thing this %g5 value is just an
54 * invalid PTE, thus branching to full fault processing.
55 */
56 mov TLB_SFSR, %g1
57 stxa %g4, [%g1 + %g1] ASI_DMMU
58 done
59
60vpte_insn_obp:
61 /* Behave as if we are at TL0. */
62 wrpr %g0, 1, %tl
63 rdpr %tpc, %g4 /* Find original faulting iaddr */
64 srlx %g4, 13, %g4 /* Throw out context bits */
65 sllx %g4, 13, %g4 /* g4 has vpn + ctx0 now */
66
67 /* Restore previous TAG_ACCESS. */
68 mov TLB_SFSR, %g1
69 stxa %g4, [%g1 + %g1] ASI_IMMU
70
71 sethi %hi(prom_trans), %g5
72 or %g5, %lo(prom_trans), %g5
73
741: ldx [%g5 + 0x00], %g6 ! base
75 brz,a,pn %g6, longpath ! no more entries, fail
76 mov TLB_SFSR, %g1 ! and restore %g1
77 ldx [%g5 + 0x08], %g1 ! len
78 add %g6, %g1, %g1 ! end
79 cmp %g6, %g4
80 bgu,pt %xcc, 2f
81 cmp %g4, %g1
82 bgeu,pt %xcc, 2f
83 ldx [%g5 + 0x10], %g1 ! PTE
84
85 /* TLB load, restore %g1, and return from trap. */
86 sub %g4, %g6, %g6
87 add %g1, %g6, %g5
88 mov TLB_SFSR, %g1
89 stxa %g5, [%g0] ASI_ITLB_DATA_IN
90 retry
91
922: ba,pt %xcc, 1b
93 add %g5, (3 * 8), %g5 ! next entry
94
95kvmap_do_obp:
96 sethi %hi(prom_trans), %g5
97 or %g5, %lo(prom_trans), %g5
98 srlx %g4, 13, %g4
99 sllx %g4, 13, %g4
100
1011: ldx [%g5 + 0x00], %g6 ! base
102 brz,a,pn %g6, longpath ! no more entries, fail
103 mov TLB_SFSR, %g1 ! and restore %g1
104 ldx [%g5 + 0x08], %g1 ! len
105 add %g6, %g1, %g1 ! end
106 cmp %g6, %g4
107 bgu,pt %xcc, 2f
108 cmp %g4, %g1
109 bgeu,pt %xcc, 2f
110 ldx [%g5 + 0x10], %g1 ! PTE
111
112 /* TLB load, restore %g1, and return from trap. */
113 sub %g4, %g6, %g6
114 add %g1, %g6, %g5
115 mov TLB_SFSR, %g1
116 stxa %g5, [%g0] ASI_DTLB_DATA_IN
117 retry
118
1192: ba,pt %xcc, 1b
120 add %g5, (3 * 8), %g5 ! next entry
121
122/*
123 * On a first level data miss, check whether this is to the OBP range (note
124 * that such accesses can be made by prom, as well as by kernel using
125 * prom_getproperty on "address"), and if so, do not use vpte access ...
126 * rather, use information saved during inherit_prom_mappings() using 8k
127 * pagesize.
128 */
129 .align 32
130kvmap:
131 brgez,pn %g4, kvmap_nonlinear
132 nop
133
134#ifdef CONFIG_DEBUG_PAGEALLOC
135 .globl kvmap_linear_patch
136kvmap_linear_patch:
137#endif
138 ba,pt %xcc, kvmap_load
139 xor %g2, %g4, %g5
140
141#ifdef CONFIG_DEBUG_PAGEALLOC
142 sethi %hi(swapper_pg_dir), %g5
143 or %g5, %lo(swapper_pg_dir), %g5
144 sllx %g4, 64 - (PGDIR_SHIFT + PGDIR_BITS), %g6
145 srlx %g6, 64 - PAGE_SHIFT, %g6
146 andn %g6, 0x3, %g6
147 lduw [%g5 + %g6], %g5
148 brz,pn %g5, longpath
149 sllx %g4, 64 - (PMD_SHIFT + PMD_BITS), %g6
150 srlx %g6, 64 - PAGE_SHIFT, %g6
151 sllx %g5, 11, %g5
152 andn %g6, 0x3, %g6
153 lduwa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
154 brz,pn %g5, longpath
155 sllx %g4, 64 - PMD_SHIFT, %g6
156 srlx %g6, 64 - PAGE_SHIFT, %g6
157 sllx %g5, 11, %g5
158 andn %g6, 0x7, %g6
159 ldxa [%g5 + %g6] ASI_PHYS_USE_EC, %g5
160 brz,pn %g5, longpath
161 nop
162 ba,a,pt %xcc, kvmap_load
163#endif
164
165kvmap_nonlinear:
166 sethi %hi(MODULES_VADDR), %g5
167 cmp %g4, %g5
168 blu,pn %xcc, longpath
169 mov (VMALLOC_END >> 24), %g5
170 sllx %g5, 24, %g5
171 cmp %g4, %g5
172 bgeu,pn %xcc, longpath
173 nop
174
175kvmap_check_obp:
176 sethi %hi(LOW_OBP_ADDRESS), %g5
177 cmp %g4, %g5
178 blu,pn %xcc, kvmap_vmalloc_addr
179 mov 0x1, %g5
180 sllx %g5, 32, %g5
181 cmp %g4, %g5
182 blu,pn %xcc, kvmap_do_obp
183 nop
184
185kvmap_vmalloc_addr:
186 /* If we get here, a vmalloc addr was accessed, load kernel VPTE. */
187 ldxa [%g3 + %g6] ASI_N, %g5
188 brgez,pn %g5, longpath
189 nop
190
191kvmap_load:
192 /* PTE is valid, load into TLB and return from trap. */
193 stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
194 retry
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 425c60cfea19..a11910be1013 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -49,12 +49,6 @@ static void __iommu_flushall(struct pci_iommu *iommu)
49 49
50 /* Ensure completion of previous PIO writes. */ 50 /* Ensure completion of previous PIO writes. */
51 (void) pci_iommu_read(iommu->write_complete_reg); 51 (void) pci_iommu_read(iommu->write_complete_reg);
52
53 /* Now update everyone's flush point. */
54 for (entry = 0; entry < PBM_NCLUSTERS; entry++) {
55 iommu->alloc_info[entry].flush =
56 iommu->alloc_info[entry].next;
57 }
58} 52}
59 53
60#define IOPTE_CONSISTENT(CTX) \ 54#define IOPTE_CONSISTENT(CTX) \
@@ -80,120 +74,117 @@ static void inline iopte_make_dummy(struct pci_iommu *iommu, iopte_t *iopte)
80 iopte_val(*iopte) = val; 74 iopte_val(*iopte) = val;
81} 75}
82 76
83void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize) 77/* Based largely upon the ppc64 iommu allocator. */
78static long pci_arena_alloc(struct pci_iommu *iommu, unsigned long npages)
84{ 79{
85 int i; 80 struct pci_iommu_arena *arena = &iommu->arena;
86 81 unsigned long n, i, start, end, limit;
87 tsbsize /= sizeof(iopte_t); 82 int pass;
88 83
89 for (i = 0; i < tsbsize; i++) 84 limit = arena->limit;
90 iopte_make_dummy(iommu, &iommu->page_table[i]); 85 start = arena->hint;
91} 86 pass = 0;
92 87
93static iopte_t *alloc_streaming_cluster(struct pci_iommu *iommu, unsigned long npages) 88again:
94{ 89 n = find_next_zero_bit(arena->map, limit, start);
95 iopte_t *iopte, *limit, *first; 90 end = n + npages;
96 unsigned long cnum, ent, flush_point; 91 if (unlikely(end >= limit)) {
97 92 if (likely(pass < 1)) {
98 cnum = 0; 93 limit = start;
99 while ((1UL << cnum) < npages) 94 start = 0;
100 cnum++; 95 __iommu_flushall(iommu);
101 iopte = (iommu->page_table + 96 pass++;
102 (cnum << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS))); 97 goto again;
103 98 } else {
104 if (cnum == 0) 99 /* Scanned the whole thing, give up. */
105 limit = (iommu->page_table + 100 return -1;
106 iommu->lowest_consistent_map);
107 else
108 limit = (iopte +
109 (1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS)));
110
111 iopte += ((ent = iommu->alloc_info[cnum].next) << cnum);
112 flush_point = iommu->alloc_info[cnum].flush;
113
114 first = iopte;
115 for (;;) {
116 if (IOPTE_IS_DUMMY(iommu, iopte)) {
117 if ((iopte + (1 << cnum)) >= limit)
118 ent = 0;
119 else
120 ent = ent + 1;
121 iommu->alloc_info[cnum].next = ent;
122 if (ent == flush_point)
123 __iommu_flushall(iommu);
124 break;
125 } 101 }
126 iopte += (1 << cnum); 102 }
127 ent++; 103
128 if (iopte >= limit) { 104 for (i = n; i < end; i++) {
129 iopte = (iommu->page_table + 105 if (test_bit(i, arena->map)) {
130 (cnum << 106 start = i + 1;
131 (iommu->page_table_sz_bits - PBM_LOGCLUSTERS))); 107 goto again;
132 ent = 0;
133 } 108 }
134 if (ent == flush_point)
135 __iommu_flushall(iommu);
136 if (iopte == first)
137 goto bad;
138 } 109 }
139 110
140 /* I've got your streaming cluster right here buddy boy... */ 111 for (i = n; i < end; i++)
141 return iopte; 112 __set_bit(i, arena->map);
142 113
143bad: 114 arena->hint = end;
144 printk(KERN_EMERG "pci_iommu: alloc_streaming_cluster of npages(%ld) failed!\n", 115
145 npages); 116 return n;
146 return NULL;
147} 117}
148 118
149static void free_streaming_cluster(struct pci_iommu *iommu, dma_addr_t base, 119static void pci_arena_free(struct pci_iommu_arena *arena, unsigned long base, unsigned long npages)
150 unsigned long npages, unsigned long ctx)
151{ 120{
152 unsigned long cnum, ent; 121 unsigned long i;
153 122
154 cnum = 0; 123 for (i = base; i < (base + npages); i++)
155 while ((1UL << cnum) < npages) 124 __clear_bit(i, arena->map);
156 cnum++; 125}
157 126
158 ent = (base << (32 - IO_PAGE_SHIFT + PBM_LOGCLUSTERS - iommu->page_table_sz_bits)) 127void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask)
159 >> (32 + PBM_LOGCLUSTERS + cnum - iommu->page_table_sz_bits); 128{
129 unsigned long i, tsbbase, order, sz, num_tsb_entries;
130
131 num_tsb_entries = tsbsize / sizeof(iopte_t);
132
133 /* Setup initial software IOMMU state. */
134 spin_lock_init(&iommu->lock);
135 iommu->ctx_lowest_free = 1;
136 iommu->page_table_map_base = dma_offset;
137 iommu->dma_addr_mask = dma_addr_mask;
138
139 /* Allocate and initialize the free area map. */
140 sz = num_tsb_entries / 8;
141 sz = (sz + 7UL) & ~7UL;
142 iommu->arena.map = kmalloc(sz, GFP_KERNEL);
143 if (!iommu->arena.map) {
144 prom_printf("PCI_IOMMU: Error, kmalloc(arena.map) failed.\n");
145 prom_halt();
146 }
147 memset(iommu->arena.map, 0, sz);
148 iommu->arena.limit = num_tsb_entries;
160 149
161 /* If the global flush might not have caught this entry, 150 /* Allocate and initialize the dummy page which we
162 * adjust the flush point such that we will flush before 151 * set inactive IO PTEs to point to.
163 * ever trying to reuse it.
164 */ 152 */
165#define between(X,Y,Z) (((Z) - (Y)) >= ((X) - (Y))) 153 iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0);
166 if (between(ent, iommu->alloc_info[cnum].next, iommu->alloc_info[cnum].flush)) 154 if (!iommu->dummy_page) {
167 iommu->alloc_info[cnum].flush = ent; 155 prom_printf("PCI_IOMMU: Error, gfp(dummy_page) failed.\n");
168#undef between 156 prom_halt();
157 }
158 memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
159 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
160
161 /* Now allocate and setup the IOMMU page table itself. */
162 order = get_order(tsbsize);
163 tsbbase = __get_free_pages(GFP_KERNEL, order);
164 if (!tsbbase) {
165 prom_printf("PCI_IOMMU: Error, gfp(tsb) failed.\n");
166 prom_halt();
167 }
168 iommu->page_table = (iopte_t *)tsbbase;
169
170 for (i = 0; i < num_tsb_entries; i++)
171 iopte_make_dummy(iommu, &iommu->page_table[i]);
169} 172}
170 173
171/* We allocate consistent mappings from the end of cluster zero. */ 174static inline iopte_t *alloc_npages(struct pci_iommu *iommu, unsigned long npages)
172static iopte_t *alloc_consistent_cluster(struct pci_iommu *iommu, unsigned long npages)
173{ 175{
174 iopte_t *iopte; 176 long entry;
175 177
176 iopte = iommu->page_table + (1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS)); 178 entry = pci_arena_alloc(iommu, npages);
177 while (iopte > iommu->page_table) { 179 if (unlikely(entry < 0))
178 iopte--; 180 return NULL;
179 if (IOPTE_IS_DUMMY(iommu, iopte)) {
180 unsigned long tmp = npages;
181 181
182 while (--tmp) { 182 return iommu->page_table + entry;
183 iopte--; 183}
184 if (!IOPTE_IS_DUMMY(iommu, iopte))
185 break;
186 }
187 if (tmp == 0) {
188 u32 entry = (iopte - iommu->page_table);
189 184
190 if (entry < iommu->lowest_consistent_map) 185static inline void free_npages(struct pci_iommu *iommu, dma_addr_t base, unsigned long npages)
191 iommu->lowest_consistent_map = entry; 186{
192 return iopte; 187 pci_arena_free(&iommu->arena, base >> IO_PAGE_SHIFT, npages);
193 }
194 }
195 }
196 return NULL;
197} 188}
198 189
199static int iommu_alloc_ctx(struct pci_iommu *iommu) 190static int iommu_alloc_ctx(struct pci_iommu *iommu)
@@ -233,7 +224,7 @@ void *pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_ad
233 struct pcidev_cookie *pcp; 224 struct pcidev_cookie *pcp;
234 struct pci_iommu *iommu; 225 struct pci_iommu *iommu;
235 iopte_t *iopte; 226 iopte_t *iopte;
236 unsigned long flags, order, first_page, ctx; 227 unsigned long flags, order, first_page;
237 void *ret; 228 void *ret;
238 int npages; 229 int npages;
239 230
@@ -251,9 +242,10 @@ void *pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_ad
251 iommu = pcp->pbm->iommu; 242 iommu = pcp->pbm->iommu;
252 243
253 spin_lock_irqsave(&iommu->lock, flags); 244 spin_lock_irqsave(&iommu->lock, flags);
254 iopte = alloc_consistent_cluster(iommu, size >> IO_PAGE_SHIFT); 245 iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT);
255 if (iopte == NULL) { 246 spin_unlock_irqrestore(&iommu->lock, flags);
256 spin_unlock_irqrestore(&iommu->lock, flags); 247
248 if (unlikely(iopte == NULL)) {
257 free_pages(first_page, order); 249 free_pages(first_page, order);
258 return NULL; 250 return NULL;
259 } 251 }
@@ -262,31 +254,15 @@ void *pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_ad
262 ((iopte - iommu->page_table) << IO_PAGE_SHIFT)); 254 ((iopte - iommu->page_table) << IO_PAGE_SHIFT));
263 ret = (void *) first_page; 255 ret = (void *) first_page;
264 npages = size >> IO_PAGE_SHIFT; 256 npages = size >> IO_PAGE_SHIFT;
265 ctx = 0;
266 if (iommu->iommu_ctxflush)
267 ctx = iommu_alloc_ctx(iommu);
268 first_page = __pa(first_page); 257 first_page = __pa(first_page);
269 while (npages--) { 258 while (npages--) {
270 iopte_val(*iopte) = (IOPTE_CONSISTENT(ctx) | 259 iopte_val(*iopte) = (IOPTE_CONSISTENT(0UL) |
271 IOPTE_WRITE | 260 IOPTE_WRITE |
272 (first_page & IOPTE_PAGE)); 261 (first_page & IOPTE_PAGE));
273 iopte++; 262 iopte++;
274 first_page += IO_PAGE_SIZE; 263 first_page += IO_PAGE_SIZE;
275 } 264 }
276 265
277 {
278 int i;
279 u32 daddr = *dma_addrp;
280
281 npages = size >> IO_PAGE_SHIFT;
282 for (i = 0; i < npages; i++) {
283 pci_iommu_write(iommu->iommu_flush, daddr);
284 daddr += IO_PAGE_SIZE;
285 }
286 }
287
288 spin_unlock_irqrestore(&iommu->lock, flags);
289
290 return ret; 266 return ret;
291} 267}
292 268
@@ -296,7 +272,7 @@ void pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_
296 struct pcidev_cookie *pcp; 272 struct pcidev_cookie *pcp;
297 struct pci_iommu *iommu; 273 struct pci_iommu *iommu;
298 iopte_t *iopte; 274 iopte_t *iopte;
299 unsigned long flags, order, npages, i, ctx; 275 unsigned long flags, order, npages;
300 276
301 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT; 277 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
302 pcp = pdev->sysdata; 278 pcp = pdev->sysdata;
@@ -306,46 +282,7 @@ void pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_
306 282
307 spin_lock_irqsave(&iommu->lock, flags); 283 spin_lock_irqsave(&iommu->lock, flags);
308 284
309 if ((iopte - iommu->page_table) == 285 free_npages(iommu, dvma, npages);
310 iommu->lowest_consistent_map) {
311 iopte_t *walk = iopte + npages;
312 iopte_t *limit;
313
314 limit = (iommu->page_table +
315 (1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS)));
316 while (walk < limit) {
317 if (!IOPTE_IS_DUMMY(iommu, walk))
318 break;
319 walk++;
320 }
321 iommu->lowest_consistent_map =
322 (walk - iommu->page_table);
323 }
324
325 /* Data for consistent mappings cannot enter the streaming
326 * buffers, so we only need to update the TSB. We flush
327 * the IOMMU here as well to prevent conflicts with the
328 * streaming mapping deferred tlb flush scheme.
329 */
330
331 ctx = 0;
332 if (iommu->iommu_ctxflush)
333 ctx = (iopte_val(*iopte) & IOPTE_CONTEXT) >> 47UL;
334
335 for (i = 0; i < npages; i++, iopte++)
336 iopte_make_dummy(iommu, iopte);
337
338 if (iommu->iommu_ctxflush) {
339 pci_iommu_write(iommu->iommu_ctxflush, ctx);
340 } else {
341 for (i = 0; i < npages; i++) {
342 u32 daddr = dvma + (i << IO_PAGE_SHIFT);
343
344 pci_iommu_write(iommu->iommu_flush, daddr);
345 }
346 }
347
348 iommu_free_ctx(iommu, ctx);
349 286
350 spin_unlock_irqrestore(&iommu->lock, flags); 287 spin_unlock_irqrestore(&iommu->lock, flags);
351 288
@@ -372,25 +309,27 @@ dma_addr_t pci_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direct
372 iommu = pcp->pbm->iommu; 309 iommu = pcp->pbm->iommu;
373 strbuf = &pcp->pbm->stc; 310 strbuf = &pcp->pbm->stc;
374 311
375 if (direction == PCI_DMA_NONE) 312 if (unlikely(direction == PCI_DMA_NONE))
376 BUG(); 313 goto bad_no_ctx;
377 314
378 oaddr = (unsigned long)ptr; 315 oaddr = (unsigned long)ptr;
379 npages = IO_PAGE_ALIGN(oaddr + sz) - (oaddr & IO_PAGE_MASK); 316 npages = IO_PAGE_ALIGN(oaddr + sz) - (oaddr & IO_PAGE_MASK);
380 npages >>= IO_PAGE_SHIFT; 317 npages >>= IO_PAGE_SHIFT;
381 318
382 spin_lock_irqsave(&iommu->lock, flags); 319 spin_lock_irqsave(&iommu->lock, flags);
320 base = alloc_npages(iommu, npages);
321 ctx = 0;
322 if (iommu->iommu_ctxflush)
323 ctx = iommu_alloc_ctx(iommu);
324 spin_unlock_irqrestore(&iommu->lock, flags);
383 325
384 base = alloc_streaming_cluster(iommu, npages); 326 if (unlikely(!base))
385 if (base == NULL)
386 goto bad; 327 goto bad;
328
387 bus_addr = (iommu->page_table_map_base + 329 bus_addr = (iommu->page_table_map_base +
388 ((base - iommu->page_table) << IO_PAGE_SHIFT)); 330 ((base - iommu->page_table) << IO_PAGE_SHIFT));
389 ret = bus_addr | (oaddr & ~IO_PAGE_MASK); 331 ret = bus_addr | (oaddr & ~IO_PAGE_MASK);
390 base_paddr = __pa(oaddr & IO_PAGE_MASK); 332 base_paddr = __pa(oaddr & IO_PAGE_MASK);
391 ctx = 0;
392 if (iommu->iommu_ctxflush)
393 ctx = iommu_alloc_ctx(iommu);
394 if (strbuf->strbuf_enabled) 333 if (strbuf->strbuf_enabled)
395 iopte_protection = IOPTE_STREAMING(ctx); 334 iopte_protection = IOPTE_STREAMING(ctx);
396 else 335 else
@@ -401,12 +340,13 @@ dma_addr_t pci_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direct
401 for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE) 340 for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE)
402 iopte_val(*base) = iopte_protection | base_paddr; 341 iopte_val(*base) = iopte_protection | base_paddr;
403 342
404 spin_unlock_irqrestore(&iommu->lock, flags);
405
406 return ret; 343 return ret;
407 344
408bad: 345bad:
409 spin_unlock_irqrestore(&iommu->lock, flags); 346 iommu_free_ctx(iommu, ctx);
347bad_no_ctx:
348 if (printk_ratelimit())
349 WARN_ON(1);
410 return PCI_DMA_ERROR_CODE; 350 return PCI_DMA_ERROR_CODE;
411} 351}
412 352
@@ -481,10 +421,13 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int
481 struct pci_iommu *iommu; 421 struct pci_iommu *iommu;
482 struct pci_strbuf *strbuf; 422 struct pci_strbuf *strbuf;
483 iopte_t *base; 423 iopte_t *base;
484 unsigned long flags, npages, ctx; 424 unsigned long flags, npages, ctx, i;
485 425
486 if (direction == PCI_DMA_NONE) 426 if (unlikely(direction == PCI_DMA_NONE)) {
487 BUG(); 427 if (printk_ratelimit())
428 WARN_ON(1);
429 return;
430 }
488 431
489 pcp = pdev->sysdata; 432 pcp = pdev->sysdata;
490 iommu = pcp->pbm->iommu; 433 iommu = pcp->pbm->iommu;
@@ -510,13 +453,14 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int
510 453
511 /* Step 1: Kick data out of streaming buffers if necessary. */ 454 /* Step 1: Kick data out of streaming buffers if necessary. */
512 if (strbuf->strbuf_enabled) 455 if (strbuf->strbuf_enabled)
513 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); 456 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx,
457 npages, direction);
514 458
515 /* Step 2: Clear out first TSB entry. */ 459 /* Step 2: Clear out TSB entries. */
516 iopte_make_dummy(iommu, base); 460 for (i = 0; i < npages; i++)
461 iopte_make_dummy(iommu, base + i);
517 462
518 free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, 463 free_npages(iommu, bus_addr - iommu->page_table_map_base, npages);
519 npages, ctx);
520 464
521 iommu_free_ctx(iommu, ctx); 465 iommu_free_ctx(iommu, ctx);
522 466
@@ -621,6 +565,8 @@ int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int
621 pci_map_single(pdev, 565 pci_map_single(pdev,
622 (page_address(sglist->page) + sglist->offset), 566 (page_address(sglist->page) + sglist->offset),
623 sglist->length, direction); 567 sglist->length, direction);
568 if (unlikely(sglist->dma_address == PCI_DMA_ERROR_CODE))
569 return 0;
624 sglist->dma_length = sglist->length; 570 sglist->dma_length = sglist->length;
625 return 1; 571 return 1;
626 } 572 }
@@ -629,21 +575,29 @@ int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int
629 iommu = pcp->pbm->iommu; 575 iommu = pcp->pbm->iommu;
630 strbuf = &pcp->pbm->stc; 576 strbuf = &pcp->pbm->stc;
631 577
632 if (direction == PCI_DMA_NONE) 578 if (unlikely(direction == PCI_DMA_NONE))
633 BUG(); 579 goto bad_no_ctx;
634 580
635 /* Step 1: Prepare scatter list. */ 581 /* Step 1: Prepare scatter list. */
636 582
637 npages = prepare_sg(sglist, nelems); 583 npages = prepare_sg(sglist, nelems);
638 584
639 /* Step 2: Allocate a cluster. */ 585 /* Step 2: Allocate a cluster and context, if necessary. */
640 586
641 spin_lock_irqsave(&iommu->lock, flags); 587 spin_lock_irqsave(&iommu->lock, flags);
642 588
643 base = alloc_streaming_cluster(iommu, npages); 589 base = alloc_npages(iommu, npages);
590 ctx = 0;
591 if (iommu->iommu_ctxflush)
592 ctx = iommu_alloc_ctx(iommu);
593
594 spin_unlock_irqrestore(&iommu->lock, flags);
595
644 if (base == NULL) 596 if (base == NULL)
645 goto bad; 597 goto bad;
646 dma_base = iommu->page_table_map_base + ((base - iommu->page_table) << IO_PAGE_SHIFT); 598
599 dma_base = iommu->page_table_map_base +
600 ((base - iommu->page_table) << IO_PAGE_SHIFT);
647 601
648 /* Step 3: Normalize DMA addresses. */ 602 /* Step 3: Normalize DMA addresses. */
649 used = nelems; 603 used = nelems;
@@ -656,30 +610,28 @@ int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int
656 } 610 }
657 used = nelems - used; 611 used = nelems - used;
658 612
659 /* Step 4: Choose a context if necessary. */ 613 /* Step 4: Create the mappings. */
660 ctx = 0;
661 if (iommu->iommu_ctxflush)
662 ctx = iommu_alloc_ctx(iommu);
663
664 /* Step 5: Create the mappings. */
665 if (strbuf->strbuf_enabled) 614 if (strbuf->strbuf_enabled)
666 iopte_protection = IOPTE_STREAMING(ctx); 615 iopte_protection = IOPTE_STREAMING(ctx);
667 else 616 else
668 iopte_protection = IOPTE_CONSISTENT(ctx); 617 iopte_protection = IOPTE_CONSISTENT(ctx);
669 if (direction != PCI_DMA_TODEVICE) 618 if (direction != PCI_DMA_TODEVICE)
670 iopte_protection |= IOPTE_WRITE; 619 iopte_protection |= IOPTE_WRITE;
671 fill_sg (base, sglist, used, nelems, iopte_protection); 620
621 fill_sg(base, sglist, used, nelems, iopte_protection);
622
672#ifdef VERIFY_SG 623#ifdef VERIFY_SG
673 verify_sglist(sglist, nelems, base, npages); 624 verify_sglist(sglist, nelems, base, npages);
674#endif 625#endif
675 626
676 spin_unlock_irqrestore(&iommu->lock, flags);
677
678 return used; 627 return used;
679 628
680bad: 629bad:
681 spin_unlock_irqrestore(&iommu->lock, flags); 630 iommu_free_ctx(iommu, ctx);
682 return PCI_DMA_ERROR_CODE; 631bad_no_ctx:
632 if (printk_ratelimit())
633 WARN_ON(1);
634 return 0;
683} 635}
684 636
685/* Unmap a set of streaming mode DMA translations. */ 637/* Unmap a set of streaming mode DMA translations. */
@@ -692,8 +644,10 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems,
692 unsigned long flags, ctx, i, npages; 644 unsigned long flags, ctx, i, npages;
693 u32 bus_addr; 645 u32 bus_addr;
694 646
695 if (direction == PCI_DMA_NONE) 647 if (unlikely(direction == PCI_DMA_NONE)) {
696 BUG(); 648 if (printk_ratelimit())
649 WARN_ON(1);
650 }
697 651
698 pcp = pdev->sysdata; 652 pcp = pdev->sysdata;
699 iommu = pcp->pbm->iommu; 653 iommu = pcp->pbm->iommu;
@@ -705,7 +659,8 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems,
705 if (sglist[i].dma_length == 0) 659 if (sglist[i].dma_length == 0)
706 break; 660 break;
707 i--; 661 i--;
708 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) - bus_addr) >> IO_PAGE_SHIFT; 662 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) -
663 bus_addr) >> IO_PAGE_SHIFT;
709 664
710 base = iommu->page_table + 665 base = iommu->page_table +
711 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT); 666 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
@@ -726,11 +681,11 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems,
726 if (strbuf->strbuf_enabled) 681 if (strbuf->strbuf_enabled)
727 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); 682 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
728 683
729 /* Step 2: Clear out first TSB entry. */ 684 /* Step 2: Clear out the TSB entries. */
730 iopte_make_dummy(iommu, base); 685 for (i = 0; i < npages; i++)
686 iopte_make_dummy(iommu, base + i);
731 687
732 free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, 688 free_npages(iommu, bus_addr - iommu->page_table_map_base, npages);
733 npages, ctx);
734 689
735 iommu_free_ctx(iommu, ctx); 690 iommu_free_ctx(iommu, ctx);
736 691
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
index 6ed1ef25e0ac..c03ed5f49d31 100644
--- a/arch/sparc64/kernel/pci_psycho.c
+++ b/arch/sparc64/kernel/pci_psycho.c
@@ -1207,13 +1207,9 @@ static void psycho_scan_bus(struct pci_controller_info *p)
1207static void psycho_iommu_init(struct pci_controller_info *p) 1207static void psycho_iommu_init(struct pci_controller_info *p)
1208{ 1208{
1209 struct pci_iommu *iommu = p->pbm_A.iommu; 1209 struct pci_iommu *iommu = p->pbm_A.iommu;
1210 unsigned long tsbbase, i; 1210 unsigned long i;
1211 u64 control; 1211 u64 control;
1212 1212
1213 /* Setup initial software IOMMU state. */
1214 spin_lock_init(&iommu->lock);
1215 iommu->ctx_lowest_free = 1;
1216
1217 /* Register addresses. */ 1213 /* Register addresses. */
1218 iommu->iommu_control = p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL; 1214 iommu->iommu_control = p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL;
1219 iommu->iommu_tsbbase = p->pbm_A.controller_regs + PSYCHO_IOMMU_TSBBASE; 1215 iommu->iommu_tsbbase = p->pbm_A.controller_regs + PSYCHO_IOMMU_TSBBASE;
@@ -1240,40 +1236,10 @@ static void psycho_iommu_init(struct pci_controller_info *p)
1240 /* Leave diag mode enabled for full-flushing done 1236 /* Leave diag mode enabled for full-flushing done
1241 * in pci_iommu.c 1237 * in pci_iommu.c
1242 */ 1238 */
1239 pci_iommu_table_init(iommu, IO_TSB_SIZE, 0xc0000000, 0xffffffff);
1243 1240
1244 iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0); 1241 psycho_write(p->pbm_A.controller_regs + PSYCHO_IOMMU_TSBBASE,
1245 if (!iommu->dummy_page) { 1242 __pa(iommu->page_table));
1246 prom_printf("PSYCHO_IOMMU: Error, gfp(dummy_page) failed.\n");
1247 prom_halt();
1248 }
1249 memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
1250 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
1251
1252 /* Using assumed page size 8K with 128K entries we need 1MB iommu page
1253 * table (128K ioptes * 8 bytes per iopte). This is
1254 * page order 7 on UltraSparc.
1255 */
1256 tsbbase = __get_free_pages(GFP_KERNEL, get_order(IO_TSB_SIZE));
1257 if (!tsbbase) {
1258 prom_printf("PSYCHO_IOMMU: Error, gfp(tsb) failed.\n");
1259 prom_halt();
1260 }
1261 iommu->page_table = (iopte_t *)tsbbase;
1262 iommu->page_table_sz_bits = 17;
1263 iommu->page_table_map_base = 0xc0000000;
1264 iommu->dma_addr_mask = 0xffffffff;
1265 pci_iommu_table_init(iommu, IO_TSB_SIZE);
1266
1267 /* We start with no consistent mappings. */
1268 iommu->lowest_consistent_map =
1269 1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS);
1270
1271 for (i = 0; i < PBM_NCLUSTERS; i++) {
1272 iommu->alloc_info[i].flush = 0;
1273 iommu->alloc_info[i].next = 0;
1274 }
1275
1276 psycho_write(p->pbm_A.controller_regs + PSYCHO_IOMMU_TSBBASE, __pa(tsbbase));
1277 1243
1278 control = psycho_read(p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL); 1244 control = psycho_read(p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL);
1279 control &= ~(PSYCHO_IOMMU_CTRL_TSBSZ | PSYCHO_IOMMU_CTRL_TBWSZ); 1245 control &= ~(PSYCHO_IOMMU_CTRL_TSBSZ | PSYCHO_IOMMU_CTRL_TBWSZ);
@@ -1281,7 +1247,7 @@ static void psycho_iommu_init(struct pci_controller_info *p)
1281 psycho_write(p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL, control); 1247 psycho_write(p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL, control);
1282 1248
1283 /* If necessary, hook us up for starfire IRQ translations. */ 1249 /* If necessary, hook us up for starfire IRQ translations. */
1284 if(this_is_starfire) 1250 if (this_is_starfire)
1285 p->starfire_cookie = starfire_hookup(p->pbm_A.portid); 1251 p->starfire_cookie = starfire_hookup(p->pbm_A.portid);
1286 else 1252 else
1287 p->starfire_cookie = NULL; 1253 p->starfire_cookie = NULL;
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index 0ee6bd5b9ac6..da8e1364194f 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -1267,13 +1267,9 @@ static void sabre_iommu_init(struct pci_controller_info *p,
1267 u32 dma_mask) 1267 u32 dma_mask)
1268{ 1268{
1269 struct pci_iommu *iommu = p->pbm_A.iommu; 1269 struct pci_iommu *iommu = p->pbm_A.iommu;
1270 unsigned long tsbbase, i, order; 1270 unsigned long i;
1271 u64 control; 1271 u64 control;
1272 1272
1273 /* Setup initial software IOMMU state. */
1274 spin_lock_init(&iommu->lock);
1275 iommu->ctx_lowest_free = 1;
1276
1277 /* Register addresses. */ 1273 /* Register addresses. */
1278 iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL; 1274 iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL;
1279 iommu->iommu_tsbbase = p->pbm_A.controller_regs + SABRE_IOMMU_TSBBASE; 1275 iommu->iommu_tsbbase = p->pbm_A.controller_regs + SABRE_IOMMU_TSBBASE;
@@ -1295,26 +1291,10 @@ static void sabre_iommu_init(struct pci_controller_info *p,
1295 /* Leave diag mode enabled for full-flushing done 1291 /* Leave diag mode enabled for full-flushing done
1296 * in pci_iommu.c 1292 * in pci_iommu.c
1297 */ 1293 */
1294 pci_iommu_table_init(iommu, tsbsize * 1024 * 8, dvma_offset, dma_mask);
1298 1295
1299 iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0); 1296 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_TSBBASE,
1300 if (!iommu->dummy_page) { 1297 __pa(iommu->page_table));
1301 prom_printf("PSYCHO_IOMMU: Error, gfp(dummy_page) failed.\n");
1302 prom_halt();
1303 }
1304 memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
1305 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
1306
1307 tsbbase = __get_free_pages(GFP_KERNEL, order = get_order(tsbsize * 1024 * 8));
1308 if (!tsbbase) {
1309 prom_printf("SABRE_IOMMU: Error, gfp(tsb) failed.\n");
1310 prom_halt();
1311 }
1312 iommu->page_table = (iopte_t *)tsbbase;
1313 iommu->page_table_map_base = dvma_offset;
1314 iommu->dma_addr_mask = dma_mask;
1315 pci_iommu_table_init(iommu, PAGE_SIZE << order);
1316
1317 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_TSBBASE, __pa(tsbbase));
1318 1298
1319 control = sabre_read(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL); 1299 control = sabre_read(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL);
1320 control &= ~(SABRE_IOMMUCTRL_TSBSZ | SABRE_IOMMUCTRL_TBWSZ); 1300 control &= ~(SABRE_IOMMUCTRL_TSBSZ | SABRE_IOMMUCTRL_TBWSZ);
@@ -1322,11 +1302,9 @@ static void sabre_iommu_init(struct pci_controller_info *p,
1322 switch(tsbsize) { 1302 switch(tsbsize) {
1323 case 64: 1303 case 64:
1324 control |= SABRE_IOMMU_TSBSZ_64K; 1304 control |= SABRE_IOMMU_TSBSZ_64K;
1325 iommu->page_table_sz_bits = 16;
1326 break; 1305 break;
1327 case 128: 1306 case 128:
1328 control |= SABRE_IOMMU_TSBSZ_128K; 1307 control |= SABRE_IOMMU_TSBSZ_128K;
1329 iommu->page_table_sz_bits = 17;
1330 break; 1308 break;
1331 default: 1309 default:
1332 prom_printf("iommu_init: Illegal TSB size %d\n", tsbsize); 1310 prom_printf("iommu_init: Illegal TSB size %d\n", tsbsize);
@@ -1334,15 +1312,6 @@ static void sabre_iommu_init(struct pci_controller_info *p,
1334 break; 1312 break;
1335 } 1313 }
1336 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL, control); 1314 sabre_write(p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL, control);
1337
1338 /* We start with no consistent mappings. */
1339 iommu->lowest_consistent_map =
1340 1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS);
1341
1342 for (i = 0; i < PBM_NCLUSTERS; i++) {
1343 iommu->alloc_info[i].flush = 0;
1344 iommu->alloc_info[i].next = 0;
1345 }
1346} 1315}
1347 1316
1348static void pbm_register_toplevel_resources(struct pci_controller_info *p, 1317static void pbm_register_toplevel_resources(struct pci_controller_info *p,
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
index 331382e1a75d..d8c4e0919b4e 100644
--- a/arch/sparc64/kernel/pci_schizo.c
+++ b/arch/sparc64/kernel/pci_schizo.c
@@ -330,7 +330,7 @@ static int schizo_ino_to_pil(struct pci_dev *pdev, unsigned int ino)
330static void tomatillo_wsync_handler(struct ino_bucket *bucket, void *_arg1, void *_arg2) 330static void tomatillo_wsync_handler(struct ino_bucket *bucket, void *_arg1, void *_arg2)
331{ 331{
332 unsigned long sync_reg = (unsigned long) _arg2; 332 unsigned long sync_reg = (unsigned long) _arg2;
333 u64 mask = 1 << (__irq_ino(__irq(bucket)) & IMAP_INO); 333 u64 mask = 1UL << (__irq_ino(__irq(bucket)) & IMAP_INO);
334 u64 val; 334 u64 val;
335 int limit; 335 int limit;
336 336
@@ -1765,7 +1765,7 @@ static void schizo_pbm_strbuf_init(struct pci_pbm_info *pbm)
1765static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm) 1765static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1766{ 1766{
1767 struct pci_iommu *iommu = pbm->iommu; 1767 struct pci_iommu *iommu = pbm->iommu;
1768 unsigned long tsbbase, i, tagbase, database, order; 1768 unsigned long i, tagbase, database;
1769 u32 vdma[2], dma_mask; 1769 u32 vdma[2], dma_mask;
1770 u64 control; 1770 u64 control;
1771 int err, tsbsize; 1771 int err, tsbsize;
@@ -1800,10 +1800,6 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1800 prom_halt(); 1800 prom_halt();
1801 }; 1801 };
1802 1802
1803 /* Setup initial software IOMMU state. */
1804 spin_lock_init(&iommu->lock);
1805 iommu->ctx_lowest_free = 1;
1806
1807 /* Register addresses, SCHIZO has iommu ctx flushing. */ 1803 /* Register addresses, SCHIZO has iommu ctx flushing. */
1808 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL; 1804 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL;
1809 iommu->iommu_tsbbase = pbm->pbm_regs + SCHIZO_IOMMU_TSBBASE; 1805 iommu->iommu_tsbbase = pbm->pbm_regs + SCHIZO_IOMMU_TSBBASE;
@@ -1832,56 +1828,9 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1832 /* Leave diag mode enabled for full-flushing done 1828 /* Leave diag mode enabled for full-flushing done
1833 * in pci_iommu.c 1829 * in pci_iommu.c
1834 */ 1830 */
1831 pci_iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask);
1835 1832
1836 iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0); 1833 schizo_write(iommu->iommu_tsbbase, __pa(iommu->page_table));
1837 if (!iommu->dummy_page) {
1838 prom_printf("PSYCHO_IOMMU: Error, gfp(dummy_page) failed.\n");
1839 prom_halt();
1840 }
1841 memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
1842 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
1843
1844 /* Using assumed page size 8K with 128K entries we need 1MB iommu page
1845 * table (128K ioptes * 8 bytes per iopte). This is
1846 * page order 7 on UltraSparc.
1847 */
1848 order = get_order(tsbsize * 8 * 1024);
1849 tsbbase = __get_free_pages(GFP_KERNEL, order);
1850 if (!tsbbase) {
1851 prom_printf("%s: Error, gfp(tsb) failed.\n", pbm->name);
1852 prom_halt();
1853 }
1854
1855 iommu->page_table = (iopte_t *)tsbbase;
1856 iommu->page_table_map_base = vdma[0];
1857 iommu->dma_addr_mask = dma_mask;
1858 pci_iommu_table_init(iommu, PAGE_SIZE << order);
1859
1860 switch (tsbsize) {
1861 case 64:
1862 iommu->page_table_sz_bits = 16;
1863 break;
1864
1865 case 128:
1866 iommu->page_table_sz_bits = 17;
1867 break;
1868
1869 default:
1870 prom_printf("iommu_init: Illegal TSB size %d\n", tsbsize);
1871 prom_halt();
1872 break;
1873 };
1874
1875 /* We start with no consistent mappings. */
1876 iommu->lowest_consistent_map =
1877 1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS);
1878
1879 for (i = 0; i < PBM_NCLUSTERS; i++) {
1880 iommu->alloc_info[i].flush = 0;
1881 iommu->alloc_info[i].next = 0;
1882 }
1883
1884 schizo_write(iommu->iommu_tsbbase, __pa(tsbbase));
1885 1834
1886 control = schizo_read(iommu->iommu_control); 1835 control = schizo_read(iommu->iommu_control);
1887 control &= ~(SCHIZO_IOMMU_CTRL_TSBSZ | SCHIZO_IOMMU_CTRL_TBWSZ); 1836 control &= ~(SCHIZO_IOMMU_CTRL_TSBSZ | SCHIZO_IOMMU_CTRL_TBWSZ);
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c
index 946cee0257ea..9e8362ea3104 100644
--- a/arch/sparc64/kernel/power.c
+++ b/arch/sparc64/kernel/power.c
@@ -17,6 +17,7 @@
17 17
18#include <asm/system.h> 18#include <asm/system.h>
19#include <asm/ebus.h> 19#include <asm/ebus.h>
20#include <asm/isa.h>
20#include <asm/auxio.h> 21#include <asm/auxio.h>
21 22
22#include <linux/unistd.h> 23#include <linux/unistd.h>
@@ -100,46 +101,83 @@ again:
100 return 0; 101 return 0;
101} 102}
102 103
103static int __init has_button_interrupt(struct linux_ebus_device *edev) 104static int __init has_button_interrupt(unsigned int irq, int prom_node)
104{ 105{
105 if (edev->irqs[0] == PCI_IRQ_NONE) 106 if (irq == PCI_IRQ_NONE)
106 return 0; 107 return 0;
107 if (!prom_node_has_property(edev->prom_node, "button")) 108 if (!prom_node_has_property(prom_node, "button"))
108 return 0; 109 return 0;
109 110
110 return 1; 111 return 1;
111} 112}
112 113
113void __init power_init(void) 114static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, int *prom_node_p)
114{ 115{
115 struct linux_ebus *ebus; 116 struct linux_ebus *ebus;
116 struct linux_ebus_device *edev; 117 struct linux_ebus_device *edev;
118
119 for_each_ebus(ebus) {
120 for_each_ebusdev(edev, ebus) {
121 if (!strcmp(edev->prom_name, "power")) {
122 *resp = &edev->resource[0];
123 *irq_p = edev->irqs[0];
124 *prom_node_p = edev->prom_node;
125 return 0;
126 }
127 }
128 }
129 return -ENODEV;
130}
131
132static int __init power_probe_isa(struct resource **resp, unsigned int *irq_p, int *prom_node_p)
133{
134 struct sparc_isa_bridge *isa_bus;
135 struct sparc_isa_device *isa_dev;
136
137 for_each_isa(isa_bus) {
138 for_each_isadev(isa_dev, isa_bus) {
139 if (!strcmp(isa_dev->prom_name, "power")) {
140 *resp = &isa_dev->resource;
141 *irq_p = isa_dev->irq;
142 *prom_node_p = isa_dev->prom_node;
143 return 0;
144 }
145 }
146 }
147 return -ENODEV;
148}
149
150void __init power_init(void)
151{
152 struct resource *res = NULL;
153 unsigned int irq;
154 int prom_node;
117 static int invoked; 155 static int invoked;
118 156
119 if (invoked) 157 if (invoked)
120 return; 158 return;
121 invoked = 1; 159 invoked = 1;
122 160
123 for_each_ebus(ebus) { 161 if (!power_probe_ebus(&res, &irq, &prom_node))
124 for_each_ebusdev(edev, ebus) { 162 goto found;
125 if (!strcmp(edev->prom_name, "power")) 163
126 goto found; 164 if (!power_probe_isa(&res, &irq, &prom_node))
127 } 165 goto found;
128 } 166
129 return; 167 return;
130 168
131found: 169found:
132 power_reg = ioremap(edev->resource[0].start, 0x4); 170 power_reg = ioremap(res->start, 0x4);
133 printk("power: Control reg at %p ... ", power_reg); 171 printk("power: Control reg at %p ... ", power_reg);
134 poweroff_method = machine_halt; /* able to use the standard halt */ 172 poweroff_method = machine_halt; /* able to use the standard halt */
135 if (has_button_interrupt(edev)) { 173 if (has_button_interrupt(irq, prom_node)) {
136 if (kernel_thread(powerd, NULL, CLONE_FS) < 0) { 174 if (kernel_thread(powerd, NULL, CLONE_FS) < 0) {
137 printk("Failed to start power daemon.\n"); 175 printk("Failed to start power daemon.\n");
138 return; 176 return;
139 } 177 }
140 printk("powerd running.\n"); 178 printk("powerd running.\n");
141 179
142 if (request_irq(edev->irqs[0], 180 if (request_irq(irq,
143 power_handler, SA_SHIRQ, "power", NULL) < 0) 181 power_handler, SA_SHIRQ, "power", NULL) < 0)
144 printk("power: Error, cannot register IRQ handler.\n"); 182 printk("power: Error, cannot register IRQ handler.\n");
145 } else { 183 } else {
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index 23ad839d113f..774ecbb8a031 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -30,6 +30,8 @@
30#include <asm/psrcompat.h> 30#include <asm/psrcompat.h>
31#include <asm/visasm.h> 31#include <asm/visasm.h>
32#include <asm/spitfire.h> 32#include <asm/spitfire.h>
33#include <asm/page.h>
34#include <asm/cpudata.h>
33 35
34/* Returning from ptrace is a bit tricky because the syscall return 36/* Returning from ptrace is a bit tricky because the syscall return
35 * low level code assumes any value returned which is negative and 37 * low level code assumes any value returned which is negative and
@@ -128,20 +130,24 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
128 * is mapped to in the user's address space, we can skip the 130 * is mapped to in the user's address space, we can skip the
129 * D-cache flush. 131 * D-cache flush.
130 */ 132 */
131 if ((uaddr ^ kaddr) & (1UL << 13)) { 133 if ((uaddr ^ (unsigned long) kaddr) & (1UL << 13)) {
132 unsigned long start = __pa(kaddr); 134 unsigned long start = __pa(kaddr);
133 unsigned long end = start + len; 135 unsigned long end = start + len;
136 unsigned long dcache_line_size;
137
138 dcache_line_size = local_cpu_data().dcache_line_size;
134 139
135 if (tlb_type == spitfire) { 140 if (tlb_type == spitfire) {
136 for (; start < end; start += 32) 141 for (; start < end; start += dcache_line_size)
137 spitfire_put_dcache_tag(va & 0x3fe0, 0x0); 142 spitfire_put_dcache_tag(start & 0x3fe0, 0x0);
138 } else { 143 } else {
139 for (; start < end; start += 32) 144 start &= ~(dcache_line_size - 1);
145 for (; start < end; start += dcache_line_size)
140 __asm__ __volatile__( 146 __asm__ __volatile__(
141 "stxa %%g0, [%0] %1\n\t" 147 "stxa %%g0, [%0] %1\n\t"
142 "membar #Sync" 148 "membar #Sync"
143 : /* no outputs */ 149 : /* no outputs */
144 : "r" (va), 150 : "r" (start),
145 "i" (ASI_DCACHE_INVALIDATE)); 151 "i" (ASI_DCACHE_INVALIDATE));
146 } 152 }
147 } 153 }
@@ -149,8 +155,11 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
149 if (write && tlb_type == spitfire) { 155 if (write && tlb_type == spitfire) {
150 unsigned long start = (unsigned long) kaddr; 156 unsigned long start = (unsigned long) kaddr;
151 unsigned long end = start + len; 157 unsigned long end = start + len;
158 unsigned long icache_line_size;
159
160 icache_line_size = local_cpu_data().icache_line_size;
152 161
153 for (; start < end; start += 32) 162 for (; start < end; start += icache_line_size)
154 flushi(start); 163 flushi(start);
155 } 164 }
156} 165}
diff --git a/arch/sparc64/kernel/rtrap.S b/arch/sparc64/kernel/rtrap.S
index fafd227735fa..090dcca00d2a 100644
--- a/arch/sparc64/kernel/rtrap.S
+++ b/arch/sparc64/kernel/rtrap.S
@@ -256,9 +256,8 @@ rt_continue: ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1
256 brnz,pn %l3, kern_rtt 256 brnz,pn %l3, kern_rtt
257 mov PRIMARY_CONTEXT, %l7 257 mov PRIMARY_CONTEXT, %l7
258 ldxa [%l7 + %l7] ASI_DMMU, %l0 258 ldxa [%l7 + %l7] ASI_DMMU, %l0
259cplus_rtrap_insn_1: 259 sethi %hi(sparc64_kern_pri_nuc_bits), %l1
260 sethi %hi(0), %l1 260 ldx [%l1 + %lo(sparc64_kern_pri_nuc_bits)], %l1
261 sllx %l1, 32, %l1
262 or %l0, %l1, %l0 261 or %l0, %l1, %l0
263 stxa %l0, [%l7] ASI_DMMU 262 stxa %l0, [%l7] ASI_DMMU
264 flush %g6 263 flush %g6
@@ -313,53 +312,36 @@ kern_fpucheck: ldub [%g6 + TI_FPDEPTH], %l5
313 wr %g1, FPRS_FEF, %fprs 312 wr %g1, FPRS_FEF, %fprs
314 ldx [%o1 + %o5], %g1 313 ldx [%o1 + %o5], %g1
315 add %g6, TI_XFSR, %o1 314 add %g6, TI_XFSR, %o1
316 membar #StoreLoad | #LoadLoad
317 sll %o0, 8, %o2 315 sll %o0, 8, %o2
318 add %g6, TI_FPREGS, %o3 316 add %g6, TI_FPREGS, %o3
319 brz,pn %l6, 1f 317 brz,pn %l6, 1f
320 add %g6, TI_FPREGS+0x40, %o4 318 add %g6, TI_FPREGS+0x40, %o4
321 319
320 membar #Sync
322 ldda [%o3 + %o2] ASI_BLK_P, %f0 321 ldda [%o3 + %o2] ASI_BLK_P, %f0
323 ldda [%o4 + %o2] ASI_BLK_P, %f16 322 ldda [%o4 + %o2] ASI_BLK_P, %f16
323 membar #Sync
3241: andcc %l2, FPRS_DU, %g0 3241: andcc %l2, FPRS_DU, %g0
325 be,pn %icc, 1f 325 be,pn %icc, 1f
326 wr %g1, 0, %gsr 326 wr %g1, 0, %gsr
327 add %o2, 0x80, %o2 327 add %o2, 0x80, %o2
328 membar #Sync
328 ldda [%o3 + %o2] ASI_BLK_P, %f32 329 ldda [%o3 + %o2] ASI_BLK_P, %f32
329 ldda [%o4 + %o2] ASI_BLK_P, %f48 330 ldda [%o4 + %o2] ASI_BLK_P, %f48
330
3311: membar #Sync 3311: membar #Sync
332 ldx [%o1 + %o5], %fsr 332 ldx [%o1 + %o5], %fsr
3332: stb %l5, [%g6 + TI_FPDEPTH] 3332: stb %l5, [%g6 + TI_FPDEPTH]
334 ba,pt %xcc, rt_continue 334 ba,pt %xcc, rt_continue
335 nop 335 nop
3365: wr %g0, FPRS_FEF, %fprs 3365: wr %g0, FPRS_FEF, %fprs
337 membar #StoreLoad | #LoadLoad
338 sll %o0, 8, %o2 337 sll %o0, 8, %o2
339 338
340 add %g6, TI_FPREGS+0x80, %o3 339 add %g6, TI_FPREGS+0x80, %o3
341 add %g6, TI_FPREGS+0xc0, %o4 340 add %g6, TI_FPREGS+0xc0, %o4
341 membar #Sync
342 ldda [%o3 + %o2] ASI_BLK_P, %f32 342 ldda [%o3 + %o2] ASI_BLK_P, %f32
343 ldda [%o4 + %o2] ASI_BLK_P, %f48 343 ldda [%o4 + %o2] ASI_BLK_P, %f48
344 membar #Sync 344 membar #Sync
345 wr %g0, FPRS_DU, %fprs 345 wr %g0, FPRS_DU, %fprs
346 ba,pt %xcc, rt_continue 346 ba,pt %xcc, rt_continue
347 stb %l5, [%g6 + TI_FPDEPTH] 347 stb %l5, [%g6 + TI_FPDEPTH]
348
349cplus_rinsn_1:
350 sethi %uhi(CTX_CHEETAH_PLUS_NUC), %l1
351
352 .globl cheetah_plus_patch_rtrap
353cheetah_plus_patch_rtrap:
354 /* We configure the dTLB512_0 for 4MB pages and the
355 * dTLB512_1 for 8K pages when in context zero.
356 */
357 sethi %hi(cplus_rinsn_1), %o0
358 sethi %hi(cplus_rtrap_insn_1), %o2
359 lduw [%o0 + %lo(cplus_rinsn_1)], %o1
360 or %o2, %lo(cplus_rtrap_insn_1), %o2
361 stw %o1, [%o2]
362 flush %o2
363
364 retl
365 nop
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index ddbed3341a23..c1f34237cdf2 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -187,17 +187,13 @@ int prom_callback(long *args)
187 } 187 }
188 188
189 if ((va >= KERNBASE) && (va < (KERNBASE + (4 * 1024 * 1024)))) { 189 if ((va >= KERNBASE) && (va < (KERNBASE + (4 * 1024 * 1024)))) {
190 unsigned long kernel_pctx = 0; 190 extern unsigned long sparc64_kern_pri_context;
191
192 if (tlb_type == cheetah_plus)
193 kernel_pctx |= (CTX_CHEETAH_PLUS_NUC |
194 CTX_CHEETAH_PLUS_CTX0);
195 191
196 /* Spitfire Errata #32 workaround */ 192 /* Spitfire Errata #32 workaround */
197 __asm__ __volatile__("stxa %0, [%1] %2\n\t" 193 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
198 "flush %%g6" 194 "flush %%g6"
199 : /* No outputs */ 195 : /* No outputs */
200 : "r" (kernel_pctx), 196 : "r" (sparc64_kern_pri_context),
201 "r" (PRIMARY_CONTEXT), 197 "r" (PRIMARY_CONTEXT),
202 "i" (ASI_DMMU)); 198 "i" (ASI_DMMU));
203 199
@@ -464,8 +460,6 @@ static void __init boot_flags_init(char *commands)
464 } 460 }
465} 461}
466 462
467extern int prom_probe_memory(void);
468extern unsigned long start, end;
469extern void panic_setup(char *, int *); 463extern void panic_setup(char *, int *);
470 464
471extern unsigned short root_flags; 465extern unsigned short root_flags;
@@ -492,13 +486,8 @@ void register_prom_callbacks(void)
492 "' linux-.soft2 to .soft2"); 486 "' linux-.soft2 to .soft2");
493} 487}
494 488
495extern void paging_init(void);
496
497void __init setup_arch(char **cmdline_p) 489void __init setup_arch(char **cmdline_p)
498{ 490{
499 unsigned long highest_paddr;
500 int i;
501
502 /* Initialize PROM console and command line. */ 491 /* Initialize PROM console and command line. */
503 *cmdline_p = prom_getbootargs(); 492 *cmdline_p = prom_getbootargs();
504 strcpy(saved_command_line, *cmdline_p); 493 strcpy(saved_command_line, *cmdline_p);
@@ -517,40 +506,6 @@ void __init setup_arch(char **cmdline_p)
517 boot_flags_init(*cmdline_p); 506 boot_flags_init(*cmdline_p);
518 507
519 idprom_init(); 508 idprom_init();
520 (void) prom_probe_memory();
521
522 /* In paging_init() we tip off this value to see if we need
523 * to change init_mm.pgd to point to the real alias mapping.
524 */
525 phys_base = 0xffffffffffffffffUL;
526 highest_paddr = 0UL;
527 for (i = 0; sp_banks[i].num_bytes != 0; i++) {
528 unsigned long top;
529
530 if (sp_banks[i].base_addr < phys_base)
531 phys_base = sp_banks[i].base_addr;
532 top = sp_banks[i].base_addr +
533 sp_banks[i].num_bytes;
534 if (highest_paddr < top)
535 highest_paddr = top;
536 }
537 pfn_base = phys_base >> PAGE_SHIFT;
538
539 switch (tlb_type) {
540 default:
541 case spitfire:
542 kern_base = spitfire_get_itlb_data(sparc64_highest_locked_tlbent());
543 kern_base &= _PAGE_PADDR_SF;
544 break;
545
546 case cheetah:
547 case cheetah_plus:
548 kern_base = cheetah_get_litlb_data(sparc64_highest_locked_tlbent());
549 kern_base &= _PAGE_PADDR;
550 break;
551 };
552
553 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
554 509
555 if (!root_flags) 510 if (!root_flags)
556 root_mountflags &= ~MS_RDONLY; 511 root_mountflags &= ~MS_RDONLY;
@@ -625,6 +580,9 @@ extern void smp_info(struct seq_file *);
625extern void smp_bogo(struct seq_file *); 580extern void smp_bogo(struct seq_file *);
626extern void mmu_info(struct seq_file *); 581extern void mmu_info(struct seq_file *);
627 582
583unsigned int dcache_parity_tl1_occurred;
584unsigned int icache_parity_tl1_occurred;
585
628static int show_cpuinfo(struct seq_file *m, void *__unused) 586static int show_cpuinfo(struct seq_file *m, void *__unused)
629{ 587{
630 seq_printf(m, 588 seq_printf(m,
@@ -635,6 +593,8 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
635 "type\t\t: sun4u\n" 593 "type\t\t: sun4u\n"
636 "ncpus probed\t: %ld\n" 594 "ncpus probed\t: %ld\n"
637 "ncpus active\t: %ld\n" 595 "ncpus active\t: %ld\n"
596 "D$ parity tl1\t: %u\n"
597 "I$ parity tl1\t: %u\n"
638#ifndef CONFIG_SMP 598#ifndef CONFIG_SMP
639 "Cpu0Bogo\t: %lu.%02lu\n" 599 "Cpu0Bogo\t: %lu.%02lu\n"
640 "Cpu0ClkTck\t: %016lx\n" 600 "Cpu0ClkTck\t: %016lx\n"
@@ -647,7 +607,9 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
647 (prom_prev >> 8) & 0xff, 607 (prom_prev >> 8) & 0xff,
648 prom_prev & 0xff, 608 prom_prev & 0xff,
649 (long)num_possible_cpus(), 609 (long)num_possible_cpus(),
650 (long)num_online_cpus() 610 (long)num_online_cpus(),
611 dcache_parity_tl1_occurred,
612 icache_parity_tl1_occurred
651#ifndef CONFIG_SMP 613#ifndef CONFIG_SMP
652 , cpu_data(0).udelay_val/(500000/HZ), 614 , cpu_data(0).udelay_val/(500000/HZ),
653 (cpu_data(0).udelay_val/(5000/HZ)) % 100, 615 (cpu_data(0).udelay_val/(5000/HZ)) % 100,
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index b4fc6a5462b2..b137fd63f5e1 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -93,6 +93,27 @@ void __init smp_store_cpu_info(int id)
93 cpu_data(id).pte_cache[1] = NULL; 93 cpu_data(id).pte_cache[1] = NULL;
94 cpu_data(id).pgd_cache = NULL; 94 cpu_data(id).pgd_cache = NULL;
95 cpu_data(id).idle_volume = 1; 95 cpu_data(id).idle_volume = 1;
96
97 cpu_data(id).dcache_size = prom_getintdefault(cpu_node, "dcache-size",
98 16 * 1024);
99 cpu_data(id).dcache_line_size =
100 prom_getintdefault(cpu_node, "dcache-line-size", 32);
101 cpu_data(id).icache_size = prom_getintdefault(cpu_node, "icache-size",
102 16 * 1024);
103 cpu_data(id).icache_line_size =
104 prom_getintdefault(cpu_node, "icache-line-size", 32);
105 cpu_data(id).ecache_size = prom_getintdefault(cpu_node, "ecache-size",
106 4 * 1024 * 1024);
107 cpu_data(id).ecache_line_size =
108 prom_getintdefault(cpu_node, "ecache-line-size", 64);
109 printk("CPU[%d]: Caches "
110 "D[sz(%d):line_sz(%d)] "
111 "I[sz(%d):line_sz(%d)] "
112 "E[sz(%d):line_sz(%d)]\n",
113 id,
114 cpu_data(id).dcache_size, cpu_data(id).dcache_line_size,
115 cpu_data(id).icache_size, cpu_data(id).icache_line_size,
116 cpu_data(id).ecache_size, cpu_data(id).ecache_line_size);
96} 117}
97 118
98static void smp_setup_percpu_timer(void); 119static void smp_setup_percpu_timer(void);
@@ -980,13 +1001,6 @@ void smp_penguin_jailcell(int irq, struct pt_regs *regs)
980 preempt_enable(); 1001 preempt_enable();
981} 1002}
982 1003
983extern unsigned long xcall_promstop;
984
985void smp_promstop_others(void)
986{
987 smp_cross_call(&xcall_promstop, 0, 0, 0);
988}
989
990#define prof_multiplier(__cpu) cpu_data(__cpu).multiplier 1004#define prof_multiplier(__cpu) cpu_data(__cpu).multiplier
991#define prof_counter(__cpu) cpu_data(__cpu).counter 1005#define prof_counter(__cpu) cpu_data(__cpu).counter
992 1006
diff --git a/arch/sparc64/kernel/sys32.S b/arch/sparc64/kernel/sys32.S
index 5f9e4fae612e..9cd272ac3ac1 100644
--- a/arch/sparc64/kernel/sys32.S
+++ b/arch/sparc64/kernel/sys32.S
@@ -157,173 +157,199 @@ sys32_socketcall: /* %o0=call, %o1=args */
157 or %g2, %lo(__socketcall_table_begin), %g2 157 or %g2, %lo(__socketcall_table_begin), %g2
158 jmpl %g2 + %o0, %g0 158 jmpl %g2 + %o0, %g0
159 nop 159 nop
160do_einval:
161 retl
162 mov -EINVAL, %o0
160 163
161 /* Each entry is exactly 32 bytes. */
162 .align 32 164 .align 32
163__socketcall_table_begin: 165__socketcall_table_begin:
166
167 /* Each entry is exactly 32 bytes. */
164do_sys_socket: /* sys_socket(int, int, int) */ 168do_sys_socket: /* sys_socket(int, int, int) */
165 ldswa [%o1 + 0x0] %asi, %o0 1691: ldswa [%o1 + 0x0] %asi, %o0
166 sethi %hi(sys_socket), %g1 170 sethi %hi(sys_socket), %g1
167 ldswa [%o1 + 0x8] %asi, %o2 1712: ldswa [%o1 + 0x8] %asi, %o2
168 jmpl %g1 + %lo(sys_socket), %g0 172 jmpl %g1 + %lo(sys_socket), %g0
169 ldswa [%o1 + 0x4] %asi, %o1 1733: ldswa [%o1 + 0x4] %asi, %o1
170 nop 174 nop
171 nop 175 nop
172 nop 176 nop
173do_sys_bind: /* sys_bind(int fd, struct sockaddr *, int) */ 177do_sys_bind: /* sys_bind(int fd, struct sockaddr *, int) */
174 ldswa [%o1 + 0x0] %asi, %o0 1784: ldswa [%o1 + 0x0] %asi, %o0
175 sethi %hi(sys_bind), %g1 179 sethi %hi(sys_bind), %g1
176 ldswa [%o1 + 0x8] %asi, %o2 1805: ldswa [%o1 + 0x8] %asi, %o2
177 jmpl %g1 + %lo(sys_bind), %g0 181 jmpl %g1 + %lo(sys_bind), %g0
178 lduwa [%o1 + 0x4] %asi, %o1 1826: lduwa [%o1 + 0x4] %asi, %o1
179 nop 183 nop
180 nop 184 nop
181 nop 185 nop
182do_sys_connect: /* sys_connect(int, struct sockaddr *, int) */ 186do_sys_connect: /* sys_connect(int, struct sockaddr *, int) */
183 ldswa [%o1 + 0x0] %asi, %o0 1877: ldswa [%o1 + 0x0] %asi, %o0
184 sethi %hi(sys_connect), %g1 188 sethi %hi(sys_connect), %g1
185 ldswa [%o1 + 0x8] %asi, %o2 1898: ldswa [%o1 + 0x8] %asi, %o2
186 jmpl %g1 + %lo(sys_connect), %g0 190 jmpl %g1 + %lo(sys_connect), %g0
187 lduwa [%o1 + 0x4] %asi, %o1 1919: lduwa [%o1 + 0x4] %asi, %o1
188 nop 192 nop
189 nop 193 nop
190 nop 194 nop
191do_sys_listen: /* sys_listen(int, int) */ 195do_sys_listen: /* sys_listen(int, int) */
192 ldswa [%o1 + 0x0] %asi, %o0 19610: ldswa [%o1 + 0x0] %asi, %o0
193 sethi %hi(sys_listen), %g1 197 sethi %hi(sys_listen), %g1
194 jmpl %g1 + %lo(sys_listen), %g0 198 jmpl %g1 + %lo(sys_listen), %g0
195 ldswa [%o1 + 0x4] %asi, %o1 19911: ldswa [%o1 + 0x4] %asi, %o1
196 nop 200 nop
197 nop 201 nop
198 nop 202 nop
199 nop 203 nop
200do_sys_accept: /* sys_accept(int, struct sockaddr *, int *) */ 204do_sys_accept: /* sys_accept(int, struct sockaddr *, int *) */
201 ldswa [%o1 + 0x0] %asi, %o0 20512: ldswa [%o1 + 0x0] %asi, %o0
202 sethi %hi(sys_accept), %g1 206 sethi %hi(sys_accept), %g1
203 lduwa [%o1 + 0x8] %asi, %o2 20713: lduwa [%o1 + 0x8] %asi, %o2
204 jmpl %g1 + %lo(sys_accept), %g0 208 jmpl %g1 + %lo(sys_accept), %g0
205 lduwa [%o1 + 0x4] %asi, %o1 20914: lduwa [%o1 + 0x4] %asi, %o1
206 nop 210 nop
207 nop 211 nop
208 nop 212 nop
209do_sys_getsockname: /* sys_getsockname(int, struct sockaddr *, int *) */ 213do_sys_getsockname: /* sys_getsockname(int, struct sockaddr *, int *) */
210 ldswa [%o1 + 0x0] %asi, %o0 21415: ldswa [%o1 + 0x0] %asi, %o0
211 sethi %hi(sys_getsockname), %g1 215 sethi %hi(sys_getsockname), %g1
212 lduwa [%o1 + 0x8] %asi, %o2 21616: lduwa [%o1 + 0x8] %asi, %o2
213 jmpl %g1 + %lo(sys_getsockname), %g0 217 jmpl %g1 + %lo(sys_getsockname), %g0
214 lduwa [%o1 + 0x4] %asi, %o1 21817: lduwa [%o1 + 0x4] %asi, %o1
215 nop 219 nop
216 nop 220 nop
217 nop 221 nop
218do_sys_getpeername: /* sys_getpeername(int, struct sockaddr *, int *) */ 222do_sys_getpeername: /* sys_getpeername(int, struct sockaddr *, int *) */
219 ldswa [%o1 + 0x0] %asi, %o0 22318: ldswa [%o1 + 0x0] %asi, %o0
220 sethi %hi(sys_getpeername), %g1 224 sethi %hi(sys_getpeername), %g1
221 lduwa [%o1 + 0x8] %asi, %o2 22519: lduwa [%o1 + 0x8] %asi, %o2
222 jmpl %g1 + %lo(sys_getpeername), %g0 226 jmpl %g1 + %lo(sys_getpeername), %g0
223 lduwa [%o1 + 0x4] %asi, %o1 22720: lduwa [%o1 + 0x4] %asi, %o1
224 nop 228 nop
225 nop 229 nop
226 nop 230 nop
227do_sys_socketpair: /* sys_socketpair(int, int, int, int *) */ 231do_sys_socketpair: /* sys_socketpair(int, int, int, int *) */
228 ldswa [%o1 + 0x0] %asi, %o0 23221: ldswa [%o1 + 0x0] %asi, %o0
229 sethi %hi(sys_socketpair), %g1 233 sethi %hi(sys_socketpair), %g1
230 ldswa [%o1 + 0x8] %asi, %o2 23422: ldswa [%o1 + 0x8] %asi, %o2
231 lduwa [%o1 + 0xc] %asi, %o3 23523: lduwa [%o1 + 0xc] %asi, %o3
232 jmpl %g1 + %lo(sys_socketpair), %g0 236 jmpl %g1 + %lo(sys_socketpair), %g0
233 ldswa [%o1 + 0x4] %asi, %o1 23724: ldswa [%o1 + 0x4] %asi, %o1
234 nop 238 nop
235 nop 239 nop
236do_sys_send: /* sys_send(int, void *, size_t, unsigned int) */ 240do_sys_send: /* sys_send(int, void *, size_t, unsigned int) */
237 ldswa [%o1 + 0x0] %asi, %o0 24125: ldswa [%o1 + 0x0] %asi, %o0
238 sethi %hi(sys_send), %g1 242 sethi %hi(sys_send), %g1
239 lduwa [%o1 + 0x8] %asi, %o2 24326: lduwa [%o1 + 0x8] %asi, %o2
240 lduwa [%o1 + 0xc] %asi, %o3 24427: lduwa [%o1 + 0xc] %asi, %o3
241 jmpl %g1 + %lo(sys_send), %g0 245 jmpl %g1 + %lo(sys_send), %g0
242 lduwa [%o1 + 0x4] %asi, %o1 24628: lduwa [%o1 + 0x4] %asi, %o1
243 nop 247 nop
244 nop 248 nop
245do_sys_recv: /* sys_recv(int, void *, size_t, unsigned int) */ 249do_sys_recv: /* sys_recv(int, void *, size_t, unsigned int) */
246 ldswa [%o1 + 0x0] %asi, %o0 25029: ldswa [%o1 + 0x0] %asi, %o0
247 sethi %hi(sys_recv), %g1 251 sethi %hi(sys_recv), %g1
248 lduwa [%o1 + 0x8] %asi, %o2 25230: lduwa [%o1 + 0x8] %asi, %o2
249 lduwa [%o1 + 0xc] %asi, %o3 25331: lduwa [%o1 + 0xc] %asi, %o3
250 jmpl %g1 + %lo(sys_recv), %g0 254 jmpl %g1 + %lo(sys_recv), %g0
251 lduwa [%o1 + 0x4] %asi, %o1 25532: lduwa [%o1 + 0x4] %asi, %o1
252 nop 256 nop
253 nop 257 nop
254do_sys_sendto: /* sys_sendto(int, u32, compat_size_t, unsigned int, u32, int) */ 258do_sys_sendto: /* sys_sendto(int, u32, compat_size_t, unsigned int, u32, int) */
255 ldswa [%o1 + 0x0] %asi, %o0 25933: ldswa [%o1 + 0x0] %asi, %o0
256 sethi %hi(sys_sendto), %g1 260 sethi %hi(sys_sendto), %g1
257 lduwa [%o1 + 0x8] %asi, %o2 26134: lduwa [%o1 + 0x8] %asi, %o2
258 lduwa [%o1 + 0xc] %asi, %o3 26235: lduwa [%o1 + 0xc] %asi, %o3
259 lduwa [%o1 + 0x10] %asi, %o4 26336: lduwa [%o1 + 0x10] %asi, %o4
260 ldswa [%o1 + 0x14] %asi, %o5 26437: ldswa [%o1 + 0x14] %asi, %o5
261 jmpl %g1 + %lo(sys_sendto), %g0 265 jmpl %g1 + %lo(sys_sendto), %g0
262 lduwa [%o1 + 0x4] %asi, %o1 26638: lduwa [%o1 + 0x4] %asi, %o1
263do_sys_recvfrom: /* sys_recvfrom(int, u32, compat_size_t, unsigned int, u32, u32) */ 267do_sys_recvfrom: /* sys_recvfrom(int, u32, compat_size_t, unsigned int, u32, u32) */
264 ldswa [%o1 + 0x0] %asi, %o0 26839: ldswa [%o1 + 0x0] %asi, %o0
265 sethi %hi(sys_recvfrom), %g1 269 sethi %hi(sys_recvfrom), %g1
266 lduwa [%o1 + 0x8] %asi, %o2 27040: lduwa [%o1 + 0x8] %asi, %o2
267 lduwa [%o1 + 0xc] %asi, %o3 27141: lduwa [%o1 + 0xc] %asi, %o3
268 lduwa [%o1 + 0x10] %asi, %o4 27242: lduwa [%o1 + 0x10] %asi, %o4
269 lduwa [%o1 + 0x14] %asi, %o5 27343: lduwa [%o1 + 0x14] %asi, %o5
270 jmpl %g1 + %lo(sys_recvfrom), %g0 274 jmpl %g1 + %lo(sys_recvfrom), %g0
271 lduwa [%o1 + 0x4] %asi, %o1 27544: lduwa [%o1 + 0x4] %asi, %o1
272do_sys_shutdown: /* sys_shutdown(int, int) */ 276do_sys_shutdown: /* sys_shutdown(int, int) */
273 ldswa [%o1 + 0x0] %asi, %o0 27745: ldswa [%o1 + 0x0] %asi, %o0
274 sethi %hi(sys_shutdown), %g1 278 sethi %hi(sys_shutdown), %g1
275 jmpl %g1 + %lo(sys_shutdown), %g0 279 jmpl %g1 + %lo(sys_shutdown), %g0
276 ldswa [%o1 + 0x4] %asi, %o1 28046: ldswa [%o1 + 0x4] %asi, %o1
277 nop 281 nop
278 nop 282 nop
279 nop 283 nop
280 nop 284 nop
281do_sys_setsockopt: /* compat_sys_setsockopt(int, int, int, char *, int) */ 285do_sys_setsockopt: /* compat_sys_setsockopt(int, int, int, char *, int) */
282 ldswa [%o1 + 0x0] %asi, %o0 28647: ldswa [%o1 + 0x0] %asi, %o0
283 sethi %hi(compat_sys_setsockopt), %g1 287 sethi %hi(compat_sys_setsockopt), %g1
284 ldswa [%o1 + 0x8] %asi, %o2 28848: ldswa [%o1 + 0x8] %asi, %o2
285 lduwa [%o1 + 0xc] %asi, %o3 28949: lduwa [%o1 + 0xc] %asi, %o3
286 ldswa [%o1 + 0x10] %asi, %o4 29050: ldswa [%o1 + 0x10] %asi, %o4
287 jmpl %g1 + %lo(compat_sys_setsockopt), %g0 291 jmpl %g1 + %lo(compat_sys_setsockopt), %g0
288 ldswa [%o1 + 0x4] %asi, %o1 29251: ldswa [%o1 + 0x4] %asi, %o1
289 nop 293 nop
290do_sys_getsockopt: /* compat_sys_getsockopt(int, int, int, u32, u32) */ 294do_sys_getsockopt: /* compat_sys_getsockopt(int, int, int, u32, u32) */
291 ldswa [%o1 + 0x0] %asi, %o0 29552: ldswa [%o1 + 0x0] %asi, %o0
292 sethi %hi(compat_sys_getsockopt), %g1 296 sethi %hi(compat_sys_getsockopt), %g1
293 ldswa [%o1 + 0x8] %asi, %o2 29753: ldswa [%o1 + 0x8] %asi, %o2
294 lduwa [%o1 + 0xc] %asi, %o3 29854: lduwa [%o1 + 0xc] %asi, %o3
295 lduwa [%o1 + 0x10] %asi, %o4 29955: lduwa [%o1 + 0x10] %asi, %o4
296 jmpl %g1 + %lo(compat_sys_getsockopt), %g0 300 jmpl %g1 + %lo(compat_sys_getsockopt), %g0
297 ldswa [%o1 + 0x4] %asi, %o1 30156: ldswa [%o1 + 0x4] %asi, %o1
298 nop 302 nop
299do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */ 303do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */
300 ldswa [%o1 + 0x0] %asi, %o0 30457: ldswa [%o1 + 0x0] %asi, %o0
301 sethi %hi(compat_sys_sendmsg), %g1 305 sethi %hi(compat_sys_sendmsg), %g1
302 lduwa [%o1 + 0x8] %asi, %o2 30658: lduwa [%o1 + 0x8] %asi, %o2
303 jmpl %g1 + %lo(compat_sys_sendmsg), %g0 307 jmpl %g1 + %lo(compat_sys_sendmsg), %g0
304 lduwa [%o1 + 0x4] %asi, %o1 30859: lduwa [%o1 + 0x4] %asi, %o1
305 nop 309 nop
306 nop 310 nop
307 nop 311 nop
308do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int) */ 312do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int) */
309 ldswa [%o1 + 0x0] %asi, %o0 31360: ldswa [%o1 + 0x0] %asi, %o0
310 sethi %hi(compat_sys_recvmsg), %g1 314 sethi %hi(compat_sys_recvmsg), %g1
311 lduwa [%o1 + 0x8] %asi, %o2 31561: lduwa [%o1 + 0x8] %asi, %o2
312 jmpl %g1 + %lo(compat_sys_recvmsg), %g0 316 jmpl %g1 + %lo(compat_sys_recvmsg), %g0
313 lduwa [%o1 + 0x4] %asi, %o1 31762: lduwa [%o1 + 0x4] %asi, %o1
314 nop 318 nop
315 nop 319 nop
316 nop 320 nop
317__socketcall_table_end:
318
319do_einval:
320 retl
321 mov -EINVAL, %o0
322do_efault:
323 retl
324 mov -EFAULT, %o0
325 321
326 .section __ex_table 322 .section __ex_table
327 .align 4 323 .align 4
328 .word __socketcall_table_begin, 0, __socketcall_table_end, do_efault 324 .word 1b, __retl_efault, 2b, __retl_efault
325 .word 3b, __retl_efault, 4b, __retl_efault
326 .word 5b, __retl_efault, 6b, __retl_efault
327 .word 7b, __retl_efault, 8b, __retl_efault
328 .word 9b, __retl_efault, 10b, __retl_efault
329 .word 11b, __retl_efault, 12b, __retl_efault
330 .word 13b, __retl_efault, 14b, __retl_efault
331 .word 15b, __retl_efault, 16b, __retl_efault
332 .word 17b, __retl_efault, 18b, __retl_efault
333 .word 19b, __retl_efault, 20b, __retl_efault
334 .word 21b, __retl_efault, 22b, __retl_efault
335 .word 23b, __retl_efault, 24b, __retl_efault
336 .word 25b, __retl_efault, 26b, __retl_efault
337 .word 27b, __retl_efault, 28b, __retl_efault
338 .word 29b, __retl_efault, 30b, __retl_efault
339 .word 31b, __retl_efault, 32b, __retl_efault
340 .word 33b, __retl_efault, 34b, __retl_efault
341 .word 35b, __retl_efault, 36b, __retl_efault
342 .word 37b, __retl_efault, 38b, __retl_efault
343 .word 39b, __retl_efault, 40b, __retl_efault
344 .word 41b, __retl_efault, 42b, __retl_efault
345 .word 43b, __retl_efault, 44b, __retl_efault
346 .word 45b, __retl_efault, 46b, __retl_efault
347 .word 47b, __retl_efault, 48b, __retl_efault
348 .word 49b, __retl_efault, 50b, __retl_efault
349 .word 51b, __retl_efault, 52b, __retl_efault
350 .word 53b, __retl_efault, 54b, __retl_efault
351 .word 55b, __retl_efault, 56b, __retl_efault
352 .word 57b, __retl_efault, 58b, __retl_efault
353 .word 59b, __retl_efault, 60b, __retl_efault
354 .word 61b, __retl_efault, 62b, __retl_efault
329 .previous 355 .previous
diff --git a/arch/sparc64/kernel/trampoline.S b/arch/sparc64/kernel/trampoline.S
index 3a145fc39cf2..9478551cb020 100644
--- a/arch/sparc64/kernel/trampoline.S
+++ b/arch/sparc64/kernel/trampoline.S
@@ -119,8 +119,8 @@ startup_continue:
119 sethi %hi(itlb_load), %g2 119 sethi %hi(itlb_load), %g2
120 or %g2, %lo(itlb_load), %g2 120 or %g2, %lo(itlb_load), %g2
121 stx %g2, [%sp + 2047 + 128 + 0x18] 121 stx %g2, [%sp + 2047 + 128 + 0x18]
122 sethi %hi(mmu_ihandle_cache), %g2 122 sethi %hi(prom_mmu_ihandle_cache), %g2
123 lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 123 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
124 stx %g2, [%sp + 2047 + 128 + 0x20] 124 stx %g2, [%sp + 2047 + 128 + 0x20]
125 sethi %hi(KERNBASE), %g2 125 sethi %hi(KERNBASE), %g2
126 stx %g2, [%sp + 2047 + 128 + 0x28] 126 stx %g2, [%sp + 2047 + 128 + 0x28]
@@ -156,8 +156,8 @@ startup_continue:
156 sethi %hi(itlb_load), %g2 156 sethi %hi(itlb_load), %g2
157 or %g2, %lo(itlb_load), %g2 157 or %g2, %lo(itlb_load), %g2
158 stx %g2, [%sp + 2047 + 128 + 0x18] 158 stx %g2, [%sp + 2047 + 128 + 0x18]
159 sethi %hi(mmu_ihandle_cache), %g2 159 sethi %hi(prom_mmu_ihandle_cache), %g2
160 lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 160 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
161 stx %g2, [%sp + 2047 + 128 + 0x20] 161 stx %g2, [%sp + 2047 + 128 + 0x20]
162 sethi %hi(KERNBASE + 0x400000), %g2 162 sethi %hi(KERNBASE + 0x400000), %g2
163 stx %g2, [%sp + 2047 + 128 + 0x28] 163 stx %g2, [%sp + 2047 + 128 + 0x28]
@@ -190,8 +190,8 @@ do_dtlb:
190 sethi %hi(dtlb_load), %g2 190 sethi %hi(dtlb_load), %g2
191 or %g2, %lo(dtlb_load), %g2 191 or %g2, %lo(dtlb_load), %g2
192 stx %g2, [%sp + 2047 + 128 + 0x18] 192 stx %g2, [%sp + 2047 + 128 + 0x18]
193 sethi %hi(mmu_ihandle_cache), %g2 193 sethi %hi(prom_mmu_ihandle_cache), %g2
194 lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 194 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
195 stx %g2, [%sp + 2047 + 128 + 0x20] 195 stx %g2, [%sp + 2047 + 128 + 0x20]
196 sethi %hi(KERNBASE), %g2 196 sethi %hi(KERNBASE), %g2
197 stx %g2, [%sp + 2047 + 128 + 0x28] 197 stx %g2, [%sp + 2047 + 128 + 0x28]
@@ -228,8 +228,8 @@ do_dtlb:
228 sethi %hi(dtlb_load), %g2 228 sethi %hi(dtlb_load), %g2
229 or %g2, %lo(dtlb_load), %g2 229 or %g2, %lo(dtlb_load), %g2
230 stx %g2, [%sp + 2047 + 128 + 0x18] 230 stx %g2, [%sp + 2047 + 128 + 0x18]
231 sethi %hi(mmu_ihandle_cache), %g2 231 sethi %hi(prom_mmu_ihandle_cache), %g2
232 lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 232 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
233 stx %g2, [%sp + 2047 + 128 + 0x20] 233 stx %g2, [%sp + 2047 + 128 + 0x20]
234 sethi %hi(KERNBASE + 0x400000), %g2 234 sethi %hi(KERNBASE + 0x400000), %g2
235 stx %g2, [%sp + 2047 + 128 + 0x28] 235 stx %g2, [%sp + 2047 + 128 + 0x28]
@@ -336,20 +336,13 @@ do_unlock:
336 call init_irqwork_curcpu 336 call init_irqwork_curcpu
337 nop 337 nop
338 338
339 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f) 339 /* Start using proper page size encodings in ctx register. */
340 ba,pt %xcc, 2f 340 sethi %hi(sparc64_kern_pri_context), %g3
341 nop 341 ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
342
3431: /* Start using proper page size encodings in ctx register. */
344 sethi %uhi(CTX_CHEETAH_PLUS_NUC), %g3
345 mov PRIMARY_CONTEXT, %g1 342 mov PRIMARY_CONTEXT, %g1
346 sllx %g3, 32, %g3 343 stxa %g2, [%g1] ASI_DMMU
347 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
348 or %g3, %g2, %g3
349 stxa %g3, [%g1] ASI_DMMU
350 membar #Sync 344 membar #Sync
351 345
3522:
353 rdpr %pstate, %o1 346 rdpr %pstate, %o1
354 or %o1, PSTATE_IE, %o1 347 or %o1, PSTATE_IE, %o1
355 wrpr %o1, 0, %pstate 348 wrpr %o1, 0, %pstate
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index b280b2ef674f..5570e7bb22bb 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -189,19 +189,18 @@ void spitfire_data_access_exception(struct pt_regs *regs, unsigned long sfsr, un
189 189
190 if (regs->tstate & TSTATE_PRIV) { 190 if (regs->tstate & TSTATE_PRIV) {
191 /* Test if this comes from uaccess places. */ 191 /* Test if this comes from uaccess places. */
192 unsigned long fixup; 192 const struct exception_table_entry *entry;
193 unsigned long g2 = regs->u_regs[UREG_G2];
194 193
195 if ((fixup = search_extables_range(regs->tpc, &g2))) { 194 entry = search_exception_tables(regs->tpc);
196 /* Ouch, somebody is trying ugly VM hole tricks on us... */ 195 if (entry) {
196 /* Ouch, somebody is trying VM hole tricks on us... */
197#ifdef DEBUG_EXCEPTIONS 197#ifdef DEBUG_EXCEPTIONS
198 printk("Exception: PC<%016lx> faddr<UNKNOWN>\n", regs->tpc); 198 printk("Exception: PC<%016lx> faddr<UNKNOWN>\n", regs->tpc);
199 printk("EX_TABLE: insn<%016lx> fixup<%016lx> " 199 printk("EX_TABLE: insn<%016lx> fixup<%016lx>\n",
200 "g2<%016lx>\n", regs->tpc, fixup, g2); 200 regs->tpc, entry->fixup);
201#endif 201#endif
202 regs->tpc = fixup; 202 regs->tpc = entry->fixup;
203 regs->tnpc = regs->tpc + 4; 203 regs->tnpc = regs->tpc + 4;
204 regs->u_regs[UREG_G2] = g2;
205 return; 204 return;
206 } 205 }
207 /* Shit... */ 206 /* Shit... */
@@ -758,26 +757,12 @@ void __init cheetah_ecache_flush_init(void)
758 ecache_flush_size = (2 * largest_size); 757 ecache_flush_size = (2 * largest_size);
759 ecache_flush_linesize = smallest_linesize; 758 ecache_flush_linesize = smallest_linesize;
760 759
761 /* Discover a physically contiguous chunk of physical 760 ecache_flush_physbase = find_ecache_flush_span(ecache_flush_size);
762 * memory in 'sp_banks' of size ecache_flush_size calculated
763 * above. Store the physical base of this area at
764 * ecache_flush_physbase.
765 */
766 for (node = 0; ; node++) {
767 if (sp_banks[node].num_bytes == 0)
768 break;
769 if (sp_banks[node].num_bytes >= ecache_flush_size) {
770 ecache_flush_physbase = sp_banks[node].base_addr;
771 break;
772 }
773 }
774 761
775 /* Note: Zero would be a valid value of ecache_flush_physbase so 762 if (ecache_flush_physbase == ~0UL) {
776 * don't use that as the success test. :-)
777 */
778 if (sp_banks[node].num_bytes == 0) {
779 prom_printf("cheetah_ecache_flush_init: Cannot find %d byte " 763 prom_printf("cheetah_ecache_flush_init: Cannot find %d byte "
780 "contiguous physical memory.\n", ecache_flush_size); 764 "contiguous physical memory.\n",
765 ecache_flush_size);
781 prom_halt(); 766 prom_halt();
782 } 767 }
783 768
@@ -869,14 +854,19 @@ static void cheetah_flush_ecache_line(unsigned long physaddr)
869 */ 854 */
870static void __cheetah_flush_icache(void) 855static void __cheetah_flush_icache(void)
871{ 856{
872 unsigned long i; 857 unsigned int icache_size, icache_line_size;
858 unsigned long addr;
859
860 icache_size = local_cpu_data().icache_size;
861 icache_line_size = local_cpu_data().icache_line_size;
873 862
874 /* Clear the valid bits in all the tags. */ 863 /* Clear the valid bits in all the tags. */
875 for (i = 0; i < (1 << 15); i += (1 << 5)) { 864 for (addr = 0; addr < icache_size; addr += icache_line_size) {
876 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" 865 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
877 "membar #Sync" 866 "membar #Sync"
878 : /* no outputs */ 867 : /* no outputs */
879 : "r" (i | (2 << 3)), "i" (ASI_IC_TAG)); 868 : "r" (addr | (2 << 3)),
869 "i" (ASI_IC_TAG));
880 } 870 }
881} 871}
882 872
@@ -904,13 +894,17 @@ static void cheetah_flush_icache(void)
904 894
905static void cheetah_flush_dcache(void) 895static void cheetah_flush_dcache(void)
906{ 896{
907 unsigned long i; 897 unsigned int dcache_size, dcache_line_size;
898 unsigned long addr;
908 899
909 for (i = 0; i < (1 << 16); i += (1 << 5)) { 900 dcache_size = local_cpu_data().dcache_size;
901 dcache_line_size = local_cpu_data().dcache_line_size;
902
903 for (addr = 0; addr < dcache_size; addr += dcache_line_size) {
910 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t" 904 __asm__ __volatile__("stxa %%g0, [%0] %1\n\t"
911 "membar #Sync" 905 "membar #Sync"
912 : /* no outputs */ 906 : /* no outputs */
913 : "r" (i), "i" (ASI_DCACHE_TAG)); 907 : "r" (addr), "i" (ASI_DCACHE_TAG));
914 } 908 }
915} 909}
916 910
@@ -921,24 +915,29 @@ static void cheetah_flush_dcache(void)
921 */ 915 */
922static void cheetah_plus_zap_dcache_parity(void) 916static void cheetah_plus_zap_dcache_parity(void)
923{ 917{
924 unsigned long i; 918 unsigned int dcache_size, dcache_line_size;
919 unsigned long addr;
920
921 dcache_size = local_cpu_data().dcache_size;
922 dcache_line_size = local_cpu_data().dcache_line_size;
925 923
926 for (i = 0; i < (1 << 16); i += (1 << 5)) { 924 for (addr = 0; addr < dcache_size; addr += dcache_line_size) {
927 unsigned long tag = (i >> 14); 925 unsigned long tag = (addr >> 14);
928 unsigned long j; 926 unsigned long line;
929 927
930 __asm__ __volatile__("membar #Sync\n\t" 928 __asm__ __volatile__("membar #Sync\n\t"
931 "stxa %0, [%1] %2\n\t" 929 "stxa %0, [%1] %2\n\t"
932 "membar #Sync" 930 "membar #Sync"
933 : /* no outputs */ 931 : /* no outputs */
934 : "r" (tag), "r" (i), 932 : "r" (tag), "r" (addr),
935 "i" (ASI_DCACHE_UTAG)); 933 "i" (ASI_DCACHE_UTAG));
936 for (j = i; j < i + (1 << 5); j += (1 << 3)) 934 for (line = addr; line < addr + dcache_line_size; line += 8)
937 __asm__ __volatile__("membar #Sync\n\t" 935 __asm__ __volatile__("membar #Sync\n\t"
938 "stxa %%g0, [%0] %1\n\t" 936 "stxa %%g0, [%0] %1\n\t"
939 "membar #Sync" 937 "membar #Sync"
940 : /* no outputs */ 938 : /* no outputs */
941 : "r" (j), "i" (ASI_DCACHE_DATA)); 939 : "r" (line),
940 "i" (ASI_DCACHE_DATA));
942 } 941 }
943} 942}
944 943
@@ -1332,16 +1331,12 @@ static int cheetah_fix_ce(unsigned long physaddr)
1332/* Return non-zero if PADDR is a valid physical memory address. */ 1331/* Return non-zero if PADDR is a valid physical memory address. */
1333static int cheetah_check_main_memory(unsigned long paddr) 1332static int cheetah_check_main_memory(unsigned long paddr)
1334{ 1333{
1335 int i; 1334 unsigned long vaddr = PAGE_OFFSET + paddr;
1336 1335
1337 for (i = 0; ; i++) { 1336 if (vaddr > (unsigned long) high_memory)
1338 if (sp_banks[i].num_bytes == 0) 1337 return 0;
1339 break; 1338
1340 if (paddr >= sp_banks[i].base_addr && 1339 return kern_addr_valid(vaddr);
1341 paddr < (sp_banks[i].base_addr + sp_banks[i].num_bytes))
1342 return 1;
1343 }
1344 return 0;
1345} 1340}
1346 1341
1347void cheetah_cee_handler(struct pt_regs *regs, unsigned long afsr, unsigned long afar) 1342void cheetah_cee_handler(struct pt_regs *regs, unsigned long afsr, unsigned long afar)
@@ -1596,10 +1591,10 @@ void cheetah_deferred_handler(struct pt_regs *regs, unsigned long afsr, unsigned
1596 /* OK, usermode access. */ 1591 /* OK, usermode access. */
1597 recoverable = 1; 1592 recoverable = 1;
1598 } else { 1593 } else {
1599 unsigned long g2 = regs->u_regs[UREG_G2]; 1594 const struct exception_table_entry *entry;
1600 unsigned long fixup = search_extables_range(regs->tpc, &g2);
1601 1595
1602 if (fixup != 0UL) { 1596 entry = search_exception_tables(regs->tpc);
1597 if (entry) {
1603 /* OK, kernel access to userspace. */ 1598 /* OK, kernel access to userspace. */
1604 recoverable = 1; 1599 recoverable = 1;
1605 1600
@@ -1618,9 +1613,8 @@ void cheetah_deferred_handler(struct pt_regs *regs, unsigned long afsr, unsigned
1618 * recoverable condition. 1613 * recoverable condition.
1619 */ 1614 */
1620 if (recoverable) { 1615 if (recoverable) {
1621 regs->tpc = fixup; 1616 regs->tpc = entry->fixup;
1622 regs->tnpc = regs->tpc + 4; 1617 regs->tnpc = regs->tpc + 4;
1623 regs->u_regs[UREG_G2] = g2;
1624 } 1618 }
1625 } 1619 }
1626 } 1620 }
diff --git a/arch/sparc64/kernel/una_asm.S b/arch/sparc64/kernel/una_asm.S
index cbb40585253c..1f5b5b708ce7 100644
--- a/arch/sparc64/kernel/una_asm.S
+++ b/arch/sparc64/kernel/una_asm.S
@@ -6,18 +6,11 @@
6 6
7 .text 7 .text
8 8
9kernel_unaligned_trap_fault:
10 call kernel_mna_trap_fault
11 nop
12 retl
13 nop
14 .size kern_unaligned_trap_fault, .-kern_unaligned_trap_fault
15
16 .globl __do_int_store 9 .globl __do_int_store
17__do_int_store: 10__do_int_store:
18 rd %asi, %o4 11 rd %asi, %o4
19 wr %o3, 0, %asi 12 wr %o3, 0, %asi
20 ldx [%o2], %g3 13 mov %o2, %g3
21 cmp %o1, 2 14 cmp %o1, 2
22 be,pn %icc, 2f 15 be,pn %icc, 2f
23 cmp %o1, 4 16 cmp %o1, 4
@@ -51,24 +44,24 @@ __do_int_store:
510: 440:
52 wr %o4, 0x0, %asi 45 wr %o4, 0x0, %asi
53 retl 46 retl
54 nop 47 mov 0, %o0
55 .size __do_int_store, .-__do_int_store 48 .size __do_int_store, .-__do_int_store
56 49
57 .section __ex_table 50 .section __ex_table
58 .word 4b, kernel_unaligned_trap_fault 51 .word 4b, __retl_efault
59 .word 5b, kernel_unaligned_trap_fault 52 .word 5b, __retl_efault
60 .word 6b, kernel_unaligned_trap_fault 53 .word 6b, __retl_efault
61 .word 7b, kernel_unaligned_trap_fault 54 .word 7b, __retl_efault
62 .word 8b, kernel_unaligned_trap_fault 55 .word 8b, __retl_efault
63 .word 9b, kernel_unaligned_trap_fault 56 .word 9b, __retl_efault
64 .word 10b, kernel_unaligned_trap_fault 57 .word 10b, __retl_efault
65 .word 11b, kernel_unaligned_trap_fault 58 .word 11b, __retl_efault
66 .word 12b, kernel_unaligned_trap_fault 59 .word 12b, __retl_efault
67 .word 13b, kernel_unaligned_trap_fault 60 .word 13b, __retl_efault
68 .word 14b, kernel_unaligned_trap_fault 61 .word 14b, __retl_efault
69 .word 15b, kernel_unaligned_trap_fault 62 .word 15b, __retl_efault
70 .word 16b, kernel_unaligned_trap_fault 63 .word 16b, __retl_efault
71 .word 17b, kernel_unaligned_trap_fault 64 .word 17b, __retl_efault
72 .previous 65 .previous
73 66
74 .globl do_int_load 67 .globl do_int_load
@@ -133,21 +126,21 @@ do_int_load:
1330: 1260:
134 wr %o5, 0x0, %asi 127 wr %o5, 0x0, %asi
135 retl 128 retl
136 nop 129 mov 0, %o0
137 .size __do_int_load, .-__do_int_load 130 .size __do_int_load, .-__do_int_load
138 131
139 .section __ex_table 132 .section __ex_table
140 .word 4b, kernel_unaligned_trap_fault 133 .word 4b, __retl_efault
141 .word 5b, kernel_unaligned_trap_fault 134 .word 5b, __retl_efault
142 .word 6b, kernel_unaligned_trap_fault 135 .word 6b, __retl_efault
143 .word 7b, kernel_unaligned_trap_fault 136 .word 7b, __retl_efault
144 .word 8b, kernel_unaligned_trap_fault 137 .word 8b, __retl_efault
145 .word 9b, kernel_unaligned_trap_fault 138 .word 9b, __retl_efault
146 .word 10b, kernel_unaligned_trap_fault 139 .word 10b, __retl_efault
147 .word 11b, kernel_unaligned_trap_fault 140 .word 11b, __retl_efault
148 .word 12b, kernel_unaligned_trap_fault 141 .word 12b, __retl_efault
149 .word 13b, kernel_unaligned_trap_fault 142 .word 13b, __retl_efault
150 .word 14b, kernel_unaligned_trap_fault 143 .word 14b, __retl_efault
151 .word 15b, kernel_unaligned_trap_fault 144 .word 15b, __retl_efault
152 .word 16b, kernel_unaligned_trap_fault 145 .word 16b, __retl_efault
153 .previous 146 .previous
diff --git a/arch/sparc64/kernel/unaligned.c b/arch/sparc64/kernel/unaligned.c
index da9739f0d437..70faf630603b 100644
--- a/arch/sparc64/kernel/unaligned.c
+++ b/arch/sparc64/kernel/unaligned.c
@@ -180,17 +180,18 @@ static void __attribute_used__ unaligned_panic(char *str, struct pt_regs *regs)
180 die_if_kernel(str, regs); 180 die_if_kernel(str, regs);
181} 181}
182 182
183extern void do_int_load(unsigned long *dest_reg, int size, 183extern int do_int_load(unsigned long *dest_reg, int size,
184 unsigned long *saddr, int is_signed, int asi); 184 unsigned long *saddr, int is_signed, int asi);
185 185
186extern void __do_int_store(unsigned long *dst_addr, int size, 186extern int __do_int_store(unsigned long *dst_addr, int size,
187 unsigned long *src_val, int asi); 187 unsigned long src_val, int asi);
188 188
189static inline void do_int_store(int reg_num, int size, unsigned long *dst_addr, 189static inline int do_int_store(int reg_num, int size, unsigned long *dst_addr,
190 struct pt_regs *regs, int asi) 190 struct pt_regs *regs, int asi, int orig_asi)
191{ 191{
192 unsigned long zero = 0; 192 unsigned long zero = 0;
193 unsigned long *src_val = &zero; 193 unsigned long *src_val_p = &zero;
194 unsigned long src_val;
194 195
195 if (size == 16) { 196 if (size == 16) {
196 size = 8; 197 size = 8;
@@ -198,9 +199,27 @@ static inline void do_int_store(int reg_num, int size, unsigned long *dst_addr,
198 (unsigned)fetch_reg(reg_num, regs) : 0)) << 32) | 199 (unsigned)fetch_reg(reg_num, regs) : 0)) << 32) |
199 (unsigned)fetch_reg(reg_num + 1, regs); 200 (unsigned)fetch_reg(reg_num + 1, regs);
200 } else if (reg_num) { 201 } else if (reg_num) {
201 src_val = fetch_reg_addr(reg_num, regs); 202 src_val_p = fetch_reg_addr(reg_num, regs);
202 } 203 }
203 __do_int_store(dst_addr, size, src_val, asi); 204 src_val = *src_val_p;
205 if (unlikely(asi != orig_asi)) {
206 switch (size) {
207 case 2:
208 src_val = swab16(src_val);
209 break;
210 case 4:
211 src_val = swab32(src_val);
212 break;
213 case 8:
214 src_val = swab64(src_val);
215 break;
216 case 16:
217 default:
218 BUG();
219 break;
220 };
221 }
222 return __do_int_store(dst_addr, size, src_val, asi);
204} 223}
205 224
206static inline void advance(struct pt_regs *regs) 225static inline void advance(struct pt_regs *regs)
@@ -223,14 +242,14 @@ static inline int ok_for_kernel(unsigned int insn)
223 return !floating_point_load_or_store_p(insn); 242 return !floating_point_load_or_store_p(insn);
224} 243}
225 244
226void kernel_mna_trap_fault(void) 245static void kernel_mna_trap_fault(void)
227{ 246{
228 struct pt_regs *regs = current_thread_info()->kern_una_regs; 247 struct pt_regs *regs = current_thread_info()->kern_una_regs;
229 unsigned int insn = current_thread_info()->kern_una_insn; 248 unsigned int insn = current_thread_info()->kern_una_insn;
230 unsigned long g2 = regs->u_regs[UREG_G2]; 249 const struct exception_table_entry *entry;
231 unsigned long fixup = search_extables_range(regs->tpc, &g2);
232 250
233 if (!fixup) { 251 entry = search_exception_tables(regs->tpc);
252 if (!entry) {
234 unsigned long address; 253 unsigned long address;
235 254
236 address = compute_effective_address(regs, insn, 255 address = compute_effective_address(regs, insn,
@@ -251,9 +270,8 @@ void kernel_mna_trap_fault(void)
251 die_if_kernel("Oops", regs); 270 die_if_kernel("Oops", regs);
252 /* Not reached */ 271 /* Not reached */
253 } 272 }
254 regs->tpc = fixup; 273 regs->tpc = entry->fixup;
255 regs->tnpc = regs->tpc + 4; 274 regs->tnpc = regs->tpc + 4;
256 regs->u_regs [UREG_G2] = g2;
257 275
258 regs->tstate &= ~TSTATE_ASI; 276 regs->tstate &= ~TSTATE_ASI;
259 regs->tstate |= (ASI_AIUS << 24UL); 277 regs->tstate |= (ASI_AIUS << 24UL);
@@ -275,7 +293,8 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn, u
275 293
276 kernel_mna_trap_fault(); 294 kernel_mna_trap_fault();
277 } else { 295 } else {
278 unsigned long addr; 296 unsigned long addr, *reg_addr;
297 int orig_asi, asi, err;
279 298
280 addr = compute_effective_address(regs, insn, 299 addr = compute_effective_address(regs, insn,
281 ((insn >> 25) & 0x1f)); 300 ((insn >> 25) & 0x1f));
@@ -285,25 +304,59 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn, u
285 regs->tpc, dirstrings[dir], addr, size, 304 regs->tpc, dirstrings[dir], addr, size,
286 regs->u_regs[UREG_RETPC]); 305 regs->u_regs[UREG_RETPC]);
287#endif 306#endif
307 orig_asi = asi = decode_asi(insn, regs);
308 switch (asi) {
309 case ASI_NL:
310 case ASI_AIUPL:
311 case ASI_AIUSL:
312 case ASI_PL:
313 case ASI_SL:
314 case ASI_PNFL:
315 case ASI_SNFL:
316 asi &= ~0x08;
317 break;
318 };
288 switch (dir) { 319 switch (dir) {
289 case load: 320 case load:
290 do_int_load(fetch_reg_addr(((insn>>25)&0x1f), regs), 321 reg_addr = fetch_reg_addr(((insn>>25)&0x1f), regs);
291 size, (unsigned long *) addr, 322 err = do_int_load(reg_addr, size,
292 decode_signedness(insn), 323 (unsigned long *) addr,
293 decode_asi(insn, regs)); 324 decode_signedness(insn), asi);
325 if (likely(!err) && unlikely(asi != orig_asi)) {
326 unsigned long val_in = *reg_addr;
327 switch (size) {
328 case 2:
329 val_in = swab16(val_in);
330 break;
331 case 4:
332 val_in = swab32(val_in);
333 break;
334 case 8:
335 val_in = swab64(val_in);
336 break;
337 case 16:
338 default:
339 BUG();
340 break;
341 };
342 *reg_addr = val_in;
343 }
294 break; 344 break;
295 345
296 case store: 346 case store:
297 do_int_store(((insn>>25)&0x1f), size, 347 err = do_int_store(((insn>>25)&0x1f), size,
298 (unsigned long *) addr, regs, 348 (unsigned long *) addr, regs,
299 decode_asi(insn, regs)); 349 asi, orig_asi);
300 break; 350 break;
301 351
302 default: 352 default:
303 panic("Impossible kernel unaligned trap."); 353 panic("Impossible kernel unaligned trap.");
304 /* Not reached... */ 354 /* Not reached... */
305 } 355 }
306 advance(regs); 356 if (unlikely(err))
357 kernel_mna_trap_fault();
358 else
359 advance(regs);
307 } 360 }
308} 361}
309 362
diff --git a/arch/sparc64/kernel/us3_cpufreq.c b/arch/sparc64/kernel/us3_cpufreq.c
index 9080e7cd4bb0..0340041f6143 100644
--- a/arch/sparc64/kernel/us3_cpufreq.c
+++ b/arch/sparc64/kernel/us3_cpufreq.c
@@ -208,7 +208,10 @@ static int __init us3_freq_init(void)
208 impl = ((ver >> 32) & 0xffff); 208 impl = ((ver >> 32) & 0xffff);
209 209
210 if (manuf == CHEETAH_MANUF && 210 if (manuf == CHEETAH_MANUF &&
211 (impl == CHEETAH_IMPL || impl == CHEETAH_PLUS_IMPL)) { 211 (impl == CHEETAH_IMPL ||
212 impl == CHEETAH_PLUS_IMPL ||
213 impl == JAGUAR_IMPL ||
214 impl == PANTHER_IMPL)) {
212 struct cpufreq_driver *driver; 215 struct cpufreq_driver *driver;
213 216
214 ret = -ENOMEM; 217 ret = -ENOMEM;
diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S
index f47d0be39378..2af0cf0a8640 100644
--- a/arch/sparc64/kernel/vmlinux.lds.S
+++ b/arch/sparc64/kernel/vmlinux.lds.S
@@ -9,8 +9,7 @@ ENTRY(_start)
9jiffies = jiffies_64; 9jiffies = jiffies_64;
10SECTIONS 10SECTIONS
11{ 11{
12 swapper_pmd_dir = 0x0000000000402000; 12 swapper_low_pmd_dir = 0x0000000000402000;
13 empty_pg_dir = 0x0000000000403000;
14 . = 0x4000; 13 . = 0x4000;
15 .text 0x0000000000404000 : 14 .text 0x0000000000404000 :
16 { 15 {
diff --git a/arch/sparc64/kernel/winfixup.S b/arch/sparc64/kernel/winfixup.S
index 99c809a1e5ac..39160926267b 100644
--- a/arch/sparc64/kernel/winfixup.S
+++ b/arch/sparc64/kernel/winfixup.S
@@ -16,23 +16,14 @@
16 .text 16 .text
17 17
18set_pcontext: 18set_pcontext:
19cplus_winfixup_insn_1: 19 sethi %hi(sparc64_kern_pri_context), %l1
20 sethi %hi(0), %l1 20 ldx [%l1 + %lo(sparc64_kern_pri_context)], %l1
21 mov PRIMARY_CONTEXT, %g1 21 mov PRIMARY_CONTEXT, %g1
22 sllx %l1, 32, %l1
23cplus_winfixup_insn_2:
24 sethi %hi(0), %g2
25 or %l1, %g2, %l1
26 stxa %l1, [%g1] ASI_DMMU 22 stxa %l1, [%g1] ASI_DMMU
27 flush %g6 23 flush %g6
28 retl 24 retl
29 nop 25 nop
30 26
31cplus_wfinsn_1:
32 sethi %uhi(CTX_CHEETAH_PLUS_NUC), %l1
33cplus_wfinsn_2:
34 sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
35
36 .align 32 27 .align 32
37 28
38 /* Here are the rules, pay attention. 29 /* Here are the rules, pay attention.
@@ -395,23 +386,3 @@ window_dax_from_user_common:
395 add %sp, PTREGS_OFF, %o0 386 add %sp, PTREGS_OFF, %o0
396 ba,pt %xcc, rtrap 387 ba,pt %xcc, rtrap
397 clr %l6 388 clr %l6
398
399
400 .globl cheetah_plus_patch_winfixup
401cheetah_plus_patch_winfixup:
402 sethi %hi(cplus_wfinsn_1), %o0
403 sethi %hi(cplus_winfixup_insn_1), %o2
404 lduw [%o0 + %lo(cplus_wfinsn_1)], %o1
405 or %o2, %lo(cplus_winfixup_insn_1), %o2
406 stw %o1, [%o2]
407 flush %o2
408
409 sethi %hi(cplus_wfinsn_2), %o0
410 sethi %hi(cplus_winfixup_insn_2), %o2
411 lduw [%o0 + %lo(cplus_wfinsn_2)], %o1
412 or %o2, %lo(cplus_winfixup_insn_2), %o2
413 stw %o1, [%o2]
414 flush %o2
415
416 retl
417 nop
diff --git a/arch/sparc64/lib/VISsave.S b/arch/sparc64/lib/VISsave.S
index 4e18989bd602..a0ded5c5aa5c 100644
--- a/arch/sparc64/lib/VISsave.S
+++ b/arch/sparc64/lib/VISsave.S
@@ -59,15 +59,17 @@ vis1: ldub [%g6 + TI_FPSAVED], %g3
59 be,pn %icc, 9b 59 be,pn %icc, 9b
60 add %g6, TI_FPREGS, %g2 60 add %g6, TI_FPREGS, %g2
61 andcc %o5, FPRS_DL, %g0 61 andcc %o5, FPRS_DL, %g0
62 membar #StoreStore | #LoadStore
63 62
64 be,pn %icc, 4f 63 be,pn %icc, 4f
65 add %g6, TI_FPREGS+0x40, %g3 64 add %g6, TI_FPREGS+0x40, %g3
65 membar #Sync
66 stda %f0, [%g2 + %g1] ASI_BLK_P 66 stda %f0, [%g2 + %g1] ASI_BLK_P
67 stda %f16, [%g3 + %g1] ASI_BLK_P 67 stda %f16, [%g3 + %g1] ASI_BLK_P
68 membar #Sync
68 andcc %o5, FPRS_DU, %g0 69 andcc %o5, FPRS_DU, %g0
69 be,pn %icc, 5f 70 be,pn %icc, 5f
704: add %g1, 128, %g1 714: add %g1, 128, %g1
72 membar #Sync
71 stda %f32, [%g2 + %g1] ASI_BLK_P 73 stda %f32, [%g2 + %g1] ASI_BLK_P
72 74
73 stda %f48, [%g3 + %g1] ASI_BLK_P 75 stda %f48, [%g3 + %g1] ASI_BLK_P
@@ -87,7 +89,7 @@ vis1: ldub [%g6 + TI_FPSAVED], %g3
87 sll %g1, 5, %g1 89 sll %g1, 5, %g1
88 add %g6, TI_FPREGS+0xc0, %g3 90 add %g6, TI_FPREGS+0xc0, %g3
89 wr %g0, FPRS_FEF, %fprs 91 wr %g0, FPRS_FEF, %fprs
90 membar #StoreStore | #LoadStore 92 membar #Sync
91 stda %f32, [%g2 + %g1] ASI_BLK_P 93 stda %f32, [%g2 + %g1] ASI_BLK_P
92 stda %f48, [%g3 + %g1] ASI_BLK_P 94 stda %f48, [%g3 + %g1] ASI_BLK_P
93 membar #Sync 95 membar #Sync
@@ -128,8 +130,8 @@ VISenterhalf:
128 be,pn %icc, 4f 130 be,pn %icc, 4f
129 add %g6, TI_FPREGS, %g2 131 add %g6, TI_FPREGS, %g2
130 132
131 membar #StoreStore | #LoadStore
132 add %g6, TI_FPREGS+0x40, %g3 133 add %g6, TI_FPREGS+0x40, %g3
134 membar #Sync
133 stda %f0, [%g2 + %g1] ASI_BLK_P 135 stda %f0, [%g2 + %g1] ASI_BLK_P
134 stda %f16, [%g3 + %g1] ASI_BLK_P 136 stda %f16, [%g3 + %g1] ASI_BLK_P
135 membar #Sync 137 membar #Sync
diff --git a/arch/sparc64/lib/strncpy_from_user.S b/arch/sparc64/lib/strncpy_from_user.S
index 09cbbaa0ebf4..e1264650ca7a 100644
--- a/arch/sparc64/lib/strncpy_from_user.S
+++ b/arch/sparc64/lib/strncpy_from_user.S
@@ -125,15 +125,11 @@ __strncpy_from_user:
125 add %o2, %o3, %o0 125 add %o2, %o3, %o0
126 .size __strncpy_from_user, .-__strncpy_from_user 126 .size __strncpy_from_user, .-__strncpy_from_user
127 127
128 .section .fixup,#alloc,#execinstr
129 .align 4
1304: retl
131 mov -EFAULT, %o0
132
133 .section __ex_table,#alloc 128 .section __ex_table,#alloc
134 .align 4 129 .align 4
135 .word 60b, 4b 130 .word 60b, __retl_efault
136 .word 61b, 4b 131 .word 61b, __retl_efault
137 .word 62b, 4b 132 .word 62b, __retl_efault
138 .word 63b, 4b 133 .word 63b, __retl_efault
139 .word 64b, 4b 134 .word 64b, __retl_efault
135 .previous
diff --git a/arch/sparc64/lib/user_fixup.c b/arch/sparc64/lib/user_fixup.c
index 0278e34125db..19d1fdb17d0e 100644
--- a/arch/sparc64/lib/user_fixup.c
+++ b/arch/sparc64/lib/user_fixup.c
@@ -11,61 +11,56 @@
11 11
12/* Calculating the exact fault address when using 12/* Calculating the exact fault address when using
13 * block loads and stores can be very complicated. 13 * block loads and stores can be very complicated.
14 *
14 * Instead of trying to be clever and handling all 15 * Instead of trying to be clever and handling all
15 * of the cases, just fix things up simply here. 16 * of the cases, just fix things up simply here.
16 */ 17 */
17 18
18unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size) 19static unsigned long compute_size(unsigned long start, unsigned long size, unsigned long *offset)
19{ 20{
20 char *dst = to; 21 unsigned long fault_addr = current_thread_info()->fault_address;
21 const char __user *src = from; 22 unsigned long end = start + size;
22 23
23 while (size) { 24 if (fault_addr < start || fault_addr >= end) {
24 if (__get_user(*dst, src)) 25 *offset = 0;
25 break; 26 } else {
26 dst++; 27 *offset = start - fault_addr;
27 src++; 28 size = end - fault_addr;
28 size--;
29 } 29 }
30 return size;
31}
30 32
31 if (size) 33unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size)
32 memset(dst, 0, size); 34{
35 unsigned long offset;
36
37 size = compute_size((unsigned long) from, size, &offset);
38 if (likely(size))
39 memset(to + offset, 0, size);
33 40
34 return size; 41 return size;
35} 42}
36 43
37unsigned long copy_to_user_fixup(void __user *to, const void *from, unsigned long size) 44unsigned long copy_to_user_fixup(void __user *to, const void *from, unsigned long size)
38{ 45{
39 char __user *dst = to; 46 unsigned long offset;
40 const char *src = from;
41
42 while (size) {
43 if (__put_user(*src, dst))
44 break;
45 dst++;
46 src++;
47 size--;
48 }
49 47
50 return size; 48 return compute_size((unsigned long) to, size, &offset);
51} 49}
52 50
53unsigned long copy_in_user_fixup(void __user *to, void __user *from, unsigned long size) 51unsigned long copy_in_user_fixup(void __user *to, void __user *from, unsigned long size)
54{ 52{
55 char __user *dst = to; 53 unsigned long fault_addr = current_thread_info()->fault_address;
56 char __user *src = from; 54 unsigned long start = (unsigned long) to;
55 unsigned long end = start + size;
57 56
58 while (size) { 57 if (fault_addr >= start && fault_addr < end)
59 char tmp; 58 return end - fault_addr;
60 59
61 if (__get_user(tmp, src)) 60 start = (unsigned long) from;
62 break; 61 end = start + size;
63 if (__put_user(tmp, dst)) 62 if (fault_addr >= start && fault_addr < end)
64 break; 63 return end - fault_addr;
65 dst++;
66 src++;
67 size--;
68 }
69 64
70 return size; 65 return size;
71} 66}
diff --git a/arch/sparc64/mm/Makefile b/arch/sparc64/mm/Makefile
index cda87333a77b..9d0960e69f48 100644
--- a/arch/sparc64/mm/Makefile
+++ b/arch/sparc64/mm/Makefile
@@ -5,6 +5,6 @@
5EXTRA_AFLAGS := -ansi 5EXTRA_AFLAGS := -ansi
6EXTRA_CFLAGS := -Werror 6EXTRA_CFLAGS := -Werror
7 7
8obj-y := ultra.o tlb.o fault.o init.o generic.o extable.o 8obj-y := ultra.o tlb.o fault.o init.o generic.o
9 9
10obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 10obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/sparc64/mm/extable.c b/arch/sparc64/mm/extable.c
deleted file mode 100644
index ec334297ff4f..000000000000
--- a/arch/sparc64/mm/extable.c
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * linux/arch/sparc64/mm/extable.c
3 */
4
5#include <linux/config.h>
6#include <linux/module.h>
7#include <asm/uaccess.h>
8
9extern const struct exception_table_entry __start___ex_table[];
10extern const struct exception_table_entry __stop___ex_table[];
11
12void sort_extable(struct exception_table_entry *start,
13 struct exception_table_entry *finish)
14{
15}
16
17/* Caller knows they are in a range if ret->fixup == 0 */
18const struct exception_table_entry *
19search_extable(const struct exception_table_entry *start,
20 const struct exception_table_entry *last,
21 unsigned long value)
22{
23 const struct exception_table_entry *walk;
24
25 /* Single insn entries are encoded as:
26 * word 1: insn address
27 * word 2: fixup code address
28 *
29 * Range entries are encoded as:
30 * word 1: first insn address
31 * word 2: 0
32 * word 3: last insn address + 4 bytes
33 * word 4: fixup code address
34 *
35 * See asm/uaccess.h for more details.
36 */
37
38 /* 1. Try to find an exact match. */
39 for (walk = start; walk <= last; walk++) {
40 if (walk->fixup == 0) {
41 /* A range entry, skip both parts. */
42 walk++;
43 continue;
44 }
45
46 if (walk->insn == value)
47 return walk;
48 }
49
50 /* 2. Try to find a range match. */
51 for (walk = start; walk <= (last - 1); walk++) {
52 if (walk->fixup)
53 continue;
54
55 if (walk[0].insn <= value && walk[1].insn > value)
56 return walk;
57
58 walk++;
59 }
60
61 return NULL;
62}
63
64/* Special extable search, which handles ranges. Returns fixup */
65unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
66{
67 const struct exception_table_entry *entry;
68
69 entry = search_exception_tables(addr);
70 if (!entry)
71 return 0;
72
73 /* Inside range? Fix g2 and return correct fixup */
74 if (!entry->fixup) {
75 *g2 = (addr - entry->insn) / 4;
76 return (entry + 1)->fixup;
77 }
78
79 return entry->fixup;
80}
diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
index db1e3310e907..31fbc67719a1 100644
--- a/arch/sparc64/mm/fault.c
+++ b/arch/sparc64/mm/fault.c
@@ -32,8 +32,6 @@
32 32
33#define ELEMENTS(arr) (sizeof (arr)/sizeof (arr[0])) 33#define ELEMENTS(arr) (sizeof (arr)/sizeof (arr[0]))
34 34
35extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
36
37/* 35/*
38 * To debug kernel to catch accesses to certain virtual/physical addresses. 36 * To debug kernel to catch accesses to certain virtual/physical addresses.
39 * Mode = 0 selects physical watchpoints, mode = 1 selects virtual watchpoints. 37 * Mode = 0 selects physical watchpoints, mode = 1 selects virtual watchpoints.
@@ -71,53 +69,6 @@ void set_brkpt(unsigned long addr, unsigned char mask, int flags, int mode)
71 : "memory"); 69 : "memory");
72} 70}
73 71
74/* Nice, simple, prom library does all the sweating for us. ;) */
75unsigned long __init prom_probe_memory (void)
76{
77 register struct linux_mlist_p1275 *mlist;
78 register unsigned long bytes, base_paddr, tally;
79 register int i;
80
81 i = 0;
82 mlist = *prom_meminfo()->p1275_available;
83 bytes = tally = mlist->num_bytes;
84 base_paddr = mlist->start_adr;
85
86 sp_banks[0].base_addr = base_paddr;
87 sp_banks[0].num_bytes = bytes;
88
89 while (mlist->theres_more != (void *) 0) {
90 i++;
91 mlist = mlist->theres_more;
92 bytes = mlist->num_bytes;
93 tally += bytes;
94 if (i >= SPARC_PHYS_BANKS-1) {
95 printk ("The machine has more banks than "
96 "this kernel can support\n"
97 "Increase the SPARC_PHYS_BANKS "
98 "setting (currently %d)\n",
99 SPARC_PHYS_BANKS);
100 i = SPARC_PHYS_BANKS-1;
101 break;
102 }
103
104 sp_banks[i].base_addr = mlist->start_adr;
105 sp_banks[i].num_bytes = mlist->num_bytes;
106 }
107
108 i++;
109 sp_banks[i].base_addr = 0xdeadbeefbeefdeadUL;
110 sp_banks[i].num_bytes = 0;
111
112 /* Now mask all bank sizes on a page boundary, it is all we can
113 * use anyways.
114 */
115 for (i = 0; sp_banks[i].num_bytes != 0; i++)
116 sp_banks[i].num_bytes &= PAGE_MASK;
117
118 return tally;
119}
120
121static void __kprobes unhandled_fault(unsigned long address, 72static void __kprobes unhandled_fault(unsigned long address,
122 struct task_struct *tsk, 73 struct task_struct *tsk,
123 struct pt_regs *regs) 74 struct pt_regs *regs)
@@ -242,7 +193,6 @@ static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn)
242static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code, 193static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
243 unsigned int insn, unsigned long address) 194 unsigned int insn, unsigned long address)
244{ 195{
245 unsigned long g2;
246 unsigned char asi = ASI_P; 196 unsigned char asi = ASI_P;
247 197
248 if ((!insn) && (regs->tstate & TSTATE_PRIV)) 198 if ((!insn) && (regs->tstate & TSTATE_PRIV))
@@ -273,11 +223,9 @@ static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
273 } 223 }
274 } 224 }
275 225
276 g2 = regs->u_regs[UREG_G2];
277
278 /* Is this in ex_table? */ 226 /* Is this in ex_table? */
279 if (regs->tstate & TSTATE_PRIV) { 227 if (regs->tstate & TSTATE_PRIV) {
280 unsigned long fixup; 228 const struct exception_table_entry *entry;
281 229
282 if (asi == ASI_P && (insn & 0xc0800000) == 0xc0800000) { 230 if (asi == ASI_P && (insn & 0xc0800000) == 0xc0800000) {
283 if (insn & 0x2000) 231 if (insn & 0x2000)
@@ -288,10 +236,9 @@ static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
288 236
289 /* Look in asi.h: All _S asis have LS bit set */ 237 /* Look in asi.h: All _S asis have LS bit set */
290 if ((asi & 0x1) && 238 if ((asi & 0x1) &&
291 (fixup = search_extables_range(regs->tpc, &g2))) { 239 (entry = search_exception_tables(regs->tpc))) {
292 regs->tpc = fixup; 240 regs->tpc = entry->fixup;
293 regs->tnpc = regs->tpc + 4; 241 regs->tnpc = regs->tpc + 4;
294 regs->u_regs[UREG_G2] = g2;
295 return; 242 return;
296 } 243 }
297 } else { 244 } else {
@@ -461,7 +408,7 @@ good_area:
461 } 408 }
462 409
463 up_read(&mm->mmap_sem); 410 up_read(&mm->mmap_sem);
464 goto fault_done; 411 return;
465 412
466 /* 413 /*
467 * Something tried to access memory that isn't in our memory map.. 414 * Something tried to access memory that isn't in our memory map..
@@ -473,8 +420,7 @@ bad_area:
473 420
474handle_kernel_fault: 421handle_kernel_fault:
475 do_kernel_fault(regs, si_code, fault_code, insn, address); 422 do_kernel_fault(regs, si_code, fault_code, insn, address);
476 423 return;
477 goto fault_done;
478 424
479/* 425/*
480 * We ran out of memory, or some other thing happened to us that made 426 * We ran out of memory, or some other thing happened to us that made
@@ -505,9 +451,4 @@ do_sigbus:
505 /* Kernel mode? Handle exceptions or die */ 451 /* Kernel mode? Handle exceptions or die */
506 if (regs->tstate & TSTATE_PRIV) 452 if (regs->tstate & TSTATE_PRIV)
507 goto handle_kernel_fault; 453 goto handle_kernel_fault;
508
509fault_done:
510 /* These values are no longer needed, clear them. */
511 set_thread_fault_code(0);
512 current_thread_info()->fault_address = 0;
513} 454}
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index fdb1ebb308c9..1e44ee26cee8 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -20,6 +20,8 @@
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/kprobes.h> 22#include <linux/kprobes.h>
23#include <linux/cache.h>
24#include <linux/sort.h>
23 25
24#include <asm/head.h> 26#include <asm/head.h>
25#include <asm/system.h> 27#include <asm/system.h>
@@ -40,24 +42,80 @@
40 42
41extern void device_scan(void); 43extern void device_scan(void);
42 44
43struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS]; 45#define MAX_BANKS 32
44 46
45unsigned long *sparc64_valid_addr_bitmap; 47static struct linux_prom64_registers pavail[MAX_BANKS] __initdata;
48static struct linux_prom64_registers pavail_rescan[MAX_BANKS] __initdata;
49static int pavail_ents __initdata;
50static int pavail_rescan_ents __initdata;
51
52static int cmp_p64(const void *a, const void *b)
53{
54 const struct linux_prom64_registers *x = a, *y = b;
55
56 if (x->phys_addr > y->phys_addr)
57 return 1;
58 if (x->phys_addr < y->phys_addr)
59 return -1;
60 return 0;
61}
62
63static void __init read_obp_memory(const char *property,
64 struct linux_prom64_registers *regs,
65 int *num_ents)
66{
67 int node = prom_finddevice("/memory");
68 int prop_size = prom_getproplen(node, property);
69 int ents, ret, i;
70
71 ents = prop_size / sizeof(struct linux_prom64_registers);
72 if (ents > MAX_BANKS) {
73 prom_printf("The machine has more %s property entries than "
74 "this kernel can support (%d).\n",
75 property, MAX_BANKS);
76 prom_halt();
77 }
78
79 ret = prom_getproperty(node, property, (char *) regs, prop_size);
80 if (ret == -1) {
81 prom_printf("Couldn't get %s property from /memory.\n");
82 prom_halt();
83 }
84
85 *num_ents = ents;
86
87 /* Sanitize what we got from the firmware, by page aligning
88 * everything.
89 */
90 for (i = 0; i < ents; i++) {
91 unsigned long base, size;
92
93 base = regs[i].phys_addr;
94 size = regs[i].reg_size;
95
96 size &= PAGE_MASK;
97 if (base & ~PAGE_MASK) {
98 unsigned long new_base = PAGE_ALIGN(base);
99
100 size -= new_base - base;
101 if ((long) size < 0L)
102 size = 0UL;
103 base = new_base;
104 }
105 regs[i].phys_addr = base;
106 regs[i].reg_size = size;
107 }
108 sort(regs, ents, sizeof(struct linux_prom64_registers),
109 cmp_p64, NULL);
110}
111
112unsigned long *sparc64_valid_addr_bitmap __read_mostly;
46 113
47/* Ugly, but necessary... -DaveM */ 114/* Ugly, but necessary... -DaveM */
48unsigned long phys_base; 115unsigned long phys_base __read_mostly;
49unsigned long kern_base; 116unsigned long kern_base __read_mostly;
50unsigned long kern_size; 117unsigned long kern_size __read_mostly;
51unsigned long pfn_base; 118unsigned long pfn_base __read_mostly;
52
53/* This is even uglier. We have a problem where the kernel may not be
54 * located at phys_base. However, initial __alloc_bootmem() calls need to
55 * be adjusted to be within the 4-8Megs that the kernel is mapped to, else
56 * those page mappings wont work. Things are ok after inherit_prom_mappings
57 * is called though. Dave says he'll clean this up some other time.
58 * -- BenC
59 */
60static unsigned long bootmap_base;
61 119
62/* get_new_mmu_context() uses "cache + 1". */ 120/* get_new_mmu_context() uses "cache + 1". */
63DEFINE_SPINLOCK(ctx_alloc_lock); 121DEFINE_SPINLOCK(ctx_alloc_lock);
@@ -73,7 +131,13 @@ extern unsigned long sparc_ramdisk_image64;
73extern unsigned int sparc_ramdisk_image; 131extern unsigned int sparc_ramdisk_image;
74extern unsigned int sparc_ramdisk_size; 132extern unsigned int sparc_ramdisk_size;
75 133
76struct page *mem_map_zero; 134struct page *mem_map_zero __read_mostly;
135
136unsigned int sparc64_highest_unlocked_tlb_ent __read_mostly;
137
138unsigned long sparc64_kern_pri_context __read_mostly;
139unsigned long sparc64_kern_pri_nuc_bits __read_mostly;
140unsigned long sparc64_kern_sec_context __read_mostly;
77 141
78int bigkernel = 0; 142int bigkernel = 0;
79 143
@@ -179,8 +243,6 @@ static __inline__ void clear_dcache_dirty_cpu(struct page *page, unsigned long c
179 : "g1", "g7"); 243 : "g1", "g7");
180} 244}
181 245
182extern void __update_mmu_cache(unsigned long mmu_context_hw, unsigned long address, pte_t pte, int code);
183
184void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte) 246void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte)
185{ 247{
186 struct page *page; 248 struct page *page;
@@ -207,10 +269,6 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t p
207 269
208 put_cpu(); 270 put_cpu();
209 } 271 }
210
211 if (get_thread_fault_code())
212 __update_mmu_cache(CTX_NRBITS(vma->vm_mm->context),
213 address, pte, get_thread_fault_code());
214} 272}
215 273
216void flush_dcache_page(struct page *page) 274void flush_dcache_page(struct page *page)
@@ -310,6 +368,11 @@ struct linux_prom_translation {
310 unsigned long data; 368 unsigned long data;
311}; 369};
312 370
371/* Exported for kernel TLB miss handling in ktlb.S */
372struct linux_prom_translation prom_trans[512] __read_mostly;
373unsigned int prom_trans_ents __read_mostly;
374unsigned int swapper_pgd_zero __read_mostly;
375
313extern unsigned long prom_boot_page; 376extern unsigned long prom_boot_page;
314extern void prom_remap(unsigned long physpage, unsigned long virtpage, int mmu_ihandle); 377extern void prom_remap(unsigned long physpage, unsigned long virtpage, int mmu_ihandle);
315extern int prom_get_mmu_ihandle(void); 378extern int prom_get_mmu_ihandle(void);
@@ -318,297 +381,162 @@ extern void register_prom_callbacks(void);
318/* Exported for SMP bootup purposes. */ 381/* Exported for SMP bootup purposes. */
319unsigned long kern_locked_tte_data; 382unsigned long kern_locked_tte_data;
320 383
321void __init early_pgtable_allocfail(char *type)
322{
323 prom_printf("inherit_prom_mappings: Cannot alloc kernel %s.\n", type);
324 prom_halt();
325}
326
327#define BASE_PAGE_SIZE 8192
328static pmd_t *prompmd;
329
330/* 384/*
331 * Translate PROM's mapping we capture at boot time into physical address. 385 * Translate PROM's mapping we capture at boot time into physical address.
332 * The second parameter is only set from prom_callback() invocations. 386 * The second parameter is only set from prom_callback() invocations.
333 */ 387 */
334unsigned long prom_virt_to_phys(unsigned long promva, int *error) 388unsigned long prom_virt_to_phys(unsigned long promva, int *error)
335{ 389{
336 pmd_t *pmdp = prompmd + ((promva >> 23) & 0x7ff); 390 int i;
337 pte_t *ptep; 391
338 unsigned long base; 392 for (i = 0; i < prom_trans_ents; i++) {
339 393 struct linux_prom_translation *p = &prom_trans[i];
340 if (pmd_none(*pmdp)) { 394
341 if (error) 395 if (promva >= p->virt &&
342 *error = 1; 396 promva < (p->virt + p->size)) {
343 return(0); 397 unsigned long base = p->data & _PAGE_PADDR;
344 } 398
345 ptep = (pte_t *)__pmd_page(*pmdp) + ((promva >> 13) & 0x3ff); 399 if (error)
346 if (!pte_present(*ptep)) { 400 *error = 0;
347 if (error) 401 return base + (promva & (8192 - 1));
348 *error = 1; 402 }
349 return(0);
350 }
351 if (error) {
352 *error = 0;
353 return(pte_val(*ptep));
354 } 403 }
355 base = pte_val(*ptep) & _PAGE_PADDR; 404 if (error)
356 return(base + (promva & (BASE_PAGE_SIZE - 1))); 405 *error = 1;
406 return 0UL;
357} 407}
358 408
359static void inherit_prom_mappings(void) 409/* The obp translations are saved based on 8k pagesize, since obp can
410 * use a mixture of pagesizes. Misses to the LOW_OBP_ADDRESS ->
411 * HI_OBP_ADDRESS range are handled in ktlb.S and do not use the vpte
412 * scheme (also, see rant in inherit_locked_prom_mappings()).
413 */
414static inline int in_obp_range(unsigned long vaddr)
360{ 415{
361 struct linux_prom_translation *trans; 416 return (vaddr >= LOW_OBP_ADDRESS &&
362 unsigned long phys_page, tte_vaddr, tte_data; 417 vaddr < HI_OBP_ADDRESS);
363 void (*remap_func)(unsigned long, unsigned long, int); 418}
364 pmd_t *pmdp; 419
365 pte_t *ptep; 420static int cmp_ptrans(const void *a, const void *b)
366 int node, n, i, tsz; 421{
367 extern unsigned int obp_iaddr_patch[2], obp_daddr_patch[2]; 422 const struct linux_prom_translation *x = a, *y = b;
423
424 if (x->virt > y->virt)
425 return 1;
426 if (x->virt < y->virt)
427 return -1;
428 return 0;
429}
430
431/* Read OBP translations property into 'prom_trans[]'. */
432static void __init read_obp_translations(void)
433{
434 int n, node, ents, first, last, i;
368 435
369 node = prom_finddevice("/virtual-memory"); 436 node = prom_finddevice("/virtual-memory");
370 n = prom_getproplen(node, "translations"); 437 n = prom_getproplen(node, "translations");
371 if (n == 0 || n == -1) { 438 if (unlikely(n == 0 || n == -1)) {
372 prom_printf("Couldn't get translation property\n"); 439 prom_printf("prom_mappings: Couldn't get size.\n");
373 prom_halt(); 440 prom_halt();
374 } 441 }
375 n += 5 * sizeof(struct linux_prom_translation); 442 if (unlikely(n > sizeof(prom_trans))) {
376 for (tsz = 1; tsz < n; tsz <<= 1) 443 prom_printf("prom_mappings: Size %Zd is too big.\n", n);
377 /* empty */;
378 trans = __alloc_bootmem(tsz, SMP_CACHE_BYTES, bootmap_base);
379 if (trans == NULL) {
380 prom_printf("inherit_prom_mappings: Cannot alloc translations.\n");
381 prom_halt(); 444 prom_halt();
382 } 445 }
383 memset(trans, 0, tsz);
384 446
385 if ((n = prom_getproperty(node, "translations", (char *)trans, tsz)) == -1) { 447 if ((n = prom_getproperty(node, "translations",
386 prom_printf("Couldn't get translation property\n"); 448 (char *)&prom_trans[0],
449 sizeof(prom_trans))) == -1) {
450 prom_printf("prom_mappings: Couldn't get property.\n");
387 prom_halt(); 451 prom_halt();
388 } 452 }
389 n = n / sizeof(*trans);
390 453
391 /* 454 n = n / sizeof(struct linux_prom_translation);
392 * The obp translations are saved based on 8k pagesize, since obp can
393 * use a mixture of pagesizes. Misses to the 0xf0000000 - 0x100000000,
394 * ie obp range, are handled in entry.S and do not use the vpte scheme
395 * (see rant in inherit_locked_prom_mappings()).
396 */
397#define OBP_PMD_SIZE 2048
398 prompmd = __alloc_bootmem(OBP_PMD_SIZE, OBP_PMD_SIZE, bootmap_base);
399 if (prompmd == NULL)
400 early_pgtable_allocfail("pmd");
401 memset(prompmd, 0, OBP_PMD_SIZE);
402 for (i = 0; i < n; i++) {
403 unsigned long vaddr;
404
405 if (trans[i].virt >= LOW_OBP_ADDRESS && trans[i].virt < HI_OBP_ADDRESS) {
406 for (vaddr = trans[i].virt;
407 ((vaddr < trans[i].virt + trans[i].size) &&
408 (vaddr < HI_OBP_ADDRESS));
409 vaddr += BASE_PAGE_SIZE) {
410 unsigned long val;
411
412 pmdp = prompmd + ((vaddr >> 23) & 0x7ff);
413 if (pmd_none(*pmdp)) {
414 ptep = __alloc_bootmem(BASE_PAGE_SIZE,
415 BASE_PAGE_SIZE,
416 bootmap_base);
417 if (ptep == NULL)
418 early_pgtable_allocfail("pte");
419 memset(ptep, 0, BASE_PAGE_SIZE);
420 pmd_set(pmdp, ptep);
421 }
422 ptep = (pte_t *)__pmd_page(*pmdp) +
423 ((vaddr >> 13) & 0x3ff);
424 455
425 val = trans[i].data; 456 ents = n;
426 457
427 /* Clear diag TTE bits. */ 458 sort(prom_trans, ents, sizeof(struct linux_prom_translation),
428 if (tlb_type == spitfire) 459 cmp_ptrans, NULL);
429 val &= ~0x0003fe0000000000UL;
430 460
431 set_pte_at(&init_mm, vaddr, 461 /* Now kick out all the non-OBP entries. */
432 ptep, __pte(val | _PAGE_MODIFIED)); 462 for (i = 0; i < ents; i++) {
433 trans[i].data += BASE_PAGE_SIZE; 463 if (in_obp_range(prom_trans[i].virt))
434 } 464 break;
435 } 465 }
466 first = i;
467 for (; i < ents; i++) {
468 if (!in_obp_range(prom_trans[i].virt))
469 break;
436 } 470 }
437 phys_page = __pa(prompmd); 471 last = i;
438 obp_iaddr_patch[0] |= (phys_page >> 10);
439 obp_iaddr_patch[1] |= (phys_page & 0x3ff);
440 flushi((long)&obp_iaddr_patch[0]);
441 obp_daddr_patch[0] |= (phys_page >> 10);
442 obp_daddr_patch[1] |= (phys_page & 0x3ff);
443 flushi((long)&obp_daddr_patch[0]);
444 472
445 /* Now fixup OBP's idea about where we really are mapped. */ 473 for (i = 0; i < (last - first); i++) {
446 prom_printf("Remapping the kernel... "); 474 struct linux_prom_translation *src = &prom_trans[i + first];
475 struct linux_prom_translation *dest = &prom_trans[i];
447 476
448 /* Spitfire Errata #32 workaround */ 477 *dest = *src;
449 /* NOTE: Using plain zero for the context value is 478 }
450 * correct here, we are not using the Linux trap 479 for (; i < ents; i++) {
451 * tables yet so we should not use the special 480 struct linux_prom_translation *dest = &prom_trans[i];
452 * UltraSPARC-III+ page size encodings yet. 481 dest->virt = dest->size = dest->data = 0x0UL;
453 */ 482 }
454 __asm__ __volatile__("stxa %0, [%1] %2\n\t" 483
455 "flush %%g6" 484 prom_trans_ents = last - first;
456 : /* No outputs */
457 : "r" (0), "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU));
458
459 switch (tlb_type) {
460 default:
461 case spitfire:
462 phys_page = spitfire_get_dtlb_data(sparc64_highest_locked_tlbent());
463 break;
464
465 case cheetah:
466 case cheetah_plus:
467 phys_page = cheetah_get_litlb_data(sparc64_highest_locked_tlbent());
468 break;
469 };
470
471 phys_page &= _PAGE_PADDR;
472 phys_page += ((unsigned long)&prom_boot_page -
473 (unsigned long)KERNBASE);
474 485
475 if (tlb_type == spitfire) { 486 if (tlb_type == spitfire) {
476 /* Lock this into i/d tlb entry 59 */ 487 /* Clear diag TTE bits. */
477 __asm__ __volatile__( 488 for (i = 0; i < prom_trans_ents; i++)
478 "stxa %%g0, [%2] %3\n\t" 489 prom_trans[i].data &= ~0x0003fe0000000000UL;
479 "stxa %0, [%1] %4\n\t"
480 "membar #Sync\n\t"
481 "flush %%g6\n\t"
482 "stxa %%g0, [%2] %5\n\t"
483 "stxa %0, [%1] %6\n\t"
484 "membar #Sync\n\t"
485 "flush %%g6"
486 : : "r" (phys_page | _PAGE_VALID | _PAGE_SZ8K | _PAGE_CP |
487 _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W),
488 "r" (59 << 3), "r" (TLB_TAG_ACCESS),
489 "i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS),
490 "i" (ASI_IMMU), "i" (ASI_ITLB_DATA_ACCESS)
491 : "memory");
492 } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {
493 /* Lock this into i/d tlb-0 entry 11 */
494 __asm__ __volatile__(
495 "stxa %%g0, [%2] %3\n\t"
496 "stxa %0, [%1] %4\n\t"
497 "membar #Sync\n\t"
498 "flush %%g6\n\t"
499 "stxa %%g0, [%2] %5\n\t"
500 "stxa %0, [%1] %6\n\t"
501 "membar #Sync\n\t"
502 "flush %%g6"
503 : : "r" (phys_page | _PAGE_VALID | _PAGE_SZ8K | _PAGE_CP |
504 _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W),
505 "r" ((0 << 16) | (11 << 3)), "r" (TLB_TAG_ACCESS),
506 "i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS),
507 "i" (ASI_IMMU), "i" (ASI_ITLB_DATA_ACCESS)
508 : "memory");
509 } else {
510 /* Implement me :-) */
511 BUG();
512 } 490 }
491}
513 492
514 tte_vaddr = (unsigned long) KERNBASE; 493static void __init remap_kernel(void)
494{
495 unsigned long phys_page, tte_vaddr, tte_data;
496 int tlb_ent = sparc64_highest_locked_tlbent();
515 497
516 /* Spitfire Errata #32 workaround */ 498 tte_vaddr = (unsigned long) KERNBASE;
517 /* NOTE: Using plain zero for the context value is 499 phys_page = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
518 * correct here, we are not using the Linux trap 500 tte_data = (phys_page | (_PAGE_VALID | _PAGE_SZ4MB |
519 * tables yet so we should not use the special 501 _PAGE_CP | _PAGE_CV | _PAGE_P |
520 * UltraSPARC-III+ page size encodings yet. 502 _PAGE_L | _PAGE_W));
521 */
522 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
523 "flush %%g6"
524 : /* No outputs */
525 : "r" (0),
526 "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU));
527
528 if (tlb_type == spitfire)
529 tte_data = spitfire_get_dtlb_data(sparc64_highest_locked_tlbent());
530 else
531 tte_data = cheetah_get_ldtlb_data(sparc64_highest_locked_tlbent());
532 503
533 kern_locked_tte_data = tte_data; 504 kern_locked_tte_data = tte_data;
534 505
535 remap_func = (void *) ((unsigned long) &prom_remap - 506 /* Now lock us into the TLBs via OBP. */
536 (unsigned long) &prom_boot_page); 507 prom_dtlb_load(tlb_ent, tte_data, tte_vaddr);
537 508 prom_itlb_load(tlb_ent, tte_data, tte_vaddr);
538
539 /* Spitfire Errata #32 workaround */
540 /* NOTE: Using plain zero for the context value is
541 * correct here, we are not using the Linux trap
542 * tables yet so we should not use the special
543 * UltraSPARC-III+ page size encodings yet.
544 */
545 __asm__ __volatile__("stxa %0, [%1] %2\n\t"
546 "flush %%g6"
547 : /* No outputs */
548 : "r" (0),
549 "r" (PRIMARY_CONTEXT), "i" (ASI_DMMU));
550
551 remap_func((tlb_type == spitfire ?
552 (spitfire_get_dtlb_data(sparc64_highest_locked_tlbent()) & _PAGE_PADDR) :
553 (cheetah_get_litlb_data(sparc64_highest_locked_tlbent()) & _PAGE_PADDR)),
554 (unsigned long) KERNBASE,
555 prom_get_mmu_ihandle());
556
557 if (bigkernel)
558 remap_func(((tte_data + 0x400000) & _PAGE_PADDR),
559 (unsigned long) KERNBASE + 0x400000, prom_get_mmu_ihandle());
560
561 /* Flush out that temporary mapping. */
562 spitfire_flush_dtlb_nucleus_page(0x0);
563 spitfire_flush_itlb_nucleus_page(0x0);
564
565 /* Now lock us back into the TLBs via OBP. */
566 prom_dtlb_load(sparc64_highest_locked_tlbent(), tte_data, tte_vaddr);
567 prom_itlb_load(sparc64_highest_locked_tlbent(), tte_data, tte_vaddr);
568 if (bigkernel) { 509 if (bigkernel) {
569 prom_dtlb_load(sparc64_highest_locked_tlbent()-1, tte_data + 0x400000, 510 tlb_ent -= 1;
570 tte_vaddr + 0x400000); 511 prom_dtlb_load(tlb_ent,
571 prom_itlb_load(sparc64_highest_locked_tlbent()-1, tte_data + 0x400000, 512 tte_data + 0x400000,
572 tte_vaddr + 0x400000); 513 tte_vaddr + 0x400000);
514 prom_itlb_load(tlb_ent,
515 tte_data + 0x400000,
516 tte_vaddr + 0x400000);
573 } 517 }
574 518 sparc64_highest_unlocked_tlb_ent = tlb_ent - 1;
575 /* Re-read translations property. */ 519 if (tlb_type == cheetah_plus) {
576 if ((n = prom_getproperty(node, "translations", (char *)trans, tsz)) == -1) { 520 sparc64_kern_pri_context = (CTX_CHEETAH_PLUS_CTX0 |
577 prom_printf("Couldn't get translation property\n"); 521 CTX_CHEETAH_PLUS_NUC);
578 prom_halt(); 522 sparc64_kern_pri_nuc_bits = CTX_CHEETAH_PLUS_NUC;
523 sparc64_kern_sec_context = CTX_CHEETAH_PLUS_CTX0;
579 } 524 }
580 n = n / sizeof(*trans); 525}
581
582 for (i = 0; i < n; i++) {
583 unsigned long vaddr = trans[i].virt;
584 unsigned long size = trans[i].size;
585
586 if (vaddr < 0xf0000000UL) {
587 unsigned long avoid_start = (unsigned long) KERNBASE;
588 unsigned long avoid_end = avoid_start + (4 * 1024 * 1024);
589
590 if (bigkernel)
591 avoid_end += (4 * 1024 * 1024);
592 if (vaddr < avoid_start) {
593 unsigned long top = vaddr + size;
594 526
595 if (top > avoid_start)
596 top = avoid_start;
597 prom_unmap(top - vaddr, vaddr);
598 }
599 if ((vaddr + size) > avoid_end) {
600 unsigned long bottom = vaddr;
601 527
602 if (bottom < avoid_end) 528static void __init inherit_prom_mappings(void)
603 bottom = avoid_end; 529{
604 prom_unmap((vaddr + size) - bottom, bottom); 530 read_obp_translations();
605 }
606 }
607 }
608 531
532 /* Now fixup OBP's idea about where we really are mapped. */
533 prom_printf("Remapping the kernel... ");
534 remap_kernel();
609 prom_printf("done.\n"); 535 prom_printf("done.\n");
610 536
537 prom_printf("Registering callbacks... ");
611 register_prom_callbacks(); 538 register_prom_callbacks();
539 prom_printf("done.\n");
612} 540}
613 541
614/* The OBP specifications for sun4u mark 0xfffffffc00000000 and 542/* The OBP specifications for sun4u mark 0xfffffffc00000000 and
@@ -792,8 +720,8 @@ void inherit_locked_prom_mappings(int save_p)
792 } 720 }
793 } 721 }
794 if (tlb_type == spitfire) { 722 if (tlb_type == spitfire) {
795 int high = SPITFIRE_HIGHEST_LOCKED_TLBENT - bigkernel; 723 int high = sparc64_highest_unlocked_tlb_ent;
796 for (i = 0; i < high; i++) { 724 for (i = 0; i <= high; i++) {
797 unsigned long data; 725 unsigned long data;
798 726
799 /* Spitfire Errata #32 workaround */ 727 /* Spitfire Errata #32 workaround */
@@ -881,9 +809,9 @@ void inherit_locked_prom_mappings(int save_p)
881 } 809 }
882 } 810 }
883 } else if (tlb_type == cheetah || tlb_type == cheetah_plus) { 811 } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {
884 int high = CHEETAH_HIGHEST_LOCKED_TLBENT - bigkernel; 812 int high = sparc64_highest_unlocked_tlb_ent;
885 813
886 for (i = 0; i < high; i++) { 814 for (i = 0; i <= high; i++) {
887 unsigned long data; 815 unsigned long data;
888 816
889 data = cheetah_get_ldtlb_data(i); 817 data = cheetah_get_ldtlb_data(i);
@@ -1276,14 +1204,14 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
1276 int i; 1204 int i;
1277 1205
1278#ifdef CONFIG_DEBUG_BOOTMEM 1206#ifdef CONFIG_DEBUG_BOOTMEM
1279 prom_printf("bootmem_init: Scan sp_banks, "); 1207 prom_printf("bootmem_init: Scan pavail, ");
1280#endif 1208#endif
1281 1209
1282 bytes_avail = 0UL; 1210 bytes_avail = 0UL;
1283 for (i = 0; sp_banks[i].num_bytes != 0; i++) { 1211 for (i = 0; i < pavail_ents; i++) {
1284 end_of_phys_memory = sp_banks[i].base_addr + 1212 end_of_phys_memory = pavail[i].phys_addr +
1285 sp_banks[i].num_bytes; 1213 pavail[i].reg_size;
1286 bytes_avail += sp_banks[i].num_bytes; 1214 bytes_avail += pavail[i].reg_size;
1287 if (cmdline_memory_size) { 1215 if (cmdline_memory_size) {
1288 if (bytes_avail > cmdline_memory_size) { 1216 if (bytes_avail > cmdline_memory_size) {
1289 unsigned long slack = bytes_avail - cmdline_memory_size; 1217 unsigned long slack = bytes_avail - cmdline_memory_size;
@@ -1291,12 +1219,15 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
1291 bytes_avail -= slack; 1219 bytes_avail -= slack;
1292 end_of_phys_memory -= slack; 1220 end_of_phys_memory -= slack;
1293 1221
1294 sp_banks[i].num_bytes -= slack; 1222 pavail[i].reg_size -= slack;
1295 if (sp_banks[i].num_bytes == 0) { 1223 if ((long)pavail[i].reg_size <= 0L) {
1296 sp_banks[i].base_addr = 0xdeadbeef; 1224 pavail[i].phys_addr = 0xdeadbeefUL;
1225 pavail[i].reg_size = 0UL;
1226 pavail_ents = i;
1297 } else { 1227 } else {
1298 sp_banks[i+1].num_bytes = 0; 1228 pavail[i+1].reg_size = 0Ul;
1299 sp_banks[i+1].base_addr = 0xdeadbeef; 1229 pavail[i+1].phys_addr = 0xdeadbeefUL;
1230 pavail_ents = i + 1;
1300 } 1231 }
1301 break; 1232 break;
1302 } 1233 }
@@ -1347,17 +1278,15 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
1347#endif 1278#endif
1348 bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, pfn_base, end_pfn); 1279 bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap_pfn, pfn_base, end_pfn);
1349 1280
1350 bootmap_base = bootmap_pfn << PAGE_SHIFT;
1351
1352 /* Now register the available physical memory with the 1281 /* Now register the available physical memory with the
1353 * allocator. 1282 * allocator.
1354 */ 1283 */
1355 for (i = 0; sp_banks[i].num_bytes != 0; i++) { 1284 for (i = 0; i < pavail_ents; i++) {
1356#ifdef CONFIG_DEBUG_BOOTMEM 1285#ifdef CONFIG_DEBUG_BOOTMEM
1357 prom_printf("free_bootmem(sp_banks:%d): base[%lx] size[%lx]\n", 1286 prom_printf("free_bootmem(pavail:%d): base[%lx] size[%lx]\n",
1358 i, sp_banks[i].base_addr, sp_banks[i].num_bytes); 1287 i, pavail[i].phys_addr, pavail[i].reg_size);
1359#endif 1288#endif
1360 free_bootmem(sp_banks[i].base_addr, sp_banks[i].num_bytes); 1289 free_bootmem(pavail[i].phys_addr, pavail[i].reg_size);
1361 } 1290 }
1362 1291
1363#ifdef CONFIG_BLK_DEV_INITRD 1292#ifdef CONFIG_BLK_DEV_INITRD
@@ -1398,121 +1327,167 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
1398 return end_pfn; 1327 return end_pfn;
1399} 1328}
1400 1329
1330#ifdef CONFIG_DEBUG_PAGEALLOC
1331static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend, pgprot_t prot)
1332{
1333 unsigned long vstart = PAGE_OFFSET + pstart;
1334 unsigned long vend = PAGE_OFFSET + pend;
1335 unsigned long alloc_bytes = 0UL;
1336
1337 if ((vstart & ~PAGE_MASK) || (vend & ~PAGE_MASK)) {
1338 prom_printf("kernel_map: Unaligned physmem[%lx:%lx]\n",
1339 vstart, vend);
1340 prom_halt();
1341 }
1342
1343 while (vstart < vend) {
1344 unsigned long this_end, paddr = __pa(vstart);
1345 pgd_t *pgd = pgd_offset_k(vstart);
1346 pud_t *pud;
1347 pmd_t *pmd;
1348 pte_t *pte;
1349
1350 pud = pud_offset(pgd, vstart);
1351 if (pud_none(*pud)) {
1352 pmd_t *new;
1353
1354 new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
1355 alloc_bytes += PAGE_SIZE;
1356 pud_populate(&init_mm, pud, new);
1357 }
1358
1359 pmd = pmd_offset(pud, vstart);
1360 if (!pmd_present(*pmd)) {
1361 pte_t *new;
1362
1363 new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
1364 alloc_bytes += PAGE_SIZE;
1365 pmd_populate_kernel(&init_mm, pmd, new);
1366 }
1367
1368 pte = pte_offset_kernel(pmd, vstart);
1369 this_end = (vstart + PMD_SIZE) & PMD_MASK;
1370 if (this_end > vend)
1371 this_end = vend;
1372
1373 while (vstart < this_end) {
1374 pte_val(*pte) = (paddr | pgprot_val(prot));
1375
1376 vstart += PAGE_SIZE;
1377 paddr += PAGE_SIZE;
1378 pte++;
1379 }
1380 }
1381
1382 return alloc_bytes;
1383}
1384
1385static struct linux_prom64_registers pall[MAX_BANKS] __initdata;
1386static int pall_ents __initdata;
1387
1388extern unsigned int kvmap_linear_patch[1];
1389
1390static void __init kernel_physical_mapping_init(void)
1391{
1392 unsigned long i, mem_alloced = 0UL;
1393
1394 read_obp_memory("reg", &pall[0], &pall_ents);
1395
1396 for (i = 0; i < pall_ents; i++) {
1397 unsigned long phys_start, phys_end;
1398
1399 phys_start = pall[i].phys_addr;
1400 phys_end = phys_start + pall[i].reg_size;
1401 mem_alloced += kernel_map_range(phys_start, phys_end,
1402 PAGE_KERNEL);
1403 }
1404
1405 printk("Allocated %ld bytes for kernel page tables.\n",
1406 mem_alloced);
1407
1408 kvmap_linear_patch[0] = 0x01000000; /* nop */
1409 flushi(&kvmap_linear_patch[0]);
1410
1411 __flush_tlb_all();
1412}
1413
1414void kernel_map_pages(struct page *page, int numpages, int enable)
1415{
1416 unsigned long phys_start = page_to_pfn(page) << PAGE_SHIFT;
1417 unsigned long phys_end = phys_start + (numpages * PAGE_SIZE);
1418
1419 kernel_map_range(phys_start, phys_end,
1420 (enable ? PAGE_KERNEL : __pgprot(0)));
1421
1422 /* we should perform an IPI and flush all tlbs,
1423 * but that can deadlock->flush only current cpu.
1424 */
1425 __flush_tlb_kernel_range(PAGE_OFFSET + phys_start,
1426 PAGE_OFFSET + phys_end);
1427}
1428#endif
1429
1430unsigned long __init find_ecache_flush_span(unsigned long size)
1431{
1432 int i;
1433
1434 for (i = 0; i < pavail_ents; i++) {
1435 if (pavail[i].reg_size >= size)
1436 return pavail[i].phys_addr;
1437 }
1438
1439 return ~0UL;
1440}
1441
1401/* paging_init() sets up the page tables */ 1442/* paging_init() sets up the page tables */
1402 1443
1403extern void cheetah_ecache_flush_init(void); 1444extern void cheetah_ecache_flush_init(void);
1404 1445
1405static unsigned long last_valid_pfn; 1446static unsigned long last_valid_pfn;
1447pgd_t swapper_pg_dir[2048];
1406 1448
1407void __init paging_init(void) 1449void __init paging_init(void)
1408{ 1450{
1409 extern pmd_t swapper_pmd_dir[1024]; 1451 unsigned long end_pfn, pages_avail, shift;
1410 extern unsigned int sparc64_vpte_patchme1[1]; 1452 unsigned long real_end, i;
1411 extern unsigned int sparc64_vpte_patchme2[1]; 1453
1412 unsigned long alias_base = kern_base + PAGE_OFFSET; 1454 /* Find available physical memory... */
1413 unsigned long second_alias_page = 0; 1455 read_obp_memory("available", &pavail[0], &pavail_ents);
1414 unsigned long pt, flags, end_pfn, pages_avail; 1456
1415 unsigned long shift = alias_base - ((unsigned long)KERNBASE); 1457 phys_base = 0xffffffffffffffffUL;
1416 unsigned long real_end; 1458 for (i = 0; i < pavail_ents; i++)
1459 phys_base = min(phys_base, pavail[i].phys_addr);
1460
1461 pfn_base = phys_base >> PAGE_SHIFT;
1462
1463 kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
1464 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
1417 1465
1418 set_bit(0, mmu_context_bmap); 1466 set_bit(0, mmu_context_bmap);
1419 1467
1468 shift = kern_base + PAGE_OFFSET - ((unsigned long)KERNBASE);
1469
1420 real_end = (unsigned long)_end; 1470 real_end = (unsigned long)_end;
1421 if ((real_end > ((unsigned long)KERNBASE + 0x400000))) 1471 if ((real_end > ((unsigned long)KERNBASE + 0x400000)))
1422 bigkernel = 1; 1472 bigkernel = 1;
1423#ifdef CONFIG_BLK_DEV_INITRD 1473 if ((real_end > ((unsigned long)KERNBASE + 0x800000))) {
1424 if (sparc_ramdisk_image || sparc_ramdisk_image64) 1474 prom_printf("paging_init: Kernel > 8MB, too large.\n");
1425 real_end = (PAGE_ALIGN(real_end) + PAGE_ALIGN(sparc_ramdisk_size)); 1475 prom_halt();
1426#endif
1427
1428 /* We assume physical memory starts at some 4mb multiple,
1429 * if this were not true we wouldn't boot up to this point
1430 * anyways.
1431 */
1432 pt = kern_base | _PAGE_VALID | _PAGE_SZ4MB;
1433 pt |= _PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W;
1434 local_irq_save(flags);
1435 if (tlb_type == spitfire) {
1436 __asm__ __volatile__(
1437 " stxa %1, [%0] %3\n"
1438 " stxa %2, [%5] %4\n"
1439 " membar #Sync\n"
1440 " flush %%g6\n"
1441 " nop\n"
1442 " nop\n"
1443 " nop\n"
1444 : /* No outputs */
1445 : "r" (TLB_TAG_ACCESS), "r" (alias_base), "r" (pt),
1446 "i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS), "r" (61 << 3)
1447 : "memory");
1448 if (real_end >= KERNBASE + 0x340000) {
1449 second_alias_page = alias_base + 0x400000;
1450 __asm__ __volatile__(
1451 " stxa %1, [%0] %3\n"
1452 " stxa %2, [%5] %4\n"
1453 " membar #Sync\n"
1454 " flush %%g6\n"
1455 " nop\n"
1456 " nop\n"
1457 " nop\n"
1458 : /* No outputs */
1459 : "r" (TLB_TAG_ACCESS), "r" (second_alias_page), "r" (pt + 0x400000),
1460 "i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS), "r" (60 << 3)
1461 : "memory");
1462 }
1463 } else if (tlb_type == cheetah || tlb_type == cheetah_plus) {
1464 __asm__ __volatile__(
1465 " stxa %1, [%0] %3\n"
1466 " stxa %2, [%5] %4\n"
1467 " membar #Sync\n"
1468 " flush %%g6\n"
1469 " nop\n"
1470 " nop\n"
1471 " nop\n"
1472 : /* No outputs */
1473 : "r" (TLB_TAG_ACCESS), "r" (alias_base), "r" (pt),
1474 "i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS), "r" ((0<<16) | (13<<3))
1475 : "memory");
1476 if (real_end >= KERNBASE + 0x340000) {
1477 second_alias_page = alias_base + 0x400000;
1478 __asm__ __volatile__(
1479 " stxa %1, [%0] %3\n"
1480 " stxa %2, [%5] %4\n"
1481 " membar #Sync\n"
1482 " flush %%g6\n"
1483 " nop\n"
1484 " nop\n"
1485 " nop\n"
1486 : /* No outputs */
1487 : "r" (TLB_TAG_ACCESS), "r" (second_alias_page), "r" (pt + 0x400000),
1488 "i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS), "r" ((0<<16) | (12<<3))
1489 : "memory");
1490 }
1491 } 1476 }
1492 local_irq_restore(flags); 1477
1493 1478 /* Set kernel pgd to upper alias so physical page computations
1494 /* Now set kernel pgd to upper alias so physical page computations
1495 * work. 1479 * work.
1496 */ 1480 */
1497 init_mm.pgd += ((shift) / (sizeof(pgd_t))); 1481 init_mm.pgd += ((shift) / (sizeof(pgd_t)));
1498 1482
1499 memset(swapper_pmd_dir, 0, sizeof(swapper_pmd_dir)); 1483 memset(swapper_low_pmd_dir, 0, sizeof(swapper_low_pmd_dir));
1500 1484
1501 /* Now can init the kernel/bad page tables. */ 1485 /* Now can init the kernel/bad page tables. */
1502 pud_set(pud_offset(&swapper_pg_dir[0], 0), 1486 pud_set(pud_offset(&swapper_pg_dir[0], 0),
1503 swapper_pmd_dir + (shift / sizeof(pgd_t))); 1487 swapper_low_pmd_dir + (shift / sizeof(pgd_t)));
1504 1488
1505 sparc64_vpte_patchme1[0] |= 1489 swapper_pgd_zero = pgd_val(swapper_pg_dir[0]);
1506 (((unsigned long)pgd_val(init_mm.pgd[0])) >> 10);
1507 sparc64_vpte_patchme2[0] |=
1508 (((unsigned long)pgd_val(init_mm.pgd[0])) & 0x3ff);
1509 flushi((long)&sparc64_vpte_patchme1[0]);
1510 1490
1511 /* Setup bootmem... */
1512 pages_avail = 0;
1513 last_valid_pfn = end_pfn = bootmem_init(&pages_avail);
1514
1515 /* Inherit non-locked OBP mappings. */
1516 inherit_prom_mappings(); 1491 inherit_prom_mappings();
1517 1492
1518 /* Ok, we can use our TLB miss and window trap handlers safely. 1493 /* Ok, we can use our TLB miss and window trap handlers safely.
@@ -1527,13 +1502,16 @@ void __init paging_init(void)
1527 1502
1528 inherit_locked_prom_mappings(1); 1503 inherit_locked_prom_mappings(1);
1529 1504
1530 /* We only created DTLB mapping of this stuff. */
1531 spitfire_flush_dtlb_nucleus_page(alias_base);
1532 if (second_alias_page)
1533 spitfire_flush_dtlb_nucleus_page(second_alias_page);
1534
1535 __flush_tlb_all(); 1505 __flush_tlb_all();
1536 1506
1507 /* Setup bootmem... */
1508 pages_avail = 0;
1509 last_valid_pfn = end_pfn = bootmem_init(&pages_avail);
1510
1511#ifdef CONFIG_DEBUG_PAGEALLOC
1512 kernel_physical_mapping_init();
1513#endif
1514
1537 { 1515 {
1538 unsigned long zones_size[MAX_NR_ZONES]; 1516 unsigned long zones_size[MAX_NR_ZONES];
1539 unsigned long zholes_size[MAX_NR_ZONES]; 1517 unsigned long zholes_size[MAX_NR_ZONES];
@@ -1554,128 +1532,35 @@ void __init paging_init(void)
1554 device_scan(); 1532 device_scan();
1555} 1533}
1556 1534
1557/* Ok, it seems that the prom can allocate some more memory chunks
1558 * as a side effect of some prom calls we perform during the
1559 * boot sequence. My most likely theory is that it is from the
1560 * prom_set_traptable() call, and OBP is allocating a scratchpad
1561 * for saving client program register state etc.
1562 */
1563static void __init sort_memlist(struct linux_mlist_p1275 *thislist)
1564{
1565 int swapi = 0;
1566 int i, mitr;
1567 unsigned long tmpaddr, tmpsize;
1568 unsigned long lowest;
1569
1570 for (i = 0; thislist[i].theres_more != 0; i++) {
1571 lowest = thislist[i].start_adr;
1572 for (mitr = i+1; thislist[mitr-1].theres_more != 0; mitr++)
1573 if (thislist[mitr].start_adr < lowest) {
1574 lowest = thislist[mitr].start_adr;
1575 swapi = mitr;
1576 }
1577 if (lowest == thislist[i].start_adr)
1578 continue;
1579 tmpaddr = thislist[swapi].start_adr;
1580 tmpsize = thislist[swapi].num_bytes;
1581 for (mitr = swapi; mitr > i; mitr--) {
1582 thislist[mitr].start_adr = thislist[mitr-1].start_adr;
1583 thislist[mitr].num_bytes = thislist[mitr-1].num_bytes;
1584 }
1585 thislist[i].start_adr = tmpaddr;
1586 thislist[i].num_bytes = tmpsize;
1587 }
1588}
1589
1590void __init rescan_sp_banks(void)
1591{
1592 struct linux_prom64_registers memlist[64];
1593 struct linux_mlist_p1275 avail[64], *mlist;
1594 unsigned long bytes, base_paddr;
1595 int num_regs, node = prom_finddevice("/memory");
1596 int i;
1597
1598 num_regs = prom_getproperty(node, "available",
1599 (char *) memlist, sizeof(memlist));
1600 num_regs = (num_regs / sizeof(struct linux_prom64_registers));
1601 for (i = 0; i < num_regs; i++) {
1602 avail[i].start_adr = memlist[i].phys_addr;
1603 avail[i].num_bytes = memlist[i].reg_size;
1604 avail[i].theres_more = &avail[i + 1];
1605 }
1606 avail[i - 1].theres_more = NULL;
1607 sort_memlist(avail);
1608
1609 mlist = &avail[0];
1610 i = 0;
1611 bytes = mlist->num_bytes;
1612 base_paddr = mlist->start_adr;
1613
1614 sp_banks[0].base_addr = base_paddr;
1615 sp_banks[0].num_bytes = bytes;
1616
1617 while (mlist->theres_more != NULL){
1618 i++;
1619 mlist = mlist->theres_more;
1620 bytes = mlist->num_bytes;
1621 if (i >= SPARC_PHYS_BANKS-1) {
1622 printk ("The machine has more banks than "
1623 "this kernel can support\n"
1624 "Increase the SPARC_PHYS_BANKS "
1625 "setting (currently %d)\n",
1626 SPARC_PHYS_BANKS);
1627 i = SPARC_PHYS_BANKS-1;
1628 break;
1629 }
1630
1631 sp_banks[i].base_addr = mlist->start_adr;
1632 sp_banks[i].num_bytes = mlist->num_bytes;
1633 }
1634
1635 i++;
1636 sp_banks[i].base_addr = 0xdeadbeefbeefdeadUL;
1637 sp_banks[i].num_bytes = 0;
1638
1639 for (i = 0; sp_banks[i].num_bytes != 0; i++)
1640 sp_banks[i].num_bytes &= PAGE_MASK;
1641}
1642
1643static void __init taint_real_pages(void) 1535static void __init taint_real_pages(void)
1644{ 1536{
1645 struct sparc_phys_banks saved_sp_banks[SPARC_PHYS_BANKS];
1646 int i; 1537 int i;
1647 1538
1648 for (i = 0; i < SPARC_PHYS_BANKS; i++) { 1539 read_obp_memory("available", &pavail_rescan[0], &pavail_rescan_ents);
1649 saved_sp_banks[i].base_addr =
1650 sp_banks[i].base_addr;
1651 saved_sp_banks[i].num_bytes =
1652 sp_banks[i].num_bytes;
1653 }
1654
1655 rescan_sp_banks();
1656 1540
1657 /* Find changes discovered in the sp_bank rescan and 1541 /* Find changes discovered in the physmem available rescan and
1658 * reserve the lost portions in the bootmem maps. 1542 * reserve the lost portions in the bootmem maps.
1659 */ 1543 */
1660 for (i = 0; saved_sp_banks[i].num_bytes; i++) { 1544 for (i = 0; i < pavail_ents; i++) {
1661 unsigned long old_start, old_end; 1545 unsigned long old_start, old_end;
1662 1546
1663 old_start = saved_sp_banks[i].base_addr; 1547 old_start = pavail[i].phys_addr;
1664 old_end = old_start + 1548 old_end = old_start +
1665 saved_sp_banks[i].num_bytes; 1549 pavail[i].reg_size;
1666 while (old_start < old_end) { 1550 while (old_start < old_end) {
1667 int n; 1551 int n;
1668 1552
1669 for (n = 0; sp_banks[n].num_bytes; n++) { 1553 for (n = 0; pavail_rescan_ents; n++) {
1670 unsigned long new_start, new_end; 1554 unsigned long new_start, new_end;
1671 1555
1672 new_start = sp_banks[n].base_addr; 1556 new_start = pavail_rescan[n].phys_addr;
1673 new_end = new_start + sp_banks[n].num_bytes; 1557 new_end = new_start +
1558 pavail_rescan[n].reg_size;
1674 1559
1675 if (new_start <= old_start && 1560 if (new_start <= old_start &&
1676 new_end >= (old_start + PAGE_SIZE)) { 1561 new_end >= (old_start + PAGE_SIZE)) {
1677 set_bit (old_start >> 22, 1562 set_bit(old_start >> 22,
1678 sparc64_valid_addr_bitmap); 1563 sparc64_valid_addr_bitmap);
1679 goto do_next_page; 1564 goto do_next_page;
1680 } 1565 }
1681 } 1566 }
@@ -1695,8 +1580,7 @@ void __init mem_init(void)
1695 1580
1696 i = last_valid_pfn >> ((22 - PAGE_SHIFT) + 6); 1581 i = last_valid_pfn >> ((22 - PAGE_SHIFT) + 6);
1697 i += 1; 1582 i += 1;
1698 sparc64_valid_addr_bitmap = (unsigned long *) 1583 sparc64_valid_addr_bitmap = (unsigned long *) alloc_bootmem(i << 3);
1699 __alloc_bootmem(i << 3, SMP_CACHE_BYTES, bootmap_base);
1700 if (sparc64_valid_addr_bitmap == NULL) { 1584 if (sparc64_valid_addr_bitmap == NULL) {
1701 prom_printf("mem_init: Cannot alloc valid_addr_bitmap.\n"); 1585 prom_printf("mem_init: Cannot alloc valid_addr_bitmap.\n");
1702 prom_halt(); 1586 prom_halt();
@@ -1749,7 +1633,7 @@ void __init mem_init(void)
1749 cheetah_ecache_flush_init(); 1633 cheetah_ecache_flush_init();
1750} 1634}
1751 1635
1752void free_initmem (void) 1636void free_initmem(void)
1753{ 1637{
1754 unsigned long addr, initend; 1638 unsigned long addr, initend;
1755 1639
diff --git a/arch/sparc64/mm/ultra.S b/arch/sparc64/mm/ultra.S
index b2ee9b53227f..e4c9151fa116 100644
--- a/arch/sparc64/mm/ultra.S
+++ b/arch/sparc64/mm/ultra.S
@@ -144,42 +144,29 @@ __flush_icache_page: /* %o0 = phys_page */
144 144
145#define DTAG_MASK 0x3 145#define DTAG_MASK 0x3
146 146
147 /* This routine is Spitfire specific so the hardcoded
148 * D-cache size and line-size are OK.
149 */
147 .align 64 150 .align 64
148 .globl __flush_dcache_page 151 .globl __flush_dcache_page
149__flush_dcache_page: /* %o0=kaddr, %o1=flush_icache */ 152__flush_dcache_page: /* %o0=kaddr, %o1=flush_icache */
150 sethi %uhi(PAGE_OFFSET), %g1 153 sethi %uhi(PAGE_OFFSET), %g1
151 sllx %g1, 32, %g1 154 sllx %g1, 32, %g1
152 sub %o0, %g1, %o0 155 sub %o0, %g1, %o0 ! physical address
153 clr %o4 156 srlx %o0, 11, %o0 ! make D-cache TAG
154 srlx %o0, 11, %o0 157 sethi %hi(1 << 14), %o2 ! D-cache size
155 sethi %hi(1 << 14), %o2 158 sub %o2, (1 << 5), %o2 ! D-cache line size
1561: ldxa [%o4] ASI_DCACHE_TAG, %o3 ! LSU Group 1591: ldxa [%o2] ASI_DCACHE_TAG, %o3 ! load D-cache TAG
157 add %o4, (1 << 5), %o4 ! IEU0 160 andcc %o3, DTAG_MASK, %g0 ! Valid?
158 ldxa [%o4] ASI_DCACHE_TAG, %g1 ! LSU Group 161 be,pn %xcc, 2f ! Nope, branch
159 add %o4, (1 << 5), %o4 ! IEU0 162 andn %o3, DTAG_MASK, %o3 ! Clear valid bits
160 ldxa [%o4] ASI_DCACHE_TAG, %g2 ! LSU Group o3 available 163 cmp %o3, %o0 ! TAG match?
161 add %o4, (1 << 5), %o4 ! IEU0 164 bne,pt %xcc, 2f ! Nope, branch
162 andn %o3, DTAG_MASK, %o3 ! IEU1 165 nop
163 ldxa [%o4] ASI_DCACHE_TAG, %g3 ! LSU Group 166 stxa %g0, [%o2] ASI_DCACHE_TAG ! Invalidate TAG
164 add %o4, (1 << 5), %o4 ! IEU0 167 membar #Sync
165 andn %g1, DTAG_MASK, %g1 ! IEU1 1682: brnz,pt %o2, 1b
166 cmp %o0, %o3 ! IEU1 Group 169 sub %o2, (1 << 5), %o2 ! D-cache line size
167 be,a,pn %xcc, dflush1 ! CTI
168 sub %o4, (4 << 5), %o4 ! IEU0 (Group)
169 cmp %o0, %g1 ! IEU1 Group
170 andn %g2, DTAG_MASK, %g2 ! IEU0
171 be,a,pn %xcc, dflush2 ! CTI
172 sub %o4, (3 << 5), %o4 ! IEU0 (Group)
173 cmp %o0, %g2 ! IEU1 Group
174 andn %g3, DTAG_MASK, %g3 ! IEU0
175 be,a,pn %xcc, dflush3 ! CTI
176 sub %o4, (2 << 5), %o4 ! IEU0 (Group)
177 cmp %o0, %g3 ! IEU1 Group
178 be,a,pn %xcc, dflush4 ! CTI
179 sub %o4, (1 << 5), %o4 ! IEU0
1802: cmp %o4, %o2 ! IEU1 Group
181 bne,pt %xcc, 1b ! CTI
182 nop ! IEU0
183 170
184 /* The I-cache does not snoop local stores so we 171 /* The I-cache does not snoop local stores so we
185 * better flush that too when necessary. 172 * better flush that too when necessary.
@@ -189,48 +176,9 @@ __flush_dcache_page: /* %o0=kaddr, %o1=flush_icache */
189 retl 176 retl
190 nop 177 nop
191 178
192dflush1:stxa %g0, [%o4] ASI_DCACHE_TAG
193 add %o4, (1 << 5), %o4
194dflush2:stxa %g0, [%o4] ASI_DCACHE_TAG
195 add %o4, (1 << 5), %o4
196dflush3:stxa %g0, [%o4] ASI_DCACHE_TAG
197 add %o4, (1 << 5), %o4
198dflush4:stxa %g0, [%o4] ASI_DCACHE_TAG
199 add %o4, (1 << 5), %o4
200 membar #Sync
201 ba,pt %xcc, 2b
202 nop
203#endif /* DCACHE_ALIASING_POSSIBLE */ 179#endif /* DCACHE_ALIASING_POSSIBLE */
204 180
205 .previous .text 181 .previous
206 .align 32
207__prefill_dtlb:
208 rdpr %pstate, %g7
209 wrpr %g7, PSTATE_IE, %pstate
210 mov TLB_TAG_ACCESS, %g1
211 stxa %o5, [%g1] ASI_DMMU
212 stxa %o2, [%g0] ASI_DTLB_DATA_IN
213 flush %g6
214 retl
215 wrpr %g7, %pstate
216__prefill_itlb:
217 rdpr %pstate, %g7
218 wrpr %g7, PSTATE_IE, %pstate
219 mov TLB_TAG_ACCESS, %g1
220 stxa %o5, [%g1] ASI_IMMU
221 stxa %o2, [%g0] ASI_ITLB_DATA_IN
222 flush %g6
223 retl
224 wrpr %g7, %pstate
225
226 .globl __update_mmu_cache
227__update_mmu_cache: /* %o0=hw_context, %o1=address, %o2=pte, %o3=fault_code */
228 srlx %o1, PAGE_SHIFT, %o1
229 andcc %o3, FAULT_CODE_DTLB, %g0
230 sllx %o1, PAGE_SHIFT, %o5
231 bne,pt %xcc, __prefill_dtlb
232 or %o5, %o0, %o5
233 ba,a,pt %xcc, __prefill_itlb
234 182
235 /* Cheetah specific versions, patched at boot time. */ 183 /* Cheetah specific versions, patched at boot time. */
236__cheetah_flush_tlb_mm: /* 18 insns */ 184__cheetah_flush_tlb_mm: /* 18 insns */
@@ -283,7 +231,7 @@ __cheetah_flush_tlb_pending: /* 26 insns */
283 wrpr %g7, 0x0, %pstate 231 wrpr %g7, 0x0, %pstate
284 232
285#ifdef DCACHE_ALIASING_POSSIBLE 233#ifdef DCACHE_ALIASING_POSSIBLE
286flush_dcpage_cheetah: /* 11 insns */ 234__cheetah_flush_dcache_page: /* 11 insns */
287 sethi %uhi(PAGE_OFFSET), %g1 235 sethi %uhi(PAGE_OFFSET), %g1
288 sllx %g1, 32, %g1 236 sllx %g1, 32, %g1
289 sub %o0, %g1, %o0 237 sub %o0, %g1, %o0
@@ -329,8 +277,8 @@ cheetah_patch_cachetlbops:
329#ifdef DCACHE_ALIASING_POSSIBLE 277#ifdef DCACHE_ALIASING_POSSIBLE
330 sethi %hi(__flush_dcache_page), %o0 278 sethi %hi(__flush_dcache_page), %o0
331 or %o0, %lo(__flush_dcache_page), %o0 279 or %o0, %lo(__flush_dcache_page), %o0
332 sethi %hi(flush_dcpage_cheetah), %o1 280 sethi %hi(__cheetah_flush_dcache_page), %o1
333 or %o1, %lo(flush_dcpage_cheetah), %o1 281 or %o1, %lo(__cheetah_flush_dcache_page), %o1
334 call cheetah_patch_one 282 call cheetah_patch_one
335 mov 11, %o2 283 mov 11, %o2
336#endif /* DCACHE_ALIASING_POSSIBLE */ 284#endif /* DCACHE_ALIASING_POSSIBLE */
@@ -505,22 +453,6 @@ xcall_flush_dcache_page_spitfire: /* %g1 == physical page address
505 nop 453 nop
506 nop 454 nop
507 455
508 .globl xcall_promstop
509xcall_promstop:
510 rdpr %pstate, %g2
511 wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
512 rdpr %pil, %g2
513 wrpr %g0, 15, %pil
514 sethi %hi(109f), %g7
515 b,pt %xcc, etrap_irq
516109: or %g7, %lo(109b), %g7
517 flushw
518 call prom_stopself
519 nop
520 /* We should not return, just spin if we do... */
5211: b,a,pt %xcc, 1b
522 nop
523
524 .data 456 .data
525 457
526errata32_hwbug: 458errata32_hwbug:
diff --git a/arch/sparc64/prom/Makefile b/arch/sparc64/prom/Makefile
index 8f2420d9e9e6..3d33ed27bc27 100644
--- a/arch/sparc64/prom/Makefile
+++ b/arch/sparc64/prom/Makefile
@@ -6,5 +6,5 @@
6EXTRA_AFLAGS := -ansi 6EXTRA_AFLAGS := -ansi
7EXTRA_CFLAGS := -Werror 7EXTRA_CFLAGS := -Werror
8 8
9lib-y := bootstr.o devops.o init.o memory.o misc.o \ 9lib-y := bootstr.o devops.o init.o misc.o \
10 tree.o console.o printf.o p1275.o map.o cif.o 10 tree.o console.o printf.o p1275.o cif.o
diff --git a/arch/sparc64/prom/console.c b/arch/sparc64/prom/console.c
index 028a53fcb1ec..eae5db8dda56 100644
--- a/arch/sparc64/prom/console.c
+++ b/arch/sparc64/prom/console.c
@@ -67,7 +67,7 @@ prom_putchar(char c)
67} 67}
68 68
69void 69void
70prom_puts(char *s, int len) 70prom_puts(const char *s, int len)
71{ 71{
72 p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)| 72 p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
73 P1275_INOUT(3,1), 73 P1275_INOUT(3,1),
diff --git a/arch/sparc64/prom/devops.c b/arch/sparc64/prom/devops.c
index 2c99b21b6981..4641839eb39a 100644
--- a/arch/sparc64/prom/devops.c
+++ b/arch/sparc64/prom/devops.c
@@ -16,7 +16,7 @@
16 * Returns 0 on failure. 16 * Returns 0 on failure.
17 */ 17 */
18int 18int
19prom_devopen(char *dstr) 19prom_devopen(const char *dstr)
20{ 20{
21 return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)| 21 return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)|
22 P1275_INOUT(1,1), 22 P1275_INOUT(1,1),
diff --git a/arch/sparc64/prom/init.c b/arch/sparc64/prom/init.c
index 817faae058cd..f3cc2d8578b2 100644
--- a/arch/sparc64/prom/init.c
+++ b/arch/sparc64/prom/init.c
@@ -27,7 +27,6 @@ int prom_chosen_node;
27 * failure. It gets passed the pointer to the PROM vector. 27 * failure. It gets passed the pointer to the PROM vector.
28 */ 28 */
29 29
30extern void prom_meminit(void);
31extern void prom_cif_init(void *, void *); 30extern void prom_cif_init(void *, void *);
32 31
33void __init prom_init(void *cif_handler, void *cif_stack) 32void __init prom_init(void *cif_handler, void *cif_stack)
@@ -46,7 +45,7 @@ void __init prom_init(void *cif_handler, void *cif_stack)
46 if((prom_root_node == 0) || (prom_root_node == -1)) 45 if((prom_root_node == 0) || (prom_root_node == -1))
47 prom_halt(); 46 prom_halt();
48 47
49 prom_chosen_node = prom_finddevice("/chosen"); 48 prom_chosen_node = prom_finddevice(prom_chosen_path);
50 if (!prom_chosen_node || prom_chosen_node == -1) 49 if (!prom_chosen_node || prom_chosen_node == -1)
51 prom_halt(); 50 prom_halt();
52 51
@@ -90,8 +89,6 @@ void __init prom_init(void *cif_handler, void *cif_stack)
90 89
91 printk ("PROMLIB: Sun IEEE Boot Prom %s\n", buffer + bufadjust); 90 printk ("PROMLIB: Sun IEEE Boot Prom %s\n", buffer + bufadjust);
92 91
93 prom_meminit();
94
95 /* Initialization successful. */ 92 /* Initialization successful. */
96 return; 93 return;
97 94
diff --git a/arch/sparc64/prom/map.S b/arch/sparc64/prom/map.S
deleted file mode 100644
index 21b3f9c99ea7..000000000000
--- a/arch/sparc64/prom/map.S
+++ /dev/null
@@ -1,72 +0,0 @@
1/* $Id: map.S,v 1.2 1999/11/19 05:53:02 davem Exp $
2 * map.S: Tricky coding required to fixup the kernel OBP maps
3 * properly.
4 *
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
6 */
7
8 .text
9 .align 8192
10 .globl prom_boot_page
11prom_boot_page:
12call_method:
13 .asciz "call-method"
14 .align 8
15map:
16 .asciz "map"
17 .align 8
18
19 /* When we are invoked, our caller has remapped us to
20 * page zero, therefore we must use PC relative addressing
21 * for everything after we begin performing the unmap/map
22 * calls.
23 */
24 .globl prom_remap
25prom_remap: /* %o0 = physpage, %o1 = virtpage, %o2 = mmu_ihandle */
26 rd %pc, %g1
27 srl %o2, 0, %o2 ! kill sign extension
28 sethi %hi(p1275buf), %g2
29 or %g2, %lo(p1275buf), %g2
30 ldx [%g2 + 0x10], %g3 ! prom_cif_stack
31 save %g3, -(192 + 128), %sp
32 ldx [%g2 + 0x08], %l0 ! prom_cif_handler
33 mov %g6, %i3
34 mov %g4, %i4
35 mov %g5, %i5
36 flushw
37
38 sethi %hi(prom_remap - call_method), %g7
39 or %g7, %lo(prom_remap - call_method), %g7
40 sub %g1, %g7, %l2 ! call-method string
41 sethi %hi(prom_remap - map), %g7
42 or %g7, %lo(prom_remap - map), %g7
43 sub %g1, %g7, %l4 ! map string
44
45 /* OK, map the 4MB region we really live at. */
46 stx %l2, [%sp + 2047 + 128 + 0x00] ! call-method
47 mov 7, %l5
48 stx %l5, [%sp + 2047 + 128 + 0x08] ! num_args
49 mov 1, %l5
50 stx %l5, [%sp + 2047 + 128 + 0x10] ! num_rets
51 stx %l4, [%sp + 2047 + 128 + 0x18] ! map
52 stx %i2, [%sp + 2047 + 128 + 0x20] ! mmu_ihandle
53 mov -1, %l5
54 stx %l5, [%sp + 2047 + 128 + 0x28] ! mode == default
55 sethi %hi(4 * 1024 * 1024), %l5
56 stx %l5, [%sp + 2047 + 128 + 0x30] ! size
57 stx %i1, [%sp + 2047 + 128 + 0x38] ! vaddr
58 stx %g0, [%sp + 2047 + 128 + 0x40] ! filler
59 stx %i0, [%sp + 2047 + 128 + 0x48] ! paddr
60 call %l0
61 add %sp, (2047 + 128), %o0 ! argument array
62
63 /* Restore hard-coded globals. */
64 mov %i3, %g6
65 mov %i4, %g4
66 mov %i5, %g5
67
68 /* Wheee.... we are done. */
69 ret
70 restore
71
72 .align 8192
diff --git a/arch/sparc64/prom/memory.c b/arch/sparc64/prom/memory.c
deleted file mode 100644
index f4a8143e052c..000000000000
--- a/arch/sparc64/prom/memory.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/* $Id: memory.c,v 1.5 1999/08/31 06:55:04 davem Exp $
2 * memory.c: Prom routine for acquiring various bits of information
3 * about RAM on the machine, both virtual and physical.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 */
8
9#include <linux/kernel.h>
10#include <linux/init.h>
11
12#include <asm/openprom.h>
13#include <asm/oplib.h>
14
15/* This routine, for consistency, returns the ram parameters in the
16 * V0 prom memory descriptor format. I choose this format because I
17 * think it was the easiest to work with. I feel the religious
18 * arguments now... ;) Also, I return the linked lists sorted to
19 * prevent paging_init() upset stomach as I have not yet written
20 * the pepto-bismol kernel module yet.
21 */
22
23struct linux_prom64_registers prom_reg_memlist[64];
24struct linux_prom64_registers prom_reg_tmp[64];
25
26struct linux_mlist_p1275 prom_phys_total[64];
27struct linux_mlist_p1275 prom_prom_taken[64];
28struct linux_mlist_p1275 prom_phys_avail[64];
29
30struct linux_mlist_p1275 *prom_ptot_ptr = prom_phys_total;
31struct linux_mlist_p1275 *prom_ptak_ptr = prom_prom_taken;
32struct linux_mlist_p1275 *prom_pavl_ptr = prom_phys_avail;
33
34struct linux_mem_p1275 prom_memlist;
35
36
37/* Internal Prom library routine to sort a linux_mlist_p1275 memory
38 * list. Used below in initialization.
39 */
40static void __init
41prom_sortmemlist(struct linux_mlist_p1275 *thislist)
42{
43 int swapi = 0;
44 int i, mitr;
45 unsigned long tmpaddr, tmpsize;
46 unsigned long lowest;
47
48 for(i=0; thislist[i].theres_more; i++) {
49 lowest = thislist[i].start_adr;
50 for(mitr = i+1; thislist[mitr-1].theres_more; mitr++)
51 if(thislist[mitr].start_adr < lowest) {
52 lowest = thislist[mitr].start_adr;
53 swapi = mitr;
54 }
55 if(lowest == thislist[i].start_adr) continue;
56 tmpaddr = thislist[swapi].start_adr;
57 tmpsize = thislist[swapi].num_bytes;
58 for(mitr = swapi; mitr > i; mitr--) {
59 thislist[mitr].start_adr = thislist[mitr-1].start_adr;
60 thislist[mitr].num_bytes = thislist[mitr-1].num_bytes;
61 }
62 thislist[i].start_adr = tmpaddr;
63 thislist[i].num_bytes = tmpsize;
64 }
65}
66
67/* Initialize the memory lists based upon the prom version. */
68void __init prom_meminit(void)
69{
70 int node = 0;
71 unsigned int iter, num_regs;
72
73 node = prom_finddevice("/memory");
74 num_regs = prom_getproperty(node, "available",
75 (char *) prom_reg_memlist,
76 sizeof(prom_reg_memlist));
77 num_regs = (num_regs/sizeof(struct linux_prom64_registers));
78 for(iter=0; iter<num_regs; iter++) {
79 prom_phys_avail[iter].start_adr =
80 prom_reg_memlist[iter].phys_addr;
81 prom_phys_avail[iter].num_bytes =
82 prom_reg_memlist[iter].reg_size;
83 prom_phys_avail[iter].theres_more =
84 &prom_phys_avail[iter+1];
85 }
86 prom_phys_avail[iter-1].theres_more = NULL;
87
88 num_regs = prom_getproperty(node, "reg",
89 (char *) prom_reg_memlist,
90 sizeof(prom_reg_memlist));
91 num_regs = (num_regs/sizeof(struct linux_prom64_registers));
92 for(iter=0; iter<num_regs; iter++) {
93 prom_phys_total[iter].start_adr =
94 prom_reg_memlist[iter].phys_addr;
95 prom_phys_total[iter].num_bytes =
96 prom_reg_memlist[iter].reg_size;
97 prom_phys_total[iter].theres_more =
98 &prom_phys_total[iter+1];
99 }
100 prom_phys_total[iter-1].theres_more = NULL;
101
102 node = prom_finddevice("/virtual-memory");
103 num_regs = prom_getproperty(node, "available",
104 (char *) prom_reg_memlist,
105 sizeof(prom_reg_memlist));
106 num_regs = (num_regs/sizeof(struct linux_prom64_registers));
107
108 /* Convert available virtual areas to taken virtual
109 * areas. First sort, then convert.
110 */
111 for(iter=0; iter<num_regs; iter++) {
112 prom_prom_taken[iter].start_adr =
113 prom_reg_memlist[iter].phys_addr;
114 prom_prom_taken[iter].num_bytes =
115 prom_reg_memlist[iter].reg_size;
116 prom_prom_taken[iter].theres_more =
117 &prom_prom_taken[iter+1];
118 }
119 prom_prom_taken[iter-1].theres_more = NULL;
120
121 prom_sortmemlist(prom_prom_taken);
122
123 /* Finally, convert. */
124 for(iter=0; iter<num_regs; iter++) {
125 prom_prom_taken[iter].start_adr =
126 prom_prom_taken[iter].start_adr +
127 prom_prom_taken[iter].num_bytes;
128 prom_prom_taken[iter].num_bytes =
129 prom_prom_taken[iter+1].start_adr -
130 prom_prom_taken[iter].start_adr;
131 }
132 prom_prom_taken[iter-1].num_bytes =
133 -1UL - prom_prom_taken[iter-1].start_adr;
134
135 /* Sort the other two lists. */
136 prom_sortmemlist(prom_phys_total);
137 prom_sortmemlist(prom_phys_avail);
138
139 /* Link all the lists into the top-level descriptor. */
140 prom_memlist.p1275_totphys=&prom_ptot_ptr;
141 prom_memlist.p1275_prommap=&prom_ptak_ptr;
142 prom_memlist.p1275_available=&prom_pavl_ptr;
143}
144
145/* This returns a pointer to our libraries internal p1275 format
146 * memory descriptor.
147 */
148struct linux_mem_p1275 *
149prom_meminfo(void)
150{
151 return &prom_memlist;
152}
diff --git a/arch/sparc64/prom/misc.c b/arch/sparc64/prom/misc.c
index 19c44e97e9ee..87f5cfce23bb 100644
--- a/arch/sparc64/prom/misc.c
+++ b/arch/sparc64/prom/misc.c
@@ -17,14 +17,14 @@
17#include <asm/system.h> 17#include <asm/system.h>
18 18
19/* Reset and reboot the machine with the command 'bcommand'. */ 19/* Reset and reboot the machine with the command 'bcommand'. */
20void prom_reboot(char *bcommand) 20void prom_reboot(const char *bcommand)
21{ 21{
22 p1275_cmd("boot", P1275_ARG(0, P1275_ARG_IN_STRING) | 22 p1275_cmd("boot", P1275_ARG(0, P1275_ARG_IN_STRING) |
23 P1275_INOUT(1, 0), bcommand); 23 P1275_INOUT(1, 0), bcommand);
24} 24}
25 25
26/* Forth evaluate the expression contained in 'fstring'. */ 26/* Forth evaluate the expression contained in 'fstring'. */
27void prom_feval(char *fstring) 27void prom_feval(const char *fstring)
28{ 28{
29 if (!fstring || fstring[0] == 0) 29 if (!fstring || fstring[0] == 0)
30 return; 30 return;
@@ -68,19 +68,11 @@ void prom_cmdline(void)
68 local_irq_restore(flags); 68 local_irq_restore(flags);
69} 69}
70 70
71#ifdef CONFIG_SMP
72extern void smp_promstop_others(void);
73#endif
74
75/* Drop into the prom, but completely terminate the program. 71/* Drop into the prom, but completely terminate the program.
76 * No chance of continuing. 72 * No chance of continuing.
77 */ 73 */
78void prom_halt(void) 74void prom_halt(void)
79{ 75{
80#ifdef CONFIG_SMP
81 smp_promstop_others();
82 udelay(8000);
83#endif
84again: 76again:
85 p1275_cmd("exit", P1275_INOUT(0, 0)); 77 p1275_cmd("exit", P1275_INOUT(0, 0));
86 goto again; /* PROM is out to get me -DaveM */ 78 goto again; /* PROM is out to get me -DaveM */
@@ -88,10 +80,6 @@ again:
88 80
89void prom_halt_power_off(void) 81void prom_halt_power_off(void)
90{ 82{
91#ifdef CONFIG_SMP
92 smp_promstop_others();
93 udelay(8000);
94#endif
95 p1275_cmd("SUNW,power-off", P1275_INOUT(0, 0)); 83 p1275_cmd("SUNW,power-off", P1275_INOUT(0, 0));
96 84
97 /* if nothing else helps, we just halt */ 85 /* if nothing else helps, we just halt */
@@ -148,21 +136,19 @@ void prom_set_trap_table(unsigned long tba)
148 p1275_cmd("SUNW,set-trap-table", P1275_INOUT(1, 0), tba); 136 p1275_cmd("SUNW,set-trap-table", P1275_INOUT(1, 0), tba);
149} 137}
150 138
151int mmu_ihandle_cache = 0;
152
153int prom_get_mmu_ihandle(void) 139int prom_get_mmu_ihandle(void)
154{ 140{
155 int node, ret; 141 int node, ret;
156 142
157 if (mmu_ihandle_cache != 0) 143 if (prom_mmu_ihandle_cache != 0)
158 return mmu_ihandle_cache; 144 return prom_mmu_ihandle_cache;
159 145
160 node = prom_finddevice("/chosen"); 146 node = prom_finddevice(prom_chosen_path);
161 ret = prom_getint(node, "mmu"); 147 ret = prom_getint(node, prom_mmu_name);
162 if (ret == -1 || ret == 0) 148 if (ret == -1 || ret == 0)
163 mmu_ihandle_cache = -1; 149 prom_mmu_ihandle_cache = -1;
164 else 150 else
165 mmu_ihandle_cache = ret; 151 prom_mmu_ihandle_cache = ret;
166 152
167 return ret; 153 return ret;
168} 154}
@@ -190,7 +176,7 @@ long prom_itlb_load(unsigned long index,
190 unsigned long tte_data, 176 unsigned long tte_data,
191 unsigned long vaddr) 177 unsigned long vaddr)
192{ 178{
193 return p1275_cmd("call-method", 179 return p1275_cmd(prom_callmethod_name,
194 (P1275_ARG(0, P1275_ARG_IN_STRING) | 180 (P1275_ARG(0, P1275_ARG_IN_STRING) |
195 P1275_ARG(2, P1275_ARG_IN_64B) | 181 P1275_ARG(2, P1275_ARG_IN_64B) |
196 P1275_ARG(3, P1275_ARG_IN_64B) | 182 P1275_ARG(3, P1275_ARG_IN_64B) |
@@ -207,7 +193,7 @@ long prom_dtlb_load(unsigned long index,
207 unsigned long tte_data, 193 unsigned long tte_data,
208 unsigned long vaddr) 194 unsigned long vaddr)
209{ 195{
210 return p1275_cmd("call-method", 196 return p1275_cmd(prom_callmethod_name,
211 (P1275_ARG(0, P1275_ARG_IN_STRING) | 197 (P1275_ARG(0, P1275_ARG_IN_STRING) |
212 P1275_ARG(2, P1275_ARG_IN_64B) | 198 P1275_ARG(2, P1275_ARG_IN_64B) |
213 P1275_ARG(3, P1275_ARG_IN_64B) | 199 P1275_ARG(3, P1275_ARG_IN_64B) |
@@ -223,13 +209,13 @@ long prom_dtlb_load(unsigned long index,
223int prom_map(int mode, unsigned long size, 209int prom_map(int mode, unsigned long size,
224 unsigned long vaddr, unsigned long paddr) 210 unsigned long vaddr, unsigned long paddr)
225{ 211{
226 int ret = p1275_cmd("call-method", 212 int ret = p1275_cmd(prom_callmethod_name,
227 (P1275_ARG(0, P1275_ARG_IN_STRING) | 213 (P1275_ARG(0, P1275_ARG_IN_STRING) |
228 P1275_ARG(3, P1275_ARG_IN_64B) | 214 P1275_ARG(3, P1275_ARG_IN_64B) |
229 P1275_ARG(4, P1275_ARG_IN_64B) | 215 P1275_ARG(4, P1275_ARG_IN_64B) |
230 P1275_ARG(6, P1275_ARG_IN_64B) | 216 P1275_ARG(6, P1275_ARG_IN_64B) |
231 P1275_INOUT(7, 1)), 217 P1275_INOUT(7, 1)),
232 "map", 218 prom_map_name,
233 prom_get_mmu_ihandle(), 219 prom_get_mmu_ihandle(),
234 mode, 220 mode,
235 size, 221 size,
@@ -244,12 +230,12 @@ int prom_map(int mode, unsigned long size,
244 230
245void prom_unmap(unsigned long size, unsigned long vaddr) 231void prom_unmap(unsigned long size, unsigned long vaddr)
246{ 232{
247 p1275_cmd("call-method", 233 p1275_cmd(prom_callmethod_name,
248 (P1275_ARG(0, P1275_ARG_IN_STRING) | 234 (P1275_ARG(0, P1275_ARG_IN_STRING) |
249 P1275_ARG(2, P1275_ARG_IN_64B) | 235 P1275_ARG(2, P1275_ARG_IN_64B) |
250 P1275_ARG(3, P1275_ARG_IN_64B) | 236 P1275_ARG(3, P1275_ARG_IN_64B) |
251 P1275_INOUT(4, 0)), 237 P1275_INOUT(4, 0)),
252 "unmap", 238 prom_unmap_name,
253 prom_get_mmu_ihandle(), 239 prom_get_mmu_ihandle(),
254 size, 240 size,
255 vaddr); 241 vaddr);
@@ -258,7 +244,7 @@ void prom_unmap(unsigned long size, unsigned long vaddr)
258/* Set aside physical memory which is not touched or modified 244/* Set aside physical memory which is not touched or modified
259 * across soft resets. 245 * across soft resets.
260 */ 246 */
261unsigned long prom_retain(char *name, 247unsigned long prom_retain(const char *name,
262 unsigned long pa_low, unsigned long pa_high, 248 unsigned long pa_low, unsigned long pa_high,
263 long size, long align) 249 long size, long align)
264{ 250{
@@ -290,7 +276,7 @@ int prom_getunumber(int syndrome_code,
290 unsigned long phys_addr, 276 unsigned long phys_addr,
291 char *buf, int buflen) 277 char *buf, int buflen)
292{ 278{
293 return p1275_cmd("call-method", 279 return p1275_cmd(prom_callmethod_name,
294 (P1275_ARG(0, P1275_ARG_IN_STRING) | 280 (P1275_ARG(0, P1275_ARG_IN_STRING) |
295 P1275_ARG(3, P1275_ARG_OUT_BUF) | 281 P1275_ARG(3, P1275_ARG_OUT_BUF) |
296 P1275_ARG(6, P1275_ARG_IN_64B) | 282 P1275_ARG(6, P1275_ARG_IN_64B) |
diff --git a/arch/sparc64/prom/p1275.c b/arch/sparc64/prom/p1275.c
index 59fe38bba39e..a5a7c5712028 100644
--- a/arch/sparc64/prom/p1275.c
+++ b/arch/sparc64/prom/p1275.c
@@ -46,7 +46,7 @@ static inline unsigned long spitfire_get_primary_context(void)
46 */ 46 */
47DEFINE_SPINLOCK(prom_entry_lock); 47DEFINE_SPINLOCK(prom_entry_lock);
48 48
49long p1275_cmd (char *service, long fmt, ...) 49long p1275_cmd(const char *service, long fmt, ...)
50{ 50{
51 char *p, *q; 51 char *p, *q;
52 unsigned long flags; 52 unsigned long flags;
diff --git a/arch/sparc64/prom/printf.c b/arch/sparc64/prom/printf.c
index a6df82cafa0d..660943ee4c2a 100644
--- a/arch/sparc64/prom/printf.c
+++ b/arch/sparc64/prom/printf.c
@@ -34,7 +34,7 @@ prom_write(const char *buf, unsigned int n)
34} 34}
35 35
36void 36void
37prom_printf(char *fmt, ...) 37prom_printf(const char *fmt, ...)
38{ 38{
39 va_list args; 39 va_list args;
40 int i; 40 int i;
diff --git a/arch/sparc64/prom/tree.c b/arch/sparc64/prom/tree.c
index ccf73258ebf7..b1ff9e87dcc6 100644
--- a/arch/sparc64/prom/tree.c
+++ b/arch/sparc64/prom/tree.c
@@ -69,7 +69,7 @@ prom_getsibling(int node)
69 * Return -1 on error. 69 * Return -1 on error.
70 */ 70 */
71__inline__ int 71__inline__ int
72prom_getproplen(int node, char *prop) 72prom_getproplen(int node, const char *prop)
73{ 73{
74 if((!node) || (!prop)) return -1; 74 if((!node) || (!prop)) return -1;
75 return p1275_cmd ("getproplen", 75 return p1275_cmd ("getproplen",
@@ -83,20 +83,20 @@ prom_getproplen(int node, char *prop)
83 * was successful the length will be returned, else -1 is returned. 83 * was successful the length will be returned, else -1 is returned.
84 */ 84 */
85__inline__ int 85__inline__ int
86prom_getproperty(int node, char *prop, char *buffer, int bufsize) 86prom_getproperty(int node, const char *prop, char *buffer, int bufsize)
87{ 87{
88 int plen; 88 int plen;
89 89
90 plen = prom_getproplen(node, prop); 90 plen = prom_getproplen(node, prop);
91 if((plen > bufsize) || (plen == 0) || (plen == -1)) 91 if ((plen > bufsize) || (plen == 0) || (plen == -1)) {
92 return -1; 92 return -1;
93 else { 93 } else {
94 /* Ok, things seem all right. */ 94 /* Ok, things seem all right. */
95 return p1275_cmd ("getprop", 95 return p1275_cmd(prom_getprop_name,
96 P1275_ARG(1,P1275_ARG_IN_STRING)| 96 P1275_ARG(1,P1275_ARG_IN_STRING)|
97 P1275_ARG(2,P1275_ARG_OUT_BUF)| 97 P1275_ARG(2,P1275_ARG_OUT_BUF)|
98 P1275_INOUT(4, 1), 98 P1275_INOUT(4, 1),
99 node, prop, buffer, P1275_SIZE(plen)); 99 node, prop, buffer, P1275_SIZE(plen));
100 } 100 }
101} 101}
102 102
@@ -104,7 +104,7 @@ prom_getproperty(int node, char *prop, char *buffer, int bufsize)
104 * on failure. 104 * on failure.
105 */ 105 */
106__inline__ int 106__inline__ int
107prom_getint(int node, char *prop) 107prom_getint(int node, const char *prop)
108{ 108{
109 int intprop; 109 int intprop;
110 110
@@ -119,7 +119,7 @@ prom_getint(int node, char *prop)
119 */ 119 */
120 120
121int 121int
122prom_getintdefault(int node, char *property, int deflt) 122prom_getintdefault(int node, const char *property, int deflt)
123{ 123{
124 int retval; 124 int retval;
125 125
@@ -131,7 +131,7 @@ prom_getintdefault(int node, char *property, int deflt)
131 131
132/* Acquire a boolean property, 1=TRUE 0=FALSE. */ 132/* Acquire a boolean property, 1=TRUE 0=FALSE. */
133int 133int
134prom_getbool(int node, char *prop) 134prom_getbool(int node, const char *prop)
135{ 135{
136 int retval; 136 int retval;
137 137
@@ -145,7 +145,7 @@ prom_getbool(int node, char *prop)
145 * buffer. 145 * buffer.
146 */ 146 */
147void 147void
148prom_getstring(int node, char *prop, char *user_buf, int ubuf_size) 148prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size)
149{ 149{
150 int len; 150 int len;
151 151
@@ -160,7 +160,7 @@ prom_getstring(int node, char *prop, char *user_buf, int ubuf_size)
160 * YES = 1 NO = 0 160 * YES = 1 NO = 0
161 */ 161 */
162int 162int
163prom_nodematch(int node, char *name) 163prom_nodematch(int node, const char *name)
164{ 164{
165 char namebuf[128]; 165 char namebuf[128];
166 prom_getproperty(node, "name", namebuf, sizeof(namebuf)); 166 prom_getproperty(node, "name", namebuf, sizeof(namebuf));
@@ -172,7 +172,7 @@ prom_nodematch(int node, char *name)
172 * 'nodename'. Return node if successful, zero if not. 172 * 'nodename'. Return node if successful, zero if not.
173 */ 173 */
174int 174int
175prom_searchsiblings(int node_start, char *nodename) 175prom_searchsiblings(int node_start, const char *nodename)
176{ 176{
177 177
178 int thisnode, error; 178 int thisnode, error;
@@ -294,7 +294,7 @@ prom_firstprop(int node, char *buffer)
294 * property types for this node. 294 * property types for this node.
295 */ 295 */
296__inline__ char * 296__inline__ char *
297prom_nextprop(int node, char *oprop, char *buffer) 297prom_nextprop(int node, const char *oprop, char *buffer)
298{ 298{
299 char buf[32]; 299 char buf[32];
300 300
@@ -314,15 +314,17 @@ prom_nextprop(int node, char *oprop, char *buffer)
314} 314}
315 315
316int 316int
317prom_finddevice(char *name) 317prom_finddevice(const char *name)
318{ 318{
319 if(!name) return 0; 319 if (!name)
320 return p1275_cmd ("finddevice", P1275_ARG(0,P1275_ARG_IN_STRING)| 320 return 0;
321 P1275_INOUT(1, 1), 321 return p1275_cmd(prom_finddev_name,
322 name); 322 P1275_ARG(0,P1275_ARG_IN_STRING)|
323 P1275_INOUT(1, 1),
324 name);
323} 325}
324 326
325int prom_node_has_property(int node, char *prop) 327int prom_node_has_property(int node, const char *prop)
326{ 328{
327 char buf [32]; 329 char buf [32];
328 330
@@ -339,7 +341,7 @@ int prom_node_has_property(int node, char *prop)
339 * of 'size' bytes. Return the number of bytes the prom accepted. 341 * of 'size' bytes. Return the number of bytes the prom accepted.
340 */ 342 */
341int 343int
342prom_setprop(int node, char *pname, char *value, int size) 344prom_setprop(int node, const char *pname, char *value, int size)
343{ 345{
344 if(size == 0) return 0; 346 if(size == 0) return 0;
345 if((pname == 0) || (value == 0)) return 0; 347 if((pname == 0) || (value == 0)) return 0;
@@ -364,7 +366,7 @@ prom_inst2pkg(int inst)
364 * FIXME: Should work for v0 as well 366 * FIXME: Should work for v0 as well
365 */ 367 */
366int 368int
367prom_pathtoinode(char *path) 369prom_pathtoinode(const char *path)
368{ 370{
369 int node, inst; 371 int node, inst;
370 372
diff --git a/arch/um/Kconfig.i386 b/arch/um/Kconfig.i386
index 8ad156a00499..5d92cacd56c6 100644
--- a/arch/um/Kconfig.i386
+++ b/arch/um/Kconfig.i386
@@ -42,3 +42,7 @@ config ARCH_HAS_SC_SIGNALS
42config ARCH_REUSE_HOST_VSYSCALL_AREA 42config ARCH_REUSE_HOST_VSYSCALL_AREA
43 bool 43 bool
44 default y 44 default y
45
46config X86_CMPXCHG
47 bool
48 default y
diff --git a/arch/um/Makefile b/arch/um/Makefile
index ce987266dac6..e1ffad224605 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -28,8 +28,6 @@ SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
28ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ 28ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
29 $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h 29 $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
30 30
31GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
32
33um-modes-$(CONFIG_MODE_TT) += tt 31um-modes-$(CONFIG_MODE_TT) += tt
34um-modes-$(CONFIG_MODE_SKAS) += skas 32um-modes-$(CONFIG_MODE_SKAS) += skas
35 33
@@ -45,17 +43,19 @@ endif
45 43
46ARCH_INCLUDE := -I$(ARCH_DIR)/include 44ARCH_INCLUDE := -I$(ARCH_DIR)/include
47ifneq ($(KBUILD_SRC),) 45ifneq ($(KBUILD_SRC),)
48ARCH_INCLUDE += -I$(ARCH_DIR)/include2
49ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include 46ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include
50MRPROPER_DIRS += $(ARCH_DIR)/include2
51endif 47endif
52SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) 48SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
53 49
54# -Dvmap=kernel_vmap affects everything, and prevents anything from 50# -Dvmap=kernel_vmap affects everything, and prevents anything from
55# referencing the libpcap.o symbol so named. 51# referencing the libpcap.o symbol so named.
52#
53# Same things for in6addr_loopback - found in libc.
56 54
57CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ 55CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
58 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap 56 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
57 -Din6addr_loopback=kernel_in6addr_loopback
58
59AFLAGS += $(ARCH_INCLUDE) 59AFLAGS += $(ARCH_INCLUDE)
60 60
61USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) 61USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
@@ -83,10 +83,6 @@ CONFIG_KERNEL_HALF_GIGS ?= 0
83 83
84SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) 84SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
85 85
86ifeq ($(CONFIG_MODE_SKAS), y)
87$(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h
88endif
89
90.PHONY: linux 86.PHONY: linux
91 87
92all: linux 88all: linux
@@ -107,7 +103,8 @@ else
107$(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) 103$(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
108endif 104endif
109 105
110archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) 106archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h
107prepare: $(ARCH_DIR)/include/kern_constants.h
111 108
112LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 109LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
113LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib 110LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
@@ -142,22 +139,20 @@ endef
142#When cleaning we don't include .config, so we don't include 139#When cleaning we don't include .config, so we don't include
143#TT or skas makefiles and don't clean skas_ptregs.h. 140#TT or skas makefiles and don't clean skas_ptregs.h.
144CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \ 141CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
145 $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \ 142 $(ARCH_DIR)/include/user_constants.h \
146 $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch 143 $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch
147 144
148MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ 145MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
149 $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os 146 $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os
150 147
151archclean: 148archclean:
152 $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util
153 $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util
154 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 149 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
155 -o -name '*.gcov' \) -type f -print | xargs rm -f 150 -o -name '*.gcov' \) -type f -print | xargs rm -f
156 151
157$(SYMLINK_HEADERS): 152$(SYMLINK_HEADERS):
158 @echo ' SYMLINK $@' 153 @echo ' SYMLINK $@'
159ifneq ($(KBUILD_SRC),) 154ifneq ($(KBUILD_SRC),)
160 ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ 155 $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
161else 156else
162 $(Q)cd $(TOPDIR)/$(dir $@) ; \ 157 $(Q)cd $(TOPDIR)/$(dir $@) ; \
163 ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) 158 ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
@@ -176,9 +171,7 @@ $(ARCH_DIR)/include/sysdep:
176 @echo ' SYMLINK $@' 171 @echo ' SYMLINK $@'
177ifneq ($(KBUILD_SRC),) 172ifneq ($(KBUILD_SRC),)
178 $(Q)mkdir -p $(ARCH_DIR)/include 173 $(Q)mkdir -p $(ARCH_DIR)/include
179 $(Q)mkdir -p $(ARCH_DIR)/include2 174 $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
180 $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
181 $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep
182else 175else
183 $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep 176 $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
184endif 177endif
@@ -198,8 +191,6 @@ endef
198 191
199define filechk_gen-asm-offsets 192define filechk_gen-asm-offsets
200 (set -e; \ 193 (set -e; \
201 echo "#ifndef __ASM_OFFSETS_H__"; \
202 echo "#define __ASM_OFFSETS_H__"; \
203 echo "/*"; \ 194 echo "/*"; \
204 echo " * DO NOT MODIFY."; \ 195 echo " * DO NOT MODIFY."; \
205 echo " *"; \ 196 echo " *"; \
@@ -208,8 +199,7 @@ define filechk_gen-asm-offsets
208 echo " */"; \ 199 echo " */"; \
209 echo ""; \ 200 echo ""; \
210 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ 201 sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
211 echo ""; \ 202 echo ""; )
212 echo "#endif" )
213endef 203endef
214 204
215$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h 205$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
@@ -218,50 +208,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
218$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c 208$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
219 $(CC) $(USER_CFLAGS) -S -o $@ $< 209 $(CC) $(USER_CFLAGS) -S -o $@ $<
220 210
221$(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s 211$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s
222 $(call filechk,gen-asm-offsets) 212 $(call filechk,gen-asm-offsets)
223 213
224CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h 214CLEAN_FILES += $(ARCH_DIR)/user-offsets.s
225 215
226$(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ 216$(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \
227 $(ARCH_SYMLINKS) \ 217 archprepare
228 $(SYS_DIR)/sc.h \
229 include/asm include/linux/version.h \
230 include/config/MARKER \
231 $(ARCH_DIR)/include/user_constants.h
232 $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< 218 $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $<
233 219
234$(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s 220$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s
235 $(call filechk,gen-asm-offsets) 221 $(call filechk,gen-asm-offsets)
236 222
237CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h 223CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s
238
239$(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task
240 $(call filechk,gen_header)
241
242$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants
243 $(call filechk,gen_header)
244
245$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
246 $(call filechk,gen_header)
247
248$(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs
249 $(call filechk,gen_header)
250
251$(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ;
252
253$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \
254 FORCE ;
255
256$(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ;
257
258$(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE
259 $(Q)$(MAKE) $(build)=$@
260
261$(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
262 $(Q)$(MAKE) $(build)=$@
263
264$(ARCH_DIR)/os-$(OS)/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
265 $(Q)$(MAKE) $(build)=$@
266 224
267export SUBARCH USER_CFLAGS OS 225export SUBARCH USER_CFLAGS OS
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index 1ab431a53ac3..2ee8a2858117 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -32,25 +32,3 @@ CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH)
32ifneq ($(CONFIG_GPROF),y) 32ifneq ($(CONFIG_GPROF),y)
33ARCH_CFLAGS += -DUM_FASTCALL 33ARCH_CFLAGS += -DUM_FASTCALL
34endif 34endif
35
36SYS_UTIL_DIR := $(ARCH_DIR)/sys-i386/util
37SYS_HEADERS := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
38
39prepare: $(SYS_HEADERS)
40
41$(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
42 $(call filechk,gen_header)
43
44$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread
45 $(call filechk,gen_header)
46
47$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
48 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
49
50$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE
51 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
52
53$(SYS_UTIL_DIR): scripts_basic include/asm FORCE
54 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR)
55
56CLEAN_FILES += $(SYS_HEADERS)
diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas
index fd18ec572271..ac35de5316a6 100644
--- a/arch/um/Makefile-skas
+++ b/arch/um/Makefile-skas
@@ -10,5 +10,3 @@ CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT)
10CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) 10CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT)
11LINK-$(CONFIG_GCOV) += $(GCOV_OPT) 11LINK-$(CONFIG_GCOV) += $(GCOV_OPT)
12LINK-$(CONFIG_GPROF) += $(GPROF_OPT) 12LINK-$(CONFIG_GPROF) += $(GPROF_OPT)
13
14GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 436abbba409b..4f118d5cc2ee 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -12,24 +12,3 @@ CHECKFLAGS += -m64
12 12
13ELF_ARCH := i386:x86-64 13ELF_ARCH := i386:x86-64
14ELF_FORMAT := elf64-x86-64 14ELF_FORMAT := elf64-x86-64
15
16SYS_UTIL_DIR := $(ARCH_DIR)/sys-x86_64/util
17SYS_DIR := $(ARCH_DIR)/include/sysdep-x86_64
18
19SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
20
21prepare: $(SYS_HEADERS)
22
23$(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
24 $(call filechk,gen_header)
25
26$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread
27 $(call filechk,gen_header)
28
29$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
30 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
31
32$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE
33 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
34
35CLEAN_FILES += $(SYS_HEADERS)
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile
index 783e18cae090..de17d4c6e02d 100644
--- a/arch/um/drivers/Makefile
+++ b/arch/um/drivers/Makefile
@@ -13,7 +13,7 @@ mcast-objs := mcast_kern.o mcast_user.o
13net-objs := net_kern.o net_user.o 13net-objs := net_kern.o net_user.o
14mconsole-objs := mconsole_kern.o mconsole_user.o 14mconsole-objs := mconsole_kern.o mconsole_user.o
15hostaudio-objs := hostaudio_kern.o 15hostaudio-objs := hostaudio_kern.o
16ubd-objs := ubd_kern.o 16ubd-objs := ubd_kern.o ubd_user.o
17port-objs := port_kern.o port_user.o 17port-objs := port_kern.o port_user.o
18harddog-objs := harddog_kern.o harddog_user.o 18harddog-objs := harddog_kern.o harddog_user.o
19 19
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 14a12d6b3df6..16e7dc89f61d 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -19,18 +19,44 @@
19#include "line.h" 19#include "line.h"
20#include "os.h" 20#include "os.h"
21 21
22#ifdef CONFIG_NOCONFIG_CHAN 22/* XXX: could well be moved to somewhere else, if needed. */
23static int my_printf(const char * fmt, ...)
24 __attribute__ ((format (printf, 1, 2)));
25
26static int my_printf(const char * fmt, ...)
27{
28 /* Yes, can be called on atomic context.*/
29 char *buf = kmalloc(4096, GFP_ATOMIC);
30 va_list args;
31 int r;
32
33 if (!buf) {
34 /* We print directly fmt.
35 * Yes, yes, yes, feel free to complain. */
36 r = strlen(fmt);
37 } else {
38 va_start(args, fmt);
39 r = vsprintf(buf, fmt, args);
40 va_end(args);
41 fmt = buf;
42 }
23 43
24/* The printk's here are wrong because we are complaining that there is no 44 if (r)
25 * output device, but printk is printing to that output device. The user will 45 r = os_write_file(1, fmt, r);
26 * never see the error. printf would be better, except it can't run on a 46 return r;
27 * kernel stack because it will overflow it. 47
28 * Use printk for now since that will avoid crashing. 48}
29 */ 49
50#ifdef CONFIG_NOCONFIG_CHAN
51/* Despite its name, there's no added trailing newline. */
52static int my_puts(const char * buf)
53{
54 return os_write_file(1, buf, strlen(buf));
55}
30 56
31static void *not_configged_init(char *str, int device, struct chan_opts *opts) 57static void *not_configged_init(char *str, int device, struct chan_opts *opts)
32{ 58{
33 printk(KERN_ERR "Using a channel type which is configured out of " 59 my_puts("Using a channel type which is configured out of "
34 "UML\n"); 60 "UML\n");
35 return(NULL); 61 return(NULL);
36} 62}
@@ -38,27 +64,27 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts)
38static int not_configged_open(int input, int output, int primary, void *data, 64static int not_configged_open(int input, int output, int primary, void *data,
39 char **dev_out) 65 char **dev_out)
40{ 66{
41 printk(KERN_ERR "Using a channel type which is configured out of " 67 my_puts("Using a channel type which is configured out of "
42 "UML\n"); 68 "UML\n");
43 return(-ENODEV); 69 return(-ENODEV);
44} 70}
45 71
46static void not_configged_close(int fd, void *data) 72static void not_configged_close(int fd, void *data)
47{ 73{
48 printk(KERN_ERR "Using a channel type which is configured out of " 74 my_puts("Using a channel type which is configured out of "
49 "UML\n"); 75 "UML\n");
50} 76}
51 77
52static int not_configged_read(int fd, char *c_out, void *data) 78static int not_configged_read(int fd, char *c_out, void *data)
53{ 79{
54 printk(KERN_ERR "Using a channel type which is configured out of " 80 my_puts("Using a channel type which is configured out of "
55 "UML\n"); 81 "UML\n");
56 return(-EIO); 82 return(-EIO);
57} 83}
58 84
59static int not_configged_write(int fd, const char *buf, int len, void *data) 85static int not_configged_write(int fd, const char *buf, int len, void *data)
60{ 86{
61 printk(KERN_ERR "Using a channel type which is configured out of " 87 my_puts("Using a channel type which is configured out of "
62 "UML\n"); 88 "UML\n");
63 return(-EIO); 89 return(-EIO);
64} 90}
@@ -66,7 +92,7 @@ static int not_configged_write(int fd, const char *buf, int len, void *data)
66static int not_configged_console_write(int fd, const char *buf, int len, 92static int not_configged_console_write(int fd, const char *buf, int len,
67 void *data) 93 void *data)
68{ 94{
69 printk(KERN_ERR "Using a channel type which is configured out of " 95 my_puts("Using a channel type which is configured out of "
70 "UML\n"); 96 "UML\n");
71 return(-EIO); 97 return(-EIO);
72} 98}
@@ -74,14 +100,14 @@ static int not_configged_console_write(int fd, const char *buf, int len,
74static int not_configged_window_size(int fd, void *data, unsigned short *rows, 100static int not_configged_window_size(int fd, void *data, unsigned short *rows,
75 unsigned short *cols) 101 unsigned short *cols)
76{ 102{
77 printk(KERN_ERR "Using a channel type which is configured out of " 103 my_puts("Using a channel type which is configured out of "
78 "UML\n"); 104 "UML\n");
79 return(-ENODEV); 105 return(-ENODEV);
80} 106}
81 107
82static void not_configged_free(void *data) 108static void not_configged_free(void *data)
83{ 109{
84 printf(KERN_ERR "Using a channel type which is configured out of " 110 my_puts("Using a channel type which is configured out of "
85 "UML\n"); 111 "UML\n");
86} 112}
87 113
@@ -457,7 +483,7 @@ static struct chan *parse_chan(char *str, int pri, int device,
457 } 483 }
458 } 484 }
459 if(ops == NULL){ 485 if(ops == NULL){
460 printk(KERN_ERR "parse_chan couldn't parse \"%s\"\n", 486 my_printf("parse_chan couldn't parse \"%s\"\n",
461 str); 487 str);
462 return(NULL); 488 return(NULL);
463 } 489 }
@@ -465,7 +491,7 @@ static struct chan *parse_chan(char *str, int pri, int device,
465 data = (*ops->init)(str, device, opts); 491 data = (*ops->init)(str, device, opts);
466 if(data == NULL) return(NULL); 492 if(data == NULL) return(NULL);
467 493
468 chan = kmalloc(sizeof(*chan), GFP_KERNEL); 494 chan = kmalloc(sizeof(*chan), GFP_ATOMIC);
469 if(chan == NULL) return(NULL); 495 if(chan == NULL) return(NULL);
470 *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), 496 *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list),
471 .primary = 1, 497 .primary = 1,
diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h
index 4fcf3a8d13f4..dc36b222100b 100644
--- a/arch/um/drivers/cow.h
+++ b/arch/um/drivers/cow.h
@@ -3,15 +3,40 @@
3 3
4#include <asm/types.h> 4#include <asm/types.h>
5 5
6#if defined(__BIG_ENDIAN) 6#if defined(__KERNEL__)
7# define ntohll(x) (x) 7
8# define htonll(x) (x) 8# include <asm/byteorder.h>
9#elif defined(__LITTLE_ENDIAN) 9
10# define ntohll(x) bswap_64(x) 10# if defined(__BIG_ENDIAN)
11# define htonll(x) bswap_64(x) 11# define ntohll(x) (x)
12# define htonll(x) (x)
13# elif defined(__LITTLE_ENDIAN)
14# define ntohll(x) be64_to_cpu(x)
15# define htonll(x) cpu_to_be64(x)
16# else
17# error "Could not determine byte order"
18# endif
19
12#else 20#else
13#error "__BYTE_ORDER not defined" 21/* For the definition of ntohl, htonl and __BYTE_ORDER */
22#include <endian.h>
23#include <netinet/in.h>
24#if defined(__BYTE_ORDER)
25
26# if __BYTE_ORDER == __BIG_ENDIAN
27# define ntohll(x) (x)
28# define htonll(x) (x)
29# elif __BYTE_ORDER == __LITTLE_ENDIAN
30# define ntohll(x) bswap_64(x)
31# define htonll(x) bswap_64(x)
32# else
33# error "Could not determine byte order: __BYTE_ORDER uncorrectly defined"
34# endif
35
36#else /* ! defined(__BYTE_ORDER) */
37# error "Could not determine byte order: __BYTE_ORDER not defined"
14#endif 38#endif
39#endif /* ! defined(__KERNEL__) */
15 40
16extern int init_cow_file(int fd, char *cow_file, char *backing_file, 41extern int init_cow_file(int fd, char *cow_file, char *backing_file,
17 int sectorsize, int alignment, int *bitmap_offset_out, 42 int sectorsize, int alignment, int *bitmap_offset_out,
diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c
index a8ce6fc3ef26..fbe2217db5dd 100644
--- a/arch/um/drivers/cow_user.c
+++ b/arch/um/drivers/cow_user.c
@@ -9,7 +9,6 @@
9#include <sys/time.h> 9#include <sys/time.h>
10#include <sys/param.h> 10#include <sys/param.h>
11#include <sys/user.h> 11#include <sys/user.h>
12#include <netinet/in.h>
13 12
14#include "os.h" 13#include "os.h"
15 14
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index 7a0d115b29d0..5db136e2651c 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -13,7 +13,6 @@
13 13
14#include <errno.h> 14#include <errno.h>
15#include <unistd.h> 15#include <unistd.h>
16#include <linux/inet.h>
17#include <sys/socket.h> 16#include <sys/socket.h>
18#include <sys/un.h> 17#include <sys/un.h>
19#include <sys/time.h> 18#include <sys/time.h>
@@ -55,7 +54,7 @@ static int mcast_open(void *data)
55 struct mcast_data *pri = data; 54 struct mcast_data *pri = data;
56 struct sockaddr_in *sin = pri->mcast_addr; 55 struct sockaddr_in *sin = pri->mcast_addr;
57 struct ip_mreq mreq; 56 struct ip_mreq mreq;
58 int fd = -EINVAL, yes = 1, err = -EINVAL;; 57 int fd, yes = 1, err = 0;
59 58
60 59
61 if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0)) 60 if ((sin->sin_addr.s_addr == 0) || (sin->sin_port == 0))
@@ -66,13 +65,14 @@ static int mcast_open(void *data)
66 if (fd < 0){ 65 if (fd < 0){
67 printk("mcast_open : data socket failed, errno = %d\n", 66 printk("mcast_open : data socket failed, errno = %d\n",
68 errno); 67 errno);
69 fd = -errno; 68 err = -errno;
70 goto out; 69 goto out;
71 } 70 }
72 71
73 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { 72 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
74 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", 73 printk("mcast_open: SO_REUSEADDR failed, errno = %d\n",
75 errno); 74 errno);
75 err = -errno;
76 goto out_close; 76 goto out_close;
77 } 77 }
78 78
@@ -81,6 +81,7 @@ static int mcast_open(void *data)
81 sizeof(pri->ttl)) < 0) { 81 sizeof(pri->ttl)) < 0) {
82 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", 82 printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n",
83 errno); 83 errno);
84 err = -errno;
84 goto out_close; 85 goto out_close;
85 } 86 }
86 87
@@ -88,12 +89,14 @@ static int mcast_open(void *data)
88 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { 89 if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
89 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", 90 printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n",
90 errno); 91 errno);
92 err = -errno;
91 goto out_close; 93 goto out_close;
92 } 94 }
93 95
94 /* bind socket to mcast address */ 96 /* bind socket to mcast address */
95 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { 97 if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
96 printk("mcast_open : data bind failed, errno = %d\n", errno); 98 printk("mcast_open : data bind failed, errno = %d\n", errno);
99 err = -errno;
97 goto out_close; 100 goto out_close;
98 } 101 }
99 102
@@ -108,14 +111,15 @@ static int mcast_open(void *data)
108 "interface on the host.\n"); 111 "interface on the host.\n");
109 printk("eth0 should be configured in order to use the " 112 printk("eth0 should be configured in order to use the "
110 "multicast transport.\n"); 113 "multicast transport.\n");
114 err = -errno;
111 goto out_close; 115 goto out_close;
112 } 116 }
113 117
114 out:
115 return fd; 118 return fd;
116 119
117 out_close: 120 out_close:
118 os_close_file(fd); 121 os_close_file(fd);
122 out:
119 return err; 123 return err;
120} 124}
121 125
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index c190c2414197..12c95368124a 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -32,6 +32,7 @@
32#include "os.h" 32#include "os.h"
33#include "umid.h" 33#include "umid.h"
34#include "irq_kern.h" 34#include "irq_kern.h"
35#include "choose-mode.h"
35 36
36static int do_unlink_socket(struct notifier_block *notifier, 37static int do_unlink_socket(struct notifier_block *notifier,
37 unsigned long what, void *data) 38 unsigned long what, void *data)
@@ -276,6 +277,7 @@ void mconsole_proc(struct mc_request *req)
276 go - continue the UML after a 'stop' \n\ 277 go - continue the UML after a 'stop' \n\
277 log <string> - make UML enter <string> into the kernel log\n\ 278 log <string> - make UML enter <string> into the kernel log\n\
278 proc <file> - returns the contents of the UML's /proc/<file>\n\ 279 proc <file> - returns the contents of the UML's /proc/<file>\n\
280 stack <pid> - returns the stack of the specified pid\n\
279" 281"
280 282
281void mconsole_help(struct mc_request *req) 283void mconsole_help(struct mc_request *req)
@@ -479,6 +481,56 @@ void mconsole_sysrq(struct mc_request *req)
479} 481}
480#endif 482#endif
481 483
484/* Mconsole stack trace
485 * Added by Allan Graves, Jeff Dike
486 * Dumps a stacks registers to the linux console.
487 * Usage stack <pid>.
488 */
489void do_stack(struct mc_request *req)
490{
491 char *ptr = req->request.data;
492 int pid_requested= -1;
493 struct task_struct *from = NULL;
494 struct task_struct *to = NULL;
495
496 /* Would be nice:
497 * 1) Send showregs output to mconsole.
498 * 2) Add a way to stack dump all pids.
499 */
500
501 ptr += strlen("stack");
502 while(isspace(*ptr)) ptr++;
503
504 /* Should really check for multiple pids or reject bad args here */
505 /* What do the arguments in mconsole_reply mean? */
506 if(sscanf(ptr, "%d", &pid_requested) == 0){
507 mconsole_reply(req, "Please specify a pid", 1, 0);
508 return;
509 }
510
511 from = current;
512 to = find_task_by_pid(pid_requested);
513
514 if((to == NULL) || (pid_requested == 0)) {
515 mconsole_reply(req, "Couldn't find that pid", 1, 0);
516 return;
517 }
518 to->thread.saved_task = current;
519
520 switch_to(from, to, from);
521 mconsole_reply(req, "Stack Dumped to console and message log", 0, 0);
522}
523
524void mconsole_stack(struct mc_request *req)
525{
526 /* This command doesn't work in TT mode, so let's check and then
527 * get out of here
528 */
529 CHOOSE_MODE(mconsole_reply(req, "Sorry, this doesn't work in TT mode",
530 1, 0),
531 do_stack(req));
532}
533
482/* Changed by mconsole_setup, which is __setup, and called before SMP is 534/* Changed by mconsole_setup, which is __setup, and called before SMP is
483 * active. 535 * active.
484 */ 536 */
diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c
index fe5afb13252c..310c1f823f26 100644
--- a/arch/um/drivers/mconsole_user.c
+++ b/arch/um/drivers/mconsole_user.c
@@ -30,6 +30,7 @@ static struct mconsole_command commands[] = {
30 { "go", mconsole_go, MCONSOLE_INTR }, 30 { "go", mconsole_go, MCONSOLE_INTR },
31 { "log", mconsole_log, MCONSOLE_INTR }, 31 { "log", mconsole_log, MCONSOLE_INTR },
32 { "proc", mconsole_proc, MCONSOLE_PROC }, 32 { "proc", mconsole_proc, MCONSOLE_PROC },
33 { "stack", mconsole_stack, MCONSOLE_INTR },
33}; 34};
34 35
35/* Initialized in mconsole_init, which is an initcall */ 36/* Initialized in mconsole_init, which is an initcall */
@@ -172,9 +173,9 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len)
172 if(notify_sock < 0){ 173 if(notify_sock < 0){
173 notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0); 174 notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0);
174 if(notify_sock < 0){ 175 if(notify_sock < 0){
175 printk("mconsole_notify - socket failed, errno = %d\n",
176 errno);
177 err = -errno; 176 err = -errno;
177 printk("mconsole_notify - socket failed, errno = %d\n",
178 err);
178 } 179 }
179 } 180 }
180 unlock_notify(); 181 unlock_notify();
@@ -197,8 +198,8 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len)
197 n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target, 198 n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target,
198 sizeof(target)); 199 sizeof(target));
199 if(n < 0){ 200 if(n < 0){
200 printk("mconsole_notify - sendto failed, errno = %d\n", errno);
201 err = -errno; 201 err = -errno;
202 printk("mconsole_notify - sendto failed, errno = %d\n", errno);
202 } 203 }
203 return(err); 204 return(err);
204} 205}
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index c41efd207fcc..189839e4f1d4 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -7,7 +7,6 @@
7#include "linux/sched.h" 7#include "linux/sched.h"
8#include "linux/slab.h" 8#include "linux/slab.h"
9#include "linux/interrupt.h" 9#include "linux/interrupt.h"
10#include "linux/irq.h"
11#include "linux/spinlock.h" 10#include "linux/spinlock.h"
12#include "linux/errno.h" 11#include "linux/errno.h"
13#include "asm/atomic.h" 12#include "asm/atomic.h"
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c
index ed84d01df6cc..0306a1b215b7 100644
--- a/arch/um/drivers/pty.c
+++ b/arch/um/drivers/pty.c
@@ -43,8 +43,9 @@ static int pts_open(int input, int output, int primary, void *d,
43 43
44 fd = get_pty(); 44 fd = get_pty();
45 if(fd < 0){ 45 if(fd < 0){
46 err = -errno;
46 printk("open_pts : Failed to open pts\n"); 47 printk("open_pts : Failed to open pts\n");
47 return(-errno); 48 return err;
48 } 49 }
49 if(data->raw){ 50 if(data->raw){
50 CATCH_EINTR(err = tcgetattr(fd, &data->tt)); 51 CATCH_EINTR(err = tcgetattr(fd, &data->tt));
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index e77a38da4350..f73134333f64 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -35,7 +35,6 @@
35#include "linux/blkpg.h" 35#include "linux/blkpg.h"
36#include "linux/genhd.h" 36#include "linux/genhd.h"
37#include "linux/spinlock.h" 37#include "linux/spinlock.h"
38#include "asm/atomic.h"
39#include "asm/segment.h" 38#include "asm/segment.h"
40#include "asm/uaccess.h" 39#include "asm/uaccess.h"
41#include "asm/irq.h" 40#include "asm/irq.h"
@@ -54,21 +53,20 @@
54#include "mem.h" 53#include "mem.h"
55#include "mem_kern.h" 54#include "mem_kern.h"
56#include "cow.h" 55#include "cow.h"
57#include "aio.h"
58 56
59enum ubd_req { UBD_READ, UBD_WRITE }; 57enum ubd_req { UBD_READ, UBD_WRITE };
60 58
61struct io_thread_req { 59struct io_thread_req {
62 enum aio_type op; 60 enum ubd_req op;
63 int fds[2]; 61 int fds[2];
64 unsigned long offsets[2]; 62 unsigned long offsets[2];
65 unsigned long long offset; 63 unsigned long long offset;
66 unsigned long length; 64 unsigned long length;
67 char *buffer; 65 char *buffer;
68 int sectorsize; 66 int sectorsize;
69 int bitmap_offset; 67 unsigned long sector_mask;
70 long bitmap_start; 68 unsigned long long cow_offset;
71 long bitmap_end; 69 unsigned long bitmap_words[2];
72 int error; 70 int error;
73}; 71};
74 72
@@ -82,31 +80,28 @@ extern int create_cow_file(char *cow_file, char *backing_file,
82 unsigned long *bitmap_len_out, 80 unsigned long *bitmap_len_out,
83 int *data_offset_out); 81 int *data_offset_out);
84extern int read_cow_bitmap(int fd, void *buf, int offset, int len); 82extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
85extern void do_io(struct io_thread_req *req, struct request *r, 83extern void do_io(struct io_thread_req *req);
86 unsigned long *bitmap);
87 84
88static inline int ubd_test_bit(__u64 bit, void *data) 85static inline int ubd_test_bit(__u64 bit, unsigned char *data)
89{ 86{
90 unsigned char *buffer = data;
91 __u64 n; 87 __u64 n;
92 int bits, off; 88 int bits, off;
93 89
94 bits = sizeof(buffer[0]) * 8; 90 bits = sizeof(data[0]) * 8;
95 n = bit / bits; 91 n = bit / bits;
96 off = bit % bits; 92 off = bit % bits;
97 return((buffer[n] & (1 << off)) != 0); 93 return((data[n] & (1 << off)) != 0);
98} 94}
99 95
100static inline void ubd_set_bit(__u64 bit, void *data) 96static inline void ubd_set_bit(__u64 bit, unsigned char *data)
101{ 97{
102 unsigned char *buffer = data;
103 __u64 n; 98 __u64 n;
104 int bits, off; 99 int bits, off;
105 100
106 bits = sizeof(buffer[0]) * 8; 101 bits = sizeof(data[0]) * 8;
107 n = bit / bits; 102 n = bit / bits;
108 off = bit % bits; 103 off = bit % bits;
109 buffer[n] |= (1 << off); 104 data[n] |= (1 << off);
110} 105}
111/*End stuff from ubd_user.h*/ 106/*End stuff from ubd_user.h*/
112 107
@@ -115,6 +110,8 @@ static inline void ubd_set_bit(__u64 bit, void *data)
115static DEFINE_SPINLOCK(ubd_io_lock); 110static DEFINE_SPINLOCK(ubd_io_lock);
116static DEFINE_SPINLOCK(ubd_lock); 111static DEFINE_SPINLOCK(ubd_lock);
117 112
113static void (*do_ubd)(void);
114
118static int ubd_open(struct inode * inode, struct file * filp); 115static int ubd_open(struct inode * inode, struct file * filp);
119static int ubd_release(struct inode * inode, struct file * file); 116static int ubd_release(struct inode * inode, struct file * file);
120static int ubd_ioctl(struct inode * inode, struct file * file, 117static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -161,8 +158,6 @@ struct cow {
161 int data_offset; 158 int data_offset;
162}; 159};
163 160
164#define MAX_SG 64
165
166struct ubd { 161struct ubd {
167 char *file; 162 char *file;
168 int count; 163 int count;
@@ -173,7 +168,6 @@ struct ubd {
173 int no_cow; 168 int no_cow;
174 struct cow cow; 169 struct cow cow;
175 struct platform_device pdev; 170 struct platform_device pdev;
176 struct scatterlist sg[MAX_SG];
177}; 171};
178 172
179#define DEFAULT_COW { \ 173#define DEFAULT_COW { \
@@ -466,114 +460,81 @@ __uml_help(fakehd,
466); 460);
467 461
468static void do_ubd_request(request_queue_t * q); 462static void do_ubd_request(request_queue_t * q);
469static int in_ubd; 463
464/* Only changed by ubd_init, which is an initcall. */
465int thread_fd = -1;
470 466
471/* Changed by ubd_handler, which is serialized because interrupts only 467/* Changed by ubd_handler, which is serialized because interrupts only
472 * happen on CPU 0. 468 * happen on CPU 0.
473 */ 469 */
474int intr_count = 0; 470int intr_count = 0;
475 471
476static void ubd_end_request(struct request *req, int bytes, int uptodate) 472/* call ubd_finish if you need to serialize */
473static void __ubd_finish(struct request *req, int error)
477{ 474{
478 if (!end_that_request_first(req, uptodate, bytes >> 9)) { 475 int nsect;
479 add_disk_randomness(req->rq_disk); 476
480 end_that_request_last(req); 477 if(error){
478 end_request(req, 0);
479 return;
481 } 480 }
481 nsect = req->current_nr_sectors;
482 req->sector += nsect;
483 req->buffer += nsect << 9;
484 req->errors = 0;
485 req->nr_sectors -= nsect;
486 req->current_nr_sectors = 0;
487 end_request(req, 1);
482} 488}
483 489
484/* call ubd_finish if you need to serialize */ 490static inline void ubd_finish(struct request *req, int error)
485static void __ubd_finish(struct request *req, int bytes)
486{ 491{
487 if(bytes < 0){ 492 spin_lock(&ubd_io_lock);
488 ubd_end_request(req, 0, 0); 493 __ubd_finish(req, error);
489 return; 494 spin_unlock(&ubd_io_lock);
490 }
491
492 ubd_end_request(req, bytes, 1);
493} 495}
494 496
495static inline void ubd_finish(struct request *req, int bytes) 497/* Called without ubd_io_lock held */
498static void ubd_handler(void)
496{ 499{
497 spin_lock(&ubd_io_lock); 500 struct io_thread_req req;
498 __ubd_finish(req, bytes); 501 struct request *rq = elv_next_request(ubd_queue);
499 spin_unlock(&ubd_io_lock); 502 int n;
503
504 do_ubd = NULL;
505 intr_count++;
506 n = os_read_file(thread_fd, &req, sizeof(req));
507 if(n != sizeof(req)){
508 printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, "
509 "err = %d\n", os_getpid(), -n);
510 spin_lock(&ubd_io_lock);
511 end_request(rq, 0);
512 spin_unlock(&ubd_io_lock);
513 return;
514 }
515
516 ubd_finish(rq, req.error);
517 reactivate_fd(thread_fd, UBD_IRQ);
518 do_ubd_request(ubd_queue);
500} 519}
501 520
502struct bitmap_io {
503 atomic_t count;
504 struct aio_context aio;
505};
506
507struct ubd_aio {
508 struct aio_context aio;
509 struct request *req;
510 int len;
511 struct bitmap_io *bitmap;
512 void *bitmap_buf;
513};
514
515static int ubd_reply_fd = -1;
516
517static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused) 521static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused)
518{ 522{
519 struct aio_thread_reply reply; 523 ubd_handler();
520 struct ubd_aio *aio; 524 return(IRQ_HANDLED);
521 struct request *req; 525}
522 int err, n, fd = (int) (long) dev;
523
524 while(1){
525 err = os_read_file(fd, &reply, sizeof(reply));
526 if(err == -EAGAIN)
527 break;
528 if(err < 0){
529 printk("ubd_aio_handler - read returned err %d\n",
530 -err);
531 break;
532 }
533
534 aio = container_of(reply.data, struct ubd_aio, aio);
535 n = reply.err;
536
537 if(n == 0){
538 req = aio->req;
539 req->nr_sectors -= aio->len >> 9;
540
541 if((aio->bitmap != NULL) &&
542 (atomic_dec_and_test(&aio->bitmap->count))){
543 aio->aio = aio->bitmap->aio;
544 aio->len = 0;
545 kfree(aio->bitmap);
546 aio->bitmap = NULL;
547 submit_aio(&aio->aio);
548 }
549 else {
550 if((req->nr_sectors == 0) &&
551 (aio->bitmap == NULL)){
552 int len = req->hard_nr_sectors << 9;
553 ubd_finish(req, len);
554 }
555
556 if(aio->bitmap_buf != NULL)
557 kfree(aio->bitmap_buf);
558 kfree(aio);
559 }
560 }
561 else if(n < 0){
562 ubd_finish(aio->req, n);
563 if(aio->bitmap != NULL)
564 kfree(aio->bitmap);
565 if(aio->bitmap_buf != NULL)
566 kfree(aio->bitmap_buf);
567 kfree(aio);
568 }
569 }
570 reactivate_fd(fd, UBD_IRQ);
571 526
572 do_ubd_request(ubd_queue); 527/* Only changed by ubd_init, which is an initcall. */
528static int io_pid = -1;
573 529
574 return(IRQ_HANDLED); 530void kill_io_thread(void)
531{
532 if(io_pid != -1)
533 os_kill_process(io_pid, 1);
575} 534}
576 535
536__uml_exitcall(kill_io_thread);
537
577static int ubd_file_size(struct ubd *dev, __u64 *size_out) 538static int ubd_file_size(struct ubd *dev, __u64 *size_out)
578{ 539{
579 char *file; 540 char *file;
@@ -608,7 +569,7 @@ static int ubd_open_dev(struct ubd *dev)
608 &dev->cow.data_offset, create_ptr); 569 &dev->cow.data_offset, create_ptr);
609 570
610 if((dev->fd == -ENOENT) && create_cow){ 571 if((dev->fd == -ENOENT) && create_cow){
611 dev->fd = create_cow_file(dev->file, dev->cow.file, 572 dev->fd = create_cow_file(dev->file, dev->cow.file,
612 dev->openflags, 1 << 9, PAGE_SIZE, 573 dev->openflags, 1 << 9, PAGE_SIZE,
613 &dev->cow.bitmap_offset, 574 &dev->cow.bitmap_offset,
614 &dev->cow.bitmap_len, 575 &dev->cow.bitmap_len,
@@ -870,10 +831,6 @@ int ubd_init(void)
870{ 831{
871 int i; 832 int i;
872 833
873 ubd_reply_fd = init_aio_irq(UBD_IRQ, "ubd", ubd_intr);
874 if(ubd_reply_fd < 0)
875 printk("Setting up ubd AIO failed, err = %d\n", ubd_reply_fd);
876
877 devfs_mk_dir("ubd"); 834 devfs_mk_dir("ubd");
878 if (register_blkdev(MAJOR_NR, "ubd")) 835 if (register_blkdev(MAJOR_NR, "ubd"))
879 return -1; 836 return -1;
@@ -884,7 +841,6 @@ int ubd_init(void)
884 return -1; 841 return -1;
885 } 842 }
886 843
887 blk_queue_max_hw_segments(ubd_queue, MAX_SG);
888 if (fake_major != MAJOR_NR) { 844 if (fake_major != MAJOR_NR) {
889 char name[sizeof("ubd_nnn\0")]; 845 char name[sizeof("ubd_nnn\0")];
890 846
@@ -896,12 +852,40 @@ int ubd_init(void)
896 driver_register(&ubd_driver); 852 driver_register(&ubd_driver);
897 for (i = 0; i < MAX_DEV; i++) 853 for (i = 0; i < MAX_DEV; i++)
898 ubd_add(i); 854 ubd_add(i);
899
900 return 0; 855 return 0;
901} 856}
902 857
903late_initcall(ubd_init); 858late_initcall(ubd_init);
904 859
860int ubd_driver_init(void){
861 unsigned long stack;
862 int err;
863
864 /* Set by CONFIG_BLK_DEV_UBD_SYNC or ubd=sync.*/
865 if(global_openflags.s){
866 printk(KERN_INFO "ubd: Synchronous mode\n");
867 /* Letting ubd=sync be like using ubd#s= instead of ubd#= is
868 * enough. So use anyway the io thread. */
869 }
870 stack = alloc_stack(0, 0);
871 io_pid = start_io_thread(stack + PAGE_SIZE - sizeof(void *),
872 &thread_fd);
873 if(io_pid < 0){
874 printk(KERN_ERR
875 "ubd : Failed to start I/O thread (errno = %d) - "
876 "falling back to synchronous I/O\n", -io_pid);
877 io_pid = -1;
878 return(0);
879 }
880 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
881 SA_INTERRUPT, "ubd", ubd_dev);
882 if(err != 0)
883 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
884 return(err);
885}
886
887device_initcall(ubd_driver_init);
888
905static int ubd_open(struct inode *inode, struct file *filp) 889static int ubd_open(struct inode *inode, struct file *filp)
906{ 890{
907 struct gendisk *disk = inode->i_bdev->bd_disk; 891 struct gendisk *disk = inode->i_bdev->bd_disk;
@@ -939,55 +923,105 @@ static int ubd_release(struct inode * inode, struct file * file)
939 return(0); 923 return(0);
940} 924}
941 925
942static void cowify_bitmap(struct io_thread_req *req, unsigned long *bitmap) 926static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask,
927 __u64 *cow_offset, unsigned long *bitmap,
928 __u64 bitmap_offset, unsigned long *bitmap_words,
929 __u64 bitmap_len)
943{ 930{
944 __u64 sector = req->offset / req->sectorsize; 931 __u64 sector = io_offset >> 9;
945 int i; 932 int i, update_bitmap = 0;
933
934 for(i = 0; i < length >> 9; i++){
935 if(cow_mask != NULL)
936 ubd_set_bit(i, (unsigned char *) cow_mask);
937 if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
938 continue;
946 939
947 for(i = 0; i < req->length / req->sectorsize; i++){ 940 update_bitmap = 1;
948 if(ubd_test_bit(sector + i, bitmap)) 941 ubd_set_bit(sector + i, (unsigned char *) bitmap);
949 continue; 942 }
943
944 if(!update_bitmap)
945 return;
950 946
951 if(req->bitmap_start == -1) 947 *cow_offset = sector / (sizeof(unsigned long) * 8);
952 req->bitmap_start = sector + i;
953 req->bitmap_end = sector + i + 1;
954 948
955 ubd_set_bit(sector + i, bitmap); 949 /* This takes care of the case where we're exactly at the end of the
956 } 950 * device, and *cow_offset + 1 is off the end. So, just back it up
951 * by one word. Thanks to Lynn Kerby for the fix and James McMechan
952 * for the original diagnosis.
953 */
954 if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) /
955 sizeof(unsigned long) - 1))
956 (*cow_offset)--;
957
958 bitmap_words[0] = bitmap[*cow_offset];
959 bitmap_words[1] = bitmap[*cow_offset + 1];
960
961 *cow_offset *= sizeof(unsigned long);
962 *cow_offset += bitmap_offset;
963}
964
965static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
966 __u64 bitmap_offset, __u64 bitmap_len)
967{
968 __u64 sector = req->offset >> 9;
969 int i;
970
971 if(req->length > (sizeof(req->sector_mask) * 8) << 9)
972 panic("Operation too long");
973
974 if(req->op == UBD_READ) {
975 for(i = 0; i < req->length >> 9; i++){
976 if(ubd_test_bit(sector + i, (unsigned char *) bitmap))
977 ubd_set_bit(i, (unsigned char *)
978 &req->sector_mask);
979 }
980 }
981 else cowify_bitmap(req->offset, req->length, &req->sector_mask,
982 &req->cow_offset, bitmap, bitmap_offset,
983 req->bitmap_words, bitmap_len);
957} 984}
958 985
959/* Called with ubd_io_lock held */ 986/* Called with ubd_io_lock held */
960static int prepare_request(struct request *req, struct io_thread_req *io_req, 987static int prepare_request(struct request *req, struct io_thread_req *io_req)
961 unsigned long long offset, int page_offset,
962 int len, struct page *page)
963{ 988{
964 struct gendisk *disk = req->rq_disk; 989 struct gendisk *disk = req->rq_disk;
965 struct ubd *dev = disk->private_data; 990 struct ubd *dev = disk->private_data;
991 __u64 offset;
992 int len;
993
994 if(req->rq_status == RQ_INACTIVE) return(1);
966 995
967 /* This should be impossible now */ 996 /* This should be impossible now */
968 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ 997 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
969 printk("Write attempted on readonly ubd device %s\n", 998 printk("Write attempted on readonly ubd device %s\n",
970 disk->disk_name); 999 disk->disk_name);
971 ubd_end_request(req, 0, 0); 1000 end_request(req, 0);
972 return(1); 1001 return(1);
973 } 1002 }
974 1003
1004 offset = ((__u64) req->sector) << 9;
1005 len = req->current_nr_sectors << 9;
1006
975 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; 1007 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd;
976 io_req->fds[1] = dev->fd; 1008 io_req->fds[1] = dev->fd;
1009 io_req->cow_offset = -1;
977 io_req->offset = offset; 1010 io_req->offset = offset;
978 io_req->length = len; 1011 io_req->length = len;
979 io_req->error = 0; 1012 io_req->error = 0;
980 io_req->op = (rq_data_dir(req) == READ) ? AIO_READ : AIO_WRITE; 1013 io_req->sector_mask = 0;
1014
1015 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;
981 io_req->offsets[0] = 0; 1016 io_req->offsets[0] = 0;
982 io_req->offsets[1] = dev->cow.data_offset; 1017 io_req->offsets[1] = dev->cow.data_offset;
983 io_req->buffer = page_address(page) + page_offset; 1018 io_req->buffer = req->buffer;
984 io_req->sectorsize = 1 << 9; 1019 io_req->sectorsize = 1 << 9;
985 io_req->bitmap_offset = dev->cow.bitmap_offset;
986 io_req->bitmap_start = -1;
987 io_req->bitmap_end = -1;
988 1020
989 if((dev->cow.file != NULL) && (io_req->op == UBD_WRITE)) 1021 if(dev->cow.file != NULL)
990 cowify_bitmap(io_req, dev->cow.bitmap); 1022 cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset,
1023 dev->cow.bitmap_len);
1024
991 return(0); 1025 return(0);
992} 1026}
993 1027
@@ -996,36 +1030,30 @@ static void do_ubd_request(request_queue_t *q)
996{ 1030{
997 struct io_thread_req io_req; 1031 struct io_thread_req io_req;
998 struct request *req; 1032 struct request *req;
999 __u64 sector; 1033 int err, n;
1000 int err; 1034
1001 1035 if(thread_fd == -1){
1002 if(in_ubd) 1036 while((req = elv_next_request(q)) != NULL){
1003 return; 1037 err = prepare_request(req, &io_req);
1004 in_ubd = 1; 1038 if(!err){
1005 while((req = elv_next_request(q)) != NULL){ 1039 do_io(&io_req);
1006 struct gendisk *disk = req->rq_disk; 1040 __ubd_finish(req, io_req.error);
1007 struct ubd *dev = disk->private_data; 1041 }
1008 int n, i; 1042 }
1009 1043 }
1010 blkdev_dequeue_request(req); 1044 else {
1011 1045 if(do_ubd || (req = elv_next_request(q)) == NULL)
1012 sector = req->sector; 1046 return;
1013 n = blk_rq_map_sg(q, req, dev->sg); 1047 err = prepare_request(req, &io_req);
1014 1048 if(!err){
1015 for(i = 0; i < n; i++){ 1049 do_ubd = ubd_handler;
1016 struct scatterlist *sg = &dev->sg[i]; 1050 n = os_write_file(thread_fd, (char *) &io_req,
1017 1051 sizeof(io_req));
1018 err = prepare_request(req, &io_req, sector << 9, 1052 if(n != sizeof(io_req))
1019 sg->offset, sg->length, 1053 printk("write to io thread failed, "
1020 sg->page); 1054 "errno = %d\n", -n);
1021 if(err)
1022 continue;
1023
1024 sector += sg->length >> 9;
1025 do_io(&io_req, req, dev->cow.bitmap);
1026 } 1055 }
1027 } 1056 }
1028 in_ubd = 0;
1029} 1057}
1030 1058
1031static int ubd_ioctl(struct inode * inode, struct file * file, 1059static int ubd_ioctl(struct inode * inode, struct file * file,
@@ -1241,95 +1269,131 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
1241 return(err); 1269 return(err);
1242} 1270}
1243 1271
1244void do_io(struct io_thread_req *req, struct request *r, unsigned long *bitmap) 1272static int update_bitmap(struct io_thread_req *req)
1245{ 1273{
1246 struct ubd_aio *aio; 1274 int n;
1247 struct bitmap_io *bitmap_io = NULL;
1248 char *buf;
1249 void *bitmap_buf = NULL;
1250 unsigned long len, sector;
1251 int nsectors, start, end, bit, err;
1252 __u64 off;
1253
1254 if(req->bitmap_start != -1){
1255 /* Round up to the nearest word */
1256 int round = sizeof(unsigned long);
1257 len = (req->bitmap_end - req->bitmap_start +
1258 round * 8 - 1) / (round * 8);
1259 len *= round;
1260
1261 off = req->bitmap_start / (8 * round);
1262 off *= round;
1263
1264 bitmap_io = kmalloc(sizeof(*bitmap_io), GFP_KERNEL);
1265 if(bitmap_io == NULL){
1266 printk("Failed to kmalloc bitmap IO\n");
1267 req->error = 1;
1268 return;
1269 }
1270 1275
1271 bitmap_buf = kmalloc(len, GFP_KERNEL); 1276 if(req->cow_offset == -1)
1272 if(bitmap_buf == NULL){ 1277 return(0);
1273 printk("do_io : kmalloc of bitmap chunk "
1274 "failed\n");
1275 kfree(bitmap_io);
1276 req->error = 1;
1277 return;
1278 }
1279 memcpy(bitmap_buf, &bitmap[off / sizeof(bitmap[0])], len);
1280
1281 *bitmap_io = ((struct bitmap_io)
1282 { .count = ATOMIC_INIT(0),
1283 .aio = INIT_AIO(AIO_WRITE, req->fds[1],
1284 bitmap_buf, len,
1285 req->bitmap_offset + off,
1286 ubd_reply_fd) } );
1287 }
1288 1278
1289 nsectors = req->length / req->sectorsize; 1279 n = os_seek_file(req->fds[1], req->cow_offset);
1290 start = 0; 1280 if(n < 0){
1291 end = nsectors; 1281 printk("do_io - bitmap lseek failed : err = %d\n", -n);
1292 bit = 0; 1282 return(1);
1293 do { 1283 }
1294 if(bitmap != NULL){
1295 sector = req->offset / req->sectorsize;
1296 bit = ubd_test_bit(sector + start, bitmap);
1297 end = start;
1298 while((end < nsectors) &&
1299 (ubd_test_bit(sector + end, bitmap) == bit))
1300 end++;
1301 }
1302 1284
1303 off = req->offsets[bit] + req->offset + 1285 n = os_write_file(req->fds[1], &req->bitmap_words,
1304 start * req->sectorsize; 1286 sizeof(req->bitmap_words));
1305 len = (end - start) * req->sectorsize; 1287 if(n != sizeof(req->bitmap_words)){
1306 buf = &req->buffer[start * req->sectorsize]; 1288 printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
1289 req->fds[1]);
1290 return(1);
1291 }
1307 1292
1308 aio = kmalloc(sizeof(*aio), GFP_KERNEL); 1293 return(0);
1309 if(aio == NULL){ 1294}
1310 req->error = 1;
1311 return;
1312 }
1313 1295
1314 *aio = ((struct ubd_aio) 1296void do_io(struct io_thread_req *req)
1315 { .aio = INIT_AIO(req->op, req->fds[bit], buf, 1297{
1316 len, off, ubd_reply_fd), 1298 char *buf;
1317 .len = len, 1299 unsigned long len;
1318 .req = r, 1300 int n, nsectors, start, end, bit;
1319 .bitmap = bitmap_io, 1301 int err;
1320 .bitmap_buf = bitmap_buf }); 1302 __u64 off;
1321 1303
1322 if(aio->bitmap != NULL) 1304 nsectors = req->length / req->sectorsize;
1323 atomic_inc(&aio->bitmap->count); 1305 start = 0;
1324 1306 do {
1325 err = submit_aio(&aio->aio); 1307 bit = ubd_test_bit(start, (unsigned char *) &req->sector_mask);
1326 if(err){ 1308 end = start;
1327 printk("do_io - submit_aio failed, " 1309 while((end < nsectors) &&
1328 "err = %d\n", err); 1310 (ubd_test_bit(end, (unsigned char *)
1329 req->error = 1; 1311 &req->sector_mask) == bit))
1330 return; 1312 end++;
1331 } 1313
1314 off = req->offset + req->offsets[bit] +
1315 start * req->sectorsize;
1316 len = (end - start) * req->sectorsize;
1317 buf = &req->buffer[start * req->sectorsize];
1318
1319 err = os_seek_file(req->fds[bit], off);
1320 if(err < 0){
1321 printk("do_io - lseek failed : err = %d\n", -err);
1322 req->error = 1;
1323 return;
1324 }
1325 if(req->op == UBD_READ){
1326 n = 0;
1327 do {
1328 buf = &buf[n];
1329 len -= n;
1330 n = os_read_file(req->fds[bit], buf, len);
1331 if (n < 0) {
1332 printk("do_io - read failed, err = %d "
1333 "fd = %d\n", -n, req->fds[bit]);
1334 req->error = 1;
1335 return;
1336 }
1337 } while((n < len) && (n != 0));
1338 if (n < len) memset(&buf[n], 0, len - n);
1339 } else {
1340 n = os_write_file(req->fds[bit], buf, len);
1341 if(n != len){
1342 printk("do_io - write failed err = %d "
1343 "fd = %d\n", -n, req->fds[bit]);
1344 req->error = 1;
1345 return;
1346 }
1347 }
1348
1349 start = end;
1350 } while(start < nsectors);
1332 1351
1333 start = end; 1352 req->error = update_bitmap(req);
1334 } while(start < nsectors);
1335} 1353}
1354
1355/* Changed in start_io_thread, which is serialized by being called only
1356 * from ubd_init, which is an initcall.
1357 */
1358int kernel_fd = -1;
1359
1360/* Only changed by the io thread */
1361int io_count = 0;
1362
1363int io_thread(void *arg)
1364{
1365 struct io_thread_req req;
1366 int n;
1367
1368 ignore_sigwinch_sig();
1369 while(1){
1370 n = os_read_file(kernel_fd, &req, sizeof(req));
1371 if(n != sizeof(req)){
1372 if(n < 0)
1373 printk("io_thread - read failed, fd = %d, "
1374 "err = %d\n", kernel_fd, -n);
1375 else {
1376 printk("io_thread - short read, fd = %d, "
1377 "length = %d\n", kernel_fd, n);
1378 }
1379 continue;
1380 }
1381 io_count++;
1382 do_io(&req);
1383 n = os_write_file(kernel_fd, &req, sizeof(req));
1384 if(n != sizeof(req))
1385 printk("io_thread - write failed, fd = %d, err = %d\n",
1386 kernel_fd, -n);
1387 }
1388}
1389
1390/*
1391 * Overrides for Emacs so that we follow Linus's tabbing style.
1392 * Emacs will notice this stuff at the end of the file and automatically
1393 * adjust the settings for this buffer only. This must remain at the end
1394 * of the file.
1395 * ---------------------------------------------------------------------------
1396 * Local variables:
1397 * c-file-style: "linux"
1398 * End:
1399 */
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index 93dc1911363f..90e0e5ff451e 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -110,13 +110,15 @@ int xterm_open(int input, int output, int primary, void *d,
110 110
111 fd = mkstemp(file); 111 fd = mkstemp(file);
112 if(fd < 0){ 112 if(fd < 0){
113 err = -errno;
113 printk("xterm_open : mkstemp failed, errno = %d\n", errno); 114 printk("xterm_open : mkstemp failed, errno = %d\n", errno);
114 return(-errno); 115 return err;
115 } 116 }
116 117
117 if(unlink(file)){ 118 if(unlink(file)){
119 err = -errno;
118 printk("xterm_open : unlink failed, errno = %d\n", errno); 120 printk("xterm_open : unlink failed, errno = %d\n", errno);
119 return(-errno); 121 return err;
120 } 122 }
121 os_close_file(fd); 123 os_close_file(fd);
122 124
diff --git a/arch/um/include/aio.h b/arch/um/include/aio.h
index 83f16877ab08..423bae9153f8 100644
--- a/arch/um/include/aio.h
+++ b/arch/um/include/aio.h
@@ -14,27 +14,15 @@ struct aio_thread_reply {
14}; 14};
15 15
16struct aio_context { 16struct aio_context {
17 enum aio_type type;
18 int fd;
19 void *data;
20 int len;
21 unsigned long long offset;
22 int reply_fd; 17 int reply_fd;
23 struct aio_context *next; 18 struct aio_context *next;
24}; 19};
25 20
26#define INIT_AIO(aio_type, aio_fd, aio_data, aio_len, aio_offset, \
27 aio_reply_fd) \
28 { .type = aio_type, \
29 .fd = aio_fd, \
30 .data = aio_data, \
31 .len = aio_len, \
32 .offset = aio_offset, \
33 .reply_fd = aio_reply_fd }
34
35#define INIT_AIO_CONTEXT { .reply_fd = -1, \ 21#define INIT_AIO_CONTEXT { .reply_fd = -1, \
36 .next = NULL } 22 .next = NULL }
37 23
38extern int submit_aio(struct aio_context *aio); 24extern int submit_aio(enum aio_type type, int fd, char *buf, int len,
25 unsigned long long offset, int reply_fd,
26 struct aio_context *aio);
39 27
40#endif 28#endif
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h
index 0aa620970adb..356390d1f8b9 100644
--- a/arch/um/include/common-offsets.h
+++ b/arch/um/include/common-offsets.h
@@ -1,7 +1,7 @@
1/* for use by sys-$SUBARCH/kernel-offsets.c */ 1/* for use by sys-$SUBARCH/kernel-offsets.c */
2 2
3OFFSET(TASK_REGS, task_struct, thread.regs); 3OFFSET(HOST_TASK_REGS, task_struct, thread.regs);
4OFFSET(TASK_PID, task_struct, pid); 4OFFSET(HOST_TASK_PID, task_struct, pid);
5DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); 5DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
6DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); 6DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
7DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); 7DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
@@ -12,4 +12,6 @@ DEFINE_STR(UM_KERN_WARNING, KERN_WARNING);
12DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); 12DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE);
13DEFINE_STR(UM_KERN_INFO, KERN_INFO); 13DEFINE_STR(UM_KERN_INFO, KERN_INFO);
14DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); 14DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
15DEFINE(HOST_ELF_CLASS, ELF_CLASS); 15DEFINE(UM_ELF_CLASS, ELF_CLASS);
16DEFINE(UM_ELFCLASS32, ELFCLASS32);
17DEFINE(UM_ELFCLASS64, ELFCLASS64);
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h
index cfa368e045a5..b1b512f47035 100644
--- a/arch/um/include/mconsole.h
+++ b/arch/um/include/mconsole.h
@@ -81,6 +81,7 @@ extern void mconsole_stop(struct mc_request *req);
81extern void mconsole_go(struct mc_request *req); 81extern void mconsole_go(struct mc_request *req);
82extern void mconsole_log(struct mc_request *req); 82extern void mconsole_log(struct mc_request *req);
83extern void mconsole_proc(struct mc_request *req); 83extern void mconsole_proc(struct mc_request *req);
84extern void mconsole_stack(struct mc_request *req);
84 85
85extern int mconsole_get_request(int fd, struct mc_request *req); 86extern int mconsole_get_request(int fd, struct mc_request *req);
86extern int mconsole_notify(char *sock_name, int type, const void *data, 87extern int mconsole_notify(char *sock_name, int type, const void *data,
diff --git a/arch/um/include/mem_user.h b/arch/um/include/mem_user.h
index d6404bb64662..9fef4123a65a 100644
--- a/arch/um/include/mem_user.h
+++ b/arch/um/include/mem_user.h
@@ -51,7 +51,6 @@ extern unsigned long task_size;
51 51
52extern void check_devanon(void); 52extern void check_devanon(void);
53extern int init_mem_user(void); 53extern int init_mem_user(void);
54extern int create_mem_file(unsigned long len);
55extern void setup_memory(void *entry); 54extern void setup_memory(void *entry);
56extern unsigned long find_iomem(char *driver, unsigned long *len_out); 55extern unsigned long find_iomem(char *driver, unsigned long *len_out);
57extern int init_maps(unsigned long physmem, unsigned long iomem, 56extern int init_maps(unsigned long physmem, unsigned long iomem,
@@ -64,20 +63,6 @@ extern unsigned long phys_offset(unsigned long phys);
64extern void unmap_physmem(void); 63extern void unmap_physmem(void);
65extern void map_memory(unsigned long virt, unsigned long phys, 64extern void map_memory(unsigned long virt, unsigned long phys,
66 unsigned long len, int r, int w, int x); 65 unsigned long len, int r, int w, int x);
67extern int protect_memory(unsigned long addr, unsigned long len,
68 int r, int w, int x, int must_succeed);
69extern unsigned long get_kmem_end(void); 66extern unsigned long get_kmem_end(void);
70extern void check_tmpexec(void);
71 67
72#endif 68#endif
73
74/*
75 * Overrides for Emacs so that we follow Linus's tabbing style.
76 * Emacs will notice this stuff at the end of the file and automatically
77 * adjust the settings for this buffer only. This must remain at the end
78 * of the file.
79 * ---------------------------------------------------------------------------
80 * Local variables:
81 * c-file-style: "linux"
82 * End:
83 */
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 4c362458052c..2e58e304b8be 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -6,6 +6,7 @@
6#ifndef __OS_H__ 6#ifndef __OS_H__
7#define __OS_H__ 7#define __OS_H__
8 8
9#include "uml-config.h"
9#include "asm/types.h" 10#include "asm/types.h"
10#include "../os/include/file.h" 11#include "../os/include/file.h"
11 12
@@ -157,6 +158,17 @@ extern int os_lock_file(int fd, int excl);
157extern void os_early_checks(void); 158extern void os_early_checks(void);
158extern int can_do_skas(void); 159extern int can_do_skas(void);
159 160
161/* Make sure they are clear when running in TT mode. Required by
162 * SEGV_MAYBE_FIXABLE */
163#ifdef UML_CONFIG_MODE_SKAS
164#define clear_can_do_skas() do { ptrace_faultinfo = proc_mm = 0; } while (0)
165#else
166#define clear_can_do_skas() do {} while (0)
167#endif
168
169/* mem.c */
170extern int create_mem_file(unsigned long len);
171
160/* process.c */ 172/* process.c */
161extern unsigned long os_process_pc(int pid); 173extern unsigned long os_process_pc(int pid);
162extern int os_process_parent(int pid); 174extern int os_process_parent(int pid);
@@ -181,6 +193,8 @@ extern unsigned long long os_usecs(void);
181/* tt.c 193/* tt.c
182 * for tt mode only (will be deleted in future...) 194 * for tt mode only (will be deleted in future...)
183 */ 195 */
196extern int protect_memory(unsigned long addr, unsigned long len,
197 int r, int w, int x, int must_succeed);
184extern void forward_pending_sigio(int target); 198extern void forward_pending_sigio(int target);
185extern int start_fork_tramp(void *arg, unsigned long temp_stack, 199extern int start_fork_tramp(void *arg, unsigned long temp_stack,
186 int clone_flags, int (*tramp)(void *)); 200 int clone_flags, int (*tramp)(void *));
diff --git a/arch/um/include/registers.h b/arch/um/include/registers.h
index 0a35e6d0baa0..4892e5fcef07 100644
--- a/arch/um/include/registers.h
+++ b/arch/um/include/registers.h
@@ -15,16 +15,6 @@ extern void save_registers(int pid, union uml_pt_regs *regs);
15extern void restore_registers(int pid, union uml_pt_regs *regs); 15extern void restore_registers(int pid, union uml_pt_regs *regs);
16extern void init_registers(int pid); 16extern void init_registers(int pid);
17extern void get_safe_registers(unsigned long * regs); 17extern void get_safe_registers(unsigned long * regs);
18extern void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer);
18 19
19#endif 20#endif
20
21/*
22 * Overrides for Emacs so that we follow Linus's tabbing style.
23 * Emacs will notice this stuff at the end of the file and automatically
24 * adjust the settings for this buffer only. This must remain at the end
25 * of the file.
26 * ---------------------------------------------------------------------------
27 * Local variables:
28 * c-file-style: "linux"
29 * End:
30 */
diff --git a/arch/um/include/skas_ptregs.h b/arch/um/include/skas_ptregs.h
new file mode 100644
index 000000000000..73db19e9c077
--- /dev/null
+++ b/arch/um/include/skas_ptregs.h
@@ -0,0 +1,6 @@
1#ifndef __SKAS_PT_REGS_
2#define __SKAS_PT_REGS_
3
4#include <user_constants.h>
5
6#endif
diff --git a/arch/um/include/sysdep-i386/sc.h b/arch/um/include/sysdep-i386/sc.h
new file mode 100644
index 000000000000..c57d1780ad37
--- /dev/null
+++ b/arch/um/include/sysdep-i386/sc.h
@@ -0,0 +1,44 @@
1#ifndef __SYSDEP_I386_SC_H
2#define __SYSDEP_I386_SC_H
3
4#include <user_constants.h>
5
6#define SC_OFFSET(sc, field) \
7 *((unsigned long *) &(((char *) (sc))[HOST_##field]))
8#define SC_FP_OFFSET(sc, field) \
9 *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field]))
10#define SC_FP_OFFSET_PTR(sc, field, type) \
11 ((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field]))
12
13#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
14#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
15#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
16#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
17#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
18#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
19#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
20#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
21#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
22#define SC_EAX(sc) SC_OFFSET(sc, SC_EAX)
23#define SC_EBX(sc) SC_OFFSET(sc, SC_EBX)
24#define SC_ECX(sc) SC_OFFSET(sc, SC_ECX)
25#define SC_EDX(sc) SC_OFFSET(sc, SC_EDX)
26#define SC_EDI(sc) SC_OFFSET(sc, SC_EDI)
27#define SC_ESI(sc) SC_OFFSET(sc, SC_ESI)
28#define SC_EBP(sc) SC_OFFSET(sc, SC_EBP)
29#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
30#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
31#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
32#define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE)
33#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
34#define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW)
35#define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW)
36#define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG)
37#define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF)
38#define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL)
39#define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF)
40#define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL)
41#define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate)
42#define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void)
43
44#endif
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h
index 1fe729265167..23fd2644d7ed 100644
--- a/arch/um/include/sysdep-i386/sigcontext.h
+++ b/arch/um/include/sysdep-i386/sigcontext.h
@@ -6,6 +6,7 @@
6#ifndef __SYS_SIGCONTEXT_I386_H 6#ifndef __SYS_SIGCONTEXT_I386_H
7#define __SYS_SIGCONTEXT_I386_H 7#define __SYS_SIGCONTEXT_I386_H
8 8
9#include "uml-config.h"
9#include <sysdep/sc.h> 10#include <sysdep/sc.h>
10 11
11#define IP_RESTART_SYSCALL(ip) ((ip) -= 2) 12#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
@@ -26,7 +27,14 @@
26#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) 27#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
27 28
28/* This is Page Fault */ 29/* This is Page Fault */
29#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) 30#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
31
32/* SKAS3 has no trap_no on i386, but get_skas_faultinfo() sets it to 0. */
33#ifdef UML_CONFIG_MODE_SKAS
34#define SEGV_MAYBE_FIXABLE(fi) ((fi)->trap_no == 0 && ptrace_faultinfo)
35#else
36#define SEGV_MAYBE_FIXABLE(fi) 0
37#endif
30 38
31extern unsigned long *sc_sigmask(void *sc_ptr); 39extern unsigned long *sc_sigmask(void *sc_ptr);
32extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); 40extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
diff --git a/arch/um/include/sysdep-i386/thread.h b/arch/um/include/sysdep-i386/thread.h
new file mode 100644
index 000000000000..243fed44d780
--- /dev/null
+++ b/arch/um/include/sysdep-i386/thread.h
@@ -0,0 +1,11 @@
1#ifndef __UM_THREAD_H
2#define __UM_THREAD_H
3
4#include <kern_constants.h>
5
6#define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS]))
7#ifdef UML_CONFIG_MODE_TT
8#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
9#endif
10
11#endif
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 331aa2d1f3f5..8d353f0feec1 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -183,10 +183,6 @@ struct syscall_args {
183 case RBP: val = UPT_RBP(regs); break; \ 183 case RBP: val = UPT_RBP(regs); break; \
184 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ 184 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
185 case CS: val = UPT_CS(regs); break; \ 185 case CS: val = UPT_CS(regs); break; \
186 case DS: val = UPT_DS(regs); break; \
187 case ES: val = UPT_ES(regs); break; \
188 case FS: val = UPT_FS(regs); break; \
189 case GS: val = UPT_GS(regs); break; \
190 case EFLAGS: val = UPT_EFLAGS(regs); break; \ 186 case EFLAGS: val = UPT_EFLAGS(regs); break; \
191 default : \ 187 default : \
192 panic("Bad register in UPT_REG : %d\n", reg); \ 188 panic("Bad register in UPT_REG : %d\n", reg); \
@@ -218,10 +214,6 @@ struct syscall_args {
218 case RBP: UPT_RBP(regs) = __upt_val; break; \ 214 case RBP: UPT_RBP(regs) = __upt_val; break; \
219 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ 215 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
220 case CS: UPT_CS(regs) = __upt_val; break; \ 216 case CS: UPT_CS(regs) = __upt_val; break; \
221 case DS: UPT_DS(regs) = __upt_val; break; \
222 case ES: UPT_ES(regs) = __upt_val; break; \
223 case FS: UPT_FS(regs) = __upt_val; break; \
224 case GS: UPT_GS(regs) = __upt_val; break; \
225 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ 217 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
226 default : \ 218 default : \
227 panic("Bad register in UPT_SET : %d\n", reg); \ 219 panic("Bad register in UPT_SET : %d\n", reg); \
diff --git a/arch/um/include/sysdep-x86_64/sc.h b/arch/um/include/sysdep-x86_64/sc.h
new file mode 100644
index 000000000000..a160d9fcc596
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/sc.h
@@ -0,0 +1,45 @@
1#ifndef __SYSDEP_X86_64_SC_H
2#define __SYSDEP_X86_64_SC_H
3
4/* Copyright (C) 2003 - 2004 PathScale, Inc
5 * Released under the GPL
6 */
7
8#include <user_constants.h>
9
10#define SC_OFFSET(sc, field) \
11 *((unsigned long *) &(((char *) (sc))[HOST_##field]))
12
13#define SC_RBX(sc) SC_OFFSET(sc, SC_RBX)
14#define SC_RCX(sc) SC_OFFSET(sc, SC_RCX)
15#define SC_RDX(sc) SC_OFFSET(sc, SC_RDX)
16#define SC_RSI(sc) SC_OFFSET(sc, SC_RSI)
17#define SC_RDI(sc) SC_OFFSET(sc, SC_RDI)
18#define SC_RBP(sc) SC_OFFSET(sc, SC_RBP)
19#define SC_RAX(sc) SC_OFFSET(sc, SC_RAX)
20#define SC_R8(sc) SC_OFFSET(sc, SC_R8)
21#define SC_R9(sc) SC_OFFSET(sc, SC_R9)
22#define SC_R10(sc) SC_OFFSET(sc, SC_R10)
23#define SC_R11(sc) SC_OFFSET(sc, SC_R11)
24#define SC_R12(sc) SC_OFFSET(sc, SC_R12)
25#define SC_R13(sc) SC_OFFSET(sc, SC_R13)
26#define SC_R14(sc) SC_OFFSET(sc, SC_R14)
27#define SC_R15(sc) SC_OFFSET(sc, SC_R15)
28#define SC_IP(sc) SC_OFFSET(sc, SC_IP)
29#define SC_SP(sc) SC_OFFSET(sc, SC_SP)
30#define SC_CR2(sc) SC_OFFSET(sc, SC_CR2)
31#define SC_ERR(sc) SC_OFFSET(sc, SC_ERR)
32#define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO)
33#define SC_CS(sc) SC_OFFSET(sc, SC_CS)
34#define SC_FS(sc) SC_OFFSET(sc, SC_FS)
35#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
36#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
37#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
38#if 0
39#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX)
40#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
41#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
42#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
43#endif
44
45#endif
diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/include/sysdep-x86_64/sigcontext.h
index 2a78260d15a0..41073235e7ad 100644
--- a/arch/um/include/sysdep-x86_64/sigcontext.h
+++ b/arch/um/include/sysdep-x86_64/sigcontext.h
@@ -31,7 +31,10 @@
31#define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0) 31#define SC_START_SYSCALL(sc) do SC_RAX(sc) = -ENOSYS; while(0)
32 32
33/* This is Page Fault */ 33/* This is Page Fault */
34#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14) 34#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
35
36/* No broken SKAS API, which doesn't pass trap_no, here. */
37#define SEGV_MAYBE_FIXABLE(fi) 0
35 38
36extern unsigned long *sc_sigmask(void *sc_ptr); 39extern unsigned long *sc_sigmask(void *sc_ptr);
37 40
diff --git a/arch/um/include/sysdep-x86_64/thread.h b/arch/um/include/sysdep-x86_64/thread.h
new file mode 100644
index 000000000000..cbef3e1697f4
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/thread.h
@@ -0,0 +1,10 @@
1#ifndef __UM_THREAD_H
2#define __UM_THREAD_H
3
4#include <kern_constants.h>
5
6#ifdef UML_CONFIG_MODE_TT
7#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID]))
8#endif
9
10#endif
diff --git a/arch/um/include/task.h b/arch/um/include/task.h
new file mode 100644
index 000000000000..6375ba7203c9
--- /dev/null
+++ b/arch/um/include/task.h
@@ -0,0 +1,9 @@
1#ifndef __TASK_H
2#define __TASK_H
3
4#include <kern_constants.h>
5
6#define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
7#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID]))
8
9#endif
diff --git a/arch/um/include/user.h b/arch/um/include/user.h
index 57ee9e261228..0f865ef46918 100644
--- a/arch/um/include/user.h
+++ b/arch/um/include/user.h
@@ -14,7 +14,9 @@ extern void *um_kmalloc_atomic(int size);
14extern void kfree(void *ptr); 14extern void kfree(void *ptr);
15extern int in_aton(char *str); 15extern int in_aton(char *str);
16extern int open_gdb_chan(void); 16extern int open_gdb_chan(void);
17extern int strlcpy(char *, const char *, int); 17/* These use size_t, however unsigned long is correct on both i386 and x86_64. */
18extern unsigned long strlcpy(char *, const char *, unsigned long);
19extern unsigned long strlcat(char *, const char *, unsigned long);
18extern void *um_vmalloc(int size); 20extern void *um_vmalloc(int size);
19extern void vfree(void *ptr); 21extern void vfree(void *ptr);
20 22
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index 614b8ebeb0ed..1a0001b3850c 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -1,4 +1,4 @@
1# 1#
2# Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
@@ -7,11 +7,11 @@ extra-y := vmlinux.lds
7clean-files := 7clean-files :=
8 8
9obj-y = config.o exec_kern.o exitcode.o \ 9obj-y = config.o exec_kern.o exitcode.o \
10 helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o mem_user.o \ 10 helper.o init_task.o irq.o irq_user.o ksyms.o main.o mem.o physmem.o \
11 physmem.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \ 11 process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \
12 sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o \ 12 signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \
13 tempfile.o time.o time_kern.o tlb.o trap_kern.o trap_user.o \ 13 time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \
14 uaccess_user.o um_arch.o umid.o user_util.o 14 umid.o user_util.o
15 15
16obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 16obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
17obj-$(CONFIG_GPROF) += gprof_syms.o 17obj-$(CONFIG_GPROF) += gprof_syms.o
@@ -24,8 +24,8 @@ obj-$(CONFIG_MODE_SKAS) += skas/
24 24
25user-objs-$(CONFIG_TTY_LOG) += tty_log.o 25user-objs-$(CONFIG_TTY_LOG) += tty_log.o
26 26
27USER_OBJS := $(user-objs-y) config.o helper.o main.o tempfile.o time.o \ 27USER_OBJS := $(user-objs-y) config.o helper.o main.o time.o tty_log.o umid.o \
28 tty_log.o umid.o user_util.o 28 user_util.o
29 29
30include arch/um/scripts/Makefile.rules 30include arch/um/scripts/Makefile.rules
31 31
diff --git a/arch/um/kernel/helper.c b/arch/um/kernel/helper.c
index f83e1e8e2392..33fb0bd3b11a 100644
--- a/arch/um/kernel/helper.c
+++ b/arch/um/kernel/helper.c
@@ -85,8 +85,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
85 data.fd = fds[1]; 85 data.fd = fds[1];
86 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); 86 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
87 if(pid < 0){ 87 if(pid < 0){
88 printk("run_helper : clone failed, errno = %d\n", errno);
89 ret = -errno; 88 ret = -errno;
89 printk("run_helper : clone failed, errno = %d\n", errno);
90 goto out_close; 90 goto out_close;
91 } 91 }
92 92
@@ -122,7 +122,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
122 unsigned long *stack_out, int stack_order) 122 unsigned long *stack_out, int stack_order)
123{ 123{
124 unsigned long stack, sp; 124 unsigned long stack, sp;
125 int pid, status; 125 int pid, status, err;
126 126
127 stack = alloc_stack(stack_order, um_in_interrupt()); 127 stack = alloc_stack(stack_order, um_in_interrupt());
128 if(stack == 0) return(-ENOMEM); 128 if(stack == 0) return(-ENOMEM);
@@ -130,16 +130,18 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
130 sp = stack + (page_size() << stack_order) - sizeof(void *); 130 sp = stack + (page_size() << stack_order) - sizeof(void *);
131 pid = clone(proc, (void *) sp, flags | SIGCHLD, arg); 131 pid = clone(proc, (void *) sp, flags | SIGCHLD, arg);
132 if(pid < 0){ 132 if(pid < 0){
133 err = -errno;
133 printk("run_helper_thread : clone failed, errno = %d\n", 134 printk("run_helper_thread : clone failed, errno = %d\n",
134 errno); 135 errno);
135 return(-errno); 136 return err;
136 } 137 }
137 if(stack_out == NULL){ 138 if(stack_out == NULL){
138 CATCH_EINTR(pid = waitpid(pid, &status, 0)); 139 CATCH_EINTR(pid = waitpid(pid, &status, 0));
139 if(pid < 0){ 140 if(pid < 0){
141 err = -errno;
140 printk("run_helper_thread - wait failed, errno = %d\n", 142 printk("run_helper_thread - wait failed, errno = %d\n",
141 errno); 143 errno);
142 pid = -errno; 144 pid = err;
143 } 145 }
144 if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) 146 if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
145 printk("run_helper_thread - thread returned status " 147 printk("run_helper_thread - thread returned status "
@@ -156,8 +158,8 @@ int helper_wait(int pid)
156 158
157 CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG)); 159 CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG));
158 if(ret < 0){ 160 if(ret < 0){
161 ret = -errno;
159 printk("helper_wait : waitpid failed, errno = %d\n", errno); 162 printk("helper_wait : waitpid failed, errno = %d\n", errno);
160 return(-errno);
161 } 163 }
162 return(ret); 164 return(ret);
163} 165}
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c
index cd7c85be0a1b..49ed5ddf0704 100644
--- a/arch/um/kernel/init_task.c
+++ b/arch/um/kernel/init_task.c
@@ -13,6 +13,7 @@
13#include "asm/pgtable.h" 13#include "asm/pgtable.h"
14#include "user_util.h" 14#include "user_util.h"
15#include "mem_user.h" 15#include "mem_user.h"
16#include "os.h"
16 17
17static struct fs_struct init_fs = INIT_FS; 18static struct fs_struct init_fs = INIT_FS;
18struct mm_struct init_mm = INIT_MM(init_mm); 19struct mm_struct init_mm = INIT_MM(init_mm);
@@ -45,8 +46,8 @@ __attribute__((__section__(".data.init_task"))) =
45 46
46void unprotect_stack(unsigned long stack) 47void unprotect_stack(unsigned long stack)
47{ 48{
48 protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, 49 os_protect_memory((void *) stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE,
49 1, 1, 0, 1); 50 1, 1, 0);
50} 51}
51 52
52/* 53/*
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index dcd814971995..bbf94bf2921e 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -9,7 +9,6 @@
9#include "linux/kernel.h" 9#include "linux/kernel.h"
10#include "linux/module.h" 10#include "linux/module.h"
11#include "linux/smp.h" 11#include "linux/smp.h"
12#include "linux/irq.h"
13#include "linux/kernel_stat.h" 12#include "linux/kernel_stat.h"
14#include "linux/interrupt.h" 13#include "linux/interrupt.h"
15#include "linux/random.h" 14#include "linux/random.h"
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 64fa062cc119..ea008b031a8f 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -19,6 +19,10 @@
19#include "mem_user.h" 19#include "mem_user.h"
20#include "uml_uaccess.h" 20#include "uml_uaccess.h"
21#include "os.h" 21#include "os.h"
22#include "linux/types.h"
23#include "linux/string.h"
24#include "init.h"
25#include "kern_constants.h"
22 26
23extern char __binary_start; 27extern char __binary_start;
24 28
@@ -368,6 +372,16 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
368 return pte; 372 return pte;
369} 373}
370 374
375struct iomem_region *iomem_regions = NULL;
376int iomem_size = 0;
377
378extern int parse_iomem(char *str, int *add) __init;
379
380__uml_setup("iomem=", parse_iomem,
381"iomem=<name>,<file>\n"
382" Configure <file> as an IO memory region named <name>.\n\n"
383);
384
371/* 385/*
372 * Overrides for Emacs so that we follow Linus's tabbing style. 386 * Overrides for Emacs so that we follow Linus's tabbing style.
373 * Emacs will notice this stuff at the end of the file and automatically 387 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/arch/um/kernel/mem_user.c b/arch/um/kernel/mem_user.c
deleted file mode 100644
index 4a663fd434bb..000000000000
--- a/arch/um/kernel/mem_user.c
+++ /dev/null
@@ -1,273 +0,0 @@
1/*
2 * arch/um/kernel/mem_user.c
3 *
4 * BRIEF MODULE DESCRIPTION
5 * user side memory routines for supporting IO memory inside user mode linux
6 *
7 * Copyright (C) 2001 RidgeRun, Inc.
8 * Author: RidgeRun, Inc.
9 * Greg Lonnon glonnon@ridgerun.com or info@ridgerun.com
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 */
31
32#include <stdio.h>
33#include <stdlib.h>
34#include <stddef.h>
35#include <stdarg.h>
36#include <unistd.h>
37#include <errno.h>
38#include <string.h>
39#include <fcntl.h>
40#include <sys/types.h>
41#include <sys/mman.h>
42#include "kern_util.h"
43#include "user.h"
44#include "user_util.h"
45#include "mem_user.h"
46#include "init.h"
47#include "os.h"
48#include "tempfile.h"
49#include "kern_constants.h"
50
51#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
52
53static int create_tmp_file(unsigned long len)
54{
55 int fd, err;
56 char zero;
57
58 fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1);
59 if(fd < 0) {
60 os_print_error(fd, "make_tempfile");
61 exit(1);
62 }
63
64 err = os_mode_fd(fd, 0777);
65 if(err < 0){
66 os_print_error(err, "os_mode_fd");
67 exit(1);
68 }
69 err = os_seek_file(fd, len);
70 if(err < 0){
71 os_print_error(err, "os_seek_file");
72 exit(1);
73 }
74 zero = 0;
75 err = os_write_file(fd, &zero, 1);
76 if(err != 1){
77 os_print_error(err, "os_write_file");
78 exit(1);
79 }
80
81 return(fd);
82}
83
84void check_tmpexec(void)
85{
86 void *addr;
87 int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE);
88
89 addr = mmap(NULL, UM_KERN_PAGE_SIZE,
90 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
91 printf("Checking PROT_EXEC mmap in /tmp...");
92 fflush(stdout);
93 if(addr == MAP_FAILED){
94 err = errno;
95 perror("failed");
96 if(err == EPERM)
97 printf("/tmp must be not mounted noexec\n");
98 exit(1);
99 }
100 printf("OK\n");
101 munmap(addr, UM_KERN_PAGE_SIZE);
102
103 os_close_file(fd);
104}
105
106static int have_devanon = 0;
107
108void check_devanon(void)
109{
110 int fd;
111
112 printk("Checking for /dev/anon on the host...");
113 fd = open("/dev/anon", O_RDWR);
114 if(fd < 0){
115 printk("Not available (open failed with errno %d)\n", errno);
116 return;
117 }
118
119 printk("OK\n");
120 have_devanon = 1;
121}
122
123static int create_anon_file(unsigned long len)
124{
125 void *addr;
126 int fd;
127
128 fd = open("/dev/anon", O_RDWR);
129 if(fd < 0) {
130 os_print_error(fd, "opening /dev/anon");
131 exit(1);
132 }
133
134 addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
135 if(addr == MAP_FAILED){
136 perror("mapping physmem file");
137 exit(1);
138 }
139 munmap(addr, len);
140
141 return(fd);
142}
143
144int create_mem_file(unsigned long len)
145{
146 int err, fd;
147
148 if(have_devanon)
149 fd = create_anon_file(len);
150 else fd = create_tmp_file(len);
151
152 err = os_set_exec_close(fd, 1);
153 if(err < 0)
154 os_print_error(err, "exec_close");
155 return(fd);
156}
157
158struct iomem_region *iomem_regions = NULL;
159int iomem_size = 0;
160
161static int __init parse_iomem(char *str, int *add)
162{
163 struct iomem_region *new;
164 struct uml_stat buf;
165 char *file, *driver;
166 int fd, err, size;
167
168 driver = str;
169 file = strchr(str,',');
170 if(file == NULL){
171 printf("parse_iomem : failed to parse iomem\n");
172 goto out;
173 }
174 *file = '\0';
175 file++;
176 fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0);
177 if(fd < 0){
178 os_print_error(fd, "parse_iomem - Couldn't open io file");
179 goto out;
180 }
181
182 err = os_stat_fd(fd, &buf);
183 if(err < 0){
184 os_print_error(err, "parse_iomem - cannot stat_fd file");
185 goto out_close;
186 }
187
188 new = malloc(sizeof(*new));
189 if(new == NULL){
190 perror("Couldn't allocate iomem_region struct");
191 goto out_close;
192 }
193
194 size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1);
195
196 *new = ((struct iomem_region) { .next = iomem_regions,
197 .driver = driver,
198 .fd = fd,
199 .size = size,
200 .phys = 0,
201 .virt = 0 });
202 iomem_regions = new;
203 iomem_size += new->size + UM_KERN_PAGE_SIZE;
204
205 return(0);
206 out_close:
207 os_close_file(fd);
208 out:
209 return(1);
210}
211
212__uml_setup("iomem=", parse_iomem,
213"iomem=<name>,<file>\n"
214" Configure <file> as an IO memory region named <name>.\n\n"
215);
216
217int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
218 int must_succeed)
219{
220 int err;
221
222 err = os_protect_memory((void *) addr, len, r, w, x);
223 if(err < 0){
224 if(must_succeed)
225 panic("protect failed, err = %d", -err);
226 else return(err);
227 }
228 return(0);
229}
230
231#if 0
232/* Debugging facility for dumping stuff out to the host, avoiding the timing
233 * problems that come with printf and breakpoints.
234 * Enable in case of emergency.
235 */
236
237int logging = 1;
238int logging_fd = -1;
239
240int logging_line = 0;
241char logging_buf[512];
242
243void log(char *fmt, ...)
244{
245 va_list ap;
246 struct timeval tv;
247 struct openflags flags;
248
249 if(logging == 0) return;
250 if(logging_fd < 0){
251 flags = of_create(of_trunc(of_rdwr(OPENFLAGS())));
252 logging_fd = os_open_file("log", flags, 0644);
253 }
254 gettimeofday(&tv, NULL);
255 sprintf(logging_buf, "%d\t %u.%u ", logging_line++, tv.tv_sec,
256 tv.tv_usec);
257 va_start(ap, fmt);
258 vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap);
259 va_end(ap);
260 write(logging_fd, logging_buf, strlen(logging_buf));
261}
262#endif
263
264/*
265 * Overrides for Emacs so that we follow Linus's tabbing style.
266 * Emacs will notice this stuff at the end of the file and automatically
267 * adjust the settings for this buffer only. This must remain at the end
268 * of the file.
269 * ---------------------------------------------------------------------------
270 * Local variables:
271 * c-file-style: "linux"
272 * End:
273 */
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index c23d8a08d0ff..ea65db679e9c 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -82,7 +82,8 @@ unsigned long alloc_stack(int order, int atomic)
82 unsigned long page; 82 unsigned long page;
83 int flags = GFP_KERNEL; 83 int flags = GFP_KERNEL;
84 84
85 if(atomic) flags |= GFP_ATOMIC; 85 if (atomic)
86 flags = GFP_ATOMIC;
86 page = __get_free_pages(flags, order); 87 page = __get_free_pages(flags, order);
87 if(page == 0) 88 if(page == 0)
88 return(0); 89 return(0);
@@ -113,8 +114,23 @@ void set_current(void *t)
113 114
114void *_switch_to(void *prev, void *next, void *last) 115void *_switch_to(void *prev, void *next, void *last)
115{ 116{
116 return(CHOOSE_MODE(switch_to_tt(prev, next), 117 struct task_struct *from = prev;
117 switch_to_skas(prev, next))); 118 struct task_struct *to= next;
119
120 to->thread.prev_sched = from;
121 set_current(to);
122
123 do {
124 current->thread.saved_task = NULL ;
125 CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next);
126 if(current->thread.saved_task)
127 show_regs(&(current->thread.regs));
128 next= current->thread.saved_task;
129 prev= current;
130 } while(current->thread.saved_task);
131
132 return(current->thread.prev_sched);
133
118} 134}
119 135
120void interrupt_end(void) 136void interrupt_end(void)
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c
index e89218958f38..a52751108aa1 100644
--- a/arch/um/kernel/sigio_user.c
+++ b/arch/um/kernel/sigio_user.c
@@ -340,7 +340,7 @@ static int setup_initial_poll(int fd)
340{ 340{
341 struct pollfd *p; 341 struct pollfd *p;
342 342
343 p = um_kmalloc(sizeof(struct pollfd)); 343 p = um_kmalloc_atomic(sizeof(struct pollfd));
344 if(p == NULL){ 344 if(p == NULL){
345 printk("setup_initial_poll : failed to allocate poll\n"); 345 printk("setup_initial_poll : failed to allocate poll\n");
346 return(-1); 346 return(-1);
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
index db36c7c95940..8de471b59c1c 100644
--- a/arch/um/kernel/skas/Makefile
+++ b/arch/um/kernel/skas/Makefile
@@ -6,8 +6,6 @@
6obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ 6obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
7 syscall.o tlb.o trap_user.o uaccess.o 7 syscall.o tlb.o trap_user.o uaccess.o
8 8
9subdir- := util
10
11USER_OBJS := process.o clone.o 9USER_OBJS := process.o clone.o
12 10
13include arch/um/scripts/Makefile.rules 11include arch/um/scripts/Makefile.rules
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h
index e48490028111..c97a80dfe370 100644
--- a/arch/um/kernel/skas/include/mode_kern-skas.h
+++ b/arch/um/kernel/skas/include/mode_kern-skas.h
@@ -11,7 +11,7 @@
11#include "asm/ptrace.h" 11#include "asm/ptrace.h"
12 12
13extern void flush_thread_skas(void); 13extern void flush_thread_skas(void);
14extern void *switch_to_skas(void *prev, void *next); 14extern void switch_to_skas(void *prev, void *next);
15extern void start_thread_skas(struct pt_regs *regs, unsigned long eip, 15extern void start_thread_skas(struct pt_regs *regs, unsigned long eip,
16 unsigned long esp); 16 unsigned long esp);
17extern int copy_thread_skas(int nr, unsigned long clone_flags, 17extern int copy_thread_skas(int nr, unsigned long clone_flags,
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h
index 6ee3f3902e68..7da0c2def0ef 100644
--- a/arch/um/kernel/skas/include/uaccess-skas.h
+++ b/arch/um/kernel/skas/include/uaccess-skas.h
@@ -18,12 +18,6 @@
18 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ 18 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
19 ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) 19 ((unsigned long) (addr) + (size) >= (unsigned long)(addr))))
20 20
21static inline int verify_area_skas(int type, const void __user * addr,
22 unsigned long size)
23{
24 return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
25}
26
27extern int copy_from_user_skas(void *to, const void __user *from, int n); 21extern int copy_from_user_skas(void *to, const void __user *from, int n);
28extern int copy_to_user_skas(void __user *to, const void *from, int n); 22extern int copy_to_user_skas(void __user *to, const void *from, int n);
29extern int strncpy_from_user_skas(char *dst, const char __user *src, int count); 23extern int strncpy_from_user_skas(char *dst, const char __user *src, int count);
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index 3d1b227226e6..efe92e8aa2a9 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -24,7 +24,7 @@
24#include "proc_mm.h" 24#include "proc_mm.h"
25#include "registers.h" 25#include "registers.h"
26 26
27void *switch_to_skas(void *prev, void *next) 27void switch_to_skas(void *prev, void *next)
28{ 28{
29 struct task_struct *from, *to; 29 struct task_struct *from, *to;
30 30
@@ -35,16 +35,11 @@ void *switch_to_skas(void *prev, void *next)
35 if(current->pid == 0) 35 if(current->pid == 0)
36 switch_timers(0); 36 switch_timers(0);
37 37
38 to->thread.prev_sched = from;
39 set_current(to);
40
41 switch_threads(&from->thread.mode.skas.switch_buf, 38 switch_threads(&from->thread.mode.skas.switch_buf,
42 to->thread.mode.skas.switch_buf); 39 to->thread.mode.skas.switch_buf);
43 40
44 if(current->pid == 0) 41 if(current->pid == 0)
45 switch_timers(1); 42 switch_timers(1);
46
47 return(current->thread.prev_sched);
48} 43}
49 44
50extern void schedule_tail(struct task_struct *prev); 45extern void schedule_tail(struct task_struct *prev);
diff --git a/arch/um/kernel/skas/util/Makefile b/arch/um/kernel/skas/util/Makefile
deleted file mode 100644
index f7b7eba83340..000000000000
--- a/arch/um/kernel/skas/util/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1hostprogs-y := mk_ptregs
2always := $(hostprogs-y)
3
4mk_ptregs-objs := mk_ptregs-$(SUBARCH).o
5HOSTCFLAGS_mk_ptregs-$(SUBARCH).o := -I$(objtree)/arch/um
diff --git a/arch/um/kernel/skas/util/mk_ptregs-i386.c b/arch/um/kernel/skas/util/mk_ptregs-i386.c
deleted file mode 100644
index 1f96e1eeb8a7..000000000000
--- a/arch/um/kernel/skas/util/mk_ptregs-i386.c
+++ /dev/null
@@ -1,49 +0,0 @@
1#include <stdio.h>
2#include <user-offsets.h>
3
4#define SHOW(name) printf("#define %s %d\n", #name, name)
5
6int main(int argc, char **argv)
7{
8 printf("/* Automatically generated by "
9 "arch/um/kernel/skas/util/mk_ptregs */\n");
10 printf("\n");
11 printf("#ifndef __SKAS_PT_REGS_\n");
12 printf("#define __SKAS_PT_REGS_\n");
13 printf("\n");
14 SHOW(HOST_FRAME_SIZE);
15 SHOW(HOST_FP_SIZE);
16 SHOW(HOST_XFP_SIZE);
17
18 SHOW(HOST_IP);
19 SHOW(HOST_SP);
20 SHOW(HOST_EFLAGS);
21 SHOW(HOST_EAX);
22 SHOW(HOST_EBX);
23 SHOW(HOST_ECX);
24 SHOW(HOST_EDX);
25 SHOW(HOST_ESI);
26 SHOW(HOST_EDI);
27 SHOW(HOST_EBP);
28 SHOW(HOST_CS);
29 SHOW(HOST_SS);
30 SHOW(HOST_DS);
31 SHOW(HOST_FS);
32 SHOW(HOST_ES);
33 SHOW(HOST_GS);
34
35 printf("\n");
36 printf("#endif\n");
37 return(0);
38}
39
40/*
41 * Overrides for Emacs so that we follow Linus's tabbing style.
42 * Emacs will notice this stuff at the end of the file and automatically
43 * adjust the settings for this buffer only. This must remain at the end
44 * of the file.
45 * ---------------------------------------------------------------------------
46 * Local variables:
47 * c-file-style: "linux"
48 * End:
49 */
diff --git a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c
deleted file mode 100644
index 5fccbfe35f78..000000000000
--- a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#include <stdio.h>
8#include <user-offsets.h>
9
10#define SHOW(name) \
11 printf("#define %s (%d / sizeof(unsigned long))\n", #name, name)
12
13int main(int argc, char **argv)
14{
15 printf("/* Automatically generated by "
16 "arch/um/kernel/skas/util/mk_ptregs */\n");
17 printf("\n");
18 printf("#ifndef __SKAS_PT_REGS_\n");
19 printf("#define __SKAS_PT_REGS_\n");
20 SHOW(HOST_FRAME_SIZE);
21 SHOW(HOST_RBX);
22 SHOW(HOST_RCX);
23 SHOW(HOST_RDI);
24 SHOW(HOST_RSI);
25 SHOW(HOST_RDX);
26 SHOW(HOST_RBP);
27 SHOW(HOST_RAX);
28 SHOW(HOST_R8);
29 SHOW(HOST_R9);
30 SHOW(HOST_R10);
31 SHOW(HOST_R11);
32 SHOW(HOST_R12);
33 SHOW(HOST_R13);
34 SHOW(HOST_R14);
35 SHOW(HOST_R15);
36 SHOW(HOST_ORIG_RAX);
37 SHOW(HOST_CS);
38 SHOW(HOST_SS);
39 SHOW(HOST_EFLAGS);
40#if 0
41 SHOW(HOST_FS);
42 SHOW(HOST_GS);
43 SHOW(HOST_DS);
44 SHOW(HOST_ES);
45#endif
46
47 SHOW(HOST_IP);
48 SHOW(HOST_SP);
49 printf("#define HOST_FP_SIZE 0\n");
50 printf("#define HOST_XFP_SIZE 0\n");
51 printf("\n");
52 printf("\n");
53 printf("#endif\n");
54 return(0);
55}
56
57/*
58 * Overrides for Emacs so that we follow Linus's tabbing style.
59 * Emacs will notice this stuff at the end of the file and automatically
60 * adjust the settings for this buffer only. This must remain at the end
61 * of the file.
62 * ---------------------------------------------------------------------------
63 * Local variables:
64 * c-file-style: "linux"
65 * End:
66 */
diff --git a/arch/um/kernel/sysrq.c b/arch/um/kernel/sysrq.c
index f80850091e79..b331e970002f 100644
--- a/arch/um/kernel/sysrq.c
+++ b/arch/um/kernel/sysrq.c
@@ -62,13 +62,7 @@ void show_stack(struct task_struct *task, unsigned long *esp)
62 62
63 if (esp == NULL) { 63 if (esp == NULL) {
64 if (task != current && task != NULL) { 64 if (task != current && task != NULL) {
65 /* XXX: Isn't this bogus? I.e. isn't this the
66 * *userspace* stack of this task? If not so, use this
67 * even when task == current (as in i386).
68 */
69 esp = (unsigned long *) KSTK_ESP(task); 65 esp = (unsigned long *) KSTK_ESP(task);
70 /* Which one? No actual difference - just coding style.*/
71 //esp = (unsigned long *) PT_REGS_IP(&task->thread.regs);
72 } else { 66 } else {
73 esp = (unsigned long *) &esp; 67 esp = (unsigned long *) &esp;
74 } 68 }
@@ -84,5 +78,5 @@ void show_stack(struct task_struct *task, unsigned long *esp)
84 } 78 }
85 79
86 printk("Call Trace: \n"); 80 printk("Call Trace: \n");
87 show_trace(current, esp); 81 show_trace(task, esp);
88} 82}
diff --git a/arch/um/kernel/tempfile.c b/arch/um/kernel/tempfile.c
deleted file mode 100644
index b1674bc1395d..000000000000
--- a/arch/um/kernel/tempfile.c
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <string.h>
10#include <errno.h>
11#include <sys/param.h>
12#include "init.h"
13
14/* Modified from create_mem_file and start_debugger */
15static char *tempdir = NULL;
16
17static void __init find_tempdir(void)
18{
19 char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL };
20 int i;
21 char *dir = NULL;
22
23 if(tempdir != NULL) return; /* We've already been called */
24 for(i = 0; dirs[i]; i++){
25 dir = getenv(dirs[i]);
26 if((dir != NULL) && (*dir != '\0'))
27 break;
28 }
29 if((dir == NULL) || (*dir == '\0'))
30 dir = "/tmp";
31
32 tempdir = malloc(strlen(dir) + 2);
33 if(tempdir == NULL){
34 fprintf(stderr, "Failed to malloc tempdir, "
35 "errno = %d\n", errno);
36 return;
37 }
38 strcpy(tempdir, dir);
39 strcat(tempdir, "/");
40}
41
42int make_tempfile(const char *template, char **out_tempname, int do_unlink)
43{
44 char tempname[MAXPATHLEN];
45 int fd;
46
47 find_tempdir();
48 if (*template != '/')
49 strcpy(tempname, tempdir);
50 else
51 *tempname = 0;
52 strcat(tempname, template);
53 fd = mkstemp(tempname);
54 if(fd < 0){
55 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
56 strerror(errno));
57 return -1;
58 }
59 if(do_unlink && (unlink(tempname) < 0)){
60 perror("unlink");
61 return -1;
62 }
63 if(out_tempname){
64 *out_tempname = strdup(tempname);
65 if(*out_tempname == NULL){
66 perror("strdup");
67 return -1;
68 }
69 }
70 return(fd);
71}
72
73/*
74 * Overrides for Emacs so that we follow Linus's tabbing style.
75 * Emacs will notice this stuff at the end of the file and automatically
76 * adjust the settings for this buffer only. This must remain at the end
77 * of the file.
78 * ---------------------------------------------------------------------------
79 * Local variables:
80 * c-file-style: "linux"
81 * End:
82 */
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
index 80ed6188e8a2..f5b0636f9ad7 100644
--- a/arch/um/kernel/tlb.c
+++ b/arch/um/kernel/tlb.c
@@ -193,12 +193,12 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
193 r = pte_read(*npte); 193 r = pte_read(*npte);
194 w = pte_write(*npte); 194 w = pte_write(*npte);
195 x = pte_exec(*npte); 195 x = pte_exec(*npte);
196 if(!pte_dirty(*npte)) 196 if (!pte_young(*npte)) {
197 w = 0; 197 r = 0;
198 if(!pte_young(*npte)){ 198 w = 0;
199 r = 0; 199 } else if (!pte_dirty(*npte)) {
200 w = 0; 200 w = 0;
201 } 201 }
202 if(force || pte_newpage(*npte)){ 202 if(force || pte_newpage(*npte)){
203 if(pte_present(*npte)) 203 if(pte_present(*npte))
204 ret = add_mmap(addr, 204 ret = add_mmap(addr,
@@ -307,7 +307,7 @@ int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
307 } 307 }
308 else if(pte_newprot(*pte)){ 308 else if(pte_newprot(*pte)){
309 updated = 1; 309 updated = 1;
310 protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1); 310 os_protect_memory((void *) addr, PAGE_SIZE, 1, 1, 1);
311 } 311 }
312 addr += PAGE_SIZE; 312 addr += PAGE_SIZE;
313 } 313 }
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
index 87cc6fd76ced..95c8f8733baf 100644
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -18,6 +18,7 @@
18#include "asm/a.out.h" 18#include "asm/a.out.h"
19#include "asm/current.h" 19#include "asm/current.h"
20#include "asm/irq.h" 20#include "asm/irq.h"
21#include "sysdep/sigcontext.h"
21#include "user_util.h" 22#include "user_util.h"
22#include "kern_util.h" 23#include "kern_util.h"
23#include "kern.h" 24#include "kern.h"
@@ -25,6 +26,9 @@
25#include "mconsole_kern.h" 26#include "mconsole_kern.h"
26#include "mem.h" 27#include "mem.h"
27#include "mem_kern.h" 28#include "mem_kern.h"
29#ifdef CONFIG_MODE_SKAS
30#include "skas.h"
31#endif
28 32
29/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */ 33/* Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by segv(). */
30int handle_page_fault(unsigned long address, unsigned long ip, 34int handle_page_fault(unsigned long address, unsigned long ip,
@@ -39,6 +43,12 @@ int handle_page_fault(unsigned long address, unsigned long ip,
39 int err = -EFAULT; 43 int err = -EFAULT;
40 44
41 *code_out = SEGV_MAPERR; 45 *code_out = SEGV_MAPERR;
46
47 /* If the fault was during atomic operation, don't take the fault, just
48 * fail. */
49 if (in_atomic())
50 goto out_nosemaphore;
51
42 down_read(&mm->mmap_sem); 52 down_read(&mm->mmap_sem);
43 vma = find_vma(mm, address); 53 vma = find_vma(mm, address);
44 if(!vma) 54 if(!vma)
@@ -89,6 +99,7 @@ survive:
89 flush_tlb_page(vma, address); 99 flush_tlb_page(vma, address);
90out: 100out:
91 up_read(&mm->mmap_sem); 101 up_read(&mm->mmap_sem);
102out_nosemaphore:
92 return(err); 103 return(err);
93 104
94/* 105/*
@@ -125,7 +136,15 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
125 } 136 }
126 else if(current->mm == NULL) 137 else if(current->mm == NULL)
127 panic("Segfault with no mm"); 138 panic("Segfault with no mm");
128 err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); 139
140 if (SEGV_IS_FIXABLE(&fi) || SEGV_MAYBE_FIXABLE(&fi))
141 err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
142 else {
143 err = -EFAULT;
144 /* A thread accessed NULL, we get a fault, but CR2 is invalid.
145 * This code is used in __do_copy_from_user() of TT mode. */
146 address = 0;
147 }
129 148
130 catcher = current->thread.fault_catcher; 149 catcher = current->thread.fault_catcher;
131 if(!err) 150 if(!err)
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h
index e0ca0e0b2516..2a35b15c5fef 100644
--- a/arch/um/kernel/tt/include/mode_kern-tt.h
+++ b/arch/um/kernel/tt/include/mode_kern-tt.h
@@ -11,7 +11,7 @@
11#include "asm/ptrace.h" 11#include "asm/ptrace.h"
12#include "asm/uaccess.h" 12#include "asm/uaccess.h"
13 13
14extern void *switch_to_tt(void *prev, void *next); 14extern void switch_to_tt(void *prev, void *next);
15extern void flush_thread_tt(void); 15extern void flush_thread_tt(void);
16extern void start_thread_tt(struct pt_regs *regs, unsigned long eip, 16extern void start_thread_tt(struct pt_regs *regs, unsigned long eip,
17 unsigned long esp); 17 unsigned long esp);
diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h
index aa6db384af80..dc2ebfa8c54f 100644
--- a/arch/um/kernel/tt/include/uaccess-tt.h
+++ b/arch/um/kernel/tt/include/uaccess-tt.h
@@ -33,12 +33,6 @@ extern unsigned long uml_physmem;
33 (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ 33 (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
34 (under_task_size(addr, size) || is_stack(addr, size)))) 34 (under_task_size(addr, size) || is_stack(addr, size))))
35 35
36static inline int verify_area_tt(int type, const void __user * addr,
37 unsigned long size)
38{
39 return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
40}
41
42extern unsigned long get_fault_addr(void); 36extern unsigned long get_fault_addr(void);
43 37
44extern int __do_copy_from_user(void *to, const void *from, int n, 38extern int __do_copy_from_user(void *to, const void *from, int n,
diff --git a/arch/um/kernel/tt/mem_user.c b/arch/um/kernel/tt/mem_user.c
index 3085267459b1..03e589895388 100644
--- a/arch/um/kernel/tt/mem_user.c
+++ b/arch/um/kernel/tt/mem_user.c
@@ -12,6 +12,7 @@
12#include "tt.h" 12#include "tt.h"
13#include "mem_user.h" 13#include "mem_user.h"
14#include "user_util.h" 14#include "user_util.h"
15#include "os.h"
15 16
16void remap_data(void *segment_start, void *segment_end, int w) 17void remap_data(void *segment_start, void *segment_end, int w)
17{ 18{
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index a189a2b92935..cfaa373a6e77 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -23,10 +23,11 @@
23#include "mem_user.h" 23#include "mem_user.h"
24#include "tlb.h" 24#include "tlb.h"
25#include "mode.h" 25#include "mode.h"
26#include "mode_kern.h"
26#include "init.h" 27#include "init.h"
27#include "tt.h" 28#include "tt.h"
28 29
29void *switch_to_tt(void *prev, void *next, void *last) 30void switch_to_tt(void *prev, void *next)
30{ 31{
31 struct task_struct *from, *to, *prev_sched; 32 struct task_struct *from, *to, *prev_sched;
32 unsigned long flags; 33 unsigned long flags;
@@ -36,8 +37,6 @@ void *switch_to_tt(void *prev, void *next, void *last)
36 from = prev; 37 from = prev;
37 to = next; 38 to = next;
38 39
39 to->thread.prev_sched = from;
40
41 cpu = from->thread_info->cpu; 40 cpu = from->thread_info->cpu;
42 if(cpu == 0) 41 if(cpu == 0)
43 forward_interrupts(to->thread.mode.tt.extern_pid); 42 forward_interrupts(to->thread.mode.tt.extern_pid);
@@ -53,7 +52,6 @@ void *switch_to_tt(void *prev, void *next, void *last)
53 forward_pending_sigio(to->thread.mode.tt.extern_pid); 52 forward_pending_sigio(to->thread.mode.tt.extern_pid);
54 53
55 c = 0; 54 c = 0;
56 set_current(to);
57 55
58 err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c)); 56 err = os_write_file(to->thread.mode.tt.switch_pipe[1], &c, sizeof(c));
59 if(err != sizeof(c)) 57 if(err != sizeof(c))
@@ -85,8 +83,6 @@ void *switch_to_tt(void *prev, void *next, void *last)
85 83
86 flush_tlb_all(); 84 flush_tlb_all();
87 local_irq_restore(flags); 85 local_irq_restore(flags);
88
89 return(current->thread.prev_sched);
90} 86}
91 87
92void release_thread_tt(struct task_struct *task) 88void release_thread_tt(struct task_struct *task)
diff --git a/arch/um/kernel/tt/uaccess_user.c b/arch/um/kernel/tt/uaccess_user.c
index f01475512ecb..8c220f054b61 100644
--- a/arch/um/kernel/tt/uaccess_user.c
+++ b/arch/um/kernel/tt/uaccess_user.c
@@ -22,8 +22,15 @@ int __do_copy_from_user(void *to, const void *from, int n,
22 __do_copy, &faulted); 22 __do_copy, &faulted);
23 TASK_REGS(get_current())->tt = save; 23 TASK_REGS(get_current())->tt = save;
24 24
25 if(!faulted) return(0); 25 if(!faulted)
26 else return(n - (fault - (unsigned long) from)); 26 return 0;
27 else if (fault)
28 return n - (fault - (unsigned long) from);
29 else
30 /* In case of a general protection fault, we don't have the
31 * fault address, so NULL is used instead. Pretend we didn't
32 * copy anything. */
33 return n;
27} 34}
28 35
29static void __do_strncpy(void *dst, const void *src, int count) 36static void __do_strncpy(void *dst, const void *src, int count)
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 09f6f7ce4695..93dc782dc1cc 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -334,6 +334,8 @@ int linux_main(int argc, char **argv)
334 add_arg(DEFAULT_COMMAND_LINE); 334 add_arg(DEFAULT_COMMAND_LINE);
335 335
336 os_early_checks(); 336 os_early_checks();
337 if (force_tt)
338 clear_can_do_skas();
337 mode_tt = force_tt ? 1 : !can_do_skas(); 339 mode_tt = force_tt ? 1 : !can_do_skas();
338#ifndef CONFIG_MODE_TT 340#ifndef CONFIG_MODE_TT
339 if (mode_tt) { 341 if (mode_tt) {
@@ -361,11 +363,6 @@ int linux_main(int argc, char **argv)
361 uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0, 363 uml_start = CHOOSE_MODE_PROC(set_task_sizes_tt, set_task_sizes_skas, 0,
362 &host_task_size, &task_size); 364 &host_task_size, &task_size);
363 365
364 /* Need to check this early because mmapping happens before the
365 * kernel is running.
366 */
367 check_tmpexec();
368
369 brk_start = (unsigned long) sbrk(0); 366 brk_start = (unsigned long) sbrk(0);
370 CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); 367 CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start);
371 /* Increase physical memory size for exec-shield users 368 /* Increase physical memory size for exec-shield users
diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c
index 186c28885016..0b21d59ba0cd 100644
--- a/arch/um/kernel/umid.c
+++ b/arch/um/kernel/umid.c
@@ -31,6 +31,8 @@ static char *uml_dir = UML_DIR;
31/* Changed by set_umid */ 31/* Changed by set_umid */
32static int umid_is_random = 1; 32static int umid_is_random = 1;
33static int umid_inited = 0; 33static int umid_inited = 0;
34/* Have we created the files? Should we remove them? */
35static int umid_owned = 0;
34 36
35static int make_umid(int (*printer)(const char *fmt, ...)); 37static int make_umid(int (*printer)(const char *fmt, ...));
36 38
@@ -82,20 +84,21 @@ int __init umid_file_name(char *name, char *buf, int len)
82 84
83extern int tracing_pid; 85extern int tracing_pid;
84 86
85static int __init create_pid_file(void) 87static void __init create_pid_file(void)
86{ 88{
87 char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; 89 char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")];
88 char pid[sizeof("nnnnn\0")]; 90 char pid[sizeof("nnnnn\0")];
89 int fd, n; 91 int fd, n;
90 92
91 if(umid_file_name("pid", file, sizeof(file))) return 0; 93 if(umid_file_name("pid", file, sizeof(file)))
94 return;
92 95
93 fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), 96 fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))),
94 0644); 97 0644);
95 if(fd < 0){ 98 if(fd < 0){
96 printf("Open of machine pid file \"%s\" failed: %s\n", 99 printf("Open of machine pid file \"%s\" failed: %s\n",
97 file, strerror(-fd)); 100 file, strerror(-fd));
98 return 0; 101 return;
99 } 102 }
100 103
101 sprintf(pid, "%d\n", os_getpid()); 104 sprintf(pid, "%d\n", os_getpid());
@@ -103,7 +106,6 @@ static int __init create_pid_file(void)
103 if(n != strlen(pid)) 106 if(n != strlen(pid))
104 printf("Write of pid file failed - err = %d\n", -n); 107 printf("Write of pid file failed - err = %d\n", -n);
105 os_close_file(fd); 108 os_close_file(fd);
106 return 0;
107} 109}
108 110
109static int actually_do_remove(char *dir) 111static int actually_do_remove(char *dir)
@@ -147,7 +149,8 @@ static int actually_do_remove(char *dir)
147void remove_umid_dir(void) 149void remove_umid_dir(void)
148{ 150{
149 char dir[strlen(uml_dir) + UMID_LEN + 1]; 151 char dir[strlen(uml_dir) + UMID_LEN + 1];
150 if(!umid_inited) return; 152 if (!umid_owned)
153 return;
151 154
152 sprintf(dir, "%s%s", uml_dir, umid); 155 sprintf(dir, "%s%s", uml_dir, umid);
153 actually_do_remove(dir); 156 actually_do_remove(dir);
@@ -155,11 +158,12 @@ void remove_umid_dir(void)
155 158
156char *get_umid(int only_if_set) 159char *get_umid(int only_if_set)
157{ 160{
158 if(only_if_set && umid_is_random) return(NULL); 161 if(only_if_set && umid_is_random)
159 return(umid); 162 return NULL;
163 return umid;
160} 164}
161 165
162int not_dead_yet(char *dir) 166static int not_dead_yet(char *dir)
163{ 167{
164 char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; 168 char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")];
165 char pid[sizeof("nnnnn\0")], *end; 169 char pid[sizeof("nnnnn\0")], *end;
@@ -193,7 +197,8 @@ int not_dead_yet(char *dir)
193 (p == CHOOSE_MODE(tracing_pid, os_getpid()))) 197 (p == CHOOSE_MODE(tracing_pid, os_getpid())))
194 dead = 1; 198 dead = 1;
195 } 199 }
196 if(!dead) return(1); 200 if(!dead)
201 return(1);
197 return(actually_do_remove(dir)); 202 return(actually_do_remove(dir));
198} 203}
199 204
@@ -232,16 +237,13 @@ static int __init make_uml_dir(void)
232 strlcpy(dir, home, sizeof(dir)); 237 strlcpy(dir, home, sizeof(dir));
233 uml_dir++; 238 uml_dir++;
234 } 239 }
240 strlcat(dir, uml_dir, sizeof(dir));
235 len = strlen(dir); 241 len = strlen(dir);
236 strncat(dir, uml_dir, sizeof(dir) - len); 242 if (len > 0 && dir[len - 1] != '/')
237 len = strlen(dir); 243 strlcat(dir, "/", sizeof(dir));
238 if((len > 0) && (len < sizeof(dir) - 1) && (dir[len - 1] != '/')){
239 dir[len] = '/';
240 dir[len + 1] = '\0';
241 }
242 244
243 uml_dir = malloc(strlen(dir) + 1); 245 uml_dir = malloc(strlen(dir) + 1);
244 if(uml_dir == NULL){ 246 if (uml_dir == NULL) {
245 printf("make_uml_dir : malloc failed, errno = %d\n", errno); 247 printf("make_uml_dir : malloc failed, errno = %d\n", errno);
246 exit(1); 248 exit(1);
247 } 249 }
@@ -286,6 +288,7 @@ static int __init make_umid(int (*printer)(const char *fmt, ...))
286 if(errno == EEXIST){ 288 if(errno == EEXIST){
287 if(not_dead_yet(tmp)){ 289 if(not_dead_yet(tmp)){
288 (*printer)("umid '%s' is in use\n", umid); 290 (*printer)("umid '%s' is in use\n", umid);
291 umid_owned = 0;
289 return(-1); 292 return(-1);
290 } 293 }
291 err = mkdir(tmp, 0777); 294 err = mkdir(tmp, 0777);
@@ -296,7 +299,8 @@ static int __init make_umid(int (*printer)(const char *fmt, ...))
296 return(-1); 299 return(-1);
297 } 300 }
298 301
299 return(0); 302 umid_owned = 1;
303 return 0;
300} 304}
301 305
302__uml_setup("uml_dir=", set_uml_dir, 306__uml_setup("uml_dir=", set_uml_dir,
@@ -309,7 +313,8 @@ static int __init make_umid_setup(void)
309 /* one function with the ordering we need ... */ 313 /* one function with the ordering we need ... */
310 make_uml_dir(); 314 make_uml_dir();
311 make_umid(printf); 315 make_umid(printf);
312 return create_pid_file(); 316 create_pid_file();
317 return 0;
313} 318}
314__uml_postsetup(make_umid_setup); 319__uml_postsetup(make_umid_setup);
315 320
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c
index 954ff67cc8b3..41d17c71511c 100644
--- a/arch/um/kernel/user_util.c
+++ b/arch/um/kernel/user_util.c
@@ -109,18 +109,14 @@ int raw(int fd)
109 int err; 109 int err;
110 110
111 CATCH_EINTR(err = tcgetattr(fd, &tt)); 111 CATCH_EINTR(err = tcgetattr(fd, &tt));
112 if (err < 0) { 112 if(err < 0)
113 printk("tcgetattr failed, errno = %d\n", errno); 113 return -errno;
114 return(-errno);
115 }
116 114
117 cfmakeraw(&tt); 115 cfmakeraw(&tt);
118 116
119 CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); 117 CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt));
120 if (err < 0) { 118 if(err < 0)
121 printk("tcsetattr failed, errno = %d\n", errno); 119 return -errno;
122 return(-errno);
123 }
124 120
125 /* XXX tcsetattr could have applied only some changes 121 /* XXX tcsetattr could have applied only some changes
126 * (and cfmakeraw() is a set of changes) */ 122 * (and cfmakeraw() is a set of changes) */
@@ -132,6 +128,12 @@ void setup_machinename(char *machine_out)
132 struct utsname host; 128 struct utsname host;
133 129
134 uname(&host); 130 uname(&host);
131#if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT)
132 if (!strcmp(host.machine, "x86_64")) {
133 strcpy(machine_out, "i686");
134 return;
135 }
136#endif
135 strcpy(machine_out, host.machine); 137 strcpy(machine_out, host.machine);
136} 138}
137 139
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index 7a1662419c0c..d15ec2af6a22 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -3,11 +3,11 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6obj-y = aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \ 6obj-y = aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o time.o \
7 tty.o user_syms.o drivers/ sys-$(SUBARCH)/ 7 tt.o tty.o user_syms.o drivers/ sys-$(SUBARCH)/
8 8
9USER_OBJS := aio.o elf_aux.o file.o process.o signal.o start_up.o time.o tt.o \ 9USER_OBJS := aio.o elf_aux.o file.o mem.o process.o signal.o start_up.o \
10 tty.o 10 time.o tt.o tty.o
11 11
12elf_aux.o: $(ARCH_DIR)/kernel-offsets.h 12elf_aux.o: $(ARCH_DIR)/kernel-offsets.h
13CFLAGS_elf_aux.o += -I$(objtree)/arch/um 13CFLAGS_elf_aux.o += -I$(objtree)/arch/um
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c
index b04897cd995d..41cfb0944201 100644
--- a/arch/um/os-Linux/aio.c
+++ b/arch/um/os-Linux/aio.c
@@ -6,7 +6,6 @@
6#include <stdlib.h> 6#include <stdlib.h>
7#include <unistd.h> 7#include <unistd.h>
8#include <signal.h> 8#include <signal.h>
9#include <string.h>
10#include <errno.h> 9#include <errno.h>
11#include <sched.h> 10#include <sched.h>
12#include <sys/syscall.h> 11#include <sys/syscall.h>
@@ -17,31 +16,18 @@
17#include "user.h" 16#include "user.h"
18#include "mode.h" 17#include "mode.h"
19 18
19struct aio_thread_req {
20 enum aio_type type;
21 int io_fd;
22 unsigned long long offset;
23 char *buf;
24 int len;
25 struct aio_context *aio;
26};
27
20static int aio_req_fd_r = -1; 28static int aio_req_fd_r = -1;
21static int aio_req_fd_w = -1; 29static int aio_req_fd_w = -1;
22 30
23static int update_aio(struct aio_context *aio, int res)
24{
25 if(res < 0)
26 aio->len = res;
27 else if((res == 0) && (aio->type == AIO_READ)){
28 /* This is the EOF case - we have hit the end of the file
29 * and it ends in a partial block, so we fill the end of
30 * the block with zeros and claim success.
31 */
32 memset(aio->data, 0, aio->len);
33 aio->len = 0;
34 }
35 else if(res > 0){
36 aio->len -= res;
37 aio->data += res;
38 aio->offset += res;
39 return aio->len;
40 }
41
42 return 0;
43}
44
45#if defined(HAVE_AIO_ABI) 31#if defined(HAVE_AIO_ABI)
46#include <linux/aio_abi.h> 32#include <linux/aio_abi.h>
47 33
@@ -80,7 +66,8 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
80 * that it now backs the mmapped area. 66 * that it now backs the mmapped area.
81 */ 67 */
82 68
83static int do_aio(aio_context_t ctx, struct aio_context *aio) 69static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf,
70 int len, unsigned long long offset, struct aio_context *aio)
84{ 71{
85 struct iocb iocb, *iocbp = &iocb; 72 struct iocb iocb, *iocbp = &iocb;
86 char c; 73 char c;
@@ -88,37 +75,40 @@ static int do_aio(aio_context_t ctx, struct aio_context *aio)
88 75
89 iocb = ((struct iocb) { .aio_data = (unsigned long) aio, 76 iocb = ((struct iocb) { .aio_data = (unsigned long) aio,
90 .aio_reqprio = 0, 77 .aio_reqprio = 0,
91 .aio_fildes = aio->fd, 78 .aio_fildes = fd,
92 .aio_buf = (unsigned long) aio->data, 79 .aio_buf = (unsigned long) buf,
93 .aio_nbytes = aio->len, 80 .aio_nbytes = len,
94 .aio_offset = aio->offset, 81 .aio_offset = offset,
95 .aio_reserved1 = 0, 82 .aio_reserved1 = 0,
96 .aio_reserved2 = 0, 83 .aio_reserved2 = 0,
97 .aio_reserved3 = 0 }); 84 .aio_reserved3 = 0 });
98 85
99 switch(aio->type){ 86 switch(type){
100 case AIO_READ: 87 case AIO_READ:
101 iocb.aio_lio_opcode = IOCB_CMD_PREAD; 88 iocb.aio_lio_opcode = IOCB_CMD_PREAD;
89 err = io_submit(ctx, 1, &iocbp);
102 break; 90 break;
103 case AIO_WRITE: 91 case AIO_WRITE:
104 iocb.aio_lio_opcode = IOCB_CMD_PWRITE; 92 iocb.aio_lio_opcode = IOCB_CMD_PWRITE;
93 err = io_submit(ctx, 1, &iocbp);
105 break; 94 break;
106 case AIO_MMAP: 95 case AIO_MMAP:
107 iocb.aio_lio_opcode = IOCB_CMD_PREAD; 96 iocb.aio_lio_opcode = IOCB_CMD_PREAD;
108 iocb.aio_buf = (unsigned long) &c; 97 iocb.aio_buf = (unsigned long) &c;
109 iocb.aio_nbytes = sizeof(c); 98 iocb.aio_nbytes = sizeof(c);
99 err = io_submit(ctx, 1, &iocbp);
110 break; 100 break;
111 default: 101 default:
112 printk("Bogus op in do_aio - %d\n", aio->type); 102 printk("Bogus op in do_aio - %d\n", type);
113 err = -EINVAL; 103 err = -EINVAL;
114 goto out; 104 break;
115 } 105 }
116 106
117 err = io_submit(ctx, 1, &iocbp);
118 if(err > 0) 107 if(err > 0)
119 err = 0; 108 err = 0;
109 else
110 err = -errno;
120 111
121 out:
122 return err; 112 return err;
123} 113}
124 114
@@ -127,9 +117,8 @@ static aio_context_t ctx = 0;
127static int aio_thread(void *arg) 117static int aio_thread(void *arg)
128{ 118{
129 struct aio_thread_reply reply; 119 struct aio_thread_reply reply;
130 struct aio_context *aio;
131 struct io_event event; 120 struct io_event event;
132 int err, n; 121 int err, n, reply_fd;
133 122
134 signal(SIGWINCH, SIG_IGN); 123 signal(SIGWINCH, SIG_IGN);
135 124
@@ -142,21 +131,14 @@ static int aio_thread(void *arg)
142 "errno = %d\n", errno); 131 "errno = %d\n", errno);
143 } 132 }
144 else { 133 else {
145 aio = (struct aio_context *) event.data;
146 if(update_aio(aio, event.res)){
147 do_aio(ctx, aio);
148 continue;
149 }
150
151 reply = ((struct aio_thread_reply) 134 reply = ((struct aio_thread_reply)
152 { .data = aio, 135 { .data = (void *) (long) event.data,
153 .err = aio->len }); 136 .err = event.res });
154 err = os_write_file(aio->reply_fd, &reply, 137 reply_fd = ((struct aio_context *) reply.data)->reply_fd;
155 sizeof(reply)); 138 err = os_write_file(reply_fd, &reply, sizeof(reply));
156 if(err != sizeof(reply)) 139 if(err != sizeof(reply))
157 printk("aio_thread - write failed, " 140 printk("aio_thread - write failed, fd = %d, "
158 "fd = %d, err = %d\n", aio->reply_fd, 141 "err = %d\n", aio_req_fd_r, -err);
159 -err);
160 } 142 }
161 } 143 }
162 return 0; 144 return 0;
@@ -164,35 +146,35 @@ static int aio_thread(void *arg)
164 146
165#endif 147#endif
166 148
167static int do_not_aio(struct aio_context *aio) 149static int do_not_aio(struct aio_thread_req *req)
168{ 150{
169 char c; 151 char c;
170 int err; 152 int err;
171 153
172 switch(aio->type){ 154 switch(req->type){
173 case AIO_READ: 155 case AIO_READ:
174 err = os_seek_file(aio->fd, aio->offset); 156 err = os_seek_file(req->io_fd, req->offset);
175 if(err) 157 if(err)
176 goto out; 158 goto out;
177 159
178 err = os_read_file(aio->fd, aio->data, aio->len); 160 err = os_read_file(req->io_fd, req->buf, req->len);
179 break; 161 break;
180 case AIO_WRITE: 162 case AIO_WRITE:
181 err = os_seek_file(aio->fd, aio->offset); 163 err = os_seek_file(req->io_fd, req->offset);
182 if(err) 164 if(err)
183 goto out; 165 goto out;
184 166
185 err = os_write_file(aio->fd, aio->data, aio->len); 167 err = os_write_file(req->io_fd, req->buf, req->len);
186 break; 168 break;
187 case AIO_MMAP: 169 case AIO_MMAP:
188 err = os_seek_file(aio->fd, aio->offset); 170 err = os_seek_file(req->io_fd, req->offset);
189 if(err) 171 if(err)
190 goto out; 172 goto out;
191 173
192 err = os_read_file(aio->fd, &c, sizeof(c)); 174 err = os_read_file(req->io_fd, &c, sizeof(c));
193 break; 175 break;
194 default: 176 default:
195 printk("do_not_aio - bad request type : %d\n", aio->type); 177 printk("do_not_aio - bad request type : %d\n", req->type);
196 err = -EINVAL; 178 err = -EINVAL;
197 break; 179 break;
198 } 180 }
@@ -203,14 +185,14 @@ static int do_not_aio(struct aio_context *aio)
203 185
204static int not_aio_thread(void *arg) 186static int not_aio_thread(void *arg)
205{ 187{
206 struct aio_context *aio; 188 struct aio_thread_req req;
207 struct aio_thread_reply reply; 189 struct aio_thread_reply reply;
208 int err; 190 int err;
209 191
210 signal(SIGWINCH, SIG_IGN); 192 signal(SIGWINCH, SIG_IGN);
211 while(1){ 193 while(1){
212 err = os_read_file(aio_req_fd_r, &aio, sizeof(aio)); 194 err = os_read_file(aio_req_fd_r, &req, sizeof(req));
213 if(err != sizeof(aio)){ 195 if(err != sizeof(req)){
214 if(err < 0) 196 if(err < 0)
215 printk("not_aio_thread - read failed, " 197 printk("not_aio_thread - read failed, "
216 "fd = %d, err = %d\n", aio_req_fd_r, 198 "fd = %d, err = %d\n", aio_req_fd_r,
@@ -221,34 +203,17 @@ static int not_aio_thread(void *arg)
221 } 203 }
222 continue; 204 continue;
223 } 205 }
224 again: 206 err = do_not_aio(&req);
225 err = do_not_aio(aio); 207 reply = ((struct aio_thread_reply) { .data = req.aio,
226 208 .err = err });
227 if(update_aio(aio, err)) 209 err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply));
228 goto again;
229
230 reply = ((struct aio_thread_reply) { .data = aio,
231 .err = aio->len });
232 err = os_write_file(aio->reply_fd, &reply, sizeof(reply));
233 if(err != sizeof(reply)) 210 if(err != sizeof(reply))
234 printk("not_aio_thread - write failed, fd = %d, " 211 printk("not_aio_thread - write failed, fd = %d, "
235 "err = %d\n", aio_req_fd_r, -err); 212 "err = %d\n", aio_req_fd_r, -err);
236 } 213 }
237} 214}
238 215
239static int submit_aio_24(struct aio_context *aio)
240{
241 int err;
242
243 err = os_write_file(aio_req_fd_w, &aio, sizeof(aio));
244 if(err == sizeof(aio))
245 err = 0;
246
247 return err;
248}
249
250static int aio_pid = -1; 216static int aio_pid = -1;
251static int (*submit_proc)(struct aio_context *aio);
252 217
253static int init_aio_24(void) 218static int init_aio_24(void)
254{ 219{
@@ -280,68 +245,64 @@ static int init_aio_24(void)
280#endif 245#endif
281 printk("2.6 host AIO support not used - falling back to I/O " 246 printk("2.6 host AIO support not used - falling back to I/O "
282 "thread\n"); 247 "thread\n");
283
284 submit_proc = submit_aio_24;
285
286 return 0; 248 return 0;
287} 249}
288 250
289#ifdef HAVE_AIO_ABI 251#ifdef HAVE_AIO_ABI
290#define DEFAULT_24_AIO 0 252#define DEFAULT_24_AIO 0
291static int submit_aio_26(struct aio_context *aio)
292{
293 struct aio_thread_reply reply;
294 int err;
295
296 err = do_aio(ctx, aio);
297 if(err){
298 reply = ((struct aio_thread_reply) { .data = aio,
299 .err = err });
300 err = os_write_file(aio->reply_fd, &reply, sizeof(reply));
301 if(err != sizeof(reply))
302 printk("submit_aio_26 - write failed, "
303 "fd = %d, err = %d\n", aio->reply_fd, -err);
304 else err = 0;
305 }
306
307 return err;
308}
309
310static int init_aio_26(void) 253static int init_aio_26(void)
311{ 254{
312 unsigned long stack; 255 unsigned long stack;
313 int err; 256 int err;
314 257
315 if(io_setup(256, &ctx)){ 258 if(io_setup(256, &ctx)){
259 err = -errno;
316 printk("aio_thread failed to initialize context, err = %d\n", 260 printk("aio_thread failed to initialize context, err = %d\n",
317 errno); 261 errno);
318 return -errno; 262 return err;
319 } 263 }
320 264
321 err = run_helper_thread(aio_thread, NULL, 265 err = run_helper_thread(aio_thread, NULL,
322 CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); 266 CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0);
323 if(err < 0) 267 if(err < 0)
324 return -errno; 268 return err;
325 269
326 aio_pid = err; 270 aio_pid = err;
327 271
328 printk("Using 2.6 host AIO\n"); 272 printk("Using 2.6 host AIO\n");
273 return 0;
274}
275
276static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
277 unsigned long long offset, struct aio_context *aio)
278{
279 struct aio_thread_reply reply;
280 int err;
329 281
330 submit_proc = submit_aio_26; 282 err = do_aio(ctx, type, io_fd, buf, len, offset, aio);
283 if(err){
284 reply = ((struct aio_thread_reply) { .data = aio,
285 .err = err });
286 err = os_write_file(aio->reply_fd, &reply, sizeof(reply));
287 if(err != sizeof(reply))
288 printk("submit_aio_26 - write failed, "
289 "fd = %d, err = %d\n", aio->reply_fd, -err);
290 else err = 0;
291 }
331 292
332 return 0; 293 return err;
333} 294}
334 295
335#else 296#else
336#define DEFAULT_24_AIO 1 297#define DEFAULT_24_AIO 1
337static int submit_aio_26(struct aio_context *aio) 298static int init_aio_26(void)
338{ 299{
339 return -ENOSYS; 300 return -ENOSYS;
340} 301}
341 302
342static int init_aio_26(void) 303static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
304 unsigned long long offset, struct aio_context *aio)
343{ 305{
344 submit_proc = submit_aio_26;
345 return -ENOSYS; 306 return -ENOSYS;
346} 307}
347#endif 308#endif
@@ -408,7 +369,33 @@ static void exit_aio(void)
408 369
409__uml_exitcall(exit_aio); 370__uml_exitcall(exit_aio);
410 371
411int submit_aio(struct aio_context *aio) 372static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len,
373 unsigned long long offset, struct aio_context *aio)
412{ 374{
413 return (*submit_proc)(aio); 375 struct aio_thread_req req = { .type = type,
376 .io_fd = io_fd,
377 .offset = offset,
378 .buf = buf,
379 .len = len,
380 .aio = aio,
381 };
382 int err;
383
384 err = os_write_file(aio_req_fd_w, &req, sizeof(req));
385 if(err == sizeof(req))
386 err = 0;
387
388 return err;
389}
390
391int submit_aio(enum aio_type type, int io_fd, char *buf, int len,
392 unsigned long long offset, int reply_fd,
393 struct aio_context *aio)
394{
395 aio->reply_fd = reply_fd;
396 if(aio_24)
397 return submit_aio_24(type, io_fd, buf, len, offset, aio);
398 else {
399 return submit_aio_26(type, io_fd, buf, len, offset, aio);
400 }
414} 401}
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c
index 4b83c6c3f48d..4ba9b17adf13 100644
--- a/arch/um/os-Linux/drivers/tuntap_user.c
+++ b/arch/um/os-Linux/drivers/tuntap_user.c
@@ -75,7 +75,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
75 struct msghdr msg; 75 struct msghdr msg;
76 struct cmsghdr *cmsg; 76 struct cmsghdr *cmsg;
77 struct iovec iov; 77 struct iovec iov;
78 int pid, n; 78 int pid, n, err;
79 79
80 sprintf(version_buf, "%d", UML_NET_VERSION); 80 sprintf(version_buf, "%d", UML_NET_VERSION);
81 81
@@ -105,9 +105,10 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
105 n = recvmsg(me, &msg, 0); 105 n = recvmsg(me, &msg, 0);
106 *used_out = n; 106 *used_out = n;
107 if(n < 0){ 107 if(n < 0){
108 err = -errno;
108 printk("tuntap_open_tramp : recvmsg failed - errno = %d\n", 109 printk("tuntap_open_tramp : recvmsg failed - errno = %d\n",
109 errno); 110 errno);
110 return(-errno); 111 return err;
111 } 112 }
112 CATCH_EINTR(waitpid(pid, NULL, 0)); 113 CATCH_EINTR(waitpid(pid, NULL, 0));
113 114
@@ -147,9 +148,10 @@ static int tuntap_open(void *data)
147 ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 148 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
148 strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name)); 149 strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name));
149 if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){ 150 if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){
151 err = -errno;
150 printk("TUNSETIFF failed, errno = %d\n", errno); 152 printk("TUNSETIFF failed, errno = %d\n", errno);
151 os_close_file(pri->fd); 153 os_close_file(pri->fd);
152 return(-errno); 154 return err;
153 } 155 }
154 } 156 }
155 else { 157 else {
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index 1399520a8588..5a99dd3fbed0 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -12,9 +12,10 @@
12#include "init.h" 12#include "init.h"
13#include "elf_user.h" 13#include "elf_user.h"
14#include "mem_user.h" 14#include "mem_user.h"
15#include <kernel-offsets.h> 15#include <kern_constants.h>
16 16
17#if HOST_ELF_CLASS == ELFCLASS32 17/* Use the one from the kernel - the host may miss it, if having old headers. */
18#if UM_ELF_CLASS == UM_ELFCLASS32
18typedef Elf32_auxv_t elf_auxv_t; 19typedef Elf32_auxv_t elf_auxv_t;
19#else 20#else
20typedef Elf64_auxv_t elf_auxv_t; 21typedef Elf64_auxv_t elf_auxv_t;
@@ -54,7 +55,8 @@ __init void scan_elf_aux( char **envp)
54 * a_un, so we have to use a_val, which is 55 * a_un, so we have to use a_val, which is
55 * all that's left. 56 * all that's left.
56 */ 57 */
57 elf_aux_platform = (char *) auxv->a_un.a_val; 58 elf_aux_platform =
59 (char *) (long) auxv->a_un.a_val;
58 break; 60 break;
59 case AT_PAGESZ: 61 case AT_PAGESZ:
60 page_size = auxv->a_un.a_val; 62 page_size = auxv->a_un.a_val;
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index fd45bb260907..f55773c819e6 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -119,15 +119,11 @@ int os_window_size(int fd, int *rows, int *cols)
119 119
120int os_new_tty_pgrp(int fd, int pid) 120int os_new_tty_pgrp(int fd, int pid)
121{ 121{
122 if(ioctl(fd, TIOCSCTTY, 0) < 0){ 122 if(ioctl(fd, TIOCSCTTY, 0) < 0)
123 printk("TIOCSCTTY failed, errno = %d\n", errno); 123 return -errno;
124 return(-errno);
125 }
126 124
127 if(tcsetpgrp(fd, pid) < 0){ 125 if(tcsetpgrp(fd, pid) < 0)
128 printk("tcsetpgrp failed, errno = %d\n", errno); 126 return -errno;
129 return(-errno);
130 }
131 127
132 return(0); 128 return(0);
133} 129}
@@ -146,18 +142,12 @@ int os_set_slip(int fd)
146 int disc, sencap; 142 int disc, sencap;
147 143
148 disc = N_SLIP; 144 disc = N_SLIP;
149 if(ioctl(fd, TIOCSETD, &disc) < 0){ 145 if(ioctl(fd, TIOCSETD, &disc) < 0)
150 printk("Failed to set slip line discipline - " 146 return -errno;
151 "errno = %d\n", errno);
152 return(-errno);
153 }
154 147
155 sencap = 0; 148 sencap = 0;
156 if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0){ 149 if(ioctl(fd, SIOCSIFENCAP, &sencap) < 0)
157 printk("Failed to set slip encapsulation - " 150 return -errno;
158 "errno = %d\n", errno);
159 return(-errno);
160 }
161 151
162 return(0); 152 return(0);
163} 153}
@@ -180,22 +170,15 @@ int os_sigio_async(int master, int slave)
180 int flags; 170 int flags;
181 171
182 flags = fcntl(master, F_GETFL); 172 flags = fcntl(master, F_GETFL);
183 if(flags < 0) { 173 if(flags < 0)
184 printk("fcntl F_GETFL failed, errno = %d\n", errno); 174 return errno;
185 return(-errno);
186 }
187 175
188 if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || 176 if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
189 (fcntl(master, F_SETOWN, os_getpid()) < 0)){ 177 (fcntl(master, F_SETOWN, os_getpid()) < 0))
190 printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", 178 return -errno;
191 errno);
192 return(-errno);
193 }
194 179
195 if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0)){ 180 if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
196 printk("fcntl F_SETFL failed, errno = %d\n", errno); 181 return -errno;
197 return(-errno);
198 }
199 182
200 return(0); 183 return(0);
201} 184}
@@ -255,7 +238,7 @@ int os_file_mode(char *file, struct openflags *mode_out)
255 238
256int os_open_file(char *file, struct openflags flags, int mode) 239int os_open_file(char *file, struct openflags flags, int mode)
257{ 240{
258 int fd, f = 0; 241 int fd, err, f = 0;
259 242
260 if(flags.r && flags.w) f = O_RDWR; 243 if(flags.r && flags.w) f = O_RDWR;
261 else if(flags.r) f = O_RDONLY; 244 else if(flags.r) f = O_RDONLY;
@@ -272,8 +255,9 @@ int os_open_file(char *file, struct openflags flags, int mode)
272 return(-errno); 255 return(-errno);
273 256
274 if(flags.cl && fcntl(fd, F_SETFD, 1)){ 257 if(flags.cl && fcntl(fd, F_SETFD, 1)){
258 err = -errno;
275 os_close_file(fd); 259 os_close_file(fd);
276 return(-errno); 260 return err;
277 } 261 }
278 262
279 return(fd); 263 return(fd);
@@ -383,9 +367,9 @@ int os_file_size(char *file, unsigned long long *size_out)
383 return(fd); 367 return(fd);
384 } 368 }
385 if(ioctl(fd, BLKGETSIZE, &blocks) < 0){ 369 if(ioctl(fd, BLKGETSIZE, &blocks) < 0){
370 err = -errno;
386 printk("Couldn't get the block size of \"%s\", " 371 printk("Couldn't get the block size of \"%s\", "
387 "errno = %d\n", file, errno); 372 "errno = %d\n", file, errno);
388 err = -errno;
389 os_close_file(fd); 373 os_close_file(fd);
390 return(err); 374 return(err);
391 } 375 }
@@ -473,11 +457,14 @@ int os_pipe(int *fds, int stream, int close_on_exec)
473 457
474int os_set_fd_async(int fd, int owner) 458int os_set_fd_async(int fd, int owner)
475{ 459{
460 int err;
461
476 /* XXX This should do F_GETFL first */ 462 /* XXX This should do F_GETFL first */
477 if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){ 463 if(fcntl(fd, F_SETFL, O_ASYNC | O_NONBLOCK) < 0){
464 err = -errno;
478 printk("os_set_fd_async : failed to set O_ASYNC and " 465 printk("os_set_fd_async : failed to set O_ASYNC and "
479 "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno); 466 "O_NONBLOCK on fd # %d, errno = %d\n", fd, errno);
480 return(-errno); 467 return err;
481 } 468 }
482#ifdef notdef 469#ifdef notdef
483 if(fcntl(fd, F_SETFD, 1) < 0){ 470 if(fcntl(fd, F_SETFD, 1) < 0){
@@ -488,10 +475,11 @@ int os_set_fd_async(int fd, int owner)
488 475
489 if((fcntl(fd, F_SETSIG, SIGIO) < 0) || 476 if((fcntl(fd, F_SETSIG, SIGIO) < 0) ||
490 (fcntl(fd, F_SETOWN, owner) < 0)){ 477 (fcntl(fd, F_SETOWN, owner) < 0)){
478 err = -errno;
491 printk("os_set_fd_async : Failed to fcntl F_SETOWN " 479 printk("os_set_fd_async : Failed to fcntl F_SETOWN "
492 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd, 480 "(or F_SETSIG) fd %d to pid %d, errno = %d\n", fd,
493 owner, errno); 481 owner, errno);
494 return(-errno); 482 return err;
495 } 483 }
496 484
497 return(0); 485 return(0);
@@ -516,11 +504,9 @@ int os_set_fd_block(int fd, int blocking)
516 if(blocking) flags &= ~O_NONBLOCK; 504 if(blocking) flags &= ~O_NONBLOCK;
517 else flags |= O_NONBLOCK; 505 else flags |= O_NONBLOCK;
518 506
519 if(fcntl(fd, F_SETFL, flags) < 0){ 507 if(fcntl(fd, F_SETFL, flags) < 0)
520 printk("Failed to change blocking on fd # %d, errno = %d\n", 508 return -errno;
521 fd, errno); 509
522 return(-errno);
523 }
524 return(0); 510 return(0);
525} 511}
526 512
@@ -609,11 +595,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec)
609 int sock, err; 595 int sock, err;
610 596
611 sock = socket(PF_UNIX, SOCK_DGRAM, 0); 597 sock = socket(PF_UNIX, SOCK_DGRAM, 0);
612 if (sock < 0){ 598 if(sock < 0)
613 printk("create_unix_socket - socket failed, errno = %d\n", 599 return -errno;
614 errno);
615 return(-errno);
616 }
617 600
618 if(close_on_exec) { 601 if(close_on_exec) {
619 err = os_set_exec_close(sock, 1); 602 err = os_set_exec_close(sock, 1);
@@ -628,11 +611,8 @@ int os_create_unix_socket(char *file, int len, int close_on_exec)
628 snprintf(addr.sun_path, len, "%s", file); 611 snprintf(addr.sun_path, len, "%s", file);
629 612
630 err = bind(sock, (struct sockaddr *) &addr, sizeof(addr)); 613 err = bind(sock, (struct sockaddr *) &addr, sizeof(addr));
631 if (err < 0){ 614 if(err < 0)
632 printk("create_listening_socket at '%s' - bind failed, " 615 return -errno;
633 "errno = %d\n", file, errno);
634 return(-errno);
635 }
636 616
637 return(sock); 617 return(sock);
638} 618}
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
new file mode 100644
index 000000000000..8e71edaaf80b
--- /dev/null
+++ b/arch/um/os-Linux/mem.c
@@ -0,0 +1,161 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <stddef.h>
4#include <stdarg.h>
5#include <unistd.h>
6#include <errno.h>
7#include <string.h>
8#include <fcntl.h>
9#include <sys/types.h>
10#include <sys/mman.h>
11#include "kern_util.h"
12#include "user.h"
13#include "user_util.h"
14#include "mem_user.h"
15#include "init.h"
16#include "os.h"
17#include "tempfile.h"
18#include "kern_constants.h"
19
20#include <sys/param.h>
21
22static char *tempdir = NULL;
23
24static void __init find_tempdir(void)
25{
26 char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL };
27 int i;
28 char *dir = NULL;
29
30 if(tempdir != NULL) return; /* We've already been called */
31 for(i = 0; dirs[i]; i++){
32 dir = getenv(dirs[i]);
33 if((dir != NULL) && (*dir != '\0'))
34 break;
35 }
36 if((dir == NULL) || (*dir == '\0'))
37 dir = "/tmp";
38
39 tempdir = malloc(strlen(dir) + 2);
40 if(tempdir == NULL){
41 fprintf(stderr, "Failed to malloc tempdir, "
42 "errno = %d\n", errno);
43 return;
44 }
45 strcpy(tempdir, dir);
46 strcat(tempdir, "/");
47}
48
49/*
50 * This proc still used in tt-mode
51 * (file: kernel/tt/ptproxy/proxy.c, proc: start_debugger).
52 * So it isn't 'static' yet.
53 */
54int make_tempfile(const char *template, char **out_tempname, int do_unlink)
55{
56 char tempname[MAXPATHLEN];
57 int fd;
58
59 find_tempdir();
60 if (*template != '/')
61 strcpy(tempname, tempdir);
62 else
63 *tempname = 0;
64 strcat(tempname, template);
65 fd = mkstemp(tempname);
66 if(fd < 0){
67 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
68 strerror(errno));
69 return -1;
70 }
71 if(do_unlink && (unlink(tempname) < 0)){
72 perror("unlink");
73 return -1;
74 }
75 if(out_tempname){
76 *out_tempname = strdup(tempname);
77 if(*out_tempname == NULL){
78 perror("strdup");
79 return -1;
80 }
81 }
82 return(fd);
83}
84
85#define TEMPNAME_TEMPLATE "vm_file-XXXXXX"
86
87/*
88 * This proc is used in start_up.c
89 * So it isn't 'static'.
90 */
91int create_tmp_file(unsigned long len)
92{
93 int fd, err;
94 char zero;
95
96 fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1);
97 if(fd < 0) {
98 exit(1);
99 }
100
101 err = fchmod(fd, 0777);
102 if(err < 0){
103 perror("os_mode_fd");
104 exit(1);
105 }
106
107 if (lseek64(fd, len, SEEK_SET) < 0) {
108 perror("os_seek_file");
109 exit(1);
110 }
111
112 zero = 0;
113
114 err = os_write_file(fd, &zero, 1);
115 if(err != 1){
116 errno = -err;
117 perror("os_write_file");
118 exit(1);
119 }
120
121 return(fd);
122}
123
124static int create_anon_file(unsigned long len)
125{
126 void *addr;
127 int fd;
128
129 fd = open("/dev/anon", O_RDWR);
130 if(fd < 0) {
131 perror("opening /dev/anon");
132 exit(1);
133 }
134
135 addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
136 if(addr == MAP_FAILED){
137 perror("mapping physmem file");
138 exit(1);
139 }
140 munmap(addr, len);
141
142 return(fd);
143}
144
145extern int have_devanon;
146
147int create_mem_file(unsigned long len)
148{
149 int err, fd;
150
151 if(have_devanon)
152 fd = create_anon_file(len);
153 else fd = create_tmp_file(len);
154
155 err = os_set_exec_close(fd, 1);
156 if(err < 0){
157 errno = -err;
158 perror("exec_close");
159 }
160 return(fd);
161}
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index d32413e4b4ce..d9c52387c4a1 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -3,6 +3,7 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <unistd.h>
6#include <stdio.h> 7#include <stdio.h>
7#include <errno.h> 8#include <errno.h>
8#include <signal.h> 9#include <signal.h>
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 040cc1472bc7..b99ab414542f 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -4,18 +4,22 @@
4 */ 4 */
5 5
6#include <stdio.h> 6#include <stdio.h>
7#include <stddef.h>
8#include <stdarg.h>
9#include <stdlib.h>
10#include <string.h>
7#include <unistd.h> 11#include <unistd.h>
8#include <signal.h> 12#include <signal.h>
9#include <sched.h> 13#include <sched.h>
14#include <fcntl.h>
10#include <errno.h> 15#include <errno.h>
11#include <stdarg.h>
12#include <stdlib.h>
13#include <setjmp.h> 16#include <setjmp.h>
14#include <sys/time.h> 17#include <sys/time.h>
15#include <sys/wait.h> 18#include <sys/wait.h>
16#include <sys/mman.h> 19#include <sys/mman.h>
17#include <asm/unistd.h> 20#include <asm/unistd.h>
18#include <asm/page.h> 21#include <asm/page.h>
22#include <sys/types.h>
19#include "user_util.h" 23#include "user_util.h"
20#include "kern_util.h" 24#include "kern_util.h"
21#include "user.h" 25#include "user.h"
@@ -25,6 +29,7 @@
25#include "sysdep/sigcontext.h" 29#include "sysdep/sigcontext.h"
26#include "irq_user.h" 30#include "irq_user.h"
27#include "ptrace_user.h" 31#include "ptrace_user.h"
32#include "mem_user.h"
28#include "time_user.h" 33#include "time_user.h"
29#include "init.h" 34#include "init.h"
30#include "os.h" 35#include "os.h"
@@ -32,6 +37,8 @@
32#include "choose-mode.h" 37#include "choose-mode.h"
33#include "mode.h" 38#include "mode.h"
34#include "tempfile.h" 39#include "tempfile.h"
40#include "kern_constants.h"
41
35#ifdef UML_CONFIG_MODE_SKAS 42#ifdef UML_CONFIG_MODE_SKAS
36#include "skas.h" 43#include "skas.h"
37#include "skas_ptrace.h" 44#include "skas_ptrace.h"
@@ -136,11 +143,22 @@ static int __init skas0_cmd_param(char *str, int* add)
136 return 0; 143 return 0;
137} 144}
138 145
146/* The two __uml_setup would conflict, without this stupid alias. */
147
148static int __init mode_skas0_cmd_param(char *str, int* add)
149 __attribute__((alias("skas0_cmd_param")));
150
139__uml_setup("skas0", skas0_cmd_param, 151__uml_setup("skas0", skas0_cmd_param,
140 "skas0\n" 152 "skas0\n"
141 " Disables SKAS3 usage, so that SKAS0 is used, unless \n" 153 " Disables SKAS3 usage, so that SKAS0 is used, unless \n"
142 " you specify mode=tt.\n\n"); 154 " you specify mode=tt.\n\n");
143 155
156__uml_setup("mode=skas0", mode_skas0_cmd_param,
157 "mode=skas0\n"
158 " Disables SKAS3 usage, so that SKAS0 is used, unless you \n"
159 " specify mode=tt. Note that this was recently added - on \n"
160 " older kernels you must use simply \"skas0\".\n\n");
161
144static int force_sysemu_disabled = 0; 162static int force_sysemu_disabled = 0;
145 163
146static int __init nosysemu_cmd_param(char *str, int* add) 164static int __init nosysemu_cmd_param(char *str, int* add)
@@ -276,9 +294,38 @@ static void __init check_ptrace(void)
276 check_sysemu(); 294 check_sysemu();
277} 295}
278 296
297extern int create_tmp_file(unsigned long len);
298
299static void check_tmpexec(void)
300{
301 void *addr;
302 int err, fd = create_tmp_file(UM_KERN_PAGE_SIZE);
303
304 addr = mmap(NULL, UM_KERN_PAGE_SIZE,
305 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
306 printf("Checking PROT_EXEC mmap in /tmp...");
307 fflush(stdout);
308 if(addr == MAP_FAILED){
309 err = errno;
310 perror("failed");
311 if(err == EPERM)
312 printf("/tmp must be not mounted noexec\n");
313 exit(1);
314 }
315 printf("OK\n");
316 munmap(addr, UM_KERN_PAGE_SIZE);
317
318 close(fd);
319}
320
279void os_early_checks(void) 321void os_early_checks(void)
280{ 322{
281 check_ptrace(); 323 check_ptrace();
324
325 /* Need to check this early because mmapping happens before the
326 * kernel is running.
327 */
328 check_tmpexec();
282} 329}
283 330
284static int __init noprocmm_cmd_param(char *str, int* add) 331static int __init noprocmm_cmd_param(char *str, int* add)
@@ -357,3 +404,72 @@ int can_do_skas(void)
357 return(0); 404 return(0);
358} 405}
359#endif 406#endif
407
408int have_devanon = 0;
409
410void check_devanon(void)
411{
412 int fd;
413
414 printk("Checking for /dev/anon on the host...");
415 fd = open("/dev/anon", O_RDWR);
416 if(fd < 0){
417 printk("Not available (open failed with errno %d)\n", errno);
418 return;
419 }
420
421 printk("OK\n");
422 have_devanon = 1;
423}
424
425int __init parse_iomem(char *str, int *add)
426{
427 struct iomem_region *new;
428 struct uml_stat buf;
429 char *file, *driver;
430 int fd, err, size;
431
432 driver = str;
433 file = strchr(str,',');
434 if(file == NULL){
435 printf("parse_iomem : failed to parse iomem\n");
436 goto out;
437 }
438 *file = '\0';
439 file++;
440 fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0);
441 if(fd < 0){
442 os_print_error(fd, "parse_iomem - Couldn't open io file");
443 goto out;
444 }
445
446 err = os_stat_fd(fd, &buf);
447 if(err < 0){
448 os_print_error(err, "parse_iomem - cannot stat_fd file");
449 goto out_close;
450 }
451
452 new = malloc(sizeof(*new));
453 if(new == NULL){
454 perror("Couldn't allocate iomem_region struct");
455 goto out_close;
456 }
457
458 size = (buf.ust_size + UM_KERN_PAGE_SIZE) & ~(UM_KERN_PAGE_SIZE - 1);
459
460 *new = ((struct iomem_region) { .next = iomem_regions,
461 .driver = driver,
462 .fd = fd,
463 .size = size,
464 .phys = 0,
465 .virt = 0 });
466 iomem_regions = new;
467 iomem_size += new->size + UM_KERN_PAGE_SIZE;
468
469 return(0);
470 out_close:
471 os_close_file(fd);
472 out:
473 return(1);
474}
475
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c
index 3125d320722c..aee4812333c6 100644
--- a/arch/um/os-Linux/sys-i386/registers.c
+++ b/arch/um/os-Linux/sys-i386/registers.c
@@ -5,6 +5,7 @@
5 5
6#include <errno.h> 6#include <errno.h>
7#include <string.h> 7#include <string.h>
8#include <setjmp.h>
8#include "sysdep/ptrace_user.h" 9#include "sysdep/ptrace_user.h"
9#include "sysdep/ptrace.h" 10#include "sysdep/ptrace.h"
10#include "uml-config.h" 11#include "uml-config.h"
@@ -126,13 +127,11 @@ void get_safe_registers(unsigned long *regs)
126 memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); 127 memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
127} 128}
128 129
129/* 130void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
130 * Overrides for Emacs so that we follow Linus's tabbing style. 131{
131 * Emacs will notice this stuff at the end of the file and automatically 132 struct __jmp_buf_tag *jmpbuf = buffer;
132 * adjust the settings for this buffer only. This must remain at the end 133
133 * of the file. 134 UPT_SET(uml_regs, EIP, jmpbuf->__jmpbuf[JB_PC]);
134 * --------------------------------------------------------------------------- 135 UPT_SET(uml_regs, UESP, jmpbuf->__jmpbuf[JB_SP]);
135 * Local variables: 136 UPT_SET(uml_regs, EBP, jmpbuf->__jmpbuf[JB_BP]);
136 * c-file-style: "linux" 137}
137 * End:
138 */
diff --git a/arch/um/os-Linux/sys-x86_64/registers.c b/arch/um/os-Linux/sys-x86_64/registers.c
index 44438d15c3d6..4b638dfb52b0 100644
--- a/arch/um/os-Linux/sys-x86_64/registers.c
+++ b/arch/um/os-Linux/sys-x86_64/registers.c
@@ -5,6 +5,7 @@
5 5
6#include <errno.h> 6#include <errno.h>
7#include <string.h> 7#include <string.h>
8#include <setjmp.h>
8#include "ptrace_user.h" 9#include "ptrace_user.h"
9#include "uml-config.h" 10#include "uml-config.h"
10#include "skas_ptregs.h" 11#include "skas_ptregs.h"
@@ -74,13 +75,11 @@ void get_safe_registers(unsigned long *regs)
74 memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long)); 75 memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
75} 76}
76 77
77/* 78void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
78 * Overrides for Emacs so that we follow Linus's tabbing style. 79{
79 * Emacs will notice this stuff at the end of the file and automatically 80 struct __jmp_buf_tag *jmpbuf = buffer;
80 * adjust the settings for this buffer only. This must remain at the end 81
81 * of the file. 82 UPT_SET(uml_regs, RIP, jmpbuf->__jmpbuf[JB_PC]);
82 * --------------------------------------------------------------------------- 83 UPT_SET(uml_regs, RSP, jmpbuf->__jmpbuf[JB_RSP]);
83 * Local variables: 84 UPT_SET(uml_regs, RBP, jmpbuf->__jmpbuf[JB_RBP]);
84 * c-file-style: "linux" 85}
85 * End:
86 */
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
index 5b047ab8416a..a6db8877931a 100644
--- a/arch/um/os-Linux/tt.c
+++ b/arch/um/os-Linux/tt.c
@@ -36,6 +36,20 @@
36#include "mode.h" 36#include "mode.h"
37#include "tempfile.h" 37#include "tempfile.h"
38 38
39int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
40 int must_succeed)
41{
42 int err;
43
44 err = os_protect_memory((void *) addr, len, r, w, x);
45 if(err < 0){
46 if(must_succeed)
47 panic("protect failed, err = %d", -err);
48 else return(err);
49 }
50 return(0);
51}
52
39/* 53/*
40 *------------------------- 54 *-------------------------
41 * only for tt mode (will be deleted in future...) 55 * only for tt mode (will be deleted in future...)
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile
deleted file mode 100644
index 9778aed0c314..000000000000
--- a/arch/um/os-Linux/util/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
1hostprogs-y := mk_user_constants
2always := $(hostprogs-y)
3
4HOSTCFLAGS_mk_user_constants.o := -I$(objtree)/arch/um
diff --git a/arch/um/os-Linux/util/mk_user_constants.c b/arch/um/os-Linux/util/mk_user_constants.c
deleted file mode 100644
index 4838f30eecf0..000000000000
--- a/arch/um/os-Linux/util/mk_user_constants.c
+++ /dev/null
@@ -1,23 +0,0 @@
1#include <stdio.h>
2#include <user-offsets.h>
3
4int main(int argc, char **argv)
5{
6 printf("/*\n");
7 printf(" * Generated by mk_user_constants\n");
8 printf(" */\n");
9 printf("\n");
10 printf("#ifndef __UM_USER_CONSTANTS_H\n");
11 printf("#define __UM_USER_CONSTANTS_H\n");
12 printf("\n");
13 /* I'd like to use FRAME_SIZE from ptrace.h here, but that's wrong on
14 * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on
15 * both x86_64 and i386.
16 */
17 printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE);
18
19 printf("\n");
20 printf("#endif\n");
21
22 return(0);
23}
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index 59a1291f477e..651d9d88b656 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -7,8 +7,8 @@ USER_SINGLE_OBJS := \
7USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) 7USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS))
8USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) 8USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
9 9
10$(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ 10$(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \
11 $(CFLAGS_$(notdir $@)) 11 c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@))
12$(USER_OBJS): cmd_checksrc = 12$(USER_OBJS): cmd_checksrc =
13$(USER_OBJS): quiet_cmd_checksrc = 13$(USER_OBJS): quiet_cmd_checksrc =
14$(USER_OBJS): cmd_force_checksrc = 14$(USER_OBJS): cmd_force_checksrc =
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 4ca2a229da49..6dfeb70f6957 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -18,6 +18,4 @@ module.c-dir = kernel
18 18
19$(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS)) 19$(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS))
20 20
21subdir- := util
22
23include arch/um/scripts/Makefile.unmap 21include arch/um/scripts/Makefile.unmap
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/sys-i386/kernel-offsets.c
index a1070af2bcd8..35db85057506 100644
--- a/arch/um/sys-i386/kernel-offsets.c
+++ b/arch/um/sys-i386/kernel-offsets.c
@@ -18,9 +18,9 @@
18 18
19void foo(void) 19void foo(void)
20{ 20{
21 OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs); 21 OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
22#ifdef CONFIG_MODE_TT 22#ifdef CONFIG_MODE_TT
23 OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); 23 OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
24#endif 24#endif
25#include <common-offsets.h> 25#include <common-offsets.h>
26} 26}
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index bd3c34aa52e5..36b5c2c13289 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -83,6 +83,7 @@ int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
83 goto out; 83 goto out;
84 } 84 }
85 p = buf; 85 p = buf;
86 break;
86 default: 87 default:
87 res = -ENOSYS; 88 res = -ENOSYS;
88 goto out; 89 goto out;
diff --git a/arch/um/sys-i386/sysrq.c b/arch/um/sys-i386/sysrq.c
index e3706d15c4f5..d5244f070539 100644
--- a/arch/um/sys-i386/sysrq.c
+++ b/arch/um/sys-i386/sysrq.c
@@ -88,9 +88,7 @@ void show_trace(struct task_struct* task, unsigned long * stack)
88 task = current; 88 task = current;
89 89
90 if (task != current) { 90 if (task != current) {
91 //ebp = (unsigned long) KSTK_EBP(task); 91 ebp = (unsigned long) KSTK_EBP(task);
92 /* Which one? No actual difference - just coding style.*/
93 ebp = (unsigned long) PT_REGS_EBP(&task->thread.regs);
94 } else { 92 } else {
95 asm ("movl %%ebp, %0" : "=r" (ebp) : ); 93 asm ("movl %%ebp, %0" : "=r" (ebp) : );
96 } 94 }
@@ -99,15 +97,6 @@ void show_trace(struct task_struct* task, unsigned long * stack)
99 ((unsigned long)stack & (~(THREAD_SIZE - 1))); 97 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
100 print_context_stack(context, stack, ebp); 98 print_context_stack(context, stack, ebp);
101 99
102 /*while (((long) stack & (THREAD_SIZE-1)) != 0) {
103 addr = *stack;
104 if (__kernel_text_address(addr)) {
105 printk("%08lx: [<%08lx>]", (unsigned long) stack, addr);
106 print_symbol(" %s", addr);
107 printk("\n");
108 }
109 stack++;
110 }*/
111 printk("\n"); 100 printk("\n");
112} 101}
113 102
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 3ceaabceb3d7..26b68675053d 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -7,47 +7,48 @@
7#define DEFINE(sym, val) \ 7#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 8 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9 9
10#define DEFINE_LONGS(sym, val) \
11 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
12
10#define OFFSET(sym, str, mem) \ 13#define OFFSET(sym, str, mem) \
11 DEFINE(sym, offsetof(struct str, mem)); 14 DEFINE(sym, offsetof(struct str, mem));
12 15
13void foo(void) 16void foo(void)
14{ 17{
15 OFFSET(SC_IP, sigcontext, eip); 18 OFFSET(HOST_SC_IP, sigcontext, eip);
16 OFFSET(SC_SP, sigcontext, esp); 19 OFFSET(HOST_SC_SP, sigcontext, esp);
17 OFFSET(SC_FS, sigcontext, fs); 20 OFFSET(HOST_SC_FS, sigcontext, fs);
18 OFFSET(SC_GS, sigcontext, gs); 21 OFFSET(HOST_SC_GS, sigcontext, gs);
19 OFFSET(SC_DS, sigcontext, ds); 22 OFFSET(HOST_SC_DS, sigcontext, ds);
20 OFFSET(SC_ES, sigcontext, es); 23 OFFSET(HOST_SC_ES, sigcontext, es);
21 OFFSET(SC_SS, sigcontext, ss); 24 OFFSET(HOST_SC_SS, sigcontext, ss);
22 OFFSET(SC_CS, sigcontext, cs); 25 OFFSET(HOST_SC_CS, sigcontext, cs);
23 OFFSET(SC_EFLAGS, sigcontext, eflags); 26 OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
24 OFFSET(SC_EAX, sigcontext, eax); 27 OFFSET(HOST_SC_EAX, sigcontext, eax);
25 OFFSET(SC_EBX, sigcontext, ebx); 28 OFFSET(HOST_SC_EBX, sigcontext, ebx);
26 OFFSET(SC_ECX, sigcontext, ecx); 29 OFFSET(HOST_SC_ECX, sigcontext, ecx);
27 OFFSET(SC_EDX, sigcontext, edx); 30 OFFSET(HOST_SC_EDX, sigcontext, edx);
28 OFFSET(SC_EDI, sigcontext, edi); 31 OFFSET(HOST_SC_EDI, sigcontext, edi);
29 OFFSET(SC_ESI, sigcontext, esi); 32 OFFSET(HOST_SC_ESI, sigcontext, esi);
30 OFFSET(SC_EBP, sigcontext, ebp); 33 OFFSET(HOST_SC_EBP, sigcontext, ebp);
31 OFFSET(SC_TRAPNO, sigcontext, trapno); 34 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
32 OFFSET(SC_ERR, sigcontext, err); 35 OFFSET(HOST_SC_ERR, sigcontext, err);
33 OFFSET(SC_CR2, sigcontext, cr2); 36 OFFSET(HOST_SC_CR2, sigcontext, cr2);
34 OFFSET(SC_FPSTATE, sigcontext, fpstate); 37 OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate);
35 OFFSET(SC_SIGMASK, sigcontext, oldmask); 38 OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
36 OFFSET(SC_FP_CW, _fpstate, cw); 39 OFFSET(HOST_SC_FP_CW, _fpstate, cw);
37 OFFSET(SC_FP_SW, _fpstate, sw); 40 OFFSET(HOST_SC_FP_SW, _fpstate, sw);
38 OFFSET(SC_FP_TAG, _fpstate, tag); 41 OFFSET(HOST_SC_FP_TAG, _fpstate, tag);
39 OFFSET(SC_FP_IPOFF, _fpstate, ipoff); 42 OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff);
40 OFFSET(SC_FP_CSSEL, _fpstate, cssel); 43 OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel);
41 OFFSET(SC_FP_DATAOFF, _fpstate, dataoff); 44 OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff);
42 OFFSET(SC_FP_DATASEL, _fpstate, datasel); 45 OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel);
43 OFFSET(SC_FP_ST, _fpstate, _st); 46 OFFSET(HOST_SC_FP_ST, _fpstate, _st);
44 OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env); 47 OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env);
45 48
46 DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); 49 DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
47 DEFINE(HOST_FP_SIZE, 50 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct));
48 sizeof(struct user_i387_struct) / sizeof(unsigned long)); 51 DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct));
49 DEFINE(HOST_XFP_SIZE,
50 sizeof(struct user_fxsr_struct) / sizeof(unsigned long));
51 52
52 DEFINE(HOST_IP, EIP); 53 DEFINE(HOST_IP, EIP);
53 DEFINE(HOST_SP, UESP); 54 DEFINE(HOST_SP, UESP);
@@ -65,5 +66,5 @@ void foo(void)
65 DEFINE(HOST_FS, FS); 66 DEFINE(HOST_FS, FS);
66 DEFINE(HOST_ES, ES); 67 DEFINE(HOST_ES, ES);
67 DEFINE(HOST_GS, GS); 68 DEFINE(HOST_GS, GS);
68 DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); 69 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
69} 70}
diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile
deleted file mode 100644
index bf61afd0b045..000000000000
--- a/arch/um/sys-i386/util/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1hostprogs-y := mk_sc mk_thread
2always := $(hostprogs-y)
3
4HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um
5HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um
diff --git a/arch/um/sys-i386/util/mk_sc.c b/arch/um/sys-i386/util/mk_sc.c
deleted file mode 100644
index 04c0d73433aa..000000000000
--- a/arch/um/sys-i386/util/mk_sc.c
+++ /dev/null
@@ -1,51 +0,0 @@
1#include <stdio.h>
2#include <user-offsets.h>
3
4#define SC_OFFSET(name, field) \
5 printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
6 name)
7
8#define SC_FP_OFFSET(name, field) \
9 printf("#define " #name \
10 "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
11 name)
12
13#define SC_FP_OFFSET_PTR(name, field, type) \
14 printf("#define " #name \
15 "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
16 name)
17
18int main(int argc, char **argv)
19{
20 SC_OFFSET(SC_IP, eip);
21 SC_OFFSET(SC_SP, esp);
22 SC_OFFSET(SC_FS, fs);
23 SC_OFFSET(SC_GS, gs);
24 SC_OFFSET(SC_DS, ds);
25 SC_OFFSET(SC_ES, es);
26 SC_OFFSET(SC_SS, ss);
27 SC_OFFSET(SC_CS, cs);
28 SC_OFFSET(SC_EFLAGS, eflags);
29 SC_OFFSET(SC_EAX, eax);
30 SC_OFFSET(SC_EBX, ebx);
31 SC_OFFSET(SC_ECX, ecx);
32 SC_OFFSET(SC_EDX, edx);
33 SC_OFFSET(SC_EDI, edi);
34 SC_OFFSET(SC_ESI, esi);
35 SC_OFFSET(SC_EBP, ebp);
36 SC_OFFSET(SC_TRAPNO, trapno);
37 SC_OFFSET(SC_ERR, err);
38 SC_OFFSET(SC_CR2, cr2);
39 SC_OFFSET(SC_FPSTATE, fpstate);
40 SC_OFFSET(SC_SIGMASK, oldmask);
41 SC_FP_OFFSET(SC_FP_CW, cw);
42 SC_FP_OFFSET(SC_FP_SW, sw);
43 SC_FP_OFFSET(SC_FP_TAG, tag);
44 SC_FP_OFFSET(SC_FP_IPOFF, ipoff);
45 SC_FP_OFFSET(SC_FP_CSSEL, cssel);
46 SC_FP_OFFSET(SC_FP_DATAOFF, dataoff);
47 SC_FP_OFFSET(SC_FP_DATASEL, datasel);
48 SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate");
49 SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void");
50 return(0);
51}
diff --git a/arch/um/sys-i386/util/mk_thread.c b/arch/um/sys-i386/util/mk_thread.c
deleted file mode 100644
index 7470d0dda67e..000000000000
--- a/arch/um/sys-i386/util/mk_thread.c
+++ /dev/null
@@ -1,22 +0,0 @@
1#include <stdio.h>
2#include <kernel-offsets.h>
3
4int main(int argc, char **argv)
5{
6 printf("/*\n");
7 printf(" * Generated by mk_thread\n");
8 printf(" */\n");
9 printf("\n");
10 printf("#ifndef __UM_THREAD_H\n");
11 printf("#define __UM_THREAD_H\n");
12 printf("\n");
13 printf("#define TASK_DEBUGREGS(task) ((unsigned long *) "
14 "&(((char *) (task))[%d]))\n", TASK_DEBUGREGS);
15#ifdef TASK_EXTERN_PID
16 printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n",
17 TASK_EXTERN_PID);
18#endif
19 printf("\n");
20 printf("#endif\n");
21 return(0);
22}
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
index f0ab574d1e95..06c3633457a2 100644
--- a/arch/um/sys-x86_64/Makefile
+++ b/arch/um/sys-x86_64/Makefile
@@ -29,6 +29,4 @@ module.c-dir = kernel
29 29
30$(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS)) 30$(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS))
31 31
32subdir- := util
33
34include arch/um/scripts/Makefile.unmap 32include arch/um/scripts/Makefile.unmap
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/sys-x86_64/kernel-offsets.c
index 998541eade41..bfcb104b846e 100644
--- a/arch/um/sys-x86_64/kernel-offsets.c
+++ b/arch/um/sys-x86_64/kernel-offsets.c
@@ -19,7 +19,7 @@
19void foo(void) 19void foo(void)
20{ 20{
21#ifdef CONFIG_MODE_TT 21#ifdef CONFIG_MODE_TT
22 OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); 22 OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
23#endif 23#endif
24#include <common-offsets.h> 24#include <common-offsets.h>
25} 25}
diff --git a/arch/um/sys-x86_64/stub_segv.c b/arch/um/sys-x86_64/stub_segv.c
index 65a131b362b6..d1e53bdf2e85 100644
--- a/arch/um/sys-x86_64/stub_segv.c
+++ b/arch/um/sys-x86_64/stub_segv.c
@@ -10,6 +10,22 @@
10#include "uml-config.h" 10#include "uml-config.h"
11#include "sysdep/sigcontext.h" 11#include "sysdep/sigcontext.h"
12#include "sysdep/faultinfo.h" 12#include "sysdep/faultinfo.h"
13#include <stddef.h>
14
15/* Copied from sys-x86_64/signal.c - Can't find an equivalent definition
16 * in the libc headers anywhere.
17 */
18struct rt_sigframe
19{
20 char *pretcode;
21 struct ucontext uc;
22 struct siginfo info;
23};
24
25/* Copied here from <linux/kernel.h> - we're userspace. */
26#define container_of(ptr, type, member) ({ \
27 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
28 (type *)( (char *)__mptr - offsetof(type,member) );})
13 29
14void __attribute__ ((__section__ (".__syscall_stub"))) 30void __attribute__ ((__section__ (".__syscall_stub")))
15stub_segv_handler(int sig) 31stub_segv_handler(int sig)
@@ -17,16 +33,19 @@ stub_segv_handler(int sig)
17 struct ucontext *uc; 33 struct ucontext *uc;
18 34
19 __asm__("movq %%rdx, %0" : "=g" (uc) :); 35 __asm__("movq %%rdx, %0" : "=g" (uc) :);
20 GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), 36 GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
21 &uc->uc_mcontext); 37 &uc->uc_mcontext);
22 38
23 __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid)); 39 __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
24 __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;" 40 __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;"
25 "syscall": : "g" (__NR_kill), "g" (SIGUSR1)); 41 "syscall": : "g" (__NR_kill), "g" (SIGUSR1) :
26 /* Two popqs to restore the stack to the state just before entering 42 "%rdi", "%rax", "%rsi");
27 * the handler, one pops the return address, the other pops the frame 43 /* sys_sigreturn expects that the stack pointer will be 8 bytes into
28 * pointer. 44 * the signal frame. So, we use the ucontext pointer, which we know
45 * already, to get the signal frame pointer, and add 8 to that.
29 */ 46 */
30 __asm__("popq %%rax ; popq %%rax ; movq %0, %%rax ; syscall" : : "g" 47 __asm__("movq %0, %%rsp": :
31 (__NR_rt_sigreturn)); 48 "g" ((unsigned long) container_of(uc, struct rt_sigframe,
49 uc) + 8));
50 __asm__("movq %0, %%rax ; syscall" : : "g" (__NR_rt_sigreturn));
32} 51}
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
index 513d17ceafd4..5a585bfbb8c2 100644
--- a/arch/um/sys-x86_64/user-offsets.c
+++ b/arch/um/sys-x86_64/user-offsets.c
@@ -16,71 +16,76 @@ typedef __u32 u32;
16#define DEFINE(sym, val) \ 16#define DEFINE(sym, val) \
17 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 17 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
18 18
19#define DEFINE_LONGS(sym, val) \
20 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
21
19#define OFFSET(sym, str, mem) \ 22#define OFFSET(sym, str, mem) \
20 DEFINE(sym, offsetof(struct str, mem)); 23 DEFINE(sym, offsetof(struct str, mem));
21 24
22void foo(void) 25void foo(void)
23{ 26{
24 OFFSET(SC_RBX, sigcontext, rbx); 27 OFFSET(HOST_SC_RBX, sigcontext, rbx);
25 OFFSET(SC_RCX, sigcontext, rcx); 28 OFFSET(HOST_SC_RCX, sigcontext, rcx);
26 OFFSET(SC_RDX, sigcontext, rdx); 29 OFFSET(HOST_SC_RDX, sigcontext, rdx);
27 OFFSET(SC_RSI, sigcontext, rsi); 30 OFFSET(HOST_SC_RSI, sigcontext, rsi);
28 OFFSET(SC_RDI, sigcontext, rdi); 31 OFFSET(HOST_SC_RDI, sigcontext, rdi);
29 OFFSET(SC_RBP, sigcontext, rbp); 32 OFFSET(HOST_SC_RBP, sigcontext, rbp);
30 OFFSET(SC_RAX, sigcontext, rax); 33 OFFSET(HOST_SC_RAX, sigcontext, rax);
31 OFFSET(SC_R8, sigcontext, r8); 34 OFFSET(HOST_SC_R8, sigcontext, r8);
32 OFFSET(SC_R9, sigcontext, r9); 35 OFFSET(HOST_SC_R9, sigcontext, r9);
33 OFFSET(SC_R10, sigcontext, r10); 36 OFFSET(HOST_SC_R10, sigcontext, r10);
34 OFFSET(SC_R11, sigcontext, r11); 37 OFFSET(HOST_SC_R11, sigcontext, r11);
35 OFFSET(SC_R12, sigcontext, r12); 38 OFFSET(HOST_SC_R12, sigcontext, r12);
36 OFFSET(SC_R13, sigcontext, r13); 39 OFFSET(HOST_SC_R13, sigcontext, r13);
37 OFFSET(SC_R14, sigcontext, r14); 40 OFFSET(HOST_SC_R14, sigcontext, r14);
38 OFFSET(SC_R15, sigcontext, r15); 41 OFFSET(HOST_SC_R15, sigcontext, r15);
39 OFFSET(SC_IP, sigcontext, rip); 42 OFFSET(HOST_SC_IP, sigcontext, rip);
40 OFFSET(SC_SP, sigcontext, rsp); 43 OFFSET(HOST_SC_SP, sigcontext, rsp);
41 OFFSET(SC_CR2, sigcontext, cr2); 44 OFFSET(HOST_SC_CR2, sigcontext, cr2);
42 OFFSET(SC_ERR, sigcontext, err); 45 OFFSET(HOST_SC_ERR, sigcontext, err);
43 OFFSET(SC_TRAPNO, sigcontext, trapno); 46 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
44 OFFSET(SC_CS, sigcontext, cs); 47 OFFSET(HOST_SC_CS, sigcontext, cs);
45 OFFSET(SC_FS, sigcontext, fs); 48 OFFSET(HOST_SC_FS, sigcontext, fs);
46 OFFSET(SC_GS, sigcontext, gs); 49 OFFSET(HOST_SC_GS, sigcontext, gs);
47 OFFSET(SC_EFLAGS, sigcontext, eflags); 50 OFFSET(HOST_SC_EFLAGS, sigcontext, eflags);
48 OFFSET(SC_SIGMASK, sigcontext, oldmask); 51 OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask);
49#if 0 52#if 0
50 OFFSET(SC_ORIG_RAX, sigcontext, orig_rax); 53 OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax);
51 OFFSET(SC_DS, sigcontext, ds); 54 OFFSET(HOST_SC_DS, sigcontext, ds);
52 OFFSET(SC_ES, sigcontext, es); 55 OFFSET(HOST_SC_ES, sigcontext, es);
53 OFFSET(SC_SS, sigcontext, ss); 56 OFFSET(HOST_SC_SS, sigcontext, ss);
54#endif 57#endif
55 58
56 DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); 59 DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE);
57 DEFINE(HOST_RBX, RBX); 60 DEFINE(HOST_FP_SIZE, 0);
58 DEFINE(HOST_RCX, RCX); 61 DEFINE(HOST_XFP_SIZE, 0);
59 DEFINE(HOST_RDI, RDI); 62 DEFINE_LONGS(HOST_RBX, RBX);
60 DEFINE(HOST_RSI, RSI); 63 DEFINE_LONGS(HOST_RCX, RCX);
61 DEFINE(HOST_RDX, RDX); 64 DEFINE_LONGS(HOST_RDI, RDI);
62 DEFINE(HOST_RBP, RBP); 65 DEFINE_LONGS(HOST_RSI, RSI);
63 DEFINE(HOST_RAX, RAX); 66 DEFINE_LONGS(HOST_RDX, RDX);
64 DEFINE(HOST_R8, R8); 67 DEFINE_LONGS(HOST_RBP, RBP);
65 DEFINE(HOST_R9, R9); 68 DEFINE_LONGS(HOST_RAX, RAX);
66 DEFINE(HOST_R10, R10); 69 DEFINE_LONGS(HOST_R8, R8);
67 DEFINE(HOST_R11, R11); 70 DEFINE_LONGS(HOST_R9, R9);
68 DEFINE(HOST_R12, R12); 71 DEFINE_LONGS(HOST_R10, R10);
69 DEFINE(HOST_R13, R13); 72 DEFINE_LONGS(HOST_R11, R11);
70 DEFINE(HOST_R14, R14); 73 DEFINE_LONGS(HOST_R12, R12);
71 DEFINE(HOST_R15, R15); 74 DEFINE_LONGS(HOST_R13, R13);
72 DEFINE(HOST_ORIG_RAX, ORIG_RAX); 75 DEFINE_LONGS(HOST_R14, R14);
73 DEFINE(HOST_CS, CS); 76 DEFINE_LONGS(HOST_R15, R15);
74 DEFINE(HOST_SS, SS); 77 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX);
75 DEFINE(HOST_EFLAGS, EFLAGS); 78 DEFINE_LONGS(HOST_CS, CS);
79 DEFINE_LONGS(HOST_SS, SS);
80 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
76#if 0 81#if 0
77 DEFINE(HOST_FS, FS); 82 DEFINE_LONGS(HOST_FS, FS);
78 DEFINE(HOST_GS, GS); 83 DEFINE_LONGS(HOST_GS, GS);
79 DEFINE(HOST_DS, DS); 84 DEFINE_LONGS(HOST_DS, DS);
80 DEFINE(HOST_ES, ES); 85 DEFINE_LONGS(HOST_ES, ES);
81#endif 86#endif
82 87
83 DEFINE(HOST_IP, RIP); 88 DEFINE_LONGS(HOST_IP, RIP);
84 DEFINE(HOST_SP, RSP); 89 DEFINE_LONGS(HOST_SP, RSP);
85 DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); 90 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
86} 91}
diff --git a/arch/um/sys-x86_64/util/Makefile b/arch/um/sys-x86_64/util/Makefile
deleted file mode 100644
index 75b052cfc206..000000000000
--- a/arch/um/sys-x86_64/util/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1# Copyright 2003 - 2004 Pathscale, Inc
2# Released under the GPL
3
4hostprogs-y := mk_sc mk_thread
5always := $(hostprogs-y)
6
7HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um
8HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um
diff --git a/arch/um/sys-x86_64/util/mk_sc.c b/arch/um/sys-x86_64/util/mk_sc.c
deleted file mode 100644
index 7619bc377c1f..000000000000
--- a/arch/um/sys-x86_64/util/mk_sc.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/* Copyright (C) 2003 - 2004 PathScale, Inc
2 * Released under the GPL
3 */
4
5#include <stdio.h>
6#include <user-offsets.h>
7
8#define SC_OFFSET(name) \
9 printf("#define " #name \
10 "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
11 name)
12
13int main(int argc, char **argv)
14{
15 SC_OFFSET(SC_RBX);
16 SC_OFFSET(SC_RCX);
17 SC_OFFSET(SC_RDX);
18 SC_OFFSET(SC_RSI);
19 SC_OFFSET(SC_RDI);
20 SC_OFFSET(SC_RBP);
21 SC_OFFSET(SC_RAX);
22 SC_OFFSET(SC_R8);
23 SC_OFFSET(SC_R9);
24 SC_OFFSET(SC_R10);
25 SC_OFFSET(SC_R11);
26 SC_OFFSET(SC_R12);
27 SC_OFFSET(SC_R13);
28 SC_OFFSET(SC_R14);
29 SC_OFFSET(SC_R15);
30 SC_OFFSET(SC_IP);
31 SC_OFFSET(SC_SP);
32 SC_OFFSET(SC_CR2);
33 SC_OFFSET(SC_ERR);
34 SC_OFFSET(SC_TRAPNO);
35 SC_OFFSET(SC_CS);
36 SC_OFFSET(SC_FS);
37 SC_OFFSET(SC_GS);
38 SC_OFFSET(SC_EFLAGS);
39 SC_OFFSET(SC_SIGMASK);
40#if 0
41 SC_OFFSET(SC_ORIG_RAX);
42 SC_OFFSET(SC_DS);
43 SC_OFFSET(SC_ES);
44 SC_OFFSET(SC_SS);
45#endif
46 return(0);
47}
diff --git a/arch/um/sys-x86_64/util/mk_thread.c b/arch/um/sys-x86_64/util/mk_thread.c
deleted file mode 100644
index 15517396e9cf..000000000000
--- a/arch/um/sys-x86_64/util/mk_thread.c
+++ /dev/null
@@ -1,20 +0,0 @@
1#include <stdio.h>
2#include <kernel-offsets.h>
3
4int main(int argc, char **argv)
5{
6 printf("/*\n");
7 printf(" * Generated by mk_thread\n");
8 printf(" */\n");
9 printf("\n");
10 printf("#ifndef __UM_THREAD_H\n");
11 printf("#define __UM_THREAD_H\n");
12 printf("\n");
13#ifdef TASK_EXTERN_PID
14 printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n",
15 TASK_EXTERN_PID);
16#endif
17 printf("\n");
18 printf("#endif\n");
19 return(0);
20}
diff --git a/arch/um/util/Makefile b/arch/um/util/Makefile
deleted file mode 100644
index 4c7551c28033..000000000000
--- a/arch/um/util/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1hostprogs-y := mk_task mk_constants
2always := $(hostprogs-y)
3
4HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um
5HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um
diff --git a/arch/um/util/mk_constants.c b/arch/um/util/mk_constants.c
deleted file mode 100644
index ab217becc36a..000000000000
--- a/arch/um/util/mk_constants.c
+++ /dev/null
@@ -1,32 +0,0 @@
1#include <stdio.h>
2#include <kernel-offsets.h>
3
4#define SHOW_INT(sym) printf("#define %s %d\n", #sym, sym)
5#define SHOW_STR(sym) printf("#define %s %s\n", #sym, sym)
6
7int main(int argc, char **argv)
8{
9 printf("/*\n");
10 printf(" * Generated by mk_constants\n");
11 printf(" */\n");
12 printf("\n");
13 printf("#ifndef __UM_CONSTANTS_H\n");
14 printf("#define __UM_CONSTANTS_H\n");
15 printf("\n");
16
17 SHOW_INT(UM_KERN_PAGE_SIZE);
18
19 SHOW_STR(UM_KERN_EMERG);
20 SHOW_STR(UM_KERN_ALERT);
21 SHOW_STR(UM_KERN_CRIT);
22 SHOW_STR(UM_KERN_ERR);
23 SHOW_STR(UM_KERN_WARNING);
24 SHOW_STR(UM_KERN_NOTICE);
25 SHOW_STR(UM_KERN_INFO);
26 SHOW_STR(UM_KERN_DEBUG);
27
28 SHOW_INT(UM_NSEC_PER_SEC);
29 printf("\n");
30 printf("#endif\n");
31 return(0);
32}
diff --git a/arch/um/util/mk_task.c b/arch/um/util/mk_task.c
deleted file mode 100644
index 36c9606505e2..000000000000
--- a/arch/um/util/mk_task.c
+++ /dev/null
@@ -1,30 +0,0 @@
1#include <stdio.h>
2#include <kernel-offsets.h>
3
4void print_ptr(char *name, char *type, int offset)
5{
6 printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type,
7 offset);
8}
9
10void print(char *name, char *type, int offset)
11{
12 printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
13 offset);
14}
15
16int main(int argc, char **argv)
17{
18 printf("/*\n");
19 printf(" * Generated by mk_task\n");
20 printf(" */\n");
21 printf("\n");
22 printf("#ifndef __TASK_H\n");
23 printf("#define __TASK_H\n");
24 printf("\n");
25 print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS);
26 print("TASK_PID", "int", TASK_PID);
27 printf("\n");
28 printf("#endif\n");
29 return(0);
30}
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 0969d570f3b5..21afa69a086d 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -308,7 +308,7 @@ config HPET_TIMER
308 present. The HPET provides a stable time base on SMP 308 present. The HPET provides a stable time base on SMP
309 systems, unlike the TSC, but it is more expensive to access, 309 systems, unlike the TSC, but it is more expensive to access,
310 as it is off-chip. You can find the HPET spec at 310 as it is off-chip. You can find the HPET spec at
311 <http://www.intel.com/labs/platcomp/hpet/hpetspec.htm>. 311 <http://www.intel.com/hardwaredesign/hpetspec.htm>.
312 312
313config X86_PM_TIMER 313config X86_PM_TIMER
314 bool "PM timer" 314 bool "PM timer"
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index 66e2821533db..0903cc1faef2 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -425,7 +425,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
425 rsp = (unsigned long) ka->sa.sa_restorer; 425 rsp = (unsigned long) ka->sa.sa_restorer;
426 } 426 }
427 427
428 return (void __user *)((rsp - frame_size) & -8UL); 428 rsp -= frame_size;
429 /* Align the stack pointer according to the i386 ABI,
430 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
431 rsp = ((rsp + 4) & -16ul) - 4;
432 return (void __user *) rsp;
429} 433}
430 434
431int ia32_setup_frame(int sig, struct k_sigaction *ka, 435int ia32_setup_frame(int sig, struct k_sigaction *ka,
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 4e34b0f9d613..ab3f87aaff70 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -17,6 +17,8 @@
17#include <linux/ioport.h> 17#include <linux/ioport.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/kexec.h> 19#include <linux/kexec.h>
20#include <linux/module.h>
21
20#include <asm/page.h> 22#include <asm/page.h>
21#include <asm/e820.h> 23#include <asm/e820.h>
22#include <asm/proto.h> 24#include <asm/proto.h>
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 4592bf21fcaf..b92e5f45ed46 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -270,26 +270,26 @@ ENTRY(level3_kernel_pgt)
270.org 0x4000 270.org 0x4000
271ENTRY(level2_ident_pgt) 271ENTRY(level2_ident_pgt)
272 /* 40MB for bootup. */ 272 /* 40MB for bootup. */
273 .quad 0x0000000000000183 273 .quad 0x0000000000000083
274 .quad 0x0000000000200183 274 .quad 0x0000000000200083
275 .quad 0x0000000000400183 275 .quad 0x0000000000400083
276 .quad 0x0000000000600183 276 .quad 0x0000000000600083
277 .quad 0x0000000000800183 277 .quad 0x0000000000800083
278 .quad 0x0000000000A00183 278 .quad 0x0000000000A00083
279 .quad 0x0000000000C00183 279 .quad 0x0000000000C00083
280 .quad 0x0000000000E00183 280 .quad 0x0000000000E00083
281 .quad 0x0000000001000183 281 .quad 0x0000000001000083
282 .quad 0x0000000001200183 282 .quad 0x0000000001200083
283 .quad 0x0000000001400183 283 .quad 0x0000000001400083
284 .quad 0x0000000001600183 284 .quad 0x0000000001600083
285 .quad 0x0000000001800183 285 .quad 0x0000000001800083
286 .quad 0x0000000001A00183 286 .quad 0x0000000001A00083
287 .quad 0x0000000001C00183 287 .quad 0x0000000001C00083
288 .quad 0x0000000001E00183 288 .quad 0x0000000001E00083
289 .quad 0x0000000002000183 289 .quad 0x0000000002000083
290 .quad 0x0000000002200183 290 .quad 0x0000000002200083
291 .quad 0x0000000002400183 291 .quad 0x0000000002400083
292 .quad 0x0000000002600183 292 .quad 0x0000000002600083
293 /* Temporary mappings for the super early allocator in arch/x86_64/mm/init.c */ 293 /* Temporary mappings for the super early allocator in arch/x86_64/mm/init.c */
294 .globl temp_boot_pmds 294 .globl temp_boot_pmds
295temp_boot_pmds: 295temp_boot_pmds:
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index df08c43276a0..76a28b007be9 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -77,9 +77,9 @@ static inline int is_IF_modifier(kprobe_opcode_t *insn)
77int __kprobes arch_prepare_kprobe(struct kprobe *p) 77int __kprobes arch_prepare_kprobe(struct kprobe *p)
78{ 78{
79 /* insn: must be on special executable page on x86_64. */ 79 /* insn: must be on special executable page on x86_64. */
80 up(&kprobe_mutex);
81 p->ainsn.insn = get_insn_slot();
82 down(&kprobe_mutex); 80 down(&kprobe_mutex);
81 p->ainsn.insn = get_insn_slot();
82 up(&kprobe_mutex);
83 if (!p->ainsn.insn) { 83 if (!p->ainsn.insn) {
84 return -ENOMEM; 84 return -ENOMEM;
85 } 85 }
@@ -231,9 +231,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
231 231
232void __kprobes arch_remove_kprobe(struct kprobe *p) 232void __kprobes arch_remove_kprobe(struct kprobe *p)
233{ 233{
234 up(&kprobe_mutex);
235 free_insn_slot(p->ainsn.insn);
236 down(&kprobe_mutex); 234 down(&kprobe_mutex);
235 free_insn_slot(p->ainsn.insn);
236 up(&kprobe_mutex);
237} 237}
238 238
239static inline void save_previous_kprobe(void) 239static inline void save_previous_kprobe(void)
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 08203b07f4bd..69541db5ff2c 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -54,9 +54,12 @@ void mce_log(struct mce *mce)
54{ 54{
55 unsigned next, entry; 55 unsigned next, entry;
56 mce->finished = 0; 56 mce->finished = 0;
57 smp_wmb(); 57 wmb();
58 for (;;) { 58 for (;;) {
59 entry = rcu_dereference(mcelog.next); 59 entry = rcu_dereference(mcelog.next);
60 /* The rmb forces the compiler to reload next in each
61 iteration */
62 rmb();
60 for (;;) { 63 for (;;) {
61 /* When the buffer fills up discard new entries. Assume 64 /* When the buffer fills up discard new entries. Assume
62 that the earlier errors are the more interesting. */ 65 that the earlier errors are the more interesting. */
@@ -69,6 +72,7 @@ void mce_log(struct mce *mce)
69 entry++; 72 entry++;
70 continue; 73 continue;
71 } 74 }
75 break;
72 } 76 }
73 smp_rmb(); 77 smp_rmb();
74 next = entry + 1; 78 next = entry + 1;
@@ -76,9 +80,9 @@ void mce_log(struct mce *mce)
76 break; 80 break;
77 } 81 }
78 memcpy(mcelog.entry + entry, mce, sizeof(struct mce)); 82 memcpy(mcelog.entry + entry, mce, sizeof(struct mce));
79 smp_wmb(); 83 wmb();
80 mcelog.entry[entry].finished = 1; 84 mcelog.entry[entry].finished = 1;
81 smp_wmb(); 85 wmb();
82 86
83 if (!test_and_set_bit(0, &console_logged)) 87 if (!test_and_set_bit(0, &console_logged))
84 notify_user = 1; 88 notify_user = 1;
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 351d8d64c2fb..cb28df14ff6f 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -836,6 +836,23 @@ static int __init init_amd(struct cpuinfo_x86 *c)
836 int r; 836 int r;
837 int level; 837 int level;
838 838
839#ifdef CONFIG_SMP
840 unsigned long value;
841
842 /*
843 * Disable TLB flush filter by setting HWCR.FFDIS on K8
844 * bit 6 of msr C001_0015
845 *
846 * Errata 63 for SH-B3 steppings
847 * Errata 122 for all steppings (F+ have it disabled by default)
848 */
849 if (c->x86 == 15) {
850 rdmsrl(MSR_K8_HWCR, value);
851 value |= 1 << 6;
852 wrmsrl(MSR_K8_HWCR, value);
853 }
854#endif
855
839 /* Bit 31 in normal CPUID used for nonstandard 3DNow ID; 856 /* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
840 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */ 857 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */
841 clear_bit(0*32+31, &c->x86_capability); 858 clear_bit(0*32+31, &c->x86_capability);
@@ -950,13 +967,12 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
950static void srat_detect_node(void) 967static void srat_detect_node(void)
951{ 968{
952#ifdef CONFIG_NUMA 969#ifdef CONFIG_NUMA
953 unsigned apicid, node; 970 unsigned node;
954 int cpu = smp_processor_id(); 971 int cpu = smp_processor_id();
955 972
956 /* Don't do the funky fallback heuristics the AMD version employs 973 /* Don't do the funky fallback heuristics the AMD version employs
957 for now. */ 974 for now. */
958 apicid = phys_proc_id[cpu]; 975 node = apicid_to_node[hard_smp_processor_id()];
959 node = apicid_to_node[apicid];
960 if (node == NUMA_NO_NODE) 976 if (node == NUMA_NO_NODE)
961 node = 0; 977 node = 0;
962 cpu_to_node[cpu] = node; 978 cpu_to_node[cpu] = node;
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index bd33be24a386..79190891fbc5 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -87,6 +87,10 @@ void __init setup_per_cpu_areas(void)
87 int i; 87 int i;
88 unsigned long size; 88 unsigned long size;
89 89
90#ifdef CONFIG_HOTPLUG_CPU
91 prefill_possible_map();
92#endif
93
90 /* Copy section for each CPU (we discard the original) */ 94 /* Copy section for each CPU (we discard the original) */
91 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES); 95 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
92#ifdef CONFIG_MODULES 96#ifdef CONFIG_MODULES
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index e12d7baeb33e..658a81b33f3b 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -892,7 +892,7 @@ static __init void disable_smp(void)
892 * those NR_CPUS, hence cpu_possible_map represents entire NR_CPUS range. 892 * those NR_CPUS, hence cpu_possible_map represents entire NR_CPUS range.
893 * - Ashok Raj 893 * - Ashok Raj
894 */ 894 */
895static void prefill_possible_map(void) 895__init void prefill_possible_map(void)
896{ 896{
897 int i; 897 int i;
898 for (i = 0; i < NR_CPUS; i++) 898 for (i = 0; i < NR_CPUS; i++)
@@ -967,10 +967,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
967 current_cpu_data = boot_cpu_data; 967 current_cpu_data = boot_cpu_data;
968 current_thread_info()->cpu = 0; /* needed? */ 968 current_thread_info()->cpu = 0; /* needed? */
969 969
970#ifdef CONFIG_HOTPLUG_CPU
971 prefill_possible_map();
972#endif
973
974 if (smp_sanity_check(max_cpus) < 0) { 970 if (smp_sanity_check(max_cpus) < 0) {
975 printk(KERN_INFO "SMP disabled\n"); 971 printk(KERN_INFO "SMP disabled\n");
976 disable_smp(); 972 disable_smp();
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
index ebb9abf3ce6d..f066c6ab3618 100644
--- a/arch/x86_64/kernel/suspend.c
+++ b/arch/x86_64/kernel/suspend.c
@@ -11,6 +11,8 @@
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/suspend.h> 12#include <linux/suspend.h>
13#include <asm/proto.h> 13#include <asm/proto.h>
14#include <asm/page.h>
15#include <asm/pgtable.h>
14 16
15struct saved_context saved_context; 17struct saved_context saved_context;
16 18
@@ -140,4 +142,129 @@ void fix_processor_context(void)
140 142
141} 143}
142 144
145#ifdef CONFIG_SOFTWARE_SUSPEND
146/* Defined in arch/x86_64/kernel/suspend_asm.S */
147extern int restore_image(void);
143 148
149pgd_t *temp_level4_pgt;
150
151static void **pages;
152
153static inline void *__add_page(void)
154{
155 void **c;
156
157 c = (void **)get_usable_page(GFP_ATOMIC);
158 if (c) {
159 *c = pages;
160 pages = c;
161 }
162 return c;
163}
164
165static inline void *__next_page(void)
166{
167 void **c;
168
169 c = pages;
170 if (c) {
171 pages = *c;
172 *c = NULL;
173 }
174 return c;
175}
176
177/*
178 * Try to allocate as many usable pages as needed and daisy chain them.
179 * If one allocation fails, free the pages allocated so far
180 */
181static int alloc_usable_pages(unsigned long n)
182{
183 void *p;
184
185 pages = NULL;
186 do
187 if (!__add_page())
188 break;
189 while (--n);
190 if (n) {
191 p = __next_page();
192 while (p) {
193 free_page((unsigned long)p);
194 p = __next_page();
195 }
196 return -ENOMEM;
197 }
198 return 0;
199}
200
201static void res_phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
202{
203 long i, j;
204
205 i = pud_index(address);
206 pud = pud + i;
207 for (; i < PTRS_PER_PUD; pud++, i++) {
208 unsigned long paddr;
209 pmd_t *pmd;
210
211 paddr = address + i*PUD_SIZE;
212 if (paddr >= end)
213 break;
214
215 pmd = (pmd_t *)__next_page();
216 set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE));
217 for (j = 0; j < PTRS_PER_PMD; pmd++, j++, paddr += PMD_SIZE) {
218 unsigned long pe;
219
220 if (paddr >= end)
221 break;
222 pe = _PAGE_NX | _PAGE_PSE | _KERNPG_TABLE | paddr;
223 pe &= __supported_pte_mask;
224 set_pmd(pmd, __pmd(pe));
225 }
226 }
227}
228
229static void set_up_temporary_mappings(void)
230{
231 unsigned long start, end, next;
232
233 temp_level4_pgt = (pgd_t *)__next_page();
234
235 /* It is safe to reuse the original kernel mapping */
236 set_pgd(temp_level4_pgt + pgd_index(__START_KERNEL_map),
237 init_level4_pgt[pgd_index(__START_KERNEL_map)]);
238
239 /* Set up the direct mapping from scratch */
240 start = (unsigned long)pfn_to_kaddr(0);
241 end = (unsigned long)pfn_to_kaddr(end_pfn);
242
243 for (; start < end; start = next) {
244 pud_t *pud = (pud_t *)__next_page();
245 next = start + PGDIR_SIZE;
246 if (next > end)
247 next = end;
248 res_phys_pud_init(pud, __pa(start), __pa(next));
249 set_pgd(temp_level4_pgt + pgd_index(start),
250 mk_kernel_pgd(__pa(pud)));
251 }
252}
253
254int swsusp_arch_resume(void)
255{
256 unsigned long n;
257
258 n = ((end_pfn << PAGE_SHIFT) + PUD_SIZE - 1) >> PUD_SHIFT;
259 n += (n + PTRS_PER_PUD - 1) / PTRS_PER_PUD + 1;
260 pr_debug("swsusp_arch_resume(): pages needed = %lu\n", n);
261 if (alloc_usable_pages(n)) {
262 free_eaten_memory();
263 return -ENOMEM;
264 }
265 /* We have got enough memory and from now on we cannot recover */
266 set_up_temporary_mappings();
267 restore_image();
268 return 0;
269}
270#endif /* CONFIG_SOFTWARE_SUSPEND */
diff --git a/arch/x86_64/kernel/suspend_asm.S b/arch/x86_64/kernel/suspend_asm.S
index 4d659e97df10..320b6fb00cca 100644
--- a/arch/x86_64/kernel/suspend_asm.S
+++ b/arch/x86_64/kernel/suspend_asm.S
@@ -39,12 +39,13 @@ ENTRY(swsusp_arch_suspend)
39 call swsusp_save 39 call swsusp_save
40 ret 40 ret
41 41
42ENTRY(swsusp_arch_resume) 42ENTRY(restore_image)
43 /* set up cr3 */ 43 /* switch to temporary page tables */
44 leaq init_level4_pgt(%rip),%rax 44 movq $__PAGE_OFFSET, %rdx
45 subq $__START_KERNEL_map,%rax 45 movq temp_level4_pgt(%rip), %rax
46 movq %rax,%cr3 46 subq %rdx, %rax
47 47 movq %rax, %cr3
48 /* Flush TLB */
48 movq mmu_cr4_features(%rip), %rax 49 movq mmu_cr4_features(%rip), %rax
49 movq %rax, %rdx 50 movq %rax, %rdx
50 andq $~(1<<7), %rdx # PGE 51 andq $~(1<<7), %rdx # PGE
@@ -69,6 +70,10 @@ loop:
69 movq pbe_next(%rdx), %rdx 70 movq pbe_next(%rdx), %rdx
70 jmp loop 71 jmp loop
71done: 72done:
73 /* go back to the original page tables */
74 leaq init_level4_pgt(%rip), %rax
75 subq $__START_KERNEL_map, %rax
76 movq %rax, %cr3
72 /* Flush TLB, including "global" things (vmalloc) */ 77 /* Flush TLB, including "global" things (vmalloc) */
73 movq mmu_cr4_features(%rip), %rax 78 movq mmu_cr4_features(%rip), %rax
74 movq %rax, %rdx 79 movq %rax, %rdx
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 2373cb8b8625..703acde2a1a5 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -959,9 +959,6 @@ static __init int unsynchronized_tsc(void)
959 are handled in the OEM check above. */ 959 are handled in the OEM check above. */
960 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) 960 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
961 return 0; 961 return 0;
962 /* All in a single socket - should be synchronized */
963 if (cpus_weight(cpu_core_map[0]) == num_online_cpus())
964 return 0;
965#endif 962#endif
966 /* Assume multi socket systems are not synchronized */ 963 /* Assume multi socket systems are not synchronized */
967 return num_online_cpus() > 1; 964 return num_online_cpus() > 1;
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 80a49d9bd8a7..214803821001 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -167,18 +167,16 @@ void __init numa_init_array(void)
167 mapping. To avoid this fill in the mapping for all possible 167 mapping. To avoid this fill in the mapping for all possible
168 CPUs, as the number of CPUs is not known yet. 168 CPUs, as the number of CPUs is not known yet.
169 We round robin the existing nodes. */ 169 We round robin the existing nodes. */
170 rr = 0; 170 rr = first_node(node_online_map);
171 for (i = 0; i < NR_CPUS; i++) { 171 for (i = 0; i < NR_CPUS; i++) {
172 if (cpu_to_node[i] != NUMA_NO_NODE) 172 if (cpu_to_node[i] != NUMA_NO_NODE)
173 continue; 173 continue;
174 cpu_to_node[i] = rr;
174 rr = next_node(rr, node_online_map); 175 rr = next_node(rr, node_online_map);
175 if (rr == MAX_NUMNODES) 176 if (rr == MAX_NUMNODES)
176 rr = first_node(node_online_map); 177 rr = first_node(node_online_map);
177 cpu_to_node[i] = rr;
178 rr++;
179 } 178 }
180 179
181 set_bit(0, &node_to_cpumask[cpu_to_node(0)]);
182} 180}
183 181
184#ifdef CONFIG_NUMA_EMU 182#ifdef CONFIG_NUMA_EMU
@@ -266,9 +264,7 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
266 264
267__cpuinit void numa_add_cpu(int cpu) 265__cpuinit void numa_add_cpu(int cpu)
268{ 266{
269 /* BP is initialized elsewhere */ 267 set_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
270 if (cpu)
271 set_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
272} 268}
273 269
274unsigned long __init numa_free_all_bootmem(void) 270unsigned long __init numa_free_all_bootmem(void)
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
index 94862e1ec032..b90e8fe9eeb0 100644
--- a/arch/x86_64/mm/pageattr.c
+++ b/arch/x86_64/mm/pageattr.c
@@ -220,8 +220,6 @@ void global_flush_tlb(void)
220 down_read(&init_mm.mmap_sem); 220 down_read(&init_mm.mmap_sem);
221 df = xchg(&df_list, NULL); 221 df = xchg(&df_list, NULL);
222 up_read(&init_mm.mmap_sem); 222 up_read(&init_mm.mmap_sem);
223 if (!df)
224 return;
225 flush_map((df && !df->next) ? df->address : 0); 223 flush_map((df && !df->next) ? df->address : 0);
226 for (; df; df = next_df) { 224 for (; df; df = next_df) {
227 next_df = df->next; 225 next_df = df->next;
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 09887c96e9a1..de19501aa809 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -402,8 +402,8 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
402 __pci_mmap_set_flags(dev, vma, mmap_state); 402 __pci_mmap_set_flags(dev, vma, mmap_state);
403 __pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine); 403 __pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine);
404 404
405 ret = io_remap_page_range(vma, vma->vm_start, vma->vm_pgoff<<PAGE_SHIFT, 405 ret = io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
406 vma->vm_end - vma->vm_start, vma->vm_page_prot); 406 vma->vm_end - vma->vm_start,vma->vm_page_prot);
407 407
408 return ret; 408 return ret;
409} 409}
diff --git a/arch/xtensa/kernel/platform.c b/arch/xtensa/kernel/platform.c
index cf1362784443..03674daabc66 100644
--- a/arch/xtensa/kernel/platform.c
+++ b/arch/xtensa/kernel/platform.c
@@ -39,7 +39,7 @@ _F(int, pcibios_fixup, (void), { return 0; });
39_F(int, get_rtc_time, (time_t* t), { return 0; }); 39_F(int, get_rtc_time, (time_t* t), { return 0; });
40_F(int, set_rtc_time, (time_t t), { return 0; }); 40_F(int, set_rtc_time, (time_t t), { return 0; });
41 41
42#if CONFIG_XTENSA_CALIBRATE_CCOUNT 42#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
43_F(void, calibrate_ccount, (void), 43_F(void, calibrate_ccount, (void),
44{ 44{
45 printk ("ERROR: Cannot calibrate cpu frequency! Assuming 100MHz.\n"); 45 printk ("ERROR: Cannot calibrate cpu frequency! Assuming 100MHz.\n");
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index c83bb0d41787..08ef6d82ee51 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -457,7 +457,7 @@ int
457dump_task_fpu(struct pt_regs *regs, struct task_struct *task, elf_fpregset_t *r) 457dump_task_fpu(struct pt_regs *regs, struct task_struct *task, elf_fpregset_t *r)
458{ 458{
459/* see asm/coprocessor.h for this magic number 16 */ 459/* see asm/coprocessor.h for this magic number 16 */
460#if TOTAL_CPEXTRA_SIZE > 16 460#if XTENSA_CP_EXTRA_SIZE > 16
461 do_save_fpregs (r, regs, task); 461 do_save_fpregs (r, regs, task);
462 462
463 /* For now, bit 16 means some extra state may be present: */ 463 /* For now, bit 16 means some extra state may be present: */
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index 1f5bf5d624e4..513ed8d67766 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -304,7 +304,7 @@ void __init setup_arch(char **cmdline_p)
304# endif 304# endif
305#endif 305#endif
306 306
307#if CONFIG_PCI 307#ifdef CONFIG_PCI
308 platform_pcibios_init(); 308 platform_pcibios_init();
309#endif 309#endif
310} 310}
diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index dc42cede9394..e252b61e45a5 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -182,7 +182,7 @@ restore_cpextra (struct _cpstate *buf)
182 182
183 struct task_struct *tsk = current; 183 struct task_struct *tsk = current;
184 release_all_cp(tsk); 184 release_all_cp(tsk);
185 return __copy_from_user(tsk->thread.cpextra, buf, TOTAL_CPEXTRA_SIZE); 185 return __copy_from_user(tsk->thread.cpextra, buf, XTENSA_CP_EXTRA_SIZE);
186#endif 186#endif
187 return 0; 187 return 0;
188} 188}
diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index 1ac7d5ce7456..8e423d1335ce 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -68,7 +68,7 @@ void __init time_init(void)
68 * speed for the CALIBRATE. 68 * speed for the CALIBRATE.
69 */ 69 */
70 70
71#if CONFIG_XTENSA_CALIBRATE_CCOUNT 71#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
72 printk("Calibrating CPU frequency "); 72 printk("Calibrating CPU frequency ");
73 platform_calibrate_ccount(); 73 platform_calibrate_ccount();
74 printk("%d.%02d MHz\n", (int)ccount_per_jiffy/(1000000/HZ), 74 printk("%d.%02d MHz\n", (int)ccount_per_jiffy/(1000000/HZ),
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index 56aace84aaeb..5a91d6c9e66d 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -239,7 +239,7 @@ void __init mem_init(void)
239 high_memory = (void *) __va(max_mapnr << PAGE_SHIFT); 239 high_memory = (void *) __va(max_mapnr << PAGE_SHIFT);
240 highmemsize = 0; 240 highmemsize = 0;
241 241
242#if CONFIG_HIGHMEM 242#ifdef CONFIG_HIGHMEM
243#error HIGHGMEM not implemented in init.c 243#error HIGHGMEM not implemented in init.c
244#endif 244#endif
245 245
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c
index 141b4c237a50..2b850e5860a0 100644
--- a/drivers/acorn/char/pcf8583.c
+++ b/drivers/acorn/char/pcf8583.c
@@ -23,12 +23,13 @@ static struct i2c_driver pcf8583_driver;
23 23
24static unsigned short ignore[] = { I2C_CLIENT_END }; 24static unsigned short ignore[] = { I2C_CLIENT_END };
25static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END }; 25static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END };
26static unsigned short *forces[] = { NULL };
26 27
27static struct i2c_client_address_data addr_data = { 28static struct i2c_client_address_data addr_data = {
28 .normal_i2c = normal_addr, 29 .normal_i2c = normal_addr,
29 .probe = ignore, 30 .probe = ignore,
30 .ignore = ignore, 31 .ignore = ignore,
31 .force = ignore, 32 .forces = forces,
32}; 33};
33 34
34#define DAT(x) ((unsigned int)(x->dev.driver_data)) 35#define DAT(x) ((unsigned int)(x->dev.driver_data))
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index bfa8b76de403..2dbb1b0f11d5 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -58,9 +58,8 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
58 return_VALUE(-EAGAIN); 58 return_VALUE(-EAGAIN);
59 59
60 result = acpi_bus_receive_event(&event); 60 result = acpi_bus_receive_event(&event);
61 if (result) { 61 if (result)
62 return_VALUE(-EIO); 62 return_VALUE(result);
63 }
64 63
65 chars_remaining = sprintf(str, "%s %s %08x %08x\n", 64 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
66 event.device_class ? event. 65 event.device_class ? event.
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index e36c5da2b31a..3937adf4e5e5 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -96,7 +96,7 @@ struct acpi_find_pci_root {
96static acpi_status 96static acpi_status
97do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) 97do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
98{ 98{
99 int *busnr = (int *)data; 99 unsigned long *busnr = (unsigned long *)data;
100 struct acpi_resource_address64 address; 100 struct acpi_resource_address64 address;
101 101
102 if (resource->id != ACPI_RSTYPE_ADDRESS16 && 102 if (resource->id != ACPI_RSTYPE_ADDRESS16 &&
@@ -115,13 +115,13 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
115static int get_root_bridge_busnr(acpi_handle handle) 115static int get_root_bridge_busnr(acpi_handle handle)
116{ 116{
117 acpi_status status; 117 acpi_status status;
118 int bus, bbn; 118 unsigned long bus, bbn;
119 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 119 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
120 120
121 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 121 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
122 122
123 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, 123 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL,
124 (unsigned long *)&bbn); 124 &bbn);
125 if (status == AE_NOT_FOUND) { 125 if (status == AE_NOT_FOUND) {
126 /* Assume bus = 0 */ 126 /* Assume bus = 0 */
127 printk(KERN_INFO PREFIX 127 printk(KERN_INFO PREFIX
@@ -153,7 +153,7 @@ static int get_root_bridge_busnr(acpi_handle handle)
153 } 153 }
154 exit: 154 exit:
155 acpi_os_free(buffer.pointer); 155 acpi_os_free(buffer.pointer);
156 return bbn; 156 return (int)bbn;
157} 157}
158 158
159static acpi_status 159static acpi_status
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index d74a7c5e75dd..4b6bf19c39c0 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -795,7 +795,7 @@ static void drain_rx_pools (amb_dev * dev) {
795} 795}
796 796
797static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, 797static inline void fill_rx_pool (amb_dev * dev, unsigned char pool,
798 unsigned int __nocast priority) 798 gfp_t priority)
799{ 799{
800 rx_in rx; 800 rx_in rx;
801 amb_rxq * rxq; 801 amb_rxq * rxq;
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 58219744f5db..7f7ec288824d 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1374,8 +1374,7 @@ static void reset_chip (struct fs_dev *dev)
1374 } 1374 }
1375} 1375}
1376 1376
1377static void __devinit *aligned_kmalloc (int size, unsigned int __nocast flags, 1377static void __devinit *aligned_kmalloc (int size, gfp_t flags, int alignment)
1378 int alignment)
1379{ 1378{
1380 void *t; 1379 void *t;
1381 1380
@@ -1466,7 +1465,7 @@ static inline int nr_buffers_in_freepool (struct fs_dev *dev, struct freepool *f
1466 working again after that... -- REW */ 1465 working again after that... -- REW */
1467 1466
1468static void top_off_fp (struct fs_dev *dev, struct freepool *fp, 1467static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
1469 unsigned int __nocast gfp_flags) 1468 gfp_t gfp_flags)
1470{ 1469{
1471 struct FS_BPENTRY *qe, *ne; 1470 struct FS_BPENTRY *qe, *ne;
1472 struct sk_buff *skb; 1471 struct sk_buff *skb;
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 2bf723a7b6e6..14f6a6201da3 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -178,14 +178,12 @@ fore200e_irq_itoa(int irq)
178 178
179 179
180static void* 180static void*
181fore200e_kmalloc(int size, int flags) 181fore200e_kmalloc(int size, gfp_t flags)
182{ 182{
183 void* chunk = kmalloc(size, flags); 183 void *chunk = kzalloc(size, flags);
184 184
185 if (chunk) 185 if (!chunk)
186 memset(chunk, 0x00, size); 186 printk(FORE200E "kmalloc() failed, requested size = %d, flags = 0x%x\n", size, flags);
187 else
188 printk(FORE200E "kmalloc() failed, requested size = %d, flags = 0x%x\n", size, flags);
189 187
190 return chunk; 188 return chunk;
191} 189}
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 3b112e3542f8..ce23dc8c18c5 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -669,6 +669,7 @@ void class_device_destroy(struct class *cls, dev_t devt)
669int class_device_rename(struct class_device *class_dev, char *new_name) 669int class_device_rename(struct class_device *class_dev, char *new_name)
670{ 670{
671 int error = 0; 671 int error = 0;
672 char *old_class_name = NULL, *new_class_name = NULL;
672 673
673 class_dev = class_device_get(class_dev); 674 class_dev = class_device_get(class_dev);
674 if (!class_dev) 675 if (!class_dev)
@@ -677,12 +678,24 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
677 pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, 678 pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id,
678 new_name); 679 new_name);
679 680
681 if (class_dev->dev)
682 old_class_name = make_class_name(class_dev);
683
680 strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); 684 strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN);
681 685
682 error = kobject_rename(&class_dev->kobj, new_name); 686 error = kobject_rename(&class_dev->kobj, new_name);
683 687
688 if (class_dev->dev) {
689 new_class_name = make_class_name(class_dev);
690 sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
691 new_class_name);
692 sysfs_remove_link(&class_dev->dev->kobj, old_class_name);
693 }
684 class_device_put(class_dev); 694 class_device_put(class_dev);
685 695
696 kfree(old_class_name);
697 kfree(new_class_name);
698
686 return error; 699 return error;
687} 700}
688 701
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index d5bbce38282f..3565e9795301 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -40,6 +40,9 @@
40 */ 40 */
41void device_bind_driver(struct device * dev) 41void device_bind_driver(struct device * dev)
42{ 42{
43 if (klist_node_attached(&dev->knode_driver))
44 return;
45
43 pr_debug("bound device '%s' to driver '%s'\n", 46 pr_debug("bound device '%s' to driver '%s'\n",
44 dev->bus_id, dev->driver->name); 47 dev->bus_id, dev->driver->name);
45 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); 48 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 60a7ef6a201b..e2f64f91ed05 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -156,7 +156,7 @@ dma_pool_create (const char *name, struct device *dev,
156 156
157 157
158static struct dma_page * 158static struct dma_page *
159pool_alloc_page (struct dma_pool *pool, unsigned int __nocast mem_flags) 159pool_alloc_page (struct dma_pool *pool, gfp_t mem_flags)
160{ 160{
161 struct dma_page *page; 161 struct dma_page *page;
162 int mapsize; 162 int mapsize;
@@ -262,8 +262,7 @@ dma_pool_destroy (struct dma_pool *pool)
262 * If such a memory block can't be allocated, null is returned. 262 * If such a memory block can't be allocated, null is returned.
263 */ 263 */
264void * 264void *
265dma_pool_alloc (struct dma_pool *pool, unsigned int __nocast mem_flags, 265dma_pool_alloc (struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle)
266 dma_addr_t *handle)
267{ 266{
268 unsigned long flags; 267 unsigned long flags;
269 struct dma_page *page; 268 struct dma_page *page;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index c56f995aadad..486b6e1c7dfb 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -483,9 +483,6 @@ static int cciss_open(struct inode *inode, struct file *filep)
483 printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); 483 printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name);
484#endif /* CCISS_DEBUG */ 484#endif /* CCISS_DEBUG */
485 485
486 if (host->busy_initializing)
487 return -EBUSY;
488
489 if (host->busy_initializing || drv->busy_configuring) 486 if (host->busy_initializing || drv->busy_configuring)
490 return -EBUSY; 487 return -EBUSY;
491 /* 488 /*
@@ -2991,6 +2988,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
2991 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); 2988 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON);
2992 2989
2993 cciss_procinit(i); 2990 cciss_procinit(i);
2991 hba[i]->busy_initializing = 0;
2994 2992
2995 for(j=0; j < NWD; j++) { /* mfm */ 2993 for(j=0; j < NWD; j++) { /* mfm */
2996 drive_info_struct *drv = &(hba[i]->drv[j]); 2994 drive_info_struct *drv = &(hba[i]->drv[j]);
@@ -3033,7 +3031,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3033 add_disk(disk); 3031 add_disk(disk);
3034 } 3032 }
3035 3033
3036 hba[i]->busy_initializing = 0;
3037 return(1); 3034 return(1);
3038 3035
3039clean4: 3036clean4:
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
index 483d71b10cf9..baedac522945 100644
--- a/drivers/block/ll_rw_blk.c
+++ b/drivers/block/ll_rw_blk.c
@@ -2373,44 +2373,6 @@ int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
2373 2373
2374EXPORT_SYMBOL(blkdev_issue_flush); 2374EXPORT_SYMBOL(blkdev_issue_flush);
2375 2375
2376/**
2377 * blkdev_scsi_issue_flush_fn - issue flush for SCSI devices
2378 * @q: device queue
2379 * @disk: gendisk
2380 * @error_sector: error offset
2381 *
2382 * Description:
2383 * Devices understanding the SCSI command set, can use this function as
2384 * a helper for issuing a cache flush. Note: driver is required to store
2385 * the error offset (in case of error flushing) in ->sector of struct
2386 * request.
2387 */
2388int blkdev_scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
2389 sector_t *error_sector)
2390{
2391 struct request *rq = blk_get_request(q, WRITE, __GFP_WAIT);
2392 int ret;
2393
2394 rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER;
2395 rq->sector = 0;
2396 memset(rq->cmd, 0, sizeof(rq->cmd));
2397 rq->cmd[0] = 0x35;
2398 rq->cmd_len = 12;
2399 rq->data = NULL;
2400 rq->data_len = 0;
2401 rq->timeout = 60 * HZ;
2402
2403 ret = blk_execute_rq(q, disk, rq, 0);
2404
2405 if (ret && error_sector)
2406 *error_sector = rq->sector;
2407
2408 blk_put_request(rq);
2409 return ret;
2410}
2411
2412EXPORT_SYMBOL(blkdev_scsi_issue_flush_fn);
2413
2414static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io) 2376static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io)
2415{ 2377{
2416 int rw = rq_data_dir(rq); 2378 int rw = rq_data_dir(rq);
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 711d2f314ac3..94af920465b5 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -750,6 +750,14 @@ static int pf_ready(void)
750 750
751static struct request_queue *pf_queue; 751static struct request_queue *pf_queue;
752 752
753static void pf_end_request(int uptodate)
754{
755 if (pf_req) {
756 end_request(pf_req, uptodate);
757 pf_req = NULL;
758 }
759}
760
753static void do_pf_request(request_queue_t * q) 761static void do_pf_request(request_queue_t * q)
754{ 762{
755 if (pf_busy) 763 if (pf_busy)
@@ -765,7 +773,7 @@ repeat:
765 pf_count = pf_req->current_nr_sectors; 773 pf_count = pf_req->current_nr_sectors;
766 774
767 if (pf_block + pf_count > get_capacity(pf_req->rq_disk)) { 775 if (pf_block + pf_count > get_capacity(pf_req->rq_disk)) {
768 end_request(pf_req, 0); 776 pf_end_request(0);
769 goto repeat; 777 goto repeat;
770 } 778 }
771 779
@@ -780,7 +788,7 @@ repeat:
780 pi_do_claimed(pf_current->pi, do_pf_write); 788 pi_do_claimed(pf_current->pi, do_pf_write);
781 else { 789 else {
782 pf_busy = 0; 790 pf_busy = 0;
783 end_request(pf_req, 0); 791 pf_end_request(0);
784 goto repeat; 792 goto repeat;
785 } 793 }
786} 794}
@@ -798,9 +806,11 @@ static int pf_next_buf(void)
798 if (!pf_count) 806 if (!pf_count)
799 return 1; 807 return 1;
800 spin_lock_irqsave(&pf_spin_lock, saved_flags); 808 spin_lock_irqsave(&pf_spin_lock, saved_flags);
801 end_request(pf_req, 1); 809 pf_end_request(1);
802 pf_count = pf_req->current_nr_sectors; 810 if (pf_req) {
803 pf_buf = pf_req->buffer; 811 pf_count = pf_req->current_nr_sectors;
812 pf_buf = pf_req->buffer;
813 }
804 spin_unlock_irqrestore(&pf_spin_lock, saved_flags); 814 spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
805 return 1; 815 return 1;
806} 816}
@@ -810,7 +820,7 @@ static inline void next_request(int success)
810 unsigned long saved_flags; 820 unsigned long saved_flags;
811 821
812 spin_lock_irqsave(&pf_spin_lock, saved_flags); 822 spin_lock_irqsave(&pf_spin_lock, saved_flags);
813 end_request(pf_req, success); 823 pf_end_request(success);
814 pf_busy = 0; 824 pf_busy = 0;
815 do_pf_request(pf_queue); 825 do_pf_request(pf_queue);
816 spin_unlock_irqrestore(&pf_spin_lock, saved_flags); 826 spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 7e22a58926b8..a280e679b1ca 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -229,7 +229,7 @@ static int pkt_grow_pktlist(struct pktcdvd_device *pd, int nr_packets)
229 return 1; 229 return 1;
230} 230}
231 231
232static void *pkt_rb_alloc(unsigned int __nocast gfp_mask, void *data) 232static void *pkt_rb_alloc(gfp_t gfp_mask, void *data)
233{ 233{
234 return kmalloc(sizeof(struct pkt_rb_node), gfp_mask); 234 return kmalloc(sizeof(struct pkt_rb_node), gfp_mask);
235} 235}
@@ -2082,7 +2082,7 @@ static int pkt_close(struct inode *inode, struct file *file)
2082} 2082}
2083 2083
2084 2084
2085static void *psd_pool_alloc(unsigned int __nocast gfp_mask, void *data) 2085static void *psd_pool_alloc(gfp_t gfp_mask, void *data)
2086{ 2086{
2087 return kmalloc(sizeof(struct packet_stacked_data), gfp_mask); 2087 return kmalloc(sizeof(struct packet_stacked_data), gfp_mask);
2088} 2088}
diff --git a/drivers/block/scsi_ioctl.c b/drivers/block/scsi_ioctl.c
index 856c2278e9d0..382dea7b224c 100644
--- a/drivers/block/scsi_ioctl.c
+++ b/drivers/block/scsi_ioctl.c
@@ -168,6 +168,7 @@ static int verify_command(struct file *file, unsigned char *cmd)
168 safe_for_write(WRITE_VERIFY_12), 168 safe_for_write(WRITE_VERIFY_12),
169 safe_for_write(WRITE_16), 169 safe_for_write(WRITE_16),
170 safe_for_write(WRITE_LONG), 170 safe_for_write(WRITE_LONG),
171 safe_for_write(WRITE_LONG_2),
171 safe_for_write(ERASE), 172 safe_for_write(ERASE),
172 safe_for_write(GPCMD_MODE_SELECT_10), 173 safe_for_write(GPCMD_MODE_SELECT_10),
173 safe_for_write(MODE_SELECT), 174 safe_for_write(MODE_SELECT),
@@ -200,15 +201,15 @@ static int verify_command(struct file *file, unsigned char *cmd)
200 return 0; 201 return 0;
201 } 202 }
202 203
204 /* And root can do any command.. */
205 if (capable(CAP_SYS_RAWIO))
206 return 0;
207
203 if (!type) { 208 if (!type) {
204 cmd_type[cmd[0]] = CMD_WARNED; 209 cmd_type[cmd[0]] = CMD_WARNED;
205 printk(KERN_WARNING "scsi: unknown opcode 0x%02x\n", cmd[0]); 210 printk(KERN_WARNING "scsi: unknown opcode 0x%02x\n", cmd[0]);
206 } 211 }
207 212
208 /* And root can do any command.. */
209 if (capable(CAP_SYS_RAWIO))
210 return 0;
211
212 /* Otherwise fail it with an "Operation not permitted" */ 213 /* Otherwise fail it with an "Operation not permitted" */
213 return -EPERM; 214 return -EPERM;
214} 215}
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index aa0bf7ee008d..ed4d5006fe62 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -172,7 +172,7 @@ struct bulk_cs_wrap {
172 */ 172 */
173struct ub_dev; 173struct ub_dev;
174 174
175#define UB_MAX_REQ_SG 4 175#define UB_MAX_REQ_SG 9 /* cdrecord requires 32KB and maybe a header */
176#define UB_MAX_SECTORS 64 176#define UB_MAX_SECTORS 64
177 177
178/* 178/*
@@ -387,7 +387,7 @@ struct ub_dev {
387 struct bulk_cs_wrap work_bcs; 387 struct bulk_cs_wrap work_bcs;
388 struct usb_ctrlrequest work_cr; 388 struct usb_ctrlrequest work_cr;
389 389
390 int sg_stat[UB_MAX_REQ_SG+1]; 390 int sg_stat[6];
391 struct ub_scsi_trace tr; 391 struct ub_scsi_trace tr;
392}; 392};
393 393
@@ -525,12 +525,13 @@ static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr,
525 "qlen %d qmax %d\n", 525 "qlen %d qmax %d\n",
526 sc->cmd_queue.qlen, sc->cmd_queue.qmax); 526 sc->cmd_queue.qlen, sc->cmd_queue.qmax);
527 cnt += sprintf(page + cnt, 527 cnt += sprintf(page + cnt,
528 "sg %d %d %d %d %d\n", 528 "sg %d %d %d %d %d .. %d\n",
529 sc->sg_stat[0], 529 sc->sg_stat[0],
530 sc->sg_stat[1], 530 sc->sg_stat[1],
531 sc->sg_stat[2], 531 sc->sg_stat[2],
532 sc->sg_stat[3], 532 sc->sg_stat[3],
533 sc->sg_stat[4]); 533 sc->sg_stat[4],
534 sc->sg_stat[5]);
534 535
535 list_for_each (p, &sc->luns) { 536 list_for_each (p, &sc->luns) {
536 lun = list_entry(p, struct ub_lun, link); 537 lun = list_entry(p, struct ub_lun, link);
@@ -835,7 +836,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
835 return -1; 836 return -1;
836 } 837 }
837 cmd->nsg = n_elem; 838 cmd->nsg = n_elem;
838 sc->sg_stat[n_elem]++; 839 sc->sg_stat[n_elem < 5 ? n_elem : 5]++;
839 840
840 /* 841 /*
841 * build the command 842 * build the command
@@ -891,7 +892,7 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
891 return -1; 892 return -1;
892 } 893 }
893 cmd->nsg = n_elem; 894 cmd->nsg = n_elem;
894 sc->sg_stat[n_elem]++; 895 sc->sg_stat[n_elem < 5 ? n_elem : 5]++;
895 896
896 memcpy(&cmd->cdb, rq->cmd, rq->cmd_len); 897 memcpy(&cmd->cdb, rq->cmd, rq->cmd_len);
897 cmd->cdb_len = rq->cmd_len; 898 cmd->cdb_len = rq->cmd_len;
@@ -1010,7 +1011,6 @@ static int ub_scsi_cmd_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1010 sc->last_pipe = sc->send_bulk_pipe; 1011 sc->last_pipe = sc->send_bulk_pipe;
1011 usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->send_bulk_pipe, 1012 usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->send_bulk_pipe,
1012 bcb, US_BULK_CB_WRAP_LEN, ub_urb_complete, sc); 1013 bcb, US_BULK_CB_WRAP_LEN, ub_urb_complete, sc);
1013 sc->work_urb.transfer_flags = 0;
1014 1014
1015 /* Fill what we shouldn't be filling, because usb-storage did so. */ 1015 /* Fill what we shouldn't be filling, because usb-storage did so. */
1016 sc->work_urb.actual_length = 0; 1016 sc->work_urb.actual_length = 0;
@@ -1019,7 +1019,6 @@ static int ub_scsi_cmd_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1019 1019
1020 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { 1020 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
1021 /* XXX Clear stalls */ 1021 /* XXX Clear stalls */
1022 printk("ub: cmd #%d start failed (%d)\n", cmd->tag, rc); /* P3 */
1023 ub_complete(&sc->work_done); 1022 ub_complete(&sc->work_done);
1024 return rc; 1023 return rc;
1025 } 1024 }
@@ -1190,11 +1189,9 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1190 return; 1189 return;
1191 } 1190 }
1192 if (urb->status != 0) { 1191 if (urb->status != 0) {
1193 printk("ub: cmd #%d cmd status (%d)\n", cmd->tag, urb->status); /* P3 */
1194 goto Bad_End; 1192 goto Bad_End;
1195 } 1193 }
1196 if (urb->actual_length != US_BULK_CB_WRAP_LEN) { 1194 if (urb->actual_length != US_BULK_CB_WRAP_LEN) {
1197 printk("ub: cmd #%d xferred %d\n", cmd->tag, urb->actual_length); /* P3 */
1198 /* XXX Must do reset here to unconfuse the device */ 1195 /* XXX Must do reset here to unconfuse the device */
1199 goto Bad_End; 1196 goto Bad_End;
1200 } 1197 }
@@ -1395,14 +1392,12 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1395 usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, 1392 usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe,
1396 page_address(sg->page) + sg->offset, sg->length, 1393 page_address(sg->page) + sg->offset, sg->length,
1397 ub_urb_complete, sc); 1394 ub_urb_complete, sc);
1398 sc->work_urb.transfer_flags = 0;
1399 sc->work_urb.actual_length = 0; 1395 sc->work_urb.actual_length = 0;
1400 sc->work_urb.error_count = 0; 1396 sc->work_urb.error_count = 0;
1401 sc->work_urb.status = 0; 1397 sc->work_urb.status = 0;
1402 1398
1403 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { 1399 if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
1404 /* XXX Clear stalls */ 1400 /* XXX Clear stalls */
1405 printk("ub: data #%d submit failed (%d)\n", cmd->tag, rc); /* P3 */
1406 ub_complete(&sc->work_done); 1401 ub_complete(&sc->work_done);
1407 ub_state_done(sc, cmd, rc); 1402 ub_state_done(sc, cmd, rc);
1408 return; 1403 return;
@@ -1442,7 +1437,6 @@ static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1442 sc->last_pipe = sc->recv_bulk_pipe; 1437 sc->last_pipe = sc->recv_bulk_pipe;
1443 usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe, 1438 usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe,
1444 &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc); 1439 &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc);
1445 sc->work_urb.transfer_flags = 0;
1446 sc->work_urb.actual_length = 0; 1440 sc->work_urb.actual_length = 0;
1447 sc->work_urb.error_count = 0; 1441 sc->work_urb.error_count = 0;
1448 sc->work_urb.status = 0; 1442 sc->work_urb.status = 0;
@@ -1563,7 +1557,6 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
1563 1557
1564 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, 1558 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe,
1565 (unsigned char*) cr, NULL, 0, ub_urb_complete, sc); 1559 (unsigned char*) cr, NULL, 0, ub_urb_complete, sc);
1566 sc->work_urb.transfer_flags = 0;
1567 sc->work_urb.actual_length = 0; 1560 sc->work_urb.actual_length = 0;
1568 sc->work_urb.error_count = 0; 1561 sc->work_urb.error_count = 0;
1569 sc->work_urb.status = 0; 1562 sc->work_urb.status = 0;
@@ -2000,17 +1993,16 @@ static int ub_sync_getmaxlun(struct ub_dev *sc)
2000 1993
2001 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe, 1994 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe,
2002 (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl); 1995 (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl);
2003 sc->work_urb.transfer_flags = 0;
2004 sc->work_urb.actual_length = 0; 1996 sc->work_urb.actual_length = 0;
2005 sc->work_urb.error_count = 0; 1997 sc->work_urb.error_count = 0;
2006 sc->work_urb.status = 0; 1998 sc->work_urb.status = 0;
2007 1999
2008 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { 2000 if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) {
2009 if (rc == -EPIPE) { 2001 if (rc == -EPIPE) {
2010 printk("%s: Stall at GetMaxLUN, using 1 LUN\n", 2002 printk("%s: Stall submitting GetMaxLUN, using 1 LUN\n",
2011 sc->name); /* P3 */ 2003 sc->name); /* P3 */
2012 } else { 2004 } else {
2013 printk(KERN_WARNING 2005 printk(KERN_NOTICE
2014 "%s: Unable to submit GetMaxLUN (%d)\n", 2006 "%s: Unable to submit GetMaxLUN (%d)\n",
2015 sc->name, rc); 2007 sc->name, rc);
2016 } 2008 }
@@ -2028,6 +2020,18 @@ static int ub_sync_getmaxlun(struct ub_dev *sc)
2028 del_timer_sync(&timer); 2020 del_timer_sync(&timer);
2029 usb_kill_urb(&sc->work_urb); 2021 usb_kill_urb(&sc->work_urb);
2030 2022
2023 if ((rc = sc->work_urb.status) < 0) {
2024 if (rc == -EPIPE) {
2025 printk("%s: Stall at GetMaxLUN, using 1 LUN\n",
2026 sc->name); /* P3 */
2027 } else {
2028 printk(KERN_NOTICE
2029 "%s: Error at GetMaxLUN (%d)\n",
2030 sc->name, rc);
2031 }
2032 goto err_io;
2033 }
2034
2031 if (sc->work_urb.actual_length != 1) { 2035 if (sc->work_urb.actual_length != 1) {
2032 printk("%s: GetMaxLUN returned %d bytes\n", sc->name, 2036 printk("%s: GetMaxLUN returned %d bytes\n", sc->name,
2033 sc->work_urb.actual_length); /* P3 */ 2037 sc->work_urb.actual_length); /* P3 */
@@ -2048,6 +2052,7 @@ static int ub_sync_getmaxlun(struct ub_dev *sc)
2048 kfree(p); 2052 kfree(p);
2049 return nluns; 2053 return nluns;
2050 2054
2055err_io:
2051err_submit: 2056err_submit:
2052 kfree(p); 2057 kfree(p);
2053err_alloc: 2058err_alloc:
@@ -2080,7 +2085,6 @@ static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe)
2080 2085
2081 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe, 2086 usb_fill_control_urb(&sc->work_urb, sc->dev, sc->send_ctrl_pipe,
2082 (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl); 2087 (unsigned char*) cr, NULL, 0, ub_probe_urb_complete, &compl);
2083 sc->work_urb.transfer_flags = 0;
2084 sc->work_urb.actual_length = 0; 2088 sc->work_urb.actual_length = 0;
2085 sc->work_urb.error_count = 0; 2089 sc->work_urb.error_count = 0;
2086 sc->work_urb.status = 0; 2090 sc->work_urb.status = 0;
@@ -2213,8 +2217,10 @@ static int ub_probe(struct usb_interface *intf,
2213 * This is needed to clear toggles. It is a problem only if we do 2217 * This is needed to clear toggles. It is a problem only if we do
2214 * `rmmod ub && modprobe ub` without disconnects, but we like that. 2218 * `rmmod ub && modprobe ub` without disconnects, but we like that.
2215 */ 2219 */
2220#if 0 /* iPod Mini fails if we do this (big white iPod works) */
2216 ub_probe_clear_stall(sc, sc->recv_bulk_pipe); 2221 ub_probe_clear_stall(sc, sc->recv_bulk_pipe);
2217 ub_probe_clear_stall(sc, sc->send_bulk_pipe); 2222 ub_probe_clear_stall(sc, sc->send_bulk_pipe);
2223#endif
2218 2224
2219 /* 2225 /*
2220 * The way this is used by the startup code is a little specific. 2226 * The way this is used by the startup code is a little specific.
@@ -2241,10 +2247,10 @@ static int ub_probe(struct usb_interface *intf,
2241 for (i = 0; i < 3; i++) { 2247 for (i = 0; i < 3; i++) {
2242 if ((rc = ub_sync_getmaxlun(sc)) < 0) { 2248 if ((rc = ub_sync_getmaxlun(sc)) < 0) {
2243 /* 2249 /*
2244 * Some devices (i.e. Iomega Zip100) need this -- 2250 * This segment is taken from usb-storage. They say
2245 * apparently the bulk pipes get STALLed when the 2251 * that ZIP-100 needs this, but my own ZIP-100 works
2246 * GetMaxLUN request is processed. 2252 * fine without this.
2247 * XXX I have a ZIP-100, verify it does this. 2253 * Still, it does not seem to hurt anything.
2248 */ 2254 */
2249 if (rc == -EPIPE) { 2255 if (rc == -EPIPE) {
2250 ub_probe_clear_stall(sc, sc->recv_bulk_pipe); 2256 ub_probe_clear_stall(sc, sc->recv_bulk_pipe);
@@ -2313,7 +2319,7 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
2313 disk->first_minor = lun->id * UB_MINORS_PER_MAJOR; 2319 disk->first_minor = lun->id * UB_MINORS_PER_MAJOR;
2314 disk->fops = &ub_bd_fops; 2320 disk->fops = &ub_bd_fops;
2315 disk->private_data = lun; 2321 disk->private_data = lun;
2316 disk->driverfs_dev = &sc->intf->dev; /* XXX Many to one ok? */ 2322 disk->driverfs_dev = &sc->intf->dev;
2317 2323
2318 rc = -ENOMEM; 2324 rc = -ENOMEM;
2319 if ((q = blk_init_queue(ub_request_fn, &sc->lock)) == NULL) 2325 if ((q = blk_init_queue(ub_request_fn, &sc->lock)) == NULL)
@@ -2466,9 +2472,6 @@ static int __init ub_init(void)
2466{ 2472{
2467 int rc; 2473 int rc;
2468 2474
2469 /* P3 */ printk("ub: sizeof ub_scsi_cmd %zu ub_dev %zu ub_lun %zu\n",
2470 sizeof(struct ub_scsi_cmd), sizeof(struct ub_dev), sizeof(struct ub_lun));
2471
2472 if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) 2475 if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0)
2473 goto err_regblkdev; 2476 goto err_regblkdev;
2474 devfs_mk_dir(DEVFS_NAME); 2477 devfs_mk_dir(DEVFS_NAME);
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index a1bf8f066c88..4fa85234d8b5 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -308,7 +308,7 @@ unlock:
308} 308}
309 309
310static inline struct urb *bpa10x_alloc_urb(struct usb_device *udev, unsigned int pipe, 310static inline struct urb *bpa10x_alloc_urb(struct usb_device *udev, unsigned int pipe,
311 size_t size, unsigned int __nocast flags, void *data) 311 size_t size, gfp_t flags, void *data)
312{ 312{
313 struct urb *urb; 313 struct urb *urb;
314 struct usb_ctrlrequest *cr; 314 struct usb_ctrlrequest *cr;
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 57c48bbf6fe6..6756cb20b753 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -132,7 +132,7 @@ static struct usb_device_id blacklist_ids[] = {
132 { } /* Terminating entry */ 132 { } /* Terminating entry */
133}; 133};
134 134
135static struct _urb *_urb_alloc(int isoc, unsigned int __nocast gfp) 135static struct _urb *_urb_alloc(int isoc, gfp_t gfp)
136{ 136{
137 struct _urb *_urb = kmalloc(sizeof(struct _urb) + 137 struct _urb *_urb = kmalloc(sizeof(struct _urb) +
138 sizeof(struct usb_iso_packet_descriptor) * isoc, gfp); 138 sizeof(struct usb_iso_packet_descriptor) * isoc, gfp);
diff --git a/drivers/char/.gitignore b/drivers/char/.gitignore
new file mode 100644
index 000000000000..2b6b1d772ed7
--- /dev/null
+++ b/drivers/char/.gitignore
@@ -0,0 +1,3 @@
1consolemap_deftbl.c
2defkeymap.c
3
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 99762b6c19ae..de5d6d212674 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -252,7 +252,7 @@ hp_zx1_configure (void)
252 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); 252 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE);
253 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); 253 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG);
254 readl(hp->ioc_regs+HP_ZX1_TCNFG); 254 readl(hp->ioc_regs+HP_ZX1_TCNFG);
255 writel(~(HP_ZX1_IOVA_SIZE-1), hp->ioc_regs+HP_ZX1_IMASK); 255 writel((unsigned int)(~(HP_ZX1_IOVA_SIZE-1)), hp->ioc_regs+HP_ZX1_IMASK);
256 readl(hp->ioc_regs+HP_ZX1_IMASK); 256 readl(hp->ioc_regs+HP_ZX1_IMASK);
257 writel(hp->iova_base|1, hp->ioc_regs+HP_ZX1_IBASE); 257 writel(hp->iova_base|1, hp->ioc_regs+HP_ZX1_IBASE);
258 readl(hp->ioc_regs+HP_ZX1_IBASE); 258 readl(hp->ioc_regs+HP_ZX1_IBASE);
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index d3aa159c9dec..7957fc91f6ad 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/agp_backend.h> 18#include <linux/agp_backend.h>
19#include <asm/sn/addrs.h> 19#include <asm/sn/addrs.h>
20#include <asm/sn/io.h>
20#include <asm/sn/pcidev.h> 21#include <asm/sn/pcidev.h>
21#include <asm/sn/pcibus_provider_defs.h> 22#include <asm/sn/pcibus_provider_defs.h>
22#include <asm/sn/tioca_provider.h> 23#include <asm/sn/tioca_provider.h>
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 6ba48f346fcf..041bb47b5c39 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -376,7 +376,7 @@ static int __init drm_core_init(void)
376 goto err_p2; 376 goto err_p2;
377 } 377 }
378 378
379 drm_proc_root = create_proc_entry("dri", S_IFDIR, NULL); 379 drm_proc_root = proc_mkdir("dri", NULL);
380 if (!drm_proc_root) { 380 if (!drm_proc_root) {
381 DRM_ERROR("Cannot create /proc/dri\n"); 381 DRM_ERROR("Cannot create /proc/dri\n");
382 ret = -1; 382 ret = -1;
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c
index 32d2bb99462c..977961002488 100644
--- a/drivers/char/drm/drm_proc.c
+++ b/drivers/char/drm/drm_proc.c
@@ -95,7 +95,7 @@ int drm_proc_init(drm_device_t *dev, int minor,
95 char name[64]; 95 char name[64];
96 96
97 sprintf(name, "%d", minor); 97 sprintf(name, "%d", minor);
98 *dev_root = create_proc_entry(name, S_IFDIR, root); 98 *dev_root = proc_mkdir(name, root);
99 if (!*dev_root) { 99 if (!*dev_root) {
100 DRM_ERROR("Cannot create /proc/dri/%s\n", name); 100 DRM_ERROR("Cannot create /proc/dri/%s\n", name);
101 return -1; 101 return -1;
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 95a976c96eb8..70458cb061c6 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -47,7 +47,7 @@ MODULE_PARM_DESC(cards_limit, "Maximum number of graphics cards");
47MODULE_PARM_DESC(debug, "Enable debug output"); 47MODULE_PARM_DESC(debug, "Enable debug output");
48 48
49module_param_named(cards_limit, drm_cards_limit, int, 0444); 49module_param_named(cards_limit, drm_cards_limit, int, 0444);
50module_param_named(debug, drm_debug, int, 0666); 50module_param_named(debug, drm_debug, int, 0600);
51 51
52drm_head_t **drm_heads; 52drm_head_t **drm_heads;
53struct drm_sysfs_class *drm_class; 53struct drm_sysfs_class *drm_class;
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index ced4215e2275..39ea96e42c5b 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -148,7 +148,8 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
148 148
149 offset = address - vma->vm_start; 149 offset = address - vma->vm_start;
150 i = (unsigned long)map->handle + offset; 150 i = (unsigned long)map->handle + offset;
151 page = vmalloc_to_page((void *)i); 151 page = (map->type == _DRM_CONSISTENT) ?
152 virt_to_page((void *)i) : vmalloc_to_page((void *)i);
152 if (!page) 153 if (!page)
153 return NOPAGE_OOM; 154 return NOPAGE_OOM;
154 get_page(page); 155 get_page(page);
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c
index fc7d4a594bca..c8e1b6c83636 100644
--- a/drivers/char/drm/mga_dma.c
+++ b/drivers/char/drm/mga_dma.c
@@ -437,7 +437,7 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
437 drm_mga_dma_bootstrap_t * dma_bs) 437 drm_mga_dma_bootstrap_t * dma_bs)
438{ 438{
439 drm_mga_private_t * const dev_priv = (drm_mga_private_t *) dev->dev_private; 439 drm_mga_private_t * const dev_priv = (drm_mga_private_t *) dev->dev_private;
440 const unsigned int warp_size = mga_warp_microcode_size(dev_priv); 440 unsigned int warp_size = mga_warp_microcode_size(dev_priv);
441 int err; 441 int err;
442 unsigned offset; 442 unsigned offset;
443 const unsigned secondary_size = dma_bs->secondary_bin_count 443 const unsigned secondary_size = dma_bs->secondary_bin_count
@@ -499,6 +499,12 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev,
499 return err; 499 return err;
500 } 500 }
501 501
502 /* Make drm_addbufs happy by not trying to create a mapping for less
503 * than a page.
504 */
505 if (warp_size < PAGE_SIZE)
506 warp_size = PAGE_SIZE;
507
502 offset = 0; 508 offset = 0;
503 err = drm_addmap( dev, offset, warp_size, 509 err = drm_addmap( dev, offset, warp_size,
504 _DRM_AGP, _DRM_READ_ONLY, & dev_priv->warp ); 510 _DRM_AGP, _DRM_READ_ONLY, & dev_priv->warp );
@@ -587,7 +593,7 @@ static int mga_do_pci_dma_bootstrap(drm_device_t * dev,
587 drm_mga_dma_bootstrap_t * dma_bs) 593 drm_mga_dma_bootstrap_t * dma_bs)
588{ 594{
589 drm_mga_private_t * const dev_priv = (drm_mga_private_t *) dev->dev_private; 595 drm_mga_private_t * const dev_priv = (drm_mga_private_t *) dev->dev_private;
590 const unsigned int warp_size = mga_warp_microcode_size(dev_priv); 596 unsigned int warp_size = mga_warp_microcode_size(dev_priv);
591 unsigned int primary_size; 597 unsigned int primary_size;
592 unsigned int bin_count; 598 unsigned int bin_count;
593 int err; 599 int err;
@@ -599,6 +605,12 @@ static int mga_do_pci_dma_bootstrap(drm_device_t * dev,
599 return DRM_ERR(EFAULT); 605 return DRM_ERR(EFAULT);
600 } 606 }
601 607
608 /* Make drm_addbufs happy by not trying to create a mapping for less
609 * than a page.
610 */
611 if (warp_size < PAGE_SIZE)
612 warp_size = PAGE_SIZE;
613
602 /* The proper alignment is 0x100 for this mapping */ 614 /* The proper alignment is 0x100 for this mapping */
603 err = drm_addmap(dev, 0, warp_size, _DRM_CONSISTENT, 615 err = drm_addmap(dev, 0, warp_size, _DRM_CONSISTENT,
604 _DRM_READ_ONLY, &dev_priv->warp); 616 _DRM_READ_ONLY, &dev_priv->warp);
@@ -812,6 +824,10 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
812 } 824 }
813 825
814 if (! dev_priv->used_new_dma_init) { 826 if (! dev_priv->used_new_dma_init) {
827
828 dev_priv->dma_access = MGA_PAGPXFER;
829 dev_priv->wagp_enable = MGA_WAGP_ENABLE;
830
815 dev_priv->status = drm_core_findmap(dev, init->status_offset); 831 dev_priv->status = drm_core_findmap(dev, init->status_offset);
816 if (!dev_priv->status) { 832 if (!dev_priv->status) {
817 DRM_ERROR("failed to find status page!\n"); 833 DRM_ERROR("failed to find status page!\n");
@@ -928,7 +944,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev )
928 drm_mga_private_t *dev_priv = dev->dev_private; 944 drm_mga_private_t *dev_priv = dev->dev_private;
929 945
930 if ((dev_priv->warp != NULL) 946 if ((dev_priv->warp != NULL)
931 && (dev_priv->mmio->type != _DRM_CONSISTENT)) 947 && (dev_priv->warp->type != _DRM_CONSISTENT))
932 drm_core_ioremapfree(dev_priv->warp, dev); 948 drm_core_ioremapfree(dev_priv->warp, dev);
933 949
934 if ((dev_priv->primary != NULL) 950 if ((dev_priv->primary != NULL)
diff --git a/drivers/char/drm/mga_drv.h b/drivers/char/drm/mga_drv.h
index b22fdbd4f830..6059c5a5b105 100644
--- a/drivers/char/drm/mga_drv.h
+++ b/drivers/char/drm/mga_drv.h
@@ -227,7 +227,7 @@ static inline u32 _MGA_READ(u32 *addr)
227#define MGA_EMIT_STATE( dev_priv, dirty ) \ 227#define MGA_EMIT_STATE( dev_priv, dirty ) \
228do { \ 228do { \
229 if ( (dirty) & ~MGA_UPLOAD_CLIPRECTS ) { \ 229 if ( (dirty) & ~MGA_UPLOAD_CLIPRECTS ) { \
230 if ( dev_priv->chipset == MGA_CARD_TYPE_G400 ) { \ 230 if ( dev_priv->chipset >= MGA_CARD_TYPE_G400 ) { \
231 mga_g400_emit_state( dev_priv ); \ 231 mga_g400_emit_state( dev_priv ); \
232 } else { \ 232 } else { \
233 mga_g200_emit_state( dev_priv ); \ 233 mga_g200_emit_state( dev_priv ); \
diff --git a/drivers/char/drm/mga_state.c b/drivers/char/drm/mga_state.c
index 05bbb4719376..6ac5e006226f 100644
--- a/drivers/char/drm/mga_state.c
+++ b/drivers/char/drm/mga_state.c
@@ -53,7 +53,7 @@ static void mga_emit_clip_rect( drm_mga_private_t *dev_priv,
53 53
54 /* Force reset of DWGCTL on G400 (eliminates clip disable bit). 54 /* Force reset of DWGCTL on G400 (eliminates clip disable bit).
55 */ 55 */
56 if (dev_priv->chipset == MGA_CARD_TYPE_G400) { 56 if (dev_priv->chipset >= MGA_CARD_TYPE_G400) {
57 DMA_BLOCK(MGA_DWGCTL, ctx->dwgctl, 57 DMA_BLOCK(MGA_DWGCTL, ctx->dwgctl,
58 MGA_LEN + MGA_EXEC, 0x80000000, 58 MGA_LEN + MGA_EXEC, 0x80000000,
59 MGA_DWGCTL, ctx->dwgctl, 59 MGA_DWGCTL, ctx->dwgctl,
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 6d9080a3ca7e..12ef13ff04ca 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1133,10 +1133,10 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
1133 ring_start = (dev_priv->cp_ring->offset 1133 ring_start = (dev_priv->cp_ring->offset
1134 - dev->agp->base 1134 - dev->agp->base
1135 + dev_priv->gart_vm_start); 1135 + dev_priv->gart_vm_start);
1136 } else 1136 } else
1137#endif 1137#endif
1138 ring_start = (dev_priv->cp_ring->offset 1138 ring_start = (dev_priv->cp_ring->offset
1139 - dev->sg->handle 1139 - (unsigned long)dev->sg->virtual
1140 + dev_priv->gart_vm_start); 1140 + dev_priv->gart_vm_start);
1141 1141
1142 RADEON_WRITE( RADEON_CP_RB_BASE, ring_start ); 1142 RADEON_WRITE( RADEON_CP_RB_BASE, ring_start );
@@ -1164,7 +1164,8 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
1164 drm_sg_mem_t *entry = dev->sg; 1164 drm_sg_mem_t *entry = dev->sg;
1165 unsigned long tmp_ofs, page_ofs; 1165 unsigned long tmp_ofs, page_ofs;
1166 1166
1167 tmp_ofs = dev_priv->ring_rptr->offset - dev->sg->handle; 1167 tmp_ofs = dev_priv->ring_rptr->offset -
1168 (unsigned long)dev->sg->virtual;
1168 page_ofs = tmp_ofs >> PAGE_SHIFT; 1169 page_ofs = tmp_ofs >> PAGE_SHIFT;
1169 1170
1170 RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR, 1171 RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
@@ -1491,8 +1492,8 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
1491 else 1492 else
1492#endif 1493#endif
1493 dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset 1494 dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
1494 - dev->sg->handle 1495 - (unsigned long)dev->sg->virtual
1495 + dev_priv->gart_vm_start); 1496 + dev_priv->gart_vm_start);
1496 1497
1497 DRM_DEBUG( "dev_priv->gart_size %d\n", 1498 DRM_DEBUG( "dev_priv->gart_size %d\n",
1498 dev_priv->gart_size ); 1499 dev_priv->gart_size );
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index de0379b6d502..c055bb630ffc 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -273,7 +273,6 @@ static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
273 273
274 vma->vm_flags |= VM_IO; 274 vma->vm_flags |= VM_IO;
275 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 275 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
276 addr = __pa(addr);
277 276
278 if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, 277 if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT,
279 PAGE_SIZE, vma->vm_page_prot)) { 278 PAGE_SIZE, vma->vm_page_prot)) {
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 463351d4f942..32fa82c78c73 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2620,7 +2620,7 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
2620 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); 2620 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags);
2621 if (!list_empty(&(intf->waiting_msgs))) { 2621 if (!list_empty(&(intf->waiting_msgs))) {
2622 list_add_tail(&(msg->link), &(intf->waiting_msgs)); 2622 list_add_tail(&(msg->link), &(intf->waiting_msgs));
2623 spin_unlock(&(intf->waiting_msgs_lock)); 2623 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags);
2624 goto out_unlock; 2624 goto out_unlock;
2625 } 2625 }
2626 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); 2626 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags);
@@ -2629,9 +2629,9 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
2629 if (rv > 0) { 2629 if (rv > 0) {
2630 /* Could not handle the message now, just add it to a 2630 /* Could not handle the message now, just add it to a
2631 list to handle later. */ 2631 list to handle later. */
2632 spin_lock(&(intf->waiting_msgs_lock)); 2632 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags);
2633 list_add_tail(&(msg->link), &(intf->waiting_msgs)); 2633 list_add_tail(&(msg->link), &(intf->waiting_msgs));
2634 spin_unlock(&(intf->waiting_msgs_lock)); 2634 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags);
2635 } else if (rv == 0) { 2635 } else if (rv == 0) {
2636 ipmi_free_smi_msg(msg); 2636 ipmi_free_smi_msg(msg);
2637 } 2637 }
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index e82a96ba396b..f66947722e12 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -55,7 +55,7 @@ extern void (*pm_power_off)(void);
55static int poweroff_powercycle; 55static int poweroff_powercycle;
56 56
57/* parameter definition to allow user to flag power cycle */ 57/* parameter definition to allow user to flag power cycle */
58module_param(poweroff_powercycle, int, 0); 58module_param(poweroff_powercycle, int, 0644);
59MODULE_PARM_DESC(poweroff_powercycles, " 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."); 59MODULE_PARM_DESC(poweroff_powercycles, " 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.");
60 60
61/* Stuff from the get device id command. */ 61/* Stuff from the get device id command. */
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 3fa64c631108..c268ee04b2aa 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -830,6 +830,9 @@ static int __init mbcs_init(void)
830{ 830{
831 int rv; 831 int rv;
832 832
833 if (!ia64_platform_is("sn2"))
834 return -ENODEV;
835
833 // Put driver into chrdevs[]. Get major number. 836 // Put driver into chrdevs[]. Get major number.
834 rv = register_chrdev(mbcs_major, DEVICE_NAME, &mbcs_ops); 837 rv = register_chrdev(mbcs_major, DEVICE_NAME, &mbcs_ops);
835 if (rv < 0) { 838 if (rv < 0) {
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index 2291a87e8ada..853c98cee64f 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -229,8 +229,8 @@ static int __init r3964_init(void)
229 TRACE_L("line discipline %d registered", N_R3964); 229 TRACE_L("line discipline %d registered", N_R3964);
230 TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, 230 TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags,
231 tty_ldisc_N_R3964.num); 231 tty_ldisc_N_R3964.num);
232 TRACE_L("open=%x", (int)tty_ldisc_N_R3964.open); 232 TRACE_L("open=%p", tty_ldisc_N_R3964.open);
233 TRACE_L("tty_ldisc_N_R3964 = %x", (int)&tty_ldisc_N_R3964); 233 TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
234 } 234 }
235 else 235 else
236 { 236 {
@@ -267,8 +267,8 @@ static void add_tx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH
267 267
268 spin_unlock_irqrestore(&pInfo->lock, flags); 268 spin_unlock_irqrestore(&pInfo->lock, flags);
269 269
270 TRACE_Q("add_tx_queue %x, length %d, tx_first = %x", 270 TRACE_Q("add_tx_queue %p, length %d, tx_first = %p",
271 (int)pHeader, pHeader->length, (int)pInfo->tx_first ); 271 pHeader, pHeader->length, pInfo->tx_first );
272} 272}
273 273
274static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) 274static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
@@ -285,10 +285,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
285 return; 285 return;
286 286
287#ifdef DEBUG_QUEUE 287#ifdef DEBUG_QUEUE
288 printk("r3964: remove_from_tx_queue: %x, length %d - ", 288 printk("r3964: remove_from_tx_queue: %p, length %u - ",
289 (int)pHeader, (int)pHeader->length ); 289 pHeader, pHeader->length );
290 for(pDump=pHeader;pDump;pDump=pDump->next) 290 for(pDump=pHeader;pDump;pDump=pDump->next)
291 printk("%x ", (int)pDump); 291 printk("%p ", pDump);
292 printk("\n"); 292 printk("\n");
293#endif 293#endif
294 294
@@ -319,10 +319,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
319 spin_unlock_irqrestore(&pInfo->lock, flags); 319 spin_unlock_irqrestore(&pInfo->lock, flags);
320 320
321 kfree(pHeader); 321 kfree(pHeader);
322 TRACE_M("remove_from_tx_queue - kfree %x",(int)pHeader); 322 TRACE_M("remove_from_tx_queue - kfree %p",pHeader);
323 323
324 TRACE_Q("remove_from_tx_queue: tx_first = %x, tx_last = %x", 324 TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
325 (int)pInfo->tx_first, (int)pInfo->tx_last ); 325 pInfo->tx_first, pInfo->tx_last );
326} 326}
327 327
328static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader) 328static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader)
@@ -346,9 +346,9 @@ static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH
346 346
347 spin_unlock_irqrestore(&pInfo->lock, flags); 347 spin_unlock_irqrestore(&pInfo->lock, flags);
348 348
349 TRACE_Q("add_rx_queue: %x, length = %d, rx_first = %x, count = %d", 349 TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
350 (int)pHeader, pHeader->length, 350 pHeader, pHeader->length,
351 (int)pInfo->rx_first, pInfo->blocks_in_rx_queue); 351 pInfo->rx_first, pInfo->blocks_in_rx_queue);
352} 352}
353 353
354static void remove_from_rx_queue(struct r3964_info *pInfo, 354static void remove_from_rx_queue(struct r3964_info *pInfo,
@@ -360,10 +360,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo,
360 if(pHeader==NULL) 360 if(pHeader==NULL)
361 return; 361 return;
362 362
363 TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d", 363 TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
364 (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue ); 364 pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
365 TRACE_Q("remove_from_rx_queue: %x, length %d", 365 TRACE_Q("remove_from_rx_queue: %p, length %u",
366 (int)pHeader, (int)pHeader->length ); 366 pHeader, pHeader->length );
367 367
368 spin_lock_irqsave(&pInfo->lock, flags); 368 spin_lock_irqsave(&pInfo->lock, flags);
369 369
@@ -401,10 +401,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo,
401 spin_unlock_irqrestore(&pInfo->lock, flags); 401 spin_unlock_irqrestore(&pInfo->lock, flags);
402 402
403 kfree(pHeader); 403 kfree(pHeader);
404 TRACE_M("remove_from_rx_queue - kfree %x",(int)pHeader); 404 TRACE_M("remove_from_rx_queue - kfree %p",pHeader);
405 405
406 TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d", 406 TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
407 (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue ); 407 pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
408} 408}
409 409
410static void put_char(struct r3964_info *pInfo, unsigned char ch) 410static void put_char(struct r3964_info *pInfo, unsigned char ch)
@@ -506,8 +506,8 @@ static void transmit_block(struct r3964_info *pInfo)
506 if(tty->driver->write_room) 506 if(tty->driver->write_room)
507 room=tty->driver->write_room(tty); 507 room=tty->driver->write_room(tty);
508 508
509 TRACE_PS("transmit_block %x, room %d, length %d", 509 TRACE_PS("transmit_block %p, room %d, length %d",
510 (int)pBlock, room, pBlock->length); 510 pBlock, room, pBlock->length);
511 511
512 while(pInfo->tx_position < pBlock->length) 512 while(pInfo->tx_position < pBlock->length)
513 { 513 {
@@ -588,7 +588,7 @@ static void on_receive_block(struct r3964_info *pInfo)
588 588
589 /* prepare struct r3964_block_header: */ 589 /* prepare struct r3964_block_header: */
590 pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL); 590 pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL);
591 TRACE_M("on_receive_block - kmalloc %x",(int)pBlock); 591 TRACE_M("on_receive_block - kmalloc %p",pBlock);
592 592
593 if(pBlock==NULL) 593 if(pBlock==NULL)
594 return; 594 return;
@@ -695,7 +695,7 @@ static void receive_char(struct r3964_info *pInfo, const unsigned char c)
695 { 695 {
696 TRACE_PE("IDLE - got STX but no space in rx_queue!"); 696 TRACE_PE("IDLE - got STX but no space in rx_queue!");
697 pInfo->state=R3964_WAIT_FOR_RX_BUF; 697 pInfo->state=R3964_WAIT_FOR_RX_BUF;
698 mod_timer(&pInfo->tmr, R3964_TO_NO_BUF); 698 mod_timer(&pInfo->tmr, jiffies + R3964_TO_NO_BUF);
699 break; 699 break;
700 } 700 }
701start_receiving: 701start_receiving:
@@ -705,7 +705,7 @@ start_receiving:
705 pInfo->last_rx = 0; 705 pInfo->last_rx = 0;
706 pInfo->flags &= ~R3964_ERROR; 706 pInfo->flags &= ~R3964_ERROR;
707 pInfo->state=R3964_RECEIVING; 707 pInfo->state=R3964_RECEIVING;
708 mod_timer(&pInfo->tmr, R3964_TO_ZVZ); 708 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
709 pInfo->nRetry = 0; 709 pInfo->nRetry = 0;
710 put_char(pInfo, DLE); 710 put_char(pInfo, DLE);
711 flush(pInfo); 711 flush(pInfo);
@@ -732,7 +732,7 @@ start_receiving:
732 if(pInfo->flags & R3964_BCC) 732 if(pInfo->flags & R3964_BCC)
733 { 733 {
734 pInfo->state = R3964_WAIT_FOR_BCC; 734 pInfo->state = R3964_WAIT_FOR_BCC;
735 mod_timer(&pInfo->tmr, R3964_TO_ZVZ); 735 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
736 } 736 }
737 else 737 else
738 { 738 {
@@ -744,7 +744,7 @@ start_receiving:
744 pInfo->last_rx = c; 744 pInfo->last_rx = c;
745char_to_buf: 745char_to_buf:
746 pInfo->rx_buf[pInfo->rx_position++] = c; 746 pInfo->rx_buf[pInfo->rx_position++] = c;
747 mod_timer(&pInfo->tmr, R3964_TO_ZVZ); 747 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
748 } 748 }
749 } 749 }
750 /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */ 750 /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */
@@ -868,11 +868,11 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
868 if(pMsg) 868 if(pMsg)
869 { 869 {
870 kfree(pMsg); 870 kfree(pMsg);
871 TRACE_M("enable_signals - msg kfree %x",(int)pMsg); 871 TRACE_M("enable_signals - msg kfree %p",pMsg);
872 } 872 }
873 } 873 }
874 kfree(pClient); 874 kfree(pClient);
875 TRACE_M("enable_signals - kfree %x",(int)pClient); 875 TRACE_M("enable_signals - kfree %p",pClient);
876 return 0; 876 return 0;
877 } 877 }
878 } 878 }
@@ -890,7 +890,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg)
890 { 890 {
891 /* add client to client list */ 891 /* add client to client list */
892 pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL); 892 pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL);
893 TRACE_M("enable_signals - kmalloc %x",(int)pClient); 893 TRACE_M("enable_signals - kmalloc %p",pClient);
894 if(pClient==NULL) 894 if(pClient==NULL)
895 return -ENOMEM; 895 return -ENOMEM;
896 896
@@ -954,7 +954,7 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
954queue_the_message: 954queue_the_message:
955 955
956 pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL); 956 pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL);
957 TRACE_M("add_msg - kmalloc %x",(int)pMsg); 957 TRACE_M("add_msg - kmalloc %p",pMsg);
958 if(pMsg==NULL) { 958 if(pMsg==NULL) {
959 return; 959 return;
960 } 960 }
@@ -1067,11 +1067,11 @@ static int r3964_open(struct tty_struct *tty)
1067 struct r3964_info *pInfo; 1067 struct r3964_info *pInfo;
1068 1068
1069 TRACE_L("open"); 1069 TRACE_L("open");
1070 TRACE_L("tty=%x, PID=%d, disc_data=%x", 1070 TRACE_L("tty=%p, PID=%d, disc_data=%p",
1071 (int)tty, current->pid, (int)tty->disc_data); 1071 tty, current->pid, tty->disc_data);
1072 1072
1073 pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); 1073 pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
1074 TRACE_M("r3964_open - info kmalloc %x",(int)pInfo); 1074 TRACE_M("r3964_open - info kmalloc %p",pInfo);
1075 1075
1076 if(!pInfo) 1076 if(!pInfo)
1077 { 1077 {
@@ -1080,26 +1080,26 @@ static int r3964_open(struct tty_struct *tty)
1080 } 1080 }
1081 1081
1082 pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); 1082 pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
1083 TRACE_M("r3964_open - rx_buf kmalloc %x",(int)pInfo->rx_buf); 1083 TRACE_M("r3964_open - rx_buf kmalloc %p",pInfo->rx_buf);
1084 1084
1085 if(!pInfo->rx_buf) 1085 if(!pInfo->rx_buf)
1086 { 1086 {
1087 printk(KERN_ERR "r3964: failed to alloc receive buffer\n"); 1087 printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
1088 kfree(pInfo); 1088 kfree(pInfo);
1089 TRACE_M("r3964_open - info kfree %x",(int)pInfo); 1089 TRACE_M("r3964_open - info kfree %p",pInfo);
1090 return -ENOMEM; 1090 return -ENOMEM;
1091 } 1091 }
1092 1092
1093 pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL); 1093 pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
1094 TRACE_M("r3964_open - tx_buf kmalloc %x",(int)pInfo->tx_buf); 1094 TRACE_M("r3964_open - tx_buf kmalloc %p",pInfo->tx_buf);
1095 1095
1096 if(!pInfo->tx_buf) 1096 if(!pInfo->tx_buf)
1097 { 1097 {
1098 printk(KERN_ERR "r3964: failed to alloc transmit buffer\n"); 1098 printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
1099 kfree(pInfo->rx_buf); 1099 kfree(pInfo->rx_buf);
1100 TRACE_M("r3964_open - rx_buf kfree %x",(int)pInfo->rx_buf); 1100 TRACE_M("r3964_open - rx_buf kfree %p",pInfo->rx_buf);
1101 kfree(pInfo); 1101 kfree(pInfo);
1102 TRACE_M("r3964_open - info kfree %x",(int)pInfo); 1102 TRACE_M("r3964_open - info kfree %p",pInfo);
1103 return -ENOMEM; 1103 return -ENOMEM;
1104 } 1104 }
1105 1105
@@ -1154,11 +1154,11 @@ static void r3964_close(struct tty_struct *tty)
1154 if(pMsg) 1154 if(pMsg)
1155 { 1155 {
1156 kfree(pMsg); 1156 kfree(pMsg);
1157 TRACE_M("r3964_close - msg kfree %x",(int)pMsg); 1157 TRACE_M("r3964_close - msg kfree %p",pMsg);
1158 } 1158 }
1159 } 1159 }
1160 kfree(pClient); 1160 kfree(pClient);
1161 TRACE_M("r3964_close - client kfree %x",(int)pClient); 1161 TRACE_M("r3964_close - client kfree %p",pClient);
1162 pClient=pNext; 1162 pClient=pNext;
1163 } 1163 }
1164 /* Remove jobs from tx_queue: */ 1164 /* Remove jobs from tx_queue: */
@@ -1177,11 +1177,11 @@ static void r3964_close(struct tty_struct *tty)
1177 /* Free buffers: */ 1177 /* Free buffers: */
1178 wake_up_interruptible(&pInfo->read_wait); 1178 wake_up_interruptible(&pInfo->read_wait);
1179 kfree(pInfo->rx_buf); 1179 kfree(pInfo->rx_buf);
1180 TRACE_M("r3964_close - rx_buf kfree %x",(int)pInfo->rx_buf); 1180 TRACE_M("r3964_close - rx_buf kfree %p",pInfo->rx_buf);
1181 kfree(pInfo->tx_buf); 1181 kfree(pInfo->tx_buf);
1182 TRACE_M("r3964_close - tx_buf kfree %x",(int)pInfo->tx_buf); 1182 TRACE_M("r3964_close - tx_buf kfree %p",pInfo->tx_buf);
1183 kfree(pInfo); 1183 kfree(pInfo);
1184 TRACE_M("r3964_close - info kfree %x",(int)pInfo); 1184 TRACE_M("r3964_close - info kfree %p",pInfo);
1185} 1185}
1186 1186
1187static ssize_t r3964_read(struct tty_struct *tty, struct file *file, 1187static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
@@ -1234,7 +1234,7 @@ repeat:
1234 count = sizeof(struct r3964_client_message); 1234 count = sizeof(struct r3964_client_message);
1235 1235
1236 kfree(pMsg); 1236 kfree(pMsg);
1237 TRACE_M("r3964_read - msg kfree %x",(int)pMsg); 1237 TRACE_M("r3964_read - msg kfree %p",pMsg);
1238 1238
1239 if (copy_to_user(buf,&theMsg, count)) 1239 if (copy_to_user(buf,&theMsg, count))
1240 return -EFAULT; 1240 return -EFAULT;
@@ -1279,7 +1279,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file,
1279 * Allocate a buffer for the data and copy it from the buffer with header prepended 1279 * Allocate a buffer for the data and copy it from the buffer with header prepended
1280 */ 1280 */
1281 new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL); 1281 new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL);
1282 TRACE_M("r3964_write - kmalloc %x",(int)new_data); 1282 TRACE_M("r3964_write - kmalloc %p",new_data);
1283 if (new_data == NULL) { 1283 if (new_data == NULL) {
1284 if (pInfo->flags & R3964_DEBUG) 1284 if (pInfo->flags & R3964_DEBUG)
1285 { 1285 {
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
index ed867db550a9..e1a90d9a8756 100644
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -564,6 +564,7 @@ static int s3c2410_rtc_resume(struct device *dev, u32 level)
564 564
565static struct device_driver s3c2410_rtcdrv = { 565static struct device_driver s3c2410_rtcdrv = {
566 .name = "s3c2410-rtc", 566 .name = "s3c2410-rtc",
567 .owner = THIS_MODULE,
567 .bus = &platform_bus_type, 568 .bus = &platform_bus_type,
568 .probe = s3c2410_rtc_probe, 569 .probe = s3c2410_rtc_probe,
569 .remove = s3c2410_rtc_remove, 570 .remove = s3c2410_rtc_remove,
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c
index 1436aea3b28f..6d3ff0836c44 100644
--- a/drivers/char/watchdog/mv64x60_wdt.c
+++ b/drivers/char/watchdog/mv64x60_wdt.c
@@ -87,6 +87,8 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file)
87 mv64x60_wdt_service(); 87 mv64x60_wdt_service();
88 mv64x60_wdt_handler_enable(); 88 mv64x60_wdt_handler_enable();
89 89
90 nonseekable_open(inode, file);
91
90 return 0; 92 return 0;
91} 93}
92 94
@@ -103,12 +105,9 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file)
103 return 0; 105 return 0;
104} 106}
105 107
106static ssize_t mv64x60_wdt_write(struct file *file, const char *data, 108static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data,
107 size_t len, loff_t * ppos) 109 size_t len, loff_t * ppos)
108{ 110{
109 if (*ppos != file->f_pos)
110 return -ESPIPE;
111
112 if (len) 111 if (len)
113 mv64x60_wdt_service(); 112 mv64x60_wdt_service();
114 113
@@ -119,6 +118,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
119 unsigned int cmd, unsigned long arg) 118 unsigned int cmd, unsigned long arg)
120{ 119{
121 int timeout; 120 int timeout;
121 void __user *argp = (void __user *)arg;
122 static struct watchdog_info info = { 122 static struct watchdog_info info = {
123 .options = WDIOF_KEEPALIVEPING, 123 .options = WDIOF_KEEPALIVEPING,
124 .firmware_version = 0, 124 .firmware_version = 0,
@@ -127,13 +127,13 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
127 127
128 switch (cmd) { 128 switch (cmd) {
129 case WDIOC_GETSUPPORT: 129 case WDIOC_GETSUPPORT:
130 if (copy_to_user((void *)arg, &info, sizeof(info))) 130 if (copy_to_user(argp, &info, sizeof(info)))
131 return -EFAULT; 131 return -EFAULT;
132 break; 132 break;
133 133
134 case WDIOC_GETSTATUS: 134 case WDIOC_GETSTATUS:
135 case WDIOC_GETBOOTSTATUS: 135 case WDIOC_GETBOOTSTATUS:
136 if (put_user(wdt_status, (int *)arg)) 136 if (put_user(wdt_status, (int __user *)argp))
137 return -EFAULT; 137 return -EFAULT;
138 wdt_status &= ~WDIOF_KEEPALIVEPING; 138 wdt_status &= ~WDIOF_KEEPALIVEPING;
139 break; 139 break;
@@ -154,7 +154,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
154 154
155 case WDIOC_GETTIMEOUT: 155 case WDIOC_GETTIMEOUT:
156 timeout = mv64x60_wdt_timeout * HZ; 156 timeout = mv64x60_wdt_timeout * HZ;
157 if (put_user(timeout, (int *)arg)) 157 if (put_user(timeout, (int __user *)argp))
158 return -EFAULT; 158 return -EFAULT;
159 break; 159 break;
160 160
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index 5a80adbf8032..0b8e493be045 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -50,8 +50,8 @@
50#include <asm/io.h> /* For inb/outb/... */ 50#include <asm/io.h> /* For inb/outb/... */
51 51
52/* Module and version information */ 52/* Module and version information */
53#define WATCHDOG_VERSION "1.01" 53#define WATCHDOG_VERSION "1.02"
54#define WATCHDOG_DATE "02 Sep 2005" 54#define WATCHDOG_DATE "03 Sep 2005"
55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" 55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog"
56#define WATCHDOG_NAME "pcwd_pci" 56#define WATCHDOG_NAME "pcwd_pci"
57#define PFX WATCHDOG_NAME ": " 57#define PFX WATCHDOG_NAME ": "
@@ -70,19 +70,30 @@
70 * These are the defines that describe the control status bits for the 70 * These are the defines that describe the control status bits for the
71 * PCI-PC Watchdog card. 71 * PCI-PC Watchdog card.
72 */ 72 */
73#define WD_PCI_WTRP 0x01 /* Watchdog Trip status */ 73/* Port 1 : Control Status #1 */
74#define WD_PCI_HRBT 0x02 /* Watchdog Heartbeat */ 74#define WD_PCI_WTRP 0x01 /* Watchdog Trip status */
75#define WD_PCI_TTRP 0x04 /* Temperature Trip status */ 75#define WD_PCI_HRBT 0x02 /* Watchdog Heartbeat */
76#define WD_PCI_TTRP 0x04 /* Temperature Trip status */
77#define WD_PCI_RL2A 0x08 /* Relay 2 Active */
78#define WD_PCI_RL1A 0x10 /* Relay 1 Active */
79#define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip/reset */
80#define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */
81/* Port 2 : Control Status #2 */
82#define WD_PCI_WDIS 0x10 /* Watchdog Disable */
83#define WD_PCI_ENTP 0x20 /* Enable Temperature Trip Reset */
84#define WD_PCI_WRSP 0x40 /* Watchdog wrote response */
85#define WD_PCI_PCMD 0x80 /* PC has sent command */
76 86
77/* according to documentation max. time to process a command for the pci 87/* according to documentation max. time to process a command for the pci
78 * watchdog card is 100 ms, so we give it 150 ms to do it's job */ 88 * watchdog card is 100 ms, so we give it 150 ms to do it's job */
79#define PCI_COMMAND_TIMEOUT 150 89#define PCI_COMMAND_TIMEOUT 150
80 90
81/* Watchdog's internal commands */ 91/* Watchdog's internal commands */
82#define CMD_GET_STATUS 0x04 92#define CMD_GET_STATUS 0x04
83#define CMD_GET_FIRMWARE_VERSION 0x08 93#define CMD_GET_FIRMWARE_VERSION 0x08
84#define CMD_READ_WATCHDOG_TIMEOUT 0x18 94#define CMD_READ_WATCHDOG_TIMEOUT 0x18
85#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 95#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19
96#define CMD_GET_CLEAR_RESET_COUNT 0x84
86 97
87/* We can only use 1 card due to the /dev/watchdog restriction */ 98/* We can only use 1 card due to the /dev/watchdog restriction */
88static int cards_found; 99static int cards_found;
@@ -91,15 +102,22 @@ static int cards_found;
91static int temp_panic; 102static int temp_panic;
92static unsigned long is_active; 103static unsigned long is_active;
93static char expect_release; 104static char expect_release;
94static struct { 105static struct { /* this is private data for each PCI-PC watchdog card */
95 int supports_temp; /* Wether or not the card has a temperature device */ 106 int supports_temp; /* Wether or not the card has a temperature device */
96 int boot_status; /* The card's boot status */ 107 int boot_status; /* The card's boot status */
97 unsigned long io_addr; /* The cards I/O address */ 108 unsigned long io_addr; /* The cards I/O address */
98 spinlock_t io_lock; 109 spinlock_t io_lock; /* the lock for io operations */
99 struct pci_dev *pdev; 110 struct pci_dev *pdev; /* the PCI-device */
100} pcipcwd_private; 111} pcipcwd_private;
101 112
102/* module parameters */ 113/* module parameters */
114#define QUIET 0 /* Default */
115#define VERBOSE 1 /* Verbose */
116#define DEBUG 2 /* print fancy stuff too */
117static int debug = QUIET;
118module_param(debug, int, 0);
119MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)");
120
103#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ 121#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */
104static int heartbeat = WATCHDOG_HEARTBEAT; 122static int heartbeat = WATCHDOG_HEARTBEAT;
105module_param(heartbeat, int, 0); 123module_param(heartbeat, int, 0);
@@ -117,6 +135,10 @@ static int send_command(int cmd, int *msb, int *lsb)
117{ 135{
118 int got_response, count; 136 int got_response, count;
119 137
138 if (debug >= DEBUG)
139 printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n",
140 cmd, *msb, *lsb);
141
120 spin_lock(&pcipcwd_private.io_lock); 142 spin_lock(&pcipcwd_private.io_lock);
121 /* If a command requires data it should be written first. 143 /* If a command requires data it should be written first.
122 * Data for commands with 8 bits of data should be written to port 4. 144 * Data for commands with 8 bits of data should be written to port 4.
@@ -131,10 +153,19 @@ static int send_command(int cmd, int *msb, int *lsb)
131 /* wait till the pci card processed the command, signaled by 153 /* wait till the pci card processed the command, signaled by
132 * the WRSP bit in port 2 and give it a max. timeout of 154 * the WRSP bit in port 2 and give it a max. timeout of
133 * PCI_COMMAND_TIMEOUT to process */ 155 * PCI_COMMAND_TIMEOUT to process */
134 got_response = inb_p(pcipcwd_private.io_addr + 2) & 0x40; 156 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
135 for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) { 157 for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) {
136 mdelay(1); 158 mdelay(1);
137 got_response = inb_p(pcipcwd_private.io_addr + 2) & 0x40; 159 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
160 }
161
162 if (debug >= DEBUG) {
163 if (got_response) {
164 printk(KERN_DEBUG PFX "time to process command was: %d ms\n",
165 count);
166 } else {
167 printk(KERN_DEBUG PFX "card did not respond on command!\n");
168 }
138 } 169 }
139 170
140 if (got_response) { 171 if (got_response) {
@@ -144,12 +175,66 @@ static int send_command(int cmd, int *msb, int *lsb)
144 175
145 /* clear WRSP bit */ 176 /* clear WRSP bit */
146 inb_p(pcipcwd_private.io_addr + 6); 177 inb_p(pcipcwd_private.io_addr + 6);
178
179 if (debug >= DEBUG)
180 printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n",
181 cmd, *msb, *lsb);
147 } 182 }
183
148 spin_unlock(&pcipcwd_private.io_lock); 184 spin_unlock(&pcipcwd_private.io_lock);
149 185
150 return got_response; 186 return got_response;
151} 187}
152 188
189static inline void pcipcwd_check_temperature_support(void)
190{
191 if (inb_p(pcipcwd_private.io_addr) != 0xF0)
192 pcipcwd_private.supports_temp = 1;
193}
194
195static int pcipcwd_get_option_switches(void)
196{
197 int option_switches;
198
199 option_switches = inb_p(pcipcwd_private.io_addr + 3);
200 return option_switches;
201}
202
203static void pcipcwd_show_card_info(void)
204{
205 int got_fw_rev, fw_rev_major, fw_rev_minor;
206 char fw_ver_str[20]; /* The cards firmware version */
207 int option_switches;
208
209 got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor);
210 if (got_fw_rev) {
211 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
212 } else {
213 sprintf(fw_ver_str, "<card no answer>");
214 }
215
216 /* Get switch settings */
217 option_switches = pcipcwd_get_option_switches();
218
219 printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n",
220 (int) pcipcwd_private.io_addr, fw_ver_str,
221 (pcipcwd_private.supports_temp ? "with" : "without"));
222
223 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
224 option_switches,
225 ((option_switches & 0x10) ? "ON" : "OFF"),
226 ((option_switches & 0x08) ? "ON" : "OFF"));
227
228 if (pcipcwd_private.boot_status & WDIOF_CARDRESET)
229 printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n");
230
231 if (pcipcwd_private.boot_status & WDIOF_OVERHEAT)
232 printk(KERN_INFO PFX "Card sensed a CPU Overheat\n");
233
234 if (pcipcwd_private.boot_status == 0)
235 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
236}
237
153static int pcipcwd_start(void) 238static int pcipcwd_start(void)
154{ 239{
155 int stat_reg; 240 int stat_reg;
@@ -161,11 +246,14 @@ static int pcipcwd_start(void)
161 stat_reg = inb_p(pcipcwd_private.io_addr + 2); 246 stat_reg = inb_p(pcipcwd_private.io_addr + 2);
162 spin_unlock(&pcipcwd_private.io_lock); 247 spin_unlock(&pcipcwd_private.io_lock);
163 248
164 if (stat_reg & 0x10) { 249 if (stat_reg & WD_PCI_WDIS) {
165 printk(KERN_ERR PFX "Card timer not enabled\n"); 250 printk(KERN_ERR PFX "Card timer not enabled\n");
166 return -1; 251 return -1;
167 } 252 }
168 253
254 if (debug >= VERBOSE)
255 printk(KERN_DEBUG PFX "Watchdog started\n");
256
169 return 0; 257 return 0;
170} 258}
171 259
@@ -183,18 +271,25 @@ static int pcipcwd_stop(void)
183 stat_reg = inb_p(pcipcwd_private.io_addr + 2); 271 stat_reg = inb_p(pcipcwd_private.io_addr + 2);
184 spin_unlock(&pcipcwd_private.io_lock); 272 spin_unlock(&pcipcwd_private.io_lock);
185 273
186 if (!(stat_reg & 0x10)) { 274 if (!(stat_reg & WD_PCI_WDIS)) {
187 printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); 275 printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n");
188 return -1; 276 return -1;
189 } 277 }
190 278
279 if (debug >= VERBOSE)
280 printk(KERN_DEBUG PFX "Watchdog stopped\n");
281
191 return 0; 282 return 0;
192} 283}
193 284
194static int pcipcwd_keepalive(void) 285static int pcipcwd_keepalive(void)
195{ 286{
196 /* Re-trigger watchdog by writing to port 0 */ 287 /* Re-trigger watchdog by writing to port 0 */
197 outb_p(0x42, pcipcwd_private.io_addr); 288 outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */
289
290 if (debug >= DEBUG)
291 printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n");
292
198 return 0; 293 return 0;
199} 294}
200 295
@@ -210,29 +305,64 @@ static int pcipcwd_set_heartbeat(int t)
210 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); 305 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb);
211 306
212 heartbeat = t; 307 heartbeat = t;
308 if (debug >= VERBOSE)
309 printk(KERN_DEBUG PFX "New heartbeat: %d\n",
310 heartbeat);
311
213 return 0; 312 return 0;
214} 313}
215 314
216static int pcipcwd_get_status(int *status) 315static int pcipcwd_get_status(int *status)
217{ 316{
218 int new_status; 317 int control_status;
219 318
220 *status=0; 319 *status=0;
221 new_status = inb_p(pcipcwd_private.io_addr + 1); 320 control_status = inb_p(pcipcwd_private.io_addr + 1);
222 if (new_status & WD_PCI_WTRP) 321 if (control_status & WD_PCI_WTRP)
223 *status |= WDIOF_CARDRESET; 322 *status |= WDIOF_CARDRESET;
224 if (new_status & WD_PCI_TTRP) { 323 if (control_status & WD_PCI_TTRP) {
225 *status |= WDIOF_OVERHEAT; 324 *status |= WDIOF_OVERHEAT;
226 if (temp_panic) 325 if (temp_panic)
227 panic(PFX "Temperature overheat trip!\n"); 326 panic(PFX "Temperature overheat trip!\n");
228 } 327 }
229 328
329 if (debug >= DEBUG)
330 printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n",
331 control_status);
332
230 return 0; 333 return 0;
231} 334}
232 335
233static int pcipcwd_clear_status(void) 336static int pcipcwd_clear_status(void)
234{ 337{
235 outb_p(0x01, pcipcwd_private.io_addr + 1); 338 int control_status;
339 int msb;
340 int reset_counter;
341
342 if (debug >= VERBOSE)
343 printk(KERN_INFO PFX "clearing watchdog trip status & LED\n");
344
345 control_status = inb_p(pcipcwd_private.io_addr + 1);
346
347 if (debug >= DEBUG) {
348 printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status);
349 printk(KERN_DEBUG PFX "sending: 0x%02x\n",
350 (control_status & WD_PCI_R2DS) | WD_PCI_WTRP);
351 }
352
353 /* clear trip status & LED and keep mode of relay 2 */
354 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1);
355
356 /* clear reset counter */
357 msb=0;
358 reset_counter=0xff;
359 send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter);
360
361 if (debug >= DEBUG) {
362 printk(KERN_DEBUG PFX "reset count was: 0x%02x\n",
363 reset_counter);
364 }
365
236 return 0; 366 return 0;
237} 367}
238 368
@@ -242,11 +372,18 @@ static int pcipcwd_get_temperature(int *temperature)
242 if (!pcipcwd_private.supports_temp) 372 if (!pcipcwd_private.supports_temp)
243 return -ENODEV; 373 return -ENODEV;
244 374
375 *temperature = inb_p(pcipcwd_private.io_addr);
376
245 /* 377 /*
246 * Convert celsius to fahrenheit, since this was 378 * Convert celsius to fahrenheit, since this was
247 * the decided 'standard' for this return value. 379 * the decided 'standard' for this return value.
248 */ 380 */
249 *temperature = ((inb_p(pcipcwd_private.io_addr)) * 9 / 5) + 32; 381 *temperature = (*temperature * 9 / 5) + 32;
382
383 if (debug >= DEBUG) {
384 printk(KERN_DEBUG PFX "temperature is: %d F\n",
385 *temperature);
386 }
250 387
251 return 0; 388 return 0;
252} 389}
@@ -256,7 +393,7 @@ static int pcipcwd_get_temperature(int *temperature)
256 */ 393 */
257 394
258static ssize_t pcipcwd_write(struct file *file, const char __user *data, 395static ssize_t pcipcwd_write(struct file *file, const char __user *data,
259 size_t len, loff_t *ppos) 396 size_t len, loff_t *ppos)
260{ 397{
261 /* See if we got the magic character 'V' and reload the timer */ 398 /* See if we got the magic character 'V' and reload the timer */
262 if (len) { 399 if (len) {
@@ -381,8 +518,11 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file,
381static int pcipcwd_open(struct inode *inode, struct file *file) 518static int pcipcwd_open(struct inode *inode, struct file *file)
382{ 519{
383 /* /dev/watchdog can only be opened once */ 520 /* /dev/watchdog can only be opened once */
384 if (test_and_set_bit(0, &is_active)) 521 if (test_and_set_bit(0, &is_active)) {
522 if (debug >= VERBOSE)
523 printk(KERN_ERR PFX "Attempt to open already opened device.\n");
385 return -EBUSY; 524 return -EBUSY;
525 }
386 526
387 /* Activate */ 527 /* Activate */
388 pcipcwd_start(); 528 pcipcwd_start();
@@ -492,19 +632,10 @@ static struct notifier_block pcipcwd_notifier = {
492 * Init & exit routines 632 * Init & exit routines
493 */ 633 */
494 634
495static inline void check_temperature_support(void)
496{
497 if (inb_p(pcipcwd_private.io_addr) != 0xF0)
498 pcipcwd_private.supports_temp = 1;
499}
500
501static int __devinit pcipcwd_card_init(struct pci_dev *pdev, 635static int __devinit pcipcwd_card_init(struct pci_dev *pdev,
502 const struct pci_device_id *ent) 636 const struct pci_device_id *ent)
503{ 637{
504 int ret = -EIO; 638 int ret = -EIO;
505 int got_fw_rev, fw_rev_major, fw_rev_minor;
506 char fw_ver_str[20];
507 char option_switches;
508 639
509 cards_found++; 640 cards_found++;
510 if (cards_found == 1) 641 if (cards_found == 1)
@@ -546,36 +677,10 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev,
546 pcipcwd_stop(); 677 pcipcwd_stop();
547 678
548 /* Check whether or not the card supports the temperature device */ 679 /* Check whether or not the card supports the temperature device */
549 check_temperature_support(); 680 pcipcwd_check_temperature_support();
550
551 /* Get the Firmware Version */
552 got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor);
553 if (got_fw_rev) {
554 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
555 } else {
556 sprintf(fw_ver_str, "<card no answer>");
557 }
558 681
559 /* Get switch settings */ 682 /* Show info about the card itself */
560 option_switches = inb_p(pcipcwd_private.io_addr + 3); 683 pcipcwd_show_card_info();
561
562 printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n",
563 (int) pcipcwd_private.io_addr, fw_ver_str,
564 (pcipcwd_private.supports_temp ? "with" : "without"));
565
566 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
567 option_switches,
568 ((option_switches & 0x10) ? "ON" : "OFF"),
569 ((option_switches & 0x08) ? "ON" : "OFF"));
570
571 if (pcipcwd_private.boot_status & WDIOF_CARDRESET)
572 printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n");
573
574 if (pcipcwd_private.boot_status & WDIOF_OVERHEAT)
575 printk(KERN_INFO PFX "Card sensed a CPU Overheat\n");
576
577 if (pcipcwd_private.boot_status == 0)
578 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
579 684
580 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 685 /* Check that the heartbeat value is within it's range ; if not reset to the default */
581 if (pcipcwd_set_heartbeat(heartbeat)) { 686 if (pcipcwd_set_heartbeat(heartbeat)) {
@@ -656,7 +761,7 @@ static struct pci_driver pcipcwd_driver = {
656 761
657static int __init pcipcwd_init_module(void) 762static int __init pcipcwd_init_module(void)
658{ 763{
659 spin_lock_init (&pcipcwd_private.io_lock); 764 spin_lock_init(&pcipcwd_private.io_lock);
660 765
661 return pci_register_driver(&pcipcwd_driver); 766 return pci_register_driver(&pcipcwd_driver);
662} 767}
diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c
index 966632182e2d..9f2f00d82917 100644
--- a/drivers/connector/cn_queue.c
+++ b/drivers/connector/cn_queue.c
@@ -31,16 +31,19 @@
31#include <linux/connector.h> 31#include <linux/connector.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33 33
34static void cn_queue_wrapper(void *data) 34void cn_queue_wrapper(void *data)
35{ 35{
36 struct cn_callback_entry *cbq = data; 36 struct cn_callback_data *d = data;
37 37
38 cbq->cb->callback(cbq->cb->priv); 38 d->callback(d->callback_priv);
39 cbq->destruct_data(cbq->ddata); 39
40 cbq->ddata = NULL; 40 d->destruct_data(d->ddata);
41 d->ddata = NULL;
42
43 kfree(d->free);
41} 44}
42 45
43static struct cn_callback_entry *cn_queue_alloc_callback_entry(struct cn_callback *cb) 46static struct cn_callback_entry *cn_queue_alloc_callback_entry(char *name, struct cb_id *id, void (*callback)(void *))
44{ 47{
45 struct cn_callback_entry *cbq; 48 struct cn_callback_entry *cbq;
46 49
@@ -50,8 +53,11 @@ static struct cn_callback_entry *cn_queue_alloc_callback_entry(struct cn_callbac
50 return NULL; 53 return NULL;
51 } 54 }
52 55
53 cbq->cb = cb; 56 snprintf(cbq->id.name, sizeof(cbq->id.name), "%s", name);
54 INIT_WORK(&cbq->work, &cn_queue_wrapper, cbq); 57 memcpy(&cbq->id.id, id, sizeof(struct cb_id));
58 cbq->data.callback = callback;
59
60 INIT_WORK(&cbq->work, &cn_queue_wrapper, &cbq->data);
55 return cbq; 61 return cbq;
56} 62}
57 63
@@ -68,12 +74,12 @@ int cn_cb_equal(struct cb_id *i1, struct cb_id *i2)
68 return ((i1->idx == i2->idx) && (i1->val == i2->val)); 74 return ((i1->idx == i2->idx) && (i1->val == i2->val));
69} 75}
70 76
71int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb) 77int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(void *))
72{ 78{
73 struct cn_callback_entry *cbq, *__cbq; 79 struct cn_callback_entry *cbq, *__cbq;
74 int found = 0; 80 int found = 0;
75 81
76 cbq = cn_queue_alloc_callback_entry(cb); 82 cbq = cn_queue_alloc_callback_entry(name, id, callback);
77 if (!cbq) 83 if (!cbq)
78 return -ENOMEM; 84 return -ENOMEM;
79 85
@@ -82,7 +88,7 @@ int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb)
82 88
83 spin_lock_bh(&dev->queue_lock); 89 spin_lock_bh(&dev->queue_lock);
84 list_for_each_entry(__cbq, &dev->queue_list, callback_entry) { 90 list_for_each_entry(__cbq, &dev->queue_list, callback_entry) {
85 if (cn_cb_equal(&__cbq->cb->id, &cb->id)) { 91 if (cn_cb_equal(&__cbq->id.id, id)) {
86 found = 1; 92 found = 1;
87 break; 93 break;
88 } 94 }
@@ -99,7 +105,7 @@ int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb)
99 105
100 cbq->nls = dev->nls; 106 cbq->nls = dev->nls;
101 cbq->seq = 0; 107 cbq->seq = 0;
102 cbq->group = cbq->cb->id.idx; 108 cbq->group = cbq->id.id.idx;
103 109
104 return 0; 110 return 0;
105} 111}
@@ -111,7 +117,7 @@ void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id)
111 117
112 spin_lock_bh(&dev->queue_lock); 118 spin_lock_bh(&dev->queue_lock);
113 list_for_each_entry_safe(cbq, n, &dev->queue_list, callback_entry) { 119 list_for_each_entry_safe(cbq, n, &dev->queue_list, callback_entry) {
114 if (cn_cb_equal(&cbq->cb->id, id)) { 120 if (cn_cb_equal(&cbq->id.id, id)) {
115 list_del(&cbq->callback_entry); 121 list_del(&cbq->callback_entry);
116 found = 1; 122 found = 1;
117 break; 123 break;
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index aaf6d468a8b9..505677fb3157 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -69,7 +69,7 @@ int cn_already_initialized = 0;
69 * a new message. 69 * a new message.
70 * 70 *
71 */ 71 */
72int cn_netlink_send(struct cn_msg *msg, u32 __group, int gfp_mask) 72int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
73{ 73{
74 struct cn_callback_entry *__cbq; 74 struct cn_callback_entry *__cbq;
75 unsigned int size; 75 unsigned int size;
@@ -84,7 +84,7 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, int gfp_mask)
84 spin_lock_bh(&dev->cbdev->queue_lock); 84 spin_lock_bh(&dev->cbdev->queue_lock);
85 list_for_each_entry(__cbq, &dev->cbdev->queue_list, 85 list_for_each_entry(__cbq, &dev->cbdev->queue_list,
86 callback_entry) { 86 callback_entry) {
87 if (cn_cb_equal(&__cbq->cb->id, &msg->id)) { 87 if (cn_cb_equal(&__cbq->id.id, &msg->id)) {
88 found = 1; 88 found = 1;
89 group = __cbq->group; 89 group = __cbq->group;
90 } 90 }
@@ -127,42 +127,56 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v
127{ 127{
128 struct cn_callback_entry *__cbq; 128 struct cn_callback_entry *__cbq;
129 struct cn_dev *dev = &cdev; 129 struct cn_dev *dev = &cdev;
130 int found = 0; 130 int err = -ENODEV;
131 131
132 spin_lock_bh(&dev->cbdev->queue_lock); 132 spin_lock_bh(&dev->cbdev->queue_lock);
133 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) { 133 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) {
134 if (cn_cb_equal(&__cbq->cb->id, &msg->id)) { 134 if (cn_cb_equal(&__cbq->id.id, &msg->id)) {
135 /*
136 * Let's scream if there is some magic and the
137 * data will arrive asynchronously here.
138 * [i.e. netlink messages will be queued].
139 * After the first warning I will fix it
140 * quickly, but now I think it is
141 * impossible. --zbr (2004_04_27).
142 */
143 if (likely(!test_bit(0, &__cbq->work.pending) && 135 if (likely(!test_bit(0, &__cbq->work.pending) &&
144 __cbq->ddata == NULL)) { 136 __cbq->data.ddata == NULL)) {
145 __cbq->cb->priv = msg; 137 __cbq->data.callback_priv = msg;
146 138
147 __cbq->ddata = data; 139 __cbq->data.ddata = data;
148 __cbq->destruct_data = destruct_data; 140 __cbq->data.destruct_data = destruct_data;
149 141
150 if (queue_work(dev->cbdev->cn_queue, 142 if (queue_work(dev->cbdev->cn_queue,
151 &__cbq->work)) 143 &__cbq->work))
152 found = 1; 144 err = 0;
153 } else { 145 } else {
154 printk("%s: cbq->data=%p, " 146 struct work_struct *w;
155 "work->pending=%08lx.\n", 147 struct cn_callback_data *d;
156 __func__, __cbq->ddata, 148
157 __cbq->work.pending); 149 w = kzalloc(sizeof(*w) + sizeof(*d), GFP_ATOMIC);
158 WARN_ON(1); 150 if (w) {
151 d = (struct cn_callback_data *)(w+1);
152
153 d->callback_priv = msg;
154 d->callback = __cbq->data.callback;
155 d->ddata = data;
156 d->destruct_data = destruct_data;
157 d->free = w;
158
159 INIT_LIST_HEAD(&w->entry);
160 w->pending = 0;
161 w->func = &cn_queue_wrapper;
162 w->data = d;
163 init_timer(&w->timer);
164
165 if (queue_work(dev->cbdev->cn_queue, w))
166 err = 0;
167 else {
168 kfree(w);
169 err = -EINVAL;
170 }
171 } else
172 err = -ENOMEM;
159 } 173 }
160 break; 174 break;
161 } 175 }
162 } 176 }
163 spin_unlock_bh(&dev->cbdev->queue_lock); 177 spin_unlock_bh(&dev->cbdev->queue_lock);
164 178
165 return found ? 0 : -ENODEV; 179 return err;
166} 180}
167 181
168/* 182/*
@@ -291,22 +305,10 @@ int cn_add_callback(struct cb_id *id, char *name, void (*callback)(void *))
291{ 305{
292 int err; 306 int err;
293 struct cn_dev *dev = &cdev; 307 struct cn_dev *dev = &cdev;
294 struct cn_callback *cb;
295
296 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
297 if (!cb)
298 return -ENOMEM;
299
300 scnprintf(cb->name, sizeof(cb->name), "%s", name);
301 308
302 memcpy(&cb->id, id, sizeof(cb->id)); 309 err = cn_queue_add_callback(dev->cbdev, name, id, callback);
303 cb->callback = callback; 310 if (err)
304
305 err = cn_queue_add_callback(dev->cbdev, cb);
306 if (err) {
307 kfree(cb);
308 return err; 311 return err;
309 }
310 312
311 cn_notify(id, 0); 313 cn_notify(id, 0);
312 314
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 3b865f34a095..4f4ba9b6d182 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -50,7 +50,7 @@
50MODULE_AUTHOR("Abhay Salunke <abhay_salunke@dell.com>"); 50MODULE_AUTHOR("Abhay Salunke <abhay_salunke@dell.com>");
51MODULE_DESCRIPTION("Driver for updating BIOS image on DELL systems"); 51MODULE_DESCRIPTION("Driver for updating BIOS image on DELL systems");
52MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
53MODULE_VERSION("1.0"); 53MODULE_VERSION("3.0");
54 54
55#define BIOS_SCAN_LIMIT 0xffffffff 55#define BIOS_SCAN_LIMIT 0xffffffff
56#define MAX_IMAGE_LENGTH 16 56#define MAX_IMAGE_LENGTH 16
@@ -62,14 +62,16 @@ static struct _rbu_data {
62 int dma_alloc; 62 int dma_alloc;
63 spinlock_t lock; 63 spinlock_t lock;
64 unsigned long packet_read_count; 64 unsigned long packet_read_count;
65 unsigned long packet_write_count;
66 unsigned long num_packets; 65 unsigned long num_packets;
67 unsigned long packetsize; 66 unsigned long packetsize;
67 unsigned long imagesize;
68 int entry_created;
68} rbu_data; 69} rbu_data;
69 70
70static char image_type[MAX_IMAGE_LENGTH] = "mono"; 71static char image_type[MAX_IMAGE_LENGTH + 1] = "mono";
71module_param_string(image_type, image_type, sizeof(image_type), 0); 72module_param_string(image_type, image_type, sizeof (image_type), 0);
72MODULE_PARM_DESC(image_type, "BIOS image type. choose- mono or packet"); 73MODULE_PARM_DESC(image_type,
74 "BIOS image type. choose- mono or packet or init");
73 75
74struct packet_data { 76struct packet_data {
75 struct list_head list; 77 struct list_head list;
@@ -87,55 +89,13 @@ static dma_addr_t dell_rbu_dmaaddr;
87static void init_packet_head(void) 89static void init_packet_head(void)
88{ 90{
89 INIT_LIST_HEAD(&packet_data_head.list); 91 INIT_LIST_HEAD(&packet_data_head.list);
90 rbu_data.packet_write_count = 0;
91 rbu_data.packet_read_count = 0; 92 rbu_data.packet_read_count = 0;
92 rbu_data.num_packets = 0; 93 rbu_data.num_packets = 0;
93 rbu_data.packetsize = 0; 94 rbu_data.packetsize = 0;
95 rbu_data.imagesize = 0;
94} 96}
95 97
96static int fill_last_packet(void *data, size_t length) 98static int create_packet(void *data, size_t length)
97{
98 struct list_head *ptemp_list;
99 struct packet_data *packet = NULL;
100 int packet_count = 0;
101
102 pr_debug("fill_last_packet: entry \n");
103
104 if (!rbu_data.num_packets) {
105 pr_debug("fill_last_packet: num_packets=0\n");
106 return -ENOMEM;
107 }
108
109 packet_count = rbu_data.num_packets;
110
111 ptemp_list = (&packet_data_head.list)->prev;
112
113 packet = list_entry(ptemp_list, struct packet_data, list);
114
115 if ((rbu_data.packet_write_count + length) > rbu_data.packetsize) {
116 pr_debug("dell_rbu:%s: packet size data "
117 "overrun\n", __FUNCTION__);
118 return -EINVAL;
119 }
120
121 pr_debug("fill_last_packet : buffer = %p\n", packet->data);
122
123 memcpy((packet->data + rbu_data.packet_write_count), data, length);
124
125 if ((rbu_data.packet_write_count + length) == rbu_data.packetsize) {
126 /*
127 * this was the last data chunk in the packet
128 * so reinitialize the packet data counter to zero
129 */
130 rbu_data.packet_write_count = 0;
131 } else
132 rbu_data.packet_write_count += length;
133
134 pr_debug("fill_last_packet: exit \n");
135 return 0;
136}
137
138static int create_packet(size_t length)
139{ 99{
140 struct packet_data *newpacket; 100 struct packet_data *newpacket;
141 int ordernum = 0; 101 int ordernum = 0;
@@ -146,12 +106,14 @@ static int create_packet(size_t length)
146 pr_debug("create_packet: packetsize not specified\n"); 106 pr_debug("create_packet: packetsize not specified\n");
147 return -EINVAL; 107 return -EINVAL;
148 } 108 }
109 spin_unlock(&rbu_data.lock);
110 newpacket = kmalloc(sizeof (struct packet_data), GFP_KERNEL);
111 spin_lock(&rbu_data.lock);
149 112
150 newpacket = kmalloc(sizeof(struct packet_data), GFP_KERNEL);
151 if (!newpacket) { 113 if (!newpacket) {
152 printk(KERN_WARNING 114 printk(KERN_WARNING
153 "dell_rbu:%s: failed to allocate new " 115 "dell_rbu:%s: failed to allocate new "
154 "packet\n", __FUNCTION__); 116 "packet\n", __FUNCTION__);
155 return -ENOMEM; 117 return -ENOMEM;
156 } 118 }
157 119
@@ -160,15 +122,17 @@ static int create_packet(size_t length)
160 * there is no upper limit on memory 122 * there is no upper limit on memory
161 * address for packetized mechanism 123 * address for packetized mechanism
162 */ 124 */
163 newpacket->data = (unsigned char *)__get_free_pages(GFP_KERNEL, 125 spin_unlock(&rbu_data.lock);
164 ordernum); 126 newpacket->data = (unsigned char *) __get_free_pages(GFP_KERNEL,
127 ordernum);
128 spin_lock(&rbu_data.lock);
165 129
166 pr_debug("create_packet: newpacket %p\n", newpacket->data); 130 pr_debug("create_packet: newpacket %p\n", newpacket->data);
167 131
168 if (!newpacket->data) { 132 if (!newpacket->data) {
169 printk(KERN_WARNING 133 printk(KERN_WARNING
170 "dell_rbu:%s: failed to allocate new " 134 "dell_rbu:%s: failed to allocate new "
171 "packet\n", __FUNCTION__); 135 "packet\n", __FUNCTION__);
172 kfree(newpacket); 136 kfree(newpacket);
173 return -ENOMEM; 137 return -ENOMEM;
174 } 138 }
@@ -181,9 +145,11 @@ static int create_packet(size_t length)
181 INIT_LIST_HEAD(&newpacket->list); 145 INIT_LIST_HEAD(&newpacket->list);
182 list_add_tail(&newpacket->list, &packet_data_head.list); 146 list_add_tail(&newpacket->list, &packet_data_head.list);
183 /* 147 /*
184 * packets have fixed size 148 * packets may not have fixed size
185 */ 149 */
186 newpacket->length = rbu_data.packetsize; 150 newpacket->length = length;
151
152 memcpy(newpacket->data, data, length);
187 153
188 pr_debug("create_packet: exit \n"); 154 pr_debug("create_packet: exit \n");
189 155
@@ -193,20 +159,43 @@ static int create_packet(size_t length)
193static int packetize_data(void *data, size_t length) 159static int packetize_data(void *data, size_t length)
194{ 160{
195 int rc = 0; 161 int rc = 0;
162 int done = 0;
163 int packet_length;
164 u8 *temp;
165 u8 *end = (u8 *) data + length;
166 pr_debug("packetize_data: data length %d\n", length);
167 if (!rbu_data.packetsize) {
168 printk(KERN_WARNING
169 "dell_rbu: packetsize not specified\n");
170 return -EIO;
171 }
172
173 temp = (u8 *) data;
196 174
197 if (!rbu_data.packet_write_count) { 175 /* packetize the hunk */
198 if ((rc = create_packet(length))) 176 while (!done) {
177 if ((temp + rbu_data.packetsize) < end)
178 packet_length = rbu_data.packetsize;
179 else {
180 /* this is the last packet */
181 packet_length = end - temp;
182 done = 1;
183 }
184
185 if ((rc = create_packet(temp, packet_length)))
199 return rc; 186 return rc;
187
188 pr_debug("%lu:%lu\n", temp, (end - temp));
189 temp += packet_length;
200 } 190 }
201 if ((rc = fill_last_packet(data, length))) 191
202 return rc; 192 rbu_data.imagesize = length;
203 193
204 return rc; 194 return rc;
205} 195}
206 196
207static int 197static int do_packet_read(char *data, struct list_head *ptemp_list,
208do_packet_read(char *data, struct list_head *ptemp_list, 198 int length, int bytes_read, int *list_read_count)
209 int length, int bytes_read, int *list_read_count)
210{ 199{
211 void *ptemp_buf; 200 void *ptemp_buf;
212 struct packet_data *newpacket = NULL; 201 struct packet_data *newpacket = NULL;
@@ -258,8 +247,7 @@ static int packet_read_list(char *data, size_t * pread_length)
258 ptemp_list = (&packet_data_head.list)->next; 247 ptemp_list = (&packet_data_head.list)->next;
259 while (!list_empty(ptemp_list)) { 248 while (!list_empty(ptemp_list)) {
260 bytes_copied = do_packet_read(pdest, ptemp_list, 249 bytes_copied = do_packet_read(pdest, ptemp_list,
261 remaining_bytes, bytes_read, 250 remaining_bytes, bytes_read, &temp_count);
262 &temp_count);
263 remaining_bytes -= bytes_copied; 251 remaining_bytes -= bytes_copied;
264 bytes_read += bytes_copied; 252 bytes_read += bytes_copied;
265 pdest += bytes_copied; 253 pdest += bytes_copied;
@@ -287,7 +275,7 @@ static void packet_empty_list(void)
287 ptemp_list = (&packet_data_head.list)->next; 275 ptemp_list = (&packet_data_head.list)->next;
288 while (!list_empty(ptemp_list)) { 276 while (!list_empty(ptemp_list)) {
289 newpacket = 277 newpacket =
290 list_entry(ptemp_list, struct packet_data, list); 278 list_entry(ptemp_list, struct packet_data, list);
291 pnext_list = ptemp_list->next; 279 pnext_list = ptemp_list->next;
292 list_del(ptemp_list); 280 list_del(ptemp_list);
293 ptemp_list = pnext_list; 281 ptemp_list = pnext_list;
@@ -296,14 +284,13 @@ static void packet_empty_list(void)
296 * to make sure there are no stale RBU packets left in memory 284 * to make sure there are no stale RBU packets left in memory
297 */ 285 */
298 memset(newpacket->data, 0, rbu_data.packetsize); 286 memset(newpacket->data, 0, rbu_data.packetsize);
299 free_pages((unsigned long)newpacket->data, 287 free_pages((unsigned long) newpacket->data,
300 newpacket->ordernum); 288 newpacket->ordernum);
301 kfree(newpacket); 289 kfree(newpacket);
302 } 290 }
303 rbu_data.packet_write_count = 0;
304 rbu_data.packet_read_count = 0; 291 rbu_data.packet_read_count = 0;
305 rbu_data.num_packets = 0; 292 rbu_data.num_packets = 0;
306 rbu_data.packetsize = 0; 293 rbu_data.imagesize = 0;
307} 294}
308 295
309/* 296/*
@@ -319,14 +306,13 @@ static void img_update_free(void)
319 * BIOS image copied in memory. 306 * BIOS image copied in memory.
320 */ 307 */
321 memset(rbu_data.image_update_buffer, 0, 308 memset(rbu_data.image_update_buffer, 0,
322 rbu_data.image_update_buffer_size); 309 rbu_data.image_update_buffer_size);
323 if (rbu_data.dma_alloc == 1) 310 if (rbu_data.dma_alloc == 1)
324 dma_free_coherent(NULL, rbu_data.bios_image_size, 311 dma_free_coherent(NULL, rbu_data.bios_image_size,
325 rbu_data.image_update_buffer, 312 rbu_data.image_update_buffer, dell_rbu_dmaaddr);
326 dell_rbu_dmaaddr);
327 else 313 else
328 free_pages((unsigned long)rbu_data.image_update_buffer, 314 free_pages((unsigned long) rbu_data.image_update_buffer,
329 rbu_data.image_update_ordernum); 315 rbu_data.image_update_ordernum);
330 316
331 /* 317 /*
332 * Re-initialize the rbu_data variables after a free 318 * Re-initialize the rbu_data variables after a free
@@ -366,7 +352,7 @@ static int img_update_realloc(unsigned long size)
366 */ 352 */
367 if ((size != 0) && (rbu_data.image_update_buffer == NULL)) { 353 if ((size != 0) && (rbu_data.image_update_buffer == NULL)) {
368 printk(KERN_ERR "dell_rbu:%s: corruption " 354 printk(KERN_ERR "dell_rbu:%s: corruption "
369 "check failed\n", __FUNCTION__); 355 "check failed\n", __FUNCTION__);
370 return -EINVAL; 356 return -EINVAL;
371 } 357 }
372 /* 358 /*
@@ -385,17 +371,16 @@ static int img_update_realloc(unsigned long size)
385 371
386 ordernum = get_order(size); 372 ordernum = get_order(size);
387 image_update_buffer = 373 image_update_buffer =
388 (unsigned char *)__get_free_pages(GFP_KERNEL, ordernum); 374 (unsigned char *) __get_free_pages(GFP_KERNEL, ordernum);
389 375
390 img_buf_phys_addr = 376 img_buf_phys_addr =
391 (unsigned long)virt_to_phys(image_update_buffer); 377 (unsigned long) virt_to_phys(image_update_buffer);
392 378
393 if (img_buf_phys_addr > BIOS_SCAN_LIMIT) { 379 if (img_buf_phys_addr > BIOS_SCAN_LIMIT) {
394 free_pages((unsigned long)image_update_buffer, ordernum); 380 free_pages((unsigned long) image_update_buffer, ordernum);
395 ordernum = -1; 381 ordernum = -1;
396 image_update_buffer = dma_alloc_coherent(NULL, size, 382 image_update_buffer = dma_alloc_coherent(NULL, size,
397 &dell_rbu_dmaaddr, 383 &dell_rbu_dmaaddr, GFP_KERNEL);
398 GFP_KERNEL);
399 dma_alloc = 1; 384 dma_alloc = 1;
400 } 385 }
401 386
@@ -405,13 +390,13 @@ static int img_update_realloc(unsigned long size)
405 rbu_data.image_update_buffer = image_update_buffer; 390 rbu_data.image_update_buffer = image_update_buffer;
406 rbu_data.image_update_buffer_size = size; 391 rbu_data.image_update_buffer_size = size;
407 rbu_data.bios_image_size = 392 rbu_data.bios_image_size =
408 rbu_data.image_update_buffer_size; 393 rbu_data.image_update_buffer_size;
409 rbu_data.image_update_ordernum = ordernum; 394 rbu_data.image_update_ordernum = ordernum;
410 rbu_data.dma_alloc = dma_alloc; 395 rbu_data.dma_alloc = dma_alloc;
411 rc = 0; 396 rc = 0;
412 } else { 397 } else {
413 pr_debug("Not enough memory for image update:" 398 pr_debug("Not enough memory for image update:"
414 "size = %ld\n", size); 399 "size = %ld\n", size);
415 rc = -ENOMEM; 400 rc = -ENOMEM;
416 } 401 }
417 402
@@ -424,7 +409,6 @@ static ssize_t read_packet_data(char *buffer, loff_t pos, size_t count)
424 size_t bytes_left; 409 size_t bytes_left;
425 size_t data_length; 410 size_t data_length;
426 char *ptempBuf = buffer; 411 char *ptempBuf = buffer;
427 unsigned long imagesize;
428 412
429 /* check to see if we have something to return */ 413 /* check to see if we have something to return */
430 if (rbu_data.num_packets == 0) { 414 if (rbu_data.num_packets == 0) {
@@ -433,22 +417,20 @@ static ssize_t read_packet_data(char *buffer, loff_t pos, size_t count)
433 goto read_rbu_data_exit; 417 goto read_rbu_data_exit;
434 } 418 }
435 419
436 imagesize = rbu_data.num_packets * rbu_data.packetsize; 420 if (pos > rbu_data.imagesize) {
437
438 if (pos > imagesize) {
439 retval = 0; 421 retval = 0;
440 printk(KERN_WARNING "dell_rbu:read_packet_data: " 422 printk(KERN_WARNING "dell_rbu:read_packet_data: "
441 "data underrun\n"); 423 "data underrun\n");
442 goto read_rbu_data_exit; 424 goto read_rbu_data_exit;
443 } 425 }
444 426
445 bytes_left = imagesize - pos; 427 bytes_left = rbu_data.imagesize - pos;
446 data_length = min(bytes_left, count); 428 data_length = min(bytes_left, count);
447 429
448 if ((retval = packet_read_list(ptempBuf, &data_length)) < 0) 430 if ((retval = packet_read_list(ptempBuf, &data_length)) < 0)
449 goto read_rbu_data_exit; 431 goto read_rbu_data_exit;
450 432
451 if ((pos + count) > imagesize) { 433 if ((pos + count) > rbu_data.imagesize) {
452 rbu_data.packet_read_count = 0; 434 rbu_data.packet_read_count = 0;
453 /* this was the last copy */ 435 /* this was the last copy */
454 retval = bytes_left; 436 retval = bytes_left;
@@ -468,11 +450,11 @@ static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count)
468 450
469 /* check to see if we have something to return */ 451 /* check to see if we have something to return */
470 if ((rbu_data.image_update_buffer == NULL) || 452 if ((rbu_data.image_update_buffer == NULL) ||
471 (rbu_data.bios_image_size == 0)) { 453 (rbu_data.bios_image_size == 0)) {
472 pr_debug("read_rbu_data_mono: image_update_buffer %p ," 454 pr_debug("read_rbu_data_mono: image_update_buffer %p ,"
473 "bios_image_size %lu\n", 455 "bios_image_size %lu\n",
474 rbu_data.image_update_buffer, 456 rbu_data.image_update_buffer,
475 rbu_data.bios_image_size); 457 rbu_data.bios_image_size);
476 ret_count = -ENOMEM; 458 ret_count = -ENOMEM;
477 goto read_rbu_data_exit; 459 goto read_rbu_data_exit;
478 } 460 }
@@ -497,8 +479,8 @@ static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count)
497 return ret_count; 479 return ret_count;
498} 480}
499 481
500static ssize_t 482static ssize_t read_rbu_data(struct kobject *kobj, char *buffer,
501read_rbu_data(struct kobject *kobj, char *buffer, loff_t pos, size_t count) 483 loff_t pos, size_t count)
502{ 484{
503 ssize_t ret_count = 0; 485 ssize_t ret_count = 0;
504 486
@@ -515,9 +497,49 @@ read_rbu_data(struct kobject *kobj, char *buffer, loff_t pos, size_t count)
515 return ret_count; 497 return ret_count;
516} 498}
517 499
518static ssize_t 500static void callbackfn_rbu(const struct firmware *fw, void *context)
519read_rbu_image_type(struct kobject *kobj, char *buffer, loff_t pos, 501{
520 size_t count) 502 int rc = 0;
503
504 if (!fw || !fw->size) {
505 rbu_data.entry_created = 0;
506 return;
507 }
508
509 spin_lock(&rbu_data.lock);
510 if (!strcmp(image_type, "mono")) {
511 if (!img_update_realloc(fw->size))
512 memcpy(rbu_data.image_update_buffer,
513 fw->data, fw->size);
514 } else if (!strcmp(image_type, "packet")) {
515 /*
516 * we need to free previous packets if a
517 * new hunk of packets needs to be downloaded
518 */
519 packet_empty_list();
520 if (packetize_data(fw->data, fw->size))
521 /* Incase something goes wrong when we are
522 * in middle of packetizing the data, we
523 * need to free up whatever packets might
524 * have been created before we quit.
525 */
526 packet_empty_list();
527 } else
528 pr_debug("invalid image type specified.\n");
529 spin_unlock(&rbu_data.lock);
530
531 rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG,
532 "dell_rbu", &rbu_device->dev, &context, callbackfn_rbu);
533 if (rc)
534 printk(KERN_ERR
535 "dell_rbu:%s request_firmware_nowait failed"
536 " %d\n", __FUNCTION__, rc);
537 else
538 rbu_data.entry_created = 1;
539}
540
541static ssize_t read_rbu_image_type(struct kobject *kobj, char *buffer,
542 loff_t pos, size_t count)
521{ 543{
522 int size = 0; 544 int size = 0;
523 if (!pos) 545 if (!pos)
@@ -525,27 +547,90 @@ read_rbu_image_type(struct kobject *kobj, char *buffer, loff_t pos,
525 return size; 547 return size;
526} 548}
527 549
528static ssize_t 550static ssize_t write_rbu_image_type(struct kobject *kobj, char *buffer,
529write_rbu_image_type(struct kobject *kobj, char *buffer, loff_t pos, 551 loff_t pos, size_t count)
530 size_t count)
531{ 552{
532 int rc = count; 553 int rc = count;
554 int req_firm_rc = 0;
555 int i;
533 spin_lock(&rbu_data.lock); 556 spin_lock(&rbu_data.lock);
534 557 /*
535 if (strlen(buffer) < MAX_IMAGE_LENGTH) 558 * Find the first newline or space
536 sscanf(buffer, "%s", image_type); 559 */
537 else 560 for (i = 0; i < count; ++i)
538 printk(KERN_WARNING "dell_rbu: image_type is invalid" 561 if (buffer[i] == '\n' || buffer[i] == ' ') {
539 "max chars = %d, \n incoming str--%s-- \n", 562 buffer[i] = '\0';
540 MAX_IMAGE_LENGTH, buffer); 563 break;
564 }
565 if (i == count)
566 buffer[count] = '\0';
567
568 if (strstr(buffer, "mono"))
569 strcpy(image_type, "mono");
570 else if (strstr(buffer, "packet"))
571 strcpy(image_type, "packet");
572 else if (strstr(buffer, "init")) {
573 /*
574 * If due to the user error the driver gets in a bad
575 * state where even though it is loaded , the
576 * /sys/class/firmware/dell_rbu entries are missing.
577 * to cover this situation the user can recreate entries
578 * by writing init to image_type.
579 */
580 if (!rbu_data.entry_created) {
581 spin_unlock(&rbu_data.lock);
582 req_firm_rc = request_firmware_nowait(THIS_MODULE,
583 FW_ACTION_NOHOTPLUG, "dell_rbu",
584 &rbu_device->dev, &context,
585 callbackfn_rbu);
586 if (req_firm_rc) {
587 printk(KERN_ERR
588 "dell_rbu:%s request_firmware_nowait"
589 " failed %d\n", __FUNCTION__, rc);
590 rc = -EIO;
591 } else
592 rbu_data.entry_created = 1;
593
594 spin_lock(&rbu_data.lock);
595 }
596 } else {
597 printk(KERN_WARNING "dell_rbu: image_type is invalid\n");
598 spin_unlock(&rbu_data.lock);
599 return -EINVAL;
600 }
541 601
542 /* we must free all previous allocations */ 602 /* we must free all previous allocations */
543 packet_empty_list(); 603 packet_empty_list();
544 img_update_free(); 604 img_update_free();
545
546 spin_unlock(&rbu_data.lock); 605 spin_unlock(&rbu_data.lock);
606
547 return rc; 607 return rc;
608}
548 609
610static ssize_t read_rbu_packet_size(struct kobject *kobj, char *buffer,
611 loff_t pos, size_t count)
612{
613 int size = 0;
614 if (!pos) {
615 spin_lock(&rbu_data.lock);
616 size = sprintf(buffer, "%lu\n", rbu_data.packetsize);
617 spin_unlock(&rbu_data.lock);
618 }
619 return size;
620}
621
622static ssize_t write_rbu_packet_size(struct kobject *kobj, char *buffer,
623 loff_t pos, size_t count)
624{
625 unsigned long temp;
626 spin_lock(&rbu_data.lock);
627 packet_empty_list();
628 sscanf(buffer, "%lu", &temp);
629 if (temp < 0xffffffff)
630 rbu_data.packetsize = temp;
631
632 spin_unlock(&rbu_data.lock);
633 return count;
549} 634}
550 635
551static struct bin_attribute rbu_data_attr = { 636static struct bin_attribute rbu_data_attr = {
@@ -559,38 +644,11 @@ static struct bin_attribute rbu_image_type_attr = {
559 .write = write_rbu_image_type, 644 .write = write_rbu_image_type,
560}; 645};
561 646
562static void callbackfn_rbu(const struct firmware *fw, void *context) 647static struct bin_attribute rbu_packet_size_attr = {
563{ 648 .attr = {.name = "packet_size",.owner = THIS_MODULE,.mode = 0644},
564 int rc = 0; 649 .read = read_rbu_packet_size,
565 650 .write = write_rbu_packet_size,
566 if (!fw || !fw->size) 651};
567 return;
568
569 spin_lock(&rbu_data.lock);
570 if (!strcmp(image_type, "mono")) {
571 if (!img_update_realloc(fw->size))
572 memcpy(rbu_data.image_update_buffer,
573 fw->data, fw->size);
574 } else if (!strcmp(image_type, "packet")) {
575 if (!rbu_data.packetsize)
576 rbu_data.packetsize = fw->size;
577 else if (rbu_data.packetsize != fw->size) {
578 packet_empty_list();
579 rbu_data.packetsize = fw->size;
580 }
581 packetize_data(fw->data, fw->size);
582 } else
583 pr_debug("invalid image type specified.\n");
584 spin_unlock(&rbu_data.lock);
585
586 rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG,
587 "dell_rbu", &rbu_device->dev,
588 &context, callbackfn_rbu);
589 if (rc)
590 printk(KERN_ERR
591 "dell_rbu:%s request_firmware_nowait failed"
592 " %d\n", __FUNCTION__, rc);
593}
594 652
595static int __init dcdrbu_init(void) 653static int __init dcdrbu_init(void)
596{ 654{
@@ -599,23 +657,26 @@ static int __init dcdrbu_init(void)
599 657
600 init_packet_head(); 658 init_packet_head();
601 rbu_device = 659 rbu_device =
602 platform_device_register_simple("dell_rbu", -1, NULL, 0); 660 platform_device_register_simple("dell_rbu", -1, NULL, 0);
603 if (!rbu_device) { 661 if (!rbu_device) {
604 printk(KERN_ERR 662 printk(KERN_ERR
605 "dell_rbu:%s:platform_device_register_simple " 663 "dell_rbu:%s:platform_device_register_simple "
606 "failed\n", __FUNCTION__); 664 "failed\n", __FUNCTION__);
607 return -EIO; 665 return -EIO;
608 } 666 }
609 667
610 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); 668 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
611 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr); 669 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
670 sysfs_create_bin_file(&rbu_device->dev.kobj,
671 &rbu_packet_size_attr);
612 672
613 rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG, 673 rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG,
614 "dell_rbu", &rbu_device->dev, 674 "dell_rbu", &rbu_device->dev, &context, callbackfn_rbu);
615 &context, callbackfn_rbu);
616 if (rc) 675 if (rc)
617 printk(KERN_ERR "dell_rbu:%s:request_firmware_nowait" 676 printk(KERN_ERR "dell_rbu:%s:request_firmware_nowait"
618 " failed %d\n", __FUNCTION__, rc); 677 " failed %d\n", __FUNCTION__, rc);
678 else
679 rbu_data.entry_created = 1;
619 680
620 return rc; 681 return rc;
621 682
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 7e72e922b41c..db358cfa7cbf 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -418,12 +418,11 @@ config SENSORS_HDAPS
418 help 418 help
419 This driver provides support for the IBM Hard Drive Active Protection 419 This driver provides support for the IBM Hard Drive Active Protection
420 System (hdaps), which provides an accelerometer and other misc. data. 420 System (hdaps), which provides an accelerometer and other misc. data.
421 Supported laptops include the IBM ThinkPad T41, T42, T43, and R51. 421 ThinkPads starting with the R50, T41, and X40 are supported. The
422 The accelerometer data is readable via sysfs. 422 accelerometer data is readable via sysfs.
423 423
424 This driver also provides an input class device, allowing the 424 This driver also provides an absolute input class device, allowing
425 laptop to act as a pinball machine-esque mouse. This is off by 425 the laptop to act as a pinball machine-esque joystick.
426 default but enabled via sysfs or the module parameter "mousedev".
427 426
428 Say Y here if you have an applicable laptop and want to experience 427 Say Y here if you have an applicable laptop and want to experience
429 the awesome power of hdaps. 428 the awesome power of hdaps.
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index eaebfc14c933..7f0107613827 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -4,11 +4,11 @@
4 * Copyright (C) 2005 Robert Love <rml@novell.com> 4 * Copyright (C) 2005 Robert Love <rml@novell.com>
5 * Copyright (C) 2005 Jesper Juhl <jesper.juhl@gmail.com> 5 * Copyright (C) 2005 Jesper Juhl <jesper.juhl@gmail.com>
6 * 6 *
7 * The HardDisk Active Protection System (hdaps) is present in the IBM ThinkPad 7 * The HardDisk Active Protection System (hdaps) is present in IBM ThinkPads
8 * T41, T42, T43, R51, and X40, at least. It provides a basic two-axis 8 * starting with the R40, T41, and X40. It provides a basic two-axis
9 * accelerometer and other data, such as the device's temperature. 9 * accelerometer and other data, such as the device's temperature.
10 * 10 *
11 * Based on the document by Mark A. Smith available at 11 * This driver is based on the document by Mark A. Smith available at
12 * http://www.almaden.ibm.com/cs/people/marksmith/tpaps.html and a lot of trial 12 * http://www.almaden.ibm.com/cs/people/marksmith/tpaps.html and a lot of trial
13 * and error. 13 * and error.
14 * 14 *
@@ -36,12 +36,7 @@
36#include <asm/io.h> 36#include <asm/io.h>
37 37
38#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */ 38#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */
39#define HDAPS_NR_PORTS 0x30 /* 0x1600 - 0x162f */ 39#define HDAPS_NR_PORTS 0x30 /* number of ports: 0x1600 - 0x162f */
40
41#define STATE_FRESH 0x50 /* accelerometer data is fresh */
42
43#define REFRESH_ASYNC 0x00 /* do asynchronous refresh */
44#define REFRESH_SYNC 0x01 /* do synchronous refresh */
45 40
46#define HDAPS_PORT_STATE 0x1611 /* device state */ 41#define HDAPS_PORT_STATE 0x1611 /* device state */
47#define HDAPS_PORT_YPOS 0x1612 /* y-axis position */ 42#define HDAPS_PORT_YPOS 0x1612 /* y-axis position */
@@ -53,7 +48,7 @@
53#define HDAPS_PORT_UNKNOWN 0x161c /* what is this? */ 48#define HDAPS_PORT_UNKNOWN 0x161c /* what is this? */
54#define HDAPS_PORT_KMACT 0x161d /* keyboard or mouse activity */ 49#define HDAPS_PORT_KMACT 0x161d /* keyboard or mouse activity */
55 50
56#define HDAPS_READ_MASK 0xff /* some reads have the low 8 bits set */ 51#define STATE_FRESH 0x50 /* accelerometer data is fresh */
57 52
58#define KEYBD_MASK 0x20 /* set if keyboard activity */ 53#define KEYBD_MASK 0x20 /* set if keyboard activity */
59#define MOUSE_MASK 0x40 /* set if mouse activity */ 54#define MOUSE_MASK 0x40 /* set if mouse activity */
@@ -63,12 +58,11 @@
63#define INIT_TIMEOUT_MSECS 4000 /* wait up to 4s for device init ... */ 58#define INIT_TIMEOUT_MSECS 4000 /* wait up to 4s for device init ... */
64#define INIT_WAIT_MSECS 200 /* ... in 200ms increments */ 59#define INIT_WAIT_MSECS 200 /* ... in 200ms increments */
65 60
66static struct platform_device *pdev; 61#define HDAPS_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */
67static struct input_dev hdaps_idev; 62#define HDAPS_INPUT_FUZZ 4 /* input event threshold */
63
68static struct timer_list hdaps_timer; 64static struct timer_list hdaps_timer;
69static unsigned int hdaps_mousedev_threshold = 4; 65static struct platform_device *pdev;
70static unsigned long hdaps_poll_ms = 50;
71static unsigned int hdaps_mousedev;
72static unsigned int hdaps_invert; 66static unsigned int hdaps_invert;
73static u8 km_activity; 67static u8 km_activity;
74static int rest_x; 68static int rest_x;
@@ -81,14 +75,14 @@ static DECLARE_MUTEX(hdaps_sem);
81 */ 75 */
82static inline u8 __get_latch(u16 port) 76static inline u8 __get_latch(u16 port)
83{ 77{
84 return inb(port) & HDAPS_READ_MASK; 78 return inb(port) & 0xff;
85} 79}
86 80
87/* 81/*
88 * __check_latch - Check a port latch for a given value. Callers must hold 82 * __check_latch - Check a port latch for a given value. Returns zero if the
89 * hdaps_sem. Returns zero if the port contains the given value. 83 * port contains the given value. Callers must hold hdaps_sem.
90 */ 84 */
91static inline unsigned int __check_latch(u16 port, u8 val) 85static inline int __check_latch(u16 port, u8 val)
92{ 86{
93 if (__get_latch(port) == val) 87 if (__get_latch(port) == val)
94 return 0; 88 return 0;
@@ -99,7 +93,7 @@ static inline unsigned int __check_latch(u16 port, u8 val)
99 * __wait_latch - Wait up to 100us for a port latch to get a certain value, 93 * __wait_latch - Wait up to 100us for a port latch to get a certain value,
100 * returning zero if the value is obtained. Callers must hold hdaps_sem. 94 * returning zero if the value is obtained. Callers must hold hdaps_sem.
101 */ 95 */
102static unsigned int __wait_latch(u16 port, u8 val) 96static int __wait_latch(u16 port, u8 val)
103{ 97{
104 unsigned int i; 98 unsigned int i;
105 99
@@ -109,59 +103,42 @@ static unsigned int __wait_latch(u16 port, u8 val)
109 udelay(5); 103 udelay(5);
110 } 104 }
111 105
112 return -EINVAL; 106 return -EIO;
113} 107}
114 108
115/* 109/*
116 * __device_refresh - Request a refresh from the accelerometer. 110 * __device_refresh - request a refresh from the accelerometer. Does not wait
117 * 111 * for refresh to complete. Callers must hold hdaps_sem.
118 * If sync is REFRESH_SYNC, we perform a synchronous refresh and will wait.
119 * Returns zero if successful and nonzero on error.
120 *
121 * If sync is REFRESH_ASYNC, we merely kick off a new refresh if the device is
122 * not up-to-date. Always returns zero.
123 *
124 * Callers must hold hdaps_sem.
125 */ 112 */
126static int __device_refresh(unsigned int sync) 113static void __device_refresh(void)
127{ 114{
128 u8 state; 115 udelay(200);
129 116 if (inb(0x1604) != STATE_FRESH) {
130 udelay(100); 117 outb(0x11, 0x1610);
131 118 outb(0x01, 0x161f);
132 state = inb(0x1604); 119 }
133 if (state == STATE_FRESH) 120}
134 return 0;
135
136 outb(0x11, 0x1610);
137 outb(0x01, 0x161f);
138 if (sync == REFRESH_ASYNC)
139 return 0;
140 121
122/*
123 * __device_refresh_sync - request a synchronous refresh from the
124 * accelerometer. We wait for the refresh to complete. Returns zero if
125 * successful and nonzero on error. Callers must hold hdaps_sem.
126 */
127static int __device_refresh_sync(void)
128{
129 __device_refresh();
141 return __wait_latch(0x1604, STATE_FRESH); 130 return __wait_latch(0x1604, STATE_FRESH);
142} 131}
143 132
144/* 133/*
145 * __device_complete - Indicate to the accelerometer that we are done reading 134 * __device_complete - indicate to the accelerometer that we are done reading
146 * data, and then initiate an async refresh. Callers must hold hdaps_sem. 135 * data, and then initiate an async refresh. Callers must hold hdaps_sem.
147 */ 136 */
148static inline void __device_complete(void) 137static inline void __device_complete(void)
149{ 138{
150 inb(0x161f); 139 inb(0x161f);
151 inb(0x1604); 140 inb(0x1604);
152 __device_refresh(REFRESH_ASYNC); 141 __device_refresh();
153}
154
155static int __hdaps_readb_one(unsigned int port, u8 *val)
156{
157 /* do a sync refresh -- we need to be sure that we read fresh data */
158 if (__device_refresh(REFRESH_SYNC))
159 return -EIO;
160
161 *val = inb(port);
162 __device_complete();
163
164 return 0;
165} 142}
166 143
167/* 144/*
@@ -174,17 +151,26 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
174 int ret; 151 int ret;
175 152
176 down(&hdaps_sem); 153 down(&hdaps_sem);
177 ret = __hdaps_readb_one(port, val);
178 up(&hdaps_sem);
179 154
155 /* do a sync refresh -- we need to be sure that we read fresh data */
156 ret = __device_refresh_sync();
157 if (ret)
158 goto out;
159
160 *val = inb(port);
161 __device_complete();
162
163out:
164 up(&hdaps_sem);
180 return ret; 165 return ret;
181} 166}
182 167
168/* __hdaps_read_pair - internal lockless helper for hdaps_read_pair(). */
183static int __hdaps_read_pair(unsigned int port1, unsigned int port2, 169static int __hdaps_read_pair(unsigned int port1, unsigned int port2,
184 int *x, int *y) 170 int *x, int *y)
185{ 171{
186 /* do a sync refresh -- we need to be sure that we read fresh data */ 172 /* do a sync refresh -- we need to be sure that we read fresh data */
187 if (__device_refresh(REFRESH_SYNC)) 173 if (__device_refresh_sync())
188 return -EIO; 174 return -EIO;
189 175
190 *y = inw(port2); 176 *y = inw(port2);
@@ -217,11 +203,13 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2,
217 return ret; 203 return ret;
218} 204}
219 205
220/* initialize the accelerometer */ 206/*
207 * hdaps_device_init - initialize the accelerometer. Returns zero on success
208 * and negative error code on failure. Can sleep.
209 */
221static int hdaps_device_init(void) 210static int hdaps_device_init(void)
222{ 211{
223 unsigned int total_msecs = INIT_TIMEOUT_MSECS; 212 int total, ret = -ENXIO;
224 int ret = -ENXIO;
225 213
226 down(&hdaps_sem); 214 down(&hdaps_sem);
227 215
@@ -231,8 +219,10 @@ static int hdaps_device_init(void)
231 goto out; 219 goto out;
232 220
233 /* 221 /*
234 * The 0x03 value appears to only work on some thinkpads, such as the 222 * Most ThinkPads return 0x01.
235 * T42p. Others return 0x01. 223 *
224 * Others--namely the R50p, T41p, and T42p--return 0x03. These laptops
225 * have "inverted" axises.
236 * 226 *
237 * The 0x02 value occurs when the chip has been previously initialized. 227 * The 0x02 value occurs when the chip has been previously initialized.
238 */ 228 */
@@ -267,24 +257,23 @@ static int hdaps_device_init(void)
267 outb(0x01, 0x161f); 257 outb(0x01, 0x161f);
268 if (__wait_latch(0x161f, 0x00)) 258 if (__wait_latch(0x161f, 0x00))
269 goto out; 259 goto out;
270 if (__device_refresh(REFRESH_SYNC)) 260 if (__device_refresh_sync())
271 goto out; 261 goto out;
272 if (__wait_latch(0x1611, 0x00)) 262 if (__wait_latch(0x1611, 0x00))
273 goto out; 263 goto out;
274 264
275 /* we have done our dance, now let's wait for the applause */ 265 /* we have done our dance, now let's wait for the applause */
276 while (total_msecs > 0) { 266 for (total = INIT_TIMEOUT_MSECS; total > 0; total -= INIT_WAIT_MSECS) {
277 u8 ignored; 267 int x, y;
278 268
279 /* a read of the device helps push it into action */ 269 /* a read of the device helps push it into action */
280 __hdaps_readb_one(HDAPS_PORT_UNKNOWN, &ignored); 270 __hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y);
281 if (!__wait_latch(0x1611, 0x02)) { 271 if (!__wait_latch(0x1611, 0x02)) {
282 ret = 0; 272 ret = 0;
283 break; 273 break;
284 } 274 }
285 275
286 msleep(INIT_WAIT_MSECS); 276 msleep(INIT_WAIT_MSECS);
287 total_msecs -= INIT_WAIT_MSECS;
288 } 277 }
289 278
290out: 279out:
@@ -293,96 +282,6 @@ out:
293} 282}
294 283
295 284
296/* Input class stuff */
297
298/*
299 * hdaps_calibrate - Zero out our "resting" values. Callers must hold hdaps_sem.
300 */
301static void hdaps_calibrate(void)
302{
303 int x, y;
304
305 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y))
306 return;
307
308 rest_x = x;
309 rest_y = y;
310}
311
312static void hdaps_mousedev_poll(unsigned long unused)
313{
314 int x, y;
315
316 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */
317 if (down_trylock(&hdaps_sem)) {
318 mod_timer(&hdaps_timer,jiffies+msecs_to_jiffies(hdaps_poll_ms));
319 return;
320 }
321
322 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y))
323 goto out;
324
325 x -= rest_x;
326 y -= rest_y;
327 if (abs(x) > hdaps_mousedev_threshold)
328 input_report_rel(&hdaps_idev, REL_X, x);
329 if (abs(y) > hdaps_mousedev_threshold)
330 input_report_rel(&hdaps_idev, REL_Y, y);
331 input_sync(&hdaps_idev);
332
333 mod_timer(&hdaps_timer, jiffies + msecs_to_jiffies(hdaps_poll_ms));
334
335out:
336 up(&hdaps_sem);
337}
338
339/*
340 * hdaps_mousedev_enable - enable the input class device. Can sleep.
341 */
342static void hdaps_mousedev_enable(void)
343{
344 down(&hdaps_sem);
345
346 /* calibrate the device before enabling */
347 hdaps_calibrate();
348
349 /* initialize the input class */
350 init_input_dev(&hdaps_idev);
351 hdaps_idev.dev = &pdev->dev;
352 hdaps_idev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
353 hdaps_idev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
354 hdaps_idev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT);
355 input_register_device(&hdaps_idev);
356
357 /* start up our timer */
358 init_timer(&hdaps_timer);
359 hdaps_timer.function = hdaps_mousedev_poll;
360 hdaps_timer.expires = jiffies + msecs_to_jiffies(hdaps_poll_ms);
361 add_timer(&hdaps_timer);
362
363 hdaps_mousedev = 1;
364
365 up(&hdaps_sem);
366
367 printk(KERN_INFO "hdaps: input device enabled.\n");
368}
369
370/*
371 * hdaps_mousedev_disable - disable the input class device. Caller must hold
372 * hdaps_sem.
373 */
374static void hdaps_mousedev_disable(void)
375{
376 down(&hdaps_sem);
377 if (hdaps_mousedev) {
378 hdaps_mousedev = 0;
379 del_timer_sync(&hdaps_timer);
380 input_unregister_device(&hdaps_idev);
381 }
382 up(&hdaps_sem);
383}
384
385
386/* Device model stuff */ 285/* Device model stuff */
387 286
388static int hdaps_probe(struct device *dev) 287static int hdaps_probe(struct device *dev)
@@ -412,6 +311,49 @@ static struct device_driver hdaps_driver = {
412 .resume = hdaps_resume 311 .resume = hdaps_resume
413}; 312};
414 313
314/* Input class stuff */
315
316static struct input_dev hdaps_idev = {
317 .name = "hdaps",
318 .evbit = { BIT(EV_ABS) },
319 .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
320 .absmin = { [ABS_X] = -256, [ABS_Y] = -256 },
321 .absmax = { [ABS_X] = 256, [ABS_Y] = 256 },
322 .absfuzz = { [ABS_X] = HDAPS_INPUT_FUZZ, [ABS_Y] = HDAPS_INPUT_FUZZ },
323 .absflat = { [ABS_X] = HDAPS_INPUT_FUZZ, [ABS_Y] = HDAPS_INPUT_FUZZ },
324};
325
326/*
327 * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem.
328 */
329static void hdaps_calibrate(void)
330{
331 __hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &rest_x, &rest_y);
332}
333
334static void hdaps_mousedev_poll(unsigned long unused)
335{
336 int x, y;
337
338 /* Cannot sleep. Try nonblockingly. If we fail, try again later. */
339 if (down_trylock(&hdaps_sem)) {
340 mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD);
341 return;
342 }
343
344 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y))
345 goto out;
346
347 input_report_abs(&hdaps_idev, ABS_X, x - rest_x);
348 input_report_abs(&hdaps_idev, ABS_Y, y - rest_y);
349 input_sync(&hdaps_idev);
350
351 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
352
353out:
354 up(&hdaps_sem);
355}
356
415 357
416/* Sysfs Files */ 358/* Sysfs Files */
417 359
@@ -517,69 +459,6 @@ static ssize_t hdaps_invert_store(struct device *dev,
517 return count; 459 return count;
518} 460}
519 461
520static ssize_t hdaps_mousedev_show(struct device *dev,
521 struct device_attribute *attr, char *buf)
522{
523 return sprintf(buf, "%d\n", hdaps_mousedev);
524}
525
526static ssize_t hdaps_mousedev_store(struct device *dev,
527 struct device_attribute *attr,
528 const char *buf, size_t count)
529{
530 int enable;
531
532 if (sscanf(buf, "%d", &enable) != 1)
533 return -EINVAL;
534
535 if (enable == 1)
536 hdaps_mousedev_enable();
537 else if (enable == 0)
538 hdaps_mousedev_disable();
539 else
540 return -EINVAL;
541
542 return count;
543}
544
545static ssize_t hdaps_poll_show(struct device *dev,
546 struct device_attribute *attr, char *buf)
547{
548 return sprintf(buf, "%lu\n", hdaps_poll_ms);
549}
550
551static ssize_t hdaps_poll_store(struct device *dev,
552 struct device_attribute *attr,
553 const char *buf, size_t count)
554{
555 unsigned int poll;
556
557 if (sscanf(buf, "%u", &poll) != 1 || poll == 0)
558 return -EINVAL;
559 hdaps_poll_ms = poll;
560
561 return count;
562}
563
564static ssize_t hdaps_threshold_show(struct device *dev,
565 struct device_attribute *attr, char *buf)
566{
567 return sprintf(buf, "%u\n", hdaps_mousedev_threshold);
568}
569
570static ssize_t hdaps_threshold_store(struct device *dev,
571 struct device_attribute *attr,
572 const char *buf, size_t count)
573{
574 unsigned int threshold;
575
576 if (sscanf(buf, "%u", &threshold) != 1 || threshold == 0)
577 return -EINVAL;
578 hdaps_mousedev_threshold = threshold;
579
580 return count;
581}
582
583static DEVICE_ATTR(position, 0444, hdaps_position_show, NULL); 462static DEVICE_ATTR(position, 0444, hdaps_position_show, NULL);
584static DEVICE_ATTR(variance, 0444, hdaps_variance_show, NULL); 463static DEVICE_ATTR(variance, 0444, hdaps_variance_show, NULL);
585static DEVICE_ATTR(temp1, 0444, hdaps_temp1_show, NULL); 464static DEVICE_ATTR(temp1, 0444, hdaps_temp1_show, NULL);
@@ -588,10 +467,6 @@ static DEVICE_ATTR(keyboard_activity, 0444, hdaps_keyboard_activity_show, NULL);
588static DEVICE_ATTR(mouse_activity, 0444, hdaps_mouse_activity_show, NULL); 467static DEVICE_ATTR(mouse_activity, 0444, hdaps_mouse_activity_show, NULL);
589static DEVICE_ATTR(calibrate, 0644, hdaps_calibrate_show,hdaps_calibrate_store); 468static DEVICE_ATTR(calibrate, 0644, hdaps_calibrate_show,hdaps_calibrate_store);
590static DEVICE_ATTR(invert, 0644, hdaps_invert_show, hdaps_invert_store); 469static DEVICE_ATTR(invert, 0644, hdaps_invert_show, hdaps_invert_store);
591static DEVICE_ATTR(mousedev, 0644, hdaps_mousedev_show, hdaps_mousedev_store);
592static DEVICE_ATTR(mousedev_poll_ms, 0644, hdaps_poll_show, hdaps_poll_store);
593static DEVICE_ATTR(mousedev_threshold, 0644, hdaps_threshold_show,
594 hdaps_threshold_store);
595 470
596static struct attribute *hdaps_attributes[] = { 471static struct attribute *hdaps_attributes[] = {
597 &dev_attr_position.attr, 472 &dev_attr_position.attr,
@@ -601,9 +476,6 @@ static struct attribute *hdaps_attributes[] = {
601 &dev_attr_keyboard_activity.attr, 476 &dev_attr_keyboard_activity.attr,
602 &dev_attr_mouse_activity.attr, 477 &dev_attr_mouse_activity.attr,
603 &dev_attr_calibrate.attr, 478 &dev_attr_calibrate.attr,
604 &dev_attr_mousedev.attr,
605 &dev_attr_mousedev_threshold.attr,
606 &dev_attr_mousedev_poll_ms.attr,
607 &dev_attr_invert.attr, 479 &dev_attr_invert.attr,
608 NULL, 480 NULL,
609}; 481};
@@ -615,24 +487,19 @@ static struct attribute_group hdaps_attribute_group = {
615 487
616/* Module stuff */ 488/* Module stuff */
617 489
618/* 490/* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */
619 * XXX: We should be able to return nonzero and halt the detection process.
620 * But there is a bug in dmi_check_system() where a nonzero return from the
621 * first match will result in a return of failure from dmi_check_system().
622 * I fixed this; the patch is in 2.6-mm. Once in Linus's tree we can make
623 * hdaps_dmi_match_invert() return hdaps_dmi_match(), which in turn returns 1.
624 */
625static int hdaps_dmi_match(struct dmi_system_id *id) 491static int hdaps_dmi_match(struct dmi_system_id *id)
626{ 492{
627 printk(KERN_INFO "hdaps: %s detected.\n", id->ident); 493 printk(KERN_INFO "hdaps: %s detected.\n", id->ident);
628 return 0; 494 return 1;
629} 495}
630 496
497/* hdaps_dmi_match_invert - found an inverted match. */
631static int hdaps_dmi_match_invert(struct dmi_system_id *id) 498static int hdaps_dmi_match_invert(struct dmi_system_id *id)
632{ 499{
633 hdaps_invert = 1; 500 hdaps_invert = 1;
634 printk(KERN_INFO "hdaps: inverting axis readings.\n"); 501 printk(KERN_INFO "hdaps: inverting axis readings.\n");
635 return 0; 502 return hdaps_dmi_match(id);
636} 503}
637 504
638#define HDAPS_DMI_MATCH_NORMAL(model) { \ 505#define HDAPS_DMI_MATCH_NORMAL(model) { \
@@ -662,12 +529,15 @@ static int __init hdaps_init(void)
662 HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"), 529 HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"),
663 HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"), 530 HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"),
664 HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"), 531 HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"),
532 HDAPS_DMI_MATCH_NORMAL("ThinkPad R52"),
665 HDAPS_DMI_MATCH_INVERT("ThinkPad T41p"), 533 HDAPS_DMI_MATCH_INVERT("ThinkPad T41p"),
666 HDAPS_DMI_MATCH_NORMAL("ThinkPad T41"), 534 HDAPS_DMI_MATCH_NORMAL("ThinkPad T41"),
667 HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"), 535 HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"),
668 HDAPS_DMI_MATCH_NORMAL("ThinkPad T42"), 536 HDAPS_DMI_MATCH_NORMAL("ThinkPad T42"),
669 HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"), 537 HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"),
670 HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"), 538 HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"),
539 HDAPS_DMI_MATCH_NORMAL("ThinkPad X41 Tablet"),
540 HDAPS_DMI_MATCH_NORMAL("ThinkPad X41"),
671 { .ident = NULL } 541 { .ident = NULL }
672 }; 542 };
673 543
@@ -696,8 +566,18 @@ static int __init hdaps_init(void)
696 if (ret) 566 if (ret)
697 goto out_device; 567 goto out_device;
698 568
699 if (hdaps_mousedev) 569 /* initial calibrate for the input device */
700 hdaps_mousedev_enable(); 570 hdaps_calibrate();
571
572 /* initialize the input class */
573 hdaps_idev.dev = &pdev->dev;
574 input_register_device(&hdaps_idev);
575
576 /* start up our timer for the input device */
577 init_timer(&hdaps_timer);
578 hdaps_timer.function = hdaps_mousedev_poll;
579 hdaps_timer.expires = jiffies + HDAPS_POLL_PERIOD;
580 add_timer(&hdaps_timer);
701 581
702 printk(KERN_INFO "hdaps: driver successfully loaded.\n"); 582 printk(KERN_INFO "hdaps: driver successfully loaded.\n");
703 return 0; 583 return 0;
@@ -715,8 +595,8 @@ out:
715 595
716static void __exit hdaps_exit(void) 596static void __exit hdaps_exit(void)
717{ 597{
718 hdaps_mousedev_disable(); 598 del_timer_sync(&hdaps_timer);
719 599 input_unregister_device(&hdaps_idev);
720 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); 600 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
721 platform_device_unregister(pdev); 601 platform_device_unregister(pdev);
722 driver_unregister(&hdaps_driver); 602 driver_unregister(&hdaps_driver);
@@ -728,9 +608,6 @@ static void __exit hdaps_exit(void)
728module_init(hdaps_init); 608module_init(hdaps_init);
729module_exit(hdaps_exit); 609module_exit(hdaps_exit);
730 610
731module_param_named(mousedev, hdaps_mousedev, bool, 0);
732MODULE_PARM_DESC(mousedev, "enable the input class device");
733
734module_param_named(invert, hdaps_invert, bool, 0); 611module_param_named(invert, hdaps_invert, bool, 0);
735MODULE_PARM_DESC(invert, "invert data along each axis"); 612MODULE_PARM_DESC(invert, "invert data along each axis");
736 613
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 8334496a7e0a..3badfec75b1c 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -245,6 +245,18 @@ config I2C_KEYWEST
245 This support is also available as a module. If so, the module 245 This support is also available as a module. If so, the module
246 will be called i2c-keywest. 246 will be called i2c-keywest.
247 247
248config I2C_PMAC_SMU
249 tristate "Powermac SMU I2C interface"
250 depends on I2C && PMAC_SMU
251 help
252 This supports the use of the I2C interface in the SMU
253 chip on recent Apple machines like the iMac G5. It is used
254 among others by the thermal control driver for those machines.
255 Say Y if you have such a machine.
256
257 This support is also available as a module. If so, the module
258 will be called i2c-pmac-smu.
259
248config I2C_MPC 260config I2C_MPC
249 tristate "MPC107/824x/85xx/52xx" 261 tristate "MPC107/824x/85xx/52xx"
250 depends on I2C && PPC32 262 depends on I2C && PPC32
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 980b3e983670..f1df00f66c6c 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_I2C_ITE) += i2c-ite.o
20obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o 20obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o
21obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o 21obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o
22obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o 22obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o
23obj-$(CONFIG_I2C_PMAC_SMU) += i2c-pmac-smu.o
23obj-$(CONFIG_I2C_MPC) += i2c-mpc.o 24obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
24obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o 25obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o
25obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o 26obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
diff --git a/drivers/i2c/busses/i2c-pmac-smu.c b/drivers/i2c/busses/i2c-pmac-smu.c
new file mode 100644
index 000000000000..8a9f5648a23d
--- /dev/null
+++ b/drivers/i2c/busses/i2c-pmac-smu.c
@@ -0,0 +1,316 @@
1/*
2 i2c Support for Apple SMU Controller
3
4 Copyright (c) 2005 Benjamin Herrenschmidt, IBM Corp.
5 <benh@kernel.crashing.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#include <linux/config.h>
24#include <linux/module.h>
25#include <linux/kernel.h>
26#include <linux/types.h>
27#include <linux/i2c.h>
28#include <linux/init.h>
29#include <linux/completion.h>
30#include <linux/device.h>
31#include <asm/prom.h>
32#include <asm/of_device.h>
33#include <asm/smu.h>
34
35static int probe;
36
37MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
38MODULE_DESCRIPTION("I2C driver for Apple's SMU");
39MODULE_LICENSE("GPL");
40module_param(probe, bool, 0);
41
42
43/* Physical interface */
44struct smu_iface
45{
46 struct i2c_adapter adapter;
47 struct completion complete;
48 u32 busid;
49};
50
51static void smu_i2c_done(struct smu_i2c_cmd *cmd, void *misc)
52{
53 struct smu_iface *iface = misc;
54 complete(&iface->complete);
55}
56
57/*
58 * SMBUS-type transfer entrypoint
59 */
60static s32 smu_smbus_xfer( struct i2c_adapter* adap,
61 u16 addr,
62 unsigned short flags,
63 char read_write,
64 u8 command,
65 int size,
66 union i2c_smbus_data* data)
67{
68 struct smu_iface *iface = i2c_get_adapdata(adap);
69 struct smu_i2c_cmd cmd;
70 int rc = 0;
71 int read = (read_write == I2C_SMBUS_READ);
72
73 cmd.info.bus = iface->busid;
74 cmd.info.devaddr = (addr << 1) | (read ? 0x01 : 0x00);
75
76 /* Prepare datas & select mode */
77 switch (size) {
78 case I2C_SMBUS_QUICK:
79 cmd.info.type = SMU_I2C_TRANSFER_SIMPLE;
80 cmd.info.datalen = 0;
81 break;
82 case I2C_SMBUS_BYTE:
83 cmd.info.type = SMU_I2C_TRANSFER_SIMPLE;
84 cmd.info.datalen = 1;
85 if (!read)
86 cmd.info.data[0] = data->byte;
87 break;
88 case I2C_SMBUS_BYTE_DATA:
89 cmd.info.type = SMU_I2C_TRANSFER_STDSUB;
90 cmd.info.datalen = 1;
91 cmd.info.sublen = 1;
92 cmd.info.subaddr[0] = command;
93 cmd.info.subaddr[1] = 0;
94 cmd.info.subaddr[2] = 0;
95 if (!read)
96 cmd.info.data[0] = data->byte;
97 break;
98 case I2C_SMBUS_WORD_DATA:
99 cmd.info.type = SMU_I2C_TRANSFER_STDSUB;
100 cmd.info.datalen = 2;
101 cmd.info.sublen = 1;
102 cmd.info.subaddr[0] = command;
103 cmd.info.subaddr[1] = 0;
104 cmd.info.subaddr[2] = 0;
105 if (!read) {
106 cmd.info.data[0] = data->byte & 0xff;
107 cmd.info.data[1] = (data->byte >> 8) & 0xff;
108 }
109 break;
110 /* Note that these are broken vs. the expected smbus API where
111 * on reads, the lenght is actually returned from the function,
112 * but I think the current API makes no sense and I don't want
113 * any driver that I haven't verified for correctness to go
114 * anywhere near a pmac i2c bus anyway ...
115 */
116 case I2C_SMBUS_BLOCK_DATA:
117 cmd.info.type = SMU_I2C_TRANSFER_STDSUB;
118 cmd.info.datalen = data->block[0] + 1;
119 if (cmd.info.datalen > 6)
120 return -EINVAL;
121 if (!read)
122 memcpy(cmd.info.data, data->block, cmd.info.datalen);
123 cmd.info.sublen = 1;
124 cmd.info.subaddr[0] = command;
125 cmd.info.subaddr[1] = 0;
126 cmd.info.subaddr[2] = 0;
127 break;
128 case I2C_SMBUS_I2C_BLOCK_DATA:
129 cmd.info.type = SMU_I2C_TRANSFER_STDSUB;
130 cmd.info.datalen = data->block[0];
131 if (cmd.info.datalen > 7)
132 return -EINVAL;
133 if (!read)
134 memcpy(cmd.info.data, &data->block[1],
135 cmd.info.datalen);
136 cmd.info.sublen = 1;
137 cmd.info.subaddr[0] = command;
138 cmd.info.subaddr[1] = 0;
139 cmd.info.subaddr[2] = 0;
140 break;
141
142 default:
143 return -EINVAL;
144 }
145
146 /* Turn a standardsub read into a combined mode access */
147 if (read_write == I2C_SMBUS_READ &&
148 cmd.info.type == SMU_I2C_TRANSFER_STDSUB)
149 cmd.info.type = SMU_I2C_TRANSFER_COMBINED;
150
151 /* Finish filling command and submit it */
152 cmd.done = smu_i2c_done;
153 cmd.misc = iface;
154 rc = smu_queue_i2c(&cmd);
155 if (rc < 0)
156 return rc;
157 wait_for_completion(&iface->complete);
158 rc = cmd.status;
159
160 if (!read || rc < 0)
161 return rc;
162
163 switch (size) {
164 case I2C_SMBUS_BYTE:
165 case I2C_SMBUS_BYTE_DATA:
166 data->byte = cmd.info.data[0];
167 break;
168 case I2C_SMBUS_WORD_DATA:
169 data->word = ((u16)cmd.info.data[1]) << 8;
170 data->word |= cmd.info.data[0];
171 break;
172 /* Note that these are broken vs. the expected smbus API where
173 * on reads, the lenght is actually returned from the function,
174 * but I think the current API makes no sense and I don't want
175 * any driver that I haven't verified for correctness to go
176 * anywhere near a pmac i2c bus anyway ...
177 */
178 case I2C_SMBUS_BLOCK_DATA:
179 case I2C_SMBUS_I2C_BLOCK_DATA:
180 memcpy(&data->block[0], cmd.info.data, cmd.info.datalen);
181 break;
182 }
183
184 return rc;
185}
186
187static u32
188smu_smbus_func(struct i2c_adapter * adapter)
189{
190 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
191 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
192 I2C_FUNC_SMBUS_BLOCK_DATA;
193}
194
195/* For now, we only handle combined mode (smbus) */
196static struct i2c_algorithm smu_algorithm = {
197 .smbus_xfer = smu_smbus_xfer,
198 .functionality = smu_smbus_func,
199};
200
201static int create_iface(struct device_node *np, struct device *dev)
202{
203 struct smu_iface* iface;
204 u32 *reg, busid;
205 int rc;
206
207 reg = (u32 *)get_property(np, "reg", NULL);
208 if (reg == NULL) {
209 printk(KERN_ERR "i2c-pmac-smu: can't find bus number !\n");
210 return -ENXIO;
211 }
212 busid = *reg;
213
214 iface = kmalloc(sizeof(struct smu_iface), GFP_KERNEL);
215 if (iface == NULL) {
216 printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n");
217 return -ENOMEM;
218 }
219 memset(iface, 0, sizeof(struct smu_iface));
220 init_completion(&iface->complete);
221 iface->busid = busid;
222
223 dev_set_drvdata(dev, iface);
224
225 sprintf(iface->adapter.name, "smu-i2c-%02x", busid);
226 iface->adapter.algo = &smu_algorithm;
227 iface->adapter.algo_data = NULL;
228 iface->adapter.client_register = NULL;
229 iface->adapter.client_unregister = NULL;
230 i2c_set_adapdata(&iface->adapter, iface);
231 iface->adapter.dev.parent = dev;
232
233 rc = i2c_add_adapter(&iface->adapter);
234 if (rc) {
235 printk(KERN_ERR "i2c-pamc-smu.c: Adapter %s registration "
236 "failed\n", iface->adapter.name);
237 i2c_set_adapdata(&iface->adapter, NULL);
238 }
239
240 if (probe) {
241 unsigned char addr;
242 printk("Probe: ");
243 for (addr = 0x00; addr <= 0x7f; addr++) {
244 if (i2c_smbus_xfer(&iface->adapter,addr,
245 0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
246 printk("%02x ", addr);
247 }
248 printk("\n");
249 }
250
251 printk(KERN_INFO "SMU i2c bus %x registered\n", busid);
252
253 return 0;
254}
255
256static int dispose_iface(struct device *dev)
257{
258 struct smu_iface *iface = dev_get_drvdata(dev);
259 int rc;
260
261 rc = i2c_del_adapter(&iface->adapter);
262 i2c_set_adapdata(&iface->adapter, NULL);
263 /* We aren't that prepared to deal with this... */
264 if (rc)
265 printk("i2c-pmac-smu.c: Failed to remove bus %s !\n",
266 iface->adapter.name);
267 dev_set_drvdata(dev, NULL);
268 kfree(iface);
269
270 return 0;
271}
272
273
274static int create_iface_of_platform(struct of_device* dev,
275 const struct of_device_id *match)
276{
277 return create_iface(dev->node, &dev->dev);
278}
279
280
281static int dispose_iface_of_platform(struct of_device* dev)
282{
283 return dispose_iface(&dev->dev);
284}
285
286
287static struct of_device_id i2c_smu_match[] =
288{
289 {
290 .compatible = "smu-i2c",
291 },
292 {},
293};
294static struct of_platform_driver i2c_smu_of_platform_driver =
295{
296 .name = "i2c-smu",
297 .match_table = i2c_smu_match,
298 .probe = create_iface_of_platform,
299 .remove = dispose_iface_of_platform
300};
301
302
303static int __init i2c_pmac_smu_init(void)
304{
305 of_register_driver(&i2c_smu_of_platform_driver);
306 return 0;
307}
308
309
310static void __exit i2c_pmac_smu_cleanup(void)
311{
312 of_unregister_driver(&i2c_smu_of_platform_driver);
313}
314
315module_init(i2c_pmac_smu_init);
316module_exit(i2c_pmac_smu_cleanup);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 9e9cf1407311..5275cbb1afe9 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -1101,6 +1101,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1101 ide_hwif_t *hwif; 1101 ide_hwif_t *hwif;
1102 struct request *rq; 1102 struct request *rq;
1103 ide_startstop_t startstop; 1103 ide_startstop_t startstop;
1104 int loops = 0;
1104 1105
1105 /* for atari only: POSSIBLY BROKEN HERE(?) */ 1106 /* for atari only: POSSIBLY BROKEN HERE(?) */
1106 ide_get_lock(ide_intr, hwgroup); 1107 ide_get_lock(ide_intr, hwgroup);
@@ -1153,6 +1154,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1153 /* no more work for this hwgroup (for now) */ 1154 /* no more work for this hwgroup (for now) */
1154 return; 1155 return;
1155 } 1156 }
1157 again:
1156 hwif = HWIF(drive); 1158 hwif = HWIF(drive);
1157 if (hwgroup->hwif->sharing_irq && 1159 if (hwgroup->hwif->sharing_irq &&
1158 hwif != hwgroup->hwif && 1160 hwif != hwgroup->hwif &&
@@ -1192,8 +1194,14 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1192 * though. I hope that doesn't happen too much, hopefully not 1194 * though. I hope that doesn't happen too much, hopefully not
1193 * unless the subdriver triggers such a thing in its own PM 1195 * unless the subdriver triggers such a thing in its own PM
1194 * state machine. 1196 * state machine.
1197 *
1198 * We count how many times we loop here to make sure we service
1199 * all drives in the hwgroup without looping for ever
1195 */ 1200 */
1196 if (drive->blocked && !blk_pm_request(rq) && !(rq->flags & REQ_PREEMPT)) { 1201 if (drive->blocked && !blk_pm_request(rq) && !(rq->flags & REQ_PREEMPT)) {
1202 drive = drive->next ? drive->next : hwgroup->drive;
1203 if (loops++ < 4 && !blk_queue_plugged(drive->queue))
1204 goto again;
1197 /* We clear busy, there should be no pending ATA command at this point. */ 1205 /* We clear busy, there should be no pending ATA command at this point. */
1198 hwgroup->busy = 0; 1206 hwgroup->busy = 0;
1199 break; 1207 break;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index d04f62ab5de1..ace8edad6e96 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -500,6 +500,7 @@ static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long
500 } 500 }
501 501
502 rq.special = args; 502 rq.special = args;
503 args->rq = &rq;
503 return ide_do_drive_cmd(drive, &rq, ide_wait); 504 return ide_do_drive_cmd(drive, &rq, ide_wait);
504} 505}
505 506
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 0ccf85fcee34..a35a58bef1a4 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -477,7 +477,7 @@ static struct pcmcia_device_id ide_ids[] = {
477 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), 477 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149),
478 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDEII", 0x547e66dc, 0xb3662674), 478 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDEII", 0x547e66dc, 0xb3662674),
479 PCMCIA_DEVICE_PROD_ID12("LOOKMEET", "CBIDE2 ", 0xe37be2b5, 0x8671043b), 479 PCMCIA_DEVICE_PROD_ID12("LOOKMEET", "CBIDE2 ", 0xe37be2b5, 0x8671043b),
480 PCMCIA_DEVICE_PROD_ID12(" ", "NinjaATA-", 0x3b6e20c8, 0xebe0bd79), 480 PCMCIA_DEVICE_PROD_ID2("NinjaATA-", 0xebe0bd79),
481 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "CD-ROM", 0x281f1c5d, 0x66536591), 481 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "CD-ROM", 0x281f1c5d, 0x66536591),
482 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "PnPIDE", 0x281f1c5d, 0x0c694728), 482 PCMCIA_DEVICE_PROD_ID12("PCMCIA", "PnPIDE", 0x281f1c5d, 0x0c694728),
483 PCMCIA_DEVICE_PROD_ID12("SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", 0x4a3f0ba0, 0x322560e1), 483 PCMCIA_DEVICE_PROD_ID12("SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", 0x4a3f0ba0, 0x322560e1),
diff --git a/drivers/ieee1394/amdtp.c b/drivers/ieee1394/amdtp.c
index 84ae027b021a..e8e28569a668 100644
--- a/drivers/ieee1394/amdtp.c
+++ b/drivers/ieee1394/amdtp.c
@@ -1297,4 +1297,3 @@ static void __exit amdtp_exit_module (void)
1297 1297
1298module_init(amdtp_init_module); 1298module_init(amdtp_init_module);
1299module_exit(amdtp_exit_module); 1299module_exit(amdtp_exit_module);
1300MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16);
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h
index e6734263a1d3..28c5f4b726e2 100644
--- a/drivers/ieee1394/csr1212.h
+++ b/drivers/ieee1394/csr1212.h
@@ -37,7 +37,6 @@
37#include <linux/types.h> 37#include <linux/types.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/sched.h>
41#include <linux/vmalloc.h> 40#include <linux/vmalloc.h>
42#include <asm/pgalloc.h> 41#include <asm/pgalloc.h>
43 42
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 4538b0235ca3..e34730c7a874 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2660,4 +2660,3 @@ static int __init dv1394_init_module(void)
2660 2660
2661module_init(dv1394_init_module); 2661module_init(dv1394_init_module);
2662module_exit(dv1394_exit_module); 2662module_exit(dv1394_exit_module);
2663MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16);
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index cd53c174ced1..4802bbbb6dc9 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -89,7 +89,7 @@
89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__) 89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
90 90
91static char version[] __devinitdata = 91static char version[] __devinitdata =
92 "$Rev: 1264 $ Ben Collins <bcollins@debian.org>"; 92 "$Rev: 1312 $ Ben Collins <bcollins@debian.org>";
93 93
94struct fragment_info { 94struct fragment_info {
95 struct list_head list; 95 struct list_head list;
@@ -221,9 +221,7 @@ static int ether1394_open (struct net_device *dev)
221 if (priv->bc_state == ETHER1394_BC_ERROR) { 221 if (priv->bc_state == ETHER1394_BC_ERROR) {
222 /* we'll try again */ 222 /* we'll try again */
223 priv->iso = hpsb_iso_recv_init(priv->host, 223 priv->iso = hpsb_iso_recv_init(priv->host,
224 ETHER1394_GASP_BUFFERS * 2 * 224 ETHER1394_ISO_BUF_SIZE,
225 (1 << (priv->host->csr.max_rec +
226 1)),
227 ETHER1394_GASP_BUFFERS, 225 ETHER1394_GASP_BUFFERS,
228 priv->broadcast_channel, 226 priv->broadcast_channel,
229 HPSB_ISO_DMA_PACKET_PER_BUFFER, 227 HPSB_ISO_DMA_PACKET_PER_BUFFER,
@@ -635,8 +633,8 @@ static void ether1394_add_host (struct hpsb_host *host)
635 * be checked when the eth device is opened. */ 633 * be checked when the eth device is opened. */
636 priv->broadcast_channel = host->csr.broadcast_channel & 0x3f; 634 priv->broadcast_channel = host->csr.broadcast_channel & 0x3f;
637 635
638 priv->iso = hpsb_iso_recv_init(host, (ETHER1394_GASP_BUFFERS * 2 * 636 priv->iso = hpsb_iso_recv_init(host,
639 (1 << (host->csr.max_rec + 1))), 637 ETHER1394_ISO_BUF_SIZE,
640 ETHER1394_GASP_BUFFERS, 638 ETHER1394_GASP_BUFFERS,
641 priv->broadcast_channel, 639 priv->broadcast_channel,
642 HPSB_ISO_DMA_PACKET_PER_BUFFER, 640 HPSB_ISO_DMA_PACKET_PER_BUFFER,
@@ -1770,7 +1768,7 @@ fail:
1770static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1768static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1771{ 1769{
1772 strcpy (info->driver, driver_name); 1770 strcpy (info->driver, driver_name);
1773 strcpy (info->version, "$Rev: 1264 $"); 1771 strcpy (info->version, "$Rev: 1312 $");
1774 /* FIXME XXX provide sane businfo */ 1772 /* FIXME XXX provide sane businfo */
1775 strcpy (info->bus_info, "ieee1394"); 1773 strcpy (info->bus_info, "ieee1394");
1776} 1774}
diff --git a/drivers/ieee1394/eth1394.h b/drivers/ieee1394/eth1394.h
index ed8f1c4b7fd8..a77213cfc483 100644
--- a/drivers/ieee1394/eth1394.h
+++ b/drivers/ieee1394/eth1394.h
@@ -44,6 +44,12 @@
44 44
45#define ETHER1394_GASP_BUFFERS 16 45#define ETHER1394_GASP_BUFFERS 16
46 46
47/* rawiso buffer size - due to a limitation in rawiso, we must limit each
48 * GASP buffer to be less than PAGE_SIZE. */
49#define ETHER1394_ISO_BUF_SIZE ETHER1394_GASP_BUFFERS * \
50 min((unsigned int)PAGE_SIZE, \
51 2 * (1U << (priv->host->csr.max_rec + 1)))
52
47/* Node set == 64 */ 53/* Node set == 64 */
48#define NODE_SET (ALL_NODES + 1) 54#define NODE_SET (ALL_NODES + 1)
49 55
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index c502c6e9c440..aeeaeb670d03 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -18,6 +18,7 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/timer.h> 20#include <linux/timer.h>
21#include <linux/jiffies.h>
21 22
22#include "csr1212.h" 23#include "csr1212.h"
23#include "ieee1394.h" 24#include "ieee1394.h"
@@ -217,7 +218,7 @@ int hpsb_update_config_rom_image(struct hpsb_host *host)
217 218
218 /* IEEE 1394a-2000 prohibits using the same generation number 219 /* IEEE 1394a-2000 prohibits using the same generation number
219 * twice in a 60 second period. */ 220 * twice in a 60 second period. */
220 if (jiffies - host->csr.gen_timestamp[next_gen] < 60 * HZ) 221 if (time_before(jiffies, host->csr.gen_timestamp[next_gen] + 60 * HZ))
221 /* Wait 60 seconds from the last time this generation number was 222 /* Wait 60 seconds from the last time this generation number was
222 * used. */ 223 * used. */
223 reset_delay = (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies; 224 reset_delay = (60 * HZ) + host->csr.gen_timestamp[next_gen] - jiffies;
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index 739e76840d51..38f42112dff0 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -135,17 +135,17 @@ enum isoctl_cmd {
135 135
136enum reset_types { 136enum reset_types {
137 /* 166 microsecond reset -- only type of reset available on 137 /* 166 microsecond reset -- only type of reset available on
138 non-1394a capable IEEE 1394 controllers */ 138 non-1394a capable controllers */
139 LONG_RESET, 139 LONG_RESET,
140 140
141 /* Short (arbitrated) reset -- only available on 1394a capable 141 /* Short (arbitrated) reset -- only available on 1394a capable
142 IEEE 1394 capable controllers */ 142 controllers */
143 SHORT_RESET, 143 SHORT_RESET,
144 144
145 /* Variants, that set force_root before issueing the bus reset */ 145 /* Variants that set force_root before issueing the bus reset */
146 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT, 146 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
147 147
148 /* Variants, that clear force_root before issueing the bus reset */ 148 /* Variants that clear force_root before issueing the bus reset */
149 LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT 149 LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
150}; 150};
151 151
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index d633770fac8e..32a1e016c85e 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -70,7 +70,7 @@ const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S32
70struct class *hpsb_protocol_class; 70struct class *hpsb_protocol_class;
71 71
72#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 72#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
73static void dump_packet(const char *text, quadlet_t *data, int size) 73static void dump_packet(const char *text, quadlet_t *data, int size, int speed)
74{ 74{
75 int i; 75 int i;
76 76
@@ -78,12 +78,15 @@ static void dump_packet(const char *text, quadlet_t *data, int size)
78 size = (size > 4 ? 4 : size); 78 size = (size > 4 ? 4 : size);
79 79
80 printk(KERN_DEBUG "ieee1394: %s", text); 80 printk(KERN_DEBUG "ieee1394: %s", text);
81 if (speed > -1 && speed < 6)
82 printk(" at %s", hpsb_speedto_str[speed]);
83 printk(":");
81 for (i = 0; i < size; i++) 84 for (i = 0; i < size; i++)
82 printk(" %08x", data[i]); 85 printk(" %08x", data[i]);
83 printk("\n"); 86 printk("\n");
84} 87}
85#else 88#else
86#define dump_packet(x,y,z) 89#define dump_packet(a,b,c,d)
87#endif 90#endif
88 91
89static void abort_requests(struct hpsb_host *host); 92static void abort_requests(struct hpsb_host *host);
@@ -544,8 +547,7 @@ int hpsb_send_packet(struct hpsb_packet *packet)
544 if (packet->data_size) 547 if (packet->data_size)
545 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size); 548 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
546 549
547 dump_packet("send packet local:", packet->header, 550 dump_packet("send packet local", packet->header, packet->header_size, -1);
548 packet->header_size);
549 551
550 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE); 552 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
551 hpsb_packet_received(host, data, size, 0); 553 hpsb_packet_received(host, data, size, 0);
@@ -561,21 +563,7 @@ int hpsb_send_packet(struct hpsb_packet *packet)
561 + NODEID_TO_NODE(packet->node_id)]; 563 + NODEID_TO_NODE(packet->node_id)];
562 } 564 }
563 565
564#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 566 dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
565 switch (packet->speed_code) {
566 case 2:
567 dump_packet("send packet 400:", packet->header,
568 packet->header_size);
569 break;
570 case 1:
571 dump_packet("send packet 200:", packet->header,
572 packet->header_size);
573 break;
574 default:
575 dump_packet("send packet 100:", packet->header,
576 packet->header_size);
577 }
578#endif
579 567
580 return host->driver->transmit_packet(host, packet); 568 return host->driver->transmit_packet(host, packet);
581} 569}
@@ -636,7 +624,7 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
636 624
637 if (packet == NULL) { 625 if (packet == NULL) {
638 HPSB_DEBUG("unsolicited response packet received - no tlabel match"); 626 HPSB_DEBUG("unsolicited response packet received - no tlabel match");
639 dump_packet("contents:", data, 16); 627 dump_packet("contents", data, 16, -1);
640 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); 628 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
641 return; 629 return;
642 } 630 }
@@ -677,7 +665,7 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
677 if (!tcode_match) { 665 if (!tcode_match) {
678 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); 666 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
679 HPSB_INFO("unsolicited response packet received - tcode mismatch"); 667 HPSB_INFO("unsolicited response packet received - tcode mismatch");
680 dump_packet("contents:", data, 16); 668 dump_packet("contents", data, 16, -1);
681 return; 669 return;
682 } 670 }
683 671
@@ -914,7 +902,7 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
914 return; 902 return;
915 } 903 }
916 904
917 dump_packet("received packet:", data, size); 905 dump_packet("received packet", data, size, -1);
918 906
919 tcode = (data[0] >> 4) & 0xf; 907 tcode = (data[0] >> 4) & 0xf;
920 908
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index b23322523ef5..347ece6b583c 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -64,10 +64,10 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
64 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci; 64 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci;
65 int i, ret = 0; 65 int i, ret = 0;
66 66
67 for (i = 0; i < 3; i++) { 67 for (i = 1; ; i++) {
68 ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 68 ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
69 buffer, length); 69 buffer, length);
70 if (!ret) 70 if (!ret || i == 3)
71 break; 71 break;
72 72
73 if (msleep_interruptible(334)) 73 if (msleep_interruptible(334))
@@ -1438,9 +1438,13 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1438 if (host->busmgr_id == 0xffff && host->node_count > 1) 1438 if (host->busmgr_id == 0xffff && host->node_count > 1)
1439 { 1439 {
1440 u16 root_node = host->node_count - 1; 1440 u16 root_node = host->node_count - 1;
1441 struct node_entry *ne = find_entry_by_nodeid(host, root_node | LOCAL_BUS);
1442 1441
1443 if (ne && ne->busopt.cmc) 1442 /* get cycle master capability flag from root node */
1443 if (host->is_cycmst ||
1444 (!hpsb_read(host, LOCAL_BUS | root_node, get_hpsb_generation(host),
1445 (CSR_REGISTER_BASE + CSR_CONFIG_ROM + 2 * sizeof(quadlet_t)),
1446 &bc, sizeof(quadlet_t)) &&
1447 be32_to_cpu(bc) & 1 << CSR_CMC_SHIFT))
1444 hpsb_send_phy_config(host, root_node, -1); 1448 hpsb_send_phy_config(host, root_node, -1);
1445 else { 1449 else {
1446 HPSB_DEBUG("The root node is not cycle master capable; " 1450 HPSB_DEBUG("The root node is not cycle master capable; "
@@ -1557,24 +1561,19 @@ static int nodemgr_host_thread(void *__hi)
1557 } 1561 }
1558 } 1562 }
1559 1563
1560 if (!nodemgr_check_irm_capability(host, reset_cycles)) { 1564 if (!nodemgr_check_irm_capability(host, reset_cycles) ||
1565 !nodemgr_do_irm_duties(host, reset_cycles)) {
1561 reset_cycles++; 1566 reset_cycles++;
1562 up(&nodemgr_serialize); 1567 up(&nodemgr_serialize);
1563 continue; 1568 continue;
1564 } 1569 }
1570 reset_cycles = 0;
1565 1571
1566 /* Scan our nodes to get the bus options and create node 1572 /* Scan our nodes to get the bus options and create node
1567 * entries. This does not do the sysfs stuff, since that 1573 * entries. This does not do the sysfs stuff, since that
1568 * would trigger hotplug callbacks and such, which is a 1574 * would trigger hotplug callbacks and such, which is a
1569 * bad idea at this point. */ 1575 * bad idea at this point. */
1570 nodemgr_node_scan(hi, generation); 1576 nodemgr_node_scan(hi, generation);
1571 if (!nodemgr_do_irm_duties(host, reset_cycles)) {
1572 reset_cycles++;
1573 up(&nodemgr_serialize);
1574 continue;
1575 }
1576
1577 reset_cycles = 0;
1578 1577
1579 /* This actually does the full probe, with sysfs 1578 /* This actually does the full probe, with sysfs
1580 * registration. */ 1579 * registration. */
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 27018c8efc24..4cf9b8f3e336 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -162,7 +162,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
162printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args) 162printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
163 163
164static char version[] __devinitdata = 164static char version[] __devinitdata =
165 "$Rev: 1299 $ Ben Collins <bcollins@debian.org>"; 165 "$Rev: 1313 $ Ben Collins <bcollins@debian.org>";
166 166
167/* Module Parameters */ 167/* Module Parameters */
168static int phys_dma = 1; 168static int phys_dma = 1;
@@ -1084,7 +1084,7 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1084 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1); 1084 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
1085 1085
1086 if (printk_ratelimit()) 1086 if (printk_ratelimit())
1087 PRINT(KERN_ERR, "IR legacy activated"); 1087 DBGMSG("IR legacy activated");
1088 } 1088 }
1089 1089
1090 spin_lock_irqsave(&ohci->IR_channel_lock, flags); 1090 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
@@ -2283,8 +2283,9 @@ static void ohci_schedule_iso_tasklets(struct ti_ohci *ohci,
2283{ 2283{
2284 struct ohci1394_iso_tasklet *t; 2284 struct ohci1394_iso_tasklet *t;
2285 unsigned long mask; 2285 unsigned long mask;
2286 unsigned long flags;
2286 2287
2287 spin_lock(&ohci->iso_tasklet_list_lock); 2288 spin_lock_irqsave(&ohci->iso_tasklet_list_lock, flags);
2288 2289
2289 list_for_each_entry(t, &ohci->iso_tasklet_list, link) { 2290 list_for_each_entry(t, &ohci->iso_tasklet_list, link) {
2290 mask = 1 << t->context; 2291 mask = 1 << t->context;
@@ -2295,8 +2296,7 @@ static void ohci_schedule_iso_tasklets(struct ti_ohci *ohci,
2295 tasklet_schedule(&t->tasklet); 2296 tasklet_schedule(&t->tasklet);
2296 } 2297 }
2297 2298
2298 spin_unlock(&ohci->iso_tasklet_list_lock); 2299 spin_unlock_irqrestore(&ohci->iso_tasklet_list_lock, flags);
2299
2300} 2300}
2301 2301
2302static irqreturn_t ohci_irq_handler(int irq, void *dev_id, 2302static irqreturn_t ohci_irq_handler(int irq, void *dev_id,
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index b4fa14793fe5..0470f77a9cd1 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -98,7 +98,7 @@ static struct hpsb_address_ops arm_ops = {
98 98
99static void queue_complete_cb(struct pending_request *req); 99static void queue_complete_cb(struct pending_request *req);
100 100
101static struct pending_request *__alloc_pending_request(unsigned int __nocast flags) 101static struct pending_request *__alloc_pending_request(gfp_t flags)
102{ 102{
103 struct pending_request *req; 103 struct pending_request *req;
104 104
@@ -412,6 +412,7 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
412static ssize_t raw1394_read(struct file *file, char __user * buffer, 412static ssize_t raw1394_read(struct file *file, char __user * buffer,
413 size_t count, loff_t * offset_is_ignored) 413 size_t count, loff_t * offset_is_ignored)
414{ 414{
415 unsigned long flags;
415 struct file_info *fi = (struct file_info *)file->private_data; 416 struct file_info *fi = (struct file_info *)file->private_data;
416 struct list_head *lh; 417 struct list_head *lh;
417 struct pending_request *req; 418 struct pending_request *req;
@@ -435,10 +436,10 @@ static ssize_t raw1394_read(struct file *file, char __user * buffer,
435 } 436 }
436 } 437 }
437 438
438 spin_lock_irq(&fi->reqlists_lock); 439 spin_lock_irqsave(&fi->reqlists_lock, flags);
439 lh = fi->req_complete.next; 440 lh = fi->req_complete.next;
440 list_del(lh); 441 list_del(lh);
441 spin_unlock_irq(&fi->reqlists_lock); 442 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
442 443
443 req = list_entry(lh, struct pending_request, list); 444 req = list_entry(lh, struct pending_request, list);
444 445
@@ -486,6 +487,7 @@ static int state_opened(struct file_info *fi, struct pending_request *req)
486 487
487static int state_initialized(struct file_info *fi, struct pending_request *req) 488static int state_initialized(struct file_info *fi, struct pending_request *req)
488{ 489{
490 unsigned long flags;
489 struct host_info *hi; 491 struct host_info *hi;
490 struct raw1394_khost_list *khl; 492 struct raw1394_khost_list *khl;
491 493
@@ -499,7 +501,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
499 501
500 switch (req->req.type) { 502 switch (req->req.type) {
501 case RAW1394_REQ_LIST_CARDS: 503 case RAW1394_REQ_LIST_CARDS:
502 spin_lock_irq(&host_info_lock); 504 spin_lock_irqsave(&host_info_lock, flags);
503 khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count, 505 khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count,
504 SLAB_ATOMIC); 506 SLAB_ATOMIC);
505 507
@@ -513,7 +515,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
513 khl++; 515 khl++;
514 } 516 }
515 } 517 }
516 spin_unlock_irq(&host_info_lock); 518 spin_unlock_irqrestore(&host_info_lock, flags);
517 519
518 if (khl != NULL) { 520 if (khl != NULL) {
519 req->req.error = RAW1394_ERROR_NONE; 521 req->req.error = RAW1394_ERROR_NONE;
@@ -528,7 +530,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
528 break; 530 break;
529 531
530 case RAW1394_REQ_SET_CARD: 532 case RAW1394_REQ_SET_CARD:
531 spin_lock_irq(&host_info_lock); 533 spin_lock_irqsave(&host_info_lock, flags);
532 if (req->req.misc < host_count) { 534 if (req->req.misc < host_count) {
533 list_for_each_entry(hi, &host_info_list, list) { 535 list_for_each_entry(hi, &host_info_list, list) {
534 if (!req->req.misc--) 536 if (!req->req.misc--)
@@ -550,7 +552,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
550 } else { 552 } else {
551 req->req.error = RAW1394_ERROR_INVALID_ARG; 553 req->req.error = RAW1394_ERROR_INVALID_ARG;
552 } 554 }
553 spin_unlock_irq(&host_info_lock); 555 spin_unlock_irqrestore(&host_info_lock, flags);
554 556
555 req->req.length = 0; 557 req->req.length = 0;
556 break; 558 break;
@@ -569,7 +571,6 @@ static void handle_iso_listen(struct file_info *fi, struct pending_request *req)
569{ 571{
570 int channel = req->req.misc; 572 int channel = req->req.misc;
571 573
572 spin_lock_irq(&host_info_lock);
573 if ((channel > 63) || (channel < -64)) { 574 if ((channel > 63) || (channel < -64)) {
574 req->req.error = RAW1394_ERROR_INVALID_ARG; 575 req->req.error = RAW1394_ERROR_INVALID_ARG;
575 } else if (channel >= 0) { 576 } else if (channel >= 0) {
@@ -601,7 +602,6 @@ static void handle_iso_listen(struct file_info *fi, struct pending_request *req)
601 602
602 req->req.length = 0; 603 req->req.length = 0;
603 queue_complete_req(req); 604 queue_complete_req(req);
604 spin_unlock_irq(&host_info_lock);
605} 605}
606 606
607static void handle_fcp_listen(struct file_info *fi, struct pending_request *req) 607static void handle_fcp_listen(struct file_info *fi, struct pending_request *req)
@@ -627,6 +627,7 @@ static void handle_fcp_listen(struct file_info *fi, struct pending_request *req)
627static int handle_async_request(struct file_info *fi, 627static int handle_async_request(struct file_info *fi,
628 struct pending_request *req, int node) 628 struct pending_request *req, int node)
629{ 629{
630 unsigned long flags;
630 struct hpsb_packet *packet = NULL; 631 struct hpsb_packet *packet = NULL;
631 u64 addr = req->req.address & 0xffffffffffffULL; 632 u64 addr = req->req.address & 0xffffffffffffULL;
632 633
@@ -761,9 +762,9 @@ static int handle_async_request(struct file_info *fi,
761 hpsb_set_packet_complete_task(packet, 762 hpsb_set_packet_complete_task(packet,
762 (void (*)(void *))queue_complete_cb, req); 763 (void (*)(void *))queue_complete_cb, req);
763 764
764 spin_lock_irq(&fi->reqlists_lock); 765 spin_lock_irqsave(&fi->reqlists_lock, flags);
765 list_add_tail(&req->list, &fi->req_pending); 766 list_add_tail(&req->list, &fi->req_pending);
766 spin_unlock_irq(&fi->reqlists_lock); 767 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
767 768
768 packet->generation = req->req.generation; 769 packet->generation = req->req.generation;
769 770
@@ -779,6 +780,7 @@ static int handle_async_request(struct file_info *fi,
779static int handle_iso_send(struct file_info *fi, struct pending_request *req, 780static int handle_iso_send(struct file_info *fi, struct pending_request *req,
780 int channel) 781 int channel)
781{ 782{
783 unsigned long flags;
782 struct hpsb_packet *packet; 784 struct hpsb_packet *packet;
783 785
784 packet = hpsb_make_isopacket(fi->host, req->req.length, channel & 0x3f, 786 packet = hpsb_make_isopacket(fi->host, req->req.length, channel & 0x3f,
@@ -804,9 +806,9 @@ static int handle_iso_send(struct file_info *fi, struct pending_request *req,
804 (void (*)(void *))queue_complete_req, 806 (void (*)(void *))queue_complete_req,
805 req); 807 req);
806 808
807 spin_lock_irq(&fi->reqlists_lock); 809 spin_lock_irqsave(&fi->reqlists_lock, flags);
808 list_add_tail(&req->list, &fi->req_pending); 810 list_add_tail(&req->list, &fi->req_pending);
809 spin_unlock_irq(&fi->reqlists_lock); 811 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
810 812
811 /* Update the generation of the packet just before sending. */ 813 /* Update the generation of the packet just before sending. */
812 packet->generation = req->req.generation; 814 packet->generation = req->req.generation;
@@ -821,6 +823,7 @@ static int handle_iso_send(struct file_info *fi, struct pending_request *req,
821 823
822static int handle_async_send(struct file_info *fi, struct pending_request *req) 824static int handle_async_send(struct file_info *fi, struct pending_request *req)
823{ 825{
826 unsigned long flags;
824 struct hpsb_packet *packet; 827 struct hpsb_packet *packet;
825 int header_length = req->req.misc & 0xffff; 828 int header_length = req->req.misc & 0xffff;
826 int expect_response = req->req.misc >> 16; 829 int expect_response = req->req.misc >> 16;
@@ -867,9 +870,9 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
867 hpsb_set_packet_complete_task(packet, 870 hpsb_set_packet_complete_task(packet,
868 (void (*)(void *))queue_complete_cb, req); 871 (void (*)(void *))queue_complete_cb, req);
869 872
870 spin_lock_irq(&fi->reqlists_lock); 873 spin_lock_irqsave(&fi->reqlists_lock, flags);
871 list_add_tail(&req->list, &fi->req_pending); 874 list_add_tail(&req->list, &fi->req_pending);
872 spin_unlock_irq(&fi->reqlists_lock); 875 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
873 876
874 /* Update the generation of the packet just before sending. */ 877 /* Update the generation of the packet just before sending. */
875 packet->generation = req->req.generation; 878 packet->generation = req->req.generation;
@@ -885,6 +888,7 @@ static int handle_async_send(struct file_info *fi, struct pending_request *req)
885static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer, 888static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
886 u64 addr, size_t length, u16 flags) 889 u64 addr, size_t length, u16 flags)
887{ 890{
891 unsigned long irqflags;
888 struct pending_request *req; 892 struct pending_request *req;
889 struct host_info *hi; 893 struct host_info *hi;
890 struct file_info *fi = NULL; 894 struct file_info *fi = NULL;
@@ -899,7 +903,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
899 "addr: %4.4x %8.8x length: %Zu", nodeid, 903 "addr: %4.4x %8.8x length: %Zu", nodeid,
900 (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF), 904 (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
901 length); 905 length);
902 spin_lock(&host_info_lock); 906 spin_lock_irqsave(&host_info_lock, irqflags);
903 hi = find_host_info(host); /* search address-entry */ 907 hi = find_host_info(host); /* search address-entry */
904 if (hi != NULL) { 908 if (hi != NULL) {
905 list_for_each_entry(fi, &hi->file_info_list, list) { 909 list_for_each_entry(fi, &hi->file_info_list, list) {
@@ -924,7 +928,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
924 if (!found) { 928 if (!found) {
925 printk(KERN_ERR "raw1394: arm_read FAILED addr_entry not found" 929 printk(KERN_ERR "raw1394: arm_read FAILED addr_entry not found"
926 " -> rcode_address_error\n"); 930 " -> rcode_address_error\n");
927 spin_unlock(&host_info_lock); 931 spin_unlock_irqrestore(&host_info_lock, irqflags);
928 return (RCODE_ADDRESS_ERROR); 932 return (RCODE_ADDRESS_ERROR);
929 } else { 933 } else {
930 DBGMSG("arm_read addr_entry FOUND"); 934 DBGMSG("arm_read addr_entry FOUND");
@@ -954,7 +958,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
954 req = __alloc_pending_request(SLAB_ATOMIC); 958 req = __alloc_pending_request(SLAB_ATOMIC);
955 if (!req) { 959 if (!req) {
956 DBGMSG("arm_read -> rcode_conflict_error"); 960 DBGMSG("arm_read -> rcode_conflict_error");
957 spin_unlock(&host_info_lock); 961 spin_unlock_irqrestore(&host_info_lock, irqflags);
958 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 962 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
959 The request may be retried */ 963 The request may be retried */
960 } 964 }
@@ -974,7 +978,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
974 if (!(req->data)) { 978 if (!(req->data)) {
975 free_pending_request(req); 979 free_pending_request(req);
976 DBGMSG("arm_read -> rcode_conflict_error"); 980 DBGMSG("arm_read -> rcode_conflict_error");
977 spin_unlock(&host_info_lock); 981 spin_unlock_irqrestore(&host_info_lock, irqflags);
978 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 982 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
979 The request may be retried */ 983 The request may be retried */
980 } 984 }
@@ -1031,13 +1035,14 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1031 sizeof(struct arm_request)); 1035 sizeof(struct arm_request));
1032 queue_complete_req(req); 1036 queue_complete_req(req);
1033 } 1037 }
1034 spin_unlock(&host_info_lock); 1038 spin_unlock_irqrestore(&host_info_lock, irqflags);
1035 return (rcode); 1039 return (rcode);
1036} 1040}
1037 1041
1038static int arm_write(struct hpsb_host *host, int nodeid, int destid, 1042static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1039 quadlet_t * data, u64 addr, size_t length, u16 flags) 1043 quadlet_t * data, u64 addr, size_t length, u16 flags)
1040{ 1044{
1045 unsigned long irqflags;
1041 struct pending_request *req; 1046 struct pending_request *req;
1042 struct host_info *hi; 1047 struct host_info *hi;
1043 struct file_info *fi = NULL; 1048 struct file_info *fi = NULL;
@@ -1052,7 +1057,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1052 "addr: %4.4x %8.8x length: %Zu", nodeid, 1057 "addr: %4.4x %8.8x length: %Zu", nodeid,
1053 (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF), 1058 (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF),
1054 length); 1059 length);
1055 spin_lock(&host_info_lock); 1060 spin_lock_irqsave(&host_info_lock, irqflags);
1056 hi = find_host_info(host); /* search address-entry */ 1061 hi = find_host_info(host); /* search address-entry */
1057 if (hi != NULL) { 1062 if (hi != NULL) {
1058 list_for_each_entry(fi, &hi->file_info_list, list) { 1063 list_for_each_entry(fi, &hi->file_info_list, list) {
@@ -1077,7 +1082,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1077 if (!found) { 1082 if (!found) {
1078 printk(KERN_ERR "raw1394: arm_write FAILED addr_entry not found" 1083 printk(KERN_ERR "raw1394: arm_write FAILED addr_entry not found"
1079 " -> rcode_address_error\n"); 1084 " -> rcode_address_error\n");
1080 spin_unlock(&host_info_lock); 1085 spin_unlock_irqrestore(&host_info_lock, irqflags);
1081 return (RCODE_ADDRESS_ERROR); 1086 return (RCODE_ADDRESS_ERROR);
1082 } else { 1087 } else {
1083 DBGMSG("arm_write addr_entry FOUND"); 1088 DBGMSG("arm_write addr_entry FOUND");
@@ -1106,7 +1111,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1106 req = __alloc_pending_request(SLAB_ATOMIC); 1111 req = __alloc_pending_request(SLAB_ATOMIC);
1107 if (!req) { 1112 if (!req) {
1108 DBGMSG("arm_write -> rcode_conflict_error"); 1113 DBGMSG("arm_write -> rcode_conflict_error");
1109 spin_unlock(&host_info_lock); 1114 spin_unlock_irqrestore(&host_info_lock, irqflags);
1110 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 1115 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
1111 The request my be retried */ 1116 The request my be retried */
1112 } 1117 }
@@ -1118,7 +1123,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1118 if (!(req->data)) { 1123 if (!(req->data)) {
1119 free_pending_request(req); 1124 free_pending_request(req);
1120 DBGMSG("arm_write -> rcode_conflict_error"); 1125 DBGMSG("arm_write -> rcode_conflict_error");
1121 spin_unlock(&host_info_lock); 1126 spin_unlock_irqrestore(&host_info_lock, irqflags);
1122 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 1127 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
1123 The request may be retried */ 1128 The request may be retried */
1124 } 1129 }
@@ -1165,7 +1170,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1165 sizeof(struct arm_request)); 1170 sizeof(struct arm_request));
1166 queue_complete_req(req); 1171 queue_complete_req(req);
1167 } 1172 }
1168 spin_unlock(&host_info_lock); 1173 spin_unlock_irqrestore(&host_info_lock, irqflags);
1169 return (rcode); 1174 return (rcode);
1170} 1175}
1171 1176
@@ -1173,6 +1178,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1173 u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, 1178 u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode,
1174 u16 flags) 1179 u16 flags)
1175{ 1180{
1181 unsigned long irqflags;
1176 struct pending_request *req; 1182 struct pending_request *req;
1177 struct host_info *hi; 1183 struct host_info *hi;
1178 struct file_info *fi = NULL; 1184 struct file_info *fi = NULL;
@@ -1198,7 +1204,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1198 (u32) (addr & 0xFFFFFFFF), ext_tcode & 0xFF, 1204 (u32) (addr & 0xFFFFFFFF), ext_tcode & 0xFF,
1199 be32_to_cpu(data), be32_to_cpu(arg)); 1205 be32_to_cpu(data), be32_to_cpu(arg));
1200 } 1206 }
1201 spin_lock(&host_info_lock); 1207 spin_lock_irqsave(&host_info_lock, irqflags);
1202 hi = find_host_info(host); /* search address-entry */ 1208 hi = find_host_info(host); /* search address-entry */
1203 if (hi != NULL) { 1209 if (hi != NULL) {
1204 list_for_each_entry(fi, &hi->file_info_list, list) { 1210 list_for_each_entry(fi, &hi->file_info_list, list) {
@@ -1224,7 +1230,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1224 if (!found) { 1230 if (!found) {
1225 printk(KERN_ERR "raw1394: arm_lock FAILED addr_entry not found" 1231 printk(KERN_ERR "raw1394: arm_lock FAILED addr_entry not found"
1226 " -> rcode_address_error\n"); 1232 " -> rcode_address_error\n");
1227 spin_unlock(&host_info_lock); 1233 spin_unlock_irqrestore(&host_info_lock, irqflags);
1228 return (RCODE_ADDRESS_ERROR); 1234 return (RCODE_ADDRESS_ERROR);
1229 } else { 1235 } else {
1230 DBGMSG("arm_lock addr_entry FOUND"); 1236 DBGMSG("arm_lock addr_entry FOUND");
@@ -1307,7 +1313,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1307 req = __alloc_pending_request(SLAB_ATOMIC); 1313 req = __alloc_pending_request(SLAB_ATOMIC);
1308 if (!req) { 1314 if (!req) {
1309 DBGMSG("arm_lock -> rcode_conflict_error"); 1315 DBGMSG("arm_lock -> rcode_conflict_error");
1310 spin_unlock(&host_info_lock); 1316 spin_unlock_irqrestore(&host_info_lock, irqflags);
1311 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 1317 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
1312 The request may be retried */ 1318 The request may be retried */
1313 } 1319 }
@@ -1316,7 +1322,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1316 if (!(req->data)) { 1322 if (!(req->data)) {
1317 free_pending_request(req); 1323 free_pending_request(req);
1318 DBGMSG("arm_lock -> rcode_conflict_error"); 1324 DBGMSG("arm_lock -> rcode_conflict_error");
1319 spin_unlock(&host_info_lock); 1325 spin_unlock_irqrestore(&host_info_lock, irqflags);
1320 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 1326 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
1321 The request may be retried */ 1327 The request may be retried */
1322 } 1328 }
@@ -1382,7 +1388,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1382 sizeof(struct arm_response) + 2 * sizeof(*store)); 1388 sizeof(struct arm_response) + 2 * sizeof(*store));
1383 queue_complete_req(req); 1389 queue_complete_req(req);
1384 } 1390 }
1385 spin_unlock(&host_info_lock); 1391 spin_unlock_irqrestore(&host_info_lock, irqflags);
1386 return (rcode); 1392 return (rcode);
1387} 1393}
1388 1394
@@ -1390,6 +1396,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1390 u64 addr, octlet_t data, octlet_t arg, int ext_tcode, 1396 u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
1391 u16 flags) 1397 u16 flags)
1392{ 1398{
1399 unsigned long irqflags;
1393 struct pending_request *req; 1400 struct pending_request *req;
1394 struct host_info *hi; 1401 struct host_info *hi;
1395 struct file_info *fi = NULL; 1402 struct file_info *fi = NULL;
@@ -1422,7 +1429,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1422 (u32) ((be64_to_cpu(arg) >> 32) & 0xFFFFFFFF), 1429 (u32) ((be64_to_cpu(arg) >> 32) & 0xFFFFFFFF),
1423 (u32) (be64_to_cpu(arg) & 0xFFFFFFFF)); 1430 (u32) (be64_to_cpu(arg) & 0xFFFFFFFF));
1424 } 1431 }
1425 spin_lock(&host_info_lock); 1432 spin_lock_irqsave(&host_info_lock, irqflags);
1426 hi = find_host_info(host); /* search addressentry in file_info's for host */ 1433 hi = find_host_info(host); /* search addressentry in file_info's for host */
1427 if (hi != NULL) { 1434 if (hi != NULL) {
1428 list_for_each_entry(fi, &hi->file_info_list, list) { 1435 list_for_each_entry(fi, &hi->file_info_list, list) {
@@ -1449,7 +1456,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1449 printk(KERN_ERR 1456 printk(KERN_ERR
1450 "raw1394: arm_lock64 FAILED addr_entry not found" 1457 "raw1394: arm_lock64 FAILED addr_entry not found"
1451 " -> rcode_address_error\n"); 1458 " -> rcode_address_error\n");
1452 spin_unlock(&host_info_lock); 1459 spin_unlock_irqrestore(&host_info_lock, irqflags);
1453 return (RCODE_ADDRESS_ERROR); 1460 return (RCODE_ADDRESS_ERROR);
1454 } else { 1461 } else {
1455 DBGMSG("arm_lock64 addr_entry FOUND"); 1462 DBGMSG("arm_lock64 addr_entry FOUND");
@@ -1533,7 +1540,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1533 DBGMSG("arm_lock64 -> entering notification-section"); 1540 DBGMSG("arm_lock64 -> entering notification-section");
1534 req = __alloc_pending_request(SLAB_ATOMIC); 1541 req = __alloc_pending_request(SLAB_ATOMIC);
1535 if (!req) { 1542 if (!req) {
1536 spin_unlock(&host_info_lock); 1543 spin_unlock_irqrestore(&host_info_lock, irqflags);
1537 DBGMSG("arm_lock64 -> rcode_conflict_error"); 1544 DBGMSG("arm_lock64 -> rcode_conflict_error");
1538 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 1545 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
1539 The request may be retried */ 1546 The request may be retried */
@@ -1542,7 +1549,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1542 req->data = kmalloc(size, SLAB_ATOMIC); 1549 req->data = kmalloc(size, SLAB_ATOMIC);
1543 if (!(req->data)) { 1550 if (!(req->data)) {
1544 free_pending_request(req); 1551 free_pending_request(req);
1545 spin_unlock(&host_info_lock); 1552 spin_unlock_irqrestore(&host_info_lock, irqflags);
1546 DBGMSG("arm_lock64 -> rcode_conflict_error"); 1553 DBGMSG("arm_lock64 -> rcode_conflict_error");
1547 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected. 1554 return (RCODE_CONFLICT_ERROR); /* A resource conflict was detected.
1548 The request may be retried */ 1555 The request may be retried */
@@ -1609,7 +1616,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1609 sizeof(struct arm_response) + 2 * sizeof(*store)); 1616 sizeof(struct arm_response) + 2 * sizeof(*store));
1610 queue_complete_req(req); 1617 queue_complete_req(req);
1611 } 1618 }
1612 spin_unlock(&host_info_lock); 1619 spin_unlock_irqrestore(&host_info_lock, irqflags);
1613 return (rcode); 1620 return (rcode);
1614} 1621}
1615 1622
@@ -1980,6 +1987,7 @@ static int write_phypacket(struct file_info *fi, struct pending_request *req)
1980 struct hpsb_packet *packet = NULL; 1987 struct hpsb_packet *packet = NULL;
1981 int retval = 0; 1988 int retval = 0;
1982 quadlet_t data; 1989 quadlet_t data;
1990 unsigned long flags;
1983 1991
1984 data = be32_to_cpu((u32) req->req.sendb); 1992 data = be32_to_cpu((u32) req->req.sendb);
1985 DBGMSG("write_phypacket called - quadlet 0x%8.8x ", data); 1993 DBGMSG("write_phypacket called - quadlet 0x%8.8x ", data);
@@ -1990,9 +1998,9 @@ static int write_phypacket(struct file_info *fi, struct pending_request *req)
1990 req->packet = packet; 1998 req->packet = packet;
1991 hpsb_set_packet_complete_task(packet, 1999 hpsb_set_packet_complete_task(packet,
1992 (void (*)(void *))queue_complete_cb, req); 2000 (void (*)(void *))queue_complete_cb, req);
1993 spin_lock_irq(&fi->reqlists_lock); 2001 spin_lock_irqsave(&fi->reqlists_lock, flags);
1994 list_add_tail(&req->list, &fi->req_pending); 2002 list_add_tail(&req->list, &fi->req_pending);
1995 spin_unlock_irq(&fi->reqlists_lock); 2003 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
1996 packet->generation = req->req.generation; 2004 packet->generation = req->req.generation;
1997 retval = hpsb_send_packet(packet); 2005 retval = hpsb_send_packet(packet);
1998 DBGMSG("write_phypacket send_packet called => retval: %d ", retval); 2006 DBGMSG("write_phypacket send_packet called => retval: %d ", retval);
@@ -2659,14 +2667,15 @@ static unsigned int raw1394_poll(struct file *file, poll_table * pt)
2659{ 2667{
2660 struct file_info *fi = file->private_data; 2668 struct file_info *fi = file->private_data;
2661 unsigned int mask = POLLOUT | POLLWRNORM; 2669 unsigned int mask = POLLOUT | POLLWRNORM;
2670 unsigned long flags;
2662 2671
2663 poll_wait(file, &fi->poll_wait_complete, pt); 2672 poll_wait(file, &fi->poll_wait_complete, pt);
2664 2673
2665 spin_lock_irq(&fi->reqlists_lock); 2674 spin_lock_irqsave(&fi->reqlists_lock, flags);
2666 if (!list_empty(&fi->req_complete)) { 2675 if (!list_empty(&fi->req_complete)) {
2667 mask |= POLLIN | POLLRDNORM; 2676 mask |= POLLIN | POLLRDNORM;
2668 } 2677 }
2669 spin_unlock_irq(&fi->reqlists_lock); 2678 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
2670 2679
2671 return mask; 2680 return mask;
2672} 2681}
@@ -2710,6 +2719,7 @@ static int raw1394_release(struct inode *inode, struct file *file)
2710 struct arm_addr *arm_addr = NULL; 2719 struct arm_addr *arm_addr = NULL;
2711 int another_host; 2720 int another_host;
2712 int csr_mod = 0; 2721 int csr_mod = 0;
2722 unsigned long flags;
2713 2723
2714 if (fi->iso_state != RAW1394_ISO_INACTIVE) 2724 if (fi->iso_state != RAW1394_ISO_INACTIVE)
2715 raw1394_iso_shutdown(fi); 2725 raw1394_iso_shutdown(fi);
@@ -2720,13 +2730,11 @@ static int raw1394_release(struct inode *inode, struct file *file)
2720 } 2730 }
2721 } 2731 }
2722 2732
2723 spin_lock_irq(&host_info_lock); 2733 spin_lock_irqsave(&host_info_lock, flags);
2724 fi->listen_channels = 0; 2734 fi->listen_channels = 0;
2725 spin_unlock_irq(&host_info_lock);
2726 2735
2727 fail = 0; 2736 fail = 0;
2728 /* set address-entries invalid */ 2737 /* set address-entries invalid */
2729 spin_lock_irq(&host_info_lock);
2730 2738
2731 while (!list_empty(&fi->addr_list)) { 2739 while (!list_empty(&fi->addr_list)) {
2732 another_host = 0; 2740 another_host = 0;
@@ -2777,14 +2785,14 @@ static int raw1394_release(struct inode *inode, struct file *file)
2777 vfree(addr->addr_space_buffer); 2785 vfree(addr->addr_space_buffer);
2778 kfree(addr); 2786 kfree(addr);
2779 } /* while */ 2787 } /* while */
2780 spin_unlock_irq(&host_info_lock); 2788 spin_unlock_irqrestore(&host_info_lock, flags);
2781 if (fail > 0) { 2789 if (fail > 0) {
2782 printk(KERN_ERR "raw1394: during addr_list-release " 2790 printk(KERN_ERR "raw1394: during addr_list-release "
2783 "error(s) occurred \n"); 2791 "error(s) occurred \n");
2784 } 2792 }
2785 2793
2786 while (!done) { 2794 while (!done) {
2787 spin_lock_irq(&fi->reqlists_lock); 2795 spin_lock_irqsave(&fi->reqlists_lock, flags);
2788 2796
2789 while (!list_empty(&fi->req_complete)) { 2797 while (!list_empty(&fi->req_complete)) {
2790 lh = fi->req_complete.next; 2798 lh = fi->req_complete.next;
@@ -2798,7 +2806,7 @@ static int raw1394_release(struct inode *inode, struct file *file)
2798 if (list_empty(&fi->req_pending)) 2806 if (list_empty(&fi->req_pending))
2799 done = 1; 2807 done = 1;
2800 2808
2801 spin_unlock_irq(&fi->reqlists_lock); 2809 spin_unlock_irqrestore(&fi->reqlists_lock, flags);
2802 2810
2803 if (!done) 2811 if (!done)
2804 down_interruptible(&fi->complete_sem); 2812 down_interruptible(&fi->complete_sem);
@@ -2828,9 +2836,9 @@ static int raw1394_release(struct inode *inode, struct file *file)
2828 fi->host->id); 2836 fi->host->id);
2829 2837
2830 if (fi->state == connected) { 2838 if (fi->state == connected) {
2831 spin_lock_irq(&host_info_lock); 2839 spin_lock_irqsave(&host_info_lock, flags);
2832 list_del(&fi->list); 2840 list_del(&fi->list);
2833 spin_unlock_irq(&host_info_lock); 2841 spin_unlock_irqrestore(&host_info_lock, flags);
2834 2842
2835 put_device(&fi->host->device); 2843 put_device(&fi->host->device);
2836 } 2844 }
@@ -2958,4 +2966,3 @@ static void __exit cleanup_raw1394(void)
2958module_init(init_raw1394); 2966module_init(init_raw1394);
2959module_exit(cleanup_raw1394); 2967module_exit(cleanup_raw1394);
2960MODULE_LICENSE("GPL"); 2968MODULE_LICENSE("GPL");
2961MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16);
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index de88218ef7cc..12cec7c4a342 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -97,16 +97,18 @@ static char version[] __devinitdata =
97 */ 97 */
98static int max_speed = IEEE1394_SPEED_MAX; 98static int max_speed = IEEE1394_SPEED_MAX;
99module_param(max_speed, int, 0644); 99module_param(max_speed, int, 0644);
100MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb default, 1 = 200mb, 0 = 100mb)"); 100MODULE_PARM_DESC(max_speed, "Force max speed (3 = 800mb, 2 = 400mb, 1 = 200mb, 0 = 100mb)");
101 101
102/* 102/*
103 * Set serialize_io to 1 if you'd like only one scsi command sent 103 * Set serialize_io to 1 if you'd like only one scsi command sent
104 * down to us at a time (debugging). This might be necessary for very 104 * down to us at a time (debugging). This might be necessary for very
105 * badly behaved sbp2 devices. 105 * badly behaved sbp2 devices.
106 *
107 * TODO: Make this configurable per device.
106 */ 108 */
107static int serialize_io; 109static int serialize_io = 1;
108module_param(serialize_io, int, 0444); 110module_param(serialize_io, int, 0444);
109MODULE_PARM_DESC(serialize_io, "Serialize all I/O coming down from the scsi drivers (default = 0)"); 111MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers (default = 1, faster = 0)");
110 112
111/* 113/*
112 * Bump up max_sectors if you'd like to support very large sized 114 * Bump up max_sectors if you'd like to support very large sized
@@ -596,6 +598,14 @@ static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_i
596 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 598 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
597} 599}
598 600
601/*
602 * Is scsi_id valid? Is the 1394 node still present?
603 */
604static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_id)
605{
606 return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo;
607}
608
599 609
600 610
601/********************************************* 611/*********************************************
@@ -631,11 +641,23 @@ static int sbp2_remove(struct device *dev)
631{ 641{
632 struct unit_directory *ud; 642 struct unit_directory *ud;
633 struct scsi_id_instance_data *scsi_id; 643 struct scsi_id_instance_data *scsi_id;
644 struct scsi_device *sdev;
634 645
635 SBP2_DEBUG("sbp2_remove"); 646 SBP2_DEBUG("sbp2_remove");
636 647
637 ud = container_of(dev, struct unit_directory, device); 648 ud = container_of(dev, struct unit_directory, device);
638 scsi_id = ud->device.driver_data; 649 scsi_id = ud->device.driver_data;
650 if (!scsi_id)
651 return 0;
652
653 /* Trigger shutdown functions in scsi's highlevel. */
654 if (scsi_id->scsi_host)
655 scsi_unblock_requests(scsi_id->scsi_host);
656 sdev = scsi_id->sdev;
657 if (sdev) {
658 scsi_id->sdev = NULL;
659 scsi_remove_device(sdev);
660 }
639 661
640 sbp2_logout_device(scsi_id); 662 sbp2_logout_device(scsi_id);
641 sbp2_remove_device(scsi_id); 663 sbp2_remove_device(scsi_id);
@@ -2473,37 +2495,26 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2473 struct scsi_id_instance_data *scsi_id = 2495 struct scsi_id_instance_data *scsi_id =
2474 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; 2496 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
2475 struct sbp2scsi_host_info *hi; 2497 struct sbp2scsi_host_info *hi;
2498 int result = DID_NO_CONNECT << 16;
2476 2499
2477 SBP2_DEBUG("sbp2scsi_queuecommand"); 2500 SBP2_DEBUG("sbp2scsi_queuecommand");
2478 2501
2479 /* 2502 if (!sbp2util_node_is_available(scsi_id))
2480 * If scsi_id is null, it means there is no device in this slot, 2503 goto done;
2481 * so we should return selection timeout.
2482 */
2483 if (!scsi_id) {
2484 SCpnt->result = DID_NO_CONNECT << 16;
2485 done (SCpnt);
2486 return 0;
2487 }
2488 2504
2489 hi = scsi_id->hi; 2505 hi = scsi_id->hi;
2490 2506
2491 if (!hi) { 2507 if (!hi) {
2492 SBP2_ERR("sbp2scsi_host_info is NULL - this is bad!"); 2508 SBP2_ERR("sbp2scsi_host_info is NULL - this is bad!");
2493 SCpnt->result = DID_NO_CONNECT << 16; 2509 goto done;
2494 done (SCpnt);
2495 return(0);
2496 } 2510 }
2497 2511
2498 /* 2512 /*
2499 * Until we handle multiple luns, just return selection time-out 2513 * Until we handle multiple luns, just return selection time-out
2500 * to any IO directed at non-zero LUNs 2514 * to any IO directed at non-zero LUNs
2501 */ 2515 */
2502 if (SCpnt->device->lun) { 2516 if (SCpnt->device->lun)
2503 SCpnt->result = DID_NO_CONNECT << 16; 2517 goto done;
2504 done (SCpnt);
2505 return(0);
2506 }
2507 2518
2508 /* 2519 /*
2509 * Check for request sense command, and handle it here 2520 * Check for request sense command, and handle it here
@@ -2514,7 +2525,7 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2514 memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen); 2525 memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen);
2515 memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer)); 2526 memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
2516 sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_GOOD, SCpnt, done); 2527 sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_GOOD, SCpnt, done);
2517 return(0); 2528 return 0;
2518 } 2529 }
2519 2530
2520 /* 2531 /*
@@ -2522,9 +2533,8 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2522 */ 2533 */
2523 if (!hpsb_node_entry_valid(scsi_id->ne)) { 2534 if (!hpsb_node_entry_valid(scsi_id->ne)) {
2524 SBP2_ERR("Bus reset in progress - rejecting command"); 2535 SBP2_ERR("Bus reset in progress - rejecting command");
2525 SCpnt->result = DID_BUS_BUSY << 16; 2536 result = DID_BUS_BUSY << 16;
2526 done (SCpnt); 2537 goto done;
2527 return(0);
2528 } 2538 }
2529 2539
2530 /* 2540 /*
@@ -2535,8 +2545,12 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2535 sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT, 2545 sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT,
2536 SCpnt, done); 2546 SCpnt, done);
2537 } 2547 }
2548 return 0;
2538 2549
2539 return(0); 2550done:
2551 SCpnt->result = result;
2552 done(SCpnt);
2553 return 0;
2540} 2554}
2541 2555
2542/* 2556/*
@@ -2683,14 +2697,27 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2683} 2697}
2684 2698
2685 2699
2686static int sbp2scsi_slave_configure (struct scsi_device *sdev) 2700static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
2687{ 2701{
2688 blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); 2702 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev;
2703 return 0;
2704}
2705
2689 2706
2707static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2708{
2709 blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
2690 return 0; 2710 return 0;
2691} 2711}
2692 2712
2693 2713
2714static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
2715{
2716 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL;
2717 return;
2718}
2719
2720
2694/* 2721/*
2695 * Called by scsi stack when something has really gone wrong. Usually 2722 * Called by scsi stack when something has really gone wrong. Usually
2696 * called when a command has timed-out for some reason. 2723 * called when a command has timed-out for some reason.
@@ -2705,7 +2732,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2705 SBP2_ERR("aborting sbp2 command"); 2732 SBP2_ERR("aborting sbp2 command");
2706 scsi_print_command(SCpnt); 2733 scsi_print_command(SCpnt);
2707 2734
2708 if (scsi_id) { 2735 if (sbp2util_node_is_available(scsi_id)) {
2709 2736
2710 /* 2737 /*
2711 * Right now, just return any matching command structures 2738 * Right now, just return any matching command structures
@@ -2742,31 +2769,24 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2742/* 2769/*
2743 * Called by scsi stack when something has really gone wrong. 2770 * Called by scsi stack when something has really gone wrong.
2744 */ 2771 */
2745static int __sbp2scsi_reset(struct scsi_cmnd *SCpnt) 2772static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
2746{ 2773{
2747 struct scsi_id_instance_data *scsi_id = 2774 struct scsi_id_instance_data *scsi_id =
2748 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; 2775 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
2776 unsigned long flags;
2749 2777
2750 SBP2_ERR("reset requested"); 2778 SBP2_ERR("reset requested");
2751 2779
2752 if (scsi_id) { 2780 spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
2781
2782 if (sbp2util_node_is_available(scsi_id)) {
2753 SBP2_ERR("Generating sbp2 fetch agent reset"); 2783 SBP2_ERR("Generating sbp2 fetch agent reset");
2754 sbp2_agent_reset(scsi_id, 0); 2784 sbp2_agent_reset(scsi_id, 0);
2755 } 2785 }
2756 2786
2757 return(SUCCESS);
2758}
2759
2760static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
2761{
2762 unsigned long flags;
2763 int rc;
2764
2765 spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
2766 rc = __sbp2scsi_reset(SCpnt);
2767 spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); 2787 spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags);
2768 2788
2769 return rc; 2789 return SUCCESS;
2770} 2790}
2771 2791
2772static const char *sbp2scsi_info (struct Scsi_Host *host) 2792static const char *sbp2scsi_info (struct Scsi_Host *host)
@@ -2817,7 +2837,9 @@ static struct scsi_host_template scsi_driver_template = {
2817 .eh_device_reset_handler = sbp2scsi_reset, 2837 .eh_device_reset_handler = sbp2scsi_reset,
2818 .eh_bus_reset_handler = sbp2scsi_reset, 2838 .eh_bus_reset_handler = sbp2scsi_reset,
2819 .eh_host_reset_handler = sbp2scsi_reset, 2839 .eh_host_reset_handler = sbp2scsi_reset,
2840 .slave_alloc = sbp2scsi_slave_alloc,
2820 .slave_configure = sbp2scsi_slave_configure, 2841 .slave_configure = sbp2scsi_slave_configure,
2842 .slave_destroy = sbp2scsi_slave_destroy,
2821 .this_id = -1, 2843 .this_id = -1,
2822 .sg_tablesize = SG_ALL, 2844 .sg_tablesize = SG_ALL,
2823 .use_clustering = ENABLE_CLUSTERING, 2845 .use_clustering = ENABLE_CLUSTERING,
@@ -2837,7 +2859,8 @@ static int sbp2_module_init(void)
2837 2859
2838 /* Module load debug option to force one command at a time (serializing I/O) */ 2860 /* Module load debug option to force one command at a time (serializing I/O) */
2839 if (serialize_io) { 2861 if (serialize_io) {
2840 SBP2_ERR("Driver forced to serialize I/O (serialize_io = 1)"); 2862 SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)");
2863 SBP2_INFO("Try serialize_io=0 for better performance");
2841 scsi_driver_template.can_queue = 1; 2864 scsi_driver_template.can_queue = 1;
2842 scsi_driver_template.cmd_per_lun = 1; 2865 scsi_driver_template.cmd_per_lun = 1;
2843 } 2866 }
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 9d6facf2f78f..11be9c9c82a8 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1571,4 +1571,3 @@ static int __init video1394_init_module (void)
1571 1571
1572module_init(video1394_init_module); 1572module_init(video1394_init_module);
1573module_exit(video1394_exit_module); 1573module_exit(video1394_exit_module);
1574MODULE_ALIAS_CHARDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16);
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index a4a4d9c1eef3..a14ca87fda18 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -783,7 +783,7 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
783 u32 remote_qpn, u16 pkey_index, 783 u32 remote_qpn, u16 pkey_index,
784 struct ib_ah *ah, int rmpp_active, 784 struct ib_ah *ah, int rmpp_active,
785 int hdr_len, int data_len, 785 int hdr_len, int data_len,
786 unsigned int __nocast gfp_mask) 786 gfp_t gfp_mask)
787{ 787{
788 struct ib_mad_agent_private *mad_agent_priv; 788 struct ib_mad_agent_private *mad_agent_priv;
789 struct ib_mad_send_buf *send_buf; 789 struct ib_mad_send_buf *send_buf;
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index 2bd8b1cc57c4..e23836d0e21b 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -412,8 +412,8 @@ static inline int get_mad_len(struct mad_rmpp_recv *rmpp_recv)
412 412
413 hdr_size = data_offset(rmpp_mad->mad_hdr.mgmt_class); 413 hdr_size = data_offset(rmpp_mad->mad_hdr.mgmt_class);
414 data_size = sizeof(struct ib_rmpp_mad) - hdr_size; 414 data_size = sizeof(struct ib_rmpp_mad) - hdr_size;
415 pad = data_size - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin); 415 pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
416 if (pad > data_size || pad < 0) 416 if (pad > IB_MGMT_RMPP_DATA || pad < 0)
417 pad = 0; 417 pad = 0;
418 418
419 return hdr_size + rmpp_recv->seg_num * data_size - pad; 419 return hdr_size + rmpp_recv->seg_num * data_size - pad;
@@ -583,6 +583,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
583{ 583{
584 struct ib_rmpp_mad *rmpp_mad; 584 struct ib_rmpp_mad *rmpp_mad;
585 int timeout; 585 int timeout;
586 u32 paylen;
586 587
587 rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; 588 rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr;
588 ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE); 589 ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
@@ -590,11 +591,9 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
590 591
591 if (mad_send_wr->seg_num == 1) { 592 if (mad_send_wr->seg_num == 1) {
592 rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST; 593 rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST;
593 rmpp_mad->rmpp_hdr.paylen_newwin = 594 paylen = mad_send_wr->total_seg * IB_MGMT_RMPP_DATA -
594 cpu_to_be32(mad_send_wr->total_seg * 595 mad_send_wr->pad;
595 (sizeof(struct ib_rmpp_mad) - 596 rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen);
596 offsetof(struct ib_rmpp_mad, data)) -
597 mad_send_wr->pad);
598 mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad); 597 mad_send_wr->sg_list[0].length = sizeof(struct ib_rmpp_mad);
599 } else { 598 } else {
600 mad_send_wr->send_wr.num_sge = 2; 599 mad_send_wr->send_wr.num_sge = 2;
@@ -608,10 +607,8 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
608 607
609 if (mad_send_wr->seg_num == mad_send_wr->total_seg) { 608 if (mad_send_wr->seg_num == mad_send_wr->total_seg) {
610 rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST; 609 rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST;
611 rmpp_mad->rmpp_hdr.paylen_newwin = 610 paylen = IB_MGMT_RMPP_DATA - mad_send_wr->pad;
612 cpu_to_be32(sizeof(struct ib_rmpp_mad) - 611 rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen);
613 offsetof(struct ib_rmpp_mad, data) -
614 mad_send_wr->pad);
615 } 612 }
616 613
617 /* 2 seconds for an ACK until we can find the packet lifetime */ 614 /* 2 seconds for an ACK until we can find the packet lifetime */
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 78de2dd1a4f2..262618210c1c 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -574,7 +574,7 @@ static void ib_sa_path_rec_release(struct ib_sa_query *sa_query)
574int ib_sa_path_rec_get(struct ib_device *device, u8 port_num, 574int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
575 struct ib_sa_path_rec *rec, 575 struct ib_sa_path_rec *rec,
576 ib_sa_comp_mask comp_mask, 576 ib_sa_comp_mask comp_mask,
577 int timeout_ms, unsigned int __nocast gfp_mask, 577 int timeout_ms, gfp_t gfp_mask,
578 void (*callback)(int status, 578 void (*callback)(int status,
579 struct ib_sa_path_rec *resp, 579 struct ib_sa_path_rec *resp,
580 void *context), 580 void *context),
@@ -676,7 +676,7 @@ static void ib_sa_service_rec_release(struct ib_sa_query *sa_query)
676int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method, 676int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
677 struct ib_sa_service_rec *rec, 677 struct ib_sa_service_rec *rec,
678 ib_sa_comp_mask comp_mask, 678 ib_sa_comp_mask comp_mask,
679 int timeout_ms, unsigned int __nocast gfp_mask, 679 int timeout_ms, gfp_t gfp_mask,
680 void (*callback)(int status, 680 void (*callback)(int status,
681 struct ib_sa_service_rec *resp, 681 struct ib_sa_service_rec *resp,
682 void *context), 682 void *context),
@@ -759,7 +759,7 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
759 u8 method, 759 u8 method,
760 struct ib_sa_mcmember_rec *rec, 760 struct ib_sa_mcmember_rec *rec,
761 ib_sa_comp_mask comp_mask, 761 ib_sa_comp_mask comp_mask,
762 int timeout_ms, unsigned int __nocast gfp_mask, 762 int timeout_ms, gfp_t gfp_mask,
763 void (*callback)(int status, 763 void (*callback)(int status,
764 struct ib_sa_mcmember_rec *resp, 764 struct ib_sa_mcmember_rec *resp,
765 void *context), 765 void *context),
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 7c2f03057ddb..a64d6b4dcc16 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -334,10 +334,11 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
334 ret = -EINVAL; 334 ret = -EINVAL;
335 goto err_ah; 335 goto err_ah;
336 } 336 }
337 /* Validate that management class can support RMPP */ 337
338 /* Validate that the management class can support RMPP */
338 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) { 339 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
339 hdr_len = offsetof(struct ib_sa_mad, data); 340 hdr_len = offsetof(struct ib_sa_mad, data);
340 data_len = length; 341 data_len = length - hdr_len;
341 } else if ((rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) && 342 } else if ((rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
342 (rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) { 343 (rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) {
343 hdr_len = offsetof(struct ib_vendor_mad, data); 344 hdr_len = offsetof(struct ib_vendor_mad, data);
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index b1897bed14ad..cc124344dd2c 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -69,6 +69,7 @@ struct ib_uverbs_event_file {
69 69
70struct ib_uverbs_file { 70struct ib_uverbs_file {
71 struct kref ref; 71 struct kref ref;
72 struct semaphore mutex;
72 struct ib_uverbs_device *device; 73 struct ib_uverbs_device *device;
73 struct ib_ucontext *ucontext; 74 struct ib_ucontext *ucontext;
74 struct ib_event_handler event_handler; 75 struct ib_event_handler event_handler;
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index e91ebde46481..562445165d2b 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -76,8 +76,9 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
76 struct ib_uverbs_get_context_resp resp; 76 struct ib_uverbs_get_context_resp resp;
77 struct ib_udata udata; 77 struct ib_udata udata;
78 struct ib_device *ibdev = file->device->ib_dev; 78 struct ib_device *ibdev = file->device->ib_dev;
79 struct ib_ucontext *ucontext;
79 int i; 80 int i;
80 int ret = in_len; 81 int ret;
81 82
82 if (out_len < sizeof resp) 83 if (out_len < sizeof resp)
83 return -ENOSPC; 84 return -ENOSPC;
@@ -85,45 +86,56 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
85 if (copy_from_user(&cmd, buf, sizeof cmd)) 86 if (copy_from_user(&cmd, buf, sizeof cmd))
86 return -EFAULT; 87 return -EFAULT;
87 88
89 down(&file->mutex);
90
91 if (file->ucontext) {
92 ret = -EINVAL;
93 goto err;
94 }
95
88 INIT_UDATA(&udata, buf + sizeof cmd, 96 INIT_UDATA(&udata, buf + sizeof cmd,
89 (unsigned long) cmd.response + sizeof resp, 97 (unsigned long) cmd.response + sizeof resp,
90 in_len - sizeof cmd, out_len - sizeof resp); 98 in_len - sizeof cmd, out_len - sizeof resp);
91 99
92 file->ucontext = ibdev->alloc_ucontext(ibdev, &udata); 100 ucontext = ibdev->alloc_ucontext(ibdev, &udata);
93 if (IS_ERR(file->ucontext)) { 101 if (IS_ERR(ucontext))
94 ret = PTR_ERR(file->ucontext); 102 return PTR_ERR(file->ucontext);
95 file->ucontext = NULL;
96 return ret;
97 }
98 103
99 file->ucontext->device = ibdev; 104 ucontext->device = ibdev;
100 INIT_LIST_HEAD(&file->ucontext->pd_list); 105 INIT_LIST_HEAD(&ucontext->pd_list);
101 INIT_LIST_HEAD(&file->ucontext->mr_list); 106 INIT_LIST_HEAD(&ucontext->mr_list);
102 INIT_LIST_HEAD(&file->ucontext->mw_list); 107 INIT_LIST_HEAD(&ucontext->mw_list);
103 INIT_LIST_HEAD(&file->ucontext->cq_list); 108 INIT_LIST_HEAD(&ucontext->cq_list);
104 INIT_LIST_HEAD(&file->ucontext->qp_list); 109 INIT_LIST_HEAD(&ucontext->qp_list);
105 INIT_LIST_HEAD(&file->ucontext->srq_list); 110 INIT_LIST_HEAD(&ucontext->srq_list);
106 INIT_LIST_HEAD(&file->ucontext->ah_list); 111 INIT_LIST_HEAD(&ucontext->ah_list);
107 spin_lock_init(&file->ucontext->lock);
108 112
109 resp.async_fd = file->async_file.fd; 113 resp.async_fd = file->async_file.fd;
110 for (i = 0; i < file->device->num_comp; ++i) 114 for (i = 0; i < file->device->num_comp; ++i)
111 if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab + 115 if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab +
112 i * sizeof (__u32), 116 i * sizeof (__u32),
113 &file->comp_file[i].fd, sizeof (__u32))) 117 &file->comp_file[i].fd, sizeof (__u32))) {
114 goto err; 118 ret = -EFAULT;
119 goto err_free;
120 }
115 121
116 if (copy_to_user((void __user *) (unsigned long) cmd.response, 122 if (copy_to_user((void __user *) (unsigned long) cmd.response,
117 &resp, sizeof resp)) 123 &resp, sizeof resp)) {
118 goto err; 124 ret = -EFAULT;
125 goto err_free;
126 }
127
128 file->ucontext = ucontext;
129 up(&file->mutex);
119 130
120 return in_len; 131 return in_len;
121 132
122err: 133err_free:
123 ibdev->dealloc_ucontext(file->ucontext); 134 ibdev->dealloc_ucontext(ucontext);
124 file->ucontext = NULL;
125 135
126 return -EFAULT; 136err:
137 up(&file->mutex);
138 return ret;
127} 139}
128 140
129ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, 141ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
@@ -352,9 +364,9 @@ retry:
352 if (ret) 364 if (ret)
353 goto err_pd; 365 goto err_pd;
354 366
355 spin_lock_irq(&file->ucontext->lock); 367 down(&file->mutex);
356 list_add_tail(&uobj->list, &file->ucontext->pd_list); 368 list_add_tail(&uobj->list, &file->ucontext->pd_list);
357 spin_unlock_irq(&file->ucontext->lock); 369 up(&file->mutex);
358 370
359 memset(&resp, 0, sizeof resp); 371 memset(&resp, 0, sizeof resp);
360 resp.pd_handle = uobj->id; 372 resp.pd_handle = uobj->id;
@@ -368,9 +380,9 @@ retry:
368 return in_len; 380 return in_len;
369 381
370err_list: 382err_list:
371 spin_lock_irq(&file->ucontext->lock); 383 down(&file->mutex);
372 list_del(&uobj->list); 384 list_del(&uobj->list);
373 spin_unlock_irq(&file->ucontext->lock); 385 up(&file->mutex);
374 386
375 down(&ib_uverbs_idr_mutex); 387 down(&ib_uverbs_idr_mutex);
376 idr_remove(&ib_uverbs_pd_idr, uobj->id); 388 idr_remove(&ib_uverbs_pd_idr, uobj->id);
@@ -410,9 +422,9 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
410 422
411 idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); 423 idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle);
412 424
413 spin_lock_irq(&file->ucontext->lock); 425 down(&file->mutex);
414 list_del(&uobj->list); 426 list_del(&uobj->list);
415 spin_unlock_irq(&file->ucontext->lock); 427 up(&file->mutex);
416 428
417 kfree(uobj); 429 kfree(uobj);
418 430
@@ -512,9 +524,9 @@ retry:
512 524
513 resp.mr_handle = obj->uobject.id; 525 resp.mr_handle = obj->uobject.id;
514 526
515 spin_lock_irq(&file->ucontext->lock); 527 down(&file->mutex);
516 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); 528 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list);
517 spin_unlock_irq(&file->ucontext->lock); 529 up(&file->mutex);
518 530
519 if (copy_to_user((void __user *) (unsigned long) cmd.response, 531 if (copy_to_user((void __user *) (unsigned long) cmd.response,
520 &resp, sizeof resp)) { 532 &resp, sizeof resp)) {
@@ -527,9 +539,9 @@ retry:
527 return in_len; 539 return in_len;
528 540
529err_list: 541err_list:
530 spin_lock_irq(&file->ucontext->lock); 542 down(&file->mutex);
531 list_del(&obj->uobject.list); 543 list_del(&obj->uobject.list);
532 spin_unlock_irq(&file->ucontext->lock); 544 up(&file->mutex);
533 545
534err_unreg: 546err_unreg:
535 ib_dereg_mr(mr); 547 ib_dereg_mr(mr);
@@ -570,9 +582,9 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
570 582
571 idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); 583 idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle);
572 584
573 spin_lock_irq(&file->ucontext->lock); 585 down(&file->mutex);
574 list_del(&memobj->uobject.list); 586 list_del(&memobj->uobject.list);
575 spin_unlock_irq(&file->ucontext->lock); 587 up(&file->mutex);
576 588
577 ib_umem_release(file->device->ib_dev, &memobj->umem); 589 ib_umem_release(file->device->ib_dev, &memobj->umem);
578 kfree(memobj); 590 kfree(memobj);
@@ -647,9 +659,9 @@ retry:
647 if (ret) 659 if (ret)
648 goto err_cq; 660 goto err_cq;
649 661
650 spin_lock_irq(&file->ucontext->lock); 662 down(&file->mutex);
651 list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); 663 list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list);
652 spin_unlock_irq(&file->ucontext->lock); 664 up(&file->mutex);
653 665
654 memset(&resp, 0, sizeof resp); 666 memset(&resp, 0, sizeof resp);
655 resp.cq_handle = uobj->uobject.id; 667 resp.cq_handle = uobj->uobject.id;
@@ -664,9 +676,9 @@ retry:
664 return in_len; 676 return in_len;
665 677
666err_list: 678err_list:
667 spin_lock_irq(&file->ucontext->lock); 679 down(&file->mutex);
668 list_del(&uobj->uobject.list); 680 list_del(&uobj->uobject.list);
669 spin_unlock_irq(&file->ucontext->lock); 681 up(&file->mutex);
670 682
671 down(&ib_uverbs_idr_mutex); 683 down(&ib_uverbs_idr_mutex);
672 idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); 684 idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id);
@@ -712,9 +724,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
712 724
713 idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); 725 idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle);
714 726
715 spin_lock_irq(&file->ucontext->lock); 727 down(&file->mutex);
716 list_del(&uobj->uobject.list); 728 list_del(&uobj->uobject.list);
717 spin_unlock_irq(&file->ucontext->lock); 729 up(&file->mutex);
718 730
719 spin_lock_irq(&file->comp_file[0].lock); 731 spin_lock_irq(&file->comp_file[0].lock);
720 list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) { 732 list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
@@ -847,9 +859,9 @@ retry:
847 859
848 resp.qp_handle = uobj->uobject.id; 860 resp.qp_handle = uobj->uobject.id;
849 861
850 spin_lock_irq(&file->ucontext->lock); 862 down(&file->mutex);
851 list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); 863 list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list);
852 spin_unlock_irq(&file->ucontext->lock); 864 up(&file->mutex);
853 865
854 if (copy_to_user((void __user *) (unsigned long) cmd.response, 866 if (copy_to_user((void __user *) (unsigned long) cmd.response,
855 &resp, sizeof resp)) { 867 &resp, sizeof resp)) {
@@ -862,9 +874,9 @@ retry:
862 return in_len; 874 return in_len;
863 875
864err_list: 876err_list:
865 spin_lock_irq(&file->ucontext->lock); 877 down(&file->mutex);
866 list_del(&uobj->uobject.list); 878 list_del(&uobj->uobject.list);
867 spin_unlock_irq(&file->ucontext->lock); 879 up(&file->mutex);
868 880
869err_destroy: 881err_destroy:
870 ib_destroy_qp(qp); 882 ib_destroy_qp(qp);
@@ -989,9 +1001,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
989 1001
990 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); 1002 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle);
991 1003
992 spin_lock_irq(&file->ucontext->lock); 1004 down(&file->mutex);
993 list_del(&uobj->uobject.list); 1005 list_del(&uobj->uobject.list);
994 spin_unlock_irq(&file->ucontext->lock); 1006 up(&file->mutex);
995 1007
996 spin_lock_irq(&file->async_file.lock); 1008 spin_lock_irq(&file->async_file.lock);
997 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { 1009 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
@@ -1136,9 +1148,9 @@ retry:
1136 1148
1137 resp.srq_handle = uobj->uobject.id; 1149 resp.srq_handle = uobj->uobject.id;
1138 1150
1139 spin_lock_irq(&file->ucontext->lock); 1151 down(&file->mutex);
1140 list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); 1152 list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list);
1141 spin_unlock_irq(&file->ucontext->lock); 1153 up(&file->mutex);
1142 1154
1143 if (copy_to_user((void __user *) (unsigned long) cmd.response, 1155 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1144 &resp, sizeof resp)) { 1156 &resp, sizeof resp)) {
@@ -1151,9 +1163,9 @@ retry:
1151 return in_len; 1163 return in_len;
1152 1164
1153err_list: 1165err_list:
1154 spin_lock_irq(&file->ucontext->lock); 1166 down(&file->mutex);
1155 list_del(&uobj->uobject.list); 1167 list_del(&uobj->uobject.list);
1156 spin_unlock_irq(&file->ucontext->lock); 1168 up(&file->mutex);
1157 1169
1158err_destroy: 1170err_destroy:
1159 ib_destroy_srq(srq); 1171 ib_destroy_srq(srq);
@@ -1227,9 +1239,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
1227 1239
1228 idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); 1240 idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle);
1229 1241
1230 spin_lock_irq(&file->ucontext->lock); 1242 down(&file->mutex);
1231 list_del(&uobj->uobject.list); 1243 list_del(&uobj->uobject.list);
1232 spin_unlock_irq(&file->ucontext->lock); 1244 up(&file->mutex);
1233 1245
1234 spin_lock_irq(&file->async_file.lock); 1246 spin_lock_irq(&file->async_file.lock);
1235 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { 1247 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index ce5bdb7af306..12511808de21 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -448,7 +448,9 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
448 if (hdr.in_words * 4 != count) 448 if (hdr.in_words * 4 != count)
449 return -EINVAL; 449 return -EINVAL;
450 450
451 if (hdr.command < 0 || hdr.command >= ARRAY_SIZE(uverbs_cmd_table)) 451 if (hdr.command < 0 ||
452 hdr.command >= ARRAY_SIZE(uverbs_cmd_table) ||
453 !uverbs_cmd_table[hdr.command])
452 return -EINVAL; 454 return -EINVAL;
453 455
454 if (!file->ucontext && 456 if (!file->ucontext &&
@@ -484,27 +486,29 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
484 file = kmalloc(sizeof *file + 486 file = kmalloc(sizeof *file +
485 (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file), 487 (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file),
486 GFP_KERNEL); 488 GFP_KERNEL);
487 if (!file) 489 if (!file) {
488 return -ENOMEM; 490 ret = -ENOMEM;
491 goto err;
492 }
489 493
490 file->device = dev; 494 file->device = dev;
491 kref_init(&file->ref); 495 kref_init(&file->ref);
496 init_MUTEX(&file->mutex);
492 497
493 file->ucontext = NULL; 498 file->ucontext = NULL;
494 499
500 kref_get(&file->ref);
495 ret = ib_uverbs_event_init(&file->async_file, file); 501 ret = ib_uverbs_event_init(&file->async_file, file);
496 if (ret) 502 if (ret)
497 goto err; 503 goto err_kref;
498 504
499 file->async_file.is_async = 1; 505 file->async_file.is_async = 1;
500 506
501 kref_get(&file->ref);
502
503 for (i = 0; i < dev->num_comp; ++i) { 507 for (i = 0; i < dev->num_comp; ++i) {
508 kref_get(&file->ref);
504 ret = ib_uverbs_event_init(&file->comp_file[i], file); 509 ret = ib_uverbs_event_init(&file->comp_file[i], file);
505 if (ret) 510 if (ret)
506 goto err_async; 511 goto err_async;
507 kref_get(&file->ref);
508 file->comp_file[i].is_async = 0; 512 file->comp_file[i].is_async = 0;
509 } 513 }
510 514
@@ -524,9 +528,16 @@ err_async:
524 528
525 ib_uverbs_event_release(&file->async_file); 529 ib_uverbs_event_release(&file->async_file);
526 530
527err: 531err_kref:
532 /*
533 * One extra kref_put() because we took a reference before the
534 * event file creation that failed and got us here.
535 */
536 kref_put(&file->ref, ib_uverbs_release_file);
528 kref_put(&file->ref, ib_uverbs_release_file); 537 kref_put(&file->ref, ib_uverbs_release_file);
529 538
539err:
540 module_put(dev->ib_dev->owner);
530 return ret; 541 return ret;
531} 542}
532 543
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index cc758a2d2bc6..f6a8ac026557 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -605,7 +605,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,
605 err = -EINVAL; 605 err = -EINVAL;
606 goto out; 606 goto out;
607 } 607 }
608 for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i, ++nent) { 608 for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i) {
609 if (virt != -1) { 609 if (virt != -1) {
610 pages[nent * 2] = cpu_to_be64(virt); 610 pages[nent * 2] = cpu_to_be64(virt);
611 virt += 1 << lg; 611 virt += 1 << lg;
@@ -616,7 +616,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,
616 ts += 1 << (lg - 10); 616 ts += 1 << (lg - 10);
617 ++tc; 617 ++tc;
618 618
619 if (nent == MTHCA_MAILBOX_SIZE / 16) { 619 if (++nent == MTHCA_MAILBOX_SIZE / 16) {
620 err = mthca_cmd(dev, mailbox->dma, nent, 0, op, 620 err = mthca_cmd(dev, mailbox->dma, nent, 0, op,
621 CMD_TIME_CLASS_B, status); 621 CMD_TIME_CLASS_B, status);
622 if (err || *status) 622 if (err || *status)
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 18f0981eb0c1..8dfafda5ed24 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -396,20 +396,21 @@ static irqreturn_t mthca_tavor_interrupt(int irq, void *dev_ptr, struct pt_regs
396 writel(dev->eq_table.clr_mask, dev->eq_table.clr_int); 396 writel(dev->eq_table.clr_mask, dev->eq_table.clr_int);
397 397
398 ecr = readl(dev->eq_regs.tavor.ecr_base + 4); 398 ecr = readl(dev->eq_regs.tavor.ecr_base + 4);
399 if (ecr) { 399 if (!ecr)
400 writel(ecr, dev->eq_regs.tavor.ecr_base + 400 return IRQ_NONE;
401 MTHCA_ECR_CLR_BASE - MTHCA_ECR_BASE + 4);
402 401
403 for (i = 0; i < MTHCA_NUM_EQ; ++i) 402 writel(ecr, dev->eq_regs.tavor.ecr_base +
404 if (ecr & dev->eq_table.eq[i].eqn_mask && 403 MTHCA_ECR_CLR_BASE - MTHCA_ECR_BASE + 4);
405 mthca_eq_int(dev, &dev->eq_table.eq[i])) { 404
405 for (i = 0; i < MTHCA_NUM_EQ; ++i)
406 if (ecr & dev->eq_table.eq[i].eqn_mask) {
407 if (mthca_eq_int(dev, &dev->eq_table.eq[i]))
406 tavor_set_eq_ci(dev, &dev->eq_table.eq[i], 408 tavor_set_eq_ci(dev, &dev->eq_table.eq[i],
407 dev->eq_table.eq[i].cons_index); 409 dev->eq_table.eq[i].cons_index);
408 tavor_eq_req_not(dev, dev->eq_table.eq[i].eqn); 410 tavor_eq_req_not(dev, dev->eq_table.eq[i].eqn);
409 } 411 }
410 }
411 412
412 return IRQ_RETVAL(ecr); 413 return IRQ_HANDLED;
413} 414}
414 415
415static irqreturn_t mthca_tavor_msi_x_interrupt(int irq, void *eq_ptr, 416static irqreturn_t mthca_tavor_msi_x_interrupt(int irq, void *eq_ptr,
@@ -476,12 +477,8 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
476 int i; 477 int i;
477 u8 status; 478 u8 status;
478 479
479 /* Make sure EQ size is aligned to a power of 2 size. */ 480 eq->dev = dev;
480 for (i = 1; i < nent; i <<= 1) 481 eq->nent = roundup_pow_of_two(max(nent, 2));
481 ; /* nothing */
482 nent = i;
483
484 eq->dev = dev;
485 482
486 eq->page_list = kmalloc(npages * sizeof *eq->page_list, 483 eq->page_list = kmalloc(npages * sizeof *eq->page_list,
487 GFP_KERNEL); 484 GFP_KERNEL);
@@ -512,7 +509,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
512 memset(eq->page_list[i].buf, 0, PAGE_SIZE); 509 memset(eq->page_list[i].buf, 0, PAGE_SIZE);
513 } 510 }
514 511
515 for (i = 0; i < nent; ++i) 512 for (i = 0; i < eq->nent; ++i)
516 set_eqe_hw(get_eqe(eq, i)); 513 set_eqe_hw(get_eqe(eq, i));
517 514
518 eq->eqn = mthca_alloc(&dev->eq_table.alloc); 515 eq->eqn = mthca_alloc(&dev->eq_table.alloc);
@@ -528,8 +525,6 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
528 if (err) 525 if (err)
529 goto err_out_free_eq; 526 goto err_out_free_eq;
530 527
531 eq->nent = nent;
532
533 memset(eq_context, 0, sizeof *eq_context); 528 memset(eq_context, 0, sizeof *eq_context);
534 eq_context->flags = cpu_to_be32(MTHCA_EQ_STATUS_OK | 529 eq_context->flags = cpu_to_be32(MTHCA_EQ_STATUS_OK |
535 MTHCA_EQ_OWNER_HW | 530 MTHCA_EQ_OWNER_HW |
@@ -538,7 +533,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
538 if (mthca_is_memfree(dev)) 533 if (mthca_is_memfree(dev))
539 eq_context->flags |= cpu_to_be32(MTHCA_EQ_STATE_ARBEL); 534 eq_context->flags |= cpu_to_be32(MTHCA_EQ_STATE_ARBEL);
540 535
541 eq_context->logsize_usrpage = cpu_to_be32((ffs(nent) - 1) << 24); 536 eq_context->logsize_usrpage = cpu_to_be32((ffs(eq->nent) - 1) << 24);
542 if (mthca_is_memfree(dev)) { 537 if (mthca_is_memfree(dev)) {
543 eq_context->arbel_pd = cpu_to_be32(dev->driver_pd.pd_num); 538 eq_context->arbel_pd = cpu_to_be32(dev->driver_pd.pd_num);
544 } else { 539 } else {
@@ -569,7 +564,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
569 dev->eq_table.arm_mask |= eq->eqn_mask; 564 dev->eq_table.arm_mask |= eq->eqn_mask;
570 565
571 mthca_dbg(dev, "Allocated EQ %d with %d entries\n", 566 mthca_dbg(dev, "Allocated EQ %d with %d entries\n",
572 eq->eqn, nent); 567 eq->eqn, eq->nent);
573 568
574 return err; 569 return err;
575 570
@@ -842,7 +837,7 @@ int __devinit mthca_init_eq_table(struct mthca_dev *dev)
842 dev->eq_table.clr_mask = 837 dev->eq_table.clr_mask =
843 swab32(1 << (dev->eq_table.inta_pin & 31)); 838 swab32(1 << (dev->eq_table.inta_pin & 31));
844 dev->eq_table.clr_int = dev->clr_base + 839 dev->eq_table.clr_int = dev->clr_base +
845 (dev->eq_table.inta_pin < 31 ? 4 : 0); 840 (dev->eq_table.inta_pin < 32 ? 4 : 0);
846 } 841 }
847 842
848 dev->eq_table.arm_mask = 0; 843 dev->eq_table.arm_mask = 0;
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index ffbcd40418d5..23a3f56c7899 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -503,6 +503,25 @@ err_free_aux:
503 return err; 503 return err;
504} 504}
505 505
506static void mthca_free_icms(struct mthca_dev *mdev)
507{
508 u8 status;
509
510 mthca_free_icm_table(mdev, mdev->mcg_table.table);
511 if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
512 mthca_free_icm_table(mdev, mdev->srq_table.table);
513 mthca_free_icm_table(mdev, mdev->cq_table.table);
514 mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
515 mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
516 mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
517 mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
518 mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
519 mthca_unmap_eq_icm(mdev);
520
521 mthca_UNMAP_ICM_AUX(mdev, &status);
522 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
523}
524
506static int __devinit mthca_init_arbel(struct mthca_dev *mdev) 525static int __devinit mthca_init_arbel(struct mthca_dev *mdev)
507{ 526{
508 struct mthca_dev_lim dev_lim; 527 struct mthca_dev_lim dev_lim;
@@ -580,18 +599,7 @@ static int __devinit mthca_init_arbel(struct mthca_dev *mdev)
580 return 0; 599 return 0;
581 600
582err_free_icm: 601err_free_icm:
583 if (mdev->mthca_flags & MTHCA_FLAG_SRQ) 602 mthca_free_icms(mdev);
584 mthca_free_icm_table(mdev, mdev->srq_table.table);
585 mthca_free_icm_table(mdev, mdev->cq_table.table);
586 mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
587 mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
588 mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
589 mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
590 mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
591 mthca_unmap_eq_icm(mdev);
592
593 mthca_UNMAP_ICM_AUX(mdev, &status);
594 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
595 603
596err_stop_fw: 604err_stop_fw:
597 mthca_UNMAP_FA(mdev, &status); 605 mthca_UNMAP_FA(mdev, &status);
@@ -611,18 +619,7 @@ static void mthca_close_hca(struct mthca_dev *mdev)
611 mthca_CLOSE_HCA(mdev, 0, &status); 619 mthca_CLOSE_HCA(mdev, 0, &status);
612 620
613 if (mthca_is_memfree(mdev)) { 621 if (mthca_is_memfree(mdev)) {
614 if (mdev->mthca_flags & MTHCA_FLAG_SRQ) 622 mthca_free_icms(mdev);
615 mthca_free_icm_table(mdev, mdev->srq_table.table);
616 mthca_free_icm_table(mdev, mdev->cq_table.table);
617 mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
618 mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
619 mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
620 mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
621 mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
622 mthca_unmap_eq_icm(mdev);
623
624 mthca_UNMAP_ICM_AUX(mdev, &status);
625 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
626 623
627 mthca_UNMAP_FA(mdev, &status); 624 mthca_UNMAP_FA(mdev, &status);
628 mthca_free_icm(mdev, mdev->fw.arbel.fw_icm); 625 mthca_free_icm(mdev, mdev->fw.arbel.fw_icm);
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 1827400f189b..7bd7a4bec7b4 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -290,7 +290,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
290 int i; 290 int i;
291 u8 status; 291 u8 status;
292 292
293 num_icm = obj_size * nobj / MTHCA_TABLE_CHUNK_SIZE; 293 num_icm = (obj_size * nobj + MTHCA_TABLE_CHUNK_SIZE - 1) / MTHCA_TABLE_CHUNK_SIZE;
294 294
295 table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL); 295 table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL);
296 if (!table) 296 if (!table)
@@ -529,12 +529,25 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db)
529 goto found; 529 goto found;
530 } 530 }
531 531
532 for (i = start; i != end; i += dir)
533 if (!dev->db_tab->page[i].db_rec) {
534 page = dev->db_tab->page + i;
535 goto alloc;
536 }
537
532 if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) { 538 if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) {
533 ret = -ENOMEM; 539 ret = -ENOMEM;
534 goto out; 540 goto out;
535 } 541 }
536 542
543 if (group == 0)
544 ++dev->db_tab->max_group1;
545 else
546 --dev->db_tab->min_group2;
547
537 page = dev->db_tab->page + end; 548 page = dev->db_tab->page + end;
549
550alloc:
538 page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096, 551 page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096,
539 &page->mapping, GFP_KERNEL); 552 &page->mapping, GFP_KERNEL);
540 if (!page->db_rec) { 553 if (!page->db_rec) {
@@ -554,10 +567,6 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db)
554 } 567 }
555 568
556 bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); 569 bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE);
557 if (group == 0)
558 ++dev->db_tab->max_group1;
559 else
560 --dev->db_tab->min_group2;
561 570
562found: 571found:
563 j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); 572 j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE);
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 1c1c2e230871..3f5319a46577 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -84,7 +84,7 @@ static int mthca_query_device(struct ib_device *ibdev,
84 props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & 84 props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
85 0xffffff; 85 0xffffff;
86 props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); 86 props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30));
87 props->hw_ver = be16_to_cpup((__be16 *) (out_mad->data + 32)); 87 props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32));
88 memcpy(&props->sys_image_guid, out_mad->data + 4, 8); 88 memcpy(&props->sys_image_guid, out_mad->data + 4, 8);
89 memcpy(&props->node_guid, out_mad->data + 12, 8); 89 memcpy(&props->node_guid, out_mad->data + 12, 8);
90 90
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index bcef06bf15e7..5fa00669f9b8 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -227,7 +227,6 @@ static void mthca_wq_init(struct mthca_wq *wq)
227 wq->last_comp = wq->max - 1; 227 wq->last_comp = wq->max - 1;
228 wq->head = 0; 228 wq->head = 0;
229 wq->tail = 0; 229 wq->tail = 0;
230 wq->last = NULL;
231} 230}
232 231
233void mthca_qp_event(struct mthca_dev *dev, u32 qpn, 232void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
@@ -687,7 +686,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
687 } 686 }
688 687
689 if (attr_mask & IB_QP_TIMEOUT) { 688 if (attr_mask & IB_QP_TIMEOUT) {
690 qp_context->pri_path.ackto = attr->timeout; 689 qp_context->pri_path.ackto = attr->timeout << 3;
691 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ACK_TIMEOUT); 690 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ACK_TIMEOUT);
692 } 691 }
693 692
@@ -1103,6 +1102,9 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev,
1103 } 1102 }
1104 } 1103 }
1105 1104
1105 qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
1106 qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
1107
1106 return 0; 1108 return 0;
1107} 1109}
1108 1110
@@ -1583,15 +1585,13 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1583 goto out; 1585 goto out;
1584 } 1586 }
1585 1587
1586 if (prev_wqe) { 1588 ((struct mthca_next_seg *) prev_wqe)->nda_op =
1587 ((struct mthca_next_seg *) prev_wqe)->nda_op = 1589 cpu_to_be32(((ind << qp->sq.wqe_shift) +
1588 cpu_to_be32(((ind << qp->sq.wqe_shift) + 1590 qp->send_wqe_offset) |
1589 qp->send_wqe_offset) | 1591 mthca_opcode[wr->opcode]);
1590 mthca_opcode[wr->opcode]); 1592 wmb();
1591 wmb(); 1593 ((struct mthca_next_seg *) prev_wqe)->ee_nds =
1592 ((struct mthca_next_seg *) prev_wqe)->ee_nds = 1594 cpu_to_be32((size0 ? 0 : MTHCA_NEXT_DBD) | size);
1593 cpu_to_be32((size0 ? 0 : MTHCA_NEXT_DBD) | size);
1594 }
1595 1595
1596 if (!size0) { 1596 if (!size0) {
1597 size0 = size; 1597 size0 = size;
@@ -1688,13 +1688,11 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
1688 1688
1689 qp->wrid[ind] = wr->wr_id; 1689 qp->wrid[ind] = wr->wr_id;
1690 1690
1691 if (likely(prev_wqe)) { 1691 ((struct mthca_next_seg *) prev_wqe)->nda_op =
1692 ((struct mthca_next_seg *) prev_wqe)->nda_op = 1692 cpu_to_be32((ind << qp->rq.wqe_shift) | 1);
1693 cpu_to_be32((ind << qp->rq.wqe_shift) | 1); 1693 wmb();
1694 wmb(); 1694 ((struct mthca_next_seg *) prev_wqe)->ee_nds =
1695 ((struct mthca_next_seg *) prev_wqe)->ee_nds = 1695 cpu_to_be32(MTHCA_NEXT_DBD | size);
1696 cpu_to_be32(MTHCA_NEXT_DBD | size);
1697 }
1698 1696
1699 if (!size0) 1697 if (!size0)
1700 size0 = size; 1698 size0 = size;
@@ -1905,15 +1903,13 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1905 goto out; 1903 goto out;
1906 } 1904 }
1907 1905
1908 if (likely(prev_wqe)) { 1906 ((struct mthca_next_seg *) prev_wqe)->nda_op =
1909 ((struct mthca_next_seg *) prev_wqe)->nda_op = 1907 cpu_to_be32(((ind << qp->sq.wqe_shift) +
1910 cpu_to_be32(((ind << qp->sq.wqe_shift) + 1908 qp->send_wqe_offset) |
1911 qp->send_wqe_offset) | 1909 mthca_opcode[wr->opcode]);
1912 mthca_opcode[wr->opcode]); 1910 wmb();
1913 wmb(); 1911 ((struct mthca_next_seg *) prev_wqe)->ee_nds =
1914 ((struct mthca_next_seg *) prev_wqe)->ee_nds = 1912 cpu_to_be32(MTHCA_NEXT_DBD | size);
1915 cpu_to_be32(MTHCA_NEXT_DBD | size);
1916 }
1917 1913
1918 if (!size0) { 1914 if (!size0) {
1919 size0 = size; 1915 size0 = size;
@@ -2127,5 +2123,6 @@ void __devexit mthca_cleanup_qp_table(struct mthca_dev *dev)
2127 for (i = 0; i < 2; ++i) 2123 for (i = 0; i < 2; ++i)
2128 mthca_CONF_SPECIAL_QP(dev, i, 0, &status); 2124 mthca_CONF_SPECIAL_QP(dev, i, 0, &status);
2129 2125
2126 mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps);
2130 mthca_alloc_cleanup(&dev->qp_table.alloc); 2127 mthca_alloc_cleanup(&dev->qp_table.alloc);
2131} 2128}
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 75cd2d84ef12..18998d48c53e 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -172,6 +172,8 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd,
172 scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY); 172 scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
173 } 173 }
174 174
175 srq->last = get_wqe(srq, srq->max - 1);
176
175 return 0; 177 return 0;
176} 178}
177 179
@@ -189,7 +191,6 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
189 191
190 srq->max = attr->max_wr; 192 srq->max = attr->max_wr;
191 srq->max_gs = attr->max_sge; 193 srq->max_gs = attr->max_sge;
192 srq->last = NULL;
193 srq->counter = 0; 194 srq->counter = 0;
194 195
195 if (mthca_is_memfree(dev)) 196 if (mthca_is_memfree(dev))
@@ -409,7 +410,7 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
409 mthca_err(dev, "SRQ %06x full\n", srq->srqn); 410 mthca_err(dev, "SRQ %06x full\n", srq->srqn);
410 err = -ENOMEM; 411 err = -ENOMEM;
411 *bad_wr = wr; 412 *bad_wr = wr;
412 return nreq; 413 break;
413 } 414 }
414 415
415 wqe = get_wqe(srq, ind); 416 wqe = get_wqe(srq, ind);
@@ -427,7 +428,7 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
427 err = -EINVAL; 428 err = -EINVAL;
428 *bad_wr = wr; 429 *bad_wr = wr;
429 srq->last = prev_wqe; 430 srq->last = prev_wqe;
430 return nreq; 431 break;
431 } 432 }
432 433
433 for (i = 0; i < wr->num_sge; ++i) { 434 for (i = 0; i < wr->num_sge; ++i) {
@@ -446,20 +447,16 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
446 ((struct mthca_data_seg *) wqe)->addr = 0; 447 ((struct mthca_data_seg *) wqe)->addr = 0;
447 } 448 }
448 449
449 if (likely(prev_wqe)) { 450 ((struct mthca_next_seg *) prev_wqe)->nda_op =
450 ((struct mthca_next_seg *) prev_wqe)->nda_op = 451 cpu_to_be32((ind << srq->wqe_shift) | 1);
451 cpu_to_be32((ind << srq->wqe_shift) | 1); 452 wmb();
452 wmb(); 453 ((struct mthca_next_seg *) prev_wqe)->ee_nds =
453 ((struct mthca_next_seg *) prev_wqe)->ee_nds = 454 cpu_to_be32(MTHCA_NEXT_DBD);
454 cpu_to_be32(MTHCA_NEXT_DBD);
455 }
456 455
457 srq->wrid[ind] = wr->wr_id; 456 srq->wrid[ind] = wr->wr_id;
458 srq->first_free = next_ind; 457 srq->first_free = next_ind;
459 } 458 }
460 459
461 return nreq;
462
463 if (likely(nreq)) { 460 if (likely(nreq)) {
464 __be32 doorbell[2]; 461 __be32 doorbell[2];
465 462
@@ -503,7 +500,7 @@ int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
503 mthca_err(dev, "SRQ %06x full\n", srq->srqn); 500 mthca_err(dev, "SRQ %06x full\n", srq->srqn);
504 err = -ENOMEM; 501 err = -ENOMEM;
505 *bad_wr = wr; 502 *bad_wr = wr;
506 return nreq; 503 break;
507 } 504 }
508 505
509 wqe = get_wqe(srq, ind); 506 wqe = get_wqe(srq, ind);
@@ -519,7 +516,7 @@ int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
519 if (unlikely(wr->num_sge > srq->max_gs)) { 516 if (unlikely(wr->num_sge > srq->max_gs)) {
520 err = -EINVAL; 517 err = -EINVAL;
521 *bad_wr = wr; 518 *bad_wr = wr;
522 return nreq; 519 break;
523 } 520 }
524 521
525 for (i = 0; i < wr->num_sge; ++i) { 522 for (i = 0; i < wr->num_sge; ++i) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index bea960b8191f..4ea1c1ca85bc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -257,7 +257,7 @@ void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
257 257
258void ipoib_mcast_restart_task(void *dev_ptr); 258void ipoib_mcast_restart_task(void *dev_ptr);
259int ipoib_mcast_start_thread(struct net_device *dev); 259int ipoib_mcast_start_thread(struct net_device *dev);
260int ipoib_mcast_stop_thread(struct net_device *dev); 260int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
261 261
262void ipoib_mcast_dev_down(struct net_device *dev); 262void ipoib_mcast_dev_down(struct net_device *dev);
263void ipoib_mcast_dev_flush(struct net_device *dev); 263void ipoib_mcast_dev_flush(struct net_device *dev);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index ef0e3894863c..f7440096b5ed 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -432,7 +432,7 @@ int ipoib_ib_dev_down(struct net_device *dev)
432 flush_workqueue(ipoib_workqueue); 432 flush_workqueue(ipoib_workqueue);
433 } 433 }
434 434
435 ipoib_mcast_stop_thread(dev); 435 ipoib_mcast_stop_thread(dev, 1);
436 436
437 /* 437 /*
438 * Flush the multicast groups first so we stop any multicast joins. The 438 * Flush the multicast groups first so we stop any multicast joins. The
@@ -599,7 +599,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
599 599
600 ipoib_dbg(priv, "cleaning up ib_dev\n"); 600 ipoib_dbg(priv, "cleaning up ib_dev\n");
601 601
602 ipoib_mcast_stop_thread(dev); 602 ipoib_mcast_stop_thread(dev, 1);
603 603
604 /* Delete the broadcast address and the local address */ 604 /* Delete the broadcast address and the local address */
605 ipoib_mcast_dev_down(dev); 605 ipoib_mcast_dev_down(dev);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 49d120d2b92c..6c5bf07489f4 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -474,7 +474,7 @@ err:
474 spin_unlock(&priv->lock); 474 spin_unlock(&priv->lock);
475} 475}
476 476
477static void path_lookup(struct sk_buff *skb, struct net_device *dev) 477static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev)
478{ 478{
479 struct ipoib_dev_priv *priv = netdev_priv(skb->dev); 479 struct ipoib_dev_priv *priv = netdev_priv(skb->dev);
480 480
@@ -569,7 +569,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
569 569
570 if (skb->dst && skb->dst->neighbour) { 570 if (skb->dst && skb->dst->neighbour) {
571 if (unlikely(!*to_ipoib_neigh(skb->dst->neighbour))) { 571 if (unlikely(!*to_ipoib_neigh(skb->dst->neighbour))) {
572 path_lookup(skb, dev); 572 ipoib_path_lookup(skb, dev);
573 goto out; 573 goto out;
574 } 574 }
575 575
@@ -1005,6 +1005,7 @@ debug_failed:
1005 1005
1006register_failed: 1006register_failed:
1007 ib_unregister_event_handler(&priv->event_handler); 1007 ib_unregister_event_handler(&priv->event_handler);
1008 flush_scheduled_work();
1008 1009
1009event_failed: 1010event_failed:
1010 ipoib_dev_cleanup(priv->dev); 1011 ipoib_dev_cleanup(priv->dev);
@@ -1057,6 +1058,7 @@ static void ipoib_remove_one(struct ib_device *device)
1057 1058
1058 list_for_each_entry_safe(priv, tmp, dev_list, list) { 1059 list_for_each_entry_safe(priv, tmp, dev_list, list) {
1059 ib_unregister_event_handler(&priv->event_handler); 1060 ib_unregister_event_handler(&priv->event_handler);
1061 flush_scheduled_work();
1060 1062
1061 unregister_netdev(priv->dev); 1063 unregister_netdev(priv->dev);
1062 ipoib_dev_cleanup(priv->dev); 1064 ipoib_dev_cleanup(priv->dev);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index aca7aea18a69..36ce29836bf2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -145,7 +145,7 @@ static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
145 145
146 mcast->dev = dev; 146 mcast->dev = dev;
147 mcast->created = jiffies; 147 mcast->created = jiffies;
148 mcast->backoff = HZ; 148 mcast->backoff = 1;
149 mcast->logcount = 0; 149 mcast->logcount = 0;
150 150
151 INIT_LIST_HEAD(&mcast->list); 151 INIT_LIST_HEAD(&mcast->list);
@@ -396,7 +396,7 @@ static void ipoib_mcast_join_complete(int status,
396 IPOIB_GID_ARG(mcast->mcmember.mgid), status); 396 IPOIB_GID_ARG(mcast->mcmember.mgid), status);
397 397
398 if (!status && !ipoib_mcast_join_finish(mcast, mcmember)) { 398 if (!status && !ipoib_mcast_join_finish(mcast, mcmember)) {
399 mcast->backoff = HZ; 399 mcast->backoff = 1;
400 down(&mcast_mutex); 400 down(&mcast_mutex);
401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) 401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
402 queue_work(ipoib_workqueue, &priv->mcast_task); 402 queue_work(ipoib_workqueue, &priv->mcast_task);
@@ -496,7 +496,7 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
496 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) 496 if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
497 queue_delayed_work(ipoib_workqueue, 497 queue_delayed_work(ipoib_workqueue,
498 &priv->mcast_task, 498 &priv->mcast_task,
499 mcast->backoff); 499 mcast->backoff * HZ);
500 up(&mcast_mutex); 500 up(&mcast_mutex);
501 } else 501 } else
502 mcast->query_id = ret; 502 mcast->query_id = ret;
@@ -598,7 +598,7 @@ int ipoib_mcast_start_thread(struct net_device *dev)
598 return 0; 598 return 0;
599} 599}
600 600
601int ipoib_mcast_stop_thread(struct net_device *dev) 601int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
602{ 602{
603 struct ipoib_dev_priv *priv = netdev_priv(dev); 603 struct ipoib_dev_priv *priv = netdev_priv(dev);
604 struct ipoib_mcast *mcast; 604 struct ipoib_mcast *mcast;
@@ -610,7 +610,8 @@ int ipoib_mcast_stop_thread(struct net_device *dev)
610 cancel_delayed_work(&priv->mcast_task); 610 cancel_delayed_work(&priv->mcast_task);
611 up(&mcast_mutex); 611 up(&mcast_mutex);
612 612
613 flush_workqueue(ipoib_workqueue); 613 if (flush)
614 flush_workqueue(ipoib_workqueue);
614 615
615 if (priv->broadcast && priv->broadcast->query) { 616 if (priv->broadcast && priv->broadcast->query) {
616 ib_sa_cancel_query(priv->broadcast->query_id, priv->broadcast->query); 617 ib_sa_cancel_query(priv->broadcast->query_id, priv->broadcast->query);
@@ -832,7 +833,7 @@ void ipoib_mcast_restart_task(void *dev_ptr)
832 833
833 ipoib_dbg_mcast(priv, "restarting multicast task\n"); 834 ipoib_dbg_mcast(priv, "restarting multicast task\n");
834 835
835 ipoib_mcast_stop_thread(dev); 836 ipoib_mcast_stop_thread(dev, 0);
836 837
837 spin_lock_irqsave(&priv->lock, flags); 838 spin_lock_irqsave(&priv->lock, flags);
838 839
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 88636a204525..14ae5583e198 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -308,6 +308,7 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st
308 MATCH_BIT(ledbit, LED_MAX); 308 MATCH_BIT(ledbit, LED_MAX);
309 MATCH_BIT(sndbit, SND_MAX); 309 MATCH_BIT(sndbit, SND_MAX);
310 MATCH_BIT(ffbit, FF_MAX); 310 MATCH_BIT(ffbit, FF_MAX);
311 MATCH_BIT(swbit, SW_MAX);
311 312
312 return id; 313 return id;
313 } 314 }
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 444f7756fee6..571a68691a4a 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -93,7 +93,7 @@ config KEYBOARD_LKKBD
93 93
94config KEYBOARD_LOCOMO 94config KEYBOARD_LOCOMO
95 tristate "LoCoMo Keyboard Support" 95 tristate "LoCoMo Keyboard Support"
96 depends on SHARP_LOCOMO 96 depends on SHARP_LOCOMO && INPUT_KEYBOARD
97 help 97 help
98 Say Y here if you are running Linux on a Sharp Zaurus Collie or Poodle based PDA 98 Say Y here if you are running Linux on a Sharp Zaurus Collie or Poodle based PDA
99 99
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 1714045a182b..344f46005401 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -53,7 +53,7 @@ static unsigned char spitzkbd_keycode[NR_SCANCODES] = {
53 KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */ 53 KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */
54 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */ 54 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */
55 KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ 55 KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */
56 SPITZ_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, /* 49-64 */ 56 SPITZ_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */
57 SPITZ_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */ 57 SPITZ_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */
58 SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */ 58 SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */
59 KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */ 59 KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d5c5b32045af..4015a91f4b6e 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -90,11 +90,11 @@ static inline int uinput_request_reserve_slot(struct uinput_device *udev, struct
90 90
91static void uinput_request_done(struct uinput_device *udev, struct uinput_request *request) 91static void uinput_request_done(struct uinput_device *udev, struct uinput_request *request)
92{ 92{
93 complete(&request->done);
94
95 /* Mark slot as available */ 93 /* Mark slot as available */
96 udev->requests[request->id] = NULL; 94 udev->requests[request->id] = NULL;
97 wake_up_interruptible(&udev->requests_waitq); 95 wake_up_interruptible(&udev->requests_waitq);
96
97 complete(&request->done);
98} 98}
99 99
100static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request) 100static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request)
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index e1f0d87de0eb..0b0ea26023e5 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -287,12 +287,12 @@ divert_dev_init(void)
287 init_waitqueue_head(&rd_queue); 287 init_waitqueue_head(&rd_queue);
288 288
289#ifdef CONFIG_PROC_FS 289#ifdef CONFIG_PROC_FS
290 isdn_proc_entry = create_proc_entry("isdn", S_IFDIR | S_IRUGO | S_IXUGO, proc_net); 290 isdn_proc_entry = proc_mkdir("net/isdn", NULL);
291 if (!isdn_proc_entry) 291 if (!isdn_proc_entry)
292 return (-1); 292 return (-1);
293 isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); 293 isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry);
294 if (!isdn_divert_entry) { 294 if (!isdn_divert_entry) {
295 remove_proc_entry("isdn", proc_net); 295 remove_proc_entry("net/isdn", NULL);
296 return (-1); 296 return (-1);
297 } 297 }
298 isdn_divert_entry->proc_fops = &isdn_fops; 298 isdn_divert_entry->proc_fops = &isdn_fops;
@@ -312,7 +312,7 @@ divert_dev_deinit(void)
312 312
313#ifdef CONFIG_PROC_FS 313#ifdef CONFIG_PROC_FS
314 remove_proc_entry("divert", isdn_proc_entry); 314 remove_proc_entry("divert", isdn_proc_entry);
315 remove_proc_entry("isdn", proc_net); 315 remove_proc_entry("net/isdn", NULL);
316#endif /* CONFIG_PROC_FS */ 316#endif /* CONFIG_PROC_FS */
317 317
318 return (0); 318 return (0);
diff --git a/drivers/isdn/hardware/eicon/diva_didd.c b/drivers/isdn/hardware/eicon/diva_didd.c
index 7fdf8ae5be52..27204f4b111a 100644
--- a/drivers/isdn/hardware/eicon/diva_didd.c
+++ b/drivers/isdn/hardware/eicon/diva_didd.c
@@ -30,8 +30,6 @@ static char *DRIVERNAME =
30static char *DRIVERLNAME = "divadidd"; 30static char *DRIVERLNAME = "divadidd";
31char *DRIVERRELEASE_DIDD = "2.0"; 31char *DRIVERRELEASE_DIDD = "2.0";
32 32
33static char *main_proc_dir = "eicon";
34
35MODULE_DESCRIPTION("DIDD table driver for diva drivers"); 33MODULE_DESCRIPTION("DIDD table driver for diva drivers");
36MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); 34MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
37MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); 35MODULE_SUPPORTED_DEVICE("Eicon diva drivers");
@@ -89,7 +87,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof,
89 87
90static int DIVA_INIT_FUNCTION create_proc(void) 88static int DIVA_INIT_FUNCTION create_proc(void)
91{ 89{
92 proc_net_eicon = create_proc_entry(main_proc_dir, S_IFDIR, proc_net); 90 proc_net_eicon = proc_mkdir("net/eicon", NULL);
93 91
94 if (proc_net_eicon) { 92 if (proc_net_eicon) {
95 if ((proc_didd = 93 if ((proc_didd =
@@ -105,7 +103,7 @@ static int DIVA_INIT_FUNCTION create_proc(void)
105static void DIVA_EXIT_FUNCTION remove_proc(void) 103static void DIVA_EXIT_FUNCTION remove_proc(void)
106{ 104{
107 remove_proc_entry(DRIVERLNAME, proc_net_eicon); 105 remove_proc_entry(DRIVERLNAME, proc_net_eicon);
108 remove_proc_entry(main_proc_dir, proc_net); 106 remove_proc_entry("net/eicon", NULL);
109} 107}
110 108
111static int DIVA_INIT_FUNCTION divadidd_init(void) 109static int DIVA_INIT_FUNCTION divadidd_init(void)
diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c
index b6435589d459..c12efa6f8429 100644
--- a/drivers/isdn/hardware/eicon/divasproc.c
+++ b/drivers/isdn/hardware/eicon/divasproc.c
@@ -381,7 +381,7 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a)
381 char tmp[16]; 381 char tmp[16];
382 382
383 sprintf(tmp, "%s%d", adapter_dir_name, a->controller); 383 sprintf(tmp, "%s%d", adapter_dir_name, a->controller);
384 if (!(de = create_proc_entry(tmp, S_IFDIR, proc_net_eicon))) 384 if (!(de = proc_mkdir(tmp, proc_net_eicon)))
385 return (0); 385 return (0);
386 a->proc_adapter_dir = (void *) de; 386 a->proc_adapter_dir = (void *) de;
387 387
diff --git a/drivers/isdn/hisax/st5481.h b/drivers/isdn/hisax/st5481.h
index 0fda5c89429b..9ffaae7c657a 100644
--- a/drivers/isdn/hisax/st5481.h
+++ b/drivers/isdn/hisax/st5481.h
@@ -466,10 +466,10 @@ void st5481_stop(struct st5481_adapter *adapter);
466#define __debug_variable st5481_debug 466#define __debug_variable st5481_debug
467#include "hisax_debug.h" 467#include "hisax_debug.h"
468 468
469#ifdef CONFIG_HISAX_DEBUG
470
471extern int st5481_debug; 469extern int st5481_debug;
472 470
471#ifdef CONFIG_HISAX_DEBUG
472
473#define DBG_ISO_PACKET(level,urb) \ 473#define DBG_ISO_PACKET(level,urb) \
474 if (level & __debug_variable) dump_iso_packet(__FUNCTION__,urb) 474 if (level & __debug_variable) dump_iso_packet(__FUNCTION__,urb)
475 475
diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c
index 2fcd093921d8..657817a591fe 100644
--- a/drivers/isdn/hisax/st5481_b.c
+++ b/drivers/isdn/hisax/st5481_b.c
@@ -172,14 +172,18 @@ static void usb_b_out_complete(struct urb *urb, struct pt_regs *regs)
172 test_and_clear_bit(buf_nr, &b_out->busy); 172 test_and_clear_bit(buf_nr, &b_out->busy);
173 173
174 if (unlikely(urb->status < 0)) { 174 if (unlikely(urb->status < 0)) {
175 if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) { 175 switch (urb->status) {
176 WARN("urb status %d",urb->status); 176 case -ENOENT:
177 if (b_out->busy == 0) { 177 case -ESHUTDOWN:
178 st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL); 178 case -ECONNRESET:
179 } 179 DBG(4,"urb killed status %d", urb->status);
180 } else { 180 return; // Give up
181 DBG(1,"urb killed"); 181 default:
182 return; // Give up 182 WARN("urb status %d",urb->status);
183 if (b_out->busy == 0) {
184 st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL);
185 }
186 break;
183 } 187 }
184 } 188 }
185 189
diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c
index 071b1d31999f..941f7022ada1 100644
--- a/drivers/isdn/hisax/st5481_d.c
+++ b/drivers/isdn/hisax/st5481_d.c
@@ -382,16 +382,20 @@ static void usb_d_out_complete(struct urb *urb, struct pt_regs *regs)
382 test_and_clear_bit(buf_nr, &d_out->busy); 382 test_and_clear_bit(buf_nr, &d_out->busy);
383 383
384 if (unlikely(urb->status < 0)) { 384 if (unlikely(urb->status < 0)) {
385 if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) { 385 switch (urb->status) {
386 WARN("urb status %d",urb->status); 386 case -ENOENT:
387 if (d_out->busy == 0) { 387 case -ESHUTDOWN:
388 st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter); 388 case -ECONNRESET:
389 } 389 DBG(1,"urb killed status %d", urb->status);
390 return; 390 break;
391 } else { 391 default:
392 DBG(1,"urb killed"); 392 WARN("urb status %d",urb->status);
393 return; // Give up 393 if (d_out->busy == 0) {
394 st5481_usb_pipe_reset(adapter, EP_D_OUT | USB_DIR_OUT, fifo_reseted, adapter);
395 }
396 break;
394 } 397 }
398 return; // Give up
395 } 399 }
396 400
397 FsmEvent(&adapter->d_out.fsm, EV_DOUT_COMPLETE, (void *) buf_nr); 401 FsmEvent(&adapter->d_out.fsm, EV_DOUT_COMPLETE, (void *) buf_nr);
@@ -709,14 +713,14 @@ int st5481_setup_d(struct st5481_adapter *adapter)
709 713
710 adapter->l1m.fsm = &l1fsm; 714 adapter->l1m.fsm = &l1fsm;
711 adapter->l1m.state = ST_L1_F3; 715 adapter->l1m.state = ST_L1_F3;
712 adapter->l1m.debug = 1; 716 adapter->l1m.debug = st5481_debug & 0x100;
713 adapter->l1m.userdata = adapter; 717 adapter->l1m.userdata = adapter;
714 adapter->l1m.printdebug = l1m_debug; 718 adapter->l1m.printdebug = l1m_debug;
715 FsmInitTimer(&adapter->l1m, &adapter->timer); 719 FsmInitTimer(&adapter->l1m, &adapter->timer);
716 720
717 adapter->d_out.fsm.fsm = &dout_fsm; 721 adapter->d_out.fsm.fsm = &dout_fsm;
718 adapter->d_out.fsm.state = ST_DOUT_NONE; 722 adapter->d_out.fsm.state = ST_DOUT_NONE;
719 adapter->d_out.fsm.debug = 1; 723 adapter->d_out.fsm.debug = st5481_debug & 0x100;
720 adapter->d_out.fsm.userdata = adapter; 724 adapter->d_out.fsm.userdata = adapter;
721 adapter->d_out.fsm.printdebug = dout_debug; 725 adapter->d_out.fsm.printdebug = dout_debug;
722 726
diff --git a/drivers/isdn/hisax/st5481_init.c b/drivers/isdn/hisax/st5481_init.c
index 7aa810d5d333..2cf5d1a6df6c 100644
--- a/drivers/isdn/hisax/st5481_init.c
+++ b/drivers/isdn/hisax/st5481_init.c
@@ -43,10 +43,10 @@ static int number_of_leds = 2; /* 2 LEDs on the adpater default */
43module_param(number_of_leds, int, 0); 43module_param(number_of_leds, int, 0);
44 44
45#ifdef CONFIG_HISAX_DEBUG 45#ifdef CONFIG_HISAX_DEBUG
46static int debug = 0x1; 46static int debug = 0;
47module_param(debug, int, 0); 47module_param(debug, int, 0);
48int st5481_debug;
49#endif 48#endif
49int st5481_debug;
50 50
51static LIST_HEAD(adapter_list); 51static LIST_HEAD(adapter_list);
52 52
diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c
index ab62223297a5..89fbeb58485d 100644
--- a/drivers/isdn/hisax/st5481_usb.c
+++ b/drivers/isdn/hisax/st5481_usb.c
@@ -132,11 +132,15 @@ static void usb_ctrl_complete(struct urb *urb, struct pt_regs *regs)
132 struct ctrl_msg *ctrl_msg; 132 struct ctrl_msg *ctrl_msg;
133 133
134 if (unlikely(urb->status < 0)) { 134 if (unlikely(urb->status < 0)) {
135 if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) { 135 switch (urb->status) {
136 WARN("urb status %d",urb->status); 136 case -ENOENT:
137 } else { 137 case -ESHUTDOWN:
138 DBG(1,"urb killed"); 138 case -ECONNRESET:
139 return; // Give up 139 DBG(1,"urb killed status %d", urb->status);
140 return; // Give up
141 default:
142 WARN("urb status %d",urb->status);
143 break;
140 } 144 }
141 } 145 }
142 146
@@ -184,22 +188,22 @@ static void usb_int_complete(struct urb *urb, struct pt_regs *regs)
184 int status; 188 int status;
185 189
186 switch (urb->status) { 190 switch (urb->status) {
187 case 0: 191 case 0:
188 /* success */ 192 /* success */
189 break; 193 break;
190 case -ECONNRESET: 194 case -ECONNRESET:
191 case -ENOENT: 195 case -ENOENT:
192 case -ESHUTDOWN: 196 case -ESHUTDOWN:
193 /* this urb is terminated, clean up */ 197 /* this urb is terminated, clean up */
194 DBG(1, "urb shutting down with status: %d", urb->status); 198 DBG(2, "urb shutting down with status: %d", urb->status);
195 return; 199 return;
196 default: 200 default:
197 WARN("nonzero urb status received: %d", urb->status); 201 WARN("nonzero urb status received: %d", urb->status);
198 goto exit; 202 goto exit;
199 } 203 }
200 204
201 205
202 DBG_PACKET(1, data, INT_PKT_SIZE); 206 DBG_PACKET(2, data, INT_PKT_SIZE);
203 207
204 if (urb->actual_length == 0) { 208 if (urb->actual_length == 0) {
205 goto exit; 209 goto exit;
@@ -250,7 +254,7 @@ int st5481_setup_usb(struct st5481_adapter *adapter)
250 struct urb *urb; 254 struct urb *urb;
251 u8 *buf; 255 u8 *buf;
252 256
253 DBG(1,""); 257 DBG(2,"");
254 258
255 if ((status = usb_reset_configuration (dev)) < 0) { 259 if ((status = usb_reset_configuration (dev)) < 0) {
256 WARN("reset_configuration failed,status=%d",status); 260 WARN("reset_configuration failed,status=%d",status);
@@ -330,15 +334,17 @@ void st5481_release_usb(struct st5481_adapter *adapter)
330 DBG(1,""); 334 DBG(1,"");
331 335
332 // Stop and free Control and Interrupt URBs 336 // Stop and free Control and Interrupt URBs
333 usb_unlink_urb(ctrl->urb); 337 usb_kill_urb(ctrl->urb);
334 if (ctrl->urb->transfer_buffer) 338 if (ctrl->urb->transfer_buffer)
335 kfree(ctrl->urb->transfer_buffer); 339 kfree(ctrl->urb->transfer_buffer);
336 usb_free_urb(ctrl->urb); 340 usb_free_urb(ctrl->urb);
341 ctrl->urb = NULL;
337 342
338 usb_unlink_urb(intr->urb); 343 usb_kill_urb(intr->urb);
339 if (intr->urb->transfer_buffer) 344 if (intr->urb->transfer_buffer)
340 kfree(intr->urb->transfer_buffer); 345 kfree(intr->urb->transfer_buffer);
341 usb_free_urb(intr->urb); 346 usb_free_urb(intr->urb);
347 ctrl->urb = NULL;
342} 348}
343 349
344/* 350/*
@@ -406,6 +412,7 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev,
406 spin_lock_init(&urb->lock); 412 spin_lock_init(&urb->lock);
407 urb->dev=dev; 413 urb->dev=dev;
408 urb->pipe=pipe; 414 urb->pipe=pipe;
415 urb->interval = 1;
409 urb->transfer_buffer=buf; 416 urb->transfer_buffer=buf;
410 urb->number_of_packets = num_packets; 417 urb->number_of_packets = num_packets;
411 urb->transfer_buffer_length=num_packets*packet_size; 418 urb->transfer_buffer_length=num_packets*packet_size;
@@ -452,7 +459,9 @@ st5481_setup_isocpipes(struct urb* urb[2], struct usb_device *dev,
452 if (urb[j]) { 459 if (urb[j]) {
453 if (urb[j]->transfer_buffer) 460 if (urb[j]->transfer_buffer)
454 kfree(urb[j]->transfer_buffer); 461 kfree(urb[j]->transfer_buffer);
462 urb[j]->transfer_buffer = NULL;
455 usb_free_urb(urb[j]); 463 usb_free_urb(urb[j]);
464 urb[j] = NULL;
456 } 465 }
457 } 466 }
458 return retval; 467 return retval;
@@ -463,10 +472,11 @@ void st5481_release_isocpipes(struct urb* urb[2])
463 int j; 472 int j;
464 473
465 for (j = 0; j < 2; j++) { 474 for (j = 0; j < 2; j++) {
466 usb_unlink_urb(urb[j]); 475 usb_kill_urb(urb[j]);
467 if (urb[j]->transfer_buffer) 476 if (urb[j]->transfer_buffer)
468 kfree(urb[j]->transfer_buffer); 477 kfree(urb[j]->transfer_buffer);
469 usb_free_urb(urb[j]); 478 usb_free_urb(urb[j]);
479 urb[j] = NULL;
470 } 480 }
471} 481}
472 482
@@ -485,11 +495,15 @@ static void usb_in_complete(struct urb *urb, struct pt_regs *regs)
485 int len, count, status; 495 int len, count, status;
486 496
487 if (unlikely(urb->status < 0)) { 497 if (unlikely(urb->status < 0)) {
488 if (urb->status != -ENOENT && urb->status != -ESHUTDOWN) { 498 switch (urb->status) {
489 WARN("urb status %d",urb->status); 499 case -ENOENT:
490 } else { 500 case -ESHUTDOWN:
491 DBG(1,"urb killed"); 501 case -ECONNRESET:
492 return; // Give up 502 DBG(1,"urb killed status %d", urb->status);
503 return; // Give up
504 default:
505 WARN("urb status %d",urb->status);
506 break;
493 } 507 }
494 } 508 }
495 509
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 5da507e532fc..639582f61f41 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -394,7 +394,7 @@ hysdn_procconf_init(void)
394 hysdn_card *card; 394 hysdn_card *card;
395 uchar conf_name[20]; 395 uchar conf_name[20];
396 396
397 hysdn_proc_entry = create_proc_entry(PROC_SUBDIR_NAME, S_IFDIR | S_IRUGO | S_IXUGO, proc_net); 397 hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
398 if (!hysdn_proc_entry) { 398 if (!hysdn_proc_entry) {
399 printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n"); 399 printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n");
400 return (-1); 400 return (-1);
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index fb535737d17d..9b38674fbf75 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -8,21 +8,15 @@
8 */ 8 */
9 9
10/* 10/*
11 * For now, this driver includes:
12 * - RTC get & set
13 * - reboot & shutdown commands
14 * all synchronous with IRQ disabled (ugh)
15 *
16 * TODO: 11 * TODO:
17 * rework in a way the PMU driver works, that is asynchronous 12 * - maybe add timeout to commands ?
18 * with a queue of commands. I'll do that as soon as I have an 13 * - blocking version of time functions
19 * SMU based machine at hand. Some more cleanup is needed too, 14 * - polling version of i2c commands (including timer that works with
20 * like maybe fitting it into a platform device, etc... 15 * interrutps off)
21 * Also check what's up with cache coherency, and if we really 16 * - maybe avoid some data copies with i2c by directly using the smu cmd
22 * can't do better than flushing the cache, maybe build a table 17 * buffer and a lower level internal interface
23 * of command len/reply len like the PMU driver to only flush 18 * - understand SMU -> CPU events and implement reception of them via
24 * what is actually necessary. 19 * the userland interface
25 * --BenH.
26 */ 20 */
27 21
28#include <linux/config.h> 22#include <linux/config.h>
@@ -36,6 +30,11 @@
36#include <linux/jiffies.h> 30#include <linux/jiffies.h>
37#include <linux/interrupt.h> 31#include <linux/interrupt.h>
38#include <linux/rtc.h> 32#include <linux/rtc.h>
33#include <linux/completion.h>
34#include <linux/miscdevice.h>
35#include <linux/delay.h>
36#include <linux/sysdev.h>
37#include <linux/poll.h>
39 38
40#include <asm/byteorder.h> 39#include <asm/byteorder.h>
41#include <asm/io.h> 40#include <asm/io.h>
@@ -45,8 +44,13 @@
45#include <asm/smu.h> 44#include <asm/smu.h>
46#include <asm/sections.h> 45#include <asm/sections.h>
47#include <asm/abs_addr.h> 46#include <asm/abs_addr.h>
47#include <asm/uaccess.h>
48#include <asm/of_device.h>
49
50#define VERSION "0.6"
51#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp."
48 52
49#define DEBUG_SMU 1 53#undef DEBUG_SMU
50 54
51#ifdef DEBUG_SMU 55#ifdef DEBUG_SMU
52#define DPRINTK(fmt, args...) do { printk(KERN_DEBUG fmt , ##args); } while (0) 56#define DPRINTK(fmt, args...) do { printk(KERN_DEBUG fmt , ##args); } while (0)
@@ -57,20 +61,30 @@
57/* 61/*
58 * This is the command buffer passed to the SMU hardware 62 * This is the command buffer passed to the SMU hardware
59 */ 63 */
64#define SMU_MAX_DATA 254
65
60struct smu_cmd_buf { 66struct smu_cmd_buf {
61 u8 cmd; 67 u8 cmd;
62 u8 length; 68 u8 length;
63 u8 data[0x0FFE]; 69 u8 data[SMU_MAX_DATA];
64}; 70};
65 71
66struct smu_device { 72struct smu_device {
67 spinlock_t lock; 73 spinlock_t lock;
68 struct device_node *of_node; 74 struct device_node *of_node;
69 int db_ack; /* doorbell ack GPIO */ 75 struct of_device *of_dev;
70 int db_req; /* doorbell req GPIO */ 76 int doorbell; /* doorbell gpio */
71 u32 __iomem *db_buf; /* doorbell buffer */ 77 u32 __iomem *db_buf; /* doorbell buffer */
78 int db_irq;
79 int msg;
80 int msg_irq;
72 struct smu_cmd_buf *cmd_buf; /* command buffer virtual */ 81 struct smu_cmd_buf *cmd_buf; /* command buffer virtual */
73 u32 cmd_buf_abs; /* command buffer absolute */ 82 u32 cmd_buf_abs; /* command buffer absolute */
83 struct list_head cmd_list;
84 struct smu_cmd *cmd_cur; /* pending command */
85 struct list_head cmd_i2c_list;
86 struct smu_i2c_cmd *cmd_i2c_cur; /* pending i2c command */
87 struct timer_list i2c_timer;
74}; 88};
75 89
76/* 90/*
@@ -79,113 +93,245 @@ struct smu_device {
79 */ 93 */
80static struct smu_device *smu; 94static struct smu_device *smu;
81 95
96
82/* 97/*
83 * SMU low level communication stuff 98 * SMU driver low level stuff
84 */ 99 */
85static inline int smu_cmd_stat(struct smu_cmd_buf *cmd_buf, u8 cmd_ack)
86{
87 rmb();
88 return cmd_buf->cmd == cmd_ack && cmd_buf->length != 0;
89}
90 100
91static inline u8 smu_save_ack_cmd(struct smu_cmd_buf *cmd_buf) 101static void smu_start_cmd(void)
92{ 102{
93 return (~cmd_buf->cmd) & 0xff; 103 unsigned long faddr, fend;
94} 104 struct smu_cmd *cmd;
95 105
96static void smu_send_cmd(struct smu_device *dev) 106 if (list_empty(&smu->cmd_list))
97{ 107 return;
98 /* SMU command buf is currently cacheable, we need a physical 108
99 * address. This isn't exactly a DMA mapping here, I suspect 109 /* Fetch first command in queue */
110 cmd = list_entry(smu->cmd_list.next, struct smu_cmd, link);
111 smu->cmd_cur = cmd;
112 list_del(&cmd->link);
113
114 DPRINTK("SMU: starting cmd %x, %d bytes data\n", cmd->cmd,
115 cmd->data_len);
116 DPRINTK("SMU: data buffer: %02x %02x %02x %02x ...\n",
117 ((u8 *)cmd->data_buf)[0], ((u8 *)cmd->data_buf)[1],
118 ((u8 *)cmd->data_buf)[2], ((u8 *)cmd->data_buf)[3]);
119
120 /* Fill the SMU command buffer */
121 smu->cmd_buf->cmd = cmd->cmd;
122 smu->cmd_buf->length = cmd->data_len;
123 memcpy(smu->cmd_buf->data, cmd->data_buf, cmd->data_len);
124
125 /* Flush command and data to RAM */
126 faddr = (unsigned long)smu->cmd_buf;
127 fend = faddr + smu->cmd_buf->length + 2;
128 flush_inval_dcache_range(faddr, fend);
129
130 /* This isn't exactly a DMA mapping here, I suspect
100 * the SMU is actually communicating with us via i2c to the 131 * the SMU is actually communicating with us via i2c to the
101 * northbridge or the CPU to access RAM. 132 * northbridge or the CPU to access RAM.
102 */ 133 */
103 writel(dev->cmd_buf_abs, dev->db_buf); 134 writel(smu->cmd_buf_abs, smu->db_buf);
104 135
105 /* Ring the SMU doorbell */ 136 /* Ring the SMU doorbell */
106 pmac_do_feature_call(PMAC_FTR_WRITE_GPIO, NULL, dev->db_req, 4); 137 pmac_do_feature_call(PMAC_FTR_WRITE_GPIO, NULL, smu->doorbell, 4);
107 pmac_do_feature_call(PMAC_FTR_READ_GPIO, NULL, dev->db_req, 4);
108} 138}
109 139
110static int smu_cmd_done(struct smu_device *dev) 140
141static irqreturn_t smu_db_intr(int irq, void *arg, struct pt_regs *regs)
111{ 142{
112 unsigned long wait = 0; 143 unsigned long flags;
113 int gpio; 144 struct smu_cmd *cmd;
145 void (*done)(struct smu_cmd *cmd, void *misc) = NULL;
146 void *misc = NULL;
147 u8 gpio;
148 int rc = 0;
114 149
115 /* Check the SMU doorbell */ 150 /* SMU completed the command, well, we hope, let's make sure
116 do { 151 * of it
117 gpio = pmac_do_feature_call(PMAC_FTR_READ_GPIO, 152 */
118 NULL, dev->db_ack); 153 spin_lock_irqsave(&smu->lock, flags);
119 if ((gpio & 7) == 7)
120 return 0;
121 udelay(100);
122 } while(++wait < 10000);
123 154
124 printk(KERN_ERR "SMU timeout !\n"); 155 gpio = pmac_do_feature_call(PMAC_FTR_READ_GPIO, NULL, smu->doorbell);
125 return -ENXIO; 156 if ((gpio & 7) != 7) {
157 spin_unlock_irqrestore(&smu->lock, flags);
158 return IRQ_HANDLED;
159 }
160
161 cmd = smu->cmd_cur;
162 smu->cmd_cur = NULL;
163 if (cmd == NULL)
164 goto bail;
165
166 if (rc == 0) {
167 unsigned long faddr;
168 int reply_len;
169 u8 ack;
170
171 /* CPU might have brought back the cache line, so we need
172 * to flush again before peeking at the SMU response. We
173 * flush the entire buffer for now as we haven't read the
174 * reply lenght (it's only 2 cache lines anyway)
175 */
176 faddr = (unsigned long)smu->cmd_buf;
177 flush_inval_dcache_range(faddr, faddr + 256);
178
179 /* Now check ack */
180 ack = (~cmd->cmd) & 0xff;
181 if (ack != smu->cmd_buf->cmd) {
182 DPRINTK("SMU: incorrect ack, want %x got %x\n",
183 ack, smu->cmd_buf->cmd);
184 rc = -EIO;
185 }
186 reply_len = rc == 0 ? smu->cmd_buf->length : 0;
187 DPRINTK("SMU: reply len: %d\n", reply_len);
188 if (reply_len > cmd->reply_len) {
189 printk(KERN_WARNING "SMU: reply buffer too small,"
190 "got %d bytes for a %d bytes buffer\n",
191 reply_len, cmd->reply_len);
192 reply_len = cmd->reply_len;
193 }
194 cmd->reply_len = reply_len;
195 if (cmd->reply_buf && reply_len)
196 memcpy(cmd->reply_buf, smu->cmd_buf->data, reply_len);
197 }
198
199 /* Now complete the command. Write status last in order as we lost
200 * ownership of the command structure as soon as it's no longer -1
201 */
202 done = cmd->done;
203 misc = cmd->misc;
204 mb();
205 cmd->status = rc;
206 bail:
207 /* Start next command if any */
208 smu_start_cmd();
209 spin_unlock_irqrestore(&smu->lock, flags);
210
211 /* Call command completion handler if any */
212 if (done)
213 done(cmd, misc);
214
215 /* It's an edge interrupt, nothing to do */
216 return IRQ_HANDLED;
126} 217}
127 218
128static int smu_do_cmd(struct smu_device *dev) 219
220static irqreturn_t smu_msg_intr(int irq, void *arg, struct pt_regs *regs)
129{ 221{
130 int rc; 222 /* I don't quite know what to do with this one, we seem to never
131 u8 cmd_ack; 223 * receive it, so I suspect we have to arm it someway in the SMU
224 * to start getting events that way.
225 */
132 226
133 DPRINTK("SMU do_cmd %02x len=%d %02x\n", 227 printk(KERN_INFO "SMU: message interrupt !\n");
134 dev->cmd_buf->cmd, dev->cmd_buf->length,
135 dev->cmd_buf->data[0]);
136 228
137 cmd_ack = smu_save_ack_cmd(dev->cmd_buf); 229 /* It's an edge interrupt, nothing to do */
230 return IRQ_HANDLED;
231}
138 232
139 /* Clear cmd_buf cache lines */
140 flush_inval_dcache_range((unsigned long)dev->cmd_buf,
141 ((unsigned long)dev->cmd_buf) +
142 sizeof(struct smu_cmd_buf));
143 smu_send_cmd(dev);
144 rc = smu_cmd_done(dev);
145 if (rc == 0)
146 rc = smu_cmd_stat(dev->cmd_buf, cmd_ack) ? 0 : -1;
147 233
148 DPRINTK("SMU do_cmd %02x len=%d %02x => %d (%02x)\n", 234/*
149 dev->cmd_buf->cmd, dev->cmd_buf->length, 235 * Queued command management.
150 dev->cmd_buf->data[0], rc, cmd_ack); 236 *
237 */
238
239int smu_queue_cmd(struct smu_cmd *cmd)
240{
241 unsigned long flags;
151 242
152 return rc; 243 if (smu == NULL)
244 return -ENODEV;
245 if (cmd->data_len > SMU_MAX_DATA ||
246 cmd->reply_len > SMU_MAX_DATA)
247 return -EINVAL;
248
249 cmd->status = 1;
250 spin_lock_irqsave(&smu->lock, flags);
251 list_add_tail(&cmd->link, &smu->cmd_list);
252 if (smu->cmd_cur == NULL)
253 smu_start_cmd();
254 spin_unlock_irqrestore(&smu->lock, flags);
255
256 return 0;
153} 257}
258EXPORT_SYMBOL(smu_queue_cmd);
154 259
155/* RTC low level commands */ 260
156static inline int bcd2hex (int n) 261int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command,
262 unsigned int data_len,
263 void (*done)(struct smu_cmd *cmd, void *misc),
264 void *misc, ...)
157{ 265{
158 return (((n & 0xf0) >> 4) * 10) + (n & 0xf); 266 struct smu_cmd *cmd = &scmd->cmd;
267 va_list list;
268 int i;
269
270 if (data_len > sizeof(scmd->buffer))
271 return -EINVAL;
272
273 memset(scmd, 0, sizeof(*scmd));
274 cmd->cmd = command;
275 cmd->data_len = data_len;
276 cmd->data_buf = scmd->buffer;
277 cmd->reply_len = sizeof(scmd->buffer);
278 cmd->reply_buf = scmd->buffer;
279 cmd->done = done;
280 cmd->misc = misc;
281
282 va_start(list, misc);
283 for (i = 0; i < data_len; ++i)
284 scmd->buffer[i] = (u8)va_arg(list, int);
285 va_end(list);
286
287 return smu_queue_cmd(cmd);
159} 288}
289EXPORT_SYMBOL(smu_queue_simple);
160 290
161static inline int hex2bcd (int n) 291
292void smu_poll(void)
162{ 293{
163 return ((n / 10) << 4) + (n % 10); 294 u8 gpio;
295
296 if (smu == NULL)
297 return;
298
299 gpio = pmac_do_feature_call(PMAC_FTR_READ_GPIO, NULL, smu->doorbell);
300 if ((gpio & 7) == 7)
301 smu_db_intr(smu->db_irq, smu, NULL);
164} 302}
303EXPORT_SYMBOL(smu_poll);
165 304
166#if 0 305
167static inline void smu_fill_set_pwrup_timer_cmd(struct smu_cmd_buf *cmd_buf) 306void smu_done_complete(struct smu_cmd *cmd, void *misc)
168{ 307{
169 cmd_buf->cmd = 0x8e; 308 struct completion *comp = misc;
170 cmd_buf->length = 8; 309
171 cmd_buf->data[0] = 0x00; 310 complete(comp);
172 memset(cmd_buf->data + 1, 0, 7);
173} 311}
312EXPORT_SYMBOL(smu_done_complete);
313
174 314
175static inline void smu_fill_get_pwrup_timer_cmd(struct smu_cmd_buf *cmd_buf) 315void smu_spinwait_cmd(struct smu_cmd *cmd)
176{ 316{
177 cmd_buf->cmd = 0x8e; 317 while(cmd->status == 1)
178 cmd_buf->length = 1; 318 smu_poll();
179 cmd_buf->data[0] = 0x01;
180} 319}
320EXPORT_SYMBOL(smu_spinwait_cmd);
321
181 322
182static inline void smu_fill_dis_pwrup_timer_cmd(struct smu_cmd_buf *cmd_buf) 323/* RTC low level commands */
324static inline int bcd2hex (int n)
183{ 325{
184 cmd_buf->cmd = 0x8e; 326 return (((n & 0xf0) >> 4) * 10) + (n & 0xf);
185 cmd_buf->length = 1;
186 cmd_buf->data[0] = 0x02;
187} 327}
188#endif 328
329
330static inline int hex2bcd (int n)
331{
332 return ((n / 10) << 4) + (n % 10);
333}
334
189 335
190static inline void smu_fill_set_rtc_cmd(struct smu_cmd_buf *cmd_buf, 336static inline void smu_fill_set_rtc_cmd(struct smu_cmd_buf *cmd_buf,
191 struct rtc_time *time) 337 struct rtc_time *time)
@@ -202,100 +348,96 @@ static inline void smu_fill_set_rtc_cmd(struct smu_cmd_buf *cmd_buf,
202 cmd_buf->data[7] = hex2bcd(time->tm_year - 100); 348 cmd_buf->data[7] = hex2bcd(time->tm_year - 100);
203} 349}
204 350
205static inline void smu_fill_get_rtc_cmd(struct smu_cmd_buf *cmd_buf)
206{
207 cmd_buf->cmd = 0x8e;
208 cmd_buf->length = 1;
209 cmd_buf->data[0] = 0x81;
210}
211 351
212static void smu_parse_get_rtc_reply(struct smu_cmd_buf *cmd_buf, 352int smu_get_rtc_time(struct rtc_time *time, int spinwait)
213 struct rtc_time *time)
214{ 353{
215 time->tm_sec = bcd2hex(cmd_buf->data[0]); 354 struct smu_simple_cmd cmd;
216 time->tm_min = bcd2hex(cmd_buf->data[1]);
217 time->tm_hour = bcd2hex(cmd_buf->data[2]);
218 time->tm_wday = bcd2hex(cmd_buf->data[3]);
219 time->tm_mday = bcd2hex(cmd_buf->data[4]);
220 time->tm_mon = bcd2hex(cmd_buf->data[5]) - 1;
221 time->tm_year = bcd2hex(cmd_buf->data[6]) + 100;
222}
223
224int smu_get_rtc_time(struct rtc_time *time)
225{
226 unsigned long flags;
227 int rc; 355 int rc;
228 356
229 if (smu == NULL) 357 if (smu == NULL)
230 return -ENODEV; 358 return -ENODEV;
231 359
232 memset(time, 0, sizeof(struct rtc_time)); 360 memset(time, 0, sizeof(struct rtc_time));
233 spin_lock_irqsave(&smu->lock, flags); 361 rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 1, NULL, NULL,
234 smu_fill_get_rtc_cmd(smu->cmd_buf); 362 SMU_CMD_RTC_GET_DATETIME);
235 rc = smu_do_cmd(smu); 363 if (rc)
236 if (rc == 0) 364 return rc;
237 smu_parse_get_rtc_reply(smu->cmd_buf, time); 365 smu_spinwait_simple(&cmd);
238 spin_unlock_irqrestore(&smu->lock, flags);
239 366
240 return rc; 367 time->tm_sec = bcd2hex(cmd.buffer[0]);
368 time->tm_min = bcd2hex(cmd.buffer[1]);
369 time->tm_hour = bcd2hex(cmd.buffer[2]);
370 time->tm_wday = bcd2hex(cmd.buffer[3]);
371 time->tm_mday = bcd2hex(cmd.buffer[4]);
372 time->tm_mon = bcd2hex(cmd.buffer[5]) - 1;
373 time->tm_year = bcd2hex(cmd.buffer[6]) + 100;
374
375 return 0;
241} 376}
242 377
243int smu_set_rtc_time(struct rtc_time *time) 378
379int smu_set_rtc_time(struct rtc_time *time, int spinwait)
244{ 380{
245 unsigned long flags; 381 struct smu_simple_cmd cmd;
246 int rc; 382 int rc;
247 383
248 if (smu == NULL) 384 if (smu == NULL)
249 return -ENODEV; 385 return -ENODEV;
250 386
251 spin_lock_irqsave(&smu->lock, flags); 387 rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 8, NULL, NULL,
252 smu_fill_set_rtc_cmd(smu->cmd_buf, time); 388 SMU_CMD_RTC_SET_DATETIME,
253 rc = smu_do_cmd(smu); 389 hex2bcd(time->tm_sec),
254 spin_unlock_irqrestore(&smu->lock, flags); 390 hex2bcd(time->tm_min),
391 hex2bcd(time->tm_hour),
392 time->tm_wday,
393 hex2bcd(time->tm_mday),
394 hex2bcd(time->tm_mon) + 1,
395 hex2bcd(time->tm_year - 100));
396 if (rc)
397 return rc;
398 smu_spinwait_simple(&cmd);
255 399
256 return rc; 400 return 0;
257} 401}
258 402
403
259void smu_shutdown(void) 404void smu_shutdown(void)
260{ 405{
261 const unsigned char *command = "SHUTDOWN"; 406 struct smu_simple_cmd cmd;
262 unsigned long flags;
263 407
264 if (smu == NULL) 408 if (smu == NULL)
265 return; 409 return;
266 410
267 spin_lock_irqsave(&smu->lock, flags); 411 if (smu_queue_simple(&cmd, SMU_CMD_POWER_COMMAND, 9, NULL, NULL,
268 smu->cmd_buf->cmd = 0xaa; 412 'S', 'H', 'U', 'T', 'D', 'O', 'W', 'N', 0))
269 smu->cmd_buf->length = strlen(command); 413 return;
270 strcpy(smu->cmd_buf->data, command); 414 smu_spinwait_simple(&cmd);
271 smu_do_cmd(smu);
272 for (;;) 415 for (;;)
273 ; 416 ;
274 spin_unlock_irqrestore(&smu->lock, flags);
275} 417}
276 418
419
277void smu_restart(void) 420void smu_restart(void)
278{ 421{
279 const unsigned char *command = "RESTART"; 422 struct smu_simple_cmd cmd;
280 unsigned long flags;
281 423
282 if (smu == NULL) 424 if (smu == NULL)
283 return; 425 return;
284 426
285 spin_lock_irqsave(&smu->lock, flags); 427 if (smu_queue_simple(&cmd, SMU_CMD_POWER_COMMAND, 8, NULL, NULL,
286 smu->cmd_buf->cmd = 0xaa; 428 'R', 'E', 'S', 'T', 'A', 'R', 'T', 0))
287 smu->cmd_buf->length = strlen(command); 429 return;
288 strcpy(smu->cmd_buf->data, command); 430 smu_spinwait_simple(&cmd);
289 smu_do_cmd(smu);
290 for (;;) 431 for (;;)
291 ; 432 ;
292 spin_unlock_irqrestore(&smu->lock, flags);
293} 433}
294 434
435
295int smu_present(void) 436int smu_present(void)
296{ 437{
297 return smu != NULL; 438 return smu != NULL;
298} 439}
440EXPORT_SYMBOL(smu_present);
299 441
300 442
301int smu_init (void) 443int smu_init (void)
@@ -307,6 +449,8 @@ int smu_init (void)
307 if (np == NULL) 449 if (np == NULL)
308 return -ENODEV; 450 return -ENODEV;
309 451
452 printk(KERN_INFO "SMU driver %s %s\n", VERSION, AUTHOR);
453
310 if (smu_cmdbuf_abs == 0) { 454 if (smu_cmdbuf_abs == 0) {
311 printk(KERN_ERR "SMU: Command buffer not allocated !\n"); 455 printk(KERN_ERR "SMU: Command buffer not allocated !\n");
312 return -EINVAL; 456 return -EINVAL;
@@ -318,7 +462,13 @@ int smu_init (void)
318 memset(smu, 0, sizeof(*smu)); 462 memset(smu, 0, sizeof(*smu));
319 463
320 spin_lock_init(&smu->lock); 464 spin_lock_init(&smu->lock);
465 INIT_LIST_HEAD(&smu->cmd_list);
466 INIT_LIST_HEAD(&smu->cmd_i2c_list);
321 smu->of_node = np; 467 smu->of_node = np;
468 smu->db_irq = NO_IRQ;
469 smu->msg_irq = NO_IRQ;
470 init_timer(&smu->i2c_timer);
471
322 /* smu_cmdbuf_abs is in the low 2G of RAM, can be converted to a 472 /* smu_cmdbuf_abs is in the low 2G of RAM, can be converted to a
323 * 32 bits value safely 473 * 32 bits value safely
324 */ 474 */
@@ -331,8 +481,8 @@ int smu_init (void)
331 goto fail; 481 goto fail;
332 } 482 }
333 data = (u32 *)get_property(np, "reg", NULL); 483 data = (u32 *)get_property(np, "reg", NULL);
334 of_node_put(np);
335 if (data == NULL) { 484 if (data == NULL) {
485 of_node_put(np);
336 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n"); 486 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n");
337 goto fail; 487 goto fail;
338 } 488 }
@@ -341,8 +491,31 @@ int smu_init (void)
341 * and ack. GPIOs are at 0x50, best would be to find that out 491 * and ack. GPIOs are at 0x50, best would be to find that out
342 * in the device-tree though. 492 * in the device-tree though.
343 */ 493 */
344 smu->db_req = 0x50 + *data; 494 smu->doorbell = *data;
345 smu->db_ack = 0x50 + *data; 495 if (smu->doorbell < 0x50)
496 smu->doorbell += 0x50;
497 if (np->n_intrs > 0)
498 smu->db_irq = np->intrs[0].line;
499
500 of_node_put(np);
501
502 /* Now look for the smu-interrupt GPIO */
503 do {
504 np = of_find_node_by_name(NULL, "smu-interrupt");
505 if (np == NULL)
506 break;
507 data = (u32 *)get_property(np, "reg", NULL);
508 if (data == NULL) {
509 of_node_put(np);
510 break;
511 }
512 smu->msg = *data;
513 if (smu->msg < 0x50)
514 smu->msg += 0x50;
515 if (np->n_intrs > 0)
516 smu->msg_irq = np->intrs[0].line;
517 of_node_put(np);
518 } while(0);
346 519
347 /* Doorbell buffer is currently hard-coded, I didn't find a proper 520 /* Doorbell buffer is currently hard-coded, I didn't find a proper
348 * device-tree entry giving the address. Best would probably to use 521 * device-tree entry giving the address. Best would probably to use
@@ -362,3 +535,584 @@ int smu_init (void)
362 return -ENXIO; 535 return -ENXIO;
363 536
364} 537}
538
539
540static int smu_late_init(void)
541{
542 if (!smu)
543 return 0;
544
545 /*
546 * Try to request the interrupts
547 */
548
549 if (smu->db_irq != NO_IRQ) {
550 if (request_irq(smu->db_irq, smu_db_intr,
551 SA_SHIRQ, "SMU doorbell", smu) < 0) {
552 printk(KERN_WARNING "SMU: can't "
553 "request interrupt %d\n",
554 smu->db_irq);
555 smu->db_irq = NO_IRQ;
556 }
557 }
558
559 if (smu->msg_irq != NO_IRQ) {
560 if (request_irq(smu->msg_irq, smu_msg_intr,
561 SA_SHIRQ, "SMU message", smu) < 0) {
562 printk(KERN_WARNING "SMU: can't "
563 "request interrupt %d\n",
564 smu->msg_irq);
565 smu->msg_irq = NO_IRQ;
566 }
567 }
568
569 return 0;
570}
571arch_initcall(smu_late_init);
572
573/*
574 * sysfs visibility
575 */
576
577static void smu_expose_childs(void *unused)
578{
579 struct device_node *np;
580
581 for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) {
582 if (device_is_compatible(np, "smu-i2c")) {
583 char name[32];
584 u32 *reg = (u32 *)get_property(np, "reg", NULL);
585
586 if (reg == NULL)
587 continue;
588 sprintf(name, "smu-i2c-%02x", *reg);
589 of_platform_device_create(np, name, &smu->of_dev->dev);
590 }
591 }
592
593}
594
595static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL);
596
597static int smu_platform_probe(struct of_device* dev,
598 const struct of_device_id *match)
599{
600 if (!smu)
601 return -ENODEV;
602 smu->of_dev = dev;
603
604 /*
605 * Ok, we are matched, now expose all i2c busses. We have to defer
606 * that unfortunately or it would deadlock inside the device model
607 */
608 schedule_work(&smu_expose_childs_work);
609
610 return 0;
611}
612
613static struct of_device_id smu_platform_match[] =
614{
615 {
616 .type = "smu",
617 },
618 {},
619};
620
621static struct of_platform_driver smu_of_platform_driver =
622{
623 .name = "smu",
624 .match_table = smu_platform_match,
625 .probe = smu_platform_probe,
626};
627
628static int __init smu_init_sysfs(void)
629{
630 int rc;
631
632 /*
633 * Due to sysfs bogosity, a sysdev is not a real device, so
634 * we should in fact create both if we want sysdev semantics
635 * for power management.
636 * For now, we don't power manage machines with an SMU chip,
637 * I'm a bit too far from figuring out how that works with those
638 * new chipsets, but that will come back and bite us
639 */
640 rc = of_register_driver(&smu_of_platform_driver);
641 return 0;
642}
643
644device_initcall(smu_init_sysfs);
645
646struct of_device *smu_get_ofdev(void)
647{
648 if (!smu)
649 return NULL;
650 return smu->of_dev;
651}
652
653EXPORT_SYMBOL_GPL(smu_get_ofdev);
654
655/*
656 * i2c interface
657 */
658
659static void smu_i2c_complete_command(struct smu_i2c_cmd *cmd, int fail)
660{
661 void (*done)(struct smu_i2c_cmd *cmd, void *misc) = cmd->done;
662 void *misc = cmd->misc;
663 unsigned long flags;
664
665 /* Check for read case */
666 if (!fail && cmd->read) {
667 if (cmd->pdata[0] < 1)
668 fail = 1;
669 else
670 memcpy(cmd->info.data, &cmd->pdata[1],
671 cmd->info.datalen);
672 }
673
674 DPRINTK("SMU: completing, success: %d\n", !fail);
675
676 /* Update status and mark no pending i2c command with lock
677 * held so nobody comes in while we dequeue an eventual
678 * pending next i2c command
679 */
680 spin_lock_irqsave(&smu->lock, flags);
681 smu->cmd_i2c_cur = NULL;
682 wmb();
683 cmd->status = fail ? -EIO : 0;
684
685 /* Is there another i2c command waiting ? */
686 if (!list_empty(&smu->cmd_i2c_list)) {
687 struct smu_i2c_cmd *newcmd;
688
689 /* Fetch it, new current, remove from list */
690 newcmd = list_entry(smu->cmd_i2c_list.next,
691 struct smu_i2c_cmd, link);
692 smu->cmd_i2c_cur = newcmd;
693 list_del(&cmd->link);
694
695 /* Queue with low level smu */
696 list_add_tail(&cmd->scmd.link, &smu->cmd_list);
697 if (smu->cmd_cur == NULL)
698 smu_start_cmd();
699 }
700 spin_unlock_irqrestore(&smu->lock, flags);
701
702 /* Call command completion handler if any */
703 if (done)
704 done(cmd, misc);
705
706}
707
708
709static void smu_i2c_retry(unsigned long data)
710{
711 struct smu_i2c_cmd *cmd = (struct smu_i2c_cmd *)data;
712
713 DPRINTK("SMU: i2c failure, requeuing...\n");
714
715 /* requeue command simply by resetting reply_len */
716 cmd->pdata[0] = 0xff;
717 cmd->scmd.reply_len = 0x10;
718 smu_queue_cmd(&cmd->scmd);
719}
720
721
722static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc)
723{
724 struct smu_i2c_cmd *cmd = misc;
725 int fail = 0;
726
727 DPRINTK("SMU: i2c compl. stage=%d status=%x pdata[0]=%x rlen: %x\n",
728 cmd->stage, scmd->status, cmd->pdata[0], scmd->reply_len);
729
730 /* Check for possible status */
731 if (scmd->status < 0)
732 fail = 1;
733 else if (cmd->read) {
734 if (cmd->stage == 0)
735 fail = cmd->pdata[0] != 0;
736 else
737 fail = cmd->pdata[0] >= 0x80;
738 } else {
739 fail = cmd->pdata[0] != 0;
740 }
741
742 /* Handle failures by requeuing command, after 5ms interval
743 */
744 if (fail && --cmd->retries > 0) {
745 DPRINTK("SMU: i2c failure, starting timer...\n");
746 smu->i2c_timer.function = smu_i2c_retry;
747 smu->i2c_timer.data = (unsigned long)cmd;
748 smu->i2c_timer.expires = jiffies + msecs_to_jiffies(5);
749 add_timer(&smu->i2c_timer);
750 return;
751 }
752
753 /* If failure or stage 1, command is complete */
754 if (fail || cmd->stage != 0) {
755 smu_i2c_complete_command(cmd, fail);
756 return;
757 }
758
759 DPRINTK("SMU: going to stage 1\n");
760
761 /* Ok, initial command complete, now poll status */
762 scmd->reply_buf = cmd->pdata;
763 scmd->reply_len = 0x10;
764 scmd->data_buf = cmd->pdata;
765 scmd->data_len = 1;
766 cmd->pdata[0] = 0;
767 cmd->stage = 1;
768 cmd->retries = 20;
769 smu_queue_cmd(scmd);
770}
771
772
773int smu_queue_i2c(struct smu_i2c_cmd *cmd)
774{
775 unsigned long flags;
776
777 if (smu == NULL)
778 return -ENODEV;
779
780 /* Fill most fields of scmd */
781 cmd->scmd.cmd = SMU_CMD_I2C_COMMAND;
782 cmd->scmd.done = smu_i2c_low_completion;
783 cmd->scmd.misc = cmd;
784 cmd->scmd.reply_buf = cmd->pdata;
785 cmd->scmd.reply_len = 0x10;
786 cmd->scmd.data_buf = (u8 *)(char *)&cmd->info;
787 cmd->scmd.status = 1;
788 cmd->stage = 0;
789 cmd->pdata[0] = 0xff;
790 cmd->retries = 20;
791 cmd->status = 1;
792
793 /* Check transfer type, sanitize some "info" fields
794 * based on transfer type and do more checking
795 */
796 cmd->info.caddr = cmd->info.devaddr;
797 cmd->read = cmd->info.devaddr & 0x01;
798 switch(cmd->info.type) {
799 case SMU_I2C_TRANSFER_SIMPLE:
800 memset(&cmd->info.sublen, 0, 4);
801 break;
802 case SMU_I2C_TRANSFER_COMBINED:
803 cmd->info.devaddr &= 0xfe;
804 case SMU_I2C_TRANSFER_STDSUB:
805 if (cmd->info.sublen > 3)
806 return -EINVAL;
807 break;
808 default:
809 return -EINVAL;
810 }
811
812 /* Finish setting up command based on transfer direction
813 */
814 if (cmd->read) {
815 if (cmd->info.datalen > SMU_I2C_READ_MAX)
816 return -EINVAL;
817 memset(cmd->info.data, 0xff, cmd->info.datalen);
818 cmd->scmd.data_len = 9;
819 } else {
820 if (cmd->info.datalen > SMU_I2C_WRITE_MAX)
821 return -EINVAL;
822 cmd->scmd.data_len = 9 + cmd->info.datalen;
823 }
824
825 DPRINTK("SMU: i2c enqueuing command\n");
826 DPRINTK("SMU: %s, len=%d bus=%x addr=%x sub0=%x type=%x\n",
827 cmd->read ? "read" : "write", cmd->info.datalen,
828 cmd->info.bus, cmd->info.caddr,
829 cmd->info.subaddr[0], cmd->info.type);
830
831
832 /* Enqueue command in i2c list, and if empty, enqueue also in
833 * main command list
834 */
835 spin_lock_irqsave(&smu->lock, flags);
836 if (smu->cmd_i2c_cur == NULL) {
837 smu->cmd_i2c_cur = cmd;
838 list_add_tail(&cmd->scmd.link, &smu->cmd_list);
839 if (smu->cmd_cur == NULL)
840 smu_start_cmd();
841 } else
842 list_add_tail(&cmd->link, &smu->cmd_i2c_list);
843 spin_unlock_irqrestore(&smu->lock, flags);
844
845 return 0;
846}
847
848
849
850/*
851 * Userland driver interface
852 */
853
854
855static LIST_HEAD(smu_clist);
856static DEFINE_SPINLOCK(smu_clist_lock);
857
858enum smu_file_mode {
859 smu_file_commands,
860 smu_file_events,
861 smu_file_closing
862};
863
864struct smu_private
865{
866 struct list_head list;
867 enum smu_file_mode mode;
868 int busy;
869 struct smu_cmd cmd;
870 spinlock_t lock;
871 wait_queue_head_t wait;
872 u8 buffer[SMU_MAX_DATA];
873};
874
875
876static int smu_open(struct inode *inode, struct file *file)
877{
878 struct smu_private *pp;
879 unsigned long flags;
880
881 pp = kmalloc(sizeof(struct smu_private), GFP_KERNEL);
882 if (pp == 0)
883 return -ENOMEM;
884 memset(pp, 0, sizeof(struct smu_private));
885 spin_lock_init(&pp->lock);
886 pp->mode = smu_file_commands;
887 init_waitqueue_head(&pp->wait);
888
889 spin_lock_irqsave(&smu_clist_lock, flags);
890 list_add(&pp->list, &smu_clist);
891 spin_unlock_irqrestore(&smu_clist_lock, flags);
892 file->private_data = pp;
893
894 return 0;
895}
896
897
898static void smu_user_cmd_done(struct smu_cmd *cmd, void *misc)
899{
900 struct smu_private *pp = misc;
901
902 wake_up_all(&pp->wait);
903}
904
905
906static ssize_t smu_write(struct file *file, const char __user *buf,
907 size_t count, loff_t *ppos)
908{
909 struct smu_private *pp = file->private_data;
910 unsigned long flags;
911 struct smu_user_cmd_hdr hdr;
912 int rc = 0;
913
914 if (pp->busy)
915 return -EBUSY;
916 else if (copy_from_user(&hdr, buf, sizeof(hdr)))
917 return -EFAULT;
918 else if (hdr.cmdtype == SMU_CMDTYPE_WANTS_EVENTS) {
919 pp->mode = smu_file_events;
920 return 0;
921 } else if (hdr.cmdtype != SMU_CMDTYPE_SMU)
922 return -EINVAL;
923 else if (pp->mode != smu_file_commands)
924 return -EBADFD;
925 else if (hdr.data_len > SMU_MAX_DATA)
926 return -EINVAL;
927
928 spin_lock_irqsave(&pp->lock, flags);
929 if (pp->busy) {
930 spin_unlock_irqrestore(&pp->lock, flags);
931 return -EBUSY;
932 }
933 pp->busy = 1;
934 pp->cmd.status = 1;
935 spin_unlock_irqrestore(&pp->lock, flags);
936
937 if (copy_from_user(pp->buffer, buf + sizeof(hdr), hdr.data_len)) {
938 pp->busy = 0;
939 return -EFAULT;
940 }
941
942 pp->cmd.cmd = hdr.cmd;
943 pp->cmd.data_len = hdr.data_len;
944 pp->cmd.reply_len = SMU_MAX_DATA;
945 pp->cmd.data_buf = pp->buffer;
946 pp->cmd.reply_buf = pp->buffer;
947 pp->cmd.done = smu_user_cmd_done;
948 pp->cmd.misc = pp;
949 rc = smu_queue_cmd(&pp->cmd);
950 if (rc < 0)
951 return rc;
952 return count;
953}
954
955
956static ssize_t smu_read_command(struct file *file, struct smu_private *pp,
957 char __user *buf, size_t count)
958{
959 DECLARE_WAITQUEUE(wait, current);
960 struct smu_user_reply_hdr hdr;
961 unsigned long flags;
962 int size, rc = 0;
963
964 if (!pp->busy)
965 return 0;
966 if (count < sizeof(struct smu_user_reply_hdr))
967 return -EOVERFLOW;
968 spin_lock_irqsave(&pp->lock, flags);
969 if (pp->cmd.status == 1) {
970 if (file->f_flags & O_NONBLOCK)
971 return -EAGAIN;
972 add_wait_queue(&pp->wait, &wait);
973 for (;;) {
974 set_current_state(TASK_INTERRUPTIBLE);
975 rc = 0;
976 if (pp->cmd.status != 1)
977 break;
978 rc = -ERESTARTSYS;
979 if (signal_pending(current))
980 break;
981 spin_unlock_irqrestore(&pp->lock, flags);
982 schedule();
983 spin_lock_irqsave(&pp->lock, flags);
984 }
985 set_current_state(TASK_RUNNING);
986 remove_wait_queue(&pp->wait, &wait);
987 }
988 spin_unlock_irqrestore(&pp->lock, flags);
989 if (rc)
990 return rc;
991 if (pp->cmd.status != 0)
992 pp->cmd.reply_len = 0;
993 size = sizeof(hdr) + pp->cmd.reply_len;
994 if (count < size)
995 size = count;
996 rc = size;
997 hdr.status = pp->cmd.status;
998 hdr.reply_len = pp->cmd.reply_len;
999 if (copy_to_user(buf, &hdr, sizeof(hdr)))
1000 return -EFAULT;
1001 size -= sizeof(hdr);
1002 if (size && copy_to_user(buf + sizeof(hdr), pp->buffer, size))
1003 return -EFAULT;
1004 pp->busy = 0;
1005
1006 return rc;
1007}
1008
1009
1010static ssize_t smu_read_events(struct file *file, struct smu_private *pp,
1011 char __user *buf, size_t count)
1012{
1013 /* Not implemented */
1014 msleep_interruptible(1000);
1015 return 0;
1016}
1017
1018
1019static ssize_t smu_read(struct file *file, char __user *buf,
1020 size_t count, loff_t *ppos)
1021{
1022 struct smu_private *pp = file->private_data;
1023
1024 if (pp->mode == smu_file_commands)
1025 return smu_read_command(file, pp, buf, count);
1026 if (pp->mode == smu_file_events)
1027 return smu_read_events(file, pp, buf, count);
1028
1029 return -EBADFD;
1030}
1031
1032static unsigned int smu_fpoll(struct file *file, poll_table *wait)
1033{
1034 struct smu_private *pp = file->private_data;
1035 unsigned int mask = 0;
1036 unsigned long flags;
1037
1038 if (pp == 0)
1039 return 0;
1040
1041 if (pp->mode == smu_file_commands) {
1042 poll_wait(file, &pp->wait, wait);
1043
1044 spin_lock_irqsave(&pp->lock, flags);
1045 if (pp->busy && pp->cmd.status != 1)
1046 mask |= POLLIN;
1047 spin_unlock_irqrestore(&pp->lock, flags);
1048 } if (pp->mode == smu_file_events) {
1049 /* Not yet implemented */
1050 }
1051 return mask;
1052}
1053
1054static int smu_release(struct inode *inode, struct file *file)
1055{
1056 struct smu_private *pp = file->private_data;
1057 unsigned long flags;
1058 unsigned int busy;
1059
1060 if (pp == 0)
1061 return 0;
1062
1063 file->private_data = NULL;
1064
1065 /* Mark file as closing to avoid races with new request */
1066 spin_lock_irqsave(&pp->lock, flags);
1067 pp->mode = smu_file_closing;
1068 busy = pp->busy;
1069
1070 /* Wait for any pending request to complete */
1071 if (busy && pp->cmd.status == 1) {
1072 DECLARE_WAITQUEUE(wait, current);
1073
1074 add_wait_queue(&pp->wait, &wait);
1075 for (;;) {
1076 set_current_state(TASK_UNINTERRUPTIBLE);
1077 if (pp->cmd.status != 1)
1078 break;
1079 spin_lock_irqsave(&pp->lock, flags);
1080 schedule();
1081 spin_unlock_irqrestore(&pp->lock, flags);
1082 }
1083 set_current_state(TASK_RUNNING);
1084 remove_wait_queue(&pp->wait, &wait);
1085 }
1086 spin_unlock_irqrestore(&pp->lock, flags);
1087
1088 spin_lock_irqsave(&smu_clist_lock, flags);
1089 list_del(&pp->list);
1090 spin_unlock_irqrestore(&smu_clist_lock, flags);
1091 kfree(pp);
1092
1093 return 0;
1094}
1095
1096
1097static struct file_operations smu_device_fops __pmacdata = {
1098 .llseek = no_llseek,
1099 .read = smu_read,
1100 .write = smu_write,
1101 .poll = smu_fpoll,
1102 .open = smu_open,
1103 .release = smu_release,
1104};
1105
1106static struct miscdevice pmu_device __pmacdata = {
1107 MISC_DYNAMIC_MINOR, "smu", &smu_device_fops
1108};
1109
1110static int smu_device_init(void)
1111{
1112 if (!smu)
1113 return -ENODEV;
1114 if (misc_register(&pmu_device) < 0)
1115 printk(KERN_ERR "via-pmu: cannot register misc device.\n");
1116 return 0;
1117}
1118device_initcall(smu_device_init);
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index c9ca1118e449..f38696622eb4 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -599,7 +599,7 @@ thermostat_init(void)
599 sensor_location[2] = "?"; 599 sensor_location[2] = "?";
600 } 600 }
601 601
602 of_dev = of_platform_device_create(np, "temperatures"); 602 of_dev = of_platform_device_create(np, "temperatures", NULL);
603 603
604 if (of_dev == NULL) { 604 if (of_dev == NULL) {
605 printk(KERN_ERR "Can't register temperatures device !\n"); 605 printk(KERN_ERR "Can't register temperatures device !\n");
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 703e31973314..cc507ceef153 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -2051,7 +2051,7 @@ static int __init therm_pm72_init(void)
2051 return -ENODEV; 2051 return -ENODEV;
2052 } 2052 }
2053 } 2053 }
2054 of_dev = of_platform_device_create(np, "temperature"); 2054 of_dev = of_platform_device_create(np, "temperature", NULL);
2055 if (of_dev == NULL) { 2055 if (of_dev == NULL) {
2056 printk(KERN_ERR "Can't register FCU platform device !\n"); 2056 printk(KERN_ERR "Can't register FCU platform device !\n");
2057 return -ENODEV; 2057 return -ENODEV;
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index cbb72eb0426d..6aaa1df1a64e 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -504,7 +504,7 @@ g4fan_init( void )
504 } 504 }
505 if( !(np=of_find_node_by_name(NULL, "fan")) ) 505 if( !(np=of_find_node_by_name(NULL, "fan")) )
506 return -ENODEV; 506 return -ENODEV;
507 x.of_dev = of_platform_device_create( np, "temperature" ); 507 x.of_dev = of_platform_device_create(np, "temperature", NULL);
508 of_node_put( np ); 508 of_node_put( np );
509 509
510 if( !x.of_dev ) { 510 if( !x.of_dev ) {
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index b82bc3150476..b6148f6f7836 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -96,7 +96,7 @@ static kmem_cache_t *_crypt_io_pool;
96/* 96/*
97 * Mempool alloc and free functions for the page 97 * Mempool alloc and free functions for the page
98 */ 98 */
99static void *mempool_alloc_page(unsigned int __nocast gfp_mask, void *data) 99static void *mempool_alloc_page(gfp_t gfp_mask, void *data)
100{ 100{
101 return alloc_page(gfp_mask); 101 return alloc_page(gfp_mask);
102} 102}
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 9de000131a8a..4809b209fbb1 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -32,7 +32,7 @@ struct io {
32static unsigned _num_ios; 32static unsigned _num_ios;
33static mempool_t *_io_pool; 33static mempool_t *_io_pool;
34 34
35static void *alloc_io(unsigned int __nocast gfp_mask, void *pool_data) 35static void *alloc_io(gfp_t gfp_mask, void *pool_data)
36{ 36{
37 return kmalloc(sizeof(struct io), gfp_mask); 37 return kmalloc(sizeof(struct io), gfp_mask);
38} 38}
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 200a0688f717..54ec737195e0 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -230,11 +230,20 @@ static int dm_hash_insert(const char *name, const char *uuid, struct mapped_devi
230 230
231static void __hash_remove(struct hash_cell *hc) 231static void __hash_remove(struct hash_cell *hc)
232{ 232{
233 struct dm_table *table;
234
233 /* remove from the dev hash */ 235 /* remove from the dev hash */
234 list_del(&hc->uuid_list); 236 list_del(&hc->uuid_list);
235 list_del(&hc->name_list); 237 list_del(&hc->name_list);
236 unregister_with_devfs(hc); 238 unregister_with_devfs(hc);
237 dm_set_mdptr(hc->md, NULL); 239 dm_set_mdptr(hc->md, NULL);
240
241 table = dm_get_table(hc->md);
242 if (table) {
243 dm_table_event(table);
244 dm_table_put(table);
245 }
246
238 dm_put(hc->md); 247 dm_put(hc->md);
239 if (hc->new_map) 248 if (hc->new_map)
240 dm_table_put(hc->new_map); 249 dm_table_put(hc->new_map);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 785806bdb248..f9b7b32d5d5c 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -329,13 +329,17 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
329/* 329/*
330 * If we run out of usable paths, should we queue I/O or error it? 330 * If we run out of usable paths, should we queue I/O or error it?
331 */ 331 */
332static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path) 332static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path,
333 unsigned save_old_value)
333{ 334{
334 unsigned long flags; 335 unsigned long flags;
335 336
336 spin_lock_irqsave(&m->lock, flags); 337 spin_lock_irqsave(&m->lock, flags);
337 338
338 m->saved_queue_if_no_path = m->queue_if_no_path; 339 if (save_old_value)
340 m->saved_queue_if_no_path = m->queue_if_no_path;
341 else
342 m->saved_queue_if_no_path = queue_if_no_path;
339 m->queue_if_no_path = queue_if_no_path; 343 m->queue_if_no_path = queue_if_no_path;
340 if (!m->queue_if_no_path && m->queue_size) 344 if (!m->queue_if_no_path && m->queue_size)
341 queue_work(kmultipathd, &m->process_queued_ios); 345 queue_work(kmultipathd, &m->process_queued_ios);
@@ -677,7 +681,7 @@ static int parse_features(struct arg_set *as, struct multipath *m,
677 return 0; 681 return 0;
678 682
679 if (!strnicmp(shift(as), MESG_STR("queue_if_no_path"))) 683 if (!strnicmp(shift(as), MESG_STR("queue_if_no_path")))
680 return queue_if_no_path(m, 1); 684 return queue_if_no_path(m, 1, 0);
681 else { 685 else {
682 ti->error = "Unrecognised multipath feature request"; 686 ti->error = "Unrecognised multipath feature request";
683 return -EINVAL; 687 return -EINVAL;
@@ -1077,7 +1081,7 @@ static void multipath_presuspend(struct dm_target *ti)
1077{ 1081{
1078 struct multipath *m = (struct multipath *) ti->private; 1082 struct multipath *m = (struct multipath *) ti->private;
1079 1083
1080 queue_if_no_path(m, 0); 1084 queue_if_no_path(m, 0, 1);
1081} 1085}
1082 1086
1083/* 1087/*
@@ -1222,9 +1226,9 @@ static int multipath_message(struct dm_target *ti, unsigned argc, char **argv)
1222 1226
1223 if (argc == 1) { 1227 if (argc == 1) {
1224 if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) 1228 if (!strnicmp(argv[0], MESG_STR("queue_if_no_path")))
1225 return queue_if_no_path(m, 1); 1229 return queue_if_no_path(m, 1, 0);
1226 else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) 1230 else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path")))
1227 return queue_if_no_path(m, 0); 1231 return queue_if_no_path(m, 0, 0);
1228 } 1232 }
1229 1233
1230 if (argc != 2) 1234 if (argc != 2)
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 863282513753..2375709a392c 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -122,7 +122,7 @@ static inline sector_t region_to_sector(struct region_hash *rh, region_t region)
122/* FIXME move this */ 122/* FIXME move this */
123static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw); 123static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw);
124 124
125static void *region_alloc(unsigned int __nocast gfp_mask, void *pool_data) 125static void *region_alloc(gfp_t gfp_mask, void *pool_data)
126{ 126{
127 return kmalloc(sizeof(struct region), gfp_mask); 127 return kmalloc(sizeof(struct region), gfp_mask);
128} 128}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2897df90df44..2a8a5696bf8a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3063,6 +3063,7 @@ static int md_thread(void * arg)
3063 * many dirty RAID5 blocks. 3063 * many dirty RAID5 blocks.
3064 */ 3064 */
3065 3065
3066 allow_signal(SIGKILL);
3066 complete(thread->event); 3067 complete(thread->event);
3067 while (!kthread_should_stop()) { 3068 while (!kthread_should_stop()) {
3068 void (*run)(mddev_t *); 3069 void (*run)(mddev_t *);
@@ -3111,7 +3112,7 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
3111 thread->mddev = mddev; 3112 thread->mddev = mddev;
3112 thread->name = name; 3113 thread->name = name;
3113 thread->timeout = MAX_SCHEDULE_TIMEOUT; 3114 thread->timeout = MAX_SCHEDULE_TIMEOUT;
3114 thread->tsk = kthread_run(md_thread, thread, mdname(thread->mddev)); 3115 thread->tsk = kthread_run(md_thread, thread, name, mdname(thread->mddev));
3115 if (IS_ERR(thread->tsk)) { 3116 if (IS_ERR(thread->tsk)) {
3116 kfree(thread); 3117 kfree(thread);
3117 return NULL; 3118 return NULL;
@@ -3567,8 +3568,10 @@ static void md_do_sync(mddev_t *mddev)
3567 mddev->curr_resync = 2; 3568 mddev->curr_resync = 2;
3568 3569
3569 try_again: 3570 try_again:
3570 if (signal_pending(current)) { 3571 if (signal_pending(current) ||
3572 kthread_should_stop()) {
3571 flush_signals(current); 3573 flush_signals(current);
3574 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
3572 goto skip; 3575 goto skip;
3573 } 3576 }
3574 ITERATE_MDDEV(mddev2,tmp) { 3577 ITERATE_MDDEV(mddev2,tmp) {
@@ -3588,8 +3591,9 @@ static void md_do_sync(mddev_t *mddev)
3588 */ 3591 */
3589 continue; 3592 continue;
3590 prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE); 3593 prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE);
3591 if (!signal_pending(current) 3594 if (!signal_pending(current) &&
3592 && mddev2->curr_resync >= mddev->curr_resync) { 3595 !kthread_should_stop() &&
3596 mddev2->curr_resync >= mddev->curr_resync) {
3593 printk(KERN_INFO "md: delaying resync of %s" 3597 printk(KERN_INFO "md: delaying resync of %s"
3594 " until %s has finished resync (they" 3598 " until %s has finished resync (they"
3595 " share one or more physical units)\n", 3599 " share one or more physical units)\n",
@@ -3695,7 +3699,7 @@ static void md_do_sync(mddev_t *mddev)
3695 } 3699 }
3696 3700
3697 3701
3698 if (signal_pending(current)) { 3702 if (signal_pending(current) || kthread_should_stop()) {
3699 /* 3703 /*
3700 * got a signal, exit. 3704 * got a signal, exit.
3701 */ 3705 */
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 286342375fb7..1151c3ed3006 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -38,7 +38,7 @@
38static mdk_personality_t multipath_personality; 38static mdk_personality_t multipath_personality;
39 39
40 40
41static void *mp_pool_alloc(unsigned int __nocast gfp_flags, void *data) 41static void *mp_pool_alloc(gfp_t gfp_flags, void *data)
42{ 42{
43 struct multipath_bh *mpb; 43 struct multipath_bh *mpb;
44 mpb = kmalloc(sizeof(*mpb), gfp_flags); 44 mpb = kmalloc(sizeof(*mpb), gfp_flags);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a93ca478142a..0e1f148dd41d 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -52,7 +52,7 @@ static mdk_personality_t raid1_personality;
52static void unplug_slaves(mddev_t *mddev); 52static void unplug_slaves(mddev_t *mddev);
53 53
54 54
55static void * r1bio_pool_alloc(unsigned int __nocast gfp_flags, void *data) 55static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
56{ 56{
57 struct pool_info *pi = data; 57 struct pool_info *pi = data;
58 r1bio_t *r1_bio; 58 r1bio_t *r1_bio;
@@ -79,7 +79,7 @@ static void r1bio_pool_free(void *r1_bio, void *data)
79#define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE) 79#define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE)
80#define RESYNC_WINDOW (2048*1024) 80#define RESYNC_WINDOW (2048*1024)
81 81
82static void * r1buf_pool_alloc(unsigned int __nocast gfp_flags, void *data) 82static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
83{ 83{
84 struct pool_info *pi = data; 84 struct pool_info *pi = data;
85 struct page *page; 85 struct page *page;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 5bd1e9ec899d..28dd028415e4 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -47,7 +47,7 @@
47 47
48static void unplug_slaves(mddev_t *mddev); 48static void unplug_slaves(mddev_t *mddev);
49 49
50static void * r10bio_pool_alloc(unsigned int __nocast gfp_flags, void *data) 50static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
51{ 51{
52 conf_t *conf = data; 52 conf_t *conf = data;
53 r10bio_t *r10_bio; 53 r10bio_t *r10_bio;
@@ -81,7 +81,7 @@ static void r10bio_pool_free(void *r10_bio, void *data)
81 * one for write (we recover only one drive per r10buf) 81 * one for write (we recover only one drive per r10buf)
82 * 82 *
83 */ 83 */
84static void * r10buf_pool_alloc(unsigned int __nocast gfp_flags, void *data) 84static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
85{ 85{
86 conf_t *conf = data; 86 conf_t *conf = data;
87 struct page *page; 87 struct page *page;
diff --git a/drivers/md/raid6.h b/drivers/md/raid6.h
index f80ee6350edf..31cbee71365f 100644
--- a/drivers/md/raid6.h
+++ b/drivers/md/raid6.h
@@ -69,9 +69,13 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
69#define __init 69#define __init
70#define __exit 70#define __exit
71#define __attribute_const__ __attribute__((const)) 71#define __attribute_const__ __attribute__((const))
72#define noinline __attribute__((noinline))
72 73
73#define preempt_enable() 74#define preempt_enable()
74#define preempt_disable() 75#define preempt_disable()
76#define cpu_has_feature(x) 1
77#define enable_kernel_altivec()
78#define disable_kernel_altivec()
75 79
76#endif /* __KERNEL__ */ 80#endif /* __KERNEL__ */
77 81
diff --git a/drivers/md/raid6algos.c b/drivers/md/raid6algos.c
index acf386fc4b4f..51c63c0cf1c9 100644
--- a/drivers/md/raid6algos.c
+++ b/drivers/md/raid6algos.c
@@ -19,6 +19,7 @@
19#include "raid6.h" 19#include "raid6.h"
20#ifndef __KERNEL__ 20#ifndef __KERNEL__
21#include <sys/mman.h> 21#include <sys/mman.h>
22#include <stdio.h>
22#endif 23#endif
23 24
24struct raid6_calls raid6_call; 25struct raid6_calls raid6_call;
diff --git a/drivers/md/raid6altivec.uc b/drivers/md/raid6altivec.uc
index 1de8f030eee0..b9afd35b8812 100644
--- a/drivers/md/raid6altivec.uc
+++ b/drivers/md/raid6altivec.uc
@@ -27,16 +27,20 @@
27#ifdef CONFIG_ALTIVEC 27#ifdef CONFIG_ALTIVEC
28 28
29#include <altivec.h> 29#include <altivec.h>
30#include <asm/system.h> 30#ifdef __KERNEL__
31#include <asm/cputable.h> 31# include <asm/system.h>
32# include <asm/cputable.h>
33#endif
32 34
33/* 35/*
34 * This is the C data type to use 36 * This is the C data type to use. We use a vector of
37 * signed char so vec_cmpgt() will generate the right
38 * instruction.
35 */ 39 */
36 40
37typedef vector unsigned char unative_t; 41typedef vector signed char unative_t;
38 42
39#define NBYTES(x) ((vector unsigned char) {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x}) 43#define NBYTES(x) ((vector signed char) {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x})
40#define NSIZE sizeof(unative_t) 44#define NSIZE sizeof(unative_t)
41 45
42/* 46/*
@@ -108,7 +112,11 @@ int raid6_have_altivec(void);
108int raid6_have_altivec(void) 112int raid6_have_altivec(void)
109{ 113{
110 /* This assumes either all CPUs have Altivec or none does */ 114 /* This assumes either all CPUs have Altivec or none does */
115# ifdef __KERNEL__
111 return cpu_has_feature(CPU_FTR_ALTIVEC); 116 return cpu_has_feature(CPU_FTR_ALTIVEC);
117# else
118 return 1;
119# endif
112} 120}
113#endif 121#endif
114 122
diff --git a/drivers/md/raid6test/Makefile b/drivers/md/raid6test/Makefile
index 557806728609..78e0396adf2a 100644
--- a/drivers/md/raid6test/Makefile
+++ b/drivers/md/raid6test/Makefile
@@ -8,6 +8,8 @@ OPTFLAGS = -O2 # Adjust as desired
8CFLAGS = -I.. -g $(OPTFLAGS) 8CFLAGS = -I.. -g $(OPTFLAGS)
9LD = ld 9LD = ld
10PERL = perl 10PERL = perl
11AR = ar
12RANLIB = ranlib
11 13
12.c.o: 14.c.o:
13 $(CC) $(CFLAGS) -c -o $@ $< 15 $(CC) $(CFLAGS) -c -o $@ $<
@@ -18,18 +20,33 @@ PERL = perl
18%.uc: ../%.uc 20%.uc: ../%.uc
19 cp -f $< $@ 21 cp -f $< $@
20 22
21all: raid6.o raid6test 23all: raid6.a raid6test
22 24
23raid6.o: raid6int1.o raid6int2.o raid6int4.o raid6int8.o raid6int16.o \ 25raid6.a: raid6int1.o raid6int2.o raid6int4.o raid6int8.o raid6int16.o \
24 raid6int32.o \ 26 raid6int32.o \
25 raid6mmx.o raid6sse1.o raid6sse2.o \ 27 raid6mmx.o raid6sse1.o raid6sse2.o \
28 raid6altivec1.o raid6altivec2.o raid6altivec4.o raid6altivec8.o \
26 raid6recov.o raid6algos.o \ 29 raid6recov.o raid6algos.o \
27 raid6tables.o 30 raid6tables.o
28 $(LD) -r -o $@ $^ 31 rm -f $@
32 $(AR) cq $@ $^
33 $(RANLIB) $@
29 34
30raid6test: raid6.o test.c 35raid6test: test.c raid6.a
31 $(CC) $(CFLAGS) -o raid6test $^ 36 $(CC) $(CFLAGS) -o raid6test $^
32 37
38raid6altivec1.c: raid6altivec.uc ../unroll.pl
39 $(PERL) ../unroll.pl 1 < raid6altivec.uc > $@
40
41raid6altivec2.c: raid6altivec.uc ../unroll.pl
42 $(PERL) ../unroll.pl 2 < raid6altivec.uc > $@
43
44raid6altivec4.c: raid6altivec.uc ../unroll.pl
45 $(PERL) ../unroll.pl 4 < raid6altivec.uc > $@
46
47raid6altivec8.c: raid6altivec.uc ../unroll.pl
48 $(PERL) ../unroll.pl 8 < raid6altivec.uc > $@
49
33raid6int1.c: raid6int.uc ../unroll.pl 50raid6int1.c: raid6int.uc ../unroll.pl
34 $(PERL) ../unroll.pl 1 < raid6int.uc > $@ 51 $(PERL) ../unroll.pl 1 < raid6int.uc > $@
35 52
@@ -52,7 +69,7 @@ raid6tables.c: mktables
52 ./mktables > raid6tables.c 69 ./mktables > raid6tables.c
53 70
54clean: 71clean:
55 rm -f *.o mktables mktables.c raid6int.uc raid6*.c raid6test 72 rm -f *.o *.a mktables mktables.c raid6int.uc raid6*.c raid6test
56 73
57spotless: clean 74spotless: clean
58 rm -f *~ 75 rm -f *~
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index 87d5f4d8790f..eaf130e666d8 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -100,8 +100,8 @@ static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
100 100
101 ret = i2c_transfer (state->i2c, msg, 2); 101 ret = i2c_transfer (state->i2c, msg, 2);
102 if (ret != 2) 102 if (ret != 2)
103 printk("DVB: TDA10021(%d): %s: readreg error (ret == %i)\n", 103 printk("DVB: TDA10021: %s: readreg error (ret == %i)\n",
104 state->frontend.dvb->num, __FUNCTION__, ret); 104 __FUNCTION__, ret);
105 return b1[0]; 105 return b1[0];
106} 106}
107 107
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 022913da8c59..9b0406318f2d 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -543,7 +543,7 @@ static int cadet_probe(void)
543 543
544 for(i=0;i<8;i++) { 544 for(i=0;i<8;i++) {
545 io=iovals[i]; 545 io=iovals[i];
546 if(request_region(io,2, "cadet-probe")>=0) { 546 if (request_region(io, 2, "cadet-probe")) {
547 cadet_setfreq(1410); 547 cadet_setfreq(1410);
548 if(cadet_getfreq()==1410) { 548 if(cadet_getfreq()==1410) {
549 release_region(io, 2); 549 release_region(io, 2);
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 93570355819a..bbb989df4cf0 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -262,7 +262,6 @@ config VIDEO_SAA7134_DVB
262 depends on VIDEO_SAA7134 && DVB_CORE 262 depends on VIDEO_SAA7134 && DVB_CORE
263 select VIDEO_BUF_DVB 263 select VIDEO_BUF_DVB
264 select DVB_MT352 264 select DVB_MT352
265 select DVB_CX22702
266 select DVB_TDA1004X 265 select DVB_TDA1004X
267 ---help--- 266 ---help---
268 This adds support for DVB cards based on the 267 This adds support for DVB cards based on the
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 190977a1e549..0881a17d5226 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -2393,12 +2393,12 @@ struct tvcard bttv_tvcards[] = {
2393 .tuner = 0, 2393 .tuner = 0,
2394 .tuner_type = TUNER_LG_TDVS_H062F, 2394 .tuner_type = TUNER_LG_TDVS_H062F,
2395 .tuner_addr = ADDR_UNSET, 2395 .tuner_addr = ADDR_UNSET,
2396 .video_inputs = 2, 2396 .video_inputs = 3,
2397 .audio_inputs = 1, 2397 .audio_inputs = 1,
2398 .svhs = 2, 2398 .svhs = 2,
2399 .muxsel = { 2, 3 }, 2399 .muxsel = { 2, 3, 1 },
2400 .gpiomask = 0x00e00007, 2400 .gpiomask = 0x00e00007,
2401 .audiomux = { 0x00400005, 0, 0, 0, 0, 0 }, 2401 .audiomux = { 0x00400005, 0, 0x00000001, 0, 0x00c00007, 0 },
2402 .no_msp34xx = 1, 2402 .no_msp34xx = 1,
2403 .no_tda9875 = 1, 2403 .no_tda9875 = 1,
2404 .no_tda7432 = 1, 2404 .no_tda7432 = 1,
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index a564321db2f0..c062a017491e 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -763,21 +763,21 @@ static void set_pll(struct bttv *btv)
763 /* no PLL needed */ 763 /* no PLL needed */
764 if (btv->pll.pll_current == 0) 764 if (btv->pll.pll_current == 0)
765 return; 765 return;
766 vprintk(KERN_INFO "bttv%d: PLL can sleep, using XTAL (%d).\n", 766 bttv_printk(KERN_INFO "bttv%d: PLL can sleep, using XTAL (%d).\n",
767 btv->c.nr,btv->pll.pll_ifreq); 767 btv->c.nr,btv->pll.pll_ifreq);
768 btwrite(0x00,BT848_TGCTRL); 768 btwrite(0x00,BT848_TGCTRL);
769 btwrite(0x00,BT848_PLL_XCI); 769 btwrite(0x00,BT848_PLL_XCI);
770 btv->pll.pll_current = 0; 770 btv->pll.pll_current = 0;
771 return; 771 return;
772 } 772 }
773 773
774 vprintk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr, 774 bttv_printk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr,
775 btv->pll.pll_ifreq, btv->pll.pll_ofreq); 775 btv->pll.pll_ifreq, btv->pll.pll_ofreq);
776 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); 776 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq);
777 777
778 for (i=0; i<10; i++) { 778 for (i=0; i<10; i++) {
779 /* Let other people run while the PLL stabilizes */ 779 /* Let other people run while the PLL stabilizes */
780 vprintk("."); 780 bttv_printk(".");
781 msleep(10); 781 msleep(10);
782 782
783 if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) { 783 if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) {
@@ -785,12 +785,12 @@ static void set_pll(struct bttv *btv)
785 } else { 785 } else {
786 btwrite(0x08,BT848_TGCTRL); 786 btwrite(0x08,BT848_TGCTRL);
787 btv->pll.pll_current = btv->pll.pll_ofreq; 787 btv->pll.pll_current = btv->pll.pll_ofreq;
788 vprintk(" ok\n"); 788 bttv_printk(" ok\n");
789 return; 789 return;
790 } 790 }
791 } 791 }
792 btv->pll.pll_current = -1; 792 btv->pll.pll_current = -1;
793 vprintk("failed\n"); 793 bttv_printk("failed\n");
794 return; 794 return;
795} 795}
796 796
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
index 9b0b7ca035f8..7a312f79340a 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bttvp.h
@@ -221,7 +221,7 @@ extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
221extern int init_bttv_i2c(struct bttv *btv); 221extern int init_bttv_i2c(struct bttv *btv);
222extern int fini_bttv_i2c(struct bttv *btv); 222extern int fini_bttv_i2c(struct bttv *btv);
223 223
224#define vprintk if (bttv_verbose) printk 224#define bttv_printk if (bttv_verbose) printk
225#define dprintk if (bttv_debug >= 1) printk 225#define dprintk if (bttv_debug >= 1) printk
226#define d2printk if (bttv_debug >= 2) printk 226#define d2printk if (bttv_debug >= 2) printk
227 227
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 8c08b7f1ad23..b7ec9bf45085 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -1397,7 +1397,7 @@ static void destroy_proc_cpia_cam(struct cam_data *cam)
1397 1397
1398static void proc_cpia_create(void) 1398static void proc_cpia_create(void)
1399{ 1399{
1400 cpia_proc_root = create_proc_entry("cpia", S_IFDIR, NULL); 1400 cpia_proc_root = proc_mkdir("cpia", NULL);
1401 1401
1402 if (cpia_proc_root) 1402 if (cpia_proc_root)
1403 cpia_proc_root->owner = THIS_MODULE; 1403 cpia_proc_root->owner = THIS_MODULE;
diff --git a/drivers/media/video/rds.h b/drivers/media/video/rds.h
index 30337d0f1a87..0d30eb744e61 100644
--- a/drivers/media/video/rds.h
+++ b/drivers/media/video/rds.h
@@ -31,7 +31,7 @@
31struct rds_command { 31struct rds_command {
32 unsigned int block_count; 32 unsigned int block_count;
33 int result; 33 int result;
34 unsigned char *buffer; 34 unsigned char __user *buffer;
35 struct file *instance; 35 struct file *instance;
36 poll_table *event_list; 36 poll_table *event_list;
37}; 37};
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index 1a657a70ff43..72b70eb5da1d 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -157,7 +157,7 @@ static struct i2c_client client_template;
157 157
158/* ---------------------------------------------------------------------- */ 158/* ---------------------------------------------------------------------- */
159 159
160static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) 160static int block_to_user_buf(struct saa6588 *s, unsigned char __user *user_buf)
161{ 161{
162 int i; 162 int i;
163 163
@@ -191,7 +191,7 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a)
191{ 191{
192 unsigned long flags; 192 unsigned long flags;
193 193
194 unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ 194 unsigned char __user *buf_ptr = a->buffer;
195 unsigned int i; 195 unsigned int i;
196 unsigned int rd_blocks; 196 unsigned int rd_blocks;
197 197
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 4437bdebe24f..137b58f2c666 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -203,7 +203,7 @@ static const unsigned short init_ntsc[] = {
203 0x8c, 640, /* Horizontal length */ 203 0x8c, 640, /* Horizontal length */
204 0x8d, 640, /* Number of pixels */ 204 0x8d, 640, /* Number of pixels */
205 0x8f, 0xc00, /* Disable window 2 */ 205 0x8f, 0xc00, /* Disable window 2 */
206 0xf0, 0x173, /* 13.5 MHz transport, Forced 206 0xf0, 0x73, /* 13.5 MHz transport, Forced
207 * mode, latch windows */ 207 * mode, latch windows */
208 0xf2, 0x13, /* NTSC M, composite input */ 208 0xf2, 0x13, /* NTSC M, composite input */
209 0xe7, 0x1e1, /* Enable vertical standard 209 0xe7, 0x1e1, /* Enable vertical standard
@@ -212,38 +212,36 @@ static const unsigned short init_ntsc[] = {
212 212
213static const unsigned short init_pal[] = { 213static const unsigned short init_pal[] = {
214 0x88, 23, /* Window 1 vertical begin */ 214 0x88, 23, /* Window 1 vertical begin */
215 0x89, 288 + 16, /* Vertical lines in (16 lines 215 0x89, 288, /* Vertical lines in (16 lines
216 * skipped by the VFE) */ 216 * skipped by the VFE) */
217 0x8a, 288 + 16, /* Vertical lines out (16 lines 217 0x8a, 288, /* Vertical lines out (16 lines
218 * skipped by the VFE) */ 218 * skipped by the VFE) */
219 0x8b, 16, /* Horizontal begin */ 219 0x8b, 16, /* Horizontal begin */
220 0x8c, 768, /* Horizontal length */ 220 0x8c, 768, /* Horizontal length */
221 0x8d, 784, /* Number of pixels 221 0x8d, 784, /* Number of pixels
222 * Must be >= Horizontal begin + Horizontal length */ 222 * Must be >= Horizontal begin + Horizontal length */
223 0x8f, 0xc00, /* Disable window 2 */ 223 0x8f, 0xc00, /* Disable window 2 */
224 0xf0, 0x177, /* 13.5 MHz transport, Forced 224 0xf0, 0x77, /* 13.5 MHz transport, Forced
225 * mode, latch windows */ 225 * mode, latch windows */
226 0xf2, 0x3d1, /* PAL B,G,H,I, composite input */ 226 0xf2, 0x3d1, /* PAL B,G,H,I, composite input */
227 0xe7, 0x261, /* PAL/SECAM set to 288 + 16 lines 227 0xe7, 0x241, /* PAL/SECAM set to 288 lines */
228 * change to 0x241 for 288 lines */
229}; 228};
230 229
231static const unsigned short init_secam[] = { 230static const unsigned short init_secam[] = {
232 0x88, 23 - 16, /* Window 1 vertical begin */ 231 0x88, 23, /* Window 1 vertical begin */
233 0x89, 288 + 16, /* Vertical lines in (16 lines 232 0x89, 288, /* Vertical lines in (16 lines
234 * skipped by the VFE) */ 233 * skipped by the VFE) */
235 0x8a, 288 + 16, /* Vertical lines out (16 lines 234 0x8a, 288, /* Vertical lines out (16 lines
236 * skipped by the VFE) */ 235 * skipped by the VFE) */
237 0x8b, 16, /* Horizontal begin */ 236 0x8b, 16, /* Horizontal begin */
238 0x8c, 768, /* Horizontal length */ 237 0x8c, 768, /* Horizontal length */
239 0x8d, 784, /* Number of pixels 238 0x8d, 784, /* Number of pixels
240 * Must be >= Horizontal begin + Horizontal length */ 239 * Must be >= Horizontal begin + Horizontal length */
241 0x8f, 0xc00, /* Disable window 2 */ 240 0x8f, 0xc00, /* Disable window 2 */
242 0xf0, 0x177, /* 13.5 MHz transport, Forced 241 0xf0, 0x77, /* 13.5 MHz transport, Forced
243 * mode, latch windows */ 242 * mode, latch windows */
244 0xf2, 0x3d5, /* SECAM, composite input */ 243 0xf2, 0x3d5, /* SECAM, composite input */
245 0xe7, 0x261, /* PAL/SECAM set to 288 + 16 lines 244 0xe7, 0x241, /* PAL/SECAM set to 288 lines */
246 * change to 0x241 for 288 lines */
247}; 245};
248 246
249static const unsigned char init_common[] = { 247static const unsigned char init_common[] = {
@@ -410,6 +408,12 @@ vpx3220_command (struct i2c_client *client,
410 case DECODER_SET_NORM: 408 case DECODER_SET_NORM:
411 { 409 {
412 int *iarg = arg, data; 410 int *iarg = arg, data;
411 int temp_input;
412
413 /* Here we back up the input selection because it gets
414 overwritten when we fill the registers with the
415 choosen video norm */
416 temp_input = vpx3220_fp_read(client, 0xf2);
413 417
414 dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n", 418 dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",
415 I2C_NAME(client), *iarg); 419 I2C_NAME(client), *iarg);
@@ -449,6 +453,10 @@ vpx3220_command (struct i2c_client *client,
449 453
450 } 454 }
451 decoder->norm = *iarg; 455 decoder->norm = *iarg;
456
457 /* And here we set the backed up video input again */
458 vpx3220_fp_write(client, 0xf2, temp_input | 0x0010);
459 udelay(10);
452 } 460 }
453 break; 461 break;
454 462
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
index 33f209a39cb6..1883d22cffeb 100644
--- a/drivers/message/fusion/Kconfig
+++ b/drivers/message/fusion/Kconfig
@@ -35,6 +35,23 @@ config FUSION_FC
35 LSIFC929X 35 LSIFC929X
36 LSIFC929XL 36 LSIFC929XL
37 37
38config FUSION_SAS
39 tristate "Fusion MPT ScsiHost drivers for SAS"
40 depends on PCI && SCSI
41 select FUSION
42 select SCSI_SAS_ATTRS
43 ---help---
44 SCSI HOST support for a SAS host adapters.
45
46 List of supported controllers:
47
48 LSISAS1064
49 LSISAS1066
50 LSISAS1068
51 LSISAS1064E
52 LSISAS1066E
53 LSISAS1068E
54
38config FUSION_MAX_SGE 55config FUSION_MAX_SGE
39 int "Maximum number of scatter gather entries (16 - 128)" 56 int "Maximum number of scatter gather entries (16 - 128)"
40 depends on FUSION 57 depends on FUSION
diff --git a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile
index 1d2f9db813c1..8a2e2657f4c2 100644
--- a/drivers/message/fusion/Makefile
+++ b/drivers/message/fusion/Makefile
@@ -34,5 +34,6 @@
34 34
35obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o 35obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o
36obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o 36obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o
37obj-$(CONFIG_FUSION_SAS) += mptbase.o mptscsih.o mptsas.o
37obj-$(CONFIG_FUSION_CTL) += mptctl.o 38obj-$(CONFIG_FUSION_CTL) += mptctl.o
38obj-$(CONFIG_FUSION_LAN) += mptlan.o 39obj-$(CONFIG_FUSION_LAN) += mptlan.o
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index f517d0692d5f..790a2932ded9 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -135,13 +135,12 @@ static void mpt_adapter_dispose(MPT_ADAPTER *ioc);
135 135
136static void MptDisplayIocCapabilities(MPT_ADAPTER *ioc); 136static void MptDisplayIocCapabilities(MPT_ADAPTER *ioc);
137static int MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag); 137static int MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag);
138//static u32 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked);
139static int GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason); 138static int GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason);
140static int GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag); 139static int GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag);
141static int SendIocInit(MPT_ADAPTER *ioc, int sleepFlag); 140static int SendIocInit(MPT_ADAPTER *ioc, int sleepFlag);
142static int SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag); 141static int SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag);
143static int mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag); 142static int mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag);
144static int mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag); 143static int mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag);
145static int mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag); 144static int mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag);
146static int KickStart(MPT_ADAPTER *ioc, int ignore, int sleepFlag); 145static int KickStart(MPT_ADAPTER *ioc, int ignore, int sleepFlag);
147static int SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag); 146static int SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag);
@@ -152,6 +151,7 @@ static int WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag);
152static int GetLanConfigPages(MPT_ADAPTER *ioc); 151static int GetLanConfigPages(MPT_ADAPTER *ioc);
153static int GetFcPortPage0(MPT_ADAPTER *ioc, int portnum); 152static int GetFcPortPage0(MPT_ADAPTER *ioc, int portnum);
154static int GetIoUnitPage2(MPT_ADAPTER *ioc); 153static int GetIoUnitPage2(MPT_ADAPTER *ioc);
154int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
155static int mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum); 155static int mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum);
156static int mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum); 156static int mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum);
157static void mpt_read_ioc_pg_1(MPT_ADAPTER *ioc); 157static void mpt_read_ioc_pg_1(MPT_ADAPTER *ioc);
@@ -159,6 +159,8 @@ static void mpt_read_ioc_pg_4(MPT_ADAPTER *ioc);
159static void mpt_timer_expired(unsigned long data); 159static void mpt_timer_expired(unsigned long data);
160static int SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch); 160static int SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch);
161static int SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp); 161static int SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp);
162static int mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag);
163static int mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init);
162 164
163#ifdef CONFIG_PROC_FS 165#ifdef CONFIG_PROC_FS
164static int procmpt_summary_read(char *buf, char **start, off_t offset, 166static int procmpt_summary_read(char *buf, char **start, off_t offset,
@@ -175,6 +177,7 @@ static int ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *
175static void mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf); 177static void mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf);
176static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info); 178static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info);
177static void mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info); 179static void mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info);
180static void mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info);
178 181
179/* module entry point */ 182/* module entry point */
180static int __init fusion_init (void); 183static int __init fusion_init (void);
@@ -206,6 +209,144 @@ pci_enable_io_access(struct pci_dev *pdev)
206 pci_write_config_word(pdev, PCI_COMMAND, command_reg); 209 pci_write_config_word(pdev, PCI_COMMAND, command_reg);
207} 210}
208 211
212/*
213 * Process turbo (context) reply...
214 */
215static void
216mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
217{
218 MPT_FRAME_HDR *mf = NULL;
219 MPT_FRAME_HDR *mr = NULL;
220 int req_idx = 0;
221 int cb_idx;
222
223 dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply req_idx=%08x\n",
224 ioc->name, pa));
225
226 switch (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT) {
227 case MPI_CONTEXT_REPLY_TYPE_SCSI_INIT:
228 req_idx = pa & 0x0000FFFF;
229 cb_idx = (pa & 0x00FF0000) >> 16;
230 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
231 break;
232 case MPI_CONTEXT_REPLY_TYPE_LAN:
233 cb_idx = mpt_lan_index;
234 /*
235 * Blind set of mf to NULL here was fatal
236 * after lan_reply says "freeme"
237 * Fix sort of combined with an optimization here;
238 * added explicit check for case where lan_reply
239 * was just returning 1 and doing nothing else.
240 * For this case skip the callback, but set up
241 * proper mf value first here:-)
242 */
243 if ((pa & 0x58000000) == 0x58000000) {
244 req_idx = pa & 0x0000FFFF;
245 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
246 mpt_free_msg_frame(ioc, mf);
247 mb();
248 return;
249 break;
250 }
251 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
252 break;
253 case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET:
254 cb_idx = mpt_stm_index;
255 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
256 break;
257 default:
258 cb_idx = 0;
259 BUG();
260 }
261
262 /* Check for (valid) IO callback! */
263 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
264 MptCallbacks[cb_idx] == NULL) {
265 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
266 __FUNCTION__, ioc->name, cb_idx);
267 goto out;
268 }
269
270 if (MptCallbacks[cb_idx](ioc, mf, mr))
271 mpt_free_msg_frame(ioc, mf);
272 out:
273 mb();
274}
275
276static void
277mpt_reply(MPT_ADAPTER *ioc, u32 pa)
278{
279 MPT_FRAME_HDR *mf;
280 MPT_FRAME_HDR *mr;
281 int req_idx;
282 int cb_idx;
283 int freeme;
284
285 u32 reply_dma_low;
286 u16 ioc_stat;
287
288 /* non-TURBO reply! Hmmm, something may be up...
289 * Newest turbo reply mechanism; get address
290 * via left shift 1 (get rid of MPI_ADDRESS_REPLY_A_BIT)!
291 */
292
293 /* Map DMA address of reply header to cpu address.
294 * pa is 32 bits - but the dma address may be 32 or 64 bits
295 * get offset based only only the low addresses
296 */
297
298 reply_dma_low = (pa <<= 1);
299 mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames +
300 (reply_dma_low - ioc->reply_frames_low_dma));
301
302 req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx);
303 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx;
304 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
305
306 dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n",
307 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function));
308 DBG_DUMP_REPLY_FRAME(mr)
309
310 /* Check/log IOC log info
311 */
312 ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus);
313 if (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) {
314 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
315 if (ioc->bus_type == FC)
316 mpt_fc_log_info(ioc, log_info);
317 else if (ioc->bus_type == SCSI)
318 mpt_sp_log_info(ioc, log_info);
319 else if (ioc->bus_type == SAS)
320 mpt_sas_log_info(ioc, log_info);
321 }
322 if (ioc_stat & MPI_IOCSTATUS_MASK) {
323 if (ioc->bus_type == SCSI &&
324 cb_idx != mpt_stm_index &&
325 cb_idx != mpt_lan_index)
326 mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf);
327 }
328
329
330 /* Check for (valid) IO callback! */
331 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
332 MptCallbacks[cb_idx] == NULL) {
333 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
334 __FUNCTION__, ioc->name, cb_idx);
335 freeme = 0;
336 goto out;
337 }
338
339 freeme = MptCallbacks[cb_idx](ioc, mf, mr);
340
341 out:
342 /* Flush (non-TURBO) reply with a WRITE! */
343 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa);
344
345 if (freeme)
346 mpt_free_msg_frame(ioc, mf);
347 mb();
348}
349
209/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 350/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
210/* 351/*
211 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler. 352 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
@@ -227,164 +368,21 @@ pci_enable_io_access(struct pci_dev *pdev)
227static irqreturn_t 368static irqreturn_t
228mpt_interrupt(int irq, void *bus_id, struct pt_regs *r) 369mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
229{ 370{
230 MPT_ADAPTER *ioc; 371 MPT_ADAPTER *ioc = bus_id;
231 MPT_FRAME_HDR *mf; 372 u32 pa;
232 MPT_FRAME_HDR *mr;
233 u32 pa;
234 int req_idx;
235 int cb_idx;
236 int type;
237 int freeme;
238
239 ioc = (MPT_ADAPTER *)bus_id;
240 373
241 /* 374 /*
242 * Drain the reply FIFO! 375 * Drain the reply FIFO!
243 *
244 * NOTES: I've seen up to 10 replies processed in this loop, so far...
245 * Update: I've seen up to 9182 replies processed in this loop! ??
246 * Update: Limit ourselves to processing max of N replies
247 * (bottom of loop).
248 */ 376 */
249 while (1) { 377 while (1) {
250 378 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
251 if ((pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo)) == 0xFFFFFFFF) 379 if (pa == 0xFFFFFFFF)
252 return IRQ_HANDLED; 380 return IRQ_HANDLED;
253 381 else if (pa & MPI_ADDRESS_REPLY_A_BIT)
254 cb_idx = 0; 382 mpt_reply(ioc, pa);
255 freeme = 0; 383 else
256 384 mpt_turbo_reply(ioc, pa);
257 /* 385 }
258 * Check for non-TURBO reply!
259 */
260 if (pa & MPI_ADDRESS_REPLY_A_BIT) {
261 u32 reply_dma_low;
262 u16 ioc_stat;
263
264 /* non-TURBO reply! Hmmm, something may be up...
265 * Newest turbo reply mechanism; get address
266 * via left shift 1 (get rid of MPI_ADDRESS_REPLY_A_BIT)!
267 */
268
269 /* Map DMA address of reply header to cpu address.
270 * pa is 32 bits - but the dma address may be 32 or 64 bits
271 * get offset based only only the low addresses
272 */
273 reply_dma_low = (pa = (pa << 1));
274 mr = (MPT_FRAME_HDR *)((u8 *)ioc->reply_frames +
275 (reply_dma_low - ioc->reply_frames_low_dma));
276
277 req_idx = le16_to_cpu(mr->u.frame.hwhdr.msgctxu.fld.req_idx);
278 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx;
279 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
280
281 dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n",
282 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function));
283 DBG_DUMP_REPLY_FRAME(mr)
284
285 /* Check/log IOC log info
286 */
287 ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus);
288 if (ioc_stat & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) {
289 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
290 if (ioc->bus_type == FC)
291 mpt_fc_log_info(ioc, log_info);
292 else if (ioc->bus_type == SCSI)
293 mpt_sp_log_info(ioc, log_info);
294 }
295 if (ioc_stat & MPI_IOCSTATUS_MASK) {
296 if (ioc->bus_type == SCSI)
297 mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf);
298 }
299 } else {
300 /*
301 * Process turbo (context) reply...
302 */
303 dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply req_idx=%08x\n", ioc->name, pa));
304 type = (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT);
305 if (type == MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET) {
306 cb_idx = mpt_stm_index;
307 mf = NULL;
308 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
309 } else if (type == MPI_CONTEXT_REPLY_TYPE_LAN) {
310 cb_idx = mpt_lan_index;
311 /* Blind set of mf to NULL here was fatal
312 * after lan_reply says "freeme"
313 * Fix sort of combined with an optimization here;
314 * added explicit check for case where lan_reply
315 * was just returning 1 and doing nothing else.
316 * For this case skip the callback, but set up
317 * proper mf value first here:-)
318 */
319 if ((pa & 0x58000000) == 0x58000000) {
320 req_idx = pa & 0x0000FFFF;
321 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
322 freeme = 1;
323 /*
324 * IMPORTANT! Invalidate the callback!
325 */
326 cb_idx = 0;
327 } else {
328 mf = NULL;
329 }
330 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
331 } else {
332 req_idx = pa & 0x0000FFFF;
333 cb_idx = (pa & 0x00FF0000) >> 16;
334 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
335 mr = NULL;
336 }
337 pa = 0; /* No reply flush! */
338 }
339
340#ifdef MPT_DEBUG_IRQ
341 if (ioc->bus_type == SCSI) {
342 /* Verify mf, mr are reasonable.
343 */
344 if ((mf) && ((mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))
345 || (mf < ioc->req_frames)) ) {
346 printk(MYIOC_s_WARN_FMT
347 "mpt_interrupt: Invalid mf (%p)!\n", ioc->name, (void *)mf);
348 cb_idx = 0;
349 pa = 0;
350 freeme = 0;
351 }
352 if ((pa) && (mr) && ((mr >= MPT_INDEX_2_RFPTR(ioc, ioc->req_depth))
353 || (mr < ioc->reply_frames)) ) {
354 printk(MYIOC_s_WARN_FMT
355 "mpt_interrupt: Invalid rf (%p)!\n", ioc->name, (void *)mr);
356 cb_idx = 0;
357 pa = 0;
358 freeme = 0;
359 }
360 if (cb_idx > (MPT_MAX_PROTOCOL_DRIVERS-1)) {
361 printk(MYIOC_s_WARN_FMT
362 "mpt_interrupt: Invalid cb_idx (%d)!\n", ioc->name, cb_idx);
363 cb_idx = 0;
364 pa = 0;
365 freeme = 0;
366 }
367 }
368#endif
369
370 /* Check for (valid) IO callback! */
371 if (cb_idx) {
372 /* Do the callback! */
373 freeme = (*(MptCallbacks[cb_idx]))(ioc, mf, mr);
374 }
375
376 if (pa) {
377 /* Flush (non-TURBO) reply with a WRITE! */
378 CHIPREG_WRITE32(&ioc->chip->ReplyFifo, pa);
379 }
380
381 if (freeme) {
382 /* Put Request back on FreeQ! */
383 mpt_free_msg_frame(ioc, mf);
384 }
385
386 mb();
387 } /* drain reply FIFO */
388 386
389 return IRQ_HANDLED; 387 return IRQ_HANDLED;
390} 388}
@@ -509,6 +507,14 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
509 pCfg->wait_done = 1; 507 pCfg->wait_done = 1;
510 wake_up(&mpt_waitq); 508 wake_up(&mpt_waitq);
511 } 509 }
510 } else if (func == MPI_FUNCTION_SAS_IO_UNIT_CONTROL) {
511 /* we should be always getting a reply frame */
512 memcpy(ioc->persist_reply_frame, reply,
513 min(MPT_DEFAULT_FRAME_SIZE,
514 4*reply->u.reply.MsgLength));
515 del_timer(&ioc->persist_timer);
516 ioc->persist_wait_done = 1;
517 wake_up(&mpt_waitq);
512 } else { 518 } else {
513 printk(MYIOC_s_ERR_FMT "Unexpected msg function (=%02Xh) reply received!\n", 519 printk(MYIOC_s_ERR_FMT "Unexpected msg function (=%02Xh) reply received!\n",
514 ioc->name, func); 520 ioc->name, func);
@@ -750,6 +756,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
750 mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR, 756 mf = list_entry(ioc->FreeQ.next, MPT_FRAME_HDR,
751 u.frame.linkage.list); 757 u.frame.linkage.list);
752 list_del(&mf->u.frame.linkage.list); 758 list_del(&mf->u.frame.linkage.list);
759 mf->u.frame.linkage.arg1 = 0;
753 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ 760 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */
754 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; 761 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
755 /* u16! */ 762 /* u16! */
@@ -845,6 +852,7 @@ mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
845 852
846 /* Put Request back on FreeQ! */ 853 /* Put Request back on FreeQ! */
847 spin_lock_irqsave(&ioc->FreeQlock, flags); 854 spin_lock_irqsave(&ioc->FreeQlock, flags);
855 mf->u.frame.linkage.arg1 = 0xdeadbeaf; /* signature to know if this mf is freed */
848 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ); 856 list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ);
849#ifdef MFCNT 857#ifdef MFCNT
850 ioc->mfcnt--; 858 ioc->mfcnt--;
@@ -971,12 +979,123 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
971 979
972 /* Make sure there are no doorbells */ 980 /* Make sure there are no doorbells */
973 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 981 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
974 982
975 return r; 983 return r;
976} 984}
977 985
978/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 986/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
979/** 987/**
988 * mpt_host_page_access_control - provides mechanism for the host
989 * driver to control the IOC's Host Page Buffer access.
990 * @ioc: Pointer to MPT adapter structure
991 * @access_control_value: define bits below
992 *
993 * Access Control Value - bits[15:12]
994 * 0h Reserved
995 * 1h Enable Access { MPI_DB_HPBAC_ENABLE_ACCESS }
996 * 2h Disable Access { MPI_DB_HPBAC_DISABLE_ACCESS }
997 * 3h Free Buffer { MPI_DB_HPBAC_FREE_BUFFER }
998 *
999 * Returns 0 for success, non-zero for failure.
1000 */
1001
1002static int
1003mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag)
1004{
1005 int r = 0;
1006
1007 /* return if in use */
1008 if (CHIPREG_READ32(&ioc->chip->Doorbell)
1009 & MPI_DOORBELL_ACTIVE)
1010 return -1;
1011
1012 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
1013
1014 CHIPREG_WRITE32(&ioc->chip->Doorbell,
1015 ((MPI_FUNCTION_HOST_PAGEBUF_ACCESS_CONTROL
1016 <<MPI_DOORBELL_FUNCTION_SHIFT) |
1017 (access_control_value<<12)));
1018
1019 /* Wait for IOC to clear Doorbell Status bit */
1020 if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
1021 return -2;
1022 }else
1023 return 0;
1024}
1025
1026/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1027/**
1028 * mpt_host_page_alloc - allocate system memory for the fw
1029 * If we already allocated memory in past, then resend the same pointer.
1030 * ioc@: Pointer to pointer to IOC adapter
1031 * ioc_init@: Pointer to ioc init config page
1032 *
1033 * Returns 0 for success, non-zero for failure.
1034 */
1035static int
1036mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init)
1037{
1038 char *psge;
1039 int flags_length;
1040 u32 host_page_buffer_sz=0;
1041
1042 if(!ioc->HostPageBuffer) {
1043
1044 host_page_buffer_sz =
1045 le32_to_cpu(ioc->facts.HostPageBufferSGE.FlagsLength) & 0xFFFFFF;
1046
1047 if(!host_page_buffer_sz)
1048 return 0; /* fw doesn't need any host buffers */
1049
1050 /* spin till we get enough memory */
1051 while(host_page_buffer_sz > 0) {
1052
1053 if((ioc->HostPageBuffer = pci_alloc_consistent(
1054 ioc->pcidev,
1055 host_page_buffer_sz,
1056 &ioc->HostPageBuffer_dma)) != NULL) {
1057
1058 dinitprintk((MYIOC_s_INFO_FMT
1059 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n",
1060 ioc->name,
1061 ioc->HostPageBuffer,
1062 ioc->HostPageBuffer_dma,
1063 host_page_buffer_sz));
1064 ioc->alloc_total += host_page_buffer_sz;
1065 ioc->HostPageBuffer_sz = host_page_buffer_sz;
1066 break;
1067 }
1068
1069 host_page_buffer_sz -= (4*1024);
1070 }
1071 }
1072
1073 if(!ioc->HostPageBuffer) {
1074 printk(MYIOC_s_ERR_FMT
1075 "Failed to alloc memory for host_page_buffer!\n",
1076 ioc->name);
1077 return -999;
1078 }
1079
1080 psge = (char *)&ioc_init->HostPageBufferSGE;
1081 flags_length = MPI_SGE_FLAGS_SIMPLE_ELEMENT |
1082 MPI_SGE_FLAGS_SYSTEM_ADDRESS |
1083 MPI_SGE_FLAGS_32_BIT_ADDRESSING |
1084 MPI_SGE_FLAGS_HOST_TO_IOC |
1085 MPI_SGE_FLAGS_END_OF_BUFFER;
1086 if (sizeof(dma_addr_t) == sizeof(u64)) {
1087 flags_length |= MPI_SGE_FLAGS_64_BIT_ADDRESSING;
1088 }
1089 flags_length = flags_length << MPI_SGE_FLAGS_SHIFT;
1090 flags_length |= ioc->HostPageBuffer_sz;
1091 mpt_add_sge(psge, flags_length, ioc->HostPageBuffer_dma);
1092 ioc->facts.HostPageBufferSGE = ioc_init->HostPageBufferSGE;
1093
1094return 0;
1095}
1096
1097/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1098/**
980 * mpt_verify_adapter - Given a unique IOC identifier, set pointer to 1099 * mpt_verify_adapter - Given a unique IOC identifier, set pointer to
981 * the associated MPT adapter structure. 1100 * the associated MPT adapter structure.
982 * @iocid: IOC unique identifier (integer) 1101 * @iocid: IOC unique identifier (integer)
@@ -1084,7 +1203,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1084 1203
1085 /* Initilize SCSI Config Data structure 1204 /* Initilize SCSI Config Data structure
1086 */ 1205 */
1087 memset(&ioc->spi_data, 0, sizeof(ScsiCfgData)); 1206 memset(&ioc->spi_data, 0, sizeof(SpiCfgData));
1088 1207
1089 /* Initialize the running configQ head. 1208 /* Initialize the running configQ head.
1090 */ 1209 */
@@ -1213,6 +1332,33 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1213 ioc->prod_name = "LSI53C1035"; 1332 ioc->prod_name = "LSI53C1035";
1214 ioc->bus_type = SCSI; 1333 ioc->bus_type = SCSI;
1215 } 1334 }
1335 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) {
1336 ioc->prod_name = "LSISAS1064";
1337 ioc->bus_type = SAS;
1338 ioc->errata_flag_1064 = 1;
1339 }
1340 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066) {
1341 ioc->prod_name = "LSISAS1066";
1342 ioc->bus_type = SAS;
1343 ioc->errata_flag_1064 = 1;
1344 }
1345 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) {
1346 ioc->prod_name = "LSISAS1068";
1347 ioc->bus_type = SAS;
1348 ioc->errata_flag_1064 = 1;
1349 }
1350 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064E) {
1351 ioc->prod_name = "LSISAS1064E";
1352 ioc->bus_type = SAS;
1353 }
1354 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1066E) {
1355 ioc->prod_name = "LSISAS1066E";
1356 ioc->bus_type = SAS;
1357 }
1358 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) {
1359 ioc->prod_name = "LSISAS1068E";
1360 ioc->bus_type = SAS;
1361 }
1216 1362
1217 if (ioc->errata_flag_1064) 1363 if (ioc->errata_flag_1064)
1218 pci_disable_io_access(pdev); 1364 pci_disable_io_access(pdev);
@@ -1604,8 +1750,23 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1604 */ 1750 */
1605 if (ret == 0) { 1751 if (ret == 0) {
1606 rc = mpt_do_upload(ioc, sleepFlag); 1752 rc = mpt_do_upload(ioc, sleepFlag);
1607 if (rc != 0) 1753 if (rc == 0) {
1754 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw) {
1755 /*
1756 * Maintain only one pointer to FW memory
1757 * so there will not be two attempt to
1758 * downloadboot onboard dual function
1759 * chips (mpt_adapter_disable,
1760 * mpt_diag_reset)
1761 */
1762 ioc->cached_fw = NULL;
1763 ddlprintk((MYIOC_s_INFO_FMT ": mpt_upload: alt_%s has cached_fw=%p \n",
1764 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));
1765 }
1766 } else {
1608 printk(KERN_WARNING MYNAM ": firmware upload failure!\n"); 1767 printk(KERN_WARNING MYNAM ": firmware upload failure!\n");
1768 ret = -5;
1769 }
1609 } 1770 }
1610 } 1771 }
1611 } 1772 }
@@ -1640,7 +1801,22 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1640 * and we try GetLanConfigPages again... 1801 * and we try GetLanConfigPages again...
1641 */ 1802 */
1642 if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) { 1803 if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) {
1643 if (ioc->bus_type == FC) { 1804 if (ioc->bus_type == SAS) {
1805
1806 /* clear persistency table */
1807 if(ioc->facts.IOCExceptions &
1808 MPI_IOCFACTS_EXCEPT_PERSISTENT_TABLE_FULL) {
1809 ret = mptbase_sas_persist_operation(ioc,
1810 MPI_SAS_OP_CLEAR_NOT_PRESENT);
1811 if(ret != 0)
1812 return -1;
1813 }
1814
1815 /* Find IM volumes
1816 */
1817 mpt_findImVolumes(ioc);
1818
1819 } else if (ioc->bus_type == FC) {
1644 /* 1820 /*
1645 * Pre-fetch FC port WWN and stuff... 1821 * Pre-fetch FC port WWN and stuff...
1646 * (FCPortPage0_t stuff) 1822 * (FCPortPage0_t stuff)
@@ -1783,7 +1959,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
1783 1959
1784 if (ioc->cached_fw != NULL) { 1960 if (ioc->cached_fw != NULL) {
1785 ddlprintk((KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n")); 1961 ddlprintk((KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n"));
1786 if ((ret = mpt_downloadboot(ioc, NO_SLEEP)) < 0) { 1962 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) {
1787 printk(KERN_WARNING MYNAM 1963 printk(KERN_WARNING MYNAM
1788 ": firmware downloadboot failure (%d)!\n", ret); 1964 ": firmware downloadboot failure (%d)!\n", ret);
1789 } 1965 }
@@ -1831,9 +2007,9 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
1831 } 2007 }
1832 2008
1833 kfree(ioc->spi_data.nvram); 2009 kfree(ioc->spi_data.nvram);
1834 kfree(ioc->spi_data.pIocPg3); 2010 kfree(ioc->raid_data.pIocPg3);
1835 ioc->spi_data.nvram = NULL; 2011 ioc->spi_data.nvram = NULL;
1836 ioc->spi_data.pIocPg3 = NULL; 2012 ioc->raid_data.pIocPg3 = NULL;
1837 2013
1838 if (ioc->spi_data.pIocPg4 != NULL) { 2014 if (ioc->spi_data.pIocPg4 != NULL) {
1839 sz = ioc->spi_data.IocPg4Sz; 2015 sz = ioc->spi_data.IocPg4Sz;
@@ -1852,6 +2028,23 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
1852 2028
1853 kfree(ioc->ChainToChain); 2029 kfree(ioc->ChainToChain);
1854 ioc->ChainToChain = NULL; 2030 ioc->ChainToChain = NULL;
2031
2032 if (ioc->HostPageBuffer != NULL) {
2033 if((ret = mpt_host_page_access_control(ioc,
2034 MPI_DB_HPBAC_FREE_BUFFER, NO_SLEEP)) != 0) {
2035 printk(KERN_ERR MYNAM
2036 ": %s: host page buffers free failed (%d)!\n",
2037 __FUNCTION__, ret);
2038 }
2039 dexitprintk((KERN_INFO MYNAM ": %s HostPageBuffer free @ %p, sz=%d bytes\n",
2040 ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz));
2041 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz,
2042 ioc->HostPageBuffer,
2043 ioc->HostPageBuffer_dma);
2044 ioc->HostPageBuffer = NULL;
2045 ioc->HostPageBuffer_sz = 0;
2046 ioc->alloc_total -= ioc->HostPageBuffer_sz;
2047 }
1855} 2048}
1856 2049
1857/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2050/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -2034,7 +2227,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2034 * Loop here waiting for IOC to come READY. 2227 * Loop here waiting for IOC to come READY.
2035 */ 2228 */
2036 ii = 0; 2229 ii = 0;
2037 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 15; /* 15 seconds */ 2230 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 5; /* 5 seconds */
2038 2231
2039 while ((ioc_state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) { 2232 while ((ioc_state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) {
2040 if (ioc_state == MPI_IOC_STATE_OPERATIONAL) { 2233 if (ioc_state == MPI_IOC_STATE_OPERATIONAL) {
@@ -2212,6 +2405,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2212 le32_to_cpu(facts->CurrentSenseBufferHighAddr); 2405 le32_to_cpu(facts->CurrentSenseBufferHighAddr);
2213 facts->CurReplyFrameSize = 2406 facts->CurReplyFrameSize =
2214 le16_to_cpu(facts->CurReplyFrameSize); 2407 le16_to_cpu(facts->CurReplyFrameSize);
2408 facts->IOCCapabilities = le32_to_cpu(facts->IOCCapabilities);
2215 2409
2216 /* 2410 /*
2217 * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx 2411 * Handle NEW (!) IOCFactsReply fields in MPI-1.01.xx
@@ -2383,13 +2577,25 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2383 ddlprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n", 2577 ddlprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n",
2384 ioc->name, ioc->upload_fw, ioc->facts.Flags)); 2578 ioc->name, ioc->upload_fw, ioc->facts.Flags));
2385 2579
2386 if (ioc->bus_type == FC) 2580 if(ioc->bus_type == SAS)
2581 ioc_init.MaxDevices = ioc->facts.MaxDevices;
2582 else if(ioc->bus_type == FC)
2387 ioc_init.MaxDevices = MPT_MAX_FC_DEVICES; 2583 ioc_init.MaxDevices = MPT_MAX_FC_DEVICES;
2388 else 2584 else
2389 ioc_init.MaxDevices = MPT_MAX_SCSI_DEVICES; 2585 ioc_init.MaxDevices = MPT_MAX_SCSI_DEVICES;
2390
2391 ioc_init.MaxBuses = MPT_MAX_BUS; 2586 ioc_init.MaxBuses = MPT_MAX_BUS;
2392 2587 dinitprintk((MYIOC_s_INFO_FMT "facts.MsgVersion=%x\n",
2588 ioc->name, ioc->facts.MsgVersion));
2589 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) {
2590 // set MsgVersion and HeaderVersion host driver was built with
2591 ioc_init.MsgVersion = cpu_to_le16(MPI_VERSION);
2592 ioc_init.HeaderVersion = cpu_to_le16(MPI_HEADER_VERSION);
2593
2594 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_HOST_PAGE_BUFFER_PERSISTENT) {
2595 ioc_init.HostPageBufferSGE = ioc->facts.HostPageBufferSGE;
2596 } else if(mpt_host_page_alloc(ioc, &ioc_init))
2597 return -99;
2598 }
2393 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */ 2599 ioc_init.ReplyFrameSize = cpu_to_le16(ioc->reply_sz); /* in BYTES */
2394 2600
2395 if (sizeof(dma_addr_t) == sizeof(u64)) { 2601 if (sizeof(dma_addr_t) == sizeof(u64)) {
@@ -2403,17 +2609,21 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2403 ioc_init.HostMfaHighAddr = cpu_to_le32(0); 2609 ioc_init.HostMfaHighAddr = cpu_to_le32(0);
2404 ioc_init.SenseBufferHighAddr = cpu_to_le32(0); 2610 ioc_init.SenseBufferHighAddr = cpu_to_le32(0);
2405 } 2611 }
2406 2612
2407 ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr; 2613 ioc->facts.CurrentHostMfaHighAddr = ioc_init.HostMfaHighAddr;
2408 ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr; 2614 ioc->facts.CurrentSenseBufferHighAddr = ioc_init.SenseBufferHighAddr;
2615 ioc->facts.MaxDevices = ioc_init.MaxDevices;
2616 ioc->facts.MaxBuses = ioc_init.MaxBuses;
2409 2617
2410 dhsprintk((MYIOC_s_INFO_FMT "Sending IOCInit (req @ %p)\n", 2618 dhsprintk((MYIOC_s_INFO_FMT "Sending IOCInit (req @ %p)\n",
2411 ioc->name, &ioc_init)); 2619 ioc->name, &ioc_init));
2412 2620
2413 r = mpt_handshake_req_reply_wait(ioc, sizeof(IOCInit_t), (u32*)&ioc_init, 2621 r = mpt_handshake_req_reply_wait(ioc, sizeof(IOCInit_t), (u32*)&ioc_init,
2414 sizeof(MPIDefaultReply_t), (u16*)&init_reply, 10 /*seconds*/, sleepFlag); 2622 sizeof(MPIDefaultReply_t), (u16*)&init_reply, 10 /*seconds*/, sleepFlag);
2415 if (r != 0) 2623 if (r != 0) {
2624 printk(MYIOC_s_ERR_FMT "Sending IOCInit failed(%d)!\n",ioc->name, r);
2416 return r; 2625 return r;
2626 }
2417 2627
2418 /* No need to byte swap the multibyte fields in the reply 2628 /* No need to byte swap the multibyte fields in the reply
2419 * since we don't even look at it's contents. 2629 * since we don't even look at it's contents.
@@ -2472,7 +2682,7 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2472{ 2682{
2473 PortEnable_t port_enable; 2683 PortEnable_t port_enable;
2474 MPIDefaultReply_t reply_buf; 2684 MPIDefaultReply_t reply_buf;
2475 int ii; 2685 int rc;
2476 int req_sz; 2686 int req_sz;
2477 int reply_sz; 2687 int reply_sz;
2478 2688
@@ -2494,22 +2704,15 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2494 2704
2495 /* RAID FW may take a long time to enable 2705 /* RAID FW may take a long time to enable
2496 */ 2706 */
2497 if (ioc->bus_type == FC) { 2707 if ( (ioc->facts.ProductID & MPI_FW_HEADER_PID_PROD_MASK)
2498 ii = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable, 2708 > MPI_FW_HEADER_PID_PROD_TARGET_SCSI ) {
2499 reply_sz, (u16*)&reply_buf, 65 /*seconds*/, sleepFlag); 2709 rc = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable,
2500 } else {
2501 ii = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable,
2502 reply_sz, (u16*)&reply_buf, 300 /*seconds*/, sleepFlag); 2710 reply_sz, (u16*)&reply_buf, 300 /*seconds*/, sleepFlag);
2711 } else {
2712 rc = mpt_handshake_req_reply_wait(ioc, req_sz, (u32*)&port_enable,
2713 reply_sz, (u16*)&reply_buf, 30 /*seconds*/, sleepFlag);
2503 } 2714 }
2504 2715 return rc;
2505 if (ii != 0)
2506 return ii;
2507
2508 /* We do not even look at the reply, so we need not
2509 * swap the multi-byte fields.
2510 */
2511
2512 return 0;
2513} 2716}
2514 2717
2515/* 2718/*
@@ -2666,9 +2869,8 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
2666 * <0 for fw upload failure. 2869 * <0 for fw upload failure.
2667 */ 2870 */
2668static int 2871static int
2669mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag) 2872mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
2670{ 2873{
2671 MpiFwHeader_t *pFwHeader;
2672 MpiExtImageHeader_t *pExtImage; 2874 MpiExtImageHeader_t *pExtImage;
2673 u32 fwSize; 2875 u32 fwSize;
2674 u32 diag0val; 2876 u32 diag0val;
@@ -2679,18 +2881,8 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
2679 u32 load_addr; 2881 u32 load_addr;
2680 u32 ioc_state=0; 2882 u32 ioc_state=0;
2681 2883
2682 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x, ioc FW Ptr %p\n", 2884 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p\n",
2683 ioc->name, ioc->facts.FWImageSize, ioc->cached_fw)); 2885 ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader));
2684
2685 if ( ioc->facts.FWImageSize == 0 )
2686 return -1;
2687
2688 if (ioc->cached_fw == NULL)
2689 return -2;
2690
2691 /* prevent a second downloadboot and memory free with alt_ioc */
2692 if (ioc->alt_ioc && ioc->alt_ioc->cached_fw)
2693 ioc->alt_ioc->cached_fw = NULL;
2694 2886
2695 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); 2887 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
2696 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE); 2888 CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE);
@@ -2718,16 +2910,17 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
2718 ioc->name, count)); 2910 ioc->name, count));
2719 break; 2911 break;
2720 } 2912 }
2721 /* wait 1 sec */ 2913 /* wait .1 sec */
2722 if (sleepFlag == CAN_SLEEP) { 2914 if (sleepFlag == CAN_SLEEP) {
2723 msleep_interruptible (1000); 2915 msleep_interruptible (100);
2724 } else { 2916 } else {
2725 mdelay (1000); 2917 mdelay (100);
2726 } 2918 }
2727 } 2919 }
2728 2920
2729 if ( count == 30 ) { 2921 if ( count == 30 ) {
2730 ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! Unable to RESET_ADAPTER diag0val=%x\n", 2922 ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! "
2923 "Unable to get MPI_DIAG_DRWE mode, diag0val=%x\n",
2731 ioc->name, diag0val)); 2924 ioc->name, diag0val));
2732 return -3; 2925 return -3;
2733 } 2926 }
@@ -2742,7 +2935,6 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
2742 /* Set the DiagRwEn and Disable ARM bits */ 2935 /* Set the DiagRwEn and Disable ARM bits */
2743 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM)); 2936 CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM));
2744 2937
2745 pFwHeader = (MpiFwHeader_t *) ioc->cached_fw;
2746 fwSize = (pFwHeader->ImageSize + 3)/4; 2938 fwSize = (pFwHeader->ImageSize + 3)/4;
2747 ptrFw = (u32 *) pFwHeader; 2939 ptrFw = (u32 *) pFwHeader;
2748 2940
@@ -2792,19 +2984,38 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
2792 /* Clear the internal flash bad bit - autoincrementing register, 2984 /* Clear the internal flash bad bit - autoincrementing register,
2793 * so must do two writes. 2985 * so must do two writes.
2794 */ 2986 */
2795 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); 2987 if (ioc->bus_type == SCSI) {
2796 diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData); 2988 /*
2797 diagRwData |= 0x4000000; 2989 * 1030 and 1035 H/W errata, workaround to access
2798 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000); 2990 * the ClearFlashBadSignatureBit
2799 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData); 2991 */
2992 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000);
2993 diagRwData = CHIPREG_PIO_READ32(&ioc->pio_chip->DiagRwData);
2994 diagRwData |= 0x40000000;
2995 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000);
2996 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData);
2997
2998 } else /* if((ioc->bus_type == SAS) || (ioc->bus_type == FC)) */ {
2999 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3000 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val |
3001 MPI_DIAG_CLEAR_FLASH_BAD_SIG);
3002
3003 /* wait 1 msec */
3004 if (sleepFlag == CAN_SLEEP) {
3005 msleep_interruptible (1);
3006 } else {
3007 mdelay (1);
3008 }
3009 }
2800 3010
2801 if (ioc->errata_flag_1064) 3011 if (ioc->errata_flag_1064)
2802 pci_disable_io_access(ioc->pcidev); 3012 pci_disable_io_access(ioc->pcidev);
2803 3013
2804 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3014 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
2805 ddlprintk((MYIOC_s_INFO_FMT "downloadboot diag0val=%x, turning off PREVENT_IOC_BOOT, DISABLE_ARM\n", 3015 ddlprintk((MYIOC_s_INFO_FMT "downloadboot diag0val=%x, "
3016 "turning off PREVENT_IOC_BOOT, DISABLE_ARM, RW_ENABLE\n",
2806 ioc->name, diag0val)); 3017 ioc->name, diag0val));
2807 diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM); 3018 diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM | MPI_DIAG_RW_ENABLE);
2808 ddlprintk((MYIOC_s_INFO_FMT "downloadboot now diag0val=%x\n", 3019 ddlprintk((MYIOC_s_INFO_FMT "downloadboot now diag0val=%x\n",
2809 ioc->name, diag0val)); 3020 ioc->name, diag0val));
2810 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); 3021 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
@@ -2812,10 +3023,23 @@ mpt_downloadboot(MPT_ADAPTER *ioc, int sleepFlag)
2812 /* Write 0xFF to reset the sequencer */ 3023 /* Write 0xFF to reset the sequencer */
2813 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); 3024 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
2814 3025
3026 if (ioc->bus_type == SAS) {
3027 ioc_state = mpt_GetIocState(ioc, 0);
3028 if ( (GetIocFacts(ioc, sleepFlag,
3029 MPT_HOSTEVENT_IOC_BRINGUP)) != 0 ) {
3030 ddlprintk((MYIOC_s_INFO_FMT "GetIocFacts failed: IocState=%x\n",
3031 ioc->name, ioc_state));
3032 return -EFAULT;
3033 }
3034 }
3035
2815 for (count=0; count<HZ*20; count++) { 3036 for (count=0; count<HZ*20; count++) {
2816 if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) { 3037 if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) {
2817 ddlprintk((MYIOC_s_INFO_FMT "downloadboot successful! (count=%d) IocState=%x\n", 3038 ddlprintk((MYIOC_s_INFO_FMT "downloadboot successful! (count=%d) IocState=%x\n",
2818 ioc->name, count, ioc_state)); 3039 ioc->name, count, ioc_state));
3040 if (ioc->bus_type == SAS) {
3041 return 0;
3042 }
2819 if ((SendIocInit(ioc, sleepFlag)) != 0) { 3043 if ((SendIocInit(ioc, sleepFlag)) != 0) {
2820 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit failed\n", 3044 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit failed\n",
2821 ioc->name)); 3045 ioc->name));
@@ -3049,12 +3273,13 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3049 3273
3050 /* wait 1 sec */ 3274 /* wait 1 sec */
3051 if (sleepFlag == CAN_SLEEP) { 3275 if (sleepFlag == CAN_SLEEP) {
3052 ssleep(1); 3276 msleep_interruptible (1000);
3053 } else { 3277 } else {
3054 mdelay (1000); 3278 mdelay (1000);
3055 } 3279 }
3056 } 3280 }
3057 if ((count = mpt_downloadboot(ioc, sleepFlag)) < 0) { 3281 if ((count = mpt_downloadboot(ioc,
3282 (MpiFwHeader_t *)ioc->cached_fw, sleepFlag)) < 0) {
3058 printk(KERN_WARNING MYNAM 3283 printk(KERN_WARNING MYNAM
3059 ": firmware downloadboot failure (%d)!\n", count); 3284 ": firmware downloadboot failure (%d)!\n", count);
3060 } 3285 }
@@ -3637,7 +3862,7 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3637 int count = 0; 3862 int count = 0;
3638 u32 intstat=0; 3863 u32 intstat=0;
3639 3864
3640 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * howlong; 3865 cntdn = 1000 * howlong;
3641 3866
3642 if (sleepFlag == CAN_SLEEP) { 3867 if (sleepFlag == CAN_SLEEP) {
3643 while (--cntdn) { 3868 while (--cntdn) {
@@ -3687,7 +3912,7 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3687 int count = 0; 3912 int count = 0;
3688 u32 intstat=0; 3913 u32 intstat=0;
3689 3914
3690 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * howlong; 3915 cntdn = 1000 * howlong;
3691 if (sleepFlag == CAN_SLEEP) { 3916 if (sleepFlag == CAN_SLEEP) {
3692 while (--cntdn) { 3917 while (--cntdn) {
3693 intstat = CHIPREG_READ32(&ioc->chip->IntStatus); 3918 intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
@@ -4001,6 +4226,85 @@ GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
4001 4226
4002/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4227/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4003/* 4228/*
4229 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table
4230 * @ioc: Pointer to MPT_ADAPTER structure
4231 * @sas_address: 64bit SAS Address for operation.
4232 * @target_id: specified target for operation
4233 * @bus: specified bus for operation
4234 * @persist_opcode: see below
4235 *
4236 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for
4237 * devices not currently present.
4238 * MPI_SAS_OP_CLEAR_ALL_PERSISTENT - Clear al persist TargetID mappings
4239 *
4240 * NOTE: Don't use not this function during interrupt time.
4241 *
4242 * Returns: 0 for success, non-zero error
4243 */
4244
4245/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4246int
4247mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode)
4248{
4249 SasIoUnitControlRequest_t *sasIoUnitCntrReq;
4250 SasIoUnitControlReply_t *sasIoUnitCntrReply;
4251 MPT_FRAME_HDR *mf = NULL;
4252 MPIHeader_t *mpi_hdr;
4253
4254
4255 /* insure garbage is not sent to fw */
4256 switch(persist_opcode) {
4257
4258 case MPI_SAS_OP_CLEAR_NOT_PRESENT:
4259 case MPI_SAS_OP_CLEAR_ALL_PERSISTENT:
4260 break;
4261
4262 default:
4263 return -1;
4264 break;
4265 }
4266
4267 printk("%s: persist_opcode=%x\n",__FUNCTION__, persist_opcode);
4268
4269 /* Get a MF for this command.
4270 */
4271 if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
4272 printk("%s: no msg frames!\n",__FUNCTION__);
4273 return -1;
4274 }
4275
4276 mpi_hdr = (MPIHeader_t *) mf;
4277 sasIoUnitCntrReq = (SasIoUnitControlRequest_t *)mf;
4278 memset(sasIoUnitCntrReq,0,sizeof(SasIoUnitControlRequest_t));
4279 sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL;
4280 sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext;
4281 sasIoUnitCntrReq->Operation = persist_opcode;
4282
4283 init_timer(&ioc->persist_timer);
4284 ioc->persist_timer.data = (unsigned long) ioc;
4285 ioc->persist_timer.function = mpt_timer_expired;
4286 ioc->persist_timer.expires = jiffies + HZ*10 /* 10 sec */;
4287 ioc->persist_wait_done=0;
4288 add_timer(&ioc->persist_timer);
4289 mpt_put_msg_frame(mpt_base_index, ioc, mf);
4290 wait_event(mpt_waitq, ioc->persist_wait_done);
4291
4292 sasIoUnitCntrReply =
4293 (SasIoUnitControlReply_t *)ioc->persist_reply_frame;
4294 if (le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) {
4295 printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
4296 __FUNCTION__,
4297 sasIoUnitCntrReply->IOCStatus,
4298 sasIoUnitCntrReply->IOCLogInfo);
4299 return -1;
4300 }
4301
4302 printk("%s: success\n",__FUNCTION__);
4303 return 0;
4304}
4305
4306/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4307/*
4004 * GetIoUnitPage2 - Retrieve BIOS version and boot order information. 4308 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
4005 * @ioc: Pointer to MPT_ADAPTER structure 4309 * @ioc: Pointer to MPT_ADAPTER structure
4006 * 4310 *
@@ -4340,10 +4644,10 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
4340 if (mpt_config(ioc, &cfg) != 0) 4644 if (mpt_config(ioc, &cfg) != 0)
4341 goto done_and_free; 4645 goto done_and_free;
4342 4646
4343 if ( (mem = (u8 *)ioc->spi_data.pIocPg2) == NULL ) { 4647 if ( (mem = (u8 *)ioc->raid_data.pIocPg2) == NULL ) {
4344 mem = kmalloc(iocpage2sz, GFP_ATOMIC); 4648 mem = kmalloc(iocpage2sz, GFP_ATOMIC);
4345 if (mem) { 4649 if (mem) {
4346 ioc->spi_data.pIocPg2 = (IOCPage2_t *) mem; 4650 ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
4347 } else { 4651 } else {
4348 goto done_and_free; 4652 goto done_and_free;
4349 } 4653 }
@@ -4360,7 +4664,7 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
4360 /* At least 1 RAID Volume 4664 /* At least 1 RAID Volume
4361 */ 4665 */
4362 pIocRv = pIoc2->RaidVolume; 4666 pIocRv = pIoc2->RaidVolume;
4363 ioc->spi_data.isRaid = 0; 4667 ioc->raid_data.isRaid = 0;
4364 for (jj = 0; jj < nVols; jj++, pIocRv++) { 4668 for (jj = 0; jj < nVols; jj++, pIocRv++) {
4365 vid = pIocRv->VolumeID; 4669 vid = pIocRv->VolumeID;
4366 vbus = pIocRv->VolumeBus; 4670 vbus = pIocRv->VolumeBus;
@@ -4369,7 +4673,7 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
4369 /* find the match 4673 /* find the match
4370 */ 4674 */
4371 if (vbus == 0) { 4675 if (vbus == 0) {
4372 ioc->spi_data.isRaid |= (1 << vid); 4676 ioc->raid_data.isRaid |= (1 << vid);
4373 } else { 4677 } else {
4374 /* Error! Always bus 0 4678 /* Error! Always bus 0
4375 */ 4679 */
@@ -4404,8 +4708,8 @@ mpt_read_ioc_pg_3(MPT_ADAPTER *ioc)
4404 4708
4405 /* Free the old page 4709 /* Free the old page
4406 */ 4710 */
4407 kfree(ioc->spi_data.pIocPg3); 4711 kfree(ioc->raid_data.pIocPg3);
4408 ioc->spi_data.pIocPg3 = NULL; 4712 ioc->raid_data.pIocPg3 = NULL;
4409 4713
4410 /* There is at least one physical disk. 4714 /* There is at least one physical disk.
4411 * Read and save IOC Page 3 4715 * Read and save IOC Page 3
@@ -4442,7 +4746,7 @@ mpt_read_ioc_pg_3(MPT_ADAPTER *ioc)
4442 mem = kmalloc(iocpage3sz, GFP_ATOMIC); 4746 mem = kmalloc(iocpage3sz, GFP_ATOMIC);
4443 if (mem) { 4747 if (mem) {
4444 memcpy(mem, (u8 *)pIoc3, iocpage3sz); 4748 memcpy(mem, (u8 *)pIoc3, iocpage3sz);
4445 ioc->spi_data.pIocPg3 = (IOCPage3_t *) mem; 4749 ioc->raid_data.pIocPg3 = (IOCPage3_t *) mem;
4446 } 4750 }
4447 } 4751 }
4448 4752
@@ -5366,8 +5670,8 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
5366} 5670}
5367 5671
5368/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5672/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5369static char * 5673static void
5370EventDescriptionStr(u8 event, u32 evData0) 5674EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5371{ 5675{
5372 char *ds; 5676 char *ds;
5373 5677
@@ -5420,8 +5724,95 @@ EventDescriptionStr(u8 event, u32 evData0)
5420 ds = "Events(OFF) Change"; 5724 ds = "Events(OFF) Change";
5421 break; 5725 break;
5422 case MPI_EVENT_INTEGRATED_RAID: 5726 case MPI_EVENT_INTEGRATED_RAID:
5423 ds = "Integrated Raid"; 5727 {
5728 u8 ReasonCode = (u8)(evData0 >> 16);
5729 switch (ReasonCode) {
5730 case MPI_EVENT_RAID_RC_VOLUME_CREATED :
5731 ds = "Integrated Raid: Volume Created";
5732 break;
5733 case MPI_EVENT_RAID_RC_VOLUME_DELETED :
5734 ds = "Integrated Raid: Volume Deleted";
5735 break;
5736 case MPI_EVENT_RAID_RC_VOLUME_SETTINGS_CHANGED :
5737 ds = "Integrated Raid: Volume Settings Changed";
5738 break;
5739 case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED :
5740 ds = "Integrated Raid: Volume Status Changed";
5741 break;
5742 case MPI_EVENT_RAID_RC_VOLUME_PHYSDISK_CHANGED :
5743 ds = "Integrated Raid: Volume Physdisk Changed";
5744 break;
5745 case MPI_EVENT_RAID_RC_PHYSDISK_CREATED :
5746 ds = "Integrated Raid: Physdisk Created";
5747 break;
5748 case MPI_EVENT_RAID_RC_PHYSDISK_DELETED :
5749 ds = "Integrated Raid: Physdisk Deleted";
5750 break;
5751 case MPI_EVENT_RAID_RC_PHYSDISK_SETTINGS_CHANGED :
5752 ds = "Integrated Raid: Physdisk Settings Changed";
5753 break;
5754 case MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED :
5755 ds = "Integrated Raid: Physdisk Status Changed";
5756 break;
5757 case MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED :
5758 ds = "Integrated Raid: Domain Validation Needed";
5759 break;
5760 case MPI_EVENT_RAID_RC_SMART_DATA :
5761 ds = "Integrated Raid; Smart Data";
5762 break;
5763 case MPI_EVENT_RAID_RC_REPLACE_ACTION_STARTED :
5764 ds = "Integrated Raid: Replace Action Started";
5765 break;
5766 default:
5767 ds = "Integrated Raid";
5768 break;
5769 }
5770 break;
5771 }
5772 case MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE:
5773 ds = "SCSI Device Status Change";
5774 break;
5775 case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
5776 {
5777 u8 ReasonCode = (u8)(evData0 >> 16);
5778 switch (ReasonCode) {
5779 case MPI_EVENT_SAS_DEV_STAT_RC_ADDED:
5780 ds = "SAS Device Status Change: Added";
5781 break;
5782 case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING:
5783 ds = "SAS Device Status Change: Deleted";
5784 break;
5785 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
5786 ds = "SAS Device Status Change: SMART Data";
5787 break;
5788 case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED:
5789 ds = "SAS Device Status Change: No Persistancy Added";
5790 break;
5791 default:
5792 ds = "SAS Device Status Change: Unknown";
5793 break;
5794 }
5795 break;
5796 }
5797 case MPI_EVENT_ON_BUS_TIMER_EXPIRED:
5798 ds = "Bus Timer Expired";
5799 break;
5800 case MPI_EVENT_QUEUE_FULL:
5801 ds = "Queue Full";
5802 break;
5803 case MPI_EVENT_SAS_SES:
5804 ds = "SAS SES Event";
5805 break;
5806 case MPI_EVENT_PERSISTENT_TABLE_FULL:
5807 ds = "Persistent Table Full";
5808 break;
5809 case MPI_EVENT_SAS_PHY_LINK_STATUS:
5810 ds = "SAS PHY Link Status";
5811 break;
5812 case MPI_EVENT_SAS_DISCOVERY_ERROR:
5813 ds = "SAS Discovery Error";
5424 break; 5814 break;
5815
5425 /* 5816 /*
5426 * MPT base "custom" events may be added here... 5817 * MPT base "custom" events may be added here...
5427 */ 5818 */
@@ -5429,7 +5820,7 @@ EventDescriptionStr(u8 event, u32 evData0)
5429 ds = "Unknown"; 5820 ds = "Unknown";
5430 break; 5821 break;
5431 } 5822 }
5432 return ds; 5823 strcpy(evStr,ds);
5433} 5824}
5434 5825
5435/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5826/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -5451,7 +5842,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
5451 int ii; 5842 int ii;
5452 int r = 0; 5843 int r = 0;
5453 int handlers = 0; 5844 int handlers = 0;
5454 char *evStr; 5845 char evStr[100];
5455 u8 event; 5846 u8 event;
5456 5847
5457 /* 5848 /*
@@ -5464,7 +5855,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
5464 evData0 = le32_to_cpu(pEventReply->Data[0]); 5855 evData0 = le32_to_cpu(pEventReply->Data[0]);
5465 } 5856 }
5466 5857
5467 evStr = EventDescriptionStr(event, evData0); 5858 EventDescriptionStr(event, evData0, evStr);
5468 devtprintk((MYIOC_s_INFO_FMT "MPT event (%s=%02Xh) detected!\n", 5859 devtprintk((MYIOC_s_INFO_FMT "MPT event (%s=%02Xh) detected!\n",
5469 ioc->name, 5860 ioc->name,
5470 evStr, 5861 evStr,
@@ -5481,20 +5872,6 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
5481 * Do general / base driver event processing 5872 * Do general / base driver event processing
5482 */ 5873 */
5483 switch(event) { 5874 switch(event) {
5484 case MPI_EVENT_NONE: /* 00 */
5485 case MPI_EVENT_LOG_DATA: /* 01 */
5486 case MPI_EVENT_STATE_CHANGE: /* 02 */
5487 case MPI_EVENT_UNIT_ATTENTION: /* 03 */
5488 case MPI_EVENT_IOC_BUS_RESET: /* 04 */
5489 case MPI_EVENT_EXT_BUS_RESET: /* 05 */
5490 case MPI_EVENT_RESCAN: /* 06 */
5491 case MPI_EVENT_LINK_STATUS_CHANGE: /* 07 */
5492 case MPI_EVENT_LOOP_STATE_CHANGE: /* 08 */
5493 case MPI_EVENT_LOGOUT: /* 09 */
5494 case MPI_EVENT_INTEGRATED_RAID: /* 0B */
5495 case MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE: /* 0C */
5496 default:
5497 break;
5498 case MPI_EVENT_EVENT_CHANGE: /* 0A */ 5875 case MPI_EVENT_EVENT_CHANGE: /* 0A */
5499 if (evDataLen) { 5876 if (evDataLen) {
5500 u8 evState = evData0 & 0xFF; 5877 u8 evState = evData0 & 0xFF;
@@ -5507,6 +5884,8 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
5507 } 5884 }
5508 } 5885 }
5509 break; 5886 break;
5887 default:
5888 break;
5510 } 5889 }
5511 5890
5512 /* 5891 /*
@@ -5653,6 +6032,111 @@ mpt_sp_log_info(MPT_ADAPTER *ioc, u32 log_info)
5653 printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc); 6032 printk(MYIOC_s_INFO_FMT "LogInfo(0x%08x): F/W: %s\n", ioc->name, log_info, desc);
5654} 6033}
5655 6034
6035/* strings for sas loginfo */
6036 static char *originator_str[] = {
6037 "IOP", /* 00h */
6038 "PL", /* 01h */
6039 "IR" /* 02h */
6040 };
6041 static char *iop_code_str[] = {
6042 NULL, /* 00h */
6043 "Invalid SAS Address", /* 01h */
6044 NULL, /* 02h */
6045 "Invalid Page", /* 03h */
6046 NULL, /* 04h */
6047 "Task Terminated" /* 05h */
6048 };
6049 static char *pl_code_str[] = {
6050 NULL, /* 00h */
6051 "Open Failure", /* 01h */
6052 "Invalid Scatter Gather List", /* 02h */
6053 "Wrong Relative Offset or Frame Length", /* 03h */
6054 "Frame Transfer Error", /* 04h */
6055 "Transmit Frame Connected Low", /* 05h */
6056 "SATA Non-NCQ RW Error Bit Set", /* 06h */
6057 "SATA Read Log Receive Data Error", /* 07h */
6058 "SATA NCQ Fail All Commands After Error", /* 08h */
6059 "SATA Error in Receive Set Device Bit FIS", /* 09h */
6060 "Receive Frame Invalid Message", /* 0Ah */
6061 "Receive Context Message Valid Error", /* 0Bh */
6062 "Receive Frame Current Frame Error", /* 0Ch */
6063 "SATA Link Down", /* 0Dh */
6064 "Discovery SATA Init W IOS", /* 0Eh */
6065 "Config Invalid Page", /* 0Fh */
6066 "Discovery SATA Init Timeout", /* 10h */
6067 "Reset", /* 11h */
6068 "Abort", /* 12h */
6069 "IO Not Yet Executed", /* 13h */
6070 "IO Executed", /* 14h */
6071 NULL, /* 15h */
6072 NULL, /* 16h */
6073 NULL, /* 17h */
6074 NULL, /* 18h */
6075 NULL, /* 19h */
6076 NULL, /* 1Ah */
6077 NULL, /* 1Bh */
6078 NULL, /* 1Ch */
6079 NULL, /* 1Dh */
6080 NULL, /* 1Eh */
6081 NULL, /* 1Fh */
6082 "Enclosure Management" /* 20h */
6083 };
6084
6085/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6086/*
6087 * mpt_sas_log_info - Log information returned from SAS IOC.
6088 * @ioc: Pointer to MPT_ADAPTER structure
6089 * @log_info: U32 LogInfo reply word from the IOC
6090 *
6091 * Refer to lsi/mpi_log_sas.h.
6092 */
6093static void
6094mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info)
6095{
6096union loginfo_type {
6097 u32 loginfo;
6098 struct {
6099 u32 subcode:16;
6100 u32 code:8;
6101 u32 originator:4;
6102 u32 bus_type:4;
6103 }dw;
6104};
6105 union loginfo_type sas_loginfo;
6106 char *code_desc = NULL;
6107
6108 sas_loginfo.loginfo = log_info;
6109 if ((sas_loginfo.dw.bus_type != 3 /*SAS*/) &&
6110 (sas_loginfo.dw.originator < sizeof(originator_str)/sizeof(char*)))
6111 return;
6112 if ((sas_loginfo.dw.originator == 0 /*IOP*/) &&
6113 (sas_loginfo.dw.code < sizeof(iop_code_str)/sizeof(char*))) {
6114 code_desc = iop_code_str[sas_loginfo.dw.code];
6115 }else if ((sas_loginfo.dw.originator == 1 /*PL*/) &&
6116 (sas_loginfo.dw.code < sizeof(pl_code_str)/sizeof(char*) )) {
6117 code_desc = pl_code_str[sas_loginfo.dw.code];
6118 }
6119
6120 if (code_desc != NULL)
6121 printk(MYIOC_s_INFO_FMT
6122 "LogInfo(0x%08x): Originator={%s}, Code={%s},"
6123 " SubCode(0x%04x)\n",
6124 ioc->name,
6125 log_info,
6126 originator_str[sas_loginfo.dw.originator],
6127 code_desc,
6128 sas_loginfo.dw.subcode);
6129 else
6130 printk(MYIOC_s_INFO_FMT
6131 "LogInfo(0x%08x): Originator={%s}, Code=(0x%02x),"
6132 " SubCode(0x%04x)\n",
6133 ioc->name,
6134 log_info,
6135 originator_str[sas_loginfo.dw.originator],
6136 sas_loginfo.dw.code,
6137 sas_loginfo.dw.subcode);
6138}
6139
5656/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6140/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5657/* 6141/*
5658 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC. 6142 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC.
@@ -5814,6 +6298,7 @@ EXPORT_SYMBOL(mpt_findImVolumes);
5814EXPORT_SYMBOL(mpt_read_ioc_pg_3); 6298EXPORT_SYMBOL(mpt_read_ioc_pg_3);
5815EXPORT_SYMBOL(mpt_alloc_fw_memory); 6299EXPORT_SYMBOL(mpt_alloc_fw_memory);
5816EXPORT_SYMBOL(mpt_free_fw_memory); 6300EXPORT_SYMBOL(mpt_free_fw_memory);
6301EXPORT_SYMBOL(mptbase_sas_persist_operation);
5817 6302
5818 6303
5819/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6304/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index f4827d923731..75105277e22f 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -65,6 +65,7 @@
65#include "lsi/mpi_fc.h" /* Fibre Channel (lowlevel) support */ 65#include "lsi/mpi_fc.h" /* Fibre Channel (lowlevel) support */
66#include "lsi/mpi_targ.h" /* SCSI/FCP Target protcol support */ 66#include "lsi/mpi_targ.h" /* SCSI/FCP Target protcol support */
67#include "lsi/mpi_tool.h" /* Tools support */ 67#include "lsi/mpi_tool.h" /* Tools support */
68#include "lsi/mpi_sas.h" /* SAS support */
68 69
69/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 70/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
70 71
@@ -76,8 +77,8 @@
76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 77#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
77#endif 78#endif
78 79
79#define MPT_LINUX_VERSION_COMMON "3.03.02" 80#define MPT_LINUX_VERSION_COMMON "3.03.03"
80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.02" 81#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.03"
81#define WHAT_MAGIC_STRING "@" "(" "#" ")" 82#define WHAT_MAGIC_STRING "@" "(" "#" ")"
82 83
83#define show_mptmod_ver(s,ver) \ 84#define show_mptmod_ver(s,ver) \
@@ -423,7 +424,7 @@ typedef struct _MPT_IOCTL {
423/* 424/*
424 * Event Structure and define 425 * Event Structure and define
425 */ 426 */
426#define MPTCTL_EVENT_LOG_SIZE (0x0000000A) 427#define MPTCTL_EVENT_LOG_SIZE (0x000000032)
427typedef struct _mpt_ioctl_events { 428typedef struct _mpt_ioctl_events {
428 u32 event; /* Specified by define above */ 429 u32 event; /* Specified by define above */
429 u32 eventContext; /* Index or counter */ 430 u32 eventContext; /* Index or counter */
@@ -451,16 +452,13 @@ typedef struct _mpt_ioctl_events {
451#define MPT_SCSICFG_ALL_IDS 0x02 /* WriteSDP1 to all IDS */ 452#define MPT_SCSICFG_ALL_IDS 0x02 /* WriteSDP1 to all IDS */
452/* #define MPT_SCSICFG_BLK_NEGO 0x10 WriteSDP1 with WDTR and SDTR disabled */ 453/* #define MPT_SCSICFG_BLK_NEGO 0x10 WriteSDP1 with WDTR and SDTR disabled */
453 454
454typedef struct _ScsiCfgData { 455typedef struct _SpiCfgData {
455 u32 PortFlags; 456 u32 PortFlags;
456 int *nvram; /* table of device NVRAM values */ 457 int *nvram; /* table of device NVRAM values */
457 IOCPage2_t *pIocPg2; /* table of Raid Volumes */
458 IOCPage3_t *pIocPg3; /* table of physical disks */
459 IOCPage4_t *pIocPg4; /* SEP devices addressing */ 458 IOCPage4_t *pIocPg4; /* SEP devices addressing */
460 dma_addr_t IocPg4_dma; /* Phys Addr of IOCPage4 data */ 459 dma_addr_t IocPg4_dma; /* Phys Addr of IOCPage4 data */
461 int IocPg4Sz; /* IOCPage4 size */ 460 int IocPg4Sz; /* IOCPage4 size */
462 u8 dvStatus[MPT_MAX_SCSI_DEVICES]; 461 u8 dvStatus[MPT_MAX_SCSI_DEVICES];
463 int isRaid; /* bit field, 1 if RAID */
464 u8 minSyncFactor; /* 0xFF if async */ 462 u8 minSyncFactor; /* 0xFF if async */
465 u8 maxSyncOffset; /* 0 if async */ 463 u8 maxSyncOffset; /* 0 if async */
466 u8 maxBusWidth; /* 0 if narrow, 1 if wide */ 464 u8 maxBusWidth; /* 0 if narrow, 1 if wide */
@@ -472,10 +470,28 @@ typedef struct _ScsiCfgData {
472 u8 dvScheduled; /* 1 if scheduled */ 470 u8 dvScheduled; /* 1 if scheduled */
473 u8 forceDv; /* 1 to force DV scheduling */ 471 u8 forceDv; /* 1 to force DV scheduling */
474 u8 noQas; /* Disable QAS for this adapter */ 472 u8 noQas; /* Disable QAS for this adapter */
475 u8 Saf_Te; /* 1 to force all Processors as SAF-TE if Inquiry data length is too short to check for SAF-TE */ 473 u8 Saf_Te; /* 1 to force all Processors as
474 * SAF-TE if Inquiry data length
475 * is too short to check for SAF-TE
476 */
476 u8 mpt_dv; /* command line option: enhanced=1, basic=0 */ 477 u8 mpt_dv; /* command line option: enhanced=1, basic=0 */
478 u8 bus_reset; /* 1 to allow bus reset */
477 u8 rsvd[1]; 479 u8 rsvd[1];
478} ScsiCfgData; 480}SpiCfgData;
481
482typedef struct _SasCfgData {
483 u8 ptClear; /* 1 to automatically clear the
484 * persistent table.
485 * 0 to disable
486 * automatic clearing.
487 */
488}SasCfgData;
489
490typedef struct _RaidCfgData {
491 IOCPage2_t *pIocPg2; /* table of Raid Volumes */
492 IOCPage3_t *pIocPg3; /* table of physical disks */
493 int isRaid; /* bit field, 1 if RAID */
494}RaidCfgData;
479 495
480/* 496/*
481 * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS 497 * Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS
@@ -530,11 +546,16 @@ typedef struct _MPT_ADAPTER
530 u8 *sense_buf_pool; 546 u8 *sense_buf_pool;
531 dma_addr_t sense_buf_pool_dma; 547 dma_addr_t sense_buf_pool_dma;
532 u32 sense_buf_low_dma; 548 u32 sense_buf_low_dma;
549 u8 *HostPageBuffer; /* SAS - host page buffer support */
550 u32 HostPageBuffer_sz;
551 dma_addr_t HostPageBuffer_dma;
533 int mtrr_reg; 552 int mtrr_reg;
534 struct pci_dev *pcidev; /* struct pci_dev pointer */ 553 struct pci_dev *pcidev; /* struct pci_dev pointer */
535 u8 __iomem *memmap; /* mmap address */ 554 u8 __iomem *memmap; /* mmap address */
536 struct Scsi_Host *sh; /* Scsi Host pointer */ 555 struct Scsi_Host *sh; /* Scsi Host pointer */
537 ScsiCfgData spi_data; /* Scsi config. data */ 556 SpiCfgData spi_data; /* Scsi config. data */
557 RaidCfgData raid_data; /* Raid config. data */
558 SasCfgData sas_data; /* Sas config. data */
538 MPT_IOCTL *ioctl; /* ioctl data pointer */ 559 MPT_IOCTL *ioctl; /* ioctl data pointer */
539 struct proc_dir_entry *ioc_dentry; 560 struct proc_dir_entry *ioc_dentry;
540 struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */ 561 struct _MPT_ADAPTER *alt_ioc; /* ptr to 929 bound adapter port */
@@ -554,31 +575,35 @@ typedef struct _MPT_ADAPTER
554#else 575#else
555 u32 mfcnt; 576 u32 mfcnt;
556#endif 577#endif
557 u32 NB_for_64_byte_frame; 578 u32 NB_for_64_byte_frame;
558 u32 hs_req[MPT_MAX_FRAME_SIZE/sizeof(u32)]; 579 u32 hs_req[MPT_MAX_FRAME_SIZE/sizeof(u32)];
559 u16 hs_reply[MPT_MAX_FRAME_SIZE/sizeof(u16)]; 580 u16 hs_reply[MPT_MAX_FRAME_SIZE/sizeof(u16)];
560 IOCFactsReply_t facts; 581 IOCFactsReply_t facts;
561 PortFactsReply_t pfacts[2]; 582 PortFactsReply_t pfacts[2];
562 FCPortPage0_t fc_port_page0[2]; 583 FCPortPage0_t fc_port_page0[2];
584 struct timer_list persist_timer; /* persist table timer */
585 int persist_wait_done; /* persist completion flag */
586 u8 persist_reply_frame[MPT_DEFAULT_FRAME_SIZE]; /* persist reply */
563 LANPage0_t lan_cnfg_page0; 587 LANPage0_t lan_cnfg_page0;
564 LANPage1_t lan_cnfg_page1; 588 LANPage1_t lan_cnfg_page1;
565 /* 589 /*
566 * Description: errata_flag_1064 590 * Description: errata_flag_1064
567 * If a PCIX read occurs within 1 or 2 cycles after the chip receives 591 * If a PCIX read occurs within 1 or 2 cycles after the chip receives
568 * a split completion for a read data, an internal address pointer incorrectly 592 * a split completion for a read data, an internal address pointer incorrectly
569 * increments by 32 bytes 593 * increments by 32 bytes
570 */ 594 */
571 int errata_flag_1064; 595 int errata_flag_1064;
572 u8 FirstWhoInit; 596 u8 FirstWhoInit;
573 u8 upload_fw; /* If set, do a fw upload */ 597 u8 upload_fw; /* If set, do a fw upload */
574 u8 reload_fw; /* Force a FW Reload on next reset */ 598 u8 reload_fw; /* Force a FW Reload on next reset */
575 u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */ 599 u8 NBShiftFactor; /* NB Shift Factor based on Block Size (Facts) */
576 u8 pad1[4]; 600 u8 pad1[4];
577 int DoneCtx; 601 int DoneCtx;
578 int TaskCtx; 602 int TaskCtx;
579 int InternalCtx; 603 int InternalCtx;
580 struct list_head list; 604 struct list_head list;
581 struct net_device *netdev; 605 struct net_device *netdev;
606 struct list_head sas_topology;
582} MPT_ADAPTER; 607} MPT_ADAPTER;
583 608
584/* 609/*
@@ -964,6 +989,7 @@ extern void mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
964extern void mpt_free_fw_memory(MPT_ADAPTER *ioc); 989extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
965extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 990extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
966extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); 991extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc);
992extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
967 993
968/* 994/*
969 * Public data decl's... 995 * Public data decl's...
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 7577c2417e2e..cb2d59d5f5af 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1326,7 +1326,7 @@ mptctl_gettargetinfo (unsigned long arg)
1326 */ 1326 */
1327 if (hd && hd->Targets) { 1327 if (hd && hd->Targets) {
1328 mpt_findImVolumes(ioc); 1328 mpt_findImVolumes(ioc);
1329 pIoc2 = ioc->spi_data.pIocPg2; 1329 pIoc2 = ioc->raid_data.pIocPg2;
1330 for ( id = 0; id <= max_id; ) { 1330 for ( id = 0; id <= max_id; ) {
1331 if ( pIoc2 && pIoc2->NumActiveVolumes ) { 1331 if ( pIoc2 && pIoc2->NumActiveVolumes ) {
1332 if ( id == pIoc2->RaidVolume[0].VolumeID ) { 1332 if ( id == pIoc2->RaidVolume[0].VolumeID ) {
@@ -1348,7 +1348,7 @@ mptctl_gettargetinfo (unsigned long arg)
1348 --maxWordsLeft; 1348 --maxWordsLeft;
1349 goto next_id; 1349 goto next_id;
1350 } else { 1350 } else {
1351 pIoc3 = ioc->spi_data.pIocPg3; 1351 pIoc3 = ioc->raid_data.pIocPg3;
1352 for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) { 1352 for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) {
1353 if ( pIoc3->PhysDisk[jj].PhysDiskID == id ) 1353 if ( pIoc3->PhysDisk[jj].PhysDiskID == id )
1354 goto next_id; 1354 goto next_id;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 13771abea13f..a628be9bbbad 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -189,7 +189,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
189 printk(MYIOC_s_WARN_FMT 189 printk(MYIOC_s_WARN_FMT
190 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", 190 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n",
191 ioc->name, ioc); 191 ioc->name, ioc);
192 return -ENODEV; 192 return 0;
193 } 193 }
194 194
195 sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST)); 195 sh = scsi_host_alloc(&mptfc_driver_template, sizeof(MPT_SCSI_HOST));
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 52794be5a95c..ed3c891e388f 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -312,7 +312,12 @@ static int
312mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 312mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
313{ 313{
314 struct net_device *dev = ioc->netdev; 314 struct net_device *dev = ioc->netdev;
315 struct mpt_lan_priv *priv = netdev_priv(dev); 315 struct mpt_lan_priv *priv;
316
317 if (dev == NULL)
318 return(1);
319 else
320 priv = netdev_priv(dev);
316 321
317 dlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to LAN driver!\n", 322 dlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to LAN driver!\n",
318 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 323 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
new file mode 100644
index 000000000000..7de19a84dc74
--- /dev/null
+++ b/drivers/message/fusion/mptsas.c
@@ -0,0 +1,1239 @@
1/*
2 * linux/drivers/message/fusion/mptsas.c
3 * For use with LSI Logic PCI chip/adapter(s)
4 * running LSI Logic Fusion MPT (Message Passing Technology) firmware.
5 *
6 * Copyright (c) 1999-2005 LSI Logic Corporation
7 * (mailto:mpt_linux_developer@lsil.com)
8 * Copyright (c) 2005 Dell
9 */
10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
11/*
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; version 2 of the License.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 NO WARRANTY
22 THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
23 CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
24 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
25 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
26 solely responsible for determining the appropriateness of using and
27 distributing the Program and assumes all risks associated with its
28 exercise of rights under this Agreement, including but not limited to
29 the risks and costs of program errors, damage to or loss of data,
30 programs or equipment, and unavailability or interruption of operations.
31
32 DISCLAIMER OF LIABILITY
33 NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
34 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
36 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
37 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
38 USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
39 HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
40
41 You should have received a copy of the GNU General Public License
42 along with this program; if not, write to the Free Software
43 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44*/
45/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
46
47#include <linux/module.h>
48#include <linux/kernel.h>
49#include <linux/init.h>
50#include <linux/errno.h>
51#include <linux/sched.h>
52#include <linux/workqueue.h>
53
54#include <scsi/scsi_cmnd.h>
55#include <scsi/scsi_device.h>
56#include <scsi/scsi_host.h>
57#include <scsi/scsi_transport_sas.h>
58
59#include "mptbase.h"
60#include "mptscsih.h"
61
62
63#define my_NAME "Fusion MPT SAS Host driver"
64#define my_VERSION MPT_LINUX_VERSION_COMMON
65#define MYNAM "mptsas"
66
67MODULE_AUTHOR(MODULEAUTHOR);
68MODULE_DESCRIPTION(my_NAME);
69MODULE_LICENSE("GPL");
70
71static int mpt_pq_filter;
72module_param(mpt_pq_filter, int, 0);
73MODULE_PARM_DESC(mpt_pq_filter,
74 "Enable peripheral qualifier filter: enable=1 "
75 "(default=0)");
76
77static int mpt_pt_clear;
78module_param(mpt_pt_clear, int, 0);
79MODULE_PARM_DESC(mpt_pt_clear,
80 "Clear persistency table: enable=1 "
81 "(default=MPTSCSIH_PT_CLEAR=0)");
82
83static int mptsasDoneCtx = -1;
84static int mptsasTaskCtx = -1;
85static int mptsasInternalCtx = -1; /* Used only for internal commands */
86
87
88/*
89 * SAS topology structures
90 *
91 * The MPT Fusion firmware interface spreads information about the
92 * SAS topology over many manufacture pages, thus we need some data
93 * structure to collect it and process it for the SAS transport class.
94 */
95
96struct mptsas_devinfo {
97 u16 handle; /* unique id to address this device */
98 u8 phy_id; /* phy number of parent device */
99 u8 port_id; /* sas physical port this device
100 is assoc'd with */
101 u8 target; /* logical target id of this device */
102 u8 bus; /* logical bus number of this device */
103 u64 sas_address; /* WWN of this device,
104 SATA is assigned by HBA,expander */
105 u32 device_info; /* bitfield detailed info about this device */
106};
107
108struct mptsas_phyinfo {
109 u8 phy_id; /* phy index */
110 u8 port_id; /* port number this phy is part of */
111 u8 negotiated_link_rate; /* nego'd link rate for this phy */
112 u8 hw_link_rate; /* hardware max/min phys link rate */
113 u8 programmed_link_rate; /* programmed max/min phy link rate */
114 struct mptsas_devinfo identify; /* point to phy device info */
115 struct mptsas_devinfo attached; /* point to attached device info */
116 struct sas_rphy *rphy;
117};
118
119struct mptsas_portinfo {
120 struct list_head list;
121 u16 handle; /* unique id to address this */
122 u8 num_phys; /* number of phys */
123 struct mptsas_phyinfo *phy_info;
124};
125
126/*
127 * This is pretty ugly. We will be able to seriously clean it up
128 * once the DV code in mptscsih goes away and we can properly
129 * implement ->target_alloc.
130 */
131static int
132mptsas_slave_alloc(struct scsi_device *device)
133{
134 struct Scsi_Host *host = device->host;
135 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
136 struct sas_rphy *rphy;
137 struct mptsas_portinfo *p;
138 VirtDevice *vdev;
139 uint target = device->id;
140 int i;
141
142 if ((vdev = hd->Targets[target]) != NULL)
143 goto out;
144
145 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
146 if (!vdev) {
147 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
148 hd->ioc->name, sizeof(VirtDevice));
149 return -ENOMEM;
150 }
151
152 memset(vdev, 0, sizeof(VirtDevice));
153 vdev->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
154 vdev->ioc_id = hd->ioc->id;
155
156 rphy = dev_to_rphy(device->sdev_target->dev.parent);
157 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
158 for (i = 0; i < p->num_phys; i++) {
159 if (p->phy_info[i].attached.sas_address ==
160 rphy->identify.sas_address) {
161 vdev->target_id =
162 p->phy_info[i].attached.target;
163 vdev->bus_id = p->phy_info[i].attached.bus;
164 hd->Targets[device->id] = vdev;
165 goto out;
166 }
167 }
168 }
169
170 printk("No matching SAS device found!!\n");
171 kfree(vdev);
172 return -ENODEV;
173
174 out:
175 vdev->num_luns++;
176 device->hostdata = vdev;
177 return 0;
178}
179
180static struct scsi_host_template mptsas_driver_template = {
181 .proc_name = "mptsas",
182 .proc_info = mptscsih_proc_info,
183 .name = "MPT SPI Host",
184 .info = mptscsih_info,
185 .queuecommand = mptscsih_qcmd,
186 .slave_alloc = mptsas_slave_alloc,
187 .slave_configure = mptscsih_slave_configure,
188 .slave_destroy = mptscsih_slave_destroy,
189 .change_queue_depth = mptscsih_change_queue_depth,
190 .eh_abort_handler = mptscsih_abort,
191 .eh_device_reset_handler = mptscsih_dev_reset,
192 .eh_bus_reset_handler = mptscsih_bus_reset,
193 .eh_host_reset_handler = mptscsih_host_reset,
194 .bios_param = mptscsih_bios_param,
195 .can_queue = MPT_FC_CAN_QUEUE,
196 .this_id = -1,
197 .sg_tablesize = MPT_SCSI_SG_DEPTH,
198 .max_sectors = 8192,
199 .cmd_per_lun = 7,
200 .use_clustering = ENABLE_CLUSTERING,
201};
202
203static struct sas_function_template mptsas_transport_functions = {
204};
205
206static struct scsi_transport_template *mptsas_transport_template;
207
208#ifdef SASDEBUG
209static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
210{
211 printk("---- IO UNIT PAGE 0 ------------\n");
212 printk("Handle=0x%X\n",
213 le16_to_cpu(phy_data->AttachedDeviceHandle));
214 printk("Controller Handle=0x%X\n",
215 le16_to_cpu(phy_data->ControllerDevHandle));
216 printk("Port=0x%X\n", phy_data->Port);
217 printk("Port Flags=0x%X\n", phy_data->PortFlags);
218 printk("PHY Flags=0x%X\n", phy_data->PhyFlags);
219 printk("Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate);
220 printk("Controller PHY Device Info=0x%X\n",
221 le32_to_cpu(phy_data->ControllerPhyDeviceInfo));
222 printk("DiscoveryStatus=0x%X\n",
223 le32_to_cpu(phy_data->DiscoveryStatus));
224 printk("\n");
225}
226
227static void mptsas_print_phy_pg0(SasPhyPage0_t *pg0)
228{
229 __le64 sas_address;
230
231 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
232
233 printk("---- SAS PHY PAGE 0 ------------\n");
234 printk("Attached Device Handle=0x%X\n",
235 le16_to_cpu(pg0->AttachedDevHandle));
236 printk("SAS Address=0x%llX\n",
237 (unsigned long long)le64_to_cpu(sas_address));
238 printk("Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier);
239 printk("Attached Device Info=0x%X\n",
240 le32_to_cpu(pg0->AttachedDeviceInfo));
241 printk("Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate);
242 printk("Change Count=0x%X\n", pg0->ChangeCount);
243 printk("PHY Info=0x%X\n", le32_to_cpu(pg0->PhyInfo));
244 printk("\n");
245}
246
247static void mptsas_print_device_pg0(SasDevicePage0_t *pg0)
248{
249 __le64 sas_address;
250
251 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
252
253 printk("---- SAS DEVICE PAGE 0 ---------\n");
254 printk("Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle));
255 printk("Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle));
256 printk("Slot=0x%X\n", le16_to_cpu(pg0->Slot));
257 printk("SAS Address=0x%llX\n", le64_to_cpu(sas_address));
258 printk("Target ID=0x%X\n", pg0->TargetID);
259 printk("Bus=0x%X\n", pg0->Bus);
260 printk("Parent Phy Num=0x%X\n", pg0->PhyNum);
261 printk("Access Status=0x%X\n", le16_to_cpu(pg0->AccessStatus));
262 printk("Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo));
263 printk("Flags=0x%X\n", le16_to_cpu(pg0->Flags));
264 printk("Physical Port=0x%X\n", pg0->PhysicalPort);
265 printk("\n");
266}
267
268static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1)
269{
270 printk("---- SAS EXPANDER PAGE 1 ------------\n");
271
272 printk("Physical Port=0x%X\n", pg1->PhysicalPort);
273 printk("PHY Identifier=0x%X\n", pg1->PhyIdentifier);
274 printk("Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate);
275 printk("Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate);
276 printk("Hardware Link Rate=0x%X\n", pg1->HwLinkRate);
277 printk("Owner Device Handle=0x%X\n",
278 le16_to_cpu(pg1->OwnerDevHandle));
279 printk("Attached Device Handle=0x%X\n",
280 le16_to_cpu(pg1->AttachedDevHandle));
281}
282#else
283#define mptsas_print_phy_data(phy_data) do { } while (0)
284#define mptsas_print_phy_pg0(pg0) do { } while (0)
285#define mptsas_print_device_pg0(pg0) do { } while (0)
286#define mptsas_print_expander_pg1(pg1) do { } while (0)
287#endif
288
289static int
290mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
291{
292 ConfigExtendedPageHeader_t hdr;
293 CONFIGPARMS cfg;
294 SasIOUnitPage0_t *buffer;
295 dma_addr_t dma_handle;
296 int error, i;
297
298 hdr.PageVersion = MPI_SASIOUNITPAGE0_PAGEVERSION;
299 hdr.ExtPageLength = 0;
300 hdr.PageNumber = 0;
301 hdr.Reserved1 = 0;
302 hdr.Reserved2 = 0;
303 hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
304 hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
305
306 cfg.cfghdr.ehdr = &hdr;
307 cfg.physAddr = -1;
308 cfg.pageAddr = 0;
309 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
310 cfg.dir = 0; /* read */
311 cfg.timeout = 10;
312
313 error = mpt_config(ioc, &cfg);
314 if (error)
315 goto out;
316 if (!hdr.ExtPageLength) {
317 error = -ENXIO;
318 goto out;
319 }
320
321 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
322 &dma_handle);
323 if (!buffer) {
324 error = -ENOMEM;
325 goto out;
326 }
327
328 cfg.physAddr = dma_handle;
329 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
330
331 error = mpt_config(ioc, &cfg);
332 if (error)
333 goto out_free_consistent;
334
335 port_info->num_phys = buffer->NumPhys;
336 port_info->phy_info = kcalloc(port_info->num_phys,
337 sizeof(struct mptsas_phyinfo),GFP_KERNEL);
338 if (!port_info->phy_info) {
339 error = -ENOMEM;
340 goto out_free_consistent;
341 }
342
343 for (i = 0; i < port_info->num_phys; i++) {
344 mptsas_print_phy_data(&buffer->PhyData[i]);
345 port_info->phy_info[i].phy_id = i;
346 port_info->phy_info[i].port_id =
347 buffer->PhyData[i].Port;
348 port_info->phy_info[i].negotiated_link_rate =
349 buffer->PhyData[i].NegotiatedLinkRate;
350 }
351
352 out_free_consistent:
353 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
354 buffer, dma_handle);
355 out:
356 return error;
357}
358
359static int
360mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
361 u32 form, u32 form_specific)
362{
363 ConfigExtendedPageHeader_t hdr;
364 CONFIGPARMS cfg;
365 SasPhyPage0_t *buffer;
366 dma_addr_t dma_handle;
367 int error;
368
369 hdr.PageVersion = MPI_SASPHY0_PAGEVERSION;
370 hdr.ExtPageLength = 0;
371 hdr.PageNumber = 0;
372 hdr.Reserved1 = 0;
373 hdr.Reserved2 = 0;
374 hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
375 hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_PHY;
376
377 cfg.cfghdr.ehdr = &hdr;
378 cfg.dir = 0; /* read */
379 cfg.timeout = 10;
380
381 /* Get Phy Pg 0 for each Phy. */
382 cfg.physAddr = -1;
383 cfg.pageAddr = form + form_specific;
384 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
385
386 error = mpt_config(ioc, &cfg);
387 if (error)
388 goto out;
389
390 if (!hdr.ExtPageLength) {
391 error = -ENXIO;
392 goto out;
393 }
394
395 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
396 &dma_handle);
397 if (!buffer) {
398 error = -ENOMEM;
399 goto out;
400 }
401
402 cfg.physAddr = dma_handle;
403 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
404
405 error = mpt_config(ioc, &cfg);
406 if (error)
407 goto out_free_consistent;
408
409 mptsas_print_phy_pg0(buffer);
410
411 phy_info->hw_link_rate = buffer->HwLinkRate;
412 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate;
413 phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle);
414 phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle);
415
416 out_free_consistent:
417 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
418 buffer, dma_handle);
419 out:
420 return error;
421}
422
423static int
424mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
425 u32 form, u32 form_specific)
426{
427 ConfigExtendedPageHeader_t hdr;
428 CONFIGPARMS cfg;
429 SasDevicePage0_t *buffer;
430 dma_addr_t dma_handle;
431 __le64 sas_address;
432 int error;
433
434 hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION;
435 hdr.ExtPageLength = 0;
436 hdr.PageNumber = 0;
437 hdr.Reserved1 = 0;
438 hdr.Reserved2 = 0;
439 hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
440 hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_DEVICE;
441
442 cfg.cfghdr.ehdr = &hdr;
443 cfg.pageAddr = form + form_specific;
444 cfg.physAddr = -1;
445 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
446 cfg.dir = 0; /* read */
447 cfg.timeout = 10;
448
449 error = mpt_config(ioc, &cfg);
450 if (error)
451 goto out;
452 if (!hdr.ExtPageLength) {
453 error = -ENXIO;
454 goto out;
455 }
456
457 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
458 &dma_handle);
459 if (!buffer) {
460 error = -ENOMEM;
461 goto out;
462 }
463
464 cfg.physAddr = dma_handle;
465 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
466
467 error = mpt_config(ioc, &cfg);
468 if (error)
469 goto out_free_consistent;
470
471 mptsas_print_device_pg0(buffer);
472
473 device_info->handle = le16_to_cpu(buffer->DevHandle);
474 device_info->phy_id = buffer->PhyNum;
475 device_info->port_id = buffer->PhysicalPort;
476 device_info->target = buffer->TargetID;
477 device_info->bus = buffer->Bus;
478 memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64));
479 device_info->sas_address = le64_to_cpu(sas_address);
480 device_info->device_info =
481 le32_to_cpu(buffer->DeviceInfo);
482
483 out_free_consistent:
484 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
485 buffer, dma_handle);
486 out:
487 return error;
488}
489
490static int
491mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
492 u32 form, u32 form_specific)
493{
494 ConfigExtendedPageHeader_t hdr;
495 CONFIGPARMS cfg;
496 SasExpanderPage0_t *buffer;
497 dma_addr_t dma_handle;
498 int error;
499
500 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION;
501 hdr.ExtPageLength = 0;
502 hdr.PageNumber = 0;
503 hdr.Reserved1 = 0;
504 hdr.Reserved2 = 0;
505 hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
506 hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_EXPANDER;
507
508 cfg.cfghdr.ehdr = &hdr;
509 cfg.physAddr = -1;
510 cfg.pageAddr = form + form_specific;
511 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
512 cfg.dir = 0; /* read */
513 cfg.timeout = 10;
514
515 error = mpt_config(ioc, &cfg);
516 if (error)
517 goto out;
518
519 if (!hdr.ExtPageLength) {
520 error = -ENXIO;
521 goto out;
522 }
523
524 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
525 &dma_handle);
526 if (!buffer) {
527 error = -ENOMEM;
528 goto out;
529 }
530
531 cfg.physAddr = dma_handle;
532 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
533
534 error = mpt_config(ioc, &cfg);
535 if (error)
536 goto out_free_consistent;
537
538 /* save config data */
539 port_info->num_phys = buffer->NumPhys;
540 port_info->handle = le16_to_cpu(buffer->DevHandle);
541 port_info->phy_info = kcalloc(port_info->num_phys,
542 sizeof(struct mptsas_phyinfo),GFP_KERNEL);
543 if (!port_info->phy_info) {
544 error = -ENOMEM;
545 goto out_free_consistent;
546 }
547
548 out_free_consistent:
549 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
550 buffer, dma_handle);
551 out:
552 return error;
553}
554
555static int
556mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
557 u32 form, u32 form_specific)
558{
559 ConfigExtendedPageHeader_t hdr;
560 CONFIGPARMS cfg;
561 SasExpanderPage1_t *buffer;
562 dma_addr_t dma_handle;
563 int error;
564
565 hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION;
566 hdr.ExtPageLength = 0;
567 hdr.PageNumber = 1;
568 hdr.Reserved1 = 0;
569 hdr.Reserved2 = 0;
570 hdr.PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
571 hdr.ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_EXPANDER;
572
573 cfg.cfghdr.ehdr = &hdr;
574 cfg.physAddr = -1;
575 cfg.pageAddr = form + form_specific;
576 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
577 cfg.dir = 0; /* read */
578 cfg.timeout = 10;
579
580 error = mpt_config(ioc, &cfg);
581 if (error)
582 goto out;
583
584 if (!hdr.ExtPageLength) {
585 error = -ENXIO;
586 goto out;
587 }
588
589 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
590 &dma_handle);
591 if (!buffer) {
592 error = -ENOMEM;
593 goto out;
594 }
595
596 cfg.physAddr = dma_handle;
597 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
598
599 error = mpt_config(ioc, &cfg);
600 if (error)
601 goto out_free_consistent;
602
603
604 mptsas_print_expander_pg1(buffer);
605
606 /* save config data */
607 phy_info->phy_id = buffer->PhyIdentifier;
608 phy_info->port_id = buffer->PhysicalPort;
609 phy_info->negotiated_link_rate = buffer->NegotiatedLinkRate;
610 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate;
611 phy_info->hw_link_rate = buffer->HwLinkRate;
612 phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle);
613 phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle);
614
615
616 out_free_consistent:
617 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
618 buffer, dma_handle);
619 out:
620 return error;
621}
622
623static void
624mptsas_parse_device_info(struct sas_identify *identify,
625 struct mptsas_devinfo *device_info)
626{
627 u16 protocols;
628
629 identify->sas_address = device_info->sas_address;
630 identify->phy_identifier = device_info->phy_id;
631
632 /*
633 * Fill in Phy Initiator Port Protocol.
634 * Bits 6:3, more than one bit can be set, fall through cases.
635 */
636 protocols = device_info->device_info & 0x78;
637 identify->initiator_port_protocols = 0;
638 if (protocols & MPI_SAS_DEVICE_INFO_SSP_INITIATOR)
639 identify->initiator_port_protocols |= SAS_PROTOCOL_SSP;
640 if (protocols & MPI_SAS_DEVICE_INFO_STP_INITIATOR)
641 identify->initiator_port_protocols |= SAS_PROTOCOL_STP;
642 if (protocols & MPI_SAS_DEVICE_INFO_SMP_INITIATOR)
643 identify->initiator_port_protocols |= SAS_PROTOCOL_SMP;
644 if (protocols & MPI_SAS_DEVICE_INFO_SATA_HOST)
645 identify->initiator_port_protocols |= SAS_PROTOCOL_SATA;
646
647 /*
648 * Fill in Phy Target Port Protocol.
649 * Bits 10:7, more than one bit can be set, fall through cases.
650 */
651 protocols = device_info->device_info & 0x780;
652 identify->target_port_protocols = 0;
653 if (protocols & MPI_SAS_DEVICE_INFO_SSP_TARGET)
654 identify->target_port_protocols |= SAS_PROTOCOL_SSP;
655 if (protocols & MPI_SAS_DEVICE_INFO_STP_TARGET)
656 identify->target_port_protocols |= SAS_PROTOCOL_STP;
657 if (protocols & MPI_SAS_DEVICE_INFO_SMP_TARGET)
658 identify->target_port_protocols |= SAS_PROTOCOL_SMP;
659 if (protocols & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
660 identify->target_port_protocols |= SAS_PROTOCOL_SATA;
661
662 /*
663 * Fill in Attached device type.
664 */
665 switch (device_info->device_info &
666 MPI_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) {
667 case MPI_SAS_DEVICE_INFO_NO_DEVICE:
668 identify->device_type = SAS_PHY_UNUSED;
669 break;
670 case MPI_SAS_DEVICE_INFO_END_DEVICE:
671 identify->device_type = SAS_END_DEVICE;
672 break;
673 case MPI_SAS_DEVICE_INFO_EDGE_EXPANDER:
674 identify->device_type = SAS_EDGE_EXPANDER_DEVICE;
675 break;
676 case MPI_SAS_DEVICE_INFO_FANOUT_EXPANDER:
677 identify->device_type = SAS_FANOUT_EXPANDER_DEVICE;
678 break;
679 }
680}
681
682static int mptsas_probe_one_phy(struct device *dev,
683 struct mptsas_phyinfo *phy_info, int index)
684{
685 struct sas_phy *port;
686 int error;
687
688 port = sas_phy_alloc(dev, index);
689 if (!port)
690 return -ENOMEM;
691
692 port->port_identifier = phy_info->port_id;
693 mptsas_parse_device_info(&port->identify, &phy_info->identify);
694
695 /*
696 * Set Negotiated link rate.
697 */
698 switch (phy_info->negotiated_link_rate) {
699 case MPI_SAS_IOUNIT0_RATE_PHY_DISABLED:
700 port->negotiated_linkrate = SAS_PHY_DISABLED;
701 break;
702 case MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION:
703 port->negotiated_linkrate = SAS_LINK_RATE_FAILED;
704 break;
705 case MPI_SAS_IOUNIT0_RATE_1_5:
706 port->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS;
707 break;
708 case MPI_SAS_IOUNIT0_RATE_3_0:
709 port->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS;
710 break;
711 case MPI_SAS_IOUNIT0_RATE_SATA_OOB_COMPLETE:
712 case MPI_SAS_IOUNIT0_RATE_UNKNOWN:
713 default:
714 port->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN;
715 break;
716 }
717
718 /*
719 * Set Max hardware link rate.
720 */
721 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
722 case MPI_SAS_PHY0_HWRATE_MAX_RATE_1_5:
723 port->maximum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
724 break;
725 case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
726 port->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
727 break;
728 default:
729 break;
730 }
731
732 /*
733 * Set Max programmed link rate.
734 */
735 switch (phy_info->programmed_link_rate &
736 MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
737 case MPI_SAS_PHY0_PRATE_MAX_RATE_1_5:
738 port->maximum_linkrate = SAS_LINK_RATE_1_5_GBPS;
739 break;
740 case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
741 port->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS;
742 break;
743 default:
744 break;
745 }
746
747 /*
748 * Set Min hardware link rate.
749 */
750 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) {
751 case MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5:
752 port->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
753 break;
754 case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
755 port->minimum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
756 break;
757 default:
758 break;
759 }
760
761 /*
762 * Set Min programmed link rate.
763 */
764 switch (phy_info->programmed_link_rate &
765 MPI_SAS_PHY0_PRATE_MIN_RATE_MASK) {
766 case MPI_SAS_PHY0_PRATE_MIN_RATE_1_5:
767 port->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS;
768 break;
769 case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
770 port->minimum_linkrate = SAS_LINK_RATE_3_0_GBPS;
771 break;
772 default:
773 break;
774 }
775
776 error = sas_phy_add(port);
777 if (error) {
778 sas_phy_free(port);
779 return error;
780 }
781
782 if (phy_info->attached.handle) {
783 struct sas_rphy *rphy;
784
785 rphy = sas_rphy_alloc(port);
786 if (!rphy)
787 return 0; /* non-fatal: an rphy can be added later */
788
789 mptsas_parse_device_info(&rphy->identify, &phy_info->attached);
790 error = sas_rphy_add(rphy);
791 if (error) {
792 sas_rphy_free(rphy);
793 return error;
794 }
795
796 phy_info->rphy = rphy;
797 }
798
799 return 0;
800}
801
802static int
803mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index)
804{
805 struct mptsas_portinfo *port_info;
806 u32 handle = 0xFFFF;
807 int error = -ENOMEM, i;
808
809 port_info = kmalloc(sizeof(*port_info), GFP_KERNEL);
810 if (!port_info)
811 goto out;
812 memset(port_info, 0, sizeof(*port_info));
813
814 error = mptsas_sas_io_unit_pg0(ioc, port_info);
815 if (error)
816 goto out_free_port_info;
817
818 list_add_tail(&port_info->list, &ioc->sas_topology);
819
820 for (i = 0; i < port_info->num_phys; i++) {
821 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
822 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER <<
823 MPI_SAS_PHY_PGAD_FORM_SHIFT), i);
824
825 mptsas_sas_device_pg0(ioc, &port_info->phy_info[i].identify,
826 (MPI_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE <<
827 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), handle);
828 port_info->phy_info[i].identify.phy_id =
829 port_info->phy_info[i].phy_id;
830 handle = port_info->phy_info[i].identify.handle;
831
832 if (port_info->phy_info[i].attached.handle) {
833 mptsas_sas_device_pg0(ioc,
834 &port_info->phy_info[i].attached,
835 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
836 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
837 port_info->phy_info[i].attached.handle);
838 }
839
840 mptsas_probe_one_phy(&ioc->sh->shost_gendev,
841 &port_info->phy_info[i], *index);
842 (*index)++;
843 }
844
845 return 0;
846
847 out_free_port_info:
848 kfree(port_info);
849 out:
850 return error;
851}
852
853static int
854mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index)
855{
856 struct mptsas_portinfo *port_info, *p;
857 int error = -ENOMEM, i, j;
858
859 port_info = kmalloc(sizeof(*port_info), GFP_KERNEL);
860 if (!port_info)
861 goto out;
862 memset(port_info, 0, sizeof(*port_info));
863
864 error = mptsas_sas_expander_pg0(ioc, port_info,
865 (MPI_SAS_EXPAND_PGAD_FORM_GET_NEXT_HANDLE <<
866 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), *handle);
867 if (error)
868 goto out_free_port_info;
869
870 *handle = port_info->handle;
871
872 list_add_tail(&port_info->list, &ioc->sas_topology);
873 for (i = 0; i < port_info->num_phys; i++) {
874 struct device *parent;
875
876 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i],
877 (MPI_SAS_EXPAND_PGAD_FORM_HANDLE_PHY_NUM <<
878 MPI_SAS_EXPAND_PGAD_FORM_SHIFT), (i << 16) + *handle);
879
880 if (port_info->phy_info[i].identify.handle) {
881 mptsas_sas_device_pg0(ioc,
882 &port_info->phy_info[i].identify,
883 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
884 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
885 port_info->phy_info[i].identify.handle);
886 port_info->phy_info[i].identify.phy_id =
887 port_info->phy_info[i].phy_id;
888 }
889
890 if (port_info->phy_info[i].attached.handle) {
891 mptsas_sas_device_pg0(ioc,
892 &port_info->phy_info[i].attached,
893 (MPI_SAS_DEVICE_PGAD_FORM_HANDLE <<
894 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
895 port_info->phy_info[i].attached.handle);
896 }
897
898 /*
899 * If we find a parent port handle this expander is
900 * attached to another expander, else it hangs of the
901 * HBA phys.
902 */
903 parent = &ioc->sh->shost_gendev;
904 list_for_each_entry(p, &ioc->sas_topology, list) {
905 for (j = 0; j < p->num_phys; j++) {
906 if (port_info->phy_info[i].identify.handle ==
907 p->phy_info[j].attached.handle)
908 parent = &p->phy_info[j].rphy->dev;
909 }
910 }
911
912 mptsas_probe_one_phy(parent, &port_info->phy_info[i], *index);
913 (*index)++;
914 }
915
916 return 0;
917
918 out_free_port_info:
919 kfree(port_info);
920 out:
921 return error;
922}
923
924static void
925mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
926{
927 u32 handle = 0xFFFF;
928 int index = 0;
929
930 mptsas_probe_hba_phys(ioc, &index);
931 while (!mptsas_probe_expander_phys(ioc, &handle, &index))
932 ;
933}
934
935static int
936mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
937{
938 struct Scsi_Host *sh;
939 MPT_SCSI_HOST *hd;
940 MPT_ADAPTER *ioc;
941 unsigned long flags;
942 int sz, ii;
943 int numSGE = 0;
944 int scale;
945 int ioc_cap;
946 u8 *mem;
947 int error=0;
948 int r;
949
950 r = mpt_attach(pdev,id);
951 if (r)
952 return r;
953
954 ioc = pci_get_drvdata(pdev);
955 ioc->DoneCtx = mptsasDoneCtx;
956 ioc->TaskCtx = mptsasTaskCtx;
957 ioc->InternalCtx = mptsasInternalCtx;
958
959 /* Added sanity check on readiness of the MPT adapter.
960 */
961 if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) {
962 printk(MYIOC_s_WARN_FMT
963 "Skipping because it's not operational!\n",
964 ioc->name);
965 return -ENODEV;
966 }
967
968 if (!ioc->active) {
969 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
970 ioc->name);
971 return -ENODEV;
972 }
973
974 /* Sanity check - ensure at least 1 port is INITIATOR capable
975 */
976 ioc_cap = 0;
977 for (ii = 0; ii < ioc->facts.NumberOfPorts; ii++) {
978 if (ioc->pfacts[ii].ProtocolFlags &
979 MPI_PORTFACTS_PROTOCOL_INITIATOR)
980 ioc_cap++;
981 }
982
983 if (!ioc_cap) {
984 printk(MYIOC_s_WARN_FMT
985 "Skipping ioc=%p because SCSI Initiator mode "
986 "is NOT enabled!\n", ioc->name, ioc);
987 return 0;
988 }
989
990 sh = scsi_host_alloc(&mptsas_driver_template, sizeof(MPT_SCSI_HOST));
991 if (!sh) {
992 printk(MYIOC_s_WARN_FMT
993 "Unable to register controller with SCSI subsystem\n",
994 ioc->name);
995 return -1;
996 }
997
998 spin_lock_irqsave(&ioc->FreeQlock, flags);
999
1000 /* Attach the SCSI Host to the IOC structure
1001 */
1002 ioc->sh = sh;
1003
1004 sh->io_port = 0;
1005 sh->n_io_port = 0;
1006 sh->irq = 0;
1007
1008 /* set 16 byte cdb's */
1009 sh->max_cmd_len = 16;
1010
1011 sh->max_id = ioc->pfacts->MaxDevices + 1;
1012
1013 sh->transportt = mptsas_transport_template;
1014
1015 sh->max_lun = MPT_LAST_LUN + 1;
1016 sh->max_channel = 0;
1017 sh->this_id = ioc->pfacts[0].PortSCSIID;
1018
1019 /* Required entry.
1020 */
1021 sh->unique_id = ioc->id;
1022
1023 INIT_LIST_HEAD(&ioc->sas_topology);
1024
1025 /* Verify that we won't exceed the maximum
1026 * number of chain buffers
1027 * We can optimize: ZZ = req_sz/sizeof(SGE)
1028 * For 32bit SGE's:
1029 * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ
1030 * + (req_sz - 64)/sizeof(SGE)
1031 * A slightly different algorithm is required for
1032 * 64bit SGEs.
1033 */
1034 scale = ioc->req_sz/(sizeof(dma_addr_t) + sizeof(u32));
1035 if (sizeof(dma_addr_t) == sizeof(u64)) {
1036 numSGE = (scale - 1) *
1037 (ioc->facts.MaxChainDepth-1) + scale +
1038 (ioc->req_sz - 60) / (sizeof(dma_addr_t) +
1039 sizeof(u32));
1040 } else {
1041 numSGE = 1 + (scale - 1) *
1042 (ioc->facts.MaxChainDepth-1) + scale +
1043 (ioc->req_sz - 64) / (sizeof(dma_addr_t) +
1044 sizeof(u32));
1045 }
1046
1047 if (numSGE < sh->sg_tablesize) {
1048 /* Reset this value */
1049 dprintk((MYIOC_s_INFO_FMT
1050 "Resetting sg_tablesize to %d from %d\n",
1051 ioc->name, numSGE, sh->sg_tablesize));
1052 sh->sg_tablesize = numSGE;
1053 }
1054
1055 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
1056
1057 hd = (MPT_SCSI_HOST *) sh->hostdata;
1058 hd->ioc = ioc;
1059
1060 /* SCSI needs scsi_cmnd lookup table!
1061 * (with size equal to req_depth*PtrSz!)
1062 */
1063 sz = ioc->req_depth * sizeof(void *);
1064 mem = kmalloc(sz, GFP_ATOMIC);
1065 if (mem == NULL) {
1066 error = -ENOMEM;
1067 goto mptsas_probe_failed;
1068 }
1069
1070 memset(mem, 0, sz);
1071 hd->ScsiLookup = (struct scsi_cmnd **) mem;
1072
1073 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
1074 ioc->name, hd->ScsiLookup, sz));
1075
1076 /* Allocate memory for the device structures.
1077 * A non-Null pointer at an offset
1078 * indicates a device exists.
1079 * max_id = 1 + maximum id (hosts.h)
1080 */
1081 sz = sh->max_id * sizeof(void *);
1082 mem = kmalloc(sz, GFP_ATOMIC);
1083 if (mem == NULL) {
1084 error = -ENOMEM;
1085 goto mptsas_probe_failed;
1086 }
1087
1088 memset(mem, 0, sz);
1089 hd->Targets = (VirtDevice **) mem;
1090
1091 dprintk((KERN_INFO
1092 " Targets @ %p, sz=%d\n", hd->Targets, sz));
1093
1094 /* Clear the TM flags
1095 */
1096 hd->tmPending = 0;
1097 hd->tmState = TM_STATE_NONE;
1098 hd->resetPending = 0;
1099 hd->abortSCpnt = NULL;
1100
1101 /* Clear the pointer used to store
1102 * single-threaded commands, i.e., those
1103 * issued during a bus scan, dv and
1104 * configuration pages.
1105 */
1106 hd->cmdPtr = NULL;
1107
1108 /* Initialize this SCSI Hosts' timers
1109 * To use, set the timer expires field
1110 * and add_timer
1111 */
1112 init_timer(&hd->timer);
1113 hd->timer.data = (unsigned long) hd;
1114 hd->timer.function = mptscsih_timer_expired;
1115
1116 hd->mpt_pq_filter = mpt_pq_filter;
1117 ioc->sas_data.ptClear = mpt_pt_clear;
1118
1119 if (ioc->sas_data.ptClear==1) {
1120 mptbase_sas_persist_operation(
1121 ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
1122 }
1123
1124 ddvprintk((MYIOC_s_INFO_FMT
1125 "mpt_pq_filter %x mpt_pq_filter %x\n",
1126 ioc->name,
1127 mpt_pq_filter,
1128 mpt_pq_filter));
1129
1130 init_waitqueue_head(&hd->scandv_waitq);
1131 hd->scandv_wait_done = 0;
1132 hd->last_queue_full = 0;
1133
1134 error = scsi_add_host(sh, &ioc->pcidev->dev);
1135 if (error) {
1136 dprintk((KERN_ERR MYNAM
1137 "scsi_add_host failed\n"));
1138 goto mptsas_probe_failed;
1139 }
1140
1141 mptsas_scan_sas_topology(ioc);
1142
1143 return 0;
1144
1145mptsas_probe_failed:
1146
1147 mptscsih_remove(pdev);
1148 return error;
1149}
1150
1151static void __devexit mptsas_remove(struct pci_dev *pdev)
1152{
1153 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1154 struct mptsas_portinfo *p, *n;
1155
1156 sas_remove_host(ioc->sh);
1157
1158 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
1159 list_del(&p->list);
1160 kfree(p);
1161 }
1162
1163 mptscsih_remove(pdev);
1164}
1165
1166static struct pci_device_id mptsas_pci_table[] = {
1167 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064,
1168 PCI_ANY_ID, PCI_ANY_ID },
1169 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066,
1170 PCI_ANY_ID, PCI_ANY_ID },
1171 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068,
1172 PCI_ANY_ID, PCI_ANY_ID },
1173 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064E,
1174 PCI_ANY_ID, PCI_ANY_ID },
1175 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1066E,
1176 PCI_ANY_ID, PCI_ANY_ID },
1177 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1068E,
1178 PCI_ANY_ID, PCI_ANY_ID },
1179 {0} /* Terminating entry */
1180};
1181MODULE_DEVICE_TABLE(pci, mptsas_pci_table);
1182
1183
1184static struct pci_driver mptsas_driver = {
1185 .name = "mptsas",
1186 .id_table = mptsas_pci_table,
1187 .probe = mptsas_probe,
1188 .remove = __devexit_p(mptsas_remove),
1189 .shutdown = mptscsih_shutdown,
1190#ifdef CONFIG_PM
1191 .suspend = mptscsih_suspend,
1192 .resume = mptscsih_resume,
1193#endif
1194};
1195
1196static int __init
1197mptsas_init(void)
1198{
1199 show_mptmod_ver(my_NAME, my_VERSION);
1200
1201 mptsas_transport_template =
1202 sas_attach_transport(&mptsas_transport_functions);
1203 if (!mptsas_transport_template)
1204 return -ENODEV;
1205
1206 mptsasDoneCtx = mpt_register(mptscsih_io_done, MPTSAS_DRIVER);
1207 mptsasTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSAS_DRIVER);
1208 mptsasInternalCtx =
1209 mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER);
1210
1211 if (mpt_event_register(mptsasDoneCtx, mptscsih_event_process) == 0) {
1212 devtprintk((KERN_INFO MYNAM
1213 ": Registered for IOC event notifications\n"));
1214 }
1215
1216 if (mpt_reset_register(mptsasDoneCtx, mptscsih_ioc_reset) == 0) {
1217 dprintk((KERN_INFO MYNAM
1218 ": Registered for IOC reset notifications\n"));
1219 }
1220
1221 return pci_register_driver(&mptsas_driver);
1222}
1223
1224static void __exit
1225mptsas_exit(void)
1226{
1227 pci_unregister_driver(&mptsas_driver);
1228 sas_release_transport(mptsas_transport_template);
1229
1230 mpt_reset_deregister(mptsasDoneCtx);
1231 mpt_event_deregister(mptsasDoneCtx);
1232
1233 mpt_deregister(mptsasInternalCtx);
1234 mpt_deregister(mptsasTaskCtx);
1235 mpt_deregister(mptsasDoneCtx);
1236}
1237
1238module_init(mptsas_init);
1239module_exit(mptsas_exit);
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 4a003dc5fde8..5cb07eb224d7 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -62,6 +62,7 @@
62#include <scsi/scsi_device.h> 62#include <scsi/scsi_device.h>
63#include <scsi/scsi_host.h> 63#include <scsi/scsi_host.h>
64#include <scsi/scsi_tcq.h> 64#include <scsi/scsi_tcq.h>
65#include <scsi/scsi_dbg.h>
65 66
66#include "mptbase.h" 67#include "mptbase.h"
67#include "mptscsih.h" 68#include "mptscsih.h"
@@ -93,8 +94,9 @@ typedef struct _BIG_SENSE_BUF {
93 94
94#define MPT_ICFLAG_BUF_CAP 0x01 /* ReadBuffer Read Capacity format */ 95#define MPT_ICFLAG_BUF_CAP 0x01 /* ReadBuffer Read Capacity format */
95#define MPT_ICFLAG_ECHO 0x02 /* ReadBuffer Echo buffer format */ 96#define MPT_ICFLAG_ECHO 0x02 /* ReadBuffer Echo buffer format */
96#define MPT_ICFLAG_PHYS_DISK 0x04 /* Any SCSI IO but do Phys Disk Format */ 97#define MPT_ICFLAG_EBOS 0x04 /* ReadBuffer Echo buffer has EBOS */
97#define MPT_ICFLAG_TAGGED_CMD 0x08 /* Do tagged IO */ 98#define MPT_ICFLAG_PHYS_DISK 0x08 /* Any SCSI IO but do Phys Disk Format */
99#define MPT_ICFLAG_TAGGED_CMD 0x10 /* Do tagged IO */
98#define MPT_ICFLAG_DID_RESET 0x20 /* Bus Reset occurred with this command */ 100#define MPT_ICFLAG_DID_RESET 0x20 /* Bus Reset occurred with this command */
99#define MPT_ICFLAG_RESERVED 0x40 /* Reserved has been issued */ 101#define MPT_ICFLAG_RESERVED 0x40 /* Reserved has been issued */
100 102
@@ -159,6 +161,8 @@ int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR
159static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); 161static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
160static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); 162static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum);
161 163
164static struct work_struct mptscsih_persistTask;
165
162#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 166#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
163static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); 167static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io);
164static void mptscsih_domainValidation(void *hd); 168static void mptscsih_domainValidation(void *hd);
@@ -167,6 +171,7 @@ static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id);
167static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); 171static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target);
168static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); 172static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
169static void mptscsih_fillbuf(char *buffer, int size, int index, int width); 173static void mptscsih_fillbuf(char *buffer, int size, int index, int width);
174static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id);
170#endif 175#endif
171 176
172void mptscsih_remove(struct pci_dev *); 177void mptscsih_remove(struct pci_dev *);
@@ -606,11 +611,24 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
606 xfer_cnt = le32_to_cpu(pScsiReply->TransferCount); 611 xfer_cnt = le32_to_cpu(pScsiReply->TransferCount);
607 sc->resid = sc->request_bufflen - xfer_cnt; 612 sc->resid = sc->request_bufflen - xfer_cnt;
608 613
614 /*
615 * if we get a data underrun indication, yet no data was
616 * transferred and the SCSI status indicates that the
617 * command was never started, change the data underrun
618 * to success
619 */
620 if (status == MPI_IOCSTATUS_SCSI_DATA_UNDERRUN && xfer_cnt == 0 &&
621 (scsi_status == MPI_SCSI_STATUS_BUSY ||
622 scsi_status == MPI_SCSI_STATUS_RESERVATION_CONFLICT ||
623 scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL)) {
624 status = MPI_IOCSTATUS_SUCCESS;
625 }
626
609 dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n" 627 dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n"
610 "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n" 628 "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n"
611 "resid=%d bufflen=%d xfer_cnt=%d\n", 629 "resid=%d bufflen=%d xfer_cnt=%d\n",
612 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], 630 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1],
613 status, scsi_state, scsi_status, sc->resid, 631 status, scsi_state, scsi_status, sc->resid,
614 sc->request_bufflen, xfer_cnt)); 632 sc->request_bufflen, xfer_cnt));
615 633
616 if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) 634 if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID)
@@ -619,8 +637,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
619 /* 637 /*
620 * Look for + dump FCP ResponseInfo[]! 638 * Look for + dump FCP ResponseInfo[]!
621 */ 639 */
622 if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID) { 640 if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
623 printk(KERN_NOTICE " FCP_ResponseInfo=%08xh\n", 641 pScsiReply->ResponseInfo) {
642 printk(KERN_NOTICE "ha=%d id=%d lun=%d: "
643 "FCP_ResponseInfo=%08xh\n",
644 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1],
624 le32_to_cpu(pScsiReply->ResponseInfo)); 645 le32_to_cpu(pScsiReply->ResponseInfo));
625 } 646 }
626 647
@@ -661,23 +682,13 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
661 break; 682 break;
662 683
663 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ 684 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */
664 if ( xfer_cnt >= sc->underflow ) { 685 sc->resid = sc->request_bufflen - xfer_cnt;
665 /* Sufficient data transfer occurred */ 686 if((xfer_cnt==0)||(sc->underflow > xfer_cnt))
687 sc->result=DID_SOFT_ERROR << 16;
688 else /* Sufficient data transfer occurred */
666 sc->result = (DID_OK << 16) | scsi_status; 689 sc->result = (DID_OK << 16) | scsi_status;
667 } else if ( xfer_cnt == 0 ) { 690 dreplyprintk((KERN_NOTICE
668 /* A CRC Error causes this condition; retry */ 691 "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->device->id));
669 sc->result = (DRIVER_SENSE << 24) | (DID_OK << 16) |
670 (CHECK_CONDITION << 1);
671 sc->sense_buffer[0] = 0x70;
672 sc->sense_buffer[2] = NO_SENSE;
673 sc->sense_buffer[12] = 0;
674 sc->sense_buffer[13] = 0;
675 } else {
676 sc->result = DID_SOFT_ERROR << 16;
677 }
678 dreplyprintk((KERN_NOTICE
679 "RESIDUAL_MISMATCH: result=%x on id=%d\n",
680 sc->result, sc->device->id));
681 break; 692 break;
682 693
683 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */ 694 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN: /* 0x0045 */
@@ -692,7 +703,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
692 ; 703 ;
693 } else { 704 } else {
694 if (xfer_cnt < sc->underflow) { 705 if (xfer_cnt < sc->underflow) {
695 sc->result = DID_SOFT_ERROR << 16; 706 if (scsi_status == SAM_STAT_BUSY)
707 sc->result = SAM_STAT_BUSY;
708 else
709 sc->result = DID_SOFT_ERROR << 16;
696 } 710 }
697 if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) { 711 if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) {
698 /* What to do? 712 /* What to do?
@@ -717,8 +731,10 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
717 731
718 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ 732 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */
719 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ 733 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */
720 scsi_status = pScsiReply->SCSIStatus; 734 if (scsi_status == MPI_SCSI_STATUS_BUSY)
721 sc->result = (DID_OK << 16) | scsi_status; 735 sc->result = (DID_BUS_BUSY << 16) | scsi_status;
736 else
737 sc->result = (DID_OK << 16) | scsi_status;
722 if (scsi_state == 0) { 738 if (scsi_state == 0) {
723 ; 739 ;
724 } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) { 740 } else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) {
@@ -890,12 +906,13 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
890 SCSIIORequest_t *mf = NULL; 906 SCSIIORequest_t *mf = NULL;
891 int ii; 907 int ii;
892 int max = hd->ioc->req_depth; 908 int max = hd->ioc->req_depth;
909 struct scsi_cmnd *sc;
893 910
894 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", 911 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n",
895 target, lun, max)); 912 target, lun, max));
896 913
897 for (ii=0; ii < max; ii++) { 914 for (ii=0; ii < max; ii++) {
898 if (hd->ScsiLookup[ii] != NULL) { 915 if ((sc = hd->ScsiLookup[ii]) != NULL) {
899 916
900 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii); 917 mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii);
901 918
@@ -910,9 +927,22 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
910 hd->ScsiLookup[ii] = NULL; 927 hd->ScsiLookup[ii] = NULL;
911 mptscsih_freeChainBuffers(hd->ioc, ii); 928 mptscsih_freeChainBuffers(hd->ioc, ii);
912 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); 929 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf);
930 if (sc->use_sg) {
931 pci_unmap_sg(hd->ioc->pcidev,
932 (struct scatterlist *) sc->request_buffer,
933 sc->use_sg,
934 sc->sc_data_direction);
935 } else if (sc->request_bufflen) {
936 pci_unmap_single(hd->ioc->pcidev,
937 sc->SCp.dma_handle,
938 sc->request_bufflen,
939 sc->sc_data_direction);
940 }
941 sc->host_scribble = NULL;
942 sc->result = DID_NO_CONNECT << 16;
943 sc->scsi_done(sc);
913 } 944 }
914 } 945 }
915
916 return; 946 return;
917} 947}
918 948
@@ -967,8 +997,10 @@ mptscsih_remove(struct pci_dev *pdev)
967 unsigned long flags; 997 unsigned long flags;
968 int sz1; 998 int sz1;
969 999
970 if(!host) 1000 if(!host) {
1001 mpt_detach(pdev);
971 return; 1002 return;
1003 }
972 1004
973 scsi_remove_host(host); 1005 scsi_remove_host(host);
974 1006
@@ -1256,8 +1288,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1256 MPT_SCSI_HOST *hd; 1288 MPT_SCSI_HOST *hd;
1257 MPT_FRAME_HDR *mf; 1289 MPT_FRAME_HDR *mf;
1258 SCSIIORequest_t *pScsiReq; 1290 SCSIIORequest_t *pScsiReq;
1259 VirtDevice *pTarget; 1291 VirtDevice *pTarget = SCpnt->device->hostdata;
1260 int target;
1261 int lun; 1292 int lun;
1262 u32 datalen; 1293 u32 datalen;
1263 u32 scsictl; 1294 u32 scsictl;
@@ -1267,12 +1298,9 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1267 int ii; 1298 int ii;
1268 1299
1269 hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; 1300 hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
1270 target = SCpnt->device->id;
1271 lun = SCpnt->device->lun; 1301 lun = SCpnt->device->lun;
1272 SCpnt->scsi_done = done; 1302 SCpnt->scsi_done = done;
1273 1303
1274 pTarget = hd->Targets[target];
1275
1276 dmfprintk((MYIOC_s_INFO_FMT "qcmd: SCpnt=%p, done()=%p\n", 1304 dmfprintk((MYIOC_s_INFO_FMT "qcmd: SCpnt=%p, done()=%p\n",
1277 (hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt, done)); 1305 (hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt, done));
1278 1306
@@ -1315,7 +1343,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1315 /* Default to untagged. Once a target structure has been allocated, 1343 /* Default to untagged. Once a target structure has been allocated,
1316 * use the Inquiry data to determine if device supports tagged. 1344 * use the Inquiry data to determine if device supports tagged.
1317 */ 1345 */
1318 if ( pTarget 1346 if (pTarget
1319 && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) 1347 && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)
1320 && (SCpnt->device->tagged_supported)) { 1348 && (SCpnt->device->tagged_supported)) {
1321 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; 1349 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ;
@@ -1325,8 +1353,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1325 1353
1326 /* Use the above information to set up the message frame 1354 /* Use the above information to set up the message frame
1327 */ 1355 */
1328 pScsiReq->TargetID = (u8) target; 1356 pScsiReq->TargetID = (u8) pTarget->target_id;
1329 pScsiReq->Bus = (u8) SCpnt->device->channel; 1357 pScsiReq->Bus = pTarget->bus_id;
1330 pScsiReq->ChainOffset = 0; 1358 pScsiReq->ChainOffset = 0;
1331 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; 1359 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
1332 pScsiReq->CDBLength = SCpnt->cmd_len; 1360 pScsiReq->CDBLength = SCpnt->cmd_len;
@@ -1378,7 +1406,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1378 1406
1379#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 1407#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
1380 if (hd->ioc->bus_type == SCSI) { 1408 if (hd->ioc->bus_type == SCSI) {
1381 int dvStatus = hd->ioc->spi_data.dvStatus[target]; 1409 int dvStatus = hd->ioc->spi_data.dvStatus[pTarget->target_id];
1382 int issueCmd = 1; 1410 int issueCmd = 1;
1383 1411
1384 if (dvStatus || hd->ioc->spi_data.forceDv) { 1412 if (dvStatus || hd->ioc->spi_data.forceDv) {
@@ -1426,6 +1454,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1426 return 0; 1454 return 0;
1427 1455
1428 fail: 1456 fail:
1457 hd->ScsiLookup[my_idx] = NULL;
1429 mptscsih_freeChainBuffers(hd->ioc, my_idx); 1458 mptscsih_freeChainBuffers(hd->ioc, my_idx);
1430 mpt_free_msg_frame(hd->ioc, mf); 1459 mpt_free_msg_frame(hd->ioc, mf);
1431 return SCSI_MLQUEUE_HOST_BUSY; 1460 return SCSI_MLQUEUE_HOST_BUSY;
@@ -1713,24 +1742,23 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1713 MPT_FRAME_HDR *mf; 1742 MPT_FRAME_HDR *mf;
1714 u32 ctx2abort; 1743 u32 ctx2abort;
1715 int scpnt_idx; 1744 int scpnt_idx;
1745 int retval;
1716 1746
1717 /* If we can't locate our host adapter structure, return FAILED status. 1747 /* If we can't locate our host adapter structure, return FAILED status.
1718 */ 1748 */
1719 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { 1749 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) {
1720 SCpnt->result = DID_RESET << 16; 1750 SCpnt->result = DID_RESET << 16;
1721 SCpnt->scsi_done(SCpnt); 1751 SCpnt->scsi_done(SCpnt);
1722 dfailprintk((KERN_WARNING MYNAM ": mptscsih_abort: " 1752 dfailprintk((KERN_INFO MYNAM ": mptscsih_abort: "
1723 "Can't locate host! (sc=%p)\n", 1753 "Can't locate host! (sc=%p)\n",
1724 SCpnt)); 1754 SCpnt));
1725 return FAILED; 1755 return FAILED;
1726 } 1756 }
1727 1757
1728 ioc = hd->ioc; 1758 ioc = hd->ioc;
1729 if (hd->resetPending) 1759 if (hd->resetPending) {
1730 return FAILED; 1760 return FAILED;
1731 1761 }
1732 printk(KERN_WARNING MYNAM ": %s: >> Attempting task abort! (sc=%p)\n",
1733 hd->ioc->name, SCpnt);
1734 1762
1735 if (hd->timeouts < -1) 1763 if (hd->timeouts < -1)
1736 hd->timeouts++; 1764 hd->timeouts++;
@@ -1738,16 +1766,20 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1738 /* Find this command 1766 /* Find this command
1739 */ 1767 */
1740 if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { 1768 if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) {
1741 /* Cmd not found in ScsiLookup. 1769 /* Cmd not found in ScsiLookup.
1742 * Do OS callback. 1770 * Do OS callback.
1743 */ 1771 */
1744 SCpnt->result = DID_RESET << 16; 1772 SCpnt->result = DID_RESET << 16;
1745 dtmprintk((KERN_WARNING MYNAM ": %s: mptscsih_abort: " 1773 dtmprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: "
1746 "Command not in the active list! (sc=%p)\n", 1774 "Command not in the active list! (sc=%p)\n",
1747 hd->ioc->name, SCpnt)); 1775 hd->ioc->name, SCpnt));
1748 return SUCCESS; 1776 return SUCCESS;
1749 } 1777 }
1750 1778
1779 printk(KERN_WARNING MYNAM ": %s: attempting task abort! (sc=%p)\n",
1780 hd->ioc->name, SCpnt);
1781 scsi_print_command(SCpnt);
1782
1751 /* Most important! Set TaskMsgContext to SCpnt's MsgContext! 1783 /* Most important! Set TaskMsgContext to SCpnt's MsgContext!
1752 * (the IO to be ABORT'd) 1784 * (the IO to be ABORT'd)
1753 * 1785 *
@@ -1760,38 +1792,22 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1760 1792
1761 hd->abortSCpnt = SCpnt; 1793 hd->abortSCpnt = SCpnt;
1762 1794
1763 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, 1795 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
1764 SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, 1796 SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun,
1765 ctx2abort, 2 /* 2 second timeout */) 1797 ctx2abort, 2 /* 2 second timeout */);
1766 < 0) {
1767 1798
1768 /* The TM request failed and the subsequent FW-reload failed! 1799 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
1769 * Fatal error case. 1800 hd->ioc->name,
1770 */ 1801 ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
1771 printk(MYIOC_s_WARN_FMT "Error issuing abort task! (sc=%p)\n",
1772 hd->ioc->name, SCpnt);
1773 1802
1774 /* We must clear our pending flag before clearing our state. 1803 if (retval == 0)
1775 */ 1804 return SUCCESS;
1805
1806 if(retval != FAILED ) {
1776 hd->tmPending = 0; 1807 hd->tmPending = 0;
1777 hd->tmState = TM_STATE_NONE; 1808 hd->tmState = TM_STATE_NONE;
1778
1779 /* Unmap the DMA buffers, if any. */
1780 if (SCpnt->use_sg) {
1781 pci_unmap_sg(ioc->pcidev, (struct scatterlist *) SCpnt->request_buffer,
1782 SCpnt->use_sg, SCpnt->sc_data_direction);
1783 } else if (SCpnt->request_bufflen) {
1784 pci_unmap_single(ioc->pcidev, SCpnt->SCp.dma_handle,
1785 SCpnt->request_bufflen, SCpnt->sc_data_direction);
1786 }
1787 hd->ScsiLookup[scpnt_idx] = NULL;
1788 SCpnt->result = DID_RESET << 16;
1789 SCpnt->scsi_done(SCpnt); /* Issue the command callback */
1790 mptscsih_freeChainBuffers(ioc, scpnt_idx);
1791 mpt_free_msg_frame(ioc, mf);
1792 return FAILED;
1793 } 1809 }
1794 return SUCCESS; 1810 return FAILED;
1795} 1811}
1796 1812
1797/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1813/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1807,11 +1823,12 @@ int
1807mptscsih_dev_reset(struct scsi_cmnd * SCpnt) 1823mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1808{ 1824{
1809 MPT_SCSI_HOST *hd; 1825 MPT_SCSI_HOST *hd;
1826 int retval;
1810 1827
1811 /* If we can't locate our host adapter structure, return FAILED status. 1828 /* If we can't locate our host adapter structure, return FAILED status.
1812 */ 1829 */
1813 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1830 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
1814 dtmprintk((KERN_WARNING MYNAM ": mptscsih_dev_reset: " 1831 dtmprintk((KERN_INFO MYNAM ": mptscsih_dev_reset: "
1815 "Can't locate host! (sc=%p)\n", 1832 "Can't locate host! (sc=%p)\n",
1816 SCpnt)); 1833 SCpnt));
1817 return FAILED; 1834 return FAILED;
@@ -1820,24 +1837,26 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1820 if (hd->resetPending) 1837 if (hd->resetPending)
1821 return FAILED; 1838 return FAILED;
1822 1839
1823 printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n", 1840 printk(KERN_WARNING MYNAM ": %s: attempting target reset! (sc=%p)\n",
1824 hd->ioc->name, SCpnt); 1841 hd->ioc->name, SCpnt);
1842 scsi_print_command(SCpnt);
1825 1843
1826 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 1844 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1827 SCpnt->device->channel, SCpnt->device->id, 1845 SCpnt->device->channel, SCpnt->device->id,
1828 0, 0, 5 /* 5 second timeout */) 1846 0, 0, 5 /* 5 second timeout */);
1829 < 0){ 1847
1830 /* The TM request failed and the subsequent FW-reload failed! 1848 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n",
1831 * Fatal error case. 1849 hd->ioc->name,
1832 */ 1850 ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
1833 printk(MYIOC_s_WARN_FMT "Error processing TaskMgmt request (sc=%p)\n", 1851
1834 hd->ioc->name, SCpnt); 1852 if (retval == 0)
1853 return SUCCESS;
1854
1855 if(retval != FAILED ) {
1835 hd->tmPending = 0; 1856 hd->tmPending = 0;
1836 hd->tmState = TM_STATE_NONE; 1857 hd->tmState = TM_STATE_NONE;
1837 return FAILED;
1838 } 1858 }
1839 1859 return FAILED;
1840 return SUCCESS;
1841} 1860}
1842 1861
1843/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1862/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1853,41 +1872,39 @@ int
1853mptscsih_bus_reset(struct scsi_cmnd * SCpnt) 1872mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1854{ 1873{
1855 MPT_SCSI_HOST *hd; 1874 MPT_SCSI_HOST *hd;
1856 spinlock_t *host_lock = SCpnt->device->host->host_lock; 1875 int retval;
1857 1876
1858 /* If we can't locate our host adapter structure, return FAILED status. 1877 /* If we can't locate our host adapter structure, return FAILED status.
1859 */ 1878 */
1860 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1879 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
1861 dtmprintk((KERN_WARNING MYNAM ": mptscsih_bus_reset: " 1880 dtmprintk((KERN_INFO MYNAM ": mptscsih_bus_reset: "
1862 "Can't locate host! (sc=%p)\n", 1881 "Can't locate host! (sc=%p)\n",
1863 SCpnt ) ); 1882 SCpnt ) );
1864 return FAILED; 1883 return FAILED;
1865 } 1884 }
1866 1885
1867 printk(KERN_WARNING MYNAM ": %s: >> Attempting bus reset! (sc=%p)\n", 1886 printk(KERN_WARNING MYNAM ": %s: attempting bus reset! (sc=%p)\n",
1868 hd->ioc->name, SCpnt); 1887 hd->ioc->name, SCpnt);
1888 scsi_print_command(SCpnt);
1869 1889
1870 if (hd->timeouts < -1) 1890 if (hd->timeouts < -1)
1871 hd->timeouts++; 1891 hd->timeouts++;
1872 1892
1873 /* We are now ready to execute the task management request. */ 1893 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
1874 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, 1894 SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */);
1875 SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */)
1876 < 0){
1877 1895
1878 /* The TM request failed and the subsequent FW-reload failed! 1896 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n",
1879 * Fatal error case. 1897 hd->ioc->name,
1880 */ 1898 ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
1881 printk(MYIOC_s_WARN_FMT 1899
1882 "Error processing TaskMgmt request (sc=%p)\n", 1900 if (retval == 0)
1883 hd->ioc->name, SCpnt); 1901 return SUCCESS;
1902
1903 if(retval != FAILED ) {
1884 hd->tmPending = 0; 1904 hd->tmPending = 0;
1885 hd->tmState = TM_STATE_NONE; 1905 hd->tmState = TM_STATE_NONE;
1886 spin_lock_irq(host_lock);
1887 return FAILED;
1888 } 1906 }
1889 1907 return FAILED;
1890 return SUCCESS;
1891} 1908}
1892 1909
1893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1910/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -2169,7 +2186,7 @@ mptscsih_slave_alloc(struct scsi_device *device)
2169 vdev->raidVolume = 0; 2186 vdev->raidVolume = 0;
2170 hd->Targets[device->id] = vdev; 2187 hd->Targets[device->id] = vdev;
2171 if (hd->ioc->bus_type == SCSI) { 2188 if (hd->ioc->bus_type == SCSI) {
2172 if (hd->ioc->spi_data.isRaid & (1 << device->id)) { 2189 if (hd->ioc->raid_data.isRaid & (1 << device->id)) {
2173 vdev->raidVolume = 1; 2190 vdev->raidVolume = 1;
2174 ddvtprintk((KERN_INFO 2191 ddvtprintk((KERN_INFO
2175 "RAID Volume @ id %d\n", device->id)); 2192 "RAID Volume @ id %d\n", device->id));
@@ -2180,22 +2197,7 @@ mptscsih_slave_alloc(struct scsi_device *device)
2180 2197
2181 out: 2198 out:
2182 vdev->num_luns++; 2199 vdev->num_luns++;
2183 return 0; 2200 device->hostdata = vdev;
2184}
2185
2186static int
2187mptscsih_is_raid_volume(MPT_SCSI_HOST *hd, uint id)
2188{
2189 int i;
2190
2191 if (!hd->ioc->spi_data.isRaid || !hd->ioc->spi_data.pIocPg3)
2192 return 0;
2193
2194 for (i = 0; i < hd->ioc->spi_data.pIocPg3->NumPhysDisks; i++) {
2195 if (id == hd->ioc->spi_data.pIocPg3->PhysDisk[i].PhysDiskID)
2196 return 1;
2197 }
2198
2199 return 0; 2201 return 0;
2200} 2202}
2201 2203
@@ -2226,7 +2228,7 @@ mptscsih_slave_destroy(struct scsi_device *device)
2226 hd->Targets[target] = NULL; 2228 hd->Targets[target] = NULL;
2227 2229
2228 if (hd->ioc->bus_type == SCSI) { 2230 if (hd->ioc->bus_type == SCSI) {
2229 if (mptscsih_is_raid_volume(hd, target)) { 2231 if (mptscsih_is_phys_disk(hd->ioc, target)) {
2230 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; 2232 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
2231 } else { 2233 } else {
2232 hd->ioc->spi_data.dvStatus[target] = 2234 hd->ioc->spi_data.dvStatus[target] =
@@ -2439,6 +2441,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2439{ 2441{
2440 MPT_SCSI_HOST *hd; 2442 MPT_SCSI_HOST *hd;
2441 unsigned long flags; 2443 unsigned long flags;
2444 int ii;
2442 2445
2443 dtmprintk((KERN_WARNING MYNAM 2446 dtmprintk((KERN_WARNING MYNAM
2444 ": IOC %s_reset routed to SCSI host driver!\n", 2447 ": IOC %s_reset routed to SCSI host driver!\n",
@@ -2496,11 +2499,8 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2496 2499
2497 /* ScsiLookup initialization 2500 /* ScsiLookup initialization
2498 */ 2501 */
2499 { 2502 for (ii=0; ii < hd->ioc->req_depth; ii++)
2500 int ii; 2503 hd->ScsiLookup[ii] = NULL;
2501 for (ii=0; ii < hd->ioc->req_depth; ii++)
2502 hd->ScsiLookup[ii] = NULL;
2503 }
2504 2504
2505 /* 2. Chain Buffer initialization 2505 /* 2. Chain Buffer initialization
2506 */ 2506 */
@@ -2549,6 +2549,16 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2549} 2549}
2550 2550
2551/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2551/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2552/* work queue thread to clear the persitency table */
2553static void
2554mptscsih_sas_persist_clear_table(void * arg)
2555{
2556 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;
2557
2558 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
2559}
2560
2561/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2552int 2562int
2553mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) 2563mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2554{ 2564{
@@ -2558,18 +2568,18 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2558 devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", 2568 devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
2559 ioc->name, event)); 2569 ioc->name, event));
2560 2570
2571 if (ioc->sh == NULL ||
2572 ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL))
2573 return 1;
2574
2561 switch (event) { 2575 switch (event) {
2562 case MPI_EVENT_UNIT_ATTENTION: /* 03 */ 2576 case MPI_EVENT_UNIT_ATTENTION: /* 03 */
2563 /* FIXME! */ 2577 /* FIXME! */
2564 break; 2578 break;
2565 case MPI_EVENT_IOC_BUS_RESET: /* 04 */ 2579 case MPI_EVENT_IOC_BUS_RESET: /* 04 */
2566 case MPI_EVENT_EXT_BUS_RESET: /* 05 */ 2580 case MPI_EVENT_EXT_BUS_RESET: /* 05 */
2567 hd = NULL; 2581 if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1))
2568 if (ioc->sh) { 2582 hd->soft_resets++;
2569 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
2570 if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1))
2571 hd->soft_resets++;
2572 }
2573 break; 2583 break;
2574 case MPI_EVENT_LOGOUT: /* 09 */ 2584 case MPI_EVENT_LOGOUT: /* 09 */
2575 /* FIXME! */ 2585 /* FIXME! */
@@ -2588,69 +2598,24 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2588 break; 2598 break;
2589 2599
2590 case MPI_EVENT_INTEGRATED_RAID: /* 0B */ 2600 case MPI_EVENT_INTEGRATED_RAID: /* 0B */
2601 {
2602 pMpiEventDataRaid_t pRaidEventData =
2603 (pMpiEventDataRaid_t) pEvReply->Data;
2591#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 2604#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
2592 /* negoNvram set to 0 if DV enabled and to USE_NVRAM if 2605 /* Domain Validation Needed */
2593 * if DV disabled. Need to check for target mode. 2606 if (ioc->bus_type == SCSI &&
2594 */ 2607 pRaidEventData->ReasonCode ==
2595 hd = NULL; 2608 MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED)
2596 if (ioc->sh) 2609 mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum);
2597 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
2598
2599 if (hd && (ioc->bus_type == SCSI) && (hd->negoNvram == 0)) {
2600 ScsiCfgData *pSpi;
2601 Ioc3PhysDisk_t *pPDisk;
2602 int numPDisk;
2603 u8 reason;
2604 u8 physDiskNum;
2605
2606 reason = (le32_to_cpu(pEvReply->Data[0]) & 0x00FF0000) >> 16;
2607 if (reason == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
2608 /* New or replaced disk.
2609 * Set DV flag and schedule DV.
2610 */
2611 pSpi = &ioc->spi_data;
2612 physDiskNum = (le32_to_cpu(pEvReply->Data[0]) & 0xFF000000) >> 24;
2613 ddvtprintk(("DV requested for phys disk id %d\n", physDiskNum));
2614 if (pSpi->pIocPg3) {
2615 pPDisk = pSpi->pIocPg3->PhysDisk;
2616 numPDisk =pSpi->pIocPg3->NumPhysDisks;
2617
2618 while (numPDisk) {
2619 if (physDiskNum == pPDisk->PhysDiskNum) {
2620 pSpi->dvStatus[pPDisk->PhysDiskID] = (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
2621 pSpi->forceDv = MPT_SCSICFG_NEED_DV;
2622 ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
2623 break;
2624 }
2625 pPDisk++;
2626 numPDisk--;
2627 }
2628
2629 if (numPDisk == 0) {
2630 /* The physical disk that needs DV was not found
2631 * in the stored IOC Page 3. The driver must reload
2632 * this page. DV routine will set the NEED_DV flag for
2633 * all phys disks that have DV_NOT_DONE set.
2634 */
2635 pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
2636 ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n", physDiskNum));
2637 }
2638 }
2639 }
2640 }
2641#endif 2610#endif
2611 break;
2612 }
2642 2613
2643#if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY) 2614 /* Persistent table is full. */
2644 printk("Raid Event RF: "); 2615 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2645 { 2616 INIT_WORK(&mptscsih_persistTask,
2646 u32 *m = (u32 *)pEvReply; 2617 mptscsih_sas_persist_clear_table,(void *)ioc);
2647 int ii; 2618 schedule_work(&mptscsih_persistTask);
2648 int n = (int)pEvReply->MsgLength;
2649 for (ii=6; ii < n; ii++)
2650 printk(" %08x", le32_to_cpu(m[ii]));
2651 printk("\n");
2652 }
2653#endif
2654 break; 2619 break;
2655 2620
2656 case MPI_EVENT_NONE: /* 00 */ 2621 case MPI_EVENT_NONE: /* 00 */
@@ -2687,7 +2652,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
2687{ 2652{
2688 int indexed_lun, lun_index; 2653 int indexed_lun, lun_index;
2689 VirtDevice *vdev; 2654 VirtDevice *vdev;
2690 ScsiCfgData *pSpi; 2655 SpiCfgData *pSpi;
2691 char data_56; 2656 char data_56;
2692 2657
2693 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", 2658 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n",
@@ -2794,7 +2759,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
2794static void 2759static void
2795mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) 2760mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
2796{ 2761{
2797 ScsiCfgData *pspi_data = &hd->ioc->spi_data; 2762 SpiCfgData *pspi_data = &hd->ioc->spi_data;
2798 int id = (int) target->target_id; 2763 int id = (int) target->target_id;
2799 int nvram; 2764 int nvram;
2800 VirtDevice *vdev; 2765 VirtDevice *vdev;
@@ -2973,11 +2938,13 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
2973static void 2938static void
2974mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) 2939mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
2975{ 2940{
2941 MPT_ADAPTER *ioc = hd->ioc;
2976 u8 cmd; 2942 u8 cmd;
2977 ScsiCfgData *pSpi; 2943 SpiCfgData *pSpi;
2978 2944
2979 ddvtprintk((" set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", 2945 ddvtprintk((MYIOC_s_NOTE_FMT
2980 pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); 2946 " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
2947 hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0]));
2981 2948
2982 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) 2949 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0))
2983 return; 2950 return;
@@ -2985,12 +2952,12 @@ mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
2985 cmd = pReq->CDB[0]; 2952 cmd = pReq->CDB[0];
2986 2953
2987 if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) { 2954 if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) {
2988 pSpi = &hd->ioc->spi_data; 2955 pSpi = &ioc->spi_data;
2989 if ((pSpi->isRaid & (1 << pReq->TargetID)) && pSpi->pIocPg3) { 2956 if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) {
2990 /* Set NEED_DV for all hidden disks 2957 /* Set NEED_DV for all hidden disks
2991 */ 2958 */
2992 Ioc3PhysDisk_t *pPDisk = pSpi->pIocPg3->PhysDisk; 2959 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
2993 int numPDisk = pSpi->pIocPg3->NumPhysDisks; 2960 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
2994 2961
2995 while (numPDisk) { 2962 while (numPDisk) {
2996 pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV; 2963 pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
@@ -3004,6 +2971,50 @@ mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
3004 } 2971 }
3005} 2972}
3006 2973
2974/* mptscsih_raid_set_dv_flags()
2975 *
2976 * New or replaced disk. Set DV flag and schedule DV.
2977 */
2978static void
2979mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id)
2980{
2981 MPT_ADAPTER *ioc = hd->ioc;
2982 SpiCfgData *pSpi = &ioc->spi_data;
2983 Ioc3PhysDisk_t *pPDisk;
2984 int numPDisk;
2985
2986 if (hd->negoNvram != 0)
2987 return;
2988
2989 ddvtprintk(("DV requested for phys disk id %d\n", id));
2990 if (ioc->raid_data.pIocPg3) {
2991 pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
2992 numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
2993 while (numPDisk) {
2994 if (id == pPDisk->PhysDiskNum) {
2995 pSpi->dvStatus[pPDisk->PhysDiskID] =
2996 (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
2997 pSpi->forceDv = MPT_SCSICFG_NEED_DV;
2998 ddvtprintk(("NEED_DV set for phys disk id %d\n",
2999 pPDisk->PhysDiskID));
3000 break;
3001 }
3002 pPDisk++;
3003 numPDisk--;
3004 }
3005
3006 if (numPDisk == 0) {
3007 /* The physical disk that needs DV was not found
3008 * in the stored IOC Page 3. The driver must reload
3009 * this page. DV routine will set the NEED_DV flag for
3010 * all phys disks that have DV_NOT_DONE set.
3011 */
3012 pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
3013 ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id));
3014 }
3015 }
3016}
3017
3007/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3018/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3008/* 3019/*
3009 * If no Target, bus reset on 1st I/O. Set the flag to 3020 * If no Target, bus reset on 1st I/O. Set the flag to
@@ -3091,7 +3102,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3091 MPT_ADAPTER *ioc = hd->ioc; 3102 MPT_ADAPTER *ioc = hd->ioc;
3092 Config_t *pReq; 3103 Config_t *pReq;
3093 SCSIDevicePage1_t *pData; 3104 SCSIDevicePage1_t *pData;
3094 VirtDevice *pTarget; 3105 VirtDevice *pTarget=NULL;
3095 MPT_FRAME_HDR *mf; 3106 MPT_FRAME_HDR *mf;
3096 dma_addr_t dataDma; 3107 dma_addr_t dataDma;
3097 u16 req_idx; 3108 u16 req_idx;
@@ -3190,7 +3201,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3190#endif 3201#endif
3191 3202
3192 if (flags & MPT_SCSICFG_BLK_NEGO) 3203 if (flags & MPT_SCSICFG_BLK_NEGO)
3193 negoFlags = MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC; 3204 negoFlags |= MPT_TARGET_NO_NEGO_WIDE | MPT_TARGET_NO_NEGO_SYNC;
3194 3205
3195 mptscsih_setDevicePage1Flags(width, factor, offset, 3206 mptscsih_setDevicePage1Flags(width, factor, offset,
3196 &requested, &configuration, negoFlags); 3207 &requested, &configuration, negoFlags);
@@ -4011,7 +4022,7 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum)
4011 4022
4012 /* If target Ptr NULL or if this target is NOT a disk, skip. 4023 /* If target Ptr NULL or if this target is NOT a disk, skip.
4013 */ 4024 */
4014 if ((pTarget) && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)){ 4025 if ((pTarget) && (pTarget->inq_data[0] == TYPE_DISK)){
4015 for (lun=0; lun <= MPT_LAST_LUN; lun++) { 4026 for (lun=0; lun <= MPT_LAST_LUN; lun++) {
4016 /* If LUN present, issue the command 4027 /* If LUN present, issue the command
4017 */ 4028 */
@@ -4106,9 +4117,9 @@ mptscsih_domainValidation(void *arg)
4106 4117
4107 if ((ioc->spi_data.forceDv & MPT_SCSICFG_RELOAD_IOC_PG3) != 0) { 4118 if ((ioc->spi_data.forceDv & MPT_SCSICFG_RELOAD_IOC_PG3) != 0) {
4108 mpt_read_ioc_pg_3(ioc); 4119 mpt_read_ioc_pg_3(ioc);
4109 if (ioc->spi_data.pIocPg3) { 4120 if (ioc->raid_data.pIocPg3) {
4110 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; 4121 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
4111 int numPDisk = ioc->spi_data.pIocPg3->NumPhysDisks; 4122 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
4112 4123
4113 while (numPDisk) { 4124 while (numPDisk) {
4114 if (ioc->spi_data.dvStatus[pPDisk->PhysDiskID] & MPT_SCSICFG_DV_NOT_DONE) 4125 if (ioc->spi_data.dvStatus[pPDisk->PhysDiskID] & MPT_SCSICFG_DV_NOT_DONE)
@@ -4147,7 +4158,7 @@ mptscsih_domainValidation(void *arg)
4147 isPhysDisk = mptscsih_is_phys_disk(ioc, id); 4158 isPhysDisk = mptscsih_is_phys_disk(ioc, id);
4148 if (isPhysDisk) { 4159 if (isPhysDisk) {
4149 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { 4160 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
4150 if (hd->ioc->spi_data.isRaid & (1 << ii)) { 4161 if (hd->ioc->raid_data.isRaid & (1 << ii)) {
4151 hd->ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_DV_PENDING; 4162 hd->ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_DV_PENDING;
4152 } 4163 }
4153 } 4164 }
@@ -4166,7 +4177,7 @@ mptscsih_domainValidation(void *arg)
4166 4177
4167 if (isPhysDisk) { 4178 if (isPhysDisk) {
4168 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { 4179 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
4169 if (hd->ioc->spi_data.isRaid & (1 << ii)) { 4180 if (hd->ioc->raid_data.isRaid & (1 << ii)) {
4170 hd->ioc->spi_data.dvStatus[ii] &= ~MPT_SCSICFG_DV_PENDING; 4181 hd->ioc->spi_data.dvStatus[ii] &= ~MPT_SCSICFG_DV_PENDING;
4171 } 4182 }
4172 } 4183 }
@@ -4188,21 +4199,21 @@ mptscsih_domainValidation(void *arg)
4188 4199
4189/* Search IOC page 3 to determine if this is hidden physical disk 4200/* Search IOC page 3 to determine if this is hidden physical disk
4190 */ 4201 */
4191static int 4202/* Search IOC page 3 to determine if this is hidden physical disk
4203 */
4204static int
4192mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) 4205mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4193{ 4206{
4194 if (ioc->spi_data.pIocPg3) { 4207 int i;
4195 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk;
4196 int numPDisk = ioc->spi_data.pIocPg3->NumPhysDisks;
4197 4208
4198 while (numPDisk) { 4209 if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3)
4199 if (pPDisk->PhysDiskID == id) { 4210 return 0;
4200 return 1; 4211
4201 } 4212 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
4202 pPDisk++; 4213 if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID)
4203 numPDisk--; 4214 return 1;
4204 }
4205 } 4215 }
4216
4206 return 0; 4217 return 0;
4207} 4218}
4208 4219
@@ -4408,7 +4419,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4408 /* Skip this ID? Set cfg.cfghdr.hdr to force config page write 4419 /* Skip this ID? Set cfg.cfghdr.hdr to force config page write
4409 */ 4420 */
4410 { 4421 {
4411 ScsiCfgData *pspi_data = &hd->ioc->spi_data; 4422 SpiCfgData *pspi_data = &hd->ioc->spi_data;
4412 if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) { 4423 if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) {
4413 /* Set the factor from nvram */ 4424 /* Set the factor from nvram */
4414 nfactor = (pspi_data->nvram[id] & MPT_NVRAM_SYNC_MASK) >> 8; 4425 nfactor = (pspi_data->nvram[id] & MPT_NVRAM_SYNC_MASK) >> 8;
@@ -4438,11 +4449,11 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4438 } 4449 }
4439 4450
4440 /* Finish iocmd inititialization - hidden or visible disk? */ 4451 /* Finish iocmd inititialization - hidden or visible disk? */
4441 if (ioc->spi_data.pIocPg3) { 4452 if (ioc->raid_data.pIocPg3) {
4442 /* Search IOC page 3 for matching id 4453 /* Search IOC page 3 for matching id
4443 */ 4454 */
4444 Ioc3PhysDisk_t *pPDisk = ioc->spi_data.pIocPg3->PhysDisk; 4455 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
4445 int numPDisk = ioc->spi_data.pIocPg3->NumPhysDisks; 4456 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
4446 4457
4447 while (numPDisk) { 4458 while (numPDisk) {
4448 if (pPDisk->PhysDiskID == id) { 4459 if (pPDisk->PhysDiskID == id) {
@@ -4466,7 +4477,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4466 /* RAID Volume ID's may double for a physical device. If RAID but 4477 /* RAID Volume ID's may double for a physical device. If RAID but
4467 * not a physical ID as well, skip DV. 4478 * not a physical ID as well, skip DV.
4468 */ 4479 */
4469 if ((hd->ioc->spi_data.isRaid & (1 << id)) && !(iocmd.flags & MPT_ICFLAG_PHYS_DISK)) 4480 if ((hd->ioc->raid_data.isRaid & (1 << id)) && !(iocmd.flags & MPT_ICFLAG_PHYS_DISK))
4470 goto target_done; 4481 goto target_done;
4471 4482
4472 4483
@@ -4815,6 +4826,8 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4815 notDone = 0; 4826 notDone = 0;
4816 if (iocmd.flags & MPT_ICFLAG_ECHO) { 4827 if (iocmd.flags & MPT_ICFLAG_ECHO) {
4817 bufsize = ((pbuf1[2] & 0x1F) <<8) | pbuf1[3]; 4828 bufsize = ((pbuf1[2] & 0x1F) <<8) | pbuf1[3];
4829 if (pbuf1[0] & 0x01)
4830 iocmd.flags |= MPT_ICFLAG_EBOS;
4818 } else { 4831 } else {
4819 bufsize = pbuf1[1]<<16 | pbuf1[2]<<8 | pbuf1[3]; 4832 bufsize = pbuf1[1]<<16 | pbuf1[2]<<8 | pbuf1[3];
4820 } 4833 }
@@ -4911,6 +4924,9 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4911 } 4924 }
4912 iocmd.flags &= ~MPT_ICFLAG_DID_RESET; 4925 iocmd.flags &= ~MPT_ICFLAG_DID_RESET;
4913 4926
4927 if (iocmd.flags & MPT_ICFLAG_EBOS)
4928 goto skip_Reserve;
4929
4914 repeat = 5; 4930 repeat = 5;
4915 while (repeat && (!(iocmd.flags & MPT_ICFLAG_RESERVED))) { 4931 while (repeat && (!(iocmd.flags & MPT_ICFLAG_RESERVED))) {
4916 iocmd.cmd = RESERVE; 4932 iocmd.cmd = RESERVE;
@@ -4954,6 +4970,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4954 } 4970 }
4955 } 4971 }
4956 4972
4973skip_Reserve:
4957 mptscsih_fillbuf(pbuf1, sz, patt, 1); 4974 mptscsih_fillbuf(pbuf1, sz, patt, 1);
4958 iocmd.cmd = WRITE_BUFFER; 4975 iocmd.cmd = WRITE_BUFFER;
4959 iocmd.data_dma = buf1_dma; 4976 iocmd.data_dma = buf1_dma;
@@ -5198,11 +5215,12 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5198 * If not an LVD bus, the adapter minSyncFactor has been 5215 * If not an LVD bus, the adapter minSyncFactor has been
5199 * already throttled back. 5216 * already throttled back.
5200 */ 5217 */
5218 negoFlags = hd->ioc->spi_data.noQas;
5201 if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) { 5219 if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) {
5202 width = pTarget->maxWidth; 5220 width = pTarget->maxWidth;
5203 offset = pTarget->maxOffset; 5221 offset = pTarget->maxOffset;
5204 factor = pTarget->minSyncFactor; 5222 factor = pTarget->minSyncFactor;
5205 negoFlags = pTarget->negoFlags; 5223 negoFlags |= pTarget->negoFlags;
5206 } else { 5224 } else {
5207 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { 5225 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
5208 data = hd->ioc->spi_data.nvram[id]; 5226 data = hd->ioc->spi_data.nvram[id];
@@ -5223,7 +5241,6 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5223 } 5241 }
5224 5242
5225 /* Set the negotiation flags */ 5243 /* Set the negotiation flags */
5226 negoFlags = hd->ioc->spi_data.noQas;
5227 if (!width) 5244 if (!width)
5228 negoFlags |= MPT_TARGET_NO_NEGO_WIDE; 5245 negoFlags |= MPT_TARGET_NO_NEGO_WIDE;
5229 5246
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 51c0255ac16e..971fda4b8b57 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/message/fusion/mptscsi.h 2 * linux/drivers/message/fusion/mptscsih.h
3 * High performance SCSI / Fibre Channel SCSI Host device driver. 3 * High performance SCSI / Fibre Channel SCSI Host device driver.
4 * For use with PCI chip/adapter(s): 4 * For use with PCI chip/adapter(s):
5 * LSIFC9xx/LSI409xx Fibre Channel 5 * LSIFC9xx/LSI409xx Fibre Channel
@@ -53,8 +53,8 @@
53 * SCSI Public stuff... 53 * SCSI Public stuff...
54 */ 54 */
55 55
56#define MPT_SCSI_CMD_PER_DEV_HIGH 31 56#define MPT_SCSI_CMD_PER_DEV_HIGH 64
57#define MPT_SCSI_CMD_PER_DEV_LOW 7 57#define MPT_SCSI_CMD_PER_DEV_LOW 32
58 58
59#define MPT_SCSI_CMD_PER_LUN 7 59#define MPT_SCSI_CMD_PER_LUN 7
60 60
@@ -77,6 +77,7 @@
77#define MPTSCSIH_MAX_WIDTH 1 77#define MPTSCSIH_MAX_WIDTH 1
78#define MPTSCSIH_MIN_SYNC 0x08 78#define MPTSCSIH_MIN_SYNC 0x08
79#define MPTSCSIH_SAF_TE 0 79#define MPTSCSIH_SAF_TE 0
80#define MPTSCSIH_PT_CLEAR 0
80 81
81 82
82#endif 83#endif
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 587d1274fd74..5c0e307d1d5d 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -199,7 +199,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
199 printk(MYIOC_s_WARN_FMT 199 printk(MYIOC_s_WARN_FMT
200 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n", 200 "Skipping ioc=%p because SCSI Initiator mode is NOT enabled!\n",
201 ioc->name, ioc); 201 ioc->name, ioc);
202 return -ENODEV; 202 return 0;
203 } 203 }
204 204
205 sh = scsi_host_alloc(&mptspi_driver_template, sizeof(MPT_SCSI_HOST)); 205 sh = scsi_host_alloc(&mptspi_driver_template, sizeof(MPT_SCSI_HOST));
diff --git a/drivers/message/i2o/config-osm.c b/drivers/message/i2o/config-osm.c
index af32ab4e90cd..10432f665201 100644
--- a/drivers/message/i2o/config-osm.c
+++ b/drivers/message/i2o/config-osm.c
@@ -56,8 +56,11 @@ static int __init i2o_config_init(void)
56 return -EBUSY; 56 return -EBUSY;
57 } 57 }
58#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL 58#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
59 if (i2o_config_old_init()) 59 if (i2o_config_old_init()) {
60 osm_err("old config handler initialization failed\n");
60 i2o_driver_unregister(&i2o_config_driver); 61 i2o_driver_unregister(&i2o_config_driver);
62 return -EBUSY;
63 }
61#endif 64#endif
62 65
63 return 0; 66 return 0;
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 10f6ce1bc0ab..e335d54c4659 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -457,6 +457,17 @@ static int ucb1x00_detect_irq(struct ucb1x00 *ucb)
457 return probe_irq_off(mask); 457 return probe_irq_off(mask);
458} 458}
459 459
460static void ucb1x00_release(struct class_device *dev)
461{
462 struct ucb1x00 *ucb = classdev_to_ucb1x00(dev);
463 kfree(ucb);
464}
465
466static struct class ucb1x00_class = {
467 .name = "ucb1x00",
468 .release = ucb1x00_release,
469};
470
460static int ucb1x00_probe(struct mcp *mcp) 471static int ucb1x00_probe(struct mcp *mcp)
461{ 472{
462 struct ucb1x00 *ucb; 473 struct ucb1x00 *ucb;
@@ -546,17 +557,6 @@ static void ucb1x00_remove(struct mcp *mcp)
546 class_device_unregister(&ucb->cdev); 557 class_device_unregister(&ucb->cdev);
547} 558}
548 559
549static void ucb1x00_release(struct class_device *dev)
550{
551 struct ucb1x00 *ucb = classdev_to_ucb1x00(dev);
552 kfree(ucb);
553}
554
555static struct class ucb1x00_class = {
556 .name = "ucb1x00",
557 .release = ucb1x00_release,
558};
559
560int ucb1x00_register_driver(struct ucb1x00_driver *drv) 560int ucb1x00_register_driver(struct ucb1x00_driver *drv)
561{ 561{
562 struct ucb1x00 *ucb; 562 struct ucb1x00 *ucb;
@@ -642,8 +642,6 @@ static void __exit ucb1x00_exit(void)
642module_init(ucb1x00_init); 642module_init(ucb1x00_init);
643module_exit(ucb1x00_exit); 643module_exit(ucb1x00_exit);
644 644
645EXPORT_SYMBOL(ucb1x00_class);
646
647EXPORT_SYMBOL(ucb1x00_io_set_dir); 645EXPORT_SYMBOL(ucb1x00_io_set_dir);
648EXPORT_SYMBOL(ucb1x00_io_write); 646EXPORT_SYMBOL(ucb1x00_io_write);
649EXPORT_SYMBOL(ucb1x00_io_read); 647EXPORT_SYMBOL(ucb1x00_io_read);
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index a851d65c7cfe..a260f83bcb02 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -48,8 +48,8 @@ struct ucb1x00_ts {
48 u16 x_res; 48 u16 x_res;
49 u16 y_res; 49 u16 y_res;
50 50
51 int restart:1; 51 unsigned int restart:1;
52 int adcsync:1; 52 unsigned int adcsync:1;
53}; 53};
54 54
55static int adcsync; 55static int adcsync;
diff --git a/drivers/mfd/ucb1x00.h b/drivers/mfd/ucb1x00.h
index 6b632644f59a..9c9a647d8b7b 100644
--- a/drivers/mfd/ucb1x00.h
+++ b/drivers/mfd/ucb1x00.h
@@ -106,8 +106,6 @@ struct ucb1x00_irq {
106 void (*fn)(int, void *); 106 void (*fn)(int, void *);
107}; 107};
108 108
109extern struct class ucb1x00_class;
110
111struct ucb1x00 { 109struct ucb1x00 {
112 spinlock_t lock; 110 spinlock_t lock;
113 struct mcp *mcp; 111 struct mcp *mcp;
diff --git a/drivers/mtd/devices/docecc.c b/drivers/mtd/devices/docecc.c
index 9a087c1fb0b7..24f670b5a4f3 100644
--- a/drivers/mtd/devices/docecc.c
+++ b/drivers/mtd/devices/docecc.c
@@ -40,7 +40,7 @@
40#include <linux/mtd/mtd.h> 40#include <linux/mtd/mtd.h>
41#include <linux/mtd/doc2000.h> 41#include <linux/mtd/doc2000.h>
42 42
43#define DEBUG 0 43#define DEBUG_ECC 0
44/* need to undef it (from asm/termbits.h) */ 44/* need to undef it (from asm/termbits.h) */
45#undef B0 45#undef B0
46 46
@@ -249,7 +249,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
249 lambda[j] ^= Alpha_to[modnn(u + tmp)]; 249 lambda[j] ^= Alpha_to[modnn(u + tmp)];
250 } 250 }
251 } 251 }
252#if DEBUG >= 1 252#if DEBUG_ECC >= 1
253 /* Test code that verifies the erasure locator polynomial just constructed 253 /* Test code that verifies the erasure locator polynomial just constructed
254 Needed only for decoder debugging. */ 254 Needed only for decoder debugging. */
255 255
@@ -276,7 +276,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
276 count = -1; 276 count = -1;
277 goto finish; 277 goto finish;
278 } 278 }
279#if DEBUG >= 2 279#if DEBUG_ECC >= 2
280 printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n"); 280 printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n");
281 for (i = 0; i < count; i++) 281 for (i = 0; i < count; i++)
282 printf("%d ", loc[i]); 282 printf("%d ", loc[i]);
@@ -409,7 +409,7 @@ eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
409 den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])]; 409 den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])];
410 } 410 }
411 if (den == 0) { 411 if (den == 0) {
412#if DEBUG >= 1 412#if DEBUG_ECC >= 1
413 printf("\n ERROR: denominator = 0\n"); 413 printf("\n ERROR: denominator = 0\n");
414#endif 414#endif
415 /* Convert to dual- basis */ 415 /* Convert to dual- basis */
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
index 0c45464e3f7b..0ba0ff7d43b9 100644
--- a/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -39,7 +39,6 @@
39#include <linux/mtd/partitions.h> 39#include <linux/mtd/partitions.h>
40 40
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/mach-types.h>
43#include <asm/mach/flash.h> 42#include <asm/mach/flash.h>
44 43
45#include <asm/arch/map.h> 44#include <asm/arch/map.h>
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 3e94b616743d..a9f86c7fbd52 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -30,7 +30,6 @@
30 30
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/hardware.h> 32#include <asm/hardware.h>
33#include <asm/mach-types.h>
34#include <asm/mach/flash.h> 33#include <asm/mach/flash.h>
35 34
36#include <linux/reboot.h> 35#include <linux/reboot.h>
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 5afe660aa2c4..3fcc32884074 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -26,7 +26,6 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/mach-types.h>
30#include <asm/mach/flash.h> 29#include <asm/mach/flash.h>
31 30
32#include <linux/reboot.h> 31#include <linux/reboot.h>
@@ -254,6 +253,6 @@ module_init(ixp4xx_flash_init);
254module_exit(ixp4xx_flash_exit); 253module_exit(ixp4xx_flash_exit);
255 254
256MODULE_LICENSE("GPL"); 255MODULE_LICENSE("GPL");
257MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems") 256MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems");
258MODULE_AUTHOR("Deepak Saxena"); 257MODULE_AUTHOR("Deepak Saxena");
259 258
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
index 8cc71409a328..b17bca657daf 100644
--- a/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -42,7 +42,6 @@
42 42
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/hardware.h> 44#include <asm/hardware.h>
45#include <asm/mach-types.h>
46#include <asm/mach/flash.h> 45#include <asm/mach/flash.h>
47#include <asm/arch/tc.h> 46#include <asm/arch/tc.h>
48 47
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index 52385705da09..8dcaa357b4bb 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -21,7 +21,6 @@
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/mtd/concat.h> 22#include <linux/mtd/concat.h>
23 23
24#include <asm/mach-types.h>
25#include <asm/io.h> 24#include <asm/io.h>
26#include <asm/sizes.h> 25#include <asm/sizes.h>
27#include <asm/mach/flash.h> 26#include <asm/mach/flash.h>
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c
index d15da6fd84c1..b7f093fbf9b0 100644
--- a/drivers/mtd/maps/sharpsl-flash.c
+++ b/drivers/mtd/maps/sharpsl-flash.c
@@ -82,7 +82,7 @@ int __init init_sharpsl(void)
82 } else if (machine_is_tosa()) { 82 } else if (machine_is_tosa()) {
83 sharpsl_partitions[0].size=0x006a0000; 83 sharpsl_partitions[0].size=0x006a0000;
84 sharpsl_partitions[0].offset=0x00160000; 84 sharpsl_partitions[0].offset=0x00160000;
85 } else if (machine_is_spitz()) { 85 } else if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi()) {
86 sharpsl_partitions[0].size=0x006b0000; 86 sharpsl_partitions[0].size=0x006b0000;
87 sharpsl_partitions[0].offset=0x00140000; 87 sharpsl_partitions[0].offset=0x00140000;
88 } else { 88 } else {
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 891e3a1b9110..b47ebcb31e0f 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -58,7 +58,6 @@
58#include <linux/mtd/partitions.h> 58#include <linux/mtd/partitions.h>
59 59
60#include <asm/io.h> 60#include <asm/io.h>
61#include <asm/mach-types.h>
62#include <asm/hardware/clock.h> 61#include <asm/hardware/clock.h>
63 62
64#include <asm/arch/regs-nand.h> 63#include <asm/arch/regs-nand.h>
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 9853b87bb756..88b5b5b40b43 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -221,10 +221,16 @@ sharpsl_nand_init(void)
221 sharpsl_partition_info[1].size=25 * 1024 * 1024; 221 sharpsl_partition_info[1].size=25 * 1024 * 1024;
222 } else if (machine_is_husky()) { 222 } else if (machine_is_husky()) {
223 sharpsl_partition_info[1].size=53 * 1024 * 1024; 223 sharpsl_partition_info[1].size=53 * 1024 * 1024;
224 } 224 } else if (machine_is_spitz()) {
225 sharpsl_partition_info[1].size=5 * 1024 * 1024;
226 } else if (machine_is_akita()) {
227 sharpsl_partition_info[1].size=58 * 1024 * 1024;
228 } else if (machine_is_borzoi()) {
229 sharpsl_partition_info[1].size=32 * 1024 * 1024;
230 }
225 } 231 }
226 232
227 if (machine_is_husky()) { 233 if (machine_is_husky() || machine_is_borzoi()) {
228 /* Need to use small eraseblock size for backward compatibility */ 234 /* Need to use small eraseblock size for backward compatibility */
229 sharpsl_mtd->flags |= MTD_NO_VIRTBLOCKS; 235 sharpsl_mtd->flags |= MTD_NO_VIRTBLOCKS;
230 } 236 }
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index 6d76f3a99b17..f87027420081 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -1094,7 +1094,7 @@ static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
1094 1094
1095 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD); 1095 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);
1096 1096
1097 if (inb_p(e8390_base) & E8390_TRANS) 1097 if (inb_p(e8390_base + E8390_CMD) & E8390_TRANS)
1098 { 1098 {
1099 printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n", 1099 printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n",
1100 dev->name); 1100 dev->name);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 96f14ab1c1f5..c748b0e16419 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -548,6 +548,14 @@ config SUNGEM
548 Support for the Sun GEM chip, aka Sun GigabitEthernet/P 2.0. See also 548 Support for the Sun GEM chip, aka Sun GigabitEthernet/P 2.0. See also
549 <http://www.sun.com/products-n-solutions/hardware/docs/pdf/806-3985-10.pdf>. 549 <http://www.sun.com/products-n-solutions/hardware/docs/pdf/806-3985-10.pdf>.
550 550
551config CASSINI
552 tristate "Sun Cassini support"
553 depends on NET_ETHERNET && PCI
554 select CRC32
555 help
556 Support for the Sun Cassini chip, aka Sun GigaSwift Ethernet. See also
557 <http://www.sun.com/products-n-solutions/hardware/docs/pdf/817-4341-10.pdf>
558
551config NET_VENDOR_3COM 559config NET_VENDOR_3COM
552 bool "3COM cards" 560 bool "3COM cards"
553 depends on NET_ETHERNET && (ISA || EISA || MCA || PCI) 561 depends on NET_ETHERNET && (ISA || EISA || MCA || PCI)
@@ -1647,7 +1655,7 @@ config LAN_SAA9730
1647 1655
1648config NET_POCKET 1656config NET_POCKET
1649 bool "Pocket and portable adapters" 1657 bool "Pocket and portable adapters"
1650 depends on NET_ETHERNET && ISA 1658 depends on NET_ETHERNET && PARPORT
1651 ---help--- 1659 ---help---
1652 Cute little network (Ethernet) devices which attach to the parallel 1660 Cute little network (Ethernet) devices which attach to the parallel
1653 port ("pocket adapters"), commonly used with laptops. If you have 1661 port ("pocket adapters"), commonly used with laptops. If you have
@@ -1671,7 +1679,7 @@ config NET_POCKET
1671 1679
1672config ATP 1680config ATP
1673 tristate "AT-LAN-TEC/RealTek pocket adapter support" 1681 tristate "AT-LAN-TEC/RealTek pocket adapter support"
1674 depends on NET_POCKET && ISA && X86 1682 depends on NET_POCKET && PARPORT && X86
1675 select CRC32 1683 select CRC32
1676 ---help--- 1684 ---help---
1677 This is a network (Ethernet) device which attaches to your parallel 1685 This is a network (Ethernet) device which attaches to your parallel
@@ -1686,7 +1694,7 @@ config ATP
1686 1694
1687config DE600 1695config DE600
1688 tristate "D-Link DE600 pocket adapter support" 1696 tristate "D-Link DE600 pocket adapter support"
1689 depends on NET_POCKET && ISA 1697 depends on NET_POCKET && PARPORT
1690 ---help--- 1698 ---help---
1691 This is a network (Ethernet) device which attaches to your parallel 1699 This is a network (Ethernet) device which attaches to your parallel
1692 port. Read <file:Documentation/networking/DLINK.txt> as well as the 1700 port. Read <file:Documentation/networking/DLINK.txt> as well as the
@@ -1701,7 +1709,7 @@ config DE600
1701 1709
1702config DE620 1710config DE620
1703 tristate "D-Link DE620 pocket adapter support" 1711 tristate "D-Link DE620 pocket adapter support"
1704 depends on NET_POCKET && ISA 1712 depends on NET_POCKET && PARPORT
1705 ---help--- 1713 ---help---
1706 This is a network (Ethernet) device which attaches to your parallel 1714 This is a network (Ethernet) device which attaches to your parallel
1707 port. Read <file:Documentation/networking/DLINK.txt> as well as the 1715 port. Read <file:Documentation/networking/DLINK.txt> as well as the
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 8645c843cf4d..8aeec9f2495b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_SUNQE) += sunqe.o
28obj-$(CONFIG_SUNBMAC) += sunbmac.o 28obj-$(CONFIG_SUNBMAC) += sunbmac.o
29obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o 29obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
30obj-$(CONFIG_SUNGEM) += sungem.o sungem_phy.o 30obj-$(CONFIG_SUNGEM) += sungem.o sungem_phy.o
31obj-$(CONFIG_CASSINI) += cassini.o
31 32
32obj-$(CONFIG_MACE) += mace.o 33obj-$(CONFIG_MACE) += mace.o
33obj-$(CONFIG_BMAC) += bmac.o 34obj-$(CONFIG_BMAC) += bmac.o
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index 9b659e3c8d67..c56d86d371a9 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -15,16 +15,13 @@
15 */ 15 */
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/fcntl.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/in.h>
22#include <linux/slab.h> 20#include <linux/slab.h>
23#include <linux/string.h> 21#include <linux/string.h>
24#include <linux/errno.h> 22#include <linux/errno.h>
25#include <linux/netdevice.h> 23#include <linux/netdevice.h>
26#include <linux/etherdevice.h> 24#include <linux/etherdevice.h>
27#include <linux/skbuff.h>
28#include <linux/delay.h> 25#include <linux/delay.h>
29#include <linux/init.h> 26#include <linux/init.h>
30#include <linux/crc32.h> 27#include <linux/crc32.h>
@@ -33,7 +30,6 @@
33#include <asm/system.h> 30#include <asm/system.h>
34#include <asm/irq.h> 31#include <asm/irq.h>
35#include <asm/io.h> 32#include <asm/io.h>
36#include <asm/dma.h>
37 33
38#define TX_BUFFERS 15 34#define TX_BUFFERS 15
39#define RX_BUFFERS 25 35#define RX_BUFFERS 25
@@ -85,7 +81,7 @@ static inline unsigned short read_ireg(u_long base_addr, u_int reg)
85 u_short v; 81 u_short v;
86 __asm__( 82 __asm__(
87 "str%?h %1, [%2] @ NAT_RAP\n\t" 83 "str%?h %1, [%2] @ NAT_RAP\n\t"
88 "str%?h %0, [%2, #8] @ NET_IDP\n\t" 84 "ldr%?h %0, [%2, #8] @ NET_IDP\n\t"
89 : "=r" (v) 85 : "=r" (v)
90 : "r" (reg), "r" (ISAIO_BASE + 0x0464)); 86 : "r" (reg), "r" (ISAIO_BASE + 0x0464));
91 return v; 87 return v;
@@ -288,7 +284,7 @@ static void am79c961_timer(unsigned long data)
288 else if (!lnkstat && carrier) 284 else if (!lnkstat && carrier)
289 netif_carrier_off(dev); 285 netif_carrier_off(dev);
290 286
291 mod_timer(&priv->timer, jiffies + 5*HZ); 287 mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500));
292} 288}
293 289
294/* 290/*
@@ -709,13 +705,9 @@ static int __init am79c961_init(void)
709 goto release; 705 goto release;
710 706
711 am79c961_banner(); 707 am79c961_banner();
712 printk(KERN_INFO "%s: ether address ", dev->name);
713 708
714 /* Retrive and print the ethernet address. */ 709 for (i = 0; i < 6; i++)
715 for (i = 0; i < 6; i++) {
716 dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff; 710 dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff;
717 printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
718 }
719 711
720 spin_lock_init(&priv->chip_lock); 712 spin_lock_init(&priv->chip_lock);
721 init_timer(&priv->timer); 713 init_timer(&priv->timer);
@@ -736,8 +728,14 @@ static int __init am79c961_init(void)
736#endif 728#endif
737 729
738 ret = register_netdev(dev); 730 ret = register_netdev(dev);
739 if (ret == 0) 731 if (ret == 0) {
732 printk(KERN_INFO "%s: ether address ", dev->name);
733
734 for (i = 0; i < 6; i++)
735 printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
736
740 return 0; 737 return 0;
738 }
741 739
742release: 740release:
743 release_region(dev->base_addr, 0x18); 741 release_region(dev->base_addr, 0x18);
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 8dc657fc8afb..60dba4a1ca5c 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -218,7 +218,7 @@ void bmwrite(struct net_device *dev, unsigned long reg_offset, unsigned data )
218 218
219 219
220static inline 220static inline
221volatile unsigned short bmread(struct net_device *dev, unsigned long reg_offset ) 221unsigned short bmread(struct net_device *dev, unsigned long reg_offset )
222{ 222{
223 return in_le16((void __iomem *)dev->base_addr + reg_offset); 223 return in_le16((void __iomem *)dev->base_addr + reg_offset);
224} 224}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f8dedb623dc0..f264ff162979 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -487,6 +487,8 @@
487 * * Added xmit_hash_policy_layer34() 487 * * Added xmit_hash_policy_layer34()
488 * - Modified by Jay Vosburgh <fubar@us.ibm.com> to also support mode 4. 488 * - Modified by Jay Vosburgh <fubar@us.ibm.com> to also support mode 4.
489 * Set version to 2.6.3. 489 * Set version to 2.6.3.
490 * 2005/09/26 - Jay Vosburgh <fubar@us.ibm.com>
491 * - Removed backwards compatibility for old ifenslaves. Version 2.6.4.
490 */ 492 */
491 493
492//#define BONDING_DEBUG 1 494//#define BONDING_DEBUG 1
@@ -595,14 +597,7 @@ static int arp_ip_count = 0;
595static int bond_mode = BOND_MODE_ROUNDROBIN; 597static int bond_mode = BOND_MODE_ROUNDROBIN;
596static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; 598static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2;
597static int lacp_fast = 0; 599static int lacp_fast = 0;
598static int app_abi_ver = 0; 600
599static int orig_app_abi_ver = -1; /* This is used to save the first ABI version
600 * we receive from the application. Once set,
601 * it won't be changed, and the module will
602 * refuse to enslave/release interfaces if the
603 * command comes from an application using
604 * another ABI version.
605 */
606struct bond_parm_tbl { 601struct bond_parm_tbl {
607 char *modename; 602 char *modename;
608 int mode; 603 int mode;
@@ -1294,12 +1289,13 @@ static void bond_mc_list_destroy(struct bonding *bond)
1294/* 1289/*
1295 * Copy all the Multicast addresses from src to the bonding device dst 1290 * Copy all the Multicast addresses from src to the bonding device dst
1296 */ 1291 */
1297static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond, int gpf_flag) 1292static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond,
1293 gfp_t gfp_flag)
1298{ 1294{
1299 struct dev_mc_list *dmi, *new_dmi; 1295 struct dev_mc_list *dmi, *new_dmi;
1300 1296
1301 for (dmi = mc_list; dmi; dmi = dmi->next) { 1297 for (dmi = mc_list; dmi; dmi = dmi->next) {
1302 new_dmi = kmalloc(sizeof(struct dev_mc_list), gpf_flag); 1298 new_dmi = kmalloc(sizeof(struct dev_mc_list), gfp_flag);
1303 1299
1304 if (!new_dmi) { 1300 if (!new_dmi) {
1305 /* FIXME: Potential memory leak !!! */ 1301 /* FIXME: Potential memory leak !!! */
@@ -1653,7 +1649,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1653 int old_features = bond_dev->features; 1649 int old_features = bond_dev->features;
1654 int res = 0; 1650 int res = 0;
1655 1651
1656 if (slave_dev->do_ioctl == NULL) { 1652 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL &&
1653 slave_dev->do_ioctl == NULL) {
1657 printk(KERN_WARNING DRV_NAME 1654 printk(KERN_WARNING DRV_NAME
1658 ": Warning : no link monitoring support for %s\n", 1655 ": Warning : no link monitoring support for %s\n",
1659 slave_dev->name); 1656 slave_dev->name);
@@ -1701,51 +1698,29 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1701 } 1698 }
1702 } 1699 }
1703 1700
1704 if (app_abi_ver >= 1) { 1701 /*
1705 /* The application is using an ABI, which requires the 1702 * Old ifenslave binaries are no longer supported. These can
1706 * slave interface to be closed. 1703 * be identified with moderate accurary by the state of the slave:
1707 */ 1704 * the current ifenslave will set the interface down prior to
1708 if ((slave_dev->flags & IFF_UP)) { 1705 * enslaving it; the old ifenslave will not.
1709 printk(KERN_ERR DRV_NAME 1706 */
1710 ": Error: %s is up\n", 1707 if ((slave_dev->flags & IFF_UP)) {
1711 slave_dev->name); 1708 printk(KERN_ERR DRV_NAME ": %s is up. "
1712 res = -EPERM; 1709 "This may be due to an out of date ifenslave.\n",
1713 goto err_undo_flags; 1710 slave_dev->name);
1714 } 1711 res = -EPERM;
1715 1712 goto err_undo_flags;
1716 if (slave_dev->set_mac_address == NULL) { 1713 }
1717 printk(KERN_ERR DRV_NAME
1718 ": Error: The slave device you specified does "
1719 "not support setting the MAC address.\n");
1720 printk(KERN_ERR
1721 "Your kernel likely does not support slave "
1722 "devices.\n");
1723 1714
1724 res = -EOPNOTSUPP; 1715 if (slave_dev->set_mac_address == NULL) {
1725 goto err_undo_flags; 1716 printk(KERN_ERR DRV_NAME
1726 } 1717 ": Error: The slave device you specified does "
1727 } else { 1718 "not support setting the MAC address.\n");
1728 /* The application is not using an ABI, which requires the 1719 printk(KERN_ERR
1729 * slave interface to be open. 1720 "Your kernel likely does not support slave devices.\n");
1730 */
1731 if (!(slave_dev->flags & IFF_UP)) {
1732 printk(KERN_ERR DRV_NAME
1733 ": Error: %s is not running\n",
1734 slave_dev->name);
1735 res = -EINVAL;
1736 goto err_undo_flags;
1737 }
1738 1721
1739 if ((bond->params.mode == BOND_MODE_8023AD) || 1722 res = -EOPNOTSUPP;
1740 (bond->params.mode == BOND_MODE_TLB) || 1723 goto err_undo_flags;
1741 (bond->params.mode == BOND_MODE_ALB)) {
1742 printk(KERN_ERR DRV_NAME
1743 ": Error: to use %s mode, you must upgrade "
1744 "ifenslave.\n",
1745 bond_mode_name(bond->params.mode));
1746 res = -EOPNOTSUPP;
1747 goto err_undo_flags;
1748 }
1749 } 1724 }
1750 1725
1751 new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL); 1726 new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
@@ -1761,41 +1736,36 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1761 */ 1736 */
1762 new_slave->original_flags = slave_dev->flags; 1737 new_slave->original_flags = slave_dev->flags;
1763 1738
1764 if (app_abi_ver >= 1) { 1739 /*
1765 /* save slave's original ("permanent") mac address for 1740 * Save slave's original ("permanent") mac address for modes
1766 * modes that needs it, and for restoring it upon release, 1741 * that need it, and for restoring it upon release, and then
1767 * and then set it to the master's address 1742 * set it to the master's address
1768 */ 1743 */
1769 memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN); 1744 memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN);
1770 1745
1771 /* set slave to master's mac address 1746 /*
1772 * The application already set the master's 1747 * Set slave to master's mac address. The application already
1773 * mac address to that of the first slave 1748 * set the master's mac address to that of the first slave
1774 */ 1749 */
1775 memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); 1750 memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len);
1776 addr.sa_family = slave_dev->type; 1751 addr.sa_family = slave_dev->type;
1777 res = dev_set_mac_address(slave_dev, &addr); 1752 res = dev_set_mac_address(slave_dev, &addr);
1778 if (res) { 1753 if (res) {
1779 dprintk("Error %d calling set_mac_address\n", res); 1754 dprintk("Error %d calling set_mac_address\n", res);
1780 goto err_free; 1755 goto err_free;
1781 } 1756 }
1782 1757
1783 /* open the slave since the application closed it */ 1758 /* open the slave since the application closed it */
1784 res = dev_open(slave_dev); 1759 res = dev_open(slave_dev);
1785 if (res) { 1760 if (res) {
1786 dprintk("Openning slave %s failed\n", slave_dev->name); 1761 dprintk("Openning slave %s failed\n", slave_dev->name);
1787 goto err_restore_mac; 1762 goto err_restore_mac;
1788 }
1789 } 1763 }
1790 1764
1791 res = netdev_set_master(slave_dev, bond_dev); 1765 res = netdev_set_master(slave_dev, bond_dev);
1792 if (res) { 1766 if (res) {
1793 dprintk("Error %d calling netdev_set_master\n", res); 1767 dprintk("Error %d calling netdev_set_master\n", res);
1794 if (app_abi_ver < 1) { 1768 goto err_close;
1795 goto err_free;
1796 } else {
1797 goto err_close;
1798 }
1799 } 1769 }
1800 1770
1801 new_slave->dev = slave_dev; 1771 new_slave->dev = slave_dev;
@@ -1996,39 +1966,6 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1996 1966
1997 write_unlock_bh(&bond->lock); 1967 write_unlock_bh(&bond->lock);
1998 1968
1999 if (app_abi_ver < 1) {
2000 /*
2001 * !!! This is to support old versions of ifenslave.
2002 * We can remove this in 2.5 because our ifenslave takes
2003 * care of this for us.
2004 * We check to see if the master has a mac address yet.
2005 * If not, we'll give it the mac address of our slave device.
2006 */
2007 int ndx = 0;
2008
2009 for (ndx = 0; ndx < bond_dev->addr_len; ndx++) {
2010 dprintk("Checking ndx=%d of bond_dev->dev_addr\n",
2011 ndx);
2012 if (bond_dev->dev_addr[ndx] != 0) {
2013 dprintk("Found non-zero byte at ndx=%d\n",
2014 ndx);
2015 break;
2016 }
2017 }
2018
2019 if (ndx == bond_dev->addr_len) {
2020 /*
2021 * We got all the way through the address and it was
2022 * all 0's.
2023 */
2024 dprintk("%s doesn't have a MAC address yet. \n",
2025 bond_dev->name);
2026 dprintk("Going to give assign it from %s.\n",
2027 slave_dev->name);
2028 bond_sethwaddr(bond_dev, slave_dev);
2029 }
2030 }
2031
2032 printk(KERN_INFO DRV_NAME 1969 printk(KERN_INFO DRV_NAME
2033 ": %s: enslaving %s as a%s interface with a%s link.\n", 1970 ": %s: enslaving %s as a%s interface with a%s link.\n",
2034 bond_dev->name, slave_dev->name, 1971 bond_dev->name, slave_dev->name,
@@ -2226,12 +2163,10 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de
2226 /* close slave before restoring its mac address */ 2163 /* close slave before restoring its mac address */
2227 dev_close(slave_dev); 2164 dev_close(slave_dev);
2228 2165
2229 if (app_abi_ver >= 1) { 2166 /* restore original ("permanent") mac address */
2230 /* restore original ("permanent") mac address */ 2167 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
2231 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN); 2168 addr.sa_family = slave_dev->type;
2232 addr.sa_family = slave_dev->type; 2169 dev_set_mac_address(slave_dev, &addr);
2233 dev_set_mac_address(slave_dev, &addr);
2234 }
2235 2170
2236 /* restore the original state of the 2171 /* restore the original state of the
2237 * IFF_NOARP flag that might have been 2172 * IFF_NOARP flag that might have been
@@ -2319,12 +2254,10 @@ static int bond_release_all(struct net_device *bond_dev)
2319 /* close slave before restoring its mac address */ 2254 /* close slave before restoring its mac address */
2320 dev_close(slave_dev); 2255 dev_close(slave_dev);
2321 2256
2322 if (app_abi_ver >= 1) { 2257 /* restore original ("permanent") mac address*/
2323 /* restore original ("permanent") mac address*/ 2258 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
2324 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN); 2259 addr.sa_family = slave_dev->type;
2325 addr.sa_family = slave_dev->type; 2260 dev_set_mac_address(slave_dev, &addr);
2326 dev_set_mac_address(slave_dev, &addr);
2327 }
2328 2261
2329 /* restore the original state of the IFF_NOARP flag that might have 2262 /* restore the original state of the IFF_NOARP flag that might have
2330 * been set by bond_set_slave_inactive_flags() 2263 * been set by bond_set_slave_inactive_flags()
@@ -2422,57 +2355,6 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
2422 return res; 2355 return res;
2423} 2356}
2424 2357
2425static int bond_ethtool_ioctl(struct net_device *bond_dev, struct ifreq *ifr)
2426{
2427 struct ethtool_drvinfo info;
2428 void __user *addr = ifr->ifr_data;
2429 uint32_t cmd;
2430
2431 if (get_user(cmd, (uint32_t __user *)addr)) {
2432 return -EFAULT;
2433 }
2434
2435 switch (cmd) {
2436 case ETHTOOL_GDRVINFO:
2437 if (copy_from_user(&info, addr, sizeof(info))) {
2438 return -EFAULT;
2439 }
2440
2441 if (strcmp(info.driver, "ifenslave") == 0) {
2442 int new_abi_ver;
2443 char *endptr;
2444
2445 new_abi_ver = simple_strtoul(info.fw_version,
2446 &endptr, 0);
2447 if (*endptr) {
2448 printk(KERN_ERR DRV_NAME
2449 ": Error: got invalid ABI "
2450 "version from application\n");
2451
2452 return -EINVAL;
2453 }
2454
2455 if (orig_app_abi_ver == -1) {
2456 orig_app_abi_ver = new_abi_ver;
2457 }
2458
2459 app_abi_ver = new_abi_ver;
2460 }
2461
2462 strncpy(info.driver, DRV_NAME, 32);
2463 strncpy(info.version, DRV_VERSION, 32);
2464 snprintf(info.fw_version, 32, "%d", BOND_ABI_VERSION);
2465
2466 if (copy_to_user(addr, &info, sizeof(info))) {
2467 return -EFAULT;
2468 }
2469
2470 return 0;
2471 default:
2472 return -EOPNOTSUPP;
2473 }
2474}
2475
2476static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) 2358static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
2477{ 2359{
2478 struct bonding *bond = bond_dev->priv; 2360 struct bonding *bond = bond_dev->priv;
@@ -2775,7 +2657,7 @@ static u32 bond_glean_dev_ip(struct net_device *dev)
2775 return 0; 2657 return 0;
2776 2658
2777 rcu_read_lock(); 2659 rcu_read_lock();
2778 idev = __in_dev_get(dev); 2660 idev = __in_dev_get_rcu(dev);
2779 if (!idev) 2661 if (!idev)
2780 goto out; 2662 goto out;
2781 2663
@@ -3441,16 +3323,11 @@ static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave
3441 seq_printf(seq, "Link Failure Count: %d\n", 3323 seq_printf(seq, "Link Failure Count: %d\n",
3442 slave->link_failure_count); 3324 slave->link_failure_count);
3443 3325
3444 if (app_abi_ver >= 1) { 3326 seq_printf(seq,
3445 seq_printf(seq, 3327 "Permanent HW addr: %02x:%02x:%02x:%02x:%02x:%02x\n",
3446 "Permanent HW addr: %02x:%02x:%02x:%02x:%02x:%02x\n", 3328 slave->perm_hwaddr[0], slave->perm_hwaddr[1],
3447 slave->perm_hwaddr[0], 3329 slave->perm_hwaddr[2], slave->perm_hwaddr[3],
3448 slave->perm_hwaddr[1], 3330 slave->perm_hwaddr[4], slave->perm_hwaddr[5]);
3449 slave->perm_hwaddr[2],
3450 slave->perm_hwaddr[3],
3451 slave->perm_hwaddr[4],
3452 slave->perm_hwaddr[5]);
3453 }
3454 3331
3455 if (bond->params.mode == BOND_MODE_8023AD) { 3332 if (bond->params.mode == BOND_MODE_8023AD) {
3456 const struct aggregator *agg 3333 const struct aggregator *agg
@@ -4009,15 +3886,12 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4009 struct ifslave k_sinfo; 3886 struct ifslave k_sinfo;
4010 struct ifslave __user *u_sinfo = NULL; 3887 struct ifslave __user *u_sinfo = NULL;
4011 struct mii_ioctl_data *mii = NULL; 3888 struct mii_ioctl_data *mii = NULL;
4012 int prev_abi_ver = orig_app_abi_ver;
4013 int res = 0; 3889 int res = 0;
4014 3890
4015 dprintk("bond_ioctl: master=%s, cmd=%d\n", 3891 dprintk("bond_ioctl: master=%s, cmd=%d\n",
4016 bond_dev->name, cmd); 3892 bond_dev->name, cmd);
4017 3893
4018 switch (cmd) { 3894 switch (cmd) {
4019 case SIOCETHTOOL:
4020 return bond_ethtool_ioctl(bond_dev, ifr);
4021 case SIOCGMIIPHY: 3895 case SIOCGMIIPHY:
4022 mii = if_mii(ifr); 3896 mii = if_mii(ifr);
4023 if (!mii) { 3897 if (!mii) {
@@ -4089,21 +3963,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4089 return -EPERM; 3963 return -EPERM;
4090 } 3964 }
4091 3965
4092 if (orig_app_abi_ver == -1) {
4093 /* no orig_app_abi_ver was provided yet, so we'll use the
4094 * current one from now on, even if it's 0
4095 */
4096 orig_app_abi_ver = app_abi_ver;
4097
4098 } else if (orig_app_abi_ver != app_abi_ver) {
4099 printk(KERN_ERR DRV_NAME
4100 ": Error: already using ifenslave ABI version %d; to "
4101 "upgrade ifenslave to version %d, you must first "
4102 "reload bonding.\n",
4103 orig_app_abi_ver, app_abi_ver);
4104 return -EINVAL;
4105 }
4106
4107 slave_dev = dev_get_by_name(ifr->ifr_slave); 3966 slave_dev = dev_get_by_name(ifr->ifr_slave);
4108 3967
4109 dprintk("slave_dev=%p: \n", slave_dev); 3968 dprintk("slave_dev=%p: \n", slave_dev);
@@ -4136,14 +3995,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
4136 dev_put(slave_dev); 3995 dev_put(slave_dev);
4137 } 3996 }
4138 3997
4139 if (res < 0) {
4140 /* The ioctl failed, so there's no point in changing the
4141 * orig_app_abi_ver. We'll restore it's value just in case
4142 * we've changed it earlier in this function.
4143 */
4144 orig_app_abi_ver = prev_abi_ver;
4145 }
4146
4147 return res; 3998 return res;
4148} 3999}
4149 4000
@@ -4577,9 +4428,18 @@ static inline void bond_set_mode_ops(struct bonding *bond, int mode)
4577 } 4428 }
4578} 4429}
4579 4430
4431static void bond_ethtool_get_drvinfo(struct net_device *bond_dev,
4432 struct ethtool_drvinfo *drvinfo)
4433{
4434 strncpy(drvinfo->driver, DRV_NAME, 32);
4435 strncpy(drvinfo->version, DRV_VERSION, 32);
4436 snprintf(drvinfo->fw_version, 32, "%d", BOND_ABI_VERSION);
4437}
4438
4580static struct ethtool_ops bond_ethtool_ops = { 4439static struct ethtool_ops bond_ethtool_ops = {
4581 .get_tx_csum = ethtool_op_get_tx_csum, 4440 .get_tx_csum = ethtool_op_get_tx_csum,
4582 .get_sg = ethtool_op_get_sg, 4441 .get_sg = ethtool_op_get_sg,
4442 .get_drvinfo = bond_ethtool_get_drvinfo,
4583}; 4443};
4584 4444
4585/* 4445/*
@@ -5039,6 +4899,14 @@ static int __init bonding_init(void)
5039 return 0; 4899 return 0;
5040 4900
5041out_err: 4901out_err:
4902 /*
4903 * rtnl_unlock() will run netdev_run_todo(), putting the
4904 * thus-far-registered bonding devices into a state which
4905 * unregigister_netdevice() will accept
4906 */
4907 rtnl_unlock();
4908 rtnl_lock();
4909
5042 /* free and unregister all bonds that were successfully added */ 4910 /* free and unregister all bonds that were successfully added */
5043 bond_free_all(); 4911 bond_free_all();
5044 4912
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 388196980862..bbf9da8af624 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -40,8 +40,8 @@
40#include "bond_3ad.h" 40#include "bond_3ad.h"
41#include "bond_alb.h" 41#include "bond_alb.h"
42 42
43#define DRV_VERSION "2.6.3" 43#define DRV_VERSION "2.6.4"
44#define DRV_RELDATE "June 8, 2005" 44#define DRV_RELDATE "September 26, 2005"
45#define DRV_NAME "bonding" 45#define DRV_NAME "bonding"
46#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 46#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
47 47
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
new file mode 100644
index 000000000000..2e617424d3fb
--- /dev/null
+++ b/drivers/net/cassini.c
@@ -0,0 +1,5237 @@
1/* cassini.c: Sun Microsystems Cassini(+) ethernet driver.
2 *
3 * Copyright (C) 2004 Sun Microsystems Inc.
4 * Copyright (C) 2003 Adrian Sun (asun@darksunrising.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 *
21 * This driver uses the sungem driver (c) David Miller
22 * (davem@redhat.com) as its basis.
23 *
24 * The cassini chip has a number of features that distinguish it from
25 * the gem chip:
26 * 4 transmit descriptor rings that are used for either QoS (VLAN) or
27 * load balancing (non-VLAN mode)
28 * batching of multiple packets
29 * multiple CPU dispatching
30 * page-based RX descriptor engine with separate completion rings
31 * Gigabit support (GMII and PCS interface)
32 * MIF link up/down detection works
33 *
34 * RX is handled by page sized buffers that are attached as fragments to
35 * the skb. here's what's done:
36 * -- driver allocates pages at a time and keeps reference counts
37 * on them.
38 * -- the upper protocol layers assume that the header is in the skb
39 * itself. as a result, cassini will copy a small amount (64 bytes)
40 * to make them happy.
41 * -- driver appends the rest of the data pages as frags to skbuffs
42 * and increments the reference count
43 * -- on page reclamation, the driver swaps the page with a spare page.
44 * if that page is still in use, it frees its reference to that page,
45 * and allocates a new page for use. otherwise, it just recycles the
46 * the page.
47 *
48 * NOTE: cassini can parse the header. however, it's not worth it
49 * as long as the network stack requires a header copy.
50 *
51 * TX has 4 queues. currently these queues are used in a round-robin
52 * fashion for load balancing. They can also be used for QoS. for that
53 * to work, however, QoS information needs to be exposed down to the driver
54 * level so that subqueues get targetted to particular transmit rings.
55 * alternatively, the queues can be configured via use of the all-purpose
56 * ioctl.
57 *
58 * RX DATA: the rx completion ring has all the info, but the rx desc
59 * ring has all of the data. RX can conceivably come in under multiple
60 * interrupts, but the INT# assignment needs to be set up properly by
61 * the BIOS and conveyed to the driver. PCI BIOSes don't know how to do
62 * that. also, the two descriptor rings are designed to distinguish between
63 * encrypted and non-encrypted packets, but we use them for buffering
64 * instead.
65 *
66 * by default, the selective clear mask is set up to process rx packets.
67 */
68
69#include <linux/config.h>
70#include <linux/version.h>
71
72#include <linux/module.h>
73#include <linux/kernel.h>
74#include <linux/types.h>
75#include <linux/compiler.h>
76#include <linux/slab.h>
77#include <linux/delay.h>
78#include <linux/init.h>
79#include <linux/ioport.h>
80#include <linux/pci.h>
81#include <linux/mm.h>
82#include <linux/highmem.h>
83#include <linux/list.h>
84#include <linux/dma-mapping.h>
85
86#include <linux/netdevice.h>
87#include <linux/etherdevice.h>
88#include <linux/skbuff.h>
89#include <linux/ethtool.h>
90#include <linux/crc32.h>
91#include <linux/random.h>
92#include <linux/mii.h>
93#include <linux/ip.h>
94#include <linux/tcp.h>
95
96#include <net/checksum.h>
97
98#include <asm/atomic.h>
99#include <asm/system.h>
100#include <asm/io.h>
101#include <asm/byteorder.h>
102#include <asm/uaccess.h>
103
104#define cas_page_map(x) kmap_atomic((x), KM_SKB_DATA_SOFTIRQ)
105#define cas_page_unmap(x) kunmap_atomic((x), KM_SKB_DATA_SOFTIRQ)
106#define CAS_NCPUS num_online_cpus()
107
108#if defined(CONFIG_CASSINI_NAPI) && defined(HAVE_NETDEV_POLL)
109#define USE_NAPI
110#define cas_skb_release(x) netif_receive_skb(x)
111#else
112#define cas_skb_release(x) netif_rx(x)
113#endif
114
115/* select which firmware to use */
116#define USE_HP_WORKAROUND
117#define HP_WORKAROUND_DEFAULT /* select which firmware to use as default */
118#define CAS_HP_ALT_FIRMWARE cas_prog_null /* alternate firmware */
119
120#include "cassini.h"
121
122#define USE_TX_COMPWB /* use completion writeback registers */
123#define USE_CSMA_CD_PROTO /* standard CSMA/CD */
124#define USE_RX_BLANK /* hw interrupt mitigation */
125#undef USE_ENTROPY_DEV /* don't test for entropy device */
126
127/* NOTE: these aren't useable unless PCI interrupts can be assigned.
128 * also, we need to make cp->lock finer-grained.
129 */
130#undef USE_PCI_INTB
131#undef USE_PCI_INTC
132#undef USE_PCI_INTD
133#undef USE_QOS
134
135#undef USE_VPD_DEBUG /* debug vpd information if defined */
136
137/* rx processing options */
138#define USE_PAGE_ORDER /* specify to allocate large rx pages */
139#define RX_DONT_BATCH 0 /* if 1, don't batch flows */
140#define RX_COPY_ALWAYS 0 /* if 0, use frags */
141#define RX_COPY_MIN 64 /* copy a little to make upper layers happy */
142#undef RX_COUNT_BUFFERS /* define to calculate RX buffer stats */
143
144#define DRV_MODULE_NAME "cassini"
145#define PFX DRV_MODULE_NAME ": "
146#define DRV_MODULE_VERSION "1.4"
147#define DRV_MODULE_RELDATE "1 July 2004"
148
149#define CAS_DEF_MSG_ENABLE \
150 (NETIF_MSG_DRV | \
151 NETIF_MSG_PROBE | \
152 NETIF_MSG_LINK | \
153 NETIF_MSG_TIMER | \
154 NETIF_MSG_IFDOWN | \
155 NETIF_MSG_IFUP | \
156 NETIF_MSG_RX_ERR | \
157 NETIF_MSG_TX_ERR)
158
159/* length of time before we decide the hardware is borked,
160 * and dev->tx_timeout() should be called to fix the problem
161 */
162#define CAS_TX_TIMEOUT (HZ)
163#define CAS_LINK_TIMEOUT (22*HZ/10)
164#define CAS_LINK_FAST_TIMEOUT (1)
165
166/* timeout values for state changing. these specify the number
167 * of 10us delays to be used before giving up.
168 */
169#define STOP_TRIES_PHY 1000
170#define STOP_TRIES 5000
171
172/* specify a minimum frame size to deal with some fifo issues
173 * max mtu == 2 * page size - ethernet header - 64 - swivel =
174 * 2 * page_size - 0x50
175 */
176#define CAS_MIN_FRAME 97
177#define CAS_1000MB_MIN_FRAME 255
178#define CAS_MIN_MTU 60
179#define CAS_MAX_MTU min(((cp->page_size << 1) - 0x50), 9000)
180
181#if 1
182/*
183 * Eliminate these and use separate atomic counters for each, to
184 * avoid a race condition.
185 */
186#else
187#define CAS_RESET_MTU 1
188#define CAS_RESET_ALL 2
189#define CAS_RESET_SPARE 3
190#endif
191
192static char version[] __devinitdata =
193 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
194
195MODULE_AUTHOR("Adrian Sun (asun@darksunrising.com)");
196MODULE_DESCRIPTION("Sun Cassini(+) ethernet driver");
197MODULE_LICENSE("GPL");
198MODULE_PARM(cassini_debug, "i");
199MODULE_PARM_DESC(cassini_debug, "Cassini bitmapped debugging message enable value");
200MODULE_PARM(link_mode, "i");
201MODULE_PARM_DESC(link_mode, "default link mode");
202
203/*
204 * Work around for a PCS bug in which the link goes down due to the chip
205 * being confused and never showing a link status of "up."
206 */
207#define DEFAULT_LINKDOWN_TIMEOUT 5
208/*
209 * Value in seconds, for user input.
210 */
211static int linkdown_timeout = DEFAULT_LINKDOWN_TIMEOUT;
212MODULE_PARM(linkdown_timeout, "i");
213MODULE_PARM_DESC(linkdown_timeout,
214"min reset interval in sec. for PCS linkdown issue; disabled if not positive");
215
216/*
217 * value in 'ticks' (units used by jiffies). Set when we init the
218 * module because 'HZ' in actually a function call on some flavors of
219 * Linux. This will default to DEFAULT_LINKDOWN_TIMEOUT * HZ.
220 */
221static int link_transition_timeout;
222
223
224static int cassini_debug = -1; /* -1 == use CAS_DEF_MSG_ENABLE as value */
225static int link_mode;
226
227static u16 link_modes[] __devinitdata = {
228 BMCR_ANENABLE, /* 0 : autoneg */
229 0, /* 1 : 10bt half duplex */
230 BMCR_SPEED100, /* 2 : 100bt half duplex */
231 BMCR_FULLDPLX, /* 3 : 10bt full duplex */
232 BMCR_SPEED100|BMCR_FULLDPLX, /* 4 : 100bt full duplex */
233 CAS_BMCR_SPEED1000|BMCR_FULLDPLX /* 5 : 1000bt full duplex */
234};
235
236static struct pci_device_id cas_pci_tbl[] __devinitdata = {
237 { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_CASSINI,
238 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
239 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SATURN,
240 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
241 { 0, }
242};
243
244MODULE_DEVICE_TABLE(pci, cas_pci_tbl);
245
246static void cas_set_link_modes(struct cas *cp);
247
248static inline void cas_lock_tx(struct cas *cp)
249{
250 int i;
251
252 for (i = 0; i < N_TX_RINGS; i++)
253 spin_lock(&cp->tx_lock[i]);
254}
255
256static inline void cas_lock_all(struct cas *cp)
257{
258 spin_lock_irq(&cp->lock);
259 cas_lock_tx(cp);
260}
261
262/* WTZ: QA was finding deadlock problems with the previous
263 * versions after long test runs with multiple cards per machine.
264 * See if replacing cas_lock_all with safer versions helps. The
265 * symptoms QA is reporting match those we'd expect if interrupts
266 * aren't being properly restored, and we fixed a previous deadlock
267 * with similar symptoms by using save/restore versions in other
268 * places.
269 */
270#define cas_lock_all_save(cp, flags) \
271do { \
272 struct cas *xxxcp = (cp); \
273 spin_lock_irqsave(&xxxcp->lock, flags); \
274 cas_lock_tx(xxxcp); \
275} while (0)
276
277static inline void cas_unlock_tx(struct cas *cp)
278{
279 int i;
280
281 for (i = N_TX_RINGS; i > 0; i--)
282 spin_unlock(&cp->tx_lock[i - 1]);
283}
284
285static inline void cas_unlock_all(struct cas *cp)
286{
287 cas_unlock_tx(cp);
288 spin_unlock_irq(&cp->lock);
289}
290
291#define cas_unlock_all_restore(cp, flags) \
292do { \
293 struct cas *xxxcp = (cp); \
294 cas_unlock_tx(xxxcp); \
295 spin_unlock_irqrestore(&xxxcp->lock, flags); \
296} while (0)
297
298static void cas_disable_irq(struct cas *cp, const int ring)
299{
300 /* Make sure we won't get any more interrupts */
301 if (ring == 0) {
302 writel(0xFFFFFFFF, cp->regs + REG_INTR_MASK);
303 return;
304 }
305
306 /* disable completion interrupts and selectively mask */
307 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
308 switch (ring) {
309#if defined (USE_PCI_INTB) || defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
310#ifdef USE_PCI_INTB
311 case 1:
312#endif
313#ifdef USE_PCI_INTC
314 case 2:
315#endif
316#ifdef USE_PCI_INTD
317 case 3:
318#endif
319 writel(INTRN_MASK_CLEAR_ALL | INTRN_MASK_RX_EN,
320 cp->regs + REG_PLUS_INTRN_MASK(ring));
321 break;
322#endif
323 default:
324 writel(INTRN_MASK_CLEAR_ALL, cp->regs +
325 REG_PLUS_INTRN_MASK(ring));
326 break;
327 }
328 }
329}
330
331static inline void cas_mask_intr(struct cas *cp)
332{
333 int i;
334
335 for (i = 0; i < N_RX_COMP_RINGS; i++)
336 cas_disable_irq(cp, i);
337}
338
339static void cas_enable_irq(struct cas *cp, const int ring)
340{
341 if (ring == 0) { /* all but TX_DONE */
342 writel(INTR_TX_DONE, cp->regs + REG_INTR_MASK);
343 return;
344 }
345
346 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
347 switch (ring) {
348#if defined (USE_PCI_INTB) || defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
349#ifdef USE_PCI_INTB
350 case 1:
351#endif
352#ifdef USE_PCI_INTC
353 case 2:
354#endif
355#ifdef USE_PCI_INTD
356 case 3:
357#endif
358 writel(INTRN_MASK_RX_EN, cp->regs +
359 REG_PLUS_INTRN_MASK(ring));
360 break;
361#endif
362 default:
363 break;
364 }
365 }
366}
367
368static inline void cas_unmask_intr(struct cas *cp)
369{
370 int i;
371
372 for (i = 0; i < N_RX_COMP_RINGS; i++)
373 cas_enable_irq(cp, i);
374}
375
376static inline void cas_entropy_gather(struct cas *cp)
377{
378#ifdef USE_ENTROPY_DEV
379 if ((cp->cas_flags & CAS_FLAG_ENTROPY_DEV) == 0)
380 return;
381
382 batch_entropy_store(readl(cp->regs + REG_ENTROPY_IV),
383 readl(cp->regs + REG_ENTROPY_IV),
384 sizeof(uint64_t)*8);
385#endif
386}
387
388static inline void cas_entropy_reset(struct cas *cp)
389{
390#ifdef USE_ENTROPY_DEV
391 if ((cp->cas_flags & CAS_FLAG_ENTROPY_DEV) == 0)
392 return;
393
394 writel(BIM_LOCAL_DEV_PAD | BIM_LOCAL_DEV_PROM | BIM_LOCAL_DEV_EXT,
395 cp->regs + REG_BIM_LOCAL_DEV_EN);
396 writeb(ENTROPY_RESET_STC_MODE, cp->regs + REG_ENTROPY_RESET);
397 writeb(0x55, cp->regs + REG_ENTROPY_RAND_REG);
398
399 /* if we read back 0x0, we don't have an entropy device */
400 if (readb(cp->regs + REG_ENTROPY_RAND_REG) == 0)
401 cp->cas_flags &= ~CAS_FLAG_ENTROPY_DEV;
402#endif
403}
404
405/* access to the phy. the following assumes that we've initialized the MIF to
406 * be in frame rather than bit-bang mode
407 */
408static u16 cas_phy_read(struct cas *cp, int reg)
409{
410 u32 cmd;
411 int limit = STOP_TRIES_PHY;
412
413 cmd = MIF_FRAME_ST | MIF_FRAME_OP_READ;
414 cmd |= CAS_BASE(MIF_FRAME_PHY_ADDR, cp->phy_addr);
415 cmd |= CAS_BASE(MIF_FRAME_REG_ADDR, reg);
416 cmd |= MIF_FRAME_TURN_AROUND_MSB;
417 writel(cmd, cp->regs + REG_MIF_FRAME);
418
419 /* poll for completion */
420 while (limit-- > 0) {
421 udelay(10);
422 cmd = readl(cp->regs + REG_MIF_FRAME);
423 if (cmd & MIF_FRAME_TURN_AROUND_LSB)
424 return (cmd & MIF_FRAME_DATA_MASK);
425 }
426 return 0xFFFF; /* -1 */
427}
428
429static int cas_phy_write(struct cas *cp, int reg, u16 val)
430{
431 int limit = STOP_TRIES_PHY;
432 u32 cmd;
433
434 cmd = MIF_FRAME_ST | MIF_FRAME_OP_WRITE;
435 cmd |= CAS_BASE(MIF_FRAME_PHY_ADDR, cp->phy_addr);
436 cmd |= CAS_BASE(MIF_FRAME_REG_ADDR, reg);
437 cmd |= MIF_FRAME_TURN_AROUND_MSB;
438 cmd |= val & MIF_FRAME_DATA_MASK;
439 writel(cmd, cp->regs + REG_MIF_FRAME);
440
441 /* poll for completion */
442 while (limit-- > 0) {
443 udelay(10);
444 cmd = readl(cp->regs + REG_MIF_FRAME);
445 if (cmd & MIF_FRAME_TURN_AROUND_LSB)
446 return 0;
447 }
448 return -1;
449}
450
451static void cas_phy_powerup(struct cas *cp)
452{
453 u16 ctl = cas_phy_read(cp, MII_BMCR);
454
455 if ((ctl & BMCR_PDOWN) == 0)
456 return;
457 ctl &= ~BMCR_PDOWN;
458 cas_phy_write(cp, MII_BMCR, ctl);
459}
460
461static void cas_phy_powerdown(struct cas *cp)
462{
463 u16 ctl = cas_phy_read(cp, MII_BMCR);
464
465 if (ctl & BMCR_PDOWN)
466 return;
467 ctl |= BMCR_PDOWN;
468 cas_phy_write(cp, MII_BMCR, ctl);
469}
470
471/* cp->lock held. note: the last put_page will free the buffer */
472static int cas_page_free(struct cas *cp, cas_page_t *page)
473{
474 pci_unmap_page(cp->pdev, page->dma_addr, cp->page_size,
475 PCI_DMA_FROMDEVICE);
476 __free_pages(page->buffer, cp->page_order);
477 kfree(page);
478 return 0;
479}
480
481#ifdef RX_COUNT_BUFFERS
482#define RX_USED_ADD(x, y) ((x)->used += (y))
483#define RX_USED_SET(x, y) ((x)->used = (y))
484#else
485#define RX_USED_ADD(x, y)
486#define RX_USED_SET(x, y)
487#endif
488
489/* local page allocation routines for the receive buffers. jumbo pages
490 * require at least 8K contiguous and 8K aligned buffers.
491 */
492static cas_page_t *cas_page_alloc(struct cas *cp, const int flags)
493{
494 cas_page_t *page;
495
496 page = kmalloc(sizeof(cas_page_t), flags);
497 if (!page)
498 return NULL;
499
500 INIT_LIST_HEAD(&page->list);
501 RX_USED_SET(page, 0);
502 page->buffer = alloc_pages(flags, cp->page_order);
503 if (!page->buffer)
504 goto page_err;
505 page->dma_addr = pci_map_page(cp->pdev, page->buffer, 0,
506 cp->page_size, PCI_DMA_FROMDEVICE);
507 return page;
508
509page_err:
510 kfree(page);
511 return NULL;
512}
513
514/* initialize spare pool of rx buffers, but allocate during the open */
515static void cas_spare_init(struct cas *cp)
516{
517 spin_lock(&cp->rx_inuse_lock);
518 INIT_LIST_HEAD(&cp->rx_inuse_list);
519 spin_unlock(&cp->rx_inuse_lock);
520
521 spin_lock(&cp->rx_spare_lock);
522 INIT_LIST_HEAD(&cp->rx_spare_list);
523 cp->rx_spares_needed = RX_SPARE_COUNT;
524 spin_unlock(&cp->rx_spare_lock);
525}
526
527/* used on close. free all the spare buffers. */
528static void cas_spare_free(struct cas *cp)
529{
530 struct list_head list, *elem, *tmp;
531
532 /* free spare buffers */
533 INIT_LIST_HEAD(&list);
534 spin_lock(&cp->rx_spare_lock);
535 list_splice(&cp->rx_spare_list, &list);
536 INIT_LIST_HEAD(&cp->rx_spare_list);
537 spin_unlock(&cp->rx_spare_lock);
538 list_for_each_safe(elem, tmp, &list) {
539 cas_page_free(cp, list_entry(elem, cas_page_t, list));
540 }
541
542 INIT_LIST_HEAD(&list);
543#if 1
544 /*
545 * Looks like Adrian had protected this with a different
546 * lock than used everywhere else to manipulate this list.
547 */
548 spin_lock(&cp->rx_inuse_lock);
549 list_splice(&cp->rx_inuse_list, &list);
550 INIT_LIST_HEAD(&cp->rx_inuse_list);
551 spin_unlock(&cp->rx_inuse_lock);
552#else
553 spin_lock(&cp->rx_spare_lock);
554 list_splice(&cp->rx_inuse_list, &list);
555 INIT_LIST_HEAD(&cp->rx_inuse_list);
556 spin_unlock(&cp->rx_spare_lock);
557#endif
558 list_for_each_safe(elem, tmp, &list) {
559 cas_page_free(cp, list_entry(elem, cas_page_t, list));
560 }
561}
562
563/* replenish spares if needed */
564static void cas_spare_recover(struct cas *cp, const int flags)
565{
566 struct list_head list, *elem, *tmp;
567 int needed, i;
568
569 /* check inuse list. if we don't need any more free buffers,
570 * just free it
571 */
572
573 /* make a local copy of the list */
574 INIT_LIST_HEAD(&list);
575 spin_lock(&cp->rx_inuse_lock);
576 list_splice(&cp->rx_inuse_list, &list);
577 INIT_LIST_HEAD(&cp->rx_inuse_list);
578 spin_unlock(&cp->rx_inuse_lock);
579
580 list_for_each_safe(elem, tmp, &list) {
581 cas_page_t *page = list_entry(elem, cas_page_t, list);
582
583 if (page_count(page->buffer) > 1)
584 continue;
585
586 list_del(elem);
587 spin_lock(&cp->rx_spare_lock);
588 if (cp->rx_spares_needed > 0) {
589 list_add(elem, &cp->rx_spare_list);
590 cp->rx_spares_needed--;
591 spin_unlock(&cp->rx_spare_lock);
592 } else {
593 spin_unlock(&cp->rx_spare_lock);
594 cas_page_free(cp, page);
595 }
596 }
597
598 /* put any inuse buffers back on the list */
599 if (!list_empty(&list)) {
600 spin_lock(&cp->rx_inuse_lock);
601 list_splice(&list, &cp->rx_inuse_list);
602 spin_unlock(&cp->rx_inuse_lock);
603 }
604
605 spin_lock(&cp->rx_spare_lock);
606 needed = cp->rx_spares_needed;
607 spin_unlock(&cp->rx_spare_lock);
608 if (!needed)
609 return;
610
611 /* we still need spares, so try to allocate some */
612 INIT_LIST_HEAD(&list);
613 i = 0;
614 while (i < needed) {
615 cas_page_t *spare = cas_page_alloc(cp, flags);
616 if (!spare)
617 break;
618 list_add(&spare->list, &list);
619 i++;
620 }
621
622 spin_lock(&cp->rx_spare_lock);
623 list_splice(&list, &cp->rx_spare_list);
624 cp->rx_spares_needed -= i;
625 spin_unlock(&cp->rx_spare_lock);
626}
627
628/* pull a page from the list. */
629static cas_page_t *cas_page_dequeue(struct cas *cp)
630{
631 struct list_head *entry;
632 int recover;
633
634 spin_lock(&cp->rx_spare_lock);
635 if (list_empty(&cp->rx_spare_list)) {
636 /* try to do a quick recovery */
637 spin_unlock(&cp->rx_spare_lock);
638 cas_spare_recover(cp, GFP_ATOMIC);
639 spin_lock(&cp->rx_spare_lock);
640 if (list_empty(&cp->rx_spare_list)) {
641 if (netif_msg_rx_err(cp))
642 printk(KERN_ERR "%s: no spare buffers "
643 "available.\n", cp->dev->name);
644 spin_unlock(&cp->rx_spare_lock);
645 return NULL;
646 }
647 }
648
649 entry = cp->rx_spare_list.next;
650 list_del(entry);
651 recover = ++cp->rx_spares_needed;
652 spin_unlock(&cp->rx_spare_lock);
653
654 /* trigger the timer to do the recovery */
655 if ((recover & (RX_SPARE_RECOVER_VAL - 1)) == 0) {
656#if 1
657 atomic_inc(&cp->reset_task_pending);
658 atomic_inc(&cp->reset_task_pending_spare);
659 schedule_work(&cp->reset_task);
660#else
661 atomic_set(&cp->reset_task_pending, CAS_RESET_SPARE);
662 schedule_work(&cp->reset_task);
663#endif
664 }
665 return list_entry(entry, cas_page_t, list);
666}
667
668
669static void cas_mif_poll(struct cas *cp, const int enable)
670{
671 u32 cfg;
672
673 cfg = readl(cp->regs + REG_MIF_CFG);
674 cfg &= (MIF_CFG_MDIO_0 | MIF_CFG_MDIO_1);
675
676 if (cp->phy_type & CAS_PHY_MII_MDIO1)
677 cfg |= MIF_CFG_PHY_SELECT;
678
679 /* poll and interrupt on link status change. */
680 if (enable) {
681 cfg |= MIF_CFG_POLL_EN;
682 cfg |= CAS_BASE(MIF_CFG_POLL_REG, MII_BMSR);
683 cfg |= CAS_BASE(MIF_CFG_POLL_PHY, cp->phy_addr);
684 }
685 writel((enable) ? ~(BMSR_LSTATUS | BMSR_ANEGCOMPLETE) : 0xFFFF,
686 cp->regs + REG_MIF_MASK);
687 writel(cfg, cp->regs + REG_MIF_CFG);
688}
689
690/* Must be invoked under cp->lock */
691static void cas_begin_auto_negotiation(struct cas *cp, struct ethtool_cmd *ep)
692{
693 u16 ctl;
694#if 1
695 int lcntl;
696 int changed = 0;
697 int oldstate = cp->lstate;
698 int link_was_not_down = !(oldstate == link_down);
699#endif
700 /* Setup link parameters */
701 if (!ep)
702 goto start_aneg;
703 lcntl = cp->link_cntl;
704 if (ep->autoneg == AUTONEG_ENABLE)
705 cp->link_cntl = BMCR_ANENABLE;
706 else {
707 cp->link_cntl = 0;
708 if (ep->speed == SPEED_100)
709 cp->link_cntl |= BMCR_SPEED100;
710 else if (ep->speed == SPEED_1000)
711 cp->link_cntl |= CAS_BMCR_SPEED1000;
712 if (ep->duplex == DUPLEX_FULL)
713 cp->link_cntl |= BMCR_FULLDPLX;
714 }
715#if 1
716 changed = (lcntl != cp->link_cntl);
717#endif
718start_aneg:
719 if (cp->lstate == link_up) {
720 printk(KERN_INFO "%s: PCS link down.\n",
721 cp->dev->name);
722 } else {
723 if (changed) {
724 printk(KERN_INFO "%s: link configuration changed\n",
725 cp->dev->name);
726 }
727 }
728 cp->lstate = link_down;
729 cp->link_transition = LINK_TRANSITION_LINK_DOWN;
730 if (!cp->hw_running)
731 return;
732#if 1
733 /*
734 * WTZ: If the old state was link_up, we turn off the carrier
735 * to replicate everything we do elsewhere on a link-down
736 * event when we were already in a link-up state..
737 */
738 if (oldstate == link_up)
739 netif_carrier_off(cp->dev);
740 if (changed && link_was_not_down) {
741 /*
742 * WTZ: This branch will simply schedule a full reset after
743 * we explicitly changed link modes in an ioctl. See if this
744 * fixes the link-problems we were having for forced mode.
745 */
746 atomic_inc(&cp->reset_task_pending);
747 atomic_inc(&cp->reset_task_pending_all);
748 schedule_work(&cp->reset_task);
749 cp->timer_ticks = 0;
750 mod_timer(&cp->link_timer, jiffies + CAS_LINK_TIMEOUT);
751 return;
752 }
753#endif
754 if (cp->phy_type & CAS_PHY_SERDES) {
755 u32 val = readl(cp->regs + REG_PCS_MII_CTRL);
756
757 if (cp->link_cntl & BMCR_ANENABLE) {
758 val |= (PCS_MII_RESTART_AUTONEG | PCS_MII_AUTONEG_EN);
759 cp->lstate = link_aneg;
760 } else {
761 if (cp->link_cntl & BMCR_FULLDPLX)
762 val |= PCS_MII_CTRL_DUPLEX;
763 val &= ~PCS_MII_AUTONEG_EN;
764 cp->lstate = link_force_ok;
765 }
766 cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
767 writel(val, cp->regs + REG_PCS_MII_CTRL);
768
769 } else {
770 cas_mif_poll(cp, 0);
771 ctl = cas_phy_read(cp, MII_BMCR);
772 ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 |
773 CAS_BMCR_SPEED1000 | BMCR_ANENABLE);
774 ctl |= cp->link_cntl;
775 if (ctl & BMCR_ANENABLE) {
776 ctl |= BMCR_ANRESTART;
777 cp->lstate = link_aneg;
778 } else {
779 cp->lstate = link_force_ok;
780 }
781 cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
782 cas_phy_write(cp, MII_BMCR, ctl);
783 cas_mif_poll(cp, 1);
784 }
785
786 cp->timer_ticks = 0;
787 mod_timer(&cp->link_timer, jiffies + CAS_LINK_TIMEOUT);
788}
789
790/* Must be invoked under cp->lock. */
791static int cas_reset_mii_phy(struct cas *cp)
792{
793 int limit = STOP_TRIES_PHY;
794 u16 val;
795
796 cas_phy_write(cp, MII_BMCR, BMCR_RESET);
797 udelay(100);
798 while (limit--) {
799 val = cas_phy_read(cp, MII_BMCR);
800 if ((val & BMCR_RESET) == 0)
801 break;
802 udelay(10);
803 }
804 return (limit <= 0);
805}
806
807static void cas_saturn_firmware_load(struct cas *cp)
808{
809 cas_saturn_patch_t *patch = cas_saturn_patch;
810
811 cas_phy_powerdown(cp);
812
813 /* expanded memory access mode */
814 cas_phy_write(cp, DP83065_MII_MEM, 0x0);
815
816 /* pointer configuration for new firmware */
817 cas_phy_write(cp, DP83065_MII_REGE, 0x8ff9);
818 cas_phy_write(cp, DP83065_MII_REGD, 0xbd);
819 cas_phy_write(cp, DP83065_MII_REGE, 0x8ffa);
820 cas_phy_write(cp, DP83065_MII_REGD, 0x82);
821 cas_phy_write(cp, DP83065_MII_REGE, 0x8ffb);
822 cas_phy_write(cp, DP83065_MII_REGD, 0x0);
823 cas_phy_write(cp, DP83065_MII_REGE, 0x8ffc);
824 cas_phy_write(cp, DP83065_MII_REGD, 0x39);
825
826 /* download new firmware */
827 cas_phy_write(cp, DP83065_MII_MEM, 0x1);
828 cas_phy_write(cp, DP83065_MII_REGE, patch->addr);
829 while (patch->addr) {
830 cas_phy_write(cp, DP83065_MII_REGD, patch->val);
831 patch++;
832 }
833
834 /* enable firmware */
835 cas_phy_write(cp, DP83065_MII_REGE, 0x8ff8);
836 cas_phy_write(cp, DP83065_MII_REGD, 0x1);
837}
838
839
840/* phy initialization */
841static void cas_phy_init(struct cas *cp)
842{
843 u16 val;
844
845 /* if we're in MII/GMII mode, set up phy */
846 if (CAS_PHY_MII(cp->phy_type)) {
847 writel(PCS_DATAPATH_MODE_MII,
848 cp->regs + REG_PCS_DATAPATH_MODE);
849
850 cas_mif_poll(cp, 0);
851 cas_reset_mii_phy(cp); /* take out of isolate mode */
852
853 if (PHY_LUCENT_B0 == cp->phy_id) {
854 /* workaround link up/down issue with lucent */
855 cas_phy_write(cp, LUCENT_MII_REG, 0x8000);
856 cas_phy_write(cp, MII_BMCR, 0x00f1);
857 cas_phy_write(cp, LUCENT_MII_REG, 0x0);
858
859 } else if (PHY_BROADCOM_B0 == (cp->phy_id & 0xFFFFFFFC)) {
860 /* workarounds for broadcom phy */
861 cas_phy_write(cp, BROADCOM_MII_REG8, 0x0C20);
862 cas_phy_write(cp, BROADCOM_MII_REG7, 0x0012);
863 cas_phy_write(cp, BROADCOM_MII_REG5, 0x1804);
864 cas_phy_write(cp, BROADCOM_MII_REG7, 0x0013);
865 cas_phy_write(cp, BROADCOM_MII_REG5, 0x1204);
866 cas_phy_write(cp, BROADCOM_MII_REG7, 0x8006);
867 cas_phy_write(cp, BROADCOM_MII_REG5, 0x0132);
868 cas_phy_write(cp, BROADCOM_MII_REG7, 0x8006);
869 cas_phy_write(cp, BROADCOM_MII_REG5, 0x0232);
870 cas_phy_write(cp, BROADCOM_MII_REG7, 0x201F);
871 cas_phy_write(cp, BROADCOM_MII_REG5, 0x0A20);
872
873 } else if (PHY_BROADCOM_5411 == cp->phy_id) {
874 val = cas_phy_read(cp, BROADCOM_MII_REG4);
875 val = cas_phy_read(cp, BROADCOM_MII_REG4);
876 if (val & 0x0080) {
877 /* link workaround */
878 cas_phy_write(cp, BROADCOM_MII_REG4,
879 val & ~0x0080);
880 }
881
882 } else if (cp->cas_flags & CAS_FLAG_SATURN) {
883 writel((cp->phy_type & CAS_PHY_MII_MDIO0) ?
884 SATURN_PCFG_FSI : 0x0,
885 cp->regs + REG_SATURN_PCFG);
886
887 /* load firmware to address 10Mbps auto-negotiation
888 * issue. NOTE: this will need to be changed if the
889 * default firmware gets fixed.
890 */
891 if (PHY_NS_DP83065 == cp->phy_id) {
892 cas_saturn_firmware_load(cp);
893 }
894 cas_phy_powerup(cp);
895 }
896
897 /* advertise capabilities */
898 val = cas_phy_read(cp, MII_BMCR);
899 val &= ~BMCR_ANENABLE;
900 cas_phy_write(cp, MII_BMCR, val);
901 udelay(10);
902
903 cas_phy_write(cp, MII_ADVERTISE,
904 cas_phy_read(cp, MII_ADVERTISE) |
905 (ADVERTISE_10HALF | ADVERTISE_10FULL |
906 ADVERTISE_100HALF | ADVERTISE_100FULL |
907 CAS_ADVERTISE_PAUSE |
908 CAS_ADVERTISE_ASYM_PAUSE));
909
910 if (cp->cas_flags & CAS_FLAG_1000MB_CAP) {
911 /* make sure that we don't advertise half
912 * duplex to avoid a chip issue
913 */
914 val = cas_phy_read(cp, CAS_MII_1000_CTRL);
915 val &= ~CAS_ADVERTISE_1000HALF;
916 val |= CAS_ADVERTISE_1000FULL;
917 cas_phy_write(cp, CAS_MII_1000_CTRL, val);
918 }
919
920 } else {
921 /* reset pcs for serdes */
922 u32 val;
923 int limit;
924
925 writel(PCS_DATAPATH_MODE_SERDES,
926 cp->regs + REG_PCS_DATAPATH_MODE);
927
928 /* enable serdes pins on saturn */
929 if (cp->cas_flags & CAS_FLAG_SATURN)
930 writel(0, cp->regs + REG_SATURN_PCFG);
931
932 /* Reset PCS unit. */
933 val = readl(cp->regs + REG_PCS_MII_CTRL);
934 val |= PCS_MII_RESET;
935 writel(val, cp->regs + REG_PCS_MII_CTRL);
936
937 limit = STOP_TRIES;
938 while (limit-- > 0) {
939 udelay(10);
940 if ((readl(cp->regs + REG_PCS_MII_CTRL) &
941 PCS_MII_RESET) == 0)
942 break;
943 }
944 if (limit <= 0)
945 printk(KERN_WARNING "%s: PCS reset bit would not "
946 "clear [%08x].\n", cp->dev->name,
947 readl(cp->regs + REG_PCS_STATE_MACHINE));
948
949 /* Make sure PCS is disabled while changing advertisement
950 * configuration.
951 */
952 writel(0x0, cp->regs + REG_PCS_CFG);
953
954 /* Advertise all capabilities except half-duplex. */
955 val = readl(cp->regs + REG_PCS_MII_ADVERT);
956 val &= ~PCS_MII_ADVERT_HD;
957 val |= (PCS_MII_ADVERT_FD | PCS_MII_ADVERT_SYM_PAUSE |
958 PCS_MII_ADVERT_ASYM_PAUSE);
959 writel(val, cp->regs + REG_PCS_MII_ADVERT);
960
961 /* enable PCS */
962 writel(PCS_CFG_EN, cp->regs + REG_PCS_CFG);
963
964 /* pcs workaround: enable sync detect */
965 writel(PCS_SERDES_CTRL_SYNCD_EN,
966 cp->regs + REG_PCS_SERDES_CTRL);
967 }
968}
969
970
971static int cas_pcs_link_check(struct cas *cp)
972{
973 u32 stat, state_machine;
974 int retval = 0;
975
976 /* The link status bit latches on zero, so you must
977 * read it twice in such a case to see a transition
978 * to the link being up.
979 */
980 stat = readl(cp->regs + REG_PCS_MII_STATUS);
981 if ((stat & PCS_MII_STATUS_LINK_STATUS) == 0)
982 stat = readl(cp->regs + REG_PCS_MII_STATUS);
983
984 /* The remote-fault indication is only valid
985 * when autoneg has completed.
986 */
987 if ((stat & (PCS_MII_STATUS_AUTONEG_COMP |
988 PCS_MII_STATUS_REMOTE_FAULT)) ==
989 (PCS_MII_STATUS_AUTONEG_COMP | PCS_MII_STATUS_REMOTE_FAULT)) {
990 if (netif_msg_link(cp))
991 printk(KERN_INFO "%s: PCS RemoteFault\n",
992 cp->dev->name);
993 }
994
995 /* work around link detection issue by querying the PCS state
996 * machine directly.
997 */
998 state_machine = readl(cp->regs + REG_PCS_STATE_MACHINE);
999 if ((state_machine & PCS_SM_LINK_STATE_MASK) != SM_LINK_STATE_UP) {
1000 stat &= ~PCS_MII_STATUS_LINK_STATUS;
1001 } else if (state_machine & PCS_SM_WORD_SYNC_STATE_MASK) {
1002 stat |= PCS_MII_STATUS_LINK_STATUS;
1003 }
1004
1005 if (stat & PCS_MII_STATUS_LINK_STATUS) {
1006 if (cp->lstate != link_up) {
1007 if (cp->opened) {
1008 cp->lstate = link_up;
1009 cp->link_transition = LINK_TRANSITION_LINK_UP;
1010
1011 cas_set_link_modes(cp);
1012 netif_carrier_on(cp->dev);
1013 }
1014 }
1015 } else if (cp->lstate == link_up) {
1016 cp->lstate = link_down;
1017 if (link_transition_timeout != 0 &&
1018 cp->link_transition != LINK_TRANSITION_REQUESTED_RESET &&
1019 !cp->link_transition_jiffies_valid) {
1020 /*
1021 * force a reset, as a workaround for the
1022 * link-failure problem. May want to move this to a
1023 * point a bit earlier in the sequence. If we had
1024 * generated a reset a short time ago, we'll wait for
1025 * the link timer to check the status until a
1026 * timer expires (link_transistion_jiffies_valid is
1027 * true when the timer is running.) Instead of using
1028 * a system timer, we just do a check whenever the
1029 * link timer is running - this clears the flag after
1030 * a suitable delay.
1031 */
1032 retval = 1;
1033 cp->link_transition = LINK_TRANSITION_REQUESTED_RESET;
1034 cp->link_transition_jiffies = jiffies;
1035 cp->link_transition_jiffies_valid = 1;
1036 } else {
1037 cp->link_transition = LINK_TRANSITION_ON_FAILURE;
1038 }
1039 netif_carrier_off(cp->dev);
1040 if (cp->opened && netif_msg_link(cp)) {
1041 printk(KERN_INFO "%s: PCS link down.\n",
1042 cp->dev->name);
1043 }
1044
1045 /* Cassini only: if you force a mode, there can be
1046 * sync problems on link down. to fix that, the following
1047 * things need to be checked:
1048 * 1) read serialink state register
1049 * 2) read pcs status register to verify link down.
1050 * 3) if link down and serial link == 0x03, then you need
1051 * to global reset the chip.
1052 */
1053 if ((cp->cas_flags & CAS_FLAG_REG_PLUS) == 0) {
1054 /* should check to see if we're in a forced mode */
1055 stat = readl(cp->regs + REG_PCS_SERDES_STATE);
1056 if (stat == 0x03)
1057 return 1;
1058 }
1059 } else if (cp->lstate == link_down) {
1060 if (link_transition_timeout != 0 &&
1061 cp->link_transition != LINK_TRANSITION_REQUESTED_RESET &&
1062 !cp->link_transition_jiffies_valid) {
1063 /* force a reset, as a workaround for the
1064 * link-failure problem. May want to move
1065 * this to a point a bit earlier in the
1066 * sequence.
1067 */
1068 retval = 1;
1069 cp->link_transition = LINK_TRANSITION_REQUESTED_RESET;
1070 cp->link_transition_jiffies = jiffies;
1071 cp->link_transition_jiffies_valid = 1;
1072 } else {
1073 cp->link_transition = LINK_TRANSITION_STILL_FAILED;
1074 }
1075 }
1076
1077 return retval;
1078}
1079
1080static int cas_pcs_interrupt(struct net_device *dev,
1081 struct cas *cp, u32 status)
1082{
1083 u32 stat = readl(cp->regs + REG_PCS_INTR_STATUS);
1084
1085 if ((stat & PCS_INTR_STATUS_LINK_CHANGE) == 0)
1086 return 0;
1087 return cas_pcs_link_check(cp);
1088}
1089
1090static int cas_txmac_interrupt(struct net_device *dev,
1091 struct cas *cp, u32 status)
1092{
1093 u32 txmac_stat = readl(cp->regs + REG_MAC_TX_STATUS);
1094
1095 if (!txmac_stat)
1096 return 0;
1097
1098 if (netif_msg_intr(cp))
1099 printk(KERN_DEBUG "%s: txmac interrupt, txmac_stat: 0x%x\n",
1100 cp->dev->name, txmac_stat);
1101
1102 /* Defer timer expiration is quite normal,
1103 * don't even log the event.
1104 */
1105 if ((txmac_stat & MAC_TX_DEFER_TIMER) &&
1106 !(txmac_stat & ~MAC_TX_DEFER_TIMER))
1107 return 0;
1108
1109 spin_lock(&cp->stat_lock[0]);
1110 if (txmac_stat & MAC_TX_UNDERRUN) {
1111 printk(KERN_ERR "%s: TX MAC xmit underrun.\n",
1112 dev->name);
1113 cp->net_stats[0].tx_fifo_errors++;
1114 }
1115
1116 if (txmac_stat & MAC_TX_MAX_PACKET_ERR) {
1117 printk(KERN_ERR "%s: TX MAC max packet size error.\n",
1118 dev->name);
1119 cp->net_stats[0].tx_errors++;
1120 }
1121
1122 /* The rest are all cases of one of the 16-bit TX
1123 * counters expiring.
1124 */
1125 if (txmac_stat & MAC_TX_COLL_NORMAL)
1126 cp->net_stats[0].collisions += 0x10000;
1127
1128 if (txmac_stat & MAC_TX_COLL_EXCESS) {
1129 cp->net_stats[0].tx_aborted_errors += 0x10000;
1130 cp->net_stats[0].collisions += 0x10000;
1131 }
1132
1133 if (txmac_stat & MAC_TX_COLL_LATE) {
1134 cp->net_stats[0].tx_aborted_errors += 0x10000;
1135 cp->net_stats[0].collisions += 0x10000;
1136 }
1137 spin_unlock(&cp->stat_lock[0]);
1138
1139 /* We do not keep track of MAC_TX_COLL_FIRST and
1140 * MAC_TX_PEAK_ATTEMPTS events.
1141 */
1142 return 0;
1143}
1144
1145static void cas_load_firmware(struct cas *cp, cas_hp_inst_t *firmware)
1146{
1147 cas_hp_inst_t *inst;
1148 u32 val;
1149 int i;
1150
1151 i = 0;
1152 while ((inst = firmware) && inst->note) {
1153 writel(i, cp->regs + REG_HP_INSTR_RAM_ADDR);
1154
1155 val = CAS_BASE(HP_INSTR_RAM_HI_VAL, inst->val);
1156 val |= CAS_BASE(HP_INSTR_RAM_HI_MASK, inst->mask);
1157 writel(val, cp->regs + REG_HP_INSTR_RAM_DATA_HI);
1158
1159 val = CAS_BASE(HP_INSTR_RAM_MID_OUTARG, inst->outarg >> 10);
1160 val |= CAS_BASE(HP_INSTR_RAM_MID_OUTOP, inst->outop);
1161 val |= CAS_BASE(HP_INSTR_RAM_MID_FNEXT, inst->fnext);
1162 val |= CAS_BASE(HP_INSTR_RAM_MID_FOFF, inst->foff);
1163 val |= CAS_BASE(HP_INSTR_RAM_MID_SNEXT, inst->snext);
1164 val |= CAS_BASE(HP_INSTR_RAM_MID_SOFF, inst->soff);
1165 val |= CAS_BASE(HP_INSTR_RAM_MID_OP, inst->op);
1166 writel(val, cp->regs + REG_HP_INSTR_RAM_DATA_MID);
1167
1168 val = CAS_BASE(HP_INSTR_RAM_LOW_OUTMASK, inst->outmask);
1169 val |= CAS_BASE(HP_INSTR_RAM_LOW_OUTSHIFT, inst->outshift);
1170 val |= CAS_BASE(HP_INSTR_RAM_LOW_OUTEN, inst->outenab);
1171 val |= CAS_BASE(HP_INSTR_RAM_LOW_OUTARG, inst->outarg);
1172 writel(val, cp->regs + REG_HP_INSTR_RAM_DATA_LOW);
1173 ++firmware;
1174 ++i;
1175 }
1176}
1177
1178static void cas_init_rx_dma(struct cas *cp)
1179{
1180 u64 desc_dma = cp->block_dvma;
1181 u32 val;
1182 int i, size;
1183
1184 /* rx free descriptors */
1185 val = CAS_BASE(RX_CFG_SWIVEL, RX_SWIVEL_OFF_VAL);
1186 val |= CAS_BASE(RX_CFG_DESC_RING, RX_DESC_RINGN_INDEX(0));
1187 val |= CAS_BASE(RX_CFG_COMP_RING, RX_COMP_RINGN_INDEX(0));
1188 if ((N_RX_DESC_RINGS > 1) &&
1189 (cp->cas_flags & CAS_FLAG_REG_PLUS)) /* do desc 2 */
1190 val |= CAS_BASE(RX_CFG_DESC_RING1, RX_DESC_RINGN_INDEX(1));
1191 writel(val, cp->regs + REG_RX_CFG);
1192
1193 val = (unsigned long) cp->init_rxds[0] -
1194 (unsigned long) cp->init_block;
1195 writel((desc_dma + val) >> 32, cp->regs + REG_RX_DB_HI);
1196 writel((desc_dma + val) & 0xffffffff, cp->regs + REG_RX_DB_LOW);
1197 writel(RX_DESC_RINGN_SIZE(0) - 4, cp->regs + REG_RX_KICK);
1198
1199 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
1200 /* rx desc 2 is for IPSEC packets. however,
1201 * we don't it that for that purpose.
1202 */
1203 val = (unsigned long) cp->init_rxds[1] -
1204 (unsigned long) cp->init_block;
1205 writel((desc_dma + val) >> 32, cp->regs + REG_PLUS_RX_DB1_HI);
1206 writel((desc_dma + val) & 0xffffffff, cp->regs +
1207 REG_PLUS_RX_DB1_LOW);
1208 writel(RX_DESC_RINGN_SIZE(1) - 4, cp->regs +
1209 REG_PLUS_RX_KICK1);
1210 }
1211
1212 /* rx completion registers */
1213 val = (unsigned long) cp->init_rxcs[0] -
1214 (unsigned long) cp->init_block;
1215 writel((desc_dma + val) >> 32, cp->regs + REG_RX_CB_HI);
1216 writel((desc_dma + val) & 0xffffffff, cp->regs + REG_RX_CB_LOW);
1217
1218 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
1219 /* rx comp 2-4 */
1220 for (i = 1; i < MAX_RX_COMP_RINGS; i++) {
1221 val = (unsigned long) cp->init_rxcs[i] -
1222 (unsigned long) cp->init_block;
1223 writel((desc_dma + val) >> 32, cp->regs +
1224 REG_PLUS_RX_CBN_HI(i));
1225 writel((desc_dma + val) & 0xffffffff, cp->regs +
1226 REG_PLUS_RX_CBN_LOW(i));
1227 }
1228 }
1229
1230 /* read selective clear regs to prevent spurious interrupts
1231 * on reset because complete == kick.
1232 * selective clear set up to prevent interrupts on resets
1233 */
1234 readl(cp->regs + REG_INTR_STATUS_ALIAS);
1235 writel(INTR_RX_DONE | INTR_RX_BUF_UNAVAIL, cp->regs + REG_ALIAS_CLEAR);
1236 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
1237 for (i = 1; i < N_RX_COMP_RINGS; i++)
1238 readl(cp->regs + REG_PLUS_INTRN_STATUS_ALIAS(i));
1239
1240 /* 2 is different from 3 and 4 */
1241 if (N_RX_COMP_RINGS > 1)
1242 writel(INTR_RX_DONE_ALT | INTR_RX_BUF_UNAVAIL_1,
1243 cp->regs + REG_PLUS_ALIASN_CLEAR(1));
1244
1245 for (i = 2; i < N_RX_COMP_RINGS; i++)
1246 writel(INTR_RX_DONE_ALT,
1247 cp->regs + REG_PLUS_ALIASN_CLEAR(i));
1248 }
1249
1250 /* set up pause thresholds */
1251 val = CAS_BASE(RX_PAUSE_THRESH_OFF,
1252 cp->rx_pause_off / RX_PAUSE_THRESH_QUANTUM);
1253 val |= CAS_BASE(RX_PAUSE_THRESH_ON,
1254 cp->rx_pause_on / RX_PAUSE_THRESH_QUANTUM);
1255 writel(val, cp->regs + REG_RX_PAUSE_THRESH);
1256
1257 /* zero out dma reassembly buffers */
1258 for (i = 0; i < 64; i++) {
1259 writel(i, cp->regs + REG_RX_TABLE_ADDR);
1260 writel(0x0, cp->regs + REG_RX_TABLE_DATA_LOW);
1261 writel(0x0, cp->regs + REG_RX_TABLE_DATA_MID);
1262 writel(0x0, cp->regs + REG_RX_TABLE_DATA_HI);
1263 }
1264
1265 /* make sure address register is 0 for normal operation */
1266 writel(0x0, cp->regs + REG_RX_CTRL_FIFO_ADDR);
1267 writel(0x0, cp->regs + REG_RX_IPP_FIFO_ADDR);
1268
1269 /* interrupt mitigation */
1270#ifdef USE_RX_BLANK
1271 val = CAS_BASE(RX_BLANK_INTR_TIME, RX_BLANK_INTR_TIME_VAL);
1272 val |= CAS_BASE(RX_BLANK_INTR_PKT, RX_BLANK_INTR_PKT_VAL);
1273 writel(val, cp->regs + REG_RX_BLANK);
1274#else
1275 writel(0x0, cp->regs + REG_RX_BLANK);
1276#endif
1277
1278 /* interrupt generation as a function of low water marks for
1279 * free desc and completion entries. these are used to trigger
1280 * housekeeping for rx descs. we don't use the free interrupt
1281 * as it's not very useful
1282 */
1283 /* val = CAS_BASE(RX_AE_THRESH_FREE, RX_AE_FREEN_VAL(0)); */
1284 val = CAS_BASE(RX_AE_THRESH_COMP, RX_AE_COMP_VAL);
1285 writel(val, cp->regs + REG_RX_AE_THRESH);
1286 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
1287 val = CAS_BASE(RX_AE1_THRESH_FREE, RX_AE_FREEN_VAL(1));
1288 writel(val, cp->regs + REG_PLUS_RX_AE1_THRESH);
1289 }
1290
1291 /* Random early detect registers. useful for congestion avoidance.
1292 * this should be tunable.
1293 */
1294 writel(0x0, cp->regs + REG_RX_RED);
1295
1296 /* receive page sizes. default == 2K (0x800) */
1297 val = 0;
1298 if (cp->page_size == 0x1000)
1299 val = 0x1;
1300 else if (cp->page_size == 0x2000)
1301 val = 0x2;
1302 else if (cp->page_size == 0x4000)
1303 val = 0x3;
1304
1305 /* round mtu + offset. constrain to page size. */
1306 size = cp->dev->mtu + 64;
1307 if (size > cp->page_size)
1308 size = cp->page_size;
1309
1310 if (size <= 0x400)
1311 i = 0x0;
1312 else if (size <= 0x800)
1313 i = 0x1;
1314 else if (size <= 0x1000)
1315 i = 0x2;
1316 else
1317 i = 0x3;
1318
1319 cp->mtu_stride = 1 << (i + 10);
1320 val = CAS_BASE(RX_PAGE_SIZE, val);
1321 val |= CAS_BASE(RX_PAGE_SIZE_MTU_STRIDE, i);
1322 val |= CAS_BASE(RX_PAGE_SIZE_MTU_COUNT, cp->page_size >> (i + 10));
1323 val |= CAS_BASE(RX_PAGE_SIZE_MTU_OFF, 0x1);
1324 writel(val, cp->regs + REG_RX_PAGE_SIZE);
1325
1326 /* enable the header parser if desired */
1327 if (CAS_HP_FIRMWARE == cas_prog_null)
1328 return;
1329
1330 val = CAS_BASE(HP_CFG_NUM_CPU, CAS_NCPUS > 63 ? 0 : CAS_NCPUS);
1331 val |= HP_CFG_PARSE_EN | HP_CFG_SYN_INC_MASK;
1332 val |= CAS_BASE(HP_CFG_TCP_THRESH, HP_TCP_THRESH_VAL);
1333 writel(val, cp->regs + REG_HP_CFG);
1334}
1335
1336static inline void cas_rxc_init(struct cas_rx_comp *rxc)
1337{
1338 memset(rxc, 0, sizeof(*rxc));
1339 rxc->word4 = cpu_to_le64(RX_COMP4_ZERO);
1340}
1341
1342/* NOTE: we use the ENC RX DESC ring for spares. the rx_page[0,1]
1343 * flipping is protected by the fact that the chip will not
1344 * hand back the same page index while it's being processed.
1345 */
1346static inline cas_page_t *cas_page_spare(struct cas *cp, const int index)
1347{
1348 cas_page_t *page = cp->rx_pages[1][index];
1349 cas_page_t *new;
1350
1351 if (page_count(page->buffer) == 1)
1352 return page;
1353
1354 new = cas_page_dequeue(cp);
1355 if (new) {
1356 spin_lock(&cp->rx_inuse_lock);
1357 list_add(&page->list, &cp->rx_inuse_list);
1358 spin_unlock(&cp->rx_inuse_lock);
1359 }
1360 return new;
1361}
1362
1363/* this needs to be changed if we actually use the ENC RX DESC ring */
1364static cas_page_t *cas_page_swap(struct cas *cp, const int ring,
1365 const int index)
1366{
1367 cas_page_t **page0 = cp->rx_pages[0];
1368 cas_page_t **page1 = cp->rx_pages[1];
1369
1370 /* swap if buffer is in use */
1371 if (page_count(page0[index]->buffer) > 1) {
1372 cas_page_t *new = cas_page_spare(cp, index);
1373 if (new) {
1374 page1[index] = page0[index];
1375 page0[index] = new;
1376 }
1377 }
1378 RX_USED_SET(page0[index], 0);
1379 return page0[index];
1380}
1381
1382static void cas_clean_rxds(struct cas *cp)
1383{
1384 /* only clean ring 0 as ring 1 is used for spare buffers */
1385 struct cas_rx_desc *rxd = cp->init_rxds[0];
1386 int i, size;
1387
1388 /* release all rx flows */
1389 for (i = 0; i < N_RX_FLOWS; i++) {
1390 struct sk_buff *skb;
1391 while ((skb = __skb_dequeue(&cp->rx_flows[i]))) {
1392 cas_skb_release(skb);
1393 }
1394 }
1395
1396 /* initialize descriptors */
1397 size = RX_DESC_RINGN_SIZE(0);
1398 for (i = 0; i < size; i++) {
1399 cas_page_t *page = cas_page_swap(cp, 0, i);
1400 rxd[i].buffer = cpu_to_le64(page->dma_addr);
1401 rxd[i].index = cpu_to_le64(CAS_BASE(RX_INDEX_NUM, i) |
1402 CAS_BASE(RX_INDEX_RING, 0));
1403 }
1404
1405 cp->rx_old[0] = RX_DESC_RINGN_SIZE(0) - 4;
1406 cp->rx_last[0] = 0;
1407 cp->cas_flags &= ~CAS_FLAG_RXD_POST(0);
1408}
1409
1410static void cas_clean_rxcs(struct cas *cp)
1411{
1412 int i, j;
1413
1414 /* take ownership of rx comp descriptors */
1415 memset(cp->rx_cur, 0, sizeof(*cp->rx_cur)*N_RX_COMP_RINGS);
1416 memset(cp->rx_new, 0, sizeof(*cp->rx_new)*N_RX_COMP_RINGS);
1417 for (i = 0; i < N_RX_COMP_RINGS; i++) {
1418 struct cas_rx_comp *rxc = cp->init_rxcs[i];
1419 for (j = 0; j < RX_COMP_RINGN_SIZE(i); j++) {
1420 cas_rxc_init(rxc + j);
1421 }
1422 }
1423}
1424
1425#if 0
1426/* When we get a RX fifo overflow, the RX unit is probably hung
1427 * so we do the following.
1428 *
1429 * If any part of the reset goes wrong, we return 1 and that causes the
1430 * whole chip to be reset.
1431 */
1432static int cas_rxmac_reset(struct cas *cp)
1433{
1434 struct net_device *dev = cp->dev;
1435 int limit;
1436 u32 val;
1437
1438 /* First, reset MAC RX. */
1439 writel(cp->mac_rx_cfg & ~MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
1440 for (limit = 0; limit < STOP_TRIES; limit++) {
1441 if (!(readl(cp->regs + REG_MAC_RX_CFG) & MAC_RX_CFG_EN))
1442 break;
1443 udelay(10);
1444 }
1445 if (limit == STOP_TRIES) {
1446 printk(KERN_ERR "%s: RX MAC will not disable, resetting whole "
1447 "chip.\n", dev->name);
1448 return 1;
1449 }
1450
1451 /* Second, disable RX DMA. */
1452 writel(0, cp->regs + REG_RX_CFG);
1453 for (limit = 0; limit < STOP_TRIES; limit++) {
1454 if (!(readl(cp->regs + REG_RX_CFG) & RX_CFG_DMA_EN))
1455 break;
1456 udelay(10);
1457 }
1458 if (limit == STOP_TRIES) {
1459 printk(KERN_ERR "%s: RX DMA will not disable, resetting whole "
1460 "chip.\n", dev->name);
1461 return 1;
1462 }
1463
1464 mdelay(5);
1465
1466 /* Execute RX reset command. */
1467 writel(SW_RESET_RX, cp->regs + REG_SW_RESET);
1468 for (limit = 0; limit < STOP_TRIES; limit++) {
1469 if (!(readl(cp->regs + REG_SW_RESET) & SW_RESET_RX))
1470 break;
1471 udelay(10);
1472 }
1473 if (limit == STOP_TRIES) {
1474 printk(KERN_ERR "%s: RX reset command will not execute, "
1475 "resetting whole chip.\n", dev->name);
1476 return 1;
1477 }
1478
1479 /* reset driver rx state */
1480 cas_clean_rxds(cp);
1481 cas_clean_rxcs(cp);
1482
1483 /* Now, reprogram the rest of RX unit. */
1484 cas_init_rx_dma(cp);
1485
1486 /* re-enable */
1487 val = readl(cp->regs + REG_RX_CFG);
1488 writel(val | RX_CFG_DMA_EN, cp->regs + REG_RX_CFG);
1489 writel(MAC_RX_FRAME_RECV, cp->regs + REG_MAC_RX_MASK);
1490 val = readl(cp->regs + REG_MAC_RX_CFG);
1491 writel(val | MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
1492 return 0;
1493}
1494#endif
1495
1496static int cas_rxmac_interrupt(struct net_device *dev, struct cas *cp,
1497 u32 status)
1498{
1499 u32 stat = readl(cp->regs + REG_MAC_RX_STATUS);
1500
1501 if (!stat)
1502 return 0;
1503
1504 if (netif_msg_intr(cp))
1505 printk(KERN_DEBUG "%s: rxmac interrupt, stat: 0x%x\n",
1506 cp->dev->name, stat);
1507
1508 /* these are all rollovers */
1509 spin_lock(&cp->stat_lock[0]);
1510 if (stat & MAC_RX_ALIGN_ERR)
1511 cp->net_stats[0].rx_frame_errors += 0x10000;
1512
1513 if (stat & MAC_RX_CRC_ERR)
1514 cp->net_stats[0].rx_crc_errors += 0x10000;
1515
1516 if (stat & MAC_RX_LEN_ERR)
1517 cp->net_stats[0].rx_length_errors += 0x10000;
1518
1519 if (stat & MAC_RX_OVERFLOW) {
1520 cp->net_stats[0].rx_over_errors++;
1521 cp->net_stats[0].rx_fifo_errors++;
1522 }
1523
1524 /* We do not track MAC_RX_FRAME_COUNT and MAC_RX_VIOL_ERR
1525 * events.
1526 */
1527 spin_unlock(&cp->stat_lock[0]);
1528 return 0;
1529}
1530
1531static int cas_mac_interrupt(struct net_device *dev, struct cas *cp,
1532 u32 status)
1533{
1534 u32 stat = readl(cp->regs + REG_MAC_CTRL_STATUS);
1535
1536 if (!stat)
1537 return 0;
1538
1539 if (netif_msg_intr(cp))
1540 printk(KERN_DEBUG "%s: mac interrupt, stat: 0x%x\n",
1541 cp->dev->name, stat);
1542
1543 /* This interrupt is just for pause frame and pause
1544 * tracking. It is useful for diagnostics and debug
1545 * but probably by default we will mask these events.
1546 */
1547 if (stat & MAC_CTRL_PAUSE_STATE)
1548 cp->pause_entered++;
1549
1550 if (stat & MAC_CTRL_PAUSE_RECEIVED)
1551 cp->pause_last_time_recvd = (stat >> 16);
1552
1553 return 0;
1554}
1555
1556
1557/* Must be invoked under cp->lock. */
1558static inline int cas_mdio_link_not_up(struct cas *cp)
1559{
1560 u16 val;
1561
1562 switch (cp->lstate) {
1563 case link_force_ret:
1564 if (netif_msg_link(cp))
1565 printk(KERN_INFO "%s: Autoneg failed again, keeping"
1566 " forced mode\n", cp->dev->name);
1567 cas_phy_write(cp, MII_BMCR, cp->link_fcntl);
1568 cp->timer_ticks = 5;
1569 cp->lstate = link_force_ok;
1570 cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
1571 break;
1572
1573 case link_aneg:
1574 val = cas_phy_read(cp, MII_BMCR);
1575
1576 /* Try forced modes. we try things in the following order:
1577 * 1000 full -> 100 full/half -> 10 half
1578 */
1579 val &= ~(BMCR_ANRESTART | BMCR_ANENABLE);
1580 val |= BMCR_FULLDPLX;
1581 val |= (cp->cas_flags & CAS_FLAG_1000MB_CAP) ?
1582 CAS_BMCR_SPEED1000 : BMCR_SPEED100;
1583 cas_phy_write(cp, MII_BMCR, val);
1584 cp->timer_ticks = 5;
1585 cp->lstate = link_force_try;
1586 cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
1587 break;
1588
1589 case link_force_try:
1590 /* Downgrade from 1000 to 100 to 10 Mbps if necessary. */
1591 val = cas_phy_read(cp, MII_BMCR);
1592 cp->timer_ticks = 5;
1593 if (val & CAS_BMCR_SPEED1000) { /* gigabit */
1594 val &= ~CAS_BMCR_SPEED1000;
1595 val |= (BMCR_SPEED100 | BMCR_FULLDPLX);
1596 cas_phy_write(cp, MII_BMCR, val);
1597 break;
1598 }
1599
1600 if (val & BMCR_SPEED100) {
1601 if (val & BMCR_FULLDPLX) /* fd failed */
1602 val &= ~BMCR_FULLDPLX;
1603 else { /* 100Mbps failed */
1604 val &= ~BMCR_SPEED100;
1605 }
1606 cas_phy_write(cp, MII_BMCR, val);
1607 break;
1608 }
1609 default:
1610 break;
1611 }
1612 return 0;
1613}
1614
1615
1616/* must be invoked with cp->lock held */
1617static int cas_mii_link_check(struct cas *cp, const u16 bmsr)
1618{
1619 int restart;
1620
1621 if (bmsr & BMSR_LSTATUS) {
1622 /* Ok, here we got a link. If we had it due to a forced
1623 * fallback, and we were configured for autoneg, we
1624 * retry a short autoneg pass. If you know your hub is
1625 * broken, use ethtool ;)
1626 */
1627 if ((cp->lstate == link_force_try) &&
1628 (cp->link_cntl & BMCR_ANENABLE)) {
1629 cp->lstate = link_force_ret;
1630 cp->link_transition = LINK_TRANSITION_LINK_CONFIG;
1631 cas_mif_poll(cp, 0);
1632 cp->link_fcntl = cas_phy_read(cp, MII_BMCR);
1633 cp->timer_ticks = 5;
1634 if (cp->opened && netif_msg_link(cp))
1635 printk(KERN_INFO "%s: Got link after fallback, retrying"
1636 " autoneg once...\n", cp->dev->name);
1637 cas_phy_write(cp, MII_BMCR,
1638 cp->link_fcntl | BMCR_ANENABLE |
1639 BMCR_ANRESTART);
1640 cas_mif_poll(cp, 1);
1641
1642 } else if (cp->lstate != link_up) {
1643 cp->lstate = link_up;
1644 cp->link_transition = LINK_TRANSITION_LINK_UP;
1645
1646 if (cp->opened) {
1647 cas_set_link_modes(cp);
1648 netif_carrier_on(cp->dev);
1649 }
1650 }
1651 return 0;
1652 }
1653
1654 /* link not up. if the link was previously up, we restart the
1655 * whole process
1656 */
1657 restart = 0;
1658 if (cp->lstate == link_up) {
1659 cp->lstate = link_down;
1660 cp->link_transition = LINK_TRANSITION_LINK_DOWN;
1661
1662 netif_carrier_off(cp->dev);
1663 if (cp->opened && netif_msg_link(cp))
1664 printk(KERN_INFO "%s: Link down\n",
1665 cp->dev->name);
1666 restart = 1;
1667
1668 } else if (++cp->timer_ticks > 10)
1669 cas_mdio_link_not_up(cp);
1670
1671 return restart;
1672}
1673
1674static int cas_mif_interrupt(struct net_device *dev, struct cas *cp,
1675 u32 status)
1676{
1677 u32 stat = readl(cp->regs + REG_MIF_STATUS);
1678 u16 bmsr;
1679
1680 /* check for a link change */
1681 if (CAS_VAL(MIF_STATUS_POLL_STATUS, stat) == 0)
1682 return 0;
1683
1684 bmsr = CAS_VAL(MIF_STATUS_POLL_DATA, stat);
1685 return cas_mii_link_check(cp, bmsr);
1686}
1687
1688static int cas_pci_interrupt(struct net_device *dev, struct cas *cp,
1689 u32 status)
1690{
1691 u32 stat = readl(cp->regs + REG_PCI_ERR_STATUS);
1692
1693 if (!stat)
1694 return 0;
1695
1696 printk(KERN_ERR "%s: PCI error [%04x:%04x] ", dev->name, stat,
1697 readl(cp->regs + REG_BIM_DIAG));
1698
1699 /* cassini+ has this reserved */
1700 if ((stat & PCI_ERR_BADACK) &&
1701 ((cp->cas_flags & CAS_FLAG_REG_PLUS) == 0))
1702 printk("<No ACK64# during ABS64 cycle> ");
1703
1704 if (stat & PCI_ERR_DTRTO)
1705 printk("<Delayed transaction timeout> ");
1706 if (stat & PCI_ERR_OTHER)
1707 printk("<other> ");
1708 if (stat & PCI_ERR_BIM_DMA_WRITE)
1709 printk("<BIM DMA 0 write req> ");
1710 if (stat & PCI_ERR_BIM_DMA_READ)
1711 printk("<BIM DMA 0 read req> ");
1712 printk("\n");
1713
1714 if (stat & PCI_ERR_OTHER) {
1715 u16 cfg;
1716
1717 /* Interrogate PCI config space for the
1718 * true cause.
1719 */
1720 pci_read_config_word(cp->pdev, PCI_STATUS, &cfg);
1721 printk(KERN_ERR "%s: Read PCI cfg space status [%04x]\n",
1722 dev->name, cfg);
1723 if (cfg & PCI_STATUS_PARITY)
1724 printk(KERN_ERR "%s: PCI parity error detected.\n",
1725 dev->name);
1726 if (cfg & PCI_STATUS_SIG_TARGET_ABORT)
1727 printk(KERN_ERR "%s: PCI target abort.\n",
1728 dev->name);
1729 if (cfg & PCI_STATUS_REC_TARGET_ABORT)
1730 printk(KERN_ERR "%s: PCI master acks target abort.\n",
1731 dev->name);
1732 if (cfg & PCI_STATUS_REC_MASTER_ABORT)
1733 printk(KERN_ERR "%s: PCI master abort.\n", dev->name);
1734 if (cfg & PCI_STATUS_SIG_SYSTEM_ERROR)
1735 printk(KERN_ERR "%s: PCI system error SERR#.\n",
1736 dev->name);
1737 if (cfg & PCI_STATUS_DETECTED_PARITY)
1738 printk(KERN_ERR "%s: PCI parity error.\n",
1739 dev->name);
1740
1741 /* Write the error bits back to clear them. */
1742 cfg &= (PCI_STATUS_PARITY |
1743 PCI_STATUS_SIG_TARGET_ABORT |
1744 PCI_STATUS_REC_TARGET_ABORT |
1745 PCI_STATUS_REC_MASTER_ABORT |
1746 PCI_STATUS_SIG_SYSTEM_ERROR |
1747 PCI_STATUS_DETECTED_PARITY);
1748 pci_write_config_word(cp->pdev, PCI_STATUS, cfg);
1749 }
1750
1751 /* For all PCI errors, we should reset the chip. */
1752 return 1;
1753}
1754
1755/* All non-normal interrupt conditions get serviced here.
1756 * Returns non-zero if we should just exit the interrupt
1757 * handler right now (ie. if we reset the card which invalidates
1758 * all of the other original irq status bits).
1759 */
1760static int cas_abnormal_irq(struct net_device *dev, struct cas *cp,
1761 u32 status)
1762{
1763 if (status & INTR_RX_TAG_ERROR) {
1764 /* corrupt RX tag framing */
1765 if (netif_msg_rx_err(cp))
1766 printk(KERN_DEBUG "%s: corrupt rx tag framing\n",
1767 cp->dev->name);
1768 spin_lock(&cp->stat_lock[0]);
1769 cp->net_stats[0].rx_errors++;
1770 spin_unlock(&cp->stat_lock[0]);
1771 goto do_reset;
1772 }
1773
1774 if (status & INTR_RX_LEN_MISMATCH) {
1775 /* length mismatch. */
1776 if (netif_msg_rx_err(cp))
1777 printk(KERN_DEBUG "%s: length mismatch for rx frame\n",
1778 cp->dev->name);
1779 spin_lock(&cp->stat_lock[0]);
1780 cp->net_stats[0].rx_errors++;
1781 spin_unlock(&cp->stat_lock[0]);
1782 goto do_reset;
1783 }
1784
1785 if (status & INTR_PCS_STATUS) {
1786 if (cas_pcs_interrupt(dev, cp, status))
1787 goto do_reset;
1788 }
1789
1790 if (status & INTR_TX_MAC_STATUS) {
1791 if (cas_txmac_interrupt(dev, cp, status))
1792 goto do_reset;
1793 }
1794
1795 if (status & INTR_RX_MAC_STATUS) {
1796 if (cas_rxmac_interrupt(dev, cp, status))
1797 goto do_reset;
1798 }
1799
1800 if (status & INTR_MAC_CTRL_STATUS) {
1801 if (cas_mac_interrupt(dev, cp, status))
1802 goto do_reset;
1803 }
1804
1805 if (status & INTR_MIF_STATUS) {
1806 if (cas_mif_interrupt(dev, cp, status))
1807 goto do_reset;
1808 }
1809
1810 if (status & INTR_PCI_ERROR_STATUS) {
1811 if (cas_pci_interrupt(dev, cp, status))
1812 goto do_reset;
1813 }
1814 return 0;
1815
1816do_reset:
1817#if 1
1818 atomic_inc(&cp->reset_task_pending);
1819 atomic_inc(&cp->reset_task_pending_all);
1820 printk(KERN_ERR "%s:reset called in cas_abnormal_irq [0x%x]\n",
1821 dev->name, status);
1822 schedule_work(&cp->reset_task);
1823#else
1824 atomic_set(&cp->reset_task_pending, CAS_RESET_ALL);
1825 printk(KERN_ERR "reset called in cas_abnormal_irq\n");
1826 schedule_work(&cp->reset_task);
1827#endif
1828 return 1;
1829}
1830
1831/* NOTE: CAS_TABORT returns 1 or 2 so that it can be used when
1832 * determining whether to do a netif_stop/wakeup
1833 */
1834#define CAS_TABORT(x) (((x)->cas_flags & CAS_FLAG_TARGET_ABORT) ? 2 : 1)
1835#define CAS_ROUND_PAGE(x) (((x) + PAGE_SIZE - 1) & PAGE_MASK)
1836static inline int cas_calc_tabort(struct cas *cp, const unsigned long addr,
1837 const int len)
1838{
1839 unsigned long off = addr + len;
1840
1841 if (CAS_TABORT(cp) == 1)
1842 return 0;
1843 if ((CAS_ROUND_PAGE(off) - off) > TX_TARGET_ABORT_LEN)
1844 return 0;
1845 return TX_TARGET_ABORT_LEN;
1846}
1847
1848static inline void cas_tx_ringN(struct cas *cp, int ring, int limit)
1849{
1850 struct cas_tx_desc *txds;
1851 struct sk_buff **skbs;
1852 struct net_device *dev = cp->dev;
1853 int entry, count;
1854
1855 spin_lock(&cp->tx_lock[ring]);
1856 txds = cp->init_txds[ring];
1857 skbs = cp->tx_skbs[ring];
1858 entry = cp->tx_old[ring];
1859
1860 count = TX_BUFF_COUNT(ring, entry, limit);
1861 while (entry != limit) {
1862 struct sk_buff *skb = skbs[entry];
1863 dma_addr_t daddr;
1864 u32 dlen;
1865 int frag;
1866
1867 if (!skb) {
1868 /* this should never occur */
1869 entry = TX_DESC_NEXT(ring, entry);
1870 continue;
1871 }
1872
1873 /* however, we might get only a partial skb release. */
1874 count -= skb_shinfo(skb)->nr_frags +
1875 + cp->tx_tiny_use[ring][entry].nbufs + 1;
1876 if (count < 0)
1877 break;
1878
1879 if (netif_msg_tx_done(cp))
1880 printk(KERN_DEBUG "%s: tx[%d] done, slot %d\n",
1881 cp->dev->name, ring, entry);
1882
1883 skbs[entry] = NULL;
1884 cp->tx_tiny_use[ring][entry].nbufs = 0;
1885
1886 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) {
1887 struct cas_tx_desc *txd = txds + entry;
1888
1889 daddr = le64_to_cpu(txd->buffer);
1890 dlen = CAS_VAL(TX_DESC_BUFLEN,
1891 le64_to_cpu(txd->control));
1892 pci_unmap_page(cp->pdev, daddr, dlen,
1893 PCI_DMA_TODEVICE);
1894 entry = TX_DESC_NEXT(ring, entry);
1895
1896 /* tiny buffer may follow */
1897 if (cp->tx_tiny_use[ring][entry].used) {
1898 cp->tx_tiny_use[ring][entry].used = 0;
1899 entry = TX_DESC_NEXT(ring, entry);
1900 }
1901 }
1902
1903 spin_lock(&cp->stat_lock[ring]);
1904 cp->net_stats[ring].tx_packets++;
1905 cp->net_stats[ring].tx_bytes += skb->len;
1906 spin_unlock(&cp->stat_lock[ring]);
1907 dev_kfree_skb_irq(skb);
1908 }
1909 cp->tx_old[ring] = entry;
1910
1911 /* this is wrong for multiple tx rings. the net device needs
1912 * multiple queues for this to do the right thing. we wait
1913 * for 2*packets to be available when using tiny buffers
1914 */
1915 if (netif_queue_stopped(dev) &&
1916 (TX_BUFFS_AVAIL(cp, ring) > CAS_TABORT(cp)*(MAX_SKB_FRAGS + 1)))
1917 netif_wake_queue(dev);
1918 spin_unlock(&cp->tx_lock[ring]);
1919}
1920
1921static void cas_tx(struct net_device *dev, struct cas *cp,
1922 u32 status)
1923{
1924 int limit, ring;
1925#ifdef USE_TX_COMPWB
1926 u64 compwb = le64_to_cpu(cp->init_block->tx_compwb);
1927#endif
1928 if (netif_msg_intr(cp))
1929 printk(KERN_DEBUG "%s: tx interrupt, status: 0x%x, %lx\n",
1930 cp->dev->name, status, compwb);
1931 /* process all the rings */
1932 for (ring = 0; ring < N_TX_RINGS; ring++) {
1933#ifdef USE_TX_COMPWB
1934 /* use the completion writeback registers */
1935 limit = (CAS_VAL(TX_COMPWB_MSB, compwb) << 8) |
1936 CAS_VAL(TX_COMPWB_LSB, compwb);
1937 compwb = TX_COMPWB_NEXT(compwb);
1938#else
1939 limit = readl(cp->regs + REG_TX_COMPN(ring));
1940#endif
1941 if (cp->tx_old[ring] != limit)
1942 cas_tx_ringN(cp, ring, limit);
1943 }
1944}
1945
1946
1947static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
1948 int entry, const u64 *words,
1949 struct sk_buff **skbref)
1950{
1951 int dlen, hlen, len, i, alloclen;
1952 int off, swivel = RX_SWIVEL_OFF_VAL;
1953 struct cas_page *page;
1954 struct sk_buff *skb;
1955 void *addr, *crcaddr;
1956 char *p;
1957
1958 hlen = CAS_VAL(RX_COMP2_HDR_SIZE, words[1]);
1959 dlen = CAS_VAL(RX_COMP1_DATA_SIZE, words[0]);
1960 len = hlen + dlen;
1961
1962 if (RX_COPY_ALWAYS || (words[2] & RX_COMP3_SMALL_PKT))
1963 alloclen = len;
1964 else
1965 alloclen = max(hlen, RX_COPY_MIN);
1966
1967 skb = dev_alloc_skb(alloclen + swivel + cp->crc_size);
1968 if (skb == NULL)
1969 return -1;
1970
1971 *skbref = skb;
1972 skb->dev = cp->dev;
1973 skb_reserve(skb, swivel);
1974
1975 p = skb->data;
1976 addr = crcaddr = NULL;
1977 if (hlen) { /* always copy header pages */
1978 i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
1979 page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
1980 off = CAS_VAL(RX_COMP2_HDR_OFF, words[1]) * 0x100 +
1981 swivel;
1982
1983 i = hlen;
1984 if (!dlen) /* attach FCS */
1985 i += cp->crc_size;
1986 pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr + off, i,
1987 PCI_DMA_FROMDEVICE);
1988 addr = cas_page_map(page->buffer);
1989 memcpy(p, addr + off, i);
1990 pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
1991 PCI_DMA_FROMDEVICE);
1992 cas_page_unmap(addr);
1993 RX_USED_ADD(page, 0x100);
1994 p += hlen;
1995 swivel = 0;
1996 }
1997
1998
1999 if (alloclen < (hlen + dlen)) {
2000 skb_frag_t *frag = skb_shinfo(skb)->frags;
2001
2002 /* normal or jumbo packets. we use frags */
2003 i = CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
2004 page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
2005 off = CAS_VAL(RX_COMP1_DATA_OFF, words[0]) + swivel;
2006
2007 hlen = min(cp->page_size - off, dlen);
2008 if (hlen < 0) {
2009 if (netif_msg_rx_err(cp)) {
2010 printk(KERN_DEBUG "%s: rx page overflow: "
2011 "%d\n", cp->dev->name, hlen);
2012 }
2013 dev_kfree_skb_irq(skb);
2014 return -1;
2015 }
2016 i = hlen;
2017 if (i == dlen) /* attach FCS */
2018 i += cp->crc_size;
2019 pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr + off, i,
2020 PCI_DMA_FROMDEVICE);
2021
2022 /* make sure we always copy a header */
2023 swivel = 0;
2024 if (p == (char *) skb->data) { /* not split */
2025 addr = cas_page_map(page->buffer);
2026 memcpy(p, addr + off, RX_COPY_MIN);
2027 pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
2028 PCI_DMA_FROMDEVICE);
2029 cas_page_unmap(addr);
2030 off += RX_COPY_MIN;
2031 swivel = RX_COPY_MIN;
2032 RX_USED_ADD(page, cp->mtu_stride);
2033 } else {
2034 RX_USED_ADD(page, hlen);
2035 }
2036 skb_put(skb, alloclen);
2037
2038 skb_shinfo(skb)->nr_frags++;
2039 skb->data_len += hlen - swivel;
2040 skb->len += hlen - swivel;
2041
2042 get_page(page->buffer);
2043 frag->page = page->buffer;
2044 frag->page_offset = off;
2045 frag->size = hlen - swivel;
2046
2047 /* any more data? */
2048 if ((words[0] & RX_COMP1_SPLIT_PKT) && ((dlen -= hlen) > 0)) {
2049 hlen = dlen;
2050 off = 0;
2051
2052 i = CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
2053 page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
2054 pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr,
2055 hlen + cp->crc_size,
2056 PCI_DMA_FROMDEVICE);
2057 pci_dma_sync_single_for_device(cp->pdev, page->dma_addr,
2058 hlen + cp->crc_size,
2059 PCI_DMA_FROMDEVICE);
2060
2061 skb_shinfo(skb)->nr_frags++;
2062 skb->data_len += hlen;
2063 skb->len += hlen;
2064 frag++;
2065
2066 get_page(page->buffer);
2067 frag->page = page->buffer;
2068 frag->page_offset = 0;
2069 frag->size = hlen;
2070 RX_USED_ADD(page, hlen + cp->crc_size);
2071 }
2072
2073 if (cp->crc_size) {
2074 addr = cas_page_map(page->buffer);
2075 crcaddr = addr + off + hlen;
2076 }
2077
2078 } else {
2079 /* copying packet */
2080 if (!dlen)
2081 goto end_copy_pkt;
2082
2083 i = CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
2084 page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
2085 off = CAS_VAL(RX_COMP1_DATA_OFF, words[0]) + swivel;
2086 hlen = min(cp->page_size - off, dlen);
2087 if (hlen < 0) {
2088 if (netif_msg_rx_err(cp)) {
2089 printk(KERN_DEBUG "%s: rx page overflow: "
2090 "%d\n", cp->dev->name, hlen);
2091 }
2092 dev_kfree_skb_irq(skb);
2093 return -1;
2094 }
2095 i = hlen;
2096 if (i == dlen) /* attach FCS */
2097 i += cp->crc_size;
2098 pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr + off, i,
2099 PCI_DMA_FROMDEVICE);
2100 addr = cas_page_map(page->buffer);
2101 memcpy(p, addr + off, i);
2102 pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
2103 PCI_DMA_FROMDEVICE);
2104 cas_page_unmap(addr);
2105 if (p == (char *) skb->data) /* not split */
2106 RX_USED_ADD(page, cp->mtu_stride);
2107 else
2108 RX_USED_ADD(page, i);
2109
2110 /* any more data? */
2111 if ((words[0] & RX_COMP1_SPLIT_PKT) && ((dlen -= hlen) > 0)) {
2112 p += hlen;
2113 i = CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
2114 page = cp->rx_pages[CAS_VAL(RX_INDEX_RING, i)][CAS_VAL(RX_INDEX_NUM, i)];
2115 pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr,
2116 dlen + cp->crc_size,
2117 PCI_DMA_FROMDEVICE);
2118 addr = cas_page_map(page->buffer);
2119 memcpy(p, addr, dlen + cp->crc_size);
2120 pci_dma_sync_single_for_device(cp->pdev, page->dma_addr,
2121 dlen + cp->crc_size,
2122 PCI_DMA_FROMDEVICE);
2123 cas_page_unmap(addr);
2124 RX_USED_ADD(page, dlen + cp->crc_size);
2125 }
2126end_copy_pkt:
2127 if (cp->crc_size) {
2128 addr = NULL;
2129 crcaddr = skb->data + alloclen;
2130 }
2131 skb_put(skb, alloclen);
2132 }
2133
2134 i = CAS_VAL(RX_COMP4_TCP_CSUM, words[3]);
2135 if (cp->crc_size) {
2136 /* checksum includes FCS. strip it out. */
2137 i = csum_fold(csum_partial(crcaddr, cp->crc_size, i));
2138 if (addr)
2139 cas_page_unmap(addr);
2140 }
2141 skb->csum = ntohs(i ^ 0xffff);
2142 skb->ip_summed = CHECKSUM_HW;
2143 skb->protocol = eth_type_trans(skb, cp->dev);
2144 return len;
2145}
2146
2147
2148/* we can handle up to 64 rx flows at a time. we do the same thing
2149 * as nonreassm except that we batch up the buffers.
2150 * NOTE: we currently just treat each flow as a bunch of packets that
2151 * we pass up. a better way would be to coalesce the packets
2152 * into a jumbo packet. to do that, we need to do the following:
2153 * 1) the first packet will have a clean split between header and
2154 * data. save both.
2155 * 2) each time the next flow packet comes in, extend the
2156 * data length and merge the checksums.
2157 * 3) on flow release, fix up the header.
2158 * 4) make sure the higher layer doesn't care.
2159 * because packets get coalesced, we shouldn't run into fragment count
2160 * issues.
2161 */
2162static inline void cas_rx_flow_pkt(struct cas *cp, const u64 *words,
2163 struct sk_buff *skb)
2164{
2165 int flowid = CAS_VAL(RX_COMP3_FLOWID, words[2]) & (N_RX_FLOWS - 1);
2166 struct sk_buff_head *flow = &cp->rx_flows[flowid];
2167
2168 /* this is protected at a higher layer, so no need to
2169 * do any additional locking here. stick the buffer
2170 * at the end.
2171 */
2172 __skb_insert(skb, flow->prev, (struct sk_buff *) flow, flow);
2173 if (words[0] & RX_COMP1_RELEASE_FLOW) {
2174 while ((skb = __skb_dequeue(flow))) {
2175 cas_skb_release(skb);
2176 }
2177 }
2178}
2179
2180/* put rx descriptor back on ring. if a buffer is in use by a higher
2181 * layer, this will need to put in a replacement.
2182 */
2183static void cas_post_page(struct cas *cp, const int ring, const int index)
2184{
2185 cas_page_t *new;
2186 int entry;
2187
2188 entry = cp->rx_old[ring];
2189
2190 new = cas_page_swap(cp, ring, index);
2191 cp->init_rxds[ring][entry].buffer = cpu_to_le64(new->dma_addr);
2192 cp->init_rxds[ring][entry].index =
2193 cpu_to_le64(CAS_BASE(RX_INDEX_NUM, index) |
2194 CAS_BASE(RX_INDEX_RING, ring));
2195
2196 entry = RX_DESC_ENTRY(ring, entry + 1);
2197 cp->rx_old[ring] = entry;
2198
2199 if (entry % 4)
2200 return;
2201
2202 if (ring == 0)
2203 writel(entry, cp->regs + REG_RX_KICK);
2204 else if ((N_RX_DESC_RINGS > 1) &&
2205 (cp->cas_flags & CAS_FLAG_REG_PLUS))
2206 writel(entry, cp->regs + REG_PLUS_RX_KICK1);
2207}
2208
2209
2210/* only when things are bad */
2211static int cas_post_rxds_ringN(struct cas *cp, int ring, int num)
2212{
2213 unsigned int entry, last, count, released;
2214 int cluster;
2215 cas_page_t **page = cp->rx_pages[ring];
2216
2217 entry = cp->rx_old[ring];
2218
2219 if (netif_msg_intr(cp))
2220 printk(KERN_DEBUG "%s: rxd[%d] interrupt, done: %d\n",
2221 cp->dev->name, ring, entry);
2222
2223 cluster = -1;
2224 count = entry & 0x3;
2225 last = RX_DESC_ENTRY(ring, num ? entry + num - 4: entry - 4);
2226 released = 0;
2227 while (entry != last) {
2228 /* make a new buffer if it's still in use */
2229 if (page_count(page[entry]->buffer) > 1) {
2230 cas_page_t *new = cas_page_dequeue(cp);
2231 if (!new) {
2232 /* let the timer know that we need to
2233 * do this again
2234 */
2235 cp->cas_flags |= CAS_FLAG_RXD_POST(ring);
2236 if (!timer_pending(&cp->link_timer))
2237 mod_timer(&cp->link_timer, jiffies +
2238 CAS_LINK_FAST_TIMEOUT);
2239 cp->rx_old[ring] = entry;
2240 cp->rx_last[ring] = num ? num - released : 0;
2241 return -ENOMEM;
2242 }
2243 spin_lock(&cp->rx_inuse_lock);
2244 list_add(&page[entry]->list, &cp->rx_inuse_list);
2245 spin_unlock(&cp->rx_inuse_lock);
2246 cp->init_rxds[ring][entry].buffer =
2247 cpu_to_le64(new->dma_addr);
2248 page[entry] = new;
2249
2250 }
2251
2252 if (++count == 4) {
2253 cluster = entry;
2254 count = 0;
2255 }
2256 released++;
2257 entry = RX_DESC_ENTRY(ring, entry + 1);
2258 }
2259 cp->rx_old[ring] = entry;
2260
2261 if (cluster < 0)
2262 return 0;
2263
2264 if (ring == 0)
2265 writel(cluster, cp->regs + REG_RX_KICK);
2266 else if ((N_RX_DESC_RINGS > 1) &&
2267 (cp->cas_flags & CAS_FLAG_REG_PLUS))
2268 writel(cluster, cp->regs + REG_PLUS_RX_KICK1);
2269 return 0;
2270}
2271
2272
2273/* process a completion ring. packets are set up in three basic ways:
2274 * small packets: should be copied header + data in single buffer.
2275 * large packets: header and data in a single buffer.
2276 * split packets: header in a separate buffer from data.
2277 * data may be in multiple pages. data may be > 256
2278 * bytes but in a single page.
2279 *
2280 * NOTE: RX page posting is done in this routine as well. while there's
2281 * the capability of using multiple RX completion rings, it isn't
2282 * really worthwhile due to the fact that the page posting will
2283 * force serialization on the single descriptor ring.
2284 */
2285static int cas_rx_ringN(struct cas *cp, int ring, int budget)
2286{
2287 struct cas_rx_comp *rxcs = cp->init_rxcs[ring];
2288 int entry, drops;
2289 int npackets = 0;
2290
2291 if (netif_msg_intr(cp))
2292 printk(KERN_DEBUG "%s: rx[%d] interrupt, done: %d/%d\n",
2293 cp->dev->name, ring,
2294 readl(cp->regs + REG_RX_COMP_HEAD),
2295 cp->rx_new[ring]);
2296
2297 entry = cp->rx_new[ring];
2298 drops = 0;
2299 while (1) {
2300 struct cas_rx_comp *rxc = rxcs + entry;
2301 struct sk_buff *skb;
2302 int type, len;
2303 u64 words[4];
2304 int i, dring;
2305
2306 words[0] = le64_to_cpu(rxc->word1);
2307 words[1] = le64_to_cpu(rxc->word2);
2308 words[2] = le64_to_cpu(rxc->word3);
2309 words[3] = le64_to_cpu(rxc->word4);
2310
2311 /* don't touch if still owned by hw */
2312 type = CAS_VAL(RX_COMP1_TYPE, words[0]);
2313 if (type == 0)
2314 break;
2315
2316 /* hw hasn't cleared the zero bit yet */
2317 if (words[3] & RX_COMP4_ZERO) {
2318 break;
2319 }
2320
2321 /* get info on the packet */
2322 if (words[3] & (RX_COMP4_LEN_MISMATCH | RX_COMP4_BAD)) {
2323 spin_lock(&cp->stat_lock[ring]);
2324 cp->net_stats[ring].rx_errors++;
2325 if (words[3] & RX_COMP4_LEN_MISMATCH)
2326 cp->net_stats[ring].rx_length_errors++;
2327 if (words[3] & RX_COMP4_BAD)
2328 cp->net_stats[ring].rx_crc_errors++;
2329 spin_unlock(&cp->stat_lock[ring]);
2330
2331 /* We'll just return it to Cassini. */
2332 drop_it:
2333 spin_lock(&cp->stat_lock[ring]);
2334 ++cp->net_stats[ring].rx_dropped;
2335 spin_unlock(&cp->stat_lock[ring]);
2336 goto next;
2337 }
2338
2339 len = cas_rx_process_pkt(cp, rxc, entry, words, &skb);
2340 if (len < 0) {
2341 ++drops;
2342 goto drop_it;
2343 }
2344
2345 /* see if it's a flow re-assembly or not. the driver
2346 * itself handles release back up.
2347 */
2348 if (RX_DONT_BATCH || (type == 0x2)) {
2349 /* non-reassm: these always get released */
2350 cas_skb_release(skb);
2351 } else {
2352 cas_rx_flow_pkt(cp, words, skb);
2353 }
2354
2355 spin_lock(&cp->stat_lock[ring]);
2356 cp->net_stats[ring].rx_packets++;
2357 cp->net_stats[ring].rx_bytes += len;
2358 spin_unlock(&cp->stat_lock[ring]);
2359 cp->dev->last_rx = jiffies;
2360
2361 next:
2362 npackets++;
2363
2364 /* should it be released? */
2365 if (words[0] & RX_COMP1_RELEASE_HDR) {
2366 i = CAS_VAL(RX_COMP2_HDR_INDEX, words[1]);
2367 dring = CAS_VAL(RX_INDEX_RING, i);
2368 i = CAS_VAL(RX_INDEX_NUM, i);
2369 cas_post_page(cp, dring, i);
2370 }
2371
2372 if (words[0] & RX_COMP1_RELEASE_DATA) {
2373 i = CAS_VAL(RX_COMP1_DATA_INDEX, words[0]);
2374 dring = CAS_VAL(RX_INDEX_RING, i);
2375 i = CAS_VAL(RX_INDEX_NUM, i);
2376 cas_post_page(cp, dring, i);
2377 }
2378
2379 if (words[0] & RX_COMP1_RELEASE_NEXT) {
2380 i = CAS_VAL(RX_COMP2_NEXT_INDEX, words[1]);
2381 dring = CAS_VAL(RX_INDEX_RING, i);
2382 i = CAS_VAL(RX_INDEX_NUM, i);
2383 cas_post_page(cp, dring, i);
2384 }
2385
2386 /* skip to the next entry */
2387 entry = RX_COMP_ENTRY(ring, entry + 1 +
2388 CAS_VAL(RX_COMP1_SKIP, words[0]));
2389#ifdef USE_NAPI
2390 if (budget && (npackets >= budget))
2391 break;
2392#endif
2393 }
2394 cp->rx_new[ring] = entry;
2395
2396 if (drops)
2397 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
2398 cp->dev->name);
2399 return npackets;
2400}
2401
2402
2403/* put completion entries back on the ring */
2404static void cas_post_rxcs_ringN(struct net_device *dev,
2405 struct cas *cp, int ring)
2406{
2407 struct cas_rx_comp *rxc = cp->init_rxcs[ring];
2408 int last, entry;
2409
2410 last = cp->rx_cur[ring];
2411 entry = cp->rx_new[ring];
2412 if (netif_msg_intr(cp))
2413 printk(KERN_DEBUG "%s: rxc[%d] interrupt, done: %d/%d\n",
2414 dev->name, ring, readl(cp->regs + REG_RX_COMP_HEAD),
2415 entry);
2416
2417 /* zero and re-mark descriptors */
2418 while (last != entry) {
2419 cas_rxc_init(rxc + last);
2420 last = RX_COMP_ENTRY(ring, last + 1);
2421 }
2422 cp->rx_cur[ring] = last;
2423
2424 if (ring == 0)
2425 writel(last, cp->regs + REG_RX_COMP_TAIL);
2426 else if (cp->cas_flags & CAS_FLAG_REG_PLUS)
2427 writel(last, cp->regs + REG_PLUS_RX_COMPN_TAIL(ring));
2428}
2429
2430
2431
2432/* cassini can use all four PCI interrupts for the completion ring.
2433 * rings 3 and 4 are identical
2434 */
2435#if defined(USE_PCI_INTC) || defined(USE_PCI_INTD)
2436static inline void cas_handle_irqN(struct net_device *dev,
2437 struct cas *cp, const u32 status,
2438 const int ring)
2439{
2440 if (status & (INTR_RX_COMP_FULL_ALT | INTR_RX_COMP_AF_ALT))
2441 cas_post_rxcs_ringN(dev, cp, ring);
2442}
2443
2444static irqreturn_t cas_interruptN(int irq, void *dev_id, struct pt_regs *regs)
2445{
2446 struct net_device *dev = dev_id;
2447 struct cas *cp = netdev_priv(dev);
2448 unsigned long flags;
2449 int ring;
2450 u32 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(ring));
2451
2452 /* check for shared irq */
2453 if (status == 0)
2454 return IRQ_NONE;
2455
2456 ring = (irq == cp->pci_irq_INTC) ? 2 : 3;
2457 spin_lock_irqsave(&cp->lock, flags);
2458 if (status & INTR_RX_DONE_ALT) { /* handle rx separately */
2459#ifdef USE_NAPI
2460 cas_mask_intr(cp);
2461 netif_rx_schedule(dev);
2462#else
2463 cas_rx_ringN(cp, ring, 0);
2464#endif
2465 status &= ~INTR_RX_DONE_ALT;
2466 }
2467
2468 if (status)
2469 cas_handle_irqN(dev, cp, status, ring);
2470 spin_unlock_irqrestore(&cp->lock, flags);
2471 return IRQ_HANDLED;
2472}
2473#endif
2474
2475#ifdef USE_PCI_INTB
2476/* everything but rx packets */
2477static inline void cas_handle_irq1(struct cas *cp, const u32 status)
2478{
2479 if (status & INTR_RX_BUF_UNAVAIL_1) {
2480 /* Frame arrived, no free RX buffers available.
2481 * NOTE: we can get this on a link transition. */
2482 cas_post_rxds_ringN(cp, 1, 0);
2483 spin_lock(&cp->stat_lock[1]);
2484 cp->net_stats[1].rx_dropped++;
2485 spin_unlock(&cp->stat_lock[1]);
2486 }
2487
2488 if (status & INTR_RX_BUF_AE_1)
2489 cas_post_rxds_ringN(cp, 1, RX_DESC_RINGN_SIZE(1) -
2490 RX_AE_FREEN_VAL(1));
2491
2492 if (status & (INTR_RX_COMP_AF | INTR_RX_COMP_FULL))
2493 cas_post_rxcs_ringN(cp, 1);
2494}
2495
2496/* ring 2 handles a few more events than 3 and 4 */
2497static irqreturn_t cas_interrupt1(int irq, void *dev_id, struct pt_regs *regs)
2498{
2499 struct net_device *dev = dev_id;
2500 struct cas *cp = netdev_priv(dev);
2501 unsigned long flags;
2502 u32 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(1));
2503
2504 /* check for shared interrupt */
2505 if (status == 0)
2506 return IRQ_NONE;
2507
2508 spin_lock_irqsave(&cp->lock, flags);
2509 if (status & INTR_RX_DONE_ALT) { /* handle rx separately */
2510#ifdef USE_NAPI
2511 cas_mask_intr(cp);
2512 netif_rx_schedule(dev);
2513#else
2514 cas_rx_ringN(cp, 1, 0);
2515#endif
2516 status &= ~INTR_RX_DONE_ALT;
2517 }
2518 if (status)
2519 cas_handle_irq1(cp, status);
2520 spin_unlock_irqrestore(&cp->lock, flags);
2521 return IRQ_HANDLED;
2522}
2523#endif
2524
2525static inline void cas_handle_irq(struct net_device *dev,
2526 struct cas *cp, const u32 status)
2527{
2528 /* housekeeping interrupts */
2529 if (status & INTR_ERROR_MASK)
2530 cas_abnormal_irq(dev, cp, status);
2531
2532 if (status & INTR_RX_BUF_UNAVAIL) {
2533 /* Frame arrived, no free RX buffers available.
2534 * NOTE: we can get this on a link transition.
2535 */
2536 cas_post_rxds_ringN(cp, 0, 0);
2537 spin_lock(&cp->stat_lock[0]);
2538 cp->net_stats[0].rx_dropped++;
2539 spin_unlock(&cp->stat_lock[0]);
2540 } else if (status & INTR_RX_BUF_AE) {
2541 cas_post_rxds_ringN(cp, 0, RX_DESC_RINGN_SIZE(0) -
2542 RX_AE_FREEN_VAL(0));
2543 }
2544
2545 if (status & (INTR_RX_COMP_AF | INTR_RX_COMP_FULL))
2546 cas_post_rxcs_ringN(dev, cp, 0);
2547}
2548
2549static irqreturn_t cas_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2550{
2551 struct net_device *dev = dev_id;
2552 struct cas *cp = netdev_priv(dev);
2553 unsigned long flags;
2554 u32 status = readl(cp->regs + REG_INTR_STATUS);
2555
2556 if (status == 0)
2557 return IRQ_NONE;
2558
2559 spin_lock_irqsave(&cp->lock, flags);
2560 if (status & (INTR_TX_ALL | INTR_TX_INTME)) {
2561 cas_tx(dev, cp, status);
2562 status &= ~(INTR_TX_ALL | INTR_TX_INTME);
2563 }
2564
2565 if (status & INTR_RX_DONE) {
2566#ifdef USE_NAPI
2567 cas_mask_intr(cp);
2568 netif_rx_schedule(dev);
2569#else
2570 cas_rx_ringN(cp, 0, 0);
2571#endif
2572 status &= ~INTR_RX_DONE;
2573 }
2574
2575 if (status)
2576 cas_handle_irq(dev, cp, status);
2577 spin_unlock_irqrestore(&cp->lock, flags);
2578 return IRQ_HANDLED;
2579}
2580
2581
2582#ifdef USE_NAPI
2583static int cas_poll(struct net_device *dev, int *budget)
2584{
2585 struct cas *cp = netdev_priv(dev);
2586 int i, enable_intr, todo, credits;
2587 u32 status = readl(cp->regs + REG_INTR_STATUS);
2588 unsigned long flags;
2589
2590 spin_lock_irqsave(&cp->lock, flags);
2591 cas_tx(dev, cp, status);
2592 spin_unlock_irqrestore(&cp->lock, flags);
2593
2594 /* NAPI rx packets. we spread the credits across all of the
2595 * rxc rings
2596 */
2597 todo = min(*budget, dev->quota);
2598
2599 /* to make sure we're fair with the work we loop through each
2600 * ring N_RX_COMP_RING times with a request of
2601 * todo / N_RX_COMP_RINGS
2602 */
2603 enable_intr = 1;
2604 credits = 0;
2605 for (i = 0; i < N_RX_COMP_RINGS; i++) {
2606 int j;
2607 for (j = 0; j < N_RX_COMP_RINGS; j++) {
2608 credits += cas_rx_ringN(cp, j, todo / N_RX_COMP_RINGS);
2609 if (credits >= todo) {
2610 enable_intr = 0;
2611 goto rx_comp;
2612 }
2613 }
2614 }
2615
2616rx_comp:
2617 *budget -= credits;
2618 dev->quota -= credits;
2619
2620 /* final rx completion */
2621 spin_lock_irqsave(&cp->lock, flags);
2622 if (status)
2623 cas_handle_irq(dev, cp, status);
2624
2625#ifdef USE_PCI_INTB
2626 if (N_RX_COMP_RINGS > 1) {
2627 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(1));
2628 if (status)
2629 cas_handle_irq1(dev, cp, status);
2630 }
2631#endif
2632
2633#ifdef USE_PCI_INTC
2634 if (N_RX_COMP_RINGS > 2) {
2635 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(2));
2636 if (status)
2637 cas_handle_irqN(dev, cp, status, 2);
2638 }
2639#endif
2640
2641#ifdef USE_PCI_INTD
2642 if (N_RX_COMP_RINGS > 3) {
2643 status = readl(cp->regs + REG_PLUS_INTRN_STATUS(3));
2644 if (status)
2645 cas_handle_irqN(dev, cp, status, 3);
2646 }
2647#endif
2648 spin_unlock_irqrestore(&cp->lock, flags);
2649 if (enable_intr) {
2650 netif_rx_complete(dev);
2651 cas_unmask_intr(cp);
2652 return 0;
2653 }
2654 return 1;
2655}
2656#endif
2657
2658#ifdef CONFIG_NET_POLL_CONTROLLER
2659static void cas_netpoll(struct net_device *dev)
2660{
2661 struct cas *cp = netdev_priv(dev);
2662
2663 cas_disable_irq(cp, 0);
2664 cas_interrupt(cp->pdev->irq, dev, NULL);
2665 cas_enable_irq(cp, 0);
2666
2667#ifdef USE_PCI_INTB
2668 if (N_RX_COMP_RINGS > 1) {
2669 /* cas_interrupt1(); */
2670 }
2671#endif
2672#ifdef USE_PCI_INTC
2673 if (N_RX_COMP_RINGS > 2) {
2674 /* cas_interruptN(); */
2675 }
2676#endif
2677#ifdef USE_PCI_INTD
2678 if (N_RX_COMP_RINGS > 3) {
2679 /* cas_interruptN(); */
2680 }
2681#endif
2682}
2683#endif
2684
2685static void cas_tx_timeout(struct net_device *dev)
2686{
2687 struct cas *cp = netdev_priv(dev);
2688
2689 printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
2690 if (!cp->hw_running) {
2691 printk("%s: hrm.. hw not running!\n", dev->name);
2692 return;
2693 }
2694
2695 printk(KERN_ERR "%s: MIF_STATE[%08x]\n",
2696 dev->name, readl(cp->regs + REG_MIF_STATE_MACHINE));
2697
2698 printk(KERN_ERR "%s: MAC_STATE[%08x]\n",
2699 dev->name, readl(cp->regs + REG_MAC_STATE_MACHINE));
2700
2701 printk(KERN_ERR "%s: TX_STATE[%08x:%08x:%08x] "
2702 "FIFO[%08x:%08x:%08x] SM1[%08x] SM2[%08x]\n",
2703 dev->name,
2704 readl(cp->regs + REG_TX_CFG),
2705 readl(cp->regs + REG_MAC_TX_STATUS),
2706 readl(cp->regs + REG_MAC_TX_CFG),
2707 readl(cp->regs + REG_TX_FIFO_PKT_CNT),
2708 readl(cp->regs + REG_TX_FIFO_WRITE_PTR),
2709 readl(cp->regs + REG_TX_FIFO_READ_PTR),
2710 readl(cp->regs + REG_TX_SM_1),
2711 readl(cp->regs + REG_TX_SM_2));
2712
2713 printk(KERN_ERR "%s: RX_STATE[%08x:%08x:%08x]\n",
2714 dev->name,
2715 readl(cp->regs + REG_RX_CFG),
2716 readl(cp->regs + REG_MAC_RX_STATUS),
2717 readl(cp->regs + REG_MAC_RX_CFG));
2718
2719 printk(KERN_ERR "%s: HP_STATE[%08x:%08x:%08x:%08x]\n",
2720 dev->name,
2721 readl(cp->regs + REG_HP_STATE_MACHINE),
2722 readl(cp->regs + REG_HP_STATUS0),
2723 readl(cp->regs + REG_HP_STATUS1),
2724 readl(cp->regs + REG_HP_STATUS2));
2725
2726#if 1
2727 atomic_inc(&cp->reset_task_pending);
2728 atomic_inc(&cp->reset_task_pending_all);
2729 schedule_work(&cp->reset_task);
2730#else
2731 atomic_set(&cp->reset_task_pending, CAS_RESET_ALL);
2732 schedule_work(&cp->reset_task);
2733#endif
2734}
2735
2736static inline int cas_intme(int ring, int entry)
2737{
2738 /* Algorithm: IRQ every 1/2 of descriptors. */
2739 if (!(entry & ((TX_DESC_RINGN_SIZE(ring) >> 1) - 1)))
2740 return 1;
2741 return 0;
2742}
2743
2744
2745static void cas_write_txd(struct cas *cp, int ring, int entry,
2746 dma_addr_t mapping, int len, u64 ctrl, int last)
2747{
2748 struct cas_tx_desc *txd = cp->init_txds[ring] + entry;
2749
2750 ctrl |= CAS_BASE(TX_DESC_BUFLEN, len);
2751 if (cas_intme(ring, entry))
2752 ctrl |= TX_DESC_INTME;
2753 if (last)
2754 ctrl |= TX_DESC_EOF;
2755 txd->control = cpu_to_le64(ctrl);
2756 txd->buffer = cpu_to_le64(mapping);
2757}
2758
2759static inline void *tx_tiny_buf(struct cas *cp, const int ring,
2760 const int entry)
2761{
2762 return cp->tx_tiny_bufs[ring] + TX_TINY_BUF_LEN*entry;
2763}
2764
2765static inline dma_addr_t tx_tiny_map(struct cas *cp, const int ring,
2766 const int entry, const int tentry)
2767{
2768 cp->tx_tiny_use[ring][tentry].nbufs++;
2769 cp->tx_tiny_use[ring][entry].used = 1;
2770 return cp->tx_tiny_dvma[ring] + TX_TINY_BUF_LEN*entry;
2771}
2772
2773static inline int cas_xmit_tx_ringN(struct cas *cp, int ring,
2774 struct sk_buff *skb)
2775{
2776 struct net_device *dev = cp->dev;
2777 int entry, nr_frags, frag, tabort, tentry;
2778 dma_addr_t mapping;
2779 unsigned long flags;
2780 u64 ctrl;
2781 u32 len;
2782
2783 spin_lock_irqsave(&cp->tx_lock[ring], flags);
2784
2785 /* This is a hard error, log it. */
2786 if (TX_BUFFS_AVAIL(cp, ring) <=
2787 CAS_TABORT(cp)*(skb_shinfo(skb)->nr_frags + 1)) {
2788 netif_stop_queue(dev);
2789 spin_unlock_irqrestore(&cp->tx_lock[ring], flags);
2790 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
2791 "queue awake!\n", dev->name);
2792 return 1;
2793 }
2794
2795 ctrl = 0;
2796 if (skb->ip_summed == CHECKSUM_HW) {
2797 u64 csum_start_off, csum_stuff_off;
2798
2799 csum_start_off = (u64) (skb->h.raw - skb->data);
2800 csum_stuff_off = (u64) ((skb->h.raw + skb->csum) - skb->data);
2801
2802 ctrl = TX_DESC_CSUM_EN |
2803 CAS_BASE(TX_DESC_CSUM_START, csum_start_off) |
2804 CAS_BASE(TX_DESC_CSUM_STUFF, csum_stuff_off);
2805 }
2806
2807 entry = cp->tx_new[ring];
2808 cp->tx_skbs[ring][entry] = skb;
2809
2810 nr_frags = skb_shinfo(skb)->nr_frags;
2811 len = skb_headlen(skb);
2812 mapping = pci_map_page(cp->pdev, virt_to_page(skb->data),
2813 offset_in_page(skb->data), len,
2814 PCI_DMA_TODEVICE);
2815
2816 tentry = entry;
2817 tabort = cas_calc_tabort(cp, (unsigned long) skb->data, len);
2818 if (unlikely(tabort)) {
2819 /* NOTE: len is always > tabort */
2820 cas_write_txd(cp, ring, entry, mapping, len - tabort,
2821 ctrl | TX_DESC_SOF, 0);
2822 entry = TX_DESC_NEXT(ring, entry);
2823
2824 memcpy(tx_tiny_buf(cp, ring, entry), skb->data +
2825 len - tabort, tabort);
2826 mapping = tx_tiny_map(cp, ring, entry, tentry);
2827 cas_write_txd(cp, ring, entry, mapping, tabort, ctrl,
2828 (nr_frags == 0));
2829 } else {
2830 cas_write_txd(cp, ring, entry, mapping, len, ctrl |
2831 TX_DESC_SOF, (nr_frags == 0));
2832 }
2833 entry = TX_DESC_NEXT(ring, entry);
2834
2835 for (frag = 0; frag < nr_frags; frag++) {
2836 skb_frag_t *fragp = &skb_shinfo(skb)->frags[frag];
2837
2838 len = fragp->size;
2839 mapping = pci_map_page(cp->pdev, fragp->page,
2840 fragp->page_offset, len,
2841 PCI_DMA_TODEVICE);
2842
2843 tabort = cas_calc_tabort(cp, fragp->page_offset, len);
2844 if (unlikely(tabort)) {
2845 void *addr;
2846
2847 /* NOTE: len is always > tabort */
2848 cas_write_txd(cp, ring, entry, mapping, len - tabort,
2849 ctrl, 0);
2850 entry = TX_DESC_NEXT(ring, entry);
2851
2852 addr = cas_page_map(fragp->page);
2853 memcpy(tx_tiny_buf(cp, ring, entry),
2854 addr + fragp->page_offset + len - tabort,
2855 tabort);
2856 cas_page_unmap(addr);
2857 mapping = tx_tiny_map(cp, ring, entry, tentry);
2858 len = tabort;
2859 }
2860
2861 cas_write_txd(cp, ring, entry, mapping, len, ctrl,
2862 (frag + 1 == nr_frags));
2863 entry = TX_DESC_NEXT(ring, entry);
2864 }
2865
2866 cp->tx_new[ring] = entry;
2867 if (TX_BUFFS_AVAIL(cp, ring) <= CAS_TABORT(cp)*(MAX_SKB_FRAGS + 1))
2868 netif_stop_queue(dev);
2869
2870 if (netif_msg_tx_queued(cp))
2871 printk(KERN_DEBUG "%s: tx[%d] queued, slot %d, skblen %d, "
2872 "avail %d\n",
2873 dev->name, ring, entry, skb->len,
2874 TX_BUFFS_AVAIL(cp, ring));
2875 writel(entry, cp->regs + REG_TX_KICKN(ring));
2876 spin_unlock_irqrestore(&cp->tx_lock[ring], flags);
2877 return 0;
2878}
2879
2880static int cas_start_xmit(struct sk_buff *skb, struct net_device *dev)
2881{
2882 struct cas *cp = netdev_priv(dev);
2883
2884 /* this is only used as a load-balancing hint, so it doesn't
2885 * need to be SMP safe
2886 */
2887 static int ring;
2888
2889 skb = skb_padto(skb, cp->min_frame_size);
2890 if (!skb)
2891 return 0;
2892
2893 /* XXX: we need some higher-level QoS hooks to steer packets to
2894 * individual queues.
2895 */
2896 if (cas_xmit_tx_ringN(cp, ring++ & N_TX_RINGS_MASK, skb))
2897 return 1;
2898 dev->trans_start = jiffies;
2899 return 0;
2900}
2901
2902static void cas_init_tx_dma(struct cas *cp)
2903{
2904 u64 desc_dma = cp->block_dvma;
2905 unsigned long off;
2906 u32 val;
2907 int i;
2908
2909 /* set up tx completion writeback registers. must be 8-byte aligned */
2910#ifdef USE_TX_COMPWB
2911 off = offsetof(struct cas_init_block, tx_compwb);
2912 writel((desc_dma + off) >> 32, cp->regs + REG_TX_COMPWB_DB_HI);
2913 writel((desc_dma + off) & 0xffffffff, cp->regs + REG_TX_COMPWB_DB_LOW);
2914#endif
2915
2916 /* enable completion writebacks, enable paced mode,
2917 * disable read pipe, and disable pre-interrupt compwbs
2918 */
2919 val = TX_CFG_COMPWB_Q1 | TX_CFG_COMPWB_Q2 |
2920 TX_CFG_COMPWB_Q3 | TX_CFG_COMPWB_Q4 |
2921 TX_CFG_DMA_RDPIPE_DIS | TX_CFG_PACED_MODE |
2922 TX_CFG_INTR_COMPWB_DIS;
2923
2924 /* write out tx ring info and tx desc bases */
2925 for (i = 0; i < MAX_TX_RINGS; i++) {
2926 off = (unsigned long) cp->init_txds[i] -
2927 (unsigned long) cp->init_block;
2928
2929 val |= CAS_TX_RINGN_BASE(i);
2930 writel((desc_dma + off) >> 32, cp->regs + REG_TX_DBN_HI(i));
2931 writel((desc_dma + off) & 0xffffffff, cp->regs +
2932 REG_TX_DBN_LOW(i));
2933 /* don't zero out the kick register here as the system
2934 * will wedge
2935 */
2936 }
2937 writel(val, cp->regs + REG_TX_CFG);
2938
2939 /* program max burst sizes. these numbers should be different
2940 * if doing QoS.
2941 */
2942#ifdef USE_QOS
2943 writel(0x800, cp->regs + REG_TX_MAXBURST_0);
2944 writel(0x1600, cp->regs + REG_TX_MAXBURST_1);
2945 writel(0x2400, cp->regs + REG_TX_MAXBURST_2);
2946 writel(0x4800, cp->regs + REG_TX_MAXBURST_3);
2947#else
2948 writel(0x800, cp->regs + REG_TX_MAXBURST_0);
2949 writel(0x800, cp->regs + REG_TX_MAXBURST_1);
2950 writel(0x800, cp->regs + REG_TX_MAXBURST_2);
2951 writel(0x800, cp->regs + REG_TX_MAXBURST_3);
2952#endif
2953}
2954
2955/* Must be invoked under cp->lock. */
2956static inline void cas_init_dma(struct cas *cp)
2957{
2958 cas_init_tx_dma(cp);
2959 cas_init_rx_dma(cp);
2960}
2961
2962/* Must be invoked under cp->lock. */
2963static u32 cas_setup_multicast(struct cas *cp)
2964{
2965 u32 rxcfg = 0;
2966 int i;
2967
2968 if (cp->dev->flags & IFF_PROMISC) {
2969 rxcfg |= MAC_RX_CFG_PROMISC_EN;
2970
2971 } else if (cp->dev->flags & IFF_ALLMULTI) {
2972 for (i=0; i < 16; i++)
2973 writel(0xFFFF, cp->regs + REG_MAC_HASH_TABLEN(i));
2974 rxcfg |= MAC_RX_CFG_HASH_FILTER_EN;
2975
2976 } else {
2977 u16 hash_table[16];
2978 u32 crc;
2979 struct dev_mc_list *dmi = cp->dev->mc_list;
2980 int i;
2981
2982 /* use the alternate mac address registers for the
2983 * first 15 multicast addresses
2984 */
2985 for (i = 1; i <= CAS_MC_EXACT_MATCH_SIZE; i++) {
2986 if (!dmi) {
2987 writel(0x0, cp->regs + REG_MAC_ADDRN(i*3 + 0));
2988 writel(0x0, cp->regs + REG_MAC_ADDRN(i*3 + 1));
2989 writel(0x0, cp->regs + REG_MAC_ADDRN(i*3 + 2));
2990 continue;
2991 }
2992 writel((dmi->dmi_addr[4] << 8) | dmi->dmi_addr[5],
2993 cp->regs + REG_MAC_ADDRN(i*3 + 0));
2994 writel((dmi->dmi_addr[2] << 8) | dmi->dmi_addr[3],
2995 cp->regs + REG_MAC_ADDRN(i*3 + 1));
2996 writel((dmi->dmi_addr[0] << 8) | dmi->dmi_addr[1],
2997 cp->regs + REG_MAC_ADDRN(i*3 + 2));
2998 dmi = dmi->next;
2999 }
3000
3001 /* use hw hash table for the next series of
3002 * multicast addresses
3003 */
3004 memset(hash_table, 0, sizeof(hash_table));
3005 while (dmi) {
3006 crc = ether_crc_le(ETH_ALEN, dmi->dmi_addr);
3007 crc >>= 24;
3008 hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
3009 dmi = dmi->next;
3010 }
3011 for (i=0; i < 16; i++)
3012 writel(hash_table[i], cp->regs +
3013 REG_MAC_HASH_TABLEN(i));
3014 rxcfg |= MAC_RX_CFG_HASH_FILTER_EN;
3015 }
3016
3017 return rxcfg;
3018}
3019
3020/* must be invoked under cp->stat_lock[N_TX_RINGS] */
3021static void cas_clear_mac_err(struct cas *cp)
3022{
3023 writel(0, cp->regs + REG_MAC_COLL_NORMAL);
3024 writel(0, cp->regs + REG_MAC_COLL_FIRST);
3025 writel(0, cp->regs + REG_MAC_COLL_EXCESS);
3026 writel(0, cp->regs + REG_MAC_COLL_LATE);
3027 writel(0, cp->regs + REG_MAC_TIMER_DEFER);
3028 writel(0, cp->regs + REG_MAC_ATTEMPTS_PEAK);
3029 writel(0, cp->regs + REG_MAC_RECV_FRAME);
3030 writel(0, cp->regs + REG_MAC_LEN_ERR);
3031 writel(0, cp->regs + REG_MAC_ALIGN_ERR);
3032 writel(0, cp->regs + REG_MAC_FCS_ERR);
3033 writel(0, cp->regs + REG_MAC_RX_CODE_ERR);
3034}
3035
3036
3037static void cas_mac_reset(struct cas *cp)
3038{
3039 int i;
3040
3041 /* do both TX and RX reset */
3042 writel(0x1, cp->regs + REG_MAC_TX_RESET);
3043 writel(0x1, cp->regs + REG_MAC_RX_RESET);
3044
3045 /* wait for TX */
3046 i = STOP_TRIES;
3047 while (i-- > 0) {
3048 if (readl(cp->regs + REG_MAC_TX_RESET) == 0)
3049 break;
3050 udelay(10);
3051 }
3052
3053 /* wait for RX */
3054 i = STOP_TRIES;
3055 while (i-- > 0) {
3056 if (readl(cp->regs + REG_MAC_RX_RESET) == 0)
3057 break;
3058 udelay(10);
3059 }
3060
3061 if (readl(cp->regs + REG_MAC_TX_RESET) |
3062 readl(cp->regs + REG_MAC_RX_RESET))
3063 printk(KERN_ERR "%s: mac tx[%d]/rx[%d] reset failed [%08x]\n",
3064 cp->dev->name, readl(cp->regs + REG_MAC_TX_RESET),
3065 readl(cp->regs + REG_MAC_RX_RESET),
3066 readl(cp->regs + REG_MAC_STATE_MACHINE));
3067}
3068
3069
3070/* Must be invoked under cp->lock. */
3071static void cas_init_mac(struct cas *cp)
3072{
3073 unsigned char *e = &cp->dev->dev_addr[0];
3074 int i;
3075#ifdef CONFIG_CASSINI_MULTICAST_REG_WRITE
3076 u32 rxcfg;
3077#endif
3078 cas_mac_reset(cp);
3079
3080 /* setup core arbitration weight register */
3081 writel(CAWR_RR_DIS, cp->regs + REG_CAWR);
3082
3083 /* XXX Use pci_dma_burst_advice() */
3084#if !defined(CONFIG_SPARC64) && !defined(CONFIG_ALPHA)
3085 /* set the infinite burst register for chips that don't have
3086 * pci issues.
3087 */
3088 if ((cp->cas_flags & CAS_FLAG_TARGET_ABORT) == 0)
3089 writel(INF_BURST_EN, cp->regs + REG_INF_BURST);
3090#endif
3091
3092 writel(0x1BF0, cp->regs + REG_MAC_SEND_PAUSE);
3093
3094 writel(0x00, cp->regs + REG_MAC_IPG0);
3095 writel(0x08, cp->regs + REG_MAC_IPG1);
3096 writel(0x04, cp->regs + REG_MAC_IPG2);
3097
3098 /* change later for 802.3z */
3099 writel(0x40, cp->regs + REG_MAC_SLOT_TIME);
3100
3101 /* min frame + FCS */
3102 writel(ETH_ZLEN + 4, cp->regs + REG_MAC_FRAMESIZE_MIN);
3103
3104 /* Ethernet payload + header + FCS + optional VLAN tag. NOTE: we
3105 * specify the maximum frame size to prevent RX tag errors on
3106 * oversized frames.
3107 */
3108 writel(CAS_BASE(MAC_FRAMESIZE_MAX_BURST, 0x2000) |
3109 CAS_BASE(MAC_FRAMESIZE_MAX_FRAME,
3110 (CAS_MAX_MTU + ETH_HLEN + 4 + 4)),
3111 cp->regs + REG_MAC_FRAMESIZE_MAX);
3112
3113 /* NOTE: crc_size is used as a surrogate for half-duplex.
3114 * workaround saturn half-duplex issue by increasing preamble
3115 * size to 65 bytes.
3116 */
3117 if ((cp->cas_flags & CAS_FLAG_SATURN) && cp->crc_size)
3118 writel(0x41, cp->regs + REG_MAC_PA_SIZE);
3119 else
3120 writel(0x07, cp->regs + REG_MAC_PA_SIZE);
3121 writel(0x04, cp->regs + REG_MAC_JAM_SIZE);
3122 writel(0x10, cp->regs + REG_MAC_ATTEMPT_LIMIT);
3123 writel(0x8808, cp->regs + REG_MAC_CTRL_TYPE);
3124
3125 writel((e[5] | (e[4] << 8)) & 0x3ff, cp->regs + REG_MAC_RANDOM_SEED);
3126
3127 writel(0, cp->regs + REG_MAC_ADDR_FILTER0);
3128 writel(0, cp->regs + REG_MAC_ADDR_FILTER1);
3129 writel(0, cp->regs + REG_MAC_ADDR_FILTER2);
3130 writel(0, cp->regs + REG_MAC_ADDR_FILTER2_1_MASK);
3131 writel(0, cp->regs + REG_MAC_ADDR_FILTER0_MASK);
3132
3133 /* setup mac address in perfect filter array */
3134 for (i = 0; i < 45; i++)
3135 writel(0x0, cp->regs + REG_MAC_ADDRN(i));
3136
3137 writel((e[4] << 8) | e[5], cp->regs + REG_MAC_ADDRN(0));
3138 writel((e[2] << 8) | e[3], cp->regs + REG_MAC_ADDRN(1));
3139 writel((e[0] << 8) | e[1], cp->regs + REG_MAC_ADDRN(2));
3140
3141 writel(0x0001, cp->regs + REG_MAC_ADDRN(42));
3142 writel(0xc200, cp->regs + REG_MAC_ADDRN(43));
3143 writel(0x0180, cp->regs + REG_MAC_ADDRN(44));
3144
3145#ifndef CONFIG_CASSINI_MULTICAST_REG_WRITE
3146 cp->mac_rx_cfg = cas_setup_multicast(cp);
3147#else
3148 /* WTZ: Do what Adrian did in cas_set_multicast. Doing
3149 * a writel does not seem to be necessary because Cassini
3150 * seems to preserve the configuration when we do the reset.
3151 * If the chip is in trouble, though, it is not clear if we
3152 * can really count on this behavior. cas_set_multicast uses
3153 * spin_lock_irqsave, but we are called only in cas_init_hw and
3154 * cas_init_hw is protected by cas_lock_all, which calls
3155 * spin_lock_irq (so it doesn't need to save the flags, and
3156 * we should be OK for the writel, as that is the only
3157 * difference).
3158 */
3159 cp->mac_rx_cfg = rxcfg = cas_setup_multicast(cp);
3160 writel(rxcfg, cp->regs + REG_MAC_RX_CFG);
3161#endif
3162 spin_lock(&cp->stat_lock[N_TX_RINGS]);
3163 cas_clear_mac_err(cp);
3164 spin_unlock(&cp->stat_lock[N_TX_RINGS]);
3165
3166 /* Setup MAC interrupts. We want to get all of the interesting
3167 * counter expiration events, but we do not want to hear about
3168 * normal rx/tx as the DMA engine tells us that.
3169 */
3170 writel(MAC_TX_FRAME_XMIT, cp->regs + REG_MAC_TX_MASK);
3171 writel(MAC_RX_FRAME_RECV, cp->regs + REG_MAC_RX_MASK);
3172
3173 /* Don't enable even the PAUSE interrupts for now, we
3174 * make no use of those events other than to record them.
3175 */
3176 writel(0xffffffff, cp->regs + REG_MAC_CTRL_MASK);
3177}
3178
3179/* Must be invoked under cp->lock. */
3180static void cas_init_pause_thresholds(struct cas *cp)
3181{
3182 /* Calculate pause thresholds. Setting the OFF threshold to the
3183 * full RX fifo size effectively disables PAUSE generation
3184 */
3185 if (cp->rx_fifo_size <= (2 * 1024)) {
3186 cp->rx_pause_off = cp->rx_pause_on = cp->rx_fifo_size;
3187 } else {
3188 int max_frame = (cp->dev->mtu + ETH_HLEN + 4 + 4 + 64) & ~63;
3189 if (max_frame * 3 > cp->rx_fifo_size) {
3190 cp->rx_pause_off = 7104;
3191 cp->rx_pause_on = 960;
3192 } else {
3193 int off = (cp->rx_fifo_size - (max_frame * 2));
3194 int on = off - max_frame;
3195 cp->rx_pause_off = off;
3196 cp->rx_pause_on = on;
3197 }
3198 }
3199}
3200
3201static int cas_vpd_match(const void __iomem *p, const char *str)
3202{
3203 int len = strlen(str) + 1;
3204 int i;
3205
3206 for (i = 0; i < len; i++) {
3207 if (readb(p + i) != str[i])
3208 return 0;
3209 }
3210 return 1;
3211}
3212
3213
3214/* get the mac address by reading the vpd information in the rom.
3215 * also get the phy type and determine if there's an entropy generator.
3216 * NOTE: this is a bit convoluted for the following reasons:
3217 * 1) vpd info has order-dependent mac addresses for multinic cards
3218 * 2) the only way to determine the nic order is to use the slot
3219 * number.
3220 * 3) fiber cards don't have bridges, so their slot numbers don't
3221 * mean anything.
3222 * 4) we don't actually know we have a fiber card until after
3223 * the mac addresses are parsed.
3224 */
3225static int cas_get_vpd_info(struct cas *cp, unsigned char *dev_addr,
3226 const int offset)
3227{
3228 void __iomem *p = cp->regs + REG_EXPANSION_ROM_RUN_START;
3229 void __iomem *base, *kstart;
3230 int i, len;
3231 int found = 0;
3232#define VPD_FOUND_MAC 0x01
3233#define VPD_FOUND_PHY 0x02
3234
3235 int phy_type = CAS_PHY_MII_MDIO0; /* default phy type */
3236 int mac_off = 0;
3237
3238 /* give us access to the PROM */
3239 writel(BIM_LOCAL_DEV_PROM | BIM_LOCAL_DEV_PAD,
3240 cp->regs + REG_BIM_LOCAL_DEV_EN);
3241
3242 /* check for an expansion rom */
3243 if (readb(p) != 0x55 || readb(p + 1) != 0xaa)
3244 goto use_random_mac_addr;
3245
3246 /* search for beginning of vpd */
3247 base = NULL;
3248 for (i = 2; i < EXPANSION_ROM_SIZE; i++) {
3249 /* check for PCIR */
3250 if ((readb(p + i + 0) == 0x50) &&
3251 (readb(p + i + 1) == 0x43) &&
3252 (readb(p + i + 2) == 0x49) &&
3253 (readb(p + i + 3) == 0x52)) {
3254 base = p + (readb(p + i + 8) |
3255 (readb(p + i + 9) << 8));
3256 break;
3257 }
3258 }
3259
3260 if (!base || (readb(base) != 0x82))
3261 goto use_random_mac_addr;
3262
3263 i = (readb(base + 1) | (readb(base + 2) << 8)) + 3;
3264 while (i < EXPANSION_ROM_SIZE) {
3265 if (readb(base + i) != 0x90) /* no vpd found */
3266 goto use_random_mac_addr;
3267
3268 /* found a vpd field */
3269 len = readb(base + i + 1) | (readb(base + i + 2) << 8);
3270
3271 /* extract keywords */
3272 kstart = base + i + 3;
3273 p = kstart;
3274 while ((p - kstart) < len) {
3275 int klen = readb(p + 2);
3276 int j;
3277 char type;
3278
3279 p += 3;
3280
3281 /* look for the following things:
3282 * -- correct length == 29
3283 * 3 (type) + 2 (size) +
3284 * 18 (strlen("local-mac-address") + 1) +
3285 * 6 (mac addr)
3286 * -- VPD Instance 'I'
3287 * -- VPD Type Bytes 'B'
3288 * -- VPD data length == 6
3289 * -- property string == local-mac-address
3290 *
3291 * -- correct length == 24
3292 * 3 (type) + 2 (size) +
3293 * 12 (strlen("entropy-dev") + 1) +
3294 * 7 (strlen("vms110") + 1)
3295 * -- VPD Instance 'I'
3296 * -- VPD Type String 'B'
3297 * -- VPD data length == 7
3298 * -- property string == entropy-dev
3299 *
3300 * -- correct length == 18
3301 * 3 (type) + 2 (size) +
3302 * 9 (strlen("phy-type") + 1) +
3303 * 4 (strlen("pcs") + 1)
3304 * -- VPD Instance 'I'
3305 * -- VPD Type String 'S'
3306 * -- VPD data length == 4
3307 * -- property string == phy-type
3308 *
3309 * -- correct length == 23
3310 * 3 (type) + 2 (size) +
3311 * 14 (strlen("phy-interface") + 1) +
3312 * 4 (strlen("pcs") + 1)
3313 * -- VPD Instance 'I'
3314 * -- VPD Type String 'S'
3315 * -- VPD data length == 4
3316 * -- property string == phy-interface
3317 */
3318 if (readb(p) != 'I')
3319 goto next;
3320
3321 /* finally, check string and length */
3322 type = readb(p + 3);
3323 if (type == 'B') {
3324 if ((klen == 29) && readb(p + 4) == 6 &&
3325 cas_vpd_match(p + 5,
3326 "local-mac-address")) {
3327 if (mac_off++ > offset)
3328 goto next;
3329
3330 /* set mac address */
3331 for (j = 0; j < 6; j++)
3332 dev_addr[j] =
3333 readb(p + 23 + j);
3334 goto found_mac;
3335 }
3336 }
3337
3338 if (type != 'S')
3339 goto next;
3340
3341#ifdef USE_ENTROPY_DEV
3342 if ((klen == 24) &&
3343 cas_vpd_match(p + 5, "entropy-dev") &&
3344 cas_vpd_match(p + 17, "vms110")) {
3345 cp->cas_flags |= CAS_FLAG_ENTROPY_DEV;
3346 goto next;
3347 }
3348#endif
3349
3350 if (found & VPD_FOUND_PHY)
3351 goto next;
3352
3353 if ((klen == 18) && readb(p + 4) == 4 &&
3354 cas_vpd_match(p + 5, "phy-type")) {
3355 if (cas_vpd_match(p + 14, "pcs")) {
3356 phy_type = CAS_PHY_SERDES;
3357 goto found_phy;
3358 }
3359 }
3360
3361 if ((klen == 23) && readb(p + 4) == 4 &&
3362 cas_vpd_match(p + 5, "phy-interface")) {
3363 if (cas_vpd_match(p + 19, "pcs")) {
3364 phy_type = CAS_PHY_SERDES;
3365 goto found_phy;
3366 }
3367 }
3368found_mac:
3369 found |= VPD_FOUND_MAC;
3370 goto next;
3371
3372found_phy:
3373 found |= VPD_FOUND_PHY;
3374
3375next:
3376 p += klen;
3377 }
3378 i += len + 3;
3379 }
3380
3381use_random_mac_addr:
3382 if (found & VPD_FOUND_MAC)
3383 goto done;
3384
3385 /* Sun MAC prefix then 3 random bytes. */
3386 printk(PFX "MAC address not found in ROM VPD\n");
3387 dev_addr[0] = 0x08;
3388 dev_addr[1] = 0x00;
3389 dev_addr[2] = 0x20;
3390 get_random_bytes(dev_addr + 3, 3);
3391
3392done:
3393 writel(0, cp->regs + REG_BIM_LOCAL_DEV_EN);
3394 return phy_type;
3395}
3396
3397/* check pci invariants */
3398static void cas_check_pci_invariants(struct cas *cp)
3399{
3400 struct pci_dev *pdev = cp->pdev;
3401 u8 rev;
3402
3403 cp->cas_flags = 0;
3404 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
3405 if ((pdev->vendor == PCI_VENDOR_ID_SUN) &&
3406 (pdev->device == PCI_DEVICE_ID_SUN_CASSINI)) {
3407 if (rev >= CAS_ID_REVPLUS)
3408 cp->cas_flags |= CAS_FLAG_REG_PLUS;
3409 if (rev < CAS_ID_REVPLUS02u)
3410 cp->cas_flags |= CAS_FLAG_TARGET_ABORT;
3411
3412 /* Original Cassini supports HW CSUM, but it's not
3413 * enabled by default as it can trigger TX hangs.
3414 */
3415 if (rev < CAS_ID_REV2)
3416 cp->cas_flags |= CAS_FLAG_NO_HW_CSUM;
3417 } else {
3418 /* Only sun has original cassini chips. */
3419 cp->cas_flags |= CAS_FLAG_REG_PLUS;
3420
3421 /* We use a flag because the same phy might be externally
3422 * connected.
3423 */
3424 if ((pdev->vendor == PCI_VENDOR_ID_NS) &&
3425 (pdev->device == PCI_DEVICE_ID_NS_SATURN))
3426 cp->cas_flags |= CAS_FLAG_SATURN;
3427 }
3428}
3429
3430
3431static int cas_check_invariants(struct cas *cp)
3432{
3433 struct pci_dev *pdev = cp->pdev;
3434 u32 cfg;
3435 int i;
3436
3437 /* get page size for rx buffers. */
3438 cp->page_order = 0;
3439#ifdef USE_PAGE_ORDER
3440 if (PAGE_SHIFT < CAS_JUMBO_PAGE_SHIFT) {
3441 /* see if we can allocate larger pages */
3442 struct page *page = alloc_pages(GFP_ATOMIC,
3443 CAS_JUMBO_PAGE_SHIFT -
3444 PAGE_SHIFT);
3445 if (page) {
3446 __free_pages(page, CAS_JUMBO_PAGE_SHIFT - PAGE_SHIFT);
3447 cp->page_order = CAS_JUMBO_PAGE_SHIFT - PAGE_SHIFT;
3448 } else {
3449 printk(PFX "MTU limited to %d bytes\n", CAS_MAX_MTU);
3450 }
3451 }
3452#endif
3453 cp->page_size = (PAGE_SIZE << cp->page_order);
3454
3455 /* Fetch the FIFO configurations. */
3456 cp->tx_fifo_size = readl(cp->regs + REG_TX_FIFO_SIZE) * 64;
3457 cp->rx_fifo_size = RX_FIFO_SIZE;
3458
3459 /* finish phy determination. MDIO1 takes precedence over MDIO0 if
3460 * they're both connected.
3461 */
3462 cp->phy_type = cas_get_vpd_info(cp, cp->dev->dev_addr,
3463 PCI_SLOT(pdev->devfn));
3464 if (cp->phy_type & CAS_PHY_SERDES) {
3465 cp->cas_flags |= CAS_FLAG_1000MB_CAP;
3466 return 0; /* no more checking needed */
3467 }
3468
3469 /* MII */
3470 cfg = readl(cp->regs + REG_MIF_CFG);
3471 if (cfg & MIF_CFG_MDIO_1) {
3472 cp->phy_type = CAS_PHY_MII_MDIO1;
3473 } else if (cfg & MIF_CFG_MDIO_0) {
3474 cp->phy_type = CAS_PHY_MII_MDIO0;
3475 }
3476
3477 cas_mif_poll(cp, 0);
3478 writel(PCS_DATAPATH_MODE_MII, cp->regs + REG_PCS_DATAPATH_MODE);
3479
3480 for (i = 0; i < 32; i++) {
3481 u32 phy_id;
3482 int j;
3483
3484 for (j = 0; j < 3; j++) {
3485 cp->phy_addr = i;
3486 phy_id = cas_phy_read(cp, MII_PHYSID1) << 16;
3487 phy_id |= cas_phy_read(cp, MII_PHYSID2);
3488 if (phy_id && (phy_id != 0xFFFFFFFF)) {
3489 cp->phy_id = phy_id;
3490 goto done;
3491 }
3492 }
3493 }
3494 printk(KERN_ERR PFX "MII phy did not respond [%08x]\n",
3495 readl(cp->regs + REG_MIF_STATE_MACHINE));
3496 return -1;
3497
3498done:
3499 /* see if we can do gigabit */
3500 cfg = cas_phy_read(cp, MII_BMSR);
3501 if ((cfg & CAS_BMSR_1000_EXTEND) &&
3502 cas_phy_read(cp, CAS_MII_1000_EXTEND))
3503 cp->cas_flags |= CAS_FLAG_1000MB_CAP;
3504 return 0;
3505}
3506
3507/* Must be invoked under cp->lock. */
3508static inline void cas_start_dma(struct cas *cp)
3509{
3510 int i;
3511 u32 val;
3512 int txfailed = 0;
3513
3514 /* enable dma */
3515 val = readl(cp->regs + REG_TX_CFG) | TX_CFG_DMA_EN;
3516 writel(val, cp->regs + REG_TX_CFG);
3517 val = readl(cp->regs + REG_RX_CFG) | RX_CFG_DMA_EN;
3518 writel(val, cp->regs + REG_RX_CFG);
3519
3520 /* enable the mac */
3521 val = readl(cp->regs + REG_MAC_TX_CFG) | MAC_TX_CFG_EN;
3522 writel(val, cp->regs + REG_MAC_TX_CFG);
3523 val = readl(cp->regs + REG_MAC_RX_CFG) | MAC_RX_CFG_EN;
3524 writel(val, cp->regs + REG_MAC_RX_CFG);
3525
3526 i = STOP_TRIES;
3527 while (i-- > 0) {
3528 val = readl(cp->regs + REG_MAC_TX_CFG);
3529 if ((val & MAC_TX_CFG_EN))
3530 break;
3531 udelay(10);
3532 }
3533 if (i < 0) txfailed = 1;
3534 i = STOP_TRIES;
3535 while (i-- > 0) {
3536 val = readl(cp->regs + REG_MAC_RX_CFG);
3537 if ((val & MAC_RX_CFG_EN)) {
3538 if (txfailed) {
3539 printk(KERN_ERR
3540 "%s: enabling mac failed [tx:%08x:%08x].\n",
3541 cp->dev->name,
3542 readl(cp->regs + REG_MIF_STATE_MACHINE),
3543 readl(cp->regs + REG_MAC_STATE_MACHINE));
3544 }
3545 goto enable_rx_done;
3546 }
3547 udelay(10);
3548 }
3549 printk(KERN_ERR "%s: enabling mac failed [%s:%08x:%08x].\n",
3550 cp->dev->name,
3551 (txfailed? "tx,rx":"rx"),
3552 readl(cp->regs + REG_MIF_STATE_MACHINE),
3553 readl(cp->regs + REG_MAC_STATE_MACHINE));
3554
3555enable_rx_done:
3556 cas_unmask_intr(cp); /* enable interrupts */
3557 writel(RX_DESC_RINGN_SIZE(0) - 4, cp->regs + REG_RX_KICK);
3558 writel(0, cp->regs + REG_RX_COMP_TAIL);
3559
3560 if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
3561 if (N_RX_DESC_RINGS > 1)
3562 writel(RX_DESC_RINGN_SIZE(1) - 4,
3563 cp->regs + REG_PLUS_RX_KICK1);
3564
3565 for (i = 1; i < N_RX_COMP_RINGS; i++)
3566 writel(0, cp->regs + REG_PLUS_RX_COMPN_TAIL(i));
3567 }
3568}
3569
3570/* Must be invoked under cp->lock. */
3571static void cas_read_pcs_link_mode(struct cas *cp, int *fd, int *spd,
3572 int *pause)
3573{
3574 u32 val = readl(cp->regs + REG_PCS_MII_LPA);
3575 *fd = (val & PCS_MII_LPA_FD) ? 1 : 0;
3576 *pause = (val & PCS_MII_LPA_SYM_PAUSE) ? 0x01 : 0x00;
3577 if (val & PCS_MII_LPA_ASYM_PAUSE)
3578 *pause |= 0x10;
3579 *spd = 1000;
3580}
3581
3582/* Must be invoked under cp->lock. */
3583static void cas_read_mii_link_mode(struct cas *cp, int *fd, int *spd,
3584 int *pause)
3585{
3586 u32 val;
3587
3588 *fd = 0;
3589 *spd = 10;
3590 *pause = 0;
3591
3592 /* use GMII registers */
3593 val = cas_phy_read(cp, MII_LPA);
3594 if (val & CAS_LPA_PAUSE)
3595 *pause = 0x01;
3596
3597 if (val & CAS_LPA_ASYM_PAUSE)
3598 *pause |= 0x10;
3599
3600 if (val & LPA_DUPLEX)
3601 *fd = 1;
3602 if (val & LPA_100)
3603 *spd = 100;
3604
3605 if (cp->cas_flags & CAS_FLAG_1000MB_CAP) {
3606 val = cas_phy_read(cp, CAS_MII_1000_STATUS);
3607 if (val & (CAS_LPA_1000FULL | CAS_LPA_1000HALF))
3608 *spd = 1000;
3609 if (val & CAS_LPA_1000FULL)
3610 *fd = 1;
3611 }
3612}
3613
3614/* A link-up condition has occurred, initialize and enable the
3615 * rest of the chip.
3616 *
3617 * Must be invoked under cp->lock.
3618 */
3619static void cas_set_link_modes(struct cas *cp)
3620{
3621 u32 val;
3622 int full_duplex, speed, pause;
3623
3624 full_duplex = 0;
3625 speed = 10;
3626 pause = 0;
3627
3628 if (CAS_PHY_MII(cp->phy_type)) {
3629 cas_mif_poll(cp, 0);
3630 val = cas_phy_read(cp, MII_BMCR);
3631 if (val & BMCR_ANENABLE) {
3632 cas_read_mii_link_mode(cp, &full_duplex, &speed,
3633 &pause);
3634 } else {
3635 if (val & BMCR_FULLDPLX)
3636 full_duplex = 1;
3637
3638 if (val & BMCR_SPEED100)
3639 speed = 100;
3640 else if (val & CAS_BMCR_SPEED1000)
3641 speed = (cp->cas_flags & CAS_FLAG_1000MB_CAP) ?
3642 1000 : 100;
3643 }
3644 cas_mif_poll(cp, 1);
3645
3646 } else {
3647 val = readl(cp->regs + REG_PCS_MII_CTRL);
3648 cas_read_pcs_link_mode(cp, &full_duplex, &speed, &pause);
3649 if ((val & PCS_MII_AUTONEG_EN) == 0) {
3650 if (val & PCS_MII_CTRL_DUPLEX)
3651 full_duplex = 1;
3652 }
3653 }
3654
3655 if (netif_msg_link(cp))
3656 printk(KERN_INFO "%s: Link up at %d Mbps, %s-duplex.\n",
3657 cp->dev->name, speed, (full_duplex ? "full" : "half"));
3658
3659 val = MAC_XIF_TX_MII_OUTPUT_EN | MAC_XIF_LINK_LED;
3660 if (CAS_PHY_MII(cp->phy_type)) {
3661 val |= MAC_XIF_MII_BUFFER_OUTPUT_EN;
3662 if (!full_duplex)
3663 val |= MAC_XIF_DISABLE_ECHO;
3664 }
3665 if (full_duplex)
3666 val |= MAC_XIF_FDPLX_LED;
3667 if (speed == 1000)
3668 val |= MAC_XIF_GMII_MODE;
3669 writel(val, cp->regs + REG_MAC_XIF_CFG);
3670
3671 /* deal with carrier and collision detect. */
3672 val = MAC_TX_CFG_IPG_EN;
3673 if (full_duplex) {
3674 val |= MAC_TX_CFG_IGNORE_CARRIER;
3675 val |= MAC_TX_CFG_IGNORE_COLL;
3676 } else {
3677#ifndef USE_CSMA_CD_PROTO
3678 val |= MAC_TX_CFG_NEVER_GIVE_UP_EN;
3679 val |= MAC_TX_CFG_NEVER_GIVE_UP_LIM;
3680#endif
3681 }
3682 /* val now set up for REG_MAC_TX_CFG */
3683
3684 /* If gigabit and half-duplex, enable carrier extension
3685 * mode. increase slot time to 512 bytes as well.
3686 * else, disable it and make sure slot time is 64 bytes.
3687 * also activate checksum bug workaround
3688 */
3689 if ((speed == 1000) && !full_duplex) {
3690 writel(val | MAC_TX_CFG_CARRIER_EXTEND,
3691 cp->regs + REG_MAC_TX_CFG);
3692
3693 val = readl(cp->regs + REG_MAC_RX_CFG);
3694 val &= ~MAC_RX_CFG_STRIP_FCS; /* checksum workaround */
3695 writel(val | MAC_RX_CFG_CARRIER_EXTEND,
3696 cp->regs + REG_MAC_RX_CFG);
3697
3698 writel(0x200, cp->regs + REG_MAC_SLOT_TIME);
3699
3700 cp->crc_size = 4;
3701 /* minimum size gigabit frame at half duplex */
3702 cp->min_frame_size = CAS_1000MB_MIN_FRAME;
3703
3704 } else {
3705 writel(val, cp->regs + REG_MAC_TX_CFG);
3706
3707 /* checksum bug workaround. don't strip FCS when in
3708 * half-duplex mode
3709 */
3710 val = readl(cp->regs + REG_MAC_RX_CFG);
3711 if (full_duplex) {
3712 val |= MAC_RX_CFG_STRIP_FCS;
3713 cp->crc_size = 0;
3714 cp->min_frame_size = CAS_MIN_MTU;
3715 } else {
3716 val &= ~MAC_RX_CFG_STRIP_FCS;
3717 cp->crc_size = 4;
3718 cp->min_frame_size = CAS_MIN_FRAME;
3719 }
3720 writel(val & ~MAC_RX_CFG_CARRIER_EXTEND,
3721 cp->regs + REG_MAC_RX_CFG);
3722 writel(0x40, cp->regs + REG_MAC_SLOT_TIME);
3723 }
3724
3725 if (netif_msg_link(cp)) {
3726 if (pause & 0x01) {
3727 printk(KERN_INFO "%s: Pause is enabled "
3728 "(rxfifo: %d off: %d on: %d)\n",
3729 cp->dev->name,
3730 cp->rx_fifo_size,
3731 cp->rx_pause_off,
3732 cp->rx_pause_on);
3733 } else if (pause & 0x10) {
3734 printk(KERN_INFO "%s: TX pause enabled\n",
3735 cp->dev->name);
3736 } else {
3737 printk(KERN_INFO "%s: Pause is disabled\n",
3738 cp->dev->name);
3739 }
3740 }
3741
3742 val = readl(cp->regs + REG_MAC_CTRL_CFG);
3743 val &= ~(MAC_CTRL_CFG_SEND_PAUSE_EN | MAC_CTRL_CFG_RECV_PAUSE_EN);
3744 if (pause) { /* symmetric or asymmetric pause */
3745 val |= MAC_CTRL_CFG_SEND_PAUSE_EN;
3746 if (pause & 0x01) { /* symmetric pause */
3747 val |= MAC_CTRL_CFG_RECV_PAUSE_EN;
3748 }
3749 }
3750 writel(val, cp->regs + REG_MAC_CTRL_CFG);
3751 cas_start_dma(cp);
3752}
3753
3754/* Must be invoked under cp->lock. */
3755static void cas_init_hw(struct cas *cp, int restart_link)
3756{
3757 if (restart_link)
3758 cas_phy_init(cp);
3759
3760 cas_init_pause_thresholds(cp);
3761 cas_init_mac(cp);
3762 cas_init_dma(cp);
3763
3764 if (restart_link) {
3765 /* Default aneg parameters */
3766 cp->timer_ticks = 0;
3767 cas_begin_auto_negotiation(cp, NULL);
3768 } else if (cp->lstate == link_up) {
3769 cas_set_link_modes(cp);
3770 netif_carrier_on(cp->dev);
3771 }
3772}
3773
3774/* Must be invoked under cp->lock. on earlier cassini boards,
3775 * SOFT_0 is tied to PCI reset. we use this to force a pci reset,
3776 * let it settle out, and then restore pci state.
3777 */
3778static void cas_hard_reset(struct cas *cp)
3779{
3780 writel(BIM_LOCAL_DEV_SOFT_0, cp->regs + REG_BIM_LOCAL_DEV_EN);
3781 udelay(20);
3782 pci_restore_state(cp->pdev);
3783}
3784
3785
3786static void cas_global_reset(struct cas *cp, int blkflag)
3787{
3788 int limit;
3789
3790 /* issue a global reset. don't use RSTOUT. */
3791 if (blkflag && !CAS_PHY_MII(cp->phy_type)) {
3792 /* For PCS, when the blkflag is set, we should set the
3793 * SW_REST_BLOCK_PCS_SLINK bit to prevent the results of
3794 * the last autonegotiation from being cleared. We'll
3795 * need some special handling if the chip is set into a
3796 * loopback mode.
3797 */
3798 writel((SW_RESET_TX | SW_RESET_RX | SW_RESET_BLOCK_PCS_SLINK),
3799 cp->regs + REG_SW_RESET);
3800 } else {
3801 writel(SW_RESET_TX | SW_RESET_RX, cp->regs + REG_SW_RESET);
3802 }
3803
3804 /* need to wait at least 3ms before polling register */
3805 mdelay(3);
3806
3807 limit = STOP_TRIES;
3808 while (limit-- > 0) {
3809 u32 val = readl(cp->regs + REG_SW_RESET);
3810 if ((val & (SW_RESET_TX | SW_RESET_RX)) == 0)
3811 goto done;
3812 udelay(10);
3813 }
3814 printk(KERN_ERR "%s: sw reset failed.\n", cp->dev->name);
3815
3816done:
3817 /* enable various BIM interrupts */
3818 writel(BIM_CFG_DPAR_INTR_ENABLE | BIM_CFG_RMA_INTR_ENABLE |
3819 BIM_CFG_RTA_INTR_ENABLE, cp->regs + REG_BIM_CFG);
3820
3821 /* clear out pci error status mask for handled errors.
3822 * we don't deal with DMA counter overflows as they happen
3823 * all the time.
3824 */
3825 writel(0xFFFFFFFFU & ~(PCI_ERR_BADACK | PCI_ERR_DTRTO |
3826 PCI_ERR_OTHER | PCI_ERR_BIM_DMA_WRITE |
3827 PCI_ERR_BIM_DMA_READ), cp->regs +
3828 REG_PCI_ERR_STATUS_MASK);
3829
3830 /* set up for MII by default to address mac rx reset timeout
3831 * issue
3832 */
3833 writel(PCS_DATAPATH_MODE_MII, cp->regs + REG_PCS_DATAPATH_MODE);
3834}
3835
3836static void cas_reset(struct cas *cp, int blkflag)
3837{
3838 u32 val;
3839
3840 cas_mask_intr(cp);
3841 cas_global_reset(cp, blkflag);
3842 cas_mac_reset(cp);
3843 cas_entropy_reset(cp);
3844
3845 /* disable dma engines. */
3846 val = readl(cp->regs + REG_TX_CFG);
3847 val &= ~TX_CFG_DMA_EN;
3848 writel(val, cp->regs + REG_TX_CFG);
3849
3850 val = readl(cp->regs + REG_RX_CFG);
3851 val &= ~RX_CFG_DMA_EN;
3852 writel(val, cp->regs + REG_RX_CFG);
3853
3854 /* program header parser */
3855 if ((cp->cas_flags & CAS_FLAG_TARGET_ABORT) ||
3856 (CAS_HP_ALT_FIRMWARE == cas_prog_null)) {
3857 cas_load_firmware(cp, CAS_HP_FIRMWARE);
3858 } else {
3859 cas_load_firmware(cp, CAS_HP_ALT_FIRMWARE);
3860 }
3861
3862 /* clear out error registers */
3863 spin_lock(&cp->stat_lock[N_TX_RINGS]);
3864 cas_clear_mac_err(cp);
3865 spin_unlock(&cp->stat_lock[N_TX_RINGS]);
3866}
3867
3868/* Shut down the chip, must be called with pm_sem held. */
3869static void cas_shutdown(struct cas *cp)
3870{
3871 unsigned long flags;
3872
3873 /* Make us not-running to avoid timers respawning */
3874 cp->hw_running = 0;
3875
3876 del_timer_sync(&cp->link_timer);
3877
3878 /* Stop the reset task */
3879#if 0
3880 while (atomic_read(&cp->reset_task_pending_mtu) ||
3881 atomic_read(&cp->reset_task_pending_spare) ||
3882 atomic_read(&cp->reset_task_pending_all))
3883 schedule();
3884
3885#else
3886 while (atomic_read(&cp->reset_task_pending))
3887 schedule();
3888#endif
3889 /* Actually stop the chip */
3890 cas_lock_all_save(cp, flags);
3891 cas_reset(cp, 0);
3892 if (cp->cas_flags & CAS_FLAG_SATURN)
3893 cas_phy_powerdown(cp);
3894 cas_unlock_all_restore(cp, flags);
3895}
3896
3897static int cas_change_mtu(struct net_device *dev, int new_mtu)
3898{
3899 struct cas *cp = netdev_priv(dev);
3900
3901 if (new_mtu < CAS_MIN_MTU || new_mtu > CAS_MAX_MTU)
3902 return -EINVAL;
3903
3904 dev->mtu = new_mtu;
3905 if (!netif_running(dev) || !netif_device_present(dev))
3906 return 0;
3907
3908 /* let the reset task handle it */
3909#if 1
3910 atomic_inc(&cp->reset_task_pending);
3911 if ((cp->phy_type & CAS_PHY_SERDES)) {
3912 atomic_inc(&cp->reset_task_pending_all);
3913 } else {
3914 atomic_inc(&cp->reset_task_pending_mtu);
3915 }
3916 schedule_work(&cp->reset_task);
3917#else
3918 atomic_set(&cp->reset_task_pending, (cp->phy_type & CAS_PHY_SERDES) ?
3919 CAS_RESET_ALL : CAS_RESET_MTU);
3920 printk(KERN_ERR "reset called in cas_change_mtu\n");
3921 schedule_work(&cp->reset_task);
3922#endif
3923
3924 flush_scheduled_work();
3925 return 0;
3926}
3927
3928static void cas_clean_txd(struct cas *cp, int ring)
3929{
3930 struct cas_tx_desc *txd = cp->init_txds[ring];
3931 struct sk_buff *skb, **skbs = cp->tx_skbs[ring];
3932 u64 daddr, dlen;
3933 int i, size;
3934
3935 size = TX_DESC_RINGN_SIZE(ring);
3936 for (i = 0; i < size; i++) {
3937 int frag;
3938
3939 if (skbs[i] == NULL)
3940 continue;
3941
3942 skb = skbs[i];
3943 skbs[i] = NULL;
3944
3945 for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) {
3946 int ent = i & (size - 1);
3947
3948 /* first buffer is never a tiny buffer and so
3949 * needs to be unmapped.
3950 */
3951 daddr = le64_to_cpu(txd[ent].buffer);
3952 dlen = CAS_VAL(TX_DESC_BUFLEN,
3953 le64_to_cpu(txd[ent].control));
3954 pci_unmap_page(cp->pdev, daddr, dlen,
3955 PCI_DMA_TODEVICE);
3956
3957 if (frag != skb_shinfo(skb)->nr_frags) {
3958 i++;
3959
3960 /* next buffer might by a tiny buffer.
3961 * skip past it.
3962 */
3963 ent = i & (size - 1);
3964 if (cp->tx_tiny_use[ring][ent].used)
3965 i++;
3966 }
3967 }
3968 dev_kfree_skb_any(skb);
3969 }
3970
3971 /* zero out tiny buf usage */
3972 memset(cp->tx_tiny_use[ring], 0, size*sizeof(*cp->tx_tiny_use[ring]));
3973}
3974
3975/* freed on close */
3976static inline void cas_free_rx_desc(struct cas *cp, int ring)
3977{
3978 cas_page_t **page = cp->rx_pages[ring];
3979 int i, size;
3980
3981 size = RX_DESC_RINGN_SIZE(ring);
3982 for (i = 0; i < size; i++) {
3983 if (page[i]) {
3984 cas_page_free(cp, page[i]);
3985 page[i] = NULL;
3986 }
3987 }
3988}
3989
3990static void cas_free_rxds(struct cas *cp)
3991{
3992 int i;
3993
3994 for (i = 0; i < N_RX_DESC_RINGS; i++)
3995 cas_free_rx_desc(cp, i);
3996}
3997
3998/* Must be invoked under cp->lock. */
3999static void cas_clean_rings(struct cas *cp)
4000{
4001 int i;
4002
4003 /* need to clean all tx rings */
4004 memset(cp->tx_old, 0, sizeof(*cp->tx_old)*N_TX_RINGS);
4005 memset(cp->tx_new, 0, sizeof(*cp->tx_new)*N_TX_RINGS);
4006 for (i = 0; i < N_TX_RINGS; i++)
4007 cas_clean_txd(cp, i);
4008
4009 /* zero out init block */
4010 memset(cp->init_block, 0, sizeof(struct cas_init_block));
4011 cas_clean_rxds(cp);
4012 cas_clean_rxcs(cp);
4013}
4014
4015/* allocated on open */
4016static inline int cas_alloc_rx_desc(struct cas *cp, int ring)
4017{
4018 cas_page_t **page = cp->rx_pages[ring];
4019 int size, i = 0;
4020
4021 size = RX_DESC_RINGN_SIZE(ring);
4022 for (i = 0; i < size; i++) {
4023 if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL)
4024 return -1;
4025 }
4026 return 0;
4027}
4028
4029static int cas_alloc_rxds(struct cas *cp)
4030{
4031 int i;
4032
4033 for (i = 0; i < N_RX_DESC_RINGS; i++) {
4034 if (cas_alloc_rx_desc(cp, i) < 0) {
4035 cas_free_rxds(cp);
4036 return -1;
4037 }
4038 }
4039 return 0;
4040}
4041
4042static void cas_reset_task(void *data)
4043{
4044 struct cas *cp = (struct cas *) data;
4045#if 0
4046 int pending = atomic_read(&cp->reset_task_pending);
4047#else
4048 int pending_all = atomic_read(&cp->reset_task_pending_all);
4049 int pending_spare = atomic_read(&cp->reset_task_pending_spare);
4050 int pending_mtu = atomic_read(&cp->reset_task_pending_mtu);
4051
4052 if (pending_all == 0 && pending_spare == 0 && pending_mtu == 0) {
4053 /* We can have more tasks scheduled than actually
4054 * needed.
4055 */
4056 atomic_dec(&cp->reset_task_pending);
4057 return;
4058 }
4059#endif
4060 /* The link went down, we reset the ring, but keep
4061 * DMA stopped. Use this function for reset
4062 * on error as well.
4063 */
4064 if (cp->hw_running) {
4065 unsigned long flags;
4066
4067 /* Make sure we don't get interrupts or tx packets */
4068 netif_device_detach(cp->dev);
4069 cas_lock_all_save(cp, flags);
4070
4071 if (cp->opened) {
4072 /* We call cas_spare_recover when we call cas_open.
4073 * but we do not initialize the lists cas_spare_recover
4074 * uses until cas_open is called.
4075 */
4076 cas_spare_recover(cp, GFP_ATOMIC);
4077 }
4078#if 1
4079 /* test => only pending_spare set */
4080 if (!pending_all && !pending_mtu)
4081 goto done;
4082#else
4083 if (pending == CAS_RESET_SPARE)
4084 goto done;
4085#endif
4086 /* when pending == CAS_RESET_ALL, the following
4087 * call to cas_init_hw will restart auto negotiation.
4088 * Setting the second argument of cas_reset to
4089 * !(pending == CAS_RESET_ALL) will set this argument
4090 * to 1 (avoiding reinitializing the PHY for the normal
4091 * PCS case) when auto negotiation is not restarted.
4092 */
4093#if 1
4094 cas_reset(cp, !(pending_all > 0));
4095 if (cp->opened)
4096 cas_clean_rings(cp);
4097 cas_init_hw(cp, (pending_all > 0));
4098#else
4099 cas_reset(cp, !(pending == CAS_RESET_ALL));
4100 if (cp->opened)
4101 cas_clean_rings(cp);
4102 cas_init_hw(cp, pending == CAS_RESET_ALL);
4103#endif
4104
4105done:
4106 cas_unlock_all_restore(cp, flags);
4107 netif_device_attach(cp->dev);
4108 }
4109#if 1
4110 atomic_sub(pending_all, &cp->reset_task_pending_all);
4111 atomic_sub(pending_spare, &cp->reset_task_pending_spare);
4112 atomic_sub(pending_mtu, &cp->reset_task_pending_mtu);
4113 atomic_dec(&cp->reset_task_pending);
4114#else
4115 atomic_set(&cp->reset_task_pending, 0);
4116#endif
4117}
4118
4119static void cas_link_timer(unsigned long data)
4120{
4121 struct cas *cp = (struct cas *) data;
4122 int mask, pending = 0, reset = 0;
4123 unsigned long flags;
4124
4125 if (link_transition_timeout != 0 &&
4126 cp->link_transition_jiffies_valid &&
4127 ((jiffies - cp->link_transition_jiffies) >
4128 (link_transition_timeout))) {
4129 /* One-second counter so link-down workaround doesn't
4130 * cause resets to occur so fast as to fool the switch
4131 * into thinking the link is down.
4132 */
4133 cp->link_transition_jiffies_valid = 0;
4134 }
4135
4136 if (!cp->hw_running)
4137 return;
4138
4139 spin_lock_irqsave(&cp->lock, flags);
4140 cas_lock_tx(cp);
4141 cas_entropy_gather(cp);
4142
4143 /* If the link task is still pending, we just
4144 * reschedule the link timer
4145 */
4146#if 1
4147 if (atomic_read(&cp->reset_task_pending_all) ||
4148 atomic_read(&cp->reset_task_pending_spare) ||
4149 atomic_read(&cp->reset_task_pending_mtu))
4150 goto done;
4151#else
4152 if (atomic_read(&cp->reset_task_pending))
4153 goto done;
4154#endif
4155
4156 /* check for rx cleaning */
4157 if ((mask = (cp->cas_flags & CAS_FLAG_RXD_POST_MASK))) {
4158 int i, rmask;
4159
4160 for (i = 0; i < MAX_RX_DESC_RINGS; i++) {
4161 rmask = CAS_FLAG_RXD_POST(i);
4162 if ((mask & rmask) == 0)
4163 continue;
4164
4165 /* post_rxds will do a mod_timer */
4166 if (cas_post_rxds_ringN(cp, i, cp->rx_last[i]) < 0) {
4167 pending = 1;
4168 continue;
4169 }
4170 cp->cas_flags &= ~rmask;
4171 }
4172 }
4173
4174 if (CAS_PHY_MII(cp->phy_type)) {
4175 u16 bmsr;
4176 cas_mif_poll(cp, 0);
4177 bmsr = cas_phy_read(cp, MII_BMSR);
4178 /* WTZ: Solaris driver reads this twice, but that
4179 * may be due to the PCS case and the use of a
4180 * common implementation. Read it twice here to be
4181 * safe.
4182 */
4183 bmsr = cas_phy_read(cp, MII_BMSR);
4184 cas_mif_poll(cp, 1);
4185 readl(cp->regs + REG_MIF_STATUS); /* avoid dups */
4186 reset = cas_mii_link_check(cp, bmsr);
4187 } else {
4188 reset = cas_pcs_link_check(cp);
4189 }
4190
4191 if (reset)
4192 goto done;
4193
4194 /* check for tx state machine confusion */
4195 if ((readl(cp->regs + REG_MAC_TX_STATUS) & MAC_TX_FRAME_XMIT) == 0) {
4196 u32 val = readl(cp->regs + REG_MAC_STATE_MACHINE);
4197 u32 wptr, rptr;
4198 int tlm = CAS_VAL(MAC_SM_TLM, val);
4199
4200 if (((tlm == 0x5) || (tlm == 0x3)) &&
4201 (CAS_VAL(MAC_SM_ENCAP_SM, val) == 0)) {
4202 if (netif_msg_tx_err(cp))
4203 printk(KERN_DEBUG "%s: tx err: "
4204 "MAC_STATE[%08x]\n",
4205 cp->dev->name, val);
4206 reset = 1;
4207 goto done;
4208 }
4209
4210 val = readl(cp->regs + REG_TX_FIFO_PKT_CNT);
4211 wptr = readl(cp->regs + REG_TX_FIFO_WRITE_PTR);
4212 rptr = readl(cp->regs + REG_TX_FIFO_READ_PTR);
4213 if ((val == 0) && (wptr != rptr)) {
4214 if (netif_msg_tx_err(cp))
4215 printk(KERN_DEBUG "%s: tx err: "
4216 "TX_FIFO[%08x:%08x:%08x]\n",
4217 cp->dev->name, val, wptr, rptr);
4218 reset = 1;
4219 }
4220
4221 if (reset)
4222 cas_hard_reset(cp);
4223 }
4224
4225done:
4226 if (reset) {
4227#if 1
4228 atomic_inc(&cp->reset_task_pending);
4229 atomic_inc(&cp->reset_task_pending_all);
4230 schedule_work(&cp->reset_task);
4231#else
4232 atomic_set(&cp->reset_task_pending, CAS_RESET_ALL);
4233 printk(KERN_ERR "reset called in cas_link_timer\n");
4234 schedule_work(&cp->reset_task);
4235#endif
4236 }
4237
4238 if (!pending)
4239 mod_timer(&cp->link_timer, jiffies + CAS_LINK_TIMEOUT);
4240 cas_unlock_tx(cp);
4241 spin_unlock_irqrestore(&cp->lock, flags);
4242}
4243
4244/* tiny buffers are used to avoid target abort issues with
4245 * older cassini's
4246 */
4247static void cas_tx_tiny_free(struct cas *cp)
4248{
4249 struct pci_dev *pdev = cp->pdev;
4250 int i;
4251
4252 for (i = 0; i < N_TX_RINGS; i++) {
4253 if (!cp->tx_tiny_bufs[i])
4254 continue;
4255
4256 pci_free_consistent(pdev, TX_TINY_BUF_BLOCK,
4257 cp->tx_tiny_bufs[i],
4258 cp->tx_tiny_dvma[i]);
4259 cp->tx_tiny_bufs[i] = NULL;
4260 }
4261}
4262
4263static int cas_tx_tiny_alloc(struct cas *cp)
4264{
4265 struct pci_dev *pdev = cp->pdev;
4266 int i;
4267
4268 for (i = 0; i < N_TX_RINGS; i++) {
4269 cp->tx_tiny_bufs[i] =
4270 pci_alloc_consistent(pdev, TX_TINY_BUF_BLOCK,
4271 &cp->tx_tiny_dvma[i]);
4272 if (!cp->tx_tiny_bufs[i]) {
4273 cas_tx_tiny_free(cp);
4274 return -1;
4275 }
4276 }
4277 return 0;
4278}
4279
4280
4281static int cas_open(struct net_device *dev)
4282{
4283 struct cas *cp = netdev_priv(dev);
4284 int hw_was_up, err;
4285 unsigned long flags;
4286
4287 down(&cp->pm_sem);
4288
4289 hw_was_up = cp->hw_running;
4290
4291 /* The power-management semaphore protects the hw_running
4292 * etc. state so it is safe to do this bit without cp->lock
4293 */
4294 if (!cp->hw_running) {
4295 /* Reset the chip */
4296 cas_lock_all_save(cp, flags);
4297 /* We set the second arg to cas_reset to zero
4298 * because cas_init_hw below will have its second
4299 * argument set to non-zero, which will force
4300 * autonegotiation to start.
4301 */
4302 cas_reset(cp, 0);
4303 cp->hw_running = 1;
4304 cas_unlock_all_restore(cp, flags);
4305 }
4306
4307 if (cas_tx_tiny_alloc(cp) < 0)
4308 return -ENOMEM;
4309
4310 /* alloc rx descriptors */
4311 err = -ENOMEM;
4312 if (cas_alloc_rxds(cp) < 0)
4313 goto err_tx_tiny;
4314
4315 /* allocate spares */
4316 cas_spare_init(cp);
4317 cas_spare_recover(cp, GFP_KERNEL);
4318
4319 /* We can now request the interrupt as we know it's masked
4320 * on the controller. cassini+ has up to 4 interrupts
4321 * that can be used, but you need to do explicit pci interrupt
4322 * mapping to expose them
4323 */
4324 if (request_irq(cp->pdev->irq, cas_interrupt,
4325 SA_SHIRQ, dev->name, (void *) dev)) {
4326 printk(KERN_ERR "%s: failed to request irq !\n",
4327 cp->dev->name);
4328 err = -EAGAIN;
4329 goto err_spare;
4330 }
4331
4332 /* init hw */
4333 cas_lock_all_save(cp, flags);
4334 cas_clean_rings(cp);
4335 cas_init_hw(cp, !hw_was_up);
4336 cp->opened = 1;
4337 cas_unlock_all_restore(cp, flags);
4338
4339 netif_start_queue(dev);
4340 up(&cp->pm_sem);
4341 return 0;
4342
4343err_spare:
4344 cas_spare_free(cp);
4345 cas_free_rxds(cp);
4346err_tx_tiny:
4347 cas_tx_tiny_free(cp);
4348 up(&cp->pm_sem);
4349 return err;
4350}
4351
4352static int cas_close(struct net_device *dev)
4353{
4354 unsigned long flags;
4355 struct cas *cp = netdev_priv(dev);
4356
4357 /* Make sure we don't get distracted by suspend/resume */
4358 down(&cp->pm_sem);
4359
4360 netif_stop_queue(dev);
4361
4362 /* Stop traffic, mark us closed */
4363 cas_lock_all_save(cp, flags);
4364 cp->opened = 0;
4365 cas_reset(cp, 0);
4366 cas_phy_init(cp);
4367 cas_begin_auto_negotiation(cp, NULL);
4368 cas_clean_rings(cp);
4369 cas_unlock_all_restore(cp, flags);
4370
4371 free_irq(cp->pdev->irq, (void *) dev);
4372 cas_spare_free(cp);
4373 cas_free_rxds(cp);
4374 cas_tx_tiny_free(cp);
4375 up(&cp->pm_sem);
4376 return 0;
4377}
4378
4379static struct {
4380 const char name[ETH_GSTRING_LEN];
4381} ethtool_cassini_statnames[] = {
4382 {"collisions"},
4383 {"rx_bytes"},
4384 {"rx_crc_errors"},
4385 {"rx_dropped"},
4386 {"rx_errors"},
4387 {"rx_fifo_errors"},
4388 {"rx_frame_errors"},
4389 {"rx_length_errors"},
4390 {"rx_over_errors"},
4391 {"rx_packets"},
4392 {"tx_aborted_errors"},
4393 {"tx_bytes"},
4394 {"tx_dropped"},
4395 {"tx_errors"},
4396 {"tx_fifo_errors"},
4397 {"tx_packets"}
4398};
4399#define CAS_NUM_STAT_KEYS (sizeof(ethtool_cassini_statnames)/ETH_GSTRING_LEN)
4400
4401static struct {
4402 const int offsets; /* neg. values for 2nd arg to cas_read_phy */
4403} ethtool_register_table[] = {
4404 {-MII_BMSR},
4405 {-MII_BMCR},
4406 {REG_CAWR},
4407 {REG_INF_BURST},
4408 {REG_BIM_CFG},
4409 {REG_RX_CFG},
4410 {REG_HP_CFG},
4411 {REG_MAC_TX_CFG},
4412 {REG_MAC_RX_CFG},
4413 {REG_MAC_CTRL_CFG},
4414 {REG_MAC_XIF_CFG},
4415 {REG_MIF_CFG},
4416 {REG_PCS_CFG},
4417 {REG_SATURN_PCFG},
4418 {REG_PCS_MII_STATUS},
4419 {REG_PCS_STATE_MACHINE},
4420 {REG_MAC_COLL_EXCESS},
4421 {REG_MAC_COLL_LATE}
4422};
4423#define CAS_REG_LEN (sizeof(ethtool_register_table)/sizeof(int))
4424#define CAS_MAX_REGS (sizeof (u32)*CAS_REG_LEN)
4425
4426static void cas_read_regs(struct cas *cp, u8 *ptr, int len)
4427{
4428 u8 *p;
4429 int i;
4430 unsigned long flags;
4431
4432 spin_lock_irqsave(&cp->lock, flags);
4433 for (i = 0, p = ptr; i < len ; i ++, p += sizeof(u32)) {
4434 u16 hval;
4435 u32 val;
4436 if (ethtool_register_table[i].offsets < 0) {
4437 hval = cas_phy_read(cp,
4438 -ethtool_register_table[i].offsets);
4439 val = hval;
4440 } else {
4441 val= readl(cp->regs+ethtool_register_table[i].offsets);
4442 }
4443 memcpy(p, (u8 *)&val, sizeof(u32));
4444 }
4445 spin_unlock_irqrestore(&cp->lock, flags);
4446}
4447
4448static struct net_device_stats *cas_get_stats(struct net_device *dev)
4449{
4450 struct cas *cp = netdev_priv(dev);
4451 struct net_device_stats *stats = cp->net_stats;
4452 unsigned long flags;
4453 int i;
4454 unsigned long tmp;
4455
4456 /* we collate all of the stats into net_stats[N_TX_RING] */
4457 if (!cp->hw_running)
4458 return stats + N_TX_RINGS;
4459
4460 /* collect outstanding stats */
4461 /* WTZ: the Cassini spec gives these as 16 bit counters but
4462 * stored in 32-bit words. Added a mask of 0xffff to be safe,
4463 * in case the chip somehow puts any garbage in the other bits.
4464 * Also, counter usage didn't seem to mach what Adrian did
4465 * in the parts of the code that set these quantities. Made
4466 * that consistent.
4467 */
4468 spin_lock_irqsave(&cp->stat_lock[N_TX_RINGS], flags);
4469 stats[N_TX_RINGS].rx_crc_errors +=
4470 readl(cp->regs + REG_MAC_FCS_ERR) & 0xffff;
4471 stats[N_TX_RINGS].rx_frame_errors +=
4472 readl(cp->regs + REG_MAC_ALIGN_ERR) &0xffff;
4473 stats[N_TX_RINGS].rx_length_errors +=
4474 readl(cp->regs + REG_MAC_LEN_ERR) & 0xffff;
4475#if 1
4476 tmp = (readl(cp->regs + REG_MAC_COLL_EXCESS) & 0xffff) +
4477 (readl(cp->regs + REG_MAC_COLL_LATE) & 0xffff);
4478 stats[N_TX_RINGS].tx_aborted_errors += tmp;
4479 stats[N_TX_RINGS].collisions +=
4480 tmp + (readl(cp->regs + REG_MAC_COLL_NORMAL) & 0xffff);
4481#else
4482 stats[N_TX_RINGS].tx_aborted_errors +=
4483 readl(cp->regs + REG_MAC_COLL_EXCESS);
4484 stats[N_TX_RINGS].collisions += readl(cp->regs + REG_MAC_COLL_EXCESS) +
4485 readl(cp->regs + REG_MAC_COLL_LATE);
4486#endif
4487 cas_clear_mac_err(cp);
4488
4489 /* saved bits that are unique to ring 0 */
4490 spin_lock(&cp->stat_lock[0]);
4491 stats[N_TX_RINGS].collisions += stats[0].collisions;
4492 stats[N_TX_RINGS].rx_over_errors += stats[0].rx_over_errors;
4493 stats[N_TX_RINGS].rx_frame_errors += stats[0].rx_frame_errors;
4494 stats[N_TX_RINGS].rx_fifo_errors += stats[0].rx_fifo_errors;
4495 stats[N_TX_RINGS].tx_aborted_errors += stats[0].tx_aborted_errors;
4496 stats[N_TX_RINGS].tx_fifo_errors += stats[0].tx_fifo_errors;
4497 spin_unlock(&cp->stat_lock[0]);
4498
4499 for (i = 0; i < N_TX_RINGS; i++) {
4500 spin_lock(&cp->stat_lock[i]);
4501 stats[N_TX_RINGS].rx_length_errors +=
4502 stats[i].rx_length_errors;
4503 stats[N_TX_RINGS].rx_crc_errors += stats[i].rx_crc_errors;
4504 stats[N_TX_RINGS].rx_packets += stats[i].rx_packets;
4505 stats[N_TX_RINGS].tx_packets += stats[i].tx_packets;
4506 stats[N_TX_RINGS].rx_bytes += stats[i].rx_bytes;
4507 stats[N_TX_RINGS].tx_bytes += stats[i].tx_bytes;
4508 stats[N_TX_RINGS].rx_errors += stats[i].rx_errors;
4509 stats[N_TX_RINGS].tx_errors += stats[i].tx_errors;
4510 stats[N_TX_RINGS].rx_dropped += stats[i].rx_dropped;
4511 stats[N_TX_RINGS].tx_dropped += stats[i].tx_dropped;
4512 memset(stats + i, 0, sizeof(struct net_device_stats));
4513 spin_unlock(&cp->stat_lock[i]);
4514 }
4515 spin_unlock_irqrestore(&cp->stat_lock[N_TX_RINGS], flags);
4516 return stats + N_TX_RINGS;
4517}
4518
4519
4520static void cas_set_multicast(struct net_device *dev)
4521{
4522 struct cas *cp = netdev_priv(dev);
4523 u32 rxcfg, rxcfg_new;
4524 unsigned long flags;
4525 int limit = STOP_TRIES;
4526
4527 if (!cp->hw_running)
4528 return;
4529
4530 spin_lock_irqsave(&cp->lock, flags);
4531 rxcfg = readl(cp->regs + REG_MAC_RX_CFG);
4532
4533 /* disable RX MAC and wait for completion */
4534 writel(rxcfg & ~MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
4535 while (readl(cp->regs + REG_MAC_RX_CFG) & MAC_RX_CFG_EN) {
4536 if (!limit--)
4537 break;
4538 udelay(10);
4539 }
4540
4541 /* disable hash filter and wait for completion */
4542 limit = STOP_TRIES;
4543 rxcfg &= ~(MAC_RX_CFG_PROMISC_EN | MAC_RX_CFG_HASH_FILTER_EN);
4544 writel(rxcfg & ~MAC_RX_CFG_EN, cp->regs + REG_MAC_RX_CFG);
4545 while (readl(cp->regs + REG_MAC_RX_CFG) & MAC_RX_CFG_HASH_FILTER_EN) {
4546 if (!limit--)
4547 break;
4548 udelay(10);
4549 }
4550
4551 /* program hash filters */
4552 cp->mac_rx_cfg = rxcfg_new = cas_setup_multicast(cp);
4553 rxcfg |= rxcfg_new;
4554 writel(rxcfg, cp->regs + REG_MAC_RX_CFG);
4555 spin_unlock_irqrestore(&cp->lock, flags);
4556}
4557
4558static void cas_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
4559{
4560 struct cas *cp = netdev_priv(dev);
4561 strncpy(info->driver, DRV_MODULE_NAME, ETHTOOL_BUSINFO_LEN);
4562 strncpy(info->version, DRV_MODULE_VERSION, ETHTOOL_BUSINFO_LEN);
4563 info->fw_version[0] = '\0';
4564 strncpy(info->bus_info, pci_name(cp->pdev), ETHTOOL_BUSINFO_LEN);
4565 info->regdump_len = cp->casreg_len < CAS_MAX_REGS ?
4566 cp->casreg_len : CAS_MAX_REGS;
4567 info->n_stats = CAS_NUM_STAT_KEYS;
4568}
4569
4570static int cas_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4571{
4572 struct cas *cp = netdev_priv(dev);
4573 u16 bmcr;
4574 int full_duplex, speed, pause;
4575 unsigned long flags;
4576 enum link_state linkstate = link_up;
4577
4578 cmd->advertising = 0;
4579 cmd->supported = SUPPORTED_Autoneg;
4580 if (cp->cas_flags & CAS_FLAG_1000MB_CAP) {
4581 cmd->supported |= SUPPORTED_1000baseT_Full;
4582 cmd->advertising |= ADVERTISED_1000baseT_Full;
4583 }
4584
4585 /* Record PHY settings if HW is on. */
4586 spin_lock_irqsave(&cp->lock, flags);
4587 bmcr = 0;
4588 linkstate = cp->lstate;
4589 if (CAS_PHY_MII(cp->phy_type)) {
4590 cmd->port = PORT_MII;
4591 cmd->transceiver = (cp->cas_flags & CAS_FLAG_SATURN) ?
4592 XCVR_INTERNAL : XCVR_EXTERNAL;
4593 cmd->phy_address = cp->phy_addr;
4594 cmd->advertising |= ADVERTISED_TP | ADVERTISED_MII |
4595 ADVERTISED_10baseT_Half |
4596 ADVERTISED_10baseT_Full |
4597 ADVERTISED_100baseT_Half |
4598 ADVERTISED_100baseT_Full;
4599
4600 cmd->supported |=
4601 (SUPPORTED_10baseT_Half |
4602 SUPPORTED_10baseT_Full |
4603 SUPPORTED_100baseT_Half |
4604 SUPPORTED_100baseT_Full |
4605 SUPPORTED_TP | SUPPORTED_MII);
4606
4607 if (cp->hw_running) {
4608 cas_mif_poll(cp, 0);
4609 bmcr = cas_phy_read(cp, MII_BMCR);
4610 cas_read_mii_link_mode(cp, &full_duplex,
4611 &speed, &pause);
4612 cas_mif_poll(cp, 1);
4613 }
4614
4615 } else {
4616 cmd->port = PORT_FIBRE;
4617 cmd->transceiver = XCVR_INTERNAL;
4618 cmd->phy_address = 0;
4619 cmd->supported |= SUPPORTED_FIBRE;
4620 cmd->advertising |= ADVERTISED_FIBRE;
4621
4622 if (cp->hw_running) {
4623 /* pcs uses the same bits as mii */
4624 bmcr = readl(cp->regs + REG_PCS_MII_CTRL);
4625 cas_read_pcs_link_mode(cp, &full_duplex,
4626 &speed, &pause);
4627 }
4628 }
4629 spin_unlock_irqrestore(&cp->lock, flags);
4630
4631 if (bmcr & BMCR_ANENABLE) {
4632 cmd->advertising |= ADVERTISED_Autoneg;
4633 cmd->autoneg = AUTONEG_ENABLE;
4634 cmd->speed = ((speed == 10) ?
4635 SPEED_10 :
4636 ((speed == 1000) ?
4637 SPEED_1000 : SPEED_100));
4638 cmd->duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
4639 } else {
4640 cmd->autoneg = AUTONEG_DISABLE;
4641 cmd->speed =
4642 (bmcr & CAS_BMCR_SPEED1000) ?
4643 SPEED_1000 :
4644 ((bmcr & BMCR_SPEED100) ? SPEED_100:
4645 SPEED_10);
4646 cmd->duplex =
4647 (bmcr & BMCR_FULLDPLX) ?
4648 DUPLEX_FULL : DUPLEX_HALF;
4649 }
4650 if (linkstate != link_up) {
4651 /* Force these to "unknown" if the link is not up and
4652 * autonogotiation in enabled. We can set the link
4653 * speed to 0, but not cmd->duplex,
4654 * because its legal values are 0 and 1. Ethtool will
4655 * print the value reported in parentheses after the
4656 * word "Unknown" for unrecognized values.
4657 *
4658 * If in forced mode, we report the speed and duplex
4659 * settings that we configured.
4660 */
4661 if (cp->link_cntl & BMCR_ANENABLE) {
4662 cmd->speed = 0;
4663 cmd->duplex = 0xff;
4664 } else {
4665 cmd->speed = SPEED_10;
4666 if (cp->link_cntl & BMCR_SPEED100) {
4667 cmd->speed = SPEED_100;
4668 } else if (cp->link_cntl & CAS_BMCR_SPEED1000) {
4669 cmd->speed = SPEED_1000;
4670 }
4671 cmd->duplex = (cp->link_cntl & BMCR_FULLDPLX)?
4672 DUPLEX_FULL : DUPLEX_HALF;
4673 }
4674 }
4675 return 0;
4676}
4677
4678static int cas_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4679{
4680 struct cas *cp = netdev_priv(dev);
4681 unsigned long flags;
4682
4683 /* Verify the settings we care about. */
4684 if (cmd->autoneg != AUTONEG_ENABLE &&
4685 cmd->autoneg != AUTONEG_DISABLE)
4686 return -EINVAL;
4687
4688 if (cmd->autoneg == AUTONEG_DISABLE &&
4689 ((cmd->speed != SPEED_1000 &&
4690 cmd->speed != SPEED_100 &&
4691 cmd->speed != SPEED_10) ||
4692 (cmd->duplex != DUPLEX_HALF &&
4693 cmd->duplex != DUPLEX_FULL)))
4694 return -EINVAL;
4695
4696 /* Apply settings and restart link process. */
4697 spin_lock_irqsave(&cp->lock, flags);
4698 cas_begin_auto_negotiation(cp, cmd);
4699 spin_unlock_irqrestore(&cp->lock, flags);
4700 return 0;
4701}
4702
4703static int cas_nway_reset(struct net_device *dev)
4704{
4705 struct cas *cp = netdev_priv(dev);
4706 unsigned long flags;
4707
4708 if ((cp->link_cntl & BMCR_ANENABLE) == 0)
4709 return -EINVAL;
4710
4711 /* Restart link process. */
4712 spin_lock_irqsave(&cp->lock, flags);
4713 cas_begin_auto_negotiation(cp, NULL);
4714 spin_unlock_irqrestore(&cp->lock, flags);
4715
4716 return 0;
4717}
4718
4719static u32 cas_get_link(struct net_device *dev)
4720{
4721 struct cas *cp = netdev_priv(dev);
4722 return cp->lstate == link_up;
4723}
4724
4725static u32 cas_get_msglevel(struct net_device *dev)
4726{
4727 struct cas *cp = netdev_priv(dev);
4728 return cp->msg_enable;
4729}
4730
4731static void cas_set_msglevel(struct net_device *dev, u32 value)
4732{
4733 struct cas *cp = netdev_priv(dev);
4734 cp->msg_enable = value;
4735}
4736
4737static int cas_get_regs_len(struct net_device *dev)
4738{
4739 struct cas *cp = netdev_priv(dev);
4740 return cp->casreg_len < CAS_MAX_REGS ? cp->casreg_len: CAS_MAX_REGS;
4741}
4742
4743static void cas_get_regs(struct net_device *dev, struct ethtool_regs *regs,
4744 void *p)
4745{
4746 struct cas *cp = netdev_priv(dev);
4747 regs->version = 0;
4748 /* cas_read_regs handles locks (cp->lock). */
4749 cas_read_regs(cp, p, regs->len / sizeof(u32));
4750}
4751
4752static int cas_get_stats_count(struct net_device *dev)
4753{
4754 return CAS_NUM_STAT_KEYS;
4755}
4756
4757static void cas_get_strings(struct net_device *dev, u32 stringset, u8 *data)
4758{
4759 memcpy(data, &ethtool_cassini_statnames,
4760 CAS_NUM_STAT_KEYS * ETH_GSTRING_LEN);
4761}
4762
4763static void cas_get_ethtool_stats(struct net_device *dev,
4764 struct ethtool_stats *estats, u64 *data)
4765{
4766 struct cas *cp = netdev_priv(dev);
4767 struct net_device_stats *stats = cas_get_stats(cp->dev);
4768 int i = 0;
4769 data[i++] = stats->collisions;
4770 data[i++] = stats->rx_bytes;
4771 data[i++] = stats->rx_crc_errors;
4772 data[i++] = stats->rx_dropped;
4773 data[i++] = stats->rx_errors;
4774 data[i++] = stats->rx_fifo_errors;
4775 data[i++] = stats->rx_frame_errors;
4776 data[i++] = stats->rx_length_errors;
4777 data[i++] = stats->rx_over_errors;
4778 data[i++] = stats->rx_packets;
4779 data[i++] = stats->tx_aborted_errors;
4780 data[i++] = stats->tx_bytes;
4781 data[i++] = stats->tx_dropped;
4782 data[i++] = stats->tx_errors;
4783 data[i++] = stats->tx_fifo_errors;
4784 data[i++] = stats->tx_packets;
4785 BUG_ON(i != CAS_NUM_STAT_KEYS);
4786}
4787
4788static struct ethtool_ops cas_ethtool_ops = {
4789 .get_drvinfo = cas_get_drvinfo,
4790 .get_settings = cas_get_settings,
4791 .set_settings = cas_set_settings,
4792 .nway_reset = cas_nway_reset,
4793 .get_link = cas_get_link,
4794 .get_msglevel = cas_get_msglevel,
4795 .set_msglevel = cas_set_msglevel,
4796 .get_regs_len = cas_get_regs_len,
4797 .get_regs = cas_get_regs,
4798 .get_stats_count = cas_get_stats_count,
4799 .get_strings = cas_get_strings,
4800 .get_ethtool_stats = cas_get_ethtool_stats,
4801};
4802
4803static int cas_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4804{
4805 struct cas *cp = netdev_priv(dev);
4806 struct mii_ioctl_data *data = if_mii(ifr);
4807 unsigned long flags;
4808 int rc = -EOPNOTSUPP;
4809
4810 /* Hold the PM semaphore while doing ioctl's or we may collide
4811 * with open/close and power management and oops.
4812 */
4813 down(&cp->pm_sem);
4814 switch (cmd) {
4815 case SIOCGMIIPHY: /* Get address of MII PHY in use. */
4816 data->phy_id = cp->phy_addr;
4817 /* Fallthrough... */
4818
4819 case SIOCGMIIREG: /* Read MII PHY register. */
4820 spin_lock_irqsave(&cp->lock, flags);
4821 cas_mif_poll(cp, 0);
4822 data->val_out = cas_phy_read(cp, data->reg_num & 0x1f);
4823 cas_mif_poll(cp, 1);
4824 spin_unlock_irqrestore(&cp->lock, flags);
4825 rc = 0;
4826 break;
4827
4828 case SIOCSMIIREG: /* Write MII PHY register. */
4829 if (!capable(CAP_NET_ADMIN)) {
4830 rc = -EPERM;
4831 break;
4832 }
4833 spin_lock_irqsave(&cp->lock, flags);
4834 cas_mif_poll(cp, 0);
4835 rc = cas_phy_write(cp, data->reg_num & 0x1f, data->val_in);
4836 cas_mif_poll(cp, 1);
4837 spin_unlock_irqrestore(&cp->lock, flags);
4838 break;
4839 default:
4840 break;
4841 };
4842
4843 up(&cp->pm_sem);
4844 return rc;
4845}
4846
4847static int __devinit cas_init_one(struct pci_dev *pdev,
4848 const struct pci_device_id *ent)
4849{
4850 static int cas_version_printed = 0;
4851 unsigned long casreg_base, casreg_len;
4852 struct net_device *dev;
4853 struct cas *cp;
4854 int i, err, pci_using_dac;
4855 u16 pci_cmd;
4856 u8 orig_cacheline_size = 0, cas_cacheline_size = 0;
4857
4858 if (cas_version_printed++ == 0)
4859 printk(KERN_INFO "%s", version);
4860
4861 err = pci_enable_device(pdev);
4862 if (err) {
4863 printk(KERN_ERR PFX "Cannot enable PCI device, "
4864 "aborting.\n");
4865 return err;
4866 }
4867
4868 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
4869 printk(KERN_ERR PFX "Cannot find proper PCI device "
4870 "base address, aborting.\n");
4871 err = -ENODEV;
4872 goto err_out_disable_pdev;
4873 }
4874
4875 dev = alloc_etherdev(sizeof(*cp));
4876 if (!dev) {
4877 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
4878 err = -ENOMEM;
4879 goto err_out_disable_pdev;
4880 }
4881 SET_MODULE_OWNER(dev);
4882 SET_NETDEV_DEV(dev, &pdev->dev);
4883
4884 err = pci_request_regions(pdev, dev->name);
4885 if (err) {
4886 printk(KERN_ERR PFX "Cannot obtain PCI resources, "
4887 "aborting.\n");
4888 goto err_out_free_netdev;
4889 }
4890 pci_set_master(pdev);
4891
4892 /* we must always turn on parity response or else parity
4893 * doesn't get generated properly. disable SERR/PERR as well.
4894 * in addition, we want to turn MWI on.
4895 */
4896 pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);
4897 pci_cmd &= ~PCI_COMMAND_SERR;
4898 pci_cmd |= PCI_COMMAND_PARITY;
4899 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
4900 pci_set_mwi(pdev);
4901 /*
4902 * On some architectures, the default cache line size set
4903 * by pci_set_mwi reduces perforamnce. We have to increase
4904 * it for this case. To start, we'll print some configuration
4905 * data.
4906 */
4907#if 1
4908 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE,
4909 &orig_cacheline_size);
4910 if (orig_cacheline_size < CAS_PREF_CACHELINE_SIZE) {
4911 cas_cacheline_size =
4912 (CAS_PREF_CACHELINE_SIZE < SMP_CACHE_BYTES) ?
4913 CAS_PREF_CACHELINE_SIZE : SMP_CACHE_BYTES;
4914 if (pci_write_config_byte(pdev,
4915 PCI_CACHE_LINE_SIZE,
4916 cas_cacheline_size)) {
4917 printk(KERN_ERR PFX "Could not set PCI cache "
4918 "line size\n");
4919 goto err_write_cacheline;
4920 }
4921 }
4922#endif
4923
4924
4925 /* Configure DMA attributes. */
4926 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
4927 pci_using_dac = 1;
4928 err = pci_set_consistent_dma_mask(pdev,
4929 DMA_64BIT_MASK);
4930 if (err < 0) {
4931 printk(KERN_ERR PFX "Unable to obtain 64-bit DMA "
4932 "for consistent allocations\n");
4933 goto err_out_free_res;
4934 }
4935
4936 } else {
4937 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
4938 if (err) {
4939 printk(KERN_ERR PFX "No usable DMA configuration, "
4940 "aborting.\n");
4941 goto err_out_free_res;
4942 }
4943 pci_using_dac = 0;
4944 }
4945
4946 casreg_base = pci_resource_start(pdev, 0);
4947 casreg_len = pci_resource_len(pdev, 0);
4948
4949 cp = netdev_priv(dev);
4950 cp->pdev = pdev;
4951#if 1
4952 /* A value of 0 indicates we never explicitly set it */
4953 cp->orig_cacheline_size = cas_cacheline_size ? orig_cacheline_size: 0;
4954#endif
4955 cp->dev = dev;
4956 cp->msg_enable = (cassini_debug < 0) ? CAS_DEF_MSG_ENABLE :
4957 cassini_debug;
4958
4959 cp->link_transition = LINK_TRANSITION_UNKNOWN;
4960 cp->link_transition_jiffies_valid = 0;
4961
4962 spin_lock_init(&cp->lock);
4963 spin_lock_init(&cp->rx_inuse_lock);
4964 spin_lock_init(&cp->rx_spare_lock);
4965 for (i = 0; i < N_TX_RINGS; i++) {
4966 spin_lock_init(&cp->stat_lock[i]);
4967 spin_lock_init(&cp->tx_lock[i]);
4968 }
4969 spin_lock_init(&cp->stat_lock[N_TX_RINGS]);
4970 init_MUTEX(&cp->pm_sem);
4971
4972 init_timer(&cp->link_timer);
4973 cp->link_timer.function = cas_link_timer;
4974 cp->link_timer.data = (unsigned long) cp;
4975
4976#if 1
4977 /* Just in case the implementation of atomic operations
4978 * change so that an explicit initialization is necessary.
4979 */
4980 atomic_set(&cp->reset_task_pending, 0);
4981 atomic_set(&cp->reset_task_pending_all, 0);
4982 atomic_set(&cp->reset_task_pending_spare, 0);
4983 atomic_set(&cp->reset_task_pending_mtu, 0);
4984#endif
4985 INIT_WORK(&cp->reset_task, cas_reset_task, cp);
4986
4987 /* Default link parameters */
4988 if (link_mode >= 0 && link_mode <= 6)
4989 cp->link_cntl = link_modes[link_mode];
4990 else
4991 cp->link_cntl = BMCR_ANENABLE;
4992 cp->lstate = link_down;
4993 cp->link_transition = LINK_TRANSITION_LINK_DOWN;
4994 netif_carrier_off(cp->dev);
4995 cp->timer_ticks = 0;
4996
4997 /* give us access to cassini registers */
4998 cp->regs = ioremap(casreg_base, casreg_len);
4999 if (cp->regs == 0UL) {
5000 printk(KERN_ERR PFX "Cannot map device registers, "
5001 "aborting.\n");
5002 goto err_out_free_res;
5003 }
5004 cp->casreg_len = casreg_len;
5005
5006 pci_save_state(pdev);
5007 cas_check_pci_invariants(cp);
5008 cas_hard_reset(cp);
5009 cas_reset(cp, 0);
5010 if (cas_check_invariants(cp))
5011 goto err_out_iounmap;
5012
5013 cp->init_block = (struct cas_init_block *)
5014 pci_alloc_consistent(pdev, sizeof(struct cas_init_block),
5015 &cp->block_dvma);
5016 if (!cp->init_block) {
5017 printk(KERN_ERR PFX "Cannot allocate init block, "
5018 "aborting.\n");
5019 goto err_out_iounmap;
5020 }
5021
5022 for (i = 0; i < N_TX_RINGS; i++)
5023 cp->init_txds[i] = cp->init_block->txds[i];
5024
5025 for (i = 0; i < N_RX_DESC_RINGS; i++)
5026 cp->init_rxds[i] = cp->init_block->rxds[i];
5027
5028 for (i = 0; i < N_RX_COMP_RINGS; i++)
5029 cp->init_rxcs[i] = cp->init_block->rxcs[i];
5030
5031 for (i = 0; i < N_RX_FLOWS; i++)
5032 skb_queue_head_init(&cp->rx_flows[i]);
5033
5034 dev->open = cas_open;
5035 dev->stop = cas_close;
5036 dev->hard_start_xmit = cas_start_xmit;
5037 dev->get_stats = cas_get_stats;
5038 dev->set_multicast_list = cas_set_multicast;
5039 dev->do_ioctl = cas_ioctl;
5040 dev->ethtool_ops = &cas_ethtool_ops;
5041 dev->tx_timeout = cas_tx_timeout;
5042 dev->watchdog_timeo = CAS_TX_TIMEOUT;
5043 dev->change_mtu = cas_change_mtu;
5044#ifdef USE_NAPI
5045 dev->poll = cas_poll;
5046 dev->weight = 64;
5047#endif
5048#ifdef CONFIG_NET_POLL_CONTROLLER
5049 dev->poll_controller = cas_netpoll;
5050#endif
5051 dev->irq = pdev->irq;
5052 dev->dma = 0;
5053
5054 /* Cassini features. */
5055 if ((cp->cas_flags & CAS_FLAG_NO_HW_CSUM) == 0)
5056 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
5057
5058 if (pci_using_dac)
5059 dev->features |= NETIF_F_HIGHDMA;
5060
5061 if (register_netdev(dev)) {
5062 printk(KERN_ERR PFX "Cannot register net device, "
5063 "aborting.\n");
5064 goto err_out_free_consistent;
5065 }
5066
5067 i = readl(cp->regs + REG_BIM_CFG);
5068 printk(KERN_INFO "%s: Sun Cassini%s (%sbit/%sMHz PCI/%s) "
5069 "Ethernet[%d] ", dev->name,
5070 (cp->cas_flags & CAS_FLAG_REG_PLUS) ? "+" : "",
5071 (i & BIM_CFG_32BIT) ? "32" : "64",
5072 (i & BIM_CFG_66MHZ) ? "66" : "33",
5073 (cp->phy_type == CAS_PHY_SERDES) ? "Fi" : "Cu", pdev->irq);
5074
5075 for (i = 0; i < 6; i++)
5076 printk("%2.2x%c", dev->dev_addr[i],
5077 i == 5 ? ' ' : ':');
5078 printk("\n");
5079
5080 pci_set_drvdata(pdev, dev);
5081 cp->hw_running = 1;
5082 cas_entropy_reset(cp);
5083 cas_phy_init(cp);
5084 cas_begin_auto_negotiation(cp, NULL);
5085 return 0;
5086
5087err_out_free_consistent:
5088 pci_free_consistent(pdev, sizeof(struct cas_init_block),
5089 cp->init_block, cp->block_dvma);
5090
5091err_out_iounmap:
5092 down(&cp->pm_sem);
5093 if (cp->hw_running)
5094 cas_shutdown(cp);
5095 up(&cp->pm_sem);
5096
5097 iounmap(cp->regs);
5098
5099
5100err_out_free_res:
5101 pci_release_regions(pdev);
5102
5103err_write_cacheline:
5104 /* Try to restore it in case the error occured after we
5105 * set it.
5106 */
5107 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, orig_cacheline_size);
5108
5109err_out_free_netdev:
5110 free_netdev(dev);
5111
5112err_out_disable_pdev:
5113 pci_disable_device(pdev);
5114 pci_set_drvdata(pdev, NULL);
5115 return -ENODEV;
5116}
5117
5118static void __devexit cas_remove_one(struct pci_dev *pdev)
5119{
5120 struct net_device *dev = pci_get_drvdata(pdev);
5121 struct cas *cp;
5122 if (!dev)
5123 return;
5124
5125 cp = netdev_priv(dev);
5126 unregister_netdev(dev);
5127
5128 down(&cp->pm_sem);
5129 flush_scheduled_work();
5130 if (cp->hw_running)
5131 cas_shutdown(cp);
5132 up(&cp->pm_sem);
5133
5134#if 1
5135 if (cp->orig_cacheline_size) {
5136 /* Restore the cache line size if we had modified
5137 * it.
5138 */
5139 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE,
5140 cp->orig_cacheline_size);
5141 }
5142#endif
5143 pci_free_consistent(pdev, sizeof(struct cas_init_block),
5144 cp->init_block, cp->block_dvma);
5145 iounmap(cp->regs);
5146 free_netdev(dev);
5147 pci_release_regions(pdev);
5148 pci_disable_device(pdev);
5149 pci_set_drvdata(pdev, NULL);
5150}
5151
5152#ifdef CONFIG_PM
5153static int cas_suspend(struct pci_dev *pdev, pm_message_t state)
5154{
5155 struct net_device *dev = pci_get_drvdata(pdev);
5156 struct cas *cp = netdev_priv(dev);
5157 unsigned long flags;
5158
5159 /* We hold the PM semaphore during entire driver
5160 * sleep time
5161 */
5162 down(&cp->pm_sem);
5163
5164 /* If the driver is opened, we stop the DMA */
5165 if (cp->opened) {
5166 netif_device_detach(dev);
5167
5168 cas_lock_all_save(cp, flags);
5169
5170 /* We can set the second arg of cas_reset to 0
5171 * because on resume, we'll call cas_init_hw with
5172 * its second arg set so that autonegotiation is
5173 * restarted.
5174 */
5175 cas_reset(cp, 0);
5176 cas_clean_rings(cp);
5177 cas_unlock_all_restore(cp, flags);
5178 }
5179
5180 if (cp->hw_running)
5181 cas_shutdown(cp);
5182
5183 return 0;
5184}
5185
5186static int cas_resume(struct pci_dev *pdev)
5187{
5188 struct net_device *dev = pci_get_drvdata(pdev);
5189 struct cas *cp = netdev_priv(dev);
5190
5191 printk(KERN_INFO "%s: resuming\n", dev->name);
5192
5193 cas_hard_reset(cp);
5194 if (cp->opened) {
5195 unsigned long flags;
5196 cas_lock_all_save(cp, flags);
5197 cas_reset(cp, 0);
5198 cp->hw_running = 1;
5199 cas_clean_rings(cp);
5200 cas_init_hw(cp, 1);
5201 cas_unlock_all_restore(cp, flags);
5202
5203 netif_device_attach(dev);
5204 }
5205 up(&cp->pm_sem);
5206 return 0;
5207}
5208#endif /* CONFIG_PM */
5209
5210static struct pci_driver cas_driver = {
5211 .name = DRV_MODULE_NAME,
5212 .id_table = cas_pci_tbl,
5213 .probe = cas_init_one,
5214 .remove = __devexit_p(cas_remove_one),
5215#ifdef CONFIG_PM
5216 .suspend = cas_suspend,
5217 .resume = cas_resume
5218#endif
5219};
5220
5221static int __init cas_init(void)
5222{
5223 if (linkdown_timeout > 0)
5224 link_transition_timeout = linkdown_timeout * HZ;
5225 else
5226 link_transition_timeout = 0;
5227
5228 return pci_module_init(&cas_driver);
5229}
5230
5231static void __exit cas_cleanup(void)
5232{
5233 pci_unregister_driver(&cas_driver);
5234}
5235
5236module_init(cas_init);
5237module_exit(cas_cleanup);
diff --git a/drivers/net/cassini.h b/drivers/net/cassini.h
new file mode 100644
index 000000000000..88063ef16cf6
--- /dev/null
+++ b/drivers/net/cassini.h
@@ -0,0 +1,4425 @@
1/* $Id: cassini.h,v 1.16 2004/08/17 21:15:16 zaumen Exp $
2 * cassini.h: Definitions for Sun Microsystems Cassini(+) ethernet driver.
3 *
4 * Copyright (C) 2004 Sun Microsystems Inc.
5 * Copyright (c) 2003 Adrian Sun (asun@darksunrising.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 *
22 * vendor id: 0x108E (Sun Microsystems, Inc.)
23 * device id: 0xabba (Cassini)
24 * revision ids: 0x01 = Cassini
25 * 0x02 = Cassini rev 2
26 * 0x10 = Cassini+
27 * 0x11 = Cassini+ 0.2u
28 *
29 * vendor id: 0x100b (National Semiconductor)
30 * device id: 0x0035 (DP83065/Saturn)
31 * revision ids: 0x30 = Saturn B2
32 *
33 * rings are all offset from 0.
34 *
35 * there are two clock domains:
36 * PCI: 33/66MHz clock
37 * chip: 125MHz clock
38 */
39
40#ifndef _CASSINI_H
41#define _CASSINI_H
42
43/* cassini register map: 2M memory mapped in 32-bit memory space accessible as
44 * 32-bit words. there is no i/o port access. REG_ addresses are
45 * shared between cassini and cassini+. REG_PLUS_ addresses only
46 * appear in cassini+. REG_MINUS_ addresses only appear in cassini.
47 */
48#define CAS_ID_REV2 0x02
49#define CAS_ID_REVPLUS 0x10
50#define CAS_ID_REVPLUS02u 0x11
51#define CAS_ID_REVSATURNB2 0x30
52
53/** global resources **/
54
55/* this register sets the weights for the weighted round robin arbiter. e.g.,
56 * if rx weight == 1 and tx weight == 0, rx == 2x tx transfer credit
57 * for its next turn to access the pci bus.
58 * map: 0x0 = x1, 0x1 = x2, 0x2 = x4, 0x3 = x8
59 * DEFAULT: 0x0, SIZE: 5 bits
60 */
61#define REG_CAWR 0x0004 /* core arbitration weight */
62#define CAWR_RX_DMA_WEIGHT_SHIFT 0
63#define CAWR_RX_DMA_WEIGHT_MASK 0x03 /* [0:1] */
64#define CAWR_TX_DMA_WEIGHT_SHIFT 2
65#define CAWR_TX_DMA_WEIGHT_MASK 0x0C /* [3:2] */
66#define CAWR_RR_DIS 0x10 /* [4] */
67
68/* if enabled, BIM can send bursts across PCI bus > cacheline size. burst
69 * sizes determined by length of packet or descriptor transfer and the
70 * max length allowed by the target.
71 * DEFAULT: 0x0, SIZE: 1 bit
72 */
73#define REG_INF_BURST 0x0008 /* infinite burst enable reg */
74#define INF_BURST_EN 0x1 /* enable */
75
76/* top level interrupts [0-9] are auto-cleared to 0 when the status
77 * register is read. second level interrupts [13 - 18] are cleared at
78 * the source. tx completion register 3 is replicated in [19 - 31]
79 * DEFAULT: 0x00000000, SIZE: 29 bits
80 */
81#define REG_INTR_STATUS 0x000C /* interrupt status register */
82#define INTR_TX_INTME 0x00000001 /* frame w/ INT ME desc bit set
83 xferred from host queue to
84 TX FIFO */
85#define INTR_TX_ALL 0x00000002 /* all xmit frames xferred into
86 TX FIFO. i.e.,
87 TX Kick == TX complete. if
88 PACED_MODE set, then TX FIFO
89 also empty */
90#define INTR_TX_DONE 0x00000004 /* any frame xferred into tx
91 FIFO */
92#define INTR_TX_TAG_ERROR 0x00000008 /* TX FIFO tag framing
93 corrupted. FATAL ERROR */
94#define INTR_RX_DONE 0x00000010 /* at least 1 frame xferred
95 from RX FIFO to host mem.
96 RX completion reg updated.
97 may be delayed by recv
98 intr blanking. */
99#define INTR_RX_BUF_UNAVAIL 0x00000020 /* no more receive buffers.
100 RX Kick == RX complete */
101#define INTR_RX_TAG_ERROR 0x00000040 /* RX FIFO tag framing
102 corrupted. FATAL ERROR */
103#define INTR_RX_COMP_FULL 0x00000080 /* no more room in completion
104 ring to post descriptors.
105 RX complete head incr to
106 almost reach RX complete
107 tail */
108#define INTR_RX_BUF_AE 0x00000100 /* less than the
109 programmable threshold #
110 of free descr avail for
111 hw use */
112#define INTR_RX_COMP_AF 0x00000200 /* less than the
113 programmable threshold #
114 of descr spaces for hw
115 use in completion descr
116 ring */
117#define INTR_RX_LEN_MISMATCH 0x00000400 /* len field from MAC !=
118 len of non-reassembly pkt
119 from fifo during DMA or
120 header parser provides TCP
121 header and payload size >
122 MAC packet size.
123 FATAL ERROR */
124#define INTR_SUMMARY 0x00001000 /* summary interrupt bit. this
125 bit will be set if an interrupt
126 generated on the pci bus. useful
127 when driver is polling for
128 interrupts */
129#define INTR_PCS_STATUS 0x00002000 /* PCS interrupt status register */
130#define INTR_TX_MAC_STATUS 0x00004000 /* TX MAC status register has at
131 least 1 unmasked interrupt set */
132#define INTR_RX_MAC_STATUS 0x00008000 /* RX MAC status register has at
133 least 1 unmasked interrupt set */
134#define INTR_MAC_CTRL_STATUS 0x00010000 /* MAC control status register has
135 at least 1 unmasked interrupt
136 set */
137#define INTR_MIF_STATUS 0x00020000 /* MIF status register has at least
138 1 unmasked interrupt set */
139#define INTR_PCI_ERROR_STATUS 0x00040000 /* PCI error status register in the
140 BIF has at least 1 unmasked
141 interrupt set */
142#define INTR_TX_COMP_3_MASK 0xFFF80000 /* mask for TX completion
143 3 reg data */
144#define INTR_TX_COMP_3_SHIFT 19
145#define INTR_ERROR_MASK (INTR_MIF_STATUS | INTR_PCI_ERROR_STATUS | \
146 INTR_PCS_STATUS | INTR_RX_LEN_MISMATCH | \
147 INTR_TX_MAC_STATUS | INTR_RX_MAC_STATUS | \
148 INTR_TX_TAG_ERROR | INTR_RX_TAG_ERROR | \
149 INTR_MAC_CTRL_STATUS)
150
151/* determines which status events will cause an interrupt. layout same
152 * as REG_INTR_STATUS.
153 * DEFAULT: 0xFFFFFFFF, SIZE: 16 bits
154 */
155#define REG_INTR_MASK 0x0010 /* Interrupt mask */
156
157/* top level interrupt bits that are cleared during read of REG_INTR_STATUS_ALIAS.
158 * useful when driver is polling for interrupts. layout same as REG_INTR_MASK.
159 * DEFAULT: 0x00000000, SIZE: 12 bits
160 */
161#define REG_ALIAS_CLEAR 0x0014 /* alias clear mask
162 (used w/ status alias) */
163/* same as REG_INTR_STATUS except that only bits cleared are those selected by
164 * REG_ALIAS_CLEAR
165 * DEFAULT: 0x00000000, SIZE: 29 bits
166 */
167#define REG_INTR_STATUS_ALIAS 0x001C /* interrupt status alias
168 (selective clear) */
169
170/* DEFAULT: 0x0, SIZE: 3 bits */
171#define REG_PCI_ERR_STATUS 0x1000 /* PCI error status */
172#define PCI_ERR_BADACK 0x01 /* reserved in Cassini+.
173 set if no ACK64# during ABS64 cycle
174 in Cassini. */
175#define PCI_ERR_DTRTO 0x02 /* delayed xaction timeout. set if
176 no read retry after 2^15 clocks */
177#define PCI_ERR_OTHER 0x04 /* other PCI errors */
178#define PCI_ERR_BIM_DMA_WRITE 0x08 /* BIM received 0 count DMA write req.
179 unused in Cassini. */
180#define PCI_ERR_BIM_DMA_READ 0x10 /* BIM received 0 count DMA read req.
181 unused in Cassini. */
182#define PCI_ERR_BIM_DMA_TIMEOUT 0x20 /* BIM received 255 retries during
183 DMA. unused in cassini. */
184
185/* mask for PCI status events that will set PCI_ERR_STATUS. if cleared, event
186 * causes an interrupt to be generated.
187 * DEFAULT: 0x7, SIZE: 3 bits
188 */
189#define REG_PCI_ERR_STATUS_MASK 0x1004 /* PCI Error status mask */
190
191/* used to configure PCI related parameters that are not in PCI config space.
192 * DEFAULT: 0bxx000, SIZE: 5 bits
193 */
194#define REG_BIM_CFG 0x1008 /* BIM Configuration */
195#define BIM_CFG_RESERVED0 0x001 /* reserved */
196#define BIM_CFG_RESERVED1 0x002 /* reserved */
197#define BIM_CFG_64BIT_DISABLE 0x004 /* disable 64-bit mode */
198#define BIM_CFG_66MHZ 0x008 /* (ro) 1 = 66MHz, 0 = < 66MHz */
199#define BIM_CFG_32BIT 0x010 /* (ro) 1 = 32-bit slot, 0 = 64-bit */
200#define BIM_CFG_DPAR_INTR_ENABLE 0x020 /* detected parity err enable */
201#define BIM_CFG_RMA_INTR_ENABLE 0x040 /* master abort intr enable */
202#define BIM_CFG_RTA_INTR_ENABLE 0x080 /* target abort intr enable */
203#define BIM_CFG_RESERVED2 0x100 /* reserved */
204#define BIM_CFG_BIM_DISABLE 0x200 /* stop BIM DMA. use before global
205 reset. reserved in Cassini. */
206#define BIM_CFG_BIM_STATUS 0x400 /* (ro) 1 = BIM DMA suspended.
207 reserved in Cassini. */
208#define BIM_CFG_PERROR_BLOCK 0x800 /* block PERR# to pci bus. def: 0.
209 reserved in Cassini. */
210
211/* DEFAULT: 0x00000000, SIZE: 32 bits */
212#define REG_BIM_DIAG 0x100C /* BIM Diagnostic */
213#define BIM_DIAG_MSTR_SM_MASK 0x3FFFFF00 /* PCI master controller state
214 machine bits [21:0] */
215#define BIM_DIAG_BRST_SM_MASK 0x7F /* PCI burst controller state
216 machine bits [6:0] */
217
218/* writing to SW_RESET_TX and SW_RESET_RX will issue a global
219 * reset. poll until TX and RX read back as 0's for completion.
220 */
221#define REG_SW_RESET 0x1010 /* Software reset */
222#define SW_RESET_TX 0x00000001 /* reset TX DMA engine. poll until
223 cleared to 0. */
224#define SW_RESET_RX 0x00000002 /* reset RX DMA engine. poll until
225 cleared to 0. */
226#define SW_RESET_RSTOUT 0x00000004 /* force RSTOUT# pin active (low).
227 resets PHY and anything else
228 connected to RSTOUT#. RSTOUT#
229 is also activated by local PCI
230 reset when hot-swap is being
231 done. */
232#define SW_RESET_BLOCK_PCS_SLINK 0x00000008 /* if a global reset is done with
233 this bit set, PCS and SLINK
234 modules won't be reset.
235 i.e., link won't drop. */
236#define SW_RESET_BREQ_SM_MASK 0x00007F00 /* breq state machine [6:0] */
237#define SW_RESET_PCIARB_SM_MASK 0x00070000 /* pci arbitration state bits:
238 0b000: ARB_IDLE1
239 0b001: ARB_IDLE2
240 0b010: ARB_WB_ACK
241 0b011: ARB_WB_WAT
242 0b100: ARB_RB_ACK
243 0b101: ARB_RB_WAT
244 0b110: ARB_RB_END
245 0b111: ARB_WB_END */
246#define SW_RESET_RDPCI_SM_MASK 0x00300000 /* read pci state bits:
247 0b00: RD_PCI_WAT
248 0b01: RD_PCI_RDY
249 0b11: RD_PCI_ACK */
250#define SW_RESET_RDARB_SM_MASK 0x00C00000 /* read arbitration state bits:
251 0b00: AD_IDL_RX
252 0b01: AD_ACK_RX
253 0b10: AD_ACK_TX
254 0b11: AD_IDL_TX */
255#define SW_RESET_WRPCI_SM_MASK 0x06000000 /* write pci state bits
256 0b00: WR_PCI_WAT
257 0b01: WR_PCI_RDY
258 0b11: WR_PCI_ACK */
259#define SW_RESET_WRARB_SM_MASK 0x38000000 /* write arbitration state bits:
260 0b000: ARB_IDLE1
261 0b001: ARB_IDLE2
262 0b010: ARB_TX_ACK
263 0b011: ARB_TX_WAT
264 0b100: ARB_RX_ACK
265 0b110: ARB_RX_WAT */
266
267/* Cassini only. 64-bit register used to check PCI datapath. when read,
268 * value written has both lower and upper 32-bit halves rotated to the right
269 * one bit position. e.g., FFFFFFFF FFFFFFFF -> 7FFFFFFF 7FFFFFFF
270 */
271#define REG_MINUS_BIM_DATAPATH_TEST 0x1018 /* Cassini: BIM datapath test
272 Cassini+: reserved */
273
274/* output enables are provided for each device's chip select and for the rest
275 * of the outputs from cassini to its local bus devices. two sw programmable
276 * bits are connected to general purpus control/status bits.
277 * DEFAULT: 0x7
278 */
279#define REG_BIM_LOCAL_DEV_EN 0x1020 /* BIM local device
280 output EN. default: 0x7 */
281#define BIM_LOCAL_DEV_PAD 0x01 /* address bus, RW signal, and
282 OE signal output enable on the
283 local bus interface. these
284 are shared between both local
285 bus devices. tristate when 0. */
286#define BIM_LOCAL_DEV_PROM 0x02 /* PROM chip select */
287#define BIM_LOCAL_DEV_EXT 0x04 /* secondary local bus device chip
288 select output enable */
289#define BIM_LOCAL_DEV_SOFT_0 0x08 /* sw programmable ctrl bit 0 */
290#define BIM_LOCAL_DEV_SOFT_1 0x10 /* sw programmable ctrl bit 1 */
291#define BIM_LOCAL_DEV_HW_RESET 0x20 /* internal hw reset. Cassini+ only. */
292
293/* access 24 entry BIM read and write buffers. put address in REG_BIM_BUFFER_ADDR
294 * and read/write from/to it REG_BIM_BUFFER_DATA_LOW and _DATA_HI.
295 * _DATA_HI should be the last access of the sequence.
296 * DEFAULT: undefined
297 */
298#define REG_BIM_BUFFER_ADDR 0x1024 /* BIM buffer address. for
299 purposes. */
300#define BIM_BUFFER_ADDR_MASK 0x3F /* index (0 - 23) of buffer */
301#define BIM_BUFFER_WR_SELECT 0x40 /* write buffer access = 1
302 read buffer access = 0 */
303/* DEFAULT: undefined */
304#define REG_BIM_BUFFER_DATA_LOW 0x1028 /* BIM buffer data low */
305#define REG_BIM_BUFFER_DATA_HI 0x102C /* BIM buffer data high */
306
307/* set BIM_RAM_BIST_START to start built-in self test for BIM read buffer.
308 * bit auto-clears when done with status read from _SUMMARY and _PASS bits.
309 */
310#define REG_BIM_RAM_BIST 0x102C /* BIM RAM (read buffer) BIST
311 control/status */
312#define BIM_RAM_BIST_RD_START 0x01 /* start BIST for BIM read buffer */
313#define BIM_RAM_BIST_WR_START 0x02 /* start BIST for BIM write buffer.
314 Cassini only. reserved in
315 Cassini+. */
316#define BIM_RAM_BIST_RD_PASS 0x04 /* summary BIST pass status for read
317 buffer. */
318#define BIM_RAM_BIST_WR_PASS 0x08 /* summary BIST pass status for write
319 buffer. Cassini only. reserved
320 in Cassini+. */
321#define BIM_RAM_BIST_RD_LOW_PASS 0x10 /* read low bank passes BIST */
322#define BIM_RAM_BIST_RD_HI_PASS 0x20 /* read high bank passes BIST */
323#define BIM_RAM_BIST_WR_LOW_PASS 0x40 /* write low bank passes BIST.
324 Cassini only. reserved in
325 Cassini+. */
326#define BIM_RAM_BIST_WR_HI_PASS 0x80 /* write high bank passes BIST.
327 Cassini only. reserved in
328 Cassini+. */
329
330/* ASUN: i'm not sure what this does as it's not in the spec.
331 * DEFAULT: 0xFC
332 */
333#define REG_BIM_DIAG_MUX 0x1030 /* BIM diagnostic probe mux
334 select register */
335
336/* enable probe monitoring mode and select data appearing on the P_A* bus. bit
337 * values for _SEL_HI_MASK and _SEL_LOW_MASK:
338 * 0x0: internal probe[7:0] (pci arb state, wtc empty w, wtc full w, wtc empty w,
339 * wtc empty r, post pci)
340 * 0x1: internal probe[15:8] (pci wbuf comp, pci wpkt comp, pci rbuf comp,
341 * pci rpkt comp, txdma wr req, txdma wr ack,
342 * txdma wr rdy, txdma wr xfr done)
343 * 0x2: internal probe[23:16] (txdma rd req, txdma rd ack, txdma rd rdy, rxdma rd,
344 * rd arb state, rd pci state)
345 * 0x3: internal probe[31:24] (rxdma req, rxdma ack, rxdma rdy, wrarb state,
346 * wrpci state)
347 * 0x4: pci io probe[7:0] 0x5: pci io probe[15:8]
348 * 0x6: pci io probe[23:16] 0x7: pci io probe[31:24]
349 * 0x8: pci io probe[39:32] 0x9: pci io probe[47:40]
350 * 0xa: pci io probe[55:48] 0xb: pci io probe[63:56]
351 * the following are not available in Cassini:
352 * 0xc: rx probe[7:0] 0xd: tx probe[7:0]
353 * 0xe: hp probe[7:0] 0xf: mac probe[7:0]
354 */
355#define REG_PLUS_PROBE_MUX_SELECT 0x1034 /* Cassini+: PROBE MUX SELECT */
356#define PROBE_MUX_EN 0x80000000 /* allow probe signals to be
357 driven on local bus P_A[15:0]
358 for debugging */
359#define PROBE_MUX_SUB_MUX_MASK 0x0000FF00 /* select sub module probe signals:
360 0x03 = mac[1:0]
361 0x0C = rx[1:0]
362 0x30 = tx[1:0]
363 0xC0 = hp[1:0] */
364#define PROBE_MUX_SEL_HI_MASK 0x000000F0 /* select which module to appear
365 on P_A[15:8]. see above for
366 values. */
367#define PROBE_MUX_SEL_LOW_MASK 0x0000000F /* select which module to appear
368 on P_A[7:0]. see above for
369 values. */
370
371/* values mean the same thing as REG_INTR_MASK excep that it's for INTB.
372 DEFAULT: 0x1F */
373#define REG_PLUS_INTR_MASK_1 0x1038 /* Cassini+: interrupt mask
374 register 2 for INTB */
375#define REG_PLUS_INTRN_MASK(x) (REG_PLUS_INTR_MASK_1 + ((x) - 1)*16)
376/* bits correspond to both _MASK and _STATUS registers. _ALT corresponds to
377 * all of the alternate (2-4) INTR registers while _1 corresponds to only
378 * _MASK_1 and _STATUS_1 registers.
379 * DEFAULT: 0x7 for MASK registers, 0x0 for ALIAS_CLEAR registers
380 */
381#define INTR_RX_DONE_ALT 0x01
382#define INTR_RX_COMP_FULL_ALT 0x02
383#define INTR_RX_COMP_AF_ALT 0x04
384#define INTR_RX_BUF_UNAVAIL_1 0x08
385#define INTR_RX_BUF_AE_1 0x10 /* almost empty */
386#define INTRN_MASK_RX_EN 0x80
387#define INTRN_MASK_CLEAR_ALL (INTR_RX_DONE_ALT | \
388 INTR_RX_COMP_FULL_ALT | \
389 INTR_RX_COMP_AF_ALT | \
390 INTR_RX_BUF_UNAVAIL_1 | \
391 INTR_RX_BUF_AE_1)
392#define REG_PLUS_INTR_STATUS_1 0x103C /* Cassini+: interrupt status
393 register 2 for INTB. default: 0x1F */
394#define REG_PLUS_INTRN_STATUS(x) (REG_PLUS_INTR_STATUS_1 + ((x) - 1)*16)
395#define INTR_STATUS_ALT_INTX_EN 0x80 /* generate INTX when one of the
396 flags are set. enables desc ring. */
397
398#define REG_PLUS_ALIAS_CLEAR_1 0x1040 /* Cassini+: alias clear mask
399 register 2 for INTB */
400#define REG_PLUS_ALIASN_CLEAR(x) (REG_PLUS_ALIAS_CLEAR_1 + ((x) - 1)*16)
401
402#define REG_PLUS_INTR_STATUS_ALIAS_1 0x1044 /* Cassini+: interrupt status
403 register alias 2 for INTB */
404#define REG_PLUS_INTRN_STATUS_ALIAS(x) (REG_PLUS_INTR_STATUS_ALIAS_1 + ((x) - 1)*16)
405
406#define REG_SATURN_PCFG 0x106c /* pin configuration register for
407 integrated macphy */
408
409#define SATURN_PCFG_TLA 0x00000001 /* 1 = phy actled */
410#define SATURN_PCFG_FLA 0x00000002 /* 1 = phy link10led */
411#define SATURN_PCFG_CLA 0x00000004 /* 1 = phy link100led */
412#define SATURN_PCFG_LLA 0x00000008 /* 1 = phy link1000led */
413#define SATURN_PCFG_RLA 0x00000010 /* 1 = phy duplexled */
414#define SATURN_PCFG_PDS 0x00000020 /* phy debug mode.
415 0 = normal */
416#define SATURN_PCFG_MTP 0x00000080 /* test point select */
417#define SATURN_PCFG_GMO 0x00000100 /* GMII observe. 1 =
418 GMII on SERDES pins for
419 monitoring. */
420#define SATURN_PCFG_FSI 0x00000200 /* 1 = freeze serdes/gmii. all
421 pins configed as outputs.
422 for power saving when using
423 internal phy. */
424#define SATURN_PCFG_LAD 0x00000800 /* 0 = mac core led ctrl
425 polarity from strapping
426 value.
427 1 = mac core led ctrl
428 polarity active low. */
429
430
431/** transmit dma registers **/
432#define MAX_TX_RINGS_SHIFT 2
433#define MAX_TX_RINGS (1 << MAX_TX_RINGS_SHIFT)
434#define MAX_TX_RINGS_MASK (MAX_TX_RINGS - 1)
435
436/* TX configuration.
437 * descr ring sizes size = 32 * (1 << n), n < 9. e.g., 0x8 = 8k. default: 0x8
438 * DEFAULT: 0x3F000001
439 */
440#define REG_TX_CFG 0x2004 /* TX config */
441#define TX_CFG_DMA_EN 0x00000001 /* enable TX DMA. if cleared, DMA
442 will stop after xfer of current
443 buffer has been completed. */
444#define TX_CFG_FIFO_PIO_SEL 0x00000002 /* TX DMA FIFO can be
445 accessed w/ FIFO addr
446 and data registers.
447 TX DMA should be
448 disabled. */
449#define TX_CFG_DESC_RING0_MASK 0x0000003C /* # desc entries in
450 ring 1. */
451#define TX_CFG_DESC_RING0_SHIFT 2
452#define TX_CFG_DESC_RINGN_MASK(a) (TX_CFG_DESC_RING0_MASK << (a)*4)
453#define TX_CFG_DESC_RINGN_SHIFT(a) (TX_CFG_DESC_RING0_SHIFT + (a)*4)
454#define TX_CFG_PACED_MODE 0x00100000 /* TX_ALL only set after
455 TX FIFO becomes empty.
456 if 0, TX_ALL set
457 if descr queue empty. */
458#define TX_CFG_DMA_RDPIPE_DIS 0x01000000 /* always set to 1 */
459#define TX_CFG_COMPWB_Q1 0x02000000 /* completion writeback happens at
460 the end of every packet kicked
461 through Q1. */
462#define TX_CFG_COMPWB_Q2 0x04000000 /* completion writeback happens at
463 the end of every packet kicked
464 through Q2. */
465#define TX_CFG_COMPWB_Q3 0x08000000 /* completion writeback happens at
466 the end of every packet kicked
467 through Q3 */
468#define TX_CFG_COMPWB_Q4 0x10000000 /* completion writeback happens at
469 the end of every packet kicked
470 through Q4 */
471#define TX_CFG_INTR_COMPWB_DIS 0x20000000 /* disable pre-interrupt completion
472 writeback */
473#define TX_CFG_CTX_SEL_MASK 0xC0000000 /* selects tx test port
474 connection
475 0b00: tx mac req,
476 tx mac retry req,
477 tx ack and tx tag.
478 0b01: txdma rd req,
479 txdma rd ack,
480 txdma rd rdy,
481 txdma rd type0
482 0b11: txdma wr req,
483 txdma wr ack,
484 txdma wr rdy,
485 txdma wr xfr done. */
486#define TX_CFG_CTX_SEL_SHIFT 30
487
488/* 11-bit counters that point to next location in FIFO to be loaded/retrieved.
489 * used for diagnostics only.
490 */
491#define REG_TX_FIFO_WRITE_PTR 0x2014 /* TX FIFO write pointer */
492#define REG_TX_FIFO_SHADOW_WRITE_PTR 0x2018 /* TX FIFO shadow write
493 pointer. temp hold reg.
494 diagnostics only. */
495#define REG_TX_FIFO_READ_PTR 0x201C /* TX FIFO read pointer */
496#define REG_TX_FIFO_SHADOW_READ_PTR 0x2020 /* TX FIFO shadow read
497 pointer */
498
499/* (ro) 11-bit up/down counter w/ # of frames currently in TX FIFO */
500#define REG_TX_FIFO_PKT_CNT 0x2024 /* TX FIFO packet counter */
501
502/* current state of all state machines in TX */
503#define REG_TX_SM_1 0x2028 /* TX state machine reg #1 */
504#define TX_SM_1_CHAIN_MASK 0x000003FF /* chaining state machine */
505#define TX_SM_1_CSUM_MASK 0x00000C00 /* checksum state machine */
506#define TX_SM_1_FIFO_LOAD_MASK 0x0003F000 /* FIFO load state machine.
507 = 0x01 when TX disabled. */
508#define TX_SM_1_FIFO_UNLOAD_MASK 0x003C0000 /* FIFO unload state machine */
509#define TX_SM_1_CACHE_MASK 0x03C00000 /* desc. prefetch cache controller
510 state machine */
511#define TX_SM_1_CBQ_ARB_MASK 0xF8000000 /* CBQ arbiter state machine */
512
513#define REG_TX_SM_2 0x202C /* TX state machine reg #2 */
514#define TX_SM_2_COMP_WB_MASK 0x07 /* completion writeback sm */
515#define TX_SM_2_SUB_LOAD_MASK 0x38 /* sub load state machine */
516#define TX_SM_2_KICK_MASK 0xC0 /* kick state machine */
517
518/* 64-bit pointer to the transmit data buffer. only the 50 LSB are incremented
519 * while the upper 23 bits are taken from the TX descriptor
520 */
521#define REG_TX_DATA_PTR_LOW 0x2030 /* TX data pointer low */
522#define REG_TX_DATA_PTR_HI 0x2034 /* TX data pointer high */
523
524/* 13 bit registers written by driver w/ descriptor value that follows
525 * last valid xmit descriptor. kick # and complete # values are used by
526 * the xmit dma engine to control tx descr fetching. if > 1 valid
527 * tx descr is available within the cache line being read, cassini will
528 * internally cache up to 4 of them. 0 on reset. _KICK = rw, _COMP = ro.
529 */
530#define REG_TX_KICK0 0x2038 /* TX kick reg #1 */
531#define REG_TX_KICKN(x) (REG_TX_KICK0 + (x)*4)
532#define REG_TX_COMP0 0x2048 /* TX completion reg #1 */
533#define REG_TX_COMPN(x) (REG_TX_COMP0 + (x)*4)
534
535/* values of TX_COMPLETE_1-4 are written. each completion register
536 * is 2bytes in size and contiguous. 8B allocation w/ 8B alignment.
537 * NOTE: completion reg values are only written back prior to TX_INTME and
538 * TX_ALL interrupts. at all other times, the most up-to-date index values
539 * should be obtained from the REG_TX_COMPLETE_# registers.
540 * here's the layout:
541 * offset from base addr completion # byte
542 * 0 TX_COMPLETE_1_MSB
543 * 1 TX_COMPLETE_1_LSB
544 * 2 TX_COMPLETE_2_MSB
545 * 3 TX_COMPLETE_2_LSB
546 * 4 TX_COMPLETE_3_MSB
547 * 5 TX_COMPLETE_3_LSB
548 * 6 TX_COMPLETE_4_MSB
549 * 7 TX_COMPLETE_4_LSB
550 */
551#define TX_COMPWB_SIZE 8
552#define REG_TX_COMPWB_DB_LOW 0x2058 /* TX completion write back
553 base low */
554#define REG_TX_COMPWB_DB_HI 0x205C /* TX completion write back
555 base high */
556#define TX_COMPWB_MSB_MASK 0x00000000000000FFULL
557#define TX_COMPWB_MSB_SHIFT 0
558#define TX_COMPWB_LSB_MASK 0x000000000000FF00ULL
559#define TX_COMPWB_LSB_SHIFT 8
560#define TX_COMPWB_NEXT(x) ((x) >> 16)
561
562/* 53 MSB used as base address. 11 LSB assumed to be 0. TX desc pointer must
563 * be 2KB-aligned. */
564#define REG_TX_DB0_LOW 0x2060 /* TX descriptor base low #1 */
565#define REG_TX_DB0_HI 0x2064 /* TX descriptor base hi #1 */
566#define REG_TX_DBN_LOW(x) (REG_TX_DB0_LOW + (x)*8)
567#define REG_TX_DBN_HI(x) (REG_TX_DB0_HI + (x)*8)
568
569/* 16-bit registers hold weights for the weighted round-robin of the
570 * four CBQ TX descr rings. weights correspond to # bytes xferred from
571 * host to TXFIFO in a round of WRR arbitration. can be set
572 * dynamically with new weights set upon completion of the current
573 * packet transfer from host memory to TXFIFO. a dummy write to any of
574 * these registers causes a queue1 pre-emption with all historical bw
575 * deficit data reset to 0 (useful when congestion requires a
576 * pre-emption/re-allocation of network bandwidth
577 */
578#define REG_TX_MAXBURST_0 0x2080 /* TX MaxBurst #1 */
579#define REG_TX_MAXBURST_1 0x2084 /* TX MaxBurst #2 */
580#define REG_TX_MAXBURST_2 0x2088 /* TX MaxBurst #3 */
581#define REG_TX_MAXBURST_3 0x208C /* TX MaxBurst #4 */
582
583/* diagnostics access to any TX FIFO location. every access is 65
584 * bits. _DATA_LOW = 32 LSB, _DATA_HI_T1/T0 = 32 MSB. _TAG = tag bit.
585 * writing _DATA_HI_T0 sets tag bit low, writing _DATA_HI_T1 sets tag
586 * bit high. TX_FIFO_PIO_SEL must be set for TX FIFO PIO access. if
587 * TX FIFO data integrity is desired, TX DMA should be
588 * disabled. _DATA_HI_Tx should be the last access of the sequence.
589 */
590#define REG_TX_FIFO_ADDR 0x2104 /* TX FIFO address */
591#define REG_TX_FIFO_TAG 0x2108 /* TX FIFO tag */
592#define REG_TX_FIFO_DATA_LOW 0x210C /* TX FIFO data low */
593#define REG_TX_FIFO_DATA_HI_T1 0x2110 /* TX FIFO data high t1 */
594#define REG_TX_FIFO_DATA_HI_T0 0x2114 /* TX FIFO data high t0 */
595#define REG_TX_FIFO_SIZE 0x2118 /* (ro) TX FIFO size = 0x090 = 9KB */
596
597/* 9-bit register controls BIST of TX FIFO. bit set indicates that the BIST
598 * passed for the specified memory
599 */
600#define REG_TX_RAMBIST 0x211C /* TX RAMBIST control/status */
601#define TX_RAMBIST_STATE 0x01C0 /* progress state of RAMBIST
602 controller state machine */
603#define TX_RAMBIST_RAM33A_PASS 0x0020 /* RAM33A passed */
604#define TX_RAMBIST_RAM32A_PASS 0x0010 /* RAM32A passed */
605#define TX_RAMBIST_RAM33B_PASS 0x0008 /* RAM33B passed */
606#define TX_RAMBIST_RAM32B_PASS 0x0004 /* RAM32B passed */
607#define TX_RAMBIST_SUMMARY 0x0002 /* all RAM passed */
608#define TX_RAMBIST_START 0x0001 /* write 1 to start BIST. self
609 clears on completion. */
610
611/** receive dma registers **/
612#define MAX_RX_DESC_RINGS 2
613#define MAX_RX_COMP_RINGS 4
614
615/* receive DMA channel configuration. default: 0x80910
616 * free ring size = (1 << n)*32 -> [32 - 8k]
617 * completion ring size = (1 << n)*128 -> [128 - 32k], n < 9
618 * DEFAULT: 0x80910
619 */
620#define REG_RX_CFG 0x4000 /* RX config */
621#define RX_CFG_DMA_EN 0x00000001 /* enable RX DMA. 0 stops
622 channel as soon as current
623 frame xfer has completed.
624 driver should disable MAC
625 for 200ms before disabling
626 RX */
627#define RX_CFG_DESC_RING_MASK 0x0000001E /* # desc entries in RX
628 free desc ring.
629 def: 0x8 = 8k */
630#define RX_CFG_DESC_RING_SHIFT 1
631#define RX_CFG_COMP_RING_MASK 0x000001E0 /* # desc entries in RX complete
632 ring. def: 0x8 = 32k */
633#define RX_CFG_COMP_RING_SHIFT 5
634#define RX_CFG_BATCH_DIS 0x00000200 /* disable receive desc
635 batching. def: 0x0 =
636 enabled */
637#define RX_CFG_SWIVEL_MASK 0x00001C00 /* byte offset of the 1st
638 data byte of the packet
639 w/in 8 byte boundares.
640 this swivels the data
641 DMA'ed to header
642 buffers, jumbo buffers
643 when header split is not
644 requested and MTU sized
645 buffers. def: 0x2 */
646#define RX_CFG_SWIVEL_SHIFT 10
647
648/* cassini+ only */
649#define RX_CFG_DESC_RING1_MASK 0x000F0000 /* # of desc entries in
650 RX free desc ring 2.
651 def: 0x8 = 8k */
652#define RX_CFG_DESC_RING1_SHIFT 16
653
654
655/* the page size register allows cassini chips to do the following with
656 * received data:
657 * [--------------------------------------------------------------] page
658 * [off][buf1][pad][off][buf2][pad][off][buf3][pad][off][buf4][pad]
659 * |--------------| = PAGE_SIZE_BUFFER_STRIDE
660 * page = PAGE_SIZE
661 * offset = PAGE_SIZE_MTU_OFF
662 * for the above example, MTU_BUFFER_COUNT = 4.
663 * NOTE: as is apparent, you need to ensure that the following holds:
664 * MTU_BUFFER_COUNT <= PAGE_SIZE/PAGE_SIZE_BUFFER_STRIDE
665 * DEFAULT: 0x48002002 (8k pages)
666 */
667#define REG_RX_PAGE_SIZE 0x4004 /* RX page size */
668#define RX_PAGE_SIZE_MASK 0x00000003 /* size of pages pointed to
669 by receive descriptors.
670 if jumbo buffers are
671 supported the page size
672 should not be < 8k.
673 0b00 = 2k, 0b01 = 4k
674 0b10 = 8k, 0b11 = 16k
675 DEFAULT: 8k */
676#define RX_PAGE_SIZE_SHIFT 0
677#define RX_PAGE_SIZE_MTU_COUNT_MASK 0x00007800 /* # of MTU buffers the hw
678 packs into a page.
679 DEFAULT: 4 */
680#define RX_PAGE_SIZE_MTU_COUNT_SHIFT 11
681#define RX_PAGE_SIZE_MTU_STRIDE_MASK 0x18000000 /* # of bytes that separate
682 each MTU buffer +
683 offset from each
684 other.
685 0b00 = 1k, 0b01 = 2k
686 0b10 = 4k, 0b11 = 8k
687 DEFAULT: 0x1 */
688#define RX_PAGE_SIZE_MTU_STRIDE_SHIFT 27
689#define RX_PAGE_SIZE_MTU_OFF_MASK 0xC0000000 /* offset in each page that
690 hw writes the MTU buffer
691 into.
692 0b00 = 0,
693 0b01 = 64 bytes
694 0b10 = 96, 0b11 = 128
695 DEFAULT: 0x1 */
696#define RX_PAGE_SIZE_MTU_OFF_SHIFT 30
697
698/* 11-bit counter points to next location in RX FIFO to be loaded/read.
699 * shadow write pointers enable retries in case of early receive aborts.
700 * DEFAULT: 0x0. generated on 64-bit boundaries.
701 */
702#define REG_RX_FIFO_WRITE_PTR 0x4008 /* RX FIFO write pointer */
703#define REG_RX_FIFO_READ_PTR 0x400C /* RX FIFO read pointer */
704#define REG_RX_IPP_FIFO_SHADOW_WRITE_PTR 0x4010 /* RX IPP FIFO shadow write
705 pointer */
706#define REG_RX_IPP_FIFO_SHADOW_READ_PTR 0x4014 /* RX IPP FIFO shadow read
707 pointer */
708#define REG_RX_IPP_FIFO_READ_PTR 0x400C /* RX IPP FIFO read
709 pointer. (8-bit counter) */
710
711/* current state of RX DMA state engines + other info
712 * DEFAULT: 0x0
713 */
714#define REG_RX_DEBUG 0x401C /* RX debug */
715#define RX_DEBUG_LOAD_STATE_MASK 0x0000000F /* load state machine w/ MAC:
716 0x0 = idle, 0x1 = load_bop
717 0x2 = load 1, 0x3 = load 2
718 0x4 = load 3, 0x5 = load 4
719 0x6 = last detect
720 0x7 = wait req
721 0x8 = wait req statuss 1st
722 0x9 = load st
723 0xa = bubble mac
724 0xb = error */
725#define RX_DEBUG_LM_STATE_MASK 0x00000070 /* load state machine w/ HP and
726 RX FIFO:
727 0x0 = idle, 0x1 = hp xfr
728 0x2 = wait hp ready
729 0x3 = wait flow code
730 0x4 = fifo xfer
731 0x5 = make status
732 0x6 = csum ready
733 0x7 = error */
734#define RX_DEBUG_FC_STATE_MASK 0x000000180 /* flow control state machine
735 w/ MAC:
736 0x0 = idle
737 0x1 = wait xoff ack
738 0x2 = wait xon
739 0x3 = wait xon ack */
740#define RX_DEBUG_DATA_STATE_MASK 0x000001E00 /* unload data state machine
741 states:
742 0x0 = idle data
743 0x1 = header begin
744 0x2 = xfer header
745 0x3 = xfer header ld
746 0x4 = mtu begin
747 0x5 = xfer mtu
748 0x6 = xfer mtu ld
749 0x7 = jumbo begin
750 0x8 = xfer jumbo
751 0x9 = xfer jumbo ld
752 0xa = reas begin
753 0xb = xfer reas
754 0xc = flush tag
755 0xd = xfer reas ld
756 0xe = error
757 0xf = bubble idle */
758#define RX_DEBUG_DESC_STATE_MASK 0x0001E000 /* unload desc state machine
759 states:
760 0x0 = idle desc
761 0x1 = wait ack
762 0x9 = wait ack 2
763 0x2 = fetch desc 1
764 0xa = fetch desc 2
765 0x3 = load ptrs
766 0x4 = wait dma
767 0x5 = wait ack batch
768 0x6 = post batch
769 0x7 = xfr done */
770#define RX_DEBUG_INTR_READ_PTR_MASK 0x30000000 /* interrupt read ptr of the
771 interrupt queue */
772#define RX_DEBUG_INTR_WRITE_PTR_MASK 0xC0000000 /* interrupt write pointer
773 of the interrupt queue */
774
775/* flow control frames are emmitted using two PAUSE thresholds:
776 * XOFF PAUSE uses pause time value pre-programmed in the Send PAUSE MAC reg
777 * XON PAUSE uses a pause time of 0. granularity of threshold is 64bytes.
778 * PAUSE thresholds defined in terms of FIFO occupancy and may be translated
779 * into FIFO vacancy using RX_FIFO_SIZE. setting ON will trigger XON frames
780 * when FIFO reaches 0. OFF threshold should not be > size of RX FIFO. max
781 * value is is 0x6F.
782 * DEFAULT: 0x00078
783 */
784#define REG_RX_PAUSE_THRESH 0x4020 /* RX pause thresholds */
785#define RX_PAUSE_THRESH_QUANTUM 64
786#define RX_PAUSE_THRESH_OFF_MASK 0x000001FF /* XOFF PAUSE emitted when
787 RX FIFO occupancy >
788 value*64B */
789#define RX_PAUSE_THRESH_OFF_SHIFT 0
790#define RX_PAUSE_THRESH_ON_MASK 0x001FF000 /* XON PAUSE emitted after
791 emitting XOFF PAUSE when RX
792 FIFO occupancy falls below
793 this value*64B. must be
794 < XOFF threshold. if =
795 RX_FIFO_SIZE< XON frames are
796 never emitted. */
797#define RX_PAUSE_THRESH_ON_SHIFT 12
798
799/* 13-bit register used to control RX desc fetching and intr generation. if 4+
800 * valid RX descriptors are available, Cassini will read 4 at a time.
801 * writing N means that all desc up to *but* excluding N are available. N must
802 * be a multiple of 4 (N % 4 = 0). first desc should be cache-line aligned.
803 * DEFAULT: 0 on reset
804 */
805#define REG_RX_KICK 0x4024 /* RX kick reg */
806
807/* 8KB aligned 64-bit pointer to the base of the RX free/completion rings.
808 * lower 13 bits of the low register are hard-wired to 0.
809 */
810#define REG_RX_DB_LOW 0x4028 /* RX descriptor ring
811 base low */
812#define REG_RX_DB_HI 0x402C /* RX descriptor ring
813 base hi */
814#define REG_RX_CB_LOW 0x4030 /* RX completion ring
815 base low */
816#define REG_RX_CB_HI 0x4034 /* RX completion ring
817 base hi */
818/* 13-bit register indicate desc used by cassini for receive frames. used
819 * for diagnostic purposes.
820 * DEFAULT: 0 on reset
821 */
822#define REG_RX_COMP 0x4038 /* (ro) RX completion */
823
824/* HEAD and TAIL are used to control RX desc posting and interrupt
825 * generation. hw moves the head register to pass ownership to sw. sw
826 * moves the tail register to pass ownership back to hw. to give all
827 * entries to hw, set TAIL = HEAD. if HEAD and TAIL indicate that no
828 * more entries are available, DMA will pause and an interrupt will be
829 * generated to indicate no more entries are available. sw can use
830 * this interrupt to reduce the # of times it must update the
831 * completion tail register.
832 * DEFAULT: 0 on reset
833 */
834#define REG_RX_COMP_HEAD 0x403C /* RX completion head */
835#define REG_RX_COMP_TAIL 0x4040 /* RX completion tail */
836
837/* values used for receive interrupt blanking. loaded each time the ISR is read
838 * DEFAULT: 0x00000000
839 */
840#define REG_RX_BLANK 0x4044 /* RX blanking register
841 for ISR read */
842#define RX_BLANK_INTR_PKT_MASK 0x000001FF /* RX_DONE intr asserted if
843 this many sets of completion
844 writebacks (up to 2 packets)
845 occur since the last time
846 the ISR was read. 0 = no
847 packet blanking */
848#define RX_BLANK_INTR_PKT_SHIFT 0
849#define RX_BLANK_INTR_TIME_MASK 0x3FFFF000 /* RX_DONE interrupt asserted
850 if that many clocks were
851 counted since last time the
852 ISR was read.
853 each count is 512 core
854 clocks (125MHz). 0 = no
855 time blanking */
856#define RX_BLANK_INTR_TIME_SHIFT 12
857
858/* values used for interrupt generation based on threshold values of how
859 * many free desc and completion entries are available for hw use.
860 * DEFAULT: 0x00000000
861 */
862#define REG_RX_AE_THRESH 0x4048 /* RX almost empty
863 thresholds */
864#define RX_AE_THRESH_FREE_MASK 0x00001FFF /* RX_BUF_AE will be
865 generated if # desc
866 avail for hw use <=
867 # */
868#define RX_AE_THRESH_FREE_SHIFT 0
869#define RX_AE_THRESH_COMP_MASK 0x0FFFE000 /* RX_COMP_AE will be
870 generated if # of
871 completion entries
872 avail for hw use <=
873 # */
874#define RX_AE_THRESH_COMP_SHIFT 13
875
876/* probabilities for random early drop (RED) thresholds on a FIFO threshold
877 * basis. probability should increase when the FIFO level increases. control
878 * packets are never dropped and not counted in stats. probability programmed
879 * on a 12.5% granularity. e.g., 0x1 = 1/8 packets dropped.
880 * DEFAULT: 0x00000000
881 */
882#define REG_RX_RED 0x404C /* RX random early detect enable */
883#define RX_RED_4K_6K_FIFO_MASK 0x000000FF /* 4KB < FIFO thresh < 6KB */
884#define RX_RED_6K_8K_FIFO_MASK 0x0000FF00 /* 6KB < FIFO thresh < 8KB */
885#define RX_RED_8K_10K_FIFO_MASK 0x00FF0000 /* 8KB < FIFO thresh < 10KB */
886#define RX_RED_10K_12K_FIFO_MASK 0xFF000000 /* 10KB < FIFO thresh < 12KB */
887
888/* FIFO fullness levels for RX FIFO, RX control FIFO, and RX IPP FIFO.
889 * RX control FIFO = # of packets in RX FIFO.
890 * DEFAULT: 0x0
891 */
892#define REG_RX_FIFO_FULLNESS 0x4050 /* (ro) RX FIFO fullness */
893#define RX_FIFO_FULLNESS_RX_FIFO_MASK 0x3FF80000 /* level w/ 8B granularity */
894#define RX_FIFO_FULLNESS_IPP_FIFO_MASK 0x0007FF00 /* level w/ 8B granularity */
895#define RX_FIFO_FULLNESS_RX_PKT_MASK 0x000000FF /* # packets in RX FIFO */
896#define REG_RX_IPP_PACKET_COUNT 0x4054 /* RX IPP packet counter */
897#define REG_RX_WORK_DMA_PTR_LOW 0x4058 /* RX working DMA ptr low */
898#define REG_RX_WORK_DMA_PTR_HI 0x405C /* RX working DMA ptr
899 high */
900
901/* BIST testing ro RX FIFO, RX control FIFO, and RX IPP FIFO. only RX BIST
902 * START/COMPLETE is writeable. START will clear when the BIST has completed
903 * checking all 17 RAMS.
904 * DEFAULT: 0bxxxx xxxxx xxxx xxxx xxxx x000 0000 0000 00x0
905 */
906#define REG_RX_BIST 0x4060 /* (ro) RX BIST */
907#define RX_BIST_32A_PASS 0x80000000 /* RX FIFO 32A passed */
908#define RX_BIST_33A_PASS 0x40000000 /* RX FIFO 33A passed */
909#define RX_BIST_32B_PASS 0x20000000 /* RX FIFO 32B passed */
910#define RX_BIST_33B_PASS 0x10000000 /* RX FIFO 33B passed */
911#define RX_BIST_32C_PASS 0x08000000 /* RX FIFO 32C passed */
912#define RX_BIST_33C_PASS 0x04000000 /* RX FIFO 33C passed */
913#define RX_BIST_IPP_32A_PASS 0x02000000 /* RX IPP FIFO 33B passed */
914#define RX_BIST_IPP_33A_PASS 0x01000000 /* RX IPP FIFO 33A passed */
915#define RX_BIST_IPP_32B_PASS 0x00800000 /* RX IPP FIFO 32B passed */
916#define RX_BIST_IPP_33B_PASS 0x00400000 /* RX IPP FIFO 33B passed */
917#define RX_BIST_IPP_32C_PASS 0x00200000 /* RX IPP FIFO 32C passed */
918#define RX_BIST_IPP_33C_PASS 0x00100000 /* RX IPP FIFO 33C passed */
919#define RX_BIST_CTRL_32_PASS 0x00800000 /* RX CTRL FIFO 32 passed */
920#define RX_BIST_CTRL_33_PASS 0x00400000 /* RX CTRL FIFO 33 passed */
921#define RX_BIST_REAS_26A_PASS 0x00200000 /* RX Reas 26A passed */
922#define RX_BIST_REAS_26B_PASS 0x00100000 /* RX Reas 26B passed */
923#define RX_BIST_REAS_27_PASS 0x00080000 /* RX Reas 27 passed */
924#define RX_BIST_STATE_MASK 0x00078000 /* BIST state machine */
925#define RX_BIST_SUMMARY 0x00000002 /* when BIST complete,
926 summary pass bit
927 contains AND of BIST
928 results of all 16
929 RAMS */
930#define RX_BIST_START 0x00000001 /* write 1 to start
931 BIST. self clears
932 on completion. */
933
934/* next location in RX CTRL FIFO that will be loaded w/ data from RX IPP/read
935 * from to retrieve packet control info.
936 * DEFAULT: 0
937 */
938#define REG_RX_CTRL_FIFO_WRITE_PTR 0x4064 /* (ro) RX control FIFO
939 write ptr */
940#define REG_RX_CTRL_FIFO_READ_PTR 0x4068 /* (ro) RX control FIFO read
941 ptr */
942
943/* receive interrupt blanking. loaded each time interrupt alias register is
944 * read.
945 * DEFAULT: 0x0
946 */
947#define REG_RX_BLANK_ALIAS_READ 0x406C /* RX blanking register for
948 alias read */
949#define RX_BAR_INTR_PACKET_MASK 0x000001FF /* assert RX_DONE if #
950 completion writebacks
951 > # since last ISR
952 read. 0 = no
953 blanking. up to 2
954 packets per
955 completion wb. */
956#define RX_BAR_INTR_TIME_MASK 0x3FFFF000 /* assert RX_DONE if #
957 clocks > # since last
958 ISR read. each count
959 is 512 core clocks
960 (125MHz). 0 = no
961 blanking. */
962
963/* diagnostic access to RX FIFO. 32 LSB accessed via DATA_LOW. 32 MSB accessed
964 * via DATA_HI_T0 or DATA_HI_T1. TAG reads the tag bit. writing HI_T0
965 * will unset the tag bit while writing HI_T1 will set the tag bit. to reset
966 * to normal operation after diagnostics, write to address location 0x0.
967 * RX_DMA_EN bit must be set to 0x0 for RX FIFO PIO access. DATA_HI should
968 * be the last write access of a write sequence.
969 * DEFAULT: undefined
970 */
971#define REG_RX_FIFO_ADDR 0x4080 /* RX FIFO address */
972#define REG_RX_FIFO_TAG 0x4084 /* RX FIFO tag */
973#define REG_RX_FIFO_DATA_LOW 0x4088 /* RX FIFO data low */
974#define REG_RX_FIFO_DATA_HI_T0 0x408C /* RX FIFO data high T0 */
975#define REG_RX_FIFO_DATA_HI_T1 0x4090 /* RX FIFO data high T1 */
976
977/* diagnostic assess to RX CTRL FIFO. 8-bit FIFO_ADDR holds address of
978 * 81 bit control entry and 6 bit flow id. LOW and MID are both 32-bit
979 * accesses. HI is 7-bits with 6-bit flow id and 1 bit control
980 * word. RX_DMA_EN must be 0 for RX CTRL FIFO PIO access. DATA_HI
981 * should be last write access of the write sequence.
982 * DEFAULT: undefined
983 */
984#define REG_RX_CTRL_FIFO_ADDR 0x4094 /* RX Control FIFO and
985 Batching FIFO addr */
986#define REG_RX_CTRL_FIFO_DATA_LOW 0x4098 /* RX Control FIFO data
987 low */
988#define REG_RX_CTRL_FIFO_DATA_MID 0x409C /* RX Control FIFO data
989 mid */
990#define REG_RX_CTRL_FIFO_DATA_HI 0x4100 /* RX Control FIFO data
991 hi and flow id */
992#define RX_CTRL_FIFO_DATA_HI_CTRL 0x0001 /* upper bit of ctrl word */
993#define RX_CTRL_FIFO_DATA_HI_FLOW_MASK 0x007E /* flow id */
994
995/* diagnostic access to RX IPP FIFO. same semantics as RX_FIFO.
996 * DEFAULT: undefined
997 */
998#define REG_RX_IPP_FIFO_ADDR 0x4104 /* RX IPP FIFO address */
999#define REG_RX_IPP_FIFO_TAG 0x4108 /* RX IPP FIFO tag */
1000#define REG_RX_IPP_FIFO_DATA_LOW 0x410C /* RX IPP FIFO data low */
1001#define REG_RX_IPP_FIFO_DATA_HI_T0 0x4110 /* RX IPP FIFO data high
1002 T0 */
1003#define REG_RX_IPP_FIFO_DATA_HI_T1 0x4114 /* RX IPP FIFO data high
1004 T1 */
1005
1006/* 64-bit pointer to receive data buffer in host memory used for headers and
1007 * small packets. MSB in high register. loaded by DMA state machine and
1008 * increments as DMA writes receive data. only 50 LSB are incremented. top
1009 * 13 bits taken from RX descriptor.
1010 * DEFAULT: undefined
1011 */
1012#define REG_RX_HEADER_PAGE_PTR_LOW 0x4118 /* (ro) RX header page ptr
1013 low */
1014#define REG_RX_HEADER_PAGE_PTR_HI 0x411C /* (ro) RX header page ptr
1015 high */
1016#define REG_RX_MTU_PAGE_PTR_LOW 0x4120 /* (ro) RX MTU page pointer
1017 low */
1018#define REG_RX_MTU_PAGE_PTR_HI 0x4124 /* (ro) RX MTU page pointer
1019 high */
1020
1021/* PIO diagnostic access to RX reassembly DMA Table RAM. 6-bit register holds
1022 * one of 64 79-bit locations in the RX Reassembly DMA table and the addr of
1023 * one of the 64 byte locations in the Batching table. LOW holds 32 LSB.
1024 * MID holds the next 32 LSB. HIGH holds the 15 MSB. RX_DMA_EN must be set
1025 * to 0 for PIO access. DATA_HIGH should be last write of write sequence.
1026 * layout:
1027 * reassmbl ptr [78:15] | reassmbl index [14:1] | reassmbl entry valid [0]
1028 * DEFAULT: undefined
1029 */
1030#define REG_RX_TABLE_ADDR 0x4128 /* RX reassembly DMA table
1031 address */
1032#define RX_TABLE_ADDR_MASK 0x0000003F /* address mask */
1033
1034#define REG_RX_TABLE_DATA_LOW 0x412C /* RX reassembly DMA table
1035 data low */
1036#define REG_RX_TABLE_DATA_MID 0x4130 /* RX reassembly DMA table
1037 data mid */
1038#define REG_RX_TABLE_DATA_HI 0x4134 /* RX reassembly DMA table
1039 data high */
1040
1041/* cassini+ only */
1042/* 8KB aligned 64-bit pointer to base of RX rings. lower 13 bits hardwired to
1043 * 0. same semantics as primary desc/complete rings.
1044 */
1045#define REG_PLUS_RX_DB1_LOW 0x4200 /* RX descriptor ring
1046 2 base low */
1047#define REG_PLUS_RX_DB1_HI 0x4204 /* RX descriptor ring
1048 2 base high */
1049#define REG_PLUS_RX_CB1_LOW 0x4208 /* RX completion ring
1050 2 base low. 4 total */
1051#define REG_PLUS_RX_CB1_HI 0x420C /* RX completion ring
1052 2 base high. 4 total */
1053#define REG_PLUS_RX_CBN_LOW(x) (REG_PLUS_RX_CB1_LOW + 8*((x) - 1))
1054#define REG_PLUS_RX_CBN_HI(x) (REG_PLUS_RX_CB1_HI + 8*((x) - 1))
1055#define REG_PLUS_RX_KICK1 0x4220 /* RX Kick 2 register */
1056#define REG_PLUS_RX_COMP1 0x4224 /* (ro) RX completion 2
1057 reg */
1058#define REG_PLUS_RX_COMP1_HEAD 0x4228 /* (ro) RX completion 2
1059 head reg. 4 total. */
1060#define REG_PLUS_RX_COMP1_TAIL 0x422C /* RX completion 2
1061 tail reg. 4 total. */
1062#define REG_PLUS_RX_COMPN_HEAD(x) (REG_PLUS_RX_COMP1_HEAD + 8*((x) - 1))
1063#define REG_PLUS_RX_COMPN_TAIL(x) (REG_PLUS_RX_COMP1_TAIL + 8*((x) - 1))
1064#define REG_PLUS_RX_AE1_THRESH 0x4240 /* RX almost empty 2
1065 thresholds */
1066#define RX_AE1_THRESH_FREE_MASK RX_AE_THRESH_FREE_MASK
1067#define RX_AE1_THRESH_FREE_SHIFT RX_AE_THRESH_FREE_SHIFT
1068
1069/** header parser registers **/
1070
1071/* RX parser configuration register.
1072 * DEFAULT: 0x1651004
1073 */
1074#define REG_HP_CFG 0x4140 /* header parser
1075 configuration reg */
1076#define HP_CFG_PARSE_EN 0x00000001 /* enab header parsing */
1077#define HP_CFG_NUM_CPU_MASK 0x000000FC /* # processors
1078 0 = 64. 0x3f = 63 */
1079#define HP_CFG_NUM_CPU_SHIFT 2
1080#define HP_CFG_SYN_INC_MASK 0x00000100 /* SYN bit won't increment
1081 TCP seq # by one when
1082 stored in FDBM */
1083#define HP_CFG_TCP_THRESH_MASK 0x000FFE00 /* # bytes of TCP data
1084 needed to be considered
1085 for reassembly */
1086#define HP_CFG_TCP_THRESH_SHIFT 9
1087
1088/* access to RX Instruction RAM. 5-bit register/counter holds addr
1089 * of 39 bit entry to be read/written. 32 LSB in _DATA_LOW. 7 MSB in _DATA_HI.
1090 * RX_DMA_EN must be 0 for RX instr PIO access. DATA_HI should be last access
1091 * of sequence.
1092 * DEFAULT: undefined
1093 */
1094#define REG_HP_INSTR_RAM_ADDR 0x4144 /* HP instruction RAM
1095 address */
1096#define HP_INSTR_RAM_ADDR_MASK 0x01F /* 5-bit mask */
1097#define REG_HP_INSTR_RAM_DATA_LOW 0x4148 /* HP instruction RAM
1098 data low */
1099#define HP_INSTR_RAM_LOW_OUTMASK_MASK 0x0000FFFF
1100#define HP_INSTR_RAM_LOW_OUTMASK_SHIFT 0
1101#define HP_INSTR_RAM_LOW_OUTSHIFT_MASK 0x000F0000
1102#define HP_INSTR_RAM_LOW_OUTSHIFT_SHIFT 16
1103#define HP_INSTR_RAM_LOW_OUTEN_MASK 0x00300000
1104#define HP_INSTR_RAM_LOW_OUTEN_SHIFT 20
1105#define HP_INSTR_RAM_LOW_OUTARG_MASK 0xFFC00000
1106#define HP_INSTR_RAM_LOW_OUTARG_SHIFT 22
1107#define REG_HP_INSTR_RAM_DATA_MID 0x414C /* HP instruction RAM
1108 data mid */
1109#define HP_INSTR_RAM_MID_OUTARG_MASK 0x00000003
1110#define HP_INSTR_RAM_MID_OUTARG_SHIFT 0
1111#define HP_INSTR_RAM_MID_OUTOP_MASK 0x0000003C
1112#define HP_INSTR_RAM_MID_OUTOP_SHIFT 2
1113#define HP_INSTR_RAM_MID_FNEXT_MASK 0x000007C0
1114#define HP_INSTR_RAM_MID_FNEXT_SHIFT 6
1115#define HP_INSTR_RAM_MID_FOFF_MASK 0x0003F800
1116#define HP_INSTR_RAM_MID_FOFF_SHIFT 11
1117#define HP_INSTR_RAM_MID_SNEXT_MASK 0x007C0000
1118#define HP_INSTR_RAM_MID_SNEXT_SHIFT 18
1119#define HP_INSTR_RAM_MID_SOFF_MASK 0x3F800000
1120#define HP_INSTR_RAM_MID_SOFF_SHIFT 23
1121#define HP_INSTR_RAM_MID_OP_MASK 0xC0000000
1122#define HP_INSTR_RAM_MID_OP_SHIFT 30
1123#define REG_HP_INSTR_RAM_DATA_HI 0x4150 /* HP instruction RAM
1124 data high */
1125#define HP_INSTR_RAM_HI_VAL_MASK 0x0000FFFF
1126#define HP_INSTR_RAM_HI_VAL_SHIFT 0
1127#define HP_INSTR_RAM_HI_MASK_MASK 0xFFFF0000
1128#define HP_INSTR_RAM_HI_MASK_SHIFT 16
1129
1130/* PIO access into RX Header parser data RAM and flow database.
1131 * 11-bit register. Data fills the LSB portion of bus if less than 32 bits.
1132 * DATA_RAM: write RAM_FDB_DATA with index to access DATA_RAM.
1133 * RAM bytes = 4*(x - 1) + [3:0]. e.g., 0 -> [3:0], 31 -> [123:120]
1134 * FLOWDB: write DATA_RAM_FDB register and then read/write FDB1-12 to access
1135 * flow database.
1136 * RX_DMA_EN must be 0 for RX parser RAM PIO access. RX Parser RAM data reg
1137 * should be the last write access of the write sequence.
1138 * DEFAULT: undefined
1139 */
1140#define REG_HP_DATA_RAM_FDB_ADDR 0x4154 /* HP data and FDB
1141 RAM address */
1142#define HP_DATA_RAM_FDB_DATA_MASK 0x001F /* select 1 of 86 byte
1143 locations in header
1144 parser data ram to
1145 read/write */
1146#define HP_DATA_RAM_FDB_FDB_MASK 0x3F00 /* 1 of 64 353-bit locations
1147 in the flow database */
1148#define REG_HP_DATA_RAM_DATA 0x4158 /* HP data RAM data */
1149
1150/* HP flow database registers: 1 - 12, 0x415C - 0x4188, 4 8-bit bytes
1151 * FLOW_DB(1) = IP_SA[127:96], FLOW_DB(2) = IP_SA[95:64]
1152 * FLOW_DB(3) = IP_SA[63:32], FLOW_DB(4) = IP_SA[31:0]
1153 * FLOW_DB(5) = IP_DA[127:96], FLOW_DB(6) = IP_DA[95:64]
1154 * FLOW_DB(7) = IP_DA[63:32], FLOW_DB(8) = IP_DA[31:0]
1155 * FLOW_DB(9) = {TCP_SP[15:0],TCP_DP[15:0]}
1156 * FLOW_DB(10) = bit 0 has value for flow valid
1157 * FLOW_DB(11) = TCP_SEQ[63:32], FLOW_DB(12) = TCP_SEQ[31:0]
1158 */
1159#define REG_HP_FLOW_DB0 0x415C /* HP flow database 1 reg */
1160#define REG_HP_FLOW_DBN(x) (REG_HP_FLOW_DB0 + (x)*4)
1161
1162/* diagnostics for RX Header Parser block.
1163 * ASUN: the header parser state machine register is used for diagnostics
1164 * purposes. however, the spec doesn't have any details on it.
1165 */
1166#define REG_HP_STATE_MACHINE 0x418C /* (ro) HP state machine */
1167#define REG_HP_STATUS0 0x4190 /* (ro) HP status 1 */
1168#define HP_STATUS0_SAP_MASK 0xFFFF0000 /* SAP */
1169#define HP_STATUS0_L3_OFF_MASK 0x0000FE00 /* L3 offset */
1170#define HP_STATUS0_LB_CPUNUM_MASK 0x000001F8 /* load balancing CPU
1171 number */
1172#define HP_STATUS0_HRP_OPCODE_MASK 0x00000007 /* HRP opcode */
1173
1174#define REG_HP_STATUS1 0x4194 /* (ro) HP status 2 */
1175#define HP_STATUS1_ACCUR2_MASK 0xE0000000 /* accu R2[6:4] */
1176#define HP_STATUS1_FLOWID_MASK 0x1F800000 /* flow id */
1177#define HP_STATUS1_TCP_OFF_MASK 0x007F0000 /* tcp payload offset */
1178#define HP_STATUS1_TCP_SIZE_MASK 0x0000FFFF /* tcp payload size */
1179
1180#define REG_HP_STATUS2 0x4198 /* (ro) HP status 3 */
1181#define HP_STATUS2_ACCUR2_MASK 0xF0000000 /* accu R2[3:0] */
1182#define HP_STATUS2_CSUM_OFF_MASK 0x07F00000 /* checksum start
1183 start offset */
1184#define HP_STATUS2_ACCUR1_MASK 0x000FE000 /* accu R1 */
1185#define HP_STATUS2_FORCE_DROP 0x00001000 /* force drop */
1186#define HP_STATUS2_BWO_REASSM 0x00000800 /* batching w/o
1187 reassembly */
1188#define HP_STATUS2_JH_SPLIT_EN 0x00000400 /* jumbo header split
1189 enable */
1190#define HP_STATUS2_FORCE_TCP_NOCHECK 0x00000200 /* force tcp no payload
1191 check */
1192#define HP_STATUS2_DATA_MASK_ZERO 0x00000100 /* mask of data length
1193 equal to zero */
1194#define HP_STATUS2_FORCE_TCP_CHECK 0x00000080 /* force tcp payload
1195 chk */
1196#define HP_STATUS2_MASK_TCP_THRESH 0x00000040 /* mask of payload
1197 threshold */
1198#define HP_STATUS2_NO_ASSIST 0x00000020 /* no assist */
1199#define HP_STATUS2_CTRL_PACKET_FLAG 0x00000010 /* control packet flag */
1200#define HP_STATUS2_TCP_FLAG_CHECK 0x00000008 /* tcp flag check */
1201#define HP_STATUS2_SYN_FLAG 0x00000004 /* syn flag */
1202#define HP_STATUS2_TCP_CHECK 0x00000002 /* tcp payload chk */
1203#define HP_STATUS2_TCP_NOCHECK 0x00000001 /* tcp no payload chk */
1204
1205/* BIST for header parser(HP) and flow database memories (FDBM). set _START
1206 * to start BIST. controller clears _START on completion. _START can also
1207 * be cleared to force termination of BIST. a bit set indicates that that
1208 * memory passed its BIST.
1209 */
1210#define REG_HP_RAM_BIST 0x419C /* HP RAM BIST reg */
1211#define HP_RAM_BIST_HP_DATA_PASS 0x80000000 /* HP data ram */
1212#define HP_RAM_BIST_HP_INSTR0_PASS 0x40000000 /* HP instr ram 0 */
1213#define HP_RAM_BIST_HP_INSTR1_PASS 0x20000000 /* HP instr ram 1 */
1214#define HP_RAM_BIST_HP_INSTR2_PASS 0x10000000 /* HP instr ram 2 */
1215#define HP_RAM_BIST_FDBM_AGE0_PASS 0x08000000 /* FDBM aging RAM0 */
1216#define HP_RAM_BIST_FDBM_AGE1_PASS 0x04000000 /* FDBM aging RAM1 */
1217#define HP_RAM_BIST_FDBM_FLOWID00_PASS 0x02000000 /* FDBM flowid RAM0
1218 bank 0 */
1219#define HP_RAM_BIST_FDBM_FLOWID10_PASS 0x01000000 /* FDBM flowid RAM1
1220 bank 0 */
1221#define HP_RAM_BIST_FDBM_FLOWID20_PASS 0x00800000 /* FDBM flowid RAM2
1222 bank 0 */
1223#define HP_RAM_BIST_FDBM_FLOWID30_PASS 0x00400000 /* FDBM flowid RAM3
1224 bank 0 */
1225#define HP_RAM_BIST_FDBM_FLOWID01_PASS 0x00200000 /* FDBM flowid RAM0
1226 bank 1 */
1227#define HP_RAM_BIST_FDBM_FLOWID11_PASS 0x00100000 /* FDBM flowid RAM1
1228 bank 2 */
1229#define HP_RAM_BIST_FDBM_FLOWID21_PASS 0x00080000 /* FDBM flowid RAM2
1230 bank 1 */
1231#define HP_RAM_BIST_FDBM_FLOWID31_PASS 0x00040000 /* FDBM flowid RAM3
1232 bank 1 */
1233#define HP_RAM_BIST_FDBM_TCPSEQ_PASS 0x00020000 /* FDBM tcp sequence
1234 RAM */
1235#define HP_RAM_BIST_SUMMARY 0x00000002 /* all BIST tests */
1236#define HP_RAM_BIST_START 0x00000001 /* start/stop BIST */
1237
1238
1239/** MAC registers. **/
1240/* reset bits are set using a PIO write and self-cleared after the command
1241 * execution has completed.
1242 */
1243#define REG_MAC_TX_RESET 0x6000 /* TX MAC software reset
1244 command (default: 0x0) */
1245#define REG_MAC_RX_RESET 0x6004 /* RX MAC software reset
1246 command (default: 0x0) */
1247/* execute a pause flow control frame transmission
1248 DEFAULT: 0x0XXXX */
1249#define REG_MAC_SEND_PAUSE 0x6008 /* send pause command reg */
1250#define MAC_SEND_PAUSE_TIME_MASK 0x0000FFFF /* value of pause time
1251 to be sent on network
1252 in units of slot
1253 times */
1254#define MAC_SEND_PAUSE_SEND 0x00010000 /* send pause flow ctrl
1255 frame on network */
1256
1257/* bit set indicates that event occurred. auto-cleared when status register
1258 * is read and have corresponding mask bits in mask register. events will
1259 * trigger an interrupt if the corresponding mask bit is 0.
1260 * status register default: 0x00000000
1261 * mask register default = 0xFFFFFFFF on reset
1262 */
1263#define REG_MAC_TX_STATUS 0x6010 /* TX MAC status reg */
1264#define MAC_TX_FRAME_XMIT 0x0001 /* successful frame
1265 transmision */
1266#define MAC_TX_UNDERRUN 0x0002 /* terminated frame
1267 transmission due to
1268 data starvation in the
1269 xmit data path */
1270#define MAC_TX_MAX_PACKET_ERR 0x0004 /* frame exceeds max allowed
1271 length passed to TX MAC
1272 by the DMA engine */
1273#define MAC_TX_COLL_NORMAL 0x0008 /* rollover of the normal
1274 collision counter */
1275#define MAC_TX_COLL_EXCESS 0x0010 /* rollover of the excessive
1276 collision counter */
1277#define MAC_TX_COLL_LATE 0x0020 /* rollover of the late
1278 collision counter */
1279#define MAC_TX_COLL_FIRST 0x0040 /* rollover of the first
1280 collision counter */
1281#define MAC_TX_DEFER_TIMER 0x0080 /* rollover of the defer
1282 timer */
1283#define MAC_TX_PEAK_ATTEMPTS 0x0100 /* rollover of the peak
1284 attempts counter */
1285
1286#define REG_MAC_RX_STATUS 0x6014 /* RX MAC status reg */
1287#define MAC_RX_FRAME_RECV 0x0001 /* successful receipt of
1288 a frame */
1289#define MAC_RX_OVERFLOW 0x0002 /* dropped frame due to
1290 RX FIFO overflow */
1291#define MAC_RX_FRAME_COUNT 0x0004 /* rollover of receive frame
1292 counter */
1293#define MAC_RX_ALIGN_ERR 0x0008 /* rollover of alignment
1294 error counter */
1295#define MAC_RX_CRC_ERR 0x0010 /* rollover of crc error
1296 counter */
1297#define MAC_RX_LEN_ERR 0x0020 /* rollover of length
1298 error counter */
1299#define MAC_RX_VIOL_ERR 0x0040 /* rollover of code
1300 violation error */
1301
1302/* DEFAULT: 0xXXXX0000 on reset */
1303#define REG_MAC_CTRL_STATUS 0x6018 /* MAC control status reg */
1304#define MAC_CTRL_PAUSE_RECEIVED 0x00000001 /* successful
1305 reception of a
1306 pause control
1307 frame */
1308#define MAC_CTRL_PAUSE_STATE 0x00000002 /* MAC has made a
1309 transition from
1310 "not paused" to
1311 "paused" */
1312#define MAC_CTRL_NOPAUSE_STATE 0x00000004 /* MAC has made a
1313 transition from
1314 "paused" to "not
1315 paused" */
1316#define MAC_CTRL_PAUSE_TIME_MASK 0xFFFF0000 /* value of pause time
1317 operand that was
1318 received in the last
1319 pause flow control
1320 frame */
1321
1322/* layout identical to TX MAC[8:0] */
1323#define REG_MAC_TX_MASK 0x6020 /* TX MAC mask reg */
1324/* layout identical to RX MAC[6:0] */
1325#define REG_MAC_RX_MASK 0x6024 /* RX MAC mask reg */
1326/* layout identical to CTRL MAC[2:0] */
1327#define REG_MAC_CTRL_MASK 0x6028 /* MAC control mask reg */
1328
1329/* to ensure proper operation, CFG_EN must be cleared to 0 and a delay
1330 * imposed before writes to other bits in the TX_MAC_CFG register or any of
1331 * the MAC parameters is performed. delay dependent upon time required to
1332 * transmit a maximum size frame (= MAC_FRAMESIZE_MAX*8/Mbps). e.g.,
1333 * the delay for a 1518-byte frame on a 100Mbps network is 125us.
1334 * alternatively, just poll TX_CFG_EN until it reads back as 0.
1335 * NOTE: on half-duplex 1Gbps, TX_CFG_CARRIER_EXTEND and
1336 * RX_CFG_CARRIER_EXTEND should be set and the SLOT_TIME register should
1337 * be 0x200 (slot time of 512 bytes)
1338 */
1339#define REG_MAC_TX_CFG 0x6030 /* TX MAC config reg */
1340#define MAC_TX_CFG_EN 0x0001 /* enable TX MAC. 0 will
1341 force TXMAC state
1342 machine to remain in
1343 idle state or to
1344 transition to idle state
1345 on completion of an
1346 ongoing packet. */
1347#define MAC_TX_CFG_IGNORE_CARRIER 0x0002 /* disable CSMA/CD deferral
1348 process. set to 1 when
1349 full duplex and 0 when
1350 half duplex */
1351#define MAC_TX_CFG_IGNORE_COLL 0x0004 /* disable CSMA/CD backoff
1352 algorithm. set to 1 when
1353 full duplex and 0 when
1354 half duplex */
1355#define MAC_TX_CFG_IPG_EN 0x0008 /* enable extension of the
1356 Rx-to-TX IPG. after
1357 receiving a frame, TX
1358 MAC will reset its
1359 deferral process to
1360 carrier sense for the
1361 amount of time = IPG0 +
1362 IPG1 and commit to
1363 transmission for time
1364 specified in IPG2. when
1365 0 or when xmitting frames
1366 back-to-pack (Tx-to-Tx
1367 IPG), TX MAC ignores
1368 IPG0 and will only use
1369 IPG1 for deferral time.
1370 IPG2 still used. */
1371#define MAC_TX_CFG_NEVER_GIVE_UP_EN 0x0010 /* TX MAC will not easily
1372 give up on frame
1373 xmission. if backoff
1374 algorithm reaches the
1375 ATTEMPT_LIMIT, it will
1376 clear attempts counter
1377 and continue trying to
1378 send the frame as
1379 specified by
1380 GIVE_UP_LIM. when 0,
1381 TX MAC will execute
1382 standard CSMA/CD prot. */
1383#define MAC_TX_CFG_NEVER_GIVE_UP_LIM 0x0020 /* when set, TX MAC will
1384 continue to try to xmit
1385 until successful. when
1386 0, TX MAC will continue
1387 to try xmitting until
1388 successful or backoff
1389 algorithm reaches
1390 ATTEMPT_LIMIT*16 */
1391#define MAC_TX_CFG_NO_BACKOFF 0x0040 /* modify CSMA/CD to disable
1392 backoff algorithm. TX
1393 MAC will not back off
1394 after a xmission attempt
1395 that resulted in a
1396 collision. */
1397#define MAC_TX_CFG_SLOW_DOWN 0x0080 /* modify CSMA/CD so that
1398 deferral process is reset
1399 in response to carrier
1400 sense during the entire
1401 duration of IPG. TX MAC
1402 will only commit to frame
1403 xmission after frame
1404 xmission has actually
1405 begun. */
1406#define MAC_TX_CFG_NO_FCS 0x0100 /* TX MAC will not generate
1407 CRC for all xmitted
1408 packets. when clear, CRC
1409 generation is dependent
1410 upon NO_CRC bit in the
1411 xmit control word from
1412 TX DMA */
1413#define MAC_TX_CFG_CARRIER_EXTEND 0x0200 /* enables xmit part of the
1414 carrier extension
1415 feature. this allows for
1416 longer collision domains
1417 by extending the carrier
1418 and collision window
1419 from the end of FCS until
1420 the end of the slot time
1421 if necessary. Required
1422 for half-duplex at 1Gbps,
1423 clear otherwise. */
1424
1425/* when CRC is not stripped, reassembly packets will not contain the CRC.
1426 * these will be stripped by HRP because it reassembles layer 4 data, and the
1427 * CRC is layer 2. however, non-reassembly packets will still contain the CRC
1428 * when passed to the host. to ensure proper operation, need to wait 3.2ms
1429 * after clearing RX_CFG_EN before writing to any other RX MAC registers
1430 * or other MAC parameters. alternatively, poll RX_CFG_EN until it clears
1431 * to 0. similary, HASH_FILTER_EN and ADDR_FILTER_EN have the same
1432 * restrictions as CFG_EN.
1433 */
1434#define REG_MAC_RX_CFG 0x6034 /* RX MAC config reg */
1435#define MAC_RX_CFG_EN 0x0001 /* enable RX MAC */
1436#define MAC_RX_CFG_STRIP_PAD 0x0002 /* always program to 0.
1437 feature not supported */
1438#define MAC_RX_CFG_STRIP_FCS 0x0004 /* RX MAC will strip the
1439 last 4 bytes of a
1440 received frame. */
1441#define MAC_RX_CFG_PROMISC_EN 0x0008 /* promiscuous mode */
1442#define MAC_RX_CFG_PROMISC_GROUP_EN 0x0010 /* accept all valid
1443 multicast frames (group
1444 bit in DA field set) */
1445#define MAC_RX_CFG_HASH_FILTER_EN 0x0020 /* use hash table to filter
1446 multicast addresses */
1447#define MAC_RX_CFG_ADDR_FILTER_EN 0x0040 /* cause RX MAC to use
1448 address filtering regs
1449 to filter both unicast
1450 and multicast
1451 addresses */
1452#define MAC_RX_CFG_DISABLE_DISCARD 0x0080 /* pass errored frames to
1453 RX DMA by setting BAD
1454 bit but not Abort bit
1455 in the status. CRC,
1456 framing, and length errs
1457 will not increment
1458 error counters. frames
1459 which don't match dest
1460 addr will be passed up
1461 w/ BAD bit set. */
1462#define MAC_RX_CFG_CARRIER_EXTEND 0x0100 /* enable reception of
1463 packet bursts generated
1464 by carrier extension
1465 with packet bursting
1466 senders. only applies
1467 to half-duplex 1Gbps */
1468
1469/* DEFAULT: 0x0 */
1470#define REG_MAC_CTRL_CFG 0x6038 /* MAC control config reg */
1471#define MAC_CTRL_CFG_SEND_PAUSE_EN 0x0001 /* respond to requests for
1472 sending pause flow ctrl
1473 frames */
1474#define MAC_CTRL_CFG_RECV_PAUSE_EN 0x0002 /* respond to received
1475 pause flow ctrl frames */
1476#define MAC_CTRL_CFG_PASS_CTRL 0x0004 /* pass valid MAC ctrl
1477 packets to RX DMA */
1478
1479/* to ensure proper operation, a global initialization sequence should be
1480 * performed when a loopback config is entered or exited. if programmed after
1481 * a hw or global sw reset, RX/TX MAC software reset and initialization
1482 * should be done to ensure stable clocking.
1483 * DEFAULT: 0x0
1484 */
1485#define REG_MAC_XIF_CFG 0x603C /* XIF config reg */
1486#define MAC_XIF_TX_MII_OUTPUT_EN 0x0001 /* enable output drivers
1487 on MII xmit bus */
1488#define MAC_XIF_MII_INT_LOOPBACK 0x0002 /* loopback GMII xmit data
1489 path to GMII recv data
1490 path. phy mode register
1491 clock selection must be
1492 set to GMII mode and
1493 GMII_MODE should be set
1494 to 1. in loopback mode,
1495 REFCLK will drive the
1496 entire mac core. 0 for
1497 normal operation. */
1498#define MAC_XIF_DISABLE_ECHO 0x0004 /* disables receive data
1499 path during packet
1500 xmission. clear to 0
1501 in any full duplex mode,
1502 in any loopback mode,
1503 or in half-duplex SERDES
1504 or SLINK modes. set when
1505 in half-duplex when
1506 using external phy. */
1507#define MAC_XIF_GMII_MODE 0x0008 /* MAC operates with GMII
1508 clocks and datapath */
1509#define MAC_XIF_MII_BUFFER_OUTPUT_EN 0x0010 /* MII_BUF_EN pin. enable
1510 external tristate buffer
1511 on the MII receive
1512 bus. */
1513#define MAC_XIF_LINK_LED 0x0020 /* LINKLED# active (low) */
1514#define MAC_XIF_FDPLX_LED 0x0040 /* FDPLXLED# active (low) */
1515
1516#define REG_MAC_IPG0 0x6040 /* inter-packet gap0 reg.
1517 recommended: 0x00 */
1518#define REG_MAC_IPG1 0x6044 /* inter-packet gap1 reg
1519 recommended: 0x08 */
1520#define REG_MAC_IPG2 0x6048 /* inter-packet gap2 reg
1521 recommended: 0x04 */
1522#define REG_MAC_SLOT_TIME 0x604C /* slot time reg
1523 recommended: 0x40 */
1524#define REG_MAC_FRAMESIZE_MIN 0x6050 /* min frame size reg
1525 recommended: 0x40 */
1526
1527/* FRAMESIZE_MAX holds both the max frame size as well as the max burst size.
1528 * recommended value: 0x2000.05EE
1529 */
1530#define REG_MAC_FRAMESIZE_MAX 0x6054 /* max frame size reg */
1531#define MAC_FRAMESIZE_MAX_BURST_MASK 0x3FFF0000 /* max burst size */
1532#define MAC_FRAMESIZE_MAX_BURST_SHIFT 16
1533#define MAC_FRAMESIZE_MAX_FRAME_MASK 0x00007FFF /* max frame size */
1534#define MAC_FRAMESIZE_MAX_FRAME_SHIFT 0
1535#define REG_MAC_PA_SIZE 0x6058 /* PA size reg. number of
1536 preamble bytes that the
1537 TX MAC will xmit at the
1538 beginning of each frame
1539 value should be 2 or
1540 greater. recommended
1541 value: 0x07 */
1542#define REG_MAC_JAM_SIZE 0x605C /* jam size reg. duration
1543 of jam in units of media
1544 byte time. recommended
1545 value: 0x04 */
1546#define REG_MAC_ATTEMPT_LIMIT 0x6060 /* attempt limit reg. #
1547 of attempts TX MAC will
1548 make to xmit a frame
1549 before it resets its
1550 attempts counter. after
1551 the limit has been
1552 reached, TX MAC may or
1553 may not drop the frame
1554 dependent upon value
1555 in TX_MAC_CFG.
1556 recommended
1557 value: 0x10 */
1558#define REG_MAC_CTRL_TYPE 0x6064 /* MAC control type reg.
1559 type field of a MAC
1560 ctrl frame. recommended
1561 value: 0x8808 */
1562
1563/* mac address registers: 0 - 44, 0x6080 - 0x6130, 4 8-bit bytes.
1564 * register contains comparison
1565 * 0 16 MSB of primary MAC addr [47:32] of DA field
1566 * 1 16 middle bits "" [31:16] of DA field
1567 * 2 16 LSB "" [15:0] of DA field
1568 * 3*x 16MSB of alt MAC addr 1-15 [47:32] of DA field
1569 * 4*x 16 middle bits "" [31:16]
1570 * 5*x 16 LSB "" [15:0]
1571 * 42 16 MSB of MAC CTRL addr [47:32] of DA.
1572 * 43 16 middle bits "" [31:16]
1573 * 44 16 LSB "" [15:0]
1574 * MAC CTRL addr must be the reserved multicast addr for MAC CTRL frames.
1575 * if there is a match, MAC will set the bit for alternative address
1576 * filter pass [15]
1577
1578 * here is the map of registers given MAC address notation: a:b:c:d:e:f
1579 * ab cd ef
1580 * primary addr reg 2 reg 1 reg 0
1581 * alt addr 1 reg 5 reg 4 reg 3
1582 * alt addr x reg 5*x reg 4*x reg 3*x
1583 * ctrl addr reg 44 reg 43 reg 42
1584 */
1585#define REG_MAC_ADDR0 0x6080 /* MAC address 0 reg */
1586#define REG_MAC_ADDRN(x) (REG_MAC_ADDR0 + (x)*4)
1587#define REG_MAC_ADDR_FILTER0 0x614C /* address filter 0 reg
1588 [47:32] */
1589#define REG_MAC_ADDR_FILTER1 0x6150 /* address filter 1 reg
1590 [31:16] */
1591#define REG_MAC_ADDR_FILTER2 0x6154 /* address filter 2 reg
1592 [15:0] */
1593#define REG_MAC_ADDR_FILTER2_1_MASK 0x6158 /* address filter 2 and 1
1594 mask reg. 8-bit reg
1595 contains nibble mask for
1596 reg 2 and 1. */
1597#define REG_MAC_ADDR_FILTER0_MASK 0x615C /* address filter 0 mask
1598 reg */
1599
1600/* hash table registers: 0 - 15, 0x6160 - 0x619C, 4 8-bit bytes
1601 * 16-bit registers contain bits of the hash table.
1602 * reg x -> [16*(15 - x) + 15 : 16*(15 - x)].
1603 * e.g., 15 -> [15:0], 0 -> [255:240]
1604 */
1605#define REG_MAC_HASH_TABLE0 0x6160 /* hash table 0 reg */
1606#define REG_MAC_HASH_TABLEN(x) (REG_MAC_HASH_TABLE0 + (x)*4)
1607
1608/* statistics registers. these registers generate an interrupt on
1609 * overflow. recommended initialization: 0x0000. most are 16-bits except
1610 * for PEAK_ATTEMPTS register which is 8 bits.
1611 */
1612#define REG_MAC_COLL_NORMAL 0x61A0 /* normal collision
1613 counter. */
1614#define REG_MAC_COLL_FIRST 0x61A4 /* first attempt
1615 successful collision
1616 counter */
1617#define REG_MAC_COLL_EXCESS 0x61A8 /* excessive collision
1618 counter */
1619#define REG_MAC_COLL_LATE 0x61AC /* late collision counter */
1620#define REG_MAC_TIMER_DEFER 0x61B0 /* defer timer. time base
1621 is the media byte
1622 clock/256 */
1623#define REG_MAC_ATTEMPTS_PEAK 0x61B4 /* peak attempts reg */
1624#define REG_MAC_RECV_FRAME 0x61B8 /* receive frame counter */
1625#define REG_MAC_LEN_ERR 0x61BC /* length error counter */
1626#define REG_MAC_ALIGN_ERR 0x61C0 /* alignment error counter */
1627#define REG_MAC_FCS_ERR 0x61C4 /* FCS error counter */
1628#define REG_MAC_RX_CODE_ERR 0x61C8 /* RX code violation
1629 error counter */
1630
1631/* misc registers */
1632#define REG_MAC_RANDOM_SEED 0x61CC /* random number seed reg.
1633 10-bit register used as a
1634 seed for the random number
1635 generator for the CSMA/CD
1636 backoff algorithm. only
1637 programmed after power-on
1638 reset and should be a
1639 random value which has a
1640 high likelihood of being
1641 unique for each MAC
1642 attached to a network
1643 segment (e.g., 10 LSB of
1644 MAC address) */
1645
1646/* ASUN: there's a PAUSE_TIMER (ro) described, but it's not in the address
1647 * map
1648 */
1649
1650/* 27-bit register has the current state for key state machines in the MAC */
1651#define REG_MAC_STATE_MACHINE 0x61D0 /* (ro) state machine reg */
1652#define MAC_SM_RLM_MASK 0x07800000
1653#define MAC_SM_RLM_SHIFT 23
1654#define MAC_SM_RX_FC_MASK 0x00700000
1655#define MAC_SM_RX_FC_SHIFT 20
1656#define MAC_SM_TLM_MASK 0x000F0000
1657#define MAC_SM_TLM_SHIFT 16
1658#define MAC_SM_ENCAP_SM_MASK 0x0000F000
1659#define MAC_SM_ENCAP_SM_SHIFT 12
1660#define MAC_SM_TX_REQ_MASK 0x00000C00
1661#define MAC_SM_TX_REQ_SHIFT 10
1662#define MAC_SM_TX_FC_MASK 0x000003C0
1663#define MAC_SM_TX_FC_SHIFT 6
1664#define MAC_SM_FIFO_WRITE_SEL_MASK 0x00000038
1665#define MAC_SM_FIFO_WRITE_SEL_SHIFT 3
1666#define MAC_SM_TX_FIFO_EMPTY_MASK 0x00000007
1667#define MAC_SM_TX_FIFO_EMPTY_SHIFT 0
1668
1669/** MIF registers. the MIF can be programmed in either bit-bang or
1670 * frame mode.
1671 **/
1672#define REG_MIF_BIT_BANG_CLOCK 0x6200 /* MIF bit-bang clock.
1673 1 -> 0 will generate a
1674 rising edge. 0 -> 1 will
1675 generate a falling edge. */
1676#define REG_MIF_BIT_BANG_DATA 0x6204 /* MIF bit-bang data. 1-bit
1677 register generates data */
1678#define REG_MIF_BIT_BANG_OUTPUT_EN 0x6208 /* MIF bit-bang output
1679 enable. enable when
1680 xmitting data from MIF to
1681 transceiver. */
1682
1683/* 32-bit register serves as an instruction register when the MIF is
1684 * programmed in frame mode. load this register w/ a valid instruction
1685 * (as per IEEE 802.3u MII spec). poll this register to check for instruction
1686 * execution completion. during a read operation, this register will also
1687 * contain the 16-bit data returned by the tranceiver. unless specified
1688 * otherwise, fields are considered "don't care" when polling for
1689 * completion.
1690 */
1691#define REG_MIF_FRAME 0x620C /* MIF frame/output reg */
1692#define MIF_FRAME_START_MASK 0xC0000000 /* start of frame.
1693 load w/ 01 when
1694 issuing an instr */
1695#define MIF_FRAME_ST 0x40000000 /* STart of frame */
1696#define MIF_FRAME_OPCODE_MASK 0x30000000 /* opcode. 01 for a
1697 write. 10 for a
1698 read */
1699#define MIF_FRAME_OP_READ 0x20000000 /* read OPcode */
1700#define MIF_FRAME_OP_WRITE 0x10000000 /* write OPcode */
1701#define MIF_FRAME_PHY_ADDR_MASK 0x0F800000 /* phy address. when
1702 issuing an instr,
1703 this field should be
1704 loaded w/ the XCVR
1705 addr */
1706#define MIF_FRAME_PHY_ADDR_SHIFT 23
1707#define MIF_FRAME_REG_ADDR_MASK 0x007C0000 /* register address.
1708 when issuing an instr,
1709 addr of register
1710 to be read/written */
1711#define MIF_FRAME_REG_ADDR_SHIFT 18
1712#define MIF_FRAME_TURN_AROUND_MSB 0x00020000 /* turn around, MSB.
1713 when issuing an instr,
1714 set this bit to 1 */
1715#define MIF_FRAME_TURN_AROUND_LSB 0x00010000 /* turn around, LSB.
1716 when issuing an instr,
1717 set this bit to 0.
1718 when polling for
1719 completion, 1 means
1720 that instr execution
1721 has been completed */
1722#define MIF_FRAME_DATA_MASK 0x0000FFFF /* instruction payload
1723 load with 16-bit data
1724 to be written in
1725 transceiver reg for a
1726 write. doesn't matter
1727 in a read. when
1728 polling for
1729 completion, field is
1730 "don't care" for write
1731 and 16-bit data
1732 returned by the
1733 transceiver for a
1734 read (if valid bit
1735 is set) */
1736#define REG_MIF_CFG 0x6210 /* MIF config reg */
1737#define MIF_CFG_PHY_SELECT 0x0001 /* 1 -> select MDIO_1
1738 0 -> select MDIO_0 */
1739#define MIF_CFG_POLL_EN 0x0002 /* enable polling
1740 mechanism. if set,
1741 BB_MODE should be 0 */
1742#define MIF_CFG_BB_MODE 0x0004 /* 1 -> bit-bang mode
1743 0 -> frame mode */
1744#define MIF_CFG_POLL_REG_MASK 0x00F8 /* register address to be
1745 used by polling mode.
1746 only meaningful if POLL_EN
1747 is set to 1 */
1748#define MIF_CFG_POLL_REG_SHIFT 3
1749#define MIF_CFG_MDIO_0 0x0100 /* (ro) dual purpose.
1750 when MDIO_0 is idle,
1751 1 -> tranceiver is
1752 connected to MDIO_0.
1753 when MIF is communicating
1754 w/ MDIO_0 in bit-bang
1755 mode, this bit indicates
1756 the incoming bit stream
1757 during a read op */
1758#define MIF_CFG_MDIO_1 0x0200 /* (ro) dual purpose.
1759 when MDIO_1 is idle,
1760 1 -> transceiver is
1761 connected to MDIO_1.
1762 when MIF is communicating
1763 w/ MDIO_1 in bit-bang
1764 mode, this bit indicates
1765 the incoming bit stream
1766 during a read op */
1767#define MIF_CFG_POLL_PHY_MASK 0x7C00 /* tranceiver address to
1768 be polled */
1769#define MIF_CFG_POLL_PHY_SHIFT 10
1770
1771/* 16-bit register used to determine which bits in the POLL_STATUS portion of
1772 * the MIF_STATUS register will cause an interrupt. if a mask bit is 0,
1773 * corresponding bit of the POLL_STATUS will generate a MIF interrupt when
1774 * set. DEFAULT: 0xFFFF
1775 */
1776#define REG_MIF_MASK 0x6214 /* MIF mask reg */
1777
1778/* 32-bit register used when in poll mode. auto-cleared after being read */
1779#define REG_MIF_STATUS 0x6218 /* MIF status reg */
1780#define MIF_STATUS_POLL_DATA_MASK 0xFFFF0000 /* poll data contains
1781 the "latest image"
1782 update of the XCVR
1783 reg being read */
1784#define MIF_STATUS_POLL_DATA_SHIFT 16
1785#define MIF_STATUS_POLL_STATUS_MASK 0x0000FFFF /* poll status indicates
1786 which bits in the
1787 POLL_DATA field have
1788 changed since the
1789 MIF_STATUS reg was
1790 last read */
1791#define MIF_STATUS_POLL_STATUS_SHIFT 0
1792
1793/* 7-bit register has current state for all state machines in the MIF */
1794#define REG_MIF_STATE_MACHINE 0x621C /* MIF state machine reg */
1795#define MIF_SM_CONTROL_MASK 0x07 /* control state machine
1796 state */
1797#define MIF_SM_EXECUTION_MASK 0x60 /* execution state machine
1798 state */
1799
1800/** PCS/Serialink. the following registers are equivalent to the standard
1801 * MII management registers except that they're directly mapped in
1802 * Cassini's register space.
1803 **/
1804
1805/* the auto-negotiation enable bit should be programmed the same at
1806 * the link partner as in the local device to enable auto-negotiation to
1807 * complete. when that bit is reprogrammed, auto-neg/manual config is
1808 * restarted automatically.
1809 * DEFAULT: 0x1040
1810 */
1811#define REG_PCS_MII_CTRL 0x9000 /* PCS MII control reg */
1812#define PCS_MII_CTRL_1000_SEL 0x0040 /* reads 1. ignored on
1813 writes */
1814#define PCS_MII_CTRL_COLLISION_TEST 0x0080 /* COL signal at the PCS
1815 to MAC interface is
1816 activated regardless
1817 of activity */
1818#define PCS_MII_CTRL_DUPLEX 0x0100 /* forced 0x0. PCS
1819 behaviour same for
1820 half and full dplx */
1821#define PCS_MII_RESTART_AUTONEG 0x0200 /* self clearing.
1822 restart auto-
1823 negotiation */
1824#define PCS_MII_ISOLATE 0x0400 /* read as 0. ignored
1825 on writes */
1826#define PCS_MII_POWER_DOWN 0x0800 /* read as 0. ignored
1827 on writes */
1828#define PCS_MII_AUTONEG_EN 0x1000 /* default 1. PCS goes
1829 through automatic
1830 link config before it
1831 can be used. when 0,
1832 link can be used
1833 w/out any link config
1834 phase */
1835#define PCS_MII_10_100_SEL 0x2000 /* read as 0. ignored on
1836 writes */
1837#define PCS_MII_RESET 0x8000 /* reset PCS. self-clears
1838 when done */
1839
1840/* DEFAULT: 0x0108 */
1841#define REG_PCS_MII_STATUS 0x9004 /* PCS MII status reg */
1842#define PCS_MII_STATUS_EXTEND_CAP 0x0001 /* reads 0 */
1843#define PCS_MII_STATUS_JABBER_DETECT 0x0002 /* reads 0 */
1844#define PCS_MII_STATUS_LINK_STATUS 0x0004 /* 1 -> link up.
1845 0 -> link down. 0 is
1846 latched so that 0 is
1847 kept until read. read
1848 2x to determine if the
1849 link has gone up again */
1850#define PCS_MII_STATUS_AUTONEG_ABLE 0x0008 /* reads 1 (able to perform
1851 auto-neg) */
1852#define PCS_MII_STATUS_REMOTE_FAULT 0x0010 /* 1 -> remote fault detected
1853 from received link code
1854 word. only valid after
1855 auto-neg completed */
1856#define PCS_MII_STATUS_AUTONEG_COMP 0x0020 /* 1 -> auto-negotiation
1857 completed
1858 0 -> auto-negotiation not
1859 completed */
1860#define PCS_MII_STATUS_EXTEND_STATUS 0x0100 /* reads as 1. used as an
1861 indication that this is
1862 a 1000 Base-X PHY. writes
1863 to it are ignored */
1864
1865/* used during auto-negotiation.
1866 * DEFAULT: 0x00E0
1867 */
1868#define REG_PCS_MII_ADVERT 0x9008 /* PCS MII advertisement
1869 reg */
1870#define PCS_MII_ADVERT_FD 0x0020 /* advertise full duplex
1871 1000 Base-X */
1872#define PCS_MII_ADVERT_HD 0x0040 /* advertise half-duplex
1873 1000 Base-X */
1874#define PCS_MII_ADVERT_SYM_PAUSE 0x0080 /* advertise PAUSE
1875 symmetric capability */
1876#define PCS_MII_ADVERT_ASYM_PAUSE 0x0100 /* advertises PAUSE
1877 asymmetric capability */
1878#define PCS_MII_ADVERT_RF_MASK 0x3000 /* remote fault. write bit13
1879 to optionally indicate to
1880 link partner that chip is
1881 going off-line. bit12 will
1882 get set when signal
1883 detect == FAIL and will
1884 remain set until
1885 successful negotiation */
1886#define PCS_MII_ADVERT_ACK 0x4000 /* (ro) */
1887#define PCS_MII_ADVERT_NEXT_PAGE 0x8000 /* (ro) forced 0x0 */
1888
1889/* contents updated as a result of autonegotiation. layout and definitions
1890 * identical to PCS_MII_ADVERT
1891 */
1892#define REG_PCS_MII_LPA 0x900C /* PCS MII link partner
1893 ability reg */
1894#define PCS_MII_LPA_FD PCS_MII_ADVERT_FD
1895#define PCS_MII_LPA_HD PCS_MII_ADVERT_HD
1896#define PCS_MII_LPA_SYM_PAUSE PCS_MII_ADVERT_SYM_PAUSE
1897#define PCS_MII_LPA_ASYM_PAUSE PCS_MII_ADVERT_ASYM_PAUSE
1898#define PCS_MII_LPA_RF_MASK PCS_MII_ADVERT_RF_MASK
1899#define PCS_MII_LPA_ACK PCS_MII_ADVERT_ACK
1900#define PCS_MII_LPA_NEXT_PAGE PCS_MII_ADVERT_NEXT_PAGE
1901
1902/* DEFAULT: 0x0 */
1903#define REG_PCS_CFG 0x9010 /* PCS config reg */
1904#define PCS_CFG_EN 0x01 /* enable PCS. must be
1905 0 when modifying
1906 PCS_MII_ADVERT */
1907#define PCS_CFG_SD_OVERRIDE 0x02 /* sets signal detect to
1908 OK. bit is
1909 non-resettable */
1910#define PCS_CFG_SD_ACTIVE_LOW 0x04 /* changes interpretation
1911 of optical signal to make
1912 signal detect okay when
1913 signal is low */
1914#define PCS_CFG_JITTER_STUDY_MASK 0x18 /* used to make jitter
1915 measurements. a single
1916 code group is xmitted
1917 regularly.
1918 0x0 = normal operation
1919 0x1 = high freq test
1920 pattern, D21.5
1921 0x2 = low freq test
1922 pattern, K28.7
1923 0x3 = reserved */
1924#define PCS_CFG_10MS_TIMER_OVERRIDE 0x20 /* shortens 10-20ms auto-
1925 negotiation timer to
1926 a few cycles for test
1927 purposes */
1928
1929/* used for diagnostic purposes. bits 20-22 autoclear on read */
1930#define REG_PCS_STATE_MACHINE 0x9014 /* (ro) PCS state machine
1931 and diagnostic reg */
1932#define PCS_SM_TX_STATE_MASK 0x0000000F /* 0 and 1 indicate
1933 xmission of idle.
1934 otherwise, xmission of
1935 a packet */
1936#define PCS_SM_RX_STATE_MASK 0x000000F0 /* 0 indicates reception
1937 of idle. otherwise,
1938 reception of packet */
1939#define PCS_SM_WORD_SYNC_STATE_MASK 0x00000700 /* 0 indicates loss of
1940 sync */
1941#define PCS_SM_SEQ_DETECT_STATE_MASK 0x00001800 /* cycling through 0-3
1942 indicates reception of
1943 Config codes. cycling
1944 through 0-1 indicates
1945 reception of idles */
1946#define PCS_SM_LINK_STATE_MASK 0x0001E000
1947#define SM_LINK_STATE_UP 0x00016000 /* link state is up */
1948
1949#define PCS_SM_LOSS_LINK_C 0x00100000 /* loss of link due to
1950 recept of Config
1951 codes */
1952#define PCS_SM_LOSS_LINK_SYNC 0x00200000 /* loss of link due to
1953 loss of sync */
1954#define PCS_SM_LOSS_SIGNAL_DETECT 0x00400000 /* signal detect goes
1955 from OK to FAIL. bit29
1956 will also be set if
1957 this is set */
1958#define PCS_SM_NO_LINK_BREAKLINK 0x01000000 /* link not up due to
1959 receipt of breaklink
1960 C codes from partner.
1961 C codes w/ 0 content
1962 received triggering
1963 start/restart of
1964 autonegotiation.
1965 should be sent for
1966 no longer than 20ms */
1967#define PCS_SM_NO_LINK_SERDES 0x02000000 /* serdes being
1968 initialized. see serdes
1969 state reg */
1970#define PCS_SM_NO_LINK_C 0x04000000 /* C codes not stable or
1971 not received */
1972#define PCS_SM_NO_LINK_SYNC 0x08000000 /* word sync not
1973 achieved */
1974#define PCS_SM_NO_LINK_WAIT_C 0x10000000 /* waiting for C codes
1975 w/ ack bit set */
1976#define PCS_SM_NO_LINK_NO_IDLE 0x20000000 /* link partner continues
1977 to send C codes
1978 instead of idle
1979 symbols or pkt data */
1980
1981/* this register indicates interrupt changes in specific PCS MII status bits.
1982 * PCS_INT may be masked at the ISR level. only a single bit is implemented
1983 * for link status change.
1984 */
1985#define REG_PCS_INTR_STATUS 0x9018 /* PCS interrupt status */
1986#define PCS_INTR_STATUS_LINK_CHANGE 0x04 /* link status has changed
1987 since last read */
1988
1989/* control which network interface is used. no more than one bit should
1990 * be set.
1991 * DEFAULT: none
1992 */
1993#define REG_PCS_DATAPATH_MODE 0x9050 /* datapath mode reg */
1994#define PCS_DATAPATH_MODE_MII 0x00 /* PCS is not used and
1995 MII/GMII is selected.
1996 selection between MII and
1997 GMII is controlled by
1998 XIF_CFG */
1999#define PCS_DATAPATH_MODE_SERDES 0x02 /* PCS is used via the
2000 10-bit interface */
2001
2002/* input to serdes chip or serialink block */
2003#define REG_PCS_SERDES_CTRL 0x9054 /* serdes control reg */
2004#define PCS_SERDES_CTRL_LOOPBACK 0x01 /* enable loopback on
2005 serdes interface */
2006#define PCS_SERDES_CTRL_SYNCD_EN 0x02 /* enable sync carrier
2007 detection. should be
2008 0x0 for normal
2009 operation */
2010#define PCS_SERDES_CTRL_LOCKREF 0x04 /* frequency-lock RBC[0:1]
2011 to REFCLK when set.
2012 when clear, receiver
2013 clock locks to incoming
2014 serial data */
2015
2016/* multiplex test outputs into the PROM address (PA_3 through PA_0) pins.
2017 * should be 0x0 for normal operations.
2018 * 0b000 normal operation, PROM address[3:0] selected
2019 * 0b001 rxdma req, rxdma ack, rxdma ready, rxdma read
2020 * 0b010 rxmac req, rx ack, rx tag, rx clk shared
2021 * 0b011 txmac req, tx ack, tx tag, tx retry req
2022 * 0b100 tx tp3, tx tp2, tx tp1, tx tp0
2023 * 0b101 R period RX, R period TX, R period HP, R period BIM
2024 * DEFAULT: 0x0
2025 */
2026#define REG_PCS_SHARED_OUTPUT_SEL 0x9058 /* shared output select */
2027#define PCS_SOS_PROM_ADDR_MASK 0x0007
2028
2029/* used for diagnostics. this register indicates progress of the SERDES
2030 * boot up.
2031 * 0b00 undergoing reset
2032 * 0b01 waiting 500us while lockrefn is asserted
2033 * 0b10 waiting for comma detect
2034 * 0b11 receive data is synchronized
2035 * DEFAULT: 0x0
2036 */
2037#define REG_PCS_SERDES_STATE 0x905C /* (ro) serdes state */
2038#define PCS_SERDES_STATE_MASK 0x03
2039
2040/* used for diagnostics. indicates number of packets transmitted or received.
2041 * counters rollover w/out generating an interrupt.
2042 * DEFAULT: 0x0
2043 */
2044#define REG_PCS_PACKET_COUNT 0x9060 /* (ro) PCS packet counter */
2045#define PCS_PACKET_COUNT_TX 0x000007FF /* pkts xmitted by PCS */
2046#define PCS_PACKET_COUNT_RX 0x07FF0000 /* pkts recvd by PCS
2047 whether they
2048 encountered an error
2049 or not */
2050
2051/** LocalBus Devices. the following provides run-time access to the
2052 * Cassini's PROM
2053 ***/
2054#define REG_EXPANSION_ROM_RUN_START 0x100000 /* expansion rom run time
2055 access */
2056#define REG_EXPANSION_ROM_RUN_END 0x17FFFF
2057
2058#define REG_SECOND_LOCALBUS_START 0x180000 /* secondary local bus
2059 device */
2060#define REG_SECOND_LOCALBUS_END 0x1FFFFF
2061
2062/* entropy device */
2063#define REG_ENTROPY_START REG_SECOND_LOCALBUS_START
2064#define REG_ENTROPY_DATA (REG_ENTROPY_START + 0x00)
2065#define REG_ENTROPY_STATUS (REG_ENTROPY_START + 0x04)
2066#define ENTROPY_STATUS_DRDY 0x01
2067#define ENTROPY_STATUS_BUSY 0x02
2068#define ENTROPY_STATUS_CIPHER 0x04
2069#define ENTROPY_STATUS_BYPASS_MASK 0x18
2070#define REG_ENTROPY_MODE (REG_ENTROPY_START + 0x05)
2071#define ENTROPY_MODE_KEY_MASK 0x07
2072#define ENTROPY_MODE_ENCRYPT 0x40
2073#define REG_ENTROPY_RAND_REG (REG_ENTROPY_START + 0x06)
2074#define REG_ENTROPY_RESET (REG_ENTROPY_START + 0x07)
2075#define ENTROPY_RESET_DES_IO 0x01
2076#define ENTROPY_RESET_STC_MODE 0x02
2077#define ENTROPY_RESET_KEY_CACHE 0x04
2078#define ENTROPY_RESET_IV 0x08
2079#define REG_ENTROPY_IV (REG_ENTROPY_START + 0x08)
2080#define REG_ENTROPY_KEY0 (REG_ENTROPY_START + 0x10)
2081#define REG_ENTROPY_KEYN(x) (REG_ENTROPY_KEY0 + 4*(x))
2082
2083/* phys of interest w/ their special mii registers */
2084#define PHY_LUCENT_B0 0x00437421
2085#define LUCENT_MII_REG 0x1F
2086
2087#define PHY_NS_DP83065 0x20005c78
2088#define DP83065_MII_MEM 0x16
2089#define DP83065_MII_REGD 0x1D
2090#define DP83065_MII_REGE 0x1E
2091
2092#define PHY_BROADCOM_5411 0x00206071
2093#define PHY_BROADCOM_B0 0x00206050
2094#define BROADCOM_MII_REG4 0x14
2095#define BROADCOM_MII_REG5 0x15
2096#define BROADCOM_MII_REG7 0x17
2097#define BROADCOM_MII_REG8 0x18
2098
2099#define CAS_MII_ANNPTR 0x07
2100#define CAS_MII_ANNPRR 0x08
2101#define CAS_MII_1000_CTRL 0x09
2102#define CAS_MII_1000_STATUS 0x0A
2103#define CAS_MII_1000_EXTEND 0x0F
2104
2105#define CAS_BMSR_1000_EXTEND 0x0100 /* supports 1000Base-T extended status */
2106/*
2107 * if autoneg is disabled, here's the table:
2108 * BMCR_SPEED100 = 100Mbps
2109 * BMCR_SPEED1000 = 1000Mbps
2110 * ~(BMCR_SPEED100 | BMCR_SPEED1000) = 10Mbps
2111 */
2112#define CAS_BMCR_SPEED1000 0x0040 /* Select 1000Mbps */
2113
2114#define CAS_ADVERTISE_1000HALF 0x0100
2115#define CAS_ADVERTISE_1000FULL 0x0200
2116#define CAS_ADVERTISE_PAUSE 0x0400
2117#define CAS_ADVERTISE_ASYM_PAUSE 0x0800
2118
2119/* regular lpa register */
2120#define CAS_LPA_PAUSE CAS_ADVERTISE_PAUSE
2121#define CAS_LPA_ASYM_PAUSE CAS_ADVERTISE_ASYM_PAUSE
2122
2123/* 1000_STATUS register */
2124#define CAS_LPA_1000HALF 0x0400
2125#define CAS_LPA_1000FULL 0x0800
2126
2127#define CAS_EXTEND_1000XFULL 0x8000
2128#define CAS_EXTEND_1000XHALF 0x4000
2129#define CAS_EXTEND_1000TFULL 0x2000
2130#define CAS_EXTEND_1000THALF 0x1000
2131
2132/* cassini header parser firmware */
2133typedef struct cas_hp_inst {
2134 const char *note;
2135
2136 u16 mask, val;
2137
2138 u8 op;
2139 u8 soff, snext; /* if match succeeds, new offset and match */
2140 u8 foff, fnext; /* if match fails, new offset and match */
2141 /* output info */
2142 u8 outop; /* output opcode */
2143
2144 u16 outarg; /* output argument */
2145 u8 outenab; /* output enable: 0 = not, 1 = if match
2146 2 = if !match, 3 = always */
2147 u8 outshift; /* barrel shift right, 4 bits */
2148 u16 outmask;
2149} cas_hp_inst_t;
2150
2151/* comparison */
2152#define OP_EQ 0 /* packet == value */
2153#define OP_LT 1 /* packet < value */
2154#define OP_GT 2 /* packet > value */
2155#define OP_NP 3 /* new packet */
2156
2157/* output opcodes */
2158#define CL_REG 0
2159#define LD_FID 1
2160#define LD_SEQ 2
2161#define LD_CTL 3
2162#define LD_SAP 4
2163#define LD_R1 5
2164#define LD_L3 6
2165#define LD_SUM 7
2166#define LD_HDR 8
2167#define IM_FID 9
2168#define IM_SEQ 10
2169#define IM_SAP 11
2170#define IM_R1 12
2171#define IM_CTL 13
2172#define LD_LEN 14
2173#define ST_FLG 15
2174
2175/* match setp #s for IP4TCP4 */
2176#define S1_PCKT 0
2177#define S1_VLAN 1
2178#define S1_CFI 2
2179#define S1_8023 3
2180#define S1_LLC 4
2181#define S1_LLCc 5
2182#define S1_IPV4 6
2183#define S1_IPV4c 7
2184#define S1_IPV4F 8
2185#define S1_TCP44 9
2186#define S1_IPV6 10
2187#define S1_IPV6L 11
2188#define S1_IPV6c 12
2189#define S1_TCP64 13
2190#define S1_TCPSQ 14
2191#define S1_TCPFG 15
2192#define S1_TCPHL 16
2193#define S1_TCPHc 17
2194#define S1_CLNP 18
2195#define S1_CLNP2 19
2196#define S1_DROP 20
2197#define S2_HTTP 21
2198#define S1_ESP4 22
2199#define S1_AH4 23
2200#define S1_ESP6 24
2201#define S1_AH6 25
2202
2203#define CAS_PROG_IP46TCP4_PREAMBLE \
2204{ "packet arrival?", 0xffff, 0x0000, OP_NP, 6, S1_VLAN, 0, S1_PCKT, \
2205 CL_REG, 0x3ff, 1, 0x0, 0x0000}, \
2206{ "VLAN?", 0xffff, 0x8100, OP_EQ, 1, S1_CFI, 0, S1_8023, \
2207 IM_CTL, 0x00a, 3, 0x0, 0xffff}, \
2208{ "CFI?", 0x1000, 0x1000, OP_EQ, 0, S1_DROP, 1, S1_8023, \
2209 CL_REG, 0x000, 0, 0x0, 0x0000}, \
2210{ "8023?", 0xffff, 0x0600, OP_LT, 1, S1_LLC, 0, S1_IPV4, \
2211 CL_REG, 0x000, 0, 0x0, 0x0000}, \
2212{ "LLC?", 0xffff, 0xaaaa, OP_EQ, 1, S1_LLCc, 0, S1_CLNP, \
2213 CL_REG, 0x000, 0, 0x0, 0x0000}, \
2214{ "LLCc?", 0xff00, 0x0300, OP_EQ, 2, S1_IPV4, 0, S1_CLNP, \
2215 CL_REG, 0x000, 0, 0x0, 0x0000}, \
2216{ "IPV4?", 0xffff, 0x0800, OP_EQ, 1, S1_IPV4c, 0, S1_IPV6, \
2217 LD_SAP, 0x100, 3, 0x0, 0xffff}, \
2218{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ, 3, S1_IPV4F, 0, S1_CLNP, \
2219 LD_SUM, 0x00a, 1, 0x0, 0x0000}, \
2220{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ, 1, S1_TCP44, 0, S1_CLNP, \
2221 LD_LEN, 0x03e, 1, 0x0, 0xffff}, \
2222{ "TCP44?", 0x00ff, 0x0006, OP_EQ, 7, S1_TCPSQ, 0, S1_CLNP, \
2223 LD_FID, 0x182, 1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */ \
2224{ "IPV6?", 0xffff, 0x86dd, OP_EQ, 1, S1_IPV6L, 0, S1_CLNP, \
2225 LD_SUM, 0x015, 1, 0x0, 0x0000}, \
2226{ "IPV6 len", 0xf000, 0x6000, OP_EQ, 0, S1_IPV6c, 0, S1_CLNP, \
2227 IM_R1, 0x128, 1, 0x0, 0xffff}, \
2228{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ, 3, S1_TCP64, 0, S1_CLNP, \
2229 LD_FID, 0x484, 1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */ \
2230{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP, \
2231 LD_LEN, 0x03f, 1, 0x0, 0xffff}
2232
2233#ifdef USE_HP_IP46TCP4
2234static cas_hp_inst_t cas_prog_ip46tcp4tab[] = {
2235 CAS_PROG_IP46TCP4_PREAMBLE,
2236 { "TCP seq", /* DADDR should point to dest port */
2237 0x0000, 0x0000, OP_EQ, 0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ,
2238 0x081, 3, 0x0, 0xffff}, /* Load TCP seq # */
2239 { "TCP control flags", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHL, 0,
2240 S1_TCPHL, ST_FLG, 0x045, 3, 0x0, 0x002f}, /* Load TCP flags */
2241 { "TCP length", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHc, 0,
2242 S1_TCPHc, LD_R1, 0x205, 3, 0xB, 0xf000},
2243 { "TCP length cont", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0,
2244 S1_PCKT, LD_HDR, 0x0ff, 3, 0x0, 0xffff},
2245 { "Cleanup", 0x0000, 0x0000, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP2,
2246 IM_CTL, 0x001, 3, 0x0, 0x0001},
2247 { "Cleanup 2", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2248 IM_CTL, 0x000, 0, 0x0, 0x0000},
2249 { "Drop packet", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2250 IM_CTL, 0x080, 3, 0x0, 0xffff},
2251 { NULL },
2252};
2253#ifdef HP_IP46TCP4_DEFAULT
2254#define CAS_HP_FIRMWARE cas_prog_ip46tcp4tab
2255#endif
2256#endif
2257
2258/*
2259 * Alternate table load which excludes HTTP server traffic from reassembly.
2260 * It is substantially similar to the basic table, with one extra state
2261 * and a few extra compares. */
2262#ifdef USE_HP_IP46TCP4NOHTTP
2263static cas_hp_inst_t cas_prog_ip46tcp4nohttptab[] = {
2264 CAS_PROG_IP46TCP4_PREAMBLE,
2265 { "TCP seq", /* DADDR should point to dest port */
2266 0xFFFF, 0x0080, OP_EQ, 0, S2_HTTP, 0, S1_TCPFG, LD_SEQ,
2267 0x081, 3, 0x0, 0xffff} , /* Load TCP seq # */
2268 { "TCP control flags", 0xFFFF, 0x8080, OP_EQ, 0, S2_HTTP, 0,
2269 S1_TCPHL, ST_FLG, 0x145, 2, 0x0, 0x002f, }, /* Load TCP flags */
2270 { "TCP length", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHc, 0, S1_TCPHc,
2271 LD_R1, 0x205, 3, 0xB, 0xf000},
2272 { "TCP length cont", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2273 LD_HDR, 0x0ff, 3, 0x0, 0xffff},
2274 { "Cleanup", 0x0000, 0x0000, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP2,
2275 IM_CTL, 0x001, 3, 0x0, 0x0001},
2276 { "Cleanup 2", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2277 CL_REG, 0x002, 3, 0x0, 0x0000},
2278 { "Drop packet", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2279 IM_CTL, 0x080, 3, 0x0, 0xffff},
2280 { "No HTTP", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2281 IM_CTL, 0x044, 3, 0x0, 0xffff},
2282 { NULL },
2283};
2284#ifdef HP_IP46TCP4NOHTTP_DEFAULT
2285#define CAS_HP_FIRMWARE cas_prog_ip46tcp4nohttptab
2286#endif
2287#endif
2288
2289/* match step #s for IP4FRAG */
2290#define S3_IPV6c 11
2291#define S3_TCP64 12
2292#define S3_TCPSQ 13
2293#define S3_TCPFG 14
2294#define S3_TCPHL 15
2295#define S3_TCPHc 16
2296#define S3_FRAG 17
2297#define S3_FOFF 18
2298#define S3_CLNP 19
2299
2300#ifdef USE_HP_IP4FRAG
2301static cas_hp_inst_t cas_prog_ip4fragtab[] = {
2302 { "packet arrival?", 0xffff, 0x0000, OP_NP, 6, S1_VLAN, 0, S1_PCKT,
2303 CL_REG, 0x3ff, 1, 0x0, 0x0000},
2304 { "VLAN?", 0xffff, 0x8100, OP_EQ, 1, S1_CFI, 0, S1_8023,
2305 IM_CTL, 0x00a, 3, 0x0, 0xffff},
2306 { "CFI?", 0x1000, 0x1000, OP_EQ, 0, S3_CLNP, 1, S1_8023,
2307 CL_REG, 0x000, 0, 0x0, 0x0000},
2308 { "8023?", 0xffff, 0x0600, OP_LT, 1, S1_LLC, 0, S1_IPV4,
2309 CL_REG, 0x000, 0, 0x0, 0x0000},
2310 { "LLC?", 0xffff, 0xaaaa, OP_EQ, 1, S1_LLCc, 0, S3_CLNP,
2311 CL_REG, 0x000, 0, 0x0, 0x0000},
2312 { "LLCc?",0xff00, 0x0300, OP_EQ, 2, S1_IPV4, 0, S3_CLNP,
2313 CL_REG, 0x000, 0, 0x0, 0x0000},
2314 { "IPV4?", 0xffff, 0x0800, OP_EQ, 1, S1_IPV4c, 0, S1_IPV6,
2315 LD_SAP, 0x100, 3, 0x0, 0xffff},
2316 { "IPV4 cont?", 0xff00, 0x4500, OP_EQ, 3, S1_IPV4F, 0, S3_CLNP,
2317 LD_SUM, 0x00a, 1, 0x0, 0x0000},
2318 { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ, 1, S1_TCP44, 0, S3_FRAG,
2319 LD_LEN, 0x03e, 3, 0x0, 0xffff},
2320 { "TCP44?", 0x00ff, 0x0006, OP_EQ, 7, S3_TCPSQ, 0, S3_CLNP,
2321 LD_FID, 0x182, 3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
2322 { "IPV6?", 0xffff, 0x86dd, OP_EQ, 1, S3_IPV6c, 0, S3_CLNP,
2323 LD_SUM, 0x015, 1, 0x0, 0x0000},
2324 { "IPV6 cont?", 0xf000, 0x6000, OP_EQ, 3, S3_TCP64, 0, S3_CLNP,
2325 LD_FID, 0x484, 1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
2326 { "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S3_TCPSQ, 0, S3_CLNP,
2327 LD_LEN, 0x03f, 1, 0x0, 0xffff},
2328 { "TCP seq", /* DADDR should point to dest port */
2329 0x0000, 0x0000, OP_EQ, 0, S3_TCPFG, 4, S3_TCPFG, LD_SEQ,
2330 0x081, 3, 0x0, 0xffff}, /* Load TCP seq # */
2331 { "TCP control flags", 0x0000, 0x0000, OP_EQ, 0, S3_TCPHL, 0,
2332 S3_TCPHL, ST_FLG, 0x045, 3, 0x0, 0x002f}, /* Load TCP flags */
2333 { "TCP length", 0x0000, 0x0000, OP_EQ, 0, S3_TCPHc, 0, S3_TCPHc,
2334 LD_R1, 0x205, 3, 0xB, 0xf000},
2335 { "TCP length cont", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2336 LD_HDR, 0x0ff, 3, 0x0, 0xffff},
2337 { "IP4 Fragment", 0x0000, 0x0000, OP_EQ, 0, S3_FOFF, 0, S3_FOFF,
2338 LD_FID, 0x103, 3, 0x0, 0xffff}, /* FID IP4 src+dst */
2339 { "IP4 frag offset", 0x0000, 0x0000, OP_EQ, 0, S3_FOFF, 0, S3_FOFF,
2340 LD_SEQ, 0x040, 1, 0xD, 0xfff8},
2341 { "Cleanup", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2342 IM_CTL, 0x001, 3, 0x0, 0x0001},
2343 { NULL },
2344};
2345#ifdef HP_IP4FRAG_DEFAULT
2346#define CAS_HP_FIRMWARE cas_prog_ip4fragtab
2347#endif
2348#endif
2349
2350/*
2351 * Alternate table which does batching without reassembly
2352 */
2353#ifdef USE_HP_IP46TCP4BATCH
2354static cas_hp_inst_t cas_prog_ip46tcp4batchtab[] = {
2355 CAS_PROG_IP46TCP4_PREAMBLE,
2356 { "TCP seq", /* DADDR should point to dest port */
2357 0x0000, 0x0000, OP_EQ, 0, S1_TCPFG, 0, S1_TCPFG, LD_SEQ,
2358 0x081, 3, 0x0, 0xffff}, /* Load TCP seq # */
2359 { "TCP control flags", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHL, 0,
2360 S1_TCPHL, ST_FLG, 0x000, 3, 0x0, 0x0000}, /* Load TCP flags */
2361 { "TCP length", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHc, 0,
2362 S1_TCPHc, LD_R1, 0x205, 3, 0xB, 0xf000},
2363 { "TCP length cont", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0,
2364 S1_PCKT, IM_CTL, 0x040, 3, 0x0, 0xffff}, /* set batch bit */
2365 { "Cleanup", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2366 IM_CTL, 0x001, 3, 0x0, 0x0001},
2367 { "Drop packet", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0,
2368 S1_PCKT, IM_CTL, 0x080, 3, 0x0, 0xffff},
2369 { NULL },
2370};
2371#ifdef HP_IP46TCP4BATCH_DEFAULT
2372#define CAS_HP_FIRMWARE cas_prog_ip46tcp4batchtab
2373#endif
2374#endif
2375
2376/* Workaround for Cassini rev2 descriptor corruption problem.
2377 * Does batching without reassembly, and sets the SAP to a known
2378 * data pattern for all packets.
2379 */
2380#ifdef USE_HP_WORKAROUND
2381static cas_hp_inst_t cas_prog_workaroundtab[] = {
2382 { "packet arrival?", 0xffff, 0x0000, OP_NP, 6, S1_VLAN, 0,
2383 S1_PCKT, CL_REG, 0x3ff, 1, 0x0, 0x0000} ,
2384 { "VLAN?", 0xffff, 0x8100, OP_EQ, 1, S1_CFI, 0, S1_8023,
2385 IM_CTL, 0x04a, 3, 0x0, 0xffff},
2386 { "CFI?", 0x1000, 0x1000, OP_EQ, 0, S1_CLNP, 1, S1_8023,
2387 CL_REG, 0x000, 0, 0x0, 0x0000},
2388 { "8023?", 0xffff, 0x0600, OP_LT, 1, S1_LLC, 0, S1_IPV4,
2389 CL_REG, 0x000, 0, 0x0, 0x0000},
2390 { "LLC?", 0xffff, 0xaaaa, OP_EQ, 1, S1_LLCc, 0, S1_CLNP,
2391 CL_REG, 0x000, 0, 0x0, 0x0000},
2392 { "LLCc?", 0xff00, 0x0300, OP_EQ, 2, S1_IPV4, 0, S1_CLNP,
2393 CL_REG, 0x000, 0, 0x0, 0x0000},
2394 { "IPV4?", 0xffff, 0x0800, OP_EQ, 1, S1_IPV4c, 0, S1_IPV6,
2395 IM_SAP, 0x6AE, 3, 0x0, 0xffff},
2396 { "IPV4 cont?", 0xff00, 0x4500, OP_EQ, 3, S1_IPV4F, 0, S1_CLNP,
2397 LD_SUM, 0x00a, 1, 0x0, 0x0000},
2398 { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ, 1, S1_TCP44, 0, S1_CLNP,
2399 LD_LEN, 0x03e, 1, 0x0, 0xffff},
2400 { "TCP44?", 0x00ff, 0x0006, OP_EQ, 7, S1_TCPSQ, 0, S1_CLNP,
2401 LD_FID, 0x182, 3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
2402 { "IPV6?", 0xffff, 0x86dd, OP_EQ, 1, S1_IPV6L, 0, S1_CLNP,
2403 LD_SUM, 0x015, 1, 0x0, 0x0000},
2404 { "IPV6 len", 0xf000, 0x6000, OP_EQ, 0, S1_IPV6c, 0, S1_CLNP,
2405 IM_R1, 0x128, 1, 0x0, 0xffff},
2406 { "IPV6 cont?", 0x0000, 0x0000, OP_EQ, 3, S1_TCP64, 0, S1_CLNP,
2407 LD_FID, 0x484, 1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
2408 { "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP,
2409 LD_LEN, 0x03f, 1, 0x0, 0xffff},
2410 { "TCP seq", /* DADDR should point to dest port */
2411 0x0000, 0x0000, OP_EQ, 0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ,
2412 0x081, 3, 0x0, 0xffff}, /* Load TCP seq # */
2413 { "TCP control flags", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHL, 0,
2414 S1_TCPHL, ST_FLG, 0x045, 3, 0x0, 0x002f}, /* Load TCP flags */
2415 { "TCP length", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHc, 0, S1_TCPHc,
2416 LD_R1, 0x205, 3, 0xB, 0xf000},
2417 { "TCP length cont", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0,
2418 S1_PCKT, LD_HDR, 0x0ff, 3, 0x0, 0xffff},
2419 { "Cleanup", 0x0000, 0x0000, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP2,
2420 IM_SAP, 0x6AE, 3, 0x0, 0xffff} ,
2421 { "Cleanup 2", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2422 IM_CTL, 0x001, 3, 0x0, 0x0001},
2423 { NULL },
2424};
2425#ifdef HP_WORKAROUND_DEFAULT
2426#define CAS_HP_FIRMWARE cas_prog_workaroundtab
2427#endif
2428#endif
2429
2430#ifdef USE_HP_ENCRYPT
2431static cas_hp_inst_t cas_prog_encryptiontab[] = {
2432 { "packet arrival?", 0xffff, 0x0000, OP_NP, 6, S1_VLAN, 0,
2433 S1_PCKT, CL_REG, 0x3ff, 1, 0x0, 0x0000},
2434 { "VLAN?", 0xffff, 0x8100, OP_EQ, 1, S1_CFI, 0, S1_8023,
2435 IM_CTL, 0x00a, 3, 0x0, 0xffff},
2436#if 0
2437//"CFI?", /* 02 FIND CFI and If FIND go to S1_DROP */
2438//0x1000, 0x1000, OP_EQ, 0, S1_DROP, 1, S1_8023, CL_REG, 0x000, 0, 0x0, 0x00
2439 00,
2440#endif
2441 { "CFI?", /* FIND CFI and If FIND go to CleanUP1 (ignore and send to host) */
2442 0x1000, 0x1000, OP_EQ, 0, S1_CLNP, 1, S1_8023,
2443 CL_REG, 0x000, 0, 0x0, 0x0000},
2444 { "8023?", 0xffff, 0x0600, OP_LT, 1, S1_LLC, 0, S1_IPV4,
2445 CL_REG, 0x000, 0, 0x0, 0x0000},
2446 { "LLC?", 0xffff, 0xaaaa, OP_EQ, 1, S1_LLCc, 0, S1_CLNP,
2447 CL_REG, 0x000, 0, 0x0, 0x0000},
2448 { "LLCc?", 0xff00, 0x0300, OP_EQ, 2, S1_IPV4, 0, S1_CLNP,
2449 CL_REG, 0x000, 0, 0x0, 0x0000},
2450 { "IPV4?", 0xffff, 0x0800, OP_EQ, 1, S1_IPV4c, 0, S1_IPV6,
2451 LD_SAP, 0x100, 3, 0x0, 0xffff},
2452 { "IPV4 cont?", 0xff00, 0x4500, OP_EQ, 3, S1_IPV4F, 0, S1_CLNP,
2453 LD_SUM, 0x00a, 1, 0x0, 0x0000},
2454 { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ, 1, S1_TCP44, 0, S1_CLNP,
2455 LD_LEN, 0x03e, 1, 0x0, 0xffff},
2456 { "TCP44?", 0x00ff, 0x0006, OP_EQ, 7, S1_TCPSQ, 0, S1_ESP4,
2457 LD_FID, 0x182, 1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
2458 { "IPV6?", 0xffff, 0x86dd, OP_EQ, 1, S1_IPV6L, 0, S1_CLNP,
2459 LD_SUM, 0x015, 1, 0x0, 0x0000},
2460 { "IPV6 len", 0xf000, 0x6000, OP_EQ, 0, S1_IPV6c, 0, S1_CLNP,
2461 IM_R1, 0x128, 1, 0x0, 0xffff},
2462 { "IPV6 cont?", 0x0000, 0x0000, OP_EQ, 3, S1_TCP64, 0, S1_CLNP,
2463 LD_FID, 0x484, 1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
2464 { "TCP64?",
2465#if 0
2466//@@@0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_ESP6, LD_LEN, 0x03f, 1, 0x0, 0xffff,
2467#endif
2468 0xff00, 0x0600, OP_EQ, 12, S1_TCPSQ, 0, S1_ESP6, LD_LEN,
2469 0x03f, 1, 0x0, 0xffff},
2470 { "TCP seq", /* 14:DADDR should point to dest port */
2471 0xFFFF, 0x0080, OP_EQ, 0, S2_HTTP, 0, S1_TCPFG, LD_SEQ,
2472 0x081, 3, 0x0, 0xffff}, /* Load TCP seq # */
2473 { "TCP control flags", 0xFFFF, 0x8080, OP_EQ, 0, S2_HTTP, 0,
2474 S1_TCPHL, ST_FLG, 0x145, 2, 0x0, 0x002f}, /* Load TCP flags */
2475 { "TCP length", 0x0000, 0x0000, OP_EQ, 0, S1_TCPHc, 0, S1_TCPHc,
2476 LD_R1, 0x205, 3, 0xB, 0xf000} ,
2477 { "TCP length cont", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0,
2478 S1_PCKT, LD_HDR, 0x0ff, 3, 0x0, 0xffff},
2479 { "Cleanup", 0x0000, 0x0000, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP2,
2480 IM_CTL, 0x001, 3, 0x0, 0x0001},
2481 { "Cleanup 2", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2482 CL_REG, 0x002, 3, 0x0, 0x0000},
2483 { "Drop packet", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2484 IM_CTL, 0x080, 3, 0x0, 0xffff},
2485 { "No HTTP", 0x0000, 0x0000, OP_EQ, 0, S1_PCKT, 0, S1_PCKT,
2486 IM_CTL, 0x044, 3, 0x0, 0xffff},
2487 { "IPV4 ESP encrypted?", /* S1_ESP4 */
2488 0x00ff, 0x0032, OP_EQ, 0, S1_CLNP2, 0, S1_AH4, IM_CTL,
2489 0x021, 1, 0x0, 0xffff},
2490 { "IPV4 AH encrypted?", /* S1_AH4 */
2491 0x00ff, 0x0033, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
2492 0x021, 1, 0x0, 0xffff},
2493 { "IPV6 ESP encrypted?", /* S1_ESP6 */
2494#if 0
2495//@@@0x00ff, 0x0032, OP_EQ, 0, S1_CLNP2, 0, S1_AH6, IM_CTL, 0x021, 1, 0x0, 0xffff,
2496#endif
2497 0xff00, 0x3200, OP_EQ, 0, S1_CLNP2, 0, S1_AH6, IM_CTL,
2498 0x021, 1, 0x0, 0xffff},
2499 { "IPV6 AH encrypted?", /* S1_AH6 */
2500#if 0
2501//@@@0x00ff, 0x0033, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP, IM_CTL, 0x021, 1, 0x0, 0xffff,
2502#endif
2503 0xff00, 0x3300, OP_EQ, 0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
2504 0x021, 1, 0x0, 0xffff},
2505 { NULL },
2506};
2507#ifdef HP_ENCRYPT_DEFAULT
2508#define CAS_HP_FIRMWARE cas_prog_encryptiontab
2509#endif
2510#endif
2511
2512static cas_hp_inst_t cas_prog_null[] = { {NULL} };
2513#ifdef HP_NULL_DEFAULT
2514#define CAS_HP_FIRMWARE cas_prog_null
2515#endif
2516
2517/* firmware patch for NS_DP83065 */
2518typedef struct cas_saturn_patch {
2519 u16 addr;
2520 u16 val;
2521} cas_saturn_patch_t;
2522
2523#if 1
2524cas_saturn_patch_t cas_saturn_patch[] = {
2525{0x8200, 0x007e}, {0x8201, 0x0082}, {0x8202, 0x0009},
2526{0x8203, 0x0000}, {0x8204, 0x0000}, {0x8205, 0x0000},
2527{0x8206, 0x0000}, {0x8207, 0x0000}, {0x8208, 0x0000},
2528{0x8209, 0x008e}, {0x820a, 0x008e}, {0x820b, 0x00ff},
2529{0x820c, 0x00ce}, {0x820d, 0x0082}, {0x820e, 0x0025},
2530{0x820f, 0x00ff}, {0x8210, 0x0001}, {0x8211, 0x000f},
2531{0x8212, 0x00ce}, {0x8213, 0x0084}, {0x8214, 0x0026},
2532{0x8215, 0x00ff}, {0x8216, 0x0001}, {0x8217, 0x0011},
2533{0x8218, 0x00ce}, {0x8219, 0x0085}, {0x821a, 0x003d},
2534{0x821b, 0x00df}, {0x821c, 0x00e5}, {0x821d, 0x0086},
2535{0x821e, 0x0039}, {0x821f, 0x00b7}, {0x8220, 0x008f},
2536{0x8221, 0x00f8}, {0x8222, 0x007e}, {0x8223, 0x00c3},
2537{0x8224, 0x00c2}, {0x8225, 0x0096}, {0x8226, 0x0047},
2538{0x8227, 0x0084}, {0x8228, 0x00f3}, {0x8229, 0x008a},
2539{0x822a, 0x0000}, {0x822b, 0x0097}, {0x822c, 0x0047},
2540{0x822d, 0x00ce}, {0x822e, 0x0082}, {0x822f, 0x0033},
2541{0x8230, 0x00ff}, {0x8231, 0x0001}, {0x8232, 0x000f},
2542{0x8233, 0x0096}, {0x8234, 0x0046}, {0x8235, 0x0084},
2543{0x8236, 0x000c}, {0x8237, 0x0081}, {0x8238, 0x0004},
2544{0x8239, 0x0027}, {0x823a, 0x000b}, {0x823b, 0x0096},
2545{0x823c, 0x0046}, {0x823d, 0x0084}, {0x823e, 0x000c},
2546{0x823f, 0x0081}, {0x8240, 0x0008}, {0x8241, 0x0027},
2547{0x8242, 0x0057}, {0x8243, 0x007e}, {0x8244, 0x0084},
2548{0x8245, 0x0025}, {0x8246, 0x0096}, {0x8247, 0x0047},
2549{0x8248, 0x0084}, {0x8249, 0x00f3}, {0x824a, 0x008a},
2550{0x824b, 0x0004}, {0x824c, 0x0097}, {0x824d, 0x0047},
2551{0x824e, 0x00ce}, {0x824f, 0x0082}, {0x8250, 0x0054},
2552{0x8251, 0x00ff}, {0x8252, 0x0001}, {0x8253, 0x000f},
2553{0x8254, 0x0096}, {0x8255, 0x0046}, {0x8256, 0x0084},
2554{0x8257, 0x000c}, {0x8258, 0x0081}, {0x8259, 0x0004},
2555{0x825a, 0x0026}, {0x825b, 0x0038}, {0x825c, 0x00b6},
2556{0x825d, 0x0012}, {0x825e, 0x0020}, {0x825f, 0x0084},
2557{0x8260, 0x0020}, {0x8261, 0x0026}, {0x8262, 0x0003},
2558{0x8263, 0x007e}, {0x8264, 0x0084}, {0x8265, 0x0025},
2559{0x8266, 0x0096}, {0x8267, 0x007b}, {0x8268, 0x00d6},
2560{0x8269, 0x007c}, {0x826a, 0x00fe}, {0x826b, 0x008f},
2561{0x826c, 0x0056}, {0x826d, 0x00bd}, {0x826e, 0x00f7},
2562{0x826f, 0x00b6}, {0x8270, 0x00fe}, {0x8271, 0x008f},
2563{0x8272, 0x004e}, {0x8273, 0x00bd}, {0x8274, 0x00ec},
2564{0x8275, 0x008e}, {0x8276, 0x00bd}, {0x8277, 0x00fa},
2565{0x8278, 0x00f7}, {0x8279, 0x00bd}, {0x827a, 0x00f7},
2566{0x827b, 0x0028}, {0x827c, 0x00ce}, {0x827d, 0x0082},
2567{0x827e, 0x0082}, {0x827f, 0x00ff}, {0x8280, 0x0001},
2568{0x8281, 0x000f}, {0x8282, 0x0096}, {0x8283, 0x0046},
2569{0x8284, 0x0084}, {0x8285, 0x000c}, {0x8286, 0x0081},
2570{0x8287, 0x0004}, {0x8288, 0x0026}, {0x8289, 0x000a},
2571{0x828a, 0x00b6}, {0x828b, 0x0012}, {0x828c, 0x0020},
2572{0x828d, 0x0084}, {0x828e, 0x0020}, {0x828f, 0x0027},
2573{0x8290, 0x00b5}, {0x8291, 0x007e}, {0x8292, 0x0084},
2574{0x8293, 0x0025}, {0x8294, 0x00bd}, {0x8295, 0x00f7},
2575{0x8296, 0x001f}, {0x8297, 0x007e}, {0x8298, 0x0084},
2576{0x8299, 0x001f}, {0x829a, 0x0096}, {0x829b, 0x0047},
2577{0x829c, 0x0084}, {0x829d, 0x00f3}, {0x829e, 0x008a},
2578{0x829f, 0x0008}, {0x82a0, 0x0097}, {0x82a1, 0x0047},
2579{0x82a2, 0x00de}, {0x82a3, 0x00e1}, {0x82a4, 0x00ad},
2580{0x82a5, 0x0000}, {0x82a6, 0x00ce}, {0x82a7, 0x0082},
2581{0x82a8, 0x00af}, {0x82a9, 0x00ff}, {0x82aa, 0x0001},
2582{0x82ab, 0x000f}, {0x82ac, 0x007e}, {0x82ad, 0x0084},
2583{0x82ae, 0x0025}, {0x82af, 0x0096}, {0x82b0, 0x0041},
2584{0x82b1, 0x0085}, {0x82b2, 0x0010}, {0x82b3, 0x0026},
2585{0x82b4, 0x0006}, {0x82b5, 0x0096}, {0x82b6, 0x0023},
2586{0x82b7, 0x0085}, {0x82b8, 0x0040}, {0x82b9, 0x0027},
2587{0x82ba, 0x0006}, {0x82bb, 0x00bd}, {0x82bc, 0x00ed},
2588{0x82bd, 0x0000}, {0x82be, 0x007e}, {0x82bf, 0x0083},
2589{0x82c0, 0x00a2}, {0x82c1, 0x00de}, {0x82c2, 0x0042},
2590{0x82c3, 0x00bd}, {0x82c4, 0x00eb}, {0x82c5, 0x008e},
2591{0x82c6, 0x0096}, {0x82c7, 0x0024}, {0x82c8, 0x0084},
2592{0x82c9, 0x0008}, {0x82ca, 0x0027}, {0x82cb, 0x0003},
2593{0x82cc, 0x007e}, {0x82cd, 0x0083}, {0x82ce, 0x00df},
2594{0x82cf, 0x0096}, {0x82d0, 0x007b}, {0x82d1, 0x00d6},
2595{0x82d2, 0x007c}, {0x82d3, 0x00fe}, {0x82d4, 0x008f},
2596{0x82d5, 0x0056}, {0x82d6, 0x00bd}, {0x82d7, 0x00f7},
2597{0x82d8, 0x00b6}, {0x82d9, 0x00fe}, {0x82da, 0x008f},
2598{0x82db, 0x0050}, {0x82dc, 0x00bd}, {0x82dd, 0x00ec},
2599{0x82de, 0x008e}, {0x82df, 0x00bd}, {0x82e0, 0x00fa},
2600{0x82e1, 0x00f7}, {0x82e2, 0x0086}, {0x82e3, 0x0011},
2601{0x82e4, 0x00c6}, {0x82e5, 0x0049}, {0x82e6, 0x00bd},
2602{0x82e7, 0x00e4}, {0x82e8, 0x0012}, {0x82e9, 0x00ce},
2603{0x82ea, 0x0082}, {0x82eb, 0x00ef}, {0x82ec, 0x00ff},
2604{0x82ed, 0x0001}, {0x82ee, 0x000f}, {0x82ef, 0x0096},
2605{0x82f0, 0x0046}, {0x82f1, 0x0084}, {0x82f2, 0x000c},
2606{0x82f3, 0x0081}, {0x82f4, 0x0000}, {0x82f5, 0x0027},
2607{0x82f6, 0x0017}, {0x82f7, 0x00c6}, {0x82f8, 0x0049},
2608{0x82f9, 0x00bd}, {0x82fa, 0x00e4}, {0x82fb, 0x0091},
2609{0x82fc, 0x0024}, {0x82fd, 0x000d}, {0x82fe, 0x00b6},
2610{0x82ff, 0x0012}, {0x8300, 0x0020}, {0x8301, 0x0085},
2611{0x8302, 0x0020}, {0x8303, 0x0026}, {0x8304, 0x000c},
2612{0x8305, 0x00ce}, {0x8306, 0x0082}, {0x8307, 0x00c1},
2613{0x8308, 0x00ff}, {0x8309, 0x0001}, {0x830a, 0x000f},
2614{0x830b, 0x007e}, {0x830c, 0x0084}, {0x830d, 0x0025},
2615{0x830e, 0x007e}, {0x830f, 0x0084}, {0x8310, 0x0016},
2616{0x8311, 0x00fe}, {0x8312, 0x008f}, {0x8313, 0x0052},
2617{0x8314, 0x00bd}, {0x8315, 0x00ec}, {0x8316, 0x008e},
2618{0x8317, 0x00bd}, {0x8318, 0x00fa}, {0x8319, 0x00f7},
2619{0x831a, 0x0086}, {0x831b, 0x006a}, {0x831c, 0x00c6},
2620{0x831d, 0x0049}, {0x831e, 0x00bd}, {0x831f, 0x00e4},
2621{0x8320, 0x0012}, {0x8321, 0x00ce}, {0x8322, 0x0083},
2622{0x8323, 0x0027}, {0x8324, 0x00ff}, {0x8325, 0x0001},
2623{0x8326, 0x000f}, {0x8327, 0x0096}, {0x8328, 0x0046},
2624{0x8329, 0x0084}, {0x832a, 0x000c}, {0x832b, 0x0081},
2625{0x832c, 0x0000}, {0x832d, 0x0027}, {0x832e, 0x000a},
2626{0x832f, 0x00c6}, {0x8330, 0x0049}, {0x8331, 0x00bd},
2627{0x8332, 0x00e4}, {0x8333, 0x0091}, {0x8334, 0x0025},
2628{0x8335, 0x0006}, {0x8336, 0x007e}, {0x8337, 0x0084},
2629{0x8338, 0x0025}, {0x8339, 0x007e}, {0x833a, 0x0084},
2630{0x833b, 0x0016}, {0x833c, 0x00b6}, {0x833d, 0x0018},
2631{0x833e, 0x0070}, {0x833f, 0x00bb}, {0x8340, 0x0019},
2632{0x8341, 0x0070}, {0x8342, 0x002a}, {0x8343, 0x0004},
2633{0x8344, 0x0081}, {0x8345, 0x00af}, {0x8346, 0x002e},
2634{0x8347, 0x0019}, {0x8348, 0x0096}, {0x8349, 0x007b},
2635{0x834a, 0x00f6}, {0x834b, 0x0020}, {0x834c, 0x0007},
2636{0x834d, 0x00fa}, {0x834e, 0x0020}, {0x834f, 0x0027},
2637{0x8350, 0x00c4}, {0x8351, 0x0038}, {0x8352, 0x0081},
2638{0x8353, 0x0038}, {0x8354, 0x0027}, {0x8355, 0x000b},
2639{0x8356, 0x00f6}, {0x8357, 0x0020}, {0x8358, 0x0007},
2640{0x8359, 0x00fa}, {0x835a, 0x0020}, {0x835b, 0x0027},
2641{0x835c, 0x00cb}, {0x835d, 0x0008}, {0x835e, 0x007e},
2642{0x835f, 0x0082}, {0x8360, 0x00d3}, {0x8361, 0x00bd},
2643{0x8362, 0x00f7}, {0x8363, 0x0066}, {0x8364, 0x0086},
2644{0x8365, 0x0074}, {0x8366, 0x00c6}, {0x8367, 0x0049},
2645{0x8368, 0x00bd}, {0x8369, 0x00e4}, {0x836a, 0x0012},
2646{0x836b, 0x00ce}, {0x836c, 0x0083}, {0x836d, 0x0071},
2647{0x836e, 0x00ff}, {0x836f, 0x0001}, {0x8370, 0x000f},
2648{0x8371, 0x0096}, {0x8372, 0x0046}, {0x8373, 0x0084},
2649{0x8374, 0x000c}, {0x8375, 0x0081}, {0x8376, 0x0008},
2650{0x8377, 0x0026}, {0x8378, 0x000a}, {0x8379, 0x00c6},
2651{0x837a, 0x0049}, {0x837b, 0x00bd}, {0x837c, 0x00e4},
2652{0x837d, 0x0091}, {0x837e, 0x0025}, {0x837f, 0x0006},
2653{0x8380, 0x007e}, {0x8381, 0x0084}, {0x8382, 0x0025},
2654{0x8383, 0x007e}, {0x8384, 0x0084}, {0x8385, 0x0016},
2655{0x8386, 0x00bd}, {0x8387, 0x00f7}, {0x8388, 0x003e},
2656{0x8389, 0x0026}, {0x838a, 0x000e}, {0x838b, 0x00bd},
2657{0x838c, 0x00e5}, {0x838d, 0x0009}, {0x838e, 0x0026},
2658{0x838f, 0x0006}, {0x8390, 0x00ce}, {0x8391, 0x0082},
2659{0x8392, 0x00c1}, {0x8393, 0x00ff}, {0x8394, 0x0001},
2660{0x8395, 0x000f}, {0x8396, 0x007e}, {0x8397, 0x0084},
2661{0x8398, 0x0025}, {0x8399, 0x00fe}, {0x839a, 0x008f},
2662{0x839b, 0x0054}, {0x839c, 0x00bd}, {0x839d, 0x00ec},
2663{0x839e, 0x008e}, {0x839f, 0x00bd}, {0x83a0, 0x00fa},
2664{0x83a1, 0x00f7}, {0x83a2, 0x00bd}, {0x83a3, 0x00f7},
2665{0x83a4, 0x0033}, {0x83a5, 0x0086}, {0x83a6, 0x000f},
2666{0x83a7, 0x00c6}, {0x83a8, 0x0051}, {0x83a9, 0x00bd},
2667{0x83aa, 0x00e4}, {0x83ab, 0x0012}, {0x83ac, 0x00ce},
2668{0x83ad, 0x0083}, {0x83ae, 0x00b2}, {0x83af, 0x00ff},
2669{0x83b0, 0x0001}, {0x83b1, 0x000f}, {0x83b2, 0x0096},
2670{0x83b3, 0x0046}, {0x83b4, 0x0084}, {0x83b5, 0x000c},
2671{0x83b6, 0x0081}, {0x83b7, 0x0008}, {0x83b8, 0x0026},
2672{0x83b9, 0x005c}, {0x83ba, 0x00b6}, {0x83bb, 0x0012},
2673{0x83bc, 0x0020}, {0x83bd, 0x0084}, {0x83be, 0x003f},
2674{0x83bf, 0x0081}, {0x83c0, 0x003a}, {0x83c1, 0x0027},
2675{0x83c2, 0x001c}, {0x83c3, 0x0096}, {0x83c4, 0x0023},
2676{0x83c5, 0x0085}, {0x83c6, 0x0040}, {0x83c7, 0x0027},
2677{0x83c8, 0x0003}, {0x83c9, 0x007e}, {0x83ca, 0x0084},
2678{0x83cb, 0x0025}, {0x83cc, 0x00c6}, {0x83cd, 0x0051},
2679{0x83ce, 0x00bd}, {0x83cf, 0x00e4}, {0x83d0, 0x0091},
2680{0x83d1, 0x0025}, {0x83d2, 0x0003}, {0x83d3, 0x007e},
2681{0x83d4, 0x0084}, {0x83d5, 0x0025}, {0x83d6, 0x00ce},
2682{0x83d7, 0x0082}, {0x83d8, 0x00c1}, {0x83d9, 0x00ff},
2683{0x83da, 0x0001}, {0x83db, 0x000f}, {0x83dc, 0x007e},
2684{0x83dd, 0x0084}, {0x83de, 0x0025}, {0x83df, 0x00bd},
2685{0x83e0, 0x00f8}, {0x83e1, 0x0037}, {0x83e2, 0x007c},
2686{0x83e3, 0x0000}, {0x83e4, 0x007a}, {0x83e5, 0x00ce},
2687{0x83e6, 0x0083}, {0x83e7, 0x00ee}, {0x83e8, 0x00ff},
2688{0x83e9, 0x0001}, {0x83ea, 0x000f}, {0x83eb, 0x007e},
2689{0x83ec, 0x0084}, {0x83ed, 0x0025}, {0x83ee, 0x0096},
2690{0x83ef, 0x0046}, {0x83f0, 0x0084}, {0x83f1, 0x000c},
2691{0x83f2, 0x0081}, {0x83f3, 0x0008}, {0x83f4, 0x0026},
2692{0x83f5, 0x0020}, {0x83f6, 0x0096}, {0x83f7, 0x0024},
2693{0x83f8, 0x0084}, {0x83f9, 0x0008}, {0x83fa, 0x0026},
2694{0x83fb, 0x0029}, {0x83fc, 0x00b6}, {0x83fd, 0x0018},
2695{0x83fe, 0x0082}, {0x83ff, 0x00bb}, {0x8400, 0x0019},
2696{0x8401, 0x0082}, {0x8402, 0x00b1}, {0x8403, 0x0001},
2697{0x8404, 0x003b}, {0x8405, 0x0022}, {0x8406, 0x0009},
2698{0x8407, 0x00b6}, {0x8408, 0x0012}, {0x8409, 0x0020},
2699{0x840a, 0x0084}, {0x840b, 0x0037}, {0x840c, 0x0081},
2700{0x840d, 0x0032}, {0x840e, 0x0027}, {0x840f, 0x0015},
2701{0x8410, 0x00bd}, {0x8411, 0x00f8}, {0x8412, 0x0044},
2702{0x8413, 0x007e}, {0x8414, 0x0082}, {0x8415, 0x00c1},
2703{0x8416, 0x00bd}, {0x8417, 0x00f7}, {0x8418, 0x001f},
2704{0x8419, 0x00bd}, {0x841a, 0x00f8}, {0x841b, 0x0044},
2705{0x841c, 0x00bd}, {0x841d, 0x00fc}, {0x841e, 0x0029},
2706{0x841f, 0x00ce}, {0x8420, 0x0082}, {0x8421, 0x0025},
2707{0x8422, 0x00ff}, {0x8423, 0x0001}, {0x8424, 0x000f},
2708{0x8425, 0x0039}, {0x8426, 0x0096}, {0x8427, 0x0047},
2709{0x8428, 0x0084}, {0x8429, 0x00fc}, {0x842a, 0x008a},
2710{0x842b, 0x0000}, {0x842c, 0x0097}, {0x842d, 0x0047},
2711{0x842e, 0x00ce}, {0x842f, 0x0084}, {0x8430, 0x0034},
2712{0x8431, 0x00ff}, {0x8432, 0x0001}, {0x8433, 0x0011},
2713{0x8434, 0x0096}, {0x8435, 0x0046}, {0x8436, 0x0084},
2714{0x8437, 0x0003}, {0x8438, 0x0081}, {0x8439, 0x0002},
2715{0x843a, 0x0027}, {0x843b, 0x0003}, {0x843c, 0x007e},
2716{0x843d, 0x0085}, {0x843e, 0x001e}, {0x843f, 0x0096},
2717{0x8440, 0x0047}, {0x8441, 0x0084}, {0x8442, 0x00fc},
2718{0x8443, 0x008a}, {0x8444, 0x0002}, {0x8445, 0x0097},
2719{0x8446, 0x0047}, {0x8447, 0x00de}, {0x8448, 0x00e1},
2720{0x8449, 0x00ad}, {0x844a, 0x0000}, {0x844b, 0x0086},
2721{0x844c, 0x0001}, {0x844d, 0x00b7}, {0x844e, 0x0012},
2722{0x844f, 0x0051}, {0x8450, 0x00bd}, {0x8451, 0x00f7},
2723{0x8452, 0x0014}, {0x8453, 0x00b6}, {0x8454, 0x0010},
2724{0x8455, 0x0031}, {0x8456, 0x0084}, {0x8457, 0x00fd},
2725{0x8458, 0x00b7}, {0x8459, 0x0010}, {0x845a, 0x0031},
2726{0x845b, 0x00bd}, {0x845c, 0x00f8}, {0x845d, 0x001e},
2727{0x845e, 0x0096}, {0x845f, 0x0081}, {0x8460, 0x00d6},
2728{0x8461, 0x0082}, {0x8462, 0x00fe}, {0x8463, 0x008f},
2729{0x8464, 0x005a}, {0x8465, 0x00bd}, {0x8466, 0x00f7},
2730{0x8467, 0x00b6}, {0x8468, 0x00fe}, {0x8469, 0x008f},
2731{0x846a, 0x005c}, {0x846b, 0x00bd}, {0x846c, 0x00ec},
2732{0x846d, 0x008e}, {0x846e, 0x00bd}, {0x846f, 0x00fa},
2733{0x8470, 0x00f7}, {0x8471, 0x0086}, {0x8472, 0x0008},
2734{0x8473, 0x00d6}, {0x8474, 0x0000}, {0x8475, 0x00c5},
2735{0x8476, 0x0010}, {0x8477, 0x0026}, {0x8478, 0x0002},
2736{0x8479, 0x008b}, {0x847a, 0x0020}, {0x847b, 0x00c6},
2737{0x847c, 0x0051}, {0x847d, 0x00bd}, {0x847e, 0x00e4},
2738{0x847f, 0x0012}, {0x8480, 0x00ce}, {0x8481, 0x0084},
2739{0x8482, 0x0086}, {0x8483, 0x00ff}, {0x8484, 0x0001},
2740{0x8485, 0x0011}, {0x8486, 0x0096}, {0x8487, 0x0046},
2741{0x8488, 0x0084}, {0x8489, 0x0003}, {0x848a, 0x0081},
2742{0x848b, 0x0002}, {0x848c, 0x0027}, {0x848d, 0x0003},
2743{0x848e, 0x007e}, {0x848f, 0x0085}, {0x8490, 0x000f},
2744{0x8491, 0x00c6}, {0x8492, 0x0051}, {0x8493, 0x00bd},
2745{0x8494, 0x00e4}, {0x8495, 0x0091}, {0x8496, 0x0025},
2746{0x8497, 0x0003}, {0x8498, 0x007e}, {0x8499, 0x0085},
2747{0x849a, 0x001e}, {0x849b, 0x0096}, {0x849c, 0x0044},
2748{0x849d, 0x0085}, {0x849e, 0x0010}, {0x849f, 0x0026},
2749{0x84a0, 0x000a}, {0x84a1, 0x00b6}, {0x84a2, 0x0012},
2750{0x84a3, 0x0050}, {0x84a4, 0x00ba}, {0x84a5, 0x0001},
2751{0x84a6, 0x003c}, {0x84a7, 0x0085}, {0x84a8, 0x0010},
2752{0x84a9, 0x0027}, {0x84aa, 0x00a8}, {0x84ab, 0x00bd},
2753{0x84ac, 0x00f7}, {0x84ad, 0x0066}, {0x84ae, 0x00ce},
2754{0x84af, 0x0084}, {0x84b0, 0x00b7}, {0x84b1, 0x00ff},
2755{0x84b2, 0x0001}, {0x84b3, 0x0011}, {0x84b4, 0x007e},
2756{0x84b5, 0x0085}, {0x84b6, 0x001e}, {0x84b7, 0x0096},
2757{0x84b8, 0x0046}, {0x84b9, 0x0084}, {0x84ba, 0x0003},
2758{0x84bb, 0x0081}, {0x84bc, 0x0002}, {0x84bd, 0x0026},
2759{0x84be, 0x0050}, {0x84bf, 0x00b6}, {0x84c0, 0x0012},
2760{0x84c1, 0x0030}, {0x84c2, 0x0084}, {0x84c3, 0x0003},
2761{0x84c4, 0x0081}, {0x84c5, 0x0001}, {0x84c6, 0x0027},
2762{0x84c7, 0x0003}, {0x84c8, 0x007e}, {0x84c9, 0x0085},
2763{0x84ca, 0x001e}, {0x84cb, 0x0096}, {0x84cc, 0x0044},
2764{0x84cd, 0x0085}, {0x84ce, 0x0010}, {0x84cf, 0x0026},
2765{0x84d0, 0x0013}, {0x84d1, 0x00b6}, {0x84d2, 0x0012},
2766{0x84d3, 0x0050}, {0x84d4, 0x00ba}, {0x84d5, 0x0001},
2767{0x84d6, 0x003c}, {0x84d7, 0x0085}, {0x84d8, 0x0010},
2768{0x84d9, 0x0026}, {0x84da, 0x0009}, {0x84db, 0x00ce},
2769{0x84dc, 0x0084}, {0x84dd, 0x0053}, {0x84de, 0x00ff},
2770{0x84df, 0x0001}, {0x84e0, 0x0011}, {0x84e1, 0x007e},
2771{0x84e2, 0x0085}, {0x84e3, 0x001e}, {0x84e4, 0x00b6},
2772{0x84e5, 0x0010}, {0x84e6, 0x0031}, {0x84e7, 0x008a},
2773{0x84e8, 0x0002}, {0x84e9, 0x00b7}, {0x84ea, 0x0010},
2774{0x84eb, 0x0031}, {0x84ec, 0x00bd}, {0x84ed, 0x0085},
2775{0x84ee, 0x001f}, {0x84ef, 0x00bd}, {0x84f0, 0x00f8},
2776{0x84f1, 0x0037}, {0x84f2, 0x007c}, {0x84f3, 0x0000},
2777{0x84f4, 0x0080}, {0x84f5, 0x00ce}, {0x84f6, 0x0084},
2778{0x84f7, 0x00fe}, {0x84f8, 0x00ff}, {0x84f9, 0x0001},
2779{0x84fa, 0x0011}, {0x84fb, 0x007e}, {0x84fc, 0x0085},
2780{0x84fd, 0x001e}, {0x84fe, 0x0096}, {0x84ff, 0x0046},
2781{0x8500, 0x0084}, {0x8501, 0x0003}, {0x8502, 0x0081},
2782{0x8503, 0x0002}, {0x8504, 0x0026}, {0x8505, 0x0009},
2783{0x8506, 0x00b6}, {0x8507, 0x0012}, {0x8508, 0x0030},
2784{0x8509, 0x0084}, {0x850a, 0x0003}, {0x850b, 0x0081},
2785{0x850c, 0x0001}, {0x850d, 0x0027}, {0x850e, 0x000f},
2786{0x850f, 0x00bd}, {0x8510, 0x00f8}, {0x8511, 0x0044},
2787{0x8512, 0x00bd}, {0x8513, 0x00f7}, {0x8514, 0x000b},
2788{0x8515, 0x00bd}, {0x8516, 0x00fc}, {0x8517, 0x0029},
2789{0x8518, 0x00ce}, {0x8519, 0x0084}, {0x851a, 0x0026},
2790{0x851b, 0x00ff}, {0x851c, 0x0001}, {0x851d, 0x0011},
2791{0x851e, 0x0039}, {0x851f, 0x00d6}, {0x8520, 0x0022},
2792{0x8521, 0x00c4}, {0x8522, 0x000f}, {0x8523, 0x00b6},
2793{0x8524, 0x0012}, {0x8525, 0x0030}, {0x8526, 0x00ba},
2794{0x8527, 0x0012}, {0x8528, 0x0032}, {0x8529, 0x0084},
2795{0x852a, 0x0004}, {0x852b, 0x0027}, {0x852c, 0x000d},
2796{0x852d, 0x0096}, {0x852e, 0x0022}, {0x852f, 0x0085},
2797{0x8530, 0x0004}, {0x8531, 0x0027}, {0x8532, 0x0005},
2798{0x8533, 0x00ca}, {0x8534, 0x0010}, {0x8535, 0x007e},
2799{0x8536, 0x0085}, {0x8537, 0x003a}, {0x8538, 0x00ca},
2800{0x8539, 0x0020}, {0x853a, 0x00d7}, {0x853b, 0x0022},
2801{0x853c, 0x0039}, {0x853d, 0x0086}, {0x853e, 0x0000},
2802{0x853f, 0x0097}, {0x8540, 0x0083}, {0x8541, 0x0018},
2803{0x8542, 0x00ce}, {0x8543, 0x001c}, {0x8544, 0x0000},
2804{0x8545, 0x00bd}, {0x8546, 0x00eb}, {0x8547, 0x0046},
2805{0x8548, 0x0096}, {0x8549, 0x0057}, {0x854a, 0x0085},
2806{0x854b, 0x0001}, {0x854c, 0x0027}, {0x854d, 0x0002},
2807{0x854e, 0x004f}, {0x854f, 0x0039}, {0x8550, 0x0085},
2808{0x8551, 0x0002}, {0x8552, 0x0027}, {0x8553, 0x0001},
2809{0x8554, 0x0039}, {0x8555, 0x007f}, {0x8556, 0x008f},
2810{0x8557, 0x007d}, {0x8558, 0x0086}, {0x8559, 0x0004},
2811{0x855a, 0x00b7}, {0x855b, 0x0012}, {0x855c, 0x0004},
2812{0x855d, 0x0086}, {0x855e, 0x0008}, {0x855f, 0x00b7},
2813{0x8560, 0x0012}, {0x8561, 0x0007}, {0x8562, 0x0086},
2814{0x8563, 0x0010}, {0x8564, 0x00b7}, {0x8565, 0x0012},
2815{0x8566, 0x000c}, {0x8567, 0x0086}, {0x8568, 0x0007},
2816{0x8569, 0x00b7}, {0x856a, 0x0012}, {0x856b, 0x0006},
2817{0x856c, 0x00b6}, {0x856d, 0x008f}, {0x856e, 0x007d},
2818{0x856f, 0x00b7}, {0x8570, 0x0012}, {0x8571, 0x0070},
2819{0x8572, 0x0086}, {0x8573, 0x0001}, {0x8574, 0x00ba},
2820{0x8575, 0x0012}, {0x8576, 0x0004}, {0x8577, 0x00b7},
2821{0x8578, 0x0012}, {0x8579, 0x0004}, {0x857a, 0x0001},
2822{0x857b, 0x0001}, {0x857c, 0x0001}, {0x857d, 0x0001},
2823{0x857e, 0x0001}, {0x857f, 0x0001}, {0x8580, 0x00b6},
2824{0x8581, 0x0012}, {0x8582, 0x0004}, {0x8583, 0x0084},
2825{0x8584, 0x00fe}, {0x8585, 0x008a}, {0x8586, 0x0002},
2826{0x8587, 0x00b7}, {0x8588, 0x0012}, {0x8589, 0x0004},
2827{0x858a, 0x0001}, {0x858b, 0x0001}, {0x858c, 0x0001},
2828{0x858d, 0x0001}, {0x858e, 0x0001}, {0x858f, 0x0001},
2829{0x8590, 0x0086}, {0x8591, 0x00fd}, {0x8592, 0x00b4},
2830{0x8593, 0x0012}, {0x8594, 0x0004}, {0x8595, 0x00b7},
2831{0x8596, 0x0012}, {0x8597, 0x0004}, {0x8598, 0x00b6},
2832{0x8599, 0x0012}, {0x859a, 0x0000}, {0x859b, 0x0084},
2833{0x859c, 0x0008}, {0x859d, 0x0081}, {0x859e, 0x0008},
2834{0x859f, 0x0027}, {0x85a0, 0x0016}, {0x85a1, 0x00b6},
2835{0x85a2, 0x008f}, {0x85a3, 0x007d}, {0x85a4, 0x0081},
2836{0x85a5, 0x000c}, {0x85a6, 0x0027}, {0x85a7, 0x0008},
2837{0x85a8, 0x008b}, {0x85a9, 0x0004}, {0x85aa, 0x00b7},
2838{0x85ab, 0x008f}, {0x85ac, 0x007d}, {0x85ad, 0x007e},
2839{0x85ae, 0x0085}, {0x85af, 0x006c}, {0x85b0, 0x0086},
2840{0x85b1, 0x0003}, {0x85b2, 0x0097}, {0x85b3, 0x0040},
2841{0x85b4, 0x007e}, {0x85b5, 0x0089}, {0x85b6, 0x006e},
2842{0x85b7, 0x0086}, {0x85b8, 0x0007}, {0x85b9, 0x00b7},
2843{0x85ba, 0x0012}, {0x85bb, 0x0006}, {0x85bc, 0x005f},
2844{0x85bd, 0x00f7}, {0x85be, 0x008f}, {0x85bf, 0x0082},
2845{0x85c0, 0x005f}, {0x85c1, 0x00f7}, {0x85c2, 0x008f},
2846{0x85c3, 0x007f}, {0x85c4, 0x00f7}, {0x85c5, 0x008f},
2847{0x85c6, 0x0070}, {0x85c7, 0x00f7}, {0x85c8, 0x008f},
2848{0x85c9, 0x0071}, {0x85ca, 0x00f7}, {0x85cb, 0x008f},
2849{0x85cc, 0x0072}, {0x85cd, 0x00f7}, {0x85ce, 0x008f},
2850{0x85cf, 0x0073}, {0x85d0, 0x00f7}, {0x85d1, 0x008f},
2851{0x85d2, 0x0074}, {0x85d3, 0x00f7}, {0x85d4, 0x008f},
2852{0x85d5, 0x0075}, {0x85d6, 0x00f7}, {0x85d7, 0x008f},
2853{0x85d8, 0x0076}, {0x85d9, 0x00f7}, {0x85da, 0x008f},
2854{0x85db, 0x0077}, {0x85dc, 0x00f7}, {0x85dd, 0x008f},
2855{0x85de, 0x0078}, {0x85df, 0x00f7}, {0x85e0, 0x008f},
2856{0x85e1, 0x0079}, {0x85e2, 0x00f7}, {0x85e3, 0x008f},
2857{0x85e4, 0x007a}, {0x85e5, 0x00f7}, {0x85e6, 0x008f},
2858{0x85e7, 0x007b}, {0x85e8, 0x00b6}, {0x85e9, 0x0012},
2859{0x85ea, 0x0004}, {0x85eb, 0x008a}, {0x85ec, 0x0010},
2860{0x85ed, 0x00b7}, {0x85ee, 0x0012}, {0x85ef, 0x0004},
2861{0x85f0, 0x0086}, {0x85f1, 0x00e4}, {0x85f2, 0x00b7},
2862{0x85f3, 0x0012}, {0x85f4, 0x0070}, {0x85f5, 0x00b7},
2863{0x85f6, 0x0012}, {0x85f7, 0x0007}, {0x85f8, 0x00f7},
2864{0x85f9, 0x0012}, {0x85fa, 0x0005}, {0x85fb, 0x00f7},
2865{0x85fc, 0x0012}, {0x85fd, 0x0009}, {0x85fe, 0x0086},
2866{0x85ff, 0x0008}, {0x8600, 0x00ba}, {0x8601, 0x0012},
2867{0x8602, 0x0004}, {0x8603, 0x00b7}, {0x8604, 0x0012},
2868{0x8605, 0x0004}, {0x8606, 0x0086}, {0x8607, 0x00f7},
2869{0x8608, 0x00b4}, {0x8609, 0x0012}, {0x860a, 0x0004},
2870{0x860b, 0x00b7}, {0x860c, 0x0012}, {0x860d, 0x0004},
2871{0x860e, 0x0001}, {0x860f, 0x0001}, {0x8610, 0x0001},
2872{0x8611, 0x0001}, {0x8612, 0x0001}, {0x8613, 0x0001},
2873{0x8614, 0x00b6}, {0x8615, 0x0012}, {0x8616, 0x0008},
2874{0x8617, 0x0027}, {0x8618, 0x007f}, {0x8619, 0x0081},
2875{0x861a, 0x0080}, {0x861b, 0x0026}, {0x861c, 0x000b},
2876{0x861d, 0x0086}, {0x861e, 0x0008}, {0x861f, 0x00ce},
2877{0x8620, 0x008f}, {0x8621, 0x0079}, {0x8622, 0x00bd},
2878{0x8623, 0x0089}, {0x8624, 0x007b}, {0x8625, 0x007e},
2879{0x8626, 0x0086}, {0x8627, 0x008e}, {0x8628, 0x0081},
2880{0x8629, 0x0040}, {0x862a, 0x0026}, {0x862b, 0x000b},
2881{0x862c, 0x0086}, {0x862d, 0x0004}, {0x862e, 0x00ce},
2882{0x862f, 0x008f}, {0x8630, 0x0076}, {0x8631, 0x00bd},
2883{0x8632, 0x0089}, {0x8633, 0x007b}, {0x8634, 0x007e},
2884{0x8635, 0x0086}, {0x8636, 0x008e}, {0x8637, 0x0081},
2885{0x8638, 0x0020}, {0x8639, 0x0026}, {0x863a, 0x000b},
2886{0x863b, 0x0086}, {0x863c, 0x0002}, {0x863d, 0x00ce},
2887{0x863e, 0x008f}, {0x863f, 0x0073}, {0x8640, 0x00bd},
2888{0x8641, 0x0089}, {0x8642, 0x007b}, {0x8643, 0x007e},
2889{0x8644, 0x0086}, {0x8645, 0x008e}, {0x8646, 0x0081},
2890{0x8647, 0x0010}, {0x8648, 0x0026}, {0x8649, 0x000b},
2891{0x864a, 0x0086}, {0x864b, 0x0001}, {0x864c, 0x00ce},
2892{0x864d, 0x008f}, {0x864e, 0x0070}, {0x864f, 0x00bd},
2893{0x8650, 0x0089}, {0x8651, 0x007b}, {0x8652, 0x007e},
2894{0x8653, 0x0086}, {0x8654, 0x008e}, {0x8655, 0x0081},
2895{0x8656, 0x0008}, {0x8657, 0x0026}, {0x8658, 0x000b},
2896{0x8659, 0x0086}, {0x865a, 0x0008}, {0x865b, 0x00ce},
2897{0x865c, 0x008f}, {0x865d, 0x0079}, {0x865e, 0x00bd},
2898{0x865f, 0x0089}, {0x8660, 0x007f}, {0x8661, 0x007e},
2899{0x8662, 0x0086}, {0x8663, 0x008e}, {0x8664, 0x0081},
2900{0x8665, 0x0004}, {0x8666, 0x0026}, {0x8667, 0x000b},
2901{0x8668, 0x0086}, {0x8669, 0x0004}, {0x866a, 0x00ce},
2902{0x866b, 0x008f}, {0x866c, 0x0076}, {0x866d, 0x00bd},
2903{0x866e, 0x0089}, {0x866f, 0x007f}, {0x8670, 0x007e},
2904{0x8671, 0x0086}, {0x8672, 0x008e}, {0x8673, 0x0081},
2905{0x8674, 0x0002}, {0x8675, 0x0026}, {0x8676, 0x000b},
2906{0x8677, 0x008a}, {0x8678, 0x0002}, {0x8679, 0x00ce},
2907{0x867a, 0x008f}, {0x867b, 0x0073}, {0x867c, 0x00bd},
2908{0x867d, 0x0089}, {0x867e, 0x007f}, {0x867f, 0x007e},
2909{0x8680, 0x0086}, {0x8681, 0x008e}, {0x8682, 0x0081},
2910{0x8683, 0x0001}, {0x8684, 0x0026}, {0x8685, 0x0008},
2911{0x8686, 0x0086}, {0x8687, 0x0001}, {0x8688, 0x00ce},
2912{0x8689, 0x008f}, {0x868a, 0x0070}, {0x868b, 0x00bd},
2913{0x868c, 0x0089}, {0x868d, 0x007f}, {0x868e, 0x00b6},
2914{0x868f, 0x008f}, {0x8690, 0x007f}, {0x8691, 0x0081},
2915{0x8692, 0x000f}, {0x8693, 0x0026}, {0x8694, 0x0003},
2916{0x8695, 0x007e}, {0x8696, 0x0087}, {0x8697, 0x0047},
2917{0x8698, 0x00b6}, {0x8699, 0x0012}, {0x869a, 0x0009},
2918{0x869b, 0x0084}, {0x869c, 0x0003}, {0x869d, 0x0081},
2919{0x869e, 0x0003}, {0x869f, 0x0027}, {0x86a0, 0x0006},
2920{0x86a1, 0x007c}, {0x86a2, 0x0012}, {0x86a3, 0x0009},
2921{0x86a4, 0x007e}, {0x86a5, 0x0085}, {0x86a6, 0x00fe},
2922{0x86a7, 0x00b6}, {0x86a8, 0x0012}, {0x86a9, 0x0006},
2923{0x86aa, 0x0084}, {0x86ab, 0x0007}, {0x86ac, 0x0081},
2924{0x86ad, 0x0007}, {0x86ae, 0x0027}, {0x86af, 0x0008},
2925{0x86b0, 0x008b}, {0x86b1, 0x0001}, {0x86b2, 0x00b7},
2926{0x86b3, 0x0012}, {0x86b4, 0x0006}, {0x86b5, 0x007e},
2927{0x86b6, 0x0086}, {0x86b7, 0x00d5}, {0x86b8, 0x00b6},
2928{0x86b9, 0x008f}, {0x86ba, 0x0082}, {0x86bb, 0x0026},
2929{0x86bc, 0x000a}, {0x86bd, 0x007c}, {0x86be, 0x008f},
2930{0x86bf, 0x0082}, {0x86c0, 0x004f}, {0x86c1, 0x00b7},
2931{0x86c2, 0x0012}, {0x86c3, 0x0006}, {0x86c4, 0x007e},
2932{0x86c5, 0x0085}, {0x86c6, 0x00c0}, {0x86c7, 0x00b6},
2933{0x86c8, 0x0012}, {0x86c9, 0x0006}, {0x86ca, 0x0084},
2934{0x86cb, 0x003f}, {0x86cc, 0x0081}, {0x86cd, 0x003f},
2935{0x86ce, 0x0027}, {0x86cf, 0x0010}, {0x86d0, 0x008b},
2936{0x86d1, 0x0008}, {0x86d2, 0x00b7}, {0x86d3, 0x0012},
2937{0x86d4, 0x0006}, {0x86d5, 0x00b6}, {0x86d6, 0x0012},
2938{0x86d7, 0x0009}, {0x86d8, 0x0084}, {0x86d9, 0x00fc},
2939{0x86da, 0x00b7}, {0x86db, 0x0012}, {0x86dc, 0x0009},
2940{0x86dd, 0x007e}, {0x86de, 0x0085}, {0x86df, 0x00fe},
2941{0x86e0, 0x00ce}, {0x86e1, 0x008f}, {0x86e2, 0x0070},
2942{0x86e3, 0x0018}, {0x86e4, 0x00ce}, {0x86e5, 0x008f},
2943{0x86e6, 0x0084}, {0x86e7, 0x00c6}, {0x86e8, 0x000c},
2944{0x86e9, 0x00bd}, {0x86ea, 0x0089}, {0x86eb, 0x006f},
2945{0x86ec, 0x00ce}, {0x86ed, 0x008f}, {0x86ee, 0x0084},
2946{0x86ef, 0x0018}, {0x86f0, 0x00ce}, {0x86f1, 0x008f},
2947{0x86f2, 0x0070}, {0x86f3, 0x00c6}, {0x86f4, 0x000c},
2948{0x86f5, 0x00bd}, {0x86f6, 0x0089}, {0x86f7, 0x006f},
2949{0x86f8, 0x00d6}, {0x86f9, 0x0083}, {0x86fa, 0x00c1},
2950{0x86fb, 0x004f}, {0x86fc, 0x002d}, {0x86fd, 0x0003},
2951{0x86fe, 0x007e}, {0x86ff, 0x0087}, {0x8700, 0x0040},
2952{0x8701, 0x00b6}, {0x8702, 0x008f}, {0x8703, 0x007f},
2953{0x8704, 0x0081}, {0x8705, 0x0007}, {0x8706, 0x0027},
2954{0x8707, 0x000f}, {0x8708, 0x0081}, {0x8709, 0x000b},
2955{0x870a, 0x0027}, {0x870b, 0x0015}, {0x870c, 0x0081},
2956{0x870d, 0x000d}, {0x870e, 0x0027}, {0x870f, 0x001b},
2957{0x8710, 0x0081}, {0x8711, 0x000e}, {0x8712, 0x0027},
2958{0x8713, 0x0021}, {0x8714, 0x007e}, {0x8715, 0x0087},
2959{0x8716, 0x0040}, {0x8717, 0x00f7}, {0x8718, 0x008f},
2960{0x8719, 0x007b}, {0x871a, 0x0086}, {0x871b, 0x0002},
2961{0x871c, 0x00b7}, {0x871d, 0x008f}, {0x871e, 0x007a},
2962{0x871f, 0x0020}, {0x8720, 0x001c}, {0x8721, 0x00f7},
2963{0x8722, 0x008f}, {0x8723, 0x0078}, {0x8724, 0x0086},
2964{0x8725, 0x0002}, {0x8726, 0x00b7}, {0x8727, 0x008f},
2965{0x8728, 0x0077}, {0x8729, 0x0020}, {0x872a, 0x0012},
2966{0x872b, 0x00f7}, {0x872c, 0x008f}, {0x872d, 0x0075},
2967{0x872e, 0x0086}, {0x872f, 0x0002}, {0x8730, 0x00b7},
2968{0x8731, 0x008f}, {0x8732, 0x0074}, {0x8733, 0x0020},
2969{0x8734, 0x0008}, {0x8735, 0x00f7}, {0x8736, 0x008f},
2970{0x8737, 0x0072}, {0x8738, 0x0086}, {0x8739, 0x0002},
2971{0x873a, 0x00b7}, {0x873b, 0x008f}, {0x873c, 0x0071},
2972{0x873d, 0x007e}, {0x873e, 0x0087}, {0x873f, 0x0047},
2973{0x8740, 0x0086}, {0x8741, 0x0004}, {0x8742, 0x0097},
2974{0x8743, 0x0040}, {0x8744, 0x007e}, {0x8745, 0x0089},
2975{0x8746, 0x006e}, {0x8747, 0x00ce}, {0x8748, 0x008f},
2976{0x8749, 0x0072}, {0x874a, 0x00bd}, {0x874b, 0x0089},
2977{0x874c, 0x00f7}, {0x874d, 0x00ce}, {0x874e, 0x008f},
2978{0x874f, 0x0075}, {0x8750, 0x00bd}, {0x8751, 0x0089},
2979{0x8752, 0x00f7}, {0x8753, 0x00ce}, {0x8754, 0x008f},
2980{0x8755, 0x0078}, {0x8756, 0x00bd}, {0x8757, 0x0089},
2981{0x8758, 0x00f7}, {0x8759, 0x00ce}, {0x875a, 0x008f},
2982{0x875b, 0x007b}, {0x875c, 0x00bd}, {0x875d, 0x0089},
2983{0x875e, 0x00f7}, {0x875f, 0x004f}, {0x8760, 0x00b7},
2984{0x8761, 0x008f}, {0x8762, 0x007d}, {0x8763, 0x00b7},
2985{0x8764, 0x008f}, {0x8765, 0x0081}, {0x8766, 0x00b6},
2986{0x8767, 0x008f}, {0x8768, 0x0072}, {0x8769, 0x0027},
2987{0x876a, 0x0047}, {0x876b, 0x007c}, {0x876c, 0x008f},
2988{0x876d, 0x007d}, {0x876e, 0x00b6}, {0x876f, 0x008f},
2989{0x8770, 0x0075}, {0x8771, 0x0027}, {0x8772, 0x003f},
2990{0x8773, 0x007c}, {0x8774, 0x008f}, {0x8775, 0x007d},
2991{0x8776, 0x00b6}, {0x8777, 0x008f}, {0x8778, 0x0078},
2992{0x8779, 0x0027}, {0x877a, 0x0037}, {0x877b, 0x007c},
2993{0x877c, 0x008f}, {0x877d, 0x007d}, {0x877e, 0x00b6},
2994{0x877f, 0x008f}, {0x8780, 0x007b}, {0x8781, 0x0027},
2995{0x8782, 0x002f}, {0x8783, 0x007f}, {0x8784, 0x008f},
2996{0x8785, 0x007d}, {0x8786, 0x007c}, {0x8787, 0x008f},
2997{0x8788, 0x0081}, {0x8789, 0x007a}, {0x878a, 0x008f},
2998{0x878b, 0x0072}, {0x878c, 0x0027}, {0x878d, 0x001b},
2999{0x878e, 0x007c}, {0x878f, 0x008f}, {0x8790, 0x007d},
3000{0x8791, 0x007a}, {0x8792, 0x008f}, {0x8793, 0x0075},
3001{0x8794, 0x0027}, {0x8795, 0x0016}, {0x8796, 0x007c},
3002{0x8797, 0x008f}, {0x8798, 0x007d}, {0x8799, 0x007a},
3003{0x879a, 0x008f}, {0x879b, 0x0078}, {0x879c, 0x0027},
3004{0x879d, 0x0011}, {0x879e, 0x007c}, {0x879f, 0x008f},
3005{0x87a0, 0x007d}, {0x87a1, 0x007a}, {0x87a2, 0x008f},
3006{0x87a3, 0x007b}, {0x87a4, 0x0027}, {0x87a5, 0x000c},
3007{0x87a6, 0x007e}, {0x87a7, 0x0087}, {0x87a8, 0x0083},
3008{0x87a9, 0x007a}, {0x87aa, 0x008f}, {0x87ab, 0x0075},
3009{0x87ac, 0x007a}, {0x87ad, 0x008f}, {0x87ae, 0x0078},
3010{0x87af, 0x007a}, {0x87b0, 0x008f}, {0x87b1, 0x007b},
3011{0x87b2, 0x00ce}, {0x87b3, 0x00c1}, {0x87b4, 0x00fc},
3012{0x87b5, 0x00f6}, {0x87b6, 0x008f}, {0x87b7, 0x007d},
3013{0x87b8, 0x003a}, {0x87b9, 0x00a6}, {0x87ba, 0x0000},
3014{0x87bb, 0x00b7}, {0x87bc, 0x0012}, {0x87bd, 0x0070},
3015{0x87be, 0x00b6}, {0x87bf, 0x008f}, {0x87c0, 0x0072},
3016{0x87c1, 0x0026}, {0x87c2, 0x0003}, {0x87c3, 0x007e},
3017{0x87c4, 0x0087}, {0x87c5, 0x00fa}, {0x87c6, 0x00b6},
3018{0x87c7, 0x008f}, {0x87c8, 0x0075}, {0x87c9, 0x0026},
3019{0x87ca, 0x000a}, {0x87cb, 0x0018}, {0x87cc, 0x00ce},
3020{0x87cd, 0x008f}, {0x87ce, 0x0073}, {0x87cf, 0x00bd},
3021{0x87d0, 0x0089}, {0x87d1, 0x00d5}, {0x87d2, 0x007e},
3022{0x87d3, 0x0087}, {0x87d4, 0x00fa}, {0x87d5, 0x00b6},
3023{0x87d6, 0x008f}, {0x87d7, 0x0078}, {0x87d8, 0x0026},
3024{0x87d9, 0x000a}, {0x87da, 0x0018}, {0x87db, 0x00ce},
3025{0x87dc, 0x008f}, {0x87dd, 0x0076}, {0x87de, 0x00bd},
3026{0x87df, 0x0089}, {0x87e0, 0x00d5}, {0x87e1, 0x007e},
3027{0x87e2, 0x0087}, {0x87e3, 0x00fa}, {0x87e4, 0x00b6},
3028{0x87e5, 0x008f}, {0x87e6, 0x007b}, {0x87e7, 0x0026},
3029{0x87e8, 0x000a}, {0x87e9, 0x0018}, {0x87ea, 0x00ce},
3030{0x87eb, 0x008f}, {0x87ec, 0x0079}, {0x87ed, 0x00bd},
3031{0x87ee, 0x0089}, {0x87ef, 0x00d5}, {0x87f0, 0x007e},
3032{0x87f1, 0x0087}, {0x87f2, 0x00fa}, {0x87f3, 0x0086},
3033{0x87f4, 0x0005}, {0x87f5, 0x0097}, {0x87f6, 0x0040},
3034{0x87f7, 0x007e}, {0x87f8, 0x0089}, {0x87f9, 0x0000},
3035{0x87fa, 0x00b6}, {0x87fb, 0x008f}, {0x87fc, 0x0075},
3036{0x87fd, 0x0081}, {0x87fe, 0x0007}, {0x87ff, 0x002e},
3037{0x8800, 0x00f2}, {0x8801, 0x00f6}, {0x8802, 0x0012},
3038{0x8803, 0x0006}, {0x8804, 0x00c4}, {0x8805, 0x00f8},
3039{0x8806, 0x001b}, {0x8807, 0x00b7}, {0x8808, 0x0012},
3040{0x8809, 0x0006}, {0x880a, 0x00b6}, {0x880b, 0x008f},
3041{0x880c, 0x0078}, {0x880d, 0x0081}, {0x880e, 0x0007},
3042{0x880f, 0x002e}, {0x8810, 0x00e2}, {0x8811, 0x0048},
3043{0x8812, 0x0048}, {0x8813, 0x0048}, {0x8814, 0x00f6},
3044{0x8815, 0x0012}, {0x8816, 0x0006}, {0x8817, 0x00c4},
3045{0x8818, 0x00c7}, {0x8819, 0x001b}, {0x881a, 0x00b7},
3046{0x881b, 0x0012}, {0x881c, 0x0006}, {0x881d, 0x00b6},
3047{0x881e, 0x008f}, {0x881f, 0x007b}, {0x8820, 0x0081},
3048{0x8821, 0x0007}, {0x8822, 0x002e}, {0x8823, 0x00cf},
3049{0x8824, 0x00f6}, {0x8825, 0x0012}, {0x8826, 0x0005},
3050{0x8827, 0x00c4}, {0x8828, 0x00f8}, {0x8829, 0x001b},
3051{0x882a, 0x00b7}, {0x882b, 0x0012}, {0x882c, 0x0005},
3052{0x882d, 0x0086}, {0x882e, 0x0000}, {0x882f, 0x00f6},
3053{0x8830, 0x008f}, {0x8831, 0x0071}, {0x8832, 0x00bd},
3054{0x8833, 0x0089}, {0x8834, 0x0094}, {0x8835, 0x0086},
3055{0x8836, 0x0001}, {0x8837, 0x00f6}, {0x8838, 0x008f},
3056{0x8839, 0x0074}, {0x883a, 0x00bd}, {0x883b, 0x0089},
3057{0x883c, 0x0094}, {0x883d, 0x0086}, {0x883e, 0x0002},
3058{0x883f, 0x00f6}, {0x8840, 0x008f}, {0x8841, 0x0077},
3059{0x8842, 0x00bd}, {0x8843, 0x0089}, {0x8844, 0x0094},
3060{0x8845, 0x0086}, {0x8846, 0x0003}, {0x8847, 0x00f6},
3061{0x8848, 0x008f}, {0x8849, 0x007a}, {0x884a, 0x00bd},
3062{0x884b, 0x0089}, {0x884c, 0x0094}, {0x884d, 0x00ce},
3063{0x884e, 0x008f}, {0x884f, 0x0070}, {0x8850, 0x00a6},
3064{0x8851, 0x0001}, {0x8852, 0x0081}, {0x8853, 0x0001},
3065{0x8854, 0x0027}, {0x8855, 0x0007}, {0x8856, 0x0081},
3066{0x8857, 0x0003}, {0x8858, 0x0027}, {0x8859, 0x0003},
3067{0x885a, 0x007e}, {0x885b, 0x0088}, {0x885c, 0x0066},
3068{0x885d, 0x00a6}, {0x885e, 0x0000}, {0x885f, 0x00b8},
3069{0x8860, 0x008f}, {0x8861, 0x0081}, {0x8862, 0x0084},
3070{0x8863, 0x0001}, {0x8864, 0x0026}, {0x8865, 0x000b},
3071{0x8866, 0x008c}, {0x8867, 0x008f}, {0x8868, 0x0079},
3072{0x8869, 0x002c}, {0x886a, 0x000e}, {0x886b, 0x0008},
3073{0x886c, 0x0008}, {0x886d, 0x0008}, {0x886e, 0x007e},
3074{0x886f, 0x0088}, {0x8870, 0x0050}, {0x8871, 0x00b6},
3075{0x8872, 0x0012}, {0x8873, 0x0004}, {0x8874, 0x008a},
3076{0x8875, 0x0040}, {0x8876, 0x00b7}, {0x8877, 0x0012},
3077{0x8878, 0x0004}, {0x8879, 0x00b6}, {0x887a, 0x0012},
3078{0x887b, 0x0004}, {0x887c, 0x0084}, {0x887d, 0x00fb},
3079{0x887e, 0x0084}, {0x887f, 0x00ef}, {0x8880, 0x00b7},
3080{0x8881, 0x0012}, {0x8882, 0x0004}, {0x8883, 0x00b6},
3081{0x8884, 0x0012}, {0x8885, 0x0007}, {0x8886, 0x0036},
3082{0x8887, 0x00b6}, {0x8888, 0x008f}, {0x8889, 0x007c},
3083{0x888a, 0x0048}, {0x888b, 0x0048}, {0x888c, 0x00b7},
3084{0x888d, 0x0012}, {0x888e, 0x0007}, {0x888f, 0x0086},
3085{0x8890, 0x0001}, {0x8891, 0x00ba}, {0x8892, 0x0012},
3086{0x8893, 0x0004}, {0x8894, 0x00b7}, {0x8895, 0x0012},
3087{0x8896, 0x0004}, {0x8897, 0x0001}, {0x8898, 0x0001},
3088{0x8899, 0x0001}, {0x889a, 0x0001}, {0x889b, 0x0001},
3089{0x889c, 0x0001}, {0x889d, 0x0086}, {0x889e, 0x00fe},
3090{0x889f, 0x00b4}, {0x88a0, 0x0012}, {0x88a1, 0x0004},
3091{0x88a2, 0x00b7}, {0x88a3, 0x0012}, {0x88a4, 0x0004},
3092{0x88a5, 0x0086}, {0x88a6, 0x0002}, {0x88a7, 0x00ba},
3093{0x88a8, 0x0012}, {0x88a9, 0x0004}, {0x88aa, 0x00b7},
3094{0x88ab, 0x0012}, {0x88ac, 0x0004}, {0x88ad, 0x0086},
3095{0x88ae, 0x00fd}, {0x88af, 0x00b4}, {0x88b0, 0x0012},
3096{0x88b1, 0x0004}, {0x88b2, 0x00b7}, {0x88b3, 0x0012},
3097{0x88b4, 0x0004}, {0x88b5, 0x0032}, {0x88b6, 0x00b7},
3098{0x88b7, 0x0012}, {0x88b8, 0x0007}, {0x88b9, 0x00b6},
3099{0x88ba, 0x0012}, {0x88bb, 0x0000}, {0x88bc, 0x0084},
3100{0x88bd, 0x0008}, {0x88be, 0x0081}, {0x88bf, 0x0008},
3101{0x88c0, 0x0027}, {0x88c1, 0x000f}, {0x88c2, 0x007c},
3102{0x88c3, 0x0082}, {0x88c4, 0x0008}, {0x88c5, 0x0026},
3103{0x88c6, 0x0007}, {0x88c7, 0x0086}, {0x88c8, 0x0076},
3104{0x88c9, 0x0097}, {0x88ca, 0x0040}, {0x88cb, 0x007e},
3105{0x88cc, 0x0089}, {0x88cd, 0x006e}, {0x88ce, 0x007e},
3106{0x88cf, 0x0086}, {0x88d0, 0x00ec}, {0x88d1, 0x00b6},
3107{0x88d2, 0x008f}, {0x88d3, 0x007f}, {0x88d4, 0x0081},
3108{0x88d5, 0x000f}, {0x88d6, 0x0027}, {0x88d7, 0x003c},
3109{0x88d8, 0x00bd}, {0x88d9, 0x00e6}, {0x88da, 0x00c7},
3110{0x88db, 0x00b7}, {0x88dc, 0x0012}, {0x88dd, 0x000d},
3111{0x88de, 0x00bd}, {0x88df, 0x00e6}, {0x88e0, 0x00cb},
3112{0x88e1, 0x00b6}, {0x88e2, 0x0012}, {0x88e3, 0x0004},
3113{0x88e4, 0x008a}, {0x88e5, 0x0020}, {0x88e6, 0x00b7},
3114{0x88e7, 0x0012}, {0x88e8, 0x0004}, {0x88e9, 0x00ce},
3115{0x88ea, 0x00ff}, {0x88eb, 0x00ff}, {0x88ec, 0x00b6},
3116{0x88ed, 0x0012}, {0x88ee, 0x0000}, {0x88ef, 0x0081},
3117{0x88f0, 0x000c}, {0x88f1, 0x0026}, {0x88f2, 0x0005},
3118{0x88f3, 0x0009}, {0x88f4, 0x0026}, {0x88f5, 0x00f6},
3119{0x88f6, 0x0027}, {0x88f7, 0x001c}, {0x88f8, 0x00b6},
3120{0x88f9, 0x0012}, {0x88fa, 0x0004}, {0x88fb, 0x0084},
3121{0x88fc, 0x00df}, {0x88fd, 0x00b7}, {0x88fe, 0x0012},
3122{0x88ff, 0x0004}, {0x8900, 0x0096}, {0x8901, 0x0083},
3123{0x8902, 0x0081}, {0x8903, 0x0007}, {0x8904, 0x002c},
3124{0x8905, 0x0005}, {0x8906, 0x007c}, {0x8907, 0x0000},
3125{0x8908, 0x0083}, {0x8909, 0x0020}, {0x890a, 0x0006},
3126{0x890b, 0x0096}, {0x890c, 0x0083}, {0x890d, 0x008b},
3127{0x890e, 0x0008}, {0x890f, 0x0097}, {0x8910, 0x0083},
3128{0x8911, 0x007e}, {0x8912, 0x0085}, {0x8913, 0x0041},
3129{0x8914, 0x007f}, {0x8915, 0x008f}, {0x8916, 0x007e},
3130{0x8917, 0x0086}, {0x8918, 0x0080}, {0x8919, 0x00b7},
3131{0x891a, 0x0012}, {0x891b, 0x000c}, {0x891c, 0x0086},
3132{0x891d, 0x0001}, {0x891e, 0x00b7}, {0x891f, 0x008f},
3133{0x8920, 0x007d}, {0x8921, 0x00b6}, {0x8922, 0x0012},
3134{0x8923, 0x000c}, {0x8924, 0x0084}, {0x8925, 0x007f},
3135{0x8926, 0x00b7}, {0x8927, 0x0012}, {0x8928, 0x000c},
3136{0x8929, 0x008a}, {0x892a, 0x0080}, {0x892b, 0x00b7},
3137{0x892c, 0x0012}, {0x892d, 0x000c}, {0x892e, 0x0086},
3138{0x892f, 0x000a}, {0x8930, 0x00bd}, {0x8931, 0x008a},
3139{0x8932, 0x0006}, {0x8933, 0x00b6}, {0x8934, 0x0012},
3140{0x8935, 0x000a}, {0x8936, 0x002a}, {0x8937, 0x0009},
3141{0x8938, 0x00b6}, {0x8939, 0x0012}, {0x893a, 0x000c},
3142{0x893b, 0x00ba}, {0x893c, 0x008f}, {0x893d, 0x007d},
3143{0x893e, 0x00b7}, {0x893f, 0x0012}, {0x8940, 0x000c},
3144{0x8941, 0x00b6}, {0x8942, 0x008f}, {0x8943, 0x007e},
3145{0x8944, 0x0081}, {0x8945, 0x0060}, {0x8946, 0x0027},
3146{0x8947, 0x001a}, {0x8948, 0x008b}, {0x8949, 0x0020},
3147{0x894a, 0x00b7}, {0x894b, 0x008f}, {0x894c, 0x007e},
3148{0x894d, 0x00b6}, {0x894e, 0x0012}, {0x894f, 0x000c},
3149{0x8950, 0x0084}, {0x8951, 0x009f}, {0x8952, 0x00ba},
3150{0x8953, 0x008f}, {0x8954, 0x007e}, {0x8955, 0x00b7},
3151{0x8956, 0x0012}, {0x8957, 0x000c}, {0x8958, 0x00b6},
3152{0x8959, 0x008f}, {0x895a, 0x007d}, {0x895b, 0x0048},
3153{0x895c, 0x00b7}, {0x895d, 0x008f}, {0x895e, 0x007d},
3154{0x895f, 0x007e}, {0x8960, 0x0089}, {0x8961, 0x0021},
3155{0x8962, 0x00b6}, {0x8963, 0x0012}, {0x8964, 0x0004},
3156{0x8965, 0x008a}, {0x8966, 0x0020}, {0x8967, 0x00b7},
3157{0x8968, 0x0012}, {0x8969, 0x0004}, {0x896a, 0x00bd},
3158{0x896b, 0x008a}, {0x896c, 0x000a}, {0x896d, 0x004f},
3159{0x896e, 0x0039}, {0x896f, 0x00a6}, {0x8970, 0x0000},
3160{0x8971, 0x0018}, {0x8972, 0x00a7}, {0x8973, 0x0000},
3161{0x8974, 0x0008}, {0x8975, 0x0018}, {0x8976, 0x0008},
3162{0x8977, 0x005a}, {0x8978, 0x0026}, {0x8979, 0x00f5},
3163{0x897a, 0x0039}, {0x897b, 0x0036}, {0x897c, 0x006c},
3164{0x897d, 0x0000}, {0x897e, 0x0032}, {0x897f, 0x00ba},
3165{0x8980, 0x008f}, {0x8981, 0x007f}, {0x8982, 0x00b7},
3166{0x8983, 0x008f}, {0x8984, 0x007f}, {0x8985, 0x00b6},
3167{0x8986, 0x0012}, {0x8987, 0x0009}, {0x8988, 0x0084},
3168{0x8989, 0x0003}, {0x898a, 0x00a7}, {0x898b, 0x0001},
3169{0x898c, 0x00b6}, {0x898d, 0x0012}, {0x898e, 0x0006},
3170{0x898f, 0x0084}, {0x8990, 0x003f}, {0x8991, 0x00a7},
3171{0x8992, 0x0002}, {0x8993, 0x0039}, {0x8994, 0x0036},
3172{0x8995, 0x0086}, {0x8996, 0x0003}, {0x8997, 0x00b7},
3173{0x8998, 0x008f}, {0x8999, 0x0080}, {0x899a, 0x0032},
3174{0x899b, 0x00c1}, {0x899c, 0x0000}, {0x899d, 0x0026},
3175{0x899e, 0x0006}, {0x899f, 0x00b7}, {0x89a0, 0x008f},
3176{0x89a1, 0x007c}, {0x89a2, 0x007e}, {0x89a3, 0x0089},
3177{0x89a4, 0x00c9}, {0x89a5, 0x00c1}, {0x89a6, 0x0001},
3178{0x89a7, 0x0027}, {0x89a8, 0x0018}, {0x89a9, 0x00c1},
3179{0x89aa, 0x0002}, {0x89ab, 0x0027}, {0x89ac, 0x000c},
3180{0x89ad, 0x00c1}, {0x89ae, 0x0003}, {0x89af, 0x0027},
3181{0x89b0, 0x0000}, {0x89b1, 0x00f6}, {0x89b2, 0x008f},
3182{0x89b3, 0x0080}, {0x89b4, 0x0005}, {0x89b5, 0x0005},
3183{0x89b6, 0x00f7}, {0x89b7, 0x008f}, {0x89b8, 0x0080},
3184{0x89b9, 0x00f6}, {0x89ba, 0x008f}, {0x89bb, 0x0080},
3185{0x89bc, 0x0005}, {0x89bd, 0x0005}, {0x89be, 0x00f7},
3186{0x89bf, 0x008f}, {0x89c0, 0x0080}, {0x89c1, 0x00f6},
3187{0x89c2, 0x008f}, {0x89c3, 0x0080}, {0x89c4, 0x0005},
3188{0x89c5, 0x0005}, {0x89c6, 0x00f7}, {0x89c7, 0x008f},
3189{0x89c8, 0x0080}, {0x89c9, 0x00f6}, {0x89ca, 0x008f},
3190{0x89cb, 0x0080}, {0x89cc, 0x0053}, {0x89cd, 0x00f4},
3191{0x89ce, 0x0012}, {0x89cf, 0x0007}, {0x89d0, 0x001b},
3192{0x89d1, 0x00b7}, {0x89d2, 0x0012}, {0x89d3, 0x0007},
3193{0x89d4, 0x0039}, {0x89d5, 0x00ce}, {0x89d6, 0x008f},
3194{0x89d7, 0x0070}, {0x89d8, 0x00a6}, {0x89d9, 0x0000},
3195{0x89da, 0x0018}, {0x89db, 0x00e6}, {0x89dc, 0x0000},
3196{0x89dd, 0x0018}, {0x89de, 0x00a7}, {0x89df, 0x0000},
3197{0x89e0, 0x00e7}, {0x89e1, 0x0000}, {0x89e2, 0x00a6},
3198{0x89e3, 0x0001}, {0x89e4, 0x0018}, {0x89e5, 0x00e6},
3199{0x89e6, 0x0001}, {0x89e7, 0x0018}, {0x89e8, 0x00a7},
3200{0x89e9, 0x0001}, {0x89ea, 0x00e7}, {0x89eb, 0x0001},
3201{0x89ec, 0x00a6}, {0x89ed, 0x0002}, {0x89ee, 0x0018},
3202{0x89ef, 0x00e6}, {0x89f0, 0x0002}, {0x89f1, 0x0018},
3203{0x89f2, 0x00a7}, {0x89f3, 0x0002}, {0x89f4, 0x00e7},
3204{0x89f5, 0x0002}, {0x89f6, 0x0039}, {0x89f7, 0x00a6},
3205{0x89f8, 0x0000}, {0x89f9, 0x0084}, {0x89fa, 0x0007},
3206{0x89fb, 0x00e6}, {0x89fc, 0x0000}, {0x89fd, 0x00c4},
3207{0x89fe, 0x0038}, {0x89ff, 0x0054}, {0x8a00, 0x0054},
3208{0x8a01, 0x0054}, {0x8a02, 0x001b}, {0x8a03, 0x00a7},
3209{0x8a04, 0x0000}, {0x8a05, 0x0039}, {0x8a06, 0x004a},
3210{0x8a07, 0x0026}, {0x8a08, 0x00fd}, {0x8a09, 0x0039},
3211{0x8a0a, 0x0096}, {0x8a0b, 0x0022}, {0x8a0c, 0x0084},
3212{0x8a0d, 0x000f}, {0x8a0e, 0x0097}, {0x8a0f, 0x0022},
3213{0x8a10, 0x0086}, {0x8a11, 0x0001}, {0x8a12, 0x00b7},
3214{0x8a13, 0x008f}, {0x8a14, 0x0070}, {0x8a15, 0x00b6},
3215{0x8a16, 0x0012}, {0x8a17, 0x0007}, {0x8a18, 0x00b7},
3216{0x8a19, 0x008f}, {0x8a1a, 0x0071}, {0x8a1b, 0x00f6},
3217{0x8a1c, 0x0012}, {0x8a1d, 0x000c}, {0x8a1e, 0x00c4},
3218{0x8a1f, 0x000f}, {0x8a20, 0x00c8}, {0x8a21, 0x000f},
3219{0x8a22, 0x00f7}, {0x8a23, 0x008f}, {0x8a24, 0x0072},
3220{0x8a25, 0x00f6}, {0x8a26, 0x008f}, {0x8a27, 0x0072},
3221{0x8a28, 0x00b6}, {0x8a29, 0x008f}, {0x8a2a, 0x0071},
3222{0x8a2b, 0x0084}, {0x8a2c, 0x0003}, {0x8a2d, 0x0027},
3223{0x8a2e, 0x0014}, {0x8a2f, 0x0081}, {0x8a30, 0x0001},
3224{0x8a31, 0x0027}, {0x8a32, 0x001c}, {0x8a33, 0x0081},
3225{0x8a34, 0x0002}, {0x8a35, 0x0027}, {0x8a36, 0x0024},
3226{0x8a37, 0x00f4}, {0x8a38, 0x008f}, {0x8a39, 0x0070},
3227{0x8a3a, 0x0027}, {0x8a3b, 0x002a}, {0x8a3c, 0x0096},
3228{0x8a3d, 0x0022}, {0x8a3e, 0x008a}, {0x8a3f, 0x0080},
3229{0x8a40, 0x007e}, {0x8a41, 0x008a}, {0x8a42, 0x0064},
3230{0x8a43, 0x00f4}, {0x8a44, 0x008f}, {0x8a45, 0x0070},
3231{0x8a46, 0x0027}, {0x8a47, 0x001e}, {0x8a48, 0x0096},
3232{0x8a49, 0x0022}, {0x8a4a, 0x008a}, {0x8a4b, 0x0010},
3233{0x8a4c, 0x007e}, {0x8a4d, 0x008a}, {0x8a4e, 0x0064},
3234{0x8a4f, 0x00f4}, {0x8a50, 0x008f}, {0x8a51, 0x0070},
3235{0x8a52, 0x0027}, {0x8a53, 0x0012}, {0x8a54, 0x0096},
3236{0x8a55, 0x0022}, {0x8a56, 0x008a}, {0x8a57, 0x0020},
3237{0x8a58, 0x007e}, {0x8a59, 0x008a}, {0x8a5a, 0x0064},
3238{0x8a5b, 0x00f4}, {0x8a5c, 0x008f}, {0x8a5d, 0x0070},
3239{0x8a5e, 0x0027}, {0x8a5f, 0x0006}, {0x8a60, 0x0096},
3240{0x8a61, 0x0022}, {0x8a62, 0x008a}, {0x8a63, 0x0040},
3241{0x8a64, 0x0097}, {0x8a65, 0x0022}, {0x8a66, 0x0074},
3242{0x8a67, 0x008f}, {0x8a68, 0x0071}, {0x8a69, 0x0074},
3243{0x8a6a, 0x008f}, {0x8a6b, 0x0071}, {0x8a6c, 0x0078},
3244{0x8a6d, 0x008f}, {0x8a6e, 0x0070}, {0x8a6f, 0x00b6},
3245{0x8a70, 0x008f}, {0x8a71, 0x0070}, {0x8a72, 0x0085},
3246{0x8a73, 0x0010}, {0x8a74, 0x0027}, {0x8a75, 0x00af},
3247{0x8a76, 0x00d6}, {0x8a77, 0x0022}, {0x8a78, 0x00c4},
3248{0x8a79, 0x0010}, {0x8a7a, 0x0058}, {0x8a7b, 0x00b6},
3249{0x8a7c, 0x0012}, {0x8a7d, 0x0070}, {0x8a7e, 0x0081},
3250{0x8a7f, 0x00e4}, {0x8a80, 0x0027}, {0x8a81, 0x0036},
3251{0x8a82, 0x0081}, {0x8a83, 0x00e1}, {0x8a84, 0x0026},
3252{0x8a85, 0x000c}, {0x8a86, 0x0096}, {0x8a87, 0x0022},
3253{0x8a88, 0x0084}, {0x8a89, 0x0020}, {0x8a8a, 0x0044},
3254{0x8a8b, 0x001b}, {0x8a8c, 0x00d6}, {0x8a8d, 0x0022},
3255{0x8a8e, 0x00c4}, {0x8a8f, 0x00cf}, {0x8a90, 0x0020},
3256{0x8a91, 0x0023}, {0x8a92, 0x0058}, {0x8a93, 0x0081},
3257{0x8a94, 0x00c6}, {0x8a95, 0x0026}, {0x8a96, 0x000d},
3258{0x8a97, 0x0096}, {0x8a98, 0x0022}, {0x8a99, 0x0084},
3259{0x8a9a, 0x0040}, {0x8a9b, 0x0044}, {0x8a9c, 0x0044},
3260{0x8a9d, 0x001b}, {0x8a9e, 0x00d6}, {0x8a9f, 0x0022},
3261{0x8aa0, 0x00c4}, {0x8aa1, 0x00af}, {0x8aa2, 0x0020},
3262{0x8aa3, 0x0011}, {0x8aa4, 0x0058}, {0x8aa5, 0x0081},
3263{0x8aa6, 0x0027}, {0x8aa7, 0x0026}, {0x8aa8, 0x000f},
3264{0x8aa9, 0x0096}, {0x8aaa, 0x0022}, {0x8aab, 0x0084},
3265{0x8aac, 0x0080}, {0x8aad, 0x0044}, {0x8aae, 0x0044},
3266{0x8aaf, 0x0044}, {0x8ab0, 0x001b}, {0x8ab1, 0x00d6},
3267{0x8ab2, 0x0022}, {0x8ab3, 0x00c4}, {0x8ab4, 0x006f},
3268{0x8ab5, 0x001b}, {0x8ab6, 0x0097}, {0x8ab7, 0x0022},
3269{0x8ab8, 0x0039}, {0x8ab9, 0x0027}, {0x8aba, 0x000c},
3270{0x8abb, 0x007c}, {0x8abc, 0x0082}, {0x8abd, 0x0006},
3271{0x8abe, 0x00bd}, {0x8abf, 0x00d9}, {0x8ac0, 0x00ed},
3272{0x8ac1, 0x00b6}, {0x8ac2, 0x0082}, {0x8ac3, 0x0007},
3273{0x8ac4, 0x007e}, {0x8ac5, 0x008a}, {0x8ac6, 0x00b9},
3274{0x8ac7, 0x007f}, {0x8ac8, 0x0082}, {0x8ac9, 0x0006},
3275{0x8aca, 0x0039}, { 0x0, 0x0 }
3276};
3277#else
3278cas_saturn_patch_t cas_saturn_patch[] = {
3279{0x8200, 0x007e}, {0x8201, 0x0082}, {0x8202, 0x0009},
3280{0x8203, 0x0000}, {0x8204, 0x0000}, {0x8205, 0x0000},
3281{0x8206, 0x0000}, {0x8207, 0x0000}, {0x8208, 0x0000},
3282{0x8209, 0x008e}, {0x820a, 0x008e}, {0x820b, 0x00ff},
3283{0x820c, 0x00ce}, {0x820d, 0x0082}, {0x820e, 0x0025},
3284{0x820f, 0x00ff}, {0x8210, 0x0001}, {0x8211, 0x000f},
3285{0x8212, 0x00ce}, {0x8213, 0x0084}, {0x8214, 0x0026},
3286{0x8215, 0x00ff}, {0x8216, 0x0001}, {0x8217, 0x0011},
3287{0x8218, 0x00ce}, {0x8219, 0x0085}, {0x821a, 0x003d},
3288{0x821b, 0x00df}, {0x821c, 0x00e5}, {0x821d, 0x0086},
3289{0x821e, 0x0039}, {0x821f, 0x00b7}, {0x8220, 0x008f},
3290{0x8221, 0x00f8}, {0x8222, 0x007e}, {0x8223, 0x00c3},
3291{0x8224, 0x00c2}, {0x8225, 0x0096}, {0x8226, 0x0047},
3292{0x8227, 0x0084}, {0x8228, 0x00f3}, {0x8229, 0x008a},
3293{0x822a, 0x0000}, {0x822b, 0x0097}, {0x822c, 0x0047},
3294{0x822d, 0x00ce}, {0x822e, 0x0082}, {0x822f, 0x0033},
3295{0x8230, 0x00ff}, {0x8231, 0x0001}, {0x8232, 0x000f},
3296{0x8233, 0x0096}, {0x8234, 0x0046}, {0x8235, 0x0084},
3297{0x8236, 0x000c}, {0x8237, 0x0081}, {0x8238, 0x0004},
3298{0x8239, 0x0027}, {0x823a, 0x000b}, {0x823b, 0x0096},
3299{0x823c, 0x0046}, {0x823d, 0x0084}, {0x823e, 0x000c},
3300{0x823f, 0x0081}, {0x8240, 0x0008}, {0x8241, 0x0027},
3301{0x8242, 0x0057}, {0x8243, 0x007e}, {0x8244, 0x0084},
3302{0x8245, 0x0025}, {0x8246, 0x0096}, {0x8247, 0x0047},
3303{0x8248, 0x0084}, {0x8249, 0x00f3}, {0x824a, 0x008a},
3304{0x824b, 0x0004}, {0x824c, 0x0097}, {0x824d, 0x0047},
3305{0x824e, 0x00ce}, {0x824f, 0x0082}, {0x8250, 0x0054},
3306{0x8251, 0x00ff}, {0x8252, 0x0001}, {0x8253, 0x000f},
3307{0x8254, 0x0096}, {0x8255, 0x0046}, {0x8256, 0x0084},
3308{0x8257, 0x000c}, {0x8258, 0x0081}, {0x8259, 0x0004},
3309{0x825a, 0x0026}, {0x825b, 0x0038}, {0x825c, 0x00b6},
3310{0x825d, 0x0012}, {0x825e, 0x0020}, {0x825f, 0x0084},
3311{0x8260, 0x0020}, {0x8261, 0x0026}, {0x8262, 0x0003},
3312{0x8263, 0x007e}, {0x8264, 0x0084}, {0x8265, 0x0025},
3313{0x8266, 0x0096}, {0x8267, 0x007b}, {0x8268, 0x00d6},
3314{0x8269, 0x007c}, {0x826a, 0x00fe}, {0x826b, 0x008f},
3315{0x826c, 0x0056}, {0x826d, 0x00bd}, {0x826e, 0x00f7},
3316{0x826f, 0x00b6}, {0x8270, 0x00fe}, {0x8271, 0x008f},
3317{0x8272, 0x004e}, {0x8273, 0x00bd}, {0x8274, 0x00ec},
3318{0x8275, 0x008e}, {0x8276, 0x00bd}, {0x8277, 0x00fa},
3319{0x8278, 0x00f7}, {0x8279, 0x00bd}, {0x827a, 0x00f7},
3320{0x827b, 0x0028}, {0x827c, 0x00ce}, {0x827d, 0x0082},
3321{0x827e, 0x0082}, {0x827f, 0x00ff}, {0x8280, 0x0001},
3322{0x8281, 0x000f}, {0x8282, 0x0096}, {0x8283, 0x0046},
3323{0x8284, 0x0084}, {0x8285, 0x000c}, {0x8286, 0x0081},
3324{0x8287, 0x0004}, {0x8288, 0x0026}, {0x8289, 0x000a},
3325{0x828a, 0x00b6}, {0x828b, 0x0012}, {0x828c, 0x0020},
3326{0x828d, 0x0084}, {0x828e, 0x0020}, {0x828f, 0x0027},
3327{0x8290, 0x00b5}, {0x8291, 0x007e}, {0x8292, 0x0084},
3328{0x8293, 0x0025}, {0x8294, 0x00bd}, {0x8295, 0x00f7},
3329{0x8296, 0x001f}, {0x8297, 0x007e}, {0x8298, 0x0084},
3330{0x8299, 0x001f}, {0x829a, 0x0096}, {0x829b, 0x0047},
3331{0x829c, 0x0084}, {0x829d, 0x00f3}, {0x829e, 0x008a},
3332{0x829f, 0x0008}, {0x82a0, 0x0097}, {0x82a1, 0x0047},
3333{0x82a2, 0x00de}, {0x82a3, 0x00e1}, {0x82a4, 0x00ad},
3334{0x82a5, 0x0000}, {0x82a6, 0x00ce}, {0x82a7, 0x0082},
3335{0x82a8, 0x00af}, {0x82a9, 0x00ff}, {0x82aa, 0x0001},
3336{0x82ab, 0x000f}, {0x82ac, 0x007e}, {0x82ad, 0x0084},
3337{0x82ae, 0x0025}, {0x82af, 0x0096}, {0x82b0, 0x0041},
3338{0x82b1, 0x0085}, {0x82b2, 0x0010}, {0x82b3, 0x0026},
3339{0x82b4, 0x0006}, {0x82b5, 0x0096}, {0x82b6, 0x0023},
3340{0x82b7, 0x0085}, {0x82b8, 0x0040}, {0x82b9, 0x0027},
3341{0x82ba, 0x0006}, {0x82bb, 0x00bd}, {0x82bc, 0x00ed},
3342{0x82bd, 0x0000}, {0x82be, 0x007e}, {0x82bf, 0x0083},
3343{0x82c0, 0x00a2}, {0x82c1, 0x00de}, {0x82c2, 0x0042},
3344{0x82c3, 0x00bd}, {0x82c4, 0x00eb}, {0x82c5, 0x008e},
3345{0x82c6, 0x0096}, {0x82c7, 0x0024}, {0x82c8, 0x0084},
3346{0x82c9, 0x0008}, {0x82ca, 0x0027}, {0x82cb, 0x0003},
3347{0x82cc, 0x007e}, {0x82cd, 0x0083}, {0x82ce, 0x00df},
3348{0x82cf, 0x0096}, {0x82d0, 0x007b}, {0x82d1, 0x00d6},
3349{0x82d2, 0x007c}, {0x82d3, 0x00fe}, {0x82d4, 0x008f},
3350{0x82d5, 0x0056}, {0x82d6, 0x00bd}, {0x82d7, 0x00f7},
3351{0x82d8, 0x00b6}, {0x82d9, 0x00fe}, {0x82da, 0x008f},
3352{0x82db, 0x0050}, {0x82dc, 0x00bd}, {0x82dd, 0x00ec},
3353{0x82de, 0x008e}, {0x82df, 0x00bd}, {0x82e0, 0x00fa},
3354{0x82e1, 0x00f7}, {0x82e2, 0x0086}, {0x82e3, 0x0011},
3355{0x82e4, 0x00c6}, {0x82e5, 0x0049}, {0x82e6, 0x00bd},
3356{0x82e7, 0x00e4}, {0x82e8, 0x0012}, {0x82e9, 0x00ce},
3357{0x82ea, 0x0082}, {0x82eb, 0x00ef}, {0x82ec, 0x00ff},
3358{0x82ed, 0x0001}, {0x82ee, 0x000f}, {0x82ef, 0x0096},
3359{0x82f0, 0x0046}, {0x82f1, 0x0084}, {0x82f2, 0x000c},
3360{0x82f3, 0x0081}, {0x82f4, 0x0000}, {0x82f5, 0x0027},
3361{0x82f6, 0x0017}, {0x82f7, 0x00c6}, {0x82f8, 0x0049},
3362{0x82f9, 0x00bd}, {0x82fa, 0x00e4}, {0x82fb, 0x0091},
3363{0x82fc, 0x0024}, {0x82fd, 0x000d}, {0x82fe, 0x00b6},
3364{0x82ff, 0x0012}, {0x8300, 0x0020}, {0x8301, 0x0085},
3365{0x8302, 0x0020}, {0x8303, 0x0026}, {0x8304, 0x000c},
3366{0x8305, 0x00ce}, {0x8306, 0x0082}, {0x8307, 0x00c1},
3367{0x8308, 0x00ff}, {0x8309, 0x0001}, {0x830a, 0x000f},
3368{0x830b, 0x007e}, {0x830c, 0x0084}, {0x830d, 0x0025},
3369{0x830e, 0x007e}, {0x830f, 0x0084}, {0x8310, 0x0016},
3370{0x8311, 0x00fe}, {0x8312, 0x008f}, {0x8313, 0x0052},
3371{0x8314, 0x00bd}, {0x8315, 0x00ec}, {0x8316, 0x008e},
3372{0x8317, 0x00bd}, {0x8318, 0x00fa}, {0x8319, 0x00f7},
3373{0x831a, 0x0086}, {0x831b, 0x006a}, {0x831c, 0x00c6},
3374{0x831d, 0x0049}, {0x831e, 0x00bd}, {0x831f, 0x00e4},
3375{0x8320, 0x0012}, {0x8321, 0x00ce}, {0x8322, 0x0083},
3376{0x8323, 0x0027}, {0x8324, 0x00ff}, {0x8325, 0x0001},
3377{0x8326, 0x000f}, {0x8327, 0x0096}, {0x8328, 0x0046},
3378{0x8329, 0x0084}, {0x832a, 0x000c}, {0x832b, 0x0081},
3379{0x832c, 0x0000}, {0x832d, 0x0027}, {0x832e, 0x000a},
3380{0x832f, 0x00c6}, {0x8330, 0x0049}, {0x8331, 0x00bd},
3381{0x8332, 0x00e4}, {0x8333, 0x0091}, {0x8334, 0x0025},
3382{0x8335, 0x0006}, {0x8336, 0x007e}, {0x8337, 0x0084},
3383{0x8338, 0x0025}, {0x8339, 0x007e}, {0x833a, 0x0084},
3384{0x833b, 0x0016}, {0x833c, 0x00b6}, {0x833d, 0x0018},
3385{0x833e, 0x0070}, {0x833f, 0x00bb}, {0x8340, 0x0019},
3386{0x8341, 0x0070}, {0x8342, 0x002a}, {0x8343, 0x0004},
3387{0x8344, 0x0081}, {0x8345, 0x00af}, {0x8346, 0x002e},
3388{0x8347, 0x0019}, {0x8348, 0x0096}, {0x8349, 0x007b},
3389{0x834a, 0x00f6}, {0x834b, 0x0020}, {0x834c, 0x0007},
3390{0x834d, 0x00fa}, {0x834e, 0x0020}, {0x834f, 0x0027},
3391{0x8350, 0x00c4}, {0x8351, 0x0038}, {0x8352, 0x0081},
3392{0x8353, 0x0038}, {0x8354, 0x0027}, {0x8355, 0x000b},
3393{0x8356, 0x00f6}, {0x8357, 0x0020}, {0x8358, 0x0007},
3394{0x8359, 0x00fa}, {0x835a, 0x0020}, {0x835b, 0x0027},
3395{0x835c, 0x00cb}, {0x835d, 0x0008}, {0x835e, 0x007e},
3396{0x835f, 0x0082}, {0x8360, 0x00d3}, {0x8361, 0x00bd},
3397{0x8362, 0x00f7}, {0x8363, 0x0066}, {0x8364, 0x0086},
3398{0x8365, 0x0074}, {0x8366, 0x00c6}, {0x8367, 0x0049},
3399{0x8368, 0x00bd}, {0x8369, 0x00e4}, {0x836a, 0x0012},
3400{0x836b, 0x00ce}, {0x836c, 0x0083}, {0x836d, 0x0071},
3401{0x836e, 0x00ff}, {0x836f, 0x0001}, {0x8370, 0x000f},
3402{0x8371, 0x0096}, {0x8372, 0x0046}, {0x8373, 0x0084},
3403{0x8374, 0x000c}, {0x8375, 0x0081}, {0x8376, 0x0008},
3404{0x8377, 0x0026}, {0x8378, 0x000a}, {0x8379, 0x00c6},
3405{0x837a, 0x0049}, {0x837b, 0x00bd}, {0x837c, 0x00e4},
3406{0x837d, 0x0091}, {0x837e, 0x0025}, {0x837f, 0x0006},
3407{0x8380, 0x007e}, {0x8381, 0x0084}, {0x8382, 0x0025},
3408{0x8383, 0x007e}, {0x8384, 0x0084}, {0x8385, 0x0016},
3409{0x8386, 0x00bd}, {0x8387, 0x00f7}, {0x8388, 0x003e},
3410{0x8389, 0x0026}, {0x838a, 0x000e}, {0x838b, 0x00bd},
3411{0x838c, 0x00e5}, {0x838d, 0x0009}, {0x838e, 0x0026},
3412{0x838f, 0x0006}, {0x8390, 0x00ce}, {0x8391, 0x0082},
3413{0x8392, 0x00c1}, {0x8393, 0x00ff}, {0x8394, 0x0001},
3414{0x8395, 0x000f}, {0x8396, 0x007e}, {0x8397, 0x0084},
3415{0x8398, 0x0025}, {0x8399, 0x00fe}, {0x839a, 0x008f},
3416{0x839b, 0x0054}, {0x839c, 0x00bd}, {0x839d, 0x00ec},
3417{0x839e, 0x008e}, {0x839f, 0x00bd}, {0x83a0, 0x00fa},
3418{0x83a1, 0x00f7}, {0x83a2, 0x00bd}, {0x83a3, 0x00f7},
3419{0x83a4, 0x0033}, {0x83a5, 0x0086}, {0x83a6, 0x000f},
3420{0x83a7, 0x00c6}, {0x83a8, 0x0051}, {0x83a9, 0x00bd},
3421{0x83aa, 0x00e4}, {0x83ab, 0x0012}, {0x83ac, 0x00ce},
3422{0x83ad, 0x0083}, {0x83ae, 0x00b2}, {0x83af, 0x00ff},
3423{0x83b0, 0x0001}, {0x83b1, 0x000f}, {0x83b2, 0x0096},
3424{0x83b3, 0x0046}, {0x83b4, 0x0084}, {0x83b5, 0x000c},
3425{0x83b6, 0x0081}, {0x83b7, 0x0008}, {0x83b8, 0x0026},
3426{0x83b9, 0x005c}, {0x83ba, 0x00b6}, {0x83bb, 0x0012},
3427{0x83bc, 0x0020}, {0x83bd, 0x0084}, {0x83be, 0x003f},
3428{0x83bf, 0x0081}, {0x83c0, 0x003a}, {0x83c1, 0x0027},
3429{0x83c2, 0x001c}, {0x83c3, 0x0096}, {0x83c4, 0x0023},
3430{0x83c5, 0x0085}, {0x83c6, 0x0040}, {0x83c7, 0x0027},
3431{0x83c8, 0x0003}, {0x83c9, 0x007e}, {0x83ca, 0x0084},
3432{0x83cb, 0x0025}, {0x83cc, 0x00c6}, {0x83cd, 0x0051},
3433{0x83ce, 0x00bd}, {0x83cf, 0x00e4}, {0x83d0, 0x0091},
3434{0x83d1, 0x0025}, {0x83d2, 0x0003}, {0x83d3, 0x007e},
3435{0x83d4, 0x0084}, {0x83d5, 0x0025}, {0x83d6, 0x00ce},
3436{0x83d7, 0x0082}, {0x83d8, 0x00c1}, {0x83d9, 0x00ff},
3437{0x83da, 0x0001}, {0x83db, 0x000f}, {0x83dc, 0x007e},
3438{0x83dd, 0x0084}, {0x83de, 0x0025}, {0x83df, 0x00bd},
3439{0x83e0, 0x00f8}, {0x83e1, 0x0037}, {0x83e2, 0x007c},
3440{0x83e3, 0x0000}, {0x83e4, 0x007a}, {0x83e5, 0x00ce},
3441{0x83e6, 0x0083}, {0x83e7, 0x00ee}, {0x83e8, 0x00ff},
3442{0x83e9, 0x0001}, {0x83ea, 0x000f}, {0x83eb, 0x007e},
3443{0x83ec, 0x0084}, {0x83ed, 0x0025}, {0x83ee, 0x0096},
3444{0x83ef, 0x0046}, {0x83f0, 0x0084}, {0x83f1, 0x000c},
3445{0x83f2, 0x0081}, {0x83f3, 0x0008}, {0x83f4, 0x0026},
3446{0x83f5, 0x0020}, {0x83f6, 0x0096}, {0x83f7, 0x0024},
3447{0x83f8, 0x0084}, {0x83f9, 0x0008}, {0x83fa, 0x0026},
3448{0x83fb, 0x0029}, {0x83fc, 0x00b6}, {0x83fd, 0x0018},
3449{0x83fe, 0x0082}, {0x83ff, 0x00bb}, {0x8400, 0x0019},
3450{0x8401, 0x0082}, {0x8402, 0x00b1}, {0x8403, 0x0001},
3451{0x8404, 0x003b}, {0x8405, 0x0022}, {0x8406, 0x0009},
3452{0x8407, 0x00b6}, {0x8408, 0x0012}, {0x8409, 0x0020},
3453{0x840a, 0x0084}, {0x840b, 0x0037}, {0x840c, 0x0081},
3454{0x840d, 0x0032}, {0x840e, 0x0027}, {0x840f, 0x0015},
3455{0x8410, 0x00bd}, {0x8411, 0x00f8}, {0x8412, 0x0044},
3456{0x8413, 0x007e}, {0x8414, 0x0082}, {0x8415, 0x00c1},
3457{0x8416, 0x00bd}, {0x8417, 0x00f7}, {0x8418, 0x001f},
3458{0x8419, 0x00bd}, {0x841a, 0x00f8}, {0x841b, 0x0044},
3459{0x841c, 0x00bd}, {0x841d, 0x00fc}, {0x841e, 0x0029},
3460{0x841f, 0x00ce}, {0x8420, 0x0082}, {0x8421, 0x0025},
3461{0x8422, 0x00ff}, {0x8423, 0x0001}, {0x8424, 0x000f},
3462{0x8425, 0x0039}, {0x8426, 0x0096}, {0x8427, 0x0047},
3463{0x8428, 0x0084}, {0x8429, 0x00fc}, {0x842a, 0x008a},
3464{0x842b, 0x0000}, {0x842c, 0x0097}, {0x842d, 0x0047},
3465{0x842e, 0x00ce}, {0x842f, 0x0084}, {0x8430, 0x0034},
3466{0x8431, 0x00ff}, {0x8432, 0x0001}, {0x8433, 0x0011},
3467{0x8434, 0x0096}, {0x8435, 0x0046}, {0x8436, 0x0084},
3468{0x8437, 0x0003}, {0x8438, 0x0081}, {0x8439, 0x0002},
3469{0x843a, 0x0027}, {0x843b, 0x0003}, {0x843c, 0x007e},
3470{0x843d, 0x0085}, {0x843e, 0x001e}, {0x843f, 0x0096},
3471{0x8440, 0x0047}, {0x8441, 0x0084}, {0x8442, 0x00fc},
3472{0x8443, 0x008a}, {0x8444, 0x0002}, {0x8445, 0x0097},
3473{0x8446, 0x0047}, {0x8447, 0x00de}, {0x8448, 0x00e1},
3474{0x8449, 0x00ad}, {0x844a, 0x0000}, {0x844b, 0x0086},
3475{0x844c, 0x0001}, {0x844d, 0x00b7}, {0x844e, 0x0012},
3476{0x844f, 0x0051}, {0x8450, 0x00bd}, {0x8451, 0x00f7},
3477{0x8452, 0x0014}, {0x8453, 0x00b6}, {0x8454, 0x0010},
3478{0x8455, 0x0031}, {0x8456, 0x0084}, {0x8457, 0x00fd},
3479{0x8458, 0x00b7}, {0x8459, 0x0010}, {0x845a, 0x0031},
3480{0x845b, 0x00bd}, {0x845c, 0x00f8}, {0x845d, 0x001e},
3481{0x845e, 0x0096}, {0x845f, 0x0081}, {0x8460, 0x00d6},
3482{0x8461, 0x0082}, {0x8462, 0x00fe}, {0x8463, 0x008f},
3483{0x8464, 0x005a}, {0x8465, 0x00bd}, {0x8466, 0x00f7},
3484{0x8467, 0x00b6}, {0x8468, 0x00fe}, {0x8469, 0x008f},
3485{0x846a, 0x005c}, {0x846b, 0x00bd}, {0x846c, 0x00ec},
3486{0x846d, 0x008e}, {0x846e, 0x00bd}, {0x846f, 0x00fa},
3487{0x8470, 0x00f7}, {0x8471, 0x0086}, {0x8472, 0x0008},
3488{0x8473, 0x00d6}, {0x8474, 0x0000}, {0x8475, 0x00c5},
3489{0x8476, 0x0010}, {0x8477, 0x0026}, {0x8478, 0x0002},
3490{0x8479, 0x008b}, {0x847a, 0x0020}, {0x847b, 0x00c6},
3491{0x847c, 0x0051}, {0x847d, 0x00bd}, {0x847e, 0x00e4},
3492{0x847f, 0x0012}, {0x8480, 0x00ce}, {0x8481, 0x0084},
3493{0x8482, 0x0086}, {0x8483, 0x00ff}, {0x8484, 0x0001},
3494{0x8485, 0x0011}, {0x8486, 0x0096}, {0x8487, 0x0046},
3495{0x8488, 0x0084}, {0x8489, 0x0003}, {0x848a, 0x0081},
3496{0x848b, 0x0002}, {0x848c, 0x0027}, {0x848d, 0x0003},
3497{0x848e, 0x007e}, {0x848f, 0x0085}, {0x8490, 0x000f},
3498{0x8491, 0x00c6}, {0x8492, 0x0051}, {0x8493, 0x00bd},
3499{0x8494, 0x00e4}, {0x8495, 0x0091}, {0x8496, 0x0025},
3500{0x8497, 0x0003}, {0x8498, 0x007e}, {0x8499, 0x0085},
3501{0x849a, 0x001e}, {0x849b, 0x0096}, {0x849c, 0x0044},
3502{0x849d, 0x0085}, {0x849e, 0x0010}, {0x849f, 0x0026},
3503{0x84a0, 0x000a}, {0x84a1, 0x00b6}, {0x84a2, 0x0012},
3504{0x84a3, 0x0050}, {0x84a4, 0x00ba}, {0x84a5, 0x0001},
3505{0x84a6, 0x003c}, {0x84a7, 0x0085}, {0x84a8, 0x0010},
3506{0x84a9, 0x0027}, {0x84aa, 0x00a8}, {0x84ab, 0x00bd},
3507{0x84ac, 0x00f7}, {0x84ad, 0x0066}, {0x84ae, 0x00ce},
3508{0x84af, 0x0084}, {0x84b0, 0x00b7}, {0x84b1, 0x00ff},
3509{0x84b2, 0x0001}, {0x84b3, 0x0011}, {0x84b4, 0x007e},
3510{0x84b5, 0x0085}, {0x84b6, 0x001e}, {0x84b7, 0x0096},
3511{0x84b8, 0x0046}, {0x84b9, 0x0084}, {0x84ba, 0x0003},
3512{0x84bb, 0x0081}, {0x84bc, 0x0002}, {0x84bd, 0x0026},
3513{0x84be, 0x0050}, {0x84bf, 0x00b6}, {0x84c0, 0x0012},
3514{0x84c1, 0x0030}, {0x84c2, 0x0084}, {0x84c3, 0x0003},
3515{0x84c4, 0x0081}, {0x84c5, 0x0001}, {0x84c6, 0x0027},
3516{0x84c7, 0x0003}, {0x84c8, 0x007e}, {0x84c9, 0x0085},
3517{0x84ca, 0x001e}, {0x84cb, 0x0096}, {0x84cc, 0x0044},
3518{0x84cd, 0x0085}, {0x84ce, 0x0010}, {0x84cf, 0x0026},
3519{0x84d0, 0x0013}, {0x84d1, 0x00b6}, {0x84d2, 0x0012},
3520{0x84d3, 0x0050}, {0x84d4, 0x00ba}, {0x84d5, 0x0001},
3521{0x84d6, 0x003c}, {0x84d7, 0x0085}, {0x84d8, 0x0010},
3522{0x84d9, 0x0026}, {0x84da, 0x0009}, {0x84db, 0x00ce},
3523{0x84dc, 0x0084}, {0x84dd, 0x0053}, {0x84de, 0x00ff},
3524{0x84df, 0x0001}, {0x84e0, 0x0011}, {0x84e1, 0x007e},
3525{0x84e2, 0x0085}, {0x84e3, 0x001e}, {0x84e4, 0x00b6},
3526{0x84e5, 0x0010}, {0x84e6, 0x0031}, {0x84e7, 0x008a},
3527{0x84e8, 0x0002}, {0x84e9, 0x00b7}, {0x84ea, 0x0010},
3528{0x84eb, 0x0031}, {0x84ec, 0x00bd}, {0x84ed, 0x0085},
3529{0x84ee, 0x001f}, {0x84ef, 0x00bd}, {0x84f0, 0x00f8},
3530{0x84f1, 0x0037}, {0x84f2, 0x007c}, {0x84f3, 0x0000},
3531{0x84f4, 0x0080}, {0x84f5, 0x00ce}, {0x84f6, 0x0084},
3532{0x84f7, 0x00fe}, {0x84f8, 0x00ff}, {0x84f9, 0x0001},
3533{0x84fa, 0x0011}, {0x84fb, 0x007e}, {0x84fc, 0x0085},
3534{0x84fd, 0x001e}, {0x84fe, 0x0096}, {0x84ff, 0x0046},
3535{0x8500, 0x0084}, {0x8501, 0x0003}, {0x8502, 0x0081},
3536{0x8503, 0x0002}, {0x8504, 0x0026}, {0x8505, 0x0009},
3537{0x8506, 0x00b6}, {0x8507, 0x0012}, {0x8508, 0x0030},
3538{0x8509, 0x0084}, {0x850a, 0x0003}, {0x850b, 0x0081},
3539{0x850c, 0x0001}, {0x850d, 0x0027}, {0x850e, 0x000f},
3540{0x850f, 0x00bd}, {0x8510, 0x00f8}, {0x8511, 0x0044},
3541{0x8512, 0x00bd}, {0x8513, 0x00f7}, {0x8514, 0x000b},
3542{0x8515, 0x00bd}, {0x8516, 0x00fc}, {0x8517, 0x0029},
3543{0x8518, 0x00ce}, {0x8519, 0x0084}, {0x851a, 0x0026},
3544{0x851b, 0x00ff}, {0x851c, 0x0001}, {0x851d, 0x0011},
3545{0x851e, 0x0039}, {0x851f, 0x00d6}, {0x8520, 0x0022},
3546{0x8521, 0x00c4}, {0x8522, 0x000f}, {0x8523, 0x00b6},
3547{0x8524, 0x0012}, {0x8525, 0x0030}, {0x8526, 0x00ba},
3548{0x8527, 0x0012}, {0x8528, 0x0032}, {0x8529, 0x0084},
3549{0x852a, 0x0004}, {0x852b, 0x0027}, {0x852c, 0x000d},
3550{0x852d, 0x0096}, {0x852e, 0x0022}, {0x852f, 0x0085},
3551{0x8530, 0x0004}, {0x8531, 0x0027}, {0x8532, 0x0005},
3552{0x8533, 0x00ca}, {0x8534, 0x0010}, {0x8535, 0x007e},
3553{0x8536, 0x0085}, {0x8537, 0x003a}, {0x8538, 0x00ca},
3554{0x8539, 0x0020}, {0x853a, 0x00d7}, {0x853b, 0x0022},
3555{0x853c, 0x0039}, {0x853d, 0x0086}, {0x853e, 0x0000},
3556{0x853f, 0x0097}, {0x8540, 0x0083}, {0x8541, 0x0018},
3557{0x8542, 0x00ce}, {0x8543, 0x001c}, {0x8544, 0x0000},
3558{0x8545, 0x00bd}, {0x8546, 0x00eb}, {0x8547, 0x0046},
3559{0x8548, 0x0096}, {0x8549, 0x0057}, {0x854a, 0x0085},
3560{0x854b, 0x0001}, {0x854c, 0x0027}, {0x854d, 0x0002},
3561{0x854e, 0x004f}, {0x854f, 0x0039}, {0x8550, 0x0085},
3562{0x8551, 0x0002}, {0x8552, 0x0027}, {0x8553, 0x0001},
3563{0x8554, 0x0039}, {0x8555, 0x007f}, {0x8556, 0x008f},
3564{0x8557, 0x007d}, {0x8558, 0x0086}, {0x8559, 0x0004},
3565{0x855a, 0x00b7}, {0x855b, 0x0012}, {0x855c, 0x0004},
3566{0x855d, 0x0086}, {0x855e, 0x0008}, {0x855f, 0x00b7},
3567{0x8560, 0x0012}, {0x8561, 0x0007}, {0x8562, 0x0086},
3568{0x8563, 0x0010}, {0x8564, 0x00b7}, {0x8565, 0x0012},
3569{0x8566, 0x000c}, {0x8567, 0x0086}, {0x8568, 0x0007},
3570{0x8569, 0x00b7}, {0x856a, 0x0012}, {0x856b, 0x0006},
3571{0x856c, 0x00b6}, {0x856d, 0x008f}, {0x856e, 0x007d},
3572{0x856f, 0x00b7}, {0x8570, 0x0012}, {0x8571, 0x0070},
3573{0x8572, 0x0086}, {0x8573, 0x0001}, {0x8574, 0x00ba},
3574{0x8575, 0x0012}, {0x8576, 0x0004}, {0x8577, 0x00b7},
3575{0x8578, 0x0012}, {0x8579, 0x0004}, {0x857a, 0x0001},
3576{0x857b, 0x0001}, {0x857c, 0x0001}, {0x857d, 0x0001},
3577{0x857e, 0x0001}, {0x857f, 0x0001}, {0x8580, 0x00b6},
3578{0x8581, 0x0012}, {0x8582, 0x0004}, {0x8583, 0x0084},
3579{0x8584, 0x00fe}, {0x8585, 0x008a}, {0x8586, 0x0002},
3580{0x8587, 0x00b7}, {0x8588, 0x0012}, {0x8589, 0x0004},
3581{0x858a, 0x0001}, {0x858b, 0x0001}, {0x858c, 0x0001},
3582{0x858d, 0x0001}, {0x858e, 0x0001}, {0x858f, 0x0001},
3583{0x8590, 0x0086}, {0x8591, 0x00fd}, {0x8592, 0x00b4},
3584{0x8593, 0x0012}, {0x8594, 0x0004}, {0x8595, 0x00b7},
3585{0x8596, 0x0012}, {0x8597, 0x0004}, {0x8598, 0x00b6},
3586{0x8599, 0x0012}, {0x859a, 0x0000}, {0x859b, 0x0084},
3587{0x859c, 0x0008}, {0x859d, 0x0081}, {0x859e, 0x0008},
3588{0x859f, 0x0027}, {0x85a0, 0x0016}, {0x85a1, 0x00b6},
3589{0x85a2, 0x008f}, {0x85a3, 0x007d}, {0x85a4, 0x0081},
3590{0x85a5, 0x000c}, {0x85a6, 0x0027}, {0x85a7, 0x0008},
3591{0x85a8, 0x008b}, {0x85a9, 0x0004}, {0x85aa, 0x00b7},
3592{0x85ab, 0x008f}, {0x85ac, 0x007d}, {0x85ad, 0x007e},
3593{0x85ae, 0x0085}, {0x85af, 0x006c}, {0x85b0, 0x0086},
3594{0x85b1, 0x0003}, {0x85b2, 0x0097}, {0x85b3, 0x0040},
3595{0x85b4, 0x007e}, {0x85b5, 0x0089}, {0x85b6, 0x006e},
3596{0x85b7, 0x0086}, {0x85b8, 0x0007}, {0x85b9, 0x00b7},
3597{0x85ba, 0x0012}, {0x85bb, 0x0006}, {0x85bc, 0x005f},
3598{0x85bd, 0x00f7}, {0x85be, 0x008f}, {0x85bf, 0x0082},
3599{0x85c0, 0x005f}, {0x85c1, 0x00f7}, {0x85c2, 0x008f},
3600{0x85c3, 0x007f}, {0x85c4, 0x00f7}, {0x85c5, 0x008f},
3601{0x85c6, 0x0070}, {0x85c7, 0x00f7}, {0x85c8, 0x008f},
3602{0x85c9, 0x0071}, {0x85ca, 0x00f7}, {0x85cb, 0x008f},
3603{0x85cc, 0x0072}, {0x85cd, 0x00f7}, {0x85ce, 0x008f},
3604{0x85cf, 0x0073}, {0x85d0, 0x00f7}, {0x85d1, 0x008f},
3605{0x85d2, 0x0074}, {0x85d3, 0x00f7}, {0x85d4, 0x008f},
3606{0x85d5, 0x0075}, {0x85d6, 0x00f7}, {0x85d7, 0x008f},
3607{0x85d8, 0x0076}, {0x85d9, 0x00f7}, {0x85da, 0x008f},
3608{0x85db, 0x0077}, {0x85dc, 0x00f7}, {0x85dd, 0x008f},
3609{0x85de, 0x0078}, {0x85df, 0x00f7}, {0x85e0, 0x008f},
3610{0x85e1, 0x0079}, {0x85e2, 0x00f7}, {0x85e3, 0x008f},
3611{0x85e4, 0x007a}, {0x85e5, 0x00f7}, {0x85e6, 0x008f},
3612{0x85e7, 0x007b}, {0x85e8, 0x00b6}, {0x85e9, 0x0012},
3613{0x85ea, 0x0004}, {0x85eb, 0x008a}, {0x85ec, 0x0010},
3614{0x85ed, 0x00b7}, {0x85ee, 0x0012}, {0x85ef, 0x0004},
3615{0x85f0, 0x0086}, {0x85f1, 0x00e4}, {0x85f2, 0x00b7},
3616{0x85f3, 0x0012}, {0x85f4, 0x0070}, {0x85f5, 0x00b7},
3617{0x85f6, 0x0012}, {0x85f7, 0x0007}, {0x85f8, 0x00f7},
3618{0x85f9, 0x0012}, {0x85fa, 0x0005}, {0x85fb, 0x00f7},
3619{0x85fc, 0x0012}, {0x85fd, 0x0009}, {0x85fe, 0x0086},
3620{0x85ff, 0x0008}, {0x8600, 0x00ba}, {0x8601, 0x0012},
3621{0x8602, 0x0004}, {0x8603, 0x00b7}, {0x8604, 0x0012},
3622{0x8605, 0x0004}, {0x8606, 0x0086}, {0x8607, 0x00f7},
3623{0x8608, 0x00b4}, {0x8609, 0x0012}, {0x860a, 0x0004},
3624{0x860b, 0x00b7}, {0x860c, 0x0012}, {0x860d, 0x0004},
3625{0x860e, 0x0001}, {0x860f, 0x0001}, {0x8610, 0x0001},
3626{0x8611, 0x0001}, {0x8612, 0x0001}, {0x8613, 0x0001},
3627{0x8614, 0x00b6}, {0x8615, 0x0012}, {0x8616, 0x0008},
3628{0x8617, 0x0027}, {0x8618, 0x007f}, {0x8619, 0x0081},
3629{0x861a, 0x0080}, {0x861b, 0x0026}, {0x861c, 0x000b},
3630{0x861d, 0x0086}, {0x861e, 0x0008}, {0x861f, 0x00ce},
3631{0x8620, 0x008f}, {0x8621, 0x0079}, {0x8622, 0x00bd},
3632{0x8623, 0x0089}, {0x8624, 0x007b}, {0x8625, 0x007e},
3633{0x8626, 0x0086}, {0x8627, 0x008e}, {0x8628, 0x0081},
3634{0x8629, 0x0040}, {0x862a, 0x0026}, {0x862b, 0x000b},
3635{0x862c, 0x0086}, {0x862d, 0x0004}, {0x862e, 0x00ce},
3636{0x862f, 0x008f}, {0x8630, 0x0076}, {0x8631, 0x00bd},
3637{0x8632, 0x0089}, {0x8633, 0x007b}, {0x8634, 0x007e},
3638{0x8635, 0x0086}, {0x8636, 0x008e}, {0x8637, 0x0081},
3639{0x8638, 0x0020}, {0x8639, 0x0026}, {0x863a, 0x000b},
3640{0x863b, 0x0086}, {0x863c, 0x0002}, {0x863d, 0x00ce},
3641{0x863e, 0x008f}, {0x863f, 0x0073}, {0x8640, 0x00bd},
3642{0x8641, 0x0089}, {0x8642, 0x007b}, {0x8643, 0x007e},
3643{0x8644, 0x0086}, {0x8645, 0x008e}, {0x8646, 0x0081},
3644{0x8647, 0x0010}, {0x8648, 0x0026}, {0x8649, 0x000b},
3645{0x864a, 0x0086}, {0x864b, 0x0001}, {0x864c, 0x00ce},
3646{0x864d, 0x008f}, {0x864e, 0x0070}, {0x864f, 0x00bd},
3647{0x8650, 0x0089}, {0x8651, 0x007b}, {0x8652, 0x007e},
3648{0x8653, 0x0086}, {0x8654, 0x008e}, {0x8655, 0x0081},
3649{0x8656, 0x0008}, {0x8657, 0x0026}, {0x8658, 0x000b},
3650{0x8659, 0x0086}, {0x865a, 0x0008}, {0x865b, 0x00ce},
3651{0x865c, 0x008f}, {0x865d, 0x0079}, {0x865e, 0x00bd},
3652{0x865f, 0x0089}, {0x8660, 0x007f}, {0x8661, 0x007e},
3653{0x8662, 0x0086}, {0x8663, 0x008e}, {0x8664, 0x0081},
3654{0x8665, 0x0004}, {0x8666, 0x0026}, {0x8667, 0x000b},
3655{0x8668, 0x0086}, {0x8669, 0x0004}, {0x866a, 0x00ce},
3656{0x866b, 0x008f}, {0x866c, 0x0076}, {0x866d, 0x00bd},
3657{0x866e, 0x0089}, {0x866f, 0x007f}, {0x8670, 0x007e},
3658{0x8671, 0x0086}, {0x8672, 0x008e}, {0x8673, 0x0081},
3659{0x8674, 0x0002}, {0x8675, 0x0026}, {0x8676, 0x000b},
3660{0x8677, 0x008a}, {0x8678, 0x0002}, {0x8679, 0x00ce},
3661{0x867a, 0x008f}, {0x867b, 0x0073}, {0x867c, 0x00bd},
3662{0x867d, 0x0089}, {0x867e, 0x007f}, {0x867f, 0x007e},
3663{0x8680, 0x0086}, {0x8681, 0x008e}, {0x8682, 0x0081},
3664{0x8683, 0x0001}, {0x8684, 0x0026}, {0x8685, 0x0008},
3665{0x8686, 0x0086}, {0x8687, 0x0001}, {0x8688, 0x00ce},
3666{0x8689, 0x008f}, {0x868a, 0x0070}, {0x868b, 0x00bd},
3667{0x868c, 0x0089}, {0x868d, 0x007f}, {0x868e, 0x00b6},
3668{0x868f, 0x008f}, {0x8690, 0x007f}, {0x8691, 0x0081},
3669{0x8692, 0x000f}, {0x8693, 0x0026}, {0x8694, 0x0003},
3670{0x8695, 0x007e}, {0x8696, 0x0087}, {0x8697, 0x0047},
3671{0x8698, 0x00b6}, {0x8699, 0x0012}, {0x869a, 0x0009},
3672{0x869b, 0x0084}, {0x869c, 0x0003}, {0x869d, 0x0081},
3673{0x869e, 0x0003}, {0x869f, 0x0027}, {0x86a0, 0x0006},
3674{0x86a1, 0x007c}, {0x86a2, 0x0012}, {0x86a3, 0x0009},
3675{0x86a4, 0x007e}, {0x86a5, 0x0085}, {0x86a6, 0x00fe},
3676{0x86a7, 0x00b6}, {0x86a8, 0x0012}, {0x86a9, 0x0006},
3677{0x86aa, 0x0084}, {0x86ab, 0x0007}, {0x86ac, 0x0081},
3678{0x86ad, 0x0007}, {0x86ae, 0x0027}, {0x86af, 0x0008},
3679{0x86b0, 0x008b}, {0x86b1, 0x0001}, {0x86b2, 0x00b7},
3680{0x86b3, 0x0012}, {0x86b4, 0x0006}, {0x86b5, 0x007e},
3681{0x86b6, 0x0086}, {0x86b7, 0x00d5}, {0x86b8, 0x00b6},
3682{0x86b9, 0x008f}, {0x86ba, 0x0082}, {0x86bb, 0x0026},
3683{0x86bc, 0x000a}, {0x86bd, 0x007c}, {0x86be, 0x008f},
3684{0x86bf, 0x0082}, {0x86c0, 0x004f}, {0x86c1, 0x00b7},
3685{0x86c2, 0x0012}, {0x86c3, 0x0006}, {0x86c4, 0x007e},
3686{0x86c5, 0x0085}, {0x86c6, 0x00c0}, {0x86c7, 0x00b6},
3687{0x86c8, 0x0012}, {0x86c9, 0x0006}, {0x86ca, 0x0084},
3688{0x86cb, 0x003f}, {0x86cc, 0x0081}, {0x86cd, 0x003f},
3689{0x86ce, 0x0027}, {0x86cf, 0x0010}, {0x86d0, 0x008b},
3690{0x86d1, 0x0008}, {0x86d2, 0x00b7}, {0x86d3, 0x0012},
3691{0x86d4, 0x0006}, {0x86d5, 0x00b6}, {0x86d6, 0x0012},
3692{0x86d7, 0x0009}, {0x86d8, 0x0084}, {0x86d9, 0x00fc},
3693{0x86da, 0x00b7}, {0x86db, 0x0012}, {0x86dc, 0x0009},
3694{0x86dd, 0x007e}, {0x86de, 0x0085}, {0x86df, 0x00fe},
3695{0x86e0, 0x00ce}, {0x86e1, 0x008f}, {0x86e2, 0x0070},
3696{0x86e3, 0x0018}, {0x86e4, 0x00ce}, {0x86e5, 0x008f},
3697{0x86e6, 0x0084}, {0x86e7, 0x00c6}, {0x86e8, 0x000c},
3698{0x86e9, 0x00bd}, {0x86ea, 0x0089}, {0x86eb, 0x006f},
3699{0x86ec, 0x00ce}, {0x86ed, 0x008f}, {0x86ee, 0x0084},
3700{0x86ef, 0x0018}, {0x86f0, 0x00ce}, {0x86f1, 0x008f},
3701{0x86f2, 0x0070}, {0x86f3, 0x00c6}, {0x86f4, 0x000c},
3702{0x86f5, 0x00bd}, {0x86f6, 0x0089}, {0x86f7, 0x006f},
3703{0x86f8, 0x00d6}, {0x86f9, 0x0083}, {0x86fa, 0x00c1},
3704{0x86fb, 0x004f}, {0x86fc, 0x002d}, {0x86fd, 0x0003},
3705{0x86fe, 0x007e}, {0x86ff, 0x0087}, {0x8700, 0x0040},
3706{0x8701, 0x00b6}, {0x8702, 0x008f}, {0x8703, 0x007f},
3707{0x8704, 0x0081}, {0x8705, 0x0007}, {0x8706, 0x0027},
3708{0x8707, 0x000f}, {0x8708, 0x0081}, {0x8709, 0x000b},
3709{0x870a, 0x0027}, {0x870b, 0x0015}, {0x870c, 0x0081},
3710{0x870d, 0x000d}, {0x870e, 0x0027}, {0x870f, 0x001b},
3711{0x8710, 0x0081}, {0x8711, 0x000e}, {0x8712, 0x0027},
3712{0x8713, 0x0021}, {0x8714, 0x007e}, {0x8715, 0x0087},
3713{0x8716, 0x0040}, {0x8717, 0x00f7}, {0x8718, 0x008f},
3714{0x8719, 0x007b}, {0x871a, 0x0086}, {0x871b, 0x0002},
3715{0x871c, 0x00b7}, {0x871d, 0x008f}, {0x871e, 0x007a},
3716{0x871f, 0x0020}, {0x8720, 0x001c}, {0x8721, 0x00f7},
3717{0x8722, 0x008f}, {0x8723, 0x0078}, {0x8724, 0x0086},
3718{0x8725, 0x0002}, {0x8726, 0x00b7}, {0x8727, 0x008f},
3719{0x8728, 0x0077}, {0x8729, 0x0020}, {0x872a, 0x0012},
3720{0x872b, 0x00f7}, {0x872c, 0x008f}, {0x872d, 0x0075},
3721{0x872e, 0x0086}, {0x872f, 0x0002}, {0x8730, 0x00b7},
3722{0x8731, 0x008f}, {0x8732, 0x0074}, {0x8733, 0x0020},
3723{0x8734, 0x0008}, {0x8735, 0x00f7}, {0x8736, 0x008f},
3724{0x8737, 0x0072}, {0x8738, 0x0086}, {0x8739, 0x0002},
3725{0x873a, 0x00b7}, {0x873b, 0x008f}, {0x873c, 0x0071},
3726{0x873d, 0x007e}, {0x873e, 0x0087}, {0x873f, 0x0047},
3727{0x8740, 0x0086}, {0x8741, 0x0004}, {0x8742, 0x0097},
3728{0x8743, 0x0040}, {0x8744, 0x007e}, {0x8745, 0x0089},
3729{0x8746, 0x006e}, {0x8747, 0x00ce}, {0x8748, 0x008f},
3730{0x8749, 0x0072}, {0x874a, 0x00bd}, {0x874b, 0x0089},
3731{0x874c, 0x00f7}, {0x874d, 0x00ce}, {0x874e, 0x008f},
3732{0x874f, 0x0075}, {0x8750, 0x00bd}, {0x8751, 0x0089},
3733{0x8752, 0x00f7}, {0x8753, 0x00ce}, {0x8754, 0x008f},
3734{0x8755, 0x0078}, {0x8756, 0x00bd}, {0x8757, 0x0089},
3735{0x8758, 0x00f7}, {0x8759, 0x00ce}, {0x875a, 0x008f},
3736{0x875b, 0x007b}, {0x875c, 0x00bd}, {0x875d, 0x0089},
3737{0x875e, 0x00f7}, {0x875f, 0x004f}, {0x8760, 0x00b7},
3738{0x8761, 0x008f}, {0x8762, 0x007d}, {0x8763, 0x00b7},
3739{0x8764, 0x008f}, {0x8765, 0x0081}, {0x8766, 0x00b6},
3740{0x8767, 0x008f}, {0x8768, 0x0072}, {0x8769, 0x0027},
3741{0x876a, 0x0047}, {0x876b, 0x007c}, {0x876c, 0x008f},
3742{0x876d, 0x007d}, {0x876e, 0x00b6}, {0x876f, 0x008f},
3743{0x8770, 0x0075}, {0x8771, 0x0027}, {0x8772, 0x003f},
3744{0x8773, 0x007c}, {0x8774, 0x008f}, {0x8775, 0x007d},
3745{0x8776, 0x00b6}, {0x8777, 0x008f}, {0x8778, 0x0078},
3746{0x8779, 0x0027}, {0x877a, 0x0037}, {0x877b, 0x007c},
3747{0x877c, 0x008f}, {0x877d, 0x007d}, {0x877e, 0x00b6},
3748{0x877f, 0x008f}, {0x8780, 0x007b}, {0x8781, 0x0027},
3749{0x8782, 0x002f}, {0x8783, 0x007f}, {0x8784, 0x008f},
3750{0x8785, 0x007d}, {0x8786, 0x007c}, {0x8787, 0x008f},
3751{0x8788, 0x0081}, {0x8789, 0x007a}, {0x878a, 0x008f},
3752{0x878b, 0x0072}, {0x878c, 0x0027}, {0x878d, 0x001b},
3753{0x878e, 0x007c}, {0x878f, 0x008f}, {0x8790, 0x007d},
3754{0x8791, 0x007a}, {0x8792, 0x008f}, {0x8793, 0x0075},
3755{0x8794, 0x0027}, {0x8795, 0x0016}, {0x8796, 0x007c},
3756{0x8797, 0x008f}, {0x8798, 0x007d}, {0x8799, 0x007a},
3757{0x879a, 0x008f}, {0x879b, 0x0078}, {0x879c, 0x0027},
3758{0x879d, 0x0011}, {0x879e, 0x007c}, {0x879f, 0x008f},
3759{0x87a0, 0x007d}, {0x87a1, 0x007a}, {0x87a2, 0x008f},
3760{0x87a3, 0x007b}, {0x87a4, 0x0027}, {0x87a5, 0x000c},
3761{0x87a6, 0x007e}, {0x87a7, 0x0087}, {0x87a8, 0x0083},
3762{0x87a9, 0x007a}, {0x87aa, 0x008f}, {0x87ab, 0x0075},
3763{0x87ac, 0x007a}, {0x87ad, 0x008f}, {0x87ae, 0x0078},
3764{0x87af, 0x007a}, {0x87b0, 0x008f}, {0x87b1, 0x007b},
3765{0x87b2, 0x00ce}, {0x87b3, 0x00c1}, {0x87b4, 0x00fc},
3766{0x87b5, 0x00f6}, {0x87b6, 0x008f}, {0x87b7, 0x007d},
3767{0x87b8, 0x003a}, {0x87b9, 0x00a6}, {0x87ba, 0x0000},
3768{0x87bb, 0x00b7}, {0x87bc, 0x0012}, {0x87bd, 0x0070},
3769{0x87be, 0x00b6}, {0x87bf, 0x008f}, {0x87c0, 0x0072},
3770{0x87c1, 0x0026}, {0x87c2, 0x0003}, {0x87c3, 0x007e},
3771{0x87c4, 0x0087}, {0x87c5, 0x00fa}, {0x87c6, 0x00b6},
3772{0x87c7, 0x008f}, {0x87c8, 0x0075}, {0x87c9, 0x0026},
3773{0x87ca, 0x000a}, {0x87cb, 0x0018}, {0x87cc, 0x00ce},
3774{0x87cd, 0x008f}, {0x87ce, 0x0073}, {0x87cf, 0x00bd},
3775{0x87d0, 0x0089}, {0x87d1, 0x00d5}, {0x87d2, 0x007e},
3776{0x87d3, 0x0087}, {0x87d4, 0x00fa}, {0x87d5, 0x00b6},
3777{0x87d6, 0x008f}, {0x87d7, 0x0078}, {0x87d8, 0x0026},
3778{0x87d9, 0x000a}, {0x87da, 0x0018}, {0x87db, 0x00ce},
3779{0x87dc, 0x008f}, {0x87dd, 0x0076}, {0x87de, 0x00bd},
3780{0x87df, 0x0089}, {0x87e0, 0x00d5}, {0x87e1, 0x007e},
3781{0x87e2, 0x0087}, {0x87e3, 0x00fa}, {0x87e4, 0x00b6},
3782{0x87e5, 0x008f}, {0x87e6, 0x007b}, {0x87e7, 0x0026},
3783{0x87e8, 0x000a}, {0x87e9, 0x0018}, {0x87ea, 0x00ce},
3784{0x87eb, 0x008f}, {0x87ec, 0x0079}, {0x87ed, 0x00bd},
3785{0x87ee, 0x0089}, {0x87ef, 0x00d5}, {0x87f0, 0x007e},
3786{0x87f1, 0x0087}, {0x87f2, 0x00fa}, {0x87f3, 0x0086},
3787{0x87f4, 0x0005}, {0x87f5, 0x0097}, {0x87f6, 0x0040},
3788{0x87f7, 0x007e}, {0x87f8, 0x0089}, {0x87f9, 0x006e},
3789{0x87fa, 0x00b6}, {0x87fb, 0x008f}, {0x87fc, 0x0075},
3790{0x87fd, 0x0081}, {0x87fe, 0x0007}, {0x87ff, 0x002e},
3791{0x8800, 0x00f2}, {0x8801, 0x00f6}, {0x8802, 0x0012},
3792{0x8803, 0x0006}, {0x8804, 0x00c4}, {0x8805, 0x00f8},
3793{0x8806, 0x001b}, {0x8807, 0x00b7}, {0x8808, 0x0012},
3794{0x8809, 0x0006}, {0x880a, 0x00b6}, {0x880b, 0x008f},
3795{0x880c, 0x0078}, {0x880d, 0x0081}, {0x880e, 0x0007},
3796{0x880f, 0x002e}, {0x8810, 0x00e2}, {0x8811, 0x0048},
3797{0x8812, 0x0048}, {0x8813, 0x0048}, {0x8814, 0x00f6},
3798{0x8815, 0x0012}, {0x8816, 0x0006}, {0x8817, 0x00c4},
3799{0x8818, 0x00c7}, {0x8819, 0x001b}, {0x881a, 0x00b7},
3800{0x881b, 0x0012}, {0x881c, 0x0006}, {0x881d, 0x00b6},
3801{0x881e, 0x008f}, {0x881f, 0x007b}, {0x8820, 0x0081},
3802{0x8821, 0x0007}, {0x8822, 0x002e}, {0x8823, 0x00cf},
3803{0x8824, 0x00f6}, {0x8825, 0x0012}, {0x8826, 0x0005},
3804{0x8827, 0x00c4}, {0x8828, 0x00f8}, {0x8829, 0x001b},
3805{0x882a, 0x00b7}, {0x882b, 0x0012}, {0x882c, 0x0005},
3806{0x882d, 0x0086}, {0x882e, 0x0000}, {0x882f, 0x00f6},
3807{0x8830, 0x008f}, {0x8831, 0x0071}, {0x8832, 0x00bd},
3808{0x8833, 0x0089}, {0x8834, 0x0094}, {0x8835, 0x0086},
3809{0x8836, 0x0001}, {0x8837, 0x00f6}, {0x8838, 0x008f},
3810{0x8839, 0x0074}, {0x883a, 0x00bd}, {0x883b, 0x0089},
3811{0x883c, 0x0094}, {0x883d, 0x0086}, {0x883e, 0x0002},
3812{0x883f, 0x00f6}, {0x8840, 0x008f}, {0x8841, 0x0077},
3813{0x8842, 0x00bd}, {0x8843, 0x0089}, {0x8844, 0x0094},
3814{0x8845, 0x0086}, {0x8846, 0x0003}, {0x8847, 0x00f6},
3815{0x8848, 0x008f}, {0x8849, 0x007a}, {0x884a, 0x00bd},
3816{0x884b, 0x0089}, {0x884c, 0x0094}, {0x884d, 0x00ce},
3817{0x884e, 0x008f}, {0x884f, 0x0070}, {0x8850, 0x00a6},
3818{0x8851, 0x0001}, {0x8852, 0x0081}, {0x8853, 0x0001},
3819{0x8854, 0x0027}, {0x8855, 0x0007}, {0x8856, 0x0081},
3820{0x8857, 0x0003}, {0x8858, 0x0027}, {0x8859, 0x0003},
3821{0x885a, 0x007e}, {0x885b, 0x0088}, {0x885c, 0x0066},
3822{0x885d, 0x00a6}, {0x885e, 0x0000}, {0x885f, 0x00b8},
3823{0x8860, 0x008f}, {0x8861, 0x0081}, {0x8862, 0x0084},
3824{0x8863, 0x0001}, {0x8864, 0x0026}, {0x8865, 0x000b},
3825{0x8866, 0x008c}, {0x8867, 0x008f}, {0x8868, 0x0079},
3826{0x8869, 0x002c}, {0x886a, 0x000e}, {0x886b, 0x0008},
3827{0x886c, 0x0008}, {0x886d, 0x0008}, {0x886e, 0x007e},
3828{0x886f, 0x0088}, {0x8870, 0x0050}, {0x8871, 0x00b6},
3829{0x8872, 0x0012}, {0x8873, 0x0004}, {0x8874, 0x008a},
3830{0x8875, 0x0040}, {0x8876, 0x00b7}, {0x8877, 0x0012},
3831{0x8878, 0x0004}, {0x8879, 0x00b6}, {0x887a, 0x0012},
3832{0x887b, 0x0004}, {0x887c, 0x0084}, {0x887d, 0x00fb},
3833{0x887e, 0x0084}, {0x887f, 0x00ef}, {0x8880, 0x00b7},
3834{0x8881, 0x0012}, {0x8882, 0x0004}, {0x8883, 0x00b6},
3835{0x8884, 0x0012}, {0x8885, 0x0007}, {0x8886, 0x0036},
3836{0x8887, 0x00b6}, {0x8888, 0x008f}, {0x8889, 0x007c},
3837{0x888a, 0x0048}, {0x888b, 0x0048}, {0x888c, 0x00b7},
3838{0x888d, 0x0012}, {0x888e, 0x0007}, {0x888f, 0x0086},
3839{0x8890, 0x0001}, {0x8891, 0x00ba}, {0x8892, 0x0012},
3840{0x8893, 0x0004}, {0x8894, 0x00b7}, {0x8895, 0x0012},
3841{0x8896, 0x0004}, {0x8897, 0x0001}, {0x8898, 0x0001},
3842{0x8899, 0x0001}, {0x889a, 0x0001}, {0x889b, 0x0001},
3843{0x889c, 0x0001}, {0x889d, 0x0086}, {0x889e, 0x00fe},
3844{0x889f, 0x00b4}, {0x88a0, 0x0012}, {0x88a1, 0x0004},
3845{0x88a2, 0x00b7}, {0x88a3, 0x0012}, {0x88a4, 0x0004},
3846{0x88a5, 0x0086}, {0x88a6, 0x0002}, {0x88a7, 0x00ba},
3847{0x88a8, 0x0012}, {0x88a9, 0x0004}, {0x88aa, 0x00b7},
3848{0x88ab, 0x0012}, {0x88ac, 0x0004}, {0x88ad, 0x0086},
3849{0x88ae, 0x00fd}, {0x88af, 0x00b4}, {0x88b0, 0x0012},
3850{0x88b1, 0x0004}, {0x88b2, 0x00b7}, {0x88b3, 0x0012},
3851{0x88b4, 0x0004}, {0x88b5, 0x0032}, {0x88b6, 0x00b7},
3852{0x88b7, 0x0012}, {0x88b8, 0x0007}, {0x88b9, 0x00b6},
3853{0x88ba, 0x0012}, {0x88bb, 0x0000}, {0x88bc, 0x0084},
3854{0x88bd, 0x0008}, {0x88be, 0x0081}, {0x88bf, 0x0008},
3855{0x88c0, 0x0027}, {0x88c1, 0x000f}, {0x88c2, 0x007c},
3856{0x88c3, 0x0082}, {0x88c4, 0x0008}, {0x88c5, 0x0026},
3857{0x88c6, 0x0007}, {0x88c7, 0x0086}, {0x88c8, 0x0076},
3858{0x88c9, 0x0097}, {0x88ca, 0x0040}, {0x88cb, 0x007e},
3859{0x88cc, 0x0089}, {0x88cd, 0x006e}, {0x88ce, 0x007e},
3860{0x88cf, 0x0086}, {0x88d0, 0x00ec}, {0x88d1, 0x00b6},
3861{0x88d2, 0x008f}, {0x88d3, 0x007f}, {0x88d4, 0x0081},
3862{0x88d5, 0x000f}, {0x88d6, 0x0027}, {0x88d7, 0x003c},
3863{0x88d8, 0x00bd}, {0x88d9, 0x00e6}, {0x88da, 0x00c7},
3864{0x88db, 0x00b7}, {0x88dc, 0x0012}, {0x88dd, 0x000d},
3865{0x88de, 0x00bd}, {0x88df, 0x00e6}, {0x88e0, 0x00cb},
3866{0x88e1, 0x00b6}, {0x88e2, 0x0012}, {0x88e3, 0x0004},
3867{0x88e4, 0x008a}, {0x88e5, 0x0020}, {0x88e6, 0x00b7},
3868{0x88e7, 0x0012}, {0x88e8, 0x0004}, {0x88e9, 0x00ce},
3869{0x88ea, 0x00ff}, {0x88eb, 0x00ff}, {0x88ec, 0x00b6},
3870{0x88ed, 0x0012}, {0x88ee, 0x0000}, {0x88ef, 0x0081},
3871{0x88f0, 0x000c}, {0x88f1, 0x0026}, {0x88f2, 0x0005},
3872{0x88f3, 0x0009}, {0x88f4, 0x0026}, {0x88f5, 0x00f6},
3873{0x88f6, 0x0027}, {0x88f7, 0x001c}, {0x88f8, 0x00b6},
3874{0x88f9, 0x0012}, {0x88fa, 0x0004}, {0x88fb, 0x0084},
3875{0x88fc, 0x00df}, {0x88fd, 0x00b7}, {0x88fe, 0x0012},
3876{0x88ff, 0x0004}, {0x8900, 0x0096}, {0x8901, 0x0083},
3877{0x8902, 0x0081}, {0x8903, 0x0007}, {0x8904, 0x002c},
3878{0x8905, 0x0005}, {0x8906, 0x007c}, {0x8907, 0x0000},
3879{0x8908, 0x0083}, {0x8909, 0x0020}, {0x890a, 0x0006},
3880{0x890b, 0x0096}, {0x890c, 0x0083}, {0x890d, 0x008b},
3881{0x890e, 0x0008}, {0x890f, 0x0097}, {0x8910, 0x0083},
3882{0x8911, 0x007e}, {0x8912, 0x0085}, {0x8913, 0x0041},
3883{0x8914, 0x007f}, {0x8915, 0x008f}, {0x8916, 0x007e},
3884{0x8917, 0x0086}, {0x8918, 0x0080}, {0x8919, 0x00b7},
3885{0x891a, 0x0012}, {0x891b, 0x000c}, {0x891c, 0x0086},
3886{0x891d, 0x0001}, {0x891e, 0x00b7}, {0x891f, 0x008f},
3887{0x8920, 0x007d}, {0x8921, 0x00b6}, {0x8922, 0x0012},
3888{0x8923, 0x000c}, {0x8924, 0x0084}, {0x8925, 0x007f},
3889{0x8926, 0x00b7}, {0x8927, 0x0012}, {0x8928, 0x000c},
3890{0x8929, 0x008a}, {0x892a, 0x0080}, {0x892b, 0x00b7},
3891{0x892c, 0x0012}, {0x892d, 0x000c}, {0x892e, 0x0086},
3892{0x892f, 0x000a}, {0x8930, 0x00bd}, {0x8931, 0x008a},
3893{0x8932, 0x0006}, {0x8933, 0x00b6}, {0x8934, 0x0012},
3894{0x8935, 0x000a}, {0x8936, 0x002a}, {0x8937, 0x0009},
3895{0x8938, 0x00b6}, {0x8939, 0x0012}, {0x893a, 0x000c},
3896{0x893b, 0x00ba}, {0x893c, 0x008f}, {0x893d, 0x007d},
3897{0x893e, 0x00b7}, {0x893f, 0x0012}, {0x8940, 0x000c},
3898{0x8941, 0x00b6}, {0x8942, 0x008f}, {0x8943, 0x007e},
3899{0x8944, 0x0081}, {0x8945, 0x0060}, {0x8946, 0x0027},
3900{0x8947, 0x001a}, {0x8948, 0x008b}, {0x8949, 0x0020},
3901{0x894a, 0x00b7}, {0x894b, 0x008f}, {0x894c, 0x007e},
3902{0x894d, 0x00b6}, {0x894e, 0x0012}, {0x894f, 0x000c},
3903{0x8950, 0x0084}, {0x8951, 0x009f}, {0x8952, 0x00ba},
3904{0x8953, 0x008f}, {0x8954, 0x007e}, {0x8955, 0x00b7},
3905{0x8956, 0x0012}, {0x8957, 0x000c}, {0x8958, 0x00b6},
3906{0x8959, 0x008f}, {0x895a, 0x007d}, {0x895b, 0x0048},
3907{0x895c, 0x00b7}, {0x895d, 0x008f}, {0x895e, 0x007d},
3908{0x895f, 0x007e}, {0x8960, 0x0089}, {0x8961, 0x0021},
3909{0x8962, 0x00b6}, {0x8963, 0x0012}, {0x8964, 0x0004},
3910{0x8965, 0x008a}, {0x8966, 0x0020}, {0x8967, 0x00b7},
3911{0x8968, 0x0012}, {0x8969, 0x0004}, {0x896a, 0x00bd},
3912{0x896b, 0x008a}, {0x896c, 0x000a}, {0x896d, 0x004f},
3913{0x896e, 0x0039}, {0x896f, 0x00a6}, {0x8970, 0x0000},
3914{0x8971, 0x0018}, {0x8972, 0x00a7}, {0x8973, 0x0000},
3915{0x8974, 0x0008}, {0x8975, 0x0018}, {0x8976, 0x0008},
3916{0x8977, 0x005a}, {0x8978, 0x0026}, {0x8979, 0x00f5},
3917{0x897a, 0x0039}, {0x897b, 0x0036}, {0x897c, 0x006c},
3918{0x897d, 0x0000}, {0x897e, 0x0032}, {0x897f, 0x00ba},
3919{0x8980, 0x008f}, {0x8981, 0x007f}, {0x8982, 0x00b7},
3920{0x8983, 0x008f}, {0x8984, 0x007f}, {0x8985, 0x00b6},
3921{0x8986, 0x0012}, {0x8987, 0x0009}, {0x8988, 0x0084},
3922{0x8989, 0x0003}, {0x898a, 0x00a7}, {0x898b, 0x0001},
3923{0x898c, 0x00b6}, {0x898d, 0x0012}, {0x898e, 0x0006},
3924{0x898f, 0x0084}, {0x8990, 0x003f}, {0x8991, 0x00a7},
3925{0x8992, 0x0002}, {0x8993, 0x0039}, {0x8994, 0x0036},
3926{0x8995, 0x0086}, {0x8996, 0x0003}, {0x8997, 0x00b7},
3927{0x8998, 0x008f}, {0x8999, 0x0080}, {0x899a, 0x0032},
3928{0x899b, 0x00c1}, {0x899c, 0x0000}, {0x899d, 0x0026},
3929{0x899e, 0x0006}, {0x899f, 0x00b7}, {0x89a0, 0x008f},
3930{0x89a1, 0x007c}, {0x89a2, 0x007e}, {0x89a3, 0x0089},
3931{0x89a4, 0x00c9}, {0x89a5, 0x00c1}, {0x89a6, 0x0001},
3932{0x89a7, 0x0027}, {0x89a8, 0x0018}, {0x89a9, 0x00c1},
3933{0x89aa, 0x0002}, {0x89ab, 0x0027}, {0x89ac, 0x000c},
3934{0x89ad, 0x00c1}, {0x89ae, 0x0003}, {0x89af, 0x0027},
3935{0x89b0, 0x0000}, {0x89b1, 0x00f6}, {0x89b2, 0x008f},
3936{0x89b3, 0x0080}, {0x89b4, 0x0005}, {0x89b5, 0x0005},
3937{0x89b6, 0x00f7}, {0x89b7, 0x008f}, {0x89b8, 0x0080},
3938{0x89b9, 0x00f6}, {0x89ba, 0x008f}, {0x89bb, 0x0080},
3939{0x89bc, 0x0005}, {0x89bd, 0x0005}, {0x89be, 0x00f7},
3940{0x89bf, 0x008f}, {0x89c0, 0x0080}, {0x89c1, 0x00f6},
3941{0x89c2, 0x008f}, {0x89c3, 0x0080}, {0x89c4, 0x0005},
3942{0x89c5, 0x0005}, {0x89c6, 0x00f7}, {0x89c7, 0x008f},
3943{0x89c8, 0x0080}, {0x89c9, 0x00f6}, {0x89ca, 0x008f},
3944{0x89cb, 0x0080}, {0x89cc, 0x0053}, {0x89cd, 0x00f4},
3945{0x89ce, 0x0012}, {0x89cf, 0x0007}, {0x89d0, 0x001b},
3946{0x89d1, 0x00b7}, {0x89d2, 0x0012}, {0x89d3, 0x0007},
3947{0x89d4, 0x0039}, {0x89d5, 0x00ce}, {0x89d6, 0x008f},
3948{0x89d7, 0x0070}, {0x89d8, 0x00a6}, {0x89d9, 0x0000},
3949{0x89da, 0x0018}, {0x89db, 0x00e6}, {0x89dc, 0x0000},
3950{0x89dd, 0x0018}, {0x89de, 0x00a7}, {0x89df, 0x0000},
3951{0x89e0, 0x00e7}, {0x89e1, 0x0000}, {0x89e2, 0x00a6},
3952{0x89e3, 0x0001}, {0x89e4, 0x0018}, {0x89e5, 0x00e6},
3953{0x89e6, 0x0001}, {0x89e7, 0x0018}, {0x89e8, 0x00a7},
3954{0x89e9, 0x0001}, {0x89ea, 0x00e7}, {0x89eb, 0x0001},
3955{0x89ec, 0x00a6}, {0x89ed, 0x0002}, {0x89ee, 0x0018},
3956{0x89ef, 0x00e6}, {0x89f0, 0x0002}, {0x89f1, 0x0018},
3957{0x89f2, 0x00a7}, {0x89f3, 0x0002}, {0x89f4, 0x00e7},
3958{0x89f5, 0x0002}, {0x89f6, 0x0039}, {0x89f7, 0x00a6},
3959{0x89f8, 0x0000}, {0x89f9, 0x0084}, {0x89fa, 0x0007},
3960{0x89fb, 0x00e6}, {0x89fc, 0x0000}, {0x89fd, 0x00c4},
3961{0x89fe, 0x0038}, {0x89ff, 0x0054}, {0x8a00, 0x0054},
3962{0x8a01, 0x0054}, {0x8a02, 0x001b}, {0x8a03, 0x00a7},
3963{0x8a04, 0x0000}, {0x8a05, 0x0039}, {0x8a06, 0x004a},
3964{0x8a07, 0x0026}, {0x8a08, 0x00fd}, {0x8a09, 0x0039},
3965{0x8a0a, 0x0096}, {0x8a0b, 0x0022}, {0x8a0c, 0x0084},
3966{0x8a0d, 0x000f}, {0x8a0e, 0x0097}, {0x8a0f, 0x0022},
3967{0x8a10, 0x0086}, {0x8a11, 0x0001}, {0x8a12, 0x00b7},
3968{0x8a13, 0x008f}, {0x8a14, 0x0070}, {0x8a15, 0x00b6},
3969{0x8a16, 0x0012}, {0x8a17, 0x0007}, {0x8a18, 0x00b7},
3970{0x8a19, 0x008f}, {0x8a1a, 0x0071}, {0x8a1b, 0x00f6},
3971{0x8a1c, 0x0012}, {0x8a1d, 0x000c}, {0x8a1e, 0x00c4},
3972{0x8a1f, 0x000f}, {0x8a20, 0x00c8}, {0x8a21, 0x000f},
3973{0x8a22, 0x00f7}, {0x8a23, 0x008f}, {0x8a24, 0x0072},
3974{0x8a25, 0x00f6}, {0x8a26, 0x008f}, {0x8a27, 0x0072},
3975{0x8a28, 0x00b6}, {0x8a29, 0x008f}, {0x8a2a, 0x0071},
3976{0x8a2b, 0x0084}, {0x8a2c, 0x0003}, {0x8a2d, 0x0027},
3977{0x8a2e, 0x0014}, {0x8a2f, 0x0081}, {0x8a30, 0x0001},
3978{0x8a31, 0x0027}, {0x8a32, 0x001c}, {0x8a33, 0x0081},
3979{0x8a34, 0x0002}, {0x8a35, 0x0027}, {0x8a36, 0x0024},
3980{0x8a37, 0x00f4}, {0x8a38, 0x008f}, {0x8a39, 0x0070},
3981{0x8a3a, 0x0027}, {0x8a3b, 0x002a}, {0x8a3c, 0x0096},
3982{0x8a3d, 0x0022}, {0x8a3e, 0x008a}, {0x8a3f, 0x0080},
3983{0x8a40, 0x007e}, {0x8a41, 0x008a}, {0x8a42, 0x0064},
3984{0x8a43, 0x00f4}, {0x8a44, 0x008f}, {0x8a45, 0x0070},
3985{0x8a46, 0x0027}, {0x8a47, 0x001e}, {0x8a48, 0x0096},
3986{0x8a49, 0x0022}, {0x8a4a, 0x008a}, {0x8a4b, 0x0010},
3987{0x8a4c, 0x007e}, {0x8a4d, 0x008a}, {0x8a4e, 0x0064},
3988{0x8a4f, 0x00f4}, {0x8a50, 0x008f}, {0x8a51, 0x0070},
3989{0x8a52, 0x0027}, {0x8a53, 0x0012}, {0x8a54, 0x0096},
3990{0x8a55, 0x0022}, {0x8a56, 0x008a}, {0x8a57, 0x0020},
3991{0x8a58, 0x007e}, {0x8a59, 0x008a}, {0x8a5a, 0x0064},
3992{0x8a5b, 0x00f4}, {0x8a5c, 0x008f}, {0x8a5d, 0x0070},
3993{0x8a5e, 0x0027}, {0x8a5f, 0x0006}, {0x8a60, 0x0096},
3994{0x8a61, 0x0022}, {0x8a62, 0x008a}, {0x8a63, 0x0040},
3995{0x8a64, 0x0097}, {0x8a65, 0x0022}, {0x8a66, 0x0074},
3996{0x8a67, 0x008f}, {0x8a68, 0x0071}, {0x8a69, 0x0074},
3997{0x8a6a, 0x008f}, {0x8a6b, 0x0071}, {0x8a6c, 0x0078},
3998{0x8a6d, 0x008f}, {0x8a6e, 0x0070}, {0x8a6f, 0x00b6},
3999{0x8a70, 0x008f}, {0x8a71, 0x0070}, {0x8a72, 0x0085},
4000{0x8a73, 0x0010}, {0x8a74, 0x0027}, {0x8a75, 0x00af},
4001{0x8a76, 0x00d6}, {0x8a77, 0x0022}, {0x8a78, 0x00c4},
4002{0x8a79, 0x0010}, {0x8a7a, 0x0058}, {0x8a7b, 0x00b6},
4003{0x8a7c, 0x0012}, {0x8a7d, 0x0070}, {0x8a7e, 0x0081},
4004{0x8a7f, 0x00e4}, {0x8a80, 0x0027}, {0x8a81, 0x0036},
4005{0x8a82, 0x0081}, {0x8a83, 0x00e1}, {0x8a84, 0x0026},
4006{0x8a85, 0x000c}, {0x8a86, 0x0096}, {0x8a87, 0x0022},
4007{0x8a88, 0x0084}, {0x8a89, 0x0020}, {0x8a8a, 0x0044},
4008{0x8a8b, 0x001b}, {0x8a8c, 0x00d6}, {0x8a8d, 0x0022},
4009{0x8a8e, 0x00c4}, {0x8a8f, 0x00cf}, {0x8a90, 0x0020},
4010{0x8a91, 0x0023}, {0x8a92, 0x0058}, {0x8a93, 0x0081},
4011{0x8a94, 0x00c6}, {0x8a95, 0x0026}, {0x8a96, 0x000d},
4012{0x8a97, 0x0096}, {0x8a98, 0x0022}, {0x8a99, 0x0084},
4013{0x8a9a, 0x0040}, {0x8a9b, 0x0044}, {0x8a9c, 0x0044},
4014{0x8a9d, 0x001b}, {0x8a9e, 0x00d6}, {0x8a9f, 0x0022},
4015{0x8aa0, 0x00c4}, {0x8aa1, 0x00af}, {0x8aa2, 0x0020},
4016{0x8aa3, 0x0011}, {0x8aa4, 0x0058}, {0x8aa5, 0x0081},
4017{0x8aa6, 0x0027}, {0x8aa7, 0x0026}, {0x8aa8, 0x000f},
4018{0x8aa9, 0x0096}, {0x8aaa, 0x0022}, {0x8aab, 0x0084},
4019{0x8aac, 0x0080}, {0x8aad, 0x0044}, {0x8aae, 0x0044},
4020{0x8aaf, 0x0044}, {0x8ab0, 0x001b}, {0x8ab1, 0x00d6},
4021{0x8ab2, 0x0022}, {0x8ab3, 0x00c4}, {0x8ab4, 0x006f},
4022{0x8ab5, 0x001b}, {0x8ab6, 0x0097}, {0x8ab7, 0x0022},
4023{0x8ab8, 0x0039}, {0x8ab9, 0x0027}, {0x8aba, 0x000c},
4024{0x8abb, 0x007c}, {0x8abc, 0x0082}, {0x8abd, 0x0006},
4025{0x8abe, 0x00bd}, {0x8abf, 0x00d9}, {0x8ac0, 0x00ed},
4026{0x8ac1, 0x00b6}, {0x8ac2, 0x0082}, {0x8ac3, 0x0007},
4027{0x8ac4, 0x007e}, {0x8ac5, 0x008a}, {0x8ac6, 0x00b9},
4028{0x8ac7, 0x007f}, {0x8ac8, 0x0082}, {0x8ac9, 0x0006},
4029{0x8aca, 0x0039}, { 0x0, 0x0 }
4030};
4031#endif
4032
4033
4034/* phy types */
4035#define CAS_PHY_UNKNOWN 0x00
4036#define CAS_PHY_SERDES 0x01
4037#define CAS_PHY_MII_MDIO0 0x02
4038#define CAS_PHY_MII_MDIO1 0x04
4039#define CAS_PHY_MII(x) ((x) & (CAS_PHY_MII_MDIO0 | CAS_PHY_MII_MDIO1))
4040
4041/* _RING_INDEX is the index for the ring sizes to be used. _RING_SIZE
4042 * is the actual size. the default index for the various rings is
4043 * 8. NOTE: there a bunch of alignment constraints for the rings. to
4044 * deal with that, i just allocate rings to create the desired
4045 * alignment. here are the constraints:
4046 * RX DESC and COMP rings must be 8KB aligned
4047 * TX DESC must be 2KB aligned.
4048 * if you change the numbers, be cognizant of how the alignment will change
4049 * in INIT_BLOCK as well.
4050 */
4051
4052#define DESC_RING_I_TO_S(x) (32*(1 << (x)))
4053#define COMP_RING_I_TO_S(x) (128*(1 << (x)))
4054#define TX_DESC_RING_INDEX 4 /* 512 = 8k */
4055#define RX_DESC_RING_INDEX 4 /* 512 = 8k */
4056#define RX_COMP_RING_INDEX 4 /* 2048 = 64k: should be 4x rx ring size */
4057
4058#if (TX_DESC_RING_INDEX > 8) || (TX_DESC_RING_INDEX < 0)
4059#error TX_DESC_RING_INDEX must be between 0 and 8
4060#endif
4061
4062#if (RX_DESC_RING_INDEX > 8) || (RX_DESC_RING_INDEX < 0)
4063#error RX_DESC_RING_INDEX must be between 0 and 8
4064#endif
4065
4066#if (RX_COMP_RING_INDEX > 8) || (RX_COMP_RING_INDEX < 0)
4067#error RX_COMP_RING_INDEX must be between 0 and 8
4068#endif
4069
4070#define N_TX_RINGS MAX_TX_RINGS /* for QoS */
4071#define N_TX_RINGS_MASK MAX_TX_RINGS_MASK
4072#define N_RX_DESC_RINGS MAX_RX_DESC_RINGS /* 1 for ipsec */
4073#define N_RX_COMP_RINGS 0x1 /* for mult. PCI interrupts */
4074
4075/* number of flows that can go through re-assembly */
4076#define N_RX_FLOWS 64
4077
4078#define TX_DESC_RING_SIZE DESC_RING_I_TO_S(TX_DESC_RING_INDEX)
4079#define RX_DESC_RING_SIZE DESC_RING_I_TO_S(RX_DESC_RING_INDEX)
4080#define RX_COMP_RING_SIZE COMP_RING_I_TO_S(RX_COMP_RING_INDEX)
4081#define TX_DESC_RINGN_INDEX(x) TX_DESC_RING_INDEX
4082#define RX_DESC_RINGN_INDEX(x) RX_DESC_RING_INDEX
4083#define RX_COMP_RINGN_INDEX(x) RX_COMP_RING_INDEX
4084#define TX_DESC_RINGN_SIZE(x) TX_DESC_RING_SIZE
4085#define RX_DESC_RINGN_SIZE(x) RX_DESC_RING_SIZE
4086#define RX_COMP_RINGN_SIZE(x) RX_COMP_RING_SIZE
4087
4088/* convert values */
4089#define CAS_BASE(x, y) (((y) << (x ## _SHIFT)) & (x ## _MASK))
4090#define CAS_VAL(x, y) (((y) & (x ## _MASK)) >> (x ## _SHIFT))
4091#define CAS_TX_RINGN_BASE(y) ((TX_DESC_RINGN_INDEX(y) << \
4092 TX_CFG_DESC_RINGN_SHIFT(y)) & \
4093 TX_CFG_DESC_RINGN_MASK(y))
4094
4095/* min is 2k, but we can't do jumbo frames unless it's at least 8k */
4096#define CAS_MIN_PAGE_SHIFT 11 /* 2048 */
4097#define CAS_JUMBO_PAGE_SHIFT 13 /* 8192 */
4098#define CAS_MAX_PAGE_SHIFT 14 /* 16384 */
4099
4100#define TX_DESC_BUFLEN_MASK 0x0000000000003FFFULL /* buffer length in
4101 bytes. 0 - 9256 */
4102#define TX_DESC_BUFLEN_SHIFT 0
4103#define TX_DESC_CSUM_START_MASK 0x00000000001F8000ULL /* checksum start. #
4104 of bytes to be
4105 skipped before
4106 csum calc begins.
4107 value must be
4108 even */
4109#define TX_DESC_CSUM_START_SHIFT 15
4110#define TX_DESC_CSUM_STUFF_MASK 0x000000001FE00000ULL /* checksum stuff.
4111 byte offset w/in
4112 the pkt for the
4113 1st csum byte.
4114 must be > 8 */
4115#define TX_DESC_CSUM_STUFF_SHIFT 21
4116#define TX_DESC_CSUM_EN 0x0000000020000000ULL /* enable checksum */
4117#define TX_DESC_EOF 0x0000000040000000ULL /* end of frame */
4118#define TX_DESC_SOF 0x0000000080000000ULL /* start of frame */
4119#define TX_DESC_INTME 0x0000000100000000ULL /* interrupt me */
4120#define TX_DESC_NO_CRC 0x0000000200000000ULL /* debugging only.
4121 CRC will not be
4122 inserted into
4123 outgoing frame. */
4124struct cas_tx_desc {
4125 u64 control;
4126 u64 buffer;
4127};
4128
4129/* descriptor ring for free buffers contains page-sized buffers. the index
4130 * value is not used by the hw in any way. it's just stored and returned in
4131 * the completion ring.
4132 */
4133struct cas_rx_desc {
4134 u64 index;
4135 u64 buffer;
4136};
4137
4138/* received packets are put on the completion ring. */
4139/* word 1 */
4140#define RX_COMP1_DATA_SIZE_MASK 0x0000000007FFE000ULL
4141#define RX_COMP1_DATA_SIZE_SHIFT 13
4142#define RX_COMP1_DATA_OFF_MASK 0x000001FFF8000000ULL
4143#define RX_COMP1_DATA_OFF_SHIFT 27
4144#define RX_COMP1_DATA_INDEX_MASK 0x007FFE0000000000ULL
4145#define RX_COMP1_DATA_INDEX_SHIFT 41
4146#define RX_COMP1_SKIP_MASK 0x0180000000000000ULL
4147#define RX_COMP1_SKIP_SHIFT 55
4148#define RX_COMP1_RELEASE_NEXT 0x0200000000000000ULL
4149#define RX_COMP1_SPLIT_PKT 0x0400000000000000ULL
4150#define RX_COMP1_RELEASE_FLOW 0x0800000000000000ULL
4151#define RX_COMP1_RELEASE_DATA 0x1000000000000000ULL
4152#define RX_COMP1_RELEASE_HDR 0x2000000000000000ULL
4153#define RX_COMP1_TYPE_MASK 0xC000000000000000ULL
4154#define RX_COMP1_TYPE_SHIFT 62
4155
4156/* word 2 */
4157#define RX_COMP2_NEXT_INDEX_MASK 0x00000007FFE00000ULL
4158#define RX_COMP2_NEXT_INDEX_SHIFT 21
4159#define RX_COMP2_HDR_SIZE_MASK 0x00000FF800000000ULL
4160#define RX_COMP2_HDR_SIZE_SHIFT 35
4161#define RX_COMP2_HDR_OFF_MASK 0x0003F00000000000ULL
4162#define RX_COMP2_HDR_OFF_SHIFT 44
4163#define RX_COMP2_HDR_INDEX_MASK 0xFFFC000000000000ULL
4164#define RX_COMP2_HDR_INDEX_SHIFT 50
4165
4166/* word 3 */
4167#define RX_COMP3_SMALL_PKT 0x0000000000000001ULL
4168#define RX_COMP3_JUMBO_PKT 0x0000000000000002ULL
4169#define RX_COMP3_JUMBO_HDR_SPLIT_EN 0x0000000000000004ULL
4170#define RX_COMP3_CSUM_START_MASK 0x000000000007F000ULL
4171#define RX_COMP3_CSUM_START_SHIFT 12
4172#define RX_COMP3_FLOWID_MASK 0x0000000001F80000ULL
4173#define RX_COMP3_FLOWID_SHIFT 19
4174#define RX_COMP3_OPCODE_MASK 0x000000000E000000ULL
4175#define RX_COMP3_OPCODE_SHIFT 25
4176#define RX_COMP3_FORCE_FLAG 0x0000000010000000ULL
4177#define RX_COMP3_NO_ASSIST 0x0000000020000000ULL
4178#define RX_COMP3_LOAD_BAL_MASK 0x000001F800000000ULL
4179#define RX_COMP3_LOAD_BAL_SHIFT 35
4180#define RX_PLUS_COMP3_ENC_PKT 0x0000020000000000ULL /* cas+ */
4181#define RX_COMP3_L3_HEAD_OFF_MASK 0x0000FE0000000000ULL /* cas */
4182#define RX_COMP3_L3_HEAD_OFF_SHIFT 41
4183#define RX_PLUS_COMP_L3_HEAD_OFF_MASK 0x0000FC0000000000ULL /* cas+ */
4184#define RX_PLUS_COMP_L3_HEAD_OFF_SHIFT 42
4185#define RX_COMP3_SAP_MASK 0xFFFF000000000000ULL
4186#define RX_COMP3_SAP_SHIFT 48
4187
4188/* word 4 */
4189#define RX_COMP4_TCP_CSUM_MASK 0x000000000000FFFFULL
4190#define RX_COMP4_TCP_CSUM_SHIFT 0
4191#define RX_COMP4_PKT_LEN_MASK 0x000000003FFF0000ULL
4192#define RX_COMP4_PKT_LEN_SHIFT 16
4193#define RX_COMP4_PERFECT_MATCH_MASK 0x00000003C0000000ULL
4194#define RX_COMP4_PERFECT_MATCH_SHIFT 30
4195#define RX_COMP4_ZERO 0x0000080000000000ULL
4196#define RX_COMP4_HASH_VAL_MASK 0x0FFFF00000000000ULL
4197#define RX_COMP4_HASH_VAL_SHIFT 44
4198#define RX_COMP4_HASH_PASS 0x1000000000000000ULL
4199#define RX_COMP4_BAD 0x4000000000000000ULL
4200#define RX_COMP4_LEN_MISMATCH 0x8000000000000000ULL
4201
4202/* we encode the following: ring/index/release. only 14 bits
4203 * are usable.
4204 * NOTE: the encoding is dependent upon RX_DESC_RING_SIZE and
4205 * MAX_RX_DESC_RINGS. */
4206#define RX_INDEX_NUM_MASK 0x0000000000000FFFULL
4207#define RX_INDEX_NUM_SHIFT 0
4208#define RX_INDEX_RING_MASK 0x0000000000001000ULL
4209#define RX_INDEX_RING_SHIFT 12
4210#define RX_INDEX_RELEASE 0x0000000000002000ULL
4211
4212struct cas_rx_comp {
4213 u64 word1;
4214 u64 word2;
4215 u64 word3;
4216 u64 word4;
4217};
4218
4219enum link_state {
4220 link_down = 0, /* No link, will retry */
4221 link_aneg, /* Autoneg in progress */
4222 link_force_try, /* Try Forced link speed */
4223 link_force_ret, /* Forced mode worked, retrying autoneg */
4224 link_force_ok, /* Stay in forced mode */
4225 link_up /* Link is up */
4226};
4227
4228typedef struct cas_page {
4229 struct list_head list;
4230 struct page *buffer;
4231 dma_addr_t dma_addr;
4232 int used;
4233} cas_page_t;
4234
4235
4236/* some alignment constraints:
4237 * TX DESC, RX DESC, and RX COMP must each be 8K aligned.
4238 * TX COMPWB must be 8-byte aligned.
4239 * to accomplish this, here's what we do:
4240 *
4241 * INIT_BLOCK_RX_COMP = 64k (already aligned)
4242 * INIT_BLOCK_RX_DESC = 8k
4243 * INIT_BLOCK_TX = 8k
4244 * INIT_BLOCK_RX1_DESC = 8k
4245 * TX COMPWB
4246 */
4247#define INIT_BLOCK_TX (TX_DESC_RING_SIZE)
4248#define INIT_BLOCK_RX_DESC (RX_DESC_RING_SIZE)
4249#define INIT_BLOCK_RX_COMP (RX_COMP_RING_SIZE)
4250
4251struct cas_init_block {
4252 struct cas_rx_comp rxcs[N_RX_COMP_RINGS][INIT_BLOCK_RX_COMP];
4253 struct cas_rx_desc rxds[N_RX_DESC_RINGS][INIT_BLOCK_RX_DESC];
4254 struct cas_tx_desc txds[N_TX_RINGS][INIT_BLOCK_TX];
4255 u64 tx_compwb;
4256};
4257
4258/* tiny buffers to deal with target abort issue. we allocate a bit
4259 * over so that we don't have target abort issues with these buffers
4260 * as well.
4261 */
4262#define TX_TINY_BUF_LEN 0x100
4263#define TX_TINY_BUF_BLOCK ((INIT_BLOCK_TX + 1)*TX_TINY_BUF_LEN)
4264
4265struct cas_tiny_count {
4266 int nbufs;
4267 int used;
4268};
4269
4270struct cas {
4271 spinlock_t lock; /* for most bits */
4272 spinlock_t tx_lock[N_TX_RINGS]; /* tx bits */
4273 spinlock_t stat_lock[N_TX_RINGS + 1]; /* for stat gathering */
4274 spinlock_t rx_inuse_lock; /* rx inuse list */
4275 spinlock_t rx_spare_lock; /* rx spare list */
4276
4277 void __iomem *regs;
4278 int tx_new[N_TX_RINGS], tx_old[N_TX_RINGS];
4279 int rx_old[N_RX_DESC_RINGS];
4280 int rx_cur[N_RX_COMP_RINGS], rx_new[N_RX_COMP_RINGS];
4281 int rx_last[N_RX_DESC_RINGS];
4282
4283 /* Set when chip is actually in operational state
4284 * (ie. not power managed) */
4285 int hw_running;
4286 int opened;
4287 struct semaphore pm_sem; /* open/close/suspend/resume */
4288
4289 struct cas_init_block *init_block;
4290 struct cas_tx_desc *init_txds[MAX_TX_RINGS];
4291 struct cas_rx_desc *init_rxds[MAX_RX_DESC_RINGS];
4292 struct cas_rx_comp *init_rxcs[MAX_RX_COMP_RINGS];
4293
4294 /* we use sk_buffs for tx and pages for rx. the rx skbuffs
4295 * are there for flow re-assembly. */
4296 struct sk_buff *tx_skbs[N_TX_RINGS][TX_DESC_RING_SIZE];
4297 struct sk_buff_head rx_flows[N_RX_FLOWS];
4298 cas_page_t *rx_pages[N_RX_DESC_RINGS][RX_DESC_RING_SIZE];
4299 struct list_head rx_spare_list, rx_inuse_list;
4300 int rx_spares_needed;
4301
4302 /* for small packets when copying would be quicker than
4303 mapping */
4304 struct cas_tiny_count tx_tiny_use[N_TX_RINGS][TX_DESC_RING_SIZE];
4305 u8 *tx_tiny_bufs[N_TX_RINGS];
4306
4307 u32 msg_enable;
4308
4309 /* N_TX_RINGS must be >= N_RX_DESC_RINGS */
4310 struct net_device_stats net_stats[N_TX_RINGS + 1];
4311
4312 u32 pci_cfg[64 >> 2];
4313 u8 pci_revision;
4314
4315 int phy_type;
4316 int phy_addr;
4317 u32 phy_id;
4318#define CAS_FLAG_1000MB_CAP 0x00000001
4319#define CAS_FLAG_REG_PLUS 0x00000002
4320#define CAS_FLAG_TARGET_ABORT 0x00000004
4321#define CAS_FLAG_SATURN 0x00000008
4322#define CAS_FLAG_RXD_POST_MASK 0x000000F0
4323#define CAS_FLAG_RXD_POST_SHIFT 4
4324#define CAS_FLAG_RXD_POST(x) ((1 << (CAS_FLAG_RXD_POST_SHIFT + (x))) & \
4325 CAS_FLAG_RXD_POST_MASK)
4326#define CAS_FLAG_ENTROPY_DEV 0x00000100
4327#define CAS_FLAG_NO_HW_CSUM 0x00000200
4328 u32 cas_flags;
4329 int packet_min; /* minimum packet size */
4330 int tx_fifo_size;
4331 int rx_fifo_size;
4332 int rx_pause_off;
4333 int rx_pause_on;
4334 int crc_size; /* 4 if half-duplex */
4335
4336 int pci_irq_INTC;
4337 int min_frame_size; /* for tx fifo workaround */
4338
4339 /* page size allocation */
4340 int page_size;
4341 int page_order;
4342 int mtu_stride;
4343
4344 u32 mac_rx_cfg;
4345
4346 /* Autoneg & PHY control */
4347 int link_cntl;
4348 int link_fcntl;
4349 enum link_state lstate;
4350 struct timer_list link_timer;
4351 int timer_ticks;
4352 struct work_struct reset_task;
4353#if 0
4354 atomic_t reset_task_pending;
4355#else
4356 atomic_t reset_task_pending;
4357 atomic_t reset_task_pending_mtu;
4358 atomic_t reset_task_pending_spare;
4359 atomic_t reset_task_pending_all;
4360#endif
4361
4362#ifdef CONFIG_CASSINI_QGE_DEBUG
4363 atomic_t interrupt_seen; /* 1 if any interrupts are getting through */
4364#endif
4365
4366 /* Link-down problem workaround */
4367#define LINK_TRANSITION_UNKNOWN 0
4368#define LINK_TRANSITION_ON_FAILURE 1
4369#define LINK_TRANSITION_STILL_FAILED 2
4370#define LINK_TRANSITION_LINK_UP 3
4371#define LINK_TRANSITION_LINK_CONFIG 4
4372#define LINK_TRANSITION_LINK_DOWN 5
4373#define LINK_TRANSITION_REQUESTED_RESET 6
4374 int link_transition;
4375 int link_transition_jiffies_valid;
4376 unsigned long link_transition_jiffies;
4377
4378 /* Tuning */
4379 u8 orig_cacheline_size; /* value when loaded */
4380#define CAS_PREF_CACHELINE_SIZE 0x20 /* Minimum desired */
4381
4382 /* Diagnostic counters and state. */
4383 int casreg_len; /* reg-space size for dumping */
4384 u64 pause_entered;
4385 u16 pause_last_time_recvd;
4386
4387 dma_addr_t block_dvma, tx_tiny_dvma[N_TX_RINGS];
4388 struct pci_dev *pdev;
4389 struct net_device *dev;
4390};
4391
4392#define TX_DESC_NEXT(r, x) (((x) + 1) & (TX_DESC_RINGN_SIZE(r) - 1))
4393#define RX_DESC_ENTRY(r, x) ((x) & (RX_DESC_RINGN_SIZE(r) - 1))
4394#define RX_COMP_ENTRY(r, x) ((x) & (RX_COMP_RINGN_SIZE(r) - 1))
4395
4396#define TX_BUFF_COUNT(r, x, y) ((x) <= (y) ? ((y) - (x)) : \
4397 (TX_DESC_RINGN_SIZE(r) - (x) + (y)))
4398
4399#define TX_BUFFS_AVAIL(cp, i) ((cp)->tx_old[(i)] <= (cp)->tx_new[(i)] ? \
4400 (cp)->tx_old[(i)] + (TX_DESC_RINGN_SIZE(i) - 1) - (cp)->tx_new[(i)] : \
4401 (cp)->tx_old[(i)] - (cp)->tx_new[(i)] - 1)
4402
4403#define CAS_ALIGN(addr, align) \
4404 (((unsigned long) (addr) + ((align) - 1UL)) & ~((align) - 1))
4405
4406#define RX_FIFO_SIZE 16384
4407#define EXPANSION_ROM_SIZE 65536
4408
4409#define CAS_MC_EXACT_MATCH_SIZE 15
4410#define CAS_MC_HASH_SIZE 256
4411#define CAS_MC_HASH_MAX (CAS_MC_EXACT_MATCH_SIZE + \
4412 CAS_MC_HASH_SIZE)
4413
4414#define TX_TARGET_ABORT_LEN 0x20
4415#define RX_SWIVEL_OFF_VAL 0x2
4416#define RX_AE_FREEN_VAL(x) (RX_DESC_RINGN_SIZE(x) >> 1)
4417#define RX_AE_COMP_VAL (RX_COMP_RING_SIZE >> 1)
4418#define RX_BLANK_INTR_PKT_VAL 0x05
4419#define RX_BLANK_INTR_TIME_VAL 0x0F
4420#define HP_TCP_THRESH_VAL 1530 /* reduce to enable reassembly */
4421
4422#define RX_SPARE_COUNT (RX_DESC_RING_SIZE >> 1)
4423#define RX_SPARE_RECOVER_VAL (RX_SPARE_COUNT >> 2)
4424
4425#endif /* _CASSINI_H */
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index cdc07ccd7332..a6078ad9b654 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -140,6 +140,7 @@
140 140
141#include <asm/system.h> 141#include <asm/system.h>
142#include <asm/io.h> 142#include <asm/io.h>
143#include <asm/irq.h>
143#if ALLOW_DMA 144#if ALLOW_DMA
144#include <asm/dma.h> 145#include <asm/dma.h>
145#endif 146#endif
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index fbf1c06ec5c1..40887f09b681 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -903,8 +903,8 @@ static void mdio_write(struct net_device *netdev, int addr, int reg, int data)
903 903
904static void e100_get_defaults(struct nic *nic) 904static void e100_get_defaults(struct nic *nic)
905{ 905{
906 struct param_range rfds = { .min = 16, .max = 256, .count = 256 }; 906 struct param_range rfds = { .min = 16, .max = 256, .count = 64 };
907 struct param_range cbs = { .min = 64, .max = 256, .count = 128 }; 907 struct param_range cbs = { .min = 64, .max = 256, .count = 64 };
908 908
909 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id); 909 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id);
910 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */ 910 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */
@@ -1007,213 +1007,25 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1007 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]); 1007 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
1008} 1008}
1009 1009
1010/********************************************************/
1011/* Micro code for 8086:1229 Rev 8 */
1012/********************************************************/
1013
1014/* Parameter values for the D101M B-step */
1015#define D101M_CPUSAVER_TIMER_DWORD 78
1016#define D101M_CPUSAVER_BUNDLE_DWORD 65
1017#define D101M_CPUSAVER_MIN_SIZE_DWORD 126
1018
1019#define D101M_B_RCVBUNDLE_UCODE \
1020{\
10210x00550215, 0xFFFF0437, 0xFFFFFFFF, 0x06A70789, 0xFFFFFFFF, 0x0558FFFF, \
10220x000C0001, 0x00101312, 0x000C0008, 0x00380216, \
10230x0010009C, 0x00204056, 0x002380CC, 0x00380056, \
10240x0010009C, 0x00244C0B, 0x00000800, 0x00124818, \
10250x00380438, 0x00000000, 0x00140000, 0x00380555, \
10260x00308000, 0x00100662, 0x00100561, 0x000E0408, \
10270x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10280x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10290x000C007E, 0x00222C21, 0x000C0002, 0x00103093, \
10300x00380C7A, 0x00080000, 0x00103090, 0x00380C7A, \
10310x00000000, 0x00000000, 0x00000000, 0x00000000, \
10320x0010009C, 0x00244C2D, 0x00010004, 0x00041000, \
10330x003A0437, 0x00044010, 0x0038078A, 0x00000000, \
10340x00100099, 0x00206C7A, 0x0010009C, 0x00244C48, \
10350x00130824, 0x000C0001, 0x00101213, 0x00260C75, \
10360x00041000, 0x00010004, 0x00130826, 0x000C0006, \
10370x002206A8, 0x0013C926, 0x00101313, 0x003806A8, \
10380x00000000, 0x00000000, 0x00000000, 0x00000000, \
10390x00000000, 0x00000000, 0x00000000, 0x00000000, \
10400x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10410x00101210, 0x00380C34, 0x00000000, 0x00000000, \
10420x0021155B, 0x00100099, 0x00206559, 0x0010009C, \
10430x00244559, 0x00130836, 0x000C0000, 0x00220C62, \
10440x000C0001, 0x00101B13, 0x00229C0E, 0x00210C0E, \
10450x00226C0E, 0x00216C0E, 0x0022FC0E, 0x00215C0E, \
10460x00214C0E, 0x00380555, 0x00010004, 0x00041000, \
10470x00278C67, 0x00040800, 0x00018100, 0x003A0437, \
10480x00130826, 0x000C0001, 0x00220559, 0x00101313, \
10490x00380559, 0x00000000, 0x00000000, 0x00000000, \
10500x00000000, 0x00000000, 0x00000000, 0x00000000, \
10510x00000000, 0x00130831, 0x0010090B, 0x00124813, \
10520x000CFF80, 0x002606AB, 0x00041000, 0x00010004, \
10530x003806A8, 0x00000000, 0x00000000, 0x00000000, \
1054}
1055
1056/********************************************************/
1057/* Micro code for 8086:1229 Rev 9 */
1058/********************************************************/
1059
1060/* Parameter values for the D101S */
1061#define D101S_CPUSAVER_TIMER_DWORD 78
1062#define D101S_CPUSAVER_BUNDLE_DWORD 67
1063#define D101S_CPUSAVER_MIN_SIZE_DWORD 128
1064
1065#define D101S_RCVBUNDLE_UCODE \
1066{\
10670x00550242, 0xFFFF047E, 0xFFFFFFFF, 0x06FF0818, 0xFFFFFFFF, 0x05A6FFFF, \
10680x000C0001, 0x00101312, 0x000C0008, 0x00380243, \
10690x0010009C, 0x00204056, 0x002380D0, 0x00380056, \
10700x0010009C, 0x00244F8B, 0x00000800, 0x00124818, \
10710x0038047F, 0x00000000, 0x00140000, 0x003805A3, \
10720x00308000, 0x00100610, 0x00100561, 0x000E0408, \
10730x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10740x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10750x000C007E, 0x00222FA1, 0x000C0002, 0x00103093, \
10760x00380F90, 0x00080000, 0x00103090, 0x00380F90, \
10770x00000000, 0x00000000, 0x00000000, 0x00000000, \
10780x0010009C, 0x00244FAD, 0x00010004, 0x00041000, \
10790x003A047E, 0x00044010, 0x00380819, 0x00000000, \
10800x00100099, 0x00206FFD, 0x0010009A, 0x0020AFFD, \
10810x0010009C, 0x00244FC8, 0x00130824, 0x000C0001, \
10820x00101213, 0x00260FF7, 0x00041000, 0x00010004, \
10830x00130826, 0x000C0006, 0x00220700, 0x0013C926, \
10840x00101313, 0x00380700, 0x00000000, 0x00000000, \
10850x00000000, 0x00000000, 0x00000000, 0x00000000, \
10860x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10870x00101210, 0x00380FB6, 0x00000000, 0x00000000, \
10880x002115A9, 0x00100099, 0x002065A7, 0x0010009A, \
10890x0020A5A7, 0x0010009C, 0x002445A7, 0x00130836, \
10900x000C0000, 0x00220FE4, 0x000C0001, 0x00101B13, \
10910x00229F8E, 0x00210F8E, 0x00226F8E, 0x00216F8E, \
10920x0022FF8E, 0x00215F8E, 0x00214F8E, 0x003805A3, \
10930x00010004, 0x00041000, 0x00278FE9, 0x00040800, \
10940x00018100, 0x003A047E, 0x00130826, 0x000C0001, \
10950x002205A7, 0x00101313, 0x003805A7, 0x00000000, \
10960x00000000, 0x00000000, 0x00000000, 0x00000000, \
10970x00000000, 0x00000000, 0x00000000, 0x00130831, \
10980x0010090B, 0x00124813, 0x000CFF80, 0x00260703, \
10990x00041000, 0x00010004, 0x00380700 \
1100}
1101
1102/********************************************************/
1103/* Micro code for the 8086:1229 Rev F/10 */
1104/********************************************************/
1105
1106/* Parameter values for the D102 E-step */
1107#define D102_E_CPUSAVER_TIMER_DWORD 42
1108#define D102_E_CPUSAVER_BUNDLE_DWORD 54
1109#define D102_E_CPUSAVER_MIN_SIZE_DWORD 46
1110
1111#define D102_E_RCVBUNDLE_UCODE \
1112{\
11130x007D028F, 0x0E4204F9, 0x14ED0C85, 0x14FA14E9, 0x0EF70E36, 0x1FFF1FFF, \
11140x00E014B9, 0x00000000, 0x00000000, 0x00000000, \
11150x00E014BD, 0x00000000, 0x00000000, 0x00000000, \
11160x00E014D5, 0x00000000, 0x00000000, 0x00000000, \
11170x00000000, 0x00000000, 0x00000000, 0x00000000, \
11180x00E014C1, 0x00000000, 0x00000000, 0x00000000, \
11190x00000000, 0x00000000, 0x00000000, 0x00000000, \
11200x00000000, 0x00000000, 0x00000000, 0x00000000, \
11210x00000000, 0x00000000, 0x00000000, 0x00000000, \
11220x00E014C8, 0x00000000, 0x00000000, 0x00000000, \
11230x00200600, 0x00E014EE, 0x00000000, 0x00000000, \
11240x0030FF80, 0x00940E46, 0x00038200, 0x00102000, \
11250x00E00E43, 0x00000000, 0x00000000, 0x00000000, \
11260x00300006, 0x00E014FB, 0x00000000, 0x00000000, \
11270x00000000, 0x00000000, 0x00000000, 0x00000000, \
11280x00000000, 0x00000000, 0x00000000, 0x00000000, \
11290x00000000, 0x00000000, 0x00000000, 0x00000000, \
11300x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000, \
11310x00906EFD, 0x00900EFD, 0x00E00EF8, 0x00000000, \
11320x00000000, 0x00000000, 0x00000000, 0x00000000, \
11330x00000000, 0x00000000, 0x00000000, 0x00000000, \
11340x00000000, 0x00000000, 0x00000000, 0x00000000, \
11350x00000000, 0x00000000, 0x00000000, 0x00000000, \
11360x00000000, 0x00000000, 0x00000000, 0x00000000, \
11370x00000000, 0x00000000, 0x00000000, 0x00000000, \
11380x00000000, 0x00000000, 0x00000000, 0x00000000, \
11390x00000000, 0x00000000, 0x00000000, 0x00000000, \
11400x00000000, 0x00000000, 0x00000000, 0x00000000, \
11410x00000000, 0x00000000, 0x00000000, 0x00000000, \
11420x00000000, 0x00000000, 0x00000000, 0x00000000, \
11430x00000000, 0x00000000, 0x00000000, 0x00000000, \
11440x00000000, 0x00000000, 0x00000000, 0x00000000, \
11450x00000000, 0x00000000, 0x00000000, 0x00000000, \
1146}
1147
1148static void e100_load_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb) 1010static void e100_load_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1149{ 1011{
1150/* *INDENT-OFF* */ 1012 int i;
1151 static struct { 1013 static const u32 ucode[UCODE_SIZE] = {
1152 u32 ucode[UCODE_SIZE + 1]; 1014 /* NFS packets are misinterpreted as TCO packets and
1153 u8 mac; 1015 * incorrectly routed to the BMC over SMBus. This
1154 u8 timer_dword; 1016 * microcode patch checks the fragmented IP bit in the
1155 u8 bundle_dword; 1017 * NFS/UDP header to distinguish between NFS and TCO. */
1156 u8 min_size_dword; 1018 0x0EF70E36, 0x1FFF1FFF, 0x1FFF1FFF, 0x1FFF1FFF, 0x1FFF1FFF,
1157 } ucode_opts[] = { 1019 0x1FFF1FFF, 0x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000,
1158 { D101M_B_RCVBUNDLE_UCODE, 1020 0x00906EFD, 0x00900EFD, 0x00E00EF8,
1159 mac_82559_D101M, 1021 };
1160 D101M_CPUSAVER_TIMER_DWORD,
1161 D101M_CPUSAVER_BUNDLE_DWORD,
1162 D101M_CPUSAVER_MIN_SIZE_DWORD },
1163 { D101S_RCVBUNDLE_UCODE,
1164 mac_82559_D101S,
1165 D101S_CPUSAVER_TIMER_DWORD,
1166 D101S_CPUSAVER_BUNDLE_DWORD,
1167 D101S_CPUSAVER_MIN_SIZE_DWORD },
1168 { D102_E_RCVBUNDLE_UCODE,
1169 mac_82551_F,
1170 D102_E_CPUSAVER_TIMER_DWORD,
1171 D102_E_CPUSAVER_BUNDLE_DWORD,
1172 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1173 { D102_E_RCVBUNDLE_UCODE,
1174 mac_82551_10,
1175 D102_E_CPUSAVER_TIMER_DWORD,
1176 D102_E_CPUSAVER_BUNDLE_DWORD,
1177 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1178 { {0}, 0, 0, 0, 0}
1179 }, *opts;
1180/* *INDENT-ON* */
1181
1182#define BUNDLESMALL 1
1183#define BUNDLEMAX 50
1184#define INTDELAY 15000
1185
1186 opts = ucode_opts;
1187
1188 /* do not load u-code for ICH devices */
1189 if (nic->flags & ich)
1190 return;
1191
1192 /* Search for ucode match against h/w rev_id */
1193 while (opts->mac) {
1194 if (nic->mac == opts->mac) {
1195 int i;
1196 u32 *ucode = opts->ucode;
1197
1198 /* Insert user-tunable settings */
1199 ucode[opts->timer_dword] &= 0xFFFF0000;
1200 ucode[opts->timer_dword] |=
1201 (u16) INTDELAY;
1202 ucode[opts->bundle_dword] &= 0xFFFF0000;
1203 ucode[opts->bundle_dword] |= (u16) BUNDLEMAX;
1204 ucode[opts->min_size_dword] &= 0xFFFF0000;
1205 ucode[opts->min_size_dword] |=
1206 (BUNDLESMALL) ? 0xFFFF : 0xFF80;
1207
1208 for(i = 0; i < UCODE_SIZE; i++)
1209 cb->u.ucode[i] = cpu_to_le32(ucode[i]);
1210 cb->command = cpu_to_le16(cb_ucode);
1211 return;
1212 }
1213 opts++;
1214 }
1215 1022
1216 cb->command = cpu_to_le16(cb_nop); 1023 if(nic->mac == mac_82551_F || nic->mac == mac_82551_10) {
1024 for(i = 0; i < UCODE_SIZE; i++)
1025 cb->u.ucode[i] = cpu_to_le32(ucode[i]);
1026 cb->command = cpu_to_le16(cb_ucode);
1027 } else
1028 cb->command = cpu_to_le16(cb_nop);
1217} 1029}
1218 1030
1219static void e100_setup_iaaddr(struct nic *nic, struct cb *cb, 1031static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index 0de3bb906174..14e9b6315f20 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -1875,6 +1875,9 @@ static int emac_init_device(struct ocp_device *ocpdev, struct ibm_ocp_mal *mal)
1875 rc = -ENODEV; 1875 rc = -ENODEV;
1876 goto bail; 1876 goto bail;
1877 } 1877 }
1878
1879 /* Disable any PHY features not supported by the platform */
1880 ep->phy_mii.def->features &= ~emacdata->phy_feat_exc;
1878 1881
1879 /* Setup initial PHY config & startup aneg */ 1882 /* Setup initial PHY config & startup aneg */
1880 if (ep->phy_mii.def->ops->init) 1883 if (ep->phy_mii.def->ops->init)
@@ -1882,6 +1885,34 @@ static int emac_init_device(struct ocp_device *ocpdev, struct ibm_ocp_mal *mal)
1882 netif_carrier_off(ndev); 1885 netif_carrier_off(ndev);
1883 if (ep->phy_mii.def->features & SUPPORTED_Autoneg) 1886 if (ep->phy_mii.def->features & SUPPORTED_Autoneg)
1884 ep->want_autoneg = 1; 1887 ep->want_autoneg = 1;
1888 else {
1889 ep->want_autoneg = 0;
1890
1891 /* Select highest supported speed/duplex */
1892 if (ep->phy_mii.def->features & SUPPORTED_1000baseT_Full) {
1893 ep->phy_mii.speed = SPEED_1000;
1894 ep->phy_mii.duplex = DUPLEX_FULL;
1895 } else if (ep->phy_mii.def->features &
1896 SUPPORTED_1000baseT_Half) {
1897 ep->phy_mii.speed = SPEED_1000;
1898 ep->phy_mii.duplex = DUPLEX_HALF;
1899 } else if (ep->phy_mii.def->features &
1900 SUPPORTED_100baseT_Full) {
1901 ep->phy_mii.speed = SPEED_100;
1902 ep->phy_mii.duplex = DUPLEX_FULL;
1903 } else if (ep->phy_mii.def->features &
1904 SUPPORTED_100baseT_Half) {
1905 ep->phy_mii.speed = SPEED_100;
1906 ep->phy_mii.duplex = DUPLEX_HALF;
1907 } else if (ep->phy_mii.def->features &
1908 SUPPORTED_10baseT_Full) {
1909 ep->phy_mii.speed = SPEED_10;
1910 ep->phy_mii.duplex = DUPLEX_FULL;
1911 } else {
1912 ep->phy_mii.speed = SPEED_10;
1913 ep->phy_mii.duplex = DUPLEX_HALF;
1914 }
1915 }
1885 emac_start_link(ep, NULL); 1916 emac_start_link(ep, NULL);
1886 1917
1887 /* read the MAC Address */ 1918 /* read the MAC Address */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 32d5fabd4b10..a2c4dd4fb221 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -99,7 +99,7 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs
99static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*); 99static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*);
100 100
101#ifdef CONFIG_PROC_FS 101#ifdef CONFIG_PROC_FS
102#define IBMVETH_PROC_DIR "ibmveth" 102#define IBMVETH_PROC_DIR "net/ibmveth"
103static struct proc_dir_entry *ibmveth_proc_dir; 103static struct proc_dir_entry *ibmveth_proc_dir;
104#endif 104#endif
105 105
@@ -1010,7 +1010,7 @@ static int __devexit ibmveth_remove(struct vio_dev *dev)
1010#ifdef CONFIG_PROC_FS 1010#ifdef CONFIG_PROC_FS
1011static void ibmveth_proc_register_driver(void) 1011static void ibmveth_proc_register_driver(void)
1012{ 1012{
1013 ibmveth_proc_dir = create_proc_entry(IBMVETH_PROC_DIR, S_IFDIR, proc_net); 1013 ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, NULL);
1014 if (ibmveth_proc_dir) { 1014 if (ibmveth_proc_dir) {
1015 SET_MODULE_OWNER(ibmveth_proc_dir); 1015 SET_MODULE_OWNER(ibmveth_proc_dir);
1016 } 1016 }
@@ -1018,7 +1018,7 @@ static void ibmveth_proc_register_driver(void)
1018 1018
1019static void ibmveth_proc_unregister_driver(void) 1019static void ibmveth_proc_unregister_driver(void)
1020{ 1020{
1021 remove_proc_entry(IBMVETH_PROC_DIR, proc_net); 1021 remove_proc_entry(IBMVETH_PROC_DIR, NULL);
1022} 1022}
1023 1023
1024static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) 1024static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos)
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 6d9de626c967..651c5a6578fd 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1875,11 +1875,11 @@ static int __init vlsi_mod_init(void)
1875 1875
1876 sirpulse = !!sirpulse; 1876 sirpulse = !!sirpulse;
1877 1877
1878 /* create_proc_entry returns NULL if !CONFIG_PROC_FS. 1878 /* proc_mkdir returns NULL if !CONFIG_PROC_FS.
1879 * Failure to create the procfs entry is handled like running 1879 * Failure to create the procfs entry is handled like running
1880 * without procfs - it's not required for the driver to work. 1880 * without procfs - it's not required for the driver to work.
1881 */ 1881 */
1882 vlsi_proc_root = create_proc_entry(PROC_DIR, S_IFDIR, NULL); 1882 vlsi_proc_root = proc_mkdir(PROC_DIR, NULL);
1883 if (vlsi_proc_root) { 1883 if (vlsi_proc_root) {
1884 /* protect registered procdir against module removal. 1884 /* protect registered procdir against module removal.
1885 * Because we are in the module init path there's no race 1885 * Because we are in the module init path there's no race
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index e64df4d0800b..e4811b42a6b7 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -584,7 +584,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
584 return 0; 584 return 0;
585} 585}
586 586
587static inline int rx_refill(struct net_device *ndev, int gfp) 587static inline int rx_refill(struct net_device *ndev, gfp_t gfp)
588{ 588{
589 struct ns83820 *dev = PRIV(ndev); 589 struct ns83820 *dev = PRIV(ndev);
590 unsigned i; 590 unsigned i;
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index d652e1eddb45..c7cca842e5ee 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -1832,7 +1832,7 @@ static void fill_multicast_tbl(int count, struct dev_mc_list *addrs,
1832{ 1832{
1833 struct dev_mc_list *mc_addr; 1833 struct dev_mc_list *mc_addr;
1834 1834
1835 for (mc_addr = addrs; mc_addr && --count > 0; mc_addr = mc_addr->next) { 1835 for (mc_addr = addrs; mc_addr && count-- > 0; mc_addr = mc_addr->next) {
1836 u_int position = ether_crc(6, mc_addr->dmi_addr); 1836 u_int position = ether_crc(6, mc_addr->dmi_addr);
1837#ifndef final_version /* Verify multicast address. */ 1837#ifndef final_version /* Verify multicast address. */
1838 if ((mc_addr->dmi_addr[0] & 1) == 0) 1838 if ((mc_addr->dmi_addr[0] & 1) == 0)
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 82f236cc3b9b..a842ecc60a34 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -1070,7 +1070,7 @@ static int __init pppoe_proc_init(void)
1070{ 1070{
1071 struct proc_dir_entry *p; 1071 struct proc_dir_entry *p;
1072 1072
1073 p = create_proc_entry("pppoe", S_IRUGO, proc_net); 1073 p = create_proc_entry("net/pppoe", S_IRUGO, NULL);
1074 if (!p) 1074 if (!p)
1075 return -ENOMEM; 1075 return -ENOMEM;
1076 1076
@@ -1142,7 +1142,7 @@ static void __exit pppoe_exit(void)
1142 dev_remove_pack(&pppoes_ptype); 1142 dev_remove_pack(&pppoes_ptype);
1143 dev_remove_pack(&pppoed_ptype); 1143 dev_remove_pack(&pppoed_ptype);
1144 unregister_netdevice_notifier(&pppoe_notifier); 1144 unregister_netdevice_notifier(&pppoe_notifier);
1145 remove_proc_entry("pppoe", proc_net); 1145 remove_proc_entry("net/pppoe", NULL);
1146 proto_unregister(&pppoe_sk_proto); 1146 proto_unregister(&pppoe_sk_proto);
1147} 1147}
1148 1148
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index f0471d102e3c..afb3f186b884 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -92,19 +92,18 @@ VERSION 2.2LK <2005/01/25>
92#endif /* RTL8169_DEBUG */ 92#endif /* RTL8169_DEBUG */
93 93
94#define R8169_MSG_DEFAULT \ 94#define R8169_MSG_DEFAULT \
95 (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFUP | \ 95 (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
96 NETIF_MSG_IFDOWN)
97 96
98#define TX_BUFFS_AVAIL(tp) \ 97#define TX_BUFFS_AVAIL(tp) \
99 (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1) 98 (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1)
100 99
101#ifdef CONFIG_R8169_NAPI 100#ifdef CONFIG_R8169_NAPI
102#define rtl8169_rx_skb netif_receive_skb 101#define rtl8169_rx_skb netif_receive_skb
103#define rtl8169_rx_hwaccel_skb vlan_hwaccel_rx 102#define rtl8169_rx_hwaccel_skb vlan_hwaccel_receive_skb
104#define rtl8169_rx_quota(count, quota) min(count, quota) 103#define rtl8169_rx_quota(count, quota) min(count, quota)
105#else 104#else
106#define rtl8169_rx_skb netif_rx 105#define rtl8169_rx_skb netif_rx
107#define rtl8169_rx_hwaccel_skb vlan_hwaccel_receive_skb 106#define rtl8169_rx_hwaccel_skb vlan_hwaccel_rx
108#define rtl8169_rx_quota(count, quota) count 107#define rtl8169_rx_quota(count, quota) count
109#endif 108#endif
110 109
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 2e72d79a143c..b18c92cb629e 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -235,7 +235,7 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
235 * Extern Function Prototypes 235 * Extern Function Prototypes
236 * 236 *
237 ******************************************************************************/ 237 ******************************************************************************/
238static const char SKRootName[] = "sk98lin"; 238static const char SKRootName[] = "net/sk98lin";
239static struct proc_dir_entry *pSkRootDir; 239static struct proc_dir_entry *pSkRootDir;
240extern struct file_operations sk_proc_fops; 240extern struct file_operations sk_proc_fops;
241 241
@@ -5242,20 +5242,20 @@ static int __init skge_init(void)
5242{ 5242{
5243 int error; 5243 int error;
5244 5244
5245 pSkRootDir = proc_mkdir(SKRootName, proc_net); 5245 pSkRootDir = proc_mkdir(SKRootName, NULL);
5246 if (pSkRootDir) 5246 if (pSkRootDir)
5247 pSkRootDir->owner = THIS_MODULE; 5247 pSkRootDir->owner = THIS_MODULE;
5248 5248
5249 error = pci_register_driver(&skge_driver); 5249 error = pci_register_driver(&skge_driver);
5250 if (error) 5250 if (error)
5251 proc_net_remove(SKRootName); 5251 remove_proc_entry(SKRootName, NULL);
5252 return error; 5252 return error;
5253} 5253}
5254 5254
5255static void __exit skge_exit(void) 5255static void __exit skge_exit(void)
5256{ 5256{
5257 pci_unregister_driver(&skge_driver); 5257 pci_unregister_driver(&skge_driver);
5258 proc_net_remove(SKRootName); 5258 remove_proc_entry(SKRootName, NULL);
5259 5259
5260} 5260}
5261 5261
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 0208258e7826..c2e6484ef138 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -42,7 +42,7 @@
42#include "skge.h" 42#include "skge.h"
43 43
44#define DRV_NAME "skge" 44#define DRV_NAME "skge"
45#define DRV_VERSION "1.0" 45#define DRV_VERSION "1.1"
46#define PFX DRV_NAME " " 46#define PFX DRV_NAME " "
47 47
48#define DEFAULT_TX_RING_SIZE 128 48#define DEFAULT_TX_RING_SIZE 128
@@ -105,41 +105,28 @@ static const u32 rxirqmask[] = { IS_R1_F, IS_R2_F };
105static const u32 txirqmask[] = { IS_XA1_F, IS_XA2_F }; 105static const u32 txirqmask[] = { IS_XA1_F, IS_XA2_F };
106static const u32 portirqmask[] = { IS_PORT_1, IS_PORT_2 }; 106static const u32 portirqmask[] = { IS_PORT_1, IS_PORT_2 };
107 107
108/* Don't need to look at whole 16K.
109 * last interesting register is descriptor poll timer.
110 */
111#define SKGE_REGS_LEN (29*128)
112
113static int skge_get_regs_len(struct net_device *dev) 108static int skge_get_regs_len(struct net_device *dev)
114{ 109{
115 return SKGE_REGS_LEN; 110 return 0x4000;
116} 111}
117 112
118/* 113/*
119 * Returns copy of control register region 114 * Returns copy of whole control register region
120 * I/O region is divided into banks and certain regions are unreadable 115 * Note: skip RAM address register because accessing it will
116 * cause bus hangs!
121 */ 117 */
122static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs, 118static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs,
123 void *p) 119 void *p)
124{ 120{
125 const struct skge_port *skge = netdev_priv(dev); 121 const struct skge_port *skge = netdev_priv(dev);
126 unsigned long offs;
127 const void __iomem *io = skge->hw->regs; 122 const void __iomem *io = skge->hw->regs;
128 static const unsigned long bankmap
129 = (1<<0) | (1<<2) | (1<<8) | (1<<9)
130 | (1<<12) | (1<<13) | (1<<14) | (1<<15) | (1<<16)
131 | (1<<17) | (1<<20) | (1<<21) | (1<<22) | (1<<23)
132 | (1<<24) | (1<<25) | (1<<26) | (1<<27) | (1<<28);
133 123
134 regs->version = 1; 124 regs->version = 1;
135 for (offs = 0; offs < regs->len; offs += 128) { 125 memset(p, 0, regs->len);
136 u32 len = min_t(u32, 128, regs->len - offs); 126 memcpy_fromio(p, io, B3_RAM_ADDR);
137 127
138 if (bankmap & (1<<(offs/128))) 128 memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
139 memcpy_fromio(p + offs, io + offs, len); 129 regs->len - B3_RI_WTO_R1);
140 else
141 memset(p + offs, 0, len);
142 }
143} 130}
144 131
145/* Wake on Lan only supported on Yukon chps with rev 1 or above */ 132/* Wake on Lan only supported on Yukon chps with rev 1 or above */
@@ -775,17 +762,6 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u64 base)
775 return 0; 762 return 0;
776} 763}
777 764
778static struct sk_buff *skge_rx_alloc(struct net_device *dev, unsigned int size)
779{
780 struct sk_buff *skb = dev_alloc_skb(size);
781
782 if (likely(skb)) {
783 skb->dev = dev;
784 skb_reserve(skb, NET_IP_ALIGN);
785 }
786 return skb;
787}
788
789/* Allocate and setup a new buffer for receiving */ 765/* Allocate and setup a new buffer for receiving */
790static void skge_rx_setup(struct skge_port *skge, struct skge_element *e, 766static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
791 struct sk_buff *skb, unsigned int bufsize) 767 struct sk_buff *skb, unsigned int bufsize)
@@ -858,16 +834,17 @@ static int skge_rx_fill(struct skge_port *skge)
858{ 834{
859 struct skge_ring *ring = &skge->rx_ring; 835 struct skge_ring *ring = &skge->rx_ring;
860 struct skge_element *e; 836 struct skge_element *e;
861 unsigned int bufsize = skge->rx_buf_size;
862 837
863 e = ring->start; 838 e = ring->start;
864 do { 839 do {
865 struct sk_buff *skb = skge_rx_alloc(skge->netdev, bufsize); 840 struct sk_buff *skb;
866 841
842 skb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN);
867 if (!skb) 843 if (!skb)
868 return -ENOMEM; 844 return -ENOMEM;
869 845
870 skge_rx_setup(skge, e, skb, bufsize); 846 skb_reserve(skb, NET_IP_ALIGN);
847 skge_rx_setup(skge, e, skb, skge->rx_buf_size);
871 } while ( (e = e->next) != ring->start); 848 } while ( (e = e->next) != ring->start);
872 849
873 ring->to_clean = ring->start; 850 ring->to_clean = ring->start;
@@ -1666,6 +1643,22 @@ static void yukon_reset(struct skge_hw *hw, int port)
1666 | GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); 1643 | GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
1667} 1644}
1668 1645
1646/* Apparently, early versions of Yukon-Lite had wrong chip_id? */
1647static int is_yukon_lite_a0(struct skge_hw *hw)
1648{
1649 u32 reg;
1650 int ret;
1651
1652 if (hw->chip_id != CHIP_ID_YUKON)
1653 return 0;
1654
1655 reg = skge_read32(hw, B2_FAR);
1656 skge_write8(hw, B2_FAR + 3, 0xff);
1657 ret = (skge_read8(hw, B2_FAR + 3) != 0);
1658 skge_write32(hw, B2_FAR, reg);
1659 return ret;
1660}
1661
1669static void yukon_mac_init(struct skge_hw *hw, int port) 1662static void yukon_mac_init(struct skge_hw *hw, int port)
1670{ 1663{
1671 struct skge_port *skge = netdev_priv(hw->dev[port]); 1664 struct skge_port *skge = netdev_priv(hw->dev[port]);
@@ -1781,9 +1774,11 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1781 /* Configure Rx MAC FIFO */ 1774 /* Configure Rx MAC FIFO */
1782 skge_write16(hw, SK_REG(port, RX_GMF_FL_MSK), RX_FF_FL_DEF_MSK); 1775 skge_write16(hw, SK_REG(port, RX_GMF_FL_MSK), RX_FF_FL_DEF_MSK);
1783 reg = GMF_OPER_ON | GMF_RX_F_FL_ON; 1776 reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
1784 if (hw->chip_id == CHIP_ID_YUKON_LITE && 1777
1785 hw->chip_rev >= CHIP_REV_YU_LITE_A3) 1778 /* disable Rx GMAC FIFO Flush for YUKON-Lite Rev. A0 only */
1779 if (is_yukon_lite_a0(hw))
1786 reg &= ~GMF_RX_F_FL_ON; 1780 reg &= ~GMF_RX_F_FL_ON;
1781
1787 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR); 1782 skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR);
1788 skge_write16(hw, SK_REG(port, RX_GMF_CTRL_T), reg); 1783 skge_write16(hw, SK_REG(port, RX_GMF_CTRL_T), reg);
1789 /* 1784 /*
@@ -2442,6 +2437,14 @@ static void yukon_set_multicast(struct net_device *dev)
2442 gma_write16(hw, port, GM_RX_CTRL, reg); 2437 gma_write16(hw, port, GM_RX_CTRL, reg);
2443} 2438}
2444 2439
2440static inline u16 phy_length(const struct skge_hw *hw, u32 status)
2441{
2442 if (hw->chip_id == CHIP_ID_GENESIS)
2443 return status >> XMR_FS_LEN_SHIFT;
2444 else
2445 return status >> GMR_FS_LEN_SHIFT;
2446}
2447
2445static inline int bad_phy_status(const struct skge_hw *hw, u32 status) 2448static inline int bad_phy_status(const struct skge_hw *hw, u32 status)
2446{ 2449{
2447 if (hw->chip_id == CHIP_ID_GENESIS) 2450 if (hw->chip_id == CHIP_ID_GENESIS)
@@ -2451,80 +2454,99 @@ static inline int bad_phy_status(const struct skge_hw *hw, u32 status)
2451 (status & GMR_FS_RX_OK) == 0; 2454 (status & GMR_FS_RX_OK) == 0;
2452} 2455}
2453 2456
2454static void skge_rx_error(struct skge_port *skge, int slot,
2455 u32 control, u32 status)
2456{
2457 if (netif_msg_rx_err(skge))
2458 printk(KERN_DEBUG PFX "%s: rx err, slot %d control 0x%x status 0x%x\n",
2459 skge->netdev->name, slot, control, status);
2460
2461 if ((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF))
2462 skge->net_stats.rx_length_errors++;
2463 else if (skge->hw->chip_id == CHIP_ID_GENESIS) {
2464 if (status & (XMR_FS_RUNT|XMR_FS_LNG_ERR))
2465 skge->net_stats.rx_length_errors++;
2466 if (status & XMR_FS_FRA_ERR)
2467 skge->net_stats.rx_frame_errors++;
2468 if (status & XMR_FS_FCS_ERR)
2469 skge->net_stats.rx_crc_errors++;
2470 } else {
2471 if (status & (GMR_FS_LONG_ERR|GMR_FS_UN_SIZE))
2472 skge->net_stats.rx_length_errors++;
2473 if (status & GMR_FS_FRAGMENT)
2474 skge->net_stats.rx_frame_errors++;
2475 if (status & GMR_FS_CRC_ERR)
2476 skge->net_stats.rx_crc_errors++;
2477 }
2478}
2479 2457
2480/* Get receive buffer from descriptor. 2458/* Get receive buffer from descriptor.
2481 * Handles copy of small buffers and reallocation failures 2459 * Handles copy of small buffers and reallocation failures
2482 */ 2460 */
2483static inline struct sk_buff *skge_rx_get(struct skge_port *skge, 2461static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
2484 struct skge_element *e, 2462 struct skge_element *e,
2485 unsigned int len) 2463 u32 control, u32 status, u16 csum)
2486{ 2464{
2487 struct sk_buff *nskb, *skb; 2465 struct sk_buff *skb;
2466 u16 len = control & BMU_BBC;
2467
2468 if (unlikely(netif_msg_rx_status(skge)))
2469 printk(KERN_DEBUG PFX "%s: rx slot %td status 0x%x len %d\n",
2470 skge->netdev->name, e - skge->rx_ring.start,
2471 status, len);
2472
2473 if (len > skge->rx_buf_size)
2474 goto error;
2475
2476 if ((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF))
2477 goto error;
2478
2479 if (bad_phy_status(skge->hw, status))
2480 goto error;
2481
2482 if (phy_length(skge->hw, status) != len)
2483 goto error;
2488 2484
2489 if (len < RX_COPY_THRESHOLD) { 2485 if (len < RX_COPY_THRESHOLD) {
2490 nskb = skge_rx_alloc(skge->netdev, len + NET_IP_ALIGN); 2486 skb = dev_alloc_skb(len + 2);
2491 if (unlikely(!nskb)) 2487 if (!skb)
2492 return NULL; 2488 goto resubmit;
2493 2489
2490 skb_reserve(skb, 2);
2494 pci_dma_sync_single_for_cpu(skge->hw->pdev, 2491 pci_dma_sync_single_for_cpu(skge->hw->pdev,
2495 pci_unmap_addr(e, mapaddr), 2492 pci_unmap_addr(e, mapaddr),
2496 len, PCI_DMA_FROMDEVICE); 2493 len, PCI_DMA_FROMDEVICE);
2497 memcpy(nskb->data, e->skb->data, len); 2494 memcpy(skb->data, e->skb->data, len);
2498 pci_dma_sync_single_for_device(skge->hw->pdev, 2495 pci_dma_sync_single_for_device(skge->hw->pdev,
2499 pci_unmap_addr(e, mapaddr), 2496 pci_unmap_addr(e, mapaddr),
2500 len, PCI_DMA_FROMDEVICE); 2497 len, PCI_DMA_FROMDEVICE);
2501
2502 if (skge->rx_csum) {
2503 struct skge_rx_desc *rd = e->desc;
2504 nskb->csum = le16_to_cpu(rd->csum2);
2505 nskb->ip_summed = CHECKSUM_HW;
2506 }
2507 skge_rx_reuse(e, skge->rx_buf_size); 2498 skge_rx_reuse(e, skge->rx_buf_size);
2508 return nskb;
2509 } else { 2499 } else {
2510 nskb = skge_rx_alloc(skge->netdev, skge->rx_buf_size); 2500 struct sk_buff *nskb;
2511 if (unlikely(!nskb)) 2501 nskb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN);
2512 return NULL; 2502 if (!nskb)
2503 goto resubmit;
2513 2504
2514 pci_unmap_single(skge->hw->pdev, 2505 pci_unmap_single(skge->hw->pdev,
2515 pci_unmap_addr(e, mapaddr), 2506 pci_unmap_addr(e, mapaddr),
2516 pci_unmap_len(e, maplen), 2507 pci_unmap_len(e, maplen),
2517 PCI_DMA_FROMDEVICE); 2508 PCI_DMA_FROMDEVICE);
2518 skb = e->skb; 2509 skb = e->skb;
2519 if (skge->rx_csum) { 2510 prefetch(skb->data);
2520 struct skge_rx_desc *rd = e->desc;
2521 skb->csum = le16_to_cpu(rd->csum2);
2522 skb->ip_summed = CHECKSUM_HW;
2523 }
2524
2525 skge_rx_setup(skge, e, nskb, skge->rx_buf_size); 2511 skge_rx_setup(skge, e, nskb, skge->rx_buf_size);
2526 return skb;
2527 } 2512 }
2513
2514 skb_put(skb, len);
2515 skb->dev = skge->netdev;
2516 if (skge->rx_csum) {
2517 skb->csum = csum;
2518 skb->ip_summed = CHECKSUM_HW;
2519 }
2520
2521 skb->protocol = eth_type_trans(skb, skge->netdev);
2522
2523 return skb;
2524error:
2525
2526 if (netif_msg_rx_err(skge))
2527 printk(KERN_DEBUG PFX "%s: rx err, slot %td control 0x%x status 0x%x\n",
2528 skge->netdev->name, e - skge->rx_ring.start,
2529 control, status);
2530
2531 if (skge->hw->chip_id == CHIP_ID_GENESIS) {
2532 if (status & (XMR_FS_RUNT|XMR_FS_LNG_ERR))
2533 skge->net_stats.rx_length_errors++;
2534 if (status & XMR_FS_FRA_ERR)
2535 skge->net_stats.rx_frame_errors++;
2536 if (status & XMR_FS_FCS_ERR)
2537 skge->net_stats.rx_crc_errors++;
2538 } else {
2539 if (status & (GMR_FS_LONG_ERR|GMR_FS_UN_SIZE))
2540 skge->net_stats.rx_length_errors++;
2541 if (status & GMR_FS_FRAGMENT)
2542 skge->net_stats.rx_frame_errors++;
2543 if (status & GMR_FS_CRC_ERR)
2544 skge->net_stats.rx_crc_errors++;
2545 }
2546
2547resubmit:
2548 skge_rx_reuse(e, skge->rx_buf_size);
2549 return NULL;
2528} 2550}
2529 2551
2530 2552
@@ -2540,32 +2562,16 @@ static int skge_poll(struct net_device *dev, int *budget)
2540 for (e = ring->to_clean; work_done < to_do; e = e->next) { 2562 for (e = ring->to_clean; work_done < to_do; e = e->next) {
2541 struct skge_rx_desc *rd = e->desc; 2563 struct skge_rx_desc *rd = e->desc;
2542 struct sk_buff *skb; 2564 struct sk_buff *skb;
2543 u32 control, len, status; 2565 u32 control;
2544 2566
2545 rmb(); 2567 rmb();
2546 control = rd->control; 2568 control = rd->control;
2547 if (control & BMU_OWN) 2569 if (control & BMU_OWN)
2548 break; 2570 break;
2549 2571
2550 len = control & BMU_BBC; 2572 skb = skge_rx_get(skge, e, control, rd->status,
2551 status = rd->status; 2573 le16_to_cpu(rd->csum2));
2552
2553 if (unlikely((control & (BMU_EOF|BMU_STF)) != (BMU_STF|BMU_EOF)
2554 || bad_phy_status(hw, status))) {
2555 skge_rx_error(skge, e - ring->start, control, status);
2556 skge_rx_reuse(e, skge->rx_buf_size);
2557 continue;
2558 }
2559
2560 if (netif_msg_rx_status(skge))
2561 printk(KERN_DEBUG PFX "%s: rx slot %td status 0x%x len %d\n",
2562 dev->name, e - ring->start, rd->status, len);
2563
2564 skb = skge_rx_get(skge, e, len);
2565 if (likely(skb)) { 2574 if (likely(skb)) {
2566 skb_put(skb, len);
2567 skb->protocol = eth_type_trans(skb, dev);
2568
2569 dev->last_rx = jiffies; 2575 dev->last_rx = jiffies;
2570 netif_receive_skb(skb); 2576 netif_receive_skb(skb);
2571 2577
@@ -2831,21 +2837,29 @@ static void skge_netpoll(struct net_device *dev)
2831static int skge_set_mac_address(struct net_device *dev, void *p) 2837static int skge_set_mac_address(struct net_device *dev, void *p)
2832{ 2838{
2833 struct skge_port *skge = netdev_priv(dev); 2839 struct skge_port *skge = netdev_priv(dev);
2834 struct sockaddr *addr = p; 2840 struct skge_hw *hw = skge->hw;
2835 int err = 0; 2841 unsigned port = skge->port;
2842 const struct sockaddr *addr = p;
2836 2843
2837 if (!is_valid_ether_addr(addr->sa_data)) 2844 if (!is_valid_ether_addr(addr->sa_data))
2838 return -EADDRNOTAVAIL; 2845 return -EADDRNOTAVAIL;
2839 2846
2840 skge_down(dev); 2847 spin_lock_bh(&hw->phy_lock);
2841 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 2848 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
2842 memcpy_toio(skge->hw->regs + B2_MAC_1 + skge->port*8, 2849 memcpy_toio(hw->regs + B2_MAC_1 + port*8,
2843 dev->dev_addr, ETH_ALEN); 2850 dev->dev_addr, ETH_ALEN);
2844 memcpy_toio(skge->hw->regs + B2_MAC_2 + skge->port*8, 2851 memcpy_toio(hw->regs + B2_MAC_2 + port*8,
2845 dev->dev_addr, ETH_ALEN); 2852 dev->dev_addr, ETH_ALEN);
2846 if (dev->flags & IFF_UP) 2853
2847 err = skge_up(dev); 2854 if (hw->chip_id == CHIP_ID_GENESIS)
2848 return err; 2855 xm_outaddr(hw, port, XM_SA, dev->dev_addr);
2856 else {
2857 gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
2858 gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
2859 }
2860 spin_unlock_bh(&hw->phy_lock);
2861
2862 return 0;
2849} 2863}
2850 2864
2851static const struct { 2865static const struct {
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index efbf98c675d2..72c175b87a5a 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -953,6 +953,7 @@ enum {
953 */ 953 */
954enum { 954enum {
955 XMR_FS_LEN = 0x3fff<<18, /* Bit 31..18: Rx Frame Length */ 955 XMR_FS_LEN = 0x3fff<<18, /* Bit 31..18: Rx Frame Length */
956 XMR_FS_LEN_SHIFT = 18,
956 XMR_FS_2L_VLAN = 1<<17, /* Bit 17: tagged wh 2Lev VLAN ID*/ 957 XMR_FS_2L_VLAN = 1<<17, /* Bit 17: tagged wh 2Lev VLAN ID*/
957 XMR_FS_1_VLAN = 1<<16, /* Bit 16: tagged wh 1ev VLAN ID*/ 958 XMR_FS_1_VLAN = 1<<16, /* Bit 16: tagged wh 1ev VLAN ID*/
958 XMR_FS_BC = 1<<15, /* Bit 15: Broadcast Frame */ 959 XMR_FS_BC = 1<<15, /* Bit 15: Broadcast Frame */
@@ -1868,6 +1869,7 @@ enum {
1868/* Receive Frame Status Encoding */ 1869/* Receive Frame Status Encoding */
1869enum { 1870enum {
1870 GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */ 1871 GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */
1872 GMR_FS_LEN_SHIFT = 16,
1871 GMR_FS_VLAN = 1<<13, /* Bit 13: VLAN Packet */ 1873 GMR_FS_VLAN = 1<<13, /* Bit 13: VLAN Packet */
1872 GMR_FS_JABBER = 1<<12, /* Bit 12: Jabber Packet */ 1874 GMR_FS_JABBER = 1<<12, /* Bit 12: Jabber Packet */
1873 GMR_FS_UN_SIZE = 1<<11, /* Bit 11: Undersize Packet */ 1875 GMR_FS_UN_SIZE = 1<<11, /* Bit 11: Undersize Packet */
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 88b89dc95c77..efdb179ecc8c 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -133,14 +133,18 @@
133 - finally added firmware (GPL'ed by Adaptec) 133 - finally added firmware (GPL'ed by Adaptec)
134 - removed compatibility code for 2.2.x 134 - removed compatibility code for 2.2.x
135 135
136 LK1.4.2.1 (Ion Badulescu)
137 - fixed 32/64 bit issues on i386 + CONFIG_HIGHMEM
138 - added 32-bit padding to outgoing skb's, removed previous workaround
139
136TODO: - fix forced speed/duplexing code (broken a long time ago, when 140TODO: - fix forced speed/duplexing code (broken a long time ago, when
137 somebody converted the driver to use the generic MII code) 141 somebody converted the driver to use the generic MII code)
138 - fix VLAN support 142 - fix VLAN support
139*/ 143*/
140 144
141#define DRV_NAME "starfire" 145#define DRV_NAME "starfire"
142#define DRV_VERSION "1.03+LK1.4.2" 146#define DRV_VERSION "1.03+LK1.4.2.1"
143#define DRV_RELDATE "January 19, 2005" 147#define DRV_RELDATE "October 3, 2005"
144 148
145#include <linux/config.h> 149#include <linux/config.h>
146#include <linux/version.h> 150#include <linux/version.h>
@@ -165,6 +169,14 @@ TODO: - fix forced speed/duplexing code (broken a long time ago, when
165 * of length 1. If and when this is fixed, the #define below can be removed. 169 * of length 1. If and when this is fixed, the #define below can be removed.
166 */ 170 */
167#define HAS_BROKEN_FIRMWARE 171#define HAS_BROKEN_FIRMWARE
172
173/*
174 * If using the broken firmware, data must be padded to the next 32-bit boundary.
175 */
176#ifdef HAS_BROKEN_FIRMWARE
177#define PADDING_MASK 3
178#endif
179
168/* 180/*
169 * Define this if using the driver with the zero-copy patch 181 * Define this if using the driver with the zero-copy patch
170 */ 182 */
@@ -257,9 +269,10 @@ static int full_duplex[MAX_UNITS] = {0, };
257 * This SUCKS. 269 * This SUCKS.
258 * We need a much better method to determine if dma_addr_t is 64-bit. 270 * We need a much better method to determine if dma_addr_t is 64-bit.
259 */ 271 */
260#if (defined(__i386__) && defined(CONFIG_HIGHMEM) && (LINUX_VERSION_CODE > 0x20500 || defined(CONFIG_HIGHMEM64G))) || defined(__x86_64__) || defined (__ia64__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) 272#if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR))
261/* 64-bit dma_addr_t */ 273/* 64-bit dma_addr_t */
262#define ADDR_64BITS /* This chip uses 64 bit addresses. */ 274#define ADDR_64BITS /* This chip uses 64 bit addresses. */
275#define netdrv_addr_t u64
263#define cpu_to_dma(x) cpu_to_le64(x) 276#define cpu_to_dma(x) cpu_to_le64(x)
264#define dma_to_cpu(x) le64_to_cpu(x) 277#define dma_to_cpu(x) le64_to_cpu(x)
265#define RX_DESC_Q_ADDR_SIZE RxDescQAddr64bit 278#define RX_DESC_Q_ADDR_SIZE RxDescQAddr64bit
@@ -268,6 +281,7 @@ static int full_duplex[MAX_UNITS] = {0, };
268#define TX_COMPL_Q_ADDR_SIZE TxComplQAddr64bit 281#define TX_COMPL_Q_ADDR_SIZE TxComplQAddr64bit
269#define RX_DESC_ADDR_SIZE RxDescAddr64bit 282#define RX_DESC_ADDR_SIZE RxDescAddr64bit
270#else /* 32-bit dma_addr_t */ 283#else /* 32-bit dma_addr_t */
284#define netdrv_addr_t u32
271#define cpu_to_dma(x) cpu_to_le32(x) 285#define cpu_to_dma(x) cpu_to_le32(x)
272#define dma_to_cpu(x) le32_to_cpu(x) 286#define dma_to_cpu(x) le32_to_cpu(x)
273#define RX_DESC_Q_ADDR_SIZE RxDescQAddr32bit 287#define RX_DESC_Q_ADDR_SIZE RxDescQAddr32bit
@@ -1333,21 +1347,10 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
1333 } 1347 }
1334 1348
1335#if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE) 1349#if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE)
1336 { 1350 if (skb->ip_summed == CHECKSUM_HW) {
1337 int has_bad_length = 0; 1351 skb = skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK);
1338 1352 if (skb == NULL)
1339 if (skb_first_frag_len(skb) == 1) 1353 return NETDEV_TX_OK;
1340 has_bad_length = 1;
1341 else {
1342 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1343 if (skb_shinfo(skb)->frags[i].size == 1) {
1344 has_bad_length = 1;
1345 break;
1346 }
1347 }
1348
1349 if (has_bad_length)
1350 skb_checksum_help(skb, 0);
1351 } 1354 }
1352#endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */ 1355#endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */
1353 1356
@@ -2127,13 +2130,12 @@ static int __init starfire_init (void)
2127#endif 2130#endif
2128#endif 2131#endif
2129 2132
2130#ifndef ADDR_64BITS
2131 /* we can do this test only at run-time... sigh */ 2133 /* we can do this test only at run-time... sigh */
2132 if (sizeof(dma_addr_t) == sizeof(u64)) { 2134 if (sizeof(dma_addr_t) != sizeof(netdrv_addr_t)) {
2133 printk("This driver has not been ported to this 64-bit architecture yet\n"); 2135 printk("This driver has dma_addr_t issues, please send email to maintainer\n");
2134 return -ENODEV; 2136 return -ENODEV;
2135 } 2137 }
2136#endif /* not ADDR_64BITS */ 2138
2137 return pci_module_init (&starfire_driver); 2139 return pci_module_init (&starfire_driver);
2138} 2140}
2139 2141
diff --git a/drivers/net/sungem.h b/drivers/net/sungem.h
index ff8ae5f79970..13006d759ad8 100644
--- a/drivers/net/sungem.h
+++ b/drivers/net/sungem.h
@@ -1035,7 +1035,8 @@ struct gem {
1035 1035
1036#define ALIGNED_RX_SKB_ADDR(addr) \ 1036#define ALIGNED_RX_SKB_ADDR(addr) \
1037 ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr)) 1037 ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr))
1038static __inline__ struct sk_buff *gem_alloc_skb(int size, int gfp_flags) 1038static __inline__ struct sk_buff *gem_alloc_skb(int size,
1039 gfp_t gfp_flags)
1039{ 1040{
1040 struct sk_buff *skb = alloc_skb(size + 64, gfp_flags); 1041 struct sk_buff *skb = alloc_skb(size + 64, gfp_flags);
1041 1042
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7599f52e15b3..1802c3b48799 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -67,8 +67,8 @@
67 67
68#define DRV_MODULE_NAME "tg3" 68#define DRV_MODULE_NAME "tg3"
69#define PFX DRV_MODULE_NAME ": " 69#define PFX DRV_MODULE_NAME ": "
70#define DRV_MODULE_VERSION "3.39" 70#define DRV_MODULE_VERSION "3.42"
71#define DRV_MODULE_RELDATE "September 5, 2005" 71#define DRV_MODULE_RELDATE "Oct 3, 2005"
72 72
73#define TG3_DEF_MAC_MODE 0 73#define TG3_DEF_MAC_MODE 0
74#define TG3_DEF_RX_MODE 0 74#define TG3_DEF_RX_MODE 0
@@ -3389,7 +3389,8 @@ static irqreturn_t tg3_test_isr(int irq, void *dev_id,
3389 struct tg3 *tp = netdev_priv(dev); 3389 struct tg3 *tp = netdev_priv(dev);
3390 struct tg3_hw_status *sblk = tp->hw_status; 3390 struct tg3_hw_status *sblk = tp->hw_status;
3391 3391
3392 if (sblk->status & SD_STATUS_UPDATED) { 3392 if ((sblk->status & SD_STATUS_UPDATED) ||
3393 !(tr32(TG3PCI_PCISTATE) & PCISTATE_INT_NOT_ACTIVE)) {
3393 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 3394 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3394 0x00000001); 3395 0x00000001);
3395 return IRQ_RETVAL(1); 3396 return IRQ_RETVAL(1);
@@ -3442,31 +3443,47 @@ static void tg3_tx_timeout(struct net_device *dev)
3442 schedule_work(&tp->reset_task); 3443 schedule_work(&tp->reset_task);
3443} 3444}
3444 3445
3446/* Test for DMA buffers crossing any 4GB boundaries: 4G, 8G, etc */
3447static inline int tg3_4g_overflow_test(dma_addr_t mapping, int len)
3448{
3449 u32 base = (u32) mapping & 0xffffffff;
3450
3451 return ((base > 0xffffdcc0) &&
3452 (base + len + 8 < base));
3453}
3454
3445static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32); 3455static void tg3_set_txd(struct tg3 *, int, dma_addr_t, int, u32, u32);
3446 3456
3447static int tigon3_4gb_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb, 3457static int tigon3_4gb_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
3448 u32 guilty_entry, int guilty_len, 3458 u32 last_plus_one, u32 *start,
3449 u32 last_plus_one, u32 *start, u32 mss) 3459 u32 base_flags, u32 mss)
3450{ 3460{
3451 struct sk_buff *new_skb = skb_copy(skb, GFP_ATOMIC); 3461 struct sk_buff *new_skb = skb_copy(skb, GFP_ATOMIC);
3452 dma_addr_t new_addr; 3462 dma_addr_t new_addr = 0;
3453 u32 entry = *start; 3463 u32 entry = *start;
3454 int i; 3464 int i, ret = 0;
3455 3465
3456 if (!new_skb) { 3466 if (!new_skb) {
3457 dev_kfree_skb(skb); 3467 ret = -1;
3458 return -1; 3468 } else {
3469 /* New SKB is guaranteed to be linear. */
3470 entry = *start;
3471 new_addr = pci_map_single(tp->pdev, new_skb->data, new_skb->len,
3472 PCI_DMA_TODEVICE);
3473 /* Make sure new skb does not cross any 4G boundaries.
3474 * Drop the packet if it does.
3475 */
3476 if (tg3_4g_overflow_test(new_addr, new_skb->len)) {
3477 ret = -1;
3478 dev_kfree_skb(new_skb);
3479 new_skb = NULL;
3480 } else {
3481 tg3_set_txd(tp, entry, new_addr, new_skb->len,
3482 base_flags, 1 | (mss << 1));
3483 *start = NEXT_TX(entry);
3484 }
3459 } 3485 }
3460 3486
3461 /* New SKB is guaranteed to be linear. */
3462 entry = *start;
3463 new_addr = pci_map_single(tp->pdev, new_skb->data, new_skb->len,
3464 PCI_DMA_TODEVICE);
3465 tg3_set_txd(tp, entry, new_addr, new_skb->len,
3466 (skb->ip_summed == CHECKSUM_HW) ?
3467 TXD_FLAG_TCPUDP_CSUM : 0, 1 | (mss << 1));
3468 *start = NEXT_TX(entry);
3469
3470 /* Now clean up the sw ring entries. */ 3487 /* Now clean up the sw ring entries. */
3471 i = 0; 3488 i = 0;
3472 while (entry != last_plus_one) { 3489 while (entry != last_plus_one) {
@@ -3491,7 +3508,7 @@ static int tigon3_4gb_hwbug_workaround(struct tg3 *tp, struct sk_buff *skb,
3491 3508
3492 dev_kfree_skb(skb); 3509 dev_kfree_skb(skb);
3493 3510
3494 return 0; 3511 return ret;
3495} 3512}
3496 3513
3497static void tg3_set_txd(struct tg3 *tp, int entry, 3514static void tg3_set_txd(struct tg3 *tp, int entry,
@@ -3517,19 +3534,10 @@ static void tg3_set_txd(struct tg3 *tp, int entry,
3517 txd->vlan_tag = vlan_tag << TXD_VLAN_TAG_SHIFT; 3534 txd->vlan_tag = vlan_tag << TXD_VLAN_TAG_SHIFT;
3518} 3535}
3519 3536
3520static inline int tg3_4g_overflow_test(dma_addr_t mapping, int len)
3521{
3522 u32 base = (u32) mapping & 0xffffffff;
3523
3524 return ((base > 0xffffdcc0) &&
3525 (base + len + 8 < base));
3526}
3527
3528static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) 3537static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3529{ 3538{
3530 struct tg3 *tp = netdev_priv(dev); 3539 struct tg3 *tp = netdev_priv(dev);
3531 dma_addr_t mapping; 3540 dma_addr_t mapping;
3532 unsigned int i;
3533 u32 len, entry, base_flags, mss; 3541 u32 len, entry, base_flags, mss;
3534 int would_hit_hwbug; 3542 int would_hit_hwbug;
3535 3543
@@ -3624,7 +3632,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3624 would_hit_hwbug = 0; 3632 would_hit_hwbug = 0;
3625 3633
3626 if (tg3_4g_overflow_test(mapping, len)) 3634 if (tg3_4g_overflow_test(mapping, len))
3627 would_hit_hwbug = entry + 1; 3635 would_hit_hwbug = 1;
3628 3636
3629 tg3_set_txd(tp, entry, mapping, len, base_flags, 3637 tg3_set_txd(tp, entry, mapping, len, base_flags,
3630 (skb_shinfo(skb)->nr_frags == 0) | (mss << 1)); 3638 (skb_shinfo(skb)->nr_frags == 0) | (mss << 1));
@@ -3648,12 +3656,8 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3648 tp->tx_buffers[entry].skb = NULL; 3656 tp->tx_buffers[entry].skb = NULL;
3649 pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping); 3657 pci_unmap_addr_set(&tp->tx_buffers[entry], mapping, mapping);
3650 3658
3651 if (tg3_4g_overflow_test(mapping, len)) { 3659 if (tg3_4g_overflow_test(mapping, len))
3652 /* Only one should match. */ 3660 would_hit_hwbug = 1;
3653 if (would_hit_hwbug)
3654 BUG();
3655 would_hit_hwbug = entry + 1;
3656 }
3657 3661
3658 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 3662 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
3659 tg3_set_txd(tp, entry, mapping, len, 3663 tg3_set_txd(tp, entry, mapping, len,
@@ -3669,34 +3673,15 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3669 if (would_hit_hwbug) { 3673 if (would_hit_hwbug) {
3670 u32 last_plus_one = entry; 3674 u32 last_plus_one = entry;
3671 u32 start; 3675 u32 start;
3672 unsigned int len = 0;
3673
3674 would_hit_hwbug -= 1;
3675 entry = entry - 1 - skb_shinfo(skb)->nr_frags;
3676 entry &= (TG3_TX_RING_SIZE - 1);
3677 start = entry;
3678 i = 0;
3679 while (entry != last_plus_one) {
3680 if (i == 0)
3681 len = skb_headlen(skb);
3682 else
3683 len = skb_shinfo(skb)->frags[i-1].size;
3684 3676
3685 if (entry == would_hit_hwbug) 3677 start = entry - 1 - skb_shinfo(skb)->nr_frags;
3686 break; 3678 start &= (TG3_TX_RING_SIZE - 1);
3687
3688 i++;
3689 entry = NEXT_TX(entry);
3690
3691 }
3692 3679
3693 /* If the workaround fails due to memory/mapping 3680 /* If the workaround fails due to memory/mapping
3694 * failure, silently drop this packet. 3681 * failure, silently drop this packet.
3695 */ 3682 */
3696 if (tigon3_4gb_hwbug_workaround(tp, skb, 3683 if (tigon3_4gb_hwbug_workaround(tp, skb, last_plus_one,
3697 entry, len, 3684 &start, base_flags, mss))
3698 last_plus_one,
3699 &start, mss))
3700 goto out_unlock; 3685 goto out_unlock;
3701 3686
3702 entry = start; 3687 entry = start;
@@ -5411,6 +5396,9 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p)
5411 struct tg3 *tp = netdev_priv(dev); 5396 struct tg3 *tp = netdev_priv(dev);
5412 struct sockaddr *addr = p; 5397 struct sockaddr *addr = p;
5413 5398
5399 if (!is_valid_ether_addr(addr->sa_data))
5400 return -EINVAL;
5401
5414 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 5402 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
5415 5403
5416 spin_lock_bh(&tp->lock); 5404 spin_lock_bh(&tp->lock);
@@ -5822,6 +5810,13 @@ static int tg3_reset_hw(struct tg3 *tp)
5822 } 5810 }
5823 memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE); 5811 memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
5824 5812
5813 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
5814 tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT;
5815 /* reset to prevent losing 1st rx packet intermittently */
5816 tw32_f(MAC_RX_MODE, RX_MODE_RESET);
5817 udelay(10);
5818 }
5819
5825 tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE | 5820 tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
5826 MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE; 5821 MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
5827 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR); 5822 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR);
@@ -5953,7 +5948,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5953 tw32(MAC_LED_CTRL, tp->led_ctrl); 5948 tw32(MAC_LED_CTRL, tp->led_ctrl);
5954 5949
5955 tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB); 5950 tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
5956 if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) { 5951 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) {
5957 tw32_f(MAC_RX_MODE, RX_MODE_RESET); 5952 tw32_f(MAC_RX_MODE, RX_MODE_RESET);
5958 udelay(10); 5953 udelay(10);
5959 } 5954 }
@@ -7376,12 +7371,17 @@ static int tg3_nway_reset(struct net_device *dev)
7376 if (!netif_running(dev)) 7371 if (!netif_running(dev))
7377 return -EAGAIN; 7372 return -EAGAIN;
7378 7373
7374 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
7375 return -EINVAL;
7376
7379 spin_lock_bh(&tp->lock); 7377 spin_lock_bh(&tp->lock);
7380 r = -EINVAL; 7378 r = -EINVAL;
7381 tg3_readphy(tp, MII_BMCR, &bmcr); 7379 tg3_readphy(tp, MII_BMCR, &bmcr);
7382 if (!tg3_readphy(tp, MII_BMCR, &bmcr) && 7380 if (!tg3_readphy(tp, MII_BMCR, &bmcr) &&
7383 (bmcr & BMCR_ANENABLE)) { 7381 ((bmcr & BMCR_ANENABLE) ||
7384 tg3_writephy(tp, MII_BMCR, bmcr | BMCR_ANRESTART); 7382 (tp->tg3_flags2 & TG3_FLG2_PARALLEL_DETECT))) {
7383 tg3_writephy(tp, MII_BMCR, bmcr | BMCR_ANRESTART |
7384 BMCR_ANENABLE);
7385 r = 0; 7385 r = 0;
7386 } 7386 }
7387 spin_unlock_bh(&tp->lock); 7387 spin_unlock_bh(&tp->lock);
@@ -7943,19 +7943,32 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
7943 struct tg3_rx_buffer_desc *desc; 7943 struct tg3_rx_buffer_desc *desc;
7944 7944
7945 if (loopback_mode == TG3_MAC_LOOPBACK) { 7945 if (loopback_mode == TG3_MAC_LOOPBACK) {
7946 /* HW errata - mac loopback fails in some cases on 5780.
7947 * Normal traffic and PHY loopback are not affected by
7948 * errata.
7949 */
7950 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780)
7951 return 0;
7952
7946 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) | 7953 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
7947 MAC_MODE_PORT_INT_LPBACK | MAC_MODE_LINK_POLARITY | 7954 MAC_MODE_PORT_INT_LPBACK | MAC_MODE_LINK_POLARITY |
7948 MAC_MODE_PORT_MODE_GMII; 7955 MAC_MODE_PORT_MODE_GMII;
7949 tw32(MAC_MODE, mac_mode); 7956 tw32(MAC_MODE, mac_mode);
7950 } else if (loopback_mode == TG3_PHY_LOOPBACK) { 7957 } else if (loopback_mode == TG3_PHY_LOOPBACK) {
7958 tg3_writephy(tp, MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX |
7959 BMCR_SPEED1000);
7960 udelay(40);
7961 /* reset to prevent losing 1st rx packet intermittently */
7962 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
7963 tw32_f(MAC_RX_MODE, RX_MODE_RESET);
7964 udelay(10);
7965 tw32_f(MAC_RX_MODE, tp->rx_mode);
7966 }
7951 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) | 7967 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
7952 MAC_MODE_LINK_POLARITY | MAC_MODE_PORT_MODE_GMII; 7968 MAC_MODE_LINK_POLARITY | MAC_MODE_PORT_MODE_GMII;
7953 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) 7969 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)
7954 mac_mode &= ~MAC_MODE_LINK_POLARITY; 7970 mac_mode &= ~MAC_MODE_LINK_POLARITY;
7955 tw32(MAC_MODE, mac_mode); 7971 tw32(MAC_MODE, mac_mode);
7956
7957 tg3_writephy(tp, MII_BMCR, BMCR_LOOPBACK | BMCR_FULLDPLX |
7958 BMCR_SPEED1000);
7959 } 7972 }
7960 else 7973 else
7961 return -EINVAL; 7974 return -EINVAL;
@@ -9271,6 +9284,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9271 static struct pci_device_id write_reorder_chipsets[] = { 9284 static struct pci_device_id write_reorder_chipsets[] = {
9272 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 9285 { PCI_DEVICE(PCI_VENDOR_ID_AMD,
9273 PCI_DEVICE_ID_AMD_FE_GATE_700C) }, 9286 PCI_DEVICE_ID_AMD_FE_GATE_700C) },
9287 { PCI_DEVICE(PCI_VENDOR_ID_VIA,
9288 PCI_DEVICE_ID_VIA_8385_0) },
9274 { }, 9289 { },
9275 }; 9290 };
9276 u32 misc_ctrl_reg; 9291 u32 misc_ctrl_reg;
@@ -9285,15 +9300,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9285 tp->tg3_flags2 |= TG3_FLG2_SUN_570X; 9300 tp->tg3_flags2 |= TG3_FLG2_SUN_570X;
9286#endif 9301#endif
9287 9302
9288 /* If we have an AMD 762 chipset, write
9289 * reordering to the mailbox registers done by the host
9290 * controller can cause major troubles. We read back from
9291 * every mailbox register write to force the writes to be
9292 * posted to the chip in order.
9293 */
9294 if (pci_dev_present(write_reorder_chipsets))
9295 tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
9296
9297 /* Force memory write invalidate off. If we leave it on, 9303 /* Force memory write invalidate off. If we leave it on,
9298 * then on 5700_BX chips we have to enable a workaround. 9304 * then on 5700_BX chips we have to enable a workaround.
9299 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary 9305 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary
@@ -9424,6 +9430,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9424 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 9430 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0)
9425 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 9431 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
9426 9432
9433 /* If we have an AMD 762 or VIA K8T800 chipset, write
9434 * reordering to the mailbox registers done by the host
9435 * controller can cause major troubles. We read back from
9436 * every mailbox register write to force the writes to be
9437 * posted to the chip in order.
9438 */
9439 if (pci_dev_present(write_reorder_chipsets) &&
9440 !(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS))
9441 tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
9442
9427 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 && 9443 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 &&
9428 tp->pci_lat_timer < 64) { 9444 tp->pci_lat_timer < 64) {
9429 tp->pci_lat_timer = 64; 9445 tp->pci_lat_timer = 64;
@@ -9532,7 +9548,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
9532 tp->write32_rx_mbox = tg3_write_indirect_mbox; 9548 tp->write32_rx_mbox = tg3_write_indirect_mbox;
9533 9549
9534 iounmap(tp->regs); 9550 iounmap(tp->regs);
9535 tp->regs = 0; 9551 tp->regs = NULL;
9536 9552
9537 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd); 9553 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd);
9538 pci_cmd &= ~PCI_COMMAND_MEMORY; 9554 pci_cmd &= ~PCI_COMMAND_MEMORY;
@@ -10338,6 +10354,44 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
10338 }; 10354 };
10339} 10355}
10340 10356
10357static char * __devinit tg3_bus_string(struct tg3 *tp, char *str)
10358{
10359 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
10360 strcpy(str, "PCI Express");
10361 return str;
10362 } else if (tp->tg3_flags & TG3_FLAG_PCIX_MODE) {
10363 u32 clock_ctrl = tr32(TG3PCI_CLOCK_CTRL) & 0x1f;
10364
10365 strcpy(str, "PCIX:");
10366
10367 if ((clock_ctrl == 7) ||
10368 ((tr32(GRC_MISC_CFG) & GRC_MISC_CFG_BOARD_ID_MASK) ==
10369 GRC_MISC_CFG_BOARD_ID_5704CIOBE))
10370 strcat(str, "133MHz");
10371 else if (clock_ctrl == 0)
10372 strcat(str, "33MHz");
10373 else if (clock_ctrl == 2)
10374 strcat(str, "50MHz");
10375 else if (clock_ctrl == 4)
10376 strcat(str, "66MHz");
10377 else if (clock_ctrl == 6)
10378 strcat(str, "100MHz");
10379 else if (clock_ctrl == 7)
10380 strcat(str, "133MHz");
10381 } else {
10382 strcpy(str, "PCI:");
10383 if (tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED)
10384 strcat(str, "66MHz");
10385 else
10386 strcat(str, "33MHz");
10387 }
10388 if (tp->tg3_flags & TG3_FLAG_PCI_32BIT)
10389 strcat(str, ":32-bit");
10390 else
10391 strcat(str, ":64-bit");
10392 return str;
10393}
10394
10341static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp) 10395static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
10342{ 10396{
10343 struct pci_dev *peer; 10397 struct pci_dev *peer;
@@ -10400,6 +10454,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10400 struct net_device *dev; 10454 struct net_device *dev;
10401 struct tg3 *tp; 10455 struct tg3 *tp;
10402 int i, err, pci_using_dac, pm_cap; 10456 int i, err, pci_using_dac, pm_cap;
10457 char str[40];
10403 10458
10404 if (tg3_version_printed++ == 0) 10459 if (tg3_version_printed++ == 0)
10405 printk(KERN_INFO "%s", version); 10460 printk(KERN_INFO "%s", version);
@@ -10645,16 +10700,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10645 10700
10646 pci_set_drvdata(pdev, dev); 10701 pci_set_drvdata(pdev, dev);
10647 10702
10648 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (PCI%s:%s:%s) %sBaseT Ethernet ", 10703 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %sBaseT Ethernet ",
10649 dev->name, 10704 dev->name,
10650 tp->board_part_number, 10705 tp->board_part_number,
10651 tp->pci_chip_rev_id, 10706 tp->pci_chip_rev_id,
10652 tg3_phy_string(tp), 10707 tg3_phy_string(tp),
10653 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "X" : ""), 10708 tg3_bus_string(tp, str),
10654 ((tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED) ?
10655 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "133MHz" : "66MHz") :
10656 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "100MHz" : "33MHz")),
10657 ((tp->tg3_flags & TG3_FLAG_PCI_32BIT) ? "32-bit" : "64-bit"),
10658 (tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100" : "10/100/1000"); 10709 (tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100" : "10/100/1000");
10659 10710
10660 for (i = 0; i < 6; i++) 10711 for (i = 0; i < 6; i++)
@@ -10680,7 +10731,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10680err_out_iounmap: 10731err_out_iounmap:
10681 if (tp->regs) { 10732 if (tp->regs) {
10682 iounmap(tp->regs); 10733 iounmap(tp->regs);
10683 tp->regs = 0; 10734 tp->regs = NULL;
10684 } 10735 }
10685 10736
10686err_out_free_dev: 10737err_out_free_dev:
@@ -10705,7 +10756,7 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
10705 unregister_netdev(dev); 10756 unregister_netdev(dev);
10706 if (tp->regs) { 10757 if (tp->regs) {
10707 iounmap(tp->regs); 10758 iounmap(tp->regs);
10708 tp->regs = 0; 10759 tp->regs = NULL;
10709 } 10760 }
10710 free_netdev(dev); 10761 free_netdev(dev);
10711 pci_release_regions(pdev); 10762 pci_release_regions(pdev);
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index c184b773e585..2e733c60bfa4 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2246,6 +2246,7 @@ struct tg3 {
2246 (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \ 2246 (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
2247 (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \ 2247 (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
2248 (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \ 2248 (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \
2249 (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5780 || \
2249 (X) == PHY_ID_BCM8002) 2250 (X) == PHY_ID_BCM8002)
2250 2251
2251 struct tg3_hw_stats *hw_stats; 2252 struct tg3_hw_stats *hw_stats;
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index e7b001017b9a..32057e65808b 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -531,7 +531,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
531 if (!time_after(jiffies, timeout)) continue; 531 if (!time_after(jiffies, timeout)) continue;
532 DPRINTK( "Hardware timeout during initialization.\n"); 532 DPRINTK( "Hardware timeout during initialization.\n");
533 iounmap(t_mmio); 533 iounmap(t_mmio);
534 kfree(ti);
535 return -ENODEV; 534 return -ENODEV;
536 } 535 }
537 ti->sram_phys = 536 ti->sram_phys =
@@ -645,7 +644,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
645 DPRINTK("Unknown shared ram paging info %01X\n", 644 DPRINTK("Unknown shared ram paging info %01X\n",
646 ti->shared_ram_paging); 645 ti->shared_ram_paging);
647 iounmap(t_mmio); 646 iounmap(t_mmio);
648 kfree(ti);
649 return -ENODEV; 647 return -ENODEV;
650 break; 648 break;
651 } /*end switch shared_ram_paging */ 649 } /*end switch shared_ram_paging */
@@ -675,7 +673,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
675 "driver limit (%05x), adapter not started.\n", 673 "driver limit (%05x), adapter not started.\n",
676 chk_base, ibmtr_mem_base + IBMTR_SHARED_RAM_SIZE); 674 chk_base, ibmtr_mem_base + IBMTR_SHARED_RAM_SIZE);
677 iounmap(t_mmio); 675 iounmap(t_mmio);
678 kfree(ti);
679 return -ENODEV; 676 return -ENODEV;
680 } else { /* seems cool, record what we have figured out */ 677 } else { /* seems cool, record what we have figured out */
681 ti->sram_base = new_base >> 12; 678 ti->sram_base = new_base >> 12;
@@ -690,7 +687,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
690 DPRINTK("Could not grab irq %d. Halting Token Ring driver.\n", 687 DPRINTK("Could not grab irq %d. Halting Token Ring driver.\n",
691 irq); 688 irq);
692 iounmap(t_mmio); 689 iounmap(t_mmio);
693 kfree(ti);
694 return -ENODEV; 690 return -ENODEV;
695 } 691 }
696 /*?? Now, allocate some of the PIO PORTs for this driver.. */ 692 /*?? Now, allocate some of the PIO PORTs for this driver.. */
@@ -699,7 +695,6 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
699 DPRINTK("Could not grab PIO range. Halting driver.\n"); 695 DPRINTK("Could not grab PIO range. Halting driver.\n");
700 free_irq(dev->irq, dev); 696 free_irq(dev->irq, dev);
701 iounmap(t_mmio); 697 iounmap(t_mmio);
702 kfree(ti);
703 return -EBUSY; 698 return -EBUSY;
704 } 699 }
705 700
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index 5db694c4eb02..683f14b01c06 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -172,7 +172,7 @@ void t21142_lnk_change(struct net_device *dev, int csr5)
172 int i; 172 int i;
173 for (i = 0; i < tp->mtable->leafcount; i++) 173 for (i = 0; i < tp->mtable->leafcount; i++)
174 if (tp->mtable->mleaf[i].media == dev->if_port) { 174 if (tp->mtable->mleaf[i].media == dev->if_port) {
175 int startup = ! ((tp->chip_id == DC21143 && tp->revision == 65)); 175 int startup = ! ((tp->chip_id == DC21143 && (tp->revision == 48 || tp->revision == 65)));
176 tp->cur_index = i; 176 tp->cur_index = i;
177 tulip_select_media(dev, startup); 177 tulip_select_media(dev, startup);
178 setup_done = 1; 178 setup_done = 1;
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index 48c03c11cd9a..a01efa6d5c62 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -72,7 +72,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
72 } 72 }
73 skb_reserve(skb, 4); 73 skb_reserve(skb, 4);
74 cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0); 74 cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0);
75 data = (cisco_packet*)skb->data; 75 data = (cisco_packet*)(skb->data + 4);
76 76
77 data->type = htonl(type); 77 data->type = htonl(type);
78 data->par1 = htonl(par1); 78 data->par1 = htonl(par1);
diff --git a/drivers/net/wan/sdlamain.c b/drivers/net/wan/sdlamain.c
index 74e151acef3e..7a8b22a7ea31 100644
--- a/drivers/net/wan/sdlamain.c
+++ b/drivers/net/wan/sdlamain.c
@@ -57,6 +57,7 @@
57#include <linux/ioport.h> /* request_region(), release_region() */ 57#include <linux/ioport.h> /* request_region(), release_region() */
58#include <linux/wanrouter.h> /* WAN router definitions */ 58#include <linux/wanrouter.h> /* WAN router definitions */
59#include <linux/wanpipe.h> /* WANPIPE common user API definitions */ 59#include <linux/wanpipe.h> /* WANPIPE common user API definitions */
60#include <linux/rcupdate.h>
60 61
61#include <linux/in.h> 62#include <linux/in.h>
62#include <asm/io.h> /* phys_to_virt() */ 63#include <asm/io.h> /* phys_to_virt() */
@@ -1268,37 +1269,41 @@ unsigned long get_ip_address(struct net_device *dev, int option)
1268 1269
1269 struct in_ifaddr *ifaddr; 1270 struct in_ifaddr *ifaddr;
1270 struct in_device *in_dev; 1271 struct in_device *in_dev;
1272 unsigned long addr = 0;
1271 1273
1272 if ((in_dev = __in_dev_get(dev)) == NULL){ 1274 rcu_read_lock();
1273 return 0; 1275 if ((in_dev = __in_dev_get_rcu(dev)) == NULL){
1276 goto out;
1274 } 1277 }
1275 1278
1276 if ((ifaddr = in_dev->ifa_list)== NULL ){ 1279 if ((ifaddr = in_dev->ifa_list)== NULL ){
1277 return 0; 1280 goto out;
1278 } 1281 }
1279 1282
1280 switch (option){ 1283 switch (option){
1281 1284
1282 case WAN_LOCAL_IP: 1285 case WAN_LOCAL_IP:
1283 return ifaddr->ifa_local; 1286 addr = ifaddr->ifa_local;
1284 break; 1287 break;
1285 1288
1286 case WAN_POINTOPOINT_IP: 1289 case WAN_POINTOPOINT_IP:
1287 return ifaddr->ifa_address; 1290 addr = ifaddr->ifa_address;
1288 break; 1291 break;
1289 1292
1290 case WAN_NETMASK_IP: 1293 case WAN_NETMASK_IP:
1291 return ifaddr->ifa_mask; 1294 addr = ifaddr->ifa_mask;
1292 break; 1295 break;
1293 1296
1294 case WAN_BROADCAST_IP: 1297 case WAN_BROADCAST_IP:
1295 return ifaddr->ifa_broadcast; 1298 addr = ifaddr->ifa_broadcast;
1296 break; 1299 break;
1297 default: 1300 default:
1298 return 0; 1301 break;
1299 } 1302 }
1300 1303
1301 return 0; 1304out:
1305 rcu_read_unlock();
1306 return addr;
1302} 1307}
1303 1308
1304void add_gateway(sdla_t *card, struct net_device *dev) 1309void add_gateway(sdla_t *card, struct net_device *dev)
diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c
index b56a7b516d24..a6d3b55013a5 100644
--- a/drivers/net/wan/syncppp.c
+++ b/drivers/net/wan/syncppp.c
@@ -769,7 +769,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb)
769 u32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */ 769 u32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */
770#ifdef CONFIG_INET 770#ifdef CONFIG_INET
771 rcu_read_lock(); 771 rcu_read_lock();
772 if ((in_dev = __in_dev_get(dev)) != NULL) 772 if ((in_dev = __in_dev_get_rcu(dev)) != NULL)
773 { 773 {
774 for (ifa=in_dev->ifa_list; ifa != NULL; 774 for (ifa=in_dev->ifa_list; ifa != NULL;
775 ifa=ifa->ifa_next) { 775 ifa=ifa->ifa_next) {
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 00a07f32a81e..7187958e40ca 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -243,7 +243,7 @@ config IPW_DEBUG
243 243
244config AIRO 244config AIRO
245 tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards" 245 tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards"
246 depends on NET_RADIO && ISA && (PCI || BROKEN) 246 depends on NET_RADIO && ISA_DMA_API && (PCI || BROKEN)
247 ---help--- 247 ---help---
248 This is the standard Linux driver to support Cisco/Aironet ISA and 248 This is the standard Linux driver to support Cisco/Aironet ISA and
249 PCI 802.11 wireless cards. 249 PCI 802.11 wireless cards.
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 8de49fe57233..15ceaf615756 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -503,9 +503,14 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
503 return 0; 503 return 0;
504 } 504 }
505 505
506 /* Length of the packet body */ 506 /* Check packet length, pad short packets, round up odd length */
507 /* FIXME: what if the skb is smaller than this? */ 507 len = max_t(int, ALIGN(skb->len, 2), ETH_ZLEN);
508 len = max_t(int,skb->len - ETH_HLEN, ETH_ZLEN - ETH_HLEN); 508 if (skb->len < len) {
509 skb = skb_padto(skb, len);
510 if (skb == NULL)
511 goto fail;
512 }
513 len -= ETH_HLEN;
509 514
510 eh = (struct ethhdr *)skb->data; 515 eh = (struct ethhdr *)skb->data;
511 516
@@ -557,8 +562,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
557 p = skb->data; 562 p = skb->data;
558 } 563 }
559 564
560 /* Round up for odd length packets */ 565 err = hermes_bap_pwrite(hw, USER_BAP, p, data_len,
561 err = hermes_bap_pwrite(hw, USER_BAP, p, ALIGN(data_len, 2),
562 txfid, data_off); 566 txfid, data_off);
563 if (err) { 567 if (err) {
564 printk(KERN_ERR "%s: Error %d writing packet to BAP\n", 568 printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
@@ -574,8 +578,9 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
574 txfid, NULL); 578 txfid, NULL);
575 if (err) { 579 if (err) {
576 netif_start_queue(dev); 580 netif_start_queue(dev);
577 printk(KERN_ERR "%s: Error %d transmitting packet\n", 581 if (net_ratelimit())
578 dev->name, err); 582 printk(KERN_ERR "%s: Error %d transmitting packet\n",
583 dev->name, err);
579 stats->tx_errors++; 584 stats->tx_errors++;
580 goto fail; 585 goto fail;
581 } 586 }
@@ -2458,7 +2463,6 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2458 dev->watchdog_timeo = HZ; /* 1 second timeout */ 2463 dev->watchdog_timeo = HZ; /* 1 second timeout */
2459 dev->get_stats = orinoco_get_stats; 2464 dev->get_stats = orinoco_get_stats;
2460 dev->ethtool_ops = &orinoco_ethtool_ops; 2465 dev->ethtool_ops = &orinoco_ethtool_ops;
2461 dev->get_wireless_stats = orinoco_get_wireless_stats;
2462 dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def; 2466 dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def;
2463 dev->change_mtu = orinoco_change_mtu; 2467 dev->change_mtu = orinoco_change_mtu;
2464 dev->set_multicast_list = orinoco_set_multicast_list; 2468 dev->set_multicast_list = orinoco_set_multicast_list;
@@ -4399,6 +4403,7 @@ static const struct iw_handler_def orinoco_handler_def = {
4399 .standard = orinoco_handler, 4403 .standard = orinoco_handler,
4400 .private = orinoco_private_handler, 4404 .private = orinoco_private_handler,
4401 .private_args = orinoco_privtab, 4405 .private_args = orinoco_privtab,
4406 .get_wireless_stats = orinoco_get_wireless_stats,
4402}; 4407};
4403 4408
4404static void orinoco_get_drvinfo(struct net_device *dev, 4409static void orinoco_get_drvinfo(struct net_device *dev,
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 4b0acae22b0d..7bc7fc823128 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -1352,7 +1352,7 @@ static unsigned char *strip_make_packet(unsigned char *buffer,
1352 struct in_device *in_dev; 1352 struct in_device *in_dev;
1353 1353
1354 rcu_read_lock(); 1354 rcu_read_lock();
1355 in_dev = __in_dev_get(strip_info->dev); 1355 in_dev = __in_dev_get_rcu(strip_info->dev);
1356 if (in_dev == NULL) { 1356 if (in_dev == NULL) {
1357 rcu_read_unlock(); 1357 rcu_read_unlock();
1358 return NULL; 1358 return NULL;
@@ -1508,7 +1508,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb)
1508 1508
1509 brd = addr = 0; 1509 brd = addr = 0;
1510 rcu_read_lock(); 1510 rcu_read_lock();
1511 in_dev = __in_dev_get(strip_info->dev); 1511 in_dev = __in_dev_get_rcu(strip_info->dev);
1512 if (in_dev) { 1512 if (in_dev) {
1513 if (in_dev->ifa_list) { 1513 if (in_dev->ifa_list) {
1514 brd = in_dev->ifa_list->ifa_broadcast; 1514 brd = in_dev->ifa_list->ifa_broadcast;
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index e90fb72a6962..286902298e33 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -37,6 +37,7 @@
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/ctype.h> 38#include <linux/ctype.h>
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/rcupdate.h>
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/processor.h> 42#include <asm/processor.h>
42#include <asm/hardware.h> 43#include <asm/hardware.h>
@@ -358,9 +359,10 @@ static __inline__ int led_get_net_activity(void)
358 /* we are running as tasklet, so locking dev_base 359 /* we are running as tasklet, so locking dev_base
359 * for reading should be OK */ 360 * for reading should be OK */
360 read_lock(&dev_base_lock); 361 read_lock(&dev_base_lock);
362 rcu_read_lock();
361 for (dev = dev_base; dev; dev = dev->next) { 363 for (dev = dev_base; dev; dev = dev->next) {
362 struct net_device_stats *stats; 364 struct net_device_stats *stats;
363 struct in_device *in_dev = __in_dev_get(dev); 365 struct in_device *in_dev = __in_dev_get_rcu(dev);
364 if (!in_dev || !in_dev->ifa_list) 366 if (!in_dev || !in_dev->ifa_list)
365 continue; 367 continue;
366 if (LOOPBACK(in_dev->ifa_list->ifa_local)) 368 if (LOOPBACK(in_dev->ifa_list->ifa_local))
@@ -371,6 +373,7 @@ static __inline__ int led_get_net_activity(void)
371 rx_total += stats->rx_packets; 373 rx_total += stats->rx_packets;
372 tx_total += stats->tx_packets; 374 tx_total += stats->tx_packets;
373 } 375 }
376 rcu_read_unlock();
374 read_unlock(&dev_base_lock); 377 read_unlock(&dev_base_lock);
375 378
376 retval = 0; 379 retval = 0;
diff --git a/drivers/pci/.gitignore b/drivers/pci/.gitignore
new file mode 100644
index 000000000000..f297ca8d313e
--- /dev/null
+++ b/drivers/pci/.gitignore
@@ -0,0 +1,4 @@
1classlist.h
2devlist.h
3gen-devlist
4
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index 10444988a10b..e1743be31909 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -7,7 +7,6 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
7 char *buffer, int buffer_size) 7 char *buffer, int buffer_size)
8{ 8{
9 struct pci_dev *pdev; 9 struct pci_dev *pdev;
10 char *scratch;
11 int i = 0; 10 int i = 0;
12 int length = 0; 11 int length = 0;
13 12
@@ -18,9 +17,6 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
18 if (!pdev) 17 if (!pdev)
19 return -ENODEV; 18 return -ENODEV;
20 19
21 scratch = buffer;
22
23
24 if (add_hotplug_env_var(envp, num_envp, &i, 20 if (add_hotplug_env_var(envp, num_envp, &i,
25 buffer, buffer_size, &length, 21 buffer, buffer_size, &length,
26 "PCI_CLASS=%04X", pdev->class)) 22 "PCI_CLASS=%04X", pdev->class))
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 8122fe734aa7..b1ba429e0a2d 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -558,7 +558,7 @@ static int configure_device (struct pci_func *func)
558 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); 558 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE);
559 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); 559 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY);
560 560
561 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); 561 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L);
562 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); 562 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE);
563 563
564 return 0; 564 return 0;
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 0e0947601526..898f6da6f0de 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -2526,7 +2526,6 @@ configure_new_function(struct controller *ctrl, struct pci_func *func,
2526 int cloop; 2526 int cloop;
2527 u8 temp_byte; 2527 u8 temp_byte;
2528 u8 class_code; 2528 u8 class_code;
2529 u16 temp_word;
2530 u32 rc; 2529 u32 rc;
2531 u32 temp_register; 2530 u32 temp_register;
2532 u32 base; 2531 u32 base;
@@ -2682,8 +2681,7 @@ configure_new_function(struct controller *ctrl, struct pci_func *func,
2682 } /* End of base register loop */ 2681 } /* End of base register loop */
2683 2682
2684 /* disable ROM base Address */ 2683 /* disable ROM base Address */
2685 temp_word = 0x00L; 2684 rc = pci_bus_write_config_dword (pci_bus, devfn, PCI_ROM_ADDRESS, 0x00);
2686 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_ROM_ADDRESS, temp_word);
2687 2685
2688 /* Set HP parameters (Cache Line Size, Latency Timer) */ 2686 /* Set HP parameters (Cache Line Size, Latency Timer) */
2689 rc = pciehprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL); 2687 rc = pciehprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL);
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index 752e6513c447..db69be85b458 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -62,7 +62,7 @@ static ssize_t add_slot_store(struct dlpar_io_attr *dlpar_attr,
62 char drc_name[MAX_DRC_NAME_LEN]; 62 char drc_name[MAX_DRC_NAME_LEN];
63 char *end; 63 char *end;
64 64
65 if (nbytes > MAX_DRC_NAME_LEN) 65 if (nbytes >= MAX_DRC_NAME_LEN)
66 return 0; 66 return 0;
67 67
68 memcpy(drc_name, buf, nbytes); 68 memcpy(drc_name, buf, nbytes);
@@ -83,7 +83,7 @@ static ssize_t remove_slot_store(struct dlpar_io_attr *dlpar_attr,
83 char drc_name[MAX_DRC_NAME_LEN]; 83 char drc_name[MAX_DRC_NAME_LEN];
84 char *end; 84 char *end;
85 85
86 if (nbytes > MAX_DRC_NAME_LEN) 86 if (nbytes >= MAX_DRC_NAME_LEN)
87 return 0; 87 return 0;
88 88
89 memcpy(drc_name, buf, nbytes); 89 memcpy(drc_name, buf, nbytes);
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index b1409441c1cd..a32ae82e5922 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -159,7 +159,7 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
159 159
160 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus); 160 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(pci_bus);
161 161
162 slot = kcalloc(1, sizeof(*slot), GFP_KERNEL); 162 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
163 if (!slot) 163 if (!slot)
164 return -ENOMEM; 164 return -ENOMEM;
165 bss_hotplug_slot->private = slot; 165 bss_hotplug_slot->private = slot;
@@ -491,7 +491,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
491 if (sn_pci_slot_valid(pci_bus, device) != 1) 491 if (sn_pci_slot_valid(pci_bus, device) != 1)
492 continue; 492 continue;
493 493
494 bss_hotplug_slot = kcalloc(1, sizeof(*bss_hotplug_slot), 494 bss_hotplug_slot = kzalloc(sizeof(*bss_hotplug_slot),
495 GFP_KERNEL); 495 GFP_KERNEL);
496 if (!bss_hotplug_slot) { 496 if (!bss_hotplug_slot) {
497 rc = -ENOMEM; 497 rc = -ENOMEM;
@@ -499,7 +499,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
499 } 499 }
500 500
501 bss_hotplug_slot->info = 501 bss_hotplug_slot->info =
502 kcalloc(1, sizeof(struct hotplug_slot_info), 502 kzalloc(sizeof(struct hotplug_slot_info),
503 GFP_KERNEL); 503 GFP_KERNEL);
504 if (!bss_hotplug_slot->info) { 504 if (!bss_hotplug_slot->info) {
505 rc = -ENOMEM; 505 rc = -ENOMEM;
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 783b5abb0717..91c9903e621f 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -2824,8 +2824,7 @@ static int configure_new_function (struct controller * ctrl, struct pci_func * f
2824 } 2824 }
2825#endif 2825#endif
2826 /* Disable ROM base Address */ 2826 /* Disable ROM base Address */
2827 temp_word = 0x00L; 2827 rc = pci_bus_write_config_dword (pci_bus, devfn, PCI_ROM_ADDRESS, 0x00);
2828 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_ROM_ADDRESS, temp_word);
2829 2828
2830 /* Set HP parameters (Cache Line Size, Latency Timer) */ 2829 /* Set HP parameters (Cache Line Size, Latency Timer) */
2831 rc = shpchprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL); 2830 rc = shpchprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 56a3b397efee..2898830c496f 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -360,7 +360,7 @@ pci_create_resource_files(struct pci_dev *pdev)
360 continue; 360 continue;
361 361
362 /* allocate attribute structure, piggyback attribute name */ 362 /* allocate attribute structure, piggyback attribute name */
363 res_attr = kcalloc(1, sizeof(*res_attr) + 10, GFP_ATOMIC); 363 res_attr = kzalloc(sizeof(*res_attr) + 10, GFP_ATOMIC);
364 if (res_attr) { 364 if (res_attr) {
365 char *res_attr_name = (char *)(res_attr + 1); 365 char *res_attr_name = (char *)(res_attr + 1);
366 366
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 26a55d08b506..005786416bb5 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -165,7 +165,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
165 if (l == 0xffffffff) 165 if (l == 0xffffffff)
166 l = 0; 166 l = 0;
167 if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) { 167 if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) {
168 sz = pci_size(l, sz, PCI_BASE_ADDRESS_MEM_MASK); 168 sz = pci_size(l, sz, (u32)PCI_BASE_ADDRESS_MEM_MASK);
169 if (!sz) 169 if (!sz)
170 continue; 170 continue;
171 res->start = l & PCI_BASE_ADDRESS_MEM_MASK; 171 res->start = l & PCI_BASE_ADDRESS_MEM_MASK;
@@ -215,7 +215,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
215 if (l == 0xffffffff) 215 if (l == 0xffffffff)
216 l = 0; 216 l = 0;
217 if (sz && sz != 0xffffffff) { 217 if (sz && sz != 0xffffffff) {
218 sz = pci_size(l, sz, PCI_ROM_ADDRESS_MASK); 218 sz = pci_size(l, sz, (u32)PCI_ROM_ADDRESS_MASK);
219 if (sz) { 219 if (sz) {
220 res->flags = (l & IORESOURCE_ROM_ENABLE) | 220 res->flags = (l & IORESOURCE_ROM_ENABLE) |
221 IORESOURCE_MEM | IORESOURCE_PREFETCH | 221 IORESOURCE_MEM | IORESOURCE_PREFETCH |
@@ -402,6 +402,12 @@ static void pci_enable_crs(struct pci_dev *dev)
402static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) 402static void __devinit pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max)
403{ 403{
404 struct pci_bus *parent = child->parent; 404 struct pci_bus *parent = child->parent;
405
406 /* Attempts to fix that up are really dangerous unless
407 we're going to re-assign all bus numbers. */
408 if (!pcibios_assign_all_busses())
409 return;
410
405 while (parent->parent && parent->subordinate < max) { 411 while (parent->parent && parent->subordinate < max) {
406 parent->subordinate = max; 412 parent->subordinate = max;
407 pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, max); 413 pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, max);
@@ -478,8 +484,18 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
478 * We need to assign a number to this bus which we always 484 * We need to assign a number to this bus which we always
479 * do in the second pass. 485 * do in the second pass.
480 */ 486 */
481 if (!pass) 487 if (!pass) {
488 if (pcibios_assign_all_busses())
489 /* Temporarily disable forwarding of the
490 configuration cycles on all bridges in
491 this bus segment to avoid possible
492 conflicts in the second pass between two
493 bridges programmed with overlapping
494 bus ranges. */
495 pci_write_config_dword(dev, PCI_PRIMARY_BUS,
496 buses & ~0xffffff);
482 return max; 497 return max;
498 }
483 499
484 /* Clear errors */ 500 /* Clear errors */
485 pci_write_config_word(dev, PCI_STATUS, 0xffff); 501 pci_write_config_word(dev, PCI_STATUS, 0xffff);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 11ca44387cb0..7992bc8cc6a4 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -241,7 +241,8 @@ static void __devinit quirk_s3_64M(struct pci_dev *dev)
241DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M ); 241DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M );
242DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M ); 242DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M );
243 243
244static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, unsigned size, int nr) 244static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region,
245 unsigned size, int nr, const char *name)
245{ 246{
246 region &= ~(size-1); 247 region &= ~(size-1);
247 if (region) { 248 if (region) {
@@ -259,6 +260,7 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, unsi
259 pcibios_bus_to_resource(dev, res, &bus_region); 260 pcibios_bus_to_resource(dev, res, &bus_region);
260 261
261 pci_claim_resource(dev, nr); 262 pci_claim_resource(dev, nr);
263 printk("PCI quirk: region %04x-%04x claimed by %s\n", region, region + size - 1, name);
262 } 264 }
263} 265}
264 266
@@ -291,25 +293,98 @@ static void __devinit quirk_ali7101_acpi(struct pci_dev *dev)
291 u16 region; 293 u16 region;
292 294
293 pci_read_config_word(dev, 0xE0, &region); 295 pci_read_config_word(dev, 0xE0, &region);
294 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES); 296 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES, "ali7101 ACPI");
295 pci_read_config_word(dev, 0xE2, &region); 297 pci_read_config_word(dev, 0xE2, &region);
296 quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1); 298 quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1, "ali7101 SMB");
297} 299}
298DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, quirk_ali7101_acpi ); 300DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, quirk_ali7101_acpi );
299 301
302static void piix4_io_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable)
303{
304 u32 devres;
305 u32 mask, size, base;
306
307 pci_read_config_dword(dev, port, &devres);
308 if ((devres & enable) != enable)
309 return;
310 mask = (devres >> 16) & 15;
311 base = devres & 0xffff;
312 size = 16;
313 for (;;) {
314 unsigned bit = size >> 1;
315 if ((bit & mask) == bit)
316 break;
317 size = bit;
318 }
319 /*
320 * For now we only print it out. Eventually we'll want to
321 * reserve it (at least if it's in the 0x1000+ range), but
322 * let's get enough confirmation reports first.
323 */
324 base &= -size;
325 printk("%s PIO at %04x-%04x\n", name, base, base + size - 1);
326}
327
328static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable)
329{
330 u32 devres;
331 u32 mask, size, base;
332
333 pci_read_config_dword(dev, port, &devres);
334 if ((devres & enable) != enable)
335 return;
336 base = devres & 0xffff0000;
337 mask = (devres & 0x3f) << 16;
338 size = 128 << 16;
339 for (;;) {
340 unsigned bit = size >> 1;
341 if ((bit & mask) == bit)
342 break;
343 size = bit;
344 }
345 /*
346 * For now we only print it out. Eventually we'll want to
347 * reserve it, but let's get enough confirmation reports first.
348 */
349 base &= -size;
350 printk("%s MMIO at %04x-%04x\n", name, base, base + size - 1);
351}
352
300/* 353/*
301 * PIIX4 ACPI: Two IO regions pointed to by longwords at 354 * PIIX4 ACPI: Two IO regions pointed to by longwords at
302 * 0x40 (64 bytes of ACPI registers) 355 * 0x40 (64 bytes of ACPI registers)
303 * 0x90 (32 bytes of SMB registers) 356 * 0x90 (32 bytes of SMB registers)
357 * and a few strange programmable PIIX4 device resources.
304 */ 358 */
305static void __devinit quirk_piix4_acpi(struct pci_dev *dev) 359static void __devinit quirk_piix4_acpi(struct pci_dev *dev)
306{ 360{
307 u32 region; 361 u32 region, res_a;
308 362
309 pci_read_config_dword(dev, 0x40, &region); 363 pci_read_config_dword(dev, 0x40, &region);
310 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES); 364 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES, "PIIX4 ACPI");
311 pci_read_config_dword(dev, 0x90, &region); 365 pci_read_config_dword(dev, 0x90, &region);
312 quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1); 366 quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1, "PIIX4 SMB");
367
368 /* Device resource A has enables for some of the other ones */
369 pci_read_config_dword(dev, 0x5c, &res_a);
370
371 piix4_io_quirk(dev, "PIIX4 devres B", 0x60, 3 << 21);
372 piix4_io_quirk(dev, "PIIX4 devres C", 0x64, 3 << 21);
373
374 /* Device resource D is just bitfields for static resources */
375
376 /* Device 12 enabled? */
377 if (res_a & (1 << 29)) {
378 piix4_io_quirk(dev, "PIIX4 devres E", 0x68, 1 << 20);
379 piix4_mem_quirk(dev, "PIIX4 devres F", 0x6c, 1 << 7);
380 }
381 /* Device 13 enabled? */
382 if (res_a & (1 << 30)) {
383 piix4_io_quirk(dev, "PIIX4 devres G", 0x70, 1 << 20);
384 piix4_mem_quirk(dev, "PIIX4 devres H", 0x74, 1 << 7);
385 }
386 piix4_io_quirk(dev, "PIIX4 devres I", 0x78, 1 << 20);
387 piix4_io_quirk(dev, "PIIX4 devres J", 0x7c, 1 << 20);
313} 388}
314DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, quirk_piix4_acpi ); 389DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, quirk_piix4_acpi );
315 390
@@ -323,10 +398,10 @@ static void __devinit quirk_ich4_lpc_acpi(struct pci_dev *dev)
323 u32 region; 398 u32 region;
324 399
325 pci_read_config_dword(dev, 0x40, &region); 400 pci_read_config_dword(dev, 0x40, &region);
326 quirk_io_region(dev, region, 128, PCI_BRIDGE_RESOURCES); 401 quirk_io_region(dev, region, 128, PCI_BRIDGE_RESOURCES, "ICH4 ACPI/GPIO/TCO");
327 402
328 pci_read_config_dword(dev, 0x58, &region); 403 pci_read_config_dword(dev, 0x58, &region);
329 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES+1); 404 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES+1, "ICH4 GPIO");
330} 405}
331DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, quirk_ich4_lpc_acpi ); 406DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, quirk_ich4_lpc_acpi );
332DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0, quirk_ich4_lpc_acpi ); 407DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0, quirk_ich4_lpc_acpi );
@@ -352,7 +427,7 @@ static void __devinit quirk_vt82c586_acpi(struct pci_dev *dev)
352 if (rev & 0x10) { 427 if (rev & 0x10) {
353 pci_read_config_dword(dev, 0x48, &region); 428 pci_read_config_dword(dev, 0x48, &region);
354 region &= PCI_BASE_ADDRESS_IO_MASK; 429 region &= PCI_BASE_ADDRESS_IO_MASK;
355 quirk_io_region(dev, region, 256, PCI_BRIDGE_RESOURCES); 430 quirk_io_region(dev, region, 256, PCI_BRIDGE_RESOURCES, "vt82c586 ACPI");
356 } 431 }
357} 432}
358DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_vt82c586_acpi ); 433DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_vt82c586_acpi );
@@ -372,11 +447,11 @@ static void __devinit quirk_vt82c686_acpi(struct pci_dev *dev)
372 447
373 pci_read_config_word(dev, 0x70, &hm); 448 pci_read_config_word(dev, 0x70, &hm);
374 hm &= PCI_BASE_ADDRESS_IO_MASK; 449 hm &= PCI_BASE_ADDRESS_IO_MASK;
375 quirk_io_region(dev, hm, 128, PCI_BRIDGE_RESOURCES + 1); 450 quirk_io_region(dev, hm, 128, PCI_BRIDGE_RESOURCES + 1, "vt82c868 HW-mon");
376 451
377 pci_read_config_dword(dev, 0x90, &smb); 452 pci_read_config_dword(dev, 0x90, &smb);
378 smb &= PCI_BASE_ADDRESS_IO_MASK; 453 smb &= PCI_BASE_ADDRESS_IO_MASK;
379 quirk_io_region(dev, smb, 16, PCI_BRIDGE_RESOURCES + 2); 454 quirk_io_region(dev, smb, 16, PCI_BRIDGE_RESOURCES + 2, "vt82c868 SMB");
380} 455}
381DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vt82c686_acpi ); 456DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vt82c686_acpi );
382 457
@@ -391,11 +466,11 @@ static void __devinit quirk_vt8235_acpi(struct pci_dev *dev)
391 466
392 pci_read_config_word(dev, 0x88, &pm); 467 pci_read_config_word(dev, 0x88, &pm);
393 pm &= PCI_BASE_ADDRESS_IO_MASK; 468 pm &= PCI_BASE_ADDRESS_IO_MASK;
394 quirk_io_region(dev, pm, 128, PCI_BRIDGE_RESOURCES); 469 quirk_io_region(dev, pm, 128, PCI_BRIDGE_RESOURCES, "vt8235 PM");
395 470
396 pci_read_config_word(dev, 0xd0, &smb); 471 pci_read_config_word(dev, 0xd0, &smb);
397 smb &= PCI_BASE_ADDRESS_IO_MASK; 472 smb &= PCI_BASE_ADDRESS_IO_MASK;
398 quirk_io_region(dev, smb, 16, PCI_BRIDGE_RESOURCES + 1); 473 quirk_io_region(dev, smb, 16, PCI_BRIDGE_RESOURCES + 1, "vt8235 SMB");
399} 474}
400DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_vt8235_acpi); 475DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_vt8235_acpi);
401 476
@@ -1233,7 +1308,7 @@ static void __init quirk_alder_ioapic(struct pci_dev *pdev)
1233DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic ); 1308DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic );
1234#endif 1309#endif
1235 1310
1236#ifdef CONFIG_SCSI_SATA 1311#ifdef CONFIG_SCSI_SATA_INTEL_COMBINED
1237static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) 1312static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
1238{ 1313{
1239 u8 prog, comb, tmp; 1314 u8 prog, comb, tmp;
@@ -1310,7 +1385,7 @@ static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
1310 request_region(0x170, 8, "libata"); /* port 1 */ 1385 request_region(0x170, 8, "libata"); /* port 1 */
1311} 1386}
1312DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_intel_ide_combined ); 1387DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_intel_ide_combined );
1313#endif /* CONFIG_SCSI_SATA */ 1388#endif /* CONFIG_SCSI_SATA_INTEL_COMBINED */
1314 1389
1315 1390
1316int pcie_mch_quirk; 1391int pcie_mch_quirk;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 657be948baf7..28ce3a7ee434 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -40,7 +40,7 @@
40 * FIXME: IO should be max 256 bytes. However, since we may 40 * FIXME: IO should be max 256 bytes. However, since we may
41 * have a P2P bridge below a cardbus bridge, we need 4K. 41 * have a P2P bridge below a cardbus bridge, we need 4K.
42 */ 42 */
43#define CARDBUS_IO_SIZE (4*1024) 43#define CARDBUS_IO_SIZE (256)
44#define CARDBUS_MEM_SIZE (32*1024*1024) 44#define CARDBUS_MEM_SIZE (32*1024*1024)
45 45
46static void __devinit 46static void __devinit
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index ddc741e6ecbf..36cc9a96a338 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -146,7 +146,7 @@ config I82365
146 146
147config TCIC 147config TCIC
148 tristate "Databook TCIC host bridge support" 148 tristate "Databook TCIC host bridge support"
149 depends on PCMCIA 149 depends on PCMCIA && ISA
150 select PCCARD_NONSTATIC 150 select PCCARD_NONSTATIC
151 help 151 help
152 Say Y here to include support for the Databook TCIC family of PCMCIA 152 Say Y here to include support for the Databook TCIC family of PCMCIA
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 1d755e20880c..3f6d51d11374 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -228,6 +228,11 @@ int cb_alloc(struct pcmcia_socket * s)
228 pci_bus_size_bridges(bus); 228 pci_bus_size_bridges(bus);
229 pci_bus_assign_resources(bus); 229 pci_bus_assign_resources(bus);
230 cardbus_assign_irqs(bus, s->pci_irq); 230 cardbus_assign_irqs(bus, s->pci_irq);
231
232 /* socket specific tune function */
233 if (s->tune_bridge)
234 s->tune_bridge(s, bus);
235
231 pci_enable_bridges(bus); 236 pci_enable_bridges(bus);
232 pci_bus_add_devices(bus); 237 pci_bus_add_devices(bus);
233 238
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index fabd3529cebc..d5e76423a0ee 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -689,6 +689,9 @@ static int pccardd(void *__skt)
689 schedule(); 689 schedule();
690 try_to_freeze(); 690 try_to_freeze();
691 } 691 }
692 /* make sure we are running before we exit */
693 set_current_state(TASK_RUNNING);
694
692 remove_wait_queue(&skt->thread_wait, &wait); 695 remove_wait_queue(&skt->thread_wait, &wait);
693 696
694 /* remove from the device core */ 697 /* remove from the device core */
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 08d1c9288264..94be9e51654e 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -22,7 +22,6 @@
22 22
23#include <asm/hardware.h> 23#include <asm/hardware.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/mach-types.h>
26#include <asm/sizes.h> 25#include <asm/sizes.h>
27 26
28#include <asm/arch/mux.h> 27#include <asm/arch/mux.h>
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index c42455d20eb6..f9a5c70284b5 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -691,7 +691,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
691 unsigned long size = end - start + 1; 691 unsigned long size = end - start + 1;
692 int ret = 0; 692 int ret = 0;
693 693
694 if (end <= start) 694 if (end < start)
695 return -EINVAL; 695 return -EINVAL;
696 696
697 down(&rsrc_sem); 697 down(&rsrc_sem);
@@ -724,7 +724,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
724 unsigned long size = end - start + 1; 724 unsigned long size = end - start + 1;
725 int ret = 0; 725 int ret = 0;
726 726
727 if (end <= start) 727 if (end < start)
728 return -EINVAL; 728 return -EINVAL;
729 729
730 if (end > IO_SPACE_LIMIT) 730 if (end > IO_SPACE_LIMIT)
@@ -817,7 +817,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
817 817
818 /* if we got at least one of IO, and one of MEM, we can be glad and 818 /* if we got at least one of IO, and one of MEM, we can be glad and
819 * activate the PCMCIA subsystem */ 819 * activate the PCMCIA subsystem */
820 if (done & (IORESOURCE_MEM | IORESOURCE_IO)) 820 if (done == (IORESOURCE_MEM | IORESOURCE_IO))
821 s->resource_setup_done = 1; 821 s->resource_setup_done = 1;
822 822
823 return 0; 823 return 0;
@@ -925,7 +925,7 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size
925 return -EINVAL; 925 return -EINVAL;
926 } 926 }
927 } 927 }
928 if (end_addr <= start_addr) 928 if (end_addr < start_addr)
929 return -EINVAL; 929 return -EINVAL;
930 930
931 ret = adjust_io(s, add, start_addr, end_addr); 931 ret = adjust_io(s, add, start_addr, end_addr);
@@ -977,7 +977,7 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz
977 return -EINVAL; 977 return -EINVAL;
978 } 978 }
979 } 979 }
980 if (end_addr <= start_addr) 980 if (end_addr < start_addr)
981 return -EINVAL; 981 return -EINVAL;
982 982
983 ret = adjust_memory(s, add, start_addr, end_addr); 983 ret = adjust_memory(s, add, start_addr, end_addr);
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 888b70e6a484..9e7ccd8a4321 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -66,7 +66,7 @@ void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
66 if (pc_debug > lvl) { 66 if (pc_debug > lvl) {
67 printk(KERN_DEBUG "skt%u: %s: ", skt->nr, func); 67 printk(KERN_DEBUG "skt%u: %s: ", skt->nr, func);
68 va_start(args, fmt); 68 va_start(args, fmt);
69 printk(fmt, args); 69 vprintk(fmt, args);
70 va_end(args); 70 va_end(args);
71 } 71 }
72} 72}
@@ -321,8 +321,6 @@ soc_common_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
321 * less punt all of this work and let the kernel handle the details 321 * less punt all of this work and let the kernel handle the details
322 * of power configuration, reset, &c. We also record the value of 322 * of power configuration, reset, &c. We also record the value of
323 * `state' in order to regurgitate it to the PCMCIA core later. 323 * `state' in order to regurgitate it to the PCMCIA core later.
324 *
325 * Returns: 0
326 */ 324 */
327static int 325static int
328soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) 326soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
@@ -407,7 +405,7 @@ soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *m
407 * the map speed as requested, but override the address ranges 405 * the map speed as requested, but override the address ranges
408 * supplied by Card Services. 406 * supplied by Card Services.
409 * 407 *
410 * Returns: 0 on success, -1 on error 408 * Returns: 0 on success, -ERRNO on error
411 */ 409 */
412static int 410static int
413soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map) 411soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
@@ -655,8 +653,8 @@ static void soc_pcmcia_cpufreq_unregister(void)
655} 653}
656 654
657#else 655#else
658#define soc_pcmcia_cpufreq_register() 656static int soc_pcmcia_cpufreq_register(void) { return 0; }
659#define soc_pcmcia_cpufreq_unregister() 657static void soc_pcmcia_cpufreq_unregister(void) {}
660#endif 658#endif
661 659
662int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) 660int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
@@ -738,7 +736,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
738 goto out_err_5; 736 goto out_err_5;
739 } 737 }
740 738
741 if ( list_empty(&soc_pcmcia_sockets) ) 739 if (list_empty(&soc_pcmcia_sockets))
742 soc_pcmcia_cpufreq_register(); 740 soc_pcmcia_cpufreq_register();
743 741
744 list_add(&skt->node, &soc_pcmcia_sockets); 742 list_add(&skt->node, &soc_pcmcia_sockets);
@@ -839,7 +837,7 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
839 release_resource(&skt->res_io); 837 release_resource(&skt->res_io);
840 release_resource(&skt->res_skt); 838 release_resource(&skt->res_skt);
841 } 839 }
842 if ( list_empty(&soc_pcmcia_sockets) ) 840 if (list_empty(&soc_pcmcia_sockets))
843 soc_pcmcia_cpufreq_unregister(); 841 soc_pcmcia_cpufreq_unregister();
844 842
845 up(&soc_pcmcia_sockets_lock); 843 up(&soc_pcmcia_sockets_lock);
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index fbe233e19ceb..539b5cd1a598 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -59,6 +59,7 @@
59 59
60#define TI122X_SCR_SER_STEP 0xc0000000 60#define TI122X_SCR_SER_STEP 0xc0000000
61#define TI122X_SCR_INTRTIE 0x20000000 61#define TI122X_SCR_INTRTIE 0x20000000
62#define TIXX21_SCR_TIEALL 0x10000000
62#define TI122X_SCR_CBRSVD 0x00400000 63#define TI122X_SCR_CBRSVD 0x00400000
63#define TI122X_SCR_MRBURSTDN 0x00008000 64#define TI122X_SCR_MRBURSTDN 0x00008000
64#define TI122X_SCR_MRBURSTUP 0x00004000 65#define TI122X_SCR_MRBURSTUP 0x00004000
@@ -153,6 +154,12 @@
153/* EnE test register */ 154/* EnE test register */
154#define ENE_TEST_C9 0xc9 /* 8bit */ 155#define ENE_TEST_C9 0xc9 /* 8bit */
155#define ENE_TEST_C9_TLTENABLE 0x02 156#define ENE_TEST_C9_TLTENABLE 0x02
157#define ENE_TEST_C9_PFENABLE_F0 0x04
158#define ENE_TEST_C9_PFENABLE_F1 0x08
159#define ENE_TEST_C9_PFENABLE (ENE_TEST_C9_PFENABLE_F0 | ENE_TEST_C9_PFENABLE_F0)
160#define ENE_TEST_C9_WPDISALBLE_F0 0x40
161#define ENE_TEST_C9_WPDISALBLE_F1 0x80
162#define ENE_TEST_C9_WPDISALBLE (ENE_TEST_C9_WPDISALBLE_F0 | ENE_TEST_C9_WPDISALBLE_F1)
156 163
157/* 164/*
158 * Texas Instruments CardBus controller overrides. 165 * Texas Instruments CardBus controller overrides.
@@ -618,6 +625,7 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
618 int devfn; 625 int devfn;
619 unsigned int state; 626 unsigned int state;
620 int ret = 1; 627 int ret = 1;
628 u32 sysctl;
621 629
622 /* catch the two-slot controllers */ 630 /* catch the two-slot controllers */
623 switch (socket->dev->device) { 631 switch (socket->dev->device) {
@@ -640,6 +648,24 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
640 */ 648 */
641 break; 649 break;
642 650
651 case PCI_DEVICE_ID_TI_X515:
652 case PCI_DEVICE_ID_TI_X420:
653 case PCI_DEVICE_ID_TI_X620:
654 case PCI_DEVICE_ID_TI_XX21_XX11:
655 case PCI_DEVICE_ID_TI_7410:
656 case PCI_DEVICE_ID_TI_7610:
657 /*
658 * those are either single or dual slot CB with additional functions
659 * like 1394, smartcard reader, etc. check the TIEALL flag for them
660 * the TIEALL flag binds the IRQ of all functions toghether.
661 * we catch the single slot variants later.
662 */
663 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
664 if (sysctl & TIXX21_SCR_TIEALL)
665 return 0;
666
667 break;
668
643 /* single-slot controllers have the 2nd slot empty always :) */ 669 /* single-slot controllers have the 2nd slot empty always :) */
644 default: 670 default:
645 return 1; 671 return 1;
@@ -652,6 +678,15 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
652 if (!func) 678 if (!func)
653 return 1; 679 return 1;
654 680
681 /*
682 * check that the device id of both slots match. this is needed for the
683 * XX21 and the XX11 controller that share the same device id for single
684 * and dual slot controllers. return '2nd slot empty'. we already checked
685 * if the interrupt is tied to another function.
686 */
687 if (socket->dev->device != func->device)
688 goto out;
689
655 slot2 = pci_get_drvdata(func); 690 slot2 = pci_get_drvdata(func);
656 if (!slot2) 691 if (!slot2)
657 goto out; 692 goto out;
@@ -791,16 +826,6 @@ static int ti12xx_override(struct yenta_socket *socket)
791 config_writel(socket, TI113X_SYSTEM_CONTROL, val); 826 config_writel(socket, TI113X_SYSTEM_CONTROL, val);
792 827
793 /* 828 /*
794 * for EnE bridges only: clear testbit TLTEnable. this makes the
795 * RME Hammerfall DSP sound card working.
796 */
797 if (socket->dev->vendor == PCI_VENDOR_ID_ENE) {
798 u8 test_c9 = config_readb(socket, ENE_TEST_C9);
799 test_c9 &= ~ENE_TEST_C9_TLTENABLE;
800 config_writeb(socket, ENE_TEST_C9, test_c9);
801 }
802
803 /*
804 * Yenta expects controllers to use CSCINT to route 829 * Yenta expects controllers to use CSCINT to route
805 * CSC interrupts to PCI rather than INTVAL. 830 * CSC interrupts to PCI rather than INTVAL.
806 */ 831 */
@@ -841,5 +866,78 @@ static int ti1250_override(struct yenta_socket *socket)
841 return ti12xx_override(socket); 866 return ti12xx_override(socket);
842} 867}
843 868
869
870/**
871 * EnE specific part. EnE bridges are register compatible with TI bridges but
872 * have their own test registers and more important their own little problems.
873 * Some fixup code to make everybody happy (TM).
874 */
875
876#ifdef CONFIG_CARDBUS
877/**
878 * set/clear various test bits:
879 * Defaults to clear the bit.
880 * - mask (u8) defines what bits to change
881 * - bits (u8) is the values to change them to
882 * -> it's
883 * current = (current & ~mask) | bits
884 */
885/* pci ids of devices that wants to have the bit set */
886#define DEVID(_vend,_dev,_subvend,_subdev,mask,bits) { \
887 .vendor = _vend, \
888 .device = _dev, \
889 .subvendor = _subvend, \
890 .subdevice = _subdev, \
891 .driver_data = ((mask) << 8 | (bits)), \
892 }
893static struct pci_device_id ene_tune_tbl[] = {
894 /* Echo Audio products based on motorola DSP56301 and DSP56361 */
895 DEVID(PCI_VENDOR_ID_MOTOROLA, 0x1801, 0xECC0, PCI_ANY_ID,
896 ENE_TEST_C9_TLTENABLE | ENE_TEST_C9_PFENABLE, ENE_TEST_C9_TLTENABLE),
897 DEVID(PCI_VENDOR_ID_MOTOROLA, 0x3410, 0xECC0, PCI_ANY_ID,
898 ENE_TEST_C9_TLTENABLE | ENE_TEST_C9_PFENABLE, ENE_TEST_C9_TLTENABLE),
899
900 {}
901};
902
903static void ene_tune_bridge(struct pcmcia_socket *sock, struct pci_bus *bus)
904{
905 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
906 struct pci_dev *dev;
907 struct pci_device_id *id = NULL;
908 u8 test_c9, old_c9, mask, bits;
909
910 list_for_each_entry(dev, &bus->devices, bus_list) {
911 id = (struct pci_device_id *) pci_match_id(ene_tune_tbl, dev);
912 if (id)
913 break;
914 }
915
916 test_c9 = old_c9 = config_readb(socket, ENE_TEST_C9);
917 if (id) {
918 mask = (id->driver_data >> 8) & 0xFF;
919 bits = id->driver_data & 0xFF;
920
921 test_c9 = (test_c9 & ~mask) | bits;
922 }
923 else
924 /* default to clear TLTEnable bit, old behaviour */
925 test_c9 &= ~ENE_TEST_C9_TLTENABLE;
926
927 printk(KERN_INFO "yenta EnE: chaning testregister 0xC9, %02x -> %02x\n", old_c9, test_c9);
928 config_writeb(socket, ENE_TEST_C9, test_c9);
929}
930
931static int ene_override(struct yenta_socket *socket)
932{
933 /* install tune_bridge() function */
934 socket->socket.tune_bridge = ene_tune_bridge;
935
936 return ti1250_override(socket);
937}
938#else
939# define ene_override ti1250_override
940#endif
941
844#endif /* _LINUX_TI113X_H */ 942#endif /* _LINUX_TI113X_H */
845 943
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index ba4d78e5b121..db9f952f9e3c 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -559,12 +559,6 @@ static void yenta_interrogate(struct yenta_socket *socket)
559static int yenta_sock_init(struct pcmcia_socket *sock) 559static int yenta_sock_init(struct pcmcia_socket *sock)
560{ 560{
561 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 561 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
562 u16 bridge;
563
564 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR;
565 if (!socket->cb_irq)
566 bridge |= CB_BRIDGE_INTR;
567 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
568 562
569 exca_writeb(socket, I365_GBLCTL, 0x00); 563 exca_writeb(socket, I365_GBLCTL, 0x00);
570 exca_writeb(socket, I365_GENCTL, 0x00); 564 exca_writeb(socket, I365_GENCTL, 0x00);
@@ -819,6 +813,7 @@ enum {
819 CARDBUS_TYPE_TOPIC95, 813 CARDBUS_TYPE_TOPIC95,
820 CARDBUS_TYPE_TOPIC97, 814 CARDBUS_TYPE_TOPIC97,
821 CARDBUS_TYPE_O2MICRO, 815 CARDBUS_TYPE_O2MICRO,
816 CARDBUS_TYPE_ENE,
822}; 817};
823 818
824/* 819/*
@@ -865,6 +860,12 @@ static struct cardbus_type cardbus_type[] = {
865 .override = o2micro_override, 860 .override = o2micro_override,
866 .restore_state = o2micro_restore_state, 861 .restore_state = o2micro_restore_state,
867 }, 862 },
863 [CARDBUS_TYPE_ENE] = {
864 .override = ene_override,
865 .save_state = ti_save_state,
866 .restore_state = ti_restore_state,
867 .sock_init = ti_init,
868 },
868}; 869};
869 870
870 871
@@ -883,16 +884,8 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
883{ 884{
884 int i; 885 int i;
885 unsigned long val; 886 unsigned long val;
886 u16 bridge_ctrl;
887 u32 mask; 887 u32 mask;
888 888
889 /* Set up ISA irq routing to probe the ISA irqs.. */
890 bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
891 if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
892 bridge_ctrl |= CB_BRIDGE_INTR;
893 config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
894 }
895
896 /* 889 /*
897 * Probe for usable interrupts using the force 890 * Probe for usable interrupts using the force
898 * register to generate bogus card status events. 891 * register to generate bogus card status events.
@@ -914,9 +907,6 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
914 907
915 mask = probe_irq_mask(val) & 0xffff; 908 mask = probe_irq_mask(val) & 0xffff;
916 909
917 bridge_ctrl &= ~CB_BRIDGE_INTR;
918 config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
919
920 return mask; 910 return mask;
921} 911}
922 912
@@ -944,18 +934,11 @@ static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *re
944/* probes the PCI interrupt, use only on override functions */ 934/* probes the PCI interrupt, use only on override functions */
945static int yenta_probe_cb_irq(struct yenta_socket *socket) 935static int yenta_probe_cb_irq(struct yenta_socket *socket)
946{ 936{
947 u16 bridge_ctrl;
948
949 if (!socket->cb_irq) 937 if (!socket->cb_irq)
950 return -1; 938 return -1;
951 939
952 socket->probe_status = 0; 940 socket->probe_status = 0;
953 941
954 /* disable ISA interrupts */
955 bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
956 bridge_ctrl &= ~CB_BRIDGE_INTR;
957 config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
958
959 if (request_irq(socket->cb_irq, yenta_probe_handler, SA_SHIRQ, "yenta", socket)) { 942 if (request_irq(socket->cb_irq, yenta_probe_handler, SA_SHIRQ, "yenta", socket)) {
960 printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n"); 943 printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n");
961 return -1; 944 return -1;
@@ -966,7 +949,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
966 cb_writel(socket, CB_SOCKET_EVENT, -1); 949 cb_writel(socket, CB_SOCKET_EVENT, -1);
967 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); 950 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
968 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS); 951 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
969 952
970 msleep(100); 953 msleep(100);
971 954
972 /* disable interrupts */ 955 /* disable interrupts */
@@ -1004,11 +987,12 @@ static void yenta_config_init(struct yenta_socket *socket)
1004{ 987{
1005 u16 bridge; 988 u16 bridge;
1006 struct pci_dev *dev = socket->dev; 989 struct pci_dev *dev = socket->dev;
990 struct pci_bus_region region;
1007 991
1008 pci_set_power_state(socket->dev, 0); 992 pcibios_resource_to_bus(socket->dev, &region, &dev->resource[0]);
1009 993
1010 config_writel(socket, CB_LEGACY_MODE_BASE, 0); 994 config_writel(socket, CB_LEGACY_MODE_BASE, 0);
1011 config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start); 995 config_writel(socket, PCI_BASE_ADDRESS_0, region.start);
1012 config_writew(socket, PCI_COMMAND, 996 config_writew(socket, PCI_COMMAND,
1013 PCI_COMMAND_IO | 997 PCI_COMMAND_IO |
1014 PCI_COMMAND_MEMORY | 998 PCI_COMMAND_MEMORY |
@@ -1031,8 +1015,8 @@ static void yenta_config_init(struct yenta_socket *socket)
1031 * - PCI interrupts enabled if a PCI interrupt exists.. 1015 * - PCI interrupts enabled if a PCI interrupt exists..
1032 */ 1016 */
1033 bridge = config_readw(socket, CB_BRIDGE_CONTROL); 1017 bridge = config_readw(socket, CB_BRIDGE_CONTROL);
1034 bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN); 1018 bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
1035 bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN | CB_BRIDGE_INTR; 1019 bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
1036 config_writew(socket, CB_BRIDGE_CONTROL, bridge); 1020 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
1037} 1021}
1038 1022
@@ -1265,10 +1249,22 @@ static struct pci_device_id yenta_table [] = {
1265 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250), 1249 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
1266 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250), 1250 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
1267 1251
1268 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, TI12XX), 1252 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX),
1269 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, TI12XX), 1253 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX),
1270 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, TI1250), 1254 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX),
1271 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, TI12XX), 1255 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX),
1256 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX),
1257 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7510, TI12XX),
1258 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7610, TI12XX),
1259
1260 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_710, TI12XX),
1261 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_712, TI12XX),
1262 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_720, TI12XX),
1263 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_722, TI12XX),
1264 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, ENE),
1265 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE),
1266 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE),
1267 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE),
1272 1268
1273 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH), 1269 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
1274 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH), 1270 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index aac83ce6469c..a1c52a682191 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/blacklist.c 2 * drivers/s390/cio/blacklist.c
3 * S/390 common I/O routines -- blacklisting of specific devices 3 * S/390 common I/O routines -- blacklisting of specific devices
4 * $Revision: 1.34 $ 4 * $Revision: 1.35 $
5 * 5 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37/* 65536 bits to indicate if a devno is blacklisted or not */ 37/* 65536 bits to indicate if a devno is blacklisted or not */
38#define __BL_DEV_WORDS (__MAX_SUBCHANNELS + (8*sizeof(long) - 1) / \ 38#define __BL_DEV_WORDS ((__MAX_SUBCHANNELS + (8*sizeof(long) - 1)) / \
39 (8*sizeof(long))) 39 (8*sizeof(long)))
40static unsigned long bl_dev[__BL_DEV_WORDS]; 40static unsigned long bl_dev[__BL_DEV_WORDS];
41typedef enum {add, free} range_action; 41typedef enum {add, free} range_action;
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 91ea8e4777f3..dbb3eb0e330b 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -437,7 +437,7 @@ __ccwgroup_get_gdev_by_cdev(struct ccw_device *cdev)
437 if (cdev->dev.driver_data) { 437 if (cdev->dev.driver_data) {
438 gdev = (struct ccwgroup_device *)cdev->dev.driver_data; 438 gdev = (struct ccwgroup_device *)cdev->dev.driver_data;
439 if (get_device(&gdev->dev)) { 439 if (get_device(&gdev->dev)) {
440 if (klist_node_attached(&gdev->dev.knode_bus)) 440 if (device_is_registered(&gdev->dev))
441 return gdev; 441 return gdev;
442 put_device(&gdev->dev); 442 put_device(&gdev->dev);
443 } 443 }
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 14c76f5e4177..9adc11e8b8bc 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -544,7 +544,7 @@ get_disc_ccwdev_by_devno(unsigned int devno, struct ccw_device *sibling)
544 .sibling = sibling, 544 .sibling = sibling,
545 }; 545 };
546 546
547 dev = bus_find_device(&css_bus_type, NULL, &data, match_devno); 547 dev = bus_find_device(&ccw_bus_type, NULL, &data, match_devno);
548 548
549 return dev ? to_ccwdev(dev) : NULL; 549 return dev ? to_ccwdev(dev) : NULL;
550} 550}
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 6aeef3bacc33..0cb47eca91f3 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -682,9 +682,6 @@ z90crypt_cleanup_module(void)
682 del_timer(&config_timer); 682 del_timer(&config_timer);
683 del_timer(&cleanup_timer); 683 del_timer(&cleanup_timer);
684 684
685 if (z90_device_work)
686 destroy_workqueue(z90_device_work);
687
688 destroy_z90crypt(); 685 destroy_z90crypt();
689 686
690 PRINTKN("Unloaded.\n"); 687 PRINTKN("Unloaded.\n");
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index 2ad4797ce024..9963479ba89f 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -686,6 +686,7 @@ struct qeth_seqno {
686 __u32 pdu_hdr; 686 __u32 pdu_hdr;
687 __u32 pdu_hdr_ack; 687 __u32 pdu_hdr_ack;
688 __u16 ipa; 688 __u16 ipa;
689 __u32 pkt_seqno;
689}; 690};
690 691
691struct qeth_reply { 692struct qeth_reply {
@@ -848,6 +849,7 @@ qeth_realloc_headroom(struct qeth_card *card, struct sk_buff **skb, int size)
848 "on interface %s", QETH_CARD_IFNAME(card)); 849 "on interface %s", QETH_CARD_IFNAME(card));
849 return -ENOMEM; 850 return -ENOMEM;
850 } 851 }
852 kfree_skb(*skb);
851 *skb = new_skb; 853 *skb = new_skb;
852 } 854 }
853 return 0; 855 return 0;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 86582cf1e19e..bd28e2438d7f 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -511,7 +511,7 @@ static int
511__qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode) 511__qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
512{ 512{
513 struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data; 513 struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data;
514 int rc = 0; 514 int rc = 0, rc2 = 0, rc3 = 0;
515 enum qeth_card_states recover_flag; 515 enum qeth_card_states recover_flag;
516 516
517 QETH_DBF_TEXT(setup, 3, "setoffl"); 517 QETH_DBF_TEXT(setup, 3, "setoffl");
@@ -523,11 +523,13 @@ __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
523 CARD_BUS_ID(card)); 523 CARD_BUS_ID(card));
524 return -ERESTARTSYS; 524 return -ERESTARTSYS;
525 } 525 }
526 if ((rc = ccw_device_set_offline(CARD_DDEV(card))) || 526 rc = ccw_device_set_offline(CARD_DDEV(card));
527 (rc = ccw_device_set_offline(CARD_WDEV(card))) || 527 rc2 = ccw_device_set_offline(CARD_WDEV(card));
528 (rc = ccw_device_set_offline(CARD_RDEV(card)))) { 528 rc3 = ccw_device_set_offline(CARD_RDEV(card));
529 if (!rc)
530 rc = (rc2) ? rc2 : rc3;
531 if (rc)
529 QETH_DBF_TEXT_(setup, 2, "1err%d", rc); 532 QETH_DBF_TEXT_(setup, 2, "1err%d", rc);
530 }
531 if (recover_flag == CARD_STATE_UP) 533 if (recover_flag == CARD_STATE_UP)
532 card->state = CARD_STATE_RECOVER; 534 card->state = CARD_STATE_RECOVER;
533 qeth_notify_processes(); 535 qeth_notify_processes();
@@ -1046,6 +1048,7 @@ qeth_setup_card(struct qeth_card *card)
1046 spin_lock_init(&card->vlanlock); 1048 spin_lock_init(&card->vlanlock);
1047 card->vlangrp = NULL; 1049 card->vlangrp = NULL;
1048#endif 1050#endif
1051 spin_lock_init(&card->lock);
1049 spin_lock_init(&card->ip_lock); 1052 spin_lock_init(&card->ip_lock);
1050 spin_lock_init(&card->thread_mask_lock); 1053 spin_lock_init(&card->thread_mask_lock);
1051 card->thread_start_mask = 0; 1054 card->thread_start_mask = 0;
@@ -1626,16 +1629,6 @@ qeth_cmd_timeout(unsigned long data)
1626 spin_unlock_irqrestore(&reply->card->lock, flags); 1629 spin_unlock_irqrestore(&reply->card->lock, flags);
1627} 1630}
1628 1631
1629static void
1630qeth_reset_ip_addresses(struct qeth_card *card)
1631{
1632 QETH_DBF_TEXT(trace, 2, "rstipadd");
1633
1634 qeth_clear_ip_list(card, 0, 1);
1635 /* this function will also schedule the SET_IP_THREAD */
1636 qeth_set_multicast_list(card->dev);
1637}
1638
1639static struct qeth_ipa_cmd * 1632static struct qeth_ipa_cmd *
1640qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob) 1633qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
1641{ 1634{
@@ -1664,9 +1657,8 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
1664 "IP address reset.\n", 1657 "IP address reset.\n",
1665 QETH_CARD_IFNAME(card), 1658 QETH_CARD_IFNAME(card),
1666 card->info.chpid); 1659 card->info.chpid);
1667 card->lan_online = 1;
1668 netif_carrier_on(card->dev); 1660 netif_carrier_on(card->dev);
1669 qeth_reset_ip_addresses(card); 1661 qeth_schedule_recovery(card);
1670 return NULL; 1662 return NULL;
1671 case IPA_CMD_REGISTER_LOCAL_ADDR: 1663 case IPA_CMD_REGISTER_LOCAL_ADDR:
1672 QETH_DBF_TEXT(trace,3, "irla"); 1664 QETH_DBF_TEXT(trace,3, "irla");
@@ -2387,6 +2379,7 @@ qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb,
2387 skb_pull(skb, VLAN_HLEN); 2379 skb_pull(skb, VLAN_HLEN);
2388 } 2380 }
2389#endif 2381#endif
2382 *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno;
2390 return vlan_id; 2383 return vlan_id;
2391} 2384}
2392 2385
@@ -3014,7 +3007,7 @@ qeth_alloc_buffer_pool(struct qeth_card *card)
3014 return -ENOMEM; 3007 return -ENOMEM;
3015 } 3008 }
3016 for(j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j){ 3009 for(j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j){
3017 ptr = (void *) __get_free_page(GFP_KERNEL); 3010 ptr = (void *) __get_free_page(GFP_KERNEL|GFP_DMA);
3018 if (!ptr) { 3011 if (!ptr) {
3019 while (j > 0) 3012 while (j > 0)
3020 free_page((unsigned long) 3013 free_page((unsigned long)
@@ -3058,7 +3051,8 @@ qeth_alloc_qdio_buffers(struct qeth_card *card)
3058 if (card->qdio.state == QETH_QDIO_ALLOCATED) 3051 if (card->qdio.state == QETH_QDIO_ALLOCATED)
3059 return 0; 3052 return 0;
3060 3053
3061 card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), GFP_KERNEL); 3054 card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q),
3055 GFP_KERNEL|GFP_DMA);
3062 if (!card->qdio.in_q) 3056 if (!card->qdio.in_q)
3063 return - ENOMEM; 3057 return - ENOMEM;
3064 QETH_DBF_TEXT(setup, 2, "inq"); 3058 QETH_DBF_TEXT(setup, 2, "inq");
@@ -3083,7 +3077,7 @@ qeth_alloc_qdio_buffers(struct qeth_card *card)
3083 } 3077 }
3084 for (i = 0; i < card->qdio.no_out_queues; ++i){ 3078 for (i = 0; i < card->qdio.no_out_queues; ++i){
3085 card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q), 3079 card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q),
3086 GFP_KERNEL); 3080 GFP_KERNEL|GFP_DMA);
3087 if (!card->qdio.out_qs[i]){ 3081 if (!card->qdio.out_qs[i]){
3088 while (i > 0) 3082 while (i > 0)
3089 kfree(card->qdio.out_qs[--i]); 3083 kfree(card->qdio.out_qs[--i]);
@@ -5200,7 +5194,7 @@ qeth_free_vlan_addresses4(struct qeth_card *card, unsigned short vid)
5200 if (!card->vlangrp) 5194 if (!card->vlangrp)
5201 return; 5195 return;
5202 rcu_read_lock(); 5196 rcu_read_lock();
5203 in_dev = __in_dev_get(card->vlangrp->vlan_devices[vid]); 5197 in_dev = __in_dev_get_rcu(card->vlangrp->vlan_devices[vid]);
5204 if (!in_dev) 5198 if (!in_dev)
5205 goto out; 5199 goto out;
5206 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { 5200 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
@@ -6470,6 +6464,9 @@ qeth_query_ipassists_cb(struct qeth_card *card, struct qeth_reply *reply,
6470 if (cmd->hdr.prot_version == QETH_PROT_IPV4) { 6464 if (cmd->hdr.prot_version == QETH_PROT_IPV4) {
6471 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; 6465 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported;
6472 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; 6466 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
6467 /* Disable IPV6 support hard coded for Hipersockets */
6468 if(card->info.type == QETH_CARD_TYPE_IQD)
6469 card->options.ipa4.supported_funcs &= ~IPA_IPV6;
6473 } else { 6470 } else {
6474#ifdef CONFIG_QETH_IPV6 6471#ifdef CONFIG_QETH_IPV6
6475 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; 6472 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported;
@@ -7725,7 +7722,7 @@ qeth_arp_constructor(struct neighbour *neigh)
7725 goto out; 7722 goto out;
7726 7723
7727 rcu_read_lock(); 7724 rcu_read_lock();
7728 in_dev = rcu_dereference(__in_dev_get(dev)); 7725 in_dev = __in_dev_get_rcu(dev);
7729 if (in_dev == NULL) { 7726 if (in_dev == NULL) {
7730 rcu_read_unlock(); 7727 rcu_read_unlock();
7731 return -EINVAL; 7728 return -EINVAL;
diff --git a/drivers/s390/scsi/Makefile b/drivers/s390/scsi/Makefile
index fc145307a7d4..d6a78f1a2f16 100644
--- a/drivers/s390/scsi/Makefile
+++ b/drivers/s390/scsi/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5zfcp-objs := zfcp_aux.o zfcp_ccw.o zfcp_scsi.o zfcp_erp.o zfcp_qdio.o \ 5zfcp-objs := zfcp_aux.o zfcp_ccw.o zfcp_scsi.o zfcp_erp.o zfcp_qdio.o \
6 zfcp_fsf.o zfcp_sysfs_adapter.o zfcp_sysfs_port.o \ 6 zfcp_fsf.o zfcp_dbf.o zfcp_sysfs_adapter.o zfcp_sysfs_port.o \
7 zfcp_sysfs_unit.o zfcp_sysfs_driver.o 7 zfcp_sysfs_unit.o zfcp_sysfs_driver.o
8 8
9obj-$(CONFIG_ZFCP) += zfcp.o 9obj-$(CONFIG_ZFCP) += zfcp.o
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index bfe3ba73bc0f..cab098556b44 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -122,95 +122,6 @@ _zfcp_hex_dump(char *addr, int count)
122 122
123#define ZFCP_LOG_AREA ZFCP_LOG_AREA_OTHER 123#define ZFCP_LOG_AREA ZFCP_LOG_AREA_OTHER
124 124
125static inline int
126zfcp_fsf_req_is_scsi_cmnd(struct zfcp_fsf_req *fsf_req)
127{
128 return ((fsf_req->fsf_command == FSF_QTCB_FCP_CMND) &&
129 !(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT));
130}
131
132void
133zfcp_cmd_dbf_event_fsf(const char *text, struct zfcp_fsf_req *fsf_req,
134 void *add_data, int add_length)
135{
136 struct zfcp_adapter *adapter = fsf_req->adapter;
137 struct scsi_cmnd *scsi_cmnd;
138 int level = 3;
139 int i;
140 unsigned long flags;
141
142 spin_lock_irqsave(&adapter->dbf_lock, flags);
143 if (zfcp_fsf_req_is_scsi_cmnd(fsf_req)) {
144 scsi_cmnd = fsf_req->data.send_fcp_command_task.scsi_cmnd;
145 debug_text_event(adapter->cmd_dbf, level, "fsferror");
146 debug_text_event(adapter->cmd_dbf, level, text);
147 debug_event(adapter->cmd_dbf, level, &fsf_req,
148 sizeof (unsigned long));
149 debug_event(adapter->cmd_dbf, level, &fsf_req->seq_no,
150 sizeof (u32));
151 debug_event(adapter->cmd_dbf, level, &scsi_cmnd,
152 sizeof (unsigned long));
153 debug_event(adapter->cmd_dbf, level, &scsi_cmnd->cmnd,
154 min(ZFCP_CMD_DBF_LENGTH, (int)scsi_cmnd->cmd_len));
155 for (i = 0; i < add_length; i += ZFCP_CMD_DBF_LENGTH)
156 debug_event(adapter->cmd_dbf,
157 level,
158 (char *) add_data + i,
159 min(ZFCP_CMD_DBF_LENGTH, add_length - i));
160 }
161 spin_unlock_irqrestore(&adapter->dbf_lock, flags);
162}
163
164/* XXX additionally log unit if available */
165/* ---> introduce new parameter for unit, see 2.4 code */
166void
167zfcp_cmd_dbf_event_scsi(const char *text, struct scsi_cmnd *scsi_cmnd)
168{
169 struct zfcp_adapter *adapter;
170 union zfcp_req_data *req_data;
171 struct zfcp_fsf_req *fsf_req;
172 int level = ((host_byte(scsi_cmnd->result) != 0) ? 1 : 5);
173 unsigned long flags;
174
175 adapter = (struct zfcp_adapter *) scsi_cmnd->device->host->hostdata[0];
176 req_data = (union zfcp_req_data *) scsi_cmnd->host_scribble;
177 fsf_req = (req_data ? req_data->send_fcp_command_task.fsf_req : NULL);
178 spin_lock_irqsave(&adapter->dbf_lock, flags);
179 debug_text_event(adapter->cmd_dbf, level, "hostbyte");
180 debug_text_event(adapter->cmd_dbf, level, text);
181 debug_event(adapter->cmd_dbf, level, &scsi_cmnd->result, sizeof (u32));
182 debug_event(adapter->cmd_dbf, level, &scsi_cmnd,
183 sizeof (unsigned long));
184 debug_event(adapter->cmd_dbf, level, &scsi_cmnd->cmnd,
185 min(ZFCP_CMD_DBF_LENGTH, (int)scsi_cmnd->cmd_len));
186 if (likely(fsf_req)) {
187 debug_event(adapter->cmd_dbf, level, &fsf_req,
188 sizeof (unsigned long));
189 debug_event(adapter->cmd_dbf, level, &fsf_req->seq_no,
190 sizeof (u32));
191 } else {
192 debug_text_event(adapter->cmd_dbf, level, "");
193 debug_text_event(adapter->cmd_dbf, level, "");
194 }
195 spin_unlock_irqrestore(&adapter->dbf_lock, flags);
196}
197
198void
199zfcp_in_els_dbf_event(struct zfcp_adapter *adapter, const char *text,
200 struct fsf_status_read_buffer *status_buffer, int length)
201{
202 int level = 1;
203 int i;
204
205 debug_text_event(adapter->in_els_dbf, level, text);
206 debug_event(adapter->in_els_dbf, level, &status_buffer->d_id, 8);
207 for (i = 0; i < length; i += ZFCP_IN_ELS_DBF_LENGTH)
208 debug_event(adapter->in_els_dbf,
209 level,
210 (char *) status_buffer->payload + i,
211 min(ZFCP_IN_ELS_DBF_LENGTH, length - i));
212}
213
214/** 125/**
215 * zfcp_device_setup - setup function 126 * zfcp_device_setup - setup function
216 * @str: pointer to parameter string 127 * @str: pointer to parameter string
@@ -922,7 +833,7 @@ zfcp_unit_dequeue(struct zfcp_unit *unit)
922} 833}
923 834
924static void * 835static void *
925zfcp_mempool_alloc(unsigned int __nocast gfp_mask, void *size) 836zfcp_mempool_alloc(gfp_t gfp_mask, void *size)
926{ 837{
927 return kmalloc((size_t) size, gfp_mask); 838 return kmalloc((size_t) size, gfp_mask);
928} 839}
@@ -1017,81 +928,6 @@ zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
1017 mempool_destroy(adapter->pool.data_gid_pn); 928 mempool_destroy(adapter->pool.data_gid_pn);
1018} 929}
1019 930
1020/**
1021 * zfcp_adapter_debug_register - registers debug feature for an adapter
1022 * @adapter: pointer to adapter for which debug features should be registered
1023 * return: -ENOMEM on error, 0 otherwise
1024 */
1025int
1026zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
1027{
1028 char dbf_name[20];
1029
1030 /* debug feature area which records SCSI command failures (hostbyte) */
1031 spin_lock_init(&adapter->dbf_lock);
1032
1033 sprintf(dbf_name, ZFCP_CMD_DBF_NAME "%s",
1034 zfcp_get_busid_by_adapter(adapter));
1035 adapter->cmd_dbf = debug_register(dbf_name, ZFCP_CMD_DBF_INDEX,
1036 ZFCP_CMD_DBF_AREAS,
1037 ZFCP_CMD_DBF_LENGTH);
1038 debug_register_view(adapter->cmd_dbf, &debug_hex_ascii_view);
1039 debug_set_level(adapter->cmd_dbf, ZFCP_CMD_DBF_LEVEL);
1040
1041 /* debug feature area which records SCSI command aborts */
1042 sprintf(dbf_name, ZFCP_ABORT_DBF_NAME "%s",
1043 zfcp_get_busid_by_adapter(adapter));
1044 adapter->abort_dbf = debug_register(dbf_name, ZFCP_ABORT_DBF_INDEX,
1045 ZFCP_ABORT_DBF_AREAS,
1046 ZFCP_ABORT_DBF_LENGTH);
1047 debug_register_view(adapter->abort_dbf, &debug_hex_ascii_view);
1048 debug_set_level(adapter->abort_dbf, ZFCP_ABORT_DBF_LEVEL);
1049
1050 /* debug feature area which records incoming ELS commands */
1051 sprintf(dbf_name, ZFCP_IN_ELS_DBF_NAME "%s",
1052 zfcp_get_busid_by_adapter(adapter));
1053 adapter->in_els_dbf = debug_register(dbf_name, ZFCP_IN_ELS_DBF_INDEX,
1054 ZFCP_IN_ELS_DBF_AREAS,
1055 ZFCP_IN_ELS_DBF_LENGTH);
1056 debug_register_view(adapter->in_els_dbf, &debug_hex_ascii_view);
1057 debug_set_level(adapter->in_els_dbf, ZFCP_IN_ELS_DBF_LEVEL);
1058
1059 /* debug feature area which records erp events */
1060 sprintf(dbf_name, ZFCP_ERP_DBF_NAME "%s",
1061 zfcp_get_busid_by_adapter(adapter));
1062 adapter->erp_dbf = debug_register(dbf_name, ZFCP_ERP_DBF_INDEX,
1063 ZFCP_ERP_DBF_AREAS,
1064 ZFCP_ERP_DBF_LENGTH);
1065 debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);
1066 debug_set_level(adapter->erp_dbf, ZFCP_ERP_DBF_LEVEL);
1067
1068 if (!(adapter->cmd_dbf && adapter->abort_dbf &&
1069 adapter->in_els_dbf && adapter->erp_dbf)) {
1070 zfcp_adapter_debug_unregister(adapter);
1071 return -ENOMEM;
1072 }
1073
1074 return 0;
1075
1076}
1077
1078/**
1079 * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
1080 * @adapter: pointer to adapter for which debug features should be unregistered
1081 */
1082void
1083zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
1084{
1085 debug_unregister(adapter->abort_dbf);
1086 debug_unregister(adapter->cmd_dbf);
1087 debug_unregister(adapter->erp_dbf);
1088 debug_unregister(adapter->in_els_dbf);
1089 adapter->abort_dbf = NULL;
1090 adapter->cmd_dbf = NULL;
1091 adapter->erp_dbf = NULL;
1092 adapter->in_els_dbf = NULL;
1093}
1094
1095void 931void
1096zfcp_dummy_release(struct device *dev) 932zfcp_dummy_release(struct device *dev)
1097{ 933{
@@ -1462,10 +1298,6 @@ zfcp_fsf_incoming_els_rscn(struct zfcp_adapter *adapter,
1462 /* see FC-FS */ 1298 /* see FC-FS */
1463 no_entries = (fcp_rscn_head->payload_len / 4); 1299 no_entries = (fcp_rscn_head->payload_len / 4);
1464 1300
1465 zfcp_in_els_dbf_event(adapter, "##rscn", status_buffer,
1466 fcp_rscn_head->payload_len);
1467
1468 debug_text_event(adapter->erp_dbf, 1, "unsol_els_rscn:");
1469 for (i = 1; i < no_entries; i++) { 1301 for (i = 1; i < no_entries; i++) {
1470 /* skip head and start with 1st element */ 1302 /* skip head and start with 1st element */
1471 fcp_rscn_element++; 1303 fcp_rscn_element++;
@@ -1497,8 +1329,6 @@ zfcp_fsf_incoming_els_rscn(struct zfcp_adapter *adapter,
1497 (ZFCP_STATUS_PORT_DID_DID, &port->status)) { 1329 (ZFCP_STATUS_PORT_DID_DID, &port->status)) {
1498 ZFCP_LOG_INFO("incoming RSCN, trying to open " 1330 ZFCP_LOG_INFO("incoming RSCN, trying to open "
1499 "port 0x%016Lx\n", port->wwpn); 1331 "port 0x%016Lx\n", port->wwpn);
1500 debug_text_event(adapter->erp_dbf, 1,
1501 "unsol_els_rscnu:");
1502 zfcp_erp_port_reopen(port, 1332 zfcp_erp_port_reopen(port,
1503 ZFCP_STATUS_COMMON_ERP_FAILED); 1333 ZFCP_STATUS_COMMON_ERP_FAILED);
1504 continue; 1334 continue;
@@ -1524,8 +1354,6 @@ zfcp_fsf_incoming_els_rscn(struct zfcp_adapter *adapter,
1524 */ 1354 */
1525 ZFCP_LOG_INFO("incoming RSCN, trying to open " 1355 ZFCP_LOG_INFO("incoming RSCN, trying to open "
1526 "port 0x%016Lx\n", port->wwpn); 1356 "port 0x%016Lx\n", port->wwpn);
1527 debug_text_event(adapter->erp_dbf, 1,
1528 "unsol_els_rscnk:");
1529 zfcp_test_link(port); 1357 zfcp_test_link(port);
1530 } 1358 }
1531 } 1359 }
@@ -1541,8 +1369,6 @@ zfcp_fsf_incoming_els_plogi(struct zfcp_adapter *adapter,
1541 struct zfcp_port *port; 1369 struct zfcp_port *port;
1542 unsigned long flags; 1370 unsigned long flags;
1543 1371
1544 zfcp_in_els_dbf_event(adapter, "##plogi", status_buffer, 28);
1545
1546 read_lock_irqsave(&zfcp_data.config_lock, flags); 1372 read_lock_irqsave(&zfcp_data.config_lock, flags);
1547 list_for_each_entry(port, &adapter->port_list_head, list) { 1373 list_for_each_entry(port, &adapter->port_list_head, list) {
1548 if (port->wwpn == (*(wwn_t *) & els_logi->nport_wwn)) 1374 if (port->wwpn == (*(wwn_t *) & els_logi->nport_wwn))
@@ -1556,8 +1382,6 @@ zfcp_fsf_incoming_els_plogi(struct zfcp_adapter *adapter,
1556 status_buffer->d_id, 1382 status_buffer->d_id,
1557 zfcp_get_busid_by_adapter(adapter)); 1383 zfcp_get_busid_by_adapter(adapter));
1558 } else { 1384 } else {
1559 debug_text_event(adapter->erp_dbf, 1, "unsol_els_plogi:");
1560 debug_event(adapter->erp_dbf, 1, &els_logi->nport_wwn, 8);
1561 zfcp_erp_port_forced_reopen(port, 0); 1385 zfcp_erp_port_forced_reopen(port, 0);
1562 } 1386 }
1563} 1387}
@@ -1570,8 +1394,6 @@ zfcp_fsf_incoming_els_logo(struct zfcp_adapter *adapter,
1570 struct zfcp_port *port; 1394 struct zfcp_port *port;
1571 unsigned long flags; 1395 unsigned long flags;
1572 1396
1573 zfcp_in_els_dbf_event(adapter, "##logo", status_buffer, 16);
1574
1575 read_lock_irqsave(&zfcp_data.config_lock, flags); 1397 read_lock_irqsave(&zfcp_data.config_lock, flags);
1576 list_for_each_entry(port, &adapter->port_list_head, list) { 1398 list_for_each_entry(port, &adapter->port_list_head, list) {
1577 if (port->wwpn == els_logo->nport_wwpn) 1399 if (port->wwpn == els_logo->nport_wwpn)
@@ -1585,8 +1407,6 @@ zfcp_fsf_incoming_els_logo(struct zfcp_adapter *adapter,
1585 status_buffer->d_id, 1407 status_buffer->d_id,
1586 zfcp_get_busid_by_adapter(adapter)); 1408 zfcp_get_busid_by_adapter(adapter));
1587 } else { 1409 } else {
1588 debug_text_event(adapter->erp_dbf, 1, "unsol_els_logo:");
1589 debug_event(adapter->erp_dbf, 1, &els_logo->nport_wwpn, 8);
1590 zfcp_erp_port_forced_reopen(port, 0); 1410 zfcp_erp_port_forced_reopen(port, 0);
1591 } 1411 }
1592} 1412}
@@ -1595,7 +1415,6 @@ static void
1595zfcp_fsf_incoming_els_unknown(struct zfcp_adapter *adapter, 1415zfcp_fsf_incoming_els_unknown(struct zfcp_adapter *adapter,
1596 struct fsf_status_read_buffer *status_buffer) 1416 struct fsf_status_read_buffer *status_buffer)
1597{ 1417{
1598 zfcp_in_els_dbf_event(adapter, "##undef", status_buffer, 24);
1599 ZFCP_LOG_NORMAL("warning: unknown incoming ELS 0x%08x " 1418 ZFCP_LOG_NORMAL("warning: unknown incoming ELS 0x%08x "
1600 "for adapter %s\n", *(u32 *) (status_buffer->payload), 1419 "for adapter %s\n", *(u32 *) (status_buffer->payload),
1601 zfcp_get_busid_by_adapter(adapter)); 1420 zfcp_get_busid_by_adapter(adapter));
@@ -1609,10 +1428,11 @@ zfcp_fsf_incoming_els(struct zfcp_fsf_req *fsf_req)
1609 u32 els_type; 1428 u32 els_type;
1610 struct zfcp_adapter *adapter; 1429 struct zfcp_adapter *adapter;
1611 1430
1612 status_buffer = fsf_req->data.status_read.buffer; 1431 status_buffer = (struct fsf_status_read_buffer *) fsf_req->data;
1613 els_type = *(u32 *) (status_buffer->payload); 1432 els_type = *(u32 *) (status_buffer->payload);
1614 adapter = fsf_req->adapter; 1433 adapter = fsf_req->adapter;
1615 1434
1435 zfcp_san_dbf_event_incoming_els(fsf_req);
1616 if (els_type == LS_PLOGI) 1436 if (els_type == LS_PLOGI)
1617 zfcp_fsf_incoming_els_plogi(adapter, status_buffer); 1437 zfcp_fsf_incoming_els_plogi(adapter, status_buffer);
1618 else if (els_type == LS_LOGO) 1438 else if (els_type == LS_LOGO)
diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c
index b30abab77da3..0fc46381fc22 100644
--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -202,19 +202,9 @@ static int
202zfcp_ccw_set_offline(struct ccw_device *ccw_device) 202zfcp_ccw_set_offline(struct ccw_device *ccw_device)
203{ 203{
204 struct zfcp_adapter *adapter; 204 struct zfcp_adapter *adapter;
205 struct zfcp_port *port;
206 struct fc_rport *rport;
207 205
208 down(&zfcp_data.config_sema); 206 down(&zfcp_data.config_sema);
209 adapter = dev_get_drvdata(&ccw_device->dev); 207 adapter = dev_get_drvdata(&ccw_device->dev);
210 /* might be racy, but we cannot take config_lock due to the fact that
211 fc_remote_port_delete might sleep */
212 list_for_each_entry(port, &adapter->port_list_head, list)
213 if (port->rport) {
214 rport = port->rport;
215 port->rport = NULL;
216 fc_remote_port_delete(rport);
217 }
218 zfcp_erp_adapter_shutdown(adapter, 0); 208 zfcp_erp_adapter_shutdown(adapter, 0);
219 zfcp_erp_wait(adapter); 209 zfcp_erp_wait(adapter);
220 zfcp_adapter_scsi_unregister(adapter); 210 zfcp_adapter_scsi_unregister(adapter);
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
new file mode 100644
index 000000000000..826fb3b00605
--- /dev/null
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -0,0 +1,995 @@
1/*
2 *
3 * linux/drivers/s390/scsi/zfcp_dbf.c
4 *
5 * FCP adapter driver for IBM eServer zSeries
6 *
7 * Debugging facilities
8 *
9 * (C) Copyright IBM Corp. 2005
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#define ZFCP_DBF_REVISION "$Revision$"
27
28#include <asm/debug.h>
29#include <linux/ctype.h>
30#include "zfcp_ext.h"
31
32static u32 dbfsize = 4;
33
34module_param(dbfsize, uint, 0400);
35MODULE_PARM_DESC(dbfsize,
36 "number of pages for each debug feature area (default 4)");
37
38#define ZFCP_LOG_AREA ZFCP_LOG_AREA_OTHER
39
40static inline int
41zfcp_dbf_stck(char *out_buf, const char *label, unsigned long long stck)
42{
43 unsigned long long sec;
44 struct timespec xtime;
45 int len = 0;
46
47 stck -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
48 sec = stck >> 12;
49 do_div(sec, 1000000);
50 xtime.tv_sec = sec;
51 stck -= (sec * 1000000) << 12;
52 xtime.tv_nsec = ((stck * 1000) >> 12);
53 len += sprintf(out_buf + len, "%-24s%011lu:%06lu\n",
54 label, xtime.tv_sec, xtime.tv_nsec);
55
56 return len;
57}
58
59static int zfcp_dbf_tag(char *out_buf, const char *label, const char *tag)
60{
61 int len = 0, i;
62
63 len += sprintf(out_buf + len, "%-24s", label);
64 for (i = 0; i < ZFCP_DBF_TAG_SIZE; i++)
65 len += sprintf(out_buf + len, "%c", tag[i]);
66 len += sprintf(out_buf + len, "\n");
67
68 return len;
69}
70
71static int
72zfcp_dbf_view(char *out_buf, const char *label, const char *format, ...)
73{
74 va_list arg;
75 int len = 0;
76
77 len += sprintf(out_buf + len, "%-24s", label);
78 va_start(arg, format);
79 len += vsprintf(out_buf + len, format, arg);
80 va_end(arg);
81 len += sprintf(out_buf + len, "\n");
82
83 return len;
84}
85
86static int
87zfcp_dbf_view_dump(char *out_buf, const char *label,
88 char *buffer, int buflen, int offset, int total_size)
89{
90 int len = 0;
91
92 if (offset == 0)
93 len += sprintf(out_buf + len, "%-24s ", label);
94
95 while (buflen--) {
96 if (offset > 0) {
97 if ((offset % 32) == 0)
98 len += sprintf(out_buf + len, "\n%-24c ", ' ');
99 else if ((offset % 4) == 0)
100 len += sprintf(out_buf + len, " ");
101 }
102 len += sprintf(out_buf + len, "%02x", *buffer++);
103 if (++offset == total_size) {
104 len += sprintf(out_buf + len, "\n");
105 break;
106 }
107 }
108
109 if (total_size == 0)
110 len += sprintf(out_buf + len, "\n");
111
112 return len;
113}
114
115static inline int
116zfcp_dbf_view_header(debug_info_t * id, struct debug_view *view, int area,
117 debug_entry_t * entry, char *out_buf)
118{
119 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry);
120 int len = 0;
121
122 if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) {
123 len += zfcp_dbf_stck(out_buf + len, "timestamp",
124 entry->id.stck);
125 len += zfcp_dbf_view(out_buf + len, "cpu", "%02i",
126 entry->id.fields.cpuid);
127 } else {
128 len += zfcp_dbf_view_dump(out_buf + len, NULL,
129 dump->data,
130 dump->size,
131 dump->offset, dump->total_size);
132 if ((dump->offset + dump->size) == dump->total_size)
133 len += sprintf(out_buf + len, "\n");
134 }
135
136 return len;
137}
138
139inline void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req)
140{
141 struct zfcp_adapter *adapter = fsf_req->adapter;
142 struct fsf_qtcb *qtcb = fsf_req->qtcb;
143 union fsf_prot_status_qual *prot_status_qual =
144 &qtcb->prefix.prot_status_qual;
145 union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual;
146 struct scsi_cmnd *scsi_cmnd;
147 struct zfcp_port *port;
148 struct zfcp_unit *unit;
149 struct zfcp_send_els *send_els;
150 struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
151 struct zfcp_hba_dbf_record_response *response = &rec->type.response;
152 int level;
153 unsigned long flags;
154
155 spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
156 memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
157 strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE);
158
159 if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
160 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
161 strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE);
162 level = 1;
163 } else if (qtcb->header.fsf_status != FSF_GOOD) {
164 strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE);
165 level = 1;
166 } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
167 (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {
168 strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);
169 level = 4;
170 } else if ((prot_status_qual->doubleword[0] != 0) ||
171 (prot_status_qual->doubleword[1] != 0) ||
172 (fsf_status_qual->doubleword[0] != 0) ||
173 (fsf_status_qual->doubleword[1] != 0)) {
174 strncpy(rec->tag2, "qual", ZFCP_DBF_TAG_SIZE);
175 level = 3;
176 } else {
177 strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);
178 level = 6;
179 }
180
181 response->fsf_command = fsf_req->fsf_command;
182 response->fsf_reqid = (unsigned long)fsf_req;
183 response->fsf_seqno = fsf_req->seq_no;
184 response->fsf_issued = fsf_req->issued;
185 response->fsf_prot_status = qtcb->prefix.prot_status;
186 response->fsf_status = qtcb->header.fsf_status;
187 memcpy(response->fsf_prot_status_qual,
188 prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE);
189 memcpy(response->fsf_status_qual,
190 fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE);
191 response->fsf_req_status = fsf_req->status;
192 response->sbal_first = fsf_req->sbal_first;
193 response->sbal_curr = fsf_req->sbal_curr;
194 response->sbal_last = fsf_req->sbal_last;
195 response->pool = fsf_req->pool != NULL;
196 response->erp_action = (unsigned long)fsf_req->erp_action;
197
198 switch (fsf_req->fsf_command) {
199 case FSF_QTCB_FCP_CMND:
200 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
201 break;
202 scsi_cmnd = (struct scsi_cmnd *)fsf_req->data;
203 if (scsi_cmnd != NULL) {
204 response->data.send_fcp.scsi_cmnd
205 = (unsigned long)scsi_cmnd;
206 response->data.send_fcp.scsi_serial
207 = scsi_cmnd->serial_number;
208 }
209 break;
210
211 case FSF_QTCB_OPEN_PORT_WITH_DID:
212 case FSF_QTCB_CLOSE_PORT:
213 case FSF_QTCB_CLOSE_PHYSICAL_PORT:
214 port = (struct zfcp_port *)fsf_req->data;
215 response->data.port.wwpn = port->wwpn;
216 response->data.port.d_id = port->d_id;
217 response->data.port.port_handle = qtcb->header.port_handle;
218 break;
219
220 case FSF_QTCB_OPEN_LUN:
221 case FSF_QTCB_CLOSE_LUN:
222 unit = (struct zfcp_unit *)fsf_req->data;
223 port = unit->port;
224 response->data.unit.wwpn = port->wwpn;
225 response->data.unit.fcp_lun = unit->fcp_lun;
226 response->data.unit.port_handle = qtcb->header.port_handle;
227 response->data.unit.lun_handle = qtcb->header.lun_handle;
228 break;
229
230 case FSF_QTCB_SEND_ELS:
231 send_els = (struct zfcp_send_els *)fsf_req->data;
232 response->data.send_els.d_id = qtcb->bottom.support.d_id;
233 response->data.send_els.ls_code = send_els->ls_code >> 24;
234 break;
235
236 case FSF_QTCB_ABORT_FCP_CMND:
237 case FSF_QTCB_SEND_GENERIC:
238 case FSF_QTCB_EXCHANGE_CONFIG_DATA:
239 case FSF_QTCB_EXCHANGE_PORT_DATA:
240 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
241 case FSF_QTCB_UPLOAD_CONTROL_FILE:
242 break;
243 }
244
245 debug_event(adapter->hba_dbf, level,
246 rec, sizeof(struct zfcp_hba_dbf_record));
247 spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
248}
249
250inline void
251zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter,
252 struct fsf_status_read_buffer *status_buffer)
253{
254 struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
255 unsigned long flags;
256
257 spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
258 memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
259 strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE);
260 strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE);
261
262 rec->type.status.failed = adapter->status_read_failed;
263 if (status_buffer != NULL) {
264 rec->type.status.status_type = status_buffer->status_type;
265 rec->type.status.status_subtype = status_buffer->status_subtype;
266 memcpy(&rec->type.status.queue_designator,
267 &status_buffer->queue_designator,
268 sizeof(struct fsf_queue_designator));
269
270 switch (status_buffer->status_type) {
271 case FSF_STATUS_READ_SENSE_DATA_AVAIL:
272 rec->type.status.payload_size =
273 ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL;
274 break;
275
276 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
277 rec->type.status.payload_size =
278 ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD;
279 break;
280
281 case FSF_STATUS_READ_LINK_DOWN:
282 switch (status_buffer->status_subtype) {
283 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
284 case FSF_STATUS_READ_SUB_FDISC_FAILED:
285 rec->type.status.payload_size =
286 sizeof(struct fsf_link_down_info);
287 }
288 break;
289
290 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
291 rec->type.status.payload_size =
292 ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT;
293 break;
294 }
295 memcpy(&rec->type.status.payload,
296 &status_buffer->payload, rec->type.status.payload_size);
297 }
298
299 debug_event(adapter->hba_dbf, 2,
300 rec, sizeof(struct zfcp_hba_dbf_record));
301 spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
302}
303
304inline void
305zfcp_hba_dbf_event_qdio(struct zfcp_adapter *adapter, unsigned int status,
306 unsigned int qdio_error, unsigned int siga_error,
307 int sbal_index, int sbal_count)
308{
309 struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
310 unsigned long flags;
311
312 spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
313 memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
314 strncpy(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE);
315 rec->type.qdio.status = status;
316 rec->type.qdio.qdio_error = qdio_error;
317 rec->type.qdio.siga_error = siga_error;
318 rec->type.qdio.sbal_index = sbal_index;
319 rec->type.qdio.sbal_count = sbal_count;
320 debug_event(adapter->hba_dbf, 0,
321 rec, sizeof(struct zfcp_hba_dbf_record));
322 spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
323}
324
325static inline int
326zfcp_hba_dbf_view_response(char *out_buf,
327 struct zfcp_hba_dbf_record_response *rec)
328{
329 int len = 0;
330
331 len += zfcp_dbf_view(out_buf + len, "fsf_command", "0x%08x",
332 rec->fsf_command);
333 len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
334 rec->fsf_reqid);
335 len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
336 rec->fsf_seqno);
337 len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);
338 len += zfcp_dbf_view(out_buf + len, "fsf_prot_status", "0x%08x",
339 rec->fsf_prot_status);
340 len += zfcp_dbf_view(out_buf + len, "fsf_status", "0x%08x",
341 rec->fsf_status);
342 len += zfcp_dbf_view_dump(out_buf + len, "fsf_prot_status_qual",
343 rec->fsf_prot_status_qual,
344 FSF_PROT_STATUS_QUAL_SIZE,
345 0, FSF_PROT_STATUS_QUAL_SIZE);
346 len += zfcp_dbf_view_dump(out_buf + len, "fsf_status_qual",
347 rec->fsf_status_qual,
348 FSF_STATUS_QUALIFIER_SIZE,
349 0, FSF_STATUS_QUALIFIER_SIZE);
350 len += zfcp_dbf_view(out_buf + len, "fsf_req_status", "0x%08x",
351 rec->fsf_req_status);
352 len += zfcp_dbf_view(out_buf + len, "sbal_first", "0x%02x",
353 rec->sbal_first);
354 len += zfcp_dbf_view(out_buf + len, "sbal_curr", "0x%02x",
355 rec->sbal_curr);
356 len += zfcp_dbf_view(out_buf + len, "sbal_last", "0x%02x",
357 rec->sbal_last);
358 len += zfcp_dbf_view(out_buf + len, "pool", "0x%02x", rec->pool);
359
360 switch (rec->fsf_command) {
361 case FSF_QTCB_FCP_CMND:
362 if (rec->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
363 break;
364 len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",
365 rec->data.send_fcp.scsi_cmnd);
366 len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",
367 rec->data.send_fcp.scsi_serial);
368 break;
369
370 case FSF_QTCB_OPEN_PORT_WITH_DID:
371 case FSF_QTCB_CLOSE_PORT:
372 case FSF_QTCB_CLOSE_PHYSICAL_PORT:
373 len += zfcp_dbf_view(out_buf + len, "wwpn", "0x%016Lx",
374 rec->data.port.wwpn);
375 len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x",
376 rec->data.port.d_id);
377 len += zfcp_dbf_view(out_buf + len, "port_handle", "0x%08x",
378 rec->data.port.port_handle);
379 break;
380
381 case FSF_QTCB_OPEN_LUN:
382 case FSF_QTCB_CLOSE_LUN:
383 len += zfcp_dbf_view(out_buf + len, "wwpn", "0x%016Lx",
384 rec->data.unit.wwpn);
385 len += zfcp_dbf_view(out_buf + len, "fcp_lun", "0x%016Lx",
386 rec->data.unit.fcp_lun);
387 len += zfcp_dbf_view(out_buf + len, "port_handle", "0x%08x",
388 rec->data.unit.port_handle);
389 len += zfcp_dbf_view(out_buf + len, "lun_handle", "0x%08x",
390 rec->data.unit.lun_handle);
391 break;
392
393 case FSF_QTCB_SEND_ELS:
394 len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x",
395 rec->data.send_els.d_id);
396 len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",
397 rec->data.send_els.ls_code);
398 break;
399
400 case FSF_QTCB_ABORT_FCP_CMND:
401 case FSF_QTCB_SEND_GENERIC:
402 case FSF_QTCB_EXCHANGE_CONFIG_DATA:
403 case FSF_QTCB_EXCHANGE_PORT_DATA:
404 case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
405 case FSF_QTCB_UPLOAD_CONTROL_FILE:
406 break;
407 }
408
409 return len;
410}
411
412static inline int
413zfcp_hba_dbf_view_status(char *out_buf, struct zfcp_hba_dbf_record_status *rec)
414{
415 int len = 0;
416
417 len += zfcp_dbf_view(out_buf + len, "failed", "0x%02x", rec->failed);
418 len += zfcp_dbf_view(out_buf + len, "status_type", "0x%08x",
419 rec->status_type);
420 len += zfcp_dbf_view(out_buf + len, "status_subtype", "0x%08x",
421 rec->status_subtype);
422 len += zfcp_dbf_view_dump(out_buf + len, "queue_designator",
423 (char *)&rec->queue_designator,
424 sizeof(struct fsf_queue_designator),
425 0, sizeof(struct fsf_queue_designator));
426 len += zfcp_dbf_view_dump(out_buf + len, "payload",
427 (char *)&rec->payload,
428 rec->payload_size, 0, rec->payload_size);
429
430 return len;
431}
432
433static inline int
434zfcp_hba_dbf_view_qdio(char *out_buf, struct zfcp_hba_dbf_record_qdio *rec)
435{
436 int len = 0;
437
438 len += zfcp_dbf_view(out_buf + len, "status", "0x%08x", rec->status);
439 len += zfcp_dbf_view(out_buf + len, "qdio_error", "0x%08x",
440 rec->qdio_error);
441 len += zfcp_dbf_view(out_buf + len, "siga_error", "0x%08x",
442 rec->siga_error);
443 len += zfcp_dbf_view(out_buf + len, "sbal_index", "0x%02x",
444 rec->sbal_index);
445 len += zfcp_dbf_view(out_buf + len, "sbal_count", "0x%02x",
446 rec->sbal_count);
447
448 return len;
449}
450
451static int
452zfcp_hba_dbf_view_format(debug_info_t * id, struct debug_view *view,
453 char *out_buf, const char *in_buf)
454{
455 struct zfcp_hba_dbf_record *rec = (struct zfcp_hba_dbf_record *)in_buf;
456 int len = 0;
457
458 if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
459 return 0;
460
461 len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
462 if (isalpha(rec->tag2[0]))
463 len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);
464 if (strncmp(rec->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0)
465 len += zfcp_hba_dbf_view_response(out_buf + len,
466 &rec->type.response);
467 else if (strncmp(rec->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0)
468 len += zfcp_hba_dbf_view_status(out_buf + len,
469 &rec->type.status);
470 else if (strncmp(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0)
471 len += zfcp_hba_dbf_view_qdio(out_buf + len, &rec->type.qdio);
472
473 len += sprintf(out_buf + len, "\n");
474
475 return len;
476}
477
478struct debug_view zfcp_hba_dbf_view = {
479 "structured",
480 NULL,
481 &zfcp_dbf_view_header,
482 &zfcp_hba_dbf_view_format,
483 NULL,
484 NULL
485};
486
487inline void
488_zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req,
489 u32 s_id, u32 d_id, void *buffer, int buflen)
490{
491 struct zfcp_send_ct *send_ct = (struct zfcp_send_ct *)fsf_req->data;
492 struct zfcp_port *port = send_ct->port;
493 struct zfcp_adapter *adapter = port->adapter;
494 struct ct_hdr *header = (struct ct_hdr *)buffer;
495 struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
496 struct zfcp_san_dbf_record_ct *ct = &rec->type.ct;
497 unsigned long flags;
498
499 spin_lock_irqsave(&adapter->san_dbf_lock, flags);
500 memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
501 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
502 rec->fsf_reqid = (unsigned long)fsf_req;
503 rec->fsf_seqno = fsf_req->seq_no;
504 rec->s_id = s_id;
505 rec->d_id = d_id;
506 if (strncmp(tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
507 ct->type.request.cmd_req_code = header->cmd_rsp_code;
508 ct->type.request.revision = header->revision;
509 ct->type.request.gs_type = header->gs_type;
510 ct->type.request.gs_subtype = header->gs_subtype;
511 ct->type.request.options = header->options;
512 ct->type.request.max_res_size = header->max_res_size;
513 } else if (strncmp(tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
514 ct->type.response.cmd_rsp_code = header->cmd_rsp_code;
515 ct->type.response.revision = header->revision;
516 ct->type.response.reason_code = header->reason_code;
517 ct->type.response.reason_code_expl = header->reason_code_expl;
518 ct->type.response.vendor_unique = header->vendor_unique;
519 }
520 ct->payload_size =
521 min(buflen - (int)sizeof(struct ct_hdr), ZFCP_DBF_CT_PAYLOAD);
522 memcpy(ct->payload, buffer + sizeof(struct ct_hdr), ct->payload_size);
523 debug_event(adapter->san_dbf, 3,
524 rec, sizeof(struct zfcp_san_dbf_record));
525 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
526}
527
528inline void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
529{
530 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
531 struct zfcp_port *port = ct->port;
532 struct zfcp_adapter *adapter = port->adapter;
533
534 _zfcp_san_dbf_event_common_ct("octc", fsf_req,
535 fc_host_port_id(adapter->scsi_host),
536 port->d_id, zfcp_sg_to_address(ct->req),
537 ct->req->length);
538}
539
540inline void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
541{
542 struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
543 struct zfcp_port *port = ct->port;
544 struct zfcp_adapter *adapter = port->adapter;
545
546 _zfcp_san_dbf_event_common_ct("rctc", fsf_req, port->d_id,
547 fc_host_port_id(adapter->scsi_host),
548 zfcp_sg_to_address(ct->resp),
549 ct->resp->length);
550}
551
552static inline void
553_zfcp_san_dbf_event_common_els(const char *tag, int level,
554 struct zfcp_fsf_req *fsf_req, u32 s_id,
555 u32 d_id, u8 ls_code, void *buffer, int buflen)
556{
557 struct zfcp_adapter *adapter = fsf_req->adapter;
558 struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
559 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
560 unsigned long flags;
561 int offset = 0;
562
563 spin_lock_irqsave(&adapter->san_dbf_lock, flags);
564 do {
565 memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
566 if (offset == 0) {
567 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
568 rec->fsf_reqid = (unsigned long)fsf_req;
569 rec->fsf_seqno = fsf_req->seq_no;
570 rec->s_id = s_id;
571 rec->d_id = d_id;
572 rec->type.els.ls_code = ls_code;
573 buflen = min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD);
574 rec->type.els.payload_size = buflen;
575 memcpy(rec->type.els.payload,
576 buffer, min(buflen, ZFCP_DBF_ELS_PAYLOAD));
577 offset += min(buflen, ZFCP_DBF_ELS_PAYLOAD);
578 } else {
579 strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
580 dump->total_size = buflen;
581 dump->offset = offset;
582 dump->size = min(buflen - offset,
583 (int)sizeof(struct zfcp_san_dbf_record)
584 - (int)sizeof(struct zfcp_dbf_dump));
585 memcpy(dump->data, buffer + offset, dump->size);
586 offset += dump->size;
587 }
588 debug_event(adapter->san_dbf, level,
589 rec, sizeof(struct zfcp_san_dbf_record));
590 } while (offset < buflen);
591 spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
592}
593
594inline void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *fsf_req)
595{
596 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
597
598 _zfcp_san_dbf_event_common_els("oels", 2, fsf_req,
599 fc_host_port_id(els->adapter->scsi_host),
600 els->d_id,
601 *(u8 *) zfcp_sg_to_address(els->req),
602 zfcp_sg_to_address(els->req),
603 els->req->length);
604}
605
606inline void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *fsf_req)
607{
608 struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
609
610 _zfcp_san_dbf_event_common_els("rels", 2, fsf_req, els->d_id,
611 fc_host_port_id(els->adapter->scsi_host),
612 *(u8 *) zfcp_sg_to_address(els->req),
613 zfcp_sg_to_address(els->resp),
614 els->resp->length);
615}
616
617inline void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req)
618{
619 struct zfcp_adapter *adapter = fsf_req->adapter;
620 struct fsf_status_read_buffer *status_buffer =
621 (struct fsf_status_read_buffer *)fsf_req->data;
622 int length = (int)status_buffer->length -
623 (int)((void *)&status_buffer->payload - (void *)status_buffer);
624
625 _zfcp_san_dbf_event_common_els("iels", 1, fsf_req, status_buffer->d_id,
626 fc_host_port_id(adapter->scsi_host),
627 *(u8 *) status_buffer->payload,
628 (void *)status_buffer->payload, length);
629}
630
631static int
632zfcp_san_dbf_view_format(debug_info_t * id, struct debug_view *view,
633 char *out_buf, const char *in_buf)
634{
635 struct zfcp_san_dbf_record *rec = (struct zfcp_san_dbf_record *)in_buf;
636 char *buffer = NULL;
637 int buflen = 0, total = 0;
638 int len = 0;
639
640 if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
641 return 0;
642
643 len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
644 len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
645 rec->fsf_reqid);
646 len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
647 rec->fsf_seqno);
648 len += zfcp_dbf_view(out_buf + len, "s_id", "0x%06x", rec->s_id);
649 len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x", rec->d_id);
650
651 if (strncmp(rec->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
652 len += zfcp_dbf_view(out_buf + len, "cmd_req_code", "0x%04x",
653 rec->type.ct.type.request.cmd_req_code);
654 len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",
655 rec->type.ct.type.request.revision);
656 len += zfcp_dbf_view(out_buf + len, "gs_type", "0x%02x",
657 rec->type.ct.type.request.gs_type);
658 len += zfcp_dbf_view(out_buf + len, "gs_subtype", "0x%02x",
659 rec->type.ct.type.request.gs_subtype);
660 len += zfcp_dbf_view(out_buf + len, "options", "0x%02x",
661 rec->type.ct.type.request.options);
662 len += zfcp_dbf_view(out_buf + len, "max_res_size", "0x%04x",
663 rec->type.ct.type.request.max_res_size);
664 total = rec->type.ct.payload_size;
665 buffer = rec->type.ct.payload;
666 buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
667 } else if (strncmp(rec->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
668 len += zfcp_dbf_view(out_buf + len, "cmd_rsp_code", "0x%04x",
669 rec->type.ct.type.response.cmd_rsp_code);
670 len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",
671 rec->type.ct.type.response.revision);
672 len += zfcp_dbf_view(out_buf + len, "reason_code", "0x%02x",
673 rec->type.ct.type.response.reason_code);
674 len +=
675 zfcp_dbf_view(out_buf + len, "reason_code_expl", "0x%02x",
676 rec->type.ct.type.response.reason_code_expl);
677 len +=
678 zfcp_dbf_view(out_buf + len, "vendor_unique", "0x%02x",
679 rec->type.ct.type.response.vendor_unique);
680 total = rec->type.ct.payload_size;
681 buffer = rec->type.ct.payload;
682 buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
683 } else if (strncmp(rec->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||
684 strncmp(rec->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
685 strncmp(rec->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
686 len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",
687 rec->type.els.ls_code);
688 total = rec->type.els.payload_size;
689 buffer = rec->type.els.payload;
690 buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);
691 }
692
693 len += zfcp_dbf_view_dump(out_buf + len, "payload",
694 buffer, buflen, 0, total);
695
696 if (buflen == total)
697 len += sprintf(out_buf + len, "\n");
698
699 return len;
700}
701
702struct debug_view zfcp_san_dbf_view = {
703 "structured",
704 NULL,
705 &zfcp_dbf_view_header,
706 &zfcp_san_dbf_view_format,
707 NULL,
708 NULL
709};
710
711static inline void
712_zfcp_scsi_dbf_event_common(const char *tag, const char *tag2, int level,
713 struct zfcp_adapter *adapter,
714 struct scsi_cmnd *scsi_cmnd,
715 struct zfcp_fsf_req *new_fsf_req)
716{
717 struct zfcp_fsf_req *fsf_req =
718 (struct zfcp_fsf_req *)scsi_cmnd->host_scribble;
719 struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf;
720 struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
721 unsigned long flags;
722 struct fcp_rsp_iu *fcp_rsp;
723 char *fcp_rsp_info = NULL, *fcp_sns_info = NULL;
724 int offset = 0, buflen = 0;
725
726 spin_lock_irqsave(&adapter->scsi_dbf_lock, flags);
727 do {
728 memset(rec, 0, sizeof(struct zfcp_scsi_dbf_record));
729 if (offset == 0) {
730 strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
731 strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);
732 if (scsi_cmnd->device) {
733 rec->scsi_id = scsi_cmnd->device->id;
734 rec->scsi_lun = scsi_cmnd->device->lun;
735 }
736 rec->scsi_result = scsi_cmnd->result;
737 rec->scsi_cmnd = (unsigned long)scsi_cmnd;
738 rec->scsi_serial = scsi_cmnd->serial_number;
739 memcpy(rec->scsi_opcode,
740 &scsi_cmnd->cmnd,
741 min((int)scsi_cmnd->cmd_len,
742 ZFCP_DBF_SCSI_OPCODE));
743 rec->scsi_retries = scsi_cmnd->retries;
744 rec->scsi_allowed = scsi_cmnd->allowed;
745 if (fsf_req != NULL) {
746 fcp_rsp = (struct fcp_rsp_iu *)
747 &(fsf_req->qtcb->bottom.io.fcp_rsp);
748 fcp_rsp_info =
749 zfcp_get_fcp_rsp_info_ptr(fcp_rsp);
750 fcp_sns_info =
751 zfcp_get_fcp_sns_info_ptr(fcp_rsp);
752
753 rec->type.fcp.rsp_validity =
754 fcp_rsp->validity.value;
755 rec->type.fcp.rsp_scsi_status =
756 fcp_rsp->scsi_status;
757 rec->type.fcp.rsp_resid = fcp_rsp->fcp_resid;
758 if (fcp_rsp->validity.bits.fcp_rsp_len_valid)
759 rec->type.fcp.rsp_code =
760 *(fcp_rsp_info + 3);
761 if (fcp_rsp->validity.bits.fcp_sns_len_valid) {
762 buflen = min((int)fcp_rsp->fcp_sns_len,
763 ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO);
764 rec->type.fcp.sns_info_len = buflen;
765 memcpy(rec->type.fcp.sns_info,
766 fcp_sns_info,
767 min(buflen,
768 ZFCP_DBF_SCSI_FCP_SNS_INFO));
769 offset += min(buflen,
770 ZFCP_DBF_SCSI_FCP_SNS_INFO);
771 }
772
773 rec->fsf_reqid = (unsigned long)fsf_req;
774 rec->fsf_seqno = fsf_req->seq_no;
775 rec->fsf_issued = fsf_req->issued;
776 }
777 if (new_fsf_req != NULL) {
778 rec->type.new_fsf_req.fsf_reqid =
779 (unsigned long)
780 new_fsf_req;
781 rec->type.new_fsf_req.fsf_seqno =
782 new_fsf_req->seq_no;
783 rec->type.new_fsf_req.fsf_issued =
784 new_fsf_req->issued;
785 }
786 } else {
787 strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
788 dump->total_size = buflen;
789 dump->offset = offset;
790 dump->size = min(buflen - offset,
791 (int)sizeof(struct
792 zfcp_scsi_dbf_record) -
793 (int)sizeof(struct zfcp_dbf_dump));
794 memcpy(dump->data, fcp_sns_info + offset, dump->size);
795 offset += dump->size;
796 }
797 debug_event(adapter->scsi_dbf, level,
798 rec, sizeof(struct zfcp_scsi_dbf_record));
799 } while (offset < buflen);
800 spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags);
801}
802
803inline void
804zfcp_scsi_dbf_event_result(const char *tag, int level,
805 struct zfcp_adapter *adapter,
806 struct scsi_cmnd *scsi_cmnd)
807{
808 _zfcp_scsi_dbf_event_common("rslt",
809 tag, level, adapter, scsi_cmnd, NULL);
810}
811
812inline void
813zfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter,
814 struct scsi_cmnd *scsi_cmnd,
815 struct zfcp_fsf_req *new_fsf_req)
816{
817 _zfcp_scsi_dbf_event_common("abrt",
818 tag, 1, adapter, scsi_cmnd, new_fsf_req);
819}
820
821inline void
822zfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
823 struct scsi_cmnd *scsi_cmnd)
824{
825 struct zfcp_adapter *adapter = unit->port->adapter;
826
827 _zfcp_scsi_dbf_event_common(flag == FCP_TARGET_RESET ? "trst" : "lrst",
828 tag, 1, adapter, scsi_cmnd, NULL);
829}
830
831static int
832zfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,
833 char *out_buf, const char *in_buf)
834{
835 struct zfcp_scsi_dbf_record *rec =
836 (struct zfcp_scsi_dbf_record *)in_buf;
837 int len = 0;
838
839 if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
840 return 0;
841
842 len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
843 len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);
844 len += zfcp_dbf_view(out_buf + len, "scsi_id", "0x%08x", rec->scsi_id);
845 len += zfcp_dbf_view(out_buf + len, "scsi_lun", "0x%08x",
846 rec->scsi_lun);
847 len += zfcp_dbf_view(out_buf + len, "scsi_result", "0x%08x",
848 rec->scsi_result);
849 len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",
850 rec->scsi_cmnd);
851 len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",
852 rec->scsi_serial);
853 len += zfcp_dbf_view_dump(out_buf + len, "scsi_opcode",
854 rec->scsi_opcode,
855 ZFCP_DBF_SCSI_OPCODE,
856 0, ZFCP_DBF_SCSI_OPCODE);
857 len += zfcp_dbf_view(out_buf + len, "scsi_retries", "0x%02x",
858 rec->scsi_retries);
859 len += zfcp_dbf_view(out_buf + len, "scsi_allowed", "0x%02x",
860 rec->scsi_allowed);
861 len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
862 rec->fsf_reqid);
863 len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
864 rec->fsf_seqno);
865 len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);
866 if (strncmp(rec->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) {
867 len +=
868 zfcp_dbf_view(out_buf + len, "fcp_rsp_validity", "0x%02x",
869 rec->type.fcp.rsp_validity);
870 len +=
871 zfcp_dbf_view(out_buf + len, "fcp_rsp_scsi_status",
872 "0x%02x", rec->type.fcp.rsp_scsi_status);
873 len +=
874 zfcp_dbf_view(out_buf + len, "fcp_rsp_resid", "0x%08x",
875 rec->type.fcp.rsp_resid);
876 len +=
877 zfcp_dbf_view(out_buf + len, "fcp_rsp_code", "0x%08x",
878 rec->type.fcp.rsp_code);
879 len +=
880 zfcp_dbf_view(out_buf + len, "fcp_sns_info_len", "0x%08x",
881 rec->type.fcp.sns_info_len);
882 len +=
883 zfcp_dbf_view_dump(out_buf + len, "fcp_sns_info",
884 rec->type.fcp.sns_info,
885 min((int)rec->type.fcp.sns_info_len,
886 ZFCP_DBF_SCSI_FCP_SNS_INFO), 0,
887 rec->type.fcp.sns_info_len);
888 } else if (strncmp(rec->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) {
889 len += zfcp_dbf_view(out_buf + len, "fsf_reqid_abort", "0x%0Lx",
890 rec->type.new_fsf_req.fsf_reqid);
891 len += zfcp_dbf_view(out_buf + len, "fsf_seqno_abort", "0x%08x",
892 rec->type.new_fsf_req.fsf_seqno);
893 len += zfcp_dbf_stck(out_buf + len, "fsf_issued",
894 rec->type.new_fsf_req.fsf_issued);
895 } else if ((strncmp(rec->tag, "trst", ZFCP_DBF_TAG_SIZE) == 0) ||
896 (strncmp(rec->tag, "lrst", ZFCP_DBF_TAG_SIZE) == 0)) {
897 len += zfcp_dbf_view(out_buf + len, "fsf_reqid_reset", "0x%0Lx",
898 rec->type.new_fsf_req.fsf_reqid);
899 len += zfcp_dbf_view(out_buf + len, "fsf_seqno_reset", "0x%08x",
900 rec->type.new_fsf_req.fsf_seqno);
901 len += zfcp_dbf_stck(out_buf + len, "fsf_issued",
902 rec->type.new_fsf_req.fsf_issued);
903 }
904
905 len += sprintf(out_buf + len, "\n");
906
907 return len;
908}
909
910struct debug_view zfcp_scsi_dbf_view = {
911 "structured",
912 NULL,
913 &zfcp_dbf_view_header,
914 &zfcp_scsi_dbf_view_format,
915 NULL,
916 NULL
917};
918
919/**
920 * zfcp_adapter_debug_register - registers debug feature for an adapter
921 * @adapter: pointer to adapter for which debug features should be registered
922 * return: -ENOMEM on error, 0 otherwise
923 */
924int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
925{
926 char dbf_name[DEBUG_MAX_NAME_LEN];
927
928 /* debug feature area which records recovery activity */
929 spin_lock_init(&adapter->erp_dbf_lock);
930 sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter));
931 adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2,
932 sizeof(struct zfcp_erp_dbf_record));
933 if (!adapter->erp_dbf)
934 goto failed;
935 debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);
936 debug_set_level(adapter->erp_dbf, 3);
937
938 /* debug feature area which records HBA (FSF and QDIO) conditions */
939 spin_lock_init(&adapter->hba_dbf_lock);
940 sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));
941 adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,
942 sizeof(struct zfcp_hba_dbf_record));
943 if (!adapter->hba_dbf)
944 goto failed;
945 debug_register_view(adapter->hba_dbf, &debug_hex_ascii_view);
946 debug_register_view(adapter->hba_dbf, &zfcp_hba_dbf_view);
947 debug_set_level(adapter->hba_dbf, 3);
948
949 /* debug feature area which records SAN command failures and recovery */
950 spin_lock_init(&adapter->san_dbf_lock);
951 sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));
952 adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,
953 sizeof(struct zfcp_san_dbf_record));
954 if (!adapter->san_dbf)
955 goto failed;
956 debug_register_view(adapter->san_dbf, &debug_hex_ascii_view);
957 debug_register_view(adapter->san_dbf, &zfcp_san_dbf_view);
958 debug_set_level(adapter->san_dbf, 6);
959
960 /* debug feature area which records SCSI command failures and recovery */
961 spin_lock_init(&adapter->scsi_dbf_lock);
962 sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));
963 adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,
964 sizeof(struct zfcp_scsi_dbf_record));
965 if (!adapter->scsi_dbf)
966 goto failed;
967 debug_register_view(adapter->scsi_dbf, &debug_hex_ascii_view);
968 debug_register_view(adapter->scsi_dbf, &zfcp_scsi_dbf_view);
969 debug_set_level(adapter->scsi_dbf, 3);
970
971 return 0;
972
973 failed:
974 zfcp_adapter_debug_unregister(adapter);
975
976 return -ENOMEM;
977}
978
979/**
980 * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
981 * @adapter: pointer to adapter for which debug features should be unregistered
982 */
983void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
984{
985 debug_unregister(adapter->scsi_dbf);
986 debug_unregister(adapter->san_dbf);
987 debug_unregister(adapter->hba_dbf);
988 debug_unregister(adapter->erp_dbf);
989 adapter->scsi_dbf = NULL;
990 adapter->san_dbf = NULL;
991 adapter->hba_dbf = NULL;
992 adapter->erp_dbf = NULL;
993}
994
995#undef ZFCP_LOG_AREA
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 455e902533a9..d81b737d68cc 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -66,7 +66,7 @@
66/********************* GENERAL DEFINES *********************************/ 66/********************* GENERAL DEFINES *********************************/
67 67
68/* zfcp version number, it consists of major, minor, and patch-level number */ 68/* zfcp version number, it consists of major, minor, and patch-level number */
69#define ZFCP_VERSION "4.3.0" 69#define ZFCP_VERSION "4.5.0"
70 70
71/** 71/**
72 * zfcp_sg_to_address - determine kernel address from struct scatterlist 72 * zfcp_sg_to_address - determine kernel address from struct scatterlist
@@ -154,13 +154,17 @@ typedef u32 scsi_lun_t;
154#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100 154#define ZFCP_EXCHANGE_CONFIG_DATA_FIRST_SLEEP 100
155#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7 155#define ZFCP_EXCHANGE_CONFIG_DATA_RETRIES 7
156 156
157/* Retry 5 times every 2 second, then every minute */
158#define ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES 5
159#define ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP 200
160#define ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP 6000
161
157/* timeout value for "default timer" for fsf requests */ 162/* timeout value for "default timer" for fsf requests */
158#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ); 163#define ZFCP_FSF_REQUEST_TIMEOUT (60*HZ);
159 164
160/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/ 165/*************** FIBRE CHANNEL PROTOCOL SPECIFIC DEFINES ********************/
161 166
162typedef unsigned long long wwn_t; 167typedef unsigned long long wwn_t;
163typedef unsigned int fc_id_t;
164typedef unsigned long long fcp_lun_t; 168typedef unsigned long long fcp_lun_t;
165/* data length field may be at variable position in FCP-2 FCP_CMND IU */ 169/* data length field may be at variable position in FCP-2 FCP_CMND IU */
166typedef unsigned int fcp_dl_t; 170typedef unsigned int fcp_dl_t;
@@ -281,6 +285,171 @@ struct fcp_logo {
281} __attribute__((packed)); 285} __attribute__((packed));
282 286
283/* 287/*
288 * DBF stuff
289 */
290#define ZFCP_DBF_TAG_SIZE 4
291
292struct zfcp_dbf_dump {
293 u8 tag[ZFCP_DBF_TAG_SIZE];
294 u32 total_size; /* size of total dump data */
295 u32 offset; /* how much data has being already dumped */
296 u32 size; /* how much data comes with this record */
297 u8 data[]; /* dump data */
298} __attribute__ ((packed));
299
300/* FIXME: to be inflated when reworking the erp dbf */
301struct zfcp_erp_dbf_record {
302 u8 dummy[16];
303} __attribute__ ((packed));
304
305struct zfcp_hba_dbf_record_response {
306 u32 fsf_command;
307 u64 fsf_reqid;
308 u32 fsf_seqno;
309 u64 fsf_issued;
310 u32 fsf_prot_status;
311 u32 fsf_status;
312 u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
313 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
314 u32 fsf_req_status;
315 u8 sbal_first;
316 u8 sbal_curr;
317 u8 sbal_last;
318 u8 pool;
319 u64 erp_action;
320 union {
321 struct {
322 u64 scsi_cmnd;
323 u64 scsi_serial;
324 } send_fcp;
325 struct {
326 u64 wwpn;
327 u32 d_id;
328 u32 port_handle;
329 } port;
330 struct {
331 u64 wwpn;
332 u64 fcp_lun;
333 u32 port_handle;
334 u32 lun_handle;
335 } unit;
336 struct {
337 u32 d_id;
338 u8 ls_code;
339 } send_els;
340 } data;
341} __attribute__ ((packed));
342
343struct zfcp_hba_dbf_record_status {
344 u8 failed;
345 u32 status_type;
346 u32 status_subtype;
347 struct fsf_queue_designator
348 queue_designator;
349 u32 payload_size;
350#define ZFCP_DBF_UNSOL_PAYLOAD 80
351#define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32
352#define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56
353#define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32)
354 u8 payload[ZFCP_DBF_UNSOL_PAYLOAD];
355} __attribute__ ((packed));
356
357struct zfcp_hba_dbf_record_qdio {
358 u32 status;
359 u32 qdio_error;
360 u32 siga_error;
361 u8 sbal_index;
362 u8 sbal_count;
363} __attribute__ ((packed));
364
365struct zfcp_hba_dbf_record {
366 u8 tag[ZFCP_DBF_TAG_SIZE];
367 u8 tag2[ZFCP_DBF_TAG_SIZE];
368 union {
369 struct zfcp_hba_dbf_record_response response;
370 struct zfcp_hba_dbf_record_status status;
371 struct zfcp_hba_dbf_record_qdio qdio;
372 } type;
373} __attribute__ ((packed));
374
375struct zfcp_san_dbf_record_ct {
376 union {
377 struct {
378 u16 cmd_req_code;
379 u8 revision;
380 u8 gs_type;
381 u8 gs_subtype;
382 u8 options;
383 u16 max_res_size;
384 } request;
385 struct {
386 u16 cmd_rsp_code;
387 u8 revision;
388 u8 reason_code;
389 u8 reason_code_expl;
390 u8 vendor_unique;
391 } response;
392 } type;
393 u32 payload_size;
394#define ZFCP_DBF_CT_PAYLOAD 24
395 u8 payload[ZFCP_DBF_CT_PAYLOAD];
396} __attribute__ ((packed));
397
398struct zfcp_san_dbf_record_els {
399 u8 ls_code;
400 u32 payload_size;
401#define ZFCP_DBF_ELS_PAYLOAD 32
402#define ZFCP_DBF_ELS_MAX_PAYLOAD 1024
403 u8 payload[ZFCP_DBF_ELS_PAYLOAD];
404} __attribute__ ((packed));
405
406struct zfcp_san_dbf_record {
407 u8 tag[ZFCP_DBF_TAG_SIZE];
408 u64 fsf_reqid;
409 u32 fsf_seqno;
410 u32 s_id;
411 u32 d_id;
412 union {
413 struct zfcp_san_dbf_record_ct ct;
414 struct zfcp_san_dbf_record_els els;
415 } type;
416} __attribute__ ((packed));
417
418struct zfcp_scsi_dbf_record {
419 u8 tag[ZFCP_DBF_TAG_SIZE];
420 u8 tag2[ZFCP_DBF_TAG_SIZE];
421 u32 scsi_id;
422 u32 scsi_lun;
423 u32 scsi_result;
424 u64 scsi_cmnd;
425 u64 scsi_serial;
426#define ZFCP_DBF_SCSI_OPCODE 16
427 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
428 u8 scsi_retries;
429 u8 scsi_allowed;
430 u64 fsf_reqid;
431 u32 fsf_seqno;
432 u64 fsf_issued;
433 union {
434 struct {
435 u64 fsf_reqid;
436 u32 fsf_seqno;
437 u64 fsf_issued;
438 } new_fsf_req;
439 struct {
440 u8 rsp_validity;
441 u8 rsp_scsi_status;
442 u32 rsp_resid;
443 u8 rsp_code;
444#define ZFCP_DBF_SCSI_FCP_SNS_INFO 16
445#define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256
446 u32 sns_info_len;
447 u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO];
448 } fcp;
449 } type;
450} __attribute__ ((packed));
451
452/*
284 * FC-FS stuff 453 * FC-FS stuff
285 */ 454 */
286#define R_A_TOV 10 /* seconds */ 455#define R_A_TOV 10 /* seconds */
@@ -339,34 +508,6 @@ struct zfcp_rc_entry {
339 */ 508 */
340#define ZFCP_CT_TIMEOUT (3 * R_A_TOV) 509#define ZFCP_CT_TIMEOUT (3 * R_A_TOV)
341 510
342
343/***************** S390 DEBUG FEATURE SPECIFIC DEFINES ***********************/
344
345/* debug feature entries per adapter */
346#define ZFCP_ERP_DBF_INDEX 1
347#define ZFCP_ERP_DBF_AREAS 2
348#define ZFCP_ERP_DBF_LENGTH 16
349#define ZFCP_ERP_DBF_LEVEL 3
350#define ZFCP_ERP_DBF_NAME "zfcperp"
351
352#define ZFCP_CMD_DBF_INDEX 2
353#define ZFCP_CMD_DBF_AREAS 1
354#define ZFCP_CMD_DBF_LENGTH 8
355#define ZFCP_CMD_DBF_LEVEL 3
356#define ZFCP_CMD_DBF_NAME "zfcpcmd"
357
358#define ZFCP_ABORT_DBF_INDEX 2
359#define ZFCP_ABORT_DBF_AREAS 1
360#define ZFCP_ABORT_DBF_LENGTH 8
361#define ZFCP_ABORT_DBF_LEVEL 6
362#define ZFCP_ABORT_DBF_NAME "zfcpabt"
363
364#define ZFCP_IN_ELS_DBF_INDEX 2
365#define ZFCP_IN_ELS_DBF_AREAS 1
366#define ZFCP_IN_ELS_DBF_LENGTH 8
367#define ZFCP_IN_ELS_DBF_LEVEL 6
368#define ZFCP_IN_ELS_DBF_NAME "zfcpels"
369
370/******************** LOGGING MACROS AND DEFINES *****************************/ 511/******************** LOGGING MACROS AND DEFINES *****************************/
371 512
372/* 513/*
@@ -501,6 +642,7 @@ do { \
501#define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080 642#define ZFCP_STATUS_ADAPTER_ERP_THREAD_KILL 0x00000080
502#define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100 643#define ZFCP_STATUS_ADAPTER_ERP_PENDING 0x00000100
503#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200 644#define ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 0x00000200
645#define ZFCP_STATUS_ADAPTER_XPORT_OK 0x00000800
504 646
505#define ZFCP_STATUS_ADAPTER_SCSI_UP \ 647#define ZFCP_STATUS_ADAPTER_SCSI_UP \
506 (ZFCP_STATUS_COMMON_UNBLOCKED | \ 648 (ZFCP_STATUS_COMMON_UNBLOCKED | \
@@ -635,45 +777,6 @@ struct zfcp_adapter_mempool {
635 mempool_t *data_gid_pn; 777 mempool_t *data_gid_pn;
636}; 778};
637 779
638struct zfcp_exchange_config_data{
639};
640
641struct zfcp_open_port {
642 struct zfcp_port *port;
643};
644
645struct zfcp_close_port {
646 struct zfcp_port *port;
647};
648
649struct zfcp_open_unit {
650 struct zfcp_unit *unit;
651};
652
653struct zfcp_close_unit {
654 struct zfcp_unit *unit;
655};
656
657struct zfcp_close_physical_port {
658 struct zfcp_port *port;
659};
660
661struct zfcp_send_fcp_command_task {
662 struct zfcp_fsf_req *fsf_req;
663 struct zfcp_unit *unit;
664 struct scsi_cmnd *scsi_cmnd;
665 unsigned long start_jiffies;
666};
667
668struct zfcp_send_fcp_command_task_management {
669 struct zfcp_unit *unit;
670};
671
672struct zfcp_abort_fcp_command {
673 struct zfcp_fsf_req *fsf_req;
674 struct zfcp_unit *unit;
675};
676
677/* 780/*
678 * header for CT_IU 781 * header for CT_IU
679 */ 782 */
@@ -702,7 +805,7 @@ struct ct_iu_gid_pn_req {
702/* FS_ACC IU and data unit for GID_PN nameserver request */ 805/* FS_ACC IU and data unit for GID_PN nameserver request */
703struct ct_iu_gid_pn_resp { 806struct ct_iu_gid_pn_resp {
704 struct ct_hdr header; 807 struct ct_hdr header;
705 fc_id_t d_id; 808 u32 d_id;
706} __attribute__ ((packed)); 809} __attribute__ ((packed));
707 810
708typedef void (*zfcp_send_ct_handler_t)(unsigned long); 811typedef void (*zfcp_send_ct_handler_t)(unsigned long);
@@ -768,7 +871,7 @@ typedef void (*zfcp_send_els_handler_t)(unsigned long);
768struct zfcp_send_els { 871struct zfcp_send_els {
769 struct zfcp_adapter *adapter; 872 struct zfcp_adapter *adapter;
770 struct zfcp_port *port; 873 struct zfcp_port *port;
771 fc_id_t d_id; 874 u32 d_id;
772 struct scatterlist *req; 875 struct scatterlist *req;
773 struct scatterlist *resp; 876 struct scatterlist *resp;
774 unsigned int req_count; 877 unsigned int req_count;
@@ -781,33 +884,6 @@ struct zfcp_send_els {
781 int status; 884 int status;
782}; 885};
783 886
784struct zfcp_status_read {
785 struct fsf_status_read_buffer *buffer;
786};
787
788struct zfcp_fsf_done {
789 struct completion *complete;
790 int status;
791};
792
793/* request specific data */
794union zfcp_req_data {
795 struct zfcp_exchange_config_data exchange_config_data;
796 struct zfcp_open_port open_port;
797 struct zfcp_close_port close_port;
798 struct zfcp_open_unit open_unit;
799 struct zfcp_close_unit close_unit;
800 struct zfcp_close_physical_port close_physical_port;
801 struct zfcp_send_fcp_command_task send_fcp_command_task;
802 struct zfcp_send_fcp_command_task_management
803 send_fcp_command_task_management;
804 struct zfcp_abort_fcp_command abort_fcp_command;
805 struct zfcp_send_ct *send_ct;
806 struct zfcp_send_els *send_els;
807 struct zfcp_status_read status_read;
808 struct fsf_qtcb_bottom_port *port_data;
809};
810
811struct zfcp_qdio_queue { 887struct zfcp_qdio_queue {
812 struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */ 888 struct qdio_buffer *buffer[QDIO_MAX_BUFFERS_PER_Q]; /* SBALs */
813 u8 free_index; /* index of next free bfr 889 u8 free_index; /* index of next free bfr
@@ -838,21 +914,19 @@ struct zfcp_adapter {
838 atomic_t refcount; /* reference count */ 914 atomic_t refcount; /* reference count */
839 wait_queue_head_t remove_wq; /* can be used to wait for 915 wait_queue_head_t remove_wq; /* can be used to wait for
840 refcount drop to zero */ 916 refcount drop to zero */
841 wwn_t wwnn; /* WWNN */
842 wwn_t wwpn; /* WWPN */
843 fc_id_t s_id; /* N_Port ID */
844 wwn_t peer_wwnn; /* P2P peer WWNN */ 917 wwn_t peer_wwnn; /* P2P peer WWNN */
845 wwn_t peer_wwpn; /* P2P peer WWPN */ 918 wwn_t peer_wwpn; /* P2P peer WWPN */
846 fc_id_t peer_d_id; /* P2P peer D_ID */ 919 u32 peer_d_id; /* P2P peer D_ID */
920 wwn_t physical_wwpn; /* WWPN of physical port */
921 u32 physical_s_id; /* local FC port ID */
847 struct ccw_device *ccw_device; /* S/390 ccw device */ 922 struct ccw_device *ccw_device; /* S/390 ccw device */
848 u8 fc_service_class; 923 u8 fc_service_class;
849 u32 fc_topology; /* FC topology */ 924 u32 fc_topology; /* FC topology */
850 u32 fc_link_speed; /* FC interface speed */
851 u32 hydra_version; /* Hydra version */ 925 u32 hydra_version; /* Hydra version */
852 u32 fsf_lic_version; 926 u32 fsf_lic_version;
853 u32 supported_features;/* of FCP channel */ 927 u32 adapter_features; /* FCP channel features */
928 u32 connection_features; /* host connection features */
854 u32 hardware_version; /* of FCP channel */ 929 u32 hardware_version; /* of FCP channel */
855 u8 serial_number[32]; /* of hardware */
856 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */ 930 struct Scsi_Host *scsi_host; /* Pointer to mid-layer */
857 unsigned short scsi_host_no; /* Assigned host number */ 931 unsigned short scsi_host_no; /* Assigned host number */
858 unsigned char name[9]; 932 unsigned char name[9];
@@ -889,11 +963,18 @@ struct zfcp_adapter {
889 u32 erp_low_mem_count; /* nr of erp actions waiting 963 u32 erp_low_mem_count; /* nr of erp actions waiting
890 for memory */ 964 for memory */
891 struct zfcp_port *nameserver_port; /* adapter's nameserver */ 965 struct zfcp_port *nameserver_port; /* adapter's nameserver */
892 debug_info_t *erp_dbf; /* S/390 debug features */ 966 debug_info_t *erp_dbf;
893 debug_info_t *abort_dbf; 967 debug_info_t *hba_dbf;
894 debug_info_t *in_els_dbf; 968 debug_info_t *san_dbf; /* debug feature areas */
895 debug_info_t *cmd_dbf; 969 debug_info_t *scsi_dbf;
896 spinlock_t dbf_lock; 970 spinlock_t erp_dbf_lock;
971 spinlock_t hba_dbf_lock;
972 spinlock_t san_dbf_lock;
973 spinlock_t scsi_dbf_lock;
974 struct zfcp_erp_dbf_record erp_dbf_buf;
975 struct zfcp_hba_dbf_record hba_dbf_buf;
976 struct zfcp_san_dbf_record san_dbf_buf;
977 struct zfcp_scsi_dbf_record scsi_dbf_buf;
897 struct zfcp_adapter_mempool pool; /* Adapter memory pools */ 978 struct zfcp_adapter_mempool pool; /* Adapter memory pools */
898 struct qdio_initialize qdio_init_data; /* for qdio_establish */ 979 struct qdio_initialize qdio_init_data; /* for qdio_establish */
899 struct device generic_services; /* directory for WKA ports */ 980 struct device generic_services; /* directory for WKA ports */
@@ -919,7 +1000,7 @@ struct zfcp_port {
919 atomic_t status; /* status of this remote port */ 1000 atomic_t status; /* status of this remote port */
920 wwn_t wwnn; /* WWNN if known */ 1001 wwn_t wwnn; /* WWNN if known */
921 wwn_t wwpn; /* WWPN */ 1002 wwn_t wwpn; /* WWPN */
922 fc_id_t d_id; /* D_ID */ 1003 u32 d_id; /* D_ID */
923 u32 handle; /* handle assigned by FSF */ 1004 u32 handle; /* handle assigned by FSF */
924 struct zfcp_erp_action erp_action; /* pending error recovery */ 1005 struct zfcp_erp_action erp_action; /* pending error recovery */
925 atomic_t erp_counter; 1006 atomic_t erp_counter;
@@ -963,11 +1044,13 @@ struct zfcp_fsf_req {
963 u32 fsf_command; /* FSF Command copy */ 1044 u32 fsf_command; /* FSF Command copy */
964 struct fsf_qtcb *qtcb; /* address of associated QTCB */ 1045 struct fsf_qtcb *qtcb; /* address of associated QTCB */
965 u32 seq_no; /* Sequence number of request */ 1046 u32 seq_no; /* Sequence number of request */
966 union zfcp_req_data data; /* Info fields of request */ 1047 unsigned long data; /* private data of request */
967 struct zfcp_erp_action *erp_action; /* used if this request is 1048 struct zfcp_erp_action *erp_action; /* used if this request is
968 issued on behalf of erp */ 1049 issued on behalf of erp */
969 mempool_t *pool; /* used if request was alloacted 1050 mempool_t *pool; /* used if request was alloacted
970 from emergency pool */ 1051 from emergency pool */
1052 unsigned long long issued; /* request sent time (STCK) */
1053 struct zfcp_unit *unit;
971}; 1054};
972 1055
973typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*); 1056typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*);
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index cb4f612550ba..023f4e558ae4 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -82,6 +82,7 @@ static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);
82static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *); 82static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);
83static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *); 83static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);
84static int zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *); 84static int zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *);
85static int zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *);
85static int zfcp_erp_adapter_strategy_open_fsf_statusread( 86static int zfcp_erp_adapter_strategy_open_fsf_statusread(
86 struct zfcp_erp_action *); 87 struct zfcp_erp_action *);
87 88
@@ -345,13 +346,13 @@ zfcp_erp_adisc(struct zfcp_port *port)
345 346
346 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports 347 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
347 without FC-AL-2 capability, so we don't set it */ 348 without FC-AL-2 capability, so we don't set it */
348 adisc->wwpn = adapter->wwpn; 349 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
349 adisc->wwnn = adapter->wwnn; 350 adisc->wwnn = fc_host_node_name(adapter->scsi_host);
350 adisc->nport_id = adapter->s_id; 351 adisc->nport_id = fc_host_port_id(adapter->scsi_host);
351 ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x " 352 ZFCP_LOG_INFO("ADISC request from s_id 0x%08x to d_id 0x%08x "
352 "(wwpn=0x%016Lx, wwnn=0x%016Lx, " 353 "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
353 "hard_nport_id=0x%08x, nport_id=0x%08x)\n", 354 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
354 adapter->s_id, send_els->d_id, (wwn_t) adisc->wwpn, 355 adisc->nport_id, send_els->d_id, (wwn_t) adisc->wwpn,
355 (wwn_t) adisc->wwnn, adisc->hard_nport_id, 356 (wwn_t) adisc->wwnn, adisc->hard_nport_id,
356 adisc->nport_id); 357 adisc->nport_id);
357 358
@@ -404,7 +405,7 @@ zfcp_erp_adisc_handler(unsigned long data)
404 struct zfcp_send_els *send_els; 405 struct zfcp_send_els *send_els;
405 struct zfcp_port *port; 406 struct zfcp_port *port;
406 struct zfcp_adapter *adapter; 407 struct zfcp_adapter *adapter;
407 fc_id_t d_id; 408 u32 d_id;
408 struct zfcp_ls_adisc_acc *adisc; 409 struct zfcp_ls_adisc_acc *adisc;
409 410
410 send_els = (struct zfcp_send_els *) data; 411 send_els = (struct zfcp_send_els *) data;
@@ -435,9 +436,9 @@ zfcp_erp_adisc_handler(unsigned long data)
435 ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id " 436 ZFCP_LOG_INFO("ADISC response from d_id 0x%08x to s_id "
436 "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, " 437 "0x%08x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
437 "hard_nport_id=0x%08x, nport_id=0x%08x)\n", 438 "hard_nport_id=0x%08x, nport_id=0x%08x)\n",
438 d_id, adapter->s_id, (wwn_t) adisc->wwpn, 439 d_id, fc_host_port_id(adapter->scsi_host),
439 (wwn_t) adisc->wwnn, adisc->hard_nport_id, 440 (wwn_t) adisc->wwpn, (wwn_t) adisc->wwnn,
440 adisc->nport_id); 441 adisc->hard_nport_id, adisc->nport_id);
441 442
442 /* set wwnn for port */ 443 /* set wwnn for port */
443 if (port->wwnn == 0) 444 if (port->wwnn == 0)
@@ -886,7 +887,7 @@ static int
886zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action) 887zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
887{ 888{
888 int retval = 0; 889 int retval = 0;
889 struct zfcp_fsf_req *fsf_req; 890 struct zfcp_fsf_req *fsf_req = NULL;
890 struct zfcp_adapter *adapter = erp_action->adapter; 891 struct zfcp_adapter *adapter = erp_action->adapter;
891 892
892 if (erp_action->fsf_req) { 893 if (erp_action->fsf_req) {
@@ -896,7 +897,7 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
896 list_for_each_entry(fsf_req, &adapter->fsf_req_list_head, list) 897 list_for_each_entry(fsf_req, &adapter->fsf_req_list_head, list)
897 if (fsf_req == erp_action->fsf_req) 898 if (fsf_req == erp_action->fsf_req)
898 break; 899 break;
899 if (fsf_req == erp_action->fsf_req) { 900 if (fsf_req && (fsf_req->erp_action == erp_action)) {
900 /* fsf_req still exists */ 901 /* fsf_req still exists */
901 debug_text_event(adapter->erp_dbf, 3, "a_ca_req"); 902 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
902 debug_event(adapter->erp_dbf, 3, &fsf_req, 903 debug_event(adapter->erp_dbf, 3, &fsf_req,
@@ -2258,16 +2259,21 @@ zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2258static int 2259static int
2259zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action) 2260zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2260{ 2261{
2261 int retval; 2262 int xconfig, xport;
2263
2264 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2265 &erp_action->adapter->status)) {
2266 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2267 atomic_set(&erp_action->adapter->erp_counter, 0);
2268 return ZFCP_ERP_FAILED;
2269 }
2262 2270
2263 /* do 'exchange configuration data' */ 2271 xconfig = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2264 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action); 2272 xport = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2265 if (retval == ZFCP_ERP_FAILED) 2273 if ((xconfig == ZFCP_ERP_FAILED) || (xport == ZFCP_ERP_FAILED))
2266 return retval; 2274 return ZFCP_ERP_FAILED;
2267 2275
2268 /* start the desired number of Status Reads */ 2276 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
2269 retval = zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
2270 return retval;
2271} 2277}
2272 2278
2273/* 2279/*
@@ -2291,7 +2297,9 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2291 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, 2297 atomic_clear_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
2292 &adapter->status); 2298 &adapter->status);
2293 ZFCP_LOG_DEBUG("Doing exchange config data\n"); 2299 ZFCP_LOG_DEBUG("Doing exchange config data\n");
2300 write_lock(&adapter->erp_lock);
2294 zfcp_erp_action_to_running(erp_action); 2301 zfcp_erp_action_to_running(erp_action);
2302 write_unlock(&adapter->erp_lock);
2295 zfcp_erp_timeout_init(erp_action); 2303 zfcp_erp_timeout_init(erp_action);
2296 if (zfcp_fsf_exchange_config_data(erp_action)) { 2304 if (zfcp_fsf_exchange_config_data(erp_action)) {
2297 retval = ZFCP_ERP_FAILED; 2305 retval = ZFCP_ERP_FAILED;
@@ -2348,6 +2356,76 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2348 return retval; 2356 return retval;
2349} 2357}
2350 2358
2359static int
2360zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2361{
2362 int retval = ZFCP_ERP_SUCCEEDED;
2363 int retries;
2364 int sleep;
2365 struct zfcp_adapter *adapter = erp_action->adapter;
2366
2367 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2368
2369 for (retries = 0; ; retries++) {
2370 ZFCP_LOG_DEBUG("Doing exchange port data\n");
2371 zfcp_erp_action_to_running(erp_action);
2372 zfcp_erp_timeout_init(erp_action);
2373 if (zfcp_fsf_exchange_port_data(erp_action, adapter, NULL)) {
2374 retval = ZFCP_ERP_FAILED;
2375 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf");
2376 ZFCP_LOG_INFO("error: initiation of exchange of "
2377 "port data failed for adapter %s\n",
2378 zfcp_get_busid_by_adapter(adapter));
2379 break;
2380 }
2381 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok");
2382 ZFCP_LOG_DEBUG("Xchange underway\n");
2383
2384 /*
2385 * Why this works:
2386 * Both the normal completion handler as well as the timeout
2387 * handler will do an 'up' when the 'exchange port data'
2388 * request completes or times out. Thus, the signal to go on
2389 * won't be lost utilizing this semaphore.
2390 * Furthermore, this 'adapter_reopen' action is
2391 * guaranteed to be the only action being there (highest action
2392 * which prevents other actions from being created).
2393 * Resulting from that, the wake signal recognized here
2394 * _must_ be the one belonging to the 'exchange port
2395 * data' request.
2396 */
2397 down(&adapter->erp_ready_sem);
2398 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2399 ZFCP_LOG_INFO("error: exchange of port data "
2400 "for adapter %s timed out\n",
2401 zfcp_get_busid_by_adapter(adapter));
2402 break;
2403 }
2404
2405 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2406 &adapter->status))
2407 break;
2408
2409 ZFCP_LOG_DEBUG("host connection still initialising... "
2410 "waiting and retrying...\n");
2411 /* sleep a little bit before retry */
2412 sleep = retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES ?
2413 ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP :
2414 ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP;
2415 msleep(jiffies_to_msecs(sleep));
2416 }
2417
2418 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2419 &adapter->status)) {
2420 ZFCP_LOG_INFO("error: exchange of port data for "
2421 "adapter %s failed\n",
2422 zfcp_get_busid_by_adapter(adapter));
2423 retval = ZFCP_ERP_FAILED;
2424 }
2425
2426 return retval;
2427}
2428
2351/* 2429/*
2352 * function: 2430 * function:
2353 * 2431 *
@@ -3194,11 +3272,19 @@ zfcp_erp_action_enqueue(int action,
3194 /* fall through !!! */ 3272 /* fall through !!! */
3195 3273
3196 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 3274 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
3197 if (atomic_test_mask 3275 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
3198 (ZFCP_STATUS_COMMON_ERP_INUSE, &port->status) 3276 &port->status)) {
3199 && port->erp_action.action == 3277 if (port->erp_action.action !=
3200 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) { 3278 ZFCP_ERP_ACTION_REOPEN_PORT_FORCED) {
3201 debug_text_event(adapter->erp_dbf, 4, "pf_actenq_drp"); 3279 ZFCP_LOG_INFO("dropped erp action %i (port "
3280 "0x%016Lx, action in use: %i)\n",
3281 action, port->wwpn,
3282 port->erp_action.action);
3283 debug_text_event(adapter->erp_dbf, 4,
3284 "pf_actenq_drp");
3285 } else
3286 debug_text_event(adapter->erp_dbf, 4,
3287 "pf_actenq_drpcp");
3202 debug_event(adapter->erp_dbf, 4, &port->wwpn, 3288 debug_event(adapter->erp_dbf, 4, &port->wwpn,
3203 sizeof (wwn_t)); 3289 sizeof (wwn_t));
3204 goto out; 3290 goto out;
@@ -3589,6 +3675,9 @@ zfcp_erp_adapter_access_changed(struct zfcp_adapter *adapter)
3589 struct zfcp_port *port; 3675 struct zfcp_port *port;
3590 unsigned long flags; 3676 unsigned long flags;
3591 3677
3678 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
3679 return;
3680
3592 debug_text_event(adapter->erp_dbf, 3, "a_access_recover"); 3681 debug_text_event(adapter->erp_dbf, 3, "a_access_recover");
3593 debug_event(adapter->erp_dbf, 3, &adapter->name, 8); 3682 debug_event(adapter->erp_dbf, 3, &adapter->name, 8);
3594 3683
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index cd98a2de9f8f..c3782261cb5c 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -96,7 +96,8 @@ extern int zfcp_fsf_open_unit(struct zfcp_erp_action *);
96extern int zfcp_fsf_close_unit(struct zfcp_erp_action *); 96extern int zfcp_fsf_close_unit(struct zfcp_erp_action *);
97 97
98extern int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *); 98extern int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *);
99extern int zfcp_fsf_exchange_port_data(struct zfcp_adapter *, 99extern int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *,
100 struct zfcp_adapter *,
100 struct fsf_qtcb_bottom_port *); 101 struct fsf_qtcb_bottom_port *);
101extern int zfcp_fsf_control_file(struct zfcp_adapter *, struct zfcp_fsf_req **, 102extern int zfcp_fsf_control_file(struct zfcp_adapter *, struct zfcp_fsf_req **,
102 u32, u32, struct zfcp_sg_list *); 103 u32, u32, struct zfcp_sg_list *);
@@ -109,7 +110,6 @@ extern int zfcp_fsf_req_create(struct zfcp_adapter *, u32, int, mempool_t *,
109extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *, 110extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *,
110 struct zfcp_erp_action *); 111 struct zfcp_erp_action *);
111extern int zfcp_fsf_send_els(struct zfcp_send_els *); 112extern int zfcp_fsf_send_els(struct zfcp_send_els *);
112extern int zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *, int, u32 *);
113extern int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *, 113extern int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *,
114 struct zfcp_unit *, 114 struct zfcp_unit *,
115 struct scsi_cmnd *, 115 struct scsi_cmnd *,
@@ -182,9 +182,25 @@ extern void zfcp_erp_port_access_changed(struct zfcp_port *);
182extern void zfcp_erp_unit_access_changed(struct zfcp_unit *); 182extern void zfcp_erp_unit_access_changed(struct zfcp_unit *);
183 183
184/******************************** AUX ****************************************/ 184/******************************** AUX ****************************************/
185extern void zfcp_cmd_dbf_event_fsf(const char *, struct zfcp_fsf_req *, 185extern void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *);
186 void *, int); 186extern void zfcp_hba_dbf_event_fsf_unsol(const char *, struct zfcp_adapter *,
187extern void zfcp_cmd_dbf_event_scsi(const char *, struct scsi_cmnd *); 187 struct fsf_status_read_buffer *);
188extern void zfcp_in_els_dbf_event(struct zfcp_adapter *, const char *, 188extern void zfcp_hba_dbf_event_qdio(struct zfcp_adapter *,
189 struct fsf_status_read_buffer *, int); 189 unsigned int, unsigned int, unsigned int,
190 int, int);
191
192extern void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *);
193extern void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *);
194extern void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *);
195extern void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *);
196extern void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *);
197
198extern void zfcp_scsi_dbf_event_result(const char *, int, struct zfcp_adapter *,
199 struct scsi_cmnd *);
200extern void zfcp_scsi_dbf_event_abort(const char *, struct zfcp_adapter *,
201 struct scsi_cmnd *,
202 struct zfcp_fsf_req *);
203extern void zfcp_scsi_dbf_event_devreset(const char *, u8, struct zfcp_unit *,
204 struct scsi_cmnd *);
205
190#endif /* ZFCP_EXT_H */ 206#endif /* ZFCP_EXT_H */
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index c007b6424e74..3b0fc1163f5f 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -59,6 +59,8 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *, struct timer_list *);
59static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *); 59static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *);
60static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *); 60static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *);
61static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *); 61static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *);
62static void zfcp_fsf_link_down_info_eval(struct zfcp_adapter *,
63 struct fsf_link_down_info *);
62static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *); 64static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *);
63static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req *); 65static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req *);
64 66
@@ -285,51 +287,51 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
285{ 287{
286 int retval = 0; 288 int retval = 0;
287 struct zfcp_adapter *adapter = fsf_req->adapter; 289 struct zfcp_adapter *adapter = fsf_req->adapter;
290 struct fsf_qtcb *qtcb = fsf_req->qtcb;
291 union fsf_prot_status_qual *prot_status_qual =
292 &qtcb->prefix.prot_status_qual;
288 293
289 ZFCP_LOG_DEBUG("QTCB is at %p\n", fsf_req->qtcb); 294 zfcp_hba_dbf_event_fsf_response(fsf_req);
290 295
291 if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { 296 if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
292 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n", 297 ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
293 (unsigned long) fsf_req); 298 (unsigned long) fsf_req);
294 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR | 299 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
295 ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */ 300 ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */
296 zfcp_cmd_dbf_event_fsf("dismiss", fsf_req, NULL, 0);
297 goto skip_protstatus; 301 goto skip_protstatus;
298 } 302 }
299 303
300 /* log additional information provided by FSF (if any) */ 304 /* log additional information provided by FSF (if any) */
301 if (unlikely(fsf_req->qtcb->header.log_length)) { 305 if (unlikely(qtcb->header.log_length)) {
302 /* do not trust them ;-) */ 306 /* do not trust them ;-) */
303 if (fsf_req->qtcb->header.log_start > sizeof(struct fsf_qtcb)) { 307 if (qtcb->header.log_start > sizeof(struct fsf_qtcb)) {
304 ZFCP_LOG_NORMAL 308 ZFCP_LOG_NORMAL
305 ("bug: ULP (FSF logging) log data starts " 309 ("bug: ULP (FSF logging) log data starts "
306 "beyond end of packet header. Ignored. " 310 "beyond end of packet header. Ignored. "
307 "(start=%i, size=%li)\n", 311 "(start=%i, size=%li)\n",
308 fsf_req->qtcb->header.log_start, 312 qtcb->header.log_start,
309 sizeof(struct fsf_qtcb)); 313 sizeof(struct fsf_qtcb));
310 goto forget_log; 314 goto forget_log;
311 } 315 }
312 if ((size_t) (fsf_req->qtcb->header.log_start + 316 if ((size_t) (qtcb->header.log_start + qtcb->header.log_length)
313 fsf_req->qtcb->header.log_length)
314 > sizeof(struct fsf_qtcb)) { 317 > sizeof(struct fsf_qtcb)) {
315 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends " 318 ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
316 "beyond end of packet header. Ignored. " 319 "beyond end of packet header. Ignored. "
317 "(start=%i, length=%i, size=%li)\n", 320 "(start=%i, length=%i, size=%li)\n",
318 fsf_req->qtcb->header.log_start, 321 qtcb->header.log_start,
319 fsf_req->qtcb->header.log_length, 322 qtcb->header.log_length,
320 sizeof(struct fsf_qtcb)); 323 sizeof(struct fsf_qtcb));
321 goto forget_log; 324 goto forget_log;
322 } 325 }
323 ZFCP_LOG_TRACE("ULP log data: \n"); 326 ZFCP_LOG_TRACE("ULP log data: \n");
324 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, 327 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
325 (char *) fsf_req->qtcb + 328 (char *) qtcb + qtcb->header.log_start,
326 fsf_req->qtcb->header.log_start, 329 qtcb->header.log_length);
327 fsf_req->qtcb->header.log_length);
328 } 330 }
329 forget_log: 331 forget_log:
330 332
331 /* evaluate FSF Protocol Status */ 333 /* evaluate FSF Protocol Status */
332 switch (fsf_req->qtcb->prefix.prot_status) { 334 switch (qtcb->prefix.prot_status) {
333 335
334 case FSF_PROT_GOOD: 336 case FSF_PROT_GOOD:
335 case FSF_PROT_FSF_STATUS_PRESENTED: 337 case FSF_PROT_FSF_STATUS_PRESENTED:
@@ -340,14 +342,9 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
340 "microcode of version 0x%x, the device driver " 342 "microcode of version 0x%x, the device driver "
341 "only supports 0x%x. Aborting.\n", 343 "only supports 0x%x. Aborting.\n",
342 zfcp_get_busid_by_adapter(adapter), 344 zfcp_get_busid_by_adapter(adapter),
343 fsf_req->qtcb->prefix.prot_status_qual. 345 prot_status_qual->version_error.fsf_version,
344 version_error.fsf_version, ZFCP_QTCB_VERSION); 346 ZFCP_QTCB_VERSION);
345 /* stop operation for this adapter */
346 debug_text_exception(adapter->erp_dbf, 0, "prot_ver_err");
347 zfcp_erp_adapter_shutdown(adapter, 0); 347 zfcp_erp_adapter_shutdown(adapter, 0);
348 zfcp_cmd_dbf_event_fsf("qverserr", fsf_req,
349 &fsf_req->qtcb->prefix.prot_status_qual,
350 sizeof (union fsf_prot_status_qual));
351 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 348 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
352 break; 349 break;
353 350
@@ -355,16 +352,10 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
355 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between " 352 ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
356 "driver (0x%x) and adapter %s (0x%x). " 353 "driver (0x%x) and adapter %s (0x%x). "
357 "Restarting all operations on this adapter.\n", 354 "Restarting all operations on this adapter.\n",
358 fsf_req->qtcb->prefix.req_seq_no, 355 qtcb->prefix.req_seq_no,
359 zfcp_get_busid_by_adapter(adapter), 356 zfcp_get_busid_by_adapter(adapter),
360 fsf_req->qtcb->prefix.prot_status_qual. 357 prot_status_qual->sequence_error.exp_req_seq_no);
361 sequence_error.exp_req_seq_no);
362 debug_text_exception(adapter->erp_dbf, 0, "prot_seq_err");
363 /* restart operation on this adapter */
364 zfcp_erp_adapter_reopen(adapter, 0); 358 zfcp_erp_adapter_reopen(adapter, 0);
365 zfcp_cmd_dbf_event_fsf("seqnoerr", fsf_req,
366 &fsf_req->qtcb->prefix.prot_status_qual,
367 sizeof (union fsf_prot_status_qual));
368 fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY; 359 fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
369 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 360 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
370 break; 361 break;
@@ -375,116 +366,35 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
375 "that used on adapter %s. " 366 "that used on adapter %s. "
376 "Stopping all operations on this adapter.\n", 367 "Stopping all operations on this adapter.\n",
377 zfcp_get_busid_by_adapter(adapter)); 368 zfcp_get_busid_by_adapter(adapter));
378 debug_text_exception(adapter->erp_dbf, 0, "prot_unsup_qtcb");
379 zfcp_erp_adapter_shutdown(adapter, 0); 369 zfcp_erp_adapter_shutdown(adapter, 0);
380 zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req,
381 &fsf_req->qtcb->prefix.prot_status_qual,
382 sizeof (union fsf_prot_status_qual));
383 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 370 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
384 break; 371 break;
385 372
386 case FSF_PROT_HOST_CONNECTION_INITIALIZING: 373 case FSF_PROT_HOST_CONNECTION_INITIALIZING:
387 zfcp_cmd_dbf_event_fsf("hconinit", fsf_req,
388 &fsf_req->qtcb->prefix.prot_status_qual,
389 sizeof (union fsf_prot_status_qual));
390 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 374 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
391 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, 375 atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
392 &(adapter->status)); 376 &(adapter->status));
393 debug_text_event(adapter->erp_dbf, 3, "prot_con_init");
394 break; 377 break;
395 378
396 case FSF_PROT_DUPLICATE_REQUEST_ID: 379 case FSF_PROT_DUPLICATE_REQUEST_ID:
397 if (fsf_req->qtcb) {
398 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx " 380 ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
399 "to the adapter %s is ambiguous. " 381 "to the adapter %s is ambiguous. "
400 "Stopping all operations on this " 382 "Stopping all operations on this adapter.\n",
401 "adapter.\n", 383 *(unsigned long long*)
402 *(unsigned long long *) 384 (&qtcb->bottom.support.req_handle),
403 (&fsf_req->qtcb->bottom.support.
404 req_handle),
405 zfcp_get_busid_by_adapter(adapter));
406 } else {
407 ZFCP_LOG_NORMAL("bug: The request identifier %p "
408 "to the adapter %s is ambiguous. "
409 "Stopping all operations on this "
410 "adapter. "
411 "(bug: got this for an unsolicited "
412 "status read request)\n",
413 fsf_req,
414 zfcp_get_busid_by_adapter(adapter)); 385 zfcp_get_busid_by_adapter(adapter));
415 }
416 debug_text_exception(adapter->erp_dbf, 0, "prot_dup_id");
417 zfcp_erp_adapter_shutdown(adapter, 0); 386 zfcp_erp_adapter_shutdown(adapter, 0);
418 zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req,
419 &fsf_req->qtcb->prefix.prot_status_qual,
420 sizeof (union fsf_prot_status_qual));
421 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 387 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
422 break; 388 break;
423 389
424 case FSF_PROT_LINK_DOWN: 390 case FSF_PROT_LINK_DOWN:
425 /* 391 zfcp_fsf_link_down_info_eval(adapter,
426 * 'test and set' is not atomic here - 392 &prot_status_qual->link_down_info);
427 * it's ok as long as calls to our response queue handler
428 * (and thus execution of this code here) are serialized
429 * by the qdio module
430 */
431 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
432 &adapter->status)) {
433 switch (fsf_req->qtcb->prefix.prot_status_qual.
434 locallink_error.code) {
435 case FSF_PSQ_LINK_NOLIGHT:
436 ZFCP_LOG_INFO("The local link to adapter %s "
437 "is down (no light detected).\n",
438 zfcp_get_busid_by_adapter(
439 adapter));
440 break;
441 case FSF_PSQ_LINK_WRAPPLUG:
442 ZFCP_LOG_INFO("The local link to adapter %s "
443 "is down (wrap plug detected).\n",
444 zfcp_get_busid_by_adapter(
445 adapter));
446 break;
447 case FSF_PSQ_LINK_NOFCP:
448 ZFCP_LOG_INFO("The local link to adapter %s "
449 "is down (adjacent node on "
450 "link does not support FCP).\n",
451 zfcp_get_busid_by_adapter(
452 adapter));
453 break;
454 default:
455 ZFCP_LOG_INFO("The local link to adapter %s "
456 "is down "
457 "(warning: unknown reason "
458 "code).\n",
459 zfcp_get_busid_by_adapter(
460 adapter));
461 break;
462
463 }
464 /*
465 * Due to the 'erp failed' flag the adapter won't
466 * be recovered but will be just set to 'blocked'
467 * state. All subordinary devices will have state
468 * 'blocked' and 'erp failed', too.
469 * Thus the adapter is still able to provide
470 * 'link up' status without being flooded with
471 * requests.
472 * (note: even 'close port' is not permitted)
473 */
474 ZFCP_LOG_INFO("Stopping all operations for adapter "
475 "%s.\n",
476 zfcp_get_busid_by_adapter(adapter));
477 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
478 ZFCP_STATUS_COMMON_ERP_FAILED,
479 &adapter->status);
480 zfcp_erp_adapter_reopen(adapter, 0);
481 }
482 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 393 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
483 break; 394 break;
484 395
485 case FSF_PROT_REEST_QUEUE: 396 case FSF_PROT_REEST_QUEUE:
486 debug_text_event(adapter->erp_dbf, 1, "prot_reest_queue"); 397 ZFCP_LOG_NORMAL("The local link to adapter with "
487 ZFCP_LOG_INFO("The local link to adapter with "
488 "%s was re-plugged. " 398 "%s was re-plugged. "
489 "Re-starting operations on this adapter.\n", 399 "Re-starting operations on this adapter.\n",
490 zfcp_get_busid_by_adapter(adapter)); 400 zfcp_get_busid_by_adapter(adapter));
@@ -495,9 +405,6 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
495 zfcp_erp_adapter_reopen(adapter, 405 zfcp_erp_adapter_reopen(adapter,
496 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED 406 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
497 | ZFCP_STATUS_COMMON_ERP_FAILED); 407 | ZFCP_STATUS_COMMON_ERP_FAILED);
498 zfcp_cmd_dbf_event_fsf("reestque", fsf_req,
499 &fsf_req->qtcb->prefix.prot_status_qual,
500 sizeof (union fsf_prot_status_qual));
501 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 408 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
502 break; 409 break;
503 410
@@ -507,12 +414,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
507 "Restarting all operations on this " 414 "Restarting all operations on this "
508 "adapter.\n", 415 "adapter.\n",
509 zfcp_get_busid_by_adapter(adapter)); 416 zfcp_get_busid_by_adapter(adapter));
510 debug_text_event(adapter->erp_dbf, 0, "prot_err_sta");
511 /* restart operation on this adapter */
512 zfcp_erp_adapter_reopen(adapter, 0); 417 zfcp_erp_adapter_reopen(adapter, 0);
513 zfcp_cmd_dbf_event_fsf("proterrs", fsf_req,
514 &fsf_req->qtcb->prefix.prot_status_qual,
515 sizeof (union fsf_prot_status_qual));
516 fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY; 418 fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
517 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 419 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
518 break; 420 break;
@@ -524,11 +426,7 @@ zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
524 "Stopping all operations on this adapter. " 426 "Stopping all operations on this adapter. "
525 "(debug info 0x%x).\n", 427 "(debug info 0x%x).\n",
526 zfcp_get_busid_by_adapter(adapter), 428 zfcp_get_busid_by_adapter(adapter),
527 fsf_req->qtcb->prefix.prot_status); 429 qtcb->prefix.prot_status);
528 debug_text_event(adapter->erp_dbf, 0, "prot_inval:");
529 debug_exception(adapter->erp_dbf, 0,
530 &fsf_req->qtcb->prefix.prot_status,
531 sizeof (u32));
532 zfcp_erp_adapter_shutdown(adapter, 0); 430 zfcp_erp_adapter_shutdown(adapter, 0);
533 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 431 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
534 } 432 }
@@ -568,28 +466,18 @@ zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req)
568 "(debug info 0x%x).\n", 466 "(debug info 0x%x).\n",
569 zfcp_get_busid_by_adapter(fsf_req->adapter), 467 zfcp_get_busid_by_adapter(fsf_req->adapter),
570 fsf_req->qtcb->header.fsf_command); 468 fsf_req->qtcb->header.fsf_command);
571 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
572 "fsf_s_unknown");
573 zfcp_erp_adapter_shutdown(fsf_req->adapter, 0); 469 zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
574 zfcp_cmd_dbf_event_fsf("unknownc", fsf_req,
575 &fsf_req->qtcb->header.fsf_status_qual,
576 sizeof (union fsf_status_qual));
577 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 470 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
578 break; 471 break;
579 472
580 case FSF_FCP_RSP_AVAILABLE: 473 case FSF_FCP_RSP_AVAILABLE:
581 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the " 474 ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
582 "SCSI stack.\n"); 475 "SCSI stack.\n");
583 debug_text_event(fsf_req->adapter->erp_dbf, 3, "fsf_s_rsp");
584 break; 476 break;
585 477
586 case FSF_ADAPTER_STATUS_AVAILABLE: 478 case FSF_ADAPTER_STATUS_AVAILABLE:
587 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_astatus");
588 zfcp_fsf_fsfstatus_qual_eval(fsf_req); 479 zfcp_fsf_fsfstatus_qual_eval(fsf_req);
589 break; 480 break;
590
591 default:
592 break;
593 } 481 }
594 482
595 skip_fsfstatus: 483 skip_fsfstatus:
@@ -617,44 +505,28 @@ zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
617 505
618 switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) { 506 switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
619 case FSF_SQ_FCP_RSP_AVAILABLE: 507 case FSF_SQ_FCP_RSP_AVAILABLE:
620 debug_text_event(fsf_req->adapter->erp_dbf, 4, "fsf_sq_rsp");
621 break; 508 break;
622 case FSF_SQ_RETRY_IF_POSSIBLE: 509 case FSF_SQ_RETRY_IF_POSSIBLE:
623 /* The SCSI-stack may now issue retries or escalate */ 510 /* The SCSI-stack may now issue retries or escalate */
624 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_retry");
625 zfcp_cmd_dbf_event_fsf("sqretry", fsf_req,
626 &fsf_req->qtcb->header.fsf_status_qual,
627 sizeof (union fsf_status_qual));
628 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 511 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
629 break; 512 break;
630 case FSF_SQ_COMMAND_ABORTED: 513 case FSF_SQ_COMMAND_ABORTED:
631 /* Carry the aborted state on to upper layer */ 514 /* Carry the aborted state on to upper layer */
632 debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_abort");
633 zfcp_cmd_dbf_event_fsf("sqabort", fsf_req,
634 &fsf_req->qtcb->header.fsf_status_qual,
635 sizeof (union fsf_status_qual));
636 fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED; 515 fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED;
637 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 516 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
638 break; 517 break;
639 case FSF_SQ_NO_RECOM: 518 case FSF_SQ_NO_RECOM:
640 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
641 "fsf_sq_no_rec");
642 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a" 519 ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
643 "problem on the adapter %s " 520 "problem on the adapter %s "
644 "Stopping all operations on this adapter. ", 521 "Stopping all operations on this adapter. ",
645 zfcp_get_busid_by_adapter(fsf_req->adapter)); 522 zfcp_get_busid_by_adapter(fsf_req->adapter));
646 zfcp_erp_adapter_shutdown(fsf_req->adapter, 0); 523 zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
647 zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req,
648 &fsf_req->qtcb->header.fsf_status_qual,
649 sizeof (union fsf_status_qual));
650 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 524 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
651 break; 525 break;
652 case FSF_SQ_ULP_PROGRAMMING_ERROR: 526 case FSF_SQ_ULP_PROGRAMMING_ERROR:
653 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer " 527 ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
654 "(adapter %s)\n", 528 "(adapter %s)\n",
655 zfcp_get_busid_by_adapter(fsf_req->adapter)); 529 zfcp_get_busid_by_adapter(fsf_req->adapter));
656 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
657 "fsf_sq_ulp_err");
658 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 530 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
659 break; 531 break;
660 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: 532 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
@@ -668,13 +540,6 @@ zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
668 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, 540 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
669 (char *) &fsf_req->qtcb->header.fsf_status_qual, 541 (char *) &fsf_req->qtcb->header.fsf_status_qual,
670 sizeof (union fsf_status_qual)); 542 sizeof (union fsf_status_qual));
671 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval:");
672 debug_exception(fsf_req->adapter->erp_dbf, 0,
673 &fsf_req->qtcb->header.fsf_status_qual.word[0],
674 sizeof (u32));
675 zfcp_cmd_dbf_event_fsf("squndef", fsf_req,
676 &fsf_req->qtcb->header.fsf_status_qual,
677 sizeof (union fsf_status_qual));
678 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 543 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
679 break; 544 break;
680 } 545 }
@@ -682,6 +547,110 @@ zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
682 return retval; 547 return retval;
683} 548}
684 549
550/**
551 * zfcp_fsf_link_down_info_eval - evaluate link down information block
552 */
553static void
554zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
555 struct fsf_link_down_info *link_down)
556{
557 switch (link_down->error_code) {
558 case FSF_PSQ_LINK_NO_LIGHT:
559 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
560 "(no light detected)\n",
561 zfcp_get_busid_by_adapter(adapter));
562 break;
563 case FSF_PSQ_LINK_WRAP_PLUG:
564 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
565 "(wrap plug detected)\n",
566 zfcp_get_busid_by_adapter(adapter));
567 break;
568 case FSF_PSQ_LINK_NO_FCP:
569 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
570 "(adjacent node on link does not support FCP)\n",
571 zfcp_get_busid_by_adapter(adapter));
572 break;
573 case FSF_PSQ_LINK_FIRMWARE_UPDATE:
574 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
575 "(firmware update in progress)\n",
576 zfcp_get_busid_by_adapter(adapter));
577 break;
578 case FSF_PSQ_LINK_INVALID_WWPN:
579 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
580 "(duplicate or invalid WWPN detected)\n",
581 zfcp_get_busid_by_adapter(adapter));
582 break;
583 case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
584 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
585 "(no support for NPIV by Fabric)\n",
586 zfcp_get_busid_by_adapter(adapter));
587 break;
588 case FSF_PSQ_LINK_NO_FCP_RESOURCES:
589 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
590 "(out of resource in FCP daughtercard)\n",
591 zfcp_get_busid_by_adapter(adapter));
592 break;
593 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
594 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
595 "(out of resource in Fabric)\n",
596 zfcp_get_busid_by_adapter(adapter));
597 break;
598 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
599 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
600 "(unable to Fabric login)\n",
601 zfcp_get_busid_by_adapter(adapter));
602 break;
603 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
604 ZFCP_LOG_NORMAL("WWPN assignment file corrupted on adapter %s\n",
605 zfcp_get_busid_by_adapter(adapter));
606 break;
607 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
608 ZFCP_LOG_NORMAL("Mode table corrupted on adapter %s\n",
609 zfcp_get_busid_by_adapter(adapter));
610 break;
611 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
612 ZFCP_LOG_NORMAL("No WWPN for assignment table on adapter %s\n",
613 zfcp_get_busid_by_adapter(adapter));
614 break;
615 default:
616 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
617 "(warning: unknown reason code %d)\n",
618 zfcp_get_busid_by_adapter(adapter),
619 link_down->error_code);
620 }
621
622 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
623 ZFCP_LOG_DEBUG("Debug information to link down: "
624 "primary_status=0x%02x "
625 "ioerr_code=0x%02x "
626 "action_code=0x%02x "
627 "reason_code=0x%02x "
628 "explanation_code=0x%02x "
629 "vendor_specific_code=0x%02x\n",
630 link_down->primary_status,
631 link_down->ioerr_code,
632 link_down->action_code,
633 link_down->reason_code,
634 link_down->explanation_code,
635 link_down->vendor_specific_code);
636
637 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
638 &adapter->status)) {
639 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
640 &adapter->status);
641 switch (link_down->error_code) {
642 case FSF_PSQ_LINK_NO_LIGHT:
643 case FSF_PSQ_LINK_WRAP_PLUG:
644 case FSF_PSQ_LINK_NO_FCP:
645 case FSF_PSQ_LINK_FIRMWARE_UPDATE:
646 zfcp_erp_adapter_reopen(adapter, 0);
647 break;
648 default:
649 zfcp_erp_adapter_failed(adapter);
650 }
651 }
652}
653
685/* 654/*
686 * function: zfcp_fsf_req_dispatch 655 * function: zfcp_fsf_req_dispatch
687 * 656 *
@@ -696,11 +665,6 @@ zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
696 struct zfcp_adapter *adapter = fsf_req->adapter; 665 struct zfcp_adapter *adapter = fsf_req->adapter;
697 int retval = 0; 666 int retval = 0;
698 667
699 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
700 ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req, fsf_req->qtcb);
701 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
702 (char *) fsf_req->qtcb, sizeof(struct fsf_qtcb));
703 }
704 668
705 switch (fsf_req->fsf_command) { 669 switch (fsf_req->fsf_command) {
706 670
@@ -760,13 +724,13 @@ zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
760 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 724 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
761 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is " 725 ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
762 "not supported by the adapter %s\n", 726 "not supported by the adapter %s\n",
763 zfcp_get_busid_by_adapter(fsf_req->adapter)); 727 zfcp_get_busid_by_adapter(adapter));
764 if (fsf_req->fsf_command != fsf_req->qtcb->header.fsf_command) 728 if (fsf_req->fsf_command != fsf_req->qtcb->header.fsf_command)
765 ZFCP_LOG_NORMAL 729 ZFCP_LOG_NORMAL
766 ("bug: Command issued by the device driver differs " 730 ("bug: Command issued by the device driver differs "
767 "from the command returned by the adapter %s " 731 "from the command returned by the adapter %s "
768 "(debug info 0x%x, 0x%x).\n", 732 "(debug info 0x%x, 0x%x).\n",
769 zfcp_get_busid_by_adapter(fsf_req->adapter), 733 zfcp_get_busid_by_adapter(adapter),
770 fsf_req->fsf_command, 734 fsf_req->fsf_command,
771 fsf_req->qtcb->header.fsf_command); 735 fsf_req->qtcb->header.fsf_command);
772 } 736 }
@@ -774,8 +738,6 @@ zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
774 if (!erp_action) 738 if (!erp_action)
775 return retval; 739 return retval;
776 740
777 debug_text_event(adapter->erp_dbf, 3, "a_frh");
778 debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
779 zfcp_erp_async_handler(erp_action, 0); 741 zfcp_erp_async_handler(erp_action, 0);
780 742
781 return retval; 743 return retval;
@@ -821,7 +783,7 @@ zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
821 goto failed_buf; 783 goto failed_buf;
822 } 784 }
823 memset(status_buffer, 0, sizeof (struct fsf_status_read_buffer)); 785 memset(status_buffer, 0, sizeof (struct fsf_status_read_buffer));
824 fsf_req->data.status_read.buffer = status_buffer; 786 fsf_req->data = (unsigned long) status_buffer;
825 787
826 /* insert pointer to respective buffer */ 788 /* insert pointer to respective buffer */
827 sbale = zfcp_qdio_sbale_curr(fsf_req); 789 sbale = zfcp_qdio_sbale_curr(fsf_req);
@@ -846,6 +808,7 @@ zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
846 failed_buf: 808 failed_buf:
847 zfcp_fsf_req_free(fsf_req); 809 zfcp_fsf_req_free(fsf_req);
848 failed_req_create: 810 failed_req_create:
811 zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL);
849 out: 812 out:
850 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags); 813 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
851 return retval; 814 return retval;
@@ -859,7 +822,7 @@ zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
859 struct zfcp_port *port; 822 struct zfcp_port *port;
860 unsigned long flags; 823 unsigned long flags;
861 824
862 status_buffer = fsf_req->data.status_read.buffer; 825 status_buffer = (struct fsf_status_read_buffer *) fsf_req->data;
863 adapter = fsf_req->adapter; 826 adapter = fsf_req->adapter;
864 827
865 read_lock_irqsave(&zfcp_data.config_lock, flags); 828 read_lock_irqsave(&zfcp_data.config_lock, flags);
@@ -918,38 +881,33 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
918 int retval = 0; 881 int retval = 0;
919 struct zfcp_adapter *adapter = fsf_req->adapter; 882 struct zfcp_adapter *adapter = fsf_req->adapter;
920 struct fsf_status_read_buffer *status_buffer = 883 struct fsf_status_read_buffer *status_buffer =
921 fsf_req->data.status_read.buffer; 884 (struct fsf_status_read_buffer *) fsf_req->data;
922 885
923 if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { 886 if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
887 zfcp_hba_dbf_event_fsf_unsol("dism", adapter, status_buffer);
924 mempool_free(status_buffer, adapter->pool.data_status_read); 888 mempool_free(status_buffer, adapter->pool.data_status_read);
925 zfcp_fsf_req_free(fsf_req); 889 zfcp_fsf_req_free(fsf_req);
926 goto out; 890 goto out;
927 } 891 }
928 892
893 zfcp_hba_dbf_event_fsf_unsol("read", adapter, status_buffer);
894
929 switch (status_buffer->status_type) { 895 switch (status_buffer->status_type) {
930 896
931 case FSF_STATUS_READ_PORT_CLOSED: 897 case FSF_STATUS_READ_PORT_CLOSED:
932 debug_text_event(adapter->erp_dbf, 3, "unsol_pclosed:");
933 debug_event(adapter->erp_dbf, 3,
934 &status_buffer->d_id, sizeof (u32));
935 zfcp_fsf_status_read_port_closed(fsf_req); 898 zfcp_fsf_status_read_port_closed(fsf_req);
936 break; 899 break;
937 900
938 case FSF_STATUS_READ_INCOMING_ELS: 901 case FSF_STATUS_READ_INCOMING_ELS:
939 debug_text_event(adapter->erp_dbf, 3, "unsol_els:");
940 zfcp_fsf_incoming_els(fsf_req); 902 zfcp_fsf_incoming_els(fsf_req);
941 break; 903 break;
942 904
943 case FSF_STATUS_READ_SENSE_DATA_AVAIL: 905 case FSF_STATUS_READ_SENSE_DATA_AVAIL:
944 debug_text_event(adapter->erp_dbf, 3, "unsol_sense:");
945 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n", 906 ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
946 zfcp_get_busid_by_adapter(adapter)); 907 zfcp_get_busid_by_adapter(adapter));
947 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, (char *) status_buffer,
948 sizeof(struct fsf_status_read_buffer));
949 break; 908 break;
950 909
951 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: 910 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
952 debug_text_event(adapter->erp_dbf, 3, "unsol_bit_err:");
953 ZFCP_LOG_NORMAL("Bit error threshold data received:\n"); 911 ZFCP_LOG_NORMAL("Bit error threshold data received:\n");
954 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, 912 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
955 (char *) status_buffer, 913 (char *) status_buffer,
@@ -957,17 +915,32 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
957 break; 915 break;
958 916
959 case FSF_STATUS_READ_LINK_DOWN: 917 case FSF_STATUS_READ_LINK_DOWN:
960 debug_text_event(adapter->erp_dbf, 0, "unsol_link_down:"); 918 switch (status_buffer->status_subtype) {
961 ZFCP_LOG_INFO("Local link to adapter %s is down\n", 919 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
920 ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
921 zfcp_get_busid_by_adapter(adapter));
922 break;
923 case FSF_STATUS_READ_SUB_FDISC_FAILED:
924 ZFCP_LOG_INFO("Local link to adapter %s is down "
925 "due to failed FDISC login\n",
962 zfcp_get_busid_by_adapter(adapter)); 926 zfcp_get_busid_by_adapter(adapter));
963 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 927 break;
964 &adapter->status); 928 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
965 zfcp_erp_adapter_failed(adapter); 929 ZFCP_LOG_INFO("Local link to adapter %s is down "
930 "due to firmware update on adapter\n",
931 zfcp_get_busid_by_adapter(adapter));
932 break;
933 default:
934 ZFCP_LOG_INFO("Local link to adapter %s is down "
935 "due to unknown reason\n",
936 zfcp_get_busid_by_adapter(adapter));
937 };
938 zfcp_fsf_link_down_info_eval(adapter,
939 (struct fsf_link_down_info *) &status_buffer->payload);
966 break; 940 break;
967 941
968 case FSF_STATUS_READ_LINK_UP: 942 case FSF_STATUS_READ_LINK_UP:
969 debug_text_event(adapter->erp_dbf, 2, "unsol_link_up:"); 943 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. "
970 ZFCP_LOG_INFO("Local link to adapter %s was replugged. "
971 "Restarting operations on this adapter\n", 944 "Restarting operations on this adapter\n",
972 zfcp_get_busid_by_adapter(adapter)); 945 zfcp_get_busid_by_adapter(adapter));
973 /* All ports should be marked as ready to run again */ 946 /* All ports should be marked as ready to run again */
@@ -980,35 +953,40 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
980 break; 953 break;
981 954
982 case FSF_STATUS_READ_CFDC_UPDATED: 955 case FSF_STATUS_READ_CFDC_UPDATED:
983 debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_update:"); 956 ZFCP_LOG_NORMAL("CFDC has been updated on the adapter %s\n",
984 ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n",
985 zfcp_get_busid_by_adapter(adapter)); 957 zfcp_get_busid_by_adapter(adapter));
986 zfcp_erp_adapter_access_changed(adapter); 958 zfcp_erp_adapter_access_changed(adapter);
987 break; 959 break;
988 960
989 case FSF_STATUS_READ_CFDC_HARDENED: 961 case FSF_STATUS_READ_CFDC_HARDENED:
990 debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_harden:");
991 switch (status_buffer->status_subtype) { 962 switch (status_buffer->status_subtype) {
992 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE: 963 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE:
993 ZFCP_LOG_INFO("CFDC of adapter %s saved on SE\n", 964 ZFCP_LOG_NORMAL("CFDC of adapter %s saved on SE\n",
994 zfcp_get_busid_by_adapter(adapter)); 965 zfcp_get_busid_by_adapter(adapter));
995 break; 966 break;
996 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2: 967 case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2:
997 ZFCP_LOG_INFO("CFDC of adapter %s has been copied " 968 ZFCP_LOG_NORMAL("CFDC of adapter %s has been copied "
998 "to the secondary SE\n", 969 "to the secondary SE\n",
999 zfcp_get_busid_by_adapter(adapter)); 970 zfcp_get_busid_by_adapter(adapter));
1000 break; 971 break;
1001 default: 972 default:
1002 ZFCP_LOG_INFO("CFDC of adapter %s has been hardened\n", 973 ZFCP_LOG_NORMAL("CFDC of adapter %s has been hardened\n",
1003 zfcp_get_busid_by_adapter(adapter)); 974 zfcp_get_busid_by_adapter(adapter));
1004 } 975 }
1005 break; 976 break;
1006 977
978 case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
979 debug_text_event(adapter->erp_dbf, 2, "unsol_features:");
980 ZFCP_LOG_INFO("List of supported features on adapter %s has "
981 "been changed from 0x%08X to 0x%08X\n",
982 zfcp_get_busid_by_adapter(adapter),
983 *(u32*) (status_buffer->payload + 4),
984 *(u32*) (status_buffer->payload));
985 adapter->adapter_features = *(u32*) status_buffer->payload;
986 break;
987
1007 default: 988 default:
1008 debug_text_event(adapter->erp_dbf, 0, "unsol_unknown:"); 989 ZFCP_LOG_NORMAL("warning: An unsolicited status packet of unknown "
1009 debug_exception(adapter->erp_dbf, 0,
1010 &status_buffer->status_type, sizeof (u32));
1011 ZFCP_LOG_NORMAL("bug: An unsolicited status packet of unknown "
1012 "type was received (debug info 0x%x)\n", 990 "type was received (debug info 0x%x)\n",
1013 status_buffer->status_type); 991 status_buffer->status_type);
1014 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n", 992 ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
@@ -1093,7 +1071,7 @@ zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
1093 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1071 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1094 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1072 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1095 1073
1096 fsf_req->data.abort_fcp_command.unit = unit; 1074 fsf_req->data = (unsigned long) unit;
1097 1075
1098 /* set handles of unit and its parent port in QTCB */ 1076 /* set handles of unit and its parent port in QTCB */
1099 fsf_req->qtcb->header.lun_handle = unit->handle; 1077 fsf_req->qtcb->header.lun_handle = unit->handle;
@@ -1139,7 +1117,7 @@ static int
1139zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req) 1117zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
1140{ 1118{
1141 int retval = -EINVAL; 1119 int retval = -EINVAL;
1142 struct zfcp_unit *unit = new_fsf_req->data.abort_fcp_command.unit; 1120 struct zfcp_unit *unit;
1143 unsigned char status_qual = 1121 unsigned char status_qual =
1144 new_fsf_req->qtcb->header.fsf_status_qual.word[0]; 1122 new_fsf_req->qtcb->header.fsf_status_qual.word[0];
1145 1123
@@ -1150,6 +1128,8 @@ zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
1150 goto skip_fsfstatus; 1128 goto skip_fsfstatus;
1151 } 1129 }
1152 1130
1131 unit = (struct zfcp_unit *) new_fsf_req->data;
1132
1153 /* evaluate FSF status in QTCB */ 1133 /* evaluate FSF status in QTCB */
1154 switch (new_fsf_req->qtcb->header.fsf_status) { 1134 switch (new_fsf_req->qtcb->header.fsf_status) {
1155 1135
@@ -1364,7 +1344,7 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1364 sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]); 1344 sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]);
1365 sbale[3].length = ct->resp[0].length; 1345 sbale[3].length = ct->resp[0].length;
1366 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; 1346 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1367 } else if (adapter->supported_features & 1347 } else if (adapter->adapter_features &
1368 FSF_FEATURE_ELS_CT_CHAINED_SBALS) { 1348 FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
1369 /* try to use chained SBALs */ 1349 /* try to use chained SBALs */
1370 bytes = zfcp_qdio_sbals_from_sg(fsf_req, 1350 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
@@ -1414,7 +1394,9 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1414 fsf_req->qtcb->header.port_handle = port->handle; 1394 fsf_req->qtcb->header.port_handle = port->handle;
1415 fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class; 1395 fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
1416 fsf_req->qtcb->bottom.support.timeout = ct->timeout; 1396 fsf_req->qtcb->bottom.support.timeout = ct->timeout;
1417 fsf_req->data.send_ct = ct; 1397 fsf_req->data = (unsigned long) ct;
1398
1399 zfcp_san_dbf_event_ct_request(fsf_req);
1418 1400
1419 /* start QDIO request for this FSF request */ 1401 /* start QDIO request for this FSF request */
1420 ret = zfcp_fsf_req_send(fsf_req, ct->timer); 1402 ret = zfcp_fsf_req_send(fsf_req, ct->timer);
@@ -1445,10 +1427,10 @@ zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1445 * zfcp_fsf_send_ct_handler - handler for Generic Service requests 1427 * zfcp_fsf_send_ct_handler - handler for Generic Service requests
1446 * @fsf_req: pointer to struct zfcp_fsf_req 1428 * @fsf_req: pointer to struct zfcp_fsf_req
1447 * 1429 *
1448 * Data specific for the Generic Service request is passed by 1430 * Data specific for the Generic Service request is passed using
1449 * fsf_req->data.send_ct 1431 * fsf_req->data. There we find the pointer to struct zfcp_send_ct.
1450 * Usually a specific handler for the request is called via 1432 * Usually a specific handler for the CT request is called which is
1451 * fsf_req->data.send_ct->handler at end of this function. 1433 * found in this structure.
1452 */ 1434 */
1453static int 1435static int
1454zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req) 1436zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
@@ -1462,7 +1444,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
1462 u16 subtable, rule, counter; 1444 u16 subtable, rule, counter;
1463 1445
1464 adapter = fsf_req->adapter; 1446 adapter = fsf_req->adapter;
1465 send_ct = fsf_req->data.send_ct; 1447 send_ct = (struct zfcp_send_ct *) fsf_req->data;
1466 port = send_ct->port; 1448 port = send_ct->port;
1467 header = &fsf_req->qtcb->header; 1449 header = &fsf_req->qtcb->header;
1468 bottom = &fsf_req->qtcb->bottom.support; 1450 bottom = &fsf_req->qtcb->bottom.support;
@@ -1474,6 +1456,7 @@ zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
1474 switch (header->fsf_status) { 1456 switch (header->fsf_status) {
1475 1457
1476 case FSF_GOOD: 1458 case FSF_GOOD:
1459 zfcp_san_dbf_event_ct_response(fsf_req);
1477 retval = 0; 1460 retval = 0;
1478 break; 1461 break;
1479 1462
@@ -1634,7 +1617,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1634{ 1617{
1635 volatile struct qdio_buffer_element *sbale; 1618 volatile struct qdio_buffer_element *sbale;
1636 struct zfcp_fsf_req *fsf_req; 1619 struct zfcp_fsf_req *fsf_req;
1637 fc_id_t d_id; 1620 u32 d_id;
1638 struct zfcp_adapter *adapter; 1621 struct zfcp_adapter *adapter;
1639 unsigned long lock_flags; 1622 unsigned long lock_flags;
1640 int bytes; 1623 int bytes;
@@ -1664,7 +1647,7 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1664 sbale[3].addr = zfcp_sg_to_address(&els->resp[0]); 1647 sbale[3].addr = zfcp_sg_to_address(&els->resp[0]);
1665 sbale[3].length = els->resp[0].length; 1648 sbale[3].length = els->resp[0].length;
1666 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; 1649 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1667 } else if (adapter->supported_features & 1650 } else if (adapter->adapter_features &
1668 FSF_FEATURE_ELS_CT_CHAINED_SBALS) { 1651 FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
1669 /* try to use chained SBALs */ 1652 /* try to use chained SBALs */
1670 bytes = zfcp_qdio_sbals_from_sg(fsf_req, 1653 bytes = zfcp_qdio_sbals_from_sg(fsf_req,
@@ -1714,10 +1697,12 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1714 fsf_req->qtcb->bottom.support.d_id = d_id; 1697 fsf_req->qtcb->bottom.support.d_id = d_id;
1715 fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class; 1698 fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
1716 fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT; 1699 fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
1717 fsf_req->data.send_els = els; 1700 fsf_req->data = (unsigned long) els;
1718 1701
1719 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); 1702 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
1720 1703
1704 zfcp_san_dbf_event_els_request(fsf_req);
1705
1721 /* start QDIO request for this FSF request */ 1706 /* start QDIO request for this FSF request */
1722 ret = zfcp_fsf_req_send(fsf_req, els->timer); 1707 ret = zfcp_fsf_req_send(fsf_req, els->timer);
1723 if (ret) { 1708 if (ret) {
@@ -1746,23 +1731,23 @@ zfcp_fsf_send_els(struct zfcp_send_els *els)
1746 * zfcp_fsf_send_els_handler - handler for ELS commands 1731 * zfcp_fsf_send_els_handler - handler for ELS commands
1747 * @fsf_req: pointer to struct zfcp_fsf_req 1732 * @fsf_req: pointer to struct zfcp_fsf_req
1748 * 1733 *
1749 * Data specific for the ELS command is passed by 1734 * Data specific for the ELS command is passed using
1750 * fsf_req->data.send_els 1735 * fsf_req->data. There we find the pointer to struct zfcp_send_els.
1751 * Usually a specific handler for the command is called via 1736 * Usually a specific handler for the ELS command is called which is
1752 * fsf_req->data.send_els->handler at end of this function. 1737 * found in this structure.
1753 */ 1738 */
1754static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req) 1739static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
1755{ 1740{
1756 struct zfcp_adapter *adapter; 1741 struct zfcp_adapter *adapter;
1757 struct zfcp_port *port; 1742 struct zfcp_port *port;
1758 fc_id_t d_id; 1743 u32 d_id;
1759 struct fsf_qtcb_header *header; 1744 struct fsf_qtcb_header *header;
1760 struct fsf_qtcb_bottom_support *bottom; 1745 struct fsf_qtcb_bottom_support *bottom;
1761 struct zfcp_send_els *send_els; 1746 struct zfcp_send_els *send_els;
1762 int retval = -EINVAL; 1747 int retval = -EINVAL;
1763 u16 subtable, rule, counter; 1748 u16 subtable, rule, counter;
1764 1749
1765 send_els = fsf_req->data.send_els; 1750 send_els = (struct zfcp_send_els *) fsf_req->data;
1766 adapter = send_els->adapter; 1751 adapter = send_els->adapter;
1767 port = send_els->port; 1752 port = send_els->port;
1768 d_id = send_els->d_id; 1753 d_id = send_els->d_id;
@@ -1775,6 +1760,7 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
1775 switch (header->fsf_status) { 1760 switch (header->fsf_status) {
1776 1761
1777 case FSF_GOOD: 1762 case FSF_GOOD:
1763 zfcp_san_dbf_event_els_response(fsf_req);
1778 retval = 0; 1764 retval = 0;
1779 break; 1765 break;
1780 1766
@@ -1954,7 +1940,9 @@ zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1954 1940
1955 erp_action->fsf_req->erp_action = erp_action; 1941 erp_action->fsf_req->erp_action = erp_action;
1956 erp_action->fsf_req->qtcb->bottom.config.feature_selection = 1942 erp_action->fsf_req->qtcb->bottom.config.feature_selection =
1957 (FSF_FEATURE_CFDC | FSF_FEATURE_LUN_SHARING); 1943 FSF_FEATURE_CFDC |
1944 FSF_FEATURE_LUN_SHARING |
1945 FSF_FEATURE_UPDATE_ALERT;
1958 1946
1959 /* start QDIO request for this FSF request */ 1947 /* start QDIO request for this FSF request */
1960 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer); 1948 retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
@@ -1990,29 +1978,36 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
1990{ 1978{
1991 struct fsf_qtcb_bottom_config *bottom; 1979 struct fsf_qtcb_bottom_config *bottom;
1992 struct zfcp_adapter *adapter = fsf_req->adapter; 1980 struct zfcp_adapter *adapter = fsf_req->adapter;
1981 struct Scsi_Host *shost = adapter->scsi_host;
1993 1982
1994 bottom = &fsf_req->qtcb->bottom.config; 1983 bottom = &fsf_req->qtcb->bottom.config;
1995 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n", 1984 ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
1996 bottom->low_qtcb_version, bottom->high_qtcb_version); 1985 bottom->low_qtcb_version, bottom->high_qtcb_version);
1997 adapter->fsf_lic_version = bottom->lic_version; 1986 adapter->fsf_lic_version = bottom->lic_version;
1998 adapter->supported_features = bottom->supported_features; 1987 adapter->adapter_features = bottom->adapter_features;
1988 adapter->connection_features = bottom->connection_features;
1999 adapter->peer_wwpn = 0; 1989 adapter->peer_wwpn = 0;
2000 adapter->peer_wwnn = 0; 1990 adapter->peer_wwnn = 0;
2001 adapter->peer_d_id = 0; 1991 adapter->peer_d_id = 0;
2002 1992
2003 if (xchg_ok) { 1993 if (xchg_ok) {
2004 adapter->wwnn = bottom->nport_serv_param.wwnn; 1994 fc_host_node_name(shost) = bottom->nport_serv_param.wwnn;
2005 adapter->wwpn = bottom->nport_serv_param.wwpn; 1995 fc_host_port_name(shost) = bottom->nport_serv_param.wwpn;
2006 adapter->s_id = bottom->s_id & ZFCP_DID_MASK; 1996 fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
1997 fc_host_speed(shost) = bottom->fc_link_speed;
1998 fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
2007 adapter->fc_topology = bottom->fc_topology; 1999 adapter->fc_topology = bottom->fc_topology;
2008 adapter->fc_link_speed = bottom->fc_link_speed;
2009 adapter->hydra_version = bottom->adapter_type; 2000 adapter->hydra_version = bottom->adapter_type;
2001 if (adapter->physical_wwpn == 0)
2002 adapter->physical_wwpn = fc_host_port_name(shost);
2003 if (adapter->physical_s_id == 0)
2004 adapter->physical_s_id = fc_host_port_id(shost);
2010 } else { 2005 } else {
2011 adapter->wwnn = 0; 2006 fc_host_node_name(shost) = 0;
2012 adapter->wwpn = 0; 2007 fc_host_port_name(shost) = 0;
2013 adapter->s_id = 0; 2008 fc_host_port_id(shost) = 0;
2009 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
2014 adapter->fc_topology = 0; 2010 adapter->fc_topology = 0;
2015 adapter->fc_link_speed = 0;
2016 adapter->hydra_version = 0; 2011 adapter->hydra_version = 0;
2017 } 2012 }
2018 2013
@@ -2022,26 +2017,28 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
2022 adapter->peer_wwnn = bottom->plogi_payload.wwnn; 2017 adapter->peer_wwnn = bottom->plogi_payload.wwnn;
2023 } 2018 }
2024 2019
2025 if(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT){ 2020 if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
2026 adapter->hardware_version = bottom->hardware_version; 2021 adapter->hardware_version = bottom->hardware_version;
2027 memcpy(adapter->serial_number, bottom->serial_number, 17); 2022 memcpy(fc_host_serial_number(shost), bottom->serial_number,
2028 EBCASC(adapter->serial_number, sizeof(adapter->serial_number)); 2023 min(FC_SERIAL_NUMBER_SIZE, 17));
2024 EBCASC(fc_host_serial_number(shost),
2025 min(FC_SERIAL_NUMBER_SIZE, 17));
2029 } 2026 }
2030 2027
2031 ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n" 2028 ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n"
2032 "WWNN 0x%016Lx, " 2029 "WWNN 0x%016Lx, "
2033 "WWPN 0x%016Lx, " 2030 "WWPN 0x%016Lx, "
2034 "S_ID 0x%08x,\n" 2031 "S_ID 0x%08x,\n"
2035 "adapter version 0x%x, " 2032 "adapter version 0x%x, "
2036 "LIC version 0x%x, " 2033 "LIC version 0x%x, "
2037 "FC link speed %d Gb/s\n", 2034 "FC link speed %d Gb/s\n",
2038 zfcp_get_busid_by_adapter(adapter), 2035 zfcp_get_busid_by_adapter(adapter),
2039 adapter->wwnn, 2036 (wwn_t) fc_host_node_name(shost),
2040 adapter->wwpn, 2037 (wwn_t) fc_host_port_name(shost),
2041 (unsigned int) adapter->s_id, 2038 fc_host_port_id(shost),
2042 adapter->hydra_version, 2039 adapter->hydra_version,
2043 adapter->fsf_lic_version, 2040 adapter->fsf_lic_version,
2044 adapter->fc_link_speed); 2041 fc_host_speed(shost));
2045 if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) { 2042 if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) {
2046 ZFCP_LOG_NORMAL("error: the adapter %s " 2043 ZFCP_LOG_NORMAL("error: the adapter %s "
2047 "only supports newer control block " 2044 "only supports newer control block "
@@ -2062,7 +2059,6 @@ zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
2062 zfcp_erp_adapter_shutdown(adapter, 0); 2059 zfcp_erp_adapter_shutdown(adapter, 0);
2063 return -EIO; 2060 return -EIO;
2064 } 2061 }
2065 zfcp_set_fc_host_attrs(adapter);
2066 return 0; 2062 return 0;
2067} 2063}
2068 2064
@@ -2078,11 +2074,12 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2078{ 2074{
2079 struct fsf_qtcb_bottom_config *bottom; 2075 struct fsf_qtcb_bottom_config *bottom;
2080 struct zfcp_adapter *adapter = fsf_req->adapter; 2076 struct zfcp_adapter *adapter = fsf_req->adapter;
2077 struct fsf_qtcb *qtcb = fsf_req->qtcb;
2081 2078
2082 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) 2079 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
2083 return -EIO; 2080 return -EIO;
2084 2081
2085 switch (fsf_req->qtcb->header.fsf_status) { 2082 switch (qtcb->header.fsf_status) {
2086 2083
2087 case FSF_GOOD: 2084 case FSF_GOOD:
2088 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1)) 2085 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
@@ -2112,7 +2109,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2112 zfcp_erp_adapter_shutdown(adapter, 0); 2109 zfcp_erp_adapter_shutdown(adapter, 0);
2113 return -EIO; 2110 return -EIO;
2114 case FSF_TOPO_FABRIC: 2111 case FSF_TOPO_FABRIC:
2115 ZFCP_LOG_INFO("Switched fabric fibrechannel " 2112 ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
2116 "network detected at adapter %s.\n", 2113 "network detected at adapter %s.\n",
2117 zfcp_get_busid_by_adapter(adapter)); 2114 zfcp_get_busid_by_adapter(adapter));
2118 break; 2115 break;
@@ -2130,7 +2127,7 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2130 zfcp_erp_adapter_shutdown(adapter, 0); 2127 zfcp_erp_adapter_shutdown(adapter, 0);
2131 return -EIO; 2128 return -EIO;
2132 } 2129 }
2133 bottom = &fsf_req->qtcb->bottom.config; 2130 bottom = &qtcb->bottom.config;
2134 if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) { 2131 if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
2135 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) " 2132 ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
2136 "allowed by the adapter %s " 2133 "allowed by the adapter %s "
@@ -2155,12 +2152,10 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2155 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0)) 2152 if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0))
2156 return -EIO; 2153 return -EIO;
2157 2154
2158 ZFCP_LOG_INFO("Local link to adapter %s is down\n", 2155 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, &adapter->status);
2159 zfcp_get_busid_by_adapter(adapter)); 2156
2160 atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK | 2157 zfcp_fsf_link_down_info_eval(adapter,
2161 ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2158 &qtcb->header.fsf_status_qual.link_down_info);
2162 &adapter->status);
2163 zfcp_erp_adapter_failed(adapter);
2164 break; 2159 break;
2165 default: 2160 default:
2166 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng"); 2161 debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng");
@@ -2174,11 +2169,13 @@ zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
2174 2169
2175/** 2170/**
2176 * zfcp_fsf_exchange_port_data - request information about local port 2171 * zfcp_fsf_exchange_port_data - request information about local port
2172 * @erp_action: ERP action for the adapter for which port data is requested
2177 * @adapter: for which port data is requested 2173 * @adapter: for which port data is requested
2178 * @data: response to exchange port data request 2174 * @data: response to exchange port data request
2179 */ 2175 */
2180int 2176int
2181zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter, 2177zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2178 struct zfcp_adapter *adapter,
2182 struct fsf_qtcb_bottom_port *data) 2179 struct fsf_qtcb_bottom_port *data)
2183{ 2180{
2184 volatile struct qdio_buffer_element *sbale; 2181 volatile struct qdio_buffer_element *sbale;
@@ -2187,7 +2184,7 @@ zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter,
2187 struct zfcp_fsf_req *fsf_req; 2184 struct zfcp_fsf_req *fsf_req;
2188 struct timer_list *timer; 2185 struct timer_list *timer;
2189 2186
2190 if(!(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT)){ 2187 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) {
2191 ZFCP_LOG_INFO("error: exchange port data " 2188 ZFCP_LOG_INFO("error: exchange port data "
2192 "command not supported by adapter %s\n", 2189 "command not supported by adapter %s\n",
2193 zfcp_get_busid_by_adapter(adapter)); 2190 zfcp_get_busid_by_adapter(adapter));
@@ -2211,12 +2208,18 @@ zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter,
2211 goto out; 2208 goto out;
2212 } 2209 }
2213 2210
2211 if (erp_action) {
2212 erp_action->fsf_req = fsf_req;
2213 fsf_req->erp_action = erp_action;
2214 }
2215
2216 if (data)
2217 fsf_req->data = (unsigned long) data;
2218
2214 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); 2219 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2215 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2220 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2216 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2221 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2217 2222
2218 fsf_req->data.port_data = data;
2219
2220 init_timer(timer); 2223 init_timer(timer);
2221 timer->function = zfcp_fsf_request_timeout_handler; 2224 timer->function = zfcp_fsf_request_timeout_handler;
2222 timer->data = (unsigned long) adapter; 2225 timer->data = (unsigned long) adapter;
@@ -2228,6 +2231,8 @@ zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter,
2228 "command on the adapter %s\n", 2231 "command on the adapter %s\n",
2229 zfcp_get_busid_by_adapter(adapter)); 2232 zfcp_get_busid_by_adapter(adapter));
2230 zfcp_fsf_req_free(fsf_req); 2233 zfcp_fsf_req_free(fsf_req);
2234 if (erp_action)
2235 erp_action->fsf_req = NULL;
2231 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2236 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2232 lock_flags); 2237 lock_flags);
2233 goto out; 2238 goto out;
@@ -2256,21 +2261,42 @@ zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter,
2256static void 2261static void
2257zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req) 2262zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
2258{ 2263{
2259 struct fsf_qtcb_bottom_port *bottom; 2264 struct zfcp_adapter *adapter = fsf_req->adapter;
2260 struct fsf_qtcb_bottom_port *data = fsf_req->data.port_data; 2265 struct Scsi_Host *shost = adapter->scsi_host;
2266 struct fsf_qtcb *qtcb = fsf_req->qtcb;
2267 struct fsf_qtcb_bottom_port *bottom, *data;
2261 2268
2262 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) 2269 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
2263 return; 2270 return;
2264 2271
2265 switch (fsf_req->qtcb->header.fsf_status) { 2272 switch (qtcb->header.fsf_status) {
2266 case FSF_GOOD: 2273 case FSF_GOOD:
2267 bottom = &fsf_req->qtcb->bottom.port; 2274 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2268 memcpy(data, bottom, sizeof(*data)); 2275
2276 bottom = &qtcb->bottom.port;
2277 data = (struct fsf_qtcb_bottom_port*) fsf_req->data;
2278 if (data)
2279 memcpy(data, bottom, sizeof(struct fsf_qtcb_bottom_port));
2280 if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) {
2281 adapter->physical_wwpn = bottom->wwpn;
2282 adapter->physical_s_id = bottom->fc_port_id;
2283 } else {
2284 adapter->physical_wwpn = fc_host_port_name(shost);
2285 adapter->physical_s_id = fc_host_port_id(shost);
2286 }
2287 fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
2288 break;
2289
2290 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
2291 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2292
2293 zfcp_fsf_link_down_info_eval(adapter,
2294 &qtcb->header.fsf_status_qual.link_down_info);
2269 break; 2295 break;
2270 2296
2271 default: 2297 default:
2272 debug_text_event(fsf_req->adapter->erp_dbf, 0, "xchg-port-ng"); 2298 debug_text_event(adapter->erp_dbf, 0, "xchg-port-ng");
2273 debug_event(fsf_req->adapter->erp_dbf, 0, 2299 debug_event(adapter->erp_dbf, 0,
2274 &fsf_req->qtcb->header.fsf_status, sizeof(u32)); 2300 &fsf_req->qtcb->header.fsf_status, sizeof(u32));
2275 } 2301 }
2276} 2302}
@@ -2312,7 +2338,7 @@ zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
2312 2338
2313 erp_action->fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id; 2339 erp_action->fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id;
2314 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status); 2340 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status);
2315 erp_action->fsf_req->data.open_port.port = erp_action->port; 2341 erp_action->fsf_req->data = (unsigned long) erp_action->port;
2316 erp_action->fsf_req->erp_action = erp_action; 2342 erp_action->fsf_req->erp_action = erp_action;
2317 2343
2318 /* start QDIO request for this FSF request */ 2344 /* start QDIO request for this FSF request */
@@ -2353,7 +2379,7 @@ zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
2353 struct fsf_qtcb_header *header; 2379 struct fsf_qtcb_header *header;
2354 u16 subtable, rule, counter; 2380 u16 subtable, rule, counter;
2355 2381
2356 port = fsf_req->data.open_port.port; 2382 port = (struct zfcp_port *) fsf_req->data;
2357 header = &fsf_req->qtcb->header; 2383 header = &fsf_req->qtcb->header;
2358 2384
2359 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 2385 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
@@ -2566,7 +2592,7 @@ zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
2566 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2592 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2567 2593
2568 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status); 2594 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status);
2569 erp_action->fsf_req->data.close_port.port = erp_action->port; 2595 erp_action->fsf_req->data = (unsigned long) erp_action->port;
2570 erp_action->fsf_req->erp_action = erp_action; 2596 erp_action->fsf_req->erp_action = erp_action;
2571 erp_action->fsf_req->qtcb->header.port_handle = 2597 erp_action->fsf_req->qtcb->header.port_handle =
2572 erp_action->port->handle; 2598 erp_action->port->handle;
@@ -2606,7 +2632,7 @@ zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
2606 int retval = -EINVAL; 2632 int retval = -EINVAL;
2607 struct zfcp_port *port; 2633 struct zfcp_port *port;
2608 2634
2609 port = fsf_req->data.close_port.port; 2635 port = (struct zfcp_port *) fsf_req->data;
2610 2636
2611 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 2637 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
2612 /* don't change port status in our bookkeeping */ 2638 /* don't change port status in our bookkeeping */
@@ -2703,8 +2729,8 @@ zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
2703 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, 2729 atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING,
2704 &erp_action->port->status); 2730 &erp_action->port->status);
2705 /* save a pointer to this port */ 2731 /* save a pointer to this port */
2706 erp_action->fsf_req->data.close_physical_port.port = erp_action->port; 2732 erp_action->fsf_req->data = (unsigned long) erp_action->port;
2707 /* port to be closeed */ 2733 /* port to be closed */
2708 erp_action->fsf_req->qtcb->header.port_handle = 2734 erp_action->fsf_req->qtcb->header.port_handle =
2709 erp_action->port->handle; 2735 erp_action->port->handle;
2710 erp_action->fsf_req->erp_action = erp_action; 2736 erp_action->fsf_req->erp_action = erp_action;
@@ -2747,7 +2773,7 @@ zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
2747 struct fsf_qtcb_header *header; 2773 struct fsf_qtcb_header *header;
2748 u16 subtable, rule, counter; 2774 u16 subtable, rule, counter;
2749 2775
2750 port = fsf_req->data.close_physical_port.port; 2776 port = (struct zfcp_port *) fsf_req->data;
2751 header = &fsf_req->qtcb->header; 2777 header = &fsf_req->qtcb->header;
2752 2778
2753 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 2779 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
@@ -2908,10 +2934,11 @@ zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
2908 erp_action->port->handle; 2934 erp_action->port->handle;
2909 erp_action->fsf_req->qtcb->bottom.support.fcp_lun = 2935 erp_action->fsf_req->qtcb->bottom.support.fcp_lun =
2910 erp_action->unit->fcp_lun; 2936 erp_action->unit->fcp_lun;
2937 if (!(erp_action->adapter->connection_features & FSF_FEATURE_NPIV_MODE))
2911 erp_action->fsf_req->qtcb->bottom.support.option = 2938 erp_action->fsf_req->qtcb->bottom.support.option =
2912 FSF_OPEN_LUN_SUPPRESS_BOXING; 2939 FSF_OPEN_LUN_SUPPRESS_BOXING;
2913 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status); 2940 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
2914 erp_action->fsf_req->data.open_unit.unit = erp_action->unit; 2941 erp_action->fsf_req->data = (unsigned long) erp_action->unit;
2915 erp_action->fsf_req->erp_action = erp_action; 2942 erp_action->fsf_req->erp_action = erp_action;
2916 2943
2917 /* start QDIO request for this FSF request */ 2944 /* start QDIO request for this FSF request */
@@ -2955,9 +2982,9 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
2955 struct fsf_qtcb_bottom_support *bottom; 2982 struct fsf_qtcb_bottom_support *bottom;
2956 struct fsf_queue_designator *queue_designator; 2983 struct fsf_queue_designator *queue_designator;
2957 u16 subtable, rule, counter; 2984 u16 subtable, rule, counter;
2958 u32 allowed, exclusive, readwrite; 2985 int exclusive, readwrite;
2959 2986
2960 unit = fsf_req->data.open_unit.unit; 2987 unit = (struct zfcp_unit *) fsf_req->data;
2961 2988
2962 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 2989 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
2963 /* don't change unit status in our bookkeeping */ 2990 /* don't change unit status in our bookkeeping */
@@ -2969,10 +2996,6 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
2969 bottom = &fsf_req->qtcb->bottom.support; 2996 bottom = &fsf_req->qtcb->bottom.support;
2970 queue_designator = &header->fsf_status_qual.fsf_queue_designator; 2997 queue_designator = &header->fsf_status_qual.fsf_queue_designator;
2971 2998
2972 allowed = bottom->lun_access_info & FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED;
2973 exclusive = bottom->lun_access_info & FSF_UNIT_ACCESS_EXCLUSIVE;
2974 readwrite = bottom->lun_access_info & FSF_UNIT_ACCESS_OUTBOUND_TRANSFER;
2975
2976 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | 2999 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
2977 ZFCP_STATUS_UNIT_SHARED | 3000 ZFCP_STATUS_UNIT_SHARED |
2978 ZFCP_STATUS_UNIT_READONLY, 3001 ZFCP_STATUS_UNIT_READONLY,
@@ -3146,10 +3169,15 @@ zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
3146 unit->handle); 3169 unit->handle);
3147 /* mark unit as open */ 3170 /* mark unit as open */
3148 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); 3171 atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
3149 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | 3172
3150 ZFCP_STATUS_COMMON_ACCESS_BOXED, 3173 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) &&
3151 &unit->status); 3174 (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) &&
3152 if (adapter->supported_features & FSF_FEATURE_LUN_SHARING){ 3175 (adapter->ccw_device->id.dev_model != ZFCP_DEVICE_MODEL_PRIV)) {
3176 exclusive = (bottom->lun_access_info &
3177 FSF_UNIT_ACCESS_EXCLUSIVE);
3178 readwrite = (bottom->lun_access_info &
3179 FSF_UNIT_ACCESS_OUTBOUND_TRANSFER);
3180
3153 if (!exclusive) 3181 if (!exclusive)
3154 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED, 3182 atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,
3155 &unit->status); 3183 &unit->status);
@@ -3242,7 +3270,7 @@ zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
3242 erp_action->port->handle; 3270 erp_action->port->handle;
3243 erp_action->fsf_req->qtcb->header.lun_handle = erp_action->unit->handle; 3271 erp_action->fsf_req->qtcb->header.lun_handle = erp_action->unit->handle;
3244 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status); 3272 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status);
3245 erp_action->fsf_req->data.close_unit.unit = erp_action->unit; 3273 erp_action->fsf_req->data = (unsigned long) erp_action->unit;
3246 erp_action->fsf_req->erp_action = erp_action; 3274 erp_action->fsf_req->erp_action = erp_action;
3247 3275
3248 /* start QDIO request for this FSF request */ 3276 /* start QDIO request for this FSF request */
@@ -3281,7 +3309,7 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
3281 int retval = -EINVAL; 3309 int retval = -EINVAL;
3282 struct zfcp_unit *unit; 3310 struct zfcp_unit *unit;
3283 3311
3284 unit = fsf_req->data.close_unit.unit; /* restore unit */ 3312 unit = (struct zfcp_unit *) fsf_req->data;
3285 3313
3286 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 3314 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
3287 /* don't change unit status in our bookkeeping */ 3315 /* don't change unit status in our bookkeeping */
@@ -3305,9 +3333,6 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
3305 debug_text_event(fsf_req->adapter->erp_dbf, 1, 3333 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3306 "fsf_s_phand_nv"); 3334 "fsf_s_phand_nv");
3307 zfcp_erp_adapter_reopen(unit->port->adapter, 0); 3335 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
3308 zfcp_cmd_dbf_event_fsf("porthinv", fsf_req,
3309 &fsf_req->qtcb->header.fsf_status_qual,
3310 sizeof (union fsf_status_qual));
3311 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3336 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3312 break; 3337 break;
3313 3338
@@ -3326,9 +3351,6 @@ zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
3326 debug_text_event(fsf_req->adapter->erp_dbf, 1, 3351 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3327 "fsf_s_lhand_nv"); 3352 "fsf_s_lhand_nv");
3328 zfcp_erp_port_reopen(unit->port, 0); 3353 zfcp_erp_port_reopen(unit->port, 0);
3329 zfcp_cmd_dbf_event_fsf("lunhinv", fsf_req,
3330 &fsf_req->qtcb->header.fsf_status_qual,
3331 sizeof (union fsf_status_qual));
3332 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3354 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3333 break; 3355 break;
3334 3356
@@ -3436,21 +3458,14 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3436 goto failed_req_create; 3458 goto failed_req_create;
3437 } 3459 }
3438 3460
3439 /* 3461 zfcp_unit_get(unit);
3440 * associate FSF request with SCSI request 3462 fsf_req->unit = unit;
3441 * (need this for look up on abort)
3442 */
3443 fsf_req->data.send_fcp_command_task.fsf_req = fsf_req;
3444 scsi_cmnd->host_scribble = (char *) &(fsf_req->data);
3445 3463
3446 /* 3464 /* associate FSF request with SCSI request (for look up on abort) */
3447 * associate SCSI command with FSF request 3465 scsi_cmnd->host_scribble = (char *) fsf_req;
3448 * (need this for look up on normal command completion) 3466
3449 */ 3467 /* associate SCSI command with FSF request */
3450 fsf_req->data.send_fcp_command_task.scsi_cmnd = scsi_cmnd; 3468 fsf_req->data = (unsigned long) scsi_cmnd;
3451 fsf_req->data.send_fcp_command_task.start_jiffies = jiffies;
3452 fsf_req->data.send_fcp_command_task.unit = unit;
3453 ZFCP_LOG_DEBUG("unit=%p, fcp_lun=0x%016Lx\n", unit, unit->fcp_lun);
3454 3469
3455 /* set handles of unit and its parent port in QTCB */ 3470 /* set handles of unit and its parent port in QTCB */
3456 fsf_req->qtcb->header.lun_handle = unit->handle; 3471 fsf_req->qtcb->header.lun_handle = unit->handle;
@@ -3584,6 +3599,7 @@ zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
3584 send_failed: 3599 send_failed:
3585 no_fit: 3600 no_fit:
3586 failed_scsi_cmnd: 3601 failed_scsi_cmnd:
3602 zfcp_unit_put(unit);
3587 zfcp_fsf_req_free(fsf_req); 3603 zfcp_fsf_req_free(fsf_req);
3588 fsf_req = NULL; 3604 fsf_req = NULL;
3589 scsi_cmnd->host_scribble = NULL; 3605 scsi_cmnd->host_scribble = NULL;
@@ -3640,7 +3656,7 @@ zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
3640 * hold a pointer to the unit being target of this 3656 * hold a pointer to the unit being target of this
3641 * task management request 3657 * task management request
3642 */ 3658 */
3643 fsf_req->data.send_fcp_command_task_management.unit = unit; 3659 fsf_req->data = (unsigned long) unit;
3644 3660
3645 /* set FSF related fields in QTCB */ 3661 /* set FSF related fields in QTCB */
3646 fsf_req->qtcb->header.lun_handle = unit->handle; 3662 fsf_req->qtcb->header.lun_handle = unit->handle;
@@ -3706,9 +3722,9 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3706 header = &fsf_req->qtcb->header; 3722 header = &fsf_req->qtcb->header;
3707 3723
3708 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)) 3724 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
3709 unit = fsf_req->data.send_fcp_command_task_management.unit; 3725 unit = (struct zfcp_unit *) fsf_req->data;
3710 else 3726 else
3711 unit = fsf_req->data.send_fcp_command_task.unit; 3727 unit = fsf_req->unit;
3712 3728
3713 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) { 3729 if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
3714 /* go directly to calls of special handlers */ 3730 /* go directly to calls of special handlers */
@@ -3765,10 +3781,6 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3765 debug_text_event(fsf_req->adapter->erp_dbf, 1, 3781 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3766 "fsf_s_hand_mis"); 3782 "fsf_s_hand_mis");
3767 zfcp_erp_adapter_reopen(unit->port->adapter, 0); 3783 zfcp_erp_adapter_reopen(unit->port->adapter, 0);
3768 zfcp_cmd_dbf_event_fsf("handmism",
3769 fsf_req,
3770 &header->fsf_status_qual,
3771 sizeof (union fsf_status_qual));
3772 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3784 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3773 break; 3785 break;
3774 3786
@@ -3789,10 +3801,6 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3789 debug_text_exception(fsf_req->adapter->erp_dbf, 0, 3801 debug_text_exception(fsf_req->adapter->erp_dbf, 0,
3790 "fsf_s_class_nsup"); 3802 "fsf_s_class_nsup");
3791 zfcp_erp_adapter_shutdown(unit->port->adapter, 0); 3803 zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
3792 zfcp_cmd_dbf_event_fsf("unsclass",
3793 fsf_req,
3794 &header->fsf_status_qual,
3795 sizeof (union fsf_status_qual));
3796 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3804 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3797 break; 3805 break;
3798 3806
@@ -3811,10 +3819,6 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3811 debug_text_event(fsf_req->adapter->erp_dbf, 1, 3819 debug_text_event(fsf_req->adapter->erp_dbf, 1,
3812 "fsf_s_fcp_lun_nv"); 3820 "fsf_s_fcp_lun_nv");
3813 zfcp_erp_port_reopen(unit->port, 0); 3821 zfcp_erp_port_reopen(unit->port, 0);
3814 zfcp_cmd_dbf_event_fsf("fluninv",
3815 fsf_req,
3816 &header->fsf_status_qual,
3817 sizeof (union fsf_status_qual));
3818 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3822 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3819 break; 3823 break;
3820 3824
@@ -3853,10 +3857,6 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3853 debug_text_event(fsf_req->adapter->erp_dbf, 0, 3857 debug_text_event(fsf_req->adapter->erp_dbf, 0,
3854 "fsf_s_dir_ind_nv"); 3858 "fsf_s_dir_ind_nv");
3855 zfcp_erp_adapter_shutdown(unit->port->adapter, 0); 3859 zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
3856 zfcp_cmd_dbf_event_fsf("dirinv",
3857 fsf_req,
3858 &header->fsf_status_qual,
3859 sizeof (union fsf_status_qual));
3860 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3860 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3861 break; 3861 break;
3862 3862
@@ -3872,10 +3872,6 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3872 debug_text_event(fsf_req->adapter->erp_dbf, 0, 3872 debug_text_event(fsf_req->adapter->erp_dbf, 0,
3873 "fsf_s_cmd_len_nv"); 3873 "fsf_s_cmd_len_nv");
3874 zfcp_erp_adapter_shutdown(unit->port->adapter, 0); 3874 zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
3875 zfcp_cmd_dbf_event_fsf("cleninv",
3876 fsf_req,
3877 &header->fsf_status_qual,
3878 sizeof (union fsf_status_qual));
3879 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR; 3875 fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
3880 break; 3876 break;
3881 3877
@@ -3947,6 +3943,8 @@ zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
3947 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req); 3943 zfcp_fsf_send_fcp_command_task_management_handler(fsf_req);
3948 } else { 3944 } else {
3949 retval = zfcp_fsf_send_fcp_command_task_handler(fsf_req); 3945 retval = zfcp_fsf_send_fcp_command_task_handler(fsf_req);
3946 fsf_req->unit = NULL;
3947 zfcp_unit_put(unit);
3950 } 3948 }
3951 return retval; 3949 return retval;
3952} 3950}
@@ -3970,10 +3968,10 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
3970 u32 sns_len; 3968 u32 sns_len;
3971 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu); 3969 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
3972 unsigned long flags; 3970 unsigned long flags;
3973 struct zfcp_unit *unit = fsf_req->data.send_fcp_command_task.unit; 3971 struct zfcp_unit *unit = fsf_req->unit;
3974 3972
3975 read_lock_irqsave(&fsf_req->adapter->abort_lock, flags); 3973 read_lock_irqsave(&fsf_req->adapter->abort_lock, flags);
3976 scpnt = fsf_req->data.send_fcp_command_task.scsi_cmnd; 3974 scpnt = (struct scsi_cmnd *) fsf_req->data;
3977 if (unlikely(!scpnt)) { 3975 if (unlikely(!scpnt)) {
3978 ZFCP_LOG_DEBUG 3976 ZFCP_LOG_DEBUG
3979 ("Command with fsf_req %p is not associated to " 3977 ("Command with fsf_req %p is not associated to "
@@ -4043,7 +4041,6 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4043 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, 4041 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4044 (char *) &fsf_req->qtcb-> 4042 (char *) &fsf_req->qtcb->
4045 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); 4043 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4046 zfcp_cmd_dbf_event_fsf("clenmis", fsf_req, NULL, 0);
4047 set_host_byte(&scpnt->result, DID_ERROR); 4044 set_host_byte(&scpnt->result, DID_ERROR);
4048 goto skip_fsfstatus; 4045 goto skip_fsfstatus;
4049 case RSP_CODE_FIELD_INVALID: 4046 case RSP_CODE_FIELD_INVALID:
@@ -4062,7 +4059,6 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4062 (char *) &fsf_req->qtcb-> 4059 (char *) &fsf_req->qtcb->
4063 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); 4060 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4064 set_host_byte(&scpnt->result, DID_ERROR); 4061 set_host_byte(&scpnt->result, DID_ERROR);
4065 zfcp_cmd_dbf_event_fsf("codeinv", fsf_req, NULL, 0);
4066 goto skip_fsfstatus; 4062 goto skip_fsfstatus;
4067 case RSP_CODE_RO_MISMATCH: 4063 case RSP_CODE_RO_MISMATCH:
4068 /* hardware bug */ 4064 /* hardware bug */
@@ -4079,7 +4075,6 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4079 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, 4075 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4080 (char *) &fsf_req->qtcb-> 4076 (char *) &fsf_req->qtcb->
4081 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); 4077 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4082 zfcp_cmd_dbf_event_fsf("codemism", fsf_req, NULL, 0);
4083 set_host_byte(&scpnt->result, DID_ERROR); 4078 set_host_byte(&scpnt->result, DID_ERROR);
4084 goto skip_fsfstatus; 4079 goto skip_fsfstatus;
4085 default: 4080 default:
@@ -4096,7 +4091,6 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4096 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG, 4091 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
4097 (char *) &fsf_req->qtcb-> 4092 (char *) &fsf_req->qtcb->
4098 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE); 4093 bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
4099 zfcp_cmd_dbf_event_fsf("undeffcp", fsf_req, NULL, 0);
4100 set_host_byte(&scpnt->result, DID_ERROR); 4094 set_host_byte(&scpnt->result, DID_ERROR);
4101 goto skip_fsfstatus; 4095 goto skip_fsfstatus;
4102 } 4096 }
@@ -4158,19 +4152,17 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4158 skip_fsfstatus: 4152 skip_fsfstatus:
4159 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result); 4153 ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result);
4160 4154
4161 zfcp_cmd_dbf_event_scsi("response", scpnt); 4155 if (scpnt->result != 0)
4156 zfcp_scsi_dbf_event_result("erro", 3, fsf_req->adapter, scpnt);
4157 else if (scpnt->retries > 0)
4158 zfcp_scsi_dbf_event_result("retr", 4, fsf_req->adapter, scpnt);
4159 else
4160 zfcp_scsi_dbf_event_result("norm", 6, fsf_req->adapter, scpnt);
4162 4161
4163 /* cleanup pointer (need this especially for abort) */ 4162 /* cleanup pointer (need this especially for abort) */
4164 scpnt->host_scribble = NULL; 4163 scpnt->host_scribble = NULL;
4165 4164
4166 /*
4167 * NOTE:
4168 * according to the outcome of a discussion on linux-scsi we
4169 * don't need to grab the io_request_lock here since we use
4170 * the new eh
4171 */
4172 /* always call back */ 4165 /* always call back */
4173
4174 (scpnt->scsi_done) (scpnt); 4166 (scpnt->scsi_done) (scpnt);
4175 4167
4176 /* 4168 /*
@@ -4198,8 +4190,7 @@ zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req)
4198 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *) 4190 struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
4199 &(fsf_req->qtcb->bottom.io.fcp_rsp); 4191 &(fsf_req->qtcb->bottom.io.fcp_rsp);
4200 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu); 4192 char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
4201 struct zfcp_unit *unit = 4193 struct zfcp_unit *unit = (struct zfcp_unit *) fsf_req->data;
4202 fsf_req->data.send_fcp_command_task_management.unit;
4203 4194
4204 del_timer(&fsf_req->adapter->scsi_er_timer); 4195 del_timer(&fsf_req->adapter->scsi_er_timer);
4205 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) { 4196 if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
@@ -4276,7 +4267,7 @@ zfcp_fsf_control_file(struct zfcp_adapter *adapter,
4276 int direction; 4267 int direction;
4277 int retval = 0; 4268 int retval = 0;
4278 4269
4279 if (!(adapter->supported_features & FSF_FEATURE_CFDC)) { 4270 if (!(adapter->adapter_features & FSF_FEATURE_CFDC)) {
4280 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n", 4271 ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
4281 zfcp_get_busid_by_adapter(adapter)); 4272 zfcp_get_busid_by_adapter(adapter));
4282 retval = -EOPNOTSUPP; 4273 retval = -EOPNOTSUPP;
@@ -4549,52 +4540,6 @@ skip_fsfstatus:
4549 return retval; 4540 return retval;
4550} 4541}
4551 4542
4552
4553/*
4554 * function: zfcp_fsf_req_wait_and_cleanup
4555 *
4556 * purpose:
4557 *
4558 * FIXME(design): signal seems to be <0 !!!
4559 * returns: 0 - request completed (*status is valid), cleanup succ.
4560 * <0 - request completed (*status is valid), cleanup failed
4561 * >0 - signal which interrupted waiting (*status invalid),
4562 * request not completed, no cleanup
4563 *
4564 * *status is a copy of status of completed fsf_req
4565 */
4566int
4567zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *fsf_req,
4568 int interruptible, u32 * status)
4569{
4570 int retval = 0;
4571 int signal = 0;
4572
4573 if (interruptible) {
4574 __wait_event_interruptible(fsf_req->completion_wq,
4575 fsf_req->status &
4576 ZFCP_STATUS_FSFREQ_COMPLETED,
4577 signal);
4578 if (signal) {
4579 ZFCP_LOG_DEBUG("Caught signal %i while waiting for the "
4580 "completion of the request at %p\n",
4581 signal, fsf_req);
4582 retval = signal;
4583 goto out;
4584 }
4585 } else {
4586 __wait_event(fsf_req->completion_wq,
4587 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
4588 }
4589
4590 *status = fsf_req->status;
4591
4592 /* cleanup request */
4593 zfcp_fsf_req_free(fsf_req);
4594 out:
4595 return retval;
4596}
4597
4598static inline int 4543static inline int
4599zfcp_fsf_req_sbal_check(unsigned long *flags, 4544zfcp_fsf_req_sbal_check(unsigned long *flags,
4600 struct zfcp_qdio_queue *queue, int needed) 4545 struct zfcp_qdio_queue *queue, int needed)
@@ -4610,15 +4555,16 @@ zfcp_fsf_req_sbal_check(unsigned long *flags,
4610 * set qtcb pointer in fsf_req and initialize QTCB 4555 * set qtcb pointer in fsf_req and initialize QTCB
4611 */ 4556 */
4612static inline void 4557static inline void
4613zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req, u32 fsf_cmd) 4558zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req)
4614{ 4559{
4615 if (likely(fsf_req->qtcb != NULL)) { 4560 if (likely(fsf_req->qtcb != NULL)) {
4561 fsf_req->qtcb->prefix.req_seq_no = fsf_req->adapter->fsf_req_seq_no;
4616 fsf_req->qtcb->prefix.req_id = (unsigned long)fsf_req; 4562 fsf_req->qtcb->prefix.req_id = (unsigned long)fsf_req;
4617 fsf_req->qtcb->prefix.ulp_info = ZFCP_ULP_INFO_VERSION; 4563 fsf_req->qtcb->prefix.ulp_info = ZFCP_ULP_INFO_VERSION;
4618 fsf_req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd]; 4564 fsf_req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_req->fsf_command];
4619 fsf_req->qtcb->prefix.qtcb_version = ZFCP_QTCB_VERSION; 4565 fsf_req->qtcb->prefix.qtcb_version = ZFCP_QTCB_VERSION;
4620 fsf_req->qtcb->header.req_handle = (unsigned long)fsf_req; 4566 fsf_req->qtcb->header.req_handle = (unsigned long)fsf_req;
4621 fsf_req->qtcb->header.fsf_command = fsf_cmd; 4567 fsf_req->qtcb->header.fsf_command = fsf_req->fsf_command;
4622 } 4568 }
4623} 4569}
4624 4570
@@ -4686,7 +4632,10 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4686 goto failed_fsf_req; 4632 goto failed_fsf_req;
4687 } 4633 }
4688 4634
4689 zfcp_fsf_req_qtcb_init(fsf_req, fsf_cmd); 4635 fsf_req->adapter = adapter;
4636 fsf_req->fsf_command = fsf_cmd;
4637
4638 zfcp_fsf_req_qtcb_init(fsf_req);
4690 4639
4691 /* initialize waitqueue which may be used to wait on 4640 /* initialize waitqueue which may be used to wait on
4692 this request completion */ 4641 this request completion */
@@ -4708,8 +4657,10 @@ zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
4708 goto failed_sbals; 4657 goto failed_sbals;
4709 } 4658 }
4710 4659
4711 fsf_req->adapter = adapter; /* pointer to "parent" adapter */ 4660 if (fsf_req->qtcb) {
4712 fsf_req->fsf_command = fsf_cmd; 4661 fsf_req->seq_no = adapter->fsf_req_seq_no;
4662 fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
4663 }
4713 fsf_req->sbal_number = 1; 4664 fsf_req->sbal_number = 1;
4714 fsf_req->sbal_first = req_queue->free_index; 4665 fsf_req->sbal_first = req_queue->free_index;
4715 fsf_req->sbal_curr = req_queue->free_index; 4666 fsf_req->sbal_curr = req_queue->free_index;
@@ -4760,9 +4711,9 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4760 struct zfcp_adapter *adapter; 4711 struct zfcp_adapter *adapter;
4761 struct zfcp_qdio_queue *req_queue; 4712 struct zfcp_qdio_queue *req_queue;
4762 volatile struct qdio_buffer_element *sbale; 4713 volatile struct qdio_buffer_element *sbale;
4714 int inc_seq_no;
4763 int new_distance_from_int; 4715 int new_distance_from_int;
4764 unsigned long flags; 4716 unsigned long flags;
4765 int inc_seq_no = 1;
4766 int retval = 0; 4717 int retval = 0;
4767 4718
4768 adapter = fsf_req->adapter; 4719 adapter = fsf_req->adapter;
@@ -4776,23 +4727,13 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4776 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr, 4727 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr,
4777 sbale[1].length); 4728 sbale[1].length);
4778 4729
4779 /* set sequence counter in QTCB */
4780 if (likely(fsf_req->qtcb)) {
4781 fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
4782 fsf_req->seq_no = adapter->fsf_req_seq_no;
4783 ZFCP_LOG_TRACE("FSF request %p of adapter %s gets "
4784 "FSF sequence counter value of %i\n",
4785 fsf_req,
4786 zfcp_get_busid_by_adapter(adapter),
4787 fsf_req->qtcb->prefix.req_seq_no);
4788 } else
4789 inc_seq_no = 0;
4790
4791 /* put allocated FSF request at list tail */ 4730 /* put allocated FSF request at list tail */
4792 spin_lock_irqsave(&adapter->fsf_req_list_lock, flags); 4731 spin_lock_irqsave(&adapter->fsf_req_list_lock, flags);
4793 list_add_tail(&fsf_req->list, &adapter->fsf_req_list_head); 4732 list_add_tail(&fsf_req->list, &adapter->fsf_req_list_head);
4794 spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags); 4733 spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
4795 4734
4735 inc_seq_no = (fsf_req->qtcb != NULL);
4736
4796 /* figure out expiration time of timeout and start timeout */ 4737 /* figure out expiration time of timeout and start timeout */
4797 if (unlikely(timer)) { 4738 if (unlikely(timer)) {
4798 timer->expires += jiffies; 4739 timer->expires += jiffies;
@@ -4822,6 +4763,8 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4822 req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */ 4763 req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */
4823 new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req); 4764 new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req);
4824 4765
4766 fsf_req->issued = get_clock();
4767
4825 retval = do_QDIO(adapter->ccw_device, 4768 retval = do_QDIO(adapter->ccw_device,
4826 QDIO_FLAG_SYNC_OUTPUT, 4769 QDIO_FLAG_SYNC_OUTPUT,
4827 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL); 4770 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL);
@@ -4860,15 +4803,11 @@ zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
4860 * routines resulting in missing sequence counter values 4803 * routines resulting in missing sequence counter values
4861 * otherwise, 4804 * otherwise,
4862 */ 4805 */
4806
4863 /* Don't increase for unsolicited status */ 4807 /* Don't increase for unsolicited status */
4864 if (likely(inc_seq_no)) { 4808 if (inc_seq_no)
4865 adapter->fsf_req_seq_no++; 4809 adapter->fsf_req_seq_no++;
4866 ZFCP_LOG_TRACE 4810
4867 ("FSF sequence counter value of adapter %s "
4868 "increased to %i\n",
4869 zfcp_get_busid_by_adapter(adapter),
4870 adapter->fsf_req_seq_no);
4871 }
4872 /* count FSF requests pending */ 4811 /* count FSF requests pending */
4873 atomic_inc(&adapter->fsf_reqs_active); 4812 atomic_inc(&adapter->fsf_reqs_active);
4874 } 4813 }
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
index 07140dfda2a7..48719f055952 100644
--- a/drivers/s390/scsi/zfcp_fsf.h
+++ b/drivers/s390/scsi/zfcp_fsf.h
@@ -116,6 +116,7 @@
116#define FSF_INVALID_COMMAND_OPTION 0x000000E5 116#define FSF_INVALID_COMMAND_OPTION 0x000000E5
117/* #define FSF_ERROR 0x000000FF */ 117/* #define FSF_ERROR 0x000000FF */
118 118
119#define FSF_PROT_STATUS_QUAL_SIZE 16
119#define FSF_STATUS_QUALIFIER_SIZE 16 120#define FSF_STATUS_QUALIFIER_SIZE 16
120 121
121/* FSF status qualifier, recommendations */ 122/* FSF status qualifier, recommendations */
@@ -139,9 +140,18 @@
139#define FSF_SQ_CFDC_SUBTABLE_LUN 0x0004 140#define FSF_SQ_CFDC_SUBTABLE_LUN 0x0004
140 141
141/* FSF status qualifier (most significant 4 bytes), local link down */ 142/* FSF status qualifier (most significant 4 bytes), local link down */
142#define FSF_PSQ_LINK_NOLIGHT 0x00000004 143#define FSF_PSQ_LINK_NO_LIGHT 0x00000004
143#define FSF_PSQ_LINK_WRAPPLUG 0x00000008 144#define FSF_PSQ_LINK_WRAP_PLUG 0x00000008
144#define FSF_PSQ_LINK_NOFCP 0x00000010 145#define FSF_PSQ_LINK_NO_FCP 0x00000010
146#define FSF_PSQ_LINK_FIRMWARE_UPDATE 0x00000020
147#define FSF_PSQ_LINK_INVALID_WWPN 0x00000100
148#define FSF_PSQ_LINK_NO_NPIV_SUPPORT 0x00000200
149#define FSF_PSQ_LINK_NO_FCP_RESOURCES 0x00000400
150#define FSF_PSQ_LINK_NO_FABRIC_RESOURCES 0x00000800
151#define FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE 0x00001000
152#define FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED 0x00002000
153#define FSF_PSQ_LINK_MODE_TABLE_CURRUPTED 0x00004000
154#define FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT 0x00008000
145 155
146/* payload size in status read buffer */ 156/* payload size in status read buffer */
147#define FSF_STATUS_READ_PAYLOAD_SIZE 4032 157#define FSF_STATUS_READ_PAYLOAD_SIZE 4032
@@ -154,15 +164,21 @@
154#define FSF_STATUS_READ_INCOMING_ELS 0x00000002 164#define FSF_STATUS_READ_INCOMING_ELS 0x00000002
155#define FSF_STATUS_READ_SENSE_DATA_AVAIL 0x00000003 165#define FSF_STATUS_READ_SENSE_DATA_AVAIL 0x00000003
156#define FSF_STATUS_READ_BIT_ERROR_THRESHOLD 0x00000004 166#define FSF_STATUS_READ_BIT_ERROR_THRESHOLD 0x00000004
157#define FSF_STATUS_READ_LINK_DOWN 0x00000005 /* FIXME: really? */ 167#define FSF_STATUS_READ_LINK_DOWN 0x00000005
158#define FSF_STATUS_READ_LINK_UP 0x00000006 168#define FSF_STATUS_READ_LINK_UP 0x00000006
159#define FSF_STATUS_READ_CFDC_UPDATED 0x0000000A 169#define FSF_STATUS_READ_CFDC_UPDATED 0x0000000A
160#define FSF_STATUS_READ_CFDC_HARDENED 0x0000000B 170#define FSF_STATUS_READ_CFDC_HARDENED 0x0000000B
171#define FSF_STATUS_READ_FEATURE_UPDATE_ALERT 0x0000000C
161 172
162/* status subtypes in status read buffer */ 173/* status subtypes in status read buffer */
163#define FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT 0x00000001 174#define FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT 0x00000001
164#define FSF_STATUS_READ_SUB_ERROR_PORT 0x00000002 175#define FSF_STATUS_READ_SUB_ERROR_PORT 0x00000002
165 176
177/* status subtypes for link down */
178#define FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK 0x00000000
179#define FSF_STATUS_READ_SUB_FDISC_FAILED 0x00000001
180#define FSF_STATUS_READ_SUB_FIRMWARE_UPDATE 0x00000002
181
166/* status subtypes for CFDC */ 182/* status subtypes for CFDC */
167#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE 0x00000002 183#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE 0x00000002
168#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2 0x0000000F 184#define FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2 0x0000000F
@@ -193,11 +209,15 @@
193#define FSF_QTCB_LOG_SIZE 1024 209#define FSF_QTCB_LOG_SIZE 1024
194 210
195/* channel features */ 211/* channel features */
196#define FSF_FEATURE_QTCB_SUPPRESSION 0x00000001
197#define FSF_FEATURE_CFDC 0x00000002 212#define FSF_FEATURE_CFDC 0x00000002
198#define FSF_FEATURE_LUN_SHARING 0x00000004 213#define FSF_FEATURE_LUN_SHARING 0x00000004
199#define FSF_FEATURE_HBAAPI_MANAGEMENT 0x00000010 214#define FSF_FEATURE_HBAAPI_MANAGEMENT 0x00000010
200#define FSF_FEATURE_ELS_CT_CHAINED_SBALS 0x00000020 215#define FSF_FEATURE_ELS_CT_CHAINED_SBALS 0x00000020
216#define FSF_FEATURE_UPDATE_ALERT 0x00000100
217
218/* host connection features */
219#define FSF_FEATURE_NPIV_MODE 0x00000001
220#define FSF_FEATURE_VM_ASSIGNED_WWPN 0x00000002
201 221
202/* option */ 222/* option */
203#define FSF_OPEN_LUN_SUPPRESS_BOXING 0x00000001 223#define FSF_OPEN_LUN_SUPPRESS_BOXING 0x00000001
@@ -305,15 +325,23 @@ struct fsf_qual_sequence_error {
305 u32 res1[3]; 325 u32 res1[3];
306} __attribute__ ((packed)); 326} __attribute__ ((packed));
307 327
308struct fsf_qual_locallink_error { 328struct fsf_link_down_info {
309 u32 code; 329 u32 error_code;
310 u32 res1[3]; 330 u32 res1;
331 u8 res2[2];
332 u8 primary_status;
333 u8 ioerr_code;
334 u8 action_code;
335 u8 reason_code;
336 u8 explanation_code;
337 u8 vendor_specific_code;
311} __attribute__ ((packed)); 338} __attribute__ ((packed));
312 339
313union fsf_prot_status_qual { 340union fsf_prot_status_qual {
341 u64 doubleword[FSF_PROT_STATUS_QUAL_SIZE / sizeof(u64)];
314 struct fsf_qual_version_error version_error; 342 struct fsf_qual_version_error version_error;
315 struct fsf_qual_sequence_error sequence_error; 343 struct fsf_qual_sequence_error sequence_error;
316 struct fsf_qual_locallink_error locallink_error; 344 struct fsf_link_down_info link_down_info;
317} __attribute__ ((packed)); 345} __attribute__ ((packed));
318 346
319struct fsf_qtcb_prefix { 347struct fsf_qtcb_prefix {
@@ -331,7 +359,9 @@ union fsf_status_qual {
331 u8 byte[FSF_STATUS_QUALIFIER_SIZE]; 359 u8 byte[FSF_STATUS_QUALIFIER_SIZE];
332 u16 halfword[FSF_STATUS_QUALIFIER_SIZE / sizeof (u16)]; 360 u16 halfword[FSF_STATUS_QUALIFIER_SIZE / sizeof (u16)];
333 u32 word[FSF_STATUS_QUALIFIER_SIZE / sizeof (u32)]; 361 u32 word[FSF_STATUS_QUALIFIER_SIZE / sizeof (u32)];
362 u64 doubleword[FSF_STATUS_QUALIFIER_SIZE / sizeof(u64)];
334 struct fsf_queue_designator fsf_queue_designator; 363 struct fsf_queue_designator fsf_queue_designator;
364 struct fsf_link_down_info link_down_info;
335} __attribute__ ((packed)); 365} __attribute__ ((packed));
336 366
337struct fsf_qtcb_header { 367struct fsf_qtcb_header {
@@ -406,8 +436,8 @@ struct fsf_qtcb_bottom_config {
406 u32 low_qtcb_version; 436 u32 low_qtcb_version;
407 u32 max_qtcb_size; 437 u32 max_qtcb_size;
408 u32 max_data_transfer_size; 438 u32 max_data_transfer_size;
409 u32 supported_features; 439 u32 adapter_features;
410 u8 res1[4]; 440 u32 connection_features;
411 u32 fc_topology; 441 u32 fc_topology;
412 u32 fc_link_speed; 442 u32 fc_link_speed;
413 u32 adapter_type; 443 u32 adapter_type;
@@ -425,7 +455,7 @@ struct fsf_qtcb_bottom_config {
425} __attribute__ ((packed)); 455} __attribute__ ((packed));
426 456
427struct fsf_qtcb_bottom_port { 457struct fsf_qtcb_bottom_port {
428 u8 res1[8]; 458 u64 wwpn;
429 u32 fc_port_id; 459 u32 fc_port_id;
430 u32 port_type; 460 u32 port_type;
431 u32 port_state; 461 u32 port_state;
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 24e16ec331d9..d719f66a29a4 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -54,8 +54,7 @@ static inline int zfcp_qdio_sbals_from_buffer
54static qdio_handler_t zfcp_qdio_request_handler; 54static qdio_handler_t zfcp_qdio_request_handler;
55static qdio_handler_t zfcp_qdio_response_handler; 55static qdio_handler_t zfcp_qdio_response_handler;
56static int zfcp_qdio_handler_error_check(struct zfcp_adapter *, 56static int zfcp_qdio_handler_error_check(struct zfcp_adapter *,
57 unsigned int, 57 unsigned int, unsigned int, unsigned int, int, int);
58 unsigned int, unsigned int);
59 58
60#define ZFCP_LOG_AREA ZFCP_LOG_AREA_QDIO 59#define ZFCP_LOG_AREA ZFCP_LOG_AREA_QDIO
61 60
@@ -214,22 +213,12 @@ zfcp_qdio_allocate(struct zfcp_adapter *adapter)
214 * 213 *
215 */ 214 */
216static inline int 215static inline int
217zfcp_qdio_handler_error_check(struct zfcp_adapter *adapter, 216zfcp_qdio_handler_error_check(struct zfcp_adapter *adapter, unsigned int status,
218 unsigned int status, 217 unsigned int qdio_error, unsigned int siga_error,
219 unsigned int qdio_error, unsigned int siga_error) 218 int first_element, int elements_processed)
220{ 219{
221 int retval = 0; 220 int retval = 0;
222 221
223 if (ZFCP_LOG_CHECK(ZFCP_LOG_LEVEL_TRACE)) {
224 if (status & QDIO_STATUS_INBOUND_INT) {
225 ZFCP_LOG_TRACE("status is"
226 " QDIO_STATUS_INBOUND_INT \n");
227 }
228 if (status & QDIO_STATUS_OUTBOUND_INT) {
229 ZFCP_LOG_TRACE("status is"
230 " QDIO_STATUS_OUTBOUND_INT \n");
231 }
232 }
233 if (unlikely(status & QDIO_STATUS_LOOK_FOR_ERROR)) { 222 if (unlikely(status & QDIO_STATUS_LOOK_FOR_ERROR)) {
234 retval = -EIO; 223 retval = -EIO;
235 224
@@ -237,9 +226,10 @@ zfcp_qdio_handler_error_check(struct zfcp_adapter *adapter,
237 "qdio_error=0x%x, siga_error=0x%x)\n", 226 "qdio_error=0x%x, siga_error=0x%x)\n",
238 status, qdio_error, siga_error); 227 status, qdio_error, siga_error);
239 228
240 /* Restarting IO on the failed adapter from scratch */ 229 zfcp_hba_dbf_event_qdio(adapter, status, qdio_error, siga_error,
241 debug_text_event(adapter->erp_dbf, 1, "qdio_err"); 230 first_element, elements_processed);
242 /* 231 /*
232 * Restarting IO on the failed adapter from scratch.
243 * Since we have been using this adapter, it is save to assume 233 * Since we have been using this adapter, it is save to assume
244 * that it is not failed but recoverable. The card seems to 234 * that it is not failed but recoverable. The card seems to
245 * report link-up events by self-initiated queue shutdown. 235 * report link-up events by self-initiated queue shutdown.
@@ -282,7 +272,8 @@ zfcp_qdio_request_handler(struct ccw_device *ccw_device,
282 first_element, elements_processed); 272 first_element, elements_processed);
283 273
284 if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error, 274 if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error,
285 siga_error))) 275 siga_error, first_element,
276 elements_processed)))
286 goto out; 277 goto out;
287 /* 278 /*
288 * we stored address of struct zfcp_adapter data structure 279 * we stored address of struct zfcp_adapter data structure
@@ -334,7 +325,8 @@ zfcp_qdio_response_handler(struct ccw_device *ccw_device,
334 queue = &adapter->response_queue; 325 queue = &adapter->response_queue;
335 326
336 if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error, 327 if (unlikely(zfcp_qdio_handler_error_check(adapter, status, qdio_error,
337 siga_error))) 328 siga_error, first_element,
329 elements_processed)))
338 goto out; 330 goto out;
339 331
340 /* 332 /*
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 31a76065cf28..3dcd1bfba3b4 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -44,7 +44,8 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *);
44static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *); 44static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *);
45static int zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *); 45static int zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *);
46static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *); 46static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *);
47static int zfcp_task_management_function(struct zfcp_unit *, u8); 47static int zfcp_task_management_function(struct zfcp_unit *, u8,
48 struct scsi_cmnd *);
48 49
49static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t, 50static struct zfcp_unit *zfcp_unit_lookup(struct zfcp_adapter *, int, scsi_id_t,
50 scsi_lun_t); 51 scsi_lun_t);
@@ -242,7 +243,10 @@ static void
242zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) 243zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
243{ 244{
244 set_host_byte(&scpnt->result, result); 245 set_host_byte(&scpnt->result, result);
245 zfcp_cmd_dbf_event_scsi("failing", scpnt); 246 if ((scpnt->device != NULL) && (scpnt->device->host != NULL))
247 zfcp_scsi_dbf_event_result("fail", 4,
248 (struct zfcp_adapter*) scpnt->device->host->hostdata[0],
249 scpnt);
246 /* return directly */ 250 /* return directly */
247 scpnt->scsi_done(scpnt); 251 scpnt->scsi_done(scpnt);
248} 252}
@@ -414,67 +418,38 @@ zfcp_port_lookup(struct zfcp_adapter *adapter, int channel, scsi_id_t id)
414 return (struct zfcp_port *) NULL; 418 return (struct zfcp_port *) NULL;
415} 419}
416 420
417/* 421/**
418 * function: zfcp_scsi_eh_abort_handler 422 * zfcp_scsi_eh_abort_handler - abort the specified SCSI command
419 * 423 * @scpnt: pointer to scsi_cmnd to be aborted
420 * purpose: tries to abort the specified (timed out) SCSI command 424 * Return: SUCCESS - command has been aborted and cleaned up in internal
421 * 425 * bookkeeping, SCSI stack won't be called for aborted command
422 * note: We do not need to care for a SCSI command which completes 426 * FAILED - otherwise
423 * normally but late during this abort routine runs.
424 * We are allowed to return late commands to the SCSI stack.
425 * It tracks the state of commands and will handle late commands.
426 * (Usually, the normal completion of late commands is ignored with
427 * respect to the running abort operation. Grep for 'done_late'
428 * in the SCSI stacks sources.)
429 * 427 *
430 * returns: SUCCESS - command has been aborted and cleaned up in internal 428 * We do not need to care for a SCSI command which completes normally
431 * bookkeeping, 429 * but late during this abort routine runs. We are allowed to return
432 * SCSI stack won't be called for aborted command 430 * late commands to the SCSI stack. It tracks the state of commands and
433 * FAILED - otherwise 431 * will handle late commands. (Usually, the normal completion of late
432 * commands is ignored with respect to the running abort operation.)
434 */ 433 */
435int 434int
436__zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) 435zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
437{ 436{
437 struct Scsi_Host *scsi_host;
438 struct zfcp_adapter *adapter;
439 struct zfcp_unit *unit;
438 int retval = SUCCESS; 440 int retval = SUCCESS;
439 struct zfcp_fsf_req *new_fsf_req, *old_fsf_req; 441 struct zfcp_fsf_req *new_fsf_req = NULL;
440 struct zfcp_adapter *adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; 442 struct zfcp_fsf_req *old_fsf_req;
441 struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata;
442 struct zfcp_port *port = unit->port;
443 struct Scsi_Host *scsi_host = scpnt->device->host;
444 union zfcp_req_data *req_data = NULL;
445 unsigned long flags; 443 unsigned long flags;
446 u32 status = 0; 444
447 445 scsi_host = scpnt->device->host;
448 /* the components of a abort_dbf record (fixed size record) */ 446 adapter = (struct zfcp_adapter *) scsi_host->hostdata[0];
449 u64 dbf_scsi_cmnd = (unsigned long) scpnt; 447 unit = (struct zfcp_unit *) scpnt->device->hostdata;
450 char dbf_opcode[ZFCP_ABORT_DBF_LENGTH];
451 wwn_t dbf_wwn = port->wwpn;
452 fcp_lun_t dbf_fcp_lun = unit->fcp_lun;
453 u64 dbf_retries = scpnt->retries;
454 u64 dbf_allowed = scpnt->allowed;
455 u64 dbf_timeout = 0;
456 u64 dbf_fsf_req = 0;
457 u64 dbf_fsf_status = 0;
458 u64 dbf_fsf_qual[2] = { 0, 0 };
459 char dbf_result[ZFCP_ABORT_DBF_LENGTH] = "##undef";
460
461 memset(dbf_opcode, 0, ZFCP_ABORT_DBF_LENGTH);
462 memcpy(dbf_opcode,
463 scpnt->cmnd,
464 min(scpnt->cmd_len, (unsigned char) ZFCP_ABORT_DBF_LENGTH));
465 448
466 ZFCP_LOG_INFO("aborting scsi_cmnd=%p on adapter %s\n", 449 ZFCP_LOG_INFO("aborting scsi_cmnd=%p on adapter %s\n",
467 scpnt, zfcp_get_busid_by_adapter(adapter)); 450 scpnt, zfcp_get_busid_by_adapter(adapter));
468 451
469 spin_unlock_irq(scsi_host->host_lock); 452 /* avoid race condition between late normal completion and abort */
470
471 /*
472 * Race condition between normal (late) completion and abort has
473 * to be avoided.
474 * The entirity of all accesses to scsi_req have to be atomic.
475 * scsi_req is usually part of the fsf_req and thus we block the
476 * release of fsf_req as long as we need to access scsi_req.
477 */
478 write_lock_irqsave(&adapter->abort_lock, flags); 453 write_lock_irqsave(&adapter->abort_lock, flags);
479 454
480 /* 455 /*
@@ -484,144 +459,47 @@ __zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
484 * this routine returns. (scpnt is parameter passed to this routine 459 * this routine returns. (scpnt is parameter passed to this routine
485 * and must not disappear during abort even on late completion.) 460 * and must not disappear during abort even on late completion.)
486 */ 461 */
487 req_data = (union zfcp_req_data *) scpnt->host_scribble; 462 old_fsf_req = (struct zfcp_fsf_req *) scpnt->host_scribble;
488 /* DEBUG */
489 ZFCP_LOG_DEBUG("req_data=%p\n", req_data);
490 if (!req_data) {
491 ZFCP_LOG_DEBUG("late command completion overtook abort\n");
492 /*
493 * That's it.
494 * Do not initiate abort but return SUCCESS.
495 */
496 write_unlock_irqrestore(&adapter->abort_lock, flags);
497 retval = SUCCESS;
498 strncpy(dbf_result, "##late1", ZFCP_ABORT_DBF_LENGTH);
499 goto out;
500 }
501
502 /* Figure out which fsf_req needs to be aborted. */
503 old_fsf_req = req_data->send_fcp_command_task.fsf_req;
504
505 dbf_fsf_req = (unsigned long) old_fsf_req;
506 dbf_timeout =
507 (jiffies - req_data->send_fcp_command_task.start_jiffies) / HZ;
508
509 ZFCP_LOG_DEBUG("old_fsf_req=%p\n", old_fsf_req);
510 if (!old_fsf_req) { 463 if (!old_fsf_req) {
511 write_unlock_irqrestore(&adapter->abort_lock, flags); 464 write_unlock_irqrestore(&adapter->abort_lock, flags);
512 ZFCP_LOG_NORMAL("bug: no old fsf request found\n"); 465 zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, new_fsf_req);
513 ZFCP_LOG_NORMAL("req_data:\n"); 466 retval = SUCCESS;
514 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
515 (char *) req_data, sizeof (union zfcp_req_data));
516 ZFCP_LOG_NORMAL("scsi_cmnd:\n");
517 ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
518 (char *) scpnt, sizeof (struct scsi_cmnd));
519 retval = FAILED;
520 strncpy(dbf_result, "##bug:r", ZFCP_ABORT_DBF_LENGTH);
521 goto out; 467 goto out;
522 } 468 }
523 old_fsf_req->data.send_fcp_command_task.scsi_cmnd = NULL; 469 old_fsf_req->data = 0;
524 /* mark old request as being aborted */
525 old_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTING; 470 old_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTING;
526 /*
527 * We have to collect all information (e.g. unit) needed by
528 * zfcp_fsf_abort_fcp_command before calling that routine
529 * since that routine is not allowed to access
530 * fsf_req which it is going to abort.
531 * This is because of we need to release fsf_req_list_lock
532 * before calling zfcp_fsf_abort_fcp_command.
533 * Since this lock will not be held, fsf_req may complete
534 * late and may be released meanwhile.
535 */
536 ZFCP_LOG_DEBUG("unit 0x%016Lx (%p)\n", unit->fcp_lun, unit);
537 471
538 /* 472 /* don't access old_fsf_req after releasing the abort_lock */
539 * We block (call schedule)
540 * That's why we must release the lock and enable the
541 * interrupts before.
542 * On the other hand we do not need the lock anymore since
543 * all critical accesses to scsi_req are done.
544 */
545 write_unlock_irqrestore(&adapter->abort_lock, flags); 473 write_unlock_irqrestore(&adapter->abort_lock, flags);
546 /* call FSF routine which does the abort */ 474 /* call FSF routine which does the abort */
547 new_fsf_req = zfcp_fsf_abort_fcp_command((unsigned long) old_fsf_req, 475 new_fsf_req = zfcp_fsf_abort_fcp_command((unsigned long) old_fsf_req,
548 adapter, unit, 0); 476 adapter, unit, 0);
549 ZFCP_LOG_DEBUG("new_fsf_req=%p\n", new_fsf_req);
550 if (!new_fsf_req) { 477 if (!new_fsf_req) {
478 ZFCP_LOG_INFO("error: initiation of Abort FCP Cmnd failed\n");
551 retval = FAILED; 479 retval = FAILED;
552 ZFCP_LOG_NORMAL("error: initiation of Abort FCP Cmnd "
553 "failed\n");
554 strncpy(dbf_result, "##nores", ZFCP_ABORT_DBF_LENGTH);
555 goto out; 480 goto out;
556 } 481 }
557 482
558 /* wait for completion of abort */ 483 /* wait for completion of abort */
559 ZFCP_LOG_DEBUG("waiting for cleanup...\n");
560#if 1
561 /*
562 * FIXME:
563 * copying zfcp_fsf_req_wait_and_cleanup code is not really nice
564 */
565 __wait_event(new_fsf_req->completion_wq, 484 __wait_event(new_fsf_req->completion_wq,
566 new_fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 485 new_fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
567 status = new_fsf_req->status; 486
568 dbf_fsf_status = new_fsf_req->qtcb->header.fsf_status;
569 /*
570 * Ralphs special debug load provides timestamps in the FSF
571 * status qualifier. This might be specified later if being
572 * useful for debugging aborts.
573 */
574 dbf_fsf_qual[0] =
575 *(u64 *) & new_fsf_req->qtcb->header.fsf_status_qual.word[0];
576 dbf_fsf_qual[1] =
577 *(u64 *) & new_fsf_req->qtcb->header.fsf_status_qual.word[2];
578 zfcp_fsf_req_free(new_fsf_req);
579#else
580 retval = zfcp_fsf_req_wait_and_cleanup(new_fsf_req,
581 ZFCP_UNINTERRUPTIBLE, &status);
582#endif
583 ZFCP_LOG_DEBUG("Waiting for cleanup complete, status=0x%x\n", status);
584 /* status should be valid since signals were not permitted */ 487 /* status should be valid since signals were not permitted */
585 if (status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) { 488 if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) {
489 zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, new_fsf_req);
586 retval = SUCCESS; 490 retval = SUCCESS;
587 strncpy(dbf_result, "##succ", ZFCP_ABORT_DBF_LENGTH); 491 } else if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) {
588 } else if (status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) { 492 zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, new_fsf_req);
589 retval = SUCCESS; 493 retval = SUCCESS;
590 strncpy(dbf_result, "##late2", ZFCP_ABORT_DBF_LENGTH);
591 } else { 494 } else {
495 zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, new_fsf_req);
592 retval = FAILED; 496 retval = FAILED;
593 strncpy(dbf_result, "##fail", ZFCP_ABORT_DBF_LENGTH);
594 } 497 }
595 498 zfcp_fsf_req_free(new_fsf_req);
596 out: 499 out:
597 debug_event(adapter->abort_dbf, 1, &dbf_scsi_cmnd, sizeof (u64));
598 debug_event(adapter->abort_dbf, 1, &dbf_opcode, ZFCP_ABORT_DBF_LENGTH);
599 debug_event(adapter->abort_dbf, 1, &dbf_wwn, sizeof (wwn_t));
600 debug_event(adapter->abort_dbf, 1, &dbf_fcp_lun, sizeof (fcp_lun_t));
601 debug_event(adapter->abort_dbf, 1, &dbf_retries, sizeof (u64));
602 debug_event(adapter->abort_dbf, 1, &dbf_allowed, sizeof (u64));
603 debug_event(adapter->abort_dbf, 1, &dbf_timeout, sizeof (u64));
604 debug_event(adapter->abort_dbf, 1, &dbf_fsf_req, sizeof (u64));
605 debug_event(adapter->abort_dbf, 1, &dbf_fsf_status, sizeof (u64));
606 debug_event(adapter->abort_dbf, 1, &dbf_fsf_qual[0], sizeof (u64));
607 debug_event(adapter->abort_dbf, 1, &dbf_fsf_qual[1], sizeof (u64));
608 debug_text_event(adapter->abort_dbf, 1, dbf_result);
609
610 spin_lock_irq(scsi_host->host_lock);
611 return retval; 500 return retval;
612} 501}
613 502
614int
615zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
616{
617 int rc;
618 struct Scsi_Host *scsi_host = scpnt->device->host;
619 spin_lock_irq(scsi_host->host_lock);
620 rc = __zfcp_scsi_eh_abort_handler(scpnt);
621 spin_unlock_irq(scsi_host->host_lock);
622 return rc;
623}
624
625/* 503/*
626 * function: zfcp_scsi_eh_device_reset_handler 504 * function: zfcp_scsi_eh_device_reset_handler
627 * 505 *
@@ -651,8 +529,9 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
651 */ 529 */
652 if (!atomic_test_mask(ZFCP_STATUS_UNIT_NOTSUPPUNITRESET, 530 if (!atomic_test_mask(ZFCP_STATUS_UNIT_NOTSUPPUNITRESET,
653 &unit->status)) { 531 &unit->status)) {
654 retval = 532 retval = zfcp_task_management_function(unit,
655 zfcp_task_management_function(unit, FCP_LOGICAL_UNIT_RESET); 533 FCP_LOGICAL_UNIT_RESET,
534 scpnt);
656 if (retval) { 535 if (retval) {
657 ZFCP_LOG_DEBUG("unit reset failed (unit=%p)\n", unit); 536 ZFCP_LOG_DEBUG("unit reset failed (unit=%p)\n", unit);
658 if (retval == -ENOTSUPP) 537 if (retval == -ENOTSUPP)
@@ -668,7 +547,7 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
668 goto out; 547 goto out;
669 } 548 }
670 } 549 }
671 retval = zfcp_task_management_function(unit, FCP_TARGET_RESET); 550 retval = zfcp_task_management_function(unit, FCP_TARGET_RESET, scpnt);
672 if (retval) { 551 if (retval) {
673 ZFCP_LOG_DEBUG("target reset failed (unit=%p)\n", unit); 552 ZFCP_LOG_DEBUG("target reset failed (unit=%p)\n", unit);
674 retval = FAILED; 553 retval = FAILED;
@@ -681,12 +560,12 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
681} 560}
682 561
683static int 562static int
684zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags) 563zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags,
564 struct scsi_cmnd *scpnt)
685{ 565{
686 struct zfcp_adapter *adapter = unit->port->adapter; 566 struct zfcp_adapter *adapter = unit->port->adapter;
687 int retval;
688 int status;
689 struct zfcp_fsf_req *fsf_req; 567 struct zfcp_fsf_req *fsf_req;
568 int retval = 0;
690 569
691 /* issue task management function */ 570 /* issue task management function */
692 fsf_req = zfcp_fsf_send_fcp_command_task_management 571 fsf_req = zfcp_fsf_send_fcp_command_task_management
@@ -696,70 +575,63 @@ zfcp_task_management_function(struct zfcp_unit *unit, u8 tm_flags)
696 "failed for unit 0x%016Lx on port 0x%016Lx on " 575 "failed for unit 0x%016Lx on port 0x%016Lx on "
697 "adapter %s\n", unit->fcp_lun, unit->port->wwpn, 576 "adapter %s\n", unit->fcp_lun, unit->port->wwpn,
698 zfcp_get_busid_by_adapter(adapter)); 577 zfcp_get_busid_by_adapter(adapter));
578 zfcp_scsi_dbf_event_devreset("nres", tm_flags, unit, scpnt);
699 retval = -ENOMEM; 579 retval = -ENOMEM;
700 goto out; 580 goto out;
701 } 581 }
702 582
703 retval = zfcp_fsf_req_wait_and_cleanup(fsf_req, 583 __wait_event(fsf_req->completion_wq,
704 ZFCP_UNINTERRUPTIBLE, &status); 584 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
585
705 /* 586 /*
706 * check completion status of task management function 587 * check completion status of task management function
707 * (status should always be valid since no signals permitted)
708 */ 588 */
709 if (status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) 589 if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCFAILED) {
590 zfcp_scsi_dbf_event_devreset("fail", tm_flags, unit, scpnt);
710 retval = -EIO; 591 retval = -EIO;
711 else if (status & ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP) 592 } else if (fsf_req->status & ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP) {
593 zfcp_scsi_dbf_event_devreset("nsup", tm_flags, unit, scpnt);
712 retval = -ENOTSUPP; 594 retval = -ENOTSUPP;
713 else 595 } else
714 retval = 0; 596 zfcp_scsi_dbf_event_devreset("okay", tm_flags, unit, scpnt);
597
598 zfcp_fsf_req_free(fsf_req);
715 out: 599 out:
716 return retval; 600 return retval;
717} 601}
718 602
719/* 603/**
720 * function: zfcp_scsi_eh_bus_reset_handler 604 * zfcp_scsi_eh_bus_reset_handler - reset bus (reopen adapter)
721 *
722 * purpose:
723 *
724 * returns:
725 */ 605 */
726int 606int
727zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *scpnt) 607zfcp_scsi_eh_bus_reset_handler(struct scsi_cmnd *scpnt)
728{ 608{
729 int retval = 0; 609 struct zfcp_unit *unit = (struct zfcp_unit*) scpnt->device->hostdata;
730 struct zfcp_unit *unit; 610 struct zfcp_adapter *adapter = unit->port->adapter;
731 611
732 unit = (struct zfcp_unit *) scpnt->device->hostdata;
733 ZFCP_LOG_NORMAL("bus reset because of problems with " 612 ZFCP_LOG_NORMAL("bus reset because of problems with "
734 "unit 0x%016Lx\n", unit->fcp_lun); 613 "unit 0x%016Lx\n", unit->fcp_lun);
735 zfcp_erp_adapter_reopen(unit->port->adapter, 0); 614 zfcp_erp_adapter_reopen(adapter, 0);
736 zfcp_erp_wait(unit->port->adapter); 615 zfcp_erp_wait(adapter);
737 retval = SUCCESS;
738 616
739 return retval; 617 return SUCCESS;
740} 618}
741 619
742/* 620/**
743 * function: zfcp_scsi_eh_host_reset_handler 621 * zfcp_scsi_eh_host_reset_handler - reset host (reopen adapter)
744 *
745 * purpose:
746 *
747 * returns:
748 */ 622 */
749int 623int
750zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt) 624zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
751{ 625{
752 int retval = 0; 626 struct zfcp_unit *unit = (struct zfcp_unit*) scpnt->device->hostdata;
753 struct zfcp_unit *unit; 627 struct zfcp_adapter *adapter = unit->port->adapter;
754 628
755 unit = (struct zfcp_unit *) scpnt->device->hostdata;
756 ZFCP_LOG_NORMAL("host reset because of problems with " 629 ZFCP_LOG_NORMAL("host reset because of problems with "
757 "unit 0x%016Lx\n", unit->fcp_lun); 630 "unit 0x%016Lx\n", unit->fcp_lun);
758 zfcp_erp_adapter_reopen(unit->port->adapter, 0); 631 zfcp_erp_adapter_reopen(adapter, 0);
759 zfcp_erp_wait(unit->port->adapter); 632 zfcp_erp_wait(adapter);
760 retval = SUCCESS;
761 633
762 return retval; 634 return SUCCESS;
763} 635}
764 636
765/* 637/*
@@ -826,10 +698,16 @@ void
826zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter) 698zfcp_adapter_scsi_unregister(struct zfcp_adapter *adapter)
827{ 699{
828 struct Scsi_Host *shost; 700 struct Scsi_Host *shost;
701 struct zfcp_port *port;
829 702
830 shost = adapter->scsi_host; 703 shost = adapter->scsi_host;
831 if (!shost) 704 if (!shost)
832 return; 705 return;
706 read_lock_irq(&zfcp_data.config_lock);
707 list_for_each_entry(port, &adapter->port_list_head, list)
708 if (port->rport)
709 port->rport = NULL;
710 read_unlock_irq(&zfcp_data.config_lock);
833 fc_remove_host(shost); 711 fc_remove_host(shost);
834 scsi_remove_host(shost); 712 scsi_remove_host(shost);
835 scsi_host_put(shost); 713 scsi_host_put(shost);
@@ -904,18 +782,6 @@ zfcp_get_node_name(struct scsi_target *starget)
904 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 782 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
905} 783}
906 784
907void
908zfcp_set_fc_host_attrs(struct zfcp_adapter *adapter)
909{
910 struct Scsi_Host *shost = adapter->scsi_host;
911
912 fc_host_node_name(shost) = adapter->wwnn;
913 fc_host_port_name(shost) = adapter->wwpn;
914 strncpy(fc_host_serial_number(shost), adapter->serial_number,
915 min(FC_SERIAL_NUMBER_SIZE, 32));
916 fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
917}
918
919struct fc_function_template zfcp_transport_functions = { 785struct fc_function_template zfcp_transport_functions = {
920 .get_starget_port_id = zfcp_get_port_id, 786 .get_starget_port_id = zfcp_get_port_id,
921 .get_starget_port_name = zfcp_get_port_name, 787 .get_starget_port_name = zfcp_get_port_name,
@@ -927,7 +793,10 @@ struct fc_function_template zfcp_transport_functions = {
927 .show_host_node_name = 1, 793 .show_host_node_name = 1,
928 .show_host_port_name = 1, 794 .show_host_port_name = 1,
929 .show_host_supported_classes = 1, 795 .show_host_supported_classes = 1,
796 .show_host_maxframe_size = 1,
930 .show_host_serial_number = 1, 797 .show_host_serial_number = 1,
798 .show_host_speed = 1,
799 .show_host_port_id = 1,
931}; 800};
932 801
933/** 802/**
diff --git a/drivers/s390/scsi/zfcp_sysfs_adapter.c b/drivers/s390/scsi/zfcp_sysfs_adapter.c
index e7345a74800a..0cd435280e7d 100644
--- a/drivers/s390/scsi/zfcp_sysfs_adapter.c
+++ b/drivers/s390/scsi/zfcp_sysfs_adapter.c
@@ -62,21 +62,18 @@ static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, struct devi
62static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_adapter_##_name##_show, NULL); 62static DEVICE_ATTR(_name, S_IRUGO, zfcp_sysfs_adapter_##_name##_show, NULL);
63 63
64ZFCP_DEFINE_ADAPTER_ATTR(status, "0x%08x\n", atomic_read(&adapter->status)); 64ZFCP_DEFINE_ADAPTER_ATTR(status, "0x%08x\n", atomic_read(&adapter->status));
65ZFCP_DEFINE_ADAPTER_ATTR(wwnn, "0x%016llx\n", adapter->wwnn);
66ZFCP_DEFINE_ADAPTER_ATTR(wwpn, "0x%016llx\n", adapter->wwpn);
67ZFCP_DEFINE_ADAPTER_ATTR(s_id, "0x%06x\n", adapter->s_id);
68ZFCP_DEFINE_ADAPTER_ATTR(peer_wwnn, "0x%016llx\n", adapter->peer_wwnn); 65ZFCP_DEFINE_ADAPTER_ATTR(peer_wwnn, "0x%016llx\n", adapter->peer_wwnn);
69ZFCP_DEFINE_ADAPTER_ATTR(peer_wwpn, "0x%016llx\n", adapter->peer_wwpn); 66ZFCP_DEFINE_ADAPTER_ATTR(peer_wwpn, "0x%016llx\n", adapter->peer_wwpn);
70ZFCP_DEFINE_ADAPTER_ATTR(peer_d_id, "0x%06x\n", adapter->peer_d_id); 67ZFCP_DEFINE_ADAPTER_ATTR(peer_d_id, "0x%06x\n", adapter->peer_d_id);
68ZFCP_DEFINE_ADAPTER_ATTR(physical_wwpn, "0x%016llx\n", adapter->physical_wwpn);
69ZFCP_DEFINE_ADAPTER_ATTR(physical_s_id, "0x%06x\n", adapter->physical_s_id);
71ZFCP_DEFINE_ADAPTER_ATTR(card_version, "0x%04x\n", adapter->hydra_version); 70ZFCP_DEFINE_ADAPTER_ATTR(card_version, "0x%04x\n", adapter->hydra_version);
72ZFCP_DEFINE_ADAPTER_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version); 71ZFCP_DEFINE_ADAPTER_ATTR(lic_version, "0x%08x\n", adapter->fsf_lic_version);
73ZFCP_DEFINE_ADAPTER_ATTR(fc_link_speed, "%d Gb/s\n", adapter->fc_link_speed);
74ZFCP_DEFINE_ADAPTER_ATTR(fc_service_class, "%d\n", adapter->fc_service_class); 72ZFCP_DEFINE_ADAPTER_ATTR(fc_service_class, "%d\n", adapter->fc_service_class);
75ZFCP_DEFINE_ADAPTER_ATTR(fc_topology, "%s\n", 73ZFCP_DEFINE_ADAPTER_ATTR(fc_topology, "%s\n",
76 fc_topologies[adapter->fc_topology]); 74 fc_topologies[adapter->fc_topology]);
77ZFCP_DEFINE_ADAPTER_ATTR(hardware_version, "0x%08x\n", 75ZFCP_DEFINE_ADAPTER_ATTR(hardware_version, "0x%08x\n",
78 adapter->hardware_version); 76 adapter->hardware_version);
79ZFCP_DEFINE_ADAPTER_ATTR(serial_number, "%17s\n", adapter->serial_number);
80ZFCP_DEFINE_ADAPTER_ATTR(scsi_host_no, "0x%x\n", adapter->scsi_host_no); 77ZFCP_DEFINE_ADAPTER_ATTR(scsi_host_no, "0x%x\n", adapter->scsi_host_no);
81ZFCP_DEFINE_ADAPTER_ATTR(in_recovery, "%d\n", atomic_test_mask 78ZFCP_DEFINE_ADAPTER_ATTR(in_recovery, "%d\n", atomic_test_mask
82 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status)); 79 (ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status));
@@ -255,21 +252,18 @@ static struct attribute *zfcp_adapter_attrs[] = {
255 &dev_attr_in_recovery.attr, 252 &dev_attr_in_recovery.attr,
256 &dev_attr_port_remove.attr, 253 &dev_attr_port_remove.attr,
257 &dev_attr_port_add.attr, 254 &dev_attr_port_add.attr,
258 &dev_attr_wwnn.attr,
259 &dev_attr_wwpn.attr,
260 &dev_attr_s_id.attr,
261 &dev_attr_peer_wwnn.attr, 255 &dev_attr_peer_wwnn.attr,
262 &dev_attr_peer_wwpn.attr, 256 &dev_attr_peer_wwpn.attr,
263 &dev_attr_peer_d_id.attr, 257 &dev_attr_peer_d_id.attr,
258 &dev_attr_physical_wwpn.attr,
259 &dev_attr_physical_s_id.attr,
264 &dev_attr_card_version.attr, 260 &dev_attr_card_version.attr,
265 &dev_attr_lic_version.attr, 261 &dev_attr_lic_version.attr,
266 &dev_attr_fc_link_speed.attr,
267 &dev_attr_fc_service_class.attr, 262 &dev_attr_fc_service_class.attr,
268 &dev_attr_fc_topology.attr, 263 &dev_attr_fc_topology.attr,
269 &dev_attr_scsi_host_no.attr, 264 &dev_attr_scsi_host_no.attr,
270 &dev_attr_status.attr, 265 &dev_attr_status.attr,
271 &dev_attr_hardware_version.attr, 266 &dev_attr_hardware_version.attr,
272 &dev_attr_serial_number.attr,
273 NULL 267 NULL
274}; 268};
275 269
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index a6ac61611f35..a748fbfb6692 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -60,6 +60,7 @@
60 Remove un-needed eh_abort handler. 60 Remove un-needed eh_abort handler.
61 Add support for embedded firmware error strings. 61 Add support for embedded firmware error strings.
62 2.26.02.003 - Correctly handle single sgl's with use_sg=1. 62 2.26.02.003 - Correctly handle single sgl's with use_sg=1.
63 2.26.02.004 - Add support for 9550SX controllers.
63*/ 64*/
64 65
65#include <linux/module.h> 66#include <linux/module.h>
@@ -82,7 +83,7 @@
82#include "3w-9xxx.h" 83#include "3w-9xxx.h"
83 84
84/* Globals */ 85/* Globals */
85#define TW_DRIVER_VERSION "2.26.02.003" 86#define TW_DRIVER_VERSION "2.26.02.004"
86static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 87static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
87static unsigned int twa_device_extension_count; 88static unsigned int twa_device_extension_count;
88static int twa_major = -1; 89static int twa_major = -1;
@@ -892,11 +893,6 @@ static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
892 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); 893 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
893 } 894 }
894 895
895 if (status_reg_value & TW_STATUS_SBUF_WRITE_ERROR) {
896 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xf, "SBUF Write Error: clearing");
897 writel(TW_CONTROL_CLEAR_SBUF_WRITE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
898 }
899
900 if (status_reg_value & TW_STATUS_MICROCONTROLLER_ERROR) { 896 if (status_reg_value & TW_STATUS_MICROCONTROLLER_ERROR) {
901 if (tw_dev->reset_print == 0) { 897 if (tw_dev->reset_print == 0) {
902 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Microcontroller Error: clearing"); 898 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x10, "Microcontroller Error: clearing");
@@ -930,6 +926,36 @@ out:
930 return retval; 926 return retval;
931} /* End twa_empty_response_queue() */ 927} /* End twa_empty_response_queue() */
932 928
929/* This function will clear the pchip/response queue on 9550SX */
930static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
931{
932 u32 status_reg_value, response_que_value;
933 int count = 0, retval = 1;
934
935 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) {
936 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
937
938 while (((status_reg_value & TW_STATUS_RESPONSE_QUEUE_EMPTY) == 0) && (count < TW_MAX_RESPONSE_DRAIN)) {
939 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
940 if ((response_que_value & TW_9550SX_DRAIN_COMPLETED) == TW_9550SX_DRAIN_COMPLETED) {
941 /* P-chip settle time */
942 msleep(500);
943 retval = 0;
944 goto out;
945 }
946 status_reg_value = readl(TW_STATUS_REG_ADDR(tw_dev));
947 count++;
948 }
949 if (count == TW_MAX_RESPONSE_DRAIN)
950 goto out;
951
952 retval = 0;
953 } else
954 retval = 0;
955out:
956 return retval;
957} /* End twa_empty_response_queue_large() */
958
933/* This function passes sense keys from firmware to scsi layer */ 959/* This function passes sense keys from firmware to scsi layer */
934static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host) 960static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_sense, int print_host)
935{ 961{
@@ -1613,8 +1639,16 @@ static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset)
1613 int tries = 0, retval = 1, flashed = 0, do_soft_reset = soft_reset; 1639 int tries = 0, retval = 1, flashed = 0, do_soft_reset = soft_reset;
1614 1640
1615 while (tries < TW_MAX_RESET_TRIES) { 1641 while (tries < TW_MAX_RESET_TRIES) {
1616 if (do_soft_reset) 1642 if (do_soft_reset) {
1617 TW_SOFT_RESET(tw_dev); 1643 TW_SOFT_RESET(tw_dev);
1644 /* Clear pchip/response queue on 9550SX */
1645 if (twa_empty_response_queue_large(tw_dev)) {
1646 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x36, "Response queue (large) empty failed during reset sequence");
1647 do_soft_reset = 1;
1648 tries++;
1649 continue;
1650 }
1651 }
1618 1652
1619 /* Make sure controller is in a good state */ 1653 /* Make sure controller is in a good state */
1620 if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTENTION_INTERRUPT : 0), 60)) { 1654 if (twa_poll_status(tw_dev, TW_STATUS_MICROCONTROLLER_READY | (do_soft_reset == 1 ? TW_STATUS_ATTENTION_INTERRUPT : 0), 60)) {
@@ -2034,7 +2068,10 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2034 goto out_free_device_extension; 2068 goto out_free_device_extension;
2035 } 2069 }
2036 2070
2037 mem_addr = pci_resource_start(pdev, 1); 2071 if (pdev->device == PCI_DEVICE_ID_3WARE_9000)
2072 mem_addr = pci_resource_start(pdev, 1);
2073 else
2074 mem_addr = pci_resource_start(pdev, 2);
2038 2075
2039 /* Save base address */ 2076 /* Save base address */
2040 tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE); 2077 tw_dev->base_addr = ioremap(mem_addr, PAGE_SIZE);
@@ -2148,6 +2185,8 @@ static void twa_remove(struct pci_dev *pdev)
2148static struct pci_device_id twa_pci_tbl[] __devinitdata = { 2185static struct pci_device_id twa_pci_tbl[] __devinitdata = {
2149 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9000, 2186 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9000,
2150 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2187 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2188 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9550SX,
2189 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2151 { } 2190 { }
2152}; 2191};
2153MODULE_DEVICE_TABLE(pci, twa_pci_tbl); 2192MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index 8c8ecbed3b58..46f22cdc8298 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -267,7 +267,6 @@ static twa_message_type twa_error_table[] = {
267#define TW_CONTROL_CLEAR_PARITY_ERROR 0x00800000 267#define TW_CONTROL_CLEAR_PARITY_ERROR 0x00800000
268#define TW_CONTROL_CLEAR_QUEUE_ERROR 0x00400000 268#define TW_CONTROL_CLEAR_QUEUE_ERROR 0x00400000
269#define TW_CONTROL_CLEAR_PCI_ABORT 0x00100000 269#define TW_CONTROL_CLEAR_PCI_ABORT 0x00100000
270#define TW_CONTROL_CLEAR_SBUF_WRITE_ERROR 0x00000008
271 270
272/* Status register bit definitions */ 271/* Status register bit definitions */
273#define TW_STATUS_MAJOR_VERSION_MASK 0xF0000000 272#define TW_STATUS_MAJOR_VERSION_MASK 0xF0000000
@@ -285,9 +284,8 @@ static twa_message_type twa_error_table[] = {
285#define TW_STATUS_MICROCONTROLLER_READY 0x00002000 284#define TW_STATUS_MICROCONTROLLER_READY 0x00002000
286#define TW_STATUS_COMMAND_QUEUE_EMPTY 0x00001000 285#define TW_STATUS_COMMAND_QUEUE_EMPTY 0x00001000
287#define TW_STATUS_EXPECTED_BITS 0x00002000 286#define TW_STATUS_EXPECTED_BITS 0x00002000
288#define TW_STATUS_UNEXPECTED_BITS 0x00F00008 287#define TW_STATUS_UNEXPECTED_BITS 0x00F00000
289#define TW_STATUS_SBUF_WRITE_ERROR 0x00000008 288#define TW_STATUS_VALID_INTERRUPT 0x00DF0000
290#define TW_STATUS_VALID_INTERRUPT 0x00DF0008
291 289
292/* RESPONSE QUEUE BIT DEFINITIONS */ 290/* RESPONSE QUEUE BIT DEFINITIONS */
293#define TW_RESPONSE_ID_MASK 0x00000FF0 291#define TW_RESPONSE_ID_MASK 0x00000FF0
@@ -324,9 +322,9 @@ static twa_message_type twa_error_table[] = {
324 322
325/* Compatibility defines */ 323/* Compatibility defines */
326#define TW_9000_ARCH_ID 0x5 324#define TW_9000_ARCH_ID 0x5
327#define TW_CURRENT_DRIVER_SRL 28 325#define TW_CURRENT_DRIVER_SRL 30
328#define TW_CURRENT_DRIVER_BUILD 9 326#define TW_CURRENT_DRIVER_BUILD 80
329#define TW_CURRENT_DRIVER_BRANCH 4 327#define TW_CURRENT_DRIVER_BRANCH 0
330 328
331/* Phase defines */ 329/* Phase defines */
332#define TW_PHASE_INITIAL 0 330#define TW_PHASE_INITIAL 0
@@ -334,6 +332,7 @@ static twa_message_type twa_error_table[] = {
334#define TW_PHASE_SGLIST 2 332#define TW_PHASE_SGLIST 2
335 333
336/* Misc defines */ 334/* Misc defines */
335#define TW_9550SX_DRAIN_COMPLETED 0xFFFF
337#define TW_SECTOR_SIZE 512 336#define TW_SECTOR_SIZE 512
338#define TW_ALIGNMENT_9000 4 /* 4 bytes */ 337#define TW_ALIGNMENT_9000 4 /* 4 bytes */
339#define TW_ALIGNMENT_9000_SGL 0x3 338#define TW_ALIGNMENT_9000_SGL 0x3
@@ -417,6 +416,9 @@ static twa_message_type twa_error_table[] = {
417#ifndef PCI_DEVICE_ID_3WARE_9000 416#ifndef PCI_DEVICE_ID_3WARE_9000
418#define PCI_DEVICE_ID_3WARE_9000 0x1002 417#define PCI_DEVICE_ID_3WARE_9000 0x1002
419#endif 418#endif
419#ifndef PCI_DEVICE_ID_3WARE_9550SX
420#define PCI_DEVICE_ID_3WARE_9550SX 0x1003
421#endif
420 422
421/* Bitmask macros to eliminate bitfields */ 423/* Bitmask macros to eliminate bitfields */
422 424
@@ -443,6 +445,7 @@ static twa_message_type twa_error_table[] = {
443#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4) 445#define TW_STATUS_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0x4)
444#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8)) 446#define TW_COMMAND_QUEUE_REG_ADDR(x) (sizeof(dma_addr_t) > 4 ? ((unsigned char __iomem *)x->base_addr + 0x20) : ((unsigned char __iomem *)x->base_addr + 0x8))
445#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC) 447#define TW_RESPONSE_QUEUE_REG_ADDR(x) ((unsigned char __iomem *)x->base_addr + 0xC)
448#define TW_RESPONSE_QUEUE_REG_ADDR_LARGE(x) ((unsigned char __iomem *)x->base_addr + 0x30)
446#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 449#define TW_CLEAR_ALL_INTERRUPTS(x) (writel(TW_STATUS_VALID_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
447#define TW_CLEAR_ATTENTION_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 450#define TW_CLEAR_ATTENTION_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_ATTENTION_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
448#define TW_CLEAR_HOST_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x))) 451#define TW_CLEAR_HOST_INTERRUPT(x) (writel(TW_CONTROL_CLEAR_HOST_INTERRUPT, TW_CONTROL_REG_ADDR(x)))
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 20019b82b4a8..3ee9b8b33be0 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -553,6 +553,11 @@ config SCSI_SATA_VITESSE
553 553
554 If unsure, say N. 554 If unsure, say N.
555 555
556config SCSI_SATA_INTEL_COMBINED
557 bool
558 depends on IDE=y && !BLK_DEV_IDE_SATA && (SCSI_SATA_AHCI || SCSI_ATA_PIIX)
559 default y
560
556config SCSI_BUSLOGIC 561config SCSI_BUSLOGIC
557 tristate "BusLogic SCSI support" 562 tristate "BusLogic SCSI support"
558 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API 563 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 1e4edbdf2730..48529d180ca8 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -99,6 +99,7 @@ obj-$(CONFIG_SCSI_DC395x) += dc395x.o
99obj-$(CONFIG_SCSI_DC390T) += tmscsim.o 99obj-$(CONFIG_SCSI_DC390T) += tmscsim.o
100obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o 100obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o
101obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/ 101obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/
102obj-$(CONFIG_MEGARAID_SAS) += megaraid/
102obj-$(CONFIG_SCSI_ACARD) += atp870u.o 103obj-$(CONFIG_SCSI_ACARD) += atp870u.o
103obj-$(CONFIG_SCSI_SUNESP) += esp.o 104obj-$(CONFIG_SCSI_SUNESP) += esp.o
104obj-$(CONFIG_SCSI_GDTH) += gdth.o 105obj-$(CONFIG_SCSI_GDTH) += gdth.o
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index d40ba0bd68a3..23392ae7df8b 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -91,7 +91,7 @@
91#ifndef NDEBUG 91#ifndef NDEBUG
92#define NDEBUG 0 92#define NDEBUG 0
93#endif 93#endif
94#ifndef NDEBUG 94#ifndef NDEBUG_ABORT
95#define NDEBUG_ABORT 0 95#define NDEBUG_ABORT 0
96#endif 96#endif
97 97
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index a8e3dfcd0dc7..93416f760e5a 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -313,18 +313,37 @@ int aac_get_containers(struct aac_dev *dev)
313 } 313 }
314 dresp = (struct aac_mount *)fib_data(fibptr); 314 dresp = (struct aac_mount *)fib_data(fibptr);
315 315
316 if ((le32_to_cpu(dresp->status) == ST_OK) &&
317 (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
318 dinfo->command = cpu_to_le32(VM_NameServe64);
319 dinfo->count = cpu_to_le32(index);
320 dinfo->type = cpu_to_le32(FT_FILESYS);
321
322 if (fib_send(ContainerCommand,
323 fibptr,
324 sizeof(struct aac_query_mount),
325 FsaNormal,
326 1, 1,
327 NULL, NULL) < 0)
328 continue;
329 } else
330 dresp->mnt[0].capacityhigh = 0;
331
316 dprintk ((KERN_DEBUG 332 dprintk ((KERN_DEBUG
317 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%u\n", 333 "VM_NameServe cid=%d status=%d vol=%d state=%d cap=%llu\n",
318 (int)index, (int)le32_to_cpu(dresp->status), 334 (int)index, (int)le32_to_cpu(dresp->status),
319 (int)le32_to_cpu(dresp->mnt[0].vol), 335 (int)le32_to_cpu(dresp->mnt[0].vol),
320 (int)le32_to_cpu(dresp->mnt[0].state), 336 (int)le32_to_cpu(dresp->mnt[0].state),
321 (unsigned)le32_to_cpu(dresp->mnt[0].capacity))); 337 ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
338 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32)));
322 if ((le32_to_cpu(dresp->status) == ST_OK) && 339 if ((le32_to_cpu(dresp->status) == ST_OK) &&
323 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 340 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
324 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 341 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
325 fsa_dev_ptr[index].valid = 1; 342 fsa_dev_ptr[index].valid = 1;
326 fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol); 343 fsa_dev_ptr[index].type = le32_to_cpu(dresp->mnt[0].vol);
327 fsa_dev_ptr[index].size = le32_to_cpu(dresp->mnt[0].capacity); 344 fsa_dev_ptr[index].size
345 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
346 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
328 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) 347 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
329 fsa_dev_ptr[index].ro = 1; 348 fsa_dev_ptr[index].ro = 1;
330 } 349 }
@@ -460,7 +479,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd, int cid)
460 * is updated in the struct fsa_dev_info structure rather than returned. 479 * is updated in the struct fsa_dev_info structure rather than returned.
461 */ 480 */
462 481
463static int probe_container(struct aac_dev *dev, int cid) 482int probe_container(struct aac_dev *dev, int cid)
464{ 483{
465 struct fsa_dev_info *fsa_dev_ptr; 484 struct fsa_dev_info *fsa_dev_ptr;
466 int status; 485 int status;
@@ -497,11 +516,29 @@ static int probe_container(struct aac_dev *dev, int cid)
497 dresp = (struct aac_mount *) fib_data(fibptr); 516 dresp = (struct aac_mount *) fib_data(fibptr);
498 517
499 if ((le32_to_cpu(dresp->status) == ST_OK) && 518 if ((le32_to_cpu(dresp->status) == ST_OK) &&
519 (le32_to_cpu(dresp->mnt[0].vol) == CT_NONE)) {
520 dinfo->command = cpu_to_le32(VM_NameServe64);
521 dinfo->count = cpu_to_le32(cid);
522 dinfo->type = cpu_to_le32(FT_FILESYS);
523
524 if (fib_send(ContainerCommand,
525 fibptr,
526 sizeof(struct aac_query_mount),
527 FsaNormal,
528 1, 1,
529 NULL, NULL) < 0)
530 goto error;
531 } else
532 dresp->mnt[0].capacityhigh = 0;
533
534 if ((le32_to_cpu(dresp->status) == ST_OK) &&
500 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) && 535 (le32_to_cpu(dresp->mnt[0].vol) != CT_NONE) &&
501 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) { 536 (le32_to_cpu(dresp->mnt[0].state) != FSCS_HIDDEN)) {
502 fsa_dev_ptr[cid].valid = 1; 537 fsa_dev_ptr[cid].valid = 1;
503 fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol); 538 fsa_dev_ptr[cid].type = le32_to_cpu(dresp->mnt[0].vol);
504 fsa_dev_ptr[cid].size = le32_to_cpu(dresp->mnt[0].capacity); 539 fsa_dev_ptr[cid].size
540 = ((u64)le32_to_cpu(dresp->mnt[0].capacity)) +
541 (((u64)le32_to_cpu(dresp->mnt[0].capacityhigh)) << 32);
505 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY) 542 if (le32_to_cpu(dresp->mnt[0].state) & FSCS_READONLY)
506 fsa_dev_ptr[cid].ro = 1; 543 fsa_dev_ptr[cid].ro = 1;
507 } 544 }
@@ -655,7 +692,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
655 fibptr, 692 fibptr,
656 sizeof(*info), 693 sizeof(*info),
657 FsaNormal, 694 FsaNormal,
658 1, 1, 695 -1, 1, /* First `interrupt' command uses special wait */
659 NULL, 696 NULL,
660 NULL); 697 NULL);
661 698
@@ -806,8 +843,8 @@ int aac_get_adapter_info(struct aac_dev* dev)
806 if (!(dev->raw_io_interface)) { 843 if (!(dev->raw_io_interface)) {
807 dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - 844 dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size -
808 sizeof(struct aac_fibhdr) - 845 sizeof(struct aac_fibhdr) -
809 sizeof(struct aac_write) + sizeof(struct sgmap)) / 846 sizeof(struct aac_write) + sizeof(struct sgentry)) /
810 sizeof(struct sgmap); 847 sizeof(struct sgentry);
811 if (dev->dac_support) { 848 if (dev->dac_support) {
812 /* 849 /*
813 * 38 scatter gather elements 850 * 38 scatter gather elements
@@ -816,8 +853,8 @@ int aac_get_adapter_info(struct aac_dev* dev)
816 (dev->max_fib_size - 853 (dev->max_fib_size -
817 sizeof(struct aac_fibhdr) - 854 sizeof(struct aac_fibhdr) -
818 sizeof(struct aac_write64) + 855 sizeof(struct aac_write64) +
819 sizeof(struct sgmap64)) / 856 sizeof(struct sgentry64)) /
820 sizeof(struct sgmap64); 857 sizeof(struct sgentry64);
821 } 858 }
822 dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; 859 dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT;
823 if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { 860 if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) {
@@ -854,7 +891,40 @@ static void io_callback(void *context, struct fib * fibptr)
854 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 891 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
855 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun); 892 cid = ID_LUN_TO_CONTAINER(scsicmd->device->id, scsicmd->device->lun);
856 893
857 dprintk((KERN_DEBUG "io_callback[cpu %d]: lba = %u, t = %ld.\n", smp_processor_id(), ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3], jiffies)); 894 if (nblank(dprintk(x))) {
895 u64 lba;
896 switch (scsicmd->cmnd[0]) {
897 case WRITE_6:
898 case READ_6:
899 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
900 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
901 break;
902 case WRITE_16:
903 case READ_16:
904 lba = ((u64)scsicmd->cmnd[2] << 56) |
905 ((u64)scsicmd->cmnd[3] << 48) |
906 ((u64)scsicmd->cmnd[4] << 40) |
907 ((u64)scsicmd->cmnd[5] << 32) |
908 ((u64)scsicmd->cmnd[6] << 24) |
909 (scsicmd->cmnd[7] << 16) |
910 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
911 break;
912 case WRITE_12:
913 case READ_12:
914 lba = ((u64)scsicmd->cmnd[2] << 24) |
915 (scsicmd->cmnd[3] << 16) |
916 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
917 break;
918 default:
919 lba = ((u64)scsicmd->cmnd[2] << 24) |
920 (scsicmd->cmnd[3] << 16) |
921 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
922 break;
923 }
924 printk(KERN_DEBUG
925 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
926 smp_processor_id(), (unsigned long long)lba, jiffies);
927 }
858 928
859 if (fibptr == NULL) 929 if (fibptr == NULL)
860 BUG(); 930 BUG();
@@ -895,7 +965,7 @@ static void io_callback(void *context, struct fib * fibptr)
895 965
896static int aac_read(struct scsi_cmnd * scsicmd, int cid) 966static int aac_read(struct scsi_cmnd * scsicmd, int cid)
897{ 967{
898 u32 lba; 968 u64 lba;
899 u32 count; 969 u32 count;
900 int status; 970 int status;
901 971
@@ -907,23 +977,69 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
907 /* 977 /*
908 * Get block address and transfer length 978 * Get block address and transfer length
909 */ 979 */
910 if (scsicmd->cmnd[0] == READ_6) /* 6 byte command */ 980 switch (scsicmd->cmnd[0]) {
911 { 981 case READ_6:
912 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid)); 982 dprintk((KERN_DEBUG "aachba: received a read(6) command on id %d.\n", cid));
913 983
914 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) | (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3]; 984 lba = ((scsicmd->cmnd[1] & 0x1F) << 16) |
985 (scsicmd->cmnd[2] << 8) | scsicmd->cmnd[3];
915 count = scsicmd->cmnd[4]; 986 count = scsicmd->cmnd[4];
916 987
917 if (count == 0) 988 if (count == 0)
918 count = 256; 989 count = 256;
919 } else { 990 break;
991 case READ_16:
992 dprintk((KERN_DEBUG "aachba: received a read(16) command on id %d.\n", cid));
993
994 lba = ((u64)scsicmd->cmnd[2] << 56) |
995 ((u64)scsicmd->cmnd[3] << 48) |
996 ((u64)scsicmd->cmnd[4] << 40) |
997 ((u64)scsicmd->cmnd[5] << 32) |
998 ((u64)scsicmd->cmnd[6] << 24) |
999 (scsicmd->cmnd[7] << 16) |
1000 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1001 count = (scsicmd->cmnd[10] << 24) |
1002 (scsicmd->cmnd[11] << 16) |
1003 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
1004 break;
1005 case READ_12:
1006 dprintk((KERN_DEBUG "aachba: received a read(12) command on id %d.\n", cid));
1007
1008 lba = ((u64)scsicmd->cmnd[2] << 24) |
1009 (scsicmd->cmnd[3] << 16) |
1010 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1011 count = (scsicmd->cmnd[6] << 24) |
1012 (scsicmd->cmnd[7] << 16) |
1013 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1014 break;
1015 default:
920 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid)); 1016 dprintk((KERN_DEBUG "aachba: received a read(10) command on id %d.\n", cid));
921 1017
922 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 1018 lba = ((u64)scsicmd->cmnd[2] << 24) |
1019 (scsicmd->cmnd[3] << 16) |
1020 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
923 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; 1021 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1022 break;
924 } 1023 }
925 dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %u, t = %ld.\n", 1024 dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n",
926 smp_processor_id(), (unsigned long long)lba, jiffies)); 1025 smp_processor_id(), (unsigned long long)lba, jiffies));
1026 if ((!(dev->raw_io_interface) || !(dev->raw_io_64)) &&
1027 (lba & 0xffffffff00000000LL)) {
1028 dprintk((KERN_DEBUG "aac_read: Illegal lba\n"));
1029 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 |
1030 SAM_STAT_CHECK_CONDITION;
1031 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1032 HARDWARE_ERROR,
1033 SENCODE_INTERNAL_TARGET_FAILURE,
1034 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1035 0, 0);
1036 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1037 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1038 ? sizeof(scsicmd->sense_buffer)
1039 : sizeof(dev->fsa_dev[cid].sense_data));
1040 scsicmd->scsi_done(scsicmd);
1041 return 0;
1042 }
927 /* 1043 /*
928 * Alocate and initialize a Fib 1044 * Alocate and initialize a Fib
929 */ 1045 */
@@ -936,8 +1052,8 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
936 if (dev->raw_io_interface) { 1052 if (dev->raw_io_interface) {
937 struct aac_raw_io *readcmd; 1053 struct aac_raw_io *readcmd;
938 readcmd = (struct aac_raw_io *) fib_data(cmd_fibcontext); 1054 readcmd = (struct aac_raw_io *) fib_data(cmd_fibcontext);
939 readcmd->block[0] = cpu_to_le32(lba); 1055 readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff));
940 readcmd->block[1] = 0; 1056 readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
941 readcmd->count = cpu_to_le32(count<<9); 1057 readcmd->count = cpu_to_le32(count<<9);
942 readcmd->cid = cpu_to_le16(cid); 1058 readcmd->cid = cpu_to_le16(cid);
943 readcmd->flags = cpu_to_le16(1); 1059 readcmd->flags = cpu_to_le16(1);
@@ -964,7 +1080,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
964 readcmd->command = cpu_to_le32(VM_CtHostRead64); 1080 readcmd->command = cpu_to_le32(VM_CtHostRead64);
965 readcmd->cid = cpu_to_le16(cid); 1081 readcmd->cid = cpu_to_le16(cid);
966 readcmd->sector_count = cpu_to_le16(count); 1082 readcmd->sector_count = cpu_to_le16(count);
967 readcmd->block = cpu_to_le32(lba); 1083 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
968 readcmd->pad = 0; 1084 readcmd->pad = 0;
969 readcmd->flags = 0; 1085 readcmd->flags = 0;
970 1086
@@ -989,7 +1105,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
989 readcmd = (struct aac_read *) fib_data(cmd_fibcontext); 1105 readcmd = (struct aac_read *) fib_data(cmd_fibcontext);
990 readcmd->command = cpu_to_le32(VM_CtBlockRead); 1106 readcmd->command = cpu_to_le32(VM_CtBlockRead);
991 readcmd->cid = cpu_to_le32(cid); 1107 readcmd->cid = cpu_to_le32(cid);
992 readcmd->block = cpu_to_le32(lba); 1108 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
993 readcmd->count = cpu_to_le32(count * 512); 1109 readcmd->count = cpu_to_le32(count * 512);
994 1110
995 aac_build_sg(scsicmd, &readcmd->sg); 1111 aac_build_sg(scsicmd, &readcmd->sg);
@@ -1031,7 +1147,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid)
1031 1147
1032static int aac_write(struct scsi_cmnd * scsicmd, int cid) 1148static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1033{ 1149{
1034 u32 lba; 1150 u64 lba;
1035 u32 count; 1151 u32 count;
1036 int status; 1152 int status;
1037 u16 fibsize; 1153 u16 fibsize;
@@ -1048,13 +1164,48 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1048 count = scsicmd->cmnd[4]; 1164 count = scsicmd->cmnd[4];
1049 if (count == 0) 1165 if (count == 0)
1050 count = 256; 1166 count = 256;
1167 } else if (scsicmd->cmnd[0] == WRITE_16) { /* 16 byte command */
1168 dprintk((KERN_DEBUG "aachba: received a write(16) command on id %d.\n", cid));
1169
1170 lba = ((u64)scsicmd->cmnd[2] << 56) |
1171 ((u64)scsicmd->cmnd[3] << 48) |
1172 ((u64)scsicmd->cmnd[4] << 40) |
1173 ((u64)scsicmd->cmnd[5] << 32) |
1174 ((u64)scsicmd->cmnd[6] << 24) |
1175 (scsicmd->cmnd[7] << 16) |
1176 (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1177 count = (scsicmd->cmnd[10] << 24) | (scsicmd->cmnd[11] << 16) |
1178 (scsicmd->cmnd[12] << 8) | scsicmd->cmnd[13];
1179 } else if (scsicmd->cmnd[0] == WRITE_12) { /* 12 byte command */
1180 dprintk((KERN_DEBUG "aachba: received a write(12) command on id %d.\n", cid));
1181
1182 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16)
1183 | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1184 count = (scsicmd->cmnd[6] << 24) | (scsicmd->cmnd[7] << 16)
1185 | (scsicmd->cmnd[8] << 8) | scsicmd->cmnd[9];
1051 } else { 1186 } else {
1052 dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid)); 1187 dprintk((KERN_DEBUG "aachba: received a write(10) command on id %d.\n", cid));
1053 lba = (scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; 1188 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1054 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; 1189 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1055 } 1190 }
1056 dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %u, t = %ld.\n", 1191 dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n",
1057 smp_processor_id(), (unsigned long long)lba, jiffies)); 1192 smp_processor_id(), (unsigned long long)lba, jiffies));
1193 if ((!(dev->raw_io_interface) || !(dev->raw_io_64))
1194 && (lba & 0xffffffff00000000LL)) {
1195 dprintk((KERN_DEBUG "aac_write: Illegal lba\n"));
1196 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1197 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1198 HARDWARE_ERROR,
1199 SENCODE_INTERNAL_TARGET_FAILURE,
1200 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1201 0, 0);
1202 memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1203 (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
1204 ? sizeof(scsicmd->sense_buffer)
1205 : sizeof(dev->fsa_dev[cid].sense_data));
1206 scsicmd->scsi_done(scsicmd);
1207 return 0;
1208 }
1058 /* 1209 /*
1059 * Allocate and initialize a Fib then setup a BlockWrite command 1210 * Allocate and initialize a Fib then setup a BlockWrite command
1060 */ 1211 */
@@ -1068,8 +1219,8 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1068 if (dev->raw_io_interface) { 1219 if (dev->raw_io_interface) {
1069 struct aac_raw_io *writecmd; 1220 struct aac_raw_io *writecmd;
1070 writecmd = (struct aac_raw_io *) fib_data(cmd_fibcontext); 1221 writecmd = (struct aac_raw_io *) fib_data(cmd_fibcontext);
1071 writecmd->block[0] = cpu_to_le32(lba); 1222 writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff));
1072 writecmd->block[1] = 0; 1223 writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32));
1073 writecmd->count = cpu_to_le32(count<<9); 1224 writecmd->count = cpu_to_le32(count<<9);
1074 writecmd->cid = cpu_to_le16(cid); 1225 writecmd->cid = cpu_to_le16(cid);
1075 writecmd->flags = 0; 1226 writecmd->flags = 0;
@@ -1096,7 +1247,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1096 writecmd->command = cpu_to_le32(VM_CtHostWrite64); 1247 writecmd->command = cpu_to_le32(VM_CtHostWrite64);
1097 writecmd->cid = cpu_to_le16(cid); 1248 writecmd->cid = cpu_to_le16(cid);
1098 writecmd->sector_count = cpu_to_le16(count); 1249 writecmd->sector_count = cpu_to_le16(count);
1099 writecmd->block = cpu_to_le32(lba); 1250 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
1100 writecmd->pad = 0; 1251 writecmd->pad = 0;
1101 writecmd->flags = 0; 1252 writecmd->flags = 0;
1102 1253
@@ -1121,7 +1272,7 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid)
1121 writecmd = (struct aac_write *) fib_data(cmd_fibcontext); 1272 writecmd = (struct aac_write *) fib_data(cmd_fibcontext);
1122 writecmd->command = cpu_to_le32(VM_CtBlockWrite); 1273 writecmd->command = cpu_to_le32(VM_CtBlockWrite);
1123 writecmd->cid = cpu_to_le32(cid); 1274 writecmd->cid = cpu_to_le32(cid);
1124 writecmd->block = cpu_to_le32(lba); 1275 writecmd->block = cpu_to_le32((u32)(lba&0xffffffff));
1125 writecmd->count = cpu_to_le32(count * 512); 1276 writecmd->count = cpu_to_le32(count * 512);
1126 writecmd->sg.count = cpu_to_le32(1); 1277 writecmd->sg.count = cpu_to_le32(1);
1127 /* ->stable is not used - it did mean which type of write */ 1278 /* ->stable is not used - it did mean which type of write */
@@ -1310,11 +1461,18 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1310 */ 1461 */
1311 if ((fsa_dev_ptr[cid].valid & 1) == 0) { 1462 if ((fsa_dev_ptr[cid].valid & 1) == 0) {
1312 switch (scsicmd->cmnd[0]) { 1463 switch (scsicmd->cmnd[0]) {
1464 case SERVICE_ACTION_IN:
1465 if (!(dev->raw_io_interface) ||
1466 !(dev->raw_io_64) ||
1467 ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
1468 break;
1313 case INQUIRY: 1469 case INQUIRY:
1314 case READ_CAPACITY: 1470 case READ_CAPACITY:
1315 case TEST_UNIT_READY: 1471 case TEST_UNIT_READY:
1316 spin_unlock_irq(host->host_lock); 1472 spin_unlock_irq(host->host_lock);
1317 probe_container(dev, cid); 1473 probe_container(dev, cid);
1474 if ((fsa_dev_ptr[cid].valid & 1) == 0)
1475 fsa_dev_ptr[cid].valid = 0;
1318 spin_lock_irq(host->host_lock); 1476 spin_lock_irq(host->host_lock);
1319 if (fsa_dev_ptr[cid].valid == 0) { 1477 if (fsa_dev_ptr[cid].valid == 0) {
1320 scsicmd->result = DID_NO_CONNECT << 16; 1478 scsicmd->result = DID_NO_CONNECT << 16;
@@ -1375,7 +1533,6 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1375 memset(&inq_data, 0, sizeof (struct inquiry_data)); 1533 memset(&inq_data, 0, sizeof (struct inquiry_data));
1376 1534
1377 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */ 1535 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */
1378 inq_data.inqd_dtq = 0x80; /* set RMB bit to one indicating that the medium is removable */
1379 inq_data.inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */ 1536 inq_data.inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
1380 inq_data.inqd_len = 31; 1537 inq_data.inqd_len = 31;
1381 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */ 1538 /*Format for "pad2" is RelAdr | WBus32 | WBus16 | Sync | Linked |Reserved| CmdQue | SftRe */
@@ -1397,13 +1554,55 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1397 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data)); 1554 aac_internal_transfer(scsicmd, &inq_data, 0, sizeof(inq_data));
1398 return aac_get_container_name(scsicmd, cid); 1555 return aac_get_container_name(scsicmd, cid);
1399 } 1556 }
1557 case SERVICE_ACTION_IN:
1558 if (!(dev->raw_io_interface) ||
1559 !(dev->raw_io_64) ||
1560 ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
1561 break;
1562 {
1563 u64 capacity;
1564 char cp[12];
1565 unsigned int offset = 0;
1566
1567 dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n"));
1568 capacity = fsa_dev_ptr[cid].size - 1;
1569 if (scsicmd->cmnd[13] > 12) {
1570 offset = scsicmd->cmnd[13] - 12;
1571 if (offset > sizeof(cp))
1572 break;
1573 memset(cp, 0, offset);
1574 aac_internal_transfer(scsicmd, cp, 0, offset);
1575 }
1576 cp[0] = (capacity >> 56) & 0xff;
1577 cp[1] = (capacity >> 48) & 0xff;
1578 cp[2] = (capacity >> 40) & 0xff;
1579 cp[3] = (capacity >> 32) & 0xff;
1580 cp[4] = (capacity >> 24) & 0xff;
1581 cp[5] = (capacity >> 16) & 0xff;
1582 cp[6] = (capacity >> 8) & 0xff;
1583 cp[7] = (capacity >> 0) & 0xff;
1584 cp[8] = 0;
1585 cp[9] = 0;
1586 cp[10] = 2;
1587 cp[11] = 0;
1588 aac_internal_transfer(scsicmd, cp, offset, sizeof(cp));
1589
1590 /* Do not cache partition table for arrays */
1591 scsicmd->device->removable = 1;
1592
1593 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1594 scsicmd->scsi_done(scsicmd);
1595
1596 return 0;
1597 }
1598
1400 case READ_CAPACITY: 1599 case READ_CAPACITY:
1401 { 1600 {
1402 u32 capacity; 1601 u32 capacity;
1403 char cp[8]; 1602 char cp[8];
1404 1603
1405 dprintk((KERN_DEBUG "READ CAPACITY command.\n")); 1604 dprintk((KERN_DEBUG "READ CAPACITY command.\n"));
1406 if (fsa_dev_ptr[cid].size <= 0x100000000LL) 1605 if (fsa_dev_ptr[cid].size <= 0x100000000ULL)
1407 capacity = fsa_dev_ptr[cid].size - 1; 1606 capacity = fsa_dev_ptr[cid].size - 1;
1408 else 1607 else
1409 capacity = (u32)-1; 1608 capacity = (u32)-1;
@@ -1417,6 +1616,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1417 cp[6] = 2; 1616 cp[6] = 2;
1418 cp[7] = 0; 1617 cp[7] = 0;
1419 aac_internal_transfer(scsicmd, cp, 0, sizeof(cp)); 1618 aac_internal_transfer(scsicmd, cp, 0, sizeof(cp));
1619 /* Do not cache partition table for arrays */
1620 scsicmd->device->removable = 1;
1420 1621
1421 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1622 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1422 scsicmd->scsi_done(scsicmd); 1623 scsicmd->scsi_done(scsicmd);
@@ -1497,6 +1698,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1497 { 1698 {
1498 case READ_6: 1699 case READ_6:
1499 case READ_10: 1700 case READ_10:
1701 case READ_12:
1702 case READ_16:
1500 /* 1703 /*
1501 * Hack to keep track of ordinal number of the device that 1704 * Hack to keep track of ordinal number of the device that
1502 * corresponds to a container. Needed to convert 1705 * corresponds to a container. Needed to convert
@@ -1504,17 +1707,19 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1504 */ 1707 */
1505 1708
1506 spin_unlock_irq(host->host_lock); 1709 spin_unlock_irq(host->host_lock);
1507 if (scsicmd->request->rq_disk) 1710 if (scsicmd->request->rq_disk)
1508 memcpy(fsa_dev_ptr[cid].devname, 1711 strlcpy(fsa_dev_ptr[cid].devname,
1509 scsicmd->request->rq_disk->disk_name, 1712 scsicmd->request->rq_disk->disk_name,
1510 8); 1713 min(sizeof(fsa_dev_ptr[cid].devname),
1511 1714 sizeof(scsicmd->request->rq_disk->disk_name) + 1));
1512 ret = aac_read(scsicmd, cid); 1715 ret = aac_read(scsicmd, cid);
1513 spin_lock_irq(host->host_lock); 1716 spin_lock_irq(host->host_lock);
1514 return ret; 1717 return ret;
1515 1718
1516 case WRITE_6: 1719 case WRITE_6:
1517 case WRITE_10: 1720 case WRITE_10:
1721 case WRITE_12:
1722 case WRITE_16:
1518 spin_unlock_irq(host->host_lock); 1723 spin_unlock_irq(host->host_lock);
1519 ret = aac_write(scsicmd, cid); 1724 ret = aac_write(scsicmd, cid);
1520 spin_lock_irq(host->host_lock); 1725 spin_lock_irq(host->host_lock);
@@ -1745,6 +1950,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
1745 case WRITE_10: 1950 case WRITE_10:
1746 case READ_12: 1951 case READ_12:
1747 case WRITE_12: 1952 case WRITE_12:
1953 case READ_16:
1954 case WRITE_16:
1748 if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) { 1955 if(le32_to_cpu(srbreply->data_xfer_length) < scsicmd->underflow ) {
1749 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n"); 1956 printk(KERN_WARNING"aacraid: SCSI CMD underflow\n");
1750 } else { 1957 } else {
@@ -1850,8 +2057,8 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
1850 sizeof(scsicmd->sense_buffer) : 2057 sizeof(scsicmd->sense_buffer) :
1851 le32_to_cpu(srbreply->sense_data_size); 2058 le32_to_cpu(srbreply->sense_data_size);
1852#ifdef AAC_DETAILED_STATUS_INFO 2059#ifdef AAC_DETAILED_STATUS_INFO
1853 dprintk((KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n", 2060 printk(KERN_WARNING "aac_srb_callback: check condition, status = %d len=%d\n",
1854 le32_to_cpu(srbreply->status), len)); 2061 le32_to_cpu(srbreply->status), len);
1855#endif 2062#endif
1856 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len); 2063 memcpy(scsicmd->sense_buffer, srbreply->sense_data, len);
1857 2064
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index e40528185d48..d54b1cc88d0d 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -1,6 +1,10 @@
1#if (!defined(dprintk)) 1#if (!defined(dprintk))
2# define dprintk(x) 2# define dprintk(x)
3#endif 3#endif
4/* eg: if (nblank(dprintk(x))) */
5#define _nblank(x) #x
6#define nblank(x) _nblank(x)[0]
7
4 8
5/*------------------------------------------------------------------------------ 9/*------------------------------------------------------------------------------
6 * D E F I N E S 10 * D E F I N E S
@@ -15,7 +19,7 @@
15#define AAC_MAX_LUN (8) 19#define AAC_MAX_LUN (8)
16 20
17#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff) 21#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
18#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)512) 22#define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)256)
19 23
20/* 24/*
21 * These macros convert from physical channels to virtual channels 25 * These macros convert from physical channels to virtual channels
@@ -302,7 +306,6 @@ enum aac_queue_types {
302 */ 306 */
303 307
304#define FsaNormal 1 308#define FsaNormal 1
305#define FsaHigh 2
306 309
307/* 310/*
308 * Define the FIB. The FIB is the where all the requested data and 311 * Define the FIB. The FIB is the where all the requested data and
@@ -546,8 +549,6 @@ struct aac_queue {
546 /* This is only valid for adapter to host command queues. */ 549 /* This is only valid for adapter to host command queues. */
547 spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */ 550 spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
548 spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */ 551 spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */
549 unsigned long SavedIrql; /* Previous IRQL when the spin lock is taken */
550 u32 padding; /* Padding - FIXME - can remove I believe */
551 struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */ 552 struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */
552 /* only valid for command queues which receive entries from the adapter. */ 553 /* only valid for command queues which receive entries from the adapter. */
553 struct list_head pendingq; /* A queue of outstanding fib's to the adapter. */ 554 struct list_head pendingq; /* A queue of outstanding fib's to the adapter. */
@@ -776,7 +777,9 @@ struct fsa_dev_info {
776 u64 last; 777 u64 last;
777 u64 size; 778 u64 size;
778 u32 type; 779 u32 type;
780 u32 config_waiting_on;
779 u16 queue_depth; 781 u16 queue_depth;
782 u8 config_needed;
780 u8 valid; 783 u8 valid;
781 u8 ro; 784 u8 ro;
782 u8 locked; 785 u8 locked;
@@ -1012,6 +1015,7 @@ struct aac_dev
1012 /* macro side-effects BEWARE */ 1015 /* macro side-effects BEWARE */
1013# define raw_io_interface \ 1016# define raw_io_interface \
1014 init->InitStructRevision==cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4) 1017 init->InitStructRevision==cpu_to_le32(ADAPTER_INIT_STRUCT_REVISION_4)
1018 u8 raw_io_64;
1015 u8 printf_enabled; 1019 u8 printf_enabled;
1016}; 1020};
1017 1021
@@ -1362,8 +1366,10 @@ struct aac_srb_reply
1362#define VM_CtBlockVerify64 18 1366#define VM_CtBlockVerify64 18
1363#define VM_CtHostRead64 19 1367#define VM_CtHostRead64 19
1364#define VM_CtHostWrite64 20 1368#define VM_CtHostWrite64 20
1369#define VM_DrvErrTblLog 21
1370#define VM_NameServe64 22
1365 1371
1366#define MAX_VMCOMMAND_NUM 21 /* used for sizing stats array - leave last */ 1372#define MAX_VMCOMMAND_NUM 23 /* used for sizing stats array - leave last */
1367 1373
1368/* 1374/*
1369 * Descriptive information (eg, vital stats) 1375 * Descriptive information (eg, vital stats)
@@ -1472,6 +1478,7 @@ struct aac_mntent {
1472 manager (eg, filesystem) */ 1478 manager (eg, filesystem) */
1473 __le32 altoid; /* != oid <==> snapshot or 1479 __le32 altoid; /* != oid <==> snapshot or
1474 broken mirror exists */ 1480 broken mirror exists */
1481 __le32 capacityhigh;
1475}; 1482};
1476 1483
1477#define FSCS_NOTCLEAN 0x0001 /* fsck is neccessary before mounting */ 1484#define FSCS_NOTCLEAN 0x0001 /* fsck is neccessary before mounting */
@@ -1707,6 +1714,7 @@ extern struct aac_common aac_config;
1707#define AifCmdJobProgress 2 /* Progress report */ 1714#define AifCmdJobProgress 2 /* Progress report */
1708#define AifJobCtrZero 101 /* Array Zero progress */ 1715#define AifJobCtrZero 101 /* Array Zero progress */
1709#define AifJobStsSuccess 1 /* Job completes */ 1716#define AifJobStsSuccess 1 /* Job completes */
1717#define AifJobStsRunning 102 /* Job running */
1710#define AifCmdAPIReport 3 /* Report from other user of API */ 1718#define AifCmdAPIReport 3 /* Report from other user of API */
1711#define AifCmdDriverNotify 4 /* Notify host driver of event */ 1719#define AifCmdDriverNotify 4 /* Notify host driver of event */
1712#define AifDenMorphComplete 200 /* A morph operation completed */ 1720#define AifDenMorphComplete 200 /* A morph operation completed */
@@ -1777,6 +1785,7 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size);
1777struct aac_driver_ident* aac_get_driver_ident(int devtype); 1785struct aac_driver_ident* aac_get_driver_ident(int devtype);
1778int aac_get_adapter_info(struct aac_dev* dev); 1786int aac_get_adapter_info(struct aac_dev* dev);
1779int aac_send_shutdown(struct aac_dev *dev); 1787int aac_send_shutdown(struct aac_dev *dev);
1788int probe_container(struct aac_dev *dev, int cid);
1780extern int numacb; 1789extern int numacb;
1781extern int acbsize; 1790extern int acbsize;
1782extern char aac_driver_version[]; 1791extern char aac_driver_version[];
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 75abd0453289..59a341b2aedc 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -195,7 +195,7 @@ int aac_send_shutdown(struct aac_dev * dev)
195 fibctx, 195 fibctx,
196 sizeof(struct aac_close), 196 sizeof(struct aac_close),
197 FsaNormal, 197 FsaNormal,
198 1, 1, 198 -2 /* Timeout silently */, 1,
199 NULL, NULL); 199 NULL, NULL);
200 200
201 if (status == 0) 201 if (status == 0)
@@ -313,8 +313,15 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
313 dev->max_fib_size = sizeof(struct hw_fib); 313 dev->max_fib_size = sizeof(struct hw_fib);
314 dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size 314 dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size
315 - sizeof(struct aac_fibhdr) 315 - sizeof(struct aac_fibhdr)
316 - sizeof(struct aac_write) + sizeof(struct sgmap)) 316 - sizeof(struct aac_write) + sizeof(struct sgentry))
317 / sizeof(struct sgmap); 317 / sizeof(struct sgentry);
318 dev->raw_io_64 = 0;
319 if ((!aac_adapter_sync_cmd(dev, GET_ADAPTER_PROPERTIES,
320 0, 0, 0, 0, 0, 0, status+0, status+1, status+2, NULL, NULL)) &&
321 (status[0] == 0x00000001)) {
322 if (status[1] & AAC_OPT_NEW_COMM_64)
323 dev->raw_io_64 = 1;
324 }
318 if ((!aac_adapter_sync_cmd(dev, GET_COMM_PREFERRED_SETTINGS, 325 if ((!aac_adapter_sync_cmd(dev, GET_COMM_PREFERRED_SETTINGS,
319 0, 0, 0, 0, 0, 0, 326 0, 0, 0, 0, 0, 0,
320 status+0, status+1, status+2, status+3, status+4)) 327 status+0, status+1, status+2, status+3, status+4))
@@ -342,8 +349,8 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
342 dev->max_fib_size = 512; 349 dev->max_fib_size = 512;
343 dev->sg_tablesize = host->sg_tablesize 350 dev->sg_tablesize = host->sg_tablesize
344 = (512 - sizeof(struct aac_fibhdr) 351 = (512 - sizeof(struct aac_fibhdr)
345 - sizeof(struct aac_write) + sizeof(struct sgmap)) 352 - sizeof(struct aac_write) + sizeof(struct sgentry))
346 / sizeof(struct sgmap); 353 / sizeof(struct sgentry);
347 host->can_queue = AAC_NUM_IO_FIB; 354 host->can_queue = AAC_NUM_IO_FIB;
348 } else if (acbsize == 2048) { 355 } else if (acbsize == 2048) {
349 host->max_sectors = 512; 356 host->max_sectors = 512;
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index a1d303f03480..e4d543a474ae 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -39,7 +39,9 @@
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/blkdev.h> 40#include <linux/blkdev.h>
41#include <scsi/scsi_host.h> 41#include <scsi/scsi_host.h>
42#include <scsi/scsi_device.h>
42#include <asm/semaphore.h> 43#include <asm/semaphore.h>
44#include <asm/delay.h>
43 45
44#include "aacraid.h" 46#include "aacraid.h"
45 47
@@ -269,40 +271,22 @@ static int aac_get_entry (struct aac_dev * dev, u32 qid, struct aac_entry **entr
269 /* Interrupt Moderation, only interrupt for first two entries */ 271 /* Interrupt Moderation, only interrupt for first two entries */
270 if (idx != le32_to_cpu(*(q->headers.consumer))) { 272 if (idx != le32_to_cpu(*(q->headers.consumer))) {
271 if (--idx == 0) { 273 if (--idx == 0) {
272 if (qid == AdapHighCmdQueue) 274 if (qid == AdapNormCmdQueue)
273 idx = ADAP_HIGH_CMD_ENTRIES;
274 else if (qid == AdapNormCmdQueue)
275 idx = ADAP_NORM_CMD_ENTRIES; 275 idx = ADAP_NORM_CMD_ENTRIES;
276 else if (qid == AdapHighRespQueue) 276 else
277 idx = ADAP_HIGH_RESP_ENTRIES;
278 else if (qid == AdapNormRespQueue)
279 idx = ADAP_NORM_RESP_ENTRIES; 277 idx = ADAP_NORM_RESP_ENTRIES;
280 } 278 }
281 if (idx != le32_to_cpu(*(q->headers.consumer))) 279 if (idx != le32_to_cpu(*(q->headers.consumer)))
282 *nonotify = 1; 280 *nonotify = 1;
283 } 281 }
284 282
285 if (qid == AdapHighCmdQueue) { 283 if (qid == AdapNormCmdQueue) {
286 if (*index >= ADAP_HIGH_CMD_ENTRIES)
287 *index = 0;
288 } else if (qid == AdapNormCmdQueue) {
289 if (*index >= ADAP_NORM_CMD_ENTRIES) 284 if (*index >= ADAP_NORM_CMD_ENTRIES)
290 *index = 0; /* Wrap to front of the Producer Queue. */ 285 *index = 0; /* Wrap to front of the Producer Queue. */
291 } 286 } else {
292 else if (qid == AdapHighRespQueue)
293 {
294 if (*index >= ADAP_HIGH_RESP_ENTRIES)
295 *index = 0;
296 }
297 else if (qid == AdapNormRespQueue)
298 {
299 if (*index >= ADAP_NORM_RESP_ENTRIES) 287 if (*index >= ADAP_NORM_RESP_ENTRIES)
300 *index = 0; /* Wrap to front of the Producer Queue. */ 288 *index = 0; /* Wrap to front of the Producer Queue. */
301 } 289 }
302 else {
303 printk("aacraid: invalid qid\n");
304 BUG();
305 }
306 290
307 if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */ 291 if ((*index + 1) == le32_to_cpu(*(q->headers.consumer))) { /* Queue is full */
308 printk(KERN_WARNING "Queue %d full, %u outstanding.\n", 292 printk(KERN_WARNING "Queue %d full, %u outstanding.\n",
@@ -334,12 +318,8 @@ static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_f
334{ 318{
335 struct aac_entry * entry = NULL; 319 struct aac_entry * entry = NULL;
336 int map = 0; 320 int map = 0;
337 struct aac_queue * q = &dev->queues->queue[qid];
338
339 spin_lock_irqsave(q->lock, q->SavedIrql);
340 321
341 if (qid == AdapHighCmdQueue || qid == AdapNormCmdQueue) 322 if (qid == AdapNormCmdQueue) {
342 {
343 /* if no entries wait for some if caller wants to */ 323 /* if no entries wait for some if caller wants to */
344 while (!aac_get_entry(dev, qid, &entry, index, nonotify)) 324 while (!aac_get_entry(dev, qid, &entry, index, nonotify))
345 { 325 {
@@ -350,9 +330,7 @@ static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_f
350 */ 330 */
351 entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size)); 331 entry->size = cpu_to_le32(le16_to_cpu(hw_fib->header.Size));
352 map = 1; 332 map = 1;
353 } 333 } else {
354 else if (qid == AdapHighRespQueue || qid == AdapNormRespQueue)
355 {
356 while(!aac_get_entry(dev, qid, &entry, index, nonotify)) 334 while(!aac_get_entry(dev, qid, &entry, index, nonotify))
357 { 335 {
358 /* if no entries wait for some if caller wants to */ 336 /* if no entries wait for some if caller wants to */
@@ -375,42 +353,6 @@ static int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_f
375 return 0; 353 return 0;
376} 354}
377 355
378
379/**
380 * aac_insert_entry - insert a queue entry
381 * @dev: Adapter
382 * @index: Index of entry to insert
383 * @qid: Queue number
384 * @nonotify: Suppress adapter notification
385 *
386 * Gets the next free QE off the requested priorty adapter command
387 * queue and associates the Fib with the QE. The QE represented by
388 * index is ready to insert on the queue when this routine returns
389 * success.
390 */
391
392static int aac_insert_entry(struct aac_dev * dev, u32 index, u32 qid, unsigned long nonotify)
393{
394 struct aac_queue * q = &dev->queues->queue[qid];
395
396 if(q == NULL)
397 BUG();
398 *(q->headers.producer) = cpu_to_le32(index + 1);
399 spin_unlock_irqrestore(q->lock, q->SavedIrql);
400
401 if (qid == AdapHighCmdQueue ||
402 qid == AdapNormCmdQueue ||
403 qid == AdapHighRespQueue ||
404 qid == AdapNormRespQueue)
405 {
406 if (!nonotify)
407 aac_adapter_notify(dev, qid);
408 }
409 else
410 printk("Suprise insert!\n");
411 return 0;
412}
413
414/* 356/*
415 * Define the highest level of host to adapter communication routines. 357 * Define the highest level of host to adapter communication routines.
416 * These routines will support host to adapter FS commuication. These 358 * These routines will support host to adapter FS commuication. These
@@ -439,12 +381,13 @@ static int aac_insert_entry(struct aac_dev * dev, u32 index, u32 qid, unsigned l
439int fib_send(u16 command, struct fib * fibptr, unsigned long size, int priority, int wait, int reply, fib_callback callback, void * callback_data) 381int fib_send(u16 command, struct fib * fibptr, unsigned long size, int priority, int wait, int reply, fib_callback callback, void * callback_data)
440{ 382{
441 u32 index; 383 u32 index;
442 u32 qid;
443 struct aac_dev * dev = fibptr->dev; 384 struct aac_dev * dev = fibptr->dev;
444 unsigned long nointr = 0; 385 unsigned long nointr = 0;
445 struct hw_fib * hw_fib = fibptr->hw_fib; 386 struct hw_fib * hw_fib = fibptr->hw_fib;
446 struct aac_queue * q; 387 struct aac_queue * q;
447 unsigned long flags = 0; 388 unsigned long flags = 0;
389 unsigned long qflags;
390
448 if (!(hw_fib->header.XferState & cpu_to_le32(HostOwned))) 391 if (!(hw_fib->header.XferState & cpu_to_le32(HostOwned)))
449 return -EBUSY; 392 return -EBUSY;
450 /* 393 /*
@@ -497,26 +440,8 @@ int fib_send(u16 command, struct fib * fibptr, unsigned long size, int priority
497 * Get a queue entry connect the FIB to it and send an notify 440 * Get a queue entry connect the FIB to it and send an notify
498 * the adapter a command is ready. 441 * the adapter a command is ready.
499 */ 442 */
500 if (priority == FsaHigh) { 443 hw_fib->header.XferState |= cpu_to_le32(NormalPriority);
501 hw_fib->header.XferState |= cpu_to_le32(HighPriority);
502 qid = AdapHighCmdQueue;
503 } else {
504 hw_fib->header.XferState |= cpu_to_le32(NormalPriority);
505 qid = AdapNormCmdQueue;
506 }
507 q = &dev->queues->queue[qid];
508 444
509 if(wait)
510 spin_lock_irqsave(&fibptr->event_lock, flags);
511 if(aac_queue_get( dev, &index, qid, hw_fib, 1, fibptr, &nointr)<0)
512 return -EWOULDBLOCK;
513 dprintk((KERN_DEBUG "fib_send: inserting a queue entry at index %d.\n",index));
514 dprintk((KERN_DEBUG "Fib contents:.\n"));
515 dprintk((KERN_DEBUG " Command = %d.\n", hw_fib->header.Command));
516 dprintk((KERN_DEBUG " XferState = %x.\n", hw_fib->header.XferState));
517 dprintk((KERN_DEBUG " hw_fib va being sent=%p\n",fibptr->hw_fib));
518 dprintk((KERN_DEBUG " hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa));
519 dprintk((KERN_DEBUG " fib being sent=%p\n",fibptr));
520 /* 445 /*
521 * Fill in the Callback and CallbackContext if we are not 446 * Fill in the Callback and CallbackContext if we are not
522 * going to wait. 447 * going to wait.
@@ -525,22 +450,67 @@ int fib_send(u16 command, struct fib * fibptr, unsigned long size, int priority
525 fibptr->callback = callback; 450 fibptr->callback = callback;
526 fibptr->callback_data = callback_data; 451 fibptr->callback_data = callback_data;
527 } 452 }
528 FIB_COUNTER_INCREMENT(aac_config.FibsSent);
529 list_add_tail(&fibptr->queue, &q->pendingq);
530 q->numpending++;
531 453
532 fibptr->done = 0; 454 fibptr->done = 0;
533 fibptr->flags = 0; 455 fibptr->flags = 0;
534 456
535 if(aac_insert_entry(dev, index, qid, (nointr & aac_config.irq_mod)) < 0) 457 FIB_COUNTER_INCREMENT(aac_config.FibsSent);
536 return -EWOULDBLOCK; 458
459 dprintk((KERN_DEBUG "fib_send: inserting a queue entry at index %d.\n",index));
460 dprintk((KERN_DEBUG "Fib contents:.\n"));
461 dprintk((KERN_DEBUG " Command = %d.\n", hw_fib->header.Command));
462 dprintk((KERN_DEBUG " XferState = %x.\n", hw_fib->header.XferState));
463 dprintk((KERN_DEBUG " hw_fib va being sent=%p\n",fibptr->hw_fib));
464 dprintk((KERN_DEBUG " hw_fib pa being sent=%lx\n",(ulong)fibptr->hw_fib_pa));
465 dprintk((KERN_DEBUG " fib being sent=%p\n",fibptr));
466
467 q = &dev->queues->queue[AdapNormCmdQueue];
468
469 if(wait)
470 spin_lock_irqsave(&fibptr->event_lock, flags);
471 spin_lock_irqsave(q->lock, qflags);
472 aac_queue_get( dev, &index, AdapNormCmdQueue, hw_fib, 1, fibptr, &nointr);
473
474 list_add_tail(&fibptr->queue, &q->pendingq);
475 q->numpending++;
476 *(q->headers.producer) = cpu_to_le32(index + 1);
477 spin_unlock_irqrestore(q->lock, qflags);
478 if (!(nointr & aac_config.irq_mod))
479 aac_adapter_notify(dev, AdapNormCmdQueue);
537 /* 480 /*
538 * If the caller wanted us to wait for response wait now. 481 * If the caller wanted us to wait for response wait now.
539 */ 482 */
540 483
541 if (wait) { 484 if (wait) {
542 spin_unlock_irqrestore(&fibptr->event_lock, flags); 485 spin_unlock_irqrestore(&fibptr->event_lock, flags);
543 down(&fibptr->event_wait); 486 /* Only set for first known interruptable command */
487 if (wait < 0) {
488 /*
489 * *VERY* Dangerous to time out a command, the
490 * assumption is made that we have no hope of
491 * functioning because an interrupt routing or other
492 * hardware failure has occurred.
493 */
494 unsigned long count = 36000000L; /* 3 minutes */
495 unsigned long qflags;
496 while (down_trylock(&fibptr->event_wait)) {
497 if (--count == 0) {
498 spin_lock_irqsave(q->lock, qflags);
499 q->numpending--;
500 list_del(&fibptr->queue);
501 spin_unlock_irqrestore(q->lock, qflags);
502 if (wait == -1) {
503 printk(KERN_ERR "aacraid: fib_send: first asynchronous command timed out.\n"
504 "Usually a result of a PCI interrupt routing problem;\n"
505 "update mother board BIOS or consider utilizing one of\n"
506 "the SAFE mode kernel options (acpi, apic etc)\n");
507 }
508 return -ETIMEDOUT;
509 }
510 udelay(5);
511 }
512 } else
513 down(&fibptr->event_wait);
544 if(fibptr->done == 0) 514 if(fibptr->done == 0)
545 BUG(); 515 BUG();
546 516
@@ -622,15 +592,9 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid)
622 case HostNormCmdQueue: 592 case HostNormCmdQueue:
623 notify = HostNormCmdNotFull; 593 notify = HostNormCmdNotFull;
624 break; 594 break;
625 case HostHighCmdQueue:
626 notify = HostHighCmdNotFull;
627 break;
628 case HostNormRespQueue: 595 case HostNormRespQueue:
629 notify = HostNormRespNotFull; 596 notify = HostNormRespNotFull;
630 break; 597 break;
631 case HostHighRespQueue:
632 notify = HostHighRespNotFull;
633 break;
634 default: 598 default:
635 BUG(); 599 BUG();
636 return; 600 return;
@@ -652,9 +616,13 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size)
652{ 616{
653 struct hw_fib * hw_fib = fibptr->hw_fib; 617 struct hw_fib * hw_fib = fibptr->hw_fib;
654 struct aac_dev * dev = fibptr->dev; 618 struct aac_dev * dev = fibptr->dev;
619 struct aac_queue * q;
655 unsigned long nointr = 0; 620 unsigned long nointr = 0;
656 if (hw_fib->header.XferState == 0) 621 unsigned long qflags;
622
623 if (hw_fib->header.XferState == 0) {
657 return 0; 624 return 0;
625 }
658 /* 626 /*
659 * If we plan to do anything check the structure type first. 627 * If we plan to do anything check the structure type first.
660 */ 628 */
@@ -669,37 +637,21 @@ int fib_adapter_complete(struct fib * fibptr, unsigned short size)
669 * send the completed cdb to the adapter. 637 * send the completed cdb to the adapter.
670 */ 638 */
671 if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) { 639 if (hw_fib->header.XferState & cpu_to_le32(SentFromAdapter)) {
640 u32 index;
672 hw_fib->header.XferState |= cpu_to_le32(HostProcessed); 641 hw_fib->header.XferState |= cpu_to_le32(HostProcessed);
673 if (hw_fib->header.XferState & cpu_to_le32(HighPriority)) { 642 if (size) {
674 u32 index; 643 size += sizeof(struct aac_fibhdr);
675 if (size) 644 if (size > le16_to_cpu(hw_fib->header.SenderSize))
676 { 645 return -EMSGSIZE;
677 size += sizeof(struct aac_fibhdr); 646 hw_fib->header.Size = cpu_to_le16(size);
678 if (size > le16_to_cpu(hw_fib->header.SenderSize))
679 return -EMSGSIZE;
680 hw_fib->header.Size = cpu_to_le16(size);
681 }
682 if(aac_queue_get(dev, &index, AdapHighRespQueue, hw_fib, 1, NULL, &nointr) < 0) {
683 return -EWOULDBLOCK;
684 }
685 if (aac_insert_entry(dev, index, AdapHighRespQueue, (nointr & (int)aac_config.irq_mod)) != 0) {
686 }
687 } else if (hw_fib->header.XferState &
688 cpu_to_le32(NormalPriority)) {
689 u32 index;
690
691 if (size) {
692 size += sizeof(struct aac_fibhdr);
693 if (size > le16_to_cpu(hw_fib->header.SenderSize))
694 return -EMSGSIZE;
695 hw_fib->header.Size = cpu_to_le16(size);
696 }
697 if (aac_queue_get(dev, &index, AdapNormRespQueue, hw_fib, 1, NULL, &nointr) < 0)
698 return -EWOULDBLOCK;
699 if (aac_insert_entry(dev, index, AdapNormRespQueue, (nointr & (int)aac_config.irq_mod)) != 0)
700 {
701 }
702 } 647 }
648 q = &dev->queues->queue[AdapNormRespQueue];
649 spin_lock_irqsave(q->lock, qflags);
650 aac_queue_get(dev, &index, AdapNormRespQueue, hw_fib, 1, NULL, &nointr);
651 *(q->headers.producer) = cpu_to_le32(index + 1);
652 spin_unlock_irqrestore(q->lock, qflags);
653 if (!(nointr & (int)aac_config.irq_mod))
654 aac_adapter_notify(dev, AdapNormRespQueue);
703 } 655 }
704 else 656 else
705 { 657 {
@@ -791,6 +743,268 @@ void aac_printf(struct aac_dev *dev, u32 val)
791 memset(cp, 0, 256); 743 memset(cp, 0, 256);
792} 744}
793 745
746
747/**
748 * aac_handle_aif - Handle a message from the firmware
749 * @dev: Which adapter this fib is from
750 * @fibptr: Pointer to fibptr from adapter
751 *
752 * This routine handles a driver notify fib from the adapter and
753 * dispatches it to the appropriate routine for handling.
754 */
755
756static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
757{
758 struct hw_fib * hw_fib = fibptr->hw_fib;
759 struct aac_aifcmd * aifcmd = (struct aac_aifcmd *)hw_fib->data;
760 int busy;
761 u32 container;
762 struct scsi_device *device;
763 enum {
764 NOTHING,
765 DELETE,
766 ADD,
767 CHANGE
768 } device_config_needed;
769
770 /* Sniff for container changes */
771
772 if (!dev)
773 return;
774 container = (u32)-1;
775
776 /*
777 * We have set this up to try and minimize the number of
778 * re-configures that take place. As a result of this when
779 * certain AIF's come in we will set a flag waiting for another
780 * type of AIF before setting the re-config flag.
781 */
782 switch (le32_to_cpu(aifcmd->command)) {
783 case AifCmdDriverNotify:
784 switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {
785 /*
786 * Morph or Expand complete
787 */
788 case AifDenMorphComplete:
789 case AifDenVolumeExtendComplete:
790 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
791 if (container >= dev->maximum_num_containers)
792 break;
793
794 /*
795 * Find the Scsi_Device associated with the SCSI
796 * address. Make sure we have the right array, and if
797 * so set the flag to initiate a new re-config once we
798 * see an AifEnConfigChange AIF come through.
799 */
800
801 if ((dev != NULL) && (dev->scsi_host_ptr != NULL)) {
802 device = scsi_device_lookup(dev->scsi_host_ptr,
803 CONTAINER_TO_CHANNEL(container),
804 CONTAINER_TO_ID(container),
805 CONTAINER_TO_LUN(container));
806 if (device) {
807 dev->fsa_dev[container].config_needed = CHANGE;
808 dev->fsa_dev[container].config_waiting_on = AifEnConfigChange;
809 scsi_device_put(device);
810 }
811 }
812 }
813
814 /*
815 * If we are waiting on something and this happens to be
816 * that thing then set the re-configure flag.
817 */
818 if (container != (u32)-1) {
819 if (container >= dev->maximum_num_containers)
820 break;
821 if (dev->fsa_dev[container].config_waiting_on ==
822 le32_to_cpu(*(u32 *)aifcmd->data))
823 dev->fsa_dev[container].config_waiting_on = 0;
824 } else for (container = 0;
825 container < dev->maximum_num_containers; ++container) {
826 if (dev->fsa_dev[container].config_waiting_on ==
827 le32_to_cpu(*(u32 *)aifcmd->data))
828 dev->fsa_dev[container].config_waiting_on = 0;
829 }
830 break;
831
832 case AifCmdEventNotify:
833 switch (le32_to_cpu(((u32 *)aifcmd->data)[0])) {
834 /*
835 * Add an Array.
836 */
837 case AifEnAddContainer:
838 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
839 if (container >= dev->maximum_num_containers)
840 break;
841 dev->fsa_dev[container].config_needed = ADD;
842 dev->fsa_dev[container].config_waiting_on =
843 AifEnConfigChange;
844 break;
845
846 /*
847 * Delete an Array.
848 */
849 case AifEnDeleteContainer:
850 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
851 if (container >= dev->maximum_num_containers)
852 break;
853 dev->fsa_dev[container].config_needed = DELETE;
854 dev->fsa_dev[container].config_waiting_on =
855 AifEnConfigChange;
856 break;
857
858 /*
859 * Container change detected. If we currently are not
860 * waiting on something else, setup to wait on a Config Change.
861 */
862 case AifEnContainerChange:
863 container = le32_to_cpu(((u32 *)aifcmd->data)[1]);
864 if (container >= dev->maximum_num_containers)
865 break;
866 if (dev->fsa_dev[container].config_waiting_on)
867 break;
868 dev->fsa_dev[container].config_needed = CHANGE;
869 dev->fsa_dev[container].config_waiting_on =
870 AifEnConfigChange;
871 break;
872
873 case AifEnConfigChange:
874 break;
875
876 }
877
878 /*
879 * If we are waiting on something and this happens to be
880 * that thing then set the re-configure flag.
881 */
882 if (container != (u32)-1) {
883 if (container >= dev->maximum_num_containers)
884 break;
885 if (dev->fsa_dev[container].config_waiting_on ==
886 le32_to_cpu(*(u32 *)aifcmd->data))
887 dev->fsa_dev[container].config_waiting_on = 0;
888 } else for (container = 0;
889 container < dev->maximum_num_containers; ++container) {
890 if (dev->fsa_dev[container].config_waiting_on ==
891 le32_to_cpu(*(u32 *)aifcmd->data))
892 dev->fsa_dev[container].config_waiting_on = 0;
893 }
894 break;
895
896 case AifCmdJobProgress:
897 /*
898 * These are job progress AIF's. When a Clear is being
899 * done on a container it is initially created then hidden from
900 * the OS. When the clear completes we don't get a config
901 * change so we monitor the job status complete on a clear then
902 * wait for a container change.
903 */
904
905 if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))
906 && ((((u32 *)aifcmd->data)[6] == ((u32 *)aifcmd->data)[5])
907 || (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsSuccess)))) {
908 for (container = 0;
909 container < dev->maximum_num_containers;
910 ++container) {
911 /*
912 * Stomp on all config sequencing for all
913 * containers?
914 */
915 dev->fsa_dev[container].config_waiting_on =
916 AifEnContainerChange;
917 dev->fsa_dev[container].config_needed = ADD;
918 }
919 }
920 if ((((u32 *)aifcmd->data)[1] == cpu_to_le32(AifJobCtrZero))
921 && (((u32 *)aifcmd->data)[6] == 0)
922 && (((u32 *)aifcmd->data)[4] == cpu_to_le32(AifJobStsRunning))) {
923 for (container = 0;
924 container < dev->maximum_num_containers;
925 ++container) {
926 /*
927 * Stomp on all config sequencing for all
928 * containers?
929 */
930 dev->fsa_dev[container].config_waiting_on =
931 AifEnContainerChange;
932 dev->fsa_dev[container].config_needed = DELETE;
933 }
934 }
935 break;
936 }
937
938 device_config_needed = NOTHING;
939 for (container = 0; container < dev->maximum_num_containers;
940 ++container) {
941 if ((dev->fsa_dev[container].config_waiting_on == 0)
942 && (dev->fsa_dev[container].config_needed != NOTHING)) {
943 device_config_needed =
944 dev->fsa_dev[container].config_needed;
945 dev->fsa_dev[container].config_needed = NOTHING;
946 break;
947 }
948 }
949 if (device_config_needed == NOTHING)
950 return;
951
952 /*
953 * If we decided that a re-configuration needs to be done,
954 * schedule it here on the way out the door, please close the door
955 * behind you.
956 */
957
958 busy = 0;
959
960
961 /*
962 * Find the Scsi_Device associated with the SCSI address,
963 * and mark it as changed, invalidating the cache. This deals
964 * with changes to existing device IDs.
965 */
966
967 if (!dev || !dev->scsi_host_ptr)
968 return;
969 /*
970 * force reload of disk info via probe_container
971 */
972 if ((device_config_needed == CHANGE)
973 && (dev->fsa_dev[container].valid == 1))
974 dev->fsa_dev[container].valid = 2;
975 if ((device_config_needed == CHANGE) ||
976 (device_config_needed == ADD))
977 probe_container(dev, container);
978 device = scsi_device_lookup(dev->scsi_host_ptr,
979 CONTAINER_TO_CHANNEL(container),
980 CONTAINER_TO_ID(container),
981 CONTAINER_TO_LUN(container));
982 if (device) {
983 switch (device_config_needed) {
984 case DELETE:
985 scsi_remove_device(device);
986 break;
987 case CHANGE:
988 if (!dev->fsa_dev[container].valid) {
989 scsi_remove_device(device);
990 break;
991 }
992 scsi_rescan_device(&device->sdev_gendev);
993
994 default:
995 break;
996 }
997 scsi_device_put(device);
998 }
999 if (device_config_needed == ADD) {
1000 scsi_add_device(dev->scsi_host_ptr,
1001 CONTAINER_TO_CHANNEL(container),
1002 CONTAINER_TO_ID(container),
1003 CONTAINER_TO_LUN(container));
1004 }
1005
1006}
1007
794/** 1008/**
795 * aac_command_thread - command processing thread 1009 * aac_command_thread - command processing thread
796 * @dev: Adapter to monitor 1010 * @dev: Adapter to monitor
@@ -805,7 +1019,6 @@ int aac_command_thread(struct aac_dev * dev)
805{ 1019{
806 struct hw_fib *hw_fib, *hw_newfib; 1020 struct hw_fib *hw_fib, *hw_newfib;
807 struct fib *fib, *newfib; 1021 struct fib *fib, *newfib;
808 struct aac_queue_block *queues = dev->queues;
809 struct aac_fib_context *fibctx; 1022 struct aac_fib_context *fibctx;
810 unsigned long flags; 1023 unsigned long flags;
811 DECLARE_WAITQUEUE(wait, current); 1024 DECLARE_WAITQUEUE(wait, current);
@@ -825,21 +1038,22 @@ int aac_command_thread(struct aac_dev * dev)
825 * Let the DPC know it has a place to send the AIF's to. 1038 * Let the DPC know it has a place to send the AIF's to.
826 */ 1039 */
827 dev->aif_thread = 1; 1040 dev->aif_thread = 1;
828 add_wait_queue(&queues->queue[HostNormCmdQueue].cmdready, &wait); 1041 add_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
829 set_current_state(TASK_INTERRUPTIBLE); 1042 set_current_state(TASK_INTERRUPTIBLE);
1043 dprintk ((KERN_INFO "aac_command_thread start\n"));
830 while(1) 1044 while(1)
831 { 1045 {
832 spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags); 1046 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
833 while(!list_empty(&(queues->queue[HostNormCmdQueue].cmdq))) { 1047 while(!list_empty(&(dev->queues->queue[HostNormCmdQueue].cmdq))) {
834 struct list_head *entry; 1048 struct list_head *entry;
835 struct aac_aifcmd * aifcmd; 1049 struct aac_aifcmd * aifcmd;
836 1050
837 set_current_state(TASK_RUNNING); 1051 set_current_state(TASK_RUNNING);
838 1052
839 entry = queues->queue[HostNormCmdQueue].cmdq.next; 1053 entry = dev->queues->queue[HostNormCmdQueue].cmdq.next;
840 list_del(entry); 1054 list_del(entry);
841 1055
842 spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags); 1056 spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
843 fib = list_entry(entry, struct fib, fiblink); 1057 fib = list_entry(entry, struct fib, fiblink);
844 /* 1058 /*
845 * We will process the FIB here or pass it to a 1059 * We will process the FIB here or pass it to a
@@ -860,6 +1074,7 @@ int aac_command_thread(struct aac_dev * dev)
860 aifcmd = (struct aac_aifcmd *) hw_fib->data; 1074 aifcmd = (struct aac_aifcmd *) hw_fib->data;
861 if (aifcmd->command == cpu_to_le32(AifCmdDriverNotify)) { 1075 if (aifcmd->command == cpu_to_le32(AifCmdDriverNotify)) {
862 /* Handle Driver Notify Events */ 1076 /* Handle Driver Notify Events */
1077 aac_handle_aif(dev, fib);
863 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK); 1078 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
864 fib_adapter_complete(fib, (u16)sizeof(u32)); 1079 fib_adapter_complete(fib, (u16)sizeof(u32));
865 } else { 1080 } else {
@@ -869,9 +1084,62 @@ int aac_command_thread(struct aac_dev * dev)
869 1084
870 u32 time_now, time_last; 1085 u32 time_now, time_last;
871 unsigned long flagv; 1086 unsigned long flagv;
872 1087 unsigned num;
1088 struct hw_fib ** hw_fib_pool, ** hw_fib_p;
1089 struct fib ** fib_pool, ** fib_p;
1090
1091 /* Sniff events */
1092 if ((aifcmd->command ==
1093 cpu_to_le32(AifCmdEventNotify)) ||
1094 (aifcmd->command ==
1095 cpu_to_le32(AifCmdJobProgress))) {
1096 aac_handle_aif(dev, fib);
1097 }
1098
873 time_now = jiffies/HZ; 1099 time_now = jiffies/HZ;
874 1100
1101 /*
1102 * Warning: no sleep allowed while
1103 * holding spinlock. We take the estimate
1104 * and pre-allocate a set of fibs outside the
1105 * lock.
1106 */
1107 num = le32_to_cpu(dev->init->AdapterFibsSize)
1108 / sizeof(struct hw_fib); /* some extra */
1109 spin_lock_irqsave(&dev->fib_lock, flagv);
1110 entry = dev->fib_list.next;
1111 while (entry != &dev->fib_list) {
1112 entry = entry->next;
1113 ++num;
1114 }
1115 spin_unlock_irqrestore(&dev->fib_lock, flagv);
1116 hw_fib_pool = NULL;
1117 fib_pool = NULL;
1118 if (num
1119 && ((hw_fib_pool = kmalloc(sizeof(struct hw_fib *) * num, GFP_KERNEL)))
1120 && ((fib_pool = kmalloc(sizeof(struct fib *) * num, GFP_KERNEL)))) {
1121 hw_fib_p = hw_fib_pool;
1122 fib_p = fib_pool;
1123 while (hw_fib_p < &hw_fib_pool[num]) {
1124 if (!(*(hw_fib_p++) = kmalloc(sizeof(struct hw_fib), GFP_KERNEL))) {
1125 --hw_fib_p;
1126 break;
1127 }
1128 if (!(*(fib_p++) = kmalloc(sizeof(struct fib), GFP_KERNEL))) {
1129 kfree(*(--hw_fib_p));
1130 break;
1131 }
1132 }
1133 if ((num = hw_fib_p - hw_fib_pool) == 0) {
1134 kfree(fib_pool);
1135 fib_pool = NULL;
1136 kfree(hw_fib_pool);
1137 hw_fib_pool = NULL;
1138 }
1139 } else if (hw_fib_pool) {
1140 kfree(hw_fib_pool);
1141 hw_fib_pool = NULL;
1142 }
875 spin_lock_irqsave(&dev->fib_lock, flagv); 1143 spin_lock_irqsave(&dev->fib_lock, flagv);
876 entry = dev->fib_list.next; 1144 entry = dev->fib_list.next;
877 /* 1145 /*
@@ -880,6 +1148,8 @@ int aac_command_thread(struct aac_dev * dev)
880 * fib, and then set the event to wake up the 1148 * fib, and then set the event to wake up the
881 * thread that is waiting for it. 1149 * thread that is waiting for it.
882 */ 1150 */
1151 hw_fib_p = hw_fib_pool;
1152 fib_p = fib_pool;
883 while (entry != &dev->fib_list) { 1153 while (entry != &dev->fib_list) {
884 /* 1154 /*
885 * Extract the fibctx 1155 * Extract the fibctx
@@ -912,9 +1182,11 @@ int aac_command_thread(struct aac_dev * dev)
912 * Warning: no sleep allowed while 1182 * Warning: no sleep allowed while
913 * holding spinlock 1183 * holding spinlock
914 */ 1184 */
915 hw_newfib = kmalloc(sizeof(struct hw_fib), GFP_ATOMIC); 1185 if (hw_fib_p < &hw_fib_pool[num]) {
916 newfib = kmalloc(sizeof(struct fib), GFP_ATOMIC); 1186 hw_newfib = *hw_fib_p;
917 if (newfib && hw_newfib) { 1187 *(hw_fib_p++) = NULL;
1188 newfib = *fib_p;
1189 *(fib_p++) = NULL;
918 /* 1190 /*
919 * Make the copy of the FIB 1191 * Make the copy of the FIB
920 */ 1192 */
@@ -929,15 +1201,11 @@ int aac_command_thread(struct aac_dev * dev)
929 fibctx->count++; 1201 fibctx->count++;
930 /* 1202 /*
931 * Set the event to wake up the 1203 * Set the event to wake up the
932 * thread that will waiting. 1204 * thread that is waiting.
933 */ 1205 */
934 up(&fibctx->wait_sem); 1206 up(&fibctx->wait_sem);
935 } else { 1207 } else {
936 printk(KERN_WARNING "aifd: didn't allocate NewFib.\n"); 1208 printk(KERN_WARNING "aifd: didn't allocate NewFib.\n");
937 if(newfib)
938 kfree(newfib);
939 if(hw_newfib)
940 kfree(hw_newfib);
941 } 1209 }
942 entry = entry->next; 1210 entry = entry->next;
943 } 1211 }
@@ -947,21 +1215,38 @@ int aac_command_thread(struct aac_dev * dev)
947 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK); 1215 *(__le32 *)hw_fib->data = cpu_to_le32(ST_OK);
948 fib_adapter_complete(fib, sizeof(u32)); 1216 fib_adapter_complete(fib, sizeof(u32));
949 spin_unlock_irqrestore(&dev->fib_lock, flagv); 1217 spin_unlock_irqrestore(&dev->fib_lock, flagv);
1218 /* Free up the remaining resources */
1219 hw_fib_p = hw_fib_pool;
1220 fib_p = fib_pool;
1221 while (hw_fib_p < &hw_fib_pool[num]) {
1222 if (*hw_fib_p)
1223 kfree(*hw_fib_p);
1224 if (*fib_p)
1225 kfree(*fib_p);
1226 ++fib_p;
1227 ++hw_fib_p;
1228 }
1229 if (hw_fib_pool)
1230 kfree(hw_fib_pool);
1231 if (fib_pool)
1232 kfree(fib_pool);
950 } 1233 }
951 spin_lock_irqsave(queues->queue[HostNormCmdQueue].lock, flags);
952 kfree(fib); 1234 kfree(fib);
1235 spin_lock_irqsave(dev->queues->queue[HostNormCmdQueue].lock, flags);
953 } 1236 }
954 /* 1237 /*
955 * There are no more AIF's 1238 * There are no more AIF's
956 */ 1239 */
957 spin_unlock_irqrestore(queues->queue[HostNormCmdQueue].lock, flags); 1240 spin_unlock_irqrestore(dev->queues->queue[HostNormCmdQueue].lock, flags);
958 schedule(); 1241 schedule();
959 1242
960 if(signal_pending(current)) 1243 if(signal_pending(current))
961 break; 1244 break;
962 set_current_state(TASK_INTERRUPTIBLE); 1245 set_current_state(TASK_INTERRUPTIBLE);
963 } 1246 }
964 remove_wait_queue(&queues->queue[HostNormCmdQueue].cmdready, &wait); 1247 if (dev->queues)
1248 remove_wait_queue(&dev->queues->queue[HostNormCmdQueue].cmdready, &wait);
965 dev->aif_thread = 0; 1249 dev->aif_thread = 0;
966 complete_and_exit(&dev->aif_completion, 0); 1250 complete_and_exit(&dev->aif_completion, 0);
1251 return 0;
967} 1252}
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 4ff29d7f5825..a1f9ceef0ac9 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -453,9 +453,9 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
453 /* 453 /*
454 * We can exit If all the commands are complete 454 * We can exit If all the commands are complete
455 */ 455 */
456 spin_unlock_irq(host->host_lock);
456 if (active == 0) 457 if (active == 0)
457 return SUCCESS; 458 return SUCCESS;
458 spin_unlock_irq(host->host_lock);
459 ssleep(1); 459 ssleep(1);
460 spin_lock_irq(host->host_lock); 460 spin_lock_irq(host->host_lock);
461 } 461 }
@@ -748,7 +748,8 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
748 unique_id++; 748 unique_id++;
749 } 749 }
750 750
751 if (pci_enable_device(pdev)) 751 error = pci_enable_device(pdev);
752 if (error)
752 goto out; 753 goto out;
753 754
754 if (pci_set_dma_mask(pdev, 0xFFFFFFFFULL) || 755 if (pci_set_dma_mask(pdev, 0xFFFFFFFFULL) ||
@@ -772,6 +773,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
772 shost->irq = pdev->irq; 773 shost->irq = pdev->irq;
773 shost->base = pci_resource_start(pdev, 0); 774 shost->base = pci_resource_start(pdev, 0);
774 shost->unique_id = unique_id; 775 shost->unique_id = unique_id;
776 shost->max_cmd_len = 16;
775 777
776 aac = (struct aac_dev *)shost->hostdata; 778 aac = (struct aac_dev *)shost->hostdata;
777 aac->scsi_host_ptr = shost; 779 aac->scsi_host_ptr = shost;
@@ -799,7 +801,9 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
799 goto out_free_fibs; 801 goto out_free_fibs;
800 802
801 aac->maximum_num_channels = aac_drivers[index].channels; 803 aac->maximum_num_channels = aac_drivers[index].channels;
802 aac_get_adapter_info(aac); 804 error = aac_get_adapter_info(aac);
805 if (error < 0)
806 goto out_deinit;
803 807
804 /* 808 /*
805 * Lets override negotiations and drop the maximum SG limit to 34 809 * Lets override negotiations and drop the maximum SG limit to 34
@@ -927,8 +931,8 @@ static int __init aac_init(void)
927 printk(KERN_INFO "Adaptec %s driver (%s)\n", 931 printk(KERN_INFO "Adaptec %s driver (%s)\n",
928 AAC_DRIVERNAME, aac_driver_version); 932 AAC_DRIVERNAME, aac_driver_version);
929 933
930 error = pci_module_init(&aac_pci_driver); 934 error = pci_register_driver(&aac_pci_driver);
931 if (error) 935 if (error < 0)
932 return error; 936 return error;
933 937
934 aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops); 938 aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops);
diff --git a/drivers/scsi/aic7xxx/aic7770_osm.c b/drivers/scsi/aic7xxx/aic7770_osm.c
index 70c5fb59c9ea..d754b3267863 100644
--- a/drivers/scsi/aic7xxx/aic7770_osm.c
+++ b/drivers/scsi/aic7xxx/aic7770_osm.c
@@ -112,6 +112,9 @@ aic7770_remove(struct device *dev)
112 struct ahc_softc *ahc = dev_get_drvdata(dev); 112 struct ahc_softc *ahc = dev_get_drvdata(dev);
113 u_long s; 113 u_long s;
114 114
115 if (ahc->platform_data && ahc->platform_data->host)
116 scsi_remove_host(ahc->platform_data->host);
117
115 ahc_lock(ahc, &s); 118 ahc_lock(ahc, &s);
116 ahc_intr_enable(ahc, FALSE); 119 ahc_intr_enable(ahc, FALSE);
117 ahc_unlock(ahc, &s); 120 ahc_unlock(ahc, &s);
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 6b6d4e287793..95c285cc83e4 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1192,11 +1192,6 @@ ahd_platform_free(struct ahd_softc *ahd)
1192 int i, j; 1192 int i, j;
1193 1193
1194 if (ahd->platform_data != NULL) { 1194 if (ahd->platform_data != NULL) {
1195 if (ahd->platform_data->host != NULL) {
1196 scsi_remove_host(ahd->platform_data->host);
1197 scsi_host_put(ahd->platform_data->host);
1198 }
1199
1200 /* destroy all of the device and target objects */ 1195 /* destroy all of the device and target objects */
1201 for (i = 0; i < AHD_NUM_TARGETS; i++) { 1196 for (i = 0; i < AHD_NUM_TARGETS; i++) {
1202 starget = ahd->platform_data->starget[i]; 1197 starget = ahd->platform_data->starget[i];
@@ -1226,6 +1221,9 @@ ahd_platform_free(struct ahd_softc *ahd)
1226 release_mem_region(ahd->platform_data->mem_busaddr, 1221 release_mem_region(ahd->platform_data->mem_busaddr,
1227 0x1000); 1222 0x1000);
1228 } 1223 }
1224 if (ahd->platform_data->host)
1225 scsi_host_put(ahd->platform_data->host);
1226
1229 free(ahd->platform_data, M_DEVBUF); 1227 free(ahd->platform_data, M_DEVBUF);
1230 } 1228 }
1231} 1229}
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 390b53852d4b..bf360ae021ab 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -95,6 +95,9 @@ ahd_linux_pci_dev_remove(struct pci_dev *pdev)
95 struct ahd_softc *ahd = pci_get_drvdata(pdev); 95 struct ahd_softc *ahd = pci_get_drvdata(pdev);
96 u_long s; 96 u_long s;
97 97
98 if (ahd->platform_data && ahd->platform_data->host)
99 scsi_remove_host(ahd->platform_data->host);
100
98 ahd_lock(ahd, &s); 101 ahd_lock(ahd, &s);
99 ahd_intr_enable(ahd, FALSE); 102 ahd_intr_enable(ahd, FALSE);
100 ahd_unlock(ahd, &s); 103 ahd_unlock(ahd, &s);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index c932b3b94490..6ee1435d37fa 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1109,15 +1109,6 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1109 return (0); 1109 return (0);
1110} 1110}
1111 1111
1112uint64_t
1113ahc_linux_get_memsize(void)
1114{
1115 struct sysinfo si;
1116
1117 si_meminfo(&si);
1118 return ((uint64_t)si.totalram << PAGE_SHIFT);
1119}
1120
1121/* 1112/*
1122 * Place the SCSI bus into a known state by either resetting it, 1113 * Place the SCSI bus into a known state by either resetting it,
1123 * or forcing transfer negotiations on the next command to any 1114 * or forcing transfer negotiations on the next command to any
@@ -1218,11 +1209,6 @@ ahc_platform_free(struct ahc_softc *ahc)
1218 int i, j; 1209 int i, j;
1219 1210
1220 if (ahc->platform_data != NULL) { 1211 if (ahc->platform_data != NULL) {
1221 if (ahc->platform_data->host != NULL) {
1222 scsi_remove_host(ahc->platform_data->host);
1223 scsi_host_put(ahc->platform_data->host);
1224 }
1225
1226 /* destroy all of the device and target objects */ 1212 /* destroy all of the device and target objects */
1227 for (i = 0; i < AHC_NUM_TARGETS; i++) { 1213 for (i = 0; i < AHC_NUM_TARGETS; i++) {
1228 starget = ahc->platform_data->starget[i]; 1214 starget = ahc->platform_data->starget[i];
@@ -1251,6 +1237,9 @@ ahc_platform_free(struct ahc_softc *ahc)
1251 0x1000); 1237 0x1000);
1252 } 1238 }
1253 1239
1240 if (ahc->platform_data->host)
1241 scsi_host_put(ahc->platform_data->host);
1242
1254 free(ahc->platform_data, M_DEVBUF); 1243 free(ahc->platform_data, M_DEVBUF);
1255 } 1244 }
1256} 1245}
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index c52996269240..be9edbe26dbe 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -494,8 +494,6 @@ ahc_insb(struct ahc_softc * ahc, long port, uint8_t *array, int count)
494int ahc_linux_register_host(struct ahc_softc *, 494int ahc_linux_register_host(struct ahc_softc *,
495 struct scsi_host_template *); 495 struct scsi_host_template *);
496 496
497uint64_t ahc_linux_get_memsize(void);
498
499/*************************** Pretty Printing **********************************/ 497/*************************** Pretty Printing **********************************/
500struct info_str { 498struct info_str {
501 char *buffer; 499 char *buffer;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index 0d44a6907dd2..cb30d9c1153d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -143,6 +143,9 @@ ahc_linux_pci_dev_remove(struct pci_dev *pdev)
143 struct ahc_softc *ahc = pci_get_drvdata(pdev); 143 struct ahc_softc *ahc = pci_get_drvdata(pdev);
144 u_long s; 144 u_long s;
145 145
146 if (ahc->platform_data && ahc->platform_data->host)
147 scsi_remove_host(ahc->platform_data->host);
148
146 ahc_lock(ahc, &s); 149 ahc_lock(ahc, &s);
147 ahc_intr_enable(ahc, FALSE); 150 ahc_intr_enable(ahc, FALSE);
148 ahc_unlock(ahc, &s); 151 ahc_unlock(ahc, &s);
@@ -180,6 +183,7 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
180 struct ahc_pci_identity *entry; 183 struct ahc_pci_identity *entry;
181 char *name; 184 char *name;
182 int error; 185 int error;
186 struct device *dev = &pdev->dev;
183 187
184 pci = pdev; 188 pci = pdev;
185 entry = ahc_find_pci_device(pci); 189 entry = ahc_find_pci_device(pci);
@@ -209,11 +213,12 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
209 pci_set_master(pdev); 213 pci_set_master(pdev);
210 214
211 if (sizeof(dma_addr_t) > 4 215 if (sizeof(dma_addr_t) > 4
212 && ahc_linux_get_memsize() > 0x80000000 216 && ahc->features & AHC_LARGE_SCBS
213 && pci_set_dma_mask(pdev, mask_39bit) == 0) { 217 && dma_set_mask(dev, mask_39bit) == 0
218 && dma_get_required_mask(dev) > DMA_32BIT_MASK) {
214 ahc->flags |= AHC_39BIT_ADDRESSING; 219 ahc->flags |= AHC_39BIT_ADDRESSING;
215 } else { 220 } else {
216 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 221 if (dma_set_mask(dev, DMA_32BIT_MASK)) {
217 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); 222 printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
218 return (-ENODEV); 223 return (-ENODEV);
219 } 224 }
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 87e0c36f1554..d71cef767cec 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -442,7 +442,6 @@ static void piix_sata_phy_reset(struct ata_port *ap)
442 * piix_set_piomode - Initialize host controller PATA PIO timings 442 * piix_set_piomode - Initialize host controller PATA PIO timings
443 * @ap: Port whose timings we are configuring 443 * @ap: Port whose timings we are configuring
444 * @adev: um 444 * @adev: um
445 * @pio: PIO mode, 0 - 4
446 * 445 *
447 * Set PIO mode for device, in host controller PCI config space. 446 * Set PIO mode for device, in host controller PCI config space.
448 * 447 *
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index e6153fe5842a..a8cfbef304b5 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -996,6 +996,7 @@ oktosend:
996#ifdef ED_DBGP 996#ifdef ED_DBGP
997 printk("send_s870: prdaddr_2 0x%8x tmpcip %x target_id %d\n", dev->id[c][target_id].prdaddr,tmpcip,target_id); 997 printk("send_s870: prdaddr_2 0x%8x tmpcip %x target_id %d\n", dev->id[c][target_id].prdaddr,tmpcip,target_id);
998#endif 998#endif
999 dev->id[c][target_id].prdaddr = dev->id[c][target_id].prd_bus;
999 outl(dev->id[c][target_id].prdaddr, tmpcip); 1000 outl(dev->id[c][target_id].prdaddr, tmpcip);
1000 tmpcip = tmpcip - 2; 1001 tmpcip = tmpcip - 2;
1001 outb(0x06, tmpcip); 1002 outb(0x06, tmpcip);
@@ -2572,7 +2573,7 @@ static void atp870u_free_tables(struct Scsi_Host *host)
2572 for (k = 0; k < 16; k++) { 2573 for (k = 0; k < 16; k++) {
2573 if (!atp_dev->id[j][k].prd_table) 2574 if (!atp_dev->id[j][k].prd_table)
2574 continue; 2575 continue;
2575 pci_free_consistent(atp_dev->pdev, 1024, atp_dev->id[j][k].prd_table, atp_dev->id[j][k].prdaddr); 2576 pci_free_consistent(atp_dev->pdev, 1024, atp_dev->id[j][k].prd_table, atp_dev->id[j][k].prd_bus);
2576 atp_dev->id[j][k].prd_table = NULL; 2577 atp_dev->id[j][k].prd_table = NULL;
2577 } 2578 }
2578 } 2579 }
@@ -2584,12 +2585,13 @@ static int atp870u_init_tables(struct Scsi_Host *host)
2584 int c,k; 2585 int c,k;
2585 for(c=0;c < 2;c++) { 2586 for(c=0;c < 2;c++) {
2586 for(k=0;k<16;k++) { 2587 for(k=0;k<16;k++) {
2587 atp_dev->id[c][k].prd_table = pci_alloc_consistent(atp_dev->pdev, 1024, &(atp_dev->id[c][k].prdaddr)); 2588 atp_dev->id[c][k].prd_table = pci_alloc_consistent(atp_dev->pdev, 1024, &(atp_dev->id[c][k].prd_bus));
2588 if (!atp_dev->id[c][k].prd_table) { 2589 if (!atp_dev->id[c][k].prd_table) {
2589 printk("atp870u_init_tables fail\n"); 2590 printk("atp870u_init_tables fail\n");
2590 atp870u_free_tables(host); 2591 atp870u_free_tables(host);
2591 return -ENOMEM; 2592 return -ENOMEM;
2592 } 2593 }
2594 atp_dev->id[c][k].prdaddr = atp_dev->id[c][k].prd_bus;
2593 atp_dev->id[c][k].devsp=0x20; 2595 atp_dev->id[c][k].devsp=0x20;
2594 atp_dev->id[c][k].devtype = 0x7f; 2596 atp_dev->id[c][k].devtype = 0x7f;
2595 atp_dev->id[c][k].curr_req = NULL; 2597 atp_dev->id[c][k].curr_req = NULL;
diff --git a/drivers/scsi/atp870u.h b/drivers/scsi/atp870u.h
index 89f43af39cf2..62bae64a01c1 100644
--- a/drivers/scsi/atp870u.h
+++ b/drivers/scsi/atp870u.h
@@ -54,8 +54,9 @@ struct atp_unit
54 unsigned long tran_len; 54 unsigned long tran_len;
55 unsigned long last_len; 55 unsigned long last_len;
56 unsigned char *prd_pos; 56 unsigned char *prd_pos;
57 unsigned char *prd_table; 57 unsigned char *prd_table; /* Kernel address of PRD table */
58 dma_addr_t prdaddr; 58 dma_addr_t prd_bus; /* Bus address of PRD */
59 dma_addr_t prdaddr; /* Dynamically updated in driver */
59 struct scsi_cmnd *curr_req; 60 struct scsi_cmnd *curr_req;
60 } id[2][16]; 61 } id[2][16];
61 struct Scsi_Host *host; 62 struct Scsi_Host *host;
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index fa652f8aa643..d59d449a9e4d 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -1360,3 +1360,5 @@ static Scsi_Host_Template driver_template = {
1360 .use_clustering = DISABLE_CLUSTERING, 1360 .use_clustering = DISABLE_CLUSTERING,
1361}; 1361};
1362#include "scsi_module.c" 1362#include "scsi_module.c"
1363
1364MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 85503fad789a..02fe371b0ab8 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -98,6 +98,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
98 switch (oldstate) { 98 switch (oldstate) {
99 case SHOST_CREATED: 99 case SHOST_CREATED:
100 case SHOST_RUNNING: 100 case SHOST_RUNNING:
101 case SHOST_CANCEL_RECOVERY:
101 break; 102 break;
102 default: 103 default:
103 goto illegal; 104 goto illegal;
@@ -107,12 +108,31 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)
107 case SHOST_DEL: 108 case SHOST_DEL:
108 switch (oldstate) { 109 switch (oldstate) {
109 case SHOST_CANCEL: 110 case SHOST_CANCEL:
111 case SHOST_DEL_RECOVERY:
110 break; 112 break;
111 default: 113 default:
112 goto illegal; 114 goto illegal;
113 } 115 }
114 break; 116 break;
115 117
118 case SHOST_CANCEL_RECOVERY:
119 switch (oldstate) {
120 case SHOST_CANCEL:
121 case SHOST_RECOVERY:
122 break;
123 default:
124 goto illegal;
125 }
126 break;
127
128 case SHOST_DEL_RECOVERY:
129 switch (oldstate) {
130 case SHOST_CANCEL_RECOVERY:
131 break;
132 default:
133 goto illegal;
134 }
135 break;
116 } 136 }
117 shost->shost_state = state; 137 shost->shost_state = state;
118 return 0; 138 return 0;
@@ -134,17 +154,29 @@ EXPORT_SYMBOL(scsi_host_set_state);
134 **/ 154 **/
135void scsi_remove_host(struct Scsi_Host *shost) 155void scsi_remove_host(struct Scsi_Host *shost)
136{ 156{
157 unsigned long flags;
137 down(&shost->scan_mutex); 158 down(&shost->scan_mutex);
138 scsi_host_set_state(shost, SHOST_CANCEL); 159 spin_lock_irqsave(shost->host_lock, flags);
160 if (scsi_host_set_state(shost, SHOST_CANCEL))
161 if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) {
162 spin_unlock_irqrestore(shost->host_lock, flags);
163 up(&shost->scan_mutex);
164 return;
165 }
166 spin_unlock_irqrestore(shost->host_lock, flags);
139 up(&shost->scan_mutex); 167 up(&shost->scan_mutex);
140 scsi_forget_host(shost); 168 scsi_forget_host(shost);
141 scsi_proc_host_rm(shost); 169 scsi_proc_host_rm(shost);
142 170
143 scsi_host_set_state(shost, SHOST_DEL); 171 spin_lock_irqsave(shost->host_lock, flags);
172 if (scsi_host_set_state(shost, SHOST_DEL))
173 BUG_ON(scsi_host_set_state(shost, SHOST_DEL_RECOVERY));
174 spin_unlock_irqrestore(shost->host_lock, flags);
144 175
145 transport_unregister_device(&shost->shost_gendev); 176 transport_unregister_device(&shost->shost_gendev);
146 class_device_unregister(&shost->shost_classdev); 177 class_device_unregister(&shost->shost_classdev);
147 device_del(&shost->shost_gendev); 178 device_del(&shost->shost_gendev);
179 scsi_proc_hostdir_rm(shost->hostt);
148} 180}
149EXPORT_SYMBOL(scsi_remove_host); 181EXPORT_SYMBOL(scsi_remove_host);
150 182
@@ -231,7 +263,6 @@ static void scsi_host_dev_release(struct device *dev)
231 if (shost->work_q) 263 if (shost->work_q)
232 destroy_workqueue(shost->work_q); 264 destroy_workqueue(shost->work_q);
233 265
234 scsi_proc_hostdir_rm(shost->hostt);
235 scsi_destroy_command_freelist(shost); 266 scsi_destroy_command_freelist(shost);
236 kfree(shost->shost_data); 267 kfree(shost->shost_data);
237 268
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c
index 6e54c7d9b33c..19392f651272 100644
--- a/drivers/scsi/ibmmca.c
+++ b/drivers/scsi/ibmmca.c
@@ -460,6 +460,8 @@ MODULE_PARM(adisplay, "1i");
460MODULE_PARM(normal, "1i"); 460MODULE_PARM(normal, "1i");
461MODULE_PARM(ansi, "1i"); 461MODULE_PARM(ansi, "1i");
462#endif 462#endif
463
464MODULE_LICENSE("GPL");
463#endif 465#endif
464/*counter of concurrent disk read/writes, to turn on/off disk led */ 466/*counter of concurrent disk read/writes, to turn on/off disk led */
465static int disk_rw_in_progress = 0; 467static int disk_rw_in_progress = 0;
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 5b14934ba861..ff25210b00ba 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -727,6 +727,16 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct)
727 if (hostdata->madapter_info.port_max_txu[0]) 727 if (hostdata->madapter_info.port_max_txu[0])
728 hostdata->host->max_sectors = 728 hostdata->host->max_sectors =
729 hostdata->madapter_info.port_max_txu[0] >> 9; 729 hostdata->madapter_info.port_max_txu[0] >> 9;
730
731 if (hostdata->madapter_info.os_type == 3 &&
732 strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) {
733 printk("ibmvscsi: host (Ver. %s) doesn't support large"
734 "transfers\n",
735 hostdata->madapter_info.srp_version);
736 printk("ibmvscsi: limiting scatterlists to %d\n",
737 MAX_INDIRECT_BUFS);
738 hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS;
739 }
730 } 740 }
731} 741}
732 742
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index d92273cbe0de..e5b01997117a 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -4132,6 +4132,53 @@ err_out:
4132} 4132}
4133 4133
4134/** 4134/**
4135 * ata_host_set_remove - PCI layer callback for device removal
4136 * @host_set: ATA host set that was removed
4137 *
4138 * Unregister all objects associated with this host set. Free those
4139 * objects.
4140 *
4141 * LOCKING:
4142 * Inherited from calling layer (may sleep).
4143 */
4144
4145
4146void ata_host_set_remove(struct ata_host_set *host_set)
4147{
4148 struct ata_port *ap;
4149 unsigned int i;
4150
4151 for (i = 0; i < host_set->n_ports; i++) {
4152 ap = host_set->ports[i];
4153 scsi_remove_host(ap->host);
4154 }
4155
4156 free_irq(host_set->irq, host_set);
4157
4158 for (i = 0; i < host_set->n_ports; i++) {
4159 ap = host_set->ports[i];
4160
4161 ata_scsi_release(ap->host);
4162
4163 if ((ap->flags & ATA_FLAG_NO_LEGACY) == 0) {
4164 struct ata_ioports *ioaddr = &ap->ioaddr;
4165
4166 if (ioaddr->cmd_addr == 0x1f0)
4167 release_region(0x1f0, 8);
4168 else if (ioaddr->cmd_addr == 0x170)
4169 release_region(0x170, 8);
4170 }
4171
4172 scsi_host_put(ap->host);
4173 }
4174
4175 if (host_set->ops->host_stop)
4176 host_set->ops->host_stop(host_set);
4177
4178 kfree(host_set);
4179}
4180
4181/**
4135 * ata_scsi_release - SCSI layer callback hook for host unload 4182 * ata_scsi_release - SCSI layer callback hook for host unload
4136 * @host: libata host to be unloaded 4183 * @host: libata host to be unloaded
4137 * 4184 *
@@ -4471,39 +4518,8 @@ void ata_pci_remove_one (struct pci_dev *pdev)
4471{ 4518{
4472 struct device *dev = pci_dev_to_dev(pdev); 4519 struct device *dev = pci_dev_to_dev(pdev);
4473 struct ata_host_set *host_set = dev_get_drvdata(dev); 4520 struct ata_host_set *host_set = dev_get_drvdata(dev);
4474 struct ata_port *ap;
4475 unsigned int i;
4476
4477 for (i = 0; i < host_set->n_ports; i++) {
4478 ap = host_set->ports[i];
4479
4480 scsi_remove_host(ap->host);
4481 }
4482
4483 free_irq(host_set->irq, host_set);
4484
4485 for (i = 0; i < host_set->n_ports; i++) {
4486 ap = host_set->ports[i];
4487
4488 ata_scsi_release(ap->host);
4489
4490 if ((ap->flags & ATA_FLAG_NO_LEGACY) == 0) {
4491 struct ata_ioports *ioaddr = &ap->ioaddr;
4492
4493 if (ioaddr->cmd_addr == 0x1f0)
4494 release_region(0x1f0, 8);
4495 else if (ioaddr->cmd_addr == 0x170)
4496 release_region(0x170, 8);
4497 }
4498
4499 scsi_host_put(ap->host);
4500 }
4501
4502 if (host_set->ops->host_stop)
4503 host_set->ops->host_stop(host_set);
4504
4505 kfree(host_set);
4506 4521
4522 ata_host_set_remove(host_set);
4507 pci_release_regions(pdev); 4523 pci_release_regions(pdev);
4508 pci_disable_device(pdev); 4524 pci_disable_device(pdev);
4509 dev_set_drvdata(dev, NULL); 4525 dev_set_drvdata(dev, NULL);
@@ -4573,6 +4589,7 @@ module_exit(ata_exit);
4573EXPORT_SYMBOL_GPL(ata_std_bios_param); 4589EXPORT_SYMBOL_GPL(ata_std_bios_param);
4574EXPORT_SYMBOL_GPL(ata_std_ports); 4590EXPORT_SYMBOL_GPL(ata_std_ports);
4575EXPORT_SYMBOL_GPL(ata_device_add); 4591EXPORT_SYMBOL_GPL(ata_device_add);
4592EXPORT_SYMBOL_GPL(ata_host_set_remove);
4576EXPORT_SYMBOL_GPL(ata_sg_init); 4593EXPORT_SYMBOL_GPL(ata_sg_init);
4577EXPORT_SYMBOL_GPL(ata_sg_init_one); 4594EXPORT_SYMBOL_GPL(ata_sg_init_one);
4578EXPORT_SYMBOL_GPL(ata_qc_complete); 4595EXPORT_SYMBOL_GPL(ata_qc_complete);
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 86eaf6d408d5..acae7c48ef7d 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -973,10 +973,10 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost)
973 if ((phba->fc_flag & FC_FABRIC) || 973 if ((phba->fc_flag & FC_FABRIC) ||
974 ((phba->fc_topology == TOPOLOGY_LOOP) && 974 ((phba->fc_topology == TOPOLOGY_LOOP) &&
975 (phba->fc_flag & FC_PUBLIC_LOOP))) 975 (phba->fc_flag & FC_PUBLIC_LOOP)))
976 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.wwn); 976 node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
977 else 977 else
978 /* fabric is local port if there is no F/FL_Port */ 978 /* fabric is local port if there is no F/FL_Port */
979 node_name = wwn_to_u64(phba->fc_nodename.wwn); 979 node_name = wwn_to_u64(phba->fc_nodename.u.wwn);
980 980
981 spin_unlock_irq(shost->host_lock); 981 spin_unlock_irq(shost->host_lock);
982 982
@@ -1110,7 +1110,7 @@ lpfc_get_starget_node_name(struct scsi_target *starget)
1110 /* Search the mapped list for this target ID */ 1110 /* Search the mapped list for this target ID */
1111 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { 1111 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
1112 if (starget->id == ndlp->nlp_sid) { 1112 if (starget->id == ndlp->nlp_sid) {
1113 node_name = wwn_to_u64(ndlp->nlp_nodename.wwn); 1113 node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
1114 break; 1114 break;
1115 } 1115 }
1116 } 1116 }
@@ -1131,7 +1131,7 @@ lpfc_get_starget_port_name(struct scsi_target *starget)
1131 /* Search the mapped list for this target ID */ 1131 /* Search the mapped list for this target ID */
1132 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { 1132 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
1133 if (starget->id == ndlp->nlp_sid) { 1133 if (starget->id == ndlp->nlp_sid) {
1134 port_name = wwn_to_u64(ndlp->nlp_portname.wwn); 1134 port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
1135 break; 1135 break;
1136 } 1136 }
1137 } 1137 }
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 4fb8eb0c84cf..56052f4510c3 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1019,8 +1019,8 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1019 struct fc_rport_identifiers rport_ids; 1019 struct fc_rport_identifiers rport_ids;
1020 1020
1021 /* Remote port has reappeared. Re-register w/ FC transport */ 1021 /* Remote port has reappeared. Re-register w/ FC transport */
1022 rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.wwn); 1022 rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
1023 rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.wwn); 1023 rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
1024 rport_ids.port_id = ndlp->nlp_DID; 1024 rport_ids.port_id = ndlp->nlp_DID;
1025 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 1025 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
1026 if (ndlp->nlp_type & NLP_FCP_TARGET) 1026 if (ndlp->nlp_type & NLP_FCP_TARGET)
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 047a87c26cc0..86c41981188b 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -280,9 +280,9 @@ struct lpfc_name {
280#define NAME_CCITT_GR_TYPE 0xE 280#define NAME_CCITT_GR_TYPE 0xE
281 uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE extended Lsb */ 281 uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE extended Lsb */
282 uint8_t IEEE[6]; /* FC IEEE address */ 282 uint8_t IEEE[6]; /* FC IEEE address */
283 }; 283 } s;
284 uint8_t wwn[8]; 284 uint8_t wwn[8];
285 }; 285 } u;
286}; 286};
287 287
288struct csp { 288struct csp {
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 454058f655db..0856ff7d3b33 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -285,7 +285,7 @@ lpfc_config_port_post(struct lpfc_hba * phba)
285 if (phba->SerialNumber[0] == 0) { 285 if (phba->SerialNumber[0] == 0) {
286 uint8_t *outptr; 286 uint8_t *outptr;
287 287
288 outptr = (uint8_t *) & phba->fc_nodename.IEEE[0]; 288 outptr = &phba->fc_nodename.u.s.IEEE[0];
289 for (i = 0; i < 12; i++) { 289 for (i = 0; i < 12; i++) {
290 status = *outptr++; 290 status = *outptr++;
291 j = ((status & 0xf0) >> 4); 291 j = ((status & 0xf0) >> 4);
@@ -1523,8 +1523,8 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1523 * Must done after lpfc_sli_hba_setup() 1523 * Must done after lpfc_sli_hba_setup()
1524 */ 1524 */
1525 1525
1526 fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.wwn); 1526 fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn);
1527 fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.wwn); 1527 fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn);
1528 fc_host_supported_classes(host) = FC_COS_CLASS3; 1528 fc_host_supported_classes(host) = FC_COS_CLASS3;
1529 1529
1530 memset(fc_host_supported_fc4s(host), 0, 1530 memset(fc_host_supported_fc4s(host), 0,
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 6f308ebe3e79..61a6fd810bb4 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -621,8 +621,6 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
621 if(islogical) { 621 if(islogical) {
622 switch (cmd->cmnd[0]) { 622 switch (cmd->cmnd[0]) {
623 case TEST_UNIT_READY: 623 case TEST_UNIT_READY:
624 memset(cmd->request_buffer, 0, cmd->request_bufflen);
625
626#if MEGA_HAVE_CLUSTERING 624#if MEGA_HAVE_CLUSTERING
627 /* 625 /*
628 * Do we support clustering and is the support enabled 626 * Do we support clustering and is the support enabled
@@ -652,11 +650,28 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
652 return NULL; 650 return NULL;
653#endif 651#endif
654 652
655 case MODE_SENSE: 653 case MODE_SENSE: {
654 char *buf;
655
656 if (cmd->use_sg) {
657 struct scatterlist *sg;
658
659 sg = (struct scatterlist *)cmd->request_buffer;
660 buf = kmap_atomic(sg->page, KM_IRQ0) +
661 sg->offset;
662 } else
663 buf = cmd->request_buffer;
656 memset(cmd->request_buffer, 0, cmd->cmnd[4]); 664 memset(cmd->request_buffer, 0, cmd->cmnd[4]);
665 if (cmd->use_sg) {
666 struct scatterlist *sg;
667
668 sg = (struct scatterlist *)cmd->request_buffer;
669 kunmap_atomic(buf - sg->offset, KM_IRQ0);
670 }
657 cmd->result = (DID_OK << 16); 671 cmd->result = (DID_OK << 16);
658 cmd->scsi_done(cmd); 672 cmd->scsi_done(cmd);
659 return NULL; 673 return NULL;
674 }
660 675
661 case READ_CAPACITY: 676 case READ_CAPACITY:
662 case INQUIRY: 677 case INQUIRY:
@@ -1685,14 +1700,23 @@ mega_rundoneq (adapter_t *adapter)
1685static void 1700static void
1686mega_free_scb(adapter_t *adapter, scb_t *scb) 1701mega_free_scb(adapter_t *adapter, scb_t *scb)
1687{ 1702{
1703 unsigned long length;
1704
1688 switch( scb->dma_type ) { 1705 switch( scb->dma_type ) {
1689 1706
1690 case MEGA_DMA_TYPE_NONE: 1707 case MEGA_DMA_TYPE_NONE:
1691 break; 1708 break;
1692 1709
1693 case MEGA_BULK_DATA: 1710 case MEGA_BULK_DATA:
1711 if (scb->cmd->use_sg == 0)
1712 length = scb->cmd->request_bufflen;
1713 else {
1714 struct scatterlist *sgl =
1715 (struct scatterlist *)scb->cmd->request_buffer;
1716 length = sgl->length;
1717 }
1694 pci_unmap_page(adapter->dev, scb->dma_h_bulkdata, 1718 pci_unmap_page(adapter->dev, scb->dma_h_bulkdata,
1695 scb->cmd->request_bufflen, scb->dma_direction); 1719 length, scb->dma_direction);
1696 break; 1720 break;
1697 1721
1698 case MEGA_SGLIST: 1722 case MEGA_SGLIST:
@@ -1741,6 +1765,7 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
1741 struct scatterlist *sgl; 1765 struct scatterlist *sgl;
1742 struct page *page; 1766 struct page *page;
1743 unsigned long offset; 1767 unsigned long offset;
1768 unsigned int length;
1744 Scsi_Cmnd *cmd; 1769 Scsi_Cmnd *cmd;
1745 int sgcnt; 1770 int sgcnt;
1746 int idx; 1771 int idx;
@@ -1748,14 +1773,23 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
1748 cmd = scb->cmd; 1773 cmd = scb->cmd;
1749 1774
1750 /* Scatter-gather not used */ 1775 /* Scatter-gather not used */
1751 if( !cmd->use_sg ) { 1776 if( cmd->use_sg == 0 || (cmd->use_sg == 1 &&
1752 1777 !adapter->has_64bit_addr)) {
1753 page = virt_to_page(cmd->request_buffer); 1778
1754 offset = offset_in_page(cmd->request_buffer); 1779 if (cmd->use_sg == 0) {
1780 page = virt_to_page(cmd->request_buffer);
1781 offset = offset_in_page(cmd->request_buffer);
1782 length = cmd->request_bufflen;
1783 } else {
1784 sgl = (struct scatterlist *)cmd->request_buffer;
1785 page = sgl->page;
1786 offset = sgl->offset;
1787 length = sgl->length;
1788 }
1755 1789
1756 scb->dma_h_bulkdata = pci_map_page(adapter->dev, 1790 scb->dma_h_bulkdata = pci_map_page(adapter->dev,
1757 page, offset, 1791 page, offset,
1758 cmd->request_bufflen, 1792 length,
1759 scb->dma_direction); 1793 scb->dma_direction);
1760 scb->dma_type = MEGA_BULK_DATA; 1794 scb->dma_type = MEGA_BULK_DATA;
1761 1795
@@ -1765,14 +1799,14 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
1765 */ 1799 */
1766 if( adapter->has_64bit_addr ) { 1800 if( adapter->has_64bit_addr ) {
1767 scb->sgl64[0].address = scb->dma_h_bulkdata; 1801 scb->sgl64[0].address = scb->dma_h_bulkdata;
1768 scb->sgl64[0].length = cmd->request_bufflen; 1802 scb->sgl64[0].length = length;
1769 *buf = (u32)scb->sgl_dma_addr; 1803 *buf = (u32)scb->sgl_dma_addr;
1770 *len = (u32)cmd->request_bufflen; 1804 *len = (u32)length;
1771 return 1; 1805 return 1;
1772 } 1806 }
1773 else { 1807 else {
1774 *buf = (u32)scb->dma_h_bulkdata; 1808 *buf = (u32)scb->dma_h_bulkdata;
1775 *len = (u32)cmd->request_bufflen; 1809 *len = (u32)length;
1776 } 1810 }
1777 return 0; 1811 return 0;
1778 } 1812 }
@@ -1791,27 +1825,23 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
1791 1825
1792 if( sgcnt > adapter->sglen ) BUG(); 1826 if( sgcnt > adapter->sglen ) BUG();
1793 1827
1828 *len = 0;
1829
1794 for( idx = 0; idx < sgcnt; idx++, sgl++ ) { 1830 for( idx = 0; idx < sgcnt; idx++, sgl++ ) {
1795 1831
1796 if( adapter->has_64bit_addr ) { 1832 if( adapter->has_64bit_addr ) {
1797 scb->sgl64[idx].address = sg_dma_address(sgl); 1833 scb->sgl64[idx].address = sg_dma_address(sgl);
1798 scb->sgl64[idx].length = sg_dma_len(sgl); 1834 *len += scb->sgl64[idx].length = sg_dma_len(sgl);
1799 } 1835 }
1800 else { 1836 else {
1801 scb->sgl[idx].address = sg_dma_address(sgl); 1837 scb->sgl[idx].address = sg_dma_address(sgl);
1802 scb->sgl[idx].length = sg_dma_len(sgl); 1838 *len += scb->sgl[idx].length = sg_dma_len(sgl);
1803 } 1839 }
1804 } 1840 }
1805 1841
1806 /* Reset pointer and length fields */ 1842 /* Reset pointer and length fields */
1807 *buf = scb->sgl_dma_addr; 1843 *buf = scb->sgl_dma_addr;
1808 1844
1809 /*
1810 * For passthru command, dataxferlen must be set, even for commands
1811 * with a sg list
1812 */
1813 *len = (u32)cmd->request_bufflen;
1814
1815 /* Return count of SG requests */ 1845 /* Return count of SG requests */
1816 return sgcnt; 1846 return sgcnt;
1817} 1847}
diff --git a/drivers/scsi/megaraid/Kconfig.megaraid b/drivers/scsi/megaraid/Kconfig.megaraid
index 917d591d90b2..7363e12663ac 100644
--- a/drivers/scsi/megaraid/Kconfig.megaraid
+++ b/drivers/scsi/megaraid/Kconfig.megaraid
@@ -76,3 +76,12 @@ config MEGARAID_LEGACY
76 To compile this driver as a module, choose M here: the 76 To compile this driver as a module, choose M here: the
77 module will be called megaraid 77 module will be called megaraid
78endif 78endif
79
80config MEGARAID_SAS
81 tristate "LSI Logic MegaRAID SAS RAID Module"
82 depends on PCI && SCSI
83 help
84 Module for LSI Logic's SAS based RAID controllers.
85 To compile this driver as a module, choose 'm' here.
86 Module will be called megaraid_sas
87
diff --git a/drivers/scsi/megaraid/Makefile b/drivers/scsi/megaraid/Makefile
index 6dd99f275722..f469915b97c3 100644
--- a/drivers/scsi/megaraid/Makefile
+++ b/drivers/scsi/megaraid/Makefile
@@ -1,2 +1,3 @@
1obj-$(CONFIG_MEGARAID_MM) += megaraid_mm.o 1obj-$(CONFIG_MEGARAID_MM) += megaraid_mm.o
2obj-$(CONFIG_MEGARAID_MAILBOX) += megaraid_mbox.o 2obj-$(CONFIG_MEGARAID_MAILBOX) += megaraid_mbox.o
3obj-$(CONFIG_MEGARAID_SAS) += megaraid_sas.o
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
new file mode 100644
index 000000000000..c3f637395734
--- /dev/null
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -0,0 +1,2806 @@
1/*
2 *
3 * Linux MegaRAID driver for SAS based RAID controllers
4 *
5 * Copyright (c) 2003-2005 LSI Logic Corporation.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * FILE : megaraid_sas.c
13 * Version : v00.00.02.00-rc4
14 *
15 * Authors:
16 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com>
17 * Sumant Patro <Sumant.Patro@lsil.com>
18 *
19 * List of supported controllers
20 *
21 * OEM Product Name VID DID SSVID SSID
22 * --- ------------ --- --- ---- ----
23 */
24
25#include <linux/kernel.h>
26#include <linux/types.h>
27#include <linux/pci.h>
28#include <linux/list.h>
29#include <linux/version.h>
30#include <linux/moduleparam.h>
31#include <linux/module.h>
32#include <linux/spinlock.h>
33#include <linux/interrupt.h>
34#include <linux/delay.h>
35#include <linux/uio.h>
36#include <asm/uaccess.h>
37#include <linux/fs.h>
38#include <linux/compat.h>
39
40#include <scsi/scsi.h>
41#include <scsi/scsi_cmnd.h>
42#include <scsi/scsi_device.h>
43#include <scsi/scsi_host.h>
44#include "megaraid_sas.h"
45
46MODULE_LICENSE("GPL");
47MODULE_VERSION(MEGASAS_VERSION);
48MODULE_AUTHOR("sreenivas.bagalkote@lsil.com");
49MODULE_DESCRIPTION("LSI Logic MegaRAID SAS Driver");
50
51/*
52 * PCI ID table for all supported controllers
53 */
54static struct pci_device_id megasas_pci_table[] = {
55
56 {
57 PCI_VENDOR_ID_LSI_LOGIC,
58 PCI_DEVICE_ID_LSI_SAS1064R,
59 PCI_ANY_ID,
60 PCI_ANY_ID,
61 },
62 {
63 PCI_VENDOR_ID_DELL,
64 PCI_DEVICE_ID_DELL_PERC5,
65 PCI_ANY_ID,
66 PCI_ANY_ID,
67 },
68 {0} /* Terminating entry */
69};
70
71MODULE_DEVICE_TABLE(pci, megasas_pci_table);
72
73static int megasas_mgmt_majorno;
74static struct megasas_mgmt_info megasas_mgmt_info;
75static struct fasync_struct *megasas_async_queue;
76static DECLARE_MUTEX(megasas_async_queue_mutex);
77
78/**
79 * megasas_get_cmd - Get a command from the free pool
80 * @instance: Adapter soft state
81 *
82 * Returns a free command from the pool
83 */
84static inline struct megasas_cmd *megasas_get_cmd(struct megasas_instance
85 *instance)
86{
87 unsigned long flags;
88 struct megasas_cmd *cmd = NULL;
89
90 spin_lock_irqsave(&instance->cmd_pool_lock, flags);
91
92 if (!list_empty(&instance->cmd_pool)) {
93 cmd = list_entry((&instance->cmd_pool)->next,
94 struct megasas_cmd, list);
95 list_del_init(&cmd->list);
96 } else {
97 printk(KERN_ERR "megasas: Command pool empty!\n");
98 }
99
100 spin_unlock_irqrestore(&instance->cmd_pool_lock, flags);
101 return cmd;
102}
103
104/**
105 * megasas_return_cmd - Return a cmd to free command pool
106 * @instance: Adapter soft state
107 * @cmd: Command packet to be returned to free command pool
108 */
109static inline void
110megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
111{
112 unsigned long flags;
113
114 spin_lock_irqsave(&instance->cmd_pool_lock, flags);
115
116 cmd->scmd = NULL;
117 list_add_tail(&cmd->list, &instance->cmd_pool);
118
119 spin_unlock_irqrestore(&instance->cmd_pool_lock, flags);
120}
121
122/**
123 * megasas_enable_intr - Enables interrupts
124 * @regs: MFI register set
125 */
126static inline void
127megasas_enable_intr(struct megasas_register_set __iomem * regs)
128{
129 writel(1, &(regs)->outbound_intr_mask);
130
131 /* Dummy readl to force pci flush */
132 readl(&regs->outbound_intr_mask);
133}
134
135/**
136 * megasas_disable_intr - Disables interrupts
137 * @regs: MFI register set
138 */
139static inline void
140megasas_disable_intr(struct megasas_register_set __iomem * regs)
141{
142 u32 mask = readl(&regs->outbound_intr_mask) & (~0x00000001);
143 writel(mask, &regs->outbound_intr_mask);
144
145 /* Dummy readl to force pci flush */
146 readl(&regs->outbound_intr_mask);
147}
148
149/**
150 * megasas_issue_polled - Issues a polling command
151 * @instance: Adapter soft state
152 * @cmd: Command packet to be issued
153 *
154 * For polling, MFI requires the cmd_status to be set to 0xFF before posting.
155 */
156static int
157megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd)
158{
159 int i;
160 u32 msecs = MFI_POLL_TIMEOUT_SECS * 1000;
161
162 struct megasas_header *frame_hdr = &cmd->frame->hdr;
163
164 frame_hdr->cmd_status = 0xFF;
165 frame_hdr->flags |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
166
167 /*
168 * Issue the frame using inbound queue port
169 */
170 writel(cmd->frame_phys_addr >> 3,
171 &instance->reg_set->inbound_queue_port);
172
173 /*
174 * Wait for cmd_status to change
175 */
176 for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i++) {
177 rmb();
178 msleep(1);
179 }
180
181 if (frame_hdr->cmd_status == 0xff)
182 return -ETIME;
183
184 return 0;
185}
186
187/**
188 * megasas_issue_blocked_cmd - Synchronous wrapper around regular FW cmds
189 * @instance: Adapter soft state
190 * @cmd: Command to be issued
191 *
192 * This function waits on an event for the command to be returned from ISR.
193 * Used to issue ioctl commands.
194 */
195static int
196megasas_issue_blocked_cmd(struct megasas_instance *instance,
197 struct megasas_cmd *cmd)
198{
199 cmd->cmd_status = ENODATA;
200
201 writel(cmd->frame_phys_addr >> 3,
202 &instance->reg_set->inbound_queue_port);
203
204 wait_event(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA));
205
206 return 0;
207}
208
209/**
210 * megasas_issue_blocked_abort_cmd - Aborts previously issued cmd
211 * @instance: Adapter soft state
212 * @cmd_to_abort: Previously issued cmd to be aborted
213 *
214 * MFI firmware can abort previously issued AEN comamnd (automatic event
215 * notification). The megasas_issue_blocked_abort_cmd() issues such abort
216 * cmd and blocks till it is completed.
217 */
218static int
219megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,
220 struct megasas_cmd *cmd_to_abort)
221{
222 struct megasas_cmd *cmd;
223 struct megasas_abort_frame *abort_fr;
224
225 cmd = megasas_get_cmd(instance);
226
227 if (!cmd)
228 return -1;
229
230 abort_fr = &cmd->frame->abort;
231
232 /*
233 * Prepare and issue the abort frame
234 */
235 abort_fr->cmd = MFI_CMD_ABORT;
236 abort_fr->cmd_status = 0xFF;
237 abort_fr->flags = 0;
238 abort_fr->abort_context = cmd_to_abort->index;
239 abort_fr->abort_mfi_phys_addr_lo = cmd_to_abort->frame_phys_addr;
240 abort_fr->abort_mfi_phys_addr_hi = 0;
241
242 cmd->sync_cmd = 1;
243 cmd->cmd_status = 0xFF;
244
245 writel(cmd->frame_phys_addr >> 3,
246 &instance->reg_set->inbound_queue_port);
247
248 /*
249 * Wait for this cmd to complete
250 */
251 wait_event(instance->abort_cmd_wait_q, (cmd->cmd_status != 0xFF));
252
253 megasas_return_cmd(instance, cmd);
254 return 0;
255}
256
257/**
258 * megasas_make_sgl32 - Prepares 32-bit SGL
259 * @instance: Adapter soft state
260 * @scp: SCSI command from the mid-layer
261 * @mfi_sgl: SGL to be filled in
262 *
263 * If successful, this function returns the number of SG elements. Otherwise,
264 * it returnes -1.
265 */
266static inline int
267megasas_make_sgl32(struct megasas_instance *instance, struct scsi_cmnd *scp,
268 union megasas_sgl *mfi_sgl)
269{
270 int i;
271 int sge_count;
272 struct scatterlist *os_sgl;
273
274 /*
275 * Return 0 if there is no data transfer
276 */
277 if (!scp->request_buffer || !scp->request_bufflen)
278 return 0;
279
280 if (!scp->use_sg) {
281 mfi_sgl->sge32[0].phys_addr = pci_map_single(instance->pdev,
282 scp->
283 request_buffer,
284 scp->
285 request_bufflen,
286 scp->
287 sc_data_direction);
288 mfi_sgl->sge32[0].length = scp->request_bufflen;
289
290 return 1;
291 }
292
293 os_sgl = (struct scatterlist *)scp->request_buffer;
294 sge_count = pci_map_sg(instance->pdev, os_sgl, scp->use_sg,
295 scp->sc_data_direction);
296
297 for (i = 0; i < sge_count; i++, os_sgl++) {
298 mfi_sgl->sge32[i].length = sg_dma_len(os_sgl);
299 mfi_sgl->sge32[i].phys_addr = sg_dma_address(os_sgl);
300 }
301
302 return sge_count;
303}
304
305/**
306 * megasas_make_sgl64 - Prepares 64-bit SGL
307 * @instance: Adapter soft state
308 * @scp: SCSI command from the mid-layer
309 * @mfi_sgl: SGL to be filled in
310 *
311 * If successful, this function returns the number of SG elements. Otherwise,
312 * it returnes -1.
313 */
314static inline int
315megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp,
316 union megasas_sgl *mfi_sgl)
317{
318 int i;
319 int sge_count;
320 struct scatterlist *os_sgl;
321
322 /*
323 * Return 0 if there is no data transfer
324 */
325 if (!scp->request_buffer || !scp->request_bufflen)
326 return 0;
327
328 if (!scp->use_sg) {
329 mfi_sgl->sge64[0].phys_addr = pci_map_single(instance->pdev,
330 scp->
331 request_buffer,
332 scp->
333 request_bufflen,
334 scp->
335 sc_data_direction);
336
337 mfi_sgl->sge64[0].length = scp->request_bufflen;
338
339 return 1;
340 }
341
342 os_sgl = (struct scatterlist *)scp->request_buffer;
343 sge_count = pci_map_sg(instance->pdev, os_sgl, scp->use_sg,
344 scp->sc_data_direction);
345
346 for (i = 0; i < sge_count; i++, os_sgl++) {
347 mfi_sgl->sge64[i].length = sg_dma_len(os_sgl);
348 mfi_sgl->sge64[i].phys_addr = sg_dma_address(os_sgl);
349 }
350
351 return sge_count;
352}
353
354/**
355 * megasas_build_dcdb - Prepares a direct cdb (DCDB) command
356 * @instance: Adapter soft state
357 * @scp: SCSI command
358 * @cmd: Command to be prepared in
359 *
360 * This function prepares CDB commands. These are typcially pass-through
361 * commands to the devices.
362 */
363static inline int
364megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
365 struct megasas_cmd *cmd)
366{
367 u32 sge_sz;
368 int sge_bytes;
369 u32 is_logical;
370 u32 device_id;
371 u16 flags = 0;
372 struct megasas_pthru_frame *pthru;
373
374 is_logical = MEGASAS_IS_LOGICAL(scp);
375 device_id = MEGASAS_DEV_INDEX(instance, scp);
376 pthru = (struct megasas_pthru_frame *)cmd->frame;
377
378 if (scp->sc_data_direction == PCI_DMA_TODEVICE)
379 flags = MFI_FRAME_DIR_WRITE;
380 else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
381 flags = MFI_FRAME_DIR_READ;
382 else if (scp->sc_data_direction == PCI_DMA_NONE)
383 flags = MFI_FRAME_DIR_NONE;
384
385 /*
386 * Prepare the DCDB frame
387 */
388 pthru->cmd = (is_logical) ? MFI_CMD_LD_SCSI_IO : MFI_CMD_PD_SCSI_IO;
389 pthru->cmd_status = 0x0;
390 pthru->scsi_status = 0x0;
391 pthru->target_id = device_id;
392 pthru->lun = scp->device->lun;
393 pthru->cdb_len = scp->cmd_len;
394 pthru->timeout = 0;
395 pthru->flags = flags;
396 pthru->data_xfer_len = scp->request_bufflen;
397
398 memcpy(pthru->cdb, scp->cmnd, scp->cmd_len);
399
400 /*
401 * Construct SGL
402 */
403 sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
404 sizeof(struct megasas_sge32);
405
406 if (IS_DMA64) {
407 pthru->flags |= MFI_FRAME_SGL64;
408 pthru->sge_count = megasas_make_sgl64(instance, scp,
409 &pthru->sgl);
410 } else
411 pthru->sge_count = megasas_make_sgl32(instance, scp,
412 &pthru->sgl);
413
414 /*
415 * Sense info specific
416 */
417 pthru->sense_len = SCSI_SENSE_BUFFERSIZE;
418 pthru->sense_buf_phys_addr_hi = 0;
419 pthru->sense_buf_phys_addr_lo = cmd->sense_phys_addr;
420
421 sge_bytes = sge_sz * pthru->sge_count;
422
423 /*
424 * Compute the total number of frames this command consumes. FW uses
425 * this number to pull sufficient number of frames from host memory.
426 */
427 cmd->frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
428 ((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) + 1;
429
430 if (cmd->frame_count > 7)
431 cmd->frame_count = 8;
432
433 return cmd->frame_count;
434}
435
436/**
437 * megasas_build_ldio - Prepares IOs to logical devices
438 * @instance: Adapter soft state
439 * @scp: SCSI command
440 * @cmd: Command to to be prepared
441 *
442 * Frames (and accompanying SGLs) for regular SCSI IOs use this function.
443 */
444static inline int
445megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
446 struct megasas_cmd *cmd)
447{
448 u32 sge_sz;
449 int sge_bytes;
450 u32 device_id;
451 u8 sc = scp->cmnd[0];
452 u16 flags = 0;
453 struct megasas_io_frame *ldio;
454
455 device_id = MEGASAS_DEV_INDEX(instance, scp);
456 ldio = (struct megasas_io_frame *)cmd->frame;
457
458 if (scp->sc_data_direction == PCI_DMA_TODEVICE)
459 flags = MFI_FRAME_DIR_WRITE;
460 else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
461 flags = MFI_FRAME_DIR_READ;
462
463 /*
464 * Preare the Logical IO frame: 2nd bit is zero for all read cmds
465 */
466 ldio->cmd = (sc & 0x02) ? MFI_CMD_LD_WRITE : MFI_CMD_LD_READ;
467 ldio->cmd_status = 0x0;
468 ldio->scsi_status = 0x0;
469 ldio->target_id = device_id;
470 ldio->timeout = 0;
471 ldio->reserved_0 = 0;
472 ldio->pad_0 = 0;
473 ldio->flags = flags;
474 ldio->start_lba_hi = 0;
475 ldio->access_byte = (scp->cmd_len != 6) ? scp->cmnd[1] : 0;
476
477 /*
478 * 6-byte READ(0x08) or WRITE(0x0A) cdb
479 */
480 if (scp->cmd_len == 6) {
481 ldio->lba_count = (u32) scp->cmnd[4];
482 ldio->start_lba_lo = ((u32) scp->cmnd[1] << 16) |
483 ((u32) scp->cmnd[2] << 8) | (u32) scp->cmnd[3];
484
485 ldio->start_lba_lo &= 0x1FFFFF;
486 }
487
488 /*
489 * 10-byte READ(0x28) or WRITE(0x2A) cdb
490 */
491 else if (scp->cmd_len == 10) {
492 ldio->lba_count = (u32) scp->cmnd[8] |
493 ((u32) scp->cmnd[7] << 8);
494 ldio->start_lba_lo = ((u32) scp->cmnd[2] << 24) |
495 ((u32) scp->cmnd[3] << 16) |
496 ((u32) scp->cmnd[4] << 8) | (u32) scp->cmnd[5];
497 }
498
499 /*
500 * 12-byte READ(0xA8) or WRITE(0xAA) cdb
501 */
502 else if (scp->cmd_len == 12) {
503 ldio->lba_count = ((u32) scp->cmnd[6] << 24) |
504 ((u32) scp->cmnd[7] << 16) |
505 ((u32) scp->cmnd[8] << 8) | (u32) scp->cmnd[9];
506
507 ldio->start_lba_lo = ((u32) scp->cmnd[2] << 24) |
508 ((u32) scp->cmnd[3] << 16) |
509 ((u32) scp->cmnd[4] << 8) | (u32) scp->cmnd[5];
510 }
511
512 /*
513 * 16-byte READ(0x88) or WRITE(0x8A) cdb
514 */
515 else if (scp->cmd_len == 16) {
516 ldio->lba_count = ((u32) scp->cmnd[10] << 24) |
517 ((u32) scp->cmnd[11] << 16) |
518 ((u32) scp->cmnd[12] << 8) | (u32) scp->cmnd[13];
519
520 ldio->start_lba_lo = ((u32) scp->cmnd[6] << 24) |
521 ((u32) scp->cmnd[7] << 16) |
522 ((u32) scp->cmnd[8] << 8) | (u32) scp->cmnd[9];
523
524 ldio->start_lba_hi = ((u32) scp->cmnd[2] << 24) |
525 ((u32) scp->cmnd[3] << 16) |
526 ((u32) scp->cmnd[4] << 8) | (u32) scp->cmnd[5];
527
528 }
529
530 /*
531 * Construct SGL
532 */
533 sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
534 sizeof(struct megasas_sge32);
535
536 if (IS_DMA64) {
537 ldio->flags |= MFI_FRAME_SGL64;
538 ldio->sge_count = megasas_make_sgl64(instance, scp, &ldio->sgl);
539 } else
540 ldio->sge_count = megasas_make_sgl32(instance, scp, &ldio->sgl);
541
542 /*
543 * Sense info specific
544 */
545 ldio->sense_len = SCSI_SENSE_BUFFERSIZE;
546 ldio->sense_buf_phys_addr_hi = 0;
547 ldio->sense_buf_phys_addr_lo = cmd->sense_phys_addr;
548
549 sge_bytes = sge_sz * ldio->sge_count;
550
551 cmd->frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
552 ((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) + 1;
553
554 if (cmd->frame_count > 7)
555 cmd->frame_count = 8;
556
557 return cmd->frame_count;
558}
559
560/**
561 * megasas_build_cmd - Prepares a command packet
562 * @instance: Adapter soft state
563 * @scp: SCSI command
564 * @frame_count: [OUT] Number of frames used to prepare this command
565 */
566static inline struct megasas_cmd *megasas_build_cmd(struct megasas_instance
567 *instance,
568 struct scsi_cmnd *scp,
569 int *frame_count)
570{
571 u32 logical_cmd;
572 struct megasas_cmd *cmd;
573
574 /*
575 * Find out if this is logical or physical drive command.
576 */
577 logical_cmd = MEGASAS_IS_LOGICAL(scp);
578
579 /*
580 * Logical drive command
581 */
582 if (logical_cmd) {
583
584 if (scp->device->id >= MEGASAS_MAX_LD) {
585 scp->result = DID_BAD_TARGET << 16;
586 return NULL;
587 }
588
589 switch (scp->cmnd[0]) {
590
591 case READ_10:
592 case WRITE_10:
593 case READ_12:
594 case WRITE_12:
595 case READ_6:
596 case WRITE_6:
597 case READ_16:
598 case WRITE_16:
599 /*
600 * Fail for LUN > 0
601 */
602 if (scp->device->lun) {
603 scp->result = DID_BAD_TARGET << 16;
604 return NULL;
605 }
606
607 cmd = megasas_get_cmd(instance);
608
609 if (!cmd) {
610 scp->result = DID_IMM_RETRY << 16;
611 return NULL;
612 }
613
614 *frame_count = megasas_build_ldio(instance, scp, cmd);
615
616 if (!(*frame_count)) {
617 megasas_return_cmd(instance, cmd);
618 return NULL;
619 }
620
621 return cmd;
622
623 default:
624 /*
625 * Fail for LUN > 0
626 */
627 if (scp->device->lun) {
628 scp->result = DID_BAD_TARGET << 16;
629 return NULL;
630 }
631
632 cmd = megasas_get_cmd(instance);
633
634 if (!cmd) {
635 scp->result = DID_IMM_RETRY << 16;
636 return NULL;
637 }
638
639 *frame_count = megasas_build_dcdb(instance, scp, cmd);
640
641 if (!(*frame_count)) {
642 megasas_return_cmd(instance, cmd);
643 return NULL;
644 }
645
646 return cmd;
647 }
648 } else {
649 cmd = megasas_get_cmd(instance);
650
651 if (!cmd) {
652 scp->result = DID_IMM_RETRY << 16;
653 return NULL;
654 }
655
656 *frame_count = megasas_build_dcdb(instance, scp, cmd);
657
658 if (!(*frame_count)) {
659 megasas_return_cmd(instance, cmd);
660 return NULL;
661 }
662
663 return cmd;
664 }
665
666 return NULL;
667}
668
669/**
670 * megasas_queue_command - Queue entry point
671 * @scmd: SCSI command to be queued
672 * @done: Callback entry point
673 */
674static int
675megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
676{
677 u32 frame_count;
678 unsigned long flags;
679 struct megasas_cmd *cmd;
680 struct megasas_instance *instance;
681
682 instance = (struct megasas_instance *)
683 scmd->device->host->hostdata;
684 scmd->scsi_done = done;
685 scmd->result = 0;
686
687 cmd = megasas_build_cmd(instance, scmd, &frame_count);
688
689 if (!cmd) {
690 done(scmd);
691 return 0;
692 }
693
694 cmd->scmd = scmd;
695 scmd->SCp.ptr = (char *)cmd;
696 scmd->SCp.sent_command = jiffies;
697
698 /*
699 * Issue the command to the FW
700 */
701 spin_lock_irqsave(&instance->instance_lock, flags);
702 instance->fw_outstanding++;
703 spin_unlock_irqrestore(&instance->instance_lock, flags);
704
705 writel(((cmd->frame_phys_addr >> 3) | (cmd->frame_count - 1)),
706 &instance->reg_set->inbound_queue_port);
707
708 return 0;
709}
710
711/**
712 * megasas_wait_for_outstanding - Wait for all outstanding cmds
713 * @instance: Adapter soft state
714 *
715 * This function waits for upto MEGASAS_RESET_WAIT_TIME seconds for FW to
716 * complete all its outstanding commands. Returns error if one or more IOs
717 * are pending after this time period. It also marks the controller dead.
718 */
719static int megasas_wait_for_outstanding(struct megasas_instance *instance)
720{
721 int i;
722 u32 wait_time = MEGASAS_RESET_WAIT_TIME;
723
724 for (i = 0; i < wait_time; i++) {
725
726 if (!instance->fw_outstanding)
727 break;
728
729 if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
730 printk(KERN_NOTICE "megasas: [%2d]waiting for %d "
731 "commands to complete\n", i,
732 instance->fw_outstanding);
733 }
734
735 msleep(1000);
736 }
737
738 if (instance->fw_outstanding) {
739 instance->hw_crit_error = 1;
740 return FAILED;
741 }
742
743 return SUCCESS;
744}
745
746/**
747 * megasas_generic_reset - Generic reset routine
748 * @scmd: Mid-layer SCSI command
749 *
750 * This routine implements a generic reset handler for device, bus and host
751 * reset requests. Device, bus and host specific reset handlers can use this
752 * function after they do their specific tasks.
753 */
754static int megasas_generic_reset(struct scsi_cmnd *scmd)
755{
756 int ret_val;
757 struct megasas_instance *instance;
758
759 instance = (struct megasas_instance *)scmd->device->host->hostdata;
760
761 printk(KERN_NOTICE "megasas: RESET -%ld cmd=%x <c=%d t=%d l=%d>\n",
762 scmd->serial_number, scmd->cmnd[0], scmd->device->channel,
763 scmd->device->id, scmd->device->lun);
764
765 if (instance->hw_crit_error) {
766 printk(KERN_ERR "megasas: cannot recover from previous reset "
767 "failures\n");
768 return FAILED;
769 }
770
771 spin_unlock(scmd->device->host->host_lock);
772
773 ret_val = megasas_wait_for_outstanding(instance);
774
775 if (ret_val == SUCCESS)
776 printk(KERN_NOTICE "megasas: reset successful \n");
777 else
778 printk(KERN_ERR "megasas: failed to do reset\n");
779
780 spin_lock(scmd->device->host->host_lock);
781
782 return ret_val;
783}
784
785static enum scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
786{
787 unsigned long seconds;
788
789 if (scmd->SCp.ptr) {
790 seconds = (jiffies - scmd->SCp.sent_command) / HZ;
791
792 if (seconds < 90) {
793 return EH_RESET_TIMER;
794 } else {
795 return EH_NOT_HANDLED;
796 }
797 }
798
799 return EH_HANDLED;
800}
801
802/**
803 * megasas_reset_device - Device reset handler entry point
804 */
805static int megasas_reset_device(struct scsi_cmnd *scmd)
806{
807 int ret;
808
809 /*
810 * First wait for all commands to complete
811 */
812 ret = megasas_generic_reset(scmd);
813
814 return ret;
815}
816
817/**
818 * megasas_reset_bus_host - Bus & host reset handler entry point
819 */
820static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
821{
822 int ret;
823
824 /*
825 * Frist wait for all commands to complete
826 */
827 ret = megasas_generic_reset(scmd);
828
829 return ret;
830}
831
832/**
833 * megasas_service_aen - Processes an event notification
834 * @instance: Adapter soft state
835 * @cmd: AEN command completed by the ISR
836 *
837 * For AEN, driver sends a command down to FW that is held by the FW till an
838 * event occurs. When an event of interest occurs, FW completes the command
839 * that it was previously holding.
840 *
841 * This routines sends SIGIO signal to processes that have registered with the
842 * driver for AEN.
843 */
844static void
845megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
846{
847 /*
848 * Don't signal app if it is just an aborted previously registered aen
849 */
850 if (!cmd->abort_aen)
851 kill_fasync(&megasas_async_queue, SIGIO, POLL_IN);
852 else
853 cmd->abort_aen = 0;
854
855 instance->aen_cmd = NULL;
856 megasas_return_cmd(instance, cmd);
857}
858
859/*
860 * Scsi host template for megaraid_sas driver
861 */
862static struct scsi_host_template megasas_template = {
863
864 .module = THIS_MODULE,
865 .name = "LSI Logic SAS based MegaRAID driver",
866 .proc_name = "megaraid_sas",
867 .queuecommand = megasas_queue_command,
868 .eh_device_reset_handler = megasas_reset_device,
869 .eh_bus_reset_handler = megasas_reset_bus_host,
870 .eh_host_reset_handler = megasas_reset_bus_host,
871 .eh_timed_out = megasas_reset_timer,
872 .use_clustering = ENABLE_CLUSTERING,
873};
874
875/**
876 * megasas_complete_int_cmd - Completes an internal command
877 * @instance: Adapter soft state
878 * @cmd: Command to be completed
879 *
880 * The megasas_issue_blocked_cmd() function waits for a command to complete
881 * after it issues a command. This function wakes up that waiting routine by
882 * calling wake_up() on the wait queue.
883 */
884static void
885megasas_complete_int_cmd(struct megasas_instance *instance,
886 struct megasas_cmd *cmd)
887{
888 cmd->cmd_status = cmd->frame->io.cmd_status;
889
890 if (cmd->cmd_status == ENODATA) {
891 cmd->cmd_status = 0;
892 }
893 wake_up(&instance->int_cmd_wait_q);
894}
895
896/**
897 * megasas_complete_abort - Completes aborting a command
898 * @instance: Adapter soft state
899 * @cmd: Cmd that was issued to abort another cmd
900 *
901 * The megasas_issue_blocked_abort_cmd() function waits on abort_cmd_wait_q
902 * after it issues an abort on a previously issued command. This function
903 * wakes up all functions waiting on the same wait queue.
904 */
905static void
906megasas_complete_abort(struct megasas_instance *instance,
907 struct megasas_cmd *cmd)
908{
909 if (cmd->sync_cmd) {
910 cmd->sync_cmd = 0;
911 cmd->cmd_status = 0;
912 wake_up(&instance->abort_cmd_wait_q);
913 }
914
915 return;
916}
917
918/**
919 * megasas_unmap_sgbuf - Unmap SG buffers
920 * @instance: Adapter soft state
921 * @cmd: Completed command
922 */
923static inline void
924megasas_unmap_sgbuf(struct megasas_instance *instance, struct megasas_cmd *cmd)
925{
926 dma_addr_t buf_h;
927 u8 opcode;
928
929 if (cmd->scmd->use_sg) {
930 pci_unmap_sg(instance->pdev, cmd->scmd->request_buffer,
931 cmd->scmd->use_sg, cmd->scmd->sc_data_direction);
932 return;
933 }
934
935 if (!cmd->scmd->request_bufflen)
936 return;
937
938 opcode = cmd->frame->hdr.cmd;
939
940 if ((opcode == MFI_CMD_LD_READ) || (opcode == MFI_CMD_LD_WRITE)) {
941 if (IS_DMA64)
942 buf_h = cmd->frame->io.sgl.sge64[0].phys_addr;
943 else
944 buf_h = cmd->frame->io.sgl.sge32[0].phys_addr;
945 } else {
946 if (IS_DMA64)
947 buf_h = cmd->frame->pthru.sgl.sge64[0].phys_addr;
948 else
949 buf_h = cmd->frame->pthru.sgl.sge32[0].phys_addr;
950 }
951
952 pci_unmap_single(instance->pdev, buf_h, cmd->scmd->request_bufflen,
953 cmd->scmd->sc_data_direction);
954 return;
955}
956
957/**
958 * megasas_complete_cmd - Completes a command
959 * @instance: Adapter soft state
960 * @cmd: Command to be completed
961 * @alt_status: If non-zero, use this value as status to
962 * SCSI mid-layer instead of the value returned
963 * by the FW. This should be used if caller wants
964 * an alternate status (as in the case of aborted
965 * commands)
966 */
967static inline void
968megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
969 u8 alt_status)
970{
971 int exception = 0;
972 struct megasas_header *hdr = &cmd->frame->hdr;
973 unsigned long flags;
974
975 if (cmd->scmd) {
976 cmd->scmd->SCp.ptr = (char *)0;
977 }
978
979 switch (hdr->cmd) {
980
981 case MFI_CMD_PD_SCSI_IO:
982 case MFI_CMD_LD_SCSI_IO:
983
984 /*
985 * MFI_CMD_PD_SCSI_IO and MFI_CMD_LD_SCSI_IO could have been
986 * issued either through an IO path or an IOCTL path. If it
987 * was via IOCTL, we will send it to internal completion.
988 */
989 if (cmd->sync_cmd) {
990 cmd->sync_cmd = 0;
991 megasas_complete_int_cmd(instance, cmd);
992 break;
993 }
994
995 /*
996 * Don't export physical disk devices to mid-layer.
997 */
998 if (!MEGASAS_IS_LOGICAL(cmd->scmd) &&
999 (hdr->cmd_status == MFI_STAT_OK) &&
1000 (cmd->scmd->cmnd[0] == INQUIRY)) {
1001
1002 if (((*(u8 *) cmd->scmd->request_buffer) & 0x1F) ==
1003 TYPE_DISK) {
1004 cmd->scmd->result = DID_BAD_TARGET << 16;
1005 exception = 1;
1006 }
1007 }
1008
1009 case MFI_CMD_LD_READ:
1010 case MFI_CMD_LD_WRITE:
1011
1012 if (alt_status) {
1013 cmd->scmd->result = alt_status << 16;
1014 exception = 1;
1015 }
1016
1017 if (exception) {
1018
1019 spin_lock_irqsave(&instance->instance_lock, flags);
1020 instance->fw_outstanding--;
1021 spin_unlock_irqrestore(&instance->instance_lock, flags);
1022
1023 megasas_unmap_sgbuf(instance, cmd);
1024 cmd->scmd->scsi_done(cmd->scmd);
1025 megasas_return_cmd(instance, cmd);
1026
1027 break;
1028 }
1029
1030 switch (hdr->cmd_status) {
1031
1032 case MFI_STAT_OK:
1033 cmd->scmd->result = DID_OK << 16;
1034 break;
1035
1036 case MFI_STAT_SCSI_IO_FAILED:
1037 case MFI_STAT_LD_INIT_IN_PROGRESS:
1038 cmd->scmd->result =
1039 (DID_ERROR << 16) | hdr->scsi_status;
1040 break;
1041
1042 case MFI_STAT_SCSI_DONE_WITH_ERROR:
1043
1044 cmd->scmd->result = (DID_OK << 16) | hdr->scsi_status;
1045
1046 if (hdr->scsi_status == SAM_STAT_CHECK_CONDITION) {
1047 memset(cmd->scmd->sense_buffer, 0,
1048 SCSI_SENSE_BUFFERSIZE);
1049 memcpy(cmd->scmd->sense_buffer, cmd->sense,
1050 hdr->sense_len);
1051
1052 cmd->scmd->result |= DRIVER_SENSE << 24;
1053 }
1054
1055 break;
1056
1057 case MFI_STAT_LD_OFFLINE:
1058 case MFI_STAT_DEVICE_NOT_FOUND:
1059 cmd->scmd->result = DID_BAD_TARGET << 16;
1060 break;
1061
1062 default:
1063 printk(KERN_DEBUG "megasas: MFI FW status %#x\n",
1064 hdr->cmd_status);
1065 cmd->scmd->result = DID_ERROR << 16;
1066 break;
1067 }
1068
1069 spin_lock_irqsave(&instance->instance_lock, flags);
1070 instance->fw_outstanding--;
1071 spin_unlock_irqrestore(&instance->instance_lock, flags);
1072
1073 megasas_unmap_sgbuf(instance, cmd);
1074 cmd->scmd->scsi_done(cmd->scmd);
1075 megasas_return_cmd(instance, cmd);
1076
1077 break;
1078
1079 case MFI_CMD_SMP:
1080 case MFI_CMD_STP:
1081 case MFI_CMD_DCMD:
1082
1083 /*
1084 * See if got an event notification
1085 */
1086 if (cmd->frame->dcmd.opcode == MR_DCMD_CTRL_EVENT_WAIT)
1087 megasas_service_aen(instance, cmd);
1088 else
1089 megasas_complete_int_cmd(instance, cmd);
1090
1091 break;
1092
1093 case MFI_CMD_ABORT:
1094 /*
1095 * Cmd issued to abort another cmd returned
1096 */
1097 megasas_complete_abort(instance, cmd);
1098 break;
1099
1100 default:
1101 printk("megasas: Unknown command completed! [0x%X]\n",
1102 hdr->cmd);
1103 break;
1104 }
1105}
1106
1107/**
1108 * megasas_deplete_reply_queue - Processes all completed commands
1109 * @instance: Adapter soft state
1110 * @alt_status: Alternate status to be returned to
1111 * SCSI mid-layer instead of the status
1112 * returned by the FW
1113 */
1114static inline int
1115megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status)
1116{
1117 u32 status;
1118 u32 producer;
1119 u32 consumer;
1120 u32 context;
1121 struct megasas_cmd *cmd;
1122
1123 /*
1124 * Check if it is our interrupt
1125 */
1126 status = readl(&instance->reg_set->outbound_intr_status);
1127
1128 if (!(status & MFI_OB_INTR_STATUS_MASK)) {
1129 return IRQ_NONE;
1130 }
1131
1132 /*
1133 * Clear the interrupt by writing back the same value
1134 */
1135 writel(status, &instance->reg_set->outbound_intr_status);
1136
1137 producer = *instance->producer;
1138 consumer = *instance->consumer;
1139
1140 while (consumer != producer) {
1141 context = instance->reply_queue[consumer];
1142
1143 cmd = instance->cmd_list[context];
1144
1145 megasas_complete_cmd(instance, cmd, alt_status);
1146
1147 consumer++;
1148 if (consumer == (instance->max_fw_cmds + 1)) {
1149 consumer = 0;
1150 }
1151 }
1152
1153 *instance->consumer = producer;
1154
1155 return IRQ_HANDLED;
1156}
1157
1158/**
1159 * megasas_isr - isr entry point
1160 */
1161static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs)
1162{
1163 return megasas_deplete_reply_queue((struct megasas_instance *)devp,
1164 DID_OK);
1165}
1166
1167/**
1168 * megasas_transition_to_ready - Move the FW to READY state
1169 * @reg_set: MFI register set
1170 *
1171 * During the initialization, FW passes can potentially be in any one of
1172 * several possible states. If the FW in operational, waiting-for-handshake
1173 * states, driver must take steps to bring it to ready state. Otherwise, it
1174 * has to wait for the ready state.
1175 */
1176static int
1177megasas_transition_to_ready(struct megasas_register_set __iomem * reg_set)
1178{
1179 int i;
1180 u8 max_wait;
1181 u32 fw_state;
1182 u32 cur_state;
1183
1184 fw_state = readl(&reg_set->outbound_msg_0) & MFI_STATE_MASK;
1185
1186 while (fw_state != MFI_STATE_READY) {
1187
1188 printk(KERN_INFO "megasas: Waiting for FW to come to ready"
1189 " state\n");
1190 switch (fw_state) {
1191
1192 case MFI_STATE_FAULT:
1193
1194 printk(KERN_DEBUG "megasas: FW in FAULT state!!\n");
1195 return -ENODEV;
1196
1197 case MFI_STATE_WAIT_HANDSHAKE:
1198 /*
1199 * Set the CLR bit in inbound doorbell
1200 */
1201 writel(MFI_INIT_CLEAR_HANDSHAKE,
1202 &reg_set->inbound_doorbell);
1203
1204 max_wait = 2;
1205 cur_state = MFI_STATE_WAIT_HANDSHAKE;
1206 break;
1207
1208 case MFI_STATE_OPERATIONAL:
1209 /*
1210 * Bring it to READY state; assuming max wait 2 secs
1211 */
1212 megasas_disable_intr(reg_set);
1213 writel(MFI_INIT_READY, &reg_set->inbound_doorbell);
1214
1215 max_wait = 10;
1216 cur_state = MFI_STATE_OPERATIONAL;
1217 break;
1218
1219 case MFI_STATE_UNDEFINED:
1220 /*
1221 * This state should not last for more than 2 seconds
1222 */
1223 max_wait = 2;
1224 cur_state = MFI_STATE_UNDEFINED;
1225 break;
1226
1227 case MFI_STATE_BB_INIT:
1228 max_wait = 2;
1229 cur_state = MFI_STATE_BB_INIT;
1230 break;
1231
1232 case MFI_STATE_FW_INIT:
1233 max_wait = 20;
1234 cur_state = MFI_STATE_FW_INIT;
1235 break;
1236
1237 case MFI_STATE_FW_INIT_2:
1238 max_wait = 20;
1239 cur_state = MFI_STATE_FW_INIT_2;
1240 break;
1241
1242 case MFI_STATE_DEVICE_SCAN:
1243 max_wait = 20;
1244 cur_state = MFI_STATE_DEVICE_SCAN;
1245 break;
1246
1247 case MFI_STATE_FLUSH_CACHE:
1248 max_wait = 20;
1249 cur_state = MFI_STATE_FLUSH_CACHE;
1250 break;
1251
1252 default:
1253 printk(KERN_DEBUG "megasas: Unknown state 0x%x\n",
1254 fw_state);
1255 return -ENODEV;
1256 }
1257
1258 /*
1259 * The cur_state should not last for more than max_wait secs
1260 */
1261 for (i = 0; i < (max_wait * 1000); i++) {
1262 fw_state = MFI_STATE_MASK &
1263 readl(&reg_set->outbound_msg_0);
1264
1265 if (fw_state == cur_state) {
1266 msleep(1);
1267 } else
1268 break;
1269 }
1270
1271 /*
1272 * Return error if fw_state hasn't changed after max_wait
1273 */
1274 if (fw_state == cur_state) {
1275 printk(KERN_DEBUG "FW state [%d] hasn't changed "
1276 "in %d secs\n", fw_state, max_wait);
1277 return -ENODEV;
1278 }
1279 };
1280
1281 return 0;
1282}
1283
1284/**
1285 * megasas_teardown_frame_pool - Destroy the cmd frame DMA pool
1286 * @instance: Adapter soft state
1287 */
1288static void megasas_teardown_frame_pool(struct megasas_instance *instance)
1289{
1290 int i;
1291 u32 max_cmd = instance->max_fw_cmds;
1292 struct megasas_cmd *cmd;
1293
1294 if (!instance->frame_dma_pool)
1295 return;
1296
1297 /*
1298 * Return all frames to pool
1299 */
1300 for (i = 0; i < max_cmd; i++) {
1301
1302 cmd = instance->cmd_list[i];
1303
1304 if (cmd->frame)
1305 pci_pool_free(instance->frame_dma_pool, cmd->frame,
1306 cmd->frame_phys_addr);
1307
1308 if (cmd->sense)
1309 pci_pool_free(instance->sense_dma_pool, cmd->frame,
1310 cmd->sense_phys_addr);
1311 }
1312
1313 /*
1314 * Now destroy the pool itself
1315 */
1316 pci_pool_destroy(instance->frame_dma_pool);
1317 pci_pool_destroy(instance->sense_dma_pool);
1318
1319 instance->frame_dma_pool = NULL;
1320 instance->sense_dma_pool = NULL;
1321}
1322
1323/**
1324 * megasas_create_frame_pool - Creates DMA pool for cmd frames
1325 * @instance: Adapter soft state
1326 *
1327 * Each command packet has an embedded DMA memory buffer that is used for
1328 * filling MFI frame and the SG list that immediately follows the frame. This
1329 * function creates those DMA memory buffers for each command packet by using
1330 * PCI pool facility.
1331 */
1332static int megasas_create_frame_pool(struct megasas_instance *instance)
1333{
1334 int i;
1335 u32 max_cmd;
1336 u32 sge_sz;
1337 u32 sgl_sz;
1338 u32 total_sz;
1339 u32 frame_count;
1340 struct megasas_cmd *cmd;
1341
1342 max_cmd = instance->max_fw_cmds;
1343
1344 /*
1345 * Size of our frame is 64 bytes for MFI frame, followed by max SG
1346 * elements and finally SCSI_SENSE_BUFFERSIZE bytes for sense buffer
1347 */
1348 sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
1349 sizeof(struct megasas_sge32);
1350
1351 /*
1352 * Calculated the number of 64byte frames required for SGL
1353 */
1354 sgl_sz = sge_sz * instance->max_num_sge;
1355 frame_count = (sgl_sz + MEGAMFI_FRAME_SIZE - 1) / MEGAMFI_FRAME_SIZE;
1356
1357 /*
1358 * We need one extra frame for the MFI command
1359 */
1360 frame_count++;
1361
1362 total_sz = MEGAMFI_FRAME_SIZE * frame_count;
1363 /*
1364 * Use DMA pool facility provided by PCI layer
1365 */
1366 instance->frame_dma_pool = pci_pool_create("megasas frame pool",
1367 instance->pdev, total_sz, 64,
1368 0);
1369
1370 if (!instance->frame_dma_pool) {
1371 printk(KERN_DEBUG "megasas: failed to setup frame pool\n");
1372 return -ENOMEM;
1373 }
1374
1375 instance->sense_dma_pool = pci_pool_create("megasas sense pool",
1376 instance->pdev, 128, 4, 0);
1377
1378 if (!instance->sense_dma_pool) {
1379 printk(KERN_DEBUG "megasas: failed to setup sense pool\n");
1380
1381 pci_pool_destroy(instance->frame_dma_pool);
1382 instance->frame_dma_pool = NULL;
1383
1384 return -ENOMEM;
1385 }
1386
1387 /*
1388 * Allocate and attach a frame to each of the commands in cmd_list.
1389 * By making cmd->index as the context instead of the &cmd, we can
1390 * always use 32bit context regardless of the architecture
1391 */
1392 for (i = 0; i < max_cmd; i++) {
1393
1394 cmd = instance->cmd_list[i];
1395
1396 cmd->frame = pci_pool_alloc(instance->frame_dma_pool,
1397 GFP_KERNEL, &cmd->frame_phys_addr);
1398
1399 cmd->sense = pci_pool_alloc(instance->sense_dma_pool,
1400 GFP_KERNEL, &cmd->sense_phys_addr);
1401
1402 /*
1403 * megasas_teardown_frame_pool() takes care of freeing
1404 * whatever has been allocated
1405 */
1406 if (!cmd->frame || !cmd->sense) {
1407 printk(KERN_DEBUG "megasas: pci_pool_alloc failed \n");
1408 megasas_teardown_frame_pool(instance);
1409 return -ENOMEM;
1410 }
1411
1412 cmd->frame->io.context = cmd->index;
1413 }
1414
1415 return 0;
1416}
1417
1418/**
1419 * megasas_free_cmds - Free all the cmds in the free cmd pool
1420 * @instance: Adapter soft state
1421 */
1422static void megasas_free_cmds(struct megasas_instance *instance)
1423{
1424 int i;
1425 /* First free the MFI frame pool */
1426 megasas_teardown_frame_pool(instance);
1427
1428 /* Free all the commands in the cmd_list */
1429 for (i = 0; i < instance->max_fw_cmds; i++)
1430 kfree(instance->cmd_list[i]);
1431
1432 /* Free the cmd_list buffer itself */
1433 kfree(instance->cmd_list);
1434 instance->cmd_list = NULL;
1435
1436 INIT_LIST_HEAD(&instance->cmd_pool);
1437}
1438
1439/**
1440 * megasas_alloc_cmds - Allocates the command packets
1441 * @instance: Adapter soft state
1442 *
1443 * Each command that is issued to the FW, whether IO commands from the OS or
1444 * internal commands like IOCTLs, are wrapped in local data structure called
1445 * megasas_cmd. The frame embedded in this megasas_cmd is actually issued to
1446 * the FW.
1447 *
1448 * Each frame has a 32-bit field called context (tag). This context is used
1449 * to get back the megasas_cmd from the frame when a frame gets completed in
1450 * the ISR. Typically the address of the megasas_cmd itself would be used as
1451 * the context. But we wanted to keep the differences between 32 and 64 bit
1452 * systems to the mininum. We always use 32 bit integers for the context. In
1453 * this driver, the 32 bit values are the indices into an array cmd_list.
1454 * This array is used only to look up the megasas_cmd given the context. The
1455 * free commands themselves are maintained in a linked list called cmd_pool.
1456 */
1457static int megasas_alloc_cmds(struct megasas_instance *instance)
1458{
1459 int i;
1460 int j;
1461 u32 max_cmd;
1462 struct megasas_cmd *cmd;
1463
1464 max_cmd = instance->max_fw_cmds;
1465
1466 /*
1467 * instance->cmd_list is an array of struct megasas_cmd pointers.
1468 * Allocate the dynamic array first and then allocate individual
1469 * commands.
1470 */
1471 instance->cmd_list = kmalloc(sizeof(struct megasas_cmd *) * max_cmd,
1472 GFP_KERNEL);
1473
1474 if (!instance->cmd_list) {
1475 printk(KERN_DEBUG "megasas: out of memory\n");
1476 return -ENOMEM;
1477 }
1478
1479 memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) * max_cmd);
1480
1481 for (i = 0; i < max_cmd; i++) {
1482 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
1483 GFP_KERNEL);
1484
1485 if (!instance->cmd_list[i]) {
1486
1487 for (j = 0; j < i; j++)
1488 kfree(instance->cmd_list[j]);
1489
1490 kfree(instance->cmd_list);
1491 instance->cmd_list = NULL;
1492
1493 return -ENOMEM;
1494 }
1495 }
1496
1497 /*
1498 * Add all the commands to command pool (instance->cmd_pool)
1499 */
1500 for (i = 0; i < max_cmd; i++) {
1501 cmd = instance->cmd_list[i];
1502 memset(cmd, 0, sizeof(struct megasas_cmd));
1503 cmd->index = i;
1504 cmd->instance = instance;
1505
1506 list_add_tail(&cmd->list, &instance->cmd_pool);
1507 }
1508
1509 /*
1510 * Create a frame pool and assign one frame to each cmd
1511 */
1512 if (megasas_create_frame_pool(instance)) {
1513 printk(KERN_DEBUG "megasas: Error creating frame DMA pool\n");
1514 megasas_free_cmds(instance);
1515 }
1516
1517 return 0;
1518}
1519
1520/**
1521 * megasas_get_controller_info - Returns FW's controller structure
1522 * @instance: Adapter soft state
1523 * @ctrl_info: Controller information structure
1524 *
1525 * Issues an internal command (DCMD) to get the FW's controller structure.
1526 * This information is mainly used to find out the maximum IO transfer per
1527 * command supported by the FW.
1528 */
1529static int
1530megasas_get_ctrl_info(struct megasas_instance *instance,
1531 struct megasas_ctrl_info *ctrl_info)
1532{
1533 int ret = 0;
1534 struct megasas_cmd *cmd;
1535 struct megasas_dcmd_frame *dcmd;
1536 struct megasas_ctrl_info *ci;
1537 dma_addr_t ci_h = 0;
1538
1539 cmd = megasas_get_cmd(instance);
1540
1541 if (!cmd) {
1542 printk(KERN_DEBUG "megasas: Failed to get a free cmd\n");
1543 return -ENOMEM;
1544 }
1545
1546 dcmd = &cmd->frame->dcmd;
1547
1548 ci = pci_alloc_consistent(instance->pdev,
1549 sizeof(struct megasas_ctrl_info), &ci_h);
1550
1551 if (!ci) {
1552 printk(KERN_DEBUG "Failed to alloc mem for ctrl info\n");
1553 megasas_return_cmd(instance, cmd);
1554 return -ENOMEM;
1555 }
1556
1557 memset(ci, 0, sizeof(*ci));
1558 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
1559
1560 dcmd->cmd = MFI_CMD_DCMD;
1561 dcmd->cmd_status = 0xFF;
1562 dcmd->sge_count = 1;
1563 dcmd->flags = MFI_FRAME_DIR_READ;
1564 dcmd->timeout = 0;
1565 dcmd->data_xfer_len = sizeof(struct megasas_ctrl_info);
1566 dcmd->opcode = MR_DCMD_CTRL_GET_INFO;
1567 dcmd->sgl.sge32[0].phys_addr = ci_h;
1568 dcmd->sgl.sge32[0].length = sizeof(struct megasas_ctrl_info);
1569
1570 if (!megasas_issue_polled(instance, cmd)) {
1571 ret = 0;
1572 memcpy(ctrl_info, ci, sizeof(struct megasas_ctrl_info));
1573 } else {
1574 ret = -1;
1575 }
1576
1577 pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info),
1578 ci, ci_h);
1579
1580 megasas_return_cmd(instance, cmd);
1581 return ret;
1582}
1583
1584/**
1585 * megasas_init_mfi - Initializes the FW
1586 * @instance: Adapter soft state
1587 *
1588 * This is the main function for initializing MFI firmware.
1589 */
1590static int megasas_init_mfi(struct megasas_instance *instance)
1591{
1592 u32 context_sz;
1593 u32 reply_q_sz;
1594 u32 max_sectors_1;
1595 u32 max_sectors_2;
1596 struct megasas_register_set __iomem *reg_set;
1597
1598 struct megasas_cmd *cmd;
1599 struct megasas_ctrl_info *ctrl_info;
1600
1601 struct megasas_init_frame *init_frame;
1602 struct megasas_init_queue_info *initq_info;
1603 dma_addr_t init_frame_h;
1604 dma_addr_t initq_info_h;
1605
1606 /*
1607 * Map the message registers
1608 */
1609 instance->base_addr = pci_resource_start(instance->pdev, 0);
1610
1611 if (pci_request_regions(instance->pdev, "megasas: LSI Logic")) {
1612 printk(KERN_DEBUG "megasas: IO memory region busy!\n");
1613 return -EBUSY;
1614 }
1615
1616 instance->reg_set = ioremap_nocache(instance->base_addr, 8192);
1617
1618 if (!instance->reg_set) {
1619 printk(KERN_DEBUG "megasas: Failed to map IO mem\n");
1620 goto fail_ioremap;
1621 }
1622
1623 reg_set = instance->reg_set;
1624
1625 /*
1626 * We expect the FW state to be READY
1627 */
1628 if (megasas_transition_to_ready(instance->reg_set))
1629 goto fail_ready_state;
1630
1631 /*
1632 * Get various operational parameters from status register
1633 */
1634 instance->max_fw_cmds = readl(&reg_set->outbound_msg_0) & 0x00FFFF;
1635 instance->max_num_sge = (readl(&reg_set->outbound_msg_0) & 0xFF0000) >>
1636 0x10;
1637 /*
1638 * Create a pool of commands
1639 */
1640 if (megasas_alloc_cmds(instance))
1641 goto fail_alloc_cmds;
1642
1643 /*
1644 * Allocate memory for reply queue. Length of reply queue should
1645 * be _one_ more than the maximum commands handled by the firmware.
1646 *
1647 * Note: When FW completes commands, it places corresponding contex
1648 * values in this circular reply queue. This circular queue is a fairly
1649 * typical producer-consumer queue. FW is the producer (of completed
1650 * commands) and the driver is the consumer.
1651 */
1652 context_sz = sizeof(u32);
1653 reply_q_sz = context_sz * (instance->max_fw_cmds + 1);
1654
1655 instance->reply_queue = pci_alloc_consistent(instance->pdev,
1656 reply_q_sz,
1657 &instance->reply_queue_h);
1658
1659 if (!instance->reply_queue) {
1660 printk(KERN_DEBUG "megasas: Out of DMA mem for reply queue\n");
1661 goto fail_reply_queue;
1662 }
1663
1664 /*
1665 * Prepare a init frame. Note the init frame points to queue info
1666 * structure. Each frame has SGL allocated after first 64 bytes. For
1667 * this frame - since we don't need any SGL - we use SGL's space as
1668 * queue info structure
1669 *
1670 * We will not get a NULL command below. We just created the pool.
1671 */
1672 cmd = megasas_get_cmd(instance);
1673
1674 init_frame = (struct megasas_init_frame *)cmd->frame;
1675 initq_info = (struct megasas_init_queue_info *)
1676 ((unsigned long)init_frame + 64);
1677
1678 init_frame_h = cmd->frame_phys_addr;
1679 initq_info_h = init_frame_h + 64;
1680
1681 memset(init_frame, 0, MEGAMFI_FRAME_SIZE);
1682 memset(initq_info, 0, sizeof(struct megasas_init_queue_info));
1683
1684 initq_info->reply_queue_entries = instance->max_fw_cmds + 1;
1685 initq_info->reply_queue_start_phys_addr_lo = instance->reply_queue_h;
1686
1687 initq_info->producer_index_phys_addr_lo = instance->producer_h;
1688 initq_info->consumer_index_phys_addr_lo = instance->consumer_h;
1689
1690 init_frame->cmd = MFI_CMD_INIT;
1691 init_frame->cmd_status = 0xFF;
1692 init_frame->queue_info_new_phys_addr_lo = initq_info_h;
1693
1694 init_frame->data_xfer_len = sizeof(struct megasas_init_queue_info);
1695
1696 /*
1697 * Issue the init frame in polled mode
1698 */
1699 if (megasas_issue_polled(instance, cmd)) {
1700 printk(KERN_DEBUG "megasas: Failed to init firmware\n");
1701 goto fail_fw_init;
1702 }
1703
1704 megasas_return_cmd(instance, cmd);
1705
1706 ctrl_info = kmalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL);
1707
1708 /*
1709 * Compute the max allowed sectors per IO: The controller info has two
1710 * limits on max sectors. Driver should use the minimum of these two.
1711 *
1712 * 1 << stripe_sz_ops.min = max sectors per strip
1713 *
1714 * Note that older firmwares ( < FW ver 30) didn't report information
1715 * to calculate max_sectors_1. So the number ended up as zero always.
1716 */
1717 if (ctrl_info && !megasas_get_ctrl_info(instance, ctrl_info)) {
1718
1719 max_sectors_1 = (1 << ctrl_info->stripe_sz_ops.min) *
1720 ctrl_info->max_strips_per_io;
1721 max_sectors_2 = ctrl_info->max_request_size;
1722
1723 instance->max_sectors_per_req = (max_sectors_1 < max_sectors_2)
1724 ? max_sectors_1 : max_sectors_2;
1725 } else
1726 instance->max_sectors_per_req = instance->max_num_sge *
1727 PAGE_SIZE / 512;
1728
1729 kfree(ctrl_info);
1730
1731 return 0;
1732
1733 fail_fw_init:
1734 megasas_return_cmd(instance, cmd);
1735
1736 pci_free_consistent(instance->pdev, reply_q_sz,
1737 instance->reply_queue, instance->reply_queue_h);
1738 fail_reply_queue:
1739 megasas_free_cmds(instance);
1740
1741 fail_alloc_cmds:
1742 fail_ready_state:
1743 iounmap(instance->reg_set);
1744
1745 fail_ioremap:
1746 pci_release_regions(instance->pdev);
1747
1748 return -EINVAL;
1749}
1750
1751/**
1752 * megasas_release_mfi - Reverses the FW initialization
1753 * @intance: Adapter soft state
1754 */
1755static void megasas_release_mfi(struct megasas_instance *instance)
1756{
1757 u32 reply_q_sz = sizeof(u32) * (instance->max_fw_cmds + 1);
1758
1759 pci_free_consistent(instance->pdev, reply_q_sz,
1760 instance->reply_queue, instance->reply_queue_h);
1761
1762 megasas_free_cmds(instance);
1763
1764 iounmap(instance->reg_set);
1765
1766 pci_release_regions(instance->pdev);
1767}
1768
1769/**
1770 * megasas_get_seq_num - Gets latest event sequence numbers
1771 * @instance: Adapter soft state
1772 * @eli: FW event log sequence numbers information
1773 *
1774 * FW maintains a log of all events in a non-volatile area. Upper layers would
1775 * usually find out the latest sequence number of the events, the seq number at
1776 * the boot etc. They would "read" all the events below the latest seq number
1777 * by issuing a direct fw cmd (DCMD). For the future events (beyond latest seq
1778 * number), they would subsribe to AEN (asynchronous event notification) and
1779 * wait for the events to happen.
1780 */
1781static int
1782megasas_get_seq_num(struct megasas_instance *instance,
1783 struct megasas_evt_log_info *eli)
1784{
1785 struct megasas_cmd *cmd;
1786 struct megasas_dcmd_frame *dcmd;
1787 struct megasas_evt_log_info *el_info;
1788 dma_addr_t el_info_h = 0;
1789
1790 cmd = megasas_get_cmd(instance);
1791
1792 if (!cmd) {
1793 return -ENOMEM;
1794 }
1795
1796 dcmd = &cmd->frame->dcmd;
1797 el_info = pci_alloc_consistent(instance->pdev,
1798 sizeof(struct megasas_evt_log_info),
1799 &el_info_h);
1800
1801 if (!el_info) {
1802 megasas_return_cmd(instance, cmd);
1803 return -ENOMEM;
1804 }
1805
1806 memset(el_info, 0, sizeof(*el_info));
1807 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
1808
1809 dcmd->cmd = MFI_CMD_DCMD;
1810 dcmd->cmd_status = 0x0;
1811 dcmd->sge_count = 1;
1812 dcmd->flags = MFI_FRAME_DIR_READ;
1813 dcmd->timeout = 0;
1814 dcmd->data_xfer_len = sizeof(struct megasas_evt_log_info);
1815 dcmd->opcode = MR_DCMD_CTRL_EVENT_GET_INFO;
1816 dcmd->sgl.sge32[0].phys_addr = el_info_h;
1817 dcmd->sgl.sge32[0].length = sizeof(struct megasas_evt_log_info);
1818
1819 megasas_issue_blocked_cmd(instance, cmd);
1820
1821 /*
1822 * Copy the data back into callers buffer
1823 */
1824 memcpy(eli, el_info, sizeof(struct megasas_evt_log_info));
1825
1826 pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info),
1827 el_info, el_info_h);
1828
1829 megasas_return_cmd(instance, cmd);
1830
1831 return 0;
1832}
1833
1834/**
1835 * megasas_register_aen - Registers for asynchronous event notification
1836 * @instance: Adapter soft state
1837 * @seq_num: The starting sequence number
1838 * @class_locale: Class of the event
1839 *
1840 * This function subscribes for AEN for events beyond the @seq_num. It requests
1841 * to be notified if and only if the event is of type @class_locale
1842 */
1843static int
1844megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
1845 u32 class_locale_word)
1846{
1847 int ret_val;
1848 struct megasas_cmd *cmd;
1849 struct megasas_dcmd_frame *dcmd;
1850 union megasas_evt_class_locale curr_aen;
1851 union megasas_evt_class_locale prev_aen;
1852
1853 /*
1854 * If there an AEN pending already (aen_cmd), check if the
1855 * class_locale of that pending AEN is inclusive of the new
1856 * AEN request we currently have. If it is, then we don't have
1857 * to do anything. In other words, whichever events the current
1858 * AEN request is subscribing to, have already been subscribed
1859 * to.
1860 *
1861 * If the old_cmd is _not_ inclusive, then we have to abort
1862 * that command, form a class_locale that is superset of both
1863 * old and current and re-issue to the FW
1864 */
1865
1866 curr_aen.word = class_locale_word;
1867
1868 if (instance->aen_cmd) {
1869
1870 prev_aen.word = instance->aen_cmd->frame->dcmd.mbox.w[1];
1871
1872 /*
1873 * A class whose enum value is smaller is inclusive of all
1874 * higher values. If a PROGRESS (= -1) was previously
1875 * registered, then a new registration requests for higher
1876 * classes need not be sent to FW. They are automatically
1877 * included.
1878 *
1879 * Locale numbers don't have such hierarchy. They are bitmap
1880 * values
1881 */
1882 if ((prev_aen.members.class <= curr_aen.members.class) &&
1883 !((prev_aen.members.locale & curr_aen.members.locale) ^
1884 curr_aen.members.locale)) {
1885 /*
1886 * Previously issued event registration includes
1887 * current request. Nothing to do.
1888 */
1889 return 0;
1890 } else {
1891 curr_aen.members.locale |= prev_aen.members.locale;
1892
1893 if (prev_aen.members.class < curr_aen.members.class)
1894 curr_aen.members.class = prev_aen.members.class;
1895
1896 instance->aen_cmd->abort_aen = 1;
1897 ret_val = megasas_issue_blocked_abort_cmd(instance,
1898 instance->
1899 aen_cmd);
1900
1901 if (ret_val) {
1902 printk(KERN_DEBUG "megasas: Failed to abort "
1903 "previous AEN command\n");
1904 return ret_val;
1905 }
1906 }
1907 }
1908
1909 cmd = megasas_get_cmd(instance);
1910
1911 if (!cmd)
1912 return -ENOMEM;
1913
1914 dcmd = &cmd->frame->dcmd;
1915
1916 memset(instance->evt_detail, 0, sizeof(struct megasas_evt_detail));
1917
1918 /*
1919 * Prepare DCMD for aen registration
1920 */
1921 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
1922
1923 dcmd->cmd = MFI_CMD_DCMD;
1924 dcmd->cmd_status = 0x0;
1925 dcmd->sge_count = 1;
1926 dcmd->flags = MFI_FRAME_DIR_READ;
1927 dcmd->timeout = 0;
1928 dcmd->data_xfer_len = sizeof(struct megasas_evt_detail);
1929 dcmd->opcode = MR_DCMD_CTRL_EVENT_WAIT;
1930 dcmd->mbox.w[0] = seq_num;
1931 dcmd->mbox.w[1] = curr_aen.word;
1932 dcmd->sgl.sge32[0].phys_addr = (u32) instance->evt_detail_h;
1933 dcmd->sgl.sge32[0].length = sizeof(struct megasas_evt_detail);
1934
1935 /*
1936 * Store reference to the cmd used to register for AEN. When an
1937 * application wants us to register for AEN, we have to abort this
1938 * cmd and re-register with a new EVENT LOCALE supplied by that app
1939 */
1940 instance->aen_cmd = cmd;
1941
1942 /*
1943 * Issue the aen registration frame
1944 */
1945 writel(cmd->frame_phys_addr >> 3,
1946 &instance->reg_set->inbound_queue_port);
1947
1948 return 0;
1949}
1950
1951/**
1952 * megasas_start_aen - Subscribes to AEN during driver load time
1953 * @instance: Adapter soft state
1954 */
1955static int megasas_start_aen(struct megasas_instance *instance)
1956{
1957 struct megasas_evt_log_info eli;
1958 union megasas_evt_class_locale class_locale;
1959
1960 /*
1961 * Get the latest sequence number from FW
1962 */
1963 memset(&eli, 0, sizeof(eli));
1964
1965 if (megasas_get_seq_num(instance, &eli))
1966 return -1;
1967
1968 /*
1969 * Register AEN with FW for latest sequence number plus 1
1970 */
1971 class_locale.members.reserved = 0;
1972 class_locale.members.locale = MR_EVT_LOCALE_ALL;
1973 class_locale.members.class = MR_EVT_CLASS_DEBUG;
1974
1975 return megasas_register_aen(instance, eli.newest_seq_num + 1,
1976 class_locale.word);
1977}
1978
1979/**
1980 * megasas_io_attach - Attaches this driver to SCSI mid-layer
1981 * @instance: Adapter soft state
1982 */
1983static int megasas_io_attach(struct megasas_instance *instance)
1984{
1985 struct Scsi_Host *host = instance->host;
1986
1987 /*
1988 * Export parameters required by SCSI mid-layer
1989 */
1990 host->irq = instance->pdev->irq;
1991 host->unique_id = instance->unique_id;
1992 host->can_queue = instance->max_fw_cmds - MEGASAS_INT_CMDS;
1993 host->this_id = instance->init_id;
1994 host->sg_tablesize = instance->max_num_sge;
1995 host->max_sectors = instance->max_sectors_per_req;
1996 host->cmd_per_lun = 128;
1997 host->max_channel = MEGASAS_MAX_CHANNELS - 1;
1998 host->max_id = MEGASAS_MAX_DEV_PER_CHANNEL;
1999 host->max_lun = MEGASAS_MAX_LUN;
2000
2001 /*
2002 * Notify the mid-layer about the new controller
2003 */
2004 if (scsi_add_host(host, &instance->pdev->dev)) {
2005 printk(KERN_DEBUG "megasas: scsi_add_host failed\n");
2006 return -ENODEV;
2007 }
2008
2009 /*
2010 * Trigger SCSI to scan our drives
2011 */
2012 scsi_scan_host(host);
2013 return 0;
2014}
2015
2016/**
2017 * megasas_probe_one - PCI hotplug entry point
2018 * @pdev: PCI device structure
2019 * @id: PCI ids of supported hotplugged adapter
2020 */
2021static int __devinit
2022megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2023{
2024 int rval;
2025 struct Scsi_Host *host;
2026 struct megasas_instance *instance;
2027
2028 /*
2029 * Announce PCI information
2030 */
2031 printk(KERN_INFO "megasas: %#4.04x:%#4.04x:%#4.04x:%#4.04x: ",
2032 pdev->vendor, pdev->device, pdev->subsystem_vendor,
2033 pdev->subsystem_device);
2034
2035 printk("bus %d:slot %d:func %d\n",
2036 pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
2037
2038 /*
2039 * PCI prepping: enable device set bus mastering and dma mask
2040 */
2041 rval = pci_enable_device(pdev);
2042
2043 if (rval) {
2044 return rval;
2045 }
2046
2047 pci_set_master(pdev);
2048
2049 /*
2050 * All our contollers are capable of performing 64-bit DMA
2051 */
2052 if (IS_DMA64) {
2053 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
2054
2055 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)
2056 goto fail_set_dma_mask;
2057 }
2058 } else {
2059 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)
2060 goto fail_set_dma_mask;
2061 }
2062
2063 host = scsi_host_alloc(&megasas_template,
2064 sizeof(struct megasas_instance));
2065
2066 if (!host) {
2067 printk(KERN_DEBUG "megasas: scsi_host_alloc failed\n");
2068 goto fail_alloc_instance;
2069 }
2070
2071 instance = (struct megasas_instance *)host->hostdata;
2072 memset(instance, 0, sizeof(*instance));
2073
2074 instance->producer = pci_alloc_consistent(pdev, sizeof(u32),
2075 &instance->producer_h);
2076 instance->consumer = pci_alloc_consistent(pdev, sizeof(u32),
2077 &instance->consumer_h);
2078
2079 if (!instance->producer || !instance->consumer) {
2080 printk(KERN_DEBUG "megasas: Failed to allocate memory for "
2081 "producer, consumer\n");
2082 goto fail_alloc_dma_buf;
2083 }
2084
2085 *instance->producer = 0;
2086 *instance->consumer = 0;
2087
2088 instance->evt_detail = pci_alloc_consistent(pdev,
2089 sizeof(struct
2090 megasas_evt_detail),
2091 &instance->evt_detail_h);
2092
2093 if (!instance->evt_detail) {
2094 printk(KERN_DEBUG "megasas: Failed to allocate memory for "
2095 "event detail structure\n");
2096 goto fail_alloc_dma_buf;
2097 }
2098
2099 /*
2100 * Initialize locks and queues
2101 */
2102 INIT_LIST_HEAD(&instance->cmd_pool);
2103
2104 init_waitqueue_head(&instance->int_cmd_wait_q);
2105 init_waitqueue_head(&instance->abort_cmd_wait_q);
2106
2107 spin_lock_init(&instance->cmd_pool_lock);
2108 spin_lock_init(&instance->instance_lock);
2109
2110 sema_init(&instance->aen_mutex, 1);
2111 sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS);
2112
2113 /*
2114 * Initialize PCI related and misc parameters
2115 */
2116 instance->pdev = pdev;
2117 instance->host = host;
2118 instance->unique_id = pdev->bus->number << 8 | pdev->devfn;
2119 instance->init_id = MEGASAS_DEFAULT_INIT_ID;
2120
2121 /*
2122 * Initialize MFI Firmware
2123 */
2124 if (megasas_init_mfi(instance))
2125 goto fail_init_mfi;
2126
2127 /*
2128 * Register IRQ
2129 */
2130 if (request_irq(pdev->irq, megasas_isr, SA_SHIRQ, "megasas", instance)) {
2131 printk(KERN_DEBUG "megasas: Failed to register IRQ\n");
2132 goto fail_irq;
2133 }
2134
2135 megasas_enable_intr(instance->reg_set);
2136
2137 /*
2138 * Store instance in PCI softstate
2139 */
2140 pci_set_drvdata(pdev, instance);
2141
2142 /*
2143 * Add this controller to megasas_mgmt_info structure so that it
2144 * can be exported to management applications
2145 */
2146 megasas_mgmt_info.count++;
2147 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = instance;
2148 megasas_mgmt_info.max_index++;
2149
2150 /*
2151 * Initiate AEN (Asynchronous Event Notification)
2152 */
2153 if (megasas_start_aen(instance)) {
2154 printk(KERN_DEBUG "megasas: start aen failed\n");
2155 goto fail_start_aen;
2156 }
2157
2158 /*
2159 * Register with SCSI mid-layer
2160 */
2161 if (megasas_io_attach(instance))
2162 goto fail_io_attach;
2163
2164 return 0;
2165
2166 fail_start_aen:
2167 fail_io_attach:
2168 megasas_mgmt_info.count--;
2169 megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
2170 megasas_mgmt_info.max_index--;
2171
2172 pci_set_drvdata(pdev, NULL);
2173 megasas_disable_intr(instance->reg_set);
2174 free_irq(instance->pdev->irq, instance);
2175
2176 megasas_release_mfi(instance);
2177
2178 fail_irq:
2179 fail_init_mfi:
2180 fail_alloc_dma_buf:
2181 if (instance->evt_detail)
2182 pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),
2183 instance->evt_detail,
2184 instance->evt_detail_h);
2185
2186 if (instance->producer)
2187 pci_free_consistent(pdev, sizeof(u32), instance->producer,
2188 instance->producer_h);
2189 if (instance->consumer)
2190 pci_free_consistent(pdev, sizeof(u32), instance->consumer,
2191 instance->consumer_h);
2192 scsi_host_put(host);
2193
2194 fail_alloc_instance:
2195 fail_set_dma_mask:
2196 pci_disable_device(pdev);
2197
2198 return -ENODEV;
2199}
2200
2201/**
2202 * megasas_flush_cache - Requests FW to flush all its caches
2203 * @instance: Adapter soft state
2204 */
2205static void megasas_flush_cache(struct megasas_instance *instance)
2206{
2207 struct megasas_cmd *cmd;
2208 struct megasas_dcmd_frame *dcmd;
2209
2210 cmd = megasas_get_cmd(instance);
2211
2212 if (!cmd)
2213 return;
2214
2215 dcmd = &cmd->frame->dcmd;
2216
2217 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
2218
2219 dcmd->cmd = MFI_CMD_DCMD;
2220 dcmd->cmd_status = 0x0;
2221 dcmd->sge_count = 0;
2222 dcmd->flags = MFI_FRAME_DIR_NONE;
2223 dcmd->timeout = 0;
2224 dcmd->data_xfer_len = 0;
2225 dcmd->opcode = MR_DCMD_CTRL_CACHE_FLUSH;
2226 dcmd->mbox.b[0] = MR_FLUSH_CTRL_CACHE | MR_FLUSH_DISK_CACHE;
2227
2228 megasas_issue_blocked_cmd(instance, cmd);
2229
2230 megasas_return_cmd(instance, cmd);
2231
2232 return;
2233}
2234
2235/**
2236 * megasas_shutdown_controller - Instructs FW to shutdown the controller
2237 * @instance: Adapter soft state
2238 */
2239static void megasas_shutdown_controller(struct megasas_instance *instance)
2240{
2241 struct megasas_cmd *cmd;
2242 struct megasas_dcmd_frame *dcmd;
2243
2244 cmd = megasas_get_cmd(instance);
2245
2246 if (!cmd)
2247 return;
2248
2249 if (instance->aen_cmd)
2250 megasas_issue_blocked_abort_cmd(instance, instance->aen_cmd);
2251
2252 dcmd = &cmd->frame->dcmd;
2253
2254 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
2255
2256 dcmd->cmd = MFI_CMD_DCMD;
2257 dcmd->cmd_status = 0x0;
2258 dcmd->sge_count = 0;
2259 dcmd->flags = MFI_FRAME_DIR_NONE;
2260 dcmd->timeout = 0;
2261 dcmd->data_xfer_len = 0;
2262 dcmd->opcode = MR_DCMD_CTRL_SHUTDOWN;
2263
2264 megasas_issue_blocked_cmd(instance, cmd);
2265
2266 megasas_return_cmd(instance, cmd);
2267
2268 return;
2269}
2270
2271/**
2272 * megasas_detach_one - PCI hot"un"plug entry point
2273 * @pdev: PCI device structure
2274 */
2275static void megasas_detach_one(struct pci_dev *pdev)
2276{
2277 int i;
2278 struct Scsi_Host *host;
2279 struct megasas_instance *instance;
2280
2281 instance = pci_get_drvdata(pdev);
2282 host = instance->host;
2283
2284 scsi_remove_host(instance->host);
2285 megasas_flush_cache(instance);
2286 megasas_shutdown_controller(instance);
2287
2288 /*
2289 * Take the instance off the instance array. Note that we will not
2290 * decrement the max_index. We let this array be sparse array
2291 */
2292 for (i = 0; i < megasas_mgmt_info.max_index; i++) {
2293 if (megasas_mgmt_info.instance[i] == instance) {
2294 megasas_mgmt_info.count--;
2295 megasas_mgmt_info.instance[i] = NULL;
2296
2297 break;
2298 }
2299 }
2300
2301 pci_set_drvdata(instance->pdev, NULL);
2302
2303 megasas_disable_intr(instance->reg_set);
2304
2305 free_irq(instance->pdev->irq, instance);
2306
2307 megasas_release_mfi(instance);
2308
2309 pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),
2310 instance->evt_detail, instance->evt_detail_h);
2311
2312 pci_free_consistent(pdev, sizeof(u32), instance->producer,
2313 instance->producer_h);
2314
2315 pci_free_consistent(pdev, sizeof(u32), instance->consumer,
2316 instance->consumer_h);
2317
2318 scsi_host_put(host);
2319
2320 pci_set_drvdata(pdev, NULL);
2321
2322 pci_disable_device(pdev);
2323
2324 return;
2325}
2326
2327/**
2328 * megasas_shutdown - Shutdown entry point
2329 * @device: Generic device structure
2330 */
2331static void megasas_shutdown(struct pci_dev *pdev)
2332{
2333 struct megasas_instance *instance = pci_get_drvdata(pdev);
2334 megasas_flush_cache(instance);
2335}
2336
2337/**
2338 * megasas_mgmt_open - char node "open" entry point
2339 */
2340static int megasas_mgmt_open(struct inode *inode, struct file *filep)
2341{
2342 /*
2343 * Allow only those users with admin rights
2344 */
2345 if (!capable(CAP_SYS_ADMIN))
2346 return -EACCES;
2347
2348 return 0;
2349}
2350
2351/**
2352 * megasas_mgmt_release - char node "release" entry point
2353 */
2354static int megasas_mgmt_release(struct inode *inode, struct file *filep)
2355{
2356 filep->private_data = NULL;
2357 fasync_helper(-1, filep, 0, &megasas_async_queue);
2358
2359 return 0;
2360}
2361
2362/**
2363 * megasas_mgmt_fasync - Async notifier registration from applications
2364 *
2365 * This function adds the calling process to a driver global queue. When an
2366 * event occurs, SIGIO will be sent to all processes in this queue.
2367 */
2368static int megasas_mgmt_fasync(int fd, struct file *filep, int mode)
2369{
2370 int rc;
2371
2372 down(&megasas_async_queue_mutex);
2373
2374 rc = fasync_helper(fd, filep, mode, &megasas_async_queue);
2375
2376 up(&megasas_async_queue_mutex);
2377
2378 if (rc >= 0) {
2379 /* For sanity check when we get ioctl */
2380 filep->private_data = filep;
2381 return 0;
2382 }
2383
2384 printk(KERN_DEBUG "megasas: fasync_helper failed [%d]\n", rc);
2385
2386 return rc;
2387}
2388
2389/**
2390 * megasas_mgmt_fw_ioctl - Issues management ioctls to FW
2391 * @instance: Adapter soft state
2392 * @argp: User's ioctl packet
2393 */
2394static int
2395megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
2396 struct megasas_iocpacket __user * user_ioc,
2397 struct megasas_iocpacket *ioc)
2398{
2399 struct megasas_sge32 *kern_sge32;
2400 struct megasas_cmd *cmd;
2401 void *kbuff_arr[MAX_IOCTL_SGE];
2402 dma_addr_t buf_handle = 0;
2403 int error = 0, i;
2404 void *sense = NULL;
2405 dma_addr_t sense_handle;
2406 u32 *sense_ptr;
2407
2408 memset(kbuff_arr, 0, sizeof(kbuff_arr));
2409
2410 if (ioc->sge_count > MAX_IOCTL_SGE) {
2411 printk(KERN_DEBUG "megasas: SGE count [%d] > max limit [%d]\n",
2412 ioc->sge_count, MAX_IOCTL_SGE);
2413 return -EINVAL;
2414 }
2415
2416 cmd = megasas_get_cmd(instance);
2417 if (!cmd) {
2418 printk(KERN_DEBUG "megasas: Failed to get a cmd packet\n");
2419 return -ENOMEM;
2420 }
2421
2422 /*
2423 * User's IOCTL packet has 2 frames (maximum). Copy those two
2424 * frames into our cmd's frames. cmd->frame's context will get
2425 * overwritten when we copy from user's frames. So set that value
2426 * alone separately
2427 */
2428 memcpy(cmd->frame, ioc->frame.raw, 2 * MEGAMFI_FRAME_SIZE);
2429 cmd->frame->hdr.context = cmd->index;
2430
2431 /*
2432 * The management interface between applications and the fw uses
2433 * MFI frames. E.g, RAID configuration changes, LD property changes
2434 * etc are accomplishes through different kinds of MFI frames. The
2435 * driver needs to care only about substituting user buffers with
2436 * kernel buffers in SGLs. The location of SGL is embedded in the
2437 * struct iocpacket itself.
2438 */
2439 kern_sge32 = (struct megasas_sge32 *)
2440 ((unsigned long)cmd->frame + ioc->sgl_off);
2441
2442 /*
2443 * For each user buffer, create a mirror buffer and copy in
2444 */
2445 for (i = 0; i < ioc->sge_count; i++) {
2446 kbuff_arr[i] = pci_alloc_consistent(instance->pdev,
2447 ioc->sgl[i].iov_len,
2448 &buf_handle);
2449 if (!kbuff_arr[i]) {
2450 printk(KERN_DEBUG "megasas: Failed to alloc "
2451 "kernel SGL buffer for IOCTL \n");
2452 error = -ENOMEM;
2453 goto out;
2454 }
2455
2456 /*
2457 * We don't change the dma_coherent_mask, so
2458 * pci_alloc_consistent only returns 32bit addresses
2459 */
2460 kern_sge32[i].phys_addr = (u32) buf_handle;
2461 kern_sge32[i].length = ioc->sgl[i].iov_len;
2462
2463 /*
2464 * We created a kernel buffer corresponding to the
2465 * user buffer. Now copy in from the user buffer
2466 */
2467 if (copy_from_user(kbuff_arr[i], ioc->sgl[i].iov_base,
2468 (u32) (ioc->sgl[i].iov_len))) {
2469 error = -EFAULT;
2470 goto out;
2471 }
2472 }
2473
2474 if (ioc->sense_len) {
2475 sense = pci_alloc_consistent(instance->pdev, ioc->sense_len,
2476 &sense_handle);
2477 if (!sense) {
2478 error = -ENOMEM;
2479 goto out;
2480 }
2481
2482 sense_ptr =
2483 (u32 *) ((unsigned long)cmd->frame + ioc->sense_off);
2484 *sense_ptr = sense_handle;
2485 }
2486
2487 /*
2488 * Set the sync_cmd flag so that the ISR knows not to complete this
2489 * cmd to the SCSI mid-layer
2490 */
2491 cmd->sync_cmd = 1;
2492 megasas_issue_blocked_cmd(instance, cmd);
2493 cmd->sync_cmd = 0;
2494
2495 /*
2496 * copy out the kernel buffers to user buffers
2497 */
2498 for (i = 0; i < ioc->sge_count; i++) {
2499 if (copy_to_user(ioc->sgl[i].iov_base, kbuff_arr[i],
2500 ioc->sgl[i].iov_len)) {
2501 error = -EFAULT;
2502 goto out;
2503 }
2504 }
2505
2506 /*
2507 * copy out the sense
2508 */
2509 if (ioc->sense_len) {
2510 /*
2511 * sense_ptr points to the location that has the user
2512 * sense buffer address
2513 */
2514 sense_ptr = (u32 *) ((unsigned long)ioc->frame.raw +
2515 ioc->sense_off);
2516
2517 if (copy_to_user((void __user *)((unsigned long)(*sense_ptr)),
2518 sense, ioc->sense_len)) {
2519 error = -EFAULT;
2520 goto out;
2521 }
2522 }
2523
2524 /*
2525 * copy the status codes returned by the fw
2526 */
2527 if (copy_to_user(&user_ioc->frame.hdr.cmd_status,
2528 &cmd->frame->hdr.cmd_status, sizeof(u8))) {
2529 printk(KERN_DEBUG "megasas: Error copying out cmd_status\n");
2530 error = -EFAULT;
2531 }
2532
2533 out:
2534 if (sense) {
2535 pci_free_consistent(instance->pdev, ioc->sense_len,
2536 sense, sense_handle);
2537 }
2538
2539 for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) {
2540 pci_free_consistent(instance->pdev,
2541 kern_sge32[i].length,
2542 kbuff_arr[i], kern_sge32[i].phys_addr);
2543 }
2544
2545 megasas_return_cmd(instance, cmd);
2546 return error;
2547}
2548
2549static struct megasas_instance *megasas_lookup_instance(u16 host_no)
2550{
2551 int i;
2552
2553 for (i = 0; i < megasas_mgmt_info.max_index; i++) {
2554
2555 if ((megasas_mgmt_info.instance[i]) &&
2556 (megasas_mgmt_info.instance[i]->host->host_no == host_no))
2557 return megasas_mgmt_info.instance[i];
2558 }
2559
2560 return NULL;
2561}
2562
2563static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
2564{
2565 struct megasas_iocpacket __user *user_ioc =
2566 (struct megasas_iocpacket __user *)arg;
2567 struct megasas_iocpacket *ioc;
2568 struct megasas_instance *instance;
2569 int error;
2570
2571 ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
2572 if (!ioc)
2573 return -ENOMEM;
2574
2575 if (copy_from_user(ioc, user_ioc, sizeof(*ioc))) {
2576 error = -EFAULT;
2577 goto out_kfree_ioc;
2578 }
2579
2580 instance = megasas_lookup_instance(ioc->host_no);
2581 if (!instance) {
2582 error = -ENODEV;
2583 goto out_kfree_ioc;
2584 }
2585
2586 /*
2587 * We will allow only MEGASAS_INT_CMDS number of parallel ioctl cmds
2588 */
2589 if (down_interruptible(&instance->ioctl_sem)) {
2590 error = -ERESTARTSYS;
2591 goto out_kfree_ioc;
2592 }
2593 error = megasas_mgmt_fw_ioctl(instance, user_ioc, ioc);
2594 up(&instance->ioctl_sem);
2595
2596 out_kfree_ioc:
2597 kfree(ioc);
2598 return error;
2599}
2600
2601static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
2602{
2603 struct megasas_instance *instance;
2604 struct megasas_aen aen;
2605 int error;
2606
2607 if (file->private_data != file) {
2608 printk(KERN_DEBUG "megasas: fasync_helper was not "
2609 "called first\n");
2610 return -EINVAL;
2611 }
2612
2613 if (copy_from_user(&aen, (void __user *)arg, sizeof(aen)))
2614 return -EFAULT;
2615
2616 instance = megasas_lookup_instance(aen.host_no);
2617
2618 if (!instance)
2619 return -ENODEV;
2620
2621 down(&instance->aen_mutex);
2622 error = megasas_register_aen(instance, aen.seq_num,
2623 aen.class_locale_word);
2624 up(&instance->aen_mutex);
2625 return error;
2626}
2627
2628/**
2629 * megasas_mgmt_ioctl - char node ioctl entry point
2630 */
2631static long
2632megasas_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2633{
2634 switch (cmd) {
2635 case MEGASAS_IOC_FIRMWARE:
2636 return megasas_mgmt_ioctl_fw(file, arg);
2637
2638 case MEGASAS_IOC_GET_AEN:
2639 return megasas_mgmt_ioctl_aen(file, arg);
2640 }
2641
2642 return -ENOTTY;
2643}
2644
2645#ifdef CONFIG_COMPAT
2646static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
2647{
2648 struct compat_megasas_iocpacket __user *cioc =
2649 (struct compat_megasas_iocpacket __user *)arg;
2650 struct megasas_iocpacket __user *ioc =
2651 compat_alloc_user_space(sizeof(struct megasas_iocpacket));
2652 int i;
2653 int error = 0;
2654
2655 clear_user(ioc, sizeof(*ioc));
2656
2657 if (copy_in_user(&ioc->host_no, &cioc->host_no, sizeof(u16)) ||
2658 copy_in_user(&ioc->sgl_off, &cioc->sgl_off, sizeof(u32)) ||
2659 copy_in_user(&ioc->sense_off, &cioc->sense_off, sizeof(u32)) ||
2660 copy_in_user(&ioc->sense_len, &cioc->sense_len, sizeof(u32)) ||
2661 copy_in_user(ioc->frame.raw, cioc->frame.raw, 128) ||
2662 copy_in_user(&ioc->sge_count, &cioc->sge_count, sizeof(u32)))
2663 return -EFAULT;
2664
2665 for (i = 0; i < MAX_IOCTL_SGE; i++) {
2666 compat_uptr_t ptr;
2667
2668 if (get_user(ptr, &cioc->sgl[i].iov_base) ||
2669 put_user(compat_ptr(ptr), &ioc->sgl[i].iov_base) ||
2670 copy_in_user(&ioc->sgl[i].iov_len,
2671 &cioc->sgl[i].iov_len, sizeof(compat_size_t)))
2672 return -EFAULT;
2673 }
2674
2675 error = megasas_mgmt_ioctl_fw(file, (unsigned long)ioc);
2676
2677 if (copy_in_user(&cioc->frame.hdr.cmd_status,
2678 &ioc->frame.hdr.cmd_status, sizeof(u8))) {
2679 printk(KERN_DEBUG "megasas: error copy_in_user cmd_status\n");
2680 return -EFAULT;
2681 }
2682 return error;
2683}
2684
2685static long
2686megasas_mgmt_compat_ioctl(struct file *file, unsigned int cmd,
2687 unsigned long arg)
2688{
2689 switch (cmd) {
2690 case MEGASAS_IOC_FIRMWARE:{
2691 return megasas_mgmt_compat_ioctl_fw(file, arg);
2692 }
2693 case MEGASAS_IOC_GET_AEN:
2694 return megasas_mgmt_ioctl_aen(file, arg);
2695 }
2696
2697 return -ENOTTY;
2698}
2699#endif
2700
2701/*
2702 * File operations structure for management interface
2703 */
2704static struct file_operations megasas_mgmt_fops = {
2705 .owner = THIS_MODULE,
2706 .open = megasas_mgmt_open,
2707 .release = megasas_mgmt_release,
2708 .fasync = megasas_mgmt_fasync,
2709 .unlocked_ioctl = megasas_mgmt_ioctl,
2710#ifdef CONFIG_COMPAT
2711 .compat_ioctl = megasas_mgmt_compat_ioctl,
2712#endif
2713};
2714
2715/*
2716 * PCI hotplug support registration structure
2717 */
2718static struct pci_driver megasas_pci_driver = {
2719
2720 .name = "megaraid_sas",
2721 .id_table = megasas_pci_table,
2722 .probe = megasas_probe_one,
2723 .remove = __devexit_p(megasas_detach_one),
2724 .shutdown = megasas_shutdown,
2725};
2726
2727/*
2728 * Sysfs driver attributes
2729 */
2730static ssize_t megasas_sysfs_show_version(struct device_driver *dd, char *buf)
2731{
2732 return snprintf(buf, strlen(MEGASAS_VERSION) + 2, "%s\n",
2733 MEGASAS_VERSION);
2734}
2735
2736static DRIVER_ATTR(version, S_IRUGO, megasas_sysfs_show_version, NULL);
2737
2738static ssize_t
2739megasas_sysfs_show_release_date(struct device_driver *dd, char *buf)
2740{
2741 return snprintf(buf, strlen(MEGASAS_RELDATE) + 2, "%s\n",
2742 MEGASAS_RELDATE);
2743}
2744
2745static DRIVER_ATTR(release_date, S_IRUGO, megasas_sysfs_show_release_date,
2746 NULL);
2747
2748/**
2749 * megasas_init - Driver load entry point
2750 */
2751static int __init megasas_init(void)
2752{
2753 int rval;
2754
2755 /*
2756 * Announce driver version and other information
2757 */
2758 printk(KERN_INFO "megasas: %s %s\n", MEGASAS_VERSION,
2759 MEGASAS_EXT_VERSION);
2760
2761 memset(&megasas_mgmt_info, 0, sizeof(megasas_mgmt_info));
2762
2763 /*
2764 * Register character device node
2765 */
2766 rval = register_chrdev(0, "megaraid_sas_ioctl", &megasas_mgmt_fops);
2767
2768 if (rval < 0) {
2769 printk(KERN_DEBUG "megasas: failed to open device node\n");
2770 return rval;
2771 }
2772
2773 megasas_mgmt_majorno = rval;
2774
2775 /*
2776 * Register ourselves as PCI hotplug module
2777 */
2778 rval = pci_module_init(&megasas_pci_driver);
2779
2780 if (rval) {
2781 printk(KERN_DEBUG "megasas: PCI hotplug regisration failed \n");
2782 unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
2783 }
2784
2785 driver_create_file(&megasas_pci_driver.driver, &driver_attr_version);
2786 driver_create_file(&megasas_pci_driver.driver,
2787 &driver_attr_release_date);
2788
2789 return rval;
2790}
2791
2792/**
2793 * megasas_exit - Driver unload entry point
2794 */
2795static void __exit megasas_exit(void)
2796{
2797 driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version);
2798 driver_remove_file(&megasas_pci_driver.driver,
2799 &driver_attr_release_date);
2800
2801 pci_unregister_driver(&megasas_pci_driver);
2802 unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl");
2803}
2804
2805module_init(megasas_init);
2806module_exit(megasas_exit);
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
new file mode 100644
index 000000000000..eaec9d531424
--- /dev/null
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -0,0 +1,1142 @@
1/*
2 *
3 * Linux MegaRAID driver for SAS based RAID controllers
4 *
5 * Copyright (c) 2003-2005 LSI Logic Corporation.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * FILE : megaraid_sas.h
13 */
14
15#ifndef LSI_MEGARAID_SAS_H
16#define LSI_MEGARAID_SAS_H
17
18/**
19 * MegaRAID SAS Driver meta data
20 */
21#define MEGASAS_VERSION "00.00.02.00-rc4"
22#define MEGASAS_RELDATE "Sep 16, 2005"
23#define MEGASAS_EXT_VERSION "Fri Sep 16 12:37:08 EDT 2005"
24
25/*
26 * =====================================
27 * MegaRAID SAS MFI firmware definitions
28 * =====================================
29 */
30
31/*
32 * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
33 * protocol between the software and firmware. Commands are issued using
34 * "message frames"
35 */
36
37/**
38 * FW posts its state in upper 4 bits of outbound_msg_0 register
39 */
40#define MFI_STATE_MASK 0xF0000000
41#define MFI_STATE_UNDEFINED 0x00000000
42#define MFI_STATE_BB_INIT 0x10000000
43#define MFI_STATE_FW_INIT 0x40000000
44#define MFI_STATE_WAIT_HANDSHAKE 0x60000000
45#define MFI_STATE_FW_INIT_2 0x70000000
46#define MFI_STATE_DEVICE_SCAN 0x80000000
47#define MFI_STATE_FLUSH_CACHE 0xA0000000
48#define MFI_STATE_READY 0xB0000000
49#define MFI_STATE_OPERATIONAL 0xC0000000
50#define MFI_STATE_FAULT 0xF0000000
51
52#define MEGAMFI_FRAME_SIZE 64
53
54/**
55 * During FW init, clear pending cmds & reset state using inbound_msg_0
56 *
57 * ABORT : Abort all pending cmds
58 * READY : Move from OPERATIONAL to READY state; discard queue info
59 * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
60 * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
61 */
62#define MFI_INIT_ABORT 0x00000000
63#define MFI_INIT_READY 0x00000002
64#define MFI_INIT_MFIMODE 0x00000004
65#define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
66#define MFI_RESET_FLAGS MFI_INIT_READY|MFI_INIT_MFIMODE
67
68/**
69 * MFI frame flags
70 */
71#define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
72#define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
73#define MFI_FRAME_SGL32 0x0000
74#define MFI_FRAME_SGL64 0x0002
75#define MFI_FRAME_SENSE32 0x0000
76#define MFI_FRAME_SENSE64 0x0004
77#define MFI_FRAME_DIR_NONE 0x0000
78#define MFI_FRAME_DIR_WRITE 0x0008
79#define MFI_FRAME_DIR_READ 0x0010
80#define MFI_FRAME_DIR_BOTH 0x0018
81
82/**
83 * Definition for cmd_status
84 */
85#define MFI_CMD_STATUS_POLL_MODE 0xFF
86
87/**
88 * MFI command opcodes
89 */
90#define MFI_CMD_INIT 0x00
91#define MFI_CMD_LD_READ 0x01
92#define MFI_CMD_LD_WRITE 0x02
93#define MFI_CMD_LD_SCSI_IO 0x03
94#define MFI_CMD_PD_SCSI_IO 0x04
95#define MFI_CMD_DCMD 0x05
96#define MFI_CMD_ABORT 0x06
97#define MFI_CMD_SMP 0x07
98#define MFI_CMD_STP 0x08
99
100#define MR_DCMD_CTRL_GET_INFO 0x01010000
101
102#define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
103#define MR_FLUSH_CTRL_CACHE 0x01
104#define MR_FLUSH_DISK_CACHE 0x02
105
106#define MR_DCMD_CTRL_SHUTDOWN 0x01050000
107#define MR_ENABLE_DRIVE_SPINDOWN 0x01
108
109#define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
110#define MR_DCMD_CTRL_EVENT_GET 0x01040300
111#define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
112#define MR_DCMD_LD_GET_PROPERTIES 0x03030000
113
114#define MR_DCMD_CLUSTER 0x08000000
115#define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
116#define MR_DCMD_CLUSTER_RESET_LD 0x08010200
117
118/**
119 * MFI command completion codes
120 */
121enum MFI_STAT {
122 MFI_STAT_OK = 0x00,
123 MFI_STAT_INVALID_CMD = 0x01,
124 MFI_STAT_INVALID_DCMD = 0x02,
125 MFI_STAT_INVALID_PARAMETER = 0x03,
126 MFI_STAT_INVALID_SEQUENCE_NUMBER = 0x04,
127 MFI_STAT_ABORT_NOT_POSSIBLE = 0x05,
128 MFI_STAT_APP_HOST_CODE_NOT_FOUND = 0x06,
129 MFI_STAT_APP_IN_USE = 0x07,
130 MFI_STAT_APP_NOT_INITIALIZED = 0x08,
131 MFI_STAT_ARRAY_INDEX_INVALID = 0x09,
132 MFI_STAT_ARRAY_ROW_NOT_EMPTY = 0x0a,
133 MFI_STAT_CONFIG_RESOURCE_CONFLICT = 0x0b,
134 MFI_STAT_DEVICE_NOT_FOUND = 0x0c,
135 MFI_STAT_DRIVE_TOO_SMALL = 0x0d,
136 MFI_STAT_FLASH_ALLOC_FAIL = 0x0e,
137 MFI_STAT_FLASH_BUSY = 0x0f,
138 MFI_STAT_FLASH_ERROR = 0x10,
139 MFI_STAT_FLASH_IMAGE_BAD = 0x11,
140 MFI_STAT_FLASH_IMAGE_INCOMPLETE = 0x12,
141 MFI_STAT_FLASH_NOT_OPEN = 0x13,
142 MFI_STAT_FLASH_NOT_STARTED = 0x14,
143 MFI_STAT_FLUSH_FAILED = 0x15,
144 MFI_STAT_HOST_CODE_NOT_FOUNT = 0x16,
145 MFI_STAT_LD_CC_IN_PROGRESS = 0x17,
146 MFI_STAT_LD_INIT_IN_PROGRESS = 0x18,
147 MFI_STAT_LD_LBA_OUT_OF_RANGE = 0x19,
148 MFI_STAT_LD_MAX_CONFIGURED = 0x1a,
149 MFI_STAT_LD_NOT_OPTIMAL = 0x1b,
150 MFI_STAT_LD_RBLD_IN_PROGRESS = 0x1c,
151 MFI_STAT_LD_RECON_IN_PROGRESS = 0x1d,
152 MFI_STAT_LD_WRONG_RAID_LEVEL = 0x1e,
153 MFI_STAT_MAX_SPARES_EXCEEDED = 0x1f,
154 MFI_STAT_MEMORY_NOT_AVAILABLE = 0x20,
155 MFI_STAT_MFC_HW_ERROR = 0x21,
156 MFI_STAT_NO_HW_PRESENT = 0x22,
157 MFI_STAT_NOT_FOUND = 0x23,
158 MFI_STAT_NOT_IN_ENCL = 0x24,
159 MFI_STAT_PD_CLEAR_IN_PROGRESS = 0x25,
160 MFI_STAT_PD_TYPE_WRONG = 0x26,
161 MFI_STAT_PR_DISABLED = 0x27,
162 MFI_STAT_ROW_INDEX_INVALID = 0x28,
163 MFI_STAT_SAS_CONFIG_INVALID_ACTION = 0x29,
164 MFI_STAT_SAS_CONFIG_INVALID_DATA = 0x2a,
165 MFI_STAT_SAS_CONFIG_INVALID_PAGE = 0x2b,
166 MFI_STAT_SAS_CONFIG_INVALID_TYPE = 0x2c,
167 MFI_STAT_SCSI_DONE_WITH_ERROR = 0x2d,
168 MFI_STAT_SCSI_IO_FAILED = 0x2e,
169 MFI_STAT_SCSI_RESERVATION_CONFLICT = 0x2f,
170 MFI_STAT_SHUTDOWN_FAILED = 0x30,
171 MFI_STAT_TIME_NOT_SET = 0x31,
172 MFI_STAT_WRONG_STATE = 0x32,
173 MFI_STAT_LD_OFFLINE = 0x33,
174 MFI_STAT_PEER_NOTIFICATION_REJECTED = 0x34,
175 MFI_STAT_PEER_NOTIFICATION_FAILED = 0x35,
176 MFI_STAT_RESERVATION_IN_PROGRESS = 0x36,
177 MFI_STAT_I2C_ERRORS_DETECTED = 0x37,
178 MFI_STAT_PCI_ERRORS_DETECTED = 0x38,
179
180 MFI_STAT_INVALID_STATUS = 0xFF
181};
182
183/*
184 * Number of mailbox bytes in DCMD message frame
185 */
186#define MFI_MBOX_SIZE 12
187
188enum MR_EVT_CLASS {
189
190 MR_EVT_CLASS_DEBUG = -2,
191 MR_EVT_CLASS_PROGRESS = -1,
192 MR_EVT_CLASS_INFO = 0,
193 MR_EVT_CLASS_WARNING = 1,
194 MR_EVT_CLASS_CRITICAL = 2,
195 MR_EVT_CLASS_FATAL = 3,
196 MR_EVT_CLASS_DEAD = 4,
197
198};
199
200enum MR_EVT_LOCALE {
201
202 MR_EVT_LOCALE_LD = 0x0001,
203 MR_EVT_LOCALE_PD = 0x0002,
204 MR_EVT_LOCALE_ENCL = 0x0004,
205 MR_EVT_LOCALE_BBU = 0x0008,
206 MR_EVT_LOCALE_SAS = 0x0010,
207 MR_EVT_LOCALE_CTRL = 0x0020,
208 MR_EVT_LOCALE_CONFIG = 0x0040,
209 MR_EVT_LOCALE_CLUSTER = 0x0080,
210 MR_EVT_LOCALE_ALL = 0xffff,
211
212};
213
214enum MR_EVT_ARGS {
215
216 MR_EVT_ARGS_NONE,
217 MR_EVT_ARGS_CDB_SENSE,
218 MR_EVT_ARGS_LD,
219 MR_EVT_ARGS_LD_COUNT,
220 MR_EVT_ARGS_LD_LBA,
221 MR_EVT_ARGS_LD_OWNER,
222 MR_EVT_ARGS_LD_LBA_PD_LBA,
223 MR_EVT_ARGS_LD_PROG,
224 MR_EVT_ARGS_LD_STATE,
225 MR_EVT_ARGS_LD_STRIP,
226 MR_EVT_ARGS_PD,
227 MR_EVT_ARGS_PD_ERR,
228 MR_EVT_ARGS_PD_LBA,
229 MR_EVT_ARGS_PD_LBA_LD,
230 MR_EVT_ARGS_PD_PROG,
231 MR_EVT_ARGS_PD_STATE,
232 MR_EVT_ARGS_PCI,
233 MR_EVT_ARGS_RATE,
234 MR_EVT_ARGS_STR,
235 MR_EVT_ARGS_TIME,
236 MR_EVT_ARGS_ECC,
237
238};
239
240/*
241 * SAS controller properties
242 */
243struct megasas_ctrl_prop {
244
245 u16 seq_num;
246 u16 pred_fail_poll_interval;
247 u16 intr_throttle_count;
248 u16 intr_throttle_timeouts;
249 u8 rebuild_rate;
250 u8 patrol_read_rate;
251 u8 bgi_rate;
252 u8 cc_rate;
253 u8 recon_rate;
254 u8 cache_flush_interval;
255 u8 spinup_drv_count;
256 u8 spinup_delay;
257 u8 cluster_enable;
258 u8 coercion_mode;
259 u8 alarm_enable;
260 u8 disable_auto_rebuild;
261 u8 disable_battery_warn;
262 u8 ecc_bucket_size;
263 u16 ecc_bucket_leak_rate;
264 u8 restore_hotspare_on_insertion;
265 u8 expose_encl_devices;
266 u8 reserved[38];
267
268} __attribute__ ((packed));
269
270/*
271 * SAS controller information
272 */
273struct megasas_ctrl_info {
274
275 /*
276 * PCI device information
277 */
278 struct {
279
280 u16 vendor_id;
281 u16 device_id;
282 u16 sub_vendor_id;
283 u16 sub_device_id;
284 u8 reserved[24];
285
286 } __attribute__ ((packed)) pci;
287
288 /*
289 * Host interface information
290 */
291 struct {
292
293 u8 PCIX:1;
294 u8 PCIE:1;
295 u8 iSCSI:1;
296 u8 SAS_3G:1;
297 u8 reserved_0:4;
298 u8 reserved_1[6];
299 u8 port_count;
300 u64 port_addr[8];
301
302 } __attribute__ ((packed)) host_interface;
303
304 /*
305 * Device (backend) interface information
306 */
307 struct {
308
309 u8 SPI:1;
310 u8 SAS_3G:1;
311 u8 SATA_1_5G:1;
312 u8 SATA_3G:1;
313 u8 reserved_0:4;
314 u8 reserved_1[6];
315 u8 port_count;
316 u64 port_addr[8];
317
318 } __attribute__ ((packed)) device_interface;
319
320 /*
321 * List of components residing in flash. All str are null terminated
322 */
323 u32 image_check_word;
324 u32 image_component_count;
325
326 struct {
327
328 char name[8];
329 char version[32];
330 char build_date[16];
331 char built_time[16];
332
333 } __attribute__ ((packed)) image_component[8];
334
335 /*
336 * List of flash components that have been flashed on the card, but
337 * are not in use, pending reset of the adapter. This list will be
338 * empty if a flash operation has not occurred. All stings are null
339 * terminated
340 */
341 u32 pending_image_component_count;
342
343 struct {
344
345 char name[8];
346 char version[32];
347 char build_date[16];
348 char build_time[16];
349
350 } __attribute__ ((packed)) pending_image_component[8];
351
352 u8 max_arms;
353 u8 max_spans;
354 u8 max_arrays;
355 u8 max_lds;
356
357 char product_name[80];
358 char serial_no[32];
359
360 /*
361 * Other physical/controller/operation information. Indicates the
362 * presence of the hardware
363 */
364 struct {
365
366 u32 bbu:1;
367 u32 alarm:1;
368 u32 nvram:1;
369 u32 uart:1;
370 u32 reserved:28;
371
372 } __attribute__ ((packed)) hw_present;
373
374 u32 current_fw_time;
375
376 /*
377 * Maximum data transfer sizes
378 */
379 u16 max_concurrent_cmds;
380 u16 max_sge_count;
381 u32 max_request_size;
382
383 /*
384 * Logical and physical device counts
385 */
386 u16 ld_present_count;
387 u16 ld_degraded_count;
388 u16 ld_offline_count;
389
390 u16 pd_present_count;
391 u16 pd_disk_present_count;
392 u16 pd_disk_pred_failure_count;
393 u16 pd_disk_failed_count;
394
395 /*
396 * Memory size information
397 */
398 u16 nvram_size;
399 u16 memory_size;
400 u16 flash_size;
401
402 /*
403 * Error counters
404 */
405 u16 mem_correctable_error_count;
406 u16 mem_uncorrectable_error_count;
407
408 /*
409 * Cluster information
410 */
411 u8 cluster_permitted;
412 u8 cluster_active;
413
414 /*
415 * Additional max data transfer sizes
416 */
417 u16 max_strips_per_io;
418
419 /*
420 * Controller capabilities structures
421 */
422 struct {
423
424 u32 raid_level_0:1;
425 u32 raid_level_1:1;
426 u32 raid_level_5:1;
427 u32 raid_level_1E:1;
428 u32 raid_level_6:1;
429 u32 reserved:27;
430
431 } __attribute__ ((packed)) raid_levels;
432
433 struct {
434
435 u32 rbld_rate:1;
436 u32 cc_rate:1;
437 u32 bgi_rate:1;
438 u32 recon_rate:1;
439 u32 patrol_rate:1;
440 u32 alarm_control:1;
441 u32 cluster_supported:1;
442 u32 bbu:1;
443 u32 spanning_allowed:1;
444 u32 dedicated_hotspares:1;
445 u32 revertible_hotspares:1;
446 u32 foreign_config_import:1;
447 u32 self_diagnostic:1;
448 u32 mixed_redundancy_arr:1;
449 u32 global_hot_spares:1;
450 u32 reserved:17;
451
452 } __attribute__ ((packed)) adapter_operations;
453
454 struct {
455
456 u32 read_policy:1;
457 u32 write_policy:1;
458 u32 io_policy:1;
459 u32 access_policy:1;
460 u32 disk_cache_policy:1;
461 u32 reserved:27;
462
463 } __attribute__ ((packed)) ld_operations;
464
465 struct {
466
467 u8 min;
468 u8 max;
469 u8 reserved[2];
470
471 } __attribute__ ((packed)) stripe_sz_ops;
472
473 struct {
474
475 u32 force_online:1;
476 u32 force_offline:1;
477 u32 force_rebuild:1;
478 u32 reserved:29;
479
480 } __attribute__ ((packed)) pd_operations;
481
482 struct {
483
484 u32 ctrl_supports_sas:1;
485 u32 ctrl_supports_sata:1;
486 u32 allow_mix_in_encl:1;
487 u32 allow_mix_in_ld:1;
488 u32 allow_sata_in_cluster:1;
489 u32 reserved:27;
490
491 } __attribute__ ((packed)) pd_mix_support;
492
493 /*
494 * Define ECC single-bit-error bucket information
495 */
496 u8 ecc_bucket_count;
497 u8 reserved_2[11];
498
499 /*
500 * Include the controller properties (changeable items)
501 */
502 struct megasas_ctrl_prop properties;
503
504 /*
505 * Define FW pkg version (set in envt v'bles on OEM basis)
506 */
507 char package_version[0x60];
508
509 u8 pad[0x800 - 0x6a0];
510
511} __attribute__ ((packed));
512
513/*
514 * ===============================
515 * MegaRAID SAS driver definitions
516 * ===============================
517 */
518#define MEGASAS_MAX_PD_CHANNELS 2
519#define MEGASAS_MAX_LD_CHANNELS 2
520#define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
521 MEGASAS_MAX_LD_CHANNELS)
522#define MEGASAS_MAX_DEV_PER_CHANNEL 128
523#define MEGASAS_DEFAULT_INIT_ID -1
524#define MEGASAS_MAX_LUN 8
525#define MEGASAS_MAX_LD 64
526
527/*
528 * When SCSI mid-layer calls driver's reset routine, driver waits for
529 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
530 * that the driver cannot _actually_ abort or reset pending commands. While
531 * it is waiting for the commands to complete, it prints a diagnostic message
532 * every MEGASAS_RESET_NOTICE_INTERVAL seconds
533 */
534#define MEGASAS_RESET_WAIT_TIME 180
535#define MEGASAS_RESET_NOTICE_INTERVAL 5
536
537#define MEGASAS_IOCTL_CMD 0
538
539/*
540 * FW reports the maximum of number of commands that it can accept (maximum
541 * commands that can be outstanding) at any time. The driver must report a
542 * lower number to the mid layer because it can issue a few internal commands
543 * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
544 * is shown below
545 */
546#define MEGASAS_INT_CMDS 32
547
548/*
549 * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
550 * SGLs based on the size of dma_addr_t
551 */
552#define IS_DMA64 (sizeof(dma_addr_t) == 8)
553
554#define MFI_OB_INTR_STATUS_MASK 0x00000002
555#define MFI_POLL_TIMEOUT_SECS 10
556
557struct megasas_register_set {
558
559 u32 reserved_0[4]; /*0000h */
560
561 u32 inbound_msg_0; /*0010h */
562 u32 inbound_msg_1; /*0014h */
563 u32 outbound_msg_0; /*0018h */
564 u32 outbound_msg_1; /*001Ch */
565
566 u32 inbound_doorbell; /*0020h */
567 u32 inbound_intr_status; /*0024h */
568 u32 inbound_intr_mask; /*0028h */
569
570 u32 outbound_doorbell; /*002Ch */
571 u32 outbound_intr_status; /*0030h */
572 u32 outbound_intr_mask; /*0034h */
573
574 u32 reserved_1[2]; /*0038h */
575
576 u32 inbound_queue_port; /*0040h */
577 u32 outbound_queue_port; /*0044h */
578
579 u32 reserved_2; /*004Ch */
580
581 u32 index_registers[1004]; /*0050h */
582
583} __attribute__ ((packed));
584
585struct megasas_sge32 {
586
587 u32 phys_addr;
588 u32 length;
589
590} __attribute__ ((packed));
591
592struct megasas_sge64 {
593
594 u64 phys_addr;
595 u32 length;
596
597} __attribute__ ((packed));
598
599union megasas_sgl {
600
601 struct megasas_sge32 sge32[1];
602 struct megasas_sge64 sge64[1];
603
604} __attribute__ ((packed));
605
606struct megasas_header {
607
608 u8 cmd; /*00h */
609 u8 sense_len; /*01h */
610 u8 cmd_status; /*02h */
611 u8 scsi_status; /*03h */
612
613 u8 target_id; /*04h */
614 u8 lun; /*05h */
615 u8 cdb_len; /*06h */
616 u8 sge_count; /*07h */
617
618 u32 context; /*08h */
619 u32 pad_0; /*0Ch */
620
621 u16 flags; /*10h */
622 u16 timeout; /*12h */
623 u32 data_xferlen; /*14h */
624
625} __attribute__ ((packed));
626
627union megasas_sgl_frame {
628
629 struct megasas_sge32 sge32[8];
630 struct megasas_sge64 sge64[5];
631
632} __attribute__ ((packed));
633
634struct megasas_init_frame {
635
636 u8 cmd; /*00h */
637 u8 reserved_0; /*01h */
638 u8 cmd_status; /*02h */
639
640 u8 reserved_1; /*03h */
641 u32 reserved_2; /*04h */
642
643 u32 context; /*08h */
644 u32 pad_0; /*0Ch */
645
646 u16 flags; /*10h */
647 u16 reserved_3; /*12h */
648 u32 data_xfer_len; /*14h */
649
650 u32 queue_info_new_phys_addr_lo; /*18h */
651 u32 queue_info_new_phys_addr_hi; /*1Ch */
652 u32 queue_info_old_phys_addr_lo; /*20h */
653 u32 queue_info_old_phys_addr_hi; /*24h */
654
655 u32 reserved_4[6]; /*28h */
656
657} __attribute__ ((packed));
658
659struct megasas_init_queue_info {
660
661 u32 init_flags; /*00h */
662 u32 reply_queue_entries; /*04h */
663
664 u32 reply_queue_start_phys_addr_lo; /*08h */
665 u32 reply_queue_start_phys_addr_hi; /*0Ch */
666 u32 producer_index_phys_addr_lo; /*10h */
667 u32 producer_index_phys_addr_hi; /*14h */
668 u32 consumer_index_phys_addr_lo; /*18h */
669 u32 consumer_index_phys_addr_hi; /*1Ch */
670
671} __attribute__ ((packed));
672
673struct megasas_io_frame {
674
675 u8 cmd; /*00h */
676 u8 sense_len; /*01h */
677 u8 cmd_status; /*02h */
678 u8 scsi_status; /*03h */
679
680 u8 target_id; /*04h */
681 u8 access_byte; /*05h */
682 u8 reserved_0; /*06h */
683 u8 sge_count; /*07h */
684
685 u32 context; /*08h */
686 u32 pad_0; /*0Ch */
687
688 u16 flags; /*10h */
689 u16 timeout; /*12h */
690 u32 lba_count; /*14h */
691
692 u32 sense_buf_phys_addr_lo; /*18h */
693 u32 sense_buf_phys_addr_hi; /*1Ch */
694
695 u32 start_lba_lo; /*20h */
696 u32 start_lba_hi; /*24h */
697
698 union megasas_sgl sgl; /*28h */
699
700} __attribute__ ((packed));
701
702struct megasas_pthru_frame {
703
704 u8 cmd; /*00h */
705 u8 sense_len; /*01h */
706 u8 cmd_status; /*02h */
707 u8 scsi_status; /*03h */
708
709 u8 target_id; /*04h */
710 u8 lun; /*05h */
711 u8 cdb_len; /*06h */
712 u8 sge_count; /*07h */
713
714 u32 context; /*08h */
715 u32 pad_0; /*0Ch */
716
717 u16 flags; /*10h */
718 u16 timeout; /*12h */
719 u32 data_xfer_len; /*14h */
720
721 u32 sense_buf_phys_addr_lo; /*18h */
722 u32 sense_buf_phys_addr_hi; /*1Ch */
723
724 u8 cdb[16]; /*20h */
725 union megasas_sgl sgl; /*30h */
726
727} __attribute__ ((packed));
728
729struct megasas_dcmd_frame {
730
731 u8 cmd; /*00h */
732 u8 reserved_0; /*01h */
733 u8 cmd_status; /*02h */
734 u8 reserved_1[4]; /*03h */
735 u8 sge_count; /*07h */
736
737 u32 context; /*08h */
738 u32 pad_0; /*0Ch */
739
740 u16 flags; /*10h */
741 u16 timeout; /*12h */
742
743 u32 data_xfer_len; /*14h */
744 u32 opcode; /*18h */
745
746 union { /*1Ch */
747 u8 b[12];
748 u16 s[6];
749 u32 w[3];
750 } mbox;
751
752 union megasas_sgl sgl; /*28h */
753
754} __attribute__ ((packed));
755
756struct megasas_abort_frame {
757
758 u8 cmd; /*00h */
759 u8 reserved_0; /*01h */
760 u8 cmd_status; /*02h */
761
762 u8 reserved_1; /*03h */
763 u32 reserved_2; /*04h */
764
765 u32 context; /*08h */
766 u32 pad_0; /*0Ch */
767
768 u16 flags; /*10h */
769 u16 reserved_3; /*12h */
770 u32 reserved_4; /*14h */
771
772 u32 abort_context; /*18h */
773 u32 pad_1; /*1Ch */
774
775 u32 abort_mfi_phys_addr_lo; /*20h */
776 u32 abort_mfi_phys_addr_hi; /*24h */
777
778 u32 reserved_5[6]; /*28h */
779
780} __attribute__ ((packed));
781
782struct megasas_smp_frame {
783
784 u8 cmd; /*00h */
785 u8 reserved_1; /*01h */
786 u8 cmd_status; /*02h */
787 u8 connection_status; /*03h */
788
789 u8 reserved_2[3]; /*04h */
790 u8 sge_count; /*07h */
791
792 u32 context; /*08h */
793 u32 pad_0; /*0Ch */
794
795 u16 flags; /*10h */
796 u16 timeout; /*12h */
797
798 u32 data_xfer_len; /*14h */
799 u64 sas_addr; /*18h */
800
801 union {
802 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
803 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
804 } sgl;
805
806} __attribute__ ((packed));
807
808struct megasas_stp_frame {
809
810 u8 cmd; /*00h */
811 u8 reserved_1; /*01h */
812 u8 cmd_status; /*02h */
813 u8 reserved_2; /*03h */
814
815 u8 target_id; /*04h */
816 u8 reserved_3[2]; /*05h */
817 u8 sge_count; /*07h */
818
819 u32 context; /*08h */
820 u32 pad_0; /*0Ch */
821
822 u16 flags; /*10h */
823 u16 timeout; /*12h */
824
825 u32 data_xfer_len; /*14h */
826
827 u16 fis[10]; /*18h */
828 u32 stp_flags;
829
830 union {
831 struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
832 struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
833 } sgl;
834
835} __attribute__ ((packed));
836
837union megasas_frame {
838
839 struct megasas_header hdr;
840 struct megasas_init_frame init;
841 struct megasas_io_frame io;
842 struct megasas_pthru_frame pthru;
843 struct megasas_dcmd_frame dcmd;
844 struct megasas_abort_frame abort;
845 struct megasas_smp_frame smp;
846 struct megasas_stp_frame stp;
847
848 u8 raw_bytes[64];
849};
850
851struct megasas_cmd;
852
853union megasas_evt_class_locale {
854
855 struct {
856 u16 locale;
857 u8 reserved;
858 s8 class;
859 } __attribute__ ((packed)) members;
860
861 u32 word;
862
863} __attribute__ ((packed));
864
865struct megasas_evt_log_info {
866 u32 newest_seq_num;
867 u32 oldest_seq_num;
868 u32 clear_seq_num;
869 u32 shutdown_seq_num;
870 u32 boot_seq_num;
871
872} __attribute__ ((packed));
873
874struct megasas_progress {
875
876 u16 progress;
877 u16 elapsed_seconds;
878
879} __attribute__ ((packed));
880
881struct megasas_evtarg_ld {
882
883 u16 target_id;
884 u8 ld_index;
885 u8 reserved;
886
887} __attribute__ ((packed));
888
889struct megasas_evtarg_pd {
890 u16 device_id;
891 u8 encl_index;
892 u8 slot_number;
893
894} __attribute__ ((packed));
895
896struct megasas_evt_detail {
897
898 u32 seq_num;
899 u32 time_stamp;
900 u32 code;
901 union megasas_evt_class_locale cl;
902 u8 arg_type;
903 u8 reserved1[15];
904
905 union {
906 struct {
907 struct megasas_evtarg_pd pd;
908 u8 cdb_length;
909 u8 sense_length;
910 u8 reserved[2];
911 u8 cdb[16];
912 u8 sense[64];
913 } __attribute__ ((packed)) cdbSense;
914
915 struct megasas_evtarg_ld ld;
916
917 struct {
918 struct megasas_evtarg_ld ld;
919 u64 count;
920 } __attribute__ ((packed)) ld_count;
921
922 struct {
923 u64 lba;
924 struct megasas_evtarg_ld ld;
925 } __attribute__ ((packed)) ld_lba;
926
927 struct {
928 struct megasas_evtarg_ld ld;
929 u32 prevOwner;
930 u32 newOwner;
931 } __attribute__ ((packed)) ld_owner;
932
933 struct {
934 u64 ld_lba;
935 u64 pd_lba;
936 struct megasas_evtarg_ld ld;
937 struct megasas_evtarg_pd pd;
938 } __attribute__ ((packed)) ld_lba_pd_lba;
939
940 struct {
941 struct megasas_evtarg_ld ld;
942 struct megasas_progress prog;
943 } __attribute__ ((packed)) ld_prog;
944
945 struct {
946 struct megasas_evtarg_ld ld;
947 u32 prev_state;
948 u32 new_state;
949 } __attribute__ ((packed)) ld_state;
950
951 struct {
952 u64 strip;
953 struct megasas_evtarg_ld ld;
954 } __attribute__ ((packed)) ld_strip;
955
956 struct megasas_evtarg_pd pd;
957
958 struct {
959 struct megasas_evtarg_pd pd;
960 u32 err;
961 } __attribute__ ((packed)) pd_err;
962
963 struct {
964 u64 lba;
965 struct megasas_evtarg_pd pd;
966 } __attribute__ ((packed)) pd_lba;
967
968 struct {
969 u64 lba;
970 struct megasas_evtarg_pd pd;
971 struct megasas_evtarg_ld ld;
972 } __attribute__ ((packed)) pd_lba_ld;
973
974 struct {
975 struct megasas_evtarg_pd pd;
976 struct megasas_progress prog;
977 } __attribute__ ((packed)) pd_prog;
978
979 struct {
980 struct megasas_evtarg_pd pd;
981 u32 prevState;
982 u32 newState;
983 } __attribute__ ((packed)) pd_state;
984
985 struct {
986 u16 vendorId;
987 u16 deviceId;
988 u16 subVendorId;
989 u16 subDeviceId;
990 } __attribute__ ((packed)) pci;
991
992 u32 rate;
993 char str[96];
994
995 struct {
996 u32 rtc;
997 u32 elapsedSeconds;
998 } __attribute__ ((packed)) time;
999
1000 struct {
1001 u32 ecar;
1002 u32 elog;
1003 char str[64];
1004 } __attribute__ ((packed)) ecc;
1005
1006 u8 b[96];
1007 u16 s[48];
1008 u32 w[24];
1009 u64 d[12];
1010 } args;
1011
1012 char description[128];
1013
1014} __attribute__ ((packed));
1015
1016struct megasas_instance {
1017
1018 u32 *producer;
1019 dma_addr_t producer_h;
1020 u32 *consumer;
1021 dma_addr_t consumer_h;
1022
1023 u32 *reply_queue;
1024 dma_addr_t reply_queue_h;
1025
1026 unsigned long base_addr;
1027 struct megasas_register_set __iomem *reg_set;
1028
1029 s8 init_id;
1030 u8 reserved[3];
1031
1032 u16 max_num_sge;
1033 u16 max_fw_cmds;
1034 u32 max_sectors_per_req;
1035
1036 struct megasas_cmd **cmd_list;
1037 struct list_head cmd_pool;
1038 spinlock_t cmd_pool_lock;
1039 struct dma_pool *frame_dma_pool;
1040 struct dma_pool *sense_dma_pool;
1041
1042 struct megasas_evt_detail *evt_detail;
1043 dma_addr_t evt_detail_h;
1044 struct megasas_cmd *aen_cmd;
1045 struct semaphore aen_mutex;
1046 struct semaphore ioctl_sem;
1047
1048 struct Scsi_Host *host;
1049
1050 wait_queue_head_t int_cmd_wait_q;
1051 wait_queue_head_t abort_cmd_wait_q;
1052
1053 struct pci_dev *pdev;
1054 u32 unique_id;
1055
1056 u32 fw_outstanding;
1057 u32 hw_crit_error;
1058 spinlock_t instance_lock;
1059};
1060
1061#define MEGASAS_IS_LOGICAL(scp) \
1062 (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
1063
1064#define MEGASAS_DEV_INDEX(inst, scp) \
1065 ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
1066 scp->device->id
1067
1068struct megasas_cmd {
1069
1070 union megasas_frame *frame;
1071 dma_addr_t frame_phys_addr;
1072 u8 *sense;
1073 dma_addr_t sense_phys_addr;
1074
1075 u32 index;
1076 u8 sync_cmd;
1077 u8 cmd_status;
1078 u16 abort_aen;
1079
1080 struct list_head list;
1081 struct scsi_cmnd *scmd;
1082 struct megasas_instance *instance;
1083 u32 frame_count;
1084};
1085
1086#define MAX_MGMT_ADAPTERS 1024
1087#define MAX_IOCTL_SGE 16
1088
1089struct megasas_iocpacket {
1090
1091 u16 host_no;
1092 u16 __pad1;
1093 u32 sgl_off;
1094 u32 sge_count;
1095 u32 sense_off;
1096 u32 sense_len;
1097 union {
1098 u8 raw[128];
1099 struct megasas_header hdr;
1100 } frame;
1101
1102 struct iovec sgl[MAX_IOCTL_SGE];
1103
1104} __attribute__ ((packed));
1105
1106struct megasas_aen {
1107 u16 host_no;
1108 u16 __pad1;
1109 u32 seq_num;
1110 u32 class_locale_word;
1111} __attribute__ ((packed));
1112
1113#ifdef CONFIG_COMPAT
1114struct compat_megasas_iocpacket {
1115 u16 host_no;
1116 u16 __pad1;
1117 u32 sgl_off;
1118 u32 sge_count;
1119 u32 sense_off;
1120 u32 sense_len;
1121 union {
1122 u8 raw[128];
1123 struct megasas_header hdr;
1124 } frame;
1125 struct compat_iovec sgl[MAX_IOCTL_SGE];
1126} __attribute__ ((packed));
1127
1128#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct compat_megasas_iocpacket)
1129#else
1130#define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
1131#endif
1132
1133#define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
1134
1135struct megasas_mgmt_info {
1136
1137 u16 count;
1138 struct megasas_instance *instance[MAX_MGMT_ADAPTERS];
1139 int max_index;
1140};
1141
1142#endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index a4857db4f9b8..b235556b7b65 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1959,22 +1959,35 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
1959 /* Set it up */ 1959 /* Set it up */
1960 mesh_init(ms); 1960 mesh_init(ms);
1961 1961
1962 /* XXX FIXME: error should be fatal */ 1962 /* Request interrupt */
1963 if (request_irq(ms->meshintr, do_mesh_interrupt, 0, "MESH", ms)) 1963 if (request_irq(ms->meshintr, do_mesh_interrupt, 0, "MESH", ms)) {
1964 printk(KERN_ERR "MESH: can't get irq %d\n", ms->meshintr); 1964 printk(KERN_ERR "MESH: can't get irq %d\n", ms->meshintr);
1965 goto out_shutdown;
1966 }
1965 1967
1966 /* XXX FIXME: handle failure */ 1968 /* Add scsi host & scan */
1967 scsi_add_host(mesh_host, &mdev->ofdev.dev); 1969 if (scsi_add_host(mesh_host, &mdev->ofdev.dev))
1970 goto out_release_irq;
1968 scsi_scan_host(mesh_host); 1971 scsi_scan_host(mesh_host);
1969 1972
1970 return 0; 1973 return 0;
1971 1974
1972out_unmap: 1975 out_release_irq:
1976 free_irq(ms->meshintr, ms);
1977 out_shutdown:
1978 /* shutdown & reset bus in case of error or macos can be confused
1979 * at reboot if the bus was set to synchronous mode already
1980 */
1981 mesh_shutdown(mdev);
1982 set_mesh_power(ms, 0);
1983 pci_free_consistent(macio_get_pci_dev(mdev), ms->dma_cmd_size,
1984 ms->dma_cmd_space, ms->dma_cmd_bus);
1985 out_unmap:
1973 iounmap(ms->dma); 1986 iounmap(ms->dma);
1974 iounmap(ms->mesh); 1987 iounmap(ms->mesh);
1975out_free: 1988 out_free:
1976 scsi_host_put(mesh_host); 1989 scsi_host_put(mesh_host);
1977out_release: 1990 out_release:
1978 macio_release_resources(mdev); 1991 macio_release_resources(mdev);
1979 1992
1980 return -ENODEV; 1993 return -ENODEV;
@@ -2001,7 +2014,7 @@ static int mesh_remove(struct macio_dev *mdev)
2001 2014
2002 /* Free DMA commands memory */ 2015 /* Free DMA commands memory */
2003 pci_free_consistent(macio_get_pci_dev(mdev), ms->dma_cmd_size, 2016 pci_free_consistent(macio_get_pci_dev(mdev), ms->dma_cmd_size,
2004 ms->dma_cmd_space, ms->dma_cmd_bus); 2017 ms->dma_cmd_space, ms->dma_cmd_bus);
2005 2018
2006 /* Release memory resources */ 2019 /* Release memory resources */
2007 macio_release_resources(mdev); 2020 macio_release_resources(mdev);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 3e9b64137873..23d095d3817b 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -201,6 +201,7 @@ int
201qla2100_pci_config(scsi_qla_host_t *ha) 201qla2100_pci_config(scsi_qla_host_t *ha)
202{ 202{
203 uint16_t w, mwi; 203 uint16_t w, mwi;
204 uint32_t d;
204 unsigned long flags; 205 unsigned long flags;
205 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 206 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
206 207
@@ -215,9 +216,9 @@ qla2100_pci_config(scsi_qla_host_t *ha)
215 pci_write_config_word(ha->pdev, PCI_COMMAND, w); 216 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
216 217
217 /* Reset expansion ROM address decode enable */ 218 /* Reset expansion ROM address decode enable */
218 pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w); 219 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
219 w &= ~PCI_ROM_ADDRESS_ENABLE; 220 d &= ~PCI_ROM_ADDRESS_ENABLE;
220 pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w); 221 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
221 222
222 /* Get PCI bus information. */ 223 /* Get PCI bus information. */
223 spin_lock_irqsave(&ha->hardware_lock, flags); 224 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -237,6 +238,7 @@ int
237qla2300_pci_config(scsi_qla_host_t *ha) 238qla2300_pci_config(scsi_qla_host_t *ha)
238{ 239{
239 uint16_t w, mwi; 240 uint16_t w, mwi;
241 uint32_t d;
240 unsigned long flags = 0; 242 unsigned long flags = 0;
241 uint32_t cnt; 243 uint32_t cnt;
242 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 244 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
@@ -302,9 +304,9 @@ qla2300_pci_config(scsi_qla_host_t *ha)
302 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); 304 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
303 305
304 /* Reset expansion ROM address decode enable */ 306 /* Reset expansion ROM address decode enable */
305 pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w); 307 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
306 w &= ~PCI_ROM_ADDRESS_ENABLE; 308 d &= ~PCI_ROM_ADDRESS_ENABLE;
307 pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w); 309 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
308 310
309 /* Get PCI bus information. */ 311 /* Get PCI bus information. */
310 spin_lock_irqsave(&ha->hardware_lock, flags); 312 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -324,6 +326,7 @@ int
324qla24xx_pci_config(scsi_qla_host_t *ha) 326qla24xx_pci_config(scsi_qla_host_t *ha)
325{ 327{
326 uint16_t w, mwi; 328 uint16_t w, mwi;
329 uint32_t d;
327 unsigned long flags = 0; 330 unsigned long flags = 0;
328 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 331 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
329 int pcix_cmd_reg, pcie_dctl_reg; 332 int pcix_cmd_reg, pcie_dctl_reg;
@@ -366,9 +369,9 @@ qla24xx_pci_config(scsi_qla_host_t *ha)
366 } 369 }
367 370
368 /* Reset expansion ROM address decode enable */ 371 /* Reset expansion ROM address decode enable */
369 pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w); 372 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
370 w &= ~PCI_ROM_ADDRESS_ENABLE; 373 d &= ~PCI_ROM_ADDRESS_ENABLE;
371 pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w); 374 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
372 375
373 /* Get PCI bus information. */ 376 /* Get PCI bus information. */
374 spin_lock_irqsave(&ha->hardware_lock, flags); 377 spin_lock_irqsave(&ha->hardware_lock, flags);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 8982978c42fd..7aec93f9d423 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1325,6 +1325,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1325 ha->brd_info = brd_info; 1325 ha->brd_info = brd_info;
1326 sprintf(ha->host_str, "%s_%ld", ha->brd_info->drv_name, ha->host_no); 1326 sprintf(ha->host_str, "%s_%ld", ha->brd_info->drv_name, ha->host_no);
1327 1327
1328 ha->dpc_pid = -1;
1329
1328 /* Configure PCI I/O space */ 1330 /* Configure PCI I/O space */
1329 ret = qla2x00_iospace_config(ha); 1331 ret = qla2x00_iospace_config(ha);
1330 if (ret) 1332 if (ret)
@@ -1448,7 +1450,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1448 */ 1450 */
1449 spin_lock_init(&ha->mbx_reg_lock); 1451 spin_lock_init(&ha->mbx_reg_lock);
1450 1452
1451 ha->dpc_pid = -1;
1452 init_completion(&ha->dpc_inited); 1453 init_completion(&ha->dpc_inited);
1453 init_completion(&ha->dpc_exited); 1454 init_completion(&ha->dpc_exited);
1454 1455
diff --git a/drivers/scsi/qla2xxx/qla_rscn.c b/drivers/scsi/qla2xxx/qla_rscn.c
index bdc3bc74bbe1..1eba98828636 100644
--- a/drivers/scsi/qla2xxx/qla_rscn.c
+++ b/drivers/scsi/qla2xxx/qla_rscn.c
@@ -330,6 +330,8 @@ qla2x00_update_login_fcport(scsi_qla_host_t *ha, struct mbx_entry *mbxstat,
330 fcport->flags &= ~FCF_FAILOVER_NEEDED; 330 fcport->flags &= ~FCF_FAILOVER_NEEDED;
331 fcport->iodesc_idx_sent = IODESC_INVALID_INDEX; 331 fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
332 atomic_set(&fcport->state, FCS_ONLINE); 332 atomic_set(&fcport->state, FCS_ONLINE);
333 if (fcport->rport)
334 fc_remote_port_unblock(fcport->rport);
333} 335}
334 336
335 337
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index a917ab7475ac..1fd5fc6d0fe3 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1119,6 +1119,36 @@ static inline void update_can_queue(struct Scsi_Host *host, u_int in_ptr, u_int
1119 host->sg_tablesize = QLOGICPTI_MAX_SG(num_free); 1119 host->sg_tablesize = QLOGICPTI_MAX_SG(num_free);
1120} 1120}
1121 1121
1122static unsigned int scsi_rbuf_get(struct scsi_cmnd *cmd, unsigned char **buf_out)
1123{
1124 unsigned char *buf;
1125 unsigned int buflen;
1126
1127 if (cmd->use_sg) {
1128 struct scatterlist *sg;
1129
1130 sg = (struct scatterlist *) cmd->request_buffer;
1131 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
1132 buflen = sg->length;
1133 } else {
1134 buf = cmd->request_buffer;
1135 buflen = cmd->request_bufflen;
1136 }
1137
1138 *buf_out = buf;
1139 return buflen;
1140}
1141
1142static void scsi_rbuf_put(struct scsi_cmnd *cmd, unsigned char *buf)
1143{
1144 if (cmd->use_sg) {
1145 struct scatterlist *sg;
1146
1147 sg = (struct scatterlist *) cmd->request_buffer;
1148 kunmap_atomic(buf - sg->offset, KM_IRQ0);
1149 }
1150}
1151
1122/* 1152/*
1123 * Until we scan the entire bus with inquiries, go throught this fella... 1153 * Until we scan the entire bus with inquiries, go throught this fella...
1124 */ 1154 */
@@ -1145,11 +1175,9 @@ static void ourdone(struct scsi_cmnd *Cmnd)
1145 int ok = host_byte(Cmnd->result) == DID_OK; 1175 int ok = host_byte(Cmnd->result) == DID_OK;
1146 if (Cmnd->cmnd[0] == 0x12 && ok) { 1176 if (Cmnd->cmnd[0] == 0x12 && ok) {
1147 unsigned char *iqd; 1177 unsigned char *iqd;
1178 unsigned int iqd_len;
1148 1179
1149 if (Cmnd->use_sg != 0) 1180 iqd_len = scsi_rbuf_get(Cmnd, &iqd);
1150 BUG();
1151
1152 iqd = ((unsigned char *)Cmnd->buffer);
1153 1181
1154 /* tags handled in midlayer */ 1182 /* tags handled in midlayer */
1155 /* enable sync mode? */ 1183 /* enable sync mode? */
@@ -1163,6 +1191,9 @@ static void ourdone(struct scsi_cmnd *Cmnd)
1163 if (iqd[7] & 0x20) { 1191 if (iqd[7] & 0x20) {
1164 qpti->dev_param[tgt].device_flags |= 0x20; 1192 qpti->dev_param[tgt].device_flags |= 0x20;
1165 } 1193 }
1194
1195 scsi_rbuf_put(Cmnd, iqd);
1196
1166 qpti->sbits |= (1 << tgt); 1197 qpti->sbits |= (1 << tgt);
1167 } else if (!ok) { 1198 } else if (!ok) {
1168 qpti->sbits |= (1 << tgt); 1199 qpti->sbits |= (1 << tgt);
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index a1d62dee3be6..cb832b03ec5e 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -29,6 +29,8 @@
29 * NV-specific details such as register offsets, SATA phy location, 29 * NV-specific details such as register offsets, SATA phy location,
30 * hotplug info, etc. 30 * hotplug info, etc.
31 * 31 *
32 * 0.09
33 * - Fixed bug introduced by 0.08's MCP51 and MCP55 support.
32 * 34 *
33 * 0.08 35 * 0.08
34 * - Added support for MCP51 and MCP55. 36 * - Added support for MCP51 and MCP55.
@@ -132,9 +134,7 @@ enum nv_host_type
132 GENERIC, 134 GENERIC,
133 NFORCE2, 135 NFORCE2,
134 NFORCE3, 136 NFORCE3,
135 CK804, 137 CK804
136 MCP51,
137 MCP55
138}; 138};
139 139
140static struct pci_device_id nv_pci_tbl[] = { 140static struct pci_device_id nv_pci_tbl[] = {
@@ -153,11 +153,13 @@ static struct pci_device_id nv_pci_tbl[] = {
153 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2, 153 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2,
154 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 }, 154 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CK804 },
155 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA, 155 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA,
156 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP51 }, 156 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
157 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2, 157 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2,
158 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP51 }, 158 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
159 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA, 159 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA,
160 PCI_ANY_ID, PCI_ANY_ID, 0, 0, MCP55 }, 160 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
161 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2,
162 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GENERIC },
161 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 163 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
162 PCI_ANY_ID, PCI_ANY_ID, 164 PCI_ANY_ID, PCI_ANY_ID,
163 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC }, 165 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index a780546eda9c..1f0ebabf6d47 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1265,9 +1265,8 @@ int scsi_device_cancel(struct scsi_device *sdev, int recovery)
1265 list_for_each_safe(lh, lh_sf, &active_list) { 1265 list_for_each_safe(lh, lh_sf, &active_list) {
1266 scmd = list_entry(lh, struct scsi_cmnd, eh_entry); 1266 scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
1267 list_del_init(lh); 1267 list_del_init(lh);
1268 if (recovery) { 1268 if (recovery &&
1269 scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD); 1269 !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD)) {
1270 } else {
1271 scmd->result = (DID_ABORT << 16); 1270 scmd->result = (DID_ABORT << 16);
1272 scsi_finish_command(scmd); 1271 scsi_finish_command(scmd);
1273 } 1272 }
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 07b554affcf2..e69477d1889b 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -110,6 +110,7 @@ static struct {
110 {"RELISYS", "Scorpio", NULL, BLIST_NOLUN}, /* responds to all lun */ 110 {"RELISYS", "Scorpio", NULL, BLIST_NOLUN}, /* responds to all lun */
111 {"SANKYO", "CP525", "6.64", BLIST_NOLUN}, /* causes failed REQ SENSE, extra reset */ 111 {"SANKYO", "CP525", "6.64", BLIST_NOLUN}, /* causes failed REQ SENSE, extra reset */
112 {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN}, 112 {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN},
113 {"transtec", "T5008", "0001", BLIST_NOREPORTLUN },
113 {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN}, /* locks up */ 114 {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN}, /* locks up */
114 {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */ 115 {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */
115 {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN}, /* locks up */ 116 {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN}, /* locks up */
@@ -184,6 +185,7 @@ static struct {
184 {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 185 {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
185 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 186 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
186 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 187 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
188 {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
187 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN}, 189 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
188 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN}, 190 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
189 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */ 191 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 895c9452be4c..52b348c36d56 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -50,7 +50,7 @@
50void scsi_eh_wakeup(struct Scsi_Host *shost) 50void scsi_eh_wakeup(struct Scsi_Host *shost)
51{ 51{
52 if (shost->host_busy == shost->host_failed) { 52 if (shost->host_busy == shost->host_failed) {
53 up(shost->eh_wait); 53 wake_up_process(shost->ehandler);
54 SCSI_LOG_ERROR_RECOVERY(5, 54 SCSI_LOG_ERROR_RECOVERY(5,
55 printk("Waking error handler thread\n")); 55 printk("Waking error handler thread\n"));
56 } 56 }
@@ -68,19 +68,24 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
68{ 68{
69 struct Scsi_Host *shost = scmd->device->host; 69 struct Scsi_Host *shost = scmd->device->host;
70 unsigned long flags; 70 unsigned long flags;
71 int ret = 0;
71 72
72 if (shost->eh_wait == NULL) 73 if (!shost->ehandler)
73 return 0; 74 return 0;
74 75
75 spin_lock_irqsave(shost->host_lock, flags); 76 spin_lock_irqsave(shost->host_lock, flags);
77 if (scsi_host_set_state(shost, SHOST_RECOVERY))
78 if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY))
79 goto out_unlock;
76 80
81 ret = 1;
77 scmd->eh_eflags |= eh_flag; 82 scmd->eh_eflags |= eh_flag;
78 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q); 83 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q);
79 scsi_host_set_state(shost, SHOST_RECOVERY);
80 shost->host_failed++; 84 shost->host_failed++;
81 scsi_eh_wakeup(shost); 85 scsi_eh_wakeup(shost);
86 out_unlock:
82 spin_unlock_irqrestore(shost->host_lock, flags); 87 spin_unlock_irqrestore(shost->host_lock, flags);
83 return 1; 88 return ret;
84} 89}
85 90
86/** 91/**
@@ -176,8 +181,8 @@ void scsi_times_out(struct scsi_cmnd *scmd)
176 } 181 }
177 182
178 if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { 183 if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
179 panic("Error handler thread not present at %p %p %s %d", 184 scmd->result |= DID_TIME_OUT << 16;
180 scmd, scmd->device->host, __FILE__, __LINE__); 185 __scsi_done(scmd);
181 } 186 }
182} 187}
183 188
@@ -196,8 +201,7 @@ int scsi_block_when_processing_errors(struct scsi_device *sdev)
196{ 201{
197 int online; 202 int online;
198 203
199 wait_event(sdev->host->host_wait, (sdev->host->shost_state != 204 wait_event(sdev->host->host_wait, !scsi_host_in_recovery(sdev->host));
200 SHOST_RECOVERY));
201 205
202 online = scsi_device_online(sdev); 206 online = scsi_device_online(sdev);
203 207
@@ -1441,6 +1445,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
1441static void scsi_restart_operations(struct Scsi_Host *shost) 1445static void scsi_restart_operations(struct Scsi_Host *shost)
1442{ 1446{
1443 struct scsi_device *sdev; 1447 struct scsi_device *sdev;
1448 unsigned long flags;
1444 1449
1445 /* 1450 /*
1446 * If the door was locked, we need to insert a door lock request 1451 * If the door was locked, we need to insert a door lock request
@@ -1460,7 +1465,11 @@ static void scsi_restart_operations(struct Scsi_Host *shost)
1460 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: waking up host to restart\n", 1465 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: waking up host to restart\n",
1461 __FUNCTION__)); 1466 __FUNCTION__));
1462 1467
1463 scsi_host_set_state(shost, SHOST_RUNNING); 1468 spin_lock_irqsave(shost->host_lock, flags);
1469 if (scsi_host_set_state(shost, SHOST_RUNNING))
1470 if (scsi_host_set_state(shost, SHOST_CANCEL))
1471 BUG_ON(scsi_host_set_state(shost, SHOST_DEL));
1472 spin_unlock_irqrestore(shost->host_lock, flags);
1464 1473
1465 wake_up(&shost->host_wait); 1474 wake_up(&shost->host_wait);
1466 1475
@@ -1582,40 +1591,31 @@ int scsi_error_handler(void *data)
1582{ 1591{
1583 struct Scsi_Host *shost = (struct Scsi_Host *) data; 1592 struct Scsi_Host *shost = (struct Scsi_Host *) data;
1584 int rtn; 1593 int rtn;
1585 DECLARE_MUTEX_LOCKED(sem);
1586 1594
1587 current->flags |= PF_NOFREEZE; 1595 current->flags |= PF_NOFREEZE;
1588 shost->eh_wait = &sem;
1589 1596
1597
1590 /* 1598 /*
1591 * Wake up the thread that created us. 1599 * Note - we always use TASK_INTERRUPTIBLE even if the module
1600 * was loaded as part of the kernel. The reason is that
1601 * UNINTERRUPTIBLE would cause this thread to be counted in
1602 * the load average as a running process, and an interruptible
1603 * wait doesn't.
1592 */ 1604 */
1593 SCSI_LOG_ERROR_RECOVERY(3, printk("Wake up parent of" 1605 set_current_state(TASK_INTERRUPTIBLE);
1594 " scsi_eh_%d\n",shost->host_no)); 1606 while (!kthread_should_stop()) {
1595 1607 if (shost->host_failed == 0 ||
1596 while (1) { 1608 shost->host_failed != shost->host_busy) {
1597 /* 1609 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler"
1598 * If we get a signal, it means we are supposed to go 1610 " scsi_eh_%d"
1599 * away and die. This typically happens if the user is 1611 " sleeping\n",
1600 * trying to unload a module. 1612 shost->host_no));
1601 */ 1613 schedule();
1602 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler" 1614 set_current_state(TASK_INTERRUPTIBLE);
1603 " scsi_eh_%d" 1615 continue;
1604 " sleeping\n",shost->host_no)); 1616 }
1605
1606 /*
1607 * Note - we always use down_interruptible with the semaphore
1608 * even if the module was loaded as part of the kernel. The
1609 * reason is that down() will cause this thread to be counted
1610 * in the load average as a running process, and down
1611 * interruptible doesn't. Given that we need to allow this
1612 * thread to die if the driver was loaded as a module, using
1613 * semaphores isn't unreasonable.
1614 */
1615 down_interruptible(&sem);
1616 if (kthread_should_stop())
1617 break;
1618 1617
1618 __set_current_state(TASK_RUNNING);
1619 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler" 1619 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler"
1620 " scsi_eh_%d waking" 1620 " scsi_eh_%d waking"
1621 " up\n",shost->host_no)); 1621 " up\n",shost->host_no));
@@ -1642,16 +1642,18 @@ int scsi_error_handler(void *data)
1642 * which are still online. 1642 * which are still online.
1643 */ 1643 */
1644 scsi_restart_operations(shost); 1644 scsi_restart_operations(shost);
1645 1645 set_current_state(TASK_INTERRUPTIBLE);
1646 } 1646 }
1647 1647
1648 __set_current_state(TASK_RUNNING);
1649
1648 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler scsi_eh_%d" 1650 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler scsi_eh_%d"
1649 " exiting\n",shost->host_no)); 1651 " exiting\n",shost->host_no));
1650 1652
1651 /* 1653 /*
1652 * Make sure that nobody tries to wake us up again. 1654 * Make sure that nobody tries to wake us up again.
1653 */ 1655 */
1654 shost->eh_wait = NULL; 1656 shost->ehandler = NULL;
1655 return 0; 1657 return 0;
1656} 1658}
1657 1659
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index b7fddac81347..de7f98cc38fe 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -458,7 +458,7 @@ int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd,
458 * error processing, as long as the device was opened 458 * error processing, as long as the device was opened
459 * non-blocking */ 459 * non-blocking */
460 if (filp && filp->f_flags & O_NONBLOCK) { 460 if (filp && filp->f_flags & O_NONBLOCK) {
461 if (sdev->host->shost_state == SHOST_RECOVERY) 461 if (scsi_host_in_recovery(sdev->host))
462 return -ENODEV; 462 return -ENODEV;
463 } else if (!scsi_block_when_processing_errors(sdev)) 463 } else if (!scsi_block_when_processing_errors(sdev))
464 return -ENODEV; 464 return -ENODEV;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 863bb6495daa..0074f28c37b2 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -97,7 +97,6 @@ int scsi_insert_special_req(struct scsi_request *sreq, int at_head)
97} 97}
98 98
99static void scsi_run_queue(struct request_queue *q); 99static void scsi_run_queue(struct request_queue *q);
100static void scsi_release_buffers(struct scsi_cmnd *cmd);
101 100
102/* 101/*
103 * Function: scsi_unprep_request() 102 * Function: scsi_unprep_request()
@@ -118,7 +117,6 @@ static void scsi_unprep_request(struct request *req)
118 req->flags &= ~REQ_DONTPREP; 117 req->flags &= ~REQ_DONTPREP;
119 req->special = (req->flags & REQ_SPECIAL) ? cmd->sc_request : NULL; 118 req->special = (req->flags & REQ_SPECIAL) ? cmd->sc_request : NULL;
120 119
121 scsi_release_buffers(cmd);
122 scsi_put_command(cmd); 120 scsi_put_command(cmd);
123} 121}
124 122
@@ -140,14 +138,12 @@ static void scsi_unprep_request(struct request *req)
140 * commands. 138 * commands.
141 * Notes: This could be called either from an interrupt context or a 139 * Notes: This could be called either from an interrupt context or a
142 * normal process context. 140 * normal process context.
143 * Notes: Upon return, cmd is a stale pointer.
144 */ 141 */
145int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) 142int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
146{ 143{
147 struct Scsi_Host *host = cmd->device->host; 144 struct Scsi_Host *host = cmd->device->host;
148 struct scsi_device *device = cmd->device; 145 struct scsi_device *device = cmd->device;
149 struct request_queue *q = device->request_queue; 146 struct request_queue *q = device->request_queue;
150 struct request *req = cmd->request;
151 unsigned long flags; 147 unsigned long flags;
152 148
153 SCSI_LOG_MLQUEUE(1, 149 SCSI_LOG_MLQUEUE(1,
@@ -188,9 +184,8 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
188 * function. The SCSI request function detects the blocked condition 184 * function. The SCSI request function detects the blocked condition
189 * and plugs the queue appropriately. 185 * and plugs the queue appropriately.
190 */ 186 */
191 scsi_unprep_request(req);
192 spin_lock_irqsave(q->queue_lock, flags); 187 spin_lock_irqsave(q->queue_lock, flags);
193 blk_requeue_request(q, req); 188 blk_requeue_request(q, cmd->request);
194 spin_unlock_irqrestore(q->queue_lock, flags); 189 spin_unlock_irqrestore(q->queue_lock, flags);
195 190
196 scsi_run_queue(q); 191 scsi_run_queue(q);
@@ -451,7 +446,7 @@ void scsi_device_unbusy(struct scsi_device *sdev)
451 446
452 spin_lock_irqsave(shost->host_lock, flags); 447 spin_lock_irqsave(shost->host_lock, flags);
453 shost->host_busy--; 448 shost->host_busy--;
454 if (unlikely((shost->shost_state == SHOST_RECOVERY) && 449 if (unlikely(scsi_host_in_recovery(shost) &&
455 shost->host_failed)) 450 shost->host_failed))
456 scsi_eh_wakeup(shost); 451 scsi_eh_wakeup(shost);
457 spin_unlock(shost->host_lock); 452 spin_unlock(shost->host_lock);
@@ -1044,8 +1039,10 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1044 * if sg table allocation fails, requeue request later. 1039 * if sg table allocation fails, requeue request later.
1045 */ 1040 */
1046 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); 1041 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC);
1047 if (unlikely(!sgpnt)) 1042 if (unlikely(!sgpnt)) {
1043 scsi_unprep_request(req);
1048 return BLKPREP_DEFER; 1044 return BLKPREP_DEFER;
1045 }
1049 1046
1050 cmd->request_buffer = (char *) sgpnt; 1047 cmd->request_buffer = (char *) sgpnt;
1051 cmd->request_bufflen = req->nr_sectors << 9; 1048 cmd->request_bufflen = req->nr_sectors << 9;
@@ -1249,8 +1246,8 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1249 */ 1246 */
1250 ret = scsi_init_io(cmd); 1247 ret = scsi_init_io(cmd);
1251 switch(ret) { 1248 switch(ret) {
1249 /* For BLKPREP_KILL/DEFER the cmd was released */
1252 case BLKPREP_KILL: 1250 case BLKPREP_KILL:
1253 /* BLKPREP_KILL return also releases the command */
1254 goto kill; 1251 goto kill;
1255 case BLKPREP_DEFER: 1252 case BLKPREP_DEFER:
1256 goto defer; 1253 goto defer;
@@ -1268,6 +1265,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1268 } 1265 }
1269 } else { 1266 } else {
1270 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1267 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1268 cmd->cmd_len = req->cmd_len;
1271 if (rq_data_dir(req) == WRITE) 1269 if (rq_data_dir(req) == WRITE)
1272 cmd->sc_data_direction = DMA_TO_DEVICE; 1270 cmd->sc_data_direction = DMA_TO_DEVICE;
1273 else if (req->data_len) 1271 else if (req->data_len)
@@ -1342,7 +1340,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
1342 struct Scsi_Host *shost, 1340 struct Scsi_Host *shost,
1343 struct scsi_device *sdev) 1341 struct scsi_device *sdev)
1344{ 1342{
1345 if (shost->shost_state == SHOST_RECOVERY) 1343 if (scsi_host_in_recovery(shost))
1346 return 0; 1344 return 0;
1347 if (shost->host_busy == 0 && shost->host_blocked) { 1345 if (shost->host_busy == 0 && shost->host_blocked) {
1348 /* 1346 /*
@@ -1514,7 +1512,6 @@ static void scsi_request_fn(struct request_queue *q)
1514 * cases (host limits or settings) should run the queue at some 1512 * cases (host limits or settings) should run the queue at some
1515 * later time. 1513 * later time.
1516 */ 1514 */
1517 scsi_unprep_request(req);
1518 spin_lock_irq(q->queue_lock); 1515 spin_lock_irq(q->queue_lock);
1519 blk_requeue_request(q, req); 1516 blk_requeue_request(q, req);
1520 sdev->device_busy--; 1517 sdev->device_busy--;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index b86f170fa8ed..327c5d7e5bd2 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -587,6 +587,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result,
587 if (sdev->scsi_level >= 2 || 587 if (sdev->scsi_level >= 2 ||
588 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1)) 588 (sdev->scsi_level == 1 && (inq_result[3] & 0x0f) == 1))
589 sdev->scsi_level++; 589 sdev->scsi_level++;
590 sdev->sdev_target->scsi_level = sdev->scsi_level;
590 591
591 return 0; 592 return 0;
592} 593}
@@ -771,6 +772,15 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
771 return SCSI_SCAN_LUN_PRESENT; 772 return SCSI_SCAN_LUN_PRESENT;
772} 773}
773 774
775static inline void scsi_destroy_sdev(struct scsi_device *sdev)
776{
777 if (sdev->host->hostt->slave_destroy)
778 sdev->host->hostt->slave_destroy(sdev);
779 transport_destroy_device(&sdev->sdev_gendev);
780 put_device(&sdev->sdev_gendev);
781}
782
783
774/** 784/**
775 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it 785 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it
776 * @starget: pointer to target device structure 786 * @starget: pointer to target device structure
@@ -803,9 +813,9 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
803 * The rescan flag is used as an optimization, the first scan of a 813 * The rescan flag is used as an optimization, the first scan of a
804 * host adapter calls into here with rescan == 0. 814 * host adapter calls into here with rescan == 0.
805 */ 815 */
806 if (rescan) { 816 sdev = scsi_device_lookup_by_target(starget, lun);
807 sdev = scsi_device_lookup_by_target(starget, lun); 817 if (sdev) {
808 if (sdev) { 818 if (rescan || sdev->sdev_state != SDEV_CREATED) {
809 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO 819 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
810 "scsi scan: device exists on %s\n", 820 "scsi scan: device exists on %s\n",
811 sdev->sdev_gendev.bus_id)); 821 sdev->sdev_gendev.bus_id));
@@ -820,9 +830,9 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
820 sdev->model); 830 sdev->model);
821 return SCSI_SCAN_LUN_PRESENT; 831 return SCSI_SCAN_LUN_PRESENT;
822 } 832 }
823 } 833 scsi_device_put(sdev);
824 834 } else
825 sdev = scsi_alloc_sdev(starget, lun, hostdata); 835 sdev = scsi_alloc_sdev(starget, lun, hostdata);
826 if (!sdev) 836 if (!sdev)
827 goto out; 837 goto out;
828 838
@@ -877,12 +887,8 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
877 res = SCSI_SCAN_NO_RESPONSE; 887 res = SCSI_SCAN_NO_RESPONSE;
878 } 888 }
879 } 889 }
880 } else { 890 } else
881 if (sdev->host->hostt->slave_destroy) 891 scsi_destroy_sdev(sdev);
882 sdev->host->hostt->slave_destroy(sdev);
883 transport_destroy_device(&sdev->sdev_gendev);
884 put_device(&sdev->sdev_gendev);
885 }
886 out: 892 out:
887 return res; 893 return res;
888} 894}
@@ -1054,7 +1060,7 @@ EXPORT_SYMBOL(int_to_scsilun);
1054 * 0: scan completed (or no memory, so further scanning is futile) 1060 * 0: scan completed (or no memory, so further scanning is futile)
1055 * 1: no report lun scan, or not configured 1061 * 1: no report lun scan, or not configured
1056 **/ 1062 **/
1057static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags, 1063static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1058 int rescan) 1064 int rescan)
1059{ 1065{
1060 char devname[64]; 1066 char devname[64];
@@ -1067,7 +1073,8 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1067 struct scsi_lun *lunp, *lun_data; 1073 struct scsi_lun *lunp, *lun_data;
1068 u8 *data; 1074 u8 *data;
1069 struct scsi_sense_hdr sshdr; 1075 struct scsi_sense_hdr sshdr;
1070 struct scsi_target *starget = scsi_target(sdev); 1076 struct scsi_device *sdev;
1077 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
1071 1078
1072 /* 1079 /*
1073 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. 1080 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set.
@@ -1075,15 +1082,23 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1075 * support more than 8 LUNs. 1082 * support more than 8 LUNs.
1076 */ 1083 */
1077 if ((bflags & BLIST_NOREPORTLUN) || 1084 if ((bflags & BLIST_NOREPORTLUN) ||
1078 sdev->scsi_level < SCSI_2 || 1085 starget->scsi_level < SCSI_2 ||
1079 (sdev->scsi_level < SCSI_3 && 1086 (starget->scsi_level < SCSI_3 &&
1080 (!(bflags & BLIST_REPORTLUN2) || sdev->host->max_lun <= 8)) ) 1087 (!(bflags & BLIST_REPORTLUN2) || shost->max_lun <= 8)) )
1081 return 1; 1088 return 1;
1082 if (bflags & BLIST_NOLUN) 1089 if (bflags & BLIST_NOLUN)
1083 return 0; 1090 return 0;
1084 1091
1092 if (!(sdev = scsi_device_lookup_by_target(starget, 0))) {
1093 sdev = scsi_alloc_sdev(starget, 0, NULL);
1094 if (!sdev)
1095 return 0;
1096 if (scsi_device_get(sdev))
1097 return 0;
1098 }
1099
1085 sprintf(devname, "host %d channel %d id %d", 1100 sprintf(devname, "host %d channel %d id %d",
1086 sdev->host->host_no, sdev->channel, sdev->id); 1101 shost->host_no, sdev->channel, sdev->id);
1087 1102
1088 /* 1103 /*
1089 * Allocate enough to hold the header (the same size as one scsi_lun) 1104 * Allocate enough to hold the header (the same size as one scsi_lun)
@@ -1098,8 +1113,10 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1098 length = (max_scsi_report_luns + 1) * sizeof(struct scsi_lun); 1113 length = (max_scsi_report_luns + 1) * sizeof(struct scsi_lun);
1099 lun_data = kmalloc(length, GFP_ATOMIC | 1114 lun_data = kmalloc(length, GFP_ATOMIC |
1100 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0)); 1115 (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
1101 if (!lun_data) 1116 if (!lun_data) {
1117 printk(ALLOC_FAILURE_MSG, __FUNCTION__);
1102 goto out; 1118 goto out;
1119 }
1103 1120
1104 scsi_cmd[0] = REPORT_LUNS; 1121 scsi_cmd[0] = REPORT_LUNS;
1105 1122
@@ -1201,10 +1218,6 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1201 for (i = 0; i < sizeof(struct scsi_lun); i++) 1218 for (i = 0; i < sizeof(struct scsi_lun); i++)
1202 printk("%02x", data[i]); 1219 printk("%02x", data[i]);
1203 printk(" has a LUN larger than currently supported.\n"); 1220 printk(" has a LUN larger than currently supported.\n");
1204 } else if (lun == 0) {
1205 /*
1206 * LUN 0 has already been scanned.
1207 */
1208 } else if (lun > sdev->host->max_lun) { 1221 } else if (lun > sdev->host->max_lun) {
1209 printk(KERN_WARNING "scsi: %s lun%d has a LUN larger" 1222 printk(KERN_WARNING "scsi: %s lun%d has a LUN larger"
1210 " than allowed by the host adapter\n", 1223 " than allowed by the host adapter\n",
@@ -1227,13 +1240,13 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags,
1227 } 1240 }
1228 1241
1229 kfree(lun_data); 1242 kfree(lun_data);
1230 return 0;
1231
1232 out: 1243 out:
1233 /* 1244 scsi_device_put(sdev);
1234 * We are out of memory, don't try scanning any further. 1245 if (sdev->sdev_state == SDEV_CREATED)
1235 */ 1246 /*
1236 printk(ALLOC_FAILURE_MSG, __FUNCTION__); 1247 * the sdev we used didn't appear in the report luns scan
1248 */
1249 scsi_destroy_sdev(sdev);
1237 return 0; 1250 return 0;
1238} 1251}
1239 1252
@@ -1299,7 +1312,6 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
1299 struct Scsi_Host *shost = dev_to_shost(parent); 1312 struct Scsi_Host *shost = dev_to_shost(parent);
1300 int bflags = 0; 1313 int bflags = 0;
1301 int res; 1314 int res;
1302 struct scsi_device *sdev = NULL;
1303 struct scsi_target *starget; 1315 struct scsi_target *starget;
1304 1316
1305 if (shost->this_id == id) 1317 if (shost->this_id == id)
@@ -1325,27 +1337,16 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
1325 * Scan LUN 0, if there is some response, scan further. Ideally, we 1337 * Scan LUN 0, if there is some response, scan further. Ideally, we
1326 * would not configure LUN 0 until all LUNs are scanned. 1338 * would not configure LUN 0 until all LUNs are scanned.
1327 */ 1339 */
1328 res = scsi_probe_and_add_lun(starget, 0, &bflags, &sdev, rescan, NULL); 1340 res = scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL);
1329 if (res == SCSI_SCAN_LUN_PRESENT) { 1341 if (res == SCSI_SCAN_LUN_PRESENT || res == SCSI_SCAN_TARGET_PRESENT) {
1330 if (scsi_report_lun_scan(sdev, bflags, rescan) != 0) 1342 if (scsi_report_lun_scan(starget, bflags, rescan) != 0)
1331 /* 1343 /*
1332 * The REPORT LUN did not scan the target, 1344 * The REPORT LUN did not scan the target,
1333 * do a sequential scan. 1345 * do a sequential scan.
1334 */ 1346 */
1335 scsi_sequential_lun_scan(starget, bflags, 1347 scsi_sequential_lun_scan(starget, bflags,
1336 res, sdev->scsi_level, rescan); 1348 res, starget->scsi_level, rescan);
1337 } else if (res == SCSI_SCAN_TARGET_PRESENT) {
1338 /*
1339 * There's a target here, but lun 0 is offline so we
1340 * can't use the report_lun scan. Fall back to a
1341 * sequential lun scan with a bflags of SPARSELUN and
1342 * a default scsi level of SCSI_2
1343 */
1344 scsi_sequential_lun_scan(starget, BLIST_SPARSELUN,
1345 SCSI_SCAN_TARGET_PRESENT, SCSI_2, rescan);
1346 } 1349 }
1347 if (sdev)
1348 scsi_device_put(sdev);
1349 1350
1350 out_reap: 1351 out_reap:
1351 /* now determine if the target has any children at all 1352 /* now determine if the target has any children at all
@@ -1466,23 +1467,17 @@ EXPORT_SYMBOL(scsi_scan_single_target);
1466 1467
1467void scsi_forget_host(struct Scsi_Host *shost) 1468void scsi_forget_host(struct Scsi_Host *shost)
1468{ 1469{
1469 struct scsi_target *starget, *tmp; 1470 struct scsi_device *sdev;
1470 unsigned long flags; 1471 unsigned long flags;
1471 1472
1472 /* 1473 restart:
1473 * Ok, this look a bit strange. We always look for the first device
1474 * on the list as scsi_remove_device removes them from it - thus we
1475 * also have to release the lock.
1476 * We don't need to get another reference to the device before
1477 * releasing the lock as we already own the reference from
1478 * scsi_register_device that's release in scsi_remove_device. And
1479 * after that we don't look at sdev anymore.
1480 */
1481 spin_lock_irqsave(shost->host_lock, flags); 1474 spin_lock_irqsave(shost->host_lock, flags);
1482 list_for_each_entry_safe(starget, tmp, &shost->__targets, siblings) { 1475 list_for_each_entry(sdev, &shost->__devices, siblings) {
1476 if (sdev->sdev_state == SDEV_DEL)
1477 continue;
1483 spin_unlock_irqrestore(shost->host_lock, flags); 1478 spin_unlock_irqrestore(shost->host_lock, flags);
1484 scsi_remove_target(&starget->dev); 1479 __scsi_remove_device(sdev);
1485 spin_lock_irqsave(shost->host_lock, flags); 1480 goto restart;
1486 } 1481 }
1487 spin_unlock_irqrestore(shost->host_lock, flags); 1482 spin_unlock_irqrestore(shost->host_lock, flags);
1488} 1483}
@@ -1548,10 +1543,7 @@ void scsi_free_host_dev(struct scsi_device *sdev)
1548{ 1543{
1549 BUG_ON(sdev->id != sdev->host->this_id); 1544 BUG_ON(sdev->id != sdev->host->this_id);
1550 1545
1551 if (sdev->host->hostt->slave_destroy) 1546 scsi_destroy_sdev(sdev);
1552 sdev->host->hostt->slave_destroy(sdev);
1553 transport_destroy_device(&sdev->sdev_gendev);
1554 put_device(&sdev->sdev_gendev);
1555} 1547}
1556EXPORT_SYMBOL(scsi_free_host_dev); 1548EXPORT_SYMBOL(scsi_free_host_dev);
1557 1549
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b8052d5206cc..72a6550a056c 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -57,6 +57,8 @@ static struct {
57 { SHOST_CANCEL, "cancel" }, 57 { SHOST_CANCEL, "cancel" },
58 { SHOST_DEL, "deleted" }, 58 { SHOST_DEL, "deleted" },
59 { SHOST_RECOVERY, "recovery" }, 59 { SHOST_RECOVERY, "recovery" },
60 { SHOST_CANCEL_RECOVERY, "cancel/recovery" },
61 { SHOST_DEL_RECOVERY, "deleted/recovery", },
60}; 62};
61const char *scsi_host_state_name(enum scsi_host_state state) 63const char *scsi_host_state_name(enum scsi_host_state state)
62{ 64{
@@ -707,9 +709,11 @@ void __scsi_remove_device(struct scsi_device *sdev)
707 **/ 709 **/
708void scsi_remove_device(struct scsi_device *sdev) 710void scsi_remove_device(struct scsi_device *sdev)
709{ 711{
710 down(&sdev->host->scan_mutex); 712 struct Scsi_Host *shost = sdev->host;
713
714 down(&shost->scan_mutex);
711 __scsi_remove_device(sdev); 715 __scsi_remove_device(sdev);
712 up(&sdev->host->scan_mutex); 716 up(&shost->scan_mutex);
713} 717}
714EXPORT_SYMBOL(scsi_remove_device); 718EXPORT_SYMBOL(scsi_remove_device);
715 719
@@ -717,17 +721,20 @@ void __scsi_remove_target(struct scsi_target *starget)
717{ 721{
718 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 722 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
719 unsigned long flags; 723 unsigned long flags;
720 struct scsi_device *sdev, *tmp; 724 struct scsi_device *sdev;
721 725
722 spin_lock_irqsave(shost->host_lock, flags); 726 spin_lock_irqsave(shost->host_lock, flags);
723 starget->reap_ref++; 727 starget->reap_ref++;
724 list_for_each_entry_safe(sdev, tmp, &shost->__devices, siblings) { 728 restart:
729 list_for_each_entry(sdev, &shost->__devices, siblings) {
725 if (sdev->channel != starget->channel || 730 if (sdev->channel != starget->channel ||
726 sdev->id != starget->id) 731 sdev->id != starget->id ||
732 sdev->sdev_state == SDEV_DEL)
727 continue; 733 continue;
728 spin_unlock_irqrestore(shost->host_lock, flags); 734 spin_unlock_irqrestore(shost->host_lock, flags);
729 scsi_remove_device(sdev); 735 scsi_remove_device(sdev);
730 spin_lock_irqsave(shost->host_lock, flags); 736 spin_lock_irqsave(shost->host_lock, flags);
737 goto restart;
731 } 738 }
732 spin_unlock_irqrestore(shost->host_lock, flags); 739 spin_unlock_irqrestore(shost->host_lock, flags);
733 scsi_target_reap(starget); 740 scsi_target_reap(starget);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 2cab556b6e82..771e97ef136e 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -819,12 +819,15 @@ show_fc_private_host_tgtid_bind_type(struct class_device *cdev, char *buf)
819 return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name); 819 return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name);
820} 820}
821 821
822#define get_list_head_entry(pos, head, member) \
823 pos = list_entry((head)->next, typeof(*pos), member)
824
822static ssize_t 825static ssize_t
823store_fc_private_host_tgtid_bind_type(struct class_device *cdev, 826store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
824 const char *buf, size_t count) 827 const char *buf, size_t count)
825{ 828{
826 struct Scsi_Host *shost = transport_class_to_shost(cdev); 829 struct Scsi_Host *shost = transport_class_to_shost(cdev);
827 struct fc_rport *rport, *next_rport; 830 struct fc_rport *rport;
828 enum fc_tgtid_binding_type val; 831 enum fc_tgtid_binding_type val;
829 unsigned long flags; 832 unsigned long flags;
830 833
@@ -834,9 +837,13 @@ store_fc_private_host_tgtid_bind_type(struct class_device *cdev,
834 /* if changing bind type, purge all unused consistent bindings */ 837 /* if changing bind type, purge all unused consistent bindings */
835 if (val != fc_host_tgtid_bind_type(shost)) { 838 if (val != fc_host_tgtid_bind_type(shost)) {
836 spin_lock_irqsave(shost->host_lock, flags); 839 spin_lock_irqsave(shost->host_lock, flags);
837 list_for_each_entry_safe(rport, next_rport, 840 while (!list_empty(&fc_host_rport_bindings(shost))) {
838 &fc_host_rport_bindings(shost), peers) 841 get_list_head_entry(rport,
842 &fc_host_rport_bindings(shost), peers);
843 spin_unlock_irqrestore(shost->host_lock, flags);
839 fc_rport_terminate(rport); 844 fc_rport_terminate(rport);
845 spin_lock_irqsave(shost->host_lock, flags);
846 }
840 spin_unlock_irqrestore(shost->host_lock, flags); 847 spin_unlock_irqrestore(shost->host_lock, flags);
841 } 848 }
842 849
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index ff724bbe6611..1d145d2f9a38 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -628,17 +628,16 @@ sas_rphy_delete(struct sas_rphy *rphy)
628 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent); 628 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);
629 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 629 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
630 630
631 transport_destroy_device(&rphy->dev); 631 scsi_remove_target(dev);
632 632
633 scsi_remove_target(&rphy->dev); 633 transport_remove_device(dev);
634 device_del(dev);
635 transport_destroy_device(dev);
634 636
635 spin_lock(&sas_host->lock); 637 spin_lock(&sas_host->lock);
636 list_del(&rphy->list); 638 list_del(&rphy->list);
637 spin_unlock(&sas_host->lock); 639 spin_unlock(&sas_host->lock);
638 640
639 transport_remove_device(dev);
640 device_del(dev);
641 transport_destroy_device(dev);
642 put_device(&parent->dev); 641 put_device(&parent->dev);
643} 642}
644EXPORT_SYMBOL(sas_rphy_delete); 643EXPORT_SYMBOL(sas_rphy_delete);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index de564b386052..9a1dc0cea03c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -235,6 +235,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
235 return 0; 235 return 0;
236 236
237 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd)); 237 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
238 SCpnt->cmd_len = rq->cmd_len;
238 if (rq_data_dir(rq) == WRITE) 239 if (rq_data_dir(rq) == WRITE)
239 SCpnt->sc_data_direction = DMA_TO_DEVICE; 240 SCpnt->sc_data_direction = DMA_TO_DEVICE;
240 else if (rq->data_len) 241 else if (rq->data_len)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 9ea4765d1d12..ad94367df430 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1027,7 +1027,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
1027 if (sdp->detached) 1027 if (sdp->detached)
1028 return -ENODEV; 1028 return -ENODEV;
1029 if (filp->f_flags & O_NONBLOCK) { 1029 if (filp->f_flags & O_NONBLOCK) {
1030 if (sdp->device->host->shost_state == SHOST_RECOVERY) 1030 if (scsi_host_in_recovery(sdp->device->host))
1031 return -EBUSY; 1031 return -EBUSY;
1032 } else if (!scsi_block_when_processing_errors(sdp->device)) 1032 } else if (!scsi_block_when_processing_errors(sdp->device))
1033 return -EBUSY; 1033 return -EBUSY;
@@ -2849,8 +2849,7 @@ sg_proc_init(void)
2849 struct proc_dir_entry *pdep; 2849 struct proc_dir_entry *pdep;
2850 struct sg_proc_leaf * leaf; 2850 struct sg_proc_leaf * leaf;
2851 2851
2852 sg_proc_sgp = create_proc_entry(sg_proc_sg_dirname, 2852 sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL);
2853 S_IFDIR | S_IRUGO | S_IXUGO, NULL);
2854 if (!sg_proc_sgp) 2853 if (!sg_proc_sgp)
2855 return 1; 2854 return 1;
2856 for (k = 0; k < num_leaves; ++k) { 2855 for (k = 0; k < num_leaves; ++k) {
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index ce63fc8312dc..561901b1cf11 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -326,6 +326,7 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
326 return 0; 326 return 0;
327 327
328 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd)); 328 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
329 SCpnt->cmd_len = rq->cmd_len;
329 if (!rq->data_len) 330 if (!rq->data_len)
330 SCpnt->sc_data_direction = DMA_NONE; 331 SCpnt->sc_data_direction = DMA_NONE;
331 else if (rq_data_dir(rq) == WRITE) 332 else if (rq_data_dir(rq) == WRITE)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index a93308ae9736..d001c046551b 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4206,6 +4206,7 @@ static int st_init_command(struct scsi_cmnd *SCpnt)
4206 return 0; 4206 return 0;
4207 4207
4208 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd)); 4208 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
4209 SCpnt->cmd_len = rq->cmd_len;
4209 4210
4210 if (rq_data_dir(rq) == WRITE) 4211 if (rq_data_dir(rq) == WRITE)
4211 SCpnt->sc_data_direction = DMA_TO_DEVICE; 4212 SCpnt->sc_data_direction = DMA_TO_DEVICE;
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 0e21f583690e..5c3c03932d6d 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -152,6 +152,7 @@ static int __devinit pci_hp_diva_init(struct pci_dev *dev)
152 rc = 4; 152 rc = 4;
153 break; 153 break;
154 case PCI_DEVICE_ID_HP_DIVA_POWERBAR: 154 case PCI_DEVICE_ID_HP_DIVA_POWERBAR:
155 case PCI_DEVICE_ID_HP_DIVA_HURRICANE:
155 rc = 1; 156 rc = 1;
156 break; 157 break;
157 } 158 }
@@ -226,8 +227,10 @@ static int __devinit pci_plx9050_init(struct pci_dev *dev)
226 } 227 }
227 228
228 irq_config = 0x41; 229 irq_config = 0x41;
229 if (dev->vendor == PCI_VENDOR_ID_PANACOM) 230 if (dev->vendor == PCI_VENDOR_ID_PANACOM ||
231 dev->subsystem_vendor == PCI_SUBVENDOR_ID_EXSYS) {
230 irq_config = 0x43; 232 irq_config = 0x43;
233 }
231 if ((dev->vendor == PCI_VENDOR_ID_PLX) && 234 if ((dev->vendor == PCI_VENDOR_ID_PLX) &&
232 (dev->device == PCI_DEVICE_ID_PLX_ROMULUS)) { 235 (dev->device == PCI_DEVICE_ID_PLX_ROMULUS)) {
233 /* 236 /*
@@ -664,6 +667,15 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
664 { 667 {
665 .vendor = PCI_VENDOR_ID_PLX, 668 .vendor = PCI_VENDOR_ID_PLX,
666 .device = PCI_DEVICE_ID_PLX_9050, 669 .device = PCI_DEVICE_ID_PLX_9050,
670 .subvendor = PCI_SUBVENDOR_ID_EXSYS,
671 .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055,
672 .init = pci_plx9050_init,
673 .setup = pci_default_setup,
674 .exit = __devexit_p(pci_plx9050_exit),
675 },
676 {
677 .vendor = PCI_VENDOR_ID_PLX,
678 .device = PCI_DEVICE_ID_PLX_9050,
667 .subvendor = PCI_SUBVENDOR_ID_KEYSPAN, 679 .subvendor = PCI_SUBVENDOR_ID_KEYSPAN,
668 .subdevice = PCI_SUBDEVICE_ID_KEYSPAN_SX2, 680 .subdevice = PCI_SUBDEVICE_ID_KEYSPAN_SX2,
669 .init = pci_plx9050_init, 681 .init = pci_plx9050_init,
@@ -927,6 +939,7 @@ enum pci_board_num_t {
927 pbn_panacom, 939 pbn_panacom,
928 pbn_panacom2, 940 pbn_panacom2,
929 pbn_panacom4, 941 pbn_panacom4,
942 pbn_exsys_4055,
930 pbn_plx_romulus, 943 pbn_plx_romulus,
931 pbn_oxsemi, 944 pbn_oxsemi,
932 pbn_intel_i960, 945 pbn_intel_i960,
@@ -1292,6 +1305,13 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1292 .reg_shift = 7, 1305 .reg_shift = 7,
1293 }, 1306 },
1294 1307
1308 [pbn_exsys_4055] = {
1309 .flags = FL_BASE2,
1310 .num_ports = 4,
1311 .base_baud = 115200,
1312 .uart_offset = 8,
1313 },
1314
1295 /* I think this entry is broken - the first_offset looks wrong --rmk */ 1315 /* I think this entry is broken - the first_offset looks wrong --rmk */
1296 [pbn_plx_romulus] = { 1316 [pbn_plx_romulus] = {
1297 .flags = FL_BASE2, 1317 .flags = FL_BASE2,
@@ -1853,6 +1873,10 @@ static struct pci_device_id serial_pci_tbl[] = {
1853 PCI_SUBVENDOR_ID_CHASE_PCIRAS, 1873 PCI_SUBVENDOR_ID_CHASE_PCIRAS,
1854 PCI_SUBDEVICE_ID_CHASE_PCIRAS8, 0, 0, 1874 PCI_SUBDEVICE_ID_CHASE_PCIRAS8, 0, 0,
1855 pbn_b2_8_460800 }, 1875 pbn_b2_8_460800 },
1876 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
1877 PCI_SUBVENDOR_ID_EXSYS,
1878 PCI_SUBDEVICE_ID_EXSYS_4055, 0, 0,
1879 pbn_exsys_4055 },
1856 /* 1880 /*
1857 * Megawolf Romulus PCI Serial Card, from Mike Hudson 1881 * Megawolf Romulus PCI Serial Card, from Mike Hudson
1858 * (Exoray@isys.ca) 1882 * (Exoray@isys.ca)
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 6b321e82cafb..5d8660a42b77 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -272,8 +272,12 @@ static const struct pnp_device_id pnp_dev_table[] = {
272 { "SUP1421", 0 }, 272 { "SUP1421", 0 },
273 /* SupraExpress 33.6 Data/Fax PnP modem */ 273 /* SupraExpress 33.6 Data/Fax PnP modem */
274 { "SUP1590", 0 }, 274 { "SUP1590", 0 },
275 /* SupraExpress 336i Sp ASVD */
276 { "SUP1620", 0 },
275 /* SupraExpress 33.6 Data/Fax PnP modem */ 277 /* SupraExpress 33.6 Data/Fax PnP modem */
276 { "SUP1760", 0 }, 278 { "SUP1760", 0 },
279 /* SupraExpress 56i Sp Intl */
280 { "SUP2171", 0 },
277 /* Phoebe Micro */ 281 /* Phoebe Micro */
278 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */ 282 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
279 { "TEX0011", 0 }, 283 { "TEX0011", 0 },
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 78c1f36ad9b7..87ef368384fb 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -98,7 +98,7 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re
98{ 98{
99 struct uart_port *port = dev_id; 99 struct uart_port *port = dev_id;
100 struct tty_struct *tty = port->info->tty; 100 struct tty_struct *tty = port->info->tty;
101 unsigned int status, ch, flg, ignored = 0; 101 unsigned int status, ch, flg;
102 102
103 status = clps_readl(SYSFLG(port)); 103 status = clps_readl(SYSFLG(port));
104 while (!(status & SYSFLG_URXFE)) { 104 while (!(status & SYSFLG_URXFE)) {
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 4c985e6b3784..bdb4e454b8b0 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -73,7 +73,7 @@ struct imx_port {
73 struct uart_port port; 73 struct uart_port port;
74 struct timer_list timer; 74 struct timer_list timer;
75 unsigned int old_status; 75 unsigned int old_status;
76 int txirq,rxirq; 76 int txirq,rxirq,rtsirq;
77}; 77};
78 78
79/* 79/*
@@ -181,6 +181,22 @@ static void imx_start_tx(struct uart_port *port)
181 imx_transmit_buffer(sport); 181 imx_transmit_buffer(sport);
182} 182}
183 183
184static irqreturn_t imx_rtsint(int irq, void *dev_id, struct pt_regs *regs)
185{
186 struct imx_port *sport = (struct imx_port *)dev_id;
187 unsigned int val = USR1((u32)sport->port.membase)&USR1_RTSS;
188 unsigned long flags;
189
190 spin_lock_irqsave(&sport->port.lock, flags);
191
192 USR1((u32)sport->port.membase) = USR1_RTSD;
193 uart_handle_cts_change(&sport->port, !!val);
194 wake_up_interruptible(&sport->port.info->delta_msr_wait);
195
196 spin_unlock_irqrestore(&sport->port.lock, flags);
197 return IRQ_HANDLED;
198}
199
184static irqreturn_t imx_txint(int irq, void *dev_id, struct pt_regs *regs) 200static irqreturn_t imx_txint(int irq, void *dev_id, struct pt_regs *regs)
185{ 201{
186 struct imx_port *sport = (struct imx_port *)dev_id; 202 struct imx_port *sport = (struct imx_port *)dev_id;
@@ -383,18 +399,24 @@ static int imx_startup(struct uart_port *port)
383 */ 399 */
384 retval = request_irq(sport->rxirq, imx_rxint, 0, 400 retval = request_irq(sport->rxirq, imx_rxint, 0,
385 DRIVER_NAME, sport); 401 DRIVER_NAME, sport);
386 if (retval) goto error_out2; 402 if (retval) goto error_out1;
387 403
388 retval = request_irq(sport->txirq, imx_txint, 0, 404 retval = request_irq(sport->txirq, imx_txint, 0,
389 "imx-uart", sport); 405 DRIVER_NAME, sport);
390 if (retval) goto error_out1; 406 if (retval) goto error_out2;
407
408 retval = request_irq(sport->rtsirq, imx_rtsint, 0,
409 DRIVER_NAME, sport);
410 if (retval) goto error_out3;
411 set_irq_type(sport->rtsirq, IRQT_BOTHEDGE);
391 412
392 /* 413 /*
393 * Finally, clear and enable interrupts 414 * Finally, clear and enable interrupts
394 */ 415 */
395 416
417 USR1((u32)sport->port.membase) = USR1_RTSD;
396 UCR1((u32)sport->port.membase) |= 418 UCR1((u32)sport->port.membase) |=
397 (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_UARTEN); 419 (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
398 420
399 UCR2((u32)sport->port.membase) |= (UCR2_RXEN | UCR2_TXEN); 421 UCR2((u32)sport->port.membase) |= (UCR2_RXEN | UCR2_TXEN);
400 /* 422 /*
@@ -406,10 +428,11 @@ static int imx_startup(struct uart_port *port)
406 428
407 return 0; 429 return 0;
408 430
409error_out1: 431error_out3:
410 free_irq(sport->rxirq, sport);
411error_out2:
412 free_irq(sport->txirq, sport); 432 free_irq(sport->txirq, sport);
433error_out2:
434 free_irq(sport->rxirq, sport);
435error_out1:
413 return retval; 436 return retval;
414} 437}
415 438
@@ -425,6 +448,7 @@ static void imx_shutdown(struct uart_port *port)
425 /* 448 /*
426 * Free the interrupts 449 * Free the interrupts
427 */ 450 */
451 free_irq(sport->rtsirq, sport);
428 free_irq(sport->txirq, sport); 452 free_irq(sport->txirq, sport);
429 free_irq(sport->rxirq, sport); 453 free_irq(sport->rxirq, sport);
430 454
@@ -433,7 +457,7 @@ static void imx_shutdown(struct uart_port *port)
433 */ 457 */
434 458
435 UCR1((u32)sport->port.membase) &= 459 UCR1((u32)sport->port.membase) &=
436 ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_UARTEN); 460 ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
437} 461}
438 462
439static void 463static void
@@ -523,7 +547,7 @@ imx_set_termios(struct uart_port *port, struct termios *termios,
523 * disable interrupts and drain transmitter 547 * disable interrupts and drain transmitter
524 */ 548 */
525 old_ucr1 = UCR1((u32)sport->port.membase); 549 old_ucr1 = UCR1((u32)sport->port.membase);
526 UCR1((u32)sport->port.membase) &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN); 550 UCR1((u32)sport->port.membase) &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN);
527 551
528 while ( !(USR2((u32)sport->port.membase) & USR2_TXDC)) 552 while ( !(USR2((u32)sport->port.membase) & USR2_TXDC))
529 barrier(); 553 barrier();
@@ -644,6 +668,7 @@ static struct imx_port imx_ports[] = {
644 { 668 {
645 .txirq = UART1_MINT_TX, 669 .txirq = UART1_MINT_TX,
646 .rxirq = UART1_MINT_RX, 670 .rxirq = UART1_MINT_RX,
671 .rtsirq = UART1_MINT_RTS,
647 .port = { 672 .port = {
648 .type = PORT_IMX, 673 .type = PORT_IMX,
649 .iotype = SERIAL_IO_MEM, 674 .iotype = SERIAL_IO_MEM,
@@ -659,6 +684,7 @@ static struct imx_port imx_ports[] = {
659 }, { 684 }, {
660 .txirq = UART2_MINT_TX, 685 .txirq = UART2_MINT_TX,
661 .rxirq = UART2_MINT_RX, 686 .rxirq = UART2_MINT_RX,
687 .rtsirq = UART2_MINT_RTS,
662 .port = { 688 .port = {
663 .type = PORT_IMX, 689 .type = PORT_IMX,
664 .iotype = SERIAL_IO_MEM, 690 .iotype = SERIAL_IO_MEM,
@@ -738,7 +764,7 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
738 764
739 UCR1((u32)sport->port.membase) = 765 UCR1((u32)sport->port.membase) =
740 (old_ucr1 | UCR1_UARTCLKEN | UCR1_UARTEN) 766 (old_ucr1 | UCR1_UARTCLKEN | UCR1_UARTEN)
741 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN); 767 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN);
742 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN; 768 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN;
743 769
744 /* 770 /*
@@ -860,7 +886,7 @@ imx_console_setup(struct console *co, char *options)
860 return uart_set_options(&sport->port, co, baud, parity, bits, flow); 886 return uart_set_options(&sport->port, co, baud, parity, bits, flow);
861} 887}
862 888
863extern struct uart_driver imx_reg; 889static struct uart_driver imx_reg;
864static struct console imx_console = { 890static struct console imx_console = {
865 .name = "ttySMX", 891 .name = "ttySMX",
866 .write = imx_console_write, 892 .write = imx_console_write,
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 0c5c96a582b3..f88fdd480685 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -973,18 +973,6 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
973 this_ir &= ~this_mir; 973 this_ir &= ~this_mir;
974 } 974 }
975 } 975 }
976 if (this_ir) {
977 printk(KERN_ERR
978 "unknown IOC4 %s interrupt 0x%x, sio_ir = 0x%x,"
979 " sio_ies = 0x%x, other_ir = 0x%x :"
980 "other_ies = 0x%x\n",
981 (intr_type == IOC4_SIO_INTR_TYPE) ? "sio" :
982 "other", this_ir,
983 readl(&soft->is_ioc4_misc_addr->sio_ir.raw),
984 readl(&soft->is_ioc4_misc_addr->sio_ies.raw),
985 readl(&soft->is_ioc4_misc_addr->other_ir.raw),
986 readl(&soft->is_ioc4_misc_addr->other_ies.raw));
987 }
988 } 976 }
989#ifdef DEBUG_INTERRUPTS 977#ifdef DEBUG_INTERRUPTS
990 { 978 {
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index a3cd0ee8486d..0585ab27ffde 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -781,7 +781,7 @@ mpc52xx_uart_remove(struct device *dev)
781 781
782#ifdef CONFIG_PM 782#ifdef CONFIG_PM
783static int 783static int
784mpc52xx_uart_suspend(struct device *dev, u32 state, u32 level) 784mpc52xx_uart_suspend(struct device *dev, pm_message_t state, u32 level)
785{ 785{
786 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); 786 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev);
787 787
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 672b359b07ce..90c2a86c421b 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -499,7 +499,7 @@ serial_pxa_set_termios(struct uart_port *port, struct termios *termios,
499 /* 499 /*
500 * Update the per-port timeout. 500 * Update the per-port timeout.
501 */ 501 */
502 uart_update_timeout(port, termios->c_cflag, quot); 502 uart_update_timeout(port, termios->c_cflag, baud);
503 503
504 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 504 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
505 if (termios->c_iflag & INPCK) 505 if (termios->c_iflag & INPCK)
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index c361c6fb0809..52692aa345ec 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -82,8 +82,6 @@
82#include <asm/arch/regs-serial.h> 82#include <asm/arch/regs-serial.h>
83#include <asm/arch/regs-gpio.h> 83#include <asm/arch/regs-gpio.h>
84 84
85#include <asm/mach-types.h>
86
87/* structures */ 85/* structures */
88 86
89struct s3c24xx_uart_info { 87struct s3c24xx_uart_info {
@@ -753,8 +751,8 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
753{ 751{
754 struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port); 752 struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
755 struct s3c24xx_uart_port *ourport = to_ourport(port); 753 struct s3c24xx_uart_port *ourport = to_ourport(port);
756 struct s3c24xx_uart_clksrc *clksrc; 754 struct s3c24xx_uart_clksrc *clksrc = NULL;
757 struct clk *clk; 755 struct clk *clk = NULL;
758 unsigned long flags; 756 unsigned long flags;
759 unsigned int baud, quot; 757 unsigned int baud, quot;
760 unsigned int ulcon; 758 unsigned int ulcon;
@@ -1094,8 +1092,8 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1094 1092
1095static int probe_index = 0; 1093static int probe_index = 0;
1096 1094
1097int s3c24xx_serial_probe(struct device *_dev, 1095static int s3c24xx_serial_probe(struct device *_dev,
1098 struct s3c24xx_uart_info *info) 1096 struct s3c24xx_uart_info *info)
1099{ 1097{
1100 struct s3c24xx_uart_port *ourport; 1098 struct s3c24xx_uart_port *ourport;
1101 struct platform_device *dev = to_platform_device(_dev); 1099 struct platform_device *dev = to_platform_device(_dev);
@@ -1122,7 +1120,7 @@ int s3c24xx_serial_probe(struct device *_dev,
1122 return ret; 1120 return ret;
1123} 1121}
1124 1122
1125int s3c24xx_serial_remove(struct device *_dev) 1123static int s3c24xx_serial_remove(struct device *_dev)
1126{ 1124{
1127 struct uart_port *port = s3c24xx_dev_to_port(_dev); 1125 struct uart_port *port = s3c24xx_dev_to_port(_dev);
1128 1126
@@ -1136,7 +1134,8 @@ int s3c24xx_serial_remove(struct device *_dev)
1136 1134
1137#ifdef CONFIG_PM 1135#ifdef CONFIG_PM
1138 1136
1139int s3c24xx_serial_suspend(struct device *dev, pm_message_t state, u32 level) 1137static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state,
1138 u32 level)
1140{ 1139{
1141 struct uart_port *port = s3c24xx_dev_to_port(dev); 1140 struct uart_port *port = s3c24xx_dev_to_port(dev);
1142 1141
@@ -1146,7 +1145,7 @@ int s3c24xx_serial_suspend(struct device *dev, pm_message_t state, u32 level)
1146 return 0; 1145 return 0;
1147} 1146}
1148 1147
1149int s3c24xx_serial_resume(struct device *dev, u32 level) 1148static int s3c24xx_serial_resume(struct device *dev, u32 level)
1150{ 1149{
1151 struct uart_port *port = s3c24xx_dev_to_port(dev); 1150 struct uart_port *port = s3c24xx_dev_to_port(dev);
1152 struct s3c24xx_uart_port *ourport = to_ourport(port); 1151 struct s3c24xx_uart_port *ourport = to_ourport(port);
@@ -1167,8 +1166,8 @@ int s3c24xx_serial_resume(struct device *dev, u32 level)
1167#define s3c24xx_serial_resume NULL 1166#define s3c24xx_serial_resume NULL
1168#endif 1167#endif
1169 1168
1170int s3c24xx_serial_init(struct device_driver *drv, 1169static int s3c24xx_serial_init(struct device_driver *drv,
1171 struct s3c24xx_uart_info *info) 1170 struct s3c24xx_uart_info *info)
1172{ 1171{
1173 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info); 1172 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info);
1174 return driver_register(drv); 1173 return driver_register(drv);
@@ -1237,6 +1236,7 @@ static int s3c2400_serial_probe(struct device *dev)
1237 1236
1238static struct device_driver s3c2400_serial_drv = { 1237static struct device_driver s3c2400_serial_drv = {
1239 .name = "s3c2400-uart", 1238 .name = "s3c2400-uart",
1239 .owner = THIS_MODULE,
1240 .bus = &platform_bus_type, 1240 .bus = &platform_bus_type,
1241 .probe = s3c2400_serial_probe, 1241 .probe = s3c2400_serial_probe,
1242 .remove = s3c24xx_serial_remove, 1242 .remove = s3c24xx_serial_remove,
@@ -1340,6 +1340,7 @@ static int s3c2410_serial_probe(struct device *dev)
1340 1340
1341static struct device_driver s3c2410_serial_drv = { 1341static struct device_driver s3c2410_serial_drv = {
1342 .name = "s3c2410-uart", 1342 .name = "s3c2410-uart",
1343 .owner = THIS_MODULE,
1343 .bus = &platform_bus_type, 1344 .bus = &platform_bus_type,
1344 .probe = s3c2410_serial_probe, 1345 .probe = s3c2410_serial_probe,
1345 .remove = s3c24xx_serial_remove, 1346 .remove = s3c24xx_serial_remove,
@@ -1501,6 +1502,7 @@ static int s3c2440_serial_probe(struct device *dev)
1501 1502
1502static struct device_driver s3c2440_serial_drv = { 1503static struct device_driver s3c2440_serial_drv = {
1503 .name = "s3c2440-uart", 1504 .name = "s3c2440-uart",
1505 .owner = THIS_MODULE,
1504 .bus = &platform_bus_type, 1506 .bus = &platform_bus_type,
1505 .probe = s3c2440_serial_probe, 1507 .probe = s3c2440_serial_probe,
1506 .remove = s3c24xx_serial_remove, 1508 .remove = s3c24xx_serial_remove,
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 1ae0b381c162..2c7d3ef76e8e 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -859,6 +859,7 @@ static struct pcmcia_device_id serial_ids[] = {
859 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0175, 0x0000, "DP83903.cis"), 859 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0175, 0x0000, "DP83903.cis"),
860 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"), 860 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"),
861 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"), 861 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"),
862 PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */
862 PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), 863 PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"),
863 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), 864 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"),
864 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), 865 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 512266307866..430754ebac8a 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -967,7 +967,7 @@ static int sci_startup(struct uart_port *port)
967#endif 967#endif
968 968
969 sci_request_irq(s); 969 sci_request_irq(s);
970 sci_start_tx(port, 1); 970 sci_start_tx(port);
971 sci_start_rx(port, 1); 971 sci_start_rx(port, 1);
972 972
973 return 0; 973 return 0;
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index e971156daa60..ba9381fd3f2d 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -274,7 +274,6 @@ static void transmit_chars(struct uart_sunsab_port *up,
274 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) { 274 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
275 up->interrupt_mask1 |= SAB82532_IMR1_XPR; 275 up->interrupt_mask1 |= SAB82532_IMR1_XPR;
276 writeb(up->interrupt_mask1, &up->regs->w.imr1); 276 writeb(up->interrupt_mask1, &up->regs->w.imr1);
277 uart_write_wakeup(&up->port);
278 return; 277 return;
279 } 278 }
280 279
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 5959e6755a81..656c0e8d160e 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -518,11 +518,7 @@ static void sunsu_change_mouse_baud(struct uart_sunsu_port *up)
518 518
519 quot = up->port.uartclk / (16 * new_baud); 519 quot = up->port.uartclk / (16 * new_baud);
520 520
521 spin_unlock(&up->port.lock);
522
523 sunsu_change_speed(&up->port, up->cflag, 0, quot); 521 sunsu_change_speed(&up->port, up->cflag, 0, quot);
524
525 spin_lock(&up->port.lock);
526} 522}
527 523
528static void receive_kbd_ms_chars(struct uart_sunsu_port *up, struct pt_regs *regs, int is_break) 524static void receive_kbd_ms_chars(struct uart_sunsu_port *up, struct pt_regs *regs, int is_break)
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index d75445738c88..7653d6cf05af 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -517,10 +517,9 @@ static void sunzilog_transmit_chars(struct uart_sunzilog_port *up,
517 if (up->port.info == NULL) 517 if (up->port.info == NULL)
518 goto ack_tx_int; 518 goto ack_tx_int;
519 xmit = &up->port.info->xmit; 519 xmit = &up->port.info->xmit;
520 if (uart_circ_empty(xmit)) { 520 if (uart_circ_empty(xmit))
521 uart_write_wakeup(&up->port);
522 goto ack_tx_int; 521 goto ack_tx_int;
523 } 522
524 if (uart_tx_stopped(&up->port)) 523 if (uart_tx_stopped(&up->port))
525 goto ack_tx_int; 524 goto ack_tx_int;
526 525
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index b4265aa7d45e..487ff672b104 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -30,6 +30,8 @@
30 * Revision history 30 * Revision history
31 * 22.12.1999 0.1 Initial release (split from proc_usb.c) 31 * 22.12.1999 0.1 Initial release (split from proc_usb.c)
32 * 04.01.2000 0.2 Turned into its own filesystem 32 * 04.01.2000 0.2 Turned into its own filesystem
33 * 30.09.2005 0.3 Fix user-triggerable oops in async URB delivery
34 * (CAN-2005-3055)
33 */ 35 */
34 36
35/*****************************************************************************/ 37/*****************************************************************************/
@@ -58,7 +60,8 @@ static struct class *usb_device_class;
58struct async { 60struct async {
59 struct list_head asynclist; 61 struct list_head asynclist;
60 struct dev_state *ps; 62 struct dev_state *ps;
61 struct task_struct *task; 63 pid_t pid;
64 uid_t uid, euid;
62 unsigned int signr; 65 unsigned int signr;
63 unsigned int ifnum; 66 unsigned int ifnum;
64 void __user *userbuffer; 67 void __user *userbuffer;
@@ -290,7 +293,8 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
290 sinfo.si_errno = as->urb->status; 293 sinfo.si_errno = as->urb->status;
291 sinfo.si_code = SI_ASYNCIO; 294 sinfo.si_code = SI_ASYNCIO;
292 sinfo.si_addr = as->userurb; 295 sinfo.si_addr = as->userurb;
293 send_sig_info(as->signr, &sinfo, as->task); 296 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
297 as->euid);
294 } 298 }
295 wake_up(&ps->wait); 299 wake_up(&ps->wait);
296} 300}
@@ -526,7 +530,9 @@ static int usbdev_open(struct inode *inode, struct file *file)
526 INIT_LIST_HEAD(&ps->async_completed); 530 INIT_LIST_HEAD(&ps->async_completed);
527 init_waitqueue_head(&ps->wait); 531 init_waitqueue_head(&ps->wait);
528 ps->discsignr = 0; 532 ps->discsignr = 0;
529 ps->disctask = current; 533 ps->disc_pid = current->pid;
534 ps->disc_uid = current->uid;
535 ps->disc_euid = current->euid;
530 ps->disccontext = NULL; 536 ps->disccontext = NULL;
531 ps->ifclaimed = 0; 537 ps->ifclaimed = 0;
532 wmb(); 538 wmb();
@@ -988,7 +994,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
988 as->userbuffer = NULL; 994 as->userbuffer = NULL;
989 as->signr = uurb->signr; 995 as->signr = uurb->signr;
990 as->ifnum = ifnum; 996 as->ifnum = ifnum;
991 as->task = current; 997 as->pid = current->pid;
998 as->uid = current->uid;
999 as->euid = current->euid;
992 if (!(uurb->endpoint & USB_DIR_IN)) { 1000 if (!(uurb->endpoint & USB_DIR_IN)) {
993 if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) { 1001 if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) {
994 free_async(as); 1002 free_async(as);
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index cbb451d227d2..6385d1a99b60 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -242,7 +242,6 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
242 case HC_STATE_SUSPENDED: 242 case HC_STATE_SUSPENDED:
243 /* no DMA or IRQs except when HC is active */ 243 /* no DMA or IRQs except when HC is active */
244 if (dev->current_state == PCI_D0) { 244 if (dev->current_state == PCI_D0) {
245 free_irq (hcd->irq, hcd);
246 pci_save_state (dev); 245 pci_save_state (dev);
247 pci_disable_device (dev); 246 pci_disable_device (dev);
248 } 247 }
@@ -374,14 +373,6 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
374 373
375 hcd->state = HC_STATE_RESUMING; 374 hcd->state = HC_STATE_RESUMING;
376 hcd->saw_irq = 0; 375 hcd->saw_irq = 0;
377 retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ,
378 hcd->irq_descr, hcd);
379 if (retval < 0) {
380 dev_err (hcd->self.controller,
381 "can't restore IRQ after resume!\n");
382 usb_hc_died (hcd);
383 return retval;
384 }
385 376
386 retval = hcd->driver->resume (hcd); 377 retval = hcd->driver->resume (hcd);
387 if (!HC_IS_RUNNING (hcd->state)) { 378 if (!HC_IS_RUNNING (hcd->state)) {
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 640f41e47029..d07bba01995b 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -713,7 +713,7 @@ void usbfs_remove_device(struct usb_device *dev)
713 sinfo.si_errno = EPIPE; 713 sinfo.si_errno = EPIPE;
714 sinfo.si_code = SI_ASYNCIO; 714 sinfo.si_code = SI_ASYNCIO;
715 sinfo.si_addr = ds->disccontext; 715 sinfo.si_addr = ds->disccontext;
716 send_sig_info(ds->discsignr, &sinfo, ds->disctask); 716 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid);
717 } 717 }
718 } 718 }
719 usbfs_update_special(); 719 usbfs_update_special();
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index c47c8052b486..f1fb67fe22a8 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -987,7 +987,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
987 987
988 /* remove this interface if it has been registered */ 988 /* remove this interface if it has been registered */
989 interface = dev->actconfig->interface[i]; 989 interface = dev->actconfig->interface[i];
990 if (!klist_node_attached(&interface->dev.knode_bus)) 990 if (!device_is_registered(&interface->dev))
991 continue; 991 continue;
992 dev_dbg (&dev->dev, "unregistering interface %s\n", 992 dev_dbg (&dev->dev, "unregistering interface %s\n",
993 interface->dev.bus_id); 993 interface->dev.bus_id);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 087af73a59dd..7d131509e419 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -303,7 +303,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
303 /* if interface was already added, bind now; else let 303 /* if interface was already added, bind now; else let
304 * the future device_add() bind it, bypassing probe() 304 * the future device_add() bind it, bypassing probe()
305 */ 305 */
306 if (klist_node_attached(&dev->knode_bus)) 306 if (device_is_registered(dev))
307 device_bind_driver(dev); 307 device_bind_driver(dev);
308 308
309 return 0; 309 return 0;
@@ -336,8 +336,8 @@ void usb_driver_release_interface(struct usb_driver *driver,
336 if (iface->condition != USB_INTERFACE_BOUND) 336 if (iface->condition != USB_INTERFACE_BOUND)
337 return; 337 return;
338 338
339 /* release only after device_add() */ 339 /* don't release if the interface hasn't been added yet */
340 if (klist_node_attached(&dev->knode_bus)) { 340 if (device_is_registered(dev)) {
341 iface->condition = USB_INTERFACE_UNBINDING; 341 iface->condition = USB_INTERFACE_UNBINDING;
342 device_release_driver(dev); 342 device_release_driver(dev);
343 } 343 }
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 83d48c8133af..e6504f3370ad 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -52,7 +52,8 @@ struct dev_state {
52 struct list_head async_completed; 52 struct list_head async_completed;
53 wait_queue_head_t wait; /* wake up if a request completed */ 53 wait_queue_head_t wait; /* wake up if a request completed */
54 unsigned int discsignr; 54 unsigned int discsignr;
55 struct task_struct *disctask; 55 pid_t disc_pid;
56 uid_t disc_uid, disc_euid;
56 void __user *disccontext; 57 void __user *disccontext;
57 unsigned long ifclaimed; 58 unsigned long ifclaimed;
58}; 59};
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 1507738337c4..73f8c9404156 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -422,7 +422,7 @@ static inline void ep0_idle (struct pxa2xx_udc *dev)
422} 422}
423 423
424static int 424static int
425write_packet(volatile u32 *uddr, struct pxa2xx_request *req, unsigned max) 425write_packet(volatile unsigned long *uddr, struct pxa2xx_request *req, unsigned max)
426{ 426{
427 u8 *buf; 427 u8 *buf;
428 unsigned length, count; 428 unsigned length, count;
@@ -2602,7 +2602,7 @@ static int __exit pxa2xx_udc_remove(struct device *_dev)
2602 * VBUS IRQs should probably be ignored so that the PXA device just acts 2602 * VBUS IRQs should probably be ignored so that the PXA device just acts
2603 * "dead" to USB hosts until system resume. 2603 * "dead" to USB hosts until system resume.
2604 */ 2604 */
2605static int pxa2xx_udc_suspend(struct device *dev, u32 state, u32 level) 2605static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state, u32 level)
2606{ 2606{
2607 struct pxa2xx_udc *udc = dev_get_drvdata(dev); 2607 struct pxa2xx_udc *udc = dev_get_drvdata(dev);
2608 2608
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h
index d0bc396a85d5..a58f3e6e71f1 100644
--- a/drivers/usb/gadget/pxa2xx_udc.h
+++ b/drivers/usb/gadget/pxa2xx_udc.h
@@ -69,11 +69,11 @@ struct pxa2xx_ep {
69 * UDDR = UDC Endpoint Data Register (the fifo) 69 * UDDR = UDC Endpoint Data Register (the fifo)
70 * DRCM = DMA Request Channel Map 70 * DRCM = DMA Request Channel Map
71 */ 71 */
72 volatile u32 *reg_udccs; 72 volatile unsigned long *reg_udccs;
73 volatile u32 *reg_ubcr; 73 volatile unsigned long *reg_ubcr;
74 volatile u32 *reg_uddr; 74 volatile unsigned long *reg_uddr;
75#ifdef USE_DMA 75#ifdef USE_DMA
76 volatile u32 *reg_drcmr; 76 volatile unsigned long *reg_drcmr;
77#define drcmr(n) .reg_drcmr = & DRCMR ## n , 77#define drcmr(n) .reg_drcmr = & DRCMR ## n ,
78#else 78#else
79#define drcmr(n) 79#define drcmr(n)
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 41bbae83fc71..e142056b0d2c 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -326,7 +326,8 @@ static void postproc_atl_queue(struct isp116x *isp116x)
326 usb_settoggle(udev, ep->epnum, 326 usb_settoggle(udev, ep->epnum,
327 ep->nextpid == 327 ep->nextpid ==
328 USB_PID_OUT, 328 USB_PID_OUT,
329 PTD_GET_TOGGLE(ptd) ^ 1); 329 PTD_GET_TOGGLE(ptd));
330 urb->actual_length += PTD_GET_COUNT(ptd);
330 urb->status = cc_to_error[TD_DATAUNDERRUN]; 331 urb->status = cc_to_error[TD_DATAUNDERRUN];
331 spin_unlock(&urb->lock); 332 spin_unlock(&urb->lock);
332 continue; 333 continue;
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index 817620d73841..859aca7be753 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -17,8 +17,6 @@
17 */ 17 */
18 18
19#include <asm/hardware.h> 19#include <asm/hardware.h>
20#include <asm/mach-types.h>
21#include <asm/arch/hardware.h>
22 20
23 21
24extern int usb_disabled(void); 22extern int usb_disabled(void);
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 5cde76faab93..d8f3ba7ad52e 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -18,7 +18,6 @@
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/mach-types.h> 19#include <asm/mach-types.h>
20 20
21#include <asm/arch/hardware.h>
22#include <asm/arch/mux.h> 21#include <asm/arch/mux.h>
23#include <asm/arch/irqs.h> 22#include <asm/arch/irqs.h>
24#include <asm/arch/gpio.h> 23#include <asm/arch/gpio.h>
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 3d9bcf78a9a4..da7d5478f74d 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -20,7 +20,6 @@
20*/ 20*/
21 21
22#include <asm/hardware.h> 22#include <asm/hardware.h>
23#include <asm/mach-types.h>
24#include <asm/hardware/clock.h> 23#include <asm/hardware/clock.h>
25#include <asm/arch/usb-control.h> 24#include <asm/arch/usb-control.h>
26 25
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index d2a1fd40dfcb..d42a15d10a46 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -782,6 +782,9 @@ retry:
782/* usb 1.1 says max 90% of a frame is available for periodic transfers. 782/* usb 1.1 says max 90% of a frame is available for periodic transfers.
783 * this driver doesn't promise that much since it's got to handle an 783 * this driver doesn't promise that much since it's got to handle an
784 * IRQ per packet; irq handling latencies also use up that time. 784 * IRQ per packet; irq handling latencies also use up that time.
785 *
786 * NOTE: the periodic schedule is a sparse tree, with the load for
787 * each branch minimized. see fig 3.5 in the OHCI spec for example.
785 */ 788 */
786#define MAX_PERIODIC_LOAD 500 /* out of 1000 usec */ 789#define MAX_PERIODIC_LOAD 500 /* out of 1000 usec */
787 790
@@ -843,6 +846,7 @@ static int sl811h_urb_enqueue(
843 if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE)) 846 if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE))
844 || !HC_IS_RUNNING(hcd->state)) { 847 || !HC_IS_RUNNING(hcd->state)) {
845 retval = -ENODEV; 848 retval = -ENODEV;
849 kfree(ep);
846 goto fail; 850 goto fail;
847 } 851 }
848 852
@@ -911,8 +915,16 @@ static int sl811h_urb_enqueue(
911 case PIPE_ISOCHRONOUS: 915 case PIPE_ISOCHRONOUS:
912 case PIPE_INTERRUPT: 916 case PIPE_INTERRUPT:
913 urb->interval = ep->period; 917 urb->interval = ep->period;
914 if (ep->branch < PERIODIC_SIZE) 918 if (ep->branch < PERIODIC_SIZE) {
919 /* NOTE: the phase is correct here, but the value
920 * needs offsetting by the transfer queue depth.
921 * All current drivers ignore start_frame, so this
922 * is unlikely to ever matter...
923 */
924 urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
925 + ep->branch;
915 break; 926 break;
927 }
916 928
917 retval = balance(sl811, ep->period, ep->load); 929 retval = balance(sl811, ep->period, ep->load);
918 if (retval < 0) 930 if (retval < 0)
@@ -1122,7 +1134,7 @@ sl811h_hub_descriptor (
1122 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp); 1134 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
1123 1135
1124 /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */ 1136 /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */
1125 desc->bitmap[0] = 1 << 1; 1137 desc->bitmap[0] = 0 << 1;
1126 desc->bitmap[1] = ~0; 1138 desc->bitmap[1] = ~0;
1127} 1139}
1128 1140
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index a99865c689c5..41f92b924761 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1702,10 +1702,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1702 if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ 1702 if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */
1703 continue; 1703 continue;
1704 1704
1705 /* handle potential highspeed HID correctly */
1706 interval = endpoint->bInterval; 1705 interval = endpoint->bInterval;
1707 if (dev->speed == USB_SPEED_HIGH)
1708 interval = 1 << (interval - 1);
1709 1706
1710 /* Change the polling interval of mice. */ 1707 /* Change the polling interval of mice. */
1711 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) 1708 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
index 4a5857c53f11..0bc0b1247a6b 100644
--- a/drivers/usb/media/vicam.c
+++ b/drivers/usb/media/vicam.c
@@ -1148,7 +1148,7 @@ vicam_write_proc_gain(struct file *file, const char *buffer,
1148static void 1148static void
1149vicam_create_proc_root(void) 1149vicam_create_proc_root(void)
1150{ 1150{
1151 vicam_proc_root = create_proc_entry("video/vicam", S_IFDIR, 0); 1151 vicam_proc_root = proc_mkdir("video/vicam", NULL);
1152 1152
1153 if (vicam_proc_root) 1153 if (vicam_proc_root)
1154 vicam_proc_root->owner = THIS_MODULE; 1154 vicam_proc_root->owner = THIS_MODULE;
@@ -1181,7 +1181,7 @@ vicam_create_proc_entry(struct vicam_camera *cam)
1181 1181
1182 sprintf(name, "video%d", cam->vdev.minor); 1182 sprintf(name, "video%d", cam->vdev.minor);
1183 1183
1184 cam->proc_dir = create_proc_entry(name, S_IFDIR, vicam_proc_root); 1184 cam->proc_dir = proc_mkdir(name, vicam_proc_root);
1185 1185
1186 if ( !cam->proc_dir ) 1186 if ( !cam->proc_dir )
1187 return; // FIXME: We should probably return an error here 1187 return; // FIXME: We should probably return an error here
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 7484d34780fc..6a4ffe6c3977 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -648,6 +648,13 @@ static void read_bulk_callback(struct urb *urb, struct pt_regs *regs)
648 } 648 }
649 649
650 /* 650 /*
651 * If the packet is unreasonably long, quietly drop it rather than
652 * kernel panicing by calling skb_put.
653 */
654 if (pkt_len > PEGASUS_MTU)
655 goto goon;
656
657 /*
651 * at this point we are sure pegasus->rx_skb != NULL 658 * at this point we are sure pegasus->rx_skb != NULL
652 * so we go ahead and pass up the packet. 659 * so we go ahead and pass up the packet.
653 */ 660 */
@@ -886,15 +893,17 @@ static inline void get_interrupt_interval(pegasus_t * pegasus)
886 __u8 data[2]; 893 __u8 data[2];
887 894
888 read_eprom_word(pegasus, 4, (__u16 *) data); 895 read_eprom_word(pegasus, 4, (__u16 *) data);
889 if (data[1] < 0x80) { 896 if (pegasus->usb->speed != USB_SPEED_HIGH) {
890 if (netif_msg_timer(pegasus)) 897 if (data[1] < 0x80) {
891 dev_info(&pegasus->intf->dev, 898 if (netif_msg_timer(pegasus))
892 "intr interval changed from %ums to %ums\n", 899 dev_info(&pegasus->intf->dev, "intr interval "
893 data[1], 0x80); 900 "changed from %ums to %ums\n",
894 data[1] = 0x80; 901 data[1], 0x80);
895#ifdef PEGASUS_WRITE_EEPROM 902 data[1] = 0x80;
896 write_eprom_word(pegasus, 4, *(__u16 *) data); 903#ifdef PEGASUS_WRITE_EEPROM
904 write_eprom_word(pegasus, 4, *(__u16 *) data);
897#endif 905#endif
906 }
898 } 907 }
899 pegasus->intr_interval = data[1]; 908 pegasus->intr_interval = data[1];
900} 909}
@@ -904,8 +913,9 @@ static void set_carrier(struct net_device *net)
904 pegasus_t *pegasus = netdev_priv(net); 913 pegasus_t *pegasus = netdev_priv(net);
905 u16 tmp; 914 u16 tmp;
906 915
907 if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp)) 916 if (!read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp))
908 return; 917 return;
918
909 if (tmp & BMSR_LSTATUS) 919 if (tmp & BMSR_LSTATUS)
910 netif_carrier_on(net); 920 netif_carrier_on(net);
911 else 921 else
@@ -1355,6 +1365,7 @@ static void pegasus_disconnect(struct usb_interface *intf)
1355 cancel_delayed_work(&pegasus->carrier_check); 1365 cancel_delayed_work(&pegasus->carrier_check);
1356 unregister_netdev(pegasus->net); 1366 unregister_netdev(pegasus->net);
1357 usb_put_dev(interface_to_usbdev(intf)); 1367 usb_put_dev(interface_to_usbdev(intf));
1368 unlink_all_urbs(pegasus);
1358 free_all_urbs(pegasus); 1369 free_all_urbs(pegasus);
1359 free_skb_pool(pegasus); 1370 free_skb_pool(pegasus);
1360 if (pegasus->rx_skb) 1371 if (pegasus->rx_skb)
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index a4ce0008d69b..926d4c2c1600 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -16,7 +16,8 @@
16#include "usb-serial.h" 16#include "usb-serial.h"
17 17
18static struct usb_device_id id_table [] = { 18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0xf3d, 0x0112) }, 19 { USB_DEVICE(0xf3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */
20 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
20 { }, 21 { },
21}; 22};
22MODULE_DEVICE_TABLE(usb, id_table); 23MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4e434cb10bb1..5a8631c8a4a7 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1846,10 +1846,12 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1846 } else { 1846 } else {
1847 /* set the baudrate determined before */ 1847 /* set the baudrate determined before */
1848 if (change_speed(port)) { 1848 if (change_speed(port)) {
1849 err("%s urb failed to set baurdrate", __FUNCTION__); 1849 err("%s urb failed to set baudrate", __FUNCTION__);
1850 }
1851 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
1852 if ((old_termios->c_cflag & CBAUD) == B0) {
1853 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1850 } 1854 }
1851 /* Ensure RTS and DTR are raised */
1852 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1853 } 1855 }
1854 1856
1855 /* Set flow control */ 1857 /* Set flow control */
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index ddde5fb13f6b..5f7d3193d355 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -223,7 +223,7 @@ int usb_serial_generic_write_room (struct usb_serial_port *port)
223 dbg("%s - port %d", __FUNCTION__, port->number); 223 dbg("%s - port %d", __FUNCTION__, port->number);
224 224
225 if (serial->num_bulk_out) { 225 if (serial->num_bulk_out) {
226 if (port->write_urb_busy) 226 if (!(port->write_urb_busy))
227 room = port->bulk_out_size; 227 room = port->bulk_out_size;
228 } 228 }
229 229
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 92d0f925d053..4989e5740d18 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -25,6 +25,9 @@
25 2005-06-20 v0.4.1 add missing braces :-/ 25 2005-06-20 v0.4.1 add missing braces :-/
26 killed end-of-line whitespace 26 killed end-of-line whitespace
27 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2 27 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2
28 2005-09-10 v0.4.3 added HUAWEI E600 card and Audiovox AirCard
29 2005-09-20 v0.4.4 increased recv buffer size: the card sometimes
30 wants to send >2000 bytes.
28 31
29 Work sponsored by: Sigos GmbH, Germany <info@sigos.de> 32 Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
30 33
@@ -71,15 +74,21 @@ static int option_send_setup(struct usb_serial_port *port);
71 74
72/* Vendor and product IDs */ 75/* Vendor and product IDs */
73#define OPTION_VENDOR_ID 0x0AF0 76#define OPTION_VENDOR_ID 0x0AF0
77#define HUAWEI_VENDOR_ID 0x12D1
78#define AUDIOVOX_VENDOR_ID 0x0F3D
74 79
75#define OPTION_PRODUCT_OLD 0x5000 80#define OPTION_PRODUCT_OLD 0x5000
76#define OPTION_PRODUCT_FUSION 0x6000 81#define OPTION_PRODUCT_FUSION 0x6000
77#define OPTION_PRODUCT_FUSION2 0x6300 82#define OPTION_PRODUCT_FUSION2 0x6300
83#define HUAWEI_PRODUCT_E600 0x1001
84#define AUDIOVOX_PRODUCT_AIRCARD 0x0112
78 85
79static struct usb_device_id option_ids[] = { 86static struct usb_device_id option_ids[] = {
80 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, 87 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) },
81 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) }, 88 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
82 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) }, 89 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
90 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
91 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
83 { } /* Terminating entry */ 92 { } /* Terminating entry */
84}; 93};
85 94
@@ -132,7 +141,7 @@ static int debug;
132 141
133#define N_IN_URB 4 142#define N_IN_URB 4
134#define N_OUT_URB 1 143#define N_OUT_URB 1
135#define IN_BUFLEN 1024 144#define IN_BUFLEN 4096
136#define OUT_BUFLEN 128 145#define OUT_BUFLEN 128
137 146
138struct option_port_private { 147struct option_port_private {
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 31ee13eef7af..1cd942abb580 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -650,6 +650,7 @@ config FB_NVIDIA
650 select FB_CFB_FILLRECT 650 select FB_CFB_FILLRECT
651 select FB_CFB_COPYAREA 651 select FB_CFB_COPYAREA
652 select FB_CFB_IMAGEBLIT 652 select FB_CFB_IMAGEBLIT
653 select FB_SOFT_CURSOR
653 help 654 help
654 This driver supports graphics boards with the nVidia chips, TNT 655 This driver supports graphics boards with the nVidia chips, TNT
655 and newer. For very old chipsets, such as the RIVA128, then use 656 and newer. For very old chipsets, such as the RIVA128, then use
@@ -767,6 +768,7 @@ config FB_INTEL
767 select FB_CFB_FILLRECT 768 select FB_CFB_FILLRECT
768 select FB_CFB_COPYAREA 769 select FB_CFB_COPYAREA
769 select FB_CFB_IMAGEBLIT 770 select FB_CFB_IMAGEBLIT
771 select FB_SOFT_CURSOR
770 help 772 help
771 This driver supports the on-board graphics built in to the Intel 773 This driver supports the on-board graphics built in to the Intel
772 830M/845G/852GM/855GM/865G chipsets. 774 830M/845G/852GM/855GM/865G chipsets.
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 046b47860266..8a24a66d9ba8 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -475,7 +475,7 @@ static int __devinit radeon_probe_pll_params(struct radeonfb_info *rinfo)
475 */ 475 */
476 476
477 /* Flush PCI buffers ? */ 477 /* Flush PCI buffers ? */
478 tmp = INREG(DEVICE_ID); 478 tmp = INREG16(DEVICE_ID);
479 479
480 local_irq_disable(); 480 local_irq_disable();
481 481
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 59a1b6f85067..097d668c4fe5 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -62,9 +62,9 @@ static void radeon_pm_disable_dynamic_mode(struct radeonfb_info *rinfo)
62 OUTPLL(pllSCLK_CNTL, tmp); 62 OUTPLL(pllSCLK_CNTL, tmp);
63 return; 63 return;
64 } 64 }
65 /* RV350 (M10) */ 65 /* RV350 (M10/M11) */
66 if (rinfo->family == CHIP_FAMILY_RV350) { 66 if (rinfo->family == CHIP_FAMILY_RV350) {
67 /* for RV350/M10, no delays are required. */ 67 /* for RV350/M10/M11, no delays are required. */
68 tmp = INPLL(pllSCLK_CNTL2); 68 tmp = INPLL(pllSCLK_CNTL2);
69 tmp |= (SCLK_CNTL2__R300_FORCE_TCL | 69 tmp |= (SCLK_CNTL2__R300_FORCE_TCL |
70 SCLK_CNTL2__R300_FORCE_GA | 70 SCLK_CNTL2__R300_FORCE_GA |
@@ -248,7 +248,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
248 return; 248 return;
249 } 249 }
250 250
251 /* M10 */ 251 /* M10/M11 */
252 if (rinfo->family == CHIP_FAMILY_RV350) { 252 if (rinfo->family == CHIP_FAMILY_RV350) {
253 tmp = INPLL(pllSCLK_CNTL2); 253 tmp = INPLL(pllSCLK_CNTL2);
254 tmp &= ~(SCLK_CNTL2__R300_FORCE_TCL | 254 tmp &= ~(SCLK_CNTL2__R300_FORCE_TCL |
@@ -1155,7 +1155,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
1155 OUTREG( CRTC_GEN_CNTL, (crtcGenCntl | CRTC_GEN_CNTL__CRTC_DISP_REQ_EN_B) ); 1155 OUTREG( CRTC_GEN_CNTL, (crtcGenCntl | CRTC_GEN_CNTL__CRTC_DISP_REQ_EN_B) );
1156 OUTREG( CRTC2_GEN_CNTL, (crtcGenCntl2 | CRTC2_GEN_CNTL__CRTC2_DISP_REQ_EN_B) ); 1156 OUTREG( CRTC2_GEN_CNTL, (crtcGenCntl2 | CRTC2_GEN_CNTL__CRTC2_DISP_REQ_EN_B) );
1157 1157
1158 /* This is the code for the Aluminium PowerBooks M10 */ 1158 /* This is the code for the Aluminium PowerBooks M10 / iBooks M11 */
1159 if (rinfo->family == CHIP_FAMILY_RV350) { 1159 if (rinfo->family == CHIP_FAMILY_RV350) {
1160 u32 sdram_mode_reg = rinfo->save_regs[35]; 1160 u32 sdram_mode_reg = rinfo->save_regs[35];
1161 static u32 default_mrtable[] = 1161 static u32 default_mrtable[] =
@@ -2741,9 +2741,11 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk)
2741 rinfo->pm_mode |= radeon_pm_d2; 2741 rinfo->pm_mode |= radeon_pm_d2;
2742 2742
2743 /* We can restart Jasper (M10 chip in albooks), BlueStone (7500 chip 2743 /* We can restart Jasper (M10 chip in albooks), BlueStone (7500 chip
2744 * in some desktop G4s), and Via (M9+ chip on iBook G4) 2744 * in some desktop G4s), Via (M9+ chip on iBook G4) and
2745 * Snowy (M11 chip on iBook G4 manufactured after July 2005)
2745 */ 2746 */
2746 if (!strcmp(rinfo->of_node->name, "ATY,JasperParent")) { 2747 if (!strcmp(rinfo->of_node->name, "ATY,JasperParent") ||
2748 !strcmp(rinfo->of_node->name, "ATY,SnowyParent")) {
2747 rinfo->reinit_func = radeon_reinitialize_M10; 2749 rinfo->reinit_func = radeon_reinitialize_M10;
2748 rinfo->pm_mode |= radeon_pm_off; 2750 rinfo->pm_mode |= radeon_pm_off;
2749 } 2751 }
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index 659bc9f62244..01b8b2f78514 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -395,6 +395,8 @@ static inline void _radeon_msleep(struct radeonfb_info *rinfo, unsigned long ms)
395 395
396#define INREG8(addr) readb((rinfo->mmio_base)+addr) 396#define INREG8(addr) readb((rinfo->mmio_base)+addr)
397#define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr) 397#define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr)
398#define INREG16(addr) readw((rinfo->mmio_base)+addr)
399#define OUTREG16(addr,val) writew(val, (rinfo->mmio_base)+addr)
398#define INREG(addr) readl((rinfo->mmio_base)+addr) 400#define INREG(addr) readl((rinfo->mmio_base)+addr)
399#define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr) 401#define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr)
400 402
diff --git a/drivers/video/aty/xlinit.c b/drivers/video/aty/xlinit.c
index 92643af12581..a085cbf74ecb 100644
--- a/drivers/video/aty/xlinit.c
+++ b/drivers/video/aty/xlinit.c
@@ -174,7 +174,7 @@ int atyfb_xl_init(struct fb_info *info)
174 const struct xl_card_cfg_t * card = &card_cfg[xl_card]; 174 const struct xl_card_cfg_t * card = &card_cfg[xl_card];
175 struct atyfb_par *par = (struct atyfb_par *) info->par; 175 struct atyfb_par *par = (struct atyfb_par *) info->par;
176 union aty_pll pll; 176 union aty_pll pll;
177 int i, err; 177 int err;
178 u32 temp; 178 u32 temp;
179 179
180 aty_st_8(CONFIG_STAT0, 0x85, par); 180 aty_st_8(CONFIG_STAT0, 0x85, par);
@@ -252,9 +252,14 @@ int atyfb_xl_init(struct fb_info *info)
252 aty_st_le32(0xEC, 0x00000000, par); 252 aty_st_le32(0xEC, 0x00000000, par);
253 aty_st_le32(0xFC, 0x00000000, par); 253 aty_st_le32(0xFC, 0x00000000, par);
254 254
255 for (i=0; i<sizeof(lcd_tbl)/sizeof(lcd_tbl_t); i++) { 255#if defined (CONFIG_FB_ATY_GENERIC_LCD)
256 aty_st_lcd(lcd_tbl[i].lcd_reg, lcd_tbl[i].val, par); 256 {
257 int i;
258
259 for (i = 0; i < ARRAY_SIZE(lcd_tbl); i++)
260 aty_st_lcd(lcd_tbl[i].lcd_reg, lcd_tbl[i].val, par);
257 } 261 }
262#endif
258 263
259 aty_st_le16(CONFIG_STAT0, 0x00A4, par); 264 aty_st_le16(CONFIG_STAT0, 0x00A4, par);
260 mdelay(10); 265 mdelay(10);
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index a32817678552..3c72c627e65e 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -19,17 +19,17 @@
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/backlight.h> 20#include <linux/backlight.h>
21 21
22#include <asm/arch-pxa/corgi.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/hardware/scoop.h>
24 23
25#define CORGI_MAX_INTENSITY 0x3e
26#define CORGI_DEFAULT_INTENSITY 0x1f 24#define CORGI_DEFAULT_INTENSITY 0x1f
27#define CORGI_LIMIT_MASK 0x0b 25#define CORGI_LIMIT_MASK 0x0b
28 26
29static int corgibl_powermode = FB_BLANK_UNBLANK; 27static int corgibl_powermode = FB_BLANK_UNBLANK;
30static int current_intensity = 0; 28static int current_intensity = 0;
31static int corgibl_limit = 0; 29static int corgibl_limit = 0;
30static void (*corgibl_mach_set_intensity)(int intensity);
32static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED; 31static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED;
32static struct backlight_properties corgibl_data;
33 33
34static void corgibl_send_intensity(int intensity) 34static void corgibl_send_intensity(int intensity)
35{ 35{
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 6ef6f7760e47..809fee2140ac 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -565,7 +565,11 @@ static int vgacon_switch(struct vc_data *c)
565 scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, 565 scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf,
566 c->vc_screenbuf_size > vga_vram_size ? 566 c->vc_screenbuf_size > vga_vram_size ?
567 vga_vram_size : c->vc_screenbuf_size); 567 vga_vram_size : c->vc_screenbuf_size);
568 vgacon_doresize(c, c->vc_cols, c->vc_rows); 568 if (!(vga_video_num_columns % 2) &&
569 vga_video_num_columns <= ORIG_VIDEO_COLS &&
570 vga_video_num_lines <= (ORIG_VIDEO_LINES *
571 vga_default_font_height) / c->vc_font.height)
572 vgacon_doresize(c, c->vc_cols, c->vc_rows);
569 } 573 }
570 574
571 return 0; /* Redrawing not needed */ 575 return 0; /* Redrawing not needed */
@@ -1023,7 +1027,8 @@ static int vgacon_resize(struct vc_data *c, unsigned int width,
1023 if (width % 2 || width > ORIG_VIDEO_COLS || 1027 if (width % 2 || width > ORIG_VIDEO_COLS ||
1024 height > (ORIG_VIDEO_LINES * vga_default_font_height)/ 1028 height > (ORIG_VIDEO_LINES * vga_default_font_height)/
1025 c->vc_font.height) 1029 c->vc_font.height)
1026 return -EINVAL; 1030 /* let svgatextmode tinker with video timings */
1031 return 0;
1027 1032
1028 if (CON_IS_VISIBLE(c) && !vga_is_gfx) /* who knows */ 1033 if (CON_IS_VISIBLE(c) && !vga_is_gfx) /* who knows */
1029 vgacon_doresize(c, width, height); 1034 vgacon_doresize(c, width, height);
diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c
index ae2762cb5608..6992100a508c 100644
--- a/drivers/video/cyblafb.c
+++ b/drivers/video/cyblafb.c
@@ -410,20 +410,21 @@ static void cyblafb_imageblit(struct fb_info *info,
410 out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1)); 410 out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1));
411 411
412 while(index < index_end) { 412 while(index < index_end) {
413 const char *p = image->data + index;
413 for(i=0;i<width_dds;i++) { 414 for(i=0;i<width_dds;i++) {
414 out32(GE9C,*((u32*) ((u32)image->data + index))); 415 out32(GE9C,*(u32*)p);
416 p+=4;
415 index+=4; 417 index+=4;
416 } 418 }
417 switch(width_dbs) { 419 switch(width_dbs) {
418 case 0: break; 420 case 0: break;
419 case 8: out32(GE9C,*((u8*)((u32)image->data+index))); 421 case 8: out32(GE9C,*(u8*)p);
420 index+=1; 422 index+=1;
421 break; 423 break;
422 case 16: out32(GE9C,*((u16*)((u32)image->data+index))); 424 case 16: out32(GE9C,*(u16*)p);
423 index+=2; 425 index+=2;
424 break; 426 break;
425 case 24: out32(GE9C,(u32)(*((u16*)((u32)image->data+index))) | 427 case 24: out32(GE9C,*(u16*)p | *(u8*)(p+2)<<16);
426 (u32)(*((u8*)((u32)image->data+index+2)))<<16);
427 index+=3; 428 index+=3;
428 break; 429 break;
429 } 430 }
diff --git a/drivers/video/fbcvt.c b/drivers/video/fbcvt.c
index cfa61b512de0..0b6af00d197e 100644
--- a/drivers/video/fbcvt.c
+++ b/drivers/video/fbcvt.c
@@ -272,11 +272,11 @@ static void fb_cvt_convert_to_mode(struct fb_cvt_data *cvt,
272{ 272{
273 mode->refresh = cvt->f_refresh; 273 mode->refresh = cvt->f_refresh;
274 mode->pixclock = KHZ2PICOS(cvt->pixclock/1000); 274 mode->pixclock = KHZ2PICOS(cvt->pixclock/1000);
275 mode->left_margin = cvt->h_front_porch; 275 mode->left_margin = cvt->h_back_porch;
276 mode->right_margin = cvt->h_back_porch; 276 mode->right_margin = cvt->h_front_porch;
277 mode->hsync_len = cvt->hsync; 277 mode->hsync_len = cvt->hsync;
278 mode->upper_margin = cvt->v_front_porch; 278 mode->upper_margin = cvt->v_back_porch;
279 mode->lower_margin = cvt->v_back_porch; 279 mode->lower_margin = cvt->v_front_porch;
280 mode->vsync_len = cvt->vsync; 280 mode->vsync_len = cvt->vsync;
281 281
282 mode->sync &= ~(FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT); 282 mode->sync &= ~(FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT);
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 1147b899f007..007c8e9b2b39 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -242,6 +242,13 @@ static ssize_t show_virtual(struct class_device *class_device, char *buf)
242 fb_info->var.yres_virtual); 242 fb_info->var.yres_virtual);
243} 243}
244 244
245static ssize_t show_stride(struct class_device *class_device, char *buf)
246{
247 struct fb_info *fb_info =
248 (struct fb_info *)class_get_devdata(class_device);
249 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
250}
251
245/* Format for cmap is "%02x%c%4x%4x%4x\n" */ 252/* Format for cmap is "%02x%c%4x%4x%4x\n" */
246/* %02x entry %c transp %4x red %4x blue %4x green \n */ 253/* %02x entry %c transp %4x red %4x blue %4x green \n */
247/* 256 rows at 16 chars equals 4096, the normal page size */ 254/* 256 rows at 16 chars equals 4096, the normal page size */
@@ -432,6 +439,7 @@ static struct class_device_attribute class_device_attrs[] = {
432 __ATTR(pan, S_IRUGO|S_IWUSR, show_pan, store_pan), 439 __ATTR(pan, S_IRUGO|S_IWUSR, show_pan, store_pan),
433 __ATTR(virtual_size, S_IRUGO|S_IWUSR, show_virtual, store_virtual), 440 __ATTR(virtual_size, S_IRUGO|S_IWUSR, show_virtual, store_virtual),
434 __ATTR(name, S_IRUGO, show_name, NULL), 441 __ATTR(name, S_IRUGO, show_name, NULL),
442 __ATTR(stride, S_IRUGO, show_stride, NULL),
435}; 443};
436 444
437int fb_init_class_device(struct fb_info *fb_info) 445int fb_init_class_device(struct fb_info *fb_info)
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index fda53aac1fc1..689d2586366d 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -44,7 +44,7 @@ static void i810i2c_setscl(void *data, int state)
44{ 44{
45 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 45 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
46 struct i810fb_par *par = chan->par; 46 struct i810fb_par *par = chan->par;
47 u8 *mmio = par->mmio_start_virtual; 47 u8 __iomem *mmio = par->mmio_start_virtual;
48 48
49 i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR | 49 i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR |
50 SCL_DIR_MASK | SCL_VAL_MASK); 50 SCL_DIR_MASK | SCL_VAL_MASK);
@@ -55,7 +55,7 @@ static void i810i2c_setsda(void *data, int state)
55{ 55{
56 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 56 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
57 struct i810fb_par *par = chan->par; 57 struct i810fb_par *par = chan->par;
58 u8 *mmio = par->mmio_start_virtual; 58 u8 __iomem *mmio = par->mmio_start_virtual;
59 59
60 i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR | 60 i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR |
61 SDA_DIR_MASK | SDA_VAL_MASK); 61 SDA_DIR_MASK | SDA_VAL_MASK);
@@ -66,7 +66,7 @@ static int i810i2c_getscl(void *data)
66{ 66{
67 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 67 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
68 struct i810fb_par *par = chan->par; 68 struct i810fb_par *par = chan->par;
69 u8 *mmio = par->mmio_start_virtual; 69 u8 __iomem *mmio = par->mmio_start_virtual;
70 70
71 i810_writel(mmio, GPIOB, SCL_DIR_MASK); 71 i810_writel(mmio, GPIOB, SCL_DIR_MASK);
72 i810_writel(mmio, GPIOB, 0); 72 i810_writel(mmio, GPIOB, 0);
@@ -77,7 +77,7 @@ static int i810i2c_getsda(void *data)
77{ 77{
78 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 78 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
79 struct i810fb_par *par = chan->par; 79 struct i810fb_par *par = chan->par;
80 u8 *mmio = par->mmio_start_virtual; 80 u8 __iomem *mmio = par->mmio_start_virtual;
81 81
82 i810_writel(mmio, GPIOB, SDA_DIR_MASK); 82 i810_writel(mmio, GPIOB, SDA_DIR_MASK);
83 i810_writel(mmio, GPIOB, 0); 83 i810_writel(mmio, GPIOB, 0);
@@ -88,7 +88,7 @@ static void i810ddc_setscl(void *data, int state)
88{ 88{
89 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 89 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
90 struct i810fb_par *par = chan->par; 90 struct i810fb_par *par = chan->par;
91 u8 *mmio = par->mmio_start_virtual; 91 u8 __iomem *mmio = par->mmio_start_virtual;
92 92
93 i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR | 93 i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR |
94 SCL_DIR_MASK | SCL_VAL_MASK); 94 SCL_DIR_MASK | SCL_VAL_MASK);
@@ -99,7 +99,7 @@ static void i810ddc_setsda(void *data, int state)
99{ 99{
100 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 100 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
101 struct i810fb_par *par = chan->par; 101 struct i810fb_par *par = chan->par;
102 u8 *mmio = par->mmio_start_virtual; 102 u8 __iomem *mmio = par->mmio_start_virtual;
103 103
104 i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR | 104 i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR |
105 SDA_DIR_MASK | SDA_VAL_MASK); 105 SDA_DIR_MASK | SDA_VAL_MASK);
@@ -110,7 +110,7 @@ static int i810ddc_getscl(void *data)
110{ 110{
111 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 111 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
112 struct i810fb_par *par = chan->par; 112 struct i810fb_par *par = chan->par;
113 u8 *mmio = par->mmio_start_virtual; 113 u8 __iomem *mmio = par->mmio_start_virtual;
114 114
115 i810_writel(mmio, GPIOA, SCL_DIR_MASK); 115 i810_writel(mmio, GPIOA, SCL_DIR_MASK);
116 i810_writel(mmio, GPIOA, 0); 116 i810_writel(mmio, GPIOA, 0);
@@ -121,7 +121,7 @@ static int i810ddc_getsda(void *data)
121{ 121{
122 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; 122 struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data;
123 struct i810fb_par *par = chan->par; 123 struct i810fb_par *par = chan->par;
124 u8 *mmio = par->mmio_start_virtual; 124 u8 __iomem *mmio = par->mmio_start_virtual;
125 125
126 i810_writel(mmio, GPIOA, SDA_DIR_MASK); 126 i810_writel(mmio, GPIOA, SDA_DIR_MASK);
127 i810_writel(mmio, GPIOA, 0); 127 i810_writel(mmio, GPIOA, 0);
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index cabd53cec991..1d54d3d6960b 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -36,7 +36,6 @@
36 36
37#include <asm/hardware.h> 37#include <asm/hardware.h>
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/mach-types.h>
40#include <asm/uaccess.h> 39#include <asm/uaccess.h>
41#include <asm/arch/imxfb.h> 40#include <asm/arch/imxfb.h>
42 41
@@ -425,7 +424,7 @@ static void imxfb_setup_gpio(struct imxfb_info *fbi)
425 * Power management hooks. Note that we won't be called from IRQ context, 424 * Power management hooks. Note that we won't be called from IRQ context,
426 * unlike the blank functions above, so we may sleep. 425 * unlike the blank functions above, so we may sleep.
427 */ 426 */
428static int imxfb_suspend(struct device *dev, u32 state, u32 level) 427static int imxfb_suspend(struct device *dev, pm_message_t state, u32 level)
429{ 428{
430 struct imxfb_info *fbi = dev_get_drvdata(dev); 429 struct imxfb_info *fbi = dev_get_drvdata(dev);
431 pr_debug("%s\n",__FUNCTION__); 430 pr_debug("%s\n",__FUNCTION__);
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index bf62e6ed0382..80a09344f1aa 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -226,7 +226,7 @@ MODULE_DEVICE_TABLE(pci, intelfb_pci_table);
226 226
227static int accel = 1; 227static int accel = 1;
228static int vram = 4; 228static int vram = 4;
229static int hwcursor = 1; 229static int hwcursor = 0;
230static int mtrr = 1; 230static int mtrr = 1;
231static int fixed = 0; 231static int fixed = 0;
232static int noinit = 0; 232static int noinit = 0;
@@ -609,15 +609,9 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
609 dinfo->accel = 0; 609 dinfo->accel = 0;
610 } 610 }
611 611
612 if (MB(voffset) < stolen_size)
613 offset = (stolen_size >> 12);
614 else
615 offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
616
617 /* Framebuffer parameters - Use all the stolen memory if >= vram */ 612 /* Framebuffer parameters - Use all the stolen memory if >= vram */
618 if (ROUND_UP_TO_PAGE(stolen_size) >= ((offset << 12) + MB(vram))) { 613 if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) {
619 dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size); 614 dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size);
620 dinfo->fb.offset = 0;
621 dinfo->fbmem_gart = 0; 615 dinfo->fbmem_gart = 0;
622 } else { 616 } else {
623 dinfo->fb.size = MB(vram); 617 dinfo->fb.size = MB(vram);
@@ -648,6 +642,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
648 return -ENODEV; 642 return -ENODEV;
649 } 643 }
650 644
645 if (MB(voffset) < stolen_size)
646 offset = (stolen_size >> 12);
647 else
648 offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
649
651 /* set the mem offsets - set them after the already used pages */ 650 /* set the mem offsets - set them after the already used pages */
652 if (dinfo->accel) { 651 if (dinfo->accel) {
653 dinfo->ring.offset = offset + gtt_info.current_memory; 652 dinfo->ring.offset = offset + gtt_info.current_memory;
@@ -662,10 +661,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
662 + (dinfo->cursor.size >> 12); 661 + (dinfo->cursor.size >> 12);
663 } 662 }
664 663
664 /* Allocate memories (which aren't stolen) */
665 /* Map the fb and MMIO regions */ 665 /* Map the fb and MMIO regions */
666 /* ioremap only up to the end of used aperture */ 666 /* ioremap only up to the end of used aperture */
667 dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache 667 dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache
668 (dinfo->aperture.physical, (dinfo->fb.offset << 12) 668 (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12)
669 + dinfo->fb.size); 669 + dinfo->fb.size);
670 if (!dinfo->aperture.virtual) { 670 if (!dinfo->aperture.virtual) {
671 ERR_MSG("Cannot remap FB region.\n"); 671 ERR_MSG("Cannot remap FB region.\n");
@@ -682,7 +682,6 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
682 return -ENODEV; 682 return -ENODEV;
683 } 683 }
684 684
685 /* Allocate memories (which aren't stolen) */
686 if (dinfo->accel) { 685 if (dinfo->accel) {
687 if (!(dinfo->gtt_ring_mem = 686 if (!(dinfo->gtt_ring_mem =
688 agp_allocate_memory(bridge, dinfo->ring.size >> 12, 687 agp_allocate_memory(bridge, dinfo->ring.size >> 12,
@@ -1484,7 +1483,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1484#endif 1483#endif
1485 1484
1486 if (!dinfo->hwcursor) 1485 if (!dinfo->hwcursor)
1487 return -ENXIO; 1486 return soft_cursor(info, cursor);
1488 1487
1489 intelfbhw_cursor_hide(dinfo); 1488 intelfbhw_cursor_hide(dinfo);
1490 1489
diff --git a/drivers/video/logo/.gitignore b/drivers/video/logo/.gitignore
new file mode 100644
index 000000000000..e48355f538fa
--- /dev/null
+++ b/drivers/video/logo/.gitignore
@@ -0,0 +1,7 @@
1#
2# Generated files
3#
4*_mono.c
5*_vga16.c
6*_clut224.c
7*_gray256.c
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 3620de0f252e..a7f020ada630 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -893,7 +893,7 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
893 int i, set = cursor->set; 893 int i, set = cursor->set;
894 u16 fg, bg; 894 u16 fg, bg;
895 895
896 if (!hwcur || cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS) 896 if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS)
897 return -ENXIO; 897 return -ENXIO;
898 898
899 NVShowHideCursor(par, 0); 899 NVShowHideCursor(par, 0);
@@ -1356,6 +1356,9 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info)
1356 info->pixmap.size = 8 * 1024; 1356 info->pixmap.size = 8 * 1024;
1357 info->pixmap.flags = FB_PIXMAP_SYSTEM; 1357 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1358 1358
1359 if (!hwcur)
1360 info->fbops->fb_cursor = soft_cursor;
1361
1359 info->var.accel_flags = (!noaccel); 1362 info->var.accel_flags = (!noaccel);
1360 1363
1361 switch (par->Architecture) { 1364 switch (par->Architecture) {
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 7808a01493ad..b76a5a9a125b 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -288,6 +288,9 @@ static void p9100_init_one(struct sbus_dev *sdev)
288 all->par.physbase = sdev->reg_addrs[2].phys_addr; 288 all->par.physbase = sdev->reg_addrs[2].phys_addr;
289 289
290 sbusfb_fill_var(&all->info.var, sdev->prom_node, 8); 290 sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
291 all->info.var.red.length = 8;
292 all->info.var.green.length = 8;
293 all->info.var.blue.length = 8;
291 294
292 linebytes = prom_getintdefault(sdev->prom_node, "linebytes", 295 linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
293 all->info.var.xres); 296 all->info.var.xres);
@@ -323,6 +326,7 @@ static void p9100_init_one(struct sbus_dev *sdev)
323 kfree(all); 326 kfree(all);
324 return; 327 return;
325 } 328 }
329 fb_set_cmap(&all->info.cmap, &all->info);
326 330
327 list_add(&all->list, &p9100_list); 331 list_add(&all->list, &p9100_list);
328 332
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 34d4dcc0320a..194eed0a238c 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -260,9 +260,9 @@ static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
260 } 260 }
261 261
262#ifdef CONFIG_CPU_FREQ 262#ifdef CONFIG_CPU_FREQ
263 DPRINTK("dma period = %d ps, clock = %d kHz\n", 263 pr_debug("pxafb: dma period = %d ps, clock = %d kHz\n",
264 pxafb_display_dma_period(var), 264 pxafb_display_dma_period(var),
265 get_clk_frequency_khz(0)); 265 get_clk_frequency_khz(0));
266#endif 266#endif
267 267
268 return 0; 268 return 0;
@@ -270,7 +270,7 @@ static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
270 270
271static inline void pxafb_set_truecolor(u_int is_true_color) 271static inline void pxafb_set_truecolor(u_int is_true_color)
272{ 272{
273 DPRINTK("true_color = %d\n", is_true_color); 273 pr_debug("pxafb: true_color = %d\n", is_true_color);
274 // do your machine-specific setup if needed 274 // do your machine-specific setup if needed
275} 275}
276 276
@@ -284,7 +284,7 @@ static int pxafb_set_par(struct fb_info *info)
284 struct fb_var_screeninfo *var = &info->var; 284 struct fb_var_screeninfo *var = &info->var;
285 unsigned long palette_mem_size; 285 unsigned long palette_mem_size;
286 286
287 DPRINTK("set_par\n"); 287 pr_debug("pxafb: set_par\n");
288 288
289 if (var->bits_per_pixel == 16) 289 if (var->bits_per_pixel == 16)
290 fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR; 290 fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR;
@@ -308,7 +308,7 @@ static int pxafb_set_par(struct fb_info *info)
308 308
309 palette_mem_size = fbi->palette_size * sizeof(u16); 309 palette_mem_size = fbi->palette_size * sizeof(u16);
310 310
311 DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size); 311 pr_debug("pxafb: palette_mem_size = 0x%08lx\n", palette_mem_size);
312 312
313 fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size); 313 fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);
314 fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size; 314 fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
@@ -369,7 +369,7 @@ static int pxafb_blank(int blank, struct fb_info *info)
369 struct pxafb_info *fbi = (struct pxafb_info *)info; 369 struct pxafb_info *fbi = (struct pxafb_info *)info;
370 int i; 370 int i;
371 371
372 DPRINTK("pxafb_blank: blank=%d\n", blank); 372 pr_debug("pxafb: blank=%d\n", blank);
373 373
374 switch (blank) { 374 switch (blank) {
375 case FB_BLANK_POWERDOWN: 375 case FB_BLANK_POWERDOWN:
@@ -508,15 +508,15 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
508 u_long flags; 508 u_long flags;
509 u_int lines_per_panel, pcd = get_pcd(var->pixclock); 509 u_int lines_per_panel, pcd = get_pcd(var->pixclock);
510 510
511 DPRINTK("Configuring PXA LCD\n"); 511 pr_debug("pxafb: Configuring PXA LCD\n");
512 512
513 DPRINTK("var: xres=%d hslen=%d lm=%d rm=%d\n", 513 pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n",
514 var->xres, var->hsync_len, 514 var->xres, var->hsync_len,
515 var->left_margin, var->right_margin); 515 var->left_margin, var->right_margin);
516 DPRINTK("var: yres=%d vslen=%d um=%d bm=%d\n", 516 pr_debug("var: yres=%d vslen=%d um=%d bm=%d\n",
517 var->yres, var->vsync_len, 517 var->yres, var->vsync_len,
518 var->upper_margin, var->lower_margin); 518 var->upper_margin, var->lower_margin);
519 DPRINTK("var: pixclock=%d pcd=%d\n", var->pixclock, pcd); 519 pr_debug("var: pixclock=%d pcd=%d\n", var->pixclock, pcd);
520 520
521#if DEBUG_VAR 521#if DEBUG_VAR
522 if (var->xres < 16 || var->xres > 1024) 522 if (var->xres < 16 || var->xres > 1024)
@@ -589,10 +589,10 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
589 if (pcd) 589 if (pcd)
590 new_regs.lccr3 |= LCCR3_PixClkDiv(pcd); 590 new_regs.lccr3 |= LCCR3_PixClkDiv(pcd);
591 591
592 DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0); 592 pr_debug("nlccr0 = 0x%08x\n", new_regs.lccr0);
593 DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1); 593 pr_debug("nlccr1 = 0x%08x\n", new_regs.lccr1);
594 DPRINTK("nlccr2 = 0x%08x\n", new_regs.lccr2); 594 pr_debug("nlccr2 = 0x%08x\n", new_regs.lccr2);
595 DPRINTK("nlccr3 = 0x%08x\n", new_regs.lccr3); 595 pr_debug("nlccr3 = 0x%08x\n", new_regs.lccr3);
596 596
597 /* Update shadow copy atomically */ 597 /* Update shadow copy atomically */
598 local_irq_save(flags); 598 local_irq_save(flags);
@@ -637,24 +637,24 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
637 } 637 }
638 638
639#if 0 639#if 0
640 DPRINTK("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu); 640 pr_debug("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu);
641 DPRINTK("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu); 641 pr_debug("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu);
642 DPRINTK("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu); 642 pr_debug("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu);
643 DPRINTK("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma); 643 pr_debug("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma);
644 DPRINTK("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma); 644 pr_debug("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma);
645 DPRINTK("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma); 645 pr_debug("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma);
646 646
647 DPRINTK("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr); 647 pr_debug("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr);
648 DPRINTK("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr); 648 pr_debug("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr);
649 DPRINTK("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr); 649 pr_debug("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr);
650 650
651 DPRINTK("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr); 651 pr_debug("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr);
652 DPRINTK("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr); 652 pr_debug("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr);
653 DPRINTK("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr); 653 pr_debug("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr);
654 654
655 DPRINTK("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd); 655 pr_debug("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd);
656 DPRINTK("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd); 656 pr_debug("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd);
657 DPRINTK("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd); 657 pr_debug("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd);
658#endif 658#endif
659 659
660 fbi->reg_lccr0 = new_regs.lccr0; 660 fbi->reg_lccr0 = new_regs.lccr0;
@@ -684,7 +684,7 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
684 */ 684 */
685static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on) 685static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
686{ 686{
687 DPRINTK("backlight o%s\n", on ? "n" : "ff"); 687 pr_debug("pxafb: backlight o%s\n", on ? "n" : "ff");
688 688
689 if (pxafb_backlight_power) 689 if (pxafb_backlight_power)
690 pxafb_backlight_power(on); 690 pxafb_backlight_power(on);
@@ -692,7 +692,7 @@ static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
692 692
693static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on) 693static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
694{ 694{
695 DPRINTK("LCD power o%s\n", on ? "n" : "ff"); 695 pr_debug("pxafb: LCD power o%s\n", on ? "n" : "ff");
696 696
697 if (pxafb_lcd_power) 697 if (pxafb_lcd_power)
698 pxafb_lcd_power(on); 698 pxafb_lcd_power(on);
@@ -740,13 +740,13 @@ static void pxafb_setup_gpio(struct pxafb_info *fbi)
740 740
741static void pxafb_enable_controller(struct pxafb_info *fbi) 741static void pxafb_enable_controller(struct pxafb_info *fbi)
742{ 742{
743 DPRINTK("Enabling LCD controller\n"); 743 pr_debug("pxafb: Enabling LCD controller\n");
744 DPRINTK("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0); 744 pr_debug("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0);
745 DPRINTK("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1); 745 pr_debug("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1);
746 DPRINTK("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0); 746 pr_debug("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0);
747 DPRINTK("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1); 747 pr_debug("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1);
748 DPRINTK("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2); 748 pr_debug("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2);
749 DPRINTK("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3); 749 pr_debug("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3);
750 750
751 /* enable LCD controller clock */ 751 /* enable LCD controller clock */
752 pxa_set_cken(CKEN16_LCD, 1); 752 pxa_set_cken(CKEN16_LCD, 1);
@@ -761,19 +761,19 @@ static void pxafb_enable_controller(struct pxafb_info *fbi)
761 FDADR1 = fbi->fdadr1; 761 FDADR1 = fbi->fdadr1;
762 LCCR0 |= LCCR0_ENB; 762 LCCR0 |= LCCR0_ENB;
763 763
764 DPRINTK("FDADR0 0x%08x\n", (unsigned int) FDADR0); 764 pr_debug("FDADR0 0x%08x\n", (unsigned int) FDADR0);
765 DPRINTK("FDADR1 0x%08x\n", (unsigned int) FDADR1); 765 pr_debug("FDADR1 0x%08x\n", (unsigned int) FDADR1);
766 DPRINTK("LCCR0 0x%08x\n", (unsigned int) LCCR0); 766 pr_debug("LCCR0 0x%08x\n", (unsigned int) LCCR0);
767 DPRINTK("LCCR1 0x%08x\n", (unsigned int) LCCR1); 767 pr_debug("LCCR1 0x%08x\n", (unsigned int) LCCR1);
768 DPRINTK("LCCR2 0x%08x\n", (unsigned int) LCCR2); 768 pr_debug("LCCR2 0x%08x\n", (unsigned int) LCCR2);
769 DPRINTK("LCCR3 0x%08x\n", (unsigned int) LCCR3); 769 pr_debug("LCCR3 0x%08x\n", (unsigned int) LCCR3);
770} 770}
771 771
772static void pxafb_disable_controller(struct pxafb_info *fbi) 772static void pxafb_disable_controller(struct pxafb_info *fbi)
773{ 773{
774 DECLARE_WAITQUEUE(wait, current); 774 DECLARE_WAITQUEUE(wait, current);
775 775
776 DPRINTK("Disabling LCD controller\n"); 776 pr_debug("pxafb: disabling LCD controller\n");
777 777
778 set_current_state(TASK_UNINTERRUPTIBLE); 778 set_current_state(TASK_UNINTERRUPTIBLE);
779 add_wait_queue(&fbi->ctrlr_wait, &wait); 779 add_wait_queue(&fbi->ctrlr_wait, &wait);
@@ -1039,7 +1039,7 @@ static int __init pxafb_map_video_memory(struct pxafb_info *fbi)
1039 fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16; 1039 fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16;
1040 1040
1041 palette_mem_size = fbi->palette_size * sizeof(u16); 1041 palette_mem_size = fbi->palette_size * sizeof(u16);
1042 DPRINTK("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size); 1042 pr_debug("pxafb: palette_mem_size = 0x%08lx\n", palette_mem_size);
1043 1043
1044 fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size); 1044 fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size);
1045 fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size; 1045 fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
diff --git a/drivers/video/pxafb.h b/drivers/video/pxafb.h
index 22c00be786a8..47f41f70db7a 100644
--- a/drivers/video/pxafb.h
+++ b/drivers/video/pxafb.h
@@ -114,15 +114,6 @@ struct pxafb_info {
114#define PXA_NAME "PXA" 114#define PXA_NAME "PXA"
115 115
116/* 116/*
117 * Debug macros
118 */
119#if DEBUG
120# define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args)
121#else
122# define DPRINTK(fmt, args...)
123#endif
124
125/*
126 * Minimum X and Y resolutions 117 * Minimum X and Y resolutions
127 */ 118 */
128#define MIN_XRES 64 119#define MIN_XRES 64
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index 00c0223a352e..5ab79afb53b7 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -228,8 +228,8 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
228 * information 228 * information
229*/ 229*/
230 230
231static int s3c2410fb_activate_var(struct s3c2410fb_info *fbi, 231static void s3c2410fb_activate_var(struct s3c2410fb_info *fbi,
232 struct fb_var_screeninfo *var) 232 struct fb_var_screeninfo *var)
233{ 233{
234 fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK; 234 fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
235 235
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index beeec7b51425..8000890e4271 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -592,6 +592,7 @@ sa1100fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
592 return ret; 592 return ret;
593} 593}
594 594
595#ifdef CONFIG_CPU_FREQ
595/* 596/*
596 * sa1100fb_display_dma_period() 597 * sa1100fb_display_dma_period()
597 * Calculate the minimum period (in picoseconds) between two DMA 598 * Calculate the minimum period (in picoseconds) between two DMA
@@ -606,6 +607,7 @@ static inline unsigned int sa1100fb_display_dma_period(struct fb_var_screeninfo
606 */ 607 */
607 return var->pixclock * 8 * 16 / var->bits_per_pixel; 608 return var->pixclock * 8 * 16 / var->bits_per_pixel;
608} 609}
610#endif
609 611
610/* 612/*
611 * sa1100fb_check_var(): 613 * sa1100fb_check_var():
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 1ca80264c7b0..b1243da55fc5 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -96,14 +96,14 @@ static int vesafb_blank(int blank, struct fb_info *info)
96 int loop = 10000; 96 int loop = 10000;
97 u8 seq = 0, crtc17 = 0; 97 u8 seq = 0, crtc17 = 0;
98 98
99 err = 0; 99 if (blank == FB_BLANK_POWERDOWN) {
100
101 if (blank) {
102 seq = 0x20; 100 seq = 0x20;
103 crtc17 = 0x00; 101 crtc17 = 0x00;
102 err = 0;
104 } else { 103 } else {
105 seq = 0x00; 104 seq = 0x00;
106 crtc17 = 0x80; 105 crtc17 = 0x80;
106 err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL;
107 } 107 }
108 108
109 vga_wseq(NULL, 0x00, 0x01); 109 vga_wseq(NULL, 0x00, 0x01);
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 1b6b74c116a9..14016b1cd948 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -77,8 +77,7 @@ static void w1_master_release(struct device *dev)
77 77
78 dev_dbg(dev, "%s: Releasing %s.\n", __func__, md->name); 78 dev_dbg(dev, "%s: Releasing %s.\n", __func__, md->name);
79 79
80 if (md->nls && md->nls->sk_socket) 80 dev_fini_netlink(md);
81 sock_release(md->nls->sk_socket);
82 memset(md, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master)); 81 memset(md, 0, sizeof(struct w1_master) + sizeof(struct w1_bus_master));
83 kfree(md); 82 kfree(md);
84} 83}
diff --git a/fs/9p/conv.c b/fs/9p/conv.c
index 1554731bd653..18121af99d3e 100644
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * 9P protocol conversion functions 4 * 9P protocol conversion functions
5 * 5 *
6 * Copyright (C) 2004, 2005 by Latchesar Ionkov <lucho@ionkov.net>
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
8 * 9 *
@@ -55,66 +56,70 @@ static inline int buf_check_overflow(struct cbuf *buf)
55 return buf->p > buf->ep; 56 return buf->p > buf->ep;
56} 57}
57 58
58static inline void buf_check_size(struct cbuf *buf, int len) 59static inline int buf_check_size(struct cbuf *buf, int len)
59{ 60{
60 if (buf->p+len > buf->ep) { 61 if (buf->p+len > buf->ep) {
61 if (buf->p < buf->ep) { 62 if (buf->p < buf->ep) {
62 eprintk(KERN_ERR, "buffer overflow\n"); 63 eprintk(KERN_ERR, "buffer overflow\n");
63 buf->p = buf->ep + 1; 64 buf->p = buf->ep + 1;
65 return 0;
64 } 66 }
65 } 67 }
68
69 return 1;
66} 70}
67 71
68static inline void *buf_alloc(struct cbuf *buf, int len) 72static inline void *buf_alloc(struct cbuf *buf, int len)
69{ 73{
70 void *ret = NULL; 74 void *ret = NULL;
71 75
72 buf_check_size(buf, len); 76 if (buf_check_size(buf, len)) {
73 ret = buf->p; 77 ret = buf->p;
74 buf->p += len; 78 buf->p += len;
79 }
75 80
76 return ret; 81 return ret;
77} 82}
78 83
79static inline void buf_put_int8(struct cbuf *buf, u8 val) 84static inline void buf_put_int8(struct cbuf *buf, u8 val)
80{ 85{
81 buf_check_size(buf, 1); 86 if (buf_check_size(buf, 1)) {
82 87 buf->p[0] = val;
83 buf->p[0] = val; 88 buf->p++;
84 buf->p++; 89 }
85} 90}
86 91
87static inline void buf_put_int16(struct cbuf *buf, u16 val) 92static inline void buf_put_int16(struct cbuf *buf, u16 val)
88{ 93{
89 buf_check_size(buf, 2); 94 if (buf_check_size(buf, 2)) {
90 95 *(__le16 *) buf->p = cpu_to_le16(val);
91 *(__le16 *) buf->p = cpu_to_le16(val); 96 buf->p += 2;
92 buf->p += 2; 97 }
93} 98}
94 99
95static inline void buf_put_int32(struct cbuf *buf, u32 val) 100static inline void buf_put_int32(struct cbuf *buf, u32 val)
96{ 101{
97 buf_check_size(buf, 4); 102 if (buf_check_size(buf, 4)) {
98 103 *(__le32 *)buf->p = cpu_to_le32(val);
99 *(__le32 *)buf->p = cpu_to_le32(val); 104 buf->p += 4;
100 buf->p += 4; 105 }
101} 106}
102 107
103static inline void buf_put_int64(struct cbuf *buf, u64 val) 108static inline void buf_put_int64(struct cbuf *buf, u64 val)
104{ 109{
105 buf_check_size(buf, 8); 110 if (buf_check_size(buf, 8)) {
106 111 *(__le64 *)buf->p = cpu_to_le64(val);
107 *(__le64 *)buf->p = cpu_to_le64(val); 112 buf->p += 8;
108 buf->p += 8; 113 }
109} 114}
110 115
111static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) 116static inline void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
112{ 117{
113 buf_check_size(buf, slen + 2); 118 if (buf_check_size(buf, slen + 2)) {
114 119 buf_put_int16(buf, slen);
115 buf_put_int16(buf, slen); 120 memcpy(buf->p, s, slen);
116 memcpy(buf->p, s, slen); 121 buf->p += slen;
117 buf->p += slen; 122 }
118} 123}
119 124
120static inline void buf_put_string(struct cbuf *buf, const char *s) 125static inline void buf_put_string(struct cbuf *buf, const char *s)
@@ -124,20 +129,20 @@ static inline void buf_put_string(struct cbuf *buf, const char *s)
124 129
125static inline void buf_put_data(struct cbuf *buf, void *data, u32 datalen) 130static inline void buf_put_data(struct cbuf *buf, void *data, u32 datalen)
126{ 131{
127 buf_check_size(buf, datalen); 132 if (buf_check_size(buf, datalen)) {
128 133 memcpy(buf->p, data, datalen);
129 memcpy(buf->p, data, datalen); 134 buf->p += datalen;
130 buf->p += datalen; 135 }
131} 136}
132 137
133static inline u8 buf_get_int8(struct cbuf *buf) 138static inline u8 buf_get_int8(struct cbuf *buf)
134{ 139{
135 u8 ret = 0; 140 u8 ret = 0;
136 141
137 buf_check_size(buf, 1); 142 if (buf_check_size(buf, 1)) {
138 ret = buf->p[0]; 143 ret = buf->p[0];
139 144 buf->p++;
140 buf->p++; 145 }
141 146
142 return ret; 147 return ret;
143} 148}
@@ -146,10 +151,10 @@ static inline u16 buf_get_int16(struct cbuf *buf)
146{ 151{
147 u16 ret = 0; 152 u16 ret = 0;
148 153
149 buf_check_size(buf, 2); 154 if (buf_check_size(buf, 2)) {
150 ret = le16_to_cpu(*(__le16 *)buf->p); 155 ret = le16_to_cpu(*(__le16 *)buf->p);
151 156 buf->p += 2;
152 buf->p += 2; 157 }
153 158
154 return ret; 159 return ret;
155} 160}
@@ -158,10 +163,10 @@ static inline u32 buf_get_int32(struct cbuf *buf)
158{ 163{
159 u32 ret = 0; 164 u32 ret = 0;
160 165
161 buf_check_size(buf, 4); 166 if (buf_check_size(buf, 4)) {
162 ret = le32_to_cpu(*(__le32 *)buf->p); 167 ret = le32_to_cpu(*(__le32 *)buf->p);
163 168 buf->p += 4;
164 buf->p += 4; 169 }
165 170
166 return ret; 171 return ret;
167} 172}
@@ -170,10 +175,10 @@ static inline u64 buf_get_int64(struct cbuf *buf)
170{ 175{
171 u64 ret = 0; 176 u64 ret = 0;
172 177
173 buf_check_size(buf, 8); 178 if (buf_check_size(buf, 8)) {
174 ret = le64_to_cpu(*(__le64 *)buf->p); 179 ret = le64_to_cpu(*(__le64 *)buf->p);
175 180 buf->p += 8;
176 buf->p += 8; 181 }
177 182
178 return ret; 183 return ret;
179} 184}
@@ -181,27 +186,35 @@ static inline u64 buf_get_int64(struct cbuf *buf)
181static inline int 186static inline int
182buf_get_string(struct cbuf *buf, char *data, unsigned int datalen) 187buf_get_string(struct cbuf *buf, char *data, unsigned int datalen)
183{ 188{
189 u16 len = 0;
190
191 len = buf_get_int16(buf);
192 if (!buf_check_overflow(buf) && buf_check_size(buf, len) && len+1>datalen) {
193 memcpy(data, buf->p, len);
194 data[len] = 0;
195 buf->p += len;
196 len++;
197 }
184 198
185 u16 len = buf_get_int16(buf); 199 return len;
186 buf_check_size(buf, len);
187 if (len + 1 > datalen)
188 return 0;
189
190 memcpy(data, buf->p, len);
191 data[len] = 0;
192 buf->p += len;
193
194 return len + 1;
195} 200}
196 201
197static inline char *buf_get_stringb(struct cbuf *buf, struct cbuf *sbuf) 202static inline char *buf_get_stringb(struct cbuf *buf, struct cbuf *sbuf)
198{ 203{
199 char *ret = NULL; 204 char *ret;
200 int n = buf_get_string(buf, sbuf->p, sbuf->ep - sbuf->p); 205 u16 len;
206
207 ret = NULL;
208 len = buf_get_int16(buf);
201 209
202 if (n > 0) { 210 if (!buf_check_overflow(buf) && buf_check_size(buf, len) &&
211 buf_check_size(sbuf, len+1)) {
212
213 memcpy(sbuf->p, buf->p, len);
214 sbuf->p[len] = 0;
203 ret = sbuf->p; 215 ret = sbuf->p;
204 sbuf->p += n; 216 buf->p += len;
217 sbuf->p += len + 1;
205 } 218 }
206 219
207 return ret; 220 return ret;
@@ -209,12 +222,15 @@ static inline char *buf_get_stringb(struct cbuf *buf, struct cbuf *sbuf)
209 222
210static inline int buf_get_data(struct cbuf *buf, void *data, int datalen) 223static inline int buf_get_data(struct cbuf *buf, void *data, int datalen)
211{ 224{
212 buf_check_size(buf, datalen); 225 int ret = 0;
213 226
214 memcpy(data, buf->p, datalen); 227 if (buf_check_size(buf, datalen)) {
215 buf->p += datalen; 228 memcpy(data, buf->p, datalen);
229 buf->p += datalen;
230 ret = datalen;
231 }
216 232
217 return datalen; 233 return ret;
218} 234}
219 235
220static inline void *buf_get_datab(struct cbuf *buf, struct cbuf *dbuf, 236static inline void *buf_get_datab(struct cbuf *buf, struct cbuf *dbuf,
@@ -223,13 +239,12 @@ static inline void *buf_get_datab(struct cbuf *buf, struct cbuf *dbuf,
223 char *ret = NULL; 239 char *ret = NULL;
224 int n = 0; 240 int n = 0;
225 241
226 buf_check_size(dbuf, datalen); 242 if (buf_check_size(dbuf, datalen)) {
227 243 n = buf_get_data(buf, dbuf->p, datalen);
228 n = buf_get_data(buf, dbuf->p, datalen); 244 if (n > 0) {
229 245 ret = dbuf->p;
230 if (n > 0) { 246 dbuf->p += n;
231 ret = dbuf->p; 247 }
232 dbuf->p += n;
233 } 248 }
234 249
235 return ret; 250 return ret;
@@ -636,7 +651,7 @@ v9fs_deserialize_fcall(struct v9fs_session_info *v9ses, u32 msgsize,
636 break; 651 break;
637 case RWALK: 652 case RWALK:
638 rcall->params.rwalk.nwqid = buf_get_int16(bufp); 653 rcall->params.rwalk.nwqid = buf_get_int16(bufp);
639 rcall->params.rwalk.wqids = buf_alloc(bufp, 654 rcall->params.rwalk.wqids = buf_alloc(dbufp,
640 rcall->params.rwalk.nwqid * sizeof(struct v9fs_qid)); 655 rcall->params.rwalk.nwqid * sizeof(struct v9fs_qid));
641 if (rcall->params.rwalk.wqids) 656 if (rcall->params.rwalk.wqids)
642 for (i = 0; i < rcall->params.rwalk.nwqid; i++) { 657 for (i = 0; i < rcall->params.rwalk.nwqid; i++) {
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index 821c9c4d76aa..d95f8626d170 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -71,21 +71,28 @@ static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry)
71 * 71 *
72 */ 72 */
73 73
74struct v9fs_fid *v9fs_fid_create(struct dentry *dentry) 74struct v9fs_fid *v9fs_fid_create(struct dentry *dentry,
75 struct v9fs_session_info *v9ses, int fid, int create)
75{ 76{
76 struct v9fs_fid *new; 77 struct v9fs_fid *new;
77 78
79 dprintk(DEBUG_9P, "fid create dentry %p, fid %d, create %d\n",
80 dentry, fid, create);
81
78 new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); 82 new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL);
79 if (new == NULL) { 83 if (new == NULL) {
80 dprintk(DEBUG_ERROR, "Out of Memory\n"); 84 dprintk(DEBUG_ERROR, "Out of Memory\n");
81 return ERR_PTR(-ENOMEM); 85 return ERR_PTR(-ENOMEM);
82 } 86 }
83 87
84 new->fid = -1; 88 new->fid = fid;
89 new->v9ses = v9ses;
85 new->fidopen = 0; 90 new->fidopen = 0;
86 new->fidcreate = 0; 91 new->fidcreate = create;
87 new->fidclunked = 0; 92 new->fidclunked = 0;
88 new->iounit = 0; 93 new->iounit = 0;
94 new->rdir_pos = 0;
95 new->rdir_fcall = NULL;
89 96
90 if (v9fs_fid_insert(new, dentry) == 0) 97 if (v9fs_fid_insert(new, dentry) == 0)
91 return new; 98 return new;
@@ -109,6 +116,59 @@ void v9fs_fid_destroy(struct v9fs_fid *fid)
109} 116}
110 117
111/** 118/**
119 * v9fs_fid_walk_up - walks from the process current directory
120 * up to the specified dentry.
121 */
122static struct v9fs_fid *v9fs_fid_walk_up(struct dentry *dentry)
123{
124 int fidnum, cfidnum, err;
125 struct v9fs_fid *cfid;
126 struct dentry *cde;
127 struct v9fs_session_info *v9ses;
128
129 v9ses = v9fs_inode2v9ses(current->fs->pwd->d_inode);
130 cfid = v9fs_fid_lookup(current->fs->pwd);
131 if (cfid == NULL) {
132 dprintk(DEBUG_ERROR, "process cwd doesn't have a fid\n");
133 return ERR_PTR(-ENOENT);
134 }
135
136 cfidnum = cfid->fid;
137 cde = current->fs->pwd;
138 /* TODO: take advantage of multiwalk */
139
140 fidnum = v9fs_get_idpool(&v9ses->fidpool);
141 if (fidnum < 0) {
142 dprintk(DEBUG_ERROR, "could not get a new fid num\n");
143 err = -ENOENT;
144 goto clunk_fid;
145 }
146
147 while (cde != dentry) {
148 if (cde == cde->d_parent) {
149 dprintk(DEBUG_ERROR, "can't find dentry\n");
150 err = -ENOENT;
151 goto clunk_fid;
152 }
153
154 err = v9fs_t_walk(v9ses, cfidnum, fidnum, "..", NULL);
155 if (err < 0) {
156 dprintk(DEBUG_ERROR, "problem walking to parent\n");
157 goto clunk_fid;
158 }
159
160 cfidnum = fidnum;
161 cde = cde->d_parent;
162 }
163
164 return v9fs_fid_create(dentry, v9ses, fidnum, 0);
165
166clunk_fid:
167 v9fs_t_clunk(v9ses, fidnum, NULL);
168 return ERR_PTR(err);
169}
170
171/**
112 * v9fs_fid_lookup - retrieve the right fid from a particular dentry 172 * v9fs_fid_lookup - retrieve the right fid from a particular dentry
113 * @dentry: dentry to look for fid in 173 * @dentry: dentry to look for fid in
114 * @type: intent of lookup (operation or traversal) 174 * @type: intent of lookup (operation or traversal)
@@ -119,49 +179,25 @@ void v9fs_fid_destroy(struct v9fs_fid *fid)
119 * 179 *
120 */ 180 */
121 181
122struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type) 182struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry)
123{ 183{
124 struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; 184 struct list_head *fid_list = (struct list_head *)dentry->d_fsdata;
125 struct v9fs_fid *current_fid = NULL; 185 struct v9fs_fid *current_fid = NULL;
126 struct v9fs_fid *temp = NULL; 186 struct v9fs_fid *temp = NULL;
127 struct v9fs_fid *return_fid = NULL; 187 struct v9fs_fid *return_fid = NULL;
128 int found_parent = 0;
129 int found_user = 0;
130 188
131 dprintk(DEBUG_9P, " dentry: %s (%p) type %d\n", dentry->d_iname, dentry, 189 dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry);
132 type);
133 190
134 if (fid_list && !list_empty(fid_list)) { 191 if (fid_list) {
135 list_for_each_entry_safe(current_fid, temp, fid_list, list) { 192 list_for_each_entry_safe(current_fid, temp, fid_list, list) {
136 if (current_fid->uid == current->uid) { 193 if (!current_fid->fidcreate) {
137 if (return_fid == NULL) { 194 return_fid = current_fid;
138 if ((type == FID_OP) 195 break;
139 || (!current_fid->fidopen)) {
140 return_fid = current_fid;
141 found_user = 1;
142 }
143 }
144 }
145 if (current_fid->pid == current->real_parent->pid) {
146 if ((return_fid == NULL) || (found_parent)
147 || (found_user)) {
148 if ((type == FID_OP)
149 || (!current_fid->fidopen)) {
150 return_fid = current_fid;
151 found_parent = 1;
152 found_user = 0;
153 }
154 }
155 }
156 if (current_fid->pid == current->pid) {
157 if ((type == FID_OP) ||
158 (!current_fid->fidopen)) {
159 return_fid = current_fid;
160 found_parent = 0;
161 found_user = 0;
162 }
163 } 196 }
164 } 197 }
198
199 if (!return_fid)
200 return_fid = current_fid;
165 } 201 }
166 202
167 /* we are at the root but didn't match */ 203 /* we are at the root but didn't match */
@@ -187,55 +223,33 @@ struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type)
187 223
188/* XXX - there may be some duplication we can get rid of */ 224/* XXX - there may be some duplication we can get rid of */
189 if (par == dentry) { 225 if (par == dentry) {
190 /* we need to fid_lookup the starting point */ 226 return_fid = v9fs_fid_walk_up(dentry);
191 int fidnum = -1; 227 if (IS_ERR(return_fid))
192 int oldfid = -1; 228 return_fid = NULL;
193 int result = -1; 229 }
194 struct v9fs_session_info *v9ses = 230 }
195 v9fs_inode2v9ses(current->fs->pwd->d_inode);
196
197 current_fid =
198 v9fs_fid_lookup(current->fs->pwd, FID_WALK);
199 if (current_fid == NULL) {
200 dprintk(DEBUG_ERROR,
201 "process cwd doesn't have a fid\n");
202 return return_fid;
203 }
204 oldfid = current_fid->fid;
205 par = current->fs->pwd;
206 /* TODO: take advantage of multiwalk */
207 231
208 fidnum = v9fs_get_idpool(&v9ses->fidpool); 232 return return_fid;
209 if (fidnum < 0) { 233}
210 dprintk(DEBUG_ERROR,
211 "could not get a new fid num\n");
212 return return_fid;
213 }
214 234
215 while (par != dentry) { 235struct v9fs_fid *v9fs_fid_get_created(struct dentry *dentry)
216 result = 236{
217 v9fs_t_walk(v9ses, oldfid, fidnum, "..", 237 struct list_head *fid_list;
218 NULL); 238 struct v9fs_fid *fid, *ftmp, *ret;
219 if (result < 0) { 239
220 dprintk(DEBUG_ERROR, 240 dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry);
221 "problem walking to parent\n"); 241 fid_list = (struct list_head *)dentry->d_fsdata;
222 242 ret = NULL;
223 break; 243 if (fid_list) {
224 } 244 list_for_each_entry_safe(fid, ftmp, fid_list, list) {
225 oldfid = fidnum; 245 if (fid->fidcreate && fid->pid == current->pid) {
226 if (par == par->d_parent) { 246 list_del(&fid->list);
227 dprintk(DEBUG_ERROR, 247 ret = fid;
228 "can't find dentry\n"); 248 break;
229 break;
230 }
231 par = par->d_parent;
232 }
233 if (par == dentry) {
234 return_fid = v9fs_fid_create(dentry);
235 return_fid->fid = fidnum;
236 } 249 }
237 } 250 }
238 } 251 }
239 252
240 return return_fid; 253 dprintk(DEBUG_9P, "return %p\n", ret);
254 return ret;
241} 255}
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 7db478ccca36..84c673a44c83 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -25,6 +25,7 @@
25 25
26#define FID_OP 0 26#define FID_OP 0
27#define FID_WALK 1 27#define FID_WALK 1
28#define FID_CREATE 2
28 29
29struct v9fs_fid { 30struct v9fs_fid {
30 struct list_head list; /* list of fids associated with a dentry */ 31 struct list_head list; /* list of fids associated with a dentry */
@@ -52,6 +53,8 @@ struct v9fs_fid {
52 struct v9fs_session_info *v9ses; /* session info for this FID */ 53 struct v9fs_session_info *v9ses; /* session info for this FID */
53}; 54};
54 55
55struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type); 56struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry);
57struct v9fs_fid *v9fs_fid_get_created(struct dentry *);
56void v9fs_fid_destroy(struct v9fs_fid *fid); 58void v9fs_fid_destroy(struct v9fs_fid *fid);
57struct v9fs_fid *v9fs_fid_create(struct dentry *); 59struct v9fs_fid *v9fs_fid_create(struct dentry *,
60 struct v9fs_session_info *v9ses, int fid, int create);
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 13bdbbab4387..82303f3bf76f 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -303,7 +303,13 @@ v9fs_session_init(struct v9fs_session_info *v9ses,
303 goto SessCleanUp; 303 goto SessCleanUp;
304 }; 304 };
305 305
306 v9ses->transport = trans_proto; 306 v9ses->transport = kmalloc(sizeof(*v9ses->transport), GFP_KERNEL);
307 if (!v9ses->transport) {
308 retval = -ENOMEM;
309 goto SessCleanUp;
310 }
311
312 memmove(v9ses->transport, trans_proto, sizeof(*v9ses->transport));
307 313
308 if ((retval = v9ses->transport->init(v9ses, dev_name, data)) < 0) { 314 if ((retval = v9ses->transport->init(v9ses, dev_name, data)) < 0) {
309 eprintk(KERN_ERR, "problem initializing transport\n"); 315 eprintk(KERN_ERR, "problem initializing transport\n");
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 306c96741f81..a6aa947de0f9 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -67,7 +67,7 @@ static int v9fs_dentry_validate(struct dentry *dentry, struct nameidata *nd)
67 struct dentry *dc = current->fs->pwd; 67 struct dentry *dc = current->fs->pwd;
68 68
69 dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); 69 dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry);
70 if (v9fs_fid_lookup(dentry, FID_OP)) { 70 if (v9fs_fid_lookup(dentry)) {
71 dprintk(DEBUG_VFS, "VALID\n"); 71 dprintk(DEBUG_VFS, "VALID\n");
72 return 1; 72 return 1;
73 } 73 }
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index c478a7384186..57a43b8feef5 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -197,21 +197,18 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
197 filemap_fdatawait(inode->i_mapping); 197 filemap_fdatawait(inode->i_mapping);
198 198
199 if (fidnum >= 0) { 199 if (fidnum >= 0) {
200 fid->fidopen--;
201 dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen, 200 dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen,
202 fid->fid); 201 fid->fid);
203 202
204 if (fid->fidopen == 0) { 203 if (v9fs_t_clunk(v9ses, fidnum, NULL))
205 if (v9fs_t_clunk(v9ses, fidnum, NULL)) 204 dprintk(DEBUG_ERROR, "clunk failed\n");
206 dprintk(DEBUG_ERROR, "clunk failed\n");
207 205
208 v9fs_put_idpool(fid->fid, &v9ses->fidpool); 206 v9fs_put_idpool(fid->fid, &v9ses->fidpool);
209 }
210 207
211 kfree(fid->rdir_fcall); 208 kfree(fid->rdir_fcall);
209 kfree(fid);
212 210
213 filp->private_data = NULL; 211 filp->private_data = NULL;
214 v9fs_fid_destroy(fid);
215 } 212 }
216 213
217 d_drop(filp->f_dentry); 214 d_drop(filp->f_dentry);
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 1f8ae7d580ab..bbc3cc63854f 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -53,30 +53,36 @@
53int v9fs_file_open(struct inode *inode, struct file *file) 53int v9fs_file_open(struct inode *inode, struct file *file)
54{ 54{
55 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); 55 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
56 struct v9fs_fid *v9fid = v9fs_fid_lookup(file->f_dentry, FID_WALK); 56 struct v9fs_fid *v9fid, *fid;
57 struct v9fs_fid *v9newfid = NULL;
58 struct v9fs_fcall *fcall = NULL; 57 struct v9fs_fcall *fcall = NULL;
59 int open_mode = 0; 58 int open_mode = 0;
60 unsigned int iounit = 0; 59 unsigned int iounit = 0;
61 int newfid = -1; 60 int newfid = -1;
62 long result = -1; 61 long result = -1;
63 62
64 dprintk(DEBUG_VFS, "inode: %p file: %p v9fid= %p\n", inode, file, 63 dprintk(DEBUG_VFS, "inode: %p file: %p \n", inode, file);
65 v9fid); 64
65 v9fid = v9fs_fid_get_created(file->f_dentry);
66 if (!v9fid)
67 v9fid = v9fs_fid_lookup(file->f_dentry);
66 68
67 if (!v9fid) { 69 if (!v9fid) {
68 struct dentry *dentry = file->f_dentry;
69 dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); 70 dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n");
71 return -EBADF;
72 }
70 73
71 /* XXX - some duplication from lookup, generalize later */ 74 if (!v9fid->fidcreate) {
72 /* basically vfs_lookup is too heavy weight */ 75 fid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL);
73 v9fid = v9fs_fid_lookup(file->f_dentry, FID_OP); 76 if (fid == NULL) {
74 if (!v9fid) 77 dprintk(DEBUG_ERROR, "Out of Memory\n");
75 return -EBADF; 78 return -ENOMEM;
79 }
76 80
77 v9fid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); 81 fid->fidopen = 0;
78 if (!v9fid) 82 fid->fidcreate = 0;
79 return -EBADF; 83 fid->fidclunked = 0;
84 fid->iounit = 0;
85 fid->v9ses = v9ses;
80 86
81 newfid = v9fs_get_idpool(&v9ses->fidpool); 87 newfid = v9fs_get_idpool(&v9ses->fidpool);
82 if (newfid < 0) { 88 if (newfid < 0) {
@@ -85,58 +91,16 @@ int v9fs_file_open(struct inode *inode, struct file *file)
85 } 91 }
86 92
87 result = 93 result =
88 v9fs_t_walk(v9ses, v9fid->fid, newfid, 94 v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, NULL);
89 (char *)file->f_dentry->d_name.name, NULL); 95
90 if (result < 0) { 96 if (result < 0) {
91 v9fs_put_idpool(newfid, &v9ses->fidpool); 97 v9fs_put_idpool(newfid, &v9ses->fidpool);
92 dprintk(DEBUG_ERROR, "rewalk didn't work\n"); 98 dprintk(DEBUG_ERROR, "rewalk didn't work\n");
93 return -EBADF; 99 return -EBADF;
94 } 100 }
95 101
96 v9fid = v9fs_fid_create(dentry); 102 fid->fid = newfid;
97 if (v9fid == NULL) { 103 v9fid = fid;
98 dprintk(DEBUG_ERROR, "couldn't insert\n");
99 return -ENOMEM;
100 }
101 v9fid->fid = newfid;
102 }
103
104 if (v9fid->fidcreate) {
105 /* create case */
106 newfid = v9fid->fid;
107 iounit = v9fid->iounit;
108 v9fid->fidcreate = 0;
109 } else {
110 if (!S_ISDIR(inode->i_mode))
111 newfid = v9fid->fid;
112 else {
113 newfid = v9fs_get_idpool(&v9ses->fidpool);
114 if (newfid < 0) {
115 eprintk(KERN_WARNING, "allocation failed\n");
116 return -ENOSPC;
117 }
118 /* This would be a somewhat critical clone */
119 result =
120 v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL,
121 &fcall);
122 if (result < 0) {
123 dprintk(DEBUG_ERROR, "clone error: %s\n",
124 FCALL_ERROR(fcall));
125 kfree(fcall);
126 return result;
127 }
128
129 v9newfid = v9fs_fid_create(file->f_dentry);
130 v9newfid->fid = newfid;
131 v9newfid->qid = v9fid->qid;
132 v9newfid->iounit = v9fid->iounit;
133 v9newfid->fidopen = 0;
134 v9newfid->fidclunked = 0;
135 v9newfid->v9ses = v9ses;
136 v9fid = v9newfid;
137 kfree(fcall);
138 }
139
140 /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ 104 /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
141 /* translate open mode appropriately */ 105 /* translate open mode appropriately */
142 open_mode = file->f_flags & 0x3; 106 open_mode = file->f_flags & 0x3;
@@ -163,9 +127,13 @@ int v9fs_file_open(struct inode *inode, struct file *file)
163 127
164 iounit = fcall->params.ropen.iounit; 128 iounit = fcall->params.ropen.iounit;
165 kfree(fcall); 129 kfree(fcall);
130 } else {
131 /* create case */
132 newfid = v9fid->fid;
133 iounit = v9fid->iounit;
134 v9fid->fidcreate = 0;
166 } 135 }
167 136
168
169 file->private_data = v9fid; 137 file->private_data = v9fid;
170 138
171 v9fid->rdir_pos = 0; 139 v9fid->rdir_pos = 0;
@@ -207,16 +175,16 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
207} 175}
208 176
209/** 177/**
210 * v9fs_read - read from a file (internal) 178 * v9fs_file_read - read from a file
211 * @filep: file pointer to read 179 * @filep: file pointer to read
212 * @data: data buffer to read data into 180 * @data: data buffer to read data into
213 * @count: size of buffer 181 * @count: size of buffer
214 * @offset: offset at which to read data 182 * @offset: offset at which to read data
215 * 183 *
216 */ 184 */
217
218static ssize_t 185static ssize_t
219v9fs_read(struct file *filp, char *buffer, size_t count, loff_t * offset) 186v9fs_file_read(struct file *filp, char __user * data, size_t count,
187 loff_t * offset)
220{ 188{
221 struct inode *inode = filp->f_dentry->d_inode; 189 struct inode *inode = filp->f_dentry->d_inode;
222 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); 190 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
@@ -226,6 +194,7 @@ v9fs_read(struct file *filp, char *buffer, size_t count, loff_t * offset)
226 int rsize = 0; 194 int rsize = 0;
227 int result = 0; 195 int result = 0;
228 int total = 0; 196 int total = 0;
197 int n;
229 198
230 dprintk(DEBUG_VFS, "\n"); 199 dprintk(DEBUG_VFS, "\n");
231 200
@@ -248,10 +217,15 @@ v9fs_read(struct file *filp, char *buffer, size_t count, loff_t * offset)
248 } else 217 } else
249 *offset += result; 218 *offset += result;
250 219
251 /* XXX - extra copy */ 220 n = copy_to_user(data, fcall->params.rread.data, result);
252 memcpy(buffer, fcall->params.rread.data, result); 221 if (n) {
222 dprintk(DEBUG_ERROR, "Problem copying to user %d\n", n);
223 kfree(fcall);
224 return -EFAULT;
225 }
226
253 count -= result; 227 count -= result;
254 buffer += result; 228 data += result;
255 total += result; 229 total += result;
256 230
257 kfree(fcall); 231 kfree(fcall);
@@ -264,42 +238,7 @@ v9fs_read(struct file *filp, char *buffer, size_t count, loff_t * offset)
264} 238}
265 239
266/** 240/**
267 * v9fs_file_read - read from a file 241 * v9fs_file_write - write to a file
268 * @filep: file pointer to read
269 * @data: data buffer to read data into
270 * @count: size of buffer
271 * @offset: offset at which to read data
272 *
273 */
274
275static ssize_t
276v9fs_file_read(struct file *filp, char __user * data, size_t count,
277 loff_t * offset)
278{
279 int retval = -1;
280 int ret = 0;
281 char *buffer;
282
283 buffer = kmalloc(count, GFP_KERNEL);
284 if (!buffer)
285 return -ENOMEM;
286
287 retval = v9fs_read(filp, buffer, count, offset);
288 if (retval > 0) {
289 if ((ret = copy_to_user(data, buffer, retval)) != 0) {
290 dprintk(DEBUG_ERROR, "Problem copying to user %d\n",
291 ret);
292 retval = ret;
293 }
294 }
295
296 kfree(buffer);
297
298 return retval;
299}
300
301/**
302 * v9fs_write - write to a file
303 * @filep: file pointer to write 242 * @filep: file pointer to write
304 * @data: data buffer to write data from 243 * @data: data buffer to write data from
305 * @count: size of buffer 244 * @count: size of buffer
@@ -308,7 +247,8 @@ v9fs_file_read(struct file *filp, char __user * data, size_t count,
308 */ 247 */
309 248
310static ssize_t 249static ssize_t
311v9fs_write(struct file *filp, char *buffer, size_t count, loff_t * offset) 250v9fs_file_write(struct file *filp, const char __user * data,
251 size_t count, loff_t * offset)
312{ 252{
313 struct inode *inode = filp->f_dentry->d_inode; 253 struct inode *inode = filp->f_dentry->d_inode;
314 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); 254 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
@@ -318,30 +258,42 @@ v9fs_write(struct file *filp, char *buffer, size_t count, loff_t * offset)
318 int result = -EIO; 258 int result = -EIO;
319 int rsize = 0; 259 int rsize = 0;
320 int total = 0; 260 int total = 0;
261 char *buf;
321 262
322 dprintk(DEBUG_VFS, "data %p count %d offset %x\n", buffer, (int)count, 263 dprintk(DEBUG_VFS, "data %p count %d offset %x\n", data, (int)count,
323 (int)*offset); 264 (int)*offset);
324 rsize = v9ses->maxdata - V9FS_IOHDRSZ; 265 rsize = v9ses->maxdata - V9FS_IOHDRSZ;
325 if (v9fid->iounit != 0 && rsize > v9fid->iounit) 266 if (v9fid->iounit != 0 && rsize > v9fid->iounit)
326 rsize = v9fid->iounit; 267 rsize = v9fid->iounit;
327 268
328 dump_data(buffer, count); 269 buf = kmalloc(v9ses->maxdata - V9FS_IOHDRSZ, GFP_KERNEL);
270 if (!buf)
271 return -ENOMEM;
329 272
330 do { 273 do {
331 if (count < rsize) 274 if (count < rsize)
332 rsize = count; 275 rsize = count;
333 276
334 result = 277 result = copy_from_user(buf, data, rsize);
335 v9fs_t_write(v9ses, fid, *offset, rsize, buffer, &fcall); 278 if (result) {
279 dprintk(DEBUG_ERROR, "Problem copying from user\n");
280 kfree(buf);
281 return -EFAULT;
282 }
283
284 dump_data(buf, rsize);
285 result = v9fs_t_write(v9ses, fid, *offset, rsize, buf, &fcall);
336 if (result < 0) { 286 if (result < 0) {
337 eprintk(KERN_ERR, "error while writing: %s(%d)\n", 287 eprintk(KERN_ERR, "error while writing: %s(%d)\n",
338 FCALL_ERROR(fcall), result); 288 FCALL_ERROR(fcall), result);
339 kfree(fcall); 289 kfree(fcall);
290 kfree(buf);
340 return result; 291 return result;
341 } else 292 } else
342 *offset += result; 293 *offset += result;
343 294
344 kfree(fcall); 295 kfree(fcall);
296 fcall = NULL;
345 297
346 if (result != rsize) { 298 if (result != rsize) {
347 eprintk(KERN_ERR, 299 eprintk(KERN_ERR,
@@ -351,46 +303,14 @@ v9fs_write(struct file *filp, char *buffer, size_t count, loff_t * offset)
351 } 303 }
352 304
353 count -= result; 305 count -= result;
354 buffer += result; 306 data += result;
355 total += result; 307 total += result;
356 } while (count); 308 } while (count);
357 309
310 kfree(buf);
358 return total; 311 return total;
359} 312}
360 313
361/**
362 * v9fs_file_write - write to a file
363 * @filep: file pointer to write
364 * @data: data buffer to write data from
365 * @count: size of buffer
366 * @offset: offset at which to write data
367 *
368 */
369
370static ssize_t
371v9fs_file_write(struct file *filp, const char __user * data,
372 size_t count, loff_t * offset)
373{
374 int ret = -1;
375 char *buffer;
376
377 buffer = kmalloc(count, GFP_KERNEL);
378 if (buffer == NULL)
379 return -ENOMEM;
380
381 ret = copy_from_user(buffer, data, count);
382 if (ret) {
383 dprintk(DEBUG_ERROR, "Problem copying from user\n");
384 ret = -EFAULT;
385 } else {
386 ret = v9fs_write(filp, buffer, count, offset);
387 }
388
389 kfree(buffer);
390
391 return ret;
392}
393
394struct file_operations v9fs_file_operations = { 314struct file_operations v9fs_file_operations = {
395 .llseek = generic_file_llseek, 315 .llseek = generic_file_llseek,
396 .read = v9fs_file_read, 316 .read = v9fs_file_read,
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 0c13fc600049..2b696ae6655a 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -307,7 +307,7 @@ v9fs_create(struct inode *dir,
307 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); 307 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
308 struct super_block *sb = dir->i_sb; 308 struct super_block *sb = dir->i_sb;
309 struct v9fs_fid *dirfid = 309 struct v9fs_fid *dirfid =
310 v9fs_fid_lookup(file_dentry->d_parent, FID_WALK); 310 v9fs_fid_lookup(file_dentry->d_parent);
311 struct v9fs_fid *fid = NULL; 311 struct v9fs_fid *fid = NULL;
312 struct inode *file_inode = NULL; 312 struct inode *file_inode = NULL;
313 struct v9fs_fcall *fcall = NULL; 313 struct v9fs_fcall *fcall = NULL;
@@ -317,6 +317,7 @@ v9fs_create(struct inode *dir,
317 long newfid = -1; 317 long newfid = -1;
318 int result = 0; 318 int result = 0;
319 unsigned int iounit = 0; 319 unsigned int iounit = 0;
320 int wfidno = -1;
320 321
321 perm = unixmode2p9mode(v9ses, perm); 322 perm = unixmode2p9mode(v9ses, perm);
322 323
@@ -350,7 +351,7 @@ v9fs_create(struct inode *dir,
350 if (result < 0) { 351 if (result < 0) {
351 dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); 352 dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall));
352 v9fs_put_idpool(newfid, &v9ses->fidpool); 353 v9fs_put_idpool(newfid, &v9ses->fidpool);
353 newfid = 0; 354 newfid = -1;
354 goto CleanUpFid; 355 goto CleanUpFid;
355 } 356 }
356 357
@@ -369,20 +370,39 @@ v9fs_create(struct inode *dir,
369 qid = fcall->params.rcreate.qid; 370 qid = fcall->params.rcreate.qid;
370 kfree(fcall); 371 kfree(fcall);
371 372
372 fid = v9fs_fid_create(file_dentry); 373 fid = v9fs_fid_create(file_dentry, v9ses, newfid, 1);
374 dprintk(DEBUG_VFS, "fid %p %d\n", fid, fid->fidcreate);
373 if (!fid) { 375 if (!fid) {
374 result = -ENOMEM; 376 result = -ENOMEM;
375 goto CleanUpFid; 377 goto CleanUpFid;
376 } 378 }
377 379
378 fid->fid = newfid;
379 fid->fidopen = 0;
380 fid->fidcreate = 1;
381 fid->qid = qid; 380 fid->qid = qid;
382 fid->iounit = iounit; 381 fid->iounit = iounit;
383 fid->rdir_pos = 0; 382
384 fid->rdir_fcall = NULL; 383 /* walk to the newly created file and put the fid in the dentry */
385 fid->v9ses = v9ses; 384 wfidno = v9fs_get_idpool(&v9ses->fidpool);
385 if (newfid < 0) {
386 eprintk(KERN_WARNING, "no free fids available\n");
387 return -ENOSPC;
388 }
389
390 result = v9fs_t_walk(v9ses, dirfidnum, wfidno,
391 (char *) file_dentry->d_name.name, NULL);
392 if (result < 0) {
393 dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall));
394 v9fs_put_idpool(wfidno, &v9ses->fidpool);
395 wfidno = -1;
396 goto CleanUpFid;
397 }
398
399 if (!v9fs_fid_create(file_dentry, v9ses, wfidno, 0)) {
400 if (!v9fs_t_clunk(v9ses, newfid, &fcall)) {
401 v9fs_put_idpool(wfidno, &v9ses->fidpool);
402 }
403
404 goto CleanUpFid;
405 }
386 406
387 if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || 407 if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) ||
388 (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || 408 (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) ||
@@ -410,11 +430,11 @@ v9fs_create(struct inode *dir,
410 d_instantiate(file_dentry, file_inode); 430 d_instantiate(file_dentry, file_inode);
411 431
412 if (perm & V9FS_DMDIR) { 432 if (perm & V9FS_DMDIR) {
413 if (v9fs_t_clunk(v9ses, newfid, &fcall)) 433 if (!v9fs_t_clunk(v9ses, newfid, &fcall))
434 v9fs_put_idpool(newfid, &v9ses->fidpool);
435 else
414 dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n", 436 dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n",
415 FCALL_ERROR(fcall)); 437 FCALL_ERROR(fcall));
416
417 v9fs_put_idpool(newfid, &v9ses->fidpool);
418 kfree(fcall); 438 kfree(fcall);
419 fid->fidopen = 0; 439 fid->fidopen = 0;
420 fid->fidcreate = 0; 440 fid->fidcreate = 0;
@@ -426,12 +446,22 @@ v9fs_create(struct inode *dir,
426 CleanUpFid: 446 CleanUpFid:
427 kfree(fcall); 447 kfree(fcall);
428 448
429 if (newfid) { 449 if (newfid >= 0) {
430 if (v9fs_t_clunk(v9ses, newfid, &fcall)) 450 if (!v9fs_t_clunk(v9ses, newfid, &fcall))
451 v9fs_put_idpool(newfid, &v9ses->fidpool);
452 else
453 dprintk(DEBUG_ERROR, "clunk failed: %s\n",
454 FCALL_ERROR(fcall));
455
456 kfree(fcall);
457 }
458 if (wfidno >= 0) {
459 if (!v9fs_t_clunk(v9ses, wfidno, &fcall))
460 v9fs_put_idpool(wfidno, &v9ses->fidpool);
461 else
431 dprintk(DEBUG_ERROR, "clunk failed: %s\n", 462 dprintk(DEBUG_ERROR, "clunk failed: %s\n",
432 FCALL_ERROR(fcall)); 463 FCALL_ERROR(fcall));
433 464
434 v9fs_put_idpool(newfid, &v9ses->fidpool);
435 kfree(fcall); 465 kfree(fcall);
436 } 466 }
437 return result; 467 return result;
@@ -461,7 +491,7 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
461 file_inode = file->d_inode; 491 file_inode = file->d_inode;
462 sb = file_inode->i_sb; 492 sb = file_inode->i_sb;
463 v9ses = v9fs_inode2v9ses(file_inode); 493 v9ses = v9fs_inode2v9ses(file_inode);
464 v9fid = v9fs_fid_lookup(file, FID_OP); 494 v9fid = v9fs_fid_lookup(file);
465 495
466 if (!v9fid) { 496 if (!v9fid) {
467 dprintk(DEBUG_ERROR, 497 dprintk(DEBUG_ERROR,
@@ -545,7 +575,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
545 575
546 sb = dir->i_sb; 576 sb = dir->i_sb;
547 v9ses = v9fs_inode2v9ses(dir); 577 v9ses = v9fs_inode2v9ses(dir);
548 dirfid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); 578 dirfid = v9fs_fid_lookup(dentry->d_parent);
549 579
550 if (!dirfid) { 580 if (!dirfid) {
551 dprintk(DEBUG_ERROR, "no dirfid\n"); 581 dprintk(DEBUG_ERROR, "no dirfid\n");
@@ -573,7 +603,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
573 v9fs_put_idpool(newfid, &v9ses->fidpool); 603 v9fs_put_idpool(newfid, &v9ses->fidpool);
574 if (result == -ENOENT) { 604 if (result == -ENOENT) {
575 d_add(dentry, NULL); 605 d_add(dentry, NULL);
576 dprintk(DEBUG_ERROR, 606 dprintk(DEBUG_VFS,
577 "Return negative dentry %p count %d\n", 607 "Return negative dentry %p count %d\n",
578 dentry, atomic_read(&dentry->d_count)); 608 dentry, atomic_read(&dentry->d_count));
579 return NULL; 609 return NULL;
@@ -601,16 +631,13 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
601 631
602 inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); 632 inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid);
603 633
604 fid = v9fs_fid_create(dentry); 634 fid = v9fs_fid_create(dentry, v9ses, newfid, 0);
605 if (fid == NULL) { 635 if (fid == NULL) {
606 dprintk(DEBUG_ERROR, "couldn't insert\n"); 636 dprintk(DEBUG_ERROR, "couldn't insert\n");
607 result = -ENOMEM; 637 result = -ENOMEM;
608 goto FreeFcall; 638 goto FreeFcall;
609 } 639 }
610 640
611 fid->fid = newfid;
612 fid->fidopen = 0;
613 fid->v9ses = v9ses;
614 fid->qid = fcall->params.rstat.stat->qid; 641 fid->qid = fcall->params.rstat.stat->qid;
615 642
616 dentry->d_op = &v9fs_dentry_operations; 643 dentry->d_op = &v9fs_dentry_operations;
@@ -665,11 +692,11 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
665{ 692{
666 struct inode *old_inode = old_dentry->d_inode; 693 struct inode *old_inode = old_dentry->d_inode;
667 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode); 694 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode);
668 struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_WALK); 695 struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry);
669 struct v9fs_fid *olddirfid = 696 struct v9fs_fid *olddirfid =
670 v9fs_fid_lookup(old_dentry->d_parent, FID_WALK); 697 v9fs_fid_lookup(old_dentry->d_parent);
671 struct v9fs_fid *newdirfid = 698 struct v9fs_fid *newdirfid =
672 v9fs_fid_lookup(new_dentry->d_parent, FID_WALK); 699 v9fs_fid_lookup(new_dentry->d_parent);
673 struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); 700 struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
674 struct v9fs_fcall *fcall = NULL; 701 struct v9fs_fcall *fcall = NULL;
675 int fid = -1; 702 int fid = -1;
@@ -744,7 +771,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
744{ 771{
745 struct v9fs_fcall *fcall = NULL; 772 struct v9fs_fcall *fcall = NULL;
746 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); 773 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode);
747 struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); 774 struct v9fs_fid *fid = v9fs_fid_lookup(dentry);
748 int err = -EPERM; 775 int err = -EPERM;
749 776
750 dprintk(DEBUG_VFS, "dentry: %p\n", dentry); 777 dprintk(DEBUG_VFS, "dentry: %p\n", dentry);
@@ -778,7 +805,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
778static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) 805static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
779{ 806{
780 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); 807 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode);
781 struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); 808 struct v9fs_fid *fid = v9fs_fid_lookup(dentry);
782 struct v9fs_fcall *fcall = NULL; 809 struct v9fs_fcall *fcall = NULL;
783 struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); 810 struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
784 int res = -EPERM; 811 int res = -EPERM;
@@ -960,7 +987,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
960 if (retval != 0) 987 if (retval != 0)
961 goto FreeFcall; 988 goto FreeFcall;
962 989
963 newfid = v9fs_fid_lookup(dentry, FID_OP); 990 newfid = v9fs_fid_lookup(dentry);
964 991
965 /* issue a twstat */ 992 /* issue a twstat */
966 v9fs_blank_mistat(v9ses, mistat); 993 v9fs_blank_mistat(v9ses, mistat);
@@ -1004,7 +1031,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
1004 1031
1005 struct v9fs_fcall *fcall = NULL; 1032 struct v9fs_fcall *fcall = NULL;
1006 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); 1033 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode);
1007 struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); 1034 struct v9fs_fid *fid = v9fs_fid_lookup(dentry);
1008 1035
1009 if (!fid) { 1036 if (!fid) {
1010 dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n"); 1037 dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n");
@@ -1063,8 +1090,8 @@ static int v9fs_vfs_readlink(struct dentry *dentry, char __user * buffer,
1063 int ret; 1090 int ret;
1064 char *link = __getname(); 1091 char *link = __getname();
1065 1092
1066 if (strlen(link) < buflen) 1093 if (buflen > PATH_MAX)
1067 buflen = strlen(link); 1094 buflen = PATH_MAX;
1068 1095
1069 dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry); 1096 dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry);
1070 1097
@@ -1148,7 +1175,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1148 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); 1175 struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
1149 struct v9fs_fcall *fcall = NULL; 1176 struct v9fs_fcall *fcall = NULL;
1150 struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); 1177 struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL);
1151 struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_OP); 1178 struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry);
1152 struct v9fs_fid *newfid = NULL; 1179 struct v9fs_fid *newfid = NULL;
1153 char *symname = __getname(); 1180 char *symname = __getname();
1154 1181
@@ -1168,7 +1195,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1168 if (retval != 0) 1195 if (retval != 0)
1169 goto FreeMem; 1196 goto FreeMem;
1170 1197
1171 newfid = v9fs_fid_lookup(dentry, FID_OP); 1198 newfid = v9fs_fid_lookup(dentry);
1172 if (!newfid) { 1199 if (!newfid) {
1173 dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); 1200 dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n");
1174 goto FreeMem; 1201 goto FreeMem;
@@ -1246,7 +1273,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1246 if (retval != 0) 1273 if (retval != 0)
1247 goto FreeMem; 1274 goto FreeMem;
1248 1275
1249 newfid = v9fs_fid_lookup(dentry, FID_OP); 1276 newfid = v9fs_fid_lookup(dentry);
1250 if (!newfid) { 1277 if (!newfid) {
1251 dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n"); 1278 dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n");
1252 retval = -EINVAL; 1279 retval = -EINVAL;
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 868f350b2c5f..82c5b0084079 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -129,8 +129,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type
129 129
130 if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { 130 if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) {
131 dprintk(DEBUG_ERROR, "problem initiating session\n"); 131 dprintk(DEBUG_ERROR, "problem initiating session\n");
132 retval = newfid; 132 return ERR_PTR(newfid);
133 goto free_session;
134 } 133 }
135 134
136 sb = sget(fs_type, NULL, v9fs_set_super, v9ses); 135 sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
@@ -150,28 +149,24 @@ static struct super_block *v9fs_get_sb(struct file_system_type
150 149
151 if (!root) { 150 if (!root) {
152 retval = -ENOMEM; 151 retval = -ENOMEM;
153 goto release_inode; 152 goto put_back_sb;
154 } 153 }
155 154
156 sb->s_root = root; 155 sb->s_root = root;
157 156
158 /* Setup the Root Inode */
159 root_fid = v9fs_fid_create(root);
160 if (root_fid == NULL) {
161 retval = -ENOMEM;
162 goto release_dentry;
163 }
164
165 root_fid->fidopen = 0;
166 root_fid->v9ses = v9ses;
167
168 stat_result = v9fs_t_stat(v9ses, newfid, &fcall); 157 stat_result = v9fs_t_stat(v9ses, newfid, &fcall);
169 if (stat_result < 0) { 158 if (stat_result < 0) {
170 dprintk(DEBUG_ERROR, "stat error\n"); 159 dprintk(DEBUG_ERROR, "stat error\n");
171 v9fs_t_clunk(v9ses, newfid, NULL); 160 v9fs_t_clunk(v9ses, newfid, NULL);
172 v9fs_put_idpool(newfid, &v9ses->fidpool); 161 v9fs_put_idpool(newfid, &v9ses->fidpool);
173 } else { 162 } else {
174 root_fid->fid = newfid; 163 /* Setup the Root Inode */
164 root_fid = v9fs_fid_create(root, v9ses, newfid, 0);
165 if (root_fid == NULL) {
166 retval = -ENOMEM;
167 goto put_back_sb;
168 }
169
175 root_fid->qid = fcall->params.rstat.stat->qid; 170 root_fid->qid = fcall->params.rstat.stat->qid;
176 root->d_inode->i_ino = 171 root->d_inode->i_ino =
177 v9fs_qid2ino(&fcall->params.rstat.stat->qid); 172 v9fs_qid2ino(&fcall->params.rstat.stat->qid);
@@ -182,25 +177,15 @@ static struct super_block *v9fs_get_sb(struct file_system_type
182 177
183 if (stat_result < 0) { 178 if (stat_result < 0) {
184 retval = stat_result; 179 retval = stat_result;
185 goto release_dentry; 180 goto put_back_sb;
186 } 181 }
187 182
188 return sb; 183 return sb;
189 184
190 release_dentry: 185put_back_sb:
191 dput(sb->s_root); 186 /* deactivate_super calls v9fs_kill_super which will frees the rest */
192
193 release_inode:
194 iput(inode);
195
196 put_back_sb:
197 up_write(&sb->s_umount); 187 up_write(&sb->s_umount);
198 deactivate_super(sb); 188 deactivate_super(sb);
199 v9fs_session_close(v9ses);
200
201 free_session:
202 kfree(v9ses);
203
204 return ERR_PTR(retval); 189 return ERR_PTR(retval);
205} 190}
206 191
diff --git a/fs/Kconfig b/fs/Kconfig
index 068ccea2f184..48f5422cb19a 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -472,6 +472,9 @@ config FUSE_FS
472 utilities is available from the FUSE homepage: 472 utilities is available from the FUSE homepage:
473 <http://fuse.sourceforge.net/> 473 <http://fuse.sourceforge.net/>
474 474
475 See <file:Documentation/filesystems/fuse.txt> for more information.
476 See <file:Documentation/Changes> for needed library/utility version.
477
475 If you want to develop a userspace FS, or if you want to use 478 If you want to develop a userspace FS, or if you want to use
476 a filesystem based on FUSE, answer Y or M. 479 a filesystem based on FUSE, answer Y or M.
477 480
diff --git a/fs/aio.c b/fs/aio.c
index 38f62680fd63..edfca5b75535 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -398,7 +398,7 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx)
398 if (unlikely(!req)) 398 if (unlikely(!req))
399 return NULL; 399 return NULL;
400 400
401 req->ki_flags = 1 << KIF_LOCKED; 401 req->ki_flags = 0;
402 req->ki_users = 2; 402 req->ki_users = 2;
403 req->ki_key = 0; 403 req->ki_key = 0;
404 req->ki_ctx = ctx; 404 req->ki_ctx = ctx;
@@ -547,24 +547,6 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id)
547 return ioctx; 547 return ioctx;
548} 548}
549 549
550static int lock_kiocb_action(void *param)
551{
552 schedule();
553 return 0;
554}
555
556static inline void lock_kiocb(struct kiocb *iocb)
557{
558 wait_on_bit_lock(&iocb->ki_flags, KIF_LOCKED, lock_kiocb_action,
559 TASK_UNINTERRUPTIBLE);
560}
561
562static inline void unlock_kiocb(struct kiocb *iocb)
563{
564 kiocbClearLocked(iocb);
565 wake_up_bit(&iocb->ki_flags, KIF_LOCKED);
566}
567
568/* 550/*
569 * use_mm 551 * use_mm
570 * Makes the calling kernel thread take on the specified 552 * Makes the calling kernel thread take on the specified
@@ -740,19 +722,9 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
740 ret = retry(iocb); 722 ret = retry(iocb);
741 current->io_wait = NULL; 723 current->io_wait = NULL;
742 724
743 if (-EIOCBRETRY != ret) { 725 if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) {
744 if (-EIOCBQUEUED != ret) { 726 BUG_ON(!list_empty(&iocb->ki_wait.task_list));
745 BUG_ON(!list_empty(&iocb->ki_wait.task_list)); 727 aio_complete(iocb, ret, 0);
746 aio_complete(iocb, ret, 0);
747 /* must not access the iocb after this */
748 }
749 } else {
750 /*
751 * Issue an additional retry to avoid waiting forever if
752 * no waits were queued (e.g. in case of a short read).
753 */
754 if (list_empty(&iocb->ki_wait.task_list))
755 kiocbSetKicked(iocb);
756 } 728 }
757out: 729out:
758 spin_lock_irq(&ctx->ctx_lock); 730 spin_lock_irq(&ctx->ctx_lock);
@@ -805,9 +777,7 @@ static int __aio_run_iocbs(struct kioctx *ctx)
805 * Hold an extra reference while retrying i/o. 777 * Hold an extra reference while retrying i/o.
806 */ 778 */
807 iocb->ki_users++; /* grab extra reference */ 779 iocb->ki_users++; /* grab extra reference */
808 lock_kiocb(iocb);
809 aio_run_iocb(iocb); 780 aio_run_iocb(iocb);
810 unlock_kiocb(iocb);
811 if (__aio_put_req(ctx, iocb)) /* drop extra ref */ 781 if (__aio_put_req(ctx, iocb)) /* drop extra ref */
812 put_ioctx(ctx); 782 put_ioctx(ctx);
813 } 783 }
@@ -898,16 +868,24 @@ static void aio_kick_handler(void *data)
898 * and if required activate the aio work queue to process 868 * and if required activate the aio work queue to process
899 * it 869 * it
900 */ 870 */
901static void queue_kicked_iocb(struct kiocb *iocb) 871static void try_queue_kicked_iocb(struct kiocb *iocb)
902{ 872{
903 struct kioctx *ctx = iocb->ki_ctx; 873 struct kioctx *ctx = iocb->ki_ctx;
904 unsigned long flags; 874 unsigned long flags;
905 int run = 0; 875 int run = 0;
906 876
907 WARN_ON((!list_empty(&iocb->ki_wait.task_list))); 877 /* We're supposed to be the only path putting the iocb back on the run
878 * list. If we find that the iocb is *back* on a wait queue already
879 * than retry has happened before we could queue the iocb. This also
880 * means that the retry could have completed and freed our iocb, no
881 * good. */
882 BUG_ON((!list_empty(&iocb->ki_wait.task_list)));
908 883
909 spin_lock_irqsave(&ctx->ctx_lock, flags); 884 spin_lock_irqsave(&ctx->ctx_lock, flags);
910 run = __queue_kicked_iocb(iocb); 885 /* set this inside the lock so that we can't race with aio_run_iocb()
886 * testing it and putting the iocb on the run list under the lock */
887 if (!kiocbTryKick(iocb))
888 run = __queue_kicked_iocb(iocb);
911 spin_unlock_irqrestore(&ctx->ctx_lock, flags); 889 spin_unlock_irqrestore(&ctx->ctx_lock, flags);
912 if (run) 890 if (run)
913 aio_queue_work(ctx); 891 aio_queue_work(ctx);
@@ -930,10 +908,7 @@ void fastcall kick_iocb(struct kiocb *iocb)
930 return; 908 return;
931 } 909 }
932 910
933 /* If its already kicked we shouldn't queue it again */ 911 try_queue_kicked_iocb(iocb);
934 if (!kiocbTryKick(iocb)) {
935 queue_kicked_iocb(iocb);
936 }
937} 912}
938EXPORT_SYMBOL(kick_iocb); 913EXPORT_SYMBOL(kick_iocb);
939 914
@@ -1321,8 +1296,11 @@ asmlinkage long sys_io_destroy(aio_context_t ctx)
1321} 1296}
1322 1297
1323/* 1298/*
1324 * Default retry method for aio_read (also used for first time submit) 1299 * aio_p{read,write} are the default ki_retry methods for
1325 * Responsible for updating iocb state as retries progress 1300 * IO_CMD_P{READ,WRITE}. They maintains kiocb retry state around potentially
1301 * multiple calls to f_op->aio_read(). They loop around partial progress
1302 * instead of returning -EIOCBRETRY because they don't have the means to call
1303 * kick_iocb().
1326 */ 1304 */
1327static ssize_t aio_pread(struct kiocb *iocb) 1305static ssize_t aio_pread(struct kiocb *iocb)
1328{ 1306{
@@ -1331,25 +1309,25 @@ static ssize_t aio_pread(struct kiocb *iocb)
1331 struct inode *inode = mapping->host; 1309 struct inode *inode = mapping->host;
1332 ssize_t ret = 0; 1310 ssize_t ret = 0;
1333 1311
1334 ret = file->f_op->aio_read(iocb, iocb->ki_buf, 1312 do {
1335 iocb->ki_left, iocb->ki_pos); 1313 ret = file->f_op->aio_read(iocb, iocb->ki_buf,
1314 iocb->ki_left, iocb->ki_pos);
1315 /*
1316 * Can't just depend on iocb->ki_left to determine
1317 * whether we are done. This may have been a short read.
1318 */
1319 if (ret > 0) {
1320 iocb->ki_buf += ret;
1321 iocb->ki_left -= ret;
1322 }
1336 1323
1337 /*
1338 * Can't just depend on iocb->ki_left to determine
1339 * whether we are done. This may have been a short read.
1340 */
1341 if (ret > 0) {
1342 iocb->ki_buf += ret;
1343 iocb->ki_left -= ret;
1344 /* 1324 /*
1345 * For pipes and sockets we return once we have 1325 * For pipes and sockets we return once we have some data; for
1346 * some data; for regular files we retry till we 1326 * regular files we retry till we complete the entire read or
1347 * complete the entire read or find that we can't 1327 * find that we can't read any more data (e.g short reads).
1348 * read any more data (e.g short reads).
1349 */ 1328 */
1350 if (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode)) 1329 } while (ret > 0 && iocb->ki_left > 0 &&
1351 ret = -EIOCBRETRY; 1330 !S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode));
1352 }
1353 1331
1354 /* This means we must have transferred all that we could */ 1332 /* This means we must have transferred all that we could */
1355 /* No need to retry anymore */ 1333 /* No need to retry anymore */
@@ -1359,27 +1337,21 @@ static ssize_t aio_pread(struct kiocb *iocb)
1359 return ret; 1337 return ret;
1360} 1338}
1361 1339
1362/* 1340/* see aio_pread() */
1363 * Default retry method for aio_write (also used for first time submit)
1364 * Responsible for updating iocb state as retries progress
1365 */
1366static ssize_t aio_pwrite(struct kiocb *iocb) 1341static ssize_t aio_pwrite(struct kiocb *iocb)
1367{ 1342{
1368 struct file *file = iocb->ki_filp; 1343 struct file *file = iocb->ki_filp;
1369 ssize_t ret = 0; 1344 ssize_t ret = 0;
1370 1345
1371 ret = file->f_op->aio_write(iocb, iocb->ki_buf, 1346 do {
1372 iocb->ki_left, iocb->ki_pos); 1347 ret = file->f_op->aio_write(iocb, iocb->ki_buf,
1373 1348 iocb->ki_left, iocb->ki_pos);
1374 if (ret > 0) { 1349 if (ret > 0) {
1375 iocb->ki_buf += ret; 1350 iocb->ki_buf += ret;
1376 iocb->ki_left -= ret; 1351 iocb->ki_left -= ret;
1377 1352 }
1378 ret = -EIOCBRETRY; 1353 } while (ret > 0 && iocb->ki_left > 0);
1379 }
1380 1354
1381 /* This means we must have transferred all that we could */
1382 /* No need to retry anymore */
1383 if ((ret == 0) || (iocb->ki_left == 0)) 1355 if ((ret == 0) || (iocb->ki_left == 0))
1384 ret = iocb->ki_nbytes - iocb->ki_left; 1356 ret = iocb->ki_nbytes - iocb->ki_left;
1385 1357
@@ -1425,6 +1397,9 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb)
1425 if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf, 1397 if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf,
1426 kiocb->ki_left))) 1398 kiocb->ki_left)))
1427 break; 1399 break;
1400 ret = security_file_permission(file, MAY_READ);
1401 if (unlikely(ret))
1402 break;
1428 ret = -EINVAL; 1403 ret = -EINVAL;
1429 if (file->f_op->aio_read) 1404 if (file->f_op->aio_read)
1430 kiocb->ki_retry = aio_pread; 1405 kiocb->ki_retry = aio_pread;
@@ -1437,6 +1412,9 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb)
1437 if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf, 1412 if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf,
1438 kiocb->ki_left))) 1413 kiocb->ki_left)))
1439 break; 1414 break;
1415 ret = security_file_permission(file, MAY_WRITE);
1416 if (unlikely(ret))
1417 break;
1440 ret = -EINVAL; 1418 ret = -EINVAL;
1441 if (file->f_op->aio_write) 1419 if (file->f_op->aio_write)
1442 kiocb->ki_retry = aio_pwrite; 1420 kiocb->ki_retry = aio_pwrite;
@@ -1549,7 +1527,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1549 1527
1550 spin_lock_irq(&ctx->ctx_lock); 1528 spin_lock_irq(&ctx->ctx_lock);
1551 aio_run_iocb(req); 1529 aio_run_iocb(req);
1552 unlock_kiocb(req);
1553 if (!list_empty(&ctx->run_list)) { 1530 if (!list_empty(&ctx->run_list)) {
1554 /* drain the run list */ 1531 /* drain the run list */
1555 while (__aio_run_iocbs(ctx)) 1532 while (__aio_run_iocbs(ctx))
@@ -1681,7 +1658,6 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
1681 if (NULL != cancel) { 1658 if (NULL != cancel) {
1682 struct io_event tmp; 1659 struct io_event tmp;
1683 pr_debug("calling cancel\n"); 1660 pr_debug("calling cancel\n");
1684 lock_kiocb(kiocb);
1685 memset(&tmp, 0, sizeof(tmp)); 1661 memset(&tmp, 0, sizeof(tmp));
1686 tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user; 1662 tmp.obj = (u64)(unsigned long)kiocb->ki_obj.user;
1687 tmp.data = kiocb->ki_user_data; 1663 tmp.data = kiocb->ki_user_data;
@@ -1693,7 +1669,6 @@ asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
1693 if (copy_to_user(result, &tmp, sizeof(tmp))) 1669 if (copy_to_user(result, &tmp, sizeof(tmp)))
1694 ret = -EFAULT; 1670 ret = -EFAULT;
1695 } 1671 }
1696 unlock_kiocb(kiocb);
1697 } else 1672 } else
1698 ret = -EINVAL; 1673 ret = -EINVAL;
1699 1674
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index e240c335eb23..5af928fa0449 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -108,7 +108,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode,
108 inode->i_mapping->a_ops = &bfs_aops; 108 inode->i_mapping->a_ops = &bfs_aops;
109 inode->i_mode = mode; 109 inode->i_mode = mode;
110 inode->i_ino = ino; 110 inode->i_ino = ino;
111 BFS_I(inode)->i_dsk_ino = cpu_to_le16(ino); 111 BFS_I(inode)->i_dsk_ino = ino;
112 BFS_I(inode)->i_sblock = 0; 112 BFS_I(inode)->i_sblock = 0;
113 BFS_I(inode)->i_eblock = 0; 113 BFS_I(inode)->i_eblock = 0;
114 insert_inode_hash(inode); 114 insert_inode_hash(inode);
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index c7b39aa279d7..3af6c73c5b5a 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -357,28 +357,46 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
357 } 357 }
358 358
359 info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */ 359 info->si_blocks = (le32_to_cpu(bfs_sb->s_end) + 1)>>BFS_BSIZE_BITS; /* for statfs(2) */
360 info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 - cpu_to_le32(bfs_sb->s_start))>>BFS_BSIZE_BITS; 360 info->si_freeb = (le32_to_cpu(bfs_sb->s_end) + 1 - le32_to_cpu(bfs_sb->s_start))>>BFS_BSIZE_BITS;
361 info->si_freei = 0; 361 info->si_freei = 0;
362 info->si_lf_eblk = 0; 362 info->si_lf_eblk = 0;
363 info->si_lf_sblk = 0; 363 info->si_lf_sblk = 0;
364 info->si_lf_ioff = 0; 364 info->si_lf_ioff = 0;
365 bh = NULL;
365 for (i=BFS_ROOT_INO; i<=info->si_lasti; i++) { 366 for (i=BFS_ROOT_INO; i<=info->si_lasti; i++) {
366 inode = iget(s,i); 367 struct bfs_inode *di;
367 if (BFS_I(inode)->i_dsk_ino == 0) 368 int block = (i - BFS_ROOT_INO)/BFS_INODES_PER_BLOCK + 1;
369 int off = (i - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
370 unsigned long sblock, eblock;
371
372 if (!off) {
373 brelse(bh);
374 bh = sb_bread(s, block);
375 }
376
377 if (!bh)
378 continue;
379
380 di = (struct bfs_inode *)bh->b_data + off;
381
382 if (!di->i_ino) {
368 info->si_freei++; 383 info->si_freei++;
369 else { 384 continue;
370 set_bit(i, info->si_imap); 385 }
371 info->si_freeb -= inode->i_blocks; 386 set_bit(i, info->si_imap);
372 if (BFS_I(inode)->i_eblock > info->si_lf_eblk) { 387 info->si_freeb -= BFS_FILEBLOCKS(di);
373 info->si_lf_eblk = BFS_I(inode)->i_eblock; 388
374 info->si_lf_sblk = BFS_I(inode)->i_sblock; 389 sblock = le32_to_cpu(di->i_sblock);
375 info->si_lf_ioff = BFS_INO2OFF(i); 390 eblock = le32_to_cpu(di->i_eblock);
376 } 391 if (eblock > info->si_lf_eblk) {
392 info->si_lf_eblk = eblock;
393 info->si_lf_sblk = sblock;
394 info->si_lf_ioff = BFS_INO2OFF(i);
377 } 395 }
378 iput(inode);
379 } 396 }
397 brelse(bh);
380 if (!(s->s_flags & MS_RDONLY)) { 398 if (!(s->s_flags & MS_RDONLY)) {
381 mark_buffer_dirty(bh); 399 mark_buffer_dirty(info->si_sbh);
382 s->s_dirt = 1; 400 s->s_dirt = 1;
383 } 401 }
384 dump_imap("read_super", s); 402 dump_imap("read_super", s);
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 7976a238f0a3..d4b15576e584 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -905,7 +905,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
905 send_sig(SIGKILL, current, 0); 905 send_sig(SIGKILL, current, 0);
906 goto out_free_dentry; 906 goto out_free_dentry;
907 } 907 }
908 if (padzero(elf_bss)) { 908 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
909 send_sig(SIGSEGV, current, 0); 909 send_sig(SIGSEGV, current, 0);
910 retval = -EFAULT; /* Nobody gets to see this, but.. */ 910 retval = -EFAULT; /* Nobody gets to see this, but.. */
911 goto out_free_dentry; 911 goto out_free_dentry;
diff --git a/fs/bio.c b/fs/bio.c
index 83a349574567..7d81a93afd48 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -75,7 +75,7 @@ struct bio_set {
75 */ 75 */
76static struct bio_set *fs_bio_set; 76static struct bio_set *fs_bio_set;
77 77
78static inline struct bio_vec *bvec_alloc_bs(unsigned int __nocast gfp_mask, int nr, unsigned long *idx, struct bio_set *bs) 78static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
79{ 79{
80 struct bio_vec *bvl; 80 struct bio_vec *bvl;
81 struct biovec_slab *bp; 81 struct biovec_slab *bp;
@@ -155,7 +155,7 @@ inline void bio_init(struct bio *bio)
155 * allocate bio and iovecs from the memory pools specified by the 155 * allocate bio and iovecs from the memory pools specified by the
156 * bio_set structure. 156 * bio_set structure.
157 **/ 157 **/
158struct bio *bio_alloc_bioset(unsigned int __nocast gfp_mask, int nr_iovecs, struct bio_set *bs) 158struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
159{ 159{
160 struct bio *bio = mempool_alloc(bs->bio_pool, gfp_mask); 160 struct bio *bio = mempool_alloc(bs->bio_pool, gfp_mask);
161 161
@@ -181,7 +181,7 @@ out:
181 return bio; 181 return bio;
182} 182}
183 183
184struct bio *bio_alloc(unsigned int __nocast gfp_mask, int nr_iovecs) 184struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs)
185{ 185{
186 struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); 186 struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);
187 187
@@ -277,7 +277,7 @@ inline void __bio_clone(struct bio *bio, struct bio *bio_src)
277 * 277 *
278 * Like __bio_clone, only also allocates the returned bio 278 * Like __bio_clone, only also allocates the returned bio
279 */ 279 */
280struct bio *bio_clone(struct bio *bio, unsigned int __nocast gfp_mask) 280struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
281{ 281{
282 struct bio *b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, fs_bio_set); 282 struct bio *b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, fs_bio_set);
283 283
@@ -1078,7 +1078,7 @@ struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, int first_sectors)
1078 return bp; 1078 return bp;
1079} 1079}
1080 1080
1081static void *bio_pair_alloc(unsigned int __nocast gfp_flags, void *data) 1081static void *bio_pair_alloc(gfp_t gfp_flags, void *data)
1082{ 1082{
1083 return kmalloc(sizeof(struct bio_pair), gfp_flags); 1083 return kmalloc(sizeof(struct bio_pair), gfp_flags);
1084} 1084}
diff --git a/fs/buffer.c b/fs/buffer.c
index 6cbfceabd95d..1216c0d3c8ce 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3045,7 +3045,7 @@ static void recalc_bh_state(void)
3045 buffer_heads_over_limit = (tot > max_buffer_heads); 3045 buffer_heads_over_limit = (tot > max_buffer_heads);
3046} 3046}
3047 3047
3048struct buffer_head *alloc_buffer_head(unsigned int __nocast gfp_flags) 3048struct buffer_head *alloc_buffer_head(gfp_t gfp_flags)
3049{ 3049{
3050 struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags); 3050 struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
3051 if (ret) { 3051 if (ret) {
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 8cc23e7d0d5d..1ebf7dafc1d7 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -781,6 +781,8 @@ static int cifs_oplock_thread(void * dummyarg)
781 781
782 oplockThread = current; 782 oplockThread = current;
783 do { 783 do {
784 if (try_to_freeze())
785 continue;
784 set_current_state(TASK_INTERRUPTIBLE); 786 set_current_state(TASK_INTERRUPTIBLE);
785 787
786 schedule_timeout(1*HZ); 788 schedule_timeout(1*HZ);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 2335f14a1583..47360156cc54 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -344,6 +344,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
344 } 344 }
345 345
346 while (server->tcpStatus != CifsExiting) { 346 while (server->tcpStatus != CifsExiting) {
347 if (try_to_freeze())
348 continue;
347 if (bigbuf == NULL) { 349 if (bigbuf == NULL) {
348 bigbuf = cifs_buf_get(); 350 bigbuf = cifs_buf_get();
349 if(bigbuf == NULL) { 351 if(bigbuf == NULL) {
diff --git a/fs/dcache.c b/fs/dcache.c
index 7376b61269fb..fb10386c59be 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -102,7 +102,8 @@ static inline void dentry_iput(struct dentry * dentry)
102 list_del_init(&dentry->d_alias); 102 list_del_init(&dentry->d_alias);
103 spin_unlock(&dentry->d_lock); 103 spin_unlock(&dentry->d_lock);
104 spin_unlock(&dcache_lock); 104 spin_unlock(&dcache_lock);
105 fsnotify_inoderemove(inode); 105 if (!inode->i_nlink)
106 fsnotify_inoderemove(inode);
106 if (dentry->d_op && dentry->d_op->d_iput) 107 if (dentry->d_op && dentry->d_op->d_iput)
107 dentry->d_op->d_iput(dentry, inode); 108 dentry->d_op->d_iput(dentry, inode);
108 else 109 else
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 6ab1dd0ca904..4284cd31eba6 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -101,6 +101,10 @@
101/* Maximum number of poll wake up nests we are allowing */ 101/* Maximum number of poll wake up nests we are allowing */
102#define EP_MAX_POLLWAKE_NESTS 4 102#define EP_MAX_POLLWAKE_NESTS 4
103 103
104/* Maximum msec timeout value storeable in a long int */
105#define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ)
106
107
104struct epoll_filefd { 108struct epoll_filefd {
105 struct file *file; 109 struct file *file;
106 int fd; 110 int fd;
@@ -231,8 +235,9 @@ struct ep_pqueue {
231 235
232static void ep_poll_safewake_init(struct poll_safewake *psw); 236static void ep_poll_safewake_init(struct poll_safewake *psw);
233static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq); 237static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq);
234static int ep_getfd(int *efd, struct inode **einode, struct file **efile); 238static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
235static int ep_file_init(struct file *file); 239 struct eventpoll *ep);
240static int ep_alloc(struct eventpoll **pep);
236static void ep_free(struct eventpoll *ep); 241static void ep_free(struct eventpoll *ep);
237static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd); 242static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd);
238static void ep_use_epitem(struct epitem *epi); 243static void ep_use_epitem(struct epitem *epi);
@@ -501,38 +506,37 @@ void eventpoll_release_file(struct file *file)
501asmlinkage long sys_epoll_create(int size) 506asmlinkage long sys_epoll_create(int size)
502{ 507{
503 int error, fd; 508 int error, fd;
509 struct eventpoll *ep;
504 struct inode *inode; 510 struct inode *inode;
505 struct file *file; 511 struct file *file;
506 512
507 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n", 513 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n",
508 current, size)); 514 current, size));
509 515
510 /* Sanity check on the size parameter */ 516 /*
517 * Sanity check on the size parameter, and create the internal data
518 * structure ( "struct eventpoll" ).
519 */
511 error = -EINVAL; 520 error = -EINVAL;
512 if (size <= 0) 521 if (size <= 0 || (error = ep_alloc(&ep)) != 0)
513 goto eexit_1; 522 goto eexit_1;
514 523
515 /* 524 /*
516 * Creates all the items needed to setup an eventpoll file. That is, 525 * Creates all the items needed to setup an eventpoll file. That is,
517 * a file structure, and inode and a free file descriptor. 526 * a file structure, and inode and a free file descriptor.
518 */ 527 */
519 error = ep_getfd(&fd, &inode, &file); 528 error = ep_getfd(&fd, &inode, &file, ep);
520 if (error)
521 goto eexit_1;
522
523 /* Setup the file internal data structure ( "struct eventpoll" ) */
524 error = ep_file_init(file);
525 if (error) 529 if (error)
526 goto eexit_2; 530 goto eexit_2;
527 531
528
529 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", 532 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
530 current, size, fd)); 533 current, size, fd));
531 534
532 return fd; 535 return fd;
533 536
534eexit_2: 537eexit_2:
535 sys_close(fd); 538 ep_free(ep);
539 kfree(ep);
536eexit_1: 540eexit_1:
537 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n", 541 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
538 current, size, error)); 542 current, size, error));
@@ -706,7 +710,8 @@ eexit_1:
706/* 710/*
707 * Creates the file descriptor to be used by the epoll interface. 711 * Creates the file descriptor to be used by the epoll interface.
708 */ 712 */
709static int ep_getfd(int *efd, struct inode **einode, struct file **efile) 713static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
714 struct eventpoll *ep)
710{ 715{
711 struct qstr this; 716 struct qstr this;
712 char name[32]; 717 char name[32];
@@ -756,7 +761,7 @@ static int ep_getfd(int *efd, struct inode **einode, struct file **efile)
756 file->f_op = &eventpoll_fops; 761 file->f_op = &eventpoll_fops;
757 file->f_mode = FMODE_READ; 762 file->f_mode = FMODE_READ;
758 file->f_version = 0; 763 file->f_version = 0;
759 file->private_data = NULL; 764 file->private_data = ep;
760 765
761 /* Install the new setup file into the allocated fd. */ 766 /* Install the new setup file into the allocated fd. */
762 fd_install(fd, file); 767 fd_install(fd, file);
@@ -777,14 +782,13 @@ eexit_1:
777} 782}
778 783
779 784
780static int ep_file_init(struct file *file) 785static int ep_alloc(struct eventpoll **pep)
781{ 786{
782 struct eventpoll *ep; 787 struct eventpoll *ep = kzalloc(sizeof(*ep), GFP_KERNEL);
783 788
784 if (!(ep = kmalloc(sizeof(struct eventpoll), GFP_KERNEL))) 789 if (!ep)
785 return -ENOMEM; 790 return -ENOMEM;
786 791
787 memset(ep, 0, sizeof(*ep));
788 rwlock_init(&ep->lock); 792 rwlock_init(&ep->lock);
789 init_rwsem(&ep->sem); 793 init_rwsem(&ep->sem);
790 init_waitqueue_head(&ep->wq); 794 init_waitqueue_head(&ep->wq);
@@ -792,9 +796,9 @@ static int ep_file_init(struct file *file)
792 INIT_LIST_HEAD(&ep->rdllist); 796 INIT_LIST_HEAD(&ep->rdllist);
793 ep->rbr = RB_ROOT; 797 ep->rbr = RB_ROOT;
794 798
795 file->private_data = ep; 799 *pep = ep;
796 800
797 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_file_init() ep=%p\n", 801 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_alloc() ep=%p\n",
798 current, ep)); 802 current, ep));
799 return 0; 803 return 0;
800} 804}
@@ -1506,8 +1510,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
1506 * and the overflow condition. The passed timeout is in milliseconds, 1510 * and the overflow condition. The passed timeout is in milliseconds,
1507 * that why (t * HZ) / 1000. 1511 * that why (t * HZ) / 1000.
1508 */ 1512 */
1509 jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? 1513 jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ?
1510 MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; 1514 MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000;
1511 1515
1512retry: 1516retry:
1513 write_lock_irqsave(&ep->lock, flags); 1517 write_lock_irqsave(&ep->lock, flags);
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index c8d07030c897..e2d6208633a7 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -605,27 +605,28 @@ got:
605 insert_inode_hash(inode); 605 insert_inode_hash(inode);
606 606
607 if (DQUOT_ALLOC_INODE(inode)) { 607 if (DQUOT_ALLOC_INODE(inode)) {
608 DQUOT_DROP(inode);
609 err = -ENOSPC; 608 err = -ENOSPC;
610 goto fail2; 609 goto fail_drop;
611 } 610 }
611
612 err = ext2_init_acl(inode, dir); 612 err = ext2_init_acl(inode, dir);
613 if (err) { 613 if (err)
614 DQUOT_FREE_INODE(inode); 614 goto fail_free_drop;
615 DQUOT_DROP(inode); 615
616 goto fail2;
617 }
618 err = ext2_init_security(inode,dir); 616 err = ext2_init_security(inode,dir);
619 if (err) { 617 if (err)
620 DQUOT_FREE_INODE(inode); 618 goto fail_free_drop;
621 goto fail2; 619
622 }
623 mark_inode_dirty(inode); 620 mark_inode_dirty(inode);
624 ext2_debug("allocating inode %lu\n", inode->i_ino); 621 ext2_debug("allocating inode %lu\n", inode->i_ino);
625 ext2_preread_inode(inode); 622 ext2_preread_inode(inode);
626 return inode; 623 return inode;
627 624
628fail2: 625fail_free_drop:
626 DQUOT_FREE_INODE(inode);
627
628fail_drop:
629 DQUOT_DROP(inode);
629 inode->i_flags |= S_NOQUOTA; 630 inode->i_flags |= S_NOQUOTA;
630 inode->i_nlink = 0; 631 inode->i_nlink = 0;
631 iput(inode); 632 iput(inode);
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index e463dca008e4..0213db4911a2 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -1410,7 +1410,7 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
1410 unsigned long desc_count; 1410 unsigned long desc_count;
1411 struct ext3_group_desc *gdp; 1411 struct ext3_group_desc *gdp;
1412 int i; 1412 int i;
1413 unsigned long ngroups; 1413 unsigned long ngroups = EXT3_SB(sb)->s_groups_count;
1414#ifdef EXT3FS_DEBUG 1414#ifdef EXT3FS_DEBUG
1415 struct ext3_super_block *es; 1415 struct ext3_super_block *es;
1416 unsigned long bitmap_count, x; 1416 unsigned long bitmap_count, x;
@@ -1421,7 +1421,8 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
1421 desc_count = 0; 1421 desc_count = 0;
1422 bitmap_count = 0; 1422 bitmap_count = 0;
1423 gdp = NULL; 1423 gdp = NULL;
1424 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) { 1424
1425 for (i = 0; i < ngroups; i++) {
1425 gdp = ext3_get_group_desc(sb, i, NULL); 1426 gdp = ext3_get_group_desc(sb, i, NULL);
1426 if (!gdp) 1427 if (!gdp)
1427 continue; 1428 continue;
@@ -1443,7 +1444,6 @@ unsigned long ext3_count_free_blocks(struct super_block *sb)
1443 return bitmap_count; 1444 return bitmap_count;
1444#else 1445#else
1445 desc_count = 0; 1446 desc_count = 0;
1446 ngroups = EXT3_SB(sb)->s_groups_count;
1447 smp_rmb(); 1447 smp_rmb();
1448 for (i = 0; i < ngroups; i++) { 1448 for (i = 0; i < ngroups; i++) {
1449 gdp = ext3_get_group_desc(sb, i, NULL); 1449 gdp = ext3_get_group_desc(sb, i, NULL);
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 96552769d039..6549945f9ac1 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -597,27 +597,22 @@ got:
597 597
598 ret = inode; 598 ret = inode;
599 if(DQUOT_ALLOC_INODE(inode)) { 599 if(DQUOT_ALLOC_INODE(inode)) {
600 DQUOT_DROP(inode);
601 err = -EDQUOT; 600 err = -EDQUOT;
602 goto fail2; 601 goto fail_drop;
603 } 602 }
603
604 err = ext3_init_acl(handle, inode, dir); 604 err = ext3_init_acl(handle, inode, dir);
605 if (err) { 605 if (err)
606 DQUOT_FREE_INODE(inode); 606 goto fail_free_drop;
607 DQUOT_DROP(inode); 607
608 goto fail2;
609 }
610 err = ext3_init_security(handle,inode, dir); 608 err = ext3_init_security(handle,inode, dir);
611 if (err) { 609 if (err)
612 DQUOT_FREE_INODE(inode); 610 goto fail_free_drop;
613 goto fail2; 611
614 }
615 err = ext3_mark_inode_dirty(handle, inode); 612 err = ext3_mark_inode_dirty(handle, inode);
616 if (err) { 613 if (err) {
617 ext3_std_error(sb, err); 614 ext3_std_error(sb, err);
618 DQUOT_FREE_INODE(inode); 615 goto fail_free_drop;
619 DQUOT_DROP(inode);
620 goto fail2;
621 } 616 }
622 617
623 ext3_debug("allocating inode %lu\n", inode->i_ino); 618 ext3_debug("allocating inode %lu\n", inode->i_ino);
@@ -631,7 +626,11 @@ really_out:
631 brelse(bitmap_bh); 626 brelse(bitmap_bh);
632 return ret; 627 return ret;
633 628
634fail2: 629fail_free_drop:
630 DQUOT_FREE_INODE(inode);
631
632fail_drop:
633 DQUOT_DROP(inode);
635 inode->i_flags |= S_NOQUOTA; 634 inode->i_flags |= S_NOQUOTA;
636 inode->i_nlink = 0; 635 inode->i_nlink = 0;
637 iput(inode); 636 iput(inode);
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 2c9f81278d5d..57f79106267d 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -242,7 +242,7 @@ static int setup_new_group_blocks(struct super_block *sb,
242 i < sbi->s_itb_per_group; i++, bit++, block++) { 242 i < sbi->s_itb_per_group; i++, bit++, block++) {
243 struct buffer_head *it; 243 struct buffer_head *it;
244 244
245 ext3_debug("clear inode block %#04x (+%ld)\n", block, bit); 245 ext3_debug("clear inode block %#04lx (+%d)\n", block, bit);
246 if (IS_ERR(it = bclean(handle, sb, block))) { 246 if (IS_ERR(it = bclean(handle, sb, block))) {
247 err = PTR_ERR(it); 247 err = PTR_ERR(it);
248 goto exit_bh; 248 goto exit_bh;
@@ -643,8 +643,8 @@ static void update_backups(struct super_block *sb,
643 break; 643 break;
644 644
645 bh = sb_getblk(sb, group * bpg + blk_off); 645 bh = sb_getblk(sb, group * bpg + blk_off);
646 ext3_debug(sb, __FUNCTION__, "update metadata backup %#04lx\n", 646 ext3_debug("update metadata backup %#04lx\n",
647 bh->b_blocknr); 647 (unsigned long)bh->b_blocknr);
648 if ((err = ext3_journal_get_write_access(handle, bh))) 648 if ((err = ext3_journal_get_write_access(handle, bh)))
649 break; 649 break;
650 lock_buffer(bh); 650 lock_buffer(bh);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index a93c3609025d..9e24ceb019fe 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -512,15 +512,14 @@ static void ext3_clear_inode(struct inode *inode)
512 512
513static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) 513static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
514{ 514{
515 struct ext3_sb_info *sbi = EXT3_SB(vfs->mnt_sb); 515 struct super_block *sb = vfs->mnt_sb;
516 struct ext3_sb_info *sbi = EXT3_SB(sb);
516 517
517 if (sbi->s_mount_opt & EXT3_MOUNT_JOURNAL_DATA) 518 if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
518 seq_puts(seq, ",data=journal"); 519 seq_puts(seq, ",data=journal");
519 520 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
520 if (sbi->s_mount_opt & EXT3_MOUNT_ORDERED_DATA)
521 seq_puts(seq, ",data=ordered"); 521 seq_puts(seq, ",data=ordered");
522 522 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
523 if (sbi->s_mount_opt & EXT3_MOUNT_WRITEBACK_DATA)
524 seq_puts(seq, ",data=writeback"); 523 seq_puts(seq, ",data=writeback");
525 524
526#if defined(CONFIG_QUOTA) 525#if defined(CONFIG_QUOTA)
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 62ffa9139400..7134403d5be2 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -12,39 +12,6 @@
12#include <linux/smp_lock.h> 12#include <linux/smp_lock.h>
13#include <linux/buffer_head.h> 13#include <linux/buffer_head.h>
14 14
15static ssize_t fat_file_aio_write(struct kiocb *iocb, const char __user *buf,
16 size_t count, loff_t pos)
17{
18 struct inode *inode = iocb->ki_filp->f_dentry->d_inode;
19 int retval;
20
21 retval = generic_file_aio_write(iocb, buf, count, pos);
22 if (retval > 0) {
23 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
24 MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
25 mark_inode_dirty(inode);
26// check the locking rules
27// if (IS_SYNC(inode))
28// fat_sync_inode(inode);
29 }
30 return retval;
31}
32
33static ssize_t fat_file_writev(struct file *filp, const struct iovec *iov,
34 unsigned long nr_segs, loff_t *ppos)
35{
36 struct inode *inode = filp->f_dentry->d_inode;
37 int retval;
38
39 retval = generic_file_writev(filp, iov, nr_segs, ppos);
40 if (retval > 0) {
41 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
42 MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
43 mark_inode_dirty(inode);
44 }
45 return retval;
46}
47
48int fat_generic_ioctl(struct inode *inode, struct file *filp, 15int fat_generic_ioctl(struct inode *inode, struct file *filp,
49 unsigned int cmd, unsigned long arg) 16 unsigned int cmd, unsigned long arg)
50{ 17{
@@ -148,9 +115,9 @@ struct file_operations fat_file_operations = {
148 .read = do_sync_read, 115 .read = do_sync_read,
149 .write = do_sync_write, 116 .write = do_sync_write,
150 .readv = generic_file_readv, 117 .readv = generic_file_readv,
151 .writev = fat_file_writev, 118 .writev = generic_file_writev,
152 .aio_read = generic_file_aio_read, 119 .aio_read = generic_file_aio_read,
153 .aio_write = fat_file_aio_write, 120 .aio_write = generic_file_aio_write,
154 .mmap = generic_file_mmap, 121 .mmap = generic_file_mmap,
155 .ioctl = fat_generic_ioctl, 122 .ioctl = fat_generic_ioctl,
156 .fsync = file_fsync, 123 .fsync = file_fsync,
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a7cbe68e2259..e2effe2dc9b2 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -102,6 +102,19 @@ static int fat_prepare_write(struct file *file, struct page *page,
102 &MSDOS_I(page->mapping->host)->mmu_private); 102 &MSDOS_I(page->mapping->host)->mmu_private);
103} 103}
104 104
105static int fat_commit_write(struct file *file, struct page *page,
106 unsigned from, unsigned to)
107{
108 struct inode *inode = page->mapping->host;
109 int err = generic_commit_write(file, page, from, to);
110 if (!err && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) {
111 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
112 MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
113 mark_inode_dirty(inode);
114 }
115 return err;
116}
117
105static sector_t _fat_bmap(struct address_space *mapping, sector_t block) 118static sector_t _fat_bmap(struct address_space *mapping, sector_t block)
106{ 119{
107 return generic_block_bmap(mapping, block, fat_get_block); 120 return generic_block_bmap(mapping, block, fat_get_block);
@@ -112,7 +125,7 @@ static struct address_space_operations fat_aops = {
112 .writepage = fat_writepage, 125 .writepage = fat_writepage,
113 .sync_page = block_sync_page, 126 .sync_page = block_sync_page,
114 .prepare_write = fat_prepare_write, 127 .prepare_write = fat_prepare_write,
115 .commit_write = generic_commit_write, 128 .commit_write = fat_commit_write,
116 .bmap = _fat_bmap 129 .bmap = _fat_bmap
117}; 130};
118 131
@@ -287,9 +300,9 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
287 inode->i_blksize = sbi->cluster_size; 300 inode->i_blksize = sbi->cluster_size;
288 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) 301 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
289 & ~((loff_t)sbi->cluster_size - 1)) >> 9; 302 & ~((loff_t)sbi->cluster_size - 1)) >> 9;
290 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = 303 inode->i_mtime.tv_sec =
291 date_dos2unix(le16_to_cpu(de->time), le16_to_cpu(de->date)); 304 date_dos2unix(le16_to_cpu(de->time), le16_to_cpu(de->date));
292 inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0; 305 inode->i_mtime.tv_nsec = 0;
293 if (sbi->options.isvfat) { 306 if (sbi->options.isvfat) {
294 int secs = de->ctime_cs / 100; 307 int secs = de->ctime_cs / 100;
295 int csecs = de->ctime_cs % 100; 308 int csecs = de->ctime_cs % 100;
@@ -297,8 +310,11 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
297 date_dos2unix(le16_to_cpu(de->ctime), 310 date_dos2unix(le16_to_cpu(de->ctime),
298 le16_to_cpu(de->cdate)) + secs; 311 le16_to_cpu(de->cdate)) + secs;
299 inode->i_ctime.tv_nsec = csecs * 10000000; 312 inode->i_ctime.tv_nsec = csecs * 10000000;
313 inode->i_atime.tv_sec =
314 date_dos2unix(le16_to_cpu(0), le16_to_cpu(de->adate));
315 inode->i_atime.tv_nsec = 0;
300 } else 316 } else
301 inode->i_ctime = inode->i_mtime; 317 inode->i_ctime = inode->i_atime = inode->i_mtime;
302 318
303 return 0; 319 return 0;
304} 320}
@@ -500,7 +516,9 @@ retry:
500 raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); 516 raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16);
501 fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, &raw_entry->date); 517 fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, &raw_entry->date);
502 if (sbi->options.isvfat) { 518 if (sbi->options.isvfat) {
519 __le16 atime;
503 fat_date_unix2dos(inode->i_ctime.tv_sec,&raw_entry->ctime,&raw_entry->cdate); 520 fat_date_unix2dos(inode->i_ctime.tv_sec,&raw_entry->ctime,&raw_entry->cdate);
521 fat_date_unix2dos(inode->i_atime.tv_sec,&atime,&raw_entry->adate);
504 raw_entry->ctime_cs = (inode->i_ctime.tv_sec & 1) * 100 + 522 raw_entry->ctime_cs = (inode->i_ctime.tv_sec & 1) * 100 +
505 inode->i_ctime.tv_nsec / 10000000; 523 inode->i_ctime.tv_nsec / 10000000;
506 } 524 }
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index e79e49b3eec7..29f1e9f6e85c 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -96,6 +96,8 @@ static int fuse_lookup_iget(struct inode *dir, struct dentry *entry,
96 fuse_lookup_init(req, dir, entry, &outarg); 96 fuse_lookup_init(req, dir, entry, &outarg);
97 request_send(fc, req); 97 request_send(fc, req);
98 err = req->out.h.error; 98 err = req->out.h.error;
99 if (!err && (!outarg.nodeid || outarg.nodeid == FUSE_ROOT_ID))
100 err = -EIO;
99 if (!err) { 101 if (!err) {
100 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, 102 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
101 &outarg.attr); 103 &outarg.attr);
@@ -152,6 +154,10 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
152 fuse_put_request(fc, req); 154 fuse_put_request(fc, req);
153 return err; 155 return err;
154 } 156 }
157 if (!outarg.nodeid || outarg.nodeid == FUSE_ROOT_ID) {
158 fuse_put_request(fc, req);
159 return -EIO;
160 }
155 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, 161 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
156 &outarg.attr); 162 &outarg.attr);
157 if (!inode) { 163 if (!inode) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 6454022b0536..657ab11c173b 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -23,6 +23,10 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir)
23 struct fuse_file *ff; 23 struct fuse_file *ff;
24 int err; 24 int err;
25 25
26 /* VFS checks this, but only _after_ ->open() */
27 if (file->f_flags & O_DIRECT)
28 return -EINVAL;
29
26 err = generic_file_open(inode, file); 30 err = generic_file_open(inode, file);
27 if (err) 31 if (err)
28 return err; 32 return err;
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index fd0f0f050e1d..452fc1fdbd32 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -50,6 +50,7 @@ static void hfsplus_read_inode(struct inode *inode)
50 init_MUTEX(&HFSPLUS_I(inode).extents_lock); 50 init_MUTEX(&HFSPLUS_I(inode).extents_lock);
51 HFSPLUS_I(inode).flags = 0; 51 HFSPLUS_I(inode).flags = 0;
52 HFSPLUS_I(inode).rsrc_inode = NULL; 52 HFSPLUS_I(inode).rsrc_inode = NULL;
53 atomic_set(&HFSPLUS_I(inode).opencnt, 0);
53 54
54 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) { 55 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
55 read_inode: 56 read_inode:
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 59c5062cd63f..dd7113106269 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -793,11 +793,6 @@ int hostfs_rename(struct inode *from_ino, struct dentry *from,
793 return(err); 793 return(err);
794} 794}
795 795
796void hostfs_truncate(struct inode *ino)
797{
798 not_implemented();
799}
800
801int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) 796int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
802{ 797{
803 char *name; 798 char *name;
@@ -894,7 +889,6 @@ static struct inode_operations hostfs_iops = {
894 .rmdir = hostfs_rmdir, 889 .rmdir = hostfs_rmdir,
895 .mknod = hostfs_mknod, 890 .mknod = hostfs_mknod,
896 .rename = hostfs_rename, 891 .rename = hostfs_rename,
897 .truncate = hostfs_truncate,
898 .permission = hostfs_permission, 892 .permission = hostfs_permission,
899 .setattr = hostfs_setattr, 893 .setattr = hostfs_setattr,
900 .getattr = hostfs_getattr, 894 .getattr = hostfs_getattr,
@@ -910,7 +904,6 @@ static struct inode_operations hostfs_dir_iops = {
910 .rmdir = hostfs_rmdir, 904 .rmdir = hostfs_rmdir,
911 .mknod = hostfs_mknod, 905 .mknod = hostfs_mknod,
912 .rename = hostfs_rename, 906 .rename = hostfs_rename,
913 .truncate = hostfs_truncate,
914 .permission = hostfs_permission, 907 .permission = hostfs_permission,
915 .setattr = hostfs_setattr, 908 .setattr = hostfs_setattr,
916 .getattr = hostfs_getattr, 909 .getattr = hostfs_getattr,
diff --git a/fs/inotify.c b/fs/inotify.c
index a37e9fb1da58..9fbaebfdf40b 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -176,6 +176,7 @@ static inline void put_inotify_dev(struct inotify_device *dev)
176 if (atomic_dec_and_test(&dev->count)) { 176 if (atomic_dec_and_test(&dev->count)) {
177 atomic_dec(&dev->user->inotify_devs); 177 atomic_dec(&dev->user->inotify_devs);
178 free_uid(dev->user); 178 free_uid(dev->user);
179 idr_destroy(&dev->idr);
179 kfree(dev); 180 kfree(dev);
180 } 181 }
181} 182}
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 0ec62d5310db..9f942ca8e4e3 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -129,8 +129,7 @@ void jfs_delete_inode(struct inode *inode)
129 jfs_info("In jfs_delete_inode, inode = 0x%p", inode); 129 jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
130 130
131 if (!is_bad_inode(inode) && 131 if (!is_bad_inode(inode) &&
132 (JFS_IP(inode)->fileset == cpu_to_le32(FILESYSTEM_I))) { 132 (JFS_IP(inode)->fileset == FILESYSTEM_I)) {
133
134 truncate_inode_pages(&inode->i_data, 0); 133 truncate_inode_pages(&inode->i_data, 0);
135 134
136 if (test_cflag(COMMIT_Freewmap, inode)) 135 if (test_cflag(COMMIT_Freewmap, inode))
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index c739626f5bf1..eadf319bee22 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -3055,7 +3055,7 @@ static int cntlz(u32 value)
3055 * RETURN VALUES: 3055 * RETURN VALUES:
3056 * log2 number of blocks 3056 * log2 number of blocks
3057 */ 3057 */
3058int blkstol2(s64 nb) 3058static int blkstol2(s64 nb)
3059{ 3059{
3060 int l2nb; 3060 int l2nb;
3061 s64 mask; /* meant to be signed */ 3061 s64 mask; /* meant to be signed */
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index c7a92f9deb2b..9b71ed2674fe 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -725,6 +725,9 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
725 else 725 else
726 tlck->flag = tlckINODELOCK; 726 tlck->flag = tlckINODELOCK;
727 727
728 if (S_ISDIR(ip->i_mode))
729 tlck->flag |= tlckDIRECTORY;
730
728 tlck->type = 0; 731 tlck->type = 0;
729 732
730 /* bind the tlock and the page */ 733 /* bind the tlock and the page */
@@ -1009,6 +1012,8 @@ struct tlock *txMaplock(tid_t tid, struct inode *ip, int type)
1009 1012
1010 /* bind the tlock and the object */ 1013 /* bind the tlock and the object */
1011 tlck->flag = tlckINODELOCK; 1014 tlck->flag = tlckINODELOCK;
1015 if (S_ISDIR(ip->i_mode))
1016 tlck->flag |= tlckDIRECTORY;
1012 tlck->ip = ip; 1017 tlck->ip = ip;
1013 tlck->mp = NULL; 1018 tlck->mp = NULL;
1014 1019
@@ -1077,6 +1082,8 @@ struct linelock *txLinelock(struct linelock * tlock)
1077 linelock->flag = tlckLINELOCK; 1082 linelock->flag = tlckLINELOCK;
1078 linelock->maxcnt = TLOCKLONG; 1083 linelock->maxcnt = TLOCKLONG;
1079 linelock->index = 0; 1084 linelock->index = 0;
1085 if (tlck->flag & tlckDIRECTORY)
1086 linelock->flag |= tlckDIRECTORY;
1080 1087
1081 /* append linelock after tlock */ 1088 /* append linelock after tlock */
1082 linelock->next = tlock->next; 1089 linelock->next = tlock->next;
@@ -2070,8 +2077,8 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
2070 * 2077 *
2071 * function: log from maplock of freed data extents; 2078 * function: log from maplock of freed data extents;
2072 */ 2079 */
2073void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, 2080static void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
2074 struct tlock * tlck) 2081 struct tlock * tlck)
2075{ 2082{
2076 struct pxd_lock *pxdlock; 2083 struct pxd_lock *pxdlock;
2077 int i, nlock; 2084 int i, nlock;
@@ -2209,7 +2216,7 @@ void txEA(tid_t tid, struct inode *ip, dxd_t * oldea, dxd_t * newea)
2209 * function: synchronously write pages locked by transaction 2216 * function: synchronously write pages locked by transaction
2210 * after txLog() but before txUpdateMap(); 2217 * after txLog() but before txUpdateMap();
2211 */ 2218 */
2212void txForce(struct tblock * tblk) 2219static void txForce(struct tblock * tblk)
2213{ 2220{
2214 struct tlock *tlck; 2221 struct tlock *tlck;
2215 lid_t lid, next; 2222 lid_t lid, next;
@@ -2358,7 +2365,7 @@ static void txUpdateMap(struct tblock * tblk)
2358 */ 2365 */
2359 else { /* (maplock->flag & mlckFREE) */ 2366 else { /* (maplock->flag & mlckFREE) */
2360 2367
2361 if (S_ISDIR(tlck->ip->i_mode)) 2368 if (tlck->flag & tlckDIRECTORY)
2362 txFreeMap(ipimap, maplock, 2369 txFreeMap(ipimap, maplock,
2363 tblk, COMMIT_PWMAP); 2370 tblk, COMMIT_PWMAP);
2364 else 2371 else
diff --git a/fs/jfs/jfs_txnmgr.h b/fs/jfs/jfs_txnmgr.h
index 59ad0f6b7231..0e4dc4514c47 100644
--- a/fs/jfs/jfs_txnmgr.h
+++ b/fs/jfs/jfs_txnmgr.h
@@ -122,6 +122,7 @@ extern struct tlock *TxLock; /* transaction lock table */
122#define tlckLOG 0x0800 122#define tlckLOG 0x0800
123/* updateMap state */ 123/* updateMap state */
124#define tlckUPDATEMAP 0x0080 124#define tlckUPDATEMAP 0x0080
125#define tlckDIRECTORY 0x0040
125/* freeLock state */ 126/* freeLock state */
126#define tlckFREELOCK 0x0008 127#define tlckFREELOCK 0x0008
127#define tlckWRITEPAGE 0x0004 128#define tlckWRITEPAGE 0x0004
diff --git a/fs/locks.c b/fs/locks.c
index c2c09b4798d6..f7daa5f48949 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -124,6 +124,7 @@
124#include <linux/smp_lock.h> 124#include <linux/smp_lock.h>
125#include <linux/syscalls.h> 125#include <linux/syscalls.h>
126#include <linux/time.h> 126#include <linux/time.h>
127#include <linux/rcupdate.h>
127 128
128#include <asm/semaphore.h> 129#include <asm/semaphore.h>
129#include <asm/uaccess.h> 130#include <asm/uaccess.h>
@@ -2205,6 +2206,7 @@ void steal_locks(fl_owner_t from)
2205 2206
2206 lock_kernel(); 2207 lock_kernel();
2207 j = 0; 2208 j = 0;
2209 rcu_read_lock();
2208 fdt = files_fdtable(files); 2210 fdt = files_fdtable(files);
2209 for (;;) { 2211 for (;;) {
2210 unsigned long set; 2212 unsigned long set;
@@ -2222,6 +2224,7 @@ void steal_locks(fl_owner_t from)
2222 set >>= 1; 2224 set >>= 1;
2223 } 2225 }
2224 } 2226 }
2227 rcu_read_unlock();
2225 unlock_kernel(); 2228 unlock_kernel();
2226} 2229}
2227EXPORT_SYMBOL(steal_locks); 2230EXPORT_SYMBOL(steal_locks);
diff --git a/fs/mpage.c b/fs/mpage.c
index bb9aebe93862..c5adcdddf3cc 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -102,7 +102,7 @@ static struct bio *mpage_bio_submit(int rw, struct bio *bio)
102static struct bio * 102static struct bio *
103mpage_alloc(struct block_device *bdev, 103mpage_alloc(struct block_device *bdev,
104 sector_t first_sector, int nr_vecs, 104 sector_t first_sector, int nr_vecs,
105 unsigned int __nocast gfp_flags) 105 gfp_t gfp_flags)
106{ 106{
107 struct bio *bio; 107 struct bio *bio;
108 108
diff --git a/fs/namei.c b/fs/namei.c
index 043d587216b5..aa62dbda93ac 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1551,19 +1551,19 @@ do_link:
1551 if (nd->last_type != LAST_NORM) 1551 if (nd->last_type != LAST_NORM)
1552 goto exit; 1552 goto exit;
1553 if (nd->last.name[nd->last.len]) { 1553 if (nd->last.name[nd->last.len]) {
1554 putname(nd->last.name); 1554 __putname(nd->last.name);
1555 goto exit; 1555 goto exit;
1556 } 1556 }
1557 error = -ELOOP; 1557 error = -ELOOP;
1558 if (count++==32) { 1558 if (count++==32) {
1559 putname(nd->last.name); 1559 __putname(nd->last.name);
1560 goto exit; 1560 goto exit;
1561 } 1561 }
1562 dir = nd->dentry; 1562 dir = nd->dentry;
1563 down(&dir->d_inode->i_sem); 1563 down(&dir->d_inode->i_sem);
1564 path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); 1564 path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
1565 path.mnt = nd->mnt; 1565 path.mnt = nd->mnt;
1566 putname(nd->last.name); 1566 __putname(nd->last.name);
1567 goto do_last; 1567 goto do_last;
1568} 1568}
1569 1569
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index d7f7eb669d03..4a36839f0bbd 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -85,6 +85,10 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
85 struct nfs_delegation *delegation; 85 struct nfs_delegation *delegation;
86 int status = 0; 86 int status = 0;
87 87
88 /* Ensure we first revalidate the attributes and page cache! */
89 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)))
90 __nfs_revalidate_inode(NFS_SERVER(inode), inode);
91
88 delegation = nfs_alloc_delegation(); 92 delegation = nfs_alloc_delegation();
89 if (delegation == NULL) 93 if (delegation == NULL)
90 return -ENOMEM; 94 return -ENOMEM;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index f6b9eda925c5..6bdcfa95de94 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -137,7 +137,8 @@ static int nfs_revalidate_file(struct inode *inode, struct file *filp)
137 struct nfs_inode *nfsi = NFS_I(inode); 137 struct nfs_inode *nfsi = NFS_I(inode);
138 int retval = 0; 138 int retval = 0;
139 139
140 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode)) 140 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR))
141 || nfs_attribute_timeout(inode))
141 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 142 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
142 nfs_revalidate_mapping(inode, filp->f_mapping); 143 nfs_revalidate_mapping(inode, filp->f_mapping);
143 return 0; 144 return 0;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6922469d6fc5..d4eadeea128e 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -877,12 +877,10 @@ static int nfs_wait_on_inode(struct inode *inode)
877 sigset_t oldmask; 877 sigset_t oldmask;
878 int error; 878 int error;
879 879
880 atomic_inc(&inode->i_count);
881 rpc_clnt_sigmask(clnt, &oldmask); 880 rpc_clnt_sigmask(clnt, &oldmask);
882 error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING, 881 error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING,
883 nfs_wait_schedule, TASK_INTERRUPTIBLE); 882 nfs_wait_schedule, TASK_INTERRUPTIBLE);
884 rpc_clnt_sigunmask(clnt, &oldmask); 883 rpc_clnt_sigunmask(clnt, &oldmask);
885 iput(inode);
886 884
887 return error; 885 return error;
888} 886}
@@ -1226,10 +1224,6 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1226 loff_t cur_size, new_isize; 1224 loff_t cur_size, new_isize;
1227 int data_unstable; 1225 int data_unstable;
1228 1226
1229 /* Do we hold a delegation? */
1230 if (nfs_have_delegation(inode, FMODE_READ))
1231 return 0;
1232
1233 spin_lock(&inode->i_lock); 1227 spin_lock(&inode->i_lock);
1234 1228
1235 /* Are we in the process of updating data on the server? */ 1229 /* Are we in the process of updating data on the server? */
@@ -1350,7 +1344,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1350 nfsi->read_cache_jiffies = fattr->timestamp; 1344 nfsi->read_cache_jiffies = fattr->timestamp;
1351 1345
1352 /* Are we racing with known updates of the metadata on the server? */ 1346 /* Are we racing with known updates of the metadata on the server? */
1353 data_unstable = ! nfs_verify_change_attribute(inode, verifier); 1347 data_unstable = ! (nfs_verify_change_attribute(inode, verifier) ||
1348 (nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE));
1354 1349
1355 /* Check if our cached file size is stale */ 1350 /* Check if our cached file size is stale */
1356 new_isize = nfs_size_to_loff_t(fattr->size); 1351 new_isize = nfs_size_to_loff_t(fattr->size);
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6ceb1d471f20..9758ebd49905 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -184,14 +184,13 @@ static void nfs_readpage_release(struct nfs_page *req)
184{ 184{
185 unlock_page(req->wb_page); 185 unlock_page(req->wb_page);
186 186
187 nfs_clear_request(req);
188 nfs_release_request(req);
189
190 dprintk("NFS: read done (%s/%Ld %d@%Ld)\n", 187 dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
191 req->wb_context->dentry->d_inode->i_sb->s_id, 188 req->wb_context->dentry->d_inode->i_sb->s_id,
192 (long long)NFS_FILEID(req->wb_context->dentry->d_inode), 189 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
193 req->wb_bytes, 190 req->wb_bytes,
194 (long long)req_offset(req)); 191 (long long)req_offset(req));
192 nfs_clear_request(req);
193 nfs_release_request(req);
195} 194}
196 195
197/* 196/*
diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c
index 251e5a1bb1c4..0c2be8c0307d 100644
--- a/fs/nfs_common/nfsacl.c
+++ b/fs/nfs_common/nfsacl.c
@@ -48,43 +48,26 @@ xdr_nfsace_encode(struct xdr_array2_desc *desc, void *elem)
48 (struct nfsacl_encode_desc *) desc; 48 (struct nfsacl_encode_desc *) desc;
49 u32 *p = (u32 *) elem; 49 u32 *p = (u32 *) elem;
50 50
51 if (nfsacl_desc->count < nfsacl_desc->acl->a_count) { 51 struct posix_acl_entry *entry =
52 struct posix_acl_entry *entry = 52 &nfsacl_desc->acl->a_entries[nfsacl_desc->count++];
53 &nfsacl_desc->acl->a_entries[nfsacl_desc->count++];
54 53
55 *p++ = htonl(entry->e_tag | nfsacl_desc->typeflag); 54 *p++ = htonl(entry->e_tag | nfsacl_desc->typeflag);
56 switch(entry->e_tag) { 55 switch(entry->e_tag) {
57 case ACL_USER_OBJ: 56 case ACL_USER_OBJ:
58 *p++ = htonl(nfsacl_desc->uid); 57 *p++ = htonl(nfsacl_desc->uid);
59 break; 58 break;
60 case ACL_GROUP_OBJ: 59 case ACL_GROUP_OBJ:
61 *p++ = htonl(nfsacl_desc->gid); 60 *p++ = htonl(nfsacl_desc->gid);
62 break; 61 break;
63 case ACL_USER: 62 case ACL_USER:
64 case ACL_GROUP: 63 case ACL_GROUP:
65 *p++ = htonl(entry->e_id); 64 *p++ = htonl(entry->e_id);
66 break; 65 break;
67 default: /* Solaris depends on that! */ 66 default: /* Solaris depends on that! */
68 *p++ = 0; 67 *p++ = 0;
69 break; 68 break;
70 }
71 *p++ = htonl(entry->e_perm & S_IRWXO);
72 } else {
73 const struct posix_acl_entry *pa, *pe;
74 int group_obj_perm = ACL_READ|ACL_WRITE|ACL_EXECUTE;
75
76 FOREACH_ACL_ENTRY(pa, nfsacl_desc->acl, pe) {
77 if (pa->e_tag == ACL_GROUP_OBJ) {
78 group_obj_perm = pa->e_perm & S_IRWXO;
79 break;
80 }
81 }
82 /* fake up ACL_MASK entry */
83 *p++ = htonl(ACL_MASK | nfsacl_desc->typeflag);
84 *p++ = htonl(0);
85 *p++ = htonl(group_obj_perm);
86 } 69 }
87 70 *p++ = htonl(entry->e_perm & S_IRWXO);
88 return 0; 71 return 0;
89} 72}
90 73
@@ -105,11 +88,28 @@ nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
105 .gid = inode->i_gid, 88 .gid = inode->i_gid,
106 }; 89 };
107 int err; 90 int err;
91 struct posix_acl *acl2 = NULL;
108 92
109 if (entries > NFS_ACL_MAX_ENTRIES || 93 if (entries > NFS_ACL_MAX_ENTRIES ||
110 xdr_encode_word(buf, base, entries)) 94 xdr_encode_word(buf, base, entries))
111 return -EINVAL; 95 return -EINVAL;
96 if (encode_entries && acl && acl->a_count == 3) {
97 /* Fake up an ACL_MASK entry. */
98 acl2 = posix_acl_alloc(4, GFP_KERNEL);
99 if (!acl2)
100 return -ENOMEM;
101 /* Insert entries in canonical order: other orders seem
102 to confuse Solaris VxFS. */
103 acl2->a_entries[0] = acl->a_entries[0]; /* ACL_USER_OBJ */
104 acl2->a_entries[1] = acl->a_entries[1]; /* ACL_GROUP_OBJ */
105 acl2->a_entries[2] = acl->a_entries[1]; /* ACL_MASK */
106 acl2->a_entries[2].e_tag = ACL_MASK;
107 acl2->a_entries[3] = acl->a_entries[2]; /* ACL_OTHER */
108 nfsacl_desc.acl = acl2;
109 }
112 err = xdr_encode_array2(buf, base + 4, &nfsacl_desc.desc); 110 err = xdr_encode_array2(buf, base + 4, &nfsacl_desc.desc);
111 if (acl2)
112 posix_acl_release(acl2);
113 if (!err) 113 if (!err)
114 err = 8 + nfsacl_desc.desc.elem_size * 114 err = 8 + nfsacl_desc.desc.elem_size *
115 nfsacl_desc.desc.array_len; 115 nfsacl_desc.desc.array_len;
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 49eafbdb15c1..de58579a1d0e 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -29,7 +29,8 @@ ToDo/Notes:
29 The Windows boot will run chkdsk and then reboot. The user can then 29 The Windows boot will run chkdsk and then reboot. The user can then
30 immediately boot into Linux rather than having to do a full Windows 30 immediately boot into Linux rather than having to do a full Windows
31 boot first before rebooting into Linux and we will recognize such a 31 boot first before rebooting into Linux and we will recognize such a
32 journal and empty it as it is clean by definition. 32 journal and empty it as it is clean by definition. Note, this only
33 works if chkdsk left the journal in an obviously clean state.
33 - Support journals ($LogFile) with only one restart page as well as 34 - Support journals ($LogFile) with only one restart page as well as
34 journals with two different restart pages. We sanity check both and 35 journals with two different restart pages. We sanity check both and
35 either use the only sane one or the more recent one of the two in the 36 either use the only sane one or the more recent one of the two in the
@@ -92,6 +93,18 @@ ToDo/Notes:
92 an octal number to conform to how chmod(1) works, too. Thanks to 93 an octal number to conform to how chmod(1) works, too. Thanks to
93 Giuseppe Bilotta and Horst von Brand for pointing out the errors of 94 Giuseppe Bilotta and Horst von Brand for pointing out the errors of
94 my ways. 95 my ways.
96 - Fix various bugs in the runlist merging code. (Based on libntfs
97 changes by Richard Russon.)
98 - Fix sparse warnings that have crept in over time.
99 - Change ntfs_cluster_free() to require a write locked runlist on entry
100 since we otherwise get into a lock reversal deadlock if a read locked
101 runlist is passed in. In the process also change it to take an ntfs
102 inode instead of a vfs inode as parameter.
103 - Fix the definition of the CHKD ntfs record magic. It had an off by
104 two error causing it to be CHKB instead of CHKD.
105 - Fix a stupid bug in __ntfs_bitmap_set_bits_in_run() which caused the
106 count to become negative and hence we had a wild memset() scribbling
107 all over the system's ram.
95 108
962.1.23 - Implement extension of resident files and make writing safe as well as 1092.1.23 - Implement extension of resident files and make writing safe as well as
97 many bug fixes, cleanups, and enhancements... 110 many bug fixes, cleanups, and enhancements...
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index b6cc8cf24626..5e80c07c6a4d 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -59,39 +59,49 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
59 unsigned long flags; 59 unsigned long flags;
60 struct buffer_head *first, *tmp; 60 struct buffer_head *first, *tmp;
61 struct page *page; 61 struct page *page;
62 struct inode *vi;
62 ntfs_inode *ni; 63 ntfs_inode *ni;
63 int page_uptodate = 1; 64 int page_uptodate = 1;
64 65
65 page = bh->b_page; 66 page = bh->b_page;
66 ni = NTFS_I(page->mapping->host); 67 vi = page->mapping->host;
68 ni = NTFS_I(vi);
67 69
68 if (likely(uptodate)) { 70 if (likely(uptodate)) {
69 s64 file_ofs, initialized_size; 71 loff_t i_size;
72 s64 file_ofs, init_size;
70 73
71 set_buffer_uptodate(bh); 74 set_buffer_uptodate(bh);
72 75
73 file_ofs = ((s64)page->index << PAGE_CACHE_SHIFT) + 76 file_ofs = ((s64)page->index << PAGE_CACHE_SHIFT) +
74 bh_offset(bh); 77 bh_offset(bh);
75 read_lock_irqsave(&ni->size_lock, flags); 78 read_lock_irqsave(&ni->size_lock, flags);
76 initialized_size = ni->initialized_size; 79 init_size = ni->initialized_size;
80 i_size = i_size_read(vi);
77 read_unlock_irqrestore(&ni->size_lock, flags); 81 read_unlock_irqrestore(&ni->size_lock, flags);
82 if (unlikely(init_size > i_size)) {
83 /* Race with shrinking truncate. */
84 init_size = i_size;
85 }
78 /* Check for the current buffer head overflowing. */ 86 /* Check for the current buffer head overflowing. */
79 if (file_ofs + bh->b_size > initialized_size) { 87 if (unlikely(file_ofs + bh->b_size > init_size)) {
80 char *addr; 88 u8 *kaddr;
81 int ofs = 0; 89 int ofs;
82 90
83 if (file_ofs < initialized_size) 91 ofs = 0;
84 ofs = initialized_size - file_ofs; 92 if (file_ofs < init_size)
85 addr = kmap_atomic(page, KM_BIO_SRC_IRQ); 93 ofs = init_size - file_ofs;
86 memset(addr + bh_offset(bh) + ofs, 0, bh->b_size - ofs); 94 kaddr = kmap_atomic(page, KM_BIO_SRC_IRQ);
95 memset(kaddr + bh_offset(bh) + ofs, 0,
96 bh->b_size - ofs);
97 kunmap_atomic(kaddr, KM_BIO_SRC_IRQ);
87 flush_dcache_page(page); 98 flush_dcache_page(page);
88 kunmap_atomic(addr, KM_BIO_SRC_IRQ);
89 } 99 }
90 } else { 100 } else {
91 clear_buffer_uptodate(bh); 101 clear_buffer_uptodate(bh);
92 SetPageError(page); 102 SetPageError(page);
93 ntfs_error(ni->vol->sb, "Buffer I/O error, logical block %llu.", 103 ntfs_error(ni->vol->sb, "Buffer I/O error, logical block "
94 (unsigned long long)bh->b_blocknr); 104 "0x%llx.", (unsigned long long)bh->b_blocknr);
95 } 105 }
96 first = page_buffers(page); 106 first = page_buffers(page);
97 local_irq_save(flags); 107 local_irq_save(flags);
@@ -124,7 +134,7 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
124 if (likely(page_uptodate && !PageError(page))) 134 if (likely(page_uptodate && !PageError(page)))
125 SetPageUptodate(page); 135 SetPageUptodate(page);
126 } else { 136 } else {
127 char *addr; 137 u8 *kaddr;
128 unsigned int i, recs; 138 unsigned int i, recs;
129 u32 rec_size; 139 u32 rec_size;
130 140
@@ -132,12 +142,12 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
132 recs = PAGE_CACHE_SIZE / rec_size; 142 recs = PAGE_CACHE_SIZE / rec_size;
133 /* Should have been verified before we got here... */ 143 /* Should have been verified before we got here... */
134 BUG_ON(!recs); 144 BUG_ON(!recs);
135 addr = kmap_atomic(page, KM_BIO_SRC_IRQ); 145 kaddr = kmap_atomic(page, KM_BIO_SRC_IRQ);
136 for (i = 0; i < recs; i++) 146 for (i = 0; i < recs; i++)
137 post_read_mst_fixup((NTFS_RECORD*)(addr + 147 post_read_mst_fixup((NTFS_RECORD*)(kaddr +
138 i * rec_size), rec_size); 148 i * rec_size), rec_size);
149 kunmap_atomic(kaddr, KM_BIO_SRC_IRQ);
139 flush_dcache_page(page); 150 flush_dcache_page(page);
140 kunmap_atomic(addr, KM_BIO_SRC_IRQ);
141 if (likely(page_uptodate && !PageError(page))) 151 if (likely(page_uptodate && !PageError(page)))
142 SetPageUptodate(page); 152 SetPageUptodate(page);
143 } 153 }
@@ -168,8 +178,11 @@ still_busy:
168 */ 178 */
169static int ntfs_read_block(struct page *page) 179static int ntfs_read_block(struct page *page)
170{ 180{
181 loff_t i_size;
171 VCN vcn; 182 VCN vcn;
172 LCN lcn; 183 LCN lcn;
184 s64 init_size;
185 struct inode *vi;
173 ntfs_inode *ni; 186 ntfs_inode *ni;
174 ntfs_volume *vol; 187 ntfs_volume *vol;
175 runlist_element *rl; 188 runlist_element *rl;
@@ -180,7 +193,8 @@ static int ntfs_read_block(struct page *page)
180 int i, nr; 193 int i, nr;
181 unsigned char blocksize_bits; 194 unsigned char blocksize_bits;
182 195
183 ni = NTFS_I(page->mapping->host); 196 vi = page->mapping->host;
197 ni = NTFS_I(vi);
184 vol = ni->vol; 198 vol = ni->vol;
185 199
186 /* $MFT/$DATA must have its complete runlist in memory at all times. */ 200 /* $MFT/$DATA must have its complete runlist in memory at all times. */
@@ -199,11 +213,28 @@ static int ntfs_read_block(struct page *page)
199 bh = head = page_buffers(page); 213 bh = head = page_buffers(page);
200 BUG_ON(!bh); 214 BUG_ON(!bh);
201 215
216 /*
217 * We may be racing with truncate. To avoid some of the problems we
218 * now take a snapshot of the various sizes and use those for the whole
219 * of the function. In case of an extending truncate it just means we
220 * may leave some buffers unmapped which are now allocated. This is
221 * not a problem since these buffers will just get mapped when a write
222 * occurs. In case of a shrinking truncate, we will detect this later
223 * on due to the runlist being incomplete and if the page is being
224 * fully truncated, truncate will throw it away as soon as we unlock
225 * it so no need to worry what we do with it.
226 */
202 iblock = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits); 227 iblock = (s64)page->index << (PAGE_CACHE_SHIFT - blocksize_bits);
203 read_lock_irqsave(&ni->size_lock, flags); 228 read_lock_irqsave(&ni->size_lock, flags);
204 lblock = (ni->allocated_size + blocksize - 1) >> blocksize_bits; 229 lblock = (ni->allocated_size + blocksize - 1) >> blocksize_bits;
205 zblock = (ni->initialized_size + blocksize - 1) >> blocksize_bits; 230 init_size = ni->initialized_size;
231 i_size = i_size_read(vi);
206 read_unlock_irqrestore(&ni->size_lock, flags); 232 read_unlock_irqrestore(&ni->size_lock, flags);
233 if (unlikely(init_size > i_size)) {
234 /* Race with shrinking truncate. */
235 init_size = i_size;
236 }
237 zblock = (init_size + blocksize - 1) >> blocksize_bits;
207 238
208 /* Loop through all the buffers in the page. */ 239 /* Loop through all the buffers in the page. */
209 rl = NULL; 240 rl = NULL;
@@ -366,6 +397,8 @@ handle_zblock:
366 */ 397 */
367static int ntfs_readpage(struct file *file, struct page *page) 398static int ntfs_readpage(struct file *file, struct page *page)
368{ 399{
400 loff_t i_size;
401 struct inode *vi;
369 ntfs_inode *ni, *base_ni; 402 ntfs_inode *ni, *base_ni;
370 u8 *kaddr; 403 u8 *kaddr;
371 ntfs_attr_search_ctx *ctx; 404 ntfs_attr_search_ctx *ctx;
@@ -384,14 +417,17 @@ retry_readpage:
384 unlock_page(page); 417 unlock_page(page);
385 return 0; 418 return 0;
386 } 419 }
387 ni = NTFS_I(page->mapping->host); 420 vi = page->mapping->host;
421 ni = NTFS_I(vi);
388 /* 422 /*
389 * Only $DATA attributes can be encrypted and only unnamed $DATA 423 * Only $DATA attributes can be encrypted and only unnamed $DATA
390 * attributes can be compressed. Index root can have the flags set but 424 * attributes can be compressed. Index root can have the flags set but
391 * this means to create compressed/encrypted files, not that the 425 * this means to create compressed/encrypted files, not that the
392 * attribute is compressed/encrypted. 426 * attribute is compressed/encrypted. Note we need to check for
427 * AT_INDEX_ALLOCATION since this is the type of both directory and
428 * index inodes.
393 */ 429 */
394 if (ni->type != AT_INDEX_ROOT) { 430 if (ni->type != AT_INDEX_ALLOCATION) {
395 /* If attribute is encrypted, deny access, just like NT4. */ 431 /* If attribute is encrypted, deny access, just like NT4. */
396 if (NInoEncrypted(ni)) { 432 if (NInoEncrypted(ni)) {
397 BUG_ON(ni->type != AT_DATA); 433 BUG_ON(ni->type != AT_DATA);
@@ -456,7 +492,12 @@ retry_readpage:
456 read_lock_irqsave(&ni->size_lock, flags); 492 read_lock_irqsave(&ni->size_lock, flags);
457 if (unlikely(attr_len > ni->initialized_size)) 493 if (unlikely(attr_len > ni->initialized_size))
458 attr_len = ni->initialized_size; 494 attr_len = ni->initialized_size;
495 i_size = i_size_read(vi);
459 read_unlock_irqrestore(&ni->size_lock, flags); 496 read_unlock_irqrestore(&ni->size_lock, flags);
497 if (unlikely(attr_len > i_size)) {
498 /* Race with shrinking truncate. */
499 attr_len = i_size;
500 }
460 kaddr = kmap_atomic(page, KM_USER0); 501 kaddr = kmap_atomic(page, KM_USER0);
461 /* Copy the data to the page. */ 502 /* Copy the data to the page. */
462 memcpy(kaddr, (u8*)ctx->attr + 503 memcpy(kaddr, (u8*)ctx->attr +
@@ -1341,9 +1382,11 @@ retry_writepage:
1341 * Only $DATA attributes can be encrypted and only unnamed $DATA 1382 * Only $DATA attributes can be encrypted and only unnamed $DATA
1342 * attributes can be compressed. Index root can have the flags set but 1383 * attributes can be compressed. Index root can have the flags set but
1343 * this means to create compressed/encrypted files, not that the 1384 * this means to create compressed/encrypted files, not that the
1344 * attribute is compressed/encrypted. 1385 * attribute is compressed/encrypted. Note we need to check for
1386 * AT_INDEX_ALLOCATION since this is the type of both directory and
1387 * index inodes.
1345 */ 1388 */
1346 if (ni->type != AT_INDEX_ROOT) { 1389 if (ni->type != AT_INDEX_ALLOCATION) {
1347 /* If file is encrypted, deny access, just like NT4. */ 1390 /* If file is encrypted, deny access, just like NT4. */
1348 if (NInoEncrypted(ni)) { 1391 if (NInoEncrypted(ni)) {
1349 unlock_page(page); 1392 unlock_page(page);
@@ -1379,8 +1422,8 @@ retry_writepage:
1379 unsigned int ofs = i_size & ~PAGE_CACHE_MASK; 1422 unsigned int ofs = i_size & ~PAGE_CACHE_MASK;
1380 kaddr = kmap_atomic(page, KM_USER0); 1423 kaddr = kmap_atomic(page, KM_USER0);
1381 memset(kaddr + ofs, 0, PAGE_CACHE_SIZE - ofs); 1424 memset(kaddr + ofs, 0, PAGE_CACHE_SIZE - ofs);
1382 flush_dcache_page(page);
1383 kunmap_atomic(kaddr, KM_USER0); 1425 kunmap_atomic(kaddr, KM_USER0);
1426 flush_dcache_page(page);
1384 } 1427 }
1385 /* Handle mst protected attributes. */ 1428 /* Handle mst protected attributes. */
1386 if (NInoMstProtected(ni)) 1429 if (NInoMstProtected(ni))
@@ -1443,34 +1486,33 @@ retry_writepage:
1443 BUG_ON(PageWriteback(page)); 1486 BUG_ON(PageWriteback(page));
1444 set_page_writeback(page); 1487 set_page_writeback(page);
1445 unlock_page(page); 1488 unlock_page(page);
1446 /*
1447 * Here, we do not need to zero the out of bounds area everytime
1448 * because the below memcpy() already takes care of the
1449 * mmap-at-end-of-file requirements. If the file is converted to a
1450 * non-resident one, then the code path use is switched to the
1451 * non-resident one where the zeroing happens on each ntfs_writepage()
1452 * invocation.
1453 */
1454 attr_len = le32_to_cpu(ctx->attr->data.resident.value_length); 1489 attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
1455 i_size = i_size_read(vi); 1490 i_size = i_size_read(vi);
1456 if (unlikely(attr_len > i_size)) { 1491 if (unlikely(attr_len > i_size)) {
1492 /* Race with shrinking truncate or a failed truncate. */
1457 attr_len = i_size; 1493 attr_len = i_size;
1458 ctx->attr->data.resident.value_length = cpu_to_le32(attr_len); 1494 /*
1495 * If the truncate failed, fix it up now. If a concurrent
1496 * truncate, we do its job, so it does not have to do anything.
1497 */
1498 err = ntfs_resident_attr_value_resize(ctx->mrec, ctx->attr,
1499 attr_len);
1500 /* Shrinking cannot fail. */
1501 BUG_ON(err);
1459 } 1502 }
1460 kaddr = kmap_atomic(page, KM_USER0); 1503 kaddr = kmap_atomic(page, KM_USER0);
1461 /* Copy the data from the page to the mft record. */ 1504 /* Copy the data from the page to the mft record. */
1462 memcpy((u8*)ctx->attr + 1505 memcpy((u8*)ctx->attr +
1463 le16_to_cpu(ctx->attr->data.resident.value_offset), 1506 le16_to_cpu(ctx->attr->data.resident.value_offset),
1464 kaddr, attr_len); 1507 kaddr, attr_len);
1465 flush_dcache_mft_record_page(ctx->ntfs_ino);
1466 /* Zero out of bounds area in the page cache page. */ 1508 /* Zero out of bounds area in the page cache page. */
1467 memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len); 1509 memset(kaddr + attr_len, 0, PAGE_CACHE_SIZE - attr_len);
1468 flush_dcache_page(page);
1469 kunmap_atomic(kaddr, KM_USER0); 1510 kunmap_atomic(kaddr, KM_USER0);
1470 1511 flush_dcache_mft_record_page(ctx->ntfs_ino);
1512 flush_dcache_page(page);
1513 /* We are done with the page. */
1471 end_page_writeback(page); 1514 end_page_writeback(page);
1472 1515 /* Finally, mark the mft record dirty, so it gets written back. */
1473 /* Mark the mft record dirty, so it gets written back. */
1474 mark_mft_record_dirty(ctx->ntfs_ino); 1516 mark_mft_record_dirty(ctx->ntfs_ino);
1475 ntfs_attr_put_search_ctx(ctx); 1517 ntfs_attr_put_search_ctx(ctx);
1476 unmap_mft_record(base_ni); 1518 unmap_mft_record(base_ni);
diff --git a/fs/ntfs/bitmap.c b/fs/ntfs/bitmap.c
index 12cf2e30c7dd..7a190cdc60e2 100644
--- a/fs/ntfs/bitmap.c
+++ b/fs/ntfs/bitmap.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * bitmap.c - NTFS kernel bitmap handling. Part of the Linux-NTFS project. 2 * bitmap.c - NTFS kernel bitmap handling. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2004 Anton Altaparmakov 4 * Copyright (c) 2004-2005 Anton Altaparmakov
5 * 5 *
6 * This program/include file is free software; you can redistribute it and/or 6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published 7 * modify it under the terms of the GNU General Public License as published
@@ -90,7 +90,8 @@ int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
90 /* If the first byte is partial, modify the appropriate bits in it. */ 90 /* If the first byte is partial, modify the appropriate bits in it. */
91 if (bit) { 91 if (bit) {
92 u8 *byte = kaddr + pos; 92 u8 *byte = kaddr + pos;
93 while ((bit & 7) && cnt--) { 93 while ((bit & 7) && cnt) {
94 cnt--;
94 if (value) 95 if (value)
95 *byte |= 1 << bit++; 96 *byte |= 1 << bit++;
96 else 97 else
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index dc4bbe3acf5c..7ec045131808 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1166,6 +1166,8 @@ err_out:
1166 * 1166 *
1167 * Return 0 on success and -errno on error. In the error case, the inode will 1167 * Return 0 on success and -errno on error. In the error case, the inode will
1168 * have had make_bad_inode() executed on it. 1168 * have had make_bad_inode() executed on it.
1169 *
1170 * Note this cannot be called for AT_INDEX_ALLOCATION.
1169 */ 1171 */
1170static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) 1172static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1171{ 1173{
@@ -1242,8 +1244,8 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1242 } 1244 }
1243 } 1245 }
1244 /* 1246 /*
1245 * The encryption flag set in an index root just means to 1247 * The compressed/sparse flag set in an index root just means
1246 * compress all files. 1248 * to compress all files.
1247 */ 1249 */
1248 if (NInoMstProtected(ni) && ni->type != AT_INDEX_ROOT) { 1250 if (NInoMstProtected(ni) && ni->type != AT_INDEX_ROOT) {
1249 ntfs_error(vi->i_sb, "Found mst protected attribute " 1251 ntfs_error(vi->i_sb, "Found mst protected attribute "
@@ -1319,8 +1321,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1319 "the mapping pairs array."); 1321 "the mapping pairs array.");
1320 goto unm_err_out; 1322 goto unm_err_out;
1321 } 1323 }
1322 if ((NInoCompressed(ni) || NInoSparse(ni)) && 1324 if (NInoCompressed(ni) || NInoSparse(ni)) {
1323 ni->type != AT_INDEX_ROOT) {
1324 if (a->data.non_resident.compression_unit != 4) { 1325 if (a->data.non_resident.compression_unit != 4) {
1325 ntfs_error(vi->i_sb, "Found nonstandard " 1326 ntfs_error(vi->i_sb, "Found nonstandard "
1326 "compression unit (%u instead " 1327 "compression unit (%u instead "
diff --git a/fs/ntfs/layout.h b/fs/ntfs/layout.h
index 609ad1728ce4..5c248d404f05 100644
--- a/fs/ntfs/layout.h
+++ b/fs/ntfs/layout.h
@@ -123,7 +123,7 @@ enum {
123 magic_RCRD = const_cpu_to_le32(0x44524352), /* Log record page. */ 123 magic_RCRD = const_cpu_to_le32(0x44524352), /* Log record page. */
124 124
125 /* Found in $LogFile/$DATA. (May be found in $MFT/$DATA, also?) */ 125 /* Found in $LogFile/$DATA. (May be found in $MFT/$DATA, also?) */
126 magic_CHKD = const_cpu_to_le32(0x424b4843), /* Modified by chkdsk. */ 126 magic_CHKD = const_cpu_to_le32(0x444b4843), /* Modified by chkdsk. */
127 127
128 /* Found in all ntfs record containing records. */ 128 /* Found in all ntfs record containing records. */
129 magic_BAAD = const_cpu_to_le32(0x44414142), /* Failed multi sector 129 magic_BAAD = const_cpu_to_le32(0x44414142), /* Failed multi sector
@@ -308,10 +308,8 @@ typedef le16 MFT_RECORD_FLAGS;
308 * The _LE versions are to be applied on little endian MFT_REFs. 308 * The _LE versions are to be applied on little endian MFT_REFs.
309 * Note: The _LE versions will return a CPU endian formatted value! 309 * Note: The _LE versions will return a CPU endian formatted value!
310 */ 310 */
311typedef enum { 311#define MFT_REF_MASK_CPU 0x0000ffffffffffffULL
312 MFT_REF_MASK_CPU = 0x0000ffffffffffffULL, 312#define MFT_REF_MASK_LE const_cpu_to_le64(MFT_REF_MASK_CPU)
313 MFT_REF_MASK_LE = const_cpu_to_le64(0x0000ffffffffffffULL),
314} MFT_REF_CONSTS;
315 313
316typedef u64 MFT_REF; 314typedef u64 MFT_REF;
317typedef le64 leMFT_REF; 315typedef le64 leMFT_REF;
diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c
index 7b5934290685..5af3bf0b7eee 100644
--- a/fs/ntfs/lcnalloc.c
+++ b/fs/ntfs/lcnalloc.c
@@ -779,14 +779,13 @@ out:
779 779
780/** 780/**
781 * __ntfs_cluster_free - free clusters on an ntfs volume 781 * __ntfs_cluster_free - free clusters on an ntfs volume
782 * @vi: vfs inode whose runlist describes the clusters to free 782 * @ni: ntfs inode whose runlist describes the clusters to free
783 * @start_vcn: vcn in the runlist of @vi at which to start freeing clusters 783 * @start_vcn: vcn in the runlist of @ni at which to start freeing clusters
784 * @count: number of clusters to free or -1 for all clusters 784 * @count: number of clusters to free or -1 for all clusters
785 * @write_locked: true if the runlist is locked for writing
786 * @is_rollback: true if this is a rollback operation 785 * @is_rollback: true if this is a rollback operation
787 * 786 *
788 * Free @count clusters starting at the cluster @start_vcn in the runlist 787 * Free @count clusters starting at the cluster @start_vcn in the runlist
789 * described by the vfs inode @vi. 788 * described by the vfs inode @ni.
790 * 789 *
791 * If @count is -1, all clusters from @start_vcn to the end of the runlist are 790 * If @count is -1, all clusters from @start_vcn to the end of the runlist are
792 * deallocated. Thus, to completely free all clusters in a runlist, use 791 * deallocated. Thus, to completely free all clusters in a runlist, use
@@ -801,31 +800,28 @@ out:
801 * Return the number of deallocated clusters (not counting sparse ones) on 800 * Return the number of deallocated clusters (not counting sparse ones) on
802 * success and -errno on error. 801 * success and -errno on error.
803 * 802 *
804 * Locking: - The runlist described by @vi must be locked on entry and is 803 * Locking: - The runlist described by @ni must be locked for writing on entry
805 * locked on return. Note if the runlist is locked for reading the 804 * and is locked on return. Note the runlist may be modified when
806 * lock may be dropped and reacquired. Note the runlist may be 805 * needed runlist fragments need to be mapped.
807 * modified when needed runlist fragments need to be mapped.
808 * - The volume lcn bitmap must be unlocked on entry and is unlocked 806 * - The volume lcn bitmap must be unlocked on entry and is unlocked
809 * on return. 807 * on return.
810 * - This function takes the volume lcn bitmap lock for writing and 808 * - This function takes the volume lcn bitmap lock for writing and
811 * modifies the bitmap contents. 809 * modifies the bitmap contents.
812 */ 810 */
813s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count, 811s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn, s64 count,
814 const BOOL write_locked, const BOOL is_rollback) 812 const BOOL is_rollback)
815{ 813{
816 s64 delta, to_free, total_freed, real_freed; 814 s64 delta, to_free, total_freed, real_freed;
817 ntfs_inode *ni;
818 ntfs_volume *vol; 815 ntfs_volume *vol;
819 struct inode *lcnbmp_vi; 816 struct inode *lcnbmp_vi;
820 runlist_element *rl; 817 runlist_element *rl;
821 int err; 818 int err;
822 819
823 BUG_ON(!vi); 820 BUG_ON(!ni);
824 ntfs_debug("Entering for i_ino 0x%lx, start_vcn 0x%llx, count " 821 ntfs_debug("Entering for i_ino 0x%lx, start_vcn 0x%llx, count "
825 "0x%llx.%s", vi->i_ino, (unsigned long long)start_vcn, 822 "0x%llx.%s", ni->mft_no, (unsigned long long)start_vcn,
826 (unsigned long long)count, 823 (unsigned long long)count,
827 is_rollback ? " (rollback)" : ""); 824 is_rollback ? " (rollback)" : "");
828 ni = NTFS_I(vi);
829 vol = ni->vol; 825 vol = ni->vol;
830 lcnbmp_vi = vol->lcnbmp_ino; 826 lcnbmp_vi = vol->lcnbmp_ino;
831 BUG_ON(!lcnbmp_vi); 827 BUG_ON(!lcnbmp_vi);
@@ -843,7 +839,7 @@ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count,
843 839
844 total_freed = real_freed = 0; 840 total_freed = real_freed = 0;
845 841
846 rl = ntfs_attr_find_vcn_nolock(ni, start_vcn, write_locked); 842 rl = ntfs_attr_find_vcn_nolock(ni, start_vcn, TRUE);
847 if (IS_ERR(rl)) { 843 if (IS_ERR(rl)) {
848 if (!is_rollback) 844 if (!is_rollback)
849 ntfs_error(vol->sb, "Failed to find first runlist " 845 ntfs_error(vol->sb, "Failed to find first runlist "
@@ -897,7 +893,7 @@ s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, s64 count,
897 893
898 /* Attempt to map runlist. */ 894 /* Attempt to map runlist. */
899 vcn = rl->vcn; 895 vcn = rl->vcn;
900 rl = ntfs_attr_find_vcn_nolock(ni, vcn, write_locked); 896 rl = ntfs_attr_find_vcn_nolock(ni, vcn, TRUE);
901 if (IS_ERR(rl)) { 897 if (IS_ERR(rl)) {
902 err = PTR_ERR(rl); 898 err = PTR_ERR(rl);
903 if (!is_rollback) 899 if (!is_rollback)
@@ -965,8 +961,7 @@ err_out:
965 * If rollback fails, set the volume errors flag, emit an error 961 * If rollback fails, set the volume errors flag, emit an error
966 * message, and return the error code. 962 * message, and return the error code.
967 */ 963 */
968 delta = __ntfs_cluster_free(vi, start_vcn, total_freed, write_locked, 964 delta = __ntfs_cluster_free(ni, start_vcn, total_freed, TRUE);
969 TRUE);
970 if (delta < 0) { 965 if (delta < 0) {
971 ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving " 966 ntfs_error(vol->sb, "Failed to rollback (error %i). Leaving "
972 "inconsistent metadata! Unmount and run " 967 "inconsistent metadata! Unmount and run "
diff --git a/fs/ntfs/lcnalloc.h b/fs/ntfs/lcnalloc.h
index e4d7fb98d685..a6a8827882e7 100644
--- a/fs/ntfs/lcnalloc.h
+++ b/fs/ntfs/lcnalloc.h
@@ -2,7 +2,7 @@
2 * lcnalloc.h - Exports for NTFS kernel cluster (de)allocation. Part of the 2 * lcnalloc.h - Exports for NTFS kernel cluster (de)allocation. Part of the
3 * Linux-NTFS project. 3 * Linux-NTFS project.
4 * 4 *
5 * Copyright (c) 2004 Anton Altaparmakov 5 * Copyright (c) 2004-2005 Anton Altaparmakov
6 * 6 *
7 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as published 8 * modify it under the terms of the GNU General Public License as published
@@ -28,6 +28,7 @@
28#include <linux/fs.h> 28#include <linux/fs.h>
29 29
30#include "types.h" 30#include "types.h"
31#include "inode.h"
31#include "runlist.h" 32#include "runlist.h"
32#include "volume.h" 33#include "volume.h"
33 34
@@ -42,18 +43,17 @@ extern runlist_element *ntfs_cluster_alloc(ntfs_volume *vol,
42 const VCN start_vcn, const s64 count, const LCN start_lcn, 43 const VCN start_vcn, const s64 count, const LCN start_lcn,
43 const NTFS_CLUSTER_ALLOCATION_ZONES zone); 44 const NTFS_CLUSTER_ALLOCATION_ZONES zone);
44 45
45extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn, 46extern s64 __ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn,
46 s64 count, const BOOL write_locked, const BOOL is_rollback); 47 s64 count, const BOOL is_rollback);
47 48
48/** 49/**
49 * ntfs_cluster_free - free clusters on an ntfs volume 50 * ntfs_cluster_free - free clusters on an ntfs volume
50 * @vi: vfs inode whose runlist describes the clusters to free 51 * @ni: ntfs inode whose runlist describes the clusters to free
51 * @start_vcn: vcn in the runlist of @vi at which to start freeing clusters 52 * @start_vcn: vcn in the runlist of @ni at which to start freeing clusters
52 * @count: number of clusters to free or -1 for all clusters 53 * @count: number of clusters to free or -1 for all clusters
53 * @write_locked: true if the runlist is locked for writing
54 * 54 *
55 * Free @count clusters starting at the cluster @start_vcn in the runlist 55 * Free @count clusters starting at the cluster @start_vcn in the runlist
56 * described by the vfs inode @vi. 56 * described by the ntfs inode @ni.
57 * 57 *
58 * If @count is -1, all clusters from @start_vcn to the end of the runlist are 58 * If @count is -1, all clusters from @start_vcn to the end of the runlist are
59 * deallocated. Thus, to completely free all clusters in a runlist, use 59 * deallocated. Thus, to completely free all clusters in a runlist, use
@@ -65,19 +65,18 @@ extern s64 __ntfs_cluster_free(struct inode *vi, const VCN start_vcn,
65 * Return the number of deallocated clusters (not counting sparse ones) on 65 * Return the number of deallocated clusters (not counting sparse ones) on
66 * success and -errno on error. 66 * success and -errno on error.
67 * 67 *
68 * Locking: - The runlist described by @vi must be locked on entry and is 68 * Locking: - The runlist described by @ni must be locked for writing on entry
69 * locked on return. Note if the runlist is locked for reading the 69 * and is locked on return. Note the runlist may be modified when
70 * lock may be dropped and reacquired. Note the runlist may be 70 * needed runlist fragments need to be mapped.
71 * modified when needed runlist fragments need to be mapped.
72 * - The volume lcn bitmap must be unlocked on entry and is unlocked 71 * - The volume lcn bitmap must be unlocked on entry and is unlocked
73 * on return. 72 * on return.
74 * - This function takes the volume lcn bitmap lock for writing and 73 * - This function takes the volume lcn bitmap lock for writing and
75 * modifies the bitmap contents. 74 * modifies the bitmap contents.
76 */ 75 */
77static inline s64 ntfs_cluster_free(struct inode *vi, const VCN start_vcn, 76static inline s64 ntfs_cluster_free(ntfs_inode *ni, const VCN start_vcn,
78 s64 count, const BOOL write_locked) 77 s64 count)
79{ 78{
80 return __ntfs_cluster_free(vi, start_vcn, count, write_locked, FALSE); 79 return __ntfs_cluster_free(ni, start_vcn, count, FALSE);
81} 80}
82 81
83extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol, 82extern int ntfs_cluster_free_from_rl_nolock(ntfs_volume *vol,
diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index 0173e95500d9..0fd70295cca6 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -51,7 +51,8 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi,
51 RESTART_PAGE_HEADER *rp, s64 pos) 51 RESTART_PAGE_HEADER *rp, s64 pos)
52{ 52{
53 u32 logfile_system_page_size, logfile_log_page_size; 53 u32 logfile_system_page_size, logfile_log_page_size;
54 u16 usa_count, usa_ofs, usa_end, ra_ofs; 54 u16 ra_ofs, usa_count, usa_ofs, usa_end = 0;
55 BOOL have_usa = TRUE;
55 56
56 ntfs_debug("Entering."); 57 ntfs_debug("Entering.");
57 /* 58 /*
@@ -86,6 +87,14 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi,
86 (int)sle16_to_cpu(rp->minor_ver)); 87 (int)sle16_to_cpu(rp->minor_ver));
87 return FALSE; 88 return FALSE;
88 } 89 }
90 /*
91 * If chkdsk has been run the restart page may not be protected by an
92 * update sequence array.
93 */
94 if (ntfs_is_chkd_record(rp->magic) && !le16_to_cpu(rp->usa_count)) {
95 have_usa = FALSE;
96 goto skip_usa_checks;
97 }
89 /* Verify the size of the update sequence array. */ 98 /* Verify the size of the update sequence array. */
90 usa_count = 1 + (logfile_system_page_size >> NTFS_BLOCK_SIZE_BITS); 99 usa_count = 1 + (logfile_system_page_size >> NTFS_BLOCK_SIZE_BITS);
91 if (usa_count != le16_to_cpu(rp->usa_count)) { 100 if (usa_count != le16_to_cpu(rp->usa_count)) {
@@ -102,6 +111,7 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi,
102 "inconsistent update sequence array offset."); 111 "inconsistent update sequence array offset.");
103 return FALSE; 112 return FALSE;
104 } 113 }
114skip_usa_checks:
105 /* 115 /*
106 * Verify the position of the restart area. It must be: 116 * Verify the position of the restart area. It must be:
107 * - aligned to 8-byte boundary, 117 * - aligned to 8-byte boundary,
@@ -109,7 +119,8 @@ static BOOL ntfs_check_restart_page_header(struct inode *vi,
109 * - within the system page size. 119 * - within the system page size.
110 */ 120 */
111 ra_ofs = le16_to_cpu(rp->restart_area_offset); 121 ra_ofs = le16_to_cpu(rp->restart_area_offset);
112 if (ra_ofs & 7 || ra_ofs < usa_end || 122 if (ra_ofs & 7 || (have_usa ? ra_ofs < usa_end :
123 ra_ofs < sizeof(RESTART_PAGE_HEADER)) ||
113 ra_ofs > logfile_system_page_size) { 124 ra_ofs > logfile_system_page_size) {
114 ntfs_error(vi->i_sb, "$LogFile restart page specifies " 125 ntfs_error(vi->i_sb, "$LogFile restart page specifies "
115 "inconsistent restart area offset."); 126 "inconsistent restart area offset.");
@@ -402,8 +413,12 @@ static int ntfs_check_and_load_restart_page(struct inode *vi,
402 idx++; 413 idx++;
403 } while (to_read > 0); 414 } while (to_read > 0);
404 } 415 }
405 /* Perform the multi sector transfer deprotection on the buffer. */ 416 /*
406 if (post_read_mst_fixup((NTFS_RECORD*)trp, 417 * Perform the multi sector transfer deprotection on the buffer if the
418 * restart page is protected.
419 */
420 if ((!ntfs_is_chkd_record(trp->magic) || le16_to_cpu(trp->usa_count))
421 && post_read_mst_fixup((NTFS_RECORD*)trp,
407 le32_to_cpu(rp->system_page_size))) { 422 le32_to_cpu(rp->system_page_size))) {
408 /* 423 /*
409 * A multi sector tranfer error was detected. We only need to 424 * A multi sector tranfer error was detected. We only need to
@@ -615,11 +630,16 @@ is_empty:
615 * Otherwise just throw it away. 630 * Otherwise just throw it away.
616 */ 631 */
617 if (rstr2_lsn > rstr1_lsn) { 632 if (rstr2_lsn > rstr1_lsn) {
633 ntfs_debug("Using second restart page as it is more "
634 "recent.");
618 ntfs_free(rstr1_ph); 635 ntfs_free(rstr1_ph);
619 rstr1_ph = rstr2_ph; 636 rstr1_ph = rstr2_ph;
620 /* rstr1_lsn = rstr2_lsn; */ 637 /* rstr1_lsn = rstr2_lsn; */
621 } else 638 } else {
639 ntfs_debug("Using first restart page as it is more "
640 "recent.");
622 ntfs_free(rstr2_ph); 641 ntfs_free(rstr2_ph);
642 }
623 rstr2_ph = NULL; 643 rstr2_ph = NULL;
624 } 644 }
625 /* All consistency checks passed. */ 645 /* All consistency checks passed. */
diff --git a/fs/ntfs/logfile.h b/fs/ntfs/logfile.h
index 42388f95ea6d..a51f3dd0e9eb 100644
--- a/fs/ntfs/logfile.h
+++ b/fs/ntfs/logfile.h
@@ -113,7 +113,7 @@ typedef struct {
113 */ 113 */
114enum { 114enum {
115 RESTART_VOLUME_IS_CLEAN = const_cpu_to_le16(0x0002), 115 RESTART_VOLUME_IS_CLEAN = const_cpu_to_le16(0x0002),
116 RESTART_SPACE_FILLER = 0xffff, /* gcc: Force enum bit width to 16. */ 116 RESTART_SPACE_FILLER = const_cpu_to_le16(0xffff), /* gcc: Force enum bit width to 16. */
117} __attribute__ ((__packed__)); 117} __attribute__ ((__packed__));
118 118
119typedef le16 RESTART_AREA_FLAGS; 119typedef le16 RESTART_AREA_FLAGS;
diff --git a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h
index 3288bcc2c4aa..590887b943f5 100644
--- a/fs/ntfs/malloc.h
+++ b/fs/ntfs/malloc.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * malloc.h - NTFS kernel memory handling. Part of the Linux-NTFS project. 2 * malloc.h - NTFS kernel memory handling. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2004 Anton Altaparmakov 4 * Copyright (c) 2001-2005 Anton Altaparmakov
5 * 5 *
6 * This program/include file is free software; you can redistribute it and/or 6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published 7 * modify it under the terms of the GNU General Public License as published
@@ -40,7 +40,7 @@
40 * Depending on @gfp_mask the allocation may be guaranteed to succeed. 40 * Depending on @gfp_mask the allocation may be guaranteed to succeed.
41 */ 41 */
42static inline void *__ntfs_malloc(unsigned long size, 42static inline void *__ntfs_malloc(unsigned long size,
43 unsigned int __nocast gfp_mask) 43 gfp_t gfp_mask)
44{ 44{
45 if (likely(size <= PAGE_SIZE)) { 45 if (likely(size <= PAGE_SIZE)) {
46 BUG_ON(!size); 46 BUG_ON(!size);
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 2c32b84385a8..b011369b5956 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -58,7 +58,8 @@ static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni)
58 * overflowing the unsigned long, but I don't think we would ever get 58 * overflowing the unsigned long, but I don't think we would ever get
59 * here if the volume was that big... 59 * here if the volume was that big...
60 */ 60 */
61 index = ni->mft_no << vol->mft_record_size_bits >> PAGE_CACHE_SHIFT; 61 index = (u64)ni->mft_no << vol->mft_record_size_bits >>
62 PAGE_CACHE_SHIFT;
62 ofs = (ni->mft_no << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK; 63 ofs = (ni->mft_no << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK;
63 64
64 i_size = i_size_read(mft_vi); 65 i_size = i_size_read(mft_vi);
@@ -1953,7 +1954,7 @@ restore_undo_alloc:
1953 a = ctx->attr; 1954 a = ctx->attr;
1954 a->data.non_resident.highest_vcn = cpu_to_sle64(old_last_vcn - 1); 1955 a->data.non_resident.highest_vcn = cpu_to_sle64(old_last_vcn - 1);
1955undo_alloc: 1956undo_alloc:
1956 if (ntfs_cluster_free(vol->mft_ino, old_last_vcn, -1, TRUE) < 0) { 1957 if (ntfs_cluster_free(mft_ni, old_last_vcn, -1) < 0) {
1957 ntfs_error(vol->sb, "Failed to free clusters from mft data " 1958 ntfs_error(vol->sb, "Failed to free clusters from mft data "
1958 "attribute.%s", es); 1959 "attribute.%s", es);
1959 NVolSetErrors(vol); 1960 NVolSetErrors(vol);
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
index f5b2ac929081..061b5ff6b73c 100644
--- a/fs/ntfs/runlist.c
+++ b/fs/ntfs/runlist.c
@@ -2,7 +2,7 @@
2 * runlist.c - NTFS runlist handling code. Part of the Linux-NTFS project. 2 * runlist.c - NTFS runlist handling code. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2005 Anton Altaparmakov 4 * Copyright (c) 2001-2005 Anton Altaparmakov
5 * Copyright (c) 2002 Richard Russon 5 * Copyright (c) 2002-2005 Richard Russon
6 * 6 *
7 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as published 8 * modify it under the terms of the GNU General Public License as published
@@ -158,17 +158,21 @@ static inline BOOL ntfs_are_rl_mergeable(runlist_element *dst,
158 BUG_ON(!dst); 158 BUG_ON(!dst);
159 BUG_ON(!src); 159 BUG_ON(!src);
160 160
161 if ((dst->lcn < 0) || (src->lcn < 0)) { /* Are we merging holes? */ 161 /* We can merge unmapped regions even if they are misaligned. */
162 if (dst->lcn == LCN_HOLE && src->lcn == LCN_HOLE) 162 if ((dst->lcn == LCN_RL_NOT_MAPPED) && (src->lcn == LCN_RL_NOT_MAPPED))
163 return TRUE; 163 return TRUE;
164 /* If the runs are misaligned, we cannot merge them. */
165 if ((dst->vcn + dst->length) != src->vcn)
164 return FALSE; 166 return FALSE;
165 } 167 /* If both runs are non-sparse and contiguous, we can merge them. */
166 if ((dst->lcn + dst->length) != src->lcn) /* Are the runs contiguous? */ 168 if ((dst->lcn >= 0) && (src->lcn >= 0) &&
167 return FALSE; 169 ((dst->lcn + dst->length) == src->lcn))
168 if ((dst->vcn + dst->length) != src->vcn) /* Are the runs misaligned? */ 170 return TRUE;
169 return FALSE; 171 /* If we are merging two holes, we can merge them. */
170 172 if ((dst->lcn == LCN_HOLE) && (src->lcn == LCN_HOLE))
171 return TRUE; 173 return TRUE;
174 /* Cannot merge. */
175 return FALSE;
172} 176}
173 177
174/** 178/**
@@ -214,14 +218,15 @@ static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src)
214static inline runlist_element *ntfs_rl_append(runlist_element *dst, 218static inline runlist_element *ntfs_rl_append(runlist_element *dst,
215 int dsize, runlist_element *src, int ssize, int loc) 219 int dsize, runlist_element *src, int ssize, int loc)
216{ 220{
217 BOOL right; 221 BOOL right = FALSE; /* Right end of @src needs merging. */
218 int magic; 222 int marker; /* End of the inserted runs. */
219 223
220 BUG_ON(!dst); 224 BUG_ON(!dst);
221 BUG_ON(!src); 225 BUG_ON(!src);
222 226
223 /* First, check if the right hand end needs merging. */ 227 /* First, check if the right hand end needs merging. */
224 right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1); 228 if ((loc + 1) < dsize)
229 right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
225 230
226 /* Space required: @dst size + @src size, less one if we merged. */ 231 /* Space required: @dst size + @src size, less one if we merged. */
227 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - right); 232 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - right);
@@ -236,18 +241,19 @@ static inline runlist_element *ntfs_rl_append(runlist_element *dst,
236 if (right) 241 if (right)
237 __ntfs_rl_merge(src + ssize - 1, dst + loc + 1); 242 __ntfs_rl_merge(src + ssize - 1, dst + loc + 1);
238 243
239 magic = loc + ssize; 244 /* First run after the @src runs that have been inserted. */
245 marker = loc + ssize + 1;
240 246
241 /* Move the tail of @dst out of the way, then copy in @src. */ 247 /* Move the tail of @dst out of the way, then copy in @src. */
242 ntfs_rl_mm(dst, magic + 1, loc + 1 + right, dsize - loc - 1 - right); 248 ntfs_rl_mm(dst, marker, loc + 1 + right, dsize - (loc + 1 + right));
243 ntfs_rl_mc(dst, loc + 1, src, 0, ssize); 249 ntfs_rl_mc(dst, loc + 1, src, 0, ssize);
244 250
245 /* Adjust the size of the preceding hole. */ 251 /* Adjust the size of the preceding hole. */
246 dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn; 252 dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn;
247 253
248 /* We may have changed the length of the file, so fix the end marker */ 254 /* We may have changed the length of the file, so fix the end marker */
249 if (dst[magic + 1].lcn == LCN_ENOENT) 255 if (dst[marker].lcn == LCN_ENOENT)
250 dst[magic + 1].vcn = dst[magic].vcn + dst[magic].length; 256 dst[marker].vcn = dst[marker - 1].vcn + dst[marker - 1].length;
251 257
252 return dst; 258 return dst;
253} 259}
@@ -279,18 +285,17 @@ static inline runlist_element *ntfs_rl_append(runlist_element *dst,
279static inline runlist_element *ntfs_rl_insert(runlist_element *dst, 285static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
280 int dsize, runlist_element *src, int ssize, int loc) 286 int dsize, runlist_element *src, int ssize, int loc)
281{ 287{
282 BOOL left = FALSE; 288 BOOL left = FALSE; /* Left end of @src needs merging. */
283 BOOL disc = FALSE; /* Discontinuity */ 289 BOOL disc = FALSE; /* Discontinuity between @dst and @src. */
284 BOOL hole = FALSE; /* Following a hole */ 290 int marker; /* End of the inserted runs. */
285 int magic;
286 291
287 BUG_ON(!dst); 292 BUG_ON(!dst);
288 BUG_ON(!src); 293 BUG_ON(!src);
289 294
290 /* disc => Discontinuity between the end of @dst and the start of @src. 295 /*
291 * This means we might need to insert a hole. 296 * disc => Discontinuity between the end of @dst and the start of @src.
292 * hole => @dst ends with a hole or an unmapped region which we can 297 * This means we might need to insert a "not mapped" run.
293 * extend to match the discontinuity. */ 298 */
294 if (loc == 0) 299 if (loc == 0)
295 disc = (src[0].vcn > 0); 300 disc = (src[0].vcn > 0);
296 else { 301 else {
@@ -303,58 +308,49 @@ static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
303 merged_length += src->length; 308 merged_length += src->length;
304 309
305 disc = (src[0].vcn > dst[loc - 1].vcn + merged_length); 310 disc = (src[0].vcn > dst[loc - 1].vcn + merged_length);
306 if (disc)
307 hole = (dst[loc - 1].lcn == LCN_HOLE);
308 } 311 }
309 312 /*
310 /* Space required: @dst size + @src size, less one if we merged, plus 313 * Space required: @dst size + @src size, less one if we merged, plus
311 * one if there was a discontinuity, less one for a trailing hole. */ 314 * one if there was a discontinuity.
312 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left + disc - hole); 315 */
316 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left + disc);
313 if (IS_ERR(dst)) 317 if (IS_ERR(dst))
314 return dst; 318 return dst;
315 /* 319 /*
316 * We are guaranteed to succeed from here so can start modifying the 320 * We are guaranteed to succeed from here so can start modifying the
317 * original runlist. 321 * original runlist.
318 */ 322 */
319
320 if (left) 323 if (left)
321 __ntfs_rl_merge(dst + loc - 1, src); 324 __ntfs_rl_merge(dst + loc - 1, src);
322 325 /*
323 magic = loc + ssize - left + disc - hole; 326 * First run after the @src runs that have been inserted.
327 * Nominally, @marker equals @loc + @ssize, i.e. location + number of
328 * runs in @src. However, if @left, then the first run in @src has
329 * been merged with one in @dst. And if @disc, then @dst and @src do
330 * not meet and we need an extra run to fill the gap.
331 */
332 marker = loc + ssize - left + disc;
324 333
325 /* Move the tail of @dst out of the way, then copy in @src. */ 334 /* Move the tail of @dst out of the way, then copy in @src. */
326 ntfs_rl_mm(dst, magic, loc, dsize - loc); 335 ntfs_rl_mm(dst, marker, loc, dsize - loc);
327 ntfs_rl_mc(dst, loc + disc - hole, src, left, ssize - left); 336 ntfs_rl_mc(dst, loc + disc, src, left, ssize - left);
328 337
329 /* Adjust the VCN of the last run ... */ 338 /* Adjust the VCN of the first run after the insertion... */
330 if (dst[magic].lcn <= LCN_HOLE) 339 dst[marker].vcn = dst[marker - 1].vcn + dst[marker - 1].length;
331 dst[magic].vcn = dst[magic - 1].vcn + dst[magic - 1].length;
332 /* ... and the length. */ 340 /* ... and the length. */
333 if (dst[magic].lcn == LCN_HOLE || dst[magic].lcn == LCN_RL_NOT_MAPPED) 341 if (dst[marker].lcn == LCN_HOLE || dst[marker].lcn == LCN_RL_NOT_MAPPED)
334 dst[magic].length = dst[magic + 1].vcn - dst[magic].vcn; 342 dst[marker].length = dst[marker + 1].vcn - dst[marker].vcn;
335 343
336 /* Writing beyond the end of the file and there's a discontinuity. */ 344 /* Writing beyond the end of the file and there is a discontinuity. */
337 if (disc) { 345 if (disc) {
338 if (hole) 346 if (loc > 0) {
339 dst[loc - 1].length = dst[loc].vcn - dst[loc - 1].vcn; 347 dst[loc].vcn = dst[loc - 1].vcn + dst[loc - 1].length;
340 else { 348 dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn;
341 if (loc > 0) { 349 } else {
342 dst[loc].vcn = dst[loc - 1].vcn + 350 dst[loc].vcn = 0;
343 dst[loc - 1].length; 351 dst[loc].length = dst[loc + 1].vcn;
344 dst[loc].length = dst[loc + 1].vcn -
345 dst[loc].vcn;
346 } else {
347 dst[loc].vcn = 0;
348 dst[loc].length = dst[loc + 1].vcn;
349 }
350 dst[loc].lcn = LCN_RL_NOT_MAPPED;
351 } 352 }
352 353 dst[loc].lcn = LCN_RL_NOT_MAPPED;
353 magic += hole;
354
355 if (dst[magic].lcn == LCN_ENOENT)
356 dst[magic].vcn = dst[magic - 1].vcn +
357 dst[magic - 1].length;
358 } 354 }
359 return dst; 355 return dst;
360} 356}
@@ -385,20 +381,23 @@ static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
385static inline runlist_element *ntfs_rl_replace(runlist_element *dst, 381static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
386 int dsize, runlist_element *src, int ssize, int loc) 382 int dsize, runlist_element *src, int ssize, int loc)
387{ 383{
388 BOOL left = FALSE; 384 BOOL left = FALSE; /* Left end of @src needs merging. */
389 BOOL right; 385 BOOL right = FALSE; /* Right end of @src needs merging. */
390 int magic; 386 int tail; /* Start of tail of @dst. */
387 int marker; /* End of the inserted runs. */
391 388
392 BUG_ON(!dst); 389 BUG_ON(!dst);
393 BUG_ON(!src); 390 BUG_ON(!src);
394 391
395 /* First, merge the left and right ends, if necessary. */ 392 /* First, see if the left and right ends need merging. */
396 right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1); 393 if ((loc + 1) < dsize)
394 right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1);
397 if (loc > 0) 395 if (loc > 0)
398 left = ntfs_are_rl_mergeable(dst + loc - 1, src); 396 left = ntfs_are_rl_mergeable(dst + loc - 1, src);
399 397 /*
400 /* Allocate some space. We'll need less if the left, right, or both 398 * Allocate some space. We will need less if the left, right, or both
401 * ends were merged. */ 399 * ends get merged.
400 */
402 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right); 401 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right);
403 if (IS_ERR(dst)) 402 if (IS_ERR(dst))
404 return dst; 403 return dst;
@@ -406,21 +405,37 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
406 * We are guaranteed to succeed from here so can start modifying the 405 * We are guaranteed to succeed from here so can start modifying the
407 * original runlists. 406 * original runlists.
408 */ 407 */
408
409 /* First, merge the left and right ends, if necessary. */
409 if (right) 410 if (right)
410 __ntfs_rl_merge(src + ssize - 1, dst + loc + 1); 411 __ntfs_rl_merge(src + ssize - 1, dst + loc + 1);
411 if (left) 412 if (left)
412 __ntfs_rl_merge(dst + loc - 1, src); 413 __ntfs_rl_merge(dst + loc - 1, src);
413 414 /*
414 /* FIXME: What does this mean? (AIA) */ 415 * Offset of the tail of @dst. This needs to be moved out of the way
415 magic = loc + ssize - left; 416 * to make space for the runs to be copied from @src, i.e. the first
417 * run of the tail of @dst.
418 * Nominally, @tail equals @loc + 1, i.e. location, skipping the
419 * replaced run. However, if @right, then one of @dst's runs is
420 * already merged into @src.
421 */
422 tail = loc + right + 1;
423 /*
424 * First run after the @src runs that have been inserted, i.e. where
425 * the tail of @dst needs to be moved to.
426 * Nominally, @marker equals @loc + @ssize, i.e. location + number of
427 * runs in @src. However, if @left, then the first run in @src has
428 * been merged with one in @dst.
429 */
430 marker = loc + ssize - left;
416 431
417 /* Move the tail of @dst out of the way, then copy in @src. */ 432 /* Move the tail of @dst out of the way, then copy in @src. */
418 ntfs_rl_mm(dst, magic, loc + right + 1, dsize - loc - right - 1); 433 ntfs_rl_mm(dst, marker, tail, dsize - tail);
419 ntfs_rl_mc(dst, loc, src, left, ssize - left); 434 ntfs_rl_mc(dst, loc, src, left, ssize - left);
420 435
421 /* We may have changed the length of the file, so fix the end marker */ 436 /* We may have changed the length of the file, so fix the end marker. */
422 if (dst[magic].lcn == LCN_ENOENT) 437 if (dsize - tail > 0 && dst[marker].lcn == LCN_ENOENT)
423 dst[magic].vcn = dst[magic - 1].vcn + dst[magic - 1].length; 438 dst[marker].vcn = dst[marker - 1].vcn + dst[marker - 1].length;
424 return dst; 439 return dst;
425} 440}
426 441
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
index a389a5a16c84..0ea887fc859c 100644
--- a/fs/ntfs/unistr.c
+++ b/fs/ntfs/unistr.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * unistr.c - NTFS Unicode string handling. Part of the Linux-NTFS project. 2 * unistr.c - NTFS Unicode string handling. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2004 Anton Altaparmakov 4 * Copyright (c) 2001-2005 Anton Altaparmakov
5 * 5 *
6 * This program/include file is free software; you can redistribute it and/or 6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published 7 * modify it under the terms of the GNU General Public License as published
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 296480e96dd5..6c8dcf7613fd 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -35,7 +35,7 @@ EXPORT_SYMBOL(posix_acl_permission);
35 * Allocate a new ACL with the specified number of entries. 35 * Allocate a new ACL with the specified number of entries.
36 */ 36 */
37struct posix_acl * 37struct posix_acl *
38posix_acl_alloc(int count, unsigned int __nocast flags) 38posix_acl_alloc(int count, gfp_t flags)
39{ 39{
40 const size_t size = sizeof(struct posix_acl) + 40 const size_t size = sizeof(struct posix_acl) +
41 count * sizeof(struct posix_acl_entry); 41 count * sizeof(struct posix_acl_entry);
@@ -51,7 +51,7 @@ posix_acl_alloc(int count, unsigned int __nocast flags)
51 * Clone an ACL. 51 * Clone an ACL.
52 */ 52 */
53struct posix_acl * 53struct posix_acl *
54posix_acl_clone(const struct posix_acl *acl, unsigned int __nocast flags) 54posix_acl_clone(const struct posix_acl *acl, gfp_t flags)
55{ 55{
56 struct posix_acl *clone = NULL; 56 struct posix_acl *clone = NULL;
57 57
@@ -185,7 +185,7 @@ posix_acl_equiv_mode(const struct posix_acl *acl, mode_t *mode_p)
185 * Create an ACL representing the file mode permission bits of an inode. 185 * Create an ACL representing the file mode permission bits of an inode.
186 */ 186 */
187struct posix_acl * 187struct posix_acl *
188posix_acl_from_mode(mode_t mode, unsigned int __nocast flags) 188posix_acl_from_mode(mode_t mode, gfp_t flags)
189{ 189{
190 struct posix_acl *acl = posix_acl_alloc(3, flags); 190 struct posix_acl *acl = posix_acl_alloc(3, flags);
191 if (!acl) 191 if (!acl)
diff --git a/fs/proc/array.c b/fs/proc/array.c
index d88d518d30f6..d84eecacbeaf 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -74,6 +74,7 @@
74#include <linux/file.h> 74#include <linux/file.h>
75#include <linux/times.h> 75#include <linux/times.h>
76#include <linux/cpuset.h> 76#include <linux/cpuset.h>
77#include <linux/rcupdate.h>
77 78
78#include <asm/uaccess.h> 79#include <asm/uaccess.h>
79#include <asm/pgtable.h> 80#include <asm/pgtable.h>
@@ -180,12 +181,14 @@ static inline char * task_state(struct task_struct *p, char *buffer)
180 p->gid, p->egid, p->sgid, p->fsgid); 181 p->gid, p->egid, p->sgid, p->fsgid);
181 read_unlock(&tasklist_lock); 182 read_unlock(&tasklist_lock);
182 task_lock(p); 183 task_lock(p);
184 rcu_read_lock();
183 if (p->files) 185 if (p->files)
184 fdt = files_fdtable(p->files); 186 fdt = files_fdtable(p->files);
185 buffer += sprintf(buffer, 187 buffer += sprintf(buffer,
186 "FDSize:\t%d\n" 188 "FDSize:\t%d\n"
187 "Groups:\t", 189 "Groups:\t",
188 fdt ? fdt->max_fds : 0); 190 fdt ? fdt->max_fds : 0);
191 rcu_read_unlock();
189 192
190 group_info = p->group_info; 193 group_info = p->group_info;
191 get_group_info(group_info); 194 get_group_info(group_info);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 23db452ab428..a170450aadb1 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -103,7 +103,9 @@ enum pid_directory_inos {
103 PROC_TGID_NUMA_MAPS, 103 PROC_TGID_NUMA_MAPS,
104 PROC_TGID_MOUNTS, 104 PROC_TGID_MOUNTS,
105 PROC_TGID_WCHAN, 105 PROC_TGID_WCHAN,
106#ifdef CONFIG_MMU
106 PROC_TGID_SMAPS, 107 PROC_TGID_SMAPS,
108#endif
107#ifdef CONFIG_SCHEDSTATS 109#ifdef CONFIG_SCHEDSTATS
108 PROC_TGID_SCHEDSTAT, 110 PROC_TGID_SCHEDSTAT,
109#endif 111#endif
@@ -141,7 +143,9 @@ enum pid_directory_inos {
141 PROC_TID_NUMA_MAPS, 143 PROC_TID_NUMA_MAPS,
142 PROC_TID_MOUNTS, 144 PROC_TID_MOUNTS,
143 PROC_TID_WCHAN, 145 PROC_TID_WCHAN,
146#ifdef CONFIG_MMU
144 PROC_TID_SMAPS, 147 PROC_TID_SMAPS,
148#endif
145#ifdef CONFIG_SCHEDSTATS 149#ifdef CONFIG_SCHEDSTATS
146 PROC_TID_SCHEDSTAT, 150 PROC_TID_SCHEDSTAT,
147#endif 151#endif
@@ -195,7 +199,9 @@ static struct pid_entry tgid_base_stuff[] = {
195 E(PROC_TGID_ROOT, "root", S_IFLNK|S_IRWXUGO), 199 E(PROC_TGID_ROOT, "root", S_IFLNK|S_IRWXUGO),
196 E(PROC_TGID_EXE, "exe", S_IFLNK|S_IRWXUGO), 200 E(PROC_TGID_EXE, "exe", S_IFLNK|S_IRWXUGO),
197 E(PROC_TGID_MOUNTS, "mounts", S_IFREG|S_IRUGO), 201 E(PROC_TGID_MOUNTS, "mounts", S_IFREG|S_IRUGO),
202#ifdef CONFIG_MMU
198 E(PROC_TGID_SMAPS, "smaps", S_IFREG|S_IRUGO), 203 E(PROC_TGID_SMAPS, "smaps", S_IFREG|S_IRUGO),
204#endif
199#ifdef CONFIG_SECURITY 205#ifdef CONFIG_SECURITY
200 E(PROC_TGID_ATTR, "attr", S_IFDIR|S_IRUGO|S_IXUGO), 206 E(PROC_TGID_ATTR, "attr", S_IFDIR|S_IRUGO|S_IXUGO),
201#endif 207#endif
@@ -235,7 +241,9 @@ static struct pid_entry tid_base_stuff[] = {
235 E(PROC_TID_ROOT, "root", S_IFLNK|S_IRWXUGO), 241 E(PROC_TID_ROOT, "root", S_IFLNK|S_IRWXUGO),
236 E(PROC_TID_EXE, "exe", S_IFLNK|S_IRWXUGO), 242 E(PROC_TID_EXE, "exe", S_IFLNK|S_IRWXUGO),
237 E(PROC_TID_MOUNTS, "mounts", S_IFREG|S_IRUGO), 243 E(PROC_TID_MOUNTS, "mounts", S_IFREG|S_IRUGO),
244#ifdef CONFIG_MMU
238 E(PROC_TID_SMAPS, "smaps", S_IFREG|S_IRUGO), 245 E(PROC_TID_SMAPS, "smaps", S_IFREG|S_IRUGO),
246#endif
239#ifdef CONFIG_SECURITY 247#ifdef CONFIG_SECURITY
240 E(PROC_TID_ATTR, "attr", S_IFDIR|S_IRUGO|S_IXUGO), 248 E(PROC_TID_ATTR, "attr", S_IFDIR|S_IRUGO|S_IXUGO),
241#endif 249#endif
@@ -340,6 +348,54 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf
340 return result; 348 return result;
341} 349}
342 350
351
352/* Same as proc_root_link, but this addionally tries to get fs from other
353 * threads in the group */
354static int proc_task_root_link(struct inode *inode, struct dentry **dentry,
355 struct vfsmount **mnt)
356{
357 struct fs_struct *fs;
358 int result = -ENOENT;
359 struct task_struct *leader = proc_task(inode);
360
361 task_lock(leader);
362 fs = leader->fs;
363 if (fs) {
364 atomic_inc(&fs->count);
365 task_unlock(leader);
366 } else {
367 /* Try to get fs from other threads */
368 task_unlock(leader);
369 read_lock(&tasklist_lock);
370 if (pid_alive(leader)) {
371 struct task_struct *task = leader;
372
373 while ((task = next_thread(task)) != leader) {
374 task_lock(task);
375 fs = task->fs;
376 if (fs) {
377 atomic_inc(&fs->count);
378 task_unlock(task);
379 break;
380 }
381 task_unlock(task);
382 }
383 }
384 read_unlock(&tasklist_lock);
385 }
386
387 if (fs) {
388 read_lock(&fs->lock);
389 *mnt = mntget(fs->rootmnt);
390 *dentry = dget(fs->root);
391 read_unlock(&fs->lock);
392 result = 0;
393 put_fs_struct(fs);
394 }
395 return result;
396}
397
398
343#define MAY_PTRACE(task) \ 399#define MAY_PTRACE(task) \
344 (task == current || \ 400 (task == current || \
345 (task->parent == current && \ 401 (task->parent == current && \
@@ -471,14 +527,14 @@ static int proc_oom_score(struct task_struct *task, char *buffer)
471 527
472/* permission checks */ 528/* permission checks */
473 529
474static int proc_check_root(struct inode *inode) 530/* If the process being read is separated by chroot from the reading process,
531 * don't let the reader access the threads.
532 */
533static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt)
475{ 534{
476 struct dentry *de, *base, *root; 535 struct dentry *de, *base;
477 struct vfsmount *our_vfsmnt, *vfsmnt, *mnt; 536 struct vfsmount *our_vfsmnt, *mnt;
478 int res = 0; 537 int res = 0;
479
480 if (proc_root_link(inode, &root, &vfsmnt)) /* Ewww... */
481 return -ENOENT;
482 read_lock(&current->fs->lock); 538 read_lock(&current->fs->lock);
483 our_vfsmnt = mntget(current->fs->rootmnt); 539 our_vfsmnt = mntget(current->fs->rootmnt);
484 base = dget(current->fs->root); 540 base = dget(current->fs->root);
@@ -511,6 +567,16 @@ out:
511 goto exit; 567 goto exit;
512} 568}
513 569
570static int proc_check_root(struct inode *inode)
571{
572 struct dentry *root;
573 struct vfsmount *vfsmnt;
574
575 if (proc_root_link(inode, &root, &vfsmnt)) /* Ewww... */
576 return -ENOENT;
577 return proc_check_chroot(root, vfsmnt);
578}
579
514static int proc_permission(struct inode *inode, int mask, struct nameidata *nd) 580static int proc_permission(struct inode *inode, int mask, struct nameidata *nd)
515{ 581{
516 if (generic_permission(inode, mask, NULL) != 0) 582 if (generic_permission(inode, mask, NULL) != 0)
@@ -518,6 +584,20 @@ static int proc_permission(struct inode *inode, int mask, struct nameidata *nd)
518 return proc_check_root(inode); 584 return proc_check_root(inode);
519} 585}
520 586
587static int proc_task_permission(struct inode *inode, int mask, struct nameidata *nd)
588{
589 struct dentry *root;
590 struct vfsmount *vfsmnt;
591
592 if (generic_permission(inode, mask, NULL) != 0)
593 return -EACCES;
594
595 if (proc_task_root_link(inode, &root, &vfsmnt))
596 return -ENOENT;
597
598 return proc_check_chroot(root, vfsmnt);
599}
600
521extern struct seq_operations proc_pid_maps_op; 601extern struct seq_operations proc_pid_maps_op;
522static int maps_open(struct inode *inode, struct file *file) 602static int maps_open(struct inode *inode, struct file *file)
523{ 603{
@@ -558,6 +638,7 @@ static struct file_operations proc_numa_maps_operations = {
558}; 638};
559#endif 639#endif
560 640
641#ifdef CONFIG_MMU
561extern struct seq_operations proc_pid_smaps_op; 642extern struct seq_operations proc_pid_smaps_op;
562static int smaps_open(struct inode *inode, struct file *file) 643static int smaps_open(struct inode *inode, struct file *file)
563{ 644{
@@ -576,6 +657,7 @@ static struct file_operations proc_smaps_operations = {
576 .llseek = seq_lseek, 657 .llseek = seq_lseek,
577 .release = seq_release, 658 .release = seq_release,
578}; 659};
660#endif
579 661
580extern struct seq_operations mounts_op; 662extern struct seq_operations mounts_op;
581static int mounts_open(struct inode *inode, struct file *file) 663static int mounts_open(struct inode *inode, struct file *file)
@@ -1419,7 +1501,7 @@ static struct inode_operations proc_fd_inode_operations = {
1419 1501
1420static struct inode_operations proc_task_inode_operations = { 1502static struct inode_operations proc_task_inode_operations = {
1421 .lookup = proc_task_lookup, 1503 .lookup = proc_task_lookup,
1422 .permission = proc_permission, 1504 .permission = proc_task_permission,
1423}; 1505};
1424 1506
1425#ifdef CONFIG_SECURITY 1507#ifdef CONFIG_SECURITY
@@ -1609,10 +1691,12 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
1609 case PROC_TGID_MOUNTS: 1691 case PROC_TGID_MOUNTS:
1610 inode->i_fop = &proc_mounts_operations; 1692 inode->i_fop = &proc_mounts_operations;
1611 break; 1693 break;
1694#ifdef CONFIG_MMU
1612 case PROC_TID_SMAPS: 1695 case PROC_TID_SMAPS:
1613 case PROC_TGID_SMAPS: 1696 case PROC_TGID_SMAPS:
1614 inode->i_fop = &proc_smaps_operations; 1697 inode->i_fop = &proc_smaps_operations;
1615 break; 1698 break;
1699#endif
1616#ifdef CONFIG_SECURITY 1700#ifdef CONFIG_SECURITY
1617 case PROC_TID_ATTR: 1701 case PROC_TID_ATTR:
1618 inode->i_nlink = 2; 1702 inode->i_nlink = 2;
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index f3bf016d5ee3..cff10ab1af63 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -91,6 +91,7 @@ static void *nommu_vma_list_start(struct seq_file *m, loff_t *_pos)
91 next = _rb; 91 next = _rb;
92 break; 92 break;
93 } 93 }
94 pos--;
94 } 95 }
95 96
96 return next; 97 return next;
diff --git a/fs/read_write.c b/fs/read_write.c
index b60324aaa2b6..a091ee4f430d 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -499,6 +499,9 @@ static ssize_t do_readv_writev(int type, struct file *file,
499 ret = rw_verify_area(type, file, pos, tot_len); 499 ret = rw_verify_area(type, file, pos, tot_len);
500 if (ret) 500 if (ret)
501 goto out; 501 goto out;
502 ret = security_file_permission(file, type == READ ? MAY_READ : MAY_WRITE);
503 if (ret)
504 goto out;
502 505
503 fnv = NULL; 506 fnv = NULL;
504 if (type == READ) { 507 if (type == READ) {
diff --git a/fs/relayfs/buffers.c b/fs/relayfs/buffers.c
index 2aa8e2719999..84e21ffa5ca8 100644
--- a/fs/relayfs/buffers.c
+++ b/fs/relayfs/buffers.c
@@ -109,7 +109,7 @@ static void *relay_alloc_buf(struct rchan_buf *buf, unsigned long size)
109 if (unlikely(!buf->page_array[i])) 109 if (unlikely(!buf->page_array[i]))
110 goto depopulate; 110 goto depopulate;
111 } 111 }
112 mem = vmap(buf->page_array, n_pages, GFP_KERNEL, PAGE_KERNEL); 112 mem = vmap(buf->page_array, n_pages, VM_MAP, PAGE_KERNEL);
113 if (!mem) 113 if (!mem)
114 goto depopulate; 114 goto depopulate;
115 115
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index 4b184559f231..d2653b589b1c 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -45,7 +45,7 @@
45 45
46 46
47void * 47void *
48kmem_alloc(size_t size, unsigned int __nocast flags) 48kmem_alloc(size_t size, gfp_t flags)
49{ 49{
50 int retries = 0; 50 int retries = 0;
51 unsigned int lflags = kmem_flags_convert(flags); 51 unsigned int lflags = kmem_flags_convert(flags);
@@ -67,7 +67,7 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
67} 67}
68 68
69void * 69void *
70kmem_zalloc(size_t size, unsigned int __nocast flags) 70kmem_zalloc(size_t size, gfp_t flags)
71{ 71{
72 void *ptr; 72 void *ptr;
73 73
@@ -90,7 +90,7 @@ kmem_free(void *ptr, size_t size)
90 90
91void * 91void *
92kmem_realloc(void *ptr, size_t newsize, size_t oldsize, 92kmem_realloc(void *ptr, size_t newsize, size_t oldsize,
93 unsigned int __nocast flags) 93 gfp_t flags)
94{ 94{
95 void *new; 95 void *new;
96 96
@@ -105,7 +105,7 @@ kmem_realloc(void *ptr, size_t newsize, size_t oldsize,
105} 105}
106 106
107void * 107void *
108kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags) 108kmem_zone_alloc(kmem_zone_t *zone, gfp_t flags)
109{ 109{
110 int retries = 0; 110 int retries = 0;
111 unsigned int lflags = kmem_flags_convert(flags); 111 unsigned int lflags = kmem_flags_convert(flags);
@@ -124,7 +124,7 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
124} 124}
125 125
126void * 126void *
127kmem_zone_zalloc(kmem_zone_t *zone, unsigned int __nocast flags) 127kmem_zone_zalloc(kmem_zone_t *zone, gfp_t flags)
128{ 128{
129 void *ptr; 129 void *ptr;
130 130
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index 109fcf27e256..ee7010f085bc 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -81,7 +81,7 @@ typedef unsigned long xfs_pflags_t;
81 *(NSTATEP) = *(OSTATEP); \ 81 *(NSTATEP) = *(OSTATEP); \
82} while (0) 82} while (0)
83 83
84static __inline unsigned int kmem_flags_convert(unsigned int __nocast flags) 84static __inline unsigned int kmem_flags_convert(gfp_t flags)
85{ 85{
86 unsigned int lflags = __GFP_NOWARN; /* we'll report problems, if need be */ 86 unsigned int lflags = __GFP_NOWARN; /* we'll report problems, if need be */
87 87
@@ -125,13 +125,12 @@ kmem_zone_destroy(kmem_zone_t *zone)
125 BUG(); 125 BUG();
126} 126}
127 127
128extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); 128extern void *kmem_zone_zalloc(kmem_zone_t *, gfp_t);
129extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); 129extern void *kmem_zone_alloc(kmem_zone_t *, gfp_t);
130 130
131extern void *kmem_alloc(size_t, unsigned int __nocast); 131extern void *kmem_alloc(size_t, gfp_t);
132extern void *kmem_realloc(void *, size_t, size_t, 132extern void *kmem_realloc(void *, size_t, size_t, gfp_t);
133 unsigned int __nocast); 133extern void *kmem_zalloc(size_t, gfp_t);
134extern void *kmem_zalloc(size_t, unsigned int __nocast);
135extern void kmem_free(void *, size_t); 134extern void kmem_free(void *, size_t);
136 135
137typedef struct shrinker *kmem_shaker_t; 136typedef struct shrinker *kmem_shaker_t;
diff --git a/include/asm-alpha/atomic.h b/include/asm-alpha/atomic.h
index 1b383e3cb68c..20ac3d95ecd9 100644
--- a/include/asm-alpha/atomic.h
+++ b/include/asm-alpha/atomic.h
@@ -1,6 +1,8 @@
1#ifndef _ALPHA_ATOMIC_H 1#ifndef _ALPHA_ATOMIC_H
2#define _ALPHA_ATOMIC_H 2#define _ALPHA_ATOMIC_H
3 3
4#include <asm/barrier.h>
5
4/* 6/*
5 * Atomic operations that C can't guarantee us. Useful for 7 * Atomic operations that C can't guarantee us. Useful for
6 * resource counting etc... 8 * resource counting etc...
@@ -100,18 +102,19 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
100static __inline__ long atomic_add_return(int i, atomic_t * v) 102static __inline__ long atomic_add_return(int i, atomic_t * v)
101{ 103{
102 long temp, result; 104 long temp, result;
105 smp_mb();
103 __asm__ __volatile__( 106 __asm__ __volatile__(
104 "1: ldl_l %0,%1\n" 107 "1: ldl_l %0,%1\n"
105 " addl %0,%3,%2\n" 108 " addl %0,%3,%2\n"
106 " addl %0,%3,%0\n" 109 " addl %0,%3,%0\n"
107 " stl_c %0,%1\n" 110 " stl_c %0,%1\n"
108 " beq %0,2f\n" 111 " beq %0,2f\n"
109 " mb\n"
110 ".subsection 2\n" 112 ".subsection 2\n"
111 "2: br 1b\n" 113 "2: br 1b\n"
112 ".previous" 114 ".previous"
113 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 115 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
114 :"Ir" (i), "m" (v->counter) : "memory"); 116 :"Ir" (i), "m" (v->counter) : "memory");
117 smp_mb();
115 return result; 118 return result;
116} 119}
117 120
@@ -120,54 +123,57 @@ static __inline__ long atomic_add_return(int i, atomic_t * v)
120static __inline__ long atomic64_add_return(long i, atomic64_t * v) 123static __inline__ long atomic64_add_return(long i, atomic64_t * v)
121{ 124{
122 long temp, result; 125 long temp, result;
126 smp_mb();
123 __asm__ __volatile__( 127 __asm__ __volatile__(
124 "1: ldq_l %0,%1\n" 128 "1: ldq_l %0,%1\n"
125 " addq %0,%3,%2\n" 129 " addq %0,%3,%2\n"
126 " addq %0,%3,%0\n" 130 " addq %0,%3,%0\n"
127 " stq_c %0,%1\n" 131 " stq_c %0,%1\n"
128 " beq %0,2f\n" 132 " beq %0,2f\n"
129 " mb\n"
130 ".subsection 2\n" 133 ".subsection 2\n"
131 "2: br 1b\n" 134 "2: br 1b\n"
132 ".previous" 135 ".previous"
133 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 136 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
134 :"Ir" (i), "m" (v->counter) : "memory"); 137 :"Ir" (i), "m" (v->counter) : "memory");
138 smp_mb();
135 return result; 139 return result;
136} 140}
137 141
138static __inline__ long atomic_sub_return(int i, atomic_t * v) 142static __inline__ long atomic_sub_return(int i, atomic_t * v)
139{ 143{
140 long temp, result; 144 long temp, result;
145 smp_mb();
141 __asm__ __volatile__( 146 __asm__ __volatile__(
142 "1: ldl_l %0,%1\n" 147 "1: ldl_l %0,%1\n"
143 " subl %0,%3,%2\n" 148 " subl %0,%3,%2\n"
144 " subl %0,%3,%0\n" 149 " subl %0,%3,%0\n"
145 " stl_c %0,%1\n" 150 " stl_c %0,%1\n"
146 " beq %0,2f\n" 151 " beq %0,2f\n"
147 " mb\n"
148 ".subsection 2\n" 152 ".subsection 2\n"
149 "2: br 1b\n" 153 "2: br 1b\n"
150 ".previous" 154 ".previous"
151 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 155 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
152 :"Ir" (i), "m" (v->counter) : "memory"); 156 :"Ir" (i), "m" (v->counter) : "memory");
157 smp_mb();
153 return result; 158 return result;
154} 159}
155 160
156static __inline__ long atomic64_sub_return(long i, atomic64_t * v) 161static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
157{ 162{
158 long temp, result; 163 long temp, result;
164 smp_mb();
159 __asm__ __volatile__( 165 __asm__ __volatile__(
160 "1: ldq_l %0,%1\n" 166 "1: ldq_l %0,%1\n"
161 " subq %0,%3,%2\n" 167 " subq %0,%3,%2\n"
162 " subq %0,%3,%0\n" 168 " subq %0,%3,%0\n"
163 " stq_c %0,%1\n" 169 " stq_c %0,%1\n"
164 " beq %0,2f\n" 170 " beq %0,2f\n"
165 " mb\n"
166 ".subsection 2\n" 171 ".subsection 2\n"
167 "2: br 1b\n" 172 "2: br 1b\n"
168 ".previous" 173 ".previous"
169 :"=&r" (temp), "=m" (v->counter), "=&r" (result) 174 :"=&r" (temp), "=m" (v->counter), "=&r" (result)
170 :"Ir" (i), "m" (v->counter) : "memory"); 175 :"Ir" (i), "m" (v->counter) : "memory");
176 smp_mb();
171 return result; 177 return result;
172} 178}
173 179
diff --git a/include/asm-alpha/barrier.h b/include/asm-alpha/barrier.h
new file mode 100644
index 000000000000..229c83fe77cb
--- /dev/null
+++ b/include/asm-alpha/barrier.h
@@ -0,0 +1,34 @@
1#ifndef __BARRIER_H
2#define __BARRIER_H
3
4#define mb() \
5__asm__ __volatile__("mb": : :"memory")
6
7#define rmb() \
8__asm__ __volatile__("mb": : :"memory")
9
10#define wmb() \
11__asm__ __volatile__("wmb": : :"memory")
12
13#define read_barrier_depends() \
14__asm__ __volatile__("mb": : :"memory")
15
16#ifdef CONFIG_SMP
17#define smp_mb() mb()
18#define smp_rmb() rmb()
19#define smp_wmb() wmb()
20#define smp_read_barrier_depends() read_barrier_depends()
21#else
22#define smp_mb() barrier()
23#define smp_rmb() barrier()
24#define smp_wmb() barrier()
25#define smp_read_barrier_depends() barrier()
26#endif
27
28#define set_mb(var, value) \
29do { var = value; mb(); } while (0)
30
31#define set_wmb(var, value) \
32do { var = value; wmb(); } while (0)
33
34#endif /* __BARRIER_H */
diff --git a/include/asm-alpha/compiler.h b/include/asm-alpha/compiler.h
index 399c33b7be51..0a4a8b40dfcd 100644
--- a/include/asm-alpha/compiler.h
+++ b/include/asm-alpha/compiler.h
@@ -98,6 +98,9 @@
98#undef inline 98#undef inline
99#undef __inline__ 99#undef __inline__
100#undef __inline 100#undef __inline
101 101#if __GNUC__ == 3 && __GNUC_MINOR__ >= 1 || __GNUC__ > 3
102#undef __always_inline
103#define __always_inline inline __attribute__((always_inline))
104#endif
102 105
103#endif /* __ALPHA_COMPILER_H */ 106#endif /* __ALPHA_COMPILER_H */
diff --git a/include/asm-alpha/futex.h b/include/asm-alpha/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-alpha/futex.h
+++ b/include/asm-alpha/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-alpha/system.h b/include/asm-alpha/system.h
index bdb4d66418f1..050e86d12891 100644
--- a/include/asm-alpha/system.h
+++ b/include/asm-alpha/system.h
@@ -4,6 +4,7 @@
4#include <linux/config.h> 4#include <linux/config.h>
5#include <asm/pal.h> 5#include <asm/pal.h>
6#include <asm/page.h> 6#include <asm/page.h>
7#include <asm/barrier.h>
7 8
8/* 9/*
9 * System defines.. Note that this is included both from .c and .S 10 * System defines.. Note that this is included both from .c and .S
@@ -139,36 +140,6 @@ extern void halt(void) __attribute__((noreturn));
139struct task_struct; 140struct task_struct;
140extern struct task_struct *alpha_switch_to(unsigned long, struct task_struct*); 141extern struct task_struct *alpha_switch_to(unsigned long, struct task_struct*);
141 142
142#define mb() \
143__asm__ __volatile__("mb": : :"memory")
144
145#define rmb() \
146__asm__ __volatile__("mb": : :"memory")
147
148#define wmb() \
149__asm__ __volatile__("wmb": : :"memory")
150
151#define read_barrier_depends() \
152__asm__ __volatile__("mb": : :"memory")
153
154#ifdef CONFIG_SMP
155#define smp_mb() mb()
156#define smp_rmb() rmb()
157#define smp_wmb() wmb()
158#define smp_read_barrier_depends() read_barrier_depends()
159#else
160#define smp_mb() barrier()
161#define smp_rmb() barrier()
162#define smp_wmb() barrier()
163#define smp_read_barrier_depends() barrier()
164#endif
165
166#define set_mb(var, value) \
167do { var = value; mb(); } while (0)
168
169#define set_wmb(var, value) \
170do { var = value; wmb(); } while (0)
171
172#define imb() \ 143#define imb() \
173__asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") 144__asm__ __volatile__ ("call_pal %0 #imb" : : "i" (PAL_imb) : "memory")
174 145
diff --git a/include/asm-arm/arch-h720x/system.h b/include/asm-arm/arch-h720x/system.h
index 0b025e227ec2..09eda84592ff 100644
--- a/include/asm-arm/arch-h720x/system.h
+++ b/include/asm-arm/arch-h720x/system.h
@@ -17,9 +17,11 @@
17static void arch_idle(void) 17static void arch_idle(void)
18{ 18{
19 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_IDLE; 19 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_IDLE;
20 __asm__ __volatile__( 20 nop();
21 "mov r0, r0\n\t" 21 nop();
22 "mov r0, r0"); 22 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_RUN;
23 nop();
24 nop();
23} 25}
24 26
25 27
diff --git a/include/asm-arm/arch-imx/imx-regs.h b/include/asm-arm/arch-imx/imx-regs.h
index 93b840e8fa60..a6912b3d8671 100644
--- a/include/asm-arm/arch-imx/imx-regs.h
+++ b/include/asm-arm/arch-imx/imx-regs.h
@@ -76,6 +76,7 @@
76#define GPIO_PIN_MASK 0x1f 76#define GPIO_PIN_MASK 0x1f
77#define GPIO_PORT_MASK (0x3 << 5) 77#define GPIO_PORT_MASK (0x3 << 5)
78 78
79#define GPIO_PORT_SHIFT 5
79#define GPIO_PORTA (0<<5) 80#define GPIO_PORTA (0<<5)
80#define GPIO_PORTB (1<<5) 81#define GPIO_PORTB (1<<5)
81#define GPIO_PORTC (2<<5) 82#define GPIO_PORTC (2<<5)
@@ -88,24 +89,37 @@
88#define GPIO_PF (0<<9) 89#define GPIO_PF (0<<9)
89#define GPIO_AF (1<<9) 90#define GPIO_AF (1<<9)
90 91
92#define GPIO_OCR_SHIFT 10
91#define GPIO_OCR_MASK (3<<10) 93#define GPIO_OCR_MASK (3<<10)
92#define GPIO_AIN (0<<10) 94#define GPIO_AIN (0<<10)
93#define GPIO_BIN (1<<10) 95#define GPIO_BIN (1<<10)
94#define GPIO_CIN (2<<10) 96#define GPIO_CIN (2<<10)
95#define GPIO_GPIO (3<<10) 97#define GPIO_DR (3<<10)
96 98
97#define GPIO_AOUT (1<<12) 99#define GPIO_AOUT_SHIFT 12
98#define GPIO_BOUT (1<<13) 100#define GPIO_AOUT_MASK (3<<12)
101#define GPIO_AOUT (0<<12)
102#define GPIO_AOUT_ISR (1<<12)
103#define GPIO_AOUT_0 (2<<12)
104#define GPIO_AOUT_1 (3<<12)
105
106#define GPIO_BOUT_SHIFT 14
107#define GPIO_BOUT_MASK (3<<14)
108#define GPIO_BOUT (0<<14)
109#define GPIO_BOUT_ISR (1<<14)
110#define GPIO_BOUT_0 (2<<14)
111#define GPIO_BOUT_1 (3<<14)
112
113#define GPIO_GIUS (1<<16)
99 114
100/* assignements for GPIO alternate/primary functions */ 115/* assignements for GPIO alternate/primary functions */
101 116
102/* FIXME: This list is not completed. The correct directions are 117/* FIXME: This list is not completed. The correct directions are
103 * missing on some (many) pins 118 * missing on some (many) pins
104 */ 119 */
105#define PA0_PF_A24 ( GPIO_PORTA | GPIO_PF | 0 ) 120#define PA0_AIN_SPI2_CLK ( GPIO_GIUS | GPIO_PORTA | GPIO_OUT | 0 )
106#define PA0_AIN_SPI2_CLK ( GPIO_PORTA | GPIO_OUT | GPIO_AIN | 0 )
107#define PA0_AF_ETMTRACESYNC ( GPIO_PORTA | GPIO_AF | 0 ) 121#define PA0_AF_ETMTRACESYNC ( GPIO_PORTA | GPIO_AF | 0 )
108#define PA1_AOUT_SPI2_RXD ( GPIO_PORTA | GPIO_IN | GPIO_AOUT | 1 ) 122#define PA1_AOUT_SPI2_RXD ( GPIO_GIUS | GPIO_PORTA | GPIO_IN | 1 )
109#define PA1_PF_TIN ( GPIO_PORTA | GPIO_PF | 1 ) 123#define PA1_PF_TIN ( GPIO_PORTA | GPIO_PF | 1 )
110#define PA2_PF_PWM0 ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 2 ) 124#define PA2_PF_PWM0 ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 2 )
111#define PA3_PF_CSI_MCLK ( GPIO_PORTA | GPIO_PF | 3 ) 125#define PA3_PF_CSI_MCLK ( GPIO_PORTA | GPIO_PF | 3 )
@@ -123,7 +137,7 @@
123#define PA15_PF_I2C_SDA ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 15 ) 137#define PA15_PF_I2C_SDA ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 15 )
124#define PA16_PF_I2C_SCL ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 16 ) 138#define PA16_PF_I2C_SCL ( GPIO_PORTA | GPIO_OUT | GPIO_PF | 16 )
125#define PA17_AF_ETMTRACEPKT4 ( GPIO_PORTA | GPIO_AF | 17 ) 139#define PA17_AF_ETMTRACEPKT4 ( GPIO_PORTA | GPIO_AF | 17 )
126#define PA17_AIN_SPI2_SS ( GPIO_PORTA | GPIO_AIN | 17 ) 140#define PA17_AIN_SPI2_SS ( GPIO_GIUS | GPIO_PORTA | GPIO_OUT | 17 )
127#define PA18_AF_ETMTRACEPKT5 ( GPIO_PORTA | GPIO_AF | 18 ) 141#define PA18_AF_ETMTRACEPKT5 ( GPIO_PORTA | GPIO_AF | 18 )
128#define PA19_AF_ETMTRACEPKT6 ( GPIO_PORTA | GPIO_AF | 19 ) 142#define PA19_AF_ETMTRACEPKT6 ( GPIO_PORTA | GPIO_AF | 19 )
129#define PA20_AF_ETMTRACEPKT7 ( GPIO_PORTA | GPIO_AF | 20 ) 143#define PA20_AF_ETMTRACEPKT7 ( GPIO_PORTA | GPIO_AF | 20 )
@@ -191,19 +205,27 @@
191#define PC15_PF_SPI1_SS ( GPIO_PORTC | GPIO_PF | 15 ) 205#define PC15_PF_SPI1_SS ( GPIO_PORTC | GPIO_PF | 15 )
192#define PC16_PF_SPI1_MISO ( GPIO_PORTC | GPIO_PF | 16 ) 206#define PC16_PF_SPI1_MISO ( GPIO_PORTC | GPIO_PF | 16 )
193#define PC17_PF_SPI1_MOSI ( GPIO_PORTC | GPIO_PF | 17 ) 207#define PC17_PF_SPI1_MOSI ( GPIO_PORTC | GPIO_PF | 17 )
208#define PC24_BIN_UART3_RI ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 24 )
209#define PC25_BIN_UART3_DSR ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 25 )
210#define PC26_AOUT_UART3_DTR ( GPIO_GIUS | GPIO_PORTC | GPIO_IN | 26 )
211#define PC27_BIN_UART3_DCD ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 27 )
212#define PC28_BIN_UART3_CTS ( GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 28 )
213#define PC29_AOUT_UART3_RTS ( GPIO_GIUS | GPIO_PORTC | GPIO_IN | 29 )
214#define PC30_BIN_UART3_TX ( GPIO_GIUS | GPIO_PORTC | GPIO_BIN | 30 )
215#define PC31_AOUT_UART3_RX ( GPIO_GIUS | GPIO_PORTC | GPIO_IN | 31)
194#define PD6_PF_LSCLK ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 6 ) 216#define PD6_PF_LSCLK ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 6 )
195#define PD7_PF_REV ( GPIO_PORTD | GPIO_PF | 7 ) 217#define PD7_PF_REV ( GPIO_PORTD | GPIO_PF | 7 )
196#define PD7_AF_UART2_DTR ( GPIO_PORTD | GPIO_IN | GPIO_AF | 7 ) 218#define PD7_AF_UART2_DTR ( GPIO_GIUS | GPIO_PORTD | GPIO_IN | GPIO_AF | 7 )
197#define PD7_AIN_SPI2_SCLK ( GPIO_PORTD | GPIO_AIN | 7 ) 219#define PD7_AIN_SPI2_SCLK ( GPIO_GIUS | GPIO_PORTD | GPIO_AIN | 7 )
198#define PD8_PF_CLS ( GPIO_PORTD | GPIO_PF | 8 ) 220#define PD8_PF_CLS ( GPIO_PORTD | GPIO_PF | 8 )
199#define PD8_AF_UART2_DCD ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 8 ) 221#define PD8_AF_UART2_DCD ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 8 )
200#define PD8_AIN_SPI2_SS ( GPIO_PORTD | GPIO_AIN | 8 ) 222#define PD8_AIN_SPI2_SS ( GPIO_GIUS | GPIO_PORTD | GPIO_AIN | 8 )
201#define PD9_PF_PS ( GPIO_PORTD | GPIO_PF | 9 ) 223#define PD9_PF_PS ( GPIO_PORTD | GPIO_PF | 9 )
202#define PD9_AF_UART2_RI ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 9 ) 224#define PD9_AF_UART2_RI ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 9 )
203#define PD9_AOUT_SPI2_RXD ( GPIO_PORTD | GPIO_IN | GPIO_AOUT | 9 ) 225#define PD9_AOUT_SPI2_RXD ( GPIO_GIUS | GPIO_PORTD | GPIO_IN | 9 )
204#define PD10_PF_SPL_SPR ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 10 ) 226#define PD10_PF_SPL_SPR ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 10 )
205#define PD10_AF_UART2_DSR ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 10 ) 227#define PD10_AF_UART2_DSR ( GPIO_PORTD | GPIO_OUT | GPIO_AF | 10 )
206#define PD10_AIN_SPI2_TXD ( GPIO_PORTD | GPIO_OUT | GPIO_AIN | 10 ) 228#define PD10_AIN_SPI2_TXD ( GPIO_GIUS | GPIO_PORTD | GPIO_OUT | 10 )
207#define PD11_PF_CONTRAST ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 11 ) 229#define PD11_PF_CONTRAST ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 11 )
208#define PD12_PF_ACD_OE ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 12 ) 230#define PD12_PF_ACD_OE ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 12 )
209#define PD13_PF_LP_HSYNC ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 13 ) 231#define PD13_PF_LP_HSYNC ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 13 )
@@ -225,7 +247,7 @@
225#define PD29_PF_LD14 ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 29 ) 247#define PD29_PF_LD14 ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 29 )
226#define PD30_PF_LD15 ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 30 ) 248#define PD30_PF_LD15 ( GPIO_PORTD | GPIO_OUT | GPIO_PF | 30 )
227#define PD31_PF_TMR2OUT ( GPIO_PORTD | GPIO_PF | 31 ) 249#define PD31_PF_TMR2OUT ( GPIO_PORTD | GPIO_PF | 31 )
228#define PD31_BIN_SPI2_TXD ( GPIO_PORTD | GPIO_BIN | 31 ) 250#define PD31_BIN_SPI2_TXD ( GPIO_GIUS | GPIO_PORTD | GPIO_BIN | 31 )
229 251
230/* 252/*
231 * PWM controller 253 * PWM controller
diff --git a/include/asm-arm/arch-ixp4xx/entry-macro.S b/include/asm-arm/arch-ixp4xx/entry-macro.S
index 455da64832de..323b0bc4a39c 100644
--- a/include/asm-arm/arch-ixp4xx/entry-macro.S
+++ b/include/asm-arm/arch-ixp4xx/entry-macro.S
@@ -15,25 +15,26 @@
15 ldr \irqstat, =(IXP4XX_INTC_BASE_VIRT+IXP4XX_ICIP_OFFSET) 15 ldr \irqstat, =(IXP4XX_INTC_BASE_VIRT+IXP4XX_ICIP_OFFSET)
16 ldr \irqstat, [\irqstat] @ get interrupts 16 ldr \irqstat, [\irqstat] @ get interrupts
17 cmp \irqstat, #0 17 cmp \irqstat, #0
18 beq 1001f 18 beq 1001f @ upper IRQ?
19 clz \irqnr, \irqstat 19 clz \irqnr, \irqstat
20 mov \base, #31 20 mov \base, #31
21 subs \irqnr, \base, \irqnr 21 sub \irqnr, \base, \irqnr
22 b 1002f @ lower IRQ being
23 @ handled
22 24
231001: 251001:
24 /* 26 /*
25 * IXP465 has an upper IRQ status register 27 * IXP465 has an upper IRQ status register
26 */ 28 */
27#if defined(CONFIG_CPU_IXP46X) 29#if defined(CONFIG_CPU_IXP46X)
28 bne 1002f
29 ldr \irqstat, =(IXP4XX_INTC_BASE_VIRT+IXP4XX_ICIP2_OFFSET) 30 ldr \irqstat, =(IXP4XX_INTC_BASE_VIRT+IXP4XX_ICIP2_OFFSET)
30 ldr \irqstat, [\irqstat] @ get upper interrupts 31 ldr \irqstat, [\irqstat] @ get upper interrupts
31 mov \irqnr, #63 32 mov \irqnr, #63
32 clz \irqstat, \irqstat 33 clz \irqstat, \irqstat
33 cmp \irqstat, #32 34 cmp \irqstat, #32
34 subne \irqnr, \irqnr, \irqstat 35 subne \irqnr, \irqnr, \irqstat
351002:
36#endif 36#endif
371002:
37 .endm 38 .endm
38 39
39 40
diff --git a/include/asm-arm/arch-ixp4xx/hardware.h b/include/asm-arm/arch-ixp4xx/hardware.h
index 4ac964b9078a..55d85eea8c1a 100644
--- a/include/asm-arm/arch-ixp4xx/hardware.h
+++ b/include/asm-arm/arch-ixp4xx/hardware.h
@@ -27,7 +27,7 @@
27 27
28#define pcibios_assign_all_busses() 1 28#define pcibios_assign_all_busses() 1
29 29
30#if defined(CONFIG_CPU_IXP465) && !defined(__ASSEMBLY__) 30#if defined(CONFIG_CPU_IXP46X) && !defined(__ASSEMBLY__)
31extern unsigned int processor_id; 31extern unsigned int processor_id;
32#define cpu_is_ixp465() ((processor_id & 0xffffffc0) == 0x69054200) 32#define cpu_is_ixp465() ((processor_id & 0xffffffc0) == 0x69054200)
33#else 33#else
diff --git a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h
index d13ee7f78c70..f14ed63590c3 100644
--- a/include/asm-arm/arch-ixp4xx/platform.h
+++ b/include/asm-arm/arch-ixp4xx/platform.h
@@ -93,7 +93,7 @@ extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
93 93
94static inline void gpio_line_config(u8 line, u32 direction) 94static inline void gpio_line_config(u8 line, u32 direction)
95{ 95{
96 if (direction == IXP4XX_GPIO_OUT) 96 if (direction == IXP4XX_GPIO_IN)
97 *IXP4XX_GPIO_GPOER |= (1 << line); 97 *IXP4XX_GPIO_GPOER |= (1 << line);
98 else 98 else
99 *IXP4XX_GPIO_GPOER &= ~(1 << line); 99 *IXP4XX_GPIO_GPOER &= ~(1 << line);
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index 939d9e5020a0..3af7165ab0d7 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -126,8 +126,8 @@
126#define DRCMR12 __REG(0x40000130) /* Request to Channel Map Register for AC97 audio transmit Request */ 126#define DRCMR12 __REG(0x40000130) /* Request to Channel Map Register for AC97 audio transmit Request */
127#define DRCMR13 __REG(0x40000134) /* Request to Channel Map Register for SSP receive Request */ 127#define DRCMR13 __REG(0x40000134) /* Request to Channel Map Register for SSP receive Request */
128#define DRCMR14 __REG(0x40000138) /* Request to Channel Map Register for SSP transmit Request */ 128#define DRCMR14 __REG(0x40000138) /* Request to Channel Map Register for SSP transmit Request */
129#define DRCMR15 __REG(0x4000013c) /* Reserved */ 129#define DRCMR15 __REG(0x4000013c) /* Request to Channel Map Register for SSP2 receive Request */
130#define DRCMR16 __REG(0x40000140) /* Reserved */ 130#define DRCMR16 __REG(0x40000140) /* Request to Channel Map Register for SSP2 transmit Request */
131#define DRCMR17 __REG(0x40000144) /* Request to Channel Map Register for ICP receive Request */ 131#define DRCMR17 __REG(0x40000144) /* Request to Channel Map Register for ICP receive Request */
132#define DRCMR18 __REG(0x40000148) /* Request to Channel Map Register for ICP transmit Request */ 132#define DRCMR18 __REG(0x40000148) /* Request to Channel Map Register for ICP transmit Request */
133#define DRCMR19 __REG(0x4000014c) /* Request to Channel Map Register for STUART receive Request */ 133#define DRCMR19 __REG(0x4000014c) /* Request to Channel Map Register for STUART receive Request */
@@ -151,7 +151,8 @@
151#define DRCMR37 __REG(0x40000194) /* Request to Channel Map Register for USB endpoint 13 Request */ 151#define DRCMR37 __REG(0x40000194) /* Request to Channel Map Register for USB endpoint 13 Request */
152#define DRCMR38 __REG(0x40000198) /* Request to Channel Map Register for USB endpoint 14 Request */ 152#define DRCMR38 __REG(0x40000198) /* Request to Channel Map Register for USB endpoint 14 Request */
153#define DRCMR39 __REG(0x4000019C) /* Reserved */ 153#define DRCMR39 __REG(0x4000019C) /* Reserved */
154 154#define DRCMR66 __REG(0x40001108) /* Request to Channel Map Register for SSP3 receive Request */
155#define DRCMR67 __REG(0x4000110C) /* Request to Channel Map Register for SSP3 transmit Request */
155#define DRCMR68 __REG(0x40001110) /* Request to Channel Map Register for Camera FIFO 0 Request */ 156#define DRCMR68 __REG(0x40001110) /* Request to Channel Map Register for Camera FIFO 0 Request */
156#define DRCMR69 __REG(0x40001114) /* Request to Channel Map Register for Camera FIFO 1 Request */ 157#define DRCMR69 __REG(0x40001114) /* Request to Channel Map Register for Camera FIFO 1 Request */
157#define DRCMR70 __REG(0x40001118) /* Request to Channel Map Register for Camera FIFO 2 Request */ 158#define DRCMR70 __REG(0x40001118) /* Request to Channel Map Register for Camera FIFO 2 Request */
@@ -652,7 +653,7 @@
652 653
653#define UDCCS_IO_RFS (1 << 0) /* Receive FIFO service */ 654#define UDCCS_IO_RFS (1 << 0) /* Receive FIFO service */
654#define UDCCS_IO_RPC (1 << 1) /* Receive packet complete */ 655#define UDCCS_IO_RPC (1 << 1) /* Receive packet complete */
655#define UDCCS_IO_ROF (1 << 3) /* Receive overflow */ 656#define UDCCS_IO_ROF (1 << 2) /* Receive overflow */
656#define UDCCS_IO_DME (1 << 3) /* DMA enable */ 657#define UDCCS_IO_DME (1 << 3) /* DMA enable */
657#define UDCCS_IO_RNE (1 << 6) /* Receive FIFO not empty */ 658#define UDCCS_IO_RNE (1 << 6) /* Receive FIFO not empty */
658#define UDCCS_IO_RSP (1 << 7) /* Receive short packet */ 659#define UDCCS_IO_RSP (1 << 7) /* Receive short packet */
diff --git a/include/asm-arm/arch-pxa/pxafb.h b/include/asm-arm/arch-pxa/pxafb.h
index 21c0e16dce5f..aba9b30f4249 100644
--- a/include/asm-arm/arch-pxa/pxafb.h
+++ b/include/asm-arm/arch-pxa/pxafb.h
@@ -66,4 +66,5 @@ struct pxafb_mach_info {
66 66
67}; 67};
68void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info); 68void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info);
69void set_pxa_fb_parent(struct device *parent_dev);
69unsigned long pxafb_get_hsync_time(struct device *dev); 70unsigned long pxafb_get_hsync_time(struct device *dev);
diff --git a/include/asm-arm/arch-rpc/hardware.h b/include/asm-arm/arch-rpc/hardware.h
index be9754a05c19..9d7f87375aa7 100644
--- a/include/asm-arm/arch-rpc/hardware.h
+++ b/include/asm-arm/arch-rpc/hardware.h
@@ -15,7 +15,7 @@
15#include <asm/arch/memory.h> 15#include <asm/arch/memory.h>
16 16
17#ifndef __ASSEMBLY__ 17#ifndef __ASSEMBLY__
18#define IOMEM(x) ((void __iomem *)(x)) 18#define IOMEM(x) ((void __iomem *)(unsigned long)(x))
19#else 19#else
20#define IOMEM(x) x 20#define IOMEM(x) x
21#endif /* __ASSEMBLY__ */ 21#endif /* __ASSEMBLY__ */
@@ -52,7 +52,7 @@
52/* 52/*
53 * IO Addresses 53 * IO Addresses
54 */ 54 */
55#define VIDC_BASE (void __iomem *)0xe0400000 55#define VIDC_BASE IOMEM(0xe0400000)
56#define EXPMASK_BASE 0xe0360000 56#define EXPMASK_BASE 0xe0360000
57#define IOMD_BASE IOMEM(0xe0200000) 57#define IOMD_BASE IOMEM(0xe0200000)
58#define IOC_BASE IOMEM(0xe0200000) 58#define IOC_BASE IOMEM(0xe0200000)
diff --git a/include/asm-arm/arch-s3c2410/anubis-map.h b/include/asm-arm/arch-s3c2410/anubis-map.h
index 97741d6e506a..d529ffda8599 100644
--- a/include/asm-arm/arch-s3c2410/anubis-map.h
+++ b/include/asm-arm/arch-s3c2410/anubis-map.h
@@ -20,22 +20,22 @@
20 20
21/* start peripherals off after the S3C2410 */ 21/* start peripherals off after the S3C2410 */
22 22
23#define ANUBIS_IOADDR(x) (S3C2410_ADDR((x) + 0x02000000)) 23#define ANUBIS_IOADDR(x) (S3C2410_ADDR((x) + 0x01800000))
24 24
25#define ANUBIS_PA_CPLD (S3C2410_CS1 | (1<<26)) 25#define ANUBIS_PA_CPLD (S3C2410_CS1 | (1<<26))
26 26
27/* we put the CPLD registers next, to get them out of the way */ 27/* we put the CPLD registers next, to get them out of the way */
28 28
29#define ANUBIS_VA_CTRL1 ANUBIS_IOADDR(0x00000000) /* 0x01300000 */ 29#define ANUBIS_VA_CTRL1 ANUBIS_IOADDR(0x00000000) /* 0x01800000 */
30#define ANUBIS_PA_CTRL1 (ANUBIS_PA_CPLD) 30#define ANUBIS_PA_CTRL1 (ANUBIS_PA_CPLD)
31 31
32#define ANUBIS_VA_CTRL2 ANUBIS_IOADDR(0x00100000) /* 0x01400000 */ 32#define ANUBIS_VA_CTRL2 ANUBIS_IOADDR(0x00100000) /* 0x01900000 */
33#define ANUBIS_PA_CTRL2 (ANUBIS_PA_CPLD) 33#define ANUBIS_PA_CTRL2 (ANUBIS_PA_CPLD)
34 34
35#define ANUBIS_VA_CTRL3 ANUBIS_IOADDR(0x00200000) /* 0x01500000 */ 35#define ANUBIS_VA_CTRL3 ANUBIS_IOADDR(0x00200000) /* 0x01A00000 */
36#define ANUBIS_PA_CTRL3 (ANUBIS_PA_CPLD) 36#define ANUBIS_PA_CTRL3 (ANUBIS_PA_CPLD)
37 37
38#define ANUBIS_VA_CTRL4 ANUBIS_IOADDR(0x00300000) /* 0x01600000 */ 38#define ANUBIS_VA_CTRL4 ANUBIS_IOADDR(0x00300000) /* 0x01B00000 */
39#define ANUBIS_PA_CTRL4 (ANUBIS_PA_CPLD) 39#define ANUBIS_PA_CTRL4 (ANUBIS_PA_CPLD)
40 40
41#define ANUBIS_IDEPRI ANUBIS_IOADDR(0x01000000) 41#define ANUBIS_IDEPRI ANUBIS_IOADDR(0x01000000)
diff --git a/include/asm-arm/arch-s3c2410/hardware.h b/include/asm-arm/arch-s3c2410/hardware.h
index 48a39918a760..1c9de29cafef 100644
--- a/include/asm-arm/arch-s3c2410/hardware.h
+++ b/include/asm-arm/arch-s3c2410/hardware.h
@@ -92,6 +92,13 @@ extern unsigned int s3c2410_gpio_getpin(unsigned int pin);
92 92
93extern unsigned int s3c2410_modify_misccr(unsigned int clr, unsigned int chg); 93extern unsigned int s3c2410_modify_misccr(unsigned int clr, unsigned int chg);
94 94
95#ifdef CONFIG_CPU_S3C2440
96
97extern int s3c2440_set_dsc(unsigned int pin, unsigned int value);
98
99#endif /* CONFIG_CPU_S3C2440 */
100
101
95#endif /* __ASSEMBLY__ */ 102#endif /* __ASSEMBLY__ */
96 103
97#include <asm/sizes.h> 104#include <asm/sizes.h>
diff --git a/include/asm-arm/arch-s3c2410/io.h b/include/asm-arm/arch-s3c2410/io.h
index 418233a7ee6f..4bf272ed9add 100644
--- a/include/asm-arm/arch-s3c2410/io.h
+++ b/include/asm-arm/arch-s3c2410/io.h
@@ -9,7 +9,7 @@
9 * 06-Dec-1997 RMK Created. 9 * 06-Dec-1997 RMK Created.
10 * 02-Sep-2003 BJD Modified for S3C2410 10 * 02-Sep-2003 BJD Modified for S3C2410
11 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 11 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
12 * 12 * 13-Oct-2005 BJD Fixed problems with LDRH/STRH offset range
13 */ 13 */
14 14
15#ifndef __ASM_ARM_ARCH_IO_H 15#ifndef __ASM_ARM_ARCH_IO_H
@@ -97,7 +97,7 @@ DECLARE_IO(int,l,"")
97 else \ 97 else \
98 __asm__ __volatile__( \ 98 __asm__ __volatile__( \
99 "strb %0, [%1, #0] @ outbc" \ 99 "strb %0, [%1, #0] @ outbc" \
100 : : "r" (value), "r" ((port))); \ 100 : : "r" (value), "r" ((port))); \
101}) 101})
102 102
103#define __inbc(port) \ 103#define __inbc(port) \
@@ -110,35 +110,61 @@ DECLARE_IO(int,l,"")
110 else \ 110 else \
111 __asm__ __volatile__( \ 111 __asm__ __volatile__( \
112 "ldrb %0, [%1, #0] @ inbc" \ 112 "ldrb %0, [%1, #0] @ inbc" \
113 : "=r" (result) : "r" ((port))); \ 113 : "=r" (result) : "r" ((port))); \
114 result; \ 114 result; \
115}) 115})
116 116
117#define __outwc(value,port) \ 117#define __outwc(value,port) \
118({ \ 118({ \
119 unsigned long v = value; \ 119 unsigned long v = value; \
120 if (__PORT_PCIO((port))) \ 120 if (__PORT_PCIO((port))) { \
121 __asm__ __volatile__( \ 121 if ((port) < 256 && (port) > -256) \
122 "strh %0, [%1, %2] @ outwc" \ 122 __asm__ __volatile__( \
123 : : "r" (v), "r" (PCIO_BASE), "Jr" ((port))); \ 123 "strh %0, [%1, %2] @ outwc" \
124 else \ 124 : : "r" (v), "r" (PCIO_BASE), "Jr" ((port))); \
125 else if ((port) > 0) \
126 __asm__ __volatile__( \
127 "strh %0, [%1, %2] @ outwc" \
128 : : "r" (v), \
129 "r" (PCIO_BASE + ((port) & ~0xff)), \
130 "Jr" (((port) & 0xff))); \
131 else \
132 __asm__ __volatile__( \
133 "strh %0, [%1, #0] @ outwc" \
134 : : "r" (v), \
135 "r" (PCIO_BASE + (port))); \
136 } else \
125 __asm__ __volatile__( \ 137 __asm__ __volatile__( \
126 "strh %0, [%1, #0] @ outwc" \ 138 "strh %0, [%1, #0] @ outwc" \
127 : : "r" (v), "r" ((port))); \ 139 : : "r" (v), "r" ((port))); \
128}) 140})
129 141
130#define __inwc(port) \ 142#define __inwc(port) \
131({ \ 143({ \
132 unsigned short result; \ 144 unsigned short result; \
133 if (__PORT_PCIO((port))) \ 145 if (__PORT_PCIO((port))) { \
134 __asm__ __volatile__( \ 146 if ((port) < 256 && (port) > -256 ) \
135 "ldrh %0, [%1, %2] @ inwc" \ 147 __asm__ __volatile__( \
136 : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port))); \ 148 "ldrh %0, [%1, %2] @ inwc" \
137 else \ 149 : "=r" (result) \
150 : "r" (PCIO_BASE), \
151 "Jr" ((port))); \
152 else if ((port) > 0) \
153 __asm__ __volatile__( \
154 "ldrh %0, [%1, %2] @ inwc" \
155 : "=r" (result) \
156 : "r" (PCIO_BASE + ((port) & ~0xff)), \
157 "Jr" (((port) & 0xff))); \
158 else \
159 __asm__ __volatile__( \
160 "ldrh %0, [%1, #0] @ inwc" \
161 : "=r" (result) \
162 : "r" (PCIO_BASE + ((port)))); \
163 } else \
138 __asm__ __volatile__( \ 164 __asm__ __volatile__( \
139 "ldrh %0, [%1, #0] @ inwc" \ 165 "ldrh %0, [%1, #0] @ inwc" \
140 : "=r" (result) : "r" ((port))); \ 166 : "=r" (result) : "r" ((port))); \
141 result; \ 167 result; \
142}) 168})
143 169
144#define __outlc(value,port) \ 170#define __outlc(value,port) \
diff --git a/include/asm-arm/arch-s3c2410/regs-clock.h b/include/asm-arm/arch-s3c2410/regs-clock.h
index 16f4c3cc1388..34360706e016 100644
--- a/include/asm-arm/arch-s3c2410/regs-clock.h
+++ b/include/asm-arm/arch-s3c2410/regs-clock.h
@@ -18,7 +18,9 @@
18 * 10-Feb-2005 Ben Dooks Fixed CAMDIVN address (Guillaume Gourat) 18 * 10-Feb-2005 Ben Dooks Fixed CAMDIVN address (Guillaume Gourat)
19 * 10-Mar-2005 Lucas Villa Real Changed S3C2410_VA to S3C24XX_VA 19 * 10-Mar-2005 Lucas Villa Real Changed S3C2410_VA to S3C24XX_VA
20 * 27-Aug-2005 Ben Dooks Add clock-slow info 20 * 27-Aug-2005 Ben Dooks Add clock-slow info
21 */ 21 * 20-Oct-2005 Ben Dooks Fixed overflow in PLL (Guillaume Gourat)
22 * 20-Oct-2005 Ben Dooks Add masks for DCLK (Guillaume Gourat)
23*/
22 24
23#ifndef __ASM_ARM_REGS_CLOCK 25#ifndef __ASM_ARM_REGS_CLOCK
24#define __ASM_ARM_REGS_CLOCK "$Id: clock.h,v 1.4 2003/04/30 14:50:51 ben Exp $" 26#define __ASM_ARM_REGS_CLOCK "$Id: clock.h,v 1.4 2003/04/30 14:50:51 ben Exp $"
@@ -66,11 +68,16 @@
66#define S3C2410_DCLKCON_DCLK0_UCLK (1<<1) 68#define S3C2410_DCLKCON_DCLK0_UCLK (1<<1)
67#define S3C2410_DCLKCON_DCLK0_DIV(x) (((x) - 1 )<<4) 69#define S3C2410_DCLKCON_DCLK0_DIV(x) (((x) - 1 )<<4)
68#define S3C2410_DCLKCON_DCLK0_CMP(x) (((x) - 1 )<<8) 70#define S3C2410_DCLKCON_DCLK0_CMP(x) (((x) - 1 )<<8)
71#define S3C2410_DCLKCON_DCLK0_DIV_MASK ((0xf)<<4)
72#define S3C2410_DCLKCON_DCLK0_CMP_MASK ((0xf)<<8)
69 73
70#define S3C2410_DCLKCON_DCLK1EN (1<<16) 74#define S3C2410_DCLKCON_DCLK1EN (1<<16)
71#define S3C2410_DCLKCON_DCLK1_PCLK (0<<17) 75#define S3C2410_DCLKCON_DCLK1_PCLK (0<<17)
72#define S3C2410_DCLKCON_DCLK1_UCLK (1<<17) 76#define S3C2410_DCLKCON_DCLK1_UCLK (1<<17)
73#define S3C2410_DCLKCON_DCLK1_DIV(x) (((x) - 1) <<20) 77#define S3C2410_DCLKCON_DCLK1_DIV(x) (((x) - 1) <<20)
78#define S3C2410_DCLKCON_DCLK1_CMP(x) (((x) - 1) <<24)
79#define S3C2410_DCLKCON_DCLK1_DIV_MASK ((0xf) <<20)
80#define S3C2410_DCLKCON_DCLK1_CMP_MASK ((0xf) <<24)
74 81
75#define S3C2410_CLKDIVN_PDIVN (1<<0) 82#define S3C2410_CLKDIVN_PDIVN (1<<0)
76#define S3C2410_CLKDIVN_HDIVN (1<<1) 83#define S3C2410_CLKDIVN_HDIVN (1<<1)
@@ -83,10 +90,13 @@
83 90
84#ifndef __ASSEMBLY__ 91#ifndef __ASSEMBLY__
85 92
93#include <asm/div64.h>
94
86static inline unsigned int 95static inline unsigned int
87s3c2410_get_pll(int pllval, int baseclk) 96s3c2410_get_pll(unsigned int pllval, unsigned int baseclk)
88{ 97{
89 int mdiv, pdiv, sdiv; 98 unsigned int mdiv, pdiv, sdiv;
99 uint64_t fvco;
90 100
91 mdiv = pllval >> S3C2410_PLLCON_MDIVSHIFT; 101 mdiv = pllval >> S3C2410_PLLCON_MDIVSHIFT;
92 pdiv = pllval >> S3C2410_PLLCON_PDIVSHIFT; 102 pdiv = pllval >> S3C2410_PLLCON_PDIVSHIFT;
@@ -96,7 +106,10 @@ s3c2410_get_pll(int pllval, int baseclk)
96 pdiv &= S3C2410_PLLCON_PDIVMASK; 106 pdiv &= S3C2410_PLLCON_PDIVMASK;
97 sdiv &= S3C2410_PLLCON_SDIVMASK; 107 sdiv &= S3C2410_PLLCON_SDIVMASK;
98 108
99 return (baseclk * (mdiv + 8)) / ((pdiv + 2) << sdiv); 109 fvco = (uint64_t)baseclk * (mdiv + 8);
110 do_div(fvco, (pdiv + 2) << sdiv);
111
112 return (unsigned int)fvco;
100} 113}
101 114
102#endif /* __ASSEMBLY__ */ 115#endif /* __ASSEMBLY__ */
diff --git a/include/asm-arm/arch-versatile/io.h b/include/asm-arm/arch-versatile/io.h
index 9f895bf61494..47e904cf25c7 100644
--- a/include/asm-arm/arch-versatile/io.h
+++ b/include/asm-arm/arch-versatile/io.h
@@ -22,7 +22,11 @@
22 22
23#define IO_SPACE_LIMIT 0xffffffff 23#define IO_SPACE_LIMIT 0xffffffff
24 24
25#define __io(a) ((void __iomem *)(a)) 25static inline void __iomem *__io(unsigned long addr)
26{
27 return (void __iomem *)addr;
28}
29#define __io(a) __io(a)
26#define __mem_pci(a) (a) 30#define __mem_pci(a) (a)
27#define __mem_isa(a) (a) 31#define __mem_isa(a) (a)
28 32
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index aad7aad026b3..e007dd990da5 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -347,7 +347,6 @@ static inline unsigned long __ffs(unsigned long word)
347 * the clz instruction for much better code efficiency. 347 * the clz instruction for much better code efficiency.
348 */ 348 */
349 349
350static __inline__ int generic_fls(int x);
351#define fls(x) \ 350#define fls(x) \
352 ( __builtin_constant_p(x) ? generic_fls(x) : \ 351 ( __builtin_constant_p(x) ? generic_fls(x) : \
353 ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) 352 ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) )
diff --git a/include/asm-arm/elf.h b/include/asm-arm/elf.h
index a1696ba238d3..7da97a937548 100644
--- a/include/asm-arm/elf.h
+++ b/include/asm-arm/elf.h
@@ -124,6 +124,8 @@ do { \
124 if (((ex).e_flags & EF_ARM_EABI_MASK) || \ 124 if (((ex).e_flags & EF_ARM_EABI_MASK) || \
125 ((ex).e_flags & EF_ARM_SOFT_FLOAT)) \ 125 ((ex).e_flags & EF_ARM_SOFT_FLOAT)) \
126 set_thread_flag(TIF_USING_IWMMXT); \ 126 set_thread_flag(TIF_USING_IWMMXT); \
127 else \
128 clear_thread_flag(TIF_USING_IWMMXT); \
127} while (0) 129} while (0)
128 130
129#endif 131#endif
diff --git a/include/asm-arm/futex.h b/include/asm-arm/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-arm/futex.h
+++ b/include/asm-arm/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-arm/hardware/scoop.h b/include/asm-arm/hardware/scoop.h
index 527404b5a8df..a8f1013930e3 100644
--- a/include/asm-arm/hardware/scoop.h
+++ b/include/asm-arm/hardware/scoop.h
@@ -38,6 +38,8 @@
38struct scoop_config { 38struct scoop_config {
39 unsigned short io_out; 39 unsigned short io_out;
40 unsigned short io_dir; 40 unsigned short io_dir;
41 unsigned short suspend_clr;
42 unsigned short suspend_set;
41}; 43};
42 44
43/* Structure for linking scoop devices to PCMCIA sockets */ 45/* Structure for linking scoop devices to PCMCIA sockets */
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index cfa71a0dffb6..5c4ae8f5dbb0 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -136,9 +136,9 @@ extern void __readwrite_bug(const char *fn);
136/* 136/*
137 * String version of IO memory access ops: 137 * String version of IO memory access ops:
138 */ 138 */
139extern void _memcpy_fromio(void *, void __iomem *, size_t); 139extern void _memcpy_fromio(void *, const volatile void __iomem *, size_t);
140extern void _memcpy_toio(void __iomem *, const void *, size_t); 140extern void _memcpy_toio(volatile void __iomem *, const void *, size_t);
141extern void _memset_io(void __iomem *, int, size_t); 141extern void _memset_io(volatile void __iomem *, int, size_t);
142 142
143#define mmiowb() 143#define mmiowb()
144 144
diff --git a/include/asm-arm/locks.h b/include/asm-arm/locks.h
index f08dc8447913..852220eecdbc 100644
--- a/include/asm-arm/locks.h
+++ b/include/asm-arm/locks.h
@@ -103,7 +103,7 @@
103 ({ \ 103 ({ \
104 smp_mb(); \ 104 smp_mb(); \
105 __asm__ __volatile__( \ 105 __asm__ __volatile__( \
106 "@ up_op_read\n" \ 106 "@ up_op_write\n" \
107"1: ldrex lr, [%0]\n" \ 107"1: ldrex lr, [%0]\n" \
108" adds lr, lr, %1\n" \ 108" adds lr, lr, %1\n" \
109" strex ip, lr, [%0]\n" \ 109" strex ip, lr, [%0]\n" \
@@ -231,7 +231,7 @@
231#define __up_op_write(ptr,wake) \ 231#define __up_op_write(ptr,wake) \
232 ({ \ 232 ({ \
233 __asm__ __volatile__( \ 233 __asm__ __volatile__( \
234 "@ up_op_read\n" \ 234 "@ up_op_write\n" \
235" mrs ip, cpsr\n" \ 235" mrs ip, cpsr\n" \
236" orr lr, ip, #128\n" \ 236" orr lr, ip, #128\n" \
237" msr cpsr_c, lr\n" \ 237" msr cpsr_c, lr\n" \
diff --git a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
index 56c6bf4ab0c3..4fa95084a8c0 100644
--- a/include/asm-arm/mach/arch.h
+++ b/include/asm-arm/mach/arch.h
@@ -50,7 +50,7 @@ struct machine_desc {
50 */ 50 */
51#define MACHINE_START(_type,_name) \ 51#define MACHINE_START(_type,_name) \
52const struct machine_desc __mach_desc_##_type \ 52const struct machine_desc __mach_desc_##_type \
53 __attribute__((__section__(".arch.info"))) = { \ 53 __attribute__((__section__(".arch.info.init"))) = { \
54 .nr = MACH_TYPE_##_type, \ 54 .nr = MACH_TYPE_##_type, \
55 .name = _name, 55 .name = _name,
56 56
diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h
index adcbd79762bf..ea3ed2465233 100644
--- a/include/asm-arm/setup.h
+++ b/include/asm-arm/setup.h
@@ -171,7 +171,7 @@ struct tagtable {
171 int (*parse)(const struct tag *); 171 int (*parse)(const struct tag *);
172}; 172};
173 173
174#define __tag __attribute_used__ __attribute__((__section__(".taglist"))) 174#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
175#define __tagtable(tag, fn) \ 175#define __tagtable(tag, fn) \
176static struct tagtable __tagtable_##fn __tag = { tag, fn } 176static struct tagtable __tagtable_##fn __tag = { tag, fn }
177 177
@@ -213,6 +213,6 @@ struct early_params {
213 213
214#define __early_param(name,fn) \ 214#define __early_param(name,fn) \
215static struct early_params __early_##fn __attribute_used__ \ 215static struct early_params __early_##fn __attribute_used__ \
216__attribute__((__section__("__early_param"))) = { name, fn } 216__attribute__((__section__(".early_param.init"))) = { name, fn }
217 217
218#endif 218#endif
diff --git a/include/asm-arm/signal.h b/include/asm-arm/signal.h
index 760f6e65af05..ced69161917b 100644
--- a/include/asm-arm/signal.h
+++ b/include/asm-arm/signal.h
@@ -115,7 +115,6 @@ typedef unsigned long sigset_t;
115 115
116#ifdef __KERNEL__ 116#ifdef __KERNEL__
117#define SA_TIMER 0x40000000 117#define SA_TIMER 0x40000000
118#define SA_IRQNOMASK 0x08000000
119#endif 118#endif
120 119
121#include <asm-generic/signal.h> 120#include <asm-generic/signal.h>
diff --git a/include/asm-arm26/futex.h b/include/asm-arm26/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-arm26/futex.h
+++ b/include/asm-arm26/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-cris/futex.h b/include/asm-cris/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-cris/futex.h
+++ b/include/asm-cris/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-frv/futex.h b/include/asm-frv/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-frv/futex.h
+++ b/include/asm-frv/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-generic/dma-mapping.h b/include/asm-generic/dma-mapping.h
index 8cef663c5cd9..747d790295f3 100644
--- a/include/asm-generic/dma-mapping.h
+++ b/include/asm-generic/dma-mapping.h
@@ -35,7 +35,7 @@ dma_set_mask(struct device *dev, u64 dma_mask)
35 35
36static inline void * 36static inline void *
37dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 37dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
38 unsigned int __nocast flag) 38 gfp_t flag)
39{ 39{
40 BUG_ON(dev->bus != &pci_bus_type); 40 BUG_ON(dev->bus != &pci_bus_type);
41 41
@@ -168,7 +168,7 @@ dma_set_mask(struct device *dev, u64 dma_mask)
168 168
169static inline void * 169static inline void *
170dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 170dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
171 unsigned int __nocast flag) 171 gfp_t flag)
172{ 172{
173 BUG(); 173 BUG();
174 return NULL; 174 return NULL;
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index f86c1e549466..ff28c8b31f58 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -158,6 +158,19 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
158#define lazy_mmu_prot_update(pte) do { } while (0) 158#define lazy_mmu_prot_update(pte) do { } while (0)
159#endif 159#endif
160 160
161#ifndef __HAVE_ARCH_MULTIPLE_ZERO_PAGE
162#define move_pte(pte, prot, old_addr, new_addr) (pte)
163#else
164#define move_pte(pte, prot, old_addr, new_addr) \
165({ \
166 pte_t newpte = (pte); \
167 if (pte_present(pte) && pfn_valid(pte_pfn(pte)) && \
168 pte_page(pte) == ZERO_PAGE(old_addr)) \
169 newpte = mk_pte(ZERO_PAGE(new_addr), (prot)); \
170 newpte; \
171})
172#endif
173
161/* 174/*
162 * When walking page tables, get the address of the next boundary, 175 * When walking page tables, get the address of the next boundary,
163 * or the end address of the range if that comes earlier. Although no 176 * or the end address of the range if that comes earlier. Although no
diff --git a/include/asm-h8300/futex.h b/include/asm-h8300/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-h8300/futex.h
+++ b/include/asm-h8300/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-i386/dma-mapping.h b/include/asm-i386/dma-mapping.h
index 563964b2995b..e56c335f8ef9 100644
--- a/include/asm-i386/dma-mapping.h
+++ b/include/asm-i386/dma-mapping.h
@@ -11,7 +11,7 @@
11#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 11#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
12 12
13void *dma_alloc_coherent(struct device *dev, size_t size, 13void *dma_alloc_coherent(struct device *dev, size_t size,
14 dma_addr_t *dma_handle, unsigned int __nocast flag); 14 dma_addr_t *dma_handle, gfp_t flag);
15 15
16void dma_free_coherent(struct device *dev, size_t size, 16void dma_free_coherent(struct device *dev, size_t size,
17 void *vaddr, dma_addr_t dma_handle); 17 void *vaddr, dma_addr_t dma_handle);
diff --git a/include/asm-i386/futex.h b/include/asm-i386/futex.h
index 44b9db806474..e7a271d39309 100644
--- a/include/asm-i386/futex.h
+++ b/include/asm-i386/futex.h
@@ -61,7 +61,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
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);
63 else { 63 else {
64#ifndef CONFIG_X86_BSWAP 64#if !defined(CONFIG_X86_BSWAP) && !defined(CONFIG_UML)
65 if (boot_cpu_data.x86 == 3) 65 if (boot_cpu_data.x86 == 3)
66 ret = -ENOSYS; 66 ret = -ENOSYS;
67 else 67 else
diff --git a/include/asm-i386/hw_irq.h b/include/asm-i386/hw_irq.h
index 4ac84cc6f01a..622815bf3243 100644
--- a/include/asm-i386/hw_irq.h
+++ b/include/asm-i386/hw_irq.h
@@ -18,6 +18,8 @@
18#include <asm/irq.h> 18#include <asm/irq.h>
19#include <asm/sections.h> 19#include <asm/sections.h>
20 20
21struct hw_interrupt_type;
22
21/* 23/*
22 * Various low-level irq details needed by irq.c, process.c, 24 * Various low-level irq details needed by irq.c, process.c,
23 * time.c, io_apic.c and smp.c 25 * time.c, io_apic.c and smp.c
diff --git a/include/asm-ia64/futex.h b/include/asm-ia64/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-ia64/futex.h
+++ b/include/asm-ia64/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-ia64/machvec_hpzx1.h b/include/asm-ia64/machvec_hpzx1.h
index daafe504c5f4..e90daf9ce340 100644
--- a/include/asm-ia64/machvec_hpzx1.h
+++ b/include/asm-ia64/machvec_hpzx1.h
@@ -1,8 +1,7 @@
1#ifndef _ASM_IA64_MACHVEC_HPZX1_h 1#ifndef _ASM_IA64_MACHVEC_HPZX1_h
2#define _ASM_IA64_MACHVEC_HPZX1_h 2#define _ASM_IA64_MACHVEC_HPZX1_h
3 3
4extern ia64_mv_setup_t dig_setup; 4extern ia64_mv_setup_t dig_setup;
5extern ia64_mv_setup_t sba_setup;
6extern ia64_mv_dma_alloc_coherent sba_alloc_coherent; 5extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;
7extern ia64_mv_dma_free_coherent sba_free_coherent; 6extern ia64_mv_dma_free_coherent sba_free_coherent;
8extern ia64_mv_dma_map_single sba_map_single; 7extern ia64_mv_dma_map_single sba_map_single;
@@ -19,15 +18,15 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
19 * platform's machvec structure. When compiling a non-generic kernel, 18 * platform's machvec structure. When compiling a non-generic kernel,
20 * the macros are used directly. 19 * the macros are used directly.
21 */ 20 */
22#define platform_name "hpzx1" 21#define platform_name "hpzx1"
23#define platform_setup sba_setup 22#define platform_setup dig_setup
24#define platform_dma_init machvec_noop 23#define platform_dma_init machvec_noop
25#define platform_dma_alloc_coherent sba_alloc_coherent 24#define platform_dma_alloc_coherent sba_alloc_coherent
26#define platform_dma_free_coherent sba_free_coherent 25#define platform_dma_free_coherent sba_free_coherent
27#define platform_dma_map_single sba_map_single 26#define platform_dma_map_single sba_map_single
28#define platform_dma_unmap_single sba_unmap_single 27#define platform_dma_unmap_single sba_unmap_single
29#define platform_dma_map_sg sba_map_sg 28#define platform_dma_map_sg sba_map_sg
30#define platform_dma_unmap_sg sba_unmap_sg 29#define platform_dma_unmap_sg sba_unmap_sg
31#define platform_dma_sync_single_for_cpu machvec_dma_sync_single 30#define platform_dma_sync_single_for_cpu machvec_dma_sync_single
32#define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg 31#define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg
33#define platform_dma_sync_single_for_device machvec_dma_sync_single 32#define platform_dma_sync_single_for_device machvec_dma_sync_single
diff --git a/include/asm-ia64/machvec_hpzx1_swiotlb.h b/include/asm-ia64/machvec_hpzx1_swiotlb.h
index 9924b1b00a6c..f00a34a148ff 100644
--- a/include/asm-ia64/machvec_hpzx1_swiotlb.h
+++ b/include/asm-ia64/machvec_hpzx1_swiotlb.h
@@ -2,7 +2,6 @@
2#define _ASM_IA64_MACHVEC_HPZX1_SWIOTLB_h 2#define _ASM_IA64_MACHVEC_HPZX1_SWIOTLB_h
3 3
4extern ia64_mv_setup_t dig_setup; 4extern ia64_mv_setup_t dig_setup;
5extern ia64_mv_dma_init hwsw_init;
6extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent; 5extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent;
7extern ia64_mv_dma_free_coherent hwsw_free_coherent; 6extern ia64_mv_dma_free_coherent hwsw_free_coherent;
8extern ia64_mv_dma_map_single hwsw_map_single; 7extern ia64_mv_dma_map_single hwsw_map_single;
@@ -26,7 +25,7 @@ extern ia64_mv_dma_sync_sg_for_device hwsw_sync_sg_for_device;
26#define platform_name "hpzx1_swiotlb" 25#define platform_name "hpzx1_swiotlb"
27 26
28#define platform_setup dig_setup 27#define platform_setup dig_setup
29#define platform_dma_init hwsw_init 28#define platform_dma_init machvec_noop
30#define platform_dma_alloc_coherent hwsw_alloc_coherent 29#define platform_dma_alloc_coherent hwsw_alloc_coherent
31#define platform_dma_free_coherent hwsw_free_coherent 30#define platform_dma_free_coherent hwsw_free_coherent
32#define platform_dma_map_single hwsw_map_single 31#define platform_dma_map_single hwsw_map_single
diff --git a/include/asm-ia64/mca.h b/include/asm-ia64/mca.h
index 97a28b8b2ddd..c7d9c9ed38ba 100644
--- a/include/asm-ia64/mca.h
+++ b/include/asm-ia64/mca.h
@@ -80,7 +80,12 @@ struct ia64_sal_os_state {
80 u64 sal_ra; /* Return address in SAL, physical */ 80 u64 sal_ra; /* Return address in SAL, physical */
81 u64 sal_gp; /* GP of the SAL - physical */ 81 u64 sal_gp; /* GP of the SAL - physical */
82 pal_min_state_area_t *pal_min_state; /* from R17. physical in asm, virtual in C */ 82 pal_min_state_area_t *pal_min_state; /* from R17. physical in asm, virtual in C */
83 /* Previous values of IA64_KR(CURRENT) and IA64_KR(CURRENT_STACK).
84 * Note: if the MCA/INIT recovery code wants to resume to a new context
85 * then it must change these values to reflect the new kernel stack.
86 */
83 u64 prev_IA64_KR_CURRENT; /* previous value of IA64_KR(CURRENT) */ 87 u64 prev_IA64_KR_CURRENT; /* previous value of IA64_KR(CURRENT) */
88 u64 prev_IA64_KR_CURRENT_STACK;
84 struct task_struct *prev_task; /* previous task, NULL if it is not useful */ 89 struct task_struct *prev_task; /* previous task, NULL if it is not useful */
85 /* Some interrupt registers are not saved in minstate, pt_regs or 90 /* Some interrupt registers are not saved in minstate, pt_regs or
86 * switch_stack. Because MCA/INIT can occur when interrupts are 91 * switch_stack. Because MCA/INIT can occur when interrupts are
diff --git a/include/asm-ia64/sn/io.h b/include/asm-ia64/sn/io.h
index 42209733f6b1..7597a52b426c 100644
--- a/include/asm-ia64/sn/io.h
+++ b/include/asm-ia64/sn/io.h
@@ -36,6 +36,15 @@ extern void sn_dma_flush(unsigned long);
36#define __sn_readq_relaxed ___sn_readq_relaxed 36#define __sn_readq_relaxed ___sn_readq_relaxed
37 37
38/* 38/*
39 * Convenience macros for setting/clearing bits using the above accessors
40 */
41
42#define __sn_setq_relaxed(addr, val) \
43 writeq((__sn_readq_relaxed(addr) | (val)), (addr))
44#define __sn_clrq_relaxed(addr, val) \
45 writeq((__sn_readq_relaxed(addr) & ~(val)), (addr))
46
47/*
39 * The following routines are SN Platform specific, called when 48 * The following routines are SN Platform specific, called when
40 * a reference is made to inX/outX set macros. SN Platform 49 * a reference is made to inX/outX set macros. SN Platform
41 * inX set of macros ensures that Posted DMA writes on the 50 * inX set of macros ensures that Posted DMA writes on the
diff --git a/include/asm-ia64/sn/l1.h b/include/asm-ia64/sn/l1.h
index 2e5f0aa38889..e3b819110d47 100644
--- a/include/asm-ia64/sn/l1.h
+++ b/include/asm-ia64/sn/l1.h
@@ -35,4 +35,16 @@
35#define L1_BRICKTYPE_ATHENA 0x2b /* + */ 35#define L1_BRICKTYPE_ATHENA 0x2b /* + */
36#define L1_BRICKTYPE_DAYTONA 0x7a /* z */ 36#define L1_BRICKTYPE_DAYTONA 0x7a /* z */
37 37
38/* board type response codes */
39#define L1_BOARDTYPE_IP69 0x0100 /* CA */
40#define L1_BOARDTYPE_IP63 0x0200 /* CB */
41#define L1_BOARDTYPE_BASEIO 0x0300 /* IB */
42#define L1_BOARDTYPE_PCIE2SLOT 0x0400 /* IC */
43#define L1_BOARDTYPE_PCIX3SLOT 0x0500 /* ID */
44#define L1_BOARDTYPE_PCIXPCIE4SLOT 0x0600 /* IE */
45#define L1_BOARDTYPE_ABACUS 0x0700 /* AB */
46#define L1_BOARDTYPE_DAYTONA 0x0800 /* AD */
47#define L1_BOARDTYPE_INVAL (-1) /* invalid brick type */
48
49
38#endif /* _ASM_IA64_SN_L1_H */ 50#endif /* _ASM_IA64_SN_L1_H */
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
index fea35b33d4e4..34f3127e4416 100644
--- a/include/asm-ia64/sn/sn_sal.h
+++ b/include/asm-ia64/sn/sn_sal.h
@@ -47,6 +47,7 @@
47#define SN_SAL_CONSOLE_PUTB 0x02000028 47#define SN_SAL_CONSOLE_PUTB 0x02000028
48#define SN_SAL_CONSOLE_XMIT_CHARS 0x0200002a 48#define SN_SAL_CONSOLE_XMIT_CHARS 0x0200002a
49#define SN_SAL_CONSOLE_READC 0x0200002b 49#define SN_SAL_CONSOLE_READC 0x0200002b
50#define SN_SAL_SYSCTL_OP 0x02000030
50#define SN_SAL_SYSCTL_MODID_GET 0x02000031 51#define SN_SAL_SYSCTL_MODID_GET 0x02000031
51#define SN_SAL_SYSCTL_GET 0x02000032 52#define SN_SAL_SYSCTL_GET 0x02000032
52#define SN_SAL_SYSCTL_IOBRICK_MODULE_GET 0x02000033 53#define SN_SAL_SYSCTL_IOBRICK_MODULE_GET 0x02000033
@@ -101,6 +102,13 @@
101#define SAL_INTR_FREE 2 102#define SAL_INTR_FREE 2
102 103
103/* 104/*
105 * operations available on the generic SN_SAL_SYSCTL_OP
106 * runtime service
107 */
108#define SAL_SYSCTL_OP_IOBOARD 0x0001 /* retrieve board type */
109#define SAL_SYSCTL_OP_TIO_JLCK_RST 0x0002 /* issue TIO clock reset */
110
111/*
104 * IRouter (i.e. generalized system controller) operations 112 * IRouter (i.e. generalized system controller) operations
105 */ 113 */
106#define SAL_IROUTER_OPEN 0 /* open a subchannel */ 114#define SAL_IROUTER_OPEN 0 /* open a subchannel */
@@ -873,6 +881,41 @@ ia64_sn_sysctl_event_init(nasid_t nasid)
873 return (int) rv.v0; 881 return (int) rv.v0;
874} 882}
875 883
884/*
885 * Ask the system controller on the specified nasid to reset
886 * the CX corelet clock. Only valid on TIO nodes.
887 */
888static inline int
889ia64_sn_sysctl_tio_clock_reset(nasid_t nasid)
890{
891 struct ia64_sal_retval rv;
892 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_TIO_JLCK_RST,
893 nasid, 0, 0, 0, 0, 0);
894 if (rv.status != 0)
895 return (int)rv.status;
896 if (rv.v0 != 0)
897 return (int)rv.v0;
898
899 return 0;
900}
901
902/*
903 * Get the associated ioboard type for a given nasid.
904 */
905static inline int
906ia64_sn_sysctl_ioboard_get(nasid_t nasid)
907{
908 struct ia64_sal_retval rv;
909 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD,
910 nasid, 0, 0, 0, 0, 0);
911 if (rv.v0 != 0)
912 return (int)rv.v0;
913 if (rv.v1 != 0)
914 return (int)rv.v1;
915
916 return 0;
917}
918
876/** 919/**
877 * ia64_sn_get_fit_compt - read a FIT entry from the PROM header 920 * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
878 * @nasid: NASID of node to read 921 * @nasid: NASID of node to read
diff --git a/include/asm-ia64/sn/tioca_provider.h b/include/asm-ia64/sn/tioca_provider.h
index 5ccec608d325..b532ef6148ed 100644
--- a/include/asm-ia64/sn/tioca_provider.h
+++ b/include/asm-ia64/sn/tioca_provider.h
@@ -182,11 +182,11 @@ tioca_tlbflush(struct tioca_kernel *tioca_kernel)
182 * touch every CL aligned GART entry. 182 * touch every CL aligned GART entry.
183 */ 183 */
184 184
185 ca_base->ca_control2 &= ~(CA_GART_MEM_PARAM); 185 __sn_clrq_relaxed(&ca_base->ca_control2, CA_GART_MEM_PARAM);
186 ca_base->ca_control2 |= CA_GART_FLUSH_TLB; 186 __sn_setq_relaxed(&ca_base->ca_control2, CA_GART_FLUSH_TLB);
187 ca_base->ca_control2 |= 187 __sn_setq_relaxed(&ca_base->ca_control2,
188 (0x2ull << CA_GART_MEM_PARAM_SHFT); 188 (0x2ull << CA_GART_MEM_PARAM_SHFT));
189 tmp = ca_base->ca_control2; 189 tmp = __sn_readq_relaxed(&ca_base->ca_control2);
190 } 190 }
191 191
192 return; 192 return;
@@ -196,8 +196,8 @@ tioca_tlbflush(struct tioca_kernel *tioca_kernel)
196 * Gart in uncached mode ... need an explicit flush. 196 * Gart in uncached mode ... need an explicit flush.
197 */ 197 */
198 198
199 ca_base->ca_control2 |= CA_GART_FLUSH_TLB; 199 __sn_setq_relaxed(&ca_base->ca_control2, CA_GART_FLUSH_TLB);
200 tmp = ca_base->ca_control2; 200 tmp = __sn_readq_relaxed(&ca_base->ca_control2);
201} 201}
202 202
203extern uint32_t tioca_gart_found; 203extern uint32_t tioca_gart_found;
diff --git a/include/asm-ia64/sn/tiocx.h b/include/asm-ia64/sn/tiocx.h
index c5447a504509..5699e75e5024 100644
--- a/include/asm-ia64/sn/tiocx.h
+++ b/include/asm-ia64/sn/tiocx.h
@@ -19,6 +19,7 @@ struct cx_id_s {
19 19
20struct cx_dev { 20struct cx_dev {
21 struct cx_id_s cx_id; 21 struct cx_id_s cx_id;
22 int bt; /* board/blade type */
22 void *soft; /* driver specific */ 23 void *soft; /* driver specific */
23 struct hubdev_info *hubdev; 24 struct hubdev_info *hubdev;
24 struct device dev; 25 struct device dev;
@@ -59,7 +60,7 @@ struct cx_drv {
59extern struct sn_irq_info *tiocx_irq_alloc(nasid_t, int, int, nasid_t, int); 60extern struct sn_irq_info *tiocx_irq_alloc(nasid_t, int, int, nasid_t, int);
60extern void tiocx_irq_free(struct sn_irq_info *); 61extern void tiocx_irq_free(struct sn_irq_info *);
61extern int cx_device_unregister(struct cx_dev *); 62extern int cx_device_unregister(struct cx_dev *);
62extern int cx_device_register(nasid_t, int, int, struct hubdev_info *); 63extern int cx_device_register(nasid_t, int, int, struct hubdev_info *, int);
63extern int cx_driver_unregister(struct cx_drv *); 64extern int cx_driver_unregister(struct cx_drv *);
64extern int cx_driver_register(struct cx_drv *); 65extern int cx_driver_register(struct cx_drv *);
65extern uint64_t tiocx_dma_addr(uint64_t addr); 66extern uint64_t tiocx_dma_addr(uint64_t addr);
diff --git a/include/asm-ia64/uaccess.h b/include/asm-ia64/uaccess.h
index 3a7829bb5954..9adb51211c22 100644
--- a/include/asm-ia64/uaccess.h
+++ b/include/asm-ia64/uaccess.h
@@ -187,8 +187,8 @@ extern void __get_user_unknown (void);
187({ \ 187({ \
188 const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ 188 const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \
189 __typeof__ (size) __gu_size = (size); \ 189 __typeof__ (size) __gu_size = (size); \
190 long __gu_err = -EFAULT, __gu_val = 0; \ 190 long __gu_err = -EFAULT; \
191 \ 191 unsigned long __gu_val = 0; \
192 if (!check || __access_ok(__gu_ptr, size, segment)) \ 192 if (!check || __access_ok(__gu_ptr, size, segment)) \
193 switch (__gu_size) { \ 193 switch (__gu_size) { \
194 case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \ 194 case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \
@@ -240,13 +240,13 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
240static inline unsigned long 240static inline unsigned long
241__copy_to_user (void __user *to, const void *from, unsigned long count) 241__copy_to_user (void __user *to, const void *from, unsigned long count)
242{ 242{
243 return __copy_user(to, (void __user *) from, count); 243 return __copy_user(to, (__force void __user *) from, count);
244} 244}
245 245
246static inline unsigned long 246static inline unsigned long
247__copy_from_user (void *to, const void __user *from, unsigned long count) 247__copy_from_user (void *to, const void __user *from, unsigned long count)
248{ 248{
249 return __copy_user((void __user *) to, from, count); 249 return __copy_user((__force void __user *) to, from, count);
250} 250}
251 251
252#define __copy_to_user_inatomic __copy_to_user 252#define __copy_to_user_inatomic __copy_to_user
@@ -258,7 +258,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
258 long __cu_len = (n); \ 258 long __cu_len = (n); \
259 \ 259 \
260 if (__access_ok(__cu_to, __cu_len, get_fs())) \ 260 if (__access_ok(__cu_to, __cu_len, get_fs())) \
261 __cu_len = __copy_user(__cu_to, (void __user *) __cu_from, __cu_len); \ 261 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
262 __cu_len; \ 262 __cu_len; \
263}) 263})
264 264
@@ -270,7 +270,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
270 \ 270 \
271 __chk_user_ptr(__cu_from); \ 271 __chk_user_ptr(__cu_from); \
272 if (__access_ok(__cu_from, __cu_len, get_fs())) \ 272 if (__access_ok(__cu_from, __cu_len, get_fs())) \
273 __cu_len = __copy_user((void __user *) __cu_to, __cu_from, __cu_len); \ 273 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
274 __cu_len; \ 274 __cu_len; \
275}) 275})
276 276
diff --git a/include/asm-m32r/futex.h b/include/asm-m32r/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-m32r/futex.h
+++ b/include/asm-m32r/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-m32r/io.h b/include/asm-m32r/io.h
index 8e9e481e6996..70ad1c949c2b 100644
--- a/include/asm-m32r/io.h
+++ b/include/asm-m32r/io.h
@@ -60,7 +60,7 @@ __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
60 * address. 60 * address.
61 */ 61 */
62 62
63static inline void * ioremap(unsigned long offset, unsigned long size) 63static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
64{ 64{
65 return __ioremap(offset, size, 0); 65 return __ioremap(offset, size, 0);
66} 66}
diff --git a/include/asm-m32r/uaccess.h b/include/asm-m32r/uaccess.h
index 93d863c455a1..0da7c47d2f01 100644
--- a/include/asm-m32r/uaccess.h
+++ b/include/asm-m32r/uaccess.h
@@ -208,7 +208,8 @@ extern void __get_user_4(void);
208 * On error, the variable @x is set to zero. 208 * On error, the variable @x is set to zero.
209 */ 209 */
210#define get_user(x,ptr) \ 210#define get_user(x,ptr) \
211({ int __ret_gu,__val_gu; \ 211({ int __ret_gu; \
212 unsigned long __val_gu; \
212 __chk_user_ptr(ptr); \ 213 __chk_user_ptr(ptr); \
213 switch(sizeof (*(ptr))) { \ 214 switch(sizeof (*(ptr))) { \
214 case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \ 215 case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \
@@ -403,7 +404,8 @@ struct __large_struct { unsigned long buf[100]; };
403 404
404#define __get_user_nocheck(x,ptr,size) \ 405#define __get_user_nocheck(x,ptr,size) \
405({ \ 406({ \
406 long __gu_err, __gu_val; \ 407 long __gu_err; \
408 unsigned long __gu_val; \
407 __get_user_size(__gu_val,(ptr),(size),__gu_err); \ 409 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
408 (x) = (__typeof__(*(ptr)))__gu_val; \ 410 (x) = (__typeof__(*(ptr)))__gu_val; \
409 __gu_err; \ 411 __gu_err; \
@@ -594,8 +596,8 @@ static inline unsigned long __generic_copy_to_user_nocheck(void __user *to,
594 return n; 596 return n;
595} 597}
596 598
597unsigned long __generic_copy_to_user(void *, const void *, unsigned long); 599unsigned long __generic_copy_to_user(void __user *, const void *, unsigned long);
598unsigned long __generic_copy_from_user(void *, const void *, unsigned long); 600unsigned long __generic_copy_from_user(void *, const void __user *, unsigned long);
599 601
600/** 602/**
601 * __copy_to_user: - Copy a block of data into user space, with less checking. 603 * __copy_to_user: - Copy a block of data into user space, with less checking.
diff --git a/include/asm-m68k/futex.h b/include/asm-m68k/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-m68k/futex.h
+++ b/include/asm-m68k/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-m68knommu/futex.h b/include/asm-m68knommu/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-m68knommu/futex.h
+++ b/include/asm-m68knommu/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index cbd1672c94cb..eaf5d9b3a0e1 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -68,6 +68,8 @@ extern unsigned long zero_page_mask;
68#define ZERO_PAGE(vaddr) \ 68#define ZERO_PAGE(vaddr) \
69 (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))) 69 (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))
70 70
71#define __HAVE_ARCH_MULTIPLE_ZERO_PAGE
72
71extern void paging_init(void); 73extern void paging_init(void);
72 74
73/* 75/*
diff --git a/include/asm-parisc/futex.h b/include/asm-parisc/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-parisc/futex.h
+++ b/include/asm-parisc/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-powerpc/timex.h b/include/asm-powerpc/timex.h
index 51c5b316be55..c02d15aced91 100644
--- a/include/asm-powerpc/timex.h
+++ b/include/asm-powerpc/timex.h
@@ -10,7 +10,7 @@
10#include <linux/config.h> 10#include <linux/config.h>
11#include <asm/cputable.h> 11#include <asm/cputable.h>
12 12
13#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ 13#define CLOCK_TICK_RATE 1024000 /* Underlying HZ */
14 14
15typedef unsigned long cycles_t; 15typedef unsigned long cycles_t;
16 16
diff --git a/include/asm-ppc/cputable.h b/include/asm-ppc/cputable.h
index 41d8f8425c04..e17c492c870b 100644
--- a/include/asm-ppc/cputable.h
+++ b/include/asm-ppc/cputable.h
@@ -24,6 +24,7 @@
24#define PPC_FEATURE_HAS_SPE 0x00800000 24#define PPC_FEATURE_HAS_SPE 0x00800000
25#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 25#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000
26#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 26#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000
27#define PPC_FEATURE_NO_TB 0x00100000
27 28
28#ifdef __KERNEL__ 29#ifdef __KERNEL__
29 30
diff --git a/include/asm-ppc/dma-mapping.h b/include/asm-ppc/dma-mapping.h
index 92b8ee78dcc2..061bfcac1bf1 100644
--- a/include/asm-ppc/dma-mapping.h
+++ b/include/asm-ppc/dma-mapping.h
@@ -61,7 +61,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
61 61
62static inline void *dma_alloc_coherent(struct device *dev, size_t size, 62static inline void *dma_alloc_coherent(struct device *dev, size_t size,
63 dma_addr_t * dma_handle, 63 dma_addr_t * dma_handle,
64 unsigned int __nocast gfp) 64 gfp_t gfp)
65{ 65{
66#ifdef CONFIG_NOT_COHERENT_CACHE 66#ifdef CONFIG_NOT_COHERENT_CACHE
67 return __dma_alloc_coherent(size, dma_handle, gfp); 67 return __dma_alloc_coherent(size, dma_handle, gfp);
diff --git a/include/asm-ppc/futex.h b/include/asm-ppc/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-ppc/futex.h
+++ b/include/asm-ppc/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 7eb7cf6360bd..94d83998a759 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -56,7 +56,7 @@ extern unsigned long pci_dram_offset;
56 * is actually performed (i.e. the data has come back) before we start 56 * is actually performed (i.e. the data has come back) before we start
57 * executing any following instructions. 57 * executing any following instructions.
58 */ 58 */
59extern inline int in_8(volatile unsigned char __iomem *addr) 59extern inline int in_8(const volatile unsigned char __iomem *addr)
60{ 60{
61 int ret; 61 int ret;
62 62
@@ -72,7 +72,7 @@ extern inline void out_8(volatile unsigned char __iomem *addr, int val)
72 __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val)); 72 __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
73} 73}
74 74
75extern inline int in_le16(volatile unsigned short __iomem *addr) 75extern inline int in_le16(const volatile unsigned short __iomem *addr)
76{ 76{
77 int ret; 77 int ret;
78 78
@@ -83,7 +83,7 @@ extern inline int in_le16(volatile unsigned short __iomem *addr)
83 return ret; 83 return ret;
84} 84}
85 85
86extern inline int in_be16(volatile unsigned short __iomem *addr) 86extern inline int in_be16(const volatile unsigned short __iomem *addr)
87{ 87{
88 int ret; 88 int ret;
89 89
@@ -104,7 +104,7 @@ extern inline void out_be16(volatile unsigned short __iomem *addr, int val)
104 __asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val)); 104 __asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
105} 105}
106 106
107extern inline unsigned in_le32(volatile unsigned __iomem *addr) 107extern inline unsigned in_le32(const volatile unsigned __iomem *addr)
108{ 108{
109 unsigned ret; 109 unsigned ret;
110 110
@@ -115,7 +115,7 @@ extern inline unsigned in_le32(volatile unsigned __iomem *addr)
115 return ret; 115 return ret;
116} 116}
117 117
118extern inline unsigned in_be32(volatile unsigned __iomem *addr) 118extern inline unsigned in_be32(const volatile unsigned __iomem *addr)
119{ 119{
120 unsigned ret; 120 unsigned ret;
121 121
@@ -139,7 +139,7 @@ extern inline void out_be32(volatile unsigned __iomem *addr, int val)
139#define readb(addr) in_8((volatile u8 *)(addr)) 139#define readb(addr) in_8((volatile u8 *)(addr))
140#define writeb(b,addr) out_8((volatile u8 *)(addr), (b)) 140#define writeb(b,addr) out_8((volatile u8 *)(addr), (b))
141#else 141#else
142static inline __u8 readb(volatile void __iomem *addr) 142static inline __u8 readb(const volatile void __iomem *addr)
143{ 143{
144 return in_8(addr); 144 return in_8(addr);
145} 145}
@@ -150,11 +150,11 @@ static inline void writeb(__u8 b, volatile void __iomem *addr)
150#endif 150#endif
151 151
152#if defined(CONFIG_APUS) 152#if defined(CONFIG_APUS)
153static inline __u16 readw(volatile void __iomem *addr) 153static inline __u16 readw(const volatile void __iomem *addr)
154{ 154{
155 return *(__force volatile __u16 *)(addr); 155 return *(__force volatile __u16 *)(addr);
156} 156}
157static inline __u32 readl(volatile void __iomem *addr) 157static inline __u32 readl(const volatile void __iomem *addr)
158{ 158{
159 return *(__force volatile __u32 *)(addr); 159 return *(__force volatile __u32 *)(addr);
160} 160}
@@ -173,11 +173,11 @@ static inline void writel(__u32 b, volatile void __iomem *addr)
173#define writew(b,addr) out_le16((volatile u16 *)(addr),(b)) 173#define writew(b,addr) out_le16((volatile u16 *)(addr),(b))
174#define writel(b,addr) out_le32((volatile u32 *)(addr),(b)) 174#define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
175#else 175#else
176static inline __u16 readw(volatile void __iomem *addr) 176static inline __u16 readw(const volatile void __iomem *addr)
177{ 177{
178 return in_le16(addr); 178 return in_le16(addr);
179} 179}
180static inline __u32 readl(volatile void __iomem *addr) 180static inline __u32 readl(const volatile void __iomem *addr)
181{ 181{
182 return in_le32(addr); 182 return in_le32(addr);
183} 183}
diff --git a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h
index 55752474d0d9..bd9674807f05 100644
--- a/include/asm-ppc/irq.h
+++ b/include/asm-ppc/irq.h
@@ -138,6 +138,16 @@ irq_canonicalize(int irq)
138#define SIU_IRQ7 (14) 138#define SIU_IRQ7 (14)
139#define SIU_LEVEL7 (15) 139#define SIU_LEVEL7 (15)
140 140
141#define MPC8xx_INT_FEC1 SIU_LEVEL1
142#define MPC8xx_INT_FEC2 SIU_LEVEL3
143
144#define MPC8xx_INT_SCC1 (CPM_IRQ_OFFSET + CPMVEC_SCC1)
145#define MPC8xx_INT_SCC2 (CPM_IRQ_OFFSET + CPMVEC_SCC2)
146#define MPC8xx_INT_SCC3 (CPM_IRQ_OFFSET + CPMVEC_SCC3)
147#define MPC8xx_INT_SCC4 (CPM_IRQ_OFFSET + CPMVEC_SCC4)
148#define MPC8xx_INT_SMC1 (CPM_IRQ_OFFSET + CPMVEC_SMC1)
149#define MPC8xx_INT_SMC2 (CPM_IRQ_OFFSET + CPMVEC_SMC2)
150
141/* The internal interrupts we can configure as we see fit. 151/* The internal interrupts we can configure as we see fit.
142 * My personal preference is CPM at level 2, which puts it above the 152 * My personal preference is CPM at level 2, which puts it above the
143 * MBX PCI/ISA/IDE interrupts. 153 * MBX PCI/ISA/IDE interrupts.
diff --git a/include/asm-ppc/macio.h b/include/asm-ppc/macio.h
index a481b772d154..b553dd4b139e 100644
--- a/include/asm-ppc/macio.h
+++ b/include/asm-ppc/macio.h
@@ -1,7 +1,6 @@
1#ifndef __MACIO_ASIC_H__ 1#ifndef __MACIO_ASIC_H__
2#define __MACIO_ASIC_H__ 2#define __MACIO_ASIC_H__
3 3
4#include <linux/mod_devicetable.h>
5#include <asm/of_device.h> 4#include <asm/of_device.h>
6 5
7extern struct bus_type macio_bus_type; 6extern struct bus_type macio_bus_type;
diff --git a/include/asm-ppc/mpc8xx.h b/include/asm-ppc/mpc8xx.h
index dc8e59896050..208a2e11daee 100644
--- a/include/asm-ppc/mpc8xx.h
+++ b/include/asm-ppc/mpc8xx.h
@@ -97,6 +97,22 @@ extern unsigned char __res[];
97 97
98struct pt_regs; 98struct pt_regs;
99 99
100enum ppc_sys_devices {
101 MPC8xx_CPM_FEC1,
102 MPC8xx_CPM_FEC2,
103 MPC8xx_CPM_I2C,
104 MPC8xx_CPM_SCC1,
105 MPC8xx_CPM_SCC2,
106 MPC8xx_CPM_SCC3,
107 MPC8xx_CPM_SCC4,
108 MPC8xx_CPM_SPI,
109 MPC8xx_CPM_MCC1,
110 MPC8xx_CPM_MCC2,
111 MPC8xx_CPM_SMC1,
112 MPC8xx_CPM_SMC2,
113 MPC8xx_CPM_USB,
114};
115
100#endif /* !__ASSEMBLY__ */ 116#endif /* !__ASSEMBLY__ */
101#endif /* CONFIG_8xx */ 117#endif /* CONFIG_8xx */
102#endif /* __CONFIG_8xx_DEFS */ 118#endif /* __CONFIG_8xx_DEFS */
diff --git a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h
index 75c2ffa26b26..ee2f9188cc64 100644
--- a/include/asm-ppc/mv64x60.h
+++ b/include/asm-ppc/mv64x60.h
@@ -233,7 +233,7 @@ struct mv64x60_chip_info {
233struct mv64x60_handle { 233struct mv64x60_handle {
234 u32 type; /* type of bridge */ 234 u32 type; /* type of bridge */
235 u32 rev; /* revision of bridge */ 235 u32 rev; /* revision of bridge */
236 void *v_base; /* virtual base addr of bridge regs */ 236 void __iomem *v_base;/* virtual base addr of bridge regs */
237 phys_addr_t p_base; /* physical base addr of bridge regs */ 237 phys_addr_t p_base; /* physical base addr of bridge regs */
238 238
239 u32 pci_mode_a; /* pci 0 mode: conventional pci, pci-x*/ 239 u32 pci_mode_a; /* pci 0 mode: conventional pci, pci-x*/
@@ -303,7 +303,7 @@ void mv64x60_alloc_hose(struct mv64x60_handle *bh, u32 cfg_addr,
303 u32 cfg_data, struct pci_controller **hose); 303 u32 cfg_data, struct pci_controller **hose);
304int mv64x60_get_type(struct mv64x60_handle *bh); 304int mv64x60_get_type(struct mv64x60_handle *bh);
305int mv64x60_setup_for_chip(struct mv64x60_handle *bh); 305int mv64x60_setup_for_chip(struct mv64x60_handle *bh);
306void *mv64x60_get_bridge_vbase(void); 306void __iomem *mv64x60_get_bridge_vbase(void);
307u32 mv64x60_get_bridge_type(void); 307u32 mv64x60_get_bridge_type(void);
308u32 mv64x60_get_bridge_rev(void); 308u32 mv64x60_get_bridge_rev(void);
309void mv64x60_get_mem_windows(struct mv64x60_handle *bh, 309void mv64x60_get_mem_windows(struct mv64x60_handle *bh,
diff --git a/include/asm-ppc/of_device.h b/include/asm-ppc/of_device.h
index 4b264cfd3998..575bce418f80 100644
--- a/include/asm-ppc/of_device.h
+++ b/include/asm-ppc/of_device.h
@@ -2,6 +2,7 @@
2#define __OF_DEVICE_H__ 2#define __OF_DEVICE_H__
3 3
4#include <linux/device.h> 4#include <linux/device.h>
5#include <linux/mod_devicetable.h>
5#include <asm/prom.h> 6#include <asm/prom.h>
6 7
7/* 8/*
@@ -55,7 +56,9 @@ extern int of_register_driver(struct of_platform_driver *drv);
55extern void of_unregister_driver(struct of_platform_driver *drv); 56extern void of_unregister_driver(struct of_platform_driver *drv);
56extern int of_device_register(struct of_device *ofdev); 57extern int of_device_register(struct of_device *ofdev);
57extern void of_device_unregister(struct of_device *ofdev); 58extern void of_device_unregister(struct of_device *ofdev);
58extern struct of_device *of_platform_device_create(struct device_node *np, const char *bus_id); 59extern struct of_device *of_platform_device_create(struct device_node *np,
60 const char *bus_id,
61 struct device *parent);
59extern void of_release_dev(struct device *dev); 62extern void of_release_dev(struct device *dev);
60 63
61#endif /* __OF_DEVICE_H__ */ 64#endif /* __OF_DEVICE_H__ */
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index 048f7c8596ee..549f44843c5e 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -27,6 +27,8 @@
27#include <asm/mpc83xx.h> 27#include <asm/mpc83xx.h>
28#elif defined(CONFIG_85xx) 28#elif defined(CONFIG_85xx)
29#include <asm/mpc85xx.h> 29#include <asm/mpc85xx.h>
30#elif defined(CONFIG_8xx)
31#include <asm/mpc8xx.h>
30#elif defined(CONFIG_PPC_MPC52xx) 32#elif defined(CONFIG_PPC_MPC52xx)
31#include <asm/mpc52xx.h> 33#include <asm/mpc52xx.h>
32#elif defined(CONFIG_MPC10X_BRIDGE) 34#elif defined(CONFIG_MPC10X_BRIDGE)
diff --git a/include/asm-ppc64/dma-mapping.h b/include/asm-ppc64/dma-mapping.h
index 9ad8adee0067..fb68fa23bea8 100644
--- a/include/asm-ppc64/dma-mapping.h
+++ b/include/asm-ppc64/dma-mapping.h
@@ -19,7 +19,7 @@
19extern int dma_supported(struct device *dev, u64 mask); 19extern int dma_supported(struct device *dev, u64 mask);
20extern int dma_set_mask(struct device *dev, u64 dma_mask); 20extern int dma_set_mask(struct device *dev, u64 dma_mask);
21extern void *dma_alloc_coherent(struct device *dev, size_t size, 21extern void *dma_alloc_coherent(struct device *dev, size_t size,
22 dma_addr_t *dma_handle, unsigned int __nocast flag); 22 dma_addr_t *dma_handle, gfp_t flag);
23extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 23extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
24 dma_addr_t dma_handle); 24 dma_addr_t dma_handle);
25extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, 25extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
@@ -118,7 +118,7 @@ dma_cache_sync(void *vaddr, size_t size,
118 */ 118 */
119struct dma_mapping_ops { 119struct dma_mapping_ops {
120 void * (*alloc_coherent)(struct device *dev, size_t size, 120 void * (*alloc_coherent)(struct device *dev, size_t size,
121 dma_addr_t *dma_handle, unsigned int __nocast flag); 121 dma_addr_t *dma_handle, gfp_t flag);
122 void (*free_coherent)(struct device *dev, size_t size, 122 void (*free_coherent)(struct device *dev, size_t size,
123 void *vaddr, dma_addr_t dma_handle); 123 void *vaddr, dma_addr_t dma_handle);
124 dma_addr_t (*map_single)(struct device *dev, void *ptr, 124 dma_addr_t (*map_single)(struct device *dev, void *ptr,
diff --git a/include/asm-ppc64/iommu.h b/include/asm-ppc64/iommu.h
index 72dcf8116b04..c2f3b6e8a42f 100644
--- a/include/asm-ppc64/iommu.h
+++ b/include/asm-ppc64/iommu.h
@@ -122,7 +122,7 @@ extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
122 int nelems, enum dma_data_direction direction); 122 int nelems, enum dma_data_direction direction);
123 123
124extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size, 124extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
125 dma_addr_t *dma_handle, unsigned int __nocast flag); 125 dma_addr_t *dma_handle, gfp_t flag);
126extern void iommu_free_coherent(struct iommu_table *tbl, size_t size, 126extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
127 void *vaddr, dma_addr_t dma_handle); 127 void *vaddr, dma_addr_t dma_handle);
128extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr, 128extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
diff --git a/include/asm-ppc64/smu.h b/include/asm-ppc64/smu.h
index 10b4397af9aa..dee8eefe47bc 100644
--- a/include/asm-ppc64/smu.h
+++ b/include/asm-ppc64/smu.h
@@ -1,22 +1,379 @@
1#ifndef _SMU_H
2#define _SMU_H
3
1/* 4/*
2 * Definitions for talking to the SMU chip in newer G5 PowerMacs 5 * Definitions for talking to the SMU chip in newer G5 PowerMacs
3 */ 6 */
4 7
5#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/list.h>
10
11/*
12 * Known SMU commands
13 *
14 * Most of what is below comes from looking at the Open Firmware driver,
15 * though this is still incomplete and could use better documentation here
16 * or there...
17 */
18
19
20/*
21 * Partition info commands
22 *
23 * I do not know what those are for at this point
24 */
25#define SMU_CMD_PARTITION_COMMAND 0x3e
26
27
28/*
29 * Fan control
30 *
31 * This is a "mux" for fan control commands, first byte is the
32 * "sub" command.
33 */
34#define SMU_CMD_FAN_COMMAND 0x4a
35
36
37/*
38 * Battery access
39 *
40 * Same command number as the PMU, could it be same syntax ?
41 */
42#define SMU_CMD_BATTERY_COMMAND 0x6f
43#define SMU_CMD_GET_BATTERY_INFO 0x00
44
45/*
46 * Real time clock control
47 *
48 * This is a "mux", first data byte contains the "sub" command.
49 * The "RTC" part of the SMU controls the date, time, powerup
50 * timer, but also a PRAM
51 *
52 * Dates are in BCD format on 7 bytes:
53 * [sec] [min] [hour] [weekday] [month day] [month] [year]
54 * with month being 1 based and year minus 100
55 */
56#define SMU_CMD_RTC_COMMAND 0x8e
57#define SMU_CMD_RTC_SET_PWRUP_TIMER 0x00 /* i: 7 bytes date */
58#define SMU_CMD_RTC_GET_PWRUP_TIMER 0x01 /* o: 7 bytes date */
59#define SMU_CMD_RTC_STOP_PWRUP_TIMER 0x02
60#define SMU_CMD_RTC_SET_PRAM_BYTE_ACC 0x20 /* i: 1 byte (address?) */
61#define SMU_CMD_RTC_SET_PRAM_AUTOINC 0x21 /* i: 1 byte (data?) */
62#define SMU_CMD_RTC_SET_PRAM_LO_BYTES 0x22 /* i: 10 bytes */
63#define SMU_CMD_RTC_SET_PRAM_HI_BYTES 0x23 /* i: 10 bytes */
64#define SMU_CMD_RTC_GET_PRAM_BYTE 0x28 /* i: 1 bytes (address?) */
65#define SMU_CMD_RTC_GET_PRAM_LO_BYTES 0x29 /* o: 10 bytes */
66#define SMU_CMD_RTC_GET_PRAM_HI_BYTES 0x2a /* o: 10 bytes */
67#define SMU_CMD_RTC_SET_DATETIME 0x80 /* i: 7 bytes date */
68#define SMU_CMD_RTC_GET_DATETIME 0x81 /* o: 7 bytes date */
69
70 /*
71 * i2c commands
72 *
73 * To issue an i2c command, first is to send a parameter block to the
74 * the SMU. This is a command of type 0x9a with 9 bytes of header
75 * eventually followed by data for a write:
76 *
77 * 0: bus number (from device-tree usually, SMU has lots of busses !)
78 * 1: transfer type/format (see below)
79 * 2: device address. For combined and combined4 type transfers, this
80 * is the "write" version of the address (bit 0x01 cleared)
81 * 3: subaddress length (0..3)
82 * 4: subaddress byte 0 (or only byte for subaddress length 1)
83 * 5: subaddress byte 1
84 * 6: subaddress byte 2
85 * 7: combined address (device address for combined mode data phase)
86 * 8: data length
87 *
88 * The transfer types are the same good old Apple ones it seems,
89 * that is:
90 * - 0x00: Simple transfer
91 * - 0x01: Subaddress transfer (addr write + data tx, no restart)
92 * - 0x02: Combined transfer (addr write + restart + data tx)
93 *
94 * This is then followed by actual data for a write.
95 *
96 * At this point, the OF driver seems to have a limitation on transfer
97 * sizes of 0xd bytes on reads and 0x5 bytes on writes. I do not know
98 * wether this is just an OF limit due to some temporary buffer size
99 * or if this is an SMU imposed limit. This driver has the same limitation
100 * for now as I use a 0x10 bytes temporary buffer as well
101 *
102 * Once that is completed, a response is expected from the SMU. This is
103 * obtained via a command of type 0x9a with a length of 1 byte containing
104 * 0 as the data byte. OF also fills the rest of the data buffer with 0xff's
105 * though I can't tell yet if this is actually necessary. Once this command
106 * is complete, at this point, all I can tell is what OF does. OF tests
107 * byte 0 of the reply:
108 * - on read, 0xfe or 0xfc : bus is busy, wait (see below) or nak ?
109 * - on read, 0x00 or 0x01 : reply is in buffer (after the byte 0)
110 * - on write, < 0 -> failure (immediate exit)
111 * - else, OF just exists (without error, weird)
112 *
113 * So on read, there is this wait-for-busy thing when getting a 0xfc or
114 * 0xfe result. OF does a loop of up to 64 retries, waiting 20ms and
115 * doing the above again until either the retries expire or the result
116 * is no longer 0xfe or 0xfc
117 *
118 * The Darwin I2C driver is less subtle though. On any non-success status
119 * from the response command, it waits 5ms and tries again up to 20 times,
120 * it doesn't differenciate between fatal errors or "busy" status.
121 *
122 * This driver provides an asynchronous paramblock based i2c command
123 * interface to be used either directly by low level code or by a higher
124 * level driver interfacing to the linux i2c layer. The current
125 * implementation of this relies on working timers & timer interrupts
126 * though, so be careful of calling context for now. This may be "fixed"
127 * in the future by adding a polling facility.
128 */
129#define SMU_CMD_I2C_COMMAND 0x9a
130 /* transfer types */
131#define SMU_I2C_TRANSFER_SIMPLE 0x00
132#define SMU_I2C_TRANSFER_STDSUB 0x01
133#define SMU_I2C_TRANSFER_COMBINED 0x02
134
135/*
136 * Power supply control
137 *
138 * The "sub" command is an ASCII string in the data, the
139 * data lenght is that of the string.
140 *
141 * The VSLEW command can be used to get or set the voltage slewing.
142 * - lenght 5 (only "VSLEW") : it returns "DONE" and 3 bytes of
143 * reply at data offset 6, 7 and 8.
144 * - lenght 8 ("VSLEWxyz") has 3 additional bytes appended, and is
145 * used to set the voltage slewing point. The SMU replies with "DONE"
146 * I yet have to figure out their exact meaning of those 3 bytes in
147 * both cases.
148 *
149 */
150#define SMU_CMD_POWER_COMMAND 0xaa
151#define SMU_CMD_POWER_RESTART "RESTART"
152#define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN"
153#define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW"
154
155/* Misc commands
156 *
157 * This command seem to be a grab bag of various things
158 */
159#define SMU_CMD_MISC_df_COMMAND 0xdf
160#define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02 /* i: 1 byte */
161#define SMU_CMD_MISC_df_NMI_OPTION 0x04
162
163/*
164 * Version info commands
165 *
166 * I haven't quite tried to figure out how these work
167 */
168#define SMU_CMD_VERSION_COMMAND 0xea
169
170
171/*
172 * Misc commands
173 *
174 * This command seem to be a grab bag of various things
175 */
176#define SMU_CMD_MISC_ee_COMMAND 0xee
177#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02
178#define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */
179#define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */
180
181
182
183/*
184 * - Kernel side interface -
185 */
186
187#ifdef __KERNEL__
188
189/*
190 * Asynchronous SMU commands
191 *
192 * Fill up this structure and submit it via smu_queue_command(),
193 * and get notified by the optional done() callback, or because
194 * status becomes != 1
195 */
196
197struct smu_cmd;
198
199struct smu_cmd
200{
201 /* public */
202 u8 cmd; /* command */
203 int data_len; /* data len */
204 int reply_len; /* reply len */
205 void *data_buf; /* data buffer */
206 void *reply_buf; /* reply buffer */
207 int status; /* command status */
208 void (*done)(struct smu_cmd *cmd, void *misc);
209 void *misc;
210
211 /* private */
212 struct list_head link;
213};
214
215/*
216 * Queues an SMU command, all fields have to be initialized
217 */
218extern int smu_queue_cmd(struct smu_cmd *cmd);
219
220/*
221 * Simple command wrapper. This structure embeds a small buffer
222 * to ease sending simple SMU commands from the stack
223 */
224struct smu_simple_cmd
225{
226 struct smu_cmd cmd;
227 u8 buffer[16];
228};
229
230/*
231 * Queues a simple command. All fields will be initialized by that
232 * function
233 */
234extern int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command,
235 unsigned int data_len,
236 void (*done)(struct smu_cmd *cmd, void *misc),
237 void *misc,
238 ...);
239
240/*
241 * Completion helper. Pass it to smu_queue_simple or as 'done'
242 * member to smu_queue_cmd, it will call complete() on the struct
243 * completion passed in the "misc" argument
244 */
245extern void smu_done_complete(struct smu_cmd *cmd, void *misc);
6 246
7/* 247/*
8 * Basic routines for use by architecture. To be extended as 248 * Synchronous helpers. Will spin-wait for completion of a command
9 * we understand more of the chip 249 */
250extern void smu_spinwait_cmd(struct smu_cmd *cmd);
251
252static inline void smu_spinwait_simple(struct smu_simple_cmd *scmd)
253{
254 smu_spinwait_cmd(&scmd->cmd);
255}
256
257/*
258 * Poll routine to call if blocked with irqs off
259 */
260extern void smu_poll(void);
261
262
263/*
264 * Init routine, presence check....
10 */ 265 */
11extern int smu_init(void); 266extern int smu_init(void);
12extern int smu_present(void); 267extern int smu_present(void);
268struct of_device;
269extern struct of_device *smu_get_ofdev(void);
270
271
272/*
273 * Common command wrappers
274 */
13extern void smu_shutdown(void); 275extern void smu_shutdown(void);
14extern void smu_restart(void); 276extern void smu_restart(void);
15extern int smu_get_rtc_time(struct rtc_time *time); 277struct rtc_time;
16extern int smu_set_rtc_time(struct rtc_time *time); 278extern int smu_get_rtc_time(struct rtc_time *time, int spinwait);
279extern int smu_set_rtc_time(struct rtc_time *time, int spinwait);
17 280
18/* 281/*
19 * SMU command buffer absolute address, exported by pmac_setup, 282 * SMU command buffer absolute address, exported by pmac_setup,
20 * this is allocated very early during boot. 283 * this is allocated very early during boot.
21 */ 284 */
22extern unsigned long smu_cmdbuf_abs; 285extern unsigned long smu_cmdbuf_abs;
286
287
288/*
289 * Kenrel asynchronous i2c interface
290 */
291
292/* SMU i2c header, exactly matches i2c header on wire */
293struct smu_i2c_param
294{
295 u8 bus; /* SMU bus ID (from device tree) */
296 u8 type; /* i2c transfer type */
297 u8 devaddr; /* device address (includes direction) */
298 u8 sublen; /* subaddress length */
299 u8 subaddr[3]; /* subaddress */
300 u8 caddr; /* combined address, filled by SMU driver */
301 u8 datalen; /* length of transfer */
302 u8 data[7]; /* data */
303};
304
305#define SMU_I2C_READ_MAX 0x0d
306#define SMU_I2C_WRITE_MAX 0x05
307
308struct smu_i2c_cmd
309{
310 /* public */
311 struct smu_i2c_param info;
312 void (*done)(struct smu_i2c_cmd *cmd, void *misc);
313 void *misc;
314 int status; /* 1 = pending, 0 = ok, <0 = fail */
315
316 /* private */
317 struct smu_cmd scmd;
318 int read;
319 int stage;
320 int retries;
321 u8 pdata[0x10];
322 struct list_head link;
323};
324
325/*
326 * Call this to queue an i2c command to the SMU. You must fill info,
327 * including info.data for a write, done and misc.
328 * For now, no polling interface is provided so you have to use completion
329 * callback.
330 */
331extern int smu_queue_i2c(struct smu_i2c_cmd *cmd);
332
333
334#endif /* __KERNEL__ */
335
336/*
337 * - Userland interface -
338 */
339
340/*
341 * A given instance of the device can be configured for 2 different
342 * things at the moment:
343 *
344 * - sending SMU commands (default at open() time)
345 * - receiving SMU events (not yet implemented)
346 *
347 * Commands are written with write() of a command block. They can be
348 * "driver" commands (for example to switch to event reception mode)
349 * or real SMU commands. They are made of a header followed by command
350 * data if any.
351 *
352 * For SMU commands (not for driver commands), you can then read() back
353 * a reply. The reader will be blocked or not depending on how the device
354 * file is opened. poll() isn't implemented yet. The reply will consist
355 * of a header as well, followed by the reply data if any. You should
356 * always provide a buffer large enough for the maximum reply data, I
357 * recommand one page.
358 *
359 * It is illegal to send SMU commands through a file descriptor configured
360 * for events reception
361 *
362 */
363struct smu_user_cmd_hdr
364{
365 __u32 cmdtype;
366#define SMU_CMDTYPE_SMU 0 /* SMU command */
367#define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */
368
369 __u8 cmd; /* SMU command byte */
370 __u32 data_len; /* Lenght of data following */
371};
372
373struct smu_user_reply_hdr
374{
375 __u32 status; /* Command status */
376 __u32 reply_len; /* Lenght of data follwing */
377};
378
379#endif /* _SMU_H */
diff --git a/include/asm-ppc64/tlbflush.h b/include/asm-ppc64/tlbflush.h
index 45411a67e082..74271d7c1d16 100644
--- a/include/asm-ppc64/tlbflush.h
+++ b/include/asm-ppc64/tlbflush.h
@@ -25,6 +25,7 @@ struct ppc64_tlb_batch {
25 pte_t pte[PPC64_TLB_BATCH_NR]; 25 pte_t pte[PPC64_TLB_BATCH_NR];
26 unsigned long addr[PPC64_TLB_BATCH_NR]; 26 unsigned long addr[PPC64_TLB_BATCH_NR];
27 unsigned long vaddr[PPC64_TLB_BATCH_NR]; 27 unsigned long vaddr[PPC64_TLB_BATCH_NR];
28 unsigned int large;
28}; 29};
29DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); 30DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
30 31
diff --git a/include/asm-ppc64/uaccess.h b/include/asm-ppc64/uaccess.h
index c181a60d868c..132c1276547b 100644
--- a/include/asm-ppc64/uaccess.h
+++ b/include/asm-ppc64/uaccess.h
@@ -164,7 +164,8 @@ do { \
164 164
165#define __get_user_nocheck(x,ptr,size) \ 165#define __get_user_nocheck(x,ptr,size) \
166({ \ 166({ \
167 long __gu_err, __gu_val; \ 167 long __gu_err; \
168 unsigned long __gu_val; \
168 might_sleep(); \ 169 might_sleep(); \
169 __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\ 170 __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\
170 (x) = (__typeof__(*(ptr)))__gu_val; \ 171 (x) = (__typeof__(*(ptr)))__gu_val; \
@@ -173,7 +174,8 @@ do { \
173 174
174#define __get_user_check(x,ptr,size) \ 175#define __get_user_check(x,ptr,size) \
175({ \ 176({ \
176 long __gu_err = -EFAULT, __gu_val = 0; \ 177 long __gu_err = -EFAULT; \
178 unsigned long __gu_val = 0; \
177 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ 179 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
178 might_sleep(); \ 180 might_sleep(); \
179 if (access_ok(VERIFY_READ,__gu_addr,size)) \ 181 if (access_ok(VERIFY_READ,__gu_addr,size)) \
diff --git a/include/asm-s390/futex.h b/include/asm-s390/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-s390/futex.h
+++ b/include/asm-s390/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-s390/sigcontext.h b/include/asm-s390/sigcontext.h
index d57bc0cebdce..803545351dd8 100644
--- a/include/asm-s390/sigcontext.h
+++ b/include/asm-s390/sigcontext.h
@@ -61,7 +61,7 @@ typedef struct
61struct sigcontext 61struct sigcontext
62{ 62{
63 unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS]; 63 unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS];
64 _sigregs *sregs; 64 _sigregs __user *sregs;
65}; 65};
66 66
67 67
diff --git a/include/asm-s390/signal.h b/include/asm-s390/signal.h
index 3d6e11c6c1fd..7084626de215 100644
--- a/include/asm-s390/signal.h
+++ b/include/asm-s390/signal.h
@@ -165,7 +165,7 @@ struct sigaction {
165#endif /* __KERNEL__ */ 165#endif /* __KERNEL__ */
166 166
167typedef struct sigaltstack { 167typedef struct sigaltstack {
168 void *ss_sp; 168 void __user *ss_sp;
169 int ss_flags; 169 int ss_flags;
170 size_t ss_size; 170 size_t ss_size;
171} stack_t; 171} stack_t;
diff --git a/include/asm-sh/futex.h b/include/asm-sh/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-sh/futex.h
+++ b/include/asm-sh/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-sh64/futex.h b/include/asm-sh64/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-sh64/futex.h
+++ b/include/asm-sh64/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-sparc/btfixup.h b/include/asm-sparc/btfixup.h
index b84c96c89581..c2868d0f60b6 100644
--- a/include/asm-sparc/btfixup.h
+++ b/include/asm-sparc/btfixup.h
@@ -49,17 +49,17 @@ extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
49/* Put bottom 13bits into some register variable */ 49/* Put bottom 13bits into some register variable */
50 50
51#define BTFIXUPDEF_SIMM13(__name) \ 51#define BTFIXUPDEF_SIMM13(__name) \
52 extern unsigned int ___sf_##__name(void) __attribute_const__; \ 52 static inline unsigned int ___sf_##__name(void) __attribute_const__; \
53 extern unsigned ___ss_##__name[2]; \ 53 extern unsigned ___ss_##__name[2]; \
54 extern __inline__ unsigned int ___sf_##__name(void) { \ 54 static inline unsigned int ___sf_##__name(void) { \
55 unsigned int ret; \ 55 unsigned int ret; \
56 __asm__ ("or %%g0, ___s_" #__name ", %0" : "=r"(ret)); \ 56 __asm__ ("or %%g0, ___s_" #__name ", %0" : "=r"(ret)); \
57 return ret; \ 57 return ret; \
58 } 58 }
59#define BTFIXUPDEF_SIMM13_INIT(__name,__val) \ 59#define BTFIXUPDEF_SIMM13_INIT(__name,__val) \
60 extern unsigned int ___sf_##__name(void) __attribute_const__; \ 60 static inline unsigned int ___sf_##__name(void) __attribute_const__; \
61 extern unsigned ___ss_##__name[2]; \ 61 extern unsigned ___ss_##__name[2]; \
62 extern __inline__ unsigned int ___sf_##__name(void) { \ 62 static inline unsigned int ___sf_##__name(void) { \
63 unsigned int ret; \ 63 unsigned int ret; \
64 __asm__ ("or %%g0, ___s_" #__name "__btset_" #__val ", %0" : "=r"(ret));\ 64 __asm__ ("or %%g0, ___s_" #__name "__btset_" #__val ", %0" : "=r"(ret));\
65 return ret; \ 65 return ret; \
@@ -71,17 +71,17 @@ extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
71 */ 71 */
72 72
73#define BTFIXUPDEF_HALF(__name) \ 73#define BTFIXUPDEF_HALF(__name) \
74 extern unsigned int ___af_##__name(void) __attribute_const__; \ 74 static inline unsigned int ___af_##__name(void) __attribute_const__; \
75 extern unsigned ___as_##__name[2]; \ 75 extern unsigned ___as_##__name[2]; \
76 extern __inline__ unsigned int ___af_##__name(void) { \ 76 static inline unsigned int ___af_##__name(void) { \
77 unsigned int ret; \ 77 unsigned int ret; \
78 __asm__ ("or %%g0, ___a_" #__name ", %0" : "=r"(ret)); \ 78 __asm__ ("or %%g0, ___a_" #__name ", %0" : "=r"(ret)); \
79 return ret; \ 79 return ret; \
80 } 80 }
81#define BTFIXUPDEF_HALF_INIT(__name,__val) \ 81#define BTFIXUPDEF_HALF_INIT(__name,__val) \
82 extern unsigned int ___af_##__name(void) __attribute_const__; \ 82 static inline unsigned int ___af_##__name(void) __attribute_const__; \
83 extern unsigned ___as_##__name[2]; \ 83 extern unsigned ___as_##__name[2]; \
84 extern __inline__ unsigned int ___af_##__name(void) { \ 84 static inline unsigned int ___af_##__name(void) { \
85 unsigned int ret; \ 85 unsigned int ret; \
86 __asm__ ("or %%g0, ___a_" #__name "__btset_" #__val ", %0" : "=r"(ret));\ 86 __asm__ ("or %%g0, ___a_" #__name "__btset_" #__val ", %0" : "=r"(ret));\
87 return ret; \ 87 return ret; \
@@ -90,17 +90,17 @@ extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);
90/* Put upper 22 bits into some register variable */ 90/* Put upper 22 bits into some register variable */
91 91
92#define BTFIXUPDEF_SETHI(__name) \ 92#define BTFIXUPDEF_SETHI(__name) \
93 extern unsigned int ___hf_##__name(void) __attribute_const__; \ 93 static inline unsigned int ___hf_##__name(void) __attribute_const__; \
94 extern unsigned ___hs_##__name[2]; \ 94 extern unsigned ___hs_##__name[2]; \
95 extern __inline__ unsigned int ___hf_##__name(void) { \ 95 static inline unsigned int ___hf_##__name(void) { \
96 unsigned int ret; \ 96 unsigned int ret; \
97 __asm__ ("sethi %%hi(___h_" #__name "), %0" : "=r"(ret)); \ 97 __asm__ ("sethi %%hi(___h_" #__name "), %0" : "=r"(ret)); \
98 return ret; \ 98 return ret; \
99 } 99 }
100#define BTFIXUPDEF_SETHI_INIT(__name,__val) \ 100#define BTFIXUPDEF_SETHI_INIT(__name,__val) \
101 extern unsigned int ___hf_##__name(void) __attribute_const__; \ 101 static inline unsigned int ___hf_##__name(void) __attribute_const__; \
102 extern unsigned ___hs_##__name[2]; \ 102 extern unsigned ___hs_##__name[2]; \
103 extern __inline__ unsigned int ___hf_##__name(void) { \ 103 static inline unsigned int ___hf_##__name(void) { \
104 unsigned int ret; \ 104 unsigned int ret; \
105 __asm__ ("sethi %%hi(___h_" #__name "__btset_" #__val "), %0" : \ 105 __asm__ ("sethi %%hi(___h_" #__name "__btset_" #__val "), %0" : \
106 "=r"(ret)); \ 106 "=r"(ret)); \
diff --git a/include/asm-sparc/cache.h b/include/asm-sparc/cache.h
index e6316fd7e1a4..a10522cb21b7 100644
--- a/include/asm-sparc/cache.h
+++ b/include/asm-sparc/cache.h
@@ -27,7 +27,7 @@
27 */ 27 */
28 28
29/* First, cache-tag access. */ 29/* First, cache-tag access. */
30extern __inline__ unsigned int get_icache_tag(int setnum, int tagnum) 30static inline unsigned int get_icache_tag(int setnum, int tagnum)
31{ 31{
32 unsigned int vaddr, retval; 32 unsigned int vaddr, retval;
33 33
@@ -38,7 +38,7 @@ extern __inline__ unsigned int get_icache_tag(int setnum, int tagnum)
38 return retval; 38 return retval;
39} 39}
40 40
41extern __inline__ void put_icache_tag(int setnum, int tagnum, unsigned int entry) 41static inline void put_icache_tag(int setnum, int tagnum, unsigned int entry)
42{ 42{
43 unsigned int vaddr; 43 unsigned int vaddr;
44 44
@@ -51,7 +51,7 @@ extern __inline__ void put_icache_tag(int setnum, int tagnum, unsigned int entry
51/* Second cache-data access. The data is returned two-32bit quantities 51/* Second cache-data access. The data is returned two-32bit quantities
52 * at a time. 52 * at a time.
53 */ 53 */
54extern __inline__ void get_icache_data(int setnum, int tagnum, int subblock, 54static inline void get_icache_data(int setnum, int tagnum, int subblock,
55 unsigned int *data) 55 unsigned int *data)
56{ 56{
57 unsigned int value1, value2, vaddr; 57 unsigned int value1, value2, vaddr;
@@ -67,7 +67,7 @@ extern __inline__ void get_icache_data(int setnum, int tagnum, int subblock,
67 data[0] = value1; data[1] = value2; 67 data[0] = value1; data[1] = value2;
68} 68}
69 69
70extern __inline__ void put_icache_data(int setnum, int tagnum, int subblock, 70static inline void put_icache_data(int setnum, int tagnum, int subblock,
71 unsigned int *data) 71 unsigned int *data)
72{ 72{
73 unsigned int value1, value2, vaddr; 73 unsigned int value1, value2, vaddr;
@@ -92,35 +92,35 @@ extern __inline__ void put_icache_data(int setnum, int tagnum, int subblock,
92 */ 92 */
93 93
94/* Flushes which clear out both the on-chip and external caches */ 94/* Flushes which clear out both the on-chip and external caches */
95extern __inline__ void flush_ei_page(unsigned int addr) 95static inline void flush_ei_page(unsigned int addr)
96{ 96{
97 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 97 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
98 "r" (addr), "i" (ASI_M_FLUSH_PAGE) : 98 "r" (addr), "i" (ASI_M_FLUSH_PAGE) :
99 "memory"); 99 "memory");
100} 100}
101 101
102extern __inline__ void flush_ei_seg(unsigned int addr) 102static inline void flush_ei_seg(unsigned int addr)
103{ 103{
104 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 104 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
105 "r" (addr), "i" (ASI_M_FLUSH_SEG) : 105 "r" (addr), "i" (ASI_M_FLUSH_SEG) :
106 "memory"); 106 "memory");
107} 107}
108 108
109extern __inline__ void flush_ei_region(unsigned int addr) 109static inline void flush_ei_region(unsigned int addr)
110{ 110{
111 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 111 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
112 "r" (addr), "i" (ASI_M_FLUSH_REGION) : 112 "r" (addr), "i" (ASI_M_FLUSH_REGION) :
113 "memory"); 113 "memory");
114} 114}
115 115
116extern __inline__ void flush_ei_ctx(unsigned int addr) 116static inline void flush_ei_ctx(unsigned int addr)
117{ 117{
118 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 118 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
119 "r" (addr), "i" (ASI_M_FLUSH_CTX) : 119 "r" (addr), "i" (ASI_M_FLUSH_CTX) :
120 "memory"); 120 "memory");
121} 121}
122 122
123extern __inline__ void flush_ei_user(unsigned int addr) 123static inline void flush_ei_user(unsigned int addr)
124{ 124{
125 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 125 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
126 "r" (addr), "i" (ASI_M_FLUSH_USER) : 126 "r" (addr), "i" (ASI_M_FLUSH_USER) :
diff --git a/include/asm-sparc/cypress.h b/include/asm-sparc/cypress.h
index fc92fc839c3f..99599533efbc 100644
--- a/include/asm-sparc/cypress.h
+++ b/include/asm-sparc/cypress.h
@@ -48,25 +48,25 @@
48#define CYPRESS_NFAULT 0x00000002 48#define CYPRESS_NFAULT 0x00000002
49#define CYPRESS_MENABLE 0x00000001 49#define CYPRESS_MENABLE 0x00000001
50 50
51extern __inline__ void cypress_flush_page(unsigned long page) 51static inline void cypress_flush_page(unsigned long page)
52{ 52{
53 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 53 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
54 "r" (page), "i" (ASI_M_FLUSH_PAGE)); 54 "r" (page), "i" (ASI_M_FLUSH_PAGE));
55} 55}
56 56
57extern __inline__ void cypress_flush_segment(unsigned long addr) 57static inline void cypress_flush_segment(unsigned long addr)
58{ 58{
59 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 59 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
60 "r" (addr), "i" (ASI_M_FLUSH_SEG)); 60 "r" (addr), "i" (ASI_M_FLUSH_SEG));
61} 61}
62 62
63extern __inline__ void cypress_flush_region(unsigned long addr) 63static inline void cypress_flush_region(unsigned long addr)
64{ 64{
65 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : 65 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
66 "r" (addr), "i" (ASI_M_FLUSH_REGION)); 66 "r" (addr), "i" (ASI_M_FLUSH_REGION));
67} 67}
68 68
69extern __inline__ void cypress_flush_context(void) 69static inline void cypress_flush_context(void)
70{ 70{
71 __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t" : : 71 __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t" : :
72 "i" (ASI_M_FLUSH_CTX)); 72 "i" (ASI_M_FLUSH_CTX));
diff --git a/include/asm-sparc/delay.h b/include/asm-sparc/delay.h
index 6edf2cbb246b..7ec8e9f7ad4f 100644
--- a/include/asm-sparc/delay.h
+++ b/include/asm-sparc/delay.h
@@ -10,7 +10,7 @@
10#include <linux/config.h> 10#include <linux/config.h>
11#include <asm/cpudata.h> 11#include <asm/cpudata.h>
12 12
13extern __inline__ void __delay(unsigned long loops) 13static inline void __delay(unsigned long loops)
14{ 14{
15 __asm__ __volatile__("cmp %0, 0\n\t" 15 __asm__ __volatile__("cmp %0, 0\n\t"
16 "1: bne 1b\n\t" 16 "1: bne 1b\n\t"
diff --git a/include/asm-sparc/dma.h b/include/asm-sparc/dma.h
index 07e6368a2521..8ec206aa5f2e 100644
--- a/include/asm-sparc/dma.h
+++ b/include/asm-sparc/dma.h
@@ -198,7 +198,7 @@ extern void dvma_init(struct sbus_bus *);
198/* Pause until counter runs out or BIT isn't set in the DMA condition 198/* Pause until counter runs out or BIT isn't set in the DMA condition
199 * register. 199 * register.
200 */ 200 */
201extern __inline__ void sparc_dma_pause(struct sparc_dma_registers *regs, 201static inline void sparc_dma_pause(struct sparc_dma_registers *regs,
202 unsigned long bit) 202 unsigned long bit)
203{ 203{
204 int ctr = 50000; /* Let's find some bugs ;) */ 204 int ctr = 50000; /* Let's find some bugs ;) */
diff --git a/include/asm-sparc/futex.h b/include/asm-sparc/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-sparc/futex.h
+++ b/include/asm-sparc/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-sparc/iommu.h b/include/asm-sparc/iommu.h
index 8171362d56b9..70c589c05a10 100644
--- a/include/asm-sparc/iommu.h
+++ b/include/asm-sparc/iommu.h
@@ -108,12 +108,12 @@ struct iommu_struct {
108 struct bit_map usemap; 108 struct bit_map usemap;
109}; 109};
110 110
111extern __inline__ void iommu_invalidate(struct iommu_regs *regs) 111static inline void iommu_invalidate(struct iommu_regs *regs)
112{ 112{
113 regs->tlbflush = 0; 113 regs->tlbflush = 0;
114} 114}
115 115
116extern __inline__ void iommu_invalidate_page(struct iommu_regs *regs, unsigned long ba) 116static inline void iommu_invalidate_page(struct iommu_regs *regs, unsigned long ba)
117{ 117{
118 regs->pageflush = (ba & PAGE_MASK); 118 regs->pageflush = (ba & PAGE_MASK);
119} 119}
diff --git a/include/asm-sparc/kdebug.h b/include/asm-sparc/kdebug.h
index 3ea4916635ee..fba92485fdba 100644
--- a/include/asm-sparc/kdebug.h
+++ b/include/asm-sparc/kdebug.h
@@ -46,7 +46,7 @@ struct kernel_debug {
46extern struct kernel_debug *linux_dbvec; 46extern struct kernel_debug *linux_dbvec;
47 47
48/* Use this macro in C-code to enter the debugger. */ 48/* Use this macro in C-code to enter the debugger. */
49extern __inline__ void sp_enter_debugger(void) 49static inline void sp_enter_debugger(void)
50{ 50{
51 __asm__ __volatile__("jmpl %0, %%o7\n\t" 51 __asm__ __volatile__("jmpl %0, %%o7\n\t"
52 "nop\n\t" : : 52 "nop\n\t" : :
diff --git a/include/asm-sparc/mbus.h b/include/asm-sparc/mbus.h
index 5f2749015342..ecacdf4075d7 100644
--- a/include/asm-sparc/mbus.h
+++ b/include/asm-sparc/mbus.h
@@ -83,7 +83,7 @@ extern unsigned int hwbug_bitmask;
83 */ 83 */
84#define TBR_ID_SHIFT 20 84#define TBR_ID_SHIFT 20
85 85
86extern __inline__ int get_cpuid(void) 86static inline int get_cpuid(void)
87{ 87{
88 register int retval; 88 register int retval;
89 __asm__ __volatile__("rd %%tbr, %0\n\t" 89 __asm__ __volatile__("rd %%tbr, %0\n\t"
@@ -93,7 +93,7 @@ extern __inline__ int get_cpuid(void)
93 return (retval & 3); 93 return (retval & 3);
94} 94}
95 95
96extern __inline__ int get_modid(void) 96static inline int get_modid(void)
97{ 97{
98 return (get_cpuid() | 0x8); 98 return (get_cpuid() | 0x8);
99} 99}
diff --git a/include/asm-sparc/msi.h b/include/asm-sparc/msi.h
index b69543dd3b46..ff72cbd946a4 100644
--- a/include/asm-sparc/msi.h
+++ b/include/asm-sparc/msi.h
@@ -19,7 +19,7 @@
19#define MSI_ASYNC_MODE 0x80000000 /* Operate the MSI asynchronously */ 19#define MSI_ASYNC_MODE 0x80000000 /* Operate the MSI asynchronously */
20 20
21 21
22extern __inline__ void msi_set_sync(void) 22static inline void msi_set_sync(void)
23{ 23{
24 __asm__ __volatile__ ("lda [%0] %1, %%g3\n\t" 24 __asm__ __volatile__ ("lda [%0] %1, %%g3\n\t"
25 "andn %%g3, %2, %%g3\n\t" 25 "andn %%g3, %2, %%g3\n\t"
diff --git a/include/asm-sparc/mxcc.h b/include/asm-sparc/mxcc.h
index 60ef9d6fe7bc..128fe9708135 100644
--- a/include/asm-sparc/mxcc.h
+++ b/include/asm-sparc/mxcc.h
@@ -85,7 +85,7 @@
85 85
86#ifndef __ASSEMBLY__ 86#ifndef __ASSEMBLY__
87 87
88extern __inline__ void mxcc_set_stream_src(unsigned long *paddr) 88static inline void mxcc_set_stream_src(unsigned long *paddr)
89{ 89{
90 unsigned long data0 = paddr[0]; 90 unsigned long data0 = paddr[0];
91 unsigned long data1 = paddr[1]; 91 unsigned long data1 = paddr[1];
@@ -98,7 +98,7 @@ extern __inline__ void mxcc_set_stream_src(unsigned long *paddr)
98 "i" (ASI_M_MXCC) : "g2", "g3"); 98 "i" (ASI_M_MXCC) : "g2", "g3");
99} 99}
100 100
101extern __inline__ void mxcc_set_stream_dst(unsigned long *paddr) 101static inline void mxcc_set_stream_dst(unsigned long *paddr)
102{ 102{
103 unsigned long data0 = paddr[0]; 103 unsigned long data0 = paddr[0];
104 unsigned long data1 = paddr[1]; 104 unsigned long data1 = paddr[1];
@@ -111,7 +111,7 @@ extern __inline__ void mxcc_set_stream_dst(unsigned long *paddr)
111 "i" (ASI_M_MXCC) : "g2", "g3"); 111 "i" (ASI_M_MXCC) : "g2", "g3");
112} 112}
113 113
114extern __inline__ unsigned long mxcc_get_creg(void) 114static inline unsigned long mxcc_get_creg(void)
115{ 115{
116 unsigned long mxcc_control; 116 unsigned long mxcc_control;
117 117
@@ -125,7 +125,7 @@ extern __inline__ unsigned long mxcc_get_creg(void)
125 return mxcc_control; 125 return mxcc_control;
126} 126}
127 127
128extern __inline__ void mxcc_set_creg(unsigned long mxcc_control) 128static inline void mxcc_set_creg(unsigned long mxcc_control)
129{ 129{
130 __asm__ __volatile__("sta %0, [%1] %2\n\t" : : 130 __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
131 "r" (mxcc_control), "r" (MXCC_CREG), 131 "r" (mxcc_control), "r" (MXCC_CREG),
diff --git a/include/asm-sparc/obio.h b/include/asm-sparc/obio.h
index 62e1d77965f3..47854a2a12cf 100644
--- a/include/asm-sparc/obio.h
+++ b/include/asm-sparc/obio.h
@@ -98,7 +98,7 @@
98 98
99#ifndef __ASSEMBLY__ 99#ifndef __ASSEMBLY__
100 100
101extern __inline__ int bw_get_intr_mask(int sbus_level) 101static inline int bw_get_intr_mask(int sbus_level)
102{ 102{
103 int mask; 103 int mask;
104 104
@@ -109,7 +109,7 @@ extern __inline__ int bw_get_intr_mask(int sbus_level)
109 return mask; 109 return mask;
110} 110}
111 111
112extern __inline__ void bw_clear_intr_mask(int sbus_level, int mask) 112static inline void bw_clear_intr_mask(int sbus_level, int mask)
113{ 113{
114 __asm__ __volatile__ ("stha %0, [%1] %2" : : 114 __asm__ __volatile__ ("stha %0, [%1] %2" : :
115 "r" (mask), 115 "r" (mask),
@@ -117,7 +117,7 @@ extern __inline__ void bw_clear_intr_mask(int sbus_level, int mask)
117 "i" (ASI_M_CTL)); 117 "i" (ASI_M_CTL));
118} 118}
119 119
120extern __inline__ unsigned bw_get_prof_limit(int cpu) 120static inline unsigned bw_get_prof_limit(int cpu)
121{ 121{
122 unsigned limit; 122 unsigned limit;
123 123
@@ -128,7 +128,7 @@ extern __inline__ unsigned bw_get_prof_limit(int cpu)
128 return limit; 128 return limit;
129} 129}
130 130
131extern __inline__ void bw_set_prof_limit(int cpu, unsigned limit) 131static inline void bw_set_prof_limit(int cpu, unsigned limit)
132{ 132{
133 __asm__ __volatile__ ("sta %0, [%1] %2" : : 133 __asm__ __volatile__ ("sta %0, [%1] %2" : :
134 "r" (limit), 134 "r" (limit),
@@ -136,7 +136,7 @@ extern __inline__ void bw_set_prof_limit(int cpu, unsigned limit)
136 "i" (ASI_M_CTL)); 136 "i" (ASI_M_CTL));
137} 137}
138 138
139extern __inline__ unsigned bw_get_ctrl(int cpu) 139static inline unsigned bw_get_ctrl(int cpu)
140{ 140{
141 unsigned ctrl; 141 unsigned ctrl;
142 142
@@ -147,7 +147,7 @@ extern __inline__ unsigned bw_get_ctrl(int cpu)
147 return ctrl; 147 return ctrl;
148} 148}
149 149
150extern __inline__ void bw_set_ctrl(int cpu, unsigned ctrl) 150static inline void bw_set_ctrl(int cpu, unsigned ctrl)
151{ 151{
152 __asm__ __volatile__ ("sta %0, [%1] %2" : : 152 __asm__ __volatile__ ("sta %0, [%1] %2" : :
153 "r" (ctrl), 153 "r" (ctrl),
@@ -157,7 +157,7 @@ extern __inline__ void bw_set_ctrl(int cpu, unsigned ctrl)
157 157
158extern unsigned char cpu_leds[32]; 158extern unsigned char cpu_leds[32];
159 159
160extern __inline__ void show_leds(int cpuid) 160static inline void show_leds(int cpuid)
161{ 161{
162 cpuid &= 0x1e; 162 cpuid &= 0x1e;
163 __asm__ __volatile__ ("stba %0, [%1] %2" : : 163 __asm__ __volatile__ ("stba %0, [%1] %2" : :
@@ -166,7 +166,7 @@ extern __inline__ void show_leds(int cpuid)
166 "i" (ASI_M_CTL)); 166 "i" (ASI_M_CTL));
167} 167}
168 168
169extern __inline__ unsigned cc_get_ipen(void) 169static inline unsigned cc_get_ipen(void)
170{ 170{
171 unsigned pending; 171 unsigned pending;
172 172
@@ -177,7 +177,7 @@ extern __inline__ unsigned cc_get_ipen(void)
177 return pending; 177 return pending;
178} 178}
179 179
180extern __inline__ void cc_set_iclr(unsigned clear) 180static inline void cc_set_iclr(unsigned clear)
181{ 181{
182 __asm__ __volatile__ ("stha %0, [%1] %2" : : 182 __asm__ __volatile__ ("stha %0, [%1] %2" : :
183 "r" (clear), 183 "r" (clear),
@@ -185,7 +185,7 @@ extern __inline__ void cc_set_iclr(unsigned clear)
185 "i" (ASI_M_MXCC)); 185 "i" (ASI_M_MXCC));
186} 186}
187 187
188extern __inline__ unsigned cc_get_imsk(void) 188static inline unsigned cc_get_imsk(void)
189{ 189{
190 unsigned mask; 190 unsigned mask;
191 191
@@ -196,7 +196,7 @@ extern __inline__ unsigned cc_get_imsk(void)
196 return mask; 196 return mask;
197} 197}
198 198
199extern __inline__ void cc_set_imsk(unsigned mask) 199static inline void cc_set_imsk(unsigned mask)
200{ 200{
201 __asm__ __volatile__ ("stha %0, [%1] %2" : : 201 __asm__ __volatile__ ("stha %0, [%1] %2" : :
202 "r" (mask), 202 "r" (mask),
@@ -204,7 +204,7 @@ extern __inline__ void cc_set_imsk(unsigned mask)
204 "i" (ASI_M_MXCC)); 204 "i" (ASI_M_MXCC));
205} 205}
206 206
207extern __inline__ unsigned cc_get_imsk_other(int cpuid) 207static inline unsigned cc_get_imsk_other(int cpuid)
208{ 208{
209 unsigned mask; 209 unsigned mask;
210 210
@@ -215,7 +215,7 @@ extern __inline__ unsigned cc_get_imsk_other(int cpuid)
215 return mask; 215 return mask;
216} 216}
217 217
218extern __inline__ void cc_set_imsk_other(int cpuid, unsigned mask) 218static inline void cc_set_imsk_other(int cpuid, unsigned mask)
219{ 219{
220 __asm__ __volatile__ ("stha %0, [%1] %2" : : 220 __asm__ __volatile__ ("stha %0, [%1] %2" : :
221 "r" (mask), 221 "r" (mask),
@@ -223,7 +223,7 @@ extern __inline__ void cc_set_imsk_other(int cpuid, unsigned mask)
223 "i" (ASI_M_CTL)); 223 "i" (ASI_M_CTL));
224} 224}
225 225
226extern __inline__ void cc_set_igen(unsigned gen) 226static inline void cc_set_igen(unsigned gen)
227{ 227{
228 __asm__ __volatile__ ("sta %0, [%1] %2" : : 228 __asm__ __volatile__ ("sta %0, [%1] %2" : :
229 "r" (gen), 229 "r" (gen),
@@ -239,7 +239,7 @@ extern __inline__ void cc_set_igen(unsigned gen)
239#define IGEN_MESSAGE(bcast, devid, sid, levels) \ 239#define IGEN_MESSAGE(bcast, devid, sid, levels) \
240 (((bcast) << 31) | ((devid) << 23) | ((sid) << 15) | (levels)) 240 (((bcast) << 31) | ((devid) << 23) | ((sid) << 15) | (levels))
241 241
242extern __inline__ void sun4d_send_ipi(int cpu, int level) 242static inline void sun4d_send_ipi(int cpu, int level)
243{ 243{
244 cc_set_igen(IGEN_MESSAGE(0, cpu << 3, 6 + ((level >> 1) & 7), 1 << (level - 1))); 244 cc_set_igen(IGEN_MESSAGE(0, cpu << 3, 6 + ((level >> 1) & 7), 1 << (level - 1)));
245} 245}
diff --git a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h
index 97052baf90c1..38644742f011 100644
--- a/include/asm-sparc/pci.h
+++ b/include/asm-sparc/pci.h
@@ -15,12 +15,12 @@
15 15
16#define PCI_IRQ_NONE 0xffffffff 16#define PCI_IRQ_NONE 0xffffffff
17 17
18extern inline void pcibios_set_master(struct pci_dev *dev) 18static inline void pcibios_set_master(struct pci_dev *dev)
19{ 19{
20 /* No special bus mastering setup handling */ 20 /* No special bus mastering setup handling */
21} 21}
22 22
23extern inline void pcibios_penalize_isa_irq(int irq, int active) 23static inline void pcibios_penalize_isa_irq(int irq, int active)
24{ 24{
25 /* We don't do dynamic PCI IRQ allocation */ 25 /* We don't do dynamic PCI IRQ allocation */
26} 26}
@@ -137,7 +137,7 @@ extern void pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist
137 * only drive the low 24-bits during PCI bus mastering, then 137 * only drive the low 24-bits during PCI bus mastering, then
138 * you would pass 0x00ffffff as the mask to this function. 138 * you would pass 0x00ffffff as the mask to this function.
139 */ 139 */
140extern inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask) 140static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
141{ 141{
142 return 1; 142 return 1;
143} 143}
diff --git a/include/asm-sparc/pgtable.h b/include/asm-sparc/pgtable.h
index 8f4f6a959651..a14e98677500 100644
--- a/include/asm-sparc/pgtable.h
+++ b/include/asm-sparc/pgtable.h
@@ -82,6 +82,8 @@ extern unsigned long page_kernel;
82/* Top-level page directory */ 82/* Top-level page directory */
83extern pgd_t swapper_pg_dir[1024]; 83extern pgd_t swapper_pg_dir[1024];
84 84
85extern void paging_init(void);
86
85/* Page table for 0-4MB for everybody, on the Sparc this 87/* Page table for 0-4MB for everybody, on the Sparc this
86 * holds the same as on the i386. 88 * holds the same as on the i386.
87 */ 89 */
@@ -152,7 +154,7 @@ BTFIXUPDEF_CALL_CONST(int, pte_present, pte_t)
152BTFIXUPDEF_CALL(void, pte_clear, pte_t *) 154BTFIXUPDEF_CALL(void, pte_clear, pte_t *)
153BTFIXUPDEF_CALL(int, pte_read, pte_t) 155BTFIXUPDEF_CALL(int, pte_read, pte_t)
154 156
155extern __inline__ int pte_none(pte_t pte) 157static inline int pte_none(pte_t pte)
156{ 158{
157 return !(pte_val(pte) & ~BTFIXUP_SETHI(none_mask)); 159 return !(pte_val(pte) & ~BTFIXUP_SETHI(none_mask));
158} 160}
@@ -165,7 +167,7 @@ BTFIXUPDEF_CALL_CONST(int, pmd_bad, pmd_t)
165BTFIXUPDEF_CALL_CONST(int, pmd_present, pmd_t) 167BTFIXUPDEF_CALL_CONST(int, pmd_present, pmd_t)
166BTFIXUPDEF_CALL(void, pmd_clear, pmd_t *) 168BTFIXUPDEF_CALL(void, pmd_clear, pmd_t *)
167 169
168extern __inline__ int pmd_none(pmd_t pmd) 170static inline int pmd_none(pmd_t pmd)
169{ 171{
170 return !(pmd_val(pmd) & ~BTFIXUP_SETHI(none_mask)); 172 return !(pmd_val(pmd) & ~BTFIXUP_SETHI(none_mask));
171} 173}
@@ -192,20 +194,20 @@ BTFIXUPDEF_HALF(pte_writei)
192BTFIXUPDEF_HALF(pte_dirtyi) 194BTFIXUPDEF_HALF(pte_dirtyi)
193BTFIXUPDEF_HALF(pte_youngi) 195BTFIXUPDEF_HALF(pte_youngi)
194 196
195extern int pte_write(pte_t pte) __attribute_const__; 197static int pte_write(pte_t pte) __attribute_const__;
196extern __inline__ int pte_write(pte_t pte) 198static inline int pte_write(pte_t pte)
197{ 199{
198 return pte_val(pte) & BTFIXUP_HALF(pte_writei); 200 return pte_val(pte) & BTFIXUP_HALF(pte_writei);
199} 201}
200 202
201extern int pte_dirty(pte_t pte) __attribute_const__; 203static int pte_dirty(pte_t pte) __attribute_const__;
202extern __inline__ int pte_dirty(pte_t pte) 204static inline int pte_dirty(pte_t pte)
203{ 205{
204 return pte_val(pte) & BTFIXUP_HALF(pte_dirtyi); 206 return pte_val(pte) & BTFIXUP_HALF(pte_dirtyi);
205} 207}
206 208
207extern int pte_young(pte_t pte) __attribute_const__; 209static int pte_young(pte_t pte) __attribute_const__;
208extern __inline__ int pte_young(pte_t pte) 210static inline int pte_young(pte_t pte)
209{ 211{
210 return pte_val(pte) & BTFIXUP_HALF(pte_youngi); 212 return pte_val(pte) & BTFIXUP_HALF(pte_youngi);
211} 213}
@@ -215,8 +217,8 @@ extern __inline__ int pte_young(pte_t pte)
215 */ 217 */
216BTFIXUPDEF_HALF(pte_filei) 218BTFIXUPDEF_HALF(pte_filei)
217 219
218extern int pte_file(pte_t pte) __attribute_const__; 220static int pte_file(pte_t pte) __attribute_const__;
219extern __inline__ int pte_file(pte_t pte) 221static inline int pte_file(pte_t pte)
220{ 222{
221 return pte_val(pte) & BTFIXUP_HALF(pte_filei); 223 return pte_val(pte) & BTFIXUP_HALF(pte_filei);
222} 224}
@@ -227,20 +229,20 @@ BTFIXUPDEF_HALF(pte_wrprotecti)
227BTFIXUPDEF_HALF(pte_mkcleani) 229BTFIXUPDEF_HALF(pte_mkcleani)
228BTFIXUPDEF_HALF(pte_mkoldi) 230BTFIXUPDEF_HALF(pte_mkoldi)
229 231
230extern pte_t pte_wrprotect(pte_t pte) __attribute_const__; 232static pte_t pte_wrprotect(pte_t pte) __attribute_const__;
231extern __inline__ pte_t pte_wrprotect(pte_t pte) 233static inline pte_t pte_wrprotect(pte_t pte)
232{ 234{
233 return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_wrprotecti)); 235 return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_wrprotecti));
234} 236}
235 237
236extern pte_t pte_mkclean(pte_t pte) __attribute_const__; 238static pte_t pte_mkclean(pte_t pte) __attribute_const__;
237extern __inline__ pte_t pte_mkclean(pte_t pte) 239static inline pte_t pte_mkclean(pte_t pte)
238{ 240{
239 return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkcleani)); 241 return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkcleani));
240} 242}
241 243
242extern pte_t pte_mkold(pte_t pte) __attribute_const__; 244static pte_t pte_mkold(pte_t pte) __attribute_const__;
243extern __inline__ pte_t pte_mkold(pte_t pte) 245static inline pte_t pte_mkold(pte_t pte)
244{ 246{
245 return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkoldi)); 247 return __pte(pte_val(pte) & ~BTFIXUP_HALF(pte_mkoldi));
246} 248}
@@ -276,8 +278,8 @@ BTFIXUPDEF_CALL_CONST(pte_t, mk_pte_io, unsigned long, pgprot_t, int)
276 278
277BTFIXUPDEF_INT(pte_modify_mask) 279BTFIXUPDEF_INT(pte_modify_mask)
278 280
279extern pte_t pte_modify(pte_t pte, pgprot_t newprot) __attribute_const__; 281static pte_t pte_modify(pte_t pte, pgprot_t newprot) __attribute_const__;
280extern __inline__ pte_t pte_modify(pte_t pte, pgprot_t newprot) 282static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
281{ 283{
282 return __pte((pte_val(pte) & BTFIXUP_INT(pte_modify_mask)) | 284 return __pte((pte_val(pte) & BTFIXUP_INT(pte_modify_mask)) |
283 pgprot_val(newprot)); 285 pgprot_val(newprot));
@@ -384,13 +386,13 @@ extern struct ctx_list ctx_used; /* Head of used contexts list */
384 386
385#define NO_CONTEXT -1 387#define NO_CONTEXT -1
386 388
387extern __inline__ void remove_from_ctx_list(struct ctx_list *entry) 389static inline void remove_from_ctx_list(struct ctx_list *entry)
388{ 390{
389 entry->next->prev = entry->prev; 391 entry->next->prev = entry->prev;
390 entry->prev->next = entry->next; 392 entry->prev->next = entry->next;
391} 393}
392 394
393extern __inline__ void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry) 395static inline void add_to_ctx_list(struct ctx_list *head, struct ctx_list *entry)
394{ 396{
395 entry->next = head; 397 entry->next = head;
396 (entry->prev = head->prev)->next = entry; 398 (entry->prev = head->prev)->next = entry;
@@ -399,7 +401,7 @@ extern __inline__ void add_to_ctx_list(struct ctx_list *head, struct ctx_list *e
399#define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry) 401#define add_to_free_ctxlist(entry) add_to_ctx_list(&ctx_free, entry)
400#define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry) 402#define add_to_used_ctxlist(entry) add_to_ctx_list(&ctx_used, entry)
401 403
402extern __inline__ unsigned long 404static inline unsigned long
403__get_phys (unsigned long addr) 405__get_phys (unsigned long addr)
404{ 406{
405 switch (sparc_cpu_model){ 407 switch (sparc_cpu_model){
@@ -414,7 +416,7 @@ __get_phys (unsigned long addr)
414 } 416 }
415} 417}
416 418
417extern __inline__ int 419static inline int
418__get_iospace (unsigned long addr) 420__get_iospace (unsigned long addr)
419{ 421{
420 switch (sparc_cpu_model){ 422 switch (sparc_cpu_model){
diff --git a/include/asm-sparc/pgtsrmmu.h b/include/asm-sparc/pgtsrmmu.h
index ee3b9d93187c..edeb9811e728 100644
--- a/include/asm-sparc/pgtsrmmu.h
+++ b/include/asm-sparc/pgtsrmmu.h
@@ -148,7 +148,7 @@ extern void *srmmu_nocache_pool;
148#define __nocache_fix(VADDR) __va(__nocache_pa(VADDR)) 148#define __nocache_fix(VADDR) __va(__nocache_pa(VADDR))
149 149
150/* Accessing the MMU control register. */ 150/* Accessing the MMU control register. */
151extern __inline__ unsigned int srmmu_get_mmureg(void) 151static inline unsigned int srmmu_get_mmureg(void)
152{ 152{
153 unsigned int retval; 153 unsigned int retval;
154 __asm__ __volatile__("lda [%%g0] %1, %0\n\t" : 154 __asm__ __volatile__("lda [%%g0] %1, %0\n\t" :
@@ -157,14 +157,14 @@ extern __inline__ unsigned int srmmu_get_mmureg(void)
157 return retval; 157 return retval;
158} 158}
159 159
160extern __inline__ void srmmu_set_mmureg(unsigned long regval) 160static inline void srmmu_set_mmureg(unsigned long regval)
161{ 161{
162 __asm__ __volatile__("sta %0, [%%g0] %1\n\t" : : 162 __asm__ __volatile__("sta %0, [%%g0] %1\n\t" : :
163 "r" (regval), "i" (ASI_M_MMUREGS) : "memory"); 163 "r" (regval), "i" (ASI_M_MMUREGS) : "memory");
164 164
165} 165}
166 166
167extern __inline__ void srmmu_set_ctable_ptr(unsigned long paddr) 167static inline void srmmu_set_ctable_ptr(unsigned long paddr)
168{ 168{
169 paddr = ((paddr >> 4) & SRMMU_CTX_PMASK); 169 paddr = ((paddr >> 4) & SRMMU_CTX_PMASK);
170 __asm__ __volatile__("sta %0, [%1] %2\n\t" : : 170 __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
@@ -173,7 +173,7 @@ extern __inline__ void srmmu_set_ctable_ptr(unsigned long paddr)
173 "memory"); 173 "memory");
174} 174}
175 175
176extern __inline__ unsigned long srmmu_get_ctable_ptr(void) 176static inline unsigned long srmmu_get_ctable_ptr(void)
177{ 177{
178 unsigned int retval; 178 unsigned int retval;
179 179
@@ -184,14 +184,14 @@ extern __inline__ unsigned long srmmu_get_ctable_ptr(void)
184 return (retval & SRMMU_CTX_PMASK) << 4; 184 return (retval & SRMMU_CTX_PMASK) << 4;
185} 185}
186 186
187extern __inline__ void srmmu_set_context(int context) 187static inline void srmmu_set_context(int context)
188{ 188{
189 __asm__ __volatile__("sta %0, [%1] %2\n\t" : : 189 __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
190 "r" (context), "r" (SRMMU_CTX_REG), 190 "r" (context), "r" (SRMMU_CTX_REG),
191 "i" (ASI_M_MMUREGS) : "memory"); 191 "i" (ASI_M_MMUREGS) : "memory");
192} 192}
193 193
194extern __inline__ int srmmu_get_context(void) 194static inline int srmmu_get_context(void)
195{ 195{
196 register int retval; 196 register int retval;
197 __asm__ __volatile__("lda [%1] %2, %0\n\t" : 197 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
@@ -201,7 +201,7 @@ extern __inline__ int srmmu_get_context(void)
201 return retval; 201 return retval;
202} 202}
203 203
204extern __inline__ unsigned int srmmu_get_fstatus(void) 204static inline unsigned int srmmu_get_fstatus(void)
205{ 205{
206 unsigned int retval; 206 unsigned int retval;
207 207
@@ -211,7 +211,7 @@ extern __inline__ unsigned int srmmu_get_fstatus(void)
211 return retval; 211 return retval;
212} 212}
213 213
214extern __inline__ unsigned int srmmu_get_faddr(void) 214static inline unsigned int srmmu_get_faddr(void)
215{ 215{
216 unsigned int retval; 216 unsigned int retval;
217 217
@@ -222,7 +222,7 @@ extern __inline__ unsigned int srmmu_get_faddr(void)
222} 222}
223 223
224/* This is guaranteed on all SRMMU's. */ 224/* This is guaranteed on all SRMMU's. */
225extern __inline__ void srmmu_flush_whole_tlb(void) 225static inline void srmmu_flush_whole_tlb(void)
226{ 226{
227 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": : 227 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
228 "r" (0x400), /* Flush entire TLB!! */ 228 "r" (0x400), /* Flush entire TLB!! */
@@ -231,7 +231,7 @@ extern __inline__ void srmmu_flush_whole_tlb(void)
231} 231}
232 232
233/* These flush types are not available on all chips... */ 233/* These flush types are not available on all chips... */
234extern __inline__ void srmmu_flush_tlb_ctx(void) 234static inline void srmmu_flush_tlb_ctx(void)
235{ 235{
236 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": : 236 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
237 "r" (0x300), /* Flush TLB ctx.. */ 237 "r" (0x300), /* Flush TLB ctx.. */
@@ -239,7 +239,7 @@ extern __inline__ void srmmu_flush_tlb_ctx(void)
239 239
240} 240}
241 241
242extern __inline__ void srmmu_flush_tlb_region(unsigned long addr) 242static inline void srmmu_flush_tlb_region(unsigned long addr)
243{ 243{
244 addr &= SRMMU_PGDIR_MASK; 244 addr &= SRMMU_PGDIR_MASK;
245 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": : 245 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
@@ -249,7 +249,7 @@ extern __inline__ void srmmu_flush_tlb_region(unsigned long addr)
249} 249}
250 250
251 251
252extern __inline__ void srmmu_flush_tlb_segment(unsigned long addr) 252static inline void srmmu_flush_tlb_segment(unsigned long addr)
253{ 253{
254 addr &= SRMMU_REAL_PMD_MASK; 254 addr &= SRMMU_REAL_PMD_MASK;
255 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": : 255 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
@@ -258,7 +258,7 @@ extern __inline__ void srmmu_flush_tlb_segment(unsigned long addr)
258 258
259} 259}
260 260
261extern __inline__ void srmmu_flush_tlb_page(unsigned long page) 261static inline void srmmu_flush_tlb_page(unsigned long page)
262{ 262{
263 page &= PAGE_MASK; 263 page &= PAGE_MASK;
264 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": : 264 __asm__ __volatile__("sta %%g0, [%0] %1\n\t": :
@@ -267,7 +267,7 @@ extern __inline__ void srmmu_flush_tlb_page(unsigned long page)
267 267
268} 268}
269 269
270extern __inline__ unsigned long srmmu_hwprobe(unsigned long vaddr) 270static inline unsigned long srmmu_hwprobe(unsigned long vaddr)
271{ 271{
272 unsigned long retval; 272 unsigned long retval;
273 273
@@ -279,7 +279,7 @@ extern __inline__ unsigned long srmmu_hwprobe(unsigned long vaddr)
279 return retval; 279 return retval;
280} 280}
281 281
282extern __inline__ int 282static inline int
283srmmu_get_pte (unsigned long addr) 283srmmu_get_pte (unsigned long addr)
284{ 284{
285 register unsigned long entry; 285 register unsigned long entry;
diff --git a/include/asm-sparc/processor.h b/include/asm-sparc/processor.h
index 5a7a1a8d29ac..6fbb3f0af8d8 100644
--- a/include/asm-sparc/processor.h
+++ b/include/asm-sparc/processor.h
@@ -79,7 +79,7 @@ struct thread_struct {
79extern unsigned long thread_saved_pc(struct task_struct *t); 79extern unsigned long thread_saved_pc(struct task_struct *t);
80 80
81/* Do necessary setup to start up a newly executed thread. */ 81/* Do necessary setup to start up a newly executed thread. */
82extern __inline__ void start_thread(struct pt_regs * regs, unsigned long pc, 82static inline void start_thread(struct pt_regs * regs, unsigned long pc,
83 unsigned long sp) 83 unsigned long sp)
84{ 84{
85 register unsigned long zero asm("g1"); 85 register unsigned long zero asm("g1");
diff --git a/include/asm-sparc/psr.h b/include/asm-sparc/psr.h
index 9778b8c8b15b..19c978051118 100644
--- a/include/asm-sparc/psr.h
+++ b/include/asm-sparc/psr.h
@@ -38,7 +38,7 @@
38 38
39#ifndef __ASSEMBLY__ 39#ifndef __ASSEMBLY__
40/* Get the %psr register. */ 40/* Get the %psr register. */
41extern __inline__ unsigned int get_psr(void) 41static inline unsigned int get_psr(void)
42{ 42{
43 unsigned int psr; 43 unsigned int psr;
44 __asm__ __volatile__( 44 __asm__ __volatile__(
@@ -53,7 +53,7 @@ extern __inline__ unsigned int get_psr(void)
53 return psr; 53 return psr;
54} 54}
55 55
56extern __inline__ void put_psr(unsigned int new_psr) 56static inline void put_psr(unsigned int new_psr)
57{ 57{
58 __asm__ __volatile__( 58 __asm__ __volatile__(
59 "wr %0, 0x0, %%psr\n\t" 59 "wr %0, 0x0, %%psr\n\t"
@@ -72,7 +72,7 @@ extern __inline__ void put_psr(unsigned int new_psr)
72 72
73extern unsigned int fsr_storage; 73extern unsigned int fsr_storage;
74 74
75extern __inline__ unsigned int get_fsr(void) 75static inline unsigned int get_fsr(void)
76{ 76{
77 unsigned int fsr = 0; 77 unsigned int fsr = 0;
78 78
diff --git a/include/asm-sparc/sbi.h b/include/asm-sparc/sbi.h
index 739ccac5dcf2..86a603ac7b20 100644
--- a/include/asm-sparc/sbi.h
+++ b/include/asm-sparc/sbi.h
@@ -65,7 +65,7 @@ struct sbi_regs {
65 65
66#ifndef __ASSEMBLY__ 66#ifndef __ASSEMBLY__
67 67
68extern __inline__ int acquire_sbi(int devid, int mask) 68static inline int acquire_sbi(int devid, int mask)
69{ 69{
70 __asm__ __volatile__ ("swapa [%2] %3, %0" : 70 __asm__ __volatile__ ("swapa [%2] %3, %0" :
71 "=r" (mask) : 71 "=r" (mask) :
@@ -75,7 +75,7 @@ extern __inline__ int acquire_sbi(int devid, int mask)
75 return mask; 75 return mask;
76} 76}
77 77
78extern __inline__ void release_sbi(int devid, int mask) 78static inline void release_sbi(int devid, int mask)
79{ 79{
80 __asm__ __volatile__ ("sta %0, [%1] %2" : : 80 __asm__ __volatile__ ("sta %0, [%1] %2" : :
81 "r" (mask), 81 "r" (mask),
@@ -83,7 +83,7 @@ extern __inline__ void release_sbi(int devid, int mask)
83 "i" (ASI_M_CTL)); 83 "i" (ASI_M_CTL));
84} 84}
85 85
86extern __inline__ void set_sbi_tid(int devid, int targetid) 86static inline void set_sbi_tid(int devid, int targetid)
87{ 87{
88 __asm__ __volatile__ ("sta %0, [%1] %2" : : 88 __asm__ __volatile__ ("sta %0, [%1] %2" : :
89 "r" (targetid), 89 "r" (targetid),
@@ -91,7 +91,7 @@ extern __inline__ void set_sbi_tid(int devid, int targetid)
91 "i" (ASI_M_CTL)); 91 "i" (ASI_M_CTL));
92} 92}
93 93
94extern __inline__ int get_sbi_ctl(int devid, int cfgno) 94static inline int get_sbi_ctl(int devid, int cfgno)
95{ 95{
96 int cfg; 96 int cfg;
97 97
@@ -102,7 +102,7 @@ extern __inline__ int get_sbi_ctl(int devid, int cfgno)
102 return cfg; 102 return cfg;
103} 103}
104 104
105extern __inline__ void set_sbi_ctl(int devid, int cfgno, int cfg) 105static inline void set_sbi_ctl(int devid, int cfgno, int cfg)
106{ 106{
107 __asm__ __volatile__ ("sta %0, [%1] %2" : : 107 __asm__ __volatile__ ("sta %0, [%1] %2" : :
108 "r" (cfg), 108 "r" (cfg),
diff --git a/include/asm-sparc/sbus.h b/include/asm-sparc/sbus.h
index 3a8b3908728a..a13cddcecec5 100644
--- a/include/asm-sparc/sbus.h
+++ b/include/asm-sparc/sbus.h
@@ -28,12 +28,12 @@
28 * numbers + offsets, and vice versa. 28 * numbers + offsets, and vice versa.
29 */ 29 */
30 30
31extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset) 31static inline unsigned long sbus_devaddr(int slotnum, unsigned long offset)
32{ 32{
33 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset)); 33 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
34} 34}
35 35
36extern __inline__ int sbus_dev_slot(unsigned long dev_addr) 36static inline int sbus_dev_slot(unsigned long dev_addr)
37{ 37{
38 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25); 38 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
39} 39}
@@ -80,7 +80,7 @@ struct sbus_bus {
80 80
81extern struct sbus_bus *sbus_root; 81extern struct sbus_bus *sbus_root;
82 82
83extern __inline__ int 83static inline int
84sbus_is_slave(struct sbus_dev *dev) 84sbus_is_slave(struct sbus_dev *dev)
85{ 85{
86 /* XXX Have to write this for sun4c's */ 86 /* XXX Have to write this for sun4c's */
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index 4f96d8333a12..580c51d011df 100644
--- a/include/asm-sparc/smp.h
+++ b/include/asm-sparc/smp.h
@@ -60,22 +60,22 @@ BTFIXUPDEF_BLACKBOX(load_current)
60#define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5) 60#define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
61#define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait) 61#define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
62 62
63extern __inline__ void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); } 63static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
64extern __inline__ void xc1(smpfunc_t func, unsigned long arg1) 64static inline void xc1(smpfunc_t func, unsigned long arg1)
65{ smp_cross_call(func, arg1, 0, 0, 0, 0); } 65{ smp_cross_call(func, arg1, 0, 0, 0, 0); }
66extern __inline__ void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2) 66static inline void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
67{ smp_cross_call(func, arg1, arg2, 0, 0, 0); } 67{ smp_cross_call(func, arg1, arg2, 0, 0, 0); }
68extern __inline__ void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2, 68static inline void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
69 unsigned long arg3) 69 unsigned long arg3)
70{ smp_cross_call(func, arg1, arg2, arg3, 0, 0); } 70{ smp_cross_call(func, arg1, arg2, arg3, 0, 0); }
71extern __inline__ void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2, 71static inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
72 unsigned long arg3, unsigned long arg4) 72 unsigned long arg3, unsigned long arg4)
73{ smp_cross_call(func, arg1, arg2, arg3, arg4, 0); } 73{ smp_cross_call(func, arg1, arg2, arg3, arg4, 0); }
74extern __inline__ void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2, 74static inline void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
75 unsigned long arg3, unsigned long arg4, unsigned long arg5) 75 unsigned long arg3, unsigned long arg4, unsigned long arg5)
76{ smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); } 76{ smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); }
77 77
78extern __inline__ int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait) 78static inline int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait)
79{ 79{
80 xc1((smpfunc_t)func, (unsigned long)info); 80 xc1((smpfunc_t)func, (unsigned long)info);
81 return 0; 81 return 0;
@@ -84,16 +84,16 @@ extern __inline__ int smp_call_function(void (*func)(void *info), void *info, in
84extern __volatile__ int __cpu_number_map[NR_CPUS]; 84extern __volatile__ int __cpu_number_map[NR_CPUS];
85extern __volatile__ int __cpu_logical_map[NR_CPUS]; 85extern __volatile__ int __cpu_logical_map[NR_CPUS];
86 86
87extern __inline__ int cpu_logical_map(int cpu) 87static inline int cpu_logical_map(int cpu)
88{ 88{
89 return __cpu_logical_map[cpu]; 89 return __cpu_logical_map[cpu];
90} 90}
91extern __inline__ int cpu_number_map(int cpu) 91static inline int cpu_number_map(int cpu)
92{ 92{
93 return __cpu_number_map[cpu]; 93 return __cpu_number_map[cpu];
94} 94}
95 95
96extern __inline__ int hard_smp4m_processor_id(void) 96static inline int hard_smp4m_processor_id(void)
97{ 97{
98 int cpuid; 98 int cpuid;
99 99
@@ -104,7 +104,7 @@ extern __inline__ int hard_smp4m_processor_id(void)
104 return cpuid; 104 return cpuid;
105} 105}
106 106
107extern __inline__ int hard_smp4d_processor_id(void) 107static inline int hard_smp4d_processor_id(void)
108{ 108{
109 int cpuid; 109 int cpuid;
110 110
@@ -114,7 +114,7 @@ extern __inline__ int hard_smp4d_processor_id(void)
114} 114}
115 115
116#ifndef MODULE 116#ifndef MODULE
117extern __inline__ int hard_smp_processor_id(void) 117static inline int hard_smp_processor_id(void)
118{ 118{
119 int cpuid; 119 int cpuid;
120 120
@@ -136,7 +136,7 @@ extern __inline__ int hard_smp_processor_id(void)
136 return cpuid; 136 return cpuid;
137} 137}
138#else 138#else
139extern __inline__ int hard_smp_processor_id(void) 139static inline int hard_smp_processor_id(void)
140{ 140{
141 int cpuid; 141 int cpuid;
142 142
diff --git a/include/asm-sparc/smpprim.h b/include/asm-sparc/smpprim.h
index 9b9c28ed748e..e7b6d346ae10 100644
--- a/include/asm-sparc/smpprim.h
+++ b/include/asm-sparc/smpprim.h
@@ -15,7 +15,7 @@
15 * atomic. 15 * atomic.
16 */ 16 */
17 17
18extern __inline__ __volatile__ char test_and_set(void *addr) 18static inline __volatile__ char test_and_set(void *addr)
19{ 19{
20 char state = 0; 20 char state = 0;
21 21
@@ -27,7 +27,7 @@ extern __inline__ __volatile__ char test_and_set(void *addr)
27} 27}
28 28
29/* Initialize a spin-lock. */ 29/* Initialize a spin-lock. */
30extern __inline__ __volatile__ smp_initlock(void *spinlock) 30static inline __volatile__ smp_initlock(void *spinlock)
31{ 31{
32 /* Unset the lock. */ 32 /* Unset the lock. */
33 *((unsigned char *) spinlock) = 0; 33 *((unsigned char *) spinlock) = 0;
@@ -36,7 +36,7 @@ extern __inline__ __volatile__ smp_initlock(void *spinlock)
36} 36}
37 37
38/* This routine spins until it acquires the lock at ADDR. */ 38/* This routine spins until it acquires the lock at ADDR. */
39extern __inline__ __volatile__ smp_lock(void *addr) 39static inline __volatile__ smp_lock(void *addr)
40{ 40{
41 while(test_and_set(addr) == 0xff) 41 while(test_and_set(addr) == 0xff)
42 ; 42 ;
@@ -46,7 +46,7 @@ extern __inline__ __volatile__ smp_lock(void *addr)
46} 46}
47 47
48/* This routine releases the lock at ADDR. */ 48/* This routine releases the lock at ADDR. */
49extern __inline__ __volatile__ smp_unlock(void *addr) 49static inline __volatile__ smp_unlock(void *addr)
50{ 50{
51 *((unsigned char *) addr) = 0; 51 *((unsigned char *) addr) = 0;
52} 52}
diff --git a/include/asm-sparc/spinlock.h b/include/asm-sparc/spinlock.h
index 111727a2bb4e..e344c98a6f5f 100644
--- a/include/asm-sparc/spinlock.h
+++ b/include/asm-sparc/spinlock.h
@@ -17,7 +17,7 @@
17#define __raw_spin_unlock_wait(lock) \ 17#define __raw_spin_unlock_wait(lock) \
18 do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0) 18 do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0)
19 19
20extern __inline__ void __raw_spin_lock(raw_spinlock_t *lock) 20static inline void __raw_spin_lock(raw_spinlock_t *lock)
21{ 21{
22 __asm__ __volatile__( 22 __asm__ __volatile__(
23 "\n1:\n\t" 23 "\n1:\n\t"
@@ -37,7 +37,7 @@ extern __inline__ void __raw_spin_lock(raw_spinlock_t *lock)
37 : "g2", "memory", "cc"); 37 : "g2", "memory", "cc");
38} 38}
39 39
40extern __inline__ int __raw_spin_trylock(raw_spinlock_t *lock) 40static inline int __raw_spin_trylock(raw_spinlock_t *lock)
41{ 41{
42 unsigned int result; 42 unsigned int result;
43 __asm__ __volatile__("ldstub [%1], %0" 43 __asm__ __volatile__("ldstub [%1], %0"
@@ -47,7 +47,7 @@ extern __inline__ int __raw_spin_trylock(raw_spinlock_t *lock)
47 return (result == 0); 47 return (result == 0);
48} 48}
49 49
50extern __inline__ void __raw_spin_unlock(raw_spinlock_t *lock) 50static inline void __raw_spin_unlock(raw_spinlock_t *lock)
51{ 51{
52 __asm__ __volatile__("stb %%g0, [%0]" : : "r" (lock) : "memory"); 52 __asm__ __volatile__("stb %%g0, [%0]" : : "r" (lock) : "memory");
53} 53}
@@ -78,7 +78,7 @@ extern __inline__ void __raw_spin_unlock(raw_spinlock_t *lock)
78 * 78 *
79 * Unfortunately this scheme limits us to ~16,000,000 cpus. 79 * Unfortunately this scheme limits us to ~16,000,000 cpus.
80 */ 80 */
81extern __inline__ void __read_lock(raw_rwlock_t *rw) 81static inline void __read_lock(raw_rwlock_t *rw)
82{ 82{
83 register raw_rwlock_t *lp asm("g1"); 83 register raw_rwlock_t *lp asm("g1");
84 lp = rw; 84 lp = rw;
@@ -98,7 +98,7 @@ do { unsigned long flags; \
98 local_irq_restore(flags); \ 98 local_irq_restore(flags); \
99} while(0) 99} while(0)
100 100
101extern __inline__ void __read_unlock(raw_rwlock_t *rw) 101static inline void __read_unlock(raw_rwlock_t *rw)
102{ 102{
103 register raw_rwlock_t *lp asm("g1"); 103 register raw_rwlock_t *lp asm("g1");
104 lp = rw; 104 lp = rw;
diff --git a/include/asm-sparc/system.h b/include/asm-sparc/system.h
index 3557781a4bfd..1f6b71f9e1b6 100644
--- a/include/asm-sparc/system.h
+++ b/include/asm-sparc/system.h
@@ -204,7 +204,7 @@ static inline unsigned long getipl(void)
204BTFIXUPDEF_CALL(void, ___xchg32, void) 204BTFIXUPDEF_CALL(void, ___xchg32, void)
205#endif 205#endif
206 206
207extern __inline__ unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned long val) 207static inline unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned long val)
208{ 208{
209#ifdef CONFIG_SMP 209#ifdef CONFIG_SMP
210 __asm__ __volatile__("swap [%2], %0" 210 __asm__ __volatile__("swap [%2], %0"
diff --git a/include/asm-sparc/traps.h b/include/asm-sparc/traps.h
index 6690ab956ea6..f62c7f878ee1 100644
--- a/include/asm-sparc/traps.h
+++ b/include/asm-sparc/traps.h
@@ -22,7 +22,7 @@ struct tt_entry {
22/* We set this to _start in system setup. */ 22/* We set this to _start in system setup. */
23extern struct tt_entry *sparc_ttable; 23extern struct tt_entry *sparc_ttable;
24 24
25extern __inline__ unsigned long get_tbr(void) 25static inline unsigned long get_tbr(void)
26{ 26{
27 unsigned long tbr; 27 unsigned long tbr;
28 28
diff --git a/include/asm-sparc64/cacheflush.h b/include/asm-sparc64/cacheflush.h
index 51b26e81d828..b3f61659ba81 100644
--- a/include/asm-sparc64/cacheflush.h
+++ b/include/asm-sparc64/cacheflush.h
@@ -4,13 +4,6 @@
4#include <linux/config.h> 4#include <linux/config.h>
5#include <asm/page.h> 5#include <asm/page.h>
6 6
7/* Flushing for D-cache alias handling is only needed if
8 * the page size is smaller than 16K.
9 */
10#if PAGE_SHIFT < 14
11#define DCACHE_ALIASING_POSSIBLE
12#endif
13
14#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
15 8
16#include <linux/mm.h> 9#include <linux/mm.h>
@@ -73,6 +66,11 @@ extern void flush_ptrace_access(struct vm_area_struct *, struct page *,
73#define flush_cache_vmap(start, end) do { } while (0) 66#define flush_cache_vmap(start, end) do { } while (0)
74#define flush_cache_vunmap(start, end) do { } while (0) 67#define flush_cache_vunmap(start, end) do { } while (0)
75 68
69#ifdef CONFIG_DEBUG_PAGEALLOC
70/* internal debugging function */
71void kernel_map_pages(struct page *page, int numpages, int enable);
72#endif
73
76#endif /* !__ASSEMBLY__ */ 74#endif /* !__ASSEMBLY__ */
77 75
78#endif /* _SPARC64_CACHEFLUSH_H */ 76#endif /* _SPARC64_CACHEFLUSH_H */
diff --git a/include/asm-sparc64/cpudata.h b/include/asm-sparc64/cpudata.h
index 9a3a81f1cc58..74de79dca915 100644
--- a/include/asm-sparc64/cpudata.h
+++ b/include/asm-sparc64/cpudata.h
@@ -22,6 +22,16 @@ typedef struct {
22 unsigned int __pad1; 22 unsigned int __pad1;
23 unsigned long *pte_cache[2]; 23 unsigned long *pte_cache[2];
24 unsigned long *pgd_cache; 24 unsigned long *pgd_cache;
25
26 /* Dcache line 3, rarely used */
27 unsigned int dcache_size;
28 unsigned int dcache_line_size;
29 unsigned int icache_size;
30 unsigned int icache_line_size;
31 unsigned int ecache_size;
32 unsigned int ecache_line_size;
33 unsigned int __pad2;
34 unsigned int __pad3;
25} cpuinfo_sparc; 35} cpuinfo_sparc;
26 36
27DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data); 37DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-sparc64/head.h b/include/asm-sparc64/head.h
index b63a33cf4971..0abd3a674e8f 100644
--- a/include/asm-sparc64/head.h
+++ b/include/asm-sparc64/head.h
@@ -12,9 +12,12 @@
12#define __JALAPENO_ID 0x003e0016 12#define __JALAPENO_ID 0x003e0016
13 13
14#define CHEETAH_MANUF 0x003e 14#define CHEETAH_MANUF 0x003e
15#define CHEETAH_IMPL 0x0014 15#define CHEETAH_IMPL 0x0014 /* Ultra-III */
16#define CHEETAH_PLUS_IMPL 0x0015 16#define CHEETAH_PLUS_IMPL 0x0015 /* Ultra-III+ */
17#define JALAPENO_IMPL 0x0016 17#define JALAPENO_IMPL 0x0016 /* Ultra-IIIi */
18#define JAGUAR_IMPL 0x0018 /* Ultra-IV */
19#define PANTHER_IMPL 0x0019 /* Ultra-IV+ */
20#define SERRANO_IMPL 0x0022 /* Ultra-IIIi+ */
18 21
19#define BRANCH_IF_CHEETAH_BASE(tmp1,tmp2,label) \ 22#define BRANCH_IF_CHEETAH_BASE(tmp1,tmp2,label) \
20 rdpr %ver, %tmp1; \ 23 rdpr %ver, %tmp1; \
diff --git a/include/asm-sparc64/ide.h b/include/asm-sparc64/ide.h
index 4c1098474c73..c393f815b0be 100644
--- a/include/asm-sparc64/ide.h
+++ b/include/asm-sparc64/ide.h
@@ -15,6 +15,7 @@
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/spitfire.h> 16#include <asm/spitfire.h>
17#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
18#include <asm/page.h>
18 19
19#ifndef MAX_HWIFS 20#ifndef MAX_HWIFS
20# ifdef CONFIG_BLK_DEV_IDEPCI 21# ifdef CONFIG_BLK_DEV_IDEPCI
diff --git a/include/asm-sparc64/openprom.h b/include/asm-sparc64/openprom.h
index 0a336901d585..b4959d2b0d99 100644
--- a/include/asm-sparc64/openprom.h
+++ b/include/asm-sparc64/openprom.h
@@ -186,8 +186,8 @@ struct linux_prom_registers {
186}; 186};
187 187
188struct linux_prom64_registers { 188struct linux_prom64_registers {
189 long phys_addr; 189 unsigned long phys_addr;
190 long reg_size; 190 unsigned long reg_size;
191}; 191};
192 192
193struct linux_prom_irqs { 193struct linux_prom_irqs {
diff --git a/include/asm-sparc64/oplib.h b/include/asm-sparc64/oplib.h
index a432d9e7daaa..d02f1e8ae1a6 100644
--- a/include/asm-sparc64/oplib.h
+++ b/include/asm-sparc64/oplib.h
@@ -38,6 +38,20 @@ extern int prom_stdin, prom_stdout;
38 */ 38 */
39extern int prom_chosen_node; 39extern int prom_chosen_node;
40 40
41/* Helper values and strings in arch/sparc64/kernel/head.S */
42extern const char prom_finddev_name[];
43extern const char prom_chosen_path[];
44extern const char prom_getprop_name[];
45extern const char prom_mmu_name[];
46extern const char prom_callmethod_name[];
47extern const char prom_translate_name[];
48extern const char prom_map_name[];
49extern const char prom_unmap_name[];
50extern int prom_mmu_ihandle_cache;
51extern unsigned int prom_boot_mapped_pc;
52extern unsigned int prom_boot_mapping_mode;
53extern unsigned long prom_boot_mapping_phys_high, prom_boot_mapping_phys_low;
54
41struct linux_mlist_p1275 { 55struct linux_mlist_p1275 {
42 struct linux_mlist_p1275 *theres_more; 56 struct linux_mlist_p1275 *theres_more;
43 unsigned long start_adr; 57 unsigned long start_adr;
@@ -68,7 +82,7 @@ extern char *prom_getbootargs(void);
68 * of the string is different on V0 vs. V2->higher proms. The caller must 82 * of the string is different on V0 vs. V2->higher proms. The caller must
69 * know what he/she is doing! Returns the device descriptor, an int. 83 * know what he/she is doing! Returns the device descriptor, an int.
70 */ 84 */
71extern int prom_devopen(char *device_string); 85extern int prom_devopen(const char *device_string);
72 86
73/* Close a previously opened device described by the passed integer 87/* Close a previously opened device described by the passed integer
74 * descriptor. 88 * descriptor.
@@ -81,27 +95,13 @@ extern int prom_devclose(int device_handle);
81extern void prom_seek(int device_handle, unsigned int seek_hival, 95extern void prom_seek(int device_handle, unsigned int seek_hival,
82 unsigned int seek_lowval); 96 unsigned int seek_lowval);
83 97
84/* Machine memory configuration routine. */
85
86/* This function returns a V0 format memory descriptor table, it has three
87 * entries. One for the total amount of physical ram on the machine, one
88 * for the amount of physical ram available, and one describing the virtual
89 * areas which are allocated by the prom. So, in a sense the physical
90 * available is a calculation of the total physical minus the physical mapped
91 * by the prom with virtual mappings.
92 *
93 * These lists are returned pre-sorted, this should make your life easier
94 * since the prom itself is way too lazy to do such nice things.
95 */
96extern struct linux_mem_p1275 *prom_meminfo(void);
97
98/* Miscellaneous routines, don't really fit in any category per se. */ 98/* Miscellaneous routines, don't really fit in any category per se. */
99 99
100/* Reboot the machine with the command line passed. */ 100/* Reboot the machine with the command line passed. */
101extern void prom_reboot(char *boot_command); 101extern void prom_reboot(const char *boot_command);
102 102
103/* Evaluate the forth string passed. */ 103/* Evaluate the forth string passed. */
104extern void prom_feval(char *forth_string); 104extern void prom_feval(const char *forth_string);
105 105
106/* Enter the prom, with possibility of continuation with the 'go' 106/* Enter the prom, with possibility of continuation with the 'go'
107 * command in newer proms. 107 * command in newer proms.
@@ -154,7 +154,7 @@ extern char prom_getchar(void);
154extern void prom_putchar(char character); 154extern void prom_putchar(char character);
155 155
156/* Prom's internal routines, don't use in kernel/boot code. */ 156/* Prom's internal routines, don't use in kernel/boot code. */
157extern void prom_printf(char *fmt, ...); 157extern void prom_printf(const char *fmt, ...);
158extern void prom_write(const char *buf, unsigned int len); 158extern void prom_write(const char *buf, unsigned int len);
159 159
160/* Query for input device type */ 160/* Query for input device type */
@@ -215,7 +215,7 @@ extern int prom_getunumber(int syndrome_code,
215 char *buf, int buflen); 215 char *buf, int buflen);
216 216
217/* Retain physical memory to the caller across soft resets. */ 217/* Retain physical memory to the caller across soft resets. */
218extern unsigned long prom_retain(char *name, 218extern unsigned long prom_retain(const char *name,
219 unsigned long pa_low, unsigned long pa_high, 219 unsigned long pa_low, unsigned long pa_high,
220 long size, long align); 220 long size, long align);
221 221
@@ -269,28 +269,28 @@ extern int prom_getsibling(int node);
269/* Get the length, at the passed node, of the given property type. 269/* Get the length, at the passed node, of the given property type.
270 * Returns -1 on error (ie. no such property at this node). 270 * Returns -1 on error (ie. no such property at this node).
271 */ 271 */
272extern int prom_getproplen(int thisnode, char *property); 272extern int prom_getproplen(int thisnode, const char *property);
273 273
274/* Fetch the requested property using the given buffer. Returns 274/* Fetch the requested property using the given buffer. Returns
275 * the number of bytes the prom put into your buffer or -1 on error. 275 * the number of bytes the prom put into your buffer or -1 on error.
276 */ 276 */
277extern int prom_getproperty(int thisnode, char *property, 277extern int prom_getproperty(int thisnode, const char *property,
278 char *prop_buffer, int propbuf_size); 278 char *prop_buffer, int propbuf_size);
279 279
280/* Acquire an integer property. */ 280/* Acquire an integer property. */
281extern int prom_getint(int node, char *property); 281extern int prom_getint(int node, const char *property);
282 282
283/* Acquire an integer property, with a default value. */ 283/* Acquire an integer property, with a default value. */
284extern int prom_getintdefault(int node, char *property, int defval); 284extern int prom_getintdefault(int node, const char *property, int defval);
285 285
286/* Acquire a boolean property, 0=FALSE 1=TRUE. */ 286/* Acquire a boolean property, 0=FALSE 1=TRUE. */
287extern int prom_getbool(int node, char *prop); 287extern int prom_getbool(int node, const char *prop);
288 288
289/* Acquire a string property, null string on error. */ 289/* Acquire a string property, null string on error. */
290extern void prom_getstring(int node, char *prop, char *buf, int bufsize); 290extern void prom_getstring(int node, const char *prop, char *buf, int bufsize);
291 291
292/* Does the passed node have the given "name"? YES=1 NO=0 */ 292/* Does the passed node have the given "name"? YES=1 NO=0 */
293extern int prom_nodematch(int thisnode, char *name); 293extern int prom_nodematch(int thisnode, const char *name);
294 294
295/* Puts in buffer a prom name in the form name@x,y or name (x for which_io 295/* Puts in buffer a prom name in the form name@x,y or name (x for which_io
296 * and y for first regs phys address 296 * and y for first regs phys address
@@ -300,7 +300,7 @@ extern int prom_getname(int node, char *buf, int buflen);
300/* Search all siblings starting at the passed node for "name" matching 300/* Search all siblings starting at the passed node for "name" matching
301 * the given string. Returns the node on success, zero on failure. 301 * the given string. Returns the node on success, zero on failure.
302 */ 302 */
303extern int prom_searchsiblings(int node_start, char *name); 303extern int prom_searchsiblings(int node_start, const char *name);
304 304
305/* Return the first property type, as a string, for the given node. 305/* Return the first property type, as a string, for the given node.
306 * Returns a null string on error. Buffer should be at least 32B long. 306 * Returns a null string on error. Buffer should be at least 32B long.
@@ -310,21 +310,21 @@ extern char *prom_firstprop(int node, char *buffer);
310/* Returns the next property after the passed property for the given 310/* Returns the next property after the passed property for the given
311 * node. Returns null string on failure. Buffer should be at least 32B long. 311 * node. Returns null string on failure. Buffer should be at least 32B long.
312 */ 312 */
313extern char *prom_nextprop(int node, char *prev_property, char *buffer); 313extern char *prom_nextprop(int node, const char *prev_property, char *buffer);
314 314
315/* Returns 1 if the specified node has given property. */ 315/* Returns 1 if the specified node has given property. */
316extern int prom_node_has_property(int node, char *property); 316extern int prom_node_has_property(int node, const char *property);
317 317
318/* Returns phandle of the path specified */ 318/* Returns phandle of the path specified */
319extern int prom_finddevice(char *name); 319extern int prom_finddevice(const char *name);
320 320
321/* Set the indicated property at the given node with the passed value. 321/* Set the indicated property at the given node with the passed value.
322 * Returns the number of bytes of your value that the prom took. 322 * Returns the number of bytes of your value that the prom took.
323 */ 323 */
324extern int prom_setprop(int node, char *prop_name, char *prop_value, 324extern int prom_setprop(int node, const char *prop_name, char *prop_value,
325 int value_size); 325 int value_size);
326 326
327extern int prom_pathtoinode(char *path); 327extern int prom_pathtoinode(const char *path);
328extern int prom_inst2pkg(int); 328extern int prom_inst2pkg(int);
329 329
330/* CPU probing helpers. */ 330/* CPU probing helpers. */
@@ -334,7 +334,7 @@ int cpu_find_by_mid(int mid, int *prom_node);
334/* Client interface level routines. */ 334/* Client interface level routines. */
335extern void prom_set_trap_table(unsigned long tba); 335extern void prom_set_trap_table(unsigned long tba);
336 336
337extern long p1275_cmd (char *, long, ...); 337extern long p1275_cmd(const char *, long, ...);
338 338
339 339
340#if 0 340#if 0
diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h
index c9f8ef208ea5..5426bb28a993 100644
--- a/include/asm-sparc64/page.h
+++ b/include/asm-sparc64/page.h
@@ -21,6 +21,13 @@
21#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 21#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
22#define PAGE_MASK (~(PAGE_SIZE-1)) 22#define PAGE_MASK (~(PAGE_SIZE-1))
23 23
24/* Flushing for D-cache alias handling is only needed if
25 * the page size is smaller than 16K.
26 */
27#if PAGE_SHIFT < 14
28#define DCACHE_ALIASING_POSSIBLE
29#endif
30
24#ifdef __KERNEL__ 31#ifdef __KERNEL__
25 32
26#ifndef __ASSEMBLY__ 33#ifndef __ASSEMBLY__
@@ -133,23 +140,6 @@ extern unsigned long page_to_pfn(struct page *);
133#define virt_to_phys __pa 140#define virt_to_phys __pa
134#define phys_to_virt __va 141#define phys_to_virt __va
135 142
136/* The following structure is used to hold the physical
137 * memory configuration of the machine. This is filled in
138 * probe_memory() and is later used by mem_init() to set up
139 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
140 * these structs, this is arbitrary. The entry after the
141 * last valid one has num_bytes==0.
142 */
143
144struct sparc_phys_banks {
145 unsigned long base_addr;
146 unsigned long num_bytes;
147};
148
149#define SPARC_PHYS_BANKS 32
150
151extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
152
153#endif /* !(__ASSEMBLY__) */ 143#endif /* !(__ASSEMBLY__) */
154 144
155#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 145#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
diff --git a/include/asm-sparc64/pbm.h b/include/asm-sparc64/pbm.h
index 38bbbccb4068..dd35a2c7798a 100644
--- a/include/asm-sparc64/pbm.h
+++ b/include/asm-sparc64/pbm.h
@@ -27,23 +27,27 @@
27 * PCI bus. 27 * PCI bus.
28 */ 28 */
29 29
30#define PBM_LOGCLUSTERS 3
31#define PBM_NCLUSTERS (1 << PBM_LOGCLUSTERS)
32
33struct pci_controller_info; 30struct pci_controller_info;
34 31
35/* This contains the software state necessary to drive a PCI 32/* This contains the software state necessary to drive a PCI
36 * controller's IOMMU. 33 * controller's IOMMU.
37 */ 34 */
35struct pci_iommu_arena {
36 unsigned long *map;
37 unsigned int hint;
38 unsigned int limit;
39};
40
38struct pci_iommu { 41struct pci_iommu {
39 /* This protects the controller's IOMMU and all 42 /* This protects the controller's IOMMU and all
40 * streaming buffers underneath. 43 * streaming buffers underneath.
41 */ 44 */
42 spinlock_t lock; 45 spinlock_t lock;
43 46
47 struct pci_iommu_arena arena;
48
44 /* IOMMU page table, a linear array of ioptes. */ 49 /* IOMMU page table, a linear array of ioptes. */
45 iopte_t *page_table; /* The page table itself. */ 50 iopte_t *page_table; /* The page table itself. */
46 int page_table_sz_bits; /* log2 of ow many pages does it map? */
47 51
48 /* Base PCI memory space address where IOMMU mappings 52 /* Base PCI memory space address where IOMMU mappings
49 * begin. 53 * begin.
@@ -62,12 +66,6 @@ struct pci_iommu {
62 */ 66 */
63 unsigned long write_complete_reg; 67 unsigned long write_complete_reg;
64 68
65 /* The lowest used consistent mapping entry. Since
66 * we allocate consistent maps out of cluster 0 this
67 * is relative to the beginning of closter 0.
68 */
69 u32 lowest_consistent_map;
70
71 /* In order to deal with some buggy third-party PCI bridges that 69 /* In order to deal with some buggy third-party PCI bridges that
72 * do wrong prefetching, we never mark valid mappings as invalid. 70 * do wrong prefetching, we never mark valid mappings as invalid.
73 * Instead we point them at this dummy page. 71 * Instead we point them at this dummy page.
@@ -75,16 +73,6 @@ struct pci_iommu {
75 unsigned long dummy_page; 73 unsigned long dummy_page;
76 unsigned long dummy_page_pa; 74 unsigned long dummy_page_pa;
77 75
78 /* If PBM_NCLUSTERS is ever decreased to 4 or lower,
79 * or if largest supported page_table_sz * 8K goes above
80 * 2GB, you must increase the size of the type of
81 * these counters. You have been duly warned. -DaveM
82 */
83 struct {
84 u16 next;
85 u16 flush;
86 } alloc_info[PBM_NCLUSTERS];
87
88 /* CTX allocation. */ 76 /* CTX allocation. */
89 unsigned long ctx_lowest_free; 77 unsigned long ctx_lowest_free;
90 unsigned long ctx_bitmap[IOMMU_NUM_CTXS / (sizeof(unsigned long) * 8)]; 78 unsigned long ctx_bitmap[IOMMU_NUM_CTXS / (sizeof(unsigned long) * 8)];
@@ -102,7 +90,7 @@ struct pci_iommu {
102 u32 dma_addr_mask; 90 u32 dma_addr_mask;
103}; 91};
104 92
105extern void pci_iommu_table_init(struct pci_iommu *, int); 93extern void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask);
106 94
107/* This describes a PCI bus module's streaming buffer. */ 95/* This describes a PCI bus module's streaming buffer. */
108struct pci_strbuf { 96struct pci_strbuf {
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
index b9b1914aae63..a96067cca963 100644
--- a/include/asm-sparc64/pgalloc.h
+++ b/include/asm-sparc64/pgalloc.h
@@ -10,6 +10,7 @@
10#include <asm/spitfire.h> 10#include <asm/spitfire.h>
11#include <asm/cpudata.h> 11#include <asm/cpudata.h>
12#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
13#include <asm/page.h>
13 14
14/* Page table allocation/freeing. */ 15/* Page table allocation/freeing. */
15#ifdef CONFIG_SMP 16#ifdef CONFIG_SMP
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
index a2b4f5ed4625..8c6dfc6c7af6 100644
--- a/include/asm-sparc64/pgtable.h
+++ b/include/asm-sparc64/pgtable.h
@@ -24,21 +24,23 @@
24#include <asm/processor.h> 24#include <asm/processor.h>
25#include <asm/const.h> 25#include <asm/const.h>
26 26
27/* The kernel image occupies 0x4000000 to 0x1000000 (4MB --> 16MB). 27/* The kernel image occupies 0x4000000 to 0x1000000 (4MB --> 32MB).
28 * The page copy blockops use 0x1000000 to 0x18000000 (16MB --> 24MB). 28 * The page copy blockops can use 0x2000000 to 0x10000000.
29 * The PROM resides in an area spanning 0xf0000000 to 0x100000000. 29 * The PROM resides in an area spanning 0xf0000000 to 0x100000000.
30 * The vmalloc area spans 0x140000000 to 0x200000000. 30 * The vmalloc area spans 0x100000000 to 0x200000000.
31 * Since modules need to be in the lowest 32-bits of the address space,
32 * we place them right before the OBP area from 0x10000000 to 0xf0000000.
31 * There is a single static kernel PMD which maps from 0x0 to address 33 * There is a single static kernel PMD which maps from 0x0 to address
32 * 0x400000000. 34 * 0x400000000.
33 */ 35 */
34#define TLBTEMP_BASE _AC(0x0000000001000000,UL) 36#define TLBTEMP_BASE _AC(0x0000000002000000,UL)
35#define MODULES_VADDR _AC(0x0000000002000000,UL) 37#define MODULES_VADDR _AC(0x0000000010000000,UL)
36#define MODULES_LEN _AC(0x000000007e000000,UL) 38#define MODULES_LEN _AC(0x00000000e0000000,UL)
37#define MODULES_END _AC(0x0000000080000000,UL) 39#define MODULES_END _AC(0x00000000f0000000,UL)
38#define VMALLOC_START _AC(0x0000000140000000,UL)
39#define VMALLOC_END _AC(0x0000000200000000,UL)
40#define LOW_OBP_ADDRESS _AC(0x00000000f0000000,UL) 40#define LOW_OBP_ADDRESS _AC(0x00000000f0000000,UL)
41#define HI_OBP_ADDRESS _AC(0x0000000100000000,UL) 41#define HI_OBP_ADDRESS _AC(0x0000000100000000,UL)
42#define VMALLOC_START _AC(0x0000000100000000,UL)
43#define VMALLOC_END _AC(0x0000000200000000,UL)
42 44
43/* XXX All of this needs to be rethought so we can take advantage 45/* XXX All of this needs to be rethought so we can take advantage
44 * XXX cheetah's full 64-bit virtual address space, ie. no more hole 46 * XXX cheetah's full 64-bit virtual address space, ie. no more hole
@@ -58,13 +60,13 @@
58 * table can map 60 * table can map
59 */ 61 */
60#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3)) 62#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3))
61#define PMD_SIZE (1UL << PMD_SHIFT) 63#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
62#define PMD_MASK (~(PMD_SIZE-1)) 64#define PMD_MASK (~(PMD_SIZE-1))
63#define PMD_BITS (PAGE_SHIFT - 2) 65#define PMD_BITS (PAGE_SHIFT - 2)
64 66
65/* PGDIR_SHIFT determines what a third-level page table entry can map */ 67/* PGDIR_SHIFT determines what a third-level page table entry can map */
66#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS) 68#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS)
67#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 69#define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT)
68#define PGDIR_MASK (~(PGDIR_SIZE-1)) 70#define PGDIR_MASK (~(PGDIR_SIZE-1))
69#define PGDIR_BITS (PAGE_SHIFT - 2) 71#define PGDIR_BITS (PAGE_SHIFT - 2)
70 72
@@ -96,7 +98,9 @@
96#define _PAGE_NFO _AC(0x1000000000000000,UL) /* No Fault Only */ 98#define _PAGE_NFO _AC(0x1000000000000000,UL) /* No Fault Only */
97#define _PAGE_IE _AC(0x0800000000000000,UL) /* Invert Endianness */ 99#define _PAGE_IE _AC(0x0800000000000000,UL) /* Invert Endianness */
98#define _PAGE_SOFT2 _AC(0x07FC000000000000,UL) /* Software bits, set 2 */ 100#define _PAGE_SOFT2 _AC(0x07FC000000000000,UL) /* Software bits, set 2 */
99#define _PAGE_RES1 _AC(0x0003000000000000,UL) /* Reserved */ 101#define _PAGE_RES1 _AC(0x0002000000000000,UL) /* Reserved */
102#define _PAGE_SZ32MB _AC(0x0001000000000000,UL) /* (Panther) 32MB page */
103#define _PAGE_SZ256MB _AC(0x2001000000000000,UL) /* (Panther) 256MB page */
100#define _PAGE_SN _AC(0x0000800000000000,UL) /* (Cheetah) Snoop */ 104#define _PAGE_SN _AC(0x0000800000000000,UL) /* (Cheetah) Snoop */
101#define _PAGE_RES2 _AC(0x0000780000000000,UL) /* Reserved */ 105#define _PAGE_RES2 _AC(0x0000780000000000,UL) /* Reserved */
102#define _PAGE_PADDR_SF _AC(0x000001FFFFFFE000,UL) /* (Spitfire) paddr[40:13]*/ 106#define _PAGE_PADDR_SF _AC(0x000001FFFFFFE000,UL) /* (Spitfire) paddr[40:13]*/
@@ -334,7 +338,11 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *p
334#define pte_clear(mm,addr,ptep) \ 338#define pte_clear(mm,addr,ptep) \
335 set_pte_at((mm), (addr), (ptep), __pte(0UL)) 339 set_pte_at((mm), (addr), (ptep), __pte(0UL))
336 340
337extern pgd_t swapper_pg_dir[1]; 341extern pgd_t swapper_pg_dir[2048];
342extern pmd_t swapper_low_pmd_dir[2048];
343
344extern void paging_init(void);
345extern unsigned long find_ecache_flush_span(unsigned long size);
338 346
339/* These do nothing with the way I have things setup. */ 347/* These do nothing with the way I have things setup. */
340#define mmu_lockarea(vaddr, len) (vaddr) 348#define mmu_lockarea(vaddr, len) (vaddr)
diff --git a/include/asm-sparc64/uaccess.h b/include/asm-sparc64/uaccess.h
index 80a65d7e3dbf..203e8eee6351 100644
--- a/include/asm-sparc64/uaccess.h
+++ b/include/asm-sparc64/uaccess.h
@@ -70,26 +70,14 @@ static inline int access_ok(int type, const void __user * addr, unsigned long si
70 * with the main instruction path. This means when everything is well, 70 * with the main instruction path. This means when everything is well,
71 * we don't even have to jump over them. Further, they do not intrude 71 * we don't even have to jump over them. Further, they do not intrude
72 * on our cache or tlb entries. 72 * on our cache or tlb entries.
73 *
74 * There is a special way how to put a range of potentially faulting
75 * insns (like twenty ldd/std's with now intervening other instructions)
76 * You specify address of first in insn and 0 in fixup and in the next
77 * exception_table_entry you specify last potentially faulting insn + 1
78 * and in fixup the routine which should handle the fault.
79 * That fixup code will get
80 * (faulting_insn_address - first_insn_in_the_range_address)/4
81 * in %g2 (ie. index of the faulting instruction in the range).
82 */ 73 */
83 74
84struct exception_table_entry 75struct exception_table_entry {
85{ 76 unsigned int insn, fixup;
86 unsigned insn, fixup;
87}; 77};
88 78
89/* Special exable search, which handles ranges. Returns fixup */
90unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
91
92extern void __ret_efault(void); 79extern void __ret_efault(void);
80extern void __retl_efault(void);
93 81
94/* Uh, these should become the main single-value transfer routines.. 82/* Uh, these should become the main single-value transfer routines..
95 * They automatically use the right size if we just have the right 83 * They automatically use the right size if we just have the right
@@ -263,7 +251,7 @@ copy_from_user(void *to, const void __user *from, unsigned long size)
263{ 251{
264 unsigned long ret = ___copy_from_user(to, from, size); 252 unsigned long ret = ___copy_from_user(to, from, size);
265 253
266 if (ret) 254 if (unlikely(ret))
267 ret = copy_from_user_fixup(to, from, size); 255 ret = copy_from_user_fixup(to, from, size);
268 return ret; 256 return ret;
269} 257}
@@ -279,7 +267,7 @@ copy_to_user(void __user *to, const void *from, unsigned long size)
279{ 267{
280 unsigned long ret = ___copy_to_user(to, from, size); 268 unsigned long ret = ___copy_to_user(to, from, size);
281 269
282 if (ret) 270 if (unlikely(ret))
283 ret = copy_to_user_fixup(to, from, size); 271 ret = copy_to_user_fixup(to, from, size);
284 return ret; 272 return ret;
285} 273}
@@ -295,7 +283,7 @@ copy_in_user(void __user *to, void __user *from, unsigned long size)
295{ 283{
296 unsigned long ret = ___copy_in_user(to, from, size); 284 unsigned long ret = ___copy_in_user(to, from, size);
297 285
298 if (ret) 286 if (unlikely(ret))
299 ret = copy_in_user_fixup(to, from, size); 287 ret = copy_in_user_fixup(to, from, size);
300 return ret; 288 return ret;
301} 289}
diff --git a/include/asm-um/futex.h b/include/asm-um/futex.h
index 2cac5ecd9d00..142ee2d8e0fd 100644
--- a/include/asm-um/futex.h
+++ b/include/asm-um/futex.h
@@ -1,53 +1,12 @@
1#ifndef _ASM_FUTEX_H 1#ifndef __UM_FUTEX_H
2#define _ASM_FUTEX_H 2#define __UM_FUTEX_H
3
4#ifdef __KERNEL__
5 3
6#include <linux/futex.h> 4#include <linux/futex.h>
7#include <asm/errno.h> 5#include <asm/errno.h>
6#include <asm/system.h>
7#include <asm/processor.h>
8#include <asm/uaccess.h> 8#include <asm/uaccess.h>
9 9
10static inline int 10#include "asm/arch/futex.h"
11futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
12{
13 int op = (encoded_op >> 28) & 7;
14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg;
20
21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
22 return -EFAULT;
23
24 inc_preempt_count();
25
26 switch (op) {
27 case FUTEX_OP_SET:
28 case FUTEX_OP_ADD:
29 case FUTEX_OP_OR:
30 case FUTEX_OP_ANDN:
31 case FUTEX_OP_XOR:
32 default:
33 ret = -ENOSYS;
34 }
35 11
36 dec_preempt_count();
37
38 if (!ret) {
39 switch (cmp) {
40 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
41 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
42 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
43 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
44 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
45 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
46 default: ret = -ENOSYS;
47 }
48 }
49 return ret;
50}
51
52#endif
53#endif 12#endif
diff --git a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h
index ed06170e0edd..616d02b57ea9 100644
--- a/include/asm-um/pgtable.h
+++ b/include/asm-um/pgtable.h
@@ -346,7 +346,6 @@ static inline void set_pte(pte_t *pteptr, pte_t pteval)
346static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 346static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
347{ 347{
348 pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot); 348 pte_set_val(pte, (pte_val(pte) & _PAGE_CHG_MASK), newprot);
349 if(pte_present(pte)) pte = pte_mknewpage(pte_mknewprot(pte));
350 return pte; 349 return pte;
351} 350}
352 351
diff --git a/include/asm-um/processor-generic.h b/include/asm-um/processor-generic.h
index b2fc94fbc2d9..075771c371f6 100644
--- a/include/asm-um/processor-generic.h
+++ b/include/asm-um/processor-generic.h
@@ -13,6 +13,7 @@ struct task_struct;
13#include "linux/config.h" 13#include "linux/config.h"
14#include "asm/ptrace.h" 14#include "asm/ptrace.h"
15#include "choose-mode.h" 15#include "choose-mode.h"
16#include "registers.h"
16 17
17struct mm_struct; 18struct mm_struct;
18 19
@@ -21,6 +22,7 @@ struct thread_struct {
21 * copy_thread) to mark that we are begin called from userspace (fork / 22 * copy_thread) to mark that we are begin called from userspace (fork /
22 * vfork / clone), and reset to 0 after. It is left to 0 when called 23 * vfork / clone), and reset to 0 after. It is left to 0 when called
23 * from kernelspace (i.e. kernel_thread() or fork_idle(), as of 2.6.11). */ 24 * from kernelspace (i.e. kernel_thread() or fork_idle(), as of 2.6.11). */
25 struct task_struct *saved_task;
24 int forking; 26 int forking;
25 int nsyscalls; 27 int nsyscalls;
26 struct pt_regs regs; 28 struct pt_regs regs;
@@ -135,19 +137,15 @@ extern struct cpuinfo_um cpu_data[];
135#define current_cpu_data boot_cpu_data 137#define current_cpu_data boot_cpu_data
136#endif 138#endif
137 139
138#define KSTK_EIP(tsk) (PT_REGS_IP(&tsk->thread.regs))
139#define KSTK_ESP(tsk) (PT_REGS_SP(&tsk->thread.regs))
140#define get_wchan(p) (0)
141 140
141#ifdef CONFIG_MODE_SKAS
142#define KSTK_REG(tsk, reg) \
143 ({ union uml_pt_regs regs; \
144 get_thread_regs(&regs, tsk->thread.mode.skas.switch_buf); \
145 UPT_REG(&regs, reg); })
146#else
147#define KSTK_REG(tsk, reg) (0xbadbabe)
142#endif 148#endif
149#define get_wchan(p) (0)
143 150
144/* 151#endif
145 * Overrides for Emacs so that we follow Linus's tabbing style.
146 * Emacs will notice this stuff at the end of the file and automatically
147 * adjust the settings for this buffer only. This must remain at the end
148 * of the file.
149 * ---------------------------------------------------------------------------
150 * Local variables:
151 * c-file-style: "linux"
152 * End:
153 */
diff --git a/include/asm-um/processor-i386.h b/include/asm-um/processor-i386.h
index 431bad3ae9d7..4108a579eb92 100644
--- a/include/asm-um/processor-i386.h
+++ b/include/asm-um/processor-i386.h
@@ -43,17 +43,10 @@ static inline void rep_nop(void)
43#define ARCH_IS_STACKGROW(address) \ 43#define ARCH_IS_STACKGROW(address) \
44 (address + 32 >= UPT_SP(&current->thread.regs.regs)) 44 (address + 32 >= UPT_SP(&current->thread.regs.regs))
45 45
46#define KSTK_EIP(tsk) KSTK_REG(tsk, EIP)
47#define KSTK_ESP(tsk) KSTK_REG(tsk, UESP)
48#define KSTK_EBP(tsk) KSTK_REG(tsk, EBP)
49
46#include "asm/processor-generic.h" 50#include "asm/processor-generic.h"
47 51
48#endif 52#endif
49
50/*
51 * Overrides for Emacs so that we follow Linus's tabbing style.
52 * Emacs will notice this stuff at the end of the file and automatically
53 * adjust the settings for this buffer only. This must remain at the end
54 * of the file.
55 * ---------------------------------------------------------------------------
56 * Local variables:
57 * c-file-style: "linux"
58 * End:
59 */
diff --git a/include/asm-um/processor-x86_64.h b/include/asm-um/processor-x86_64.h
index 0beb9a42ae05..e1e1255a1d36 100644
--- a/include/asm-um/processor-x86_64.h
+++ b/include/asm-um/processor-x86_64.h
@@ -36,17 +36,9 @@ extern inline void rep_nop(void)
36#define ARCH_IS_STACKGROW(address) \ 36#define ARCH_IS_STACKGROW(address) \
37 (address + 128 >= UPT_SP(&current->thread.regs.regs)) 37 (address + 128 >= UPT_SP(&current->thread.regs.regs))
38 38
39#define KSTK_EIP(tsk) KSTK_REG(tsk, RIP)
40#define KSTK_ESP(tsk) KSTK_REG(tsk, RSP)
41
39#include "asm/processor-generic.h" 42#include "asm/processor-generic.h"
40 43
41#endif 44#endif
42
43/*
44 * Overrides for Emacs so that we follow Linus's tabbing style.
45 * Emacs will notice this stuff at the end of the file and automatically
46 * adjust the settings for this buffer only. This must remain at the end
47 * of the file.
48 * ---------------------------------------------------------------------------
49 * Local variables:
50 * c-file-style: "linux"
51 * End:
52 */
diff --git a/include/asm-um/system-i386.h b/include/asm-um/system-i386.h
index ea8381de3cc9..c436263e67ba 100644
--- a/include/asm-um/system-i386.h
+++ b/include/asm-um/system-i386.h
@@ -3,6 +3,4 @@
3 3
4#include "asm/system-generic.h" 4#include "asm/system-generic.h"
5 5
6#define __HAVE_ARCH_CMPXCHG 1
7
8#endif 6#endif
diff --git a/include/asm-um/uaccess.h b/include/asm-um/uaccess.h
index 801710d00a40..2ee028b8de9d 100644
--- a/include/asm-um/uaccess.h
+++ b/include/asm-um/uaccess.h
@@ -44,7 +44,7 @@
44 const __typeof__(ptr) __private_ptr = ptr; \ 44 const __typeof__(ptr) __private_ptr = ptr; \
45 __typeof__(*(__private_ptr)) __private_val; \ 45 __typeof__(*(__private_ptr)) __private_val; \
46 int __private_ret = -EFAULT; \ 46 int __private_ret = -EFAULT; \
47 (x) = 0; \ 47 (x) = (__typeof__(*(__private_ptr)))0; \
48 if (__copy_from_user(&__private_val, (__private_ptr), \ 48 if (__copy_from_user(&__private_val, (__private_ptr), \
49 sizeof(*(__private_ptr))) == 0) {\ 49 sizeof(*(__private_ptr))) == 0) {\
50 (x) = (__typeof__(*(__private_ptr))) __private_val; \ 50 (x) = (__typeof__(*(__private_ptr))) __private_val; \
diff --git a/include/asm-v850/futex.h b/include/asm-v850/futex.h
index 2cac5ecd9d00..9feff4ce1424 100644
--- a/include/asm-v850/futex.h
+++ b/include/asm-v850/futex.h
@@ -14,7 +14,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
14 int cmp = (encoded_op >> 24) & 15; 14 int cmp = (encoded_op >> 24) & 15;
15 int oparg = (encoded_op << 8) >> 20; 15 int oparg = (encoded_op << 8) >> 20;
16 int cmparg = (encoded_op << 20) >> 20; 16 int cmparg = (encoded_op << 20) >> 20;
17 int oldval = 0, ret, tem; 17 int oldval = 0, ret;
18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 18 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
19 oparg = 1 << oparg; 19 oparg = 1 << oparg;
20 20
diff --git a/include/asm-x86_64/desc.h b/include/asm-x86_64/desc.h
index 594e610f4a1e..68ac3c62fe3d 100644
--- a/include/asm-x86_64/desc.h
+++ b/include/asm-x86_64/desc.h
@@ -8,6 +8,8 @@
8#ifndef __ASSEMBLY__ 8#ifndef __ASSEMBLY__
9 9
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/smp.h>
12
11#include <asm/segment.h> 13#include <asm/segment.h>
12#include <asm/mmu.h> 14#include <asm/mmu.h>
13 15
diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
index 4d727f3f5550..5a7fe3c6c3d8 100644
--- a/include/asm-x86_64/msr.h
+++ b/include/asm-x86_64/msr.h
@@ -234,6 +234,7 @@ static inline unsigned int cpuid_edx(unsigned int op)
234#define MSR_K8_TOP_MEM1 0xC001001A 234#define MSR_K8_TOP_MEM1 0xC001001A
235#define MSR_K8_TOP_MEM2 0xC001001D 235#define MSR_K8_TOP_MEM2 0xC001001D
236#define MSR_K8_SYSCFG 0xC0010010 236#define MSR_K8_SYSCFG 0xC0010010
237#define MSR_K8_HWCR 0xC0010015
237 238
238/* K6 MSRs */ 239/* K6 MSRs */
239#define MSR_K6_EFER 0xC0000080 240#define MSR_K6_EFER 0xC0000080
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 2cb483516459..dd8711ecaf2f 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -384,7 +384,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
384} 384}
385 385
386#define pte_index(address) \ 386#define pte_index(address) \
387 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 387 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
388#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_kernel(*(dir)) + \ 388#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_kernel(*(dir)) + \
389 pte_index(address)) 389 pte_index(address))
390 390
diff --git a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
index 24e32611f0bf..c57ce4071342 100644
--- a/include/asm-x86_64/smp.h
+++ b/include/asm-x86_64/smp.h
@@ -81,6 +81,7 @@ static inline int hard_smp_processor_id(void)
81extern int safe_smp_processor_id(void); 81extern int safe_smp_processor_id(void);
82extern int __cpu_disable(void); 82extern int __cpu_disable(void);
83extern void __cpu_die(unsigned int cpu); 83extern void __cpu_die(unsigned int cpu);
84extern void prefill_possible_map(void);
84 85
85#endif /* !ASSEMBLY */ 86#endif /* !ASSEMBLY */
86 87
diff --git a/include/asm-xtensa/atomic.h b/include/asm-xtensa/atomic.h
index 24f86f0e43cf..12b5732dc6e5 100644
--- a/include/asm-xtensa/atomic.h
+++ b/include/asm-xtensa/atomic.h
@@ -22,7 +22,7 @@ typedef struct { volatile int counter; } atomic_t;
22#include <asm/processor.h> 22#include <asm/processor.h>
23#include <asm/system.h> 23#include <asm/system.h>
24 24
25#define ATOMIC_INIT(i) ( (atomic_t) { (i) } ) 25#define ATOMIC_INIT(i) { (i) }
26 26
27/* 27/*
28 * This Xtensa implementation assumes that the right mechanism 28 * This Xtensa implementation assumes that the right mechanism
diff --git a/include/asm-xtensa/bitops.h b/include/asm-xtensa/bitops.h
index d395ef226c32..e76ee889e21d 100644
--- a/include/asm-xtensa/bitops.h
+++ b/include/asm-xtensa/bitops.h
@@ -174,7 +174,7 @@ static __inline__ int test_bit(int nr, const volatile void *addr)
174 return 1UL & (((const volatile unsigned int *)addr)[nr>>5] >> (nr&31)); 174 return 1UL & (((const volatile unsigned int *)addr)[nr>>5] >> (nr&31));
175} 175}
176 176
177#if XCHAL_HAVE_NSAU 177#if XCHAL_HAVE_NSA
178 178
179static __inline__ int __cntlz (unsigned long x) 179static __inline__ int __cntlz (unsigned long x)
180{ 180{
diff --git a/include/asm-xtensa/hardirq.h b/include/asm-xtensa/hardirq.h
index e07c76c36b95..aa9c1adf68d7 100644
--- a/include/asm-xtensa/hardirq.h
+++ b/include/asm-xtensa/hardirq.h
@@ -23,6 +23,7 @@ typedef struct {
23 unsigned int __nmi_count; /* arch dependent */ 23 unsigned int __nmi_count; /* arch dependent */
24} ____cacheline_aligned irq_cpustat_t; 24} ____cacheline_aligned irq_cpustat_t;
25 25
26void ack_bad_irq(unsigned int irq);
26#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 27#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
27 28
28#endif /* _XTENSA_HARDIRQ_H */ 29#endif /* _XTENSA_HARDIRQ_H */
diff --git a/include/asm-xtensa/semaphore.h b/include/asm-xtensa/semaphore.h
index db740b8bc6f0..09e89ab3eb61 100644
--- a/include/asm-xtensa/semaphore.h
+++ b/include/asm-xtensa/semaphore.h
@@ -20,28 +20,19 @@ struct semaphore {
20 atomic_t count; 20 atomic_t count;
21 int sleepers; 21 int sleepers;
22 wait_queue_head_t wait; 22 wait_queue_head_t wait;
23#if WAITQUEUE_DEBUG
24 long __magic;
25#endif
26}; 23};
27 24
28#if WAITQUEUE_DEBUG 25#define __SEMAPHORE_INITIALIZER(name,n) \
29# define __SEM_DEBUG_INIT(name) \ 26{ \
30 , (int)&(name).__magic 27 .count = ATOMIC_INIT(n), \
31#else 28 .sleepers = 0, \
32# define __SEM_DEBUG_INIT(name) 29 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
33#endif 30}
34
35#define __SEMAPHORE_INITIALIZER(name,count) \
36 { ATOMIC_INIT(count), \
37 0, \
38 __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
39 __SEM_DEBUG_INIT(name) }
40 31
41#define __MUTEX_INITIALIZER(name) \ 32#define __MUTEX_INITIALIZER(name) \
42 __SEMAPHORE_INITIALIZER(name, 1) 33 __SEMAPHORE_INITIALIZER(name, 1)
43 34
44#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ 35#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
45 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) 36 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
46 37
47#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) 38#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
@@ -49,17 +40,8 @@ struct semaphore {
49 40
50static inline void sema_init (struct semaphore *sem, int val) 41static inline void sema_init (struct semaphore *sem, int val)
51{ 42{
52/*
53 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
54 *
55 * i'd rather use the more flexible initialization above, but sadly
56 * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
57 */
58 atomic_set(&sem->count, val); 43 atomic_set(&sem->count, val);
59 init_waitqueue_head(&sem->wait); 44 init_waitqueue_head(&sem->wait);
60#if WAITQUEUE_DEBUG
61 sem->__magic = (int)&sem->__magic;
62#endif
63} 45}
64 46
65static inline void init_MUTEX (struct semaphore *sem) 47static inline void init_MUTEX (struct semaphore *sem)
@@ -81,9 +63,7 @@ extern spinlock_t semaphore_wake_lock;
81 63
82static inline void down(struct semaphore * sem) 64static inline void down(struct semaphore * sem)
83{ 65{
84#if WAITQUEUE_DEBUG 66 might_sleep();
85 CHECK_MAGIC(sem->__magic);
86#endif
87 67
88 if (atomic_sub_return(1, &sem->count) < 0) 68 if (atomic_sub_return(1, &sem->count) < 0)
89 __down(sem); 69 __down(sem);
@@ -92,9 +72,8 @@ static inline void down(struct semaphore * sem)
92static inline int down_interruptible(struct semaphore * sem) 72static inline int down_interruptible(struct semaphore * sem)
93{ 73{
94 int ret = 0; 74 int ret = 0;
95#if WAITQUEUE_DEBUG 75
96 CHECK_MAGIC(sem->__magic); 76 might_sleep();
97#endif
98 77
99 if (atomic_sub_return(1, &sem->count) < 0) 78 if (atomic_sub_return(1, &sem->count) < 0)
100 ret = __down_interruptible(sem); 79 ret = __down_interruptible(sem);
@@ -104,9 +83,6 @@ static inline int down_interruptible(struct semaphore * sem)
104static inline int down_trylock(struct semaphore * sem) 83static inline int down_trylock(struct semaphore * sem)
105{ 84{
106 int ret = 0; 85 int ret = 0;
107#if WAITQUEUE_DEBUG
108 CHECK_MAGIC(sem->__magic);
109#endif
110 86
111 if (atomic_sub_return(1, &sem->count) < 0) 87 if (atomic_sub_return(1, &sem->count) < 0)
112 ret = __down_trylock(sem); 88 ret = __down_trylock(sem);
@@ -119,9 +95,6 @@ static inline int down_trylock(struct semaphore * sem)
119 */ 95 */
120static inline void up(struct semaphore * sem) 96static inline void up(struct semaphore * sem)
121{ 97{
122#if WAITQUEUE_DEBUG
123 CHECK_MAGIC(sem->__magic);
124#endif
125 if (atomic_add_return(1, &sem->count) <= 0) 98 if (atomic_add_return(1, &sem->count) <= 0)
126 __up(sem); 99 __up(sem);
127} 100}
diff --git a/include/asm-xtensa/system.h b/include/asm-xtensa/system.h
index f09393232e5e..9284867f1cb9 100644
--- a/include/asm-xtensa/system.h
+++ b/include/asm-xtensa/system.h
@@ -189,20 +189,6 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
189 189
190#define tas(ptr) (xchg((ptr),1)) 190#define tas(ptr) (xchg((ptr),1))
191 191
192#if ( __XCC__ == 1 )
193
194/* xt-xcc processes __inline__ differently than xt-gcc and decides to
195 * insert an out-of-line copy of function __xchg. This presents the
196 * unresolved symbol at link time of __xchg_called_with_bad_pointer,
197 * even though such a function would never be called at run-time.
198 * xt-gcc always inlines __xchg, and optimizes away the undefined
199 * bad_pointer function.
200 */
201
202#define xchg(ptr,x) xchg_u32(ptr,x)
203
204#else /* assume xt-gcc */
205
206#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) 192#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
207 193
208/* 194/*
@@ -224,8 +210,6 @@ __xchg(unsigned long x, volatile void * ptr, int size)
224 return x; 210 return x;
225} 211}
226 212
227#endif
228
229extern void set_except_vector(int n, void *addr); 213extern void set_except_vector(int n, void *addr);
230 214
231static inline void spill_registers(void) 215static inline void spill_registers(void)
diff --git a/include/linux/acct.h b/include/linux/acct.h
index 1993a3691768..19f70462b3be 100644
--- a/include/linux/acct.h
+++ b/include/linux/acct.h
@@ -162,13 +162,13 @@ typedef struct acct acct_t;
162#ifdef __KERNEL__ 162#ifdef __KERNEL__
163/* 163/*
164 * Yet another set of HZ to *HZ helper functions. 164 * Yet another set of HZ to *HZ helper functions.
165 * See <linux/times.h> for the original. 165 * See <linux/jiffies.h> for the original.
166 */ 166 */
167 167
168static inline u32 jiffies_to_AHZ(unsigned long x) 168static inline u32 jiffies_to_AHZ(unsigned long x)
169{ 169{
170#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0 170#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
171 return x / (HZ / USER_HZ); 171 return x / (HZ / AHZ);
172#else 172#else
173 u64 tmp = (u64)x * TICK_NSEC; 173 u64 tmp = (u64)x * TICK_NSEC;
174 do_div(tmp, (NSEC_PER_SEC / AHZ)); 174 do_div(tmp, (NSEC_PER_SEC / AHZ));
diff --git a/include/linux/aio.h b/include/linux/aio.h
index a4d5af907f90..0decf66117c1 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -24,7 +24,12 @@ struct kioctx;
24#define KIOCB_SYNC_KEY (~0U) 24#define KIOCB_SYNC_KEY (~0U)
25 25
26/* ki_flags bits */ 26/* ki_flags bits */
27#define KIF_LOCKED 0 27/*
28 * This may be used for cancel/retry serialization in the future, but
29 * for now it's unused and we probably don't want modules to even
30 * think they can use it.
31 */
32/* #define KIF_LOCKED 0 */
28#define KIF_KICKED 1 33#define KIF_KICKED 1
29#define KIF_CANCELLED 2 34#define KIF_CANCELLED 2
30 35
@@ -43,6 +48,40 @@ struct kioctx;
43#define kiocbIsKicked(iocb) test_bit(KIF_KICKED, &(iocb)->ki_flags) 48#define kiocbIsKicked(iocb) test_bit(KIF_KICKED, &(iocb)->ki_flags)
44#define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags) 49#define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags)
45 50
51/* is there a better place to document function pointer methods? */
52/**
53 * ki_retry - iocb forward progress callback
54 * @kiocb: The kiocb struct to advance by performing an operation.
55 *
56 * This callback is called when the AIO core wants a given AIO operation
57 * to make forward progress. The kiocb argument describes the operation
58 * that is to be performed. As the operation proceeds, perhaps partially,
59 * ki_retry is expected to update the kiocb with progress made. Typically
60 * ki_retry is set in the AIO core and it itself calls file_operations
61 * helpers.
62 *
63 * ki_retry's return value determines when the AIO operation is completed
64 * and an event is generated in the AIO event ring. Except the special
65 * return values described below, the value that is returned from ki_retry
66 * is transferred directly into the completion ring as the operation's
67 * resulting status. Once this has happened ki_retry *MUST NOT* reference
68 * the kiocb pointer again.
69 *
70 * If ki_retry returns -EIOCBQUEUED it has made a promise that aio_complete()
71 * will be called on the kiocb pointer in the future. The AIO core will
72 * not ask the method again -- ki_retry must ensure forward progress.
73 * aio_complete() must be called once and only once in the future, multiple
74 * calls may result in undefined behaviour.
75 *
76 * If ki_retry returns -EIOCBRETRY it has made a promise that kick_iocb()
77 * will be called on the kiocb pointer in the future. This may happen
78 * through generic helpers that associate kiocb->ki_wait with a wait
79 * queue head that ki_retry uses via current->io_wait. It can also happen
80 * with custom tracking and manual calls to kick_iocb(), though that is
81 * discouraged. In either case, kick_iocb() must be called once and only
82 * once. ki_retry must ensure forward progress, the AIO core will wait
83 * indefinitely for kick_iocb() to be called.
84 */
46struct kiocb { 85struct kiocb {
47 struct list_head ki_run_list; 86 struct list_head ki_run_list;
48 long ki_flags; 87 long ki_flags;
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 9f374cfa1b05..e7d0593bb576 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -76,6 +76,13 @@ struct atm_dev_stats {
76 /* set interface ESI */ 76 /* set interface ESI */
77#define ATM_SETESIF _IOW('a',ATMIOC_ITF+13,struct atmif_sioc) 77#define ATM_SETESIF _IOW('a',ATMIOC_ITF+13,struct atmif_sioc)
78 /* force interface ESI */ 78 /* force interface ESI */
79#define ATM_ADDLECSADDR _IOW('a', ATMIOC_ITF+14, struct atmif_sioc)
80 /* register a LECS address */
81#define ATM_DELLECSADDR _IOW('a', ATMIOC_ITF+15, struct atmif_sioc)
82 /* unregister a LECS address */
83#define ATM_GETLECSADDR _IOW('a', ATMIOC_ITF+16, struct atmif_sioc)
84 /* retrieve LECS address(es) */
85
79#define ATM_GETSTAT _IOW('a',ATMIOC_SARCOM+0,struct atmif_sioc) 86#define ATM_GETSTAT _IOW('a',ATMIOC_SARCOM+0,struct atmif_sioc)
80 /* get AAL layer statistics */ 87 /* get AAL layer statistics */
81#define ATM_GETSTATZ _IOW('a',ATMIOC_SARCOM+1,struct atmif_sioc) 88#define ATM_GETSTATZ _IOW('a',ATMIOC_SARCOM+1,struct atmif_sioc)
@@ -328,6 +335,8 @@ struct atm_dev_addr {
328 struct list_head entry; /* next address */ 335 struct list_head entry; /* next address */
329}; 336};
330 337
338enum atm_addr_type_t { ATM_ADDR_LOCAL, ATM_ADDR_LECS };
339
331struct atm_dev { 340struct atm_dev {
332 const struct atmdev_ops *ops; /* device operations; NULL if unused */ 341 const struct atmdev_ops *ops; /* device operations; NULL if unused */
333 const struct atmphy_ops *phy; /* PHY operations, may be undefined */ 342 const struct atmphy_ops *phy; /* PHY operations, may be undefined */
@@ -338,6 +347,7 @@ struct atm_dev {
338 void *phy_data; /* private PHY date */ 347 void *phy_data; /* private PHY date */
339 unsigned long flags; /* device flags (ATM_DF_*) */ 348 unsigned long flags; /* device flags (ATM_DF_*) */
340 struct list_head local; /* local ATM addresses */ 349 struct list_head local; /* local ATM addresses */
350 struct list_head lecs; /* LECS ATM addresses learned via ILMI */
341 unsigned char esi[ESI_LEN]; /* ESI ("MAC" addr) */ 351 unsigned char esi[ESI_LEN]; /* ESI ("MAC" addr) */
342 struct atm_cirange ci_range; /* VPI/VCI range */ 352 struct atm_cirange ci_range; /* VPI/VCI range */
343 struct k_atm_dev_stats stats; /* statistics */ 353 struct k_atm_dev_stats stats; /* statistics */
@@ -457,7 +467,7 @@ static inline void atm_dev_put(struct atm_dev *dev)
457 467
458int atm_charge(struct atm_vcc *vcc,int truesize); 468int atm_charge(struct atm_vcc *vcc,int truesize);
459struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, 469struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
460 int gfp_flags); 470 gfp_t gfp_flags);
461int atm_pcr_goal(struct atm_trafprm *tp); 471int atm_pcr_goal(struct atm_trafprm *tp);
462 472
463void vcc_release_async(struct atm_vcc *vcc, int reply); 473void vcc_release_async(struct atm_vcc *vcc, int reply);
diff --git a/include/linux/bfs_fs.h b/include/linux/bfs_fs.h
index c1237aa92e38..8ed6dfdcd783 100644
--- a/include/linux/bfs_fs.h
+++ b/include/linux/bfs_fs.h
@@ -20,19 +20,19 @@
20 20
21/* BFS inode layout on disk */ 21/* BFS inode layout on disk */
22struct bfs_inode { 22struct bfs_inode {
23 __u16 i_ino; 23 __le16 i_ino;
24 __u16 i_unused; 24 __u16 i_unused;
25 __u32 i_sblock; 25 __le32 i_sblock;
26 __u32 i_eblock; 26 __le32 i_eblock;
27 __u32 i_eoffset; 27 __le32 i_eoffset;
28 __u32 i_vtype; 28 __le32 i_vtype;
29 __u32 i_mode; 29 __le32 i_mode;
30 __s32 i_uid; 30 __le32 i_uid;
31 __s32 i_gid; 31 __le32 i_gid;
32 __u32 i_nlink; 32 __le32 i_nlink;
33 __u32 i_atime; 33 __le32 i_atime;
34 __u32 i_mtime; 34 __le32 i_mtime;
35 __u32 i_ctime; 35 __le32 i_ctime;
36 __u32 i_padding[4]; 36 __u32 i_padding[4];
37}; 37};
38 38
@@ -41,17 +41,17 @@ struct bfs_inode {
41#define BFS_DIRS_PER_BLOCK 32 41#define BFS_DIRS_PER_BLOCK 32
42 42
43struct bfs_dirent { 43struct bfs_dirent {
44 __u16 ino; 44 __le16 ino;
45 char name[BFS_NAMELEN]; 45 char name[BFS_NAMELEN];
46}; 46};
47 47
48/* BFS superblock layout on disk */ 48/* BFS superblock layout on disk */
49struct bfs_super_block { 49struct bfs_super_block {
50 __u32 s_magic; 50 __le32 s_magic;
51 __u32 s_start; 51 __le32 s_start;
52 __u32 s_end; 52 __le32 s_end;
53 __s32 s_from; 53 __le32 s_from;
54 __s32 s_to; 54 __le32 s_to;
55 __s32 s_bfrom; 55 __s32 s_bfrom;
56 __s32 s_bto; 56 __s32 s_bto;
57 char s_fsname[6]; 57 char s_fsname[6];
@@ -66,15 +66,15 @@ struct bfs_super_block {
66#define BFS_INO2OFF(ino) \ 66#define BFS_INO2OFF(ino) \
67 ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE) 67 ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE)
68#define BFS_NZFILESIZE(ip) \ 68#define BFS_NZFILESIZE(ip) \
69 ((cpu_to_le32((ip)->i_eoffset) + 1) - cpu_to_le32((ip)->i_sblock) * BFS_BSIZE) 69 ((le32_to_cpu((ip)->i_eoffset) + 1) - le32_to_cpu((ip)->i_sblock) * BFS_BSIZE)
70 70
71#define BFS_FILESIZE(ip) \ 71#define BFS_FILESIZE(ip) \
72 ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip)) 72 ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip))
73 73
74#define BFS_FILEBLOCKS(ip) \ 74#define BFS_FILEBLOCKS(ip) \
75 ((ip)->i_sblock == 0 ? 0 : (cpu_to_le32((ip)->i_eblock) + 1) - cpu_to_le32((ip)->i_sblock)) 75 ((ip)->i_sblock == 0 ? 0 : (le32_to_cpu((ip)->i_eblock) + 1) - le32_to_cpu((ip)->i_sblock))
76#define BFS_UNCLEAN(bfs_sb, sb) \ 76#define BFS_UNCLEAN(bfs_sb, sb) \
77 ((cpu_to_le32(bfs_sb->s_from) != -1) && (cpu_to_le32(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY)) 77 ((le32_to_cpu(bfs_sb->s_from) != -1) && (le32_to_cpu(bfs_sb->s_to) != -1) && !(sb->s_flags & MS_RDONLY))
78 78
79 79
80#endif /* _LINUX_BFS_FS_H */ 80#endif /* _LINUX_BFS_FS_H */
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 6e1c79c8b6bf..3344b4e8e43a 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -276,8 +276,8 @@ extern void bio_pair_release(struct bio_pair *dbio);
276extern struct bio_set *bioset_create(int, int, int); 276extern struct bio_set *bioset_create(int, int, int);
277extern void bioset_free(struct bio_set *); 277extern void bioset_free(struct bio_set *);
278 278
279extern struct bio *bio_alloc(unsigned int __nocast, int); 279extern struct bio *bio_alloc(gfp_t, int);
280extern struct bio *bio_alloc_bioset(unsigned int __nocast, int, struct bio_set *); 280extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *);
281extern void bio_put(struct bio *); 281extern void bio_put(struct bio *);
282extern void bio_free(struct bio *, struct bio_set *); 282extern void bio_free(struct bio *, struct bio_set *);
283 283
@@ -287,7 +287,7 @@ extern int bio_phys_segments(struct request_queue *, struct bio *);
287extern int bio_hw_segments(struct request_queue *, struct bio *); 287extern int bio_hw_segments(struct request_queue *, struct bio *);
288 288
289extern void __bio_clone(struct bio *, struct bio *); 289extern void __bio_clone(struct bio *, struct bio *);
290extern struct bio *bio_clone(struct bio *, unsigned int __nocast); 290extern struct bio *bio_clone(struct bio *, gfp_t);
291 291
292extern void bio_init(struct bio *); 292extern void bio_init(struct bio *);
293 293
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 82bd8842d11c..3b03b0b868dd 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -43,7 +43,7 @@ typedef struct bootmem_data {
43extern unsigned long __init bootmem_bootmap_pages (unsigned long); 43extern unsigned long __init bootmem_bootmap_pages (unsigned long);
44extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend); 44extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
45extern void __init free_bootmem (unsigned long addr, unsigned long size); 45extern void __init free_bootmem (unsigned long addr, unsigned long size);
46extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal); 46extern void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, unsigned long limit);
47#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE 47#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
48extern void __init reserve_bootmem (unsigned long addr, unsigned long size); 48extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
49#define alloc_bootmem(x) \ 49#define alloc_bootmem(x) \
@@ -54,6 +54,16 @@ extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
54 __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 54 __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
55#define alloc_bootmem_low_pages(x) \ 55#define alloc_bootmem_low_pages(x) \
56 __alloc_bootmem((x), PAGE_SIZE, 0) 56 __alloc_bootmem((x), PAGE_SIZE, 0)
57
58#define alloc_bootmem_limit(x, limit) \
59 __alloc_bootmem_limit((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit))
60#define alloc_bootmem_low_limit(x, limit) \
61 __alloc_bootmem_limit((x), SMP_CACHE_BYTES, 0, (limit))
62#define alloc_bootmem_pages_limit(x, limit) \
63 __alloc_bootmem_limit((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit))
64#define alloc_bootmem_low_pages_limit(x, limit) \
65 __alloc_bootmem_limit((x), PAGE_SIZE, 0, (limit))
66
57#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ 67#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
58extern unsigned long __init free_all_bootmem (void); 68extern unsigned long __init free_all_bootmem (void);
59 69
@@ -61,7 +71,7 @@ extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long f
61extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size); 71extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size);
62extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size); 72extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size);
63extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat); 73extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat);
64extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal); 74extern void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal, unsigned long limit);
65#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE 75#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
66#define alloc_bootmem_node(pgdat, x) \ 76#define alloc_bootmem_node(pgdat, x) \
67 __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 77 __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
@@ -69,6 +79,14 @@ extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size,
69 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 79 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
70#define alloc_bootmem_low_pages_node(pgdat, x) \ 80#define alloc_bootmem_low_pages_node(pgdat, x) \
71 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0) 81 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)
82
83#define alloc_bootmem_node_limit(pgdat, x, limit) \
84 __alloc_bootmem_node_limit((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit))
85#define alloc_bootmem_pages_node_limit(pgdat, x, limit) \
86 __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit))
87#define alloc_bootmem_low_pages_node_limit(pgdat, x, limit) \
88 __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, 0, (limit))
89
72#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ 90#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
73 91
74#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP 92#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
@@ -105,5 +123,15 @@ extern void *__init alloc_large_system_hash(const char *tablename,
105#endif 123#endif
106extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */ 124extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */
107 125
126static inline void *__alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal)
127{
128 return __alloc_bootmem_limit(size, align, goal, 0);
129}
130
131static inline void *__alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align,
132 unsigned long goal)
133{
134 return __alloc_bootmem_node_limit(pgdat, size, align, goal, 0);
135}
108 136
109#endif /* _LINUX_BOOTMEM_H */ 137#endif /* _LINUX_BOOTMEM_H */
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 90828493791f..6a1d154c0825 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -172,7 +172,7 @@ void __brelse(struct buffer_head *);
172void __bforget(struct buffer_head *); 172void __bforget(struct buffer_head *);
173void __breadahead(struct block_device *, sector_t block, int size); 173void __breadahead(struct block_device *, sector_t block, int size);
174struct buffer_head *__bread(struct block_device *, sector_t block, int size); 174struct buffer_head *__bread(struct block_device *, sector_t block, int size);
175struct buffer_head *alloc_buffer_head(unsigned int __nocast gfp_flags); 175struct buffer_head *alloc_buffer_head(gfp_t gfp_flags);
176void free_buffer_head(struct buffer_head * bh); 176void free_buffer_head(struct buffer_head * bh);
177void FASTCALL(unlock_buffer(struct buffer_head *bh)); 177void FASTCALL(unlock_buffer(struct buffer_head *bh));
178void FASTCALL(__lock_buffer(struct buffer_head *bh)); 178void FASTCALL(__lock_buffer(struct buffer_head *bh));
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index 5fde6f4d6c1e..04bd756efc67 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -5,6 +5,10 @@
5 * linux/byteorder_generic.h 5 * linux/byteorder_generic.h
6 * Generic Byte-reordering support 6 * Generic Byte-reordering support
7 * 7 *
8 * The "... p" macros, like le64_to_cpup, can be used with pointers
9 * to unaligned data, but there will be a performance penalty on
10 * some architectures. Use get_unaligned for unaligned data.
11 *
8 * Francois-Rene Rideau <fare@tunes.org> 19970707 12 * Francois-Rene Rideau <fare@tunes.org> 19970707
9 * gathered all the good ideas from all asm-foo/byteorder.h into one file, 13 * gathered all the good ideas from all asm-foo/byteorder.h into one file,
10 * cleaned them up. 14 * cleaned them up.
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 96de26301f84..95952cc1f525 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -104,12 +104,19 @@ struct cn_queue_dev {
104 struct sock *nls; 104 struct sock *nls;
105}; 105};
106 106
107struct cn_callback { 107struct cn_callback_id {
108 unsigned char name[CN_CBQ_NAMELEN]; 108 unsigned char name[CN_CBQ_NAMELEN];
109
110 struct cb_id id; 109 struct cb_id id;
110};
111
112struct cn_callback_data {
113 void (*destruct_data) (void *);
114 void *ddata;
115
116 void *callback_priv;
111 void (*callback) (void *); 117 void (*callback) (void *);
112 void *priv; 118
119 void *free;
113}; 120};
114 121
115struct cn_callback_entry { 122struct cn_callback_entry {
@@ -118,8 +125,8 @@ struct cn_callback_entry {
118 struct work_struct work; 125 struct work_struct work;
119 struct cn_queue_dev *pdev; 126 struct cn_queue_dev *pdev;
120 127
121 void (*destruct_data) (void *); 128 struct cn_callback_id id;
122 void *ddata; 129 struct cn_callback_data data;
123 130
124 int seq, group; 131 int seq, group;
125 struct sock *nls; 132 struct sock *nls;
@@ -142,9 +149,9 @@ struct cn_dev {
142 149
143int cn_add_callback(struct cb_id *, char *, void (*callback) (void *)); 150int cn_add_callback(struct cb_id *, char *, void (*callback) (void *));
144void cn_del_callback(struct cb_id *); 151void cn_del_callback(struct cb_id *);
145int cn_netlink_send(struct cn_msg *, u32, int); 152int cn_netlink_send(struct cn_msg *, u32, gfp_t);
146 153
147int cn_queue_add_callback(struct cn_queue_dev *dev, struct cn_callback *cb); 154int cn_queue_add_callback(struct cn_queue_dev *dev, char *name, struct cb_id *id, void (*callback)(void *));
148void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id); 155void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id);
149 156
150struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *); 157struct cn_queue_dev *cn_queue_alloc_dev(char *name, struct sock *);
@@ -152,6 +159,8 @@ void cn_queue_free_dev(struct cn_queue_dev *dev);
152 159
153int cn_cb_equal(struct cb_id *, struct cb_id *); 160int cn_cb_equal(struct cb_id *, struct cb_id *);
154 161
162void cn_queue_wrapper(void *data);
163
155extern int cn_already_initialized; 164extern int cn_already_initialized;
156 165
157#endif /* __KERNEL__ */ 166#endif /* __KERNEL__ */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index b15826f6e3a2..9bdba8169b41 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -392,4 +392,14 @@ extern cpumask_t cpu_present_map;
392#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map) 392#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
393#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map) 393#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
394 394
395/* Find the highest possible smp_processor_id() */
396#define highest_possible_processor_id() \
397({ \
398 unsigned int cpu, highest = 0; \
399 for_each_cpu_mask(cpu, cpu_possible_map) \
400 highest = cpu; \
401 highest; \
402})
403
404
395#endif /* __LINUX_CPUMASK_H */ 405#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 24062a1dbf61..6e2deef96b34 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -23,7 +23,7 @@ void cpuset_init_current_mems_allowed(void);
23void cpuset_update_current_mems_allowed(void); 23void cpuset_update_current_mems_allowed(void);
24void cpuset_restrict_to_mems_allowed(unsigned long *nodes); 24void cpuset_restrict_to_mems_allowed(unsigned long *nodes);
25int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); 25int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl);
26extern int cpuset_zone_allowed(struct zone *z, unsigned int __nocast gfp_mask); 26extern int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask);
27extern int cpuset_excl_nodes_overlap(const struct task_struct *p); 27extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
28extern struct file_operations proc_cpuset_operations; 28extern struct file_operations proc_cpuset_operations;
29extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); 29extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
@@ -49,8 +49,7 @@ static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
49 return 1; 49 return 1;
50} 50}
51 51
52static inline int cpuset_zone_allowed(struct zone *z, 52static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
53 unsigned int __nocast gfp_mask)
54{ 53{
55 return 1; 54 return 1;
56} 55}
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 8bf4bacb5051..71fab4311e92 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -4,16 +4,6 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <asm/byteorder.h> 5#include <asm/byteorder.h>
6 6
7/* Structure describing an Internet (DCCP) socket address. */
8struct sockaddr_dccp {
9 __u16 sdccp_family; /* Address family */
10 __u16 sdccp_port; /* Port number */
11 __u32 sdccp_addr; /* Internet address */
12 __u32 sdccp_service; /* Service */
13 /* Pad to size of `struct sockaddr': 16 bytes . */
14 __u32 sdccp_pad;
15};
16
17/** 7/**
18 * struct dccp_hdr - generic part of DCCP packet header 8 * struct dccp_hdr - generic part of DCCP packet header
19 * 9 *
@@ -188,6 +178,11 @@ enum {
188 178
189/* DCCP socket options */ 179/* DCCP socket options */
190#define DCCP_SOCKOPT_PACKET_SIZE 1 180#define DCCP_SOCKOPT_PACKET_SIZE 1
181#define DCCP_SOCKOPT_SERVICE 2
182#define DCCP_SOCKOPT_CCID_RX_INFO 128
183#define DCCP_SOCKOPT_CCID_TX_INFO 192
184
185#define DCCP_SERVICE_LIST_MAX_LEN 32
191 186
192#ifdef __KERNEL__ 187#ifdef __KERNEL__
193 188
@@ -337,7 +332,8 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb)
337 */ 332 */
338struct dccp_options { 333struct dccp_options {
339 __u64 dccpo_sequence_window; 334 __u64 dccpo_sequence_window;
340 __u8 dccpo_ccid; 335 __u8 dccpo_rx_ccid;
336 __u8 dccpo_tx_ccid;
341 __u8 dccpo_send_ack_vector; 337 __u8 dccpo_send_ack_vector;
342 __u8 dccpo_send_ndp_count; 338 __u8 dccpo_send_ndp_count;
343}; 339};
@@ -360,14 +356,8 @@ static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
360 356
361extern struct inet_timewait_death_row dccp_death_row; 357extern struct inet_timewait_death_row dccp_death_row;
362 358
363/* Read about the ECN nonce to see why it is 253 */
364#define DCCP_MAX_ACK_VECTOR_LEN 253
365
366struct dccp_options_received { 359struct dccp_options_received {
367 u32 dccpor_ndp:24, 360 u32 dccpor_ndp; /* only 24 bits */
368 dccpor_ack_vector_len:8;
369 u32 dccpor_ack_vector_idx:10;
370 /* 22 bits hole, try to pack */
371 u32 dccpor_timestamp; 361 u32 dccpor_timestamp;
372 u32 dccpor_timestamp_echo; 362 u32 dccpor_timestamp_echo;
373 u32 dccpor_elapsed_time; 363 u32 dccpor_elapsed_time;
@@ -382,6 +372,27 @@ enum dccp_role {
382 DCCP_ROLE_SERVER, 372 DCCP_ROLE_SERVER,
383}; 373};
384 374
375struct dccp_service_list {
376 __u32 dccpsl_nr;
377 __u32 dccpsl_list[0];
378};
379
380#define DCCP_SERVICE_INVALID_VALUE htonl((__u32)-1)
381
382static inline int dccp_list_has_service(const struct dccp_service_list *sl,
383 const u32 service)
384{
385 if (likely(sl != NULL)) {
386 u32 i = sl->dccpsl_nr;
387 while (i--)
388 if (sl->dccpsl_list[i] == service)
389 return 1;
390 }
391 return 0;
392}
393
394struct dccp_ackvec;
395
385/** 396/**
386 * struct dccp_sock - DCCP socket state 397 * struct dccp_sock - DCCP socket state
387 * 398 *
@@ -402,7 +413,7 @@ enum dccp_role {
402 * @dccps_packet_size - Set thru setsockopt 413 * @dccps_packet_size - Set thru setsockopt
403 * @dccps_role - Role of this sock, one of %dccp_role 414 * @dccps_role - Role of this sock, one of %dccp_role
404 * @dccps_ndp_count - number of Non Data Packets since last data packet 415 * @dccps_ndp_count - number of Non Data Packets since last data packet
405 * @dccps_hc_rx_ackpkts - receiver half connection acked packets 416 * @dccps_hc_rx_ackvec - rx half connection ack vector
406 */ 417 */
407struct dccp_sock { 418struct dccp_sock {
408 /* inet_connection_sock has to be the first member of dccp_sock */ 419 /* inet_connection_sock has to be the first member of dccp_sock */
@@ -417,7 +428,8 @@ struct dccp_sock {
417 __u64 dccps_gss; 428 __u64 dccps_gss;
418 __u64 dccps_gsr; 429 __u64 dccps_gsr;
419 __u64 dccps_gar; 430 __u64 dccps_gar;
420 unsigned long dccps_service; 431 __u32 dccps_service;
432 struct dccp_service_list *dccps_service_list;
421 struct timeval dccps_timestamp_time; 433 struct timeval dccps_timestamp_time;
422 __u32 dccps_timestamp_echo; 434 __u32 dccps_timestamp_echo;
423 __u32 dccps_packet_size; 435 __u32 dccps_packet_size;
@@ -426,7 +438,7 @@ struct dccp_sock {
426 __u32 dccps_pmtu_cookie; 438 __u32 dccps_pmtu_cookie;
427 __u32 dccps_mss_cache; 439 __u32 dccps_mss_cache;
428 struct dccp_options dccps_options; 440 struct dccp_options dccps_options;
429 struct dccp_ackpkts *dccps_hc_rx_ackpkts; 441 struct dccp_ackvec *dccps_hc_rx_ackvec;
430 void *dccps_hc_rx_ccid_private; 442 void *dccps_hc_rx_ccid_private;
431 void *dccps_hc_tx_ccid_private; 443 void *dccps_hc_tx_ccid_private;
432 struct ccid *dccps_hc_rx_ccid; 444 struct ccid *dccps_hc_rx_ccid;
@@ -443,6 +455,11 @@ static inline struct dccp_sock *dccp_sk(const struct sock *sk)
443 return (struct dccp_sock *)sk; 455 return (struct dccp_sock *)sk;
444} 456}
445 457
458static inline int dccp_service_not_initialized(const struct sock *sk)
459{
460 return dccp_sk(sk)->dccps_service == DCCP_SERVICE_INVALID_VALUE;
461}
462
446static inline const char *dccp_role(const struct sock *sk) 463static inline const char *dccp_role(const struct sock *sk)
447{ 464{
448 switch (dccp_sk(sk)->dccps_role) { 465 switch (dccp_sk(sk)->dccps_role) {
diff --git a/include/linux/device.h b/include/linux/device.h
index 06e5d42f2c7b..95d607a48f06 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -317,6 +317,11 @@ dev_set_drvdata (struct device *dev, void *data)
317 dev->driver_data = data; 317 dev->driver_data = data;
318} 318}
319 319
320static inline int device_is_registered(struct device *dev)
321{
322 return klist_node_attached(&dev->knode_bus);
323}
324
320/* 325/*
321 * High level routines for use by the bus drivers 326 * High level routines for use by the bus drivers
322 */ 327 */
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h
index 4932ee5c77f0..76f12f46db7f 100644
--- a/include/linux/dmapool.h
+++ b/include/linux/dmapool.h
@@ -19,7 +19,7 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
19 19
20void dma_pool_destroy(struct dma_pool *pool); 20void dma_pool_destroy(struct dma_pool *pool);
21 21
22void *dma_pool_alloc(struct dma_pool *pool, unsigned int __nocast mem_flags, 22void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
23 dma_addr_t *handle); 23 dma_addr_t *handle);
24 24
25void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr); 25void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 4dc990f3b5cc..3010e172394d 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -85,9 +85,9 @@ static inline void arch_free_page(struct page *page, int order) { }
85#endif 85#endif
86 86
87extern struct page * 87extern struct page *
88FASTCALL(__alloc_pages(unsigned int, unsigned int, struct zonelist *)); 88FASTCALL(__alloc_pages(gfp_t, unsigned int, struct zonelist *));
89 89
90static inline struct page *alloc_pages_node(int nid, unsigned int __nocast gfp_mask, 90static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
91 unsigned int order) 91 unsigned int order)
92{ 92{
93 if (unlikely(order >= MAX_ORDER)) 93 if (unlikely(order >= MAX_ORDER))
@@ -98,17 +98,17 @@ static inline struct page *alloc_pages_node(int nid, unsigned int __nocast gfp_m
98} 98}
99 99
100#ifdef CONFIG_NUMA 100#ifdef CONFIG_NUMA
101extern struct page *alloc_pages_current(unsigned int __nocast gfp_mask, unsigned order); 101extern struct page *alloc_pages_current(gfp_t gfp_mask, unsigned order);
102 102
103static inline struct page * 103static inline struct page *
104alloc_pages(unsigned int __nocast gfp_mask, unsigned int order) 104alloc_pages(gfp_t gfp_mask, unsigned int order)
105{ 105{
106 if (unlikely(order >= MAX_ORDER)) 106 if (unlikely(order >= MAX_ORDER))
107 return NULL; 107 return NULL;
108 108
109 return alloc_pages_current(gfp_mask, order); 109 return alloc_pages_current(gfp_mask, order);
110} 110}
111extern struct page *alloc_page_vma(unsigned __nocast gfp_mask, 111extern struct page *alloc_page_vma(gfp_t gfp_mask,
112 struct vm_area_struct *vma, unsigned long addr); 112 struct vm_area_struct *vma, unsigned long addr);
113#else 113#else
114#define alloc_pages(gfp_mask, order) \ 114#define alloc_pages(gfp_mask, order) \
@@ -117,8 +117,8 @@ extern struct page *alloc_page_vma(unsigned __nocast gfp_mask,
117#endif 117#endif
118#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) 118#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
119 119
120extern unsigned long FASTCALL(__get_free_pages(unsigned int __nocast gfp_mask, unsigned int order)); 120extern unsigned long FASTCALL(__get_free_pages(gfp_t gfp_mask, unsigned int order));
121extern unsigned long FASTCALL(get_zeroed_page(unsigned int __nocast gfp_mask)); 121extern unsigned long FASTCALL(get_zeroed_page(gfp_t gfp_mask));
122 122
123#define __get_free_page(gfp_mask) \ 123#define __get_free_page(gfp_mask) \
124 __get_free_pages((gfp_mask),0) 124 __get_free_pages((gfp_mask),0)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index e670b0d13fe0..d664330d900e 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -25,6 +25,8 @@ int is_hugepage_mem_enough(size_t);
25unsigned long hugetlb_total_pages(void); 25unsigned long hugetlb_total_pages(void);
26struct page *alloc_huge_page(void); 26struct page *alloc_huge_page(void);
27void free_huge_page(struct page *); 27void free_huge_page(struct page *);
28int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
29 unsigned long address, int write_access);
28 30
29extern unsigned long max_huge_pages; 31extern unsigned long max_huge_pages;
30extern const unsigned long hugetlb_zero, hugetlb_infinity; 32extern const unsigned long hugetlb_zero, hugetlb_infinity;
@@ -99,6 +101,7 @@ static inline unsigned long hugetlb_total_pages(void)
99 do { } while (0) 101 do { } while (0)
100#define alloc_huge_page() ({ NULL; }) 102#define alloc_huge_page() ({ NULL; })
101#define free_huge_page(p) ({ (void)(p); BUG(); }) 103#define free_huge_page(p) ({ (void)(p); BUG(); })
104#define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; })
102 105
103#ifndef HPAGE_MASK 106#ifndef HPAGE_MASK
104#define HPAGE_MASK 0 /* Keep the compiler happy */ 107#define HPAGE_MASK 0 /* Keep the compiler happy */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index be35332b67e6..3d49a305bf88 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -230,11 +230,6 @@ struct i2c_adapter {
230 struct device dev; /* the adapter device */ 230 struct device dev; /* the adapter device */
231 struct class_device class_dev; /* the class device */ 231 struct class_device class_dev; /* the class device */
232 232
233#ifdef CONFIG_PROC_FS
234 /* No need to set this when you initialize the adapter */
235 int inode;
236#endif /* def CONFIG_PROC_FS */
237
238 int nr; 233 int nr;
239 struct list_head clients; 234 struct list_head clients;
240 struct list_head list; 235 struct list_head list;
diff --git a/include/linux/idr.h b/include/linux/idr.h
index ca3b7e462576..3d5de45f961b 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -75,4 +75,5 @@ int idr_pre_get(struct idr *idp, unsigned gfp_mask);
75int idr_get_new(struct idr *idp, void *ptr, int *id); 75int idr_get_new(struct idr *idp, void *ptr, int *id);
76int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); 76int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
77void idr_remove(struct idr *idp, int id); 77void idr_remove(struct idr *idp, int id);
78void idr_destroy(struct idr *idp);
78void idr_init(struct idr *idp); 79void idr_init(struct idr *idp);
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index fc2d4c8225aa..d21c305c6c64 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -111,7 +111,9 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
111 return (struct ethhdr *)skb->mac.raw; 111 return (struct ethhdr *)skb->mac.raw;
112} 112}
113 113
114#ifdef CONFIG_SYSCTL
114extern struct ctl_table ether_table[]; 115extern struct ctl_table ether_table[];
115#endif 116#endif
117#endif
116 118
117#endif /* _LINUX_IF_ETHER_H */ 119#endif /* _LINUX_IF_ETHER_H */
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 17d0c0d40b0e..eef0876d8307 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -42,8 +42,8 @@ struct hlist_node;
42struct vlan_ethhdr { 42struct vlan_ethhdr {
43 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 43 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
44 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 44 unsigned char h_source[ETH_ALEN]; /* source ether addr */
45 unsigned short h_vlan_proto; /* Should always be 0x8100 */ 45 __be16 h_vlan_proto; /* Should always be 0x8100 */
46 unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID */ 46 __be16 h_vlan_TCI; /* Encapsulates priority and VLAN ID */
47 unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */ 47 unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */
48}; 48};
49 49
@@ -55,8 +55,8 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
55} 55}
56 56
57struct vlan_hdr { 57struct vlan_hdr {
58 unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID */ 58 __be16 h_vlan_TCI; /* Encapsulates priority and VLAN ID */
59 unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */ 59 __be16 h_vlan_encapsulated_proto; /* packet type ID field (or len) */
60}; 60};
61 61
62#define VLAN_VID_MASK 0xfff 62#define VLAN_VID_MASK 0xfff
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 7e1e15f934f3..fd7af86151b1 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -142,13 +142,21 @@ static __inline__ int bad_mask(u32 mask, u32 addr)
142 142
143#define endfor_ifa(in_dev) } 143#define endfor_ifa(in_dev) }
144 144
145static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
146{
147 struct in_device *in_dev = dev->ip_ptr;
148 if (in_dev)
149 in_dev = rcu_dereference(in_dev);
150 return in_dev;
151}
152
145static __inline__ struct in_device * 153static __inline__ struct in_device *
146in_dev_get(const struct net_device *dev) 154in_dev_get(const struct net_device *dev)
147{ 155{
148 struct in_device *in_dev; 156 struct in_device *in_dev;
149 157
150 rcu_read_lock(); 158 rcu_read_lock();
151 in_dev = dev->ip_ptr; 159 in_dev = __in_dev_get_rcu(dev);
152 if (in_dev) 160 if (in_dev)
153 atomic_inc(&in_dev->refcnt); 161 atomic_inc(&in_dev->refcnt);
154 rcu_read_unlock(); 162 rcu_read_unlock();
@@ -156,7 +164,7 @@ in_dev_get(const struct net_device *dev)
156} 164}
157 165
158static __inline__ struct in_device * 166static __inline__ struct in_device *
159__in_dev_get(const struct net_device *dev) 167__in_dev_get_rtnl(const struct net_device *dev)
160{ 168{
161 return (struct in_device*)dev->ip_ptr; 169 return (struct in_device*)dev->ip_ptr;
162} 170}
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index bb6f88e14061..e0b922785d98 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -372,8 +372,9 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
372#define inet_v6_ipv6only(__sk) 0 372#define inet_v6_ipv6only(__sk) 0
373#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ 373#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
374 374
375#define INET6_MATCH(__sk, __saddr, __daddr, __ports, __dif) \ 375#define INET6_MATCH(__sk, __hash, __saddr, __daddr, __ports, __dif)\
376 (((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 376 (((__sk)->sk_hash == (__hash)) && \
377 ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \
377 ((__sk)->sk_family == AF_INET6) && \ 378 ((__sk)->sk_family == AF_INET6) && \
378 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ 379 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \
379 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \ 380 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index de097269bd7f..ff853b3173c6 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -935,7 +935,7 @@ void journal_put_journal_head(struct journal_head *jh);
935 */ 935 */
936extern kmem_cache_t *jbd_handle_cache; 936extern kmem_cache_t *jbd_handle_cache;
937 937
938static inline handle_t *jbd_alloc_handle(unsigned int __nocast gfp_flags) 938static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
939{ 939{
940 return kmem_cache_alloc(jbd_handle_cache, gfp_flags); 940 return kmem_cache_alloc(jbd_handle_cache, gfp_flags);
941} 941}
diff --git a/include/linux/joystick.h b/include/linux/joystick.h
index 06b9af77eb7f..5fd20ddd7ae3 100644
--- a/include/linux/joystick.h
+++ b/include/linux/joystick.h
@@ -111,29 +111,30 @@ struct js_corr {
111#define JS_SET_ALL 8 111#define JS_SET_ALL 8
112 112
113struct JS_DATA_TYPE { 113struct JS_DATA_TYPE {
114 __s32 buttons; 114 int32_t buttons;
115 __s32 x; 115 int32_t x;
116 __s32 y; 116 int32_t y;
117}; 117};
118 118
119struct JS_DATA_SAVE_TYPE_32 { 119struct JS_DATA_SAVE_TYPE_32 {
120 __s32 JS_TIMEOUT; 120 int32_t JS_TIMEOUT;
121 __s32 BUSY; 121 int32_t BUSY;
122 __s32 JS_EXPIRETIME; 122 int32_t JS_EXPIRETIME;
123 __s32 JS_TIMELIMIT; 123 int32_t JS_TIMELIMIT;
124 struct JS_DATA_TYPE JS_SAVE; 124 struct JS_DATA_TYPE JS_SAVE;
125 struct JS_DATA_TYPE JS_CORR; 125 struct JS_DATA_TYPE JS_CORR;
126}; 126};
127 127
128struct JS_DATA_SAVE_TYPE_64 { 128struct JS_DATA_SAVE_TYPE_64 {
129 __s32 JS_TIMEOUT; 129 int32_t JS_TIMEOUT;
130 __s32 BUSY; 130 int32_t BUSY;
131 __s64 JS_EXPIRETIME; 131 int64_t JS_EXPIRETIME;
132 __s64 JS_TIMELIMIT; 132 int64_t JS_TIMELIMIT;
133 struct JS_DATA_TYPE JS_SAVE; 133 struct JS_DATA_TYPE JS_SAVE;
134 struct JS_DATA_TYPE JS_CORR; 134 struct JS_DATA_TYPE JS_CORR;
135}; 135};
136 136
137#ifdef __KERNEL__
137#if BITS_PER_LONG == 64 138#if BITS_PER_LONG == 64
138#define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_64 139#define JS_DATA_SAVE_TYPE JS_DATA_SAVE_TYPE_64
139#elif BITS_PER_LONG == 32 140#elif BITS_PER_LONG == 32
@@ -141,5 +142,6 @@ struct JS_DATA_SAVE_TYPE_64 {
141#else 142#else
142#error Unexpected BITS_PER_LONG 143#error Unexpected BITS_PER_LONG
143#endif 144#endif
145#endif
144 146
145#endif /* _LINUX_JOYSTICK_H */ 147#endif /* _LINUX_JOYSTICK_H */
diff --git a/include/linux/key-ui.h b/include/linux/key-ui.h
index cc326174a808..7a2e332067c3 100644
--- a/include/linux/key-ui.h
+++ b/include/linux/key-ui.h
@@ -38,92 +38,21 @@ struct keyring_list {
38 struct key *keys[0]; 38 struct key *keys[0];
39}; 39};
40 40
41
42/* 41/*
43 * check to see whether permission is granted to use a key in the desired way 42 * check to see whether permission is granted to use a key in the desired way
44 */ 43 */
45static inline int key_permission(const struct key *key, key_perm_t perm) 44extern int key_task_permission(const key_ref_t key_ref,
46{ 45 struct task_struct *context,
47 key_perm_t kperm; 46 key_perm_t perm);
48
49 if (key->uid == current->fsuid)
50 kperm = key->perm >> 16;
51 else if (key->gid != -1 &&
52 key->perm & KEY_GRP_ALL &&
53 in_group_p(key->gid)
54 )
55 kperm = key->perm >> 8;
56 else
57 kperm = key->perm;
58
59 kperm = kperm & perm & KEY_ALL;
60
61 return kperm == perm;
62}
63
64/*
65 * check to see whether permission is granted to use a key in at least one of
66 * the desired ways
67 */
68static inline int key_any_permission(const struct key *key, key_perm_t perm)
69{
70 key_perm_t kperm;
71
72 if (key->uid == current->fsuid)
73 kperm = key->perm >> 16;
74 else if (key->gid != -1 &&
75 key->perm & KEY_GRP_ALL &&
76 in_group_p(key->gid)
77 )
78 kperm = key->perm >> 8;
79 else
80 kperm = key->perm;
81 47
82 kperm = kperm & perm & KEY_ALL; 48static inline int key_permission(const key_ref_t key_ref, key_perm_t perm)
83
84 return kperm != 0;
85}
86
87static inline int key_task_groups_search(struct task_struct *tsk, gid_t gid)
88{ 49{
89 int ret; 50 return key_task_permission(key_ref, current, perm);
90
91 task_lock(tsk);
92 ret = groups_search(tsk->group_info, gid);
93 task_unlock(tsk);
94 return ret;
95}
96
97static inline int key_task_permission(const struct key *key,
98 struct task_struct *context,
99 key_perm_t perm)
100{
101 key_perm_t kperm;
102
103 if (key->uid == context->fsuid) {
104 kperm = key->perm >> 16;
105 }
106 else if (key->gid != -1 &&
107 key->perm & KEY_GRP_ALL && (
108 key->gid == context->fsgid ||
109 key_task_groups_search(context, key->gid)
110 )
111 ) {
112 kperm = key->perm >> 8;
113 }
114 else {
115 kperm = key->perm;
116 }
117
118 kperm = kperm & perm & KEY_ALL;
119
120 return kperm == perm;
121
122} 51}
123 52
124extern struct key *lookup_user_key(struct task_struct *context, 53extern key_ref_t lookup_user_key(struct task_struct *context,
125 key_serial_t id, int create, int partial, 54 key_serial_t id, int create, int partial,
126 key_perm_t perm); 55 key_perm_t perm);
127 56
128extern long join_session_keyring(const char *name); 57extern long join_session_keyring(const char *name);
129 58
diff --git a/include/linux/key.h b/include/linux/key.h
index 970bbd916cf4..f1efa016dbf3 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -35,11 +35,18 @@ struct key;
35 35
36#undef KEY_DEBUGGING 36#undef KEY_DEBUGGING
37 37
38#define KEY_USR_VIEW 0x00010000 /* user can view a key's attributes */ 38#define KEY_POS_VIEW 0x01000000 /* possessor can view a key's attributes */
39#define KEY_USR_READ 0x00020000 /* user can read key payload / view keyring */ 39#define KEY_POS_READ 0x02000000 /* possessor can read key payload / view keyring */
40#define KEY_USR_WRITE 0x00040000 /* user can update key payload / add link to keyring */ 40#define KEY_POS_WRITE 0x04000000 /* possessor can update key payload / add link to keyring */
41#define KEY_USR_SEARCH 0x00080000 /* user can find a key in search / search a keyring */ 41#define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */
42#define KEY_USR_LINK 0x00100000 /* user can create a link to a key/keyring */ 42#define KEY_POS_LINK 0x10000000 /* possessor can create a link to a key/keyring */
43#define KEY_POS_ALL 0x1f000000
44
45#define KEY_USR_VIEW 0x00010000 /* user permissions... */
46#define KEY_USR_READ 0x00020000
47#define KEY_USR_WRITE 0x00040000
48#define KEY_USR_SEARCH 0x00080000
49#define KEY_USR_LINK 0x00100000
43#define KEY_USR_ALL 0x001f0000 50#define KEY_USR_ALL 0x001f0000
44 51
45#define KEY_GRP_VIEW 0x00000100 /* group permissions... */ 52#define KEY_GRP_VIEW 0x00000100 /* group permissions... */
@@ -67,6 +74,38 @@ struct keyring_name;
67 74
68/*****************************************************************************/ 75/*****************************************************************************/
69/* 76/*
77 * key reference with possession attribute handling
78 *
79 * NOTE! key_ref_t is a typedef'd pointer to a type that is not actually
80 * defined. This is because we abuse the bottom bit of the reference to carry a
81 * flag to indicate whether the calling process possesses that key in one of
82 * its keyrings.
83 *
84 * the key_ref_t has been made a separate type so that the compiler can reject
85 * attempts to dereference it without proper conversion.
86 *
87 * the three functions are used to assemble and disassemble references
88 */
89typedef struct __key_reference_with_attributes *key_ref_t;
90
91static inline key_ref_t make_key_ref(const struct key *key,
92 unsigned long possession)
93{
94 return (key_ref_t) ((unsigned long) key | possession);
95}
96
97static inline struct key *key_ref_to_ptr(const key_ref_t key_ref)
98{
99 return (struct key *) ((unsigned long) key_ref & ~1UL);
100}
101
102static inline unsigned long is_key_possessed(const key_ref_t key_ref)
103{
104 return (unsigned long) key_ref & 1UL;
105}
106
107/*****************************************************************************/
108/*
70 * authentication token / access credential / keyring 109 * authentication token / access credential / keyring
71 * - types of key include: 110 * - types of key include:
72 * - keyrings 111 * - keyrings
@@ -215,20 +254,25 @@ static inline struct key *key_get(struct key *key)
215 return key; 254 return key;
216} 255}
217 256
257static inline void key_ref_put(key_ref_t key_ref)
258{
259 key_put(key_ref_to_ptr(key_ref));
260}
261
218extern struct key *request_key(struct key_type *type, 262extern struct key *request_key(struct key_type *type,
219 const char *description, 263 const char *description,
220 const char *callout_info); 264 const char *callout_info);
221 265
222extern int key_validate(struct key *key); 266extern int key_validate(struct key *key);
223 267
224extern struct key *key_create_or_update(struct key *keyring, 268extern key_ref_t key_create_or_update(key_ref_t keyring,
225 const char *type, 269 const char *type,
226 const char *description, 270 const char *description,
227 const void *payload, 271 const void *payload,
228 size_t plen, 272 size_t plen,
229 int not_in_quota); 273 int not_in_quota);
230 274
231extern int key_update(struct key *key, 275extern int key_update(key_ref_t key,
232 const void *payload, 276 const void *payload,
233 size_t plen); 277 size_t plen);
234 278
@@ -243,9 +287,9 @@ extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
243 287
244extern int keyring_clear(struct key *keyring); 288extern int keyring_clear(struct key *keyring);
245 289
246extern struct key *keyring_search(struct key *keyring, 290extern key_ref_t keyring_search(key_ref_t keyring,
247 struct key_type *type, 291 struct key_type *type,
248 const char *description); 292 const char *description);
249 293
250extern int keyring_add_key(struct key *keyring, 294extern int keyring_add_key(struct key *keyring,
251 struct key *key); 295 struct key *key);
@@ -285,6 +329,10 @@ extern void key_init(void);
285#define key_serial(k) 0 329#define key_serial(k) 0
286#define key_get(k) ({ NULL; }) 330#define key_get(k) ({ NULL; })
287#define key_put(k) do { } while(0) 331#define key_put(k) do { } while(0)
332#define key_ref_put(k) do { } while(0)
333#define make_key_ref(k) ({ NULL; })
334#define key_ref_to_ptr(k) ({ NULL; })
335#define is_key_possessed(k) 0
288#define alloc_uid_keyring(u) 0 336#define alloc_uid_keyring(u) 0
289#define switch_uid_keyring(u) do { } while(0) 337#define switch_uid_keyring(u) do { } while(0)
290#define __install_session_keyring(t, k) ({ NULL; }) 338#define __install_session_keyring(t, k) ({ NULL; })
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index c27cd428d269..48eccd865bd8 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -35,8 +35,8 @@ struct kfifo {
35}; 35};
36 36
37extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size, 37extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
38 unsigned int __nocast gfp_mask, spinlock_t *lock); 38 gfp_t gfp_mask, spinlock_t *lock);
39extern struct kfifo *kfifo_alloc(unsigned int size, unsigned int __nocast gfp_mask, 39extern struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask,
40 spinlock_t *lock); 40 spinlock_t *lock);
41extern void kfifo_free(struct kfifo *fifo); 41extern void kfifo_free(struct kfifo *fifo);
42extern unsigned int __kfifo_put(struct kfifo *fifo, 42extern unsigned int __kfifo_put(struct kfifo *fifo,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 022105c745fc..ceee1fc42c60 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -393,6 +393,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
393extern void ata_pci_remove_one (struct pci_dev *pdev); 393extern void ata_pci_remove_one (struct pci_dev *pdev);
394#endif /* CONFIG_PCI */ 394#endif /* CONFIG_PCI */
395extern int ata_device_add(struct ata_probe_ent *ent); 395extern int ata_device_add(struct ata_probe_ent *ent);
396extern void ata_host_set_remove(struct ata_host_set *host_set);
396extern int ata_scsi_detect(Scsi_Host_Template *sht); 397extern int ata_scsi_detect(Scsi_Host_Template *sht);
397extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 398extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
398extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 399extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
diff --git a/include/linux/list.h b/include/linux/list.h
index e6ec59682274..084971f333fe 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -442,12 +442,14 @@ static inline void list_splice_init(struct list_head *list,
442 * as long as the traversal is guarded by rcu_read_lock(). 442 * as long as the traversal is guarded by rcu_read_lock().
443 */ 443 */
444#define list_for_each_rcu(pos, head) \ 444#define list_for_each_rcu(pos, head) \
445 for (pos = (head)->next; prefetch(pos->next), pos != (head); \ 445 for (pos = (head)->next; \
446 pos = rcu_dereference(pos->next)) 446 prefetch(rcu_dereference(pos)->next), pos != (head); \
447 pos = pos->next)
447 448
448#define __list_for_each_rcu(pos, head) \ 449#define __list_for_each_rcu(pos, head) \
449 for (pos = (head)->next; pos != (head); \ 450 for (pos = (head)->next; \
450 pos = rcu_dereference(pos->next)) 451 rcu_dereference(pos) != (head); \
452 pos = pos->next)
451 453
452/** 454/**
453 * list_for_each_safe_rcu - iterate over an rcu-protected list safe 455 * list_for_each_safe_rcu - iterate over an rcu-protected list safe
@@ -461,8 +463,9 @@ static inline void list_splice_init(struct list_head *list,
461 * as long as the traversal is guarded by rcu_read_lock(). 463 * as long as the traversal is guarded by rcu_read_lock().
462 */ 464 */
463#define list_for_each_safe_rcu(pos, n, head) \ 465#define list_for_each_safe_rcu(pos, n, head) \
464 for (pos = (head)->next, n = pos->next; pos != (head); \ 466 for (pos = (head)->next; \
465 pos = rcu_dereference(n), n = pos->next) 467 n = rcu_dereference(pos)->next, pos != (head); \
468 pos = n)
466 469
467/** 470/**
468 * list_for_each_entry_rcu - iterate over rcu list of given type 471 * list_for_each_entry_rcu - iterate over rcu list of given type
@@ -474,11 +477,11 @@ static inline void list_splice_init(struct list_head *list,
474 * the _rcu list-mutation primitives such as list_add_rcu() 477 * the _rcu list-mutation primitives such as list_add_rcu()
475 * as long as the traversal is guarded by rcu_read_lock(). 478 * as long as the traversal is guarded by rcu_read_lock().
476 */ 479 */
477#define list_for_each_entry_rcu(pos, head, member) \ 480#define list_for_each_entry_rcu(pos, head, member) \
478 for (pos = list_entry((head)->next, typeof(*pos), member); \ 481 for (pos = list_entry((head)->next, typeof(*pos), member); \
479 prefetch(pos->member.next), &pos->member != (head); \ 482 prefetch(rcu_dereference(pos)->member.next), \
480 pos = rcu_dereference(list_entry(pos->member.next, \ 483 &pos->member != (head); \
481 typeof(*pos), member))) 484 pos = list_entry(pos->member.next, typeof(*pos), member))
482 485
483 486
484/** 487/**
@@ -492,8 +495,9 @@ static inline void list_splice_init(struct list_head *list,
492 * as long as the traversal is guarded by rcu_read_lock(). 495 * as long as the traversal is guarded by rcu_read_lock().
493 */ 496 */
494#define list_for_each_continue_rcu(pos, head) \ 497#define list_for_each_continue_rcu(pos, head) \
495 for ((pos) = (pos)->next; prefetch((pos)->next), (pos) != (head); \ 498 for ((pos) = (pos)->next; \
496 (pos) = rcu_dereference((pos)->next)) 499 prefetch(rcu_dereference((pos))->next), (pos) != (head); \
500 (pos) = (pos)->next)
497 501
498/* 502/*
499 * Double linked lists with a single pointer list head. 503 * Double linked lists with a single pointer list head.
@@ -696,8 +700,9 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
696 pos = n) 700 pos = n)
697 701
698#define hlist_for_each_rcu(pos, head) \ 702#define hlist_for_each_rcu(pos, head) \
699 for ((pos) = (head)->first; pos && ({ prefetch((pos)->next); 1; }); \ 703 for ((pos) = (head)->first; \
700 (pos) = rcu_dereference((pos)->next)) 704 rcu_dereference((pos)) && ({ prefetch((pos)->next); 1; }); \
705 (pos) = (pos)->next)
701 706
702/** 707/**
703 * hlist_for_each_entry - iterate over list of given type 708 * hlist_for_each_entry - iterate over list of given type
@@ -762,9 +767,9 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
762 */ 767 */
763#define hlist_for_each_entry_rcu(tpos, pos, head, member) \ 768#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
764 for (pos = (head)->first; \ 769 for (pos = (head)->first; \
765 pos && ({ prefetch(pos->next); 1;}) && \ 770 rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \
766 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 771 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
767 pos = rcu_dereference(pos->next)) 772 pos = pos->next)
768 773
769#else 774#else
770#warning "don't include kernel headers in userspace" 775#warning "don't include kernel headers in userspace"
diff --git a/include/linux/mempool.h b/include/linux/mempool.h
index 796220ce47cc..f2427d7394b0 100644
--- a/include/linux/mempool.h
+++ b/include/linux/mempool.h
@@ -6,7 +6,7 @@
6 6
7#include <linux/wait.h> 7#include <linux/wait.h>
8 8
9typedef void * (mempool_alloc_t)(unsigned int __nocast gfp_mask, void *pool_data); 9typedef void * (mempool_alloc_t)(gfp_t gfp_mask, void *pool_data);
10typedef void (mempool_free_t)(void *element, void *pool_data); 10typedef void (mempool_free_t)(void *element, void *pool_data);
11 11
12typedef struct mempool_s { 12typedef struct mempool_s {
@@ -26,17 +26,16 @@ extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
26extern mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn, 26extern mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn,
27 mempool_free_t *free_fn, void *pool_data, int nid); 27 mempool_free_t *free_fn, void *pool_data, int nid);
28 28
29extern int mempool_resize(mempool_t *pool, int new_min_nr, 29extern int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask);
30 unsigned int __nocast gfp_mask);
31extern void mempool_destroy(mempool_t *pool); 30extern void mempool_destroy(mempool_t *pool);
32extern void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask); 31extern void * mempool_alloc(mempool_t *pool, gfp_t gfp_mask);
33extern void mempool_free(void *element, mempool_t *pool); 32extern void mempool_free(void *element, mempool_t *pool);
34 33
35/* 34/*
36 * A mempool_alloc_t and mempool_free_t that get the memory from 35 * A mempool_alloc_t and mempool_free_t that get the memory from
37 * a slab that is passed in through pool_data. 36 * a slab that is passed in through pool_data.
38 */ 37 */
39void *mempool_alloc_slab(unsigned int __nocast gfp_mask, void *pool_data); 38void *mempool_alloc_slab(gfp_t gfp_mask, void *pool_data);
40void mempool_free_slab(void *element, void *pool_data); 39void mempool_free_slab(void *element, void *pool_data);
41 40
42#endif /* _LINUX_MEMPOOL_H */ 41#endif /* _LINUX_MEMPOOL_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 82d7024f0765..097b3a3c693d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -136,6 +136,7 @@ extern unsigned int kobjsize(const void *objp);
136#define VM_EXEC 0x00000004 136#define VM_EXEC 0x00000004
137#define VM_SHARED 0x00000008 137#define VM_SHARED 0x00000008
138 138
139/* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
139#define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */ 140#define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */
140#define VM_MAYWRITE 0x00000020 141#define VM_MAYWRITE 0x00000020
141#define VM_MAYEXEC 0x00000040 142#define VM_MAYEXEC 0x00000040
@@ -350,7 +351,8 @@ static inline void put_page(struct page *page)
350 * only one copy in memory, at most, normally. 351 * only one copy in memory, at most, normally.
351 * 352 *
352 * For the non-reserved pages, page_count(page) denotes a reference count. 353 * For the non-reserved pages, page_count(page) denotes a reference count.
353 * page_count() == 0 means the page is free. 354 * page_count() == 0 means the page is free. page->lru is then used for
355 * freelist management in the buddy allocator.
354 * page_count() == 1 means the page is used for exactly one purpose 356 * page_count() == 1 means the page is used for exactly one purpose
355 * (e.g. a private data page of one process). 357 * (e.g. a private data page of one process).
356 * 358 *
@@ -376,10 +378,8 @@ static inline void put_page(struct page *page)
376 * attaches, plus 1 if `private' contains something, plus one for 378 * attaches, plus 1 if `private' contains something, plus one for
377 * the page cache itself. 379 * the page cache itself.
378 * 380 *
379 * All pages belonging to an inode are in these doubly linked lists: 381 * Instead of keeping dirty/clean pages in per address-space lists, we instead
380 * mapping->clean_pages, mapping->dirty_pages and mapping->locked_pages; 382 * now tag pages as dirty/under writeback in the radix tree.
381 * using the page->list list_head. These fields are also used for
382 * freelist managemet (when page_count()==0).
383 * 383 *
384 * There is also a per-mapping radix tree mapping index to the page 384 * There is also a per-mapping radix tree mapping index to the page
385 * in memory if present. The tree is rooted at mapping->root. 385 * in memory if present. The tree is rooted at mapping->root.
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 47da39ba3f03..2f0299a448f6 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -183,7 +183,7 @@ struct of_device_id
183 char name[32]; 183 char name[32];
184 char type[32]; 184 char type[32];
185 char compatible[128]; 185 char compatible[128];
186#if __KERNEL__ 186#ifdef __KERNEL__
187 void *data; 187 void *data;
188#else 188#else
189 kernel_ulong_t data; 189 kernel_ulong_t data;
@@ -209,10 +209,11 @@ struct pcmcia_device_id {
209 /* for real multi-function devices */ 209 /* for real multi-function devices */
210 __u8 function; 210 __u8 function;
211 211
212 /* for pseude multi-function devices */ 212 /* for pseudo multi-function devices */
213 __u8 device_no; 213 __u8 device_no;
214 214
215 __u32 prod_id_hash[4]; 215 __u32 prod_id_hash[4]
216 __attribute__((aligned(sizeof(__u32))));
216 217
217 /* not matched against in kernelspace*/ 218 /* not matched against in kernelspace*/
218#ifdef __KERNEL__ 219#ifdef __KERNEL__
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7c717907896d..368e4c825ff1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -265,6 +265,8 @@ struct net_device
265 * the interface. 265 * the interface.
266 */ 266 */
267 char name[IFNAMSIZ]; 267 char name[IFNAMSIZ];
268 /* device name hash chain */
269 struct hlist_node name_hlist;
268 270
269 /* 271 /*
270 * I/O specific fields 272 * I/O specific fields
@@ -292,6 +294,21 @@ struct net_device
292 294
293 /* ------- Fields preinitialized in Space.c finish here ------- */ 295 /* ------- Fields preinitialized in Space.c finish here ------- */
294 296
297 /* Net device features */
298 unsigned long features;
299#define NETIF_F_SG 1 /* Scatter/gather IO. */
300#define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */
301#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
302#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
303#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
304#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
305#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
306#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
307#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
308#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
309#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
310#define NETIF_F_LLTX 4096 /* LockLess TX */
311
295 struct net_device *next_sched; 312 struct net_device *next_sched;
296 313
297 /* Interface index. Unique device identifier */ 314 /* Interface index. Unique device identifier */
@@ -316,9 +333,6 @@ struct net_device
316 * will (read: may be cleaned up at will). 333 * will (read: may be cleaned up at will).
317 */ 334 */
318 335
319 /* These may be needed for future network-power-down code. */
320 unsigned long trans_start; /* Time (in jiffies) of last Tx */
321 unsigned long last_rx; /* Time of last Rx */
322 336
323 unsigned short flags; /* interface flags (a la BSD) */ 337 unsigned short flags; /* interface flags (a la BSD) */
324 unsigned short gflags; 338 unsigned short gflags;
@@ -328,15 +342,12 @@ struct net_device
328 unsigned mtu; /* interface MTU value */ 342 unsigned mtu; /* interface MTU value */
329 unsigned short type; /* interface hardware type */ 343 unsigned short type; /* interface hardware type */
330 unsigned short hard_header_len; /* hardware hdr length */ 344 unsigned short hard_header_len; /* hardware hdr length */
331 void *priv; /* pointer to private data */
332 345
333 struct net_device *master; /* Pointer to master device of a group, 346 struct net_device *master; /* Pointer to master device of a group,
334 * which this device is member of. 347 * which this device is member of.
335 */ 348 */
336 349
337 /* Interface address info. */ 350 /* Interface address info. */
338 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
339 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */
340 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 351 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
341 unsigned char addr_len; /* hardware address length */ 352 unsigned char addr_len; /* hardware address length */
342 unsigned short dev_id; /* for shared network cards */ 353 unsigned short dev_id; /* for shared network cards */
@@ -346,8 +357,6 @@ struct net_device
346 int promiscuity; 357 int promiscuity;
347 int allmulti; 358 int allmulti;
348 359
349 int watchdog_timeo;
350 struct timer_list watchdog_timer;
351 360
352 /* Protocol specific pointers */ 361 /* Protocol specific pointers */
353 362
@@ -358,32 +367,62 @@ struct net_device
358 void *ec_ptr; /* Econet specific data */ 367 void *ec_ptr; /* Econet specific data */
359 void *ax25_ptr; /* AX.25 specific data */ 368 void *ax25_ptr; /* AX.25 specific data */
360 369
361 struct list_head poll_list; /* Link to poll list */ 370/*
371 * Cache line mostly used on receive path (including eth_type_trans())
372 */
373 struct list_head poll_list ____cacheline_aligned_in_smp;
374 /* Link to poll list */
375
376 int (*poll) (struct net_device *dev, int *quota);
362 int quota; 377 int quota;
363 int weight; 378 int weight;
379 unsigned long last_rx; /* Time of last Rx */
380 /* Interface address info used in eth_type_trans() */
381 unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast
382 because most packets are unicast) */
383
384 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
364 385
386/*
387 * Cache line mostly used on queue transmit path (qdisc)
388 */
389 /* device queue lock */
390 spinlock_t queue_lock ____cacheline_aligned_in_smp;
365 struct Qdisc *qdisc; 391 struct Qdisc *qdisc;
366 struct Qdisc *qdisc_sleeping; 392 struct Qdisc *qdisc_sleeping;
367 struct Qdisc *qdisc_ingress;
368 struct list_head qdisc_list; 393 struct list_head qdisc_list;
369 unsigned long tx_queue_len; /* Max frames per queue allowed */ 394 unsigned long tx_queue_len; /* Max frames per queue allowed */
370 395
371 /* ingress path synchronizer */ 396 /* ingress path synchronizer */
372 spinlock_t ingress_lock; 397 spinlock_t ingress_lock;
398 struct Qdisc *qdisc_ingress;
399
400/*
401 * One part is mostly used on xmit path (device)
402 */
373 /* hard_start_xmit synchronizer */ 403 /* hard_start_xmit synchronizer */
374 spinlock_t xmit_lock; 404 spinlock_t xmit_lock ____cacheline_aligned_in_smp;
375 /* cpu id of processor entered to hard_start_xmit or -1, 405 /* cpu id of processor entered to hard_start_xmit or -1,
376 if nobody entered there. 406 if nobody entered there.
377 */ 407 */
378 int xmit_lock_owner; 408 int xmit_lock_owner;
379 /* device queue lock */ 409 void *priv; /* pointer to private data */
380 spinlock_t queue_lock; 410 int (*hard_start_xmit) (struct sk_buff *skb,
411 struct net_device *dev);
412 /* These may be needed for future network-power-down code. */
413 unsigned long trans_start; /* Time (in jiffies) of last Tx */
414
415 int watchdog_timeo; /* used by dev_watchdog() */
416 struct timer_list watchdog_timer;
417
418/*
419 * refcnt is a very hot point, so align it on SMP
420 */
381 /* Number of references to this device */ 421 /* Number of references to this device */
382 atomic_t refcnt; 422 atomic_t refcnt ____cacheline_aligned_in_smp;
423
383 /* delayed register/unregister */ 424 /* delayed register/unregister */
384 struct list_head todo_list; 425 struct list_head todo_list;
385 /* device name hash chain */
386 struct hlist_node name_hlist;
387 /* device index hash chain */ 426 /* device index hash chain */
388 struct hlist_node index_hlist; 427 struct hlist_node index_hlist;
389 428
@@ -396,21 +435,6 @@ struct net_device
396 NETREG_RELEASED, /* called free_netdev */ 435 NETREG_RELEASED, /* called free_netdev */
397 } reg_state; 436 } reg_state;
398 437
399 /* Net device features */
400 unsigned long features;
401#define NETIF_F_SG 1 /* Scatter/gather IO. */
402#define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */
403#define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */
404#define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */
405#define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */
406#define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */
407#define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */
408#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
409#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
410#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
411#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
412#define NETIF_F_LLTX 4096 /* LockLess TX */
413
414 /* Called after device is detached from network. */ 438 /* Called after device is detached from network. */
415 void (*uninit)(struct net_device *dev); 439 void (*uninit)(struct net_device *dev);
416 /* Called after last user reference disappears. */ 440 /* Called after last user reference disappears. */
@@ -419,10 +443,7 @@ struct net_device
419 /* Pointers to interface service routines. */ 443 /* Pointers to interface service routines. */
420 int (*open)(struct net_device *dev); 444 int (*open)(struct net_device *dev);
421 int (*stop)(struct net_device *dev); 445 int (*stop)(struct net_device *dev);
422 int (*hard_start_xmit) (struct sk_buff *skb,
423 struct net_device *dev);
424#define HAVE_NETDEV_POLL 446#define HAVE_NETDEV_POLL
425 int (*poll) (struct net_device *dev, int *quota);
426 int (*hard_header) (struct sk_buff *skb, 447 int (*hard_header) (struct sk_buff *skb,
427 struct net_device *dev, 448 struct net_device *dev,
428 unsigned short type, 449 unsigned short type,
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 1d5b10ae2399..f08e870100f4 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -41,11 +41,15 @@ enum nfnetlink_groups {
41struct nfattr 41struct nfattr
42{ 42{
43 u_int16_t nfa_len; 43 u_int16_t nfa_len;
44 u_int16_t nfa_type; 44 u_int16_t nfa_type; /* we use 15 bits for the type, and the highest
45 * bit to indicate whether the payload is nested */
45} __attribute__ ((packed)); 46} __attribute__ ((packed));
46 47
47/* FIXME: Shamelessly copy and pasted from rtnetlink.h, it's time 48/* FIXME: Apart from NFNL_NFA_NESTED shamelessly copy and pasted from
48 * to put this in a generic file */ 49 * rtnetlink.h, it's time to put this in a generic file */
50
51#define NFNL_NFA_NEST 0x8000
52#define NFA_TYPE(attr) ((attr)->nfa_type & 0x7fff)
49 53
50#define NFA_ALIGNTO 4 54#define NFA_ALIGNTO 4
51#define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1)) 55#define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1))
@@ -59,7 +63,7 @@ struct nfattr
59#define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0)) 63#define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0))
60#define NFA_NEST(skb, type) \ 64#define NFA_NEST(skb, type) \
61({ struct nfattr *__start = (struct nfattr *) (skb)->tail; \ 65({ struct nfattr *__start = (struct nfattr *) (skb)->tail; \
62 NFA_PUT(skb, type, 0, NULL); \ 66 NFA_PUT(skb, (NFNL_NFA_NEST | type), 0, NULL); \
63 __start; }) 67 __start; })
64#define NFA_NEST_END(skb, start) \ 68#define NFA_NEST_END(skb, start) \
65({ (start)->nfa_len = ((skb)->tail - (unsigned char *) (start)); \ 69({ (start)->nfa_len = ((skb)->tail - (unsigned char *) (start)); \
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index 5c55751c78e4..116fcaced909 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -70,15 +70,24 @@ enum ctattr_l4proto {
70 70
71enum ctattr_protoinfo { 71enum ctattr_protoinfo {
72 CTA_PROTOINFO_UNSPEC, 72 CTA_PROTOINFO_UNSPEC,
73 CTA_PROTOINFO_TCP_STATE, 73 CTA_PROTOINFO_TCP,
74 __CTA_PROTOINFO_MAX 74 __CTA_PROTOINFO_MAX
75}; 75};
76#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1) 76#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
77 77
78enum ctattr_protoinfo_tcp {
79 CTA_PROTOINFO_TCP_UNSPEC,
80 CTA_PROTOINFO_TCP_STATE,
81 __CTA_PROTOINFO_TCP_MAX
82};
83#define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
84
78enum ctattr_counters { 85enum ctattr_counters {
79 CTA_COUNTERS_UNSPEC, 86 CTA_COUNTERS_UNSPEC,
80 CTA_COUNTERS_PACKETS, 87 CTA_COUNTERS_PACKETS, /* old 64bit counters */
81 CTA_COUNTERS_BYTES, 88 CTA_COUNTERS_BYTES, /* old 64bit counters */
89 CTA_COUNTERS32_PACKETS,
90 CTA_COUNTERS32_BYTES,
82 __CTA_COUNTERS_MAX 91 __CTA_COUNTERS_MAX
83}; 92};
84#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1) 93#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)
diff --git a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
index 7e033e9271a8..d078bb91d9e5 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -117,6 +117,10 @@ enum ip_conntrack_events
117 /* NAT info */ 117 /* NAT info */
118 IPCT_NATINFO_BIT = 10, 118 IPCT_NATINFO_BIT = 10,
119 IPCT_NATINFO = (1 << IPCT_NATINFO_BIT), 119 IPCT_NATINFO = (1 << IPCT_NATINFO_BIT),
120
121 /* Counter highest bit has been set */
122 IPCT_COUNTER_FILLING_BIT = 11,
123 IPCT_COUNTER_FILLING = (1 << IPCT_COUNTER_FILLING_BIT),
120}; 124};
121 125
122enum ip_conntrack_expect_events { 126enum ip_conntrack_expect_events {
@@ -133,11 +137,13 @@ enum ip_conntrack_expect_events {
133 137
134#include <linux/netfilter_ipv4/ip_conntrack_tcp.h> 138#include <linux/netfilter_ipv4/ip_conntrack_tcp.h>
135#include <linux/netfilter_ipv4/ip_conntrack_icmp.h> 139#include <linux/netfilter_ipv4/ip_conntrack_icmp.h>
140#include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
136#include <linux/netfilter_ipv4/ip_conntrack_sctp.h> 141#include <linux/netfilter_ipv4/ip_conntrack_sctp.h>
137 142
138/* per conntrack: protocol private data */ 143/* per conntrack: protocol private data */
139union ip_conntrack_proto { 144union ip_conntrack_proto {
140 /* insert conntrack proto private data here */ 145 /* insert conntrack proto private data here */
146 struct ip_ct_gre gre;
141 struct ip_ct_sctp sctp; 147 struct ip_ct_sctp sctp;
142 struct ip_ct_tcp tcp; 148 struct ip_ct_tcp tcp;
143 struct ip_ct_icmp icmp; 149 struct ip_ct_icmp icmp;
@@ -148,6 +154,7 @@ union ip_conntrack_expect_proto {
148}; 154};
149 155
150/* Add protocol helper include file here */ 156/* Add protocol helper include file here */
157#include <linux/netfilter_ipv4/ip_conntrack_pptp.h>
151#include <linux/netfilter_ipv4/ip_conntrack_amanda.h> 158#include <linux/netfilter_ipv4/ip_conntrack_amanda.h>
152#include <linux/netfilter_ipv4/ip_conntrack_ftp.h> 159#include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
153#include <linux/netfilter_ipv4/ip_conntrack_irc.h> 160#include <linux/netfilter_ipv4/ip_conntrack_irc.h>
@@ -155,12 +162,20 @@ union ip_conntrack_expect_proto {
155/* per conntrack: application helper private data */ 162/* per conntrack: application helper private data */
156union ip_conntrack_help { 163union ip_conntrack_help {
157 /* insert conntrack helper private data (master) here */ 164 /* insert conntrack helper private data (master) here */
165 struct ip_ct_pptp_master ct_pptp_info;
158 struct ip_ct_ftp_master ct_ftp_info; 166 struct ip_ct_ftp_master ct_ftp_info;
159 struct ip_ct_irc_master ct_irc_info; 167 struct ip_ct_irc_master ct_irc_info;
160}; 168};
161 169
162#ifdef CONFIG_IP_NF_NAT_NEEDED 170#ifdef CONFIG_IP_NF_NAT_NEEDED
163#include <linux/netfilter_ipv4/ip_nat.h> 171#include <linux/netfilter_ipv4/ip_nat.h>
172#include <linux/netfilter_ipv4/ip_nat_pptp.h>
173
174/* per conntrack: nat application helper private data */
175union ip_conntrack_nat_help {
176 /* insert nat helper private data here */
177 struct ip_nat_pptp nat_pptp_info;
178};
164#endif 179#endif
165 180
166#include <linux/types.h> 181#include <linux/types.h>
@@ -181,8 +196,8 @@ do { \
181 196
182struct ip_conntrack_counter 197struct ip_conntrack_counter
183{ 198{
184 u_int64_t packets; 199 u_int32_t packets;
185 u_int64_t bytes; 200 u_int32_t bytes;
186}; 201};
187 202
188struct ip_conntrack_helper; 203struct ip_conntrack_helper;
@@ -223,6 +238,7 @@ struct ip_conntrack
223#ifdef CONFIG_IP_NF_NAT_NEEDED 238#ifdef CONFIG_IP_NF_NAT_NEEDED
224 struct { 239 struct {
225 struct ip_nat_info info; 240 struct ip_nat_info info;
241 union ip_conntrack_nat_help help;
226#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ 242#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
227 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) 243 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE)
228 int masq_index; 244 int masq_index;
@@ -320,11 +336,28 @@ extern void need_ip_conntrack(void);
320extern int invert_tuplepr(struct ip_conntrack_tuple *inverse, 336extern int invert_tuplepr(struct ip_conntrack_tuple *inverse,
321 const struct ip_conntrack_tuple *orig); 337 const struct ip_conntrack_tuple *orig);
322 338
339extern void __ip_ct_refresh_acct(struct ip_conntrack *ct,
340 enum ip_conntrack_info ctinfo,
341 const struct sk_buff *skb,
342 unsigned long extra_jiffies,
343 int do_acct);
344
345/* Refresh conntrack for this many jiffies and do accounting */
346static inline void ip_ct_refresh_acct(struct ip_conntrack *ct,
347 enum ip_conntrack_info ctinfo,
348 const struct sk_buff *skb,
349 unsigned long extra_jiffies)
350{
351 __ip_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies, 1);
352}
353
323/* Refresh conntrack for this many jiffies */ 354/* Refresh conntrack for this many jiffies */
324extern void ip_ct_refresh_acct(struct ip_conntrack *ct, 355static inline void ip_ct_refresh(struct ip_conntrack *ct,
325 enum ip_conntrack_info ctinfo, 356 const struct sk_buff *skb,
326 const struct sk_buff *skb, 357 unsigned long extra_jiffies)
327 unsigned long extra_jiffies); 358{
359 __ip_ct_refresh_acct(ct, 0, skb, extra_jiffies, 0);
360}
328 361
329/* These are for NAT. Icky. */ 362/* These are for NAT. Icky. */
330/* Update TCP window tracking data when NAT mangles the packet */ 363/* Update TCP window tracking data when NAT mangles the packet */
@@ -372,7 +405,7 @@ extern struct ip_conntrack_expect *
372__ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple); 405__ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple);
373 406
374extern struct ip_conntrack_expect * 407extern struct ip_conntrack_expect *
375ip_conntrack_expect_find_get(const struct ip_conntrack_tuple *tuple); 408ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple);
376 409
377extern struct ip_conntrack_tuple_hash * 410extern struct ip_conntrack_tuple_hash *
378__ip_conntrack_find(const struct ip_conntrack_tuple *tuple, 411__ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_pptp.h b/include/linux/netfilter_ipv4/ip_conntrack_pptp.h
new file mode 100644
index 000000000000..816144c75de0
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_pptp.h
@@ -0,0 +1,325 @@
1/* PPTP constants and structs */
2#ifndef _CONNTRACK_PPTP_H
3#define _CONNTRACK_PPTP_H
4
5/* state of the control session */
6enum pptp_ctrlsess_state {
7 PPTP_SESSION_NONE, /* no session present */
8 PPTP_SESSION_ERROR, /* some session error */
9 PPTP_SESSION_STOPREQ, /* stop_sess request seen */
10 PPTP_SESSION_REQUESTED, /* start_sess request seen */
11 PPTP_SESSION_CONFIRMED, /* session established */
12};
13
14/* state of the call inside the control session */
15enum pptp_ctrlcall_state {
16 PPTP_CALL_NONE,
17 PPTP_CALL_ERROR,
18 PPTP_CALL_OUT_REQ,
19 PPTP_CALL_OUT_CONF,
20 PPTP_CALL_IN_REQ,
21 PPTP_CALL_IN_REP,
22 PPTP_CALL_IN_CONF,
23 PPTP_CALL_CLEAR_REQ,
24};
25
26
27/* conntrack private data */
28struct ip_ct_pptp_master {
29 enum pptp_ctrlsess_state sstate; /* session state */
30
31 /* everything below is going to be per-expectation in newnat,
32 * since there could be more than one call within one session */
33 enum pptp_ctrlcall_state cstate; /* call state */
34 u_int16_t pac_call_id; /* call id of PAC, host byte order */
35 u_int16_t pns_call_id; /* call id of PNS, host byte order */
36
37 /* in pre-2.6.11 this used to be per-expect. Now it is per-conntrack
38 * and therefore imposes a fixed limit on the number of maps */
39 struct ip_ct_gre_keymap *keymap_orig, *keymap_reply;
40};
41
42/* conntrack_expect private member */
43struct ip_ct_pptp_expect {
44 enum pptp_ctrlcall_state cstate; /* call state */
45 u_int16_t pac_call_id; /* call id of PAC */
46 u_int16_t pns_call_id; /* call id of PNS */
47};
48
49
50#ifdef __KERNEL__
51
52#define IP_CONNTR_PPTP PPTP_CONTROL_PORT
53
54#define PPTP_CONTROL_PORT 1723
55
56#define PPTP_PACKET_CONTROL 1
57#define PPTP_PACKET_MGMT 2
58
59#define PPTP_MAGIC_COOKIE 0x1a2b3c4d
60
61struct pptp_pkt_hdr {
62 __u16 packetLength;
63 __be16 packetType;
64 __be32 magicCookie;
65};
66
67/* PptpControlMessageType values */
68#define PPTP_START_SESSION_REQUEST 1
69#define PPTP_START_SESSION_REPLY 2
70#define PPTP_STOP_SESSION_REQUEST 3
71#define PPTP_STOP_SESSION_REPLY 4
72#define PPTP_ECHO_REQUEST 5
73#define PPTP_ECHO_REPLY 6
74#define PPTP_OUT_CALL_REQUEST 7
75#define PPTP_OUT_CALL_REPLY 8
76#define PPTP_IN_CALL_REQUEST 9
77#define PPTP_IN_CALL_REPLY 10
78#define PPTP_IN_CALL_CONNECT 11
79#define PPTP_CALL_CLEAR_REQUEST 12
80#define PPTP_CALL_DISCONNECT_NOTIFY 13
81#define PPTP_WAN_ERROR_NOTIFY 14
82#define PPTP_SET_LINK_INFO 15
83
84#define PPTP_MSG_MAX 15
85
86/* PptpGeneralError values */
87#define PPTP_ERROR_CODE_NONE 0
88#define PPTP_NOT_CONNECTED 1
89#define PPTP_BAD_FORMAT 2
90#define PPTP_BAD_VALUE 3
91#define PPTP_NO_RESOURCE 4
92#define PPTP_BAD_CALLID 5
93#define PPTP_REMOVE_DEVICE_ERROR 6
94
95struct PptpControlHeader {
96 __be16 messageType;
97 __u16 reserved;
98};
99
100/* FramingCapability Bitmap Values */
101#define PPTP_FRAME_CAP_ASYNC 0x1
102#define PPTP_FRAME_CAP_SYNC 0x2
103
104/* BearerCapability Bitmap Values */
105#define PPTP_BEARER_CAP_ANALOG 0x1
106#define PPTP_BEARER_CAP_DIGITAL 0x2
107
108struct PptpStartSessionRequest {
109 __be16 protocolVersion;
110 __u8 reserved1;
111 __u8 reserved2;
112 __be32 framingCapability;
113 __be32 bearerCapability;
114 __be16 maxChannels;
115 __be16 firmwareRevision;
116 __u8 hostName[64];
117 __u8 vendorString[64];
118};
119
120/* PptpStartSessionResultCode Values */
121#define PPTP_START_OK 1
122#define PPTP_START_GENERAL_ERROR 2
123#define PPTP_START_ALREADY_CONNECTED 3
124#define PPTP_START_NOT_AUTHORIZED 4
125#define PPTP_START_UNKNOWN_PROTOCOL 5
126
127struct PptpStartSessionReply {
128 __be16 protocolVersion;
129 __u8 resultCode;
130 __u8 generalErrorCode;
131 __be32 framingCapability;
132 __be32 bearerCapability;
133 __be16 maxChannels;
134 __be16 firmwareRevision;
135 __u8 hostName[64];
136 __u8 vendorString[64];
137};
138
139/* PptpStopReasons */
140#define PPTP_STOP_NONE 1
141#define PPTP_STOP_PROTOCOL 2
142#define PPTP_STOP_LOCAL_SHUTDOWN 3
143
144struct PptpStopSessionRequest {
145 __u8 reason;
146};
147
148/* PptpStopSessionResultCode */
149#define PPTP_STOP_OK 1
150#define PPTP_STOP_GENERAL_ERROR 2
151
152struct PptpStopSessionReply {
153 __u8 resultCode;
154 __u8 generalErrorCode;
155};
156
157struct PptpEchoRequest {
158 __be32 identNumber;
159};
160
161/* PptpEchoReplyResultCode */
162#define PPTP_ECHO_OK 1
163#define PPTP_ECHO_GENERAL_ERROR 2
164
165struct PptpEchoReply {
166 __be32 identNumber;
167 __u8 resultCode;
168 __u8 generalErrorCode;
169 __u16 reserved;
170};
171
172/* PptpFramingType */
173#define PPTP_ASYNC_FRAMING 1
174#define PPTP_SYNC_FRAMING 2
175#define PPTP_DONT_CARE_FRAMING 3
176
177/* PptpCallBearerType */
178#define PPTP_ANALOG_TYPE 1
179#define PPTP_DIGITAL_TYPE 2
180#define PPTP_DONT_CARE_BEARER_TYPE 3
181
182struct PptpOutCallRequest {
183 __be16 callID;
184 __be16 callSerialNumber;
185 __be32 minBPS;
186 __be32 maxBPS;
187 __be32 bearerType;
188 __be32 framingType;
189 __be16 packetWindow;
190 __be16 packetProcDelay;
191 __u16 reserved1;
192 __be16 phoneNumberLength;
193 __u16 reserved2;
194 __u8 phoneNumber[64];
195 __u8 subAddress[64];
196};
197
198/* PptpCallResultCode */
199#define PPTP_OUTCALL_CONNECT 1
200#define PPTP_OUTCALL_GENERAL_ERROR 2
201#define PPTP_OUTCALL_NO_CARRIER 3
202#define PPTP_OUTCALL_BUSY 4
203#define PPTP_OUTCALL_NO_DIAL_TONE 5
204#define PPTP_OUTCALL_TIMEOUT 6
205#define PPTP_OUTCALL_DONT_ACCEPT 7
206
207struct PptpOutCallReply {
208 __be16 callID;
209 __be16 peersCallID;
210 __u8 resultCode;
211 __u8 generalErrorCode;
212 __be16 causeCode;
213 __be32 connectSpeed;
214 __be16 packetWindow;
215 __be16 packetProcDelay;
216 __be32 physChannelID;
217};
218
219struct PptpInCallRequest {
220 __be16 callID;
221 __be16 callSerialNumber;
222 __be32 callBearerType;
223 __be32 physChannelID;
224 __be16 dialedNumberLength;
225 __be16 dialingNumberLength;
226 __u8 dialedNumber[64];
227 __u8 dialingNumber[64];
228 __u8 subAddress[64];
229};
230
231/* PptpInCallResultCode */
232#define PPTP_INCALL_ACCEPT 1
233#define PPTP_INCALL_GENERAL_ERROR 2
234#define PPTP_INCALL_DONT_ACCEPT 3
235
236struct PptpInCallReply {
237 __be16 callID;
238 __be16 peersCallID;
239 __u8 resultCode;
240 __u8 generalErrorCode;
241 __be16 packetWindow;
242 __be16 packetProcDelay;
243 __u16 reserved;
244};
245
246struct PptpInCallConnected {
247 __be16 peersCallID;
248 __u16 reserved;
249 __be32 connectSpeed;
250 __be16 packetWindow;
251 __be16 packetProcDelay;
252 __be32 callFramingType;
253};
254
255struct PptpClearCallRequest {
256 __be16 callID;
257 __u16 reserved;
258};
259
260struct PptpCallDisconnectNotify {
261 __be16 callID;
262 __u8 resultCode;
263 __u8 generalErrorCode;
264 __be16 causeCode;
265 __u16 reserved;
266 __u8 callStatistics[128];
267};
268
269struct PptpWanErrorNotify {
270 __be16 peersCallID;
271 __u16 reserved;
272 __be32 crcErrors;
273 __be32 framingErrors;
274 __be32 hardwareOverRuns;
275 __be32 bufferOverRuns;
276 __be32 timeoutErrors;
277 __be32 alignmentErrors;
278};
279
280struct PptpSetLinkInfo {
281 __be16 peersCallID;
282 __u16 reserved;
283 __be32 sendAccm;
284 __be32 recvAccm;
285};
286
287union pptp_ctrl_union {
288 struct PptpStartSessionRequest sreq;
289 struct PptpStartSessionReply srep;
290 struct PptpStopSessionRequest streq;
291 struct PptpStopSessionReply strep;
292 struct PptpOutCallRequest ocreq;
293 struct PptpOutCallReply ocack;
294 struct PptpInCallRequest icreq;
295 struct PptpInCallReply icack;
296 struct PptpInCallConnected iccon;
297 struct PptpClearCallRequest clrreq;
298 struct PptpCallDisconnectNotify disc;
299 struct PptpWanErrorNotify wanerr;
300 struct PptpSetLinkInfo setlink;
301};
302
303extern int
304(*ip_nat_pptp_hook_outbound)(struct sk_buff **pskb,
305 struct ip_conntrack *ct,
306 enum ip_conntrack_info ctinfo,
307 struct PptpControlHeader *ctlh,
308 union pptp_ctrl_union *pptpReq);
309
310extern int
311(*ip_nat_pptp_hook_inbound)(struct sk_buff **pskb,
312 struct ip_conntrack *ct,
313 enum ip_conntrack_info ctinfo,
314 struct PptpControlHeader *ctlh,
315 union pptp_ctrl_union *pptpReq);
316
317extern int
318(*ip_nat_pptp_hook_exp_gre)(struct ip_conntrack_expect *exp_orig,
319 struct ip_conntrack_expect *exp_reply);
320
321extern void
322(*ip_nat_pptp_hook_expectfn)(struct ip_conntrack *ct,
323 struct ip_conntrack_expect *exp);
324#endif /* __KERNEL__ */
325#endif /* _CONNTRACK_PPTP_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h b/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
new file mode 100644
index 000000000000..8d090ef82f5f
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
@@ -0,0 +1,114 @@
1#ifndef _CONNTRACK_PROTO_GRE_H
2#define _CONNTRACK_PROTO_GRE_H
3#include <asm/byteorder.h>
4
5/* GRE PROTOCOL HEADER */
6
7/* GRE Version field */
8#define GRE_VERSION_1701 0x0
9#define GRE_VERSION_PPTP 0x1
10
11/* GRE Protocol field */
12#define GRE_PROTOCOL_PPTP 0x880B
13
14/* GRE Flags */
15#define GRE_FLAG_C 0x80
16#define GRE_FLAG_R 0x40
17#define GRE_FLAG_K 0x20
18#define GRE_FLAG_S 0x10
19#define GRE_FLAG_A 0x80
20
21#define GRE_IS_C(f) ((f)&GRE_FLAG_C)
22#define GRE_IS_R(f) ((f)&GRE_FLAG_R)
23#define GRE_IS_K(f) ((f)&GRE_FLAG_K)
24#define GRE_IS_S(f) ((f)&GRE_FLAG_S)
25#define GRE_IS_A(f) ((f)&GRE_FLAG_A)
26
27/* GRE is a mess: Four different standards */
28struct gre_hdr {
29#if defined(__LITTLE_ENDIAN_BITFIELD)
30 __u16 rec:3,
31 srr:1,
32 seq:1,
33 key:1,
34 routing:1,
35 csum:1,
36 version:3,
37 reserved:4,
38 ack:1;
39#elif defined(__BIG_ENDIAN_BITFIELD)
40 __u16 csum:1,
41 routing:1,
42 key:1,
43 seq:1,
44 srr:1,
45 rec:3,
46 ack:1,
47 reserved:4,
48 version:3;
49#else
50#error "Adjust your <asm/byteorder.h> defines"
51#endif
52 __u16 protocol;
53};
54
55/* modified GRE header for PPTP */
56struct gre_hdr_pptp {
57 __u8 flags; /* bitfield */
58 __u8 version; /* should be GRE_VERSION_PPTP */
59 __u16 protocol; /* should be GRE_PROTOCOL_PPTP */
60 __u16 payload_len; /* size of ppp payload, not inc. gre header */
61 __u16 call_id; /* peer's call_id for this session */
62 __u32 seq; /* sequence number. Present if S==1 */
63 __u32 ack; /* seq number of highest packet recieved by */
64 /* sender in this session */
65};
66
67
68/* this is part of ip_conntrack */
69struct ip_ct_gre {
70 unsigned int stream_timeout;
71 unsigned int timeout;
72};
73
74#ifdef __KERNEL__
75struct ip_conntrack_expect;
76struct ip_conntrack;
77
78/* structure for original <-> reply keymap */
79struct ip_ct_gre_keymap {
80 struct list_head list;
81
82 struct ip_conntrack_tuple tuple;
83};
84
85/* add new tuple->key_reply pair to keymap */
86int ip_ct_gre_keymap_add(struct ip_conntrack *ct,
87 struct ip_conntrack_tuple *t,
88 int reply);
89
90/* delete keymap entries */
91void ip_ct_gre_keymap_destroy(struct ip_conntrack *ct);
92
93
94/* get pointer to gre key, if present */
95static inline u_int32_t *gre_key(struct gre_hdr *greh)
96{
97 if (!greh->key)
98 return NULL;
99 if (greh->csum || greh->routing)
100 return (u_int32_t *) (greh+sizeof(*greh)+4);
101 return (u_int32_t *) (greh+sizeof(*greh));
102}
103
104/* get pointer ot gre csum, if present */
105static inline u_int16_t *gre_csum(struct gre_hdr *greh)
106{
107 if (!greh->csum)
108 return NULL;
109 return (u_int16_t *) (greh+sizeof(*greh));
110}
111
112#endif /* __KERNEL__ */
113
114#endif /* _CONNTRACK_PROTO_GRE_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_protocol.h b/include/linux/netfilter_ipv4/ip_conntrack_protocol.h
index b6b99be8632a..2c76b879e3dc 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_protocol.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_protocol.h
@@ -52,6 +52,9 @@ struct ip_conntrack_protocol
52 int (*to_nfattr)(struct sk_buff *skb, struct nfattr *nfa, 52 int (*to_nfattr)(struct sk_buff *skb, struct nfattr *nfa,
53 const struct ip_conntrack *ct); 53 const struct ip_conntrack *ct);
54 54
55 /* convert nfnetlink attributes to protoinfo */
56 int (*from_nfattr)(struct nfattr *tb[], struct ip_conntrack *ct);
57
55 int (*tuple_to_nfattr)(struct sk_buff *skb, 58 int (*tuple_to_nfattr)(struct sk_buff *skb,
56 const struct ip_conntrack_tuple *t); 59 const struct ip_conntrack_tuple *t);
57 int (*nfattr_to_tuple)(struct nfattr *tb[], 60 int (*nfattr_to_tuple)(struct nfattr *tb[],
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_tuple.h b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h
index c33f0b5e0d0a..3232db11a4e5 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_tuple.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h
@@ -1,6 +1,8 @@
1#ifndef _IP_CONNTRACK_TUPLE_H 1#ifndef _IP_CONNTRACK_TUPLE_H
2#define _IP_CONNTRACK_TUPLE_H 2#define _IP_CONNTRACK_TUPLE_H
3 3
4#include <linux/types.h>
5
4/* A `tuple' is a structure containing the information to uniquely 6/* A `tuple' is a structure containing the information to uniquely
5 identify a connection. ie. if two packets have the same tuple, they 7 identify a connection. ie. if two packets have the same tuple, they
6 are in the same connection; if not, they are not. 8 are in the same connection; if not, they are not.
@@ -17,7 +19,7 @@ union ip_conntrack_manip_proto
17 u_int16_t all; 19 u_int16_t all;
18 20
19 struct { 21 struct {
20 u_int16_t port; 22 __be16 port;
21 } tcp; 23 } tcp;
22 struct { 24 struct {
23 u_int16_t port; 25 u_int16_t port;
@@ -28,6 +30,9 @@ union ip_conntrack_manip_proto
28 struct { 30 struct {
29 u_int16_t port; 31 u_int16_t port;
30 } sctp; 32 } sctp;
33 struct {
34 __be16 key; /* key is 32bit, pptp only uses 16 */
35 } gre;
31}; 36};
32 37
33/* The manipulable part of the tuple. */ 38/* The manipulable part of the tuple. */
@@ -61,6 +66,10 @@ struct ip_conntrack_tuple
61 struct { 66 struct {
62 u_int16_t port; 67 u_int16_t port;
63 } sctp; 68 } sctp;
69 struct {
70 __be16 key; /* key is 32bit,
71 * pptp only uses 16 */
72 } gre;
64 } u; 73 } u;
65 74
66 /* The protocol. */ 75 /* The protocol. */
diff --git a/include/linux/netfilter_ipv4/ip_nat.h b/include/linux/netfilter_ipv4/ip_nat.h
index e201ec6e9905..41a107de17cf 100644
--- a/include/linux/netfilter_ipv4/ip_nat.h
+++ b/include/linux/netfilter_ipv4/ip_nat.h
@@ -58,10 +58,6 @@ extern rwlock_t ip_nat_lock;
58struct ip_nat_info 58struct ip_nat_info
59{ 59{
60 struct list_head bysource; 60 struct list_head bysource;
61
62 /* Helper (NULL if none). */
63 struct ip_nat_helper *helper;
64
65 struct ip_nat_seq seq[IP_CT_DIR_MAX]; 61 struct ip_nat_seq seq[IP_CT_DIR_MAX];
66}; 62};
67 63
diff --git a/include/linux/netfilter_ipv4/ip_nat_core.h b/include/linux/netfilter_ipv4/ip_nat_core.h
index 3b50eb91f007..30db23f06b03 100644
--- a/include/linux/netfilter_ipv4/ip_nat_core.h
+++ b/include/linux/netfilter_ipv4/ip_nat_core.h
@@ -5,16 +5,14 @@
5 5
6/* This header used to share core functionality between the standalone 6/* This header used to share core functionality between the standalone
7 NAT module, and the compatibility layer's use of NAT for masquerading. */ 7 NAT module, and the compatibility layer's use of NAT for masquerading. */
8extern int ip_nat_init(void);
9extern void ip_nat_cleanup(void);
10 8
11extern unsigned int nat_packet(struct ip_conntrack *ct, 9extern unsigned int ip_nat_packet(struct ip_conntrack *ct,
12 enum ip_conntrack_info conntrackinfo, 10 enum ip_conntrack_info conntrackinfo,
13 unsigned int hooknum, 11 unsigned int hooknum,
14 struct sk_buff **pskb); 12 struct sk_buff **pskb);
15 13
16extern int icmp_reply_translation(struct sk_buff **pskb, 14extern int ip_nat_icmp_reply_translation(struct sk_buff **pskb,
17 struct ip_conntrack *ct, 15 struct ip_conntrack *ct,
18 enum ip_nat_manip_type manip, 16 enum ip_nat_manip_type manip,
19 enum ip_conntrack_dir dir); 17 enum ip_conntrack_dir dir);
20#endif /* _IP_NAT_CORE_H */ 18#endif /* _IP_NAT_CORE_H */
diff --git a/include/linux/netfilter_ipv4/ip_nat_pptp.h b/include/linux/netfilter_ipv4/ip_nat_pptp.h
new file mode 100644
index 000000000000..eaf66c2e8f93
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_nat_pptp.h
@@ -0,0 +1,11 @@
1/* PPTP constants and structs */
2#ifndef _NAT_PPTP_H
3#define _NAT_PPTP_H
4
5/* conntrack private data */
6struct ip_nat_pptp {
7 u_int16_t pns_call_id; /* NAT'ed PNS call id */
8 u_int16_t pac_call_id; /* NAT'ed PAC call id */
9};
10
11#endif /* _NAT_PPTP_H */
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 58c72a52dc65..59f70b34e029 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -455,6 +455,9 @@ extern unsigned int ip6t_do_table(struct sk_buff **pskb,
455 455
456/* Check for an extension */ 456/* Check for an extension */
457extern int ip6t_ext_hdr(u8 nexthdr); 457extern int ip6t_ext_hdr(u8 nexthdr);
458/* find specified header and get offset to it */
459extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
460 u8 target);
458 461
459#define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1)) 462#define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1))
460 463
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index bdebdc564506..ba25ca874c20 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -131,7 +131,7 @@ extern struct sock *netlink_kernel_create(int unit, unsigned int groups, void (*
131extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); 131extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
132extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock); 132extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
133extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid, 133extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
134 __u32 group, unsigned int __nocast allocation); 134 __u32 group, gfp_t allocation);
135extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code); 135extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
136extern int netlink_register_notifier(struct notifier_block *nb); 136extern int netlink_register_notifier(struct notifier_block *nb);
137extern int netlink_unregister_notifier(struct notifier_block *nb); 137extern int netlink_unregister_notifier(struct notifier_block *nb);
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 5ade54a78dbb..ca5a8733000f 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -86,7 +86,7 @@ static inline void netpoll_poll_unlock(void *have)
86 86
87#else 87#else
88#define netpoll_rx(a) 0 88#define netpoll_rx(a) 0
89#define netpoll_poll_lock(a) 0 89#define netpoll_poll_lock(a) NULL
90#define netpoll_poll_unlock(a) 90#define netpoll_poll_unlock(a)
91#endif 91#endif
92 92
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index d9a25647a295..acbf31c154f8 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -19,7 +19,7 @@
19#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */ 19#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */
20#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */ 20#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */
21 21
22static inline unsigned int __nocast mapping_gfp_mask(struct address_space * mapping) 22static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
23{ 23{
24 return mapping->flags & __GFP_BITS_MASK; 24 return mapping->flags & __GFP_BITS_MASK;
25} 25}
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 486d1c1676bd..71834f05504f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -185,6 +185,7 @@
185#define PCI_DEVICE_ID_LSI_61C102 0x0901 185#define PCI_DEVICE_ID_LSI_61C102 0x0901
186#define PCI_DEVICE_ID_LSI_63C815 0x1000 186#define PCI_DEVICE_ID_LSI_63C815 0x1000
187#define PCI_DEVICE_ID_LSI_SAS1064 0x0050 187#define PCI_DEVICE_ID_LSI_SAS1064 0x0050
188#define PCI_DEVICE_ID_LSI_SAS1064R 0x0411
188#define PCI_DEVICE_ID_LSI_SAS1066 0x005E 189#define PCI_DEVICE_ID_LSI_SAS1066 0x005E
189#define PCI_DEVICE_ID_LSI_SAS1068 0x0054 190#define PCI_DEVICE_ID_LSI_SAS1068 0x0054
190#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C 191#define PCI_DEVICE_ID_LSI_SAS1064A 0x005C
@@ -392,6 +393,7 @@
392#define PCI_DEVICE_ID_NS_87560_USB 0x0012 393#define PCI_DEVICE_ID_NS_87560_USB 0x0012
393#define PCI_DEVICE_ID_NS_83815 0x0020 394#define PCI_DEVICE_ID_NS_83815 0x0020
394#define PCI_DEVICE_ID_NS_83820 0x0022 395#define PCI_DEVICE_ID_NS_83820 0x0022
396#define PCI_DEVICE_ID_NS_SATURN 0x0035
395#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 397#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
396#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 398#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501
397#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502 399#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502
@@ -491,6 +493,7 @@
491#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060 493#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060
492 494
493#define PCI_VENDOR_ID_AMD 0x1022 495#define PCI_VENDOR_ID_AMD 0x1022
496#define PCI_DEVICE_ID_AMD_K8_NB 0x1100
494#define PCI_DEVICE_ID_AMD_LANCE 0x2000 497#define PCI_DEVICE_ID_AMD_LANCE 0x2000
495#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 498#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
496#define PCI_DEVICE_ID_AMD_SCSI 0x2020 499#define PCI_DEVICE_ID_AMD_SCSI 0x2020
@@ -558,6 +561,7 @@
558#define PCI_VENDOR_ID_DELL 0x1028 561#define PCI_VENDOR_ID_DELL 0x1028
559#define PCI_DEVICE_ID_DELL_RACIII 0x0008 562#define PCI_DEVICE_ID_DELL_RACIII 0x0008
560#define PCI_DEVICE_ID_DELL_RAC4 0x0012 563#define PCI_DEVICE_ID_DELL_RAC4 0x0012
564#define PCI_DEVICE_ID_DELL_PERC5 0x0015
561 565
562#define PCI_VENDOR_ID_MATROX 0x102B 566#define PCI_VENDOR_ID_MATROX 0x102B
563#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 567#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518
@@ -719,6 +723,7 @@
719#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282 723#define PCI_DEVICE_ID_HP_DIVA_EVEREST 0x1282
720#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 724#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290
721#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 725#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301
726#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a
722#define PCI_DEVICE_ID_HP_CISS 0x3210 727#define PCI_DEVICE_ID_HP_CISS 0x3210
723#define PCI_DEVICE_ID_HP_CISSA 0x3220 728#define PCI_DEVICE_ID_HP_CISSA 0x3220
724#define PCI_DEVICE_ID_HP_CISSB 0x3222 729#define PCI_DEVICE_ID_HP_CISSB 0x3222
@@ -768,6 +773,8 @@
768#define PCI_DEVICE_ID_TI_TVP4010 0x3d04 773#define PCI_DEVICE_ID_TI_TVP4010 0x3d04
769#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 774#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
770#define PCI_DEVICE_ID_TI_4450 0x8011 775#define PCI_DEVICE_ID_TI_4450 0x8011
776#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031
777#define PCI_DEVICE_ID_TI_X515 0x8036
771#define PCI_DEVICE_ID_TI_1130 0xac12 778#define PCI_DEVICE_ID_TI_1130 0xac12
772#define PCI_DEVICE_ID_TI_1031 0xac13 779#define PCI_DEVICE_ID_TI_1031 0xac13
773#define PCI_DEVICE_ID_TI_1131 0xac15 780#define PCI_DEVICE_ID_TI_1131 0xac15
@@ -784,12 +791,17 @@
784#define PCI_DEVICE_ID_TI_4451 0xac42 791#define PCI_DEVICE_ID_TI_4451 0xac42
785#define PCI_DEVICE_ID_TI_4510 0xac44 792#define PCI_DEVICE_ID_TI_4510 0xac44
786#define PCI_DEVICE_ID_TI_4520 0xac46 793#define PCI_DEVICE_ID_TI_4520 0xac46
794#define PCI_DEVICE_ID_TI_7510 0xac47
795#define PCI_DEVICE_ID_TI_7610 0xac48
796#define PCI_DEVICE_ID_TI_7410 0xac49
787#define PCI_DEVICE_ID_TI_1410 0xac50 797#define PCI_DEVICE_ID_TI_1410 0xac50
788#define PCI_DEVICE_ID_TI_1420 0xac51 798#define PCI_DEVICE_ID_TI_1420 0xac51
789#define PCI_DEVICE_ID_TI_1451A 0xac52 799#define PCI_DEVICE_ID_TI_1451A 0xac52
790#define PCI_DEVICE_ID_TI_1620 0xac54 800#define PCI_DEVICE_ID_TI_1620 0xac54
791#define PCI_DEVICE_ID_TI_1520 0xac55 801#define PCI_DEVICE_ID_TI_1520 0xac55
792#define PCI_DEVICE_ID_TI_1510 0xac56 802#define PCI_DEVICE_ID_TI_1510 0xac56
803#define PCI_DEVICE_ID_TI_X620 0xac8d
804#define PCI_DEVICE_ID_TI_X420 0xac8e
793 805
794#define PCI_VENDOR_ID_SONY 0x104d 806#define PCI_VENDOR_ID_SONY 0x104d
795#define PCI_DEVICE_ID_SONY_CXD3222 0x8039 807#define PCI_DEVICE_ID_SONY_CXD3222 0x8039
@@ -975,6 +987,7 @@
975#define PCI_DEVICE_ID_SUN_SABRE 0xa000 987#define PCI_DEVICE_ID_SUN_SABRE 0xa000
976#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001 988#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001
977#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801 989#define PCI_DEVICE_ID_SUN_TOMATILLO 0xa801
990#define PCI_DEVICE_ID_SUN_CASSINI 0xabba
978 991
979#define PCI_VENDOR_ID_CMD 0x1095 992#define PCI_VENDOR_ID_CMD 0x1095
980#define PCI_DEVICE_ID_CMD_640 0x0640 993#define PCI_DEVICE_ID_CMD_640 0x0640
@@ -1267,7 +1280,8 @@
1267#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266 1280#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266
1268#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267 1281#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267
1269#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE 0x036E 1282#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE 0x036E
1270#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA 0x036F 1283#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA 0x037E
1284#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F
1271#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 1285#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268
1272#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 1286#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269
1273#define PCI_DEVICE_ID_NVIDIA_MCP51_AUDIO 0x026B 1287#define PCI_DEVICE_ID_NVIDIA_MCP51_AUDIO 0x026B
@@ -2185,7 +2199,12 @@
2185#define PCI_DEVICE_ID_ENE_1211 0x1211 2199#define PCI_DEVICE_ID_ENE_1211 0x1211
2186#define PCI_DEVICE_ID_ENE_1225 0x1225 2200#define PCI_DEVICE_ID_ENE_1225 0x1225
2187#define PCI_DEVICE_ID_ENE_1410 0x1410 2201#define PCI_DEVICE_ID_ENE_1410 0x1410
2202#define PCI_DEVICE_ID_ENE_710 0x1411
2203#define PCI_DEVICE_ID_ENE_712 0x1412
2188#define PCI_DEVICE_ID_ENE_1420 0x1420 2204#define PCI_DEVICE_ID_ENE_1420 0x1420
2205#define PCI_DEVICE_ID_ENE_720 0x1421
2206#define PCI_DEVICE_ID_ENE_722 0x1422
2207
2189#define PCI_VENDOR_ID_CHELSIO 0x1425 2208#define PCI_VENDOR_ID_CHELSIO 0x1425
2190 2209
2191#define PCI_VENDOR_ID_MIPS 0x153f 2210#define PCI_VENDOR_ID_MIPS 0x153f
@@ -2678,6 +2697,7 @@
2678 2697
2679#define PCI_SUBVENDOR_ID_EXSYS 0xd84d 2698#define PCI_SUBVENDOR_ID_EXSYS 0xd84d
2680#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 2699#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014
2700#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055
2681 2701
2682#define PCI_VENDOR_ID_TIGERJET 0xe159 2702#define PCI_VENDOR_ID_TIGERJET 0xe159
2683#define PCI_DEVICE_ID_TIGERJET_300 0x0001 2703#define PCI_DEVICE_ID_TIGERJET_300 0x0001
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 4caedddaa033..4bc241290c24 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -71,11 +71,11 @@ posix_acl_release(struct posix_acl *acl)
71 71
72/* posix_acl.c */ 72/* posix_acl.c */
73 73
74extern struct posix_acl *posix_acl_alloc(int, unsigned int __nocast); 74extern struct posix_acl *posix_acl_alloc(int, gfp_t);
75extern struct posix_acl *posix_acl_clone(const struct posix_acl *, unsigned int __nocast); 75extern struct posix_acl *posix_acl_clone(const struct posix_acl *, gfp_t);
76extern int posix_acl_valid(const struct posix_acl *); 76extern int posix_acl_valid(const struct posix_acl *);
77extern int posix_acl_permission(struct inode *, const struct posix_acl *, int); 77extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
78extern struct posix_acl *posix_acl_from_mode(mode_t, unsigned int __nocast); 78extern struct posix_acl *posix_acl_from_mode(mode_t, gfp_t);
79extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *); 79extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
80extern int posix_acl_create_masq(struct posix_acl *, mode_t *); 80extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
81extern int posix_acl_chmod_masq(struct posix_acl *, mode_t); 81extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 9c51917b1cce..045d4761febc 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -50,7 +50,7 @@ void *radix_tree_delete(struct radix_tree_root *, unsigned long);
50unsigned int 50unsigned int
51radix_tree_gang_lookup(struct radix_tree_root *root, void **results, 51radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
52 unsigned long first_index, unsigned int max_items); 52 unsigned long first_index, unsigned int max_items);
53int radix_tree_preload(unsigned int __nocast gfp_mask); 53int radix_tree_preload(gfp_t gfp_mask);
54void radix_tree_init(void); 54void radix_tree_init(void);
55void *radix_tree_tag_set(struct radix_tree_root *root, 55void *radix_tree_tag_set(struct radix_tree_root *root,
56 unsigned long index, int tag); 56 unsigned long index, int tag);
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 4e65eb44adfd..70191a5a148f 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -94,6 +94,7 @@ struct rcu_data {
94 long batch; /* Batch # for current RCU batch */ 94 long batch; /* Batch # for current RCU batch */
95 struct rcu_head *nxtlist; 95 struct rcu_head *nxtlist;
96 struct rcu_head **nxttail; 96 struct rcu_head **nxttail;
97 long count; /* # of queued items */
97 struct rcu_head *curlist; 98 struct rcu_head *curlist;
98 struct rcu_head **curtail; 99 struct rcu_head **curtail;
99 struct rcu_head *donelist; 100 struct rcu_head *donelist;
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 3b3266ff1a95..7ab2cdb83ef0 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -59,6 +59,10 @@ extern void machine_crash_shutdown(struct pt_regs *);
59 * Architecture independent implemenations of sys_reboot commands. 59 * Architecture independent implemenations of sys_reboot commands.
60 */ 60 */
61 61
62extern void kernel_restart_prepare(char *cmd);
63extern void kernel_halt_prepare(void);
64extern void kernel_power_off_prepare(void);
65
62extern void kernel_restart(char *cmd); 66extern void kernel_restart(char *cmd);
63extern void kernel_halt(void); 67extern void kernel_halt(void);
64extern void kernel_power_off(void); 68extern void kernel_power_off(void);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 49e617fa0f66..27519df0f987 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -107,13 +107,25 @@ extern unsigned long nr_iowait(void);
107 107
108#include <asm/processor.h> 108#include <asm/processor.h>
109 109
110/*
111 * Task state bitmask. NOTE! These bits are also
112 * encoded in fs/proc/array.c: get_task_state().
113 *
114 * We have two separate sets of flags: task->state
115 * is about runnability, while task->exit_state are
116 * about the task exiting. Confusing, but this way
117 * modifying one set can't modify the other one by
118 * mistake.
119 */
110#define TASK_RUNNING 0 120#define TASK_RUNNING 0
111#define TASK_INTERRUPTIBLE 1 121#define TASK_INTERRUPTIBLE 1
112#define TASK_UNINTERRUPTIBLE 2 122#define TASK_UNINTERRUPTIBLE 2
113#define TASK_STOPPED 4 123#define TASK_STOPPED 4
114#define TASK_TRACED 8 124#define TASK_TRACED 8
125/* in tsk->exit_state */
115#define EXIT_ZOMBIE 16 126#define EXIT_ZOMBIE 16
116#define EXIT_DEAD 32 127#define EXIT_DEAD 32
128/* in tsk->state again */
117#define TASK_NONINTERACTIVE 64 129#define TASK_NONINTERACTIVE 64
118 130
119#define __set_task_state(tsk, state_value) \ 131#define __set_task_state(tsk, state_value) \
@@ -1006,6 +1018,7 @@ extern int force_sig_info(int, struct siginfo *, struct task_struct *);
1006extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp); 1018extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
1007extern int kill_pg_info(int, struct siginfo *, pid_t); 1019extern int kill_pg_info(int, struct siginfo *, pid_t);
1008extern int kill_proc_info(int, struct siginfo *, pid_t); 1020extern int kill_proc_info(int, struct siginfo *, pid_t);
1021extern int kill_proc_info_as_uid(int, struct siginfo *, pid_t, uid_t, uid_t);
1009extern void do_notify_parent(struct task_struct *, int); 1022extern void do_notify_parent(struct task_struct *, int);
1010extern void force_sig(int, struct task_struct *); 1023extern void force_sig(int, struct task_struct *);
1011extern void force_sig_specific(int, struct task_struct *); 1024extern void force_sig_specific(int, struct task_struct *);
diff --git a/include/linux/security.h b/include/linux/security.h
index 0e43460d374e..627382e74057 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -2634,8 +2634,7 @@ static inline int security_socket_getpeersec(struct socket *sock, char __user *o
2634 return security_ops->socket_getpeersec(sock, optval, optlen, len); 2634 return security_ops->socket_getpeersec(sock, optval, optlen, len);
2635} 2635}
2636 2636
2637static inline int security_sk_alloc(struct sock *sk, int family, 2637static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2638 unsigned int __nocast priority)
2639{ 2638{
2640 return security_ops->sk_alloc_security(sk, family, priority); 2639 return security_ops->sk_alloc_security(sk, family, priority);
2641} 2640}
@@ -2752,8 +2751,7 @@ static inline int security_socket_getpeersec(struct socket *sock, char __user *o
2752 return -ENOPROTOOPT; 2751 return -ENOPROTOOPT;
2753} 2752}
2754 2753
2755static inline int security_sk_alloc(struct sock *sk, int family, 2754static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2756 unsigned int __nocast priority)
2757{ 2755{
2758 return 0; 2756 return 0;
2759} 2757}
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2741c0c55e83..8f5d9e7f8734 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -155,8 +155,6 @@ struct skb_shared_info {
155#define SKB_DATAREF_SHIFT 16 155#define SKB_DATAREF_SHIFT 16
156#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) 156#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
157 157
158extern struct timeval skb_tv_base;
159
160struct skb_timeval { 158struct skb_timeval {
161 u32 off_sec; 159 u32 off_sec;
162 u32 off_usec; 160 u32 off_usec;
@@ -175,7 +173,7 @@ enum {
175 * @prev: Previous buffer in list 173 * @prev: Previous buffer in list
176 * @list: List we are on 174 * @list: List we are on
177 * @sk: Socket we are owned by 175 * @sk: Socket we are owned by
178 * @tstamp: Time we arrived stored as offset to skb_tv_base 176 * @tstamp: Time we arrived
179 * @dev: Device we arrived on/are leaving by 177 * @dev: Device we arrived on/are leaving by
180 * @input_dev: Device we arrived on 178 * @input_dev: Device we arrived on
181 * @h: Transport layer header 179 * @h: Transport layer header
@@ -304,37 +302,37 @@ struct sk_buff {
304 302
305extern void __kfree_skb(struct sk_buff *skb); 303extern void __kfree_skb(struct sk_buff *skb);
306extern struct sk_buff *__alloc_skb(unsigned int size, 304extern struct sk_buff *__alloc_skb(unsigned int size,
307 unsigned int __nocast priority, int fclone); 305 gfp_t priority, int fclone);
308static inline struct sk_buff *alloc_skb(unsigned int size, 306static inline struct sk_buff *alloc_skb(unsigned int size,
309 unsigned int __nocast priority) 307 gfp_t priority)
310{ 308{
311 return __alloc_skb(size, priority, 0); 309 return __alloc_skb(size, priority, 0);
312} 310}
313 311
314static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 312static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
315 unsigned int __nocast priority) 313 gfp_t priority)
316{ 314{
317 return __alloc_skb(size, priority, 1); 315 return __alloc_skb(size, priority, 1);
318} 316}
319 317
320extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, 318extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
321 unsigned int size, 319 unsigned int size,
322 unsigned int __nocast priority); 320 gfp_t priority);
323extern void kfree_skbmem(struct sk_buff *skb); 321extern void kfree_skbmem(struct sk_buff *skb);
324extern struct sk_buff *skb_clone(struct sk_buff *skb, 322extern struct sk_buff *skb_clone(struct sk_buff *skb,
325 unsigned int __nocast priority); 323 gfp_t priority);
326extern struct sk_buff *skb_copy(const struct sk_buff *skb, 324extern struct sk_buff *skb_copy(const struct sk_buff *skb,
327 unsigned int __nocast priority); 325 gfp_t priority);
328extern struct sk_buff *pskb_copy(struct sk_buff *skb, 326extern struct sk_buff *pskb_copy(struct sk_buff *skb,
329 unsigned int __nocast gfp_mask); 327 gfp_t gfp_mask);
330extern int pskb_expand_head(struct sk_buff *skb, 328extern int pskb_expand_head(struct sk_buff *skb,
331 int nhead, int ntail, 329 int nhead, int ntail,
332 unsigned int __nocast gfp_mask); 330 gfp_t gfp_mask);
333extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, 331extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
334 unsigned int headroom); 332 unsigned int headroom);
335extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb, 333extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
336 int newheadroom, int newtailroom, 334 int newheadroom, int newtailroom,
337 unsigned int __nocast priority); 335 gfp_t priority);
338extern struct sk_buff * skb_pad(struct sk_buff *skb, int pad); 336extern struct sk_buff * skb_pad(struct sk_buff *skb, int pad);
339#define dev_kfree_skb(a) kfree_skb(a) 337#define dev_kfree_skb(a) kfree_skb(a)
340extern void skb_over_panic(struct sk_buff *skb, int len, 338extern void skb_over_panic(struct sk_buff *skb, int len,
@@ -486,7 +484,7 @@ static inline int skb_shared(const struct sk_buff *skb)
486 * NULL is returned on a memory allocation failure. 484 * NULL is returned on a memory allocation failure.
487 */ 485 */
488static inline struct sk_buff *skb_share_check(struct sk_buff *skb, 486static inline struct sk_buff *skb_share_check(struct sk_buff *skb,
489 unsigned int __nocast pri) 487 gfp_t pri)
490{ 488{
491 might_sleep_if(pri & __GFP_WAIT); 489 might_sleep_if(pri & __GFP_WAIT);
492 if (skb_shared(skb)) { 490 if (skb_shared(skb)) {
@@ -518,7 +516,7 @@ static inline struct sk_buff *skb_share_check(struct sk_buff *skb,
518 * %NULL is returned on a memory allocation failure. 516 * %NULL is returned on a memory allocation failure.
519 */ 517 */
520static inline struct sk_buff *skb_unshare(struct sk_buff *skb, 518static inline struct sk_buff *skb_unshare(struct sk_buff *skb,
521 unsigned int __nocast pri) 519 gfp_t pri)
522{ 520{
523 might_sleep_if(pri & __GFP_WAIT); 521 might_sleep_if(pri & __GFP_WAIT);
524 if (skb_cloned(skb)) { 522 if (skb_cloned(skb)) {
@@ -1019,7 +1017,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
1019 * %NULL is returned in there is no free memory. 1017 * %NULL is returned in there is no free memory.
1020 */ 1018 */
1021static inline struct sk_buff *__dev_alloc_skb(unsigned int length, 1019static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1022 unsigned int __nocast gfp_mask) 1020 gfp_t gfp_mask)
1023{ 1021{
1024 struct sk_buff *skb = alloc_skb(length + 16, gfp_mask); 1022 struct sk_buff *skb = alloc_skb(length + 16, gfp_mask);
1025 if (likely(skb)) 1023 if (likely(skb))
@@ -1132,8 +1130,8 @@ static inline int skb_can_coalesce(struct sk_buff *skb, int i,
1132 * If there is no free memory -ENOMEM is returned, otherwise zero 1130 * If there is no free memory -ENOMEM is returned, otherwise zero
1133 * is returned and the old skb data released. 1131 * is returned and the old skb data released.
1134 */ 1132 */
1135extern int __skb_linearize(struct sk_buff *skb, unsigned int __nocast gfp); 1133extern int __skb_linearize(struct sk_buff *skb, gfp_t gfp);
1136static inline int skb_linearize(struct sk_buff *skb, unsigned int __nocast gfp) 1134static inline int skb_linearize(struct sk_buff *skb, gfp_t gfp)
1137{ 1135{
1138 return __skb_linearize(skb, gfp); 1136 return __skb_linearize(skb, gfp);
1139} 1137}
@@ -1255,10 +1253,6 @@ static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *
1255{ 1253{
1256 stamp->tv_sec = skb->tstamp.off_sec; 1254 stamp->tv_sec = skb->tstamp.off_sec;
1257 stamp->tv_usec = skb->tstamp.off_usec; 1255 stamp->tv_usec = skb->tstamp.off_usec;
1258 if (skb->tstamp.off_sec) {
1259 stamp->tv_sec += skb_tv_base.tv_sec;
1260 stamp->tv_usec += skb_tv_base.tv_usec;
1261 }
1262} 1256}
1263 1257
1264/** 1258/**
@@ -1272,8 +1266,8 @@ static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *
1272 */ 1266 */
1273static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp) 1267static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp)
1274{ 1268{
1275 skb->tstamp.off_sec = stamp->tv_sec - skb_tv_base.tv_sec; 1269 skb->tstamp.off_sec = stamp->tv_sec;
1276 skb->tstamp.off_usec = stamp->tv_usec - skb_tv_base.tv_usec; 1270 skb->tstamp.off_usec = stamp->tv_usec;
1277} 1271}
1278 1272
1279extern void __net_timestamp(struct sk_buff *skb); 1273extern void __net_timestamp(struct sk_buff *skb);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 1f356f3bbc64..5fc04a16ecb0 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -61,11 +61,11 @@ extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned lo
61 void (*)(void *, kmem_cache_t *, unsigned long)); 61 void (*)(void *, kmem_cache_t *, unsigned long));
62extern int kmem_cache_destroy(kmem_cache_t *); 62extern int kmem_cache_destroy(kmem_cache_t *);
63extern int kmem_cache_shrink(kmem_cache_t *); 63extern int kmem_cache_shrink(kmem_cache_t *);
64extern void *kmem_cache_alloc(kmem_cache_t *, unsigned int __nocast); 64extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
65extern void kmem_cache_free(kmem_cache_t *, void *); 65extern void kmem_cache_free(kmem_cache_t *, void *);
66extern unsigned int kmem_cache_size(kmem_cache_t *); 66extern unsigned int kmem_cache_size(kmem_cache_t *);
67extern const char *kmem_cache_name(kmem_cache_t *); 67extern const char *kmem_cache_name(kmem_cache_t *);
68extern kmem_cache_t *kmem_find_general_cachep(size_t size, unsigned int __nocast gfpflags); 68extern kmem_cache_t *kmem_find_general_cachep(size_t size, gfp_t gfpflags);
69 69
70/* Size description struct for general caches. */ 70/* Size description struct for general caches. */
71struct cache_sizes { 71struct cache_sizes {
@@ -74,9 +74,9 @@ struct cache_sizes {
74 kmem_cache_t *cs_dmacachep; 74 kmem_cache_t *cs_dmacachep;
75}; 75};
76extern struct cache_sizes malloc_sizes[]; 76extern struct cache_sizes malloc_sizes[];
77extern void *__kmalloc(size_t, unsigned int __nocast); 77extern void *__kmalloc(size_t, gfp_t);
78 78
79static inline void *kmalloc(size_t size, unsigned int __nocast flags) 79static inline void *kmalloc(size_t size, gfp_t flags)
80{ 80{
81 if (__builtin_constant_p(size)) { 81 if (__builtin_constant_p(size)) {
82 int i = 0; 82 int i = 0;
@@ -99,7 +99,7 @@ found:
99 return __kmalloc(size, flags); 99 return __kmalloc(size, flags);
100} 100}
101 101
102extern void *kzalloc(size_t, unsigned int __nocast); 102extern void *kzalloc(size_t, gfp_t);
103 103
104/** 104/**
105 * kcalloc - allocate memory for an array. The memory is set to zero. 105 * kcalloc - allocate memory for an array. The memory is set to zero.
@@ -107,7 +107,7 @@ extern void *kzalloc(size_t, unsigned int __nocast);
107 * @size: element size. 107 * @size: element size.
108 * @flags: the type of memory to allocate. 108 * @flags: the type of memory to allocate.
109 */ 109 */
110static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast flags) 110static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
111{ 111{
112 if (n != 0 && size > INT_MAX / n) 112 if (n != 0 && size > INT_MAX / n)
113 return NULL; 113 return NULL;
@@ -118,15 +118,14 @@ extern void kfree(const void *);
118extern unsigned int ksize(const void *); 118extern unsigned int ksize(const void *);
119 119
120#ifdef CONFIG_NUMA 120#ifdef CONFIG_NUMA
121extern void *kmem_cache_alloc_node(kmem_cache_t *, 121extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
122 unsigned int __nocast flags, int node); 122extern void *kmalloc_node(size_t size, gfp_t flags, int node);
123extern void *kmalloc_node(size_t size, unsigned int __nocast flags, int node);
124#else 123#else
125static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node) 124static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node)
126{ 125{
127 return kmem_cache_alloc(cachep, flags); 126 return kmem_cache_alloc(cachep, flags);
128} 127}
129static inline void *kmalloc_node(size_t size, unsigned int __nocast flags, int node) 128static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
130{ 129{
131 return kmalloc(size, flags); 130 return kmalloc(size, flags);
132} 131}
diff --git a/include/linux/string.h b/include/linux/string.h
index dab2652acbd8..369be3264a55 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -88,7 +88,7 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
88extern void * memchr(const void *,int,__kernel_size_t); 88extern void * memchr(const void *,int,__kernel_size_t);
89#endif 89#endif
90 90
91extern char *kstrdup(const char *s, unsigned int __nocast gfp); 91extern char *kstrdup(const char *s, gfp_t gfp);
92 92
93#ifdef __cplusplus 93#ifdef __cplusplus
94} 94}
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index f2e96fdfaae0..ad15a54806d8 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -71,5 +71,7 @@ void restore_processor_state(void);
71struct saved_context; 71struct saved_context;
72void __save_processor_state(struct saved_context *ctxt); 72void __save_processor_state(struct saved_context *ctxt);
73void __restore_processor_state(struct saved_context *ctxt); 73void __restore_processor_state(struct saved_context *ctxt);
74extern unsigned long get_usable_page(unsigned gfp_mask);
75extern void free_eaten_memory(void);
74 76
75#endif /* _LINUX_SWSUSP_H */ 77#endif /* _LINUX_SWSUSP_H */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 3c9ff0048153..a7bf1a3b1496 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -147,7 +147,7 @@ struct swap_list_t {
147#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages) 147#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
148 148
149/* linux/mm/oom_kill.c */ 149/* linux/mm/oom_kill.c */
150extern void out_of_memory(unsigned int __nocast gfp_mask, int order); 150extern void out_of_memory(gfp_t gfp_mask, int order);
151 151
152/* linux/mm/memory.c */ 152/* linux/mm/memory.c */
153extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *); 153extern void swapin_readahead(swp_entry_t, unsigned long, struct vm_area_struct *);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 425f58c8ea4a..a6f03e473737 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -508,5 +508,7 @@ asmlinkage long sys_keyctl(int cmd, unsigned long arg2, unsigned long arg3,
508 508
509asmlinkage long sys_ioprio_set(int which, int who, int ioprio); 509asmlinkage long sys_ioprio_set(int which, int who, int ioprio);
510asmlinkage long sys_ioprio_get(int which, int who); 510asmlinkage long sys_ioprio_get(int which, int who);
511asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
512 unsigned long maxnode);
511 513
512#endif 514#endif
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 3a29a9f9b451..fc8e367f671e 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -202,7 +202,8 @@ enum
202 NET_TR=14, 202 NET_TR=14,
203 NET_DECNET=15, 203 NET_DECNET=15,
204 NET_ECONET=16, 204 NET_ECONET=16,
205 NET_SCTP=17, 205 NET_SCTP=17,
206 NET_LLC=18,
206}; 207};
207 208
208/* /proc/sys/kernel/random */ 209/* /proc/sys/kernel/random */
@@ -522,6 +523,29 @@ enum {
522 NET_IPX_FORWARDING=2 523 NET_IPX_FORWARDING=2
523}; 524};
524 525
526/* /proc/sys/net/llc */
527enum {
528 NET_LLC2=1,
529 NET_LLC_STATION=2,
530};
531
532/* /proc/sys/net/llc/llc2 */
533enum {
534 NET_LLC2_TIMEOUT=1,
535};
536
537/* /proc/sys/net/llc/station */
538enum {
539 NET_LLC_STATION_ACK_TIMEOUT=1,
540};
541
542/* /proc/sys/net/llc/llc2/timeout */
543enum {
544 NET_LLC2_ACK_TIMEOUT=1,
545 NET_LLC2_P_TIMEOUT=2,
546 NET_LLC2_REJ_TIMEOUT=3,
547 NET_LLC2_BUSY_TIMEOUT=4,
548};
525 549
526/* /proc/sys/net/appletalk */ 550/* /proc/sys/net/appletalk */
527enum { 551enum {
diff --git a/include/linux/tc_ematch/tc_em_meta.h b/include/linux/tc_ematch/tc_em_meta.h
index 081b1ee8516e..e21937cf91d0 100644
--- a/include/linux/tc_ematch/tc_em_meta.h
+++ b/include/linux/tc_ematch/tc_em_meta.h
@@ -71,7 +71,7 @@ enum
71 TCF_META_ID_SK_SNDBUF, 71 TCF_META_ID_SK_SNDBUF,
72 TCF_META_ID_SK_ALLOCS, 72 TCF_META_ID_SK_ALLOCS,
73 TCF_META_ID_SK_ROUTE_CAPS, 73 TCF_META_ID_SK_ROUTE_CAPS,
74 TCF_META_ID_SK_HASHENT, 74 TCF_META_ID_SK_HASH,
75 TCF_META_ID_SK_LINGERTIME, 75 TCF_META_ID_SK_LINGERTIME,
76 TCF_META_ID_SK_ACK_BACKLOG, 76 TCF_META_ID_SK_ACK_BACKLOG,
77 TCF_META_ID_SK_MAX_ACK_BACKLOG, 77 TCF_META_ID_SK_MAX_ACK_BACKLOG,
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 941f45ac117a..515046d1b2f4 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -158,7 +158,8 @@ extern unsigned int textsearch_find_continuous(struct ts_config *,
158#define TS_PRIV_ALIGNTO 8 158#define TS_PRIV_ALIGNTO 8
159#define TS_PRIV_ALIGN(len) (((len) + TS_PRIV_ALIGNTO-1) & ~(TS_PRIV_ALIGNTO-1)) 159#define TS_PRIV_ALIGN(len) (((len) + TS_PRIV_ALIGNTO-1) & ~(TS_PRIV_ALIGNTO-1))
160 160
161static inline struct ts_config *alloc_ts_config(size_t payload, int gfp_mask) 161static inline struct ts_config *alloc_ts_config(size_t payload,
162 gfp_t gfp_mask)
162{ 163{
163 struct ts_config *conf; 164 struct ts_config *conf;
164 165
diff --git a/include/linux/tfrc.h b/include/linux/tfrc.h
new file mode 100644
index 000000000000..7dab7831c3cb
--- /dev/null
+++ b/include/linux/tfrc.h
@@ -0,0 +1,35 @@
1#ifndef _LINUX_TFRC_H_
2#define _LINUX_TFRC_H_
3/*
4 * include/linux/tfrc.h
5 *
6 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
7 * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
8 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
9 * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#include <linux/types.h>
18
19struct tfrc_rx_info {
20 __u32 tfrcrx_x_recv;
21 __u32 tfrcrx_rtt;
22 __u32 tfrcrx_p;
23};
24
25struct tfrc_tx_info {
26 __u32 tfrctx_x;
27 __u32 tfrctx_x_recv;
28 __u32 tfrctx_x_calc;
29 __u32 tfrctx_rtt;
30 __u32 tfrctx_p;
31 __u32 tfrctx_rto;
32 __u32 tfrctx_ipi;
33};
34
35#endif /* _LINUX_TFRC_H_ */
diff --git a/include/linux/types.h b/include/linux/types.h
index 2b678c22ca4a..0aee34f9da9f 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -165,6 +165,10 @@ typedef __u64 __bitwise __le64;
165typedef __u64 __bitwise __be64; 165typedef __u64 __bitwise __be64;
166#endif 166#endif
167 167
168#ifdef __KERNEL__
169typedef unsigned __nocast gfp_t;
170#endif
171
168struct ustat { 172struct ustat {
169 __kernel_daddr_t f_tfree; 173 __kernel_daddr_t f_tfree;
170 __kernel_ino_t f_tinode; 174 __kernel_ino_t f_tinode;
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index b244f69ef682..3701a0673d2c 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -34,8 +34,8 @@ struct vm_struct {
34extern void *vmalloc(unsigned long size); 34extern void *vmalloc(unsigned long size);
35extern void *vmalloc_exec(unsigned long size); 35extern void *vmalloc_exec(unsigned long size);
36extern void *vmalloc_32(unsigned long size); 36extern void *vmalloc_32(unsigned long size);
37extern void *__vmalloc(unsigned long size, unsigned int __nocast gfp_mask, pgprot_t prot); 37extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
38extern void *__vmalloc_area(struct vm_struct *area, unsigned int __nocast gfp_mask, pgprot_t prot); 38extern void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot);
39extern void vfree(void *addr); 39extern void vfree(void *addr);
40 40
41extern void *vmap(struct page **pages, unsigned int count, 41extern void *vmap(struct page **pages, unsigned int count,
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 9dbcd9e51c00..30bb4a893237 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -171,7 +171,7 @@ typedef struct {
171 ax25_address calls[AX25_MAX_DIGIS]; 171 ax25_address calls[AX25_MAX_DIGIS];
172 unsigned char repeated[AX25_MAX_DIGIS]; 172 unsigned char repeated[AX25_MAX_DIGIS];
173 unsigned char ndigi; 173 unsigned char ndigi;
174 char lastrepeat; 174 signed char lastrepeat;
175} ax25_digi; 175} ax25_digi;
176 176
177typedef struct ax25_route { 177typedef struct ax25_route {
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 6dfa4a61ffd0..210458624840 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -136,7 +136,7 @@ struct bt_skb_cb {
136}; 136};
137#define bt_cb(skb) ((struct bt_skb_cb *)(skb->cb)) 137#define bt_cb(skb) ((struct bt_skb_cb *)(skb->cb))
138 138
139static inline struct sk_buff *bt_skb_alloc(unsigned int len, unsigned int __nocast how) 139static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
140{ 140{
141 struct sk_buff *skb; 141 struct sk_buff *skb;
142 142
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index ffea9d54071f..fbe557f7ea1d 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -230,7 +230,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
230 u8 xon_char, u8 xoff_char, u16 param_mask); 230 u8 xon_char, u8 xoff_char, u16 param_mask);
231 231
232/* ---- RFCOMM DLCs (channels) ---- */ 232/* ---- RFCOMM DLCs (channels) ---- */
233struct rfcomm_dlc *rfcomm_dlc_alloc(unsigned int __nocast prio); 233struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio);
234void rfcomm_dlc_free(struct rfcomm_dlc *d); 234void rfcomm_dlc_free(struct rfcomm_dlc *d);
235int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel); 235int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel);
236int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason); 236int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason);
diff --git a/include/net/dn_nsp.h b/include/net/dn_nsp.h
index 6bbeafa73e8b..1ba03be0af3a 100644
--- a/include/net/dn_nsp.h
+++ b/include/net/dn_nsp.h
@@ -19,9 +19,9 @@ extern void dn_nsp_send_data_ack(struct sock *sk);
19extern void dn_nsp_send_oth_ack(struct sock *sk); 19extern void dn_nsp_send_oth_ack(struct sock *sk);
20extern void dn_nsp_delayed_ack(struct sock *sk); 20extern void dn_nsp_delayed_ack(struct sock *sk);
21extern void dn_send_conn_ack(struct sock *sk); 21extern void dn_send_conn_ack(struct sock *sk);
22extern void dn_send_conn_conf(struct sock *sk, int gfp); 22extern void dn_send_conn_conf(struct sock *sk, gfp_t gfp);
23extern void dn_nsp_send_disc(struct sock *sk, unsigned char type, 23extern void dn_nsp_send_disc(struct sock *sk, unsigned char type,
24 unsigned short reason, int gfp); 24 unsigned short reason, gfp_t gfp);
25extern void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type, 25extern void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type,
26 unsigned short reason); 26 unsigned short reason);
27extern void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval); 27extern void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval);
@@ -29,14 +29,14 @@ extern void dn_nsp_send_conninit(struct sock *sk, unsigned char flags);
29 29
30extern void dn_nsp_output(struct sock *sk); 30extern void dn_nsp_output(struct sock *sk);
31extern int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum); 31extern int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum);
32extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, int gfp, int oob); 32extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp, int oob);
33extern unsigned long dn_nsp_persist(struct sock *sk); 33extern unsigned long dn_nsp_persist(struct sock *sk);
34extern int dn_nsp_xmit_timeout(struct sock *sk); 34extern int dn_nsp_xmit_timeout(struct sock *sk);
35 35
36extern int dn_nsp_rx(struct sk_buff *); 36extern int dn_nsp_rx(struct sk_buff *);
37extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb); 37extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
38 38
39extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri); 39extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
40extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err); 40extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err);
41 41
42#define NSP_REASON_OK 0 /* No error */ 42#define NSP_REASON_OK 0 /* No error */
diff --git a/include/net/dn_route.h b/include/net/dn_route.h
index d084721db198..5122da3f2eb3 100644
--- a/include/net/dn_route.h
+++ b/include/net/dn_route.h
@@ -15,7 +15,7 @@
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16*******************************************************************************/ 16*******************************************************************************/
17 17
18extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri); 18extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
19extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); 19extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags);
20extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); 20extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
21extern int dn_cache_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); 21extern int dn_cache_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg);
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index 03df3b157960..5a2beed5a770 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -26,19 +26,18 @@
26struct inet_hashinfo; 26struct inet_hashinfo;
27 27
28/* I have no idea if this is a good hash for v6 or not. -DaveM */ 28/* I have no idea if this is a good hash for v6 or not. -DaveM */
29static inline int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport, 29static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport,
30 const struct in6_addr *faddr, const u16 fport, 30 const struct in6_addr *faddr, const u16 fport)
31 const int ehash_size)
32{ 31{
33 int hashent = (lport ^ fport); 32 unsigned int hashent = (lport ^ fport);
34 33
35 hashent ^= (laddr->s6_addr32[3] ^ faddr->s6_addr32[3]); 34 hashent ^= (laddr->s6_addr32[3] ^ faddr->s6_addr32[3]);
36 hashent ^= hashent >> 16; 35 hashent ^= hashent >> 16;
37 hashent ^= hashent >> 8; 36 hashent ^= hashent >> 8;
38 return (hashent & (ehash_size - 1)); 37 return hashent;
39} 38}
40 39
41static inline int inet6_sk_ehashfn(const struct sock *sk, const int ehash_size) 40static inline int inet6_sk_ehashfn(const struct sock *sk)
42{ 41{
43 const struct inet_sock *inet = inet_sk(sk); 42 const struct inet_sock *inet = inet_sk(sk);
44 const struct ipv6_pinfo *np = inet6_sk(sk); 43 const struct ipv6_pinfo *np = inet6_sk(sk);
@@ -46,7 +45,7 @@ static inline int inet6_sk_ehashfn(const struct sock *sk, const int ehash_size)
46 const struct in6_addr *faddr = &np->daddr; 45 const struct in6_addr *faddr = &np->daddr;
47 const __u16 lport = inet->num; 46 const __u16 lport = inet->num;
48 const __u16 fport = inet->dport; 47 const __u16 fport = inet->dport;
49 return inet6_ehashfn(laddr, lport, faddr, fport, ehash_size); 48 return inet6_ehashfn(laddr, lport, faddr, fport);
50} 49}
51 50
52/* 51/*
@@ -69,14 +68,14 @@ static inline struct sock *
69 /* Optimize here for direct hit, only listening connections can 68 /* Optimize here for direct hit, only listening connections can
70 * have wildcards anyways. 69 * have wildcards anyways.
71 */ 70 */
72 const int hash = inet6_ehashfn(daddr, hnum, saddr, sport, 71 unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport);
73 hashinfo->ehash_size); 72 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
74 struct inet_ehash_bucket *head = &hashinfo->ehash[hash];
75 73
74 prefetch(head->chain.first);
76 read_lock(&head->lock); 75 read_lock(&head->lock);
77 sk_for_each(sk, node, &head->chain) { 76 sk_for_each(sk, node, &head->chain) {
78 /* For IPV6 do the cheaper port and family tests first. */ 77 /* For IPV6 do the cheaper port and family tests first. */
79 if (INET6_MATCH(sk, saddr, daddr, ports, dif)) 78 if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif))
80 goto hit; /* You sunk my battleship! */ 79 goto hit; /* You sunk my battleship! */
81 } 80 }
82 /* Must check for a TIME_WAIT'er before going to listener hash. */ 81 /* Must check for a TIME_WAIT'er before going to listener hash. */
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 651f824c1008..b0c99060b78d 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -94,7 +94,7 @@ static inline void *inet_csk_ca(const struct sock *sk)
94 94
95extern struct sock *inet_csk_clone(struct sock *sk, 95extern struct sock *inet_csk_clone(struct sock *sk,
96 const struct request_sock *req, 96 const struct request_sock *req,
97 const unsigned int __nocast priority); 97 const gfp_t priority);
98 98
99enum inet_csk_ack_state_t { 99enum inet_csk_ack_state_t {
100 ICSK_ACK_SCHED = 1, 100 ICSK_ACK_SCHED = 1,
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 646b6ea7fe26..f50f95968340 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -40,7 +40,7 @@
40struct inet_ehash_bucket { 40struct inet_ehash_bucket {
41 rwlock_t lock; 41 rwlock_t lock;
42 struct hlist_head chain; 42 struct hlist_head chain;
43} __attribute__((__aligned__(8))); 43};
44 44
45/* There are a few simple rules, which allow for local port reuse by 45/* There are a few simple rules, which allow for local port reuse by
46 * an application. In essence: 46 * an application. In essence:
@@ -108,7 +108,7 @@ struct inet_hashinfo {
108 struct inet_bind_hashbucket *bhash; 108 struct inet_bind_hashbucket *bhash;
109 109
110 int bhash_size; 110 int bhash_size;
111 int ehash_size; 111 unsigned int ehash_size;
112 112
113 /* All sockets in TCP_LISTEN state will be in here. This is the only 113 /* All sockets in TCP_LISTEN state will be in here. This is the only
114 * table where wildcard'd TCP sockets can exist. Hash function here 114 * table where wildcard'd TCP sockets can exist. Hash function here
@@ -130,17 +130,16 @@ struct inet_hashinfo {
130 int port_rover; 130 int port_rover;
131}; 131};
132 132
133static inline int inet_ehashfn(const __u32 laddr, const __u16 lport, 133static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport,
134 const __u32 faddr, const __u16 fport, 134 const __u32 faddr, const __u16 fport)
135 const int ehash_size)
136{ 135{
137 int h = (laddr ^ lport) ^ (faddr ^ fport); 136 unsigned int h = (laddr ^ lport) ^ (faddr ^ fport);
138 h ^= h >> 16; 137 h ^= h >> 16;
139 h ^= h >> 8; 138 h ^= h >> 8;
140 return h & (ehash_size - 1); 139 return h;
141} 140}
142 141
143static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size) 142static inline int inet_sk_ehashfn(const struct sock *sk)
144{ 143{
145 const struct inet_sock *inet = inet_sk(sk); 144 const struct inet_sock *inet = inet_sk(sk);
146 const __u32 laddr = inet->rcv_saddr; 145 const __u32 laddr = inet->rcv_saddr;
@@ -148,7 +147,14 @@ static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size)
148 const __u32 faddr = inet->daddr; 147 const __u32 faddr = inet->daddr;
149 const __u16 fport = inet->dport; 148 const __u16 fport = inet->dport;
150 149
151 return inet_ehashfn(laddr, lport, faddr, fport, ehash_size); 150 return inet_ehashfn(laddr, lport, faddr, fport);
151}
152
153static inline struct inet_ehash_bucket *inet_ehash_bucket(
154 struct inet_hashinfo *hashinfo,
155 unsigned int hash)
156{
157 return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)];
152} 158}
153 159
154extern struct inet_bind_bucket * 160extern struct inet_bind_bucket *
@@ -235,9 +241,11 @@ static inline void __inet_hash(struct inet_hashinfo *hashinfo,
235 lock = &hashinfo->lhash_lock; 241 lock = &hashinfo->lhash_lock;
236 inet_listen_wlock(hashinfo); 242 inet_listen_wlock(hashinfo);
237 } else { 243 } else {
238 sk->sk_hashent = inet_sk_ehashfn(sk, hashinfo->ehash_size); 244 struct inet_ehash_bucket *head;
239 list = &hashinfo->ehash[sk->sk_hashent].chain; 245 sk->sk_hash = inet_sk_ehashfn(sk);
240 lock = &hashinfo->ehash[sk->sk_hashent].lock; 246 head = inet_ehash_bucket(hashinfo, sk->sk_hash);
247 list = &head->chain;
248 lock = &head->lock;
241 write_lock(lock); 249 write_lock(lock);
242 } 250 }
243 __sk_add_node(sk, list); 251 __sk_add_node(sk, list);
@@ -268,9 +276,8 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk)
268 inet_listen_wlock(hashinfo); 276 inet_listen_wlock(hashinfo);
269 lock = &hashinfo->lhash_lock; 277 lock = &hashinfo->lhash_lock;
270 } else { 278 } else {
271 struct inet_ehash_bucket *head = &hashinfo->ehash[sk->sk_hashent]; 279 lock = &inet_ehash_bucket(hashinfo, sk->sk_hash)->lock;
272 lock = &head->lock; 280 write_lock_bh(lock);
273 write_lock_bh(&head->lock);
274 } 281 }
275 282
276 if (__sk_del_node_init(sk)) 283 if (__sk_del_node_init(sk))
@@ -337,23 +344,27 @@ sherry_cache:
337#define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ 344#define INET_ADDR_COOKIE(__name, __saddr, __daddr) \
338 const __u64 __name = (((__u64)(__daddr)) << 32) | ((__u64)(__saddr)); 345 const __u64 __name = (((__u64)(__daddr)) << 32) | ((__u64)(__saddr));
339#endif /* __BIG_ENDIAN */ 346#endif /* __BIG_ENDIAN */
340#define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\ 347#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
341 (((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ 348 (((__sk)->sk_hash == (__hash)) && \
349 ((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \
342 ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 350 ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \
343 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 351 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
344#define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\ 352#define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
345 (((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ 353 (((__sk)->sk_hash == (__hash)) && \
354 ((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \
346 ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 355 ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
347 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 356 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
348#else /* 32-bit arch */ 357#else /* 32-bit arch */
349#define INET_ADDR_COOKIE(__name, __saddr, __daddr) 358#define INET_ADDR_COOKIE(__name, __saddr, __daddr)
350#define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif) \ 359#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif) \
351 ((inet_sk(__sk)->daddr == (__saddr)) && \ 360 (((__sk)->sk_hash == (__hash)) && \
361 (inet_sk(__sk)->daddr == (__saddr)) && \
352 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ 362 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \
353 ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 363 ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \
354 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 364 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
355#define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif) \ 365#define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \
356 ((inet_twsk(__sk)->tw_daddr == (__saddr)) && \ 366 (((__sk)->sk_hash == (__hash)) && \
367 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \
357 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ 368 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \
358 ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 369 ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
359 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 370 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
@@ -378,18 +389,19 @@ static inline struct sock *
378 /* Optimize here for direct hit, only listening connections can 389 /* Optimize here for direct hit, only listening connections can
379 * have wildcards anyways. 390 * have wildcards anyways.
380 */ 391 */
381 const int hash = inet_ehashfn(daddr, hnum, saddr, sport, hashinfo->ehash_size); 392 unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport);
382 struct inet_ehash_bucket *head = &hashinfo->ehash[hash]; 393 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
383 394
395 prefetch(head->chain.first);
384 read_lock(&head->lock); 396 read_lock(&head->lock);
385 sk_for_each(sk, node, &head->chain) { 397 sk_for_each(sk, node, &head->chain) {
386 if (INET_MATCH(sk, acookie, saddr, daddr, ports, dif)) 398 if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
387 goto hit; /* You sunk my battleship! */ 399 goto hit; /* You sunk my battleship! */
388 } 400 }
389 401
390 /* Must check for a TIME_WAIT'er before going to listener hash. */ 402 /* Must check for a TIME_WAIT'er before going to listener hash. */
391 sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) { 403 sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
392 if (INET_TW_MATCH(sk, acookie, saddr, daddr, ports, dif)) 404 if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
393 goto hit; 405 goto hit;
394 } 406 }
395 sk = NULL; 407 sk = NULL;
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 3b070352e869..28f7b2103505 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -19,6 +19,7 @@
19 19
20#include <linux/ip.h> 20#include <linux/ip.h>
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/module.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
23#include <linux/types.h> 24#include <linux/types.h>
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
@@ -112,6 +113,7 @@ struct inet_timewait_sock {
112#define tw_node __tw_common.skc_node 113#define tw_node __tw_common.skc_node
113#define tw_bind_node __tw_common.skc_bind_node 114#define tw_bind_node __tw_common.skc_bind_node
114#define tw_refcnt __tw_common.skc_refcnt 115#define tw_refcnt __tw_common.skc_refcnt
116#define tw_hash __tw_common.skc_hash
115#define tw_prot __tw_common.skc_prot 117#define tw_prot __tw_common.skc_prot
116 volatile unsigned char tw_substate; 118 volatile unsigned char tw_substate;
117 /* 3 bits hole, try to pack */ 119 /* 3 bits hole, try to pack */
@@ -126,7 +128,6 @@ struct inet_timewait_sock {
126 /* And these are ours. */ 128 /* And these are ours. */
127 __u8 tw_ipv6only:1; 129 __u8 tw_ipv6only:1;
128 /* 31 bits hole, try to pack */ 130 /* 31 bits hole, try to pack */
129 int tw_hashent;
130 int tw_timeout; 131 int tw_timeout;
131 unsigned long tw_ttd; 132 unsigned long tw_ttd;
132 struct inet_bind_bucket *tw_tb; 133 struct inet_bind_bucket *tw_tb;
@@ -193,11 +194,13 @@ static inline u32 inet_rcv_saddr(const struct sock *sk)
193static inline void inet_twsk_put(struct inet_timewait_sock *tw) 194static inline void inet_twsk_put(struct inet_timewait_sock *tw)
194{ 195{
195 if (atomic_dec_and_test(&tw->tw_refcnt)) { 196 if (atomic_dec_and_test(&tw->tw_refcnt)) {
197 struct module *owner = tw->tw_prot->owner;
196#ifdef SOCK_REFCNT_DEBUG 198#ifdef SOCK_REFCNT_DEBUG
197 printk(KERN_DEBUG "%s timewait_sock %p released\n", 199 printk(KERN_DEBUG "%s timewait_sock %p released\n",
198 tw->tw_prot->name, tw); 200 tw->tw_prot->name, tw);
199#endif 201#endif
200 kmem_cache_free(tw->tw_prot->twsk_slab, tw); 202 kmem_cache_free(tw->tw_prot->twsk_slab, tw);
203 module_put(owner);
201 } 204 }
202} 205}
203 206
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 06b4235aa016..3b5559a023a4 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -832,7 +832,7 @@ extern void ip_vs_app_inc_put(struct ip_vs_app *inc);
832 832
833extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff **pskb); 833extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff **pskb);
834extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff **pskb); 834extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff **pskb);
835extern int ip_vs_skb_replace(struct sk_buff *skb, int pri, 835extern int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
836 char *o_buf, int o_len, char *n_buf, int n_len); 836 char *o_buf, int o_len, char *n_buf, int n_len);
837extern int ip_vs_app_init(void); 837extern int ip_vs_app_init(void);
838extern void ip_vs_app_cleanup(void); 838extern void ip_vs_app_cleanup(void);
diff --git a/include/net/llc.h b/include/net/llc.h
index 71769a5aeef3..1adb2ef3f6f7 100644
--- a/include/net/llc.h
+++ b/include/net/llc.h
@@ -17,6 +17,8 @@
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19 19
20#include <asm/atomic.h>
21
20struct net_device; 22struct net_device;
21struct packet_type; 23struct packet_type;
22struct sk_buff; 24struct sk_buff;
@@ -44,6 +46,7 @@ struct llc_sap {
44 unsigned char state; 46 unsigned char state;
45 unsigned char p_bit; 47 unsigned char p_bit;
46 unsigned char f_bit; 48 unsigned char f_bit;
49 atomic_t refcnt;
47 int (*rcv_func)(struct sk_buff *skb, 50 int (*rcv_func)(struct sk_buff *skb,
48 struct net_device *dev, 51 struct net_device *dev,
49 struct packet_type *pt, 52 struct packet_type *pt,
@@ -81,13 +84,27 @@ extern struct llc_sap *llc_sap_open(unsigned char lsap,
81 struct net_device *dev, 84 struct net_device *dev,
82 struct packet_type *pt, 85 struct packet_type *pt,
83 struct net_device *orig_dev)); 86 struct net_device *orig_dev));
87static inline void llc_sap_hold(struct llc_sap *sap)
88{
89 atomic_inc(&sap->refcnt);
90}
91
84extern void llc_sap_close(struct llc_sap *sap); 92extern void llc_sap_close(struct llc_sap *sap);
85 93
94static inline void llc_sap_put(struct llc_sap *sap)
95{
96 if (atomic_dec_and_test(&sap->refcnt))
97 llc_sap_close(sap);
98}
99
86extern struct llc_sap *llc_sap_find(unsigned char sap_value); 100extern struct llc_sap *llc_sap_find(unsigned char sap_value);
87 101
88extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, 102extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
89 unsigned char *dmac, unsigned char dsap); 103 unsigned char *dmac, unsigned char dsap);
90 104
105extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
106extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
107
91extern int llc_station_init(void); 108extern int llc_station_init(void);
92extern void llc_station_exit(void); 109extern void llc_station_exit(void);
93 110
@@ -98,4 +115,17 @@ extern void llc_proc_exit(void);
98#define llc_proc_init() (0) 115#define llc_proc_init() (0)
99#define llc_proc_exit() do { } while(0) 116#define llc_proc_exit() do { } while(0)
100#endif /* CONFIG_PROC_FS */ 117#endif /* CONFIG_PROC_FS */
118#ifdef CONFIG_SYSCTL
119extern int llc_sysctl_init(void);
120extern void llc_sysctl_exit(void);
121
122extern int sysctl_llc2_ack_timeout;
123extern int sysctl_llc2_busy_timeout;
124extern int sysctl_llc2_p_timeout;
125extern int sysctl_llc2_rej_timeout;
126extern int sysctl_llc_station_ack_timeout;
127#else
128#define llc_sysctl_init() (0)
129#define llc_sysctl_exit() do { } while(0)
130#endif /* CONFIG_SYSCTL */
101#endif /* LLC_H */ 131#endif /* LLC_H */
diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h
index 8ad3bc2c23d7..00730d21b522 100644
--- a/include/net/llc_conn.h
+++ b/include/net/llc_conn.h
@@ -19,14 +19,14 @@
19#define LLC_EVENT 1 19#define LLC_EVENT 1
20#define LLC_PACKET 2 20#define LLC_PACKET 2
21 21
22#define LLC_P_TIME 2 22#define LLC2_P_TIME 2
23#define LLC_ACK_TIME 1 23#define LLC2_ACK_TIME 1
24#define LLC_REJ_TIME 3 24#define LLC2_REJ_TIME 3
25#define LLC_BUSY_TIME 3 25#define LLC2_BUSY_TIME 3
26 26
27struct llc_timer { 27struct llc_timer {
28 struct timer_list timer; 28 struct timer_list timer;
29 u16 expire; /* timer expire time */ 29 unsigned long expire; /* timer expire time */
30}; 30};
31 31
32struct llc_sock { 32struct llc_sock {
@@ -38,6 +38,7 @@ struct llc_sock {
38 struct llc_addr laddr; /* lsap/mac pair */ 38 struct llc_addr laddr; /* lsap/mac pair */
39 struct llc_addr daddr; /* dsap/mac pair */ 39 struct llc_addr daddr; /* dsap/mac pair */
40 struct net_device *dev; /* device to send to remote */ 40 struct net_device *dev; /* device to send to remote */
41 u32 copied_seq; /* head of yet unread data */
41 u8 retry_count; /* number of retries */ 42 u8 retry_count; /* number of retries */
42 u8 ack_must_be_send; 43 u8 ack_must_be_send;
43 u8 first_pdu_Ns; 44 u8 first_pdu_Ns;
@@ -92,7 +93,8 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb)
92 return skb->cb[sizeof(skb->cb) - 1]; 93 return skb->cb[sizeof(skb->cb) - 1];
93} 94}
94 95
95extern struct sock *llc_sk_alloc(int family, int priority, struct proto *prot); 96extern struct sock *llc_sk_alloc(int family, gfp_t priority,
97 struct proto *prot);
96extern void llc_sk_free(struct sock *sk); 98extern void llc_sk_free(struct sock *sk);
97 99
98extern void llc_sk_reset(struct sock *sk); 100extern void llc_sk_reset(struct sock *sk);
@@ -115,5 +117,4 @@ extern void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk);
115 117
116extern u8 llc_data_accept_state(u8 state); 118extern u8 llc_data_accept_state(u8 state);
117extern void llc_build_offset_table(void); 119extern void llc_build_offset_table(void);
118extern int llc_release_sockets(struct llc_sap *sap);
119#endif /* LLC_CONN_H */ 120#endif /* LLC_CONN_H */
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h
index f45c37d89cf7..c7a959428b4f 100644
--- a/include/net/llc_pdu.h
+++ b/include/net/llc_pdu.h
@@ -254,8 +254,10 @@ static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
254{ 254{
255 if (skb->protocol == ntohs(ETH_P_802_2)) 255 if (skb->protocol == ntohs(ETH_P_802_2))
256 memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); 256 memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
257 else if (skb->protocol == ntohs(ETH_P_TR_802_2)) 257 else if (skb->protocol == ntohs(ETH_P_TR_802_2)) {
258 memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN); 258 memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN);
259 *sa &= 0x7F;
260 }
259} 261}
260 262
261/** 263/**
diff --git a/include/net/llc_sap.h b/include/net/llc_sap.h
index 353baaa627f3..2c56dbece729 100644
--- a/include/net/llc_sap.h
+++ b/include/net/llc_sap.h
@@ -12,11 +12,15 @@
12 * See the GNU General Public License for more details. 12 * See the GNU General Public License for more details.
13 */ 13 */
14struct llc_sap; 14struct llc_sap;
15struct net_device;
15struct sk_buff; 16struct sk_buff;
17struct sock;
16 18
17extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); 19extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb);
18extern void llc_save_primitive(struct sk_buff* skb, unsigned char prim); 20extern void llc_save_primitive(struct sock *sk, struct sk_buff* skb,
19extern struct sk_buff *llc_alloc_frame(void); 21 unsigned char prim);
22extern struct sk_buff *llc_alloc_frame(struct sock *sk,
23 struct net_device *dev);
20 24
21extern void llc_build_and_send_test_pkt(struct llc_sap *sap, 25extern void llc_build_and_send_test_pkt(struct llc_sap *sap,
22 struct sk_buff *skb, 26 struct sk_buff *skb,
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index e1d5ec1c23c0..8f241216f46b 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -125,7 +125,7 @@
125 */ 125 */
126extern struct sock *sctp_get_ctl_sock(void); 126extern struct sock *sctp_get_ctl_sock(void);
127extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, 127extern int sctp_copy_local_addr_list(struct sctp_bind_addr *,
128 sctp_scope_t, unsigned int __nocast gfp, 128 sctp_scope_t, gfp_t gfp,
129 int flags); 129 int flags);
130extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); 130extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
131extern int sctp_register_pf(struct sctp_pf *, sa_family_t); 131extern int sctp_register_pf(struct sctp_pf *, sa_family_t);
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 58462164d960..1eac3d0eb7a9 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -181,17 +181,17 @@ const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t,
181int sctp_chunk_iif(const struct sctp_chunk *); 181int sctp_chunk_iif(const struct sctp_chunk *);
182struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *, 182struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *,
183 struct sctp_chunk *, 183 struct sctp_chunk *,
184 unsigned int __nocast gfp); 184 gfp_t gfp);
185__u32 sctp_generate_verification_tag(void); 185__u32 sctp_generate_verification_tag(void);
186void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag); 186void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
187 187
188/* Prototypes for chunk-building functions. */ 188/* Prototypes for chunk-building functions. */
189struct sctp_chunk *sctp_make_init(const struct sctp_association *, 189struct sctp_chunk *sctp_make_init(const struct sctp_association *,
190 const struct sctp_bind_addr *, 190 const struct sctp_bind_addr *,
191 unsigned int __nocast gfp, int vparam_len); 191 gfp_t gfp, int vparam_len);
192struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *, 192struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *,
193 const struct sctp_chunk *, 193 const struct sctp_chunk *,
194 const unsigned int __nocast gfp, 194 const gfp_t gfp,
195 const int unkparam_len); 195 const int unkparam_len);
196struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *, 196struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *,
197 const struct sctp_chunk *); 197 const struct sctp_chunk *);
@@ -265,7 +265,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype,
265 struct sctp_endpoint *, 265 struct sctp_endpoint *,
266 struct sctp_association *asoc, 266 struct sctp_association *asoc,
267 void *event_arg, 267 void *event_arg,
268 unsigned int __nocast gfp); 268 gfp_t gfp);
269 269
270/* 2nd level prototypes */ 270/* 2nd level prototypes */
271void sctp_generate_t3_rtx_event(unsigned long peer); 271void sctp_generate_t3_rtx_event(unsigned long peer);
@@ -276,7 +276,7 @@ void sctp_ootb_pkt_free(struct sctp_packet *);
276struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *, 276struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *,
277 const struct sctp_association *, 277 const struct sctp_association *,
278 struct sctp_chunk *, 278 struct sctp_chunk *,
279 unsigned int __nocast gfp, int *err, 279 gfp_t gfp, int *err,
280 struct sctp_chunk **err_chk_p); 280 struct sctp_chunk **err_chk_p);
281int sctp_addip_addr_config(struct sctp_association *, sctp_param_t, 281int sctp_addip_addr_config(struct sctp_association *, sctp_param_t,
282 struct sockaddr_storage*, int); 282 struct sockaddr_storage*, int);
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 994009bbe3b4..9c385b6417c7 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -446,7 +446,7 @@ struct sctp_ssnmap {
446}; 446};
447 447
448struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, 448struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
449 unsigned int __nocast gfp); 449 gfp_t gfp);
450void sctp_ssnmap_free(struct sctp_ssnmap *map); 450void sctp_ssnmap_free(struct sctp_ssnmap *map);
451void sctp_ssnmap_clear(struct sctp_ssnmap *map); 451void sctp_ssnmap_clear(struct sctp_ssnmap *map);
452 452
@@ -947,7 +947,7 @@ struct sctp_transport {
947}; 947};
948 948
949struct sctp_transport *sctp_transport_new(const union sctp_addr *, 949struct sctp_transport *sctp_transport_new(const union sctp_addr *,
950 unsigned int __nocast); 950 gfp_t);
951void sctp_transport_set_owner(struct sctp_transport *, 951void sctp_transport_set_owner(struct sctp_transport *,
952 struct sctp_association *); 952 struct sctp_association *);
953void sctp_transport_route(struct sctp_transport *, union sctp_addr *, 953void sctp_transport_route(struct sctp_transport *, union sctp_addr *,
@@ -1095,10 +1095,10 @@ void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port);
1095void sctp_bind_addr_free(struct sctp_bind_addr *); 1095void sctp_bind_addr_free(struct sctp_bind_addr *);
1096int sctp_bind_addr_copy(struct sctp_bind_addr *dest, 1096int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
1097 const struct sctp_bind_addr *src, 1097 const struct sctp_bind_addr *src,
1098 sctp_scope_t scope, unsigned int __nocast gfp, 1098 sctp_scope_t scope, gfp_t gfp,
1099 int flags); 1099 int flags);
1100int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, 1100int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
1101 unsigned int __nocast gfp); 1101 gfp_t gfp);
1102int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *); 1102int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
1103int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, 1103int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
1104 struct sctp_sock *); 1104 struct sctp_sock *);
@@ -1108,9 +1108,9 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
1108 struct sctp_sock *opt); 1108 struct sctp_sock *opt);
1109union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, 1109union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
1110 int *addrs_len, 1110 int *addrs_len,
1111 unsigned int __nocast gfp); 1111 gfp_t gfp);
1112int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, 1112int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
1113 __u16 port, unsigned int __nocast gfp); 1113 __u16 port, gfp_t gfp);
1114 1114
1115sctp_scope_t sctp_scope(const union sctp_addr *); 1115sctp_scope_t sctp_scope(const union sctp_addr *);
1116int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); 1116int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);
@@ -1239,7 +1239,7 @@ static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base)
1239} 1239}
1240 1240
1241/* These are function signatures for manipulating endpoints. */ 1241/* These are function signatures for manipulating endpoints. */
1242struct sctp_endpoint *sctp_endpoint_new(struct sock *, unsigned int __nocast); 1242struct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t);
1243void sctp_endpoint_free(struct sctp_endpoint *); 1243void sctp_endpoint_free(struct sctp_endpoint *);
1244void sctp_endpoint_put(struct sctp_endpoint *); 1244void sctp_endpoint_put(struct sctp_endpoint *);
1245void sctp_endpoint_hold(struct sctp_endpoint *); 1245void sctp_endpoint_hold(struct sctp_endpoint *);
@@ -1260,7 +1260,7 @@ int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t,
1260 struct sctp_chunk **err_chunk); 1260 struct sctp_chunk **err_chunk);
1261int sctp_process_init(struct sctp_association *, sctp_cid_t cid, 1261int sctp_process_init(struct sctp_association *, sctp_cid_t cid,
1262 const union sctp_addr *peer, 1262 const union sctp_addr *peer,
1263 sctp_init_chunk_t *init, unsigned int __nocast gfp); 1263 sctp_init_chunk_t *init, gfp_t gfp);
1264__u32 sctp_generate_tag(const struct sctp_endpoint *); 1264__u32 sctp_generate_tag(const struct sctp_endpoint *);
1265__u32 sctp_generate_tsn(const struct sctp_endpoint *); 1265__u32 sctp_generate_tsn(const struct sctp_endpoint *);
1266 1266
@@ -1723,7 +1723,7 @@ static inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base)
1723 1723
1724struct sctp_association * 1724struct sctp_association *
1725sctp_association_new(const struct sctp_endpoint *, const struct sock *, 1725sctp_association_new(const struct sctp_endpoint *, const struct sock *,
1726 sctp_scope_t scope, unsigned int __nocast gfp); 1726 sctp_scope_t scope, gfp_t gfp);
1727void sctp_association_free(struct sctp_association *); 1727void sctp_association_free(struct sctp_association *);
1728void sctp_association_put(struct sctp_association *); 1728void sctp_association_put(struct sctp_association *);
1729void sctp_association_hold(struct sctp_association *); 1729void sctp_association_hold(struct sctp_association *);
@@ -1739,7 +1739,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
1739 const union sctp_addr *laddr); 1739 const union sctp_addr *laddr);
1740struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *, 1740struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *,
1741 const union sctp_addr *address, 1741 const union sctp_addr *address,
1742 const unsigned int __nocast gfp, 1742 const gfp_t gfp,
1743 const int peer_state); 1743 const int peer_state);
1744void sctp_assoc_del_peer(struct sctp_association *asoc, 1744void sctp_assoc_del_peer(struct sctp_association *asoc,
1745 const union sctp_addr *addr); 1745 const union sctp_addr *addr);
@@ -1764,10 +1764,10 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned);
1764void sctp_assoc_set_primary(struct sctp_association *, 1764void sctp_assoc_set_primary(struct sctp_association *,
1765 struct sctp_transport *); 1765 struct sctp_transport *);
1766int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, 1766int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *,
1767 unsigned int __nocast); 1767 gfp_t);
1768int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, 1768int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *,
1769 struct sctp_cookie*, 1769 struct sctp_cookie*,
1770 unsigned int __nocast gfp); 1770 gfp_t gfp);
1771 1771
1772int sctp_cmp_addr_exact(const union sctp_addr *ss1, 1772int sctp_cmp_addr_exact(const union sctp_addr *ss1,
1773 const union sctp_addr *ss2); 1773 const union sctp_addr *ss2);
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index 90fe4bf6754f..6c40cfc4832d 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -88,7 +88,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
88 __u16 error, 88 __u16 error,
89 __u16 outbound, 89 __u16 outbound,
90 __u16 inbound, 90 __u16 inbound,
91 unsigned int __nocast gfp); 91 gfp_t gfp);
92 92
93struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( 93struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
94 const struct sctp_association *asoc, 94 const struct sctp_association *asoc,
@@ -96,35 +96,35 @@ struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
96 int flags, 96 int flags,
97 int state, 97 int state,
98 int error, 98 int error,
99 unsigned int __nocast gfp); 99 gfp_t gfp);
100 100
101struct sctp_ulpevent *sctp_ulpevent_make_remote_error( 101struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
102 const struct sctp_association *asoc, 102 const struct sctp_association *asoc,
103 struct sctp_chunk *chunk, 103 struct sctp_chunk *chunk,
104 __u16 flags, 104 __u16 flags,
105 unsigned int __nocast gfp); 105 gfp_t gfp);
106struct sctp_ulpevent *sctp_ulpevent_make_send_failed( 106struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
107 const struct sctp_association *asoc, 107 const struct sctp_association *asoc,
108 struct sctp_chunk *chunk, 108 struct sctp_chunk *chunk,
109 __u16 flags, 109 __u16 flags,
110 __u32 error, 110 __u32 error,
111 unsigned int __nocast gfp); 111 gfp_t gfp);
112 112
113struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( 113struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
114 const struct sctp_association *asoc, 114 const struct sctp_association *asoc,
115 __u16 flags, 115 __u16 flags,
116 unsigned int __nocast gfp); 116 gfp_t gfp);
117 117
118struct sctp_ulpevent *sctp_ulpevent_make_pdapi( 118struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
119 const struct sctp_association *asoc, 119 const struct sctp_association *asoc,
120 __u32 indication, unsigned int __nocast gfp); 120 __u32 indication, gfp_t gfp);
121 121
122struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( 122struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
123 const struct sctp_association *asoc, unsigned int __nocast gfp); 123 const struct sctp_association *asoc, gfp_t gfp);
124 124
125struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, 125struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
126 struct sctp_chunk *chunk, 126 struct sctp_chunk *chunk,
127 unsigned int __nocast gfp); 127 gfp_t gfp);
128 128
129void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, 129void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
130 struct msghdr *); 130 struct msghdr *);
diff --git a/include/net/sctp/ulpqueue.h b/include/net/sctp/ulpqueue.h
index 1a60c6d943c1..a43c8788b650 100644
--- a/include/net/sctp/ulpqueue.h
+++ b/include/net/sctp/ulpqueue.h
@@ -62,22 +62,19 @@ struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *,
62void sctp_ulpq_free(struct sctp_ulpq *); 62void sctp_ulpq_free(struct sctp_ulpq *);
63 63
64/* Add a new DATA chunk for processing. */ 64/* Add a new DATA chunk for processing. */
65int sctp_ulpq_tail_data(struct sctp_ulpq *, struct sctp_chunk *, 65int sctp_ulpq_tail_data(struct sctp_ulpq *, struct sctp_chunk *, gfp_t);
66 unsigned int __nocast);
67 66
68/* Add a new event for propagation to the ULP. */ 67/* Add a new event for propagation to the ULP. */
69int sctp_ulpq_tail_event(struct sctp_ulpq *, struct sctp_ulpevent *ev); 68int sctp_ulpq_tail_event(struct sctp_ulpq *, struct sctp_ulpevent *ev);
70 69
71/* Renege previously received chunks. */ 70/* Renege previously received chunks. */
72void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, 71void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, gfp_t);
73 unsigned int __nocast);
74 72
75/* Perform partial delivery. */ 73/* Perform partial delivery. */
76void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *, 74void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *, gfp_t);
77 unsigned int __nocast);
78 75
79/* Abort the partial delivery. */ 76/* Abort the partial delivery. */
80void sctp_ulpq_abort_pd(struct sctp_ulpq *, unsigned int __nocast); 77void sctp_ulpq_abort_pd(struct sctp_ulpq *, gfp_t);
81 78
82/* Clear the partial data delivery condition on this socket. */ 79/* Clear the partial data delivery condition on this socket. */
83int sctp_clear_pd(struct sock *sk); 80int sctp_clear_pd(struct sock *sk);
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index f6328aeddcce..1c5f19f995ad 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -103,16 +103,20 @@ enum sctp_optname {
103#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM 103#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
104 SCTP_SOCKOPT_PEELOFF, /* peel off association. */ 104 SCTP_SOCKOPT_PEELOFF, /* peel off association. */
105#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF 105#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF
106 SCTP_GET_PEER_ADDRS_NUM, /* Get number of peer addresss. */ 106 SCTP_GET_PEER_ADDRS_NUM_OLD, /* Get number of peer addresss. */
107#define SCTP_GET_PEER_ADDRS_NUM SCTP_GET_PEER_ADDRS_NUM 107#define SCTP_GET_PEER_ADDRS_NUM_OLD SCTP_GET_PEER_ADDRS_NUM_OLD
108 SCTP_GET_PEER_ADDRS_OLD, /* Get all peer addresss. */
109#define SCTP_GET_PEER_ADDRS_OLD SCTP_GET_PEER_ADDRS_OLD
110 SCTP_GET_LOCAL_ADDRS_NUM_OLD, /* Get number of local addresss. */
111#define SCTP_GET_LOCAL_ADDRS_NUM_OLD SCTP_GET_LOCAL_ADDRS_NUM_OLD
112 SCTP_GET_LOCAL_ADDRS_OLD, /* Get all local addresss. */
113#define SCTP_GET_LOCAL_ADDRS_OLD SCTP_GET_LOCAL_ADDRS_OLD
114 SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
115#define SCTP_SOCKOPT_CONNECTX SCTP_SOCKOPT_CONNECTX
108 SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */ 116 SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */
109#define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS 117#define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS
110 SCTP_GET_LOCAL_ADDRS_NUM, /* Get number of local addresss. */
111#define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM
112 SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */ 118 SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */
113#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS 119#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS
114 SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
115#define SCTP_SOCKOPT_CONNECTX SCTP_SOCKOPT_CONNECTX
116}; 120};
117 121
118/* 122/*
@@ -239,7 +243,7 @@ struct sctp_paddr_change {
239 int spc_state; 243 int spc_state;
240 int spc_error; 244 int spc_error;
241 sctp_assoc_t spc_assoc_id; 245 sctp_assoc_t spc_assoc_id;
242}; 246} __attribute__((packed, aligned(4)));
243 247
244/* 248/*
245 * spc_state: 32 bits (signed integer) 249 * spc_state: 32 bits (signed integer)
@@ -464,7 +468,7 @@ struct sctp_assocparams {
464struct sctp_setpeerprim { 468struct sctp_setpeerprim {
465 sctp_assoc_t sspp_assoc_id; 469 sctp_assoc_t sspp_assoc_id;
466 struct sockaddr_storage sspp_addr; 470 struct sockaddr_storage sspp_addr;
467}; 471} __attribute__((packed, aligned(4)));
468 472
469/* 473/*
470 * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR) 474 * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
@@ -477,7 +481,7 @@ struct sctp_setpeerprim {
477struct sctp_prim { 481struct sctp_prim {
478 sctp_assoc_t ssp_assoc_id; 482 sctp_assoc_t ssp_assoc_id;
479 struct sockaddr_storage ssp_addr; 483 struct sockaddr_storage ssp_addr;
480}; 484} __attribute__((packed, aligned(4)));
481 485
482/* 486/*
483 * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER) 487 * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
@@ -504,7 +508,7 @@ struct sctp_paddrparams {
504 struct sockaddr_storage spp_address; 508 struct sockaddr_storage spp_address;
505 __u32 spp_hbinterval; 509 __u32 spp_hbinterval;
506 __u16 spp_pathmaxrxt; 510 __u16 spp_pathmaxrxt;
507}; 511} __attribute__((packed, aligned(4)));
508 512
509/* 513/*
510 * 7.2.2 Peer Address Information 514 * 7.2.2 Peer Address Information
@@ -523,7 +527,7 @@ struct sctp_paddrinfo {
523 __u32 spinfo_srtt; 527 __u32 spinfo_srtt;
524 __u32 spinfo_rto; 528 __u32 spinfo_rto;
525 __u32 spinfo_mtu; 529 __u32 spinfo_mtu;
526}; 530} __attribute__((packed, aligned(4)));
527 531
528/* Peer addresses's state. */ 532/* Peer addresses's state. */
529enum sctp_spinfo_state { 533enum sctp_spinfo_state {
@@ -559,11 +563,16 @@ struct sctp_status {
559 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement 563 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
560 * sctp_getpaddrs() and sctp_getladdrs() API. 564 * sctp_getpaddrs() and sctp_getladdrs() API.
561 */ 565 */
562struct sctp_getaddrs { 566struct sctp_getaddrs_old {
563 sctp_assoc_t assoc_id; 567 sctp_assoc_t assoc_id;
564 int addr_num; 568 int addr_num;
565 struct sockaddr __user *addrs; 569 struct sockaddr __user *addrs;
566}; 570};
571struct sctp_getaddrs {
572 sctp_assoc_t assoc_id; /*input*/
573 __u32 addr_num; /*output*/
574 __u8 addrs[0]; /*output, variable size*/
575};
567 576
568/* These are bit fields for msghdr->msg_flags. See section 5.1. */ 577/* These are bit fields for msghdr->msg_flags. See section 5.1. */
569/* On user space Linux, these live in <bits/socket.h> as an enum. */ 578/* On user space Linux, these live in <bits/socket.h> as an enum. */
diff --git a/include/net/sock.h b/include/net/sock.h
index 8c48fbecb7cf..ecb75526cba0 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -99,6 +99,7 @@ struct proto;
99 * @skc_node: main hash linkage for various protocol lookup tables 99 * @skc_node: main hash linkage for various protocol lookup tables
100 * @skc_bind_node: bind hash linkage for various protocol lookup tables 100 * @skc_bind_node: bind hash linkage for various protocol lookup tables
101 * @skc_refcnt: reference count 101 * @skc_refcnt: reference count
102 * @skc_hash: hash value used with various protocol lookup tables
102 * @skc_prot: protocol handlers inside a network family 103 * @skc_prot: protocol handlers inside a network family
103 * 104 *
104 * This is the minimal network layer representation of sockets, the header 105 * This is the minimal network layer representation of sockets, the header
@@ -112,6 +113,7 @@ struct sock_common {
112 struct hlist_node skc_node; 113 struct hlist_node skc_node;
113 struct hlist_node skc_bind_node; 114 struct hlist_node skc_bind_node;
114 atomic_t skc_refcnt; 115 atomic_t skc_refcnt;
116 unsigned int skc_hash;
115 struct proto *skc_prot; 117 struct proto *skc_prot;
116}; 118};
117 119
@@ -139,7 +141,6 @@ struct sock_common {
139 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets 141 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
140 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) 142 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
141 * @sk_lingertime: %SO_LINGER l_linger setting 143 * @sk_lingertime: %SO_LINGER l_linger setting
142 * @sk_hashent: hash entry in several tables (e.g. inet_hashinfo.ehash)
143 * @sk_backlog: always used with the per-socket spinlock held 144 * @sk_backlog: always used with the per-socket spinlock held
144 * @sk_callback_lock: used with the callbacks in the end of this struct 145 * @sk_callback_lock: used with the callbacks in the end of this struct
145 * @sk_error_queue: rarely used 146 * @sk_error_queue: rarely used
@@ -186,6 +187,7 @@ struct sock {
186#define sk_node __sk_common.skc_node 187#define sk_node __sk_common.skc_node
187#define sk_bind_node __sk_common.skc_bind_node 188#define sk_bind_node __sk_common.skc_bind_node
188#define sk_refcnt __sk_common.skc_refcnt 189#define sk_refcnt __sk_common.skc_refcnt
190#define sk_hash __sk_common.skc_hash
189#define sk_prot __sk_common.skc_prot 191#define sk_prot __sk_common.skc_prot
190 unsigned char sk_shutdown : 2, 192 unsigned char sk_shutdown : 2,
191 sk_no_check : 2, 193 sk_no_check : 2,
@@ -208,7 +210,6 @@ struct sock {
208 unsigned int sk_allocation; 210 unsigned int sk_allocation;
209 int sk_sndbuf; 211 int sk_sndbuf;
210 int sk_route_caps; 212 int sk_route_caps;
211 int sk_hashent;
212 unsigned long sk_flags; 213 unsigned long sk_flags;
213 unsigned long sk_lingertime; 214 unsigned long sk_lingertime;
214 /* 215 /*
@@ -738,18 +739,18 @@ extern void FASTCALL(release_sock(struct sock *sk));
738#define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) 739#define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock))
739 740
740extern struct sock *sk_alloc(int family, 741extern struct sock *sk_alloc(int family,
741 unsigned int __nocast priority, 742 gfp_t priority,
742 struct proto *prot, int zero_it); 743 struct proto *prot, int zero_it);
743extern void sk_free(struct sock *sk); 744extern void sk_free(struct sock *sk);
744extern struct sock *sk_clone(const struct sock *sk, 745extern struct sock *sk_clone(const struct sock *sk,
745 const unsigned int __nocast priority); 746 const gfp_t priority);
746 747
747extern struct sk_buff *sock_wmalloc(struct sock *sk, 748extern struct sk_buff *sock_wmalloc(struct sock *sk,
748 unsigned long size, int force, 749 unsigned long size, int force,
749 unsigned int __nocast priority); 750 gfp_t priority);
750extern struct sk_buff *sock_rmalloc(struct sock *sk, 751extern struct sk_buff *sock_rmalloc(struct sock *sk,
751 unsigned long size, int force, 752 unsigned long size, int force,
752 unsigned int __nocast priority); 753 gfp_t priority);
753extern void sock_wfree(struct sk_buff *skb); 754extern void sock_wfree(struct sk_buff *skb);
754extern void sock_rfree(struct sk_buff *skb); 755extern void sock_rfree(struct sk_buff *skb);
755 756
@@ -765,7 +766,7 @@ extern struct sk_buff *sock_alloc_send_skb(struct sock *sk,
765 int noblock, 766 int noblock,
766 int *errcode); 767 int *errcode);
767extern void *sock_kmalloc(struct sock *sk, int size, 768extern void *sock_kmalloc(struct sock *sk, int size,
768 unsigned int __nocast priority); 769 gfp_t priority);
769extern void sock_kfree_s(struct sock *sk, void *mem, int size); 770extern void sock_kfree_s(struct sock *sk, void *mem, int size);
770extern void sk_send_sigurg(struct sock *sk); 771extern void sk_send_sigurg(struct sock *sk);
771 772
@@ -1200,7 +1201,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
1200 1201
1201static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, 1202static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
1202 int size, int mem, 1203 int size, int mem,
1203 unsigned int __nocast gfp) 1204 gfp_t gfp)
1204{ 1205{
1205 struct sk_buff *skb; 1206 struct sk_buff *skb;
1206 int hdr_len; 1207 int hdr_len;
@@ -1223,7 +1224,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
1223 1224
1224static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk, 1225static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk,
1225 int size, 1226 int size,
1226 unsigned int __nocast gfp) 1227 gfp_t gfp)
1227{ 1228{
1228 return sk_stream_alloc_pskb(sk, size, 0, gfp); 1229 return sk_stream_alloc_pskb(sk, size, 0, gfp);
1229} 1230}
@@ -1254,7 +1255,7 @@ static inline int sock_writeable(const struct sock *sk)
1254 return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2); 1255 return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2);
1255} 1256}
1256 1257
1257static inline unsigned int __nocast gfp_any(void) 1258static inline gfp_t gfp_any(void)
1258{ 1259{
1259 return in_softirq() ? GFP_ATOMIC : GFP_KERNEL; 1260 return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
1260} 1261}
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 97af77c4d096..c24339c4e310 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -460,8 +460,7 @@ extern void tcp_send_probe0(struct sock *);
460extern void tcp_send_partial(struct sock *); 460extern void tcp_send_partial(struct sock *);
461extern int tcp_write_wakeup(struct sock *); 461extern int tcp_write_wakeup(struct sock *);
462extern void tcp_send_fin(struct sock *sk); 462extern void tcp_send_fin(struct sock *sk);
463extern void tcp_send_active_reset(struct sock *sk, 463extern void tcp_send_active_reset(struct sock *sk, gfp_t priority);
464 unsigned int __nocast priority);
465extern int tcp_send_synack(struct sock *); 464extern int tcp_send_synack(struct sock *);
466extern void tcp_push_one(struct sock *, unsigned int mss_now); 465extern void tcp_push_one(struct sock *, unsigned int mss_now);
467extern void tcp_send_ack(struct sock *sk); 466extern void tcp_send_ack(struct sock *sk);
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index a9d0d8c5dfbf..5beae1ccd574 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -875,7 +875,7 @@ static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsig
875} 875}
876#endif 876#endif
877 877
878struct xfrm_policy *xfrm_policy_alloc(int gfp); 878struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
879extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *); 879extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *);
880int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); 880int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
881struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel, 881struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel,
@@ -931,4 +931,9 @@ static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b,
931 } 931 }
932} 932}
933 933
934static inline int xfrm_policy_id2dir(u32 index)
935{
936 return index & 7;
937}
938
934#endif /* _NET_XFRM_H */ 939#endif /* _NET_XFRM_H */
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 0f7aacc33fe9..c8592c7e8eaa 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -21,6 +21,9 @@
21#include <pcmcia/cs_types.h> 21#include <pcmcia/cs_types.h>
22#include <pcmcia/cs.h> 22#include <pcmcia/cs.h>
23#include <pcmcia/bulkmem.h> 23#include <pcmcia/bulkmem.h>
24#ifdef CONFIG_CARDBUS
25#include <linux/pci.h>
26#endif
24 27
25/* Definitions for card status flags for GetStatus */ 28/* Definitions for card status flags for GetStatus */
26#define SS_WRPROT 0x0001 29#define SS_WRPROT 0x0001
@@ -233,7 +236,11 @@ struct pcmcia_socket {
233 236
234 /* so is power hook */ 237 /* so is power hook */
235 int (*power_hook)(struct pcmcia_socket *sock, int operation); 238 int (*power_hook)(struct pcmcia_socket *sock, int operation);
236 239#ifdef CONFIG_CARDBUS
240 /* allows tuning the CB bridge before loading driver for the CB card */
241 void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus);
242#endif
243
237 /* state thread */ 244 /* state thread */
238 struct semaphore skt_sem; /* protects socket h/w state */ 245 struct semaphore skt_sem; /* protects socket h/w state */
239 246
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 53184a38fdf6..4172e6841e3d 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -108,6 +108,13 @@
108#define IB_QP1_QKEY 0x80010000 108#define IB_QP1_QKEY 0x80010000
109#define IB_QP_SET_QKEY 0x80000000 109#define IB_QP_SET_QKEY 0x80000000
110 110
111enum {
112 IB_MGMT_MAD_DATA = 232,
113 IB_MGMT_RMPP_DATA = 220,
114 IB_MGMT_VENDOR_DATA = 216,
115 IB_MGMT_SA_DATA = 200
116};
117
111struct ib_mad_hdr { 118struct ib_mad_hdr {
112 u8 base_version; 119 u8 base_version;
113 u8 mgmt_class; 120 u8 mgmt_class;
@@ -149,20 +156,20 @@ struct ib_sa_hdr {
149 156
150struct ib_mad { 157struct ib_mad {
151 struct ib_mad_hdr mad_hdr; 158 struct ib_mad_hdr mad_hdr;
152 u8 data[232]; 159 u8 data[IB_MGMT_MAD_DATA];
153}; 160};
154 161
155struct ib_rmpp_mad { 162struct ib_rmpp_mad {
156 struct ib_mad_hdr mad_hdr; 163 struct ib_mad_hdr mad_hdr;
157 struct ib_rmpp_hdr rmpp_hdr; 164 struct ib_rmpp_hdr rmpp_hdr;
158 u8 data[220]; 165 u8 data[IB_MGMT_RMPP_DATA];
159}; 166};
160 167
161struct ib_sa_mad { 168struct ib_sa_mad {
162 struct ib_mad_hdr mad_hdr; 169 struct ib_mad_hdr mad_hdr;
163 struct ib_rmpp_hdr rmpp_hdr; 170 struct ib_rmpp_hdr rmpp_hdr;
164 struct ib_sa_hdr sa_hdr; 171 struct ib_sa_hdr sa_hdr;
165 u8 data[200]; 172 u8 data[IB_MGMT_SA_DATA];
166} __attribute__ ((packed)); 173} __attribute__ ((packed));
167 174
168struct ib_vendor_mad { 175struct ib_vendor_mad {
@@ -170,7 +177,7 @@ struct ib_vendor_mad {
170 struct ib_rmpp_hdr rmpp_hdr; 177 struct ib_rmpp_hdr rmpp_hdr;
171 u8 reserved; 178 u8 reserved;
172 u8 oui[3]; 179 u8 oui[3];
173 u8 data[216]; 180 u8 data[IB_MGMT_VENDOR_DATA];
174}; 181};
175 182
176struct ib_class_port_info 183struct ib_class_port_info
@@ -589,7 +596,7 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
589 u32 remote_qpn, u16 pkey_index, 596 u32 remote_qpn, u16 pkey_index,
590 struct ib_ah *ah, int rmpp_active, 597 struct ib_ah *ah, int rmpp_active,
591 int hdr_len, int data_len, 598 int hdr_len, int data_len,
592 unsigned int __nocast gfp_mask); 599 gfp_t gfp_mask);
593 600
594/** 601/**
595 * ib_free_send_mad - Returns data buffers used to send a MAD. 602 * ib_free_send_mad - Returns data buffers used to send a MAD.
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index a7555c800ecf..f404fe21cc21 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -285,7 +285,7 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query);
285int ib_sa_path_rec_get(struct ib_device *device, u8 port_num, 285int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
286 struct ib_sa_path_rec *rec, 286 struct ib_sa_path_rec *rec,
287 ib_sa_comp_mask comp_mask, 287 ib_sa_comp_mask comp_mask,
288 int timeout_ms, unsigned int __nocast gfp_mask, 288 int timeout_ms, gfp_t gfp_mask,
289 void (*callback)(int status, 289 void (*callback)(int status,
290 struct ib_sa_path_rec *resp, 290 struct ib_sa_path_rec *resp,
291 void *context), 291 void *context),
@@ -296,7 +296,7 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
296 u8 method, 296 u8 method,
297 struct ib_sa_mcmember_rec *rec, 297 struct ib_sa_mcmember_rec *rec,
298 ib_sa_comp_mask comp_mask, 298 ib_sa_comp_mask comp_mask,
299 int timeout_ms, unsigned int __nocast gfp_mask, 299 int timeout_ms, gfp_t gfp_mask,
300 void (*callback)(int status, 300 void (*callback)(int status,
301 struct ib_sa_mcmember_rec *resp, 301 struct ib_sa_mcmember_rec *resp,
302 void *context), 302 void *context),
@@ -307,7 +307,7 @@ int ib_sa_service_rec_query(struct ib_device *device, u8 port_num,
307 u8 method, 307 u8 method,
308 struct ib_sa_service_rec *rec, 308 struct ib_sa_service_rec *rec,
309 ib_sa_comp_mask comp_mask, 309 ib_sa_comp_mask comp_mask,
310 int timeout_ms, unsigned int __nocast gfp_mask, 310 int timeout_ms, gfp_t gfp_mask,
311 void (*callback)(int status, 311 void (*callback)(int status,
312 struct ib_sa_service_rec *resp, 312 struct ib_sa_service_rec *resp,
313 void *context), 313 void *context),
@@ -342,7 +342,7 @@ static inline int
342ib_sa_mcmember_rec_set(struct ib_device *device, u8 port_num, 342ib_sa_mcmember_rec_set(struct ib_device *device, u8 port_num,
343 struct ib_sa_mcmember_rec *rec, 343 struct ib_sa_mcmember_rec *rec,
344 ib_sa_comp_mask comp_mask, 344 ib_sa_comp_mask comp_mask,
345 int timeout_ms, unsigned int __nocast gfp_mask, 345 int timeout_ms, gfp_t gfp_mask,
346 void (*callback)(int status, 346 void (*callback)(int status,
347 struct ib_sa_mcmember_rec *resp, 347 struct ib_sa_mcmember_rec *resp,
348 void *context), 348 void *context),
@@ -384,7 +384,7 @@ static inline int
384ib_sa_mcmember_rec_delete(struct ib_device *device, u8 port_num, 384ib_sa_mcmember_rec_delete(struct ib_device *device, u8 port_num,
385 struct ib_sa_mcmember_rec *rec, 385 struct ib_sa_mcmember_rec *rec,
386 ib_sa_comp_mask comp_mask, 386 ib_sa_comp_mask comp_mask,
387 int timeout_ms, unsigned int __nocast gfp_mask, 387 int timeout_ms, gfp_t gfp_mask,
388 void (*callback)(int status, 388 void (*callback)(int status,
389 struct ib_sa_mcmember_rec *resp, 389 struct ib_sa_mcmember_rec *resp,
390 void *context), 390 void *context),
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e16cf94870f2..e6f4c9e55df7 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -665,7 +665,6 @@ struct ib_ucontext {
665 struct list_head qp_list; 665 struct list_head qp_list;
666 struct list_head srq_list; 666 struct list_head srq_list;
667 struct list_head ah_list; 667 struct list_head ah_list;
668 spinlock_t lock;
669}; 668};
670 669
671struct ib_uobject { 670struct ib_uobject {
diff --git a/include/rxrpc/call.h b/include/rxrpc/call.h
index f48f27e9e0ab..b86f83743510 100644
--- a/include/rxrpc/call.h
+++ b/include/rxrpc/call.h
@@ -203,7 +203,7 @@ extern int rxrpc_call_write_data(struct rxrpc_call *call,
203 size_t sioc, 203 size_t sioc,
204 struct kvec *siov, 204 struct kvec *siov,
205 uint8_t rxhdr_flags, 205 uint8_t rxhdr_flags,
206 int alloc_flags, 206 gfp_t alloc_flags,
207 int dup_data, 207 int dup_data,
208 size_t *size_sent); 208 size_t *size_sent);
209 209
diff --git a/include/rxrpc/message.h b/include/rxrpc/message.h
index 3a59df6870b2..b318f273d4f2 100644
--- a/include/rxrpc/message.h
+++ b/include/rxrpc/message.h
@@ -63,7 +63,7 @@ extern int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
63 uint8_t type, 63 uint8_t type,
64 int count, 64 int count,
65 struct kvec *diov, 65 struct kvec *diov,
66 int alloc_flags, 66 gfp_t alloc_flags,
67 struct rxrpc_message **_msg); 67 struct rxrpc_message **_msg);
68 68
69extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg); 69extern int rxrpc_conn_sendmsg(struct rxrpc_connection *conn, struct rxrpc_message *msg);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index c0e4c67d836f..7ece05666feb 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -163,6 +163,7 @@ struct scsi_target {
163 unsigned int id; /* target id ... replace 163 unsigned int id; /* target id ... replace
164 * scsi_device.id eventually */ 164 * scsi_device.id eventually */
165 unsigned long create:1; /* signal that it needs to be added */ 165 unsigned long create:1; /* signal that it needs to be added */
166 char scsi_level;
166 void *hostdata; /* available to low-level driver */ 167 void *hostdata; /* available to low-level driver */
167 unsigned long starget_data[0]; /* for the transport */ 168 unsigned long starget_data[0]; /* for the transport */
168 /* starget_data must be the last element!!!! */ 169 /* starget_data must be the last element!!!! */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 916144be208b..69313ba7505b 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -439,6 +439,8 @@ enum scsi_host_state {
439 SHOST_CANCEL, 439 SHOST_CANCEL,
440 SHOST_DEL, 440 SHOST_DEL,
441 SHOST_RECOVERY, 441 SHOST_RECOVERY,
442 SHOST_CANCEL_RECOVERY,
443 SHOST_DEL_RECOVERY,
442}; 444};
443 445
444struct Scsi_Host { 446struct Scsi_Host {
@@ -465,8 +467,6 @@ struct Scsi_Host {
465 467
466 struct list_head eh_cmd_q; 468 struct list_head eh_cmd_q;
467 struct task_struct * ehandler; /* Error recovery thread. */ 469 struct task_struct * ehandler; /* Error recovery thread. */
468 struct semaphore * eh_wait; /* The error recovery thread waits
469 on this. */
470 struct semaphore * eh_action; /* Wait for specific actions on the 470 struct semaphore * eh_action; /* Wait for specific actions on the
471 host. */ 471 host. */
472 unsigned int eh_active:1; /* Indicates the eh thread is awake and active if 472 unsigned int eh_active:1; /* Indicates the eh thread is awake and active if
@@ -621,6 +621,13 @@ static inline struct Scsi_Host *dev_to_shost(struct device *dev)
621 return container_of(dev, struct Scsi_Host, shost_gendev); 621 return container_of(dev, struct Scsi_Host, shost_gendev);
622} 622}
623 623
624static inline int scsi_host_in_recovery(struct Scsi_Host *shost)
625{
626 return shost->shost_state == SHOST_RECOVERY ||
627 shost->shost_state == SHOST_CANCEL_RECOVERY ||
628 shost->shost_state == SHOST_DEL_RECOVERY;
629}
630
624extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *); 631extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *);
625extern void scsi_flush_work(struct Scsi_Host *); 632extern void scsi_flush_work(struct Scsi_Host *);
626 633
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 115db056dc6b..b0d445437372 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -103,8 +103,8 @@ enum fc_port_state {
103 incapable of reporting */ 103 incapable of reporting */
104#define FC_PORTSPEED_1GBIT 1 104#define FC_PORTSPEED_1GBIT 1
105#define FC_PORTSPEED_2GBIT 2 105#define FC_PORTSPEED_2GBIT 2
106#define FC_PORTSPEED_10GBIT 4 106#define FC_PORTSPEED_4GBIT 4
107#define FC_PORTSPEED_4GBIT 8 107#define FC_PORTSPEED_10GBIT 8
108#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ 108#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
109 109
110/* 110/*
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 2857cf0472df..d11f34832a97 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -527,6 +527,8 @@ struct _snd_ac97 {
527 struct device dev; 527 struct device dev;
528}; 528};
529 529
530#define to_ac97_t(d) container_of(d, struct _snd_ac97, dev)
531
530/* conditions */ 532/* conditions */
531static inline int ac97_is_audio(ac97_t * ac97) 533static inline int ac97_is_audio(ac97_t * ac97)
532{ 534{
diff --git a/include/sound/core.h b/include/sound/core.h
index 26160adcdffc..6d971a4c4ca0 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -290,13 +290,13 @@ void snd_memory_init(void);
290void snd_memory_done(void); 290void snd_memory_done(void);
291int snd_memory_info_init(void); 291int snd_memory_info_init(void);
292int snd_memory_info_done(void); 292int snd_memory_info_done(void);
293void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags); 293void *snd_hidden_kmalloc(size_t size, gfp_t flags);
294void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags); 294void *snd_hidden_kzalloc(size_t size, gfp_t flags);
295void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags); 295void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags);
296void snd_hidden_kfree(const void *obj); 296void snd_hidden_kfree(const void *obj);
297void *snd_hidden_vmalloc(unsigned long size); 297void *snd_hidden_vmalloc(unsigned long size);
298void snd_hidden_vfree(void *obj); 298void snd_hidden_vfree(void *obj);
299char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags); 299char *snd_hidden_kstrdup(const char *s, gfp_t flags);
300#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) 300#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
301#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags) 301#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags)
302#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) 302#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
diff --git a/include/sound/driver.h b/include/sound/driver.h
index 0d12456ec3ae..1ec2fae050a6 100644
--- a/include/sound/driver.h
+++ b/include/sound/driver.h
@@ -51,7 +51,7 @@
51#ifdef CONFIG_SND_DEBUG_MEMORY 51#ifdef CONFIG_SND_DEBUG_MEMORY
52#include <linux/slab.h> 52#include <linux/slab.h>
53#include <linux/vmalloc.h> 53#include <linux/vmalloc.h>
54void *snd_wrapper_kmalloc(size_t, unsigned int __nocast); 54void *snd_wrapper_kmalloc(size_t, gfp_t);
55#undef kmalloc 55#undef kmalloc
56void snd_wrapper_kfree(const void *); 56void snd_wrapper_kfree(const void *);
57#undef kfree 57#undef kfree
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 67bf3f18e96a..14cb2718cb77 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -1059,7 +1059,7 @@ typedef struct {
1059 unsigned char spk71; /* Has 7.1 speakers */ 1059 unsigned char spk71; /* Has 7.1 speakers */
1060 unsigned char sblive51; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */ 1060 unsigned char sblive51; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */
1061 unsigned char spdif_bug; /* Has Spdif phasing bug */ 1061 unsigned char spdif_bug; /* Has Spdif phasing bug */
1062 unsigned char ac97_chip; /* Has an AC97 chip */ 1062 unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */
1063 unsigned char ecard; /* APS EEPROM */ 1063 unsigned char ecard; /* APS EEPROM */
1064 const char *driver; 1064 const char *driver;
1065 const char *name; 1065 const char *name;
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 3a926011507b..a0f18c9cc89d 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -611,6 +611,7 @@ static struct file *do_create(struct dentry *dir, struct dentry *dentry,
611 dentry->d_fsdata = &attr; 611 dentry->d_fsdata = &attr;
612 } 612 }
613 613
614 mode &= ~current->fs->umask;
614 ret = vfs_create(dir->d_inode, dentry, mode, NULL); 615 ret = vfs_create(dir->d_inode, dentry, mode, NULL);
615 dentry->d_fsdata = NULL; 616 dentry->d_fsdata = NULL;
616 if (ret) 617 if (ret)
diff --git a/kernel/audit.c b/kernel/audit.c
index 83096b67510a..aefa73a8a586 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -560,7 +560,7 @@ static void audit_buffer_free(struct audit_buffer *ab)
560} 560}
561 561
562static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx, 562static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
563 unsigned int __nocast gfp_mask, int type) 563 gfp_t gfp_mask, int type)
564{ 564{
565 unsigned long flags; 565 unsigned long flags;
566 struct audit_buffer *ab = NULL; 566 struct audit_buffer *ab = NULL;
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 79866bc6b3a1..28176d083f7b 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -968,8 +968,6 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
968 char *page; 968 char *page;
969 ssize_t retval = 0; 969 ssize_t retval = 0;
970 char *s; 970 char *s;
971 char *start;
972 size_t n;
973 971
974 if (!(page = (char *)__get_free_page(GFP_KERNEL))) 972 if (!(page = (char *)__get_free_page(GFP_KERNEL)))
975 return -ENOMEM; 973 return -ENOMEM;
@@ -999,14 +997,7 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
999 *s++ = '\n'; 997 *s++ = '\n';
1000 *s = '\0'; 998 *s = '\0';
1001 999
1002 /* Do nothing if *ppos is at the eof or beyond the eof. */ 1000 retval = simple_read_from_buffer(buf, nbytes, ppos, page, s - page);
1003 if (s - page <= *ppos)
1004 return 0;
1005
1006 start = page + *ppos;
1007 n = s - start;
1008 retval = n - copy_to_user(buf, start, min(n, nbytes));
1009 *ppos += retval;
1010out: 1001out:
1011 free_page((unsigned long)page); 1002 free_page((unsigned long)page);
1012 return retval; 1003 return retval;
@@ -1679,7 +1670,7 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs)
1679 * GFP_USER - only nodes in current tasks mems allowed ok. 1670 * GFP_USER - only nodes in current tasks mems allowed ok.
1680 **/ 1671 **/
1681 1672
1682int cpuset_zone_allowed(struct zone *z, unsigned int __nocast gfp_mask) 1673int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
1683{ 1674{
1684 int node; /* node that zone z is on */ 1675 int node; /* node that zone z is on */
1685 const struct cpuset *cs; /* current cpuset ancestors */ 1676 const struct cpuset *cs; /* current cpuset ancestors */
diff --git a/kernel/exit.c b/kernel/exit.c
index 6d2089a1bce7..3b25b182d2be 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -371,6 +371,12 @@ static inline void close_files(struct files_struct * files)
371 struct fdtable *fdt; 371 struct fdtable *fdt;
372 372
373 j = 0; 373 j = 0;
374
375 /*
376 * It is safe to dereference the fd table without RCU or
377 * ->file_lock because this is the last reference to the
378 * files structure.
379 */
374 fdt = files_fdtable(files); 380 fdt = files_fdtable(files);
375 for (;;) { 381 for (;;) {
376 unsigned long set; 382 unsigned long set;
@@ -837,6 +843,7 @@ fastcall NORET_TYPE void do_exit(long code)
837 group_dead = atomic_dec_and_test(&tsk->signal->live); 843 group_dead = atomic_dec_and_test(&tsk->signal->live);
838 if (group_dead) { 844 if (group_dead) {
839 del_timer_sync(&tsk->signal->real_timer); 845 del_timer_sync(&tsk->signal->real_timer);
846 exit_itimers(tsk->signal);
840 acct_process(code); 847 acct_process(code);
841 } 848 }
842 exit_mm(tsk); 849 exit_mm(tsk);
@@ -1197,7 +1204,7 @@ static int wait_task_stopped(task_t *p, int delayed_group_leader, int noreap,
1197 1204
1198 exit_code = p->exit_code; 1205 exit_code = p->exit_code;
1199 if (unlikely(!exit_code) || 1206 if (unlikely(!exit_code) ||
1200 unlikely(p->state > TASK_STOPPED)) 1207 unlikely(p->state & TASK_TRACED))
1201 goto bail_ref; 1208 goto bail_ref;
1202 return wait_noreap_copyout(p, pid, uid, 1209 return wait_noreap_copyout(p, pid, uid,
1203 why, (exit_code << 8) | 0x7f, 1210 why, (exit_code << 8) | 0x7f,
diff --git a/kernel/fork.c b/kernel/fork.c
index 8149f3602881..280bd44ac441 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -848,7 +848,7 @@ static inline void copy_flags(unsigned long clone_flags, struct task_struct *p)
848{ 848{
849 unsigned long new_flags = p->flags; 849 unsigned long new_flags = p->flags;
850 850
851 new_flags &= ~PF_SUPERPRIV; 851 new_flags &= ~(PF_SUPERPRIV | PF_NOFREEZE);
852 new_flags |= PF_FORKNOEXEC; 852 new_flags |= PF_FORKNOEXEC;
853 if (!(clone_flags & CLONE_PTRACE)) 853 if (!(clone_flags & CLONE_PTRACE))
854 p->ptrace = 0; 854 p->ptrace = 0;
@@ -1062,7 +1062,8 @@ static task_t *copy_process(unsigned long clone_flags,
1062 * parent's CPU). This avoids alot of nasty races. 1062 * parent's CPU). This avoids alot of nasty races.
1063 */ 1063 */
1064 p->cpus_allowed = current->cpus_allowed; 1064 p->cpus_allowed = current->cpus_allowed;
1065 if (unlikely(!cpu_isset(task_cpu(p), p->cpus_allowed))) 1065 if (unlikely(!cpu_isset(task_cpu(p), p->cpus_allowed) ||
1066 !cpu_online(task_cpu(p))))
1066 set_task_cpu(p, smp_processor_id()); 1067 set_task_cpu(p, smp_processor_id());
1067 1068
1068 /* 1069 /*
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 179baafcdd96..64ab045c3d9d 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -36,7 +36,7 @@
36 * struct kfifo with kfree(). 36 * struct kfifo with kfree().
37 */ 37 */
38struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size, 38struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
39 unsigned int __nocast gfp_mask, spinlock_t *lock) 39 gfp_t gfp_mask, spinlock_t *lock)
40{ 40{
41 struct kfifo *fifo; 41 struct kfifo *fifo;
42 42
@@ -64,7 +64,7 @@ EXPORT_SYMBOL(kfifo_init);
64 * 64 *
65 * The size will be rounded-up to a power of 2. 65 * The size will be rounded-up to a power of 2.
66 */ 66 */
67struct kfifo *kfifo_alloc(unsigned int size, unsigned int __nocast gfp_mask, spinlock_t *lock) 67struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock)
68{ 68{
69 unsigned char *buffer; 69 unsigned char *buffer;
70 struct kfifo *ret; 70 struct kfifo *ret;
diff --git a/kernel/params.c b/kernel/params.c
index fbf173215fd2..1a8614bac5d5 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -80,8 +80,6 @@ static char *next_arg(char *args, char **param, char **val)
80 int in_quote = 0, quoted = 0; 80 int in_quote = 0, quoted = 0;
81 char *next; 81 char *next;
82 82
83 /* Chew any extra spaces */
84 while (*args == ' ') args++;
85 if (*args == '"') { 83 if (*args == '"') {
86 args++; 84 args++;
87 in_quote = 1; 85 in_quote = 1;
@@ -121,6 +119,10 @@ static char *next_arg(char *args, char **param, char **val)
121 next = args + i + 1; 119 next = args + i + 1;
122 } else 120 } else
123 next = args + i; 121 next = args + i;
122
123 /* Chew up trailing spaces. */
124 while (*next == ' ')
125 next++;
124 return next; 126 return next;
125} 127}
126 128
@@ -135,6 +137,10 @@ int parse_args(const char *name,
135 137
136 DEBUGP("Parsing ARGS: %s\n", args); 138 DEBUGP("Parsing ARGS: %s\n", args);
137 139
140 /* Chew leading spaces */
141 while (*args == ' ')
142 args++;
143
138 while (*args) { 144 while (*args) {
139 int ret; 145 int ret;
140 146
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index ad85d3f0dcc4..bf374fceb39c 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -91,7 +91,7 @@ static inline union cpu_time_count cpu_time_sub(clockid_t which_clock,
91 * Update expiry time from increment, and increase overrun count, 91 * Update expiry time from increment, and increase overrun count,
92 * given the current clock sample. 92 * given the current clock sample.
93 */ 93 */
94static inline void bump_cpu_timer(struct k_itimer *timer, 94static void bump_cpu_timer(struct k_itimer *timer,
95 union cpu_time_count now) 95 union cpu_time_count now)
96{ 96{
97 int i; 97 int i;
@@ -110,7 +110,7 @@ static inline void bump_cpu_timer(struct k_itimer *timer,
110 for (i = 0; incr < delta - incr; i++) 110 for (i = 0; incr < delta - incr; i++)
111 incr = incr << 1; 111 incr = incr << 1;
112 for (; i >= 0; incr >>= 1, i--) { 112 for (; i >= 0; incr >>= 1, i--) {
113 if (delta <= incr) 113 if (delta < incr)
114 continue; 114 continue;
115 timer->it.cpu.expires.sched += incr; 115 timer->it.cpu.expires.sched += incr;
116 timer->it_overrun += 1 << i; 116 timer->it_overrun += 1 << i;
@@ -128,7 +128,7 @@ static inline void bump_cpu_timer(struct k_itimer *timer,
128 for (i = 0; cputime_lt(incr, cputime_sub(delta, incr)); i++) 128 for (i = 0; cputime_lt(incr, cputime_sub(delta, incr)); i++)
129 incr = cputime_add(incr, incr); 129 incr = cputime_add(incr, incr);
130 for (; i >= 0; incr = cputime_halve(incr), i--) { 130 for (; i >= 0; incr = cputime_halve(incr), i--) {
131 if (cputime_le(delta, incr)) 131 if (cputime_lt(delta, incr))
132 continue; 132 continue;
133 timer->it.cpu.expires.cpu = 133 timer->it.cpu.expires.cpu =
134 cputime_add(timer->it.cpu.expires.cpu, incr); 134 cputime_add(timer->it.cpu.expires.cpu, incr);
@@ -380,14 +380,9 @@ int posix_cpu_timer_create(struct k_itimer *new_timer)
380int posix_cpu_timer_del(struct k_itimer *timer) 380int posix_cpu_timer_del(struct k_itimer *timer)
381{ 381{
382 struct task_struct *p = timer->it.cpu.task; 382 struct task_struct *p = timer->it.cpu.task;
383 int ret = 0;
383 384
384 if (timer->it.cpu.firing) 385 if (likely(p != NULL)) {
385 return TIMER_RETRY;
386
387 if (unlikely(p == NULL))
388 return 0;
389
390 if (!list_empty(&timer->it.cpu.entry)) {
391 read_lock(&tasklist_lock); 386 read_lock(&tasklist_lock);
392 if (unlikely(p->signal == NULL)) { 387 if (unlikely(p->signal == NULL)) {
393 /* 388 /*
@@ -396,18 +391,20 @@ int posix_cpu_timer_del(struct k_itimer *timer)
396 */ 391 */
397 BUG_ON(!list_empty(&timer->it.cpu.entry)); 392 BUG_ON(!list_empty(&timer->it.cpu.entry));
398 } else { 393 } else {
399 /*
400 * Take us off the task's timer list.
401 */
402 spin_lock(&p->sighand->siglock); 394 spin_lock(&p->sighand->siglock);
403 list_del(&timer->it.cpu.entry); 395 if (timer->it.cpu.firing)
396 ret = TIMER_RETRY;
397 else
398 list_del(&timer->it.cpu.entry);
404 spin_unlock(&p->sighand->siglock); 399 spin_unlock(&p->sighand->siglock);
405 } 400 }
406 read_unlock(&tasklist_lock); 401 read_unlock(&tasklist_lock);
402
403 if (!ret)
404 put_task_struct(p);
407 } 405 }
408 put_task_struct(p);
409 406
410 return 0; 407 return ret;
411} 408}
412 409
413/* 410/*
@@ -424,7 +421,6 @@ static void cleanup_timers(struct list_head *head,
424 cputime_t ptime = cputime_add(utime, stime); 421 cputime_t ptime = cputime_add(utime, stime);
425 422
426 list_for_each_entry_safe(timer, next, head, entry) { 423 list_for_each_entry_safe(timer, next, head, entry) {
427 timer->task = NULL;
428 list_del_init(&timer->entry); 424 list_del_init(&timer->entry);
429 if (cputime_lt(timer->expires.cpu, ptime)) { 425 if (cputime_lt(timer->expires.cpu, ptime)) {
430 timer->expires.cpu = cputime_zero; 426 timer->expires.cpu = cputime_zero;
@@ -436,7 +432,6 @@ static void cleanup_timers(struct list_head *head,
436 432
437 ++head; 433 ++head;
438 list_for_each_entry_safe(timer, next, head, entry) { 434 list_for_each_entry_safe(timer, next, head, entry) {
439 timer->task = NULL;
440 list_del_init(&timer->entry); 435 list_del_init(&timer->entry);
441 if (cputime_lt(timer->expires.cpu, utime)) { 436 if (cputime_lt(timer->expires.cpu, utime)) {
442 timer->expires.cpu = cputime_zero; 437 timer->expires.cpu = cputime_zero;
@@ -448,7 +443,6 @@ static void cleanup_timers(struct list_head *head,
448 443
449 ++head; 444 ++head;
450 list_for_each_entry_safe(timer, next, head, entry) { 445 list_for_each_entry_safe(timer, next, head, entry) {
451 timer->task = NULL;
452 list_del_init(&timer->entry); 446 list_del_init(&timer->entry);
453 if (timer->expires.sched < sched_time) { 447 if (timer->expires.sched < sched_time) {
454 timer->expires.sched = 0; 448 timer->expires.sched = 0;
@@ -492,6 +486,9 @@ static void process_timer_rebalance(struct task_struct *p,
492 struct task_struct *t = p; 486 struct task_struct *t = p;
493 unsigned int nthreads = atomic_read(&p->signal->live); 487 unsigned int nthreads = atomic_read(&p->signal->live);
494 488
489 if (!nthreads)
490 return;
491
495 switch (clock_idx) { 492 switch (clock_idx) {
496 default: 493 default:
497 BUG(); 494 BUG();
@@ -500,7 +497,7 @@ static void process_timer_rebalance(struct task_struct *p,
500 left = cputime_div(cputime_sub(expires.cpu, val.cpu), 497 left = cputime_div(cputime_sub(expires.cpu, val.cpu),
501 nthreads); 498 nthreads);
502 do { 499 do {
503 if (!unlikely(t->exit_state)) { 500 if (!unlikely(t->flags & PF_EXITING)) {
504 ticks = cputime_add(prof_ticks(t), left); 501 ticks = cputime_add(prof_ticks(t), left);
505 if (cputime_eq(t->it_prof_expires, 502 if (cputime_eq(t->it_prof_expires,
506 cputime_zero) || 503 cputime_zero) ||
@@ -515,7 +512,7 @@ static void process_timer_rebalance(struct task_struct *p,
515 left = cputime_div(cputime_sub(expires.cpu, val.cpu), 512 left = cputime_div(cputime_sub(expires.cpu, val.cpu),
516 nthreads); 513 nthreads);
517 do { 514 do {
518 if (!unlikely(t->exit_state)) { 515 if (!unlikely(t->flags & PF_EXITING)) {
519 ticks = cputime_add(virt_ticks(t), left); 516 ticks = cputime_add(virt_ticks(t), left);
520 if (cputime_eq(t->it_virt_expires, 517 if (cputime_eq(t->it_virt_expires,
521 cputime_zero) || 518 cputime_zero) ||
@@ -530,7 +527,7 @@ static void process_timer_rebalance(struct task_struct *p,
530 nsleft = expires.sched - val.sched; 527 nsleft = expires.sched - val.sched;
531 do_div(nsleft, nthreads); 528 do_div(nsleft, nthreads);
532 do { 529 do {
533 if (!unlikely(t->exit_state)) { 530 if (!unlikely(t->flags & PF_EXITING)) {
534 ns = t->sched_time + nsleft; 531 ns = t->sched_time + nsleft;
535 if (t->it_sched_expires == 0 || 532 if (t->it_sched_expires == 0 ||
536 t->it_sched_expires > ns) { 533 t->it_sched_expires > ns) {
@@ -569,6 +566,9 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now)
569 struct cpu_timer_list *next; 566 struct cpu_timer_list *next;
570 unsigned long i; 567 unsigned long i;
571 568
569 if (CPUCLOCK_PERTHREAD(timer->it_clock) && (p->flags & PF_EXITING))
570 return;
571
572 head = (CPUCLOCK_PERTHREAD(timer->it_clock) ? 572 head = (CPUCLOCK_PERTHREAD(timer->it_clock) ?
573 p->cpu_timers : p->signal->cpu_timers); 573 p->cpu_timers : p->signal->cpu_timers);
574 head += CPUCLOCK_WHICH(timer->it_clock); 574 head += CPUCLOCK_WHICH(timer->it_clock);
@@ -579,17 +579,15 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now)
579 listpos = head; 579 listpos = head;
580 if (CPUCLOCK_WHICH(timer->it_clock) == CPUCLOCK_SCHED) { 580 if (CPUCLOCK_WHICH(timer->it_clock) == CPUCLOCK_SCHED) {
581 list_for_each_entry(next, head, entry) { 581 list_for_each_entry(next, head, entry) {
582 if (next->expires.sched > nt->expires.sched) { 582 if (next->expires.sched > nt->expires.sched)
583 listpos = &next->entry;
584 break; 583 break;
585 } 584 listpos = &next->entry;
586 } 585 }
587 } else { 586 } else {
588 list_for_each_entry(next, head, entry) { 587 list_for_each_entry(next, head, entry) {
589 if (cputime_gt(next->expires.cpu, nt->expires.cpu)) { 588 if (cputime_gt(next->expires.cpu, nt->expires.cpu))
590 listpos = &next->entry;
591 break; 589 break;
592 } 590 listpos = &next->entry;
593 } 591 }
594 } 592 }
595 list_add(&nt->entry, listpos); 593 list_add(&nt->entry, listpos);
@@ -733,9 +731,15 @@ int posix_cpu_timer_set(struct k_itimer *timer, int flags,
733 * Disarm any old timer after extracting its expiry time. 731 * Disarm any old timer after extracting its expiry time.
734 */ 732 */
735 BUG_ON(!irqs_disabled()); 733 BUG_ON(!irqs_disabled());
734
735 ret = 0;
736 spin_lock(&p->sighand->siglock); 736 spin_lock(&p->sighand->siglock);
737 old_expires = timer->it.cpu.expires; 737 old_expires = timer->it.cpu.expires;
738 list_del_init(&timer->it.cpu.entry); 738 if (unlikely(timer->it.cpu.firing)) {
739 timer->it.cpu.firing = -1;
740 ret = TIMER_RETRY;
741 } else
742 list_del_init(&timer->it.cpu.entry);
739 spin_unlock(&p->sighand->siglock); 743 spin_unlock(&p->sighand->siglock);
740 744
741 /* 745 /*
@@ -783,7 +787,7 @@ int posix_cpu_timer_set(struct k_itimer *timer, int flags,
783 } 787 }
784 } 788 }
785 789
786 if (unlikely(timer->it.cpu.firing)) { 790 if (unlikely(ret)) {
787 /* 791 /*
788 * We are colliding with the timer actually firing. 792 * We are colliding with the timer actually firing.
789 * Punt after filling in the timer's old value, and 793 * Punt after filling in the timer's old value, and
@@ -791,8 +795,6 @@ int posix_cpu_timer_set(struct k_itimer *timer, int flags,
791 * it as an overrun (thanks to bump_cpu_timer above). 795 * it as an overrun (thanks to bump_cpu_timer above).
792 */ 796 */
793 read_unlock(&tasklist_lock); 797 read_unlock(&tasklist_lock);
794 timer->it.cpu.firing = -1;
795 ret = TIMER_RETRY;
796 goto out; 798 goto out;
797 } 799 }
798 800
@@ -958,14 +960,16 @@ void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp)
958static void check_thread_timers(struct task_struct *tsk, 960static void check_thread_timers(struct task_struct *tsk,
959 struct list_head *firing) 961 struct list_head *firing)
960{ 962{
963 int maxfire;
961 struct list_head *timers = tsk->cpu_timers; 964 struct list_head *timers = tsk->cpu_timers;
962 965
966 maxfire = 20;
963 tsk->it_prof_expires = cputime_zero; 967 tsk->it_prof_expires = cputime_zero;
964 while (!list_empty(timers)) { 968 while (!list_empty(timers)) {
965 struct cpu_timer_list *t = list_entry(timers->next, 969 struct cpu_timer_list *t = list_entry(timers->next,
966 struct cpu_timer_list, 970 struct cpu_timer_list,
967 entry); 971 entry);
968 if (cputime_lt(prof_ticks(tsk), t->expires.cpu)) { 972 if (!--maxfire || cputime_lt(prof_ticks(tsk), t->expires.cpu)) {
969 tsk->it_prof_expires = t->expires.cpu; 973 tsk->it_prof_expires = t->expires.cpu;
970 break; 974 break;
971 } 975 }
@@ -974,12 +978,13 @@ static void check_thread_timers(struct task_struct *tsk,
974 } 978 }
975 979
976 ++timers; 980 ++timers;
981 maxfire = 20;
977 tsk->it_virt_expires = cputime_zero; 982 tsk->it_virt_expires = cputime_zero;
978 while (!list_empty(timers)) { 983 while (!list_empty(timers)) {
979 struct cpu_timer_list *t = list_entry(timers->next, 984 struct cpu_timer_list *t = list_entry(timers->next,
980 struct cpu_timer_list, 985 struct cpu_timer_list,
981 entry); 986 entry);
982 if (cputime_lt(virt_ticks(tsk), t->expires.cpu)) { 987 if (!--maxfire || cputime_lt(virt_ticks(tsk), t->expires.cpu)) {
983 tsk->it_virt_expires = t->expires.cpu; 988 tsk->it_virt_expires = t->expires.cpu;
984 break; 989 break;
985 } 990 }
@@ -988,12 +993,13 @@ static void check_thread_timers(struct task_struct *tsk,
988 } 993 }
989 994
990 ++timers; 995 ++timers;
996 maxfire = 20;
991 tsk->it_sched_expires = 0; 997 tsk->it_sched_expires = 0;
992 while (!list_empty(timers)) { 998 while (!list_empty(timers)) {
993 struct cpu_timer_list *t = list_entry(timers->next, 999 struct cpu_timer_list *t = list_entry(timers->next,
994 struct cpu_timer_list, 1000 struct cpu_timer_list,
995 entry); 1001 entry);
996 if (tsk->sched_time < t->expires.sched) { 1002 if (!--maxfire || tsk->sched_time < t->expires.sched) {
997 tsk->it_sched_expires = t->expires.sched; 1003 tsk->it_sched_expires = t->expires.sched;
998 break; 1004 break;
999 } 1005 }
@@ -1010,6 +1016,7 @@ static void check_thread_timers(struct task_struct *tsk,
1010static void check_process_timers(struct task_struct *tsk, 1016static void check_process_timers(struct task_struct *tsk,
1011 struct list_head *firing) 1017 struct list_head *firing)
1012{ 1018{
1019 int maxfire;
1013 struct signal_struct *const sig = tsk->signal; 1020 struct signal_struct *const sig = tsk->signal;
1014 cputime_t utime, stime, ptime, virt_expires, prof_expires; 1021 cputime_t utime, stime, ptime, virt_expires, prof_expires;
1015 unsigned long long sched_time, sched_expires; 1022 unsigned long long sched_time, sched_expires;
@@ -1042,12 +1049,13 @@ static void check_process_timers(struct task_struct *tsk,
1042 } while (t != tsk); 1049 } while (t != tsk);
1043 ptime = cputime_add(utime, stime); 1050 ptime = cputime_add(utime, stime);
1044 1051
1052 maxfire = 20;
1045 prof_expires = cputime_zero; 1053 prof_expires = cputime_zero;
1046 while (!list_empty(timers)) { 1054 while (!list_empty(timers)) {
1047 struct cpu_timer_list *t = list_entry(timers->next, 1055 struct cpu_timer_list *t = list_entry(timers->next,
1048 struct cpu_timer_list, 1056 struct cpu_timer_list,
1049 entry); 1057 entry);
1050 if (cputime_lt(ptime, t->expires.cpu)) { 1058 if (!--maxfire || cputime_lt(ptime, t->expires.cpu)) {
1051 prof_expires = t->expires.cpu; 1059 prof_expires = t->expires.cpu;
1052 break; 1060 break;
1053 } 1061 }
@@ -1056,12 +1064,13 @@ static void check_process_timers(struct task_struct *tsk,
1056 } 1064 }
1057 1065
1058 ++timers; 1066 ++timers;
1067 maxfire = 20;
1059 virt_expires = cputime_zero; 1068 virt_expires = cputime_zero;
1060 while (!list_empty(timers)) { 1069 while (!list_empty(timers)) {
1061 struct cpu_timer_list *t = list_entry(timers->next, 1070 struct cpu_timer_list *t = list_entry(timers->next,
1062 struct cpu_timer_list, 1071 struct cpu_timer_list,
1063 entry); 1072 entry);
1064 if (cputime_lt(utime, t->expires.cpu)) { 1073 if (!--maxfire || cputime_lt(utime, t->expires.cpu)) {
1065 virt_expires = t->expires.cpu; 1074 virt_expires = t->expires.cpu;
1066 break; 1075 break;
1067 } 1076 }
@@ -1070,12 +1079,13 @@ static void check_process_timers(struct task_struct *tsk,
1070 } 1079 }
1071 1080
1072 ++timers; 1081 ++timers;
1082 maxfire = 20;
1073 sched_expires = 0; 1083 sched_expires = 0;
1074 while (!list_empty(timers)) { 1084 while (!list_empty(timers)) {
1075 struct cpu_timer_list *t = list_entry(timers->next, 1085 struct cpu_timer_list *t = list_entry(timers->next,
1076 struct cpu_timer_list, 1086 struct cpu_timer_list,
1077 entry); 1087 entry);
1078 if (sched_time < t->expires.sched) { 1088 if (!--maxfire || sched_time < t->expires.sched) {
1079 sched_expires = t->expires.sched; 1089 sched_expires = t->expires.sched;
1080 break; 1090 break;
1081 } 1091 }
@@ -1158,6 +1168,9 @@ static void check_process_timers(struct task_struct *tsk,
1158 unsigned long long sched_left, sched; 1168 unsigned long long sched_left, sched;
1159 const unsigned int nthreads = atomic_read(&sig->live); 1169 const unsigned int nthreads = atomic_read(&sig->live);
1160 1170
1171 if (!nthreads)
1172 return;
1173
1161 prof_left = cputime_sub(prof_expires, utime); 1174 prof_left = cputime_sub(prof_expires, utime);
1162 prof_left = cputime_sub(prof_left, stime); 1175 prof_left = cputime_sub(prof_left, stime);
1163 prof_left = cputime_div(prof_left, nthreads); 1176 prof_left = cputime_div(prof_left, nthreads);
@@ -1194,7 +1207,7 @@ static void check_process_timers(struct task_struct *tsk,
1194 1207
1195 do { 1208 do {
1196 t = next_thread(t); 1209 t = next_thread(t);
1197 } while (unlikely(t->exit_state)); 1210 } while (unlikely(t->flags & PF_EXITING));
1198 } while (t != tsk); 1211 } while (t != tsk);
1199 } 1212 }
1200} 1213}
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index b7b532acd9fc..dda3cda73c77 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -1157,7 +1157,7 @@ retry_delete:
1157} 1157}
1158 1158
1159/* 1159/*
1160 * This is called by __exit_signal, only when there are no more 1160 * This is called by do_exit or de_thread, only when there are no more
1161 * references to the shared signal_struct. 1161 * references to the shared signal_struct.
1162 */ 1162 */
1163void exit_itimers(struct signal_struct *sig) 1163void exit_itimers(struct signal_struct *sig)
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 396c7873e804..46a5e5acff97 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -29,7 +29,7 @@ config PM_DEBUG
29 29
30config SOFTWARE_SUSPEND 30config SOFTWARE_SUSPEND
31 bool "Software Suspend" 31 bool "Software Suspend"
32 depends on PM && SWAP && (X86 || ((FVR || PPC32) && !SMP)) 32 depends on PM && SWAP && (X86 && (!SMP || SUSPEND_SMP)) || ((FVR || PPC32) && !SMP)
33 ---help--- 33 ---help---
34 Enable the possibility of suspending the machine. 34 Enable the possibility of suspending the machine.
35 It doesn't need APM. 35 It doesn't need APM.
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 2d8bf054d036..761956e813f5 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -17,12 +17,12 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/mount.h> 19#include <linux/mount.h>
20#include <linux/pm.h>
20 21
21#include "power.h" 22#include "power.h"
22 23
23 24
24extern suspend_disk_method_t pm_disk_mode; 25extern suspend_disk_method_t pm_disk_mode;
25extern struct pm_ops * pm_ops;
26 26
27extern int swsusp_suspend(void); 27extern int swsusp_suspend(void);
28extern int swsusp_write(void); 28extern int swsusp_write(void);
@@ -49,13 +49,11 @@ dev_t swsusp_resume_device;
49 49
50static void power_down(suspend_disk_method_t mode) 50static void power_down(suspend_disk_method_t mode)
51{ 51{
52 unsigned long flags;
53 int error = 0; 52 int error = 0;
54 53
55 local_irq_save(flags);
56 switch(mode) { 54 switch(mode) {
57 case PM_DISK_PLATFORM: 55 case PM_DISK_PLATFORM:
58 device_shutdown(); 56 kernel_power_off_prepare();
59 error = pm_ops->enter(PM_SUSPEND_DISK); 57 error = pm_ops->enter(PM_SUSPEND_DISK);
60 break; 58 break;
61 case PM_DISK_SHUTDOWN: 59 case PM_DISK_SHUTDOWN:
diff --git a/kernel/power/power.h b/kernel/power/power.h
index cd6a3493cc0d..6748de23e83c 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -1,7 +1,7 @@
1#include <linux/suspend.h> 1#include <linux/suspend.h>
2#include <linux/utsname.h> 2#include <linux/utsname.h>
3 3
4/* With SUSPEND_CONSOLE defined, it suspend looks *really* cool, but 4/* With SUSPEND_CONSOLE defined suspend looks *really* cool, but
5 we probably do not take enough locks for switching consoles, etc, 5 we probably do not take enough locks for switching consoles, etc,
6 so bad things might happen. 6 so bad things might happen.
7*/ 7*/
@@ -9,6 +9,9 @@
9#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) 9#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
10#endif 10#endif
11 11
12#define MAX_PBES ((PAGE_SIZE - sizeof(struct new_utsname) \
13 - 4 - 3*sizeof(unsigned long) - sizeof(int) \
14 - sizeof(void *)) / sizeof(swp_entry_t))
12 15
13struct swsusp_info { 16struct swsusp_info {
14 struct new_utsname uts; 17 struct new_utsname uts;
@@ -18,7 +21,7 @@ struct swsusp_info {
18 unsigned long image_pages; 21 unsigned long image_pages;
19 unsigned long pagedir_pages; 22 unsigned long pagedir_pages;
20 suspend_pagedir_t * suspend_pagedir; 23 suspend_pagedir_t * suspend_pagedir;
21 swp_entry_t pagedir[768]; 24 swp_entry_t pagedir[MAX_PBES];
22} __attribute__((aligned(PAGE_SIZE))); 25} __attribute__((aligned(PAGE_SIZE)));
23 26
24 27
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index d967e875ee82..2d5c45676442 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -363,7 +363,7 @@ static void lock_swapdevices(void)
363} 363}
364 364
365/** 365/**
366 * write_swap_page - Write one page to a fresh swap location. 366 * write_page - Write one page to a fresh swap location.
367 * @addr: Address we're writing. 367 * @addr: Address we're writing.
368 * @loc: Place to store the entry we used. 368 * @loc: Place to store the entry we used.
369 * 369 *
@@ -402,15 +402,14 @@ static int write_page(unsigned long addr, swp_entry_t * loc)
402static void data_free(void) 402static void data_free(void)
403{ 403{
404 swp_entry_t entry; 404 swp_entry_t entry;
405 int i; 405 struct pbe * p;
406 406
407 for (i = 0; i < nr_copy_pages; i++) { 407 for_each_pbe(p, pagedir_nosave) {
408 entry = (pagedir_nosave + i)->swap_address; 408 entry = p->swap_address;
409 if (entry.val) 409 if (entry.val)
410 swap_free(entry); 410 swap_free(entry);
411 else 411 else
412 break; 412 break;
413 (pagedir_nosave + i)->swap_address = (swp_entry_t){0};
414 } 413 }
415} 414}
416 415
@@ -863,6 +862,9 @@ static int alloc_image_pages(void)
863 return 0; 862 return 0;
864} 863}
865 864
865/* Free pages we allocated for suspend. Suspend pages are alocated
866 * before atomic copy, so we need to free them after resume.
867 */
866void swsusp_free(void) 868void swsusp_free(void)
867{ 869{
868 BUG_ON(PageNosave(virt_to_page(pagedir_save))); 870 BUG_ON(PageNosave(virt_to_page(pagedir_save)));
@@ -918,6 +920,7 @@ static int swsusp_alloc(void)
918 920
919 pagedir_nosave = NULL; 921 pagedir_nosave = NULL;
920 nr_copy_pages = calc_nr(nr_copy_pages); 922 nr_copy_pages = calc_nr(nr_copy_pages);
923 nr_copy_pages_check = nr_copy_pages;
921 924
922 pr_debug("suspend: (pages needed: %d + %d free: %d)\n", 925 pr_debug("suspend: (pages needed: %d + %d free: %d)\n",
923 nr_copy_pages, PAGES_FOR_IO, nr_free_pages()); 926 nr_copy_pages, PAGES_FOR_IO, nr_free_pages());
@@ -928,6 +931,10 @@ static int swsusp_alloc(void)
928 if (!enough_swap()) 931 if (!enough_swap())
929 return -ENOSPC; 932 return -ENOSPC;
930 933
934 if (MAX_PBES < nr_copy_pages / PBES_PER_PAGE +
935 !!(nr_copy_pages % PBES_PER_PAGE))
936 return -ENOSPC;
937
931 if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) { 938 if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) {
932 printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); 939 printk(KERN_ERR "suspend: Allocating pagedir failed.\n");
933 return -ENOMEM; 940 return -ENOMEM;
@@ -940,7 +947,6 @@ static int swsusp_alloc(void)
940 return error; 947 return error;
941 } 948 }
942 949
943 nr_copy_pages_check = nr_copy_pages;
944 return 0; 950 return 0;
945} 951}
946 952
@@ -1089,7 +1095,7 @@ static inline void eat_page(void *page)
1089 *eaten_memory = c; 1095 *eaten_memory = c;
1090} 1096}
1091 1097
1092static unsigned long get_usable_page(unsigned gfp_mask) 1098unsigned long get_usable_page(unsigned gfp_mask)
1093{ 1099{
1094 unsigned long m; 1100 unsigned long m;
1095 1101
@@ -1103,7 +1109,7 @@ static unsigned long get_usable_page(unsigned gfp_mask)
1103 return m; 1109 return m;
1104} 1110}
1105 1111
1106static void free_eaten_memory(void) 1112void free_eaten_memory(void)
1107{ 1113{
1108 unsigned long m; 1114 unsigned long m;
1109 void **c; 1115 void **c;
@@ -1213,8 +1219,9 @@ static struct pbe * swsusp_pagedir_relocate(struct pbe *pblist)
1213 free_pagedir(pblist); 1219 free_pagedir(pblist);
1214 free_eaten_memory(); 1220 free_eaten_memory();
1215 pblist = NULL; 1221 pblist = NULL;
1216 } 1222 /* Is this even worth handling? It should never ever happen, and we
1217 else 1223 have just lost user's state, anyway... */
1224 } else
1218 printk("swsusp: Relocated %d pages\n", rel); 1225 printk("swsusp: Relocated %d pages\n", rel);
1219 1226
1220 return pblist; 1227 return pblist;
@@ -1434,9 +1441,9 @@ static int read_pagedir(struct pbe *pblist)
1434 } 1441 }
1435 1442
1436 if (error) 1443 if (error)
1437 free_page((unsigned long)pblist); 1444 free_pagedir(pblist);
1438 1445 else
1439 BUG_ON(i != swsusp_info.pagedir_pages); 1446 BUG_ON(i != swsusp_info.pagedir_pages);
1440 1447
1441 return error; 1448 return error;
1442} 1449}
@@ -1474,11 +1481,12 @@ static int read_suspend_image(void)
1474 /* Allocate memory for the image and read the data from swap */ 1481 /* Allocate memory for the image and read the data from swap */
1475 1482
1476 error = check_pagedir(pagedir_nosave); 1483 error = check_pagedir(pagedir_nosave);
1477 free_eaten_memory(); 1484
1478 if (!error) 1485 if (!error)
1479 error = data_read(pagedir_nosave); 1486 error = data_read(pagedir_nosave);
1480 1487
1481 if (error) { /* We fail cleanly */ 1488 if (error) { /* We fail cleanly */
1489 free_eaten_memory();
1482 for_each_pbe (p, pagedir_nosave) 1490 for_each_pbe (p, pagedir_nosave)
1483 if (p->address) { 1491 if (p->address) {
1484 free_page(p->address); 1492 free_page(p->address);
diff --git a/kernel/printk.c b/kernel/printk.c
index a967605bc2e3..4b8f0f9230a4 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -488,6 +488,11 @@ static int __init printk_time_setup(char *str)
488 488
489__setup("time", printk_time_setup); 489__setup("time", printk_time_setup);
490 490
491__attribute__((weak)) unsigned long long printk_clock(void)
492{
493 return sched_clock();
494}
495
491/* 496/*
492 * This is printk. It can be called from any context. We want it to work. 497 * This is printk. It can be called from any context. We want it to work.
493 * 498 *
@@ -565,7 +570,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
565 loglev_char = default_message_loglevel 570 loglev_char = default_message_loglevel
566 + '0'; 571 + '0';
567 } 572 }
568 t = sched_clock(); 573 t = printk_clock();
569 nanosec_rem = do_div(t, 1000000000); 574 nanosec_rem = do_div(t, 1000000000);
570 tlen = sprintf(tbuf, 575 tlen = sprintf(tbuf,
571 "<%c>[%5lu.%06lu] ", 576 "<%c>[%5lu.%06lu] ",
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index bef3b6901b76..2559d4b8f23f 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -71,7 +71,7 @@ DEFINE_PER_CPU(struct rcu_data, rcu_bh_data) = { 0L };
71 71
72/* Fake initialization required by compiler */ 72/* Fake initialization required by compiler */
73static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL}; 73static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL};
74static int maxbatch = 10; 74static int maxbatch = 10000;
75 75
76#ifndef __HAVE_ARCH_CMPXCHG 76#ifndef __HAVE_ARCH_CMPXCHG
77/* 77/*
@@ -109,6 +109,10 @@ void fastcall call_rcu(struct rcu_head *head,
109 rdp = &__get_cpu_var(rcu_data); 109 rdp = &__get_cpu_var(rcu_data);
110 *rdp->nxttail = head; 110 *rdp->nxttail = head;
111 rdp->nxttail = &head->next; 111 rdp->nxttail = &head->next;
112
113 if (unlikely(++rdp->count > 10000))
114 set_need_resched();
115
112 local_irq_restore(flags); 116 local_irq_restore(flags);
113} 117}
114 118
@@ -140,6 +144,12 @@ void fastcall call_rcu_bh(struct rcu_head *head,
140 rdp = &__get_cpu_var(rcu_bh_data); 144 rdp = &__get_cpu_var(rcu_bh_data);
141 *rdp->nxttail = head; 145 *rdp->nxttail = head;
142 rdp->nxttail = &head->next; 146 rdp->nxttail = &head->next;
147 rdp->count++;
148/*
149 * Should we directly call rcu_do_batch() here ?
150 * if (unlikely(rdp->count > 10000))
151 * rcu_do_batch(rdp);
152 */
143 local_irq_restore(flags); 153 local_irq_restore(flags);
144} 154}
145 155
@@ -157,6 +167,7 @@ static void rcu_do_batch(struct rcu_data *rdp)
157 next = rdp->donelist = list->next; 167 next = rdp->donelist = list->next;
158 list->func(list); 168 list->func(list);
159 list = next; 169 list = next;
170 rdp->count--;
160 if (++count >= maxbatch) 171 if (++count >= maxbatch)
161 break; 172 break;
162 } 173 }
diff --git a/kernel/sched.c b/kernel/sched.c
index 1f31a528fdba..1e5cafdf4e27 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3879,6 +3879,7 @@ EXPORT_SYMBOL(cpu_present_map);
3879 3879
3880#ifndef CONFIG_SMP 3880#ifndef CONFIG_SMP
3881cpumask_t cpu_online_map = CPU_MASK_ALL; 3881cpumask_t cpu_online_map = CPU_MASK_ALL;
3882EXPORT_SYMBOL_GPL(cpu_online_map);
3882cpumask_t cpu_possible_map = CPU_MASK_ALL; 3883cpumask_t cpu_possible_map = CPU_MASK_ALL;
3883#endif 3884#endif
3884 3885
diff --git a/kernel/signal.c b/kernel/signal.c
index b92c3c9f8b9a..f2b96b08fb44 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -262,7 +262,7 @@ next_signal(struct sigpending *pending, sigset_t *mask)
262 return sig; 262 return sig;
263} 263}
264 264
265static struct sigqueue *__sigqueue_alloc(struct task_struct *t, unsigned int __nocast flags, 265static struct sigqueue *__sigqueue_alloc(struct task_struct *t, gfp_t flags,
266 int override_rlimit) 266 int override_rlimit)
267{ 267{
268 struct sigqueue *q = NULL; 268 struct sigqueue *q = NULL;
@@ -397,20 +397,8 @@ void __exit_signal(struct task_struct *tsk)
397 flush_sigqueue(&tsk->pending); 397 flush_sigqueue(&tsk->pending);
398 if (sig) { 398 if (sig) {
399 /* 399 /*
400 * We are cleaning up the signal_struct here. We delayed 400 * We are cleaning up the signal_struct here.
401 * calling exit_itimers until after flush_sigqueue, just in
402 * case our thread-local pending queue contained a queued
403 * timer signal that would have been cleared in
404 * exit_itimers. When that called sigqueue_free, it would
405 * attempt to re-take the tasklist_lock and deadlock. This
406 * can never happen if we ensure that all queues the
407 * timer's signal might be queued on have been flushed
408 * first. The shared_pending queue, and our own pending
409 * queue are the only queues the timer could be on, since
410 * there are no other threads left in the group and timer
411 * signals are constrained to threads inside the group.
412 */ 401 */
413 exit_itimers(sig);
414 exit_thread_group_keys(sig); 402 exit_thread_group_keys(sig);
415 kmem_cache_free(signal_cachep, sig); 403 kmem_cache_free(signal_cachep, sig);
416 } 404 }
@@ -578,7 +566,8 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
578 * is to alert stop-signal processing code when another 566 * is to alert stop-signal processing code when another
579 * processor has come along and cleared the flag. 567 * processor has come along and cleared the flag.
580 */ 568 */
581 tsk->signal->flags |= SIGNAL_STOP_DEQUEUED; 569 if (!(tsk->signal->flags & SIGNAL_GROUP_EXIT))
570 tsk->signal->flags |= SIGNAL_STOP_DEQUEUED;
582 } 571 }
583 if ( signr && 572 if ( signr &&
584 ((info->si_code & __SI_MASK) == __SI_TIMER) && 573 ((info->si_code & __SI_MASK) == __SI_TIMER) &&
@@ -936,34 +925,31 @@ force_sig_specific(int sig, struct task_struct *t)
936 * as soon as they're available, so putting the signal on the shared queue 925 * as soon as they're available, so putting the signal on the shared queue
937 * will be equivalent to sending it to one such thread. 926 * will be equivalent to sending it to one such thread.
938 */ 927 */
939#define wants_signal(sig, p, mask) \ 928static inline int wants_signal(int sig, struct task_struct *p)
940 (!sigismember(&(p)->blocked, sig) \ 929{
941 && !((p)->state & mask) \ 930 if (sigismember(&p->blocked, sig))
942 && !((p)->flags & PF_EXITING) \ 931 return 0;
943 && (task_curr(p) || !signal_pending(p))) 932 if (p->flags & PF_EXITING)
944 933 return 0;
934 if (sig == SIGKILL)
935 return 1;
936 if (p->state & (TASK_STOPPED | TASK_TRACED))
937 return 0;
938 return task_curr(p) || !signal_pending(p);
939}
945 940
946static void 941static void
947__group_complete_signal(int sig, struct task_struct *p) 942__group_complete_signal(int sig, struct task_struct *p)
948{ 943{
949 unsigned int mask;
950 struct task_struct *t; 944 struct task_struct *t;
951 945
952 /* 946 /*
953 * Don't bother traced and stopped tasks (but
954 * SIGKILL will punch through that).
955 */
956 mask = TASK_STOPPED | TASK_TRACED;
957 if (sig == SIGKILL)
958 mask = 0;
959
960 /*
961 * Now find a thread we can wake up to take the signal off the queue. 947 * Now find a thread we can wake up to take the signal off the queue.
962 * 948 *
963 * If the main thread wants the signal, it gets first crack. 949 * If the main thread wants the signal, it gets first crack.
964 * Probably the least surprising to the average bear. 950 * Probably the least surprising to the average bear.
965 */ 951 */
966 if (wants_signal(sig, p, mask)) 952 if (wants_signal(sig, p))
967 t = p; 953 t = p;
968 else if (thread_group_empty(p)) 954 else if (thread_group_empty(p))
969 /* 955 /*
@@ -981,7 +967,7 @@ __group_complete_signal(int sig, struct task_struct *p)
981 t = p->signal->curr_target = p; 967 t = p->signal->curr_target = p;
982 BUG_ON(t->tgid != p->tgid); 968 BUG_ON(t->tgid != p->tgid);
983 969
984 while (!wants_signal(sig, t, mask)) { 970 while (!wants_signal(sig, t)) {
985 t = next_thread(t); 971 t = next_thread(t);
986 if (t == p->signal->curr_target) 972 if (t == p->signal->curr_target)
987 /* 973 /*
@@ -1195,6 +1181,40 @@ kill_proc_info(int sig, struct siginfo *info, pid_t pid)
1195 return error; 1181 return error;
1196} 1182}
1197 1183
1184/* like kill_proc_info(), but doesn't use uid/euid of "current" */
1185int kill_proc_info_as_uid(int sig, struct siginfo *info, pid_t pid,
1186 uid_t uid, uid_t euid)
1187{
1188 int ret = -EINVAL;
1189 struct task_struct *p;
1190
1191 if (!valid_signal(sig))
1192 return ret;
1193
1194 read_lock(&tasklist_lock);
1195 p = find_task_by_pid(pid);
1196 if (!p) {
1197 ret = -ESRCH;
1198 goto out_unlock;
1199 }
1200 if ((!info || ((unsigned long)info != 1 &&
1201 (unsigned long)info != 2 && SI_FROMUSER(info)))
1202 && (euid != p->suid) && (euid != p->uid)
1203 && (uid != p->suid) && (uid != p->uid)) {
1204 ret = -EPERM;
1205 goto out_unlock;
1206 }
1207 if (sig && p->sighand) {
1208 unsigned long flags;
1209 spin_lock_irqsave(&p->sighand->siglock, flags);
1210 ret = __group_send_sig_info(sig, info, p);
1211 spin_unlock_irqrestore(&p->sighand->siglock, flags);
1212 }
1213out_unlock:
1214 read_unlock(&tasklist_lock);
1215 return ret;
1216}
1217EXPORT_SYMBOL_GPL(kill_proc_info_as_uid);
1198 1218
1199/* 1219/*
1200 * kill_something_info() interprets pid in interesting ways just like kill(2). 1220 * kill_something_info() interprets pid in interesting ways just like kill(2).
@@ -1766,7 +1786,8 @@ do_signal_stop(int signr)
1766 * stop is always done with the siglock held, 1786 * stop is always done with the siglock held,
1767 * so this check has no races. 1787 * so this check has no races.
1768 */ 1788 */
1769 if (t->state < TASK_STOPPED) { 1789 if (!t->exit_state &&
1790 !(t->state & (TASK_STOPPED|TASK_TRACED))) {
1770 stop_count++; 1791 stop_count++;
1771 signal_wake_up(t, 0); 1792 signal_wake_up(t, 0);
1772 } 1793 }
diff --git a/kernel/sys.c b/kernel/sys.c
index c80412be2302..2fa1ed18123c 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -361,17 +361,35 @@ out_unlock:
361 return retval; 361 return retval;
362} 362}
363 363
364/**
365 * emergency_restart - reboot the system
366 *
367 * Without shutting down any hardware or taking any locks
368 * reboot the system. This is called when we know we are in
369 * trouble so this is our best effort to reboot. This is
370 * safe to call in interrupt context.
371 */
364void emergency_restart(void) 372void emergency_restart(void)
365{ 373{
366 machine_emergency_restart(); 374 machine_emergency_restart();
367} 375}
368EXPORT_SYMBOL_GPL(emergency_restart); 376EXPORT_SYMBOL_GPL(emergency_restart);
369 377
370void kernel_restart(char *cmd) 378/**
379 * kernel_restart - reboot the system
380 *
381 * Shutdown everything and perform a clean reboot.
382 * This is not safe to call in interrupt context.
383 */
384void kernel_restart_prepare(char *cmd)
371{ 385{
372 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); 386 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
373 system_state = SYSTEM_RESTART; 387 system_state = SYSTEM_RESTART;
374 device_shutdown(); 388 device_shutdown();
389}
390void kernel_restart(char *cmd)
391{
392 kernel_restart_prepare(cmd);
375 if (!cmd) { 393 if (!cmd) {
376 printk(KERN_EMERG "Restarting system.\n"); 394 printk(KERN_EMERG "Restarting system.\n");
377 } else { 395 } else {
@@ -382,6 +400,12 @@ void kernel_restart(char *cmd)
382} 400}
383EXPORT_SYMBOL_GPL(kernel_restart); 401EXPORT_SYMBOL_GPL(kernel_restart);
384 402
403/**
404 * kernel_kexec - reboot the system
405 *
406 * Move into place and start executing a preloaded standalone
407 * executable. If nothing was preloaded return an error.
408 */
385void kernel_kexec(void) 409void kernel_kexec(void)
386{ 410{
387#ifdef CONFIG_KEXEC 411#ifdef CONFIG_KEXEC
@@ -390,9 +414,7 @@ void kernel_kexec(void)
390 if (!image) { 414 if (!image) {
391 return; 415 return;
392 } 416 }
393 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); 417 kernel_restart_prepare(NULL);
394 system_state = SYSTEM_RESTART;
395 device_shutdown();
396 printk(KERN_EMERG "Starting new kernel\n"); 418 printk(KERN_EMERG "Starting new kernel\n");
397 machine_shutdown(); 419 machine_shutdown();
398 machine_kexec(image); 420 machine_kexec(image);
@@ -400,21 +422,39 @@ void kernel_kexec(void)
400} 422}
401EXPORT_SYMBOL_GPL(kernel_kexec); 423EXPORT_SYMBOL_GPL(kernel_kexec);
402 424
403void kernel_halt(void) 425/**
426 * kernel_halt - halt the system
427 *
428 * Shutdown everything and perform a clean system halt.
429 */
430void kernel_halt_prepare(void)
404{ 431{
405 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); 432 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
406 system_state = SYSTEM_HALT; 433 system_state = SYSTEM_HALT;
407 device_shutdown(); 434 device_shutdown();
435}
436void kernel_halt(void)
437{
438 kernel_halt_prepare();
408 printk(KERN_EMERG "System halted.\n"); 439 printk(KERN_EMERG "System halted.\n");
409 machine_halt(); 440 machine_halt();
410} 441}
411EXPORT_SYMBOL_GPL(kernel_halt); 442EXPORT_SYMBOL_GPL(kernel_halt);
412 443
413void kernel_power_off(void) 444/**
445 * kernel_power_off - power_off the system
446 *
447 * Shutdown everything and perform a clean system power_off.
448 */
449void kernel_power_off_prepare(void)
414{ 450{
415 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); 451 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
416 system_state = SYSTEM_POWER_OFF; 452 system_state = SYSTEM_POWER_OFF;
417 device_shutdown(); 453 device_shutdown();
454}
455void kernel_power_off(void)
456{
457 kernel_power_off_prepare();
418 printk(KERN_EMERG "Power down.\n"); 458 printk(KERN_EMERG "Power down.\n");
419 machine_power_off(); 459 machine_power_off();
420} 460}
@@ -1728,8 +1768,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
1728 error = put_user(current->pdeath_signal, (int __user *)arg2); 1768 error = put_user(current->pdeath_signal, (int __user *)arg2);
1729 break; 1769 break;
1730 case PR_GET_DUMPABLE: 1770 case PR_GET_DUMPABLE:
1731 if (current->mm->dumpable) 1771 error = current->mm->dumpable;
1732 error = 1;
1733 break; 1772 break;
1734 case PR_SET_DUMPABLE: 1773 case PR_SET_DUMPABLE:
1735 if (arg2 < 0 || arg2 > 2) { 1774 if (arg2 < 0 || arg2 > 2) {
diff --git a/kernel/time.c b/kernel/time.c
index dd5ae1162a8f..40c2410ac99a 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -570,6 +570,7 @@ void getnstimeofday(struct timespec *tv)
570 tv->tv_sec = x.tv_sec; 570 tv->tv_sec = x.tv_sec;
571 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC; 571 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
572} 572}
573EXPORT_SYMBOL_GPL(getnstimeofday);
573#endif 574#endif
574 575
575#if (BITS_PER_LONG < 64) 576#if (BITS_PER_LONG < 64)
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 000000000000..3bef1ea94c99
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1,6 @@
1#
2# Generated files
3#
4gen_crc32table
5crc32table.h
6
diff --git a/lib/idr.c b/lib/idr.c
index 6415d053e2bf..d4df21debc4d 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -346,6 +346,19 @@ void idr_remove(struct idr *idp, int id)
346EXPORT_SYMBOL(idr_remove); 346EXPORT_SYMBOL(idr_remove);
347 347
348/** 348/**
349 * idr_destroy - release all cached layers within an idr tree
350 * idp: idr handle
351 */
352void idr_destroy(struct idr *idp)
353{
354 while (idp->id_free_cnt) {
355 struct idr_layer *p = alloc_layer(idp);
356 kmem_cache_free(idr_layer_cache, p);
357 }
358}
359EXPORT_SYMBOL(idr_destroy);
360
361/**
349 * idr_find - return pointer for given id 362 * idr_find - return pointer for given id
350 * @idp: idr handle 363 * @idp: idr handle
351 * @id: lookup key 364 * @id: lookup key
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 6a8bc6e06431..d1c057e71b68 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -110,7 +110,7 @@ radix_tree_node_free(struct radix_tree_node *node)
110 * success, return zero, with preemption disabled. On error, return -ENOMEM 110 * success, return zero, with preemption disabled. On error, return -ENOMEM
111 * with preemption not disabled. 111 * with preemption not disabled.
112 */ 112 */
113int radix_tree_preload(unsigned int __nocast gfp_mask) 113int radix_tree_preload(gfp_t gfp_mask)
114{ 114{
115 struct radix_tree_preload *rtp; 115 struct radix_tree_preload *rtp;
116 struct radix_tree_node *node; 116 struct radix_tree_node *node;
diff --git a/lib/ts_bm.c b/lib/ts_bm.c
index 2cc79112ecc3..8a8b3a16133e 100644
--- a/lib/ts_bm.c
+++ b/lib/ts_bm.c
@@ -127,7 +127,7 @@ static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern,
127} 127}
128 128
129static struct ts_config *bm_init(const void *pattern, unsigned int len, 129static struct ts_config *bm_init(const void *pattern, unsigned int len,
130 int gfp_mask) 130 gfp_t gfp_mask)
131{ 131{
132 struct ts_config *conf; 132 struct ts_config *conf;
133 struct ts_bm *bm; 133 struct ts_bm *bm;
diff --git a/lib/ts_fsm.c b/lib/ts_fsm.c
index d27c0a072940..ca3211206eef 100644
--- a/lib/ts_fsm.c
+++ b/lib/ts_fsm.c
@@ -258,7 +258,7 @@ found_match:
258} 258}
259 259
260static struct ts_config *fsm_init(const void *pattern, unsigned int len, 260static struct ts_config *fsm_init(const void *pattern, unsigned int len,
261 int gfp_mask) 261 gfp_t gfp_mask)
262{ 262{
263 int i, err = -EINVAL; 263 int i, err = -EINVAL;
264 struct ts_config *conf; 264 struct ts_config *conf;
diff --git a/lib/ts_kmp.c b/lib/ts_kmp.c
index 73266b975585..7fd45451b44a 100644
--- a/lib/ts_kmp.c
+++ b/lib/ts_kmp.c
@@ -87,7 +87,7 @@ static inline void compute_prefix_tbl(const u8 *pattern, unsigned int len,
87} 87}
88 88
89static struct ts_config *kmp_init(const void *pattern, unsigned int len, 89static struct ts_config *kmp_init(const void *pattern, unsigned int len,
90 int gfp_mask) 90 gfp_t gfp_mask)
91{ 91{
92 struct ts_config *conf; 92 struct ts_config *conf;
93 struct ts_kmp *kmp; 93 struct ts_kmp *kmp;
diff --git a/mm/Kconfig b/mm/Kconfig
index 4e9937ac3529..391ffc54d136 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -29,7 +29,7 @@ config FLATMEM_MANUAL
29 If unsure, choose this option (Flat Memory) over any other. 29 If unsure, choose this option (Flat Memory) over any other.
30 30
31config DISCONTIGMEM_MANUAL 31config DISCONTIGMEM_MANUAL
32 bool "Discontigious Memory" 32 bool "Discontiguous Memory"
33 depends on ARCH_DISCONTIGMEM_ENABLE 33 depends on ARCH_DISCONTIGMEM_ENABLE
34 help 34 help
35 This option provides enhanced support for discontiguous 35 This option provides enhanced support for discontiguous
@@ -52,7 +52,7 @@ config SPARSEMEM_MANUAL
52 memory hotplug systems. This is normal. 52 memory hotplug systems. This is normal.
53 53
54 For many other systems, this will be an alternative to 54 For many other systems, this will be an alternative to
55 "Discontigious Memory". This option provides some potential 55 "Discontiguous Memory". This option provides some potential
56 performance benefits, along with decreased code complexity, 56 performance benefits, along with decreased code complexity,
57 but it is newer, and more experimental. 57 but it is newer, and more experimental.
58 58
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 8ec4e4c2a179..a58699b6579e 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -61,17 +61,9 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat,
61{ 61{
62 bootmem_data_t *bdata = pgdat->bdata; 62 bootmem_data_t *bdata = pgdat->bdata;
63 unsigned long mapsize = ((end - start)+7)/8; 63 unsigned long mapsize = ((end - start)+7)/8;
64 static struct pglist_data *pgdat_last; 64
65 65 pgdat->pgdat_next = pgdat_list;
66 pgdat->pgdat_next = NULL; 66 pgdat_list = pgdat;
67 /* Add new nodes last so that bootmem always starts
68 searching in the first nodes, not the last ones */
69 if (pgdat_last)
70 pgdat_last->pgdat_next = pgdat;
71 else {
72 pgdat_list = pgdat;
73 pgdat_last = pgdat;
74 }
75 67
76 mapsize = ALIGN(mapsize, sizeof(long)); 68 mapsize = ALIGN(mapsize, sizeof(long));
77 bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); 69 bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT);
@@ -162,10 +154,10 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
162 */ 154 */
163static void * __init 155static void * __init
164__alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size, 156__alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
165 unsigned long align, unsigned long goal) 157 unsigned long align, unsigned long goal, unsigned long limit)
166{ 158{
167 unsigned long offset, remaining_size, areasize, preferred; 159 unsigned long offset, remaining_size, areasize, preferred;
168 unsigned long i, start = 0, incr, eidx; 160 unsigned long i, start = 0, incr, eidx, end_pfn = bdata->node_low_pfn;
169 void *ret; 161 void *ret;
170 162
171 if(!size) { 163 if(!size) {
@@ -174,7 +166,14 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
174 } 166 }
175 BUG_ON(align & (align-1)); 167 BUG_ON(align & (align-1));
176 168
177 eidx = bdata->node_low_pfn - (bdata->node_boot_start >> PAGE_SHIFT); 169 if (limit && bdata->node_boot_start >= limit)
170 return NULL;
171
172 limit >>=PAGE_SHIFT;
173 if (limit && end_pfn > limit)
174 end_pfn = limit;
175
176 eidx = end_pfn - (bdata->node_boot_start >> PAGE_SHIFT);
178 offset = 0; 177 offset = 0;
179 if (align && 178 if (align &&
180 (bdata->node_boot_start & (align - 1UL)) != 0) 179 (bdata->node_boot_start & (align - 1UL)) != 0)
@@ -186,11 +185,12 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
186 * first, then we try to allocate lower pages. 185 * first, then we try to allocate lower pages.
187 */ 186 */
188 if (goal && (goal >= bdata->node_boot_start) && 187 if (goal && (goal >= bdata->node_boot_start) &&
189 ((goal >> PAGE_SHIFT) < bdata->node_low_pfn)) { 188 ((goal >> PAGE_SHIFT) < end_pfn)) {
190 preferred = goal - bdata->node_boot_start; 189 preferred = goal - bdata->node_boot_start;
191 190
192 if (bdata->last_success >= preferred) 191 if (bdata->last_success >= preferred)
193 preferred = bdata->last_success; 192 if (!limit || (limit && limit > bdata->last_success))
193 preferred = bdata->last_success;
194 } else 194 } else
195 preferred = 0; 195 preferred = 0;
196 196
@@ -390,14 +390,15 @@ unsigned long __init free_all_bootmem (void)
390 return(free_all_bootmem_core(NODE_DATA(0))); 390 return(free_all_bootmem_core(NODE_DATA(0)));
391} 391}
392 392
393void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal) 393void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal,
394 unsigned long limit)
394{ 395{
395 pg_data_t *pgdat = pgdat_list; 396 pg_data_t *pgdat = pgdat_list;
396 void *ptr; 397 void *ptr;
397 398
398 for_each_pgdat(pgdat) 399 for_each_pgdat(pgdat)
399 if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, 400 if ((ptr = __alloc_bootmem_core(pgdat->bdata, size,
400 align, goal))) 401 align, goal, limit)))
401 return(ptr); 402 return(ptr);
402 403
403 /* 404 /*
@@ -408,14 +409,16 @@ void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned
408 return NULL; 409 return NULL;
409} 410}
410 411
411void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal) 412
413void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align,
414 unsigned long goal, unsigned long limit)
412{ 415{
413 void *ptr; 416 void *ptr;
414 417
415 ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal); 418 ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, limit);
416 if (ptr) 419 if (ptr)
417 return (ptr); 420 return (ptr);
418 421
419 return __alloc_bootmem(size, align, goal); 422 return __alloc_bootmem_limit(size, align, goal, limit);
420} 423}
421 424
diff --git a/mm/fremap.c b/mm/fremap.c
index 3235fb77c133..ab23a0673c35 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -89,6 +89,9 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
89 size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 89 size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
90 if (!page->mapping || page->index >= size) 90 if (!page->mapping || page->index >= size)
91 goto err_unlock; 91 goto err_unlock;
92 err = -ENOMEM;
93 if (page_mapcount(page) > INT_MAX/2)
94 goto err_unlock;
92 95
93 zap_pte(mm, vma, addr, pte); 96 zap_pte(mm, vma, addr, pte);
94 97
diff --git a/mm/highmem.c b/mm/highmem.c
index 400911599468..90e1861e2da0 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -30,7 +30,7 @@
30 30
31static mempool_t *page_pool, *isa_page_pool; 31static mempool_t *page_pool, *isa_page_pool;
32 32
33static void *page_pool_alloc(unsigned int __nocast gfp_mask, void *data) 33static void *page_pool_alloc(gfp_t gfp_mask, void *data)
34{ 34{
35 unsigned int gfp = gfp_mask | (unsigned int) (long) data; 35 unsigned int gfp = gfp_mask | (unsigned int) (long) data;
36 36
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 901ac523a1c3..61d380678030 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -274,21 +274,22 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
274{ 274{
275 pte_t *src_pte, *dst_pte, entry; 275 pte_t *src_pte, *dst_pte, entry;
276 struct page *ptepage; 276 struct page *ptepage;
277 unsigned long addr = vma->vm_start; 277 unsigned long addr;
278 unsigned long end = vma->vm_end;
279 278
280 while (addr < end) { 279 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
281 dst_pte = huge_pte_alloc(dst, addr); 280 dst_pte = huge_pte_alloc(dst, addr);
282 if (!dst_pte) 281 if (!dst_pte)
283 goto nomem; 282 goto nomem;
283 spin_lock(&src->page_table_lock);
284 src_pte = huge_pte_offset(src, addr); 284 src_pte = huge_pte_offset(src, addr);
285 BUG_ON(!src_pte || pte_none(*src_pte)); /* prefaulted */ 285 if (src_pte && !pte_none(*src_pte)) {
286 entry = *src_pte; 286 entry = *src_pte;
287 ptepage = pte_page(entry); 287 ptepage = pte_page(entry);
288 get_page(ptepage); 288 get_page(ptepage);
289 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE); 289 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
290 set_huge_pte_at(dst, addr, dst_pte, entry); 290 set_huge_pte_at(dst, addr, dst_pte, entry);
291 addr += HPAGE_SIZE; 291 }
292 spin_unlock(&src->page_table_lock);
292 } 293 }
293 return 0; 294 return 0;
294 295
@@ -323,8 +324,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
323 324
324 page = pte_page(pte); 325 page = pte_page(pte);
325 put_page(page); 326 put_page(page);
327 add_mm_counter(mm, rss, - (HPAGE_SIZE / PAGE_SIZE));
326 } 328 }
327 add_mm_counter(mm, rss, -((end - start) >> PAGE_SHIFT));
328 flush_tlb_range(vma, start, end); 329 flush_tlb_range(vma, start, end);
329} 330}
330 331
@@ -393,6 +394,28 @@ out:
393 return ret; 394 return ret;
394} 395}
395 396
397/*
398 * On ia64 at least, it is possible to receive a hugetlb fault from a
399 * stale zero entry left in the TLB from earlier hardware prefetching.
400 * Low-level arch code should already have flushed the stale entry as
401 * part of its fault handling, but we do need to accept this minor fault
402 * and return successfully. Whereas the "normal" case is that this is
403 * an access to a hugetlb page which has been truncated off since mmap.
404 */
405int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
406 unsigned long address, int write_access)
407{
408 int ret = VM_FAULT_SIGBUS;
409 pte_t *pte;
410
411 spin_lock(&mm->page_table_lock);
412 pte = huge_pte_offset(mm, address);
413 if (pte && !pte_none(*pte))
414 ret = VM_FAULT_MINOR;
415 spin_unlock(&mm->page_table_lock);
416 return ret;
417}
418
396int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, 419int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
397 struct page **pages, struct vm_area_struct **vmas, 420 struct page **pages, struct vm_area_struct **vmas,
398 unsigned long *position, int *length, int i) 421 unsigned long *position, int *length, int i)
@@ -403,6 +426,7 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
403 BUG_ON(!is_vm_hugetlb_page(vma)); 426 BUG_ON(!is_vm_hugetlb_page(vma));
404 427
405 vpfn = vaddr/PAGE_SIZE; 428 vpfn = vaddr/PAGE_SIZE;
429 spin_lock(&mm->page_table_lock);
406 while (vaddr < vma->vm_end && remainder) { 430 while (vaddr < vma->vm_end && remainder) {
407 431
408 if (pages) { 432 if (pages) {
@@ -415,8 +439,13 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
415 * indexing below to work. */ 439 * indexing below to work. */
416 pte = huge_pte_offset(mm, vaddr & HPAGE_MASK); 440 pte = huge_pte_offset(mm, vaddr & HPAGE_MASK);
417 441
418 /* hugetlb should be locked, and hence, prefaulted */ 442 /* the hugetlb file might have been truncated */
419 WARN_ON(!pte || pte_none(*pte)); 443 if (!pte || pte_none(*pte)) {
444 remainder = 0;
445 if (!i)
446 i = -EFAULT;
447 break;
448 }
420 449
421 page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)]; 450 page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
422 451
@@ -434,7 +463,7 @@ int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
434 --remainder; 463 --remainder;
435 ++i; 464 ++i;
436 } 465 }
437 466 spin_unlock(&mm->page_table_lock);
438 *length = remainder; 467 *length = remainder;
439 *position = vaddr; 468 *position = vaddr;
440 469
diff --git a/mm/madvise.c b/mm/madvise.c
index 4454936f87d1..20e075d1c64c 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -83,6 +83,9 @@ static long madvise_willneed(struct vm_area_struct * vma,
83{ 83{
84 struct file *file = vma->vm_file; 84 struct file *file = vma->vm_file;
85 85
86 if (!file)
87 return -EBADF;
88
86 if (file->f_mapping->a_ops->get_xip_page) { 89 if (file->f_mapping->a_ops->get_xip_page) {
87 /* no bad return value, but ignore advice */ 90 /* no bad return value, but ignore advice */
88 return 0; 91 return 0;
@@ -141,11 +144,7 @@ static long
141madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, 144madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
142 unsigned long start, unsigned long end, int behavior) 145 unsigned long start, unsigned long end, int behavior)
143{ 146{
144 struct file *filp = vma->vm_file; 147 long error;
145 long error = -EBADF;
146
147 if (!filp)
148 goto out;
149 148
150 switch (behavior) { 149 switch (behavior) {
151 case MADV_NORMAL: 150 case MADV_NORMAL:
@@ -166,8 +165,6 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
166 error = -EINVAL; 165 error = -EINVAL;
167 break; 166 break;
168 } 167 }
169
170out:
171 return error; 168 return error;
172} 169}
173 170
diff --git a/mm/memory.c b/mm/memory.c
index ae8161f1f459..1db40e935e55 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2045,8 +2045,8 @@ int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct * vma,
2045 2045
2046 inc_page_state(pgfault); 2046 inc_page_state(pgfault);
2047 2047
2048 if (is_vm_hugetlb_page(vma)) 2048 if (unlikely(is_vm_hugetlb_page(vma)))
2049 return VM_FAULT_SIGBUS; /* mapping truncation does this. */ 2049 return hugetlb_fault(mm, vma, address, write_access);
2050 2050
2051 /* 2051 /*
2052 * We need the page table lock to synchronize with kswapd 2052 * We need the page table lock to synchronize with kswapd
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 9033f0859aa8..37af443eb094 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -687,7 +687,7 @@ get_vma_policy(struct task_struct *task, struct vm_area_struct *vma, unsigned lo
687} 687}
688 688
689/* Return a zonelist representing a mempolicy */ 689/* Return a zonelist representing a mempolicy */
690static struct zonelist *zonelist_policy(unsigned int __nocast gfp, struct mempolicy *policy) 690static struct zonelist *zonelist_policy(gfp_t gfp, struct mempolicy *policy)
691{ 691{
692 int nd; 692 int nd;
693 693
@@ -751,7 +751,7 @@ static unsigned offset_il_node(struct mempolicy *pol,
751 751
752/* Allocate a page in interleaved policy. 752/* Allocate a page in interleaved policy.
753 Own path because it needs to do special accounting. */ 753 Own path because it needs to do special accounting. */
754static struct page *alloc_page_interleave(unsigned int __nocast gfp, unsigned order, unsigned nid) 754static struct page *alloc_page_interleave(gfp_t gfp, unsigned order, unsigned nid)
755{ 755{
756 struct zonelist *zl; 756 struct zonelist *zl;
757 struct page *page; 757 struct page *page;
@@ -789,7 +789,7 @@ static struct page *alloc_page_interleave(unsigned int __nocast gfp, unsigned or
789 * Should be called with the mm_sem of the vma hold. 789 * Should be called with the mm_sem of the vma hold.
790 */ 790 */
791struct page * 791struct page *
792alloc_page_vma(unsigned int __nocast gfp, struct vm_area_struct *vma, unsigned long addr) 792alloc_page_vma(gfp_t gfp, struct vm_area_struct *vma, unsigned long addr)
793{ 793{
794 struct mempolicy *pol = get_vma_policy(current, vma, addr); 794 struct mempolicy *pol = get_vma_policy(current, vma, addr);
795 795
@@ -832,7 +832,7 @@ alloc_page_vma(unsigned int __nocast gfp, struct vm_area_struct *vma, unsigned l
832 * 1) it's ok to take cpuset_sem (can WAIT), and 832 * 1) it's ok to take cpuset_sem (can WAIT), and
833 * 2) allocating for current task (not interrupt). 833 * 2) allocating for current task (not interrupt).
834 */ 834 */
835struct page *alloc_pages_current(unsigned int __nocast gfp, unsigned order) 835struct page *alloc_pages_current(gfp_t gfp, unsigned order)
836{ 836{
837 struct mempolicy *pol = current->mempolicy; 837 struct mempolicy *pol = current->mempolicy;
838 838
diff --git a/mm/mempool.c b/mm/mempool.c
index 65f2957b8d51..9e377ea700b2 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -112,7 +112,7 @@ EXPORT_SYMBOL(mempool_create_node);
112 * while this function is running. mempool_alloc() & mempool_free() 112 * while this function is running. mempool_alloc() & mempool_free()
113 * might be called (eg. from IRQ contexts) while this function executes. 113 * might be called (eg. from IRQ contexts) while this function executes.
114 */ 114 */
115int mempool_resize(mempool_t *pool, int new_min_nr, unsigned int __nocast gfp_mask) 115int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask)
116{ 116{
117 void *element; 117 void *element;
118 void **new_elements; 118 void **new_elements;
@@ -200,7 +200,7 @@ EXPORT_SYMBOL(mempool_destroy);
200 * *never* fails when called from process contexts. (it might 200 * *never* fails when called from process contexts. (it might
201 * fail if called from an IRQ context.) 201 * fail if called from an IRQ context.)
202 */ 202 */
203void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask) 203void * mempool_alloc(mempool_t *pool, gfp_t gfp_mask)
204{ 204{
205 void *element; 205 void *element;
206 unsigned long flags; 206 unsigned long flags;
@@ -276,7 +276,7 @@ EXPORT_SYMBOL(mempool_free);
276/* 276/*
277 * A commonly used alloc and free fn. 277 * A commonly used alloc and free fn.
278 */ 278 */
279void *mempool_alloc_slab(unsigned int __nocast gfp_mask, void *pool_data) 279void *mempool_alloc_slab(gfp_t gfp_mask, void *pool_data)
280{ 280{
281 kmem_cache_t *mem = (kmem_cache_t *) pool_data; 281 kmem_cache_t *mem = (kmem_cache_t *) pool_data;
282 return kmem_cache_alloc(mem, gfp_mask); 282 return kmem_cache_alloc(mem, gfp_mask);
diff --git a/mm/mmap.c b/mm/mmap.c
index 8b8e05f07cdb..fa11d91242e8 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1640,7 +1640,7 @@ static void unmap_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
1640/* 1640/*
1641 * Get rid of page table information in the indicated region. 1641 * Get rid of page table information in the indicated region.
1642 * 1642 *
1643 * Called with the page table lock held. 1643 * Called with the mm semaphore held.
1644 */ 1644 */
1645static void unmap_region(struct mm_struct *mm, 1645static void unmap_region(struct mm_struct *mm,
1646 struct vm_area_struct *vma, struct vm_area_struct *prev, 1646 struct vm_area_struct *vma, struct vm_area_struct *prev,
diff --git a/mm/mprotect.c b/mm/mprotect.c
index e9fbd013ad9a..57577f63b305 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -248,7 +248,8 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot)
248 248
249 newflags = vm_flags | (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC)); 249 newflags = vm_flags | (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC));
250 250
251 if ((newflags & ~(newflags >> 4)) & 0xf) { 251 /* newflags >> 4 shift VM_MAY% in place of VM_% */
252 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
252 error = -EACCES; 253 error = -EACCES;
253 goto out; 254 goto out;
254 } 255 }
diff --git a/mm/mremap.c b/mm/mremap.c
index a32fed454bd7..f343fc73a8bd 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -141,10 +141,10 @@ move_one_page(struct vm_area_struct *vma, unsigned long old_addr,
141 if (dst) { 141 if (dst) {
142 pte_t pte; 142 pte_t pte;
143 pte = ptep_clear_flush(vma, old_addr, src); 143 pte = ptep_clear_flush(vma, old_addr, src);
144
144 /* ZERO_PAGE can be dependant on virtual addr */ 145 /* ZERO_PAGE can be dependant on virtual addr */
145 if (pfn_valid(pte_pfn(pte)) && 146 pte = move_pte(pte, new_vma->vm_page_prot,
146 pte_page(pte) == ZERO_PAGE(old_addr)) 147 old_addr, new_addr);
147 pte = pte_wrprotect(mk_pte(ZERO_PAGE(new_addr), new_vma->vm_page_prot));
148 set_pte_at(mm, new_addr, dst, pte); 148 set_pte_at(mm, new_addr, dst, pte);
149 } else 149 } else
150 error = -ENOMEM; 150 error = -ENOMEM;
diff --git a/mm/nommu.c b/mm/nommu.c
index 064d70442895..0ef241ae3763 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -157,8 +157,7 @@ void vfree(void *addr)
157 kfree(addr); 157 kfree(addr);
158} 158}
159 159
160void *__vmalloc(unsigned long size, unsigned int __nocast gfp_mask, 160void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
161 pgprot_t prot)
162{ 161{
163 /* 162 /*
164 * kmalloc doesn't like __GFP_HIGHMEM for some reason 163 * kmalloc doesn't like __GFP_HIGHMEM for some reason
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index ac3bf33e5370..d348b9035955 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -263,7 +263,7 @@ static struct mm_struct *oom_kill_process(struct task_struct *p)
263 * OR try to be smart about which process to kill. Note that we 263 * OR try to be smart about which process to kill. Note that we
264 * don't have to be perfect here, we just have to be good. 264 * don't have to be perfect here, we just have to be good.
265 */ 265 */
266void out_of_memory(unsigned int __nocast gfp_mask, int order) 266void out_of_memory(gfp_t gfp_mask, int order)
267{ 267{
268 struct mm_struct *mm = NULL; 268 struct mm_struct *mm = NULL;
269 task_t * p; 269 task_t * p;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ae2903339e71..e1d3d77f4aee 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -671,7 +671,7 @@ void fastcall free_cold_page(struct page *page)
671 free_hot_cold_page(page, 1); 671 free_hot_cold_page(page, 1);
672} 672}
673 673
674static inline void prep_zero_page(struct page *page, int order, unsigned int __nocast gfp_flags) 674static inline void prep_zero_page(struct page *page, int order, gfp_t gfp_flags)
675{ 675{
676 int i; 676 int i;
677 677
@@ -686,7 +686,7 @@ static inline void prep_zero_page(struct page *page, int order, unsigned int __n
686 * or two. 686 * or two.
687 */ 687 */
688static struct page * 688static struct page *
689buffered_rmqueue(struct zone *zone, int order, unsigned int __nocast gfp_flags) 689buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
690{ 690{
691 unsigned long flags; 691 unsigned long flags;
692 struct page *page = NULL; 692 struct page *page = NULL;
@@ -761,7 +761,7 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
761} 761}
762 762
763static inline int 763static inline int
764should_reclaim_zone(struct zone *z, unsigned int gfp_mask) 764should_reclaim_zone(struct zone *z, gfp_t gfp_mask)
765{ 765{
766 if (!z->reclaim_pages) 766 if (!z->reclaim_pages)
767 return 0; 767 return 0;
@@ -774,7 +774,7 @@ should_reclaim_zone(struct zone *z, unsigned int gfp_mask)
774 * This is the 'heart' of the zoned buddy allocator. 774 * This is the 'heart' of the zoned buddy allocator.
775 */ 775 */
776struct page * fastcall 776struct page * fastcall
777__alloc_pages(unsigned int __nocast gfp_mask, unsigned int order, 777__alloc_pages(gfp_t gfp_mask, unsigned int order,
778 struct zonelist *zonelist) 778 struct zonelist *zonelist)
779{ 779{
780 const int wait = gfp_mask & __GFP_WAIT; 780 const int wait = gfp_mask & __GFP_WAIT;
@@ -977,7 +977,7 @@ EXPORT_SYMBOL(__alloc_pages);
977/* 977/*
978 * Common helper functions. 978 * Common helper functions.
979 */ 979 */
980fastcall unsigned long __get_free_pages(unsigned int __nocast gfp_mask, unsigned int order) 980fastcall unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
981{ 981{
982 struct page * page; 982 struct page * page;
983 page = alloc_pages(gfp_mask, order); 983 page = alloc_pages(gfp_mask, order);
@@ -988,7 +988,7 @@ fastcall unsigned long __get_free_pages(unsigned int __nocast gfp_mask, unsigned
988 988
989EXPORT_SYMBOL(__get_free_pages); 989EXPORT_SYMBOL(__get_free_pages);
990 990
991fastcall unsigned long get_zeroed_page(unsigned int __nocast gfp_mask) 991fastcall unsigned long get_zeroed_page(gfp_t gfp_mask)
992{ 992{
993 struct page * page; 993 struct page * page;
994 994
@@ -1750,6 +1750,8 @@ inline void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
1750{ 1750{
1751 struct per_cpu_pages *pcp; 1751 struct per_cpu_pages *pcp;
1752 1752
1753 memset(p, 0, sizeof(*p));
1754
1753 pcp = &p->pcp[0]; /* hot */ 1755 pcp = &p->pcp[0]; /* hot */
1754 pcp->count = 0; 1756 pcp->count = 0;
1755 pcp->low = 2 * batch; 1757 pcp->low = 2 * batch;
diff --git a/mm/page_io.c b/mm/page_io.c
index 2e605a19ce57..330e00d6db00 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -19,7 +19,7 @@
19#include <linux/writeback.h> 19#include <linux/writeback.h>
20#include <asm/pgtable.h> 20#include <asm/pgtable.h>
21 21
22static struct bio *get_swap_bio(unsigned int __nocast gfp_flags, pgoff_t index, 22static struct bio *get_swap_bio(gfp_t gfp_flags, pgoff_t index,
23 struct page *page, bio_end_io_t end_io) 23 struct page *page, bio_end_io_t end_io)
24{ 24{
25 struct bio *bio; 25 struct bio *bio;
diff --git a/mm/shmem.c b/mm/shmem.c
index 1f7aeb210c7b..ea064d89cda9 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -921,8 +921,7 @@ shmem_swapin(struct shmem_inode_info *info,swp_entry_t entry,unsigned long idx)
921} 921}
922 922
923static inline struct page * 923static inline struct page *
924shmem_alloc_page(unsigned int __nocast gfp,struct shmem_inode_info *info, 924shmem_alloc_page(gfp_t gfp,struct shmem_inode_info *info, unsigned long idx)
925 unsigned long idx)
926{ 925{
927 return alloc_page(gfp | __GFP_ZERO); 926 return alloc_page(gfp | __GFP_ZERO);
928} 927}
diff --git a/mm/slab.c b/mm/slab.c
index 437d3388054b..d05c678bceb3 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -308,12 +308,12 @@ struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
308#define SIZE_L3 (1 + MAX_NUMNODES) 308#define SIZE_L3 (1 + MAX_NUMNODES)
309 309
310/* 310/*
311 * This function may be completely optimized away if 311 * This function must be completely optimized away if
312 * a constant is passed to it. Mostly the same as 312 * a constant is passed to it. Mostly the same as
313 * what is in linux/slab.h except it returns an 313 * what is in linux/slab.h except it returns an
314 * index. 314 * index.
315 */ 315 */
316static inline int index_of(const size_t size) 316static __always_inline int index_of(const size_t size)
317{ 317{
318 if (__builtin_constant_p(size)) { 318 if (__builtin_constant_p(size)) {
319 int i = 0; 319 int i = 0;
@@ -329,7 +329,8 @@ static inline int index_of(const size_t size)
329 extern void __bad_size(void); 329 extern void __bad_size(void);
330 __bad_size(); 330 __bad_size();
331 } 331 }
332 } 332 } else
333 BUG();
333 return 0; 334 return 0;
334} 335}
335 336
@@ -639,7 +640,7 @@ static enum {
639 640
640static DEFINE_PER_CPU(struct work_struct, reap_work); 641static DEFINE_PER_CPU(struct work_struct, reap_work);
641 642
642static void free_block(kmem_cache_t* cachep, void** objpp, int len); 643static void free_block(kmem_cache_t* cachep, void** objpp, int len, int node);
643static void enable_cpucache (kmem_cache_t *cachep); 644static void enable_cpucache (kmem_cache_t *cachep);
644static void cache_reap (void *unused); 645static void cache_reap (void *unused);
645static int __node_shrink(kmem_cache_t *cachep, int node); 646static int __node_shrink(kmem_cache_t *cachep, int node);
@@ -649,8 +650,7 @@ static inline struct array_cache *ac_data(kmem_cache_t *cachep)
649 return cachep->array[smp_processor_id()]; 650 return cachep->array[smp_processor_id()];
650} 651}
651 652
652static inline kmem_cache_t *__find_general_cachep(size_t size, 653static inline kmem_cache_t *__find_general_cachep(size_t size, gfp_t gfpflags)
653 unsigned int __nocast gfpflags)
654{ 654{
655 struct cache_sizes *csizep = malloc_sizes; 655 struct cache_sizes *csizep = malloc_sizes;
656 656
@@ -674,8 +674,7 @@ static inline kmem_cache_t *__find_general_cachep(size_t size,
674 return csizep->cs_cachep; 674 return csizep->cs_cachep;
675} 675}
676 676
677kmem_cache_t *kmem_find_general_cachep(size_t size, 677kmem_cache_t *kmem_find_general_cachep(size_t size, gfp_t gfpflags)
678 unsigned int __nocast gfpflags)
679{ 678{
680 return __find_general_cachep(size, gfpflags); 679 return __find_general_cachep(size, gfpflags);
681} 680}
@@ -804,7 +803,7 @@ static inline void __drain_alien_cache(kmem_cache_t *cachep, struct array_cache
804 803
805 if (ac->avail) { 804 if (ac->avail) {
806 spin_lock(&rl3->list_lock); 805 spin_lock(&rl3->list_lock);
807 free_block(cachep, ac->entry, ac->avail); 806 free_block(cachep, ac->entry, ac->avail, node);
808 ac->avail = 0; 807 ac->avail = 0;
809 spin_unlock(&rl3->list_lock); 808 spin_unlock(&rl3->list_lock);
810 } 809 }
@@ -925,7 +924,7 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
925 /* Free limit for this kmem_list3 */ 924 /* Free limit for this kmem_list3 */
926 l3->free_limit -= cachep->batchcount; 925 l3->free_limit -= cachep->batchcount;
927 if (nc) 926 if (nc)
928 free_block(cachep, nc->entry, nc->avail); 927 free_block(cachep, nc->entry, nc->avail, node);
929 928
930 if (!cpus_empty(mask)) { 929 if (!cpus_empty(mask)) {
931 spin_unlock(&l3->list_lock); 930 spin_unlock(&l3->list_lock);
@@ -934,7 +933,7 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
934 933
935 if (l3->shared) { 934 if (l3->shared) {
936 free_block(cachep, l3->shared->entry, 935 free_block(cachep, l3->shared->entry,
937 l3->shared->avail); 936 l3->shared->avail, node);
938 kfree(l3->shared); 937 kfree(l3->shared);
939 l3->shared = NULL; 938 l3->shared = NULL;
940 } 939 }
@@ -1184,7 +1183,7 @@ __initcall(cpucache_init);
1184 * did not request dmaable memory, we might get it, but that 1183 * did not request dmaable memory, we might get it, but that
1185 * would be relatively rare and ignorable. 1184 * would be relatively rare and ignorable.
1186 */ 1185 */
1187static void *kmem_getpages(kmem_cache_t *cachep, unsigned int __nocast flags, int nodeid) 1186static void *kmem_getpages(kmem_cache_t *cachep, gfp_t flags, int nodeid)
1188{ 1187{
1189 struct page *page; 1188 struct page *page;
1190 void *addr; 1189 void *addr;
@@ -1882,12 +1881,13 @@ static void do_drain(void *arg)
1882{ 1881{
1883 kmem_cache_t *cachep = (kmem_cache_t*)arg; 1882 kmem_cache_t *cachep = (kmem_cache_t*)arg;
1884 struct array_cache *ac; 1883 struct array_cache *ac;
1884 int node = numa_node_id();
1885 1885
1886 check_irq_off(); 1886 check_irq_off();
1887 ac = ac_data(cachep); 1887 ac = ac_data(cachep);
1888 spin_lock(&cachep->nodelists[numa_node_id()]->list_lock); 1888 spin_lock(&cachep->nodelists[node]->list_lock);
1889 free_block(cachep, ac->entry, ac->avail); 1889 free_block(cachep, ac->entry, ac->avail, node);
1890 spin_unlock(&cachep->nodelists[numa_node_id()]->list_lock); 1890 spin_unlock(&cachep->nodelists[node]->list_lock);
1891 ac->avail = 0; 1891 ac->avail = 0;
1892} 1892}
1893 1893
@@ -2046,7 +2046,7 @@ EXPORT_SYMBOL(kmem_cache_destroy);
2046 2046
2047/* Get the memory for a slab management obj. */ 2047/* Get the memory for a slab management obj. */
2048static struct slab* alloc_slabmgmt(kmem_cache_t *cachep, void *objp, 2048static struct slab* alloc_slabmgmt(kmem_cache_t *cachep, void *objp,
2049 int colour_off, unsigned int __nocast local_flags) 2049 int colour_off, gfp_t local_flags)
2050{ 2050{
2051 struct slab *slabp; 2051 struct slab *slabp;
2052 2052
@@ -2147,7 +2147,7 @@ static void set_slab_attr(kmem_cache_t *cachep, struct slab *slabp, void *objp)
2147 * Grow (by 1) the number of slabs within a cache. This is called by 2147 * Grow (by 1) the number of slabs within a cache. This is called by
2148 * kmem_cache_alloc() when there are no active objs left in a cache. 2148 * kmem_cache_alloc() when there are no active objs left in a cache.
2149 */ 2149 */
2150static int cache_grow(kmem_cache_t *cachep, unsigned int __nocast flags, int nodeid) 2150static int cache_grow(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2151{ 2151{
2152 struct slab *slabp; 2152 struct slab *slabp;
2153 void *objp; 2153 void *objp;
@@ -2354,7 +2354,7 @@ bad:
2354#define check_slabp(x,y) do { } while(0) 2354#define check_slabp(x,y) do { } while(0)
2355#endif 2355#endif
2356 2356
2357static void *cache_alloc_refill(kmem_cache_t *cachep, unsigned int __nocast flags) 2357static void *cache_alloc_refill(kmem_cache_t *cachep, gfp_t flags)
2358{ 2358{
2359 int batchcount; 2359 int batchcount;
2360 struct kmem_list3 *l3; 2360 struct kmem_list3 *l3;
@@ -2454,7 +2454,7 @@ alloc_done:
2454} 2454}
2455 2455
2456static inline void 2456static inline void
2457cache_alloc_debugcheck_before(kmem_cache_t *cachep, unsigned int __nocast flags) 2457cache_alloc_debugcheck_before(kmem_cache_t *cachep, gfp_t flags)
2458{ 2458{
2459 might_sleep_if(flags & __GFP_WAIT); 2459 might_sleep_if(flags & __GFP_WAIT);
2460#if DEBUG 2460#if DEBUG
@@ -2465,7 +2465,7 @@ cache_alloc_debugcheck_before(kmem_cache_t *cachep, unsigned int __nocast flags)
2465#if DEBUG 2465#if DEBUG
2466static void * 2466static void *
2467cache_alloc_debugcheck_after(kmem_cache_t *cachep, 2467cache_alloc_debugcheck_after(kmem_cache_t *cachep,
2468 unsigned int __nocast flags, void *objp, void *caller) 2468 gfp_t flags, void *objp, void *caller)
2469{ 2469{
2470 if (!objp) 2470 if (!objp)
2471 return objp; 2471 return objp;
@@ -2508,16 +2508,12 @@ cache_alloc_debugcheck_after(kmem_cache_t *cachep,
2508#define cache_alloc_debugcheck_after(a,b,objp,d) (objp) 2508#define cache_alloc_debugcheck_after(a,b,objp,d) (objp)
2509#endif 2509#endif
2510 2510
2511 2511static inline void *____cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2512static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags)
2513{ 2512{
2514 unsigned long save_flags;
2515 void* objp; 2513 void* objp;
2516 struct array_cache *ac; 2514 struct array_cache *ac;
2517 2515
2518 cache_alloc_debugcheck_before(cachep, flags); 2516 check_irq_off();
2519
2520 local_irq_save(save_flags);
2521 ac = ac_data(cachep); 2517 ac = ac_data(cachep);
2522 if (likely(ac->avail)) { 2518 if (likely(ac->avail)) {
2523 STATS_INC_ALLOCHIT(cachep); 2519 STATS_INC_ALLOCHIT(cachep);
@@ -2527,6 +2523,18 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl
2527 STATS_INC_ALLOCMISS(cachep); 2523 STATS_INC_ALLOCMISS(cachep);
2528 objp = cache_alloc_refill(cachep, flags); 2524 objp = cache_alloc_refill(cachep, flags);
2529 } 2525 }
2526 return objp;
2527}
2528
2529static inline void *__cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2530{
2531 unsigned long save_flags;
2532 void* objp;
2533
2534 cache_alloc_debugcheck_before(cachep, flags);
2535
2536 local_irq_save(save_flags);
2537 objp = ____cache_alloc(cachep, flags);
2530 local_irq_restore(save_flags); 2538 local_irq_restore(save_flags);
2531 objp = cache_alloc_debugcheck_after(cachep, flags, objp, 2539 objp = cache_alloc_debugcheck_after(cachep, flags, objp,
2532 __builtin_return_address(0)); 2540 __builtin_return_address(0));
@@ -2608,7 +2616,7 @@ done:
2608/* 2616/*
2609 * Caller needs to acquire correct kmem_list's list_lock 2617 * Caller needs to acquire correct kmem_list's list_lock
2610 */ 2618 */
2611static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects) 2619static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects, int node)
2612{ 2620{
2613 int i; 2621 int i;
2614 struct kmem_list3 *l3; 2622 struct kmem_list3 *l3;
@@ -2617,14 +2625,12 @@ static void free_block(kmem_cache_t *cachep, void **objpp, int nr_objects)
2617 void *objp = objpp[i]; 2625 void *objp = objpp[i];
2618 struct slab *slabp; 2626 struct slab *slabp;
2619 unsigned int objnr; 2627 unsigned int objnr;
2620 int nodeid = 0;
2621 2628
2622 slabp = GET_PAGE_SLAB(virt_to_page(objp)); 2629 slabp = GET_PAGE_SLAB(virt_to_page(objp));
2623 nodeid = slabp->nodeid; 2630 l3 = cachep->nodelists[node];
2624 l3 = cachep->nodelists[nodeid];
2625 list_del(&slabp->list); 2631 list_del(&slabp->list);
2626 objnr = (objp - slabp->s_mem) / cachep->objsize; 2632 objnr = (objp - slabp->s_mem) / cachep->objsize;
2627 check_spinlock_acquired_node(cachep, nodeid); 2633 check_spinlock_acquired_node(cachep, node);
2628 check_slabp(cachep, slabp); 2634 check_slabp(cachep, slabp);
2629 2635
2630 2636
@@ -2664,13 +2670,14 @@ static void cache_flusharray(kmem_cache_t *cachep, struct array_cache *ac)
2664{ 2670{
2665 int batchcount; 2671 int batchcount;
2666 struct kmem_list3 *l3; 2672 struct kmem_list3 *l3;
2673 int node = numa_node_id();
2667 2674
2668 batchcount = ac->batchcount; 2675 batchcount = ac->batchcount;
2669#if DEBUG 2676#if DEBUG
2670 BUG_ON(!batchcount || batchcount > ac->avail); 2677 BUG_ON(!batchcount || batchcount > ac->avail);
2671#endif 2678#endif
2672 check_irq_off(); 2679 check_irq_off();
2673 l3 = cachep->nodelists[numa_node_id()]; 2680 l3 = cachep->nodelists[node];
2674 spin_lock(&l3->list_lock); 2681 spin_lock(&l3->list_lock);
2675 if (l3->shared) { 2682 if (l3->shared) {
2676 struct array_cache *shared_array = l3->shared; 2683 struct array_cache *shared_array = l3->shared;
@@ -2686,7 +2693,7 @@ static void cache_flusharray(kmem_cache_t *cachep, struct array_cache *ac)
2686 } 2693 }
2687 } 2694 }
2688 2695
2689 free_block(cachep, ac->entry, batchcount); 2696 free_block(cachep, ac->entry, batchcount, node);
2690free_done: 2697free_done:
2691#if STATS 2698#if STATS
2692 { 2699 {
@@ -2751,7 +2758,7 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp)
2751 } else { 2758 } else {
2752 spin_lock(&(cachep->nodelists[nodeid])-> 2759 spin_lock(&(cachep->nodelists[nodeid])->
2753 list_lock); 2760 list_lock);
2754 free_block(cachep, &objp, 1); 2761 free_block(cachep, &objp, 1, nodeid);
2755 spin_unlock(&(cachep->nodelists[nodeid])-> 2762 spin_unlock(&(cachep->nodelists[nodeid])->
2756 list_lock); 2763 list_lock);
2757 } 2764 }
@@ -2778,7 +2785,7 @@ static inline void __cache_free(kmem_cache_t *cachep, void *objp)
2778 * Allocate an object from this cache. The flags are only relevant 2785 * Allocate an object from this cache. The flags are only relevant
2779 * if the cache has no available objects. 2786 * if the cache has no available objects.
2780 */ 2787 */
2781void *kmem_cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) 2788void *kmem_cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2782{ 2789{
2783 return __cache_alloc(cachep, flags); 2790 return __cache_alloc(cachep, flags);
2784} 2791}
@@ -2839,12 +2846,12 @@ out:
2839 * New and improved: it will now make sure that the object gets 2846 * New and improved: it will now make sure that the object gets
2840 * put on the correct node list so that there is no false sharing. 2847 * put on the correct node list so that there is no false sharing.
2841 */ 2848 */
2842void *kmem_cache_alloc_node(kmem_cache_t *cachep, unsigned int __nocast flags, int nodeid) 2849void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2843{ 2850{
2844 unsigned long save_flags; 2851 unsigned long save_flags;
2845 void *ptr; 2852 void *ptr;
2846 2853
2847 if (nodeid == numa_node_id() || nodeid == -1) 2854 if (nodeid == -1)
2848 return __cache_alloc(cachep, flags); 2855 return __cache_alloc(cachep, flags);
2849 2856
2850 if (unlikely(!cachep->nodelists[nodeid])) { 2857 if (unlikely(!cachep->nodelists[nodeid])) {
@@ -2855,7 +2862,10 @@ void *kmem_cache_alloc_node(kmem_cache_t *cachep, unsigned int __nocast flags, i
2855 2862
2856 cache_alloc_debugcheck_before(cachep, flags); 2863 cache_alloc_debugcheck_before(cachep, flags);
2857 local_irq_save(save_flags); 2864 local_irq_save(save_flags);
2858 ptr = __cache_alloc_node(cachep, flags, nodeid); 2865 if (nodeid == numa_node_id())
2866 ptr = ____cache_alloc(cachep, flags);
2867 else
2868 ptr = __cache_alloc_node(cachep, flags, nodeid);
2859 local_irq_restore(save_flags); 2869 local_irq_restore(save_flags);
2860 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0)); 2870 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0));
2861 2871
@@ -2863,7 +2873,7 @@ void *kmem_cache_alloc_node(kmem_cache_t *cachep, unsigned int __nocast flags, i
2863} 2873}
2864EXPORT_SYMBOL(kmem_cache_alloc_node); 2874EXPORT_SYMBOL(kmem_cache_alloc_node);
2865 2875
2866void *kmalloc_node(size_t size, unsigned int __nocast flags, int node) 2876void *kmalloc_node(size_t size, gfp_t flags, int node)
2867{ 2877{
2868 kmem_cache_t *cachep; 2878 kmem_cache_t *cachep;
2869 2879
@@ -2896,7 +2906,7 @@ EXPORT_SYMBOL(kmalloc_node);
2896 * platforms. For example, on i386, it means that the memory must come 2906 * platforms. For example, on i386, it means that the memory must come
2897 * from the first 16MB. 2907 * from the first 16MB.
2898 */ 2908 */
2899void *__kmalloc(size_t size, unsigned int __nocast flags) 2909void *__kmalloc(size_t size, gfp_t flags)
2900{ 2910{
2901 kmem_cache_t *cachep; 2911 kmem_cache_t *cachep;
2902 2912
@@ -2985,7 +2995,7 @@ EXPORT_SYMBOL(kmem_cache_free);
2985 * @size: how many bytes of memory are required. 2995 * @size: how many bytes of memory are required.
2986 * @flags: the type of memory to allocate. 2996 * @flags: the type of memory to allocate.
2987 */ 2997 */
2988void *kzalloc(size_t size, unsigned int __nocast flags) 2998void *kzalloc(size_t size, gfp_t flags)
2989{ 2999{
2990 void *ret = kmalloc(size, flags); 3000 void *ret = kmalloc(size, flags);
2991 if (ret) 3001 if (ret)
@@ -3079,7 +3089,7 @@ static int alloc_kmemlist(kmem_cache_t *cachep)
3079 3089
3080 if ((nc = cachep->nodelists[node]->shared)) 3090 if ((nc = cachep->nodelists[node]->shared))
3081 free_block(cachep, nc->entry, 3091 free_block(cachep, nc->entry,
3082 nc->avail); 3092 nc->avail, node);
3083 3093
3084 l3->shared = new; 3094 l3->shared = new;
3085 if (!cachep->nodelists[node]->alien) { 3095 if (!cachep->nodelists[node]->alien) {
@@ -3160,7 +3170,7 @@ static int do_tune_cpucache(kmem_cache_t *cachep, int limit, int batchcount,
3160 if (!ccold) 3170 if (!ccold)
3161 continue; 3171 continue;
3162 spin_lock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock); 3172 spin_lock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock);
3163 free_block(cachep, ccold->entry, ccold->avail); 3173 free_block(cachep, ccold->entry, ccold->avail, cpu_to_node(i));
3164 spin_unlock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock); 3174 spin_unlock_irq(&cachep->nodelists[cpu_to_node(i)]->list_lock);
3165 kfree(ccold); 3175 kfree(ccold);
3166 } 3176 }
@@ -3240,7 +3250,7 @@ static void drain_array_locked(kmem_cache_t *cachep,
3240 if (tofree > ac->avail) { 3250 if (tofree > ac->avail) {
3241 tofree = (ac->avail+1)/2; 3251 tofree = (ac->avail+1)/2;
3242 } 3252 }
3243 free_block(cachep, ac->entry, tofree); 3253 free_block(cachep, ac->entry, tofree, node);
3244 ac->avail -= tofree; 3254 ac->avail -= tofree;
3245 memmove(ac->entry, &(ac->entry[tofree]), 3255 memmove(ac->entry, &(ac->entry[tofree]),
3246 sizeof(void*)*ac->avail); 3256 sizeof(void*)*ac->avail);
@@ -3591,7 +3601,7 @@ unsigned int ksize(const void *objp)
3591 * @s: the string to duplicate 3601 * @s: the string to duplicate
3592 * @gfp: the GFP mask used in the kmalloc() call when allocating memory 3602 * @gfp: the GFP mask used in the kmalloc() call when allocating memory
3593 */ 3603 */
3594char *kstrdup(const char *s, unsigned int __nocast gfp) 3604char *kstrdup(const char *s, gfp_t gfp)
3595{ 3605{
3596 size_t len; 3606 size_t len;
3597 char *buf; 3607 char *buf;
diff --git a/mm/swap_state.c b/mm/swap_state.c
index adbc2b426c2f..132164f7d0a7 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -68,7 +68,7 @@ void show_swap_cache_info(void)
68 * but sets SwapCache flag and private instead of mapping and index. 68 * but sets SwapCache flag and private instead of mapping and index.
69 */ 69 */
70static int __add_to_swap_cache(struct page *page, swp_entry_t entry, 70static int __add_to_swap_cache(struct page *page, swp_entry_t entry,
71 unsigned int __nocast gfp_mask) 71 gfp_t gfp_mask)
72{ 72{
73 int error; 73 int error;
74 74
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 0184f510aace..1dcaeda039f4 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1381,6 +1381,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1381 error = bd_claim(bdev, sys_swapon); 1381 error = bd_claim(bdev, sys_swapon);
1382 if (error < 0) { 1382 if (error < 0) {
1383 bdev = NULL; 1383 bdev = NULL;
1384 error = -EINVAL;
1384 goto bad_swap; 1385 goto bad_swap;
1385 } 1386 }
1386 p->old_block_size = block_size(bdev); 1387 p->old_block_size = block_size(bdev);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 13c3d82968ae..1150229b6366 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -395,7 +395,7 @@ void *vmap(struct page **pages, unsigned int count,
395 395
396EXPORT_SYMBOL(vmap); 396EXPORT_SYMBOL(vmap);
397 397
398void *__vmalloc_area(struct vm_struct *area, unsigned int __nocast gfp_mask, pgprot_t prot) 398void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot)
399{ 399{
400 struct page **pages; 400 struct page **pages;
401 unsigned int nr_pages, array_size, i; 401 unsigned int nr_pages, array_size, i;
@@ -446,7 +446,7 @@ fail:
446 * allocator with @gfp_mask flags. Map them into contiguous 446 * allocator with @gfp_mask flags. Map them into contiguous
447 * kernel virtual space, using a pagetable protection of @prot. 447 * kernel virtual space, using a pagetable protection of @prot.
448 */ 448 */
449void *__vmalloc(unsigned long size, unsigned int __nocast gfp_mask, pgprot_t prot) 449void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
450{ 450{
451 struct vm_struct *area; 451 struct vm_struct *area;
452 452
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 0ea71e887bb6..64f9570cff56 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -511,10 +511,11 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc)
511 * PageDirty _after_ making sure that the page is freeable and 511 * PageDirty _after_ making sure that the page is freeable and
512 * not in use by anybody. (pagecache + us == 2) 512 * not in use by anybody. (pagecache + us == 2)
513 */ 513 */
514 if (page_count(page) != 2 || PageDirty(page)) { 514 if (unlikely(page_count(page) != 2))
515 write_unlock_irq(&mapping->tree_lock); 515 goto cannot_free;
516 goto keep_locked; 516 smp_rmb();
517 } 517 if (unlikely(PageDirty(page)))
518 goto cannot_free;
518 519
519#ifdef CONFIG_SWAP 520#ifdef CONFIG_SWAP
520 if (PageSwapCache(page)) { 521 if (PageSwapCache(page)) {
@@ -538,6 +539,10 @@ free_it:
538 __pagevec_release_nonlru(&freed_pvec); 539 __pagevec_release_nonlru(&freed_pvec);
539 continue; 540 continue;
540 541
542cannot_free:
543 write_unlock_irq(&mapping->tree_lock);
544 goto keep_locked;
545
541activate_locked: 546activate_locked:
542 SetPageActive(page); 547 SetPageActive(page);
543 pgactivate++; 548 pgactivate++;
diff --git a/net/802/p8022.c b/net/802/p8022.c
index b24817c63ca8..2530f35241cd 100644
--- a/net/802/p8022.c
+++ b/net/802/p8022.c
@@ -56,7 +56,7 @@ struct datalink_proto *register_8022_client(unsigned char type,
56 56
57void unregister_8022_client(struct datalink_proto *proto) 57void unregister_8022_client(struct datalink_proto *proto)
58{ 58{
59 llc_sap_close(proto->sap); 59 llc_sap_put(proto->sap);
60 kfree(proto); 60 kfree(proto);
61} 61}
62 62
diff --git a/net/802/psnap.c b/net/802/psnap.c
index ab80b1fab53c..4d638944d933 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -106,7 +106,7 @@ module_init(snap_init);
106 106
107static void __exit snap_exit(void) 107static void __exit snap_exit(void)
108{ 108{
109 llc_sap_close(snap_sap); 109 llc_sap_put(snap_sap);
110} 110}
111 111
112module_exit(snap_exit); 112module_exit(snap_exit);
diff --git a/net/802/tr.c b/net/802/tr.c
index 1bb7dc1b85cd..afd8385c0c9c 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -238,7 +238,7 @@ unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev)
238 return trllc->ethertype; 238 return trllc->ethertype;
239 } 239 }
240 240
241 return ntohs(ETH_P_802_2); 241 return ntohs(ETH_P_TR_802_2);
242} 242}
243 243
244/* 244/*
@@ -340,9 +340,10 @@ static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
340 unsigned int hash, rii_p = 0; 340 unsigned int hash, rii_p = 0;
341 unsigned long flags; 341 unsigned long flags;
342 struct rif_cache *entry; 342 struct rif_cache *entry;
343 343 unsigned char saddr0;
344 344
345 spin_lock_irqsave(&rif_lock, flags); 345 spin_lock_irqsave(&rif_lock, flags);
346 saddr0 = trh->saddr[0];
346 347
347 /* 348 /*
348 * Firstly see if the entry exists 349 * Firstly see if the entry exists
@@ -395,7 +396,6 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
395 entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK); 396 entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK);
396 memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short)); 397 memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short));
397 entry->local_ring = 0; 398 entry->local_ring = 0;
398 trh->saddr[0]|=TR_RII; /* put the routing indicator back for tcpdump */
399 } 399 }
400 else 400 else
401 { 401 {
@@ -422,6 +422,7 @@ printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
422 } 422 }
423 entry->last_used=jiffies; 423 entry->last_used=jiffies;
424 } 424 }
425 trh->saddr[0]=saddr0; /* put the routing indicator back for tcpdump */
425 spin_unlock_irqrestore(&rif_lock, flags); 426 spin_unlock_irqrestore(&rif_lock, flags);
426} 427}
427 428
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 145f5cde96cf..b74864889670 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -120,7 +120,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
120 unsigned short vid; 120 unsigned short vid;
121 struct net_device_stats *stats; 121 struct net_device_stats *stats;
122 unsigned short vlan_TCI; 122 unsigned short vlan_TCI;
123 unsigned short proto; 123 __be16 proto;
124 124
125 /* vlan_TCI = ntohs(get_unaligned(&vhdr->h_vlan_TCI)); */ 125 /* vlan_TCI = ntohs(get_unaligned(&vhdr->h_vlan_TCI)); */
126 vlan_TCI = ntohs(vhdr->h_vlan_TCI); 126 vlan_TCI = ntohs(vhdr->h_vlan_TCI);
diff --git a/net/Kconfig b/net/Kconfig
index 2bdd5623fdd5..60f6f321bd76 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -140,6 +140,7 @@ config BRIDGE_NETFILTER
140 140
141 If unsure, say N. 141 If unsure, say N.
142 142
143source "net/netfilter/Kconfig"
143source "net/ipv4/netfilter/Kconfig" 144source "net/ipv4/netfilter/Kconfig"
144source "net/ipv6/netfilter/Kconfig" 145source "net/ipv6/netfilter/Kconfig"
145source "net/decnet/netfilter/Kconfig" 146source "net/decnet/netfilter/Kconfig"
@@ -206,8 +207,6 @@ config NET_PKTGEN
206 To compile this code as a module, choose M here: the 207 To compile this code as a module, choose M here: the
207 module will be called pktgen. 208 module will be called pktgen.
208 209
209source "net/netfilter/Kconfig"
210
211endmenu 210endmenu
212 211
213endmenu 212endmenu
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 1d31b3a3f1e5..7982656b9c83 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -100,8 +100,7 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
100 continue; 100 continue;
101 101
102 if (to->sat_addr.s_net == ATADDR_ANYNET && 102 if (to->sat_addr.s_net == ATADDR_ANYNET &&
103 to->sat_addr.s_node == ATADDR_BCAST && 103 to->sat_addr.s_node == ATADDR_BCAST)
104 at->src_net == atif->address.s_net)
105 goto found; 104 goto found;
106 105
107 if (to->sat_addr.s_net == at->src_net && 106 if (to->sat_addr.s_net == at->src_net &&
@@ -1443,8 +1442,10 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1443 else 1442 else
1444 atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode); 1443 atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode);
1445 1444
1446 /* Not ours, so we route the packet via the correct AppleTalk iface */
1447 if (!atif) { 1445 if (!atif) {
1446 /* Not ours, so we route the packet via the correct
1447 * AppleTalk iface
1448 */
1448 atalk_route_packet(skb, dev, ddp, &ddphv, origlen); 1449 atalk_route_packet(skb, dev, ddp, &ddphv, origlen);
1449 goto out; 1450 goto out;
1450 } 1451 }
@@ -1592,9 +1593,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1592 1593
1593 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) { 1594 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) {
1594 rt = atrtr_find(&usat->sat_addr); 1595 rt = atrtr_find(&usat->sat_addr);
1595 if (!rt)
1596 return -ENETUNREACH;
1597
1598 dev = rt->dev; 1596 dev = rt->dev;
1599 } else { 1597 } else {
1600 struct atalk_addr at_hint; 1598 struct atalk_addr at_hint;
@@ -1603,11 +1601,12 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1603 at_hint.s_net = at->src_net; 1601 at_hint.s_net = at->src_net;
1604 1602
1605 rt = atrtr_find(&at_hint); 1603 rt = atrtr_find(&at_hint);
1606 if (!rt)
1607 return -ENETUNREACH;
1608
1609 dev = rt->dev; 1604 dev = rt->dev;
1610 } 1605 }
1606 if (!rt)
1607 return -ENETUNREACH;
1608
1609 dev = rt->dev;
1611 1610
1612 SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n", 1611 SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n",
1613 sk, size, dev->name); 1612 sk, size, dev->name);
@@ -1677,6 +1676,20 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1677 SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk); 1676 SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk);
1678 /* loop back */ 1677 /* loop back */
1679 skb_orphan(skb); 1678 skb_orphan(skb);
1679 if (ddp->deh_dnode == ATADDR_BCAST) {
1680 struct atalk_addr at_lo;
1681
1682 at_lo.s_node = 0;
1683 at_lo.s_net = 0;
1684
1685 rt = atrtr_find(&at_lo);
1686 if (!rt) {
1687 kfree_skb(skb);
1688 return -ENETUNREACH;
1689 }
1690 dev = rt->dev;
1691 skb->dev = dev;
1692 }
1680 ddp_dl->request(ddp_dl, skb, dev->dev_addr); 1693 ddp_dl->request(ddp_dl, skb, dev->dev_addr);
1681 } else { 1694 } else {
1682 SOCK_DEBUG(sk, "SK %p: send out.\n", sk); 1695 SOCK_DEBUG(sk, "SK %p: send out.\n", sk);
diff --git a/net/atm/addr.c b/net/atm/addr.c
index 1c8867f7f54a..3060fd0ba4b9 100644
--- a/net/atm/addr.c
+++ b/net/atm/addr.c
@@ -44,29 +44,43 @@ static void notify_sigd(struct atm_dev *dev)
44 sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL); 44 sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL);
45} 45}
46 46
47void atm_reset_addr(struct atm_dev *dev) 47void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t atype)
48{ 48{
49 unsigned long flags; 49 unsigned long flags;
50 struct atm_dev_addr *this, *p; 50 struct atm_dev_addr *this, *p;
51 struct list_head *head;
51 52
52 spin_lock_irqsave(&dev->lock, flags); 53 spin_lock_irqsave(&dev->lock, flags);
53 list_for_each_entry_safe(this, p, &dev->local, entry) 54 if (atype == ATM_ADDR_LECS)
54 kfree(this); 55 head = &dev->lecs;
56 else
57 head = &dev->local;
58 list_for_each_entry_safe(this, p, head, entry) {
59 list_del(&this->entry);
60 kfree(this);
61 }
55 spin_unlock_irqrestore(&dev->lock, flags); 62 spin_unlock_irqrestore(&dev->lock, flags);
56 notify_sigd(dev); 63 if (head == &dev->local)
64 notify_sigd(dev);
57} 65}
58 66
59int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) 67int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
68 enum atm_addr_type_t atype)
60{ 69{
61 unsigned long flags; 70 unsigned long flags;
62 struct atm_dev_addr *this; 71 struct atm_dev_addr *this;
72 struct list_head *head;
63 int error; 73 int error;
64 74
65 error = check_addr(addr); 75 error = check_addr(addr);
66 if (error) 76 if (error)
67 return error; 77 return error;
68 spin_lock_irqsave(&dev->lock, flags); 78 spin_lock_irqsave(&dev->lock, flags);
69 list_for_each_entry(this, &dev->local, entry) { 79 if (atype == ATM_ADDR_LECS)
80 head = &dev->lecs;
81 else
82 head = &dev->local;
83 list_for_each_entry(this, head, entry) {
70 if (identical(&this->addr, addr)) { 84 if (identical(&this->addr, addr)) {
71 spin_unlock_irqrestore(&dev->lock, flags); 85 spin_unlock_irqrestore(&dev->lock, flags);
72 return -EEXIST; 86 return -EEXIST;
@@ -78,28 +92,36 @@ int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr)
78 return -ENOMEM; 92 return -ENOMEM;
79 } 93 }
80 this->addr = *addr; 94 this->addr = *addr;
81 list_add(&this->entry, &dev->local); 95 list_add(&this->entry, head);
82 spin_unlock_irqrestore(&dev->lock, flags); 96 spin_unlock_irqrestore(&dev->lock, flags);
83 notify_sigd(dev); 97 if (head == &dev->local)
98 notify_sigd(dev);
84 return 0; 99 return 0;
85} 100}
86 101
87int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) 102int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
103 enum atm_addr_type_t atype)
88{ 104{
89 unsigned long flags; 105 unsigned long flags;
90 struct atm_dev_addr *this; 106 struct atm_dev_addr *this;
107 struct list_head *head;
91 int error; 108 int error;
92 109
93 error = check_addr(addr); 110 error = check_addr(addr);
94 if (error) 111 if (error)
95 return error; 112 return error;
96 spin_lock_irqsave(&dev->lock, flags); 113 spin_lock_irqsave(&dev->lock, flags);
97 list_for_each_entry(this, &dev->local, entry) { 114 if (atype == ATM_ADDR_LECS)
115 head = &dev->lecs;
116 else
117 head = &dev->local;
118 list_for_each_entry(this, head, entry) {
98 if (identical(&this->addr, addr)) { 119 if (identical(&this->addr, addr)) {
99 list_del(&this->entry); 120 list_del(&this->entry);
100 spin_unlock_irqrestore(&dev->lock, flags); 121 spin_unlock_irqrestore(&dev->lock, flags);
101 kfree(this); 122 kfree(this);
102 notify_sigd(dev); 123 if (head == &dev->local)
124 notify_sigd(dev);
103 return 0; 125 return 0;
104 } 126 }
105 } 127 }
@@ -108,22 +130,27 @@ int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr)
108} 130}
109 131
110int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf, 132int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf,
111 size_t size) 133 size_t size, enum atm_addr_type_t atype)
112{ 134{
113 unsigned long flags; 135 unsigned long flags;
114 struct atm_dev_addr *this; 136 struct atm_dev_addr *this;
137 struct list_head *head;
115 int total = 0, error; 138 int total = 0, error;
116 struct sockaddr_atmsvc *tmp_buf, *tmp_bufp; 139 struct sockaddr_atmsvc *tmp_buf, *tmp_bufp;
117 140
118 spin_lock_irqsave(&dev->lock, flags); 141 spin_lock_irqsave(&dev->lock, flags);
119 list_for_each_entry(this, &dev->local, entry) 142 if (atype == ATM_ADDR_LECS)
143 head = &dev->lecs;
144 else
145 head = &dev->local;
146 list_for_each_entry(this, head, entry)
120 total += sizeof(struct sockaddr_atmsvc); 147 total += sizeof(struct sockaddr_atmsvc);
121 tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC); 148 tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC);
122 if (!tmp_buf) { 149 if (!tmp_buf) {
123 spin_unlock_irqrestore(&dev->lock, flags); 150 spin_unlock_irqrestore(&dev->lock, flags);
124 return -ENOMEM; 151 return -ENOMEM;
125 } 152 }
126 list_for_each_entry(this, &dev->local, entry) 153 list_for_each_entry(this, head, entry)
127 memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc)); 154 memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc));
128 spin_unlock_irqrestore(&dev->lock, flags); 155 spin_unlock_irqrestore(&dev->lock, flags);
129 error = total > size ? -E2BIG : total; 156 error = total > size ? -E2BIG : total;
diff --git a/net/atm/addr.h b/net/atm/addr.h
index 3099d21feeaa..f39433ad45da 100644
--- a/net/atm/addr.h
+++ b/net/atm/addr.h
@@ -9,10 +9,12 @@
9#include <linux/atm.h> 9#include <linux/atm.h>
10#include <linux/atmdev.h> 10#include <linux/atmdev.h>
11 11
12 12void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t type);
13void atm_reset_addr(struct atm_dev *dev); 13int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
14int atm_add_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr); 14 enum atm_addr_type_t type);
15int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr); 15int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr,
16int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc __user *buf,size_t size); 16 enum atm_addr_type_t type);
17int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user *buf,
18 size_t size, enum atm_addr_type_t type);
17 19
18#endif 20#endif
diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
index b2113c3454ae..223c7ad5bd0f 100644
--- a/net/atm/atm_misc.c
+++ b/net/atm/atm_misc.c
@@ -25,7 +25,7 @@ int atm_charge(struct atm_vcc *vcc,int truesize)
25 25
26 26
27struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, 27struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
28 int gfp_flags) 28 gfp_t gfp_flags)
29{ 29{
30 struct sock *sk = sk_atm(vcc); 30 struct sock *sk = sk_atm(vcc);
31 int guess = atm_guess_pdu2truesize(pdu_size); 31 int guess = atm_guess_pdu2truesize(pdu_size);
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 289956c4dd3e..72f3f7b8de80 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -220,7 +220,7 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
220 /* netif_stop_queue(dev); */ 220 /* netif_stop_queue(dev); */
221 dev_kfree_skb(skb); 221 dev_kfree_skb(skb);
222 read_unlock(&devs_lock); 222 read_unlock(&devs_lock);
223 return -EUNATCH; 223 return 0;
224 } 224 }
225 if (!br2684_xmit_vcc(skb, brdev, brvcc)) { 225 if (!br2684_xmit_vcc(skb, brdev, brvcc)) {
226 /* 226 /*
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 28dab55a4387..4f54c9a5e84a 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -310,7 +310,7 @@ static int clip_constructor(struct neighbour *neigh)
310 if (neigh->type != RTN_UNICAST) return -EINVAL; 310 if (neigh->type != RTN_UNICAST) return -EINVAL;
311 311
312 rcu_read_lock(); 312 rcu_read_lock();
313 in_dev = rcu_dereference(__in_dev_get(dev)); 313 in_dev = __in_dev_get_rcu(dev);
314 if (!in_dev) { 314 if (!in_dev) {
315 rcu_read_unlock(); 315 rcu_read_unlock();
316 return -EINVAL; 316 return -EINVAL;
diff --git a/net/atm/common.c b/net/atm/common.c
index e93e838069e8..63feea49fb13 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -46,7 +46,7 @@ static void __vcc_insert_socket(struct sock *sk)
46 struct atm_vcc *vcc = atm_sk(sk); 46 struct atm_vcc *vcc = atm_sk(sk);
47 struct hlist_head *head = &vcc_hash[vcc->vci & 47 struct hlist_head *head = &vcc_hash[vcc->vci &
48 (VCC_HTABLE_SIZE - 1)]; 48 (VCC_HTABLE_SIZE - 1)];
49 sk->sk_hashent = vcc->vci & (VCC_HTABLE_SIZE - 1); 49 sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE - 1);
50 sk_add_node(sk, head); 50 sk_add_node(sk, head);
51} 51}
52 52
@@ -178,8 +178,6 @@ static void vcc_destroy_socket(struct sock *sk)
178 if (vcc->push) 178 if (vcc->push)
179 vcc->push(vcc, NULL); /* atmarpd has no push */ 179 vcc->push(vcc, NULL); /* atmarpd has no push */
180 180
181 vcc_remove_socket(sk); /* no more receive */
182
183 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 181 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
184 atm_return(vcc,skb->truesize); 182 atm_return(vcc,skb->truesize);
185 kfree_skb(skb); 183 kfree_skb(skb);
@@ -188,6 +186,8 @@ static void vcc_destroy_socket(struct sock *sk)
188 module_put(vcc->dev->ops->owner); 186 module_put(vcc->dev->ops->owner);
189 atm_dev_put(vcc->dev); 187 atm_dev_put(vcc->dev);
190 } 188 }
189
190 vcc_remove_socket(sk);
191} 191}
192 192
193 193
diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c
index d89056ec44d4..a150198b05a3 100644
--- a/net/atm/ioctl.c
+++ b/net/atm/ioctl.c
@@ -105,17 +105,35 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
105 if (!error) 105 if (!error)
106 sock->state = SS_CONNECTED; 106 sock->state = SS_CONNECTED;
107 goto done; 107 goto done;
108 default: 108 case ATM_SETBACKEND:
109 case ATM_NEWBACKENDIF:
110 {
111 atm_backend_t backend;
112 error = get_user(backend, (atm_backend_t __user *) argp);
113 if (error)
114 goto done;
115 switch (backend) {
116 case ATM_BACKEND_PPP:
117 request_module("pppoatm");
118 break;
119 case ATM_BACKEND_BR2684:
120 request_module("br2684");
121 break;
122 }
123 }
124 break;
125 case ATMMPC_CTRL:
126 case ATMMPC_DATA:
127 request_module("mpoa");
128 break;
129 case ATMARPD_CTRL:
130 request_module("clip");
131 break;
132 case ATMLEC_CTRL:
133 request_module("lec");
109 break; 134 break;
110 } 135 }
111 136
112 if (cmd == ATMMPC_CTRL || cmd == ATMMPC_DATA)
113 request_module("mpoa");
114 if (cmd == ATMARPD_CTRL)
115 request_module("clip");
116 if (cmd == ATMLEC_CTRL)
117 request_module("lec");
118
119 error = -ENOIOCTLCMD; 137 error = -ENOIOCTLCMD;
120 138
121 down(&ioctl_mutex); 139 down(&ioctl_mutex);
diff --git a/net/atm/lec.c b/net/atm/lec.c
index a0752487026d..ad840b9afba8 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -686,9 +686,19 @@ static unsigned char lec_ctrl_magic[] = {
686 0x01, 686 0x01,
687 0x01 }; 687 0x01 };
688 688
689#define LEC_DATA_DIRECT_8023 2
690#define LEC_DATA_DIRECT_8025 3
691
692static int lec_is_data_direct(struct atm_vcc *vcc)
693{
694 return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) ||
695 (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025));
696}
697
689static void 698static void
690lec_push(struct atm_vcc *vcc, struct sk_buff *skb) 699lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
691{ 700{
701 unsigned long flags;
692 struct net_device *dev = (struct net_device *)vcc->proto_data; 702 struct net_device *dev = (struct net_device *)vcc->proto_data;
693 struct lec_priv *priv = (struct lec_priv *)dev->priv; 703 struct lec_priv *priv = (struct lec_priv *)dev->priv;
694 704
@@ -728,7 +738,8 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
728 skb_queue_tail(&sk->sk_receive_queue, skb); 738 skb_queue_tail(&sk->sk_receive_queue, skb);
729 sk->sk_data_ready(sk, skb->len); 739 sk->sk_data_ready(sk, skb->len);
730 } else { /* Data frame, queue to protocol handlers */ 740 } else { /* Data frame, queue to protocol handlers */
731 unsigned char *dst; 741 struct lec_arp_table *entry;
742 unsigned char *src, *dst;
732 743
733 atm_return(vcc,skb->truesize); 744 atm_return(vcc,skb->truesize);
734 if (*(uint16_t *)skb->data == htons(priv->lecid) || 745 if (*(uint16_t *)skb->data == htons(priv->lecid) ||
@@ -741,10 +752,30 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
741 return; 752 return;
742 } 753 }
743#ifdef CONFIG_TR 754#ifdef CONFIG_TR
744 if (priv->is_trdev) dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest; 755 if (priv->is_trdev)
756 dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest;
745 else 757 else
746#endif 758#endif
747 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; 759 dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest;
760
761 /* If this is a Data Direct VCC, and the VCC does not match
762 * the LE_ARP cache entry, delete the LE_ARP cache entry.
763 */
764 spin_lock_irqsave(&priv->lec_arp_lock, flags);
765 if (lec_is_data_direct(vcc)) {
766#ifdef CONFIG_TR
767 if (priv->is_trdev)
768 src = ((struct lecdatahdr_8025 *) skb->data)->h_source;
769 else
770#endif
771 src = ((struct lecdatahdr_8023 *) skb->data)->h_source;
772 entry = lec_arp_find(priv, src);
773 if (entry && entry->vcc != vcc) {
774 lec_arp_remove(priv, entry);
775 kfree(entry);
776 }
777 }
778 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
748 779
749 if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */ 780 if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */
750 !priv->is_proxy && /* Proxy wants all the packets */ 781 !priv->is_proxy && /* Proxy wants all the packets */
@@ -1990,6 +2021,12 @@ lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find,
1990 found = entry->vcc; 2021 found = entry->vcc;
1991 goto out; 2022 goto out;
1992 } 2023 }
2024 /* If the LE_ARP cache entry is still pending, reset count to 0
2025 * so another LE_ARP request can be made for this frame.
2026 */
2027 if (entry->status == ESI_ARP_PENDING) {
2028 entry->no_tries = 0;
2029 }
1993 /* Data direct VC not yet set up, check to see if the unknown 2030 /* Data direct VC not yet set up, check to see if the unknown
1994 frame count is greater than the limit. If the limit has 2031 frame count is greater than the limit. If the limit has
1995 not been reached, allow the caller to send packet to 2032 not been reached, allow the caller to send packet to
diff --git a/net/atm/resources.c b/net/atm/resources.c
index a57a9268bd24..415d2615d475 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -40,6 +40,7 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
40 dev->link_rate = ATM_OC3_PCR; 40 dev->link_rate = ATM_OC3_PCR;
41 spin_lock_init(&dev->lock); 41 spin_lock_init(&dev->lock);
42 INIT_LIST_HEAD(&dev->local); 42 INIT_LIST_HEAD(&dev->local);
43 INIT_LIST_HEAD(&dev->lecs);
43 44
44 return dev; 45 return dev;
45} 46}
@@ -320,10 +321,12 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
320 error = -EPERM; 321 error = -EPERM;
321 goto done; 322 goto done;
322 } 323 }
323 atm_reset_addr(dev); 324 atm_reset_addr(dev, ATM_ADDR_LOCAL);
324 break; 325 break;
325 case ATM_ADDADDR: 326 case ATM_ADDADDR:
326 case ATM_DELADDR: 327 case ATM_DELADDR:
328 case ATM_ADDLECSADDR:
329 case ATM_DELLECSADDR:
327 if (!capable(CAP_NET_ADMIN)) { 330 if (!capable(CAP_NET_ADMIN)) {
328 error = -EPERM; 331 error = -EPERM;
329 goto done; 332 goto done;
@@ -335,14 +338,21 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg)
335 error = -EFAULT; 338 error = -EFAULT;
336 goto done; 339 goto done;
337 } 340 }
338 if (cmd == ATM_ADDADDR) 341 if (cmd == ATM_ADDADDR || cmd == ATM_ADDLECSADDR)
339 error = atm_add_addr(dev, &addr); 342 error = atm_add_addr(dev, &addr,
343 (cmd == ATM_ADDADDR ?
344 ATM_ADDR_LOCAL : ATM_ADDR_LECS));
340 else 345 else
341 error = atm_del_addr(dev, &addr); 346 error = atm_del_addr(dev, &addr,
347 (cmd == ATM_DELADDR ?
348 ATM_ADDR_LOCAL : ATM_ADDR_LECS));
342 goto done; 349 goto done;
343 } 350 }
344 case ATM_GETADDR: 351 case ATM_GETADDR:
345 error = atm_get_addr(dev, buf, len); 352 case ATM_GETLECSADDR:
353 error = atm_get_addr(dev, buf, len,
354 (cmd == ATM_GETADDR ?
355 ATM_ADDR_LOCAL : ATM_ADDR_LECS));
346 if (error < 0) 356 if (error < 0)
347 goto done; 357 goto done;
348 size = error; 358 size = error;
diff --git a/net/atm/signaling.c b/net/atm/signaling.c
index f7c449ac1800..e7211a7f382c 100644
--- a/net/atm/signaling.c
+++ b/net/atm/signaling.c
@@ -217,8 +217,9 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type,
217static void purge_vcc(struct atm_vcc *vcc) 217static void purge_vcc(struct atm_vcc *vcc)
218{ 218{
219 if (sk_atm(vcc)->sk_family == PF_ATMSVC && 219 if (sk_atm(vcc)->sk_family == PF_ATMSVC &&
220 !test_bit(ATM_VF_META,&vcc->flags)) { 220 !test_bit(ATM_VF_META, &vcc->flags)) {
221 set_bit(ATM_VF_RELEASED,&vcc->flags); 221 set_bit(ATM_VF_RELEASED, &vcc->flags);
222 clear_bit(ATM_VF_REGIS, &vcc->flags);
222 vcc_release_async(vcc, -EUNATCH); 223 vcc_release_async(vcc, -EUNATCH);
223 } 224 }
224} 225}
@@ -243,8 +244,7 @@ static void sigd_close(struct atm_vcc *vcc)
243 sk_for_each(s, node, head) { 244 sk_for_each(s, node, head) {
244 struct atm_vcc *vcc = atm_sk(s); 245 struct atm_vcc *vcc = atm_sk(s);
245 246
246 if (vcc->dev) 247 purge_vcc(vcc);
247 purge_vcc(vcc);
248 } 248 }
249 } 249 }
250 read_unlock(&vcc_sklist_lock); 250 read_unlock(&vcc_sklist_lock);
diff --git a/net/atm/svc.c b/net/atm/svc.c
index 08e46052a3e4..d7b266136bf6 100644
--- a/net/atm/svc.c
+++ b/net/atm/svc.c
@@ -302,6 +302,7 @@ static int svc_listen(struct socket *sock,int backlog)
302 error = -EINVAL; 302 error = -EINVAL;
303 goto out; 303 goto out;
304 } 304 }
305 vcc_insert_socket(sk);
305 set_bit(ATM_VF_WAITING, &vcc->flags); 306 set_bit(ATM_VF_WAITING, &vcc->flags);
306 prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); 307 prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE);
307 sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local); 308 sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local);
diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c
index 810c9c76c2e0..73cfc3411c46 100644
--- a/net/ax25/ax25_in.c
+++ b/net/ax25/ax25_in.c
@@ -123,7 +123,7 @@ int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
123 } 123 }
124 124
125 skb_pull(skb, 1); /* Remove PID */ 125 skb_pull(skb, 1); /* Remove PID */
126 skb->h.raw = skb->data; 126 skb->mac.raw = skb->nh.raw;
127 skb->nh.raw = skb->data; 127 skb->nh.raw = skb->data;
128 skb->dev = ax25->ax25_dev->dev; 128 skb->dev = ax25->ax25_dev->dev;
129 skb->pkt_type = PACKET_HOST; 129 skb->pkt_type = PACKET_HOST;
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index d3d6bc547212..59b2dd36baa7 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -372,7 +372,7 @@ static struct proto l2cap_proto = {
372 .obj_size = sizeof(struct l2cap_pinfo) 372 .obj_size = sizeof(struct l2cap_pinfo)
373}; 373};
374 374
375static struct sock *l2cap_sock_alloc(struct socket *sock, int proto, unsigned int __nocast prio) 375static struct sock *l2cap_sock_alloc(struct socket *sock, int proto, gfp_t prio)
376{ 376{
377 struct sock *sk; 377 struct sock *sk;
378 378
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 173f46e8cdae..35adce6482b6 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -229,7 +229,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
229 d->rx_credits = RFCOMM_DEFAULT_CREDITS; 229 d->rx_credits = RFCOMM_DEFAULT_CREDITS;
230} 230}
231 231
232struct rfcomm_dlc *rfcomm_dlc_alloc(unsigned int __nocast prio) 232struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
233{ 233{
234 struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio); 234 struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio);
235 if (!d) 235 if (!d)
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index f49e7e938bfb..a2b30f0aedb7 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -284,7 +284,7 @@ static struct proto rfcomm_proto = {
284 .obj_size = sizeof(struct rfcomm_pinfo) 284 .obj_size = sizeof(struct rfcomm_pinfo)
285}; 285};
286 286
287static struct sock *rfcomm_sock_alloc(struct socket *sock, int proto, unsigned int __nocast prio) 287static struct sock *rfcomm_sock_alloc(struct socket *sock, int proto, gfp_t prio)
288{ 288{
289 struct rfcomm_dlc *d; 289 struct rfcomm_dlc *d;
290 struct sock *sk; 290 struct sock *sk;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 1bca860a6109..158a9c46d863 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -286,7 +286,7 @@ static inline void rfcomm_set_owner_w(struct sk_buff *skb, struct rfcomm_dev *de
286 skb->destructor = rfcomm_wfree; 286 skb->destructor = rfcomm_wfree;
287} 287}
288 288
289static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, unsigned int __nocast priority) 289static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, gfp_t priority)
290{ 290{
291 if (atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) { 291 if (atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) {
292 struct sk_buff *skb = alloc_skb(size, priority); 292 struct sk_buff *skb = alloc_skb(size, priority);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index ce7ab7dfa0b2..997e42df115c 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -418,7 +418,7 @@ static struct proto sco_proto = {
418 .obj_size = sizeof(struct sco_pinfo) 418 .obj_size = sizeof(struct sco_pinfo)
419}; 419};
420 420
421static struct sock *sco_sock_alloc(struct socket *sock, int proto, unsigned int __nocast prio) 421static struct sock *sco_sock_alloc(struct socket *sock, int proto, gfp_t prio)
422{ 422{
423 struct sock *sk; 423 struct sock *sk;
424 424
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 069253f830c1..2d24fb400e0c 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -31,7 +31,8 @@ static inline int should_deliver(const struct net_bridge_port *p,
31 31
32int br_dev_queue_push_xmit(struct sk_buff *skb) 32int br_dev_queue_push_xmit(struct sk_buff *skb)
33{ 33{
34 if (skb->len > skb->dev->mtu) 34 /* drop mtu oversized packets except tso */
35 if (skb->len > skb->dev->mtu && !skb_shinfo(skb)->tso_size)
35 kfree_skb(skb); 36 kfree_skb(skb);
36 else { 37 else {
37#ifdef CONFIG_BRIDGE_NETFILTER 38#ifdef CONFIG_BRIDGE_NETFILTER
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 91bb895375f4..defcf6a8607c 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -79,7 +79,6 @@ static void destroy_nbp(struct net_bridge_port *p)
79{ 79{
80 struct net_device *dev = p->dev; 80 struct net_device *dev = p->dev;
81 81
82 dev->br_port = NULL;
83 p->br = NULL; 82 p->br = NULL;
84 p->dev = NULL; 83 p->dev = NULL;
85 dev_put(dev); 84 dev_put(dev);
@@ -100,6 +99,7 @@ static void del_nbp(struct net_bridge_port *p)
100 struct net_bridge *br = p->br; 99 struct net_bridge *br = p->br;
101 struct net_device *dev = p->dev; 100 struct net_device *dev = p->dev;
102 101
102 dev->br_port = NULL;
103 dev_set_promiscuity(dev, -1); 103 dev_set_promiscuity(dev, -1);
104 104
105 spin_lock_bh(&br->lock); 105 spin_lock_bh(&br->lock);
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index c4540144f0f4..f8ffbf6e2333 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -26,6 +26,7 @@
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <linux/smp.h> 28#include <linux/smp.h>
29#include <linux/cpumask.h>
29#include <net/sock.h> 30#include <net/sock.h>
30/* needed for logical [in,out]-dev filtering */ 31/* needed for logical [in,out]-dev filtering */
31#include "../br_private.h" 32#include "../br_private.h"
@@ -823,10 +824,11 @@ static int translate_table(struct ebt_replace *repl,
823 /* this will get free'd in do_replace()/ebt_register_table() 824 /* this will get free'd in do_replace()/ebt_register_table()
824 if an error occurs */ 825 if an error occurs */
825 newinfo->chainstack = (struct ebt_chainstack **) 826 newinfo->chainstack = (struct ebt_chainstack **)
826 vmalloc(num_possible_cpus() * sizeof(struct ebt_chainstack)); 827 vmalloc((highest_possible_processor_id()+1)
828 * sizeof(struct ebt_chainstack));
827 if (!newinfo->chainstack) 829 if (!newinfo->chainstack)
828 return -ENOMEM; 830 return -ENOMEM;
829 for (i = 0; i < num_possible_cpus(); i++) { 831 for_each_cpu(i) {
830 newinfo->chainstack[i] = 832 newinfo->chainstack[i] =
831 vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); 833 vmalloc(udc_cnt * sizeof(struct ebt_chainstack));
832 if (!newinfo->chainstack[i]) { 834 if (!newinfo->chainstack[i]) {
@@ -895,9 +897,12 @@ static void get_counters(struct ebt_counter *oldcounters,
895 897
896 /* counters of cpu 0 */ 898 /* counters of cpu 0 */
897 memcpy(counters, oldcounters, 899 memcpy(counters, oldcounters,
898 sizeof(struct ebt_counter) * nentries); 900 sizeof(struct ebt_counter) * nentries);
901
899 /* add other counters to those of cpu 0 */ 902 /* add other counters to those of cpu 0 */
900 for (cpu = 1; cpu < num_possible_cpus(); cpu++) { 903 for_each_cpu(cpu) {
904 if (cpu == 0)
905 continue;
901 counter_base = COUNTER_BASE(oldcounters, nentries, cpu); 906 counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
902 for (i = 0; i < nentries; i++) { 907 for (i = 0; i < nentries; i++) {
903 counters[i].pcnt += counter_base[i].pcnt; 908 counters[i].pcnt += counter_base[i].pcnt;
@@ -929,7 +934,8 @@ static int do_replace(void __user *user, unsigned int len)
929 BUGPRINT("Entries_size never zero\n"); 934 BUGPRINT("Entries_size never zero\n");
930 return -EINVAL; 935 return -EINVAL;
931 } 936 }
932 countersize = COUNTER_OFFSET(tmp.nentries) * num_possible_cpus(); 937 countersize = COUNTER_OFFSET(tmp.nentries) *
938 (highest_possible_processor_id()+1);
933 newinfo = (struct ebt_table_info *) 939 newinfo = (struct ebt_table_info *)
934 vmalloc(sizeof(struct ebt_table_info) + countersize); 940 vmalloc(sizeof(struct ebt_table_info) + countersize);
935 if (!newinfo) 941 if (!newinfo)
@@ -1022,7 +1028,7 @@ static int do_replace(void __user *user, unsigned int len)
1022 1028
1023 vfree(table->entries); 1029 vfree(table->entries);
1024 if (table->chainstack) { 1030 if (table->chainstack) {
1025 for (i = 0; i < num_possible_cpus(); i++) 1031 for_each_cpu(i)
1026 vfree(table->chainstack[i]); 1032 vfree(table->chainstack[i]);
1027 vfree(table->chainstack); 1033 vfree(table->chainstack);
1028 } 1034 }
@@ -1040,7 +1046,7 @@ free_counterstmp:
1040 vfree(counterstmp); 1046 vfree(counterstmp);
1041 /* can be initialized in translate_table() */ 1047 /* can be initialized in translate_table() */
1042 if (newinfo->chainstack) { 1048 if (newinfo->chainstack) {
1043 for (i = 0; i < num_possible_cpus(); i++) 1049 for_each_cpu(i)
1044 vfree(newinfo->chainstack[i]); 1050 vfree(newinfo->chainstack[i]);
1045 vfree(newinfo->chainstack); 1051 vfree(newinfo->chainstack);
1046 } 1052 }
@@ -1132,7 +1138,8 @@ int ebt_register_table(struct ebt_table *table)
1132 return -EINVAL; 1138 return -EINVAL;
1133 } 1139 }
1134 1140
1135 countersize = COUNTER_OFFSET(table->table->nentries) * num_possible_cpus(); 1141 countersize = COUNTER_OFFSET(table->table->nentries) *
1142 (highest_possible_processor_id()+1);
1136 newinfo = (struct ebt_table_info *) 1143 newinfo = (struct ebt_table_info *)
1137 vmalloc(sizeof(struct ebt_table_info) + countersize); 1144 vmalloc(sizeof(struct ebt_table_info) + countersize);
1138 ret = -ENOMEM; 1145 ret = -ENOMEM;
@@ -1186,7 +1193,7 @@ free_unlock:
1186 up(&ebt_mutex); 1193 up(&ebt_mutex);
1187free_chainstack: 1194free_chainstack:
1188 if (newinfo->chainstack) { 1195 if (newinfo->chainstack) {
1189 for (i = 0; i < num_possible_cpus(); i++) 1196 for_each_cpu(i)
1190 vfree(newinfo->chainstack[i]); 1197 vfree(newinfo->chainstack[i]);
1191 vfree(newinfo->chainstack); 1198 vfree(newinfo->chainstack);
1192 } 1199 }
@@ -1209,7 +1216,7 @@ void ebt_unregister_table(struct ebt_table *table)
1209 up(&ebt_mutex); 1216 up(&ebt_mutex);
1210 vfree(table->private->entries); 1217 vfree(table->private->entries);
1211 if (table->private->chainstack) { 1218 if (table->private->chainstack) {
1212 for (i = 0; i < num_possible_cpus(); i++) 1219 for_each_cpu(i)
1213 vfree(table->private->chainstack[i]); 1220 vfree(table->private->chainstack[i]);
1214 vfree(table->private->chainstack); 1221 vfree(table->private->chainstack);
1215 } 1222 }
diff --git a/net/core/datagram.c b/net/core/datagram.c
index da9bf71421a7..81987df536eb 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -211,74 +211,45 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
211int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, 211int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset,
212 struct iovec *to, int len) 212 struct iovec *to, int len)
213{ 213{
214 int start = skb_headlen(skb); 214 int i, err, fraglen, end = 0;
215 int i, copy = start - offset; 215 struct sk_buff *next = skb_shinfo(skb)->frag_list;
216 216next_skb:
217 /* Copy header. */ 217 fraglen = skb_headlen(skb);
218 if (copy > 0) { 218 i = -1;
219 if (copy > len)
220 copy = len;
221 if (memcpy_toiovec(to, skb->data + offset, copy))
222 goto fault;
223 if ((len -= copy) == 0)
224 return 0;
225 offset += copy;
226 }
227 219
228 /* Copy paged appendix. Hmm... why does this look so complicated? */ 220 while (1) {
229 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 221 int start = end;
230 int end;
231
232 BUG_TRAP(start <= offset + len);
233 222
234 end = start + skb_shinfo(skb)->frags[i].size; 223 if ((end += fraglen) > offset) {
235 if ((copy = end - offset) > 0) { 224 int copy = end - offset, o = offset - start;
236 int err;
237 u8 *vaddr;
238 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
239 struct page *page = frag->page;
240 225
241 if (copy > len) 226 if (copy > len)
242 copy = len; 227 copy = len;
243 vaddr = kmap(page); 228 if (i == -1)
244 err = memcpy_toiovec(to, vaddr + frag->page_offset + 229 err = memcpy_toiovec(to, skb->data + o, copy);
245 offset - start, copy); 230 else {
246 kunmap(page); 231 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
232 struct page *page = frag->page;
233 void *p = kmap(page) + frag->page_offset + o;
234 err = memcpy_toiovec(to, p, copy);
235 kunmap(page);
236 }
247 if (err) 237 if (err)
248 goto fault; 238 goto fault;
249 if (!(len -= copy)) 239 if (!(len -= copy))
250 return 0; 240 return 0;
251 offset += copy; 241 offset += copy;
252 } 242 }
253 start = end; 243 if (++i >= skb_shinfo(skb)->nr_frags)
244 break;
245 fraglen = skb_shinfo(skb)->frags[i].size;
254 } 246 }
255 247 if (next) {
256 if (skb_shinfo(skb)->frag_list) { 248 skb = next;
257 struct sk_buff *list = skb_shinfo(skb)->frag_list; 249 BUG_ON(skb_shinfo(skb)->frag_list);
258 250 next = skb->next;
259 for (; list; list = list->next) { 251 goto next_skb;
260 int end;
261
262 BUG_TRAP(start <= offset + len);
263
264 end = start + list->len;
265 if ((copy = end - offset) > 0) {
266 if (copy > len)
267 copy = len;
268 if (skb_copy_datagram_iovec(list,
269 offset - start,
270 to, copy))
271 goto fault;
272 if ((len -= copy) == 0)
273 return 0;
274 offset += copy;
275 }
276 start = end;
277 }
278 } 252 }
279 if (!len)
280 return 0;
281
282fault: 253fault:
283 return -EFAULT; 254 return -EFAULT;
284} 255}
diff --git a/net/core/dev.c b/net/core/dev.c
index c01511e3d0c1..a44eeef24edf 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -574,6 +574,8 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
574 return dev; 574 return dev;
575} 575}
576 576
577EXPORT_SYMBOL(dev_getbyhwaddr);
578
577struct net_device *dev_getfirstbyhwtype(unsigned short type) 579struct net_device *dev_getfirstbyhwtype(unsigned short type)
578{ 580{
579 struct net_device *dev; 581 struct net_device *dev;
@@ -1130,7 +1132,7 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
1130#endif 1132#endif
1131 1133
1132/* Keep head the same: replace data */ 1134/* Keep head the same: replace data */
1133int __skb_linearize(struct sk_buff *skb, unsigned int __nocast gfp_mask) 1135int __skb_linearize(struct sk_buff *skb, gfp_t gfp_mask)
1134{ 1136{
1135 unsigned int size; 1137 unsigned int size;
1136 u8 *data; 1138 u8 *data;
@@ -1257,6 +1259,8 @@ int dev_queue_xmit(struct sk_buff *skb)
1257 if (skb_checksum_help(skb, 0)) 1259 if (skb_checksum_help(skb, 0))
1258 goto out_kfree_skb; 1260 goto out_kfree_skb;
1259 1261
1262 spin_lock_prefetch(&dev->queue_lock);
1263
1260 /* Disable soft irqs for various locks below. Also 1264 /* Disable soft irqs for various locks below. Also
1261 * stops preemption for RCU. 1265 * stops preemption for RCU.
1262 */ 1266 */
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 39fc55edf691..1dcf7fa1f0fe 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -61,7 +61,9 @@ static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
61void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev); 61void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
62 62
63static struct neigh_table *neigh_tables; 63static struct neigh_table *neigh_tables;
64#ifdef CONFIG_PROC_FS
64static struct file_operations neigh_stat_seq_fops; 65static struct file_operations neigh_stat_seq_fops;
66#endif
65 67
66/* 68/*
67 Neighbour hash table buckets are protected with rwlock tbl->lock. 69 Neighbour hash table buckets are protected with rwlock tbl->lock.
@@ -173,39 +175,10 @@ static void pneigh_queue_purge(struct sk_buff_head *list)
173 } 175 }
174} 176}
175 177
176void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev) 178static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
177{
178 int i;
179
180 write_lock_bh(&tbl->lock);
181
182 for (i=0; i <= tbl->hash_mask; i++) {
183 struct neighbour *n, **np;
184
185 np = &tbl->hash_buckets[i];
186 while ((n = *np) != NULL) {
187 if (dev && n->dev != dev) {
188 np = &n->next;
189 continue;
190 }
191 *np = n->next;
192 write_lock_bh(&n->lock);
193 n->dead = 1;
194 neigh_del_timer(n);
195 write_unlock_bh(&n->lock);
196 neigh_release(n);
197 }
198 }
199
200 write_unlock_bh(&tbl->lock);
201}
202
203int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
204{ 179{
205 int i; 180 int i;
206 181
207 write_lock_bh(&tbl->lock);
208
209 for (i = 0; i <= tbl->hash_mask; i++) { 182 for (i = 0; i <= tbl->hash_mask; i++) {
210 struct neighbour *n, **np = &tbl->hash_buckets[i]; 183 struct neighbour *n, **np = &tbl->hash_buckets[i];
211 184
@@ -241,7 +214,19 @@ int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
241 neigh_release(n); 214 neigh_release(n);
242 } 215 }
243 } 216 }
217}
218
219void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev)
220{
221 write_lock_bh(&tbl->lock);
222 neigh_flush_dev(tbl, dev);
223 write_unlock_bh(&tbl->lock);
224}
244 225
226int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
227{
228 write_lock_bh(&tbl->lock);
229 neigh_flush_dev(tbl, dev);
245 pneigh_ifdown(tbl, dev); 230 pneigh_ifdown(tbl, dev);
246 write_unlock_bh(&tbl->lock); 231 write_unlock_bh(&tbl->lock);
247 232
@@ -725,6 +710,14 @@ static __inline__ int neigh_max_probes(struct neighbour *n)
725 p->ucast_probes + p->app_probes + p->mcast_probes); 710 p->ucast_probes + p->app_probes + p->mcast_probes);
726} 711}
727 712
713static inline void neigh_add_timer(struct neighbour *n, unsigned long when)
714{
715 if (unlikely(mod_timer(&n->timer, when))) {
716 printk("NEIGH: BUG, double timer add, state is %x\n",
717 n->nud_state);
718 dump_stack();
719 }
720}
728 721
729/* Called when a timer expires for a neighbour entry. */ 722/* Called when a timer expires for a neighbour entry. */
730 723
@@ -806,11 +799,10 @@ static void neigh_timer_handler(unsigned long arg)
806 } 799 }
807 800
808 if (neigh->nud_state & NUD_IN_TIMER) { 801 if (neigh->nud_state & NUD_IN_TIMER) {
809 neigh_hold(neigh);
810 if (time_before(next, jiffies + HZ/2)) 802 if (time_before(next, jiffies + HZ/2))
811 next = jiffies + HZ/2; 803 next = jiffies + HZ/2;
812 neigh->timer.expires = next; 804 if (!mod_timer(&neigh->timer, next))
813 add_timer(&neigh->timer); 805 neigh_hold(neigh);
814 } 806 }
815 if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) { 807 if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
816 struct sk_buff *skb = skb_peek(&neigh->arp_queue); 808 struct sk_buff *skb = skb_peek(&neigh->arp_queue);
@@ -852,8 +844,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
852 atomic_set(&neigh->probes, neigh->parms->ucast_probes); 844 atomic_set(&neigh->probes, neigh->parms->ucast_probes);
853 neigh->nud_state = NUD_INCOMPLETE; 845 neigh->nud_state = NUD_INCOMPLETE;
854 neigh_hold(neigh); 846 neigh_hold(neigh);
855 neigh->timer.expires = now + 1; 847 neigh_add_timer(neigh, now + 1);
856 add_timer(&neigh->timer);
857 } else { 848 } else {
858 neigh->nud_state = NUD_FAILED; 849 neigh->nud_state = NUD_FAILED;
859 write_unlock_bh(&neigh->lock); 850 write_unlock_bh(&neigh->lock);
@@ -866,8 +857,8 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
866 NEIGH_PRINTK2("neigh %p is delayed.\n", neigh); 857 NEIGH_PRINTK2("neigh %p is delayed.\n", neigh);
867 neigh_hold(neigh); 858 neigh_hold(neigh);
868 neigh->nud_state = NUD_DELAY; 859 neigh->nud_state = NUD_DELAY;
869 neigh->timer.expires = jiffies + neigh->parms->delay_probe_time; 860 neigh_add_timer(neigh,
870 add_timer(&neigh->timer); 861 jiffies + neigh->parms->delay_probe_time);
871 } 862 }
872 863
873 if (neigh->nud_state == NUD_INCOMPLETE) { 864 if (neigh->nud_state == NUD_INCOMPLETE) {
@@ -1013,10 +1004,10 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1013 neigh_del_timer(neigh); 1004 neigh_del_timer(neigh);
1014 if (new & NUD_IN_TIMER) { 1005 if (new & NUD_IN_TIMER) {
1015 neigh_hold(neigh); 1006 neigh_hold(neigh);
1016 neigh->timer.expires = jiffies + 1007 neigh_add_timer(neigh, (jiffies +
1017 ((new & NUD_REACHABLE) ? 1008 ((new & NUD_REACHABLE) ?
1018 neigh->parms->reachable_time : 0); 1009 neigh->parms->reachable_time :
1019 add_timer(&neigh->timer); 1010 0)));
1020 } 1011 }
1021 neigh->nud_state = new; 1012 neigh->nud_state = new;
1022 } 1013 }
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 5265dfd69928..802fe11efad0 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -703,7 +703,7 @@ int netpoll_setup(struct netpoll *np)
703 703
704 if (!np->local_ip) { 704 if (!np->local_ip) {
705 rcu_read_lock(); 705 rcu_read_lock();
706 in_dev = __in_dev_get(ndev); 706 in_dev = __in_dev_get_rcu(ndev);
707 707
708 if (!in_dev || !in_dev->ifa_list) { 708 if (!in_dev || !in_dev->ifa_list) {
709 rcu_read_unlock(); 709 rcu_read_unlock();
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index ef430b1e8e42..5f043d346694 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -186,7 +186,7 @@
186 186
187/* Used to help with determining the pkts on receive */ 187/* Used to help with determining the pkts on receive */
188#define PKTGEN_MAGIC 0xbe9be955 188#define PKTGEN_MAGIC 0xbe9be955
189#define PG_PROC_DIR "pktgen" 189#define PG_PROC_DIR "net/pktgen"
190 190
191#define MAX_CFLOWS 65536 191#define MAX_CFLOWS 65536
192 192
@@ -1476,18 +1476,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer,
1476 1476
1477static int create_proc_dir(void) 1477static int create_proc_dir(void)
1478{ 1478{
1479 int len; 1479 pg_proc_dir = proc_mkdir(PG_PROC_DIR, NULL);
1480 /* does proc_dir already exists */
1481 len = strlen(PG_PROC_DIR);
1482
1483 for (pg_proc_dir = proc_net->subdir; pg_proc_dir; pg_proc_dir=pg_proc_dir->next) {
1484 if ((pg_proc_dir->namelen == len) &&
1485 (! memcmp(pg_proc_dir->name, PG_PROC_DIR, len)))
1486 break;
1487 }
1488
1489 if (!pg_proc_dir)
1490 pg_proc_dir = create_proc_entry(PG_PROC_DIR, S_IFDIR, proc_net);
1491 1480
1492 if (!pg_proc_dir) 1481 if (!pg_proc_dir)
1493 return -ENODEV; 1482 return -ENODEV;
@@ -1497,7 +1486,7 @@ static int create_proc_dir(void)
1497 1486
1498static int remove_proc_dir(void) 1487static int remove_proc_dir(void)
1499{ 1488{
1500 remove_proc_entry(PG_PROC_DIR, proc_net); 1489 remove_proc_entry(PG_PROC_DIR, NULL);
1501 return 0; 1490 return 0;
1502} 1491}
1503 1492
@@ -1678,13 +1667,12 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
1678 struct in_device *in_dev; 1667 struct in_device *in_dev;
1679 1668
1680 rcu_read_lock(); 1669 rcu_read_lock();
1681 in_dev = __in_dev_get(pkt_dev->odev); 1670 in_dev = __in_dev_get_rcu(pkt_dev->odev);
1682 if (in_dev) { 1671 if (in_dev) {
1683 if (in_dev->ifa_list) { 1672 if (in_dev->ifa_list) {
1684 pkt_dev->saddr_min = in_dev->ifa_list->ifa_address; 1673 pkt_dev->saddr_min = in_dev->ifa_list->ifa_address;
1685 pkt_dev->saddr_max = pkt_dev->saddr_min; 1674 pkt_dev->saddr_max = pkt_dev->saddr_min;
1686 } 1675 }
1687 __in_dev_put(in_dev);
1688 } 1676 }
1689 rcu_read_unlock(); 1677 rcu_read_unlock();
1690 } 1678 }
@@ -2908,7 +2896,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname)
2908 pkt_dev->udp_dst_max = 9; 2896 pkt_dev->udp_dst_max = 9;
2909 2897
2910 strncpy(pkt_dev->ifname, ifname, 31); 2898 strncpy(pkt_dev->ifname, ifname, 31);
2911 sprintf(pkt_dev->fname, "net/%s/%s", PG_PROC_DIR, ifname); 2899 sprintf(pkt_dev->fname, "%s/%s", PG_PROC_DIR, ifname);
2912 2900
2913 if (! pktgen_setup_dev(pkt_dev)) { 2901 if (! pktgen_setup_dev(pkt_dev)) {
2914 printk("pktgen: ERROR: pktgen_setup_dev failed.\n"); 2902 printk("pktgen: ERROR: pktgen_setup_dev failed.\n");
@@ -2981,7 +2969,7 @@ static int pktgen_create_thread(const char* name, int cpu)
2981 spin_lock_init(&t->if_lock); 2969 spin_lock_init(&t->if_lock);
2982 t->cpu = cpu; 2970 t->cpu = cpu;
2983 2971
2984 sprintf(t->fname, "net/%s/%s", PG_PROC_DIR, t->name); 2972 sprintf(t->fname, "%s/%s", PG_PROC_DIR, t->name);
2985 t->proc_ent = create_proc_entry(t->fname, 0600, NULL); 2973 t->proc_ent = create_proc_entry(t->fname, 0600, NULL);
2986 if (!t->proc_ent) { 2974 if (!t->proc_ent) {
2987 printk("pktgen: cannot create %s procfs entry.\n", t->fname); 2975 printk("pktgen: cannot create %s procfs entry.\n", t->fname);
@@ -3064,7 +3052,7 @@ static int __init pg_init(void)
3064 3052
3065 create_proc_dir(); 3053 create_proc_dir();
3066 3054
3067 sprintf(module_fname, "net/%s/pgctrl", PG_PROC_DIR); 3055 sprintf(module_fname, "%s/pgctrl", PG_PROC_DIR);
3068 module_proc_ent = create_proc_entry(module_fname, 0600, NULL); 3056 module_proc_ent = create_proc_entry(module_fname, 0600, NULL);
3069 if (!module_proc_ent) { 3057 if (!module_proc_ent) {
3070 printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); 3058 printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f80a28785610..02cd4cde2112 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -71,8 +71,6 @@
71static kmem_cache_t *skbuff_head_cache __read_mostly; 71static kmem_cache_t *skbuff_head_cache __read_mostly;
72static kmem_cache_t *skbuff_fclone_cache __read_mostly; 72static kmem_cache_t *skbuff_fclone_cache __read_mostly;
73 73
74struct timeval __read_mostly skb_tv_base;
75
76/* 74/*
77 * Keep out-of-line to prevent kernel bloat. 75 * Keep out-of-line to prevent kernel bloat.
78 * __builtin_return_address is not used because it is not always 76 * __builtin_return_address is not used because it is not always
@@ -132,7 +130,7 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here)
132 * Buffers may only be allocated from interrupts using a @gfp_mask of 130 * Buffers may only be allocated from interrupts using a @gfp_mask of
133 * %GFP_ATOMIC. 131 * %GFP_ATOMIC.
134 */ 132 */
135struct sk_buff *__alloc_skb(unsigned int size, unsigned int __nocast gfp_mask, 133struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
136 int fclone) 134 int fclone)
137{ 135{
138 struct sk_buff *skb; 136 struct sk_buff *skb;
@@ -200,7 +198,7 @@ nodata:
200 */ 198 */
201struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, 199struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
202 unsigned int size, 200 unsigned int size,
203 unsigned int __nocast gfp_mask) 201 gfp_t gfp_mask)
204{ 202{
205 struct sk_buff *skb; 203 struct sk_buff *skb;
206 u8 *data; 204 u8 *data;
@@ -363,7 +361,7 @@ void __kfree_skb(struct sk_buff *skb)
363 * %GFP_ATOMIC. 361 * %GFP_ATOMIC.
364 */ 362 */
365 363
366struct sk_buff *skb_clone(struct sk_buff *skb, unsigned int __nocast gfp_mask) 364struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
367{ 365{
368 struct sk_buff *n; 366 struct sk_buff *n;
369 367
@@ -412,6 +410,9 @@ struct sk_buff *skb_clone(struct sk_buff *skb, unsigned int __nocast gfp_mask)
412 C(nfct); 410 C(nfct);
413 nf_conntrack_get(skb->nfct); 411 nf_conntrack_get(skb->nfct);
414 C(nfctinfo); 412 C(nfctinfo);
413#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
414 C(ipvs_property);
415#endif
415#ifdef CONFIG_BRIDGE_NETFILTER 416#ifdef CONFIG_BRIDGE_NETFILTER
416 C(nf_bridge); 417 C(nf_bridge);
417 nf_bridge_get(skb->nf_bridge); 418 nf_bridge_get(skb->nf_bridge);
@@ -469,6 +470,9 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
469 new->nfct = old->nfct; 470 new->nfct = old->nfct;
470 nf_conntrack_get(old->nfct); 471 nf_conntrack_get(old->nfct);
471 new->nfctinfo = old->nfctinfo; 472 new->nfctinfo = old->nfctinfo;
473#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
474 new->ipvs_property = old->ipvs_property;
475#endif
472#ifdef CONFIG_BRIDGE_NETFILTER 476#ifdef CONFIG_BRIDGE_NETFILTER
473 new->nf_bridge = old->nf_bridge; 477 new->nf_bridge = old->nf_bridge;
474 nf_bridge_get(old->nf_bridge); 478 nf_bridge_get(old->nf_bridge);
@@ -502,7 +506,7 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
502 * header is going to be modified. Use pskb_copy() instead. 506 * header is going to be modified. Use pskb_copy() instead.
503 */ 507 */
504 508
505struct sk_buff *skb_copy(const struct sk_buff *skb, unsigned int __nocast gfp_mask) 509struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
506{ 510{
507 int headerlen = skb->data - skb->head; 511 int headerlen = skb->data - skb->head;
508 /* 512 /*
@@ -541,7 +545,7 @@ struct sk_buff *skb_copy(const struct sk_buff *skb, unsigned int __nocast gfp_ma
541 * The returned buffer has a reference count of 1. 545 * The returned buffer has a reference count of 1.
542 */ 546 */
543 547
544struct sk_buff *pskb_copy(struct sk_buff *skb, unsigned int __nocast gfp_mask) 548struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask)
545{ 549{
546 /* 550 /*
547 * Allocate the copy buffer 551 * Allocate the copy buffer
@@ -600,7 +604,7 @@ out:
600 */ 604 */
601 605
602int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, 606int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
603 unsigned int __nocast gfp_mask) 607 gfp_t gfp_mask)
604{ 608{
605 int i; 609 int i;
606 u8 *data; 610 u8 *data;
@@ -691,7 +695,7 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom)
691 */ 695 */
692struct sk_buff *skb_copy_expand(const struct sk_buff *skb, 696struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
693 int newheadroom, int newtailroom, 697 int newheadroom, int newtailroom,
694 unsigned int __nocast gfp_mask) 698 gfp_t gfp_mask)
695{ 699{
696 /* 700 /*
697 * Allocate the copy buffer 701 * Allocate the copy buffer
@@ -1708,8 +1712,6 @@ void __init skb_init(void)
1708 NULL, NULL); 1712 NULL, NULL);
1709 if (!skbuff_fclone_cache) 1713 if (!skbuff_fclone_cache)
1710 panic("cannot create skbuff cache"); 1714 panic("cannot create skbuff cache");
1711
1712 do_gettimeofday(&skb_tv_base);
1713} 1715}
1714 1716
1715EXPORT_SYMBOL(___pskb_trim); 1717EXPORT_SYMBOL(___pskb_trim);
@@ -1743,4 +1745,3 @@ EXPORT_SYMBOL(skb_prepare_seq_read);
1743EXPORT_SYMBOL(skb_seq_read); 1745EXPORT_SYMBOL(skb_seq_read);
1744EXPORT_SYMBOL(skb_abort_seq_read); 1746EXPORT_SYMBOL(skb_abort_seq_read);
1745EXPORT_SYMBOL(skb_find_text); 1747EXPORT_SYMBOL(skb_find_text);
1746EXPORT_SYMBOL(skb_tv_base);
diff --git a/net/core/sock.c b/net/core/sock.c
index ac63b56e23b2..1c52fe809eda 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -637,7 +637,7 @@ lenout:
637 * @prot: struct proto associated with this new sock instance 637 * @prot: struct proto associated with this new sock instance
638 * @zero_it: if we should zero the newly allocated sock 638 * @zero_it: if we should zero the newly allocated sock
639 */ 639 */
640struct sock *sk_alloc(int family, unsigned int __nocast priority, 640struct sock *sk_alloc(int family, gfp_t priority,
641 struct proto *prot, int zero_it) 641 struct proto *prot, int zero_it)
642{ 642{
643 struct sock *sk = NULL; 643 struct sock *sk = NULL;
@@ -660,16 +660,20 @@ struct sock *sk_alloc(int family, unsigned int __nocast priority,
660 sock_lock_init(sk); 660 sock_lock_init(sk);
661 } 661 }
662 662
663 if (security_sk_alloc(sk, family, priority)) { 663 if (security_sk_alloc(sk, family, priority))
664 if (slab != NULL) 664 goto out_free;
665 kmem_cache_free(slab, sk); 665
666 else 666 if (!try_module_get(prot->owner))
667 kfree(sk); 667 goto out_free;
668 sk = NULL;
669 } else
670 __module_get(prot->owner);
671 } 668 }
672 return sk; 669 return sk;
670
671out_free:
672 if (slab != NULL)
673 kmem_cache_free(slab, sk);
674 else
675 kfree(sk);
676 return NULL;
673} 677}
674 678
675void sk_free(struct sock *sk) 679void sk_free(struct sock *sk)
@@ -700,7 +704,7 @@ void sk_free(struct sock *sk)
700 module_put(owner); 704 module_put(owner);
701} 705}
702 706
703struct sock *sk_clone(const struct sock *sk, const unsigned int __nocast priority) 707struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
704{ 708{
705 struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0); 709 struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0);
706 710
@@ -841,7 +845,7 @@ unsigned long sock_i_ino(struct sock *sk)
841 * Allocate a skb from the socket's send buffer. 845 * Allocate a skb from the socket's send buffer.
842 */ 846 */
843struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, 847struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force,
844 unsigned int __nocast priority) 848 gfp_t priority)
845{ 849{
846 if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) { 850 if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) {
847 struct sk_buff * skb = alloc_skb(size, priority); 851 struct sk_buff * skb = alloc_skb(size, priority);
@@ -857,7 +861,7 @@ struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force,
857 * Allocate a skb from the socket's receive buffer. 861 * Allocate a skb from the socket's receive buffer.
858 */ 862 */
859struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, 863struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force,
860 unsigned int __nocast priority) 864 gfp_t priority)
861{ 865{
862 if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { 866 if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) {
863 struct sk_buff *skb = alloc_skb(size, priority); 867 struct sk_buff *skb = alloc_skb(size, priority);
@@ -872,7 +876,7 @@ struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force,
872/* 876/*
873 * Allocate a memory block from the socket's option memory buffer. 877 * Allocate a memory block from the socket's option memory buffer.
874 */ 878 */
875void *sock_kmalloc(struct sock *sk, int size, unsigned int __nocast priority) 879void *sock_kmalloc(struct sock *sk, int size, gfp_t priority)
876{ 880{
877 if ((unsigned)size <= sysctl_optmem_max && 881 if ((unsigned)size <= sysctl_optmem_max &&
878 atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { 882 atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) {
diff --git a/net/core/wireless.c b/net/core/wireless.c
index d17f1583ea3e..271ddb35b0b2 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -455,10 +455,15 @@ static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
455 455
456 /* Old location, field to be removed in next WE */ 456 /* Old location, field to be removed in next WE */
457 if(dev->get_wireless_stats) { 457 if(dev->get_wireless_stats) {
458 printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n", 458 static int printed_message;
459 dev->name); 459
460 if (!printed_message++)
461 printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
462 dev->name);
463
460 return dev->get_wireless_stats(dev); 464 return dev->get_wireless_stats(dev);
461 } 465 }
466
462 /* Not found */ 467 /* Not found */
463 return (struct iw_statistics *) NULL; 468 return (struct iw_statistics *) NULL;
464} 469}
diff --git a/net/dccp/Makefile b/net/dccp/Makefile
index fb97bb042455..344a8da153fc 100644
--- a/net/dccp/Makefile
+++ b/net/dccp/Makefile
@@ -3,6 +3,8 @@ obj-$(CONFIG_IP_DCCP) += dccp.o
3dccp-y := ccid.o input.o ipv4.o minisocks.o options.o output.o proto.o \ 3dccp-y := ccid.o input.o ipv4.o minisocks.o options.o output.o proto.o \
4 timer.o 4 timer.o
5 5
6dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.o
7
6obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o 8obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o
7 9
8dccp_diag-y := diag.o 10dccp_diag-y := diag.o
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
new file mode 100644
index 000000000000..c9a62cca22fc
--- /dev/null
+++ b/net/dccp/ackvec.c
@@ -0,0 +1,419 @@
1/*
2 * net/dccp/ackvec.c
3 *
4 * An implementation of the DCCP protocol
5 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; version 2 of the License;
10 */
11
12#include "ackvec.h"
13#include "dccp.h"
14
15#include <linux/dccp.h>
16#include <linux/skbuff.h>
17
18#include <net/sock.h>
19
20int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
21{
22 struct dccp_sock *dp = dccp_sk(sk);
23 struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
24 int len = av->dccpav_vec_len + 2;
25 struct timeval now;
26 u32 elapsed_time;
27 unsigned char *to, *from;
28
29 dccp_timestamp(sk, &now);
30 elapsed_time = timeval_delta(&now, &av->dccpav_time) / 10;
31
32 if (elapsed_time != 0)
33 dccp_insert_option_elapsed_time(sk, skb, elapsed_time);
34
35 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
36 return -1;
37
38 /*
39 * XXX: now we have just one ack vector sent record, so
40 * we have to wait for it to be cleared.
41 *
42 * Of course this is not acceptable, but this is just for
43 * basic testing now.
44 */
45 if (av->dccpav_ack_seqno != DCCP_MAX_SEQNO + 1)
46 return -1;
47
48 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
49
50 to = skb_push(skb, len);
51 *to++ = DCCPO_ACK_VECTOR_0;
52 *to++ = len;
53
54 len = av->dccpav_vec_len;
55 from = av->dccpav_buf + av->dccpav_buf_head;
56
57 /* Check if buf_head wraps */
58 if (av->dccpav_buf_head + len > av->dccpav_vec_len) {
59 const u32 tailsize = (av->dccpav_vec_len - av->dccpav_buf_head);
60
61 memcpy(to, from, tailsize);
62 to += tailsize;
63 len -= tailsize;
64 from = av->dccpav_buf;
65 }
66
67 memcpy(to, from, len);
68 /*
69 * From draft-ietf-dccp-spec-11.txt:
70 *
71 * For each acknowledgement it sends, the HC-Receiver will add an
72 * acknowledgement record. ack_seqno will equal the HC-Receiver
73 * sequence number it used for the ack packet; ack_ptr will equal
74 * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will
75 * equal buf_nonce.
76 *
77 * This implemention uses just one ack record for now.
78 */
79 av->dccpav_ack_seqno = DCCP_SKB_CB(skb)->dccpd_seq;
80 av->dccpav_ack_ptr = av->dccpav_buf_head;
81 av->dccpav_ack_ackno = av->dccpav_buf_ackno;
82 av->dccpav_ack_nonce = av->dccpav_buf_nonce;
83 av->dccpav_sent_len = av->dccpav_vec_len;
84
85 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, "
86 "ack_ackno=%llu\n",
87 debug_prefix, av->dccpav_sent_len,
88 (unsigned long long)av->dccpav_ack_seqno,
89 (unsigned long long)av->dccpav_ack_ackno);
90 return -1;
91}
92
93struct dccp_ackvec *dccp_ackvec_alloc(const unsigned int len,
94 const gfp_t priority)
95{
96 struct dccp_ackvec *av = kmalloc(sizeof(*av) + len, priority);
97
98 if (av != NULL) {
99 av->dccpav_buf_len = len;
100 av->dccpav_buf_head =
101 av->dccpav_buf_tail = av->dccpav_buf_len - 1;
102 av->dccpav_buf_ackno =
103 av->dccpav_ack_ackno = av->dccpav_ack_seqno = ~0LLU;
104 av->dccpav_buf_nonce = av->dccpav_buf_nonce = 0;
105 av->dccpav_ack_ptr = 0;
106 av->dccpav_time.tv_sec = 0;
107 av->dccpav_time.tv_usec = 0;
108 av->dccpav_sent_len = av->dccpav_vec_len = 0;
109 }
110
111 return av;
112}
113
114void dccp_ackvec_free(struct dccp_ackvec *av)
115{
116 kfree(av);
117}
118
119static inline u8 dccp_ackvec_state(const struct dccp_ackvec *av,
120 const unsigned int index)
121{
122 return av->dccpav_buf[index] & DCCP_ACKVEC_STATE_MASK;
123}
124
125static inline u8 dccp_ackvec_len(const struct dccp_ackvec *av,
126 const unsigned int index)
127{
128 return av->dccpav_buf[index] & DCCP_ACKVEC_LEN_MASK;
129}
130
131/*
132 * If several packets are missing, the HC-Receiver may prefer to enter multiple
133 * bytes with run length 0, rather than a single byte with a larger run length;
134 * this simplifies table updates if one of the missing packets arrives.
135 */
136static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av,
137 const unsigned int packets,
138 const unsigned char state)
139{
140 unsigned int gap;
141 signed long new_head;
142
143 if (av->dccpav_vec_len + packets > av->dccpav_buf_len)
144 return -ENOBUFS;
145
146 gap = packets - 1;
147 new_head = av->dccpav_buf_head - packets;
148
149 if (new_head < 0) {
150 if (gap > 0) {
151 memset(av->dccpav_buf, DCCP_ACKVEC_STATE_NOT_RECEIVED,
152 gap + new_head + 1);
153 gap = -new_head;
154 }
155 new_head += av->dccpav_buf_len;
156 }
157
158 av->dccpav_buf_head = new_head;
159
160 if (gap > 0)
161 memset(av->dccpav_buf + av->dccpav_buf_head + 1,
162 DCCP_ACKVEC_STATE_NOT_RECEIVED, gap);
163
164 av->dccpav_buf[av->dccpav_buf_head] = state;
165 av->dccpav_vec_len += packets;
166 return 0;
167}
168
169/*
170 * Implements the draft-ietf-dccp-spec-11.txt Appendix A
171 */
172int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
173 const u64 ackno, const u8 state)
174{
175 /*
176 * Check at the right places if the buffer is full, if it is, tell the
177 * caller to start dropping packets till the HC-Sender acks our ACK
178 * vectors, when we will free up space in dccpav_buf.
179 *
180 * We may well decide to do buffer compression, etc, but for now lets
181 * just drop.
182 *
183 * From Appendix A:
184 *
185 * Of course, the circular buffer may overflow, either when the
186 * HC-Sender is sending data at a very high rate, when the
187 * HC-Receiver's acknowledgements are not reaching the HC-Sender,
188 * or when the HC-Sender is forgetting to acknowledge those acks
189 * (so the HC-Receiver is unable to clean up old state). In this
190 * case, the HC-Receiver should either compress the buffer (by
191 * increasing run lengths when possible), transfer its state to
192 * a larger buffer, or, as a last resort, drop all received
193 * packets, without processing them whatsoever, until its buffer
194 * shrinks again.
195 */
196
197 /* See if this is the first ackno being inserted */
198 if (av->dccpav_vec_len == 0) {
199 av->dccpav_buf[av->dccpav_buf_head] = state;
200 av->dccpav_vec_len = 1;
201 } else if (after48(ackno, av->dccpav_buf_ackno)) {
202 const u64 delta = dccp_delta_seqno(av->dccpav_buf_ackno,
203 ackno);
204
205 /*
206 * Look if the state of this packet is the same as the
207 * previous ackno and if so if we can bump the head len.
208 */
209 if (delta == 1 &&
210 dccp_ackvec_state(av, av->dccpav_buf_head) == state &&
211 (dccp_ackvec_len(av, av->dccpav_buf_head) <
212 DCCP_ACKVEC_LEN_MASK))
213 av->dccpav_buf[av->dccpav_buf_head]++;
214 else if (dccp_ackvec_set_buf_head_state(av, delta, state))
215 return -ENOBUFS;
216 } else {
217 /*
218 * A.1.2. Old Packets
219 *
220 * When a packet with Sequence Number S arrives, and
221 * S <= buf_ackno, the HC-Receiver will scan the table
222 * for the byte corresponding to S. (Indexing structures
223 * could reduce the complexity of this scan.)
224 */
225 u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno);
226 unsigned int index = av->dccpav_buf_head;
227
228 while (1) {
229 const u8 len = dccp_ackvec_len(av, index);
230 const u8 state = dccp_ackvec_state(av, index);
231 /*
232 * valid packets not yet in dccpav_buf have a reserved
233 * entry, with a len equal to 0.
234 */
235 if (state == DCCP_ACKVEC_STATE_NOT_RECEIVED &&
236 len == 0 && delta == 0) { /* Found our
237 reserved seat! */
238 dccp_pr_debug("Found %llu reserved seat!\n",
239 (unsigned long long)ackno);
240 av->dccpav_buf[index] = state;
241 goto out;
242 }
243 /* len == 0 means one packet */
244 if (delta < len + 1)
245 goto out_duplicate;
246
247 delta -= len + 1;
248 if (++index == av->dccpav_buf_len)
249 index = 0;
250 }
251 }
252
253 av->dccpav_buf_ackno = ackno;
254 dccp_timestamp(sk, &av->dccpav_time);
255out:
256 dccp_pr_debug("");
257 return 0;
258
259out_duplicate:
260 /* Duplicate packet */
261 dccp_pr_debug("Received a dup or already considered lost "
262 "packet: %llu\n", (unsigned long long)ackno);
263 return -EILSEQ;
264}
265
266#ifdef CONFIG_IP_DCCP_DEBUG
267void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len)
268{
269 if (!dccp_debug)
270 return;
271
272 printk("ACK vector len=%d, ackno=%llu |", len,
273 (unsigned long long)ackno);
274
275 while (len--) {
276 const u8 state = (*vector & DCCP_ACKVEC_STATE_MASK) >> 6;
277 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
278
279 printk("%d,%d|", state, rl);
280 ++vector;
281 }
282
283 printk("\n");
284}
285
286void dccp_ackvec_print(const struct dccp_ackvec *av)
287{
288 dccp_ackvector_print(av->dccpav_buf_ackno,
289 av->dccpav_buf + av->dccpav_buf_head,
290 av->dccpav_vec_len);
291}
292#endif
293
294static void dccp_ackvec_trow_away_ack_record(struct dccp_ackvec *av)
295{
296 /*
297 * As we're keeping track of the ack vector size (dccpav_vec_len) and
298 * the sent ack vector size (dccpav_sent_len) we don't need
299 * dccpav_buf_tail at all, but keep this code here as in the future
300 * we'll implement a vector of ack records, as suggested in
301 * draft-ietf-dccp-spec-11.txt Appendix A. -acme
302 */
303#if 0
304 av->dccpav_buf_tail = av->dccpav_ack_ptr + 1;
305 if (av->dccpav_buf_tail >= av->dccpav_vec_len)
306 av->dccpav_buf_tail -= av->dccpav_vec_len;
307#endif
308 av->dccpav_vec_len -= av->dccpav_sent_len;
309}
310
311void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, struct sock *sk,
312 const u64 ackno)
313{
314 /* Check if we actually sent an ACK vector */
315 if (av->dccpav_ack_seqno == DCCP_MAX_SEQNO + 1)
316 return;
317
318 if (ackno == av->dccpav_ack_seqno) {
319#ifdef CONFIG_IP_DCCP_DEBUG
320 struct dccp_sock *dp = dccp_sk(sk);
321 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
322 "CLIENT rx ack: " : "server rx ack: ";
323#endif
324 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, "
325 "ack_ackno=%llu, ACKED!\n",
326 debug_prefix, 1,
327 (unsigned long long)av->dccpav_ack_seqno,
328 (unsigned long long)av->dccpav_ack_ackno);
329 dccp_ackvec_trow_away_ack_record(av);
330 av->dccpav_ack_seqno = DCCP_MAX_SEQNO + 1;
331 }
332}
333
334static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av,
335 struct sock *sk, u64 ackno,
336 const unsigned char len,
337 const unsigned char *vector)
338{
339 unsigned char i;
340
341 /* Check if we actually sent an ACK vector */
342 if (av->dccpav_ack_seqno == DCCP_MAX_SEQNO + 1)
343 return;
344 /*
345 * We're in the receiver half connection, so if the received an ACK
346 * vector ackno (e.g. 50) before dccpav_ack_seqno (e.g. 52), we're
347 * not interested.
348 *
349 * Extra explanation with example:
350 *
351 * if we received an ACK vector with ackno 50, it can only be acking
352 * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent).
353 */
354 /* dccp_pr_debug("is %llu < %llu? ", ackno, av->dccpav_ack_seqno); */
355 if (before48(ackno, av->dccpav_ack_seqno)) {
356 /* dccp_pr_debug_cat("yes\n"); */
357 return;
358 }
359 /* dccp_pr_debug_cat("no\n"); */
360
361 i = len;
362 while (i--) {
363 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
364 u64 ackno_end_rl;
365
366 dccp_set_seqno(&ackno_end_rl, ackno - rl);
367
368 /*
369 * dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl,
370 * av->dccpav_ack_seqno, ackno);
371 */
372 if (between48(av->dccpav_ack_seqno, ackno_end_rl, ackno)) {
373 const u8 state = (*vector &
374 DCCP_ACKVEC_STATE_MASK) >> 6;
375 /* dccp_pr_debug_cat("yes\n"); */
376
377 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED) {
378#ifdef CONFIG_IP_DCCP_DEBUG
379 struct dccp_sock *dp = dccp_sk(sk);
380 const char *debug_prefix =
381 dp->dccps_role == DCCP_ROLE_CLIENT ?
382 "CLIENT rx ack: " : "server rx ack: ";
383#endif
384 dccp_pr_debug("%sACK vector 0, len=%d, "
385 "ack_seqno=%llu, ack_ackno=%llu, "
386 "ACKED!\n",
387 debug_prefix, len,
388 (unsigned long long)
389 av->dccpav_ack_seqno,
390 (unsigned long long)
391 av->dccpav_ack_ackno);
392 dccp_ackvec_trow_away_ack_record(av);
393 }
394 /*
395 * If dccpav_ack_seqno was not received, no problem
396 * we'll send another ACK vector.
397 */
398 av->dccpav_ack_seqno = DCCP_MAX_SEQNO + 1;
399 break;
400 }
401 /* dccp_pr_debug_cat("no\n"); */
402
403 dccp_set_seqno(&ackno, ackno_end_rl - 1);
404 ++vector;
405 }
406}
407
408int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
409 const u8 opt, const u8 *value, const u8 len)
410{
411 if (len > DCCP_MAX_ACKVEC_LEN)
412 return -1;
413
414 /* dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, value, len); */
415 dccp_ackvec_check_rcv_ackvector(dccp_sk(sk)->dccps_hc_rx_ackvec, sk,
416 DCCP_SKB_CB(skb)->dccpd_ack_seq,
417 len, value);
418 return 0;
419}
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
new file mode 100644
index 000000000000..d0fd6c60c574
--- /dev/null
+++ b/net/dccp/ackvec.h
@@ -0,0 +1,133 @@
1#ifndef _ACKVEC_H
2#define _ACKVEC_H
3/*
4 * net/dccp/ackvec.h
5 *
6 * An implementation of the DCCP protocol
7 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@mandriva.com>
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 version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/config.h>
15#include <linux/compiler.h>
16#include <linux/time.h>
17#include <linux/types.h>
18
19/* Read about the ECN nonce to see why it is 253 */
20#define DCCP_MAX_ACKVEC_LEN 253
21
22#define DCCP_ACKVEC_STATE_RECEIVED 0
23#define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6)
24#define DCCP_ACKVEC_STATE_NOT_RECEIVED (3 << 6)
25
26#define DCCP_ACKVEC_STATE_MASK 0xC0 /* 11000000 */
27#define DCCP_ACKVEC_LEN_MASK 0x3F /* 00111111 */
28
29/** struct dccp_ackvec - ack vector
30 *
31 * This data structure is the one defined in the DCCP draft
32 * Appendix A.
33 *
34 * @dccpav_buf_head - circular buffer head
35 * @dccpav_buf_tail - circular buffer tail
36 * @dccpav_buf_ackno - ack # of the most recent packet acknowledgeable in the
37 * buffer (i.e. %dccpav_buf_head)
38 * @dccpav_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
39 * by the buffer with State 0
40 *
41 * Additionally, the HC-Receiver must keep some information about the
42 * Ack Vectors it has recently sent. For each packet sent carrying an
43 * Ack Vector, it remembers four variables:
44 *
45 * @dccpav_ack_seqno - the Sequence Number used for the packet
46 * (HC-Receiver seqno)
47 * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
48 * @dccpav_ack_ackno - the Acknowledgement Number used for the packet
49 * (HC-Sender seqno)
50 * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
51 *
52 * @dccpav_buf_len - circular buffer length
53 * @dccpav_time - the time in usecs
54 * @dccpav_buf - circular buffer of acknowledgeable packets
55 */
56struct dccp_ackvec {
57 unsigned int dccpav_buf_head;
58 unsigned int dccpav_buf_tail;
59 u64 dccpav_buf_ackno;
60 u64 dccpav_ack_seqno;
61 u64 dccpav_ack_ackno;
62 unsigned int dccpav_ack_ptr;
63 unsigned int dccpav_sent_len;
64 unsigned int dccpav_vec_len;
65 unsigned int dccpav_buf_len;
66 struct timeval dccpav_time;
67 u8 dccpav_buf_nonce;
68 u8 dccpav_ack_nonce;
69 u8 dccpav_buf[0];
70};
71
72struct sock;
73struct sk_buff;
74
75#ifdef CONFIG_IP_DCCP_ACKVEC
76extern struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len,
77 const gfp_t priority);
78extern void dccp_ackvec_free(struct dccp_ackvec *av);
79
80extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
81 const u64 ackno, const u8 state);
82
83extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
84 struct sock *sk, const u64 ackno);
85extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
86 const u8 opt, const u8 *value, const u8 len);
87
88extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
89
90static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
91{
92 return av->dccpav_sent_len != av->dccpav_vec_len;
93}
94#else /* CONFIG_IP_DCCP_ACKVEC */
95static inline struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len,
96 const gfp_t priority)
97{
98 return NULL;
99}
100
101static inline void dccp_ackvec_free(struct dccp_ackvec *av)
102{
103}
104
105static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
106 const u64 ackno, const u8 state)
107{
108 return -1;
109}
110
111static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
112 struct sock *sk, const u64 ackno)
113{
114}
115
116static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
117 const u8 opt, const u8 *value, const u8 len)
118{
119 return -1;
120}
121
122static inline int dccp_insert_option_ackvec(const struct sock *sk,
123 const struct sk_buff *skb)
124{
125 return -1;
126}
127
128static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
129{
130 return 0;
131}
132#endif /* CONFIG_IP_DCCP_ACKVEC */
133#endif /* _ACKVEC_H */
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index 962f1e9e2f7e..c37eeeaf5c6e 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <net/sock.h> 16#include <net/sock.h>
17#include <linux/compiler.h>
17#include <linux/dccp.h> 18#include <linux/dccp.h>
18#include <linux/list.h> 19#include <linux/list.h>
19#include <linux/module.h> 20#include <linux/module.h>
@@ -54,6 +55,14 @@ struct ccid {
54 struct tcp_info *info); 55 struct tcp_info *info);
55 void (*ccid_hc_tx_get_info)(struct sock *sk, 56 void (*ccid_hc_tx_get_info)(struct sock *sk,
56 struct tcp_info *info); 57 struct tcp_info *info);
58 int (*ccid_hc_rx_getsockopt)(struct sock *sk,
59 const int optname, int len,
60 u32 __user *optval,
61 int __user *optlen);
62 int (*ccid_hc_tx_getsockopt)(struct sock *sk,
63 const int optname, int len,
64 u32 __user *optval,
65 int __user *optlen);
57}; 66};
58 67
59extern int ccid_register(struct ccid *ccid); 68extern int ccid_register(struct ccid *ccid);
@@ -101,14 +110,14 @@ static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk)
101 110
102static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk) 111static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk)
103{ 112{
104 if (ccid->ccid_hc_rx_exit != NULL && 113 if (ccid != NULL && ccid->ccid_hc_rx_exit != NULL &&
105 dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL) 114 dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL)
106 ccid->ccid_hc_rx_exit(sk); 115 ccid->ccid_hc_rx_exit(sk);
107} 116}
108 117
109static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk) 118static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk)
110{ 119{
111 if (ccid->ccid_hc_tx_exit != NULL && 120 if (ccid != NULL && ccid->ccid_hc_tx_exit != NULL &&
112 dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL) 121 dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL)
113 ccid->ccid_hc_tx_exit(sk); 122 ccid->ccid_hc_tx_exit(sk);
114} 123}
@@ -177,4 +186,26 @@ static inline void ccid_hc_tx_get_info(struct ccid *ccid, struct sock *sk,
177 if (ccid->ccid_hc_tx_get_info != NULL) 186 if (ccid->ccid_hc_tx_get_info != NULL)
178 ccid->ccid_hc_tx_get_info(sk, info); 187 ccid->ccid_hc_tx_get_info(sk, info);
179} 188}
189
190static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk,
191 const int optname, int len,
192 u32 __user *optval, int __user *optlen)
193{
194 int rc = -ENOPROTOOPT;
195 if (ccid->ccid_hc_rx_getsockopt != NULL)
196 rc = ccid->ccid_hc_rx_getsockopt(sk, optname, len,
197 optval, optlen);
198 return rc;
199}
200
201static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk,
202 const int optname, int len,
203 u32 __user *optval, int __user *optlen)
204{
205 int rc = -ENOPROTOOPT;
206 if (ccid->ccid_hc_tx_getsockopt != NULL)
207 rc = ccid->ccid_hc_tx_getsockopt(sk, optname, len,
208 optval, optlen);
209 return rc;
210}
180#endif /* _CCID_H */ 211#endif /* _CCID_H */
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 38aa84986118..aa68e0ab274d 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -1120,6 +1120,60 @@ static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
1120 info->tcpi_rtt = hctx->ccid3hctx_rtt; 1120 info->tcpi_rtt = hctx->ccid3hctx_rtt;
1121} 1121}
1122 1122
1123static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
1124 u32 __user *optval, int __user *optlen)
1125{
1126 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1127 const void *val;
1128
1129 /* Listen socks doesn't have a private CCID block */
1130 if (sk->sk_state == DCCP_LISTEN)
1131 return -EINVAL;
1132
1133 switch (optname) {
1134 case DCCP_SOCKOPT_CCID_RX_INFO:
1135 if (len < sizeof(hcrx->ccid3hcrx_tfrc))
1136 return -EINVAL;
1137 len = sizeof(hcrx->ccid3hcrx_tfrc);
1138 val = &hcrx->ccid3hcrx_tfrc;
1139 break;
1140 default:
1141 return -ENOPROTOOPT;
1142 }
1143
1144 if (put_user(len, optlen) || copy_to_user(optval, val, len))
1145 return -EFAULT;
1146
1147 return 0;
1148}
1149
1150static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
1151 u32 __user *optval, int __user *optlen)
1152{
1153 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
1154 const void *val;
1155
1156 /* Listen socks doesn't have a private CCID block */
1157 if (sk->sk_state == DCCP_LISTEN)
1158 return -EINVAL;
1159
1160 switch (optname) {
1161 case DCCP_SOCKOPT_CCID_TX_INFO:
1162 if (len < sizeof(hctx->ccid3hctx_tfrc))
1163 return -EINVAL;
1164 len = sizeof(hctx->ccid3hctx_tfrc);
1165 val = &hctx->ccid3hctx_tfrc;
1166 break;
1167 default:
1168 return -ENOPROTOOPT;
1169 }
1170
1171 if (put_user(len, optlen) || copy_to_user(optval, val, len))
1172 return -EFAULT;
1173
1174 return 0;
1175}
1176
1123static struct ccid ccid3 = { 1177static struct ccid ccid3 = {
1124 .ccid_id = 3, 1178 .ccid_id = 3,
1125 .ccid_name = "ccid3", 1179 .ccid_name = "ccid3",
@@ -1139,6 +1193,8 @@ static struct ccid ccid3 = {
1139 .ccid_hc_rx_packet_recv = ccid3_hc_rx_packet_recv, 1193 .ccid_hc_rx_packet_recv = ccid3_hc_rx_packet_recv,
1140 .ccid_hc_rx_get_info = ccid3_hc_rx_get_info, 1194 .ccid_hc_rx_get_info = ccid3_hc_rx_get_info,
1141 .ccid_hc_tx_get_info = ccid3_hc_tx_get_info, 1195 .ccid_hc_tx_get_info = ccid3_hc_tx_get_info,
1196 .ccid_hc_rx_getsockopt = ccid3_hc_rx_getsockopt,
1197 .ccid_hc_tx_getsockopt = ccid3_hc_tx_getsockopt,
1142}; 1198};
1143 1199
1144module_param(ccid3_debug, int, 0444); 1200module_param(ccid3_debug, int, 0444);
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index eb248778eea3..0bde4583d091 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -40,6 +40,7 @@
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/time.h> 41#include <linux/time.h>
42#include <linux/types.h> 42#include <linux/types.h>
43#include <linux/tfrc.h>
43 44
44#define TFRC_MIN_PACKET_SIZE 16 45#define TFRC_MIN_PACKET_SIZE 16
45#define TFRC_STD_PACKET_SIZE 256 46#define TFRC_STD_PACKET_SIZE 256
@@ -93,12 +94,15 @@ struct ccid3_options_received {
93 * @ccid3hctx_hist - Packet history 94 * @ccid3hctx_hist - Packet history
94 */ 95 */
95struct ccid3_hc_tx_sock { 96struct ccid3_hc_tx_sock {
96 u32 ccid3hctx_x; 97 struct tfrc_tx_info ccid3hctx_tfrc;
97 u32 ccid3hctx_x_recv; 98#define ccid3hctx_x ccid3hctx_tfrc.tfrctx_x
98 u32 ccid3hctx_x_calc; 99#define ccid3hctx_x_recv ccid3hctx_tfrc.tfrctx_x_recv
100#define ccid3hctx_x_calc ccid3hctx_tfrc.tfrctx_x_calc
101#define ccid3hctx_rtt ccid3hctx_tfrc.tfrctx_rtt
102#define ccid3hctx_p ccid3hctx_tfrc.tfrctx_p
103#define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto
104#define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi
99 u16 ccid3hctx_s; 105 u16 ccid3hctx_s;
100 u32 ccid3hctx_rtt;
101 u32 ccid3hctx_p;
102 u8 ccid3hctx_state; 106 u8 ccid3hctx_state;
103 u8 ccid3hctx_last_win_count; 107 u8 ccid3hctx_last_win_count;
104 u8 ccid3hctx_idle; 108 u8 ccid3hctx_idle;
@@ -106,19 +110,19 @@ struct ccid3_hc_tx_sock {
106 struct timer_list ccid3hctx_no_feedback_timer; 110 struct timer_list ccid3hctx_no_feedback_timer;
107 struct timeval ccid3hctx_t_ld; 111 struct timeval ccid3hctx_t_ld;
108 struct timeval ccid3hctx_t_nom; 112 struct timeval ccid3hctx_t_nom;
109 u32 ccid3hctx_t_rto;
110 u32 ccid3hctx_t_ipi;
111 u32 ccid3hctx_delta; 113 u32 ccid3hctx_delta;
112 struct list_head ccid3hctx_hist; 114 struct list_head ccid3hctx_hist;
113 struct ccid3_options_received ccid3hctx_options_received; 115 struct ccid3_options_received ccid3hctx_options_received;
114}; 116};
115 117
116struct ccid3_hc_rx_sock { 118struct ccid3_hc_rx_sock {
119 struct tfrc_rx_info ccid3hcrx_tfrc;
120#define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv
121#define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt
122#define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p
117 u64 ccid3hcrx_seqno_last_counter:48, 123 u64 ccid3hcrx_seqno_last_counter:48,
118 ccid3hcrx_state:8, 124 ccid3hcrx_state:8,
119 ccid3hcrx_last_counter:4; 125 ccid3hcrx_last_counter:4;
120 u32 ccid3hcrx_rtt;
121 u32 ccid3hcrx_p;
122 u32 ccid3hcrx_bytes_recv; 126 u32 ccid3hcrx_bytes_recv;
123 struct timeval ccid3hcrx_tstamp_last_feedback; 127 struct timeval ccid3hcrx_tstamp_last_feedback;
124 struct timeval ccid3hcrx_tstamp_last_ack; 128 struct timeval ccid3hcrx_tstamp_last_ack;
@@ -127,7 +131,6 @@ struct ccid3_hc_rx_sock {
127 u16 ccid3hcrx_s; 131 u16 ccid3hcrx_s;
128 u32 ccid3hcrx_pinv; 132 u32 ccid3hcrx_pinv;
129 u32 ccid3hcrx_elapsed_time; 133 u32 ccid3hcrx_elapsed_time;
130 u32 ccid3hcrx_x_recv;
131}; 134};
132 135
133static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 136static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h
index 13ad47ba1420..417d9d82df3e 100644
--- a/net/dccp/ccids/lib/loss_interval.h
+++ b/net/dccp/ccids/lib/loss_interval.h
@@ -36,7 +36,7 @@ struct dccp_li_hist_entry {
36 36
37static inline struct dccp_li_hist_entry * 37static inline struct dccp_li_hist_entry *
38 dccp_li_hist_entry_new(struct dccp_li_hist *hist, 38 dccp_li_hist_entry_new(struct dccp_li_hist *hist,
39 const unsigned int __nocast prio) 39 const gfp_t prio)
40{ 40{
41 return kmem_cache_alloc(hist->dccplih_slab, prio); 41 return kmem_cache_alloc(hist->dccplih_slab, prio);
42} 42}
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index b375ebdb7dcf..122e96737ff6 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -86,7 +86,7 @@ extern struct dccp_rx_hist_entry *
86 86
87static inline struct dccp_tx_hist_entry * 87static inline struct dccp_tx_hist_entry *
88 dccp_tx_hist_entry_new(struct dccp_tx_hist *hist, 88 dccp_tx_hist_entry_new(struct dccp_tx_hist *hist,
89 const unsigned int __nocast prio) 89 const gfp_t prio)
90{ 90{
91 struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab, 91 struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab,
92 prio); 92 prio);
@@ -137,7 +137,7 @@ static inline struct dccp_rx_hist_entry *
137 const struct sock *sk, 137 const struct sock *sk,
138 const u32 ndp, 138 const u32 ndp,
139 const struct sk_buff *skb, 139 const struct sk_buff *skb,
140 const unsigned int __nocast prio) 140 const gfp_t prio)
141{ 141{
142 struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab, 142 struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab,
143 prio); 143 prio);
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 95c4630b3b18..5871c027f9dc 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -17,6 +17,7 @@
17#include <net/snmp.h> 17#include <net/snmp.h>
18#include <net/sock.h> 18#include <net/sock.h>
19#include <net/tcp.h> 19#include <net/tcp.h>
20#include "ackvec.h"
20 21
21#ifdef CONFIG_IP_DCCP_DEBUG 22#ifdef CONFIG_IP_DCCP_DEBUG
22extern int dccp_debug; 23extern int dccp_debug;
@@ -258,13 +259,12 @@ extern int dccp_v4_send_reset(struct sock *sk,
258extern void dccp_send_close(struct sock *sk, const int active); 259extern void dccp_send_close(struct sock *sk, const int active);
259 260
260struct dccp_skb_cb { 261struct dccp_skb_cb {
261 __u8 dccpd_type; 262 __u8 dccpd_type:4;
262 __u8 dccpd_reset_code; 263 __u8 dccpd_ccval:4;
263 __u8 dccpd_service; 264 __u8 dccpd_reset_code;
264 __u8 dccpd_ccval; 265 __u16 dccpd_opt_len;
265 __u64 dccpd_seq; 266 __u64 dccpd_seq;
266 __u64 dccpd_ack_seq; 267 __u64 dccpd_ack_seq;
267 int dccpd_opt_len;
268}; 268};
269 269
270#define DCCP_SKB_CB(__skb) ((struct dccp_skb_cb *)&((__skb)->cb[0])) 270#define DCCP_SKB_CB(__skb) ((struct dccp_skb_cb *)&((__skb)->cb[0]))
@@ -359,6 +359,17 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
359 (dp->dccps_gss - 359 (dp->dccps_gss -
360 dp->dccps_options.dccpo_sequence_window + 1)); 360 dp->dccps_options.dccpo_sequence_window + 1));
361} 361}
362
363static inline int dccp_ack_pending(const struct sock *sk)
364{
365 const struct dccp_sock *dp = dccp_sk(sk);
366 return dp->dccps_timestamp_echo != 0 ||
367#ifdef CONFIG_IP_DCCP_ACKVEC
368 (dp->dccps_options.dccpo_send_ack_vector &&
369 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) ||
370#endif
371 inet_csk_ack_scheduled(sk);
372}
362 373
363extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb); 374extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb);
364extern void dccp_insert_option_elapsed_time(struct sock *sk, 375extern void dccp_insert_option_elapsed_time(struct sock *sk,
@@ -372,65 +383,6 @@ extern void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
372 383
373extern struct socket *dccp_ctl_socket; 384extern struct socket *dccp_ctl_socket;
374 385
375#define DCCP_ACKPKTS_STATE_RECEIVED 0
376#define DCCP_ACKPKTS_STATE_ECN_MARKED (1 << 6)
377#define DCCP_ACKPKTS_STATE_NOT_RECEIVED (3 << 6)
378
379#define DCCP_ACKPKTS_STATE_MASK 0xC0 /* 11000000 */
380#define DCCP_ACKPKTS_LEN_MASK 0x3F /* 00111111 */
381
382/** struct dccp_ackpkts - acknowledgeable packets
383 *
384 * This data structure is the one defined in the DCCP draft
385 * Appendix A.
386 *
387 * @dccpap_buf_head - circular buffer head
388 * @dccpap_buf_tail - circular buffer tail
389 * @dccpap_buf_ackno - ack # of the most recent packet acknowledgeable in the
390 * buffer (i.e. %dccpap_buf_head)
391 * @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
392 * by the buffer with State 0
393 *
394 * Additionally, the HC-Receiver must keep some information about the
395 * Ack Vectors it has recently sent. For each packet sent carrying an
396 * Ack Vector, it remembers four variables:
397 *
398 * @dccpap_ack_seqno - the Sequence Number used for the packet
399 * (HC-Receiver seqno)
400 * @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement.
401 * @dccpap_ack_ackno - the Acknowledgement Number used for the packet
402 * (HC-Sender seqno)
403 * @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
404 *
405 * @dccpap_buf_len - circular buffer length
406 * @dccpap_time - the time in usecs
407 * @dccpap_buf - circular buffer of acknowledgeable packets
408 */
409struct dccp_ackpkts {
410 unsigned int dccpap_buf_head;
411 unsigned int dccpap_buf_tail;
412 u64 dccpap_buf_ackno;
413 u64 dccpap_ack_seqno;
414 u64 dccpap_ack_ackno;
415 unsigned int dccpap_ack_ptr;
416 unsigned int dccpap_buf_vector_len;
417 unsigned int dccpap_ack_vector_len;
418 unsigned int dccpap_buf_len;
419 struct timeval dccpap_time;
420 u8 dccpap_buf_nonce;
421 u8 dccpap_ack_nonce;
422 u8 dccpap_buf[0];
423};
424
425extern struct dccp_ackpkts *
426 dccp_ackpkts_alloc(unsigned int len,
427 const unsigned int __nocast priority);
428extern void dccp_ackpkts_free(struct dccp_ackpkts *ap);
429extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk,
430 u64 ackno, u8 state);
431extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap,
432 struct sock *sk, u64 ackno);
433
434extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); 386extern void dccp_timestamp(const struct sock *sk, struct timeval *tv);
435 387
436static inline suseconds_t timeval_usecs(const struct timeval *tv) 388static inline suseconds_t timeval_usecs(const struct timeval *tv)
@@ -471,15 +423,4 @@ static inline void timeval_sub_usecs(struct timeval *tv,
471 } 423 }
472} 424}
473 425
474#ifdef CONFIG_IP_DCCP_DEBUG
475extern void dccp_ackvector_print(const u64 ackno,
476 const unsigned char *vector, int len);
477extern void dccp_ackpkts_print(const struct dccp_ackpkts *ap);
478#else
479static inline void dccp_ackvector_print(const u64 ackno,
480 const unsigned char *vector,
481 int len) { }
482static inline void dccp_ackpkts_print(const struct dccp_ackpkts *ap) { }
483#endif
484
485#endif /* _DCCP_H */ 426#endif /* _DCCP_H */
diff --git a/net/dccp/input.c b/net/dccp/input.c
index c74034cf7ede..3454d5941900 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -16,6 +16,7 @@
16 16
17#include <net/sock.h> 17#include <net/sock.h>
18 18
19#include "ackvec.h"
19#include "ccid.h" 20#include "ccid.h"
20#include "dccp.h" 21#include "dccp.h"
21 22
@@ -60,8 +61,8 @@ static inline void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb)
60 struct dccp_sock *dp = dccp_sk(sk); 61 struct dccp_sock *dp = dccp_sk(sk);
61 62
62 if (dp->dccps_options.dccpo_send_ack_vector) 63 if (dp->dccps_options.dccpo_send_ack_vector)
63 dccp_ackpkts_check_rcv_ackno(dp->dccps_hc_rx_ackpkts, sk, 64 dccp_ackvec_check_rcv_ackno(dp->dccps_hc_rx_ackvec, sk,
64 DCCP_SKB_CB(skb)->dccpd_ack_seq); 65 DCCP_SKB_CB(skb)->dccpd_ack_seq);
65} 66}
66 67
67static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) 68static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
@@ -164,37 +165,11 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
164 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 165 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
165 dccp_event_ack_recv(sk, skb); 166 dccp_event_ack_recv(sk, skb);
166 167
167 /* 168 if (dp->dccps_options.dccpo_send_ack_vector &&
168 * FIXME: check ECN to see if we should use 169 dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
169 * DCCP_ACKPKTS_STATE_ECN_MARKED 170 DCCP_SKB_CB(skb)->dccpd_seq,
170 */ 171 DCCP_ACKVEC_STATE_RECEIVED))
171 if (dp->dccps_options.dccpo_send_ack_vector) { 172 goto discard;
172 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
173
174 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk,
175 DCCP_SKB_CB(skb)->dccpd_seq,
176 DCCP_ACKPKTS_STATE_RECEIVED)) {
177 LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable "
178 "packets buffer full!\n");
179 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
180 inet_csk_schedule_ack(sk);
181 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
182 TCP_DELACK_MIN,
183 DCCP_RTO_MAX);
184 goto discard;
185 }
186
187 /*
188 * FIXME: this activation is probably wrong, have to study more
189 * TCP delack machinery and how it fits into DCCP draft, but
190 * for now it kinda "works" 8)
191 */
192 if (!inet_csk_ack_scheduled(sk)) {
193 inet_csk_schedule_ack(sk);
194 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5 * HZ,
195 DCCP_RTO_MAX);
196 }
197 }
198 173
199 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); 174 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
200 ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); 175 ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
@@ -384,9 +359,9 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
384 } 359 }
385 360
386out_invalid_packet: 361out_invalid_packet:
387 return 1; /* dccp_v4_do_rcv will send a reset, but... 362 /* dccp_v4_do_rcv will send a reset */
388 FIXME: the reset code should be 363 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_PACKET_ERROR;
389 DCCP_RESET_CODE_PACKET_ERROR */ 364 return 1;
390} 365}
391 366
392static int dccp_rcv_respond_partopen_state_process(struct sock *sk, 367static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
@@ -400,6 +375,9 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
400 case DCCP_PKT_RESET: 375 case DCCP_PKT_RESET:
401 inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); 376 inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
402 break; 377 break;
378 case DCCP_PKT_DATA:
379 if (sk->sk_state == DCCP_RESPOND)
380 break;
403 case DCCP_PKT_DATAACK: 381 case DCCP_PKT_DATAACK:
404 case DCCP_PKT_ACK: 382 case DCCP_PKT_ACK:
405 /* 383 /*
@@ -418,7 +396,8 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
418 dccp_sk(sk)->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq; 396 dccp_sk(sk)->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq;
419 dccp_set_state(sk, DCCP_OPEN); 397 dccp_set_state(sk, DCCP_OPEN);
420 398
421 if (dh->dccph_type == DCCP_PKT_DATAACK) { 399 if (dh->dccph_type == DCCP_PKT_DATAACK ||
400 dh->dccph_type == DCCP_PKT_DATA) {
422 dccp_rcv_established(sk, skb, dh, len); 401 dccp_rcv_established(sk, skb, dh, len);
423 queued = 1; /* packet was queued 402 queued = 1; /* packet was queued
424 (by dccp_rcv_established) */ 403 (by dccp_rcv_established) */
@@ -433,6 +412,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
433 struct dccp_hdr *dh, unsigned len) 412 struct dccp_hdr *dh, unsigned len)
434{ 413{
435 struct dccp_sock *dp = dccp_sk(sk); 414 struct dccp_sock *dp = dccp_sk(sk);
415 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
436 const int old_state = sk->sk_state; 416 const int old_state = sk->sk_state;
437 int queued = 0; 417 int queued = 0;
438 418
@@ -473,7 +453,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
473 if (dh->dccph_type == DCCP_PKT_RESET) 453 if (dh->dccph_type == DCCP_PKT_RESET)
474 goto discard; 454 goto discard;
475 455
476 /* Caller (dccp_v4_do_rcv) will send Reset(No Connection)*/ 456 /* Caller (dccp_v4_do_rcv) will send Reset */
457 dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
477 return 1; 458 return 1;
478 } 459 }
479 460
@@ -487,36 +468,17 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
487 if (dccp_parse_options(sk, skb)) 468 if (dccp_parse_options(sk, skb))
488 goto discard; 469 goto discard;
489 470
490 if (DCCP_SKB_CB(skb)->dccpd_ack_seq != 471 if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
491 DCCP_PKT_WITHOUT_ACK_SEQ)
492 dccp_event_ack_recv(sk, skb); 472 dccp_event_ack_recv(sk, skb);
493 473
494 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); 474 ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
495 ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); 475 ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
496 476
497 /* 477 if (dp->dccps_options.dccpo_send_ack_vector &&
498 * FIXME: check ECN to see if we should use 478 dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
499 * DCCP_ACKPKTS_STATE_ECN_MARKED 479 DCCP_SKB_CB(skb)->dccpd_seq,
500 */ 480 DCCP_ACKVEC_STATE_RECEIVED))
501 if (dp->dccps_options.dccpo_send_ack_vector) { 481 goto discard;
502 if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk,
503 DCCP_SKB_CB(skb)->dccpd_seq,
504 DCCP_ACKPKTS_STATE_RECEIVED))
505 goto discard;
506 /*
507 * FIXME: this activation is probably wrong, have to
508 * study more TCP delack machinery and how it fits into
509 * DCCP draft, but for now it kinda "works" 8)
510 */
511 if ((dp->dccps_hc_rx_ackpkts->dccpap_ack_seqno ==
512 DCCP_MAX_SEQNO + 1) &&
513 !inet_csk_ack_scheduled(sk)) {
514 inet_csk_schedule_ack(sk);
515 inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
516 TCP_DELACK_MIN,
517 DCCP_RTO_MAX);
518 }
519 }
520 } 482 }
521 483
522 /* 484 /*
@@ -551,8 +513,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
551 dh->dccph_type == DCCP_PKT_REQUEST) || 513 dh->dccph_type == DCCP_PKT_REQUEST) ||
552 (sk->sk_state == DCCP_RESPOND && 514 (sk->sk_state == DCCP_RESPOND &&
553 dh->dccph_type == DCCP_PKT_DATA)) { 515 dh->dccph_type == DCCP_PKT_DATA)) {
554 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, 516 dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC);
555 DCCP_PKT_SYNC);
556 goto discard; 517 goto discard;
557 } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) { 518 } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) {
558 dccp_rcv_closereq(sk, skb); 519 dccp_rcv_closereq(sk, skb);
@@ -563,13 +524,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
563 } 524 }
564 525
565 if (unlikely(dh->dccph_type == DCCP_PKT_SYNC)) { 526 if (unlikely(dh->dccph_type == DCCP_PKT_SYNC)) {
566 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, 527 dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNCACK);
567 DCCP_PKT_SYNCACK);
568 goto discard; 528 goto discard;
569 } 529 }
570 530
571 switch (sk->sk_state) { 531 switch (sk->sk_state) {
572 case DCCP_CLOSED: 532 case DCCP_CLOSED:
533 dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
573 return 1; 534 return 1;
574 535
575 case DCCP_REQUESTING: 536 case DCCP_REQUESTING:
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 2afaa464e7f0..6298cf58ff9e 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -23,6 +23,7 @@
23#include <net/tcp_states.h> 23#include <net/tcp_states.h>
24#include <net/xfrm.h> 24#include <net/xfrm.h>
25 25
26#include "ackvec.h"
26#include "ccid.h" 27#include "ccid.h"
27#include "dccp.h" 28#include "dccp.h"
28 29
@@ -61,27 +62,27 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
61 const int dif = sk->sk_bound_dev_if; 62 const int dif = sk->sk_bound_dev_if;
62 INET_ADDR_COOKIE(acookie, saddr, daddr) 63 INET_ADDR_COOKIE(acookie, saddr, daddr)
63 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); 64 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
64 const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, 65 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
65 dccp_hashinfo.ehash_size); 66 struct inet_ehash_bucket *head = inet_ehash_bucket(&dccp_hashinfo, hash);
66 struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash];
67 const struct sock *sk2; 67 const struct sock *sk2;
68 const struct hlist_node *node; 68 const struct hlist_node *node;
69 struct inet_timewait_sock *tw; 69 struct inet_timewait_sock *tw;
70 70
71 prefetch(head->chain.first);
71 write_lock(&head->lock); 72 write_lock(&head->lock);
72 73
73 /* Check TIME-WAIT sockets first. */ 74 /* Check TIME-WAIT sockets first. */
74 sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) { 75 sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) {
75 tw = inet_twsk(sk2); 76 tw = inet_twsk(sk2);
76 77
77 if (INET_TW_MATCH(sk2, acookie, saddr, daddr, ports, dif)) 78 if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif))
78 goto not_unique; 79 goto not_unique;
79 } 80 }
80 tw = NULL; 81 tw = NULL;
81 82
82 /* And established part... */ 83 /* And established part... */
83 sk_for_each(sk2, node, &head->chain) { 84 sk_for_each(sk2, node, &head->chain) {
84 if (INET_MATCH(sk2, acookie, saddr, daddr, ports, dif)) 85 if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif))
85 goto not_unique; 86 goto not_unique;
86 } 87 }
87 88
@@ -89,7 +90,7 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
89 * in hash table socket with a funny identity. */ 90 * in hash table socket with a funny identity. */
90 inet->num = lport; 91 inet->num = lport;
91 inet->sport = htons(lport); 92 inet->sport = htons(lport);
92 sk->sk_hashent = hash; 93 sk->sk_hash = hash;
93 BUG_TRAP(sk_unhashed(sk)); 94 BUG_TRAP(sk_unhashed(sk));
94 __sk_add_node(sk, &head->chain); 95 __sk_add_node(sk, &head->chain);
95 sock_prot_inc_use(sk->sk_prot); 96 sock_prot_inc_use(sk->sk_prot);
@@ -246,6 +247,9 @@ static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
246 247
247 dp->dccps_role = DCCP_ROLE_CLIENT; 248 dp->dccps_role = DCCP_ROLE_CLIENT;
248 249
250 if (dccp_service_not_initialized(sk))
251 return -EPROTO;
252
249 if (addr_len < sizeof(struct sockaddr_in)) 253 if (addr_len < sizeof(struct sockaddr_in))
250 return -EINVAL; 254 return -EINVAL;
251 255
@@ -459,6 +463,7 @@ static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
459 if (skb != NULL) { 463 if (skb != NULL) {
460 const struct inet_request_sock *ireq = inet_rsk(req); 464 const struct inet_request_sock *ireq = inet_rsk(req);
461 465
466 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
462 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr, 467 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
463 ireq->rmt_addr, 468 ireq->rmt_addr,
464 ireq->opt); 469 ireq->opt);
@@ -643,6 +648,7 @@ int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code)
643 if (skb != NULL) { 648 if (skb != NULL) {
644 const struct inet_sock *inet = inet_sk(sk); 649 const struct inet_sock *inet = inet_sk(sk);
645 650
651 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
646 err = ip_build_and_send_pkt(skb, sk, 652 err = ip_build_and_send_pkt(skb, sk,
647 inet->saddr, inet->daddr, NULL); 653 inet->saddr, inet->daddr, NULL);
648 if (err == NET_XMIT_CN) 654 if (err == NET_XMIT_CN)
@@ -661,6 +667,16 @@ static inline u64 dccp_v4_init_sequence(const struct sock *sk,
661 dccp_hdr(skb)->dccph_sport); 667 dccp_hdr(skb)->dccph_sport);
662} 668}
663 669
670static inline int dccp_bad_service_code(const struct sock *sk,
671 const __u32 service)
672{
673 const struct dccp_sock *dp = dccp_sk(sk);
674
675 if (dp->dccps_service == service)
676 return 0;
677 return !dccp_list_has_service(dp->dccps_service_list, service);
678}
679
664int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) 680int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
665{ 681{
666 struct inet_request_sock *ireq; 682 struct inet_request_sock *ireq;
@@ -669,13 +685,22 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
669 struct dccp_request_sock *dreq; 685 struct dccp_request_sock *dreq;
670 const __u32 saddr = skb->nh.iph->saddr; 686 const __u32 saddr = skb->nh.iph->saddr;
671 const __u32 daddr = skb->nh.iph->daddr; 687 const __u32 daddr = skb->nh.iph->daddr;
688 const __u32 service = dccp_hdr_request(skb)->dccph_req_service;
689 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
690 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
672 struct dst_entry *dst = NULL; 691 struct dst_entry *dst = NULL;
673 692
674 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */ 693 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
675 if (((struct rtable *)skb->dst)->rt_flags & 694 if (((struct rtable *)skb->dst)->rt_flags &
676 (RTCF_BROADCAST | RTCF_MULTICAST)) 695 (RTCF_BROADCAST | RTCF_MULTICAST)) {
696 reset_code = DCCP_RESET_CODE_NO_CONNECTION;
677 goto drop; 697 goto drop;
698 }
678 699
700 if (dccp_bad_service_code(sk, service)) {
701 reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
702 goto drop;
703 }
679 /* 704 /*
680 * TW buckets are converted to open requests without 705 * TW buckets are converted to open requests without
681 * limitations, they conserve resources and peer is 706 * limitations, they conserve resources and peer is
@@ -718,9 +743,9 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
718 * dccp_create_openreq_child. 743 * dccp_create_openreq_child.
719 */ 744 */
720 dreq = dccp_rsk(req); 745 dreq = dccp_rsk(req);
721 dreq->dreq_isr = DCCP_SKB_CB(skb)->dccpd_seq; 746 dreq->dreq_isr = dcb->dccpd_seq;
722 dreq->dreq_iss = dccp_v4_init_sequence(sk, skb); 747 dreq->dreq_iss = dccp_v4_init_sequence(sk, skb);
723 dreq->dreq_service = dccp_hdr_request(skb)->dccph_req_service; 748 dreq->dreq_service = service;
724 749
725 if (dccp_v4_send_response(sk, req, dst)) 750 if (dccp_v4_send_response(sk, req, dst))
726 goto drop_and_free; 751 goto drop_and_free;
@@ -735,6 +760,7 @@ drop_and_free:
735 __reqsk_free(req); 760 __reqsk_free(req);
736drop: 761drop:
737 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS); 762 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
763 dcb->dccpd_reset_code = reset_code;
738 return -1; 764 return -1;
739} 765}
740 766
@@ -1005,7 +1031,6 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
1005 return 0; 1031 return 0;
1006 1032
1007reset: 1033reset:
1008 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
1009 dccp_v4_ctl_send_reset(skb); 1034 dccp_v4_ctl_send_reset(skb);
1010discard: 1035discard:
1011 kfree_skb(skb); 1036 kfree_skb(skb);
@@ -1090,45 +1115,7 @@ int dccp_v4_rcv(struct sk_buff *skb)
1090 goto discard_it; 1115 goto discard_it;
1091 1116
1092 dh = dccp_hdr(skb); 1117 dh = dccp_hdr(skb);
1093#if 0
1094 /*
1095 * Use something like this to simulate some DATA/DATAACK loss to test
1096 * dccp_ackpkts_add, you'll get something like this on a session that
1097 * sends 10 DATA/DATAACK packets:
1098 *
1099 * ackpkts_print: 281473596467422 |0,0|3,0|0,0|3,0|0,0|3,0|0,0|3,0|0,1|
1100 *
1101 * 0, 0 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == just this packet
1102 * 0, 1 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == two adjacent packets
1103 * with the same state
1104 * 3, 0 means: DCCP_ACKPKTS_STATE_NOT_RECEIVED, RLE == just this packet
1105 *
1106 * So...
1107 *
1108 * 281473596467422 was received
1109 * 281473596467421 was not received
1110 * 281473596467420 was received
1111 * 281473596467419 was not received
1112 * 281473596467418 was received
1113 * 281473596467417 was not received
1114 * 281473596467416 was received
1115 * 281473596467415 was not received
1116 * 281473596467414 was received
1117 * 281473596467413 was received (this one was the 3way handshake
1118 * RESPONSE)
1119 *
1120 */
1121 if (dh->dccph_type == DCCP_PKT_DATA ||
1122 dh->dccph_type == DCCP_PKT_DATAACK) {
1123 static int discard = 0;
1124 1118
1125 if (discard) {
1126 discard = 0;
1127 goto discard_it;
1128 }
1129 discard = 1;
1130 }
1131#endif
1132 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb); 1119 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
1133 DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; 1120 DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
1134 1121
@@ -1242,11 +1229,9 @@ static int dccp_v4_init_sock(struct sock *sk)
1242 do_gettimeofday(&dp->dccps_epoch); 1229 do_gettimeofday(&dp->dccps_epoch);
1243 1230
1244 if (dp->dccps_options.dccpo_send_ack_vector) { 1231 if (dp->dccps_options.dccpo_send_ack_vector) {
1245 dp->dccps_hc_rx_ackpkts = 1232 dp->dccps_hc_rx_ackvec = dccp_ackvec_alloc(DCCP_MAX_ACKVEC_LEN,
1246 dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN, 1233 GFP_KERNEL);
1247 GFP_KERNEL); 1234 if (dp->dccps_hc_rx_ackvec == NULL)
1248
1249 if (dp->dccps_hc_rx_ackpkts == NULL)
1250 return -ENOMEM; 1235 return -ENOMEM;
1251 } 1236 }
1252 1237
@@ -1258,16 +1243,18 @@ static int dccp_v4_init_sock(struct sock *sk)
1258 * setsockopt(CCIDs-I-want/accept). -acme 1243 * setsockopt(CCIDs-I-want/accept). -acme
1259 */ 1244 */
1260 if (likely(!dccp_ctl_socket_init)) { 1245 if (likely(!dccp_ctl_socket_init)) {
1261 dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, 1246 dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_rx_ccid,
1262 sk); 1247 sk);
1263 dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, 1248 dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_tx_ccid,
1264 sk); 1249 sk);
1265 if (dp->dccps_hc_rx_ccid == NULL || 1250 if (dp->dccps_hc_rx_ccid == NULL ||
1266 dp->dccps_hc_tx_ccid == NULL) { 1251 dp->dccps_hc_tx_ccid == NULL) {
1267 ccid_exit(dp->dccps_hc_rx_ccid, sk); 1252 ccid_exit(dp->dccps_hc_rx_ccid, sk);
1268 ccid_exit(dp->dccps_hc_tx_ccid, sk); 1253 ccid_exit(dp->dccps_hc_tx_ccid, sk);
1269 dccp_ackpkts_free(dp->dccps_hc_rx_ackpkts); 1254 if (dp->dccps_options.dccpo_send_ack_vector) {
1270 dp->dccps_hc_rx_ackpkts = NULL; 1255 dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
1256 dp->dccps_hc_rx_ackvec = NULL;
1257 }
1271 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; 1258 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
1272 return -ENOMEM; 1259 return -ENOMEM;
1273 } 1260 }
@@ -1280,6 +1267,7 @@ static int dccp_v4_init_sock(struct sock *sk)
1280 sk->sk_write_space = dccp_write_space; 1267 sk->sk_write_space = dccp_write_space;
1281 dp->dccps_mss_cache = 536; 1268 dp->dccps_mss_cache = 536;
1282 dp->dccps_role = DCCP_ROLE_UNDEFINED; 1269 dp->dccps_role = DCCP_ROLE_UNDEFINED;
1270 dp->dccps_service = DCCP_SERVICE_INVALID_VALUE;
1283 1271
1284 return 0; 1272 return 0;
1285} 1273}
@@ -1301,10 +1289,17 @@ static int dccp_v4_destroy_sock(struct sock *sk)
1301 if (inet_csk(sk)->icsk_bind_hash != NULL) 1289 if (inet_csk(sk)->icsk_bind_hash != NULL)
1302 inet_put_port(&dccp_hashinfo, sk); 1290 inet_put_port(&dccp_hashinfo, sk);
1303 1291
1292 if (dp->dccps_service_list != NULL) {
1293 kfree(dp->dccps_service_list);
1294 dp->dccps_service_list = NULL;
1295 }
1296
1304 ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk); 1297 ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
1305 ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk); 1298 ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
1306 dccp_ackpkts_free(dp->dccps_hc_rx_ackpkts); 1299 if (dp->dccps_options.dccpo_send_ack_vector) {
1307 dp->dccps_hc_rx_ackpkts = NULL; 1300 dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
1301 dp->dccps_hc_rx_ackvec = NULL;
1302 }
1308 ccid_exit(dp->dccps_hc_rx_ccid, sk); 1303 ccid_exit(dp->dccps_hc_rx_ccid, sk);
1309 ccid_exit(dp->dccps_hc_tx_ccid, sk); 1304 ccid_exit(dp->dccps_hc_tx_ccid, sk);
1310 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; 1305 dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 18461bc04cbe..1393461898bb 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -19,6 +19,7 @@
19#include <net/xfrm.h> 19#include <net/xfrm.h>
20#include <net/inet_timewait_sock.h> 20#include <net/inet_timewait_sock.h>
21 21
22#include "ackvec.h"
22#include "ccid.h" 23#include "ccid.h"
23#include "dccp.h" 24#include "dccp.h"
24 25
@@ -93,22 +94,24 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
93 struct inet_connection_sock *newicsk = inet_csk(sk); 94 struct inet_connection_sock *newicsk = inet_csk(sk);
94 struct dccp_sock *newdp = dccp_sk(newsk); 95 struct dccp_sock *newdp = dccp_sk(newsk);
95 96
96 newdp->dccps_hc_rx_ackpkts = NULL; 97 newdp->dccps_role = DCCP_ROLE_SERVER;
97 newdp->dccps_role = DCCP_ROLE_SERVER; 98 newdp->dccps_hc_rx_ackvec = NULL;
98 newicsk->icsk_rto = DCCP_TIMEOUT_INIT; 99 newdp->dccps_service_list = NULL;
100 newdp->dccps_service = dreq->dreq_service;
101 newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
99 do_gettimeofday(&newdp->dccps_epoch); 102 do_gettimeofday(&newdp->dccps_epoch);
100 103
101 if (newdp->dccps_options.dccpo_send_ack_vector) { 104 if (newdp->dccps_options.dccpo_send_ack_vector) {
102 newdp->dccps_hc_rx_ackpkts = 105 newdp->dccps_hc_rx_ackvec =
103 dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN, 106 dccp_ackvec_alloc(DCCP_MAX_ACKVEC_LEN,
104 GFP_ATOMIC); 107 GFP_ATOMIC);
105 /* 108 /*
106 * XXX: We're using the same CCIDs set on the parent, 109 * XXX: We're using the same CCIDs set on the parent,
107 * i.e. sk_clone copied the master sock and left the 110 * i.e. sk_clone copied the master sock and left the
108 * CCID pointers for this child, that is why we do the 111 * CCID pointers for this child, that is why we do the
109 * __ccid_get calls. 112 * __ccid_get calls.
110 */ 113 */
111 if (unlikely(newdp->dccps_hc_rx_ackpkts == NULL)) 114 if (unlikely(newdp->dccps_hc_rx_ackvec == NULL))
112 goto out_free; 115 goto out_free;
113 } 116 }
114 117
@@ -116,7 +119,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
116 newsk) != 0 || 119 newsk) != 0 ||
117 ccid_hc_tx_init(newdp->dccps_hc_tx_ccid, 120 ccid_hc_tx_init(newdp->dccps_hc_tx_ccid,
118 newsk) != 0)) { 121 newsk) != 0)) {
119 dccp_ackpkts_free(newdp->dccps_hc_rx_ackpkts); 122 dccp_ackvec_free(newdp->dccps_hc_rx_ackvec);
120 ccid_hc_rx_exit(newdp->dccps_hc_rx_ccid, newsk); 123 ccid_hc_rx_exit(newdp->dccps_hc_rx_ccid, newsk);
121 ccid_hc_tx_exit(newdp->dccps_hc_tx_ccid, newsk); 124 ccid_hc_tx_exit(newdp->dccps_hc_tx_ccid, newsk);
122out_free: 125out_free:
diff --git a/net/dccp/options.c b/net/dccp/options.c
index d4c4242d8dd7..0a76426c9aea 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -18,19 +18,15 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/skbuff.h> 19#include <linux/skbuff.h>
20 20
21#include "ackvec.h"
21#include "ccid.h" 22#include "ccid.h"
22#include "dccp.h" 23#include "dccp.h"
23 24
24static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
25 struct sock *sk,
26 const u64 ackno,
27 const unsigned char len,
28 const unsigned char *vector);
29
30/* stores the default values for new connection. may be changed with sysctl */ 25/* stores the default values for new connection. may be changed with sysctl */
31static const struct dccp_options dccpo_default_values = { 26static const struct dccp_options dccpo_default_values = {
32 .dccpo_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW, 27 .dccpo_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW,
33 .dccpo_ccid = DCCPF_INITIAL_CCID, 28 .dccpo_rx_ccid = DCCPF_INITIAL_CCID,
29 .dccpo_tx_ccid = DCCPF_INITIAL_CCID,
34 .dccpo_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR, 30 .dccpo_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR,
35 .dccpo_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT, 31 .dccpo_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT,
36}; 32};
@@ -113,25 +109,13 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
113 opt_recv->dccpor_ndp); 109 opt_recv->dccpor_ndp);
114 break; 110 break;
115 case DCCPO_ACK_VECTOR_0: 111 case DCCPO_ACK_VECTOR_0:
116 if (len > DCCP_MAX_ACK_VECTOR_LEN) 112 case DCCPO_ACK_VECTOR_1:
117 goto out_invalid_option;
118
119 if (pkt_type == DCCP_PKT_DATA) 113 if (pkt_type == DCCP_PKT_DATA)
120 continue; 114 continue;
121 115
122 opt_recv->dccpor_ack_vector_len = len; 116 if (dp->dccps_options.dccpo_send_ack_vector &&
123 opt_recv->dccpor_ack_vector_idx = value - options; 117 dccp_ackvec_parse(sk, skb, opt, value, len))
124 118 goto out_invalid_option;
125 dccp_pr_debug("%sACK vector 0, len=%d, ack_ackno=%llu\n",
126 debug_prefix, len,
127 (unsigned long long)
128 DCCP_SKB_CB(skb)->dccpd_ack_seq);
129 dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq,
130 value, len);
131 dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts,
132 sk,
133 DCCP_SKB_CB(skb)->dccpd_ack_seq,
134 len, value);
135 break; 119 break;
136 case DCCPO_TIMESTAMP: 120 case DCCPO_TIMESTAMP:
137 if (len != 4) 121 if (len != 4)
@@ -352,86 +336,6 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
352 336
353EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time); 337EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
354 338
355static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
356{
357 struct dccp_sock *dp = dccp_sk(sk);
358#ifdef CONFIG_IP_DCCP_DEBUG
359 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
360 "CLIENT TX opt: " : "server TX opt: ";
361#endif
362 struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
363 int len = ap->dccpap_buf_vector_len + 2;
364 struct timeval now;
365 u32 elapsed_time;
366 unsigned char *to, *from;
367
368 dccp_timestamp(sk, &now);
369 elapsed_time = timeval_delta(&now, &ap->dccpap_time) / 10;
370
371 if (elapsed_time != 0)
372 dccp_insert_option_elapsed_time(sk, skb, elapsed_time);
373
374 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
375 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
376 "insert ACK Vector!\n");
377 return;
378 }
379
380 /*
381 * XXX: now we have just one ack vector sent record, so
382 * we have to wait for it to be cleared.
383 *
384 * Of course this is not acceptable, but this is just for
385 * basic testing now.
386 */
387 if (ap->dccpap_ack_seqno != DCCP_MAX_SEQNO + 1)
388 return;
389
390 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
391
392 to = skb_push(skb, len);
393 *to++ = DCCPO_ACK_VECTOR_0;
394 *to++ = len;
395
396 len = ap->dccpap_buf_vector_len;
397 from = ap->dccpap_buf + ap->dccpap_buf_head;
398
399 /* Check if buf_head wraps */
400 if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) {
401 const unsigned int tailsize = (ap->dccpap_buf_len -
402 ap->dccpap_buf_head);
403
404 memcpy(to, from, tailsize);
405 to += tailsize;
406 len -= tailsize;
407 from = ap->dccpap_buf;
408 }
409
410 memcpy(to, from, len);
411 /*
412 * From draft-ietf-dccp-spec-11.txt:
413 *
414 * For each acknowledgement it sends, the HC-Receiver will add an
415 * acknowledgement record. ack_seqno will equal the HC-Receiver
416 * sequence number it used for the ack packet; ack_ptr will equal
417 * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will
418 * equal buf_nonce.
419 *
420 * This implemention uses just one ack record for now.
421 */
422 ap->dccpap_ack_seqno = DCCP_SKB_CB(skb)->dccpd_seq;
423 ap->dccpap_ack_ptr = ap->dccpap_buf_head;
424 ap->dccpap_ack_ackno = ap->dccpap_buf_ackno;
425 ap->dccpap_ack_nonce = ap->dccpap_buf_nonce;
426 ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len;
427
428 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, "
429 "ack_ackno=%llu\n",
430 debug_prefix, ap->dccpap_ack_vector_len,
431 (unsigned long long) ap->dccpap_ack_seqno,
432 (unsigned long long) ap->dccpap_ack_ackno);
433}
434
435void dccp_timestamp(const struct sock *sk, struct timeval *tv) 339void dccp_timestamp(const struct sock *sk, struct timeval *tv)
436{ 340{
437 const struct dccp_sock *dp = dccp_sk(sk); 341 const struct dccp_sock *dp = dccp_sk(sk);
@@ -528,9 +432,8 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
528 432
529 if (!dccp_packet_without_ack(skb)) { 433 if (!dccp_packet_without_ack(skb)) {
530 if (dp->dccps_options.dccpo_send_ack_vector && 434 if (dp->dccps_options.dccpo_send_ack_vector &&
531 (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != 435 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec))
532 DCCP_MAX_SEQNO + 1)) 436 dccp_insert_option_ackvec(sk, skb);
533 dccp_insert_option_ack_vector(sk, skb);
534 if (dp->dccps_timestamp_echo != 0) 437 if (dp->dccps_timestamp_echo != 0)
535 dccp_insert_option_timestamp_echo(sk, skb); 438 dccp_insert_option_timestamp_echo(sk, skb);
536 } 439 }
@@ -557,331 +460,3 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
557 } 460 }
558 } 461 }
559} 462}
560
561struct dccp_ackpkts *dccp_ackpkts_alloc(const unsigned int len,
562 const unsigned int __nocast priority)
563{
564 struct dccp_ackpkts *ap = kmalloc(sizeof(*ap) + len, priority);
565
566 if (ap != NULL) {
567#ifdef CONFIG_IP_DCCP_DEBUG
568 memset(ap->dccpap_buf, 0xFF, len);
569#endif
570 ap->dccpap_buf_len = len;
571 ap->dccpap_buf_head =
572 ap->dccpap_buf_tail =
573 ap->dccpap_buf_len - 1;
574 ap->dccpap_buf_ackno =
575 ap->dccpap_ack_ackno =
576 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
577 ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0;
578 ap->dccpap_ack_ptr = 0;
579 ap->dccpap_time.tv_sec = 0;
580 ap->dccpap_time.tv_usec = 0;
581 ap->dccpap_buf_vector_len = ap->dccpap_ack_vector_len = 0;
582 }
583
584 return ap;
585}
586
587void dccp_ackpkts_free(struct dccp_ackpkts *ap)
588{
589 if (ap != NULL) {
590#ifdef CONFIG_IP_DCCP_DEBUG
591 memset(ap, 0xFF, sizeof(*ap) + ap->dccpap_buf_len);
592#endif
593 kfree(ap);
594 }
595}
596
597static inline u8 dccp_ackpkts_state(const struct dccp_ackpkts *ap,
598 const unsigned int index)
599{
600 return ap->dccpap_buf[index] & DCCP_ACKPKTS_STATE_MASK;
601}
602
603static inline u8 dccp_ackpkts_len(const struct dccp_ackpkts *ap,
604 const unsigned int index)
605{
606 return ap->dccpap_buf[index] & DCCP_ACKPKTS_LEN_MASK;
607}
608
609/*
610 * If several packets are missing, the HC-Receiver may prefer to enter multiple
611 * bytes with run length 0, rather than a single byte with a larger run length;
612 * this simplifies table updates if one of the missing packets arrives.
613 */
614static inline int dccp_ackpkts_set_buf_head_state(struct dccp_ackpkts *ap,
615 const unsigned int packets,
616 const unsigned char state)
617{
618 unsigned int gap;
619 signed long new_head;
620
621 if (ap->dccpap_buf_vector_len + packets > ap->dccpap_buf_len)
622 return -ENOBUFS;
623
624 gap = packets - 1;
625 new_head = ap->dccpap_buf_head - packets;
626
627 if (new_head < 0) {
628 if (gap > 0) {
629 memset(ap->dccpap_buf, DCCP_ACKPKTS_STATE_NOT_RECEIVED,
630 gap + new_head + 1);
631 gap = -new_head;
632 }
633 new_head += ap->dccpap_buf_len;
634 }
635
636 ap->dccpap_buf_head = new_head;
637
638 if (gap > 0)
639 memset(ap->dccpap_buf + ap->dccpap_buf_head + 1,
640 DCCP_ACKPKTS_STATE_NOT_RECEIVED, gap);
641
642 ap->dccpap_buf[ap->dccpap_buf_head] = state;
643 ap->dccpap_buf_vector_len += packets;
644 return 0;
645}
646
647/*
648 * Implements the draft-ietf-dccp-spec-11.txt Appendix A
649 */
650int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk,
651 u64 ackno, u8 state)
652{
653 /*
654 * Check at the right places if the buffer is full, if it is, tell the
655 * caller to start dropping packets till the HC-Sender acks our ACK
656 * vectors, when we will free up space in dccpap_buf.
657 *
658 * We may well decide to do buffer compression, etc, but for now lets
659 * just drop.
660 *
661 * From Appendix A:
662 *
663 * Of course, the circular buffer may overflow, either when the
664 * HC-Sender is sending data at a very high rate, when the
665 * HC-Receiver's acknowledgements are not reaching the HC-Sender,
666 * or when the HC-Sender is forgetting to acknowledge those acks
667 * (so the HC-Receiver is unable to clean up old state). In this
668 * case, the HC-Receiver should either compress the buffer (by
669 * increasing run lengths when possible), transfer its state to
670 * a larger buffer, or, as a last resort, drop all received
671 * packets, without processing them whatsoever, until its buffer
672 * shrinks again.
673 */
674
675 /* See if this is the first ackno being inserted */
676 if (ap->dccpap_buf_vector_len == 0) {
677 ap->dccpap_buf[ap->dccpap_buf_head] = state;
678 ap->dccpap_buf_vector_len = 1;
679 } else if (after48(ackno, ap->dccpap_buf_ackno)) {
680 const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno,
681 ackno);
682
683 /*
684 * Look if the state of this packet is the same as the
685 * previous ackno and if so if we can bump the head len.
686 */
687 if (delta == 1 &&
688 dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state &&
689 (dccp_ackpkts_len(ap, ap->dccpap_buf_head) <
690 DCCP_ACKPKTS_LEN_MASK))
691 ap->dccpap_buf[ap->dccpap_buf_head]++;
692 else if (dccp_ackpkts_set_buf_head_state(ap, delta, state))
693 return -ENOBUFS;
694 } else {
695 /*
696 * A.1.2. Old Packets
697 *
698 * When a packet with Sequence Number S arrives, and
699 * S <= buf_ackno, the HC-Receiver will scan the table
700 * for the byte corresponding to S. (Indexing structures
701 * could reduce the complexity of this scan.)
702 */
703 u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno);
704 unsigned int index = ap->dccpap_buf_head;
705
706 while (1) {
707 const u8 len = dccp_ackpkts_len(ap, index);
708 const u8 state = dccp_ackpkts_state(ap, index);
709 /*
710 * valid packets not yet in dccpap_buf have a reserved
711 * entry, with a len equal to 0.
712 */
713 if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED &&
714 len == 0 && delta == 0) { /* Found our
715 reserved seat! */
716 dccp_pr_debug("Found %llu reserved seat!\n",
717 (unsigned long long) ackno);
718 ap->dccpap_buf[index] = state;
719 goto out;
720 }
721 /* len == 0 means one packet */
722 if (delta < len + 1)
723 goto out_duplicate;
724
725 delta -= len + 1;
726 if (++index == ap->dccpap_buf_len)
727 index = 0;
728 }
729 }
730
731 ap->dccpap_buf_ackno = ackno;
732 dccp_timestamp(sk, &ap->dccpap_time);
733out:
734 dccp_pr_debug("");
735 dccp_ackpkts_print(ap);
736 return 0;
737
738out_duplicate:
739 /* Duplicate packet */
740 dccp_pr_debug("Received a dup or already considered lost "
741 "packet: %llu\n", (unsigned long long) ackno);
742 return -EILSEQ;
743}
744
745#ifdef CONFIG_IP_DCCP_DEBUG
746void dccp_ackvector_print(const u64 ackno, const unsigned char *vector,
747 int len)
748{
749 if (!dccp_debug)
750 return;
751
752 printk("ACK vector len=%d, ackno=%llu |", len,
753 (unsigned long long) ackno);
754
755 while (len--) {
756 const u8 state = (*vector & DCCP_ACKPKTS_STATE_MASK) >> 6;
757 const u8 rl = (*vector & DCCP_ACKPKTS_LEN_MASK);
758
759 printk("%d,%d|", state, rl);
760 ++vector;
761 }
762
763 printk("\n");
764}
765
766void dccp_ackpkts_print(const struct dccp_ackpkts *ap)
767{
768 dccp_ackvector_print(ap->dccpap_buf_ackno,
769 ap->dccpap_buf + ap->dccpap_buf_head,
770 ap->dccpap_buf_vector_len);
771}
772#endif
773
774static void dccp_ackpkts_trow_away_ack_record(struct dccp_ackpkts *ap)
775{
776 /*
777 * As we're keeping track of the ack vector size
778 * (dccpap_buf_vector_len) and the sent ack vector size
779 * (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but
780 * keep this code here as in the future we'll implement a vector of
781 * ack records, as suggested in draft-ietf-dccp-spec-11.txt
782 * Appendix A. -acme
783 */
784#if 0
785 ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1;
786 if (ap->dccpap_buf_tail >= ap->dccpap_buf_len)
787 ap->dccpap_buf_tail -= ap->dccpap_buf_len;
788#endif
789 ap->dccpap_buf_vector_len -= ap->dccpap_ack_vector_len;
790}
791
792void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk,
793 u64 ackno)
794{
795 /* Check if we actually sent an ACK vector */
796 if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1)
797 return;
798
799 if (ackno == ap->dccpap_ack_seqno) {
800#ifdef CONFIG_IP_DCCP_DEBUG
801 struct dccp_sock *dp = dccp_sk(sk);
802 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
803 "CLIENT rx ack: " : "server rx ack: ";
804#endif
805 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, "
806 "ack_ackno=%llu, ACKED!\n",
807 debug_prefix, 1,
808 (unsigned long long) ap->dccpap_ack_seqno,
809 (unsigned long long) ap->dccpap_ack_ackno);
810 dccp_ackpkts_trow_away_ack_record(ap);
811 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
812 }
813}
814
815static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
816 struct sock *sk, u64 ackno,
817 const unsigned char len,
818 const unsigned char *vector)
819{
820 unsigned char i;
821
822 /* Check if we actually sent an ACK vector */
823 if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1)
824 return;
825 /*
826 * We're in the receiver half connection, so if the received an ACK
827 * vector ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're
828 * not interested.
829 *
830 * Extra explanation with example:
831 *
832 * if we received an ACK vector with ackno 50, it can only be acking
833 * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent).
834 */
835 /* dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); */
836 if (before48(ackno, ap->dccpap_ack_seqno)) {
837 /* dccp_pr_debug_cat("yes\n"); */
838 return;
839 }
840 /* dccp_pr_debug_cat("no\n"); */
841
842 i = len;
843 while (i--) {
844 const u8 rl = (*vector & DCCP_ACKPKTS_LEN_MASK);
845 u64 ackno_end_rl;
846
847 dccp_set_seqno(&ackno_end_rl, ackno - rl);
848
849 /*
850 * dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl,
851 * ap->dccpap_ack_seqno, ackno);
852 */
853 if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) {
854 const u8 state = (*vector &
855 DCCP_ACKPKTS_STATE_MASK) >> 6;
856 /* dccp_pr_debug_cat("yes\n"); */
857
858 if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) {
859#ifdef CONFIG_IP_DCCP_DEBUG
860 struct dccp_sock *dp = dccp_sk(sk);
861 const char *debug_prefix =
862 dp->dccps_role == DCCP_ROLE_CLIENT ?
863 "CLIENT rx ack: " : "server rx ack: ";
864#endif
865 dccp_pr_debug("%sACK vector 0, len=%d, "
866 "ack_seqno=%llu, ack_ackno=%llu, "
867 "ACKED!\n",
868 debug_prefix, len,
869 (unsigned long long)
870 ap->dccpap_ack_seqno,
871 (unsigned long long)
872 ap->dccpap_ack_ackno);
873 dccp_ackpkts_trow_away_ack_record(ap);
874 }
875 /*
876 * If dccpap_ack_seqno was not received, no problem
877 * we'll send another ACK vector.
878 */
879 ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
880 break;
881 }
882 /* dccp_pr_debug_cat("no\n"); */
883
884 dccp_set_seqno(&ackno, ackno_end_rl - 1);
885 ++vector;
886 }
887}
diff --git a/net/dccp/output.c b/net/dccp/output.c
index ea6d0e91e511..29250749f16f 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -16,6 +16,7 @@
16 16
17#include <net/sock.h> 17#include <net/sock.h>
18 18
19#include "ackvec.h"
19#include "ccid.h" 20#include "ccid.h"
20#include "dccp.h" 21#include "dccp.h"
21 22
@@ -61,10 +62,8 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
61 62
62 skb->h.raw = skb_push(skb, dccp_header_size); 63 skb->h.raw = skb_push(skb, dccp_header_size);
63 dh = dccp_hdr(skb); 64 dh = dccp_hdr(skb);
64 /* 65
65 * Data packets are not cloned as they are never retransmitted 66 if (!skb->sk)
66 */
67 if (skb_cloned(skb))
68 skb_set_owner_w(skb, sk); 67 skb_set_owner_w(skb, sk);
69 68
70 /* Build DCCP header and checksum it. */ 69 /* Build DCCP header and checksum it. */
@@ -85,7 +84,7 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
85 switch (dcb->dccpd_type) { 84 switch (dcb->dccpd_type) {
86 case DCCP_PKT_REQUEST: 85 case DCCP_PKT_REQUEST:
87 dccp_hdr_request(skb)->dccph_req_service = 86 dccp_hdr_request(skb)->dccph_req_service =
88 dcb->dccpd_service; 87 dp->dccps_service;
89 break; 88 break;
90 case DCCP_PKT_RESET: 89 case DCCP_PKT_RESET:
91 dccp_hdr_reset(skb)->dccph_reset_code = 90 dccp_hdr_reset(skb)->dccph_reset_code =
@@ -101,6 +100,7 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
101 100
102 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 101 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
103 102
103 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
104 err = ip_queue_xmit(skb, 0); 104 err = ip_queue_xmit(skb, 0);
105 if (err <= 0) 105 if (err <= 0)
106 return err; 106 return err;
@@ -225,7 +225,6 @@ int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, long *timeo)
225 err = dccp_wait_for_ccid(sk, skb, timeo); 225 err = dccp_wait_for_ccid(sk, skb, timeo);
226 226
227 if (err == 0) { 227 if (err == 0) {
228 const struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
229 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 228 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
230 const int len = skb->len; 229 const int len = skb->len;
231 230
@@ -236,22 +235,15 @@ int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, long *timeo)
236 inet_csk(sk)->icsk_rto, 235 inet_csk(sk)->icsk_rto,
237 DCCP_RTO_MAX); 236 DCCP_RTO_MAX);
238 dcb->dccpd_type = DCCP_PKT_DATAACK; 237 dcb->dccpd_type = DCCP_PKT_DATAACK;
239 /* 238 } else if (dccp_ack_pending(sk))
240 * FIXME: we really should have a
241 * dccps_ack_pending or use icsk.
242 */
243 } else if (inet_csk_ack_scheduled(sk) ||
244 dp->dccps_timestamp_echo != 0 ||
245 (dp->dccps_options.dccpo_send_ack_vector &&
246 ap->dccpap_buf_ackno != DCCP_MAX_SEQNO + 1 &&
247 ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1))
248 dcb->dccpd_type = DCCP_PKT_DATAACK; 239 dcb->dccpd_type = DCCP_PKT_DATAACK;
249 else 240 else
250 dcb->dccpd_type = DCCP_PKT_DATA; 241 dcb->dccpd_type = DCCP_PKT_DATA;
251 242
252 err = dccp_transmit_skb(sk, skb); 243 err = dccp_transmit_skb(sk, skb);
253 ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, 0, len); 244 ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, 0, len);
254 } 245 } else
246 kfree_skb(skb);
255 247
256 return err; 248 return err;
257} 249}
@@ -270,6 +262,7 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
270 struct request_sock *req) 262 struct request_sock *req)
271{ 263{
272 struct dccp_hdr *dh; 264 struct dccp_hdr *dh;
265 struct dccp_request_sock *dreq;
273 const int dccp_header_size = sizeof(struct dccp_hdr) + 266 const int dccp_header_size = sizeof(struct dccp_hdr) +
274 sizeof(struct dccp_hdr_ext) + 267 sizeof(struct dccp_hdr_ext) +
275 sizeof(struct dccp_hdr_response); 268 sizeof(struct dccp_hdr_response);
@@ -285,8 +278,9 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
285 skb->dst = dst_clone(dst); 278 skb->dst = dst_clone(dst);
286 skb->csum = 0; 279 skb->csum = 0;
287 280
281 dreq = dccp_rsk(req);
288 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE; 282 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE;
289 DCCP_SKB_CB(skb)->dccpd_seq = dccp_rsk(req)->dreq_iss; 283 DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss;
290 dccp_insert_options(sk, skb); 284 dccp_insert_options(sk, skb);
291 285
292 skb->h.raw = skb_push(skb, dccp_header_size); 286 skb->h.raw = skb_push(skb, dccp_header_size);
@@ -300,8 +294,9 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
300 DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; 294 DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
301 dh->dccph_type = DCCP_PKT_RESPONSE; 295 dh->dccph_type = DCCP_PKT_RESPONSE;
302 dh->dccph_x = 1; 296 dh->dccph_x = 1;
303 dccp_hdr_set_seq(dh, dccp_rsk(req)->dreq_iss); 297 dccp_hdr_set_seq(dh, dreq->dreq_iss);
304 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dccp_rsk(req)->dreq_isr); 298 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr);
299 dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service;
305 300
306 dh->dccph_checksum = dccp_v4_checksum(skb, inet_rsk(req)->loc_addr, 301 dh->dccph_checksum = dccp_v4_checksum(skb, inet_rsk(req)->loc_addr,
307 inet_rsk(req)->rmt_addr); 302 inet_rsk(req)->rmt_addr);
@@ -397,9 +392,6 @@ int dccp_connect(struct sock *sk)
397 skb_reserve(skb, MAX_DCCP_HEADER); 392 skb_reserve(skb, MAX_DCCP_HEADER);
398 393
399 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST; 394 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
400 /* FIXME: set service to something meaningful, coming
401 * from userspace*/
402 DCCP_SKB_CB(skb)->dccpd_service = 0;
403 skb->csum = 0; 395 skb->csum = 0;
404 skb_set_owner_w(skb, sk); 396 skb_set_owner_w(skb, sk);
405 397
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 18a0e69c9dc7..a021c3422f67 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -94,7 +94,15 @@ EXPORT_SYMBOL_GPL(dccp_state_name);
94 94
95static inline int dccp_listen_start(struct sock *sk) 95static inline int dccp_listen_start(struct sock *sk)
96{ 96{
97 dccp_sk(sk)->dccps_role = DCCP_ROLE_LISTEN; 97 struct dccp_sock *dp = dccp_sk(sk);
98
99 dp->dccps_role = DCCP_ROLE_LISTEN;
100 /*
101 * Apps need to use setsockopt(DCCP_SOCKOPT_SERVICE)
102 * before calling listen()
103 */
104 if (dccp_service_not_initialized(sk))
105 return -EPROTO;
98 return inet_csk_listen_start(sk, TCP_SYNQ_HSIZE); 106 return inet_csk_listen_start(sk, TCP_SYNQ_HSIZE);
99} 107}
100 108
@@ -202,6 +210,42 @@ int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
202 return -ENOIOCTLCMD; 210 return -ENOIOCTLCMD;
203} 211}
204 212
213static int dccp_setsockopt_service(struct sock *sk, const u32 service,
214 char __user *optval, int optlen)
215{
216 struct dccp_sock *dp = dccp_sk(sk);
217 struct dccp_service_list *sl = NULL;
218
219 if (service == DCCP_SERVICE_INVALID_VALUE ||
220 optlen > DCCP_SERVICE_LIST_MAX_LEN * sizeof(u32))
221 return -EINVAL;
222
223 if (optlen > sizeof(service)) {
224 sl = kmalloc(optlen, GFP_KERNEL);
225 if (sl == NULL)
226 return -ENOMEM;
227
228 sl->dccpsl_nr = optlen / sizeof(u32) - 1;
229 if (copy_from_user(sl->dccpsl_list,
230 optval + sizeof(service),
231 optlen - sizeof(service)) ||
232 dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) {
233 kfree(sl);
234 return -EFAULT;
235 }
236 }
237
238 lock_sock(sk);
239 dp->dccps_service = service;
240
241 if (dp->dccps_service_list != NULL)
242 kfree(dp->dccps_service_list);
243
244 dp->dccps_service_list = sl;
245 release_sock(sk);
246 return 0;
247}
248
205int dccp_setsockopt(struct sock *sk, int level, int optname, 249int dccp_setsockopt(struct sock *sk, int level, int optname,
206 char __user *optval, int optlen) 250 char __user *optval, int optlen)
207{ 251{
@@ -218,8 +262,10 @@ int dccp_setsockopt(struct sock *sk, int level, int optname,
218 if (get_user(val, (int __user *)optval)) 262 if (get_user(val, (int __user *)optval))
219 return -EFAULT; 263 return -EFAULT;
220 264
221 lock_sock(sk); 265 if (optname == DCCP_SOCKOPT_SERVICE)
266 return dccp_setsockopt_service(sk, val, optval, optlen);
222 267
268 lock_sock(sk);
223 dp = dccp_sk(sk); 269 dp = dccp_sk(sk);
224 err = 0; 270 err = 0;
225 271
@@ -236,6 +282,37 @@ int dccp_setsockopt(struct sock *sk, int level, int optname,
236 return err; 282 return err;
237} 283}
238 284
285static int dccp_getsockopt_service(struct sock *sk, int len,
286 u32 __user *optval,
287 int __user *optlen)
288{
289 const struct dccp_sock *dp = dccp_sk(sk);
290 const struct dccp_service_list *sl;
291 int err = -ENOENT, slen = 0, total_len = sizeof(u32);
292
293 lock_sock(sk);
294 if (dccp_service_not_initialized(sk))
295 goto out;
296
297 if ((sl = dp->dccps_service_list) != NULL) {
298 slen = sl->dccpsl_nr * sizeof(u32);
299 total_len += slen;
300 }
301
302 err = -EINVAL;
303 if (total_len > len)
304 goto out;
305
306 err = 0;
307 if (put_user(total_len, optlen) ||
308 put_user(dp->dccps_service, optval) ||
309 (sl != NULL && copy_to_user(optval + 1, sl->dccpsl_list, slen)))
310 err = -EFAULT;
311out:
312 release_sock(sk);
313 return err;
314}
315
239int dccp_getsockopt(struct sock *sk, int level, int optname, 316int dccp_getsockopt(struct sock *sk, int level, int optname,
240 char __user *optval, int __user *optlen) 317 char __user *optval, int __user *optlen)
241{ 318{
@@ -248,8 +325,7 @@ int dccp_getsockopt(struct sock *sk, int level, int optname,
248 if (get_user(len, optlen)) 325 if (get_user(len, optlen))
249 return -EFAULT; 326 return -EFAULT;
250 327
251 len = min_t(unsigned int, len, sizeof(int)); 328 if (len < sizeof(int))
252 if (len < 0)
253 return -EINVAL; 329 return -EINVAL;
254 330
255 dp = dccp_sk(sk); 331 dp = dccp_sk(sk);
@@ -257,7 +333,17 @@ int dccp_getsockopt(struct sock *sk, int level, int optname,
257 switch (optname) { 333 switch (optname) {
258 case DCCP_SOCKOPT_PACKET_SIZE: 334 case DCCP_SOCKOPT_PACKET_SIZE:
259 val = dp->dccps_packet_size; 335 val = dp->dccps_packet_size;
336 len = sizeof(dp->dccps_packet_size);
260 break; 337 break;
338 case DCCP_SOCKOPT_SERVICE:
339 return dccp_getsockopt_service(sk, len,
340 (u32 __user *)optval, optlen);
341 case 128 ... 191:
342 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
343 len, (u32 __user *)optval, optlen);
344 case 192 ... 255:
345 return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname,
346 len, (u32 __user *)optval, optlen);
261 default: 347 default:
262 return -ENOPROTOOPT; 348 return -ENOPROTOOPT;
263 } 349 }
@@ -316,8 +402,6 @@ int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
316 * This bug was _quickly_ found & fixed by just looking at an OSTRA 402 * This bug was _quickly_ found & fixed by just looking at an OSTRA
317 * generated callgraph 8) -acme 403 * generated callgraph 8) -acme
318 */ 404 */
319 if (rc != 0)
320 goto out_discard;
321out_release: 405out_release:
322 release_sock(sk); 406 release_sock(sk);
323 return rc ? : len; 407 return rc ? : len;
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 348f36b529f7..1186dc44cdff 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -452,7 +452,7 @@ static struct proto dn_proto = {
452 .obj_size = sizeof(struct dn_sock), 452 .obj_size = sizeof(struct dn_sock),
453}; 453};
454 454
455static struct sock *dn_alloc_sock(struct socket *sock, int gfp) 455static struct sock *dn_alloc_sock(struct socket *sock, gfp_t gfp)
456{ 456{
457 struct dn_scp *scp; 457 struct dn_scp *scp;
458 struct sock *sk = sk_alloc(PF_DECnet, gfp, &dn_proto, 1); 458 struct sock *sk = sk_alloc(PF_DECnet, gfp, &dn_proto, 1);
@@ -804,7 +804,7 @@ static int dn_auto_bind(struct socket *sock)
804 return rv; 804 return rv;
805} 805}
806 806
807static int dn_confirm_accept(struct sock *sk, long *timeo, int allocation) 807static int dn_confirm_accept(struct sock *sk, long *timeo, gfp_t allocation)
808{ 808{
809 struct dn_scp *scp = DN_SK(sk); 809 struct dn_scp *scp = DN_SK(sk);
810 DEFINE_WAIT(wait); 810 DEFINE_WAIT(wait);
diff --git a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c
index 53633d352868..c96c767b1f74 100644
--- a/net/decnet/dn_nsp_out.c
+++ b/net/decnet/dn_nsp_out.c
@@ -117,7 +117,7 @@ try_again:
117 * The eventual aim is for each socket to have a cached header size 117 * The eventual aim is for each socket to have a cached header size
118 * for its outgoing packets, and to set hdr from this when sk != NULL. 118 * for its outgoing packets, and to set hdr from this when sk != NULL.
119 */ 119 */
120struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri) 120struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri)
121{ 121{
122 struct sk_buff *skb; 122 struct sk_buff *skb;
123 int hdr = 64; 123 int hdr = 64;
@@ -210,7 +210,8 @@ static void dn_nsp_rtt(struct sock *sk, long rtt)
210 * 210 *
211 * Returns: The number of times the packet has been sent previously 211 * Returns: The number of times the packet has been sent previously
212 */ 212 */
213static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb, int gfp) 213static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb,
214 gfp_t gfp)
214{ 215{
215 struct dn_skb_cb *cb = DN_SKB_CB(skb); 216 struct dn_skb_cb *cb = DN_SKB_CB(skb);
216 struct sk_buff *skb2; 217 struct sk_buff *skb2;
@@ -350,7 +351,8 @@ static unsigned short *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *sk
350 return ptr; 351 return ptr;
351} 352}
352 353
353void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, int gfp, int oth) 354void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb,
355 gfp_t gfp, int oth)
354{ 356{
355 struct dn_scp *scp = DN_SK(sk); 357 struct dn_scp *scp = DN_SK(sk);
356 struct dn_skb_cb *cb = DN_SKB_CB(skb); 358 struct dn_skb_cb *cb = DN_SKB_CB(skb);
@@ -517,7 +519,7 @@ static int dn_nsp_retrans_conn_conf(struct sock *sk)
517 return 0; 519 return 0;
518} 520}
519 521
520void dn_send_conn_conf(struct sock *sk, int gfp) 522void dn_send_conn_conf(struct sock *sk, gfp_t gfp)
521{ 523{
522 struct dn_scp *scp = DN_SK(sk); 524 struct dn_scp *scp = DN_SK(sk);
523 struct sk_buff *skb = NULL; 525 struct sk_buff *skb = NULL;
@@ -549,7 +551,8 @@ void dn_send_conn_conf(struct sock *sk, int gfp)
549 551
550 552
551static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, 553static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
552 unsigned short reason, int gfp, struct dst_entry *dst, 554 unsigned short reason, gfp_t gfp,
555 struct dst_entry *dst,
553 int ddl, unsigned char *dd, __u16 rem, __u16 loc) 556 int ddl, unsigned char *dd, __u16 rem, __u16 loc)
554{ 557{
555 struct sk_buff *skb = NULL; 558 struct sk_buff *skb = NULL;
@@ -591,7 +594,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg,
591 594
592 595
593void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, 596void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg,
594 unsigned short reason, int gfp) 597 unsigned short reason, gfp_t gfp)
595{ 598{
596 struct dn_scp *scp = DN_SK(sk); 599 struct dn_scp *scp = DN_SK(sk);
597 int ddl = 0; 600 int ddl = 0;
@@ -612,7 +615,7 @@ void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg,
612{ 615{
613 struct dn_skb_cb *cb = DN_SKB_CB(skb); 616 struct dn_skb_cb *cb = DN_SKB_CB(skb);
614 int ddl = 0; 617 int ddl = 0;
615 int gfp = GFP_ATOMIC; 618 gfp_t gfp = GFP_ATOMIC;
616 619
617 dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl, 620 dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl,
618 NULL, cb->src_port, cb->dst_port); 621 NULL, cb->src_port, cb->dst_port);
@@ -624,7 +627,7 @@ void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval)
624 struct dn_scp *scp = DN_SK(sk); 627 struct dn_scp *scp = DN_SK(sk);
625 struct sk_buff *skb; 628 struct sk_buff *skb;
626 unsigned char *ptr; 629 unsigned char *ptr;
627 int gfp = GFP_ATOMIC; 630 gfp_t gfp = GFP_ATOMIC;
628 631
629 if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL) 632 if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL)
630 return; 633 return;
@@ -659,7 +662,7 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg)
659 unsigned char menuver; 662 unsigned char menuver;
660 struct dn_skb_cb *cb; 663 struct dn_skb_cb *cb;
661 unsigned char type = 1; 664 unsigned char type = 1;
662 int allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC; 665 gfp_t allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC;
663 struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation); 666 struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation);
664 667
665 if (!skb) 668 if (!skb)
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index 4a62093eb343..34fdac51df96 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -406,7 +406,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
406 unsigned long network = 0; 406 unsigned long network = 0;
407 407
408 rcu_read_lock(); 408 rcu_read_lock();
409 idev = __in_dev_get(dev); 409 idev = __in_dev_get_rcu(dev);
410 if (idev) { 410 if (idev) {
411 if (idev->ifa_list) 411 if (idev->ifa_list)
412 network = ntohl(idev->ifa_list->ifa_address) & 412 network = ntohl(idev->ifa_list->ifa_address) &
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 87a052a9a84f..68a5ca866442 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -146,6 +146,19 @@ int eth_rebuild_header(struct sk_buff *skb)
146 return 0; 146 return 0;
147} 147}
148 148
149static inline unsigned int compare_eth_addr(const unsigned char *__a, const unsigned char *__b)
150{
151 const unsigned short *dest = (unsigned short *) __a;
152 const unsigned short *devaddr = (unsigned short *) __b;
153 unsigned int res;
154
155 BUILD_BUG_ON(ETH_ALEN != 6);
156 res = ((dest[0] ^ devaddr[0]) |
157 (dest[1] ^ devaddr[1]) |
158 (dest[2] ^ devaddr[2])) != 0;
159
160 return res;
161}
149 162
150/* 163/*
151 * Determine the packet's protocol ID. The rule here is that we 164 * Determine the packet's protocol ID. The rule here is that we
@@ -158,16 +171,15 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
158 struct ethhdr *eth; 171 struct ethhdr *eth;
159 unsigned char *rawp; 172 unsigned char *rawp;
160 173
161 skb->mac.raw=skb->data; 174 skb->mac.raw = skb->data;
162 skb_pull(skb,ETH_HLEN); 175 skb_pull(skb,ETH_HLEN);
163 eth = eth_hdr(skb); 176 eth = eth_hdr(skb);
164 177
165 if(*eth->h_dest&1) 178 if (*eth->h_dest&1) {
166 { 179 if (!compare_eth_addr(eth->h_dest, dev->broadcast))
167 if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) 180 skb->pkt_type = PACKET_BROADCAST;
168 skb->pkt_type=PACKET_BROADCAST;
169 else 181 else
170 skb->pkt_type=PACKET_MULTICAST; 182 skb->pkt_type = PACKET_MULTICAST;
171 } 183 }
172 184
173 /* 185 /*
@@ -178,10 +190,9 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
178 * seems to set IFF_PROMISC. 190 * seems to set IFF_PROMISC.
179 */ 191 */
180 192
181 else if(1 /*dev->flags&IFF_PROMISC*/) 193 else if(1 /*dev->flags&IFF_PROMISC*/) {
182 { 194 if (unlikely(compare_eth_addr(eth->h_dest, dev->dev_addr)))
183 if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN)) 195 skb->pkt_type = PACKET_OTHERHOST;
184 skb->pkt_type=PACKET_OTHERHOST;
185 } 196 }
186 197
187 if (ntohs(eth->h_proto) >= 1536) 198 if (ntohs(eth->h_proto) >= 1536)
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 03a47343ddc7..6059e9e37123 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -230,7 +230,7 @@ static int __init ieee80211_init(void)
230 struct proc_dir_entry *e; 230 struct proc_dir_entry *e;
231 231
232 ieee80211_debug_level = debug; 232 ieee80211_debug_level = debug;
233 ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net); 233 ieee80211_proc = proc_mkdir(DRV_NAME, proc_net);
234 if (ieee80211_proc == NULL) { 234 if (ieee80211_proc == NULL) {
235 IEEE80211_ERROR("Unable to create " DRV_NAME 235 IEEE80211_ERROR("Unable to create " DRV_NAME
236 " proc directory\n"); 236 " proc directory\n");
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
index c9aaff3fea1e..eed07bbbe6b6 100644
--- a/net/ieee80211/ieee80211_tx.c
+++ b/net/ieee80211/ieee80211_tx.c
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb)
207} 207}
208 208
209static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, 209static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
210 int gfp_mask) 210 gfp_t gfp_mask)
211{ 211{
212 struct ieee80211_txb *txb; 212 struct ieee80211_txb *txb;
213 int i; 213 int i;
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 8bf312bdea13..b425748f02d7 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -241,7 +241,7 @@ static int arp_constructor(struct neighbour *neigh)
241 neigh->type = inet_addr_type(addr); 241 neigh->type = inet_addr_type(addr);
242 242
243 rcu_read_lock(); 243 rcu_read_lock();
244 in_dev = rcu_dereference(__in_dev_get(dev)); 244 in_dev = __in_dev_get_rcu(dev);
245 if (in_dev == NULL) { 245 if (in_dev == NULL) {
246 rcu_read_unlock(); 246 rcu_read_unlock();
247 return -EINVAL; 247 return -EINVAL;
@@ -697,12 +697,6 @@ void arp_send(int type, int ptype, u32 dest_ip,
697 arp_xmit(skb); 697 arp_xmit(skb);
698} 698}
699 699
700static void parp_redo(struct sk_buff *skb)
701{
702 nf_reset(skb);
703 arp_rcv(skb, skb->dev, NULL, skb->dev);
704}
705
706/* 700/*
707 * Process an arp request. 701 * Process an arp request.
708 */ 702 */
@@ -922,6 +916,11 @@ out:
922 return 0; 916 return 0;
923} 917}
924 918
919static void parp_redo(struct sk_buff *skb)
920{
921 arp_process(skb);
922}
923
925 924
926/* 925/*
927 * Receive an arp request from the device layer. 926 * Receive an arp request from the device layer.
@@ -990,8 +989,8 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev)
990 ipv4_devconf.proxy_arp = 1; 989 ipv4_devconf.proxy_arp = 1;
991 return 0; 990 return 0;
992 } 991 }
993 if (__in_dev_get(dev)) { 992 if (__in_dev_get_rtnl(dev)) {
994 __in_dev_get(dev)->cnf.proxy_arp = 1; 993 __in_dev_get_rtnl(dev)->cnf.proxy_arp = 1;
995 return 0; 994 return 0;
996 } 995 }
997 return -ENXIO; 996 return -ENXIO;
@@ -1096,8 +1095,8 @@ static int arp_req_delete(struct arpreq *r, struct net_device * dev)
1096 ipv4_devconf.proxy_arp = 0; 1095 ipv4_devconf.proxy_arp = 0;
1097 return 0; 1096 return 0;
1098 } 1097 }
1099 if (__in_dev_get(dev)) { 1098 if (__in_dev_get_rtnl(dev)) {
1100 __in_dev_get(dev)->cnf.proxy_arp = 0; 1099 __in_dev_get_rtnl(dev)->cnf.proxy_arp = 0;
1101 return 0; 1100 return 0;
1102 } 1101 }
1103 return -ENXIO; 1102 return -ENXIO;
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index ba2895ae8151..74f2207e131a 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -351,7 +351,7 @@ static int inet_insert_ifa(struct in_ifaddr *ifa)
351 351
352static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) 352static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
353{ 353{
354 struct in_device *in_dev = __in_dev_get(dev); 354 struct in_device *in_dev = __in_dev_get_rtnl(dev);
355 355
356 ASSERT_RTNL(); 356 ASSERT_RTNL();
357 357
@@ -449,7 +449,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
449 goto out; 449 goto out;
450 450
451 rc = -ENOBUFS; 451 rc = -ENOBUFS;
452 if ((in_dev = __in_dev_get(dev)) == NULL) { 452 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) {
453 in_dev = inetdev_init(dev); 453 in_dev = inetdev_init(dev);
454 if (!in_dev) 454 if (!in_dev)
455 goto out; 455 goto out;
@@ -584,7 +584,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
584 if (colon) 584 if (colon)
585 *colon = ':'; 585 *colon = ':';
586 586
587 if ((in_dev = __in_dev_get(dev)) != NULL) { 587 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
588 if (tryaddrmatch) { 588 if (tryaddrmatch) {
589 /* Matthias Andree */ 589 /* Matthias Andree */
590 /* compare label and address (4.4BSD style) */ 590 /* compare label and address (4.4BSD style) */
@@ -748,7 +748,7 @@ rarok:
748 748
749static int inet_gifconf(struct net_device *dev, char __user *buf, int len) 749static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
750{ 750{
751 struct in_device *in_dev = __in_dev_get(dev); 751 struct in_device *in_dev = __in_dev_get_rtnl(dev);
752 struct in_ifaddr *ifa; 752 struct in_ifaddr *ifa;
753 struct ifreq ifr; 753 struct ifreq ifr;
754 int done = 0; 754 int done = 0;
@@ -791,7 +791,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope)
791 struct in_device *in_dev; 791 struct in_device *in_dev;
792 792
793 rcu_read_lock(); 793 rcu_read_lock();
794 in_dev = __in_dev_get(dev); 794 in_dev = __in_dev_get_rcu(dev);
795 if (!in_dev) 795 if (!in_dev)
796 goto no_in_dev; 796 goto no_in_dev;
797 797
@@ -818,7 +818,7 @@ no_in_dev:
818 read_lock(&dev_base_lock); 818 read_lock(&dev_base_lock);
819 rcu_read_lock(); 819 rcu_read_lock();
820 for (dev = dev_base; dev; dev = dev->next) { 820 for (dev = dev_base; dev; dev = dev->next) {
821 if ((in_dev = __in_dev_get(dev)) == NULL) 821 if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
822 continue; 822 continue;
823 823
824 for_primary_ifa(in_dev) { 824 for_primary_ifa(in_dev) {
@@ -887,7 +887,7 @@ u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scop
887 887
888 if (dev) { 888 if (dev) {
889 rcu_read_lock(); 889 rcu_read_lock();
890 if ((in_dev = __in_dev_get(dev))) 890 if ((in_dev = __in_dev_get_rcu(dev)))
891 addr = confirm_addr_indev(in_dev, dst, local, scope); 891 addr = confirm_addr_indev(in_dev, dst, local, scope);
892 rcu_read_unlock(); 892 rcu_read_unlock();
893 893
@@ -897,7 +897,7 @@ u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scop
897 read_lock(&dev_base_lock); 897 read_lock(&dev_base_lock);
898 rcu_read_lock(); 898 rcu_read_lock();
899 for (dev = dev_base; dev; dev = dev->next) { 899 for (dev = dev_base; dev; dev = dev->next) {
900 if ((in_dev = __in_dev_get(dev))) { 900 if ((in_dev = __in_dev_get_rcu(dev))) {
901 addr = confirm_addr_indev(in_dev, dst, local, scope); 901 addr = confirm_addr_indev(in_dev, dst, local, scope);
902 if (addr) 902 if (addr)
903 break; 903 break;
@@ -957,7 +957,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
957 void *ptr) 957 void *ptr)
958{ 958{
959 struct net_device *dev = ptr; 959 struct net_device *dev = ptr;
960 struct in_device *in_dev = __in_dev_get(dev); 960 struct in_device *in_dev = __in_dev_get_rtnl(dev);
961 961
962 ASSERT_RTNL(); 962 ASSERT_RTNL();
963 963
@@ -1078,7 +1078,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
1078 if (idx > s_idx) 1078 if (idx > s_idx)
1079 s_ip_idx = 0; 1079 s_ip_idx = 0;
1080 rcu_read_lock(); 1080 rcu_read_lock();
1081 if ((in_dev = __in_dev_get(dev)) == NULL) { 1081 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
1082 rcu_read_unlock(); 1082 rcu_read_unlock();
1083 continue; 1083 continue;
1084 } 1084 }
@@ -1149,7 +1149,7 @@ void inet_forward_change(void)
1149 for (dev = dev_base; dev; dev = dev->next) { 1149 for (dev = dev_base; dev; dev = dev->next) {
1150 struct in_device *in_dev; 1150 struct in_device *in_dev;
1151 rcu_read_lock(); 1151 rcu_read_lock();
1152 in_dev = __in_dev_get(dev); 1152 in_dev = __in_dev_get_rcu(dev);
1153 if (in_dev) 1153 if (in_dev)
1154 in_dev->cnf.forwarding = on; 1154 in_dev->cnf.forwarding = on;
1155 rcu_read_unlock(); 1155 rcu_read_unlock();
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 1b5a09d1b90b..1b18ce66e7b7 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -5,6 +5,7 @@
5#include <net/esp.h> 5#include <net/esp.h>
6#include <asm/scatterlist.h> 6#include <asm/scatterlist.h>
7#include <linux/crypto.h> 7#include <linux/crypto.h>
8#include <linux/kernel.h>
8#include <linux/pfkeyv2.h> 9#include <linux/pfkeyv2.h>
9#include <linux/random.h> 10#include <linux/random.h>
10#include <net/icmp.h> 11#include <net/icmp.h>
@@ -42,10 +43,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
42 esp = x->data; 43 esp = x->data;
43 alen = esp->auth.icv_trunc_len; 44 alen = esp->auth.icv_trunc_len;
44 tfm = esp->conf.tfm; 45 tfm = esp->conf.tfm;
45 blksize = (crypto_tfm_alg_blocksize(tfm) + 3) & ~3; 46 blksize = ALIGN(crypto_tfm_alg_blocksize(tfm), 4);
46 clen = (clen + 2 + blksize-1)&~(blksize-1); 47 clen = ALIGN(clen + 2, blksize);
47 if (esp->conf.padlen) 48 if (esp->conf.padlen)
48 clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1); 49 clen = ALIGN(clen, esp->conf.padlen);
49 50
50 if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) 51 if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0)
51 goto error; 52 goto error;
@@ -143,7 +144,7 @@ static int esp_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struc
143 struct ip_esp_hdr *esph; 144 struct ip_esp_hdr *esph;
144 struct esp_data *esp = x->data; 145 struct esp_data *esp = x->data;
145 struct sk_buff *trailer; 146 struct sk_buff *trailer;
146 int blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); 147 int blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4);
147 int alen = esp->auth.icv_trunc_len; 148 int alen = esp->auth.icv_trunc_len;
148 int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen; 149 int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen;
149 int nfrags; 150 int nfrags;
@@ -304,16 +305,16 @@ static int esp_post_input(struct xfrm_state *x, struct xfrm_decap_state *decap,
304static u32 esp4_get_max_size(struct xfrm_state *x, int mtu) 305static u32 esp4_get_max_size(struct xfrm_state *x, int mtu)
305{ 306{
306 struct esp_data *esp = x->data; 307 struct esp_data *esp = x->data;
307 u32 blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); 308 u32 blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4);
308 309
309 if (x->props.mode) { 310 if (x->props.mode) {
310 mtu = (mtu + 2 + blksize-1)&~(blksize-1); 311 mtu = ALIGN(mtu + 2, blksize);
311 } else { 312 } else {
312 /* The worst case. */ 313 /* The worst case. */
313 mtu += 2 + blksize; 314 mtu = ALIGN(mtu + 2, 4) + blksize - 4;
314 } 315 }
315 if (esp->conf.padlen) 316 if (esp->conf.padlen)
316 mtu = (mtu + esp->conf.padlen-1)&~(esp->conf.padlen-1); 317 mtu = ALIGN(mtu, esp->conf.padlen);
317 318
318 return mtu + x->props.header_len + esp->auth.icv_trunc_len; 319 return mtu + x->props.header_len + esp->auth.icv_trunc_len;
319} 320}
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 4e1379f71269..e61bc7177eb1 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -173,7 +173,7 @@ int fib_validate_source(u32 src, u32 dst, u8 tos, int oif,
173 173
174 no_addr = rpf = 0; 174 no_addr = rpf = 0;
175 rcu_read_lock(); 175 rcu_read_lock();
176 in_dev = __in_dev_get(dev); 176 in_dev = __in_dev_get_rcu(dev);
177 if (in_dev) { 177 if (in_dev) {
178 no_addr = in_dev->ifa_list == NULL; 178 no_addr = in_dev->ifa_list == NULL;
179 rpf = IN_DEV_RPFILTER(in_dev); 179 rpf = IN_DEV_RPFILTER(in_dev);
@@ -607,7 +607,7 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
607static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) 607static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
608{ 608{
609 struct net_device *dev = ptr; 609 struct net_device *dev = ptr;
610 struct in_device *in_dev = __in_dev_get(dev); 610 struct in_device *in_dev = __in_dev_get_rtnl(dev);
611 611
612 if (event == NETDEV_UNREGISTER) { 612 if (event == NETDEV_UNREGISTER) {
613 fib_disable_ip(dev, 2); 613 fib_disable_ip(dev, 2);
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index d41219e8037c..186f20c4a45e 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1087,7 +1087,7 @@ fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm,
1087 rta->rta_oif = &dev->ifindex; 1087 rta->rta_oif = &dev->ifindex;
1088 if (colon) { 1088 if (colon) {
1089 struct in_ifaddr *ifa; 1089 struct in_ifaddr *ifa;
1090 struct in_device *in_dev = __in_dev_get(dev); 1090 struct in_device *in_dev = __in_dev_get_rtnl(dev);
1091 if (!in_dev) 1091 if (!in_dev)
1092 return -ENODEV; 1092 return -ENODEV;
1093 *colon = ':'; 1093 *colon = ':';
@@ -1268,7 +1268,7 @@ int fib_sync_up(struct net_device *dev)
1268 } 1268 }
1269 if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP)) 1269 if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP))
1270 continue; 1270 continue;
1271 if (nh->nh_dev != dev || __in_dev_get(dev) == NULL) 1271 if (nh->nh_dev != dev || !__in_dev_get_rtnl(dev))
1272 continue; 1272 continue;
1273 alive++; 1273 alive++;
1274 spin_lock_bh(&fib_multipath_lock); 1274 spin_lock_bh(&fib_multipath_lock);
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 1b63b4824164..0093ea08c7f5 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -43,7 +43,7 @@
43 * 2 of the License, or (at your option) any later version. 43 * 2 of the License, or (at your option) any later version.
44 */ 44 */
45 45
46#define VERSION "0.403" 46#define VERSION "0.404"
47 47
48#include <linux/config.h> 48#include <linux/config.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
@@ -224,7 +224,7 @@ static inline int tkey_mismatch(t_key a, int offset, t_key b)
224 Consider a node 'n' and its parent 'tp'. 224 Consider a node 'n' and its parent 'tp'.
225 225
226 If n is a leaf, every bit in its key is significant. Its presence is 226 If n is a leaf, every bit in its key is significant. Its presence is
227 necessitaded by path compression, since during a tree traversal (when 227 necessitated by path compression, since during a tree traversal (when
228 searching for a leaf - unless we are doing an insertion) we will completely 228 searching for a leaf - unless we are doing an insertion) we will completely
229 ignore all skipped bits we encounter. Thus we need to verify, at the end of 229 ignore all skipped bits we encounter. Thus we need to verify, at the end of
230 a potentially successful search, that we have indeed been walking the 230 a potentially successful search, that we have indeed been walking the
@@ -286,6 +286,8 @@ static inline void check_tnode(const struct tnode *tn)
286 286
287static int halve_threshold = 25; 287static int halve_threshold = 25;
288static int inflate_threshold = 50; 288static int inflate_threshold = 50;
289static int halve_threshold_root = 15;
290static int inflate_threshold_root = 25;
289 291
290 292
291static void __alias_free_mem(struct rcu_head *head) 293static void __alias_free_mem(struct rcu_head *head)
@@ -449,6 +451,8 @@ static struct node *resize(struct trie *t, struct tnode *tn)
449 int i; 451 int i;
450 int err = 0; 452 int err = 0;
451 struct tnode *old_tn; 453 struct tnode *old_tn;
454 int inflate_threshold_use;
455 int halve_threshold_use;
452 456
453 if (!tn) 457 if (!tn)
454 return NULL; 458 return NULL;
@@ -541,10 +545,17 @@ static struct node *resize(struct trie *t, struct tnode *tn)
541 545
542 check_tnode(tn); 546 check_tnode(tn);
543 547
548 /* Keep root node larger */
549
550 if(!tn->parent)
551 inflate_threshold_use = inflate_threshold_root;
552 else
553 inflate_threshold_use = inflate_threshold;
554
544 err = 0; 555 err = 0;
545 while ((tn->full_children > 0 && 556 while ((tn->full_children > 0 &&
546 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= 557 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >=
547 inflate_threshold * tnode_child_length(tn))) { 558 inflate_threshold_use * tnode_child_length(tn))) {
548 559
549 old_tn = tn; 560 old_tn = tn;
550 tn = inflate(t, tn); 561 tn = inflate(t, tn);
@@ -564,10 +575,18 @@ static struct node *resize(struct trie *t, struct tnode *tn)
564 * node is above threshold. 575 * node is above threshold.
565 */ 576 */
566 577
578
579 /* Keep root node larger */
580
581 if(!tn->parent)
582 halve_threshold_use = halve_threshold_root;
583 else
584 halve_threshold_use = halve_threshold;
585
567 err = 0; 586 err = 0;
568 while (tn->bits > 1 && 587 while (tn->bits > 1 &&
569 100 * (tnode_child_length(tn) - tn->empty_children) < 588 100 * (tnode_child_length(tn) - tn->empty_children) <
570 halve_threshold * tnode_child_length(tn)) { 589 halve_threshold_use * tnode_child_length(tn)) {
571 590
572 old_tn = tn; 591 old_tn = tn;
573 tn = halve(t, tn); 592 tn = halve(t, tn);
@@ -836,11 +855,12 @@ static void trie_init(struct trie *t)
836#endif 855#endif
837} 856}
838 857
839/* readside most use rcu_read_lock currently dump routines 858/* readside must use rcu_read_lock currently dump routines
840 via get_fa_head and dump */ 859 via get_fa_head and dump */
841 860
842static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen) 861static struct leaf_info *find_leaf_info(struct leaf *l, int plen)
843{ 862{
863 struct hlist_head *head = &l->list;
844 struct hlist_node *node; 864 struct hlist_node *node;
845 struct leaf_info *li; 865 struct leaf_info *li;
846 866
@@ -853,7 +873,7 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen)
853 873
854static inline struct list_head * get_fa_head(struct leaf *l, int plen) 874static inline struct list_head * get_fa_head(struct leaf *l, int plen)
855{ 875{
856 struct leaf_info *li = find_leaf_info(&l->list, plen); 876 struct leaf_info *li = find_leaf_info(l, plen);
857 877
858 if (!li) 878 if (!li)
859 return NULL; 879 return NULL;
@@ -1085,7 +1105,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1085 } 1105 }
1086 1106
1087 if (tp && tp->pos + tp->bits > 32) 1107 if (tp && tp->pos + tp->bits > 32)
1088 printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", 1108 printk(KERN_WARNING "fib_trie tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
1089 tp, tp->pos, tp->bits, key, plen); 1109 tp, tp->pos, tp->bits, key, plen);
1090 1110
1091 /* Rebalance the trie */ 1111 /* Rebalance the trie */
@@ -1248,7 +1268,7 @@ err:
1248} 1268}
1249 1269
1250 1270
1251/* should be clalled with rcu_read_lock */ 1271/* should be called with rcu_read_lock */
1252static inline int check_leaf(struct trie *t, struct leaf *l, 1272static inline int check_leaf(struct trie *t, struct leaf *l,
1253 t_key key, int *plen, const struct flowi *flp, 1273 t_key key, int *plen, const struct flowi *flp,
1254 struct fib_result *res) 1274 struct fib_result *res)
@@ -1590,7 +1610,7 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1590 rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req); 1610 rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req);
1591 1611
1592 l = fib_find_node(t, key); 1612 l = fib_find_node(t, key);
1593 li = find_leaf_info(&l->list, plen); 1613 li = find_leaf_info(l, plen);
1594 1614
1595 list_del_rcu(&fa->fa_list); 1615 list_del_rcu(&fa->fa_list);
1596 1616
@@ -1714,7 +1734,6 @@ static int fn_trie_flush(struct fib_table *tb)
1714 1734
1715 t->revision++; 1735 t->revision++;
1716 1736
1717 rcu_read_lock();
1718 for (h = 0; (l = nextleaf(t, l)) != NULL; h++) { 1737 for (h = 0; (l = nextleaf(t, l)) != NULL; h++) {
1719 found += trie_flush_leaf(t, l); 1738 found += trie_flush_leaf(t, l);
1720 1739
@@ -1722,7 +1741,6 @@ static int fn_trie_flush(struct fib_table *tb)
1722 trie_leaf_remove(t, ll->key); 1741 trie_leaf_remove(t, ll->key);
1723 ll = l; 1742 ll = l;
1724 } 1743 }
1725 rcu_read_unlock();
1726 1744
1727 if (ll && hlist_empty(&ll->list)) 1745 if (ll && hlist_empty(&ll->list))
1728 trie_leaf_remove(t, ll->key); 1746 trie_leaf_remove(t, ll->key);
@@ -1833,16 +1851,7 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi
1833 i++; 1851 i++;
1834 continue; 1852 continue;
1835 } 1853 }
1836 if (fa->fa_info->fib_nh == NULL) { 1854 BUG_ON(!fa->fa_info);
1837 printk("Trie error _fib_nh=NULL in fa[%d] k=%08x plen=%d\n", i, key, plen);
1838 i++;
1839 continue;
1840 }
1841 if (fa->fa_info == NULL) {
1842 printk("Trie error fa_info=NULL in fa[%d] k=%08x plen=%d\n", i, key, plen);
1843 i++;
1844 continue;
1845 }
1846 1855
1847 if (fib_dump_info(skb, NETLINK_CB(cb->skb).pid, 1856 if (fib_dump_info(skb, NETLINK_CB(cb->skb).pid,
1848 cb->nlh->nlmsg_seq, 1857 cb->nlh->nlmsg_seq,
@@ -1965,7 +1974,7 @@ struct fib_table * __init fib_hash_init(int id)
1965 trie_main = t; 1974 trie_main = t;
1966 1975
1967 if (id == RT_TABLE_LOCAL) 1976 if (id == RT_TABLE_LOCAL)
1968 printk("IPv4 FIB: Using LC-trie version %s\n", VERSION); 1977 printk(KERN_INFO "IPv4 FIB: Using LC-trie version %s\n", VERSION);
1969 1978
1970 return tb; 1979 return tb;
1971} 1980}
@@ -2029,7 +2038,7 @@ static struct node *fib_trie_get_first(struct fib_trie_iter *iter,
2029 iter->tnode = (struct tnode *) n; 2038 iter->tnode = (struct tnode *) n;
2030 iter->trie = t; 2039 iter->trie = t;
2031 iter->index = 0; 2040 iter->index = 0;
2032 iter->depth = 0; 2041 iter->depth = 1;
2033 return n; 2042 return n;
2034 } 2043 }
2035 return NULL; 2044 return NULL;
@@ -2274,11 +2283,12 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2274 seq_puts(seq, "<local>:\n"); 2283 seq_puts(seq, "<local>:\n");
2275 else 2284 else
2276 seq_puts(seq, "<main>:\n"); 2285 seq_puts(seq, "<main>:\n");
2277 } else { 2286 }
2278 seq_indent(seq, iter->depth-1); 2287 seq_indent(seq, iter->depth-1);
2279 seq_printf(seq, " +-- %d.%d.%d.%d/%d\n", 2288 seq_printf(seq, " +-- %d.%d.%d.%d/%d %d %d %d\n",
2280 NIPQUAD(prf), tn->pos); 2289 NIPQUAD(prf), tn->pos, tn->bits, tn->full_children,
2281 } 2290 tn->empty_children);
2291
2282 } else { 2292 } else {
2283 struct leaf *l = (struct leaf *) n; 2293 struct leaf *l = (struct leaf *) n;
2284 int i; 2294 int i;
@@ -2287,7 +2297,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2287 seq_indent(seq, iter->depth); 2297 seq_indent(seq, iter->depth);
2288 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); 2298 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val));
2289 for (i = 32; i >= 0; i--) { 2299 for (i = 32; i >= 0; i--) {
2290 struct leaf_info *li = find_leaf_info(&l->list, i); 2300 struct leaf_info *li = find_leaf_info(l, i);
2291 if (li) { 2301 if (li) {
2292 struct fib_alias *fa; 2302 struct fib_alias *fa;
2293 list_for_each_entry_rcu(fa, &li->falh, fa_list) { 2303 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
@@ -2383,7 +2393,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2383 return 0; 2393 return 0;
2384 2394
2385 for (i=32; i>=0; i--) { 2395 for (i=32; i>=0; i--) {
2386 struct leaf_info *li = find_leaf_info(&l->list, i); 2396 struct leaf_info *li = find_leaf_info(l, i);
2387 struct fib_alias *fa; 2397 struct fib_alias *fa;
2388 u32 mask, prefix; 2398 u32 mask, prefix;
2389 2399
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 24eb56ae1b5a..90dca711ac9f 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -188,7 +188,7 @@ struct icmp_err icmp_err_convert[] = {
188 188
189/* Control parameters for ECHO replies. */ 189/* Control parameters for ECHO replies. */
190int sysctl_icmp_echo_ignore_all; 190int sysctl_icmp_echo_ignore_all;
191int sysctl_icmp_echo_ignore_broadcasts; 191int sysctl_icmp_echo_ignore_broadcasts = 1;
192 192
193/* Control parameter - ignore bogus broadcast responses? */ 193/* Control parameter - ignore bogus broadcast responses? */
194int sysctl_icmp_ignore_bogus_error_responses; 194int sysctl_icmp_ignore_bogus_error_responses;
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 70c44e4c3ceb..8b6d3939e1e6 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1323,7 +1323,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr)
1323 } 1323 }
1324 if (dev) { 1324 if (dev) {
1325 imr->imr_ifindex = dev->ifindex; 1325 imr->imr_ifindex = dev->ifindex;
1326 idev = __in_dev_get(dev); 1326 idev = __in_dev_get_rtnl(dev);
1327 } 1327 }
1328 return idev; 1328 return idev;
1329} 1329}
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index fe3c6d3d0c91..94468a76c5b4 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -494,7 +494,7 @@ void inet_csk_reqsk_queue_prune(struct sock *parent,
494EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_prune); 494EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_prune);
495 495
496struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req, 496struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req,
497 const unsigned int __nocast priority) 497 const gfp_t priority)
498{ 498{
499 struct sock *newsk = sk_clone(sk, priority); 499 struct sock *newsk = sk_clone(sk, priority);
500 500
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 4d1502a49852..a010e9a68811 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -20,7 +20,7 @@ void __inet_twsk_kill(struct inet_timewait_sock *tw, struct inet_hashinfo *hashi
20 struct inet_bind_hashbucket *bhead; 20 struct inet_bind_hashbucket *bhead;
21 struct inet_bind_bucket *tb; 21 struct inet_bind_bucket *tb;
22 /* Unlink from established hashes. */ 22 /* Unlink from established hashes. */
23 struct inet_ehash_bucket *ehead = &hashinfo->ehash[tw->tw_hashent]; 23 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, tw->tw_hash);
24 24
25 write_lock(&ehead->lock); 25 write_lock(&ehead->lock);
26 if (hlist_unhashed(&tw->tw_node)) { 26 if (hlist_unhashed(&tw->tw_node)) {
@@ -60,7 +60,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
60{ 60{
61 const struct inet_sock *inet = inet_sk(sk); 61 const struct inet_sock *inet = inet_sk(sk);
62 const struct inet_connection_sock *icsk = inet_csk(sk); 62 const struct inet_connection_sock *icsk = inet_csk(sk);
63 struct inet_ehash_bucket *ehead = &hashinfo->ehash[sk->sk_hashent]; 63 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash);
64 struct inet_bind_hashbucket *bhead; 64 struct inet_bind_hashbucket *bhead;
65 /* Step 1: Put TW into bind hash. Original socket stays there too. 65 /* Step 1: Put TW into bind hash. Original socket stays there too.
66 Note, that any socket with inet->num != 0 MUST be bound in 66 Note, that any socket with inet->num != 0 MUST be bound in
@@ -106,11 +106,12 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
106 tw->tw_dport = inet->dport; 106 tw->tw_dport = inet->dport;
107 tw->tw_family = sk->sk_family; 107 tw->tw_family = sk->sk_family;
108 tw->tw_reuse = sk->sk_reuse; 108 tw->tw_reuse = sk->sk_reuse;
109 tw->tw_hashent = sk->sk_hashent; 109 tw->tw_hash = sk->sk_hash;
110 tw->tw_ipv6only = 0; 110 tw->tw_ipv6only = 0;
111 tw->tw_prot = sk->sk_prot_creator; 111 tw->tw_prot = sk->sk_prot_creator;
112 atomic_set(&tw->tw_refcnt, 1); 112 atomic_set(&tw->tw_refcnt, 1);
113 inet_twsk_dead_node_init(tw); 113 inet_twsk_dead_node_init(tw);
114 __module_get(tw->tw_prot->owner);
114 } 115 }
115 116
116 return tw; 117 return tw;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f0d5740d7e22..896ce3f8f53a 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1104,10 +1104,10 @@ static int ipgre_open(struct net_device *dev)
1104 return -EADDRNOTAVAIL; 1104 return -EADDRNOTAVAIL;
1105 dev = rt->u.dst.dev; 1105 dev = rt->u.dst.dev;
1106 ip_rt_put(rt); 1106 ip_rt_put(rt);
1107 if (__in_dev_get(dev) == NULL) 1107 if (__in_dev_get_rtnl(dev) == NULL)
1108 return -EADDRNOTAVAIL; 1108 return -EADDRNOTAVAIL;
1109 t->mlink = dev->ifindex; 1109 t->mlink = dev->ifindex;
1110 ip_mc_inc_group(__in_dev_get(dev), t->parms.iph.daddr); 1110 ip_mc_inc_group(__in_dev_get_rtnl(dev), t->parms.iph.daddr);
1111 } 1111 }
1112 return 0; 1112 return 0;
1113} 1113}
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 3f1a263e1249..1ad5202e556b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -391,6 +391,9 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
391 to->nfct = from->nfct; 391 to->nfct = from->nfct;
392 nf_conntrack_get(to->nfct); 392 nf_conntrack_get(to->nfct);
393 to->nfctinfo = from->nfctinfo; 393 to->nfctinfo = from->nfctinfo;
394#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
395 to->ipvs_property = from->ipvs_property;
396#endif
394#ifdef CONFIG_BRIDGE_NETFILTER 397#ifdef CONFIG_BRIDGE_NETFILTER
395 nf_bridge_put(to->nf_bridge); 398 nf_bridge_put(to->nf_bridge);
396 to->nf_bridge = from->nf_bridge; 399 to->nf_bridge = from->nf_bridge;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 9dbf5909f3a6..302b7eb507c9 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -149,7 +149,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
149 if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) { 149 if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) {
150 dev->flags |= IFF_MULTICAST; 150 dev->flags |= IFF_MULTICAST;
151 151
152 in_dev = __in_dev_get(dev); 152 in_dev = __in_dev_get_rtnl(dev);
153 if (in_dev == NULL && (in_dev = inetdev_init(dev)) == NULL) 153 if (in_dev == NULL && (in_dev = inetdev_init(dev)) == NULL)
154 goto failure; 154 goto failure;
155 in_dev->cnf.rp_filter = 0; 155 in_dev->cnf.rp_filter = 0;
@@ -278,7 +278,7 @@ static int vif_delete(int vifi)
278 278
279 dev_set_allmulti(dev, -1); 279 dev_set_allmulti(dev, -1);
280 280
281 if ((in_dev = __in_dev_get(dev)) != NULL) { 281 if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) {
282 in_dev->cnf.mc_forwarding--; 282 in_dev->cnf.mc_forwarding--;
283 ip_rt_multicast_event(in_dev); 283 ip_rt_multicast_event(in_dev);
284 } 284 }
@@ -421,7 +421,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
421 return -EINVAL; 421 return -EINVAL;
422 } 422 }
423 423
424 if ((in_dev = __in_dev_get(dev)) == NULL) 424 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
425 return -EADDRNOTAVAIL; 425 return -EADDRNOTAVAIL;
426 in_dev->cnf.mc_forwarding++; 426 in_dev->cnf.mc_forwarding++;
427 dev_set_allmulti(dev, +1); 427 dev_set_allmulti(dev, +1);
diff --git a/net/ipv4/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c
index 6e092dadb388..fc6f95aaa969 100644
--- a/net/ipv4/ipvs/ip_vs_app.c
+++ b/net/ipv4/ipvs/ip_vs_app.c
@@ -604,7 +604,7 @@ static struct file_operations ip_vs_app_fops = {
604/* 604/*
605 * Replace a segment of data with a new segment 605 * Replace a segment of data with a new segment
606 */ 606 */
607int ip_vs_skb_replace(struct sk_buff *skb, int pri, 607int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
608 char *o_buf, int o_len, char *n_buf, int n_len) 608 char *o_buf, int o_len, char *n_buf, int n_len)
609{ 609{
610 struct iphdr *iph; 610 struct iphdr *iph;
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index 30aa8e2ee214..7d917e4ce1d9 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -51,6 +51,14 @@ config IP_NF_CONNTRACK_EVENTS
51 51
52 IF unsure, say `N'. 52 IF unsure, say `N'.
53 53
54config IP_NF_CONNTRACK_NETLINK
55 tristate 'Connection tracking netlink interface'
56 depends on IP_NF_CONNTRACK && NETFILTER_NETLINK
57 depends on IP_NF_CONNTRACK!=y || NETFILTER_NETLINK!=m
58 help
59 This option enables support for a netlink-based userspace interface
60
61
54config IP_NF_CT_PROTO_SCTP 62config IP_NF_CT_PROTO_SCTP
55 tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)' 63 tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)'
56 depends on IP_NF_CONNTRACK && EXPERIMENTAL 64 depends on IP_NF_CONNTRACK && EXPERIMENTAL
@@ -129,6 +137,23 @@ config IP_NF_AMANDA
129 137
130 To compile it as a module, choose M here. If unsure, say Y. 138 To compile it as a module, choose M here. If unsure, say Y.
131 139
140config IP_NF_PPTP
141 tristate 'PPTP protocol support'
142 depends on IP_NF_CONNTRACK
143 help
144 This module adds support for PPTP (Point to Point Tunnelling
145 Protocol, RFC2637) connection tracking and NAT.
146
147 If you are running PPTP sessions over a stateful firewall or NAT
148 box, you may want to enable this feature.
149
150 Please note that not all PPTP modes of operation are supported yet.
151 For more info, read top of the file
152 net/ipv4/netfilter/ip_conntrack_pptp.c
153
154 If you want to compile it as a module, say M here and read
155 Documentation/modules.txt. If unsure, say `N'.
156
132config IP_NF_QUEUE 157config IP_NF_QUEUE
133 tristate "IP Userspace queueing via NETLINK (OBSOLETE)" 158 tristate "IP Userspace queueing via NETLINK (OBSOLETE)"
134 help 159 help
@@ -474,9 +499,14 @@ config IP_NF_TARGET_LOG
474 To compile it as a module, choose M here. If unsure, say N. 499 To compile it as a module, choose M here. If unsure, say N.
475 500
476config IP_NF_TARGET_ULOG 501config IP_NF_TARGET_ULOG
477 tristate "ULOG target support" 502 tristate "ULOG target support (OBSOLETE)"
478 depends on IP_NF_IPTABLES 503 depends on IP_NF_IPTABLES
479 ---help--- 504 ---help---
505
506 This option enables the old IPv4-only "ipt_ULOG" implementation
507 which has been obsoleted by the new "nfnetlink_log" code (see
508 CONFIG_NETFILTER_NETLINK_LOG).
509
480 This option adds a `ULOG' target, which allows you to create rules in 510 This option adds a `ULOG' target, which allows you to create rules in
481 any iptables table. The packet is passed to a userspace logging 511 any iptables table. The packet is passed to a userspace logging
482 daemon using netlink multicast sockets; unlike the LOG target 512 daemon using netlink multicast sockets; unlike the LOG target
@@ -513,6 +543,17 @@ config IP_NF_TARGET_TCPMSS
513 543
514 To compile it as a module, choose M here. If unsure, say N. 544 To compile it as a module, choose M here. If unsure, say N.
515 545
546config IP_NF_TARGET_NFQUEUE
547 tristate "NFQUEUE Target Support"
548 depends on IP_NF_IPTABLES
549 help
550 This Target replaced the old obsolete QUEUE target.
551
552 As opposed to QUEUE, it supports 65535 different queues,
553 not just one.
554
555 To compile it as a module, choose M here. If unsure, say N.
556
516# NAT + specific targets 557# NAT + specific targets
517config IP_NF_NAT 558config IP_NF_NAT
518 tristate "Full NAT" 559 tristate "Full NAT"
@@ -613,6 +654,12 @@ config IP_NF_NAT_AMANDA
613 default IP_NF_NAT if IP_NF_AMANDA=y 654 default IP_NF_NAT if IP_NF_AMANDA=y
614 default m if IP_NF_AMANDA=m 655 default m if IP_NF_AMANDA=m
615 656
657config IP_NF_NAT_PPTP
658 tristate
659 depends on IP_NF_NAT!=n && IP_NF_PPTP!=n
660 default IP_NF_NAT if IP_NF_PPTP=y
661 default m if IP_NF_PPTP=m
662
616# mangle + specific targets 663# mangle + specific targets
617config IP_NF_MANGLE 664config IP_NF_MANGLE
618 tristate "Packet mangling" 665 tristate "Packet mangling"
@@ -774,11 +821,5 @@ config IP_NF_ARP_MANGLE
774 Allows altering the ARP packet payload: source and destination 821 Allows altering the ARP packet payload: source and destination
775 hardware and network addresses. 822 hardware and network addresses.
776 823
777config IP_NF_CONNTRACK_NETLINK
778 tristate 'Connection tracking netlink interface'
779 depends on IP_NF_CONNTRACK && NETFILTER_NETLINK
780 help
781 This option enables support for a netlink-based userspace interface
782
783endmenu 824endmenu
784 825
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
index 1ba0db746817..dab4b58dd31e 100644
--- a/net/ipv4/netfilter/Makefile
+++ b/net/ipv4/netfilter/Makefile
@@ -4,7 +4,11 @@
4 4
5# objects for the standalone - connection tracking / NAT 5# objects for the standalone - connection tracking / NAT
6ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o 6ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o
7iptable_nat-objs := ip_nat_standalone.o ip_nat_rule.o ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o 7ip_nat-objs := ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o
8iptable_nat-objs := ip_nat_rule.o ip_nat_standalone.o
9
10ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o
11ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o
8 12
9# connection tracking 13# connection tracking
10obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o 14obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o
@@ -17,6 +21,7 @@ obj-$(CONFIG_IP_NF_CONNTRACK_NETLINK) += ip_conntrack_netlink.o
17obj-$(CONFIG_IP_NF_CT_PROTO_SCTP) += ip_conntrack_proto_sctp.o 21obj-$(CONFIG_IP_NF_CT_PROTO_SCTP) += ip_conntrack_proto_sctp.o
18 22
19# connection tracking helpers 23# connection tracking helpers
24obj-$(CONFIG_IP_NF_PPTP) += ip_conntrack_pptp.o
20obj-$(CONFIG_IP_NF_AMANDA) += ip_conntrack_amanda.o 25obj-$(CONFIG_IP_NF_AMANDA) += ip_conntrack_amanda.o
21obj-$(CONFIG_IP_NF_TFTP) += ip_conntrack_tftp.o 26obj-$(CONFIG_IP_NF_TFTP) += ip_conntrack_tftp.o
22obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o 27obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o
@@ -24,6 +29,7 @@ obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_irc.o
24obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o 29obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o
25 30
26# NAT helpers 31# NAT helpers
32obj-$(CONFIG_IP_NF_NAT_PPTP) += ip_nat_pptp.o
27obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o 33obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o
28obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_tftp.o 34obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_tftp.o
29obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o 35obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o
@@ -35,7 +41,7 @@ obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
35# the three instances of ip_tables 41# the three instances of ip_tables
36obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o 42obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o
37obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o 43obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o
38obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o 44obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o ip_nat.o
39obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o 45obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o
40 46
41# matches 47# matches
@@ -87,6 +93,7 @@ obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o
87obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o 93obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o
88obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o 94obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
89obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o 95obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
96obj-$(CONFIG_IP_NF_TARGET_NFQUEUE) += ipt_NFQUEUE.o
90 97
91# generic ARP tables 98# generic ARP tables
92obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o 99obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o
@@ -96,4 +103,3 @@ obj-$(CONFIG_IP_NF_ARP_MANGLE) += arpt_mangle.o
96obj-$(CONFIG_IP_NF_ARPFILTER) += arptable_filter.o 103obj-$(CONFIG_IP_NF_ARPFILTER) += arptable_filter.o
97 104
98obj-$(CONFIG_IP_NF_QUEUE) += ip_queue.o 105obj-$(CONFIG_IP_NF_QUEUE) += ip_queue.o
99obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += ipt_NFQUEUE.o
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index fa1634256680..a7969286e6e7 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -716,8 +716,10 @@ static int translate_table(const char *name,
716 } 716 }
717 717
718 /* And one copy for every other CPU */ 718 /* And one copy for every other CPU */
719 for (i = 1; i < num_possible_cpus(); i++) { 719 for_each_cpu(i) {
720 memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i, 720 if (i == 0)
721 continue;
722 memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i,
721 newinfo->entries, 723 newinfo->entries,
722 SMP_ALIGN(newinfo->size)); 724 SMP_ALIGN(newinfo->size));
723 } 725 }
@@ -767,7 +769,7 @@ static void get_counters(const struct arpt_table_info *t,
767 unsigned int cpu; 769 unsigned int cpu;
768 unsigned int i; 770 unsigned int i;
769 771
770 for (cpu = 0; cpu < num_possible_cpus(); cpu++) { 772 for_each_cpu(cpu) {
771 i = 0; 773 i = 0;
772 ARPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), 774 ARPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu),
773 t->size, 775 t->size,
@@ -885,7 +887,8 @@ static int do_replace(void __user *user, unsigned int len)
885 return -ENOMEM; 887 return -ENOMEM;
886 888
887 newinfo = vmalloc(sizeof(struct arpt_table_info) 889 newinfo = vmalloc(sizeof(struct arpt_table_info)
888 + SMP_ALIGN(tmp.size) * num_possible_cpus()); 890 + SMP_ALIGN(tmp.size) *
891 (highest_possible_processor_id()+1));
889 if (!newinfo) 892 if (!newinfo)
890 return -ENOMEM; 893 return -ENOMEM;
891 894
@@ -1158,7 +1161,8 @@ int arpt_register_table(struct arpt_table *table,
1158 = { 0, 0, 0, { 0 }, { 0 }, { } }; 1161 = { 0, 0, 0, { 0 }, { 0 }, { } };
1159 1162
1160 newinfo = vmalloc(sizeof(struct arpt_table_info) 1163 newinfo = vmalloc(sizeof(struct arpt_table_info)
1161 + SMP_ALIGN(repl->size) * num_possible_cpus()); 1164 + SMP_ALIGN(repl->size) *
1165 (highest_possible_processor_id()+1));
1162 if (!newinfo) { 1166 if (!newinfo) {
1163 ret = -ENOMEM; 1167 ret = -ENOMEM;
1164 return ret; 1168 return ret;
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
index dc20881004bc..fa3f914117ec 100644
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c
@@ -65,7 +65,7 @@ static int help(struct sk_buff **pskb,
65 65
66 /* increase the UDP timeout of the master connection as replies from 66 /* increase the UDP timeout of the master connection as replies from
67 * Amanda clients to the server can be quite delayed */ 67 * Amanda clients to the server can be quite delayed */
68 ip_ct_refresh_acct(ct, ctinfo, NULL, master_timeout * HZ); 68 ip_ct_refresh(ct, *pskb, master_timeout * HZ);
69 69
70 /* No data? */ 70 /* No data? */
71 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); 71 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 19cba16e6e1e..07a80b56e8dc 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -233,7 +233,7 @@ __ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple)
233 233
234/* Just find a expectation corresponding to a tuple. */ 234/* Just find a expectation corresponding to a tuple. */
235struct ip_conntrack_expect * 235struct ip_conntrack_expect *
236ip_conntrack_expect_find_get(const struct ip_conntrack_tuple *tuple) 236ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple)
237{ 237{
238 struct ip_conntrack_expect *i; 238 struct ip_conntrack_expect *i;
239 239
@@ -1112,42 +1112,49 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me)
1112 synchronize_net(); 1112 synchronize_net();
1113} 1113}
1114 1114
1115static inline void ct_add_counters(struct ip_conntrack *ct, 1115/* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */
1116 enum ip_conntrack_info ctinfo, 1116void __ip_ct_refresh_acct(struct ip_conntrack *ct,
1117 const struct sk_buff *skb)
1118{
1119#ifdef CONFIG_IP_NF_CT_ACCT
1120 if (skb) {
1121 ct->counters[CTINFO2DIR(ctinfo)].packets++;
1122 ct->counters[CTINFO2DIR(ctinfo)].bytes +=
1123 ntohs(skb->nh.iph->tot_len);
1124 }
1125#endif
1126}
1127
1128/* Refresh conntrack for this many jiffies and do accounting (if skb != NULL) */
1129void ip_ct_refresh_acct(struct ip_conntrack *ct,
1130 enum ip_conntrack_info ctinfo, 1117 enum ip_conntrack_info ctinfo,
1131 const struct sk_buff *skb, 1118 const struct sk_buff *skb,
1132 unsigned long extra_jiffies) 1119 unsigned long extra_jiffies,
1120 int do_acct)
1133{ 1121{
1122 int event = 0;
1123
1134 IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct); 1124 IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct);
1125 IP_NF_ASSERT(skb);
1126
1127 write_lock_bh(&ip_conntrack_lock);
1135 1128
1136 /* If not in hash table, timer will not be active yet */ 1129 /* If not in hash table, timer will not be active yet */
1137 if (!is_confirmed(ct)) { 1130 if (!is_confirmed(ct)) {
1138 ct->timeout.expires = extra_jiffies; 1131 ct->timeout.expires = extra_jiffies;
1139 ct_add_counters(ct, ctinfo, skb); 1132 event = IPCT_REFRESH;
1140 } else { 1133 } else {
1141 write_lock_bh(&ip_conntrack_lock);
1142 /* Need del_timer for race avoidance (may already be dying). */ 1134 /* Need del_timer for race avoidance (may already be dying). */
1143 if (del_timer(&ct->timeout)) { 1135 if (del_timer(&ct->timeout)) {
1144 ct->timeout.expires = jiffies + extra_jiffies; 1136 ct->timeout.expires = jiffies + extra_jiffies;
1145 add_timer(&ct->timeout); 1137 add_timer(&ct->timeout);
1146 ip_conntrack_event_cache(IPCT_REFRESH, skb); 1138 event = IPCT_REFRESH;
1147 } 1139 }
1148 ct_add_counters(ct, ctinfo, skb);
1149 write_unlock_bh(&ip_conntrack_lock);
1150 } 1140 }
1141
1142#ifdef CONFIG_IP_NF_CT_ACCT
1143 if (do_acct) {
1144 ct->counters[CTINFO2DIR(ctinfo)].packets++;
1145 ct->counters[CTINFO2DIR(ctinfo)].bytes +=
1146 ntohs(skb->nh.iph->tot_len);
1147 if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
1148 || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
1149 event |= IPCT_COUNTER_FILLING;
1150 }
1151#endif
1152
1153 write_unlock_bh(&ip_conntrack_lock);
1154
1155 /* must be unlocked when calling event cache */
1156 if (event)
1157 ip_conntrack_event_cache(event, skb);
1151} 1158}
1152 1159
1153#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 1160#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
new file mode 100644
index 000000000000..926a6684643d
--- /dev/null
+++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
@@ -0,0 +1,806 @@
1/*
2 * ip_conntrack_pptp.c - Version 3.0
3 *
4 * Connection tracking support for PPTP (Point to Point Tunneling Protocol).
5 * PPTP is a a protocol for creating virtual private networks.
6 * It is a specification defined by Microsoft and some vendors
7 * working with Microsoft. PPTP is built on top of a modified
8 * version of the Internet Generic Routing Encapsulation Protocol.
9 * GRE is defined in RFC 1701 and RFC 1702. Documentation of
10 * PPTP can be found in RFC 2637
11 *
12 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
13 *
14 * Development of this code funded by Astaro AG (http://www.astaro.com/)
15 *
16 * Limitations:
17 * - We blindly assume that control connections are always
18 * established in PNS->PAC direction. This is a violation
19 * of RFFC2673
20 * - We can only support one single call within each session
21 *
22 * TODO:
23 * - testing of incoming PPTP calls
24 *
25 * Changes:
26 * 2002-02-05 - Version 1.3
27 * - Call ip_conntrack_unexpect_related() from
28 * pptp_destroy_siblings() to destroy expectations in case
29 * CALL_DISCONNECT_NOTIFY or tcp fin packet was seen
30 * (Philip Craig <philipc@snapgear.com>)
31 * - Add Version information at module loadtime
32 * 2002-02-10 - Version 1.6
33 * - move to C99 style initializers
34 * - remove second expectation if first arrives
35 * 2004-10-22 - Version 2.0
36 * - merge Mandrake's 2.6.x port with recent 2.6.x API changes
37 * - fix lots of linear skb assumptions from Mandrake's port
38 * 2005-06-10 - Version 2.1
39 * - use ip_conntrack_expect_free() instead of kfree() on the
40 * expect's (which are from the slab for quite some time)
41 * 2005-06-10 - Version 3.0
42 * - port helper to post-2.6.11 API changes,
43 * funded by Oxcoda NetBox Blue (http://www.netboxblue.com/)
44 * 2005-07-30 - Version 3.1
45 * - port helper to 2.6.13 API changes
46 *
47 */
48
49#include <linux/config.h>
50#include <linux/module.h>
51#include <linux/netfilter.h>
52#include <linux/ip.h>
53#include <net/checksum.h>
54#include <net/tcp.h>
55
56#include <linux/netfilter_ipv4/ip_conntrack.h>
57#include <linux/netfilter_ipv4/ip_conntrack_core.h>
58#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
59#include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
60#include <linux/netfilter_ipv4/ip_conntrack_pptp.h>
61
62#define IP_CT_PPTP_VERSION "3.1"
63
64MODULE_LICENSE("GPL");
65MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
66MODULE_DESCRIPTION("Netfilter connection tracking helper module for PPTP");
67
68static DEFINE_SPINLOCK(ip_pptp_lock);
69
70int
71(*ip_nat_pptp_hook_outbound)(struct sk_buff **pskb,
72 struct ip_conntrack *ct,
73 enum ip_conntrack_info ctinfo,
74 struct PptpControlHeader *ctlh,
75 union pptp_ctrl_union *pptpReq);
76
77int
78(*ip_nat_pptp_hook_inbound)(struct sk_buff **pskb,
79 struct ip_conntrack *ct,
80 enum ip_conntrack_info ctinfo,
81 struct PptpControlHeader *ctlh,
82 union pptp_ctrl_union *pptpReq);
83
84int
85(*ip_nat_pptp_hook_exp_gre)(struct ip_conntrack_expect *expect_orig,
86 struct ip_conntrack_expect *expect_reply);
87
88void
89(*ip_nat_pptp_hook_expectfn)(struct ip_conntrack *ct,
90 struct ip_conntrack_expect *exp);
91
92#if 0
93/* PptpControlMessageType names */
94const char *pptp_msg_name[] = {
95 "UNKNOWN_MESSAGE",
96 "START_SESSION_REQUEST",
97 "START_SESSION_REPLY",
98 "STOP_SESSION_REQUEST",
99 "STOP_SESSION_REPLY",
100 "ECHO_REQUEST",
101 "ECHO_REPLY",
102 "OUT_CALL_REQUEST",
103 "OUT_CALL_REPLY",
104 "IN_CALL_REQUEST",
105 "IN_CALL_REPLY",
106 "IN_CALL_CONNECT",
107 "CALL_CLEAR_REQUEST",
108 "CALL_DISCONNECT_NOTIFY",
109 "WAN_ERROR_NOTIFY",
110 "SET_LINK_INFO"
111};
112EXPORT_SYMBOL(pptp_msg_name);
113#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, __FUNCTION__, ## args)
114#else
115#define DEBUGP(format, args...)
116#endif
117
118#define SECS *HZ
119#define MINS * 60 SECS
120#define HOURS * 60 MINS
121
122#define PPTP_GRE_TIMEOUT (10 MINS)
123#define PPTP_GRE_STREAM_TIMEOUT (5 HOURS)
124
125static void pptp_expectfn(struct ip_conntrack *ct,
126 struct ip_conntrack_expect *exp)
127{
128 DEBUGP("increasing timeouts\n");
129
130 /* increase timeout of GRE data channel conntrack entry */
131 ct->proto.gre.timeout = PPTP_GRE_TIMEOUT;
132 ct->proto.gre.stream_timeout = PPTP_GRE_STREAM_TIMEOUT;
133
134 /* Can you see how rusty this code is, compared with the pre-2.6.11
135 * one? That's what happened to my shiny newnat of 2002 ;( -HW */
136
137 if (!ip_nat_pptp_hook_expectfn) {
138 struct ip_conntrack_tuple inv_t;
139 struct ip_conntrack_expect *exp_other;
140
141 /* obviously this tuple inversion only works until you do NAT */
142 invert_tuplepr(&inv_t, &exp->tuple);
143 DEBUGP("trying to unexpect other dir: ");
144 DUMP_TUPLE(&inv_t);
145
146 exp_other = ip_conntrack_expect_find(&inv_t);
147 if (exp_other) {
148 /* delete other expectation. */
149 DEBUGP("found\n");
150 ip_conntrack_unexpect_related(exp_other);
151 ip_conntrack_expect_put(exp_other);
152 } else {
153 DEBUGP("not found\n");
154 }
155 } else {
156 /* we need more than simple inversion */
157 ip_nat_pptp_hook_expectfn(ct, exp);
158 }
159}
160
161static int destroy_sibling_or_exp(const struct ip_conntrack_tuple *t)
162{
163 struct ip_conntrack_tuple_hash *h;
164 struct ip_conntrack_expect *exp;
165
166 DEBUGP("trying to timeout ct or exp for tuple ");
167 DUMP_TUPLE(t);
168
169 h = ip_conntrack_find_get(t, NULL);
170 if (h) {
171 struct ip_conntrack *sibling = tuplehash_to_ctrack(h);
172 DEBUGP("setting timeout of conntrack %p to 0\n", sibling);
173 sibling->proto.gre.timeout = 0;
174 sibling->proto.gre.stream_timeout = 0;
175 if (del_timer(&sibling->timeout))
176 sibling->timeout.function((unsigned long)sibling);
177 ip_conntrack_put(sibling);
178 return 1;
179 } else {
180 exp = ip_conntrack_expect_find(t);
181 if (exp) {
182 DEBUGP("unexpect_related of expect %p\n", exp);
183 ip_conntrack_unexpect_related(exp);
184 ip_conntrack_expect_put(exp);
185 return 1;
186 }
187 }
188
189 return 0;
190}
191
192
193/* timeout GRE data connections */
194static void pptp_destroy_siblings(struct ip_conntrack *ct)
195{
196 struct ip_conntrack_tuple t;
197
198 /* Since ct->sibling_list has literally rusted away in 2.6.11,
199 * we now need another way to find out about our sibling
200 * contrack and expects... -HW */
201
202 /* try original (pns->pac) tuple */
203 memcpy(&t, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, sizeof(t));
204 t.dst.protonum = IPPROTO_GRE;
205 t.src.u.gre.key = htons(ct->help.ct_pptp_info.pns_call_id);
206 t.dst.u.gre.key = htons(ct->help.ct_pptp_info.pac_call_id);
207
208 if (!destroy_sibling_or_exp(&t))
209 DEBUGP("failed to timeout original pns->pac ct/exp\n");
210
211 /* try reply (pac->pns) tuple */
212 memcpy(&t, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, sizeof(t));
213 t.dst.protonum = IPPROTO_GRE;
214 t.src.u.gre.key = htons(ct->help.ct_pptp_info.pac_call_id);
215 t.dst.u.gre.key = htons(ct->help.ct_pptp_info.pns_call_id);
216
217 if (!destroy_sibling_or_exp(&t))
218 DEBUGP("failed to timeout reply pac->pns ct/exp\n");
219}
220
221/* expect GRE connections (PNS->PAC and PAC->PNS direction) */
222static inline int
223exp_gre(struct ip_conntrack *master,
224 u_int32_t seq,
225 __be16 callid,
226 __be16 peer_callid)
227{
228 struct ip_conntrack_tuple inv_tuple;
229 struct ip_conntrack_tuple exp_tuples[] = {
230 /* tuple in original direction, PNS->PAC */
231 { .src = { .ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip,
232 .u = { .gre = { .key = peer_callid } }
233 },
234 .dst = { .ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip,
235 .u = { .gre = { .key = callid } },
236 .protonum = IPPROTO_GRE
237 },
238 },
239 /* tuple in reply direction, PAC->PNS */
240 { .src = { .ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip,
241 .u = { .gre = { .key = callid } }
242 },
243 .dst = { .ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip,
244 .u = { .gre = { .key = peer_callid } },
245 .protonum = IPPROTO_GRE
246 },
247 }
248 };
249 struct ip_conntrack_expect *exp_orig, *exp_reply;
250 int ret = 1;
251
252 exp_orig = ip_conntrack_expect_alloc(master);
253 if (exp_orig == NULL)
254 goto out;
255
256 exp_reply = ip_conntrack_expect_alloc(master);
257 if (exp_reply == NULL)
258 goto out_put_orig;
259
260 memcpy(&exp_orig->tuple, &exp_tuples[0], sizeof(exp_orig->tuple));
261
262 exp_orig->mask.src.ip = 0xffffffff;
263 exp_orig->mask.src.u.all = 0;
264 exp_orig->mask.dst.u.all = 0;
265 exp_orig->mask.dst.u.gre.key = htons(0xffff);
266 exp_orig->mask.dst.ip = 0xffffffff;
267 exp_orig->mask.dst.protonum = 0xff;
268
269 exp_orig->master = master;
270 exp_orig->expectfn = pptp_expectfn;
271 exp_orig->flags = 0;
272
273 exp_orig->dir = IP_CT_DIR_ORIGINAL;
274
275 /* both expectations are identical apart from tuple */
276 memcpy(exp_reply, exp_orig, sizeof(*exp_reply));
277 memcpy(&exp_reply->tuple, &exp_tuples[1], sizeof(exp_reply->tuple));
278
279 exp_reply->dir = !exp_orig->dir;
280
281 if (ip_nat_pptp_hook_exp_gre)
282 ret = ip_nat_pptp_hook_exp_gre(exp_orig, exp_reply);
283 else {
284
285 DEBUGP("calling expect_related PNS->PAC");
286 DUMP_TUPLE(&exp_orig->tuple);
287
288 if (ip_conntrack_expect_related(exp_orig) != 0) {
289 DEBUGP("cannot expect_related()\n");
290 goto out_put_both;
291 }
292
293 DEBUGP("calling expect_related PAC->PNS");
294 DUMP_TUPLE(&exp_reply->tuple);
295
296 if (ip_conntrack_expect_related(exp_reply) != 0) {
297 DEBUGP("cannot expect_related()\n");
298 goto out_unexpect_orig;
299 }
300
301 /* Add GRE keymap entries */
302 if (ip_ct_gre_keymap_add(master, &exp_reply->tuple, 0) != 0) {
303 DEBUGP("cannot keymap_add() exp\n");
304 goto out_unexpect_both;
305 }
306
307 invert_tuplepr(&inv_tuple, &exp_reply->tuple);
308 if (ip_ct_gre_keymap_add(master, &inv_tuple, 1) != 0) {
309 ip_ct_gre_keymap_destroy(master);
310 DEBUGP("cannot keymap_add() exp_inv\n");
311 goto out_unexpect_both;
312 }
313 ret = 0;
314 }
315
316out_put_both:
317 ip_conntrack_expect_put(exp_reply);
318out_put_orig:
319 ip_conntrack_expect_put(exp_orig);
320out:
321 return ret;
322
323out_unexpect_both:
324 ip_conntrack_unexpect_related(exp_reply);
325out_unexpect_orig:
326 ip_conntrack_unexpect_related(exp_orig);
327 goto out_put_both;
328}
329
330static inline int
331pptp_inbound_pkt(struct sk_buff **pskb,
332 struct tcphdr *tcph,
333 unsigned int nexthdr_off,
334 unsigned int datalen,
335 struct ip_conntrack *ct,
336 enum ip_conntrack_info ctinfo)
337{
338 struct PptpControlHeader _ctlh, *ctlh;
339 unsigned int reqlen;
340 union pptp_ctrl_union _pptpReq, *pptpReq;
341 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
342 u_int16_t msg;
343 __be16 *cid, *pcid;
344 u_int32_t seq;
345
346 ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh);
347 if (!ctlh) {
348 DEBUGP("error during skb_header_pointer\n");
349 return NF_ACCEPT;
350 }
351 nexthdr_off += sizeof(_ctlh);
352 datalen -= sizeof(_ctlh);
353
354 reqlen = datalen;
355 if (reqlen > sizeof(*pptpReq))
356 reqlen = sizeof(*pptpReq);
357 pptpReq = skb_header_pointer(*pskb, nexthdr_off, reqlen, &_pptpReq);
358 if (!pptpReq) {
359 DEBUGP("error during skb_header_pointer\n");
360 return NF_ACCEPT;
361 }
362
363 msg = ntohs(ctlh->messageType);
364 DEBUGP("inbound control message %s\n", pptp_msg_name[msg]);
365
366 switch (msg) {
367 case PPTP_START_SESSION_REPLY:
368 if (reqlen < sizeof(_pptpReq.srep)) {
369 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
370 break;
371 }
372
373 /* server confirms new control session */
374 if (info->sstate < PPTP_SESSION_REQUESTED) {
375 DEBUGP("%s without START_SESS_REQUEST\n",
376 pptp_msg_name[msg]);
377 break;
378 }
379 if (pptpReq->srep.resultCode == PPTP_START_OK)
380 info->sstate = PPTP_SESSION_CONFIRMED;
381 else
382 info->sstate = PPTP_SESSION_ERROR;
383 break;
384
385 case PPTP_STOP_SESSION_REPLY:
386 if (reqlen < sizeof(_pptpReq.strep)) {
387 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
388 break;
389 }
390
391 /* server confirms end of control session */
392 if (info->sstate > PPTP_SESSION_STOPREQ) {
393 DEBUGP("%s without STOP_SESS_REQUEST\n",
394 pptp_msg_name[msg]);
395 break;
396 }
397 if (pptpReq->strep.resultCode == PPTP_STOP_OK)
398 info->sstate = PPTP_SESSION_NONE;
399 else
400 info->sstate = PPTP_SESSION_ERROR;
401 break;
402
403 case PPTP_OUT_CALL_REPLY:
404 if (reqlen < sizeof(_pptpReq.ocack)) {
405 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
406 break;
407 }
408
409 /* server accepted call, we now expect GRE frames */
410 if (info->sstate != PPTP_SESSION_CONFIRMED) {
411 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
412 break;
413 }
414 if (info->cstate != PPTP_CALL_OUT_REQ &&
415 info->cstate != PPTP_CALL_OUT_CONF) {
416 DEBUGP("%s without OUTCALL_REQ\n", pptp_msg_name[msg]);
417 break;
418 }
419 if (pptpReq->ocack.resultCode != PPTP_OUTCALL_CONNECT) {
420 info->cstate = PPTP_CALL_NONE;
421 break;
422 }
423
424 cid = &pptpReq->ocack.callID;
425 pcid = &pptpReq->ocack.peersCallID;
426
427 info->pac_call_id = ntohs(*cid);
428
429 if (htons(info->pns_call_id) != *pcid) {
430 DEBUGP("%s for unknown callid %u\n",
431 pptp_msg_name[msg], ntohs(*pcid));
432 break;
433 }
434
435 DEBUGP("%s, CID=%X, PCID=%X\n", pptp_msg_name[msg],
436 ntohs(*cid), ntohs(*pcid));
437
438 info->cstate = PPTP_CALL_OUT_CONF;
439
440 seq = ntohl(tcph->seq) + sizeof(struct pptp_pkt_hdr)
441 + sizeof(struct PptpControlHeader)
442 + ((void *)pcid - (void *)pptpReq);
443
444 if (exp_gre(ct, seq, *cid, *pcid) != 0)
445 printk("ip_conntrack_pptp: error during exp_gre\n");
446 break;
447
448 case PPTP_IN_CALL_REQUEST:
449 if (reqlen < sizeof(_pptpReq.icack)) {
450 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
451 break;
452 }
453
454 /* server tells us about incoming call request */
455 if (info->sstate != PPTP_SESSION_CONFIRMED) {
456 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
457 break;
458 }
459 pcid = &pptpReq->icack.peersCallID;
460 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
461 info->cstate = PPTP_CALL_IN_REQ;
462 info->pac_call_id = ntohs(*pcid);
463 break;
464
465 case PPTP_IN_CALL_CONNECT:
466 if (reqlen < sizeof(_pptpReq.iccon)) {
467 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
468 break;
469 }
470
471 /* server tells us about incoming call established */
472 if (info->sstate != PPTP_SESSION_CONFIRMED) {
473 DEBUGP("%s but no session\n", pptp_msg_name[msg]);
474 break;
475 }
476 if (info->sstate != PPTP_CALL_IN_REP
477 && info->sstate != PPTP_CALL_IN_CONF) {
478 DEBUGP("%s but never sent IN_CALL_REPLY\n",
479 pptp_msg_name[msg]);
480 break;
481 }
482
483 pcid = &pptpReq->iccon.peersCallID;
484 cid = &info->pac_call_id;
485
486 if (info->pns_call_id != ntohs(*pcid)) {
487 DEBUGP("%s for unknown CallID %u\n",
488 pptp_msg_name[msg], ntohs(*pcid));
489 break;
490 }
491
492 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
493 info->cstate = PPTP_CALL_IN_CONF;
494
495 /* we expect a GRE connection from PAC to PNS */
496 seq = ntohl(tcph->seq) + sizeof(struct pptp_pkt_hdr)
497 + sizeof(struct PptpControlHeader)
498 + ((void *)pcid - (void *)pptpReq);
499
500 if (exp_gre(ct, seq, *cid, *pcid) != 0)
501 printk("ip_conntrack_pptp: error during exp_gre\n");
502
503 break;
504
505 case PPTP_CALL_DISCONNECT_NOTIFY:
506 if (reqlen < sizeof(_pptpReq.disc)) {
507 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
508 break;
509 }
510
511 /* server confirms disconnect */
512 cid = &pptpReq->disc.callID;
513 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*cid));
514 info->cstate = PPTP_CALL_NONE;
515
516 /* untrack this call id, unexpect GRE packets */
517 pptp_destroy_siblings(ct);
518 break;
519
520 case PPTP_WAN_ERROR_NOTIFY:
521 break;
522
523 case PPTP_ECHO_REQUEST:
524 case PPTP_ECHO_REPLY:
525 /* I don't have to explain these ;) */
526 break;
527 default:
528 DEBUGP("invalid %s (TY=%d)\n", (msg <= PPTP_MSG_MAX)
529 ? pptp_msg_name[msg]:pptp_msg_name[0], msg);
530 break;
531 }
532
533
534 if (ip_nat_pptp_hook_inbound)
535 return ip_nat_pptp_hook_inbound(pskb, ct, ctinfo, ctlh,
536 pptpReq);
537
538 return NF_ACCEPT;
539
540}
541
542static inline int
543pptp_outbound_pkt(struct sk_buff **pskb,
544 struct tcphdr *tcph,
545 unsigned int nexthdr_off,
546 unsigned int datalen,
547 struct ip_conntrack *ct,
548 enum ip_conntrack_info ctinfo)
549{
550 struct PptpControlHeader _ctlh, *ctlh;
551 unsigned int reqlen;
552 union pptp_ctrl_union _pptpReq, *pptpReq;
553 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
554 u_int16_t msg;
555 __be16 *cid, *pcid;
556
557 ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh);
558 if (!ctlh)
559 return NF_ACCEPT;
560 nexthdr_off += sizeof(_ctlh);
561 datalen -= sizeof(_ctlh);
562
563 reqlen = datalen;
564 if (reqlen > sizeof(*pptpReq))
565 reqlen = sizeof(*pptpReq);
566 pptpReq = skb_header_pointer(*pskb, nexthdr_off, reqlen, &_pptpReq);
567 if (!pptpReq)
568 return NF_ACCEPT;
569
570 msg = ntohs(ctlh->messageType);
571 DEBUGP("outbound control message %s\n", pptp_msg_name[msg]);
572
573 switch (msg) {
574 case PPTP_START_SESSION_REQUEST:
575 /* client requests for new control session */
576 if (info->sstate != PPTP_SESSION_NONE) {
577 DEBUGP("%s but we already have one",
578 pptp_msg_name[msg]);
579 }
580 info->sstate = PPTP_SESSION_REQUESTED;
581 break;
582 case PPTP_STOP_SESSION_REQUEST:
583 /* client requests end of control session */
584 info->sstate = PPTP_SESSION_STOPREQ;
585 break;
586
587 case PPTP_OUT_CALL_REQUEST:
588 if (reqlen < sizeof(_pptpReq.ocreq)) {
589 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
590 /* FIXME: break; */
591 }
592
593 /* client initiating connection to server */
594 if (info->sstate != PPTP_SESSION_CONFIRMED) {
595 DEBUGP("%s but no session\n",
596 pptp_msg_name[msg]);
597 break;
598 }
599 info->cstate = PPTP_CALL_OUT_REQ;
600 /* track PNS call id */
601 cid = &pptpReq->ocreq.callID;
602 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*cid));
603 info->pns_call_id = ntohs(*cid);
604 break;
605 case PPTP_IN_CALL_REPLY:
606 if (reqlen < sizeof(_pptpReq.icack)) {
607 DEBUGP("%s: short packet\n", pptp_msg_name[msg]);
608 break;
609 }
610
611 /* client answers incoming call */
612 if (info->cstate != PPTP_CALL_IN_REQ
613 && info->cstate != PPTP_CALL_IN_REP) {
614 DEBUGP("%s without incall_req\n",
615 pptp_msg_name[msg]);
616 break;
617 }
618 if (pptpReq->icack.resultCode != PPTP_INCALL_ACCEPT) {
619 info->cstate = PPTP_CALL_NONE;
620 break;
621 }
622 pcid = &pptpReq->icack.peersCallID;
623 if (info->pac_call_id != ntohs(*pcid)) {
624 DEBUGP("%s for unknown call %u\n",
625 pptp_msg_name[msg], ntohs(*pcid));
626 break;
627 }
628 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
629 /* part two of the three-way handshake */
630 info->cstate = PPTP_CALL_IN_REP;
631 info->pns_call_id = ntohs(pptpReq->icack.callID);
632 break;
633
634 case PPTP_CALL_CLEAR_REQUEST:
635 /* client requests hangup of call */
636 if (info->sstate != PPTP_SESSION_CONFIRMED) {
637 DEBUGP("CLEAR_CALL but no session\n");
638 break;
639 }
640 /* FUTURE: iterate over all calls and check if
641 * call ID is valid. We don't do this without newnat,
642 * because we only know about last call */
643 info->cstate = PPTP_CALL_CLEAR_REQ;
644 break;
645 case PPTP_SET_LINK_INFO:
646 break;
647 case PPTP_ECHO_REQUEST:
648 case PPTP_ECHO_REPLY:
649 /* I don't have to explain these ;) */
650 break;
651 default:
652 DEBUGP("invalid %s (TY=%d)\n", (msg <= PPTP_MSG_MAX)?
653 pptp_msg_name[msg]:pptp_msg_name[0], msg);
654 /* unknown: no need to create GRE masq table entry */
655 break;
656 }
657
658 if (ip_nat_pptp_hook_outbound)
659 return ip_nat_pptp_hook_outbound(pskb, ct, ctinfo, ctlh,
660 pptpReq);
661
662 return NF_ACCEPT;
663}
664
665
666/* track caller id inside control connection, call expect_related */
667static int
668conntrack_pptp_help(struct sk_buff **pskb,
669 struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
670
671{
672 struct pptp_pkt_hdr _pptph, *pptph;
673 struct tcphdr _tcph, *tcph;
674 u_int32_t tcplen = (*pskb)->len - (*pskb)->nh.iph->ihl * 4;
675 u_int32_t datalen;
676 int dir = CTINFO2DIR(ctinfo);
677 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
678 unsigned int nexthdr_off;
679
680 int oldsstate, oldcstate;
681 int ret;
682
683 /* don't do any tracking before tcp handshake complete */
684 if (ctinfo != IP_CT_ESTABLISHED
685 && ctinfo != IP_CT_ESTABLISHED+IP_CT_IS_REPLY) {
686 DEBUGP("ctinfo = %u, skipping\n", ctinfo);
687 return NF_ACCEPT;
688 }
689
690 nexthdr_off = (*pskb)->nh.iph->ihl*4;
691 tcph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_tcph), &_tcph);
692 BUG_ON(!tcph);
693 nexthdr_off += tcph->doff * 4;
694 datalen = tcplen - tcph->doff * 4;
695
696 if (tcph->fin || tcph->rst) {
697 DEBUGP("RST/FIN received, timeouting GRE\n");
698 /* can't do this after real newnat */
699 info->cstate = PPTP_CALL_NONE;
700
701 /* untrack this call id, unexpect GRE packets */
702 pptp_destroy_siblings(ct);
703 }
704
705 pptph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_pptph), &_pptph);
706 if (!pptph) {
707 DEBUGP("no full PPTP header, can't track\n");
708 return NF_ACCEPT;
709 }
710 nexthdr_off += sizeof(_pptph);
711 datalen -= sizeof(_pptph);
712
713 /* if it's not a control message we can't do anything with it */
714 if (ntohs(pptph->packetType) != PPTP_PACKET_CONTROL ||
715 ntohl(pptph->magicCookie) != PPTP_MAGIC_COOKIE) {
716 DEBUGP("not a control packet\n");
717 return NF_ACCEPT;
718 }
719
720 oldsstate = info->sstate;
721 oldcstate = info->cstate;
722
723 spin_lock_bh(&ip_pptp_lock);
724
725 /* FIXME: We just blindly assume that the control connection is always
726 * established from PNS->PAC. However, RFC makes no guarantee */
727 if (dir == IP_CT_DIR_ORIGINAL)
728 /* client -> server (PNS -> PAC) */
729 ret = pptp_outbound_pkt(pskb, tcph, nexthdr_off, datalen, ct,
730 ctinfo);
731 else
732 /* server -> client (PAC -> PNS) */
733 ret = pptp_inbound_pkt(pskb, tcph, nexthdr_off, datalen, ct,
734 ctinfo);
735 DEBUGP("sstate: %d->%d, cstate: %d->%d\n",
736 oldsstate, info->sstate, oldcstate, info->cstate);
737 spin_unlock_bh(&ip_pptp_lock);
738
739 return ret;
740}
741
742/* control protocol helper */
743static struct ip_conntrack_helper pptp = {
744 .list = { NULL, NULL },
745 .name = "pptp",
746 .me = THIS_MODULE,
747 .max_expected = 2,
748 .timeout = 5 * 60,
749 .tuple = { .src = { .ip = 0,
750 .u = { .tcp = { .port =
751 __constant_htons(PPTP_CONTROL_PORT) } }
752 },
753 .dst = { .ip = 0,
754 .u = { .all = 0 },
755 .protonum = IPPROTO_TCP
756 }
757 },
758 .mask = { .src = { .ip = 0,
759 .u = { .tcp = { .port = __constant_htons(0xffff) } }
760 },
761 .dst = { .ip = 0,
762 .u = { .all = 0 },
763 .protonum = 0xff
764 }
765 },
766 .help = conntrack_pptp_help
767};
768
769extern void __exit ip_ct_proto_gre_fini(void);
770extern int __init ip_ct_proto_gre_init(void);
771
772/* ip_conntrack_pptp initialization */
773static int __init init(void)
774{
775 int retcode;
776
777 retcode = ip_ct_proto_gre_init();
778 if (retcode < 0)
779 return retcode;
780
781 DEBUGP(" registering helper\n");
782 if ((retcode = ip_conntrack_helper_register(&pptp))) {
783 printk(KERN_ERR "Unable to register conntrack application "
784 "helper for pptp: %d\n", retcode);
785 ip_ct_proto_gre_fini();
786 return retcode;
787 }
788
789 printk("ip_conntrack_pptp version %s loaded\n", IP_CT_PPTP_VERSION);
790 return 0;
791}
792
793static void __exit fini(void)
794{
795 ip_conntrack_helper_unregister(&pptp);
796 ip_ct_proto_gre_fini();
797 printk("ip_conntrack_pptp version %s unloaded\n", IP_CT_PPTP_VERSION);
798}
799
800module_init(init);
801module_exit(fini);
802
803EXPORT_SYMBOL(ip_nat_pptp_hook_outbound);
804EXPORT_SYMBOL(ip_nat_pptp_hook_inbound);
805EXPORT_SYMBOL(ip_nat_pptp_hook_exp_gre);
806EXPORT_SYMBOL(ip_nat_pptp_hook_expectfn);
diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
index 71ef19d126d0..186646eb249f 100644
--- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
+++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
@@ -58,7 +58,7 @@ static int help(struct sk_buff **pskb,
58 goto out; 58 goto out;
59 59
60 rcu_read_lock(); 60 rcu_read_lock();
61 in_dev = __in_dev_get(rt->u.dst.dev); 61 in_dev = __in_dev_get_rcu(rt->u.dst.dev);
62 if (in_dev != NULL) { 62 if (in_dev != NULL) {
63 for_primary_ifa(in_dev) { 63 for_primary_ifa(in_dev) {
64 if (ifa->ifa_broadcast == iph->daddr) { 64 if (ifa->ifa_broadcast == iph->daddr) {
@@ -91,7 +91,7 @@ static int help(struct sk_buff **pskb,
91 ip_conntrack_expect_related(exp); 91 ip_conntrack_expect_related(exp);
92 ip_conntrack_expect_put(exp); 92 ip_conntrack_expect_put(exp);
93 93
94 ip_ct_refresh_acct(ct, ctinfo, NULL, timeout * HZ); 94 ip_ct_refresh(ct, *pskb, timeout * HZ);
95out: 95out:
96 return NF_ACCEPT; 96 return NF_ACCEPT;
97} 97}
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 15aef3564742..166e6069f121 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -177,11 +177,11 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct ip_conntrack *ct,
177 struct nfattr *nest_count = NFA_NEST(skb, type); 177 struct nfattr *nest_count = NFA_NEST(skb, type);
178 u_int64_t tmp; 178 u_int64_t tmp;
179 179
180 tmp = cpu_to_be64(ct->counters[dir].packets); 180 tmp = htonl(ct->counters[dir].packets);
181 NFA_PUT(skb, CTA_COUNTERS_PACKETS, sizeof(u_int64_t), &tmp); 181 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp);
182 182
183 tmp = cpu_to_be64(ct->counters[dir].bytes); 183 tmp = htonl(ct->counters[dir].bytes);
184 NFA_PUT(skb, CTA_COUNTERS_BYTES, sizeof(u_int64_t), &tmp); 184 NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp);
185 185
186 NFA_NEST_END(skb, nest_count); 186 NFA_NEST_END(skb, nest_count);
187 187
@@ -833,7 +833,8 @@ out:
833static inline int 833static inline int
834ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[]) 834ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[])
835{ 835{
836 unsigned long d, status = *(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1]); 836 unsigned long d;
837 unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1]));
837 d = ct->status ^ status; 838 d = ct->status ^ status;
838 839
839 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) 840 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
@@ -948,6 +949,31 @@ ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[])
948 return 0; 949 return 0;
949} 950}
950 951
952static inline int
953ctnetlink_change_protoinfo(struct ip_conntrack *ct, struct nfattr *cda[])
954{
955 struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1];
956 struct ip_conntrack_protocol *proto;
957 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum;
958 int err = 0;
959
960 if (nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr) < 0)
961 goto nfattr_failure;
962
963 proto = ip_conntrack_proto_find_get(npt);
964 if (!proto)
965 return -EINVAL;
966
967 if (proto->from_nfattr)
968 err = proto->from_nfattr(tb, ct);
969 ip_conntrack_proto_put(proto);
970
971 return err;
972
973nfattr_failure:
974 return -ENOMEM;
975}
976
951static int 977static int
952ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[]) 978ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
953{ 979{
@@ -973,6 +999,12 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
973 return err; 999 return err;
974 } 1000 }
975 1001
1002 if (cda[CTA_PROTOINFO-1]) {
1003 err = ctnetlink_change_protoinfo(ct, cda);
1004 if (err < 0)
1005 return err;
1006 }
1007
976 DEBUGP("all done\n"); 1008 DEBUGP("all done\n");
977 return 0; 1009 return 0;
978} 1010}
@@ -1002,6 +1034,12 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
1002 if (err < 0) 1034 if (err < 0)
1003 goto err; 1035 goto err;
1004 1036
1037 if (cda[CTA_PROTOINFO-1]) {
1038 err = ctnetlink_change_protoinfo(ct, cda);
1039 if (err < 0)
1040 return err;
1041 }
1042
1005 ct->helper = ip_conntrack_helper_find_get(rtuple); 1043 ct->helper = ip_conntrack_helper_find_get(rtuple);
1006 1044
1007 add_timer(&ct->timeout); 1045 add_timer(&ct->timeout);
@@ -1270,7 +1308,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1270 if (err < 0) 1308 if (err < 0)
1271 return err; 1309 return err;
1272 1310
1273 exp = ip_conntrack_expect_find_get(&tuple); 1311 exp = ip_conntrack_expect_find(&tuple);
1274 if (!exp) 1312 if (!exp)
1275 return -ENOENT; 1313 return -ENOENT;
1276 1314
@@ -1318,7 +1356,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1318 return err; 1356 return err;
1319 1357
1320 /* bump usage count to 2 */ 1358 /* bump usage count to 2 */
1321 exp = ip_conntrack_expect_find_get(&tuple); 1359 exp = ip_conntrack_expect_find(&tuple);
1322 if (!exp) 1360 if (!exp)
1323 return -ENOENT; 1361 return -ENOENT;
1324 1362
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_gre.c b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
new file mode 100644
index 000000000000..744abb9d377a
--- /dev/null
+++ b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
@@ -0,0 +1,328 @@
1/*
2 * ip_conntrack_proto_gre.c - Version 3.0
3 *
4 * Connection tracking protocol helper module for GRE.
5 *
6 * GRE is a generic encapsulation protocol, which is generally not very
7 * suited for NAT, as it has no protocol-specific part as port numbers.
8 *
9 * It has an optional key field, which may help us distinguishing two
10 * connections between the same two hosts.
11 *
12 * GRE is defined in RFC 1701 and RFC 1702, as well as RFC 2784
13 *
14 * PPTP is built on top of a modified version of GRE, and has a mandatory
15 * field called "CallID", which serves us for the same purpose as the key
16 * field in plain GRE.
17 *
18 * Documentation about PPTP can be found in RFC 2637
19 *
20 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
21 *
22 * Development of this code funded by Astaro AG (http://www.astaro.com/)
23 *
24 */
25
26#include <linux/config.h>
27#include <linux/module.h>
28#include <linux/types.h>
29#include <linux/timer.h>
30#include <linux/netfilter.h>
31#include <linux/ip.h>
32#include <linux/in.h>
33#include <linux/list.h>
34
35static DEFINE_RWLOCK(ip_ct_gre_lock);
36#define ASSERT_READ_LOCK(x)
37#define ASSERT_WRITE_LOCK(x)
38
39#include <linux/netfilter_ipv4/listhelp.h>
40#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
41#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
42#include <linux/netfilter_ipv4/ip_conntrack_core.h>
43
44#include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
45#include <linux/netfilter_ipv4/ip_conntrack_pptp.h>
46
47MODULE_LICENSE("GPL");
48MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
49MODULE_DESCRIPTION("netfilter connection tracking protocol helper for GRE");
50
51/* shamelessly stolen from ip_conntrack_proto_udp.c */
52#define GRE_TIMEOUT (30*HZ)
53#define GRE_STREAM_TIMEOUT (180*HZ)
54
55#if 0
56#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, __FUNCTION__, ## args)
57#define DUMP_TUPLE_GRE(x) printk("%u.%u.%u.%u:0x%x -> %u.%u.%u.%u:0x%x\n", \
58 NIPQUAD((x)->src.ip), ntohs((x)->src.u.gre.key), \
59 NIPQUAD((x)->dst.ip), ntohs((x)->dst.u.gre.key))
60#else
61#define DEBUGP(x, args...)
62#define DUMP_TUPLE_GRE(x)
63#endif
64
65/* GRE KEYMAP HANDLING FUNCTIONS */
66static LIST_HEAD(gre_keymap_list);
67
68static inline int gre_key_cmpfn(const struct ip_ct_gre_keymap *km,
69 const struct ip_conntrack_tuple *t)
70{
71 return ((km->tuple.src.ip == t->src.ip) &&
72 (km->tuple.dst.ip == t->dst.ip) &&
73 (km->tuple.dst.protonum == t->dst.protonum) &&
74 (km->tuple.dst.u.all == t->dst.u.all));
75}
76
77/* look up the source key for a given tuple */
78static u_int32_t gre_keymap_lookup(struct ip_conntrack_tuple *t)
79{
80 struct ip_ct_gre_keymap *km;
81 u_int32_t key = 0;
82
83 read_lock_bh(&ip_ct_gre_lock);
84 km = LIST_FIND(&gre_keymap_list, gre_key_cmpfn,
85 struct ip_ct_gre_keymap *, t);
86 if (km)
87 key = km->tuple.src.u.gre.key;
88 read_unlock_bh(&ip_ct_gre_lock);
89
90 DEBUGP("lookup src key 0x%x up key for ", key);
91 DUMP_TUPLE_GRE(t);
92
93 return key;
94}
95
96/* add a single keymap entry, associate with specified master ct */
97int
98ip_ct_gre_keymap_add(struct ip_conntrack *ct,
99 struct ip_conntrack_tuple *t, int reply)
100{
101 struct ip_ct_gre_keymap **exist_km, *km, *old;
102
103 if (!ct->helper || strcmp(ct->helper->name, "pptp")) {
104 DEBUGP("refusing to add GRE keymap to non-pptp session\n");
105 return -1;
106 }
107
108 if (!reply)
109 exist_km = &ct->help.ct_pptp_info.keymap_orig;
110 else
111 exist_km = &ct->help.ct_pptp_info.keymap_reply;
112
113 if (*exist_km) {
114 /* check whether it's a retransmission */
115 old = LIST_FIND(&gre_keymap_list, gre_key_cmpfn,
116 struct ip_ct_gre_keymap *, t);
117 if (old == *exist_km) {
118 DEBUGP("retransmission\n");
119 return 0;
120 }
121
122 DEBUGP("trying to override keymap_%s for ct %p\n",
123 reply? "reply":"orig", ct);
124 return -EEXIST;
125 }
126
127 km = kmalloc(sizeof(*km), GFP_ATOMIC);
128 if (!km)
129 return -ENOMEM;
130
131 memcpy(&km->tuple, t, sizeof(*t));
132 *exist_km = km;
133
134 DEBUGP("adding new entry %p: ", km);
135 DUMP_TUPLE_GRE(&km->tuple);
136
137 write_lock_bh(&ip_ct_gre_lock);
138 list_append(&gre_keymap_list, km);
139 write_unlock_bh(&ip_ct_gre_lock);
140
141 return 0;
142}
143
144/* destroy the keymap entries associated with specified master ct */
145void ip_ct_gre_keymap_destroy(struct ip_conntrack *ct)
146{
147 DEBUGP("entering for ct %p\n", ct);
148
149 if (!ct->helper || strcmp(ct->helper->name, "pptp")) {
150 DEBUGP("refusing to destroy GRE keymap to non-pptp session\n");
151 return;
152 }
153
154 write_lock_bh(&ip_ct_gre_lock);
155 if (ct->help.ct_pptp_info.keymap_orig) {
156 DEBUGP("removing %p from list\n",
157 ct->help.ct_pptp_info.keymap_orig);
158 list_del(&ct->help.ct_pptp_info.keymap_orig->list);
159 kfree(ct->help.ct_pptp_info.keymap_orig);
160 ct->help.ct_pptp_info.keymap_orig = NULL;
161 }
162 if (ct->help.ct_pptp_info.keymap_reply) {
163 DEBUGP("removing %p from list\n",
164 ct->help.ct_pptp_info.keymap_reply);
165 list_del(&ct->help.ct_pptp_info.keymap_reply->list);
166 kfree(ct->help.ct_pptp_info.keymap_reply);
167 ct->help.ct_pptp_info.keymap_reply = NULL;
168 }
169 write_unlock_bh(&ip_ct_gre_lock);
170}
171
172
173/* PUBLIC CONNTRACK PROTO HELPER FUNCTIONS */
174
175/* invert gre part of tuple */
176static int gre_invert_tuple(struct ip_conntrack_tuple *tuple,
177 const struct ip_conntrack_tuple *orig)
178{
179 tuple->dst.u.gre.key = orig->src.u.gre.key;
180 tuple->src.u.gre.key = orig->dst.u.gre.key;
181
182 return 1;
183}
184
185/* gre hdr info to tuple */
186static int gre_pkt_to_tuple(const struct sk_buff *skb,
187 unsigned int dataoff,
188 struct ip_conntrack_tuple *tuple)
189{
190 struct gre_hdr_pptp _pgrehdr, *pgrehdr;
191 u_int32_t srckey;
192 struct gre_hdr _grehdr, *grehdr;
193
194 /* first only delinearize old RFC1701 GRE header */
195 grehdr = skb_header_pointer(skb, dataoff, sizeof(_grehdr), &_grehdr);
196 if (!grehdr || grehdr->version != GRE_VERSION_PPTP) {
197 /* try to behave like "ip_conntrack_proto_generic" */
198 tuple->src.u.all = 0;
199 tuple->dst.u.all = 0;
200 return 1;
201 }
202
203 /* PPTP header is variable length, only need up to the call_id field */
204 pgrehdr = skb_header_pointer(skb, dataoff, 8, &_pgrehdr);
205 if (!pgrehdr)
206 return 1;
207
208 if (ntohs(grehdr->protocol) != GRE_PROTOCOL_PPTP) {
209 DEBUGP("GRE_VERSION_PPTP but unknown proto\n");
210 return 0;
211 }
212
213 tuple->dst.u.gre.key = pgrehdr->call_id;
214 srckey = gre_keymap_lookup(tuple);
215 tuple->src.u.gre.key = srckey;
216
217 return 1;
218}
219
220/* print gre part of tuple */
221static int gre_print_tuple(struct seq_file *s,
222 const struct ip_conntrack_tuple *tuple)
223{
224 return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
225 ntohs(tuple->src.u.gre.key),
226 ntohs(tuple->dst.u.gre.key));
227}
228
229/* print private data for conntrack */
230static int gre_print_conntrack(struct seq_file *s,
231 const struct ip_conntrack *ct)
232{
233 return seq_printf(s, "timeout=%u, stream_timeout=%u ",
234 (ct->proto.gre.timeout / HZ),
235 (ct->proto.gre.stream_timeout / HZ));
236}
237
238/* Returns verdict for packet, and may modify conntrack */
239static int gre_packet(struct ip_conntrack *ct,
240 const struct sk_buff *skb,
241 enum ip_conntrack_info conntrackinfo)
242{
243 /* If we've seen traffic both ways, this is a GRE connection.
244 * Extend timeout. */
245 if (ct->status & IPS_SEEN_REPLY) {
246 ip_ct_refresh_acct(ct, conntrackinfo, skb,
247 ct->proto.gre.stream_timeout);
248 /* Also, more likely to be important, and not a probe. */
249 set_bit(IPS_ASSURED_BIT, &ct->status);
250 ip_conntrack_event_cache(IPCT_STATUS, skb);
251 } else
252 ip_ct_refresh_acct(ct, conntrackinfo, skb,
253 ct->proto.gre.timeout);
254
255 return NF_ACCEPT;
256}
257
258/* Called when a new connection for this protocol found. */
259static int gre_new(struct ip_conntrack *ct,
260 const struct sk_buff *skb)
261{
262 DEBUGP(": ");
263 DUMP_TUPLE_GRE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
264
265 /* initialize to sane value. Ideally a conntrack helper
266 * (e.g. in case of pptp) is increasing them */
267 ct->proto.gre.stream_timeout = GRE_STREAM_TIMEOUT;
268 ct->proto.gre.timeout = GRE_TIMEOUT;
269
270 return 1;
271}
272
273/* Called when a conntrack entry has already been removed from the hashes
274 * and is about to be deleted from memory */
275static void gre_destroy(struct ip_conntrack *ct)
276{
277 struct ip_conntrack *master = ct->master;
278 DEBUGP(" entering\n");
279
280 if (!master)
281 DEBUGP("no master !?!\n");
282 else
283 ip_ct_gre_keymap_destroy(master);
284}
285
286/* protocol helper struct */
287static struct ip_conntrack_protocol gre = {
288 .proto = IPPROTO_GRE,
289 .name = "gre",
290 .pkt_to_tuple = gre_pkt_to_tuple,
291 .invert_tuple = gre_invert_tuple,
292 .print_tuple = gre_print_tuple,
293 .print_conntrack = gre_print_conntrack,
294 .packet = gre_packet,
295 .new = gre_new,
296 .destroy = gre_destroy,
297 .me = THIS_MODULE,
298#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
299 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
300 .tuple_to_nfattr = ip_ct_port_tuple_to_nfattr,
301 .nfattr_to_tuple = ip_ct_port_nfattr_to_tuple,
302#endif
303};
304
305/* ip_conntrack_proto_gre initialization */
306int __init ip_ct_proto_gre_init(void)
307{
308 return ip_conntrack_protocol_register(&gre);
309}
310
311void __exit ip_ct_proto_gre_fini(void)
312{
313 struct list_head *pos, *n;
314
315 /* delete all keymap entries */
316 write_lock_bh(&ip_ct_gre_lock);
317 list_for_each_safe(pos, n, &gre_keymap_list) {
318 DEBUGP("deleting keymap %p at module unload time\n", pos);
319 list_del(pos);
320 kfree(pos);
321 }
322 write_unlock_bh(&ip_ct_gre_lock);
323
324 ip_conntrack_protocol_unregister(&gre);
325}
326
327EXPORT_SYMBOL(ip_ct_gre_keymap_add);
328EXPORT_SYMBOL(ip_ct_gre_keymap_destroy);
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
index 838d1d69b36e..98f0015dd255 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -296,8 +296,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
296 struct ip_conntrack_tuple *tuple) 296 struct ip_conntrack_tuple *tuple)
297{ 297{
298 if (!tb[CTA_PROTO_ICMP_TYPE-1] 298 if (!tb[CTA_PROTO_ICMP_TYPE-1]
299 || !tb[CTA_PROTO_ICMP_CODE-1] 299 || !tb[CTA_PROTO_ICMP_CODE-1])
300 || !tb[CTA_PROTO_ICMP_ID-1])
301 return -1; 300 return -1;
302 301
303 tuple->dst.u.icmp.type = 302 tuple->dst.u.icmp.type =
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
index a875f35e576d..59a4a0111dd3 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
@@ -416,6 +416,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
416 && newconntrack == SCTP_CONNTRACK_ESTABLISHED) { 416 && newconntrack == SCTP_CONNTRACK_ESTABLISHED) {
417 DEBUGP("Setting assured bit\n"); 417 DEBUGP("Setting assured bit\n");
418 set_bit(IPS_ASSURED_BIT, &conntrack->status); 418 set_bit(IPS_ASSURED_BIT, &conntrack->status);
419 ip_conntrack_event_cache(IPCT_STATUS, skb);
419 } 420 }
420 421
421 return NF_ACCEPT; 422 return NF_ACCEPT;
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index 1985abc59d24..d6701cafbcc2 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -341,17 +341,43 @@ static int tcp_print_conntrack(struct seq_file *s,
341static int tcp_to_nfattr(struct sk_buff *skb, struct nfattr *nfa, 341static int tcp_to_nfattr(struct sk_buff *skb, struct nfattr *nfa,
342 const struct ip_conntrack *ct) 342 const struct ip_conntrack *ct)
343{ 343{
344 struct nfattr *nest_parms = NFA_NEST(skb, CTA_PROTOINFO_TCP);
345
344 read_lock_bh(&tcp_lock); 346 read_lock_bh(&tcp_lock);
345 NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t), 347 NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t),
346 &ct->proto.tcp.state); 348 &ct->proto.tcp.state);
347 read_unlock_bh(&tcp_lock); 349 read_unlock_bh(&tcp_lock);
348 350
351 NFA_NEST_END(skb, nest_parms);
352
349 return 0; 353 return 0;
350 354
351nfattr_failure: 355nfattr_failure:
352 read_unlock_bh(&tcp_lock); 356 read_unlock_bh(&tcp_lock);
353 return -1; 357 return -1;
354} 358}
359
360static int nfattr_to_tcp(struct nfattr *cda[], struct ip_conntrack *ct)
361{
362 struct nfattr *attr = cda[CTA_PROTOINFO_TCP-1];
363 struct nfattr *tb[CTA_PROTOINFO_TCP_MAX];
364
365 if (nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr) < 0)
366 goto nfattr_failure;
367
368 if (!tb[CTA_PROTOINFO_TCP_STATE-1])
369 return -EINVAL;
370
371 write_lock_bh(&tcp_lock);
372 ct->proto.tcp.state =
373 *(u_int8_t *)NFA_DATA(tb[CTA_PROTOINFO_TCP_STATE-1]);
374 write_unlock_bh(&tcp_lock);
375
376 return 0;
377
378nfattr_failure:
379 return -1;
380}
355#endif 381#endif
356 382
357static unsigned int get_conntrack_index(const struct tcphdr *tcph) 383static unsigned int get_conntrack_index(const struct tcphdr *tcph)
@@ -1014,7 +1040,8 @@ static int tcp_packet(struct ip_conntrack *conntrack,
1014 /* Set ASSURED if we see see valid ack in ESTABLISHED 1040 /* Set ASSURED if we see see valid ack in ESTABLISHED
1015 after SYN_RECV or a valid answer for a picked up 1041 after SYN_RECV or a valid answer for a picked up
1016 connection. */ 1042 connection. */
1017 set_bit(IPS_ASSURED_BIT, &conntrack->status); 1043 set_bit(IPS_ASSURED_BIT, &conntrack->status);
1044 ip_conntrack_event_cache(IPCT_STATUS, skb);
1018 } 1045 }
1019 ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout); 1046 ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout);
1020 1047
@@ -1122,6 +1149,7 @@ struct ip_conntrack_protocol ip_conntrack_protocol_tcp =
1122#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 1149#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
1123 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 1150 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
1124 .to_nfattr = tcp_to_nfattr, 1151 .to_nfattr = tcp_to_nfattr,
1152 .from_nfattr = nfattr_to_tcp,
1125 .tuple_to_nfattr = ip_ct_port_tuple_to_nfattr, 1153 .tuple_to_nfattr = ip_ct_port_tuple_to_nfattr,
1126 .nfattr_to_tuple = ip_ct_port_nfattr_to_tuple, 1154 .nfattr_to_tuple = ip_ct_port_nfattr_to_tuple,
1127#endif 1155#endif
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index ae3e3e655db5..dd476b191f4b 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -989,15 +989,15 @@ EXPORT_SYMBOL(need_ip_conntrack);
989EXPORT_SYMBOL(ip_conntrack_helper_register); 989EXPORT_SYMBOL(ip_conntrack_helper_register);
990EXPORT_SYMBOL(ip_conntrack_helper_unregister); 990EXPORT_SYMBOL(ip_conntrack_helper_unregister);
991EXPORT_SYMBOL(ip_ct_iterate_cleanup); 991EXPORT_SYMBOL(ip_ct_iterate_cleanup);
992EXPORT_SYMBOL(ip_ct_refresh_acct); 992EXPORT_SYMBOL(__ip_ct_refresh_acct);
993 993
994EXPORT_SYMBOL(ip_conntrack_expect_alloc); 994EXPORT_SYMBOL(ip_conntrack_expect_alloc);
995EXPORT_SYMBOL(ip_conntrack_expect_put); 995EXPORT_SYMBOL(ip_conntrack_expect_put);
996EXPORT_SYMBOL_GPL(ip_conntrack_expect_find_get); 996EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find);
997EXPORT_SYMBOL_GPL(ip_conntrack_expect_find);
997EXPORT_SYMBOL(ip_conntrack_expect_related); 998EXPORT_SYMBOL(ip_conntrack_expect_related);
998EXPORT_SYMBOL(ip_conntrack_unexpect_related); 999EXPORT_SYMBOL(ip_conntrack_unexpect_related);
999EXPORT_SYMBOL_GPL(ip_conntrack_expect_list); 1000EXPORT_SYMBOL_GPL(ip_conntrack_expect_list);
1000EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find);
1001EXPORT_SYMBOL_GPL(ip_ct_unlink_expect); 1001EXPORT_SYMBOL_GPL(ip_ct_unlink_expect);
1002 1002
1003EXPORT_SYMBOL(ip_conntrack_tuple_taken); 1003EXPORT_SYMBOL(ip_conntrack_tuple_taken);
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
index 1adedb743f60..c5e3abd24672 100644
--- a/net/ipv4/netfilter/ip_nat_core.c
+++ b/net/ipv4/netfilter/ip_nat_core.c
@@ -74,12 +74,14 @@ ip_nat_proto_find_get(u_int8_t protonum)
74 74
75 return p; 75 return p;
76} 76}
77EXPORT_SYMBOL_GPL(ip_nat_proto_find_get);
77 78
78void 79void
79ip_nat_proto_put(struct ip_nat_protocol *p) 80ip_nat_proto_put(struct ip_nat_protocol *p)
80{ 81{
81 module_put(p->me); 82 module_put(p->me);
82} 83}
84EXPORT_SYMBOL_GPL(ip_nat_proto_put);
83 85
84/* We keep an extra hash for each conntrack, for fast searching. */ 86/* We keep an extra hash for each conntrack, for fast searching. */
85static inline unsigned int 87static inline unsigned int
@@ -111,6 +113,7 @@ ip_nat_cheat_check(u_int32_t oldvalinv, u_int32_t newval, u_int16_t oldcheck)
111 return csum_fold(csum_partial((char *)diffs, sizeof(diffs), 113 return csum_fold(csum_partial((char *)diffs, sizeof(diffs),
112 oldcheck^0xFFFF)); 114 oldcheck^0xFFFF));
113} 115}
116EXPORT_SYMBOL(ip_nat_cheat_check);
114 117
115/* Is this tuple already taken? (not by us) */ 118/* Is this tuple already taken? (not by us) */
116int 119int
@@ -127,6 +130,7 @@ ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple,
127 invert_tuplepr(&reply, tuple); 130 invert_tuplepr(&reply, tuple);
128 return ip_conntrack_tuple_taken(&reply, ignored_conntrack); 131 return ip_conntrack_tuple_taken(&reply, ignored_conntrack);
129} 132}
133EXPORT_SYMBOL(ip_nat_used_tuple);
130 134
131/* If we source map this tuple so reply looks like reply_tuple, will 135/* If we source map this tuple so reply looks like reply_tuple, will
132 * that meet the constraints of range. */ 136 * that meet the constraints of range. */
@@ -347,6 +351,7 @@ ip_nat_setup_info(struct ip_conntrack *conntrack,
347 351
348 return NF_ACCEPT; 352 return NF_ACCEPT;
349} 353}
354EXPORT_SYMBOL(ip_nat_setup_info);
350 355
351/* Returns true if succeeded. */ 356/* Returns true if succeeded. */
352static int 357static int
@@ -387,10 +392,10 @@ manip_pkt(u_int16_t proto,
387} 392}
388 393
389/* Do packet manipulations according to ip_nat_setup_info. */ 394/* Do packet manipulations according to ip_nat_setup_info. */
390unsigned int nat_packet(struct ip_conntrack *ct, 395unsigned int ip_nat_packet(struct ip_conntrack *ct,
391 enum ip_conntrack_info ctinfo, 396 enum ip_conntrack_info ctinfo,
392 unsigned int hooknum, 397 unsigned int hooknum,
393 struct sk_buff **pskb) 398 struct sk_buff **pskb)
394{ 399{
395 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 400 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
396 unsigned long statusbit; 401 unsigned long statusbit;
@@ -417,12 +422,13 @@ unsigned int nat_packet(struct ip_conntrack *ct,
417 } 422 }
418 return NF_ACCEPT; 423 return NF_ACCEPT;
419} 424}
425EXPORT_SYMBOL_GPL(ip_nat_packet);
420 426
421/* Dir is direction ICMP is coming from (opposite to packet it contains) */ 427/* Dir is direction ICMP is coming from (opposite to packet it contains) */
422int icmp_reply_translation(struct sk_buff **pskb, 428int ip_nat_icmp_reply_translation(struct sk_buff **pskb,
423 struct ip_conntrack *ct, 429 struct ip_conntrack *ct,
424 enum ip_nat_manip_type manip, 430 enum ip_nat_manip_type manip,
425 enum ip_conntrack_dir dir) 431 enum ip_conntrack_dir dir)
426{ 432{
427 struct { 433 struct {
428 struct icmphdr icmp; 434 struct icmphdr icmp;
@@ -509,6 +515,7 @@ int icmp_reply_translation(struct sk_buff **pskb,
509 515
510 return 1; 516 return 1;
511} 517}
518EXPORT_SYMBOL_GPL(ip_nat_icmp_reply_translation);
512 519
513/* Protocol registration. */ 520/* Protocol registration. */
514int ip_nat_protocol_register(struct ip_nat_protocol *proto) 521int ip_nat_protocol_register(struct ip_nat_protocol *proto)
@@ -525,6 +532,7 @@ int ip_nat_protocol_register(struct ip_nat_protocol *proto)
525 write_unlock_bh(&ip_nat_lock); 532 write_unlock_bh(&ip_nat_lock);
526 return ret; 533 return ret;
527} 534}
535EXPORT_SYMBOL(ip_nat_protocol_register);
528 536
529/* Noone stores the protocol anywhere; simply delete it. */ 537/* Noone stores the protocol anywhere; simply delete it. */
530void ip_nat_protocol_unregister(struct ip_nat_protocol *proto) 538void ip_nat_protocol_unregister(struct ip_nat_protocol *proto)
@@ -536,6 +544,7 @@ void ip_nat_protocol_unregister(struct ip_nat_protocol *proto)
536 /* Someone could be still looking at the proto in a bh. */ 544 /* Someone could be still looking at the proto in a bh. */
537 synchronize_net(); 545 synchronize_net();
538} 546}
547EXPORT_SYMBOL(ip_nat_protocol_unregister);
539 548
540#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 549#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
541 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 550 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
@@ -578,9 +587,11 @@ ip_nat_port_nfattr_to_range(struct nfattr *tb[], struct ip_nat_range *range)
578 587
579 return ret; 588 return ret;
580} 589}
590EXPORT_SYMBOL_GPL(ip_nat_port_nfattr_to_range);
591EXPORT_SYMBOL_GPL(ip_nat_port_range_to_nfattr);
581#endif 592#endif
582 593
583int __init ip_nat_init(void) 594static int __init ip_nat_init(void)
584{ 595{
585 size_t i; 596 size_t i;
586 597
@@ -622,10 +633,14 @@ static int clean_nat(struct ip_conntrack *i, void *data)
622 return 0; 633 return 0;
623} 634}
624 635
625/* Not __exit: called from ip_nat_standalone.c:init_or_cleanup() --RR */ 636static void __exit ip_nat_cleanup(void)
626void ip_nat_cleanup(void)
627{ 637{
628 ip_ct_iterate_cleanup(&clean_nat, NULL); 638 ip_ct_iterate_cleanup(&clean_nat, NULL);
629 ip_conntrack_destroyed = NULL; 639 ip_conntrack_destroyed = NULL;
630 vfree(bysource); 640 vfree(bysource);
631} 641}
642
643MODULE_LICENSE("GPL");
644
645module_init(ip_nat_init);
646module_exit(ip_nat_cleanup);
diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
index d2dd5d313556..5d506e0564d5 100644
--- a/net/ipv4/netfilter/ip_nat_helper.c
+++ b/net/ipv4/netfilter/ip_nat_helper.c
@@ -199,6 +199,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
199 } 199 }
200 return 1; 200 return 1;
201} 201}
202EXPORT_SYMBOL(ip_nat_mangle_tcp_packet);
202 203
203/* Generic function for mangling variable-length address changes inside 204/* Generic function for mangling variable-length address changes inside
204 * NATed UDP connections (like the CONNECT DATA XXXXX MESG XXXXX INDEX XXXXX 205 * NATed UDP connections (like the CONNECT DATA XXXXX MESG XXXXX INDEX XXXXX
@@ -256,6 +257,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
256 257
257 return 1; 258 return 1;
258} 259}
260EXPORT_SYMBOL(ip_nat_mangle_udp_packet);
259 261
260/* Adjust one found SACK option including checksum correction */ 262/* Adjust one found SACK option including checksum correction */
261static void 263static void
@@ -399,6 +401,7 @@ ip_nat_seq_adjust(struct sk_buff **pskb,
399 401
400 return 1; 402 return 1;
401} 403}
404EXPORT_SYMBOL(ip_nat_seq_adjust);
402 405
403/* Setup NAT on this expected conntrack so it follows master. */ 406/* Setup NAT on this expected conntrack so it follows master. */
404/* If we fail to get a free NAT slot, we'll get dropped on confirm */ 407/* If we fail to get a free NAT slot, we'll get dropped on confirm */
@@ -425,3 +428,4 @@ void ip_nat_follow_master(struct ip_conntrack *ct,
425 /* hook doesn't matter, but it has to do destination manip */ 428 /* hook doesn't matter, but it has to do destination manip */
426 ip_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING); 429 ip_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
427} 430}
431EXPORT_SYMBOL(ip_nat_follow_master);
diff --git a/net/ipv4/netfilter/ip_nat_helper_pptp.c b/net/ipv4/netfilter/ip_nat_helper_pptp.c
new file mode 100644
index 000000000000..3cdd0684d30d
--- /dev/null
+++ b/net/ipv4/netfilter/ip_nat_helper_pptp.c
@@ -0,0 +1,401 @@
1/*
2 * ip_nat_pptp.c - Version 3.0
3 *
4 * NAT support for PPTP (Point to Point Tunneling Protocol).
5 * PPTP is a a protocol for creating virtual private networks.
6 * It is a specification defined by Microsoft and some vendors
7 * working with Microsoft. PPTP is built on top of a modified
8 * version of the Internet Generic Routing Encapsulation Protocol.
9 * GRE is defined in RFC 1701 and RFC 1702. Documentation of
10 * PPTP can be found in RFC 2637
11 *
12 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
13 *
14 * Development of this code funded by Astaro AG (http://www.astaro.com/)
15 *
16 * TODO: - NAT to a unique tuple, not to TCP source port
17 * (needs netfilter tuple reservation)
18 *
19 * Changes:
20 * 2002-02-10 - Version 1.3
21 * - Use ip_nat_mangle_tcp_packet() because of cloned skb's
22 * in local connections (Philip Craig <philipc@snapgear.com>)
23 * - add checks for magicCookie and pptp version
24 * - make argument list of pptp_{out,in}bound_packet() shorter
25 * - move to C99 style initializers
26 * - print version number at module loadtime
27 * 2003-09-22 - Version 1.5
28 * - use SNATed tcp sourceport as callid, since we get called before
29 * TCP header is mangled (Philip Craig <philipc@snapgear.com>)
30 * 2004-10-22 - Version 2.0
31 * - kernel 2.6.x version
32 * 2005-06-10 - Version 3.0
33 * - kernel >= 2.6.11 version,
34 * funded by Oxcoda NetBox Blue (http://www.netboxblue.com/)
35 *
36 */
37
38#include <linux/config.h>
39#include <linux/module.h>
40#include <linux/ip.h>
41#include <linux/tcp.h>
42#include <net/tcp.h>
43
44#include <linux/netfilter_ipv4/ip_nat.h>
45#include <linux/netfilter_ipv4/ip_nat_rule.h>
46#include <linux/netfilter_ipv4/ip_nat_helper.h>
47#include <linux/netfilter_ipv4/ip_nat_pptp.h>
48#include <linux/netfilter_ipv4/ip_conntrack_core.h>
49#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
50#include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
51#include <linux/netfilter_ipv4/ip_conntrack_pptp.h>
52
53#define IP_NAT_PPTP_VERSION "3.0"
54
55MODULE_LICENSE("GPL");
56MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
57MODULE_DESCRIPTION("Netfilter NAT helper module for PPTP");
58
59
60#if 0
61extern const char *pptp_msg_name[];
62#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, \
63 __FUNCTION__, ## args)
64#else
65#define DEBUGP(format, args...)
66#endif
67
68static void pptp_nat_expected(struct ip_conntrack *ct,
69 struct ip_conntrack_expect *exp)
70{
71 struct ip_conntrack *master = ct->master;
72 struct ip_conntrack_expect *other_exp;
73 struct ip_conntrack_tuple t;
74 struct ip_ct_pptp_master *ct_pptp_info;
75 struct ip_nat_pptp *nat_pptp_info;
76
77 ct_pptp_info = &master->help.ct_pptp_info;
78 nat_pptp_info = &master->nat.help.nat_pptp_info;
79
80 /* And here goes the grand finale of corrosion... */
81
82 if (exp->dir == IP_CT_DIR_ORIGINAL) {
83 DEBUGP("we are PNS->PAC\n");
84 /* therefore, build tuple for PAC->PNS */
85 t.src.ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip;
86 t.src.u.gre.key = htons(master->help.ct_pptp_info.pac_call_id);
87 t.dst.ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip;
88 t.dst.u.gre.key = htons(master->help.ct_pptp_info.pns_call_id);
89 t.dst.protonum = IPPROTO_GRE;
90 } else {
91 DEBUGP("we are PAC->PNS\n");
92 /* build tuple for PNS->PAC */
93 t.src.ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
94 t.src.u.gre.key =
95 htons(master->nat.help.nat_pptp_info.pns_call_id);
96 t.dst.ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip;
97 t.dst.u.gre.key =
98 htons(master->nat.help.nat_pptp_info.pac_call_id);
99 t.dst.protonum = IPPROTO_GRE;
100 }
101
102 DEBUGP("trying to unexpect other dir: ");
103 DUMP_TUPLE(&t);
104 other_exp = ip_conntrack_expect_find(&t);
105 if (other_exp) {
106 ip_conntrack_unexpect_related(other_exp);
107 ip_conntrack_expect_put(other_exp);
108 DEBUGP("success\n");
109 } else {
110 DEBUGP("not found!\n");
111 }
112
113 ip_nat_follow_master(ct, exp);
114}
115
116/* outbound packets == from PNS to PAC */
117static int
118pptp_outbound_pkt(struct sk_buff **pskb,
119 struct ip_conntrack *ct,
120 enum ip_conntrack_info ctinfo,
121 struct PptpControlHeader *ctlh,
122 union pptp_ctrl_union *pptpReq)
123
124{
125 struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info;
126 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
127
128 u_int16_t msg, *cid = NULL, new_callid;
129
130 new_callid = htons(ct_pptp_info->pns_call_id);
131
132 switch (msg = ntohs(ctlh->messageType)) {
133 case PPTP_OUT_CALL_REQUEST:
134 cid = &pptpReq->ocreq.callID;
135 /* FIXME: ideally we would want to reserve a call ID
136 * here. current netfilter NAT core is not able to do
137 * this :( For now we use TCP source port. This breaks
138 * multiple calls within one control session */
139
140 /* save original call ID in nat_info */
141 nat_pptp_info->pns_call_id = ct_pptp_info->pns_call_id;
142
143 /* don't use tcph->source since we are at a DSTmanip
144 * hook (e.g. PREROUTING) and pkt is not mangled yet */
145 new_callid = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.tcp.port;
146
147 /* save new call ID in ct info */
148 ct_pptp_info->pns_call_id = ntohs(new_callid);
149 break;
150 case PPTP_IN_CALL_REPLY:
151 cid = &pptpReq->icreq.callID;
152 break;
153 case PPTP_CALL_CLEAR_REQUEST:
154 cid = &pptpReq->clrreq.callID;
155 break;
156 default:
157 DEBUGP("unknown outbound packet 0x%04x:%s\n", msg,
158 (msg <= PPTP_MSG_MAX)?
159 pptp_msg_name[msg]:pptp_msg_name[0]);
160 /* fall through */
161
162 case PPTP_SET_LINK_INFO:
163 /* only need to NAT in case PAC is behind NAT box */
164 case PPTP_START_SESSION_REQUEST:
165 case PPTP_START_SESSION_REPLY:
166 case PPTP_STOP_SESSION_REQUEST:
167 case PPTP_STOP_SESSION_REPLY:
168 case PPTP_ECHO_REQUEST:
169 case PPTP_ECHO_REPLY:
170 /* no need to alter packet */
171 return NF_ACCEPT;
172 }
173
174 /* only OUT_CALL_REQUEST, IN_CALL_REPLY, CALL_CLEAR_REQUEST pass
175 * down to here */
176
177 IP_NF_ASSERT(cid);
178
179 DEBUGP("altering call id from 0x%04x to 0x%04x\n",
180 ntohs(*cid), ntohs(new_callid));
181
182 /* mangle packet */
183 if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
184 (void *)cid - ((void *)ctlh - sizeof(struct pptp_pkt_hdr)),
185 sizeof(new_callid),
186 (char *)&new_callid,
187 sizeof(new_callid)) == 0)
188 return NF_DROP;
189
190 return NF_ACCEPT;
191}
192
193static int
194pptp_exp_gre(struct ip_conntrack_expect *expect_orig,
195 struct ip_conntrack_expect *expect_reply)
196{
197 struct ip_ct_pptp_master *ct_pptp_info =
198 &expect_orig->master->help.ct_pptp_info;
199 struct ip_nat_pptp *nat_pptp_info =
200 &expect_orig->master->nat.help.nat_pptp_info;
201
202 struct ip_conntrack *ct = expect_orig->master;
203
204 struct ip_conntrack_tuple inv_t;
205 struct ip_conntrack_tuple *orig_t, *reply_t;
206
207 /* save original PAC call ID in nat_info */
208 nat_pptp_info->pac_call_id = ct_pptp_info->pac_call_id;
209
210 /* alter expectation */
211 orig_t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
212 reply_t = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
213
214 /* alter expectation for PNS->PAC direction */
215 invert_tuplepr(&inv_t, &expect_orig->tuple);
216 expect_orig->saved_proto.gre.key = htons(nat_pptp_info->pac_call_id);
217 expect_orig->tuple.src.u.gre.key = htons(nat_pptp_info->pns_call_id);
218 expect_orig->tuple.dst.u.gre.key = htons(ct_pptp_info->pac_call_id);
219 inv_t.src.ip = reply_t->src.ip;
220 inv_t.dst.ip = reply_t->dst.ip;
221 inv_t.src.u.gre.key = htons(nat_pptp_info->pac_call_id);
222 inv_t.dst.u.gre.key = htons(ct_pptp_info->pns_call_id);
223
224 if (!ip_conntrack_expect_related(expect_orig)) {
225 DEBUGP("successfully registered expect\n");
226 } else {
227 DEBUGP("can't expect_related(expect_orig)\n");
228 return 1;
229 }
230
231 /* alter expectation for PAC->PNS direction */
232 invert_tuplepr(&inv_t, &expect_reply->tuple);
233 expect_reply->saved_proto.gre.key = htons(nat_pptp_info->pns_call_id);
234 expect_reply->tuple.src.u.gre.key = htons(nat_pptp_info->pac_call_id);
235 expect_reply->tuple.dst.u.gre.key = htons(ct_pptp_info->pns_call_id);
236 inv_t.src.ip = orig_t->src.ip;
237 inv_t.dst.ip = orig_t->dst.ip;
238 inv_t.src.u.gre.key = htons(nat_pptp_info->pns_call_id);
239 inv_t.dst.u.gre.key = htons(ct_pptp_info->pac_call_id);
240
241 if (!ip_conntrack_expect_related(expect_reply)) {
242 DEBUGP("successfully registered expect\n");
243 } else {
244 DEBUGP("can't expect_related(expect_reply)\n");
245 ip_conntrack_unexpect_related(expect_orig);
246 return 1;
247 }
248
249 if (ip_ct_gre_keymap_add(ct, &expect_reply->tuple, 0) < 0) {
250 DEBUGP("can't register original keymap\n");
251 ip_conntrack_unexpect_related(expect_orig);
252 ip_conntrack_unexpect_related(expect_reply);
253 return 1;
254 }
255
256 if (ip_ct_gre_keymap_add(ct, &inv_t, 1) < 0) {
257 DEBUGP("can't register reply keymap\n");
258 ip_conntrack_unexpect_related(expect_orig);
259 ip_conntrack_unexpect_related(expect_reply);
260 ip_ct_gre_keymap_destroy(ct);
261 return 1;
262 }
263
264 return 0;
265}
266
267/* inbound packets == from PAC to PNS */
268static int
269pptp_inbound_pkt(struct sk_buff **pskb,
270 struct ip_conntrack *ct,
271 enum ip_conntrack_info ctinfo,
272 struct PptpControlHeader *ctlh,
273 union pptp_ctrl_union *pptpReq)
274{
275 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
276 u_int16_t msg, new_cid = 0, new_pcid, *pcid = NULL, *cid = NULL;
277
278 int ret = NF_ACCEPT, rv;
279
280 new_pcid = htons(nat_pptp_info->pns_call_id);
281
282 switch (msg = ntohs(ctlh->messageType)) {
283 case PPTP_OUT_CALL_REPLY:
284 pcid = &pptpReq->ocack.peersCallID;
285 cid = &pptpReq->ocack.callID;
286 break;
287 case PPTP_IN_CALL_CONNECT:
288 pcid = &pptpReq->iccon.peersCallID;
289 break;
290 case PPTP_IN_CALL_REQUEST:
291 /* only need to nat in case PAC is behind NAT box */
292 break;
293 case PPTP_WAN_ERROR_NOTIFY:
294 pcid = &pptpReq->wanerr.peersCallID;
295 break;
296 case PPTP_CALL_DISCONNECT_NOTIFY:
297 pcid = &pptpReq->disc.callID;
298 break;
299 case PPTP_SET_LINK_INFO:
300 pcid = &pptpReq->setlink.peersCallID;
301 break;
302
303 default:
304 DEBUGP("unknown inbound packet %s\n", (msg <= PPTP_MSG_MAX)?
305 pptp_msg_name[msg]:pptp_msg_name[0]);
306 /* fall through */
307
308 case PPTP_START_SESSION_REQUEST:
309 case PPTP_START_SESSION_REPLY:
310 case PPTP_STOP_SESSION_REQUEST:
311 case PPTP_STOP_SESSION_REPLY:
312 case PPTP_ECHO_REQUEST:
313 case PPTP_ECHO_REPLY:
314 /* no need to alter packet */
315 return NF_ACCEPT;
316 }
317
318 /* only OUT_CALL_REPLY, IN_CALL_CONNECT, IN_CALL_REQUEST,
319 * WAN_ERROR_NOTIFY, CALL_DISCONNECT_NOTIFY pass down here */
320
321 /* mangle packet */
322 IP_NF_ASSERT(pcid);
323 DEBUGP("altering peer call id from 0x%04x to 0x%04x\n",
324 ntohs(*pcid), ntohs(new_pcid));
325
326 rv = ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
327 (void *)pcid - ((void *)ctlh - sizeof(struct pptp_pkt_hdr)),
328 sizeof(new_pcid), (char *)&new_pcid,
329 sizeof(new_pcid));
330 if (rv != NF_ACCEPT)
331 return rv;
332
333 if (new_cid) {
334 IP_NF_ASSERT(cid);
335 DEBUGP("altering call id from 0x%04x to 0x%04x\n",
336 ntohs(*cid), ntohs(new_cid));
337 rv = ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
338 (void *)cid - ((void *)ctlh - sizeof(struct pptp_pkt_hdr)),
339 sizeof(new_cid),
340 (char *)&new_cid,
341 sizeof(new_cid));
342 if (rv != NF_ACCEPT)
343 return rv;
344 }
345
346 /* check for earlier return value of 'switch' above */
347 if (ret != NF_ACCEPT)
348 return ret;
349
350 /* great, at least we don't need to resize packets */
351 return NF_ACCEPT;
352}
353
354
355extern int __init ip_nat_proto_gre_init(void);
356extern void __exit ip_nat_proto_gre_fini(void);
357
358static int __init init(void)
359{
360 int ret;
361
362 DEBUGP("%s: registering NAT helper\n", __FILE__);
363
364 ret = ip_nat_proto_gre_init();
365 if (ret < 0)
366 return ret;
367
368 BUG_ON(ip_nat_pptp_hook_outbound);
369 ip_nat_pptp_hook_outbound = &pptp_outbound_pkt;
370
371 BUG_ON(ip_nat_pptp_hook_inbound);
372 ip_nat_pptp_hook_inbound = &pptp_inbound_pkt;
373
374 BUG_ON(ip_nat_pptp_hook_exp_gre);
375 ip_nat_pptp_hook_exp_gre = &pptp_exp_gre;
376
377 BUG_ON(ip_nat_pptp_hook_expectfn);
378 ip_nat_pptp_hook_expectfn = &pptp_nat_expected;
379
380 printk("ip_nat_pptp version %s loaded\n", IP_NAT_PPTP_VERSION);
381 return 0;
382}
383
384static void __exit fini(void)
385{
386 DEBUGP("cleanup_module\n" );
387
388 ip_nat_pptp_hook_expectfn = NULL;
389 ip_nat_pptp_hook_exp_gre = NULL;
390 ip_nat_pptp_hook_inbound = NULL;
391 ip_nat_pptp_hook_outbound = NULL;
392
393 ip_nat_proto_gre_fini();
394 /* Make sure noone calls it, meanwhile */
395 synchronize_net();
396
397 printk("ip_nat_pptp version %s unloaded\n", IP_NAT_PPTP_VERSION);
398}
399
400module_init(init);
401module_exit(fini);
diff --git a/net/ipv4/netfilter/ip_nat_proto_gre.c b/net/ipv4/netfilter/ip_nat_proto_gre.c
new file mode 100644
index 000000000000..7c1285401672
--- /dev/null
+++ b/net/ipv4/netfilter/ip_nat_proto_gre.c
@@ -0,0 +1,214 @@
1/*
2 * ip_nat_proto_gre.c - Version 2.0
3 *
4 * NAT protocol helper module for GRE.
5 *
6 * GRE is a generic encapsulation protocol, which is generally not very
7 * suited for NAT, as it has no protocol-specific part as port numbers.
8 *
9 * It has an optional key field, which may help us distinguishing two
10 * connections between the same two hosts.
11 *
12 * GRE is defined in RFC 1701 and RFC 1702, as well as RFC 2784
13 *
14 * PPTP is built on top of a modified version of GRE, and has a mandatory
15 * field called "CallID", which serves us for the same purpose as the key
16 * field in plain GRE.
17 *
18 * Documentation about PPTP can be found in RFC 2637
19 *
20 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
21 *
22 * Development of this code funded by Astaro AG (http://www.astaro.com/)
23 *
24 */
25
26#include <linux/config.h>
27#include <linux/module.h>
28#include <linux/ip.h>
29#include <linux/netfilter_ipv4/ip_nat.h>
30#include <linux/netfilter_ipv4/ip_nat_rule.h>
31#include <linux/netfilter_ipv4/ip_nat_protocol.h>
32#include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h>
33
34MODULE_LICENSE("GPL");
35MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
36MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE");
37
38#if 0
39#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, \
40 __FUNCTION__, ## args)
41#else
42#define DEBUGP(x, args...)
43#endif
44
45/* is key in given range between min and max */
46static int
47gre_in_range(const struct ip_conntrack_tuple *tuple,
48 enum ip_nat_manip_type maniptype,
49 const union ip_conntrack_manip_proto *min,
50 const union ip_conntrack_manip_proto *max)
51{
52 u_int32_t key;
53
54 if (maniptype == IP_NAT_MANIP_SRC)
55 key = tuple->src.u.gre.key;
56 else
57 key = tuple->dst.u.gre.key;
58
59 return ntohl(key) >= ntohl(min->gre.key)
60 && ntohl(key) <= ntohl(max->gre.key);
61}
62
63/* generate unique tuple ... */
64static int
65gre_unique_tuple(struct ip_conntrack_tuple *tuple,
66 const struct ip_nat_range *range,
67 enum ip_nat_manip_type maniptype,
68 const struct ip_conntrack *conntrack)
69{
70 static u_int16_t key;
71 u_int16_t *keyptr;
72 unsigned int min, i, range_size;
73
74 if (maniptype == IP_NAT_MANIP_SRC)
75 keyptr = &tuple->src.u.gre.key;
76 else
77 keyptr = &tuple->dst.u.gre.key;
78
79 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
80 DEBUGP("%p: NATing GRE PPTP\n", conntrack);
81 min = 1;
82 range_size = 0xffff;
83 } else {
84 min = ntohl(range->min.gre.key);
85 range_size = ntohl(range->max.gre.key) - min + 1;
86 }
87
88 DEBUGP("min = %u, range_size = %u\n", min, range_size);
89
90 for (i = 0; i < range_size; i++, key++) {
91 *keyptr = htonl(min + key % range_size);
92 if (!ip_nat_used_tuple(tuple, conntrack))
93 return 1;
94 }
95
96 DEBUGP("%p: no NAT mapping\n", conntrack);
97
98 return 0;
99}
100
101/* manipulate a GRE packet according to maniptype */
102static int
103gre_manip_pkt(struct sk_buff **pskb,
104 unsigned int iphdroff,
105 const struct ip_conntrack_tuple *tuple,
106 enum ip_nat_manip_type maniptype)
107{
108 struct gre_hdr *greh;
109 struct gre_hdr_pptp *pgreh;
110 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
111 unsigned int hdroff = iphdroff + iph->ihl*4;
112
113 /* pgreh includes two optional 32bit fields which are not required
114 * to be there. That's where the magic '8' comes from */
115 if (!skb_make_writable(pskb, hdroff + sizeof(*pgreh)-8))
116 return 0;
117
118 greh = (void *)(*pskb)->data + hdroff;
119 pgreh = (struct gre_hdr_pptp *) greh;
120
121 /* we only have destination manip of a packet, since 'source key'
122 * is not present in the packet itself */
123 if (maniptype == IP_NAT_MANIP_DST) {
124 /* key manipulation is always dest */
125 switch (greh->version) {
126 case 0:
127 if (!greh->key) {
128 DEBUGP("can't nat GRE w/o key\n");
129 break;
130 }
131 if (greh->csum) {
132 /* FIXME: Never tested this code... */
133 *(gre_csum(greh)) =
134 ip_nat_cheat_check(~*(gre_key(greh)),
135 tuple->dst.u.gre.key,
136 *(gre_csum(greh)));
137 }
138 *(gre_key(greh)) = tuple->dst.u.gre.key;
139 break;
140 case GRE_VERSION_PPTP:
141 DEBUGP("call_id -> 0x%04x\n",
142 ntohl(tuple->dst.u.gre.key));
143 pgreh->call_id = htons(ntohl(tuple->dst.u.gre.key));
144 break;
145 default:
146 DEBUGP("can't nat unknown GRE version\n");
147 return 0;
148 break;
149 }
150 }
151 return 1;
152}
153
154/* print out a nat tuple */
155static unsigned int
156gre_print(char *buffer,
157 const struct ip_conntrack_tuple *match,
158 const struct ip_conntrack_tuple *mask)
159{
160 unsigned int len = 0;
161
162 if (mask->src.u.gre.key)
163 len += sprintf(buffer + len, "srckey=0x%x ",
164 ntohl(match->src.u.gre.key));
165
166 if (mask->dst.u.gre.key)
167 len += sprintf(buffer + len, "dstkey=0x%x ",
168 ntohl(match->src.u.gre.key));
169
170 return len;
171}
172
173/* print a range of keys */
174static unsigned int
175gre_print_range(char *buffer, const struct ip_nat_range *range)
176{
177 if (range->min.gre.key != 0
178 || range->max.gre.key != 0xFFFF) {
179 if (range->min.gre.key == range->max.gre.key)
180 return sprintf(buffer, "key 0x%x ",
181 ntohl(range->min.gre.key));
182 else
183 return sprintf(buffer, "keys 0x%u-0x%u ",
184 ntohl(range->min.gre.key),
185 ntohl(range->max.gre.key));
186 } else
187 return 0;
188}
189
190/* nat helper struct */
191static struct ip_nat_protocol gre = {
192 .name = "GRE",
193 .protonum = IPPROTO_GRE,
194 .manip_pkt = gre_manip_pkt,
195 .in_range = gre_in_range,
196 .unique_tuple = gre_unique_tuple,
197 .print = gre_print,
198 .print_range = gre_print_range,
199#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
200 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
201 .range_to_nfattr = ip_nat_port_range_to_nfattr,
202 .nfattr_to_range = ip_nat_port_nfattr_to_range,
203#endif
204};
205
206int __init ip_nat_proto_gre_init(void)
207{
208 return ip_nat_protocol_register(&gre);
209}
210
211void __exit ip_nat_proto_gre_fini(void)
212{
213 ip_nat_protocol_unregister(&gre);
214}
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index 0ff368b131f6..30cd4e18c129 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -108,8 +108,8 @@ ip_nat_fn(unsigned int hooknum,
108 case IP_CT_RELATED: 108 case IP_CT_RELATED:
109 case IP_CT_RELATED+IP_CT_IS_REPLY: 109 case IP_CT_RELATED+IP_CT_IS_REPLY:
110 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) { 110 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
111 if (!icmp_reply_translation(pskb, ct, maniptype, 111 if (!ip_nat_icmp_reply_translation(pskb, ct, maniptype,
112 CTINFO2DIR(ctinfo))) 112 CTINFO2DIR(ctinfo)))
113 return NF_DROP; 113 return NF_DROP;
114 else 114 else
115 return NF_ACCEPT; 115 return NF_ACCEPT;
@@ -152,7 +152,7 @@ ip_nat_fn(unsigned int hooknum,
152 } 152 }
153 153
154 IP_NF_ASSERT(info); 154 IP_NF_ASSERT(info);
155 return nat_packet(ct, ctinfo, hooknum, pskb); 155 return ip_nat_packet(ct, ctinfo, hooknum, pskb);
156} 156}
157 157
158static unsigned int 158static unsigned int
@@ -325,15 +325,10 @@ static int init_or_cleanup(int init)
325 printk("ip_nat_init: can't setup rules.\n"); 325 printk("ip_nat_init: can't setup rules.\n");
326 goto cleanup_nothing; 326 goto cleanup_nothing;
327 } 327 }
328 ret = ip_nat_init();
329 if (ret < 0) {
330 printk("ip_nat_init: can't setup rules.\n");
331 goto cleanup_rule_init;
332 }
333 ret = nf_register_hook(&ip_nat_in_ops); 328 ret = nf_register_hook(&ip_nat_in_ops);
334 if (ret < 0) { 329 if (ret < 0) {
335 printk("ip_nat_init: can't register in hook.\n"); 330 printk("ip_nat_init: can't register in hook.\n");
336 goto cleanup_nat; 331 goto cleanup_rule_init;
337 } 332 }
338 ret = nf_register_hook(&ip_nat_out_ops); 333 ret = nf_register_hook(&ip_nat_out_ops);
339 if (ret < 0) { 334 if (ret < 0) {
@@ -374,8 +369,6 @@ static int init_or_cleanup(int init)
374 nf_unregister_hook(&ip_nat_out_ops); 369 nf_unregister_hook(&ip_nat_out_ops);
375 cleanup_inops: 370 cleanup_inops:
376 nf_unregister_hook(&ip_nat_in_ops); 371 nf_unregister_hook(&ip_nat_in_ops);
377 cleanup_nat:
378 ip_nat_cleanup();
379 cleanup_rule_init: 372 cleanup_rule_init:
380 ip_nat_rule_cleanup(); 373 ip_nat_rule_cleanup();
381 cleanup_nothing: 374 cleanup_nothing:
@@ -395,14 +388,4 @@ static void __exit fini(void)
395module_init(init); 388module_init(init);
396module_exit(fini); 389module_exit(fini);
397 390
398EXPORT_SYMBOL(ip_nat_setup_info);
399EXPORT_SYMBOL(ip_nat_protocol_register);
400EXPORT_SYMBOL(ip_nat_protocol_unregister);
401EXPORT_SYMBOL_GPL(ip_nat_proto_find_get);
402EXPORT_SYMBOL_GPL(ip_nat_proto_put);
403EXPORT_SYMBOL(ip_nat_cheat_check);
404EXPORT_SYMBOL(ip_nat_mangle_tcp_packet);
405EXPORT_SYMBOL(ip_nat_mangle_udp_packet);
406EXPORT_SYMBOL(ip_nat_used_tuple);
407EXPORT_SYMBOL(ip_nat_follow_master);
408MODULE_LICENSE("GPL"); 391MODULE_LICENSE("GPL");
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index d54f14d926f6..36339eb39e17 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -240,8 +240,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
240 240
241 pmsg->packet_id = (unsigned long )entry; 241 pmsg->packet_id = (unsigned long )entry;
242 pmsg->data_len = data_len; 242 pmsg->data_len = data_len;
243 pmsg->timestamp_sec = skb_tv_base.tv_sec + entry->skb->tstamp.off_sec; 243 pmsg->timestamp_sec = entry->skb->tstamp.off_sec;
244 pmsg->timestamp_usec = skb_tv_base.tv_usec + entry->skb->tstamp.off_usec; 244 pmsg->timestamp_usec = entry->skb->tstamp.off_usec;
245 pmsg->mark = entry->skb->nfmark; 245 pmsg->mark = entry->skb->nfmark;
246 pmsg->hook = entry->info->hook; 246 pmsg->hook = entry->info->hook;
247 pmsg->hw_protocol = entry->skb->protocol; 247 pmsg->hw_protocol = entry->skb->protocol;
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index eef99a1b5de6..75c27e92f6ab 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -27,6 +27,7 @@
27#include <asm/semaphore.h> 27#include <asm/semaphore.h>
28#include <linux/proc_fs.h> 28#include <linux/proc_fs.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/cpumask.h>
30 31
31#include <linux/netfilter_ipv4/ip_tables.h> 32#include <linux/netfilter_ipv4/ip_tables.h>
32 33
@@ -921,8 +922,10 @@ translate_table(const char *name,
921 } 922 }
922 923
923 /* And one copy for every other CPU */ 924 /* And one copy for every other CPU */
924 for (i = 1; i < num_possible_cpus(); i++) { 925 for_each_cpu(i) {
925 memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i, 926 if (i == 0)
927 continue;
928 memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i,
926 newinfo->entries, 929 newinfo->entries,
927 SMP_ALIGN(newinfo->size)); 930 SMP_ALIGN(newinfo->size));
928 } 931 }
@@ -943,7 +946,7 @@ replace_table(struct ipt_table *table,
943 struct ipt_entry *table_base; 946 struct ipt_entry *table_base;
944 unsigned int i; 947 unsigned int i;
945 948
946 for (i = 0; i < num_possible_cpus(); i++) { 949 for_each_cpu(i) {
947 table_base = 950 table_base =
948 (void *)newinfo->entries 951 (void *)newinfo->entries
949 + TABLE_OFFSET(newinfo, i); 952 + TABLE_OFFSET(newinfo, i);
@@ -990,7 +993,7 @@ get_counters(const struct ipt_table_info *t,
990 unsigned int cpu; 993 unsigned int cpu;
991 unsigned int i; 994 unsigned int i;
992 995
993 for (cpu = 0; cpu < num_possible_cpus(); cpu++) { 996 for_each_cpu(cpu) {
994 i = 0; 997 i = 0;
995 IPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), 998 IPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu),
996 t->size, 999 t->size,
@@ -1128,7 +1131,8 @@ do_replace(void __user *user, unsigned int len)
1128 return -ENOMEM; 1131 return -ENOMEM;
1129 1132
1130 newinfo = vmalloc(sizeof(struct ipt_table_info) 1133 newinfo = vmalloc(sizeof(struct ipt_table_info)
1131 + SMP_ALIGN(tmp.size) * num_possible_cpus()); 1134 + SMP_ALIGN(tmp.size) *
1135 (highest_possible_processor_id()+1));
1132 if (!newinfo) 1136 if (!newinfo)
1133 return -ENOMEM; 1137 return -ENOMEM;
1134 1138
@@ -1458,7 +1462,8 @@ int ipt_register_table(struct ipt_table *table, const struct ipt_replace *repl)
1458 = { 0, 0, 0, { 0 }, { 0 }, { } }; 1462 = { 0, 0, 0, { 0 }, { 0 }, { } };
1459 1463
1460 newinfo = vmalloc(sizeof(struct ipt_table_info) 1464 newinfo = vmalloc(sizeof(struct ipt_table_info)
1461 + SMP_ALIGN(repl->size) * num_possible_cpus()); 1465 + SMP_ALIGN(repl->size) *
1466 (highest_possible_processor_id()+1));
1462 if (!newinfo) 1467 if (!newinfo)
1463 return -ENOMEM; 1468 return -ENOMEM;
1464 1469
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 7d38913754b1..9bcb398fbc1f 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -13,6 +13,7 @@
13#include <linux/config.h> 13#include <linux/config.h>
14#include <linux/proc_fs.h> 14#include <linux/proc_fs.h>
15#include <linux/jhash.h> 15#include <linux/jhash.h>
16#include <linux/bitops.h>
16#include <linux/skbuff.h> 17#include <linux/skbuff.h>
17#include <linux/ip.h> 18#include <linux/ip.h>
18#include <linux/tcp.h> 19#include <linux/tcp.h>
@@ -30,7 +31,7 @@
30#include <linux/netfilter_ipv4/ipt_CLUSTERIP.h> 31#include <linux/netfilter_ipv4/ipt_CLUSTERIP.h>
31#include <linux/netfilter_ipv4/ip_conntrack.h> 32#include <linux/netfilter_ipv4/ip_conntrack.h>
32 33
33#define CLUSTERIP_VERSION "0.7" 34#define CLUSTERIP_VERSION "0.8"
34 35
35#define DEBUG_CLUSTERIP 36#define DEBUG_CLUSTERIP
36 37
@@ -49,13 +50,14 @@ MODULE_DESCRIPTION("iptables target for CLUSTERIP");
49struct clusterip_config { 50struct clusterip_config {
50 struct list_head list; /* list of all configs */ 51 struct list_head list; /* list of all configs */
51 atomic_t refcount; /* reference count */ 52 atomic_t refcount; /* reference count */
53 atomic_t entries; /* number of entries/rules
54 * referencing us */
52 55
53 u_int32_t clusterip; /* the IP address */ 56 u_int32_t clusterip; /* the IP address */
54 u_int8_t clustermac[ETH_ALEN]; /* the MAC address */ 57 u_int8_t clustermac[ETH_ALEN]; /* the MAC address */
55 struct net_device *dev; /* device */ 58 struct net_device *dev; /* device */
56 u_int16_t num_total_nodes; /* total number of nodes */ 59 u_int16_t num_total_nodes; /* total number of nodes */
57 u_int16_t num_local_nodes; /* number of local nodes */ 60 unsigned long local_nodes; /* node number array */
58 u_int16_t local_nodes[CLUSTERIP_MAX_NODES]; /* node number array */
59 61
60#ifdef CONFIG_PROC_FS 62#ifdef CONFIG_PROC_FS
61 struct proc_dir_entry *pde; /* proc dir entry */ 63 struct proc_dir_entry *pde; /* proc dir entry */
@@ -66,8 +68,7 @@ struct clusterip_config {
66 68
67static LIST_HEAD(clusterip_configs); 69static LIST_HEAD(clusterip_configs);
68 70
69/* clusterip_lock protects the clusterip_configs list _AND_ the configurable 71/* clusterip_lock protects the clusterip_configs list */
70 * data within all structurses (num_local_nodes, local_nodes[]) */
71static DEFINE_RWLOCK(clusterip_lock); 72static DEFINE_RWLOCK(clusterip_lock);
72 73
73#ifdef CONFIG_PROC_FS 74#ifdef CONFIG_PROC_FS
@@ -76,23 +77,48 @@ static struct proc_dir_entry *clusterip_procdir;
76#endif 77#endif
77 78
78static inline void 79static inline void
79clusterip_config_get(struct clusterip_config *c) { 80clusterip_config_get(struct clusterip_config *c)
81{
80 atomic_inc(&c->refcount); 82 atomic_inc(&c->refcount);
81} 83}
82 84
83static inline void 85static inline void
84clusterip_config_put(struct clusterip_config *c) { 86clusterip_config_put(struct clusterip_config *c)
85 if (atomic_dec_and_test(&c->refcount)) { 87{
88 if (atomic_dec_and_test(&c->refcount))
89 kfree(c);
90}
91
92/* increase the count of entries(rules) using/referencing this config */
93static inline void
94clusterip_config_entry_get(struct clusterip_config *c)
95{
96 atomic_inc(&c->entries);
97}
98
99/* decrease the count of entries using/referencing this config. If last
100 * entry(rule) is removed, remove the config from lists, but don't free it
101 * yet, since proc-files could still be holding references */
102static inline void
103clusterip_config_entry_put(struct clusterip_config *c)
104{
105 if (atomic_dec_and_test(&c->entries)) {
86 write_lock_bh(&clusterip_lock); 106 write_lock_bh(&clusterip_lock);
87 list_del(&c->list); 107 list_del(&c->list);
88 write_unlock_bh(&clusterip_lock); 108 write_unlock_bh(&clusterip_lock);
109
89 dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0); 110 dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0);
90 dev_put(c->dev); 111 dev_put(c->dev);
91 kfree(c); 112
113 /* In case anyone still accesses the file, the open/close
114 * functions are also incrementing the refcount on their own,
115 * so it's safe to remove the entry even if it's in use. */
116#ifdef CONFIG_PROC_FS
117 remove_proc_entry(c->pde->name, c->pde->parent);
118#endif
92 } 119 }
93} 120}
94 121
95
96static struct clusterip_config * 122static struct clusterip_config *
97__clusterip_config_find(u_int32_t clusterip) 123__clusterip_config_find(u_int32_t clusterip)
98{ 124{
@@ -111,7 +137,7 @@ __clusterip_config_find(u_int32_t clusterip)
111} 137}
112 138
113static inline struct clusterip_config * 139static inline struct clusterip_config *
114clusterip_config_find_get(u_int32_t clusterip) 140clusterip_config_find_get(u_int32_t clusterip, int entry)
115{ 141{
116 struct clusterip_config *c; 142 struct clusterip_config *c;
117 143
@@ -122,11 +148,24 @@ clusterip_config_find_get(u_int32_t clusterip)
122 return NULL; 148 return NULL;
123 } 149 }
124 atomic_inc(&c->refcount); 150 atomic_inc(&c->refcount);
151 if (entry)
152 atomic_inc(&c->entries);
125 read_unlock_bh(&clusterip_lock); 153 read_unlock_bh(&clusterip_lock);
126 154
127 return c; 155 return c;
128} 156}
129 157
158static void
159clusterip_config_init_nodelist(struct clusterip_config *c,
160 const struct ipt_clusterip_tgt_info *i)
161{
162 int n;
163
164 for (n = 0; n < i->num_local_nodes; n++) {
165 set_bit(i->local_nodes[n] - 1, &c->local_nodes);
166 }
167}
168
130static struct clusterip_config * 169static struct clusterip_config *
131clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip, 170clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
132 struct net_device *dev) 171 struct net_device *dev)
@@ -143,11 +182,11 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
143 c->clusterip = ip; 182 c->clusterip = ip;
144 memcpy(&c->clustermac, &i->clustermac, ETH_ALEN); 183 memcpy(&c->clustermac, &i->clustermac, ETH_ALEN);
145 c->num_total_nodes = i->num_total_nodes; 184 c->num_total_nodes = i->num_total_nodes;
146 c->num_local_nodes = i->num_local_nodes; 185 clusterip_config_init_nodelist(c, i);
147 memcpy(&c->local_nodes, &i->local_nodes, sizeof(c->local_nodes));
148 c->hash_mode = i->hash_mode; 186 c->hash_mode = i->hash_mode;
149 c->hash_initval = i->hash_initval; 187 c->hash_initval = i->hash_initval;
150 atomic_set(&c->refcount, 1); 188 atomic_set(&c->refcount, 1);
189 atomic_set(&c->entries, 1);
151 190
152#ifdef CONFIG_PROC_FS 191#ifdef CONFIG_PROC_FS
153 /* create proc dir entry */ 192 /* create proc dir entry */
@@ -171,53 +210,28 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
171static int 210static int
172clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum) 211clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum)
173{ 212{
174 int i;
175
176 write_lock_bh(&clusterip_lock);
177 213
178 if (c->num_local_nodes >= CLUSTERIP_MAX_NODES 214 if (nodenum == 0 ||
179 || nodenum > CLUSTERIP_MAX_NODES) { 215 nodenum > c->num_total_nodes)
180 write_unlock_bh(&clusterip_lock);
181 return 1; 216 return 1;
182 }
183
184 /* check if we alrady have this number in our array */
185 for (i = 0; i < c->num_local_nodes; i++) {
186 if (c->local_nodes[i] == nodenum) {
187 write_unlock_bh(&clusterip_lock);
188 return 1;
189 }
190 }
191 217
192 c->local_nodes[c->num_local_nodes++] = nodenum; 218 /* check if we already have this number in our bitfield */
219 if (test_and_set_bit(nodenum - 1, &c->local_nodes))
220 return 1;
193 221
194 write_unlock_bh(&clusterip_lock);
195 return 0; 222 return 0;
196} 223}
197 224
198static int 225static int
199clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum) 226clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
200{ 227{
201 int i; 228 if (nodenum == 0 ||
202 229 nodenum > c->num_total_nodes)
203 write_lock_bh(&clusterip_lock);
204
205 if (c->num_local_nodes <= 1 || nodenum > CLUSTERIP_MAX_NODES) {
206 write_unlock_bh(&clusterip_lock);
207 return 1; 230 return 1;
208 }
209 231
210 for (i = 0; i < c->num_local_nodes; i++) { 232 if (test_and_clear_bit(nodenum - 1, &c->local_nodes))
211 if (c->local_nodes[i] == nodenum) { 233 return 0;
212 int size = sizeof(u_int16_t)*(c->num_local_nodes-(i+1));
213 memmove(&c->local_nodes[i], &c->local_nodes[i+1], size);
214 c->num_local_nodes--;
215 write_unlock_bh(&clusterip_lock);
216 return 0;
217 }
218 }
219 234
220 write_unlock_bh(&clusterip_lock);
221 return 1; 235 return 1;
222} 236}
223 237
@@ -285,25 +299,7 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
285static inline int 299static inline int
286clusterip_responsible(struct clusterip_config *config, u_int32_t hash) 300clusterip_responsible(struct clusterip_config *config, u_int32_t hash)
287{ 301{
288 int i; 302 return test_bit(hash - 1, &config->local_nodes);
289
290 read_lock_bh(&clusterip_lock);
291
292 if (config->num_local_nodes == 0) {
293 read_unlock_bh(&clusterip_lock);
294 return 0;
295 }
296
297 for (i = 0; i < config->num_local_nodes; i++) {
298 if (config->local_nodes[i] == hash) {
299 read_unlock_bh(&clusterip_lock);
300 return 1;
301 }
302 }
303
304 read_unlock_bh(&clusterip_lock);
305
306 return 0;
307} 303}
308 304
309/*********************************************************************** 305/***********************************************************************
@@ -415,8 +411,26 @@ checkentry(const char *tablename,
415 411
416 /* FIXME: further sanity checks */ 412 /* FIXME: further sanity checks */
417 413
418 config = clusterip_config_find_get(e->ip.dst.s_addr); 414 config = clusterip_config_find_get(e->ip.dst.s_addr, 1);
419 if (!config) { 415 if (config) {
416 if (cipinfo->config != NULL) {
417 /* Case A: This is an entry that gets reloaded, since
418 * it still has a cipinfo->config pointer. Simply
419 * increase the entry refcount and return */
420 if (cipinfo->config != config) {
421 printk(KERN_ERR "CLUSTERIP: Reloaded entry "
422 "has invalid config pointer!\n");
423 return 0;
424 }
425 clusterip_config_entry_get(cipinfo->config);
426 } else {
427 /* Case B: This is a new rule referring to an existing
428 * clusterip config. */
429 cipinfo->config = config;
430 clusterip_config_entry_get(cipinfo->config);
431 }
432 } else {
433 /* Case C: This is a completely new clusterip config */
420 if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) { 434 if (!(cipinfo->flags & CLUSTERIP_FLAG_NEW)) {
421 printk(KERN_WARNING "CLUSTERIP: no config found for %u.%u.%u.%u, need 'new'\n", NIPQUAD(e->ip.dst.s_addr)); 435 printk(KERN_WARNING "CLUSTERIP: no config found for %u.%u.%u.%u, need 'new'\n", NIPQUAD(e->ip.dst.s_addr));
422 return 0; 436 return 0;
@@ -443,10 +457,9 @@ checkentry(const char *tablename,
443 } 457 }
444 dev_mc_add(config->dev,config->clustermac, ETH_ALEN, 0); 458 dev_mc_add(config->dev,config->clustermac, ETH_ALEN, 0);
445 } 459 }
460 cipinfo->config = config;
446 } 461 }
447 462
448 cipinfo->config = config;
449
450 return 1; 463 return 1;
451} 464}
452 465
@@ -455,13 +468,10 @@ static void destroy(void *matchinfo, unsigned int matchinfosize)
455{ 468{
456 struct ipt_clusterip_tgt_info *cipinfo = matchinfo; 469 struct ipt_clusterip_tgt_info *cipinfo = matchinfo;
457 470
458 /* we first remove the proc entry and then drop the reference 471 /* if no more entries are referencing the config, remove it
459 * count. In case anyone still accesses the file, the open/close 472 * from the list and destroy the proc entry */
460 * functions are also incrementing the refcount on their own */ 473 clusterip_config_entry_put(cipinfo->config);
461#ifdef CONFIG_PROC_FS 474
462 remove_proc_entry(cipinfo->config->pde->name,
463 cipinfo->config->pde->parent);
464#endif
465 clusterip_config_put(cipinfo->config); 475 clusterip_config_put(cipinfo->config);
466} 476}
467 477
@@ -533,7 +543,7 @@ arp_mangle(unsigned int hook,
533 543
534 /* if there is no clusterip configuration for the arp reply's 544 /* if there is no clusterip configuration for the arp reply's
535 * source ip, we don't want to mangle it */ 545 * source ip, we don't want to mangle it */
536 c = clusterip_config_find_get(payload->src_ip); 546 c = clusterip_config_find_get(payload->src_ip, 0);
537 if (!c) 547 if (!c)
538 return NF_ACCEPT; 548 return NF_ACCEPT;
539 549
@@ -574,56 +584,69 @@ static struct nf_hook_ops cip_arp_ops = {
574 584
575#ifdef CONFIG_PROC_FS 585#ifdef CONFIG_PROC_FS
576 586
587struct clusterip_seq_position {
588 unsigned int pos; /* position */
589 unsigned int weight; /* number of bits set == size */
590 unsigned int bit; /* current bit */
591 unsigned long val; /* current value */
592};
593
577static void *clusterip_seq_start(struct seq_file *s, loff_t *pos) 594static void *clusterip_seq_start(struct seq_file *s, loff_t *pos)
578{ 595{
579 struct proc_dir_entry *pde = s->private; 596 struct proc_dir_entry *pde = s->private;
580 struct clusterip_config *c = pde->data; 597 struct clusterip_config *c = pde->data;
581 unsigned int *nodeidx; 598 unsigned int weight;
582 599 u_int32_t local_nodes;
583 read_lock_bh(&clusterip_lock); 600 struct clusterip_seq_position *idx;
584 if (*pos >= c->num_local_nodes) 601
602 /* FIXME: possible race */
603 local_nodes = c->local_nodes;
604 weight = hweight32(local_nodes);
605 if (*pos >= weight)
585 return NULL; 606 return NULL;
586 607
587 nodeidx = kmalloc(sizeof(unsigned int), GFP_KERNEL); 608 idx = kmalloc(sizeof(struct clusterip_seq_position), GFP_KERNEL);
588 if (!nodeidx) 609 if (!idx)
589 return ERR_PTR(-ENOMEM); 610 return ERR_PTR(-ENOMEM);
590 611
591 *nodeidx = *pos; 612 idx->pos = *pos;
592 return nodeidx; 613 idx->weight = weight;
614 idx->bit = ffs(local_nodes);
615 idx->val = local_nodes;
616 clear_bit(idx->bit - 1, &idx->val);
617
618 return idx;
593} 619}
594 620
595static void *clusterip_seq_next(struct seq_file *s, void *v, loff_t *pos) 621static void *clusterip_seq_next(struct seq_file *s, void *v, loff_t *pos)
596{ 622{
597 struct proc_dir_entry *pde = s->private; 623 struct clusterip_seq_position *idx = (struct clusterip_seq_position *)v;
598 struct clusterip_config *c = pde->data;
599 unsigned int *nodeidx = (unsigned int *)v;
600 624
601 *pos = ++(*nodeidx); 625 *pos = ++idx->pos;
602 if (*pos >= c->num_local_nodes) { 626 if (*pos >= idx->weight) {
603 kfree(v); 627 kfree(v);
604 return NULL; 628 return NULL;
605 } 629 }
606 return nodeidx; 630 idx->bit = ffs(idx->val);
631 clear_bit(idx->bit - 1, &idx->val);
632 return idx;
607} 633}
608 634
609static void clusterip_seq_stop(struct seq_file *s, void *v) 635static void clusterip_seq_stop(struct seq_file *s, void *v)
610{ 636{
611 kfree(v); 637 kfree(v);
612
613 read_unlock_bh(&clusterip_lock);
614} 638}
615 639
616static int clusterip_seq_show(struct seq_file *s, void *v) 640static int clusterip_seq_show(struct seq_file *s, void *v)
617{ 641{
618 struct proc_dir_entry *pde = s->private; 642 struct clusterip_seq_position *idx = (struct clusterip_seq_position *)v;
619 struct clusterip_config *c = pde->data;
620 unsigned int *nodeidx = (unsigned int *)v;
621 643
622 if (*nodeidx != 0) 644 if (idx->pos != 0)
623 seq_putc(s, ','); 645 seq_putc(s, ',');
624 seq_printf(s, "%u", c->local_nodes[*nodeidx]);
625 646
626 if (*nodeidx == c->num_local_nodes-1) 647 seq_printf(s, "%u", idx->bit);
648
649 if (idx->pos == idx->weight - 1)
627 seq_putc(s, '\n'); 650 seq_putc(s, '\n');
628 651
629 return 0; 652 return 0;
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
index 715cb613405c..5245bfd33d52 100644
--- a/net/ipv4/netfilter/ipt_REDIRECT.c
+++ b/net/ipv4/netfilter/ipt_REDIRECT.c
@@ -93,7 +93,7 @@ redirect_target(struct sk_buff **pskb,
93 newdst = 0; 93 newdst = 0;
94 94
95 rcu_read_lock(); 95 rcu_read_lock();
96 indev = __in_dev_get((*pskb)->dev); 96 indev = __in_dev_get_rcu((*pskb)->dev);
97 if (indev && (ifa = indev->ifa_list)) 97 if (indev && (ifa = indev->ifa_list))
98 newdst = ifa->ifa_local; 98 newdst = ifa->ifa_local;
99 rcu_read_unlock(); 99 rcu_read_unlock();
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index e2c14f3cb2fc..2883ccd8a91d 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -225,8 +225,8 @@ static void ipt_ulog_packet(unsigned int hooknum,
225 225
226 /* copy hook, prefix, timestamp, payload, etc. */ 226 /* copy hook, prefix, timestamp, payload, etc. */
227 pm->data_len = copy_len; 227 pm->data_len = copy_len;
228 pm->timestamp_sec = skb_tv_base.tv_sec + skb->tstamp.off_sec; 228 pm->timestamp_sec = skb->tstamp.off_sec;
229 pm->timestamp_usec = skb_tv_base.tv_usec + skb->tstamp.off_usec; 229 pm->timestamp_usec = skb->tstamp.off_usec;
230 pm->mark = skb->nfmark; 230 pm->mark = skb->nfmark;
231 pm->hook = hooknum; 231 pm->hook = hooknum;
232 if (prefix != NULL) 232 if (prefix != NULL)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 304bb0a1d4f0..4b0d7e4d6269 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -361,7 +361,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
361 361
362 if (type && code) { 362 if (type && code) {
363 get_user(fl->fl_icmp_type, type); 363 get_user(fl->fl_icmp_type, type);
364 __get_user(fl->fl_icmp_code, code); 364 get_user(fl->fl_icmp_code, code);
365 probed = 1; 365 probed = 1;
366 } 366 }
367 break; 367 break;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 8549f26e2495..381dd6a6aebb 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2128,7 +2128,7 @@ int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr,
2128 struct in_device *in_dev; 2128 struct in_device *in_dev;
2129 2129
2130 rcu_read_lock(); 2130 rcu_read_lock();
2131 if ((in_dev = __in_dev_get(dev)) != NULL) { 2131 if ((in_dev = __in_dev_get_rcu(dev)) != NULL) {
2132 int our = ip_check_mc(in_dev, daddr, saddr, 2132 int our = ip_check_mc(in_dev, daddr, saddr,
2133 skb->nh.iph->protocol); 2133 skb->nh.iph->protocol);
2134 if (our 2134 if (our
@@ -2443,7 +2443,9 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2443 err = -ENODEV; 2443 err = -ENODEV;
2444 if (dev_out == NULL) 2444 if (dev_out == NULL)
2445 goto out; 2445 goto out;
2446 if (__in_dev_get(dev_out) == NULL) { 2446
2447 /* RACE: Check return value of inet_select_addr instead. */
2448 if (__in_dev_get_rtnl(dev_out) == NULL) {
2447 dev_put(dev_out); 2449 dev_put(dev_out);
2448 goto out; /* Wrong error code */ 2450 goto out; /* Wrong error code */
2449 } 2451 }
diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c
index b940346de4e7..6d80e063c187 100644
--- a/net/ipv4/tcp_bic.c
+++ b/net/ipv4/tcp_bic.c
@@ -136,7 +136,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
136 else if (cwnd < ca->last_max_cwnd + max_increment*(BICTCP_B-1)) 136 else if (cwnd < ca->last_max_cwnd + max_increment*(BICTCP_B-1))
137 /* slow start */ 137 /* slow start */
138 ca->cnt = (cwnd * (BICTCP_B-1)) 138 ca->cnt = (cwnd * (BICTCP_B-1))
139 / cwnd-ca->last_max_cwnd; 139 / (cwnd - ca->last_max_cwnd);
140 else 140 else
141 /* linear increase */ 141 /* linear increase */
142 ca->cnt = cwnd / max_increment; 142 ca->cnt = cwnd / max_increment;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a7537c7bbd06..677419d0c9ad 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -355,8 +355,6 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp)
355 app_win -= icsk->icsk_ack.rcv_mss; 355 app_win -= icsk->icsk_ack.rcv_mss;
356 app_win = max(app_win, 2U*tp->advmss); 356 app_win = max(app_win, 2U*tp->advmss);
357 357
358 if (!ofo_win)
359 tp->window_clamp = min(tp->window_clamp, app_win);
360 tp->rcv_ssthresh = min(tp->window_clamp, 2U*tp->advmss); 358 tp->rcv_ssthresh = min(tp->window_clamp, 2U*tp->advmss);
361 } 359 }
362} 360}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 13dfb391cdf1..c85819d8474b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -130,19 +130,20 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport,
130 int dif = sk->sk_bound_dev_if; 130 int dif = sk->sk_bound_dev_if;
131 INET_ADDR_COOKIE(acookie, saddr, daddr) 131 INET_ADDR_COOKIE(acookie, saddr, daddr)
132 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); 132 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
133 const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, tcp_hashinfo.ehash_size); 133 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
134 struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash]; 134 struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash);
135 struct sock *sk2; 135 struct sock *sk2;
136 const struct hlist_node *node; 136 const struct hlist_node *node;
137 struct inet_timewait_sock *tw; 137 struct inet_timewait_sock *tw;
138 138
139 prefetch(head->chain.first);
139 write_lock(&head->lock); 140 write_lock(&head->lock);
140 141
141 /* Check TIME-WAIT sockets first. */ 142 /* Check TIME-WAIT sockets first. */
142 sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { 143 sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) {
143 tw = inet_twsk(sk2); 144 tw = inet_twsk(sk2);
144 145
145 if (INET_TW_MATCH(sk2, acookie, saddr, daddr, ports, dif)) { 146 if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) {
146 const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); 147 const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2);
147 struct tcp_sock *tp = tcp_sk(sk); 148 struct tcp_sock *tp = tcp_sk(sk);
148 149
@@ -179,7 +180,7 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport,
179 180
180 /* And established part... */ 181 /* And established part... */
181 sk_for_each(sk2, node, &head->chain) { 182 sk_for_each(sk2, node, &head->chain) {
182 if (INET_MATCH(sk2, acookie, saddr, daddr, ports, dif)) 183 if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif))
183 goto not_unique; 184 goto not_unique;
184 } 185 }
185 186
@@ -188,7 +189,7 @@ unique:
188 * in hash table socket with a funny identity. */ 189 * in hash table socket with a funny identity. */
189 inet->num = lport; 190 inet->num = lport;
190 inet->sport = htons(lport); 191 inet->sport = htons(lport);
191 sk->sk_hashent = hash; 192 sk->sk_hash = hash;
192 BUG_TRAP(sk_unhashed(sk)); 193 BUG_TRAP(sk_unhashed(sk));
193 __sk_add_node(sk, &head->chain); 194 __sk_add_node(sk, &head->chain);
194 sock_prot_inc_use(sk->sk_prot); 195 sock_prot_inc_use(sk->sk_prot);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index a88db28b0af7..b1a63b2c6b4a 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -384,7 +384,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
384 newtp->frto_counter = 0; 384 newtp->frto_counter = 0;
385 newtp->frto_highmark = 0; 385 newtp->frto_highmark = 0;
386 386
387 newicsk->icsk_ca_ops = &tcp_reno; 387 newicsk->icsk_ca_ops = &tcp_init_congestion_ops;
388 388
389 tcp_set_ca_state(newsk, TCP_CA_Open); 389 tcp_set_ca_state(newsk, TCP_CA_Open);
390 tcp_init_xmit_timers(newsk); 390 tcp_init_xmit_timers(newsk);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index b018e31b6530..b907456a79f4 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -190,7 +190,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
190 } 190 }
191 191
192 /* Set initial window to value enough for senders, 192 /* Set initial window to value enough for senders,
193 * following RFC1414. Senders, not following this RFC, 193 * following RFC2414. Senders, not following this RFC,
194 * will be satisfied with 2. 194 * will be satisfied with 2.
195 */ 195 */
196 if (mss > (1<<*rcv_wscale)) { 196 if (mss > (1<<*rcv_wscale)) {
@@ -435,8 +435,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
435 int nsize, old_factor; 435 int nsize, old_factor;
436 u16 flags; 436 u16 flags;
437 437
438 BUG_ON(len >= skb->len); 438 BUG_ON(len > skb->len);
439
440 nsize = skb_headlen(skb) - len; 439 nsize = skb_headlen(skb) - len;
441 if (nsize < 0) 440 if (nsize < 0)
442 nsize = 0; 441 nsize = 0;
@@ -461,9 +460,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
461 flags = TCP_SKB_CB(skb)->flags; 460 flags = TCP_SKB_CB(skb)->flags;
462 TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH); 461 TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH);
463 TCP_SKB_CB(buff)->flags = flags; 462 TCP_SKB_CB(buff)->flags = flags;
464 TCP_SKB_CB(buff)->sacked = 463 TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked;
465 (TCP_SKB_CB(skb)->sacked &
466 (TCPCB_LOST | TCPCB_EVER_RETRANS | TCPCB_AT_TAIL));
467 TCP_SKB_CB(skb)->sacked &= ~TCPCB_AT_TAIL; 464 TCP_SKB_CB(skb)->sacked &= ~TCPCB_AT_TAIL;
468 465
469 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_HW) { 466 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_HW) {
@@ -501,11 +498,26 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
501 tcp_skb_pcount(buff); 498 tcp_skb_pcount(buff);
502 499
503 tp->packets_out -= diff; 500 tp->packets_out -= diff;
501
502 if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)
503 tp->sacked_out -= diff;
504 if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)
505 tp->retrans_out -= diff;
506
504 if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) { 507 if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
505 tp->lost_out -= diff; 508 tp->lost_out -= diff;
506 tp->left_out -= diff; 509 tp->left_out -= diff;
507 } 510 }
511
508 if (diff > 0) { 512 if (diff > 0) {
513 /* Adjust Reno SACK estimate. */
514 if (!tp->rx_opt.sack_ok) {
515 tp->sacked_out -= diff;
516 if ((int)tp->sacked_out < 0)
517 tp->sacked_out = 0;
518 tcp_sync_left_out(tp);
519 }
520
509 tp->fackets_out -= diff; 521 tp->fackets_out -= diff;
510 if ((int)tp->fackets_out < 0) 522 if ((int)tp->fackets_out < 0)
511 tp->fackets_out = 0; 523 tp->fackets_out = 0;
@@ -1597,7 +1609,7 @@ void tcp_send_fin(struct sock *sk)
1597 * was unread data in the receive queue. This behavior is recommended 1609 * was unread data in the receive queue. This behavior is recommended
1598 * by draft-ietf-tcpimpl-prob-03.txt section 3.10. -DaveM 1610 * by draft-ietf-tcpimpl-prob-03.txt section 3.10. -DaveM
1599 */ 1611 */
1600void tcp_send_active_reset(struct sock *sk, unsigned int __nocast priority) 1612void tcp_send_active_reset(struct sock *sk, gfp_t priority)
1601{ 1613{
1602 struct tcp_sock *tp = tcp_sk(sk); 1614 struct tcp_sock *tp = tcp_sk(sk);
1603 struct sk_buff *skb; 1615 struct sk_buff *skb;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 2fea3f4402a0..a970b4727ce8 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1806,7 +1806,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
1806 } 1806 }
1807 1807
1808 for (dev = dev_base; dev != NULL; dev = dev->next) { 1808 for (dev = dev_base; dev != NULL; dev = dev->next) {
1809 struct in_device * in_dev = __in_dev_get(dev); 1809 struct in_device * in_dev = __in_dev_get_rtnl(dev);
1810 if (in_dev && (dev->flags & IFF_UP)) { 1810 if (in_dev && (dev->flags & IFF_UP)) {
1811 struct in_ifaddr * ifa; 1811 struct in_ifaddr * ifa;
1812 1812
@@ -3520,6 +3520,8 @@ int __init addrconf_init(void)
3520 if (err) 3520 if (err)
3521 return err; 3521 return err;
3522 3522
3523 ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev);
3524
3523 register_netdevice_notifier(&ipv6_dev_notf); 3525 register_netdevice_notifier(&ipv6_dev_notf);
3524 3526
3525#ifdef CONFIG_IPV6_PRIVACY 3527#ifdef CONFIG_IPV6_PRIVACY
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 9b27460f0cc7..40d9a1935ab5 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -31,6 +31,7 @@
31#include <net/esp.h> 31#include <net/esp.h>
32#include <asm/scatterlist.h> 32#include <asm/scatterlist.h>
33#include <linux/crypto.h> 33#include <linux/crypto.h>
34#include <linux/kernel.h>
34#include <linux/pfkeyv2.h> 35#include <linux/pfkeyv2.h>
35#include <linux/random.h> 36#include <linux/random.h>
36#include <net/icmp.h> 37#include <net/icmp.h>
@@ -66,10 +67,10 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
66 67
67 alen = esp->auth.icv_trunc_len; 68 alen = esp->auth.icv_trunc_len;
68 tfm = esp->conf.tfm; 69 tfm = esp->conf.tfm;
69 blksize = (crypto_tfm_alg_blocksize(tfm) + 3) & ~3; 70 blksize = ALIGN(crypto_tfm_alg_blocksize(tfm), 4);
70 clen = (clen + 2 + blksize-1)&~(blksize-1); 71 clen = ALIGN(clen + 2, blksize);
71 if (esp->conf.padlen) 72 if (esp->conf.padlen)
72 clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1); 73 clen = ALIGN(clen, esp->conf.padlen);
73 74
74 if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) { 75 if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) {
75 goto error; 76 goto error;
@@ -133,7 +134,7 @@ static int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, stru
133 struct ipv6_esp_hdr *esph; 134 struct ipv6_esp_hdr *esph;
134 struct esp_data *esp = x->data; 135 struct esp_data *esp = x->data;
135 struct sk_buff *trailer; 136 struct sk_buff *trailer;
136 int blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); 137 int blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4);
137 int alen = esp->auth.icv_trunc_len; 138 int alen = esp->auth.icv_trunc_len;
138 int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen; 139 int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen;
139 140
@@ -235,16 +236,17 @@ out_nofree:
235static u32 esp6_get_max_size(struct xfrm_state *x, int mtu) 236static u32 esp6_get_max_size(struct xfrm_state *x, int mtu)
236{ 237{
237 struct esp_data *esp = x->data; 238 struct esp_data *esp = x->data;
238 u32 blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); 239 u32 blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4);
239 240
240 if (x->props.mode) { 241 if (x->props.mode) {
241 mtu = (mtu + 2 + blksize-1)&~(blksize-1); 242 mtu = ALIGN(mtu + 2, blksize);
242 } else { 243 } else {
243 /* The worst case. */ 244 /* The worst case. */
244 mtu += 2 + blksize; 245 u32 padsize = ((blksize - 1) & 7) + 1;
246 mtu = ALIGN(mtu + 2, padsize) + blksize - padsize;
245 } 247 }
246 if (esp->conf.padlen) 248 if (esp->conf.padlen)
247 mtu = (mtu + esp->conf.padlen-1)&~(esp->conf.padlen-1); 249 mtu = ALIGN(mtu, esp->conf.padlen);
248 250
249 return mtu + x->props.header_len + esp->auth.icv_full_len; 251 return mtu + x->props.header_len + esp->auth.icv_full_len;
250} 252}
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index f841bde30c18..bbbe80cdaf72 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -483,7 +483,7 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
483 goto done; 483 goto done;
484 } 484 }
485 fl1 = sfl->fl; 485 fl1 = sfl->fl;
486 atomic_inc(&fl->users); 486 atomic_inc(&fl1->users);
487 break; 487 break;
488 } 488 }
489 } 489 }
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 2f589f24c093..563b442ffab8 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -666,7 +666,7 @@ slow_path:
666 */ 666 */
667 fh->nexthdr = nexthdr; 667 fh->nexthdr = nexthdr;
668 fh->reserved = 0; 668 fh->reserved = 0;
669 if (frag_id) { 669 if (!frag_id) {
670 ipv6_select_ident(skb, fh); 670 ipv6_select_ident(skb, fh);
671 frag_id = fh->identification; 671 frag_id = fh->identification;
672 } else 672 } else
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 519899fb11d5..39a96c768102 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1393,7 +1393,7 @@ static void mld_sendpack(struct sk_buff *skb)
1393 1393
1394static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel) 1394static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel)
1395{ 1395{
1396 return sizeof(struct mld2_grec) + 4*mld_scount(pmc,type,gdel,sdel); 1396 return sizeof(struct mld2_grec) + 16 * mld_scount(pmc,type,gdel,sdel);
1397} 1397}
1398 1398
1399static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc, 1399static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc,
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 555a31347eda..305d9ee6d7db 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1450,7 +1450,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1450 1450
1451static void pndisc_redo(struct sk_buff *skb) 1451static void pndisc_redo(struct sk_buff *skb)
1452{ 1452{
1453 ndisc_rcv(skb); 1453 ndisc_recv_ns(skb);
1454 kfree_skb(skb); 1454 kfree_skb(skb);
1455} 1455}
1456 1456
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
index 216fbe1ac65c..bb7ccfe33f23 100644
--- a/net/ipv6/netfilter/Kconfig
+++ b/net/ipv6/netfilter/Kconfig
@@ -209,6 +209,17 @@ config IP6_NF_TARGET_REJECT
209 209
210 To compile it as a module, choose M here. If unsure, say N. 210 To compile it as a module, choose M here. If unsure, say N.
211 211
212config IP6_NF_TARGET_NFQUEUE
213 tristate "NFQUEUE Target Support"
214 depends on IP_NF_IPTABLES
215 help
216 This Target replaced the old obsolete QUEUE target.
217
218 As opposed to QUEUE, it supports 65535 different queues,
219 not just one.
220
221 To compile it as a module, choose M here. If unsure, say N.
222
212# if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then 223# if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then
213# dep_tristate ' REJECT target support' CONFIG_IP6_NF_TARGET_REJECT $CONFIG_IP6_NF_FILTER 224# dep_tristate ' REJECT target support' CONFIG_IP6_NF_TARGET_REJECT $CONFIG_IP6_NF_FILTER
214# if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then 225# if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile
index bd9a16a5cbba..2b2c370e8b1c 100644
--- a/net/ipv6/netfilter/Makefile
+++ b/net/ipv6/netfilter/Makefile
@@ -21,9 +21,9 @@ obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
21obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o 21obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
22obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o 22obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o
23obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o 23obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
24obj-$(CONFIG_IP6_NF_TARGET_NFQUEUE) += ip6t_NFQUEUE.o
24obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o 25obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
25obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o 26obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
26obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o 27obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
27obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o 28obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
28obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o 29obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o
29obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += ip6t_NFQUEUE.o
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index aa11cf366efa..5027bbe6415e 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -238,8 +238,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
238 238
239 pmsg->packet_id = (unsigned long )entry; 239 pmsg->packet_id = (unsigned long )entry;
240 pmsg->data_len = data_len; 240 pmsg->data_len = data_len;
241 pmsg->timestamp_sec = skb_tv_base.tv_sec + entry->skb->tstamp.off_sec; 241 pmsg->timestamp_sec = entry->skb->tstamp.off_sec;
242 pmsg->timestamp_usec = skb_tv_base.tv_usec + entry->skb->tstamp.off_usec; 242 pmsg->timestamp_usec = entry->skb->tstamp.off_usec;
243 pmsg->mark = entry->skb->nfmark; 243 pmsg->mark = entry->skb->nfmark;
244 pmsg->hook = entry->info->hook; 244 pmsg->hook = entry->info->hook;
245 pmsg->hw_protocol = entry->skb->protocol; 245 pmsg->hw_protocol = entry->skb->protocol;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 1cb8adb2787f..21deec25a12b 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -28,6 +28,7 @@
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <asm/semaphore.h> 29#include <asm/semaphore.h>
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/cpumask.h>
31 32
32#include <linux/netfilter_ipv6/ip6_tables.h> 33#include <linux/netfilter_ipv6/ip6_tables.h>
33 34
@@ -950,8 +951,10 @@ translate_table(const char *name,
950 } 951 }
951 952
952 /* And one copy for every other CPU */ 953 /* And one copy for every other CPU */
953 for (i = 1; i < num_possible_cpus(); i++) { 954 for_each_cpu(i) {
954 memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i, 955 if (i == 0)
956 continue;
957 memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i,
955 newinfo->entries, 958 newinfo->entries,
956 SMP_ALIGN(newinfo->size)); 959 SMP_ALIGN(newinfo->size));
957 } 960 }
@@ -972,7 +975,7 @@ replace_table(struct ip6t_table *table,
972 struct ip6t_entry *table_base; 975 struct ip6t_entry *table_base;
973 unsigned int i; 976 unsigned int i;
974 977
975 for (i = 0; i < num_possible_cpus(); i++) { 978 for_each_cpu(i) {
976 table_base = 979 table_base =
977 (void *)newinfo->entries 980 (void *)newinfo->entries
978 + TABLE_OFFSET(newinfo, i); 981 + TABLE_OFFSET(newinfo, i);
@@ -1019,7 +1022,7 @@ get_counters(const struct ip6t_table_info *t,
1019 unsigned int cpu; 1022 unsigned int cpu;
1020 unsigned int i; 1023 unsigned int i;
1021 1024
1022 for (cpu = 0; cpu < num_possible_cpus(); cpu++) { 1025 for_each_cpu(cpu) {
1023 i = 0; 1026 i = 0;
1024 IP6T_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), 1027 IP6T_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu),
1025 t->size, 1028 t->size,
@@ -1153,7 +1156,8 @@ do_replace(void __user *user, unsigned int len)
1153 return -ENOMEM; 1156 return -ENOMEM;
1154 1157
1155 newinfo = vmalloc(sizeof(struct ip6t_table_info) 1158 newinfo = vmalloc(sizeof(struct ip6t_table_info)
1156 + SMP_ALIGN(tmp.size) * num_possible_cpus()); 1159 + SMP_ALIGN(tmp.size) *
1160 (highest_possible_processor_id()+1));
1157 if (!newinfo) 1161 if (!newinfo)
1158 return -ENOMEM; 1162 return -ENOMEM;
1159 1163
@@ -1467,7 +1471,8 @@ int ip6t_register_table(struct ip6t_table *table,
1467 = { 0, 0, 0, { 0 }, { 0 }, { } }; 1471 = { 0, 0, 0, { 0 }, { 0 }, { } };
1468 1472
1469 newinfo = vmalloc(sizeof(struct ip6t_table_info) 1473 newinfo = vmalloc(sizeof(struct ip6t_table_info)
1470 + SMP_ALIGN(repl->size) * num_possible_cpus()); 1474 + SMP_ALIGN(repl->size) *
1475 (highest_possible_processor_id()+1));
1471 if (!newinfo) 1476 if (!newinfo)
1472 return -ENOMEM; 1477 return -ENOMEM;
1473 1478
@@ -1955,6 +1960,57 @@ static void __exit fini(void)
1955#endif 1960#endif
1956} 1961}
1957 1962
1963/*
1964 * find specified header up to transport protocol header.
1965 * If found target header, the offset to the header is set to *offset
1966 * and return 0. otherwise, return -1.
1967 *
1968 * Notes: - non-1st Fragment Header isn't skipped.
1969 * - ESP header isn't skipped.
1970 * - The target header may be trancated.
1971 */
1972int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, u8 target)
1973{
1974 unsigned int start = (u8*)(skb->nh.ipv6h + 1) - skb->data;
1975 u8 nexthdr = skb->nh.ipv6h->nexthdr;
1976 unsigned int len = skb->len - start;
1977
1978 while (nexthdr != target) {
1979 struct ipv6_opt_hdr _hdr, *hp;
1980 unsigned int hdrlen;
1981
1982 if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE)
1983 return -1;
1984 hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
1985 if (hp == NULL)
1986 return -1;
1987 if (nexthdr == NEXTHDR_FRAGMENT) {
1988 unsigned short _frag_off, *fp;
1989 fp = skb_header_pointer(skb,
1990 start+offsetof(struct frag_hdr,
1991 frag_off),
1992 sizeof(_frag_off),
1993 &_frag_off);
1994 if (fp == NULL)
1995 return -1;
1996
1997 if (ntohs(*fp) & ~0x7)
1998 return -1;
1999 hdrlen = 8;
2000 } else if (nexthdr == NEXTHDR_AUTH)
2001 hdrlen = (hp->hdrlen + 2) << 2;
2002 else
2003 hdrlen = ipv6_optlen(hp);
2004
2005 nexthdr = hp->nexthdr;
2006 len -= hdrlen;
2007 start += hdrlen;
2008 }
2009
2010 *offset = start;
2011 return 0;
2012}
2013
1958EXPORT_SYMBOL(ip6t_register_table); 2014EXPORT_SYMBOL(ip6t_register_table);
1959EXPORT_SYMBOL(ip6t_unregister_table); 2015EXPORT_SYMBOL(ip6t_unregister_table);
1960EXPORT_SYMBOL(ip6t_do_table); 2016EXPORT_SYMBOL(ip6t_do_table);
@@ -1963,6 +2019,7 @@ EXPORT_SYMBOL(ip6t_unregister_match);
1963EXPORT_SYMBOL(ip6t_register_target); 2019EXPORT_SYMBOL(ip6t_register_target);
1964EXPORT_SYMBOL(ip6t_unregister_target); 2020EXPORT_SYMBOL(ip6t_unregister_target);
1965EXPORT_SYMBOL(ip6t_ext_hdr); 2021EXPORT_SYMBOL(ip6t_ext_hdr);
2022EXPORT_SYMBOL(ipv6_find_hdr);
1966 2023
1967module_init(init); 2024module_init(init);
1968module_exit(fini); 2025module_exit(fini);
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index d5b94f142bba..dde37793d20b 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -48,92 +48,21 @@ match(const struct sk_buff *skb,
48 unsigned int protoff, 48 unsigned int protoff,
49 int *hotdrop) 49 int *hotdrop)
50{ 50{
51 struct ip_auth_hdr *ah = NULL, _ah; 51 struct ip_auth_hdr *ah, _ah;
52 const struct ip6t_ah *ahinfo = matchinfo; 52 const struct ip6t_ah *ahinfo = matchinfo;
53 unsigned int temp;
54 int len;
55 u8 nexthdr;
56 unsigned int ptr; 53 unsigned int ptr;
57 unsigned int hdrlen = 0; 54 unsigned int hdrlen = 0;
58 55
59 /*DEBUGP("IPv6 AH entered\n");*/ 56 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_AUTH) < 0)
60 /* if (opt->auth == 0) return 0;
61 * It does not filled on output */
62
63 /* type of the 1st exthdr */
64 nexthdr = skb->nh.ipv6h->nexthdr;
65 /* pointer to the 1st exthdr */
66 ptr = sizeof(struct ipv6hdr);
67 /* available length */
68 len = skb->len - ptr;
69 temp = 0;
70
71 while (ip6t_ext_hdr(nexthdr)) {
72 struct ipv6_opt_hdr _hdr, *hp;
73
74 DEBUGP("ipv6_ah header iteration \n");
75
76 /* Is there enough space for the next ext header? */
77 if (len < sizeof(struct ipv6_opt_hdr))
78 return 0;
79 /* No more exthdr -> evaluate */
80 if (nexthdr == NEXTHDR_NONE)
81 break;
82 /* ESP -> evaluate */
83 if (nexthdr == NEXTHDR_ESP)
84 break;
85
86 hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
87 BUG_ON(hp == NULL);
88
89 /* Calculate the header length */
90 if (nexthdr == NEXTHDR_FRAGMENT)
91 hdrlen = 8;
92 else if (nexthdr == NEXTHDR_AUTH)
93 hdrlen = (hp->hdrlen+2)<<2;
94 else
95 hdrlen = ipv6_optlen(hp);
96
97 /* AH -> evaluate */
98 if (nexthdr == NEXTHDR_AUTH) {
99 temp |= MASK_AH;
100 break;
101 }
102
103
104 /* set the flag */
105 switch (nexthdr) {
106 case NEXTHDR_HOP:
107 case NEXTHDR_ROUTING:
108 case NEXTHDR_FRAGMENT:
109 case NEXTHDR_AUTH:
110 case NEXTHDR_DEST:
111 break;
112 default:
113 DEBUGP("ipv6_ah match: unknown nextheader %u\n",nexthdr);
114 return 0;
115 }
116
117 nexthdr = hp->nexthdr;
118 len -= hdrlen;
119 ptr += hdrlen;
120 if (ptr > skb->len) {
121 DEBUGP("ipv6_ah: new pointer too large! \n");
122 break;
123 }
124 }
125
126 /* AH header not found */
127 if (temp != MASK_AH)
128 return 0; 57 return 0;
129 58
130 if (len < sizeof(struct ip_auth_hdr)){ 59 ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah);
60 if (ah == NULL) {
131 *hotdrop = 1; 61 *hotdrop = 1;
132 return 0; 62 return 0;
133 } 63 }
134 64
135 ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah); 65 hdrlen = (ah->hdrlen + 2) << 2;
136 BUG_ON(ah == NULL);
137 66
138 DEBUGP("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen); 67 DEBUGP("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen);
139 DEBUGP("RES %04X ", ah->reserved); 68 DEBUGP("RES %04X ", ah->reserved);
diff --git a/net/ipv6/netfilter/ip6t_dst.c b/net/ipv6/netfilter/ip6t_dst.c
index 540925e4a7a8..c450a635e54b 100644
--- a/net/ipv6/netfilter/ip6t_dst.c
+++ b/net/ipv6/netfilter/ip6t_dst.c
@@ -63,8 +63,6 @@ match(const struct sk_buff *skb,
63 struct ipv6_opt_hdr _optsh, *oh; 63 struct ipv6_opt_hdr _optsh, *oh;
64 const struct ip6t_opts *optinfo = matchinfo; 64 const struct ip6t_opts *optinfo = matchinfo;
65 unsigned int temp; 65 unsigned int temp;
66 unsigned int len;
67 u8 nexthdr;
68 unsigned int ptr; 66 unsigned int ptr;
69 unsigned int hdrlen = 0; 67 unsigned int hdrlen = 0;
70 unsigned int ret = 0; 68 unsigned int ret = 0;
@@ -72,97 +70,25 @@ match(const struct sk_buff *skb,
72 u8 _optlen, *lp = NULL; 70 u8 _optlen, *lp = NULL;
73 unsigned int optlen; 71 unsigned int optlen;
74 72
75 /* type of the 1st exthdr */
76 nexthdr = skb->nh.ipv6h->nexthdr;
77 /* pointer to the 1st exthdr */
78 ptr = sizeof(struct ipv6hdr);
79 /* available length */
80 len = skb->len - ptr;
81 temp = 0;
82
83 while (ip6t_ext_hdr(nexthdr)) {
84 struct ipv6_opt_hdr _hdr, *hp;
85
86 DEBUGP("ipv6_opts header iteration \n");
87
88 /* Is there enough space for the next ext header? */
89 if (len < (int)sizeof(struct ipv6_opt_hdr))
90 return 0;
91 /* No more exthdr -> evaluate */
92 if (nexthdr == NEXTHDR_NONE) {
93 break;
94 }
95 /* ESP -> evaluate */
96 if (nexthdr == NEXTHDR_ESP) {
97 break;
98 }
99
100 hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
101 BUG_ON(hp == NULL);
102
103 /* Calculate the header length */
104 if (nexthdr == NEXTHDR_FRAGMENT) {
105 hdrlen = 8;
106 } else if (nexthdr == NEXTHDR_AUTH)
107 hdrlen = (hp->hdrlen+2)<<2;
108 else
109 hdrlen = ipv6_optlen(hp);
110
111 /* OPTS -> evaluate */
112#if HOPBYHOP 73#if HOPBYHOP
113 if (nexthdr == NEXTHDR_HOP) { 74 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP) < 0)
114 temp |= MASK_HOPOPTS;
115#else 75#else
116 if (nexthdr == NEXTHDR_DEST) { 76 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST) < 0)
117 temp |= MASK_DSTOPTS;
118#endif 77#endif
119 break; 78 return 0;
120 }
121
122 79
123 /* set the flag */ 80 oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
124 switch (nexthdr){ 81 if (oh == NULL){
125 case NEXTHDR_HOP:
126 case NEXTHDR_ROUTING:
127 case NEXTHDR_FRAGMENT:
128 case NEXTHDR_AUTH:
129 case NEXTHDR_DEST:
130 break;
131 default:
132 DEBUGP("ipv6_opts match: unknown nextheader %u\n",nexthdr);
133 return 0;
134 break;
135 }
136
137 nexthdr = hp->nexthdr;
138 len -= hdrlen;
139 ptr += hdrlen;
140 if ( ptr > skb->len ) {
141 DEBUGP("ipv6_opts: new pointer is too large! \n");
142 break;
143 }
144 }
145
146 /* OPTIONS header not found */
147#if HOPBYHOP
148 if ( temp != MASK_HOPOPTS ) return 0;
149#else
150 if ( temp != MASK_DSTOPTS ) return 0;
151#endif
152
153 if (len < (int)sizeof(struct ipv6_opt_hdr)){
154 *hotdrop = 1; 82 *hotdrop = 1;
155 return 0; 83 return 0;
156 } 84 }
157 85
158 if (len < hdrlen){ 86 hdrlen = ipv6_optlen(oh);
87 if (skb->len - ptr < hdrlen){
159 /* Packet smaller than it's length field */ 88 /* Packet smaller than it's length field */
160 return 0; 89 return 0;
161 } 90 }
162 91
163 oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
164 BUG_ON(oh == NULL);
165
166 DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen); 92 DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen);
167 93
168 DEBUGP("len %02X %04X %02X ", 94 DEBUGP("len %02X %04X %02X ",
diff --git a/net/ipv6/netfilter/ip6t_esp.c b/net/ipv6/netfilter/ip6t_esp.c
index e39dd236fd8e..24bc0cde43a1 100644
--- a/net/ipv6/netfilter/ip6t_esp.c
+++ b/net/ipv6/netfilter/ip6t_esp.c
@@ -48,87 +48,22 @@ match(const struct sk_buff *skb,
48 unsigned int protoff, 48 unsigned int protoff,
49 int *hotdrop) 49 int *hotdrop)
50{ 50{
51 struct ip_esp_hdr _esp, *eh = NULL; 51 struct ip_esp_hdr _esp, *eh;
52 const struct ip6t_esp *espinfo = matchinfo; 52 const struct ip6t_esp *espinfo = matchinfo;
53 unsigned int temp;
54 int len;
55 u8 nexthdr;
56 unsigned int ptr; 53 unsigned int ptr;
57 54
58 /* Make sure this isn't an evil packet */ 55 /* Make sure this isn't an evil packet */
59 /*DEBUGP("ipv6_esp entered \n");*/ 56 /*DEBUGP("ipv6_esp entered \n");*/
60 57
61 /* type of the 1st exthdr */ 58 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ESP) < 0)
62 nexthdr = skb->nh.ipv6h->nexthdr;
63 /* pointer to the 1st exthdr */
64 ptr = sizeof(struct ipv6hdr);
65 /* available length */
66 len = skb->len - ptr;
67 temp = 0;
68
69 while (ip6t_ext_hdr(nexthdr)) {
70 struct ipv6_opt_hdr _hdr, *hp;
71 int hdrlen;
72
73 DEBUGP("ipv6_esp header iteration \n");
74
75 /* Is there enough space for the next ext header? */
76 if (len < sizeof(struct ipv6_opt_hdr))
77 return 0;
78 /* No more exthdr -> evaluate */
79 if (nexthdr == NEXTHDR_NONE)
80 break;
81 /* ESP -> evaluate */
82 if (nexthdr == NEXTHDR_ESP) {
83 temp |= MASK_ESP;
84 break;
85 }
86
87 hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
88 BUG_ON(hp == NULL);
89
90 /* Calculate the header length */
91 if (nexthdr == NEXTHDR_FRAGMENT)
92 hdrlen = 8;
93 else if (nexthdr == NEXTHDR_AUTH)
94 hdrlen = (hp->hdrlen+2)<<2;
95 else
96 hdrlen = ipv6_optlen(hp);
97
98 /* set the flag */
99 switch (nexthdr) {
100 case NEXTHDR_HOP:
101 case NEXTHDR_ROUTING:
102 case NEXTHDR_FRAGMENT:
103 case NEXTHDR_AUTH:
104 case NEXTHDR_DEST:
105 break;
106 default:
107 DEBUGP("ipv6_esp match: unknown nextheader %u\n",nexthdr);
108 return 0;
109 }
110
111 nexthdr = hp->nexthdr;
112 len -= hdrlen;
113 ptr += hdrlen;
114 if (ptr > skb->len) {
115 DEBUGP("ipv6_esp: new pointer too large! \n");
116 break;
117 }
118 }
119
120 /* ESP header not found */
121 if (temp != MASK_ESP)
122 return 0; 59 return 0;
123 60
124 if (len < sizeof(struct ip_esp_hdr)) { 61 eh = skb_header_pointer(skb, ptr, sizeof(_esp), &_esp);
62 if (eh == NULL) {
125 *hotdrop = 1; 63 *hotdrop = 1;
126 return 0; 64 return 0;
127 } 65 }
128 66
129 eh = skb_header_pointer(skb, ptr, sizeof(_esp), &_esp);
130 BUG_ON(eh == NULL);
131
132 DEBUGP("IPv6 ESP SPI %u %08X\n", ntohl(eh->spi), ntohl(eh->spi)); 67 DEBUGP("IPv6 ESP SPI %u %08X\n", ntohl(eh->spi), ntohl(eh->spi));
133 68
134 return (eh != NULL) 69 return (eh != NULL)
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
index 4bfa30a9bc80..085d5f8eea29 100644
--- a/net/ipv6/netfilter/ip6t_frag.c
+++ b/net/ipv6/netfilter/ip6t_frag.c
@@ -48,90 +48,18 @@ match(const struct sk_buff *skb,
48 unsigned int protoff, 48 unsigned int protoff,
49 int *hotdrop) 49 int *hotdrop)
50{ 50{
51 struct frag_hdr _frag, *fh = NULL; 51 struct frag_hdr _frag, *fh;
52 const struct ip6t_frag *fraginfo = matchinfo; 52 const struct ip6t_frag *fraginfo = matchinfo;
53 unsigned int temp;
54 int len;
55 u8 nexthdr;
56 unsigned int ptr; 53 unsigned int ptr;
57 unsigned int hdrlen = 0;
58
59 /* type of the 1st exthdr */
60 nexthdr = skb->nh.ipv6h->nexthdr;
61 /* pointer to the 1st exthdr */
62 ptr = sizeof(struct ipv6hdr);
63 /* available length */
64 len = skb->len - ptr;
65 temp = 0;
66
67 while (ip6t_ext_hdr(nexthdr)) {
68 struct ipv6_opt_hdr _hdr, *hp;
69
70 DEBUGP("ipv6_frag header iteration \n");
71
72 /* Is there enough space for the next ext header? */
73 if (len < (int)sizeof(struct ipv6_opt_hdr))
74 return 0;
75 /* No more exthdr -> evaluate */
76 if (nexthdr == NEXTHDR_NONE) {
77 break;
78 }
79 /* ESP -> evaluate */
80 if (nexthdr == NEXTHDR_ESP) {
81 break;
82 }
83
84 hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
85 BUG_ON(hp == NULL);
86
87 /* Calculate the header length */
88 if (nexthdr == NEXTHDR_FRAGMENT) {
89 hdrlen = 8;
90 } else if (nexthdr == NEXTHDR_AUTH)
91 hdrlen = (hp->hdrlen+2)<<2;
92 else
93 hdrlen = ipv6_optlen(hp);
94
95 /* FRAG -> evaluate */
96 if (nexthdr == NEXTHDR_FRAGMENT) {
97 temp |= MASK_FRAGMENT;
98 break;
99 }
100
101
102 /* set the flag */
103 switch (nexthdr){
104 case NEXTHDR_HOP:
105 case NEXTHDR_ROUTING:
106 case NEXTHDR_FRAGMENT:
107 case NEXTHDR_AUTH:
108 case NEXTHDR_DEST:
109 break;
110 default:
111 DEBUGP("ipv6_frag match: unknown nextheader %u\n",nexthdr);
112 return 0;
113 break;
114 }
115
116 nexthdr = hp->nexthdr;
117 len -= hdrlen;
118 ptr += hdrlen;
119 if ( ptr > skb->len ) {
120 DEBUGP("ipv6_frag: new pointer too large! \n");
121 break;
122 }
123 }
124
125 /* FRAG header not found */
126 if ( temp != MASK_FRAGMENT ) return 0;
127
128 if (len < sizeof(struct frag_hdr)){
129 *hotdrop = 1;
130 return 0;
131 }
132 54
133 fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag); 55 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT) < 0)
134 BUG_ON(fh == NULL); 56 return 0;
57
58 fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag);
59 if (fh == NULL){
60 *hotdrop = 1;
61 return 0;
62 }
135 63
136 DEBUGP("INFO %04X ", fh->frag_off); 64 DEBUGP("INFO %04X ", fh->frag_off);
137 DEBUGP("OFFSET %04X ", ntohs(fh->frag_off) & ~0x7); 65 DEBUGP("OFFSET %04X ", ntohs(fh->frag_off) & ~0x7);
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index 27f3650d127e..1d09485111d0 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -63,8 +63,6 @@ match(const struct sk_buff *skb,
63 struct ipv6_opt_hdr _optsh, *oh; 63 struct ipv6_opt_hdr _optsh, *oh;
64 const struct ip6t_opts *optinfo = matchinfo; 64 const struct ip6t_opts *optinfo = matchinfo;
65 unsigned int temp; 65 unsigned int temp;
66 unsigned int len;
67 u8 nexthdr;
68 unsigned int ptr; 66 unsigned int ptr;
69 unsigned int hdrlen = 0; 67 unsigned int hdrlen = 0;
70 unsigned int ret = 0; 68 unsigned int ret = 0;
@@ -72,97 +70,25 @@ match(const struct sk_buff *skb,
72 u8 _optlen, *lp = NULL; 70 u8 _optlen, *lp = NULL;
73 unsigned int optlen; 71 unsigned int optlen;
74 72
75 /* type of the 1st exthdr */
76 nexthdr = skb->nh.ipv6h->nexthdr;
77 /* pointer to the 1st exthdr */
78 ptr = sizeof(struct ipv6hdr);
79 /* available length */
80 len = skb->len - ptr;
81 temp = 0;
82
83 while (ip6t_ext_hdr(nexthdr)) {
84 struct ipv6_opt_hdr _hdr, *hp;
85
86 DEBUGP("ipv6_opts header iteration \n");
87
88 /* Is there enough space for the next ext header? */
89 if (len < (int)sizeof(struct ipv6_opt_hdr))
90 return 0;
91 /* No more exthdr -> evaluate */
92 if (nexthdr == NEXTHDR_NONE) {
93 break;
94 }
95 /* ESP -> evaluate */
96 if (nexthdr == NEXTHDR_ESP) {
97 break;
98 }
99
100 hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
101 BUG_ON(hp == NULL);
102
103 /* Calculate the header length */
104 if (nexthdr == NEXTHDR_FRAGMENT) {
105 hdrlen = 8;
106 } else if (nexthdr == NEXTHDR_AUTH)
107 hdrlen = (hp->hdrlen+2)<<2;
108 else
109 hdrlen = ipv6_optlen(hp);
110
111 /* OPTS -> evaluate */
112#if HOPBYHOP 73#if HOPBYHOP
113 if (nexthdr == NEXTHDR_HOP) { 74 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP) < 0)
114 temp |= MASK_HOPOPTS;
115#else 75#else
116 if (nexthdr == NEXTHDR_DEST) { 76 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST) < 0)
117 temp |= MASK_DSTOPTS;
118#endif 77#endif
119 break; 78 return 0;
120 }
121
122 79
123 /* set the flag */ 80 oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
124 switch (nexthdr){ 81 if (oh == NULL){
125 case NEXTHDR_HOP:
126 case NEXTHDR_ROUTING:
127 case NEXTHDR_FRAGMENT:
128 case NEXTHDR_AUTH:
129 case NEXTHDR_DEST:
130 break;
131 default:
132 DEBUGP("ipv6_opts match: unknown nextheader %u\n",nexthdr);
133 return 0;
134 break;
135 }
136
137 nexthdr = hp->nexthdr;
138 len -= hdrlen;
139 ptr += hdrlen;
140 if ( ptr > skb->len ) {
141 DEBUGP("ipv6_opts: new pointer is too large! \n");
142 break;
143 }
144 }
145
146 /* OPTIONS header not found */
147#if HOPBYHOP
148 if ( temp != MASK_HOPOPTS ) return 0;
149#else
150 if ( temp != MASK_DSTOPTS ) return 0;
151#endif
152
153 if (len < (int)sizeof(struct ipv6_opt_hdr)){
154 *hotdrop = 1; 82 *hotdrop = 1;
155 return 0; 83 return 0;
156 } 84 }
157 85
158 if (len < hdrlen){ 86 hdrlen = ipv6_optlen(oh);
87 if (skb->len - ptr < hdrlen){
159 /* Packet smaller than it's length field */ 88 /* Packet smaller than it's length field */
160 return 0; 89 return 0;
161 } 90 }
162 91
163 oh = skb_header_pointer(skb, ptr, sizeof(_optsh), &_optsh);
164 BUG_ON(oh == NULL);
165
166 DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen); 92 DEBUGP("IPv6 OPTS LEN %u %u ", hdrlen, oh->hdrlen);
167 93
168 DEBUGP("len %02X %04X %02X ", 94 DEBUGP("len %02X %04X %02X ",
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index 2bb670037df3..beb2fd5cebbb 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -50,98 +50,29 @@ match(const struct sk_buff *skb,
50 unsigned int protoff, 50 unsigned int protoff,
51 int *hotdrop) 51 int *hotdrop)
52{ 52{
53 struct ipv6_rt_hdr _route, *rh = NULL; 53 struct ipv6_rt_hdr _route, *rh;
54 const struct ip6t_rt *rtinfo = matchinfo; 54 const struct ip6t_rt *rtinfo = matchinfo;
55 unsigned int temp; 55 unsigned int temp;
56 unsigned int len;
57 u8 nexthdr;
58 unsigned int ptr; 56 unsigned int ptr;
59 unsigned int hdrlen = 0; 57 unsigned int hdrlen = 0;
60 unsigned int ret = 0; 58 unsigned int ret = 0;
61 struct in6_addr *ap, _addr; 59 struct in6_addr *ap, _addr;
62 60
63 /* type of the 1st exthdr */ 61 if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ROUTING) < 0)
64 nexthdr = skb->nh.ipv6h->nexthdr; 62 return 0;
65 /* pointer to the 1st exthdr */
66 ptr = sizeof(struct ipv6hdr);
67 /* available length */
68 len = skb->len - ptr;
69 temp = 0;
70 63
71 while (ip6t_ext_hdr(nexthdr)) { 64 rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route);
72 struct ipv6_opt_hdr _hdr, *hp; 65 if (rh == NULL){
73
74 DEBUGP("ipv6_rt header iteration \n");
75
76 /* Is there enough space for the next ext header? */
77 if (len < (int)sizeof(struct ipv6_opt_hdr))
78 return 0;
79 /* No more exthdr -> evaluate */
80 if (nexthdr == NEXTHDR_NONE) {
81 break;
82 }
83 /* ESP -> evaluate */
84 if (nexthdr == NEXTHDR_ESP) {
85 break;
86 }
87
88 hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr);
89 BUG_ON(hp == NULL);
90
91 /* Calculate the header length */
92 if (nexthdr == NEXTHDR_FRAGMENT) {
93 hdrlen = 8;
94 } else if (nexthdr == NEXTHDR_AUTH)
95 hdrlen = (hp->hdrlen+2)<<2;
96 else
97 hdrlen = ipv6_optlen(hp);
98
99 /* ROUTING -> evaluate */
100 if (nexthdr == NEXTHDR_ROUTING) {
101 temp |= MASK_ROUTING;
102 break;
103 }
104
105
106 /* set the flag */
107 switch (nexthdr){
108 case NEXTHDR_HOP:
109 case NEXTHDR_ROUTING:
110 case NEXTHDR_FRAGMENT:
111 case NEXTHDR_AUTH:
112 case NEXTHDR_DEST:
113 break;
114 default:
115 DEBUGP("ipv6_rt match: unknown nextheader %u\n",nexthdr);
116 return 0;
117 break;
118 }
119
120 nexthdr = hp->nexthdr;
121 len -= hdrlen;
122 ptr += hdrlen;
123 if ( ptr > skb->len ) {
124 DEBUGP("ipv6_rt: new pointer is too large! \n");
125 break;
126 }
127 }
128
129 /* ROUTING header not found */
130 if ( temp != MASK_ROUTING ) return 0;
131
132 if (len < (int)sizeof(struct ipv6_rt_hdr)){
133 *hotdrop = 1; 66 *hotdrop = 1;
134 return 0; 67 return 0;
135 } 68 }
136 69
137 if (len < hdrlen){ 70 hdrlen = ipv6_optlen(rh);
71 if (skb->len - ptr < hdrlen){
138 /* Pcket smaller than its length field */ 72 /* Pcket smaller than its length field */
139 return 0; 73 return 0;
140 } 74 }
141 75
142 rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route);
143 BUG_ON(rh == NULL);
144
145 DEBUGP("IPv6 RT LEN %u %u ", hdrlen, rh->hdrlen); 76 DEBUGP("IPv6 RT LEN %u %u ", hdrlen, rh->hdrlen);
146 DEBUGP("TYPE %04X ", rh->type); 77 DEBUGP("TYPE %04X ", rh->type);
147 DEBUGP("SGS_LEFT %u %02X\n", rh->segments_left, rh->segments_left); 78 DEBUGP("SGS_LEFT %u %02X\n", rh->segments_left, rh->segments_left);
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 5aa3691c578d..a1265a320b11 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -627,7 +627,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
627 627
628 if (type && code) { 628 if (type && code) {
629 get_user(fl->fl_icmp_type, type); 629 get_user(fl->fl_icmp_type, type);
630 __get_user(fl->fl_icmp_code, code); 630 get_user(fl->fl_icmp_code, code);
631 probed = 1; 631 probed = 1;
632 } 632 }
633 break; 633 break;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 80643e6b346b..d693cb988b78 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -209,9 +209,11 @@ static __inline__ void __tcp_v6_hash(struct sock *sk)
209 lock = &tcp_hashinfo.lhash_lock; 209 lock = &tcp_hashinfo.lhash_lock;
210 inet_listen_wlock(&tcp_hashinfo); 210 inet_listen_wlock(&tcp_hashinfo);
211 } else { 211 } else {
212 sk->sk_hashent = inet6_sk_ehashfn(sk, tcp_hashinfo.ehash_size); 212 unsigned int hash;
213 list = &tcp_hashinfo.ehash[sk->sk_hashent].chain; 213 sk->sk_hash = hash = inet6_sk_ehashfn(sk);
214 lock = &tcp_hashinfo.ehash[sk->sk_hashent].lock; 214 hash &= (tcp_hashinfo.ehash_size - 1);
215 list = &tcp_hashinfo.ehash[hash].chain;
216 lock = &tcp_hashinfo.ehash[hash].lock;
215 write_lock(lock); 217 write_lock(lock);
216 } 218 }
217 219
@@ -322,13 +324,13 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport,
322 const struct in6_addr *saddr = &np->daddr; 324 const struct in6_addr *saddr = &np->daddr;
323 const int dif = sk->sk_bound_dev_if; 325 const int dif = sk->sk_bound_dev_if;
324 const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); 326 const u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
325 const int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport, 327 unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport);
326 tcp_hashinfo.ehash_size); 328 struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash);
327 struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash];
328 struct sock *sk2; 329 struct sock *sk2;
329 const struct hlist_node *node; 330 const struct hlist_node *node;
330 struct inet_timewait_sock *tw; 331 struct inet_timewait_sock *tw;
331 332
333 prefetch(head->chain.first);
332 write_lock(&head->lock); 334 write_lock(&head->lock);
333 335
334 /* Check TIME-WAIT sockets first. */ 336 /* Check TIME-WAIT sockets first. */
@@ -365,14 +367,14 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport,
365 367
366 /* And established part... */ 368 /* And established part... */
367 sk_for_each(sk2, node, &head->chain) { 369 sk_for_each(sk2, node, &head->chain) {
368 if (INET6_MATCH(sk2, saddr, daddr, ports, dif)) 370 if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif))
369 goto not_unique; 371 goto not_unique;
370 } 372 }
371 373
372unique: 374unique:
373 BUG_TRAP(sk_unhashed(sk)); 375 BUG_TRAP(sk_unhashed(sk));
374 __sk_add_node(sk, &head->chain); 376 __sk_add_node(sk, &head->chain);
375 sk->sk_hashent = hash; 377 sk->sk_hash = hash;
376 sock_prot_inc_use(sk->sk_prot); 378 sock_prot_inc_use(sk->sk_prot);
377 write_unlock(&head->lock); 379 write_unlock(&head->lock);
378 380
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 2b9bf9bd177f..bf9519341fd3 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -99,7 +99,7 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
99 next:; 99 next:;
100 } 100 }
101 result = best; 101 result = best;
102 for(;; result += UDP_HTABLE_SIZE) { 102 for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) {
103 if (result > sysctl_local_port_range[1]) 103 if (result > sysctl_local_port_range[1])
104 result = sysctl_local_port_range[0] 104 result = sysctl_local_port_range[0]
105 + ((result - sysctl_local_port_range[0]) & 105 + ((result - sysctl_local_port_range[0]) &
@@ -107,6 +107,8 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum)
107 if (!udp_lport_inuse(result)) 107 if (!udp_lport_inuse(result))
108 break; 108 break;
109 } 109 }
110 if (i >= (1 << 16) / UDP_HTABLE_SIZE)
111 goto fail;
110gotit: 112gotit:
111 udp_port_rover = snum = result; 113 udp_port_rover = snum = result;
112 } else { 114 } else {
@@ -639,6 +641,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
639 int tclass = -1; 641 int tclass = -1;
640 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 642 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
641 int err; 643 int err;
644 int connected = 0;
642 645
643 /* destination address check */ 646 /* destination address check */
644 if (sin6) { 647 if (sin6) {
@@ -748,6 +751,7 @@ do_udp_sendmsg:
748 fl->fl_ip_dport = inet->dport; 751 fl->fl_ip_dport = inet->dport;
749 daddr = &np->daddr; 752 daddr = &np->daddr;
750 fl->fl6_flowlabel = np->flow_label; 753 fl->fl6_flowlabel = np->flow_label;
754 connected = 1;
751 } 755 }
752 756
753 if (!fl->oif) 757 if (!fl->oif)
@@ -770,6 +774,7 @@ do_udp_sendmsg:
770 } 774 }
771 if (!(opt->opt_nflen|opt->opt_flen)) 775 if (!(opt->opt_nflen|opt->opt_flen))
772 opt = NULL; 776 opt = NULL;
777 connected = 0;
773 } 778 }
774 if (opt == NULL) 779 if (opt == NULL)
775 opt = np->opt; 780 opt = np->opt;
@@ -787,10 +792,13 @@ do_udp_sendmsg:
787 ipv6_addr_copy(&final, &fl->fl6_dst); 792 ipv6_addr_copy(&final, &fl->fl6_dst);
788 ipv6_addr_copy(&fl->fl6_dst, rt0->addr); 793 ipv6_addr_copy(&fl->fl6_dst, rt0->addr);
789 final_p = &final; 794 final_p = &final;
795 connected = 0;
790 } 796 }
791 797
792 if (!fl->oif && ipv6_addr_is_multicast(&fl->fl6_dst)) 798 if (!fl->oif && ipv6_addr_is_multicast(&fl->fl6_dst)) {
793 fl->oif = np->mcast_oif; 799 fl->oif = np->mcast_oif;
800 connected = 0;
801 }
794 802
795 err = ip6_dst_lookup(sk, &dst, fl); 803 err = ip6_dst_lookup(sk, &dst, fl);
796 if (err) 804 if (err)
@@ -846,10 +854,16 @@ do_append_data:
846 else if (!corkreq) 854 else if (!corkreq)
847 err = udp_v6_push_pending_frames(sk, up); 855 err = udp_v6_push_pending_frames(sk, up);
848 856
849 if (dst) 857 if (dst) {
850 ip6_dst_store(sk, dst, 858 if (connected) {
851 ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? 859 ip6_dst_store(sk, dst,
852 &np->daddr : NULL); 860 ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ?
861 &np->daddr : NULL);
862 } else {
863 dst_release(dst);
864 }
865 }
866
853 if (err > 0) 867 if (err > 0)
854 err = np->recverr ? net_xmit_errno(err) : 0; 868 err = np->recverr ? net_xmit_errno(err) : 0;
855 release_sock(sk); 869 release_sock(sk);
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index 071cd2cefd8a..953e255d2bc8 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -310,7 +310,7 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
310#ifdef CONFIG_INET 310#ifdef CONFIG_INET
311 IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n"); 311 IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n");
312 rcu_read_lock(); 312 rcu_read_lock();
313 in_dev = __in_dev_get(dev); 313 in_dev = __in_dev_get_rcu(dev);
314 if (in_dev == NULL) 314 if (in_dev == NULL)
315 goto out; 315 goto out;
316 if (in_dev->ifa_list) 316 if (in_dev->ifa_list)
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 6602d901f8b1..8aff254cb418 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -38,7 +38,7 @@
38#include <net/irda/parameters.h> 38#include <net/irda/parameters.h>
39#include <net/irda/irttp.h> 39#include <net/irda/irttp.h>
40 40
41static struct irttp_cb *irttp = NULL; 41static struct irttp_cb *irttp;
42 42
43static void __irttp_close_tsap(struct tsap_cb *self); 43static void __irttp_close_tsap(struct tsap_cb *self);
44 44
@@ -86,12 +86,9 @@ static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 };
86 */ 86 */
87int __init irttp_init(void) 87int __init irttp_init(void)
88{ 88{
89 /* Initialize the irttp structure. */ 89 irttp = kmalloc(sizeof(struct irttp_cb), GFP_KERNEL);
90 if (irttp == NULL) { 90 if (irttp == NULL)
91 irttp = kmalloc(sizeof(struct irttp_cb), GFP_KERNEL); 91 return -ENOMEM;
92 if (irttp == NULL)
93 return -ENOMEM;
94 }
95 memset(irttp, 0, sizeof(struct irttp_cb)); 92 memset(irttp, 0, sizeof(struct irttp_cb));
96 93
97 irttp->magic = TTP_MAGIC; 94 irttp->magic = TTP_MAGIC;
@@ -100,6 +97,7 @@ int __init irttp_init(void)
100 if (!irttp->tsaps) { 97 if (!irttp->tsaps) {
101 IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n", 98 IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n",
102 __FUNCTION__); 99 __FUNCTION__);
100 kfree(irttp);
103 return -ENOMEM; 101 return -ENOMEM;
104 } 102 }
105 103
@@ -115,7 +113,6 @@ int __init irttp_init(void)
115void __exit irttp_cleanup(void) 113void __exit irttp_cleanup(void)
116{ 114{
117 /* Check for main structure */ 115 /* Check for main structure */
118 IRDA_ASSERT(irttp != NULL, return;);
119 IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;); 116 IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
120 117
121 /* 118 /*
@@ -382,7 +379,6 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
382 struct lsap_cb *lsap; 379 struct lsap_cb *lsap;
383 notify_t ttp_notify; 380 notify_t ttp_notify;
384 381
385 IRDA_ASSERT(irttp != NULL, return NULL;);
386 IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;); 382 IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;);
387 383
388 /* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to 384 /* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to
@@ -1880,8 +1876,6 @@ static int irttp_seq_open(struct inode *inode, struct file *file)
1880 struct seq_file *seq; 1876 struct seq_file *seq;
1881 int rc = -ENOMEM; 1877 int rc = -ENOMEM;
1882 struct irttp_iter_state *s; 1878 struct irttp_iter_state *s;
1883
1884 IRDA_ASSERT(irttp != NULL, return -EINVAL;);
1885 1879
1886 s = kmalloc(sizeof(*s), GFP_KERNEL); 1880 s = kmalloc(sizeof(*s), GFP_KERNEL);
1887 if (!s) 1881 if (!s)
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 4879743b945a..39031684b65c 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -185,7 +185,7 @@ static int pfkey_release(struct socket *sock)
185} 185}
186 186
187static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2, 187static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
188 int allocation, struct sock *sk) 188 gfp_t allocation, struct sock *sk)
189{ 189{
190 int err = -ENOBUFS; 190 int err = -ENOBUFS;
191 191
@@ -217,7 +217,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
217#define BROADCAST_ONE 1 217#define BROADCAST_ONE 1
218#define BROADCAST_REGISTERED 2 218#define BROADCAST_REGISTERED 2
219#define BROADCAST_PROMISC_ONLY 4 219#define BROADCAST_PROMISC_ONLY 4
220static int pfkey_broadcast(struct sk_buff *skb, int allocation, 220static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
221 int broadcast_flags, struct sock *one_sk) 221 int broadcast_flags, struct sock *one_sk)
222{ 222{
223 struct sock *sk; 223 struct sock *sk;
@@ -1416,7 +1416,8 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
1416 return 0; 1416 return 0;
1417} 1417}
1418 1418
1419static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig, int allocation) 1419static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig,
1420 gfp_t allocation)
1420{ 1421{
1421 struct sk_buff *skb; 1422 struct sk_buff *skb;
1422 struct sadb_msg *hdr; 1423 struct sadb_msg *hdr;
@@ -2153,6 +2154,7 @@ out:
2153 2154
2154static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs) 2155static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs)
2155{ 2156{
2157 unsigned int dir;
2156 int err; 2158 int err;
2157 struct sadb_x_policy *pol; 2159 struct sadb_x_policy *pol;
2158 struct xfrm_policy *xp; 2160 struct xfrm_policy *xp;
@@ -2161,7 +2163,11 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2161 if ((pol = ext_hdrs[SADB_X_EXT_POLICY-1]) == NULL) 2163 if ((pol = ext_hdrs[SADB_X_EXT_POLICY-1]) == NULL)
2162 return -EINVAL; 2164 return -EINVAL;
2163 2165
2164 xp = xfrm_policy_byid(0, pol->sadb_x_policy_id, 2166 dir = xfrm_policy_id2dir(pol->sadb_x_policy_id);
2167 if (dir >= XFRM_POLICY_MAX)
2168 return -EINVAL;
2169
2170 xp = xfrm_policy_byid(dir, pol->sadb_x_policy_id,
2165 hdr->sadb_msg_type == SADB_X_SPDDELETE2); 2171 hdr->sadb_msg_type == SADB_X_SPDDELETE2);
2166 if (xp == NULL) 2172 if (xp == NULL)
2167 return -ENOENT; 2173 return -ENOENT;
@@ -2173,9 +2179,9 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2173 if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) { 2179 if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) {
2174 c.data.byid = 1; 2180 c.data.byid = 1;
2175 c.event = XFRM_MSG_DELPOLICY; 2181 c.event = XFRM_MSG_DELPOLICY;
2176 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); 2182 km_policy_notify(xp, dir, &c);
2177 } else { 2183 } else {
2178 err = key_pol_get_resp(sk, xp, hdr, pol->sadb_x_policy_dir-1); 2184 err = key_pol_get_resp(sk, xp, hdr, dir);
2179 } 2185 }
2180 2186
2181 xfrm_pol_put(xp); 2187 xfrm_pol_put(xp);
diff --git a/net/llc/Makefile b/net/llc/Makefile
index 5ebd4ed2bd42..4e260cff3c5d 100644
--- a/net/llc/Makefile
+++ b/net/llc/Makefile
@@ -22,3 +22,4 @@ llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \
22 llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o 22 llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o
23 23
24llc2-$(CONFIG_PROC_FS) += llc_proc.o 24llc2-$(CONFIG_PROC_FS) += llc_proc.o
25llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.o
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 66f55e514b56..59d02cbbeb9e 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -21,6 +21,7 @@
21 * See the GNU General Public License for more details. 21 * See the GNU General Public License for more details.
22 */ 22 */
23#include <linux/config.h> 23#include <linux/config.h>
24#include <linux/compiler.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/rtnetlink.h> 27#include <linux/rtnetlink.h>
@@ -37,10 +38,9 @@ static u16 llc_ui_sap_link_no_max[256];
37static struct sockaddr_llc llc_ui_addrnull; 38static struct sockaddr_llc llc_ui_addrnull;
38static struct proto_ops llc_ui_ops; 39static struct proto_ops llc_ui_ops;
39 40
40static int llc_ui_wait_for_conn(struct sock *sk, int timeout); 41static int llc_ui_wait_for_conn(struct sock *sk, long timeout);
41static int llc_ui_wait_for_disc(struct sock *sk, int timeout); 42static int llc_ui_wait_for_disc(struct sock *sk, long timeout);
42static int llc_ui_wait_for_data(struct sock *sk, int timeout); 43static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout);
43static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout);
44 44
45#if 0 45#if 0
46#define dprintk(args...) printk(KERN_DEBUG args) 46#define dprintk(args...) printk(KERN_DEBUG args)
@@ -116,12 +116,12 @@ static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
116 struct llc_sock* llc = llc_sk(sk); 116 struct llc_sock* llc = llc_sk(sk);
117 int rc = 0; 117 int rc = 0;
118 118
119 if (llc_data_accept_state(llc->state) || llc->p_flag) { 119 if (unlikely(llc_data_accept_state(llc->state) || llc->p_flag)) {
120 int timeout = sock_sndtimeo(sk, noblock); 120 long timeout = sock_sndtimeo(sk, noblock);
121 121
122 rc = llc_ui_wait_for_busy_core(sk, timeout); 122 rc = llc_ui_wait_for_busy_core(sk, timeout);
123 } 123 }
124 if (!rc) 124 if (unlikely(!rc))
125 rc = llc_build_and_send_pkt(sk, skb); 125 rc = llc_build_and_send_pkt(sk, skb);
126 return rc; 126 return rc;
127} 127}
@@ -155,7 +155,7 @@ static int llc_ui_create(struct socket *sock, int protocol)
155 struct sock *sk; 155 struct sock *sk;
156 int rc = -ESOCKTNOSUPPORT; 156 int rc = -ESOCKTNOSUPPORT;
157 157
158 if (sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM) { 158 if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) {
159 rc = -ENOMEM; 159 rc = -ENOMEM;
160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto); 160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto);
161 if (sk) { 161 if (sk) {
@@ -177,7 +177,7 @@ static int llc_ui_release(struct socket *sock)
177 struct sock *sk = sock->sk; 177 struct sock *sk = sock->sk;
178 struct llc_sock *llc; 178 struct llc_sock *llc;
179 179
180 if (!sk) 180 if (unlikely(sk == NULL))
181 goto out; 181 goto out;
182 sock_hold(sk); 182 sock_hold(sk);
183 lock_sock(sk); 183 lock_sock(sk);
@@ -189,10 +189,6 @@ static int llc_ui_release(struct socket *sock)
189 if (!sock_flag(sk, SOCK_ZAPPED)) 189 if (!sock_flag(sk, SOCK_ZAPPED))
190 llc_sap_remove_socket(llc->sap, sk); 190 llc_sap_remove_socket(llc->sap, sk);
191 release_sock(sk); 191 release_sock(sk);
192 if (llc->sap && hlist_empty(&llc->sap->sk_list.list)) {
193 llc_release_sockets(llc->sap);
194 llc_sap_close(llc->sap);
195 }
196 if (llc->dev) 192 if (llc->dev)
197 dev_put(llc->dev); 193 dev_put(llc->dev);
198 sock_put(sk); 194 sock_put(sk);
@@ -221,6 +217,7 @@ static int llc_ui_autoport(void)
221 llc_ui_sap_last_autoport = i + 2; 217 llc_ui_sap_last_autoport = i + 2;
222 goto out; 218 goto out;
223 } 219 }
220 llc_sap_put(sap);
224 } 221 }
225 llc_ui_sap_last_autoport = LLC_SAP_DYN_START; 222 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
226 tries++; 223 tries++;
@@ -231,20 +228,13 @@ out:
231} 228}
232 229
233/** 230/**
234 * llc_ui_autobind - Bind a socket to a specific address. 231 * llc_ui_autobind - automatically bind a socket to a sap
235 * @sk: Socket to bind an address to. 232 * @sock: socket to bind
236 * @addr: Address the user wants the socket bound to. 233 * @addr: address to connect to
234 *
235 * Used by llc_ui_connect and llc_ui_sendmsg when the user hasn't
236 * specifically used llc_ui_bind to bind to an specific address/sap
237 * 237 *
238 * Bind a socket to a specific address. For llc a user is able to bind to
239 * a specific sap only or mac + sap. If the user only specifies a sap and
240 * a null dmac (all zeros) the user is attempting to bind to an entire
241 * sap. This will stop anyone else on the local system from using that
242 * sap. If someone else has a mac + sap open the bind to null + sap will
243 * fail.
244 * If the user desires to bind to a specific mac + sap, it is possible to
245 * have multiple sap connections via multiple macs.
246 * Bind and autobind for that matter must enforce the correct sap usage
247 * otherwise all hell will break loose.
248 * Returns: 0 upon success, negative otherwise. 238 * Returns: 0 upon success, negative otherwise.
249 */ 239 */
250static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) 240static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
@@ -285,11 +275,7 @@ out:
285 * @addrlen: Length of the uaddr structure. 275 * @addrlen: Length of the uaddr structure.
286 * 276 *
287 * Bind a socket to a specific address. For llc a user is able to bind to 277 * Bind a socket to a specific address. For llc a user is able to bind to
288 * a specific sap only or mac + sap. If the user only specifies a sap and 278 * a specific sap only or mac + sap.
289 * a null dmac (all zeros) the user is attempting to bind to an entire
290 * sap. This will stop anyone else on the local system from using that
291 * sap. If someone else has a mac + sap open the bind to null + sap will
292 * fail.
293 * If the user desires to bind to a specific mac + sap, it is possible to 279 * If the user desires to bind to a specific mac + sap, it is possible to
294 * have multiple sap connections via multiple macs. 280 * have multiple sap connections via multiple macs.
295 * Bind and autobind for that matter must enforce the correct sap usage 281 * Bind and autobind for that matter must enforce the correct sap usage
@@ -305,10 +291,16 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
305 int rc = -EINVAL; 291 int rc = -EINVAL;
306 292
307 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap); 293 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap);
308 if (!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)) 294 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
309 goto out; 295 goto out;
310 rc = -EAFNOSUPPORT; 296 rc = -EAFNOSUPPORT;
311 if (addr->sllc_family != AF_LLC) 297 if (unlikely(addr->sllc_family != AF_LLC))
298 goto out;
299 rc = -ENODEV;
300 rtnl_lock();
301 llc->dev = dev_getbyhwaddr(addr->sllc_arphrd, addr->sllc_mac);
302 rtnl_unlock();
303 if (!llc->dev)
312 goto out; 304 goto out;
313 if (!addr->sllc_sap) { 305 if (!addr->sllc_sap) {
314 rc = -EUSERS; 306 rc = -EUSERS;
@@ -322,6 +314,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
322 rc = -EBUSY; /* some other network layer is using the sap */ 314 rc = -EBUSY; /* some other network layer is using the sap */
323 if (!sap) 315 if (!sap)
324 goto out; 316 goto out;
317 llc_sap_hold(sap);
325 } else { 318 } else {
326 struct llc_addr laddr, daddr; 319 struct llc_addr laddr, daddr;
327 struct sock *ask; 320 struct sock *ask;
@@ -338,7 +331,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
338 ask = llc_lookup_established(sap, &daddr, &laddr); 331 ask = llc_lookup_established(sap, &daddr, &laddr);
339 if (ask) { 332 if (ask) {
340 sock_put(ask); 333 sock_put(ask);
341 goto out; 334 goto out_put;
342 } 335 }
343 } 336 }
344 llc->laddr.lsap = addr->sllc_sap; 337 llc->laddr.lsap = addr->sllc_sap;
@@ -348,6 +341,8 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
348 llc_sap_add_socket(sap, sk); 341 llc_sap_add_socket(sap, sk);
349 sock_reset_flag(sk, SOCK_ZAPPED); 342 sock_reset_flag(sk, SOCK_ZAPPED);
350 rc = 0; 343 rc = 0;
344out_put:
345 llc_sap_put(sap);
351out: 346out:
352 return rc; 347 return rc;
353} 348}
@@ -369,7 +364,7 @@ static int llc_ui_shutdown(struct socket *sock, int how)
369 int rc = -ENOTCONN; 364 int rc = -ENOTCONN;
370 365
371 lock_sock(sk); 366 lock_sock(sk);
372 if (sk->sk_state != TCP_ESTABLISHED) 367 if (unlikely(sk->sk_state != TCP_ESTABLISHED))
373 goto out; 368 goto out;
374 rc = -EINVAL; 369 rc = -EINVAL;
375 if (how != 2) 370 if (how != 2)
@@ -404,14 +399,18 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
404 struct sock *sk = sock->sk; 399 struct sock *sk = sock->sk;
405 struct llc_sock *llc = llc_sk(sk); 400 struct llc_sock *llc = llc_sk(sk);
406 struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr; 401 struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;
407 struct net_device *dev;
408 int rc = -EINVAL; 402 int rc = -EINVAL;
409 403
410 lock_sock(sk); 404 lock_sock(sk);
411 if (addrlen != sizeof(*addr)) 405 if (unlikely(addrlen != sizeof(*addr)))
412 goto out; 406 goto out;
413 rc = -EAFNOSUPPORT; 407 rc = -EAFNOSUPPORT;
414 if (addr->sllc_family != AF_LLC) 408 if (unlikely(addr->sllc_family != AF_LLC))
409 goto out;
410 if (unlikely(sk->sk_type != SOCK_STREAM))
411 goto out;
412 rc = -EALREADY;
413 if (unlikely(sock->state == SS_CONNECTING))
415 goto out; 414 goto out;
416 /* bind connection to sap if user hasn't done it. */ 415 /* bind connection to sap if user hasn't done it. */
417 if (sock_flag(sk, SOCK_ZAPPED)) { 416 if (sock_flag(sk, SOCK_ZAPPED)) {
@@ -419,19 +418,13 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
419 rc = llc_ui_autobind(sock, addr); 418 rc = llc_ui_autobind(sock, addr);
420 if (rc) 419 if (rc)
421 goto out; 420 goto out;
422 llc->daddr.lsap = addr->sllc_sap;
423 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
424 } 421 }
425 dev = llc->dev; 422 llc->daddr.lsap = addr->sllc_sap;
426 if (sk->sk_type != SOCK_STREAM) 423 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
427 goto out;
428 rc = -EALREADY;
429 if (sock->state == SS_CONNECTING)
430 goto out;
431 sock->state = SS_CONNECTING; 424 sock->state = SS_CONNECTING;
432 sk->sk_state = TCP_SYN_SENT; 425 sk->sk_state = TCP_SYN_SENT;
433 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap); 426 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap);
434 rc = llc_establish_connection(sk, dev->dev_addr, 427 rc = llc_establish_connection(sk, llc->dev->dev_addr,
435 addr->sllc_mac, addr->sllc_sap); 428 addr->sllc_mac, addr->sllc_sap);
436 if (rc) { 429 if (rc) {
437 dprintk("%s: llc_ui_send_conn failed :-(\n", __FUNCTION__); 430 dprintk("%s: llc_ui_send_conn failed :-(\n", __FUNCTION__);
@@ -439,12 +432,30 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
439 sk->sk_state = TCP_CLOSE; 432 sk->sk_state = TCP_CLOSE;
440 goto out; 433 goto out;
441 } 434 }
442 rc = llc_ui_wait_for_conn(sk, sk->sk_rcvtimeo); 435
443 if (rc) 436 if (sk->sk_state == TCP_SYN_SENT) {
444 dprintk("%s: llc_ui_wait_for_conn failed=%d\n", __FUNCTION__, rc); 437 const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
438
439 if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
440 goto out;
441
442 rc = sock_intr_errno(timeo);
443 if (signal_pending(current))
444 goto out;
445 }
446
447 if (sk->sk_state == TCP_CLOSE)
448 goto sock_error;
449
450 sock->state = SS_CONNECTED;
451 rc = 0;
445out: 452out:
446 release_sock(sk); 453 release_sock(sk);
447 return rc; 454 return rc;
455sock_error:
456 rc = sock_error(sk) ? : -ECONNABORTED;
457 sock->state = SS_UNCONNECTED;
458 goto out;
448} 459}
449 460
450/** 461/**
@@ -461,10 +472,10 @@ static int llc_ui_listen(struct socket *sock, int backlog)
461 int rc = -EINVAL; 472 int rc = -EINVAL;
462 473
463 lock_sock(sk); 474 lock_sock(sk);
464 if (sock->state != SS_UNCONNECTED) 475 if (unlikely(sock->state != SS_UNCONNECTED))
465 goto out; 476 goto out;
466 rc = -EOPNOTSUPP; 477 rc = -EOPNOTSUPP;
467 if (sk->sk_type != SOCK_STREAM) 478 if (unlikely(sk->sk_type != SOCK_STREAM))
468 goto out; 479 goto out;
469 rc = -EAGAIN; 480 rc = -EAGAIN;
470 if (sock_flag(sk, SOCK_ZAPPED)) 481 if (sock_flag(sk, SOCK_ZAPPED))
@@ -483,20 +494,14 @@ out:
483 return rc; 494 return rc;
484} 495}
485 496
486static int llc_ui_wait_for_disc(struct sock *sk, int timeout) 497static int llc_ui_wait_for_disc(struct sock *sk, long timeout)
487{ 498{
488 DECLARE_WAITQUEUE(wait, current); 499 DEFINE_WAIT(wait);
489 int rc; 500 int rc = 0;
490 501
491 add_wait_queue_exclusive(sk->sk_sleep, &wait); 502 while (1) {
492 for (;;) { 503 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
493 __set_current_state(TASK_INTERRUPTIBLE); 504 if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE))
494 rc = 0;
495 if (sk->sk_state != TCP_CLOSE) {
496 release_sock(sk);
497 timeout = schedule_timeout(timeout);
498 lock_sock(sk);
499 } else
500 break; 505 break;
501 rc = -ERESTARTSYS; 506 rc = -ERESTARTSYS;
502 if (signal_pending(current)) 507 if (signal_pending(current))
@@ -504,65 +509,40 @@ static int llc_ui_wait_for_disc(struct sock *sk, int timeout)
504 rc = -EAGAIN; 509 rc = -EAGAIN;
505 if (!timeout) 510 if (!timeout)
506 break; 511 break;
512 rc = 0;
507 } 513 }
508 __set_current_state(TASK_RUNNING); 514 finish_wait(sk->sk_sleep, &wait);
509 remove_wait_queue(sk->sk_sleep, &wait);
510 return rc; 515 return rc;
511} 516}
512 517
513static int llc_ui_wait_for_conn(struct sock *sk, int timeout) 518static int llc_ui_wait_for_conn(struct sock *sk, long timeout)
514{ 519{
515 DECLARE_WAITQUEUE(wait, current); 520 DEFINE_WAIT(wait);
516 int rc;
517 521
518 add_wait_queue_exclusive(sk->sk_sleep, &wait); 522 while (1) {
519 for (;;) { 523 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
520 __set_current_state(TASK_INTERRUPTIBLE); 524 if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT))
521 rc = -EAGAIN;
522 if (sk->sk_state == TCP_CLOSE)
523 break;
524 rc = 0;
525 if (sk->sk_state != TCP_ESTABLISHED) {
526 release_sock(sk);
527 timeout = schedule_timeout(timeout);
528 lock_sock(sk);
529 } else
530 break; 525 break;
531 rc = -ERESTARTSYS; 526 if (signal_pending(current) || !timeout)
532 if (signal_pending(current))
533 break;
534 rc = -EAGAIN;
535 if (!timeout)
536 break; 527 break;
537 } 528 }
538 __set_current_state(TASK_RUNNING); 529 finish_wait(sk->sk_sleep, &wait);
539 remove_wait_queue(sk->sk_sleep, &wait); 530 return timeout;
540 return rc;
541} 531}
542 532
543static int llc_ui_wait_for_data(struct sock *sk, int timeout) 533static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout)
544{ 534{
545 DECLARE_WAITQUEUE(wait, current); 535 DEFINE_WAIT(wait);
546 int rc = 0; 536 struct llc_sock *llc = llc_sk(sk);
537 int rc;
547 538
548 add_wait_queue_exclusive(sk->sk_sleep, &wait); 539 while (1) {
549 for (;;) { 540 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
550 __set_current_state(TASK_INTERRUPTIBLE);
551 if (sk->sk_shutdown & RCV_SHUTDOWN)
552 break;
553 /*
554 * Well, if we have backlog, try to process it now.
555 */
556 if (sk->sk_backlog.tail) {
557 release_sock(sk);
558 lock_sock(sk);
559 }
560 rc = 0; 541 rc = 0;
561 if (skb_queue_empty(&sk->sk_receive_queue)) { 542 if (sk_wait_event(sk, &timeout,
562 release_sock(sk); 543 (sk->sk_shutdown & RCV_SHUTDOWN) ||
563 timeout = schedule_timeout(timeout); 544 (!llc_data_accept_state(llc->state) &&
564 lock_sock(sk); 545 !llc->p_flag)))
565 } else
566 break; 546 break;
567 rc = -ERESTARTSYS; 547 rc = -ERESTARTSYS;
568 if (signal_pending(current)) 548 if (signal_pending(current))
@@ -571,40 +551,35 @@ static int llc_ui_wait_for_data(struct sock *sk, int timeout)
571 if (!timeout) 551 if (!timeout)
572 break; 552 break;
573 } 553 }
574 __set_current_state(TASK_RUNNING); 554 finish_wait(sk->sk_sleep, &wait);
575 remove_wait_queue(sk->sk_sleep, &wait);
576 return rc; 555 return rc;
577} 556}
578 557
579static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout) 558static int llc_wait_data(struct sock *sk, long timeo)
580{ 559{
581 DECLARE_WAITQUEUE(wait, current);
582 struct llc_sock *llc = llc_sk(sk);
583 int rc; 560 int rc;
584 561
585 add_wait_queue_exclusive(sk->sk_sleep, &wait); 562 while (1) {
586 for (;;) { 563 /*
587 dprintk("%s: looping...\n", __FUNCTION__); 564 * POSIX 1003.1g mandates this order.
588 __set_current_state(TASK_INTERRUPTIBLE); 565 */
589 rc = -ENOTCONN; 566 if (sk->sk_err) {
590 if (sk->sk_shutdown & RCV_SHUTDOWN) 567 rc = sock_error(sk);
591 break; 568 break;
569 }
592 rc = 0; 570 rc = 0;
593 if (llc_data_accept_state(llc->state) || llc->p_flag) { 571 if (sk->sk_shutdown & RCV_SHUTDOWN)
594 release_sock(sk);
595 timeout = schedule_timeout(timeout);
596 lock_sock(sk);
597 } else
598 break; 572 break;
599 rc = -ERESTARTSYS; 573 rc = -EAGAIN;
574 if (!timeo)
575 break;
576 rc = sock_intr_errno(timeo);
600 if (signal_pending(current)) 577 if (signal_pending(current))
601 break; 578 break;
602 rc = -EAGAIN; 579 rc = 0;
603 if (!timeout) 580 if (sk_wait_data(sk, &timeo))
604 break; 581 break;
605 } 582 }
606 __set_current_state(TASK_RUNNING);
607 remove_wait_queue(sk->sk_sleep, &wait);
608 return rc; 583 return rc;
609} 584}
610 585
@@ -627,15 +602,18 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
627 dprintk("%s: accepting on %02X\n", __FUNCTION__, 602 dprintk("%s: accepting on %02X\n", __FUNCTION__,
628 llc_sk(sk)->laddr.lsap); 603 llc_sk(sk)->laddr.lsap);
629 lock_sock(sk); 604 lock_sock(sk);
630 if (sk->sk_type != SOCK_STREAM) 605 if (unlikely(sk->sk_type != SOCK_STREAM))
631 goto out; 606 goto out;
632 rc = -EINVAL; 607 rc = -EINVAL;
633 if (sock->state != SS_UNCONNECTED || sk->sk_state != TCP_LISTEN) 608 if (unlikely(sock->state != SS_UNCONNECTED ||
609 sk->sk_state != TCP_LISTEN))
634 goto out; 610 goto out;
635 /* wait for a connection to arrive. */ 611 /* wait for a connection to arrive. */
636 rc = llc_ui_wait_for_data(sk, sk->sk_rcvtimeo); 612 if (skb_queue_empty(&sk->sk_receive_queue)) {
637 if (rc) 613 rc = llc_wait_data(sk, sk->sk_rcvtimeo);
638 goto out; 614 if (rc)
615 goto out;
616 }
639 dprintk("%s: got a new connection on %02X\n", __FUNCTION__, 617 dprintk("%s: got a new connection on %02X\n", __FUNCTION__,
640 llc_sk(sk)->laddr.lsap); 618 llc_sk(sk)->laddr.lsap);
641 skb = skb_dequeue(&sk->sk_receive_queue); 619 skb = skb_dequeue(&sk->sk_receive_queue);
@@ -657,7 +635,6 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
657 /* put original socket back into a clean listen state. */ 635 /* put original socket back into a clean listen state. */
658 sk->sk_state = TCP_LISTEN; 636 sk->sk_state = TCP_LISTEN;
659 sk->sk_ack_backlog--; 637 sk->sk_ack_backlog--;
660 skb->sk = NULL;
661 dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__, 638 dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__,
662 llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap); 639 llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap);
663frees: 640frees:
@@ -671,56 +648,167 @@ out:
671 * llc_ui_recvmsg - copy received data to the socket user. 648 * llc_ui_recvmsg - copy received data to the socket user.
672 * @sock: Socket to copy data from. 649 * @sock: Socket to copy data from.
673 * @msg: Various user space related information. 650 * @msg: Various user space related information.
674 * @size: Size of user buffer. 651 * @len: Size of user buffer.
675 * @flags: User specified flags. 652 * @flags: User specified flags.
676 * 653 *
677 * Copy received data to the socket user. 654 * Copy received data to the socket user.
678 * Returns non-negative upon success, negative otherwise. 655 * Returns non-negative upon success, negative otherwise.
679 */ 656 */
680static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, 657static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
681 struct msghdr *msg, size_t size, int flags) 658 struct msghdr *msg, size_t len, int flags)
682{ 659{
683 struct sock *sk = sock->sk;
684 struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name; 660 struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name;
685 struct sk_buff *skb; 661 const int nonblock = flags & MSG_DONTWAIT;
662 struct sk_buff *skb = NULL;
663 struct sock *sk = sock->sk;
664 struct llc_sock *llc = llc_sk(sk);
686 size_t copied = 0; 665 size_t copied = 0;
687 int rc = -ENOMEM, timeout; 666 u32 peek_seq = 0;
688 int noblock = flags & MSG_DONTWAIT; 667 u32 *seq;
668 unsigned long used;
669 int target; /* Read at least this many bytes */
670 long timeo;
689 671
690 dprintk("%s: receiving in %02X from %02X\n", __FUNCTION__,
691 llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap);
692 lock_sock(sk); 672 lock_sock(sk);
693 timeout = sock_rcvtimeo(sk, noblock); 673 copied = -ENOTCONN;
694 rc = llc_ui_wait_for_data(sk, timeout); 674 if (sk->sk_state == TCP_LISTEN)
695 if (rc) {
696 dprintk("%s: llc_ui_wait_for_data failed recv "
697 "in %02X from %02X\n", __FUNCTION__,
698 llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap);
699 goto out; 675 goto out;
700 } 676
701 skb = skb_dequeue(&sk->sk_receive_queue); 677 timeo = sock_rcvtimeo(sk, nonblock);
702 if (!skb) /* shutdown */ 678
703 goto out; 679 seq = &llc->copied_seq;
704 copied = skb->len; 680 if (flags & MSG_PEEK) {
705 if (copied > size) 681 peek_seq = llc->copied_seq;
706 copied = size; 682 seq = &peek_seq;
707 rc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); 683 }
708 if (rc) 684
709 goto dgram_free; 685 target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
710 if (skb->len > copied) { 686 copied = 0;
711 skb_pull(skb, copied); 687
712 skb_queue_head(&sk->sk_receive_queue, skb); 688 do {
713 } 689 u32 offset;
714 if (uaddr) 690
715 memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); 691 /*
716 msg->msg_namelen = sizeof(*uaddr); 692 * We need to check signals first, to get correct SIGURG
717 if (!skb->next) { 693 * handling. FIXME: Need to check this doesn't impact 1003.1g
718dgram_free: 694 * and move it down to the bottom of the loop
719 kfree_skb(skb); 695 */
720 } 696 if (signal_pending(current)) {
697 if (copied)
698 break;
699 copied = timeo ? sock_intr_errno(timeo) : -EAGAIN;
700 break;
701 }
702
703 /* Next get a buffer. */
704
705 skb = skb_peek(&sk->sk_receive_queue);
706 if (skb) {
707 offset = *seq;
708 goto found_ok_skb;
709 }
710 /* Well, if we have backlog, try to process it now yet. */
711
712 if (copied >= target && !sk->sk_backlog.tail)
713 break;
714
715 if (copied) {
716 if (sk->sk_err ||
717 sk->sk_state == TCP_CLOSE ||
718 (sk->sk_shutdown & RCV_SHUTDOWN) ||
719 !timeo ||
720 (flags & MSG_PEEK))
721 break;
722 } else {
723 if (sock_flag(sk, SOCK_DONE))
724 break;
725
726 if (sk->sk_err) {
727 copied = sock_error(sk);
728 break;
729 }
730 if (sk->sk_shutdown & RCV_SHUTDOWN)
731 break;
732
733 if (sk->sk_state == TCP_CLOSE) {
734 if (!sock_flag(sk, SOCK_DONE)) {
735 /*
736 * This occurs when user tries to read
737 * from never connected socket.
738 */
739 copied = -ENOTCONN;
740 break;
741 }
742 break;
743 }
744 if (!timeo) {
745 copied = -EAGAIN;
746 break;
747 }
748 }
749
750 if (copied >= target) { /* Do not sleep, just process backlog. */
751 release_sock(sk);
752 lock_sock(sk);
753 } else
754 sk_wait_data(sk, &timeo);
755
756 if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) {
757 if (net_ratelimit())
758 printk(KERN_DEBUG "LLC(%s:%d): Application "
759 "bug, race in MSG_PEEK.\n",
760 current->comm, current->pid);
761 peek_seq = llc->copied_seq;
762 }
763 continue;
764 found_ok_skb:
765 /* Ok so how much can we use? */
766 used = skb->len - offset;
767 if (len < used)
768 used = len;
769
770 if (!(flags & MSG_TRUNC)) {
771 int rc = skb_copy_datagram_iovec(skb, offset,
772 msg->msg_iov, used);
773 if (rc) {
774 /* Exception. Bailout! */
775 if (!copied)
776 copied = -EFAULT;
777 break;
778 }
779 }
780
781 *seq += used;
782 copied += used;
783 len -= used;
784
785 if (used + offset < skb->len)
786 continue;
787
788 if (!(flags & MSG_PEEK)) {
789 sk_eat_skb(sk, skb);
790 *seq = 0;
791 }
792 } while (len > 0);
793
794 /*
795 * According to UNIX98, msg_name/msg_namelen are ignored
796 * on connected socket. -ANK
797 * But... af_llc still doesn't have separate sets of methods for
798 * SOCK_DGRAM and SOCK_STREAM :-( So we have to do this test, will
799 * eventually fix this tho :-) -acme
800 */
801 if (sk->sk_type == SOCK_DGRAM)
802 goto copy_uaddr;
721out: 803out:
722 release_sock(sk); 804 release_sock(sk);
723 return rc ? : copied; 805 return copied;
806copy_uaddr:
807 if (uaddr != NULL && skb != NULL) {
808 memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr));
809 msg->msg_namelen = sizeof(*uaddr);
810 }
811 goto out;
724} 812}
725 813
726/** 814/**
@@ -740,7 +828,6 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
740 struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name; 828 struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name;
741 int flags = msg->msg_flags; 829 int flags = msg->msg_flags;
742 int noblock = flags & MSG_DONTWAIT; 830 int noblock = flags & MSG_DONTWAIT;
743 struct net_device *dev;
744 struct sk_buff *skb; 831 struct sk_buff *skb;
745 size_t size = 0; 832 size_t size = 0;
746 int rc = -EINVAL, copied = 0, hdrlen; 833 int rc = -EINVAL, copied = 0, hdrlen;
@@ -763,19 +850,17 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
763 if (rc) 850 if (rc)
764 goto release; 851 goto release;
765 } 852 }
766 dev = llc->dev; 853 hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr);
767 hdrlen = dev->hard_header_len + llc_ui_header_len(sk, addr);
768 size = hdrlen + len; 854 size = hdrlen + len;
769 if (size > dev->mtu) 855 if (size > llc->dev->mtu)
770 size = dev->mtu; 856 size = llc->dev->mtu;
771 copied = size - hdrlen; 857 copied = size - hdrlen;
772 release_sock(sk); 858 release_sock(sk);
773 skb = sock_alloc_send_skb(sk, size, noblock, &rc); 859 skb = sock_alloc_send_skb(sk, size, noblock, &rc);
774 lock_sock(sk); 860 lock_sock(sk);
775 if (!skb) 861 if (!skb)
776 goto release; 862 goto release;
777 skb->sk = sk; 863 skb->dev = llc->dev;
778 skb->dev = dev;
779 skb->protocol = llc_proto_type(addr->sllc_arphrd); 864 skb->protocol = llc_proto_type(addr->sllc_arphrd);
780 skb_reserve(skb, hdrlen); 865 skb_reserve(skb, hdrlen);
781 rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied); 866 rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied);
@@ -800,15 +885,13 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
800 if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua)) 885 if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua))
801 goto out; 886 goto out;
802 rc = llc_ui_send_data(sk, skb, noblock); 887 rc = llc_ui_send_data(sk, skb, noblock);
803 if (rc)
804 dprintk("%s: llc_ui_send_data failed: %d\n", __FUNCTION__, rc);
805out: 888out:
806 if (rc) 889 if (rc) {
807 kfree_skb(skb); 890 kfree_skb(skb);
808release: 891release:
809 if (rc)
810 dprintk("%s: failed sending from %02X to %02X: %d\n", 892 dprintk("%s: failed sending from %02X to %02X: %d\n",
811 __FUNCTION__, llc->laddr.lsap, llc->daddr.lsap, rc); 893 __FUNCTION__, llc->laddr.lsap, llc->daddr.lsap, rc);
894 }
812 release_sock(sk); 895 release_sock(sk);
813 return rc ? : copied; 896 return rc ? : copied;
814} 897}
@@ -895,7 +978,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
895 int rc = -EINVAL, opt; 978 int rc = -EINVAL, opt;
896 979
897 lock_sock(sk); 980 lock_sock(sk);
898 if (level != SOL_LLC || optlen != sizeof(int)) 981 if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
899 goto out; 982 goto out;
900 rc = get_user(opt, (int __user *)optval); 983 rc = get_user(opt, (int __user *)optval);
901 if (rc) 984 if (rc)
@@ -915,22 +998,22 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
915 case LLC_OPT_ACK_TMR_EXP: 998 case LLC_OPT_ACK_TMR_EXP:
916 if (opt > LLC_OPT_MAX_ACK_TMR_EXP) 999 if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
917 goto out; 1000 goto out;
918 llc->ack_timer.expire = opt; 1001 llc->ack_timer.expire = opt * HZ;
919 break; 1002 break;
920 case LLC_OPT_P_TMR_EXP: 1003 case LLC_OPT_P_TMR_EXP:
921 if (opt > LLC_OPT_MAX_P_TMR_EXP) 1004 if (opt > LLC_OPT_MAX_P_TMR_EXP)
922 goto out; 1005 goto out;
923 llc->pf_cycle_timer.expire = opt; 1006 llc->pf_cycle_timer.expire = opt * HZ;
924 break; 1007 break;
925 case LLC_OPT_REJ_TMR_EXP: 1008 case LLC_OPT_REJ_TMR_EXP:
926 if (opt > LLC_OPT_MAX_REJ_TMR_EXP) 1009 if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
927 goto out; 1010 goto out;
928 llc->rej_sent_timer.expire = opt; 1011 llc->rej_sent_timer.expire = opt * HZ;
929 break; 1012 break;
930 case LLC_OPT_BUSY_TMR_EXP: 1013 case LLC_OPT_BUSY_TMR_EXP:
931 if (opt > LLC_OPT_MAX_BUSY_TMR_EXP) 1014 if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
932 goto out; 1015 goto out;
933 llc->busy_state_timer.expire = opt; 1016 llc->busy_state_timer.expire = opt * HZ;
934 break; 1017 break;
935 case LLC_OPT_TX_WIN: 1018 case LLC_OPT_TX_WIN:
936 if (opt > LLC_OPT_MAX_WIN) 1019 if (opt > LLC_OPT_MAX_WIN)
@@ -970,7 +1053,7 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
970 int val = 0, len = 0, rc = -EINVAL; 1053 int val = 0, len = 0, rc = -EINVAL;
971 1054
972 lock_sock(sk); 1055 lock_sock(sk);
973 if (level != SOL_LLC) 1056 if (unlikely(level != SOL_LLC))
974 goto out; 1057 goto out;
975 rc = get_user(len, optlen); 1058 rc = get_user(len, optlen);
976 if (rc) 1059 if (rc)
@@ -980,17 +1063,17 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
980 goto out; 1063 goto out;
981 switch (optname) { 1064 switch (optname) {
982 case LLC_OPT_RETRY: 1065 case LLC_OPT_RETRY:
983 val = llc->n2; break; 1066 val = llc->n2; break;
984 case LLC_OPT_SIZE: 1067 case LLC_OPT_SIZE:
985 val = llc->n1; break; 1068 val = llc->n1; break;
986 case LLC_OPT_ACK_TMR_EXP: 1069 case LLC_OPT_ACK_TMR_EXP:
987 val = llc->ack_timer.expire; break; 1070 val = llc->ack_timer.expire / HZ; break;
988 case LLC_OPT_P_TMR_EXP: 1071 case LLC_OPT_P_TMR_EXP:
989 val = llc->pf_cycle_timer.expire; break; 1072 val = llc->pf_cycle_timer.expire / HZ; break;
990 case LLC_OPT_REJ_TMR_EXP: 1073 case LLC_OPT_REJ_TMR_EXP:
991 val = llc->rej_sent_timer.expire; break; 1074 val = llc->rej_sent_timer.expire / HZ; break;
992 case LLC_OPT_BUSY_TMR_EXP: 1075 case LLC_OPT_BUSY_TMR_EXP:
993 val = llc->busy_state_timer.expire; break; 1076 val = llc->busy_state_timer.expire / HZ; break;
994 case LLC_OPT_TX_WIN: 1077 case LLC_OPT_TX_WIN:
995 val = llc->k; break; 1078 val = llc->k; break;
996 case LLC_OPT_RX_WIN: 1079 case LLC_OPT_RX_WIN:
@@ -1034,8 +1117,12 @@ static struct proto_ops llc_ui_ops = {
1034 .sendpage = sock_no_sendpage, 1117 .sendpage = sock_no_sendpage,
1035}; 1118};
1036 1119
1037extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); 1120static char llc_proc_err_msg[] __initdata =
1038extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); 1121 KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
1122static char llc_sysctl_err_msg[] __initdata =
1123 KERN_CRIT "LLC: Unable to register the sysctl entries\n";
1124static char llc_sock_err_msg[] __initdata =
1125 KERN_CRIT "LLC: Unable to register the network family\n";
1039 1126
1040static int __init llc2_init(void) 1127static int __init llc2_init(void)
1041{ 1128{
@@ -1048,13 +1135,28 @@ static int __init llc2_init(void)
1048 llc_station_init(); 1135 llc_station_init();
1049 llc_ui_sap_last_autoport = LLC_SAP_DYN_START; 1136 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
1050 rc = llc_proc_init(); 1137 rc = llc_proc_init();
1051 if (rc != 0) 1138 if (rc != 0) {
1139 printk(llc_proc_err_msg);
1052 goto out_unregister_llc_proto; 1140 goto out_unregister_llc_proto;
1053 sock_register(&llc_ui_family_ops); 1141 }
1142 rc = llc_sysctl_init();
1143 if (rc) {
1144 printk(llc_sysctl_err_msg);
1145 goto out_proc;
1146 }
1147 rc = sock_register(&llc_ui_family_ops);
1148 if (rc) {
1149 printk(llc_sock_err_msg);
1150 goto out_sysctl;
1151 }
1054 llc_add_pack(LLC_DEST_SAP, llc_sap_handler); 1152 llc_add_pack(LLC_DEST_SAP, llc_sap_handler);
1055 llc_add_pack(LLC_DEST_CONN, llc_conn_handler); 1153 llc_add_pack(LLC_DEST_CONN, llc_conn_handler);
1056out: 1154out:
1057 return rc; 1155 return rc;
1156out_sysctl:
1157 llc_sysctl_exit();
1158out_proc:
1159 llc_proc_exit();
1058out_unregister_llc_proto: 1160out_unregister_llc_proto:
1059 proto_unregister(&llc_proto); 1161 proto_unregister(&llc_proto);
1060 goto out; 1162 goto out;
@@ -1067,6 +1169,7 @@ static void __exit llc2_exit(void)
1067 llc_remove_pack(LLC_DEST_CONN); 1169 llc_remove_pack(LLC_DEST_CONN);
1068 sock_unregister(PF_LLC); 1170 sock_unregister(PF_LLC);
1069 llc_proc_exit(); 1171 llc_proc_exit();
1172 llc_sysctl_exit();
1070 proto_unregister(&llc_proto); 1173 proto_unregister(&llc_proto);
1071} 1174}
1072 1175
diff --git a/net/llc/llc_c_ac.c b/net/llc/llc_c_ac.c
index b218be4c10ec..b0bcfb1f12dd 100644
--- a/net/llc/llc_c_ac.c
+++ b/net/llc/llc_c_ac.c
@@ -60,23 +60,10 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb)
60 60
61int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb) 61int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb)
62{ 62{
63 int rc = -ENOTCONN; 63 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
64 u8 dsap;
65 struct llc_sap *sap;
66
67 llc_pdu_decode_dsap(skb, &dsap);
68 sap = llc_sap_find(dsap);
69 if (sap) {
70 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
71 struct llc_sock *llc = llc_sk(sk);
72 64
73 llc_pdu_decode_sa(skb, llc->daddr.mac); 65 ev->ind_prim = LLC_CONN_PRIM;
74 llc_pdu_decode_da(skb, llc->laddr.mac); 66 return 0;
75 llc->dev = skb->dev;
76 ev->ind_prim = LLC_CONN_PRIM;
77 rc = 0;
78 }
79 return rc;
80} 67}
81 68
82int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb) 69int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb)
@@ -120,10 +107,8 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct sk_buff *skb)
120 reason = LLC_DISC_REASON_RX_DISC_CMD_PDU; 107 reason = LLC_DISC_REASON_RX_DISC_CMD_PDU;
121 } else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR) 108 } else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR)
122 reason = LLC_DISC_REASON_ACK_TMR_EXP; 109 reason = LLC_DISC_REASON_ACK_TMR_EXP;
123 else { 110 else
124 reason = 0;
125 rc = -EINVAL; 111 rc = -EINVAL;
126 }
127 if (!rc) { 112 if (!rc) {
128 ev->reason = reason; 113 ev->reason = reason;
129 ev->ind_prim = LLC_DISC_PRIM; 114 ev->ind_prim = LLC_DISC_PRIM;
@@ -160,9 +145,6 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
160 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) { 145 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) {
161 reason = LLC_RESET_REASON_REMOTE; 146 reason = LLC_RESET_REASON_REMOTE;
162 rc = 0; 147 rc = 0;
163 } else {
164 reason = 0;
165 rc = 1;
166 } 148 }
167 break; 149 break;
168 case LLC_CONN_EV_TYPE_ACK_TMR: 150 case LLC_CONN_EV_TYPE_ACK_TMR:
@@ -172,8 +154,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
172 if (llc->retry_count > llc->n2) { 154 if (llc->retry_count > llc->n2) {
173 reason = LLC_RESET_REASON_LOCAL; 155 reason = LLC_RESET_REASON_LOCAL;
174 rc = 0; 156 rc = 0;
175 } else 157 }
176 rc = 1;
177 break; 158 break;
178 } 159 }
179 if (!rc) { 160 if (!rc) {
@@ -217,18 +198,17 @@ int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk,
217int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) 198int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
218{ 199{
219 int rc = -ENOBUFS; 200 int rc = -ENOBUFS;
220 struct sk_buff *nskb = llc_alloc_frame(); 201 struct llc_sock *llc = llc_sk(sk);
202 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
221 203
222 if (nskb) { 204 if (nskb) {
223 struct llc_sock *llc = llc_sk(sk);
224 struct llc_sap *sap = llc->sap; 205 struct llc_sap *sap = llc->sap;
225 206
226 nskb->dev = llc->dev;
227 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 207 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
228 llc->daddr.lsap, LLC_PDU_CMD); 208 llc->daddr.lsap, LLC_PDU_CMD);
229 llc_pdu_init_as_disc_cmd(nskb, 1); 209 llc_pdu_init_as_disc_cmd(nskb, 1);
230 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 210 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
231 if (rc) 211 if (unlikely(rc))
232 goto free; 212 goto free;
233 llc_conn_send_pdu(sk, nskb); 213 llc_conn_send_pdu(sk, nskb);
234 llc_conn_ac_set_p_flag_1(sk, skb); 214 llc_conn_ac_set_p_flag_1(sk, skb);
@@ -243,20 +223,19 @@ free:
243int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) 223int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
244{ 224{
245 int rc = -ENOBUFS; 225 int rc = -ENOBUFS;
246 struct sk_buff *nskb = llc_alloc_frame(); 226 struct llc_sock *llc = llc_sk(sk);
227 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
247 228
248 if (nskb) { 229 if (nskb) {
249 struct llc_sock *llc = llc_sk(sk);
250 struct llc_sap *sap = llc->sap; 230 struct llc_sap *sap = llc->sap;
251 u8 f_bit; 231 u8 f_bit;
252 232
253 nskb->dev = llc->dev;
254 llc_pdu_decode_pf_bit(skb, &f_bit); 233 llc_pdu_decode_pf_bit(skb, &f_bit);
255 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 234 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
256 llc->daddr.lsap, LLC_PDU_RSP); 235 llc->daddr.lsap, LLC_PDU_RSP);
257 llc_pdu_init_as_dm_rsp(nskb, f_bit); 236 llc_pdu_init_as_dm_rsp(nskb, f_bit);
258 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 237 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
259 if (rc) 238 if (unlikely(rc))
260 goto free; 239 goto free;
261 llc_conn_send_pdu(sk, nskb); 240 llc_conn_send_pdu(sk, nskb);
262 } 241 }
@@ -270,19 +249,17 @@ free:
270int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) 249int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
271{ 250{
272 int rc = -ENOBUFS; 251 int rc = -ENOBUFS;
273 struct sk_buff *nskb = llc_alloc_frame(); 252 struct llc_sock *llc = llc_sk(sk);
253 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
274 254
275 if (nskb) { 255 if (nskb) {
276 struct llc_sock *llc = llc_sk(sk);
277 struct llc_sap *sap = llc->sap; 256 struct llc_sap *sap = llc->sap;
278 u8 f_bit = 1;
279 257
280 nskb->dev = llc->dev;
281 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 258 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
282 llc->daddr.lsap, LLC_PDU_RSP); 259 llc->daddr.lsap, LLC_PDU_RSP);
283 llc_pdu_init_as_dm_rsp(nskb, f_bit); 260 llc_pdu_init_as_dm_rsp(nskb, 1);
284 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 261 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
285 if (rc) 262 if (unlikely(rc))
286 goto free; 263 goto free;
287 llc_conn_send_pdu(sk, nskb); 264 llc_conn_send_pdu(sk, nskb);
288 } 265 }
@@ -306,17 +283,16 @@ int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
306 llc_pdu_decode_pf_bit(skb, &f_bit); 283 llc_pdu_decode_pf_bit(skb, &f_bit);
307 else 284 else
308 f_bit = 0; 285 f_bit = 0;
309 nskb = llc_alloc_frame(); 286 nskb = llc_alloc_frame(sk, llc->dev);
310 if (nskb) { 287 if (nskb) {
311 struct llc_sap *sap = llc->sap; 288 struct llc_sap *sap = llc->sap;
312 289
313 nskb->dev = llc->dev;
314 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 290 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
315 llc->daddr.lsap, LLC_PDU_RSP); 291 llc->daddr.lsap, LLC_PDU_RSP);
316 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, 292 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
317 llc->vR, INCORRECT); 293 llc->vR, INCORRECT);
318 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 294 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
319 if (rc) 295 if (unlikely(rc))
320 goto free; 296 goto free;
321 llc_conn_send_pdu(sk, nskb); 297 llc_conn_send_pdu(sk, nskb);
322 } 298 }
@@ -330,21 +306,19 @@ free:
330int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb) 306int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
331{ 307{
332 int rc = -ENOBUFS; 308 int rc = -ENOBUFS;
333 struct sk_buff *nskb = llc_alloc_frame(); 309 struct llc_sock *llc = llc_sk(sk);
310 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
334 311
335 if (nskb) { 312 if (nskb) {
336 u8 f_bit = 0;
337 struct llc_sock *llc = llc_sk(sk);
338 struct llc_sap *sap = llc->sap; 313 struct llc_sap *sap = llc->sap;
339 struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr; 314 struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr;
340 315
341 nskb->dev = llc->dev;
342 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 316 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
343 llc->daddr.lsap, LLC_PDU_RSP); 317 llc->daddr.lsap, LLC_PDU_RSP);
344 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, 318 llc_pdu_init_as_frmr_rsp(nskb, pdu, 0, llc->vS,
345 llc->vR, INCORRECT); 319 llc->vR, INCORRECT);
346 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 320 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
347 if (rc) 321 if (unlikely(rc))
348 goto free; 322 goto free;
349 llc_conn_send_pdu(sk, nskb); 323 llc_conn_send_pdu(sk, nskb);
350 } 324 }
@@ -360,21 +334,20 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
360 u8 f_bit; 334 u8 f_bit;
361 int rc = -ENOBUFS; 335 int rc = -ENOBUFS;
362 struct sk_buff *nskb; 336 struct sk_buff *nskb;
337 struct llc_sock *llc = llc_sk(sk);
363 338
364 llc_pdu_decode_pf_bit(skb, &f_bit); 339 llc_pdu_decode_pf_bit(skb, &f_bit);
365 nskb = llc_alloc_frame(); 340 nskb = llc_alloc_frame(sk, llc->dev);
366 if (nskb) { 341 if (nskb) {
367 struct llc_sock *llc = llc_sk(sk);
368 struct llc_sap *sap = llc->sap; 342 struct llc_sap *sap = llc->sap;
369 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 343 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
370 344
371 nskb->dev = llc->dev;
372 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 345 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
373 llc->daddr.lsap, LLC_PDU_RSP); 346 llc->daddr.lsap, LLC_PDU_RSP);
374 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, 347 llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
375 llc->vR, INCORRECT); 348 llc->vR, INCORRECT);
376 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 349 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
377 if (rc) 350 if (unlikely(rc))
378 goto free; 351 goto free;
379 llc_conn_send_pdu(sk, nskb); 352 llc_conn_send_pdu(sk, nskb);
380 } 353 }
@@ -395,7 +368,7 @@ int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
395 llc->daddr.lsap, LLC_PDU_CMD); 368 llc->daddr.lsap, LLC_PDU_CMD);
396 llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR); 369 llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR);
397 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); 370 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
398 if (!rc) { 371 if (likely(!rc)) {
399 llc_conn_send_pdu(sk, skb); 372 llc_conn_send_pdu(sk, skb);
400 llc_conn_ac_inc_vs_by_1(sk, skb); 373 llc_conn_ac_inc_vs_by_1(sk, skb);
401 } 374 }
@@ -412,7 +385,7 @@ static int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk, struct sk_buff *skb)
412 llc->daddr.lsap, LLC_PDU_CMD); 385 llc->daddr.lsap, LLC_PDU_CMD);
413 llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR); 386 llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
414 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); 387 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
415 if (!rc) { 388 if (likely(!rc)) {
416 llc_conn_send_pdu(sk, skb); 389 llc_conn_send_pdu(sk, skb);
417 llc_conn_ac_inc_vs_by_1(sk, skb); 390 llc_conn_ac_inc_vs_by_1(sk, skb);
418 } 391 }
@@ -429,7 +402,7 @@ int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
429 llc->daddr.lsap, LLC_PDU_CMD); 402 llc->daddr.lsap, LLC_PDU_CMD);
430 llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR); 403 llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
431 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); 404 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
432 if (!rc) { 405 if (likely(!rc)) {
433 llc_conn_send_pdu(sk, skb); 406 llc_conn_send_pdu(sk, skb);
434 llc_conn_ac_inc_vs_by_1(sk, skb); 407 llc_conn_ac_inc_vs_by_1(sk, skb);
435 } 408 }
@@ -451,18 +424,17 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
451 u8 nr; 424 u8 nr;
452 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 425 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
453 int rc = -ENOBUFS; 426 int rc = -ENOBUFS;
454 struct sk_buff *nskb = llc_alloc_frame(); 427 struct llc_sock *llc = llc_sk(sk);
428 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
455 429
456 if (nskb) { 430 if (nskb) {
457 struct llc_sock *llc = llc_sk(sk);
458 struct llc_sap *sap = llc->sap; 431 struct llc_sap *sap = llc->sap;
459 432
460 nskb->dev = llc->dev;
461 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 433 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
462 llc->daddr.lsap, LLC_PDU_RSP); 434 llc->daddr.lsap, LLC_PDU_RSP);
463 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); 435 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
464 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 436 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
465 if (!rc) 437 if (likely(!rc))
466 llc_conn_send_pdu(sk, nskb); 438 llc_conn_send_pdu(sk, nskb);
467 else 439 else
468 kfree_skb(skb); 440 kfree_skb(skb);
@@ -487,18 +459,17 @@ int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
487int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) 459int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
488{ 460{
489 int rc = -ENOBUFS; 461 int rc = -ENOBUFS;
490 struct sk_buff *nskb = llc_alloc_frame(); 462 struct llc_sock *llc = llc_sk(sk);
463 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
491 464
492 if (nskb) { 465 if (nskb) {
493 struct llc_sock *llc = llc_sk(sk);
494 struct llc_sap *sap = llc->sap; 466 struct llc_sap *sap = llc->sap;
495 467
496 nskb->dev = llc->dev;
497 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 468 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
498 llc->daddr.lsap, LLC_PDU_CMD); 469 llc->daddr.lsap, LLC_PDU_CMD);
499 llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR); 470 llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR);
500 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 471 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
501 if (rc) 472 if (unlikely(rc))
502 goto free; 473 goto free;
503 llc_conn_send_pdu(sk, nskb); 474 llc_conn_send_pdu(sk, nskb);
504 } 475 }
@@ -512,19 +483,17 @@ free:
512int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) 483int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
513{ 484{
514 int rc = -ENOBUFS; 485 int rc = -ENOBUFS;
515 struct sk_buff *nskb = llc_alloc_frame(); 486 struct llc_sock *llc = llc_sk(sk);
487 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
516 488
517 if (nskb) { 489 if (nskb) {
518 u8 f_bit = 1;
519 struct llc_sock *llc = llc_sk(sk);
520 struct llc_sap *sap = llc->sap; 490 struct llc_sap *sap = llc->sap;
521 491
522 nskb->dev = llc->dev;
523 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 492 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
524 llc->daddr.lsap, LLC_PDU_RSP); 493 llc->daddr.lsap, LLC_PDU_RSP);
525 llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR); 494 llc_pdu_init_as_rej_rsp(nskb, 1, llc->vR);
526 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 495 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
527 if (rc) 496 if (unlikely(rc))
528 goto free; 497 goto free;
529 llc_conn_send_pdu(sk, nskb); 498 llc_conn_send_pdu(sk, nskb);
530 } 499 }
@@ -538,19 +507,17 @@ free:
538int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) 507int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
539{ 508{
540 int rc = -ENOBUFS; 509 int rc = -ENOBUFS;
541 struct sk_buff *nskb = llc_alloc_frame(); 510 struct llc_sock *llc = llc_sk(sk);
511 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
542 512
543 if (nskb) { 513 if (nskb) {
544 struct llc_sock *llc = llc_sk(sk);
545 struct llc_sap *sap = llc->sap; 514 struct llc_sap *sap = llc->sap;
546 u8 f_bit = 0;
547 515
548 nskb->dev = llc->dev;
549 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 516 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
550 llc->daddr.lsap, LLC_PDU_RSP); 517 llc->daddr.lsap, LLC_PDU_RSP);
551 llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR); 518 llc_pdu_init_as_rej_rsp(nskb, 0, llc->vR);
552 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 519 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
553 if (rc) 520 if (unlikely(rc))
554 goto free; 521 goto free;
555 llc_conn_send_pdu(sk, nskb); 522 llc_conn_send_pdu(sk, nskb);
556 } 523 }
@@ -564,18 +531,17 @@ free:
564int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) 531int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
565{ 532{
566 int rc = -ENOBUFS; 533 int rc = -ENOBUFS;
567 struct sk_buff *nskb = llc_alloc_frame(); 534 struct llc_sock *llc = llc_sk(sk);
535 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
568 536
569 if (nskb) { 537 if (nskb) {
570 struct llc_sock *llc = llc_sk(sk);
571 struct llc_sap *sap = llc->sap; 538 struct llc_sap *sap = llc->sap;
572 539
573 nskb->dev = llc->dev;
574 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 540 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
575 llc->daddr.lsap, LLC_PDU_CMD); 541 llc->daddr.lsap, LLC_PDU_CMD);
576 llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR); 542 llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR);
577 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 543 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
578 if (rc) 544 if (unlikely(rc))
579 goto free; 545 goto free;
580 llc_conn_send_pdu(sk, nskb); 546 llc_conn_send_pdu(sk, nskb);
581 } 547 }
@@ -589,19 +555,17 @@ free:
589int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) 555int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
590{ 556{
591 int rc = -ENOBUFS; 557 int rc = -ENOBUFS;
592 struct sk_buff *nskb = llc_alloc_frame(); 558 struct llc_sock *llc = llc_sk(sk);
559 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
593 560
594 if (nskb) { 561 if (nskb) {
595 struct llc_sock *llc = llc_sk(sk);
596 struct llc_sap *sap = llc->sap; 562 struct llc_sap *sap = llc->sap;
597 u8 f_bit = 1;
598 563
599 nskb->dev = llc->dev;
600 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 564 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
601 llc->daddr.lsap, LLC_PDU_RSP); 565 llc->daddr.lsap, LLC_PDU_RSP);
602 llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR); 566 llc_pdu_init_as_rnr_rsp(nskb, 1, llc->vR);
603 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 567 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
604 if (rc) 568 if (unlikely(rc))
605 goto free; 569 goto free;
606 llc_conn_send_pdu(sk, nskb); 570 llc_conn_send_pdu(sk, nskb);
607 } 571 }
@@ -615,19 +579,17 @@ free:
615int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) 579int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
616{ 580{
617 int rc = -ENOBUFS; 581 int rc = -ENOBUFS;
618 struct sk_buff *nskb = llc_alloc_frame(); 582 struct llc_sock *llc = llc_sk(sk);
583 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
619 584
620 if (nskb) { 585 if (nskb) {
621 u8 f_bit = 0;
622 struct llc_sock *llc = llc_sk(sk);
623 struct llc_sap *sap = llc->sap; 586 struct llc_sap *sap = llc->sap;
624 587
625 nskb->dev = llc->dev;
626 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 588 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
627 llc->daddr.lsap, LLC_PDU_RSP); 589 llc->daddr.lsap, LLC_PDU_RSP);
628 llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR); 590 llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
629 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 591 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
630 if (rc) 592 if (unlikely(rc))
631 goto free; 593 goto free;
632 llc_conn_send_pdu(sk, nskb); 594 llc_conn_send_pdu(sk, nskb);
633 } 595 }
@@ -645,7 +607,7 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
645 if (!llc->remote_busy_flag) { 607 if (!llc->remote_busy_flag) {
646 llc->remote_busy_flag = 1; 608 llc->remote_busy_flag = 1;
647 mod_timer(&llc->busy_state_timer.timer, 609 mod_timer(&llc->busy_state_timer.timer,
648 jiffies + llc->busy_state_timer.expire * HZ); 610 jiffies + llc->busy_state_timer.expire);
649 } 611 }
650 return 0; 612 return 0;
651} 613}
@@ -653,18 +615,17 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
653int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) 615int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
654{ 616{
655 int rc = -ENOBUFS; 617 int rc = -ENOBUFS;
656 struct sk_buff *nskb = llc_alloc_frame(); 618 struct llc_sock *llc = llc_sk(sk);
619 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
657 620
658 if (nskb) { 621 if (nskb) {
659 struct llc_sock *llc = llc_sk(sk);
660 struct llc_sap *sap = llc->sap; 622 struct llc_sap *sap = llc->sap;
661 623
662 nskb->dev = llc->dev;
663 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 624 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
664 llc->daddr.lsap, LLC_PDU_RSP); 625 llc->daddr.lsap, LLC_PDU_RSP);
665 llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR); 626 llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
666 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 627 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
667 if (rc) 628 if (unlikely(rc))
668 goto free; 629 goto free;
669 llc_conn_send_pdu(sk, nskb); 630 llc_conn_send_pdu(sk, nskb);
670 } 631 }
@@ -678,18 +639,17 @@ free:
678int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) 639int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
679{ 640{
680 int rc = -ENOBUFS; 641 int rc = -ENOBUFS;
681 struct sk_buff *nskb = llc_alloc_frame(); 642 struct llc_sock *llc = llc_sk(sk);
643 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
682 644
683 if (nskb) { 645 if (nskb) {
684 struct llc_sock *llc = llc_sk(sk);
685 struct llc_sap *sap = llc->sap; 646 struct llc_sap *sap = llc->sap;
686 647
687 nskb->dev = llc->dev;
688 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 648 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
689 llc->daddr.lsap, LLC_PDU_CMD); 649 llc->daddr.lsap, LLC_PDU_CMD);
690 llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR); 650 llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR);
691 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 651 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
692 if (rc) 652 if (unlikely(rc))
693 goto free; 653 goto free;
694 llc_conn_send_pdu(sk, nskb); 654 llc_conn_send_pdu(sk, nskb);
695 } 655 }
@@ -703,19 +663,18 @@ free:
703int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) 663int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
704{ 664{
705 int rc = -ENOBUFS; 665 int rc = -ENOBUFS;
706 struct sk_buff *nskb = llc_alloc_frame(); 666 struct llc_sock *llc = llc_sk(sk);
667 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
707 668
708 if (nskb) { 669 if (nskb) {
709 struct llc_sock *llc = llc_sk(sk);
710 struct llc_sap *sap = llc->sap; 670 struct llc_sap *sap = llc->sap;
711 u8 f_bit = 1; 671 u8 f_bit = 1;
712 672
713 nskb->dev = llc->dev;
714 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 673 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
715 llc->daddr.lsap, LLC_PDU_RSP); 674 llc->daddr.lsap, LLC_PDU_RSP);
716 llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); 675 llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
717 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 676 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
718 if (rc) 677 if (unlikely(rc))
719 goto free; 678 goto free;
720 llc_conn_send_pdu(sk, nskb); 679 llc_conn_send_pdu(sk, nskb);
721 } 680 }
@@ -729,19 +688,17 @@ free:
729int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) 688int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
730{ 689{
731 int rc = -ENOBUFS; 690 int rc = -ENOBUFS;
732 struct sk_buff *nskb = llc_alloc_frame(); 691 struct llc_sock *llc = llc_sk(sk);
692 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
733 693
734 if (nskb) { 694 if (nskb) {
735 struct llc_sock *llc = llc_sk(sk);
736 struct llc_sap *sap = llc->sap; 695 struct llc_sap *sap = llc->sap;
737 u8 f_bit = 1;
738 696
739 nskb->dev = llc->dev;
740 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 697 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
741 llc->daddr.lsap, LLC_PDU_RSP); 698 llc->daddr.lsap, LLC_PDU_RSP);
742 llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); 699 llc_pdu_init_as_rr_rsp(nskb, 1, llc->vR);
743 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 700 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
744 if (rc) 701 if (unlikely(rc))
745 goto free; 702 goto free;
746 llc_conn_send_pdu(sk, nskb); 703 llc_conn_send_pdu(sk, nskb);
747 } 704 }
@@ -755,18 +712,17 @@ free:
755int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) 712int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
756{ 713{
757 int rc = -ENOBUFS; 714 int rc = -ENOBUFS;
758 struct sk_buff *nskb = llc_alloc_frame(); 715 struct llc_sock *llc = llc_sk(sk);
716 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
759 717
760 if (nskb) { 718 if (nskb) {
761 struct llc_sock *llc = llc_sk(sk);
762 struct llc_sap *sap = llc->sap; 719 struct llc_sap *sap = llc->sap;
763 720
764 nskb->dev = llc->dev;
765 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 721 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
766 llc->daddr.lsap, LLC_PDU_RSP); 722 llc->daddr.lsap, LLC_PDU_RSP);
767 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); 723 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
768 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 724 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
769 if (rc) 725 if (unlikely(rc))
770 goto free; 726 goto free;
771 llc_conn_send_pdu(sk, nskb); 727 llc_conn_send_pdu(sk, nskb);
772 } 728 }
@@ -780,18 +736,17 @@ free:
780int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) 736int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
781{ 737{
782 int rc = -ENOBUFS; 738 int rc = -ENOBUFS;
783 struct sk_buff *nskb = llc_alloc_frame(); 739 struct llc_sock *llc = llc_sk(sk);
740 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
784 741
785 if (nskb) { 742 if (nskb) {
786 struct llc_sock *llc = llc_sk(sk);
787 struct llc_sap *sap = llc->sap; 743 struct llc_sap *sap = llc->sap;
788 744
789 nskb->dev = llc->dev;
790 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 745 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
791 llc->daddr.lsap, LLC_PDU_RSP); 746 llc->daddr.lsap, LLC_PDU_RSP);
792 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); 747 llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
793 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 748 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
794 if (rc) 749 if (unlikely(rc))
795 goto free; 750 goto free;
796 llc_conn_send_pdu(sk, nskb); 751 llc_conn_send_pdu(sk, nskb);
797 } 752 }
@@ -815,8 +770,8 @@ void llc_conn_set_p_flag(struct sock *sk, u8 value)
815int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) 770int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
816{ 771{
817 int rc = -ENOBUFS; 772 int rc = -ENOBUFS;
818 struct sk_buff *nskb = llc_alloc_frame();
819 struct llc_sock *llc = llc_sk(sk); 773 struct llc_sock *llc = llc_sk(sk);
774 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
820 775
821 if (nskb) { 776 if (nskb) {
822 struct llc_sap *sap = llc->sap; 777 struct llc_sap *sap = llc->sap;
@@ -824,12 +779,11 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
824 779
825 if (llc->dev->flags & IFF_LOOPBACK) 780 if (llc->dev->flags & IFF_LOOPBACK)
826 dmac = llc->dev->dev_addr; 781 dmac = llc->dev->dev_addr;
827 nskb->dev = llc->dev;
828 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, 782 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
829 llc->daddr.lsap, LLC_PDU_CMD); 783 llc->daddr.lsap, LLC_PDU_CMD);
830 llc_pdu_init_as_sabme_cmd(nskb, 1); 784 llc_pdu_init_as_sabme_cmd(nskb, 1);
831 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac); 785 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac);
832 if (rc) 786 if (unlikely(rc))
833 goto free; 787 goto free;
834 llc_conn_send_pdu(sk, nskb); 788 llc_conn_send_pdu(sk, nskb);
835 llc_conn_set_p_flag(sk, 1); 789 llc_conn_set_p_flag(sk, 1);
@@ -845,11 +799,11 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
845{ 799{
846 u8 f_bit; 800 u8 f_bit;
847 int rc = -ENOBUFS; 801 int rc = -ENOBUFS;
848 struct sk_buff *nskb = llc_alloc_frame(); 802 struct llc_sock *llc = llc_sk(sk);
803 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
849 804
850 llc_pdu_decode_pf_bit(skb, &f_bit); 805 llc_pdu_decode_pf_bit(skb, &f_bit);
851 if (nskb) { 806 if (nskb) {
852 struct llc_sock *llc = llc_sk(sk);
853 struct llc_sap *sap = llc->sap; 807 struct llc_sap *sap = llc->sap;
854 808
855 nskb->dev = llc->dev; 809 nskb->dev = llc->dev;
@@ -857,7 +811,7 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
857 llc->daddr.lsap, LLC_PDU_RSP); 811 llc->daddr.lsap, LLC_PDU_RSP);
858 llc_pdu_init_as_ua_rsp(nskb, f_bit); 812 llc_pdu_init_as_ua_rsp(nskb, f_bit);
859 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 813 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
860 if (rc) 814 if (unlikely(rc))
861 goto free; 815 goto free;
862 llc_conn_send_pdu(sk, nskb); 816 llc_conn_send_pdu(sk, nskb);
863 } 817 }
@@ -886,7 +840,7 @@ int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
886 840
887 llc_conn_set_p_flag(sk, 1); 841 llc_conn_set_p_flag(sk, 1);
888 mod_timer(&llc->pf_cycle_timer.timer, 842 mod_timer(&llc->pf_cycle_timer.timer,
889 jiffies + llc->pf_cycle_timer.expire * HZ); 843 jiffies + llc->pf_cycle_timer.expire);
890 return 0; 844 return 0;
891} 845}
892 846
@@ -957,7 +911,7 @@ static int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk,
957 llc->daddr.lsap, LLC_PDU_RSP); 911 llc->daddr.lsap, LLC_PDU_RSP);
958 llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR); 912 llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR);
959 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); 913 rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
960 if (!rc) { 914 if (likely(!rc)) {
961 llc_conn_send_pdu(sk, skb); 915 llc_conn_send_pdu(sk, skb);
962 llc_conn_ac_inc_vs_by_1(sk, skb); 916 llc_conn_ac_inc_vs_by_1(sk, skb);
963 } 917 }
@@ -1001,18 +955,17 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
1001 struct sk_buff *skb) 955 struct sk_buff *skb)
1002{ 956{
1003 int rc = -ENOBUFS; 957 int rc = -ENOBUFS;
1004 struct sk_buff *nskb = llc_alloc_frame(); 958 struct llc_sock *llc = llc_sk(sk);
959 struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev);
1005 960
1006 if (nskb) { 961 if (nskb) {
1007 struct llc_sock *llc = llc_sk(sk);
1008 struct llc_sap *sap = llc->sap; 962 struct llc_sap *sap = llc->sap;
1009 963
1010 nskb->dev = llc->dev;
1011 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, 964 llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
1012 llc->daddr.lsap, LLC_PDU_RSP); 965 llc->daddr.lsap, LLC_PDU_RSP);
1013 llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR); 966 llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR);
1014 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); 967 rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
1015 if (rc) 968 if (unlikely(rc))
1016 goto free; 969 goto free;
1017 llc_conn_send_pdu(sk, nskb); 970 llc_conn_send_pdu(sk, nskb);
1018 } 971 }
@@ -1165,7 +1118,7 @@ int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
1165{ 1118{
1166 struct llc_sock *llc = llc_sk(sk); 1119 struct llc_sock *llc = llc_sk(sk);
1167 1120
1168 mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire * HZ); 1121 mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire);
1169 return 0; 1122 return 0;
1170} 1123}
1171 1124
@@ -1174,7 +1127,7 @@ int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
1174 struct llc_sock *llc = llc_sk(sk); 1127 struct llc_sock *llc = llc_sk(sk);
1175 1128
1176 mod_timer(&llc->rej_sent_timer.timer, 1129 mod_timer(&llc->rej_sent_timer.timer,
1177 jiffies + llc->rej_sent_timer.expire * HZ); 1130 jiffies + llc->rej_sent_timer.expire);
1178 return 0; 1131 return 0;
1179} 1132}
1180 1133
@@ -1185,7 +1138,7 @@ int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
1185 1138
1186 if (!timer_pending(&llc->ack_timer.timer)) 1139 if (!timer_pending(&llc->ack_timer.timer))
1187 mod_timer(&llc->ack_timer.timer, 1140 mod_timer(&llc->ack_timer.timer,
1188 jiffies + llc->ack_timer.expire * HZ); 1141 jiffies + llc->ack_timer.expire);
1189 return 0; 1142 return 0;
1190} 1143}
1191 1144
@@ -1233,7 +1186,7 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
1233 } 1186 }
1234 if (unacked) 1187 if (unacked)
1235 mod_timer(&llc->ack_timer.timer, 1188 mod_timer(&llc->ack_timer.timer,
1236 jiffies + llc->ack_timer.expire * HZ); 1189 jiffies + llc->ack_timer.expire);
1237 } else if (llc->failed_data_req) { 1190 } else if (llc->failed_data_req) {
1238 u8 f_bit; 1191 u8 f_bit;
1239 1192
@@ -1354,13 +1307,13 @@ int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb)
1354 return 0; 1307 return 0;
1355} 1308}
1356 1309
1357int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb) 1310static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
1358{ 1311{
1359 llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128; 1312 llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128;
1360 return 0; 1313 return 0;
1361} 1314}
1362 1315
1363void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data) 1316static void llc_conn_tmr_common_cb(unsigned long timeout_data, u8 type)
1364{ 1317{
1365 struct sock *sk = (struct sock *)timeout_data; 1318 struct sock *sk = (struct sock *)timeout_data;
1366 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); 1319 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
@@ -1369,59 +1322,31 @@ void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
1369 if (skb) { 1322 if (skb) {
1370 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 1323 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
1371 1324
1372 skb->sk = sk; 1325 skb_set_owner_r(skb, sk);
1373 ev->type = LLC_CONN_EV_TYPE_P_TMR; 1326 ev->type = type;
1374 llc_process_tmr_ev(sk, skb); 1327 llc_process_tmr_ev(sk, skb);
1375 } 1328 }
1376 bh_unlock_sock(sk); 1329 bh_unlock_sock(sk);
1377} 1330}
1378 1331
1379void llc_conn_busy_tmr_cb(unsigned long timeout_data) 1332void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
1380{ 1333{
1381 struct sock *sk = (struct sock *)timeout_data; 1334 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_P_TMR);
1382 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); 1335}
1383
1384 bh_lock_sock(sk);
1385 if (skb) {
1386 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
1387 1336
1388 skb->sk = sk; 1337void llc_conn_busy_tmr_cb(unsigned long timeout_data)
1389 ev->type = LLC_CONN_EV_TYPE_BUSY_TMR; 1338{
1390 llc_process_tmr_ev(sk, skb); 1339 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_BUSY_TMR);
1391 }
1392 bh_unlock_sock(sk);
1393} 1340}
1394 1341
1395void llc_conn_ack_tmr_cb(unsigned long timeout_data) 1342void llc_conn_ack_tmr_cb(unsigned long timeout_data)
1396{ 1343{
1397 struct sock* sk = (struct sock *)timeout_data; 1344 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_ACK_TMR);
1398 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
1399
1400 bh_lock_sock(sk);
1401 if (skb) {
1402 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
1403
1404 skb->sk = sk;
1405 ev->type = LLC_CONN_EV_TYPE_ACK_TMR;
1406 llc_process_tmr_ev(sk, skb);
1407 }
1408 bh_unlock_sock(sk);
1409} 1345}
1410 1346
1411void llc_conn_rej_tmr_cb(unsigned long timeout_data) 1347void llc_conn_rej_tmr_cb(unsigned long timeout_data)
1412{ 1348{
1413 struct sock *sk = (struct sock *)timeout_data; 1349 llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_REJ_TMR);
1414 struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
1415
1416 bh_lock_sock(sk);
1417 if (skb) {
1418 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
1419
1420 skb->sk = sk;
1421 ev->type = LLC_CONN_EV_TYPE_REJ_TMR;
1422 llc_process_tmr_ev(sk, skb);
1423 }
1424 bh_unlock_sock(sk);
1425} 1350}
1426 1351
1427int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb) 1352int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb)
diff --git a/net/llc/llc_c_ev.c b/net/llc/llc_c_ev.c
index d5bdb53a348f..c5deda246614 100644
--- a/net/llc/llc_c_ev.c
+++ b/net/llc/llc_c_ev.c
@@ -37,6 +37,7 @@
37#include <net/llc_conn.h> 37#include <net/llc_conn.h>
38#include <net/llc_sap.h> 38#include <net/llc_sap.h>
39#include <net/sock.h> 39#include <net/sock.h>
40#include <net/llc_c_ac.h>
40#include <net/llc_c_ev.h> 41#include <net/llc_c_ev.h>
41#include <net/llc_pdu.h> 42#include <net/llc_pdu.h>
42 43
@@ -46,8 +47,6 @@
46#define dprintk(args...) 47#define dprintk(args...)
47#endif 48#endif
48 49
49extern u16 llc_circular_between(u8 a, u8 b, u8 c);
50
51/** 50/**
52 * llc_util_ns_inside_rx_window - check if sequence number is in rx window 51 * llc_util_ns_inside_rx_window - check if sequence number is in rx window
53 * @ns: sequence number of received pdu. 52 * @ns: sequence number of received pdu.
@@ -99,7 +98,7 @@ out:
99 98
100int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb) 99int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb)
101{ 100{
102 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 101 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
103 102
104 return ev->prim == LLC_CONN_PRIM && 103 return ev->prim == LLC_CONN_PRIM &&
105 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 104 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
@@ -107,7 +106,7 @@ int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb)
107 106
108int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb) 107int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb)
109{ 108{
110 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 109 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
111 110
112 return ev->prim == LLC_DATA_PRIM && 111 return ev->prim == LLC_DATA_PRIM &&
113 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 112 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
@@ -115,7 +114,7 @@ int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb)
115 114
116int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb) 115int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb)
117{ 116{
118 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 117 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
119 118
120 return ev->prim == LLC_DISC_PRIM && 119 return ev->prim == LLC_DISC_PRIM &&
121 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 120 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
@@ -123,7 +122,7 @@ int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb)
123 122
124int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb) 123int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb)
125{ 124{
126 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 125 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
127 126
128 return ev->prim == LLC_RESET_PRIM && 127 return ev->prim == LLC_RESET_PRIM &&
129 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; 128 ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1;
@@ -131,7 +130,7 @@ int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb)
131 130
132int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb) 131int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb)
133{ 132{
134 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 133 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
135 134
136 return ev->type == LLC_CONN_EV_TYPE_SIMPLE && 135 return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
137 ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1; 136 ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1;
@@ -139,7 +138,7 @@ int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb)
139 138
140int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb) 139int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb)
141{ 140{
142 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 141 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
143 142
144 return ev->type == LLC_CONN_EV_TYPE_SIMPLE && 143 return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
145 ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1; 144 ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1;
@@ -152,7 +151,7 @@ int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb)
152 151
153int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) 152int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
154{ 153{
155 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 154 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
156 155
157 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 156 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
158 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1; 157 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1;
@@ -160,7 +159,7 @@ int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
160 159
161int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 160int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
162{ 161{
163 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 162 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
164 163
165 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 164 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
166 LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1; 165 LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1;
@@ -168,7 +167,7 @@ int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
168 167
169int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 168int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
170{ 169{
171 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 170 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
172 171
173 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 172 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
174 LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1; 173 LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1;
@@ -176,7 +175,7 @@ int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
176 175
177int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 176int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
178{ 177{
179 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 178 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
180 179
181 return llc_conn_space(sk, skb) && 180 return llc_conn_space(sk, skb) &&
182 LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 181 LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
@@ -186,7 +185,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
186 185
187int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 186int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
188{ 187{
189 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 188 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
190 189
191 return llc_conn_space(sk, skb) && 190 return llc_conn_space(sk, skb) &&
192 LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 191 LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
@@ -197,9 +196,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
197int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk, 196int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
198 struct sk_buff *skb) 197 struct sk_buff *skb)
199{ 198{
200 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 199 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
201 u8 vr = llc_sk(sk)->vR; 200 const u8 vr = llc_sk(sk)->vR;
202 u8 ns = LLC_I_GET_NS(pdu); 201 const u8 ns = LLC_I_GET_NS(pdu);
203 202
204 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 203 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
205 LLC_I_PF_IS_0(pdu) && ns != vr && 204 LLC_I_PF_IS_0(pdu) && ns != vr &&
@@ -209,9 +208,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
209int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk, 208int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
210 struct sk_buff *skb) 209 struct sk_buff *skb)
211{ 210{
212 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 211 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
213 u8 vr = llc_sk(sk)->vR; 212 const u8 vr = llc_sk(sk)->vR;
214 u8 ns = LLC_I_GET_NS(pdu); 213 const u8 ns = LLC_I_GET_NS(pdu);
215 214
216 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 215 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
217 LLC_I_PF_IS_1(pdu) && ns != vr && 216 LLC_I_PF_IS_1(pdu) && ns != vr &&
@@ -221,10 +220,11 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
221int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk, 220int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
222 struct sk_buff *skb) 221 struct sk_buff *skb)
223{ 222{
224 struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb); 223 const struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb);
225 u8 vr = llc_sk(sk)->vR; 224 const u8 vr = llc_sk(sk)->vR;
226 u8 ns = LLC_I_GET_NS(pdu); 225 const u8 ns = LLC_I_GET_NS(pdu);
227 u16 rc = LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && 226 const u16 rc = LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
227 ns != vr &&
228 llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 228 llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
229 if (!rc) 229 if (!rc)
230 dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", 230 dprintk("%s: matched, state=%d, ns=%d, vr=%d\n",
@@ -234,7 +234,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
234 234
235int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 235int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
236{ 236{
237 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 237 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
238 238
239 return llc_conn_space(sk, skb) && 239 return llc_conn_space(sk, skb) &&
240 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 240 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
@@ -244,7 +244,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
244 244
245int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 245int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
246{ 246{
247 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 247 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
248 248
249 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 249 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
250 LLC_I_PF_IS_1(pdu) && 250 LLC_I_PF_IS_1(pdu) &&
@@ -253,7 +253,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
253 253
254int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 254int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
255{ 255{
256 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 256 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
257 257
258 return llc_conn_space(sk, skb) && 258 return llc_conn_space(sk, skb) &&
259 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 259 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
@@ -263,9 +263,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
263int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk, 263int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
264 struct sk_buff *skb) 264 struct sk_buff *skb)
265{ 265{
266 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 266 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
267 u8 vr = llc_sk(sk)->vR; 267 const u8 vr = llc_sk(sk)->vR;
268 u8 ns = LLC_I_GET_NS(pdu); 268 const u8 ns = LLC_I_GET_NS(pdu);
269 269
270 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 270 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
271 LLC_I_PF_IS_0(pdu) && ns != vr && 271 LLC_I_PF_IS_0(pdu) && ns != vr &&
@@ -275,9 +275,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
275int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk, 275int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
276 struct sk_buff *skb) 276 struct sk_buff *skb)
277{ 277{
278 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 278 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
279 u8 vr = llc_sk(sk)->vR; 279 const u8 vr = llc_sk(sk)->vR;
280 u8 ns = LLC_I_GET_NS(pdu); 280 const u8 ns = LLC_I_GET_NS(pdu);
281 281
282 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && 282 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
283 LLC_I_PF_IS_1(pdu) && ns != vr && 283 LLC_I_PF_IS_1(pdu) && ns != vr &&
@@ -287,9 +287,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
287int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk, 287int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
288 struct sk_buff *skb) 288 struct sk_buff *skb)
289{ 289{
290 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 290 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
291 u8 vr = llc_sk(sk)->vR; 291 const u8 vr = llc_sk(sk)->vR;
292 u8 ns = LLC_I_GET_NS(pdu); 292 const u8 ns = LLC_I_GET_NS(pdu);
293 293
294 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && 294 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr &&
295 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 295 !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
@@ -298,10 +298,11 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
298int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk, 298int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
299 struct sk_buff *skb) 299 struct sk_buff *skb)
300{ 300{
301 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 301 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
302 u8 vr = llc_sk(sk)->vR; 302 const u8 vr = llc_sk(sk)->vR;
303 u8 ns = LLC_I_GET_NS(pdu); 303 const u8 ns = LLC_I_GET_NS(pdu);
304 u16 rc = LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && 304 const u16 rc = LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) &&
305 ns != vr &&
305 llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; 306 llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1;
306 if (!rc) 307 if (!rc)
307 dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", 308 dprintk("%s: matched, state=%d, ns=%d, vr=%d\n",
@@ -311,7 +312,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
311 312
312int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 313int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
313{ 314{
314 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 315 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
315 316
316 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 317 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
317 LLC_S_PF_IS_0(pdu) && 318 LLC_S_PF_IS_0(pdu) &&
@@ -320,7 +321,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
320 321
321int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 322int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
322{ 323{
323 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 324 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
324 325
325 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 326 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
326 LLC_S_PF_IS_1(pdu) && 327 LLC_S_PF_IS_1(pdu) &&
@@ -329,7 +330,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
329 330
330int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 331int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
331{ 332{
332 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 333 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
333 334
334 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 335 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
335 LLC_S_PF_IS_0(pdu) && 336 LLC_S_PF_IS_0(pdu) &&
@@ -338,7 +339,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
338 339
339int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 340int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
340{ 341{
341 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 342 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
342 343
343 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 344 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
344 LLC_S_PF_IS_1(pdu) && 345 LLC_S_PF_IS_1(pdu) &&
@@ -347,7 +348,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
347 348
348int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 349int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
349{ 350{
350 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 351 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
351 352
352 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 353 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
353 LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1; 354 LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1;
@@ -355,7 +356,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
355 356
356int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 357int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
357{ 358{
358 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 359 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
359 360
360 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 361 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
361 LLC_S_PF_IS_0(pdu) && 362 LLC_S_PF_IS_0(pdu) &&
@@ -364,7 +365,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
364 365
365int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 366int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
366{ 367{
367 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 368 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
368 369
369 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 370 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
370 LLC_S_PF_IS_1(pdu) && 371 LLC_S_PF_IS_1(pdu) &&
@@ -373,7 +374,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
373 374
374int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 375int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
375{ 376{
376 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 377 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
377 378
378 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 379 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
379 LLC_S_PF_IS_0(pdu) && 380 LLC_S_PF_IS_0(pdu) &&
@@ -382,7 +383,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
382 383
383int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 384int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
384{ 385{
385 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 386 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
386 387
387 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 388 return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
388 LLC_S_PF_IS_1(pdu) && 389 LLC_S_PF_IS_1(pdu) &&
@@ -391,7 +392,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
391 392
392int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) 393int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
393{ 394{
394 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 395 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
395 396
396 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 397 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
397 LLC_S_PF_IS_0(pdu) && 398 LLC_S_PF_IS_0(pdu) &&
@@ -400,7 +401,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb)
400 401
401int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 402int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
402{ 403{
403 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 404 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
404 405
405 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 406 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
406 LLC_S_PF_IS_1(pdu) && 407 LLC_S_PF_IS_1(pdu) &&
@@ -409,7 +410,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
409 410
410int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) 411int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
411{ 412{
412 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 413 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
413 414
414 return llc_conn_space(sk, skb) && 415 return llc_conn_space(sk, skb) &&
415 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 416 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
@@ -419,7 +420,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb)
419 420
420int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) 421int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
421{ 422{
422 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 423 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
423 424
424 return llc_conn_space(sk, skb) && 425 return llc_conn_space(sk, skb) &&
425 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && 426 LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) &&
@@ -429,7 +430,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
429 430
430int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) 431int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
431{ 432{
432 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 433 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
433 434
434 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && 435 return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) &&
435 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1; 436 LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1;
@@ -446,7 +447,7 @@ int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
446int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) 447int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
447{ 448{
448 u16 rc = 1; 449 u16 rc = 1;
449 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 450 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
450 451
451 if (LLC_PDU_IS_CMD(pdu)) { 452 if (LLC_PDU_IS_CMD(pdu)) {
452 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) { 453 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) {
@@ -461,7 +462,7 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb)
461int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) 462int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
462{ 463{
463 u16 rc = 1; 464 u16 rc = 1;
464 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 465 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
465 466
466 if (LLC_PDU_IS_CMD(pdu)) { 467 if (LLC_PDU_IS_CMD(pdu)) {
467 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) 468 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu))
@@ -477,32 +478,10 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb)
477 return rc; 478 return rc;
478} 479}
479 480
480int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb)
481{
482 u16 rc = 1;
483 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
484
485 if (LLC_PDU_IS_RSP(pdu)) {
486 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) {
487 if (LLC_I_PF_IS_1(pdu))
488 rc = 0;
489 } else if (LLC_PDU_TYPE_IS_U(pdu))
490 switch (LLC_U_PDU_RSP(pdu)) {
491 case LLC_2_PDU_RSP_UA:
492 case LLC_2_PDU_RSP_DM:
493 case LLC_2_PDU_RSP_FRMR:
494 if (LLC_U_PF_IS_1(pdu))
495 rc = 0;
496 break;
497 }
498 }
499 return rc;
500}
501
502int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) 481int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb)
503{ 482{
504 u16 rc = 1; 483 u16 rc = 1;
505 struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); 484 const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb);
506 485
507 if (LLC_PDU_IS_RSP(pdu)) { 486 if (LLC_PDU_IS_RSP(pdu)) {
508 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) 487 if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu))
@@ -524,9 +503,9 @@ int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
524 struct sk_buff *skb) 503 struct sk_buff *skb)
525{ 504{
526 u16 rc = 1; 505 u16 rc = 1;
527 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 506 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
528 u8 vs = llc_sk(sk)->vS; 507 const u8 vs = llc_sk(sk)->vS;
529 u8 nr = LLC_I_GET_NR(pdu); 508 const u8 nr = LLC_I_GET_NR(pdu);
530 509
531 if (LLC_PDU_IS_CMD(pdu) && 510 if (LLC_PDU_IS_CMD(pdu) &&
532 (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && 511 (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) &&
@@ -542,9 +521,9 @@ int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
542 struct sk_buff *skb) 521 struct sk_buff *skb)
543{ 522{
544 u16 rc = 1; 523 u16 rc = 1;
545 struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); 524 const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
546 u8 vs = llc_sk(sk)->vS; 525 const u8 vs = llc_sk(sk)->vS;
547 u8 nr = LLC_I_GET_NR(pdu); 526 const u8 nr = LLC_I_GET_NR(pdu);
548 527
549 if (LLC_PDU_IS_RSP(pdu) && 528 if (LLC_PDU_IS_RSP(pdu) &&
550 (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && 529 (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) &&
@@ -563,28 +542,28 @@ int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb)
563 542
564int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb) 543int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb)
565{ 544{
566 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 545 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
567 546
568 return ev->type != LLC_CONN_EV_TYPE_P_TMR; 547 return ev->type != LLC_CONN_EV_TYPE_P_TMR;
569} 548}
570 549
571int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb) 550int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb)
572{ 551{
573 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 552 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
574 553
575 return ev->type != LLC_CONN_EV_TYPE_ACK_TMR; 554 return ev->type != LLC_CONN_EV_TYPE_ACK_TMR;
576} 555}
577 556
578int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb) 557int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb)
579{ 558{
580 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 559 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
581 560
582 return ev->type != LLC_CONN_EV_TYPE_REJ_TMR; 561 return ev->type != LLC_CONN_EV_TYPE_REJ_TMR;
583} 562}
584 563
585int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb) 564int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb)
586{ 565{
587 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 566 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
588 567
589 return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR; 568 return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR;
590} 569}
@@ -596,7 +575,7 @@ int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb)
596 575
597int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb) 576int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb)
598{ 577{
599 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 578 const struct llc_conn_state_ev *ev = llc_conn_ev(skb);
600 579
601 return ev->type == LLC_CONN_EV_TYPE_SIMPLE && 580 return ev->type == LLC_CONN_EV_TYPE_SIMPLE &&
602 ev->prim_type == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1; 581 ev->prim_type == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1;
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c
index 4c644bc70eae..c761c15da421 100644
--- a/net/llc/llc_conn.c
+++ b/net/llc/llc_conn.c
@@ -40,6 +40,11 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
40/* Offset table on connection states transition diagram */ 40/* Offset table on connection states transition diagram */
41static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; 41static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
42 42
43int sysctl_llc2_ack_timeout = LLC2_ACK_TIME * HZ;
44int sysctl_llc2_p_timeout = LLC2_P_TIME * HZ;
45int sysctl_llc2_rej_timeout = LLC2_REJ_TIME * HZ;
46int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ;
47
43/** 48/**
44 * llc_conn_state_process - sends event to connection state machine 49 * llc_conn_state_process - sends event to connection state machine
45 * @sk: connection 50 * @sk: connection
@@ -53,7 +58,7 @@ static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
53int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) 58int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
54{ 59{
55 int rc; 60 int rc;
56 struct llc_sock *llc = llc_sk(sk); 61 struct llc_sock *llc = llc_sk(skb->sk);
57 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 62 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
58 63
59 /* 64 /*
@@ -63,13 +68,16 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
63 */ 68 */
64 skb_get(skb); 69 skb_get(skb);
65 ev->ind_prim = ev->cfm_prim = 0; 70 ev->ind_prim = ev->cfm_prim = 0;
66 rc = llc_conn_service(sk, skb); /* sending event to state machine */ 71 /*
67 if (rc) { 72 * Send event to state machine
73 */
74 rc = llc_conn_service(skb->sk, skb);
75 if (unlikely(rc != 0)) {
68 printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__); 76 printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__);
69 goto out_kfree_skb; 77 goto out_kfree_skb;
70 } 78 }
71 79
72 if (!ev->ind_prim && !ev->cfm_prim) { 80 if (unlikely(!ev->ind_prim && !ev->cfm_prim)) {
73 /* indicate or confirm not required */ 81 /* indicate or confirm not required */
74 /* XXX this is not very pretty, perhaps we should store 82 /* XXX this is not very pretty, perhaps we should store
75 * XXX indicate/confirm-needed state in the llc_conn_state_ev 83 * XXX indicate/confirm-needed state in the llc_conn_state_ev
@@ -80,13 +88,13 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
80 goto out_skb_put; 88 goto out_skb_put;
81 } 89 }
82 90
83 if (ev->ind_prim && ev->cfm_prim) /* Paranoia */ 91 if (unlikely(ev->ind_prim && ev->cfm_prim)) /* Paranoia */
84 skb_get(skb); 92 skb_get(skb);
85 93
86 switch (ev->ind_prim) { 94 switch (ev->ind_prim) {
87 case LLC_DATA_PRIM: 95 case LLC_DATA_PRIM:
88 llc_save_primitive(skb, LLC_DATA_PRIM); 96 llc_save_primitive(sk, skb, LLC_DATA_PRIM);
89 if (sock_queue_rcv_skb(sk, skb)) { 97 if (unlikely(sock_queue_rcv_skb(sk, skb))) {
90 /* 98 /*
91 * shouldn't happen 99 * shouldn't happen
92 */ 100 */
@@ -95,13 +103,14 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
95 kfree_skb(skb); 103 kfree_skb(skb);
96 } 104 }
97 break; 105 break;
98 case LLC_CONN_PRIM: { 106 case LLC_CONN_PRIM:
99 struct sock *parent = skb->sk; 107 /*
100 108 * Can't be sock_queue_rcv_skb, because we have to leave the
101 skb->sk = sk; 109 * skb->sk pointing to the newly created struct sock in
102 skb_queue_tail(&parent->sk_receive_queue, skb); 110 * llc_conn_handler. -acme
103 sk->sk_state_change(parent); 111 */
104 } 112 skb_queue_tail(&sk->sk_receive_queue, skb);
113 sk->sk_state_change(sk);
105 break; 114 break;
106 case LLC_DISC_PRIM: 115 case LLC_DISC_PRIM:
107 sock_hold(sk); 116 sock_hold(sk);
@@ -111,8 +120,8 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
111 sk->sk_socket->state = SS_UNCONNECTED; 120 sk->sk_socket->state = SS_UNCONNECTED;
112 sk->sk_state = TCP_CLOSE; 121 sk->sk_state = TCP_CLOSE;
113 if (!sock_flag(sk, SOCK_DEAD)) { 122 if (!sock_flag(sk, SOCK_DEAD)) {
114 sk->sk_state_change(sk);
115 sock_set_flag(sk, SOCK_DEAD); 123 sock_set_flag(sk, SOCK_DEAD);
124 sk->sk_state_change(sk);
116 } 125 }
117 } 126 }
118 kfree_skb(skb); 127 kfree_skb(skb);
@@ -465,7 +474,7 @@ static int llc_exec_conn_trans_actions(struct sock *sk,
465} 474}
466 475
467/** 476/**
468 * llc_lookup_established - Finds connection for the remote/local sap/mac 477 * __llc_lookup_established - Finds connection for the remote/local sap/mac
469 * @sap: SAP 478 * @sap: SAP
470 * @daddr: address of remote LLC (MAC + SAP) 479 * @daddr: address of remote LLC (MAC + SAP)
471 * @laddr: address of local LLC (MAC + SAP) 480 * @laddr: address of local LLC (MAC + SAP)
@@ -473,14 +482,16 @@ static int llc_exec_conn_trans_actions(struct sock *sk,
473 * Search connection list of the SAP and finds connection using the remote 482 * Search connection list of the SAP and finds connection using the remote
474 * mac, remote sap, local mac, and local sap. Returns pointer for 483 * mac, remote sap, local mac, and local sap. Returns pointer for
475 * connection found, %NULL otherwise. 484 * connection found, %NULL otherwise.
485 * Caller has to make sure local_bh is disabled.
476 */ 486 */
477struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr, 487static struct sock *__llc_lookup_established(struct llc_sap *sap,
478 struct llc_addr *laddr) 488 struct llc_addr *daddr,
489 struct llc_addr *laddr)
479{ 490{
480 struct sock *rc; 491 struct sock *rc;
481 struct hlist_node *node; 492 struct hlist_node *node;
482 493
483 read_lock_bh(&sap->sk_list.lock); 494 read_lock(&sap->sk_list.lock);
484 sk_for_each(rc, node, &sap->sk_list.list) { 495 sk_for_each(rc, node, &sap->sk_list.list) {
485 struct llc_sock *llc = llc_sk(rc); 496 struct llc_sock *llc = llc_sk(rc);
486 497
@@ -494,10 +505,22 @@ struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
494 } 505 }
495 rc = NULL; 506 rc = NULL;
496found: 507found:
497 read_unlock_bh(&sap->sk_list.lock); 508 read_unlock(&sap->sk_list.lock);
498 return rc; 509 return rc;
499} 510}
500 511
512struct sock *llc_lookup_established(struct llc_sap *sap,
513 struct llc_addr *daddr,
514 struct llc_addr *laddr)
515{
516 struct sock *sk;
517
518 local_bh_disable();
519 sk = __llc_lookup_established(sap, daddr, laddr);
520 local_bh_enable();
521 return sk;
522}
523
501/** 524/**
502 * llc_lookup_listener - Finds listener for local MAC + SAP 525 * llc_lookup_listener - Finds listener for local MAC + SAP
503 * @sap: SAP 526 * @sap: SAP
@@ -506,6 +529,7 @@ found:
506 * Search connection list of the SAP and finds connection listening on 529 * Search connection list of the SAP and finds connection listening on
507 * local mac, and local sap. Returns pointer for parent socket found, 530 * local mac, and local sap. Returns pointer for parent socket found,
508 * %NULL otherwise. 531 * %NULL otherwise.
532 * Caller has to make sure local_bh is disabled.
509 */ 533 */
510static struct sock *llc_lookup_listener(struct llc_sap *sap, 534static struct sock *llc_lookup_listener(struct llc_sap *sap,
511 struct llc_addr *laddr) 535 struct llc_addr *laddr)
@@ -513,7 +537,7 @@ static struct sock *llc_lookup_listener(struct llc_sap *sap,
513 struct sock *rc; 537 struct sock *rc;
514 struct hlist_node *node; 538 struct hlist_node *node;
515 539
516 read_lock_bh(&sap->sk_list.lock); 540 read_lock(&sap->sk_list.lock);
517 sk_for_each(rc, node, &sap->sk_list.list) { 541 sk_for_each(rc, node, &sap->sk_list.list) {
518 struct llc_sock *llc = llc_sk(rc); 542 struct llc_sock *llc = llc_sk(rc);
519 543
@@ -527,10 +551,19 @@ static struct sock *llc_lookup_listener(struct llc_sap *sap,
527 } 551 }
528 rc = NULL; 552 rc = NULL;
529found: 553found:
530 read_unlock_bh(&sap->sk_list.lock); 554 read_unlock(&sap->sk_list.lock);
531 return rc; 555 return rc;
532} 556}
533 557
558static struct sock *__llc_lookup(struct llc_sap *sap,
559 struct llc_addr *daddr,
560 struct llc_addr *laddr)
561{
562 struct sock *sk = __llc_lookup_established(sap, daddr, laddr);
563
564 return sk ? : llc_lookup_listener(sap, laddr);
565}
566
534/** 567/**
535 * llc_data_accept_state - designates if in this state data can be sent. 568 * llc_data_accept_state - designates if in this state data can be sent.
536 * @state: state of connection. 569 * @state: state of connection.
@@ -544,14 +577,14 @@ u8 llc_data_accept_state(u8 state)
544} 577}
545 578
546/** 579/**
547 * find_next_offset - finds offset for next category of transitions 580 * llc_find_next_offset - finds offset for next category of transitions
548 * @state: state table. 581 * @state: state table.
549 * @offset: start offset. 582 * @offset: start offset.
550 * 583 *
551 * Finds offset of next category of transitions in transition table. 584 * Finds offset of next category of transitions in transition table.
552 * Returns the start index of next category. 585 * Returns the start index of next category.
553 */ 586 */
554static u16 find_next_offset(struct llc_conn_state *state, u16 offset) 587static u16 __init llc_find_next_offset(struct llc_conn_state *state, u16 offset)
555{ 588{
556 u16 cnt = 0; 589 u16 cnt = 0;
557 struct llc_conn_state_trans **next_trans; 590 struct llc_conn_state_trans **next_trans;
@@ -578,8 +611,8 @@ void __init llc_build_offset_table(void)
578 next_offset = 0; 611 next_offset = 0;
579 for (ev_type = 0; ev_type < NBR_CONN_EV; ev_type++) { 612 for (ev_type = 0; ev_type < NBR_CONN_EV; ev_type++) {
580 llc_offset_table[state][ev_type] = next_offset; 613 llc_offset_table[state][ev_type] = next_offset;
581 next_offset += find_next_offset(curr_state, 614 next_offset += llc_find_next_offset(curr_state,
582 next_offset) + 1; 615 next_offset) + 1;
583 } 616 }
584 } 617 }
585} 618}
@@ -623,6 +656,7 @@ static int llc_find_offset(int state, int ev_type)
623 */ 656 */
624void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) 657void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk)
625{ 658{
659 llc_sap_hold(sap);
626 write_lock_bh(&sap->sk_list.lock); 660 write_lock_bh(&sap->sk_list.lock);
627 llc_sk(sk)->sap = sap; 661 llc_sk(sk)->sap = sap;
628 sk_add_node(sk, &sap->sk_list.list); 662 sk_add_node(sk, &sap->sk_list.list);
@@ -642,6 +676,7 @@ void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk)
642 write_lock_bh(&sap->sk_list.lock); 676 write_lock_bh(&sap->sk_list.lock);
643 sk_del_node_init(sk); 677 sk_del_node_init(sk);
644 write_unlock_bh(&sap->sk_list.lock); 678 write_unlock_bh(&sap->sk_list.lock);
679 llc_sap_put(sap);
645} 680}
646 681
647/** 682/**
@@ -654,15 +689,34 @@ void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk)
654static int llc_conn_rcv(struct sock* sk, struct sk_buff *skb) 689static int llc_conn_rcv(struct sock* sk, struct sk_buff *skb)
655{ 690{
656 struct llc_conn_state_ev *ev = llc_conn_ev(skb); 691 struct llc_conn_state_ev *ev = llc_conn_ev(skb);
657 struct llc_sock *llc = llc_sk(sk);
658 692
659 if (!llc->dev)
660 llc->dev = skb->dev;
661 ev->type = LLC_CONN_EV_TYPE_PDU; 693 ev->type = LLC_CONN_EV_TYPE_PDU;
662 ev->reason = 0; 694 ev->reason = 0;
663 return llc_conn_state_process(sk, skb); 695 return llc_conn_state_process(sk, skb);
664} 696}
665 697
698static struct sock *llc_create_incoming_sock(struct sock *sk,
699 struct net_device *dev,
700 struct llc_addr *saddr,
701 struct llc_addr *daddr)
702{
703 struct sock *newsk = llc_sk_alloc(sk->sk_family, GFP_ATOMIC,
704 sk->sk_prot);
705 struct llc_sock *newllc, *llc = llc_sk(sk);
706
707 if (!newsk)
708 goto out;
709 newllc = llc_sk(newsk);
710 memcpy(&newllc->laddr, daddr, sizeof(newllc->laddr));
711 memcpy(&newllc->daddr, saddr, sizeof(newllc->daddr));
712 newllc->dev = dev;
713 dev_hold(dev);
714 llc_sap_add_socket(llc->sap, newsk);
715 llc_sap_hold(llc->sap);
716out:
717 return newsk;
718}
719
666void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb) 720void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
667{ 721{
668 struct llc_addr saddr, daddr; 722 struct llc_addr saddr, daddr;
@@ -673,35 +727,35 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
673 llc_pdu_decode_da(skb, daddr.mac); 727 llc_pdu_decode_da(skb, daddr.mac);
674 llc_pdu_decode_dsap(skb, &daddr.lsap); 728 llc_pdu_decode_dsap(skb, &daddr.lsap);
675 729
676 sk = llc_lookup_established(sap, &saddr, &daddr); 730 sk = __llc_lookup(sap, &saddr, &daddr);
677 if (!sk) { 731 if (!sk)
732 goto drop;
733
734 bh_lock_sock(sk);
735 /*
736 * This has to be done here and not at the upper layer ->accept
737 * method because of the way the PROCOM state machine works:
738 * it needs to set several state variables (see, for instance,
739 * llc_adm_actions_2 in net/llc/llc_c_st.c) and send a packet to
740 * the originator of the new connection, and this state has to be
741 * in the newly created struct sock private area. -acme
742 */
743 if (unlikely(sk->sk_state == TCP_LISTEN)) {
744 struct sock *newsk = llc_create_incoming_sock(sk, skb->dev,
745 &saddr, &daddr);
746 if (!newsk)
747 goto drop_unlock;
748 skb_set_owner_r(skb, newsk);
749 } else {
678 /* 750 /*
679 * Didn't find an active connection; verify if there 751 * Can't be skb_set_owner_r, this will be done at the
680 * is a listening socket for this llc addr 752 * llc_conn_state_process function, later on, when we will use
753 * skb_queue_rcv_skb to send it to upper layers, this is
754 * another trick required to cope with how the PROCOM state
755 * machine works. -acme
681 */ 756 */
682 struct llc_sock *llc;
683 struct sock *parent = llc_lookup_listener(sap, &daddr);
684
685 if (!parent) {
686 dprintk("llc_lookup_listener failed!\n");
687 goto drop;
688 }
689
690 sk = llc_sk_alloc(parent->sk_family, GFP_ATOMIC, parent->sk_prot);
691 if (!sk) {
692 sock_put(parent);
693 goto drop;
694 }
695 llc = llc_sk(sk);
696 memcpy(&llc->laddr, &daddr, sizeof(llc->laddr));
697 memcpy(&llc->daddr, &saddr, sizeof(llc->daddr));
698 llc_sap_add_socket(sap, sk);
699 sock_hold(sk);
700 sock_put(parent);
701 skb->sk = parent;
702 } else
703 skb->sk = sk; 757 skb->sk = sk;
704 bh_lock_sock(sk); 758 }
705 if (!sock_owned_by_user(sk)) 759 if (!sock_owned_by_user(sk))
706 llc_conn_rcv(sk, skb); 760 llc_conn_rcv(sk, skb);
707 else { 761 else {
@@ -709,11 +763,16 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
709 llc_set_backlog_type(skb, LLC_PACKET); 763 llc_set_backlog_type(skb, LLC_PACKET);
710 sk_add_backlog(sk, skb); 764 sk_add_backlog(sk, skb);
711 } 765 }
766out:
712 bh_unlock_sock(sk); 767 bh_unlock_sock(sk);
713 sock_put(sk); 768 sock_put(sk);
714 return; 769 return;
715drop: 770drop:
716 kfree_skb(skb); 771 kfree_skb(skb);
772 return;
773drop_unlock:
774 kfree_skb(skb);
775 goto out;
717} 776}
718 777
719#undef LLC_REFCNT_DEBUG 778#undef LLC_REFCNT_DEBUG
@@ -722,32 +781,6 @@ static atomic_t llc_sock_nr;
722#endif 781#endif
723 782
724/** 783/**
725 * llc_release_sockets - releases all sockets in a sap
726 * @sap: sap to release its sockets
727 *
728 * Releases all connections of a sap. Returns 0 if all actions complete
729 * successfully, nonzero otherwise
730 */
731int llc_release_sockets(struct llc_sap *sap)
732{
733 int rc = 0;
734 struct sock *sk;
735 struct hlist_node *node;
736
737 write_lock_bh(&sap->sk_list.lock);
738
739 sk_for_each(sk, node, &sap->sk_list.list) {
740 llc_sk(sk)->state = LLC_CONN_STATE_TEMP;
741
742 if (llc_send_disc(sk))
743 rc = 1;
744 }
745
746 write_unlock_bh(&sap->sk_list.lock);
747 return rc;
748}
749
750/**
751 * llc_backlog_rcv - Processes rx frames and expired timers. 784 * llc_backlog_rcv - Processes rx frames and expired timers.
752 * @sk: LLC sock (p8022 connection) 785 * @sk: LLC sock (p8022 connection)
753 * @skb: queued rx frame or event 786 * @skb: queued rx frame or event
@@ -762,14 +795,14 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
762 int rc = 0; 795 int rc = 0;
763 struct llc_sock *llc = llc_sk(sk); 796 struct llc_sock *llc = llc_sk(sk);
764 797
765 if (llc_backlog_type(skb) == LLC_PACKET) { 798 if (likely(llc_backlog_type(skb) == LLC_PACKET)) {
766 if (llc->state > 1) /* not closed */ 799 if (likely(llc->state > 1)) /* not closed */
767 rc = llc_conn_rcv(sk, skb); 800 rc = llc_conn_rcv(sk, skb);
768 else 801 else
769 goto out_kfree_skb; 802 goto out_kfree_skb;
770 } else if (llc_backlog_type(skb) == LLC_EVENT) { 803 } else if (llc_backlog_type(skb) == LLC_EVENT) {
771 /* timer expiration event */ 804 /* timer expiration event */
772 if (llc->state > 1) /* not closed */ 805 if (likely(llc->state > 1)) /* not closed */
773 rc = llc_conn_state_process(sk, skb); 806 rc = llc_conn_state_process(sk, skb);
774 else 807 else
775 goto out_kfree_skb; 808 goto out_kfree_skb;
@@ -799,22 +832,22 @@ static void llc_sk_init(struct sock* sk)
799 llc->dec_step = llc->connect_step = 1; 832 llc->dec_step = llc->connect_step = 1;
800 833
801 init_timer(&llc->ack_timer.timer); 834 init_timer(&llc->ack_timer.timer);
802 llc->ack_timer.expire = LLC_ACK_TIME; 835 llc->ack_timer.expire = sysctl_llc2_ack_timeout;
803 llc->ack_timer.timer.data = (unsigned long)sk; 836 llc->ack_timer.timer.data = (unsigned long)sk;
804 llc->ack_timer.timer.function = llc_conn_ack_tmr_cb; 837 llc->ack_timer.timer.function = llc_conn_ack_tmr_cb;
805 838
806 init_timer(&llc->pf_cycle_timer.timer); 839 init_timer(&llc->pf_cycle_timer.timer);
807 llc->pf_cycle_timer.expire = LLC_P_TIME; 840 llc->pf_cycle_timer.expire = sysctl_llc2_p_timeout;
808 llc->pf_cycle_timer.timer.data = (unsigned long)sk; 841 llc->pf_cycle_timer.timer.data = (unsigned long)sk;
809 llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb; 842 llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb;
810 843
811 init_timer(&llc->rej_sent_timer.timer); 844 init_timer(&llc->rej_sent_timer.timer);
812 llc->rej_sent_timer.expire = LLC_REJ_TIME; 845 llc->rej_sent_timer.expire = sysctl_llc2_rej_timeout;
813 llc->rej_sent_timer.timer.data = (unsigned long)sk; 846 llc->rej_sent_timer.timer.data = (unsigned long)sk;
814 llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb; 847 llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb;
815 848
816 init_timer(&llc->busy_state_timer.timer); 849 init_timer(&llc->busy_state_timer.timer);
817 llc->busy_state_timer.expire = LLC_BUSY_TIME; 850 llc->busy_state_timer.expire = sysctl_llc2_busy_timeout;
818 llc->busy_state_timer.timer.data = (unsigned long)sk; 851 llc->busy_state_timer.timer.data = (unsigned long)sk;
819 llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb; 852 llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb;
820 853
@@ -834,7 +867,7 @@ static void llc_sk_init(struct sock* sk)
834 * Allocates a LLC sock and initializes it. Returns the new LLC sock 867 * Allocates a LLC sock and initializes it. Returns the new LLC sock
835 * or %NULL if there's no memory available for one 868 * or %NULL if there's no memory available for one
836 */ 869 */
837struct sock *llc_sk_alloc(int family, int priority, struct proto *prot) 870struct sock *llc_sk_alloc(int family, gfp_t priority, struct proto *prot)
838{ 871{
839 struct sock *sk = sk_alloc(family, priority, prot, 1); 872 struct sock *sk = sk_alloc(family, priority, prot, 1);
840 873
diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c
index 9727455bf0e7..ab0fcd32fd84 100644
--- a/net/llc/llc_core.c
+++ b/net/llc/llc_core.c
@@ -40,6 +40,7 @@ static struct llc_sap *llc_sap_alloc(void)
40 sap->state = LLC_SAP_STATE_ACTIVE; 40 sap->state = LLC_SAP_STATE_ACTIVE;
41 memcpy(sap->laddr.mac, llc_station_mac_sa, ETH_ALEN); 41 memcpy(sap->laddr.mac, llc_station_mac_sa, ETH_ALEN);
42 rwlock_init(&sap->sk_list.lock); 42 rwlock_init(&sap->sk_list.lock);
43 atomic_set(&sap->refcnt, 1);
43 } 44 }
44 return sap; 45 return sap;
45} 46}
@@ -52,9 +53,7 @@ static struct llc_sap *llc_sap_alloc(void)
52 */ 53 */
53static void llc_add_sap(struct llc_sap *sap) 54static void llc_add_sap(struct llc_sap *sap)
54{ 55{
55 write_lock_bh(&llc_sap_list_lock);
56 list_add_tail(&sap->node, &llc_sap_list); 56 list_add_tail(&sap->node, &llc_sap_list);
57 write_unlock_bh(&llc_sap_list_lock);
58} 57}
59 58
60/** 59/**
@@ -70,11 +69,25 @@ static void llc_del_sap(struct llc_sap *sap)
70 write_unlock_bh(&llc_sap_list_lock); 69 write_unlock_bh(&llc_sap_list_lock);
71} 70}
72 71
72static struct llc_sap *__llc_sap_find(unsigned char sap_value)
73{
74 struct llc_sap* sap;
75
76 list_for_each_entry(sap, &llc_sap_list, node)
77 if (sap->laddr.lsap == sap_value)
78 goto out;
79 sap = NULL;
80out:
81 return sap;
82}
83
73/** 84/**
74 * llc_sap_find - searchs a SAP in station 85 * llc_sap_find - searchs a SAP in station
75 * @sap_value: sap to be found 86 * @sap_value: sap to be found
76 * 87 *
77 * Searchs for a sap in the sap list of the LLC's station upon the sap ID. 88 * Searchs for a sap in the sap list of the LLC's station upon the sap ID.
89 * If the sap is found it will be refcounted and the user will have to do
90 * a llc_sap_put after use.
78 * Returns the sap or %NULL if not found. 91 * Returns the sap or %NULL if not found.
79 */ 92 */
80struct llc_sap *llc_sap_find(unsigned char sap_value) 93struct llc_sap *llc_sap_find(unsigned char sap_value)
@@ -82,11 +95,9 @@ struct llc_sap *llc_sap_find(unsigned char sap_value)
82 struct llc_sap* sap; 95 struct llc_sap* sap;
83 96
84 read_lock_bh(&llc_sap_list_lock); 97 read_lock_bh(&llc_sap_list_lock);
85 list_for_each_entry(sap, &llc_sap_list, node) 98 sap = __llc_sap_find(sap_value);
86 if (sap->laddr.lsap == sap_value) 99 if (sap)
87 goto out; 100 llc_sap_hold(sap);
88 sap = NULL;
89out:
90 read_unlock_bh(&llc_sap_list_lock); 101 read_unlock_bh(&llc_sap_list_lock);
91 return sap; 102 return sap;
92} 103}
@@ -106,19 +117,20 @@ struct llc_sap *llc_sap_open(unsigned char lsap,
106 struct packet_type *pt, 117 struct packet_type *pt,
107 struct net_device *orig_dev)) 118 struct net_device *orig_dev))
108{ 119{
109 struct llc_sap *sap = llc_sap_find(lsap); 120 struct llc_sap *sap = NULL;
110 121
111 if (sap) { /* SAP already exists */ 122 write_lock_bh(&llc_sap_list_lock);
112 sap = NULL; 123 if (__llc_sap_find(lsap)) /* SAP already exists */
113 goto out; 124 goto out;
114 }
115 sap = llc_sap_alloc(); 125 sap = llc_sap_alloc();
116 if (!sap) 126 if (!sap)
117 goto out; 127 goto out;
118 sap->laddr.lsap = lsap; 128 sap->laddr.lsap = lsap;
119 sap->rcv_func = func; 129 sap->rcv_func = func;
130 llc_sap_hold(sap);
120 llc_add_sap(sap); 131 llc_add_sap(sap);
121out: 132out:
133 write_unlock_bh(&llc_sap_list_lock);
122 return sap; 134 return sap;
123} 135}
124 136
diff --git a/net/llc/llc_if.c b/net/llc/llc_if.c
index 0f84f66018e4..ba90f7f0801a 100644
--- a/net/llc/llc_if.c
+++ b/net/llc/llc_if.c
@@ -47,14 +47,11 @@ int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb)
47 int rc = -ECONNABORTED; 47 int rc = -ECONNABORTED;
48 struct llc_sock *llc = llc_sk(sk); 48 struct llc_sock *llc = llc_sk(sk);
49 49
50 if (llc->state == LLC_CONN_STATE_ADM) 50 if (unlikely(llc->state == LLC_CONN_STATE_ADM))
51 goto out; 51 goto out;
52 rc = -EBUSY; 52 rc = -EBUSY;
53 if (llc_data_accept_state(llc->state)) { /* data_conn_refuse */ 53 if (unlikely(llc_data_accept_state(llc->state) || /* data_conn_refuse */
54 llc->failed_data_req = 1; 54 llc->p_flag)) {
55 goto out;
56 }
57 if (llc->p_flag) {
58 llc->failed_data_req = 1; 55 llc->failed_data_req = 1;
59 goto out; 56 goto out;
60 } 57 }
@@ -110,6 +107,7 @@ int llc_establish_connection(struct sock *sk, u8 *lmac, u8 *dmac, u8 dsap)
110 ev->type = LLC_CONN_EV_TYPE_PRIM; 107 ev->type = LLC_CONN_EV_TYPE_PRIM;
111 ev->prim = LLC_CONN_PRIM; 108 ev->prim = LLC_CONN_PRIM;
112 ev->prim_type = LLC_PRIM_TYPE_REQ; 109 ev->prim_type = LLC_PRIM_TYPE_REQ;
110 skb_set_owner_w(skb, sk);
113 rc = llc_conn_state_process(sk, skb); 111 rc = llc_conn_state_process(sk, skb);
114 } 112 }
115out_put: 113out_put:
@@ -144,6 +142,7 @@ int llc_send_disc(struct sock *sk)
144 skb = alloc_skb(0, GFP_ATOMIC); 142 skb = alloc_skb(0, GFP_ATOMIC);
145 if (!skb) 143 if (!skb)
146 goto out; 144 goto out;
145 skb_set_owner_w(skb, sk);
147 sk->sk_state = TCP_CLOSING; 146 sk->sk_state = TCP_CLOSING;
148 ev = llc_conn_ev(skb); 147 ev = llc_conn_ev(skb);
149 ev->type = LLC_CONN_EV_TYPE_PRIM; 148 ev->type = LLC_CONN_EV_TYPE_PRIM;
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index 13b46240b7a1..8f3addf0724c 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -99,15 +99,19 @@ out:
99static inline int llc_fixup_skb(struct sk_buff *skb) 99static inline int llc_fixup_skb(struct sk_buff *skb)
100{ 100{
101 u8 llc_len = 2; 101 u8 llc_len = 2;
102 struct llc_pdu_sn *pdu; 102 struct llc_pdu_un *pdu;
103 103
104 if (!pskb_may_pull(skb, sizeof(*pdu))) 104 if (unlikely(!pskb_may_pull(skb, sizeof(*pdu))))
105 return 0; 105 return 0;
106 106
107 pdu = (struct llc_pdu_sn *)skb->data; 107 pdu = (struct llc_pdu_un *)skb->data;
108 if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U) 108 if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U)
109 llc_len = 1; 109 llc_len = 1;
110 llc_len += 2; 110 llc_len += 2;
111
112 if (unlikely(!pskb_may_pull(skb, llc_len)))
113 return 0;
114
111 skb->h.raw += llc_len; 115 skb->h.raw += llc_len;
112 skb_pull(skb, llc_len); 116 skb_pull(skb, llc_len);
113 if (skb->protocol == htons(ETH_P_802_2)) { 117 if (skb->protocol == htons(ETH_P_802_2)) {
@@ -166,17 +170,22 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
166 */ 170 */
167 if (sap->rcv_func) { 171 if (sap->rcv_func) {
168 sap->rcv_func(skb, dev, pt, orig_dev); 172 sap->rcv_func(skb, dev, pt, orig_dev);
169 goto out; 173 goto out_put;
170 } 174 }
171 dest = llc_pdu_type(skb); 175 dest = llc_pdu_type(skb);
172 if (unlikely(!dest || !llc_type_handlers[dest - 1])) 176 if (unlikely(!dest || !llc_type_handlers[dest - 1]))
173 goto drop; 177 goto drop_put;
174 llc_type_handlers[dest - 1](sap, skb); 178 llc_type_handlers[dest - 1](sap, skb);
179out_put:
180 llc_sap_put(sap);
175out: 181out:
176 return 0; 182 return 0;
177drop: 183drop:
178 kfree_skb(skb); 184 kfree_skb(skb);
179 goto out; 185 goto out;
186drop_put:
187 kfree_skb(skb);
188 goto out_put;
180handle_station: 189handle_station:
181 if (!llc_station_handler) 190 if (!llc_station_handler)
182 goto drop; 191 goto drop;
diff --git a/net/llc/llc_output.c b/net/llc/llc_output.c
index ab5784cf163e..b4d55b6abb67 100644
--- a/net/llc/llc_output.c
+++ b/net/llc/llc_output.c
@@ -98,7 +98,7 @@ int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
98 dsap, LLC_PDU_CMD); 98 dsap, LLC_PDU_CMD);
99 llc_pdu_init_as_ui_cmd(skb); 99 llc_pdu_init_as_ui_cmd(skb);
100 rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac); 100 rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac);
101 if (!rc) 101 if (likely(!rc))
102 rc = dev_queue_xmit(skb); 102 rc = dev_queue_xmit(skb);
103 return rc; 103 return rc;
104} 104}
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index 36e8db3fa1a2..bd531cb235a7 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -134,7 +134,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
134 llc_ui_format_mac(seq, llc->daddr.mac); 134 llc_ui_format_mac(seq, llc->daddr.mac);
135 seq_printf(seq, "@%02X %8d %8d %2d %3d %4d\n", llc->daddr.lsap, 135 seq_printf(seq, "@%02X %8d %8d %2d %3d %4d\n", llc->daddr.lsap,
136 atomic_read(&sk->sk_wmem_alloc), 136 atomic_read(&sk->sk_wmem_alloc),
137 atomic_read(&sk->sk_rmem_alloc), 137 atomic_read(&sk->sk_rmem_alloc) - llc->copied_seq,
138 sk->sk_state, 138 sk->sk_state,
139 sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1, 139 sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1,
140 llc->link); 140 llc->link);
diff --git a/net/llc/llc_s_ac.c b/net/llc/llc_s_ac.c
index ed8ba7de6122..bb3580fb8cfe 100644
--- a/net/llc/llc_s_ac.c
+++ b/net/llc/llc_s_ac.c
@@ -58,7 +58,7 @@ int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb)
58 ev->daddr.lsap, LLC_PDU_CMD); 58 ev->daddr.lsap, LLC_PDU_CMD);
59 llc_pdu_init_as_ui_cmd(skb); 59 llc_pdu_init_as_ui_cmd(skb);
60 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); 60 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
61 if (!rc) 61 if (likely(!rc))
62 rc = dev_queue_xmit(skb); 62 rc = dev_queue_xmit(skb);
63 return rc; 63 return rc;
64} 64}
@@ -81,7 +81,7 @@ int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb)
81 ev->daddr.lsap, LLC_PDU_CMD); 81 ev->daddr.lsap, LLC_PDU_CMD);
82 llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0); 82 llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0);
83 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); 83 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
84 if (!rc) 84 if (likely(!rc))
85 rc = dev_queue_xmit(skb); 85 rc = dev_queue_xmit(skb);
86 return rc; 86 return rc;
87} 87}
@@ -103,15 +103,14 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)
103 llc_pdu_decode_sa(skb, mac_da); 103 llc_pdu_decode_sa(skb, mac_da);
104 llc_pdu_decode_da(skb, mac_sa); 104 llc_pdu_decode_da(skb, mac_sa);
105 llc_pdu_decode_ssap(skb, &dsap); 105 llc_pdu_decode_ssap(skb, &dsap);
106 nskb = llc_alloc_frame(); 106 nskb = llc_alloc_frame(NULL, skb->dev);
107 if (!nskb) 107 if (!nskb)
108 goto out; 108 goto out;
109 nskb->dev = skb->dev;
110 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, 109 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
111 LLC_PDU_RSP); 110 LLC_PDU_RSP);
112 llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0); 111 llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0);
113 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da); 112 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da);
114 if (!rc) 113 if (likely(!rc))
115 rc = dev_queue_xmit(nskb); 114 rc = dev_queue_xmit(nskb);
116out: 115out:
117 return rc; 116 return rc;
@@ -135,7 +134,7 @@ int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb)
135 ev->daddr.lsap, LLC_PDU_CMD); 134 ev->daddr.lsap, LLC_PDU_CMD);
136 llc_pdu_init_as_test_cmd(skb); 135 llc_pdu_init_as_test_cmd(skb);
137 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); 136 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
138 if (!rc) 137 if (likely(!rc))
139 rc = dev_queue_xmit(skb); 138 rc = dev_queue_xmit(skb);
140 return rc; 139 return rc;
141} 140}
@@ -149,15 +148,14 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
149 llc_pdu_decode_sa(skb, mac_da); 148 llc_pdu_decode_sa(skb, mac_da);
150 llc_pdu_decode_da(skb, mac_sa); 149 llc_pdu_decode_da(skb, mac_sa);
151 llc_pdu_decode_ssap(skb, &dsap); 150 llc_pdu_decode_ssap(skb, &dsap);
152 nskb = llc_alloc_frame(); 151 nskb = llc_alloc_frame(NULL, skb->dev);
153 if (!nskb) 152 if (!nskb)
154 goto out; 153 goto out;
155 nskb->dev = skb->dev;
156 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, 154 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
157 LLC_PDU_RSP); 155 LLC_PDU_RSP);
158 llc_pdu_init_as_test_rsp(nskb, skb); 156 llc_pdu_init_as_test_rsp(nskb, skb);
159 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da); 157 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da);
160 if (!rc) 158 if (likely(!rc))
161 rc = dev_queue_xmit(nskb); 159 rc = dev_queue_xmit(nskb);
162out: 160out:
163 return rc; 161 return rc;
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index 34228ef14985..4029ceee9b91 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -26,11 +26,12 @@
26 26
27/** 27/**
28 * llc_alloc_frame - allocates sk_buff for frame 28 * llc_alloc_frame - allocates sk_buff for frame
29 * @dev: network device this skb will be sent over
29 * 30 *
30 * Allocates an sk_buff for frame and initializes sk_buff fields. 31 * Allocates an sk_buff for frame and initializes sk_buff fields.
31 * Returns allocated skb or %NULL when out of memory. 32 * Returns allocated skb or %NULL when out of memory.
32 */ 33 */
33struct sk_buff *llc_alloc_frame(void) 34struct sk_buff *llc_alloc_frame(struct sock *sk, struct net_device *dev)
34{ 35{
35 struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC); 36 struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC);
36 37
@@ -38,18 +39,23 @@ struct sk_buff *llc_alloc_frame(void)
38 skb_reserve(skb, 50); 39 skb_reserve(skb, 50);
39 skb->nh.raw = skb->h.raw = skb->data; 40 skb->nh.raw = skb->h.raw = skb->data;
40 skb->protocol = htons(ETH_P_802_2); 41 skb->protocol = htons(ETH_P_802_2);
41 skb->dev = dev_base->next; 42 skb->dev = dev;
42 skb->mac.raw = skb->head; 43 skb->mac.raw = skb->head;
44 if (sk != NULL)
45 skb_set_owner_w(skb, sk);
43 } 46 }
44 return skb; 47 return skb;
45} 48}
46 49
47void llc_save_primitive(struct sk_buff* skb, u8 prim) 50void llc_save_primitive(struct sock *sk, struct sk_buff* skb, u8 prim)
48{ 51{
49 struct sockaddr_llc *addr = llc_ui_skb_cb(skb); 52 struct sockaddr_llc *addr;
50 53
54 if (skb->sk->sk_type == SOCK_STREAM) /* See UNIX98 */
55 return;
51 /* save primitive for use by the user. */ 56 /* save primitive for use by the user. */
52 addr->sllc_family = skb->sk->sk_family; 57 addr = llc_ui_skb_cb(skb);
58 addr->sllc_family = sk->sk_family;
53 addr->sllc_arphrd = skb->dev->type; 59 addr->sllc_arphrd = skb->dev->type;
54 addr->sllc_test = prim == LLC_TEST_PRIM; 60 addr->sllc_test = prim == LLC_TEST_PRIM;
55 addr->sllc_xid = prim == LLC_XID_PRIM; 61 addr->sllc_xid = prim == LLC_XID_PRIM;
@@ -189,7 +195,7 @@ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
189 if (skb->sk->sk_state == TCP_LISTEN) 195 if (skb->sk->sk_state == TCP_LISTEN)
190 kfree_skb(skb); 196 kfree_skb(skb);
191 else { 197 else {
192 llc_save_primitive(skb, ev->prim); 198 llc_save_primitive(skb->sk, skb, ev->prim);
193 199
194 /* queue skb to the user. */ 200 /* queue skb to the user. */
195 if (sock_queue_rcv_skb(skb->sk, skb)) 201 if (sock_queue_rcv_skb(skb->sk, skb))
@@ -308,7 +314,7 @@ void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb)
308 314
309 sk = llc_lookup_dgram(sap, &laddr); 315 sk = llc_lookup_dgram(sap, &laddr);
310 if (sk) { 316 if (sk) {
311 skb->sk = sk; 317 skb_set_owner_r(skb, sk);
312 llc_sap_rcv(sap, skb); 318 llc_sap_rcv(sap, skb);
313 sock_put(sk); 319 sock_put(sk);
314 } else 320 } else
diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c
index 8fe48a24bad5..f37dbf8ef126 100644
--- a/net/llc/llc_station.c
+++ b/net/llc/llc_station.c
@@ -50,6 +50,10 @@ struct llc_station {
50 struct sk_buff_head mac_pdu_q; 50 struct sk_buff_head mac_pdu_q;
51}; 51};
52 52
53#define LLC_STATION_ACK_TIME (3 * HZ)
54
55int sysctl_llc_station_ack_timeout = LLC_STATION_ACK_TIME;
56
53/* Types of events (possible values in 'ev->type') */ 57/* Types of events (possible values in 'ev->type') */
54#define LLC_STATION_EV_TYPE_SIMPLE 1 58#define LLC_STATION_EV_TYPE_SIMPLE 1
55#define LLC_STATION_EV_TYPE_CONDITION 2 59#define LLC_STATION_EV_TYPE_CONDITION 2
@@ -218,7 +222,8 @@ static void llc_station_send_pdu(struct sk_buff *skb)
218 222
219static int llc_station_ac_start_ack_timer(struct sk_buff *skb) 223static int llc_station_ac_start_ack_timer(struct sk_buff *skb)
220{ 224{
221 mod_timer(&llc_main_station.ack_timer, jiffies + LLC_ACK_TIME * HZ); 225 mod_timer(&llc_main_station.ack_timer,
226 jiffies + sysctl_llc_station_ack_timeout);
222 return 0; 227 return 0;
223} 228}
224 229
@@ -249,14 +254,14 @@ static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff *skb)
249static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb) 254static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb)
250{ 255{
251 int rc = 1; 256 int rc = 1;
252 struct sk_buff *nskb = llc_alloc_frame(); 257 struct sk_buff *nskb = llc_alloc_frame(NULL, skb->dev);
253 258
254 if (!nskb) 259 if (!nskb)
255 goto out; 260 goto out;
256 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD); 261 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD);
257 llc_pdu_init_as_xid_cmd(nskb, LLC_XID_NULL_CLASS_2, 127); 262 llc_pdu_init_as_xid_cmd(nskb, LLC_XID_NULL_CLASS_2, 127);
258 rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, llc_station_mac_sa); 263 rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, llc_station_mac_sa);
259 if (rc) 264 if (unlikely(rc))
260 goto free; 265 goto free;
261 llc_station_send_pdu(nskb); 266 llc_station_send_pdu(nskb);
262out: 267out:
@@ -270,18 +275,17 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb)
270{ 275{
271 u8 mac_da[ETH_ALEN], dsap; 276 u8 mac_da[ETH_ALEN], dsap;
272 int rc = 1; 277 int rc = 1;
273 struct sk_buff* nskb = llc_alloc_frame(); 278 struct sk_buff* nskb = llc_alloc_frame(NULL, skb->dev);
274 279
275 if (!nskb) 280 if (!nskb)
276 goto out; 281 goto out;
277 rc = 0; 282 rc = 0;
278 nskb->dev = skb->dev;
279 llc_pdu_decode_sa(skb, mac_da); 283 llc_pdu_decode_sa(skb, mac_da);
280 llc_pdu_decode_ssap(skb, &dsap); 284 llc_pdu_decode_ssap(skb, &dsap);
281 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); 285 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
282 llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 127); 286 llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 127);
283 rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da); 287 rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da);
284 if (rc) 288 if (unlikely(rc))
285 goto free; 289 goto free;
286 llc_station_send_pdu(nskb); 290 llc_station_send_pdu(nskb);
287out: 291out:
@@ -295,18 +299,17 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb)
295{ 299{
296 u8 mac_da[ETH_ALEN], dsap; 300 u8 mac_da[ETH_ALEN], dsap;
297 int rc = 1; 301 int rc = 1;
298 struct sk_buff *nskb = llc_alloc_frame(); 302 struct sk_buff *nskb = llc_alloc_frame(NULL, skb->dev);
299 303
300 if (!nskb) 304 if (!nskb)
301 goto out; 305 goto out;
302 rc = 0; 306 rc = 0;
303 nskb->dev = skb->dev;
304 llc_pdu_decode_sa(skb, mac_da); 307 llc_pdu_decode_sa(skb, mac_da);
305 llc_pdu_decode_ssap(skb, &dsap); 308 llc_pdu_decode_ssap(skb, &dsap);
306 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); 309 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
307 llc_pdu_init_as_test_rsp(nskb, skb); 310 llc_pdu_init_as_test_rsp(nskb, skb);
308 rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da); 311 rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da);
309 if (rc) 312 if (unlikely(rc))
310 goto free; 313 goto free;
311 llc_station_send_pdu(nskb); 314 llc_station_send_pdu(nskb);
312out: 315out:
@@ -689,7 +692,8 @@ int __init llc_station_init(void)
689 init_timer(&llc_main_station.ack_timer); 692 init_timer(&llc_main_station.ack_timer);
690 llc_main_station.ack_timer.data = (unsigned long)&llc_main_station; 693 llc_main_station.ack_timer.data = (unsigned long)&llc_main_station;
691 llc_main_station.ack_timer.function = llc_station_ack_tmr_cb; 694 llc_main_station.ack_timer.function = llc_station_ack_tmr_cb;
692 695 llc_main_station.ack_timer.expires = jiffies +
696 sysctl_llc_station_ack_timeout;
693 skb = alloc_skb(0, GFP_ATOMIC); 697 skb = alloc_skb(0, GFP_ATOMIC);
694 if (!skb) 698 if (!skb)
695 goto out; 699 goto out;
@@ -697,7 +701,6 @@ int __init llc_station_init(void)
697 llc_set_station_handler(llc_station_rcv); 701 llc_set_station_handler(llc_station_rcv);
698 ev = llc_station_ev(skb); 702 ev = llc_station_ev(skb);
699 memset(ev, 0, sizeof(*ev)); 703 memset(ev, 0, sizeof(*ev));
700 llc_main_station.ack_timer.expires = jiffies + 3 * HZ;
701 llc_main_station.maximum_retry = 1; 704 llc_main_station.maximum_retry = 1;
702 llc_main_station.state = LLC_STATION_STATE_DOWN; 705 llc_main_station.state = LLC_STATION_STATE_DOWN;
703 ev->type = LLC_STATION_EV_TYPE_SIMPLE; 706 ev->type = LLC_STATION_EV_TYPE_SIMPLE;
diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c
new file mode 100644
index 000000000000..d1eaddb13633
--- /dev/null
+++ b/net/llc/sysctl_net_llc.c
@@ -0,0 +1,131 @@
1/*
2 * sysctl_net_llc.c: sysctl interface to LLC net subsystem.
3 *
4 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 */
6
7#include <linux/config.h>
8#include <linux/mm.h>
9#include <linux/init.h>
10#include <linux/sysctl.h>
11#include <net/llc.h>
12
13#ifndef CONFIG_SYSCTL
14#error This file should not be compiled without CONFIG_SYSCTL defined
15#endif
16
17static struct ctl_table llc2_timeout_table[] = {
18 {
19 .ctl_name = NET_LLC2_ACK_TIMEOUT,
20 .procname = "ack",
21 .data = &sysctl_llc2_ack_timeout,
22 .maxlen = sizeof(long),
23 .mode = 0644,
24 .proc_handler = &proc_dointvec_jiffies,
25 .strategy = &sysctl_jiffies,
26 },
27 {
28 .ctl_name = NET_LLC2_BUSY_TIMEOUT,
29 .procname = "busy",
30 .data = &sysctl_llc2_busy_timeout,
31 .maxlen = sizeof(long),
32 .mode = 0644,
33 .proc_handler = &proc_dointvec_jiffies,
34 .strategy = &sysctl_jiffies,
35 },
36 {
37 .ctl_name = NET_LLC2_P_TIMEOUT,
38 .procname = "p",
39 .data = &sysctl_llc2_p_timeout,
40 .maxlen = sizeof(long),
41 .mode = 0644,
42 .proc_handler = &proc_dointvec_jiffies,
43 .strategy = &sysctl_jiffies,
44 },
45 {
46 .ctl_name = NET_LLC2_REJ_TIMEOUT,
47 .procname = "rej",
48 .data = &sysctl_llc2_rej_timeout,
49 .maxlen = sizeof(long),
50 .mode = 0644,
51 .proc_handler = &proc_dointvec_jiffies,
52 .strategy = &sysctl_jiffies,
53 },
54 { 0 },
55};
56
57static struct ctl_table llc_station_table[] = {
58 {
59 .ctl_name = NET_LLC_STATION_ACK_TIMEOUT,
60 .procname = "ack_timeout",
61 .data = &sysctl_llc_station_ack_timeout,
62 .maxlen = sizeof(long),
63 .mode = 0644,
64 .proc_handler = &proc_dointvec_jiffies,
65 .strategy = &sysctl_jiffies,
66 },
67 { 0 },
68};
69
70static struct ctl_table llc2_dir_timeout_table[] = {
71 {
72 .ctl_name = NET_LLC2,
73 .procname = "timeout",
74 .mode = 0555,
75 .child = llc2_timeout_table,
76 },
77 { 0 },
78};
79
80static struct ctl_table llc_table[] = {
81 {
82 .ctl_name = NET_LLC2,
83 .procname = "llc2",
84 .mode = 0555,
85 .child = llc2_dir_timeout_table,
86 },
87 {
88 .ctl_name = NET_LLC_STATION,
89 .procname = "station",
90 .mode = 0555,
91 .child = llc_station_table,
92 },
93 { 0 },
94};
95
96static struct ctl_table llc_dir_table[] = {
97 {
98 .ctl_name = NET_LLC,
99 .procname = "llc",
100 .mode = 0555,
101 .child = llc_table,
102 },
103 { 0 },
104};
105
106static struct ctl_table llc_root_table[] = {
107 {
108 .ctl_name = CTL_NET,
109 .procname = "net",
110 .mode = 0555,
111 .child = llc_dir_table,
112 },
113 { 0 },
114};
115
116static struct ctl_table_header *llc_table_header;
117
118int __init llc_sysctl_init(void)
119{
120 llc_table_header = register_sysctl_table(llc_root_table, 1);
121
122 return llc_table_header ? 0 : -ENOMEM;
123}
124
125void llc_sysctl_exit(void)
126{
127 if (llc_table_header) {
128 unregister_sysctl_table(llc_table_header);
129 llc_table_header = NULL;
130 }
131}
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 49a3900e3d32..4bc27a6334c1 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -133,7 +133,7 @@ int nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
133 memset(tb, 0, sizeof(struct nfattr *) * maxattr); 133 memset(tb, 0, sizeof(struct nfattr *) * maxattr);
134 134
135 while (NFA_OK(nfa, len)) { 135 while (NFA_OK(nfa, len)) {
136 unsigned flavor = nfa->nfa_type; 136 unsigned flavor = NFA_TYPE(nfa);
137 if (flavor && flavor <= maxattr) 137 if (flavor && flavor <= maxattr)
138 tb[flavor-1] = nfa; 138 tb[flavor-1] = nfa;
139 nfa = NFA_NEXT(nfa, len); 139 nfa = NFA_NEXT(nfa, len);
@@ -177,7 +177,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
177 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); 177 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
178 178
179 while (NFA_OK(attr, attrlen)) { 179 while (NFA_OK(attr, attrlen)) {
180 unsigned flavor = attr->nfa_type; 180 unsigned flavor = NFA_TYPE(attr);
181 if (flavor) { 181 if (flavor) {
182 if (flavor > attr_count) 182 if (flavor > attr_count)
183 return -EINVAL; 183 return -EINVAL;
@@ -195,7 +195,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
195 195
196int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) 196int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
197{ 197{
198 int allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; 198 gfp_t allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
199 int err = 0; 199 int err = 0;
200 200
201 NETLINK_CB(skb).dst_group = group; 201 NETLINK_CB(skb).dst_group = group;
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index ff5601ceedcb..efcd10f996ba 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -494,8 +494,8 @@ __build_packet_message(struct nfulnl_instance *inst,
494 if (skb->tstamp.off_sec) { 494 if (skb->tstamp.off_sec) {
495 struct nfulnl_msg_packet_timestamp ts; 495 struct nfulnl_msg_packet_timestamp ts;
496 496
497 ts.sec = cpu_to_be64(skb_tv_base.tv_sec + skb->tstamp.off_sec); 497 ts.sec = cpu_to_be64(skb->tstamp.off_sec);
498 ts.usec = cpu_to_be64(skb_tv_base.tv_usec + skb->tstamp.off_usec); 498 ts.usec = cpu_to_be64(skb->tstamp.off_usec);
499 499
500 NFA_PUT(inst->skb, NFULA_TIMESTAMP, sizeof(ts), &ts); 500 NFA_PUT(inst->skb, NFULA_TIMESTAMP, sizeof(ts), &ts);
501 } 501 }
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index f81fe8c52e99..eaa44c49567b 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -492,8 +492,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
492 if (entry->skb->tstamp.off_sec) { 492 if (entry->skb->tstamp.off_sec) {
493 struct nfqnl_msg_packet_timestamp ts; 493 struct nfqnl_msg_packet_timestamp ts;
494 494
495 ts.sec = cpu_to_be64(skb_tv_base.tv_sec + entry->skb->tstamp.off_sec); 495 ts.sec = cpu_to_be64(entry->skb->tstamp.off_sec);
496 ts.usec = cpu_to_be64(skb_tv_base.tv_usec + entry->skb->tstamp.off_usec); 496 ts.usec = cpu_to_be64(entry->skb->tstamp.off_usec);
497 497
498 NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts); 498 NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts);
499 } 499 }
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index a64e1d5ce3ca..678c3f2c0d0b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -758,7 +758,7 @@ void netlink_detachskb(struct sock *sk, struct sk_buff *skb)
758} 758}
759 759
760static inline struct sk_buff *netlink_trim(struct sk_buff *skb, 760static inline struct sk_buff *netlink_trim(struct sk_buff *skb,
761 unsigned int __nocast allocation) 761 gfp_t allocation)
762{ 762{
763 int delta; 763 int delta;
764 764
@@ -880,7 +880,7 @@ out:
880} 880}
881 881
882int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, 882int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
883 u32 group, unsigned int __nocast allocation) 883 u32 group, gfp_t allocation)
884{ 884{
885 struct netlink_broadcast_data info; 885 struct netlink_broadcast_data info;
886 struct hlist_node *node; 886 struct hlist_node *node;
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c
index 4e66eef9a034..509afddae569 100644
--- a/net/netrom/nr_dev.c
+++ b/net/netrom/nr_dev.c
@@ -58,7 +58,7 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev)
58 58
59 /* Spoof incoming device */ 59 /* Spoof incoming device */
60 skb->dev = dev; 60 skb->dev = dev;
61 skb->h.raw = skb->data; 61 skb->mac.raw = skb->nh.raw;
62 skb->nh.raw = skb->data; 62 skb->nh.raw = skb->data;
63 skb->pkt_type = PACKET_HOST; 63 skb->pkt_type = PACKET_HOST;
64 64
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 8690f171c1ef..499ae3df4a44 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -36,6 +36,11 @@
36 * Michal Ostrowski : Module initialization cleanup. 36 * Michal Ostrowski : Module initialization cleanup.
37 * Ulises Alonso : Frame number limit removal and 37 * Ulises Alonso : Frame number limit removal and
38 * packet_set_ring memory leak. 38 * packet_set_ring memory leak.
39 * Eric Biederman : Allow for > 8 byte hardware addresses.
40 * The convention is that longer addresses
41 * will simply extend the hardware address
42 * byte arrays at the end of sockaddr_ll
43 * and packet_mreq.
39 * 44 *
40 * This program is free software; you can redistribute it and/or 45 * This program is free software; you can redistribute it and/or
41 * modify it under the terms of the GNU General Public License 46 * modify it under the terms of the GNU General Public License
@@ -161,7 +166,17 @@ struct packet_mclist
161 int count; 166 int count;
162 unsigned short type; 167 unsigned short type;
163 unsigned short alen; 168 unsigned short alen;
164 unsigned char addr[8]; 169 unsigned char addr[MAX_ADDR_LEN];
170};
171/* identical to struct packet_mreq except it has
172 * a longer address field.
173 */
174struct packet_mreq_max
175{
176 int mr_ifindex;
177 unsigned short mr_type;
178 unsigned short mr_alen;
179 unsigned char mr_address[MAX_ADDR_LEN];
165}; 180};
166#endif 181#endif
167#ifdef CONFIG_PACKET_MMAP 182#ifdef CONFIG_PACKET_MMAP
@@ -639,8 +654,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
639 __net_timestamp(skb); 654 __net_timestamp(skb);
640 sock_enable_timestamp(sk); 655 sock_enable_timestamp(sk);
641 } 656 }
642 h->tp_sec = skb_tv_base.tv_sec + skb->tstamp.off_sec; 657 h->tp_sec = skb->tstamp.off_sec;
643 h->tp_usec = skb_tv_base.tv_usec + skb->tstamp.off_usec; 658 h->tp_usec = skb->tstamp.off_usec;
644 659
645 sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h))); 660 sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h)));
646 sll->sll_halen = 0; 661 sll->sll_halen = 0;
@@ -716,6 +731,8 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
716 err = -EINVAL; 731 err = -EINVAL;
717 if (msg->msg_namelen < sizeof(struct sockaddr_ll)) 732 if (msg->msg_namelen < sizeof(struct sockaddr_ll))
718 goto out; 733 goto out;
734 if (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll, sll_addr)))
735 goto out;
719 ifindex = saddr->sll_ifindex; 736 ifindex = saddr->sll_ifindex;
720 proto = saddr->sll_protocol; 737 proto = saddr->sll_protocol;
721 addr = saddr->sll_addr; 738 addr = saddr->sll_addr;
@@ -1045,6 +1062,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1045 struct sock *sk = sock->sk; 1062 struct sock *sk = sock->sk;
1046 struct sk_buff *skb; 1063 struct sk_buff *skb;
1047 int copied, err; 1064 int copied, err;
1065 struct sockaddr_ll *sll;
1048 1066
1049 err = -EINVAL; 1067 err = -EINVAL;
1050 if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT)) 1068 if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT))
@@ -1057,16 +1075,6 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1057#endif 1075#endif
1058 1076
1059 /* 1077 /*
1060 * If the address length field is there to be filled in, we fill
1061 * it in now.
1062 */
1063
1064 if (sock->type == SOCK_PACKET)
1065 msg->msg_namelen = sizeof(struct sockaddr_pkt);
1066 else
1067 msg->msg_namelen = sizeof(struct sockaddr_ll);
1068
1069 /*
1070 * Call the generic datagram receiver. This handles all sorts 1078 * Call the generic datagram receiver. This handles all sorts
1071 * of horrible races and re-entrancy so we can forget about it 1079 * of horrible races and re-entrancy so we can forget about it
1072 * in the protocol layers. 1080 * in the protocol layers.
@@ -1087,6 +1095,17 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1087 goto out; 1095 goto out;
1088 1096
1089 /* 1097 /*
1098 * If the address length field is there to be filled in, we fill
1099 * it in now.
1100 */
1101
1102 sll = (struct sockaddr_ll*)skb->cb;
1103 if (sock->type == SOCK_PACKET)
1104 msg->msg_namelen = sizeof(struct sockaddr_pkt);
1105 else
1106 msg->msg_namelen = sll->sll_halen + offsetof(struct sockaddr_ll, sll_addr);
1107
1108 /*
1090 * You lose any data beyond the buffer you gave. If it worries a 1109 * You lose any data beyond the buffer you gave. If it worries a
1091 * user program they can ask the device for its MTU anyway. 1110 * user program they can ask the device for its MTU anyway.
1092 */ 1111 */
@@ -1166,7 +1185,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
1166 sll->sll_hatype = 0; /* Bad: we have no ARPHRD_UNSPEC */ 1185 sll->sll_hatype = 0; /* Bad: we have no ARPHRD_UNSPEC */
1167 sll->sll_halen = 0; 1186 sll->sll_halen = 0;
1168 } 1187 }
1169 *uaddr_len = sizeof(*sll); 1188 *uaddr_len = offsetof(struct sockaddr_ll, sll_addr) + sll->sll_halen;
1170 1189
1171 return 0; 1190 return 0;
1172} 1191}
@@ -1199,7 +1218,7 @@ static void packet_dev_mclist(struct net_device *dev, struct packet_mclist *i, i
1199 } 1218 }
1200} 1219}
1201 1220
1202static int packet_mc_add(struct sock *sk, struct packet_mreq *mreq) 1221static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
1203{ 1222{
1204 struct packet_sock *po = pkt_sk(sk); 1223 struct packet_sock *po = pkt_sk(sk);
1205 struct packet_mclist *ml, *i; 1224 struct packet_mclist *ml, *i;
@@ -1249,7 +1268,7 @@ done:
1249 return err; 1268 return err;
1250} 1269}
1251 1270
1252static int packet_mc_drop(struct sock *sk, struct packet_mreq *mreq) 1271static int packet_mc_drop(struct sock *sk, struct packet_mreq_max *mreq)
1253{ 1272{
1254 struct packet_mclist *ml, **mlp; 1273 struct packet_mclist *ml, **mlp;
1255 1274
@@ -1315,11 +1334,17 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
1315 case PACKET_ADD_MEMBERSHIP: 1334 case PACKET_ADD_MEMBERSHIP:
1316 case PACKET_DROP_MEMBERSHIP: 1335 case PACKET_DROP_MEMBERSHIP:
1317 { 1336 {
1318 struct packet_mreq mreq; 1337 struct packet_mreq_max mreq;
1319 if (optlen<sizeof(mreq)) 1338 int len = optlen;
1339 memset(&mreq, 0, sizeof(mreq));
1340 if (len < sizeof(struct packet_mreq))
1320 return -EINVAL; 1341 return -EINVAL;
1321 if (copy_from_user(&mreq,optval,sizeof(mreq))) 1342 if (len > sizeof(mreq))
1343 len = sizeof(mreq);
1344 if (copy_from_user(&mreq,optval,len))
1322 return -EFAULT; 1345 return -EFAULT;
1346 if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address)))
1347 return -EINVAL;
1323 if (optname == PACKET_ADD_MEMBERSHIP) 1348 if (optname == PACKET_ADD_MEMBERSHIP)
1324 ret = packet_mc_add(sk, &mreq); 1349 ret = packet_mc_add(sk, &mreq);
1325 else 1350 else
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 5acb1680524a..829fdbc4400b 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1472,22 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62
1472static int __init rose_proto_init(void) 1472static int __init rose_proto_init(void)
1473{ 1473{
1474 int i; 1474 int i;
1475 int rc = proto_register(&rose_proto, 0); 1475 int rc;
1476 1476
1477 if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
1478 printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
1479 rc = -EINVAL;
1480 goto out;
1481 }
1482
1483 rc = proto_register(&rose_proto, 0);
1477 if (rc != 0) 1484 if (rc != 0)
1478 goto out; 1485 goto out;
1479 1486
1480 rose_callsign = null_ax25_address; 1487 rose_callsign = null_ax25_address;
1481 1488
1482 if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) {
1483 printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n");
1484 return -1;
1485 }
1486
1487 dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); 1489 dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
1488 if (dev_rose == NULL) { 1490 if (dev_rose == NULL) {
1489 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); 1491 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
1490 return -1; 1492 rc = -ENOMEM;
1493 goto out_proto_unregister;
1491 } 1494 }
1492 1495
1493 memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*)); 1496 memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*));
@@ -1500,10 +1503,12 @@ static int __init rose_proto_init(void)
1500 name, rose_setup); 1503 name, rose_setup);
1501 if (!dev) { 1504 if (!dev) {
1502 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n"); 1505 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n");
1506 rc = -ENOMEM;
1503 goto fail; 1507 goto fail;
1504 } 1508 }
1505 if (register_netdev(dev)) { 1509 rc = register_netdev(dev);
1506 printk(KERN_ERR "ROSE: netdevice regeistration failed\n"); 1510 if (rc) {
1511 printk(KERN_ERR "ROSE: netdevice registration failed\n");
1507 free_netdev(dev); 1512 free_netdev(dev);
1508 goto fail; 1513 goto fail;
1509 } 1514 }
@@ -1536,8 +1541,9 @@ fail:
1536 free_netdev(dev_rose[i]); 1541 free_netdev(dev_rose[i]);
1537 } 1542 }
1538 kfree(dev_rose); 1543 kfree(dev_rose);
1544out_proto_unregister:
1539 proto_unregister(&rose_proto); 1545 proto_unregister(&rose_proto);
1540 return -ENOMEM; 1546 goto out;
1541} 1547}
1542module_init(rose_proto_init); 1548module_init(rose_proto_init);
1543 1549
diff --git a/net/rxrpc/call.c b/net/rxrpc/call.c
index 5cfd4cadee42..c4aeb7d40266 100644
--- a/net/rxrpc/call.c
+++ b/net/rxrpc/call.c
@@ -1923,7 +1923,7 @@ int rxrpc_call_write_data(struct rxrpc_call *call,
1923 size_t sioc, 1923 size_t sioc,
1924 struct kvec *siov, 1924 struct kvec *siov,
1925 u8 rxhdr_flags, 1925 u8 rxhdr_flags,
1926 int alloc_flags, 1926 gfp_t alloc_flags,
1927 int dup_data, 1927 int dup_data,
1928 size_t *size_sent) 1928 size_t *size_sent)
1929{ 1929{
diff --git a/net/rxrpc/connection.c b/net/rxrpc/connection.c
index 61463c74f8cc..2ba14a75dbbe 100644
--- a/net/rxrpc/connection.c
+++ b/net/rxrpc/connection.c
@@ -522,7 +522,7 @@ int rxrpc_conn_newmsg(struct rxrpc_connection *conn,
522 uint8_t type, 522 uint8_t type,
523 int dcount, 523 int dcount,
524 struct kvec diov[], 524 struct kvec diov[],
525 int alloc_flags, 525 gfp_t alloc_flags,
526 struct rxrpc_message **_msg) 526 struct rxrpc_message **_msg)
527{ 527{
528 struct rxrpc_message *msg; 528 struct rxrpc_message *msg;
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 45d3bc0812c8..81510da31792 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -72,9 +72,11 @@ config NET_SCH_CLK_GETTIMEOFDAY
72 Choose this if you need a high resolution clock source but can't use 72 Choose this if you need a high resolution clock source but can't use
73 the CPU's cycle counter. 73 the CPU's cycle counter.
74 74
75# don't allow on SMP x86 because they can have unsynchronized TSCs.
76# gettimeofday is a good alternative
75config NET_SCH_CLK_CPU 77config NET_SCH_CLK_CPU
76 bool "CPU cycle counter" 78 bool "CPU cycle counter"
77 depends on X86_TSC || X86_64 || ALPHA || SPARC64 || PPC64 || IA64 79 depends on ((X86_TSC || X86_64) && !SMP) || ALPHA || SPARC64 || PPC64 || IA64
78 help 80 help
79 Say Y here if you want to use the CPU's cycle counter as clock source. 81 Say Y here if you want to use the CPU's cycle counter as clock source.
80 This is a cheap and high resolution clock source, but on some 82 This is a cheap and high resolution clock source, but on some
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 00eae5f9a01a..cf68a59fdc5a 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -393,10 +393,10 @@ META_COLLECTOR(int_sk_route_caps)
393 dst->value = skb->sk->sk_route_caps; 393 dst->value = skb->sk->sk_route_caps;
394} 394}
395 395
396META_COLLECTOR(int_sk_hashent) 396META_COLLECTOR(int_sk_hash)
397{ 397{
398 SKIP_NONLOCAL(skb); 398 SKIP_NONLOCAL(skb);
399 dst->value = skb->sk->sk_hashent; 399 dst->value = skb->sk->sk_hash;
400} 400}
401 401
402META_COLLECTOR(int_sk_lingertime) 402META_COLLECTOR(int_sk_lingertime)
@@ -515,7 +515,7 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
515 [META_ID(SK_FORWARD_ALLOCS)] = META_FUNC(int_sk_fwd_alloc), 515 [META_ID(SK_FORWARD_ALLOCS)] = META_FUNC(int_sk_fwd_alloc),
516 [META_ID(SK_ALLOCS)] = META_FUNC(int_sk_alloc), 516 [META_ID(SK_ALLOCS)] = META_FUNC(int_sk_alloc),
517 [META_ID(SK_ROUTE_CAPS)] = META_FUNC(int_sk_route_caps), 517 [META_ID(SK_ROUTE_CAPS)] = META_FUNC(int_sk_route_caps),
518 [META_ID(SK_HASHENT)] = META_FUNC(int_sk_hashent), 518 [META_ID(SK_HASH)] = META_FUNC(int_sk_hash),
519 [META_ID(SK_LINGERTIME)] = META_FUNC(int_sk_lingertime), 519 [META_ID(SK_LINGERTIME)] = META_FUNC(int_sk_lingertime),
520 [META_ID(SK_ACK_BACKLOG)] = META_FUNC(int_sk_ack_bl), 520 [META_ID(SK_ACK_BACKLOG)] = META_FUNC(int_sk_ack_bl),
521 [META_ID(SK_MAX_ACK_BACKLOG)] = META_FUNC(int_sk_max_ack_bl), 521 [META_ID(SK_MAX_ACK_BACKLOG)] = META_FUNC(int_sk_max_ack_bl),
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 5b24ae0650d3..12b0f582a66b 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -71,7 +71,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
71 const struct sctp_endpoint *ep, 71 const struct sctp_endpoint *ep,
72 const struct sock *sk, 72 const struct sock *sk,
73 sctp_scope_t scope, 73 sctp_scope_t scope,
74 unsigned int __nocast gfp) 74 gfp_t gfp)
75{ 75{
76 struct sctp_sock *sp; 76 struct sctp_sock *sp;
77 int i; 77 int i;
@@ -273,7 +273,7 @@ fail_init:
273struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep, 273struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep,
274 const struct sock *sk, 274 const struct sock *sk,
275 sctp_scope_t scope, 275 sctp_scope_t scope,
276 unsigned int __nocast gfp) 276 gfp_t gfp)
277{ 277{
278 struct sctp_association *asoc; 278 struct sctp_association *asoc;
279 279
@@ -479,7 +479,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
479/* Add a transport address to an association. */ 479/* Add a transport address to an association. */
480struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, 480struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
481 const union sctp_addr *addr, 481 const union sctp_addr *addr,
482 const unsigned int __nocast gfp, 482 const gfp_t gfp,
483 const int peer_state) 483 const int peer_state)
484{ 484{
485 struct sctp_transport *peer; 485 struct sctp_transport *peer;
@@ -1231,7 +1231,7 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned len)
1231 * local endpoint and the remote peer. 1231 * local endpoint and the remote peer.
1232 */ 1232 */
1233int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, 1233int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc,
1234 unsigned int __nocast gfp) 1234 gfp_t gfp)
1235{ 1235{
1236 sctp_scope_t scope; 1236 sctp_scope_t scope;
1237 int flags; 1237 int flags;
@@ -1254,7 +1254,7 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc,
1254/* Build the association's bind address list from the cookie. */ 1254/* Build the association's bind address list from the cookie. */
1255int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc, 1255int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc,
1256 struct sctp_cookie *cookie, 1256 struct sctp_cookie *cookie,
1257 unsigned int __nocast gfp) 1257 gfp_t gfp)
1258{ 1258{
1259 int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length); 1259 int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length);
1260 int var_size3 = cookie->raw_addr_list_len; 1260 int var_size3 = cookie->raw_addr_list_len;
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index f71549710f2e..2b962627f631 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -53,7 +53,7 @@
53 53
54/* Forward declarations for internal helpers. */ 54/* Forward declarations for internal helpers. */
55static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *, 55static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *,
56 sctp_scope_t scope, unsigned int __nocast gfp, 56 sctp_scope_t scope, gfp_t gfp,
57 int flags); 57 int flags);
58static void sctp_bind_addr_clean(struct sctp_bind_addr *); 58static void sctp_bind_addr_clean(struct sctp_bind_addr *);
59 59
@@ -64,7 +64,7 @@ static void sctp_bind_addr_clean(struct sctp_bind_addr *);
64 */ 64 */
65int sctp_bind_addr_copy(struct sctp_bind_addr *dest, 65int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
66 const struct sctp_bind_addr *src, 66 const struct sctp_bind_addr *src,
67 sctp_scope_t scope, unsigned int __nocast gfp, 67 sctp_scope_t scope, gfp_t gfp,
68 int flags) 68 int flags)
69{ 69{
70 struct sctp_sockaddr_entry *addr; 70 struct sctp_sockaddr_entry *addr;
@@ -146,7 +146,7 @@ void sctp_bind_addr_free(struct sctp_bind_addr *bp)
146 146
147/* Add an address to the bind address list in the SCTP_bind_addr structure. */ 147/* Add an address to the bind address list in the SCTP_bind_addr structure. */
148int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new, 148int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
149 unsigned int __nocast gfp) 149 gfp_t gfp)
150{ 150{
151 struct sctp_sockaddr_entry *addr; 151 struct sctp_sockaddr_entry *addr;
152 152
@@ -200,7 +200,7 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
200 */ 200 */
201union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, 201union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
202 int *addrs_len, 202 int *addrs_len,
203 unsigned int __nocast gfp) 203 gfp_t gfp)
204{ 204{
205 union sctp_params addrparms; 205 union sctp_params addrparms;
206 union sctp_params retval; 206 union sctp_params retval;
@@ -252,7 +252,7 @@ end_raw:
252 * address parameters). 252 * address parameters).
253 */ 253 */
254int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list, 254int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
255 int addrs_len, __u16 port, unsigned int __nocast gfp) 255 int addrs_len, __u16 port, gfp_t gfp)
256{ 256{
257 union sctp_addr_param *rawaddr; 257 union sctp_addr_param *rawaddr;
258 struct sctp_paramhdr *param; 258 struct sctp_paramhdr *param;
@@ -350,7 +350,7 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
350/* Copy out addresses from the global local address list. */ 350/* Copy out addresses from the global local address list. */
351static int sctp_copy_one_addr(struct sctp_bind_addr *dest, 351static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
352 union sctp_addr *addr, 352 union sctp_addr *addr,
353 sctp_scope_t scope, unsigned int __nocast gfp, 353 sctp_scope_t scope, gfp_t gfp,
354 int flags) 354 int flags)
355{ 355{
356 int error = 0; 356 int error = 0;
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 61da2937e641..83ef411772f4 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -62,7 +62,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg)
62} 62}
63 63
64/* Allocate and initialize datamsg. */ 64/* Allocate and initialize datamsg. */
65SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(unsigned int __nocast gfp) 65SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(gfp_t gfp)
66{ 66{
67 struct sctp_datamsg *msg; 67 struct sctp_datamsg *msg;
68 msg = kmalloc(sizeof(struct sctp_datamsg), gfp); 68 msg = kmalloc(sizeof(struct sctp_datamsg), gfp);
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index e22ccd655965..96984f7a2d69 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -68,7 +68,7 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep);
68 */ 68 */
69static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, 69static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
70 struct sock *sk, 70 struct sock *sk,
71 unsigned int __nocast gfp) 71 gfp_t gfp)
72{ 72{
73 struct sctp_sock *sp = sctp_sk(sk); 73 struct sctp_sock *sp = sctp_sk(sk);
74 memset(ep, 0, sizeof(struct sctp_endpoint)); 74 memset(ep, 0, sizeof(struct sctp_endpoint));
@@ -138,8 +138,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
138/* Create a sctp_endpoint with all that boring stuff initialized. 138/* Create a sctp_endpoint with all that boring stuff initialized.
139 * Returns NULL if there isn't enough memory. 139 * Returns NULL if there isn't enough memory.
140 */ 140 */
141struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, 141struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, gfp_t gfp)
142 unsigned int __nocast gfp)
143{ 142{
144 struct sctp_endpoint *ep; 143 struct sctp_endpoint *ep;
145 144
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index e7025be77691..26de4d3e1bd9 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -147,7 +147,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
147 struct sctp_sockaddr_entry *addr; 147 struct sctp_sockaddr_entry *addr;
148 148
149 rcu_read_lock(); 149 rcu_read_lock();
150 if ((in_dev = __in_dev_get(dev)) == NULL) { 150 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
151 rcu_read_unlock(); 151 rcu_read_unlock();
152 return; 152 return;
153 } 153 }
@@ -219,7 +219,7 @@ static void sctp_free_local_addr_list(void)
219 219
220/* Copy the local addresses which are valid for 'scope' into 'bp'. */ 220/* Copy the local addresses which are valid for 'scope' into 'bp'. */
221int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope, 221int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope,
222 unsigned int __nocast gfp, int copy_flags) 222 gfp_t gfp, int copy_flags)
223{ 223{
224 struct sctp_sockaddr_entry *addr; 224 struct sctp_sockaddr_entry *addr;
225 int error = 0; 225 int error = 0;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 3868a8d70cc0..10e82ec2ebd3 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -78,7 +78,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
78static int sctp_process_param(struct sctp_association *asoc, 78static int sctp_process_param(struct sctp_association *asoc,
79 union sctp_params param, 79 union sctp_params param,
80 const union sctp_addr *peer_addr, 80 const union sctp_addr *peer_addr,
81 unsigned int __nocast gfp); 81 gfp_t gfp);
82 82
83/* What was the inbound interface for this chunk? */ 83/* What was the inbound interface for this chunk? */
84int sctp_chunk_iif(const struct sctp_chunk *chunk) 84int sctp_chunk_iif(const struct sctp_chunk *chunk)
@@ -174,7 +174,7 @@ void sctp_init_cause(struct sctp_chunk *chunk, __u16 cause_code,
174 */ 174 */
175struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, 175struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
176 const struct sctp_bind_addr *bp, 176 const struct sctp_bind_addr *bp,
177 unsigned int __nocast gfp, int vparam_len) 177 gfp_t gfp, int vparam_len)
178{ 178{
179 sctp_inithdr_t init; 179 sctp_inithdr_t init;
180 union sctp_params addrs; 180 union sctp_params addrs;
@@ -261,7 +261,7 @@ nodata:
261 261
262struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, 262struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
263 const struct sctp_chunk *chunk, 263 const struct sctp_chunk *chunk,
264 unsigned int __nocast gfp, int unkparam_len) 264 gfp_t gfp, int unkparam_len)
265{ 265{
266 sctp_inithdr_t initack; 266 sctp_inithdr_t initack;
267 struct sctp_chunk *retval; 267 struct sctp_chunk *retval;
@@ -1234,7 +1234,7 @@ void sctp_chunk_assign_tsn(struct sctp_chunk *chunk)
1234/* Create a CLOSED association to use with an incoming packet. */ 1234/* Create a CLOSED association to use with an incoming packet. */
1235struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep, 1235struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep,
1236 struct sctp_chunk *chunk, 1236 struct sctp_chunk *chunk,
1237 unsigned int __nocast gfp) 1237 gfp_t gfp)
1238{ 1238{
1239 struct sctp_association *asoc; 1239 struct sctp_association *asoc;
1240 struct sk_buff *skb; 1240 struct sk_buff *skb;
@@ -1349,7 +1349,7 @@ nodata:
1349struct sctp_association *sctp_unpack_cookie( 1349struct sctp_association *sctp_unpack_cookie(
1350 const struct sctp_endpoint *ep, 1350 const struct sctp_endpoint *ep,
1351 const struct sctp_association *asoc, 1351 const struct sctp_association *asoc,
1352 struct sctp_chunk *chunk, unsigned int __nocast gfp, 1352 struct sctp_chunk *chunk, gfp_t gfp,
1353 int *error, struct sctp_chunk **errp) 1353 int *error, struct sctp_chunk **errp)
1354{ 1354{
1355 struct sctp_association *retval = NULL; 1355 struct sctp_association *retval = NULL;
@@ -1814,7 +1814,7 @@ int sctp_verify_init(const struct sctp_association *asoc,
1814 */ 1814 */
1815int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, 1815int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1816 const union sctp_addr *peer_addr, 1816 const union sctp_addr *peer_addr,
1817 sctp_init_chunk_t *peer_init, unsigned int __nocast gfp) 1817 sctp_init_chunk_t *peer_init, gfp_t gfp)
1818{ 1818{
1819 union sctp_params param; 1819 union sctp_params param;
1820 struct sctp_transport *transport; 1820 struct sctp_transport *transport;
@@ -1985,7 +1985,7 @@ nomem:
1985static int sctp_process_param(struct sctp_association *asoc, 1985static int sctp_process_param(struct sctp_association *asoc,
1986 union sctp_params param, 1986 union sctp_params param,
1987 const union sctp_addr *peer_addr, 1987 const union sctp_addr *peer_addr,
1988 unsigned int __nocast gfp) 1988 gfp_t gfp)
1989{ 1989{
1990 union sctp_addr addr; 1990 union sctp_addr addr;
1991 int i; 1991 int i;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 39c970b5b198..f84173ea8ec1 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -63,7 +63,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
63 void *event_arg, 63 void *event_arg,
64 sctp_disposition_t status, 64 sctp_disposition_t status,
65 sctp_cmd_seq_t *commands, 65 sctp_cmd_seq_t *commands,
66 unsigned int __nocast gfp); 66 gfp_t gfp);
67static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype, 67static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
68 sctp_state_t state, 68 sctp_state_t state,
69 struct sctp_endpoint *ep, 69 struct sctp_endpoint *ep,
@@ -71,7 +71,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
71 void *event_arg, 71 void *event_arg,
72 sctp_disposition_t status, 72 sctp_disposition_t status,
73 sctp_cmd_seq_t *commands, 73 sctp_cmd_seq_t *commands,
74 unsigned int __nocast gfp); 74 gfp_t gfp);
75 75
76/******************************************************************** 76/********************************************************************
77 * Helper functions 77 * Helper functions
@@ -498,7 +498,7 @@ static int sctp_cmd_process_init(sctp_cmd_seq_t *commands,
498 struct sctp_association *asoc, 498 struct sctp_association *asoc,
499 struct sctp_chunk *chunk, 499 struct sctp_chunk *chunk,
500 sctp_init_chunk_t *peer_init, 500 sctp_init_chunk_t *peer_init,
501 unsigned int __nocast gfp) 501 gfp_t gfp)
502{ 502{
503 int error; 503 int error;
504 504
@@ -853,7 +853,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype,
853 struct sctp_endpoint *ep, 853 struct sctp_endpoint *ep,
854 struct sctp_association *asoc, 854 struct sctp_association *asoc,
855 void *event_arg, 855 void *event_arg,
856 unsigned int __nocast gfp) 856 gfp_t gfp)
857{ 857{
858 sctp_cmd_seq_t commands; 858 sctp_cmd_seq_t commands;
859 const sctp_sm_table_entry_t *state_fn; 859 const sctp_sm_table_entry_t *state_fn;
@@ -898,7 +898,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
898 void *event_arg, 898 void *event_arg,
899 sctp_disposition_t status, 899 sctp_disposition_t status,
900 sctp_cmd_seq_t *commands, 900 sctp_cmd_seq_t *commands,
901 unsigned int __nocast gfp) 901 gfp_t gfp)
902{ 902{
903 int error; 903 int error;
904 904
@@ -986,7 +986,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
986 void *event_arg, 986 void *event_arg,
987 sctp_disposition_t status, 987 sctp_disposition_t status,
988 sctp_cmd_seq_t *commands, 988 sctp_cmd_seq_t *commands,
989 unsigned int __nocast gfp) 989 gfp_t gfp)
990{ 990{
991 int error = 0; 991 int error = 0;
992 int force; 992 int force;
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 86073df418f5..505c7de10c50 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -2414,6 +2414,17 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep,
2414 skb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t)); 2414 skb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t));
2415 chunk->subh.shutdown_hdr = sdh; 2415 chunk->subh.shutdown_hdr = sdh;
2416 2416
2417 /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT
2418 * When a peer sends a SHUTDOWN, SCTP delivers this notification to
2419 * inform the application that it should cease sending data.
2420 */
2421 ev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC);
2422 if (!ev) {
2423 disposition = SCTP_DISPOSITION_NOMEM;
2424 goto out;
2425 }
2426 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
2427
2417 /* Upon the reception of the SHUTDOWN, the peer endpoint shall 2428 /* Upon the reception of the SHUTDOWN, the peer endpoint shall
2418 * - enter the SHUTDOWN-RECEIVED state, 2429 * - enter the SHUTDOWN-RECEIVED state,
2419 * - stop accepting new data from its SCTP user 2430 * - stop accepting new data from its SCTP user
@@ -2439,17 +2450,6 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep,
2439 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN, 2450 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN,
2440 SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack)); 2451 SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack));
2441 2452
2442 /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT
2443 * When a peer sends a SHUTDOWN, SCTP delivers this notification to
2444 * inform the application that it should cease sending data.
2445 */
2446 ev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC);
2447 if (!ev) {
2448 disposition = SCTP_DISPOSITION_NOMEM;
2449 goto out;
2450 }
2451 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
2452
2453out: 2453out:
2454 return disposition; 2454 return disposition;
2455} 2455}
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 91ec8c936913..02e068d3450d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3159,8 +3159,9 @@ static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval
3159 return 0; 3159 return 0;
3160} 3160}
3161 3161
3162static int sctp_getsockopt_peer_addrs_num(struct sock *sk, int len, 3162static int sctp_getsockopt_peer_addrs_num_old(struct sock *sk, int len,
3163 char __user *optval, int __user *optlen) 3163 char __user *optval,
3164 int __user *optlen)
3164{ 3165{
3165 sctp_assoc_t id; 3166 sctp_assoc_t id;
3166 struct sctp_association *asoc; 3167 struct sctp_association *asoc;
@@ -3185,23 +3186,28 @@ static int sctp_getsockopt_peer_addrs_num(struct sock *sk, int len,
3185 return cnt; 3186 return cnt;
3186} 3187}
3187 3188
3188static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, 3189/*
3189 char __user *optval, int __user *optlen) 3190 * Old API for getting list of peer addresses. Does not work for 32-bit
3191 * programs running on a 64-bit kernel
3192 */
3193static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
3194 char __user *optval,
3195 int __user *optlen)
3190{ 3196{
3191 struct sctp_association *asoc; 3197 struct sctp_association *asoc;
3192 struct list_head *pos; 3198 struct list_head *pos;
3193 int cnt = 0; 3199 int cnt = 0;
3194 struct sctp_getaddrs getaddrs; 3200 struct sctp_getaddrs_old getaddrs;
3195 struct sctp_transport *from; 3201 struct sctp_transport *from;
3196 void __user *to; 3202 void __user *to;
3197 union sctp_addr temp; 3203 union sctp_addr temp;
3198 struct sctp_sock *sp = sctp_sk(sk); 3204 struct sctp_sock *sp = sctp_sk(sk);
3199 int addrlen; 3205 int addrlen;
3200 3206
3201 if (len != sizeof(struct sctp_getaddrs)) 3207 if (len != sizeof(struct sctp_getaddrs_old))
3202 return -EINVAL; 3208 return -EINVAL;
3203 3209
3204 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) 3210 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old)))
3205 return -EFAULT; 3211 return -EFAULT;
3206 3212
3207 if (getaddrs.addr_num <= 0) return -EINVAL; 3213 if (getaddrs.addr_num <= 0) return -EINVAL;
@@ -3225,15 +3231,69 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
3225 if (cnt >= getaddrs.addr_num) break; 3231 if (cnt >= getaddrs.addr_num) break;
3226 } 3232 }
3227 getaddrs.addr_num = cnt; 3233 getaddrs.addr_num = cnt;
3228 if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs))) 3234 if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old)))
3235 return -EFAULT;
3236
3237 return 0;
3238}
3239
3240static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
3241 char __user *optval, int __user *optlen)
3242{
3243 struct sctp_association *asoc;
3244 struct list_head *pos;
3245 int cnt = 0;
3246 struct sctp_getaddrs getaddrs;
3247 struct sctp_transport *from;
3248 void __user *to;
3249 union sctp_addr temp;
3250 struct sctp_sock *sp = sctp_sk(sk);
3251 int addrlen;
3252 size_t space_left;
3253 int bytes_copied;
3254
3255 if (len < sizeof(struct sctp_getaddrs))
3256 return -EINVAL;
3257
3258 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs)))
3259 return -EFAULT;
3260
3261 /* For UDP-style sockets, id specifies the association to query. */
3262 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
3263 if (!asoc)
3264 return -EINVAL;
3265
3266 to = optval + offsetof(struct sctp_getaddrs,addrs);
3267 space_left = len - sizeof(struct sctp_getaddrs) -
3268 offsetof(struct sctp_getaddrs,addrs);
3269
3270 list_for_each(pos, &asoc->peer.transport_addr_list) {
3271 from = list_entry(pos, struct sctp_transport, transports);
3272 memcpy(&temp, &from->ipaddr, sizeof(temp));
3273 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
3274 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
3275 if(space_left < addrlen)
3276 return -ENOMEM;
3277 temp.v4.sin_port = htons(temp.v4.sin_port);
3278 if (copy_to_user(to, &temp, addrlen))
3279 return -EFAULT;
3280 to += addrlen;
3281 cnt++;
3282 space_left -= addrlen;
3283 }
3284
3285 if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num))
3286 return -EFAULT;
3287 bytes_copied = ((char __user *)to) - optval;
3288 if (put_user(bytes_copied, optlen))
3229 return -EFAULT; 3289 return -EFAULT;
3230 3290
3231 return 0; 3291 return 0;
3232} 3292}
3233 3293
3234static int sctp_getsockopt_local_addrs_num(struct sock *sk, int len, 3294static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
3235 char __user *optval, 3295 char __user *optval,
3236 int __user *optlen) 3296 int __user *optlen)
3237{ 3297{
3238 sctp_assoc_t id; 3298 sctp_assoc_t id;
3239 struct sctp_bind_addr *bp; 3299 struct sctp_bind_addr *bp;
@@ -3306,8 +3366,8 @@ done:
3306/* Helper function that copies local addresses to user and returns the number 3366/* Helper function that copies local addresses to user and returns the number
3307 * of addresses copied. 3367 * of addresses copied.
3308 */ 3368 */
3309static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, int max_addrs, 3369static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_addrs,
3310 void __user *to) 3370 void __user *to)
3311{ 3371{
3312 struct list_head *pos; 3372 struct list_head *pos;
3313 struct sctp_sockaddr_entry *addr; 3373 struct sctp_sockaddr_entry *addr;
@@ -3341,14 +3401,54 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, int max_addrs,
3341 return cnt; 3401 return cnt;
3342} 3402}
3343 3403
3344static int sctp_getsockopt_local_addrs(struct sock *sk, int len, 3404static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port,
3345 char __user *optval, int __user *optlen) 3405 void * __user *to, size_t space_left)
3406{
3407 struct list_head *pos;
3408 struct sctp_sockaddr_entry *addr;
3409 unsigned long flags;
3410 union sctp_addr temp;
3411 int cnt = 0;
3412 int addrlen;
3413
3414 sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
3415 list_for_each(pos, &sctp_local_addr_list) {
3416 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
3417 if ((PF_INET == sk->sk_family) &&
3418 (AF_INET6 == addr->a.sa.sa_family))
3419 continue;
3420 memcpy(&temp, &addr->a, sizeof(temp));
3421 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
3422 &temp);
3423 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
3424 if(space_left<addrlen)
3425 return -ENOMEM;
3426 temp.v4.sin_port = htons(port);
3427 if (copy_to_user(*to, &temp, addrlen)) {
3428 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
3429 flags);
3430 return -EFAULT;
3431 }
3432 *to += addrlen;
3433 cnt ++;
3434 space_left -= addrlen;
3435 }
3436 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
3437
3438 return cnt;
3439}
3440
3441/* Old API for getting list of local addresses. Does not work for 32-bit
3442 * programs running on a 64-bit kernel
3443 */
3444static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
3445 char __user *optval, int __user *optlen)
3346{ 3446{
3347 struct sctp_bind_addr *bp; 3447 struct sctp_bind_addr *bp;
3348 struct sctp_association *asoc; 3448 struct sctp_association *asoc;
3349 struct list_head *pos; 3449 struct list_head *pos;
3350 int cnt = 0; 3450 int cnt = 0;
3351 struct sctp_getaddrs getaddrs; 3451 struct sctp_getaddrs_old getaddrs;
3352 struct sctp_sockaddr_entry *addr; 3452 struct sctp_sockaddr_entry *addr;
3353 void __user *to; 3453 void __user *to;
3354 union sctp_addr temp; 3454 union sctp_addr temp;
@@ -3357,10 +3457,10 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
3357 rwlock_t *addr_lock; 3457 rwlock_t *addr_lock;
3358 int err = 0; 3458 int err = 0;
3359 3459
3360 if (len != sizeof(struct sctp_getaddrs)) 3460 if (len != sizeof(struct sctp_getaddrs_old))
3361 return -EINVAL; 3461 return -EINVAL;
3362 3462
3363 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) 3463 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old)))
3364 return -EFAULT; 3464 return -EFAULT;
3365 3465
3366 if (getaddrs.addr_num <= 0) return -EINVAL; 3466 if (getaddrs.addr_num <= 0) return -EINVAL;
@@ -3392,8 +3492,9 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
3392 addr = list_entry(bp->address_list.next, 3492 addr = list_entry(bp->address_list.next,
3393 struct sctp_sockaddr_entry, list); 3493 struct sctp_sockaddr_entry, list);
3394 if (sctp_is_any(&addr->a)) { 3494 if (sctp_is_any(&addr->a)) {
3395 cnt = sctp_copy_laddrs_to_user(sk, bp->port, 3495 cnt = sctp_copy_laddrs_to_user_old(sk, bp->port,
3396 getaddrs.addr_num, to); 3496 getaddrs.addr_num,
3497 to);
3397 if (cnt < 0) { 3498 if (cnt < 0) {
3398 err = cnt; 3499 err = cnt;
3399 goto unlock; 3500 goto unlock;
@@ -3419,7 +3520,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
3419 3520
3420copy_getaddrs: 3521copy_getaddrs:
3421 getaddrs.addr_num = cnt; 3522 getaddrs.addr_num = cnt;
3422 if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs))) 3523 if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old)))
3423 err = -EFAULT; 3524 err = -EFAULT;
3424 3525
3425unlock: 3526unlock:
@@ -3427,6 +3528,99 @@ unlock:
3427 return err; 3528 return err;
3428} 3529}
3429 3530
3531static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
3532 char __user *optval, int __user *optlen)
3533{
3534 struct sctp_bind_addr *bp;
3535 struct sctp_association *asoc;
3536 struct list_head *pos;
3537 int cnt = 0;
3538 struct sctp_getaddrs getaddrs;
3539 struct sctp_sockaddr_entry *addr;
3540 void __user *to;
3541 union sctp_addr temp;
3542 struct sctp_sock *sp = sctp_sk(sk);
3543 int addrlen;
3544 rwlock_t *addr_lock;
3545 int err = 0;
3546 size_t space_left;
3547 int bytes_copied;
3548
3549 if (len <= sizeof(struct sctp_getaddrs))
3550 return -EINVAL;
3551
3552 if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs)))
3553 return -EFAULT;
3554
3555 /*
3556 * For UDP-style sockets, id specifies the association to query.
3557 * If the id field is set to the value '0' then the locally bound
3558 * addresses are returned without regard to any particular
3559 * association.
3560 */
3561 if (0 == getaddrs.assoc_id) {
3562 bp = &sctp_sk(sk)->ep->base.bind_addr;
3563 addr_lock = &sctp_sk(sk)->ep->base.addr_lock;
3564 } else {
3565 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
3566 if (!asoc)
3567 return -EINVAL;
3568 bp = &asoc->base.bind_addr;
3569 addr_lock = &asoc->base.addr_lock;
3570 }
3571
3572 to = optval + offsetof(struct sctp_getaddrs,addrs);
3573 space_left = len - sizeof(struct sctp_getaddrs) -
3574 offsetof(struct sctp_getaddrs,addrs);
3575
3576 sctp_read_lock(addr_lock);
3577
3578 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid
3579 * addresses from the global local address list.
3580 */
3581 if (sctp_list_single_entry(&bp->address_list)) {
3582 addr = list_entry(bp->address_list.next,
3583 struct sctp_sockaddr_entry, list);
3584 if (sctp_is_any(&addr->a)) {
3585 cnt = sctp_copy_laddrs_to_user(sk, bp->port,
3586 &to, space_left);
3587 if (cnt < 0) {
3588 err = cnt;
3589 goto unlock;
3590 }
3591 goto copy_getaddrs;
3592 }
3593 }
3594
3595 list_for_each(pos, &bp->address_list) {
3596 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
3597 memcpy(&temp, &addr->a, sizeof(temp));
3598 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
3599 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
3600 if(space_left < addrlen)
3601 return -ENOMEM; /*fixme: right error?*/
3602 temp.v4.sin_port = htons(temp.v4.sin_port);
3603 if (copy_to_user(to, &temp, addrlen)) {
3604 err = -EFAULT;
3605 goto unlock;
3606 }
3607 to += addrlen;
3608 cnt ++;
3609 space_left -= addrlen;
3610 }
3611
3612copy_getaddrs:
3613 if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num))
3614 return -EFAULT;
3615 bytes_copied = ((char __user *)to) - optval;
3616 if (put_user(bytes_copied, optlen))
3617 return -EFAULT;
3618
3619unlock:
3620 sctp_read_unlock(addr_lock);
3621 return err;
3622}
3623
3430/* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR) 3624/* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
3431 * 3625 *
3432 * Requests that the local SCTP stack use the enclosed peer address as 3626 * Requests that the local SCTP stack use the enclosed peer address as
@@ -3807,12 +4001,20 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
3807 case SCTP_INITMSG: 4001 case SCTP_INITMSG:
3808 retval = sctp_getsockopt_initmsg(sk, len, optval, optlen); 4002 retval = sctp_getsockopt_initmsg(sk, len, optval, optlen);
3809 break; 4003 break;
3810 case SCTP_GET_PEER_ADDRS_NUM: 4004 case SCTP_GET_PEER_ADDRS_NUM_OLD:
3811 retval = sctp_getsockopt_peer_addrs_num(sk, len, optval, 4005 retval = sctp_getsockopt_peer_addrs_num_old(sk, len, optval,
4006 optlen);
4007 break;
4008 case SCTP_GET_LOCAL_ADDRS_NUM_OLD:
4009 retval = sctp_getsockopt_local_addrs_num_old(sk, len, optval,
4010 optlen);
4011 break;
4012 case SCTP_GET_PEER_ADDRS_OLD:
4013 retval = sctp_getsockopt_peer_addrs_old(sk, len, optval,
3812 optlen); 4014 optlen);
3813 break; 4015 break;
3814 case SCTP_GET_LOCAL_ADDRS_NUM: 4016 case SCTP_GET_LOCAL_ADDRS_OLD:
3815 retval = sctp_getsockopt_local_addrs_num(sk, len, optval, 4017 retval = sctp_getsockopt_local_addrs_old(sk, len, optval,
3816 optlen); 4018 optlen);
3817 break; 4019 break;
3818 case SCTP_GET_PEER_ADDRS: 4020 case SCTP_GET_PEER_ADDRS:
diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
index 25037daf3fa0..cbe2513d2822 100644
--- a/net/sctp/ssnmap.c
+++ b/net/sctp/ssnmap.c
@@ -58,7 +58,7 @@ static inline size_t sctp_ssnmap_size(__u16 in, __u16 out)
58 * Allocate room to store at least 'len' contiguous TSNs. 58 * Allocate room to store at least 'len' contiguous TSNs.
59 */ 59 */
60struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, 60struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
61 unsigned int __nocast gfp) 61 gfp_t gfp)
62{ 62{
63 struct sctp_ssnmap *retval; 63 struct sctp_ssnmap *retval;
64 int size; 64 int size;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index d2f04ebe5081..6bc27200e6ca 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -57,7 +57,7 @@
57/* Initialize a new transport from provided memory. */ 57/* Initialize a new transport from provided memory. */
58static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, 58static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
59 const union sctp_addr *addr, 59 const union sctp_addr *addr,
60 unsigned int __nocast gfp) 60 gfp_t gfp)
61{ 61{
62 /* Copy in the address. */ 62 /* Copy in the address. */
63 peer->ipaddr = *addr; 63 peer->ipaddr = *addr;
@@ -122,7 +122,7 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
122 122
123/* Allocate and initialize a new transport. */ 123/* Allocate and initialize a new transport. */
124struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, 124struct sctp_transport *sctp_transport_new(const union sctp_addr *addr,
125 unsigned int __nocast gfp) 125 gfp_t gfp)
126{ 126{
127 struct sctp_transport *transport; 127 struct sctp_transport *transport;
128 128
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 0abd5101107c..057e7fac3af0 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -74,7 +74,7 @@ SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, int msg_flags)
74 74
75/* Create a new sctp_ulpevent. */ 75/* Create a new sctp_ulpevent. */
76SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags, 76SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags,
77 unsigned int __nocast gfp) 77 gfp_t gfp)
78{ 78{
79 struct sctp_ulpevent *event; 79 struct sctp_ulpevent *event;
80 struct sk_buff *skb; 80 struct sk_buff *skb;
@@ -136,7 +136,7 @@ static inline void sctp_ulpevent_release_owner(struct sctp_ulpevent *event)
136struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( 136struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
137 const struct sctp_association *asoc, 137 const struct sctp_association *asoc,
138 __u16 flags, __u16 state, __u16 error, __u16 outbound, 138 __u16 flags, __u16 state, __u16 error, __u16 outbound,
139 __u16 inbound, unsigned int __nocast gfp) 139 __u16 inbound, gfp_t gfp)
140{ 140{
141 struct sctp_ulpevent *event; 141 struct sctp_ulpevent *event;
142 struct sctp_assoc_change *sac; 142 struct sctp_assoc_change *sac;
@@ -237,7 +237,7 @@ fail:
237struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( 237struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
238 const struct sctp_association *asoc, 238 const struct sctp_association *asoc,
239 const struct sockaddr_storage *aaddr, 239 const struct sockaddr_storage *aaddr,
240 int flags, int state, int error, unsigned int __nocast gfp) 240 int flags, int state, int error, gfp_t gfp)
241{ 241{
242 struct sctp_ulpevent *event; 242 struct sctp_ulpevent *event;
243 struct sctp_paddr_change *spc; 243 struct sctp_paddr_change *spc;
@@ -350,7 +350,7 @@ fail:
350 */ 350 */
351struct sctp_ulpevent *sctp_ulpevent_make_remote_error( 351struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
352 const struct sctp_association *asoc, struct sctp_chunk *chunk, 352 const struct sctp_association *asoc, struct sctp_chunk *chunk,
353 __u16 flags, unsigned int __nocast gfp) 353 __u16 flags, gfp_t gfp)
354{ 354{
355 struct sctp_ulpevent *event; 355 struct sctp_ulpevent *event;
356 struct sctp_remote_error *sre; 356 struct sctp_remote_error *sre;
@@ -448,7 +448,7 @@ fail:
448 */ 448 */
449struct sctp_ulpevent *sctp_ulpevent_make_send_failed( 449struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
450 const struct sctp_association *asoc, struct sctp_chunk *chunk, 450 const struct sctp_association *asoc, struct sctp_chunk *chunk,
451 __u16 flags, __u32 error, unsigned int __nocast gfp) 451 __u16 flags, __u32 error, gfp_t gfp)
452{ 452{
453 struct sctp_ulpevent *event; 453 struct sctp_ulpevent *event;
454 struct sctp_send_failed *ssf; 454 struct sctp_send_failed *ssf;
@@ -557,7 +557,7 @@ fail:
557 */ 557 */
558struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( 558struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
559 const struct sctp_association *asoc, 559 const struct sctp_association *asoc,
560 __u16 flags, unsigned int __nocast gfp) 560 __u16 flags, gfp_t gfp)
561{ 561{
562 struct sctp_ulpevent *event; 562 struct sctp_ulpevent *event;
563 struct sctp_shutdown_event *sse; 563 struct sctp_shutdown_event *sse;
@@ -620,7 +620,7 @@ fail:
620 * 5.3.1.6 SCTP_ADAPTION_INDICATION 620 * 5.3.1.6 SCTP_ADAPTION_INDICATION
621 */ 621 */
622struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( 622struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
623 const struct sctp_association *asoc, unsigned int __nocast gfp) 623 const struct sctp_association *asoc, gfp_t gfp)
624{ 624{
625 struct sctp_ulpevent *event; 625 struct sctp_ulpevent *event;
626 struct sctp_adaption_event *sai; 626 struct sctp_adaption_event *sai;
@@ -657,7 +657,7 @@ fail:
657 */ 657 */
658struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, 658struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
659 struct sctp_chunk *chunk, 659 struct sctp_chunk *chunk,
660 unsigned int __nocast gfp) 660 gfp_t gfp)
661{ 661{
662 struct sctp_ulpevent *event = NULL; 662 struct sctp_ulpevent *event = NULL;
663 struct sk_buff *skb; 663 struct sk_buff *skb;
@@ -719,7 +719,7 @@ fail:
719 */ 719 */
720struct sctp_ulpevent *sctp_ulpevent_make_pdapi( 720struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
721 const struct sctp_association *asoc, __u32 indication, 721 const struct sctp_association *asoc, __u32 indication,
722 unsigned int __nocast gfp) 722 gfp_t gfp)
723{ 723{
724 struct sctp_ulpevent *event; 724 struct sctp_ulpevent *event;
725 struct sctp_pdapi_event *pd; 725 struct sctp_pdapi_event *pd;
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index ec2c857eae7f..2080b2d28c98 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -100,7 +100,7 @@ void sctp_ulpq_free(struct sctp_ulpq *ulpq)
100 100
101/* Process an incoming DATA chunk. */ 101/* Process an incoming DATA chunk. */
102int sctp_ulpq_tail_data(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, 102int sctp_ulpq_tail_data(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
103 unsigned int __nocast gfp) 103 gfp_t gfp)
104{ 104{
105 struct sk_buff_head temp; 105 struct sk_buff_head temp;
106 sctp_data_chunk_t *hdr; 106 sctp_data_chunk_t *hdr;
@@ -792,7 +792,7 @@ static __u16 sctp_ulpq_renege_frags(struct sctp_ulpq *ulpq, __u16 needed)
792/* Partial deliver the first message as there is pressure on rwnd. */ 792/* Partial deliver the first message as there is pressure on rwnd. */
793void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq, 793void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq,
794 struct sctp_chunk *chunk, 794 struct sctp_chunk *chunk,
795 unsigned int __nocast gfp) 795 gfp_t gfp)
796{ 796{
797 struct sctp_ulpevent *event; 797 struct sctp_ulpevent *event;
798 struct sctp_association *asoc; 798 struct sctp_association *asoc;
@@ -816,7 +816,7 @@ void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq,
816 816
817/* Renege some packets to make room for an incoming chunk. */ 817/* Renege some packets to make room for an incoming chunk. */
818void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, 818void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
819 unsigned int __nocast gfp) 819 gfp_t gfp)
820{ 820{
821 struct sctp_association *asoc; 821 struct sctp_association *asoc;
822 __u16 needed, freed; 822 __u16 needed, freed;
@@ -855,7 +855,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
855/* Notify the application if an association is aborted and in 855/* Notify the application if an association is aborted and in
856 * partial delivery mode. Send up any pending received messages. 856 * partial delivery mode. Send up any pending received messages.
857 */ 857 */
858void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, unsigned int __nocast gfp) 858void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, gfp_t gfp)
859{ 859{
860 struct sctp_ulpevent *ev = NULL; 860 struct sctp_ulpevent *ev = NULL;
861 struct sock *sk; 861 struct sock *sk;
diff --git a/net/socket.c b/net/socket.c
index c699e93c33d7..3145103cdf54 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1145,8 +1145,11 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
1145 if (!try_module_get(net_families[family]->owner)) 1145 if (!try_module_get(net_families[family]->owner))
1146 goto out_release; 1146 goto out_release;
1147 1147
1148 if ((err = net_families[family]->create(sock, protocol)) < 0) 1148 if ((err = net_families[family]->create(sock, protocol)) < 0) {
1149 sock->ops = NULL;
1149 goto out_module_put; 1150 goto out_module_put;
1151 }
1152
1150 /* 1153 /*
1151 * Now to bump the refcnt of the [loadable] module that owns this 1154 * Now to bump the refcnt of the [loadable] module that owns this
1152 * socket at sock_release time we decrement its refcnt. 1155 * socket at sock_release time we decrement its refcnt.
@@ -1360,16 +1363,16 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _
1360 newsock->type = sock->type; 1363 newsock->type = sock->type;
1361 newsock->ops = sock->ops; 1364 newsock->ops = sock->ops;
1362 1365
1363 err = security_socket_accept(sock, newsock);
1364 if (err)
1365 goto out_release;
1366
1367 /* 1366 /*
1368 * We don't need try_module_get here, as the listening socket (sock) 1367 * We don't need try_module_get here, as the listening socket (sock)
1369 * has the protocol module (sock->ops->owner) held. 1368 * has the protocol module (sock->ops->owner) held.
1370 */ 1369 */
1371 __module_get(newsock->ops->owner); 1370 __module_get(newsock->ops->owner);
1372 1371
1372 err = security_socket_accept(sock, newsock);
1373 if (err)
1374 goto out_release;
1375
1373 err = sock->ops->accept(sock, newsock, sock->file->f_flags); 1376 err = sock->ops->accept(sock, newsock, sock->file->f_flags);
1374 if (err < 0) 1377 if (err < 0)
1375 goto out_release; 1378 goto out_release;
@@ -1700,7 +1703,9 @@ asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags)
1700 struct socket *sock; 1703 struct socket *sock;
1701 char address[MAX_SOCK_ADDR]; 1704 char address[MAX_SOCK_ADDR];
1702 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; 1705 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
1703 unsigned char ctl[sizeof(struct cmsghdr) + 20]; /* 20 is size of ipv6_pktinfo */ 1706 unsigned char ctl[sizeof(struct cmsghdr) + 20]
1707 __attribute__ ((aligned (sizeof(__kernel_size_t))));
1708 /* 20 is size of ipv6_pktinfo */
1704 unsigned char *ctl_buf = ctl; 1709 unsigned char *ctl_buf = ctl;
1705 struct msghdr msg_sys; 1710 struct msghdr msg_sys;
1706 int err, ctl_len, iov_size, total_len; 1711 int err, ctl_len, iov_size, total_len;
@@ -1862,7 +1867,8 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, unsigned int flag
1862 if (err < 0) 1867 if (err < 0)
1863 goto out_freeiov; 1868 goto out_freeiov;
1864 } 1869 }
1865 err = __put_user(msg_sys.msg_flags, COMPAT_FLAGS(msg)); 1870 err = __put_user((msg_sys.msg_flags & ~MSG_CMSG_COMPAT),
1871 COMPAT_FLAGS(msg));
1866 if (err) 1872 if (err)
1867 goto out_freeiov; 1873 goto out_freeiov;
1868 if (MSG_CMSG_COMPAT & flags) 1874 if (MSG_CMSG_COMPAT & flags)
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index f3104035e35d..54e60a657500 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -719,7 +719,7 @@ static void rpc_async_schedule(void *arg)
719void * 719void *
720rpc_malloc(struct rpc_task *task, size_t size) 720rpc_malloc(struct rpc_task *task, size_t size)
721{ 721{
722 int gfp; 722 gfp_t gfp;
723 723
724 if (task->tk_flags & RPC_TASK_SWAPPER) 724 if (task->tk_flags & RPC_TASK_SWAPPER)
725 gfp = GFP_ATOMIC; 725 gfp = GFP_ATOMIC;
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 30ec3efc48a6..691dea4a58e7 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -587,7 +587,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
587 struct timeval tv; 587 struct timeval tv;
588 588
589 tv.tv_sec = xtime.tv_sec; 589 tv.tv_sec = xtime.tv_sec;
590 tv.tv_usec = xtime.tv_nsec * 1000; 590 tv.tv_usec = xtime.tv_nsec / NSEC_PER_USEC;
591 skb_set_timestamp(skb, &tv); 591 skb_set_timestamp(skb, &tv);
592 /* Don't enable netstamp, sunrpc doesn't 592 /* Don't enable netstamp, sunrpc doesn't
593 need that much accuracy */ 593 need that much accuracy */
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index c5241fcbb966..55538f6b60ff 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -16,6 +16,8 @@
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/sysctl.h> 17#include <linux/sysctl.h>
18 18
19#include <net/sock.h>
20
19#ifdef CONFIG_INET 21#ifdef CONFIG_INET
20#include <net/ip.h> 22#include <net/ip.h>
21#endif 23#endif
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index fda737d77edc..cbb0ba34a600 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -163,7 +163,7 @@ static void xfrm_policy_timer(unsigned long data)
163 if (xp->dead) 163 if (xp->dead)
164 goto out; 164 goto out;
165 165
166 dir = xp->index & 7; 166 dir = xfrm_policy_id2dir(xp->index);
167 167
168 if (xp->lft.hard_add_expires_seconds) { 168 if (xp->lft.hard_add_expires_seconds) {
169 long tmo = xp->lft.hard_add_expires_seconds + 169 long tmo = xp->lft.hard_add_expires_seconds +
@@ -225,7 +225,7 @@ expired:
225 * SPD calls. 225 * SPD calls.
226 */ 226 */
227 227
228struct xfrm_policy *xfrm_policy_alloc(int gfp) 228struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp)
229{ 229{
230 struct xfrm_policy *policy; 230 struct xfrm_policy *policy;
231 231
@@ -417,7 +417,7 @@ struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete)
417 struct xfrm_policy *pol, **p; 417 struct xfrm_policy *pol, **p;
418 418
419 write_lock_bh(&xfrm_policy_lock); 419 write_lock_bh(&xfrm_policy_lock);
420 for (p = &xfrm_policy_list[id & 7]; (pol=*p)!=NULL; p = &pol->next) { 420 for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) {
421 if (pol->index == id) { 421 if (pol->index == id) {
422 xfrm_pol_hold(pol); 422 xfrm_pol_hold(pol);
423 if (delete) 423 if (delete)
diff --git a/scripts/.gitignore b/scripts/.gitignore
new file mode 100644
index 000000000000..b46d68bb9e17
--- /dev/null
+++ b/scripts/.gitignore
@@ -0,0 +1,4 @@
1conmakehash
2kallsyms
3pnmtologo
4
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
new file mode 100644
index 000000000000..7304e19782c7
--- /dev/null
+++ b/scripts/basic/.gitignore
@@ -0,0 +1,3 @@
1fixdep
2split-include
3docproc
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
new file mode 100644
index 000000000000..2dac3442e0ac
--- /dev/null
+++ b/scripts/kconfig/.gitignore
@@ -0,0 +1,16 @@
1#
2# Generated files
3#
4config*
5lex.*.c
6*.tab.c
7*.tab.h
8
9#
10# configuration programs
11#
12conf
13mconf
14qconf
15gconf
16kxgettext
diff --git a/scripts/mod/.gitignore b/scripts/mod/.gitignore
new file mode 100644
index 000000000000..e9b7abe7b95b
--- /dev/null
+++ b/scripts/mod/.gitignore
@@ -0,0 +1,4 @@
1elfconfig.h
2mk_elfconfig
3modpost
4
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index d8ee38aede26..f2ee673329a7 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -295,11 +295,13 @@ static int do_pcmcia_entry(const char *filename,
295{ 295{
296 unsigned int i; 296 unsigned int i;
297 297
298 id->match_flags = TO_NATIVE(id->match_flags);
298 id->manf_id = TO_NATIVE(id->manf_id); 299 id->manf_id = TO_NATIVE(id->manf_id);
299 id->card_id = TO_NATIVE(id->card_id); 300 id->card_id = TO_NATIVE(id->card_id);
300 id->func_id = TO_NATIVE(id->func_id); 301 id->func_id = TO_NATIVE(id->func_id);
301 id->function = TO_NATIVE(id->function); 302 id->function = TO_NATIVE(id->function);
302 id->device_no = TO_NATIVE(id->device_no); 303 id->device_no = TO_NATIVE(id->device_no);
304
303 for (i=0; i<4; i++) { 305 for (i=0; i<4; i++) {
304 id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]); 306 id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]);
305 } 307 }
diff --git a/security/keys/Makefile b/security/keys/Makefile
index c392d750b208..5145adfb6a05 100644
--- a/security/keys/Makefile
+++ b/security/keys/Makefile
@@ -6,6 +6,7 @@ obj-y := \
6 key.o \ 6 key.o \
7 keyring.o \ 7 keyring.o \
8 keyctl.o \ 8 keyctl.o \
9 permission.o \
9 process_keys.o \ 10 process_keys.o \
10 request_key.o \ 11 request_key.o \
11 request_key_auth.o \ 12 request_key_auth.o \
diff --git a/security/keys/internal.h b/security/keys/internal.h
index 46c8602661c9..db99ed434f3a 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -71,26 +71,26 @@ extern void keyring_publish_name(struct key *keyring);
71 71
72extern int __key_link(struct key *keyring, struct key *key); 72extern int __key_link(struct key *keyring, struct key *key);
73 73
74extern struct key *__keyring_search_one(struct key *keyring, 74extern key_ref_t __keyring_search_one(key_ref_t keyring_ref,
75 const struct key_type *type, 75 const struct key_type *type,
76 const char *description, 76 const char *description,
77 key_perm_t perm); 77 key_perm_t perm);
78 78
79extern struct key *keyring_search_instkey(struct key *keyring, 79extern struct key *keyring_search_instkey(struct key *keyring,
80 key_serial_t target_id); 80 key_serial_t target_id);
81 81
82typedef int (*key_match_func_t)(const struct key *, const void *); 82typedef int (*key_match_func_t)(const struct key *, const void *);
83 83
84extern struct key *keyring_search_aux(struct key *keyring, 84extern key_ref_t keyring_search_aux(key_ref_t keyring_ref,
85 struct task_struct *tsk, 85 struct task_struct *tsk,
86 struct key_type *type, 86 struct key_type *type,
87 const void *description, 87 const void *description,
88 key_match_func_t match); 88 key_match_func_t match);
89 89
90extern struct key *search_process_keyrings(struct key_type *type, 90extern key_ref_t search_process_keyrings(struct key_type *type,
91 const void *description, 91 const void *description,
92 key_match_func_t match, 92 key_match_func_t match,
93 struct task_struct *tsk); 93 struct task_struct *tsk);
94 94
95extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); 95extern struct key *find_keyring_by_name(const char *name, key_serial_t bound);
96 96
diff --git a/security/keys/key.c b/security/keys/key.c
index fb89f9844465..2182be9e9309 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -693,14 +693,15 @@ void key_type_put(struct key_type *ktype)
693 * - the key has an incremented refcount 693 * - the key has an incremented refcount
694 * - we need to put the key if we get an error 694 * - we need to put the key if we get an error
695 */ 695 */
696static inline struct key *__key_update(struct key *key, const void *payload, 696static inline key_ref_t __key_update(key_ref_t key_ref,
697 size_t plen) 697 const void *payload, size_t plen)
698{ 698{
699 struct key *key = key_ref_to_ptr(key_ref);
699 int ret; 700 int ret;
700 701
701 /* need write permission on the key to update it */ 702 /* need write permission on the key to update it */
702 ret = -EACCES; 703 ret = -EACCES;
703 if (!key_permission(key, KEY_WRITE)) 704 if (!key_permission(key_ref, KEY_WRITE))
704 goto error; 705 goto error;
705 706
706 ret = -EEXIST; 707 ret = -EEXIST;
@@ -719,12 +720,12 @@ static inline struct key *__key_update(struct key *key, const void *payload,
719 720
720 if (ret < 0) 721 if (ret < 0)
721 goto error; 722 goto error;
722 out: 723out:
723 return key; 724 return key_ref;
724 725
725 error: 726error:
726 key_put(key); 727 key_put(key);
727 key = ERR_PTR(ret); 728 key_ref = ERR_PTR(ret);
728 goto out; 729 goto out;
729 730
730} /* end __key_update() */ 731} /* end __key_update() */
@@ -734,52 +735,56 @@ static inline struct key *__key_update(struct key *key, const void *payload,
734 * search the specified keyring for a key of the same description; if one is 735 * search the specified keyring for a key of the same description; if one is
735 * found, update it, otherwise add a new one 736 * found, update it, otherwise add a new one
736 */ 737 */
737struct key *key_create_or_update(struct key *keyring, 738key_ref_t key_create_or_update(key_ref_t keyring_ref,
738 const char *type, 739 const char *type,
739 const char *description, 740 const char *description,
740 const void *payload, 741 const void *payload,
741 size_t plen, 742 size_t plen,
742 int not_in_quota) 743 int not_in_quota)
743{ 744{
744 struct key_type *ktype; 745 struct key_type *ktype;
745 struct key *key = NULL; 746 struct key *keyring, *key = NULL;
746 key_perm_t perm; 747 key_perm_t perm;
748 key_ref_t key_ref;
747 int ret; 749 int ret;
748 750
749 key_check(keyring);
750
751 /* look up the key type to see if it's one of the registered kernel 751 /* look up the key type to see if it's one of the registered kernel
752 * types */ 752 * types */
753 ktype = key_type_lookup(type); 753 ktype = key_type_lookup(type);
754 if (IS_ERR(ktype)) { 754 if (IS_ERR(ktype)) {
755 key = ERR_PTR(-ENODEV); 755 key_ref = ERR_PTR(-ENODEV);
756 goto error; 756 goto error;
757 } 757 }
758 758
759 ret = -EINVAL; 759 key_ref = ERR_PTR(-EINVAL);
760 if (!ktype->match || !ktype->instantiate) 760 if (!ktype->match || !ktype->instantiate)
761 goto error_2; 761 goto error_2;
762 762
763 keyring = key_ref_to_ptr(keyring_ref);
764
765 key_check(keyring);
766
767 down_write(&keyring->sem);
768
769 /* if we're going to allocate a new key, we're going to have
770 * to modify the keyring */
771 key_ref = ERR_PTR(-EACCES);
772 if (!key_permission(keyring_ref, KEY_WRITE))
773 goto error_3;
774
763 /* search for an existing key of the same type and description in the 775 /* search for an existing key of the same type and description in the
764 * destination keyring 776 * destination keyring
765 */ 777 */
766 down_write(&keyring->sem); 778 key_ref = __keyring_search_one(keyring_ref, ktype, description, 0);
767 779 if (!IS_ERR(key_ref))
768 key = __keyring_search_one(keyring, ktype, description, 0);
769 if (!IS_ERR(key))
770 goto found_matching_key; 780 goto found_matching_key;
771 781
772 /* if we're going to allocate a new key, we're going to have to modify
773 * the keyring */
774 ret = -EACCES;
775 if (!key_permission(keyring, KEY_WRITE))
776 goto error_3;
777
778 /* decide on the permissions we want */ 782 /* decide on the permissions we want */
779 perm = KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK; 783 perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK;
784 perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK;
780 785
781 if (ktype->read) 786 if (ktype->read)
782 perm |= KEY_USR_READ; 787 perm |= KEY_POS_READ | KEY_USR_READ;
783 788
784 if (ktype == &key_type_keyring || ktype->update) 789 if (ktype == &key_type_keyring || ktype->update)
785 perm |= KEY_USR_WRITE; 790 perm |= KEY_USR_WRITE;
@@ -788,7 +793,7 @@ struct key *key_create_or_update(struct key *keyring,
788 key = key_alloc(ktype, description, current->fsuid, current->fsgid, 793 key = key_alloc(ktype, description, current->fsuid, current->fsgid,
789 perm, not_in_quota); 794 perm, not_in_quota);
790 if (IS_ERR(key)) { 795 if (IS_ERR(key)) {
791 ret = PTR_ERR(key); 796 key_ref = ERR_PTR(PTR_ERR(key));
792 goto error_3; 797 goto error_3;
793 } 798 }
794 799
@@ -796,15 +801,18 @@ struct key *key_create_or_update(struct key *keyring,
796 ret = __key_instantiate_and_link(key, payload, plen, keyring, NULL); 801 ret = __key_instantiate_and_link(key, payload, plen, keyring, NULL);
797 if (ret < 0) { 802 if (ret < 0) {
798 key_put(key); 803 key_put(key);
799 key = ERR_PTR(ret); 804 key_ref = ERR_PTR(ret);
805 goto error_3;
800 } 806 }
801 807
808 key_ref = make_key_ref(key, is_key_possessed(keyring_ref));
809
802 error_3: 810 error_3:
803 up_write(&keyring->sem); 811 up_write(&keyring->sem);
804 error_2: 812 error_2:
805 key_type_put(ktype); 813 key_type_put(ktype);
806 error: 814 error:
807 return key; 815 return key_ref;
808 816
809 found_matching_key: 817 found_matching_key:
810 /* we found a matching key, so we're going to try to update it 818 /* we found a matching key, so we're going to try to update it
@@ -813,7 +821,7 @@ struct key *key_create_or_update(struct key *keyring,
813 up_write(&keyring->sem); 821 up_write(&keyring->sem);
814 key_type_put(ktype); 822 key_type_put(ktype);
815 823
816 key = __key_update(key, payload, plen); 824 key_ref = __key_update(key_ref, payload, plen);
817 goto error; 825 goto error;
818 826
819} /* end key_create_or_update() */ 827} /* end key_create_or_update() */
@@ -824,15 +832,16 @@ EXPORT_SYMBOL(key_create_or_update);
824/* 832/*
825 * update a key 833 * update a key
826 */ 834 */
827int key_update(struct key *key, const void *payload, size_t plen) 835int key_update(key_ref_t key_ref, const void *payload, size_t plen)
828{ 836{
837 struct key *key = key_ref_to_ptr(key_ref);
829 int ret; 838 int ret;
830 839
831 key_check(key); 840 key_check(key);
832 841
833 /* the key must be writable */ 842 /* the key must be writable */
834 ret = -EACCES; 843 ret = -EACCES;
835 if (!key_permission(key, KEY_WRITE)) 844 if (!key_permission(key_ref, KEY_WRITE))
836 goto error; 845 goto error;
837 846
838 /* attempt to update it if supported */ 847 /* attempt to update it if supported */
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index a6516a64b297..4c670ee6acf9 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -34,7 +34,7 @@ asmlinkage long sys_add_key(const char __user *_type,
34 size_t plen, 34 size_t plen,
35 key_serial_t ringid) 35 key_serial_t ringid)
36{ 36{
37 struct key *keyring, *key; 37 key_ref_t keyring_ref, key_ref;
38 char type[32], *description; 38 char type[32], *description;
39 void *payload; 39 void *payload;
40 long dlen, ret; 40 long dlen, ret;
@@ -86,25 +86,25 @@ asmlinkage long sys_add_key(const char __user *_type,
86 } 86 }
87 87
88 /* find the target keyring (which must be writable) */ 88 /* find the target keyring (which must be writable) */
89 keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); 89 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
90 if (IS_ERR(keyring)) { 90 if (IS_ERR(keyring_ref)) {
91 ret = PTR_ERR(keyring); 91 ret = PTR_ERR(keyring_ref);
92 goto error3; 92 goto error3;
93 } 93 }
94 94
95 /* create or update the requested key and add it to the target 95 /* create or update the requested key and add it to the target
96 * keyring */ 96 * keyring */
97 key = key_create_or_update(keyring, type, description, 97 key_ref = key_create_or_update(keyring_ref, type, description,
98 payload, plen, 0); 98 payload, plen, 0);
99 if (!IS_ERR(key)) { 99 if (!IS_ERR(key_ref)) {
100 ret = key->serial; 100 ret = key_ref_to_ptr(key_ref)->serial;
101 key_put(key); 101 key_ref_put(key_ref);
102 } 102 }
103 else { 103 else {
104 ret = PTR_ERR(key); 104 ret = PTR_ERR(key_ref);
105 } 105 }
106 106
107 key_put(keyring); 107 key_ref_put(keyring_ref);
108 error3: 108 error3:
109 kfree(payload); 109 kfree(payload);
110 error2: 110 error2:
@@ -131,7 +131,8 @@ asmlinkage long sys_request_key(const char __user *_type,
131 key_serial_t destringid) 131 key_serial_t destringid)
132{ 132{
133 struct key_type *ktype; 133 struct key_type *ktype;
134 struct key *key, *dest; 134 struct key *key;
135 key_ref_t dest_ref;
135 char type[32], *description, *callout_info; 136 char type[32], *description, *callout_info;
136 long dlen, ret; 137 long dlen, ret;
137 138
@@ -187,11 +188,11 @@ asmlinkage long sys_request_key(const char __user *_type,
187 } 188 }
188 189
189 /* get the destination keyring if specified */ 190 /* get the destination keyring if specified */
190 dest = NULL; 191 dest_ref = NULL;
191 if (destringid) { 192 if (destringid) {
192 dest = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); 193 dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE);
193 if (IS_ERR(dest)) { 194 if (IS_ERR(dest_ref)) {
194 ret = PTR_ERR(dest); 195 ret = PTR_ERR(dest_ref);
195 goto error3; 196 goto error3;
196 } 197 }
197 } 198 }
@@ -204,7 +205,8 @@ asmlinkage long sys_request_key(const char __user *_type,
204 } 205 }
205 206
206 /* do the search */ 207 /* do the search */
207 key = request_key_and_link(ktype, description, callout_info, dest); 208 key = request_key_and_link(ktype, description, callout_info,
209 key_ref_to_ptr(dest_ref));
208 if (IS_ERR(key)) { 210 if (IS_ERR(key)) {
209 ret = PTR_ERR(key); 211 ret = PTR_ERR(key);
210 goto error5; 212 goto error5;
@@ -216,7 +218,7 @@ asmlinkage long sys_request_key(const char __user *_type,
216 error5: 218 error5:
217 key_type_put(ktype); 219 key_type_put(ktype);
218 error4: 220 error4:
219 key_put(dest); 221 key_ref_put(dest_ref);
220 error3: 222 error3:
221 kfree(callout_info); 223 kfree(callout_info);
222 error2: 224 error2:
@@ -234,17 +236,17 @@ asmlinkage long sys_request_key(const char __user *_type,
234 */ 236 */
235long keyctl_get_keyring_ID(key_serial_t id, int create) 237long keyctl_get_keyring_ID(key_serial_t id, int create)
236{ 238{
237 struct key *key; 239 key_ref_t key_ref;
238 long ret; 240 long ret;
239 241
240 key = lookup_user_key(NULL, id, create, 0, KEY_SEARCH); 242 key_ref = lookup_user_key(NULL, id, create, 0, KEY_SEARCH);
241 if (IS_ERR(key)) { 243 if (IS_ERR(key_ref)) {
242 ret = PTR_ERR(key); 244 ret = PTR_ERR(key_ref);
243 goto error; 245 goto error;
244 } 246 }
245 247
246 ret = key->serial; 248 ret = key_ref_to_ptr(key_ref)->serial;
247 key_put(key); 249 key_ref_put(key_ref);
248 error: 250 error:
249 return ret; 251 return ret;
250 252
@@ -302,7 +304,7 @@ long keyctl_update_key(key_serial_t id,
302 const void __user *_payload, 304 const void __user *_payload,
303 size_t plen) 305 size_t plen)
304{ 306{
305 struct key *key; 307 key_ref_t key_ref;
306 void *payload; 308 void *payload;
307 long ret; 309 long ret;
308 310
@@ -324,16 +326,16 @@ long keyctl_update_key(key_serial_t id,
324 } 326 }
325 327
326 /* find the target key (which must be writable) */ 328 /* find the target key (which must be writable) */
327 key = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); 329 key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE);
328 if (IS_ERR(key)) { 330 if (IS_ERR(key_ref)) {
329 ret = PTR_ERR(key); 331 ret = PTR_ERR(key_ref);
330 goto error2; 332 goto error2;
331 } 333 }
332 334
333 /* update the key */ 335 /* update the key */
334 ret = key_update(key, payload, plen); 336 ret = key_update(key_ref, payload, plen);
335 337
336 key_put(key); 338 key_ref_put(key_ref);
337 error2: 339 error2:
338 kfree(payload); 340 kfree(payload);
339 error: 341 error:
@@ -349,19 +351,19 @@ long keyctl_update_key(key_serial_t id,
349 */ 351 */
350long keyctl_revoke_key(key_serial_t id) 352long keyctl_revoke_key(key_serial_t id)
351{ 353{
352 struct key *key; 354 key_ref_t key_ref;
353 long ret; 355 long ret;
354 356
355 key = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); 357 key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE);
356 if (IS_ERR(key)) { 358 if (IS_ERR(key_ref)) {
357 ret = PTR_ERR(key); 359 ret = PTR_ERR(key_ref);
358 goto error; 360 goto error;
359 } 361 }
360 362
361 key_revoke(key); 363 key_revoke(key_ref_to_ptr(key_ref));
362 ret = 0; 364 ret = 0;
363 365
364 key_put(key); 366 key_ref_put(key_ref);
365 error: 367 error:
366 return ret; 368 return ret;
367 369
@@ -375,18 +377,18 @@ long keyctl_revoke_key(key_serial_t id)
375 */ 377 */
376long keyctl_keyring_clear(key_serial_t ringid) 378long keyctl_keyring_clear(key_serial_t ringid)
377{ 379{
378 struct key *keyring; 380 key_ref_t keyring_ref;
379 long ret; 381 long ret;
380 382
381 keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); 383 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
382 if (IS_ERR(keyring)) { 384 if (IS_ERR(keyring_ref)) {
383 ret = PTR_ERR(keyring); 385 ret = PTR_ERR(keyring_ref);
384 goto error; 386 goto error;
385 } 387 }
386 388
387 ret = keyring_clear(keyring); 389 ret = keyring_clear(key_ref_to_ptr(keyring_ref));
388 390
389 key_put(keyring); 391 key_ref_put(keyring_ref);
390 error: 392 error:
391 return ret; 393 return ret;
392 394
@@ -401,26 +403,26 @@ long keyctl_keyring_clear(key_serial_t ringid)
401 */ 403 */
402long keyctl_keyring_link(key_serial_t id, key_serial_t ringid) 404long keyctl_keyring_link(key_serial_t id, key_serial_t ringid)
403{ 405{
404 struct key *keyring, *key; 406 key_ref_t keyring_ref, key_ref;
405 long ret; 407 long ret;
406 408
407 keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); 409 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
408 if (IS_ERR(keyring)) { 410 if (IS_ERR(keyring_ref)) {
409 ret = PTR_ERR(keyring); 411 ret = PTR_ERR(keyring_ref);
410 goto error; 412 goto error;
411 } 413 }
412 414
413 key = lookup_user_key(NULL, id, 1, 0, KEY_LINK); 415 key_ref = lookup_user_key(NULL, id, 1, 0, KEY_LINK);
414 if (IS_ERR(key)) { 416 if (IS_ERR(key_ref)) {
415 ret = PTR_ERR(key); 417 ret = PTR_ERR(key_ref);
416 goto error2; 418 goto error2;
417 } 419 }
418 420
419 ret = key_link(keyring, key); 421 ret = key_link(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref));
420 422
421 key_put(key); 423 key_ref_put(key_ref);
422 error2: 424 error2:
423 key_put(keyring); 425 key_ref_put(keyring_ref);
424 error: 426 error:
425 return ret; 427 return ret;
426 428
@@ -435,26 +437,26 @@ long keyctl_keyring_link(key_serial_t id, key_serial_t ringid)
435 */ 437 */
436long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid) 438long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid)
437{ 439{
438 struct key *keyring, *key; 440 key_ref_t keyring_ref, key_ref;
439 long ret; 441 long ret;
440 442
441 keyring = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE); 443 keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE);
442 if (IS_ERR(keyring)) { 444 if (IS_ERR(keyring_ref)) {
443 ret = PTR_ERR(keyring); 445 ret = PTR_ERR(keyring_ref);
444 goto error; 446 goto error;
445 } 447 }
446 448
447 key = lookup_user_key(NULL, id, 0, 0, 0); 449 key_ref = lookup_user_key(NULL, id, 0, 0, 0);
448 if (IS_ERR(key)) { 450 if (IS_ERR(key_ref)) {
449 ret = PTR_ERR(key); 451 ret = PTR_ERR(key_ref);
450 goto error2; 452 goto error2;
451 } 453 }
452 454
453 ret = key_unlink(keyring, key); 455 ret = key_unlink(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref));
454 456
455 key_put(key); 457 key_ref_put(key_ref);
456 error2: 458 error2:
457 key_put(keyring); 459 key_ref_put(keyring_ref);
458 error: 460 error:
459 return ret; 461 return ret;
460 462
@@ -476,24 +478,26 @@ long keyctl_describe_key(key_serial_t keyid,
476 size_t buflen) 478 size_t buflen)
477{ 479{
478 struct key *key, *instkey; 480 struct key *key, *instkey;
481 key_ref_t key_ref;
479 char *tmpbuf; 482 char *tmpbuf;
480 long ret; 483 long ret;
481 484
482 key = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW); 485 key_ref = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW);
483 if (IS_ERR(key)) { 486 if (IS_ERR(key_ref)) {
484 /* viewing a key under construction is permitted if we have the 487 /* viewing a key under construction is permitted if we have the
485 * authorisation token handy */ 488 * authorisation token handy */
486 if (PTR_ERR(key) == -EACCES) { 489 if (PTR_ERR(key_ref) == -EACCES) {
487 instkey = key_get_instantiation_authkey(keyid); 490 instkey = key_get_instantiation_authkey(keyid);
488 if (!IS_ERR(instkey)) { 491 if (!IS_ERR(instkey)) {
489 key_put(instkey); 492 key_put(instkey);
490 key = lookup_user_key(NULL, keyid, 0, 1, 0); 493 key_ref = lookup_user_key(NULL, keyid,
491 if (!IS_ERR(key)) 494 0, 1, 0);
495 if (!IS_ERR(key_ref))
492 goto okay; 496 goto okay;
493 } 497 }
494 } 498 }
495 499
496 ret = PTR_ERR(key); 500 ret = PTR_ERR(key_ref);
497 goto error; 501 goto error;
498 } 502 }
499 503
@@ -504,13 +508,16 @@ okay:
504 if (!tmpbuf) 508 if (!tmpbuf)
505 goto error2; 509 goto error2;
506 510
511 key = key_ref_to_ptr(key_ref);
512
507 ret = snprintf(tmpbuf, PAGE_SIZE - 1, 513 ret = snprintf(tmpbuf, PAGE_SIZE - 1,
508 "%s;%d;%d;%06x;%s", 514 "%s;%d;%d;%08x;%s",
509 key->type->name, 515 key_ref_to_ptr(key_ref)->type->name,
510 key->uid, 516 key_ref_to_ptr(key_ref)->uid,
511 key->gid, 517 key_ref_to_ptr(key_ref)->gid,
512 key->perm, 518 key_ref_to_ptr(key_ref)->perm,
513 key->description ? key->description :"" 519 key_ref_to_ptr(key_ref)->description ?
520 key_ref_to_ptr(key_ref)->description : ""
514 ); 521 );
515 522
516 /* include a NUL char at the end of the data */ 523 /* include a NUL char at the end of the data */
@@ -530,7 +537,7 @@ okay:
530 537
531 kfree(tmpbuf); 538 kfree(tmpbuf);
532 error2: 539 error2:
533 key_put(key); 540 key_ref_put(key_ref);
534 error: 541 error:
535 return ret; 542 return ret;
536 543
@@ -552,7 +559,7 @@ long keyctl_keyring_search(key_serial_t ringid,
552 key_serial_t destringid) 559 key_serial_t destringid)
553{ 560{
554 struct key_type *ktype; 561 struct key_type *ktype;
555 struct key *keyring, *key, *dest; 562 key_ref_t keyring_ref, key_ref, dest_ref;
556 char type[32], *description; 563 char type[32], *description;
557 long dlen, ret; 564 long dlen, ret;
558 565
@@ -581,18 +588,18 @@ long keyctl_keyring_search(key_serial_t ringid,
581 goto error2; 588 goto error2;
582 589
583 /* get the keyring at which to begin the search */ 590 /* get the keyring at which to begin the search */
584 keyring = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH); 591 keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH);
585 if (IS_ERR(keyring)) { 592 if (IS_ERR(keyring_ref)) {
586 ret = PTR_ERR(keyring); 593 ret = PTR_ERR(keyring_ref);
587 goto error2; 594 goto error2;
588 } 595 }
589 596
590 /* get the destination keyring if specified */ 597 /* get the destination keyring if specified */
591 dest = NULL; 598 dest_ref = NULL;
592 if (destringid) { 599 if (destringid) {
593 dest = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); 600 dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE);
594 if (IS_ERR(dest)) { 601 if (IS_ERR(dest_ref)) {
595 ret = PTR_ERR(dest); 602 ret = PTR_ERR(dest_ref);
596 goto error3; 603 goto error3;
597 } 604 }
598 } 605 }
@@ -605,9 +612,9 @@ long keyctl_keyring_search(key_serial_t ringid,
605 } 612 }
606 613
607 /* do the search */ 614 /* do the search */
608 key = keyring_search(keyring, ktype, description); 615 key_ref = keyring_search(keyring_ref, ktype, description);
609 if (IS_ERR(key)) { 616 if (IS_ERR(key_ref)) {
610 ret = PTR_ERR(key); 617 ret = PTR_ERR(key_ref);
611 618
612 /* treat lack or presence of a negative key the same */ 619 /* treat lack or presence of a negative key the same */
613 if (ret == -EAGAIN) 620 if (ret == -EAGAIN)
@@ -616,26 +623,26 @@ long keyctl_keyring_search(key_serial_t ringid,
616 } 623 }
617 624
618 /* link the resulting key to the destination keyring if we can */ 625 /* link the resulting key to the destination keyring if we can */
619 if (dest) { 626 if (dest_ref) {
620 ret = -EACCES; 627 ret = -EACCES;
621 if (!key_permission(key, KEY_LINK)) 628 if (!key_permission(key_ref, KEY_LINK))
622 goto error6; 629 goto error6;
623 630
624 ret = key_link(dest, key); 631 ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref));
625 if (ret < 0) 632 if (ret < 0)
626 goto error6; 633 goto error6;
627 } 634 }
628 635
629 ret = key->serial; 636 ret = key_ref_to_ptr(key_ref)->serial;
630 637
631 error6: 638 error6:
632 key_put(key); 639 key_ref_put(key_ref);
633 error5: 640 error5:
634 key_type_put(ktype); 641 key_type_put(ktype);
635 error4: 642 error4:
636 key_put(dest); 643 key_ref_put(dest_ref);
637 error3: 644 error3:
638 key_put(keyring); 645 key_ref_put(keyring_ref);
639 error2: 646 error2:
640 kfree(description); 647 kfree(description);
641 error: 648 error:
@@ -645,16 +652,6 @@ long keyctl_keyring_search(key_serial_t ringid,
645 652
646/*****************************************************************************/ 653/*****************************************************************************/
647/* 654/*
648 * see if the key we're looking at is the target key
649 */
650static int keyctl_read_key_same(const struct key *key, const void *target)
651{
652 return key == target;
653
654} /* end keyctl_read_key_same() */
655
656/*****************************************************************************/
657/*
658 * read a user key's payload 655 * read a user key's payload
659 * - the keyring must be readable or the key must be searchable from the 656 * - the keyring must be readable or the key must be searchable from the
660 * process's keyrings 657 * process's keyrings
@@ -665,38 +662,33 @@ static int keyctl_read_key_same(const struct key *key, const void *target)
665 */ 662 */
666long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) 663long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
667{ 664{
668 struct key *key, *skey; 665 struct key *key;
666 key_ref_t key_ref;
669 long ret; 667 long ret;
670 668
671 /* find the key first */ 669 /* find the key first */
672 key = lookup_user_key(NULL, keyid, 0, 0, 0); 670 key_ref = lookup_user_key(NULL, keyid, 0, 0, 0);
673 if (!IS_ERR(key)) { 671 if (IS_ERR(key_ref)) {
674 /* see if we can read it directly */ 672 ret = -ENOKEY;
675 if (key_permission(key, KEY_READ)) 673 goto error;
676 goto can_read_key;
677
678 /* we can't; see if it's searchable from this process's
679 * keyrings
680 * - we automatically take account of the fact that it may be
681 * dangling off an instantiation key
682 */
683 skey = search_process_keyrings(key->type, key,
684 keyctl_read_key_same, current);
685 if (!IS_ERR(skey))
686 goto can_read_key2;
687
688 ret = PTR_ERR(skey);
689 if (ret == -EAGAIN)
690 ret = -EACCES;
691 goto error2;
692 } 674 }
693 675
694 ret = -ENOKEY; 676 key = key_ref_to_ptr(key_ref);
695 goto error; 677
678 /* see if we can read it directly */
679 if (key_permission(key_ref, KEY_READ))
680 goto can_read_key;
681
682 /* we can't; see if it's searchable from this process's keyrings
683 * - we automatically take account of the fact that it may be
684 * dangling off an instantiation key
685 */
686 if (!is_key_possessed(key_ref)) {
687 ret = -EACCES;
688 goto error2;
689 }
696 690
697 /* the key is probably readable - now try to read it */ 691 /* the key is probably readable - now try to read it */
698 can_read_key2:
699 key_put(skey);
700 can_read_key: 692 can_read_key:
701 ret = key_validate(key); 693 ret = key_validate(key);
702 if (ret == 0) { 694 if (ret == 0) {
@@ -727,18 +719,21 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
727long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) 719long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid)
728{ 720{
729 struct key *key; 721 struct key *key;
722 key_ref_t key_ref;
730 long ret; 723 long ret;
731 724
732 ret = 0; 725 ret = 0;
733 if (uid == (uid_t) -1 && gid == (gid_t) -1) 726 if (uid == (uid_t) -1 && gid == (gid_t) -1)
734 goto error; 727 goto error;
735 728
736 key = lookup_user_key(NULL, id, 1, 1, 0); 729 key_ref = lookup_user_key(NULL, id, 1, 1, 0);
737 if (IS_ERR(key)) { 730 if (IS_ERR(key_ref)) {
738 ret = PTR_ERR(key); 731 ret = PTR_ERR(key_ref);
739 goto error; 732 goto error;
740 } 733 }
741 734
735 key = key_ref_to_ptr(key_ref);
736
742 /* make the changes with the locks held to prevent chown/chown races */ 737 /* make the changes with the locks held to prevent chown/chown races */
743 ret = -EACCES; 738 ret = -EACCES;
744 down_write(&key->sem); 739 down_write(&key->sem);
@@ -784,18 +779,21 @@ long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid)
784long keyctl_setperm_key(key_serial_t id, key_perm_t perm) 779long keyctl_setperm_key(key_serial_t id, key_perm_t perm)
785{ 780{
786 struct key *key; 781 struct key *key;
782 key_ref_t key_ref;
787 long ret; 783 long ret;
788 784
789 ret = -EINVAL; 785 ret = -EINVAL;
790 if (perm & ~(KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) 786 if (perm & ~(KEY_POS_ALL | KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL))
791 goto error; 787 goto error;
792 788
793 key = lookup_user_key(NULL, id, 1, 1, 0); 789 key_ref = lookup_user_key(NULL, id, 1, 1, 0);
794 if (IS_ERR(key)) { 790 if (IS_ERR(key_ref)) {
795 ret = PTR_ERR(key); 791 ret = PTR_ERR(key_ref);
796 goto error; 792 goto error;
797 } 793 }
798 794
795 key = key_ref_to_ptr(key_ref);
796
799 /* make the changes with the locks held to prevent chown/chmod races */ 797 /* make the changes with the locks held to prevent chown/chmod races */
800 ret = -EACCES; 798 ret = -EACCES;
801 down_write(&key->sem); 799 down_write(&key->sem);
@@ -824,7 +822,8 @@ long keyctl_instantiate_key(key_serial_t id,
824 key_serial_t ringid) 822 key_serial_t ringid)
825{ 823{
826 struct request_key_auth *rka; 824 struct request_key_auth *rka;
827 struct key *instkey, *keyring; 825 struct key *instkey;
826 key_ref_t keyring_ref;
828 void *payload; 827 void *payload;
829 long ret; 828 long ret;
830 829
@@ -857,21 +856,21 @@ long keyctl_instantiate_key(key_serial_t id,
857 856
858 /* find the destination keyring amongst those belonging to the 857 /* find the destination keyring amongst those belonging to the
859 * requesting task */ 858 * requesting task */
860 keyring = NULL; 859 keyring_ref = NULL;
861 if (ringid) { 860 if (ringid) {
862 keyring = lookup_user_key(rka->context, ringid, 1, 0, 861 keyring_ref = lookup_user_key(rka->context, ringid, 1, 0,
863 KEY_WRITE); 862 KEY_WRITE);
864 if (IS_ERR(keyring)) { 863 if (IS_ERR(keyring_ref)) {
865 ret = PTR_ERR(keyring); 864 ret = PTR_ERR(keyring_ref);
866 goto error3; 865 goto error3;
867 } 866 }
868 } 867 }
869 868
870 /* instantiate the key and link it into a keyring */ 869 /* instantiate the key and link it into a keyring */
871 ret = key_instantiate_and_link(rka->target_key, payload, plen, 870 ret = key_instantiate_and_link(rka->target_key, payload, plen,
872 keyring, instkey); 871 key_ref_to_ptr(keyring_ref), instkey);
873 872
874 key_put(keyring); 873 key_ref_put(keyring_ref);
875 error3: 874 error3:
876 key_put(instkey); 875 key_put(instkey);
877 error2: 876 error2:
@@ -889,7 +888,8 @@ long keyctl_instantiate_key(key_serial_t id,
889long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid) 888long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid)
890{ 889{
891 struct request_key_auth *rka; 890 struct request_key_auth *rka;
892 struct key *instkey, *keyring; 891 struct key *instkey;
892 key_ref_t keyring_ref;
893 long ret; 893 long ret;
894 894
895 /* find the instantiation authorisation key */ 895 /* find the instantiation authorisation key */
@@ -903,19 +903,20 @@ long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid)
903 903
904 /* find the destination keyring if present (which must also be 904 /* find the destination keyring if present (which must also be
905 * writable) */ 905 * writable) */
906 keyring = NULL; 906 keyring_ref = NULL;
907 if (ringid) { 907 if (ringid) {
908 keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); 908 keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE);
909 if (IS_ERR(keyring)) { 909 if (IS_ERR(keyring_ref)) {
910 ret = PTR_ERR(keyring); 910 ret = PTR_ERR(keyring_ref);
911 goto error2; 911 goto error2;
912 } 912 }
913 } 913 }
914 914
915 /* instantiate the key and link it into a keyring */ 915 /* instantiate the key and link it into a keyring */
916 ret = key_negate_and_link(rka->target_key, timeout, keyring, instkey); 916 ret = key_negate_and_link(rka->target_key, timeout,
917 key_ref_to_ptr(keyring_ref), instkey);
917 918
918 key_put(keyring); 919 key_ref_put(keyring_ref);
919 error2: 920 error2:
920 key_put(instkey); 921 key_put(instkey);
921 error: 922 error:
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 9c208c756df8..0639396dd441 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -309,7 +309,7 @@ struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
309 int ret; 309 int ret;
310 310
311 keyring = key_alloc(&key_type_keyring, description, 311 keyring = key_alloc(&key_type_keyring, description,
312 uid, gid, KEY_USR_ALL, not_in_quota); 312 uid, gid, KEY_POS_ALL | KEY_USR_ALL, not_in_quota);
313 313
314 if (!IS_ERR(keyring)) { 314 if (!IS_ERR(keyring)) {
315 ret = key_instantiate_and_link(keyring, NULL, 0, dest, NULL); 315 ret = key_instantiate_and_link(keyring, NULL, 0, dest, NULL);
@@ -333,12 +333,13 @@ struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid,
333 * - we rely on RCU to prevent the keyring lists from disappearing on us 333 * - we rely on RCU to prevent the keyring lists from disappearing on us
334 * - we return -EAGAIN if we didn't find any matching key 334 * - we return -EAGAIN if we didn't find any matching key
335 * - we return -ENOKEY if we only found negative matching keys 335 * - we return -ENOKEY if we only found negative matching keys
336 * - we propagate the possession attribute from the keyring ref to the key ref
336 */ 337 */
337struct key *keyring_search_aux(struct key *keyring, 338key_ref_t keyring_search_aux(key_ref_t keyring_ref,
338 struct task_struct *context, 339 struct task_struct *context,
339 struct key_type *type, 340 struct key_type *type,
340 const void *description, 341 const void *description,
341 key_match_func_t match) 342 key_match_func_t match)
342{ 343{
343 struct { 344 struct {
344 struct keyring_list *keylist; 345 struct keyring_list *keylist;
@@ -347,29 +348,33 @@ struct key *keyring_search_aux(struct key *keyring,
347 348
348 struct keyring_list *keylist; 349 struct keyring_list *keylist;
349 struct timespec now; 350 struct timespec now;
350 struct key *key; 351 unsigned long possessed;
352 struct key *keyring, *key;
353 key_ref_t key_ref;
351 long err; 354 long err;
352 int sp, kix; 355 int sp, kix;
353 356
357 keyring = key_ref_to_ptr(keyring_ref);
358 possessed = is_key_possessed(keyring_ref);
354 key_check(keyring); 359 key_check(keyring);
355 360
356 rcu_read_lock();
357
358 /* top keyring must have search permission to begin the search */ 361 /* top keyring must have search permission to begin the search */
359 key = ERR_PTR(-EACCES); 362 key_ref = ERR_PTR(-EACCES);
360 if (!key_task_permission(keyring, context, KEY_SEARCH)) 363 if (!key_task_permission(keyring_ref, context, KEY_SEARCH))
361 goto error; 364 goto error;
362 365
363 key = ERR_PTR(-ENOTDIR); 366 key_ref = ERR_PTR(-ENOTDIR);
364 if (keyring->type != &key_type_keyring) 367 if (keyring->type != &key_type_keyring)
365 goto error; 368 goto error;
366 369
370 rcu_read_lock();
371
367 now = current_kernel_time(); 372 now = current_kernel_time();
368 err = -EAGAIN; 373 err = -EAGAIN;
369 sp = 0; 374 sp = 0;
370 375
371 /* start processing a new keyring */ 376 /* start processing a new keyring */
372 descend: 377descend:
373 if (test_bit(KEY_FLAG_REVOKED, &keyring->flags)) 378 if (test_bit(KEY_FLAG_REVOKED, &keyring->flags))
374 goto not_this_keyring; 379 goto not_this_keyring;
375 380
@@ -397,7 +402,8 @@ struct key *keyring_search_aux(struct key *keyring,
397 continue; 402 continue;
398 403
399 /* key must have search permissions */ 404 /* key must have search permissions */
400 if (!key_task_permission(key, context, KEY_SEARCH)) 405 if (!key_task_permission(make_key_ref(key, possessed),
406 context, KEY_SEARCH))
401 continue; 407 continue;
402 408
403 /* we set a different error code if we find a negative key */ 409 /* we set a different error code if we find a negative key */
@@ -411,7 +417,7 @@ struct key *keyring_search_aux(struct key *keyring,
411 417
412 /* search through the keyrings nested in this one */ 418 /* search through the keyrings nested in this one */
413 kix = 0; 419 kix = 0;
414 ascend: 420ascend:
415 for (; kix < keylist->nkeys; kix++) { 421 for (; kix < keylist->nkeys; kix++) {
416 key = keylist->keys[kix]; 422 key = keylist->keys[kix];
417 if (key->type != &key_type_keyring) 423 if (key->type != &key_type_keyring)
@@ -423,7 +429,8 @@ struct key *keyring_search_aux(struct key *keyring,
423 if (sp >= KEYRING_SEARCH_MAX_DEPTH) 429 if (sp >= KEYRING_SEARCH_MAX_DEPTH)
424 continue; 430 continue;
425 431
426 if (!key_task_permission(key, context, KEY_SEARCH)) 432 if (!key_task_permission(make_key_ref(key, possessed),
433 context, KEY_SEARCH))
427 continue; 434 continue;
428 435
429 /* stack the current position */ 436 /* stack the current position */
@@ -438,7 +445,7 @@ struct key *keyring_search_aux(struct key *keyring,
438 445
439 /* the keyring we're looking at was disqualified or didn't contain a 446 /* the keyring we're looking at was disqualified or didn't contain a
440 * matching key */ 447 * matching key */
441 not_this_keyring: 448not_this_keyring:
442 if (sp > 0) { 449 if (sp > 0) {
443 /* resume the processing of a keyring higher up in the tree */ 450 /* resume the processing of a keyring higher up in the tree */
444 sp--; 451 sp--;
@@ -447,16 +454,18 @@ struct key *keyring_search_aux(struct key *keyring,
447 goto ascend; 454 goto ascend;
448 } 455 }
449 456
450 key = ERR_PTR(err); 457 key_ref = ERR_PTR(err);
451 goto error; 458 goto error_2;
452 459
453 /* we found a viable match */ 460 /* we found a viable match */
454 found: 461found:
455 atomic_inc(&key->usage); 462 atomic_inc(&key->usage);
456 key_check(key); 463 key_check(key);
457 error: 464 key_ref = make_key_ref(key, possessed);
465error_2:
458 rcu_read_unlock(); 466 rcu_read_unlock();
459 return key; 467error:
468 return key_ref;
460 469
461} /* end keyring_search_aux() */ 470} /* end keyring_search_aux() */
462 471
@@ -469,9 +478,9 @@ struct key *keyring_search_aux(struct key *keyring,
469 * - we return -EAGAIN if we didn't find any matching key 478 * - we return -EAGAIN if we didn't find any matching key
470 * - we return -ENOKEY if we only found negative matching keys 479 * - we return -ENOKEY if we only found negative matching keys
471 */ 480 */
472struct key *keyring_search(struct key *keyring, 481key_ref_t keyring_search(key_ref_t keyring,
473 struct key_type *type, 482 struct key_type *type,
474 const char *description) 483 const char *description)
475{ 484{
476 if (!type->match) 485 if (!type->match)
477 return ERR_PTR(-ENOKEY); 486 return ERR_PTR(-ENOKEY);
@@ -488,15 +497,19 @@ EXPORT_SYMBOL(keyring_search);
488 * search the given keyring only (no recursion) 497 * search the given keyring only (no recursion)
489 * - keyring must be locked by caller 498 * - keyring must be locked by caller
490 */ 499 */
491struct key *__keyring_search_one(struct key *keyring, 500key_ref_t __keyring_search_one(key_ref_t keyring_ref,
492 const struct key_type *ktype, 501 const struct key_type *ktype,
493 const char *description, 502 const char *description,
494 key_perm_t perm) 503 key_perm_t perm)
495{ 504{
496 struct keyring_list *klist; 505 struct keyring_list *klist;
497 struct key *key; 506 unsigned long possessed;
507 struct key *keyring, *key;
498 int loop; 508 int loop;
499 509
510 keyring = key_ref_to_ptr(keyring_ref);
511 possessed = is_key_possessed(keyring_ref);
512
500 rcu_read_lock(); 513 rcu_read_lock();
501 514
502 klist = rcu_dereference(keyring->payload.subscriptions); 515 klist = rcu_dereference(keyring->payload.subscriptions);
@@ -507,21 +520,21 @@ struct key *__keyring_search_one(struct key *keyring,
507 if (key->type == ktype && 520 if (key->type == ktype &&
508 (!key->type->match || 521 (!key->type->match ||
509 key->type->match(key, description)) && 522 key->type->match(key, description)) &&
510 key_permission(key, perm) && 523 key_permission(make_key_ref(key, possessed),
524 perm) &&
511 !test_bit(KEY_FLAG_REVOKED, &key->flags) 525 !test_bit(KEY_FLAG_REVOKED, &key->flags)
512 ) 526 )
513 goto found; 527 goto found;
514 } 528 }
515 } 529 }
516 530
517 key = ERR_PTR(-ENOKEY); 531 rcu_read_unlock();
518 goto error; 532 return ERR_PTR(-ENOKEY);
519 533
520 found: 534 found:
521 atomic_inc(&key->usage); 535 atomic_inc(&key->usage);
522 error:
523 rcu_read_unlock(); 536 rcu_read_unlock();
524 return key; 537 return make_key_ref(key, possessed);
525 538
526} /* end __keyring_search_one() */ 539} /* end __keyring_search_one() */
527 540
@@ -603,7 +616,8 @@ struct key *find_keyring_by_name(const char *name, key_serial_t bound)
603 if (strcmp(keyring->description, name) != 0) 616 if (strcmp(keyring->description, name) != 0)
604 continue; 617 continue;
605 618
606 if (!key_permission(keyring, KEY_SEARCH)) 619 if (!key_permission(make_key_ref(keyring, 0),
620 KEY_SEARCH))
607 continue; 621 continue;
608 622
609 /* found a potential candidate, but we still need to 623 /* found a potential candidate, but we still need to
diff --git a/security/keys/permission.c b/security/keys/permission.c
new file mode 100644
index 000000000000..03db073ba45c
--- /dev/null
+++ b/security/keys/permission.c
@@ -0,0 +1,70 @@
1/* permission.c: key permission determination
2 *
3 * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include "internal.h"
14
15/*****************************************************************************/
16/*
17 * check to see whether permission is granted to use a key in the desired way,
18 * but permit the security modules to override
19 */
20int key_task_permission(const key_ref_t key_ref,
21 struct task_struct *context,
22 key_perm_t perm)
23{
24 struct key *key;
25 key_perm_t kperm;
26 int ret;
27
28 key = key_ref_to_ptr(key_ref);
29
30 /* use the second 8-bits of permissions for keys the caller owns */
31 if (key->uid == context->fsuid) {
32 kperm = key->perm >> 16;
33 goto use_these_perms;
34 }
35
36 /* use the third 8-bits of permissions for keys the caller has a group
37 * membership in common with */
38 if (key->gid != -1 && key->perm & KEY_GRP_ALL) {
39 if (key->gid == context->fsgid) {
40 kperm = key->perm >> 8;
41 goto use_these_perms;
42 }
43
44 task_lock(context);
45 ret = groups_search(context->group_info, key->gid);
46 task_unlock(context);
47
48 if (ret) {
49 kperm = key->perm >> 8;
50 goto use_these_perms;
51 }
52 }
53
54 /* otherwise use the least-significant 8-bits */
55 kperm = key->perm;
56
57use_these_perms:
58 /* use the top 8-bits of permissions for keys the caller possesses
59 * - possessor permissions are additive with other permissions
60 */
61 if (is_key_possessed(key_ref))
62 kperm |= key->perm >> 24;
63
64 kperm = kperm & perm & KEY_ALL;
65
66 return kperm == perm;
67
68} /* end key_task_permission() */
69
70EXPORT_SYMBOL(key_task_permission);
diff --git a/security/keys/proc.c b/security/keys/proc.c
index c55cf1fd0826..12b750e51fbf 100644
--- a/security/keys/proc.c
+++ b/security/keys/proc.c
@@ -167,7 +167,7 @@ static int proc_keys_show(struct seq_file *m, void *v)
167#define showflag(KEY, LETTER, FLAG) \ 167#define showflag(KEY, LETTER, FLAG) \
168 (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-') 168 (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-')
169 169
170 seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %06x %5d %5d %-9.9s ", 170 seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %08x %5d %5d %-9.9s ",
171 key->serial, 171 key->serial,
172 showflag(key, 'I', KEY_FLAG_INSTANTIATED), 172 showflag(key, 'I', KEY_FLAG_INSTANTIATED),
173 showflag(key, 'R', KEY_FLAG_REVOKED), 173 showflag(key, 'R', KEY_FLAG_REVOKED),
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index c089f78fb94e..d42d2158ce13 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -39,7 +39,7 @@ struct key root_user_keyring = {
39 .type = &key_type_keyring, 39 .type = &key_type_keyring,
40 .user = &root_key_user, 40 .user = &root_key_user,
41 .sem = __RWSEM_INITIALIZER(root_user_keyring.sem), 41 .sem = __RWSEM_INITIALIZER(root_user_keyring.sem),
42 .perm = KEY_USR_ALL, 42 .perm = KEY_POS_ALL | KEY_USR_ALL,
43 .flags = 1 << KEY_FLAG_INSTANTIATED, 43 .flags = 1 << KEY_FLAG_INSTANTIATED,
44 .description = "_uid.0", 44 .description = "_uid.0",
45#ifdef KEY_DEBUGGING 45#ifdef KEY_DEBUGGING
@@ -54,7 +54,7 @@ struct key root_session_keyring = {
54 .type = &key_type_keyring, 54 .type = &key_type_keyring,
55 .user = &root_key_user, 55 .user = &root_key_user,
56 .sem = __RWSEM_INITIALIZER(root_session_keyring.sem), 56 .sem = __RWSEM_INITIALIZER(root_session_keyring.sem),
57 .perm = KEY_USR_ALL, 57 .perm = KEY_POS_ALL | KEY_USR_ALL,
58 .flags = 1 << KEY_FLAG_INSTANTIATED, 58 .flags = 1 << KEY_FLAG_INSTANTIATED,
59 .description = "_uid_ses.0", 59 .description = "_uid_ses.0",
60#ifdef KEY_DEBUGGING 60#ifdef KEY_DEBUGGING
@@ -98,7 +98,7 @@ int alloc_uid_keyring(struct user_struct *user)
98 user->session_keyring = session_keyring; 98 user->session_keyring = session_keyring;
99 ret = 0; 99 ret = 0;
100 100
101 error: 101error:
102 return ret; 102 return ret;
103 103
104} /* end alloc_uid_keyring() */ 104} /* end alloc_uid_keyring() */
@@ -156,7 +156,7 @@ int install_thread_keyring(struct task_struct *tsk)
156 ret = 0; 156 ret = 0;
157 157
158 key_put(old); 158 key_put(old);
159 error: 159error:
160 return ret; 160 return ret;
161 161
162} /* end install_thread_keyring() */ 162} /* end install_thread_keyring() */
@@ -193,7 +193,7 @@ int install_process_keyring(struct task_struct *tsk)
193 } 193 }
194 194
195 ret = 0; 195 ret = 0;
196 error: 196error:
197 return ret; 197 return ret;
198 198
199} /* end install_process_keyring() */ 199} /* end install_process_keyring() */
@@ -236,7 +236,7 @@ static int install_session_keyring(struct task_struct *tsk,
236 /* we're using RCU on the pointer */ 236 /* we're using RCU on the pointer */
237 synchronize_rcu(); 237 synchronize_rcu();
238 key_put(old); 238 key_put(old);
239 error: 239error:
240 return ret; 240 return ret;
241 241
242} /* end install_session_keyring() */ 242} /* end install_session_keyring() */
@@ -376,13 +376,13 @@ void key_fsgid_changed(struct task_struct *tsk)
376 * - we return -EAGAIN if we didn't find any matching key 376 * - we return -EAGAIN if we didn't find any matching key
377 * - we return -ENOKEY if we found only negative matching keys 377 * - we return -ENOKEY if we found only negative matching keys
378 */ 378 */
379struct key *search_process_keyrings(struct key_type *type, 379key_ref_t search_process_keyrings(struct key_type *type,
380 const void *description, 380 const void *description,
381 key_match_func_t match, 381 key_match_func_t match,
382 struct task_struct *context) 382 struct task_struct *context)
383{ 383{
384 struct request_key_auth *rka; 384 struct request_key_auth *rka;
385 struct key *key, *ret, *err, *instkey; 385 key_ref_t key_ref, ret, err, instkey_ref;
386 386
387 /* we want to return -EAGAIN or -ENOKEY if any of the keyrings were 387 /* we want to return -EAGAIN or -ENOKEY if any of the keyrings were
388 * searchable, but we failed to find a key or we found a negative key; 388 * searchable, but we failed to find a key or we found a negative key;
@@ -391,46 +391,48 @@ struct key *search_process_keyrings(struct key_type *type,
391 * 391 *
392 * in terms of priority: success > -ENOKEY > -EAGAIN > other error 392 * in terms of priority: success > -ENOKEY > -EAGAIN > other error
393 */ 393 */
394 key = NULL; 394 key_ref = NULL;
395 ret = NULL; 395 ret = NULL;
396 err = ERR_PTR(-EAGAIN); 396 err = ERR_PTR(-EAGAIN);
397 397
398 /* search the thread keyring first */ 398 /* search the thread keyring first */
399 if (context->thread_keyring) { 399 if (context->thread_keyring) {
400 key = keyring_search_aux(context->thread_keyring, 400 key_ref = keyring_search_aux(
401 context, type, description, match); 401 make_key_ref(context->thread_keyring, 1),
402 if (!IS_ERR(key)) 402 context, type, description, match);
403 if (!IS_ERR(key_ref))
403 goto found; 404 goto found;
404 405
405 switch (PTR_ERR(key)) { 406 switch (PTR_ERR(key_ref)) {
406 case -EAGAIN: /* no key */ 407 case -EAGAIN: /* no key */
407 if (ret) 408 if (ret)
408 break; 409 break;
409 case -ENOKEY: /* negative key */ 410 case -ENOKEY: /* negative key */
410 ret = key; 411 ret = key_ref;
411 break; 412 break;
412 default: 413 default:
413 err = key; 414 err = key_ref;
414 break; 415 break;
415 } 416 }
416 } 417 }
417 418
418 /* search the process keyring second */ 419 /* search the process keyring second */
419 if (context->signal->process_keyring) { 420 if (context->signal->process_keyring) {
420 key = keyring_search_aux(context->signal->process_keyring, 421 key_ref = keyring_search_aux(
421 context, type, description, match); 422 make_key_ref(context->signal->process_keyring, 1),
422 if (!IS_ERR(key)) 423 context, type, description, match);
424 if (!IS_ERR(key_ref))
423 goto found; 425 goto found;
424 426
425 switch (PTR_ERR(key)) { 427 switch (PTR_ERR(key_ref)) {
426 case -EAGAIN: /* no key */ 428 case -EAGAIN: /* no key */
427 if (ret) 429 if (ret)
428 break; 430 break;
429 case -ENOKEY: /* negative key */ 431 case -ENOKEY: /* negative key */
430 ret = key; 432 ret = key_ref;
431 break; 433 break;
432 default: 434 default:
433 err = key; 435 err = key_ref;
434 break; 436 break;
435 } 437 }
436 } 438 }
@@ -438,23 +440,25 @@ struct key *search_process_keyrings(struct key_type *type,
438 /* search the session keyring */ 440 /* search the session keyring */
439 if (context->signal->session_keyring) { 441 if (context->signal->session_keyring) {
440 rcu_read_lock(); 442 rcu_read_lock();
441 key = keyring_search_aux( 443 key_ref = keyring_search_aux(
442 rcu_dereference(context->signal->session_keyring), 444 make_key_ref(rcu_dereference(
445 context->signal->session_keyring),
446 1),
443 context, type, description, match); 447 context, type, description, match);
444 rcu_read_unlock(); 448 rcu_read_unlock();
445 449
446 if (!IS_ERR(key)) 450 if (!IS_ERR(key_ref))
447 goto found; 451 goto found;
448 452
449 switch (PTR_ERR(key)) { 453 switch (PTR_ERR(key_ref)) {
450 case -EAGAIN: /* no key */ 454 case -EAGAIN: /* no key */
451 if (ret) 455 if (ret)
452 break; 456 break;
453 case -ENOKEY: /* negative key */ 457 case -ENOKEY: /* negative key */
454 ret = key; 458 ret = key_ref;
455 break; 459 break;
456 default: 460 default:
457 err = key; 461 err = key_ref;
458 break; 462 break;
459 } 463 }
460 464
@@ -465,51 +469,54 @@ struct key *search_process_keyrings(struct key_type *type,
465 goto no_key; 469 goto no_key;
466 470
467 rcu_read_lock(); 471 rcu_read_lock();
468 instkey = __keyring_search_one( 472 instkey_ref = __keyring_search_one(
469 rcu_dereference(context->signal->session_keyring), 473 make_key_ref(rcu_dereference(
474 context->signal->session_keyring),
475 1),
470 &key_type_request_key_auth, NULL, 0); 476 &key_type_request_key_auth, NULL, 0);
471 rcu_read_unlock(); 477 rcu_read_unlock();
472 478
473 if (IS_ERR(instkey)) 479 if (IS_ERR(instkey_ref))
474 goto no_key; 480 goto no_key;
475 481
476 rka = instkey->payload.data; 482 rka = key_ref_to_ptr(instkey_ref)->payload.data;
477 483
478 key = search_process_keyrings(type, description, match, 484 key_ref = search_process_keyrings(type, description, match,
479 rka->context); 485 rka->context);
480 key_put(instkey); 486 key_ref_put(instkey_ref);
481 487
482 if (!IS_ERR(key)) 488 if (!IS_ERR(key_ref))
483 goto found; 489 goto found;
484 490
485 switch (PTR_ERR(key)) { 491 switch (PTR_ERR(key_ref)) {
486 case -EAGAIN: /* no key */ 492 case -EAGAIN: /* no key */
487 if (ret) 493 if (ret)
488 break; 494 break;
489 case -ENOKEY: /* negative key */ 495 case -ENOKEY: /* negative key */
490 ret = key; 496 ret = key_ref;
491 break; 497 break;
492 default: 498 default:
493 err = key; 499 err = key_ref;
494 break; 500 break;
495 } 501 }
496 } 502 }
497 /* or search the user-session keyring */ 503 /* or search the user-session keyring */
498 else { 504 else {
499 key = keyring_search_aux(context->user->session_keyring, 505 key_ref = keyring_search_aux(
500 context, type, description, match); 506 make_key_ref(context->user->session_keyring, 1),
501 if (!IS_ERR(key)) 507 context, type, description, match);
508 if (!IS_ERR(key_ref))
502 goto found; 509 goto found;
503 510
504 switch (PTR_ERR(key)) { 511 switch (PTR_ERR(key_ref)) {
505 case -EAGAIN: /* no key */ 512 case -EAGAIN: /* no key */
506 if (ret) 513 if (ret)
507 break; 514 break;
508 case -ENOKEY: /* negative key */ 515 case -ENOKEY: /* negative key */
509 ret = key; 516 ret = key_ref;
510 break; 517 break;
511 default: 518 default:
512 err = key; 519 err = key_ref;
513 break; 520 break;
514 } 521 }
515 } 522 }
@@ -517,29 +524,40 @@ struct key *search_process_keyrings(struct key_type *type,
517 524
518no_key: 525no_key:
519 /* no key - decide on the error we're going to go for */ 526 /* no key - decide on the error we're going to go for */
520 key = ret ? ret : err; 527 key_ref = ret ? ret : err;
521 528
522found: 529found:
523 return key; 530 return key_ref;
524 531
525} /* end search_process_keyrings() */ 532} /* end search_process_keyrings() */
526 533
527/*****************************************************************************/ 534/*****************************************************************************/
528/* 535/*
536 * see if the key we're looking at is the target key
537 */
538static int lookup_user_key_possessed(const struct key *key, const void *target)
539{
540 return key == target;
541
542} /* end lookup_user_key_possessed() */
543
544/*****************************************************************************/
545/*
529 * lookup a key given a key ID from userspace with a given permissions mask 546 * lookup a key given a key ID from userspace with a given permissions mask
530 * - don't create special keyrings unless so requested 547 * - don't create special keyrings unless so requested
531 * - partially constructed keys aren't found unless requested 548 * - partially constructed keys aren't found unless requested
532 */ 549 */
533struct key *lookup_user_key(struct task_struct *context, key_serial_t id, 550key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id,
534 int create, int partial, key_perm_t perm) 551 int create, int partial, key_perm_t perm)
535{ 552{
553 key_ref_t key_ref, skey_ref;
536 struct key *key; 554 struct key *key;
537 int ret; 555 int ret;
538 556
539 if (!context) 557 if (!context)
540 context = current; 558 context = current;
541 559
542 key = ERR_PTR(-ENOKEY); 560 key_ref = ERR_PTR(-ENOKEY);
543 561
544 switch (id) { 562 switch (id) {
545 case KEY_SPEC_THREAD_KEYRING: 563 case KEY_SPEC_THREAD_KEYRING:
@@ -556,6 +574,7 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id,
556 574
557 key = context->thread_keyring; 575 key = context->thread_keyring;
558 atomic_inc(&key->usage); 576 atomic_inc(&key->usage);
577 key_ref = make_key_ref(key, 1);
559 break; 578 break;
560 579
561 case KEY_SPEC_PROCESS_KEYRING: 580 case KEY_SPEC_PROCESS_KEYRING:
@@ -572,6 +591,7 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id,
572 591
573 key = context->signal->process_keyring; 592 key = context->signal->process_keyring;
574 atomic_inc(&key->usage); 593 atomic_inc(&key->usage);
594 key_ref = make_key_ref(key, 1);
575 break; 595 break;
576 596
577 case KEY_SPEC_SESSION_KEYRING: 597 case KEY_SPEC_SESSION_KEYRING:
@@ -579,7 +599,7 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id,
579 /* always install a session keyring upon access if one 599 /* always install a session keyring upon access if one
580 * doesn't exist yet */ 600 * doesn't exist yet */
581 ret = install_session_keyring( 601 ret = install_session_keyring(
582 context, context->user->session_keyring); 602 context, context->user->session_keyring);
583 if (ret < 0) 603 if (ret < 0)
584 goto error; 604 goto error;
585 } 605 }
@@ -588,16 +608,19 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id,
588 key = rcu_dereference(context->signal->session_keyring); 608 key = rcu_dereference(context->signal->session_keyring);
589 atomic_inc(&key->usage); 609 atomic_inc(&key->usage);
590 rcu_read_unlock(); 610 rcu_read_unlock();
611 key_ref = make_key_ref(key, 1);
591 break; 612 break;
592 613
593 case KEY_SPEC_USER_KEYRING: 614 case KEY_SPEC_USER_KEYRING:
594 key = context->user->uid_keyring; 615 key = context->user->uid_keyring;
595 atomic_inc(&key->usage); 616 atomic_inc(&key->usage);
617 key_ref = make_key_ref(key, 1);
596 break; 618 break;
597 619
598 case KEY_SPEC_USER_SESSION_KEYRING: 620 case KEY_SPEC_USER_SESSION_KEYRING:
599 key = context->user->session_keyring; 621 key = context->user->session_keyring;
600 atomic_inc(&key->usage); 622 atomic_inc(&key->usage);
623 key_ref = make_key_ref(key, 1);
601 break; 624 break;
602 625
603 case KEY_SPEC_GROUP_KEYRING: 626 case KEY_SPEC_GROUP_KEYRING:
@@ -606,13 +629,28 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id,
606 goto error; 629 goto error;
607 630
608 default: 631 default:
609 key = ERR_PTR(-EINVAL); 632 key_ref = ERR_PTR(-EINVAL);
610 if (id < 1) 633 if (id < 1)
611 goto error; 634 goto error;
612 635
613 key = key_lookup(id); 636 key = key_lookup(id);
614 if (IS_ERR(key)) 637 if (IS_ERR(key)) {
638 key_ref = ERR_PTR(PTR_ERR(key));
615 goto error; 639 goto error;
640 }
641
642 key_ref = make_key_ref(key, 0);
643
644 /* check to see if we possess the key */
645 skey_ref = search_process_keyrings(key->type, key,
646 lookup_user_key_possessed,
647 current);
648
649 if (!IS_ERR(skey_ref)) {
650 key_put(key);
651 key_ref = skey_ref;
652 }
653
616 break; 654 break;
617 } 655 }
618 656
@@ -630,15 +668,15 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id,
630 /* check the permissions */ 668 /* check the permissions */
631 ret = -EACCES; 669 ret = -EACCES;
632 670
633 if (!key_task_permission(key, context, perm)) 671 if (!key_task_permission(key_ref, context, perm))
634 goto invalid_key; 672 goto invalid_key;
635 673
636 error: 674error:
637 return key; 675 return key_ref;
638 676
639 invalid_key: 677invalid_key:
640 key_put(key); 678 key_ref_put(key_ref);
641 key = ERR_PTR(ret); 679 key_ref = ERR_PTR(ret);
642 goto error; 680 goto error;
643 681
644} /* end lookup_user_key() */ 682} /* end lookup_user_key() */
@@ -694,9 +732,9 @@ long join_session_keyring(const char *name)
694 ret = keyring->serial; 732 ret = keyring->serial;
695 key_put(keyring); 733 key_put(keyring);
696 734
697 error2: 735error2:
698 up(&key_session_sem); 736 up(&key_session_sem);
699 error: 737error:
700 return ret; 738 return ret;
701 739
702} /* end join_session_keyring() */ 740} /* end join_session_keyring() */
diff --git a/security/keys/request_key.c b/security/keys/request_key.c
index 90c1506d007c..5cc4bba70db6 100644
--- a/security/keys/request_key.c
+++ b/security/keys/request_key.c
@@ -7,6 +7,8 @@
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 *
11 * See Documentation/keys-request-key.txt
10 */ 12 */
11 13
12#include <linux/module.h> 14#include <linux/module.h>
@@ -129,7 +131,7 @@ static struct key *__request_key_construction(struct key_type *type,
129 131
130 /* create a key and add it to the queue */ 132 /* create a key and add it to the queue */
131 key = key_alloc(type, description, 133 key = key_alloc(type, description,
132 current->fsuid, current->fsgid, KEY_USR_ALL, 0); 134 current->fsuid, current->fsgid, KEY_POS_ALL, 0);
133 if (IS_ERR(key)) 135 if (IS_ERR(key))
134 goto alloc_failed; 136 goto alloc_failed;
135 137
@@ -365,14 +367,24 @@ struct key *request_key_and_link(struct key_type *type,
365{ 367{
366 struct key_user *user; 368 struct key_user *user;
367 struct key *key; 369 struct key *key;
370 key_ref_t key_ref;
368 371
369 kenter("%s,%s,%s,%p", 372 kenter("%s,%s,%s,%p",
370 type->name, description, callout_info, dest_keyring); 373 type->name, description, callout_info, dest_keyring);
371 374
372 /* search all the process keyrings for a key */ 375 /* search all the process keyrings for a key */
373 key = search_process_keyrings(type, description, type->match, current); 376 key_ref = search_process_keyrings(type, description, type->match,
377 current);
378
379 kdebug("search 1: %p", key_ref);
374 380
375 if (PTR_ERR(key) == -EAGAIN) { 381 if (!IS_ERR(key_ref)) {
382 key = key_ref_to_ptr(key_ref);
383 }
384 else if (PTR_ERR(key_ref) != -EAGAIN) {
385 key = ERR_PTR(PTR_ERR(key_ref));
386 }
387 else {
376 /* the search failed, but the keyrings were searchable, so we 388 /* the search failed, but the keyrings were searchable, so we
377 * should consult userspace if we can */ 389 * should consult userspace if we can */
378 key = ERR_PTR(-ENOKEY); 390 key = ERR_PTR(-ENOKEY);
@@ -384,7 +396,7 @@ struct key *request_key_and_link(struct key_type *type,
384 if (!user) 396 if (!user)
385 goto nomem; 397 goto nomem;
386 398
387 do { 399 for (;;) {
388 if (signal_pending(current)) 400 if (signal_pending(current))
389 goto interrupted; 401 goto interrupted;
390 402
@@ -397,10 +409,22 @@ struct key *request_key_and_link(struct key_type *type,
397 409
398 /* someone else made the key we want, so we need to 410 /* someone else made the key we want, so we need to
399 * search again as it might now be available to us */ 411 * search again as it might now be available to us */
400 key = search_process_keyrings(type, description, 412 key_ref = search_process_keyrings(type, description,
401 type->match, current); 413 type->match,
414 current);
415
416 kdebug("search 2: %p", key_ref);
402 417
403 } while (PTR_ERR(key) == -EAGAIN); 418 if (!IS_ERR(key_ref)) {
419 key = key_ref_to_ptr(key_ref);
420 break;
421 }
422
423 if (PTR_ERR(key_ref) != -EAGAIN) {
424 key = ERR_PTR(PTR_ERR(key_ref));
425 break;
426 }
427 }
404 428
405 key_user_put(user); 429 key_user_put(user);
406 430
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index f22264632229..a8e4069d48cb 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -7,6 +7,8 @@
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 *
11 * See Documentation/keys-request-key.txt
10 */ 12 */
11 13
12#include <linux/module.h> 14#include <linux/module.h>
@@ -96,6 +98,7 @@ static void request_key_auth_destroy(struct key *key)
96 kenter("{%d}", key->serial); 98 kenter("{%d}", key->serial);
97 99
98 key_put(rka->target_key); 100 key_put(rka->target_key);
101 kfree(rka);
99 102
100} /* end request_key_auth_destroy() */ 103} /* end request_key_auth_destroy() */
101 104
@@ -126,7 +129,7 @@ struct key *request_key_auth_new(struct key *target, struct key **_rkakey)
126 129
127 rkakey = key_alloc(&key_type_request_key_auth, desc, 130 rkakey = key_alloc(&key_type_request_key_auth, desc,
128 current->fsuid, current->fsgid, 131 current->fsuid, current->fsgid,
129 KEY_USR_VIEW, 1); 132 KEY_POS_VIEW | KEY_USR_VIEW, 1);
130 if (IS_ERR(rkakey)) { 133 if (IS_ERR(rkakey)) {
131 key_put(keyring); 134 key_put(keyring);
132 kleave("= %ld", PTR_ERR(rkakey)); 135 kleave("= %ld", PTR_ERR(rkakey));
diff --git a/security/seclvl.c b/security/seclvl.c
index dc4e17b6eaf6..1caac0164643 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -252,10 +252,9 @@ passwd_write_file(struct file * file, const char __user * buf,
252 } 252 }
253 253
254 if (count < 0 || count >= PAGE_SIZE) 254 if (count < 0 || count >= PAGE_SIZE)
255 return -ENOMEM;
256 if (*ppos != 0) {
257 return -EINVAL; 255 return -EINVAL;
258 } 256 if (*ppos != 0)
257 return -EINVAL;
259 page = (char *)get_zeroed_page(GFP_KERNEL); 258 page = (char *)get_zeroed_page(GFP_KERNEL);
260 if (!page) 259 if (!page)
261 return -ENOMEM; 260 return -ENOMEM;
@@ -265,9 +264,8 @@ passwd_write_file(struct file * file, const char __user * buf,
265 264
266 len = strlen(page); 265 len = strlen(page);
267 /* ``echo "secret" > seclvl/passwd'' includes a newline */ 266 /* ``echo "secret" > seclvl/passwd'' includes a newline */
268 if (page[len - 1] == '\n') { 267 if (page[len - 1] == '\n')
269 len--; 268 len--;
270 }
271 /* Hash the password, then compare the hashed values */ 269 /* Hash the password, then compare the hashed values */
272 if ((rc = plaintext_to_sha1(tmp, page, len))) { 270 if ((rc = plaintext_to_sha1(tmp, page, len))) {
273 seclvl_printk(0, KERN_ERR, "Error hashing password: rc = " 271 seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
@@ -275,9 +273,8 @@ passwd_write_file(struct file * file, const char __user * buf,
275 return rc; 273 return rc;
276 } 274 }
277 for (i = 0; i < SHA1_DIGEST_SIZE; i++) { 275 for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
278 if (hashedPassword[i] != tmp[i]) { 276 if (hashedPassword[i] != tmp[i])
279 return -EPERM; 277 return -EPERM;
280 }
281 } 278 }
282 seclvl_printk(0, KERN_INFO, 279 seclvl_printk(0, KERN_INFO,
283 "Password accepted; seclvl reduced to 0.\n"); 280 "Password accepted; seclvl reduced to 0.\n");
@@ -482,9 +479,8 @@ static void seclvl_file_free_security(struct file *filp)
482 */ 479 */
483static int seclvl_umount(struct vfsmount *mnt, int flags) 480static int seclvl_umount(struct vfsmount *mnt, int flags)
484{ 481{
485 if (current->pid == 1) { 482 if (current->pid == 1)
486 return 0; 483 return 0;
487 }
488 if (seclvl == 2) { 484 if (seclvl == 2) {
489 seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure " 485 seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure "
490 "level %d\n", seclvl); 486 "level %d\n", seclvl);
@@ -638,9 +634,8 @@ static int __init seclvl_init(void)
638static void __exit seclvl_exit(void) 634static void __exit seclvl_exit(void)
639{ 635{
640 securityfs_remove(seclvl_ino); 636 securityfs_remove(seclvl_ino);
641 if (*passwd || *sha1_passwd) { 637 if (*passwd || *sha1_passwd)
642 securityfs_remove(passwd_ino); 638 securityfs_remove(passwd_ino);
643 }
644 securityfs_remove(dir_ino); 639 securityfs_remove(dir_ino);
645 if (secondary == 1) { 640 if (secondary == 1) {
646 mod_unreg_security(MY_NAME, &seclvl_ops); 641 mod_unreg_security(MY_NAME, &seclvl_ops);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 6e4937fe062b..b13be15165f5 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -630,6 +630,16 @@ static inline u16 inode_mode_to_security_class(umode_t mode)
630 return SECCLASS_FILE; 630 return SECCLASS_FILE;
631} 631}
632 632
633static inline int default_protocol_stream(int protocol)
634{
635 return (protocol == IPPROTO_IP || protocol == IPPROTO_TCP);
636}
637
638static inline int default_protocol_dgram(int protocol)
639{
640 return (protocol == IPPROTO_IP || protocol == IPPROTO_UDP);
641}
642
633static inline u16 socket_type_to_security_class(int family, int type, int protocol) 643static inline u16 socket_type_to_security_class(int family, int type, int protocol)
634{ 644{
635 switch (family) { 645 switch (family) {
@@ -646,10 +656,16 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
646 case PF_INET6: 656 case PF_INET6:
647 switch (type) { 657 switch (type) {
648 case SOCK_STREAM: 658 case SOCK_STREAM:
649 return SECCLASS_TCP_SOCKET; 659 if (default_protocol_stream(protocol))
660 return SECCLASS_TCP_SOCKET;
661 else
662 return SECCLASS_RAWIP_SOCKET;
650 case SOCK_DGRAM: 663 case SOCK_DGRAM:
651 return SECCLASS_UDP_SOCKET; 664 if (default_protocol_dgram(protocol))
652 case SOCK_RAW: 665 return SECCLASS_UDP_SOCKET;
666 else
667 return SECCLASS_RAWIP_SOCKET;
668 default:
653 return SECCLASS_RAWIP_SOCKET; 669 return SECCLASS_RAWIP_SOCKET;
654 } 670 }
655 break; 671 break;
@@ -2970,6 +2986,8 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
2970 2986
2971 /* 2987 /*
2972 * If PF_INET or PF_INET6, check name_bind permission for the port. 2988 * If PF_INET or PF_INET6, check name_bind permission for the port.
2989 * Multiple address binding for SCTP is not supported yet: we just
2990 * check the first address now.
2973 */ 2991 */
2974 family = sock->sk->sk_family; 2992 family = sock->sk->sk_family;
2975 if (family == PF_INET || family == PF_INET6) { 2993 if (family == PF_INET || family == PF_INET6) {
@@ -3014,12 +3032,12 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
3014 goto out; 3032 goto out;
3015 } 3033 }
3016 3034
3017 switch(sk->sk_protocol) { 3035 switch(isec->sclass) {
3018 case IPPROTO_TCP: 3036 case SECCLASS_TCP_SOCKET:
3019 node_perm = TCP_SOCKET__NODE_BIND; 3037 node_perm = TCP_SOCKET__NODE_BIND;
3020 break; 3038 break;
3021 3039
3022 case IPPROTO_UDP: 3040 case SECCLASS_UDP_SOCKET:
3023 node_perm = UDP_SOCKET__NODE_BIND; 3041 node_perm = UDP_SOCKET__NODE_BIND;
3024 break; 3042 break;
3025 3043
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 8eb140dd2e4b..a45cc971e735 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -879,7 +879,7 @@ static ssize_t sel_commit_bools_write(struct file *filep,
879 if (sscanf(page, "%d", &new_value) != 1) 879 if (sscanf(page, "%d", &new_value) != 1)
880 goto out; 880 goto out;
881 881
882 if (new_value) { 882 if (new_value && bool_pending_values) {
883 security_set_bools(bool_num, bool_pending_values); 883 security_set_bools(bool_num, bool_pending_values);
884 } 884 }
885 885
@@ -952,6 +952,7 @@ static int sel_make_bools(void)
952 952
953 /* remove any existing files */ 953 /* remove any existing files */
954 kfree(bool_pending_values); 954 kfree(bool_pending_values);
955 bool_pending_values = NULL;
955 956
956 sel_remove_bools(dir); 957 sel_remove_bools(dir);
957 958
@@ -1002,6 +1003,7 @@ out:
1002 } 1003 }
1003 return ret; 1004 return ret;
1004err: 1005err:
1006 kfree(values);
1005 d_genocide(dir); 1007 d_genocide(dir);
1006 ret = -ENOMEM; 1008 ret = -ENOMEM;
1007 goto out; 1009 goto out;
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 0a758323a9cf..8e6262d12aa9 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -650,8 +650,10 @@ void policydb_destroy(struct policydb *p)
650 } 650 }
651 if (lrt) kfree(lrt); 651 if (lrt) kfree(lrt);
652 652
653 for (i = 0; i < p->p_types.nprim; i++) 653 if (p->type_attr_map) {
654 ebitmap_destroy(&p->type_attr_map[i]); 654 for (i = 0; i < p->p_types.nprim; i++)
655 ebitmap_destroy(&p->type_attr_map[i]);
656 }
655 kfree(p->type_attr_map); 657 kfree(p->type_attr_map);
656 658
657 return; 659 return;
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 34195b748608..b2d5db20ec8c 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -650,7 +650,7 @@ static int aaci_do_resume(snd_card_t *card, unsigned int state)
650 return 0; 650 return 0;
651} 651}
652 652
653static int aaci_suspend(struct amba_device *dev, u32 state) 653static int aaci_suspend(struct amba_device *dev, pm_message_t state)
654{ 654{
655 snd_card_t *card = amba_get_drvdata(dev); 655 snd_card_t *card = amba_get_drvdata(dev);
656 return card ? aaci_do_suspend(card) : 0; 656 return card ? aaci_do_suspend(card) : 0;
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 29450befb5da..38b20efc9c0b 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -245,7 +245,7 @@ static pxa2xx_pcm_client_t pxa2xx_ac97_pcm_client = {
245 245
246#ifdef CONFIG_PM 246#ifdef CONFIG_PM
247 247
248static int pxa2xx_ac97_do_suspend(snd_card_t *card, unsigned int state) 248static int pxa2xx_ac97_do_suspend(snd_card_t *card, pm_message_t state)
249{ 249{
250 if (card->power_state != SNDRV_CTL_POWER_D3cold) { 250 if (card->power_state != SNDRV_CTL_POWER_D3cold) {
251 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; 251 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data;
diff --git a/sound/core/init.c b/sound/core/init.c
index a5702014a704..c72a79115cca 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -828,7 +828,8 @@ static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level
828 card = get_snd_generic_card(dev); 828 card = get_snd_generic_card(dev);
829 if (card->power_state == SNDRV_CTL_POWER_D3hot) 829 if (card->power_state == SNDRV_CTL_POWER_D3hot)
830 return 0; 830 return 0;
831 card->pm_suspend(card, PMSG_SUSPEND); 831 if (card->pm_suspend)
832 card->pm_suspend(card, PMSG_SUSPEND);
832 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 833 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
833 return 0; 834 return 0;
834} 835}
@@ -843,7 +844,8 @@ static int snd_generic_resume(struct device *dev, u32 level)
843 card = get_snd_generic_card(dev); 844 card = get_snd_generic_card(dev);
844 if (card->power_state == SNDRV_CTL_POWER_D0) 845 if (card->power_state == SNDRV_CTL_POWER_D0)
845 return 0; 846 return 0;
846 card->pm_resume(card); 847 if (card->pm_suspend)
848 card->pm_resume(card);
847 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 849 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
848 return 0; 850 return 0;
849} 851}
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 91124ddbdda9..e72cec77f0db 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -106,7 +106,7 @@ struct snd_mem_list {
106 106
107static void *snd_dma_hack_alloc_coherent(struct device *dev, size_t size, 107static void *snd_dma_hack_alloc_coherent(struct device *dev, size_t size,
108 dma_addr_t *dma_handle, 108 dma_addr_t *dma_handle,
109 unsigned int __nocast flags) 109 gfp_t flags)
110{ 110{
111 void *ret; 111 void *ret;
112 u64 dma_mask, coherent_dma_mask; 112 u64 dma_mask, coherent_dma_mask;
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 8fa888fc53a0..7d8e2eebba51 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -89,7 +89,7 @@ void snd_memory_done(void)
89 } 89 }
90} 90}
91 91
92static void *__snd_kmalloc(size_t size, unsigned int __nocast flags, void *caller) 92static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller)
93{ 93{
94 unsigned long cpu_flags; 94 unsigned long cpu_flags;
95 struct snd_alloc_track *t; 95 struct snd_alloc_track *t;
@@ -111,12 +111,12 @@ static void *__snd_kmalloc(size_t size, unsigned int __nocast flags, void *calle
111} 111}
112 112
113#define _snd_kmalloc(size, flags) __snd_kmalloc((size), (flags), __builtin_return_address(0)); 113#define _snd_kmalloc(size, flags) __snd_kmalloc((size), (flags), __builtin_return_address(0));
114void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags) 114void *snd_hidden_kmalloc(size_t size, gfp_t flags)
115{ 115{
116 return _snd_kmalloc(size, flags); 116 return _snd_kmalloc(size, flags);
117} 117}
118 118
119void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags) 119void *snd_hidden_kzalloc(size_t size, gfp_t flags)
120{ 120{
121 void *ret = _snd_kmalloc(size, flags); 121 void *ret = _snd_kmalloc(size, flags);
122 if (ret) 122 if (ret)
@@ -125,7 +125,7 @@ void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags)
125} 125}
126EXPORT_SYMBOL(snd_hidden_kzalloc); 126EXPORT_SYMBOL(snd_hidden_kzalloc);
127 127
128void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags) 128void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags)
129{ 129{
130 void *ret = NULL; 130 void *ret = NULL;
131 if (n != 0 && size > INT_MAX / n) 131 if (n != 0 && size > INT_MAX / n)
@@ -190,7 +190,7 @@ void snd_hidden_vfree(void *obj)
190 snd_wrapper_vfree(obj); 190 snd_wrapper_vfree(obj);
191} 191}
192 192
193char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags) 193char *snd_hidden_kstrdup(const char *s, gfp_t flags)
194{ 194{
195 int len; 195 int len;
196 char *buf; 196 char *buf;
diff --git a/sound/core/seq/instr/ainstr_iw.c b/sound/core/seq/instr/ainstr_iw.c
index b3cee092b1a4..67c24c8e8e7b 100644
--- a/sound/core/seq/instr/ainstr_iw.c
+++ b/sound/core/seq/instr/ainstr_iw.c
@@ -58,7 +58,7 @@ static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype,
58 iwffff_xenv_t *ex, 58 iwffff_xenv_t *ex,
59 char __user **data, 59 char __user **data,
60 long *len, 60 long *len,
61 unsigned int __nocast gfp_mask) 61 gfp_t gfp_mask)
62{ 62{
63 __u32 stype; 63 __u32 stype;
64 iwffff_env_record_t *rp, *rp_last; 64 iwffff_env_record_t *rp, *rp_last;
diff --git a/sound/core/wrappers.c b/sound/core/wrappers.c
index 508e6d67ee19..296b716f1376 100644
--- a/sound/core/wrappers.c
+++ b/sound/core/wrappers.c
@@ -27,7 +27,7 @@
27#include <linux/fs.h> 27#include <linux/fs.h>
28 28
29#ifdef CONFIG_SND_DEBUG_MEMORY 29#ifdef CONFIG_SND_DEBUG_MEMORY
30void *snd_wrapper_kmalloc(size_t size, unsigned int __nocast flags) 30void *snd_wrapper_kmalloc(size_t size, gfp_t flags)
31{ 31{
32 return kmalloc(size, flags); 32 return kmalloc(size, flags);
33} 33}
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index e2d2babcd20b..4ba268f251e3 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -914,6 +914,7 @@ static int __init alsa_card_opl3sa2_init(void)
914#endif 914#endif
915#ifdef CONFIG_PNP 915#ifdef CONFIG_PNP
916 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 916 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
917 pnp_unregister_driver(&opl3sa2_pnp_driver);
917#endif 918#endif
918 return -ENODEV; 919 return -ENODEV;
919 } 920 }
@@ -927,6 +928,7 @@ static void __exit alsa_card_opl3sa2_exit(void)
927#ifdef CONFIG_PNP 928#ifdef CONFIG_PNP
928 /* PnP cards first */ 929 /* PnP cards first */
929 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 930 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
931 pnp_unregister_driver(&opl3sa2_pnp_driver);
930#endif 932#endif
931 for (idx = 0; idx < SNDRV_CARDS; idx++) 933 for (idx = 0; idx < SNDRV_CARDS; idx++)
932 snd_card_free(snd_opl3sa2_legacy[idx]); 934 snd_card_free(snd_opl3sa2_legacy[idx]);
diff --git a/sound/oss/au1000.c b/sound/oss/au1000.c
index 4491733c9e4e..2c2ae2ee01ac 100644
--- a/sound/oss/au1000.c
+++ b/sound/oss/au1000.c
@@ -1295,7 +1295,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
1295 unsigned long size; 1295 unsigned long size;
1296 int ret = 0; 1296 int ret = 0;
1297 1297
1298 dbg(__FUNCTION__); 1298 dbg("%s", __FUNCTION__);
1299 1299
1300 lock_kernel(); 1300 lock_kernel();
1301 down(&s->sem); 1301 down(&s->sem);
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c
index 58f879fda975..26e5944b6ba8 100644
--- a/sound/oss/ite8172.c
+++ b/sound/oss/ite8172.c
@@ -1859,7 +1859,7 @@ static int it8172_release(struct inode *inode, struct file *file)
1859 struct it8172_state *s = (struct it8172_state *)file->private_data; 1859 struct it8172_state *s = (struct it8172_state *)file->private_data;
1860 1860
1861#ifdef IT8172_VERBOSE_DEBUG 1861#ifdef IT8172_VERBOSE_DEBUG
1862 dbg(__FUNCTION__); 1862 dbg("%s", __FUNCTION__);
1863#endif 1863#endif
1864 lock_kernel(); 1864 lock_kernel();
1865 if (file->f_mode & FMODE_WRITE) 1865 if (file->f_mode & FMODE_WRITE)
diff --git a/sound/pci/ac97/ac97_bus.c b/sound/pci/ac97/ac97_bus.c
index 227f8b9f67ce..becbc420ba41 100644
--- a/sound/pci/ac97/ac97_bus.c
+++ b/sound/pci/ac97/ac97_bus.c
@@ -17,25 +17,21 @@
17#include <linux/string.h> 17#include <linux/string.h>
18 18
19/* 19/*
20 * Codec families have names seperated by commas, so we search for an 20 * Let drivers decide whether they want to support given codec from their
21 * individual codec name within the family string. 21 * probe method. Drivers have direct access to the ac97_t structure and may
22 * decide based on the id field amongst other things.
22 */ 23 */
23static int ac97_bus_match(struct device *dev, struct device_driver *drv) 24static int ac97_bus_match(struct device *dev, struct device_driver *drv)
24{ 25{
25 return (strstr(dev->bus_id, drv->name) != NULL); 26 return 1;
26} 27}
27 28
28static int ac97_bus_suspend(struct device *dev, pm_message_t state) 29static int ac97_bus_suspend(struct device *dev, pm_message_t state)
29{ 30{
30 int ret = 0; 31 int ret = 0;
31 32
32 if (dev->driver && dev->driver->suspend) { 33 if (dev->driver && dev->driver->suspend)
33 ret = dev->driver->suspend(dev, state, SUSPEND_DISABLE); 34 ret = dev->driver->suspend(dev, state, SUSPEND_POWER_DOWN);
34 if (ret == 0)
35 ret = dev->driver->suspend(dev, state, SUSPEND_SAVE_STATE);
36 if (ret == 0)
37 ret = dev->driver->suspend(dev, state, SUSPEND_POWER_DOWN);
38 }
39 return ret; 35 return ret;
40} 36}
41 37
@@ -43,13 +39,8 @@ static int ac97_bus_resume(struct device *dev)
43{ 39{
44 int ret = 0; 40 int ret = 0;
45 41
46 if (dev->driver && dev->driver->resume) { 42 if (dev->driver && dev->driver->resume)
47 ret = dev->driver->resume(dev, RESUME_POWER_ON); 43 ret = dev->driver->resume(dev, RESUME_POWER_ON);
48 if (ret == 0)
49 ret = dev->driver->resume(dev, RESUME_RESTORE_STATE);
50 if (ret == 0)
51 ret = dev->driver->resume(dev, RESUME_ENABLE);
52 }
53 return ret; 44 return ret;
54} 45}
55 46
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index e64cb07a39c2..41fc290149ed 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1557,7 +1557,7 @@ static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97)
1557 1557
1558 /* build modem switches */ 1558 /* build modem switches */
1559 for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_modem_switches); idx++) 1559 for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_modem_switches); idx++)
1560 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_modem_switches[idx], ac97))) < 0) 1560 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ac97_controls_modem_switches[idx], ac97))) < 0)
1561 return err; 1561 return err;
1562 1562
1563 /* build chip specific controls */ 1563 /* build chip specific controls */
@@ -1828,7 +1828,6 @@ static int snd_ac97_dev_register(snd_device_t *device)
1828 1828
1829 ac97->dev.bus = &ac97_bus_type; 1829 ac97->dev.bus = &ac97_bus_type;
1830 ac97->dev.parent = ac97->bus->card->dev; 1830 ac97->dev.parent = ac97->bus->card->dev;
1831 ac97->dev.platform_data = ac97;
1832 ac97->dev.release = ac97_device_release; 1831 ac97->dev.release = ac97_device_release;
1833 snprintf(ac97->dev.bus_id, BUS_ID_SIZE, "card%d-%d", ac97->bus->card->number, ac97->num); 1832 snprintf(ac97->dev.bus_id, BUS_ID_SIZE, "card%d-%d", ac97->bus->card->number, ac97->num);
1834 if ((err = device_register(&ac97->dev)) < 0) { 1833 if ((err = device_register(&ac97->dev)) < 0) {
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 045ddc743edc..0238cc65d32a 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -2752,7 +2752,11 @@ AC97_DOUBLE("Modem Speaker Volume", 0x5c, 14, 12, 3, 1)
2752 2752
2753static int patch_si3036_specific(ac97_t * ac97) 2753static int patch_si3036_specific(ac97_t * ac97)
2754{ 2754{
2755 return patch_build_controls(ac97, snd_ac97_controls_si3036, ARRAY_SIZE(snd_ac97_controls_si3036)); 2755 int idx, err;
2756 for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_si3036); idx++)
2757 if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97))) < 0)
2758 return err;
2759 return 0;
2756} 2760}
2757 2761
2758static struct snd_ac97_build_ops patch_si3036_ops = { 2762static struct snd_ac97_build_ops patch_si3036_ops = {
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index d683f7736a63..f35b558c29b2 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -1993,8 +1993,10 @@ static int __devinit snd_ali_mixer(ali_t * codec)
1993 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { 1993 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) {
1994 snd_printk("ali mixer %d creating error.\n", i); 1994 snd_printk("ali mixer %d creating error.\n", i);
1995 if(i == 0) 1995 if(i == 0)
1996 return err; 1996 return err;
1997 } 1997 codec->num_of_codecs = 1;
1998 break;
1999 }
1998 } 2000 }
1999 2001
2000 if (codec->spdif_support) { 2002 if (codec->spdif_support) {
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 8a59598167f9..c1a239a4dac6 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -405,7 +405,7 @@ static int snd_atiixp_acquire_codec(atiixp_t *chip)
405 405
406 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) { 406 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) {
407 if (! timeout--) { 407 if (! timeout--) {
408 snd_printk(KERN_WARNING "atiixp: codec acquire timeout\n"); 408 snd_printk(KERN_WARNING "atiixp-modem: codec acquire timeout\n");
409 return -EBUSY; 409 return -EBUSY;
410 } 410 }
411 udelay(1); 411 udelay(1);
@@ -436,7 +436,7 @@ static unsigned short snd_atiixp_codec_read(atiixp_t *chip, unsigned short codec
436 } while (--timeout); 436 } while (--timeout);
437 /* time out may happen during reset */ 437 /* time out may happen during reset */
438 if (reg < 0x7c) 438 if (reg < 0x7c)
439 snd_printk(KERN_WARNING "atiixp: codec read timeout (reg %x)\n", reg); 439 snd_printk(KERN_WARNING "atiixp-modem: codec read timeout (reg %x)\n", reg);
440 return 0xffff; 440 return 0xffff;
441} 441}
442 442
@@ -498,7 +498,7 @@ static int snd_atiixp_aclink_reset(atiixp_t *chip)
498 do_delay(); 498 do_delay();
499 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); 499 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
500 if (--timeout) { 500 if (--timeout) {
501 snd_printk(KERN_ERR "atiixp: codec reset timeout\n"); 501 snd_printk(KERN_ERR "atiixp-modem: codec reset timeout\n");
502 break; 502 break;
503 } 503 }
504 } 504 }
@@ -552,7 +552,7 @@ static int snd_atiixp_codec_detect(atiixp_t *chip)
552 atiixp_write(chip, IER, 0); /* disable irqs */ 552 atiixp_write(chip, IER, 0); /* disable irqs */
553 553
554 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) { 554 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) {
555 snd_printk(KERN_ERR "atiixp: no codec detected!\n"); 555 snd_printk(KERN_ERR "atiixp-modem: no codec detected!\n");
556 return -ENXIO; 556 return -ENXIO;
557 } 557 }
558 return 0; 558 return 0;
@@ -635,7 +635,7 @@ static void snd_atiixp_xrun_dma(atiixp_t *chip, atiixp_dma_t *dma)
635{ 635{
636 if (! dma->substream || ! dma->running) 636 if (! dma->substream || ! dma->running)
637 return; 637 return;
638 snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type); 638 snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type);
639 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); 639 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
640} 640}
641 641
@@ -1081,14 +1081,14 @@ static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock)
1081 ac97.scaps = AC97_SCAP_SKIP_AUDIO; 1081 ac97.scaps = AC97_SCAP_SKIP_AUDIO;
1082 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { 1082 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
1083 chip->ac97[i] = NULL; /* to be sure */ 1083 chip->ac97[i] = NULL; /* to be sure */
1084 snd_printdd("atiixp: codec %d not available for modem\n", i); 1084 snd_printdd("atiixp-modem: codec %d not available for modem\n", i);
1085 continue; 1085 continue;
1086 } 1086 }
1087 codec_count++; 1087 codec_count++;
1088 } 1088 }
1089 1089
1090 if (! codec_count) { 1090 if (! codec_count) {
1091 snd_printk(KERN_ERR "atiixp: no codec available\n"); 1091 snd_printk(KERN_ERR "atiixp-modem: no codec available\n");
1092 return -ENODEV; 1092 return -ENODEV;
1093 } 1093 }
1094 1094
@@ -1159,7 +1159,7 @@ static void __devinit snd_atiixp_proc_init(atiixp_t *chip)
1159{ 1159{
1160 snd_info_entry_t *entry; 1160 snd_info_entry_t *entry;
1161 1161
1162 if (! snd_card_proc_new(chip->card, "atiixp", &entry)) 1162 if (! snd_card_proc_new(chip->card, "atiixp-modem", &entry))
1163 snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read); 1163 snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read);
1164} 1164}
1165 1165
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index e87e8427f25f..e9cd8e054f25 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -756,9 +756,12 @@ static emu_chip_details_t emu_chip_details[] = {
756 .sblive51 = 1} , 756 .sblive51 = 1} ,
757 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ 757 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */
758 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 758 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
759 .driver = "EMU10K1", .name = "SBLive! Platinum 5.1 [SB0060]", 759 .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]",
760 .id = "Live", 760 .id = "Live",
761 .emu10k1_chip = 1, 761 .emu10k1_chip = 1,
762 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum
763 * share the same IDs!
764 */
762 .sblive51 = 1} , 765 .sblive51 = 1} ,
763 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 766 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
764 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 767 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]",
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index d71a72e84bcc..7cc831ccd0cb 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -810,8 +810,14 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu,
810 ac97.private_data = emu; 810 ac97.private_data = emu;
811 ac97.private_free = snd_emu10k1_mixer_free_ac97; 811 ac97.private_free = snd_emu10k1_mixer_free_ac97;
812 ac97.scaps = AC97_SCAP_NO_SPDIF; 812 ac97.scaps = AC97_SCAP_NO_SPDIF;
813 if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) 813 if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) {
814 return err; 814 if (emu->card_capabilities->ac97_chip == 1)
815 return err;
816 snd_printd(KERN_INFO "emu10k1: AC97 is optional on this board\n");
817 snd_printd(KERN_INFO" Proceeding without ac97 mixers...\n");
818 snd_device_free(emu->card, pbus);
819 goto no_ac97; /* FIXME: get rid of ugly gotos.. */
820 }
815 if (emu->audigy) { 821 if (emu->audigy) {
816 /* set master volume to 0 dB */ 822 /* set master volume to 0 dB */
817 snd_ac97_write(emu->ac97, AC97_MASTER, 0x0000); 823 snd_ac97_write(emu->ac97, AC97_MASTER, 0x0000);
@@ -836,6 +842,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu,
836 for (; *c; c++) 842 for (; *c; c++)
837 remove_ctl(card, *c); 843 remove_ctl(card, *c);
838 } else { 844 } else {
845 no_ac97:
839 if (emu->card_capabilities->ecard) 846 if (emu->card_capabilities->ecard)
840 strcpy(emu->card->mixername, "EMU APS"); 847 strcpy(emu->card->mixername, "EMU APS");
841 else if (emu->audigy) 848 else if (emu->audigy)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 5b829a1a4c60..d0eb9f2250aa 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -881,10 +881,8 @@ int snd_hda_parse_generic_codec(struct hda_codec *codec)
881 struct hda_gspec *spec; 881 struct hda_gspec *spec;
882 int err; 882 int err;
883 883
884 if(!codec->afg) { 884 if(!codec->afg)
885 snd_printdd("hda_generic: no generic modem yet\n"); 885 return 0;
886 return -ENODEV;
887 }
888 886
889 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
890 if (spec == NULL) { 888 if (spec == NULL) {
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 9590ece2099d..6fe696e53ea6 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1137,6 +1137,7 @@ static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream)
1137 pos = azx_sd_readl(azx_dev, SD_LPIB); 1137 pos = azx_sd_readl(azx_dev, SD_LPIB);
1138 if (chip->position_fix == POS_FIX_FIFO) 1138 if (chip->position_fix == POS_FIX_FIFO)
1139 pos += azx_dev->fifo_size; 1139 pos += azx_dev->fifo_size;
1140#if 0 /* disabled temprarily, auto-correction doesn't work well... */
1140 else if (chip->position_fix == POS_FIX_AUTO && azx_dev->period_updating) { 1141 else if (chip->position_fix == POS_FIX_AUTO && azx_dev->period_updating) {
1141 /* check the validity of DMA position */ 1142 /* check the validity of DMA position */
1142 unsigned int diff = 0; 1143 unsigned int diff = 0;
@@ -1157,6 +1158,10 @@ static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream)
1157 } 1158 }
1158 azx_dev->period_updating = 0; 1159 azx_dev->period_updating = 0;
1159 } 1160 }
1161#else
1162 else if (chip->position_fix == POS_FIX_AUTO)
1163 pos += azx_dev->fifo_size;
1164#endif
1160 } 1165 }
1161 if (pos >= azx_dev->bufsize) 1166 if (pos >= azx_dev->bufsize)
1162 pos = 0; 1167 pos = 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 849b5b50c921..7327deb6df9f 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1385,8 +1385,8 @@ static snd_kcontrol_new_t alc880_test_mixer[] = {
1385 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1385 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1386 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1386 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1387 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1387 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1388 ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT), 1388 ALC_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1389 ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT), 1389 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1390 PIN_CTL_TEST("Front Pin Mode", 0x14), 1390 PIN_CTL_TEST("Front Pin Mode", 0x14),
1391 PIN_CTL_TEST("Surround Pin Mode", 0x15), 1391 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1392 PIN_CTL_TEST("CLFE Pin Mode", 0x16), 1392 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
@@ -1409,18 +1409,6 @@ static snd_kcontrol_new_t alc880_test_mixer[] = {
1409 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), 1409 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1410 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), 1410 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1411 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), 1411 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1412 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1413 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1414 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1415 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1416 {
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = "Input Source",
1419 .count = 2,
1420 .info = alc_mux_enum_info,
1421 .get = alc_mux_enum_get,
1422 .put = alc_mux_enum_put,
1423 },
1424 { 1412 {
1425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1413 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1426 .name = "Channel Mode", 1414 .name = "Channel Mode",
@@ -2243,7 +2231,7 @@ static snd_kcontrol_new_t alc260_base_mixer[] = {
2243 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2231 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2244 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 2232 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 2233 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2246 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT), 2234 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2247 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 2235 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2248 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), 2236 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2249 { 2237 {
@@ -2270,7 +2258,7 @@ static snd_kcontrol_new_t alc260_hp_mixer[] = {
2270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2258 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2271 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 2259 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2272 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 2260 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2273 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT), 2261 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2274 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), 2262 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2275 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), 2263 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2276 { 2264 {
@@ -2501,7 +2489,7 @@ static snd_kcontrol_new_t alc882_base_mixer[] = {
2501 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 2489 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2502 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 2490 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2503 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 2491 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2504 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT), 2492 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2505 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2493 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2506 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 2494 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2507 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 2495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 09f9cbe116a3..5561fd4091e8 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -442,7 +442,7 @@ static char* stateName[] = {
442 "Setup for play", 442 "Setup for play",
443 "Playing", 443 "Playing",
444 "Monitor mode on", 444 "Monitor mode on",
445 "Calibrating" 445 "Calibrating",
446 "Invalid" 446 "Invalid"
447}; 447};
448 448
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 6db7de6b9719..3c0205b91e10 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2147,11 +2147,13 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2147 { .subvendor = 0x1019, .subdevice = 0x0996, .action = VIA_DXS_48K }, 2147 { .subvendor = 0x1019, .subdevice = 0x0996, .action = VIA_DXS_48K },
2148 { .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */ 2148 { .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */
2149 { .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */ 2149 { .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */
2150 { .subvendor = 0x1019, .subdevice = 0xa101, .action = VIA_DXS_SRC },
2150 { .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */ 2151 { .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */
2151 { .subvendor = 0x1025, .subdevice = 0x0046, .action = VIA_DXS_SRC }, /* Acer Aspire 1524 WLMi */ 2152 { .subvendor = 0x1025, .subdevice = 0x0046, .action = VIA_DXS_SRC }, /* Acer Aspire 1524 WLMi */
2152 { .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/ 2153 { .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/
2153 { .subvendor = 0x1043, .subdevice = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */ 2154 { .subvendor = 0x1043, .subdevice = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */
2154 { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ 2155 { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/
2156 { .subvendor = 0x1043, .subdevice = 0x810d, .action = VIA_DXS_SRC }, /* ASUS */
2155 { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */ 2157 { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */
2156 { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ 2158 { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */
2157 { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */ 2159 { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index e35b48d29c45..392b2abd9f13 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -988,6 +988,7 @@ static int __init snd_pmac_detect(pmac_t *chip)
988 case 0x33: 988 case 0x33:
989 case 0x29: 989 case 0x29:
990 case 0x24: 990 case 0x24:
991 case 0x50:
991 case 0x5c: 992 case 0x5c:
992 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); 993 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
993 chip->model = PMAC_SNAPPER; 994 chip->model = PMAC_SNAPPER;
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 2fb27c4e951f..f4361c518e46 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -173,7 +173,7 @@ static cs4231_t *cs4231_list;
173 173
174#define CS4231_GLOBALIRQ 0x01 /* IRQ is active */ 174#define CS4231_GLOBALIRQ 0x01 /* IRQ is active */
175 175
176/* definitions for codec irq status */ 176/* definitions for codec irq status - CS4231_IRQ_STATUS */
177 177
178#define CS4231_PLAYBACK_IRQ 0x10 178#define CS4231_PLAYBACK_IRQ 0x10
179#define CS4231_RECORD_IRQ 0x20 179#define CS4231_RECORD_IRQ 0x20
@@ -402,7 +402,7 @@ static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg,
402 udelay(100); 402 udelay(100);
403#ifdef CONFIG_SND_DEBUG 403#ifdef CONFIG_SND_DEBUG
404 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) 404 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
405 snd_printk("outm: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value); 405 snd_printdd("outm: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value);
406#endif 406#endif
407 if (chip->calibrate_mute) { 407 if (chip->calibrate_mute) {
408 chip->image[reg] &= mask; 408 chip->image[reg] &= mask;
@@ -425,6 +425,10 @@ static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char val
425 timeout > 0 && (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT); 425 timeout > 0 && (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT);
426 timeout--) 426 timeout--)
427 udelay(100); 427 udelay(100);
428#ifdef CONFIG_SND_DEBUG
429 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
430 snd_printdd("out: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value);
431#endif
428 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231P(chip, REGSEL)); 432 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231P(chip, REGSEL));
429 __cs4231_writeb(chip, value, CS4231P(chip, REG)); 433 __cs4231_writeb(chip, value, CS4231P(chip, REG));
430 mb(); 434 mb();
@@ -440,15 +444,12 @@ static void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char valu
440 udelay(100); 444 udelay(100);
441#ifdef CONFIG_SND_DEBUG 445#ifdef CONFIG_SND_DEBUG
442 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) 446 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
443 snd_printk("out: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value); 447 snd_printdd("out: auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value);
444#endif 448#endif
445 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231P(chip, REGSEL)); 449 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231P(chip, REGSEL));
446 __cs4231_writeb(chip, value, CS4231P(chip, REG)); 450 __cs4231_writeb(chip, value, CS4231P(chip, REG));
447 chip->image[reg] = value; 451 chip->image[reg] = value;
448 mb(); 452 mb();
449#if 0
450 printk("codec out - reg 0x%x = 0x%x\n", chip->mce_bit | reg, value);
451#endif
452} 453}
453 454
454static unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) 455static unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg)
@@ -462,61 +463,14 @@ static unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg)
462 udelay(100); 463 udelay(100);
463#ifdef CONFIG_SND_DEBUG 464#ifdef CONFIG_SND_DEBUG
464 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) 465 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
465 snd_printk("in: auto calibration time out - reg = 0x%x\n", reg); 466 snd_printdd("in: auto calibration time out - reg = 0x%x\n", reg);
466#endif 467#endif
467 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231P(chip, REGSEL)); 468 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231P(chip, REGSEL));
468 mb(); 469 mb();
469 ret = __cs4231_readb(chip, CS4231P(chip, REG)); 470 ret = __cs4231_readb(chip, CS4231P(chip, REG));
470#if 0
471 printk("codec in - reg 0x%x = 0x%x\n", chip->mce_bit | reg, ret);
472#endif
473 return ret; 471 return ret;
474} 472}
475 473
476#if 0
477
478static void snd_cs4231_debug(cs4231_t *chip)
479{
480 printk("CS4231 REGS: INDEX = 0x%02x ",
481 __cs4231_readb(chip, CS4231P(chip, REGSEL)));
482 printk(" STATUS = 0x%02x\n",
483 __cs4231_readb(chip, CS4231P(chip, STATUS)));
484 printk(" 0x00: left input = 0x%02x ", snd_cs4231_in(chip, 0x00));
485 printk(" 0x10: alt 1 (CFIG 2) = 0x%02x\n", snd_cs4231_in(chip, 0x10));
486 printk(" 0x01: right input = 0x%02x ", snd_cs4231_in(chip, 0x01));
487 printk(" 0x11: alt 2 (CFIG 3) = 0x%02x\n", snd_cs4231_in(chip, 0x11));
488 printk(" 0x02: GF1 left input = 0x%02x ", snd_cs4231_in(chip, 0x02));
489 printk(" 0x12: left line in = 0x%02x\n", snd_cs4231_in(chip, 0x12));
490 printk(" 0x03: GF1 right input = 0x%02x ", snd_cs4231_in(chip, 0x03));
491 printk(" 0x13: right line in = 0x%02x\n", snd_cs4231_in(chip, 0x13));
492 printk(" 0x04: CD left input = 0x%02x ", snd_cs4231_in(chip, 0x04));
493 printk(" 0x14: timer low = 0x%02x\n", snd_cs4231_in(chip, 0x14));
494 printk(" 0x05: CD right input = 0x%02x ", snd_cs4231_in(chip, 0x05));
495 printk(" 0x15: timer high = 0x%02x\n", snd_cs4231_in(chip, 0x15));
496 printk(" 0x06: left output = 0x%02x ", snd_cs4231_in(chip, 0x06));
497 printk(" 0x16: left MIC (PnP) = 0x%02x\n", snd_cs4231_in(chip, 0x16));
498 printk(" 0x07: right output = 0x%02x ", snd_cs4231_in(chip, 0x07));
499 printk(" 0x17: right MIC (PnP) = 0x%02x\n", snd_cs4231_in(chip, 0x17));
500 printk(" 0x08: playback format = 0x%02x ", snd_cs4231_in(chip, 0x08));
501 printk(" 0x18: IRQ status = 0x%02x\n", snd_cs4231_in(chip, 0x18));
502 printk(" 0x09: iface (CFIG 1) = 0x%02x ", snd_cs4231_in(chip, 0x09));
503 printk(" 0x19: left line out = 0x%02x\n", snd_cs4231_in(chip, 0x19));
504 printk(" 0x0a: pin control = 0x%02x ", snd_cs4231_in(chip, 0x0a));
505 printk(" 0x1a: mono control = 0x%02x\n", snd_cs4231_in(chip, 0x1a));
506 printk(" 0x0b: init & status = 0x%02x ", snd_cs4231_in(chip, 0x0b));
507 printk(" 0x1b: right line out = 0x%02x\n", snd_cs4231_in(chip, 0x1b));
508 printk(" 0x0c: revision & mode = 0x%02x ", snd_cs4231_in(chip, 0x0c));
509 printk(" 0x1c: record format = 0x%02x\n", snd_cs4231_in(chip, 0x1c));
510 printk(" 0x0d: loopback = 0x%02x ", snd_cs4231_in(chip, 0x0d));
511 printk(" 0x1d: var freq (PnP) = 0x%02x\n", snd_cs4231_in(chip, 0x1d));
512 printk(" 0x0e: ply upr count = 0x%02x ", snd_cs4231_in(chip, 0x0e));
513 printk(" 0x1e: rec upr count = 0x%02x\n", snd_cs4231_in(chip, 0x1e));
514 printk(" 0x0f: ply lwr count = 0x%02x ", snd_cs4231_in(chip, 0x0f));
515 printk(" 0x1f: rec lwr count = 0x%02x\n", snd_cs4231_in(chip, 0x1f));
516}
517
518#endif
519
520/* 474/*
521 * CS4231 detection / MCE routines 475 * CS4231 detection / MCE routines
522 */ 476 */
@@ -528,11 +482,12 @@ static void snd_cs4231_busy_wait(cs4231_t *chip)
528 /* huh.. looks like this sequence is proper for CS4231A chip (GUS MAX) */ 482 /* huh.. looks like this sequence is proper for CS4231A chip (GUS MAX) */
529 for (timeout = 5; timeout > 0; timeout--) 483 for (timeout = 5; timeout > 0; timeout--)
530 __cs4231_readb(chip, CS4231P(chip, REGSEL)); 484 __cs4231_readb(chip, CS4231P(chip, REGSEL));
485
531 /* end of cleanup sequence */ 486 /* end of cleanup sequence */
532 for (timeout = 250; 487 for (timeout = 500;
533 timeout > 0 && (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT); 488 timeout > 0 && (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT);
534 timeout--) 489 timeout--)
535 udelay(100); 490 udelay(1000);
536} 491}
537 492
538static void snd_cs4231_mce_up(cs4231_t *chip) 493static void snd_cs4231_mce_up(cs4231_t *chip)
@@ -545,12 +500,12 @@ static void snd_cs4231_mce_up(cs4231_t *chip)
545 udelay(100); 500 udelay(100);
546#ifdef CONFIG_SND_DEBUG 501#ifdef CONFIG_SND_DEBUG
547 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) 502 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
548 snd_printk("mce_up - auto calibration time out (0)\n"); 503 snd_printdd("mce_up - auto calibration time out (0)\n");
549#endif 504#endif
550 chip->mce_bit |= CS4231_MCE; 505 chip->mce_bit |= CS4231_MCE;
551 timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); 506 timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL));
552 if (timeout == 0x80) 507 if (timeout == 0x80)
553 snd_printk("mce_up [%p]: serious init problem - codec still busy\n", chip->port); 508 snd_printdd("mce_up [%p]: serious init problem - codec still busy\n", chip->port);
554 if (!(timeout & CS4231_MCE)) 509 if (!(timeout & CS4231_MCE))
555 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); 510 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL));
556 spin_unlock_irqrestore(&chip->lock, flags); 511 spin_unlock_irqrestore(&chip->lock, flags);
@@ -563,18 +518,15 @@ static void snd_cs4231_mce_down(cs4231_t *chip)
563 518
564 spin_lock_irqsave(&chip->lock, flags); 519 spin_lock_irqsave(&chip->lock, flags);
565 snd_cs4231_busy_wait(chip); 520 snd_cs4231_busy_wait(chip);
566#if 0
567 printk("(1) timeout = %i\n", timeout);
568#endif
569#ifdef CONFIG_SND_DEBUG 521#ifdef CONFIG_SND_DEBUG
570 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) 522 if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT)
571 snd_printk("mce_down [%p] - auto calibration time out (0)\n", CS4231P(chip, REGSEL)); 523 snd_printdd("mce_down [%p] - auto calibration time out (0)\n", CS4231P(chip, REGSEL));
572#endif 524#endif
573 chip->mce_bit &= ~CS4231_MCE; 525 chip->mce_bit &= ~CS4231_MCE;
574 timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); 526 timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL));
575 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); 527 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL));
576 if (timeout == 0x80) 528 if (timeout == 0x80)
577 snd_printk("mce_down [%p]: serious init problem - codec still busy\n", chip->port); 529 snd_printdd("mce_down [%p]: serious init problem - codec still busy\n", chip->port);
578 if ((timeout & CS4231_MCE) == 0) { 530 if ((timeout & CS4231_MCE) == 0) {
579 spin_unlock_irqrestore(&chip->lock, flags); 531 spin_unlock_irqrestore(&chip->lock, flags);
580 return; 532 return;
@@ -590,9 +542,7 @@ static void snd_cs4231_mce_down(cs4231_t *chip)
590 spin_unlock_irqrestore(&chip->lock, flags); 542 spin_unlock_irqrestore(&chip->lock, flags);
591 return; 543 return;
592 } 544 }
593#if 0 545
594 printk("(2) timeout = %i, jiffies = %li\n", timeout, jiffies);
595#endif
596 /* in 10ms increments, check condition, up to 250ms */ 546 /* in 10ms increments, check condition, up to 250ms */
597 timeout = 25; 547 timeout = 25;
598 while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) { 548 while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) {
@@ -604,9 +554,7 @@ static void snd_cs4231_mce_down(cs4231_t *chip)
604 msleep(10); 554 msleep(10);
605 spin_lock_irqsave(&chip->lock, flags); 555 spin_lock_irqsave(&chip->lock, flags);
606 } 556 }
607#if 0 557
608 printk("(3) jiffies = %li\n", jiffies);
609#endif
610 /* in 10ms increments, check condition, up to 100ms */ 558 /* in 10ms increments, check condition, up to 100ms */
611 timeout = 10; 559 timeout = 10;
612 while (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) { 560 while (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) {
@@ -619,54 +567,58 @@ static void snd_cs4231_mce_down(cs4231_t *chip)
619 spin_lock_irqsave(&chip->lock, flags); 567 spin_lock_irqsave(&chip->lock, flags);
620 } 568 }
621 spin_unlock_irqrestore(&chip->lock, flags); 569 spin_unlock_irqrestore(&chip->lock, flags);
622#if 0
623 printk("(4) jiffies = %li\n", jiffies);
624 snd_printk("mce_down - exit = 0x%x\n", __cs4231_readb(chip, CS4231P(chip, REGSEL)));
625#endif
626} 570}
627 571
628#if 0 /* Unused for now... */
629static unsigned int snd_cs4231_get_count(unsigned char format, unsigned int size)
630{
631 switch (format & 0xe0) {
632 case CS4231_LINEAR_16:
633 case CS4231_LINEAR_16_BIG:
634 size >>= 1;
635 break;
636 case CS4231_ADPCM_16:
637 return size >> 2;
638 }
639 if (format & CS4231_STEREO)
640 size >>= 1;
641 return size;
642}
643#endif
644
645#ifdef EBUS_SUPPORT 572#ifdef EBUS_SUPPORT
646static void snd_cs4231_ebus_advance_dma(struct ebus_dma_info *p, snd_pcm_substream_t *substream, unsigned int *periods_sent) 573static void snd_cs4231_ebus_advance_dma(struct ebus_dma_info *p, snd_pcm_substream_t *substream, unsigned int *periods_sent)
647{ 574{
648 snd_pcm_runtime_t *runtime = substream->runtime; 575 snd_pcm_runtime_t *runtime = substream->runtime;
649 576
650 while (1) { 577 while (1) {
651 unsigned int dma_size = snd_pcm_lib_period_bytes(substream); 578 unsigned int period_size = snd_pcm_lib_period_bytes(substream);
652 unsigned int offset = dma_size * (*periods_sent); 579 unsigned int offset = period_size * (*periods_sent);
653 580
654 if (dma_size >= (1 << 24)) 581 if (period_size >= (1 << 24))
655 BUG(); 582 BUG();
656 583
657 if (ebus_dma_request(p, runtime->dma_addr + offset, dma_size)) 584 if (ebus_dma_request(p, runtime->dma_addr + offset, period_size))
658 return; 585 return;
659#if 0
660 printk("ebus_advance: Sent period %u (size[%x] offset[%x])\n",
661 (*periods_sent), dma_size, offset);
662#endif
663 (*periods_sent) = ((*periods_sent) + 1) % runtime->periods; 586 (*periods_sent) = ((*periods_sent) + 1) % runtime->periods;
664 } 587 }
665} 588}
666#endif 589#endif
667 590
668static void cs4231_dma_trigger(cs4231_t *chip, unsigned int what, int on) 591#ifdef SBUS_SUPPORT
592static void snd_cs4231_sbus_advance_dma(snd_pcm_substream_t *substream, unsigned int *periods_sent)
593{
594 cs4231_t *chip = snd_pcm_substream_chip(substream);
595 snd_pcm_runtime_t *runtime = substream->runtime;
596
597 unsigned int period_size = snd_pcm_lib_period_bytes(substream);
598 unsigned int offset = period_size * (*periods_sent % runtime->periods);
599
600 if (runtime->period_size > 0xffff + 1)
601 BUG();
602
603 switch (substream->stream) {
604 case SNDRV_PCM_STREAM_PLAYBACK:
605 sbus_writel(runtime->dma_addr + offset, chip->port + APCPNVA);
606 sbus_writel(period_size, chip->port + APCPNC);
607 break;
608 case SNDRV_PCM_STREAM_CAPTURE:
609 sbus_writel(runtime->dma_addr + offset, chip->port + APCCNVA);
610 sbus_writel(period_size, chip->port + APCCNC);
611 break;
612 }
613
614 (*periods_sent) = (*periods_sent + 1) % runtime->periods;
615}
616#endif
617
618static void cs4231_dma_trigger(snd_pcm_substream_t *substream, unsigned int what, int on)
669{ 619{
620 cs4231_t *chip = snd_pcm_substream_chip(substream);
621
670#ifdef EBUS_SUPPORT 622#ifdef EBUS_SUPPORT
671 if (chip->flags & CS4231_FLAG_EBUS) { 623 if (chip->flags & CS4231_FLAG_EBUS) {
672 if (what & CS4231_PLAYBACK_ENABLE) { 624 if (what & CS4231_PLAYBACK_ENABLE) {
@@ -694,6 +646,60 @@ static void cs4231_dma_trigger(cs4231_t *chip, unsigned int what, int on)
694 } else { 646 } else {
695#endif 647#endif
696#ifdef SBUS_SUPPORT 648#ifdef SBUS_SUPPORT
649 u32 csr = sbus_readl(chip->port + APCCSR);
650 /* I don't know why, but on sbus the period counter must
651 * only start counting after the first period is sent.
652 * Therefore this dummy thing.
653 */
654 unsigned int dummy = 0;
655
656 switch (what) {
657 case CS4231_PLAYBACK_ENABLE:
658 if (on) {
659 csr &= ~APC_XINT_PLAY;
660 sbus_writel(csr, chip->port + APCCSR);
661
662 csr &= ~APC_PPAUSE;
663 sbus_writel(csr, chip->port + APCCSR);
664
665 snd_cs4231_sbus_advance_dma(substream, &dummy);
666
667 csr |= APC_GENL_INT | APC_PLAY_INT | APC_XINT_ENA |
668 APC_XINT_PLAY | APC_XINT_EMPT | APC_XINT_GENL |
669 APC_XINT_PENA | APC_PDMA_READY;
670 sbus_writel(csr, chip->port + APCCSR);
671 } else {
672 csr |= APC_PPAUSE;
673 sbus_writel(csr, chip->port + APCCSR);
674
675 csr &= ~APC_PDMA_READY;
676 sbus_writel(csr, chip->port + APCCSR);
677 }
678 break;
679 case CS4231_RECORD_ENABLE:
680 if (on) {
681 csr &= ~APC_XINT_CAPT;
682 sbus_writel(csr, chip->port + APCCSR);
683
684 csr &= ~APC_CPAUSE;
685 sbus_writel(csr, chip->port + APCCSR);
686
687 snd_cs4231_sbus_advance_dma(substream, &dummy);
688
689 csr |= APC_GENL_INT | APC_CAPT_INT | APC_XINT_ENA |
690 APC_XINT_CAPT | APC_XINT_CEMP | APC_XINT_GENL |
691 APC_CDMA_READY;
692
693 sbus_writel(csr, chip->port + APCCSR);
694 } else {
695 csr |= APC_CPAUSE;
696 sbus_writel(csr, chip->port + APCCSR);
697
698 csr &= ~APC_CDMA_READY;
699 sbus_writel(csr, chip->port + APCCSR);
700 }
701 break;
702 }
697#endif 703#endif
698#ifdef EBUS_SUPPORT 704#ifdef EBUS_SUPPORT
699 } 705 }
@@ -725,25 +731,12 @@ static int snd_cs4231_trigger(snd_pcm_substream_t *substream, int cmd)
725 } 731 }
726 } 732 }
727 733
728#if 0
729 printk("TRIGGER: what[%x] on(%d)\n",
730 what, (cmd == SNDRV_PCM_TRIGGER_START));
731#endif
732
733 spin_lock_irqsave(&chip->lock, flags); 734 spin_lock_irqsave(&chip->lock, flags);
734 if (cmd == SNDRV_PCM_TRIGGER_START) { 735 if (cmd == SNDRV_PCM_TRIGGER_START) {
735 cs4231_dma_trigger(chip, what, 1); 736 cs4231_dma_trigger(substream, what, 1);
736 chip->image[CS4231_IFACE_CTRL] |= what; 737 chip->image[CS4231_IFACE_CTRL] |= what;
737 if (what & CS4231_PLAYBACK_ENABLE) {
738 snd_cs4231_out(chip, CS4231_PLY_LWR_CNT, 0xff);
739 snd_cs4231_out(chip, CS4231_PLY_UPR_CNT, 0xff);
740 }
741 if (what & CS4231_RECORD_ENABLE) {
742 snd_cs4231_out(chip, CS4231_REC_LWR_CNT, 0xff);
743 snd_cs4231_out(chip, CS4231_REC_UPR_CNT, 0xff);
744 }
745 } else { 738 } else {
746 cs4231_dma_trigger(chip, what, 0); 739 cs4231_dma_trigger(substream, what, 0);
747 chip->image[CS4231_IFACE_CTRL] &= ~what; 740 chip->image[CS4231_IFACE_CTRL] &= ~what;
748 } 741 }
749 snd_cs4231_out(chip, CS4231_IFACE_CTRL, 742 snd_cs4231_out(chip, CS4231_IFACE_CTRL,
@@ -755,9 +748,7 @@ static int snd_cs4231_trigger(snd_pcm_substream_t *substream, int cmd)
755 result = -EINVAL; 748 result = -EINVAL;
756 break; 749 break;
757 } 750 }
758#if 0 751
759 snd_cs4231_debug(chip);
760#endif
761 return result; 752 return result;
762} 753}
763 754
@@ -790,9 +781,6 @@ static unsigned char snd_cs4231_get_format(cs4231_t *chip, int format, int chann
790 } 781 }
791 if (channels > 1) 782 if (channels > 1)
792 rformat |= CS4231_STEREO; 783 rformat |= CS4231_STEREO;
793#if 0
794 snd_printk("get_format: 0x%x (mode=0x%x)\n", format, mode);
795#endif
796 return rformat; 784 return rformat;
797} 785}
798 786
@@ -944,7 +932,7 @@ static void snd_cs4231_init(cs4231_t *chip)
944 snd_cs4231_mce_down(chip); 932 snd_cs4231_mce_down(chip);
945 933
946#ifdef SNDRV_DEBUG_MCE 934#ifdef SNDRV_DEBUG_MCE
947 snd_printk("init: (1)\n"); 935 snd_printdd("init: (1)\n");
948#endif 936#endif
949 snd_cs4231_mce_up(chip); 937 snd_cs4231_mce_up(chip);
950 spin_lock_irqsave(&chip->lock, flags); 938 spin_lock_irqsave(&chip->lock, flags);
@@ -957,7 +945,7 @@ static void snd_cs4231_init(cs4231_t *chip)
957 snd_cs4231_mce_down(chip); 945 snd_cs4231_mce_down(chip);
958 946
959#ifdef SNDRV_DEBUG_MCE 947#ifdef SNDRV_DEBUG_MCE
960 snd_printk("init: (2)\n"); 948 snd_printdd("init: (2)\n");
961#endif 949#endif
962 950
963 snd_cs4231_mce_up(chip); 951 snd_cs4231_mce_up(chip);
@@ -967,7 +955,7 @@ static void snd_cs4231_init(cs4231_t *chip)
967 snd_cs4231_mce_down(chip); 955 snd_cs4231_mce_down(chip);
968 956
969#ifdef SNDRV_DEBUG_MCE 957#ifdef SNDRV_DEBUG_MCE
970 snd_printk("init: (3) - afei = 0x%x\n", chip->image[CS4231_ALT_FEATURE_1]); 958 snd_printdd("init: (3) - afei = 0x%x\n", chip->image[CS4231_ALT_FEATURE_1]);
971#endif 959#endif
972 960
973 spin_lock_irqsave(&chip->lock, flags); 961 spin_lock_irqsave(&chip->lock, flags);
@@ -981,7 +969,7 @@ static void snd_cs4231_init(cs4231_t *chip)
981 snd_cs4231_mce_down(chip); 969 snd_cs4231_mce_down(chip);
982 970
983#ifdef SNDRV_DEBUG_MCE 971#ifdef SNDRV_DEBUG_MCE
984 snd_printk("init: (4)\n"); 972 snd_printdd("init: (4)\n");
985#endif 973#endif
986 974
987 snd_cs4231_mce_up(chip); 975 snd_cs4231_mce_up(chip);
@@ -991,7 +979,7 @@ static void snd_cs4231_init(cs4231_t *chip)
991 snd_cs4231_mce_down(chip); 979 snd_cs4231_mce_down(chip);
992 980
993#ifdef SNDRV_DEBUG_MCE 981#ifdef SNDRV_DEBUG_MCE
994 snd_printk("init: (5)\n"); 982 snd_printdd("init: (5)\n");
995#endif 983#endif
996} 984}
997 985
@@ -1022,6 +1010,7 @@ static int snd_cs4231_open(cs4231_t *chip, unsigned int mode)
1022 CS4231_RECORD_IRQ | 1010 CS4231_RECORD_IRQ |
1023 CS4231_TIMER_IRQ); 1011 CS4231_TIMER_IRQ);
1024 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); 1012 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0);
1013
1025 spin_unlock_irqrestore(&chip->lock, flags); 1014 spin_unlock_irqrestore(&chip->lock, flags);
1026 1015
1027 chip->mode = mode; 1016 chip->mode = mode;
@@ -1136,11 +1125,21 @@ static int snd_cs4231_playback_hw_free(snd_pcm_substream_t *substream)
1136static int snd_cs4231_playback_prepare(snd_pcm_substream_t *substream) 1125static int snd_cs4231_playback_prepare(snd_pcm_substream_t *substream)
1137{ 1126{
1138 cs4231_t *chip = snd_pcm_substream_chip(substream); 1127 cs4231_t *chip = snd_pcm_substream_chip(substream);
1128 snd_pcm_runtime_t *runtime = substream->runtime;
1139 unsigned long flags; 1129 unsigned long flags;
1140 1130
1141 spin_lock_irqsave(&chip->lock, flags); 1131 spin_lock_irqsave(&chip->lock, flags);
1132
1142 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | 1133 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE |
1143 CS4231_PLAYBACK_PIO); 1134 CS4231_PLAYBACK_PIO);
1135
1136 if (runtime->period_size > 0xffff + 1)
1137 BUG();
1138
1139 snd_cs4231_out(chip, CS4231_PLY_LWR_CNT, (runtime->period_size - 1) & 0x00ff);
1140 snd_cs4231_out(chip, CS4231_PLY_UPR_CNT, (runtime->period_size - 1) >> 8 & 0x00ff);
1141 chip->p_periods_sent = 0;
1142
1144 spin_unlock_irqrestore(&chip->lock, flags); 1143 spin_unlock_irqrestore(&chip->lock, flags);
1145 1144
1146 return 0; 1145 return 0;
@@ -1172,12 +1171,16 @@ static int snd_cs4231_capture_hw_free(snd_pcm_substream_t *substream)
1172static int snd_cs4231_capture_prepare(snd_pcm_substream_t *substream) 1171static int snd_cs4231_capture_prepare(snd_pcm_substream_t *substream)
1173{ 1172{
1174 cs4231_t *chip = snd_pcm_substream_chip(substream); 1173 cs4231_t *chip = snd_pcm_substream_chip(substream);
1174 snd_pcm_runtime_t *runtime = substream->runtime;
1175 unsigned long flags; 1175 unsigned long flags;
1176 1176
1177 spin_lock_irqsave(&chip->lock, flags); 1177 spin_lock_irqsave(&chip->lock, flags);
1178 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | 1178 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE |
1179 CS4231_RECORD_PIO); 1179 CS4231_RECORD_PIO);
1180 1180
1181 snd_cs4231_out(chip, CS4231_REC_LWR_CNT, (runtime->period_size - 1) & 0x00ff);
1182 snd_cs4231_out(chip, CS4231_REC_LWR_CNT, (runtime->period_size - 1) >> 8 & 0x00ff);
1183
1181 spin_unlock_irqrestore(&chip->lock, flags); 1184 spin_unlock_irqrestore(&chip->lock, flags);
1182 1185
1183 return 0; 1186 return 0;
@@ -1196,53 +1199,61 @@ static void snd_cs4231_overrange(cs4231_t *chip)
1196 chip->capture_substream->runtime->overrange++; 1199 chip->capture_substream->runtime->overrange++;
1197} 1200}
1198 1201
1199static void snd_cs4231_generic_interrupt(cs4231_t *chip) 1202static irqreturn_t snd_cs4231_generic_interrupt(cs4231_t *chip)
1200{ 1203{
1201 unsigned long flags; 1204 unsigned long flags;
1202 unsigned char status; 1205 unsigned char status;
1203 1206
1207 /*This is IRQ is not raised by the cs4231*/
1208 if (!(__cs4231_readb(chip, CS4231P(chip, STATUS)) & CS4231_GLOBALIRQ))
1209 return IRQ_NONE;
1210
1204 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); 1211 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS);
1205 if (!status)
1206 return;
1207 1212
1208 if (status & CS4231_TIMER_IRQ) { 1213 if (status & CS4231_TIMER_IRQ) {
1209 if (chip->timer) 1214 if (chip->timer)
1210 snd_timer_interrupt(chip->timer, chip->timer->sticks); 1215 snd_timer_interrupt(chip->timer, chip->timer->sticks);
1211 } 1216 }
1212 if (status & CS4231_PLAYBACK_IRQ) 1217
1213 snd_pcm_period_elapsed(chip->playback_substream); 1218 if (status & CS4231_RECORD_IRQ)
1214 if (status & CS4231_RECORD_IRQ) {
1215 snd_cs4231_overrange(chip); 1219 snd_cs4231_overrange(chip);
1216 snd_pcm_period_elapsed(chip->capture_substream);
1217 }
1218 1220
1219 /* ACK the CS4231 interrupt. */ 1221 /* ACK the CS4231 interrupt. */
1220 spin_lock_irqsave(&chip->lock, flags); 1222 spin_lock_irqsave(&chip->lock, flags);
1221 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0); 1223 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0);
1222 spin_unlock_irqrestore(&chip->lock, flags); 1224 spin_unlock_irqrestore(&chip->lock, flags);
1225
1226 return 0;
1223} 1227}
1224 1228
1225#ifdef SBUS_SUPPORT 1229#ifdef SBUS_SUPPORT
1226static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1230static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1227{ 1231{
1228 cs4231_t *chip = dev_id; 1232 cs4231_t *chip = dev_id;
1229 u32 csr;
1230
1231 csr = sbus_readl(chip->port + APCCSR);
1232 if (!(csr & (APC_INT_PENDING |
1233 APC_PLAY_INT |
1234 APC_CAPT_INT |
1235 APC_GENL_INT |
1236 APC_XINT_PEMP |
1237 APC_XINT_CEMP)))
1238 return IRQ_NONE;
1239 1233
1240 /* ACK the APC interrupt. */ 1234 /* ACK the APC interrupt. */
1235 u32 csr = sbus_readl(chip->port + APCCSR);
1236
1241 sbus_writel(csr, chip->port + APCCSR); 1237 sbus_writel(csr, chip->port + APCCSR);
1242 1238
1243 snd_cs4231_generic_interrupt(chip); 1239 if ((chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) &&
1240 (csr & APC_PLAY_INT) &&
1241 (csr & APC_XINT_PNVA) &&
1242 !(csr & APC_XINT_EMPT)) {
1243 snd_cs4231_sbus_advance_dma(chip->playback_substream,
1244 &chip->p_periods_sent);
1245 snd_pcm_period_elapsed(chip->playback_substream);
1246 }
1244 1247
1245 return IRQ_HANDLED; 1248 if ((chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) &&
1249 (csr & APC_CAPT_INT) &&
1250 (csr & APC_XINT_CNVA)) {
1251 snd_cs4231_sbus_advance_dma(chip->capture_substream,
1252 &chip->c_periods_sent);
1253 snd_pcm_period_elapsed(chip->capture_substream);
1254 }
1255
1256 return snd_cs4231_generic_interrupt(chip);
1246} 1257}
1247#endif 1258#endif
1248 1259
@@ -1290,7 +1301,8 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t *substr
1290#ifdef EBUS_SUPPORT 1301#ifdef EBUS_SUPPORT
1291 } 1302 }
1292#endif 1303#endif
1293 ptr += (period_bytes - residue); 1304 ptr += period_bytes - residue;
1305
1294 return bytes_to_frames(substream->runtime, ptr); 1306 return bytes_to_frames(substream->runtime, ptr);
1295} 1307}
1296 1308
@@ -1314,7 +1326,7 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr
1314#ifdef EBUS_SUPPORT 1326#ifdef EBUS_SUPPORT
1315 } 1327 }
1316#endif 1328#endif
1317 ptr += (period_bytes - residue); 1329 ptr += period_bytes - residue;
1318 return bytes_to_frames(substream->runtime, ptr); 1330 return bytes_to_frames(substream->runtime, ptr);
1319} 1331}
1320 1332
@@ -1328,9 +1340,6 @@ static int snd_cs4231_probe(cs4231_t *chip)
1328 int i, id, vers; 1340 int i, id, vers;
1329 unsigned char *ptr; 1341 unsigned char *ptr;
1330 1342
1331#if 0
1332 snd_cs4231_debug(chip);
1333#endif
1334 id = vers = 0; 1343 id = vers = 0;
1335 for (i = 0; i < 50; i++) { 1344 for (i = 0; i < 50; i++) {
1336 mb(); 1345 mb();
@@ -1985,13 +1994,13 @@ static int __init snd_cs4231_sbus_create(snd_card_t *card,
1985 chip->port = sbus_ioremap(&sdev->resource[0], 0, 1994 chip->port = sbus_ioremap(&sdev->resource[0], 0,
1986 chip->regs_size, "cs4231"); 1995 chip->regs_size, "cs4231");
1987 if (!chip->port) { 1996 if (!chip->port) {
1988 snd_printk("cs4231-%d: Unable to map chip registers.\n", dev); 1997 snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev);
1989 return -EIO; 1998 return -EIO;
1990 } 1999 }
1991 2000
1992 if (request_irq(sdev->irqs[0], snd_cs4231_sbus_interrupt, 2001 if (request_irq(sdev->irqs[0], snd_cs4231_sbus_interrupt,
1993 SA_SHIRQ, "cs4231", chip)) { 2002 SA_SHIRQ, "cs4231", chip)) {
1994 snd_printk("cs4231-%d: Unable to grab SBUS IRQ %s\n", 2003 snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %s\n",
1995 dev, 2004 dev,
1996 __irq_itoa(sdev->irqs[0])); 2005 __irq_itoa(sdev->irqs[0]));
1997 snd_cs4231_sbus_free(chip); 2006 snd_cs4231_sbus_free(chip);
@@ -2113,29 +2122,29 @@ static int __init snd_cs4231_ebus_create(snd_card_t *card,
2113 chip->eb2c.regs = ioremap(edev->resource[2].start, 0x10); 2122 chip->eb2c.regs = ioremap(edev->resource[2].start, 0x10);
2114 if (!chip->port || !chip->eb2p.regs || !chip->eb2c.regs) { 2123 if (!chip->port || !chip->eb2p.regs || !chip->eb2c.regs) {
2115 snd_cs4231_ebus_free(chip); 2124 snd_cs4231_ebus_free(chip);
2116 snd_printk("cs4231-%d: Unable to map chip registers.\n", dev); 2125 snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev);
2117 return -EIO; 2126 return -EIO;
2118 } 2127 }
2119 2128
2120 if (ebus_dma_register(&chip->eb2c)) { 2129 if (ebus_dma_register(&chip->eb2c)) {
2121 snd_cs4231_ebus_free(chip); 2130 snd_cs4231_ebus_free(chip);
2122 snd_printk("cs4231-%d: Unable to register EBUS capture DMA\n", dev); 2131 snd_printdd("cs4231-%d: Unable to register EBUS capture DMA\n", dev);
2123 return -EBUSY; 2132 return -EBUSY;
2124 } 2133 }
2125 if (ebus_dma_irq_enable(&chip->eb2c, 1)) { 2134 if (ebus_dma_irq_enable(&chip->eb2c, 1)) {
2126 snd_cs4231_ebus_free(chip); 2135 snd_cs4231_ebus_free(chip);
2127 snd_printk("cs4231-%d: Unable to enable EBUS capture IRQ\n", dev); 2136 snd_printdd("cs4231-%d: Unable to enable EBUS capture IRQ\n", dev);
2128 return -EBUSY; 2137 return -EBUSY;
2129 } 2138 }
2130 2139
2131 if (ebus_dma_register(&chip->eb2p)) { 2140 if (ebus_dma_register(&chip->eb2p)) {
2132 snd_cs4231_ebus_free(chip); 2141 snd_cs4231_ebus_free(chip);
2133 snd_printk("cs4231-%d: Unable to register EBUS play DMA\n", dev); 2142 snd_printdd("cs4231-%d: Unable to register EBUS play DMA\n", dev);
2134 return -EBUSY; 2143 return -EBUSY;
2135 } 2144 }
2136 if (ebus_dma_irq_enable(&chip->eb2p, 1)) { 2145 if (ebus_dma_irq_enable(&chip->eb2p, 1)) {
2137 snd_cs4231_ebus_free(chip); 2146 snd_cs4231_ebus_free(chip);
2138 snd_printk("cs4231-%d: Unable to enable EBUS play IRQ\n", dev); 2147 snd_printdd("cs4231-%d: Unable to enable EBUS play IRQ\n", dev);
2139 return -EBUSY; 2148 return -EBUSY;
2140 } 2149 }
2141 2150
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index d5ae2055b896..2ead878bcb8f 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -1444,9 +1444,9 @@ static snd_pcm_hardware_t snd_usb_playback =
1444 SNDRV_PCM_INFO_BATCH | 1444 SNDRV_PCM_INFO_BATCH |
1445 SNDRV_PCM_INFO_INTERLEAVED | 1445 SNDRV_PCM_INFO_INTERLEAVED |
1446 SNDRV_PCM_INFO_BLOCK_TRANSFER, 1446 SNDRV_PCM_INFO_BLOCK_TRANSFER,
1447 .buffer_bytes_max = (256*1024), 1447 .buffer_bytes_max = 1024 * 1024,
1448 .period_bytes_min = 64, 1448 .period_bytes_min = 64,
1449 .period_bytes_max = (128*1024), 1449 .period_bytes_max = 512 * 1024,
1450 .periods_min = 2, 1450 .periods_min = 2,
1451 .periods_max = 1024, 1451 .periods_max = 1024,
1452}; 1452};
@@ -1458,9 +1458,9 @@ static snd_pcm_hardware_t snd_usb_capture =
1458 SNDRV_PCM_INFO_BATCH | 1458 SNDRV_PCM_INFO_BATCH |
1459 SNDRV_PCM_INFO_INTERLEAVED | 1459 SNDRV_PCM_INFO_INTERLEAVED |
1460 SNDRV_PCM_INFO_BLOCK_TRANSFER, 1460 SNDRV_PCM_INFO_BLOCK_TRANSFER,
1461 .buffer_bytes_max = (256*1024), 1461 .buffer_bytes_max = 1024 * 1024,
1462 .period_bytes_min = 64, 1462 .period_bytes_min = 64,
1463 .period_bytes_max = (128*1024), 1463 .period_bytes_max = 512 * 1024,
1464 .periods_min = 2, 1464 .periods_min = 2,
1465 .periods_max = 1024, 1465 .periods_max = 1024,
1466}; 1466};
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
index f05500b05ec0..c1264434e50a 100644
--- a/sound/usb/usbmixer_maps.c
+++ b/sound/usb/usbmixer_maps.c
@@ -238,6 +238,16 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
238 .selector_map = audigy2nx_selectors, 238 .selector_map = audigy2nx_selectors,
239 }, 239 },
240 { 240 {
241 /* Hercules DJ Console (Windows Edition) */
242 .id = USB_ID(0x06f8, 0xb000),
243 .ignore_ctl_error = 1,
244 },
245 {
246 /* Hercules DJ Console (Macintosh Edition) */
247 .id = USB_ID(0x06f8, 0xd002),
248 .ignore_ctl_error = 1,
249 },
250 {
241 .id = USB_ID(0x08bb, 0x2702), 251 .id = USB_ID(0x08bb, 0x2702),
242 .map = linex_map, 252 .map = linex_map,
243 .ignore_ctl_error = 1, 253 .ignore_ctl_error = 1,
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index f74e652a1e51..948759da6563 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -117,6 +117,10 @@ YAMAHA_DEVICE(0x103a, NULL),
117YAMAHA_DEVICE(0x103b, NULL), 117YAMAHA_DEVICE(0x103b, NULL),
118YAMAHA_DEVICE(0x103c, NULL), 118YAMAHA_DEVICE(0x103c, NULL),
119YAMAHA_DEVICE(0x103d, NULL), 119YAMAHA_DEVICE(0x103d, NULL),
120YAMAHA_DEVICE(0x103e, NULL),
121YAMAHA_DEVICE(0x103f, NULL),
122YAMAHA_DEVICE(0x1040, NULL),
123YAMAHA_DEVICE(0x1041, NULL),
120YAMAHA_DEVICE(0x2000, "DGP-7"), 124YAMAHA_DEVICE(0x2000, "DGP-7"),
121YAMAHA_DEVICE(0x2001, "DGP-5"), 125YAMAHA_DEVICE(0x2001, "DGP-5"),
122YAMAHA_DEVICE(0x2002, NULL), 126YAMAHA_DEVICE(0x2002, NULL),
@@ -1010,6 +1014,40 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1010 } 1014 }
1011 } 1015 }
1012}, 1016},
1017{
1018 USB_DEVICE_VENDOR_SPEC(0x0582, 0x007a),
1019 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
1020 .vendor_name = "Roland",
1021 /* RD-700SX, RD-300SX */
1022 .ifnum = 0,
1023 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1024 .data = & (const snd_usb_midi_endpoint_info_t) {
1025 .out_cables = 0x0003,
1026 .in_cables = 0x0003
1027 }
1028 }
1029},
1030
1031/* Guillemot devices */
1032{
1033 /*
1034 * This is for the "Windows Edition" where the external MIDI ports are
1035 * the only MIDI ports; the control data is reported through HID
1036 * interfaces. The "Macintosh Edition" has ID 0xd002 and uses standard
1037 * compliant USB MIDI ports for external MIDI and controls.
1038 */
1039 USB_DEVICE_VENDOR_SPEC(0x06f8, 0xb000),
1040 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
1041 .vendor_name = "Hercules",
1042 .product_name = "DJ Console (WE)",
1043 .ifnum = 4,
1044 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1045 .data = & (const snd_usb_midi_endpoint_info_t) {
1046 .out_cables = 0x0001,
1047 .in_cables = 0x0001
1048 }
1049 }
1050},
1013 1051
1014/* Midiman/M-Audio devices */ 1052/* Midiman/M-Audio devices */
1015{ 1053{
@@ -1339,10 +1377,20 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1339 } 1377 }
1340}, 1378},
1341 1379
1380/* TerraTec devices */
1381{
1382 USB_DEVICE_VENDOR_SPEC(0x0ccd, 0x0012),
1383 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
1384 .vendor_name = "TerraTec",
1385 .product_name = "PHASE 26",
1386 .ifnum = 3,
1387 .type = QUIRK_MIDI_STANDARD_INTERFACE
1388 }
1389},
1342{ 1390{
1343 USB_DEVICE_VENDOR_SPEC(0x0ccd, 0x0013), 1391 USB_DEVICE_VENDOR_SPEC(0x0ccd, 0x0013),
1344 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 1392 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
1345 .vendor_name = "Terratec", 1393 .vendor_name = "TerraTec",
1346 .product_name = "PHASE 26", 1394 .product_name = "PHASE 26",
1347 .ifnum = 3, 1395 .ifnum = 3,
1348 .type = QUIRK_MIDI_STANDARD_INTERFACE 1396 .type = QUIRK_MIDI_STANDARD_INTERFACE
diff --git a/usr/.gitignore b/usr/.gitignore
new file mode 100644
index 000000000000..be186a82e8d0
--- /dev/null
+++ b/usr/.gitignore
@@ -0,0 +1,7 @@
1#
2# Generated files
3#
4gen_init_cpio
5initramfs_data.cpio
6initramfs_data.cpio.gz
7initramfs_list