aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <jejb@titanic.(none)>2005-05-20 16:27:44 -0400
committerJames Bottomley <jejb@titanic.(none)>2005-05-20 16:27:44 -0400
commitad34ea2cc3845ef4dcd7d12fb0fa8484734bd672 (patch)
treead434400f5ecaa33b433c8f830e40792d8d6c05c
parent90356ac3194bf91a441a5f9c3067af386ef62462 (diff)
parent88d7bd8cb9eb8d64bf7997600b0d64f7834047c5 (diff)
merge by hand - fix up rejections in Documentation/DocBook/Makefile
-rw-r--r--CREDITS2
-rw-r--r--Documentation/00-INDEX2
-rw-r--r--Documentation/BK-usage/00-INDEX51
-rw-r--r--Documentation/BK-usage/bk-kernel-howto.txt283
-rwxr-xr-xDocumentation/BK-usage/bk-make-sum34
-rwxr-xr-xDocumentation/BK-usage/bksend36
-rwxr-xr-xDocumentation/BK-usage/bz64wrap41
-rwxr-xr-xDocumentation/BK-usage/cpcset36
-rwxr-xr-xDocumentation/BK-usage/cset-to-linus49
-rwxr-xr-xDocumentation/BK-usage/csets-to-patches44
-rwxr-xr-xDocumentation/BK-usage/gcapatch8
-rwxr-xr-xDocumentation/BK-usage/unbz64wrap25
-rw-r--r--Documentation/Changes8
-rw-r--r--Documentation/DocBook/Makefile60
-rw-r--r--Documentation/DocBook/kernel-api.tmpl186
-rw-r--r--Documentation/DocBook/stylesheet.xsl5
-rw-r--r--Documentation/DocBook/tulip-user.tmpl327
-rw-r--r--Documentation/DocBook/via-audio.tmpl597
-rw-r--r--Documentation/RCU/RTFP.txt29
-rw-r--r--Documentation/RCU/UP.txt8
-rw-r--r--Documentation/RCU/checklist.txt47
-rw-r--r--Documentation/RCU/listRCU.txt13
-rw-r--r--Documentation/RCU/rcu.txt4
-rw-r--r--Documentation/aoe/aoe.txt40
-rw-r--r--Documentation/aoe/status.sh4
-rw-r--r--Documentation/dontdiff139
-rw-r--r--Documentation/feature-removal-schedule.txt15
-rw-r--r--Documentation/filesystems/Locking8
-rw-r--r--Documentation/filesystems/proc.txt10
-rw-r--r--Documentation/i386/zero-page.txt6
-rw-r--r--Documentation/networking/DLINK.txt7
-rw-r--r--Documentation/networking/netdevices.txt2
-rw-r--r--Documentation/pci.txt1
-rw-r--r--Documentation/power/pci.txt35
-rw-r--r--Documentation/s390/cds.txt45
-rw-r--r--MAINTAINERS11
-rw-r--r--Makefile12
-rw-r--r--arch/alpha/Kconfig4
-rw-r--r--arch/alpha/kernel/osf_sys.c16
-rw-r--r--arch/alpha/kernel/ptrace.c5
-rw-r--r--arch/alpha/kernel/systbls.S2
-rw-r--r--arch/arm/Kconfig22
-rw-r--r--arch/arm/boot/compressed/head.S105
-rw-r--r--arch/arm/common/rtctime.c29
-rw-r--r--arch/arm/configs/ixdp2800_defconfig2
-rw-r--r--arch/arm/kernel/Makefile5
-rw-r--r--arch/arm/kernel/asm-offsets.c20
-rw-r--r--arch/arm/kernel/entry-armv.S276
-rw-r--r--arch/arm/kernel/entry-common.S65
-rw-r--r--arch/arm/kernel/entry-header.S143
-rw-r--r--arch/arm/kernel/head.S3
-rw-r--r--arch/arm/kernel/process.c25
-rw-r--r--arch/arm/kernel/ptrace.c5
-rw-r--r--arch/arm/kernel/sys_arm.c14
-rw-r--r--arch/arm/kernel/traps.c69
-rw-r--r--arch/arm/kernel/vmlinux.lds.S3
-rw-r--r--arch/arm/mach-clps711x/Kconfig3
-rw-r--r--arch/arm/mach-footbridge/Kconfig12
-rw-r--r--arch/arm/mach-imx/Kconfig1
-rw-r--r--arch/arm/mach-imx/generic.c16
-rw-r--r--arch/arm/mach-integrator/core.c6
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c17
-rw-r--r--arch/arm/mach-integrator/leds.c2
-rw-r--r--arch/arm/mach-integrator/time.c17
-rw-r--r--arch/arm/mach-ixp2000/ixdp2800.c147
-rw-r--r--arch/arm/mach-ixp2000/pci.c8
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c10
-rw-r--r--arch/arm/mach-pxa/generic.c25
-rw-r--r--arch/arm/mach-pxa/sleep.S56
-rw-r--r--arch/arm/mm/Kconfig21
-rw-r--r--arch/arm/mm/abort-ev6.S16
-rw-r--r--arch/arm/mm/mm-armv.c5
-rw-r--r--arch/arm26/Kconfig4
-rw-r--r--arch/arm26/kernel/ptrace.c5
-rw-r--r--arch/arm26/mm/small_page.c6
-rw-r--r--arch/cris/arch-v10/kernel/ptrace.c5
-rw-r--r--arch/frv/kernel/ptrace.c5
-rw-r--r--arch/h8300/kernel/ptrace.c5
-rw-r--r--arch/i386/Kconfig42
-rw-r--r--arch/i386/Makefile13
-rw-r--r--arch/i386/boot/bootsect.S2
-rw-r--r--arch/i386/boot/compressed/misc.c1
-rw-r--r--arch/i386/boot/setup.S6
-rw-r--r--arch/i386/boot/video.S18
-rw-r--r--arch/i386/kernel/Makefile1
-rw-r--r--arch/i386/kernel/acpi/boot.c2
-rw-r--r--arch/i386/kernel/apic.c2
-rw-r--r--arch/i386/kernel/cpu/amd.c4
-rw-r--r--arch/i386/kernel/cpu/mtrr/cyrix.c4
-rw-r--r--arch/i386/kernel/cpu/mtrr/generic.c4
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c14
-rw-r--r--arch/i386/kernel/cpu/proc.c2
-rw-r--r--arch/i386/kernel/entry.S304
-rw-r--r--arch/i386/kernel/head.S2
-rw-r--r--arch/i386/kernel/i386_ksyms.c4
-rw-r--r--arch/i386/kernel/io_apic.c2
-rw-r--r--arch/i386/kernel/kprobes.c7
-rw-r--r--arch/i386/kernel/nmi.c11
-rw-r--r--arch/i386/kernel/process.c17
-rw-r--r--arch/i386/kernel/ptrace.c24
-rw-r--r--arch/i386/kernel/reboot.c2
-rw-r--r--arch/i386/kernel/reboot_fixups.c56
-rw-r--r--arch/i386/kernel/smpboot.c3
-rw-r--r--arch/i386/kernel/syscall_table.S291
-rw-r--r--arch/i386/kernel/time.c2
-rw-r--r--arch/i386/kernel/time_hpet.c48
-rw-r--r--arch/i386/kernel/timers/timer_hpet.c11
-rw-r--r--arch/i386/kernel/timers/timer_tsc.c2
-rw-r--r--arch/i386/kernel/traps.c6
-rw-r--r--arch/i386/kernel/vm86.c21
-rw-r--r--arch/i386/oprofile/nmi_timer_int.c2
-rw-r--r--arch/i386/pci/irq.c2
-rw-r--r--arch/ia64/Kconfig25
-rw-r--r--arch/ia64/configs/sn2_defconfig2
-rw-r--r--arch/ia64/configs/tiger_defconfig96
-rw-r--r--arch/ia64/hp/common/sba_iommu.c130
-rw-r--r--arch/ia64/ia32/ia32_signal.c5
-rw-r--r--arch/ia64/kernel/acpi.c23
-rw-r--r--arch/ia64/kernel/entry.S18
-rw-r--r--arch/ia64/kernel/fsys.S4
-rw-r--r--arch/ia64/kernel/head.S284
-rw-r--r--arch/ia64/kernel/iosapic.c358
-rw-r--r--arch/ia64/kernel/irq_ia64.c16
-rw-r--r--arch/ia64/kernel/mca_asm.S88
-rw-r--r--arch/ia64/kernel/mca_drv.c4
-rw-r--r--arch/ia64/kernel/mca_drv_asm.S18
-rw-r--r--arch/ia64/kernel/perfmon.c102
-rw-r--r--arch/ia64/kernel/perfmon_default_smpl.c13
-rw-r--r--arch/ia64/kernel/process.c77
-rw-r--r--arch/ia64/kernel/ptrace.c26
-rw-r--r--arch/ia64/kernel/setup.c69
-rw-r--r--arch/ia64/kernel/signal.c3
-rw-r--r--arch/ia64/kernel/smpboot.c294
-rw-r--r--arch/ia64/kernel/sys_ia64.c14
-rw-r--r--arch/ia64/kernel/unwind.c27
-rw-r--r--arch/ia64/lib/flush.S6
-rw-r--r--arch/ia64/lib/memcpy_mck.S4
-rw-r--r--arch/ia64/lib/memset.S2
-rw-r--r--arch/ia64/mm/contig.c3
-rw-r--r--arch/ia64/mm/discontig.c3
-rw-r--r--arch/ia64/mm/fault.c9
-rw-r--r--arch/ia64/mm/init.c74
-rw-r--r--arch/ia64/sn/include/pci/pcibr_provider.h6
-rw-r--r--arch/ia64/sn/kernel/Makefile8
-rw-r--r--arch/ia64/sn/kernel/bte.c20
-rw-r--r--arch/ia64/sn/kernel/bte_error.c76
-rw-r--r--arch/ia64/sn/kernel/huberror.c9
-rw-r--r--arch/ia64/sn/kernel/io_init.c88
-rw-r--r--arch/ia64/sn/kernel/irq.c19
-rw-r--r--arch/ia64/sn/kernel/mca.c34
-rw-r--r--arch/ia64/sn/kernel/setup.c49
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c112
-rw-r--r--arch/ia64/sn/kernel/tiocx.c552
-rw-r--r--arch/ia64/sn/kernel/xp_main.c289
-rw-r--r--arch/ia64/sn/kernel/xp_nofault.S31
-rw-r--r--arch/ia64/sn/kernel/xpc.h991
-rw-r--r--arch/ia64/sn/kernel/xpc_channel.c2297
-rw-r--r--arch/ia64/sn/kernel/xpc_main.c1064
-rw-r--r--arch/ia64/sn/kernel/xpc_partition.c984
-rw-r--r--arch/ia64/sn/kernel/xpnet.c715
-rw-r--r--arch/ia64/sn/pci/Makefile2
-rw-r--r--arch/ia64/sn/pci/pci_dma.c39
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_ate.c4
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_dma.c109
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_provider.c24
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_reg.c4
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c668
-rw-r--r--arch/m32r/kernel/ptrace.c5
-rw-r--r--arch/m68k/kernel/ptrace.c5
-rw-r--r--arch/m68knommu/Kconfig5
-rw-r--r--arch/m68knommu/kernel/ptrace.c5
-rw-r--r--arch/mips/Kconfig4
-rw-r--r--arch/mips/kernel/ptrace.c41
-rw-r--r--arch/mips/kernel/ptrace32.c3
-rw-r--r--arch/mips/kernel/syscall.c16
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/parisc/kernel/ptrace.c7
-rw-r--r--arch/parisc/kernel/sys_parisc.c11
-rw-r--r--arch/parisc/kernel/syscall_table.S2
-rw-r--r--arch/ppc/Kconfig14
-rw-r--r--arch/ppc/Makefile1
-rw-r--r--arch/ppc/boot/images/Makefile3
-rw-r--r--arch/ppc/kernel/Makefile1
-rw-r--r--arch/ppc/kernel/align.c12
-rw-r--r--arch/ppc/kernel/cpu_setup_6xx.S42
-rw-r--r--arch/ppc/kernel/entry.S59
-rw-r--r--arch/ppc/kernel/fpu.S133
-rw-r--r--arch/ppc/kernel/head.S163
-rw-r--r--arch/ppc/kernel/head_44x.S6
-rw-r--r--arch/ppc/kernel/head_booke.h7
-rw-r--r--arch/ppc/kernel/head_fsl_booke.S8
-rw-r--r--arch/ppc/kernel/misc.S12
-rw-r--r--arch/ppc/kernel/pci.c2
-rw-r--r--arch/ppc/kernel/ptrace.c5
-rw-r--r--arch/ppc/kernel/setup.c37
-rw-r--r--arch/ppc/kernel/signal.c4
-rw-r--r--arch/ppc/kernel/traps.c4
-rw-r--r--arch/ppc/kernel/vmlinux.lds.S2
-rw-r--r--arch/ppc/platforms/4xx/ebony.c7
-rw-r--r--arch/ppc/platforms/4xx/luan.c5
-rw-r--r--arch/ppc/platforms/4xx/ocotea.c5
-rw-r--r--arch/ppc/platforms/chrp_pci.c7
-rw-r--r--arch/ppc/platforms/chrp_setup.c2
-rw-r--r--arch/ppc/platforms/pmac_cache.S54
-rw-r--r--arch/ppc/platforms/pmac_feature.c216
-rw-r--r--arch/ppc/platforms/pmac_low_i2c.c10
-rw-r--r--arch/ppc/platforms/pmac_sleep.S4
-rw-r--r--arch/ppc/platforms/pmac_smp.c14
-rw-r--r--arch/ppc/platforms/pmac_time.c7
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.c60
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.h1
-rw-r--r--arch/ppc/syslib/cpm2_pic.c5
-rw-r--r--arch/ppc/syslib/m8260_pci.c5
-rw-r--r--arch/ppc/syslib/mpc52xx_pci.c8
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.c12
-rw-r--r--arch/ppc64/Kconfig8
-rw-r--r--arch/ppc64/Kconfig.debug3
-rw-r--r--arch/ppc64/Makefile7
-rw-r--r--arch/ppc64/boot/addnote.c60
-rw-r--r--arch/ppc64/boot/main.c1
-rw-r--r--arch/ppc64/boot/start.c654
-rw-r--r--arch/ppc64/kernel/HvLpEvent.c2
-rw-r--r--arch/ppc64/kernel/misc.S2
-rw-r--r--arch/ppc64/kernel/nvram.c17
-rw-r--r--arch/ppc64/kernel/pSeries_hvCall.S8
-rw-r--r--arch/ppc64/kernel/pSeries_smp.c7
-rw-r--r--arch/ppc64/kernel/pci.c2
-rw-r--r--arch/ppc64/kernel/prom.c6
-rw-r--r--arch/ppc64/kernel/prom_init.c115
-rw-r--r--arch/ppc64/kernel/ptrace.c20
-rw-r--r--arch/ppc64/kernel/ptrace32.c5
-rw-r--r--arch/ppc64/kernel/rtas_flash.c12
-rw-r--r--arch/ppc64/kernel/scanlog.c4
-rw-r--r--arch/ppc64/kernel/signal.c6
-rw-r--r--arch/ppc64/kernel/signal32.c4
-rw-r--r--arch/ppc64/kernel/smp.c12
-rw-r--r--arch/ppc64/kernel/time.c12
-rw-r--r--arch/ppc64/kernel/vdso32/Makefile2
-rw-r--r--arch/ppc64/kernel/vdso32/cacheflush.S2
-rw-r--r--arch/ppc64/kernel/vdso32/gettimeofday.S1
-rw-r--r--arch/ppc64/kernel/vdso32/note.S25
-rw-r--r--arch/ppc64/kernel/vdso32/vdso32.lds.S3
-rw-r--r--arch/ppc64/kernel/vdso64/Makefile2
-rw-r--r--arch/ppc64/kernel/vdso64/cacheflush.S2
-rw-r--r--arch/ppc64/kernel/vdso64/note.S1
-rw-r--r--arch/ppc64/kernel/vdso64/vdso64.lds.S5
-rw-r--r--arch/ppc64/kernel/xics.c16
-rw-r--r--arch/ppc64/mm/hash_low.S9
-rw-r--r--arch/ppc64/mm/hash_native.c3
-rw-r--r--arch/ppc64/mm/hash_utils.c11
-rw-r--r--arch/ppc64/mm/hugetlbpage.c45
-rw-r--r--arch/ppc64/mm/imalloc.c5
-rw-r--r--arch/ppc64/mm/init.c201
-rw-r--r--arch/ppc64/mm/slb.c9
-rw-r--r--arch/ppc64/mm/stab.c5
-rw-r--r--arch/ppc64/xmon/ppc-opc.c119
-rw-r--r--arch/s390/defconfig19
-rw-r--r--arch/s390/kernel/compat_ioctl.c7
-rw-r--r--arch/s390/kernel/ptrace.c26
-rw-r--r--arch/s390/kernel/s390_ksyms.c1
-rw-r--r--arch/s390/kernel/setup.c401
-rw-r--r--arch/s390/kernel/time.c12
-rw-r--r--arch/s390/kernel/vtime.c25
-rw-r--r--arch/s390/mm/cmm.c9
-rw-r--r--arch/s390/mm/init.c15
-rw-r--r--arch/sh/Kconfig4
-rw-r--r--arch/sh/kernel/ptrace.c5
-rw-r--r--arch/sh64/kernel/ptrace.c5
-rw-r--r--arch/sh64/kernel/sys_sh64.c15
-rw-r--r--arch/sh64/kernel/syscalls.S2
-rw-r--r--arch/sparc/kernel/process.c16
-rw-r--r--arch/sparc/kernel/ptrace.c3
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c20
-rw-r--r--arch/sparc/prom/memory.c28
-rw-r--r--arch/sparc/prom/sun4prom.c2
-rw-r--r--arch/sparc64/Kconfig1
-rw-r--r--arch/sparc64/kernel/irq.c6
-rw-r--r--arch/sparc64/kernel/process.c4
-rw-r--r--arch/sparc64/kernel/ptrace.c3
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c2
-rw-r--r--arch/sparc64/kernel/time.c37
-rw-r--r--arch/sparc64/mm/init.c2
-rw-r--r--arch/um/Kconfig1
-rw-r--r--arch/um/Kconfig_i3866
-rw-r--r--arch/um/Kconfig_x86_646
-rw-r--r--arch/um/Makefile80
-rw-r--r--arch/um/Makefile-i3866
-rw-r--r--arch/um/Makefile-x86_644
-rw-r--r--arch/um/defconfig10
-rw-r--r--arch/um/drivers/chan_kern.c16
-rw-r--r--arch/um/drivers/line.c355
-rw-r--r--arch/um/drivers/ssl.c25
-rw-r--r--arch/um/drivers/stdio_console.c19
-rw-r--r--arch/um/drivers/ubd_kern.c14
-rw-r--r--arch/um/drivers/xterm_kern.c1
-rw-r--r--arch/um/include/common-offsets.h14
-rw-r--r--arch/um/include/kern_util.h7
-rw-r--r--arch/um/include/line.h36
-rw-r--r--arch/um/include/os.h1
-rw-r--r--arch/um/include/skas_ptrace.h15
-rw-r--r--arch/um/include/sysdep-i386/checksum.h39
-rw-r--r--arch/um/include/sysdep-i386/faultinfo.h29
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h23
-rw-r--r--arch/um/include/sysdep-i386/sigcontext.h19
-rw-r--r--arch/um/include/sysdep-i386/signal.h2
-rw-r--r--arch/um/include/sysdep-i386/skas_ptrace.h22
-rw-r--r--arch/um/include/sysdep-i386/syscalls.h99
-rw-r--r--arch/um/include/sysdep-ia64/skas_ptrace.h22
-rw-r--r--arch/um/include/sysdep-ppc/skas_ptrace.h22
-rw-r--r--arch/um/include/sysdep-x86_64/faultinfo.h29
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h16
-rw-r--r--arch/um/include/sysdep-x86_64/sigcontext.h15
-rw-r--r--arch/um/include/sysdep-x86_64/signal.h2
-rw-r--r--arch/um/include/sysdep-x86_64/skas_ptrace.h22
-rw-r--r--arch/um/include/sysdep-x86_64/syscalls.h59
-rw-r--r--arch/um/include/user_util.h1
-rw-r--r--arch/um/kernel/Makefile17
-rw-r--r--arch/um/kernel/checksum.c36
-rw-r--r--arch/um/kernel/irq.c1
-rw-r--r--arch/um/kernel/ksyms.c3
-rw-r--r--arch/um/kernel/process.c2
-rw-r--r--arch/um/kernel/process_kern.c24
-rw-r--r--arch/um/kernel/ptrace.c123
-rw-r--r--arch/um/kernel/sigio_user.c1
-rw-r--r--arch/um/kernel/skas/include/mode_kern-skas.h1
-rw-r--r--arch/um/kernel/skas/include/skas.h3
-rw-r--r--arch/um/kernel/skas/include/uaccess-skas.h2
-rw-r--r--arch/um/kernel/skas/process.c68
-rw-r--r--arch/um/kernel/skas/process_kern.c4
-rw-r--r--arch/um/kernel/skas/trap_user.c24
-rw-r--r--arch/um/kernel/skas/uaccess.c11
-rw-r--r--arch/um/kernel/skas/util/Makefile1
-rw-r--r--arch/um/kernel/skas/util/mk_ptregs-i386.c46
-rw-r--r--arch/um/kernel/skas/util/mk_ptregs-x86_64.c60
-rw-r--r--arch/um/kernel/sys_call_table.c276
-rw-r--r--arch/um/kernel/syscall_kern.c1
-rw-r--r--arch/um/kernel/time_kern.c18
-rw-r--r--arch/um/kernel/trap_kern.c27
-rw-r--r--arch/um/kernel/trap_user.c13
-rw-r--r--arch/um/kernel/tt/Makefile1
-rw-r--r--arch/um/kernel/tt/include/mode_kern-tt.h1
-rw-r--r--arch/um/kernel/tt/include/uaccess-tt.h2
-rw-r--r--arch/um/kernel/tt/mem.c8
-rw-r--r--arch/um/kernel/tt/process_kern.c20
-rw-r--r--arch/um/kernel/tt/syscall_user.c4
-rw-r--r--arch/um/kernel/tt/tracer.c8
-rw-r--r--arch/um/kernel/tt/trap_user.c6
-rw-r--r--arch/um/kernel/um_arch.c7
-rw-r--r--arch/um/kernel/vmlinux.lds.S6
-rw-r--r--arch/um/os-Linux/process.c5
-rw-r--r--arch/um/os-Linux/signal.c4
-rw-r--r--arch/um/os-Linux/sys-i386/registers.c7
-rw-r--r--arch/um/os-Linux/util/Makefile2
-rw-r--r--arch/um/os-Linux/util/mk_user_constants.c10
-rw-r--r--arch/um/scripts/Makefile.rules25
-rw-r--r--arch/um/sys-i386/Makefile18
-rw-r--r--arch/um/sys-i386/checksum.S6
-rw-r--r--arch/um/sys-i386/delay.c18
-rw-r--r--arch/um/sys-i386/kernel-offsets.c25
-rw-r--r--arch/um/sys-i386/ksyms.c8
-rw-r--r--arch/um/sys-i386/ldt.c5
-rw-r--r--arch/um/sys-i386/ptrace.c40
-rw-r--r--arch/um/sys-i386/signal.c17
-rw-r--r--arch/um/sys-i386/sys_call_table.S16
-rw-r--r--arch/um/sys-i386/user-offsets.c69
-rw-r--r--arch/um/sys-i386/util/Makefile7
-rw-r--r--arch/um/sys-i386/util/mk_sc.c75
-rw-r--r--arch/um/sys-i386/util/mk_thread.c22
-rw-r--r--arch/um/sys-i386/util/mk_thread_kern.c22
-rw-r--r--arch/um/sys-i386/util/mk_thread_user.c30
-rw-r--r--arch/um/sys-ppc/ptrace.c40
-rw-r--r--arch/um/sys-x86_64/Makefile22
-rw-r--r--arch/um/sys-x86_64/delay.c18
-rw-r--r--arch/um/sys-x86_64/kernel-offsets.c24
-rw-r--r--arch/um/sys-x86_64/ksyms.c20
-rw-r--r--arch/um/sys-x86_64/ptrace.c44
-rw-r--r--arch/um/sys-x86_64/signal.c12
-rw-r--r--arch/um/sys-x86_64/syscall_table.c59
-rw-r--r--arch/um/sys-x86_64/syscalls.c16
-rw-r--r--arch/um/sys-x86_64/um_module.c19
-rw-r--r--arch/um/sys-x86_64/user-offsets.c78
-rw-r--r--arch/um/sys-x86_64/util/Makefile6
-rw-r--r--arch/um/sys-x86_64/util/mk_sc.c79
-rw-r--r--arch/um/sys-x86_64/util/mk_thread.c20
-rw-r--r--arch/um/sys-x86_64/util/mk_thread_kern.c21
-rw-r--r--arch/um/sys-x86_64/util/mk_thread_user.c30
-rw-r--r--arch/um/util/Makefile7
-rw-r--r--arch/um/util/mk_constants.c32
-rw-r--r--arch/um/util/mk_constants_kern.c28
-rw-r--r--arch/um/util/mk_constants_user.c28
-rw-r--r--arch/um/util/mk_task.c (renamed from arch/um/util/mk_task_user.c)18
-rw-r--r--arch/um/util/mk_task_kern.c17
-rw-r--r--arch/v850/kernel/ptrace.c3
-rw-r--r--arch/x86_64/Kconfig5
-rw-r--r--arch/x86_64/boot/bootsect.S4
-rw-r--r--arch/x86_64/boot/setup.S6
-rw-r--r--arch/x86_64/ia32/vsyscall.lds2
-rw-r--r--arch/x86_64/kernel/e820.c26
-rw-r--r--arch/x86_64/kernel/early_printk.c2
-rw-r--r--arch/x86_64/kernel/entry.S5
-rw-r--r--arch/x86_64/kernel/head64.c7
-rw-r--r--arch/x86_64/kernel/io_apic.c2
-rw-r--r--arch/x86_64/kernel/kprobes.c7
-rw-r--r--arch/x86_64/kernel/module.c4
-rw-r--r--arch/x86_64/kernel/nmi.c9
-rw-r--r--arch/x86_64/kernel/process.c12
-rw-r--r--arch/x86_64/kernel/ptrace.c26
-rw-r--r--arch/x86_64/kernel/setup.c12
-rw-r--r--arch/x86_64/kernel/setup64.c3
-rw-r--r--arch/x86_64/kernel/signal.c2
-rw-r--r--arch/x86_64/kernel/sys_x86_64.c6
-rw-r--r--arch/x86_64/kernel/x8664_ksyms.c13
-rw-r--r--arch/x86_64/lib/putuser.S12
-rw-r--r--crypto/Kconfig4
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/scan.c4
-rw-r--r--drivers/atm/eni.c27
-rw-r--r--drivers/atm/fore200e.c4
-rw-r--r--drivers/atm/he.c3
-rw-r--r--drivers/atm/he.h2
-rw-r--r--drivers/base/bus.c5
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/platform.c4
-rw-r--r--drivers/block/DAC960.c132
-rw-r--r--drivers/block/DAC960.h317
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c13
-rw-r--r--drivers/block/aoe/aoedev.c11
-rw-r--r--drivers/block/aoe/aoenet.c17
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/block/genhd.c4
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/noop-iosched.c27
-rw-r--r--drivers/cdrom/cdrom.c2
-rw-r--r--drivers/cdrom/cdu31a.c6
-rw-r--r--drivers/cdrom/mcdx.c28
-rw-r--r--drivers/cdrom/sbpcd.c2
-rw-r--r--drivers/char/Kconfig20
-rw-r--r--drivers/char/Makefile3
-rw-r--r--drivers/char/agp/ali-agp.c4
-rw-r--r--drivers/char/agp/amd-k7-agp.c2
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/agp/ati-agp.c2
-rw-r--r--drivers/char/agp/backend.c4
-rw-r--r--drivers/char/agp/efficeon-agp.c2
-rw-r--r--drivers/char/agp/frontend.c6
-rw-r--r--drivers/char/agp/nvidia-agp.c2
-rw-r--r--drivers/char/agp/sis-agp.c2
-rw-r--r--drivers/char/agp/sworks-agp.c2
-rw-r--r--drivers/char/agp/via-agp.c4
-rw-r--r--drivers/char/dtlk.c2
-rw-r--r--drivers/char/hangcheck-timer.c104
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c1
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c36
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c97
-rw-r--r--drivers/char/ipmi/ipmi_si_sm.h2
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c2
-rw-r--r--drivers/char/keyboard.c3
-rw-r--r--drivers/char/mbcs.c849
-rw-r--r--drivers/char/mbcs.h553
-rw-r--r--drivers/char/rio/rio_linux.c2
-rw-r--r--drivers/char/s3c2410-rtc.c8
-rw-r--r--drivers/char/snsc.c8
-rw-r--r--drivers/char/snsc.h40
-rw-r--r--drivers/char/snsc_event.c304
-rw-r--r--drivers/char/sonypi.c6
-rw-r--r--drivers/char/specialix.c11
-rw-r--r--drivers/char/stallion.c4
-rw-r--r--drivers/char/tpm/tpm.c6
-rw-r--r--drivers/char/tty_io.c2
-rw-r--r--drivers/char/vt_ioctl.c3
-rw-r--r--drivers/cpufreq/cpufreq.c97
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c4
-rw-r--r--drivers/ide/pci/sis5513.c6
-rw-r--r--drivers/ide/ppc/pmac.c7
-rw-r--r--drivers/ieee1394/ohci1394.c69
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c2
-rw-r--r--drivers/input/joystick/spaceorb.c2
-rw-r--r--drivers/input/keyboard/atkbd.c2
-rw-r--r--drivers/isdn/capi/capi.c10
-rw-r--r--drivers/isdn/capi/kcapi_proc.c10
-rw-r--r--drivers/isdn/divert/isdn_divert.c10
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c1
-rw-r--r--drivers/macintosh/adbhid.c40
-rw-r--r--drivers/macintosh/via-pmu.c9
-rw-r--r--drivers/md/dm-crypt.c19
-rw-r--r--drivers/md/dm-emc.c6
-rw-r--r--drivers/md/dm-hw-handler.c2
-rw-r--r--drivers/md/dm-mpath.c32
-rw-r--r--drivers/md/dm-path-selector.c2
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/md/dm-zero.c4
-rw-r--r--drivers/md/dm.c96
-rw-r--r--drivers/md/md.c14
-rw-r--r--drivers/md/multipath.c5
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/md/raid5.c2
-rw-r--r--drivers/md/raid6main.c2
-rw-r--r--drivers/media/common/ir-common.c18
-rw-r--r--drivers/media/dvb/frontends/cx22702.c15
-rw-r--r--drivers/media/dvb/frontends/cx22702.h3
-rw-r--r--drivers/media/video/Kconfig1
-rw-r--r--drivers/media/video/bttv-driver.c6
-rw-r--r--drivers/media/video/bttv-i2c.c14
-rw-r--r--drivers/media/video/cx88/cx88-core.c5
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c16
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c4
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c6
-rw-r--r--drivers/media/video/cx88/cx88-video.c12
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/msp3400.c28
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c89
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c21
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c20
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c1
-rw-r--r--drivers/media/video/tuner-core.c14
-rw-r--r--drivers/media/video/tvaudio.c2
-rw-r--r--drivers/mmc/Kconfig2
-rw-r--r--drivers/net/3c59x.c9
-rw-r--r--drivers/net/Kconfig10
-rw-r--r--drivers/net/Space.c2
-rw-r--r--drivers/net/appletalk/Kconfig2
-rw-r--r--drivers/net/appletalk/cops.c4
-rw-r--r--drivers/net/appletalk/cops_ffdrv.h2
-rw-r--r--drivers/net/appletalk/cops_ltdrv.h2
-rw-r--r--drivers/net/appletalk/ltpc.c2
-rw-r--r--drivers/net/arcnet/capmode.c2
-rw-r--r--drivers/net/gt96100eth.h4
-rw-r--r--drivers/net/hamradio/6pack.c4
-rw-r--r--drivers/net/hamradio/Kconfig4
-rw-r--r--drivers/net/hamradio/baycom_epp.c4
-rw-r--r--drivers/net/hamradio/bpqether.c10
-rw-r--r--drivers/net/hamradio/dmascc.c4
-rw-r--r--drivers/net/hamradio/hdlcdrv.c4
-rw-r--r--drivers/net/hamradio/mkiss.c4
-rw-r--r--drivers/net/hamradio/scc.c5
-rw-r--r--drivers/net/hamradio/yam.c4
-rw-r--r--drivers/net/hp100.c4
-rw-r--r--drivers/net/irda/Kconfig10
-rw-r--r--drivers/net/loopback.c2
-rw-r--r--drivers/net/mv643xx_eth.c4
-rw-r--r--drivers/net/ppp_deflate.c6
-rw-r--r--drivers/net/ppp_generic.c12
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/slip.c30
-rw-r--r--drivers/net/sunbmac.c13
-rw-r--r--drivers/net/sunhme.c16
-rw-r--r--drivers/net/sunlance.c17
-rw-r--r--drivers/net/sunqe.c17
-rw-r--r--drivers/net/tg3.c662
-rw-r--r--drivers/net/tg3.h25
-rw-r--r--drivers/net/wan/Kconfig6
-rw-r--r--drivers/net/wan/cycx_x25.c8
-rw-r--r--drivers/net/wan/pc300_drv.c22
-rw-r--r--drivers/net/wan/pc300_tty.c27
-rw-r--r--drivers/net/wan/sdla_chdlc.c13
-rw-r--r--drivers/net/wan/x25_asy.c20
-rw-r--r--drivers/oprofile/oprofile_files.c4
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/parport/parport_pc.c34
-rw-r--r--drivers/pci/hotplug.c4
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c7
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c23
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c2
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci-sysfs.c82
-rw-r--r--drivers/pci/pci.c20
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pci/proc.c1
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/pci/rom.c14
-rw-r--r--drivers/pcmcia/pd6729.c2
-rw-r--r--drivers/pcmcia/ti113x.h40
-rw-r--r--drivers/pnp/manager.c2
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c4
-rw-r--r--drivers/pnp/pnpbios/rsparser.c4
-rw-r--r--drivers/s390/block/dasd.c21
-rw-r--r--drivers/s390/block/dasd_cmb.c19
-rw-r--r--drivers/s390/block/dasd_devmap.c59
-rw-r--r--drivers/s390/block/dasd_eckd.c5
-rw-r--r--drivers/s390/block/dasd_genhd.c10
-rw-r--r--drivers/s390/block/dasd_int.h7
-rw-r--r--drivers/s390/block/dasd_ioctl.c31
-rw-r--r--drivers/s390/block/dasd_proc.c8
-rw-r--r--drivers/s390/cio/airq.c4
-rw-r--r--drivers/s390/cio/cio.c4
-rw-r--r--drivers/s390/cio/device_ops.c6
-rw-r--r--drivers/s390/cio/qdio.h6
-rw-r--r--drivers/s390/crypto/z90main.c140
-rw-r--r--drivers/s390/net/smsgiucv.c19
-rw-r--r--drivers/s390/net/smsgiucv.h4
-rw-r--r--drivers/sbus/char/rtc.c109
-rw-r--r--drivers/scsi/Kconfig12
-rw-r--r--drivers/scsi/NCR53C9x.c5
-rw-r--r--drivers/scsi/aacraid/linit.c2
-rw-r--r--drivers/scsi/esp.c11
-rw-r--r--drivers/scsi/pas16.c6
-rw-r--r--drivers/scsi/pluto.c2
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c49
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c5
-rw-r--r--drivers/serial/21285.c2
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/8250_hp300.c53
-rw-r--r--drivers/serial/8250_pci.c2
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/amba-pl011.c2
-rw-r--r--drivers/serial/clps711x.c65
-rw-r--r--drivers/serial/imx.c68
-rw-r--r--drivers/serial/ioc4_serial.c50
-rw-r--r--drivers/serial/jsm/jsm.h1
-rw-r--r--drivers/serial/jsm/jsm_neo.c2
-rw-r--r--drivers/serial/jsm/jsm_tty.c4
-rw-r--r--drivers/serial/mpsc.c14
-rw-r--r--drivers/serial/mpsc.h10
-rw-r--r--drivers/serial/s3c2410.c2
-rw-r--r--drivers/serial/sa1100.c65
-rw-r--r--drivers/serial/serial_cs.c173
-rw-r--r--drivers/serial/serial_lh7a40x.c2
-rw-r--r--drivers/serial/sn_console.c4
-rw-r--r--drivers/serial/sunsab.c16
-rw-r--r--drivers/serial/sunsu.c11
-rw-r--r--drivers/telephony/ixj.c18
-rw-r--r--drivers/telephony/ixj.h2
-rw-r--r--drivers/usb/core/message.c4
-rw-r--r--drivers/usb/core/urb.c6
-rw-r--r--drivers/usb/core/usb.c6
-rw-r--r--drivers/usb/gadget/ether.c2
-rw-r--r--drivers/usb/gadget/inode.c2
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c2
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c65
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ehci.h19
-rw-r--r--drivers/usb/host/hc_crisv10.c2
-rw-r--r--drivers/usb/host/sl811-hcd.c4
-rw-r--r--drivers/usb/image/mdc800.c2
-rw-r--r--drivers/usb/image/microtek.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/ati_remote.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/usbkbd.c3
-rw-r--r--drivers/usb/media/ov511.c2
-rw-r--r--drivers/usb/media/pwc/pwc-ctrl.c80
-rw-r--r--drivers/usb/media/pwc/pwc-if.c12
-rw-r--r--drivers/usb/media/pwc/pwc-ioctl.h2
-rw-r--r--drivers/usb/media/pwc/pwc.h6
-rw-r--r--drivers/usb/media/sn9c102_core.c4
-rw-r--r--drivers/usb/media/sn9c102_sensor.h2
-rw-r--r--drivers/usb/misc/legousbtower.c2
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c3
-rw-r--r--drivers/usb/net/pegasus.c4
-rw-r--r--drivers/usb/net/usbnet.c432
-rw-r--r--drivers/usb/net/zd1201.c28
-rw-r--r--drivers/usb/serial/Kconfig18
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/airprime.c63
-rw-r--r--drivers/usb/serial/cypress_m8.c187
-rw-r--r--drivers/usb/serial/ftdi_sio.c46
-rw-r--r--drivers/usb/serial/ftdi_sio.h36
-rw-r--r--drivers/usb/serial/hp4x.c85
-rw-r--r--drivers/usb/serial/io_usbvend.h2
-rw-r--r--drivers/usb/serial/keyspan_usa90msg.h2
-rw-r--r--drivers/usb/storage/debug.c1
-rw-r--r--drivers/usb/storage/shuttle_usbat.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h39
-rw-r--r--drivers/video/Kconfig8
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/amba-clcd.c22
-rw-r--r--drivers/video/aty/radeon_base.c118
-rw-r--r--drivers/video/console/fbcon.c5
-rw-r--r--drivers/video/console/vgacon.c2
-rw-r--r--drivers/video/cyber2000fb.c8
-rw-r--r--drivers/video/fbcmap.c32
-rw-r--r--drivers/video/fbmem.c7
-rw-r--r--drivers/video/fbmon.c1
-rw-r--r--drivers/video/fbsysfs.c2
-rw-r--r--drivers/video/i810/i810_main.c14
-rw-r--r--drivers/video/imsttfb.c4
-rw-r--r--drivers/video/imxfb.c695
-rw-r--r--drivers/video/imxfb.h72
-rw-r--r--drivers/video/intelfb/intelfbdrv.c38
-rw-r--r--drivers/video/intelfb/intelfbdrv.h68
-rw-r--r--drivers/video/logo/Kconfig2
-rw-r--r--drivers/video/nvidia/nvidia.c26
-rw-r--r--drivers/video/radeonfb.c2
-rw-r--r--drivers/video/savage/savagefb_driver.c6
-rw-r--r--drivers/video/sis/init.c4
-rw-r--r--drivers/video/sis/init.h3
-rw-r--r--drivers/video/sis/init301.c9
-rw-r--r--drivers/video/sis/init301.h4
-rw-r--r--drivers/video/sis/sis_main.c5
-rw-r--r--drivers/video/tcx.c14
-rw-r--r--drivers/video/tdfxfb.c88
-rw-r--r--drivers/video/tgafb.c4
-rw-r--r--drivers/video/vesafb.c3
-rw-r--r--fs/afs/file.c3
-rw-r--r--fs/aio.c75
-rw-r--r--fs/autofs4/autofs_i.h15
-rw-r--r--fs/autofs4/expire.c16
-rw-r--r--fs/autofs4/inode.c1
-rw-r--r--fs/autofs4/waitq.c22
-rw-r--r--fs/bad_inode.c2
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--fs/bio.c2
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/buffer.c42
-rw-r--r--fs/char_dev.c2
-rw-r--r--fs/cifs/AUTHORS24
-rw-r--r--fs/cifs/CHANGES39
-rw-r--r--fs/cifs/README49
-rw-r--r--fs/cifs/TODO30
-rw-r--r--fs/cifs/cifs_debug.c43
-rw-r--r--fs/cifs/cifs_fs_sb.h1
-rw-r--r--fs/cifs/cifs_unicode.c4
-rw-r--r--fs/cifs/cifsencrypt.c16
-rw-r--r--fs/cifs/cifsfs.c34
-rw-r--r--fs/cifs/cifsfs.h8
-rw-r--r--fs/cifs/cifsglob.h18
-rw-r--r--fs/cifs/cifspdu.h71
-rw-r--r--fs/cifs/cifsproto.h109
-rw-r--r--fs/cifs/cifssmb.c436
-rw-r--r--fs/cifs/connect.c743
-rw-r--r--fs/cifs/dir.c189
-rw-r--r--fs/cifs/fcntl.c3
-rw-r--r--fs/cifs/file.c15
-rw-r--r--fs/cifs/inode.c106
-rw-r--r--fs/cifs/ioctl.c75
-rw-r--r--fs/cifs/link.c18
-rw-r--r--fs/cifs/misc.c160
-rw-r--r--fs/cifs/netmisc.c5
-rw-r--r--fs/cifs/readdir.c120
-rw-r--r--fs/cifs/smberr.h231
-rw-r--r--fs/cifs/transport.c54
-rw-r--r--fs/cifs/xattr.c51
-rw-r--r--fs/compat.c6
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/eventpoll.c2
-rw-r--r--fs/exec.c7
-rw-r--r--fs/ext3/inode.c190
-rw-r--r--fs/fcntl.c3
-rw-r--r--fs/fs-writeback.c4
-rw-r--r--fs/hfs/mdb.c5
-rw-r--r--fs/hfs/super.c8
-rw-r--r--fs/hfsplus/super.c6
-rw-r--r--fs/hostfs/hostfs_kern.c12
-rw-r--r--fs/inode.c23
-rw-r--r--fs/isofs/compress.c21
-rw-r--r--fs/isofs/dir.c13
-rw-r--r--fs/isofs/export.c6
-rw-r--r--fs/isofs/inode.c19
-rw-r--r--fs/isofs/isofs.h190
-rw-r--r--fs/isofs/joliet.c6
-rw-r--r--fs/isofs/namei.c13
-rw-r--r--fs/isofs/rock.c8
-rw-r--r--fs/isofs/util.c5
-rw-r--r--fs/jffs2/compr_rubin.c18
-rw-r--r--fs/jffs2/compr_zlib.c12
-rw-r--r--fs/jffs2/file.c3
-rw-r--r--fs/jfs/inode.c35
-rw-r--r--fs/jfs/jfs_dmap.c12
-rw-r--r--fs/jfs/jfs_dtree.c6
-rw-r--r--fs/jfs/jfs_imap.c84
-rw-r--r--fs/jfs/jfs_incore.h1
-rw-r--r--fs/jfs/jfs_logmgr.c150
-rw-r--r--fs/jfs/jfs_logmgr.h9
-rw-r--r--fs/jfs/jfs_metapage.c908
-rw-r--r--fs/jfs/jfs_metapage.h80
-rw-r--r--fs/jfs/jfs_mount.c5
-rw-r--r--fs/jfs/jfs_txnmgr.c166
-rw-r--r--fs/jfs/jfs_umount.c16
-rw-r--r--fs/jfs/jfs_xtree.c63
-rw-r--r--fs/jfs/resize.c3
-rw-r--r--fs/jfs/super.c37
-rw-r--r--fs/locks.c6
-rw-r--r--fs/mbcache.c2
-rw-r--r--fs/mpage.c108
-rw-r--r--fs/namei.c28
-rw-r--r--fs/nfs/idmap.c4
-rw-r--r--fs/nfs/inode.c4
-rw-r--r--fs/nls/nls_base.c2
-rw-r--r--fs/partitions/msdos.c5
-rw-r--r--fs/proc/base.c34
-rw-r--r--fs/reiserfs/bitmap.c11
-rw-r--r--fs/reiserfs/dir.c8
-rw-r--r--fs/reiserfs/file.c13
-rw-r--r--fs/reiserfs/inode.c14
-rw-r--r--fs/reiserfs/item_ops.c5
-rw-r--r--fs/reiserfs/journal.c14
-rw-r--r--fs/reiserfs/namei.c2
-rw-r--r--fs/reiserfs/objectid.c18
-rw-r--r--fs/reiserfs/procfs.c4
-rw-r--r--fs/reiserfs/stree.c51
-rw-r--r--fs/reiserfs/super.c35
-rw-r--r--fs/select.c6
-rw-r--r--fs/seq_file.c9
-rw-r--r--fs/sysfs/file.c4
-rw-r--r--fs/udf/file.c6
-rw-r--r--fs/udf/inode.c4
-rw-r--r--fs/udf/udftime.c2
-rw-r--r--fs/xfs/Makefile2
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c81
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c11
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c43
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c5
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h10
-rw-r--r--fs/xfs/xfs_dfrag.c2
-rw-r--r--fs/xfs/xfs_iget.c51
-rw-r--r--fs/xfs/xfs_inode.c2
-rw-r--r--fs/xfs/xfs_inode.h6
-rw-r--r--fs/xfs/xfs_iomap.c26
-rw-r--r--fs/xfs/xfs_iomap.h25
-rw-r--r--fs/xfs/xfs_mount.c9
-rw-r--r--fs/xfs/xfs_mount.h19
-rw-r--r--fs/xfs/xfs_types.h1
-rw-r--r--fs/xfs/xfs_utils.c2
-rw-r--r--fs/xfs/xfs_utils.h2
-rw-r--r--fs/xfs/xfs_vfsops.c67
-rw-r--r--fs/xfs/xfs_vnodeops.c11
-rw-r--r--include/asm-alpha/bug.h3
-rw-r--r--include/asm-alpha/errno.h4
-rw-r--r--include/asm-alpha/siginfo.h2
-rw-r--r--include/asm-alpha/signal.h25
-rw-r--r--include/asm-arm/arch-cl7500/vmalloc.h11
-rw-r--r--include/asm-arm/arch-clps711x/vmalloc.h11
-rw-r--r--include/asm-arm/arch-ebsa110/vmalloc.h11
-rw-r--r--include/asm-arm/arch-ebsa285/vmalloc.h11
-rw-r--r--include/asm-arm/arch-epxa10db/vmalloc.h11
-rw-r--r--include/asm-arm/arch-h720x/vmalloc.h11
-rw-r--r--include/asm-arm/arch-imx/imxfb.h35
-rw-r--r--include/asm-arm/arch-imx/vmalloc.h12
-rw-r--r--include/asm-arm/arch-integrator/cm.h6
-rw-r--r--include/asm-arm/arch-integrator/platform.h108
-rw-r--r--include/asm-arm/arch-integrator/vmalloc.h11
-rw-r--r--include/asm-arm/arch-iop3xx/vmalloc.h3
-rw-r--r--include/asm-arm/arch-ixp2000/platform.h1
-rw-r--r--include/asm-arm/arch-ixp2000/vmalloc.h3
-rw-r--r--include/asm-arm/arch-ixp4xx/vmalloc.h12
-rw-r--r--include/asm-arm/arch-l7200/vmalloc.h11
-rw-r--r--include/asm-arm/arch-lh7a40x/vmalloc.h11
-rw-r--r--include/asm-arm/arch-omap/vmalloc.h12
-rw-r--r--include/asm-arm/arch-pxa/vmalloc.h11
-rw-r--r--include/asm-arm/arch-rpc/vmalloc.h11
-rw-r--r--include/asm-arm/arch-s3c2410/regs-iis.h10
-rw-r--r--include/asm-arm/arch-s3c2410/regs-mem.h8
-rw-r--r--include/asm-arm/arch-s3c2410/regs-spi.h2
-rw-r--r--include/asm-arm/arch-s3c2410/uncompress.h6
-rw-r--r--include/asm-arm/arch-s3c2410/vmalloc.h12
-rw-r--r--include/asm-arm/arch-sa1100/vmalloc.h11
-rw-r--r--include/asm-arm/arch-shark/vmalloc.h11
-rw-r--r--include/asm-arm/arch-versatile/vmalloc.h12
-rw-r--r--include/asm-arm/bug.h3
-rw-r--r--include/asm-arm/hardware/amba_clcd.h31
-rw-r--r--include/asm-arm/hardware/clock.h7
-rw-r--r--include/asm-arm/io.h28
-rw-r--r--include/asm-arm/pgtable.h17
-rw-r--r--include/asm-arm/processor.h7
-rw-r--r--include/asm-arm/rtc.h4
-rw-r--r--include/asm-arm/signal.h26
-rw-r--r--include/asm-arm/string.h17
-rw-r--r--include/asm-arm/thread_info.h6
-rw-r--r--include/asm-arm/unistd.h3
-rw-r--r--include/asm-arm26/bug.h3
-rw-r--r--include/asm-arm26/signal.h22
-rw-r--r--include/asm-cris/page.h4
-rw-r--r--include/asm-cris/signal.h25
-rw-r--r--include/asm-frv/bug.h2
-rw-r--r--include/asm-frv/pgtable.h4
-rw-r--r--include/asm-frv/signal.h25
-rw-r--r--include/asm-generic/bug.h22
-rw-r--r--include/asm-generic/errno.h4
-rw-r--r--include/asm-generic/resource.h7
-rw-r--r--include/asm-generic/sections.h2
-rw-r--r--include/asm-generic/siginfo.h13
-rw-r--r--include/asm-generic/signal.h21
-rw-r--r--include/asm-generic/unaligned.h83
-rw-r--r--include/asm-h8300/signal.h24
-rw-r--r--include/asm-i386/apic.h1
-rw-r--r--include/asm-i386/bug.h5
-rw-r--r--include/asm-i386/checksum.h2
-rw-r--r--include/asm-i386/cpufeature.h4
-rw-r--r--include/asm-i386/e820.h2
-rw-r--r--include/asm-i386/floppy.h2
-rw-r--r--include/asm-i386/hpet.h1
-rw-r--r--include/asm-i386/module.h4
-rw-r--r--include/asm-i386/pgtable.h4
-rw-r--r--include/asm-i386/setup.h2
-rw-r--r--include/asm-i386/signal.h29
-rw-r--r--include/asm-i386/string.h89
-rw-r--r--include/asm-i386/system.h6
-rw-r--r--include/asm-ia64/bitops.h21
-rw-r--r--include/asm-ia64/bug.h5
-rw-r--r--include/asm-ia64/gcc_intrin.h10
-rw-r--r--include/asm-ia64/hw_irq.h1
-rw-r--r--include/asm-ia64/pal.h68
-rw-r--r--include/asm-ia64/perfmon.h12
-rw-r--r--include/asm-ia64/pgalloc.h148
-rw-r--r--include/asm-ia64/processor.h10
-rw-r--r--include/asm-ia64/sal.h50
-rw-r--r--include/asm-ia64/siginfo.h4
-rw-r--r--include/asm-ia64/signal.h21
-rw-r--r--include/asm-ia64/smp.h5
-rw-r--r--include/asm-ia64/sn/addrs.h14
-rw-r--r--include/asm-ia64/sn/arch.h17
-rw-r--r--include/asm-ia64/sn/bte.h53
-rw-r--r--include/asm-ia64/sn/fetchop.h85
-rw-r--r--include/asm-ia64/sn/geo.h45
-rw-r--r--include/asm-ia64/sn/l1.h3
-rw-r--r--include/asm-ia64/sn/nodepda.h19
-rw-r--r--include/asm-ia64/sn/pcibus_provider_defs.h (renamed from arch/ia64/sn/include/pci/pcibus_provider_defs.h)13
-rw-r--r--include/asm-ia64/sn/pcidev.h (renamed from arch/ia64/sn/include/pci/pcidev.h)4
-rw-r--r--include/asm-ia64/sn/pda.h12
-rw-r--r--include/asm-ia64/sn/shub_mmr.h61
-rw-r--r--include/asm-ia64/sn/shubio.h3116
-rw-r--r--include/asm-ia64/sn/sn_cpuid.h25
-rw-r--r--include/asm-ia64/sn/sn_fru.h44
-rw-r--r--include/asm-ia64/sn/sn_sal.h111
-rw-r--r--include/asm-ia64/sn/sndrv.h47
-rw-r--r--include/asm-ia64/sn/tioca.h596
-rw-r--r--include/asm-ia64/sn/tioca_provider.h206
-rw-r--r--include/asm-ia64/sn/tiocx.h71
-rw-r--r--include/asm-ia64/sn/types.h3
-rw-r--r--include/asm-ia64/sn/xp.h436
-rw-r--r--include/asm-m32r/signal.h29
-rw-r--r--include/asm-m68k/bug.h3
-rw-r--r--include/asm-m68k/signal.h28
-rw-r--r--include/asm-m68knommu/MC68328.h2
-rw-r--r--include/asm-m68knommu/MC68EZ328.h2
-rw-r--r--include/asm-m68knommu/MC68VZ328.h2
-rw-r--r--include/asm-m68knommu/signal.h24
-rw-r--r--include/asm-mips/bug.h4
-rw-r--r--include/asm-mips/errno.h4
-rw-r--r--include/asm-mips/siginfo.h2
-rw-r--r--include/asm-mips/signal.h24
-rw-r--r--include/asm-parisc/bug.h2
-rw-r--r--include/asm-parisc/errno.h4
-rw-r--r--include/asm-parisc/floppy.h2
-rw-r--r--include/asm-parisc/signal.h11
-rw-r--r--include/asm-parisc/uaccess.h2
-rw-r--r--include/asm-ppc/bug.h3
-rw-r--r--include/asm-ppc/hydra.h2
-rw-r--r--include/asm-ppc/pci-bridge.h4
-rw-r--r--include/asm-ppc/pmac_feature.h3
-rw-r--r--include/asm-ppc/reg_booke.h1
-rw-r--r--include/asm-ppc/sigcontext.h2
-rw-r--r--include/asm-ppc/signal.h28
-rw-r--r--include/asm-ppc64/a.out.h2
-rw-r--r--include/asm-ppc64/bug.h7
-rw-r--r--include/asm-ppc64/elf.h8
-rw-r--r--include/asm-ppc64/imalloc.h24
-rw-r--r--include/asm-ppc64/mmu.h193
-rw-r--r--include/asm-ppc64/mmu_context.h82
-rw-r--r--include/asm-ppc64/page.h30
-rw-r--r--include/asm-ppc64/pgalloc.h2
-rw-r--r--include/asm-ppc64/pgtable.h156
-rw-r--r--include/asm-ppc64/signal.h33
-rw-r--r--include/asm-ppc64/spinlock.h8
-rw-r--r--include/asm-ppc64/xics.h3
-rw-r--r--include/asm-s390/bug.h3
-rw-r--r--include/asm-s390/cmb.h2
-rw-r--r--include/asm-s390/debug.h2
-rw-r--r--include/asm-s390/page.h2
-rw-r--r--include/asm-s390/processor.h2
-rw-r--r--include/asm-s390/ptrace.h16
-rw-r--r--include/asm-s390/siginfo.h6
-rw-r--r--include/asm-s390/signal.h25
-rw-r--r--include/asm-sh/bug.h3
-rw-r--r--include/asm-sh/checksum.h2
-rw-r--r--include/asm-sh/floppy.h2
-rw-r--r--include/asm-sh/signal.h25
-rw-r--r--include/asm-sh64/bug.h4
-rw-r--r--include/asm-sh64/checksum.h2
-rw-r--r--include/asm-sh64/signal.h25
-rw-r--r--include/asm-sparc/bug.h3
-rw-r--r--include/asm-sparc/errno.h4
-rw-r--r--include/asm-sparc/floppy.h2
-rw-r--r--include/asm-sparc/mxcc.h4
-rw-r--r--include/asm-sparc/signal.h19
-rw-r--r--include/asm-sparc/uaccess.h2
-rw-r--r--include/asm-sparc64/bug.h3
-rw-r--r--include/asm-sparc64/errno.h4
-rw-r--r--include/asm-sparc64/mostek.h6
-rw-r--r--include/asm-sparc64/parport.h6
-rw-r--r--include/asm-sparc64/pgalloc.h9
-rw-r--r--include/asm-sparc64/pgtable.h5
-rw-r--r--include/asm-sparc64/siginfo.h2
-rw-r--r--include/asm-sparc64/signal.h24
-rw-r--r--include/asm-sparc64/spinlock.h4
-rw-r--r--include/asm-um/arch-signal-i386.h24
-rw-r--r--include/asm-um/archparam-i386.h137
-rw-r--r--include/asm-um/archparam-ppc.h20
-rw-r--r--include/asm-um/archparam-x86_64.h36
-rw-r--r--include/asm-um/common.lds.S9
-rw-r--r--include/asm-um/delay.h2
-rw-r--r--include/asm-um/elf-i386.h169
-rw-r--r--include/asm-um/elf-ppc.h54
-rw-r--r--include/asm-um/elf-x86_64.h73
-rw-r--r--include/asm-um/elf.h37
-rw-r--r--include/asm-um/fixmap.h1
-rw-r--r--include/asm-um/ipc.h7
-rw-r--r--include/asm-um/linkage.h7
-rw-r--r--include/asm-um/page.h5
-rw-r--r--include/asm-um/pgtable-3level.h4
-rw-r--r--include/asm-um/pgtable.h2
-rw-r--r--include/asm-um/processor-generic.h15
-rw-r--r--include/asm-um/processor-i386.h7
-rw-r--r--include/asm-um/processor-x86_64.h12
-rw-r--r--include/asm-um/ptrace-i386.h2
-rw-r--r--include/asm-um/ptrace-x86_64.h2
-rw-r--r--include/asm-um/setup.h3
-rw-r--r--include/asm-um/thread_info.h4
-rw-r--r--include/asm-v850/bug.h3
-rw-r--r--include/asm-v850/signal.h27
-rw-r--r--include/asm-x86_64/apic.h1
-rw-r--r--include/asm-x86_64/bootsetup.h3
-rw-r--r--include/asm-x86_64/bug.h4
-rw-r--r--include/asm-x86_64/cpufeature.h14
-rw-r--r--include/asm-x86_64/e820.h2
-rw-r--r--include/asm-x86_64/floppy.h2
-rw-r--r--include/asm-x86_64/siginfo.h2
-rw-r--r--include/asm-x86_64/signal.h28
-rw-r--r--include/asm-x86_64/unistd.h2
-rw-r--r--include/linux/audit.h64
-rw-r--r--include/linux/auto_fs4.h2
-rw-r--r--include/linux/awe_voice.h6
-rw-r--r--include/linux/binfmts.h1
-rw-r--r--include/linux/compiler-gcc2.h5
-rw-r--r--include/linux/compiler.h6
-rw-r--r--include/linux/cpufreq.h5
-rw-r--r--include/linux/edd.h2
-rw-r--r--include/linux/etherdevice.h2
-rw-r--r--include/linux/fb.h3
-rw-r--r--include/linux/fddidevice.h2
-rw-r--r--include/linux/fs.h114
-rw-r--r--include/linux/gfp.h6
-rw-r--r--include/linux/hippidevice.h2
-rw-r--r--include/linux/if.h2
-rw-r--r--include/linux/if_arp.h2
-rw-r--r--include/linux/if_ltalk.h2
-rw-r--r--include/linux/input.h5
-rw-r--r--include/linux/iso_fs.h147
-rw-r--r--include/linux/iso_fs_i.h27
-rw-r--r--include/linux/iso_fs_sb.h34
-rw-r--r--include/linux/ixjuser.h2
-rw-r--r--include/linux/kernel.h9
-rw-r--r--include/linux/kprobes.h3
-rw-r--r--include/linux/mm.h5
-rw-r--r--include/linux/mpage.h3
-rw-r--r--include/linux/net.h40
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/netfilter_ipv4.h3
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/page-flags.h1
-rw-r--r--include/linux/patchkey.h45
-rw-r--r--include/linux/pci.h3
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/rcupdate.h23
-rw-r--r--include/linux/reboot_fixups.h10
-rw-r--r--include/linux/reiserfs_acl.h12
-rw-r--r--include/linux/reiserfs_fs.h249
-rw-r--r--include/linux/reiserfs_xattr.h4
-rw-r--r--include/linux/rtnetlink.h8
-rw-r--r--include/linux/sched.h9
-rw-r--r--include/linux/signal.h17
-rw-r--r--include/linux/skbuff.h7
-rw-r--r--include/linux/slab.h23
-rw-r--r--include/linux/sockios.h2
-rw-r--r--include/linux/soundcard.h34
-rw-r--r--include/linux/syscalls.h3
-rw-r--r--include/linux/sysctl.h1
-rw-r--r--include/linux/tc_act/tc_defact.h21
-rw-r--r--include/linux/trdevice.h2
-rw-r--r--include/linux/xfrm.h5
-rw-r--r--include/net/act_generic.h142
-rw-r--r--include/net/addrconf.h4
-rw-r--r--include/net/ax25.h10
-rw-r--r--include/net/icmp.h2
-rw-r--r--include/net/ip.h2
-rw-r--r--include/net/ipv6.h2
-rw-r--r--include/net/pkt_sched.h6
-rw-r--r--include/net/route.h2
-rw-r--r--include/net/sctp/sm.h42
-rw-r--r--include/net/sctp/structs.h11
-rw-r--r--include/net/sock.h139
-rw-r--r--include/net/tc_act/tc_defact.h13
-rw-r--r--include/net/tcp.h13
-rw-r--r--include/net/udp.h2
-rw-r--r--include/net/xfrm.h10
-rw-r--r--include/video/edid.h9
-rw-r--r--include/video/tdfx.h2
-rw-r--r--init/Kconfig23
-rw-r--r--ipc/mqueue.c8
-rw-r--r--ipc/shm.c14
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/audit.c112
-rw-r--r--kernel/auditsc.c47
-rw-r--r--kernel/exit.c15
-rw-r--r--kernel/futex.c3
-rw-r--r--kernel/itimer.c6
-rw-r--r--kernel/kallsyms.c13
-rw-r--r--kernel/kprobes.c142
-rw-r--r--kernel/kthread.c2
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/panic.c4
-rw-r--r--kernel/power/swsusp.c2
-rw-r--r--kernel/printk.c27
-rw-r--r--kernel/profile.c4
-rw-r--r--kernel/ptrace.c5
-rw-r--r--kernel/rcupdate.c22
-rw-r--r--kernel/sched.c28
-rw-r--r--kernel/signal.c9
-rw-r--r--kernel/stop_machine.c10
-rw-r--r--kernel/sys.c27
-rw-r--r--kernel/sys_ni.c1
-rw-r--r--kernel/sysctl.c2
-rw-r--r--kernel/time.c8
-rw-r--r--kernel/timer.c2
-rw-r--r--lib/Kconfig.debug1
-rw-r--r--lib/kobject.c3
-rw-r--r--lib/rwsem-spinlock.c6
-rw-r--r--lib/rwsem.c4
-rw-r--r--lib/sort.c2
-rw-r--r--lib/string.c8
-rw-r--r--mm/filemap.c51
-rw-r--r--mm/highmem.c2
-rw-r--r--mm/mempolicy.c2
-rw-r--r--mm/mempool.c35
-rw-r--r--mm/mmap.c34
-rw-r--r--mm/mremap.c6
-rw-r--r--mm/page-writeback.c6
-rw-r--r--mm/page_alloc.c38
-rw-r--r--mm/rmap.c113
-rw-r--r--mm/slab.c47
-rw-r--r--mm/swap_state.c27
-rw-r--r--mm/truncate.c4
-rw-r--r--mm/vmalloc.c8
-rw-r--r--net/802/fddi.c2
-rw-r--r--net/802/hippi.c2
-rw-r--r--net/8021q/vlanproc.c2
-rw-r--r--net/appletalk/dev.c22
-rw-r--r--net/atm/common.c4
-rw-r--r--net/atm/resources.c11
-rw-r--r--net/atm/signaling.c1
-rw-r--r--net/ax25/af_ax25.c4
-rw-r--r--net/ax25/ax25_ds_subr.c3
-rw-r--r--net/ax25/ax25_ip.c4
-rw-r--r--net/ax25/ax25_out.c9
-rw-r--r--net/ax25/ax25_subr.c4
-rw-r--r--net/bluetooth/af_bluetooth.c1
-rw-r--r--net/bluetooth/bnep/sock.c1
-rw-r--r--net/bluetooth/cmtp/capi.c1
-rw-r--r--net/bluetooth/cmtp/core.c1
-rw-r--r--net/bluetooth/cmtp/sock.c1
-rw-r--r--net/bluetooth/hci_conn.c1
-rw-r--r--net/bluetooth/hci_core.c1
-rw-r--r--net/bluetooth/hci_event.c1
-rw-r--r--net/bluetooth/hci_sock.c1
-rw-r--r--net/bluetooth/hidp/core.c1
-rw-r--r--net/bluetooth/hidp/sock.c1
-rw-r--r--net/bluetooth/l2cap.c1
-rw-r--r--net/bluetooth/rfcomm/sock.c1
-rw-r--r--net/bluetooth/sco.c1
-rw-r--r--net/core/datagram.c28
-rw-r--r--net/core/dev.c17
-rw-r--r--net/core/iovec.c2
-rw-r--r--net/core/link_watch.c7
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/netfilter.c17
-rw-r--r--net/core/rtnetlink.c68
-rw-r--r--net/core/scm.c1
-rw-r--r--net/core/skbuff.c12
-rw-r--r--net/core/sock.c27
-rw-r--r--net/core/stream.c12
-rw-r--r--net/decnet/dn_dev.c25
-rw-r--r--net/decnet/netfilter/dn_rtmsg.c3
-rw-r--r--net/ethernet/eth.c2
-rw-r--r--net/ipv4/af_inet.c3
-rw-r--r--net/ipv4/devinet.c23
-rw-r--r--net/ipv4/ip_input.c2
-rw-r--r--net/ipv4/ip_output.c5
-rw-r--r--net/ipv4/multipath_wrandom.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c58
-rw-r--r--net/ipv4/netfilter/ip_nat_core.c9
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c54
-rw-r--r--net/ipv4/netfilter/ip_queue.c20
-rw-r--r--net/ipv4/netfilter/iptable_raw.c6
-rw-r--r--net/ipv4/protocol.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/route.c6
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_diag.c3
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/tcp_ipv4.c7
-rw-r--r--net/ipv4/tcp_minisocks.c2
-rw-r--r--net/ipv4/tcp_output.c27
-rw-r--r--net/ipv4/tcp_timer.c2
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv4/xfrm4_policy.c42
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/ipv6/exthdrs_core.c11
-rw-r--r--net/ipv6/icmp.c4
-rw-r--r--net/ipv6/netfilter/ip6_queue.c20
-rw-r--r--net/ipv6/raw.c7
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/ipv6/xfrm6_policy.c43
-rw-r--r--net/irda/irda_device.c2
-rw-r--r--net/netlink/af_netlink.c7
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/sched/Kconfig12
-rw-r--r--net/sched/Makefile11
-rw-r--r--net/sched/act_api.c4
-rw-r--r--net/sched/cls_fw.c31
-rw-r--r--net/sched/sch_api.c1
-rw-r--r--net/sched/sch_generic.c5
-rw-r--r--net/sched/sch_htb.c4
-rw-r--r--net/sched/sch_netem.c131
-rw-r--r--net/sched/simple.c93
-rw-r--r--net/sctp/endpointola.c1
-rw-r--r--net/sctp/ipv6.c4
-rw-r--r--net/sctp/output.c4
-rw-r--r--net/sctp/protocol.c7
-rw-r--r--net/sctp/sm_make_chunk.c19
-rw-r--r--net/sctp/sm_statefuns.c77
-rw-r--r--net/sctp/socket.c38
-rw-r--r--net/sctp/sysctl.c8
-rw-r--r--net/socket.c2
-rw-r--r--net/sunrpc/xdr.c12
-rw-r--r--net/unix/af_unix.c1
-rw-r--r--net/wanrouter/wanmain.c4
-rw-r--r--net/xfrm/xfrm_policy.c25
-rw-r--r--net/xfrm/xfrm_state.c5
-rw-r--r--net/xfrm/xfrm_user.c87
-rw-r--r--scripts/kallsyms.c94
-rw-r--r--scripts/kconfig/Makefile14
-rw-r--r--scripts/kconfig/POTFILES.in5
-rw-r--r--scripts/kconfig/conf.c20
-rw-r--r--scripts/kconfig/confdata.c16
-rw-r--r--scripts/kconfig/gconf.c52
-rw-r--r--scripts/kconfig/kxgettext.c221
-rw-r--r--scripts/kconfig/lkc.h8
-rw-r--r--scripts/kconfig/mconf.c120
-rw-r--r--scripts/kconfig/menu.c4
-rw-r--r--scripts/kconfig/qconf.cc59
-rwxr-xr-xscripts/kernel-doc49
-rwxr-xr-xscripts/makeman185
-rw-r--r--scripts/mod/file2alias.c111
-rwxr-xr-xscripts/patch-kernel131
-rwxr-xr-xscripts/split-man112
-rw-r--r--security/selinux/hooks.c24
-rw-r--r--security/selinux/include/av_perm_to_string.h2
-rw-r--r--security/selinux/include/av_permissions.h2
-rw-r--r--security/selinux/nlmsgtab.c13
-rw-r--r--sound/isa/Kconfig1
-rw-r--r--sound/oss/ac97_codec.c1
-rw-r--r--sound/oss/msnd_pinnacle.c2
-rw-r--r--sound/oss/sonicvibes.c2
-rw-r--r--sound/pci/hda/hda_intel.c4
-rw-r--r--sound/pci/intel8x0.c6
-rw-r--r--sound/pci/via82xx.c2
-rw-r--r--sound/ppc/Kconfig2
-rw-r--r--sound/ppc/Makefile2
-rw-r--r--sound/ppc/pmac.c8
-rw-r--r--sound/ppc/pmac.h4
-rw-r--r--sound/ppc/powermac.c7
-rw-r--r--sound/ppc/toonie.c379
-rw-r--r--sound/ppc/tumbler.c28
1282 files changed, 32287 insertions, 15731 deletions
diff --git a/CREDITS b/CREDITS
index c9068febcffc..3b9e160d6f7e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -339,7 +339,7 @@ W: http://tomas.nocrew.org/
339D: dsp56k device driver 339D: dsp56k device driver
340 340
341N: Ross Biro 341N: Ross Biro
342E: bir7@leland.Stanford.Edu 342E: ross.biro@gmail.com
343D: Original author of the Linux networking code 343D: Original author of the Linux networking code
344 344
345N: Anton Blanchard 345N: Anton Blanchard
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index 72dc90f8f4a7..8de8a01a2474 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -12,8 +12,6 @@ Following translations are available on the WWW:
12 12
1300-INDEX 1300-INDEX
14 - this file. 14 - this file.
15BK-usage/
16 - directory with info on BitKeeper.
17BUG-HUNTING 15BUG-HUNTING
18 - brute force method of doing binary search of patches to find bug. 16 - brute force method of doing binary search of patches to find bug.
19Changes 17Changes
diff --git a/Documentation/BK-usage/00-INDEX b/Documentation/BK-usage/00-INDEX
deleted file mode 100644
index 82768784ea52..000000000000
--- a/Documentation/BK-usage/00-INDEX
+++ /dev/null
@@ -1,51 +0,0 @@
1bk-kernel-howto.txt: Description of kernel workflow under BitKeeper
2
3bk-make-sum: Create summary of changesets in one repository and not
4another, typically in preparation to be sent to an upstream maintainer.
5Typical usage:
6 cd my-updated-repo
7 bk-make-sum ~/repo/original-repo
8 mv /tmp/linus.txt ../original-repo.txt
9
10bksend: Create readable text output containing summary of changes, GNU
11patch of the changes, and BK metadata of changes (as needed for proper
12importing into BitKeeper by an upstream maintainer). This output is
13suitable for emailing BitKeeper changes. The recipient of this output
14may pipe it directly to 'bk receive'.
15
16bz64wrap: helper script. Uncompressed input is piped to this script,
17which compresses its input, and then outputs the uu-/base64-encoded
18version of the compressed input.
19
20cpcset: Copy changeset between unrelated repositories.
21Attempts to preserve changeset user, user address, description, in
22addition to the changeset (the patch) itself.
23Typical usage:
24 cd my-updated-repo
25 bk changes # looking for a changeset...
26 cpcset 1.1511 . ../another-repo
27
28csets-to-patches: Produces a delta of two BK repositories, in the form
29of individual files, each containing a single cset as a GNU patch.
30Output is several files, each with the filename "/tmp/rev-$REV.patch"
31Typical usage:
32 cd my-updated-repo
33 bk changes -L ~/repo/original-repo 2>&1 | \
34 perl csets-to-patches
35
36cset-to-linus: Produces a delta of two BK repositories, in the form of
37changeset descriptions, with 'diffstat' output created for each
38individual changset.
39Typical usage:
40 cd my-updated-repo
41 bk changes -L ~/repo/original-repo 2>&1 | \
42 perl cset-to-linus > summary.txt
43
44gcapatch: Generates patch containing changes in local repository.
45Typical usage:
46 cd my-updated-repo
47 gcapatch > foo.patch
48
49unbz64wrap: Reverse an encoded, compressed data stream created by
50bz64wrap into an uncompressed, typically text/plain output.
51
diff --git a/Documentation/BK-usage/bk-kernel-howto.txt b/Documentation/BK-usage/bk-kernel-howto.txt
deleted file mode 100644
index b7b9075d2910..000000000000
--- a/Documentation/BK-usage/bk-kernel-howto.txt
+++ /dev/null
@@ -1,283 +0,0 @@
1
2 Doing the BK Thing, Penguin-Style
3
4
5
6
7This set of notes is intended mainly for kernel developers, occasional
8or full-time, but sysadmins and power users may find parts of it useful
9as well. It assumes at least a basic familiarity with CVS, both at a
10user level (use on the cmd line) and at a higher level (client-server model).
11Due to the author's background, an operation may be described in terms
12of CVS, or in terms of how that operation differs from CVS.
13
14This is -not- intended to be BitKeeper documentation. Always run
15"bk help <command>" or in X "bk helptool <command>" for reference
16documentation.
17
18
19BitKeeper Concepts
20------------------
21
22In the true nature of the Internet itself, BitKeeper is a distributed
23system. When applied to revision control, this means doing away with
24client-server, and changing to a parent-child model... essentially
25peer-to-peer. On the developer's end, this also represents a
26fundamental disruption in the standard workflow of changes, commits,
27and merges. You will need to take a few minutes to think about
28how to best work under BitKeeper, and re-optimize things a bit.
29In some sense it is a bit radical, because it might described as
30tossing changes out into a maelstrom and having them magically
31land at the right destination... but I'm getting ahead of myself.
32
33Let's start with this progression:
34Each BitKeeper source tree on disk is a repository unto itself.
35Each repository has a parent (except the root/original, of course).
36Each repository contains a set of a changesets ("csets").
37Each cset is one or more changed files, bundled together.
38
39Each tree is a repository, so all changes are checked into the local
40tree. When a change is checked in, all modified files are grouped
41into a logical unit, the changeset. Internally, BK links these
42changesets in a tree, representing various converging and diverging
43lines of development. These changesets are the bread and butter of
44the BK system.
45
46After the concept of changesets, the next thing you need to get used
47to is having multiple copies of source trees lying around. This -really-
48takes some getting used to, for some people. Separate source trees
49are the means in BitKeeper by which you delineate parallel lines
50of development, both minor and major. What would be branches in
51CVS become separate source trees, or "clones" in BitKeeper [heh,
52or Star Wars] terminology.
53
54Clones and changesets are the tools from which most of the power of
55BitKeeper is derived. As mentioned earlier, each clone has a parent,
56the tree used as the source when the new clone was created. In a
57CVS-like setup, the parent would be a remote server on the Internet,
58and the child is your local clone of that tree.
59
60Once you have established a common baseline between two source trees --
61a common parent -- then you can merge changesets between those two
62trees with ease. Merging changes into a tree is called a "pull", and
63is analagous to 'cvs update'. A pull downloads all the changesets in
64the remote tree you do not have, and merges them. Sending changes in
65one tree to another tree is called a "push". Push sends all changes
66in the local tree the remote does not yet have, and merges them.
67
68From these concepts come some initial command examples:
69
701) bk clone -q http://linux.bkbits.net/linux-2.5 linus-2.5
71Download a 2.5 stock kernel tree, naming it "linus-2.5" in the local dir.
72The "-q" disables listing every single file as it is downloaded.
73
742) bk clone -ql linus-2.5 alpha-2.5
75Create a separate source tree for the Alpha AXP architecture.
76The "-l" uses hard links instead of copying data, since both trees are
77on the local disk. You can also replace the above with "bk lclone -q ..."
78
79You only clone a tree -once-. After cloning the tree lives a long time
80on disk, being updating by pushes and pulls.
81
823) cd alpha-2.5 ; bk pull http://gkernel.bkbits.net/alpha-2.5
83Download changes in "alpha-2.5" repository which are not present
84in the local repository, and merge them into the source tree.
85
864) bk -r co -q
87Because every tree is a repository, files must be checked out before
88they will be in their standard places in the source tree.
89
905) bk vi fs/inode.c # example change...
91 bk citool # checkin, using X tool
92 bk push bk://gkernel@bkbits.net/alpha-2.5 # upload change
93Typical example of a BK sequence that would replace the analagous CVS
94situation,
95 vi fs/inode.c
96 cvs commit
97
98As this is just supposed to be a quick BK intro, for more in-depth
99tutorials, live working demos, and docs, see http://www.bitkeeper.com/
100
101
102
103BK and Kernel Development Workflow
104----------------------------------
105Currently the latest 2.5 tree is available via "bk clone $URL"
106and "bk pull $URL" at http://linux.bkbits.net/linux-2.5
107This should change in a few weeks to a kernel.org URL.
108
109
110A big part of using BitKeeper is organizing the various trees you have
111on your local disk, and organizing the flow of changes among those
112trees, and remote trees. If one were to graph the relationships between
113a desired BK setup, you are likely to see a few-many-few graph, like
114this:
115
116 linux-2.5
117 |
118 merge-to-linus-2.5
119 / | |
120 / | |
121 vm-hacks bugfixes filesys personal-hacks
122 \ | | /
123 \ | | /
124 \ | | /
125 testing-and-validation
126
127Since a "bk push" sends all changes not in the target tree, and
128since a "bk pull" receives all changes not in the source tree, you want
129to make sure you are only pushing specific changes to the desired tree,
130not all changes from "peer parent" trees. For example, pushing a change
131from the testing-and-validation tree would probably be a bad idea,
132because it will push all changes from vm-hacks, bugfixes, filesys, and
133personal-hacks trees into the target tree.
134
135One would typically work on only one "theme" at a time, either
136vm-hacks or bugfixes or filesys, keeping those changes isolated in
137their own tree during development, and only merge the isolated with
138other changes when going upstream (to Linus or other maintainers) or
139downstream (to your "union" trees, like testing-and-validation above).
140
141It should be noted that some of this separation is not just recommended
142practice, it's actually [for now] -enforced- by BitKeeper. BitKeeper
143requires that changesets maintain a certain order, which is the reason
144that "bk push" sends all local changesets the remote doesn't have. This
145separation may look like a lot of wasted disk space at first, but it
146helps when two unrelated changes may "pollute" the same area of code, or
147don't follow the same pace of development, or any other of the standard
148reasons why one creates a development branch.
149
150Small development branches (clones) will appear and disappear:
151
152 -------- A --------- B --------- C --------- D -------
153 \ /
154 -----short-term devel branch-----
155
156While long-term branches will parallel a tree (or trees), with period
157merge points. In this first example, we pull from a tree (pulls,
158"\") periodically, such as what occurs when tracking changes in a
159vendor tree, never pushing changes back up the line:
160
161 -------- A --------- B --------- C --------- D -------
162 \ \ \
163 ----long-term devel branch-----------------
164
165And then a more common case in Linux kernel development, a long term
166branch with periodic merges back into the tree (pushes, "/"):
167
168 -------- A --------- B --------- C --------- D -------
169 \ \ / \
170 ----long-term devel branch-----------------
171
172
173
174
175
176Submitting Changes to Linus
177---------------------------
178There's a bit of an art, or style, of submitting changes to Linus.
179Since Linus's tree is now (you might say) fully integrated into the
180distributed BitKeeper system, there are several prerequisites to
181properly submitting a BitKeeper change. All these prereq's are just
182general cleanliness of BK usage, so as people become experts at BK, feel
183free to optimize this process further (assuming Linus agrees, of
184course).
185
186
187
1880) Make sure your tree was originally cloned from the linux-2.5 tree
189created by Linus. If your tree does not have this as its ancestor, it
190is impossible to reliably exchange changesets.
191
192
193
1941) Pay attention to your commit text. The commit message that
195accompanies each changeset you submit will live on forever in history,
196and is used by Linus to accurately summarize the changes in each
197pre-patch. Remember that there is no context, so
198 "fix for new scheduler changes"
199would be too vague, but
200 "fix mips64 arch for new scheduler switch_to(), TIF_xxx semantics"
201would be much better.
202
203You can and should use the command "bk comment -C<rev>" to update the
204commit text, and improve it after the fact. This is very useful for
205development: poor, quick descriptions during development, which get
206cleaned up using "bk comment" before issuing the "bk push" to submit the
207changes.
208
209
210
2112) Include an Internet-available URL for Linus to pull from, such as
212
213 Pull from: http://gkernel.bkbits.net/net-drivers-2.5
214
215
216
2173) Include a summary and "diffstat -p1" of each changeset that will be
218downloaded, when Linus issues a "bk pull". The author auto-generates
219these summaries using "bk changes -L <parent>", to obtain a listing
220of all the pending-to-send changesets, and their commit messages.
221
222It is important to show Linus what he will be downloading when he issues
223a "bk pull", to reduce the time required to sift the changes once they
224are downloaded to Linus's local machine.
225
226IMPORTANT NOTE: One of the features of BK is that your repository does
227not have to be up to date, in order for Linus to receive your changes.
228It is considered a courtesy to keep your repository fairly recent, to
229lessen any potential merge work Linus may need to do.
230
231
2324) Split up your changes. Each maintainer<->Linus situation is likely
233to be slightly different here, so take this just as general advice. The
234author splits up changes according to "themes" when merging with Linus.
235Simultaneous pushes from local development go to special trees which
236exist solely to house changes "queued" for Linus. Example of the trees:
237
238 net-drivers-2.5 -- on-going net driver maintenance
239 vm-2.5 -- VM-related changes
240 fs-2.5 -- filesystem-related changes
241
242Linus then has much more freedom for pulling changes. He could (for
243example) issue a "bk pull" on vm-2.5 and fs-2.5 trees, to merge their
244changes, but hold off net-drivers-2.5 because of a change that needs
245more discussion.
246
247Other maintainers may find that a single linus-pull-from tree is
248adequate for passing BK changesets to him.
249
250
251
252Frequently Answered Questions
253-----------------------------
2541) How do I change the e-mail address shown in the changelog?
255A. When you run "bk citool" or "bk commit", set environment
256 variables BK_USER and BK_HOST to the desired username
257 and host/domain name.
258
259
2602) How do I use tags / get a diff between two kernel versions?
261A. Pass the tags Linus uses to 'bk export'.
262
263ChangeSets are in a forward-progressing order, so it's pretty easy
264to get a snapshot starting and ending at any two points in time.
265Linus puts tags on each release and pre-release, so you could use
266these two examples:
267
268 bk export -tpatch -hdu -rv2.5.4,v2.5.5 | less
269 # creates patch-2.5.5 essentially
270 bk export -tpatch -du -rv2.5.5-pre1,v2.5.5 | less
271 # changes from pre1 to final
272
273A tag is just an alias for a specific changeset... and since changesets
274are ordered, a tag is thus a marker for a specific point in time (or
275specific state of the tree).
276
277
2783) Is there an easy way to generate One Big Patch versus mainline,
279 for my long-lived kernel branch?
280A. Yes. This requires BK 3.x, though.
281
282 bk export -tpatch -r`bk repogca bk://linux.bkbits.net/linux-2.5`,+
283
diff --git a/Documentation/BK-usage/bk-make-sum b/Documentation/BK-usage/bk-make-sum
deleted file mode 100755
index 58ca46a0fcc6..000000000000
--- a/Documentation/BK-usage/bk-make-sum
+++ /dev/null
@@ -1,34 +0,0 @@
1#!/bin/sh -e
2# DIR=$HOME/BK/axp-2.5
3# cd $DIR
4
5LINUS_REPO=$1
6DIRBASE=`basename $PWD`
7
8{
9cat <<EOT
10Please do a
11
12 bk pull bk://gkernel.bkbits.net/$DIRBASE
13
14This will update the following files:
15
16EOT
17
18bk export -tpatch -hdu -r`bk repogca $LINUS_REPO`,+ | diffstat -p1 2>/dev/null
19
20cat <<EOT
21
22through these ChangeSets:
23
24EOT
25
26bk changes -L -d'$unless(:MERGE:){ChangeSet|:CSETREV:\n}' $LINUS_REPO |
27bk -R prs -h -d'$unless(:MERGE:){<:P:@:HOST:> (:D: :I:)\n$each(:C:){ (:C:)\n}\n}' -
28
29} > /tmp/linus.txt
30
31cat <<EOT
32Mail text in /tmp/linus.txt; please check and send using your favourite
33mailer.
34EOT
diff --git a/Documentation/BK-usage/bksend b/Documentation/BK-usage/bksend
deleted file mode 100755
index 836ca943694f..000000000000
--- a/Documentation/BK-usage/bksend
+++ /dev/null
@@ -1,36 +0,0 @@
1#!/bin/sh
2# A script to format BK changeset output in a manner that is easy to read.
3# Andreas Dilger <adilger@turbolabs.com> 13/02/2002
4#
5# Add diffstat output after Changelog <adilger@turbolabs.com> 21/02/2002
6
7PROG=bksend
8
9usage() {
10 echo "usage: $PROG -r<rev>"
11 echo -e "\twhere <rev> is of the form '1.23', '1.23..', '1.23..1.27',"
12 echo -e "\tor '+' to indicate the most recent revision"
13
14 exit 1
15}
16
17case $1 in
18-r) REV=$2; shift ;;
19-r*) REV=`echo $1 | sed 's/^-r//'` ;;
20*) echo "$PROG: no revision given, you probably don't want that";;
21esac
22
23[ -z "$REV" ] && usage
24
25echo "You can import this changeset into BK by piping this whole message to:"
26echo "'| bk receive [path to repository]' or apply the patch as usual."
27
28SEP="\n===================================================================\n\n"
29echo -e $SEP
30env PAGER=/bin/cat bk changes -r$REV
31echo
32bk export -tpatch -du -h -r$REV | diffstat
33echo; echo
34bk export -tpatch -du -h -r$REV
35echo -e $SEP
36bk send -wgzip_uu -r$REV -
diff --git a/Documentation/BK-usage/bz64wrap b/Documentation/BK-usage/bz64wrap
deleted file mode 100755
index be780876849f..000000000000
--- a/Documentation/BK-usage/bz64wrap
+++ /dev/null
@@ -1,41 +0,0 @@
1#!/bin/sh
2
3# bz64wrap - the sending side of a bzip2 | base64 stream
4# Andreas Dilger <adilger@clusterfs.com> Jan 2002
5
6
7PATH=$PATH:/usr/bin:/usr/local/bin:/usr/freeware/bin
8
9# A program to generate base64 encoding on stdout
10BASE64_ENCODE="uuencode -m /dev/stdout"
11BASE64_BEGIN=
12BASE64_END=
13
14BZIP=NO
15BASE64=NO
16
17# Test if we have the bzip program installed
18bzip2 -c /dev/null > /dev/null 2>&1 && BZIP=YES
19
20# Test if uuencode can handle the -m (MIME) encoding option
21$BASE64_ENCODE < /dev/null > /dev/null 2>&1 && BASE64=YES
22
23if [ $BASE64 = NO ]; then
24 BASE64_ENCODE=mimencode
25 BASE64_BEGIN="begin-base64 644 -"
26 BASE64_END="===="
27
28 $BASE64_ENCODE < /dev/null > /dev/null 2>&1 && BASE64=YES
29fi
30
31if [ $BZIP = NO -o $BASE64 = NO ]; then
32 echo "$0: can't use bz64 encoding: bzip2=$BZIP, $BASE64_ENCODE=$BASE64"
33 exit 1
34fi
35
36# Sadly, mimencode does not appear to have good "begin" and "end" markers
37# like uuencode does, and it is picky about getting the right start/end of
38# the base64 stream, so we handle this internally.
39echo "$BASE64_BEGIN"
40bzip2 -9 | $BASE64_ENCODE
41echo "$BASE64_END"
diff --git a/Documentation/BK-usage/cpcset b/Documentation/BK-usage/cpcset
deleted file mode 100755
index b8faca97dab9..000000000000
--- a/Documentation/BK-usage/cpcset
+++ /dev/null
@@ -1,36 +0,0 @@
1#!/bin/sh
2#
3# Purpose: Copy changeset patch and description from one
4# repository to another, unrelated one.
5#
6# usage: cpcset [revision] [from-repository] [to-repository]
7#
8
9REV=$1
10FROM=$2
11TO=$3
12TMPF=/tmp/cpcset.$$
13
14rm -f $TMPF*
15
16CWD_SAVE=`pwd`
17cd $FROM
18bk changes -r$REV | \
19 grep -v '^ChangeSet' | \
20 sed -e 's/^ //g' > $TMPF.log
21
22USERHOST=`bk changes -r$REV | grep '^ChangeSet' | awk '{print $4}'`
23export BK_USER=`echo $USERHOST | awk '-F@' '{print $1}'`
24export BK_HOST=`echo $USERHOST | awk '-F@' '{print $2}'`
25
26bk export -tpatch -hdu -r$REV > $TMPF.patch && \
27cd $CWD_SAVE && \
28cd $TO && \
29bk import -tpatch -CFR -y"`cat $TMPF.log`" $TMPF.patch . && \
30bk commit -y"`cat $TMPF.log`"
31
32rm -f $TMPF*
33
34echo changeset $REV copied.
35echo ""
36
diff --git a/Documentation/BK-usage/cset-to-linus b/Documentation/BK-usage/cset-to-linus
deleted file mode 100755
index d28a96f8c618..000000000000
--- a/Documentation/BK-usage/cset-to-linus
+++ /dev/null
@@ -1,49 +0,0 @@
1#!/usr/bin/perl -w
2
3use strict;
4
5my ($lhs, $rev, $tmp, $rhs, $s);
6my @cset_text = ();
7my @pipe_text = ();
8my $have_cset = 0;
9
10while (<>) {
11 next if /^---/;
12
13 if (($lhs, $tmp, $rhs) = (/^(ChangeSet\@)([^,]+)(, .*)$/)) {
14 &cset_rev if ($have_cset);
15
16 $rev = $tmp;
17 $have_cset = 1;
18
19 push(@cset_text, $_);
20 }
21
22 elsif ($have_cset) {
23 push(@cset_text, $_);
24 }
25}
26&cset_rev if ($have_cset);
27exit(0);
28
29
30sub cset_rev {
31 my $empty_cset = 0;
32
33 open PIPE, "bk export -tpatch -hdu -r $rev | diffstat -p1 2>/dev/null |" or die;
34 while ($s = <PIPE>) {
35 $empty_cset = 1 if ($s =~ /0 files changed/);
36 push(@pipe_text, $s);
37 }
38 close(PIPE);
39
40 if (! $empty_cset) {
41 print @cset_text;
42 print @pipe_text;
43 print "\n\n";
44 }
45
46 @pipe_text = ();
47 @cset_text = ();
48}
49
diff --git a/Documentation/BK-usage/csets-to-patches b/Documentation/BK-usage/csets-to-patches
deleted file mode 100755
index e2b81c35883f..000000000000
--- a/Documentation/BK-usage/csets-to-patches
+++ /dev/null
@@ -1,44 +0,0 @@
1#!/usr/bin/perl -w
2
3use strict;
4
5my ($lhs, $rev, $tmp, $rhs, $s);
6my @cset_text = ();
7my @pipe_text = ();
8my $have_cset = 0;
9
10while (<>) {
11 next if /^---/;
12
13 if (($lhs, $tmp, $rhs) = (/^(ChangeSet\@)([^,]+)(, .*)$/)) {
14 &cset_rev if ($have_cset);
15
16 $rev = $tmp;
17 $have_cset = 1;
18
19 push(@cset_text, $_);
20 }
21
22 elsif ($have_cset) {
23 push(@cset_text, $_);
24 }
25}
26&cset_rev if ($have_cset);
27exit(0);
28
29
30sub cset_rev {
31 my $empty_cset = 0;
32
33 system("bk export -tpatch -du -r $rev > /tmp/rev-$rev.patch");
34
35 if (! $empty_cset) {
36 print @cset_text;
37 print @pipe_text;
38 print "\n\n";
39 }
40
41 @pipe_text = ();
42 @cset_text = ();
43}
44
diff --git a/Documentation/BK-usage/gcapatch b/Documentation/BK-usage/gcapatch
deleted file mode 100755
index aaeb17dc7c7f..000000000000
--- a/Documentation/BK-usage/gcapatch
+++ /dev/null
@@ -1,8 +0,0 @@
1#!/bin/sh
2#
3# Purpose: Generate GNU diff of local changes versus canonical top-of-tree
4#
5# Usage: gcapatch > foo.patch
6#
7
8bk export -tpatch -hdu -r`bk repogca bk://linux.bkbits.net/linux-2.5`,+
diff --git a/Documentation/BK-usage/unbz64wrap b/Documentation/BK-usage/unbz64wrap
deleted file mode 100755
index 4fc3e73e9a81..000000000000
--- a/Documentation/BK-usage/unbz64wrap
+++ /dev/null
@@ -1,25 +0,0 @@
1#!/bin/sh
2
3# unbz64wrap - the receiving side of a bzip2 | base64 stream
4# Andreas Dilger <adilger@clusterfs.com> Jan 2002
5
6# Sadly, mimencode does not appear to have good "begin" and "end" markers
7# like uuencode does, and it is picky about getting the right start/end of
8# the base64 stream, so we handle this explicitly here.
9
10PATH=$PATH:/usr/bin:/usr/local/bin:/usr/freeware/bin
11
12if mimencode -u < /dev/null > /dev/null 2>&1 ; then
13 SHOW=
14 while read LINE; do
15 case $LINE in
16 begin-base64*) SHOW=YES ;;
17 ====) SHOW= ;;
18 *) [ "$SHOW" ] && echo "$LINE" ;;
19 esac
20 done | mimencode -u | bunzip2
21 exit $?
22else
23 cat - | uudecode -o /dev/stdout | bunzip2
24 exit $?
25fi
diff --git a/Documentation/Changes b/Documentation/Changes
index caa6a5529b6b..57542bc25edd 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -357,14 +357,14 @@ Quota-tools
357---------- 357----------
358o <http://sourceforge.net/projects/linuxquota/> 358o <http://sourceforge.net/projects/linuxquota/>
359 359
360Jade
361----
362o <ftp://ftp.jclark.com/pub/jade/jade-1.2.1.tar.gz>
363
364DocBook Stylesheets 360DocBook Stylesheets
365------------------- 361-------------------
366o <http://nwalsh.com/docbook/dsssl/> 362o <http://nwalsh.com/docbook/dsssl/>
367 363
364XMLTO XSLT Frontend
365-------------------
366o <http://cyberelk.net/tim/xmlto/>
367
368Intel P6 microcode 368Intel P6 microcode
369------------------ 369------------------
370o <http://www.urbanmyth.org/microcode/> 370o <http://www.urbanmyth.org/microcode/>
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index e69d68659455..87da3478fada 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -7,11 +7,10 @@
7# list of DOCBOOKS. 7# list of DOCBOOKS.
8 8
9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ 9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
10 kernel-hacking.xml kernel-locking.xml via-audio.xml \ 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 deviceiobook.xml procfs-guide.xml tulip-user.xml \ 11 procfs-guide.xml writing_usb_driver.xml \
12 writing_usb_driver.xml sis900.xml kernel-api.xml \ 12 sis900.xml kernel-api.xml journal-api.xml lsm.xml usb.xml \
13 journal-api.xml lsm.xml usb.xml gadget.xml libata.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml
14 mtdnand.xml librs.xml
15 14
16### 15###
17# The build process is as follows (targets): 16# The build process is as follows (targets):
@@ -42,14 +41,16 @@ MAN := $(patsubst %.xml, %.9, $(BOOKS))
42mandocs: $(MAN) 41mandocs: $(MAN)
43 42
44installmandocs: mandocs 43installmandocs: mandocs
45 $(MAKEMAN) install Documentation/DocBook/man 44 mkdir -p /usr/local/man/man9/
45 install Documentation/DocBook/man/*.9.gz /usr/local/man/man9/
46 46
47### 47###
48#External programs used 48#External programs used
49KERNELDOC = scripts/kernel-doc 49KERNELDOC = scripts/kernel-doc
50DOCPROC = scripts/basic/docproc 50DOCPROC = scripts/basic/docproc
51SPLITMAN = $(PERL) $(srctree)/scripts/split-man 51
52MAKEMAN = $(PERL) $(srctree)/scripts/makeman 52XMLTOFLAGS = -m Documentation/DocBook/stylesheet.xsl
53#XMLTOFLAGS += --skip-validation
53 54
54### 55###
55# DOCPROC is used for two purposes: 56# DOCPROC is used for two purposes:
@@ -96,45 +97,44 @@ $(obj)/procfs-guide.xml: $(C-procfs-example2)
96# Rules to generate postscript, PDF and HTML 97# Rules to generate postscript, PDF and HTML
97# db2html creates a directory. Generate a html file used for timestamp 98# db2html creates a directory. Generate a html file used for timestamp
98 99
99quiet_cmd_db2ps = DB2PS $@ 100quiet_cmd_db2ps = XMLTO $@
100 cmd_db2ps = db2ps -o $(dir $@) $< 101 cmd_db2ps = xmlto ps $(XMLTOFLAGS) -o $(dir $@) $<
101%.ps : %.xml 102%.ps : %.xml
102 @(which db2ps > /dev/null 2>&1) || \ 103 @(which xmlto > /dev/null 2>&1) || \
103 (echo "*** You need to install DocBook stylesheets ***"; \ 104 (echo "*** You need to install xmlto ***"; \
104 exit 1) 105 exit 1)
105 $(call cmd,db2ps) 106 $(call cmd,db2ps)
106 107
107quiet_cmd_db2pdf = DB2PDF $@ 108quiet_cmd_db2pdf = XMLTO $@
108 cmd_db2pdf = db2pdf -o $(dir $@) $< 109 cmd_db2pdf = xmlto pdf $(XMLTOFLAGS) -o $(dir $@) $<
109%.pdf : %.xml 110%.pdf : %.xml
110 @(which db2pdf > /dev/null 2>&1) || \ 111 @(which xmlto > /dev/null 2>&1) || \
111 (echo "*** You need to install DocBook stylesheets ***"; \ 112 (echo "*** You need to install xmlto ***"; \
112 exit 1) 113 exit 1)
113 $(call cmd,db2pdf) 114 $(call cmd,db2pdf)
114 115
115quiet_cmd_db2html = DB2HTML $@ 116quiet_cmd_db2html = XMLTO $@
116 cmd_db2html = db2html -o $(patsubst %.html,%,$@) $< && \ 117 cmd_db2html = xmlto xhtml $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
117 echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/book1.html"> \ 118 echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/index.html"> \
118 Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@ 119 Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
119 120
120%.html: %.xml 121%.html: %.xml
121 @(which db2html > /dev/null 2>&1) || \ 122 @(which xmlto > /dev/null 2>&1) || \
122 (echo "*** You need to install DocBook stylesheets ***"; \ 123 (echo "*** You need to install xmlto ***"; \
123 exit 1) 124 exit 1)
124 @rm -rf $@ $(patsubst %.html,%,$@) 125 @rm -rf $@ $(patsubst %.html,%,$@)
125 $(call cmd,db2html) 126 $(call cmd,db2html)
126 @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \ 127 @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
127 cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi 128 cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
128 129
129### 130quiet_cmd_db2man = XMLTO $@
130# Rule to generate man files - output is placed in the man subdirectory 131 cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
131 132%.9 : %.xml
132%.9: %.xml 133 @(which xmlto > /dev/null 2>&1) || \
133ifneq ($(KBUILD_SRC),) 134 (echo "*** You need to install xmlto ***"; \
134 $(Q)mkdir -p $(objtree)/Documentation/DocBook/man 135 exit 1)
135endif 136 $(call cmd,db2man)
136 $(SPLITMAN) $< $(objtree)/Documentation/DocBook/man "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)" 137 @touch $@
137 $(MAKEMAN) convert $(objtree)/Documentation/DocBook/man $<
138 138
139### 139###
140# Rules to generate postscripts and PNG imgages from .fig format files 140# Rules to generate postscripts and PNG imgages from .fig format files
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 1bd20c860285..757cef8f8491 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -49,13 +49,33 @@
49!Iinclude/asm-i386/unaligned.h 49!Iinclude/asm-i386/unaligned.h
50 </sect1> 50 </sect1>
51 51
52<!-- FIXME:
53 kernel/sched.c has no docs, which stuffs up the sgml. Comment
54 out until somebody adds docs. KAO
55 <sect1><title>Delaying, scheduling, and timer routines</title> 52 <sect1><title>Delaying, scheduling, and timer routines</title>
56X!Ekernel/sched.c 53!Iinclude/linux/sched.h
54!Ekernel/sched.c
55!Ekernel/timer.c
57 </sect1> 56 </sect1>
58KAO --> 57 <sect1><title>Internal Functions</title>
58!Ikernel/exit.c
59!Ikernel/signal.c
60 </sect1>
61
62 <sect1><title>Kernel objects manipulation</title>
63<!--
64X!Iinclude/linux/kobject.h
65-->
66!Elib/kobject.c
67 </sect1>
68
69 <sect1><title>Kernel utility functions</title>
70!Iinclude/linux/kernel.h
71<!-- This needs to clean up to make kernel-doc happy
72X!Ekernel/printk.c
73 -->
74!Ekernel/panic.c
75!Ekernel/sys.c
76!Ekernel/rcupdate.c
77 </sect1>
78
59 </chapter> 79 </chapter>
60 80
61 <chapter id="adt"> 81 <chapter id="adt">
@@ -81,7 +101,9 @@ KAO -->
81!Elib/vsprintf.c 101!Elib/vsprintf.c
82 </sect1> 102 </sect1>
83 <sect1><title>String Manipulation</title> 103 <sect1><title>String Manipulation</title>
84!Ilib/string.c 104<!-- All functions are exported at now
105X!Ilib/string.c
106 -->
85!Elib/string.c 107!Elib/string.c
86 </sect1> 108 </sect1>
87 <sect1><title>Bit Operations</title> 109 <sect1><title>Bit Operations</title>
@@ -98,6 +120,25 @@ KAO -->
98!Iinclude/asm-i386/uaccess.h 120!Iinclude/asm-i386/uaccess.h
99!Iarch/i386/lib/usercopy.c 121!Iarch/i386/lib/usercopy.c
100 </sect1> 122 </sect1>
123 <sect1><title>More Memory Management Functions</title>
124!Iinclude/linux/rmap.h
125!Emm/readahead.c
126!Emm/filemap.c
127!Emm/memory.c
128!Emm/vmalloc.c
129!Emm/mempool.c
130!Emm/page-writeback.c
131!Emm/truncate.c
132 </sect1>
133 </chapter>
134
135
136 <chapter id="ipc">
137 <title>Kernel IPC facilities</title>
138
139 <sect1><title>IPC utilities</title>
140!Iipc/util.c
141 </sect1>
101 </chapter> 142 </chapter>
102 143
103 <chapter id="kfifo"> 144 <chapter id="kfifo">
@@ -114,6 +155,10 @@ KAO -->
114 <sect1><title>sysctl interface</title> 155 <sect1><title>sysctl interface</title>
115!Ekernel/sysctl.c 156!Ekernel/sysctl.c
116 </sect1> 157 </sect1>
158
159 <sect1><title>proc filesystem interface</title>
160!Ifs/proc/base.c
161 </sect1>
117 </chapter> 162 </chapter>
118 163
119 <chapter id="debugfs"> 164 <chapter id="debugfs">
@@ -127,6 +172,10 @@ KAO -->
127 172
128 <chapter id="vfs"> 173 <chapter id="vfs">
129 <title>The Linux VFS</title> 174 <title>The Linux VFS</title>
175 <sect1><title>The Filesystem types</title>
176!Iinclude/linux/fs.h
177!Einclude/linux/fs.h
178 </sect1>
130 <sect1><title>The Directory Cache</title> 179 <sect1><title>The Directory Cache</title>
131!Efs/dcache.c 180!Efs/dcache.c
132!Iinclude/linux/dcache.h 181!Iinclude/linux/dcache.h
@@ -142,13 +191,31 @@ KAO -->
142!Efs/locks.c 191!Efs/locks.c
143!Ifs/locks.c 192!Ifs/locks.c
144 </sect1> 193 </sect1>
194 <sect1><title>Other Functions</title>
195!Efs/mpage.c
196!Efs/namei.c
197!Efs/buffer.c
198!Efs/bio.c
199!Efs/seq_file.c
200!Efs/filesystems.c
201!Efs/fs-writeback.c
202!Efs/block_dev.c
203 </sect1>
145 </chapter> 204 </chapter>
146 205
147 <chapter id="netcore"> 206 <chapter id="netcore">
148 <title>Linux Networking</title> 207 <title>Linux Networking</title>
208 <sect1><title>Networking Base Types</title>
209!Iinclude/linux/net.h
210 </sect1>
149 <sect1><title>Socket Buffer Functions</title> 211 <sect1><title>Socket Buffer Functions</title>
150!Iinclude/linux/skbuff.h 212!Iinclude/linux/skbuff.h
213!Iinclude/net/sock.h
214!Enet/socket.c
151!Enet/core/skbuff.c 215!Enet/core/skbuff.c
216!Enet/core/sock.c
217!Enet/core/datagram.c
218!Enet/core/stream.c
152 </sect1> 219 </sect1>
153 <sect1><title>Socket Filter</title> 220 <sect1><title>Socket Filter</title>
154!Enet/core/filter.c 221!Enet/core/filter.c
@@ -158,6 +225,14 @@ KAO -->
158!Enet/core/gen_stats.c 225!Enet/core/gen_stats.c
159!Enet/core/gen_estimator.c 226!Enet/core/gen_estimator.c
160 </sect1> 227 </sect1>
228 <sect1><title>SUN RPC subsystem</title>
229<!-- The !D functionality is not perfect, garbage has to be protected by comments
230!Dnet/sunrpc/sunrpc_syms.c
231-->
232!Enet/sunrpc/xdr.c
233!Enet/sunrpc/svcsock.c
234!Enet/sunrpc/sched.c
235 </sect1>
161 </chapter> 236 </chapter>
162 237
163 <chapter id="netdev"> 238 <chapter id="netdev">
@@ -194,11 +269,26 @@ X!Ekernel/module.c
194!Iarch/i386/kernel/irq.c 269!Iarch/i386/kernel/irq.c
195 </sect1> 270 </sect1>
196 271
272 <sect1><title>Resources Management</title>
273!Ekernel/resource.c
274 </sect1>
275
197 <sect1><title>MTRR Handling</title> 276 <sect1><title>MTRR Handling</title>
198!Earch/i386/kernel/cpu/mtrr/main.c 277!Earch/i386/kernel/cpu/mtrr/main.c
199 </sect1> 278 </sect1>
200 <sect1><title>PCI Support Library</title> 279 <sect1><title>PCI Support Library</title>
201!Edrivers/pci/pci.c 280!Edrivers/pci/pci.c
281!Edrivers/pci/pci-driver.c
282!Edrivers/pci/remove.c
283!Edrivers/pci/pci-acpi.c
284<!-- kerneldoc does not understand to __devinit
285X!Edrivers/pci/search.c
286 -->
287!Edrivers/pci/msi.c
288!Edrivers/pci/bus.c
289!Edrivers/pci/hotplug.c
290!Edrivers/pci/probe.c
291!Edrivers/pci/rom.c
202 </sect1> 292 </sect1>
203 <sect1><title>PCI Hotplug Support Library</title> 293 <sect1><title>PCI Hotplug Support Library</title>
204!Edrivers/pci/hotplug/pci_hotplug_core.c 294!Edrivers/pci/hotplug/pci_hotplug_core.c
@@ -223,6 +313,14 @@ X!Earch/i386/kernel/mca.c
223!Efs/devfs/base.c 313!Efs/devfs/base.c
224 </chapter> 314 </chapter>
225 315
316 <chapter id="sysfs">
317 <title>The Filesystem for Exporting Kernel Objects</title>
318!Efs/sysfs/file.c
319!Efs/sysfs/dir.c
320!Efs/sysfs/symlink.c
321!Efs/sysfs/bin.c
322 </chapter>
323
226 <chapter id="security"> 324 <chapter id="security">
227 <title>Security Framework</title> 325 <title>Security Framework</title>
228!Esecurity/security.c 326!Esecurity/security.c
@@ -233,6 +331,61 @@ X!Earch/i386/kernel/mca.c
233!Ekernel/power/pm.c 331!Ekernel/power/pm.c
234 </chapter> 332 </chapter>
235 333
334 <chapter id="devdrivers">
335 <title>Device drivers infrastructure</title>
336 <sect1><title>Device Drivers Base</title>
337<!--
338X!Iinclude/linux/device.h
339-->
340!Edrivers/base/driver.c
341!Edrivers/base/class_simple.c
342!Edrivers/base/core.c
343!Edrivers/base/firmware_class.c
344!Edrivers/base/transport_class.c
345!Edrivers/base/dmapool.c
346<!-- Cannot be included, because
347 attribute_container_add_class_device_adapter
348 and attribute_container_classdev_to_container
349 exceed allowed 44 characters maximum
350X!Edrivers/base/attribute_container.c
351-->
352!Edrivers/base/sys.c
353<!--
354X!Edrivers/base/interface.c
355-->
356!Edrivers/base/platform.c
357!Edrivers/base/bus.c
358 </sect1>
359 <sect1><title>Device Drivers Power Management</title>
360!Edrivers/base/power/main.c
361!Edrivers/base/power/resume.c
362!Edrivers/base/power/suspend.c
363 </sect1>
364 <sect1><title>Device Drivers ACPI Support</title>
365<!-- Internal functions only
366X!Edrivers/acpi/sleep/main.c
367X!Edrivers/acpi/sleep/wakeup.c
368X!Edrivers/acpi/motherboard.c
369X!Edrivers/acpi/bus.c
370-->
371!Edrivers/acpi/scan.c
372<!-- No correct structured comments
373X!Edrivers/acpi/pci_bind.c
374-->
375 </sect1>
376 <sect1><title>Device drivers PnP support</title>
377!Edrivers/pnp/core.c
378<!-- No correct structured comments
379X!Edrivers/pnp/system.c
380 -->
381!Edrivers/pnp/card.c
382!Edrivers/pnp/driver.c
383!Edrivers/pnp/manager.c
384!Edrivers/pnp/support.c
385 </sect1>
386 </chapter>
387
388
236 <chapter id="blkdev"> 389 <chapter id="blkdev">
237 <title>Block Devices</title> 390 <title>Block Devices</title>
238!Edrivers/block/ll_rw_blk.c 391!Edrivers/block/ll_rw_blk.c
@@ -250,7 +403,23 @@ X!Earch/i386/kernel/mca.c
250 403
251 <chapter id="snddev"> 404 <chapter id="snddev">
252 <title>Sound Devices</title> 405 <title>Sound Devices</title>
406!Iinclude/sound/core.h
253!Esound/sound_core.c 407!Esound/sound_core.c
408!Iinclude/sound/pcm.h
409!Esound/core/pcm.c
410!Esound/core/device.c
411!Esound/core/info.c
412!Esound/core/rawmidi.c
413!Esound/core/sound.c
414!Esound/core/memory.c
415!Esound/core/pcm_memory.c
416!Esound/core/init.c
417!Esound/core/isadma.c
418!Esound/core/control.c
419!Esound/core/pcm_lib.c
420!Esound/core/hwdep.c
421!Esound/core/pcm_native.c
422!Esound/core/memalloc.c
254<!-- FIXME: Removed for now since no structured comments in source 423<!-- FIXME: Removed for now since no structured comments in source
255X!Isound/sound_firmware.c 424X!Isound/sound_firmware.c
256--> 425-->
@@ -258,6 +427,7 @@ X!Isound/sound_firmware.c
258 427
259 <chapter id="uart16x50"> 428 <chapter id="uart16x50">
260 <title>16x50 UART Driver</title> 429 <title>16x50 UART Driver</title>
430!Iinclude/linux/serial_core.h
261!Edrivers/serial/serial_core.c 431!Edrivers/serial/serial_core.c
262!Edrivers/serial/8250.c 432!Edrivers/serial/8250.c
263 </chapter> 433 </chapter>
@@ -310,9 +480,11 @@ X!Isound/sound_firmware.c
310 <sect1><title>Frame Buffer Memory</title> 480 <sect1><title>Frame Buffer Memory</title>
311!Edrivers/video/fbmem.c 481!Edrivers/video/fbmem.c
312 </sect1> 482 </sect1>
483<!--
313 <sect1><title>Frame Buffer Console</title> 484 <sect1><title>Frame Buffer Console</title>
314!Edrivers/video/console/fbcon.c 485X!Edrivers/video/console/fbcon.c
315 </sect1> 486 </sect1>
487-->
316 <sect1><title>Frame Buffer Colormap</title> 488 <sect1><title>Frame Buffer Colormap</title>
317!Edrivers/video/fbcmap.c 489!Edrivers/video/fbcmap.c
318 </sect1> 490 </sect1>
diff --git a/Documentation/DocBook/stylesheet.xsl b/Documentation/DocBook/stylesheet.xsl
new file mode 100644
index 000000000000..e14c21dda403
--- /dev/null
+++ b/Documentation/DocBook/stylesheet.xsl
@@ -0,0 +1,5 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
3<param name="chunk.quietly">1</param>
4<param name="funcsynopsis.style">ansi</param>
5</stylesheet>
diff --git a/Documentation/DocBook/tulip-user.tmpl b/Documentation/DocBook/tulip-user.tmpl
deleted file mode 100644
index 6520d7a1b132..000000000000
--- a/Documentation/DocBook/tulip-user.tmpl
+++ /dev/null
@@ -1,327 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="TulipUserGuide">
6 <bookinfo>
7 <title>Tulip Driver User's Guide</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Jeff</firstname>
12 <surname>Garzik</surname>
13 <affiliation>
14 <address>
15 <email>jgarzik@pobox.com</email>
16 </address>
17 </affiliation>
18 </author>
19 </authorgroup>
20
21 <copyright>
22 <year>2001</year>
23 <holder>Jeff Garzik</holder>
24 </copyright>
25
26 <legalnotice>
27 <para>
28 This documentation is free software; you can redistribute
29 it and/or modify it under the terms of the GNU General Public
30 License as published by the Free Software Foundation; either
31 version 2 of the License, or (at your option) any later
32 version.
33 </para>
34
35 <para>
36 This program is distributed in the hope that it will be
37 useful, but WITHOUT ANY WARRANTY; without even the implied
38 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
39 See the GNU General Public License for more details.
40 </para>
41
42 <para>
43 You should have received a copy of the GNU General Public
44 License along with this program; if not, write to the Free
45 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
46 MA 02111-1307 USA
47 </para>
48
49 <para>
50 For more details see the file COPYING in the source
51 distribution of Linux.
52 </para>
53 </legalnotice>
54 </bookinfo>
55
56 <toc></toc>
57
58 <chapter id="intro">
59 <title>Introduction</title>
60<para>
61The Tulip Ethernet Card Driver
62is maintained by Jeff Garzik (<email>jgarzik@pobox.com</email>).
63</para>
64
65<para>
66The Tulip driver was developed by Donald Becker and changed by
67Jeff Garzik, Takashi Manabe and a cast of thousands.
68</para>
69
70<para>
71For 2.4.x and later kernels, the Linux Tulip driver is available at
72<ulink url="http://sourceforge.net/projects/tulip/">http://sourceforge.net/projects/tulip/</ulink>
73</para>
74
75<para>
76 This driver is for the Digital "Tulip" Ethernet adapter interface.
77 It should work with most DEC 21*4*-based chips/ethercards, as well as
78 with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and ASIX.
79</para>
80
81<para>
82 The original author may be reached as becker@scyld.com, or C/O
83 Scyld Computing Corporation,
84 410 Severn Ave., Suite 210,
85 Annapolis MD 21403
86</para>
87
88<para>
89 Additional information on Donald Becker's tulip.c
90 is available at <ulink url="http://www.scyld.com/network/tulip.html">http://www.scyld.com/network/tulip.html</ulink>
91</para>
92
93 </chapter>
94
95 <chapter id="drvr-compat">
96 <title>Driver Compatibility</title>
97
98<para>
99This device driver is designed for the DECchip "Tulip", Digital's
100single-chip ethernet controllers for PCI (now owned by Intel).
101Supported members of the family
102are the 21040, 21041, 21140, 21140A, 21142, and 21143. Similar work-alike
103chips from Lite-On, Macronics, ASIX, Compex and other listed below are also
104supported.
105</para>
106
107<para>
108These chips are used on at least 140 unique PCI board designs. The great
109number of chips and board designs supported is the reason for the
110driver size and complexity. Almost of the increasing complexity is in the
111board configuration and media selection code. There is very little
112increasing in the operational critical path length.
113</para>
114 </chapter>
115
116 <chapter id="board-settings">
117 <title>Board-specific Settings</title>
118
119<para>
120PCI bus devices are configured by the system at boot time, so no jumpers
121need to be set on the board. The system BIOS preferably should assign the
122PCI INTA signal to an otherwise unused system IRQ line.
123</para>
124
125<para>
126Some boards have EEPROMs tables with default media entry. The factory default
127is usually "autoselect". This should only be overridden when using
128transceiver connections without link beat e.g. 10base2 or AUI, or (rarely!)
129for forcing full-duplex when used with old link partners that do not do
130autonegotiation.
131</para>
132 </chapter>
133
134 <chapter id="driver-operation">
135 <title>Driver Operation</title>
136
137<sect1><title>Ring buffers</title>
138
139<para>
140The Tulip can use either ring buffers or lists of Tx and Rx descriptors.
141This driver uses statically allocated rings of Rx and Tx descriptors, set at
142compile time by RX/TX_RING_SIZE. This version of the driver allocates skbuffs
143for the Rx ring buffers at open() time and passes the skb->data field to the
144Tulip as receive data buffers. When an incoming frame is less than
145RX_COPYBREAK bytes long, a fresh skbuff is allocated and the frame is
146copied to the new skbuff. When the incoming frame is larger, the skbuff is
147passed directly up the protocol stack and replaced by a newly allocated
148skbuff.
149</para>
150
151<para>
152The RX_COPYBREAK value is chosen to trade-off the memory wasted by
153using a full-sized skbuff for small frames vs. the copying costs of larger
154frames. For small frames the copying cost is negligible (esp. considering
155that we are pre-loading the cache with immediately useful header
156information). For large frames the copying cost is non-trivial, and the
157larger copy might flush the cache of useful data. A subtle aspect of this
158choice is that the Tulip only receives into longword aligned buffers, thus
159the IP header at offset 14 isn't longword aligned for further processing.
160Copied frames are put into the new skbuff at an offset of "+2", thus copying
161has the beneficial effect of aligning the IP header and preloading the
162cache.
163</para>
164
165</sect1>
166
167<sect1><title>Synchronization</title>
168<para>
169The driver runs as two independent, single-threaded flows of control. One
170is the send-packet routine, which enforces single-threaded use by the
171dev->tbusy flag. The other thread is the interrupt handler, which is single
172threaded by the hardware and other software.
173</para>
174
175<para>
176The send packet thread has partial control over the Tx ring and 'dev->tbusy'
177flag. It sets the tbusy flag whenever it's queuing a Tx packet. If the next
178queue slot is empty, it clears the tbusy flag when finished otherwise it sets
179the 'tp->tx_full' flag.
180</para>
181
182<para>
183The interrupt handler has exclusive control over the Rx ring and records stats
184from the Tx ring. (The Tx-done interrupt can't be selectively turned off, so
185we can't avoid the interrupt overhead by having the Tx routine reap the Tx
186stats.) After reaping the stats, it marks the queue entry as empty by setting
187the 'base' to zero. Iff the 'tp->tx_full' flag is set, it clears both the
188tx_full and tbusy flags.
189</para>
190
191</sect1>
192
193 </chapter>
194
195 <chapter id="errata">
196 <title>Errata</title>
197
198<para>
199The old DEC databooks were light on details.
200The 21040 databook claims that CSR13, CSR14, and CSR15 should each be the last
201register of the set CSR12-15 written. Hmmm, now how is that possible?
202</para>
203
204<para>
205The DEC SROM format is very badly designed not precisely defined, leading to
206part of the media selection junkheap below. Some boards do not have EEPROM
207media tables and need to be patched up. Worse, other boards use the DEC
208design kit media table when it isn't correct for their board.
209</para>
210
211<para>
212We cannot use MII interrupts because there is no defined GPIO pin to attach
213them. The MII transceiver status is polled using an kernel timer.
214</para>
215 </chapter>
216
217 <chapter id="changelog">
218 <title>Driver Change History</title>
219
220 <sect1><title>Version 0.9.14 (February 20, 2001)</title>
221 <itemizedlist>
222 <listitem><para>Fix PNIC problems (Manfred Spraul)</para></listitem>
223 <listitem><para>Add new PCI id for Accton comet</para></listitem>
224 <listitem><para>Support Davicom tulips</para></listitem>
225 <listitem><para>Fix oops in eeprom parsing</para></listitem>
226 <listitem><para>Enable workarounds for early PCI chipsets</para></listitem>
227 <listitem><para>IA64, hppa csr0 support</para></listitem>
228 <listitem><para>Support media types 5, 6</para></listitem>
229 <listitem><para>Interpret a bit more of the 21142 SROM extended media type 3</para></listitem>
230 <listitem><para>Add missing delay in eeprom reading</para></listitem>
231 </itemizedlist>
232 </sect1>
233
234 <sect1><title>Version 0.9.11 (November 3, 2000)</title>
235 <itemizedlist>
236 <listitem><para>Eliminate extra bus accesses when sharing interrupts (prumpf)</para></listitem>
237 <listitem><para>Barrier following ownership descriptor bit flip (prumpf)</para></listitem>
238 <listitem><para>Endianness fixes for >14 addresses in setup frames (prumpf)</para></listitem>
239 <listitem><para>Report link beat to kernel/userspace via netif_carrier_*. (kuznet)</para></listitem>
240 <listitem><para>Better spinlocking in set_rx_mode.</para></listitem>
241 <listitem><para>Fix I/O resource request failure error messages (DaveM catch)</para></listitem>
242 <listitem><para>Handle DMA allocation failure.</para></listitem>
243 </itemizedlist>
244 </sect1>
245
246 <sect1><title>Version 0.9.10 (September 6, 2000)</title>
247 <itemizedlist>
248 <listitem><para>Simple interrupt mitigation (via jamal)</para></listitem>
249 <listitem><para>More PCI ids</para></listitem>
250 </itemizedlist>
251 </sect1>
252
253 <sect1><title>Version 0.9.9 (August 11, 2000)</title>
254 <itemizedlist>
255 <listitem><para>More PCI ids</para></listitem>
256 </itemizedlist>
257 </sect1>
258
259 <sect1><title>Version 0.9.8 (July 13, 2000)</title>
260 <itemizedlist>
261 <listitem><para>Correct signed/unsigned comparison for dummy frame index</para></listitem>
262 <listitem><para>Remove outdated references to struct enet_statistics</para></listitem>
263 </itemizedlist>
264 </sect1>
265
266 <sect1><title>Version 0.9.7 (June 17, 2000)</title>
267 <itemizedlist>
268 <listitem><para>Timer cleanups (Andrew Morton)</para></listitem>
269 <listitem><para>Alpha compile fix (somebody?)</para></listitem>
270 </itemizedlist>
271 </sect1>
272
273 <sect1><title>Version 0.9.6 (May 31, 2000)</title>
274 <itemizedlist>
275 <listitem><para>Revert 21143-related support flag patch</para></listitem>
276 <listitem><para>Add HPPA/media-table debugging printk</para></listitem>
277 </itemizedlist>
278 </sect1>
279
280 <sect1><title>Version 0.9.5 (May 30, 2000)</title>
281 <itemizedlist>
282 <listitem><para>HPPA support (willy@puffingroup)</para></listitem>
283 <listitem><para>CSR6 bits and tulip.h cleanup (Chris Smith)</para></listitem>
284 <listitem><para>Improve debugging messages a bit</para></listitem>
285 <listitem><para>Add delay after CSR13 write in t21142_start_nway</para></listitem>
286 <listitem><para>Remove unused ETHER_STATS code</para></listitem>
287 <listitem><para>Convert 'extern inline' to 'static inline' in tulip.h (Chris Smith)</para></listitem>
288 <listitem><para>Update DS21143 support flags in tulip_chip_info[]</para></listitem>
289 <listitem><para>Use spin_lock_irq, not _irqsave/restore, in tulip_start_xmit()</para></listitem>
290 <listitem><para>Add locking to set_rx_mode()</para></listitem>
291 <listitem><para>Fix race with chip setting DescOwned bit (Hal Murray)</para></listitem>
292 <listitem><para>Request 100% of PIO and MMIO resource space assigned to card</para></listitem>
293 <listitem><para>Remove error message from pci_enable_device failure</para></listitem>
294 </itemizedlist>
295 </sect1>
296
297 <sect1><title>Version 0.9.4.3 (April 14, 2000)</title>
298 <itemizedlist>
299 <listitem><para>mod_timer fix (Hal Murray)</para></listitem>
300 <listitem><para>PNIC2 resuscitation (Chris Smith)</para></listitem>
301 </itemizedlist>
302 </sect1>
303
304 <sect1><title>Version 0.9.4.2 (March 21, 2000)</title>
305 <itemizedlist>
306 <listitem><para>Fix 21041 CSR7, CSR13/14/15 handling</para></listitem>
307 <listitem><para>Merge some PCI ids from tulip 0.91x</para></listitem>
308 <listitem><para>Merge some HAS_xxx flags and flag settings from tulip 0.91x</para></listitem>
309 <listitem><para>asm/io.h fix (submitted by many) and cleanup</para></listitem>
310 <listitem><para>s/HAS_NWAY143/HAS_NWAY/</para></listitem>
311 <listitem><para>Cleanup 21041 mode reporting</para></listitem>
312 <listitem><para>Small code cleanups</para></listitem>
313 </itemizedlist>
314 </sect1>
315
316 <sect1><title>Version 0.9.4.1 (March 18, 2000)</title>
317 <itemizedlist>
318 <listitem><para>Finish PCI DMA conversion (davem)</para></listitem>
319 <listitem><para>Do not netif_start_queue() at end of tulip_tx_timeout() (kuznet)</para></listitem>
320 <listitem><para>PCI DMA fix (kuznet)</para></listitem>
321 <listitem><para>eeprom.c code cleanup</para></listitem>
322 <listitem><para>Remove Xircom Tulip crud</para></listitem>
323 </itemizedlist>
324 </sect1>
325 </chapter>
326
327</book>
diff --git a/Documentation/DocBook/via-audio.tmpl b/Documentation/DocBook/via-audio.tmpl
deleted file mode 100644
index 36e642147d6b..000000000000
--- a/Documentation/DocBook/via-audio.tmpl
+++ /dev/null
@@ -1,597 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="ViaAudioGuide">
6 <bookinfo>
7 <title>Via 686 Audio Driver for Linux</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Jeff</firstname>
12 <surname>Garzik</surname>
13 </author>
14 </authorgroup>
15
16 <copyright>
17 <year>1999-2001</year>
18 <holder>Jeff Garzik</holder>
19 </copyright>
20
21 <legalnotice>
22 <para>
23 This documentation is free software; you can redistribute
24 it and/or modify it under the terms of the GNU General Public
25 License as published by the Free Software Foundation; either
26 version 2 of the License, or (at your option) any later
27 version.
28 </para>
29
30 <para>
31 This program is distributed in the hope that it will be
32 useful, but WITHOUT ANY WARRANTY; without even the implied
33 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34 See the GNU General Public License for more details.
35 </para>
36
37 <para>
38 You should have received a copy of the GNU General Public
39 License along with this program; if not, write to the Free
40 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
41 MA 02111-1307 USA
42 </para>
43
44 <para>
45 For more details see the file COPYING in the source
46 distribution of Linux.
47 </para>
48 </legalnotice>
49 </bookinfo>
50
51<toc></toc>
52
53 <chapter id="intro">
54 <title>Introduction</title>
55 <para>
56 The Via VT82C686A "super southbridge" chips contain
57 AC97-compatible audio logic which features dual 16-bit stereo
58 PCM sound channels (full duplex), plus a third PCM channel intended for use
59 in hardware-assisted FM synthesis.
60 </para>
61 <para>
62 The current Linux kernel audio driver for this family of chips
63 supports audio playback and recording, but hardware-assisted
64 FM features, and hardware buffer direct-access (mmap)
65 support are not yet available.
66 </para>
67 <para>
68 This driver supports any Linux kernel version after 2.4.10.
69 </para>
70 <para>
71 Please send bug reports to the mailing list <email>linux-via@gtf.org</email>.
72 To subscribe, e-mail <email>majordomo@gtf.org</email> with
73 </para>
74 <programlisting>
75 subscribe linux-via
76 </programlisting>
77 <para>
78 in the body of the message.
79 </para>
80 </chapter>
81
82 <chapter id="install">
83 <title>Driver Installation</title>
84 <para>
85 To use this audio driver, select the
86 CONFIG_SOUND_VIA82CXXX option in the section Sound during kernel configuration.
87 Follow the usual kernel procedures for rebuilding the kernel,
88 or building and installing driver modules.
89 </para>
90 <para>
91 To make this driver the default audio driver, you can add the
92 following to your /etc/conf.modules file:
93 </para>
94 <programlisting>
95 alias sound via82cxxx_audio
96 </programlisting>
97 <para>
98 Note that soundcore and ac97_codec support modules
99 are also required for working audio, in addition to
100 the via82cxxx_audio module itself.
101 </para>
102 </chapter>
103
104 <chapter id="reportbug">
105 <title>Submitting a bug report</title>
106 <sect1 id="bugrepdesc"><title>Description of problem</title>
107 <para>
108 Describe the application you were using to play/record sound, and how
109 to reproduce the problem.
110 </para>
111 </sect1>
112 <sect1 id="bugrepdiag"><title>Diagnostic output</title>
113 <para>
114 Obtain the via-audio-diag diagnostics program from
115 http://sf.net/projects/gkernel/ and provide a dump of the
116 audio chip's registers while the problem is occurring. Sample command line:
117 </para>
118 <programlisting>
119 ./via-audio-diag -aps > diag-output.txt
120 </programlisting>
121 </sect1>
122 <sect1 id="bugrepdebug"><title>Driver debug output</title>
123 <para>
124 Define <constant>VIA_DEBUG</constant> at the beginning of the driver, then capture and email
125 the kernel log output. This can be viewed in the system kernel log (if
126 enabled), or via the dmesg program. Sample command line:
127 </para>
128 <programlisting>
129 dmesg > /tmp/dmesg-output.txt
130 </programlisting>
131 </sect1>
132 <sect1 id="bugrepprintk"><title>Bigger kernel message buffer</title>
133 <para>
134 If you wish to increase the size of the buffer displayed by dmesg, then
135 change the <constant>LOG_BUF_LEN</constant> macro at the top of linux/kernel/printk.c, recompile
136 your kernel, and pass the <constant>LOG_BUF_LEN</constant> value to dmesg. Sample command line with
137 <constant>LOG_BUF_LEN</constant> == 32768:
138 </para>
139 <programlisting>
140 dmesg -s 32768 > /tmp/dmesg-output.txt
141 </programlisting>
142 </sect1>
143 </chapter>
144
145 <chapter id="bugs">
146 <title>Known Bugs And Assumptions</title>
147 <para>
148 <variablelist>
149 <varlistentry><term>Low volume</term>
150 <listitem>
151 <para>
152 Volume too low on many systems. Workaround: use mixer program
153 such as xmixer to increase volume.
154 </para>
155 </listitem></varlistentry>
156
157 </variablelist>
158
159 </para>
160 </chapter>
161
162 <chapter id="thanks">
163 <title>Thanks</title>
164 <para>
165 Via for providing e-mail support, specs, and NDA'd source code.
166 </para>
167 <para>
168 MandrakeSoft for providing hacking time.
169 </para>
170 <para>
171 AC97 mixer interface fixes and debugging by Ron Cemer <email>roncemer@gte.net</email>.
172 </para>
173 <para>
174 Rui Sousa <email>rui.sousa@conexant.com</email>, for bugfixing
175 MMAP support, and several other notable fixes that resulted from
176 his hard work and testing.
177 </para>
178 <para>
179 Adrian Cox <email>adrian@humboldt.co.uk</email>, for bugfixing
180 MMAP support, and several other notable fixes that resulted from
181 his hard work and testing.
182 </para>
183 <para>
184 Thomas Sailer for further bugfixes.
185 </para>
186 </chapter>
187
188 <chapter id="notes">
189 <title>Random Notes</title>
190 <para>
191 Two /proc pseudo-files provide diagnostic information. This is generally
192 not useful to most users. Power users can disable CONFIG_SOUND_VIA82CXXX_PROCFS,
193 and remove the /proc support code. Once
194 version 2.0.0 is released, the /proc support code will be disabled by
195 default. Available /proc pseudo-files:
196 </para>
197 <programlisting>
198 /proc/driver/via/0/info
199 /proc/driver/via/0/ac97
200 </programlisting>
201 <para>
202 This driver by default supports all PCI audio devices which report
203 a vendor id of 0x1106, and a device id of 0x3058. Subsystem vendor
204 and device ids are not examined.
205 </para>
206 <para>
207 GNU indent formatting options:
208 <programlisting>
209-kr -i8 -ts8 -br -ce -bap -sob -l80 -pcs -cs -ss -bs -di1 -nbc -lp -psl
210 </programlisting>
211 </para>
212 <para>
213 Via has graciously donated e-mail support and source code to help further
214 the development of this driver. Their assistance has been invaluable
215 in the design and coding of the next major version of this driver.
216 </para>
217 <para>
218 The Via audio chip apparently provides a second PCM scatter-gather
219 DMA channel just for FM data, but does not have a full hardware MIDI
220 processor. I haven't put much thought towards a solution here, but it
221 might involve using SoftOSS midi wave table, or simply disabling MIDI
222 support altogether and using the FM PCM channel as a second (input? output?)
223 </para>
224 </chapter>
225
226 <chapter id="changelog">
227 <title>Driver ChangeLog</title>
228
229<sect1 id="version191"><title>
230Version 1.9.1
231</title>
232 <itemizedlist spacing="compact">
233 <listitem>
234 <para>
235 DSP read/write bugfixes from Thomas Sailer.
236 </para>
237 </listitem>
238
239 <listitem>
240 <para>
241 Add new PCI id for single-channel use of Via 8233.
242 </para>
243 </listitem>
244
245 <listitem>
246 <para>
247 Other bug fixes, tweaks, new ioctls.
248 </para>
249 </listitem>
250
251 </itemizedlist>
252</sect1>
253
254<sect1 id="version1115"><title>
255Version 1.1.15
256</title>
257 <itemizedlist spacing="compact">
258 <listitem>
259 <para>
260 Support for variable fragment size and variable fragment number (Rui
261 Sousa)
262 </para>
263 </listitem>
264
265 <listitem>
266 <para>
267 Fixes for the SPEED, STEREO, CHANNELS, FMT ioctls when in read &amp;
268 write mode (Rui Sousa)
269 </para>
270 </listitem>
271
272 <listitem>
273 <para>
274 Mmaped sound is now fully functional. (Rui Sousa)
275 </para>
276 </listitem>
277
278 <listitem>
279 <para>
280 Make sure to enable PCI device before reading any of its PCI
281 config information. (fixes potential hotplug problems)
282 </para>
283 </listitem>
284
285 <listitem>
286 <para>
287 Clean up code a bit and add more internal function documentation.
288 </para>
289 </listitem>
290
291 <listitem>
292 <para>
293 AC97 codec access fixes (Adrian Cox)
294 </para>
295 </listitem>
296
297 <listitem>
298 <para>
299 Big endian fixes (Adrian Cox)
300 </para>
301 </listitem>
302
303 <listitem>
304 <para>
305 MIDI support (Adrian Cox)
306 </para>
307 </listitem>
308
309 <listitem>
310 <para>
311 Detect and report locked-rate AC97 codecs. If your hardware only
312 supports 48Khz (locked rate), then your recording/playback software
313 must upsample or downsample accordingly. The hardware cannot do it.
314 </para>
315 </listitem>
316
317 <listitem>
318 <para>
319 Use new pci_request_regions and pci_disable_device functions in
320 kernel 2.4.6.
321 </para>
322 </listitem>
323
324 </itemizedlist>
325</sect1>
326
327<sect1 id="version1114"><title>
328Version 1.1.14
329</title>
330 <itemizedlist spacing="compact">
331 <listitem>
332 <para>
333 Use VM_RESERVE when available, to eliminate unnecessary page faults.
334 </para>
335 </listitem>
336 </itemizedlist>
337</sect1>
338
339<sect1 id="version1112"><title>
340Version 1.1.12
341</title>
342 <itemizedlist spacing="compact">
343 <listitem>
344 <para>
345 mmap bug fixes from Linus.
346 </para>
347 </listitem>
348 </itemizedlist>
349</sect1>
350
351<sect1 id="version1111"><title>
352Version 1.1.11
353</title>
354 <itemizedlist spacing="compact">
355 <listitem>
356 <para>
357 Many more bug fixes. mmap enabled by default, but may still be buggy.
358 </para>
359 </listitem>
360
361 <listitem>
362 <para>
363 Uses new and spiffy method of mmap'ing the DMA buffer, based
364 on a suggestion from Linus.
365 </para>
366 </listitem>
367 </itemizedlist>
368</sect1>
369
370<sect1 id="version1110"><title>
371Version 1.1.10
372</title>
373 <itemizedlist spacing="compact">
374 <listitem>
375 <para>
376 Many bug fixes. mmap enabled by default, but may still be buggy.
377 </para>
378 </listitem>
379 </itemizedlist>
380</sect1>
381
382<sect1 id="version119"><title>
383Version 1.1.9
384</title>
385 <itemizedlist spacing="compact">
386 <listitem>
387 <para>
388 Redesign and rewrite audio playback implementation. (faster and smaller, hopefully)
389 </para>
390 </listitem>
391
392 <listitem>
393 <para>
394 Implement recording and full duplex (DSP_CAP_DUPLEX) support.
395 </para>
396 </listitem>
397
398 <listitem>
399 <para>
400 Make procfs support optional.
401 </para>
402 </listitem>
403
404 <listitem>
405 <para>
406 Quick interrupt status check, to lessen overhead in interrupt
407 sharing situations.
408 </para>
409 </listitem>
410
411 <listitem>
412 <para>
413 Add mmap(2) support. Disabled for now, it is still buggy and experimental.
414 </para>
415 </listitem>
416
417 <listitem>
418 <para>
419 Surround all syscalls with a semaphore for cheap and easy SMP protection.
420 </para>
421 </listitem>
422
423 <listitem>
424 <para>
425 Fix bug in channel shutdown (hardware channel reset) code.
426 </para>
427 </listitem>
428
429 <listitem>
430 <para>
431 Remove unnecessary spinlocks (better performance).
432 </para>
433 </listitem>
434
435 <listitem>
436 <para>
437 Eliminate "unknown AFMT" message by using a different method
438 of selecting the best AFMT_xxx sound sample format for use.
439 </para>
440 </listitem>
441
442 <listitem>
443 <para>
444 Support for realtime hardware pointer position reporting
445 (DSP_CAP_REALTIME, SNDCTL_DSP_GETxPTR ioctls)
446 </para>
447 </listitem>
448
449 <listitem>
450 <para>
451 Support for capture/playback triggering
452 (DSP_CAP_TRIGGER, SNDCTL_DSP_SETTRIGGER ioctls)
453 </para>
454 </listitem>
455
456 <listitem>
457 <para>
458 SNDCTL_DSP_SETDUPLEX and SNDCTL_DSP_POST ioctls now handled.
459 </para>
460 </listitem>
461
462 <listitem>
463 <para>
464 Rewrite open(2) and close(2) logic to allow only one user at
465 a time. All other open(2) attempts will sleep until they succeed.
466 FIXME: open(O_RDONLY) and open(O_WRONLY) should be allowed to succeed.
467 </para>
468 </listitem>
469
470 <listitem>
471 <para>
472 Reviewed code to ensure that SMP and multiple audio devices
473 are fully supported.
474 </para>
475 </listitem>
476
477 </itemizedlist>
478</sect1>
479
480<sect1 id="version118"><title>
481Version 1.1.8
482</title>
483 <itemizedlist spacing="compact">
484 <listitem>
485 <para>
486 Clean up interrupt handler output. Fixes the following kernel error message:
487 </para>
488 <programlisting>
489 unhandled interrupt ...
490 </programlisting>
491 </listitem>
492
493 <listitem>
494 <para>
495 Convert documentation to DocBook, so that PDF, HTML and PostScript (.ps) output is readily
496 available.
497 </para>
498 </listitem>
499
500 </itemizedlist>
501</sect1>
502
503<sect1 id="version117"><title>
504Version 1.1.7
505</title>
506 <itemizedlist spacing="compact">
507 <listitem>
508 <para>
509 Fix module unload bug where mixer device left registered
510 after driver exit
511 </para>
512 </listitem>
513 </itemizedlist>
514</sect1>
515
516<sect1 id="version116"><title>
517Version 1.1.6
518</title>
519 <itemizedlist spacing="compact">
520 <listitem>
521 <para>
522 Rewrite via_set_rate to mimic ALSA basic AC97 rate setting
523 </para>
524 </listitem>
525 <listitem>
526 <para>
527 Remove much dead code
528 </para>
529 </listitem>
530 <listitem>
531 <para>
532 Complete spin_lock_irqsave -> spin_lock_irq conversion in via_dsp_ioctl
533 </para>
534 </listitem>
535 <listitem>
536 <para>
537 Fix build problem in via_dsp_ioctl
538 </para>
539 </listitem>
540 <listitem>
541 <para>
542 Optimize included headers to eliminate headers found in linux/sound
543 </para>
544 </listitem>
545 </itemizedlist>
546</sect1>
547
548<sect1 id="version115"><title>
549Version 1.1.5
550</title>
551 <itemizedlist spacing="compact">
552 <listitem>
553 <para>
554 Disable some overly-verbose debugging code
555 </para>
556 </listitem>
557 <listitem>
558 <para>
559 Remove unnecessary sound locks
560 </para>
561 </listitem>
562 <listitem>
563 <para>
564 Fix some ioctls for better time resolution
565 </para>
566 </listitem>
567 <listitem>
568 <para>
569 Begin spin_lock_irqsave -> spin_lock_irq conversion in via_dsp_ioctl
570 </para>
571 </listitem>
572 </itemizedlist>
573</sect1>
574
575<sect1 id="version114"><title>
576Version 1.1.4
577</title>
578 <itemizedlist spacing="compact">
579 <listitem>
580 <para>
581 Completed rewrite of driver. Eliminated SoundBlaster compatibility
582 completely, and now uses the much-faster scatter-gather DMA engine.
583 </para>
584 </listitem>
585 </itemizedlist>
586</sect1>
587
588 </chapter>
589
590 <chapter id="intfunctions">
591 <title>Internal Functions</title>
592!Isound/oss/via82cxxx_audio.c
593 </chapter>
594
595</book>
596
597
diff --git a/Documentation/RCU/RTFP.txt b/Documentation/RCU/RTFP.txt
index 12250b342e1f..9c6d450138ea 100644
--- a/Documentation/RCU/RTFP.txt
+++ b/Documentation/RCU/RTFP.txt
@@ -108,8 +108,9 @@ year saw a paper describing an RCU implementation of System V IPC
1082004 has seen a Linux-Journal article on use of RCU in dcache 1082004 has seen a Linux-Journal article on use of RCU in dcache
109[McKenney04a], a performance comparison of locking to RCU on several 109[McKenney04a], a performance comparison of locking to RCU on several
110different CPUs [McKenney04b], a dissertation describing use of RCU in a 110different CPUs [McKenney04b], a dissertation describing use of RCU in a
111number of operating-system kernels [PaulEdwardMcKenneyPhD], and a paper 111number of operating-system kernels [PaulEdwardMcKenneyPhD], a paper
112describing how to make RCU safe for soft-realtime applications [Sarma04c]. 112describing how to make RCU safe for soft-realtime applications [Sarma04c],
113and a paper describing SELinux performance with RCU [JamesMorris04b].
113 114
114 115
115Bibtex Entries 116Bibtex Entries
@@ -341,6 +342,17 @@ Dipankar Sarma"
341,pages="18-26" 342,pages="18-26"
342} 343}
343 344
345@techreport{Friedberg03a
346,author="Stuart A. Friedberg"
347,title="Lock-Free Wild Card Search Data Structure and Method"
348,institution="US Patent and Trademark Office"
349,address="Washington, DC"
350,year="2003"
351,number="US Patent 6,662,184 (contributed under GPL)"
352,month="December"
353,pages="112"
354}
355
344@article{McKenney04a 356@article{McKenney04a
345,author="Paul E. McKenney and Dipankar Sarma and Maneesh Soni" 357,author="Paul E. McKenney and Dipankar Sarma and Maneesh Soni"
346,title="Scaling dcache with {RCU}" 358,title="Scaling dcache with {RCU}"
@@ -373,6 +385,9 @@ in Operating System Kernels"
373,school="OGI School of Science and Engineering at 385,school="OGI School of Science and Engineering at
374Oregon Health and Sciences University" 386Oregon Health and Sciences University"
375,year="2004" 387,year="2004"
388,note="Available:
389\url{http://www.rdrop.com/users/paulmck/RCU/RCUdissertation.2004.07.14e1.pdf}
390[Viewed October 15, 2004]"
376} 391}
377 392
378@Conference{Sarma04c 393@Conference{Sarma04c
@@ -385,3 +400,13 @@ Oregon Health and Sciences University"
385,month="June" 400,month="June"
386,pages="182-191" 401,pages="182-191"
387} 402}
403
404@unpublished{JamesMorris04b
405,Author="James Morris"
406,Title="Recent Developments in {SELinux} Kernel Performance"
407,month="December"
408,year="2004"
409,note="Available:
410\url{http://www.livejournal.com/users/james_morris/2153.html}
411[Viewed December 10, 2004]"
412}
diff --git a/Documentation/RCU/UP.txt b/Documentation/RCU/UP.txt
index 551a803d82a8..3bfb84b3b7db 100644
--- a/Documentation/RCU/UP.txt
+++ b/Documentation/RCU/UP.txt
@@ -2,11 +2,11 @@ RCU on Uniprocessor Systems
2 2
3 3
4A common misconception is that, on UP systems, the call_rcu() primitive 4A common misconception is that, on UP systems, the call_rcu() primitive
5may immediately invoke its function, and that the synchronize_kernel 5may immediately invoke its function, and that the synchronize_rcu()
6primitive may return immediately. The basis of this misconception 6primitive may return immediately. The basis of this misconception
7is that since there is only one CPU, it should not be necessary to 7is that since there is only one CPU, it should not be necessary to
8wait for anything else to get done, since there are no other CPUs for 8wait for anything else to get done, since there are no other CPUs for
9anything else to be happening on. Although this approach will sort of 9anything else to be happening on. Although this approach will -sort- -of-
10work a surprising amount of the time, it is a very bad idea in general. 10work a surprising amount of the time, it is a very bad idea in general.
11This document presents two examples that demonstrate exactly how bad an 11This document presents two examples that demonstrate exactly how bad an
12idea this is. 12idea this is.
@@ -44,14 +44,14 @@ its arguments would cause it to fail to make the fundamental guarantee
44underlying RCU, namely that call_rcu() defers invoking its arguments until 44underlying RCU, namely that call_rcu() defers invoking its arguments until
45all RCU read-side critical sections currently executing have completed. 45all RCU read-side critical sections currently executing have completed.
46 46
47Quick Quiz: why is it -not- legal to invoke synchronize_kernel() in 47Quick Quiz: why is it -not- legal to invoke synchronize_rcu() in
48this case? 48this case?
49 49
50 50
51Summary 51Summary
52 52
53Permitting call_rcu() to immediately invoke its arguments or permitting 53Permitting call_rcu() to immediately invoke its arguments or permitting
54synchronize_kernel() to immediately return breaks RCU, even on a UP system. 54synchronize_rcu() to immediately return breaks RCU, even on a UP system.
55So do not do it! Even on a UP system, the RCU infrastructure -must- 55So do not do it! Even on a UP system, the RCU infrastructure -must-
56respect grace periods. 56respect grace periods.
57 57
diff --git a/Documentation/RCU/checklist.txt b/Documentation/RCU/checklist.txt
index b3a568abe6b1..8f3fb77c9cd3 100644
--- a/Documentation/RCU/checklist.txt
+++ b/Documentation/RCU/checklist.txt
@@ -32,7 +32,10 @@ over a rather long period of time, but improvements are always welcome!
32 them -- even x86 allows reads to be reordered), and be prepared 32 them -- even x86 allows reads to be reordered), and be prepared
33 to explain why this added complexity is worthwhile. If you 33 to explain why this added complexity is worthwhile. If you
34 choose #c, be prepared to explain how this single task does not 34 choose #c, be prepared to explain how this single task does not
35 become a major bottleneck on big multiprocessor machines. 35 become a major bottleneck on big multiprocessor machines (for
36 example, if the task is updating information relating to itself
37 that other tasks can read, there by definition can be no
38 bottleneck).
36 39
372. Do the RCU read-side critical sections make proper use of 402. Do the RCU read-side critical sections make proper use of
38 rcu_read_lock() and friends? These primitives are needed 41 rcu_read_lock() and friends? These primitives are needed
@@ -89,27 +92,34 @@ over a rather long period of time, but improvements are always welcome!
89 "_rcu()" list-traversal primitives, such as the 92 "_rcu()" list-traversal primitives, such as the
90 list_for_each_entry_rcu(). 93 list_for_each_entry_rcu().
91 94
92 b. If the list macros are being used, the list_del_rcu(), 95 b. If the list macros are being used, the list_add_tail_rcu()
93 list_add_tail_rcu(), and list_del_rcu() primitives must 96 and list_add_rcu() primitives must be used in order
94 be used in order to prevent weakly ordered machines from 97 to prevent weakly ordered machines from misordering
95 misordering structure initialization and pointer planting. 98 structure initialization and pointer planting.
96 Similarly, if the hlist macros are being used, the 99 Similarly, if the hlist macros are being used, the
97 hlist_del_rcu() and hlist_add_head_rcu() primitives 100 hlist_add_head_rcu() primitive is required.
98 are required.
99 101
100 c. Updates must ensure that initialization of a given 102 c. If the list macros are being used, the list_del_rcu()
103 primitive must be used to keep list_del()'s pointer
104 poisoning from inflicting toxic effects on concurrent
105 readers. Similarly, if the hlist macros are being used,
106 the hlist_del_rcu() primitive is required.
107
108 The list_replace_rcu() primitive may be used to
109 replace an old structure with a new one in an
110 RCU-protected list.
111
112 d. Updates must ensure that initialization of a given
101 structure happens before pointers to that structure are 113 structure happens before pointers to that structure are
102 publicized. Use the rcu_assign_pointer() primitive 114 publicized. Use the rcu_assign_pointer() primitive
103 when publicizing a pointer to a structure that can 115 when publicizing a pointer to a structure that can
104 be traversed by an RCU read-side critical section. 116 be traversed by an RCU read-side critical section.
105 117
106 [The rcu_assign_pointer() primitive is in process.]
107
1085. If call_rcu(), or a related primitive such as call_rcu_bh(), 1185. If call_rcu(), or a related primitive such as call_rcu_bh(),
109 is used, the callback function must be written to be called 119 is used, the callback function must be written to be called
110 from softirq context. In particular, it cannot block. 120 from softirq context. In particular, it cannot block.
111 121
1126. Since synchronize_kernel() blocks, it cannot be called from 1226. Since synchronize_rcu() can block, it cannot be called from
113 any sort of irq context. 123 any sort of irq context.
114 124
1157. If the updater uses call_rcu(), then the corresponding readers 1257. If the updater uses call_rcu(), then the corresponding readers
@@ -125,9 +135,9 @@ over a rather long period of time, but improvements are always welcome!
125 such cases is a must, of course! And the jury is still out on 135 such cases is a must, of course! And the jury is still out on
126 whether the increased speed is worth it. 136 whether the increased speed is worth it.
127 137
1288. Although synchronize_kernel() is a bit slower than is call_rcu(), 1388. Although synchronize_rcu() is a bit slower than is call_rcu(),
129 it usually results in simpler code. So, unless update performance 139 it usually results in simpler code. So, unless update performance
130 is important or the updaters cannot block, synchronize_kernel() 140 is important or the updaters cannot block, synchronize_rcu()
131 should be used in preference to call_rcu(). 141 should be used in preference to call_rcu().
132 142
1339. All RCU list-traversal primitives, which include 1439. All RCU list-traversal primitives, which include
@@ -155,3 +165,14 @@ over a rather long period of time, but improvements are always welcome!
155 you -must- use the "_rcu()" variants of the list macros. 165 you -must- use the "_rcu()" variants of the list macros.
156 Failing to do so will break Alpha and confuse people reading 166 Failing to do so will break Alpha and confuse people reading
157 your code. 167 your code.
168
16911. Note that synchronize_rcu() -only- guarantees to wait until
170 all currently executing rcu_read_lock()-protected RCU read-side
171 critical sections complete. It does -not- necessarily guarantee
172 that all currently running interrupts, NMIs, preempt_disable()
173 code, or idle loops will complete. Therefore, if you do not have
174 rcu_read_lock()-protected read-side critical sections, do -not-
175 use synchronize_rcu().
176
177 If you want to wait for some of these other things, you might
178 instead need to use synchronize_irq() or synchronize_sched().
diff --git a/Documentation/RCU/listRCU.txt b/Documentation/RCU/listRCU.txt
index bda6ead69bd0..f8a54fa0d8ab 100644
--- a/Documentation/RCU/listRCU.txt
+++ b/Documentation/RCU/listRCU.txt
@@ -32,6 +32,7 @@ implementation of audit_filter_task() might be as follows:
32 enum audit_state state; 32 enum audit_state state;
33 33
34 read_lock(&auditsc_lock); 34 read_lock(&auditsc_lock);
35 /* Note: audit_netlink_sem held by caller. */
35 list_for_each_entry(e, &audit_tsklist, list) { 36 list_for_each_entry(e, &audit_tsklist, list) {
36 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { 37 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {
37 read_unlock(&auditsc_lock); 38 read_unlock(&auditsc_lock);
@@ -55,6 +56,7 @@ This means that RCU can be easily applied to the read side, as follows:
55 enum audit_state state; 56 enum audit_state state;
56 57
57 rcu_read_lock(); 58 rcu_read_lock();
59 /* Note: audit_netlink_sem held by caller. */
58 list_for_each_entry_rcu(e, &audit_tsklist, list) { 60 list_for_each_entry_rcu(e, &audit_tsklist, list) {
59 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) { 61 if (audit_filter_rules(tsk, &e->rule, NULL, &state)) {
60 rcu_read_unlock(); 62 rcu_read_unlock();
@@ -139,12 +141,15 @@ Normally, the write_lock() and write_unlock() would be replaced by
139a spin_lock() and a spin_unlock(), but in this case, all callers hold 141a spin_lock() and a spin_unlock(), but in this case, all callers hold
140audit_netlink_sem, so no additional locking is required. The auditsc_lock 142audit_netlink_sem, so no additional locking is required. The auditsc_lock
141can therefore be eliminated, since use of RCU eliminates the need for 143can therefore be eliminated, since use of RCU eliminates the need for
142writers to exclude readers. 144writers to exclude readers. Normally, the write_lock() calls would
145be converted into spin_lock() calls.
143 146
144The list_del(), list_add(), and list_add_tail() primitives have been 147The list_del(), list_add(), and list_add_tail() primitives have been
145replaced by list_del_rcu(), list_add_rcu(), and list_add_tail_rcu(). 148replaced by list_del_rcu(), list_add_rcu(), and list_add_tail_rcu().
146The _rcu() list-manipulation primitives add memory barriers that are 149The _rcu() list-manipulation primitives add memory barriers that are
147needed on weakly ordered CPUs (most of them!). 150needed on weakly ordered CPUs (most of them!). The list_del_rcu()
151primitive omits the pointer poisoning debug-assist code that would
152otherwise cause concurrent readers to fail spectacularly.
148 153
149So, when readers can tolerate stale data and when entries are either added 154So, when readers can tolerate stale data and when entries are either added
150or deleted, without in-place modification, it is very easy to use RCU! 155or deleted, without in-place modification, it is very easy to use RCU!
@@ -166,6 +171,7 @@ otherwise, the added fields would need to be filled in):
166 struct audit_newentry *ne; 171 struct audit_newentry *ne;
167 172
168 write_lock(&auditsc_lock); 173 write_lock(&auditsc_lock);
174 /* Note: audit_netlink_sem held by caller. */
169 list_for_each_entry(e, list, list) { 175 list_for_each_entry(e, list, list) {
170 if (!audit_compare_rule(rule, &e->rule)) { 176 if (!audit_compare_rule(rule, &e->rule)) {
171 e->rule.action = newaction; 177 e->rule.action = newaction;
@@ -199,8 +205,7 @@ RCU ("read-copy update") its name. The RCU code is as follows:
199 audit_copy_rule(&ne->rule, &e->rule); 205 audit_copy_rule(&ne->rule, &e->rule);
200 ne->rule.action = newaction; 206 ne->rule.action = newaction;
201 ne->rule.file_count = newfield_count; 207 ne->rule.file_count = newfield_count;
202 list_add_rcu(ne, e); 208 list_replace_rcu(e, ne);
203 list_del(e);
204 call_rcu(&e->rcu, audit_free_rule, e); 209 call_rcu(&e->rcu, audit_free_rule, e);
205 return 0; 210 return 0;
206 } 211 }
diff --git a/Documentation/RCU/rcu.txt b/Documentation/RCU/rcu.txt
index 7e0c2ab6f2bd..eb444006683e 100644
--- a/Documentation/RCU/rcu.txt
+++ b/Documentation/RCU/rcu.txt
@@ -43,7 +43,9 @@ o If I am running on a uniprocessor kernel, which can only do one
43 43
44o How can I see where RCU is currently used in the Linux kernel? 44o How can I see where RCU is currently used in the Linux kernel?
45 45
46 Search for "rcu_read_lock", "call_rcu", and "synchronize_kernel". 46 Search for "rcu_read_lock", "rcu_read_unlock", "call_rcu",
47 "rcu_read_lock_bh", "rcu_read_unlock_bh", "call_rcu_bh",
48 "synchronize_rcu", and "synchronize_net".
47 49
48o What guidelines should I follow when writing code that uses RCU? 50o What guidelines should I follow when writing code that uses RCU?
49 51
diff --git a/Documentation/aoe/aoe.txt b/Documentation/aoe/aoe.txt
index 43e50108d0e2..3a4dbe4663c9 100644
--- a/Documentation/aoe/aoe.txt
+++ b/Documentation/aoe/aoe.txt
@@ -4,6 +4,16 @@ The EtherDrive (R) HOWTO for users of 2.6 kernels is found at ...
4 4
5 It has many tips and hints! 5 It has many tips and hints!
6 6
7The aoetools are userland programs that are designed to work with this
8driver. The aoetools are on sourceforge.
9
10 http://aoetools.sourceforge.net/
11
12The scripts in this Documentation/aoe directory are intended to
13document the use of the driver and are not necessary if you install
14the aoetools.
15
16
7CREATING DEVICE NODES 17CREATING DEVICE NODES
8 18
9 Users of udev should find the block device nodes created 19 Users of udev should find the block device nodes created
@@ -35,14 +45,15 @@ USING DEVICE NODES
35 45
36 "echo eth2 eth4 > /dev/etherd/interfaces" tells the aoe driver to 46 "echo eth2 eth4 > /dev/etherd/interfaces" tells the aoe driver to
37 limit ATA over Ethernet traffic to eth2 and eth4. AoE traffic from 47 limit ATA over Ethernet traffic to eth2 and eth4. AoE traffic from
38 untrusted networks should be ignored as a matter of security. 48 untrusted networks should be ignored as a matter of security. See
49 also the aoe_iflist driver option described below.
39 50
40 "echo > /dev/etherd/discover" tells the driver to find out what AoE 51 "echo > /dev/etherd/discover" tells the driver to find out what AoE
41 devices are available. 52 devices are available.
42 53
43 These character devices may disappear and be replaced by sysfs 54 These character devices may disappear and be replaced by sysfs
44 counterparts, so distribution maintainers are encouraged to create 55 counterparts. Using the commands in aoetools insulates users from
45 scripts that use these devices. 56 these implementation details.
46 57
47 The block devices are named like this: 58 The block devices are named like this:
48 59
@@ -66,7 +77,8 @@ USING SYSFS
66 through which we are communicating with the remote AoE device. 77 through which we are communicating with the remote AoE device.
67 78
68 There is a script in this directory that formats this information 79 There is a script in this directory that formats this information
69 in a convenient way. 80 in a convenient way. Users with aoetools can use the aoe-stat
81 command.
70 82
71 root@makki root# sh Documentation/aoe/status.sh 83 root@makki root# sh Documentation/aoe/status.sh
72 e10.0 eth3 up 84 e10.0 eth3 up
@@ -89,3 +101,23 @@ USING SYSFS
89 e4.7 eth1 up 101 e4.7 eth1 up
90 e4.8 eth1 up 102 e4.8 eth1 up
91 e4.9 eth1 up 103 e4.9 eth1 up
104
105 Use /sys/module/aoe/parameters/aoe_iflist (or better, the driver
106 option discussed below) instead of /dev/etherd/interfaces to limit
107 AoE traffic to the network interfaces in the given
108 whitespace-separated list. Unlike the old character device, the
109 sysfs entry can be read from as well as written to.
110
111 It's helpful to trigger discovery after setting the list of allowed
112 interfaces. The aoetools package provides an aoe-discover script
113 for this purpose. You can also directly use the
114 /dev/etherd/discover special file described above.
115
116DRIVER OPTIONS
117
118 There is a boot option for the built-in aoe driver and a
119 corresponding module parameter, aoe_iflist. Without this option,
120 all network interfaces may be used for ATA over Ethernet. Here is a
121 usage example for the module parameter.
122
123 modprobe aoe_iflist="eth1 eth3"
diff --git a/Documentation/aoe/status.sh b/Documentation/aoe/status.sh
index 6628116d4a9f..751f3be514b8 100644
--- a/Documentation/aoe/status.sh
+++ b/Documentation/aoe/status.sh
@@ -14,10 +14,6 @@ test ! -d "$sysd/block" && {
14 echo "$me Error: sysfs is not mounted" 1>&2 14 echo "$me Error: sysfs is not mounted" 1>&2
15 exit 1 15 exit 1
16} 16}
17test -z "`lsmod | grep '^aoe'`" && {
18 echo "$me Error: aoe module is not loaded" 1>&2
19 exit 1
20}
21 17
22for d in `ls -d $sysd/block/etherd* 2>/dev/null | grep -v p` end; do 18for d in `ls -d $sysd/block/etherd* 2>/dev/null | grep -v p` end; do
23 # maybe ls comes up empty, so we use "end" 19 # maybe ls comes up empty, so we use "end"
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 734fcc87db25..9a33bb94f74f 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -1,137 +1,140 @@
1.* 1*.a
2*.aux
3*.bin
4*.cpio
5*.css
6*.dvi
7*.eps
8*.gif
9*.grep
10*.grp
11*.gz
12*.html
13*.jpeg
14*.ko
15*.log
16*.lst
17*.mod.c
18*.o
19*.orig
20*.out
21*.pdf
22*.png
23*.ps
24*.rej
25*.s
26*.sgml
27*.so
28*.tex
29*.ver
30*.xml
31*_MODULES
32*_vga16.c
33*cscope*
2*~ 34*~
35.*
36.cscope
3753c700_d.h
353c8xx_d.h* 3853c8xx_d.h*
4*.a 39BitKeeper
40COPYING
41CREDITS
42CVS
43ChangeSet
44Kerntypes
45MODS.txt
46Module.symvers
47PENDING
48SCCS
49System.map*
50TAGS
5aic7*reg.h* 51aic7*reg.h*
6aic7*seq.h*
7aic7*reg_print.c* 52aic7*reg_print.c*
853c700_d.h 53aic7*seq.h*
9aicasm 54aicasm
10aicdb.h* 55aicdb.h*
11asm 56asm
12asm_offsets.* 57asm_offsets.*
13autoconf.h* 58autoconf.h*
14*.aux
15bbootsect 59bbootsect
16*.bin
17bin2c 60bin2c
18binkernel.spec 61binkernel.spec
19BitKeeper
20bootsect 62bootsect
21bsetup 63bsetup
22btfixupprep 64btfixupprep
23build 65build
24bvmlinux 66bvmlinux
25bzImage* 67bzImage*
26ChangeSet
27classlist.h* 68classlist.h*
28compile.h*
29comp*.log 69comp*.log
70compile.h*
30config 71config
31config-* 72config-*
32config_data.h* 73config_data.h*
33conmakehash 74conmakehash
34consolemap_deftbl.c* 75consolemap_deftbl.c*
35COPYING 76crc32table.h*
36CREDITS
37.cscope
38*cscope*
39cscope.* 77cscope.*
40*.out
41*.css
42CVS
43defkeymap.c* 78defkeymap.c*
44devlist.h* 79devlist.h*
45docproc 80docproc
46dummy_sym.c* 81dummy_sym.c*
47*.dvi 82elfconfig.h*
48*.eps
49filelist 83filelist
50fixdep 84fixdep
51fore200e_mkfirm 85fore200e_mkfirm
52fore200e_pca_fw.c* 86fore200e_pca_fw.c*
53gen-devlist 87gen-devlist
54gen_init_cpio
55gen_crc32table
56crc32table.h*
57*.cpio
58gen-kdb_cmds.c* 88gen-kdb_cmds.c*
59gentbl 89gen_crc32table
90gen_init_cpio
60genksyms 91genksyms
61*.gif 92gentbl
62*.gz
63*.html
64ikconfig.h* 93ikconfig.h*
65initramfs_list 94initramfs_list
66*.jpeg 95kallsyms
67kconfig 96kconfig
68kconfig.tk 97kconfig.tk
69Kerntypes
70keywords.c* 98keywords.c*
71ksym.c* 99ksym.c*
72ksym.h* 100ksym.h*
73kallsyms
74mk_elfconfig
75elfconfig.h*
76modpost
77pnmtologo
78logo_*.c
79*.log
80lex.c* 101lex.c*
102logo_*.c
81logo_*_clut224.c 103logo_*_clut224.c
82logo_*_mono.c 104logo_*_mono.c
83lxdialog 105lxdialog
84make_times_h 106make_times_h
85map 107map
108maui_boot.h
109mk_elfconfig
86mkdep 110mkdep
87*_MODULES 111mktables
88MODS.txt 112modpost
89modversions.h* 113modversions.h*
90Module.symvers 114offsets.h
91*.mod.c
92*.o
93*.ko
94*.orig
95*.lst
96*.grp
97*.grep
98oui.c* 115oui.c*
99mktables
100raid6tables.c
101raid6int*.c
102raid6altivec*.c
103wanxlfw.inc
104maui_boot.h
105pss_boot.h
106trix_boot.h
107*.pdf
108parse.c* 116parse.c*
109parse.h* 117parse.h*
110PENDING 118pnmtologo
111ppc_defs.h* 119ppc_defs.h*
112promcon_tbl.c* 120promcon_tbl.c*
113*.png 121pss_boot.h
114*.ps 122raid6altivec*.c
115*.rej 123raid6int*.c
116SCCS 124raid6tables.c
117setup 125setup
118*.s
119*.so
120*.sgml
121sim710_d.h* 126sim710_d.h*
122sm_tbl* 127sm_tbl*
123split-include 128split-include
124System.map*
125tags 129tags
126TAGS
127*.tex
128times.h* 130times.h*
129tkparse 131tkparse
130*.ver 132trix_boot.h
131version.h* 133version.h*
132*_vga16.c
133vmlinux 134vmlinux
134vmlinux.lds
135vmlinux-* 135vmlinux-*
136vmlinux.lds
136vsyscall.lds 137vsyscall.lds
138wanxlfw.inc
139uImage
137zImage 140zImage
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 56627c1546de..d3c52dd24a2a 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -48,3 +48,18 @@ When: April 2005
48Why: Replaced by ->compat_ioctl in file_operations and other method 48Why: Replaced by ->compat_ioctl in file_operations and other method
49 vecors. 49 vecors.
50Who: Andi Kleen <ak@muc.de>, Christoph Hellwig <hch@lst.de> 50Who: Andi Kleen <ak@muc.de>, Christoph Hellwig <hch@lst.de>
51
52---------------------------
53
54What: RCU API moves to EXPORT_SYMBOL_GPL
55When: April 2006
56Files: include/linux/rcupdate.h, kernel/rcupdate.c
57Why: Outside of Linux, the only implementations of anything even
58 vaguely resembling RCU that I am aware of are in DYNIX/ptx,
59 VM/XA, Tornado, and K42. I do not expect anyone to port binary
60 drivers or kernel modules from any of these, since the first two
61 are owned by IBM and the last two are open-source research OSes.
62 So these will move to GPL after a grace period to allow
63 people, who might be using implementations that I am not aware
64 of, to adjust to this upcoming change.
65Who: Paul E. McKenney <paulmck@us.ibm.com>
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index a934baeeb33a..1045da582b9b 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -219,8 +219,12 @@ This may also be done to avoid internal deadlocks, but rarely.
219If the filesytem is called for sync then it must wait on any 219If the filesytem is called for sync then it must wait on any
220in-progress I/O and then start new I/O. 220in-progress I/O and then start new I/O.
221 221
222The filesystem should unlock the page synchronously, before returning 222The filesystem should unlock the page synchronously, before returning to the
223to the caller. 223caller, unless ->writepage() returns special WRITEPAGE_ACTIVATE
224value. WRITEPAGE_ACTIVATE means that page cannot really be written out
225currently, and VM should stop calling ->writepage() on this page for some
226time. VM does this by moving page to the head of the active list, hence the
227name.
224 228
225Unless the filesystem is going to redirty_page_for_writepage(), unlock the page 229Unless the filesystem is going to redirty_page_for_writepage(), unlock the page
226and return zero, writepage *must* run set_page_writeback() against the page, 230and return zero, writepage *must* run set_page_writeback() against the page,
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index cbe85c17176b..6c98f2bd421e 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -909,16 +909,6 @@ nr_free_inodes
909Represents the number of free inodes. Ie. The number of inuse inodes is 909Represents the number of free inodes. Ie. The number of inuse inodes is
910(nr_inodes - nr_free_inodes). 910(nr_inodes - nr_free_inodes).
911 911
912super-nr and super-max
913----------------------
914
915Again, super block structures are allocated by the kernel, but not freed. The
916file super-max contains the maximum number of super block handlers, where
917super-nr shows the number of currently allocated ones.
918
919Every mounted file system needs a super block, so if you plan to mount lots of
920file systems, you may want to increase these numbers.
921
922aio-nr and aio-max-nr 912aio-nr and aio-max-nr
923--------------------- 913---------------------
924 914
diff --git a/Documentation/i386/zero-page.txt b/Documentation/i386/zero-page.txt
index 67c053a099ed..df28c7416781 100644
--- a/Documentation/i386/zero-page.txt
+++ b/Documentation/i386/zero-page.txt
@@ -79,6 +79,6 @@ Offset Type Description
790x22c unsigned long ramdisk_max 790x22c unsigned long ramdisk_max
800x230 16 bytes trampoline 800x230 16 bytes trampoline
810x290 - 0x2cf EDD_MBR_SIG_BUFFER (edd.S) 810x290 - 0x2cf EDD_MBR_SIG_BUFFER (edd.S)
820x2d0 - 0x600 E820MAP 820x2d0 - 0xd00 E820MAP
830x600 - 0x7ff EDDBUF (edd.S) for disk signature read sector 830xd00 - 0xeff EDDBUF (edd.S) for disk signature read sector
840x600 - 0x7eb EDDBUF (edd.S) for edd data 840xd00 - 0xeeb EDDBUF (edd.S) for edd data
diff --git a/Documentation/networking/DLINK.txt b/Documentation/networking/DLINK.txt
index 083d24752b83..55d24433d151 100644
--- a/Documentation/networking/DLINK.txt
+++ b/Documentation/networking/DLINK.txt
@@ -178,10 +178,9 @@ Released 1994-06-13
178 7. ACKNOWLEDGMENTS. 178 7. ACKNOWLEDGMENTS.
179 179
180 These drivers wouldn't have been done without the base 180 These drivers wouldn't have been done without the base
181 (and support) from Ross Biro <bir7@leland.stanford.edu>, 181 (and support) from Ross Biro, and D-Link Systems Inc.
182 and D-Link Systems Inc. The driver relies upon GPL-ed 182 The driver relies upon GPL-ed source from D-Link Systems Inc.
183 source from D-Link Systems Inc. and from Russel Nelson at 183 and from Russel Nelson at Crynwr Software <nelson@crynwr.com>.
184 Crynwr Software <nelson@crynwr.com>.
185 184
186 Additional input also from: 185 Additional input also from:
187 Donald Becker <becker@super.org>, Alan Cox <A.Cox@swansea.ac.uk> 186 Donald Becker <becker@super.org>, Alan Cox <A.Cox@swansea.ac.uk>
diff --git a/Documentation/networking/netdevices.txt b/Documentation/networking/netdevices.txt
index 1509f3aff968..3c0a5ba614d7 100644
--- a/Documentation/networking/netdevices.txt
+++ b/Documentation/networking/netdevices.txt
@@ -51,6 +51,8 @@ dev->hard_start_xmit:
51 set_multicast_list 51 set_multicast_list
52 Context: BHs disabled 52 Context: BHs disabled
53 Notes: netif_queue_stopped() is guaranteed false 53 Notes: netif_queue_stopped() is guaranteed false
54 Interrupts must be enabled when calling hard_start_xmit.
55 (Interrupts must also be enabled when enabling the BH handler.)
54 Return codes: 56 Return codes:
55 o NETDEV_TX_OK everything ok. 57 o NETDEV_TX_OK everything ok.
56 o NETDEV_TX_BUSY Cannot transmit packet, try later 58 o NETDEV_TX_BUSY Cannot transmit packet, try later
diff --git a/Documentation/pci.txt b/Documentation/pci.txt
index 67514bf87ccd..62b1dc5d97e2 100644
--- a/Documentation/pci.txt
+++ b/Documentation/pci.txt
@@ -279,6 +279,7 @@ pci_for_each_dev_reverse() Superseded by pci_find_device_reverse()
279pci_for_each_bus() Superseded by pci_find_next_bus() 279pci_for_each_bus() Superseded by pci_find_next_bus()
280pci_find_device() Superseded by pci_get_device() 280pci_find_device() Superseded by pci_get_device()
281pci_find_subsys() Superseded by pci_get_subsys() 281pci_find_subsys() Superseded by pci_get_subsys()
282pci_find_slot() Superseded by pci_get_slot()
282pcibios_find_class() Superseded by pci_get_class() 283pcibios_find_class() Superseded by pci_get_class()
283pci_find_class() Superseded by pci_get_class() 284pci_find_class() Superseded by pci_get_class()
284pci_(read|write)_*_nodev() Superseded by pci_bus_(read|write)_*() 285pci_(read|write)_*_nodev() Superseded by pci_bus_(read|write)_*()
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index c85428e7ad92..35b1a7dae342 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -165,40 +165,9 @@ Description:
165These functions are intended for use by individual drivers, and are defined in 165These functions are intended for use by individual drivers, and are defined in
166struct pci_driver: 166struct pci_driver:
167 167
168 int (*save_state) (struct pci_dev *dev, u32 state); 168 int (*suspend) (struct pci_dev *dev, pm_message_t state);
169 int (*suspend) (struct pci_dev *dev, u32 state);
170 int (*resume) (struct pci_dev *dev); 169 int (*resume) (struct pci_dev *dev);
171 int (*enable_wake) (struct pci_dev *dev, u32 state, int enable); 170 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable);
172
173
174save_state
175----------
176
177Usage:
178
179if (dev->driver && dev->driver->save_state)
180 dev->driver->save_state(dev,state);
181
182The driver should use this callback to save device state. It should take into
183account the current state of the device and the requested state in order to
184avoid any unnecessary operations.
185
186For example, a video card that supports all 4 states (D0-D3), all controller
187context is preserved when entering D1, but the screen is placed into a low power
188state (blanked).
189
190The driver can also interpret this function as a notification that it may be
191entering a sleep state in the near future. If it knows that the device cannot
192enter the requested state, either because of lack of support for it, or because
193the device is middle of some critical operation, then it should fail.
194
195This function should not be used to set any state in the device or the driver
196because the device may not actually enter the sleep state (e.g. another driver
197later causes causes a global state transition to fail).
198
199Note that in intermediate low power states, a device's I/O and memory spaces may
200be disabled and may not be available in subsequent transitions to lower power
201states.
202 171
203 172
204suspend 173suspend
diff --git a/Documentation/s390/cds.txt b/Documentation/s390/cds.txt
index d9397170fb36..f0be389c7116 100644
--- a/Documentation/s390/cds.txt
+++ b/Documentation/s390/cds.txt
@@ -56,12 +56,16 @@ read_dev_chars()
56 read device characteristics 56 read device characteristics
57 57
58read_conf_data() 58read_conf_data()
59read_conf_data_lpm()
59 read configuration data. 60 read configuration data.
60 61
61ccw_device_get_ciw() 62ccw_device_get_ciw()
62 get commands from extended sense data. 63 get commands from extended sense data.
63 64
64ccw_device_start() 65ccw_device_start()
66ccw_device_start_timeout()
67ccw_device_start_key()
68ccw_device_start_key_timeout()
65 initiate an I/O request. 69 initiate an I/O request.
66 70
67ccw_device_resume() 71ccw_device_resume()
@@ -197,19 +201,21 @@ The read_dev_chars() function returns :
197 operational. 201 operational.
198 202
199 203
200read_conf_data() - Read Configuration Data 204read_conf_data(), read_conf_data_lpm() - Read Configuration Data
201 205
202Retrieve the device dependent configuration data. Please have a look at your 206Retrieve the device dependent configuration data. Please have a look at your
203device dependent I/O commands for the device specific layout of the node 207device dependent I/O commands for the device specific layout of the node
204descriptor elements. 208descriptor elements. read_conf_data_lpm() will retrieve the configuration data
209for a specific path.
205 210
206The function is meant to be called with an irq handler in place; that is, 211The function is meant to be called with the device already enabled; that is,
207at earliest during set_online() processing. 212at earliest during set_online() processing.
208 213
209The function may be called enabled or disabled, but the device must not be 214The function may be called enabled or disabled, but the device must not be
210locked 215locked
211 216
212int read_conf_data(struct ccw_device, void **buffer, int *length, __u8 lpm); 217int read_conf_data(struct ccw_device, void **buffer, int *length);
218int read_conf_data_lpm(struct ccw_device, void **buffer, int *length, __u8 lpm);
213 219
214cdev - the ccw_device the data is requested for. 220cdev - the ccw_device the data is requested for.
215buffer - Pointer to a buffer pointer. The read_conf_data() routine 221buffer - Pointer to a buffer pointer. The read_conf_data() routine
@@ -263,6 +269,25 @@ int ccw_device_start(struct ccw_device *cdev,
263 unsigned long intparm, 269 unsigned long intparm,
264 __u8 lpm, 270 __u8 lpm,
265 unsigned long flags); 271 unsigned long flags);
272int ccw_device_start_timeout(struct ccw_device *cdev,
273 struct ccw1 *cpa,
274 unsigned long intparm,
275 __u8 lpm,
276 unsigned long flags,
277 int expires);
278int ccw_device_start_key(struct ccw_device *cdev,
279 struct ccw1 *cpa,
280 unsigned long intparm,
281 __u8 lpm,
282 __u8 key,
283 unsigned long flags);
284int ccw_device_start_key_timeout(struct ccw_device *cdev,
285 struct ccw1 *cpa,
286 unsigned long intparm,
287 __u8 lpm,
288 __u8 key,
289 unsigned long flags,
290 int expires);
266 291
267cdev : ccw_device the I/O is destined for 292cdev : ccw_device the I/O is destined for
268cpa : logical start address of channel program 293cpa : logical start address of channel program
@@ -272,7 +297,12 @@ user_intparm : user specific interrupt information; will be presented
272 particular I/O request. 297 particular I/O request.
273lpm : defines the channel path to be used for a specific I/O 298lpm : defines the channel path to be used for a specific I/O
274 request. A value of 0 will make cio use the opm. 299 request. A value of 0 will make cio use the opm.
300key : the storage key to use for the I/O (useful for operating on a
301 storage with a storage key != default key)
275flag : defines the action to be performed for I/O processing 302flag : defines the action to be performed for I/O processing
303expires : timeout value in jiffies. The common I/O layer will terminate
304 the running program after this and call the interrupt handler
305 with ERR_PTR(-ETIMEDOUT) as irb.
276 306
277Possible flag values are : 307Possible flag values are :
278 308
@@ -327,6 +357,13 @@ current (last) I/O request. In case of a delayed status notification no special
327interrupt will be presented to indicate I/O completion as the I/O request was 357interrupt will be presented to indicate I/O completion as the I/O request was
328never started, even though ccw_device_start() returned with successful completion. 358never started, even though ccw_device_start() returned with successful completion.
329 359
360The irb may contain an error value, and the device driver should check for this
361first:
362
363-ETIMEDOUT: the common I/O layer terminated the request after the specified
364 timeout value
365-EIO: the common I/O layer terminated the request due to an error state
366
330If the concurrent sense flag in the extended status word in the irb is set, the 367If the concurrent sense flag in the extended status word in the irb is set, the
331field irb->scsw.count describes the numer of device specific sense bytes 368field irb->scsw.count describes the numer of device specific sense bytes
332available in the extended control word irb->scsw.ecw[0]. No device sensing by 369available in the extended control word irb->scsw.ecw[0]. No device sensing by
diff --git a/MAINTAINERS b/MAINTAINERS
index 4333b69e56bd..5b8483334de1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1699,7 +1699,9 @@ P: Pavel Roskin
1699M: proski@gnu.org 1699M: proski@gnu.org
1700P: David Gibson 1700P: David Gibson
1701M: hermes@gibson.dropbear.id.au 1701M: hermes@gibson.dropbear.id.au
1702W: http://www.ozlabs.org/people/dgibson/dldwd 1702L: orinoco-users@lists.sourceforge.net
1703L: orinoco-devel@lists.sourceforge.net
1704W: http://www.nongnu.org/orinoco/
1703S: Maintained 1705S: Maintained
1704 1706
1705PARALLEL PORT SUPPORT 1707PARALLEL PORT SUPPORT
@@ -2113,6 +2115,13 @@ M: perex@suse.cz
2113L: alsa-devel@alsa-project.org 2115L: alsa-devel@alsa-project.org
2114S: Maintained 2116S: Maintained
2115 2117
2118TPM DEVICE DRIVER
2119P: Kylene Hall
2120M: kjhall@us.ibm.com
2121W: http://tpmdd.sourceforge.net
2122L: tpmdd-devel@lists.sourceforge.net
2123S: Maintained
2124
2116UltraSPARC (sparc64): 2125UltraSPARC (sparc64):
2117P: David S. Miller 2126P: David S. Miller
2118M: davem@davemloft.net 2127M: davem@davemloft.net
diff --git a/Makefile b/Makefile
index 8da3a306d0c0..bddcb861b49b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 12 3SUBLEVEL = 12
4EXTRAVERSION =-rc3 4EXTRAVERSION =-rc4
5NAME=Woozy Numbat 5NAME=Woozy Numbat
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -332,9 +332,7 @@ KALLSYMS = scripts/kallsyms
332PERL = perl 332PERL = perl
333CHECK = sparse 333CHECK = sparse
334 334
335NOSTDINC_FLAGS = -nostdinc -isystem $(shell $(CC) -print-file-name=include)
336CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ 335CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__
337CHECKFLAGS += $(NOSTDINC_FLAGS)
338MODFLAGS = -DMODULE 336MODFLAGS = -DMODULE
339CFLAGS_MODULE = $(MODFLAGS) 337CFLAGS_MODULE = $(MODFLAGS)
340AFLAGS_MODULE = $(MODFLAGS) 338AFLAGS_MODULE = $(MODFLAGS)
@@ -531,6 +529,10 @@ endif
531 529
532include $(srctree)/arch/$(ARCH)/Makefile 530include $(srctree)/arch/$(ARCH)/Makefile
533 531
532# arch Makefile may override CC so keep this after arch Makefile is included
533NOSTDINC_FLAGS := -nostdinc -isystem $(shell $(CC) -print-file-name=include)
534CHECKFLAGS += $(NOSTDINC_FLAGS)
535
534# warn about C99 declaration after statement 536# warn about C99 declaration after statement
535CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) 537CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
536 538
@@ -1188,8 +1190,8 @@ cmd_TAGS = $(all-sources) | etags -
1188quiet_cmd_tags = MAKE $@ 1190quiet_cmd_tags = MAKE $@
1189define cmd_tags 1191define cmd_tags
1190 rm -f $@; \ 1192 rm -f $@; \
1191 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL"`; \ 1193 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL --extra=+f"`; \
1192 $(all-sources) | xargs ctags $$CTAGSF -a --extra=+f 1194 $(all-sources) | xargs ctags $$CTAGSF -a
1193endef 1195endef
1194 1196
1195TAGS: FORCE 1197TAGS: FORCE
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 0c79b9d95f74..f7c96635d3b4 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -280,6 +280,10 @@ config ISA
280 (MCA) or VESA. ISA is an older system, now being displaced by PCI; 280 (MCA) or VESA. ISA is an older system, now being displaced by PCI;
281 newer boards don't support it. If you have ISA, say Y, otherwise N. 281 newer boards don't support it. If you have ISA, say Y, otherwise N.
282 282
283config ISA_DMA_API
284 bool
285 default y
286
283config PCI 287config PCI
284 bool 288 bool
285 depends on !ALPHA_JENSEN 289 depends on !ALPHA_JENSEN
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index b5d0fd2bb10a..64e450dddb49 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -457,22 +457,6 @@ osf_getdomainname(char __user *name, int namelen)
457 return 0; 457 return 0;
458} 458}
459 459
460asmlinkage long
461osf_shmat(int shmid, void __user *shmaddr, int shmflg)
462{
463 unsigned long raddr;
464 long err;
465
466 err = do_shmat(shmid, shmaddr, shmflg, &raddr);
467
468 /*
469 * This works because all user-level addresses are
470 * non-negative longs!
471 */
472 return err ? err : (long)raddr;
473}
474
475
476/* 460/*
477 * The following stuff should move into a header file should it ever 461 * The following stuff should move into a header file should it ever
478 * be labeled "officially supported." Right now, there is just enough 462 * be labeled "officially supported." Right now, there is just enough
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index d00583161574..bbd37536d14e 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -14,6 +14,7 @@
14#include <linux/user.h> 14#include <linux/user.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/security.h> 16#include <linux/security.h>
17#include <linux/signal.h>
17 18
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
19#include <asm/pgtable.h> 20#include <asm/pgtable.h>
@@ -335,7 +336,7 @@ do_sys_ptrace(long request, long pid, long addr, long data,
335 /* continue and stop at next (return from) syscall */ 336 /* continue and stop at next (return from) syscall */
336 case PTRACE_CONT: /* restart after signal. */ 337 case PTRACE_CONT: /* restart after signal. */
337 ret = -EIO; 338 ret = -EIO;
338 if ((unsigned long) data > _NSIG) 339 if (!valid_signal(data))
339 break; 340 break;
340 if (request == PTRACE_SYSCALL) 341 if (request == PTRACE_SYSCALL)
341 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 342 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -365,7 +366,7 @@ do_sys_ptrace(long request, long pid, long addr, long data,
365 366
366 case PTRACE_SINGLESTEP: /* execute single instruction. */ 367 case PTRACE_SINGLESTEP: /* execute single instruction. */
367 ret = -EIO; 368 ret = -EIO;
368 if ((unsigned long) data > _NSIG) 369 if (!valid_signal(data))
369 break; 370 break;
370 /* Mark single stepping. */ 371 /* Mark single stepping. */
371 child->thread_info->bpt_nsaved = -1; 372 child->thread_info->bpt_nsaved = -1;
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index 3864b33562ee..052120882876 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -227,7 +227,7 @@ sys_call_table:
227 .quad sys_semop 227 .quad sys_semop
228 .quad osf_utsname 228 .quad osf_utsname
229 .quad sys_lchown 229 .quad sys_lchown
230 .quad osf_shmat 230 .quad sys_shmat
231 .quad sys_shmctl /* 210 */ 231 .quad sys_shmctl /* 210 */
232 .quad sys_shmdt 232 .quad sys_shmdt
233 .quad sys_shmget 233 .quad sys_shmget
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4055115ae0e2..bf397a9f8ac2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -85,6 +85,7 @@ choice
85config ARCH_CLPS7500 85config ARCH_CLPS7500
86 bool "Cirrus-CL-PS7500FE" 86 bool "Cirrus-CL-PS7500FE"
87 select TIMER_ACORN 87 select TIMER_ACORN
88 select ISA
88 89
89config ARCH_CLPS711X 90config ARCH_CLPS711X
90 bool "CLPS711x/EP721x-based" 91 bool "CLPS711x/EP721x-based"
@@ -96,6 +97,7 @@ config ARCH_CO285
96 97
97config ARCH_EBSA110 98config ARCH_EBSA110
98 bool "EBSA-110" 99 bool "EBSA-110"
100 select ISA
99 help 101 help
100 This is an evaluation board for the StrongARM processor available 102 This is an evaluation board for the StrongARM processor available
101 from Digital. It has limited hardware on-board, including an onboard 103 from Digital. It has limited hardware on-board, including an onboard
@@ -120,13 +122,16 @@ config ARCH_INTEGRATOR
120 122
121config ARCH_IOP3XX 123config ARCH_IOP3XX
122 bool "IOP3xx-based" 124 bool "IOP3xx-based"
125 select PCI
123 126
124config ARCH_IXP4XX 127config ARCH_IXP4XX
125 bool "IXP4xx-based" 128 bool "IXP4xx-based"
126 select DMABOUNCE 129 select DMABOUNCE
130 select PCI
127 131
128config ARCH_IXP2000 132config ARCH_IXP2000
129 bool "IXP2400/2800-based" 133 bool "IXP2400/2800-based"
134 select PCI
130 135
131config ARCH_L7200 136config ARCH_L7200
132 bool "LinkUp-L7200" 137 bool "LinkUp-L7200"
@@ -155,6 +160,8 @@ config ARCH_RPC
155 160
156config ARCH_SA1100 161config ARCH_SA1100
157 bool "SA1100-based" 162 bool "SA1100-based"
163 select ISA
164 select DISCONTIGMEM
158 165
159config ARCH_S3C2410 166config ARCH_S3C2410
160 bool "Samsung S3C2410" 167 bool "Samsung S3C2410"
@@ -165,6 +172,9 @@ config ARCH_S3C2410
165 172
166config ARCH_SHARK 173config ARCH_SHARK
167 bool "Shark" 174 bool "Shark"
175 select ISA
176 select ISA_DMA
177 select PCI
168 178
169config ARCH_LH7A40X 179config ARCH_LH7A40X
170 bool "Sharp LH7A40X" 180 bool "Sharp LH7A40X"
@@ -252,8 +262,6 @@ config ARM_AMBA
252 262
253config ISA 263config ISA
254 bool 264 bool
255 depends on FOOTBRIDGE_HOST || ARCH_SHARK || ARCH_CLPS7500 || ARCH_EBSA110 || ARCH_CDB89712 || ARCH_EDB7211 || ARCH_SA1100 || ARCH_MX1ADS
256 default y
257 help 265 help
258 Find out whether you have ISA slots on your motherboard. ISA is the 266 Find out whether you have ISA slots on your motherboard. ISA is the
259 name of a bus system, i.e. the way the CPU talks to the other stuff 267 name of a bus system, i.e. the way the CPU talks to the other stuff
@@ -263,12 +271,13 @@ config ISA
263 271
264config ISA_DMA 272config ISA_DMA
265 bool 273 bool
266 depends on FOOTBRIDGE_HOST || ARCH_SHARK 274
275config ISA_DMA_API
276 bool
267 default y 277 default y
268 278
269config PCI 279config PCI
270 bool "PCI support" if ARCH_INTEGRATOR_AP 280 bool "PCI support" if ARCH_INTEGRATOR_AP
271 default y if ARCH_SHARK || FOOTBRIDGE_HOST || ARCH_IOP3XX || ARCH_IXP4XX || ARCH_IXP2000
272 help 281 help
273 Find out whether you have a PCI motherboard. PCI is the name of a 282 Find out whether you have a PCI motherboard. PCI is the name of a
274 bus system, i.e. the way the CPU talks to the other stuff inside 283 bus system, i.e. the way the CPU talks to the other stuff inside
@@ -296,7 +305,7 @@ menu "Kernel Features"
296 305
297config SMP 306config SMP
298 bool "Symmetric Multi-Processing (EXPERIMENTAL)" 307 bool "Symmetric Multi-Processing (EXPERIMENTAL)"
299 depends on EXPERIMENTAL && n 308 depends on EXPERIMENTAL #&& n
300 help 309 help
301 This enables support for systems with more than one CPU. If you have 310 This enables support for systems with more than one CPU. If you have
302 a system with only one CPU, like most personal computers, say N. If 311 a system with only one CPU, like most personal computers, say N. If
@@ -336,8 +345,7 @@ config PREEMPT
336 345
337config DISCONTIGMEM 346config DISCONTIGMEM
338 bool 347 bool
339 depends on ARCH_EDB7211 || ARCH_SA1100 || (ARCH_LH7A40X && !LH7A40X_CONTIGMEM) 348 default (ARCH_LH7A40X && !LH7A40X_CONTIGMEM)
340 default y
341 help 349 help
342 Say Y to support efficient handling of discontiguous physical memory, 350 Say Y to support efficient handling of discontiguous physical memory,
343 for architectures which are either NUMA (Non-Uniform Memory Access) 351 for architectures which are either NUMA (Non-Uniform Memory Access)
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index c0e7aff3dec2..7c7f475e213e 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -18,48 +18,30 @@
18 * Please select one of the following when turning on debugging. 18 * Please select one of the following when turning on debugging.
19 */ 19 */
20#ifdef DEBUG 20#ifdef DEBUG
21#if defined(CONFIG_DEBUG_DC21285_PORT) 21
22 .macro loadsp, rb 22#include <asm/arch/debug-macro.S>
23 mov \rb, #0x42000000 23
24 .endm 24#if defined(CONFIG_DEBUG_ICEDCC)
25 .macro writeb, rb
26 str \rb, [r3, #0x160]
27 .endm
28#elif defined(CONFIG_DEBUG_ICEDCC)
29 .macro loadsp, rb 25 .macro loadsp, rb
30 .endm 26 .endm
31 .macro writeb, rb 27 .macro writeb, ch, rb
32 mcr p14, 0, \rb, c0, c1, 0 28 mcr p14, 0, \ch, c0, c1, 0
33 .endm
34#elif defined(CONFIG_FOOTBRIDGE)
35 .macro loadsp, rb
36 mov \rb, #0x7c000000
37 .endm 29 .endm
38 .macro writeb, rb 30#else
39 strb \rb, [r3, #0x3f8] 31 .macro writeb, ch, rb
32 senduart \ch, \rb
40 .endm 33 .endm
41#elif defined(CONFIG_ARCH_RPC) 34
35#if defined(CONFIG_FOOTBRIDGE) || \
36 defined(CONFIG_ARCH_RPC) || \
37 defined(CONFIG_ARCH_INTEGRATOR) || \
38 defined(CONFIG_ARCH_PXA) || \
39 defined(CONFIG_ARCH_IXP4XX) || \
40 defined(CONFIG_ARCH_IXP2000) || \
41 defined(CONFIG_ARCH_LH7A40X) || \
42 defined(CONFIG_ARCH_OMAP)
42 .macro loadsp, rb 43 .macro loadsp, rb
43 mov \rb, #0x03000000 44 addruart \rb
44 orr \rb, \rb, #0x00010000
45 .endm
46 .macro writeb, rb
47 strb \rb, [r3, #0x3f8 << 2]
48 .endm
49#elif defined(CONFIG_ARCH_INTEGRATOR)
50 .macro loadsp, rb
51 mov \rb, #0x16000000
52 .endm
53 .macro writeb, rb
54 strb \rb, [r3, #0]
55 .endm
56#elif defined(CONFIG_ARCH_PXA) /* Xscale-type */
57 .macro loadsp, rb
58 mov \rb, #0x40000000
59 orr \rb, \rb, #0x00100000
60 .endm
61 .macro writeb, rb
62 strb \rb, [r3, #0]
63 .endm 45 .endm
64#elif defined(CONFIG_ARCH_SA1100) 46#elif defined(CONFIG_ARCH_SA1100)
65 .macro loadsp, rb 47 .macro loadsp, rb
@@ -70,65 +52,22 @@
70 add \rb, \rb, #0x00010000 @ Ser1 52 add \rb, \rb, #0x00010000 @ Ser1
71# endif 53# endif
72 .endm 54 .endm
73 .macro writeb, rb
74 str \rb, [r3, #0x14] @ UTDR
75 .endm
76#elif defined(CONFIG_ARCH_IXP4XX)
77 .macro loadsp, rb
78 mov \rb, #0xc8000000
79 .endm
80 .macro writeb, rb
81 str \rb, [r3, #0]
82#elif defined(CONFIG_ARCH_IXP2000)
83 .macro loadsp, rb
84 mov \rb, #0xc0000000
85 orr \rb, \rb, #0x00030000
86 .endm
87 .macro writeb, rb
88 str \rb, [r3, #0]
89 .endm
90#elif defined(CONFIG_ARCH_LH7A40X)
91 .macro loadsp, rb
92 ldr \rb, =0x80000700 @ UART2 UARTBASE
93 .endm
94 .macro writeb, rb
95 strb \rb, [r3, #0]
96 .endm
97#elif defined(CONFIG_ARCH_OMAP)
98 .macro loadsp, rb
99 mov \rb, #0xff000000 @ physical base address
100 add \rb, \rb, #0x00fb0000
101#if defined(CONFIG_OMAP_LL_DEBUG_UART2) || defined(CONFIG_OMAP_LL_DEBUG_UART3)
102 add \rb, \rb, #0x00000800
103#endif
104#ifdef CONFIG_OMAP_LL_DEBUG_UART3
105 add \rb, \rb, #0x00009000
106#endif
107 .endm
108 .macro writeb, rb
109 strb \rb, [r3]
110 .endm
111#elif defined(CONFIG_ARCH_IOP331) 55#elif defined(CONFIG_ARCH_IOP331)
112 .macro loadsp, rb 56 .macro loadsp, rb
113 mov \rb, #0xff000000 57 mov \rb, #0xff000000
114 orr \rb, \rb, #0x00ff0000 58 orr \rb, \rb, #0x00ff0000
115 orr \rb, \rb, #0x0000f700 @ location of the UART 59 orr \rb, \rb, #0x0000f700 @ location of the UART
116 .endm 60 .endm
117 .macro writeb, rb
118 str \rb, [r3, #0]
119 .endm
120#elif defined(CONFIG_ARCH_S3C2410) 61#elif defined(CONFIG_ARCH_S3C2410)
121 .macro loadsp, rb 62 .macro loadsp, rb
122 mov \rb, #0x50000000 63 mov \rb, #0x50000000
123 add \rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT 64 add \rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT
124 .endm 65 .endm
125 .macro writeb, rb
126 strb \rb, [r3, #0x20]
127 .endm
128#else 66#else
129#error no serial architecture defined 67#error no serial architecture defined
130#endif 68#endif
131#endif 69#endif
70#endif
132 71
133 .macro kputc,val 72 .macro kputc,val
134 mov r0, \val 73 mov r0, \val
@@ -734,7 +673,7 @@ puts: loadsp r3
7341: ldrb r2, [r0], #1 6731: ldrb r2, [r0], #1
735 teq r2, #0 674 teq r2, #0
736 moveq pc, lr 675 moveq pc, lr
7372: writeb r2 6762: writeb r2, r3
738 mov r1, #0x00020000 677 mov r1, #0x00020000
7393: subs r1, r1, #1 6783: subs r1, r1, #1
740 bne 3b 679 bne 3b
diff --git a/arch/arm/common/rtctime.c b/arch/arm/common/rtctime.c
index c397e71f938d..72b03f201eb9 100644
--- a/arch/arm/common/rtctime.c
+++ b/arch/arm/common/rtctime.c
@@ -141,10 +141,10 @@ void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now, struct rtc
141 next->tm_sec = alrm->tm_sec; 141 next->tm_sec = alrm->tm_sec;
142} 142}
143 143
144static inline void rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm) 144static inline int rtc_read_time(struct rtc_ops *ops, struct rtc_time *tm)
145{ 145{
146 memset(tm, 0, sizeof(struct rtc_time)); 146 memset(tm, 0, sizeof(struct rtc_time));
147 ops->read_time(tm); 147 return ops->read_time(tm);
148} 148}
149 149
150static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm) 150static inline int rtc_set_time(struct rtc_ops *ops, struct rtc_time *tm)
@@ -163,8 +163,7 @@ static inline int rtc_read_alarm(struct rtc_ops *ops, struct rtc_wkalrm *alrm)
163 int ret = -EINVAL; 163 int ret = -EINVAL;
164 if (ops->read_alarm) { 164 if (ops->read_alarm) {
165 memset(alrm, 0, sizeof(struct rtc_wkalrm)); 165 memset(alrm, 0, sizeof(struct rtc_wkalrm));
166 ops->read_alarm(alrm); 166 ret = ops->read_alarm(alrm);
167 ret = 0;
168 } 167 }
169 return ret; 168 return ret;
170} 169}
@@ -283,7 +282,9 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
283 break; 282 break;
284 283
285 case RTC_RD_TIME: 284 case RTC_RD_TIME:
286 rtc_read_time(ops, &tm); 285 ret = rtc_read_time(ops, &tm);
286 if (ret)
287 break;
287 ret = copy_to_user(uarg, &tm, sizeof(tm)); 288 ret = copy_to_user(uarg, &tm, sizeof(tm));
288 if (ret) 289 if (ret)
289 ret = -EFAULT; 290 ret = -EFAULT;
@@ -424,15 +425,15 @@ static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eo
424 struct rtc_time tm; 425 struct rtc_time tm;
425 char *p = page; 426 char *p = page;
426 427
427 rtc_read_time(ops, &tm); 428 if (rtc_read_time(ops, &tm) == 0) {
428 429 p += sprintf(p,
429 p += sprintf(p, 430 "rtc_time\t: %02d:%02d:%02d\n"
430 "rtc_time\t: %02d:%02d:%02d\n" 431 "rtc_date\t: %04d-%02d-%02d\n"
431 "rtc_date\t: %04d-%02d-%02d\n" 432 "rtc_epoch\t: %04lu\n",
432 "rtc_epoch\t: %04lu\n", 433 tm.tm_hour, tm.tm_min, tm.tm_sec,
433 tm.tm_hour, tm.tm_min, tm.tm_sec, 434 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
434 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 435 rtc_epoch);
435 rtc_epoch); 436 }
436 437
437 if (rtc_read_alarm(ops, &alrm) == 0) { 438 if (rtc_read_alarm(ops, &alrm) == 0) {
438 p += sprintf(p, "alrm_time\t: "); 439 p += sprintf(p, "alrm_time\t: ");
diff --git a/arch/arm/configs/ixdp2800_defconfig b/arch/arm/configs/ixdp2800_defconfig
index d36f99192962..7be3521f91fc 100644
--- a/arch/arm/configs/ixdp2800_defconfig
+++ b/arch/arm/configs/ixdp2800_defconfig
@@ -133,7 +133,7 @@ CONFIG_ALIGNMENT_TRAP=y
133# 133#
134CONFIG_ZBOOT_ROM_TEXT=0x0 134CONFIG_ZBOOT_ROM_TEXT=0x0
135CONFIG_ZBOOT_ROM_BSS=0x0 135CONFIG_ZBOOT_ROM_BSS=0x0
136CONFIG_CMDLINE="console=ttyS0,9600 root=/dev/nfs ip=bootp mem=64M@0x0 pci=firmware" 136CONFIG_CMDLINE="console=ttyS0,9600 root=/dev/nfs ip=bootp mem=64M@0x0"
137# CONFIG_XIP_KERNEL is not set 137# CONFIG_XIP_KERNEL is not set
138 138
139# 139#
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 07a56ff61494..4a2af55e134b 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -31,8 +31,3 @@ head-y := head.o
31obj-$(CONFIG_DEBUG_LL) += debug.o 31obj-$(CONFIG_DEBUG_LL) += debug.o
32 32
33extra-y := $(head-y) init_task.o vmlinux.lds 33extra-y := $(head-y) init_task.o vmlinux.lds
34
35# Spell out some dependencies that aren't automatically figured out
36$(obj)/entry-armv.o: $(obj)/entry-header.S include/asm-arm/constants.h
37$(obj)/entry-common.o: $(obj)/entry-header.S include/asm-arm/constants.h \
38 $(obj)/calls.S
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 99d43259ff89..c1ff4d1f1bfd 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -64,6 +64,26 @@ int main(void)
64 DEFINE(TI_VFPSTATE, offsetof(struct thread_info, vfpstate)); 64 DEFINE(TI_VFPSTATE, offsetof(struct thread_info, vfpstate));
65 DEFINE(TI_IWMMXT_STATE, (offsetof(struct thread_info, fpstate)+4)&~7); 65 DEFINE(TI_IWMMXT_STATE, (offsetof(struct thread_info, fpstate)+4)&~7);
66 BLANK(); 66 BLANK();
67 DEFINE(S_R0, offsetof(struct pt_regs, ARM_r0));
68 DEFINE(S_R1, offsetof(struct pt_regs, ARM_r1));
69 DEFINE(S_R2, offsetof(struct pt_regs, ARM_r2));
70 DEFINE(S_R3, offsetof(struct pt_regs, ARM_r3));
71 DEFINE(S_R4, offsetof(struct pt_regs, ARM_r4));
72 DEFINE(S_R5, offsetof(struct pt_regs, ARM_r5));
73 DEFINE(S_R6, offsetof(struct pt_regs, ARM_r6));
74 DEFINE(S_R7, offsetof(struct pt_regs, ARM_r7));
75 DEFINE(S_R8, offsetof(struct pt_regs, ARM_r8));
76 DEFINE(S_R9, offsetof(struct pt_regs, ARM_r9));
77 DEFINE(S_R10, offsetof(struct pt_regs, ARM_r10));
78 DEFINE(S_FP, offsetof(struct pt_regs, ARM_fp));
79 DEFINE(S_IP, offsetof(struct pt_regs, ARM_ip));
80 DEFINE(S_SP, offsetof(struct pt_regs, ARM_sp));
81 DEFINE(S_LR, offsetof(struct pt_regs, ARM_lr));
82 DEFINE(S_PC, offsetof(struct pt_regs, ARM_pc));
83 DEFINE(S_PSR, offsetof(struct pt_regs, ARM_cpsr));
84 DEFINE(S_OLD_R0, offsetof(struct pt_regs, ARM_ORIG_r0));
85 DEFINE(S_FRAME_SIZE, sizeof(struct pt_regs));
86 BLANK();
67#if __LINUX_ARM_ARCH__ >= 6 87#if __LINUX_ARM_ARCH__ >= 6
68 DEFINE(MM_CONTEXT_ID, offsetof(struct mm_struct, context.id)); 88 DEFINE(MM_CONTEXT_ID, offsetof(struct mm_struct, context.id));
69 BLANK(); 89 BLANK();
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index bb27c317d94b..4eb36155dc93 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -14,12 +14,12 @@
14 * it to save wrong values... Be aware! 14 * it to save wrong values... Be aware!
15 */ 15 */
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/init.h>
18 17
19#include <asm/thread_info.h>
20#include <asm/glue.h> 18#include <asm/glue.h>
21#include <asm/ptrace.h>
22#include <asm/vfpmacros.h> 19#include <asm/vfpmacros.h>
20#include <asm/hardware.h> /* should be moved into entry-macro.S */
21#include <asm/arch/irqs.h> /* should be moved into entry-macro.S */
22#include <asm/arch/entry-macro.S>
23 23
24#include "entry-header.S" 24#include "entry-header.S"
25 25
@@ -118,7 +118,7 @@ __dabt_svc:
118 @ 118 @
119 @ IRQs off again before pulling preserved data off the stack 119 @ IRQs off again before pulling preserved data off the stack
120 @ 120 @
121 disable_irq r0 121 disable_irq
122 122
123 @ 123 @
124 @ restore SPSR and restart the instruction 124 @ restore SPSR and restart the instruction
@@ -198,7 +198,7 @@ __und_svc:
198 @ 198 @
199 @ IRQs off again before pulling preserved data off the stack 199 @ IRQs off again before pulling preserved data off the stack
200 @ 200 @
2011: disable_irq r0 2011: disable_irq
202 202
203 @ 203 @
204 @ restore SPSR and restart the instruction 204 @ restore SPSR and restart the instruction
@@ -232,7 +232,7 @@ __pabt_svc:
232 @ 232 @
233 @ IRQs off again before pulling preserved data off the stack 233 @ IRQs off again before pulling preserved data off the stack
234 @ 234 @
235 disable_irq r0 235 disable_irq
236 236
237 @ 237 @
238 @ restore SPSR and restart the instruction 238 @ restore SPSR and restart the instruction
@@ -269,6 +269,12 @@ __pabt_svc:
269 add r5, sp, #S_PC 269 add r5, sp, #S_PC
270 ldmia r7, {r2 - r4} @ Get USR pc, cpsr 270 ldmia r7, {r2 - r4} @ Get USR pc, cpsr
271 271
272#if __LINUX_ARM_ARCH__ < 6
273 @ make sure our user space atomic helper is aborted
274 cmp r2, #VIRT_OFFSET
275 bichs r3, r3, #PSR_Z_BIT
276#endif
277
272 @ 278 @
273 @ We are now ready to fill in the remaining blanks on the stack: 279 @ We are now ready to fill in the remaining blanks on the stack:
274 @ 280 @
@@ -316,7 +322,7 @@ __dabt_usr:
316 @ 322 @
317 @ IRQs on, then call the main handler 323 @ IRQs on, then call the main handler
318 @ 324 @
319 enable_irq r2 325 enable_irq
320 mov r2, sp 326 mov r2, sp
321 adr lr, ret_from_exception 327 adr lr, ret_from_exception
322 b do_DataAbort 328 b do_DataAbort
@@ -418,7 +424,7 @@ call_fpe:
418 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1) 424 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
419 bcs iwmmxt_task_enable 425 bcs iwmmxt_task_enable
420#endif 426#endif
421 enable_irq r7 427 enable_irq
422 add pc, pc, r8, lsr #6 428 add pc, pc, r8, lsr #6
423 mov r0, r0 429 mov r0, r0
424 430
@@ -472,7 +478,7 @@ fpundefinstr:
472__pabt_usr: 478__pabt_usr:
473 usr_entry abt 479 usr_entry abt
474 480
475 enable_irq r0 @ Enable interrupts 481 enable_irq @ Enable interrupts
476 mov r0, r2 @ address (pc) 482 mov r0, r2 @ address (pc)
477 mov r1, sp @ regs 483 mov r1, sp @ regs
478 bl do_PrefetchAbort @ call abort handler 484 bl do_PrefetchAbort @ call abort handler
@@ -499,8 +505,12 @@ ENTRY(__switch_to)
499 mra r4, r5, acc0 505 mra r4, r5, acc0
500 stmia ip, {r4, r5} 506 stmia ip, {r4, r5}
501#endif 507#endif
508#if defined(CONFIG_HAS_TLS_REG)
509 mcr p15, 0, r3, c13, c0, 3 @ set TLS register
510#elif !defined(CONFIG_TLS_REG_EMUL)
502 mov r4, #0xffff0fff 511 mov r4, #0xffff0fff
503 str r3, [r4, #-3] @ Set TLS ptr 512 str r3, [r4, #-15] @ TLS val at 0xffff0ff0
513#endif
504 mcr p15, 0, r6, c3, c0, 0 @ Set domain register 514 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
505#ifdef CONFIG_VFP 515#ifdef CONFIG_VFP
506 @ Always disable VFP so we can lazily save/restore the old 516 @ Always disable VFP so we can lazily save/restore the old
@@ -519,11 +529,209 @@ ENTRY(__switch_to)
519 ldmib r2, {r4 - sl, fp, sp, pc} @ Load all regs saved previously 529 ldmib r2, {r4 - sl, fp, sp, pc} @ Load all regs saved previously
520 530
521 __INIT 531 __INIT
532
533/*
534 * User helpers.
535 *
536 * These are segment of kernel provided user code reachable from user space
537 * at a fixed address in kernel memory. This is used to provide user space
538 * with some operations which require kernel help because of unimplemented
539 * native feature and/or instructions in many ARM CPUs. The idea is for
540 * this code to be executed directly in user mode for best efficiency but
541 * which is too intimate with the kernel counter part to be left to user
542 * libraries. In fact this code might even differ from one CPU to another
543 * depending on the available instruction set and restrictions like on
544 * SMP systems. In other words, the kernel reserves the right to change
545 * this code as needed without warning. Only the entry points and their
546 * results are guaranteed to be stable.
547 *
548 * Each segment is 32-byte aligned and will be moved to the top of the high
549 * vector page. New segments (if ever needed) must be added in front of
550 * existing ones. This mechanism should be used only for things that are
551 * really small and justified, and not be abused freely.
552 *
553 * User space is expected to implement those things inline when optimizing
554 * for a processor that has the necessary native support, but only if such
555 * resulting binaries are already to be incompatible with earlier ARM
556 * processors due to the use of unsupported instructions other than what
557 * is provided here. In other words don't make binaries unable to run on
558 * earlier processors just for the sake of not using these kernel helpers
559 * if your compiled code is not going to use the new instructions for other
560 * purpose.
561 */
562
563 .align 5
564 .globl __kuser_helper_start
565__kuser_helper_start:
566
567/*
568 * Reference prototype:
569 *
570 * int __kernel_cmpxchg(int oldval, int newval, int *ptr)
571 *
572 * Input:
573 *
574 * r0 = oldval
575 * r1 = newval
576 * r2 = ptr
577 * lr = return address
578 *
579 * Output:
580 *
581 * r0 = returned value (zero or non-zero)
582 * C flag = set if r0 == 0, clear if r0 != 0
583 *
584 * Clobbered:
585 *
586 * r3, ip, flags
587 *
588 * Definition and user space usage example:
589 *
590 * typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
591 * #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
592 *
593 * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
594 * Return zero if *ptr was changed or non-zero if no exchange happened.
595 * The C flag is also set if *ptr was changed to allow for assembly
596 * optimization in the calling code.
597 *
598 * For example, a user space atomic_add implementation could look like this:
599 *
600 * #define atomic_add(ptr, val) \
601 * ({ register unsigned int *__ptr asm("r2") = (ptr); \
602 * register unsigned int __result asm("r1"); \
603 * asm volatile ( \
604 * "1: @ atomic_add\n\t" \
605 * "ldr r0, [r2]\n\t" \
606 * "mov r3, #0xffff0fff\n\t" \
607 * "add lr, pc, #4\n\t" \
608 * "add r1, r0, %2\n\t" \
609 * "add pc, r3, #(0xffff0fc0 - 0xffff0fff)\n\t" \
610 * "bcc 1b" \
611 * : "=&r" (__result) \
612 * : "r" (__ptr), "rIL" (val) \
613 * : "r0","r3","ip","lr","cc","memory" ); \
614 * __result; })
615 */
616
617__kuser_cmpxchg: @ 0xffff0fc0
618
619#if __LINUX_ARM_ARCH__ < 6
620
621#ifdef CONFIG_SMP /* sanity check */
622#error "CONFIG_SMP on a machine supporting pre-ARMv6 processors?"
623#endif
624
625 /*
626 * Theory of operation:
627 *
628 * We set the Z flag before loading oldval. If ever an exception
629 * occurs we can not be sure the loaded value will still be the same
630 * when the exception returns, therefore the user exception handler
631 * will clear the Z flag whenever the interrupted user code was
632 * actually from the kernel address space (see the usr_entry macro).
633 *
634 * The post-increment on the str is used to prevent a race with an
635 * exception happening just after the str instruction which would
636 * clear the Z flag although the exchange was done.
637 */
638 teq ip, ip @ set Z flag
639 ldr ip, [r2] @ load current val
640 add r3, r2, #1 @ prepare store ptr
641 teqeq ip, r0 @ compare with oldval if still allowed
642 streq r1, [r3, #-1]! @ store newval if still allowed
643 subs r0, r2, r3 @ if r2 == r3 the str occured
644 mov pc, lr
645
646#else
647
648 ldrex r3, [r2]
649 subs r3, r3, r0
650 strexeq r3, r1, [r2]
651 rsbs r0, r3, #0
652 mov pc, lr
653
654#endif
655
656 .align 5
657
658/*
659 * Reference prototype:
660 *
661 * int __kernel_get_tls(void)
662 *
663 * Input:
664 *
665 * lr = return address
666 *
667 * Output:
668 *
669 * r0 = TLS value
670 *
671 * Clobbered:
672 *
673 * the Z flag might be lost
674 *
675 * Definition and user space usage example:
676 *
677 * typedef int (__kernel_get_tls_t)(void);
678 * #define __kernel_get_tls (*(__kernel_get_tls_t *)0xffff0fe0)
679 *
680 * Get the TLS value as previously set via the __ARM_NR_set_tls syscall.
681 *
682 * This could be used as follows:
683 *
684 * #define __kernel_get_tls() \
685 * ({ register unsigned int __val asm("r0"); \
686 * asm( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #31" \
687 * : "=r" (__val) : : "lr","cc" ); \
688 * __val; })
689 */
690
691__kuser_get_tls: @ 0xffff0fe0
692
693#if !defined(CONFIG_HAS_TLS_REG) && !defined(CONFIG_TLS_REG_EMUL)
694
695 ldr r0, [pc, #(16 - 8)] @ TLS stored at 0xffff0ff0
696 mov pc, lr
697
698#else
699
700 mrc p15, 0, r0, c13, c0, 3 @ read TLS register
701 mov pc, lr
702
703#endif
704
705 .rep 5
706 .word 0 @ pad up to __kuser_helper_version
707 .endr
708
709/*
710 * Reference declaration:
711 *
712 * extern unsigned int __kernel_helper_version;
713 *
714 * Definition and user space usage example:
715 *
716 * #define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
717 *
718 * User space may read this to determine the curent number of helpers
719 * available.
720 */
721
722__kuser_helper_version: @ 0xffff0ffc
723 .word ((__kuser_helper_end - __kuser_helper_start) >> 5)
724
725 .globl __kuser_helper_end
726__kuser_helper_end:
727
728
522/* 729/*
523 * Vector stubs. 730 * Vector stubs.
524 * 731 *
525 * This code is copied to 0x200 or 0xffff0200 so we can use branches in the 732 * This code is copied to 0xffff0200 so we can use branches in the
526 * vectors, rather than ldr's. 733 * vectors, rather than ldr's. Note that this code must not
734 * exceed 0x300 bytes.
527 * 735 *
528 * Common stub entry macro: 736 * Common stub entry macro:
529 * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC 737 * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
@@ -544,7 +752,7 @@ vector_\name:
544 @ 752 @
545 mrs r13, cpsr 753 mrs r13, cpsr
546 bic r13, r13, #MODE_MASK 754 bic r13, r13, #MODE_MASK
547 orr r13, r13, #MODE_SVC 755 orr r13, r13, #SVC_MODE
548 msr spsr_cxsf, r13 @ switch to SVC_32 mode 756 msr spsr_cxsf, r13 @ switch to SVC_32 mode
549 757
550 and lr, lr, #15 758 and lr, lr, #15
@@ -552,6 +760,7 @@ vector_\name:
552 movs pc, lr @ Changes mode and branches 760 movs pc, lr @ Changes mode and branches
553 .endm 761 .endm
554 762
763 .globl __stubs_start
555__stubs_start: 764__stubs_start:
556/* 765/*
557 * Interrupt dispatcher 766 * Interrupt dispatcher
@@ -686,37 +895,24 @@ vector_addrexcptn:
686.LCsabt: 895.LCsabt:
687 .word __temp_abt 896 .word __temp_abt
688 897
898 .globl __stubs_end
689__stubs_end: 899__stubs_end:
690 900
691 .equ __real_stubs_start, .LCvectors + 0x200 901 .equ stubs_offset, __vectors_start + 0x200 - __stubs_start
692 902
693.LCvectors: 903 .globl __vectors_start
904__vectors_start:
694 swi SYS_ERROR0 905 swi SYS_ERROR0
695 b __real_stubs_start + (vector_und - __stubs_start) 906 b vector_und + stubs_offset
696 ldr pc, __real_stubs_start + (.LCvswi - __stubs_start) 907 ldr pc, .LCvswi + stubs_offset
697 b __real_stubs_start + (vector_pabt - __stubs_start) 908 b vector_pabt + stubs_offset
698 b __real_stubs_start + (vector_dabt - __stubs_start) 909 b vector_dabt + stubs_offset
699 b __real_stubs_start + (vector_addrexcptn - __stubs_start) 910 b vector_addrexcptn + stubs_offset
700 b __real_stubs_start + (vector_irq - __stubs_start) 911 b vector_irq + stubs_offset
701 b __real_stubs_start + (vector_fiq - __stubs_start) 912 b vector_fiq + stubs_offset
702 913
703ENTRY(__trap_init) 914 .globl __vectors_end
704 stmfd sp!, {r4 - r6, lr} 915__vectors_end:
705
706 mov r0, #0xff000000
707 orr r0, r0, #0x00ff0000 @ high vectors position
708 adr r1, .LCvectors @ set up the vectors
709 ldmia r1, {r1, r2, r3, r4, r5, r6, ip, lr}
710 stmia r0, {r1, r2, r3, r4, r5, r6, ip, lr}
711
712 add r2, r0, #0x200
713 adr r0, __stubs_start @ copy stubs to 0x200
714 adr r1, __stubs_end
7151: ldr r3, [r0], #4
716 str r3, [r2], #4
717 cmp r0, r1
718 blt 1b
719 LOADREGS(fd, sp!, {r4 - r6, pc})
720 916
721 .data 917 .data
722 918
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 53a7e0dea44d..3f8d0e3aefab 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -9,19 +9,10 @@
9 */ 9 */
10#include <linux/config.h> 10#include <linux/config.h>
11 11
12#include <asm/thread_info.h>
13#include <asm/ptrace.h>
14#include <asm/unistd.h> 12#include <asm/unistd.h>
15 13
16#include "entry-header.S" 14#include "entry-header.S"
17 15
18/*
19 * We rely on the fact that R0 is at the bottom of the stack (due to
20 * slow/fast restore user regs).
21 */
22#if S_R0 != 0
23#error "Please fix"
24#endif
25 16
26 .align 5 17 .align 5
27/* 18/*
@@ -30,11 +21,19 @@
30 * stack. 21 * stack.
31 */ 22 */
32ret_fast_syscall: 23ret_fast_syscall:
33 disable_irq r1 @ disable interrupts 24 disable_irq @ disable interrupts
34 ldr r1, [tsk, #TI_FLAGS] 25 ldr r1, [tsk, #TI_FLAGS]
35 tst r1, #_TIF_WORK_MASK 26 tst r1, #_TIF_WORK_MASK
36 bne fast_work_pending 27 bne fast_work_pending
37 fast_restore_user_regs 28
29 @ fast_restore_user_regs
30 ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr
31 ldr lr, [sp, #S_OFF + S_PC]! @ get pc
32 msr spsr_cxsf, r1 @ save in spsr_svc
33 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
34 mov r0, r0
35 add sp, sp, #S_FRAME_SIZE - S_PC
36 movs pc, lr @ return & move spsr_svc into cpsr
38 37
39/* 38/*
40 * Ok, we need to do extra processing, enter the slow path. 39 * Ok, we need to do extra processing, enter the slow path.
@@ -49,7 +48,7 @@ work_pending:
49 mov r0, sp @ 'regs' 48 mov r0, sp @ 'regs'
50 mov r2, why @ 'syscall' 49 mov r2, why @ 'syscall'
51 bl do_notify_resume 50 bl do_notify_resume
52 disable_irq r1 @ disable interrupts 51 disable_irq @ disable interrupts
53 b no_work_pending 52 b no_work_pending
54 53
55work_resched: 54work_resched:
@@ -59,12 +58,19 @@ work_resched:
59 */ 58 */
60ENTRY(ret_to_user) 59ENTRY(ret_to_user)
61ret_slow_syscall: 60ret_slow_syscall:
62 disable_irq r1 @ disable interrupts 61 disable_irq @ disable interrupts
63 ldr r1, [tsk, #TI_FLAGS] 62 ldr r1, [tsk, #TI_FLAGS]
64 tst r1, #_TIF_WORK_MASK 63 tst r1, #_TIF_WORK_MASK
65 bne work_pending 64 bne work_pending
66no_work_pending: 65no_work_pending:
67 slow_restore_user_regs 66 @ slow_restore_user_regs
67 ldr r1, [sp, #S_PSR] @ get calling cpsr
68 ldr lr, [sp, #S_PC]! @ get pc
69 msr spsr_cxsf, r1 @ save in spsr_svc
70 ldmdb sp, {r0 - lr}^ @ get calling r1 - lr
71 mov r0, r0
72 add sp, sp, #S_FRAME_SIZE - S_PC
73 movs pc, lr @ return & move spsr_svc into cpsr
68 74
69/* 75/*
70 * This is how we return from a fork. 76 * This is how we return from a fork.
@@ -116,9 +122,26 @@ ENTRY(ret_from_fork)
116 122
117 .align 5 123 .align 5
118ENTRY(vector_swi) 124ENTRY(vector_swi)
119 save_user_regs 125 sub sp, sp, #S_FRAME_SIZE
126 stmia sp, {r0 - r12} @ Calling r0 - r12
127 add r8, sp, #S_PC
128 stmdb r8, {sp, lr}^ @ Calling sp, lr
129 mrs r8, spsr @ called from non-FIQ mode, so ok.
130 str lr, [sp, #S_PC] @ Save calling PC
131 str r8, [sp, #S_PSR] @ Save CPSR
132 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
120 zero_fp 133 zero_fp
121 get_scno 134
135 /*
136 * Get the system call number.
137 */
138#ifdef CONFIG_ARM_THUMB
139 tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs
140 addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in
141 ldreq scno, [lr, #-4]
142#else
143 ldr scno, [lr, #-4] @ get SWI instruction
144#endif
122 arm710_bug_check scno, ip 145 arm710_bug_check scno, ip
123 146
124#ifdef CONFIG_ALIGNMENT_TRAP 147#ifdef CONFIG_ALIGNMENT_TRAP
@@ -126,14 +149,14 @@ ENTRY(vector_swi)
126 ldr ip, [ip] 149 ldr ip, [ip]
127 mcr p15, 0, ip, c1, c0 @ update control register 150 mcr p15, 0, ip, c1, c0 @ update control register
128#endif 151#endif
129 enable_irq ip 152 enable_irq
130 153
131 str r4, [sp, #-S_OFF]! @ push fifth arg 154 str r4, [sp, #-S_OFF]! @ push fifth arg
132 155
133 get_thread_info tsk 156 get_thread_info tsk
134 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing 157 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
135 bic scno, scno, #0xff000000 @ mask off SWI op-code 158 bic scno, scno, #0xff000000 @ mask off SWI op-code
136 eor scno, scno, #OS_NUMBER << 20 @ check OS number 159 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
137 adr tbl, sys_call_table @ load syscall table pointer 160 adr tbl, sys_call_table @ load syscall table pointer
138 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 161 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
139 bne __sys_trace 162 bne __sys_trace
@@ -144,8 +167,8 @@ ENTRY(vector_swi)
144 167
145 add r1, sp, #S_OFF 168 add r1, sp, #S_OFF
1462: mov why, #0 @ no longer a real syscall 1692: mov why, #0 @ no longer a real syscall
147 cmp scno, #ARMSWI_OFFSET 170 cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
148 eor r0, scno, #OS_NUMBER << 20 @ put OS number back 171 eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back
149 bcs arm_syscall 172 bcs arm_syscall
150 b sys_ni_syscall @ not private func 173 b sys_ni_syscall @ not private func
151 174
@@ -190,7 +213,7 @@ ENTRY(sys_call_table)
190@ r5 = syscall table 213@ r5 = syscall table
191 .type sys_syscall, #function 214 .type sys_syscall, #function
192sys_syscall: 215sys_syscall:
193 eor scno, r0, #OS_NUMBER << 20 216 eor scno, r0, #__NR_SYSCALL_BASE
194 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE 217 cmp scno, #__NR_syscall - __NR_SYSCALL_BASE
195 cmpne scno, #NR_syscalls @ check range 218 cmpne scno, #NR_syscalls @ check range
196 stmloia sp, {r5, r6} @ shuffle args 219 stmloia sp, {r5, r6} @ shuffle args
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index 4039d8c120b5..a3d40a0e2b04 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -1,24 +1,11 @@
1#include <linux/config.h> /* for CONFIG_ARCH_xxxx */ 1#include <linux/config.h>
2#include <linux/init.h>
2#include <linux/linkage.h> 3#include <linux/linkage.h>
3 4
4#include <asm/assembler.h> 5#include <asm/assembler.h>
5#include <asm/constants.h> 6#include <asm/constants.h>
6#include <asm/errno.h> 7#include <asm/errno.h>
7#include <asm/hardware.h> 8#include <asm/thread_info.h>
8#include <asm/arch/irqs.h>
9#include <asm/arch/entry-macro.S>
10
11#ifndef MODE_SVC
12#define MODE_SVC 0x13
13#endif
14
15 .macro zero_fp
16#ifdef CONFIG_FRAME_POINTER
17 mov fp, #0
18#endif
19 .endm
20
21 .text
22 9
23@ Bad Abort numbers 10@ Bad Abort numbers
24@ ----------------- 11@ -----------------
@@ -29,113 +16,44 @@
29#define BAD_IRQ 3 16#define BAD_IRQ 3
30#define BAD_UNDEFINSTR 4 17#define BAD_UNDEFINSTR 4
31 18
32#define PT_TRACESYS 0x00000002
33
34@ OS version number used in SWIs
35@ RISC OS is 0
36@ RISC iX is 8
37@ 19@
38#define OS_NUMBER 9 20@ Most of the stack format comes from struct pt_regs, but with
39#define ARMSWI_OFFSET 0x000f0000 21@ the addition of 8 bytes for storing syscall args 5 and 6.
40
41@ 22@
42@ Stack format (ensured by USER_* and SVC_*)
43@
44#define S_FRAME_SIZE 72
45#define S_OLD_R0 68
46#define S_PSR 64
47
48#define S_PC 60
49#define S_LR 56
50#define S_SP 52
51#define S_IP 48
52#define S_FP 44
53#define S_R10 40
54#define S_R9 36
55#define S_R8 32
56#define S_R7 28
57#define S_R6 24
58#define S_R5 20
59#define S_R4 16
60#define S_R3 12
61#define S_R2 8
62#define S_R1 4
63#define S_R0 0
64#define S_OFF 8 23#define S_OFF 8
65 24
66 .macro set_cpsr_c, reg, mode 25/*
67 msr cpsr_c, \mode 26 * The SWI code relies on the fact that R0 is at the bottom of the stack
27 * (due to slow/fast restore user regs).
28 */
29#if S_R0 != 0
30#error "Please fix"
31#endif
32
33 .macro zero_fp
34#ifdef CONFIG_FRAME_POINTER
35 mov fp, #0
36#endif
68 .endm 37 .endm
69 38
70#if __LINUX_ARM_ARCH__ >= 6 39#if __LINUX_ARM_ARCH__ >= 6
71 .macro disable_irq, temp 40 .macro disable_irq
72 cpsid i 41 cpsid i
73 .endm 42 .endm
74 43
75 .macro enable_irq, temp 44 .macro enable_irq
76 cpsie i 45 cpsie i
77 .endm 46 .endm
78#else 47#else
79 .macro disable_irq, temp 48 .macro disable_irq
80 set_cpsr_c \temp, #PSR_I_BIT | MODE_SVC 49 msr cpsr_c, #PSR_I_BIT | SVC_MODE
81 .endm 50 .endm
82 51
83 .macro enable_irq, temp 52 .macro enable_irq
84 set_cpsr_c \temp, #MODE_SVC 53 msr cpsr_c, #SVC_MODE
85 .endm 54 .endm
86#endif 55#endif
87 56
88 .macro save_user_regs
89 sub sp, sp, #S_FRAME_SIZE
90 stmia sp, {r0 - r12} @ Calling r0 - r12
91 add r8, sp, #S_PC
92 stmdb r8, {sp, lr}^ @ Calling sp, lr
93 mrs r8, spsr @ called from non-FIQ mode, so ok.
94 str lr, [sp, #S_PC] @ Save calling PC
95 str r8, [sp, #S_PSR] @ Save CPSR
96 str r0, [sp, #S_OLD_R0] @ Save OLD_R0
97 .endm
98
99 .macro restore_user_regs
100 ldr r1, [sp, #S_PSR] @ Get calling cpsr
101 disable_irq ip @ disable IRQs
102 ldr lr, [sp, #S_PC]! @ Get PC
103 msr spsr_cxsf, r1 @ save in spsr_svc
104 ldmdb sp, {r0 - lr}^ @ Get calling r0 - lr
105 mov r0, r0
106 add sp, sp, #S_FRAME_SIZE - S_PC
107 movs pc, lr @ return & move spsr_svc into cpsr
108 .endm
109
110/*
111 * Must be called with IRQs already disabled.
112 */
113 .macro fast_restore_user_regs
114 ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr
115 ldr lr, [sp, #S_OFF + S_PC]! @ get pc
116 msr spsr_cxsf, r1 @ save in spsr_svc
117 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
118 mov r0, r0
119 add sp, sp, #S_FRAME_SIZE - S_PC
120 movs pc, lr @ return & move spsr_svc into cpsr
121 .endm
122
123/*
124 * Must be called with IRQs already disabled.
125 */
126 .macro slow_restore_user_regs
127 ldr r1, [sp, #S_PSR] @ get calling cpsr
128 ldr lr, [sp, #S_PC]! @ get pc
129 msr spsr_cxsf, r1 @ save in spsr_svc
130 ldmdb sp, {r0 - lr}^ @ get calling r1 - lr
131 mov r0, r0
132 add sp, sp, #S_FRAME_SIZE - S_PC
133 movs pc, lr @ return & move spsr_svc into cpsr
134 .endm
135
136 .macro mask_pc, rd, rm
137 .endm
138
139 .macro get_thread_info, rd 57 .macro get_thread_info, rd
140 mov \rd, sp, lsr #13 58 mov \rd, sp, lsr #13
141 mov \rd, \rd, lsl #13 59 mov \rd, \rd, lsl #13
@@ -165,18 +83,3 @@ scno .req r7 @ syscall number
165tbl .req r8 @ syscall table pointer 83tbl .req r8 @ syscall table pointer
166why .req r8 @ Linux syscall (!= 0) 84why .req r8 @ Linux syscall (!= 0)
167tsk .req r9 @ current thread_info 85tsk .req r9 @ current thread_info
168
169/*
170 * Get the system call number.
171 */
172 .macro get_scno
173#ifdef CONFIG_ARM_THUMB
174 tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs
175 addne scno, r7, #OS_NUMBER << 20 @ put OS number in
176 ldreq scno, [lr, #-4]
177
178#else
179 mask_pc lr, lr
180 ldr scno, [lr, #-4] @ get SWI instruction
181#endif
182 .endm
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 171b3e811c71..4733877296d4 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -19,6 +19,7 @@
19#include <asm/procinfo.h> 19#include <asm/procinfo.h>
20#include <asm/ptrace.h> 20#include <asm/ptrace.h>
21#include <asm/constants.h> 21#include <asm/constants.h>
22#include <asm/thread_info.h>
22#include <asm/system.h> 23#include <asm/system.h>
23 24
24#define PROCINFO_MMUFLAGS 8 25#define PROCINFO_MMUFLAGS 8
@@ -131,7 +132,7 @@ __switch_data:
131 .long processor_id @ r4 132 .long processor_id @ r4
132 .long __machine_arch_type @ r5 133 .long __machine_arch_type @ r5
133 .long cr_alignment @ r6 134 .long cr_alignment @ r6
134 .long init_thread_union+8192 @ sp 135 .long init_thread_union + THREAD_START_SP @ sp
135 136
136/* 137/*
137 * The following fragment of code is executed with the MMU on, and uses 138 * The following fragment of code is executed with the MMU on, and uses
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 26eacd3e5def..8f146a4b4752 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -256,8 +256,6 @@ static unsigned long *thread_info_head;
256static unsigned int nr_thread_info; 256static unsigned int nr_thread_info;
257 257
258#define EXTRA_TASK_STRUCT 4 258#define EXTRA_TASK_STRUCT 4
259#define ll_alloc_task_struct() ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
260#define ll_free_task_struct(p) free_pages((unsigned long)(p),1)
261 259
262struct thread_info *alloc_thread_info(struct task_struct *task) 260struct thread_info *alloc_thread_info(struct task_struct *task)
263{ 261{
@@ -274,17 +272,16 @@ struct thread_info *alloc_thread_info(struct task_struct *task)
274 } 272 }
275 273
276 if (!thread) 274 if (!thread)
277 thread = ll_alloc_task_struct(); 275 thread = (struct thread_info *)
276 __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER);
278 277
279#ifdef CONFIG_MAGIC_SYSRQ 278#ifdef CONFIG_DEBUG_STACK_USAGE
280 /* 279 /*
281 * The stack must be cleared if you want SYSRQ-T to 280 * The stack must be cleared if you want SYSRQ-T to
282 * give sensible stack usage information 281 * give sensible stack usage information
283 */ 282 */
284 if (thread) { 283 if (thread)
285 char *p = (char *)thread; 284 memzero(thread, THREAD_SIZE);
286 memzero(p+KERNEL_STACK_SIZE, KERNEL_STACK_SIZE);
287 }
288#endif 285#endif
289 return thread; 286 return thread;
290} 287}
@@ -297,7 +294,7 @@ void free_thread_info(struct thread_info *thread)
297 thread_info_head = p; 294 thread_info_head = p;
298 nr_thread_info += 1; 295 nr_thread_info += 1;
299 } else 296 } else
300 ll_free_task_struct(thread); 297 free_pages((unsigned long)thread, THREAD_SIZE_ORDER);
301} 298}
302 299
303/* 300/*
@@ -350,7 +347,7 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
350 struct thread_info *thread = p->thread_info; 347 struct thread_info *thread = p->thread_info;
351 struct pt_regs *childregs; 348 struct pt_regs *childregs;
352 349
353 childregs = ((struct pt_regs *)((unsigned long)thread + THREAD_SIZE - 8)) - 1; 350 childregs = ((struct pt_regs *)((unsigned long)thread + THREAD_START_SP)) - 1;
354 *childregs = *regs; 351 *childregs = *regs;
355 childregs->ARM_r0 = 0; 352 childregs->ARM_r0 = 0;
356 childregs->ARM_sp = stack_start; 353 childregs->ARM_sp = stack_start;
@@ -447,15 +444,17 @@ EXPORT_SYMBOL(kernel_thread);
447unsigned long get_wchan(struct task_struct *p) 444unsigned long get_wchan(struct task_struct *p)
448{ 445{
449 unsigned long fp, lr; 446 unsigned long fp, lr;
450 unsigned long stack_page; 447 unsigned long stack_start, stack_end;
451 int count = 0; 448 int count = 0;
452 if (!p || p == current || p->state == TASK_RUNNING) 449 if (!p || p == current || p->state == TASK_RUNNING)
453 return 0; 450 return 0;
454 451
455 stack_page = 4096 + (unsigned long)p->thread_info; 452 stack_start = (unsigned long)(p->thread_info + 1);
453 stack_end = ((unsigned long)p->thread_info) + THREAD_SIZE;
454
456 fp = thread_saved_fp(p); 455 fp = thread_saved_fp(p);
457 do { 456 do {
458 if (fp < stack_page || fp > 4092+stack_page) 457 if (fp < stack_start || fp > stack_end)
459 return 0; 458 return 0;
460 lr = pc_pointer (((unsigned long *)fp)[-1]); 459 lr = pc_pointer (((unsigned long *)fp)[-1]);
461 if (!in_sched_functions(lr)) 460 if (!in_sched_functions(lr))
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index efd7a341614b..cd99b83f14c2 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -19,6 +19,7 @@
19#include <linux/user.h> 19#include <linux/user.h>
20#include <linux/security.h> 20#include <linux/security.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/signal.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/pgtable.h> 25#include <asm/pgtable.h>
@@ -693,7 +694,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
693 case PTRACE_SYSCALL: 694 case PTRACE_SYSCALL:
694 case PTRACE_CONT: 695 case PTRACE_CONT:
695 ret = -EIO; 696 ret = -EIO;
696 if ((unsigned long) data > _NSIG) 697 if (!valid_signal(data))
697 break; 698 break;
698 if (request == PTRACE_SYSCALL) 699 if (request == PTRACE_SYSCALL)
699 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 700 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -728,7 +729,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
728 */ 729 */
729 case PTRACE_SINGLESTEP: 730 case PTRACE_SINGLESTEP:
730 ret = -EIO; 731 ret = -EIO;
731 if ((unsigned long) data > _NSIG) 732 if (!valid_signal(data))
732 break; 733 break;
733 child->ptrace |= PT_SINGLESTEP; 734 child->ptrace |= PT_SINGLESTEP;
734 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 735 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
diff --git a/arch/arm/kernel/sys_arm.c b/arch/arm/kernel/sys_arm.c
index 7ba6342cf93d..f897ce2ccf0d 100644
--- a/arch/arm/kernel/sys_arm.c
+++ b/arch/arm/kernel/sys_arm.c
@@ -227,18 +227,6 @@ asmlinkage int sys_ipc(uint call, int first, int second, int third,
227 } 227 }
228} 228}
229 229
230asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
231 unsigned long __user *addr)
232{
233 unsigned long ret;
234 long err;
235
236 err = do_shmat(shmid, shmaddr, shmflg, &ret);
237 if (err == 0)
238 err = put_user(ret, addr);
239 return err;
240}
241
242/* Fork a new task - this creates a new program thread. 230/* Fork a new task - this creates a new program thread.
243 * This is called indirectly via a small wrapper 231 * This is called indirectly via a small wrapper
244 */ 232 */
@@ -314,7 +302,7 @@ long execve(const char *filename, char **argv, char **envp)
314 "b ret_to_user" 302 "b ret_to_user"
315 : 303 :
316 : "r" (current_thread_info()), 304 : "r" (current_thread_info()),
317 "Ir" (THREAD_SIZE - 8 - sizeof(regs)), 305 "Ir" (THREAD_START_SP - sizeof(regs)),
318 "r" (&regs), 306 "r" (&regs),
319 "Ir" (sizeof(regs)) 307 "Ir" (sizeof(regs))
320 : "r0", "r1", "r2", "r3", "ip", "memory"); 308 : "r0", "r1", "r2", "r3", "ip", "memory");
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 6e31718f6008..14df16b983f4 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -218,7 +218,8 @@ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
218 tsk->comm, tsk->pid, tsk->thread_info + 1); 218 tsk->comm, tsk->pid, tsk->thread_info + 1);
219 219
220 if (!user_mode(regs) || in_interrupt()) { 220 if (!user_mode(regs) || in_interrupt()) {
221 dump_mem("Stack: ", regs->ARM_sp, 8192+(unsigned long)tsk->thread_info); 221 dump_mem("Stack: ", regs->ARM_sp,
222 THREAD_SIZE + (unsigned long)tsk->thread_info);
222 dump_backtrace(regs, tsk); 223 dump_backtrace(regs, tsk);
223 dump_instr(regs); 224 dump_instr(regs);
224 } 225 }
@@ -450,13 +451,17 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
450 451
451 case NR(set_tls): 452 case NR(set_tls):
452 thread->tp_value = regs->ARM_r0; 453 thread->tp_value = regs->ARM_r0;
454#if defined(CONFIG_HAS_TLS_REG)
455 asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) );
456#elif !defined(CONFIG_TLS_REG_EMUL)
453 /* 457 /*
454 * Our user accessible TLS ptr is located at 0xffff0ffc. 458 * User space must never try to access this directly.
455 * On SMP read access to this address must raise a fault 459 * Expect your app to break eventually if you do so.
456 * and be emulated from the data abort handler. 460 * The user helper at 0xffff0fe0 must be used instead.
457 * m 461 * (see entry-armv.S for details)
458 */ 462 */
459 *((unsigned long *)0xffff0ffc) = thread->tp_value; 463 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
464#endif
460 return 0; 465 return 0;
461 466
462 default: 467 default:
@@ -493,6 +498,44 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
493 return 0; 498 return 0;
494} 499}
495 500
501#ifdef CONFIG_TLS_REG_EMUL
502
503/*
504 * We might be running on an ARMv6+ processor which should have the TLS
505 * register but for some reason we can't use it, or maybe an SMP system
506 * using a pre-ARMv6 processor (there are apparently a few prototypes like
507 * that in existence) and therefore access to that register must be
508 * emulated.
509 */
510
511static int get_tp_trap(struct pt_regs *regs, unsigned int instr)
512{
513 int reg = (instr >> 12) & 15;
514 if (reg == 15)
515 return 1;
516 regs->uregs[reg] = current_thread_info()->tp_value;
517 regs->ARM_pc += 4;
518 return 0;
519}
520
521static struct undef_hook arm_mrc_hook = {
522 .instr_mask = 0x0fff0fff,
523 .instr_val = 0x0e1d0f70,
524 .cpsr_mask = PSR_T_BIT,
525 .cpsr_val = 0,
526 .fn = get_tp_trap,
527};
528
529static int __init arm_mrc_hook_init(void)
530{
531 register_undef_hook(&arm_mrc_hook);
532 return 0;
533}
534
535late_initcall(arm_mrc_hook_init);
536
537#endif
538
496void __bad_xchg(volatile void *ptr, int size) 539void __bad_xchg(volatile void *ptr, int size)
497{ 540{
498 printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n", 541 printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
@@ -578,9 +621,19 @@ EXPORT_SYMBOL(abort);
578 621
579void __init trap_init(void) 622void __init trap_init(void)
580{ 623{
581 extern void __trap_init(void); 624 extern char __stubs_start[], __stubs_end[];
625 extern char __vectors_start[], __vectors_end[];
626 extern char __kuser_helper_start[], __kuser_helper_end[];
627 int kuser_sz = __kuser_helper_end - __kuser_helper_start;
582 628
583 __trap_init(); 629 /*
630 * Copy the vectors, stubs and kuser helpers (in entry-armv.S)
631 * into the vector page, mapped at 0xffff0000, and ensure these
632 * are visible to the instruction stream.
633 */
634 memcpy((void *)0xffff0000, __vectors_start, __vectors_end - __vectors_start);
635 memcpy((void *)0xffff0200, __stubs_start, __stubs_end - __stubs_start);
636 memcpy((void *)0xffff1000 - kuser_sz, __kuser_helper_start, kuser_sz);
584 flush_icache_range(0xffff0000, 0xffff0000 + PAGE_SIZE); 637 flush_icache_range(0xffff0000, 0xffff0000 + PAGE_SIZE);
585 modify_domain(DOMAIN_USER, DOMAIN_CLIENT); 638 modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
586} 639}
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index a39c6a42d68a..ad2d66c93a5c 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -5,6 +5,7 @@
5 5
6#include <asm-generic/vmlinux.lds.h> 6#include <asm-generic/vmlinux.lds.h>
7#include <linux/config.h> 7#include <linux/config.h>
8#include <asm/thread_info.h>
8 9
9OUTPUT_ARCH(arm) 10OUTPUT_ARCH(arm)
10ENTRY(stext) 11ENTRY(stext)
@@ -103,7 +104,7 @@ SECTIONS
103 __data_loc = ALIGN(4); /* location in binary */ 104 __data_loc = ALIGN(4); /* location in binary */
104 . = DATAADDR; 105 . = DATAADDR;
105#else 106#else
106 . = ALIGN(8192); 107 . = ALIGN(THREAD_SIZE);
107 __data_loc = .; 108 __data_loc = .;
108#endif 109#endif
109 110
diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
index f6e676322ca9..45c930ccd064 100644
--- a/arch/arm/mach-clps711x/Kconfig
+++ b/arch/arm/mach-clps711x/Kconfig
@@ -10,6 +10,7 @@ config ARCH_AUTCPU12
10 10
11config ARCH_CDB89712 11config ARCH_CDB89712
12 bool "CDB89712" 12 bool "CDB89712"
13 select ISA
13 help 14 help
14 This is an evaluation board from Cirrus for the CS89712 processor. 15 This is an evaluation board from Cirrus for the CS89712 processor.
15 The board includes 2 serial ports, Ethernet, IRDA, and expansion 16 The board includes 2 serial ports, Ethernet, IRDA, and expansion
@@ -26,6 +27,8 @@ config ARCH_CLEP7312
26 27
27config ARCH_EDB7211 28config ARCH_EDB7211
28 bool "EDB7211" 29 bool "EDB7211"
30 select ISA
31 select DISCONTIGMEM
29 help 32 help
30 Say Y here if you intend to run this kernel on a Cirrus Logic EDB-7211 33 Say Y here if you intend to run this kernel on a Cirrus Logic EDB-7211
31 evaluation board. 34 evaluation board.
diff --git a/arch/arm/mach-footbridge/Kconfig b/arch/arm/mach-footbridge/Kconfig
index 1090c680b6dd..324d9edeec38 100644
--- a/arch/arm/mach-footbridge/Kconfig
+++ b/arch/arm/mach-footbridge/Kconfig
@@ -5,6 +5,9 @@ menu "Footbridge Implementations"
5config ARCH_CATS 5config ARCH_CATS
6 bool "CATS" 6 bool "CATS"
7 select FOOTBRIDGE_HOST 7 select FOOTBRIDGE_HOST
8 select ISA
9 select ISA_DMA
10 select PCI
8 help 11 help
9 Say Y here if you intend to run this kernel on the CATS. 12 Say Y here if you intend to run this kernel on the CATS.
10 13
@@ -13,6 +16,9 @@ config ARCH_CATS
13config ARCH_PERSONAL_SERVER 16config ARCH_PERSONAL_SERVER
14 bool "Compaq Personal Server" 17 bool "Compaq Personal Server"
15 select FOOTBRIDGE_HOST 18 select FOOTBRIDGE_HOST
19 select ISA
20 select ISA_DMA
21 select PCI
16 ---help--- 22 ---help---
17 Say Y here if you intend to run this kernel on the Compaq 23 Say Y here if you intend to run this kernel on the Compaq
18 Personal Server. 24 Personal Server.
@@ -42,6 +48,9 @@ config ARCH_EBSA285_HOST
42 bool "EBSA285 (host mode)" 48 bool "EBSA285 (host mode)"
43 select ARCH_EBSA285 49 select ARCH_EBSA285
44 select FOOTBRIDGE_HOST 50 select FOOTBRIDGE_HOST
51 select ISA
52 select ISA_DMA
53 select PCI
45 help 54 help
46 Say Y here if you intend to run this kernel on the EBSA285 card 55 Say Y here if you intend to run this kernel on the EBSA285 card
47 in host ("central function") mode. 56 in host ("central function") mode.
@@ -51,6 +60,9 @@ config ARCH_EBSA285_HOST
51config ARCH_NETWINDER 60config ARCH_NETWINDER
52 bool "NetWinder" 61 bool "NetWinder"
53 select FOOTBRIDGE_HOST 62 select FOOTBRIDGE_HOST
63 select ISA
64 select ISA_DMA
65 select PCI
54 help 66 help
55 Say Y here if you intend to run this kernel on the Rebel.COM 67 Say Y here if you intend to run this kernel on the Rebel.COM
56 NetWinder. Information about this machine can be found at: 68 NetWinder. Information about this machine can be found at:
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index ec85813ee5dc..cddd194ac6eb 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -4,6 +4,7 @@ menu "IMX Implementations"
4config ARCH_MX1ADS 4config ARCH_MX1ADS
5 bool "mx1ads" 5 bool "mx1ads"
6 depends on ARCH_IMX 6 depends on ARCH_IMX
7 select ISA
7 help 8 help
8 Say Y here if you are using the Motorola MX1ADS board 9 Say Y here if you are using the Motorola MX1ADS board
9 10
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index 54377d0f578c..41e5849ae8da 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -26,6 +26,7 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <asm/arch/imxfb.h>
29#include <asm/hardware.h> 30#include <asm/hardware.h>
30 31
31#include <asm/mach/map.h> 32#include <asm/mach/map.h>
@@ -228,6 +229,14 @@ static struct platform_device imx_uart2_device = {
228 .resource = imx_uart2_resources, 229 .resource = imx_uart2_resources,
229}; 230};
230 231
232static struct imxfb_mach_info imx_fb_info;
233
234void __init set_imx_fb_info(struct imxfb_mach_info *hard_imx_fb_info)
235{
236 memcpy(&imx_fb_info,hard_imx_fb_info,sizeof(struct imxfb_mach_info));
237}
238EXPORT_SYMBOL(set_imx_fb_info);
239
231static struct resource imxfb_resources[] = { 240static struct resource imxfb_resources[] = {
232 [0] = { 241 [0] = {
233 .start = 0x00205000, 242 .start = 0x00205000,
@@ -241,9 +250,16 @@ static struct resource imxfb_resources[] = {
241 }, 250 },
242}; 251};
243 252
253static u64 fb_dma_mask = ~(u64)0;
254
244static struct platform_device imxfb_device = { 255static struct platform_device imxfb_device = {
245 .name = "imx-fb", 256 .name = "imx-fb",
246 .id = 0, 257 .id = 0,
258 .dev = {
259 .platform_data = &imx_fb_info,
260 .dma_mask = &fb_dma_mask,
261 .coherent_dma_mask = 0xffffffff,
262 },
247 .num_resources = ARRAY_SIZE(imxfb_resources), 263 .num_resources = ARRAY_SIZE(imxfb_resources),
248 .resource = imxfb_resources, 264 .resource = imxfb_resources,
249}; 265};
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 86c50c3889b7..bd17b5154311 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -216,7 +216,9 @@ integrator_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
216 216
217 write_seqlock(&xtime_lock); 217 write_seqlock(&xtime_lock);
218 218
219 // ...clear the interrupt 219 /*
220 * clear the interrupt
221 */
220 timer1->TimerClear = 1; 222 timer1->TimerClear = 1;
221 223
222 timer_tick(regs); 224 timer_tick(regs);
@@ -264,7 +266,7 @@ void __init integrator_time_init(unsigned long reload, unsigned int ctrl)
264 timer1->TimerValue = timer_reload; 266 timer1->TimerValue = timer_reload;
265 timer1->TimerControl = timer_ctrl; 267 timer1->TimerControl = timer_ctrl;
266 268
267 /* 269 /*
268 * Make irqs happen for the system timer 270 * Make irqs happen for the system timer
269 */ 271 */
270 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq); 272 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq);
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 68e15c36e336..3b948e8c2751 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -420,7 +420,22 @@ static struct clcd_panel vga = {
420 */ 420 */
421static void cp_clcd_enable(struct clcd_fb *fb) 421static void cp_clcd_enable(struct clcd_fb *fb)
422{ 422{
423 cm_control(CM_CTRL_LCDMUXSEL_MASK, CM_CTRL_LCDMUXSEL_VGA); 423 u32 val;
424
425 if (fb->fb.var.bits_per_pixel <= 8)
426 val = CM_CTRL_LCDMUXSEL_VGA_8421BPP;
427 else if (fb->fb.var.bits_per_pixel <= 16)
428 val = CM_CTRL_LCDMUXSEL_VGA_16BPP;
429 else
430 val = 0; /* no idea for this, don't trust the docs */
431
432 cm_control(CM_CTRL_LCDMUXSEL_MASK|
433 CM_CTRL_LCDEN0|
434 CM_CTRL_LCDEN1|
435 CM_CTRL_STATIC1|
436 CM_CTRL_STATIC2|
437 CM_CTRL_STATIC|
438 CM_CTRL_n24BITEN, val);
424} 439}
425 440
426static unsigned long framesize = SZ_1M; 441static unsigned long framesize = SZ_1M;
diff --git a/arch/arm/mach-integrator/leds.c b/arch/arm/mach-integrator/leds.c
index 9d182b77b312..d2c0ab21150c 100644
--- a/arch/arm/mach-integrator/leds.c
+++ b/arch/arm/mach-integrator/leds.c
@@ -37,7 +37,7 @@ static void integrator_leds_event(led_event_t ledevt)
37 unsigned long flags; 37 unsigned long flags;
38 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE); 38 const unsigned int dbg_base = IO_ADDRESS(INTEGRATOR_DBG_BASE);
39 unsigned int update_alpha_leds; 39 unsigned int update_alpha_leds;
40 40
41 // yup, change the LEDs 41 // yup, change the LEDs
42 local_irq_save(flags); 42 local_irq_save(flags);
43 update_alpha_leds = 0; 43 update_alpha_leds = 0;
diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c
index 20729de2af28..1a844ca139e0 100644
--- a/arch/arm/mach-integrator/time.c
+++ b/arch/arm/mach-integrator/time.c
@@ -40,25 +40,32 @@ static int integrator_set_rtc(void)
40 return 1; 40 return 1;
41} 41}
42 42
43static void rtc_read_alarm(struct rtc_wkalrm *alrm) 43static int rtc_read_alarm(struct rtc_wkalrm *alrm)
44{ 44{
45 rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time); 45 rtc_time_to_tm(readl(rtc_base + RTC_MR), &alrm->time);
46 return 0;
46} 47}
47 48
48static int rtc_set_alarm(struct rtc_wkalrm *alrm) 49static inline int rtc_set_alarm(struct rtc_wkalrm *alrm)
49{ 50{
50 unsigned long time; 51 unsigned long time;
51 int ret; 52 int ret;
52 53
53 ret = rtc_tm_to_time(&alrm->time, &time); 54 /*
55 * At the moment, we can only deal with non-wildcarded alarm times.
56 */
57 ret = rtc_valid_tm(&alrm->time);
58 if (ret == 0)
59 ret = rtc_tm_to_time(&alrm->time, &time);
54 if (ret == 0) 60 if (ret == 0)
55 writel(time, rtc_base + RTC_MR); 61 writel(time, rtc_base + RTC_MR);
56 return ret; 62 return ret;
57} 63}
58 64
59static void rtc_read_time(struct rtc_time *tm) 65static int rtc_read_time(struct rtc_time *tm)
60{ 66{
61 rtc_time_to_tm(readl(rtc_base + RTC_DR), tm); 67 rtc_time_to_tm(readl(rtc_base + RTC_DR), tm);
68 return 0;
62} 69}
63 70
64/* 71/*
@@ -69,7 +76,7 @@ static void rtc_read_time(struct rtc_time *tm)
69 * edge of the 1Hz clock, we must write the time one second 76 * edge of the 1Hz clock, we must write the time one second
70 * in advance. 77 * in advance.
71 */ 78 */
72static int rtc_set_time(struct rtc_time *tm) 79static inline int rtc_set_time(struct rtc_time *tm)
73{ 80{
74 unsigned long time; 81 unsigned long time;
75 int ret; 82 int ret;
diff --git a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
index c4683aaff84a..aec13c7108a9 100644
--- a/arch/arm/mach-ixp2000/ixdp2800.c
+++ b/arch/arm/mach-ixp2000/ixdp2800.c
@@ -65,19 +65,102 @@ static struct sys_timer ixdp2800_timer = {
65/************************************************************************* 65/*************************************************************************
66 * IXDP2800 PCI 66 * IXDP2800 PCI
67 *************************************************************************/ 67 *************************************************************************/
68static void __init ixdp2800_slave_disable_pci_master(void)
69{
70 *IXP2000_PCI_CMDSTAT &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
71}
72
73static void __init ixdp2800_master_wait_for_slave(void)
74{
75 volatile u32 *addr;
76
77 printk(KERN_INFO "IXDP2800: waiting for slave NPU to configure "
78 "its BAR sizes\n");
79
80 addr = ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN,
81 PCI_BASE_ADDRESS_1);
82 do {
83 *addr = 0xffffffff;
84 cpu_relax();
85 } while (*addr != 0xfe000008);
86
87 addr = ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN,
88 PCI_BASE_ADDRESS_2);
89 do {
90 *addr = 0xffffffff;
91 cpu_relax();
92 } while (*addr != 0xc0000008);
93
94 /*
95 * Configure the slave's SDRAM BAR by hand.
96 */
97 *addr = 0x40000008;
98}
99
100static void __init ixdp2800_slave_wait_for_master_enable(void)
101{
102 printk(KERN_INFO "IXDP2800: waiting for master NPU to enable us\n");
103
104 while ((*IXP2000_PCI_CMDSTAT & PCI_COMMAND_MASTER) == 0)
105 cpu_relax();
106}
107
68void __init ixdp2800_pci_preinit(void) 108void __init ixdp2800_pci_preinit(void)
69{ 109{
70 printk("ixdp2x00_pci_preinit called\n"); 110 printk("ixdp2x00_pci_preinit called\n");
71 111
72 *IXP2000_PCI_ADDR_EXT = 0x0000e000; 112 *IXP2000_PCI_ADDR_EXT = 0x0001e000;
113
114 if (!ixdp2x00_master_npu())
115 ixdp2800_slave_disable_pci_master();
73 116
74 *IXP2000_PCI_DRAM_BASE_ADDR_MASK = (0x40000000 - 1) & ~0xfffff;
75 *IXP2000_PCI_SRAM_BASE_ADDR_MASK = (0x2000000 - 1) & ~0x3ffff; 117 *IXP2000_PCI_SRAM_BASE_ADDR_MASK = (0x2000000 - 1) & ~0x3ffff;
118 *IXP2000_PCI_DRAM_BASE_ADDR_MASK = (0x40000000 - 1) & ~0xfffff;
76 119
77 ixp2000_pci_preinit(); 120 ixp2000_pci_preinit();
121
122 if (ixdp2x00_master_npu()) {
123 /*
124 * Wait until the slave set its SRAM/SDRAM BAR sizes
125 * correctly before we proceed to scan and enumerate
126 * the bus.
127 */
128 ixdp2800_master_wait_for_slave();
129
130 /*
131 * We configure the SDRAM BARs by hand because they
132 * are 1G and fall outside of the regular allocated
133 * PCI address space.
134 */
135 *IXP2000_PCI_SDRAM_BAR = 0x00000008;
136 } else {
137 /*
138 * Wait for the master to complete scanning the bus
139 * and assigning resources before we proceed to scan
140 * the bus ourselves. Set pci=firmware to honor the
141 * master's resource assignment.
142 */
143 ixdp2800_slave_wait_for_master_enable();
144 pcibios_setup("firmware");
145 }
78} 146}
79 147
80int ixdp2800_pci_setup(int nr, struct pci_sys_data *sys) 148/*
149 * We assign the SDRAM BARs for the two IXP2800 CPUs by hand, outside
150 * of the regular PCI window, because there's only 512M of outbound PCI
151 * memory window on each IXP, while we need 1G for each of the BARs.
152 */
153static void __devinit ixp2800_pci_fixup(struct pci_dev *dev)
154{
155 if (machine_is_ixdp2800()) {
156 dev->resource[2].start = 0;
157 dev->resource[2].end = 0;
158 dev->resource[2].flags = 0;
159 }
160}
161DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IXP2800, ixp2800_pci_fixup);
162
163static int __init ixdp2800_pci_setup(int nr, struct pci_sys_data *sys)
81{ 164{
82 sys->mem_offset = 0x00000000; 165 sys->mem_offset = 0x00000000;
83 166
@@ -129,22 +212,47 @@ static int __init ixdp2800_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
129 } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */ 212 } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
130} 213}
131 214
132static void ixdp2800_pci_postinit(void) 215static void __init ixdp2800_master_enable_slave(void)
133{ 216{
134 struct pci_dev *dev; 217 volatile u32 *addr;
135 218
136 if (ixdp2x00_master_npu()) { 219 printk(KERN_INFO "IXDP2800: enabling slave NPU\n");
137 dev = pci_find_slot(1, IXDP2800_SLAVE_ENET_DEVFN); 220
138 pci_remove_bus_device(dev); 221 addr = (volatile u32 *)ixp2000_pci_config_addr(0,
139 } else { 222 IXDP2X00_SLAVE_NPU_DEVFN,
140 dev = pci_find_slot(1, IXDP2800_MASTER_ENET_DEVFN); 223 PCI_COMMAND);
141 pci_remove_bus_device(dev); 224
225 *addr |= PCI_COMMAND_MASTER;
226}
142 227
228static void __init ixdp2800_master_wait_for_slave_bus_scan(void)
229{
230 volatile u32 *addr;
231
232 printk(KERN_INFO "IXDP2800: waiting for slave to finish bus scan\n");
233
234 addr = (volatile u32 *)ixp2000_pci_config_addr(0,
235 IXDP2X00_SLAVE_NPU_DEVFN,
236 PCI_COMMAND);
237 while ((*addr & PCI_COMMAND_MEMORY) == 0)
238 cpu_relax();
239}
240
241static void __init ixdp2800_slave_signal_bus_scan_completion(void)
242{
243 printk(KERN_INFO "IXDP2800: bus scan done, signaling master\n");
244 *IXP2000_PCI_CMDSTAT |= PCI_COMMAND_MEMORY;
245}
246
247static void __init ixdp2800_pci_postinit(void)
248{
249 if (!ixdp2x00_master_npu()) {
143 ixdp2x00_slave_pci_postinit(); 250 ixdp2x00_slave_pci_postinit();
251 ixdp2800_slave_signal_bus_scan_completion();
144 } 252 }
145} 253}
146 254
147struct hw_pci ixdp2800_pci __initdata = { 255struct __initdata hw_pci ixdp2800_pci __initdata = {
148 .nr_controllers = 1, 256 .nr_controllers = 1,
149 .setup = ixdp2800_pci_setup, 257 .setup = ixdp2800_pci_setup,
150 .preinit = ixdp2800_pci_preinit, 258 .preinit = ixdp2800_pci_preinit,
@@ -155,8 +263,21 @@ struct hw_pci ixdp2800_pci __initdata = {
155 263
156int __init ixdp2800_pci_init(void) 264int __init ixdp2800_pci_init(void)
157{ 265{
158 if (machine_is_ixdp2800()) 266 if (machine_is_ixdp2800()) {
267 struct pci_dev *dev;
268
159 pci_common_init(&ixdp2800_pci); 269 pci_common_init(&ixdp2800_pci);
270 if (ixdp2x00_master_npu()) {
271 dev = pci_find_slot(1, IXDP2800_SLAVE_ENET_DEVFN);
272 pci_remove_bus_device(dev);
273
274 ixdp2800_master_enable_slave();
275 ixdp2800_master_wait_for_slave_bus_scan();
276 } else {
277 dev = pci_find_slot(1, IXDP2800_MASTER_ENET_DEVFN);
278 pci_remove_bus_device(dev);
279 }
280 }
160 281
161 return 0; 282 return 0;
162} 283}
diff --git a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
index 831f8ffb6b61..5ff2f2718c58 100644
--- a/arch/arm/mach-ixp2000/pci.c
+++ b/arch/arm/mach-ixp2000/pci.c
@@ -37,7 +37,7 @@ static int pci_master_aborts = 0;
37 37
38static int clear_master_aborts(void); 38static int clear_master_aborts(void);
39 39
40static u32 * 40u32 *
41ixp2000_pci_config_addr(unsigned int bus_nr, unsigned int devfn, int where) 41ixp2000_pci_config_addr(unsigned int bus_nr, unsigned int devfn, int where)
42{ 42{
43 u32 *paddress; 43 u32 *paddress;
@@ -208,15 +208,15 @@ ixp2000_pci_preinit(void)
208 * use our own resource space. 208 * use our own resource space.
209 */ 209 */
210static struct resource ixp2000_pci_mem_space = { 210static struct resource ixp2000_pci_mem_space = {
211 .start = 0x00000000, 211 .start = 0xe0000000,
212 .end = 0xffffffff, 212 .end = 0xffffffff,
213 .flags = IORESOURCE_MEM, 213 .flags = IORESOURCE_MEM,
214 .name = "PCI Mem Space" 214 .name = "PCI Mem Space"
215}; 215};
216 216
217static struct resource ixp2000_pci_io_space = { 217static struct resource ixp2000_pci_io_space = {
218 .start = 0x00000000, 218 .start = 0x00010000,
219 .end = 0xffffffff, 219 .end = 0x0001ffff,
220 .flags = IORESOURCE_IO, 220 .flags = IORESOURCE_IO,
221 .name = "PCI I/O Space" 221 .name = "PCI I/O Space"
222}; 222};
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 94bcdb933e41..aa92e3708838 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -502,15 +502,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
502} 502}
503 503
504int 504int
505pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
506{
507 if (mask >= SZ_64M - 1 )
508 return 0;
509
510 return -EIO;
511}
512
513int
514pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 505pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
515{ 506{
516 if (mask >= SZ_64M - 1 ) 507 if (mask >= SZ_64M - 1 )
@@ -520,7 +511,6 @@ pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
520} 511}
521 512
522EXPORT_SYMBOL(pci_set_dma_mask); 513EXPORT_SYMBOL(pci_set_dma_mask);
523EXPORT_SYMBOL(pci_dac_set_dma_mask);
524EXPORT_SYMBOL(pci_set_consistent_dma_mask); 514EXPORT_SYMBOL(pci_set_consistent_dma_mask);
525EXPORT_SYMBOL(ixp4xx_pci_read); 515EXPORT_SYMBOL(ixp4xx_pci_read);
526EXPORT_SYMBOL(ixp4xx_pci_write); 516EXPORT_SYMBOL(ixp4xx_pci_write);
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index b1575b8dc1cd..a45aaa115a76 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -220,6 +220,30 @@ static struct platform_device stuart_device = {
220 .id = 2, 220 .id = 2,
221}; 221};
222 222
223static struct resource i2c_resources[] = {
224 {
225 .start = 0x40301680,
226 .end = 0x403016a3,
227 .flags = IORESOURCE_MEM,
228 }, {
229 .start = IRQ_I2C,
230 .end = IRQ_I2C,
231 .flags = IORESOURCE_IRQ,
232 },
233};
234
235static struct platform_device i2c_device = {
236 .name = "pxa2xx-i2c",
237 .id = 0,
238 .resource = i2c_resources,
239 .num_resources = ARRAY_SIZE(i2c_resources),
240};
241
242void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
243{
244 i2c_device.dev.platform_data = info;
245}
246
223static struct platform_device *devices[] __initdata = { 247static struct platform_device *devices[] __initdata = {
224 &pxamci_device, 248 &pxamci_device,
225 &udc_device, 249 &udc_device,
@@ -227,6 +251,7 @@ static struct platform_device *devices[] __initdata = {
227 &ffuart_device, 251 &ffuart_device,
228 &btuart_device, 252 &btuart_device,
229 &stuart_device, 253 &stuart_device,
254 &i2c_device,
230}; 255};
231 256
232static int __init pxa_init(void) 257static int __init pxa_init(void)
diff --git a/arch/arm/mach-pxa/sleep.S b/arch/arm/mach-pxa/sleep.S
index 16cad2c2497c..5786ccad938c 100644
--- a/arch/arm/mach-pxa/sleep.S
+++ b/arch/arm/mach-pxa/sleep.S
@@ -18,6 +18,11 @@
18 18
19#include <asm/arch/pxa-regs.h> 19#include <asm/arch/pxa-regs.h>
20 20
21#ifdef CONFIG_PXA27x // workaround for Errata 50
22#define MDREFR_KDIV 0x200a4000 // all banks
23#define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0
24#endif
25
21 .text 26 .text
22 27
23/* 28/*
@@ -28,7 +33,9 @@
28 33
29ENTRY(pxa_cpu_suspend) 34ENTRY(pxa_cpu_suspend)
30 35
36#ifndef CONFIG_IWMMXT
31 mra r2, r3, acc0 37 mra r2, r3, acc0
38#endif
32 stmfd sp!, {r2 - r12, lr} @ save registers on stack 39 stmfd sp!, {r2 - r12, lr} @ save registers on stack
33 40
34 @ get coprocessor registers 41 @ get coprocessor registers
@@ -61,14 +68,23 @@ ENTRY(pxa_cpu_suspend)
61 @ prepare value for sleep mode 68 @ prepare value for sleep mode
62 mov r1, #3 @ sleep mode 69 mov r1, #3 @ sleep mode
63 70
64 @ prepare to put SDRAM into self-refresh manually 71 @ prepare pointer to physical address 0 (virtual mapping in generic.c)
72 mov r2, #UNCACHED_PHYS_0
73
74 @ prepare SDRAM refresh settings
65 ldr r4, =MDREFR 75 ldr r4, =MDREFR
66 ldr r5, [r4] 76 ldr r5, [r4]
77
78 @ enable SDRAM self-refresh mode
67 orr r5, r5, #MDREFR_SLFRSH 79 orr r5, r5, #MDREFR_SLFRSH
68 80
69 @ prepare pointer to physical address 0 (virtual mapping in generic.c) 81#ifdef CONFIG_PXA27x
70 mov r2, #UNCACHED_PHYS_0 82 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
83 ldr r6, =MDREFR_KDIV
84 orr r5, r5, r6
85#endif
71 86
87#ifdef CONFIG_PXA25x
72 @ Intel PXA255 Specification Update notes problems 88 @ Intel PXA255 Specification Update notes problems
73 @ about suspending with PXBus operating above 133MHz 89 @ about suspending with PXBus operating above 133MHz
74 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep 90 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep
@@ -100,6 +116,18 @@ ENTRY(pxa_cpu_suspend)
100 mov r0, #0 116 mov r0, #0
101 mcr p14, 0, r0, c6, c0, 0 117 mcr p14, 0, r0, c6, c0, 0
102 orr r0, r0, #2 @ initiate change bit 118 orr r0, r0, #2 @ initiate change bit
119#endif
120#ifdef CONFIG_PXA27x
121 @ Intel PXA270 Specification Update notes problems sleeping
122 @ with core operating above 91 MHz
123 @ (see Errata 50, ...processor does not exit from sleep...)
124
125 ldr r6, =CCCR
126 ldr r8, [r6] @ keep original value for resume
127
128 ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
129 mov r0, #0x2 @ prepare value for CLKCFG
130#endif
103 131
104 @ align execution to a cache line 132 @ align execution to a cache line
105 b 1f 133 b 1f
@@ -111,6 +139,7 @@ ENTRY(pxa_cpu_suspend)
111 @ All needed values are now in registers. 139 @ All needed values are now in registers.
112 @ These last instructions should be in cache 140 @ These last instructions should be in cache
113 141
142#if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x)
114 @ initiate the frequency change... 143 @ initiate the frequency change...
115 str r7, [r6] 144 str r7, [r6]
116 mcr p14, 0, r0, c6, c0, 0 145 mcr p14, 0, r0, c6, c0, 0
@@ -118,14 +147,27 @@ ENTRY(pxa_cpu_suspend)
118 @ restore the original cpu speed value for resume 147 @ restore the original cpu speed value for resume
119 str r8, [r6] 148 str r8, [r6]
120 149
121 @ put SDRAM into self-refresh 150 @ need 6 13-MHz cycles before changing PWRMODE
122 str r5, [r4] 151 @ just set frequency to 91-MHz... 6*91/13 = 42
152
153 mov r0, #42
15410: subs r0, r0, #1
155 bne 10b
156#endif
157
158 @ Do not reorder...
159 @ Intel PXA270 Specification Update notes problems performing
160 @ external accesses after SDRAM is put in self-refresh mode
161 @ (see Errata 39 ...hangs when entering self-refresh mode)
123 162
124 @ force address lines low by reading at physical address 0 163 @ force address lines low by reading at physical address 0
125 ldr r3, [r2] 164 ldr r3, [r2]
126 165
166 @ put SDRAM into self-refresh
167 str r5, [r4]
168
127 @ enter sleep mode 169 @ enter sleep mode
128 mcr p14, 0, r1, c7, c0, 0 170 mcr p14, 0, r1, c7, c0, 0 @ PWRMODE
129 171
13020: b 20b @ loop waiting for sleep 17220: b 20b @ loop waiting for sleep
131 173
@@ -188,7 +230,9 @@ resume_after_mmu:
188 bl cpu_xscale_proc_init 230 bl cpu_xscale_proc_init
189#endif 231#endif
190 ldmfd sp!, {r2, r3} 232 ldmfd sp!, {r2, r3}
233#ifndef CONFIG_IWMMXT
191 mar acc0, r2, r3 234 mar acc0, r2, r3
235#endif
192 ldmfd sp!, {r4 - r12, pc} @ return to caller 236 ldmfd sp!, {r4 - r12, pc} @ return to caller
193 237
194 238
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 5b670c9ac5ef..c4fc6be629de 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -409,3 +409,24 @@ config CPU_BPREDICT_DISABLE
409 depends on CPU_ARM1020 409 depends on CPU_ARM1020
410 help 410 help
411 Say Y here to disable branch prediction. If unsure, say N. 411 Say Y here to disable branch prediction. If unsure, say N.
412
413config TLS_REG_EMUL
414 bool
415 default y if (SMP || CPU_32v6) && (CPU_32v5 || CPU_32v4 || CPU_32v3)
416 help
417 We might be running on an ARMv6+ processor which should have the TLS
418 register but for some reason we can't use it, or maybe an SMP system
419 using a pre-ARMv6 processor (there are apparently a few prototypes
420 like that in existence) and therefore access to that register must
421 be emulated.
422
423config HAS_TLS_REG
424 bool
425 depends on CPU_32v6
426 default y if !TLS_REG_EMUL
427 help
428 This selects support for the CP15 thread register.
429 It is defined to be available on ARMv6 or later. If a particular
430 ARMv6 or later CPU doesn't support it then it must omc;ide "select
431 TLS_REG_EMUL" along with its other caracteristics.
432
diff --git a/arch/arm/mm/abort-ev6.S b/arch/arm/mm/abort-ev6.S
index 38b2cbb89beb..8f76f3df7b4c 100644
--- a/arch/arm/mm/abort-ev6.S
+++ b/arch/arm/mm/abort-ev6.S
@@ -1,5 +1,6 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <asm/assembler.h> 2#include <asm/assembler.h>
3#include "abort-macro.S"
3/* 4/*
4 * Function: v6_early_abort 5 * Function: v6_early_abort
5 * 6 *
@@ -13,11 +14,26 @@
13 * : sp = pointer to registers 14 * : sp = pointer to registers
14 * 15 *
15 * Purpose : obtain information about current aborted instruction. 16 * Purpose : obtain information about current aborted instruction.
17 * Note: we read user space. This means we might cause a data
18 * abort here if the I-TLB and D-TLB aren't seeing the same
19 * picture. Unfortunately, this does happen. We live with it.
16 */ 20 */
17 .align 5 21 .align 5
18ENTRY(v6_early_abort) 22ENTRY(v6_early_abort)
19 mrc p15, 0, r1, c5, c0, 0 @ get FSR 23 mrc p15, 0, r1, c5, c0, 0 @ get FSR
20 mrc p15, 0, r0, c6, c0, 0 @ get FAR 24 mrc p15, 0, r0, c6, c0, 0 @ get FAR
25/*
26 * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR.
27 * The test below covers all the write situations, including Java bytecodes
28 */
29 bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
30 tst r3, #PSR_J_BIT @ Java?
31 movne pc, lr
32 do_thumb_abort
33 ldreq r3, [r2] @ read aborted ARM instruction
34 do_ldrd_abort
35 tst r3, #1 << 20 @ L = 0 -> write
36 orreq r1, r1, #1 << 11 @ yes.
21 mov pc, lr 37 mov pc, lr
22 38
23 39
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index f5a87db8b498..585dfb8e20b9 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -411,9 +411,10 @@ static void __init build_mem_type_table(void)
411 mem_types[MT_MEMORY].prot_sect &= ~PMD_BIT4; 411 mem_types[MT_MEMORY].prot_sect &= ~PMD_BIT4;
412 mem_types[MT_ROM].prot_sect &= ~PMD_BIT4; 412 mem_types[MT_ROM].prot_sect &= ~PMD_BIT4;
413 /* 413 /*
414 * Mark cache clean areas read only from SVC mode 414 * Mark cache clean areas and XIP ROM read only
415 * and no access from userspace. 415 * from SVC mode and no access from userspace.
416 */ 416 */
417 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
417 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 418 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
418 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 419 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
419 } 420 }
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index 3955de5af4c0..6caed90661fc 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -89,6 +89,10 @@ config PAGESIZE_16
89 machine with 4MB of memory. 89 machine with 4MB of memory.
90endmenu 90endmenu
91 91
92config ISA_DMA_API
93 bool
94 default y
95
92menu "General setup" 96menu "General setup"
93 97
94# Compressed boot loader in ROM. Yes, we really want to ask about 98# Compressed boot loader in ROM. Yes, we really want to ask about
diff --git a/arch/arm26/kernel/ptrace.c b/arch/arm26/kernel/ptrace.c
index 2a137146a77c..8a52124de0e1 100644
--- a/arch/arm26/kernel/ptrace.c
+++ b/arch/arm26/kernel/ptrace.c
@@ -18,6 +18,7 @@
18#include <linux/ptrace.h> 18#include <linux/ptrace.h>
19#include <linux/user.h> 19#include <linux/user.h>
20#include <linux/security.h> 20#include <linux/security.h>
21#include <linux/signal.h>
21 22
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
@@ -591,7 +592,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
591 case PTRACE_SYSCALL: 592 case PTRACE_SYSCALL:
592 case PTRACE_CONT: 593 case PTRACE_CONT:
593 ret = -EIO; 594 ret = -EIO;
594 if ((unsigned long) data > _NSIG) 595 if (!valid_signal(data))
595 break; 596 break;
596 if (request == PTRACE_SYSCALL) 597 if (request == PTRACE_SYSCALL)
597 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 598 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -626,7 +627,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
626 */ 627 */
627 case PTRACE_SINGLESTEP: 628 case PTRACE_SINGLESTEP:
628 ret = -EIO; 629 ret = -EIO;
629 if ((unsigned long) data > _NSIG) 630 if (!valid_signal(data))
630 break; 631 break;
631 child->ptrace |= PT_SINGLESTEP; 632 child->ptrace |= PT_SINGLESTEP;
632 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 633 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
diff --git a/arch/arm26/mm/small_page.c b/arch/arm26/mm/small_page.c
index 77be86cca789..30447106c25f 100644
--- a/arch/arm26/mm/small_page.c
+++ b/arch/arm26/mm/small_page.c
@@ -92,8 +92,7 @@ static unsigned long __get_small_page(int priority, struct order *order)
92 page = list_entry(order->queue.next, struct page, lru); 92 page = list_entry(order->queue.next, struct page, lru);
93again: 93again:
94#ifdef PEDANTIC 94#ifdef PEDANTIC
95 if (USED_MAP(page) & ~order->all_used) 95 BUG_ON(USED_MAP(page) & ~order->all_used);
96 PAGE_BUG(page);
97#endif 96#endif
98 offset = ffz(USED_MAP(page)); 97 offset = ffz(USED_MAP(page));
99 SET_USED(page, offset); 98 SET_USED(page, offset);
@@ -141,8 +140,7 @@ static void __free_small_page(unsigned long spage, struct order *order)
141 goto non_small; 140 goto non_small;
142 141
143#ifdef PEDANTIC 142#ifdef PEDANTIC
144 if (USED_MAP(page) & ~order->all_used) 143 BUG_ON(USED_MAP(page) & ~order->all_used);
145 PAGE_BUG(page);
146#endif 144#endif
147 145
148 spage = spage >> order->shift; 146 spage = spage >> order->shift;
diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c
index da15db8ae482..581ecabaae53 100644
--- a/arch/cris/arch-v10/kernel/ptrace.c
+++ b/arch/cris/arch-v10/kernel/ptrace.c
@@ -10,6 +10,7 @@
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/ptrace.h> 11#include <linux/ptrace.h>
12#include <linux/user.h> 12#include <linux/user.h>
13#include <linux/signal.h>
13 14
14#include <asm/uaccess.h> 15#include <asm/uaccess.h>
15#include <asm/page.h> 16#include <asm/page.h>
@@ -184,7 +185,7 @@ sys_ptrace(long request, long pid, long addr, long data)
184 case PTRACE_CONT: 185 case PTRACE_CONT:
185 ret = -EIO; 186 ret = -EIO;
186 187
187 if ((unsigned long) data > _NSIG) 188 if (!valid_signal(data))
188 break; 189 break;
189 190
190 if (request == PTRACE_SYSCALL) { 191 if (request == PTRACE_SYSCALL) {
@@ -219,7 +220,7 @@ sys_ptrace(long request, long pid, long addr, long data)
219 case PTRACE_SINGLESTEP: 220 case PTRACE_SINGLESTEP:
220 ret = -EIO; 221 ret = -EIO;
221 222
222 if ((unsigned long) data > _NSIG) 223 if (!valid_signal(data))
223 break; 224 break;
224 225
225 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 226 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
diff --git a/arch/frv/kernel/ptrace.c b/arch/frv/kernel/ptrace.c
index 2a0efb739adc..cbe03cba9f02 100644
--- a/arch/frv/kernel/ptrace.c
+++ b/arch/frv/kernel/ptrace.c
@@ -20,6 +20,7 @@
20#include <linux/user.h> 20#include <linux/user.h>
21#include <linux/config.h> 21#include <linux/config.h>
22#include <linux/security.h> 22#include <linux/security.h>
23#include <linux/signal.h>
23 24
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
25#include <asm/page.h> 26#include <asm/page.h>
@@ -239,7 +240,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
239 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 240 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
240 case PTRACE_CONT: /* restart after signal. */ 241 case PTRACE_CONT: /* restart after signal. */
241 ret = -EIO; 242 ret = -EIO;
242 if ((unsigned long) data > _NSIG) 243 if (!valid_signal(data))
243 break; 244 break;
244 if (request == PTRACE_SYSCALL) 245 if (request == PTRACE_SYSCALL)
245 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 246 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -267,7 +268,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
267 268
268 case PTRACE_SINGLESTEP: /* set the trap flag. */ 269 case PTRACE_SINGLESTEP: /* set the trap flag. */
269 ret = -EIO; 270 ret = -EIO;
270 if ((unsigned long) data > _NSIG) 271 if (!valid_signal(data))
271 break; 272 break;
272 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 273 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
273 ptrace_enable(child); 274 ptrace_enable(child);
diff --git a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
index 5f19d774a288..05c15e869777 100644
--- a/arch/h8300/kernel/ptrace.c
+++ b/arch/h8300/kernel/ptrace.c
@@ -24,6 +24,7 @@
24#include <linux/ptrace.h> 24#include <linux/ptrace.h>
25#include <linux/user.h> 25#include <linux/user.h>
26#include <linux/config.h> 26#include <linux/config.h>
27#include <linux/signal.h>
27 28
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/page.h> 30#include <asm/page.h>
@@ -171,7 +172,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
171 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 172 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
172 case PTRACE_CONT: { /* restart after signal. */ 173 case PTRACE_CONT: { /* restart after signal. */
173 ret = -EIO; 174 ret = -EIO;
174 if ((unsigned long) data >= _NSIG) 175 if (!valid_signal(data))
175 break ; 176 break ;
176 if (request == PTRACE_SYSCALL) 177 if (request == PTRACE_SYSCALL)
177 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 178 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -202,7 +203,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
202 203
203 case PTRACE_SINGLESTEP: { /* set the trap flag. */ 204 case PTRACE_SINGLESTEP: { /* set the trap flag. */
204 ret = -EIO; 205 ret = -EIO;
205 if ((unsigned long) data > _NSIG) 206 if (!valid_signal(data))
206 break; 207 break;
207 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 208 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
208 child->exit_code = data; 209 child->exit_code = data;
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 17a0cbce6f30..e382f32d435e 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -183,7 +183,7 @@ config M386
183 - "Winchip-C6" for original IDT Winchip. 183 - "Winchip-C6" for original IDT Winchip.
184 - "Winchip-2" for IDT Winchip 2. 184 - "Winchip-2" for IDT Winchip 2.
185 - "Winchip-2A" for IDT Winchips with 3dNow! capabilities. 185 - "Winchip-2A" for IDT Winchips with 3dNow! capabilities.
186 - "MediaGX/Geode" for Cyrix MediaGX aka Geode. 186 - "GeodeGX1" for Geode GX1 (Cyrix MediaGX).
187 - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3. 187 - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
188 - "VIA C3-2 for VIA C3-2 "Nehemiah" (model 9 and above). 188 - "VIA C3-2 for VIA C3-2 "Nehemiah" (model 9 and above).
189 189
@@ -311,12 +311,10 @@ config MWINCHIP3D
311 stores for this CPU, which can increase performance of some 311 stores for this CPU, which can increase performance of some
312 operations. 312 operations.
313 313
314config MGEODE 314config MGEODEGX1
315 bool "MediaGX/Geode" 315 bool "GeodeGX1"
316 help 316 help
317 Select this for a Cyrix MediaGX aka Geode chip. Linux and GCC 317 Select this for a Geode GX1 (Cyrix MediaGX) chip.
318 treat this chip as a 586TSC with some extended instructions
319 and alignment reqirements.
320 318
321config MCYRIXIII 319config MCYRIXIII
322 bool "CyrixIII/VIA-C3" 320 bool "CyrixIII/VIA-C3"
@@ -368,7 +366,7 @@ config X86_L1_CACHE_SHIFT
368 int 366 int
369 default "7" if MPENTIUM4 || X86_GENERIC 367 default "7" if MPENTIUM4 || X86_GENERIC
370 default "4" if X86_ELAN || M486 || M386 368 default "4" if X86_ELAN || M486 || M386
371 default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE 369 default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODEGX1
372 default "6" if MK7 || MK8 || MPENTIUMM 370 default "6" if MK7 || MK8 || MPENTIUMM
373 371
374config RWSEM_GENERIC_SPINLOCK 372config RWSEM_GENERIC_SPINLOCK
@@ -387,7 +385,7 @@ config GENERIC_CALIBRATE_DELAY
387 385
388config X86_PPRO_FENCE 386config X86_PPRO_FENCE
389 bool 387 bool
390 depends on M686 || M586MMX || M586TSC || M586 || M486 || M386 || MGEODE 388 depends on M686 || M586MMX || M586TSC || M586 || M486 || M386 || MGEODEGX1
391 default y 389 default y
392 390
393config X86_F00F_BUG 391config X86_F00F_BUG
@@ -417,7 +415,7 @@ config X86_POPAD_OK
417 415
418config X86_ALIGNMENT_16 416config X86_ALIGNMENT_16
419 bool 417 bool
420 depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODE 418 depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
421 default y 419 default y
422 420
423config X86_GOOD_APIC 421config X86_GOOD_APIC
@@ -442,7 +440,7 @@ config X86_USE_3DNOW
442 440
443config X86_OOSTORE 441config X86_OOSTORE
444 bool 442 bool
445 depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MGEODE) && MTRR 443 depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6) && MTRR
446 default y 444 default y
447 445
448config HPET_TIMER 446config HPET_TIMER
@@ -578,7 +576,7 @@ config X86_VISWS_APIC
578 576
579config X86_TSC 577config X86_TSC
580 bool 578 bool
581 depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODE) && !X86_NUMAQ 579 depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1) && !X86_NUMAQ
582 default y 580 default y
583 581
584config X86_MCE 582config X86_MCE
@@ -653,6 +651,24 @@ config I8K
653 Say Y if you intend to run this kernel on a Dell Inspiron 8000. 651 Say Y if you intend to run this kernel on a Dell Inspiron 8000.
654 Say N otherwise. 652 Say N otherwise.
655 653
654config X86_REBOOTFIXUPS
655 bool "Enable X86 board specific fixups for reboot"
656 depends on X86
657 default n
658 ---help---
659 This enables chipset and/or board specific fixups to be done
660 in order to get reboot to work correctly. This is only needed on
661 some combinations of hardware and BIOS. The symptom, for which
662 this config is intended, is when reboot ends with a stalled/hung
663 system.
664
665 Currently, the only fixup is for the Geode GX1/CS5530A/TROM2.1.
666 combination.
667
668 Say Y if you want to enable the fixup. Currently, it's safe to
669 enable this option even if you don't need it.
670 Say N otherwise.
671
656config MICROCODE 672config MICROCODE
657 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support" 673 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support"
658 ---help--- 674 ---help---
@@ -1155,6 +1171,10 @@ source "drivers/pci/pcie/Kconfig"
1155 1171
1156source "drivers/pci/Kconfig" 1172source "drivers/pci/Kconfig"
1157 1173
1174config ISA_DMA_API
1175 bool
1176 default y
1177
1158config ISA 1178config ISA
1159 bool "ISA support" 1179 bool "ISA support"
1160 depends on !(X86_VOYAGER || X86_VISWS) 1180 depends on !(X86_VOYAGER || X86_VISWS)
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 314c7146e9bf..1c36ca332a96 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -14,7 +14,7 @@
14# 19990713 Artur Skawina <skawina@geocities.com> 14# 19990713 Artur Skawina <skawina@geocities.com>
15# Added '-march' and '-mpreferred-stack-boundary' support 15# Added '-march' and '-mpreferred-stack-boundary' support
16# 16#
17# Kianusch Sayah Karadji <kianusch@sk-tech.net> 17# 20050320 Kianusch Sayah Karadji <kianusch@sk-tech.net>
18# Added support for GEODE CPU 18# Added support for GEODE CPU
19 19
20LDFLAGS := -m elf_i386 20LDFLAGS := -m elf_i386
@@ -54,8 +54,8 @@ cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
54# AMD Elan support 54# AMD Elan support
55cflags-$(CONFIG_X86_ELAN) += -march=i486 55cflags-$(CONFIG_X86_ELAN) += -march=i486
56 56
57# MediaGX aka Geode support 57# Geode GX1 support
58cflags-$(CONFIG_MGEODE) += $(call cc-option,-march=pentium-mmx,-march=i586) 58cflags-$(CONFIG_MGEODEGX1) += $(call cc-option,-march=pentium-mmx,-march=i486)
59 59
60# -mregparm=3 works ok on gcc-3.0 and later 60# -mregparm=3 works ok on gcc-3.0 and later
61# 61#
@@ -123,7 +123,7 @@ AFLAGS += $(mflags-y)
123boot := arch/i386/boot 123boot := arch/i386/boot
124 124
125.PHONY: zImage bzImage compressed zlilo bzlilo \ 125.PHONY: zImage bzImage compressed zlilo bzlilo \
126 zdisk bzdisk fdimage fdimage144 fdimage288 install 126 zdisk bzdisk fdimage fdimage144 fdimage288 install kernel_install
127 127
128all: bzImage 128all: bzImage
129 129
@@ -145,8 +145,9 @@ zdisk bzdisk: vmlinux
145fdimage fdimage144 fdimage288: vmlinux 145fdimage fdimage144 fdimage288: vmlinux
146 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ 146 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@
147 147
148install: 148install: vmlinux
149 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@ 149install kernel_install:
150 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
150 151
151prepare: include/asm-$(ARCH)/asm_offsets.h 152prepare: include/asm-$(ARCH)/asm_offsets.h
152CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h 153CLEAN_FILES += include/asm-$(ARCH)/asm_offsets.h
diff --git a/arch/i386/boot/bootsect.S b/arch/i386/boot/bootsect.S
index ba9fe14db6a9..011b7a4993d4 100644
--- a/arch/i386/boot/bootsect.S
+++ b/arch/i386/boot/bootsect.S
@@ -83,7 +83,7 @@ bugger_off_msg:
83 .ascii "\n" 83 .ascii "\n"
84 .ascii "Remove disk and press any key to reboot . . .\r\n" 84 .ascii "Remove disk and press any key to reboot . . .\r\n"
85 .byte 0 85 .byte 0
86 86
87 87
88 # Kernel attributes; used by setup 88 # Kernel attributes; used by setup
89 89
diff --git a/arch/i386/boot/compressed/misc.c b/arch/i386/boot/compressed/misc.c
index fa67045234a3..cedc55cc47de 100644
--- a/arch/i386/boot/compressed/misc.c
+++ b/arch/i386/boot/compressed/misc.c
@@ -12,7 +12,6 @@
12#include <linux/linkage.h> 12#include <linux/linkage.h>
13#include <linux/vmalloc.h> 13#include <linux/vmalloc.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <video/edid.h>
16#include <asm/io.h> 15#include <asm/io.h>
17 16
18/* 17/*
diff --git a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S
index a934ab32bf8e..caa1fde6904e 100644
--- a/arch/i386/boot/setup.S
+++ b/arch/i386/boot/setup.S
@@ -164,7 +164,7 @@ ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
164trampoline: call start_of_setup 164trampoline: call start_of_setup
165 .align 16 165 .align 16
166 # The offset at this point is 0x240 166 # The offset at this point is 0x240
167 .space (0x7ff-0x240+1) # E820 & EDD space (ending at 0x7ff) 167 .space (0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
168# End of setup header ##################################################### 168# End of setup header #####################################################
169 169
170start_of_setup: 170start_of_setup:
@@ -333,9 +333,9 @@ jmpe820:
333 # sizeof(e820rec). 333 # sizeof(e820rec).
334 # 334 #
335good820: 335good820:
336 movb (E820NR), %al # up to 32 entries 336 movb (E820NR), %al # up to 128 entries
337 cmpb $E820MAX, %al 337 cmpb $E820MAX, %al
338 jnl bail820 338 jae bail820
339 339
340 incb (E820NR) 340 incb (E820NR)
341 movw %di, %ax 341 movw %di, %ax
diff --git a/arch/i386/boot/video.S b/arch/i386/boot/video.S
index 925d3f5a3824..0587477c99f2 100644
--- a/arch/i386/boot/video.S
+++ b/arch/i386/boot/video.S
@@ -1924,36 +1924,36 @@ skip10: movb %ah, %al
1924 ret 1924 ret
1925 1925
1926store_edid: 1926store_edid:
1927 pushw %es # just save all registers 1927 pushw %es # just save all registers
1928 pushw %ax 1928 pushw %ax
1929 pushw %bx 1929 pushw %bx
1930 pushw %cx 1930 pushw %cx
1931 pushw %dx 1931 pushw %dx
1932 pushw %di 1932 pushw %di
1933 1933
1934 pushw %fs 1934 pushw %fs
1935 popw %es 1935 popw %es
1936 1936
1937 movl $0x13131313, %eax # memset block with 0x13 1937 movl $0x13131313, %eax # memset block with 0x13
1938 movw $32, %cx 1938 movw $32, %cx
1939 movw $0x140, %di 1939 movw $0x140, %di
1940 cld 1940 cld
1941 rep 1941 rep
1942 stosl 1942 stosl
1943 1943
1944 movw $0x4f15, %ax # do VBE/DDC 1944 movw $0x4f15, %ax # do VBE/DDC
1945 movw $0x01, %bx 1945 movw $0x01, %bx
1946 movw $0x00, %cx 1946 movw $0x00, %cx
1947 movw $0x01, %dx 1947 movw $0x01, %dx
1948 movw $0x140, %di 1948 movw $0x140, %di
1949 int $0x10 1949 int $0x10
1950 1950
1951 popw %di # restore all registers 1951 popw %di # restore all registers
1952 popw %dx 1952 popw %dx
1953 popw %cx 1953 popw %cx
1954 popw %bx 1954 popw %bx
1955 popw %ax 1955 popw %ax
1956 popw %es 1956 popw %es
1957 ret 1957 ret
1958 1958
1959# VIDEO_SELECT-only variables 1959# VIDEO_SELECT-only variables
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index aacdae6f372d..0fbcfe00dd8d 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
23obj-$(CONFIG_X86_MPPARSE) += mpparse.o 23obj-$(CONFIG_X86_MPPARSE) += mpparse.o
24obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o 24obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o
25obj-$(CONFIG_X86_IO_APIC) += io_apic.o 25obj-$(CONFIG_X86_IO_APIC) += io_apic.o
26obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups.o
26obj-$(CONFIG_X86_NUMAQ) += numaq.o 27obj-$(CONFIG_X86_NUMAQ) += numaq.o
27obj-$(CONFIG_X86_SUMMIT_NUMA) += summit.o 28obj-$(CONFIG_X86_SUMMIT_NUMA) += summit.o
28obj-$(CONFIG_KPROBES) += kprobes.o 29obj-$(CONFIG_KPROBES) += kprobes.o
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 53eb5cfd5b63..848bb97af7ca 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -650,7 +650,7 @@ acpi_find_rsdp (void)
650 */ 650 */
651 rsdp_phys = acpi_scan_rsdp (0, 0x400); 651 rsdp_phys = acpi_scan_rsdp (0, 0x400);
652 if (!rsdp_phys) 652 if (!rsdp_phys)
653 rsdp_phys = acpi_scan_rsdp (0xE0000, 0xFFFFF); 653 rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
654 654
655 return rsdp_phys; 655 return rsdp_phys;
656} 656}
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index e3879f7625c2..d509836b70c3 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -1265,8 +1265,6 @@ int __init APIC_init_uniprocessor (void)
1265 1265
1266 setup_local_APIC(); 1266 setup_local_APIC();
1267 1267
1268 if (nmi_watchdog == NMI_LOCAL_APIC)
1269 check_nmi_watchdog();
1270#ifdef CONFIG_X86_IO_APIC 1268#ifdef CONFIG_X86_IO_APIC
1271 if (smp_found_config) 1269 if (smp_found_config)
1272 if (!skip_ioapic_setup && nr_ioapics) 1270 if (!skip_ioapic_setup && nr_ioapics)
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 8d182e875cd7..16dbc4151be4 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -24,7 +24,7 @@ __asm__(".align 4\nvide: ret");
24 24
25static void __init init_amd(struct cpuinfo_x86 *c) 25static void __init init_amd(struct cpuinfo_x86 *c)
26{ 26{
27#ifdef CONFIG_SMP 27#ifdef CONFIG_X86_SMP
28 int cpu = c == &boot_cpu_data ? 0 : c - cpu_data; 28 int cpu = c == &boot_cpu_data ? 0 : c - cpu_data;
29#endif 29#endif
30 u32 l, h; 30 u32 l, h;
@@ -198,7 +198,7 @@ static void __init init_amd(struct cpuinfo_x86 *c)
198 c->x86_num_cores = 1; 198 c->x86_num_cores = 1;
199 } 199 }
200 200
201#ifdef CONFIG_SMP 201#ifdef CONFIG_X86_SMP
202 /* 202 /*
203 * On a AMD dual core setup the lower bits of the APIC id 203 * On a AMD dual core setup the lower bits of the APIC id
204 * distingush the cores. Assumes number of cores is a power 204 * distingush the cores. Assumes number of cores is a power
diff --git a/arch/i386/kernel/cpu/mtrr/cyrix.c b/arch/i386/kernel/cpu/mtrr/cyrix.c
index 933b0dd62f48..9027a987006b 100644
--- a/arch/i386/kernel/cpu/mtrr/cyrix.c
+++ b/arch/i386/kernel/cpu/mtrr/cyrix.c
@@ -218,12 +218,12 @@ typedef struct {
218 mtrr_type type; 218 mtrr_type type;
219} arr_state_t; 219} arr_state_t;
220 220
221static arr_state_t arr_state[8] __initdata = { 221static arr_state_t arr_state[8] __devinitdata = {
222 {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, 222 {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL},
223 {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL} 223 {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}, {0UL, 0UL, 0UL}
224}; 224};
225 225
226static unsigned char ccr_state[7] __initdata = { 0, 0, 0, 0, 0, 0, 0 }; 226static unsigned char ccr_state[7] __devinitdata = { 0, 0, 0, 0, 0, 0, 0 };
227 227
228static void cyrix_set_all(void) 228static void cyrix_set_all(void)
229{ 229{
diff --git a/arch/i386/kernel/cpu/mtrr/generic.c b/arch/i386/kernel/cpu/mtrr/generic.c
index 9f7a7ea6388d..f468a979e9aa 100644
--- a/arch/i386/kernel/cpu/mtrr/generic.c
+++ b/arch/i386/kernel/cpu/mtrr/generic.c
@@ -124,8 +124,8 @@ int generic_get_free_region(unsigned long base, unsigned long size)
124 return -ENOSPC; 124 return -ENOSPC;
125} 125}
126 126
127void generic_get_mtrr(unsigned int reg, unsigned long *base, 127static void generic_get_mtrr(unsigned int reg, unsigned long *base,
128 unsigned int *size, mtrr_type * type) 128 unsigned int *size, mtrr_type * type)
129{ 129{
130 unsigned int mask_lo, mask_hi, base_lo, base_hi; 130 unsigned int mask_lo, mask_hi, base_lo, base_hi;
131 131
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index 54999e4c55fd..e1c2042b9b7e 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -72,17 +72,21 @@ void set_mtrr_ops(struct mtrr_ops * ops)
72static int have_wrcomb(void) 72static int have_wrcomb(void)
73{ 73{
74 struct pci_dev *dev; 74 struct pci_dev *dev;
75 u8 rev;
75 76
76 if ((dev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) { 77 if ((dev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, NULL)) != NULL) {
77 /* ServerWorks LE chipsets have problems with write-combining 78 /* ServerWorks LE chipsets < rev 6 have problems with write-combining
78 Don't allow it and leave room for other chipsets to be tagged */ 79 Don't allow it and leave room for other chipsets to be tagged */
79 if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS && 80 if (dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
80 dev->device == PCI_DEVICE_ID_SERVERWORKS_LE) { 81 dev->device == PCI_DEVICE_ID_SERVERWORKS_LE) {
81 printk(KERN_INFO "mtrr: Serverworks LE detected. Write-combining disabled.\n"); 82 pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
82 pci_dev_put(dev); 83 if (rev <= 5) {
83 return 0; 84 printk(KERN_INFO "mtrr: Serverworks LE rev < 6 detected. Write-combining disabled.\n");
85 pci_dev_put(dev);
86 return 0;
87 }
84 } 88 }
85 /* Intel 450NX errata # 23. Non ascending cachline evictions to 89 /* Intel 450NX errata # 23. Non ascending cacheline evictions to
86 write combining memory may resulting in data corruption */ 90 write combining memory may resulting in data corruption */
87 if (dev->vendor == PCI_VENDOR_ID_INTEL && 91 if (dev->vendor == PCI_VENDOR_ID_INTEL &&
88 dev->device == PCI_DEVICE_ID_INTEL_82451NX) { 92 dev->device == PCI_DEVICE_ID_INTEL_82451NX) {
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 4f28eba7fb8a..7323c19f354e 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -25,7 +25,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
25 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe", 25 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
26 26
27 /* AMD-defined */ 27 /* AMD-defined */
28 "pni", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 28 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
29 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL, 29 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
30 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL, 30 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
31 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow", 31 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 3c73dc865ead..a991d4e5edd2 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -260,11 +260,9 @@ restore_nocheck:
260.section .fixup,"ax" 260.section .fixup,"ax"
261iret_exc: 261iret_exc:
262 sti 262 sti
263 movl $__USER_DS, %edx 263 pushl $0 # no error code
264 movl %edx, %ds 264 pushl $do_iret_error
265 movl %edx, %es 265 jmp error_code
266 movl $11,%eax
267 call do_exit
268.previous 266.previous
269.section __ex_table,"a" 267.section __ex_table,"a"
270 .align 4 268 .align 4
@@ -516,8 +514,6 @@ debug_stack_correct:
516 xorl %edx,%edx # error code 0 514 xorl %edx,%edx # error code 0
517 movl %esp,%eax # pt_regs pointer 515 movl %esp,%eax # pt_regs pointer
518 call do_debug 516 call do_debug
519 testl %eax,%eax
520 jnz restore_all
521 jmp ret_from_exception 517 jmp ret_from_exception
522 518
523/* 519/*
@@ -598,8 +594,6 @@ ENTRY(int3)
598 xorl %edx,%edx # zero error code 594 xorl %edx,%edx # zero error code
599 movl %esp,%eax # pt_regs pointer 595 movl %esp,%eax # pt_regs pointer
600 call do_int3 596 call do_int3
601 testl %eax,%eax
602 jnz restore_all
603 jmp ret_from_exception 597 jmp ret_from_exception
604 598
605ENTRY(overflow) 599ENTRY(overflow)
@@ -658,296 +652,6 @@ ENTRY(spurious_interrupt_bug)
658 pushl $do_spurious_interrupt_bug 652 pushl $do_spurious_interrupt_bug
659 jmp error_code 653 jmp error_code
660 654
661.data 655#include "syscall_table.S"
662ENTRY(sys_call_table)
663 .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
664 .long sys_exit
665 .long sys_fork
666 .long sys_read
667 .long sys_write
668 .long sys_open /* 5 */
669 .long sys_close
670 .long sys_waitpid
671 .long sys_creat
672 .long sys_link
673 .long sys_unlink /* 10 */
674 .long sys_execve
675 .long sys_chdir
676 .long sys_time
677 .long sys_mknod
678 .long sys_chmod /* 15 */
679 .long sys_lchown16
680 .long sys_ni_syscall /* old break syscall holder */
681 .long sys_stat
682 .long sys_lseek
683 .long sys_getpid /* 20 */
684 .long sys_mount
685 .long sys_oldumount
686 .long sys_setuid16
687 .long sys_getuid16
688 .long sys_stime /* 25 */
689 .long sys_ptrace
690 .long sys_alarm
691 .long sys_fstat
692 .long sys_pause
693 .long sys_utime /* 30 */
694 .long sys_ni_syscall /* old stty syscall holder */
695 .long sys_ni_syscall /* old gtty syscall holder */
696 .long sys_access
697 .long sys_nice
698 .long sys_ni_syscall /* 35 - old ftime syscall holder */
699 .long sys_sync
700 .long sys_kill
701 .long sys_rename
702 .long sys_mkdir
703 .long sys_rmdir /* 40 */
704 .long sys_dup
705 .long sys_pipe
706 .long sys_times
707 .long sys_ni_syscall /* old prof syscall holder */
708 .long sys_brk /* 45 */
709 .long sys_setgid16
710 .long sys_getgid16
711 .long sys_signal
712 .long sys_geteuid16
713 .long sys_getegid16 /* 50 */
714 .long sys_acct
715 .long sys_umount /* recycled never used phys() */
716 .long sys_ni_syscall /* old lock syscall holder */
717 .long sys_ioctl
718 .long sys_fcntl /* 55 */
719 .long sys_ni_syscall /* old mpx syscall holder */
720 .long sys_setpgid
721 .long sys_ni_syscall /* old ulimit syscall holder */
722 .long sys_olduname
723 .long sys_umask /* 60 */
724 .long sys_chroot
725 .long sys_ustat
726 .long sys_dup2
727 .long sys_getppid
728 .long sys_getpgrp /* 65 */
729 .long sys_setsid
730 .long sys_sigaction
731 .long sys_sgetmask
732 .long sys_ssetmask
733 .long sys_setreuid16 /* 70 */
734 .long sys_setregid16
735 .long sys_sigsuspend
736 .long sys_sigpending
737 .long sys_sethostname
738 .long sys_setrlimit /* 75 */
739 .long sys_old_getrlimit
740 .long sys_getrusage
741 .long sys_gettimeofday
742 .long sys_settimeofday
743 .long sys_getgroups16 /* 80 */
744 .long sys_setgroups16
745 .long old_select
746 .long sys_symlink
747 .long sys_lstat
748 .long sys_readlink /* 85 */
749 .long sys_uselib
750 .long sys_swapon
751 .long sys_reboot
752 .long old_readdir
753 .long old_mmap /* 90 */
754 .long sys_munmap
755 .long sys_truncate
756 .long sys_ftruncate
757 .long sys_fchmod
758 .long sys_fchown16 /* 95 */
759 .long sys_getpriority
760 .long sys_setpriority
761 .long sys_ni_syscall /* old profil syscall holder */
762 .long sys_statfs
763 .long sys_fstatfs /* 100 */
764 .long sys_ioperm
765 .long sys_socketcall
766 .long sys_syslog
767 .long sys_setitimer
768 .long sys_getitimer /* 105 */
769 .long sys_newstat
770 .long sys_newlstat
771 .long sys_newfstat
772 .long sys_uname
773 .long sys_iopl /* 110 */
774 .long sys_vhangup
775 .long sys_ni_syscall /* old "idle" system call */
776 .long sys_vm86old
777 .long sys_wait4
778 .long sys_swapoff /* 115 */
779 .long sys_sysinfo
780 .long sys_ipc
781 .long sys_fsync
782 .long sys_sigreturn
783 .long sys_clone /* 120 */
784 .long sys_setdomainname
785 .long sys_newuname
786 .long sys_modify_ldt
787 .long sys_adjtimex
788 .long sys_mprotect /* 125 */
789 .long sys_sigprocmask
790 .long sys_ni_syscall /* old "create_module" */
791 .long sys_init_module
792 .long sys_delete_module
793 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
794 .long sys_quotactl
795 .long sys_getpgid
796 .long sys_fchdir
797 .long sys_bdflush
798 .long sys_sysfs /* 135 */
799 .long sys_personality
800 .long sys_ni_syscall /* reserved for afs_syscall */
801 .long sys_setfsuid16
802 .long sys_setfsgid16
803 .long sys_llseek /* 140 */
804 .long sys_getdents
805 .long sys_select
806 .long sys_flock
807 .long sys_msync
808 .long sys_readv /* 145 */
809 .long sys_writev
810 .long sys_getsid
811 .long sys_fdatasync
812 .long sys_sysctl
813 .long sys_mlock /* 150 */
814 .long sys_munlock
815 .long sys_mlockall
816 .long sys_munlockall
817 .long sys_sched_setparam
818 .long sys_sched_getparam /* 155 */
819 .long sys_sched_setscheduler
820 .long sys_sched_getscheduler
821 .long sys_sched_yield
822 .long sys_sched_get_priority_max
823 .long sys_sched_get_priority_min /* 160 */
824 .long sys_sched_rr_get_interval
825 .long sys_nanosleep
826 .long sys_mremap
827 .long sys_setresuid16
828 .long sys_getresuid16 /* 165 */
829 .long sys_vm86
830 .long sys_ni_syscall /* Old sys_query_module */
831 .long sys_poll
832 .long sys_nfsservctl
833 .long sys_setresgid16 /* 170 */
834 .long sys_getresgid16
835 .long sys_prctl
836 .long sys_rt_sigreturn
837 .long sys_rt_sigaction
838 .long sys_rt_sigprocmask /* 175 */
839 .long sys_rt_sigpending
840 .long sys_rt_sigtimedwait
841 .long sys_rt_sigqueueinfo
842 .long sys_rt_sigsuspend
843 .long sys_pread64 /* 180 */
844 .long sys_pwrite64
845 .long sys_chown16
846 .long sys_getcwd
847 .long sys_capget
848 .long sys_capset /* 185 */
849 .long sys_sigaltstack
850 .long sys_sendfile
851 .long sys_ni_syscall /* reserved for streams1 */
852 .long sys_ni_syscall /* reserved for streams2 */
853 .long sys_vfork /* 190 */
854 .long sys_getrlimit
855 .long sys_mmap2
856 .long sys_truncate64
857 .long sys_ftruncate64
858 .long sys_stat64 /* 195 */
859 .long sys_lstat64
860 .long sys_fstat64
861 .long sys_lchown
862 .long sys_getuid
863 .long sys_getgid /* 200 */
864 .long sys_geteuid
865 .long sys_getegid
866 .long sys_setreuid
867 .long sys_setregid
868 .long sys_getgroups /* 205 */
869 .long sys_setgroups
870 .long sys_fchown
871 .long sys_setresuid
872 .long sys_getresuid
873 .long sys_setresgid /* 210 */
874 .long sys_getresgid
875 .long sys_chown
876 .long sys_setuid
877 .long sys_setgid
878 .long sys_setfsuid /* 215 */
879 .long sys_setfsgid
880 .long sys_pivot_root
881 .long sys_mincore
882 .long sys_madvise
883 .long sys_getdents64 /* 220 */
884 .long sys_fcntl64
885 .long sys_ni_syscall /* reserved for TUX */
886 .long sys_ni_syscall
887 .long sys_gettid
888 .long sys_readahead /* 225 */
889 .long sys_setxattr
890 .long sys_lsetxattr
891 .long sys_fsetxattr
892 .long sys_getxattr
893 .long sys_lgetxattr /* 230 */
894 .long sys_fgetxattr
895 .long sys_listxattr
896 .long sys_llistxattr
897 .long sys_flistxattr
898 .long sys_removexattr /* 235 */
899 .long sys_lremovexattr
900 .long sys_fremovexattr
901 .long sys_tkill
902 .long sys_sendfile64
903 .long sys_futex /* 240 */
904 .long sys_sched_setaffinity
905 .long sys_sched_getaffinity
906 .long sys_set_thread_area
907 .long sys_get_thread_area
908 .long sys_io_setup /* 245 */
909 .long sys_io_destroy
910 .long sys_io_getevents
911 .long sys_io_submit
912 .long sys_io_cancel
913 .long sys_fadvise64 /* 250 */
914 .long sys_ni_syscall
915 .long sys_exit_group
916 .long sys_lookup_dcookie
917 .long sys_epoll_create
918 .long sys_epoll_ctl /* 255 */
919 .long sys_epoll_wait
920 .long sys_remap_file_pages
921 .long sys_set_tid_address
922 .long sys_timer_create
923 .long sys_timer_settime /* 260 */
924 .long sys_timer_gettime
925 .long sys_timer_getoverrun
926 .long sys_timer_delete
927 .long sys_clock_settime
928 .long sys_clock_gettime /* 265 */
929 .long sys_clock_getres
930 .long sys_clock_nanosleep
931 .long sys_statfs64
932 .long sys_fstatfs64
933 .long sys_tgkill /* 270 */
934 .long sys_utimes
935 .long sys_fadvise64_64
936 .long sys_ni_syscall /* sys_vserver */
937 .long sys_mbind
938 .long sys_get_mempolicy
939 .long sys_set_mempolicy
940 .long sys_mq_open
941 .long sys_mq_unlink
942 .long sys_mq_timedsend
943 .long sys_mq_timedreceive /* 280 */
944 .long sys_mq_notify
945 .long sys_mq_getsetattr
946 .long sys_ni_syscall /* reserved for kexec */
947 .long sys_waitid
948 .long sys_ni_syscall /* 285 */ /* available */
949 .long sys_add_key
950 .long sys_request_key
951 .long sys_keyctl
952 656
953syscall_table_size=(.-sys_call_table) 657syscall_table_size=(.-sys_call_table)
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index d273fd746192..e966fc8c44c4 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -380,6 +380,7 @@ rp_sidt:
380 ALIGN 380 ALIGN
381ignore_int: 381ignore_int:
382 cld 382 cld
383#ifdef CONFIG_PRINTK
383 pushl %eax 384 pushl %eax
384 pushl %ecx 385 pushl %ecx
385 pushl %edx 386 pushl %edx
@@ -400,6 +401,7 @@ ignore_int:
400 popl %edx 401 popl %edx
401 popl %ecx 402 popl %ecx
402 popl %eax 403 popl %eax
404#endif
403 iret 405 iret
404 406
405/* 407/*
diff --git a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
index 14ec354bec92..903190a4b3ff 100644
--- a/arch/i386/kernel/i386_ksyms.c
+++ b/arch/i386/kernel/i386_ksyms.c
@@ -169,10 +169,6 @@ EXPORT_SYMBOL(rtc_lock);
169EXPORT_SYMBOL_GPL(set_nmi_callback); 169EXPORT_SYMBOL_GPL(set_nmi_callback);
170EXPORT_SYMBOL_GPL(unset_nmi_callback); 170EXPORT_SYMBOL_GPL(unset_nmi_callback);
171 171
172#undef memcmp
173extern int memcmp(const void *,const void *,__kernel_size_t);
174EXPORT_SYMBOL(memcmp);
175
176EXPORT_SYMBOL(register_die_notifier); 172EXPORT_SYMBOL(register_die_notifier);
177#ifdef CONFIG_HAVE_DEC_LOCK 173#ifdef CONFIG_HAVE_DEC_LOCK
178EXPORT_SYMBOL(_atomic_dec_and_lock); 174EXPORT_SYMBOL(_atomic_dec_and_lock);
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 5e0d55be5435..7a324e8b86f9 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -2175,7 +2175,6 @@ static inline void check_timer(void)
2175 disable_8259A_irq(0); 2175 disable_8259A_irq(0);
2176 setup_nmi(); 2176 setup_nmi();
2177 enable_8259A_irq(0); 2177 enable_8259A_irq(0);
2178 check_nmi_watchdog();
2179 } 2178 }
2180 return; 2179 return;
2181 } 2180 }
@@ -2198,7 +2197,6 @@ static inline void check_timer(void)
2198 add_pin_to_irq(0, 0, pin2); 2197 add_pin_to_irq(0, 0, pin2);
2199 if (nmi_watchdog == NMI_IO_APIC) { 2198 if (nmi_watchdog == NMI_IO_APIC) {
2200 setup_nmi(); 2199 setup_nmi();
2201 check_nmi_watchdog();
2202 } 2200 }
2203 return; 2201 return;
2204 } 2202 }
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 671681659243..59ff9b455069 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -217,6 +217,13 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs)
217 *tos &= ~(TF_MASK | IF_MASK); 217 *tos &= ~(TF_MASK | IF_MASK);
218 *tos |= kprobe_old_eflags; 218 *tos |= kprobe_old_eflags;
219 break; 219 break;
220 case 0xc3: /* ret/lret */
221 case 0xcb:
222 case 0xc2:
223 case 0xca:
224 regs->eflags &= ~TF_MASK;
225 /* eip is already adjusted, no more changes required*/
226 return;
220 case 0xe8: /* call relative - Fix return addr */ 227 case 0xe8: /* call relative - Fix return addr */
221 *tos = orig_eip + (*tos - copy_eip); 228 *tos = orig_eip + (*tos - copy_eip);
222 break; 229 break;
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 2f89d000f954..2c0ee9c2d020 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -102,20 +102,21 @@ int nmi_active;
102 (P4_CCCR_OVF_PMI0|P4_CCCR_THRESHOLD(15)|P4_CCCR_COMPLEMENT| \ 102 (P4_CCCR_OVF_PMI0|P4_CCCR_THRESHOLD(15)|P4_CCCR_COMPLEMENT| \
103 P4_CCCR_COMPARE|P4_CCCR_REQUIRED|P4_CCCR_ESCR_SELECT(4)|P4_CCCR_ENABLE) 103 P4_CCCR_COMPARE|P4_CCCR_REQUIRED|P4_CCCR_ESCR_SELECT(4)|P4_CCCR_ENABLE)
104 104
105int __init check_nmi_watchdog (void) 105static int __init check_nmi_watchdog(void)
106{ 106{
107 unsigned int prev_nmi_count[NR_CPUS]; 107 unsigned int prev_nmi_count[NR_CPUS];
108 int cpu; 108 int cpu;
109 109
110 printk(KERN_INFO "testing NMI watchdog ... "); 110 if (nmi_watchdog == NMI_NONE)
111 return 0;
112
113 printk(KERN_INFO "Testing NMI watchdog ... ");
111 114
112 for (cpu = 0; cpu < NR_CPUS; cpu++) 115 for (cpu = 0; cpu < NR_CPUS; cpu++)
113 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count; 116 prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
114 local_irq_enable(); 117 local_irq_enable();
115 mdelay((10*1000)/nmi_hz); // wait 10 ticks 118 mdelay((10*1000)/nmi_hz); // wait 10 ticks
116 119
117 /* FIXME: Only boot CPU is online at this stage. Check CPUs
118 as they come up. */
119 for (cpu = 0; cpu < NR_CPUS; cpu++) { 120 for (cpu = 0; cpu < NR_CPUS; cpu++) {
120#ifdef CONFIG_SMP 121#ifdef CONFIG_SMP
121 /* Check cpu_callin_map here because that is set 122 /* Check cpu_callin_map here because that is set
@@ -139,6 +140,8 @@ int __init check_nmi_watchdog (void)
139 140
140 return 0; 141 return 0;
141} 142}
143/* This needs to happen later in boot so counters are working */
144late_initcall(check_nmi_watchdog);
142 145
143static int __init setup_nmi_watchdog(char *str) 146static int __init setup_nmi_watchdog(char *str)
144{ 147{
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index b2203e21acb3..96e3ea6b17c7 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -400,11 +400,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
400 int err; 400 int err;
401 401
402 childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p->thread_info)) - 1; 402 childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p->thread_info)) - 1;
403 *childregs = *regs;
404 childregs->eax = 0;
405 childregs->esp = esp;
406
407 p->thread.esp = (unsigned long) childregs;
408 /* 403 /*
409 * The below -8 is to reserve 8 bytes on top of the ring0 stack. 404 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
410 * This is necessary to guarantee that the entire "struct pt_regs" 405 * This is necessary to guarantee that the entire "struct pt_regs"
@@ -415,7 +410,13 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
415 * "struct pt_regs" is possible, but they may contain the 410 * "struct pt_regs" is possible, but they may contain the
416 * completely wrong values. 411 * completely wrong values.
417 */ 412 */
418 p->thread.esp0 = (unsigned long) (childregs+1) - 8; 413 childregs = (struct pt_regs *) ((unsigned long) childregs - 8);
414 *childregs = *regs;
415 childregs->eax = 0;
416 childregs->esp = esp;
417
418 p->thread.esp = (unsigned long) childregs;
419 p->thread.esp0 = (unsigned long) (childregs+1);
419 420
420 p->thread.eip = (unsigned long) ret_from_fork; 421 p->thread.eip = (unsigned long) ret_from_fork;
421 422
@@ -611,8 +612,8 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
611 * Save away %fs and %gs. No need to save %es and %ds, as 612 * Save away %fs and %gs. No need to save %es and %ds, as
612 * those are always kernel segments while inside the kernel. 613 * those are always kernel segments while inside the kernel.
613 */ 614 */
614 asm volatile("movl %%fs,%0":"=m" (*(int *)&prev->fs)); 615 asm volatile("mov %%fs,%0":"=m" (prev->fs));
615 asm volatile("movl %%gs,%0":"=m" (*(int *)&prev->gs)); 616 asm volatile("mov %%gs,%0":"=m" (prev->gs));
616 617
617 /* 618 /*
618 * Restore %fs and %gs if needed. 619 * Restore %fs and %gs if needed.
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index b2f17640ceff..e34f651fa13c 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -16,6 +16,7 @@
16#include <linux/security.h> 16#include <linux/security.h>
17#include <linux/audit.h> 17#include <linux/audit.h>
18#include <linux/seccomp.h> 18#include <linux/seccomp.h>
19#include <linux/signal.h>
19 20
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include <asm/pgtable.h> 22#include <asm/pgtable.h>
@@ -511,7 +512,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
511 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 512 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
512 case PTRACE_CONT: /* restart after signal. */ 513 case PTRACE_CONT: /* restart after signal. */
513 ret = -EIO; 514 ret = -EIO;
514 if ((unsigned long) data > _NSIG) 515 if (!valid_signal(data))
515 break; 516 break;
516 if (request == PTRACE_SYSCALL) { 517 if (request == PTRACE_SYSCALL) {
517 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 518 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -543,7 +544,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
543 544
544 case PTRACE_SINGLESTEP: /* set the trap flag. */ 545 case PTRACE_SINGLESTEP: /* set the trap flag. */
545 ret = -EIO; 546 ret = -EIO;
546 if ((unsigned long) data > _NSIG) 547 if (!valid_signal(data))
547 break; 548 break;
548 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 549 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
549 set_singlestep(child); 550 set_singlestep(child);
@@ -682,24 +683,18 @@ void do_syscall_trace(struct pt_regs *regs, int entryexit)
682 /* do the secure computing check first */ 683 /* do the secure computing check first */
683 secure_computing(regs->orig_eax); 684 secure_computing(regs->orig_eax);
684 685
685 if (unlikely(current->audit_context)) { 686 if (unlikely(current->audit_context) && entryexit)
686 if (!entryexit) 687 audit_syscall_exit(current, AUDITSC_RESULT(regs->eax), regs->eax);
687 audit_syscall_entry(current, regs->orig_eax,
688 regs->ebx, regs->ecx,
689 regs->edx, regs->esi);
690 else
691 audit_syscall_exit(current, regs->eax);
692 }
693 688
694 if (!(current->ptrace & PT_PTRACED)) 689 if (!(current->ptrace & PT_PTRACED))
695 return; 690 goto out;
696 691
697 /* Fake a debug trap */ 692 /* Fake a debug trap */
698 if (test_thread_flag(TIF_SINGLESTEP)) 693 if (test_thread_flag(TIF_SINGLESTEP))
699 send_sigtrap(current, regs, 0); 694 send_sigtrap(current, regs, 0);
700 695
701 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 696 if (!test_thread_flag(TIF_SYSCALL_TRACE))
702 return; 697 goto out;
703 698
704 /* the 0x80 provides a way for the tracing parent to distinguish 699 /* the 0x80 provides a way for the tracing parent to distinguish
705 between a syscall stop and SIGTRAP delivery */ 700 between a syscall stop and SIGTRAP delivery */
@@ -714,4 +709,9 @@ void do_syscall_trace(struct pt_regs *regs, int entryexit)
714 send_sig(current->exit_code, current, 1); 709 send_sig(current->exit_code, current, 1);
715 current->exit_code = 0; 710 current->exit_code = 0;
716 } 711 }
712 out:
713 if (unlikely(current->audit_context) && !entryexit)
714 audit_syscall_entry(current, AUDIT_ARCH_I386, regs->orig_eax,
715 regs->ebx, regs->ecx, regs->edx, regs->esi);
716
717} 717}
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 3d7e994563df..6dc27eb70ee7 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -13,6 +13,7 @@
13#include <asm/uaccess.h> 13#include <asm/uaccess.h>
14#include <asm/apic.h> 14#include <asm/apic.h>
15#include "mach_reboot.h" 15#include "mach_reboot.h"
16#include <linux/reboot_fixups.h>
16 17
17/* 18/*
18 * Power off function, if any 19 * Power off function, if any
@@ -348,6 +349,7 @@ void machine_restart(char * __unused)
348 /* rebooting needs to touch the page at absolute addr 0 */ 349 /* rebooting needs to touch the page at absolute addr 0 */
349 *((unsigned short *)__va(0x472)) = reboot_mode; 350 *((unsigned short *)__va(0x472)) = reboot_mode;
350 for (;;) { 351 for (;;) {
352 mach_reboot_fixups(); /* for board specific fixups */
351 mach_reboot(); 353 mach_reboot();
352 /* That didn't work - force a triple fault.. */ 354 /* That didn't work - force a triple fault.. */
353 __asm__ __volatile__("lidt %0": :"m" (no_idt)); 355 __asm__ __volatile__("lidt %0": :"m" (no_idt));
diff --git a/arch/i386/kernel/reboot_fixups.c b/arch/i386/kernel/reboot_fixups.c
new file mode 100644
index 000000000000..1b183b378c2c
--- /dev/null
+++ b/arch/i386/kernel/reboot_fixups.c
@@ -0,0 +1,56 @@
1/*
2 * linux/arch/i386/kernel/reboot_fixups.c
3 *
4 * This is a good place to put board specific reboot fixups.
5 *
6 * List of supported fixups:
7 * geode-gx1/cs5530a - Jaya Kumar <jayalk@intworks.biz>
8 *
9 */
10
11#include <asm/delay.h>
12#include <linux/pci.h>
13
14static void cs5530a_warm_reset(struct pci_dev *dev)
15{
16 /* writing 1 to the reset control register, 0x44 causes the
17 cs5530a to perform a system warm reset */
18 pci_write_config_byte(dev, 0x44, 0x1);
19 udelay(50); /* shouldn't get here but be safe and spin-a-while */
20 return;
21}
22
23struct device_fixup {
24 unsigned int vendor;
25 unsigned int device;
26 void (*reboot_fixup)(struct pci_dev *);
27};
28
29static struct device_fixup fixups_table[] = {
30{ PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, cs5530a_warm_reset },
31};
32
33/*
34 * we see if any fixup is available for our current hardware. if there
35 * is a fixup, we call it and we expect to never return from it. if we
36 * do return, we keep looking and then eventually fall back to the
37 * standard mach_reboot on return.
38 */
39void mach_reboot_fixups(void)
40{
41 struct device_fixup *cur;
42 struct pci_dev *dev;
43 int i;
44
45 for (i=0; i < (sizeof(fixups_table)/sizeof(fixups_table[0])); i++) {
46 cur = &(fixups_table[i]);
47 dev = pci_get_device(cur->vendor, cur->device, 0);
48 if (!dev)
49 continue;
50
51 cur->reboot_fixup(dev);
52 }
53
54 printk(KERN_WARNING "No reboot fixup found for your hardware\n");
55}
56
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index fd36d2f65f88..cbea7ac582e5 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -1089,9 +1089,6 @@ static void __init smp_boot_cpus(unsigned int max_cpus)
1089 } 1089 }
1090 } 1090 }
1091 1091
1092 if (nmi_watchdog == NMI_LOCAL_APIC)
1093 check_nmi_watchdog();
1094
1095 smpboot_setup_io_apic(); 1092 smpboot_setup_io_apic();
1096 1093
1097 setup_boot_APIC_clock(); 1094 setup_boot_APIC_clock();
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
new file mode 100644
index 000000000000..6cd1ed311f02
--- /dev/null
+++ b/arch/i386/kernel/syscall_table.S
@@ -0,0 +1,291 @@
1.data
2ENTRY(sys_call_table)
3 .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */
4 .long sys_exit
5 .long sys_fork
6 .long sys_read
7 .long sys_write
8 .long sys_open /* 5 */
9 .long sys_close
10 .long sys_waitpid
11 .long sys_creat
12 .long sys_link
13 .long sys_unlink /* 10 */
14 .long sys_execve
15 .long sys_chdir
16 .long sys_time
17 .long sys_mknod
18 .long sys_chmod /* 15 */
19 .long sys_lchown16
20 .long sys_ni_syscall /* old break syscall holder */
21 .long sys_stat
22 .long sys_lseek
23 .long sys_getpid /* 20 */
24 .long sys_mount
25 .long sys_oldumount
26 .long sys_setuid16
27 .long sys_getuid16
28 .long sys_stime /* 25 */
29 .long sys_ptrace
30 .long sys_alarm
31 .long sys_fstat
32 .long sys_pause
33 .long sys_utime /* 30 */
34 .long sys_ni_syscall /* old stty syscall holder */
35 .long sys_ni_syscall /* old gtty syscall holder */
36 .long sys_access
37 .long sys_nice
38 .long sys_ni_syscall /* 35 - old ftime syscall holder */
39 .long sys_sync
40 .long sys_kill
41 .long sys_rename
42 .long sys_mkdir
43 .long sys_rmdir /* 40 */
44 .long sys_dup
45 .long sys_pipe
46 .long sys_times
47 .long sys_ni_syscall /* old prof syscall holder */
48 .long sys_brk /* 45 */
49 .long sys_setgid16
50 .long sys_getgid16
51 .long sys_signal
52 .long sys_geteuid16
53 .long sys_getegid16 /* 50 */
54 .long sys_acct
55 .long sys_umount /* recycled never used phys() */
56 .long sys_ni_syscall /* old lock syscall holder */
57 .long sys_ioctl
58 .long sys_fcntl /* 55 */
59 .long sys_ni_syscall /* old mpx syscall holder */
60 .long sys_setpgid
61 .long sys_ni_syscall /* old ulimit syscall holder */
62 .long sys_olduname
63 .long sys_umask /* 60 */
64 .long sys_chroot
65 .long sys_ustat
66 .long sys_dup2
67 .long sys_getppid
68 .long sys_getpgrp /* 65 */
69 .long sys_setsid
70 .long sys_sigaction
71 .long sys_sgetmask
72 .long sys_ssetmask
73 .long sys_setreuid16 /* 70 */
74 .long sys_setregid16
75 .long sys_sigsuspend
76 .long sys_sigpending
77 .long sys_sethostname
78 .long sys_setrlimit /* 75 */
79 .long sys_old_getrlimit
80 .long sys_getrusage
81 .long sys_gettimeofday
82 .long sys_settimeofday
83 .long sys_getgroups16 /* 80 */
84 .long sys_setgroups16
85 .long old_select
86 .long sys_symlink
87 .long sys_lstat
88 .long sys_readlink /* 85 */
89 .long sys_uselib
90 .long sys_swapon
91 .long sys_reboot
92 .long old_readdir
93 .long old_mmap /* 90 */
94 .long sys_munmap
95 .long sys_truncate
96 .long sys_ftruncate
97 .long sys_fchmod
98 .long sys_fchown16 /* 95 */
99 .long sys_getpriority
100 .long sys_setpriority
101 .long sys_ni_syscall /* old profil syscall holder */
102 .long sys_statfs
103 .long sys_fstatfs /* 100 */
104 .long sys_ioperm
105 .long sys_socketcall
106 .long sys_syslog
107 .long sys_setitimer
108 .long sys_getitimer /* 105 */
109 .long sys_newstat
110 .long sys_newlstat
111 .long sys_newfstat
112 .long sys_uname
113 .long sys_iopl /* 110 */
114 .long sys_vhangup
115 .long sys_ni_syscall /* old "idle" system call */
116 .long sys_vm86old
117 .long sys_wait4
118 .long sys_swapoff /* 115 */
119 .long sys_sysinfo
120 .long sys_ipc
121 .long sys_fsync
122 .long sys_sigreturn
123 .long sys_clone /* 120 */
124 .long sys_setdomainname
125 .long sys_newuname
126 .long sys_modify_ldt
127 .long sys_adjtimex
128 .long sys_mprotect /* 125 */
129 .long sys_sigprocmask
130 .long sys_ni_syscall /* old "create_module" */
131 .long sys_init_module
132 .long sys_delete_module
133 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
134 .long sys_quotactl
135 .long sys_getpgid
136 .long sys_fchdir
137 .long sys_bdflush
138 .long sys_sysfs /* 135 */
139 .long sys_personality
140 .long sys_ni_syscall /* reserved for afs_syscall */
141 .long sys_setfsuid16
142 .long sys_setfsgid16
143 .long sys_llseek /* 140 */
144 .long sys_getdents
145 .long sys_select
146 .long sys_flock
147 .long sys_msync
148 .long sys_readv /* 145 */
149 .long sys_writev
150 .long sys_getsid
151 .long sys_fdatasync
152 .long sys_sysctl
153 .long sys_mlock /* 150 */
154 .long sys_munlock
155 .long sys_mlockall
156 .long sys_munlockall
157 .long sys_sched_setparam
158 .long sys_sched_getparam /* 155 */
159 .long sys_sched_setscheduler
160 .long sys_sched_getscheduler
161 .long sys_sched_yield
162 .long sys_sched_get_priority_max
163 .long sys_sched_get_priority_min /* 160 */
164 .long sys_sched_rr_get_interval
165 .long sys_nanosleep
166 .long sys_mremap
167 .long sys_setresuid16
168 .long sys_getresuid16 /* 165 */
169 .long sys_vm86
170 .long sys_ni_syscall /* Old sys_query_module */
171 .long sys_poll
172 .long sys_nfsservctl
173 .long sys_setresgid16 /* 170 */
174 .long sys_getresgid16
175 .long sys_prctl
176 .long sys_rt_sigreturn
177 .long sys_rt_sigaction
178 .long sys_rt_sigprocmask /* 175 */
179 .long sys_rt_sigpending
180 .long sys_rt_sigtimedwait
181 .long sys_rt_sigqueueinfo
182 .long sys_rt_sigsuspend
183 .long sys_pread64 /* 180 */
184 .long sys_pwrite64
185 .long sys_chown16
186 .long sys_getcwd
187 .long sys_capget
188 .long sys_capset /* 185 */
189 .long sys_sigaltstack
190 .long sys_sendfile
191 .long sys_ni_syscall /* reserved for streams1 */
192 .long sys_ni_syscall /* reserved for streams2 */
193 .long sys_vfork /* 190 */
194 .long sys_getrlimit
195 .long sys_mmap2
196 .long sys_truncate64
197 .long sys_ftruncate64
198 .long sys_stat64 /* 195 */
199 .long sys_lstat64
200 .long sys_fstat64
201 .long sys_lchown
202 .long sys_getuid
203 .long sys_getgid /* 200 */
204 .long sys_geteuid
205 .long sys_getegid
206 .long sys_setreuid
207 .long sys_setregid
208 .long sys_getgroups /* 205 */
209 .long sys_setgroups
210 .long sys_fchown
211 .long sys_setresuid
212 .long sys_getresuid
213 .long sys_setresgid /* 210 */
214 .long sys_getresgid
215 .long sys_chown
216 .long sys_setuid
217 .long sys_setgid
218 .long sys_setfsuid /* 215 */
219 .long sys_setfsgid
220 .long sys_pivot_root
221 .long sys_mincore
222 .long sys_madvise
223 .long sys_getdents64 /* 220 */
224 .long sys_fcntl64
225 .long sys_ni_syscall /* reserved for TUX */
226 .long sys_ni_syscall
227 .long sys_gettid
228 .long sys_readahead /* 225 */
229 .long sys_setxattr
230 .long sys_lsetxattr
231 .long sys_fsetxattr
232 .long sys_getxattr
233 .long sys_lgetxattr /* 230 */
234 .long sys_fgetxattr
235 .long sys_listxattr
236 .long sys_llistxattr
237 .long sys_flistxattr
238 .long sys_removexattr /* 235 */
239 .long sys_lremovexattr
240 .long sys_fremovexattr
241 .long sys_tkill
242 .long sys_sendfile64
243 .long sys_futex /* 240 */
244 .long sys_sched_setaffinity
245 .long sys_sched_getaffinity
246 .long sys_set_thread_area
247 .long sys_get_thread_area
248 .long sys_io_setup /* 245 */
249 .long sys_io_destroy
250 .long sys_io_getevents
251 .long sys_io_submit
252 .long sys_io_cancel
253 .long sys_fadvise64 /* 250 */
254 .long sys_ni_syscall
255 .long sys_exit_group
256 .long sys_lookup_dcookie
257 .long sys_epoll_create
258 .long sys_epoll_ctl /* 255 */
259 .long sys_epoll_wait
260 .long sys_remap_file_pages
261 .long sys_set_tid_address
262 .long sys_timer_create
263 .long sys_timer_settime /* 260 */
264 .long sys_timer_gettime
265 .long sys_timer_getoverrun
266 .long sys_timer_delete
267 .long sys_clock_settime
268 .long sys_clock_gettime /* 265 */
269 .long sys_clock_getres
270 .long sys_clock_nanosleep
271 .long sys_statfs64
272 .long sys_fstatfs64
273 .long sys_tgkill /* 270 */
274 .long sys_utimes
275 .long sys_fadvise64_64
276 .long sys_ni_syscall /* sys_vserver */
277 .long sys_mbind
278 .long sys_get_mempolicy
279 .long sys_set_mempolicy
280 .long sys_mq_open
281 .long sys_mq_unlink
282 .long sys_mq_timedsend
283 .long sys_mq_timedreceive /* 280 */
284 .long sys_mq_notify
285 .long sys_mq_getsetattr
286 .long sys_ni_syscall /* reserved for kexec */
287 .long sys_waitid
288 .long sys_ni_syscall /* 285 */ /* available */
289 .long sys_add_key
290 .long sys_request_key
291 .long sys_keyctl
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 4d75b373f90e..a0dcb7c87c30 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -441,7 +441,7 @@ static void __init hpet_time_init(void)
441 set_normalized_timespec(&wall_to_monotonic, 441 set_normalized_timespec(&wall_to_monotonic,
442 -xtime.tv_sec, -xtime.tv_nsec); 442 -xtime.tv_sec, -xtime.tv_nsec);
443 443
444 if (hpet_enable() >= 0) { 444 if ((hpet_enable() >= 0) && hpet_use_timer) {
445 printk("Using HPET for base-timer\n"); 445 printk("Using HPET for base-timer\n");
446 } 446 }
447 447
diff --git a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
index 244a31b04be7..10a0cbb88e75 100644
--- a/arch/i386/kernel/time_hpet.c
+++ b/arch/i386/kernel/time_hpet.c
@@ -26,6 +26,7 @@
26static unsigned long hpet_period; /* fsecs / HPET clock */ 26static unsigned long hpet_period; /* fsecs / HPET clock */
27unsigned long hpet_tick; /* hpet clks count per tick */ 27unsigned long hpet_tick; /* hpet clks count per tick */
28unsigned long hpet_address; /* hpet memory map physical address */ 28unsigned long hpet_address; /* hpet memory map physical address */
29int hpet_use_timer;
29 30
30static int use_hpet; /* can be used for runtime check of hpet */ 31static int use_hpet; /* can be used for runtime check of hpet */
31static int boot_hpet_disable; /* boottime override for HPET timer */ 32static int boot_hpet_disable; /* boottime override for HPET timer */
@@ -73,27 +74,30 @@ static int hpet_timer_stop_set_go(unsigned long tick)
73 hpet_writel(0, HPET_COUNTER); 74 hpet_writel(0, HPET_COUNTER);
74 hpet_writel(0, HPET_COUNTER + 4); 75 hpet_writel(0, HPET_COUNTER + 4);
75 76
76 /* 77 if (hpet_use_timer) {
77 * Set up timer 0, as periodic with first interrupt to happen at 78 /*
78 * hpet_tick, and period also hpet_tick. 79 * Set up timer 0, as periodic with first interrupt to happen at
79 */ 80 * hpet_tick, and period also hpet_tick.
80 cfg = hpet_readl(HPET_T0_CFG); 81 */
81 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | 82 cfg = hpet_readl(HPET_T0_CFG);
82 HPET_TN_SETVAL | HPET_TN_32BIT; 83 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
83 hpet_writel(cfg, HPET_T0_CFG); 84 HPET_TN_SETVAL | HPET_TN_32BIT;
84 85 hpet_writel(cfg, HPET_T0_CFG);
85 /*
86 * The first write after writing TN_SETVAL to the config register sets
87 * the counter value, the second write sets the threshold.
88 */
89 hpet_writel(tick, HPET_T0_CMP);
90 hpet_writel(tick, HPET_T0_CMP);
91 86
87 /*
88 * The first write after writing TN_SETVAL to the config register sets
89 * the counter value, the second write sets the threshold.
90 */
91 hpet_writel(tick, HPET_T0_CMP);
92 hpet_writel(tick, HPET_T0_CMP);
93 }
92 /* 94 /*
93 * Go! 95 * Go!
94 */ 96 */
95 cfg = hpet_readl(HPET_CFG); 97 cfg = hpet_readl(HPET_CFG);
96 cfg |= HPET_CFG_ENABLE | HPET_CFG_LEGACY; 98 if (hpet_use_timer)
99 cfg |= HPET_CFG_LEGACY;
100 cfg |= HPET_CFG_ENABLE;
97 hpet_writel(cfg, HPET_CFG); 101 hpet_writel(cfg, HPET_CFG);
98 102
99 return 0; 103 return 0;
@@ -128,12 +132,11 @@ int __init hpet_enable(void)
128 * However, we can do with one timer otherwise using the 132 * However, we can do with one timer otherwise using the
129 * the single HPET timer for system time. 133 * the single HPET timer for system time.
130 */ 134 */
131 if (
132#ifdef CONFIG_HPET_EMULATE_RTC 135#ifdef CONFIG_HPET_EMULATE_RTC
133 !(id & HPET_ID_NUMBER) || 136 if (!(id & HPET_ID_NUMBER))
134#endif
135 !(id & HPET_ID_LEGSUP))
136 return -1; 137 return -1;
138#endif
139
137 140
138 hpet_period = hpet_readl(HPET_PERIOD); 141 hpet_period = hpet_readl(HPET_PERIOD);
139 if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD)) 142 if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD))
@@ -152,6 +155,8 @@ int __init hpet_enable(void)
152 if (hpet_tick_rem > (hpet_period >> 1)) 155 if (hpet_tick_rem > (hpet_period >> 1))
153 hpet_tick++; /* rounding the result */ 156 hpet_tick++; /* rounding the result */
154 157
158 hpet_use_timer = id & HPET_ID_LEGSUP;
159
155 if (hpet_timer_stop_set_go(hpet_tick)) 160 if (hpet_timer_stop_set_go(hpet_tick))
156 return -1; 161 return -1;
157 162
@@ -202,7 +207,8 @@ int __init hpet_enable(void)
202#endif 207#endif
203 208
204#ifdef CONFIG_X86_LOCAL_APIC 209#ifdef CONFIG_X86_LOCAL_APIC
205 wait_timer_tick = wait_hpet_tick; 210 if (hpet_use_timer)
211 wait_timer_tick = wait_hpet_tick;
206#endif 212#endif
207 return 0; 213 return 0;
208} 214}
diff --git a/arch/i386/kernel/timers/timer_hpet.c b/arch/i386/kernel/timers/timer_hpet.c
index 713134e71844..f778f471a09a 100644
--- a/arch/i386/kernel/timers/timer_hpet.c
+++ b/arch/i386/kernel/timers/timer_hpet.c
@@ -79,7 +79,7 @@ static unsigned long get_offset_hpet(void)
79 79
80 eax = hpet_readl(HPET_COUNTER); 80 eax = hpet_readl(HPET_COUNTER);
81 eax -= hpet_last; /* hpet delta */ 81 eax -= hpet_last; /* hpet delta */
82 82 eax = min(hpet_tick, eax);
83 /* 83 /*
84 * Time offset = (hpet delta) * ( usecs per HPET clock ) 84 * Time offset = (hpet delta) * ( usecs per HPET clock )
85 * = (hpet delta) * ( usecs per tick / HPET clocks per tick) 85 * = (hpet delta) * ( usecs per tick / HPET clocks per tick)
@@ -105,9 +105,12 @@ static void mark_offset_hpet(void)
105 last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low; 105 last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
106 rdtsc(last_tsc_low, last_tsc_high); 106 rdtsc(last_tsc_low, last_tsc_high);
107 107
108 offset = hpet_readl(HPET_T0_CMP) - hpet_tick; 108 if (hpet_use_timer)
109 if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) { 109 offset = hpet_readl(HPET_T0_CMP) - hpet_tick;
110 int lost_ticks = (offset - hpet_last) / hpet_tick; 110 else
111 offset = hpet_readl(HPET_COUNTER);
112 if (unlikely(((offset - hpet_last) >= (2*hpet_tick)) && (hpet_last != 0))) {
113 int lost_ticks = ((offset - hpet_last) / hpet_tick) - 1;
111 jiffies_64 += lost_ticks; 114 jiffies_64 += lost_ticks;
112 } 115 }
113 hpet_last = offset; 116 hpet_last = offset;
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
index a685994e5c8e..7926d967be00 100644
--- a/arch/i386/kernel/timers/timer_tsc.c
+++ b/arch/i386/kernel/timers/timer_tsc.c
@@ -477,7 +477,7 @@ static int __init init_tsc(char* override)
477 if (cpu_has_tsc) { 477 if (cpu_has_tsc) {
478 unsigned long tsc_quotient; 478 unsigned long tsc_quotient;
479#ifdef CONFIG_HPET_TIMER 479#ifdef CONFIG_HPET_TIMER
480 if (is_hpet_enabled()){ 480 if (is_hpet_enabled() && hpet_use_timer) {
481 unsigned long result, remain; 481 unsigned long result, remain;
482 printk("Using TSC for gettimeofday\n"); 482 printk("Using TSC for gettimeofday\n");
483 tsc_quotient = calibrate_tsc_hpet(NULL); 483 tsc_quotient = calibrate_tsc_hpet(NULL);
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 6c0e383915b6..00c63419c06f 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -451,6 +451,7 @@ DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
451DO_ERROR(11, SIGBUS, "segment not present", segment_not_present) 451DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
452DO_ERROR(12, SIGBUS, "stack segment", stack_segment) 452DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
453DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0) 453DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
454DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
454 455
455fastcall void do_general_protection(struct pt_regs * regs, long error_code) 456fastcall void do_general_protection(struct pt_regs * regs, long error_code)
456{ 457{
@@ -642,16 +643,15 @@ void unset_nmi_callback(void)
642} 643}
643 644
644#ifdef CONFIG_KPROBES 645#ifdef CONFIG_KPROBES
645fastcall int do_int3(struct pt_regs *regs, long error_code) 646fastcall void do_int3(struct pt_regs *regs, long error_code)
646{ 647{
647 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP) 648 if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
648 == NOTIFY_STOP) 649 == NOTIFY_STOP)
649 return 1; 650 return;
650 /* This is an interrupt gate, because kprobes wants interrupts 651 /* This is an interrupt gate, because kprobes wants interrupts
651 disabled. Normal trap handlers don't. */ 652 disabled. Normal trap handlers don't. */
652 restore_interrupts(regs); 653 restore_interrupts(regs);
653 do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL); 654 do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
654 return 0;
655} 655}
656#endif 656#endif
657 657
diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
index 2f3d52dacff7..ec0f68ce6886 100644
--- a/arch/i386/kernel/vm86.c
+++ b/arch/i386/kernel/vm86.c
@@ -222,7 +222,7 @@ asmlinkage int sys_vm86(struct pt_regs regs)
222 goto out; 222 goto out;
223 case VM86_PLUS_INSTALL_CHECK: 223 case VM86_PLUS_INSTALL_CHECK:
224 /* NOTE: on old vm86 stuff this will return the error 224 /* NOTE: on old vm86 stuff this will return the error
225 from verify_area(), because the subfunction is 225 from access_ok(), because the subfunction is
226 interpreted as (invalid) address to vm86_struct. 226 interpreted as (invalid) address to vm86_struct.
227 So the installation check works. 227 So the installation check works.
228 */ 228 */
@@ -294,8 +294,8 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
294 */ 294 */
295 info->regs32->eax = 0; 295 info->regs32->eax = 0;
296 tsk->thread.saved_esp0 = tsk->thread.esp0; 296 tsk->thread.saved_esp0 = tsk->thread.esp0;
297 asm volatile("movl %%fs,%0":"=m" (tsk->thread.saved_fs)); 297 asm volatile("mov %%fs,%0":"=m" (tsk->thread.saved_fs));
298 asm volatile("movl %%gs,%0":"=m" (tsk->thread.saved_gs)); 298 asm volatile("mov %%gs,%0":"=m" (tsk->thread.saved_gs));
299 299
300 tss = &per_cpu(init_tss, get_cpu()); 300 tss = &per_cpu(init_tss, get_cpu());
301 tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0; 301 tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
@@ -717,12 +717,12 @@ static irqreturn_t irq_handler(int intno, void *dev_id, struct pt_regs * regs)
717 irqbits |= irq_bit; 717 irqbits |= irq_bit;
718 if (vm86_irqs[intno].sig) 718 if (vm86_irqs[intno].sig)
719 send_sig(vm86_irqs[intno].sig, vm86_irqs[intno].tsk, 1); 719 send_sig(vm86_irqs[intno].sig, vm86_irqs[intno].tsk, 1);
720 spin_unlock_irqrestore(&irqbits_lock, flags);
721 /* 720 /*
722 * IRQ will be re-enabled when user asks for the irq (whether 721 * IRQ will be re-enabled when user asks for the irq (whether
723 * polling or as a result of the signal) 722 * polling or as a result of the signal)
724 */ 723 */
725 disable_irq(intno); 724 disable_irq_nosync(intno);
725 spin_unlock_irqrestore(&irqbits_lock, flags);
726 return IRQ_HANDLED; 726 return IRQ_HANDLED;
727 727
728out: 728out:
@@ -754,17 +754,20 @@ static inline int get_and_reset_irq(int irqnumber)
754{ 754{
755 int bit; 755 int bit;
756 unsigned long flags; 756 unsigned long flags;
757 int ret = 0;
757 758
758 if (invalid_vm86_irq(irqnumber)) return 0; 759 if (invalid_vm86_irq(irqnumber)) return 0;
759 if (vm86_irqs[irqnumber].tsk != current) return 0; 760 if (vm86_irqs[irqnumber].tsk != current) return 0;
760 spin_lock_irqsave(&irqbits_lock, flags); 761 spin_lock_irqsave(&irqbits_lock, flags);
761 bit = irqbits & (1 << irqnumber); 762 bit = irqbits & (1 << irqnumber);
762 irqbits &= ~bit; 763 irqbits &= ~bit;
764 if (bit) {
765 enable_irq(irqnumber);
766 ret = 1;
767 }
768
763 spin_unlock_irqrestore(&irqbits_lock, flags); 769 spin_unlock_irqrestore(&irqbits_lock, flags);
764 if (!bit) 770 return ret;
765 return 0;
766 enable_irq(irqnumber);
767 return 1;
768} 771}
769 772
770 773
diff --git a/arch/i386/oprofile/nmi_timer_int.c b/arch/i386/oprofile/nmi_timer_int.c
index b2e462abf337..c58d0c14f274 100644
--- a/arch/i386/oprofile/nmi_timer_int.c
+++ b/arch/i386/oprofile/nmi_timer_int.c
@@ -36,7 +36,7 @@ static void timer_stop(void)
36{ 36{
37 enable_timer_nmi_watchdog(); 37 enable_timer_nmi_watchdog();
38 unset_nmi_callback(); 38 unset_nmi_callback();
39 synchronize_kernel(); 39 synchronize_sched(); /* Allow already-started NMIs to complete. */
40} 40}
41 41
42 42
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index e07589d04f64..d6598da4b67b 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -495,6 +495,8 @@ static __init int intel_router_probe(struct irq_router *r, struct pci_dev *route
495 case PCI_DEVICE_ID_INTEL_ICH6_1: 495 case PCI_DEVICE_ID_INTEL_ICH6_1:
496 case PCI_DEVICE_ID_INTEL_ICH7_0: 496 case PCI_DEVICE_ID_INTEL_ICH7_0:
497 case PCI_DEVICE_ID_INTEL_ICH7_1: 497 case PCI_DEVICE_ID_INTEL_ICH7_1:
498 case PCI_DEVICE_ID_INTEL_ICH7_30:
499 case PCI_DEVICE_ID_INTEL_ICH7_31:
498 case PCI_DEVICE_ID_INTEL_ESB2_0: 500 case PCI_DEVICE_ID_INTEL_ESB2_0:
499 r->name = "PIIX/ICH"; 501 r->name = "PIIX/ICH";
500 r->get = pirq_piix_get; 502 r->get = pirq_piix_get;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 33fcb205fcb7..3ad2c4af099c 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -46,6 +46,10 @@ config GENERIC_IOMAP
46 bool 46 bool
47 default y 47 default y
48 48
49config SCHED_NO_NO_OMIT_FRAME_POINTER
50 bool
51 default y
52
49choice 53choice
50 prompt "System type" 54 prompt "System type"
51 default IA64_GENERIC 55 default IA64_GENERIC
@@ -217,6 +221,16 @@ config IA64_SGI_SN_SIM
217 If you are compiling a kernel that will run under SGI's IA-64 221 If you are compiling a kernel that will run under SGI's IA-64
218 simulator (Medusa) then say Y, otherwise say N. 222 simulator (Medusa) then say Y, otherwise say N.
219 223
224config IA64_SGI_SN_XP
225 tristate "Support communication between SGI SSIs"
226 depends on MSPEC
227 help
228 An SGI machine can be divided into multiple Single System
229 Images which act independently of each other and have
230 hardware based memory protection from the others. Enabling
231 this feature will allow for direct communication between SSIs
232 based on a network adapter and DMA messaging.
233
220config FORCE_MAX_ZONEORDER 234config FORCE_MAX_ZONEORDER
221 int 235 int
222 default "18" 236 default "18"
@@ -261,6 +275,15 @@ config HOTPLUG_CPU
261 can be controlled through /sys/devices/system/cpu/cpu#. 275 can be controlled through /sys/devices/system/cpu/cpu#.
262 Say N if you want to disable CPU hotplug. 276 Say N if you want to disable CPU hotplug.
263 277
278config SCHED_SMT
279 bool "SMT scheduler support"
280 depends on SMP
281 default off
282 help
283 Improves the CPU scheduler's decision making when dealing with
284 Intel IA64 chips with MultiThreading at a cost of slightly increased
285 overhead in some places. If unsure say N here.
286
264config PREEMPT 287config PREEMPT
265 bool "Preemptible Kernel" 288 bool "Preemptible Kernel"
266 help 289 help
@@ -329,7 +352,7 @@ menu "Power management and ACPI"
329 352
330config PM 353config PM
331 bool "Power Management support" 354 bool "Power Management support"
332 depends on IA64_GENERIC || IA64_DIG || IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB 355 depends on !IA64_HP_SIM
333 default y 356 default y
334 help 357 help
335 "Power Management" means that parts of your computer are shut 358 "Power Management" means that parts of your computer are shut
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index bfeb952fe8e2..6ff7107fee4d 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -574,6 +574,8 @@ CONFIG_SERIAL_NONSTANDARD=y
574# CONFIG_N_HDLC is not set 574# CONFIG_N_HDLC is not set
575# CONFIG_STALDRV is not set 575# CONFIG_STALDRV is not set
576CONFIG_SGI_SNSC=y 576CONFIG_SGI_SNSC=y
577CONFIG_SGI_TIOCX=y
578CONFIG_SGI_MBCS=m
577 579
578# 580#
579# Serial drivers 581# Serial drivers
diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig
index 99830e8fc9ba..9086b789f6ac 100644
--- a/arch/ia64/configs/tiger_defconfig
+++ b/arch/ia64/configs/tiger_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.11-rc2 3# Linux kernel version: 2.6.12-rc3
4# Sat Jan 22 11:17:02 2005 4# Tue May 3 15:55:04 2005
5# 5#
6 6
7# 7#
@@ -10,6 +10,7 @@
10CONFIG_EXPERIMENTAL=y 10CONFIG_EXPERIMENTAL=y
11CONFIG_CLEAN_COMPILE=y 11CONFIG_CLEAN_COMPILE=y
12CONFIG_LOCK_KERNEL=y 12CONFIG_LOCK_KERNEL=y
13CONFIG_INIT_ENV_ARG_LIMIT=32
13 14
14# 15#
15# General setup 16# General setup
@@ -21,24 +22,27 @@ CONFIG_POSIX_MQUEUE=y
21# CONFIG_BSD_PROCESS_ACCT is not set 22# CONFIG_BSD_PROCESS_ACCT is not set
22CONFIG_SYSCTL=y 23CONFIG_SYSCTL=y
23# CONFIG_AUDIT is not set 24# CONFIG_AUDIT is not set
24CONFIG_LOG_BUF_SHIFT=20
25CONFIG_HOTPLUG=y 25CONFIG_HOTPLUG=y
26CONFIG_KOBJECT_UEVENT=y 26CONFIG_KOBJECT_UEVENT=y
27CONFIG_IKCONFIG=y 27CONFIG_IKCONFIG=y
28CONFIG_IKCONFIG_PROC=y 28CONFIG_IKCONFIG_PROC=y
29# CONFIG_CPUSETS is not set
29# CONFIG_EMBEDDED is not set 30# CONFIG_EMBEDDED is not set
30CONFIG_KALLSYMS=y 31CONFIG_KALLSYMS=y
31CONFIG_KALLSYMS_ALL=y 32CONFIG_KALLSYMS_ALL=y
32# CONFIG_KALLSYMS_EXTRA_PASS is not set 33# CONFIG_KALLSYMS_EXTRA_PASS is not set
34CONFIG_PRINTK=y
35CONFIG_BUG=y
36CONFIG_BASE_FULL=y
33CONFIG_FUTEX=y 37CONFIG_FUTEX=y
34CONFIG_EPOLL=y 38CONFIG_EPOLL=y
35# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
36CONFIG_SHMEM=y 39CONFIG_SHMEM=y
37CONFIG_CC_ALIGN_FUNCTIONS=0 40CONFIG_CC_ALIGN_FUNCTIONS=0
38CONFIG_CC_ALIGN_LABELS=0 41CONFIG_CC_ALIGN_LABELS=0
39CONFIG_CC_ALIGN_LOOPS=0 42CONFIG_CC_ALIGN_LOOPS=0
40CONFIG_CC_ALIGN_JUMPS=0 43CONFIG_CC_ALIGN_JUMPS=0
41# CONFIG_TINY_SHMEM is not set 44# CONFIG_TINY_SHMEM is not set
45CONFIG_BASE_SMALL=0
42 46
43# 47#
44# Loadable module support 48# Loadable module support
@@ -85,6 +89,7 @@ CONFIG_FORCE_MAX_ZONEORDER=18
85CONFIG_SMP=y 89CONFIG_SMP=y
86CONFIG_NR_CPUS=4 90CONFIG_NR_CPUS=4
87CONFIG_HOTPLUG_CPU=y 91CONFIG_HOTPLUG_CPU=y
92# CONFIG_SCHED_SMT is not set
88# CONFIG_PREEMPT is not set 93# CONFIG_PREEMPT is not set
89CONFIG_HAVE_DEC_LOCK=y 94CONFIG_HAVE_DEC_LOCK=y
90CONFIG_IA32_SUPPORT=y 95CONFIG_IA32_SUPPORT=y
@@ -135,6 +140,7 @@ CONFIG_PCI_DOMAINS=y
135# CONFIG_PCI_MSI is not set 140# CONFIG_PCI_MSI is not set
136CONFIG_PCI_LEGACY_PROC=y 141CONFIG_PCI_LEGACY_PROC=y
137CONFIG_PCI_NAMES=y 142CONFIG_PCI_NAMES=y
143# CONFIG_PCI_DEBUG is not set
138 144
139# 145#
140# PCI Hotplug Support 146# PCI Hotplug Support
@@ -152,10 +158,6 @@ CONFIG_HOTPLUG_PCI_ACPI=m
152# CONFIG_PCCARD is not set 158# CONFIG_PCCARD is not set
153 159
154# 160#
155# PC-card bridges
156#
157
158#
159# Device Drivers 161# Device Drivers
160# 162#
161 163
@@ -195,9 +197,10 @@ CONFIG_BLK_DEV_CRYPTOLOOP=m
195CONFIG_BLK_DEV_NBD=m 197CONFIG_BLK_DEV_NBD=m
196# CONFIG_BLK_DEV_SX8 is not set 198# CONFIG_BLK_DEV_SX8 is not set
197# CONFIG_BLK_DEV_UB is not set 199# CONFIG_BLK_DEV_UB is not set
198CONFIG_BLK_DEV_RAM=m 200CONFIG_BLK_DEV_RAM=y
199CONFIG_BLK_DEV_RAM_COUNT=16 201CONFIG_BLK_DEV_RAM_COUNT=16
200CONFIG_BLK_DEV_RAM_SIZE=4096 202CONFIG_BLK_DEV_RAM_SIZE=4096
203CONFIG_BLK_DEV_INITRD=y
201CONFIG_INITRAMFS_SOURCE="" 204CONFIG_INITRAMFS_SOURCE=""
202# CONFIG_CDROM_PKTCDVD is not set 205# CONFIG_CDROM_PKTCDVD is not set
203 206
@@ -313,7 +316,6 @@ CONFIG_SCSI_FC_ATTRS=y
313# CONFIG_SCSI_BUSLOGIC is not set 316# CONFIG_SCSI_BUSLOGIC is not set
314# CONFIG_SCSI_DMX3191D is not set 317# CONFIG_SCSI_DMX3191D is not set
315# CONFIG_SCSI_EATA is not set 318# CONFIG_SCSI_EATA is not set
316# CONFIG_SCSI_EATA_PIO is not set
317# CONFIG_SCSI_FUTURE_DOMAIN is not set 319# CONFIG_SCSI_FUTURE_DOMAIN is not set
318# CONFIG_SCSI_GDTH is not set 320# CONFIG_SCSI_GDTH is not set
319# CONFIG_SCSI_IPS is not set 321# CONFIG_SCSI_IPS is not set
@@ -325,7 +327,6 @@ CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
325CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 327CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
326# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set 328# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
327# CONFIG_SCSI_IPR is not set 329# CONFIG_SCSI_IPR is not set
328# CONFIG_SCSI_QLOGIC_ISP is not set
329CONFIG_SCSI_QLOGIC_FC=y 330CONFIG_SCSI_QLOGIC_FC=y
330# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set 331# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set
331CONFIG_SCSI_QLOGIC_1280=y 332CONFIG_SCSI_QLOGIC_1280=y
@@ -336,6 +337,7 @@ CONFIG_SCSI_QLA22XX=m
336CONFIG_SCSI_QLA2300=m 337CONFIG_SCSI_QLA2300=m
337CONFIG_SCSI_QLA2322=m 338CONFIG_SCSI_QLA2322=m
338# CONFIG_SCSI_QLA6312 is not set 339# CONFIG_SCSI_QLA6312 is not set
340# CONFIG_SCSI_LPFC is not set
339# CONFIG_SCSI_DC395x is not set 341# CONFIG_SCSI_DC395x is not set
340# CONFIG_SCSI_DC390T is not set 342# CONFIG_SCSI_DC390T is not set
341# CONFIG_SCSI_DEBUG is not set 343# CONFIG_SCSI_DEBUG is not set
@@ -358,6 +360,7 @@ CONFIG_DM_CRYPT=m
358CONFIG_DM_SNAPSHOT=m 360CONFIG_DM_SNAPSHOT=m
359CONFIG_DM_MIRROR=m 361CONFIG_DM_MIRROR=m
360CONFIG_DM_ZERO=m 362CONFIG_DM_ZERO=m
363# CONFIG_DM_MULTIPATH is not set
361 364
362# 365#
363# Fusion MPT device support 366# Fusion MPT device support
@@ -386,7 +389,6 @@ CONFIG_NET=y
386# 389#
387CONFIG_PACKET=y 390CONFIG_PACKET=y
388# CONFIG_PACKET_MMAP is not set 391# CONFIG_PACKET_MMAP is not set
389CONFIG_NETLINK_DEV=y
390CONFIG_UNIX=y 392CONFIG_UNIX=y
391# CONFIG_NET_KEY is not set 393# CONFIG_NET_KEY is not set
392CONFIG_INET=y 394CONFIG_INET=y
@@ -446,7 +448,6 @@ CONFIG_DUMMY=m
446# CONFIG_BONDING is not set 448# CONFIG_BONDING is not set
447# CONFIG_EQUALIZER is not set 449# CONFIG_EQUALIZER is not set
448# CONFIG_TUN is not set 450# CONFIG_TUN is not set
449# CONFIG_ETHERTAP is not set
450 451
451# 452#
452# ARCnet devices 453# ARCnet devices
@@ -484,7 +485,6 @@ CONFIG_NET_PCI=y
484# CONFIG_DGRS is not set 485# CONFIG_DGRS is not set
485CONFIG_EEPRO100=m 486CONFIG_EEPRO100=m
486CONFIG_E100=m 487CONFIG_E100=m
487# CONFIG_E100_NAPI is not set
488# CONFIG_FEALNX is not set 488# CONFIG_FEALNX is not set
489# CONFIG_NATSEMI is not set 489# CONFIG_NATSEMI is not set
490# CONFIG_NE2K_PCI is not set 490# CONFIG_NE2K_PCI is not set
@@ -566,25 +566,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
566# CONFIG_INPUT_EVBUG is not set 566# CONFIG_INPUT_EVBUG is not set
567 567
568# 568#
569# Input I/O drivers
570#
571CONFIG_GAMEPORT=m
572CONFIG_SOUND_GAMEPORT=m
573# CONFIG_GAMEPORT_NS558 is not set
574# CONFIG_GAMEPORT_L4 is not set
575# CONFIG_GAMEPORT_EMU10K1 is not set
576# CONFIG_GAMEPORT_VORTEX is not set
577# CONFIG_GAMEPORT_FM801 is not set
578# CONFIG_GAMEPORT_CS461X is not set
579CONFIG_SERIO=y
580CONFIG_SERIO_I8042=y
581# CONFIG_SERIO_SERPORT is not set
582# CONFIG_SERIO_CT82C710 is not set
583# CONFIG_SERIO_PCIPS2 is not set
584CONFIG_SERIO_LIBPS2=y
585# CONFIG_SERIO_RAW is not set
586
587#
588# Input Device Drivers 569# Input Device Drivers
589# 570#
590CONFIG_INPUT_KEYBOARD=y 571CONFIG_INPUT_KEYBOARD=y
@@ -602,6 +583,24 @@ CONFIG_MOUSE_PS2=y
602# CONFIG_INPUT_MISC is not set 583# CONFIG_INPUT_MISC is not set
603 584
604# 585#
586# Hardware I/O ports
587#
588CONFIG_SERIO=y
589CONFIG_SERIO_I8042=y
590# CONFIG_SERIO_SERPORT is not set
591# CONFIG_SERIO_PCIPS2 is not set
592CONFIG_SERIO_LIBPS2=y
593# CONFIG_SERIO_RAW is not set
594CONFIG_GAMEPORT=m
595# CONFIG_GAMEPORT_NS558 is not set
596# CONFIG_GAMEPORT_L4 is not set
597# CONFIG_GAMEPORT_EMU10K1 is not set
598# CONFIG_GAMEPORT_VORTEX is not set
599# CONFIG_GAMEPORT_FM801 is not set
600# CONFIG_GAMEPORT_CS461X is not set
601CONFIG_SOUND_GAMEPORT=m
602
603#
605# Character devices 604# Character devices
606# 605#
607CONFIG_VT=y 606CONFIG_VT=y
@@ -615,6 +614,8 @@ CONFIG_SERIAL_NONSTANDARD=y
615# CONFIG_SYNCLINK is not set 614# CONFIG_SYNCLINK is not set
616# CONFIG_SYNCLINKMP is not set 615# CONFIG_SYNCLINKMP is not set
617# CONFIG_N_HDLC is not set 616# CONFIG_N_HDLC is not set
617# CONFIG_SPECIALIX is not set
618# CONFIG_SX is not set
618# CONFIG_STALDRV is not set 619# CONFIG_STALDRV is not set
619 620
620# 621#
@@ -635,6 +636,7 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
635# 636#
636CONFIG_SERIAL_CORE=y 637CONFIG_SERIAL_CORE=y
637CONFIG_SERIAL_CORE_CONSOLE=y 638CONFIG_SERIAL_CORE_CONSOLE=y
639# CONFIG_SERIAL_JSM is not set
638CONFIG_UNIX98_PTYS=y 640CONFIG_UNIX98_PTYS=y
639CONFIG_LEGACY_PTYS=y 641CONFIG_LEGACY_PTYS=y
640CONFIG_LEGACY_PTY_COUNT=256 642CONFIG_LEGACY_PTY_COUNT=256
@@ -670,6 +672,12 @@ CONFIG_HPET=y
670# CONFIG_HPET_RTC_IRQ is not set 672# CONFIG_HPET_RTC_IRQ is not set
671CONFIG_HPET_MMAP=y 673CONFIG_HPET_MMAP=y
672CONFIG_MAX_RAW_DEVS=256 674CONFIG_MAX_RAW_DEVS=256
675# CONFIG_HANGCHECK_TIMER is not set
676
677#
678# TPM devices
679#
680# CONFIG_TCG_TPM is not set
673 681
674# 682#
675# I2C support 683# I2C support
@@ -705,7 +713,6 @@ CONFIG_MAX_RAW_DEVS=256
705# 713#
706CONFIG_VGA_CONSOLE=y 714CONFIG_VGA_CONSOLE=y
707CONFIG_DUMMY_CONSOLE=y 715CONFIG_DUMMY_CONSOLE=y
708# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
709 716
710# 717#
711# Sound 718# Sound
@@ -715,6 +722,8 @@ CONFIG_DUMMY_CONSOLE=y
715# 722#
716# USB support 723# USB support
717# 724#
725CONFIG_USB_ARCH_HAS_HCD=y
726CONFIG_USB_ARCH_HAS_OHCI=y
718CONFIG_USB=y 727CONFIG_USB=y
719# CONFIG_USB_DEBUG is not set 728# CONFIG_USB_DEBUG is not set
720 729
@@ -726,8 +735,6 @@ CONFIG_USB_DEVICEFS=y
726# CONFIG_USB_DYNAMIC_MINORS is not set 735# CONFIG_USB_DYNAMIC_MINORS is not set
727# CONFIG_USB_SUSPEND is not set 736# CONFIG_USB_SUSPEND is not set
728# CONFIG_USB_OTG is not set 737# CONFIG_USB_OTG is not set
729CONFIG_USB_ARCH_HAS_HCD=y
730CONFIG_USB_ARCH_HAS_OHCI=y
731 738
732# 739#
733# USB Host Controller Drivers 740# USB Host Controller Drivers
@@ -736,6 +743,8 @@ CONFIG_USB_EHCI_HCD=m
736# CONFIG_USB_EHCI_SPLIT_ISO is not set 743# CONFIG_USB_EHCI_SPLIT_ISO is not set
737# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 744# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
738CONFIG_USB_OHCI_HCD=m 745CONFIG_USB_OHCI_HCD=m
746# CONFIG_USB_OHCI_BIG_ENDIAN is not set
747CONFIG_USB_OHCI_LITTLE_ENDIAN=y
739CONFIG_USB_UHCI_HCD=y 748CONFIG_USB_UHCI_HCD=y
740# CONFIG_USB_SL811_HCD is not set 749# CONFIG_USB_SL811_HCD is not set
741 750
@@ -751,12 +760,11 @@ CONFIG_USB_UHCI_HCD=y
751# 760#
752CONFIG_USB_STORAGE=m 761CONFIG_USB_STORAGE=m
753# CONFIG_USB_STORAGE_DEBUG is not set 762# CONFIG_USB_STORAGE_DEBUG is not set
754# CONFIG_USB_STORAGE_RW_DETECT is not set
755# CONFIG_USB_STORAGE_DATAFAB is not set 763# CONFIG_USB_STORAGE_DATAFAB is not set
756# CONFIG_USB_STORAGE_FREECOM is not set 764# CONFIG_USB_STORAGE_FREECOM is not set
757# CONFIG_USB_STORAGE_ISD200 is not set 765# CONFIG_USB_STORAGE_ISD200 is not set
758# CONFIG_USB_STORAGE_DPCM is not set 766# CONFIG_USB_STORAGE_DPCM is not set
759# CONFIG_USB_STORAGE_HP8200e is not set 767# CONFIG_USB_STORAGE_USBAT is not set
760# CONFIG_USB_STORAGE_SDDR09 is not set 768# CONFIG_USB_STORAGE_SDDR09 is not set
761# CONFIG_USB_STORAGE_SDDR55 is not set 769# CONFIG_USB_STORAGE_SDDR55 is not set
762# CONFIG_USB_STORAGE_JUMPSHOT is not set 770# CONFIG_USB_STORAGE_JUMPSHOT is not set
@@ -800,6 +808,7 @@ CONFIG_USB_HIDINPUT=y
800# CONFIG_USB_PEGASUS is not set 808# CONFIG_USB_PEGASUS is not set
801# CONFIG_USB_RTL8150 is not set 809# CONFIG_USB_RTL8150 is not set
802# CONFIG_USB_USBNET is not set 810# CONFIG_USB_USBNET is not set
811# CONFIG_USB_MON is not set
803 812
804# 813#
805# USB port drivers 814# USB port drivers
@@ -824,6 +833,7 @@ CONFIG_USB_HIDINPUT=y
824# CONFIG_USB_PHIDGETKIT is not set 833# CONFIG_USB_PHIDGETKIT is not set
825# CONFIG_USB_PHIDGETSERVO is not set 834# CONFIG_USB_PHIDGETSERVO is not set
826# CONFIG_USB_IDMOUSE is not set 835# CONFIG_USB_IDMOUSE is not set
836# CONFIG_USB_SISUSBVGA is not set
827# CONFIG_USB_TEST is not set 837# CONFIG_USB_TEST is not set
828 838
829# 839#
@@ -867,7 +877,12 @@ CONFIG_REISERFS_FS_POSIX_ACL=y
867CONFIG_REISERFS_FS_SECURITY=y 877CONFIG_REISERFS_FS_SECURITY=y
868# CONFIG_JFS_FS is not set 878# CONFIG_JFS_FS is not set
869CONFIG_FS_POSIX_ACL=y 879CONFIG_FS_POSIX_ACL=y
880
881#
882# XFS support
883#
870CONFIG_XFS_FS=y 884CONFIG_XFS_FS=y
885CONFIG_XFS_EXPORT=y
871# CONFIG_XFS_RT is not set 886# CONFIG_XFS_RT is not set
872# CONFIG_XFS_QUOTA is not set 887# CONFIG_XFS_QUOTA is not set
873# CONFIG_XFS_SECURITY is not set 888# CONFIG_XFS_SECURITY is not set
@@ -945,7 +960,7 @@ CONFIG_NFSD_V4=y
945CONFIG_NFSD_TCP=y 960CONFIG_NFSD_TCP=y
946CONFIG_LOCKD=m 961CONFIG_LOCKD=m
947CONFIG_LOCKD_V4=y 962CONFIG_LOCKD_V4=y
948CONFIG_EXPORTFS=m 963CONFIG_EXPORTFS=y
949CONFIG_SUNRPC=m 964CONFIG_SUNRPC=m
950CONFIG_SUNRPC_GSS=m 965CONFIG_SUNRPC_GSS=m
951CONFIG_RPCSEC_GSS_KRB5=m 966CONFIG_RPCSEC_GSS_KRB5=m
@@ -1042,8 +1057,10 @@ CONFIG_GENERIC_IRQ_PROBE=y
1042# 1057#
1043# Kernel hacking 1058# Kernel hacking
1044# 1059#
1060# CONFIG_PRINTK_TIME is not set
1045CONFIG_DEBUG_KERNEL=y 1061CONFIG_DEBUG_KERNEL=y
1046CONFIG_MAGIC_SYSRQ=y 1062CONFIG_MAGIC_SYSRQ=y
1063CONFIG_LOG_BUF_SHIFT=20
1047# CONFIG_SCHEDSTATS is not set 1064# CONFIG_SCHEDSTATS is not set
1048# CONFIG_DEBUG_SLAB is not set 1065# CONFIG_DEBUG_SLAB is not set
1049# CONFIG_DEBUG_SPINLOCK is not set 1066# CONFIG_DEBUG_SPINLOCK is not set
@@ -1077,6 +1094,7 @@ CONFIG_CRYPTO_MD5=m
1077# CONFIG_CRYPTO_SHA256 is not set 1094# CONFIG_CRYPTO_SHA256 is not set
1078# CONFIG_CRYPTO_SHA512 is not set 1095# CONFIG_CRYPTO_SHA512 is not set
1079# CONFIG_CRYPTO_WP512 is not set 1096# CONFIG_CRYPTO_WP512 is not set
1097# CONFIG_CRYPTO_TGR192 is not set
1080CONFIG_CRYPTO_DES=m 1098CONFIG_CRYPTO_DES=m
1081# CONFIG_CRYPTO_BLOWFISH is not set 1099# CONFIG_CRYPTO_BLOWFISH is not set
1082# CONFIG_CRYPTO_TWOFISH is not set 1100# CONFIG_CRYPTO_TWOFISH is not set
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 017c9ab5fc1b..b8db6e3e5e81 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -1,9 +1,9 @@
1/* 1/*
2** IA64 System Bus Adapter (SBA) I/O MMU manager 2** IA64 System Bus Adapter (SBA) I/O MMU manager
3** 3**
4** (c) Copyright 2002-2004 Alex Williamson 4** (c) Copyright 2002-2005 Alex Williamson
5** (c) Copyright 2002-2003 Grant Grundler 5** (c) Copyright 2002-2003 Grant Grundler
6** (c) Copyright 2002-2004 Hewlett-Packard Company 6** (c) Copyright 2002-2005 Hewlett-Packard Company
7** 7**
8** Portions (c) 2000 Grant Grundler (from parisc I/O MMU code) 8** Portions (c) 2000 Grant Grundler (from parisc I/O MMU code)
9** Portions (c) 1999 Dave S. Miller (from sparc64 I/O MMU code) 9** Portions (c) 1999 Dave S. Miller (from sparc64 I/O MMU code)
@@ -459,21 +459,32 @@ get_iovp_order (unsigned long size)
459 * sba_search_bitmap - find free space in IO PDIR resource bitmap 459 * sba_search_bitmap - find free space in IO PDIR resource bitmap
460 * @ioc: IO MMU structure which owns the pdir we are interested in. 460 * @ioc: IO MMU structure which owns the pdir we are interested in.
461 * @bits_wanted: number of entries we need. 461 * @bits_wanted: number of entries we need.
462 * @use_hint: use res_hint to indicate where to start looking
462 * 463 *
463 * Find consecutive free bits in resource bitmap. 464 * Find consecutive free bits in resource bitmap.
464 * Each bit represents one entry in the IO Pdir. 465 * Each bit represents one entry in the IO Pdir.
465 * Cool perf optimization: search for log2(size) bits at a time. 466 * Cool perf optimization: search for log2(size) bits at a time.
466 */ 467 */
467static SBA_INLINE unsigned long 468static SBA_INLINE unsigned long
468sba_search_bitmap(struct ioc *ioc, unsigned long bits_wanted) 469sba_search_bitmap(struct ioc *ioc, unsigned long bits_wanted, int use_hint)
469{ 470{
470 unsigned long *res_ptr = ioc->res_hint; 471 unsigned long *res_ptr;
471 unsigned long *res_end = (unsigned long *) &(ioc->res_map[ioc->res_size]); 472 unsigned long *res_end = (unsigned long *) &(ioc->res_map[ioc->res_size]);
472 unsigned long pide = ~0UL; 473 unsigned long flags, pide = ~0UL;
473 474
474 ASSERT(((unsigned long) ioc->res_hint & (sizeof(unsigned long) - 1UL)) == 0); 475 ASSERT(((unsigned long) ioc->res_hint & (sizeof(unsigned long) - 1UL)) == 0);
475 ASSERT(res_ptr < res_end); 476 ASSERT(res_ptr < res_end);
476 477
478 spin_lock_irqsave(&ioc->res_lock, flags);
479
480 /* Allow caller to force a search through the entire resource space */
481 if (likely(use_hint)) {
482 res_ptr = ioc->res_hint;
483 } else {
484 res_ptr = (ulong *)ioc->res_map;
485 ioc->res_bitshift = 0;
486 }
487
477 /* 488 /*
478 * N.B. REO/Grande defect AR2305 can cause TLB fetch timeouts 489 * N.B. REO/Grande defect AR2305 can cause TLB fetch timeouts
479 * if a TLB entry is purged while in use. sba_mark_invalid() 490 * if a TLB entry is purged while in use. sba_mark_invalid()
@@ -570,10 +581,12 @@ not_found:
570 prefetch(ioc->res_map); 581 prefetch(ioc->res_map);
571 ioc->res_hint = (unsigned long *) ioc->res_map; 582 ioc->res_hint = (unsigned long *) ioc->res_map;
572 ioc->res_bitshift = 0; 583 ioc->res_bitshift = 0;
584 spin_unlock_irqrestore(&ioc->res_lock, flags);
573 return (pide); 585 return (pide);
574 586
575found_it: 587found_it:
576 ioc->res_hint = res_ptr; 588 ioc->res_hint = res_ptr;
589 spin_unlock_irqrestore(&ioc->res_lock, flags);
577 return (pide); 590 return (pide);
578} 591}
579 592
@@ -594,36 +607,36 @@ sba_alloc_range(struct ioc *ioc, size_t size)
594 unsigned long itc_start; 607 unsigned long itc_start;
595#endif 608#endif
596 unsigned long pide; 609 unsigned long pide;
597 unsigned long flags;
598 610
599 ASSERT(pages_needed); 611 ASSERT(pages_needed);
600 ASSERT(0 == (size & ~iovp_mask)); 612 ASSERT(0 == (size & ~iovp_mask));
601 613
602 spin_lock_irqsave(&ioc->res_lock, flags);
603
604#ifdef PDIR_SEARCH_TIMING 614#ifdef PDIR_SEARCH_TIMING
605 itc_start = ia64_get_itc(); 615 itc_start = ia64_get_itc();
606#endif 616#endif
607 /* 617 /*
608 ** "seek and ye shall find"...praying never hurts either... 618 ** "seek and ye shall find"...praying never hurts either...
609 */ 619 */
610 pide = sba_search_bitmap(ioc, pages_needed); 620 pide = sba_search_bitmap(ioc, pages_needed, 1);
611 if (unlikely(pide >= (ioc->res_size << 3))) { 621 if (unlikely(pide >= (ioc->res_size << 3))) {
612 pide = sba_search_bitmap(ioc, pages_needed); 622 pide = sba_search_bitmap(ioc, pages_needed, 0);
613 if (unlikely(pide >= (ioc->res_size << 3))) { 623 if (unlikely(pide >= (ioc->res_size << 3))) {
614#if DELAYED_RESOURCE_CNT > 0 624#if DELAYED_RESOURCE_CNT > 0
625 unsigned long flags;
626
615 /* 627 /*
616 ** With delayed resource freeing, we can give this one more shot. We're 628 ** With delayed resource freeing, we can give this one more shot. We're
617 ** getting close to being in trouble here, so do what we can to make this 629 ** getting close to being in trouble here, so do what we can to make this
618 ** one count. 630 ** one count.
619 */ 631 */
620 spin_lock(&ioc->saved_lock); 632 spin_lock_irqsave(&ioc->saved_lock, flags);
621 if (ioc->saved_cnt > 0) { 633 if (ioc->saved_cnt > 0) {
622 struct sba_dma_pair *d; 634 struct sba_dma_pair *d;
623 int cnt = ioc->saved_cnt; 635 int cnt = ioc->saved_cnt;
624 636
625 d = &(ioc->saved[ioc->saved_cnt]); 637 d = &(ioc->saved[ioc->saved_cnt - 1]);
626 638
639 spin_lock(&ioc->res_lock);
627 while (cnt--) { 640 while (cnt--) {
628 sba_mark_invalid(ioc, d->iova, d->size); 641 sba_mark_invalid(ioc, d->iova, d->size);
629 sba_free_range(ioc, d->iova, d->size); 642 sba_free_range(ioc, d->iova, d->size);
@@ -631,10 +644,11 @@ sba_alloc_range(struct ioc *ioc, size_t size)
631 } 644 }
632 ioc->saved_cnt = 0; 645 ioc->saved_cnt = 0;
633 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ 646 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */
647 spin_unlock(&ioc->res_lock);
634 } 648 }
635 spin_unlock(&ioc->saved_lock); 649 spin_unlock_irqrestore(&ioc->saved_lock, flags);
636 650
637 pide = sba_search_bitmap(ioc, pages_needed); 651 pide = sba_search_bitmap(ioc, pages_needed, 0);
638 if (unlikely(pide >= (ioc->res_size << 3))) 652 if (unlikely(pide >= (ioc->res_size << 3)))
639 panic(__FILE__ ": I/O MMU @ %p is out of mapping resources\n", 653 panic(__FILE__ ": I/O MMU @ %p is out of mapping resources\n",
640 ioc->ioc_hpa); 654 ioc->ioc_hpa);
@@ -664,8 +678,6 @@ sba_alloc_range(struct ioc *ioc, size_t size)
664 (uint) ((unsigned long) ioc->res_hint - (unsigned long) ioc->res_map), 678 (uint) ((unsigned long) ioc->res_hint - (unsigned long) ioc->res_map),
665 ioc->res_bitshift ); 679 ioc->res_bitshift );
666 680
667 spin_unlock_irqrestore(&ioc->res_lock, flags);
668
669 return (pide); 681 return (pide);
670} 682}
671 683
@@ -950,6 +962,30 @@ sba_map_single(struct device *dev, void *addr, size_t size, int dir)
950 return SBA_IOVA(ioc, iovp, offset); 962 return SBA_IOVA(ioc, iovp, offset);
951} 963}
952 964
965#ifdef ENABLE_MARK_CLEAN
966static SBA_INLINE void
967sba_mark_clean(struct ioc *ioc, dma_addr_t iova, size_t size)
968{
969 u32 iovp = (u32) SBA_IOVP(ioc,iova);
970 int off = PDIR_INDEX(iovp);
971 void *addr;
972
973 if (size <= iovp_size) {
974 addr = phys_to_virt(ioc->pdir_base[off] &
975 ~0xE000000000000FFFULL);
976 mark_clean(addr, size);
977 } else {
978 do {
979 addr = phys_to_virt(ioc->pdir_base[off] &
980 ~0xE000000000000FFFULL);
981 mark_clean(addr, min(size, iovp_size));
982 off++;
983 size -= iovp_size;
984 } while (size > 0);
985 }
986}
987#endif
988
953/** 989/**
954 * sba_unmap_single - unmap one IOVA and free resources 990 * sba_unmap_single - unmap one IOVA and free resources
955 * @dev: instance of PCI owned by the driver that's asking. 991 * @dev: instance of PCI owned by the driver that's asking.
@@ -995,6 +1031,10 @@ void sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, int dir)
995 size += offset; 1031 size += offset;
996 size = ROUNDUP(size, iovp_size); 1032 size = ROUNDUP(size, iovp_size);
997 1033
1034#ifdef ENABLE_MARK_CLEAN
1035 if (dir == DMA_FROM_DEVICE)
1036 sba_mark_clean(ioc, iova, size);
1037#endif
998 1038
999#if DELAYED_RESOURCE_CNT > 0 1039#if DELAYED_RESOURCE_CNT > 0
1000 spin_lock_irqsave(&ioc->saved_lock, flags); 1040 spin_lock_irqsave(&ioc->saved_lock, flags);
@@ -1021,30 +1061,6 @@ void sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, int dir)
1021 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ 1061 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */
1022 spin_unlock_irqrestore(&ioc->res_lock, flags); 1062 spin_unlock_irqrestore(&ioc->res_lock, flags);
1023#endif /* DELAYED_RESOURCE_CNT == 0 */ 1063#endif /* DELAYED_RESOURCE_CNT == 0 */
1024#ifdef ENABLE_MARK_CLEAN
1025 if (dir == DMA_FROM_DEVICE) {
1026 u32 iovp = (u32) SBA_IOVP(ioc,iova);
1027 int off = PDIR_INDEX(iovp);
1028 void *addr;
1029
1030 if (size <= iovp_size) {
1031 addr = phys_to_virt(ioc->pdir_base[off] &
1032 ~0xE000000000000FFFULL);
1033 mark_clean(addr, size);
1034 } else {
1035 size_t byte_cnt = size;
1036
1037 do {
1038 addr = phys_to_virt(ioc->pdir_base[off] &
1039 ~0xE000000000000FFFULL);
1040 mark_clean(addr, min(byte_cnt, iovp_size));
1041 off++;
1042 byte_cnt -= iovp_size;
1043
1044 } while (byte_cnt > 0);
1045 }
1046 }
1047#endif
1048} 1064}
1049 1065
1050 1066
@@ -1928,43 +1944,17 @@ sba_connect_bus(struct pci_bus *bus)
1928static void __init 1944static void __init
1929sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle) 1945sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
1930{ 1946{
1931 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
1932 union acpi_object *obj;
1933 acpi_handle phandle;
1934 unsigned int node; 1947 unsigned int node;
1948 int pxm;
1935 1949
1936 ioc->node = MAX_NUMNODES; 1950 ioc->node = MAX_NUMNODES;
1937 1951
1938 /* 1952 pxm = acpi_get_pxm(handle);
1939 * Check for a _PXM on this node first. We don't typically see
1940 * one here, so we'll end up getting it from the parent.
1941 */
1942 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PXM", NULL, &buffer))) {
1943 if (ACPI_FAILURE(acpi_get_parent(handle, &phandle)))
1944 return;
1945
1946 /* Reset the acpi buffer */
1947 buffer.length = ACPI_ALLOCATE_BUFFER;
1948 buffer.pointer = NULL;
1949 1953
1950 if (ACPI_FAILURE(acpi_evaluate_object(phandle, "_PXM", NULL, 1954 if (pxm < 0)
1951 &buffer)))
1952 return;
1953 }
1954
1955 if (!buffer.length || !buffer.pointer)
1956 return; 1955 return;
1957 1956
1958 obj = buffer.pointer; 1957 node = pxm_to_nid_map[pxm];
1959
1960 if (obj->type != ACPI_TYPE_INTEGER ||
1961 obj->integer.value >= MAX_PXM_DOMAINS) {
1962 acpi_os_free(buffer.pointer);
1963 return;
1964 }
1965
1966 node = pxm_to_nid_map[obj->integer.value];
1967 acpi_os_free(buffer.pointer);
1968 1958
1969 if (node >= MAX_NUMNODES || !node_online(node)) 1959 if (node >= MAX_NUMNODES || !node_online(node))
1970 return; 1960 return;
diff --git a/arch/ia64/ia32/ia32_signal.c b/arch/ia64/ia32/ia32_signal.c
index 19b02adce68c..ebb89be2aa2d 100644
--- a/arch/ia64/ia32/ia32_signal.c
+++ b/arch/ia64/ia32/ia32_signal.c
@@ -460,10 +460,9 @@ __ia32_rt_sigsuspend (compat_sigset_t *sset, unsigned int sigsetsize, struct sig
460 sigset_t oldset, set; 460 sigset_t oldset, set;
461 461
462 scr->scratch_unat = 0; /* avoid leaking kernel bits to user level */ 462 scr->scratch_unat = 0; /* avoid leaking kernel bits to user level */
463 memset(&set, 0, sizeof(&set)); 463 memset(&set, 0, sizeof(set));
464 464
465 if (memcpy(&set.sig, &sset->sig, sigsetsize)) 465 memcpy(&set.sig, &sset->sig, sigsetsize);
466 return -EFAULT;
467 466
468 sigdelsetmask(&set, ~_BLOCKABLE); 467 sigdelsetmask(&set, ~_BLOCKABLE);
469 468
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index a8e99c56a768..72dfd9e7de0f 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -779,7 +779,7 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
779 union acpi_object *obj; 779 union acpi_object *obj;
780 struct acpi_table_iosapic *iosapic; 780 struct acpi_table_iosapic *iosapic;
781 unsigned int gsi_base; 781 unsigned int gsi_base;
782 int node; 782 int pxm, node;
783 783
784 /* Only care about objects w/ a method that returns the MADT */ 784 /* Only care about objects w/ a method that returns the MADT */
785 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 785 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
@@ -805,29 +805,16 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret)
805 gsi_base = iosapic->global_irq_base; 805 gsi_base = iosapic->global_irq_base;
806 806
807 acpi_os_free(buffer.pointer); 807 acpi_os_free(buffer.pointer);
808 buffer.length = ACPI_ALLOCATE_BUFFER;
809 buffer.pointer = NULL;
810 808
811 /* 809 /*
812 * OK, it's an IOSAPIC MADT entry, look for a _PXM method to tell 810 * OK, it's an IOSAPIC MADT entry, look for a _PXM value to tell
813 * us which node to associate this with. 811 * us which node to associate this with.
814 */ 812 */
815 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PXM", NULL, &buffer))) 813 pxm = acpi_get_pxm(handle);
816 return AE_OK; 814 if (pxm < 0)
817
818 if (!buffer.length || !buffer.pointer)
819 return AE_OK;
820
821 obj = buffer.pointer;
822
823 if (obj->type != ACPI_TYPE_INTEGER ||
824 obj->integer.value >= MAX_PXM_DOMAINS) {
825 acpi_os_free(buffer.pointer);
826 return AE_OK; 815 return AE_OK;
827 }
828 816
829 node = pxm_to_nid_map[obj->integer.value]; 817 node = pxm_to_nid_map[pxm];
830 acpi_os_free(buffer.pointer);
831 818
832 if (node >= MAX_NUMNODES || !node_online(node) || 819 if (node >= MAX_NUMNODES || !node_online(node) ||
833 cpus_empty(node_to_cpumask(node))) 820 cpus_empty(node_to_cpumask(node)))
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index 0272c010a3ba..81c45d447394 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -728,12 +728,8 @@ ENTRY(ia64_leave_syscall)
728 mov f8=f0 // clear f8 728 mov f8=f0 // clear f8
729 ;; 729 ;;
730 ld8 r30=[r2],16 // M0|1 load cr.ifs 730 ld8 r30=[r2],16 // M0|1 load cr.ifs
731 mov.m ar.ssd=r0 // M2 clear ar.ssd
732 cmp.eq p9,p0=r0,r0 // set p9 to indicate that we should restore cr.ifs
733 ;;
734 ld8 r25=[r3],16 // M0|1 load ar.unat 731 ld8 r25=[r3],16 // M0|1 load ar.unat
735 mov.m ar.csd=r0 // M2 clear ar.csd 732 cmp.eq p9,p0=r0,r0 // set p9 to indicate that we should restore cr.ifs
736 mov r22=r0 // clear r22
737 ;; 733 ;;
738 ld8 r26=[r2],PT(B0)-PT(AR_PFS) // M0|1 load ar.pfs 734 ld8 r26=[r2],PT(B0)-PT(AR_PFS) // M0|1 load ar.pfs
739(pKStk) mov r22=psr // M2 read PSR now that interrupts are disabled 735(pKStk) mov r22=psr // M2 read PSR now that interrupts are disabled
@@ -756,11 +752,15 @@ ENTRY(ia64_leave_syscall)
756 mov f7=f0 // clear f7 752 mov f7=f0 // clear f7
757 ;; 753 ;;
758 ld8.fill r12=[r2] // restore r12 (sp) 754 ld8.fill r12=[r2] // restore r12 (sp)
755 mov.m ar.ssd=r0 // M2 clear ar.ssd
756 mov r22=r0 // clear r22
757
759 ld8.fill r15=[r3] // restore r15 758 ld8.fill r15=[r3] // restore r15
759(pUStk) st1 [r14]=r17
760 addl r3=THIS_CPU(ia64_phys_stacked_size_p8),r0 760 addl r3=THIS_CPU(ia64_phys_stacked_size_p8),r0
761 ;; 761 ;;
762(pUStk) ld4 r3=[r3] // r3 = cpu_data->phys_stacked_size_p8 762(pUStk) ld4 r17=[r3] // r17 = cpu_data->phys_stacked_size_p8
763(pUStk) st1 [r14]=r17 763 mov.m ar.csd=r0 // M2 clear ar.csd
764 mov b6=r18 // I0 restore b6 764 mov b6=r18 // I0 restore b6
765 ;; 765 ;;
766 mov r14=r0 // clear r14 766 mov r14=r0 // clear r14
@@ -782,7 +782,7 @@ GLOBAL_ENTRY(ia64_ret_from_ia32_execve)
782 st8.spill [r2]=r8 // store return value in slot for r8 and set unat bit 782 st8.spill [r2]=r8 // store return value in slot for r8 and set unat bit
783 .mem.offset 8,0 783 .mem.offset 8,0
784 st8.spill [r3]=r0 // clear error indication in slot for r10 and set unat bit 784 st8.spill [r3]=r0 // clear error indication in slot for r10 and set unat bit
785END(ia64_ret_from_ia32_execve_syscall) 785END(ia64_ret_from_ia32_execve)
786 // fall through 786 // fall through
787#endif /* CONFIG_IA32_SUPPORT */ 787#endif /* CONFIG_IA32_SUPPORT */
788GLOBAL_ENTRY(ia64_leave_kernel) 788GLOBAL_ENTRY(ia64_leave_kernel)
@@ -1417,7 +1417,7 @@ sys_call_table:
1417 data8 sys_msgrcv 1417 data8 sys_msgrcv
1418 data8 sys_msgctl 1418 data8 sys_msgctl
1419 data8 sys_shmget 1419 data8 sys_shmget
1420 data8 ia64_shmat 1420 data8 sys_shmat
1421 data8 sys_shmdt // 1115 1421 data8 sys_shmdt // 1115
1422 data8 sys_shmctl 1422 data8 sys_shmctl
1423 data8 sys_syslog 1423 data8 sys_syslog
diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S
index 0d8650f7fce7..4f3cdef75797 100644
--- a/arch/ia64/kernel/fsys.S
+++ b/arch/ia64/kernel/fsys.S
@@ -611,8 +611,10 @@ GLOBAL_ENTRY(fsys_bubble_down)
611 movl r2=ia64_ret_from_syscall 611 movl r2=ia64_ret_from_syscall
612 ;; 612 ;;
613 mov rp=r2 // set the real return addr 613 mov rp=r2 // set the real return addr
614 tbit.z p8,p0=r3,TIF_SYSCALL_TRACE 614 and r3=_TIF_SYSCALL_TRACEAUDIT,r3
615 ;; 615 ;;
616 cmp.eq p8,p0=r3,r0
617
616(p10) br.cond.spnt.many ia64_ret_from_syscall // p10==true means out registers are more than 8 618(p10) br.cond.spnt.many ia64_ret_from_syscall // p10==true means out registers are more than 8
617(p8) br.call.sptk.many b6=b6 // ignore this return addr 619(p8) br.call.sptk.many b6=b6 // ignore this return addr
618 br.cond.sptk ia64_trace_syscall 620 br.cond.sptk ia64_trace_syscall
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 105c7fec8c6d..8d3a9291b47f 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -15,6 +15,8 @@
15 * Copyright (C) 1999 Don Dugger <Don.Dugger@intel.com> 15 * Copyright (C) 1999 Don Dugger <Don.Dugger@intel.com>
16 * Copyright (C) 2002 Fenghua Yu <fenghua.yu@intel.com> 16 * Copyright (C) 2002 Fenghua Yu <fenghua.yu@intel.com>
17 * -Optimize __ia64_save_fpu() and __ia64_load_fpu() for Itanium 2. 17 * -Optimize __ia64_save_fpu() and __ia64_load_fpu() for Itanium 2.
18 * Copyright (C) 2004 Ashok Raj <ashok.raj@intel.com>
19 * Support for CPU Hotplug
18 */ 20 */
19 21
20#include <linux/config.h> 22#include <linux/config.h>
@@ -29,6 +31,139 @@
29#include <asm/processor.h> 31#include <asm/processor.h>
30#include <asm/ptrace.h> 32#include <asm/ptrace.h>
31#include <asm/system.h> 33#include <asm/system.h>
34#include <asm/mca_asm.h>
35
36#ifdef CONFIG_HOTPLUG_CPU
37#define SAL_PSR_BITS_TO_SET \
38 (IA64_PSR_AC | IA64_PSR_BN | IA64_PSR_MFH | IA64_PSR_MFL)
39
40#define SAVE_FROM_REG(src, ptr, dest) \
41 mov dest=src;; \
42 st8 [ptr]=dest,0x08
43
44#define RESTORE_REG(reg, ptr, _tmp) \
45 ld8 _tmp=[ptr],0x08;; \
46 mov reg=_tmp
47
48#define SAVE_BREAK_REGS(ptr, _idx, _breg, _dest)\
49 mov ar.lc=IA64_NUM_DBG_REGS-1;; \
50 mov _idx=0;; \
511: \
52 SAVE_FROM_REG(_breg[_idx], ptr, _dest);; \
53 add _idx=1,_idx;; \
54 br.cloop.sptk.many 1b
55
56#define RESTORE_BREAK_REGS(ptr, _idx, _breg, _tmp, _lbl)\
57 mov ar.lc=IA64_NUM_DBG_REGS-1;; \
58 mov _idx=0;; \
59_lbl: RESTORE_REG(_breg[_idx], ptr, _tmp);; \
60 add _idx=1, _idx;; \
61 br.cloop.sptk.many _lbl
62
63#define SAVE_ONE_RR(num, _reg, _tmp) \
64 movl _tmp=(num<<61);; \
65 mov _reg=rr[_tmp]
66
67#define SAVE_REGION_REGS(_tmp, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) \
68 SAVE_ONE_RR(0,_r0, _tmp);; \
69 SAVE_ONE_RR(1,_r1, _tmp);; \
70 SAVE_ONE_RR(2,_r2, _tmp);; \
71 SAVE_ONE_RR(3,_r3, _tmp);; \
72 SAVE_ONE_RR(4,_r4, _tmp);; \
73 SAVE_ONE_RR(5,_r5, _tmp);; \
74 SAVE_ONE_RR(6,_r6, _tmp);; \
75 SAVE_ONE_RR(7,_r7, _tmp);;
76
77#define STORE_REGION_REGS(ptr, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7) \
78 st8 [ptr]=_r0, 8;; \
79 st8 [ptr]=_r1, 8;; \
80 st8 [ptr]=_r2, 8;; \
81 st8 [ptr]=_r3, 8;; \
82 st8 [ptr]=_r4, 8;; \
83 st8 [ptr]=_r5, 8;; \
84 st8 [ptr]=_r6, 8;; \
85 st8 [ptr]=_r7, 8;;
86
87#define RESTORE_REGION_REGS(ptr, _idx1, _idx2, _tmp) \
88 mov ar.lc=0x08-1;; \
89 movl _idx1=0x00;; \
90RestRR: \
91 dep.z _idx2=_idx1,61,3;; \
92 ld8 _tmp=[ptr],8;; \
93 mov rr[_idx2]=_tmp;; \
94 srlz.d;; \
95 add _idx1=1,_idx1;; \
96 br.cloop.sptk.few RestRR
97
98#define SET_AREA_FOR_BOOTING_CPU(reg1, reg2) \
99 movl reg1=sal_state_for_booting_cpu;; \
100 ld8 reg2=[reg1];;
101
102/*
103 * Adjust region registers saved before starting to save
104 * break regs and rest of the states that need to be preserved.
105 */
106#define SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(_reg1,_reg2,_pred) \
107 SAVE_FROM_REG(b0,_reg1,_reg2);; \
108 SAVE_FROM_REG(b1,_reg1,_reg2);; \
109 SAVE_FROM_REG(b2,_reg1,_reg2);; \
110 SAVE_FROM_REG(b3,_reg1,_reg2);; \
111 SAVE_FROM_REG(b4,_reg1,_reg2);; \
112 SAVE_FROM_REG(b5,_reg1,_reg2);; \
113 st8 [_reg1]=r1,0x08;; \
114 st8 [_reg1]=r12,0x08;; \
115 st8 [_reg1]=r13,0x08;; \
116 SAVE_FROM_REG(ar.fpsr,_reg1,_reg2);; \
117 SAVE_FROM_REG(ar.pfs,_reg1,_reg2);; \
118 SAVE_FROM_REG(ar.rnat,_reg1,_reg2);; \
119 SAVE_FROM_REG(ar.unat,_reg1,_reg2);; \
120 SAVE_FROM_REG(ar.bspstore,_reg1,_reg2);; \
121 SAVE_FROM_REG(cr.dcr,_reg1,_reg2);; \
122 SAVE_FROM_REG(cr.iva,_reg1,_reg2);; \
123 SAVE_FROM_REG(cr.pta,_reg1,_reg2);; \
124 SAVE_FROM_REG(cr.itv,_reg1,_reg2);; \
125 SAVE_FROM_REG(cr.pmv,_reg1,_reg2);; \
126 SAVE_FROM_REG(cr.cmcv,_reg1,_reg2);; \
127 SAVE_FROM_REG(cr.lrr0,_reg1,_reg2);; \
128 SAVE_FROM_REG(cr.lrr1,_reg1,_reg2);; \
129 st8 [_reg1]=r4,0x08;; \
130 st8 [_reg1]=r5,0x08;; \
131 st8 [_reg1]=r6,0x08;; \
132 st8 [_reg1]=r7,0x08;; \
133 st8 [_reg1]=_pred,0x08;; \
134 SAVE_FROM_REG(ar.lc, _reg1, _reg2);; \
135 stf.spill.nta [_reg1]=f2,16;; \
136 stf.spill.nta [_reg1]=f3,16;; \
137 stf.spill.nta [_reg1]=f4,16;; \
138 stf.spill.nta [_reg1]=f5,16;; \
139 stf.spill.nta [_reg1]=f16,16;; \
140 stf.spill.nta [_reg1]=f17,16;; \
141 stf.spill.nta [_reg1]=f18,16;; \
142 stf.spill.nta [_reg1]=f19,16;; \
143 stf.spill.nta [_reg1]=f20,16;; \
144 stf.spill.nta [_reg1]=f21,16;; \
145 stf.spill.nta [_reg1]=f22,16;; \
146 stf.spill.nta [_reg1]=f23,16;; \
147 stf.spill.nta [_reg1]=f24,16;; \
148 stf.spill.nta [_reg1]=f25,16;; \
149 stf.spill.nta [_reg1]=f26,16;; \
150 stf.spill.nta [_reg1]=f27,16;; \
151 stf.spill.nta [_reg1]=f28,16;; \
152 stf.spill.nta [_reg1]=f29,16;; \
153 stf.spill.nta [_reg1]=f30,16;; \
154 stf.spill.nta [_reg1]=f31,16;;
155
156#else
157#define SET_AREA_FOR_BOOTING_CPU(a1, a2)
158#define SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(a1,a2, a3)
159#define SAVE_REGION_REGS(_tmp, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7)
160#define STORE_REGION_REGS(ptr, _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7)
161#endif
162
163#define SET_ONE_RR(num, pgsize, _tmp1, _tmp2, vhpt) \
164 movl _tmp1=(num << 61);; \
165 mov _tmp2=((ia64_rid(IA64_REGION_ID_KERNEL, (num<<61)) << 8) | (pgsize << 2) | vhpt);; \
166 mov rr[_tmp1]=_tmp2
32 167
33 .section __special_page_section,"ax" 168 .section __special_page_section,"ax"
34 169
@@ -64,6 +199,12 @@ start_ap:
64 srlz.i 199 srlz.i
65 ;; 200 ;;
66 /* 201 /*
202 * Save the region registers, predicate before they get clobbered
203 */
204 SAVE_REGION_REGS(r2, r8,r9,r10,r11,r12,r13,r14,r15);
205 mov r25=pr;;
206
207 /*
67 * Initialize kernel region registers: 208 * Initialize kernel region registers:
68 * rr[0]: VHPT enabled, page size = PAGE_SHIFT 209 * rr[0]: VHPT enabled, page size = PAGE_SHIFT
69 * rr[1]: VHPT enabled, page size = PAGE_SHIFT 210 * rr[1]: VHPT enabled, page size = PAGE_SHIFT
@@ -76,32 +217,14 @@ start_ap:
76 * We initialize all of them to prevent inadvertently assuming 217 * We initialize all of them to prevent inadvertently assuming
77 * something about the state of address translation early in boot. 218 * something about the state of address translation early in boot.
78 */ 219 */
79 mov r6=((ia64_rid(IA64_REGION_ID_KERNEL, (0<<61)) << 8) | (PAGE_SHIFT << 2) | 1) 220 SET_ONE_RR(0, PAGE_SHIFT, r2, r16, 1);;
80 movl r7=(0<<61) 221 SET_ONE_RR(1, PAGE_SHIFT, r2, r16, 1);;
81 mov r8=((ia64_rid(IA64_REGION_ID_KERNEL, (1<<61)) << 8) | (PAGE_SHIFT << 2) | 1) 222 SET_ONE_RR(2, PAGE_SHIFT, r2, r16, 1);;
82 movl r9=(1<<61) 223 SET_ONE_RR(3, PAGE_SHIFT, r2, r16, 1);;
83 mov r10=((ia64_rid(IA64_REGION_ID_KERNEL, (2<<61)) << 8) | (PAGE_SHIFT << 2) | 1) 224 SET_ONE_RR(4, PAGE_SHIFT, r2, r16, 1);;
84 movl r11=(2<<61) 225 SET_ONE_RR(5, PAGE_SHIFT, r2, r16, 1);;
85 mov r12=((ia64_rid(IA64_REGION_ID_KERNEL, (3<<61)) << 8) | (PAGE_SHIFT << 2) | 1) 226 SET_ONE_RR(6, IA64_GRANULE_SHIFT, r2, r16, 0);;
86 movl r13=(3<<61) 227 SET_ONE_RR(7, IA64_GRANULE_SHIFT, r2, r16, 0);;
87 mov r14=((ia64_rid(IA64_REGION_ID_KERNEL, (4<<61)) << 8) | (PAGE_SHIFT << 2) | 1)
88 movl r15=(4<<61)
89 mov r16=((ia64_rid(IA64_REGION_ID_KERNEL, (5<<61)) << 8) | (PAGE_SHIFT << 2) | 1)
90 movl r17=(5<<61)
91 mov r18=((ia64_rid(IA64_REGION_ID_KERNEL, (6<<61)) << 8) | (IA64_GRANULE_SHIFT << 2))
92 movl r19=(6<<61)
93 mov r20=((ia64_rid(IA64_REGION_ID_KERNEL, (7<<61)) << 8) | (IA64_GRANULE_SHIFT << 2))
94 movl r21=(7<<61)
95 ;;
96 mov rr[r7]=r6
97 mov rr[r9]=r8
98 mov rr[r11]=r10
99 mov rr[r13]=r12
100 mov rr[r15]=r14
101 mov rr[r17]=r16
102 mov rr[r19]=r18
103 mov rr[r21]=r20
104 ;;
105 /* 228 /*
106 * Now pin mappings into the TLB for kernel text and data 229 * Now pin mappings into the TLB for kernel text and data
107 */ 230 */
@@ -142,6 +265,12 @@ start_ap:
142 ;; 265 ;;
1431: // now we are in virtual mode 2661: // now we are in virtual mode
144 267
268 SET_AREA_FOR_BOOTING_CPU(r2, r16);
269
270 STORE_REGION_REGS(r16, r8,r9,r10,r11,r12,r13,r14,r15);
271 SAL_TO_OS_BOOT_HANDOFF_STATE_SAVE(r16,r17,r25)
272 ;;
273
145 // set IVT entry point---can't access I/O ports without it 274 // set IVT entry point---can't access I/O ports without it
146 movl r3=ia64_ivt 275 movl r3=ia64_ivt
147 ;; 276 ;;
@@ -211,12 +340,13 @@ start_ap:
211 mov IA64_KR(CURRENT_STACK)=r16 340 mov IA64_KR(CURRENT_STACK)=r16
212 mov r13=r2 341 mov r13=r2
213 /* 342 /*
214 * Reserve space at the top of the stack for "struct pt_regs". Kernel threads 343 * Reserve space at the top of the stack for "struct pt_regs". Kernel
215 * don't store interesting values in that structure, but the space still needs 344 * threads don't store interesting values in that structure, but the space
216 * to be there because time-critical stuff such as the context switching can 345 * still needs to be there because time-critical stuff such as the context
217 * be implemented more efficiently (for example, __switch_to() 346 * switching can be implemented more efficiently (for example, __switch_to()
218 * always sets the psr.dfh bit of the task it is switching to). 347 * always sets the psr.dfh bit of the task it is switching to).
219 */ 348 */
349
220 addl r12=IA64_STK_OFFSET-IA64_PT_REGS_SIZE-16,r2 350 addl r12=IA64_STK_OFFSET-IA64_PT_REGS_SIZE-16,r2
221 addl r2=IA64_RBS_OFFSET,r2 // initialize the RSE 351 addl r2=IA64_RBS_OFFSET,r2 // initialize the RSE
222 mov ar.rsc=0 // place RSE in enforced lazy mode 352 mov ar.rsc=0 // place RSE in enforced lazy mode
@@ -993,4 +1123,98 @@ END(ia64_spinlock_contention)
993 1123
994#endif 1124#endif
995 1125
1126#ifdef CONFIG_HOTPLUG_CPU
1127GLOBAL_ENTRY(ia64_jump_to_sal)
1128 alloc r16=ar.pfs,1,0,0,0;;
1129 rsm psr.i | psr.ic
1130{
1131 flushrs
1132 srlz.i
1133}
1134 tpa r25=in0
1135 movl r18=tlb_purge_done;;
1136 DATA_VA_TO_PA(r18);;
1137 mov b1=r18 // Return location
1138 movl r18=ia64_do_tlb_purge;;
1139 DATA_VA_TO_PA(r18);;
1140 mov b2=r18 // doing tlb_flush work
1141 mov ar.rsc=0 // Put RSE in enforced lazy, LE mode
1142 movl r17=1f;;
1143 DATA_VA_TO_PA(r17);;
1144 mov cr.iip=r17
1145 movl r16=SAL_PSR_BITS_TO_SET;;
1146 mov cr.ipsr=r16
1147 mov cr.ifs=r0;;
1148 rfi;;
11491:
1150 /*
1151 * Invalidate all TLB data/inst
1152 */
1153 br.sptk.many b2;; // jump to tlb purge code
1154
1155tlb_purge_done:
1156 RESTORE_REGION_REGS(r25, r17,r18,r19);;
1157 RESTORE_REG(b0, r25, r17);;
1158 RESTORE_REG(b1, r25, r17);;
1159 RESTORE_REG(b2, r25, r17);;
1160 RESTORE_REG(b3, r25, r17);;
1161 RESTORE_REG(b4, r25, r17);;
1162 RESTORE_REG(b5, r25, r17);;
1163 ld8 r1=[r25],0x08;;
1164 ld8 r12=[r25],0x08;;
1165 ld8 r13=[r25],0x08;;
1166 RESTORE_REG(ar.fpsr, r25, r17);;
1167 RESTORE_REG(ar.pfs, r25, r17);;
1168 RESTORE_REG(ar.rnat, r25, r17);;
1169 RESTORE_REG(ar.unat, r25, r17);;
1170 RESTORE_REG(ar.bspstore, r25, r17);;
1171 RESTORE_REG(cr.dcr, r25, r17);;
1172 RESTORE_REG(cr.iva, r25, r17);;
1173 RESTORE_REG(cr.pta, r25, r17);;
1174 RESTORE_REG(cr.itv, r25, r17);;
1175 RESTORE_REG(cr.pmv, r25, r17);;
1176 RESTORE_REG(cr.cmcv, r25, r17);;
1177 RESTORE_REG(cr.lrr0, r25, r17);;
1178 RESTORE_REG(cr.lrr1, r25, r17);;
1179 ld8 r4=[r25],0x08;;
1180 ld8 r5=[r25],0x08;;
1181 ld8 r6=[r25],0x08;;
1182 ld8 r7=[r25],0x08;;
1183 ld8 r17=[r25],0x08;;
1184 mov pr=r17,-1;;
1185 RESTORE_REG(ar.lc, r25, r17);;
1186 /*
1187 * Now Restore floating point regs
1188 */
1189 ldf.fill.nta f2=[r25],16;;
1190 ldf.fill.nta f3=[r25],16;;
1191 ldf.fill.nta f4=[r25],16;;
1192 ldf.fill.nta f5=[r25],16;;
1193 ldf.fill.nta f16=[r25],16;;
1194 ldf.fill.nta f17=[r25],16;;
1195 ldf.fill.nta f18=[r25],16;;
1196 ldf.fill.nta f19=[r25],16;;
1197 ldf.fill.nta f20=[r25],16;;
1198 ldf.fill.nta f21=[r25],16;;
1199 ldf.fill.nta f22=[r25],16;;
1200 ldf.fill.nta f23=[r25],16;;
1201 ldf.fill.nta f24=[r25],16;;
1202 ldf.fill.nta f25=[r25],16;;
1203 ldf.fill.nta f26=[r25],16;;
1204 ldf.fill.nta f27=[r25],16;;
1205 ldf.fill.nta f28=[r25],16;;
1206 ldf.fill.nta f29=[r25],16;;
1207 ldf.fill.nta f30=[r25],16;;
1208 ldf.fill.nta f31=[r25],16;;
1209
1210 /*
1211 * Now that we have done all the register restores
1212 * we are now ready for the big DIVE to SAL Land
1213 */
1214 ssm psr.ic;;
1215 srlz.d;;
1216 br.ret.sptk.many b0;;
1217END(ia64_jump_to_sal)
1218#endif /* CONFIG_HOTPLUG_CPU */
1219
996#endif /* CONFIG_SMP */ 1220#endif /* CONFIG_SMP */
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index c15be5c38f56..88b014381df5 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -79,6 +79,7 @@
79#include <linux/smp.h> 79#include <linux/smp.h>
80#include <linux/smp_lock.h> 80#include <linux/smp_lock.h>
81#include <linux/string.h> 81#include <linux/string.h>
82#include <linux/bootmem.h>
82 83
83#include <asm/delay.h> 84#include <asm/delay.h>
84#include <asm/hw_irq.h> 85#include <asm/hw_irq.h>
@@ -98,19 +99,30 @@
98#define DBG(fmt...) 99#define DBG(fmt...)
99#endif 100#endif
100 101
102#define NR_PREALLOCATE_RTE_ENTRIES (PAGE_SIZE / sizeof(struct iosapic_rte_info))
103#define RTE_PREALLOCATED (1)
104
101static DEFINE_SPINLOCK(iosapic_lock); 105static DEFINE_SPINLOCK(iosapic_lock);
102 106
103/* These tables map IA-64 vectors to the IOSAPIC pin that generates this vector. */ 107/* These tables map IA-64 vectors to the IOSAPIC pin that generates this vector. */
104 108
105static struct iosapic_intr_info { 109struct iosapic_rte_info {
110 struct list_head rte_list; /* node in list of RTEs sharing the same vector */
106 char __iomem *addr; /* base address of IOSAPIC */ 111 char __iomem *addr; /* base address of IOSAPIC */
107 u32 low32; /* current value of low word of Redirection table entry */
108 unsigned int gsi_base; /* first GSI assigned to this IOSAPIC */ 112 unsigned int gsi_base; /* first GSI assigned to this IOSAPIC */
109 char rte_index; /* IOSAPIC RTE index (-1 => not an IOSAPIC interrupt) */ 113 char rte_index; /* IOSAPIC RTE index */
114 int refcnt; /* reference counter */
115 unsigned int flags; /* flags */
116} ____cacheline_aligned;
117
118static struct iosapic_intr_info {
119 struct list_head rtes; /* RTEs using this vector (empty => not an IOSAPIC interrupt) */
120 int count; /* # of RTEs that shares this vector */
121 u32 low32; /* current value of low word of Redirection table entry */
122 unsigned int dest; /* destination CPU physical ID */
110 unsigned char dmode : 3; /* delivery mode (see iosapic.h) */ 123 unsigned char dmode : 3; /* delivery mode (see iosapic.h) */
111 unsigned char polarity: 1; /* interrupt polarity (see iosapic.h) */ 124 unsigned char polarity: 1; /* interrupt polarity (see iosapic.h) */
112 unsigned char trigger : 1; /* trigger mode (see iosapic.h) */ 125 unsigned char trigger : 1; /* trigger mode (see iosapic.h) */
113 int refcnt; /* reference counter */
114} iosapic_intr_info[IA64_NUM_VECTORS]; 126} iosapic_intr_info[IA64_NUM_VECTORS];
115 127
116static struct iosapic { 128static struct iosapic {
@@ -126,6 +138,8 @@ static int num_iosapic;
126 138
127static unsigned char pcat_compat __initdata; /* 8259 compatibility flag */ 139static unsigned char pcat_compat __initdata; /* 8259 compatibility flag */
128 140
141static int iosapic_kmalloc_ok;
142static LIST_HEAD(free_rte_list);
129 143
130/* 144/*
131 * Find an IOSAPIC associated with a GSI 145 * Find an IOSAPIC associated with a GSI
@@ -147,10 +161,12 @@ static inline int
147_gsi_to_vector (unsigned int gsi) 161_gsi_to_vector (unsigned int gsi)
148{ 162{
149 struct iosapic_intr_info *info; 163 struct iosapic_intr_info *info;
164 struct iosapic_rte_info *rte;
150 165
151 for (info = iosapic_intr_info; info < iosapic_intr_info + IA64_NUM_VECTORS; ++info) 166 for (info = iosapic_intr_info; info < iosapic_intr_info + IA64_NUM_VECTORS; ++info)
152 if (info->gsi_base + info->rte_index == gsi) 167 list_for_each_entry(rte, &info->rtes, rte_list)
153 return info - iosapic_intr_info; 168 if (rte->gsi_base + rte->rte_index == gsi)
169 return info - iosapic_intr_info;
154 return -1; 170 return -1;
155} 171}
156 172
@@ -167,33 +183,52 @@ gsi_to_vector (unsigned int gsi)
167int 183int
168gsi_to_irq (unsigned int gsi) 184gsi_to_irq (unsigned int gsi)
169{ 185{
186 unsigned long flags;
187 int irq;
170 /* 188 /*
171 * XXX fix me: this assumes an identity mapping vetween IA-64 vector and Linux irq 189 * XXX fix me: this assumes an identity mapping vetween IA-64 vector and Linux irq
172 * numbers... 190 * numbers...
173 */ 191 */
174 return _gsi_to_vector(gsi); 192 spin_lock_irqsave(&iosapic_lock, flags);
193 {
194 irq = _gsi_to_vector(gsi);
195 }
196 spin_unlock_irqrestore(&iosapic_lock, flags);
197
198 return irq;
199}
200
201static struct iosapic_rte_info *gsi_vector_to_rte(unsigned int gsi, unsigned int vec)
202{
203 struct iosapic_rte_info *rte;
204
205 list_for_each_entry(rte, &iosapic_intr_info[vec].rtes, rte_list)
206 if (rte->gsi_base + rte->rte_index == gsi)
207 return rte;
208 return NULL;
175} 209}
176 210
177static void 211static void
178set_rte (unsigned int vector, unsigned int dest, int mask) 212set_rte (unsigned int gsi, unsigned int vector, unsigned int dest, int mask)
179{ 213{
180 unsigned long pol, trigger, dmode; 214 unsigned long pol, trigger, dmode;
181 u32 low32, high32; 215 u32 low32, high32;
182 char __iomem *addr; 216 char __iomem *addr;
183 int rte_index; 217 int rte_index;
184 char redir; 218 char redir;
219 struct iosapic_rte_info *rte;
185 220
186 DBG(KERN_DEBUG"IOSAPIC: routing vector %d to 0x%x\n", vector, dest); 221 DBG(KERN_DEBUG"IOSAPIC: routing vector %d to 0x%x\n", vector, dest);
187 222
188 rte_index = iosapic_intr_info[vector].rte_index; 223 rte = gsi_vector_to_rte(gsi, vector);
189 if (rte_index < 0) 224 if (!rte)
190 return; /* not an IOSAPIC interrupt */ 225 return; /* not an IOSAPIC interrupt */
191 226
192 addr = iosapic_intr_info[vector].addr; 227 rte_index = rte->rte_index;
228 addr = rte->addr;
193 pol = iosapic_intr_info[vector].polarity; 229 pol = iosapic_intr_info[vector].polarity;
194 trigger = iosapic_intr_info[vector].trigger; 230 trigger = iosapic_intr_info[vector].trigger;
195 dmode = iosapic_intr_info[vector].dmode; 231 dmode = iosapic_intr_info[vector].dmode;
196 vector &= (~IA64_IRQ_REDIRECTED);
197 232
198 redir = (dmode == IOSAPIC_LOWEST_PRIORITY) ? 1 : 0; 233 redir = (dmode == IOSAPIC_LOWEST_PRIORITY) ? 1 : 0;
199 234
@@ -221,6 +256,7 @@ set_rte (unsigned int vector, unsigned int dest, int mask)
221 iosapic_write(addr, IOSAPIC_RTE_HIGH(rte_index), high32); 256 iosapic_write(addr, IOSAPIC_RTE_HIGH(rte_index), high32);
222 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32); 257 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32);
223 iosapic_intr_info[vector].low32 = low32; 258 iosapic_intr_info[vector].low32 = low32;
259 iosapic_intr_info[vector].dest = dest;
224} 260}
225 261
226static void 262static void
@@ -237,18 +273,20 @@ mask_irq (unsigned int irq)
237 u32 low32; 273 u32 low32;
238 int rte_index; 274 int rte_index;
239 ia64_vector vec = irq_to_vector(irq); 275 ia64_vector vec = irq_to_vector(irq);
276 struct iosapic_rte_info *rte;
240 277
241 addr = iosapic_intr_info[vec].addr; 278 if (list_empty(&iosapic_intr_info[vec].rtes))
242 rte_index = iosapic_intr_info[vec].rte_index;
243
244 if (rte_index < 0)
245 return; /* not an IOSAPIC interrupt! */ 279 return; /* not an IOSAPIC interrupt! */
246 280
247 spin_lock_irqsave(&iosapic_lock, flags); 281 spin_lock_irqsave(&iosapic_lock, flags);
248 { 282 {
249 /* set only the mask bit */ 283 /* set only the mask bit */
250 low32 = iosapic_intr_info[vec].low32 |= IOSAPIC_MASK; 284 low32 = iosapic_intr_info[vec].low32 |= IOSAPIC_MASK;
251 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32); 285 list_for_each_entry(rte, &iosapic_intr_info[vec].rtes, rte_list) {
286 addr = rte->addr;
287 rte_index = rte->rte_index;
288 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32);
289 }
252 } 290 }
253 spin_unlock_irqrestore(&iosapic_lock, flags); 291 spin_unlock_irqrestore(&iosapic_lock, flags);
254} 292}
@@ -261,16 +299,19 @@ unmask_irq (unsigned int irq)
261 u32 low32; 299 u32 low32;
262 int rte_index; 300 int rte_index;
263 ia64_vector vec = irq_to_vector(irq); 301 ia64_vector vec = irq_to_vector(irq);
302 struct iosapic_rte_info *rte;
264 303
265 addr = iosapic_intr_info[vec].addr; 304 if (list_empty(&iosapic_intr_info[vec].rtes))
266 rte_index = iosapic_intr_info[vec].rte_index;
267 if (rte_index < 0)
268 return; /* not an IOSAPIC interrupt! */ 305 return; /* not an IOSAPIC interrupt! */
269 306
270 spin_lock_irqsave(&iosapic_lock, flags); 307 spin_lock_irqsave(&iosapic_lock, flags);
271 { 308 {
272 low32 = iosapic_intr_info[vec].low32 &= ~IOSAPIC_MASK; 309 low32 = iosapic_intr_info[vec].low32 &= ~IOSAPIC_MASK;
273 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32); 310 list_for_each_entry(rte, &iosapic_intr_info[vec].rtes, rte_list) {
311 addr = rte->addr;
312 rte_index = rte->rte_index;
313 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32);
314 }
274 } 315 }
275 spin_unlock_irqrestore(&iosapic_lock, flags); 316 spin_unlock_irqrestore(&iosapic_lock, flags);
276} 317}
@@ -286,6 +327,7 @@ iosapic_set_affinity (unsigned int irq, cpumask_t mask)
286 char __iomem *addr; 327 char __iomem *addr;
287 int redir = (irq & IA64_IRQ_REDIRECTED) ? 1 : 0; 328 int redir = (irq & IA64_IRQ_REDIRECTED) ? 1 : 0;
288 ia64_vector vec; 329 ia64_vector vec;
330 struct iosapic_rte_info *rte;
289 331
290 irq &= (~IA64_IRQ_REDIRECTED); 332 irq &= (~IA64_IRQ_REDIRECTED);
291 vec = irq_to_vector(irq); 333 vec = irq_to_vector(irq);
@@ -295,10 +337,7 @@ iosapic_set_affinity (unsigned int irq, cpumask_t mask)
295 337
296 dest = cpu_physical_id(first_cpu(mask)); 338 dest = cpu_physical_id(first_cpu(mask));
297 339
298 rte_index = iosapic_intr_info[vec].rte_index; 340 if (list_empty(&iosapic_intr_info[vec].rtes))
299 addr = iosapic_intr_info[vec].addr;
300
301 if (rte_index < 0)
302 return; /* not an IOSAPIC interrupt */ 341 return; /* not an IOSAPIC interrupt */
303 342
304 set_irq_affinity_info(irq, dest, redir); 343 set_irq_affinity_info(irq, dest, redir);
@@ -318,8 +357,13 @@ iosapic_set_affinity (unsigned int irq, cpumask_t mask)
318 low32 |= (IOSAPIC_FIXED << IOSAPIC_DELIVERY_SHIFT); 357 low32 |= (IOSAPIC_FIXED << IOSAPIC_DELIVERY_SHIFT);
319 358
320 iosapic_intr_info[vec].low32 = low32; 359 iosapic_intr_info[vec].low32 = low32;
321 iosapic_write(addr, IOSAPIC_RTE_HIGH(rte_index), high32); 360 iosapic_intr_info[vec].dest = dest;
322 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32); 361 list_for_each_entry(rte, &iosapic_intr_info[vec].rtes, rte_list) {
362 addr = rte->addr;
363 rte_index = rte->rte_index;
364 iosapic_write(addr, IOSAPIC_RTE_HIGH(rte_index), high32);
365 iosapic_write(addr, IOSAPIC_RTE_LOW(rte_index), low32);
366 }
323 } 367 }
324 spin_unlock_irqrestore(&iosapic_lock, flags); 368 spin_unlock_irqrestore(&iosapic_lock, flags);
325#endif 369#endif
@@ -340,9 +384,11 @@ static void
340iosapic_end_level_irq (unsigned int irq) 384iosapic_end_level_irq (unsigned int irq)
341{ 385{
342 ia64_vector vec = irq_to_vector(irq); 386 ia64_vector vec = irq_to_vector(irq);
387 struct iosapic_rte_info *rte;
343 388
344 move_irq(irq); 389 move_irq(irq);
345 iosapic_eoi(iosapic_intr_info[vec].addr, vec); 390 list_for_each_entry(rte, &iosapic_intr_info[vec].rtes, rte_list)
391 iosapic_eoi(rte->addr, vec);
346} 392}
347 393
348#define iosapic_shutdown_level_irq mask_irq 394#define iosapic_shutdown_level_irq mask_irq
@@ -422,6 +468,34 @@ iosapic_version (char __iomem *addr)
422 return iosapic_read(addr, IOSAPIC_VERSION); 468 return iosapic_read(addr, IOSAPIC_VERSION);
423} 469}
424 470
471static int iosapic_find_sharable_vector (unsigned long trigger, unsigned long pol)
472{
473 int i, vector = -1, min_count = -1;
474 struct iosapic_intr_info *info;
475
476 /*
477 * shared vectors for edge-triggered interrupts are not
478 * supported yet
479 */
480 if (trigger == IOSAPIC_EDGE)
481 return -1;
482
483 for (i = IA64_FIRST_DEVICE_VECTOR; i <= IA64_LAST_DEVICE_VECTOR; i++) {
484 info = &iosapic_intr_info[i];
485 if (info->trigger == trigger && info->polarity == pol &&
486 (info->dmode == IOSAPIC_FIXED || info->dmode == IOSAPIC_LOWEST_PRIORITY)) {
487 if (min_count == -1 || info->count < min_count) {
488 vector = i;
489 min_count = info->count;
490 }
491 }
492 }
493 if (vector < 0)
494 panic("%s: out of interrupt vectors!\n", __FUNCTION__);
495
496 return vector;
497}
498
425/* 499/*
426 * if the given vector is already owned by other, 500 * if the given vector is already owned by other,
427 * assign a new vector for the other and make the vector available 501 * assign a new vector for the other and make the vector available
@@ -431,19 +505,63 @@ iosapic_reassign_vector (int vector)
431{ 505{
432 int new_vector; 506 int new_vector;
433 507
434 if (iosapic_intr_info[vector].rte_index >= 0 || iosapic_intr_info[vector].addr 508 if (!list_empty(&iosapic_intr_info[vector].rtes)) {
435 || iosapic_intr_info[vector].gsi_base || iosapic_intr_info[vector].dmode
436 || iosapic_intr_info[vector].polarity || iosapic_intr_info[vector].trigger)
437 {
438 new_vector = assign_irq_vector(AUTO_ASSIGN); 509 new_vector = assign_irq_vector(AUTO_ASSIGN);
439 printk(KERN_INFO "Reassigning vector %d to %d\n", vector, new_vector); 510 printk(KERN_INFO "Reassigning vector %d to %d\n", vector, new_vector);
440 memcpy(&iosapic_intr_info[new_vector], &iosapic_intr_info[vector], 511 memcpy(&iosapic_intr_info[new_vector], &iosapic_intr_info[vector],
441 sizeof(struct iosapic_intr_info)); 512 sizeof(struct iosapic_intr_info));
513 INIT_LIST_HEAD(&iosapic_intr_info[new_vector].rtes);
514 list_move(iosapic_intr_info[vector].rtes.next, &iosapic_intr_info[new_vector].rtes);
442 memset(&iosapic_intr_info[vector], 0, sizeof(struct iosapic_intr_info)); 515 memset(&iosapic_intr_info[vector], 0, sizeof(struct iosapic_intr_info));
443 iosapic_intr_info[vector].rte_index = -1; 516 iosapic_intr_info[vector].low32 = IOSAPIC_MASK;
517 INIT_LIST_HEAD(&iosapic_intr_info[vector].rtes);
444 } 518 }
445} 519}
446 520
521static struct iosapic_rte_info *iosapic_alloc_rte (void)
522{
523 int i;
524 struct iosapic_rte_info *rte;
525 int preallocated = 0;
526
527 if (!iosapic_kmalloc_ok && list_empty(&free_rte_list)) {
528 rte = alloc_bootmem(sizeof(struct iosapic_rte_info) * NR_PREALLOCATE_RTE_ENTRIES);
529 if (!rte)
530 return NULL;
531 for (i = 0; i < NR_PREALLOCATE_RTE_ENTRIES; i++, rte++)
532 list_add(&rte->rte_list, &free_rte_list);
533 }
534
535 if (!list_empty(&free_rte_list)) {
536 rte = list_entry(free_rte_list.next, struct iosapic_rte_info, rte_list);
537 list_del(&rte->rte_list);
538 preallocated++;
539 } else {
540 rte = kmalloc(sizeof(struct iosapic_rte_info), GFP_ATOMIC);
541 if (!rte)
542 return NULL;
543 }
544
545 memset(rte, 0, sizeof(struct iosapic_rte_info));
546 if (preallocated)
547 rte->flags |= RTE_PREALLOCATED;
548
549 return rte;
550}
551
552static void iosapic_free_rte (struct iosapic_rte_info *rte)
553{
554 if (rte->flags & RTE_PREALLOCATED)
555 list_add_tail(&rte->rte_list, &free_rte_list);
556 else
557 kfree(rte);
558}
559
560static inline int vector_is_shared (int vector)
561{
562 return (iosapic_intr_info[vector].count > 1);
563}
564
447static void 565static void
448register_intr (unsigned int gsi, int vector, unsigned char delivery, 566register_intr (unsigned int gsi, int vector, unsigned char delivery,
449 unsigned long polarity, unsigned long trigger) 567 unsigned long polarity, unsigned long trigger)
@@ -454,6 +572,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
454 int index; 572 int index;
455 unsigned long gsi_base; 573 unsigned long gsi_base;
456 void __iomem *iosapic_address; 574 void __iomem *iosapic_address;
575 struct iosapic_rte_info *rte;
457 576
458 index = find_iosapic(gsi); 577 index = find_iosapic(gsi);
459 if (index < 0) { 578 if (index < 0) {
@@ -464,14 +583,33 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery,
464 iosapic_address = iosapic_lists[index].addr; 583 iosapic_address = iosapic_lists[index].addr;
465 gsi_base = iosapic_lists[index].gsi_base; 584 gsi_base = iosapic_lists[index].gsi_base;
466 585
467 rte_index = gsi - gsi_base; 586 rte = gsi_vector_to_rte(gsi, vector);
468 iosapic_intr_info[vector].rte_index = rte_index; 587 if (!rte) {
588 rte = iosapic_alloc_rte();
589 if (!rte) {
590 printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__);
591 return;
592 }
593
594 rte_index = gsi - gsi_base;
595 rte->rte_index = rte_index;
596 rte->addr = iosapic_address;
597 rte->gsi_base = gsi_base;
598 rte->refcnt++;
599 list_add_tail(&rte->rte_list, &iosapic_intr_info[vector].rtes);
600 iosapic_intr_info[vector].count++;
601 }
602 else if (vector_is_shared(vector)) {
603 struct iosapic_intr_info *info = &iosapic_intr_info[vector];
604 if (info->trigger != trigger || info->polarity != polarity) {
605 printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__);
606 return;
607 }
608 }
609
469 iosapic_intr_info[vector].polarity = polarity; 610 iosapic_intr_info[vector].polarity = polarity;
470 iosapic_intr_info[vector].dmode = delivery; 611 iosapic_intr_info[vector].dmode = delivery;
471 iosapic_intr_info[vector].addr = iosapic_address;
472 iosapic_intr_info[vector].gsi_base = gsi_base;
473 iosapic_intr_info[vector].trigger = trigger; 612 iosapic_intr_info[vector].trigger = trigger;
474 iosapic_intr_info[vector].refcnt++;
475 613
476 if (trigger == IOSAPIC_EDGE) 614 if (trigger == IOSAPIC_EDGE)
477 irq_type = &irq_type_iosapic_edge; 615 irq_type = &irq_type_iosapic_edge;
@@ -494,6 +632,13 @@ get_target_cpu (unsigned int gsi, int vector)
494 static int cpu = -1; 632 static int cpu = -1;
495 633
496 /* 634 /*
635 * In case of vector shared by multiple RTEs, all RTEs that
636 * share the vector need to use the same destination CPU.
637 */
638 if (!list_empty(&iosapic_intr_info[vector].rtes))
639 return iosapic_intr_info[vector].dest;
640
641 /*
497 * If the platform supports redirection via XTP, let it 642 * If the platform supports redirection via XTP, let it
498 * distribute interrupts. 643 * distribute interrupts.
499 */ 644 */
@@ -565,10 +710,12 @@ int
565iosapic_register_intr (unsigned int gsi, 710iosapic_register_intr (unsigned int gsi,
566 unsigned long polarity, unsigned long trigger) 711 unsigned long polarity, unsigned long trigger)
567{ 712{
568 int vector; 713 int vector, mask = 1;
569 unsigned int dest; 714 unsigned int dest;
570 unsigned long flags; 715 unsigned long flags;
571 716 struct iosapic_rte_info *rte;
717 u32 low32;
718again:
572 /* 719 /*
573 * If this GSI has already been registered (i.e., it's a 720 * If this GSI has already been registered (i.e., it's a
574 * shared interrupt, or we lost a race to register it), 721 * shared interrupt, or we lost a race to register it),
@@ -578,19 +725,45 @@ iosapic_register_intr (unsigned int gsi,
578 { 725 {
579 vector = gsi_to_vector(gsi); 726 vector = gsi_to_vector(gsi);
580 if (vector > 0) { 727 if (vector > 0) {
581 iosapic_intr_info[vector].refcnt++; 728 rte = gsi_vector_to_rte(gsi, vector);
729 rte->refcnt++;
582 spin_unlock_irqrestore(&iosapic_lock, flags); 730 spin_unlock_irqrestore(&iosapic_lock, flags);
583 return vector; 731 return vector;
584 } 732 }
733 }
734 spin_unlock_irqrestore(&iosapic_lock, flags);
735
736 /* If vector is running out, we try to find a sharable vector */
737 vector = assign_irq_vector_nopanic(AUTO_ASSIGN);
738 if (vector < 0)
739 vector = iosapic_find_sharable_vector(trigger, polarity);
740
741 spin_lock_irqsave(&irq_descp(vector)->lock, flags);
742 spin_lock(&iosapic_lock);
743 {
744 if (gsi_to_vector(gsi) > 0) {
745 if (list_empty(&iosapic_intr_info[vector].rtes))
746 free_irq_vector(vector);
747 spin_unlock(&iosapic_lock);
748 spin_unlock_irqrestore(&irq_descp(vector)->lock, flags);
749 goto again;
750 }
585 751
586 vector = assign_irq_vector(AUTO_ASSIGN);
587 dest = get_target_cpu(gsi, vector); 752 dest = get_target_cpu(gsi, vector);
588 register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY, 753 register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY,
589 polarity, trigger); 754 polarity, trigger);
590 755
591 set_rte(vector, dest, 1); 756 /*
757 * If the vector is shared and already unmasked for
758 * other interrupt sources, don't mask it.
759 */
760 low32 = iosapic_intr_info[vector].low32;
761 if (vector_is_shared(vector) && !(low32 & IOSAPIC_MASK))
762 mask = 0;
763 set_rte(gsi, vector, dest, mask);
592 } 764 }
593 spin_unlock_irqrestore(&iosapic_lock, flags); 765 spin_unlock(&iosapic_lock);
766 spin_unlock_irqrestore(&irq_descp(vector)->lock, flags);
594 767
595 printk(KERN_INFO "GSI %u (%s, %s) -> CPU %d (0x%04x) vector %d\n", 768 printk(KERN_INFO "GSI %u (%s, %s) -> CPU %d (0x%04x) vector %d\n",
596 gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"), 769 gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"),
@@ -607,8 +780,10 @@ iosapic_unregister_intr (unsigned int gsi)
607 unsigned long flags; 780 unsigned long flags;
608 int irq, vector; 781 int irq, vector;
609 irq_desc_t *idesc; 782 irq_desc_t *idesc;
610 int rte_index; 783 u32 low32;
611 unsigned long trigger, polarity; 784 unsigned long trigger, polarity;
785 unsigned int dest;
786 struct iosapic_rte_info *rte;
612 787
613 /* 788 /*
614 * If the irq associated with the gsi is not found, 789 * If the irq associated with the gsi is not found,
@@ -627,54 +802,56 @@ iosapic_unregister_intr (unsigned int gsi)
627 spin_lock_irqsave(&idesc->lock, flags); 802 spin_lock_irqsave(&idesc->lock, flags);
628 spin_lock(&iosapic_lock); 803 spin_lock(&iosapic_lock);
629 { 804 {
630 rte_index = iosapic_intr_info[vector].rte_index; 805 if ((rte = gsi_vector_to_rte(gsi, vector)) == NULL) {
631 if (rte_index < 0) {
632 spin_unlock(&iosapic_lock);
633 spin_unlock_irqrestore(&idesc->lock, flags);
634 printk(KERN_ERR "iosapic_unregister_intr(%u) unbalanced\n", gsi); 806 printk(KERN_ERR "iosapic_unregister_intr(%u) unbalanced\n", gsi);
635 WARN_ON(1); 807 WARN_ON(1);
636 return; 808 goto out;
637 } 809 }
638 810
639 if (--iosapic_intr_info[vector].refcnt > 0) { 811 if (--rte->refcnt > 0)
640 spin_unlock(&iosapic_lock); 812 goto out;
641 spin_unlock_irqrestore(&idesc->lock, flags);
642 return;
643 }
644 813
645 /* 814 /* Mask the interrupt */
646 * If interrupt handlers still exist on the irq 815 low32 = iosapic_intr_info[vector].low32 | IOSAPIC_MASK;
647 * associated with the gsi, don't unregister the 816 iosapic_write(rte->addr, IOSAPIC_RTE_LOW(rte->rte_index), low32);
648 * interrupt.
649 */
650 if (idesc->action) {
651 iosapic_intr_info[vector].refcnt++;
652 spin_unlock(&iosapic_lock);
653 spin_unlock_irqrestore(&idesc->lock, flags);
654 printk(KERN_WARNING "Cannot unregister GSI. IRQ %u is still in use.\n", irq);
655 return;
656 }
657 817
658 /* Clear the interrupt controller descriptor. */ 818 /* Remove the rte entry from the list */
659 idesc->handler = &no_irq_type; 819 list_del(&rte->rte_list);
820 iosapic_intr_info[vector].count--;
821 iosapic_free_rte(rte);
660 822
661 trigger = iosapic_intr_info[vector].trigger; 823 trigger = iosapic_intr_info[vector].trigger;
662 polarity = iosapic_intr_info[vector].polarity; 824 polarity = iosapic_intr_info[vector].polarity;
825 dest = iosapic_intr_info[vector].dest;
826 printk(KERN_INFO "GSI %u (%s, %s) -> CPU %d (0x%04x) vector %d unregistered\n",
827 gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"),
828 (polarity == IOSAPIC_POL_HIGH ? "high" : "low"),
829 cpu_logical_id(dest), dest, vector);
830
831 if (list_empty(&iosapic_intr_info[vector].rtes)) {
832 /* Sanity check */
833 BUG_ON(iosapic_intr_info[vector].count);
834
835 /* Clear the interrupt controller descriptor */
836 idesc->handler = &no_irq_type;
837
838 /* Clear the interrupt information */
839 memset(&iosapic_intr_info[vector], 0, sizeof(struct iosapic_intr_info));
840 iosapic_intr_info[vector].low32 |= IOSAPIC_MASK;
841 INIT_LIST_HEAD(&iosapic_intr_info[vector].rtes);
842
843 if (idesc->action) {
844 printk(KERN_ERR "interrupt handlers still exist on IRQ %u\n", irq);
845 WARN_ON(1);
846 }
663 847
664 /* Clear the interrupt information. */ 848 /* Free the interrupt vector */
665 memset(&iosapic_intr_info[vector], 0, sizeof(struct iosapic_intr_info)); 849 free_irq_vector(vector);
666 iosapic_intr_info[vector].rte_index = -1; /* mark as unused */ 850 }
667 } 851 }
852 out:
668 spin_unlock(&iosapic_lock); 853 spin_unlock(&iosapic_lock);
669 spin_unlock_irqrestore(&idesc->lock, flags); 854 spin_unlock_irqrestore(&idesc->lock, flags);
670
671 /* Free the interrupt vector */
672 free_irq_vector(vector);
673
674 printk(KERN_INFO "GSI %u (%s, %s) -> vector %d unregisterd.\n",
675 gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"),
676 (polarity == IOSAPIC_POL_HIGH ? "high" : "low"),
677 vector);
678} 855}
679#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */ 856#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
680 857
@@ -724,7 +901,7 @@ iosapic_register_platform_intr (u32 int_type, unsigned int gsi,
724 (polarity == IOSAPIC_POL_HIGH ? "high" : "low"), 901 (polarity == IOSAPIC_POL_HIGH ? "high" : "low"),
725 cpu_logical_id(dest), dest, vector); 902 cpu_logical_id(dest), dest, vector);
726 903
727 set_rte(vector, dest, mask); 904 set_rte(gsi, vector, dest, mask);
728 return vector; 905 return vector;
729} 906}
730 907
@@ -750,7 +927,7 @@ iosapic_override_isa_irq (unsigned int isa_irq, unsigned int gsi,
750 polarity == IOSAPIC_POL_HIGH ? "high" : "low", 927 polarity == IOSAPIC_POL_HIGH ? "high" : "low",
751 cpu_logical_id(dest), dest, vector); 928 cpu_logical_id(dest), dest, vector);
752 929
753 set_rte(vector, dest, 1); 930 set_rte(gsi, vector, dest, 1);
754} 931}
755 932
756void __init 933void __init
@@ -758,8 +935,10 @@ iosapic_system_init (int system_pcat_compat)
758{ 935{
759 int vector; 936 int vector;
760 937
761 for (vector = 0; vector < IA64_NUM_VECTORS; ++vector) 938 for (vector = 0; vector < IA64_NUM_VECTORS; ++vector) {
762 iosapic_intr_info[vector].rte_index = -1; /* mark as unused */ 939 iosapic_intr_info[vector].low32 = IOSAPIC_MASK;
940 INIT_LIST_HEAD(&iosapic_intr_info[vector].rtes); /* mark as unused */
941 }
763 942
764 pcat_compat = system_pcat_compat; 943 pcat_compat = system_pcat_compat;
765 if (pcat_compat) { 944 if (pcat_compat) {
@@ -825,3 +1004,10 @@ map_iosapic_to_node(unsigned int gsi_base, int node)
825 return; 1004 return;
826} 1005}
827#endif 1006#endif
1007
1008static int __init iosapic_enable_kmalloc (void)
1009{
1010 iosapic_kmalloc_ok = 1;
1011 return 0;
1012}
1013core_initcall (iosapic_enable_kmalloc);
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 5ba06ebe355b..4fe60c7a2e90 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -63,20 +63,30 @@ EXPORT_SYMBOL(isa_irq_to_vector_map);
63static unsigned long ia64_vector_mask[BITS_TO_LONGS(IA64_NUM_DEVICE_VECTORS)]; 63static unsigned long ia64_vector_mask[BITS_TO_LONGS(IA64_NUM_DEVICE_VECTORS)];
64 64
65int 65int
66assign_irq_vector (int irq) 66assign_irq_vector_nopanic (int irq)
67{ 67{
68 int pos, vector; 68 int pos, vector;
69 again: 69 again:
70 pos = find_first_zero_bit(ia64_vector_mask, IA64_NUM_DEVICE_VECTORS); 70 pos = find_first_zero_bit(ia64_vector_mask, IA64_NUM_DEVICE_VECTORS);
71 vector = IA64_FIRST_DEVICE_VECTOR + pos; 71 vector = IA64_FIRST_DEVICE_VECTOR + pos;
72 if (vector > IA64_LAST_DEVICE_VECTOR) 72 if (vector > IA64_LAST_DEVICE_VECTOR)
73 /* XXX could look for sharable vectors instead of panic'ing... */ 73 return -1;
74 panic("assign_irq_vector: out of interrupt vectors!");
75 if (test_and_set_bit(pos, ia64_vector_mask)) 74 if (test_and_set_bit(pos, ia64_vector_mask))
76 goto again; 75 goto again;
77 return vector; 76 return vector;
78} 77}
79 78
79int
80assign_irq_vector (int irq)
81{
82 int vector = assign_irq_vector_nopanic(irq);
83
84 if (vector < 0)
85 panic("assign_irq_vector: out of interrupt vectors!");
86
87 return vector;
88}
89
80void 90void
81free_irq_vector (int vector) 91free_irq_vector (int vector)
82{ 92{
diff --git a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
index cf3f8014f9ad..ef3fd7265b67 100644
--- a/arch/ia64/kernel/mca_asm.S
+++ b/arch/ia64/kernel/mca_asm.S
@@ -110,46 +110,19 @@
110 .global ia64_os_mca_dispatch_end 110 .global ia64_os_mca_dispatch_end
111 .global ia64_sal_to_os_handoff_state 111 .global ia64_sal_to_os_handoff_state
112 .global ia64_os_to_sal_handoff_state 112 .global ia64_os_to_sal_handoff_state
113 .global ia64_do_tlb_purge
113 114
114 .text 115 .text
115 .align 16 116 .align 16
116 117
117ia64_os_mca_dispatch: 118/*
118 119 * Just the TLB purge part is moved to a separate function
119 // Serialize all MCA processing 120 * so we can re-use the code for cpu hotplug code as well
120 mov r3=1;; 121 * Caller should now setup b1, so we can branch once the
121 LOAD_PHYSICAL(p0,r2,ia64_mca_serialize);; 122 * tlb flush is complete.
122ia64_os_mca_spin: 123 */
123 xchg8 r4=[r2],r3;;
124 cmp.ne p6,p0=r4,r0
125(p6) br ia64_os_mca_spin
126
127 // Save the SAL to OS MCA handoff state as defined
128 // by SAL SPEC 3.0
129 // NOTE : The order in which the state gets saved
130 // is dependent on the way the C-structure
131 // for ia64_mca_sal_to_os_state_t has been
132 // defined in include/asm/mca.h
133 SAL_TO_OS_MCA_HANDOFF_STATE_SAVE(r2)
134 ;;
135
136 // LOG PROCESSOR STATE INFO FROM HERE ON..
137begin_os_mca_dump:
138 br ia64_os_mca_proc_state_dump;;
139
140ia64_os_mca_done_dump:
141
142 LOAD_PHYSICAL(p0,r16,ia64_sal_to_os_handoff_state+56)
143 ;;
144 ld8 r18=[r16] // Get processor state parameter on existing PALE_CHECK.
145 ;;
146 tbit.nz p6,p7=r18,60
147(p7) br.spnt done_tlb_purge_and_reload
148
149 // The following code purges TC and TR entries. Then reload all TC entries.
150 // Purge percpu data TC entries.
151begin_tlb_purge_and_reload:
152 124
125ia64_do_tlb_purge:
153#define O(member) IA64_CPUINFO_##member##_OFFSET 126#define O(member) IA64_CPUINFO_##member##_OFFSET
154 127
155 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2 128 GET_THIS_PADDR(r2, cpu_info) // load phys addr of cpu_info into r2
@@ -230,6 +203,51 @@ begin_tlb_purge_and_reload:
230 ;; 203 ;;
231 srlz.i 204 srlz.i
232 ;; 205 ;;
206 // Now branch away to caller.
207 br.sptk.many b1
208 ;;
209
210ia64_os_mca_dispatch:
211
212 // Serialize all MCA processing
213 mov r3=1;;
214 LOAD_PHYSICAL(p0,r2,ia64_mca_serialize);;
215ia64_os_mca_spin:
216 xchg8 r4=[r2],r3;;
217 cmp.ne p6,p0=r4,r0
218(p6) br ia64_os_mca_spin
219
220 // Save the SAL to OS MCA handoff state as defined
221 // by SAL SPEC 3.0
222 // NOTE : The order in which the state gets saved
223 // is dependent on the way the C-structure
224 // for ia64_mca_sal_to_os_state_t has been
225 // defined in include/asm/mca.h
226 SAL_TO_OS_MCA_HANDOFF_STATE_SAVE(r2)
227 ;;
228
229 // LOG PROCESSOR STATE INFO FROM HERE ON..
230begin_os_mca_dump:
231 br ia64_os_mca_proc_state_dump;;
232
233ia64_os_mca_done_dump:
234
235 LOAD_PHYSICAL(p0,r16,ia64_sal_to_os_handoff_state+56)
236 ;;
237 ld8 r18=[r16] // Get processor state parameter on existing PALE_CHECK.
238 ;;
239 tbit.nz p6,p7=r18,60
240(p7) br.spnt done_tlb_purge_and_reload
241
242 // The following code purges TC and TR entries. Then reload all TC entries.
243 // Purge percpu data TC entries.
244begin_tlb_purge_and_reload:
245 movl r18=ia64_reload_tr;;
246 LOAD_PHYSICAL(p0,r18,ia64_reload_tr);;
247 mov b1=r18;;
248 br.sptk.many ia64_do_tlb_purge;;
249
250ia64_reload_tr:
233 // Finally reload the TR registers. 251 // Finally reload the TR registers.
234 // 1. Reload DTR/ITR registers for kernel. 252 // 1. Reload DTR/ITR registers for kernel.
235 mov r18=KERNEL_TR_PAGE_SHIFT<<2 253 mov r18=KERNEL_TR_PAGE_SHIFT<<2
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index ab478172c349..abc0113a821d 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -132,8 +132,7 @@ mca_handler_bh(unsigned long paddr)
132 spin_unlock(&mca_bh_lock); 132 spin_unlock(&mca_bh_lock);
133 133
134 /* This process is about to be killed itself */ 134 /* This process is about to be killed itself */
135 force_sig(SIGKILL, current); 135 do_exit(SIGKILL);
136 schedule();
137} 136}
138 137
139/** 138/**
@@ -439,6 +438,7 @@ recover_from_read_error(slidx_table_t *slidx, peidx_table_t *peidx, pal_bus_chec
439 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr; 438 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr;
440 psr2->cpl = 0; 439 psr2->cpl = 0;
441 psr2->ri = 0; 440 psr2->ri = 0;
441 psr2->i = 0;
442 442
443 return 1; 443 return 1;
444 } 444 }
diff --git a/arch/ia64/kernel/mca_drv_asm.S b/arch/ia64/kernel/mca_drv_asm.S
index bcfa05acc561..2d7e0217638d 100644
--- a/arch/ia64/kernel/mca_drv_asm.S
+++ b/arch/ia64/kernel/mca_drv_asm.S
@@ -10,6 +10,7 @@
10 10
11#include <asm/asmmacro.h> 11#include <asm/asmmacro.h>
12#include <asm/processor.h> 12#include <asm/processor.h>
13#include <asm/ptrace.h>
13 14
14GLOBAL_ENTRY(mca_handler_bhhook) 15GLOBAL_ENTRY(mca_handler_bhhook)
15 invala // clear RSE ? 16 invala // clear RSE ?
@@ -20,12 +21,21 @@ GLOBAL_ENTRY(mca_handler_bhhook)
20 ;; 21 ;;
21 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
22 ;; 23 ;;
24 mov ar.rsc=0
25 ;;
23 mov r13=IA64_KR(CURRENT) // current task pointer 26 mov r13=IA64_KR(CURRENT) // current task pointer
24 ;; 27 ;;
25 adds r12=IA64_TASK_THREAD_KSP_OFFSET,r13 28 mov r2=r13
29 ;;
30 addl r22=IA64_RBS_OFFSET,r2
31 ;;
32 mov ar.bspstore=r22
26 ;; 33 ;;
27 ld8 r12=[r12] // stack pointer 34 addl sp=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r2
28 ;; 35 ;;
36 adds r2=IA64_TASK_THREAD_ON_USTACK_OFFSET,r13
37 ;;
38 st1 [r2]=r0 // clear current->thread.on_ustack flag
29 mov loc0=r16 39 mov loc0=r16
30 movl loc1=mca_handler_bh // recovery C function 40 movl loc1=mca_handler_bh // recovery C function
31 ;; 41 ;;
@@ -34,7 +44,9 @@ GLOBAL_ENTRY(mca_handler_bhhook)
34 ;; 44 ;;
35 mov loc1=rp 45 mov loc1=rp
36 ;; 46 ;;
37 br.call.sptk.many rp=b6 // not return ... 47 ssm psr.i
48 ;;
49 br.call.sptk.many rp=b6 // does not return ...
38 ;; 50 ;;
39 mov ar.pfs=loc0 51 mov ar.pfs=loc0
40 mov rp=loc1 52 mov rp=loc1
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 71147be3279c..71c101601e3e 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -480,14 +480,6 @@ typedef struct {
480#define PFM_CMD_ARG_MANY -1 /* cannot be zero */ 480#define PFM_CMD_ARG_MANY -1 /* cannot be zero */
481 481
482typedef struct { 482typedef struct {
483 int debug; /* turn on/off debugging via syslog */
484 int debug_ovfl; /* turn on/off debug printk in overflow handler */
485 int fastctxsw; /* turn on/off fast (unsecure) ctxsw */
486 int expert_mode; /* turn on/off value checking */
487 int debug_pfm_read;
488} pfm_sysctl_t;
489
490typedef struct {
491 unsigned long pfm_spurious_ovfl_intr_count; /* keep track of spurious ovfl interrupts */ 483 unsigned long pfm_spurious_ovfl_intr_count; /* keep track of spurious ovfl interrupts */
492 unsigned long pfm_replay_ovfl_intr_count; /* keep track of replayed ovfl interrupts */ 484 unsigned long pfm_replay_ovfl_intr_count; /* keep track of replayed ovfl interrupts */
493 unsigned long pfm_ovfl_intr_count; /* keep track of ovfl interrupts */ 485 unsigned long pfm_ovfl_intr_count; /* keep track of ovfl interrupts */
@@ -514,8 +506,8 @@ static LIST_HEAD(pfm_buffer_fmt_list);
514static pmu_config_t *pmu_conf; 506static pmu_config_t *pmu_conf;
515 507
516/* sysctl() controls */ 508/* sysctl() controls */
517static pfm_sysctl_t pfm_sysctl; 509pfm_sysctl_t pfm_sysctl;
518int pfm_debug_var; 510EXPORT_SYMBOL(pfm_sysctl);
519 511
520static ctl_table pfm_ctl_table[]={ 512static ctl_table pfm_ctl_table[]={
521 {1, "debug", &pfm_sysctl.debug, sizeof(int), 0666, NULL, &proc_dointvec, NULL,}, 513 {1, "debug", &pfm_sysctl.debug, sizeof(int), 0666, NULL, &proc_dointvec, NULL,},
@@ -1273,6 +1265,8 @@ out:
1273} 1265}
1274EXPORT_SYMBOL(pfm_unregister_buffer_fmt); 1266EXPORT_SYMBOL(pfm_unregister_buffer_fmt);
1275 1267
1268extern void update_pal_halt_status(int);
1269
1276static int 1270static int
1277pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu) 1271pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
1278{ 1272{
@@ -1319,6 +1313,11 @@ pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu)
1319 is_syswide, 1313 is_syswide,
1320 cpu)); 1314 cpu));
1321 1315
1316 /*
1317 * disable default_idle() to go to PAL_HALT
1318 */
1319 update_pal_halt_status(0);
1320
1322 UNLOCK_PFS(flags); 1321 UNLOCK_PFS(flags);
1323 1322
1324 return 0; 1323 return 0;
@@ -1374,6 +1373,12 @@ pfm_unreserve_session(pfm_context_t *ctx, int is_syswide, unsigned int cpu)
1374 is_syswide, 1373 is_syswide,
1375 cpu)); 1374 cpu));
1376 1375
1376 /*
1377 * if possible, enable default_idle() to go into PAL_HALT
1378 */
1379 if (pfm_sessions.pfs_task_sessions == 0 && pfm_sessions.pfs_sys_sessions == 0)
1380 update_pal_halt_status(1);
1381
1377 UNLOCK_PFS(flags); 1382 UNLOCK_PFS(flags);
1378 1383
1379 return 0; 1384 return 0;
@@ -1576,7 +1581,7 @@ pfm_read(struct file *filp, char __user *buf, size_t size, loff_t *ppos)
1576 goto abort_locked; 1581 goto abort_locked;
1577 } 1582 }
1578 1583
1579 DPRINT(("[%d] fd=%d type=%d\n", current->pid, msg->pfm_gen_msg.msg_ctx_fd, msg->pfm_gen_msg.msg_type)); 1584 DPRINT(("fd=%d type=%d\n", msg->pfm_gen_msg.msg_ctx_fd, msg->pfm_gen_msg.msg_type));
1580 1585
1581 ret = -EFAULT; 1586 ret = -EFAULT;
1582 if(copy_to_user(buf, msg, sizeof(pfm_msg_t)) == 0) ret = sizeof(pfm_msg_t); 1587 if(copy_to_user(buf, msg, sizeof(pfm_msg_t)) == 0) ret = sizeof(pfm_msg_t);
@@ -3695,8 +3700,6 @@ pfm_debug(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3695 3700
3696 pfm_sysctl.debug = m == 0 ? 0 : 1; 3701 pfm_sysctl.debug = m == 0 ? 0 : 1;
3697 3702
3698 pfm_debug_var = pfm_sysctl.debug;
3699
3700 printk(KERN_INFO "perfmon debugging %s (timing reset)\n", pfm_sysctl.debug ? "on" : "off"); 3703 printk(KERN_INFO "perfmon debugging %s (timing reset)\n", pfm_sysctl.debug ? "on" : "off");
3701 3704
3702 if (m == 0) { 3705 if (m == 0) {
@@ -4212,7 +4215,7 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
4212 DPRINT(("cannot load to [%d], invalid ctx_state=%d\n", 4215 DPRINT(("cannot load to [%d], invalid ctx_state=%d\n",
4213 req->load_pid, 4216 req->load_pid,
4214 ctx->ctx_state)); 4217 ctx->ctx_state));
4215 return -EINVAL; 4218 return -EBUSY;
4216 } 4219 }
4217 4220
4218 DPRINT(("load_pid [%d] using_dbreg=%d\n", req->load_pid, ctx->ctx_fl_using_dbreg)); 4221 DPRINT(("load_pid [%d] using_dbreg=%d\n", req->load_pid, ctx->ctx_fl_using_dbreg));
@@ -4714,16 +4717,26 @@ recheck:
4714 if (task == current || ctx->ctx_fl_system) return 0; 4717 if (task == current || ctx->ctx_fl_system) return 0;
4715 4718
4716 /* 4719 /*
4717 * if context is UNLOADED we are safe to go 4720 * we are monitoring another thread
4718 */ 4721 */
4719 if (state == PFM_CTX_UNLOADED) return 0; 4722 switch(state) {
4720 4723 case PFM_CTX_UNLOADED:
4721 /* 4724 /*
4722 * no command can operate on a zombie context 4725 * if context is UNLOADED we are safe to go
4723 */ 4726 */
4724 if (state == PFM_CTX_ZOMBIE) { 4727 return 0;
4725 DPRINT(("cmd %d state zombie cannot operate on context\n", cmd)); 4728 case PFM_CTX_ZOMBIE:
4726 return -EINVAL; 4729 /*
4730 * no command can operate on a zombie context
4731 */
4732 DPRINT(("cmd %d state zombie cannot operate on context\n", cmd));
4733 return -EINVAL;
4734 case PFM_CTX_MASKED:
4735 /*
4736 * PMU state has been saved to software even though
4737 * the thread may still be running.
4738 */
4739 if (cmd != PFM_UNLOAD_CONTEXT) return 0;
4727 } 4740 }
4728 4741
4729 /* 4742 /*
@@ -4996,13 +5009,21 @@ pfm_context_force_terminate(pfm_context_t *ctx, struct pt_regs *regs)
4996} 5009}
4997 5010
4998static int pfm_ovfl_notify_user(pfm_context_t *ctx, unsigned long ovfl_pmds); 5011static int pfm_ovfl_notify_user(pfm_context_t *ctx, unsigned long ovfl_pmds);
4999 5012 /*
5013 * pfm_handle_work() can be called with interrupts enabled
5014 * (TIF_NEED_RESCHED) or disabled. The down_interruptible
5015 * call may sleep, therefore we must re-enable interrupts
5016 * to avoid deadlocks. It is safe to do so because this function
5017 * is called ONLY when returning to user level (PUStk=1), in which case
5018 * there is no risk of kernel stack overflow due to deep
5019 * interrupt nesting.
5020 */
5000void 5021void
5001pfm_handle_work(void) 5022pfm_handle_work(void)
5002{ 5023{
5003 pfm_context_t *ctx; 5024 pfm_context_t *ctx;
5004 struct pt_regs *regs; 5025 struct pt_regs *regs;
5005 unsigned long flags; 5026 unsigned long flags, dummy_flags;
5006 unsigned long ovfl_regs; 5027 unsigned long ovfl_regs;
5007 unsigned int reason; 5028 unsigned int reason;
5008 int ret; 5029 int ret;
@@ -5039,18 +5060,15 @@ pfm_handle_work(void)
5039 //if (CTX_OVFL_NOBLOCK(ctx)) goto skip_blocking; 5060 //if (CTX_OVFL_NOBLOCK(ctx)) goto skip_blocking;
5040 if (reason == PFM_TRAP_REASON_RESET) goto skip_blocking; 5061 if (reason == PFM_TRAP_REASON_RESET) goto skip_blocking;
5041 5062
5063 /*
5064 * restore interrupt mask to what it was on entry.
5065 * Could be enabled/diasbled.
5066 */
5042 UNPROTECT_CTX(ctx, flags); 5067 UNPROTECT_CTX(ctx, flags);
5043 5068
5044 /* 5069 /*
5045 * pfm_handle_work() is currently called with interrupts disabled. 5070 * force interrupt enable because of down_interruptible()
5046 * The down_interruptible call may sleep, therefore we 5071 */
5047 * must re-enable interrupts to avoid deadlocks. It is
5048 * safe to do so because this function is called ONLY
5049 * when returning to user level (PUStk=1), in which case
5050 * there is no risk of kernel stack overflow due to deep
5051 * interrupt nesting.
5052 */
5053 BUG_ON(flags & IA64_PSR_I);
5054 local_irq_enable(); 5072 local_irq_enable();
5055 5073
5056 DPRINT(("before block sleeping\n")); 5074 DPRINT(("before block sleeping\n"));
@@ -5064,12 +5082,12 @@ pfm_handle_work(void)
5064 DPRINT(("after block sleeping ret=%d\n", ret)); 5082 DPRINT(("after block sleeping ret=%d\n", ret));
5065 5083
5066 /* 5084 /*
5067 * disable interrupts to restore state we had upon entering 5085 * lock context and mask interrupts again
5068 * this function 5086 * We save flags into a dummy because we may have
5087 * altered interrupts mask compared to entry in this
5088 * function.
5069 */ 5089 */
5070 local_irq_disable(); 5090 PROTECT_CTX(ctx, dummy_flags);
5071
5072 PROTECT_CTX(ctx, flags);
5073 5091
5074 /* 5092 /*
5075 * we need to read the ovfl_regs only after wake-up 5093 * we need to read the ovfl_regs only after wake-up
@@ -5095,7 +5113,9 @@ skip_blocking:
5095 ctx->ctx_ovfl_regs[0] = 0UL; 5113 ctx->ctx_ovfl_regs[0] = 0UL;
5096 5114
5097nothing_to_do: 5115nothing_to_do:
5098 5116 /*
5117 * restore flags as they were upon entry
5118 */
5099 UNPROTECT_CTX(ctx, flags); 5119 UNPROTECT_CTX(ctx, flags);
5100} 5120}
5101 5121
diff --git a/arch/ia64/kernel/perfmon_default_smpl.c b/arch/ia64/kernel/perfmon_default_smpl.c
index 965d29004555..344941db0a9e 100644
--- a/arch/ia64/kernel/perfmon_default_smpl.c
+++ b/arch/ia64/kernel/perfmon_default_smpl.c
@@ -20,24 +20,17 @@ MODULE_AUTHOR("Stephane Eranian <eranian@hpl.hp.com>");
20MODULE_DESCRIPTION("perfmon default sampling format"); 20MODULE_DESCRIPTION("perfmon default sampling format");
21MODULE_LICENSE("GPL"); 21MODULE_LICENSE("GPL");
22 22
23MODULE_PARM(debug, "i");
24MODULE_PARM_DESC(debug, "debug");
25
26MODULE_PARM(debug_ovfl, "i");
27MODULE_PARM_DESC(debug_ovfl, "debug ovfl");
28
29
30#define DEFAULT_DEBUG 1 23#define DEFAULT_DEBUG 1
31 24
32#ifdef DEFAULT_DEBUG 25#ifdef DEFAULT_DEBUG
33#define DPRINT(a) \ 26#define DPRINT(a) \
34 do { \ 27 do { \
35 if (unlikely(debug >0)) { printk("%s.%d: CPU%d ", __FUNCTION__, __LINE__, smp_processor_id()); printk a; } \ 28 if (unlikely(pfm_sysctl.debug >0)) { printk("%s.%d: CPU%d ", __FUNCTION__, __LINE__, smp_processor_id()); printk a; } \
36 } while (0) 29 } while (0)
37 30
38#define DPRINT_ovfl(a) \ 31#define DPRINT_ovfl(a) \
39 do { \ 32 do { \
40 if (unlikely(debug_ovfl >0)) { printk("%s.%d: CPU%d ", __FUNCTION__, __LINE__, smp_processor_id()); printk a; } \ 33 if (unlikely(pfm_sysctl.debug > 0 && pfm_sysctl.debug_ovfl >0)) { printk("%s.%d: CPU%d ", __FUNCTION__, __LINE__, smp_processor_id()); printk a; } \
41 } while (0) 34 } while (0)
42 35
43#else 36#else
@@ -45,8 +38,6 @@ MODULE_PARM_DESC(debug_ovfl, "debug ovfl");
45#define DPRINT_ovfl(a) 38#define DPRINT_ovfl(a)
46#endif 39#endif
47 40
48static int debug, debug_ovfl;
49
50static int 41static int
51default_validate(struct task_struct *task, unsigned int flags, int cpu, void *data) 42default_validate(struct task_struct *task, unsigned int flags, int cpu, void *data)
52{ 43{
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 91293388dd29..ebb71f3d6d19 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 1998-2003 Hewlett-Packard Co 4 * Copyright (C) 1998-2003 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com> 5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * 04/11/17 Ashok Raj <ashok.raj@intel.com> Added CPU Hotplug Support
6 */ 7 */
7#define __KERNEL_SYSCALLS__ /* see <asm/unistd.h> */ 8#define __KERNEL_SYSCALLS__ /* see <asm/unistd.h> */
8#include <linux/config.h> 9#include <linux/config.h>
@@ -49,7 +50,7 @@
49#include "sigframe.h" 50#include "sigframe.h"
50 51
51void (*ia64_mark_idle)(int); 52void (*ia64_mark_idle)(int);
52static cpumask_t cpu_idle_map; 53static DEFINE_PER_CPU(unsigned int, cpu_idle_state);
53 54
54unsigned long boot_option_idle_override = 0; 55unsigned long boot_option_idle_override = 0;
55EXPORT_SYMBOL(boot_option_idle_override); 56EXPORT_SYMBOL(boot_option_idle_override);
@@ -172,7 +173,9 @@ do_notify_resume_user (sigset_t *oldset, struct sigscratch *scr, long in_syscall
172 ia64_do_signal(oldset, scr, in_syscall); 173 ia64_do_signal(oldset, scr, in_syscall);
173} 174}
174 175
175static int pal_halt = 1; 176static int pal_halt = 1;
177static int can_do_pal_halt = 1;
178
176static int __init nohalt_setup(char * str) 179static int __init nohalt_setup(char * str)
177{ 180{
178 pal_halt = 0; 181 pal_halt = 0;
@@ -180,16 +183,20 @@ static int __init nohalt_setup(char * str)
180} 183}
181__setup("nohalt", nohalt_setup); 184__setup("nohalt", nohalt_setup);
182 185
186void
187update_pal_halt_status(int status)
188{
189 can_do_pal_halt = pal_halt && status;
190}
191
183/* 192/*
184 * We use this if we don't have any better idle routine.. 193 * We use this if we don't have any better idle routine..
185 */ 194 */
186void 195void
187default_idle (void) 196default_idle (void)
188{ 197{
189 unsigned long pmu_active = ia64_getreg(_IA64_REG_PSR) & (IA64_PSR_PP | IA64_PSR_UP);
190
191 while (!need_resched()) 198 while (!need_resched())
192 if (pal_halt && !pmu_active) 199 if (can_do_pal_halt)
193 safe_halt(); 200 safe_halt();
194 else 201 else
195 cpu_relax(); 202 cpu_relax();
@@ -200,27 +207,20 @@ default_idle (void)
200static inline void play_dead(void) 207static inline void play_dead(void)
201{ 208{
202 extern void ia64_cpu_local_tick (void); 209 extern void ia64_cpu_local_tick (void);
210 unsigned int this_cpu = smp_processor_id();
211
203 /* Ack it */ 212 /* Ack it */
204 __get_cpu_var(cpu_state) = CPU_DEAD; 213 __get_cpu_var(cpu_state) = CPU_DEAD;
205 214
206 /* We shouldn't have to disable interrupts while dead, but
207 * some interrupts just don't seem to go away, and this makes
208 * it "work" for testing purposes. */
209 max_xtp(); 215 max_xtp();
210 local_irq_disable(); 216 local_irq_disable();
211 /* Death loop */ 217 idle_task_exit();
212 while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE) 218 ia64_jump_to_sal(&sal_boot_rendez_state[this_cpu]);
213 cpu_relax();
214
215 /* 219 /*
216 * Enable timer interrupts from now on 220 * The above is a point of no-return, the processor is
217 * Not required if we put processor in SAL_BOOT_RENDEZ mode. 221 * expected to be in SAL loop now.
218 */ 222 */
219 local_flush_tlb_all(); 223 BUG();
220 cpu_set(smp_processor_id(), cpu_online_map);
221 wmb();
222 ia64_cpu_local_tick ();
223 local_irq_enable();
224} 224}
225#else 225#else
226static inline void play_dead(void) 226static inline void play_dead(void)
@@ -229,20 +229,31 @@ static inline void play_dead(void)
229} 229}
230#endif /* CONFIG_HOTPLUG_CPU */ 230#endif /* CONFIG_HOTPLUG_CPU */
231 231
232
233void cpu_idle_wait(void) 232void cpu_idle_wait(void)
234{ 233{
235 int cpu; 234 unsigned int cpu, this_cpu = get_cpu();
236 cpumask_t map; 235 cpumask_t map;
236
237 set_cpus_allowed(current, cpumask_of_cpu(this_cpu));
238 put_cpu();
237 239
238 for_each_online_cpu(cpu) 240 cpus_clear(map);
239 cpu_set(cpu, cpu_idle_map); 241 for_each_online_cpu(cpu) {
242 per_cpu(cpu_idle_state, cpu) = 1;
243 cpu_set(cpu, map);
244 }
240 245
241 wmb(); 246 __get_cpu_var(cpu_idle_state) = 0;
242 do { 247
243 ssleep(1); 248 wmb();
244 cpus_and(map, cpu_idle_map, cpu_online_map); 249 do {
245 } while (!cpus_empty(map)); 250 ssleep(1);
251 for_each_online_cpu(cpu) {
252 if (cpu_isset(cpu, map) && !per_cpu(cpu_idle_state, cpu))
253 cpu_clear(cpu, map);
254 }
255 cpus_and(map, map, cpu_online_map);
256 } while (!cpus_empty(map));
246} 257}
247EXPORT_SYMBOL_GPL(cpu_idle_wait); 258EXPORT_SYMBOL_GPL(cpu_idle_wait);
248 259
@@ -250,7 +261,6 @@ void __attribute__((noreturn))
250cpu_idle (void) 261cpu_idle (void)
251{ 262{
252 void (*mark_idle)(int) = ia64_mark_idle; 263 void (*mark_idle)(int) = ia64_mark_idle;
253 int cpu = smp_processor_id();
254 264
255 /* endless idle loop with no priority at all */ 265 /* endless idle loop with no priority at all */
256 while (1) { 266 while (1) {
@@ -261,12 +271,13 @@ cpu_idle (void)
261 while (!need_resched()) { 271 while (!need_resched()) {
262 void (*idle)(void); 272 void (*idle)(void);
263 273
274 if (__get_cpu_var(cpu_idle_state))
275 __get_cpu_var(cpu_idle_state) = 0;
276
277 rmb();
264 if (mark_idle) 278 if (mark_idle)
265 (*mark_idle)(1); 279 (*mark_idle)(1);
266 280
267 if (cpu_isset(cpu, cpu_idle_map))
268 cpu_clear(cpu, cpu_idle_map);
269 rmb();
270 idle = pm_idle; 281 idle = pm_idle;
271 if (!idle) 282 if (!idle)
272 idle = default_idle; 283 idle = default_idle;
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 55789fcd7210..907464ee7273 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -17,6 +17,7 @@
17#include <linux/user.h> 17#include <linux/user.h>
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/audit.h> 19#include <linux/audit.h>
20#include <linux/signal.h>
20 21
21#include <asm/pgtable.h> 22#include <asm/pgtable.h>
22#include <asm/processor.h> 23#include <asm/processor.h>
@@ -1481,7 +1482,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
1481 case PTRACE_CONT: 1482 case PTRACE_CONT:
1482 /* restart after signal. */ 1483 /* restart after signal. */
1483 ret = -EIO; 1484 ret = -EIO;
1484 if (data > _NSIG) 1485 if (!valid_signal(data))
1485 goto out_tsk; 1486 goto out_tsk;
1486 if (request == PTRACE_SYSCALL) 1487 if (request == PTRACE_SYSCALL)
1487 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 1488 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -1520,7 +1521,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
1520 /* let child execute for one instruction */ 1521 /* let child execute for one instruction */
1521 case PTRACE_SINGLEBLOCK: 1522 case PTRACE_SINGLEBLOCK:
1522 ret = -EIO; 1523 ret = -EIO;
1523 if (data > _NSIG) 1524 if (!valid_signal(data))
1524 goto out_tsk; 1525 goto out_tsk;
1525 1526
1526 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 1527 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -1595,20 +1596,25 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
1595 long arg4, long arg5, long arg6, long arg7, 1596 long arg4, long arg5, long arg6, long arg7,
1596 struct pt_regs regs) 1597 struct pt_regs regs)
1597{ 1598{
1598 long syscall; 1599 if (test_thread_flag(TIF_SYSCALL_TRACE)
1600 && (current->ptrace & PT_PTRACED))
1601 syscall_trace();
1599 1602
1600 if (unlikely(current->audit_context)) { 1603 if (unlikely(current->audit_context)) {
1601 if (IS_IA32_PROCESS(&regs)) 1604 long syscall;
1605 int arch;
1606
1607 if (IS_IA32_PROCESS(&regs)) {
1602 syscall = regs.r1; 1608 syscall = regs.r1;
1603 else 1609 arch = AUDIT_ARCH_I386;
1610 } else {
1604 syscall = regs.r15; 1611 syscall = regs.r15;
1612 arch = AUDIT_ARCH_IA64;
1613 }
1605 1614
1606 audit_syscall_entry(current, syscall, arg0, arg1, arg2, arg3); 1615 audit_syscall_entry(current, arch, syscall, arg0, arg1, arg2, arg3);
1607 } 1616 }
1608 1617
1609 if (test_thread_flag(TIF_SYSCALL_TRACE)
1610 && (current->ptrace & PT_PTRACED))
1611 syscall_trace();
1612} 1618}
1613 1619
1614/* "asmlinkage" so the input arguments are preserved... */ 1620/* "asmlinkage" so the input arguments are preserved... */
@@ -1619,7 +1625,7 @@ syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
1619 struct pt_regs regs) 1625 struct pt_regs regs)
1620{ 1626{
1621 if (unlikely(current->audit_context)) 1627 if (unlikely(current->audit_context))
1622 audit_syscall_exit(current, regs.r8); 1628 audit_syscall_exit(current, AUDITSC_RESULT(regs.r10), regs.r8);
1623 1629
1624 if (test_thread_flag(TIF_SYSCALL_TRACE) 1630 if (test_thread_flag(TIF_SYSCALL_TRACE)
1625 && (current->ptrace & PT_PTRACED)) 1631 && (current->ptrace & PT_PTRACED))
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index f05650c801d2..b7e6b4cb374b 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -4,10 +4,15 @@
4 * Copyright (C) 1998-2001, 2003-2004 Hewlett-Packard Co 4 * Copyright (C) 1998-2001, 2003-2004 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com> 5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * Stephane Eranian <eranian@hpl.hp.com> 6 * Stephane Eranian <eranian@hpl.hp.com>
7 * Copyright (C) 2000, Rohit Seth <rohit.seth@intel.com> 7 * Copyright (C) 2000, 2004 Intel Corp
8 * Rohit Seth <rohit.seth@intel.com>
9 * Suresh Siddha <suresh.b.siddha@intel.com>
10 * Gordon Jin <gordon.jin@intel.com>
8 * Copyright (C) 1999 VA Linux Systems 11 * Copyright (C) 1999 VA Linux Systems
9 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> 12 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
10 * 13 *
14 * 12/26/04 S.Siddha, G.Jin, R.Seth
15 * Add multi-threading and multi-core detection
11 * 11/12/01 D.Mosberger Convert get_cpuinfo() to seq_file based show_cpuinfo(). 16 * 11/12/01 D.Mosberger Convert get_cpuinfo() to seq_file based show_cpuinfo().
12 * 04/04/00 D.Mosberger renamed cpu_initialized to cpu_online_map 17 * 04/04/00 D.Mosberger renamed cpu_initialized to cpu_online_map
13 * 03/31/00 R.Seth cpu_initialized and current->processor fixes 18 * 03/31/00 R.Seth cpu_initialized and current->processor fixes
@@ -296,6 +301,34 @@ mark_bsp_online (void)
296#endif 301#endif
297} 302}
298 303
304#ifdef CONFIG_SMP
305static void
306check_for_logical_procs (void)
307{
308 pal_logical_to_physical_t info;
309 s64 status;
310
311 status = ia64_pal_logical_to_phys(0, &info);
312 if (status == -1) {
313 printk(KERN_INFO "No logical to physical processor mapping "
314 "available\n");
315 return;
316 }
317 if (status) {
318 printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n",
319 status);
320 return;
321 }
322 /*
323 * Total number of siblings that BSP has. Though not all of them
324 * may have booted successfully. The correct number of siblings
325 * booted is in info.overview_num_log.
326 */
327 smp_num_siblings = info.overview_tpc;
328 smp_num_cpucores = info.overview_cpp;
329}
330#endif
331
299void __init 332void __init
300setup_arch (char **cmdline_p) 333setup_arch (char **cmdline_p)
301{ 334{
@@ -356,6 +389,19 @@ setup_arch (char **cmdline_p)
356 389
357#ifdef CONFIG_SMP 390#ifdef CONFIG_SMP
358 cpu_physical_id(0) = hard_smp_processor_id(); 391 cpu_physical_id(0) = hard_smp_processor_id();
392
393 cpu_set(0, cpu_sibling_map[0]);
394 cpu_set(0, cpu_core_map[0]);
395
396 check_for_logical_procs();
397 if (smp_num_cpucores > 1)
398 printk(KERN_INFO
399 "cpu package is Multi-Core capable: number of cores=%d\n",
400 smp_num_cpucores);
401 if (smp_num_siblings > 1)
402 printk(KERN_INFO
403 "cpu package is Multi-Threading capable: number of siblings=%d\n",
404 smp_num_siblings);
359#endif 405#endif
360 406
361 cpu_init(); /* initialize the bootstrap CPU */ 407 cpu_init(); /* initialize the bootstrap CPU */
@@ -459,12 +505,23 @@ show_cpuinfo (struct seq_file *m, void *v)
459 "cpu regs : %u\n" 505 "cpu regs : %u\n"
460 "cpu MHz : %lu.%06lu\n" 506 "cpu MHz : %lu.%06lu\n"
461 "itc MHz : %lu.%06lu\n" 507 "itc MHz : %lu.%06lu\n"
462 "BogoMIPS : %lu.%02lu\n\n", 508 "BogoMIPS : %lu.%02lu\n",
463 cpunum, c->vendor, family, c->model, c->revision, c->archrev, 509 cpunum, c->vendor, family, c->model, c->revision, c->archrev,
464 features, c->ppn, c->number, 510 features, c->ppn, c->number,
465 c->proc_freq / 1000000, c->proc_freq % 1000000, 511 c->proc_freq / 1000000, c->proc_freq % 1000000,
466 c->itc_freq / 1000000, c->itc_freq % 1000000, 512 c->itc_freq / 1000000, c->itc_freq % 1000000,
467 lpj*HZ/500000, (lpj*HZ/5000) % 100); 513 lpj*HZ/500000, (lpj*HZ/5000) % 100);
514#ifdef CONFIG_SMP
515 seq_printf(m, "siblings : %u\n", c->num_log);
516 if (c->threads_per_core > 1 || c->cores_per_socket > 1)
517 seq_printf(m,
518 "physical id: %u\n"
519 "core id : %u\n"
520 "thread id : %u\n",
521 c->socket_id, c->core_id, c->thread_id);
522#endif
523 seq_printf(m,"\n");
524
468 return 0; 525 return 0;
469} 526}
470 527
@@ -533,6 +590,14 @@ identify_cpu (struct cpuinfo_ia64 *c)
533 memcpy(c->vendor, cpuid.field.vendor, 16); 590 memcpy(c->vendor, cpuid.field.vendor, 16);
534#ifdef CONFIG_SMP 591#ifdef CONFIG_SMP
535 c->cpu = smp_processor_id(); 592 c->cpu = smp_processor_id();
593
594 /* below default values will be overwritten by identify_siblings()
595 * for Multi-Threading/Multi-Core capable cpu's
596 */
597 c->threads_per_core = c->cores_per_socket = c->num_log = 1;
598 c->socket_id = -1;
599
600 identify_siblings(c);
536#endif 601#endif
537 c->ppn = cpuid.field.ppn; 602 c->ppn = cpuid.field.ppn;
538 c->number = cpuid.field.number; 603 c->number = cpuid.field.number;
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
index 6891d86937d9..499b7e5317cf 100644
--- a/arch/ia64/kernel/signal.c
+++ b/arch/ia64/kernel/signal.c
@@ -224,7 +224,8 @@ ia64_rt_sigreturn (struct sigscratch *scr)
224 * could be corrupted. 224 * could be corrupted.
225 */ 225 */
226 retval = (long) &ia64_leave_kernel; 226 retval = (long) &ia64_leave_kernel;
227 if (test_thread_flag(TIF_SYSCALL_TRACE)) 227 if (test_thread_flag(TIF_SYSCALL_TRACE)
228 || test_thread_flag(TIF_SYSCALL_AUDIT))
228 /* 229 /*
229 * strace expects to be notified after sigreturn returns even though the 230 * strace expects to be notified after sigreturn returns even though the
230 * context to which we return may not be in the middle of a syscall. 231 * context to which we return may not be in the middle of a syscall.
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 5318f0cbfc26..0d5ee57c9865 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -1,14 +1,25 @@
1/* 1/*
2 * SMP boot-related support 2 * SMP boot-related support
3 * 3 *
4 * Copyright (C) 1998-2003 Hewlett-Packard Co 4 * Copyright (C) 1998-2003, 2005 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com> 5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * Copyright (C) 2001, 2004-2005 Intel Corp
7 * Rohit Seth <rohit.seth@intel.com>
8 * Suresh Siddha <suresh.b.siddha@intel.com>
9 * Gordon Jin <gordon.jin@intel.com>
10 * Ashok Raj <ashok.raj@intel.com>
6 * 11 *
7 * 01/05/16 Rohit Seth <rohit.seth@intel.com> Moved SMP booting functions from smp.c to here. 12 * 01/05/16 Rohit Seth <rohit.seth@intel.com> Moved SMP booting functions from smp.c to here.
8 * 01/04/27 David Mosberger <davidm@hpl.hp.com> Added ITC synching code. 13 * 01/04/27 David Mosberger <davidm@hpl.hp.com> Added ITC synching code.
9 * 02/07/31 David Mosberger <davidm@hpl.hp.com> Switch over to hotplug-CPU boot-sequence. 14 * 02/07/31 David Mosberger <davidm@hpl.hp.com> Switch over to hotplug-CPU boot-sequence.
10 * smp_boot_cpus()/smp_commence() is replaced by 15 * smp_boot_cpus()/smp_commence() is replaced by
11 * smp_prepare_cpus()/__cpu_up()/smp_cpus_done(). 16 * smp_prepare_cpus()/__cpu_up()/smp_cpus_done().
17 * 04/06/21 Ashok Raj <ashok.raj@intel.com> Added CPU Hotplug Support
18 * 04/12/26 Jin Gordon <gordon.jin@intel.com>
19 * 04/12/26 Rohit Seth <rohit.seth@intel.com>
20 * Add multi-threading and multi-core detection
21 * 05/01/30 Suresh Siddha <suresh.b.siddha@intel.com>
22 * Setup cpu_sibling_map and cpu_core_map
12 */ 23 */
13#include <linux/config.h> 24#include <linux/config.h>
14 25
@@ -58,6 +69,37 @@
58#define Dprintk(x...) 69#define Dprintk(x...)
59#endif 70#endif
60 71
72#ifdef CONFIG_HOTPLUG_CPU
73/*
74 * Store all idle threads, this can be reused instead of creating
75 * a new thread. Also avoids complicated thread destroy functionality
76 * for idle threads.
77 */
78struct task_struct *idle_thread_array[NR_CPUS];
79
80/*
81 * Global array allocated for NR_CPUS at boot time
82 */
83struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
84
85/*
86 * start_ap in head.S uses this to store current booting cpu
87 * info.
88 */
89struct sal_to_os_boot *sal_state_for_booting_cpu = &sal_boot_rendez_state[0];
90
91#define set_brendez_area(x) (sal_state_for_booting_cpu = &sal_boot_rendez_state[(x)]);
92
93#define get_idle_for_cpu(x) (idle_thread_array[(x)])
94#define set_idle_for_cpu(x,p) (idle_thread_array[(x)] = (p))
95
96#else
97
98#define get_idle_for_cpu(x) (NULL)
99#define set_idle_for_cpu(x,p)
100#define set_brendez_area(x)
101#endif
102
61 103
62/* 104/*
63 * ITC synchronization related stuff: 105 * ITC synchronization related stuff:
@@ -90,6 +132,11 @@ EXPORT_SYMBOL(cpu_online_map);
90cpumask_t cpu_possible_map; 132cpumask_t cpu_possible_map;
91EXPORT_SYMBOL(cpu_possible_map); 133EXPORT_SYMBOL(cpu_possible_map);
92 134
135cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned;
136cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned;
137int smp_num_siblings = 1;
138int smp_num_cpucores = 1;
139
93/* which logical CPU number maps to which CPU (physical APIC ID) */ 140/* which logical CPU number maps to which CPU (physical APIC ID) */
94volatile int ia64_cpu_to_sapicid[NR_CPUS]; 141volatile int ia64_cpu_to_sapicid[NR_CPUS];
95EXPORT_SYMBOL(ia64_cpu_to_sapicid); 142EXPORT_SYMBOL(ia64_cpu_to_sapicid);
@@ -124,7 +171,8 @@ sync_master (void *arg)
124 local_irq_save(flags); 171 local_irq_save(flags);
125 { 172 {
126 for (i = 0; i < NUM_ROUNDS*NUM_ITERS; ++i) { 173 for (i = 0; i < NUM_ROUNDS*NUM_ITERS; ++i) {
127 while (!go[MASTER]); 174 while (!go[MASTER])
175 cpu_relax();
128 go[MASTER] = 0; 176 go[MASTER] = 0;
129 go[SLAVE] = ia64_get_itc(); 177 go[SLAVE] = ia64_get_itc();
130 } 178 }
@@ -147,7 +195,8 @@ get_delta (long *rt, long *master)
147 for (i = 0; i < NUM_ITERS; ++i) { 195 for (i = 0; i < NUM_ITERS; ++i) {
148 t0 = ia64_get_itc(); 196 t0 = ia64_get_itc();
149 go[MASTER] = 1; 197 go[MASTER] = 1;
150 while (!(tm = go[SLAVE])); 198 while (!(tm = go[SLAVE]))
199 cpu_relax();
151 go[SLAVE] = 0; 200 go[SLAVE] = 0;
152 t1 = ia64_get_itc(); 201 t1 = ia64_get_itc();
153 202
@@ -226,7 +275,8 @@ ia64_sync_itc (unsigned int master)
226 return; 275 return;
227 } 276 }
228 277
229 while (go[MASTER]); /* wait for master to be ready */ 278 while (go[MASTER])
279 cpu_relax(); /* wait for master to be ready */
230 280
231 spin_lock_irqsave(&itc_sync_lock, flags); 281 spin_lock_irqsave(&itc_sync_lock, flags);
232 { 282 {
@@ -345,7 +395,6 @@ start_secondary (void *unused)
345{ 395{
346 /* Early console may use I/O ports */ 396 /* Early console may use I/O ports */
347 ia64_set_kr(IA64_KR_IO_BASE, __pa(ia64_iobase)); 397 ia64_set_kr(IA64_KR_IO_BASE, __pa(ia64_iobase));
348
349 Dprintk("start_secondary: starting CPU 0x%x\n", hard_smp_processor_id()); 398 Dprintk("start_secondary: starting CPU 0x%x\n", hard_smp_processor_id());
350 efi_map_pal_code(); 399 efi_map_pal_code();
351 cpu_init(); 400 cpu_init();
@@ -384,6 +433,13 @@ do_boot_cpu (int sapicid, int cpu)
384 .done = COMPLETION_INITIALIZER(c_idle.done), 433 .done = COMPLETION_INITIALIZER(c_idle.done),
385 }; 434 };
386 DECLARE_WORK(work, do_fork_idle, &c_idle); 435 DECLARE_WORK(work, do_fork_idle, &c_idle);
436
437 c_idle.idle = get_idle_for_cpu(cpu);
438 if (c_idle.idle) {
439 init_idle(c_idle.idle, cpu);
440 goto do_rest;
441 }
442
387 /* 443 /*
388 * We can't use kernel_thread since we must avoid to reschedule the child. 444 * We can't use kernel_thread since we must avoid to reschedule the child.
389 */ 445 */
@@ -396,10 +452,15 @@ do_boot_cpu (int sapicid, int cpu)
396 452
397 if (IS_ERR(c_idle.idle)) 453 if (IS_ERR(c_idle.idle))
398 panic("failed fork for CPU %d", cpu); 454 panic("failed fork for CPU %d", cpu);
455
456 set_idle_for_cpu(cpu, c_idle.idle);
457
458do_rest:
399 task_for_booting_cpu = c_idle.idle; 459 task_for_booting_cpu = c_idle.idle;
400 460
401 Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid); 461 Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid);
402 462
463 set_brendez_area(cpu);
403 platform_send_ipi(cpu, ap_wakeup_vector, IA64_IPI_DM_INT, 0); 464 platform_send_ipi(cpu, ap_wakeup_vector, IA64_IPI_DM_INT, 0);
404 465
405 /* 466 /*
@@ -552,19 +613,70 @@ void __devinit smp_prepare_boot_cpu(void)
552 cpu_set(smp_processor_id(), cpu_callin_map); 613 cpu_set(smp_processor_id(), cpu_callin_map);
553} 614}
554 615
616/*
617 * mt_info[] is a temporary store for all info returned by
618 * PAL_LOGICAL_TO_PHYSICAL, to be copied into cpuinfo_ia64 when the
619 * specific cpu comes.
620 */
621static struct {
622 __u32 socket_id;
623 __u16 core_id;
624 __u16 thread_id;
625 __u16 proc_fixed_addr;
626 __u8 valid;
627}mt_info[NR_CPUS] __devinit;
628
555#ifdef CONFIG_HOTPLUG_CPU 629#ifdef CONFIG_HOTPLUG_CPU
556extern void fixup_irqs(void); 630static inline void
557/* must be called with cpucontrol mutex held */ 631remove_from_mtinfo(int cpu)
558static int __devinit cpu_enable(unsigned int cpu)
559{ 632{
560 per_cpu(cpu_state,cpu) = CPU_UP_PREPARE; 633 int i;
561 wmb();
562 634
563 while (!cpu_online(cpu)) 635 for_each_cpu(i)
564 cpu_relax(); 636 if (mt_info[i].valid && mt_info[i].socket_id ==
565 return 0; 637 cpu_data(cpu)->socket_id)
638 mt_info[i].valid = 0;
639}
640
641static inline void
642clear_cpu_sibling_map(int cpu)
643{
644 int i;
645
646 for_each_cpu_mask(i, cpu_sibling_map[cpu])
647 cpu_clear(cpu, cpu_sibling_map[i]);
648 for_each_cpu_mask(i, cpu_core_map[cpu])
649 cpu_clear(cpu, cpu_core_map[i]);
650
651 cpu_sibling_map[cpu] = cpu_core_map[cpu] = CPU_MASK_NONE;
652}
653
654static void
655remove_siblinginfo(int cpu)
656{
657 int last = 0;
658
659 if (cpu_data(cpu)->threads_per_core == 1 &&
660 cpu_data(cpu)->cores_per_socket == 1) {
661 cpu_clear(cpu, cpu_core_map[cpu]);
662 cpu_clear(cpu, cpu_sibling_map[cpu]);
663 return;
664 }
665
666 last = (cpus_weight(cpu_core_map[cpu]) == 1 ? 1 : 0);
667
668 /* remove it from all sibling map's */
669 clear_cpu_sibling_map(cpu);
670
671 /* if this cpu is the last in the core group, remove all its info
672 * from mt_info structure
673 */
674 if (last)
675 remove_from_mtinfo(cpu);
566} 676}
567 677
678extern void fixup_irqs(void);
679/* must be called with cpucontrol mutex held */
568int __cpu_disable(void) 680int __cpu_disable(void)
569{ 681{
570 int cpu = smp_processor_id(); 682 int cpu = smp_processor_id();
@@ -575,9 +687,10 @@ int __cpu_disable(void)
575 if (cpu == 0) 687 if (cpu == 0)
576 return -EBUSY; 688 return -EBUSY;
577 689
690 remove_siblinginfo(cpu);
578 fixup_irqs(); 691 fixup_irqs();
579 local_flush_tlb_all(); 692 local_flush_tlb_all();
580 printk ("Disabled cpu %u\n", smp_processor_id()); 693 cpu_clear(cpu, cpu_callin_map);
581 return 0; 694 return 0;
582} 695}
583 696
@@ -589,12 +702,7 @@ void __cpu_die(unsigned int cpu)
589 /* They ack this in play_dead by setting CPU_DEAD */ 702 /* They ack this in play_dead by setting CPU_DEAD */
590 if (per_cpu(cpu_state, cpu) == CPU_DEAD) 703 if (per_cpu(cpu_state, cpu) == CPU_DEAD)
591 { 704 {
592 /* 705 printk ("CPU %d is now offline\n", cpu);
593 * TBD: Enable this when physical removal
594 * or when we put the processor is put in
595 * SAL_BOOT_RENDEZ mode
596 * cpu_clear(cpu, cpu_callin_map);
597 */
598 return; 706 return;
599 } 707 }
600 msleep(100); 708 msleep(100);
@@ -602,11 +710,6 @@ void __cpu_die(unsigned int cpu)
602 printk(KERN_ERR "CPU %u didn't die...\n", cpu); 710 printk(KERN_ERR "CPU %u didn't die...\n", cpu);
603} 711}
604#else /* !CONFIG_HOTPLUG_CPU */ 712#else /* !CONFIG_HOTPLUG_CPU */
605static int __devinit cpu_enable(unsigned int cpu)
606{
607 return 0;
608}
609
610int __cpu_disable(void) 713int __cpu_disable(void)
611{ 714{
612 return -ENOSYS; 715 return -ENOSYS;
@@ -637,6 +740,23 @@ smp_cpus_done (unsigned int dummy)
637 (int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100); 740 (int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);
638} 741}
639 742
743static inline void __devinit
744set_cpu_sibling_map(int cpu)
745{
746 int i;
747
748 for_each_online_cpu(i) {
749 if ((cpu_data(cpu)->socket_id == cpu_data(i)->socket_id)) {
750 cpu_set(i, cpu_core_map[cpu]);
751 cpu_set(cpu, cpu_core_map[i]);
752 if (cpu_data(cpu)->core_id == cpu_data(i)->core_id) {
753 cpu_set(i, cpu_sibling_map[cpu]);
754 cpu_set(cpu, cpu_sibling_map[i]);
755 }
756 }
757 }
758}
759
640int __devinit 760int __devinit
641__cpu_up (unsigned int cpu) 761__cpu_up (unsigned int cpu)
642{ 762{
@@ -648,21 +768,26 @@ __cpu_up (unsigned int cpu)
648 return -EINVAL; 768 return -EINVAL;
649 769
650 /* 770 /*
651 * Already booted.. just enable and get outa idle lool 771 * Already booted cpu? not valid anymore since we dont
772 * do idle loop tightspin anymore.
652 */ 773 */
653 if (cpu_isset(cpu, cpu_callin_map)) 774 if (cpu_isset(cpu, cpu_callin_map))
654 { 775 return -EINVAL;
655 cpu_enable(cpu); 776
656 local_irq_enable();
657 while (!cpu_isset(cpu, cpu_online_map))
658 mb();
659 return 0;
660 }
661 /* Processor goes to start_secondary(), sets online flag */ 777 /* Processor goes to start_secondary(), sets online flag */
662 ret = do_boot_cpu(sapicid, cpu); 778 ret = do_boot_cpu(sapicid, cpu);
663 if (ret < 0) 779 if (ret < 0)
664 return ret; 780 return ret;
665 781
782 if (cpu_data(cpu)->threads_per_core == 1 &&
783 cpu_data(cpu)->cores_per_socket == 1) {
784 cpu_set(cpu, cpu_sibling_map[cpu]);
785 cpu_set(cpu, cpu_core_map[cpu]);
786 return 0;
787 }
788
789 set_cpu_sibling_map(cpu);
790
666 return 0; 791 return 0;
667} 792}
668 793
@@ -690,3 +815,106 @@ init_smp_config(void)
690 ia64_sal_strerror(sal_ret)); 815 ia64_sal_strerror(sal_ret));
691} 816}
692 817
818static inline int __devinit
819check_for_mtinfo_index(void)
820{
821 int i;
822
823 for_each_cpu(i)
824 if (!mt_info[i].valid)
825 return i;
826
827 return -1;
828}
829
830/*
831 * Search the mt_info to find out if this socket's cid/tid information is
832 * cached or not. If the socket exists, fill in the core_id and thread_id
833 * in cpuinfo
834 */
835static int __devinit
836check_for_new_socket(__u16 logical_address, struct cpuinfo_ia64 *c)
837{
838 int i;
839 __u32 sid = c->socket_id;
840
841 for_each_cpu(i) {
842 if (mt_info[i].valid && mt_info[i].proc_fixed_addr == logical_address
843 && mt_info[i].socket_id == sid) {
844 c->core_id = mt_info[i].core_id;
845 c->thread_id = mt_info[i].thread_id;
846 return 1; /* not a new socket */
847 }
848 }
849 return 0;
850}
851
852/*
853 * identify_siblings(cpu) gets called from identify_cpu. This populates the
854 * information related to logical execution units in per_cpu_data structure.
855 */
856void __devinit
857identify_siblings(struct cpuinfo_ia64 *c)
858{
859 s64 status;
860 u16 pltid;
861 u64 proc_fixed_addr;
862 int count, i;
863 pal_logical_to_physical_t info;
864
865 if (smp_num_cpucores == 1 && smp_num_siblings == 1)
866 return;
867
868 if ((status = ia64_pal_logical_to_phys(0, &info)) != PAL_STATUS_SUCCESS) {
869 printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n",
870 status);
871 return;
872 }
873 if ((status = ia64_sal_physical_id_info(&pltid)) != PAL_STATUS_SUCCESS) {
874 printk(KERN_ERR "ia64_sal_pltid failed with %ld\n", status);
875 return;
876 }
877 if ((status = ia64_pal_fixed_addr(&proc_fixed_addr)) != PAL_STATUS_SUCCESS) {
878 printk(KERN_ERR "ia64_pal_fixed_addr failed with %ld\n", status);
879 return;
880 }
881
882 c->socket_id = (pltid << 8) | info.overview_ppid;
883 c->cores_per_socket = info.overview_cpp;
884 c->threads_per_core = info.overview_tpc;
885 count = c->num_log = info.overview_num_log;
886
887 /* If the thread and core id information is already cached, then
888 * we will simply update cpu_info and return. Otherwise, we will
889 * do the PAL calls and cache core and thread id's of all the siblings.
890 */
891 if (check_for_new_socket(proc_fixed_addr, c))
892 return;
893
894 for (i = 0; i < count; i++) {
895 int index;
896
897 if (i && (status = ia64_pal_logical_to_phys(i, &info))
898 != PAL_STATUS_SUCCESS) {
899 printk(KERN_ERR "ia64_pal_logical_to_phys failed"
900 " with %ld\n", status);
901 return;
902 }
903 if (info.log2_la == proc_fixed_addr) {
904 c->core_id = info.log1_cid;
905 c->thread_id = info.log1_tid;
906 }
907
908 index = check_for_mtinfo_index();
909 /* We will not do the mt_info caching optimization in this case.
910 */
911 if (index < 0)
912 continue;
913
914 mt_info[index].valid = 1;
915 mt_info[index].socket_id = c->socket_id;
916 mt_info[index].core_id = info.log1_cid;
917 mt_info[index].thread_id = info.log1_tid;
918 mt_info[index].proc_fixed_addr = info.log2_la;
919 }
920}
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
index 3ac216e1c8bb..a8cf6d8a509c 100644
--- a/arch/ia64/kernel/sys_ia64.c
+++ b/arch/ia64/kernel/sys_ia64.c
@@ -93,20 +93,6 @@ sys_getpagesize (void)
93} 93}
94 94
95asmlinkage unsigned long 95asmlinkage unsigned long
96ia64_shmat (int shmid, void __user *shmaddr, int shmflg)
97{
98 unsigned long raddr;
99 int retval;
100
101 retval = do_shmat(shmid, shmaddr, shmflg, &raddr);
102 if (retval < 0)
103 return retval;
104
105 force_successful_syscall_return();
106 return raddr;
107}
108
109asmlinkage unsigned long
110ia64_brk (unsigned long brk) 96ia64_brk (unsigned long brk)
111{ 97{
112 unsigned long rlim, retval, newbrk, oldbrk; 98 unsigned long rlim, retval, newbrk, oldbrk;
diff --git a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
index d494ff647cac..2776a074c6f1 100644
--- a/arch/ia64/kernel/unwind.c
+++ b/arch/ia64/kernel/unwind.c
@@ -1943,23 +1943,30 @@ EXPORT_SYMBOL(unw_unwind);
1943int 1943int
1944unw_unwind_to_user (struct unw_frame_info *info) 1944unw_unwind_to_user (struct unw_frame_info *info)
1945{ 1945{
1946 unsigned long ip, sp; 1946 unsigned long ip, sp, pr = 0;
1947 1947
1948 while (unw_unwind(info) >= 0) { 1948 while (unw_unwind(info) >= 0) {
1949 if (unw_get_rp(info, &ip) < 0) {
1950 unw_get_ip(info, &ip);
1951 UNW_DPRINT(0, "unwind.%s: failed to read return pointer (ip=0x%lx)\n",
1952 __FUNCTION__, ip);
1953 return -1;
1954 }
1955 unw_get_sp(info, &sp); 1949 unw_get_sp(info, &sp);
1956 if (sp >= (unsigned long)info->task + IA64_STK_OFFSET) 1950 if ((long)((unsigned long)info->task + IA64_STK_OFFSET - sp)
1951 < IA64_PT_REGS_SIZE) {
1952 UNW_DPRINT(0, "unwind.%s: ran off the top of the kernel stack\n",
1953 __FUNCTION__);
1957 break; 1954 break;
1958 if (ip < FIXADDR_USER_END) 1955 }
1956 if (unw_is_intr_frame(info) &&
1957 (pr & (1UL << PRED_USER_STACK)))
1959 return 0; 1958 return 0;
1959 if (unw_get_pr (info, &pr) < 0) {
1960 unw_get_rp(info, &ip);
1961 UNW_DPRINT(0, "unwind.%s: failed to read "
1962 "predicate register (ip=0x%lx)\n",
1963 __FUNCTION__, ip);
1964 return -1;
1965 }
1960 } 1966 }
1961 unw_get_ip(info, &ip); 1967 unw_get_ip(info, &ip);
1962 UNW_DPRINT(0, "unwind.%s: failed to unwind to user-level (ip=0x%lx)\n", __FUNCTION__, ip); 1968 UNW_DPRINT(0, "unwind.%s: failed to unwind to user-level (ip=0x%lx)\n",
1969 __FUNCTION__, ip);
1963 return -1; 1970 return -1;
1964} 1971}
1965EXPORT_SYMBOL(unw_unwind_to_user); 1972EXPORT_SYMBOL(unw_unwind_to_user);
diff --git a/arch/ia64/lib/flush.S b/arch/ia64/lib/flush.S
index 29c802b19669..a1af9146cfdb 100644
--- a/arch/ia64/lib/flush.S
+++ b/arch/ia64/lib/flush.S
@@ -1,8 +1,8 @@
1/* 1/*
2 * Cache flushing routines. 2 * Cache flushing routines.
3 * 3 *
4 * Copyright (C) 1999-2001 Hewlett-Packard Co 4 * Copyright (C) 1999-2001, 2005 Hewlett-Packard Co
5 * Copyright (C) 1999-2001 David Mosberger-Tang <davidm@hpl.hp.com> 5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 */ 6 */
7#include <asm/asmmacro.h> 7#include <asm/asmmacro.h>
8#include <asm/page.h> 8#include <asm/page.h>
@@ -26,7 +26,7 @@ GLOBAL_ENTRY(flush_icache_range)
26 26
27 mov ar.lc=r8 27 mov ar.lc=r8
28 ;; 28 ;;
29.Loop: fc in0 // issuable on M0 only 29.Loop: fc.i in0 // issuable on M2 only
30 add in0=32,in0 30 add in0=32,in0
31 br.cloop.sptk.few .Loop 31 br.cloop.sptk.few .Loop
32 ;; 32 ;;
diff --git a/arch/ia64/lib/memcpy_mck.S b/arch/ia64/lib/memcpy_mck.S
index 6f26ef7cc236..6f308e62c137 100644
--- a/arch/ia64/lib/memcpy_mck.S
+++ b/arch/ia64/lib/memcpy_mck.S
@@ -75,6 +75,7 @@ GLOBAL_ENTRY(memcpy)
75 mov f6=f0 75 mov f6=f0
76 br.cond.sptk .common_code 76 br.cond.sptk .common_code
77 ;; 77 ;;
78END(memcpy)
78GLOBAL_ENTRY(__copy_user) 79GLOBAL_ENTRY(__copy_user)
79 .prologue 80 .prologue
80// check dest alignment 81// check dest alignment
@@ -300,7 +301,7 @@ EK(.ex_handler, (p[D]) st8 [dst1] = t15, 4*8)
300 add src_pre_mem=0,src0 // prefetch src pointer 301 add src_pre_mem=0,src0 // prefetch src pointer
301 add dst_pre_mem=0,dst0 // prefetch dest pointer 302 add dst_pre_mem=0,dst0 // prefetch dest pointer
302 and src0=-8,src0 // 1st src pointer 303 and src0=-8,src0 // 1st src pointer
303(p7) mov ar.lc = r21 304(p7) mov ar.lc = cnt
304(p8) mov ar.lc = r0 305(p8) mov ar.lc = r0
305 ;; 306 ;;
306 TEXT_ALIGN(32) 307 TEXT_ALIGN(32)
@@ -524,7 +525,6 @@ EK(.ex_handler, (p17) st8 [dst1]=r39,8); \
524#undef B 525#undef B
525#undef C 526#undef C
526#undef D 527#undef D
527END(memcpy)
528 528
529/* 529/*
530 * Due to lack of local tag support in gcc 2.x assembler, it is not clear which 530 * Due to lack of local tag support in gcc 2.x assembler, it is not clear which
diff --git a/arch/ia64/lib/memset.S b/arch/ia64/lib/memset.S
index bd8cf907fe22..f26c16aefb1c 100644
--- a/arch/ia64/lib/memset.S
+++ b/arch/ia64/lib/memset.S
@@ -57,10 +57,10 @@ GLOBAL_ENTRY(memset)
57{ .mmi 57{ .mmi
58 .prologue 58 .prologue
59 alloc tmp = ar.pfs, 3, 0, 0, 0 59 alloc tmp = ar.pfs, 3, 0, 0, 0
60 .body
61 lfetch.nt1 [dest] // 60 lfetch.nt1 [dest] //
62 .save ar.lc, save_lc 61 .save ar.lc, save_lc
63 mov.i save_lc = ar.lc 62 mov.i save_lc = ar.lc
63 .body
64} { .mmi 64} { .mmi
65 mov ret0 = dest // return value 65 mov ret0 = dest // return value
66 cmp.ne p_nz, p_zr = value, r0 // use stf.spill if value is zero 66 cmp.ne p_nz, p_zr = value, r0 // use stf.spill if value is zero
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 6daf15ac8940..91a055f5731f 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -61,7 +61,8 @@ show_mem (void)
61 printk("%d reserved pages\n", reserved); 61 printk("%d reserved pages\n", reserved);
62 printk("%d pages shared\n", shared); 62 printk("%d pages shared\n", shared);
63 printk("%d pages swap cached\n", cached); 63 printk("%d pages swap cached\n", cached);
64 printk("%ld pages in page table cache\n", pgtable_cache_size); 64 printk("%ld pages in page table cache\n",
65 pgtable_quicklist_total_size());
65} 66}
66 67
67/* physical address where the bootmem map is located */ 68/* physical address where the bootmem map is located */
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 3456a9b6971e..c00710929390 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -582,7 +582,8 @@ void show_mem(void)
582 printk("%d reserved pages\n", total_reserved); 582 printk("%d reserved pages\n", total_reserved);
583 printk("%d pages shared\n", total_shared); 583 printk("%d pages shared\n", total_shared);
584 printk("%d pages swap cached\n", total_cached); 584 printk("%d pages swap cached\n", total_cached);
585 printk("Total of %ld pages in page table cache\n", pgtable_cache_size); 585 printk("Total of %ld pages in page table cache\n",
586 pgtable_quicklist_total_size());
586 printk("%d free buffer pages\n", nr_free_buffer_pages()); 587 printk("%d free buffer pages\n", nr_free_buffer_pages());
587} 588}
588 589
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index da859125aaef..4174ec999dde 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -209,10 +209,13 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
209 } 209 }
210 210
211 no_context: 211 no_context:
212 if (isr & IA64_ISR_SP) { 212 if ((isr & IA64_ISR_SP)
213 || ((isr & IA64_ISR_NA) && (isr & IA64_ISR_CODE_MASK) == IA64_ISR_CODE_LFETCH))
214 {
213 /* 215 /*
214 * This fault was due to a speculative load set the "ed" bit in the psr to 216 * This fault was due to a speculative load or lfetch.fault, set the "ed"
215 * ensure forward progress (target register will get a NaT). 217 * bit in the psr to ensure forward progress. (Target register will get a
218 * NaT for ld.s, lfetch will be canceled.)
216 */ 219 */
217 ia64_psr(regs)->ed = 1; 220 ia64_psr(regs)->ed = 1;
218 return; 221 return;
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 65cf839573ea..547785e3cba2 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -39,6 +39,9 @@
39 39
40DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 40DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
41 41
42DEFINE_PER_CPU(unsigned long *, __pgtable_quicklist);
43DEFINE_PER_CPU(long, __pgtable_quicklist_size);
44
42extern void ia64_tlb_init (void); 45extern void ia64_tlb_init (void);
43 46
44unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL; 47unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL;
@@ -50,27 +53,53 @@ struct page *vmem_map;
50EXPORT_SYMBOL(vmem_map); 53EXPORT_SYMBOL(vmem_map);
51#endif 54#endif
52 55
53static int pgt_cache_water[2] = { 25, 50 }; 56struct page *zero_page_memmap_ptr; /* map entry for zero page */
54
55struct page *zero_page_memmap_ptr; /* map entry for zero page */
56EXPORT_SYMBOL(zero_page_memmap_ptr); 57EXPORT_SYMBOL(zero_page_memmap_ptr);
57 58
59#define MIN_PGT_PAGES 25UL
60#define MAX_PGT_FREES_PER_PASS 16L
61#define PGT_FRACTION_OF_NODE_MEM 16
62
63static inline long
64max_pgt_pages(void)
65{
66 u64 node_free_pages, max_pgt_pages;
67
68#ifndef CONFIG_NUMA
69 node_free_pages = nr_free_pages();
70#else
71 node_free_pages = nr_free_pages_pgdat(NODE_DATA(numa_node_id()));
72#endif
73 max_pgt_pages = node_free_pages / PGT_FRACTION_OF_NODE_MEM;
74 max_pgt_pages = max(max_pgt_pages, MIN_PGT_PAGES);
75 return max_pgt_pages;
76}
77
78static inline long
79min_pages_to_free(void)
80{
81 long pages_to_free;
82
83 pages_to_free = pgtable_quicklist_size - max_pgt_pages();
84 pages_to_free = min(pages_to_free, MAX_PGT_FREES_PER_PASS);
85 return pages_to_free;
86}
87
58void 88void
59check_pgt_cache (void) 89check_pgt_cache(void)
60{ 90{
61 int low, high; 91 long pages_to_free;
62 92
63 low = pgt_cache_water[0]; 93 if (unlikely(pgtable_quicklist_size <= MIN_PGT_PAGES))
64 high = pgt_cache_water[1]; 94 return;
65 95
66 preempt_disable(); 96 preempt_disable();
67 if (pgtable_cache_size > (u64) high) { 97 while (unlikely((pages_to_free = min_pages_to_free()) > 0)) {
68 do { 98 while (pages_to_free--) {
69 if (pgd_quicklist) 99 free_page((unsigned long)pgtable_quicklist_alloc());
70 free_page((unsigned long)pgd_alloc_one_fast(NULL)); 100 }
71 if (pmd_quicklist) 101 preempt_enable();
72 free_page((unsigned long)pmd_alloc_one_fast(NULL, 0)); 102 preempt_disable();
73 } while (pgtable_cache_size > (u64) low);
74 } 103 }
75 preempt_enable(); 104 preempt_enable();
76} 105}
@@ -523,11 +552,14 @@ void
523mem_init (void) 552mem_init (void)
524{ 553{
525 long reserved_pages, codesize, datasize, initsize; 554 long reserved_pages, codesize, datasize, initsize;
526 unsigned long num_pgt_pages;
527 pg_data_t *pgdat; 555 pg_data_t *pgdat;
528 int i; 556 int i;
529 static struct kcore_list kcore_mem, kcore_vmem, kcore_kernel; 557 static struct kcore_list kcore_mem, kcore_vmem, kcore_kernel;
530 558
559 BUG_ON(PTRS_PER_PGD * sizeof(pgd_t) != PAGE_SIZE);
560 BUG_ON(PTRS_PER_PMD * sizeof(pmd_t) != PAGE_SIZE);
561 BUG_ON(PTRS_PER_PTE * sizeof(pte_t) != PAGE_SIZE);
562
531#ifdef CONFIG_PCI 563#ifdef CONFIG_PCI
532 /* 564 /*
533 * This needs to be called _after_ the command line has been parsed but _before_ 565 * This needs to be called _after_ the command line has been parsed but _before_
@@ -564,18 +596,6 @@ mem_init (void)
564 num_physpages << (PAGE_SHIFT - 10), codesize >> 10, 596 num_physpages << (PAGE_SHIFT - 10), codesize >> 10,
565 reserved_pages << (PAGE_SHIFT - 10), datasize >> 10, initsize >> 10); 597 reserved_pages << (PAGE_SHIFT - 10), datasize >> 10, initsize >> 10);
566 598
567 /*
568 * Allow for enough (cached) page table pages so that we can map the entire memory
569 * at least once. Each task also needs a couple of page tables pages, so add in a
570 * fudge factor for that (don't use "threads-max" here; that would be wrong!).
571 * Don't allow the cache to be more than 10% of total memory, though.
572 */
573# define NUM_TASKS 500 /* typical number of tasks */
574 num_pgt_pages = nr_free_pages() / PTRS_PER_PGD + NUM_TASKS;
575 if (num_pgt_pages > nr_free_pages() / 10)
576 num_pgt_pages = nr_free_pages() / 10;
577 if (num_pgt_pages > (u64) pgt_cache_water[1])
578 pgt_cache_water[1] = num_pgt_pages;
579 599
580 /* 600 /*
581 * For fsyscall entrpoints with no light-weight handler, use the ordinary 601 * For fsyscall entrpoints with no light-weight handler, use the ordinary
diff --git a/arch/ia64/sn/include/pci/pcibr_provider.h b/arch/ia64/sn/include/pci/pcibr_provider.h
index b1f05ffec70b..1cd291d8badd 100644
--- a/arch/ia64/sn/include/pci/pcibr_provider.h
+++ b/arch/ia64/sn/include/pci/pcibr_provider.h
@@ -123,9 +123,11 @@ pcibr_lock(struct pcibus_info *pcibus_info)
123} 123}
124#define pcibr_unlock(pcibus_info, flag) spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag) 124#define pcibr_unlock(pcibus_info, flag) spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag)
125 125
126extern int pcibr_init_provider(void);
126extern void *pcibr_bus_fixup(struct pcibus_bussoft *); 127extern void *pcibr_bus_fixup(struct pcibus_bussoft *);
127extern uint64_t pcibr_dma_map(struct pcidev_info *, unsigned long, size_t, unsigned int); 128extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t);
128extern void pcibr_dma_unmap(struct pcidev_info *, dma_addr_t, int); 129extern dma_addr_t pcibr_dma_map_consistent(struct pci_dev *, unsigned long, size_t);
130extern void pcibr_dma_unmap(struct pci_dev *, dma_addr_t, int);
129 131
130/* 132/*
131 * prototypes for the bridge asic register access routines in pcibr_reg.c 133 * prototypes for the bridge asic register access routines in pcibr_reg.c
diff --git a/arch/ia64/sn/kernel/Makefile b/arch/ia64/sn/kernel/Makefile
index 6c7f4d9e8ea0..4351c4ff9845 100644
--- a/arch/ia64/sn/kernel/Makefile
+++ b/arch/ia64/sn/kernel/Makefile
@@ -4,9 +4,15 @@
4# License. See the file "COPYING" in the main directory of this archive 4# License. See the file "COPYING" in the main directory of this archive
5# for more details. 5# for more details.
6# 6#
7# Copyright (C) 1999,2001-2003 Silicon Graphics, Inc. All Rights Reserved. 7# Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All Rights Reserved.
8# 8#
9 9
10obj-y += setup.o bte.o bte_error.o irq.o mca.o idle.o \ 10obj-y += setup.o bte.o bte_error.o irq.o mca.o idle.o \
11 huberror.o io_init.o iomv.o klconflib.o sn2/ 11 huberror.o io_init.o iomv.o klconflib.o sn2/
12obj-$(CONFIG_IA64_GENERIC) += machvec.o 12obj-$(CONFIG_IA64_GENERIC) += machvec.o
13obj-$(CONFIG_SGI_TIOCX) += tiocx.o
14obj-$(CONFIG_IA64_SGI_SN_XP) += xp.o
15xp-y := xp_main.o xp_nofault.o
16obj-$(CONFIG_IA64_SGI_SN_XP) += xpc.o
17xpc-y := xpc_main.o xpc_channel.o xpc_partition.o
18obj-$(CONFIG_IA64_SGI_SN_XP) += xpnet.o
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index ce0bc4085eae..647deae9bfcd 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9#include <linux/config.h> 9#include <linux/config.h>
@@ -170,10 +170,6 @@ retry_bteop:
170 /* Initialize the notification to a known value. */ 170 /* Initialize the notification to a known value. */
171 *bte->most_rcnt_na = BTE_WORD_BUSY; 171 *bte->most_rcnt_na = BTE_WORD_BUSY;
172 172
173 /* Set the status reg busy bit and transfer length */
174 BTE_PRINTKV(("IBLS = 0x%lx\n", IBLS_BUSY | transfer_size));
175 BTE_LNSTAT_STORE(bte, IBLS_BUSY | transfer_size);
176
177 /* Set the source and destination registers */ 173 /* Set the source and destination registers */
178 BTE_PRINTKV(("IBSA = 0x%lx)\n", (TO_PHYS(src)))); 174 BTE_PRINTKV(("IBSA = 0x%lx)\n", (TO_PHYS(src))));
179 BTE_SRC_STORE(bte, TO_PHYS(src)); 175 BTE_SRC_STORE(bte, TO_PHYS(src));
@@ -188,7 +184,7 @@ retry_bteop:
188 184
189 /* Initiate the transfer */ 185 /* Initiate the transfer */
190 BTE_PRINTK(("IBCT = 0x%lx)\n", BTE_VALID_MODE(mode))); 186 BTE_PRINTK(("IBCT = 0x%lx)\n", BTE_VALID_MODE(mode)));
191 BTE_CTRL_STORE(bte, BTE_VALID_MODE(mode)); 187 BTE_START_TRANSFER(bte, transfer_size, BTE_VALID_MODE(mode));
192 188
193 itc_end = ia64_get_itc() + (40000000 * local_cpu_data->cyc_per_usec); 189 itc_end = ia64_get_itc() + (40000000 * local_cpu_data->cyc_per_usec);
194 190
@@ -429,10 +425,16 @@ void bte_init_node(nodepda_t * mynodepda, cnodeid_t cnode)
429 mynodepda->bte_recovery_timer.data = (unsigned long)mynodepda; 425 mynodepda->bte_recovery_timer.data = (unsigned long)mynodepda;
430 426
431 for (i = 0; i < BTES_PER_NODE; i++) { 427 for (i = 0; i < BTES_PER_NODE; i++) {
428 u64 *base_addr;
429
432 /* Which link status register should we use? */ 430 /* Which link status register should we use? */
433 unsigned long link_status = (i == 0 ? IIO_IBLS0 : IIO_IBLS1); 431 base_addr = (u64 *)
434 mynodepda->bte_if[i].bte_base_addr = (u64 *) 432 REMOTE_HUB_ADDR(cnodeid_to_nasid(cnode), BTE_BASE_ADDR(i));
435 REMOTE_HUB_ADDR(cnodeid_to_nasid(cnode), link_status); 433 mynodepda->bte_if[i].bte_base_addr = base_addr;
434 mynodepda->bte_if[i].bte_source_addr = BTE_SOURCE_ADDR(base_addr);
435 mynodepda->bte_if[i].bte_destination_addr = BTE_DEST_ADDR(base_addr);
436 mynodepda->bte_if[i].bte_control_addr = BTE_CTRL_ADDR(base_addr);
437 mynodepda->bte_if[i].bte_notify_addr = BTE_NOTIF_ADDR(base_addr);
436 438
437 /* 439 /*
438 * Initialize the notification and spinlock 440 * Initialize the notification and spinlock
diff --git a/arch/ia64/sn/kernel/bte_error.c b/arch/ia64/sn/kernel/bte_error.c
index fd104312c6bd..fcbc748ae433 100644
--- a/arch/ia64/sn/kernel/bte_error.c
+++ b/arch/ia64/sn/kernel/bte_error.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9#include <linux/types.h> 9#include <linux/types.h>
@@ -33,48 +33,28 @@ void bte_error_handler(unsigned long);
33 * Wait until all BTE related CRBs are completed 33 * Wait until all BTE related CRBs are completed
34 * and then reset the interfaces. 34 * and then reset the interfaces.
35 */ 35 */
36void bte_error_handler(unsigned long _nodepda) 36void shub1_bte_error_handler(unsigned long _nodepda)
37{ 37{
38 struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda; 38 struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda;
39 spinlock_t *recovery_lock = &err_nodepda->bte_recovery_lock;
40 struct timer_list *recovery_timer = &err_nodepda->bte_recovery_timer; 39 struct timer_list *recovery_timer = &err_nodepda->bte_recovery_timer;
41 nasid_t nasid; 40 nasid_t nasid;
42 int i; 41 int i;
43 int valid_crbs; 42 int valid_crbs;
44 unsigned long irq_flags;
45 volatile u64 *notify;
46 bte_result_t bh_error;
47 ii_imem_u_t imem; /* II IMEM Register */ 43 ii_imem_u_t imem; /* II IMEM Register */
48 ii_icrb0_d_u_t icrbd; /* II CRB Register D */ 44 ii_icrb0_d_u_t icrbd; /* II CRB Register D */
49 ii_ibcr_u_t ibcr; 45 ii_ibcr_u_t ibcr;
50 ii_icmr_u_t icmr; 46 ii_icmr_u_t icmr;
51 ii_ieclr_u_t ieclr; 47 ii_ieclr_u_t ieclr;
52 48
53 BTE_PRINTK(("bte_error_handler(%p) - %d\n", err_nodepda, 49 BTE_PRINTK(("shub1_bte_error_handler(%p) - %d\n", err_nodepda,
54 smp_processor_id())); 50 smp_processor_id()));
55 51
56 spin_lock_irqsave(recovery_lock, irq_flags);
57
58 if ((err_nodepda->bte_if[0].bh_error == BTE_SUCCESS) && 52 if ((err_nodepda->bte_if[0].bh_error == BTE_SUCCESS) &&
59 (err_nodepda->bte_if[1].bh_error == BTE_SUCCESS)) { 53 (err_nodepda->bte_if[1].bh_error == BTE_SUCCESS)) {
60 BTE_PRINTK(("eh:%p:%d Nothing to do.\n", err_nodepda, 54 BTE_PRINTK(("eh:%p:%d Nothing to do.\n", err_nodepda,
61 smp_processor_id())); 55 smp_processor_id()));
62 spin_unlock_irqrestore(recovery_lock, irq_flags);
63 return; 56 return;
64 } 57 }
65 /*
66 * Lock all interfaces on this node to prevent new transfers
67 * from being queued.
68 */
69 for (i = 0; i < BTES_PER_NODE; i++) {
70 if (err_nodepda->bte_if[i].cleanup_active) {
71 continue;
72 }
73 spin_lock(&err_nodepda->bte_if[i].spinlock);
74 BTE_PRINTK(("eh:%p:%d locked %d\n", err_nodepda,
75 smp_processor_id(), i));
76 err_nodepda->bte_if[i].cleanup_active = 1;
77 }
78 58
79 /* Determine information about our hub */ 59 /* Determine information about our hub */
80 nasid = cnodeid_to_nasid(err_nodepda->bte_if[0].bte_cnode); 60 nasid = cnodeid_to_nasid(err_nodepda->bte_if[0].bte_cnode);
@@ -101,7 +81,6 @@ void bte_error_handler(unsigned long _nodepda)
101 mod_timer(recovery_timer, HZ * 5); 81 mod_timer(recovery_timer, HZ * 5);
102 BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda, 82 BTE_PRINTK(("eh:%p:%d Marked Giving up\n", err_nodepda,
103 smp_processor_id())); 83 smp_processor_id()));
104 spin_unlock_irqrestore(recovery_lock, irq_flags);
105 return; 84 return;
106 } 85 }
107 if (icmr.ii_icmr_fld_s.i_crb_vld != 0) { 86 if (icmr.ii_icmr_fld_s.i_crb_vld != 0) {
@@ -120,8 +99,6 @@ void bte_error_handler(unsigned long _nodepda)
120 BTE_PRINTK(("eh:%p:%d Valid %d, Giving up\n", 99 BTE_PRINTK(("eh:%p:%d Valid %d, Giving up\n",
121 err_nodepda, smp_processor_id(), 100 err_nodepda, smp_processor_id(),
122 i)); 101 i));
123 spin_unlock_irqrestore(recovery_lock,
124 irq_flags);
125 return; 102 return;
126 } 103 }
127 } 104 }
@@ -146,6 +123,51 @@ void bte_error_handler(unsigned long _nodepda)
146 ibcr.ii_ibcr_fld_s.i_soft_reset = 1; 123 ibcr.ii_ibcr_fld_s.i_soft_reset = 1;
147 REMOTE_HUB_S(nasid, IIO_IBCR, ibcr.ii_ibcr_regval); 124 REMOTE_HUB_S(nasid, IIO_IBCR, ibcr.ii_ibcr_regval);
148 125
126 del_timer(recovery_timer);
127}
128
129/*
130 * Wait until all BTE related CRBs are completed
131 * and then reset the interfaces.
132 */
133void bte_error_handler(unsigned long _nodepda)
134{
135 struct nodepda_s *err_nodepda = (struct nodepda_s *)_nodepda;
136 spinlock_t *recovery_lock = &err_nodepda->bte_recovery_lock;
137 int i;
138 nasid_t nasid;
139 unsigned long irq_flags;
140 volatile u64 *notify;
141 bte_result_t bh_error;
142
143 BTE_PRINTK(("bte_error_handler(%p) - %d\n", err_nodepda,
144 smp_processor_id()));
145
146 spin_lock_irqsave(recovery_lock, irq_flags);
147
148 /*
149 * Lock all interfaces on this node to prevent new transfers
150 * from being queued.
151 */
152 for (i = 0; i < BTES_PER_NODE; i++) {
153 if (err_nodepda->bte_if[i].cleanup_active) {
154 continue;
155 }
156 spin_lock(&err_nodepda->bte_if[i].spinlock);
157 BTE_PRINTK(("eh:%p:%d locked %d\n", err_nodepda,
158 smp_processor_id(), i));
159 err_nodepda->bte_if[i].cleanup_active = 1;
160 }
161
162 if (is_shub1()) {
163 shub1_bte_error_handler(_nodepda);
164 } else {
165 nasid = cnodeid_to_nasid(err_nodepda->bte_if[0].bte_cnode);
166
167 if (ia64_sn_bte_recovery(nasid))
168 panic("bte_error_handler(): Fatal BTE Error");
169 }
170
149 for (i = 0; i < BTES_PER_NODE; i++) { 171 for (i = 0; i < BTES_PER_NODE; i++) {
150 bh_error = err_nodepda->bte_if[i].bh_error; 172 bh_error = err_nodepda->bte_if[i].bh_error;
151 if (bh_error != BTE_SUCCESS) { 173 if (bh_error != BTE_SUCCESS) {
@@ -165,8 +187,6 @@ void bte_error_handler(unsigned long _nodepda)
165 spin_unlock(&err_nodepda->bte_if[i].spinlock); 187 spin_unlock(&err_nodepda->bte_if[i].spinlock);
166 } 188 }
167 189
168 del_timer(recovery_timer);
169
170 spin_unlock_irqrestore(recovery_lock, irq_flags); 190 spin_unlock_irqrestore(recovery_lock, irq_flags);
171} 191}
172 192
diff --git a/arch/ia64/sn/kernel/huberror.c b/arch/ia64/sn/kernel/huberror.c
index 2bdf684c5066..5c39b43ba3c0 100644
--- a/arch/ia64/sn/kernel/huberror.c
+++ b/arch/ia64/sn/kernel/huberror.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000,2002-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000,2002-2005 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#include <linux/types.h> 9#include <linux/types.h>
@@ -38,8 +38,11 @@ static irqreturn_t hub_eint_handler(int irq, void *arg, struct pt_regs *ep)
38 if ((int)ret_stuff.v0) 38 if ((int)ret_stuff.v0)
39 panic("hubii_eint_handler(): Fatal TIO Error"); 39 panic("hubii_eint_handler(): Fatal TIO Error");
40 40
41 if (!(nasid & 1)) /* Not a TIO, handle CRB errors */ 41 if (is_shub1()) {
42 (void)hubiio_crb_error_handler(hubdev_info); 42 if (!(nasid & 1)) /* Not a TIO, handle CRB errors */
43 (void)hubiio_crb_error_handler(hubdev_info);
44 } else
45 bte_error_handler((unsigned long)NODEPDA(nasid_to_cnodeid(nasid)));
43 46
44 return IRQ_HANDLED; 47 return IRQ_HANDLED;
45} 48}
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 001880812b7c..9e07f5463f21 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -11,14 +11,15 @@
11#include <asm/sn/types.h> 11#include <asm/sn/types.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 "pci/pcibus_provider_defs.h" 14#include <asm/sn/pcibus_provider_defs.h>
15#include "pci/pcidev.h" 15#include <asm/sn/pcidev.h>
16#include "pci/pcibr_provider.h" 16#include "pci/pcibr_provider.h"
17#include "xtalk/xwidgetdev.h" 17#include "xtalk/xwidgetdev.h"
18#include <asm/sn/geo.h> 18#include <asm/sn/geo.h>
19#include "xtalk/hubdev.h" 19#include "xtalk/hubdev.h"
20#include <asm/sn/io.h> 20#include <asm/sn/io.h>
21#include <asm/sn/simulator.h> 21#include <asm/sn/simulator.h>
22#include <asm/sn/tioca_provider.h>
22 23
23char master_baseio_wid; 24char master_baseio_wid;
24nasid_t master_nasid = INVALID_NASID; /* Partition Master */ 25nasid_t master_nasid = INVALID_NASID; /* Partition Master */
@@ -34,6 +35,37 @@ struct brick {
34 35
35int sn_ioif_inited = 0; /* SN I/O infrastructure initialized? */ 36int sn_ioif_inited = 0; /* SN I/O infrastructure initialized? */
36 37
38struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
39
40/*
41 * Hooks and struct for unsupported pci providers
42 */
43
44static dma_addr_t
45sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size)
46{
47 return 0;
48}
49
50static void
51sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
52{
53 return;
54}
55
56static void *
57sn_default_pci_bus_fixup(struct pcibus_bussoft *soft)
58{
59 return NULL;
60}
61
62static struct sn_pcibus_provider sn_pci_default_provider = {
63 .dma_map = sn_default_pci_map,
64 .dma_map_consistent = sn_default_pci_map,
65 .dma_unmap = sn_default_pci_unmap,
66 .bus_fixup = sn_default_pci_bus_fixup,
67};
68
37/* 69/*
38 * Retrieve the DMA Flush List given nasid. This list is needed 70 * Retrieve the DMA Flush List given nasid. This list is needed
39 * to implement the WAR - Flush DMA data on PIO Reads. 71 * to implement the WAR - Flush DMA data on PIO Reads.
@@ -142,6 +174,12 @@ static void sn_fixup_ionodes(void)
142 if (status) 174 if (status)
143 continue; 175 continue;
144 176
177 /* Attach the error interrupt handlers */
178 if (nasid & 1)
179 ice_error_init(hubdev);
180 else
181 hub_error_init(hubdev);
182
145 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) 183 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)
146 hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev; 184 hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;
147 185
@@ -179,10 +217,6 @@ static void sn_fixup_ionodes(void)
179 sn_flush_device_list; 217 sn_flush_device_list;
180 } 218 }
181 219
182 if (!(i & 1))
183 hub_error_init(hubdev);
184 else
185 ice_error_init(hubdev);
186 } 220 }
187 221
188} 222}
@@ -201,6 +235,7 @@ static void sn_pci_fixup_slot(struct pci_dev *dev)
201 struct sn_irq_info *sn_irq_info; 235 struct sn_irq_info *sn_irq_info;
202 struct pci_dev *host_pci_dev; 236 struct pci_dev *host_pci_dev;
203 int status = 0; 237 int status = 0;
238 struct pcibus_bussoft *bs;
204 239
205 dev->sysdata = kmalloc(sizeof(struct pcidev_info), GFP_KERNEL); 240 dev->sysdata = kmalloc(sizeof(struct pcidev_info), GFP_KERNEL);
206 if (SN_PCIDEV_INFO(dev) <= 0) 241 if (SN_PCIDEV_INFO(dev) <= 0)
@@ -241,6 +276,7 @@ static void sn_pci_fixup_slot(struct pci_dev *dev)
241 } 276 }
242 277
243 /* set up host bus linkages */ 278 /* set up host bus linkages */
279 bs = SN_PCIBUS_BUSSOFT(dev->bus);
244 host_pci_dev = 280 host_pci_dev =
245 pci_find_slot(SN_PCIDEV_INFO(dev)->pdi_slot_host_handle >> 32, 281 pci_find_slot(SN_PCIDEV_INFO(dev)->pdi_slot_host_handle >> 32,
246 SN_PCIDEV_INFO(dev)-> 282 SN_PCIDEV_INFO(dev)->
@@ -248,10 +284,16 @@ static void sn_pci_fixup_slot(struct pci_dev *dev)
248 SN_PCIDEV_INFO(dev)->pdi_host_pcidev_info = 284 SN_PCIDEV_INFO(dev)->pdi_host_pcidev_info =
249 SN_PCIDEV_INFO(host_pci_dev); 285 SN_PCIDEV_INFO(host_pci_dev);
250 SN_PCIDEV_INFO(dev)->pdi_linux_pcidev = dev; 286 SN_PCIDEV_INFO(dev)->pdi_linux_pcidev = dev;
251 SN_PCIDEV_INFO(dev)->pdi_pcibus_info = SN_PCIBUS_BUSSOFT(dev->bus); 287 SN_PCIDEV_INFO(dev)->pdi_pcibus_info = bs;
288
289 if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) {
290 SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type];
291 } else {
292 SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider;
293 }
252 294
253 /* Only set up IRQ stuff if this device has a host bus context */ 295 /* Only set up IRQ stuff if this device has a host bus context */
254 if (SN_PCIDEV_BUSSOFT(dev) && sn_irq_info->irq_irq) { 296 if (bs && sn_irq_info->irq_irq) {
255 SN_PCIDEV_INFO(dev)->pdi_sn_irq_info = sn_irq_info; 297 SN_PCIDEV_INFO(dev)->pdi_sn_irq_info = sn_irq_info;
256 dev->irq = SN_PCIDEV_INFO(dev)->pdi_sn_irq_info->irq_irq; 298 dev->irq = SN_PCIDEV_INFO(dev)->pdi_sn_irq_info->irq_irq;
257 sn_irq_fixup(dev, sn_irq_info); 299 sn_irq_fixup(dev, sn_irq_info);
@@ -271,6 +313,7 @@ static void sn_pci_controller_fixup(int segment, int busnum)
271 struct pcibus_bussoft *prom_bussoft_ptr; 313 struct pcibus_bussoft *prom_bussoft_ptr;
272 struct hubdev_info *hubdev_info; 314 struct hubdev_info *hubdev_info;
273 void *provider_soft; 315 void *provider_soft;
316 struct sn_pcibus_provider *provider;
274 317
275 status = 318 status =
276 sal_get_pcibus_info((u64) segment, (u64) busnum, 319 sal_get_pcibus_info((u64) segment, (u64) busnum,
@@ -291,16 +334,22 @@ static void sn_pci_controller_fixup(int segment, int busnum)
291 /* 334 /*
292 * Per-provider fixup. Copies the contents from prom to local 335 * Per-provider fixup. Copies the contents from prom to local
293 * area and links SN_PCIBUS_BUSSOFT(). 336 * area and links SN_PCIBUS_BUSSOFT().
294 *
295 * Note: Provider is responsible for ensuring that prom_bussoft_ptr
296 * represents an asic-type that it can handle.
297 */ 337 */
298 338
299 if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB) { 339 if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES) {
300 return; /* no further fixup necessary */ 340 return; /* unsupported asic type */
341 }
342
343 provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type];
344 if (provider == NULL) {
345 return; /* no provider registerd for this asic */
346 }
347
348 provider_soft = NULL;
349 if (provider->bus_fixup) {
350 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr);
301 } 351 }
302 352
303 provider_soft = pcibr_bus_fixup(prom_bussoft_ptr);
304 if (provider_soft == NULL) { 353 if (provider_soft == NULL) {
305 return; /* fixup failed or not applicable */ 354 return; /* fixup failed or not applicable */
306 } 355 }
@@ -339,6 +388,17 @@ static int __init sn_pci_init(void)
339 return 0; 388 return 0;
340 389
341 /* 390 /*
391 * prime sn_pci_provider[]. Individial provider init routines will
392 * override their respective default entries.
393 */
394
395 for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++)
396 sn_pci_provider[i] = &sn_pci_default_provider;
397
398 pcibr_init_provider();
399 tioca_init_provider();
400
401 /*
342 * This is needed to avoid bounce limit checks in the blk layer 402 * This is needed to avoid bounce limit checks in the blk layer
343 */ 403 */
344 ia64_max_iommu_merge_mask = ~PAGE_MASK; 404 ia64_max_iommu_merge_mask = ~PAGE_MASK;
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index 3be44724f6c8..0f4e8138658f 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -13,8 +13,8 @@
13#include <asm/sn/addrs.h> 13#include <asm/sn/addrs.h>
14#include <asm/sn/arch.h> 14#include <asm/sn/arch.h>
15#include "xtalk/xwidgetdev.h" 15#include "xtalk/xwidgetdev.h"
16#include "pci/pcibus_provider_defs.h" 16#include <asm/sn/pcibus_provider_defs.h>
17#include "pci/pcidev.h" 17#include <asm/sn/pcidev.h>
18#include "pci/pcibr_provider.h" 18#include "pci/pcibr_provider.h"
19#include <asm/sn/shub_mmr.h> 19#include <asm/sn/shub_mmr.h>
20#include <asm/sn/sn_sal.h> 20#include <asm/sn/sn_sal.h>
@@ -82,20 +82,9 @@ static void sn_ack_irq(unsigned int irq)
82 nasid = get_nasid(); 82 nasid = get_nasid();
83 event_occurred = 83 event_occurred =
84 HUB_L((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED)); 84 HUB_L((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED));
85 if (event_occurred & SH_EVENT_OCCURRED_UART_INT_MASK) { 85 mask = event_occurred & SH_ALL_INT_MASK;
86 mask |= (1 << SH_EVENT_OCCURRED_UART_INT_SHFT);
87 }
88 if (event_occurred & SH_EVENT_OCCURRED_IPI_INT_MASK) {
89 mask |= (1 << SH_EVENT_OCCURRED_IPI_INT_SHFT);
90 }
91 if (event_occurred & SH_EVENT_OCCURRED_II_INT0_MASK) {
92 mask |= (1 << SH_EVENT_OCCURRED_II_INT0_SHFT);
93 }
94 if (event_occurred & SH_EVENT_OCCURRED_II_INT1_MASK) {
95 mask |= (1 << SH_EVENT_OCCURRED_II_INT1_SHFT);
96 }
97 HUB_S((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED_ALIAS), 86 HUB_S((uint64_t *) GLOBAL_MMR_ADDR(nasid, SH_EVENT_OCCURRED_ALIAS),
98 mask); 87 mask);
99 __set_bit(irq, (volatile void *)pda->sn_in_service_ivecs); 88 __set_bit(irq, (volatile void *)pda->sn_in_service_ivecs);
100 89
101 move_irq(irq); 90 move_irq(irq);
diff --git a/arch/ia64/sn/kernel/mca.c b/arch/ia64/sn/kernel/mca.c
index 857774bb2c9a..6546db6abdba 100644
--- a/arch/ia64/sn/kernel/mca.c
+++ b/arch/ia64/sn/kernel/mca.c
@@ -37,6 +37,11 @@ static u64 *sn_oemdata_size, sn_oemdata_bufsize;
37 * This function is the callback routine that SAL calls to log error 37 * This function is the callback routine that SAL calls to log error
38 * info for platform errors. buf is appended to sn_oemdata, resizing as 38 * info for platform errors. buf is appended to sn_oemdata, resizing as
39 * required. 39 * required.
40 * Note: this is a SAL to OS callback, running under the same rules as the SAL
41 * code. SAL calls are run with preempt disabled so this routine must not
42 * sleep. vmalloc can sleep so print_hook cannot resize the output buffer
43 * itself, instead it must set the required size and return to let the caller
44 * resize the buffer then redrive the SAL call.
40 */ 45 */
41static int print_hook(const char *fmt, ...) 46static int print_hook(const char *fmt, ...)
42{ 47{
@@ -47,18 +52,8 @@ static int print_hook(const char *fmt, ...)
47 vsnprintf(buf, sizeof(buf), fmt, args); 52 vsnprintf(buf, sizeof(buf), fmt, args);
48 va_end(args); 53 va_end(args);
49 len = strlen(buf); 54 len = strlen(buf);
50 while (*sn_oemdata_size + len + 1 > sn_oemdata_bufsize) { 55 if (*sn_oemdata_size + len <= sn_oemdata_bufsize)
51 u8 *newbuf = vmalloc(sn_oemdata_bufsize += 1000); 56 memcpy(*sn_oemdata + *sn_oemdata_size, buf, len);
52 if (!newbuf) {
53 printk(KERN_ERR "%s: unable to extend sn_oemdata\n",
54 __FUNCTION__);
55 return 0;
56 }
57 memcpy(newbuf, *sn_oemdata, *sn_oemdata_size);
58 vfree(*sn_oemdata);
59 *sn_oemdata = newbuf;
60 }
61 memcpy(*sn_oemdata + *sn_oemdata_size, buf, len + 1);
62 *sn_oemdata_size += len; 57 *sn_oemdata_size += len;
63 return 0; 58 return 0;
64} 59}
@@ -98,7 +93,20 @@ sn_platform_plat_specific_err_print(const u8 * sect_header, u8 ** oemdata,
98 sn_oemdata = oemdata; 93 sn_oemdata = oemdata;
99 sn_oemdata_size = oemdata_size; 94 sn_oemdata_size = oemdata_size;
100 sn_oemdata_bufsize = 0; 95 sn_oemdata_bufsize = 0;
101 ia64_sn_plat_specific_err_print(print_hook, (char *)sect_header); 96 *sn_oemdata_size = PAGE_SIZE; /* first guess at how much data will be generated */
97 while (*sn_oemdata_size > sn_oemdata_bufsize) {
98 u8 *newbuf = vmalloc(*sn_oemdata_size);
99 if (!newbuf) {
100 printk(KERN_ERR "%s: unable to extend sn_oemdata\n",
101 __FUNCTION__);
102 return 1;
103 }
104 vfree(*sn_oemdata);
105 *sn_oemdata = newbuf;
106 sn_oemdata_bufsize = *sn_oemdata_size;
107 *sn_oemdata_size = 0;
108 ia64_sn_plat_specific_err_print(print_hook, (char *)sect_header);
109 }
102 up(&sn_oemdata_mutex); 110 up(&sn_oemdata_mutex);
103 return 0; 111 return 0;
104} 112}
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index f0306b516afb..4fb44984afe6 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1999,2001-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#include <linux/config.h> 9#include <linux/config.h>
@@ -29,6 +29,7 @@
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/root_dev.h> 30#include <linux/root_dev.h>
31#include <linux/nodemask.h> 31#include <linux/nodemask.h>
32#include <linux/pm.h>
32 33
33#include <asm/io.h> 34#include <asm/io.h>
34#include <asm/sal.h> 35#include <asm/sal.h>
@@ -72,6 +73,12 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second);
72DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info); 73DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
73EXPORT_PER_CPU_SYMBOL(__sn_hub_info); 74EXPORT_PER_CPU_SYMBOL(__sn_hub_info);
74 75
76DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_NUMNODES]);
77EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
78
79DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
80EXPORT_PER_CPU_SYMBOL(__sn_nodepda);
81
75partid_t sn_partid = -1; 82partid_t sn_partid = -1;
76EXPORT_SYMBOL(sn_partid); 83EXPORT_SYMBOL(sn_partid);
77char sn_system_serial_number_string[128]; 84char sn_system_serial_number_string[128];
@@ -353,6 +360,14 @@ void __init sn_setup(char **cmdline_p)
353 screen_info = sn_screen_info; 360 screen_info = sn_screen_info;
354 361
355 sn_timer_init(); 362 sn_timer_init();
363
364 /*
365 * set pm_power_off to a SAL call to allow
366 * sn machines to power off. The SAL call can be replaced
367 * by an ACPI interface call when ACPI is fully implemented
368 * for sn.
369 */
370 pm_power_off = ia64_sn_power_down;
356} 371}
357 372
358/** 373/**
@@ -364,11 +379,11 @@ static void __init sn_init_pdas(char **cmdline_p)
364{ 379{
365 cnodeid_t cnode; 380 cnodeid_t cnode;
366 381
367 memset(pda->cnodeid_to_nasid_table, -1, 382 memset(sn_cnodeid_to_nasid, -1,
368 sizeof(pda->cnodeid_to_nasid_table)); 383 sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
369 for_each_online_node(cnode) 384 for_each_online_node(cnode)
370 pda->cnodeid_to_nasid_table[cnode] = 385 sn_cnodeid_to_nasid[cnode] =
371 pxm_to_nasid(nid_to_pxm_map[cnode]); 386 pxm_to_nasid(nid_to_pxm_map[cnode]);
372 387
373 numionodes = num_online_nodes(); 388 numionodes = num_online_nodes();
374 scan_for_ionodes(); 389 scan_for_ionodes();
@@ -468,7 +483,8 @@ void __init sn_cpu_init(void)
468 483
469 cnode = nasid_to_cnodeid(nasid); 484 cnode = nasid_to_cnodeid(nasid);
470 485
471 pda->p_nodepda = nodepdaindr[cnode]; 486 sn_nodepda = nodepdaindr[cnode];
487
472 pda->led_address = 488 pda->led_address =
473 (typeof(pda->led_address)) (LED0 + (slice << LED_CPU_SHIFT)); 489 (typeof(pda->led_address)) (LED0 + (slice << LED_CPU_SHIFT));
474 pda->led_state = LED_ALWAYS_SET; 490 pda->led_state = LED_ALWAYS_SET;
@@ -477,15 +493,18 @@ void __init sn_cpu_init(void)
477 pda->idle_flag = 0; 493 pda->idle_flag = 0;
478 494
479 if (cpuid != 0) { 495 if (cpuid != 0) {
480 memcpy(pda->cnodeid_to_nasid_table, 496 /* copy cpu 0's sn_cnodeid_to_nasid table to this cpu's */
481 pdacpu(0)->cnodeid_to_nasid_table, 497 memcpy(sn_cnodeid_to_nasid,
482 sizeof(pda->cnodeid_to_nasid_table)); 498 (&per_cpu(__sn_cnodeid_to_nasid, 0)),
499 sizeof(__ia64_per_cpu_var(__sn_cnodeid_to_nasid)));
483 } 500 }
484 501
485 /* 502 /*
486 * Check for WARs. 503 * Check for WARs.
487 * Only needs to be done once, on BSP. 504 * Only needs to be done once, on BSP.
488 * Has to be done after loop above, because it uses pda.cnodeid_to_nasid_table[i]. 505 * Has to be done after loop above, because it uses this cpu's
506 * sn_cnodeid_to_nasid table which was just initialized if this
507 * isn't cpu 0.
489 * Has to be done before assignment below. 508 * Has to be done before assignment below.
490 */ 509 */
491 if (!wars_have_been_checked) { 510 if (!wars_have_been_checked) {
@@ -571,8 +590,7 @@ static void __init scan_for_ionodes(void)
571 brd = find_lboard_any(brd, KLTYPE_SNIA); 590 brd = find_lboard_any(brd, KLTYPE_SNIA);
572 591
573 while (brd) { 592 while (brd) {
574 pda->cnodeid_to_nasid_table[numionodes] = 593 sn_cnodeid_to_nasid[numionodes] = brd->brd_nasid;
575 brd->brd_nasid;
576 physical_node_map[brd->brd_nasid] = numionodes; 594 physical_node_map[brd->brd_nasid] = numionodes;
577 root_lboard[numionodes] = brd; 595 root_lboard[numionodes] = brd;
578 numionodes++; 596 numionodes++;
@@ -593,8 +611,7 @@ static void __init scan_for_ionodes(void)
593 root_lboard[nasid_to_cnodeid(nasid)], 611 root_lboard[nasid_to_cnodeid(nasid)],
594 KLTYPE_TIO); 612 KLTYPE_TIO);
595 while (brd) { 613 while (brd) {
596 pda->cnodeid_to_nasid_table[numionodes] = 614 sn_cnodeid_to_nasid[numionodes] = brd->brd_nasid;
597 brd->brd_nasid;
598 physical_node_map[brd->brd_nasid] = numionodes; 615 physical_node_map[brd->brd_nasid] = numionodes;
599 root_lboard[numionodes] = brd; 616 root_lboard[numionodes] = brd;
600 numionodes++; 617 numionodes++;
@@ -605,7 +622,6 @@ static void __init scan_for_ionodes(void)
605 brd = find_lboard_any(brd, KLTYPE_TIO); 622 brd = find_lboard_any(brd, KLTYPE_TIO);
606 } 623 }
607 } 624 }
608
609} 625}
610 626
611int 627int
@@ -614,7 +630,8 @@ nasid_slice_to_cpuid(int nasid, int slice)
614 long cpu; 630 long cpu;
615 631
616 for (cpu=0; cpu < NR_CPUS; cpu++) 632 for (cpu=0; cpu < NR_CPUS; cpu++)
617 if (nodepda->phys_cpuid[cpu].nasid == nasid && nodepda->phys_cpuid[cpu].slice == slice) 633 if (cpuid_to_nasid(cpu) == nasid &&
634 cpuid_to_slice(cpu) == slice)
618 return cpu; 635 return cpu;
619 636
620 return -1; 637 return -1;
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 197356460ee1..833e700fdac9 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -28,6 +28,7 @@
28#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
29#include <linux/seq_file.h> 29#include <linux/seq_file.h>
30#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
31#include <linux/utsname.h>
31#include <linux/cpumask.h> 32#include <linux/cpumask.h>
32#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
33#include <linux/nodemask.h> 34#include <linux/nodemask.h>
@@ -43,6 +44,7 @@
43#include <asm/sn/module.h> 44#include <asm/sn/module.h>
44#include <asm/sn/geo.h> 45#include <asm/sn/geo.h>
45#include <asm/sn/sn2/sn_hwperf.h> 46#include <asm/sn/sn2/sn_hwperf.h>
47#include <asm/sn/addrs.h>
46 48
47static void *sn_hwperf_salheap = NULL; 49static void *sn_hwperf_salheap = NULL;
48static int sn_hwperf_obj_cnt = 0; 50static int sn_hwperf_obj_cnt = 0;
@@ -81,26 +83,45 @@ out:
81 return e; 83 return e;
82} 84}
83 85
86static int sn_hwperf_location_to_bpos(char *location,
87 int *rack, int *bay, int *slot, int *slab)
88{
89 char type;
90
91 /* first scan for an old style geoid string */
92 if (sscanf(location, "%03d%c%02d#%d",
93 rack, &type, bay, slab) == 4)
94 *slot = 0;
95 else /* scan for a new bladed geoid string */
96 if (sscanf(location, "%03d%c%02d^%02d#%d",
97 rack, &type, bay, slot, slab) != 5)
98 return -1;
99 /* success */
100 return 0;
101}
102
84static int sn_hwperf_geoid_to_cnode(char *location) 103static int sn_hwperf_geoid_to_cnode(char *location)
85{ 104{
86 int cnode; 105 int cnode;
87 geoid_t geoid; 106 geoid_t geoid;
88 moduleid_t module_id; 107 moduleid_t module_id;
89 char type; 108 int rack, bay, slot, slab;
90 int rack, slot, slab; 109 int this_rack, this_bay, this_slot, this_slab;
91 int this_rack, this_slot, this_slab;
92 110
93 if (sscanf(location, "%03d%c%02d#%d", &rack, &type, &slot, &slab) != 4) 111 if (sn_hwperf_location_to_bpos(location, &rack, &bay, &slot, &slab))
94 return -1; 112 return -1;
95 113
96 for (cnode = 0; cnode < numionodes; cnode++) { 114 for (cnode = 0; cnode < numionodes; cnode++) {
97 geoid = cnodeid_get_geoid(cnode); 115 geoid = cnodeid_get_geoid(cnode);
98 module_id = geo_module(geoid); 116 module_id = geo_module(geoid);
99 this_rack = MODULE_GET_RACK(module_id); 117 this_rack = MODULE_GET_RACK(module_id);
100 this_slot = MODULE_GET_BPOS(module_id); 118 this_bay = MODULE_GET_BPOS(module_id);
119 this_slot = geo_slot(geoid);
101 this_slab = geo_slab(geoid); 120 this_slab = geo_slab(geoid);
102 if (rack == this_rack && slot == this_slot && slab == this_slab) 121 if (rack == this_rack && bay == this_bay &&
122 slot == this_slot && slab == this_slab) {
103 break; 123 break;
124 }
104 } 125 }
105 126
106 return cnode < numionodes ? cnode : -1; 127 return cnode < numionodes ? cnode : -1;
@@ -153,11 +174,36 @@ static const char *sn_hwperf_get_slabname(struct sn_hwperf_object_info *obj,
153 return slabname; 174 return slabname;
154} 175}
155 176
177static void print_pci_topology(struct seq_file *s,
178 struct sn_hwperf_object_info *obj, int *ordinal,
179 u64 rack, u64 bay, u64 slot, u64 slab)
180{
181 char *p1;
182 char *p2;
183 char *pg;
184
185 if (!(pg = (char *)get_zeroed_page(GFP_KERNEL)))
186 return; /* ignore */
187 if (ia64_sn_ioif_get_pci_topology(rack, bay, slot, slab,
188 __pa(pg), PAGE_SIZE) == SN_HWPERF_OP_OK) {
189 for (p1=pg; *p1 && p1 < pg + PAGE_SIZE;) {
190 if (!(p2 = strchr(p1, '\n')))
191 break;
192 *p2 = '\0';
193 seq_printf(s, "pcibus %d %s-%s\n",
194 *ordinal, obj->location, p1);
195 (*ordinal)++;
196 p1 = p2 + 1;
197 }
198 }
199 free_page((unsigned long)pg);
200}
201
156static int sn_topology_show(struct seq_file *s, void *d) 202static int sn_topology_show(struct seq_file *s, void *d)
157{ 203{
158 int sz; 204 int sz;
159 int pt; 205 int pt;
160 int e; 206 int e = 0;
161 int i; 207 int i;
162 int j; 208 int j;
163 const char *slabname; 209 const char *slabname;
@@ -169,11 +215,44 @@ static int sn_topology_show(struct seq_file *s, void *d)
169 struct sn_hwperf_object_info *p; 215 struct sn_hwperf_object_info *p;
170 struct sn_hwperf_object_info *obj = d; /* this object */ 216 struct sn_hwperf_object_info *obj = d; /* this object */
171 struct sn_hwperf_object_info *objs = s->private; /* all objects */ 217 struct sn_hwperf_object_info *objs = s->private; /* all objects */
218 int rack, bay, slot, slab;
219 u8 shubtype;
220 u8 system_size;
221 u8 sharing_size;
222 u8 partid;
223 u8 coher;
224 u8 nasid_shift;
225 u8 region_size;
226 u16 nasid_mask;
227 int nasid_msb;
228 int pci_bus_ordinal = 0;
172 229
173 if (obj == objs) { 230 if (obj == objs) {
174 seq_printf(s, "# sn_topology version 1\n"); 231 seq_printf(s, "# sn_topology version 2\n");
175 seq_printf(s, "# objtype ordinal location partition" 232 seq_printf(s, "# objtype ordinal location partition"
176 " [attribute value [, ...]]\n"); 233 " [attribute value [, ...]]\n");
234
235 if (ia64_sn_get_sn_info(0,
236 &shubtype, &nasid_mask, &nasid_shift, &system_size,
237 &sharing_size, &partid, &coher, &region_size))
238 BUG();
239 for (nasid_msb=63; nasid_msb > 0; nasid_msb--) {
240 if (((u64)nasid_mask << nasid_shift) & (1ULL << nasid_msb))
241 break;
242 }
243 seq_printf(s, "partition %u %s local "
244 "shubtype %s, "
245 "nasid_mask 0x%016lx, "
246 "nasid_bits %d:%d, "
247 "system_size %d, "
248 "sharing_size %d, "
249 "coherency_domain %d, "
250 "region_size %d\n",
251
252 partid, system_utsname.nodename,
253 shubtype ? "shub2" : "shub1",
254 (u64)nasid_mask << nasid_shift, nasid_msb, nasid_shift,
255 system_size, sharing_size, coher, region_size);
177 } 256 }
178 257
179 if (SN_HWPERF_FOREIGN(obj)) { 258 if (SN_HWPERF_FOREIGN(obj)) {
@@ -181,7 +260,7 @@ static int sn_topology_show(struct seq_file *s, void *d)
181 return 0; 260 return 0;
182 } 261 }
183 262
184 for (i = 0; obj->name[i]; i++) { 263 for (i = 0; i < SN_HWPERF_MAXSTRING && obj->name[i]; i++) {
185 if (obj->name[i] == ' ') 264 if (obj->name[i] == ' ')
186 obj->name[i] = '_'; 265 obj->name[i] = '_';
187 } 266 }
@@ -221,6 +300,17 @@ static int sn_topology_show(struct seq_file *s, void *d)
221 seq_putc(s, '\n'); 300 seq_putc(s, '\n');
222 } 301 }
223 } 302 }
303
304 /*
305 * PCI busses attached to this node, if any
306 */
307 if (sn_hwperf_location_to_bpos(obj->location,
308 &rack, &bay, &slot, &slab)) {
309 /* export pci bus info */
310 print_pci_topology(s, obj, &pci_bus_ordinal,
311 rack, bay, slot, slab);
312
313 }
224 } 314 }
225 315
226 if (obj->ports) { 316 if (obj->ports) {
@@ -397,6 +487,9 @@ static int sn_hwperf_map_err(int hwperf_err)
397 break; 487 break;
398 488
399 case SN_HWPERF_OP_BUSY: 489 case SN_HWPERF_OP_BUSY:
490 e = -EBUSY;
491 break;
492
400 case SN_HWPERF_OP_RECONFIGURE: 493 case SN_HWPERF_OP_RECONFIGURE:
401 e = -EAGAIN; 494 e = -EAGAIN;
402 break; 495 break;
@@ -549,6 +642,7 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, u64 arg)
549 r = sn_hwperf_op_cpu(&op_info); 642 r = sn_hwperf_op_cpu(&op_info);
550 if (r) { 643 if (r) {
551 r = sn_hwperf_map_err(r); 644 r = sn_hwperf_map_err(r);
645 a.v0 = v0;
552 goto error; 646 goto error;
553 } 647 }
554 break; 648 break;
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
new file mode 100644
index 000000000000..ab9b5f35c2a7
--- /dev/null
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -0,0 +1,552 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/version.h>
12#include <linux/slab.h>
13#include <linux/spinlock.h>
14#include <linux/proc_fs.h>
15#include <linux/device.h>
16#include <linux/delay.h>
17#include <asm/uaccess.h>
18#include <asm/sn/sn_sal.h>
19#include <asm/sn/addrs.h>
20#include <asm/sn/io.h>
21#include <asm/sn/types.h>
22#include <asm/sn/shubio.h>
23#include <asm/sn/tiocx.h>
24#include <asm/sn/l1.h>
25#include <asm/sn/module.h>
26#include "tio.h"
27#include "xtalk/xwidgetdev.h"
28#include "xtalk/hubdev.h"
29
30#define CX_DEV_NONE 0
31#define DEVICE_NAME "tiocx"
32#define WIDGET_ID 0
33#define TIOCX_DEBUG 0
34
35#if TIOCX_DEBUG
36#define DBG(fmt...) printk(KERN_ALERT fmt)
37#else
38#define DBG(fmt...)
39#endif
40
41struct device_attribute dev_attr_cxdev_control;
42
43/**
44 * tiocx_match - Try to match driver id list with device.
45 * @dev: device pointer
46 * @drv: driver pointer
47 *
48 * Returns 1 if match, 0 otherwise.
49 */
50static int tiocx_match(struct device *dev, struct device_driver *drv)
51{
52 struct cx_dev *cx_dev = to_cx_dev(dev);
53 struct cx_drv *cx_drv = to_cx_driver(drv);
54 const struct cx_device_id *ids = cx_drv->id_table;
55
56 if (!ids)
57 return 0;
58
59 while (ids->part_num) {
60 if (ids->part_num == cx_dev->cx_id.part_num)
61 return 1;
62 ids++;
63 }
64 return 0;
65
66}
67
68static int tiocx_hotplug(struct device *dev, char **envp, int num_envp,
69 char *buffer, int buffer_size)
70{
71 return -ENODEV;
72}
73
74static void tiocx_bus_release(struct device *dev)
75{
76 kfree(to_cx_dev(dev));
77}
78
79struct bus_type tiocx_bus_type = {
80 .name = "tiocx",
81 .match = tiocx_match,
82 .hotplug = tiocx_hotplug,
83};
84
85/**
86 * cx_device_match - Find cx_device in the id table.
87 * @ids: id table from driver
88 * @cx_device: part/mfg id for the device
89 *
90 */
91static const struct cx_device_id *cx_device_match(const struct cx_device_id
92 *ids,
93 struct cx_dev *cx_device)
94{
95 /*
96 * NOTES: We may want to check for CX_ANY_ID too.
97 * Do we want to match against nasid too?
98 * CX_DEV_NONE == 0, if the driver tries to register for
99 * part/mfg == 0 we should return no-match (NULL) here.
100 */
101 while (ids->part_num && ids->mfg_num) {
102 if (ids->part_num == cx_device->cx_id.part_num &&
103 ids->mfg_num == cx_device->cx_id.mfg_num)
104 return ids;
105 ids++;
106 }
107
108 return NULL;
109}
110
111/**
112 * cx_device_probe - Look for matching device.
113 * Call driver probe routine if found.
114 * @cx_driver: driver table (cx_drv struct) from driver
115 * @cx_device: part/mfg id for the device
116 */
117static int cx_device_probe(struct device *dev)
118{
119 const struct cx_device_id *id;
120 struct cx_drv *cx_drv = to_cx_driver(dev->driver);
121 struct cx_dev *cx_dev = to_cx_dev(dev);
122 int error = 0;
123
124 if (!cx_dev->driver && cx_drv->probe) {
125 id = cx_device_match(cx_drv->id_table, cx_dev);
126 if (id) {
127 if ((error = cx_drv->probe(cx_dev, id)) < 0)
128 return error;
129 else
130 cx_dev->driver = cx_drv;
131 }
132 }
133
134 return error;
135}
136
137/**
138 * cx_driver_remove - Remove driver from device struct.
139 * @dev: device
140 */
141static int cx_driver_remove(struct device *dev)
142{
143 struct cx_dev *cx_dev = to_cx_dev(dev);
144 struct cx_drv *cx_drv = cx_dev->driver;
145 if (cx_drv->remove)
146 cx_drv->remove(cx_dev);
147 cx_dev->driver = NULL;
148 return 0;
149}
150
151/**
152 * cx_driver_register - Register the driver.
153 * @cx_driver: driver table (cx_drv struct) from driver
154 *
155 * Called from the driver init routine to register a driver.
156 * The cx_drv struct contains the driver name, a pointer to
157 * a table of part/mfg numbers and a pointer to the driver's
158 * probe/attach routine.
159 */
160int cx_driver_register(struct cx_drv *cx_driver)
161{
162 cx_driver->driver.name = cx_driver->name;
163 cx_driver->driver.bus = &tiocx_bus_type;
164 cx_driver->driver.probe = cx_device_probe;
165 cx_driver->driver.remove = cx_driver_remove;
166
167 return driver_register(&cx_driver->driver);
168}
169
170/**
171 * cx_driver_unregister - Unregister the driver.
172 * @cx_driver: driver table (cx_drv struct) from driver
173 */
174int cx_driver_unregister(struct cx_drv *cx_driver)
175{
176 driver_unregister(&cx_driver->driver);
177 return 0;
178}
179
180/**
181 * cx_device_register - Register a device.
182 * @nasid: device's nasid
183 * @part_num: device's part number
184 * @mfg_num: device's manufacturer number
185 * @hubdev: hub info associated with this device
186 *
187 */
188int
189cx_device_register(nasid_t nasid, int part_num, int mfg_num,
190 struct hubdev_info *hubdev)
191{
192 struct cx_dev *cx_dev;
193
194 cx_dev = kcalloc(1, sizeof(struct cx_dev), GFP_KERNEL);
195 DBG("cx_dev= 0x%p\n", cx_dev);
196 if (cx_dev == NULL)
197 return -ENOMEM;
198
199 cx_dev->cx_id.part_num = part_num;
200 cx_dev->cx_id.mfg_num = mfg_num;
201 cx_dev->cx_id.nasid = nasid;
202 cx_dev->hubdev = hubdev;
203
204 cx_dev->dev.parent = NULL;
205 cx_dev->dev.bus = &tiocx_bus_type;
206 cx_dev->dev.release = tiocx_bus_release;
207 snprintf(cx_dev->dev.bus_id, BUS_ID_SIZE, "%d.0x%x",
208 cx_dev->cx_id.nasid, cx_dev->cx_id.part_num);
209 device_register(&cx_dev->dev);
210 get_device(&cx_dev->dev);
211
212 device_create_file(&cx_dev->dev, &dev_attr_cxdev_control);
213
214 return 0;
215}
216
217/**
218 * cx_device_unregister - Unregister a device.
219 * @cx_dev: part/mfg id for the device
220 */
221int cx_device_unregister(struct cx_dev *cx_dev)
222{
223 put_device(&cx_dev->dev);
224 device_unregister(&cx_dev->dev);
225 return 0;
226}
227
228/**
229 * cx_device_reload - Reload the device.
230 * @nasid: device's nasid
231 * @part_num: device's part number
232 * @mfg_num: device's manufacturer number
233 *
234 * Remove the device associated with 'nasid' from device list and then
235 * call device-register with the given part/mfg numbers.
236 */
237static int cx_device_reload(struct cx_dev *cx_dev)
238{
239 device_remove_file(&cx_dev->dev, &dev_attr_cxdev_control);
240 cx_device_unregister(cx_dev);
241 return cx_device_register(cx_dev->cx_id.nasid, cx_dev->cx_id.part_num,
242 cx_dev->cx_id.mfg_num, cx_dev->hubdev);
243}
244
245static inline uint64_t tiocx_intr_alloc(nasid_t nasid, int widget,
246 u64 sn_irq_info,
247 int req_irq, nasid_t req_nasid,
248 int req_slice)
249{
250 struct ia64_sal_retval rv;
251 rv.status = 0;
252 rv.v0 = 0;
253
254 ia64_sal_oemcall_nolock(&rv, SN_SAL_IOIF_INTERRUPT,
255 SAL_INTR_ALLOC, nasid,
256 widget, sn_irq_info, req_irq,
257 req_nasid, req_slice);
258 return rv.status;
259}
260
261static inline void tiocx_intr_free(nasid_t nasid, int widget,
262 struct sn_irq_info *sn_irq_info)
263{
264 struct ia64_sal_retval rv;
265 rv.status = 0;
266 rv.v0 = 0;
267
268 ia64_sal_oemcall_nolock(&rv, SN_SAL_IOIF_INTERRUPT,
269 SAL_INTR_FREE, nasid,
270 widget, sn_irq_info->irq_irq,
271 sn_irq_info->irq_cookie, 0, 0);
272}
273
274struct sn_irq_info *tiocx_irq_alloc(nasid_t nasid, int widget, int irq,
275 nasid_t req_nasid, int slice)
276{
277 struct sn_irq_info *sn_irq_info;
278 int status;
279 int sn_irq_size = sizeof(struct sn_irq_info);
280
281 if ((nasid & 1) == 0)
282 return NULL;
283
284 sn_irq_info = kmalloc(sn_irq_size, GFP_KERNEL);
285 if (sn_irq_info == NULL)
286 return NULL;
287
288 memset(sn_irq_info, 0x0, sn_irq_size);
289
290 status = tiocx_intr_alloc(nasid, widget, __pa(sn_irq_info), irq,
291 req_nasid, slice);
292 if (status) {
293 kfree(sn_irq_info);
294 return NULL;
295 } else {
296 return sn_irq_info;
297 }
298}
299
300void tiocx_irq_free(struct sn_irq_info *sn_irq_info)
301{
302 uint64_t bridge = (uint64_t) sn_irq_info->irq_bridge;
303 nasid_t nasid = NASID_GET(bridge);
304 int widget;
305
306 if (nasid & 1) {
307 widget = TIO_SWIN_WIDGETNUM(bridge);
308 tiocx_intr_free(nasid, widget, sn_irq_info);
309 kfree(sn_irq_info);
310 }
311}
312
313uint64_t tiocx_dma_addr(uint64_t addr)
314{
315 return PHYS_TO_TIODMA(addr);
316}
317
318uint64_t tiocx_swin_base(int nasid)
319{
320 return TIO_SWIN_BASE(nasid, TIOCX_CORELET);
321}
322
323EXPORT_SYMBOL(cx_driver_register);
324EXPORT_SYMBOL(cx_driver_unregister);
325EXPORT_SYMBOL(cx_device_register);
326EXPORT_SYMBOL(cx_device_unregister);
327EXPORT_SYMBOL(tiocx_irq_alloc);
328EXPORT_SYMBOL(tiocx_irq_free);
329EXPORT_SYMBOL(tiocx_bus_type);
330EXPORT_SYMBOL(tiocx_dma_addr);
331EXPORT_SYMBOL(tiocx_swin_base);
332
333static void tio_conveyor_set(nasid_t nasid, int enable_flag)
334{
335 uint64_t ice_frz;
336 uint64_t disable_cb = (1ull << 61);
337
338 if (!(nasid & 1))
339 return;
340
341 ice_frz = REMOTE_HUB_L(nasid, TIO_ICE_FRZ_CFG);
342 if (enable_flag) {
343 if (!(ice_frz & disable_cb)) /* already enabled */
344 return;
345 ice_frz &= ~disable_cb;
346 } else {
347 if (ice_frz & disable_cb) /* already disabled */
348 return;
349 ice_frz |= disable_cb;
350 }
351 DBG(KERN_ALERT "TIO_ICE_FRZ_CFG= 0x%lx\n", ice_frz);
352 REMOTE_HUB_S(nasid, TIO_ICE_FRZ_CFG, ice_frz);
353}
354
355#define tio_conveyor_enable(nasid) tio_conveyor_set(nasid, 1)
356#define tio_conveyor_disable(nasid) tio_conveyor_set(nasid, 0)
357
358static void tio_corelet_reset(nasid_t nasid, int corelet)
359{
360 if (!(nasid & 1))
361 return;
362
363 REMOTE_HUB_S(nasid, TIO_ICE_PMI_TX_CFG, 1 << corelet);
364 udelay(2000);
365 REMOTE_HUB_S(nasid, TIO_ICE_PMI_TX_CFG, 0);
366 udelay(2000);
367}
368
369static int tiocx_btchar_get(int nasid)
370{
371 moduleid_t module_id;
372 geoid_t geoid;
373 int cnodeid;
374
375 cnodeid = nasid_to_cnodeid(nasid);
376 geoid = cnodeid_get_geoid(cnodeid);
377 module_id = geo_module(geoid);
378 return MODULE_GET_BTCHAR(module_id);
379}
380
381static int is_fpga_brick(int nasid)
382{
383 switch (tiocx_btchar_get(nasid)) {
384 case L1_BRICKTYPE_SA:
385 case L1_BRICKTYPE_ATHENA:
386 return 1;
387 }
388 return 0;
389}
390
391static int bitstream_loaded(nasid_t nasid)
392{
393 uint64_t cx_credits;
394
395 cx_credits = REMOTE_HUB_L(nasid, TIO_ICE_PMI_TX_DYN_CREDIT_STAT_CB3);
396 cx_credits &= TIO_ICE_PMI_TX_DYN_CREDIT_STAT_CB3_CREDIT_CNT_MASK;
397 DBG("cx_credits= 0x%lx\n", cx_credits);
398
399 return (cx_credits == 0xf) ? 1 : 0;
400}
401
402static int tiocx_reload(struct cx_dev *cx_dev)
403{
404 int part_num = CX_DEV_NONE;
405 int mfg_num = CX_DEV_NONE;
406 nasid_t nasid = cx_dev->cx_id.nasid;
407
408 if (bitstream_loaded(nasid)) {
409 uint64_t cx_id;
410
411 cx_id =
412 *(volatile int32_t *)(TIO_SWIN_BASE(nasid, TIOCX_CORELET) +
413 WIDGET_ID);
414 part_num = XWIDGET_PART_NUM(cx_id);
415 mfg_num = XWIDGET_MFG_NUM(cx_id);
416 DBG("part= 0x%x, mfg= 0x%x\n", part_num, mfg_num);
417 /* just ignore it if it's a CE */
418 if (part_num == TIO_CE_ASIC_PARTNUM)
419 return 0;
420 }
421
422 cx_dev->cx_id.part_num = part_num;
423 cx_dev->cx_id.mfg_num = mfg_num;
424
425 /*
426 * Delete old device and register the new one. It's ok if
427 * part_num/mfg_num == CX_DEV_NONE. We want to register
428 * devices in the table even if a bitstream isn't loaded.
429 * That allows use to see that a bitstream isn't loaded via
430 * TIOCX_IOCTL_DEV_LIST.
431 */
432 return cx_device_reload(cx_dev);
433}
434
435static ssize_t show_cxdev_control(struct device *dev, char *buf)
436{
437 struct cx_dev *cx_dev = to_cx_dev(dev);
438
439 return sprintf(buf, "0x%x 0x%x 0x%x %d\n",
440 cx_dev->cx_id.nasid,
441 cx_dev->cx_id.part_num, cx_dev->cx_id.mfg_num,
442 tiocx_btchar_get(cx_dev->cx_id.nasid));
443}
444
445static ssize_t store_cxdev_control(struct device *dev, const char *buf,
446 size_t count)
447{
448 int n;
449 struct cx_dev *cx_dev = to_cx_dev(dev);
450
451 if (!capable(CAP_SYS_ADMIN))
452 return -EPERM;
453
454 if (count <= 0)
455 return 0;
456
457 n = simple_strtoul(buf, NULL, 0);
458
459 switch (n) {
460 case 1:
461 tiocx_reload(cx_dev);
462 break;
463 case 3:
464 tio_corelet_reset(cx_dev->cx_id.nasid, TIOCX_CORELET);
465 break;
466 default:
467 break;
468 }
469
470 return count;
471}
472
473DEVICE_ATTR(cxdev_control, 0644, show_cxdev_control, store_cxdev_control);
474
475static int __init tiocx_init(void)
476{
477 cnodeid_t cnodeid;
478 int found_tiocx_device = 0;
479
480 bus_register(&tiocx_bus_type);
481
482 for (cnodeid = 0; cnodeid < MAX_COMPACT_NODES; cnodeid++) {
483 nasid_t nasid;
484
485 if ((nasid = cnodeid_to_nasid(cnodeid)) < 0)
486 break; /* No more nasids .. bail out of loop */
487
488 if ((nasid & 0x1) && is_fpga_brick(nasid)) {
489 struct hubdev_info *hubdev;
490 struct xwidget_info *widgetp;
491
492 DBG("Found TIO at nasid 0x%x\n", nasid);
493
494 hubdev =
495 (struct hubdev_info *)(NODEPDA(cnodeid)->pdinfo);
496
497 widgetp = &hubdev->hdi_xwidget_info[TIOCX_CORELET];
498
499 /* The CE hangs off of the CX port but is not an FPGA */
500 if (widgetp->xwi_hwid.part_num == TIO_CE_ASIC_PARTNUM)
501 continue;
502
503 tio_corelet_reset(nasid, TIOCX_CORELET);
504 tio_conveyor_enable(nasid);
505
506 if (cx_device_register
507 (nasid, widgetp->xwi_hwid.part_num,
508 widgetp->xwi_hwid.mfg_num, hubdev) < 0)
509 return -ENXIO;
510 else
511 found_tiocx_device++;
512 }
513 }
514
515 /* It's ok if we find zero devices. */
516 DBG("found_tiocx_device= %d\n", found_tiocx_device);
517
518 return 0;
519}
520
521static void __exit tiocx_exit(void)
522{
523 struct device *dev;
524 struct device *tdev;
525
526 DBG("tiocx_exit\n");
527
528 /*
529 * Unregister devices.
530 */
531 list_for_each_entry_safe(dev, tdev, &tiocx_bus_type.devices.list,
532 bus_list) {
533 if (dev) {
534 struct cx_dev *cx_dev = to_cx_dev(dev);
535 device_remove_file(dev, &dev_attr_cxdev_control);
536 cx_device_unregister(cx_dev);
537 }
538 }
539
540 bus_unregister(&tiocx_bus_type);
541}
542
543module_init(tiocx_init);
544module_exit(tiocx_exit);
545
546/************************************************************************
547 * Module licensing and description
548 ************************************************************************/
549MODULE_LICENSE("GPL");
550MODULE_AUTHOR("Bruce Losure <blosure@sgi.com>");
551MODULE_DESCRIPTION("TIOCX module");
552MODULE_SUPPORTED_DEVICE(DEVICE_NAME);
diff --git a/arch/ia64/sn/kernel/xp_main.c b/arch/ia64/sn/kernel/xp_main.c
new file mode 100644
index 000000000000..3be52a34c80f
--- /dev/null
+++ b/arch/ia64/sn/kernel/xp_main.c
@@ -0,0 +1,289 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * Cross Partition (XP) base.
12 *
13 * XP provides a base from which its users can interact
14 * with XPC, yet not be dependent on XPC.
15 *
16 */
17
18
19#include <linux/kernel.h>
20#include <linux/interrupt.h>
21#include <linux/module.h>
22#include <asm/sn/intr.h>
23#include <asm/sn/sn_sal.h>
24#include <asm/sn/xp.h>
25
26
27/*
28 * Target of nofault PIO read.
29 */
30u64 xp_nofault_PIOR_target;
31
32
33/*
34 * xpc_registrations[] keeps track of xpc_connect()'s done by the kernel-level
35 * users of XPC.
36 */
37struct xpc_registration xpc_registrations[XPC_NCHANNELS];
38
39
40/*
41 * Initialize the XPC interface to indicate that XPC isn't loaded.
42 */
43static enum xpc_retval xpc_notloaded(void) { return xpcNotLoaded; }
44
45struct xpc_interface xpc_interface = {
46 (void (*)(int)) xpc_notloaded,
47 (void (*)(int)) xpc_notloaded,
48 (enum xpc_retval (*)(partid_t, int, u32, void **)) xpc_notloaded,
49 (enum xpc_retval (*)(partid_t, int, void *)) xpc_notloaded,
50 (enum xpc_retval (*)(partid_t, int, void *, xpc_notify_func, void *))
51 xpc_notloaded,
52 (void (*)(partid_t, int, void *)) xpc_notloaded,
53 (enum xpc_retval (*)(partid_t, void *)) xpc_notloaded
54};
55
56
57/*
58 * XPC calls this when it (the XPC module) has been loaded.
59 */
60void
61xpc_set_interface(void (*connect)(int),
62 void (*disconnect)(int),
63 enum xpc_retval (*allocate)(partid_t, int, u32, void **),
64 enum xpc_retval (*send)(partid_t, int, void *),
65 enum xpc_retval (*send_notify)(partid_t, int, void *,
66 xpc_notify_func, void *),
67 void (*received)(partid_t, int, void *),
68 enum xpc_retval (*partid_to_nasids)(partid_t, void *))
69{
70 xpc_interface.connect = connect;
71 xpc_interface.disconnect = disconnect;
72 xpc_interface.allocate = allocate;
73 xpc_interface.send = send;
74 xpc_interface.send_notify = send_notify;
75 xpc_interface.received = received;
76 xpc_interface.partid_to_nasids = partid_to_nasids;
77}
78
79
80/*
81 * XPC calls this when it (the XPC module) is being unloaded.
82 */
83void
84xpc_clear_interface(void)
85{
86 xpc_interface.connect = (void (*)(int)) xpc_notloaded;
87 xpc_interface.disconnect = (void (*)(int)) xpc_notloaded;
88 xpc_interface.allocate = (enum xpc_retval (*)(partid_t, int, u32,
89 void **)) xpc_notloaded;
90 xpc_interface.send = (enum xpc_retval (*)(partid_t, int, void *))
91 xpc_notloaded;
92 xpc_interface.send_notify = (enum xpc_retval (*)(partid_t, int, void *,
93 xpc_notify_func, void *)) xpc_notloaded;
94 xpc_interface.received = (void (*)(partid_t, int, void *))
95 xpc_notloaded;
96 xpc_interface.partid_to_nasids = (enum xpc_retval (*)(partid_t, void *))
97 xpc_notloaded;
98}
99
100
101/*
102 * Register for automatic establishment of a channel connection whenever
103 * a partition comes up.
104 *
105 * Arguments:
106 *
107 * ch_number - channel # to register for connection.
108 * func - function to call for asynchronous notification of channel
109 * state changes (i.e., connection, disconnection, error) and
110 * the arrival of incoming messages.
111 * key - pointer to optional user-defined value that gets passed back
112 * to the user on any callouts made to func.
113 * payload_size - size in bytes of the XPC message's payload area which
114 * contains a user-defined message. The user should make
115 * this large enough to hold their largest message.
116 * nentries - max #of XPC message entries a message queue can contain.
117 * The actual number, which is determined when a connection
118 * is established and may be less then requested, will be
119 * passed to the user via the xpcConnected callout.
120 * assigned_limit - max number of kthreads allowed to be processing
121 * messages (per connection) at any given instant.
122 * idle_limit - max number of kthreads allowed to be idle at any given
123 * instant.
124 */
125enum xpc_retval
126xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
127 u16 nentries, u32 assigned_limit, u32 idle_limit)
128{
129 struct xpc_registration *registration;
130
131
132 DBUG_ON(ch_number < 0 || ch_number >= XPC_NCHANNELS);
133 DBUG_ON(payload_size == 0 || nentries == 0);
134 DBUG_ON(func == NULL);
135 DBUG_ON(assigned_limit == 0 || idle_limit > assigned_limit);
136
137 registration = &xpc_registrations[ch_number];
138
139 if (down_interruptible(&registration->sema) != 0) {
140 return xpcInterrupted;
141 }
142
143 /* if XPC_CHANNEL_REGISTERED(ch_number) */
144 if (registration->func != NULL) {
145 up(&registration->sema);
146 return xpcAlreadyRegistered;
147 }
148
149 /* register the channel for connection */
150 registration->msg_size = XPC_MSG_SIZE(payload_size);
151 registration->nentries = nentries;
152 registration->assigned_limit = assigned_limit;
153 registration->idle_limit = idle_limit;
154 registration->key = key;
155 registration->func = func;
156
157 up(&registration->sema);
158
159 xpc_interface.connect(ch_number);
160
161 return xpcSuccess;
162}
163
164
165/*
166 * Remove the registration for automatic connection of the specified channel
167 * when a partition comes up.
168 *
169 * Before returning this xpc_disconnect() will wait for all connections on the
170 * specified channel have been closed/torndown. So the caller can be assured
171 * that they will not be receiving any more callouts from XPC to their
172 * function registered via xpc_connect().
173 *
174 * Arguments:
175 *
176 * ch_number - channel # to unregister.
177 */
178void
179xpc_disconnect(int ch_number)
180{
181 struct xpc_registration *registration;
182
183
184 DBUG_ON(ch_number < 0 || ch_number >= XPC_NCHANNELS);
185
186 registration = &xpc_registrations[ch_number];
187
188 /*
189 * We've decided not to make this a down_interruptible(), since we
190 * figured XPC's users will just turn around and call xpc_disconnect()
191 * again anyways, so we might as well wait, if need be.
192 */
193 down(&registration->sema);
194
195 /* if !XPC_CHANNEL_REGISTERED(ch_number) */
196 if (registration->func == NULL) {
197 up(&registration->sema);
198 return;
199 }
200
201 /* remove the connection registration for the specified channel */
202 registration->func = NULL;
203 registration->key = NULL;
204 registration->nentries = 0;
205 registration->msg_size = 0;
206 registration->assigned_limit = 0;
207 registration->idle_limit = 0;
208
209 xpc_interface.disconnect(ch_number);
210
211 up(&registration->sema);
212
213 return;
214}
215
216
217int __init
218xp_init(void)
219{
220 int ret, ch_number;
221 u64 func_addr = *(u64 *) xp_nofault_PIOR;
222 u64 err_func_addr = *(u64 *) xp_error_PIOR;
223
224
225 if (!ia64_platform_is("sn2")) {
226 return -ENODEV;
227 }
228
229 /*
230 * Register a nofault code region which performs a cross-partition
231 * PIO read. If the PIO read times out, the MCA handler will consume
232 * the error and return to a kernel-provided instruction to indicate
233 * an error. This PIO read exists because it is guaranteed to timeout
234 * if the destination is down (AMO operations do not timeout on at
235 * least some CPUs on Shubs <= v1.2, which unfortunately we have to
236 * work around).
237 */
238 if ((ret = sn_register_nofault_code(func_addr, err_func_addr,
239 err_func_addr, 1, 1)) != 0) {
240 printk(KERN_ERR "XP: can't register nofault code, error=%d\n",
241 ret);
242 }
243 /*
244 * Setup the nofault PIO read target. (There is no special reason why
245 * SH_IPI_ACCESS was selected.)
246 */
247 if (is_shub2()) {
248 xp_nofault_PIOR_target = SH2_IPI_ACCESS0;
249 } else {
250 xp_nofault_PIOR_target = SH1_IPI_ACCESS;
251 }
252
253 /* initialize the connection registration semaphores */
254 for (ch_number = 0; ch_number < XPC_NCHANNELS; ch_number++) {
255 sema_init(&xpc_registrations[ch_number].sema, 1); /* mutex */
256 }
257
258 return 0;
259}
260module_init(xp_init);
261
262
263void __exit
264xp_exit(void)
265{
266 u64 func_addr = *(u64 *) xp_nofault_PIOR;
267 u64 err_func_addr = *(u64 *) xp_error_PIOR;
268
269
270 /* unregister the PIO read nofault code region */
271 (void) sn_register_nofault_code(func_addr, err_func_addr,
272 err_func_addr, 1, 0);
273}
274module_exit(xp_exit);
275
276
277MODULE_AUTHOR("Silicon Graphics, Inc.");
278MODULE_DESCRIPTION("Cross Partition (XP) base");
279MODULE_LICENSE("GPL");
280
281EXPORT_SYMBOL(xp_nofault_PIOR);
282EXPORT_SYMBOL(xp_nofault_PIOR_target);
283EXPORT_SYMBOL(xpc_registrations);
284EXPORT_SYMBOL(xpc_interface);
285EXPORT_SYMBOL(xpc_clear_interface);
286EXPORT_SYMBOL(xpc_set_interface);
287EXPORT_SYMBOL(xpc_connect);
288EXPORT_SYMBOL(xpc_disconnect);
289
diff --git a/arch/ia64/sn/kernel/xp_nofault.S b/arch/ia64/sn/kernel/xp_nofault.S
new file mode 100644
index 000000000000..b772543053c9
--- /dev/null
+++ b/arch/ia64/sn/kernel/xp_nofault.S
@@ -0,0 +1,31 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * The xp_nofault_PIOR function takes a pointer to a remote PIO register
12 * and attempts to load and consume a value from it. This function
13 * will be registered as a nofault code block. In the event that the
14 * PIO read fails, the MCA handler will force the error to look
15 * corrected and vector to the xp_error_PIOR which will return an error.
16 *
17 * extern int xp_nofault_PIOR(void *remote_register);
18 */
19
20 .global xp_nofault_PIOR
21xp_nofault_PIOR:
22 mov r8=r0 // Stage a success return value
23 ld8.acq r9=[r32];; // PIO Read the specified register
24 adds r9=1,r9 // Add to force a consume
25 br.ret.sptk.many b0;; // Return success
26
27 .global xp_error_PIOR
28xp_error_PIOR:
29 mov r8=1 // Return value of 1
30 br.ret.sptk.many b0;; // Return failure
31
diff --git a/arch/ia64/sn/kernel/xpc.h b/arch/ia64/sn/kernel/xpc.h
new file mode 100644
index 000000000000..1a0aed8490d1
--- /dev/null
+++ b/arch/ia64/sn/kernel/xpc.h
@@ -0,0 +1,991 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * Cross Partition Communication (XPC) structures and macros.
12 */
13
14#ifndef _IA64_SN_KERNEL_XPC_H
15#define _IA64_SN_KERNEL_XPC_H
16
17
18#include <linux/config.h>
19#include <linux/interrupt.h>
20#include <linux/sysctl.h>
21#include <linux/device.h>
22#include <asm/pgtable.h>
23#include <asm/processor.h>
24#include <asm/sn/bte.h>
25#include <asm/sn/clksupport.h>
26#include <asm/sn/addrs.h>
27#include <asm/sn/mspec.h>
28#include <asm/sn/shub_mmr.h>
29#include <asm/sn/xp.h>
30
31
32/*
33 * XPC Version numbers consist of a major and minor number. XPC can always
34 * talk to versions with same major #, and never talk to versions with a
35 * different major #.
36 */
37#define _XPC_VERSION(_maj, _min) (((_maj) << 4) | ((_min) & 0xf))
38#define XPC_VERSION_MAJOR(_v) ((_v) >> 4)
39#define XPC_VERSION_MINOR(_v) ((_v) & 0xf)
40
41
42/*
43 * The next macros define word or bit representations for given
44 * C-brick nasid in either the SAL provided bit array representing
45 * nasids in the partition/machine or the AMO_t array used for
46 * inter-partition initiation communications.
47 *
48 * For SN2 machines, C-Bricks are alway even numbered NASIDs. As
49 * such, some space will be saved by insisting that nasid information
50 * passed from SAL always be packed for C-Bricks and the
51 * cross-partition interrupts use the same packing scheme.
52 */
53#define XPC_NASID_W_INDEX(_n) (((_n) / 64) / 2)
54#define XPC_NASID_B_INDEX(_n) (((_n) / 2) & (64 - 1))
55#define XPC_NASID_IN_ARRAY(_n, _p) ((_p)[XPC_NASID_W_INDEX(_n)] & \
56 (1UL << XPC_NASID_B_INDEX(_n)))
57#define XPC_NASID_FROM_W_B(_w, _b) (((_w) * 64 + (_b)) * 2)
58
59#define XPC_HB_DEFAULT_INTERVAL 5 /* incr HB every x secs */
60#define XPC_HB_CHECK_DEFAULT_TIMEOUT 20 /* check HB every x secs */
61
62/* define the process name of HB checker and the CPU it is pinned to */
63#define XPC_HB_CHECK_THREAD_NAME "xpc_hb"
64#define XPC_HB_CHECK_CPU 0
65
66/* define the process name of the discovery thread */
67#define XPC_DISCOVERY_THREAD_NAME "xpc_discovery"
68
69
70#define XPC_HB_ALLOWED(_p, _v) ((_v)->heartbeating_to_mask & (1UL << (_p)))
71#define XPC_ALLOW_HB(_p, _v) (_v)->heartbeating_to_mask |= (1UL << (_p))
72#define XPC_DISALLOW_HB(_p, _v) (_v)->heartbeating_to_mask &= (~(1UL << (_p)))
73
74
75/*
76 * Reserved Page provided by SAL.
77 *
78 * SAL provides one page per partition of reserved memory. When SAL
79 * initialization is complete, SAL_signature, SAL_version, partid,
80 * part_nasids, and mach_nasids are set.
81 *
82 * Note: Until vars_pa is set, the partition XPC code has not been initialized.
83 */
84struct xpc_rsvd_page {
85 u64 SAL_signature; /* SAL unique signature */
86 u64 SAL_version; /* SAL specified version */
87 u8 partid; /* partition ID from SAL */
88 u8 version;
89 u8 pad[6]; /* pad to u64 align */
90 u64 vars_pa;
91 u64 part_nasids[XP_NASID_MASK_WORDS] ____cacheline_aligned;
92 u64 mach_nasids[XP_NASID_MASK_WORDS] ____cacheline_aligned;
93};
94#define XPC_RP_VERSION _XPC_VERSION(1,0) /* version 1.0 of the reserved page */
95
96#define XPC_RSVD_PAGE_ALIGNED_SIZE \
97 (L1_CACHE_ALIGN(sizeof(struct xpc_rsvd_page)))
98
99
100/*
101 * Define the structures by which XPC variables can be exported to other
102 * partitions. (There are two: struct xpc_vars and struct xpc_vars_part)
103 */
104
105/*
106 * The following structure describes the partition generic variables
107 * needed by other partitions in order to properly initialize.
108 *
109 * struct xpc_vars version number also applies to struct xpc_vars_part.
110 * Changes to either structure and/or related functionality should be
111 * reflected by incrementing either the major or minor version numbers
112 * of struct xpc_vars.
113 */
114struct xpc_vars {
115 u8 version;
116 u64 heartbeat;
117 u64 heartbeating_to_mask;
118 u64 kdb_status; /* 0 = machine running */
119 int act_nasid;
120 int act_phys_cpuid;
121 u64 vars_part_pa;
122 u64 amos_page_pa; /* paddr of page of AMOs from MSPEC driver */
123 AMO_t *amos_page; /* vaddr of page of AMOs from MSPEC driver */
124 AMO_t *act_amos; /* pointer to the first activation AMO */
125};
126#define XPC_V_VERSION _XPC_VERSION(3,0) /* version 3.0 of the cross vars */
127
128#define XPC_VARS_ALIGNED_SIZE (L1_CACHE_ALIGN(sizeof(struct xpc_vars)))
129
130/*
131 * The following structure describes the per partition specific variables.
132 *
133 * An array of these structures, one per partition, will be defined. As a
134 * partition becomes active XPC will copy the array entry corresponding to
135 * itself from that partition. It is desirable that the size of this
136 * structure evenly divide into a cacheline, such that none of the entries
137 * in this array crosses a cacheline boundary. As it is now, each entry
138 * occupies half a cacheline.
139 */
140struct xpc_vars_part {
141 u64 magic;
142
143 u64 openclose_args_pa; /* physical address of open and close args */
144 u64 GPs_pa; /* physical address of Get/Put values */
145
146 u64 IPI_amo_pa; /* physical address of IPI AMO_t structure */
147 int IPI_nasid; /* nasid of where to send IPIs */
148 int IPI_phys_cpuid; /* physical CPU ID of where to send IPIs */
149
150 u8 nchannels; /* #of defined channels supported */
151
152 u8 reserved[23]; /* pad to a full 64 bytes */
153};
154
155/*
156 * The vars_part MAGIC numbers play a part in the first contact protocol.
157 *
158 * MAGIC1 indicates that the per partition specific variables for a remote
159 * partition have been initialized by this partition.
160 *
161 * MAGIC2 indicates that this partition has pulled the remote partititions
162 * per partition variables that pertain to this partition.
163 */
164#define XPC_VP_MAGIC1 0x0053524156435058L /* 'XPCVARS\0'L (little endian) */
165#define XPC_VP_MAGIC2 0x0073726176435058L /* 'XPCvars\0'L (little endian) */
166
167
168
169/*
170 * Functions registered by add_timer() or called by kernel_thread() only
171 * allow for a single 64-bit argument. The following macros can be used to
172 * pack and unpack two (32-bit, 16-bit or 8-bit) arguments into or out from
173 * the passed argument.
174 */
175#define XPC_PACK_ARGS(_arg1, _arg2) \
176 ((((u64) _arg1) & 0xffffffff) | \
177 ((((u64) _arg2) & 0xffffffff) << 32))
178
179#define XPC_UNPACK_ARG1(_args) (((u64) _args) & 0xffffffff)
180#define XPC_UNPACK_ARG2(_args) ((((u64) _args) >> 32) & 0xffffffff)
181
182
183
184/*
185 * Define a Get/Put value pair (pointers) used with a message queue.
186 */
187struct xpc_gp {
188 s64 get; /* Get value */
189 s64 put; /* Put value */
190};
191
192#define XPC_GP_SIZE \
193 L1_CACHE_ALIGN(sizeof(struct xpc_gp) * XPC_NCHANNELS)
194
195
196
197/*
198 * Define a structure that contains arguments associated with opening and
199 * closing a channel.
200 */
201struct xpc_openclose_args {
202 u16 reason; /* reason why channel is closing */
203 u16 msg_size; /* sizeof each message entry */
204 u16 remote_nentries; /* #of message entries in remote msg queue */
205 u16 local_nentries; /* #of message entries in local msg queue */
206 u64 local_msgqueue_pa; /* physical address of local message queue */
207};
208
209#define XPC_OPENCLOSE_ARGS_SIZE \
210 L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * XPC_NCHANNELS)
211
212
213
214/* struct xpc_msg flags */
215
216#define XPC_M_DONE 0x01 /* msg has been received/consumed */
217#define XPC_M_READY 0x02 /* msg is ready to be sent */
218#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */
219
220
221#define XPC_MSG_ADDRESS(_payload) \
222 ((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET))
223
224
225
226/*
227 * Defines notify entry.
228 *
229 * This is used to notify a message's sender that their message was received
230 * and consumed by the intended recipient.
231 */
232struct xpc_notify {
233 struct semaphore sema; /* notify semaphore */
234 u8 type; /* type of notification */
235
236 /* the following two fields are only used if type == XPC_N_CALL */
237 xpc_notify_func func; /* user's notify function */
238 void *key; /* pointer to user's key */
239};
240
241/* struct xpc_notify type of notification */
242
243#define XPC_N_CALL 0x01 /* notify function provided by user */
244
245
246
247/*
248 * Define the structure that manages all the stuff required by a channel. In
249 * particular, they are used to manage the messages sent across the channel.
250 *
251 * This structure is private to a partition, and is NOT shared across the
252 * partition boundary.
253 *
254 * There is an array of these structures for each remote partition. It is
255 * allocated at the time a partition becomes active. The array contains one
256 * of these structures for each potential channel connection to that partition.
257 *
258 * Each of these structures manages two message queues (circular buffers).
259 * They are allocated at the time a channel connection is made. One of
260 * these message queues (local_msgqueue) holds the locally created messages
261 * that are destined for the remote partition. The other of these message
262 * queues (remote_msgqueue) is a locally cached copy of the remote partition's
263 * own local_msgqueue.
264 *
265 * The following is a description of the Get/Put pointers used to manage these
266 * two message queues. Consider the local_msgqueue to be on one partition
267 * and the remote_msgqueue to be its cached copy on another partition. A
268 * description of what each of the lettered areas contains is included.
269 *
270 *
271 * local_msgqueue remote_msgqueue
272 *
273 * |/////////| |/////////|
274 * w_remote_GP.get --> +---------+ |/////////|
275 * | F | |/////////|
276 * remote_GP.get --> +---------+ +---------+ <-- local_GP->get
277 * | | | |
278 * | | | E |
279 * | | | |
280 * | | +---------+ <-- w_local_GP.get
281 * | B | |/////////|
282 * | | |////D////|
283 * | | |/////////|
284 * | | +---------+ <-- w_remote_GP.put
285 * | | |////C////|
286 * local_GP->put --> +---------+ +---------+ <-- remote_GP.put
287 * | | |/////////|
288 * | A | |/////////|
289 * | | |/////////|
290 * w_local_GP.put --> +---------+ |/////////|
291 * |/////////| |/////////|
292 *
293 *
294 * ( remote_GP.[get|put] are cached copies of the remote
295 * partition's local_GP->[get|put], and thus their values can
296 * lag behind their counterparts on the remote partition. )
297 *
298 *
299 * A - Messages that have been allocated, but have not yet been sent to the
300 * remote partition.
301 *
302 * B - Messages that have been sent, but have not yet been acknowledged by the
303 * remote partition as having been received.
304 *
305 * C - Area that needs to be prepared for the copying of sent messages, by
306 * the clearing of the message flags of any previously received messages.
307 *
308 * D - Area into which sent messages are to be copied from the remote
309 * partition's local_msgqueue and then delivered to their intended
310 * recipients. [ To allow for a multi-message copy, another pointer
311 * (next_msg_to_pull) has been added to keep track of the next message
312 * number needing to be copied (pulled). It chases after w_remote_GP.put.
313 * Any messages lying between w_local_GP.get and next_msg_to_pull have
314 * been copied and are ready to be delivered. ]
315 *
316 * E - Messages that have been copied and delivered, but have not yet been
317 * acknowledged by the recipient as having been received.
318 *
319 * F - Messages that have been acknowledged, but XPC has not yet notified the
320 * sender that the message was received by its intended recipient.
321 * This is also an area that needs to be prepared for the allocating of
322 * new messages, by the clearing of the message flags of the acknowledged
323 * messages.
324 */
325struct xpc_channel {
326 partid_t partid; /* ID of remote partition connected */
327 spinlock_t lock; /* lock for updating this structure */
328 u32 flags; /* general flags */
329
330 enum xpc_retval reason; /* reason why channel is disconnect'g */
331 int reason_line; /* line# disconnect initiated from */
332
333 u16 number; /* channel # */
334
335 u16 msg_size; /* sizeof each msg entry */
336 u16 local_nentries; /* #of msg entries in local msg queue */
337 u16 remote_nentries; /* #of msg entries in remote msg queue*/
338
339 void *local_msgqueue_base; /* base address of kmalloc'd space */
340 struct xpc_msg *local_msgqueue; /* local message queue */
341 void *remote_msgqueue_base; /* base address of kmalloc'd space */
342 struct xpc_msg *remote_msgqueue;/* cached copy of remote partition's */
343 /* local message queue */
344 u64 remote_msgqueue_pa; /* phys addr of remote partition's */
345 /* local message queue */
346
347 atomic_t references; /* #of external references to queues */
348
349 atomic_t n_on_msg_allocate_wq; /* #on msg allocation wait queue */
350 wait_queue_head_t msg_allocate_wq; /* msg allocation wait queue */
351
352 /* queue of msg senders who want to be notified when msg received */
353
354 atomic_t n_to_notify; /* #of msg senders to notify */
355 struct xpc_notify *notify_queue;/* notify queue for messages sent */
356
357 xpc_channel_func func; /* user's channel function */
358 void *key; /* pointer to user's key */
359
360 struct semaphore msg_to_pull_sema; /* next msg to pull serialization */
361 struct semaphore teardown_sema; /* wait for teardown completion */
362
363 struct xpc_openclose_args *local_openclose_args; /* args passed on */
364 /* opening or closing of channel */
365
366 /* various flavors of local and remote Get/Put values */
367
368 struct xpc_gp *local_GP; /* local Get/Put values */
369 struct xpc_gp remote_GP; /* remote Get/Put values */
370 struct xpc_gp w_local_GP; /* working local Get/Put values */
371 struct xpc_gp w_remote_GP; /* working remote Get/Put values */
372 s64 next_msg_to_pull; /* Put value of next msg to pull */
373
374 /* kthread management related fields */
375
376// >>> rethink having kthreads_assigned_limit and kthreads_idle_limit; perhaps
377// >>> allow the assigned limit be unbounded and let the idle limit be dynamic
378// >>> dependent on activity over the last interval of time
379 atomic_t kthreads_assigned; /* #of kthreads assigned to channel */
380 u32 kthreads_assigned_limit; /* limit on #of kthreads assigned */
381 atomic_t kthreads_idle; /* #of kthreads idle waiting for work */
382 u32 kthreads_idle_limit; /* limit on #of kthreads idle */
383 atomic_t kthreads_active; /* #of kthreads actively working */
384 // >>> following field is temporary
385 u32 kthreads_created; /* total #of kthreads created */
386
387 wait_queue_head_t idle_wq; /* idle kthread wait queue */
388
389} ____cacheline_aligned;
390
391
392/* struct xpc_channel flags */
393
394#define XPC_C_WASCONNECTED 0x00000001 /* channel was connected */
395
396#define XPC_C_ROPENREPLY 0x00000002 /* remote open channel reply */
397#define XPC_C_OPENREPLY 0x00000004 /* local open channel reply */
398#define XPC_C_ROPENREQUEST 0x00000008 /* remote open channel request */
399#define XPC_C_OPENREQUEST 0x00000010 /* local open channel request */
400
401#define XPC_C_SETUP 0x00000020 /* channel's msgqueues are alloc'd */
402#define XPC_C_CONNECTCALLOUT 0x00000040 /* channel connected callout made */
403#define XPC_C_CONNECTED 0x00000080 /* local channel is connected */
404#define XPC_C_CONNECTING 0x00000100 /* channel is being connected */
405
406#define XPC_C_RCLOSEREPLY 0x00000200 /* remote close channel reply */
407#define XPC_C_CLOSEREPLY 0x00000400 /* local close channel reply */
408#define XPC_C_RCLOSEREQUEST 0x00000800 /* remote close channel request */
409#define XPC_C_CLOSEREQUEST 0x00001000 /* local close channel request */
410
411#define XPC_C_DISCONNECTED 0x00002000 /* channel is disconnected */
412#define XPC_C_DISCONNECTING 0x00004000 /* channel is being disconnected */
413
414
415
416/*
417 * Manages channels on a partition basis. There is one of these structures
418 * for each partition (a partition will never utilize the structure that
419 * represents itself).
420 */
421struct xpc_partition {
422
423 /* XPC HB infrastructure */
424
425 u64 remote_rp_pa; /* phys addr of partition's rsvd pg */
426 u64 remote_vars_pa; /* phys addr of partition's vars */
427 u64 remote_vars_part_pa; /* phys addr of partition's vars part */
428 u64 last_heartbeat; /* HB at last read */
429 u64 remote_amos_page_pa; /* phys addr of partition's amos page */
430 int remote_act_nasid; /* active part's act/deact nasid */
431 int remote_act_phys_cpuid; /* active part's act/deact phys cpuid */
432 u32 act_IRQ_rcvd; /* IRQs since activation */
433 spinlock_t act_lock; /* protect updating of act_state */
434 u8 act_state; /* from XPC HB viewpoint */
435 enum xpc_retval reason; /* reason partition is deactivating */
436 int reason_line; /* line# deactivation initiated from */
437 int reactivate_nasid; /* nasid in partition to reactivate */
438
439
440 /* XPC infrastructure referencing and teardown control */
441
442 u8 setup_state; /* infrastructure setup state */
443 wait_queue_head_t teardown_wq; /* kthread waiting to teardown infra */
444 atomic_t references; /* #of references to infrastructure */
445
446
447 /*
448 * NONE OF THE PRECEDING FIELDS OF THIS STRUCTURE WILL BE CLEARED WHEN
449 * XPC SETS UP THE NECESSARY INFRASTRUCTURE TO SUPPORT CROSS PARTITION
450 * COMMUNICATION. ALL OF THE FOLLOWING FIELDS WILL BE CLEARED. (THE
451 * 'nchannels' FIELD MUST BE THE FIRST OF THE FIELDS TO BE CLEARED.)
452 */
453
454
455 u8 nchannels; /* #of defined channels supported */
456 atomic_t nchannels_active; /* #of channels that are not DISCONNECTED */
457 struct xpc_channel *channels;/* array of channel structures */
458
459 void *local_GPs_base; /* base address of kmalloc'd space */
460 struct xpc_gp *local_GPs; /* local Get/Put values */
461 void *remote_GPs_base; /* base address of kmalloc'd space */
462 struct xpc_gp *remote_GPs;/* copy of remote partition's local Get/Put */
463 /* values */
464 u64 remote_GPs_pa; /* phys address of remote partition's local */
465 /* Get/Put values */
466
467
468 /* fields used to pass args when opening or closing a channel */
469
470 void *local_openclose_args_base; /* base address of kmalloc'd space */
471 struct xpc_openclose_args *local_openclose_args; /* local's args */
472 void *remote_openclose_args_base; /* base address of kmalloc'd space */
473 struct xpc_openclose_args *remote_openclose_args; /* copy of remote's */
474 /* args */
475 u64 remote_openclose_args_pa; /* phys addr of remote's args */
476
477
478 /* IPI sending, receiving and handling related fields */
479
480 int remote_IPI_nasid; /* nasid of where to send IPIs */
481 int remote_IPI_phys_cpuid; /* phys CPU ID of where to send IPIs */
482 AMO_t *remote_IPI_amo_va; /* address of remote IPI AMO_t structure */
483
484 AMO_t *local_IPI_amo_va; /* address of IPI AMO_t structure */
485 u64 local_IPI_amo; /* IPI amo flags yet to be handled */
486 char IPI_owner[8]; /* IPI owner's name */
487 struct timer_list dropped_IPI_timer; /* dropped IPI timer */
488
489 spinlock_t IPI_lock; /* IPI handler lock */
490
491
492 /* channel manager related fields */
493
494 atomic_t channel_mgr_requests; /* #of requests to activate chan mgr */
495 wait_queue_head_t channel_mgr_wq; /* channel mgr's wait queue */
496
497} ____cacheline_aligned;
498
499
500/* struct xpc_partition act_state values (for XPC HB) */
501
502#define XPC_P_INACTIVE 0x00 /* partition is not active */
503#define XPC_P_ACTIVATION_REQ 0x01 /* created thread to activate */
504#define XPC_P_ACTIVATING 0x02 /* activation thread started */
505#define XPC_P_ACTIVE 0x03 /* xpc_partition_up() was called */
506#define XPC_P_DEACTIVATING 0x04 /* partition deactivation initiated */
507
508
509#define XPC_DEACTIVATE_PARTITION(_p, _reason) \
510 xpc_deactivate_partition(__LINE__, (_p), (_reason))
511
512
513/* struct xpc_partition setup_state values */
514
515#define XPC_P_UNSET 0x00 /* infrastructure was never setup */
516#define XPC_P_SETUP 0x01 /* infrastructure is setup */
517#define XPC_P_WTEARDOWN 0x02 /* waiting to teardown infrastructure */
518#define XPC_P_TORNDOWN 0x03 /* infrastructure is torndown */
519
520
521/*
522 * struct xpc_partition IPI_timer #of seconds to wait before checking for
523 * dropped IPIs. These occur whenever an IPI amo write doesn't complete until
524 * after the IPI was received.
525 */
526#define XPC_P_DROPPED_IPI_WAIT (0.25 * HZ)
527
528
529#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0]))
530
531
532
533/* found in xp_main.c */
534extern struct xpc_registration xpc_registrations[];
535
536
537/* >>> found in xpc_main.c only */
538extern struct device *xpc_part;
539extern struct device *xpc_chan;
540extern irqreturn_t xpc_notify_IRQ_handler(int, void *, struct pt_regs *);
541extern void xpc_dropped_IPI_check(struct xpc_partition *);
542extern void xpc_activate_kthreads(struct xpc_channel *, int);
543extern void xpc_create_kthreads(struct xpc_channel *, int);
544extern void xpc_disconnect_wait(int);
545
546
547/* found in xpc_main.c and efi-xpc.c */
548extern void xpc_activate_partition(struct xpc_partition *);
549
550
551/* found in xpc_partition.c */
552extern int xpc_exiting;
553extern int xpc_hb_interval;
554extern int xpc_hb_check_interval;
555extern struct xpc_vars *xpc_vars;
556extern struct xpc_rsvd_page *xpc_rsvd_page;
557extern struct xpc_vars_part *xpc_vars_part;
558extern struct xpc_partition xpc_partitions[XP_MAX_PARTITIONS + 1];
559extern char xpc_remote_copy_buffer[];
560extern struct xpc_rsvd_page *xpc_rsvd_page_init(void);
561extern void xpc_allow_IPI_ops(void);
562extern void xpc_restrict_IPI_ops(void);
563extern int xpc_identify_act_IRQ_sender(void);
564extern enum xpc_retval xpc_mark_partition_active(struct xpc_partition *);
565extern void xpc_mark_partition_inactive(struct xpc_partition *);
566extern void xpc_discovery(void);
567extern void xpc_check_remote_hb(void);
568extern void xpc_deactivate_partition(const int, struct xpc_partition *,
569 enum xpc_retval);
570extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *);
571
572
573/* found in xpc_channel.c */
574extern void xpc_initiate_connect(int);
575extern void xpc_initiate_disconnect(int);
576extern enum xpc_retval xpc_initiate_allocate(partid_t, int, u32, void **);
577extern enum xpc_retval xpc_initiate_send(partid_t, int, void *);
578extern enum xpc_retval xpc_initiate_send_notify(partid_t, int, void *,
579 xpc_notify_func, void *);
580extern void xpc_initiate_received(partid_t, int, void *);
581extern enum xpc_retval xpc_setup_infrastructure(struct xpc_partition *);
582extern enum xpc_retval xpc_pull_remote_vars_part(struct xpc_partition *);
583extern void xpc_process_channel_activity(struct xpc_partition *);
584extern void xpc_connected_callout(struct xpc_channel *);
585extern void xpc_deliver_msg(struct xpc_channel *);
586extern void xpc_disconnect_channel(const int, struct xpc_channel *,
587 enum xpc_retval, unsigned long *);
588extern void xpc_disconnected_callout(struct xpc_channel *);
589extern void xpc_partition_down(struct xpc_partition *, enum xpc_retval);
590extern void xpc_teardown_infrastructure(struct xpc_partition *);
591
592
593
594static inline void
595xpc_wakeup_channel_mgr(struct xpc_partition *part)
596{
597 if (atomic_inc_return(&part->channel_mgr_requests) == 1) {
598 wake_up(&part->channel_mgr_wq);
599 }
600}
601
602
603
604/*
605 * These next two inlines are used to keep us from tearing down a channel's
606 * msg queues while a thread may be referencing them.
607 */
608static inline void
609xpc_msgqueue_ref(struct xpc_channel *ch)
610{
611 atomic_inc(&ch->references);
612}
613
614static inline void
615xpc_msgqueue_deref(struct xpc_channel *ch)
616{
617 s32 refs = atomic_dec_return(&ch->references);
618
619 DBUG_ON(refs < 0);
620 if (refs == 0) {
621 xpc_wakeup_channel_mgr(&xpc_partitions[ch->partid]);
622 }
623}
624
625
626
627#define XPC_DISCONNECT_CHANNEL(_ch, _reason, _irqflgs) \
628 xpc_disconnect_channel(__LINE__, _ch, _reason, _irqflgs)
629
630
631/*
632 * These two inlines are used to keep us from tearing down a partition's
633 * setup infrastructure while a thread may be referencing it.
634 */
635static inline void
636xpc_part_deref(struct xpc_partition *part)
637{
638 s32 refs = atomic_dec_return(&part->references);
639
640
641 DBUG_ON(refs < 0);
642 if (refs == 0 && part->setup_state == XPC_P_WTEARDOWN) {
643 wake_up(&part->teardown_wq);
644 }
645}
646
647static inline int
648xpc_part_ref(struct xpc_partition *part)
649{
650 int setup;
651
652
653 atomic_inc(&part->references);
654 setup = (part->setup_state == XPC_P_SETUP);
655 if (!setup) {
656 xpc_part_deref(part);
657 }
658 return setup;
659}
660
661
662
663/*
664 * The following macro is to be used for the setting of the reason and
665 * reason_line fields in both the struct xpc_channel and struct xpc_partition
666 * structures.
667 */
668#define XPC_SET_REASON(_p, _reason, _line) \
669 { \
670 (_p)->reason = _reason; \
671 (_p)->reason_line = _line; \
672 }
673
674
675
676/*
677 * The following set of macros and inlines are used for the sending and
678 * receiving of IPIs (also known as IRQs). There are two flavors of IPIs,
679 * one that is associated with partition activity (SGI_XPC_ACTIVATE) and
680 * the other that is associated with channel activity (SGI_XPC_NOTIFY).
681 */
682
683static inline u64
684xpc_IPI_receive(AMO_t *amo)
685{
686 return FETCHOP_LOAD_OP(TO_AMO((u64) &amo->variable), FETCHOP_CLEAR);
687}
688
689
690static inline enum xpc_retval
691xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
692{
693 int ret = 0;
694 unsigned long irq_flags;
695
696
697 local_irq_save(irq_flags);
698
699 FETCHOP_STORE_OP(TO_AMO((u64) &amo->variable), FETCHOP_OR, flag);
700 sn_send_IPI_phys(nasid, phys_cpuid, vector, 0);
701
702 /*
703 * We must always use the nofault function regardless of whether we
704 * are on a Shub 1.1 system or a Shub 1.2 slice 0xc processor. If we
705 * didn't, we'd never know that the other partition is down and would
706 * keep sending IPIs and AMOs to it until the heartbeat times out.
707 */
708 ret = xp_nofault_PIOR((u64 *) GLOBAL_MMR_ADDR(NASID_GET(&amo->variable),
709 xp_nofault_PIOR_target));
710
711 local_irq_restore(irq_flags);
712
713 return ((ret == 0) ? xpcSuccess : xpcPioReadError);
714}
715
716
717/*
718 * IPIs associated with SGI_XPC_ACTIVATE IRQ.
719 */
720
721/*
722 * Flag the appropriate AMO variable and send an IPI to the specified node.
723 */
724static inline void
725xpc_activate_IRQ_send(u64 amos_page, int from_nasid, int to_nasid,
726 int to_phys_cpuid)
727{
728 int w_index = XPC_NASID_W_INDEX(from_nasid);
729 int b_index = XPC_NASID_B_INDEX(from_nasid);
730 AMO_t *amos = (AMO_t *) __va(amos_page +
731 (XP_MAX_PARTITIONS * sizeof(AMO_t)));
732
733
734 (void) xpc_IPI_send(&amos[w_index], (1UL << b_index), to_nasid,
735 to_phys_cpuid, SGI_XPC_ACTIVATE);
736}
737
738static inline void
739xpc_IPI_send_activate(struct xpc_vars *vars)
740{
741 xpc_activate_IRQ_send(vars->amos_page_pa, cnodeid_to_nasid(0),
742 vars->act_nasid, vars->act_phys_cpuid);
743}
744
745static inline void
746xpc_IPI_send_activated(struct xpc_partition *part)
747{
748 xpc_activate_IRQ_send(part->remote_amos_page_pa, cnodeid_to_nasid(0),
749 part->remote_act_nasid, part->remote_act_phys_cpuid);
750}
751
752static inline void
753xpc_IPI_send_reactivate(struct xpc_partition *part)
754{
755 xpc_activate_IRQ_send(xpc_vars->amos_page_pa, part->reactivate_nasid,
756 xpc_vars->act_nasid, xpc_vars->act_phys_cpuid);
757}
758
759
760/*
761 * IPIs associated with SGI_XPC_NOTIFY IRQ.
762 */
763
764/*
765 * Send an IPI to the remote partition that is associated with the
766 * specified channel.
767 */
768#define XPC_NOTIFY_IRQ_SEND(_ch, _ipi_f, _irq_f) \
769 xpc_notify_IRQ_send(_ch, _ipi_f, #_ipi_f, _irq_f)
770
771static inline void
772xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
773 unsigned long *irq_flags)
774{
775 struct xpc_partition *part = &xpc_partitions[ch->partid];
776 enum xpc_retval ret;
777
778
779 if (likely(part->act_state != XPC_P_DEACTIVATING)) {
780 ret = xpc_IPI_send(part->remote_IPI_amo_va,
781 (u64) ipi_flag << (ch->number * 8),
782 part->remote_IPI_nasid,
783 part->remote_IPI_phys_cpuid,
784 SGI_XPC_NOTIFY);
785 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n",
786 ipi_flag_string, ch->partid, ch->number, ret);
787 if (unlikely(ret != xpcSuccess)) {
788 if (irq_flags != NULL) {
789 spin_unlock_irqrestore(&ch->lock, *irq_flags);
790 }
791 XPC_DEACTIVATE_PARTITION(part, ret);
792 if (irq_flags != NULL) {
793 spin_lock_irqsave(&ch->lock, *irq_flags);
794 }
795 }
796 }
797}
798
799
800/*
801 * Make it look like the remote partition, which is associated with the
802 * specified channel, sent us an IPI. This faked IPI will be handled
803 * by xpc_dropped_IPI_check().
804 */
805#define XPC_NOTIFY_IRQ_SEND_LOCAL(_ch, _ipi_f) \
806 xpc_notify_IRQ_send_local(_ch, _ipi_f, #_ipi_f)
807
808static inline void
809xpc_notify_IRQ_send_local(struct xpc_channel *ch, u8 ipi_flag,
810 char *ipi_flag_string)
811{
812 struct xpc_partition *part = &xpc_partitions[ch->partid];
813
814
815 FETCHOP_STORE_OP(TO_AMO((u64) &part->local_IPI_amo_va->variable),
816 FETCHOP_OR, ((u64) ipi_flag << (ch->number * 8)));
817 dev_dbg(xpc_chan, "%s sent local from partid=%d, channel=%d\n",
818 ipi_flag_string, ch->partid, ch->number);
819}
820
821
822/*
823 * The sending and receiving of IPIs includes the setting of an AMO variable
824 * to indicate the reason the IPI was sent. The 64-bit variable is divided
825 * up into eight bytes, ordered from right to left. Byte zero pertains to
826 * channel 0, byte one to channel 1, and so on. Each byte is described by
827 * the following IPI flags.
828 */
829
830#define XPC_IPI_CLOSEREQUEST 0x01
831#define XPC_IPI_CLOSEREPLY 0x02
832#define XPC_IPI_OPENREQUEST 0x04
833#define XPC_IPI_OPENREPLY 0x08
834#define XPC_IPI_MSGREQUEST 0x10
835
836
837/* given an AMO variable and a channel#, get its associated IPI flags */
838#define XPC_GET_IPI_FLAGS(_amo, _c) ((u8) (((_amo) >> ((_c) * 8)) & 0xff))
839
840#define XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(_amo) ((_amo) & 0x0f0f0f0f0f0f0f0f)
841#define XPC_ANY_MSG_IPI_FLAGS_SET(_amo) ((_amo) & 0x1010101010101010)
842
843
844static inline void
845xpc_IPI_send_closerequest(struct xpc_channel *ch, unsigned long *irq_flags)
846{
847 struct xpc_openclose_args *args = ch->local_openclose_args;
848
849
850 args->reason = ch->reason;
851
852 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_CLOSEREQUEST, irq_flags);
853}
854
855static inline void
856xpc_IPI_send_closereply(struct xpc_channel *ch, unsigned long *irq_flags)
857{
858 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_CLOSEREPLY, irq_flags);
859}
860
861static inline void
862xpc_IPI_send_openrequest(struct xpc_channel *ch, unsigned long *irq_flags)
863{
864 struct xpc_openclose_args *args = ch->local_openclose_args;
865
866
867 args->msg_size = ch->msg_size;
868 args->local_nentries = ch->local_nentries;
869
870 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_OPENREQUEST, irq_flags);
871}
872
873static inline void
874xpc_IPI_send_openreply(struct xpc_channel *ch, unsigned long *irq_flags)
875{
876 struct xpc_openclose_args *args = ch->local_openclose_args;
877
878
879 args->remote_nentries = ch->remote_nentries;
880 args->local_nentries = ch->local_nentries;
881 args->local_msgqueue_pa = __pa(ch->local_msgqueue);
882
883 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_OPENREPLY, irq_flags);
884}
885
886static inline void
887xpc_IPI_send_msgrequest(struct xpc_channel *ch)
888{
889 XPC_NOTIFY_IRQ_SEND(ch, XPC_IPI_MSGREQUEST, NULL);
890}
891
892static inline void
893xpc_IPI_send_local_msgrequest(struct xpc_channel *ch)
894{
895 XPC_NOTIFY_IRQ_SEND_LOCAL(ch, XPC_IPI_MSGREQUEST);
896}
897
898
899/*
900 * Memory for XPC's AMO variables is allocated by the MSPEC driver. These
901 * pages are located in the lowest granule. The lowest granule uses 4k pages
902 * for cached references and an alternate TLB handler to never provide a
903 * cacheable mapping for the entire region. This will prevent speculative
904 * reading of cached copies of our lines from being issued which will cause
905 * a PI FSB Protocol error to be generated by the SHUB. For XPC, we need 64
906 * (XP_MAX_PARTITIONS) AMO variables for message notification (xpc_main.c)
907 * and an additional 16 AMO variables for partition activation (xpc_hb.c).
908 */
909static inline AMO_t *
910xpc_IPI_init(partid_t partid)
911{
912 AMO_t *part_amo = xpc_vars->amos_page + partid;
913
914
915 xpc_IPI_receive(part_amo);
916 return part_amo;
917}
918
919
920
921static inline enum xpc_retval
922xpc_map_bte_errors(bte_result_t error)
923{
924 switch (error) {
925 case BTE_SUCCESS: return xpcSuccess;
926 case BTEFAIL_DIR: return xpcBteDirectoryError;
927 case BTEFAIL_POISON: return xpcBtePoisonError;
928 case BTEFAIL_WERR: return xpcBteWriteError;
929 case BTEFAIL_ACCESS: return xpcBteAccessError;
930 case BTEFAIL_PWERR: return xpcBtePWriteError;
931 case BTEFAIL_PRERR: return xpcBtePReadError;
932 case BTEFAIL_TOUT: return xpcBteTimeOutError;
933 case BTEFAIL_XTERR: return xpcBteXtalkError;
934 case BTEFAIL_NOTAVAIL: return xpcBteNotAvailable;
935 default: return xpcBteUnmappedError;
936 }
937}
938
939
940
941static inline void *
942xpc_kmalloc_cacheline_aligned(size_t size, int flags, void **base)
943{
944 /* see if kmalloc will give us cachline aligned memory by default */
945 *base = kmalloc(size, flags);
946 if (*base == NULL) {
947 return NULL;
948 }
949 if ((u64) *base == L1_CACHE_ALIGN((u64) *base)) {
950 return *base;
951 }
952 kfree(*base);
953
954 /* nope, we'll have to do it ourselves */
955 *base = kmalloc(size + L1_CACHE_BYTES, flags);
956 if (*base == NULL) {
957 return NULL;
958 }
959 return (void *) L1_CACHE_ALIGN((u64) *base);
960}
961
962
963/*
964 * Check to see if there is any channel activity to/from the specified
965 * partition.
966 */
967static inline void
968xpc_check_for_channel_activity(struct xpc_partition *part)
969{
970 u64 IPI_amo;
971 unsigned long irq_flags;
972
973
974 IPI_amo = xpc_IPI_receive(part->local_IPI_amo_va);
975 if (IPI_amo == 0) {
976 return;
977 }
978
979 spin_lock_irqsave(&part->IPI_lock, irq_flags);
980 part->local_IPI_amo |= IPI_amo;
981 spin_unlock_irqrestore(&part->IPI_lock, irq_flags);
982
983 dev_dbg(xpc_chan, "received IPI from partid=%d, IPI_amo=0x%lx\n",
984 XPC_PARTID(part), IPI_amo);
985
986 xpc_wakeup_channel_mgr(part);
987}
988
989
990#endif /* _IA64_SN_KERNEL_XPC_H */
991
diff --git a/arch/ia64/sn/kernel/xpc_channel.c b/arch/ia64/sn/kernel/xpc_channel.c
new file mode 100644
index 000000000000..0bf6fbcc46d2
--- /dev/null
+++ b/arch/ia64/sn/kernel/xpc_channel.c
@@ -0,0 +1,2297 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * Cross Partition Communication (XPC) channel support.
12 *
13 * This is the part of XPC that manages the channels and
14 * sends/receives messages across them to/from other partitions.
15 *
16 */
17
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/sched.h>
22#include <linux/cache.h>
23#include <linux/interrupt.h>
24#include <linux/slab.h>
25#include <asm/sn/bte.h>
26#include <asm/sn/sn_sal.h>
27#include "xpc.h"
28
29
30/*
31 * Set up the initial values for the XPartition Communication channels.
32 */
33static void
34xpc_initialize_channels(struct xpc_partition *part, partid_t partid)
35{
36 int ch_number;
37 struct xpc_channel *ch;
38
39
40 for (ch_number = 0; ch_number < part->nchannels; ch_number++) {
41 ch = &part->channels[ch_number];
42
43 ch->partid = partid;
44 ch->number = ch_number;
45 ch->flags = XPC_C_DISCONNECTED;
46
47 ch->local_GP = &part->local_GPs[ch_number];
48 ch->local_openclose_args =
49 &part->local_openclose_args[ch_number];
50
51 atomic_set(&ch->kthreads_assigned, 0);
52 atomic_set(&ch->kthreads_idle, 0);
53 atomic_set(&ch->kthreads_active, 0);
54
55 atomic_set(&ch->references, 0);
56 atomic_set(&ch->n_to_notify, 0);
57
58 spin_lock_init(&ch->lock);
59 sema_init(&ch->msg_to_pull_sema, 1); /* mutex */
60
61 atomic_set(&ch->n_on_msg_allocate_wq, 0);
62 init_waitqueue_head(&ch->msg_allocate_wq);
63 init_waitqueue_head(&ch->idle_wq);
64 }
65}
66
67
68/*
69 * Setup the infrastructure necessary to support XPartition Communication
70 * between the specified remote partition and the local one.
71 */
72enum xpc_retval
73xpc_setup_infrastructure(struct xpc_partition *part)
74{
75 int ret;
76 struct timer_list *timer;
77 partid_t partid = XPC_PARTID(part);
78
79
80 /*
81 * Zero out MOST of the entry for this partition. Only the fields
82 * starting with `nchannels' will be zeroed. The preceding fields must
83 * remain `viable' across partition ups and downs, since they may be
84 * referenced during this memset() operation.
85 */
86 memset(&part->nchannels, 0, sizeof(struct xpc_partition) -
87 offsetof(struct xpc_partition, nchannels));
88
89 /*
90 * Allocate all of the channel structures as a contiguous chunk of
91 * memory.
92 */
93 part->channels = kmalloc(sizeof(struct xpc_channel) * XPC_NCHANNELS,
94 GFP_KERNEL);
95 if (part->channels == NULL) {
96 dev_err(xpc_chan, "can't get memory for channels\n");
97 return xpcNoMemory;
98 }
99 memset(part->channels, 0, sizeof(struct xpc_channel) * XPC_NCHANNELS);
100
101 part->nchannels = XPC_NCHANNELS;
102
103
104 /* allocate all the required GET/PUT values */
105
106 part->local_GPs = xpc_kmalloc_cacheline_aligned(XPC_GP_SIZE,
107 GFP_KERNEL, &part->local_GPs_base);
108 if (part->local_GPs == NULL) {
109 kfree(part->channels);
110 part->channels = NULL;
111 dev_err(xpc_chan, "can't get memory for local get/put "
112 "values\n");
113 return xpcNoMemory;
114 }
115 memset(part->local_GPs, 0, XPC_GP_SIZE);
116
117 part->remote_GPs = xpc_kmalloc_cacheline_aligned(XPC_GP_SIZE,
118 GFP_KERNEL, &part->remote_GPs_base);
119 if (part->remote_GPs == NULL) {
120 kfree(part->channels);
121 part->channels = NULL;
122 kfree(part->local_GPs_base);
123 part->local_GPs = NULL;
124 dev_err(xpc_chan, "can't get memory for remote get/put "
125 "values\n");
126 return xpcNoMemory;
127 }
128 memset(part->remote_GPs, 0, XPC_GP_SIZE);
129
130
131 /* allocate all the required open and close args */
132
133 part->local_openclose_args = xpc_kmalloc_cacheline_aligned(
134 XPC_OPENCLOSE_ARGS_SIZE, GFP_KERNEL,
135 &part->local_openclose_args_base);
136 if (part->local_openclose_args == NULL) {
137 kfree(part->channels);
138 part->channels = NULL;
139 kfree(part->local_GPs_base);
140 part->local_GPs = NULL;
141 kfree(part->remote_GPs_base);
142 part->remote_GPs = NULL;
143 dev_err(xpc_chan, "can't get memory for local connect args\n");
144 return xpcNoMemory;
145 }
146 memset(part->local_openclose_args, 0, XPC_OPENCLOSE_ARGS_SIZE);
147
148 part->remote_openclose_args = xpc_kmalloc_cacheline_aligned(
149 XPC_OPENCLOSE_ARGS_SIZE, GFP_KERNEL,
150 &part->remote_openclose_args_base);
151 if (part->remote_openclose_args == NULL) {
152 kfree(part->channels);
153 part->channels = NULL;
154 kfree(part->local_GPs_base);
155 part->local_GPs = NULL;
156 kfree(part->remote_GPs_base);
157 part->remote_GPs = NULL;
158 kfree(part->local_openclose_args_base);
159 part->local_openclose_args = NULL;
160 dev_err(xpc_chan, "can't get memory for remote connect args\n");
161 return xpcNoMemory;
162 }
163 memset(part->remote_openclose_args, 0, XPC_OPENCLOSE_ARGS_SIZE);
164
165
166 xpc_initialize_channels(part, partid);
167
168 atomic_set(&part->nchannels_active, 0);
169
170
171 /* local_IPI_amo were set to 0 by an earlier memset() */
172
173 /* Initialize this partitions AMO_t structure */
174 part->local_IPI_amo_va = xpc_IPI_init(partid);
175
176 spin_lock_init(&part->IPI_lock);
177
178 atomic_set(&part->channel_mgr_requests, 1);
179 init_waitqueue_head(&part->channel_mgr_wq);
180
181 sprintf(part->IPI_owner, "xpc%02d", partid);
182 ret = request_irq(SGI_XPC_NOTIFY, xpc_notify_IRQ_handler, SA_SHIRQ,
183 part->IPI_owner, (void *) (u64) partid);
184 if (ret != 0) {
185 kfree(part->channels);
186 part->channels = NULL;
187 kfree(part->local_GPs_base);
188 part->local_GPs = NULL;
189 kfree(part->remote_GPs_base);
190 part->remote_GPs = NULL;
191 kfree(part->local_openclose_args_base);
192 part->local_openclose_args = NULL;
193 kfree(part->remote_openclose_args_base);
194 part->remote_openclose_args = NULL;
195 dev_err(xpc_chan, "can't register NOTIFY IRQ handler, "
196 "errno=%d\n", -ret);
197 return xpcLackOfResources;
198 }
199
200 /* Setup a timer to check for dropped IPIs */
201 timer = &part->dropped_IPI_timer;
202 init_timer(timer);
203 timer->function = (void (*)(unsigned long)) xpc_dropped_IPI_check;
204 timer->data = (unsigned long) part;
205 timer->expires = jiffies + XPC_P_DROPPED_IPI_WAIT;
206 add_timer(timer);
207
208 /*
209 * With the setting of the partition setup_state to XPC_P_SETUP, we're
210 * declaring that this partition is ready to go.
211 */
212 (volatile u8) part->setup_state = XPC_P_SETUP;
213
214
215 /*
216 * Setup the per partition specific variables required by the
217 * remote partition to establish channel connections with us.
218 *
219 * The setting of the magic # indicates that these per partition
220 * specific variables are ready to be used.
221 */
222 xpc_vars_part[partid].GPs_pa = __pa(part->local_GPs);
223 xpc_vars_part[partid].openclose_args_pa =
224 __pa(part->local_openclose_args);
225 xpc_vars_part[partid].IPI_amo_pa = __pa(part->local_IPI_amo_va);
226 xpc_vars_part[partid].IPI_nasid = cpuid_to_nasid(smp_processor_id());
227 xpc_vars_part[partid].IPI_phys_cpuid =
228 cpu_physical_id(smp_processor_id());
229 xpc_vars_part[partid].nchannels = part->nchannels;
230 (volatile u64) xpc_vars_part[partid].magic = XPC_VP_MAGIC1;
231
232 return xpcSuccess;
233}
234
235
236/*
237 * Create a wrapper that hides the underlying mechanism for pulling a cacheline
238 * (or multiple cachelines) from a remote partition.
239 *
240 * src must be a cacheline aligned physical address on the remote partition.
241 * dst must be a cacheline aligned virtual address on this partition.
242 * cnt must be an cacheline sized
243 */
244static enum xpc_retval
245xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
246 const void *src, size_t cnt)
247{
248 bte_result_t bte_ret;
249
250
251 DBUG_ON((u64) src != L1_CACHE_ALIGN((u64) src));
252 DBUG_ON((u64) dst != L1_CACHE_ALIGN((u64) dst));
253 DBUG_ON(cnt != L1_CACHE_ALIGN(cnt));
254
255 if (part->act_state == XPC_P_DEACTIVATING) {
256 return part->reason;
257 }
258
259 bte_ret = xp_bte_copy((u64) src, (u64) ia64_tpa((u64) dst),
260 (u64) cnt, (BTE_NORMAL | BTE_WACQUIRE), NULL);
261 if (bte_ret == BTE_SUCCESS) {
262 return xpcSuccess;
263 }
264
265 dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n",
266 XPC_PARTID(part), bte_ret);
267
268 return xpc_map_bte_errors(bte_ret);
269}
270
271
272/*
273 * Pull the remote per partititon specific variables from the specified
274 * partition.
275 */
276enum xpc_retval
277xpc_pull_remote_vars_part(struct xpc_partition *part)
278{
279 u8 buffer[L1_CACHE_BYTES * 2];
280 struct xpc_vars_part *pulled_entry_cacheline =
281 (struct xpc_vars_part *) L1_CACHE_ALIGN((u64) buffer);
282 struct xpc_vars_part *pulled_entry;
283 u64 remote_entry_cacheline_pa, remote_entry_pa;
284 partid_t partid = XPC_PARTID(part);
285 enum xpc_retval ret;
286
287
288 /* pull the cacheline that contains the variables we're interested in */
289
290 DBUG_ON(part->remote_vars_part_pa !=
291 L1_CACHE_ALIGN(part->remote_vars_part_pa));
292 DBUG_ON(sizeof(struct xpc_vars_part) != L1_CACHE_BYTES / 2);
293
294 remote_entry_pa = part->remote_vars_part_pa +
295 sn_partition_id * sizeof(struct xpc_vars_part);
296
297 remote_entry_cacheline_pa = (remote_entry_pa & ~(L1_CACHE_BYTES - 1));
298
299 pulled_entry = (struct xpc_vars_part *) ((u64) pulled_entry_cacheline +
300 (remote_entry_pa & (L1_CACHE_BYTES - 1)));
301
302 ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline,
303 (void *) remote_entry_cacheline_pa,
304 L1_CACHE_BYTES);
305 if (ret != xpcSuccess) {
306 dev_dbg(xpc_chan, "failed to pull XPC vars_part from "
307 "partition %d, ret=%d\n", partid, ret);
308 return ret;
309 }
310
311
312 /* see if they've been set up yet */
313
314 if (pulled_entry->magic != XPC_VP_MAGIC1 &&
315 pulled_entry->magic != XPC_VP_MAGIC2) {
316
317 if (pulled_entry->magic != 0) {
318 dev_dbg(xpc_chan, "partition %d's XPC vars_part for "
319 "partition %d has bad magic value (=0x%lx)\n",
320 partid, sn_partition_id, pulled_entry->magic);
321 return xpcBadMagic;
322 }
323
324 /* they've not been initialized yet */
325 return xpcRetry;
326 }
327
328 if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) {
329
330 /* validate the variables */
331
332 if (pulled_entry->GPs_pa == 0 ||
333 pulled_entry->openclose_args_pa == 0 ||
334 pulled_entry->IPI_amo_pa == 0) {
335
336 dev_err(xpc_chan, "partition %d's XPC vars_part for "
337 "partition %d are not valid\n", partid,
338 sn_partition_id);
339 return xpcInvalidAddress;
340 }
341
342 /* the variables we imported look to be valid */
343
344 part->remote_GPs_pa = pulled_entry->GPs_pa;
345 part->remote_openclose_args_pa =
346 pulled_entry->openclose_args_pa;
347 part->remote_IPI_amo_va =
348 (AMO_t *) __va(pulled_entry->IPI_amo_pa);
349 part->remote_IPI_nasid = pulled_entry->IPI_nasid;
350 part->remote_IPI_phys_cpuid = pulled_entry->IPI_phys_cpuid;
351
352 if (part->nchannels > pulled_entry->nchannels) {
353 part->nchannels = pulled_entry->nchannels;
354 }
355
356 /* let the other side know that we've pulled their variables */
357
358 (volatile u64) xpc_vars_part[partid].magic = XPC_VP_MAGIC2;
359 }
360
361 if (pulled_entry->magic == XPC_VP_MAGIC1) {
362 return xpcRetry;
363 }
364
365 return xpcSuccess;
366}
367
368
369/*
370 * Get the IPI flags and pull the openclose args and/or remote GPs as needed.
371 */
372static u64
373xpc_get_IPI_flags(struct xpc_partition *part)
374{
375 unsigned long irq_flags;
376 u64 IPI_amo;
377 enum xpc_retval ret;
378
379
380 /*
381 * See if there are any IPI flags to be handled.
382 */
383
384 spin_lock_irqsave(&part->IPI_lock, irq_flags);
385 if ((IPI_amo = part->local_IPI_amo) != 0) {
386 part->local_IPI_amo = 0;
387 }
388 spin_unlock_irqrestore(&part->IPI_lock, irq_flags);
389
390
391 if (XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(IPI_amo)) {
392 ret = xpc_pull_remote_cachelines(part,
393 part->remote_openclose_args,
394 (void *) part->remote_openclose_args_pa,
395 XPC_OPENCLOSE_ARGS_SIZE);
396 if (ret != xpcSuccess) {
397 XPC_DEACTIVATE_PARTITION(part, ret);
398
399 dev_dbg(xpc_chan, "failed to pull openclose args from "
400 "partition %d, ret=%d\n", XPC_PARTID(part),
401 ret);
402
403 /* don't bother processing IPIs anymore */
404 IPI_amo = 0;
405 }
406 }
407
408 if (XPC_ANY_MSG_IPI_FLAGS_SET(IPI_amo)) {
409 ret = xpc_pull_remote_cachelines(part, part->remote_GPs,
410 (void *) part->remote_GPs_pa,
411 XPC_GP_SIZE);
412 if (ret != xpcSuccess) {
413 XPC_DEACTIVATE_PARTITION(part, ret);
414
415 dev_dbg(xpc_chan, "failed to pull GPs from partition "
416 "%d, ret=%d\n", XPC_PARTID(part), ret);
417
418 /* don't bother processing IPIs anymore */
419 IPI_amo = 0;
420 }
421 }
422
423 return IPI_amo;
424}
425
426
427/*
428 * Allocate the local message queue and the notify queue.
429 */
430static enum xpc_retval
431xpc_allocate_local_msgqueue(struct xpc_channel *ch)
432{
433 unsigned long irq_flags;
434 int nentries;
435 size_t nbytes;
436
437
438 // >>> may want to check for ch->flags & XPC_C_DISCONNECTING between
439 // >>> iterations of the for-loop, bail if set?
440
441 // >>> should we impose a minumum #of entries? like 4 or 8?
442 for (nentries = ch->local_nentries; nentries > 0; nentries--) {
443
444 nbytes = nentries * ch->msg_size;
445 ch->local_msgqueue = xpc_kmalloc_cacheline_aligned(nbytes,
446 (GFP_KERNEL | GFP_DMA),
447 &ch->local_msgqueue_base);
448 if (ch->local_msgqueue == NULL) {
449 continue;
450 }
451 memset(ch->local_msgqueue, 0, nbytes);
452
453 nbytes = nentries * sizeof(struct xpc_notify);
454 ch->notify_queue = kmalloc(nbytes, (GFP_KERNEL | GFP_DMA));
455 if (ch->notify_queue == NULL) {
456 kfree(ch->local_msgqueue_base);
457 ch->local_msgqueue = NULL;
458 continue;
459 }
460 memset(ch->notify_queue, 0, nbytes);
461
462 spin_lock_irqsave(&ch->lock, irq_flags);
463 if (nentries < ch->local_nentries) {
464 dev_dbg(xpc_chan, "nentries=%d local_nentries=%d, "
465 "partid=%d, channel=%d\n", nentries,
466 ch->local_nentries, ch->partid, ch->number);
467
468 ch->local_nentries = nentries;
469 }
470 spin_unlock_irqrestore(&ch->lock, irq_flags);
471 return xpcSuccess;
472 }
473
474 dev_dbg(xpc_chan, "can't get memory for local message queue and notify "
475 "queue, partid=%d, channel=%d\n", ch->partid, ch->number);
476 return xpcNoMemory;
477}
478
479
480/*
481 * Allocate the cached remote message queue.
482 */
483static enum xpc_retval
484xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
485{
486 unsigned long irq_flags;
487 int nentries;
488 size_t nbytes;
489
490
491 DBUG_ON(ch->remote_nentries <= 0);
492
493 // >>> may want to check for ch->flags & XPC_C_DISCONNECTING between
494 // >>> iterations of the for-loop, bail if set?
495
496 // >>> should we impose a minumum #of entries? like 4 or 8?
497 for (nentries = ch->remote_nentries; nentries > 0; nentries--) {
498
499 nbytes = nentries * ch->msg_size;
500 ch->remote_msgqueue = xpc_kmalloc_cacheline_aligned(nbytes,
501 (GFP_KERNEL | GFP_DMA),
502 &ch->remote_msgqueue_base);
503 if (ch->remote_msgqueue == NULL) {
504 continue;
505 }
506 memset(ch->remote_msgqueue, 0, nbytes);
507
508 spin_lock_irqsave(&ch->lock, irq_flags);
509 if (nentries < ch->remote_nentries) {
510 dev_dbg(xpc_chan, "nentries=%d remote_nentries=%d, "
511 "partid=%d, channel=%d\n", nentries,
512 ch->remote_nentries, ch->partid, ch->number);
513
514 ch->remote_nentries = nentries;
515 }
516 spin_unlock_irqrestore(&ch->lock, irq_flags);
517 return xpcSuccess;
518 }
519
520 dev_dbg(xpc_chan, "can't get memory for cached remote message queue, "
521 "partid=%d, channel=%d\n", ch->partid, ch->number);
522 return xpcNoMemory;
523}
524
525
526/*
527 * Allocate message queues and other stuff associated with a channel.
528 *
529 * Note: Assumes all of the channel sizes are filled in.
530 */
531static enum xpc_retval
532xpc_allocate_msgqueues(struct xpc_channel *ch)
533{
534 unsigned long irq_flags;
535 int i;
536 enum xpc_retval ret;
537
538
539 DBUG_ON(ch->flags & XPC_C_SETUP);
540
541 if ((ret = xpc_allocate_local_msgqueue(ch)) != xpcSuccess) {
542 return ret;
543 }
544
545 if ((ret = xpc_allocate_remote_msgqueue(ch)) != xpcSuccess) {
546 kfree(ch->local_msgqueue_base);
547 ch->local_msgqueue = NULL;
548 kfree(ch->notify_queue);
549 ch->notify_queue = NULL;
550 return ret;
551 }
552
553 for (i = 0; i < ch->local_nentries; i++) {
554 /* use a semaphore as an event wait queue */
555 sema_init(&ch->notify_queue[i].sema, 0);
556 }
557
558 sema_init(&ch->teardown_sema, 0); /* event wait */
559
560 spin_lock_irqsave(&ch->lock, irq_flags);
561 ch->flags |= XPC_C_SETUP;
562 spin_unlock_irqrestore(&ch->lock, irq_flags);
563
564 return xpcSuccess;
565}
566
567
568/*
569 * Process a connect message from a remote partition.
570 *
571 * Note: xpc_process_connect() is expecting to be called with the
572 * spin_lock_irqsave held and will leave it locked upon return.
573 */
574static void
575xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
576{
577 enum xpc_retval ret;
578
579
580 DBUG_ON(!spin_is_locked(&ch->lock));
581
582 if (!(ch->flags & XPC_C_OPENREQUEST) ||
583 !(ch->flags & XPC_C_ROPENREQUEST)) {
584 /* nothing more to do for now */
585 return;
586 }
587 DBUG_ON(!(ch->flags & XPC_C_CONNECTING));
588
589 if (!(ch->flags & XPC_C_SETUP)) {
590 spin_unlock_irqrestore(&ch->lock, *irq_flags);
591 ret = xpc_allocate_msgqueues(ch);
592 spin_lock_irqsave(&ch->lock, *irq_flags);
593
594 if (ret != xpcSuccess) {
595 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags);
596 }
597 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) {
598 return;
599 }
600
601 DBUG_ON(!(ch->flags & XPC_C_SETUP));
602 DBUG_ON(ch->local_msgqueue == NULL);
603 DBUG_ON(ch->remote_msgqueue == NULL);
604 }
605
606 if (!(ch->flags & XPC_C_OPENREPLY)) {
607 ch->flags |= XPC_C_OPENREPLY;
608 xpc_IPI_send_openreply(ch, irq_flags);
609 }
610
611 if (!(ch->flags & XPC_C_ROPENREPLY)) {
612 return;
613 }
614
615 DBUG_ON(ch->remote_msgqueue_pa == 0);
616
617 ch->flags = (XPC_C_CONNECTED | XPC_C_SETUP); /* clear all else */
618
619 dev_info(xpc_chan, "channel %d to partition %d connected\n",
620 ch->number, ch->partid);
621
622 spin_unlock_irqrestore(&ch->lock, *irq_flags);
623 xpc_create_kthreads(ch, 1);
624 spin_lock_irqsave(&ch->lock, *irq_flags);
625}
626
627
628/*
629 * Free up message queues and other stuff that were allocated for the specified
630 * channel.
631 *
632 * Note: ch->reason and ch->reason_line are left set for debugging purposes,
633 * they're cleared when XPC_C_DISCONNECTED is cleared.
634 */
635static void
636xpc_free_msgqueues(struct xpc_channel *ch)
637{
638 DBUG_ON(!spin_is_locked(&ch->lock));
639 DBUG_ON(atomic_read(&ch->n_to_notify) != 0);
640
641 ch->remote_msgqueue_pa = 0;
642 ch->func = NULL;
643 ch->key = NULL;
644 ch->msg_size = 0;
645 ch->local_nentries = 0;
646 ch->remote_nentries = 0;
647 ch->kthreads_assigned_limit = 0;
648 ch->kthreads_idle_limit = 0;
649
650 ch->local_GP->get = 0;
651 ch->local_GP->put = 0;
652 ch->remote_GP.get = 0;
653 ch->remote_GP.put = 0;
654 ch->w_local_GP.get = 0;
655 ch->w_local_GP.put = 0;
656 ch->w_remote_GP.get = 0;
657 ch->w_remote_GP.put = 0;
658 ch->next_msg_to_pull = 0;
659
660 if (ch->flags & XPC_C_SETUP) {
661 ch->flags &= ~XPC_C_SETUP;
662
663 dev_dbg(xpc_chan, "ch->flags=0x%x, partid=%d, channel=%d\n",
664 ch->flags, ch->partid, ch->number);
665
666 kfree(ch->local_msgqueue_base);
667 ch->local_msgqueue = NULL;
668 kfree(ch->remote_msgqueue_base);
669 ch->remote_msgqueue = NULL;
670 kfree(ch->notify_queue);
671 ch->notify_queue = NULL;
672
673 /* in case someone is waiting for the teardown to complete */
674 up(&ch->teardown_sema);
675 }
676}
677
678
679/*
680 * spin_lock_irqsave() is expected to be held on entry.
681 */
682static void
683xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
684{
685 struct xpc_partition *part = &xpc_partitions[ch->partid];
686 u32 ch_flags = ch->flags;
687
688
689 DBUG_ON(!spin_is_locked(&ch->lock));
690
691 if (!(ch->flags & XPC_C_DISCONNECTING)) {
692 return;
693 }
694
695 DBUG_ON(!(ch->flags & XPC_C_CLOSEREQUEST));
696
697 /* make sure all activity has settled down first */
698
699 if (atomic_read(&ch->references) > 0) {
700 return;
701 }
702 DBUG_ON(atomic_read(&ch->kthreads_assigned) != 0);
703
704 /* it's now safe to free the channel's message queues */
705
706 xpc_free_msgqueues(ch);
707 DBUG_ON(ch->flags & XPC_C_SETUP);
708
709 if (part->act_state != XPC_P_DEACTIVATING) {
710
711 /* as long as the other side is up do the full protocol */
712
713 if (!(ch->flags & XPC_C_RCLOSEREQUEST)) {
714 return;
715 }
716
717 if (!(ch->flags & XPC_C_CLOSEREPLY)) {
718 ch->flags |= XPC_C_CLOSEREPLY;
719 xpc_IPI_send_closereply(ch, irq_flags);
720 }
721
722 if (!(ch->flags & XPC_C_RCLOSEREPLY)) {
723 return;
724 }
725 }
726
727 /* both sides are disconnected now */
728
729 ch->flags = XPC_C_DISCONNECTED; /* clear all flags, but this one */
730
731 atomic_dec(&part->nchannels_active);
732
733 if (ch_flags & XPC_C_WASCONNECTED) {
734 dev_info(xpc_chan, "channel %d to partition %d disconnected, "
735 "reason=%d\n", ch->number, ch->partid, ch->reason);
736 }
737}
738
739
740/*
741 * Process a change in the channel's remote connection state.
742 */
743static void
744xpc_process_openclose_IPI(struct xpc_partition *part, int ch_number,
745 u8 IPI_flags)
746{
747 unsigned long irq_flags;
748 struct xpc_openclose_args *args =
749 &part->remote_openclose_args[ch_number];
750 struct xpc_channel *ch = &part->channels[ch_number];
751 enum xpc_retval reason;
752
753
754
755 spin_lock_irqsave(&ch->lock, irq_flags);
756
757
758 if (IPI_flags & XPC_IPI_CLOSEREQUEST) {
759
760 dev_dbg(xpc_chan, "XPC_IPI_CLOSEREQUEST (reason=%d) received "
761 "from partid=%d, channel=%d\n", args->reason,
762 ch->partid, ch->number);
763
764 /*
765 * If RCLOSEREQUEST is set, we're probably waiting for
766 * RCLOSEREPLY. We should find it and a ROPENREQUEST packed
767 * with this RCLOSEQREUQEST in the IPI_flags.
768 */
769
770 if (ch->flags & XPC_C_RCLOSEREQUEST) {
771 DBUG_ON(!(ch->flags & XPC_C_DISCONNECTING));
772 DBUG_ON(!(ch->flags & XPC_C_CLOSEREQUEST));
773 DBUG_ON(!(ch->flags & XPC_C_CLOSEREPLY));
774 DBUG_ON(ch->flags & XPC_C_RCLOSEREPLY);
775
776 DBUG_ON(!(IPI_flags & XPC_IPI_CLOSEREPLY));
777 IPI_flags &= ~XPC_IPI_CLOSEREPLY;
778 ch->flags |= XPC_C_RCLOSEREPLY;
779
780 /* both sides have finished disconnecting */
781 xpc_process_disconnect(ch, &irq_flags);
782 }
783
784 if (ch->flags & XPC_C_DISCONNECTED) {
785 // >>> explain this section
786
787 if (!(IPI_flags & XPC_IPI_OPENREQUEST)) {
788 DBUG_ON(part->act_state !=
789 XPC_P_DEACTIVATING);
790 spin_unlock_irqrestore(&ch->lock, irq_flags);
791 return;
792 }
793
794 XPC_SET_REASON(ch, 0, 0);
795 ch->flags &= ~XPC_C_DISCONNECTED;
796
797 atomic_inc(&part->nchannels_active);
798 ch->flags |= (XPC_C_CONNECTING | XPC_C_ROPENREQUEST);
799 }
800
801 IPI_flags &= ~(XPC_IPI_OPENREQUEST | XPC_IPI_OPENREPLY);
802
803 /*
804 * The meaningful CLOSEREQUEST connection state fields are:
805 * reason = reason connection is to be closed
806 */
807
808 ch->flags |= XPC_C_RCLOSEREQUEST;
809
810 if (!(ch->flags & XPC_C_DISCONNECTING)) {
811 reason = args->reason;
812 if (reason <= xpcSuccess || reason > xpcUnknownReason) {
813 reason = xpcUnknownReason;
814 } else if (reason == xpcUnregistering) {
815 reason = xpcOtherUnregistering;
816 }
817
818 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags);
819 } else {
820 xpc_process_disconnect(ch, &irq_flags);
821 }
822 }
823
824
825 if (IPI_flags & XPC_IPI_CLOSEREPLY) {
826
827 dev_dbg(xpc_chan, "XPC_IPI_CLOSEREPLY received from partid=%d,"
828 " channel=%d\n", ch->partid, ch->number);
829
830 if (ch->flags & XPC_C_DISCONNECTED) {
831 DBUG_ON(part->act_state != XPC_P_DEACTIVATING);
832 spin_unlock_irqrestore(&ch->lock, irq_flags);
833 return;
834 }
835
836 DBUG_ON(!(ch->flags & XPC_C_CLOSEREQUEST));
837 DBUG_ON(!(ch->flags & XPC_C_RCLOSEREQUEST));
838
839 ch->flags |= XPC_C_RCLOSEREPLY;
840
841 if (ch->flags & XPC_C_CLOSEREPLY) {
842 /* both sides have finished disconnecting */
843 xpc_process_disconnect(ch, &irq_flags);
844 }
845 }
846
847
848 if (IPI_flags & XPC_IPI_OPENREQUEST) {
849
850 dev_dbg(xpc_chan, "XPC_IPI_OPENREQUEST (msg_size=%d, "
851 "local_nentries=%d) received from partid=%d, "
852 "channel=%d\n", args->msg_size, args->local_nentries,
853 ch->partid, ch->number);
854
855 if ((ch->flags & XPC_C_DISCONNECTING) ||
856 part->act_state == XPC_P_DEACTIVATING) {
857 spin_unlock_irqrestore(&ch->lock, irq_flags);
858 return;
859 }
860 DBUG_ON(!(ch->flags & (XPC_C_DISCONNECTED |
861 XPC_C_OPENREQUEST)));
862 DBUG_ON(ch->flags & (XPC_C_ROPENREQUEST | XPC_C_ROPENREPLY |
863 XPC_C_OPENREPLY | XPC_C_CONNECTED));
864
865 /*
866 * The meaningful OPENREQUEST connection state fields are:
867 * msg_size = size of channel's messages in bytes
868 * local_nentries = remote partition's local_nentries
869 */
870 DBUG_ON(args->msg_size == 0);
871 DBUG_ON(args->local_nentries == 0);
872
873 ch->flags |= (XPC_C_ROPENREQUEST | XPC_C_CONNECTING);
874 ch->remote_nentries = args->local_nentries;
875
876
877 if (ch->flags & XPC_C_OPENREQUEST) {
878 if (args->msg_size != ch->msg_size) {
879 XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes,
880 &irq_flags);
881 spin_unlock_irqrestore(&ch->lock, irq_flags);
882 return;
883 }
884 } else {
885 ch->msg_size = args->msg_size;
886
887 XPC_SET_REASON(ch, 0, 0);
888 ch->flags &= ~XPC_C_DISCONNECTED;
889
890 atomic_inc(&part->nchannels_active);
891 }
892
893 xpc_process_connect(ch, &irq_flags);
894 }
895
896
897 if (IPI_flags & XPC_IPI_OPENREPLY) {
898
899 dev_dbg(xpc_chan, "XPC_IPI_OPENREPLY (local_msgqueue_pa=0x%lx, "
900 "local_nentries=%d, remote_nentries=%d) received from "
901 "partid=%d, channel=%d\n", args->local_msgqueue_pa,
902 args->local_nentries, args->remote_nentries,
903 ch->partid, ch->number);
904
905 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_DISCONNECTED)) {
906 spin_unlock_irqrestore(&ch->lock, irq_flags);
907 return;
908 }
909 DBUG_ON(!(ch->flags & XPC_C_OPENREQUEST));
910 DBUG_ON(!(ch->flags & XPC_C_ROPENREQUEST));
911 DBUG_ON(ch->flags & XPC_C_CONNECTED);
912
913 /*
914 * The meaningful OPENREPLY connection state fields are:
915 * local_msgqueue_pa = physical address of remote
916 * partition's local_msgqueue
917 * local_nentries = remote partition's local_nentries
918 * remote_nentries = remote partition's remote_nentries
919 */
920 DBUG_ON(args->local_msgqueue_pa == 0);
921 DBUG_ON(args->local_nentries == 0);
922 DBUG_ON(args->remote_nentries == 0);
923
924 ch->flags |= XPC_C_ROPENREPLY;
925 ch->remote_msgqueue_pa = args->local_msgqueue_pa;
926
927 if (args->local_nentries < ch->remote_nentries) {
928 dev_dbg(xpc_chan, "XPC_IPI_OPENREPLY: new "
929 "remote_nentries=%d, old remote_nentries=%d, "
930 "partid=%d, channel=%d\n",
931 args->local_nentries, ch->remote_nentries,
932 ch->partid, ch->number);
933
934 ch->remote_nentries = args->local_nentries;
935 }
936 if (args->remote_nentries < ch->local_nentries) {
937 dev_dbg(xpc_chan, "XPC_IPI_OPENREPLY: new "
938 "local_nentries=%d, old local_nentries=%d, "
939 "partid=%d, channel=%d\n",
940 args->remote_nentries, ch->local_nentries,
941 ch->partid, ch->number);
942
943 ch->local_nentries = args->remote_nentries;
944 }
945
946 xpc_process_connect(ch, &irq_flags);
947 }
948
949 spin_unlock_irqrestore(&ch->lock, irq_flags);
950}
951
952
953/*
954 * Attempt to establish a channel connection to a remote partition.
955 */
956static enum xpc_retval
957xpc_connect_channel(struct xpc_channel *ch)
958{
959 unsigned long irq_flags;
960 struct xpc_registration *registration = &xpc_registrations[ch->number];
961
962
963 if (down_interruptible(&registration->sema) != 0) {
964 return xpcInterrupted;
965 }
966
967 if (!XPC_CHANNEL_REGISTERED(ch->number)) {
968 up(&registration->sema);
969 return xpcUnregistered;
970 }
971
972 spin_lock_irqsave(&ch->lock, irq_flags);
973
974 DBUG_ON(ch->flags & XPC_C_CONNECTED);
975 DBUG_ON(ch->flags & XPC_C_OPENREQUEST);
976
977 if (ch->flags & XPC_C_DISCONNECTING) {
978 spin_unlock_irqrestore(&ch->lock, irq_flags);
979 up(&registration->sema);
980 return ch->reason;
981 }
982
983
984 /* add info from the channel connect registration to the channel */
985
986 ch->kthreads_assigned_limit = registration->assigned_limit;
987 ch->kthreads_idle_limit = registration->idle_limit;
988 DBUG_ON(atomic_read(&ch->kthreads_assigned) != 0);
989 DBUG_ON(atomic_read(&ch->kthreads_idle) != 0);
990 DBUG_ON(atomic_read(&ch->kthreads_active) != 0);
991
992 ch->func = registration->func;
993 DBUG_ON(registration->func == NULL);
994 ch->key = registration->key;
995
996 ch->local_nentries = registration->nentries;
997
998 if (ch->flags & XPC_C_ROPENREQUEST) {
999 if (registration->msg_size != ch->msg_size) {
1000 /* the local and remote sides aren't the same */
1001
1002 /*
1003 * Because XPC_DISCONNECT_CHANNEL() can block we're
1004 * forced to up the registration sema before we unlock
1005 * the channel lock. But that's okay here because we're
1006 * done with the part that required the registration
1007 * sema. XPC_DISCONNECT_CHANNEL() requires that the
1008 * channel lock be locked and will unlock and relock
1009 * the channel lock as needed.
1010 */
1011 up(&registration->sema);
1012 XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes,
1013 &irq_flags);
1014 spin_unlock_irqrestore(&ch->lock, irq_flags);
1015 return xpcUnequalMsgSizes;
1016 }
1017 } else {
1018 ch->msg_size = registration->msg_size;
1019
1020 XPC_SET_REASON(ch, 0, 0);
1021 ch->flags &= ~XPC_C_DISCONNECTED;
1022
1023 atomic_inc(&xpc_partitions[ch->partid].nchannels_active);
1024 }
1025
1026 up(&registration->sema);
1027
1028
1029 /* initiate the connection */
1030
1031 ch->flags |= (XPC_C_OPENREQUEST | XPC_C_CONNECTING);
1032 xpc_IPI_send_openrequest(ch, &irq_flags);
1033
1034 xpc_process_connect(ch, &irq_flags);
1035
1036 spin_unlock_irqrestore(&ch->lock, irq_flags);
1037
1038 return xpcSuccess;
1039}
1040
1041
1042/*
1043 * Notify those who wanted to be notified upon delivery of their message.
1044 */
1045static void
1046xpc_notify_senders(struct xpc_channel *ch, enum xpc_retval reason, s64 put)
1047{
1048 struct xpc_notify *notify;
1049 u8 notify_type;
1050 s64 get = ch->w_remote_GP.get - 1;
1051
1052
1053 while (++get < put && atomic_read(&ch->n_to_notify) > 0) {
1054
1055 notify = &ch->notify_queue[get % ch->local_nentries];
1056
1057 /*
1058 * See if the notify entry indicates it was associated with
1059 * a message who's sender wants to be notified. It is possible
1060 * that it is, but someone else is doing or has done the
1061 * notification.
1062 */
1063 notify_type = notify->type;
1064 if (notify_type == 0 ||
1065 cmpxchg(&notify->type, notify_type, 0) !=
1066 notify_type) {
1067 continue;
1068 }
1069
1070 DBUG_ON(notify_type != XPC_N_CALL);
1071
1072 atomic_dec(&ch->n_to_notify);
1073
1074 if (notify->func != NULL) {
1075 dev_dbg(xpc_chan, "notify->func() called, notify=0x%p, "
1076 "msg_number=%ld, partid=%d, channel=%d\n",
1077 (void *) notify, get, ch->partid, ch->number);
1078
1079 notify->func(reason, ch->partid, ch->number,
1080 notify->key);
1081
1082 dev_dbg(xpc_chan, "notify->func() returned, "
1083 "notify=0x%p, msg_number=%ld, partid=%d, "
1084 "channel=%d\n", (void *) notify, get,
1085 ch->partid, ch->number);
1086 }
1087 }
1088}
1089
1090
1091/*
1092 * Clear some of the msg flags in the local message queue.
1093 */
1094static inline void
1095xpc_clear_local_msgqueue_flags(struct xpc_channel *ch)
1096{
1097 struct xpc_msg *msg;
1098 s64 get;
1099
1100
1101 get = ch->w_remote_GP.get;
1102 do {
1103 msg = (struct xpc_msg *) ((u64) ch->local_msgqueue +
1104 (get % ch->local_nentries) * ch->msg_size);
1105 msg->flags = 0;
1106 } while (++get < (volatile s64) ch->remote_GP.get);
1107}
1108
1109
1110/*
1111 * Clear some of the msg flags in the remote message queue.
1112 */
1113static inline void
1114xpc_clear_remote_msgqueue_flags(struct xpc_channel *ch)
1115{
1116 struct xpc_msg *msg;
1117 s64 put;
1118
1119
1120 put = ch->w_remote_GP.put;
1121 do {
1122 msg = (struct xpc_msg *) ((u64) ch->remote_msgqueue +
1123 (put % ch->remote_nentries) * ch->msg_size);
1124 msg->flags = 0;
1125 } while (++put < (volatile s64) ch->remote_GP.put);
1126}
1127
1128
1129static void
1130xpc_process_msg_IPI(struct xpc_partition *part, int ch_number)
1131{
1132 struct xpc_channel *ch = &part->channels[ch_number];
1133 int nmsgs_sent;
1134
1135
1136 ch->remote_GP = part->remote_GPs[ch_number];
1137
1138
1139 /* See what, if anything, has changed for each connected channel */
1140
1141 xpc_msgqueue_ref(ch);
1142
1143 if (ch->w_remote_GP.get == ch->remote_GP.get &&
1144 ch->w_remote_GP.put == ch->remote_GP.put) {
1145 /* nothing changed since GPs were last pulled */
1146 xpc_msgqueue_deref(ch);
1147 return;
1148 }
1149
1150 if (!(ch->flags & XPC_C_CONNECTED)){
1151 xpc_msgqueue_deref(ch);
1152 return;
1153 }
1154
1155
1156 /*
1157 * First check to see if messages recently sent by us have been
1158 * received by the other side. (The remote GET value will have
1159 * changed since we last looked at it.)
1160 */
1161
1162 if (ch->w_remote_GP.get != ch->remote_GP.get) {
1163
1164 /*
1165 * We need to notify any senders that want to be notified
1166 * that their sent messages have been received by their
1167 * intended recipients. We need to do this before updating
1168 * w_remote_GP.get so that we don't allocate the same message
1169 * queue entries prematurely (see xpc_allocate_msg()).
1170 */
1171 if (atomic_read(&ch->n_to_notify) > 0) {
1172 /*
1173 * Notify senders that messages sent have been
1174 * received and delivered by the other side.
1175 */
1176 xpc_notify_senders(ch, xpcMsgDelivered,
1177 ch->remote_GP.get);
1178 }
1179
1180 /*
1181 * Clear msg->flags in previously sent messages, so that
1182 * they're ready for xpc_allocate_msg().
1183 */
1184 xpc_clear_local_msgqueue_flags(ch);
1185
1186 (volatile s64) ch->w_remote_GP.get = ch->remote_GP.get;
1187
1188 dev_dbg(xpc_chan, "w_remote_GP.get changed to %ld, partid=%d, "
1189 "channel=%d\n", ch->w_remote_GP.get, ch->partid,
1190 ch->number);
1191
1192 /*
1193 * If anyone was waiting for message queue entries to become
1194 * available, wake them up.
1195 */
1196 if (atomic_read(&ch->n_on_msg_allocate_wq) > 0) {
1197 wake_up(&ch->msg_allocate_wq);
1198 }
1199 }
1200
1201
1202 /*
1203 * Now check for newly sent messages by the other side. (The remote
1204 * PUT value will have changed since we last looked at it.)
1205 */
1206
1207 if (ch->w_remote_GP.put != ch->remote_GP.put) {
1208 /*
1209 * Clear msg->flags in previously received messages, so that
1210 * they're ready for xpc_get_deliverable_msg().
1211 */
1212 xpc_clear_remote_msgqueue_flags(ch);
1213
1214 (volatile s64) ch->w_remote_GP.put = ch->remote_GP.put;
1215
1216 dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, "
1217 "channel=%d\n", ch->w_remote_GP.put, ch->partid,
1218 ch->number);
1219
1220 nmsgs_sent = ch->w_remote_GP.put - ch->w_local_GP.get;
1221 if (nmsgs_sent > 0) {
1222 dev_dbg(xpc_chan, "msgs waiting to be copied and "
1223 "delivered=%d, partid=%d, channel=%d\n",
1224 nmsgs_sent, ch->partid, ch->number);
1225
1226 if (ch->flags & XPC_C_CONNECTCALLOUT) {
1227 xpc_activate_kthreads(ch, nmsgs_sent);
1228 }
1229 }
1230 }
1231
1232 xpc_msgqueue_deref(ch);
1233}
1234
1235
1236void
1237xpc_process_channel_activity(struct xpc_partition *part)
1238{
1239 unsigned long irq_flags;
1240 u64 IPI_amo, IPI_flags;
1241 struct xpc_channel *ch;
1242 int ch_number;
1243
1244
1245 IPI_amo = xpc_get_IPI_flags(part);
1246
1247 /*
1248 * Initiate channel connections for registered channels.
1249 *
1250 * For each connected channel that has pending messages activate idle
1251 * kthreads and/or create new kthreads as needed.
1252 */
1253
1254 for (ch_number = 0; ch_number < part->nchannels; ch_number++) {
1255 ch = &part->channels[ch_number];
1256
1257
1258 /*
1259 * Process any open or close related IPI flags, and then deal
1260 * with connecting or disconnecting the channel as required.
1261 */
1262
1263 IPI_flags = XPC_GET_IPI_FLAGS(IPI_amo, ch_number);
1264
1265 if (XPC_ANY_OPENCLOSE_IPI_FLAGS_SET(IPI_flags)) {
1266 xpc_process_openclose_IPI(part, ch_number, IPI_flags);
1267 }
1268
1269
1270 if (ch->flags & XPC_C_DISCONNECTING) {
1271 spin_lock_irqsave(&ch->lock, irq_flags);
1272 xpc_process_disconnect(ch, &irq_flags);
1273 spin_unlock_irqrestore(&ch->lock, irq_flags);
1274 continue;
1275 }
1276
1277 if (part->act_state == XPC_P_DEACTIVATING) {
1278 continue;
1279 }
1280
1281 if (!(ch->flags & XPC_C_CONNECTED)) {
1282 if (!(ch->flags & XPC_C_OPENREQUEST)) {
1283 DBUG_ON(ch->flags & XPC_C_SETUP);
1284 (void) xpc_connect_channel(ch);
1285 } else {
1286 spin_lock_irqsave(&ch->lock, irq_flags);
1287 xpc_process_connect(ch, &irq_flags);
1288 spin_unlock_irqrestore(&ch->lock, irq_flags);
1289 }
1290 continue;
1291 }
1292
1293
1294 /*
1295 * Process any message related IPI flags, this may involve the
1296 * activation of kthreads to deliver any pending messages sent
1297 * from the other partition.
1298 */
1299
1300 if (XPC_ANY_MSG_IPI_FLAGS_SET(IPI_flags)) {
1301 xpc_process_msg_IPI(part, ch_number);
1302 }
1303 }
1304}
1305
1306
1307/*
1308 * XPC's heartbeat code calls this function to inform XPC that a partition has
1309 * gone down. XPC responds by tearing down the XPartition Communication
1310 * infrastructure used for the just downed partition.
1311 *
1312 * XPC's heartbeat code will never call this function and xpc_partition_up()
1313 * at the same time. Nor will it ever make multiple calls to either function
1314 * at the same time.
1315 */
1316void
1317xpc_partition_down(struct xpc_partition *part, enum xpc_retval reason)
1318{
1319 unsigned long irq_flags;
1320 int ch_number;
1321 struct xpc_channel *ch;
1322
1323
1324 dev_dbg(xpc_chan, "deactivating partition %d, reason=%d\n",
1325 XPC_PARTID(part), reason);
1326
1327 if (!xpc_part_ref(part)) {
1328 /* infrastructure for this partition isn't currently set up */
1329 return;
1330 }
1331
1332
1333 /* disconnect all channels associated with the downed partition */
1334
1335 for (ch_number = 0; ch_number < part->nchannels; ch_number++) {
1336 ch = &part->channels[ch_number];
1337
1338
1339 xpc_msgqueue_ref(ch);
1340 spin_lock_irqsave(&ch->lock, irq_flags);
1341
1342 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags);
1343
1344 spin_unlock_irqrestore(&ch->lock, irq_flags);
1345 xpc_msgqueue_deref(ch);
1346 }
1347
1348 xpc_wakeup_channel_mgr(part);
1349
1350 xpc_part_deref(part);
1351}
1352
1353
1354/*
1355 * Teardown the infrastructure necessary to support XPartition Communication
1356 * between the specified remote partition and the local one.
1357 */
1358void
1359xpc_teardown_infrastructure(struct xpc_partition *part)
1360{
1361 partid_t partid = XPC_PARTID(part);
1362
1363
1364 /*
1365 * We start off by making this partition inaccessible to local
1366 * processes by marking it as no longer setup. Then we make it
1367 * inaccessible to remote processes by clearing the XPC per partition
1368 * specific variable's magic # (which indicates that these variables
1369 * are no longer valid) and by ignoring all XPC notify IPIs sent to
1370 * this partition.
1371 */
1372
1373 DBUG_ON(atomic_read(&part->nchannels_active) != 0);
1374 DBUG_ON(part->setup_state != XPC_P_SETUP);
1375 part->setup_state = XPC_P_WTEARDOWN;
1376
1377 xpc_vars_part[partid].magic = 0;
1378
1379
1380 free_irq(SGI_XPC_NOTIFY, (void *) (u64) partid);
1381
1382
1383 /*
1384 * Before proceding with the teardown we have to wait until all
1385 * existing references cease.
1386 */
1387 wait_event(part->teardown_wq, (atomic_read(&part->references) == 0));
1388
1389
1390 /* now we can begin tearing down the infrastructure */
1391
1392 part->setup_state = XPC_P_TORNDOWN;
1393
1394 /* in case we've still got outstanding timers registered... */
1395 del_timer_sync(&part->dropped_IPI_timer);
1396
1397 kfree(part->remote_openclose_args_base);
1398 part->remote_openclose_args = NULL;
1399 kfree(part->local_openclose_args_base);
1400 part->local_openclose_args = NULL;
1401 kfree(part->remote_GPs_base);
1402 part->remote_GPs = NULL;
1403 kfree(part->local_GPs_base);
1404 part->local_GPs = NULL;
1405 kfree(part->channels);
1406 part->channels = NULL;
1407 part->local_IPI_amo_va = NULL;
1408}
1409
1410
1411/*
1412 * Called by XP at the time of channel connection registration to cause
1413 * XPC to establish connections to all currently active partitions.
1414 */
1415void
1416xpc_initiate_connect(int ch_number)
1417{
1418 partid_t partid;
1419 struct xpc_partition *part;
1420 struct xpc_channel *ch;
1421
1422
1423 DBUG_ON(ch_number < 0 || ch_number >= XPC_NCHANNELS);
1424
1425 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
1426 part = &xpc_partitions[partid];
1427
1428 if (xpc_part_ref(part)) {
1429 ch = &part->channels[ch_number];
1430
1431 if (!(ch->flags & XPC_C_DISCONNECTING)) {
1432 DBUG_ON(ch->flags & XPC_C_OPENREQUEST);
1433 DBUG_ON(ch->flags & XPC_C_CONNECTED);
1434 DBUG_ON(ch->flags & XPC_C_SETUP);
1435
1436 /*
1437 * Initiate the establishment of a connection
1438 * on the newly registered channel to the
1439 * remote partition.
1440 */
1441 xpc_wakeup_channel_mgr(part);
1442 }
1443
1444 xpc_part_deref(part);
1445 }
1446 }
1447}
1448
1449
1450void
1451xpc_connected_callout(struct xpc_channel *ch)
1452{
1453 unsigned long irq_flags;
1454
1455
1456 /* let the registerer know that a connection has been established */
1457
1458 if (ch->func != NULL) {
1459 dev_dbg(xpc_chan, "ch->func() called, reason=xpcConnected, "
1460 "partid=%d, channel=%d\n", ch->partid, ch->number);
1461
1462 ch->func(xpcConnected, ch->partid, ch->number,
1463 (void *) (u64) ch->local_nentries, ch->key);
1464
1465 dev_dbg(xpc_chan, "ch->func() returned, reason=xpcConnected, "
1466 "partid=%d, channel=%d\n", ch->partid, ch->number);
1467 }
1468
1469 spin_lock_irqsave(&ch->lock, irq_flags);
1470 ch->flags |= XPC_C_CONNECTCALLOUT;
1471 spin_unlock_irqrestore(&ch->lock, irq_flags);
1472}
1473
1474
1475/*
1476 * Called by XP at the time of channel connection unregistration to cause
1477 * XPC to teardown all current connections for the specified channel.
1478 *
1479 * Before returning xpc_initiate_disconnect() will wait until all connections
1480 * on the specified channel have been closed/torndown. So the caller can be
1481 * assured that they will not be receiving any more callouts from XPC to the
1482 * function they registered via xpc_connect().
1483 *
1484 * Arguments:
1485 *
1486 * ch_number - channel # to unregister.
1487 */
1488void
1489xpc_initiate_disconnect(int ch_number)
1490{
1491 unsigned long irq_flags;
1492 partid_t partid;
1493 struct xpc_partition *part;
1494 struct xpc_channel *ch;
1495
1496
1497 DBUG_ON(ch_number < 0 || ch_number >= XPC_NCHANNELS);
1498
1499 /* initiate the channel disconnect for every active partition */
1500 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
1501 part = &xpc_partitions[partid];
1502
1503 if (xpc_part_ref(part)) {
1504 ch = &part->channels[ch_number];
1505 xpc_msgqueue_ref(ch);
1506
1507 spin_lock_irqsave(&ch->lock, irq_flags);
1508
1509 XPC_DISCONNECT_CHANNEL(ch, xpcUnregistering,
1510 &irq_flags);
1511
1512 spin_unlock_irqrestore(&ch->lock, irq_flags);
1513
1514 xpc_msgqueue_deref(ch);
1515 xpc_part_deref(part);
1516 }
1517 }
1518
1519 xpc_disconnect_wait(ch_number);
1520}
1521
1522
1523/*
1524 * To disconnect a channel, and reflect it back to all who may be waiting.
1525 *
1526 * >>> An OPEN is not allowed until XPC_C_DISCONNECTING is cleared by
1527 * >>> xpc_free_msgqueues().
1528 *
1529 * THE CHANNEL IS TO BE LOCKED BY THE CALLER AND WILL REMAIN LOCKED UPON RETURN.
1530 */
1531void
1532xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1533 enum xpc_retval reason, unsigned long *irq_flags)
1534{
1535 u32 flags;
1536
1537
1538 DBUG_ON(!spin_is_locked(&ch->lock));
1539
1540 if (ch->flags & (XPC_C_DISCONNECTING | XPC_C_DISCONNECTED)) {
1541 return;
1542 }
1543 DBUG_ON(!(ch->flags & (XPC_C_CONNECTING | XPC_C_CONNECTED)));
1544
1545 dev_dbg(xpc_chan, "reason=%d, line=%d, partid=%d, channel=%d\n",
1546 reason, line, ch->partid, ch->number);
1547
1548 XPC_SET_REASON(ch, reason, line);
1549
1550 flags = ch->flags;
1551 /* some of these may not have been set */
1552 ch->flags &= ~(XPC_C_OPENREQUEST | XPC_C_OPENREPLY |
1553 XPC_C_ROPENREQUEST | XPC_C_ROPENREPLY |
1554 XPC_C_CONNECTING | XPC_C_CONNECTED);
1555
1556 ch->flags |= (XPC_C_CLOSEREQUEST | XPC_C_DISCONNECTING);
1557 xpc_IPI_send_closerequest(ch, irq_flags);
1558
1559 if (flags & XPC_C_CONNECTED) {
1560 ch->flags |= XPC_C_WASCONNECTED;
1561 }
1562
1563 if (atomic_read(&ch->kthreads_idle) > 0) {
1564 /* wake all idle kthreads so they can exit */
1565 wake_up_all(&ch->idle_wq);
1566 }
1567
1568 spin_unlock_irqrestore(&ch->lock, *irq_flags);
1569
1570
1571 /* wake those waiting to allocate an entry from the local msg queue */
1572
1573 if (atomic_read(&ch->n_on_msg_allocate_wq) > 0) {
1574 wake_up(&ch->msg_allocate_wq);
1575 }
1576
1577 /* wake those waiting for notify completion */
1578
1579 if (atomic_read(&ch->n_to_notify) > 0) {
1580 xpc_notify_senders(ch, reason, ch->w_local_GP.put);
1581 }
1582
1583 spin_lock_irqsave(&ch->lock, *irq_flags);
1584}
1585
1586
1587void
1588xpc_disconnected_callout(struct xpc_channel *ch)
1589{
1590 /*
1591 * Let the channel's registerer know that the channel is now
1592 * disconnected. We don't want to do this if the registerer was never
1593 * informed of a connection being made, unless the disconnect was for
1594 * abnormal reasons.
1595 */
1596
1597 if (ch->func != NULL) {
1598 dev_dbg(xpc_chan, "ch->func() called, reason=%d, partid=%d, "
1599 "channel=%d\n", ch->reason, ch->partid, ch->number);
1600
1601 ch->func(ch->reason, ch->partid, ch->number, NULL, ch->key);
1602
1603 dev_dbg(xpc_chan, "ch->func() returned, reason=%d, partid=%d, "
1604 "channel=%d\n", ch->reason, ch->partid, ch->number);
1605 }
1606}
1607
1608
1609/*
1610 * Wait for a message entry to become available for the specified channel,
1611 * but don't wait any longer than 1 jiffy.
1612 */
1613static enum xpc_retval
1614xpc_allocate_msg_wait(struct xpc_channel *ch)
1615{
1616 enum xpc_retval ret;
1617
1618
1619 if (ch->flags & XPC_C_DISCONNECTING) {
1620 DBUG_ON(ch->reason == xpcInterrupted); // >>> Is this true?
1621 return ch->reason;
1622 }
1623
1624 atomic_inc(&ch->n_on_msg_allocate_wq);
1625 ret = interruptible_sleep_on_timeout(&ch->msg_allocate_wq, 1);
1626 atomic_dec(&ch->n_on_msg_allocate_wq);
1627
1628 if (ch->flags & XPC_C_DISCONNECTING) {
1629 ret = ch->reason;
1630 DBUG_ON(ch->reason == xpcInterrupted); // >>> Is this true?
1631 } else if (ret == 0) {
1632 ret = xpcTimeout;
1633 } else {
1634 ret = xpcInterrupted;
1635 }
1636
1637 return ret;
1638}
1639
1640
1641/*
1642 * Allocate an entry for a message from the message queue associated with the
1643 * specified channel.
1644 */
1645static enum xpc_retval
1646xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1647 struct xpc_msg **address_of_msg)
1648{
1649 struct xpc_msg *msg;
1650 enum xpc_retval ret;
1651 s64 put;
1652
1653
1654 /* this reference will be dropped in xpc_send_msg() */
1655 xpc_msgqueue_ref(ch);
1656
1657 if (ch->flags & XPC_C_DISCONNECTING) {
1658 xpc_msgqueue_deref(ch);
1659 return ch->reason;
1660 }
1661 if (!(ch->flags & XPC_C_CONNECTED)) {
1662 xpc_msgqueue_deref(ch);
1663 return xpcNotConnected;
1664 }
1665
1666
1667 /*
1668 * Get the next available message entry from the local message queue.
1669 * If none are available, we'll make sure that we grab the latest
1670 * GP values.
1671 */
1672 ret = xpcTimeout;
1673
1674 while (1) {
1675
1676 put = (volatile s64) ch->w_local_GP.put;
1677 if (put - (volatile s64) ch->w_remote_GP.get <
1678 ch->local_nentries) {
1679
1680 /* There are available message entries. We need to try
1681 * to secure one for ourselves. We'll do this by trying
1682 * to increment w_local_GP.put as long as someone else
1683 * doesn't beat us to it. If they do, we'll have to
1684 * try again.
1685 */
1686 if (cmpxchg(&ch->w_local_GP.put, put, put + 1) ==
1687 put) {
1688 /* we got the entry referenced by put */
1689 break;
1690 }
1691 continue; /* try again */
1692 }
1693
1694
1695 /*
1696 * There aren't any available msg entries at this time.
1697 *
1698 * In waiting for a message entry to become available,
1699 * we set a timeout in case the other side is not
1700 * sending completion IPIs. This lets us fake an IPI
1701 * that will cause the IPI handler to fetch the latest
1702 * GP values as if an IPI was sent by the other side.
1703 */
1704 if (ret == xpcTimeout) {
1705 xpc_IPI_send_local_msgrequest(ch);
1706 }
1707
1708 if (flags & XPC_NOWAIT) {
1709 xpc_msgqueue_deref(ch);
1710 return xpcNoWait;
1711 }
1712
1713 ret = xpc_allocate_msg_wait(ch);
1714 if (ret != xpcInterrupted && ret != xpcTimeout) {
1715 xpc_msgqueue_deref(ch);
1716 return ret;
1717 }
1718 }
1719
1720
1721 /* get the message's address and initialize it */
1722 msg = (struct xpc_msg *) ((u64) ch->local_msgqueue +
1723 (put % ch->local_nentries) * ch->msg_size);
1724
1725
1726 DBUG_ON(msg->flags != 0);
1727 msg->number = put;
1728
1729 dev_dbg(xpc_chan, "w_local_GP.put changed to %ld; msg=0x%p, "
1730 "msg_number=%ld, partid=%d, channel=%d\n", put + 1,
1731 (void *) msg, msg->number, ch->partid, ch->number);
1732
1733 *address_of_msg = msg;
1734
1735 return xpcSuccess;
1736}
1737
1738
1739/*
1740 * Allocate an entry for a message from the message queue associated with the
1741 * specified channel. NOTE that this routine can sleep waiting for a message
1742 * entry to become available. To not sleep, pass in the XPC_NOWAIT flag.
1743 *
1744 * Arguments:
1745 *
1746 * partid - ID of partition to which the channel is connected.
1747 * ch_number - channel #.
1748 * flags - see xpc.h for valid flags.
1749 * payload - address of the allocated payload area pointer (filled in on
1750 * return) in which the user-defined message is constructed.
1751 */
1752enum xpc_retval
1753xpc_initiate_allocate(partid_t partid, int ch_number, u32 flags, void **payload)
1754{
1755 struct xpc_partition *part = &xpc_partitions[partid];
1756 enum xpc_retval ret = xpcUnknownReason;
1757 struct xpc_msg *msg;
1758
1759
1760 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
1761 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
1762
1763 *payload = NULL;
1764
1765 if (xpc_part_ref(part)) {
1766 ret = xpc_allocate_msg(&part->channels[ch_number], flags, &msg);
1767 xpc_part_deref(part);
1768
1769 if (msg != NULL) {
1770 *payload = &msg->payload;
1771 }
1772 }
1773
1774 return ret;
1775}
1776
1777
1778/*
1779 * Now we actually send the messages that are ready to be sent by advancing
1780 * the local message queue's Put value and then send an IPI to the recipient
1781 * partition.
1782 */
1783static void
1784xpc_send_msgs(struct xpc_channel *ch, s64 initial_put)
1785{
1786 struct xpc_msg *msg;
1787 s64 put = initial_put + 1;
1788 int send_IPI = 0;
1789
1790
1791 while (1) {
1792
1793 while (1) {
1794 if (put == (volatile s64) ch->w_local_GP.put) {
1795 break;
1796 }
1797
1798 msg = (struct xpc_msg *) ((u64) ch->local_msgqueue +
1799 (put % ch->local_nentries) * ch->msg_size);
1800
1801 if (!(msg->flags & XPC_M_READY)) {
1802 break;
1803 }
1804
1805 put++;
1806 }
1807
1808 if (put == initial_put) {
1809 /* nothing's changed */
1810 break;
1811 }
1812
1813 if (cmpxchg_rel(&ch->local_GP->put, initial_put, put) !=
1814 initial_put) {
1815 /* someone else beat us to it */
1816 DBUG_ON((volatile s64) ch->local_GP->put < initial_put);
1817 break;
1818 }
1819
1820 /* we just set the new value of local_GP->put */
1821
1822 dev_dbg(xpc_chan, "local_GP->put changed to %ld, partid=%d, "
1823 "channel=%d\n", put, ch->partid, ch->number);
1824
1825 send_IPI = 1;
1826
1827 /*
1828 * We need to ensure that the message referenced by
1829 * local_GP->put is not XPC_M_READY or that local_GP->put
1830 * equals w_local_GP.put, so we'll go have a look.
1831 */
1832 initial_put = put;
1833 }
1834
1835 if (send_IPI) {
1836 xpc_IPI_send_msgrequest(ch);
1837 }
1838}
1839
1840
1841/*
1842 * Common code that does the actual sending of the message by advancing the
1843 * local message queue's Put value and sends an IPI to the partition the
1844 * message is being sent to.
1845 */
1846static enum xpc_retval
1847xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1848 xpc_notify_func func, void *key)
1849{
1850 enum xpc_retval ret = xpcSuccess;
1851 struct xpc_notify *notify = NULL; // >>> to keep the compiler happy!!
1852 s64 put, msg_number = msg->number;
1853
1854
1855 DBUG_ON(notify_type == XPC_N_CALL && func == NULL);
1856 DBUG_ON((((u64) msg - (u64) ch->local_msgqueue) / ch->msg_size) !=
1857 msg_number % ch->local_nentries);
1858 DBUG_ON(msg->flags & XPC_M_READY);
1859
1860 if (ch->flags & XPC_C_DISCONNECTING) {
1861 /* drop the reference grabbed in xpc_allocate_msg() */
1862 xpc_msgqueue_deref(ch);
1863 return ch->reason;
1864 }
1865
1866 if (notify_type != 0) {
1867 /*
1868 * Tell the remote side to send an ACK interrupt when the
1869 * message has been delivered.
1870 */
1871 msg->flags |= XPC_M_INTERRUPT;
1872
1873 atomic_inc(&ch->n_to_notify);
1874
1875 notify = &ch->notify_queue[msg_number % ch->local_nentries];
1876 notify->func = func;
1877 notify->key = key;
1878 (volatile u8) notify->type = notify_type;
1879
1880 // >>> is a mb() needed here?
1881
1882 if (ch->flags & XPC_C_DISCONNECTING) {
1883 /*
1884 * An error occurred between our last error check and
1885 * this one. We will try to clear the type field from
1886 * the notify entry. If we succeed then
1887 * xpc_disconnect_channel() didn't already process
1888 * the notify entry.
1889 */
1890 if (cmpxchg(&notify->type, notify_type, 0) ==
1891 notify_type) {
1892 atomic_dec(&ch->n_to_notify);
1893 ret = ch->reason;
1894 }
1895
1896 /* drop the reference grabbed in xpc_allocate_msg() */
1897 xpc_msgqueue_deref(ch);
1898 return ret;
1899 }
1900 }
1901
1902 msg->flags |= XPC_M_READY;
1903
1904 /*
1905 * The preceding store of msg->flags must occur before the following
1906 * load of ch->local_GP->put.
1907 */
1908 mb();
1909
1910 /* see if the message is next in line to be sent, if so send it */
1911
1912 put = ch->local_GP->put;
1913 if (put == msg_number) {
1914 xpc_send_msgs(ch, put);
1915 }
1916
1917 /* drop the reference grabbed in xpc_allocate_msg() */
1918 xpc_msgqueue_deref(ch);
1919 return ret;
1920}
1921
1922
1923/*
1924 * Send a message previously allocated using xpc_initiate_allocate() on the
1925 * specified channel connected to the specified partition.
1926 *
1927 * This routine will not wait for the message to be received, nor will
1928 * notification be given when it does happen. Once this routine has returned
1929 * the message entry allocated via xpc_initiate_allocate() is no longer
1930 * accessable to the caller.
1931 *
1932 * This routine, although called by users, does not call xpc_part_ref() to
1933 * ensure that the partition infrastructure is in place. It relies on the
1934 * fact that we called xpc_msgqueue_ref() in xpc_allocate_msg().
1935 *
1936 * Arguments:
1937 *
1938 * partid - ID of partition to which the channel is connected.
1939 * ch_number - channel # to send message on.
1940 * payload - pointer to the payload area allocated via
1941 * xpc_initiate_allocate().
1942 */
1943enum xpc_retval
1944xpc_initiate_send(partid_t partid, int ch_number, void *payload)
1945{
1946 struct xpc_partition *part = &xpc_partitions[partid];
1947 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
1948 enum xpc_retval ret;
1949
1950
1951 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *) msg,
1952 partid, ch_number);
1953
1954 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
1955 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
1956 DBUG_ON(msg == NULL);
1957
1958 ret = xpc_send_msg(&part->channels[ch_number], msg, 0, NULL, NULL);
1959
1960 return ret;
1961}
1962
1963
1964/*
1965 * Send a message previously allocated using xpc_initiate_allocate on the
1966 * specified channel connected to the specified partition.
1967 *
1968 * This routine will not wait for the message to be sent. Once this routine
1969 * has returned the message entry allocated via xpc_initiate_allocate() is no
1970 * longer accessable to the caller.
1971 *
1972 * Once the remote end of the channel has received the message, the function
1973 * passed as an argument to xpc_initiate_send_notify() will be called. This
1974 * allows the sender to free up or re-use any buffers referenced by the
1975 * message, but does NOT mean the message has been processed at the remote
1976 * end by a receiver.
1977 *
1978 * If this routine returns an error, the caller's function will NOT be called.
1979 *
1980 * This routine, although called by users, does not call xpc_part_ref() to
1981 * ensure that the partition infrastructure is in place. It relies on the
1982 * fact that we called xpc_msgqueue_ref() in xpc_allocate_msg().
1983 *
1984 * Arguments:
1985 *
1986 * partid - ID of partition to which the channel is connected.
1987 * ch_number - channel # to send message on.
1988 * payload - pointer to the payload area allocated via
1989 * xpc_initiate_allocate().
1990 * func - function to call with asynchronous notification of message
1991 * receipt. THIS FUNCTION MUST BE NON-BLOCKING.
1992 * key - user-defined key to be passed to the function when it's called.
1993 */
1994enum xpc_retval
1995xpc_initiate_send_notify(partid_t partid, int ch_number, void *payload,
1996 xpc_notify_func func, void *key)
1997{
1998 struct xpc_partition *part = &xpc_partitions[partid];
1999 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
2000 enum xpc_retval ret;
2001
2002
2003 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *) msg,
2004 partid, ch_number);
2005
2006 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
2007 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
2008 DBUG_ON(msg == NULL);
2009 DBUG_ON(func == NULL);
2010
2011 ret = xpc_send_msg(&part->channels[ch_number], msg, XPC_N_CALL,
2012 func, key);
2013 return ret;
2014}
2015
2016
2017static struct xpc_msg *
2018xpc_pull_remote_msg(struct xpc_channel *ch, s64 get)
2019{
2020 struct xpc_partition *part = &xpc_partitions[ch->partid];
2021 struct xpc_msg *remote_msg, *msg;
2022 u32 msg_index, nmsgs;
2023 u64 msg_offset;
2024 enum xpc_retval ret;
2025
2026
2027 if (down_interruptible(&ch->msg_to_pull_sema) != 0) {
2028 /* we were interrupted by a signal */
2029 return NULL;
2030 }
2031
2032 while (get >= ch->next_msg_to_pull) {
2033
2034 /* pull as many messages as are ready and able to be pulled */
2035
2036 msg_index = ch->next_msg_to_pull % ch->remote_nentries;
2037
2038 DBUG_ON(ch->next_msg_to_pull >=
2039 (volatile s64) ch->w_remote_GP.put);
2040 nmsgs = (volatile s64) ch->w_remote_GP.put -
2041 ch->next_msg_to_pull;
2042 if (msg_index + nmsgs > ch->remote_nentries) {
2043 /* ignore the ones that wrap the msg queue for now */
2044 nmsgs = ch->remote_nentries - msg_index;
2045 }
2046
2047 msg_offset = msg_index * ch->msg_size;
2048 msg = (struct xpc_msg *) ((u64) ch->remote_msgqueue +
2049 msg_offset);
2050 remote_msg = (struct xpc_msg *) (ch->remote_msgqueue_pa +
2051 msg_offset);
2052
2053 if ((ret = xpc_pull_remote_cachelines(part, msg, remote_msg,
2054 nmsgs * ch->msg_size)) != xpcSuccess) {
2055
2056 dev_dbg(xpc_chan, "failed to pull %d msgs starting with"
2057 " msg %ld from partition %d, channel=%d, "
2058 "ret=%d\n", nmsgs, ch->next_msg_to_pull,
2059 ch->partid, ch->number, ret);
2060
2061 XPC_DEACTIVATE_PARTITION(part, ret);
2062
2063 up(&ch->msg_to_pull_sema);
2064 return NULL;
2065 }
2066
2067 mb(); /* >>> this may not be needed, we're not sure */
2068
2069 ch->next_msg_to_pull += nmsgs;
2070 }
2071
2072 up(&ch->msg_to_pull_sema);
2073
2074 /* return the message we were looking for */
2075 msg_offset = (get % ch->remote_nentries) * ch->msg_size;
2076 msg = (struct xpc_msg *) ((u64) ch->remote_msgqueue + msg_offset);
2077
2078 return msg;
2079}
2080
2081
2082/*
2083 * Get a message to be delivered.
2084 */
2085static struct xpc_msg *
2086xpc_get_deliverable_msg(struct xpc_channel *ch)
2087{
2088 struct xpc_msg *msg = NULL;
2089 s64 get;
2090
2091
2092 do {
2093 if ((volatile u32) ch->flags & XPC_C_DISCONNECTING) {
2094 break;
2095 }
2096
2097 get = (volatile s64) ch->w_local_GP.get;
2098 if (get == (volatile s64) ch->w_remote_GP.put) {
2099 break;
2100 }
2101
2102 /* There are messages waiting to be pulled and delivered.
2103 * We need to try to secure one for ourselves. We'll do this
2104 * by trying to increment w_local_GP.get and hope that no one
2105 * else beats us to it. If they do, we'll we'll simply have
2106 * to try again for the next one.
2107 */
2108
2109 if (cmpxchg(&ch->w_local_GP.get, get, get + 1) == get) {
2110 /* we got the entry referenced by get */
2111
2112 dev_dbg(xpc_chan, "w_local_GP.get changed to %ld, "
2113 "partid=%d, channel=%d\n", get + 1,
2114 ch->partid, ch->number);
2115
2116 /* pull the message from the remote partition */
2117
2118 msg = xpc_pull_remote_msg(ch, get);
2119
2120 DBUG_ON(msg != NULL && msg->number != get);
2121 DBUG_ON(msg != NULL && (msg->flags & XPC_M_DONE));
2122 DBUG_ON(msg != NULL && !(msg->flags & XPC_M_READY));
2123
2124 break;
2125 }
2126
2127 } while (1);
2128
2129 return msg;
2130}
2131
2132
2133/*
2134 * Deliver a message to its intended recipient.
2135 */
2136void
2137xpc_deliver_msg(struct xpc_channel *ch)
2138{
2139 struct xpc_msg *msg;
2140
2141
2142 if ((msg = xpc_get_deliverable_msg(ch)) != NULL) {
2143
2144 /*
2145 * This ref is taken to protect the payload itself from being
2146 * freed before the user is finished with it, which the user
2147 * indicates by calling xpc_initiate_received().
2148 */
2149 xpc_msgqueue_ref(ch);
2150
2151 atomic_inc(&ch->kthreads_active);
2152
2153 if (ch->func != NULL) {
2154 dev_dbg(xpc_chan, "ch->func() called, msg=0x%p, "
2155 "msg_number=%ld, partid=%d, channel=%d\n",
2156 (void *) msg, msg->number, ch->partid,
2157 ch->number);
2158
2159 /* deliver the message to its intended recipient */
2160 ch->func(xpcMsgReceived, ch->partid, ch->number,
2161 &msg->payload, ch->key);
2162
2163 dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, "
2164 "msg_number=%ld, partid=%d, channel=%d\n",
2165 (void *) msg, msg->number, ch->partid,
2166 ch->number);
2167 }
2168
2169 atomic_dec(&ch->kthreads_active);
2170 }
2171}
2172
2173
2174/*
2175 * Now we actually acknowledge the messages that have been delivered and ack'd
2176 * by advancing the cached remote message queue's Get value and if requested
2177 * send an IPI to the message sender's partition.
2178 */
2179static void
2180xpc_acknowledge_msgs(struct xpc_channel *ch, s64 initial_get, u8 msg_flags)
2181{
2182 struct xpc_msg *msg;
2183 s64 get = initial_get + 1;
2184 int send_IPI = 0;
2185
2186
2187 while (1) {
2188
2189 while (1) {
2190 if (get == (volatile s64) ch->w_local_GP.get) {
2191 break;
2192 }
2193
2194 msg = (struct xpc_msg *) ((u64) ch->remote_msgqueue +
2195 (get % ch->remote_nentries) * ch->msg_size);
2196
2197 if (!(msg->flags & XPC_M_DONE)) {
2198 break;
2199 }
2200
2201 msg_flags |= msg->flags;
2202 get++;
2203 }
2204
2205 if (get == initial_get) {
2206 /* nothing's changed */
2207 break;
2208 }
2209
2210 if (cmpxchg_rel(&ch->local_GP->get, initial_get, get) !=
2211 initial_get) {
2212 /* someone else beat us to it */
2213 DBUG_ON((volatile s64) ch->local_GP->get <=
2214 initial_get);
2215 break;
2216 }
2217
2218 /* we just set the new value of local_GP->get */
2219
2220 dev_dbg(xpc_chan, "local_GP->get changed to %ld, partid=%d, "
2221 "channel=%d\n", get, ch->partid, ch->number);
2222
2223 send_IPI = (msg_flags & XPC_M_INTERRUPT);
2224
2225 /*
2226 * We need to ensure that the message referenced by
2227 * local_GP->get is not XPC_M_DONE or that local_GP->get
2228 * equals w_local_GP.get, so we'll go have a look.
2229 */
2230 initial_get = get;
2231 }
2232
2233 if (send_IPI) {
2234 xpc_IPI_send_msgrequest(ch);
2235 }
2236}
2237
2238
2239/*
2240 * Acknowledge receipt of a delivered message.
2241 *
2242 * If a message has XPC_M_INTERRUPT set, send an interrupt to the partition
2243 * that sent the message.
2244 *
2245 * This function, although called by users, does not call xpc_part_ref() to
2246 * ensure that the partition infrastructure is in place. It relies on the
2247 * fact that we called xpc_msgqueue_ref() in xpc_deliver_msg().
2248 *
2249 * Arguments:
2250 *
2251 * partid - ID of partition to which the channel is connected.
2252 * ch_number - channel # message received on.
2253 * payload - pointer to the payload area allocated via
2254 * xpc_initiate_allocate().
2255 */
2256void
2257xpc_initiate_received(partid_t partid, int ch_number, void *payload)
2258{
2259 struct xpc_partition *part = &xpc_partitions[partid];
2260 struct xpc_channel *ch;
2261 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
2262 s64 get, msg_number = msg->number;
2263
2264
2265 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
2266 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
2267
2268 ch = &part->channels[ch_number];
2269
2270 dev_dbg(xpc_chan, "msg=0x%p, msg_number=%ld, partid=%d, channel=%d\n",
2271 (void *) msg, msg_number, ch->partid, ch->number);
2272
2273 DBUG_ON((((u64) msg - (u64) ch->remote_msgqueue) / ch->msg_size) !=
2274 msg_number % ch->remote_nentries);
2275 DBUG_ON(msg->flags & XPC_M_DONE);
2276
2277 msg->flags |= XPC_M_DONE;
2278
2279 /*
2280 * The preceding store of msg->flags must occur before the following
2281 * load of ch->local_GP->get.
2282 */
2283 mb();
2284
2285 /*
2286 * See if this message is next in line to be acknowledged as having
2287 * been delivered.
2288 */
2289 get = ch->local_GP->get;
2290 if (get == msg_number) {
2291 xpc_acknowledge_msgs(ch, get, msg->flags);
2292 }
2293
2294 /* the call to xpc_msgqueue_ref() was done by xpc_deliver_msg() */
2295 xpc_msgqueue_deref(ch);
2296}
2297
diff --git a/arch/ia64/sn/kernel/xpc_main.c b/arch/ia64/sn/kernel/xpc_main.c
new file mode 100644
index 000000000000..177ddb748ebe
--- /dev/null
+++ b/arch/ia64/sn/kernel/xpc_main.c
@@ -0,0 +1,1064 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * Cross Partition Communication (XPC) support - standard version.
12 *
13 * XPC provides a message passing capability that crosses partition
14 * boundaries. This module is made up of two parts:
15 *
16 * partition This part detects the presence/absence of other
17 * partitions. It provides a heartbeat and monitors
18 * the heartbeats of other partitions.
19 *
20 * channel This part manages the channels and sends/receives
21 * messages across them to/from other partitions.
22 *
23 * There are a couple of additional functions residing in XP, which
24 * provide an interface to XPC for its users.
25 *
26 *
27 * Caveats:
28 *
29 * . We currently have no way to determine which nasid an IPI came
30 * from. Thus, xpc_IPI_send() does a remote AMO write followed by
31 * an IPI. The AMO indicates where data is to be pulled from, so
32 * after the IPI arrives, the remote partition checks the AMO word.
33 * The IPI can actually arrive before the AMO however, so other code
34 * must periodically check for this case. Also, remote AMO operations
35 * do not reliably time out. Thus we do a remote PIO read solely to
36 * know whether the remote partition is down and whether we should
37 * stop sending IPIs to it. This remote PIO read operation is set up
38 * in a special nofault region so SAL knows to ignore (and cleanup)
39 * any errors due to the remote AMO write, PIO read, and/or PIO
40 * write operations.
41 *
42 * If/when new hardware solves this IPI problem, we should abandon
43 * the current approach.
44 *
45 */
46
47
48#include <linux/kernel.h>
49#include <linux/module.h>
50#include <linux/init.h>
51#include <linux/sched.h>
52#include <linux/syscalls.h>
53#include <linux/cache.h>
54#include <linux/interrupt.h>
55#include <linux/slab.h>
56#include <asm/sn/intr.h>
57#include <asm/sn/sn_sal.h>
58#include <asm/uaccess.h>
59#include "xpc.h"
60
61
62/* define two XPC debug device structures to be used with dev_dbg() et al */
63
64struct device_driver xpc_dbg_name = {
65 .name = "xpc"
66};
67
68struct device xpc_part_dbg_subname = {
69 .bus_id = {0}, /* set to "part" at xpc_init() time */
70 .driver = &xpc_dbg_name
71};
72
73struct device xpc_chan_dbg_subname = {
74 .bus_id = {0}, /* set to "chan" at xpc_init() time */
75 .driver = &xpc_dbg_name
76};
77
78struct device *xpc_part = &xpc_part_dbg_subname;
79struct device *xpc_chan = &xpc_chan_dbg_subname;
80
81
82/* systune related variables for /proc/sys directories */
83
84static int xpc_hb_min = 1;
85static int xpc_hb_max = 10;
86
87static int xpc_hb_check_min = 10;
88static int xpc_hb_check_max = 120;
89
90static ctl_table xpc_sys_xpc_hb_dir[] = {
91 {
92 1,
93 "hb_interval",
94 &xpc_hb_interval,
95 sizeof(int),
96 0644,
97 NULL,
98 &proc_dointvec_minmax,
99 &sysctl_intvec,
100 NULL,
101 &xpc_hb_min, &xpc_hb_max
102 },
103 {
104 2,
105 "hb_check_interval",
106 &xpc_hb_check_interval,
107 sizeof(int),
108 0644,
109 NULL,
110 &proc_dointvec_minmax,
111 &sysctl_intvec,
112 NULL,
113 &xpc_hb_check_min, &xpc_hb_check_max
114 },
115 {0}
116};
117static ctl_table xpc_sys_xpc_dir[] = {
118 {
119 1,
120 "hb",
121 NULL,
122 0,
123 0555,
124 xpc_sys_xpc_hb_dir
125 },
126 {0}
127};
128static ctl_table xpc_sys_dir[] = {
129 {
130 1,
131 "xpc",
132 NULL,
133 0,
134 0555,
135 xpc_sys_xpc_dir
136 },
137 {0}
138};
139static struct ctl_table_header *xpc_sysctl;
140
141
142/* #of IRQs received */
143static atomic_t xpc_act_IRQ_rcvd;
144
145/* IRQ handler notifies this wait queue on receipt of an IRQ */
146static DECLARE_WAIT_QUEUE_HEAD(xpc_act_IRQ_wq);
147
148static unsigned long xpc_hb_check_timeout;
149
150/* xpc_hb_checker thread exited notification */
151static DECLARE_MUTEX_LOCKED(xpc_hb_checker_exited);
152
153/* xpc_discovery thread exited notification */
154static DECLARE_MUTEX_LOCKED(xpc_discovery_exited);
155
156
157static struct timer_list xpc_hb_timer;
158
159
160static void xpc_kthread_waitmsgs(struct xpc_partition *, struct xpc_channel *);
161
162
163/*
164 * Notify the heartbeat check thread that an IRQ has been received.
165 */
166static irqreturn_t
167xpc_act_IRQ_handler(int irq, void *dev_id, struct pt_regs *regs)
168{
169 atomic_inc(&xpc_act_IRQ_rcvd);
170 wake_up_interruptible(&xpc_act_IRQ_wq);
171 return IRQ_HANDLED;
172}
173
174
175/*
176 * Timer to produce the heartbeat. The timer structures function is
177 * already set when this is initially called. A tunable is used to
178 * specify when the next timeout should occur.
179 */
180static void
181xpc_hb_beater(unsigned long dummy)
182{
183 xpc_vars->heartbeat++;
184
185 if (jiffies >= xpc_hb_check_timeout) {
186 wake_up_interruptible(&xpc_act_IRQ_wq);
187 }
188
189 xpc_hb_timer.expires = jiffies + (xpc_hb_interval * HZ);
190 add_timer(&xpc_hb_timer);
191}
192
193
194/*
195 * This thread is responsible for nearly all of the partition
196 * activation/deactivation.
197 */
198static int
199xpc_hb_checker(void *ignore)
200{
201 int last_IRQ_count = 0;
202 int new_IRQ_count;
203 int force_IRQ=0;
204
205
206 /* this thread was marked active by xpc_hb_init() */
207
208 daemonize(XPC_HB_CHECK_THREAD_NAME);
209
210 set_cpus_allowed(current, cpumask_of_cpu(XPC_HB_CHECK_CPU));
211
212 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
213
214 while (!(volatile int) xpc_exiting) {
215
216 /* wait for IRQ or timeout */
217 (void) wait_event_interruptible(xpc_act_IRQ_wq,
218 (last_IRQ_count < atomic_read(&xpc_act_IRQ_rcvd) ||
219 jiffies >= xpc_hb_check_timeout ||
220 (volatile int) xpc_exiting));
221
222 dev_dbg(xpc_part, "woke up with %d ticks rem; %d IRQs have "
223 "been received\n",
224 (int) (xpc_hb_check_timeout - jiffies),
225 atomic_read(&xpc_act_IRQ_rcvd) - last_IRQ_count);
226
227
228 /* checking of remote heartbeats is skewed by IRQ handling */
229 if (jiffies >= xpc_hb_check_timeout) {
230 dev_dbg(xpc_part, "checking remote heartbeats\n");
231 xpc_check_remote_hb();
232
233 /*
234 * We need to periodically recheck to ensure no
235 * IPI/AMO pairs have been missed. That check
236 * must always reset xpc_hb_check_timeout.
237 */
238 force_IRQ = 1;
239 }
240
241
242 new_IRQ_count = atomic_read(&xpc_act_IRQ_rcvd);
243 if (last_IRQ_count < new_IRQ_count || force_IRQ != 0) {
244 force_IRQ = 0;
245
246 dev_dbg(xpc_part, "found an IRQ to process; will be "
247 "resetting xpc_hb_check_timeout\n");
248
249 last_IRQ_count += xpc_identify_act_IRQ_sender();
250 if (last_IRQ_count < new_IRQ_count) {
251 /* retry once to help avoid missing AMO */
252 (void) xpc_identify_act_IRQ_sender();
253 }
254 last_IRQ_count = new_IRQ_count;
255
256 xpc_hb_check_timeout = jiffies +
257 (xpc_hb_check_interval * HZ);
258 }
259 }
260
261 dev_dbg(xpc_part, "heartbeat checker is exiting\n");
262
263
264 /* mark this thread as inactive */
265 up(&xpc_hb_checker_exited);
266 return 0;
267}
268
269
270/*
271 * This thread will attempt to discover other partitions to activate
272 * based on info provided by SAL. This new thread is short lived and
273 * will exit once discovery is complete.
274 */
275static int
276xpc_initiate_discovery(void *ignore)
277{
278 daemonize(XPC_DISCOVERY_THREAD_NAME);
279
280 xpc_discovery();
281
282 dev_dbg(xpc_part, "discovery thread is exiting\n");
283
284 /* mark this thread as inactive */
285 up(&xpc_discovery_exited);
286 return 0;
287}
288
289
290/*
291 * Establish first contact with the remote partititon. This involves pulling
292 * the XPC per partition variables from the remote partition and waiting for
293 * the remote partition to pull ours.
294 */
295static enum xpc_retval
296xpc_make_first_contact(struct xpc_partition *part)
297{
298 enum xpc_retval ret;
299
300
301 while ((ret = xpc_pull_remote_vars_part(part)) != xpcSuccess) {
302 if (ret != xpcRetry) {
303 XPC_DEACTIVATE_PARTITION(part, ret);
304 return ret;
305 }
306
307 dev_dbg(xpc_chan, "waiting to make first contact with "
308 "partition %d\n", XPC_PARTID(part));
309
310 /* wait a 1/4 of a second or so */
311 set_current_state(TASK_INTERRUPTIBLE);
312 (void) schedule_timeout(0.25 * HZ);
313
314 if (part->act_state == XPC_P_DEACTIVATING) {
315 return part->reason;
316 }
317 }
318
319 return xpc_mark_partition_active(part);
320}
321
322
323/*
324 * The first kthread assigned to a newly activated partition is the one
325 * created by XPC HB with which it calls xpc_partition_up(). XPC hangs on to
326 * that kthread until the partition is brought down, at which time that kthread
327 * returns back to XPC HB. (The return of that kthread will signify to XPC HB
328 * that XPC has dismantled all communication infrastructure for the associated
329 * partition.) This kthread becomes the channel manager for that partition.
330 *
331 * Each active partition has a channel manager, who, besides connecting and
332 * disconnecting channels, will ensure that each of the partition's connected
333 * channels has the required number of assigned kthreads to get the work done.
334 */
335static void
336xpc_channel_mgr(struct xpc_partition *part)
337{
338 while (part->act_state != XPC_P_DEACTIVATING ||
339 atomic_read(&part->nchannels_active) > 0) {
340
341 xpc_process_channel_activity(part);
342
343
344 /*
345 * Wait until we've been requested to activate kthreads or
346 * all of the channel's message queues have been torn down or
347 * a signal is pending.
348 *
349 * The channel_mgr_requests is set to 1 after being awakened,
350 * This is done to prevent the channel mgr from making one pass
351 * through the loop for each request, since he will
352 * be servicing all the requests in one pass. The reason it's
353 * set to 1 instead of 0 is so that other kthreads will know
354 * that the channel mgr is running and won't bother trying to
355 * wake him up.
356 */
357 atomic_dec(&part->channel_mgr_requests);
358 (void) wait_event_interruptible(part->channel_mgr_wq,
359 (atomic_read(&part->channel_mgr_requests) > 0 ||
360 (volatile u64) part->local_IPI_amo != 0 ||
361 ((volatile u8) part->act_state ==
362 XPC_P_DEACTIVATING &&
363 atomic_read(&part->nchannels_active) == 0)));
364 atomic_set(&part->channel_mgr_requests, 1);
365
366 // >>> Does it need to wakeup periodically as well? In case we
367 // >>> miscalculated the #of kthreads to wakeup or create?
368 }
369}
370
371
372/*
373 * When XPC HB determines that a partition has come up, it will create a new
374 * kthread and that kthread will call this function to attempt to set up the
375 * basic infrastructure used for Cross Partition Communication with the newly
376 * upped partition.
377 *
378 * The kthread that was created by XPC HB and which setup the XPC
379 * infrastructure will remain assigned to the partition until the partition
380 * goes down. At which time the kthread will teardown the XPC infrastructure
381 * and then exit.
382 *
383 * XPC HB will put the remote partition's XPC per partition specific variables
384 * physical address into xpc_partitions[partid].remote_vars_part_pa prior to
385 * calling xpc_partition_up().
386 */
387static void
388xpc_partition_up(struct xpc_partition *part)
389{
390 DBUG_ON(part->channels != NULL);
391
392 dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part));
393
394 if (xpc_setup_infrastructure(part) != xpcSuccess) {
395 return;
396 }
397
398 /*
399 * The kthread that XPC HB called us with will become the
400 * channel manager for this partition. It will not return
401 * back to XPC HB until the partition's XPC infrastructure
402 * has been dismantled.
403 */
404
405 (void) xpc_part_ref(part); /* this will always succeed */
406
407 if (xpc_make_first_contact(part) == xpcSuccess) {
408 xpc_channel_mgr(part);
409 }
410
411 xpc_part_deref(part);
412
413 xpc_teardown_infrastructure(part);
414}
415
416
417static int
418xpc_activating(void *__partid)
419{
420 partid_t partid = (u64) __partid;
421 struct xpc_partition *part = &xpc_partitions[partid];
422 unsigned long irq_flags;
423 struct sched_param param = { sched_priority: MAX_USER_RT_PRIO - 1 };
424 int ret;
425
426
427 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
428
429 spin_lock_irqsave(&part->act_lock, irq_flags);
430
431 if (part->act_state == XPC_P_DEACTIVATING) {
432 part->act_state = XPC_P_INACTIVE;
433 spin_unlock_irqrestore(&part->act_lock, irq_flags);
434 part->remote_rp_pa = 0;
435 return 0;
436 }
437
438 /* indicate the thread is activating */
439 DBUG_ON(part->act_state != XPC_P_ACTIVATION_REQ);
440 part->act_state = XPC_P_ACTIVATING;
441
442 XPC_SET_REASON(part, 0, 0);
443 spin_unlock_irqrestore(&part->act_lock, irq_flags);
444
445 dev_dbg(xpc_part, "bringing partition %d up\n", partid);
446
447 daemonize("xpc%02d", partid);
448
449 /*
450 * This thread needs to run at a realtime priority to prevent a
451 * significant performance degradation.
452 */
453 ret = sched_setscheduler(current, SCHED_FIFO, &param);
454 if (ret != 0) {
455 dev_warn(xpc_part, "unable to set pid %d to a realtime "
456 "priority, ret=%d\n", current->pid, ret);
457 }
458
459 /* allow this thread and its children to run on any CPU */
460 set_cpus_allowed(current, CPU_MASK_ALL);
461
462 /*
463 * Register the remote partition's AMOs with SAL so it can handle
464 * and cleanup errors within that address range should the remote
465 * partition go down. We don't unregister this range because it is
466 * difficult to tell when outstanding writes to the remote partition
467 * are finished and thus when it is safe to unregister. This should
468 * not result in wasted space in the SAL xp_addr_region table because
469 * we should get the same page for remote_amos_page_pa after module
470 * reloads and system reboots.
471 */
472 if (sn_register_xp_addr_region(part->remote_amos_page_pa,
473 PAGE_SIZE, 1) < 0) {
474 dev_warn(xpc_part, "xpc_partition_up(%d) failed to register "
475 "xp_addr region\n", partid);
476
477 spin_lock_irqsave(&part->act_lock, irq_flags);
478 part->act_state = XPC_P_INACTIVE;
479 XPC_SET_REASON(part, xpcPhysAddrRegFailed, __LINE__);
480 spin_unlock_irqrestore(&part->act_lock, irq_flags);
481 part->remote_rp_pa = 0;
482 return 0;
483 }
484
485 XPC_ALLOW_HB(partid, xpc_vars);
486 xpc_IPI_send_activated(part);
487
488
489 /*
490 * xpc_partition_up() holds this thread and marks this partition as
491 * XPC_P_ACTIVE by calling xpc_hb_mark_active().
492 */
493 (void) xpc_partition_up(part);
494
495 xpc_mark_partition_inactive(part);
496
497 if (part->reason == xpcReactivating) {
498 /* interrupting ourselves results in activating partition */
499 xpc_IPI_send_reactivate(part);
500 }
501
502 return 0;
503}
504
505
506void
507xpc_activate_partition(struct xpc_partition *part)
508{
509 partid_t partid = XPC_PARTID(part);
510 unsigned long irq_flags;
511 pid_t pid;
512
513
514 spin_lock_irqsave(&part->act_lock, irq_flags);
515
516 pid = kernel_thread(xpc_activating, (void *) ((u64) partid), 0);
517
518 DBUG_ON(part->act_state != XPC_P_INACTIVE);
519
520 if (pid > 0) {
521 part->act_state = XPC_P_ACTIVATION_REQ;
522 XPC_SET_REASON(part, xpcCloneKThread, __LINE__);
523 } else {
524 XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__);
525 }
526
527 spin_unlock_irqrestore(&part->act_lock, irq_flags);
528}
529
530
531/*
532 * Handle the receipt of a SGI_XPC_NOTIFY IRQ by seeing whether the specified
533 * partition actually sent it. Since SGI_XPC_NOTIFY IRQs may be shared by more
534 * than one partition, we use an AMO_t structure per partition to indicate
535 * whether a partition has sent an IPI or not. >>> If it has, then wake up the
536 * associated kthread to handle it.
537 *
538 * All SGI_XPC_NOTIFY IRQs received by XPC are the result of IPIs sent by XPC
539 * running on other partitions.
540 *
541 * Noteworthy Arguments:
542 *
543 * irq - Interrupt ReQuest number. NOT USED.
544 *
545 * dev_id - partid of IPI's potential sender.
546 *
547 * regs - processor's context before the processor entered
548 * interrupt code. NOT USED.
549 */
550irqreturn_t
551xpc_notify_IRQ_handler(int irq, void *dev_id, struct pt_regs *regs)
552{
553 partid_t partid = (partid_t) (u64) dev_id;
554 struct xpc_partition *part = &xpc_partitions[partid];
555
556
557 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
558
559 if (xpc_part_ref(part)) {
560 xpc_check_for_channel_activity(part);
561
562 xpc_part_deref(part);
563 }
564 return IRQ_HANDLED;
565}
566
567
568/*
569 * Check to see if xpc_notify_IRQ_handler() dropped any IPIs on the floor
570 * because the write to their associated IPI amo completed after the IRQ/IPI
571 * was received.
572 */
573void
574xpc_dropped_IPI_check(struct xpc_partition *part)
575{
576 if (xpc_part_ref(part)) {
577 xpc_check_for_channel_activity(part);
578
579 part->dropped_IPI_timer.expires = jiffies +
580 XPC_P_DROPPED_IPI_WAIT;
581 add_timer(&part->dropped_IPI_timer);
582 xpc_part_deref(part);
583 }
584}
585
586
587void
588xpc_activate_kthreads(struct xpc_channel *ch, int needed)
589{
590 int idle = atomic_read(&ch->kthreads_idle);
591 int assigned = atomic_read(&ch->kthreads_assigned);
592 int wakeup;
593
594
595 DBUG_ON(needed <= 0);
596
597 if (idle > 0) {
598 wakeup = (needed > idle) ? idle : needed;
599 needed -= wakeup;
600
601 dev_dbg(xpc_chan, "wakeup %d idle kthreads, partid=%d, "
602 "channel=%d\n", wakeup, ch->partid, ch->number);
603
604 /* only wakeup the requested number of kthreads */
605 wake_up_nr(&ch->idle_wq, wakeup);
606 }
607
608 if (needed <= 0) {
609 return;
610 }
611
612 if (needed + assigned > ch->kthreads_assigned_limit) {
613 needed = ch->kthreads_assigned_limit - assigned;
614 // >>>should never be less than 0
615 if (needed <= 0) {
616 return;
617 }
618 }
619
620 dev_dbg(xpc_chan, "create %d new kthreads, partid=%d, channel=%d\n",
621 needed, ch->partid, ch->number);
622
623 xpc_create_kthreads(ch, needed);
624}
625
626
627/*
628 * This function is where XPC's kthreads wait for messages to deliver.
629 */
630static void
631xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
632{
633 do {
634 /* deliver messages to their intended recipients */
635
636 while ((volatile s64) ch->w_local_GP.get <
637 (volatile s64) ch->w_remote_GP.put &&
638 !((volatile u32) ch->flags &
639 XPC_C_DISCONNECTING)) {
640 xpc_deliver_msg(ch);
641 }
642
643 if (atomic_inc_return(&ch->kthreads_idle) >
644 ch->kthreads_idle_limit) {
645 /* too many idle kthreads on this channel */
646 atomic_dec(&ch->kthreads_idle);
647 break;
648 }
649
650 dev_dbg(xpc_chan, "idle kthread calling "
651 "wait_event_interruptible_exclusive()\n");
652
653 (void) wait_event_interruptible_exclusive(ch->idle_wq,
654 ((volatile s64) ch->w_local_GP.get <
655 (volatile s64) ch->w_remote_GP.put ||
656 ((volatile u32) ch->flags &
657 XPC_C_DISCONNECTING)));
658
659 atomic_dec(&ch->kthreads_idle);
660
661 } while (!((volatile u32) ch->flags & XPC_C_DISCONNECTING));
662}
663
664
665static int
666xpc_daemonize_kthread(void *args)
667{
668 partid_t partid = XPC_UNPACK_ARG1(args);
669 u16 ch_number = XPC_UNPACK_ARG2(args);
670 struct xpc_partition *part = &xpc_partitions[partid];
671 struct xpc_channel *ch;
672 int n_needed;
673
674
675 daemonize("xpc%02dc%d", partid, ch_number);
676
677 dev_dbg(xpc_chan, "kthread starting, partid=%d, channel=%d\n",
678 partid, ch_number);
679
680 ch = &part->channels[ch_number];
681
682 if (!(ch->flags & XPC_C_DISCONNECTING)) {
683 DBUG_ON(!(ch->flags & XPC_C_CONNECTED));
684
685 /* let registerer know that connection has been established */
686
687 if (atomic_read(&ch->kthreads_assigned) == 1) {
688 xpc_connected_callout(ch);
689
690 /*
691 * It is possible that while the callout was being
692 * made that the remote partition sent some messages.
693 * If that is the case, we may need to activate
694 * additional kthreads to help deliver them. We only
695 * need one less than total #of messages to deliver.
696 */
697 n_needed = ch->w_remote_GP.put - ch->w_local_GP.get - 1;
698 if (n_needed > 0 &&
699 !(ch->flags & XPC_C_DISCONNECTING)) {
700 xpc_activate_kthreads(ch, n_needed);
701 }
702 }
703
704 xpc_kthread_waitmsgs(part, ch);
705 }
706
707 if (atomic_dec_return(&ch->kthreads_assigned) == 0 &&
708 ((ch->flags & XPC_C_CONNECTCALLOUT) ||
709 (ch->reason != xpcUnregistering &&
710 ch->reason != xpcOtherUnregistering))) {
711 xpc_disconnected_callout(ch);
712 }
713
714
715 xpc_msgqueue_deref(ch);
716
717 dev_dbg(xpc_chan, "kthread exiting, partid=%d, channel=%d\n",
718 partid, ch_number);
719
720 xpc_part_deref(part);
721 return 0;
722}
723
724
725/*
726 * For each partition that XPC has established communications with, there is
727 * a minimum of one kernel thread assigned to perform any operation that
728 * may potentially sleep or block (basically the callouts to the asynchronous
729 * functions registered via xpc_connect()).
730 *
731 * Additional kthreads are created and destroyed by XPC as the workload
732 * demands.
733 *
734 * A kthread is assigned to one of the active channels that exists for a given
735 * partition.
736 */
737void
738xpc_create_kthreads(struct xpc_channel *ch, int needed)
739{
740 unsigned long irq_flags;
741 pid_t pid;
742 u64 args = XPC_PACK_ARGS(ch->partid, ch->number);
743
744
745 while (needed-- > 0) {
746 pid = kernel_thread(xpc_daemonize_kthread, (void *) args, 0);
747 if (pid < 0) {
748 /* the fork failed */
749
750 if (atomic_read(&ch->kthreads_assigned) <
751 ch->kthreads_idle_limit) {
752 /*
753 * Flag this as an error only if we have an
754 * insufficient #of kthreads for the channel
755 * to function.
756 *
757 * No xpc_msgqueue_ref() is needed here since
758 * the channel mgr is doing this.
759 */
760 spin_lock_irqsave(&ch->lock, irq_flags);
761 XPC_DISCONNECT_CHANNEL(ch, xpcLackOfResources,
762 &irq_flags);
763 spin_unlock_irqrestore(&ch->lock, irq_flags);
764 }
765 break;
766 }
767
768 /*
769 * The following is done on behalf of the newly created
770 * kthread. That kthread is responsible for doing the
771 * counterpart to the following before it exits.
772 */
773 (void) xpc_part_ref(&xpc_partitions[ch->partid]);
774 xpc_msgqueue_ref(ch);
775 atomic_inc(&ch->kthreads_assigned);
776 ch->kthreads_created++; // >>> temporary debug only!!!
777 }
778}
779
780
781void
782xpc_disconnect_wait(int ch_number)
783{
784 partid_t partid;
785 struct xpc_partition *part;
786 struct xpc_channel *ch;
787
788
789 /* now wait for all callouts to the caller's function to cease */
790 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
791 part = &xpc_partitions[partid];
792
793 if (xpc_part_ref(part)) {
794 ch = &part->channels[ch_number];
795
796// >>> how do we keep from falling into the window between our check and going
797// >>> down and coming back up where sema is re-inited?
798 if (ch->flags & XPC_C_SETUP) {
799 (void) down(&ch->teardown_sema);
800 }
801
802 xpc_part_deref(part);
803 }
804 }
805}
806
807
808static void
809xpc_do_exit(void)
810{
811 partid_t partid;
812 int active_part_count;
813 struct xpc_partition *part;
814
815
816 /* now it's time to eliminate our heartbeat */
817 del_timer_sync(&xpc_hb_timer);
818 xpc_vars->heartbeating_to_mask = 0;
819
820 /* indicate to others that our reserved page is uninitialized */
821 xpc_rsvd_page->vars_pa = 0;
822
823 /*
824 * Ignore all incoming interrupts. Without interupts the heartbeat
825 * checker won't activate any new partitions that may come up.
826 */
827 free_irq(SGI_XPC_ACTIVATE, NULL);
828
829 /*
830 * Cause the heartbeat checker and the discovery threads to exit.
831 * We don't want them attempting to activate new partitions as we
832 * try to deactivate the existing ones.
833 */
834 xpc_exiting = 1;
835 wake_up_interruptible(&xpc_act_IRQ_wq);
836
837 /* wait for the heartbeat checker thread to mark itself inactive */
838 down(&xpc_hb_checker_exited);
839
840 /* wait for the discovery thread to mark itself inactive */
841 down(&xpc_discovery_exited);
842
843
844 set_current_state(TASK_INTERRUPTIBLE);
845 schedule_timeout(0.3 * HZ);
846 set_current_state(TASK_RUNNING);
847
848
849 /* wait for all partitions to become inactive */
850
851 do {
852 active_part_count = 0;
853
854 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
855 part = &xpc_partitions[partid];
856 if (part->act_state != XPC_P_INACTIVE) {
857 active_part_count++;
858
859 XPC_DEACTIVATE_PARTITION(part, xpcUnloading);
860 }
861 }
862
863 if (active_part_count) {
864 set_current_state(TASK_INTERRUPTIBLE);
865 schedule_timeout(0.3 * HZ);
866 set_current_state(TASK_RUNNING);
867 }
868
869 } while (active_part_count > 0);
870
871
872 /* close down protections for IPI operations */
873 xpc_restrict_IPI_ops();
874
875
876 /* clear the interface to XPC's functions */
877 xpc_clear_interface();
878
879 if (xpc_sysctl) {
880 unregister_sysctl_table(xpc_sysctl);
881 }
882}
883
884
885int __init
886xpc_init(void)
887{
888 int ret;
889 partid_t partid;
890 struct xpc_partition *part;
891 pid_t pid;
892
893
894 /*
895 * xpc_remote_copy_buffer is used as a temporary buffer for bte_copy'ng
896 * both a partition's reserved page and its XPC variables. Its size was
897 * based on the size of a reserved page. So we need to ensure that the
898 * XPC variables will fit as well.
899 */
900 if (XPC_VARS_ALIGNED_SIZE > XPC_RSVD_PAGE_ALIGNED_SIZE) {
901 dev_err(xpc_part, "xpc_remote_copy_buffer is not big enough\n");
902 return -EPERM;
903 }
904 DBUG_ON((u64) xpc_remote_copy_buffer !=
905 L1_CACHE_ALIGN((u64) xpc_remote_copy_buffer));
906
907 snprintf(xpc_part->bus_id, BUS_ID_SIZE, "part");
908 snprintf(xpc_chan->bus_id, BUS_ID_SIZE, "chan");
909
910 xpc_sysctl = register_sysctl_table(xpc_sys_dir, 1);
911
912 /*
913 * The first few fields of each entry of xpc_partitions[] need to
914 * be initialized now so that calls to xpc_connect() and
915 * xpc_disconnect() can be made prior to the activation of any remote
916 * partition. NOTE THAT NONE OF THE OTHER FIELDS BELONGING TO THESE
917 * ENTRIES ARE MEANINGFUL UNTIL AFTER AN ENTRY'S CORRESPONDING
918 * PARTITION HAS BEEN ACTIVATED.
919 */
920 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
921 part = &xpc_partitions[partid];
922
923 DBUG_ON((u64) part != L1_CACHE_ALIGN((u64) part));
924
925 part->act_IRQ_rcvd = 0;
926 spin_lock_init(&part->act_lock);
927 part->act_state = XPC_P_INACTIVE;
928 XPC_SET_REASON(part, 0, 0);
929 part->setup_state = XPC_P_UNSET;
930 init_waitqueue_head(&part->teardown_wq);
931 atomic_set(&part->references, 0);
932 }
933
934 /*
935 * Open up protections for IPI operations (and AMO operations on
936 * Shub 1.1 systems).
937 */
938 xpc_allow_IPI_ops();
939
940 /*
941 * Interrupts being processed will increment this atomic variable and
942 * awaken the heartbeat thread which will process the interrupts.
943 */
944 atomic_set(&xpc_act_IRQ_rcvd, 0);
945
946 /*
947 * This is safe to do before the xpc_hb_checker thread has started
948 * because the handler releases a wait queue. If an interrupt is
949 * received before the thread is waiting, it will not go to sleep,
950 * but rather immediately process the interrupt.
951 */
952 ret = request_irq(SGI_XPC_ACTIVATE, xpc_act_IRQ_handler, 0,
953 "xpc hb", NULL);
954 if (ret != 0) {
955 dev_err(xpc_part, "can't register ACTIVATE IRQ handler, "
956 "errno=%d\n", -ret);
957
958 xpc_restrict_IPI_ops();
959
960 if (xpc_sysctl) {
961 unregister_sysctl_table(xpc_sysctl);
962 }
963 return -EBUSY;
964 }
965
966 /*
967 * Fill the partition reserved page with the information needed by
968 * other partitions to discover we are alive and establish initial
969 * communications.
970 */
971 xpc_rsvd_page = xpc_rsvd_page_init();
972 if (xpc_rsvd_page == NULL) {
973 dev_err(xpc_part, "could not setup our reserved page\n");
974
975 free_irq(SGI_XPC_ACTIVATE, NULL);
976 xpc_restrict_IPI_ops();
977
978 if (xpc_sysctl) {
979 unregister_sysctl_table(xpc_sysctl);
980 }
981 return -EBUSY;
982 }
983
984
985 /*
986 * Set the beating to other partitions into motion. This is
987 * the last requirement for other partitions' discovery to
988 * initiate communications with us.
989 */
990 init_timer(&xpc_hb_timer);
991 xpc_hb_timer.function = xpc_hb_beater;
992 xpc_hb_beater(0);
993
994
995 /*
996 * The real work-horse behind xpc. This processes incoming
997 * interrupts and monitors remote heartbeats.
998 */
999 pid = kernel_thread(xpc_hb_checker, NULL, 0);
1000 if (pid < 0) {
1001 dev_err(xpc_part, "failed while forking hb check thread\n");
1002
1003 /* indicate to others that our reserved page is uninitialized */
1004 xpc_rsvd_page->vars_pa = 0;
1005
1006 del_timer_sync(&xpc_hb_timer);
1007 free_irq(SGI_XPC_ACTIVATE, NULL);
1008 xpc_restrict_IPI_ops();
1009
1010 if (xpc_sysctl) {
1011 unregister_sysctl_table(xpc_sysctl);
1012 }
1013 return -EBUSY;
1014 }
1015
1016
1017 /*
1018 * Startup a thread that will attempt to discover other partitions to
1019 * activate based on info provided by SAL. This new thread is short
1020 * lived and will exit once discovery is complete.
1021 */
1022 pid = kernel_thread(xpc_initiate_discovery, NULL, 0);
1023 if (pid < 0) {
1024 dev_err(xpc_part, "failed while forking discovery thread\n");
1025
1026 /* mark this new thread as a non-starter */
1027 up(&xpc_discovery_exited);
1028
1029 xpc_do_exit();
1030 return -EBUSY;
1031 }
1032
1033
1034 /* set the interface to point at XPC's functions */
1035 xpc_set_interface(xpc_initiate_connect, xpc_initiate_disconnect,
1036 xpc_initiate_allocate, xpc_initiate_send,
1037 xpc_initiate_send_notify, xpc_initiate_received,
1038 xpc_initiate_partid_to_nasids);
1039
1040 return 0;
1041}
1042module_init(xpc_init);
1043
1044
1045void __exit
1046xpc_exit(void)
1047{
1048 xpc_do_exit();
1049}
1050module_exit(xpc_exit);
1051
1052
1053MODULE_AUTHOR("Silicon Graphics, Inc.");
1054MODULE_DESCRIPTION("Cross Partition Communication (XPC) support");
1055MODULE_LICENSE("GPL");
1056
1057module_param(xpc_hb_interval, int, 0);
1058MODULE_PARM_DESC(xpc_hb_interval, "Number of seconds between "
1059 "heartbeat increments.");
1060
1061module_param(xpc_hb_check_interval, int, 0);
1062MODULE_PARM_DESC(xpc_hb_check_interval, "Number of seconds between "
1063 "heartbeat checks.");
1064
diff --git a/arch/ia64/sn/kernel/xpc_partition.c b/arch/ia64/sn/kernel/xpc_partition.c
new file mode 100644
index 000000000000..2c3c4a8af553
--- /dev/null
+++ b/arch/ia64/sn/kernel/xpc_partition.c
@@ -0,0 +1,984 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2004-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9
10/*
11 * Cross Partition Communication (XPC) partition support.
12 *
13 * This is the part of XPC that detects the presence/absence of
14 * other partitions. It provides a heartbeat and monitors the
15 * heartbeats of other partitions.
16 *
17 */
18
19
20#include <linux/kernel.h>
21#include <linux/sysctl.h>
22#include <linux/cache.h>
23#include <linux/mmzone.h>
24#include <linux/nodemask.h>
25#include <asm/sn/bte.h>
26#include <asm/sn/intr.h>
27#include <asm/sn/sn_sal.h>
28#include <asm/sn/nodepda.h>
29#include <asm/sn/addrs.h>
30#include "xpc.h"
31
32
33/* XPC is exiting flag */
34int xpc_exiting;
35
36
37/* SH_IPI_ACCESS shub register value on startup */
38static u64 xpc_sh1_IPI_access;
39static u64 xpc_sh2_IPI_access0;
40static u64 xpc_sh2_IPI_access1;
41static u64 xpc_sh2_IPI_access2;
42static u64 xpc_sh2_IPI_access3;
43
44
45/* original protection values for each node */
46u64 xpc_prot_vec[MAX_COMPACT_NODES];
47
48
49/* this partition's reserved page */
50struct xpc_rsvd_page *xpc_rsvd_page;
51
52/* this partition's XPC variables (within the reserved page) */
53struct xpc_vars *xpc_vars;
54struct xpc_vars_part *xpc_vars_part;
55
56
57/*
58 * For performance reasons, each entry of xpc_partitions[] is cacheline
59 * aligned. And xpc_partitions[] is padded with an additional entry at the
60 * end so that the last legitimate entry doesn't share its cacheline with
61 * another variable.
62 */
63struct xpc_partition xpc_partitions[XP_MAX_PARTITIONS + 1];
64
65
66/*
67 * Generic buffer used to store a local copy of the remote partitions
68 * reserved page or XPC variables.
69 *
70 * xpc_discovery runs only once and is a seperate thread that is
71 * very likely going to be processing in parallel with receiving
72 * interrupts.
73 */
74char ____cacheline_aligned
75 xpc_remote_copy_buffer[XPC_RSVD_PAGE_ALIGNED_SIZE];
76
77
78/* systune related variables */
79int xpc_hb_interval = XPC_HB_DEFAULT_INTERVAL;
80int xpc_hb_check_interval = XPC_HB_CHECK_DEFAULT_TIMEOUT;
81
82
83/*
84 * Given a nasid, get the physical address of the partition's reserved page
85 * for that nasid. This function returns 0 on any error.
86 */
87static u64
88xpc_get_rsvd_page_pa(int nasid, u64 buf, u64 buf_size)
89{
90 bte_result_t bte_res;
91 s64 status;
92 u64 cookie = 0;
93 u64 rp_pa = nasid; /* seed with nasid */
94 u64 len = 0;
95
96
97 while (1) {
98
99 status = sn_partition_reserved_page_pa(buf, &cookie, &rp_pa,
100 &len);
101
102 dev_dbg(xpc_part, "SAL returned with status=%li, cookie="
103 "0x%016lx, address=0x%016lx, len=0x%016lx\n",
104 status, cookie, rp_pa, len);
105
106 if (status != SALRET_MORE_PASSES) {
107 break;
108 }
109
110 if (len > buf_size) {
111 dev_err(xpc_part, "len (=0x%016lx) > buf_size\n", len);
112 status = SALRET_ERROR;
113 break;
114 }
115
116 bte_res = xp_bte_copy(rp_pa, ia64_tpa(buf), buf_size,
117 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
118 if (bte_res != BTE_SUCCESS) {
119 dev_dbg(xpc_part, "xp_bte_copy failed %i\n", bte_res);
120 status = SALRET_ERROR;
121 break;
122 }
123 }
124
125 if (status != SALRET_OK) {
126 rp_pa = 0;
127 }
128 dev_dbg(xpc_part, "reserved page at phys address 0x%016lx\n", rp_pa);
129 return rp_pa;
130}
131
132
133/*
134 * Fill the partition reserved page with the information needed by
135 * other partitions to discover we are alive and establish initial
136 * communications.
137 */
138struct xpc_rsvd_page *
139xpc_rsvd_page_init(void)
140{
141 struct xpc_rsvd_page *rp;
142 AMO_t *amos_page;
143 u64 rp_pa, next_cl, nasid_array = 0;
144 int i, ret;
145
146
147 /* get the local reserved page's address */
148
149 rp_pa = xpc_get_rsvd_page_pa(cnodeid_to_nasid(0),
150 (u64) xpc_remote_copy_buffer,
151 XPC_RSVD_PAGE_ALIGNED_SIZE);
152 if (rp_pa == 0) {
153 dev_err(xpc_part, "SAL failed to locate the reserved page\n");
154 return NULL;
155 }
156 rp = (struct xpc_rsvd_page *) __va(rp_pa);
157
158 if (rp->partid != sn_partition_id) {
159 dev_err(xpc_part, "the reserved page's partid of %d should be "
160 "%d\n", rp->partid, sn_partition_id);
161 return NULL;
162 }
163
164 rp->version = XPC_RP_VERSION;
165
166 /*
167 * Place the XPC variables on the cache line following the
168 * reserved page structure.
169 */
170 next_cl = (u64) rp + XPC_RSVD_PAGE_ALIGNED_SIZE;
171 xpc_vars = (struct xpc_vars *) next_cl;
172
173 /*
174 * Before clearing xpc_vars, see if a page of AMOs had been previously
175 * allocated. If not we'll need to allocate one and set permissions
176 * so that cross-partition AMOs are allowed.
177 *
178 * The allocated AMO page needs MCA reporting to remain disabled after
179 * XPC has unloaded. To make this work, we keep a copy of the pointer
180 * to this page (i.e., amos_page) in the struct xpc_vars structure,
181 * which is pointed to by the reserved page, and re-use that saved copy
182 * on subsequent loads of XPC. This AMO page is never freed, and its
183 * memory protections are never restricted.
184 */
185 if ((amos_page = xpc_vars->amos_page) == NULL) {
186 amos_page = (AMO_t *) mspec_kalloc_page(0);
187 if (amos_page == NULL) {
188 dev_err(xpc_part, "can't allocate page of AMOs\n");
189 return NULL;
190 }
191
192 /*
193 * Open up AMO-R/W to cpu. This is done for Shub 1.1 systems
194 * when xpc_allow_IPI_ops() is called via xpc_hb_init().
195 */
196 if (!enable_shub_wars_1_1()) {
197 ret = sn_change_memprotect(ia64_tpa((u64) amos_page),
198 PAGE_SIZE, SN_MEMPROT_ACCESS_CLASS_1,
199 &nasid_array);
200 if (ret != 0) {
201 dev_err(xpc_part, "can't change memory "
202 "protections\n");
203 mspec_kfree_page((unsigned long) amos_page);
204 return NULL;
205 }
206 }
207 } else if (!IS_AMO_ADDRESS((u64) amos_page)) {
208 /*
209 * EFI's XPBOOT can also set amos_page in the reserved page,
210 * but it happens to leave it as an uncached physical address
211 * and we need it to be an uncached virtual, so we'll have to
212 * convert it.
213 */
214 if (!IS_AMO_PHYS_ADDRESS((u64) amos_page)) {
215 dev_err(xpc_part, "previously used amos_page address "
216 "is bad = 0x%p\n", (void *) amos_page);
217 return NULL;
218 }
219 amos_page = (AMO_t *) TO_AMO((u64) amos_page);
220 }
221
222 memset(xpc_vars, 0, sizeof(struct xpc_vars));
223
224 /*
225 * Place the XPC per partition specific variables on the cache line
226 * following the XPC variables structure.
227 */
228 next_cl += XPC_VARS_ALIGNED_SIZE;
229 memset((u64 *) next_cl, 0, sizeof(struct xpc_vars_part) *
230 XP_MAX_PARTITIONS);
231 xpc_vars_part = (struct xpc_vars_part *) next_cl;
232 xpc_vars->vars_part_pa = __pa(next_cl);
233
234 xpc_vars->version = XPC_V_VERSION;
235 xpc_vars->act_nasid = cpuid_to_nasid(0);
236 xpc_vars->act_phys_cpuid = cpu_physical_id(0);
237 xpc_vars->amos_page = amos_page; /* save for next load of XPC */
238
239
240 /*
241 * Initialize the activation related AMO variables.
242 */
243 xpc_vars->act_amos = xpc_IPI_init(XP_MAX_PARTITIONS);
244 for (i = 1; i < XP_NASID_MASK_WORDS; i++) {
245 xpc_IPI_init(i + XP_MAX_PARTITIONS);
246 }
247 /* export AMO page's physical address to other partitions */
248 xpc_vars->amos_page_pa = ia64_tpa((u64) xpc_vars->amos_page);
249
250 /*
251 * This signifies to the remote partition that our reserved
252 * page is initialized.
253 */
254 (volatile u64) rp->vars_pa = __pa(xpc_vars);
255
256 return rp;
257}
258
259
260/*
261 * Change protections to allow IPI operations (and AMO operations on
262 * Shub 1.1 systems).
263 */
264void
265xpc_allow_IPI_ops(void)
266{
267 int node;
268 int nasid;
269
270
271 // >>> Change SH_IPI_ACCESS code to use SAL call once it is available.
272
273 if (is_shub2()) {
274 xpc_sh2_IPI_access0 =
275 (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS0));
276 xpc_sh2_IPI_access1 =
277 (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS1));
278 xpc_sh2_IPI_access2 =
279 (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS2));
280 xpc_sh2_IPI_access3 =
281 (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH2_IPI_ACCESS3));
282
283 for_each_online_node(node) {
284 nasid = cnodeid_to_nasid(node);
285 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),
286 -1UL);
287 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),
288 -1UL);
289 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),
290 -1UL);
291 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),
292 -1UL);
293 }
294
295 } else {
296 xpc_sh1_IPI_access =
297 (u64) HUB_L((u64 *) LOCAL_MMR_ADDR(SH1_IPI_ACCESS));
298
299 for_each_online_node(node) {
300 nasid = cnodeid_to_nasid(node);
301 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),
302 -1UL);
303
304 /*
305 * Since the BIST collides with memory operations on
306 * SHUB 1.1 sn_change_memprotect() cannot be used.
307 */
308 if (enable_shub_wars_1_1()) {
309 /* open up everything */
310 xpc_prot_vec[node] = (u64) HUB_L((u64 *)
311 GLOBAL_MMR_ADDR(nasid,
312 SH1_MD_DQLP_MMR_DIR_PRIVEC0));
313 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,
314 SH1_MD_DQLP_MMR_DIR_PRIVEC0),
315 -1UL);
316 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,
317 SH1_MD_DQRP_MMR_DIR_PRIVEC0),
318 -1UL);
319 }
320 }
321 }
322}
323
324
325/*
326 * Restrict protections to disallow IPI operations (and AMO operations on
327 * Shub 1.1 systems).
328 */
329void
330xpc_restrict_IPI_ops(void)
331{
332 int node;
333 int nasid;
334
335
336 // >>> Change SH_IPI_ACCESS code to use SAL call once it is available.
337
338 if (is_shub2()) {
339
340 for_each_online_node(node) {
341 nasid = cnodeid_to_nasid(node);
342 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS0),
343 xpc_sh2_IPI_access0);
344 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS1),
345 xpc_sh2_IPI_access1);
346 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS2),
347 xpc_sh2_IPI_access2);
348 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH2_IPI_ACCESS3),
349 xpc_sh2_IPI_access3);
350 }
351
352 } else {
353
354 for_each_online_node(node) {
355 nasid = cnodeid_to_nasid(node);
356 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid, SH1_IPI_ACCESS),
357 xpc_sh1_IPI_access);
358
359 if (enable_shub_wars_1_1()) {
360 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,
361 SH1_MD_DQLP_MMR_DIR_PRIVEC0),
362 xpc_prot_vec[node]);
363 HUB_S((u64 *) GLOBAL_MMR_ADDR(nasid,
364 SH1_MD_DQRP_MMR_DIR_PRIVEC0),
365 xpc_prot_vec[node]);
366 }
367 }
368 }
369}
370
371
372/*
373 * At periodic intervals, scan through all active partitions and ensure
374 * their heartbeat is still active. If not, the partition is deactivated.
375 */
376void
377xpc_check_remote_hb(void)
378{
379 struct xpc_vars *remote_vars;
380 struct xpc_partition *part;
381 partid_t partid;
382 bte_result_t bres;
383
384
385 remote_vars = (struct xpc_vars *) xpc_remote_copy_buffer;
386
387 for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
388 if (partid == sn_partition_id) {
389 continue;
390 }
391
392 part = &xpc_partitions[partid];
393
394 if (part->act_state == XPC_P_INACTIVE ||
395 part->act_state == XPC_P_DEACTIVATING) {
396 continue;
397 }
398
399 /* pull the remote_hb cache line */
400 bres = xp_bte_copy(part->remote_vars_pa,
401 ia64_tpa((u64) remote_vars),
402 XPC_VARS_ALIGNED_SIZE,
403 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
404 if (bres != BTE_SUCCESS) {
405 XPC_DEACTIVATE_PARTITION(part,
406 xpc_map_bte_errors(bres));
407 continue;
408 }
409
410 dev_dbg(xpc_part, "partid = %d, heartbeat = %ld, last_heartbeat"
411 " = %ld, kdb_status = %ld, HB_mask = 0x%lx\n", partid,
412 remote_vars->heartbeat, part->last_heartbeat,
413 remote_vars->kdb_status,
414 remote_vars->heartbeating_to_mask);
415
416 if (((remote_vars->heartbeat == part->last_heartbeat) &&
417 (remote_vars->kdb_status == 0)) ||
418 !XPC_HB_ALLOWED(sn_partition_id, remote_vars)) {
419
420 XPC_DEACTIVATE_PARTITION(part, xpcNoHeartbeat);
421 continue;
422 }
423
424 part->last_heartbeat = remote_vars->heartbeat;
425 }
426}
427
428
429/*
430 * Get a copy of the remote partition's rsvd page.
431 *
432 * remote_rp points to a buffer that is cacheline aligned for BTE copies and
433 * assumed to be of size XPC_RSVD_PAGE_ALIGNED_SIZE.
434 */
435static enum xpc_retval
436xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
437 struct xpc_rsvd_page *remote_rp, u64 *remote_rsvd_page_pa)
438{
439 int bres, i;
440
441
442 /* get the reserved page's physical address */
443
444 *remote_rsvd_page_pa = xpc_get_rsvd_page_pa(nasid, (u64) remote_rp,
445 XPC_RSVD_PAGE_ALIGNED_SIZE);
446 if (*remote_rsvd_page_pa == 0) {
447 return xpcNoRsvdPageAddr;
448 }
449
450
451 /* pull over the reserved page structure */
452
453 bres = xp_bte_copy(*remote_rsvd_page_pa, ia64_tpa((u64) remote_rp),
454 XPC_RSVD_PAGE_ALIGNED_SIZE,
455 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
456 if (bres != BTE_SUCCESS) {
457 return xpc_map_bte_errors(bres);
458 }
459
460
461 if (discovered_nasids != NULL) {
462 for (i = 0; i < XP_NASID_MASK_WORDS; i++) {
463 discovered_nasids[i] |= remote_rp->part_nasids[i];
464 }
465 }
466
467
468 /* check that the partid is for another partition */
469
470 if (remote_rp->partid < 1 ||
471 remote_rp->partid > (XP_MAX_PARTITIONS - 1)) {
472 return xpcInvalidPartid;
473 }
474
475 if (remote_rp->partid == sn_partition_id) {
476 return xpcLocalPartid;
477 }
478
479
480 if (XPC_VERSION_MAJOR(remote_rp->version) !=
481 XPC_VERSION_MAJOR(XPC_RP_VERSION)) {
482 return xpcBadVersion;
483 }
484
485 return xpcSuccess;
486}
487
488
489/*
490 * Get a copy of the remote partition's XPC variables.
491 *
492 * remote_vars points to a buffer that is cacheline aligned for BTE copies and
493 * assumed to be of size XPC_VARS_ALIGNED_SIZE.
494 */
495static enum xpc_retval
496xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars)
497{
498 int bres;
499
500
501 if (remote_vars_pa == 0) {
502 return xpcVarsNotSet;
503 }
504
505
506 /* pull over the cross partition variables */
507
508 bres = xp_bte_copy(remote_vars_pa, ia64_tpa((u64) remote_vars),
509 XPC_VARS_ALIGNED_SIZE,
510 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
511 if (bres != BTE_SUCCESS) {
512 return xpc_map_bte_errors(bres);
513 }
514
515 if (XPC_VERSION_MAJOR(remote_vars->version) !=
516 XPC_VERSION_MAJOR(XPC_V_VERSION)) {
517 return xpcBadVersion;
518 }
519
520 return xpcSuccess;
521}
522
523
524/*
525 * Prior code has determine the nasid which generated an IPI. Inspect
526 * that nasid to determine if its partition needs to be activated or
527 * deactivated.
528 *
529 * A partition is consider "awaiting activation" if our partition
530 * flags indicate it is not active and it has a heartbeat. A
531 * partition is considered "awaiting deactivation" if our partition
532 * flags indicate it is active but it has no heartbeat or it is not
533 * sending its heartbeat to us.
534 *
535 * To determine the heartbeat, the remote nasid must have a properly
536 * initialized reserved page.
537 */
538static void
539xpc_identify_act_IRQ_req(int nasid)
540{
541 struct xpc_rsvd_page *remote_rp;
542 struct xpc_vars *remote_vars;
543 u64 remote_rsvd_page_pa;
544 u64 remote_vars_pa;
545 partid_t partid;
546 struct xpc_partition *part;
547 enum xpc_retval ret;
548
549
550 /* pull over the reserved page structure */
551
552 remote_rp = (struct xpc_rsvd_page *) xpc_remote_copy_buffer;
553
554 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rsvd_page_pa);
555 if (ret != xpcSuccess) {
556 dev_warn(xpc_part, "unable to get reserved page from nasid %d, "
557 "which sent interrupt, reason=%d\n", nasid, ret);
558 return;
559 }
560
561 remote_vars_pa = remote_rp->vars_pa;
562 partid = remote_rp->partid;
563 part = &xpc_partitions[partid];
564
565
566 /* pull over the cross partition variables */
567
568 remote_vars = (struct xpc_vars *) xpc_remote_copy_buffer;
569
570 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
571 if (ret != xpcSuccess) {
572
573 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, "
574 "which sent interrupt, reason=%d\n", nasid, ret);
575
576 XPC_DEACTIVATE_PARTITION(part, ret);
577 return;
578 }
579
580
581 part->act_IRQ_rcvd++;
582
583 dev_dbg(xpc_part, "partid for nasid %d is %d; IRQs = %d; HB = "
584 "%ld:0x%lx\n", (int) nasid, (int) partid, part->act_IRQ_rcvd,
585 remote_vars->heartbeat, remote_vars->heartbeating_to_mask);
586
587
588 if (part->act_state == XPC_P_INACTIVE) {
589
590 part->remote_rp_pa = remote_rsvd_page_pa;
591 dev_dbg(xpc_part, " remote_rp_pa = 0x%016lx\n",
592 part->remote_rp_pa);
593
594 part->remote_vars_pa = remote_vars_pa;
595 dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n",
596 part->remote_vars_pa);
597
598 part->last_heartbeat = remote_vars->heartbeat;
599 dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n",
600 part->last_heartbeat);
601
602 part->remote_vars_part_pa = remote_vars->vars_part_pa;
603 dev_dbg(xpc_part, " remote_vars_part_pa = 0x%016lx\n",
604 part->remote_vars_part_pa);
605
606 part->remote_act_nasid = remote_vars->act_nasid;
607 dev_dbg(xpc_part, " remote_act_nasid = 0x%x\n",
608 part->remote_act_nasid);
609
610 part->remote_act_phys_cpuid = remote_vars->act_phys_cpuid;
611 dev_dbg(xpc_part, " remote_act_phys_cpuid = 0x%x\n",
612 part->remote_act_phys_cpuid);
613
614 part->remote_amos_page_pa = remote_vars->amos_page_pa;
615 dev_dbg(xpc_part, " remote_amos_page_pa = 0x%lx\n",
616 part->remote_amos_page_pa);
617
618 xpc_activate_partition(part);
619
620 } else if (part->remote_amos_page_pa != remote_vars->amos_page_pa ||
621 !XPC_HB_ALLOWED(sn_partition_id, remote_vars)) {
622
623 part->reactivate_nasid = nasid;
624 XPC_DEACTIVATE_PARTITION(part, xpcReactivating);
625 }
626}
627
628
629/*
630 * Loop through the activation AMO variables and process any bits
631 * which are set. Each bit indicates a nasid sending a partition
632 * activation or deactivation request.
633 *
634 * Return #of IRQs detected.
635 */
636int
637xpc_identify_act_IRQ_sender(void)
638{
639 int word, bit;
640 u64 nasid_mask;
641 u64 nasid; /* remote nasid */
642 int n_IRQs_detected = 0;
643 AMO_t *act_amos;
644 struct xpc_rsvd_page *rp = (struct xpc_rsvd_page *) xpc_rsvd_page;
645
646
647 act_amos = xpc_vars->act_amos;
648
649
650 /* scan through act AMO variable looking for non-zero entries */
651 for (word = 0; word < XP_NASID_MASK_WORDS; word++) {
652
653 nasid_mask = xpc_IPI_receive(&act_amos[word]);
654 if (nasid_mask == 0) {
655 /* no IRQs from nasids in this variable */
656 continue;
657 }
658
659 dev_dbg(xpc_part, "AMO[%d] gave back 0x%lx\n", word,
660 nasid_mask);
661
662
663 /*
664 * If this nasid has been added to the machine since
665 * our partition was reset, this will retain the
666 * remote nasid in our reserved pages machine mask.
667 * This is used in the event of module reload.
668 */
669 rp->mach_nasids[word] |= nasid_mask;
670
671
672 /* locate the nasid(s) which sent interrupts */
673
674 for (bit = 0; bit < (8 * sizeof(u64)); bit++) {
675 if (nasid_mask & (1UL << bit)) {
676 n_IRQs_detected++;
677 nasid = XPC_NASID_FROM_W_B(word, bit);
678 dev_dbg(xpc_part, "interrupt from nasid %ld\n",
679 nasid);
680 xpc_identify_act_IRQ_req(nasid);
681 }
682 }
683 }
684 return n_IRQs_detected;
685}
686
687
688/*
689 * Mark specified partition as active.
690 */
691enum xpc_retval
692xpc_mark_partition_active(struct xpc_partition *part)
693{
694 unsigned long irq_flags;
695 enum xpc_retval ret;
696
697
698 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part));
699
700 spin_lock_irqsave(&part->act_lock, irq_flags);
701 if (part->act_state == XPC_P_ACTIVATING) {
702 part->act_state = XPC_P_ACTIVE;
703 ret = xpcSuccess;
704 } else {
705 DBUG_ON(part->reason == xpcSuccess);
706 ret = part->reason;
707 }
708 spin_unlock_irqrestore(&part->act_lock, irq_flags);
709
710 return ret;
711}
712
713
714/*
715 * Notify XPC that the partition is down.
716 */
717void
718xpc_deactivate_partition(const int line, struct xpc_partition *part,
719 enum xpc_retval reason)
720{
721 unsigned long irq_flags;
722 partid_t partid = XPC_PARTID(part);
723
724
725 spin_lock_irqsave(&part->act_lock, irq_flags);
726
727 if (part->act_state == XPC_P_INACTIVE) {
728 XPC_SET_REASON(part, reason, line);
729 spin_unlock_irqrestore(&part->act_lock, irq_flags);
730 if (reason == xpcReactivating) {
731 /* we interrupt ourselves to reactivate partition */
732 xpc_IPI_send_reactivate(part);
733 }
734 return;
735 }
736 if (part->act_state == XPC_P_DEACTIVATING) {
737 if ((part->reason == xpcUnloading && reason != xpcUnloading) ||
738 reason == xpcReactivating) {
739 XPC_SET_REASON(part, reason, line);
740 }
741 spin_unlock_irqrestore(&part->act_lock, irq_flags);
742 return;
743 }
744
745 part->act_state = XPC_P_DEACTIVATING;
746 XPC_SET_REASON(part, reason, line);
747
748 spin_unlock_irqrestore(&part->act_lock, irq_flags);
749
750 XPC_DISALLOW_HB(partid, xpc_vars);
751
752 dev_dbg(xpc_part, "bringing partition %d down, reason = %d\n", partid,
753 reason);
754
755 xpc_partition_down(part, reason);
756}
757
758
759/*
760 * Mark specified partition as active.
761 */
762void
763xpc_mark_partition_inactive(struct xpc_partition *part)
764{
765 unsigned long irq_flags;
766
767
768 dev_dbg(xpc_part, "setting partition %d to INACTIVE\n",
769 XPC_PARTID(part));
770
771 spin_lock_irqsave(&part->act_lock, irq_flags);
772 part->act_state = XPC_P_INACTIVE;
773 spin_unlock_irqrestore(&part->act_lock, irq_flags);
774 part->remote_rp_pa = 0;
775}
776
777
778/*
779 * SAL has provided a partition and machine mask. The partition mask
780 * contains a bit for each even nasid in our partition. The machine
781 * mask contains a bit for each even nasid in the entire machine.
782 *
783 * Using those two bit arrays, we can determine which nasids are
784 * known in the machine. Each should also have a reserved page
785 * initialized if they are available for partitioning.
786 */
787void
788xpc_discovery(void)
789{
790 void *remote_rp_base;
791 struct xpc_rsvd_page *remote_rp;
792 struct xpc_vars *remote_vars;
793 u64 remote_rsvd_page_pa;
794 u64 remote_vars_pa;
795 int region;
796 int max_regions;
797 int nasid;
798 struct xpc_rsvd_page *rp;
799 partid_t partid;
800 struct xpc_partition *part;
801 u64 *discovered_nasids;
802 enum xpc_retval ret;
803
804
805 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RSVD_PAGE_ALIGNED_SIZE,
806 GFP_KERNEL, &remote_rp_base);
807 if (remote_rp == NULL) {
808 return;
809 }
810 remote_vars = (struct xpc_vars *) remote_rp;
811
812
813 discovered_nasids = kmalloc(sizeof(u64) * XP_NASID_MASK_WORDS,
814 GFP_KERNEL);
815 if (discovered_nasids == NULL) {
816 kfree(remote_rp_base);
817 return;
818 }
819 memset(discovered_nasids, 0, sizeof(u64) * XP_NASID_MASK_WORDS);
820
821 rp = (struct xpc_rsvd_page *) xpc_rsvd_page;
822
823 /*
824 * The term 'region' in this context refers to the minimum number of
825 * nodes that can comprise an access protection grouping. The access
826 * protection is in regards to memory, IOI and IPI.
827 */
828//>>> move the next two #defines into either include/asm-ia64/sn/arch.h or
829//>>> include/asm-ia64/sn/addrs.h
830#define SH1_MAX_REGIONS 64
831#define SH2_MAX_REGIONS 256
832 max_regions = is_shub2() ? SH2_MAX_REGIONS : SH1_MAX_REGIONS;
833
834 for (region = 0; region < max_regions; region++) {
835
836 if ((volatile int) xpc_exiting) {
837 break;
838 }
839
840 dev_dbg(xpc_part, "searching region %d\n", region);
841
842 for (nasid = (region * sn_region_size * 2);
843 nasid < ((region + 1) * sn_region_size * 2);
844 nasid += 2) {
845
846 if ((volatile int) xpc_exiting) {
847 break;
848 }
849
850 dev_dbg(xpc_part, "checking nasid %d\n", nasid);
851
852
853 if (XPC_NASID_IN_ARRAY(nasid, rp->part_nasids)) {
854 dev_dbg(xpc_part, "PROM indicates Nasid %d is "
855 "part of the local partition; skipping "
856 "region\n", nasid);
857 break;
858 }
859
860 if (!(XPC_NASID_IN_ARRAY(nasid, rp->mach_nasids))) {
861 dev_dbg(xpc_part, "PROM indicates Nasid %d was "
862 "not on Numa-Link network at reset\n",
863 nasid);
864 continue;
865 }
866
867 if (XPC_NASID_IN_ARRAY(nasid, discovered_nasids)) {
868 dev_dbg(xpc_part, "Nasid %d is part of a "
869 "partition which was previously "
870 "discovered\n", nasid);
871 continue;
872 }
873
874
875 /* pull over the reserved page structure */
876
877 ret = xpc_get_remote_rp(nasid, discovered_nasids,
878 remote_rp, &remote_rsvd_page_pa);
879 if (ret != xpcSuccess) {
880 dev_dbg(xpc_part, "unable to get reserved page "
881 "from nasid %d, reason=%d\n", nasid,
882 ret);
883
884 if (ret == xpcLocalPartid) {
885 break;
886 }
887 continue;
888 }
889
890 remote_vars_pa = remote_rp->vars_pa;
891
892 partid = remote_rp->partid;
893 part = &xpc_partitions[partid];
894
895
896 /* pull over the cross partition variables */
897
898 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
899 if (ret != xpcSuccess) {
900 dev_dbg(xpc_part, "unable to get XPC variables "
901 "from nasid %d, reason=%d\n", nasid,
902 ret);
903
904 XPC_DEACTIVATE_PARTITION(part, ret);
905 continue;
906 }
907
908 if (part->act_state != XPC_P_INACTIVE) {
909 dev_dbg(xpc_part, "partition %d on nasid %d is "
910 "already activating\n", partid, nasid);
911 break;
912 }
913
914 /*
915 * Register the remote partition's AMOs with SAL so it
916 * can handle and cleanup errors within that address
917 * range should the remote partition go down. We don't
918 * unregister this range because it is difficult to
919 * tell when outstanding writes to the remote partition
920 * are finished and thus when it is thus safe to
921 * unregister. This should not result in wasted space
922 * in the SAL xp_addr_region table because we should
923 * get the same page for remote_act_amos_pa after
924 * module reloads and system reboots.
925 */
926 if (sn_register_xp_addr_region(
927 remote_vars->amos_page_pa,
928 PAGE_SIZE, 1) < 0) {
929 dev_dbg(xpc_part, "partition %d failed to "
930 "register xp_addr region 0x%016lx\n",
931 partid, remote_vars->amos_page_pa);
932
933 XPC_SET_REASON(part, xpcPhysAddrRegFailed,
934 __LINE__);
935 break;
936 }
937
938 /*
939 * The remote nasid is valid and available.
940 * Send an interrupt to that nasid to notify
941 * it that we are ready to begin activation.
942 */
943 dev_dbg(xpc_part, "sending an interrupt to AMO 0x%lx, "
944 "nasid %d, phys_cpuid 0x%x\n",
945 remote_vars->amos_page_pa,
946 remote_vars->act_nasid,
947 remote_vars->act_phys_cpuid);
948
949 xpc_IPI_send_activate(remote_vars);
950 }
951 }
952
953 kfree(discovered_nasids);
954 kfree(remote_rp_base);
955}
956
957
958/*
959 * Given a partid, get the nasids owned by that partition from the
960 * remote partition's reserved page.
961 */
962enum xpc_retval
963xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask)
964{
965 struct xpc_partition *part;
966 u64 part_nasid_pa;
967 int bte_res;
968
969
970 part = &xpc_partitions[partid];
971 if (part->remote_rp_pa == 0) {
972 return xpcPartitionDown;
973 }
974
975 part_nasid_pa = part->remote_rp_pa +
976 (u64) &((struct xpc_rsvd_page *) 0)->part_nasids;
977
978 bte_res = xp_bte_copy(part_nasid_pa, ia64_tpa((u64) nasid_mask),
979 L1_CACHE_ALIGN(XP_NASID_MASK_BYTES),
980 (BTE_NOTIFY | BTE_WACQUIRE), NULL);
981
982 return xpc_map_bte_errors(bte_res);
983}
984
diff --git a/arch/ia64/sn/kernel/xpnet.c b/arch/ia64/sn/kernel/xpnet.c
new file mode 100644
index 000000000000..78c13d676fa6
--- /dev/null
+++ b/arch/ia64/sn/kernel/xpnet.c
@@ -0,0 +1,715 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9
10/*
11 * Cross Partition Network Interface (XPNET) support
12 *
13 * XPNET provides a virtual network layered on top of the Cross
14 * Partition communication layer.
15 *
16 * XPNET provides direct point-to-point and broadcast-like support
17 * for an ethernet-like device. The ethernet broadcast medium is
18 * replaced with a point-to-point message structure which passes
19 * pointers to a DMA-capable block that a remote partition should
20 * retrieve and pass to the upper level networking layer.
21 *
22 */
23
24
25#include <linux/config.h>
26#include <linux/module.h>
27#include <linux/kernel.h>
28#include <linux/pci.h>
29#include <linux/init.h>
30#include <linux/ioport.h>
31#include <linux/netdevice.h>
32#include <linux/etherdevice.h>
33#include <linux/delay.h>
34#include <linux/ethtool.h>
35#include <linux/mii.h>
36#include <linux/smp.h>
37#include <linux/string.h>
38#include <asm/sn/bte.h>
39#include <asm/sn/io.h>
40#include <asm/sn/sn_sal.h>
41#include <asm/types.h>
42#include <asm/atomic.h>
43#include <asm/sn/xp.h>
44
45
46/*
47 * The message payload transferred by XPC.
48 *
49 * buf_pa is the physical address where the DMA should pull from.
50 *
51 * NOTE: for performance reasons, buf_pa should _ALWAYS_ begin on a
52 * cacheline boundary. To accomplish this, we record the number of
53 * bytes from the beginning of the first cacheline to the first useful
54 * byte of the skb (leadin_ignore) and the number of bytes from the
55 * last useful byte of the skb to the end of the last cacheline
56 * (tailout_ignore).
57 *
58 * size is the number of bytes to transfer which includes the skb->len
59 * (useful bytes of the senders skb) plus the leadin and tailout
60 */
61struct xpnet_message {
62 u16 version; /* Version for this message */
63 u16 embedded_bytes; /* #of bytes embedded in XPC message */
64 u32 magic; /* Special number indicating this is xpnet */
65 u64 buf_pa; /* phys address of buffer to retrieve */
66 u32 size; /* #of bytes in buffer */
67 u8 leadin_ignore; /* #of bytes to ignore at the beginning */
68 u8 tailout_ignore; /* #of bytes to ignore at the end */
69 unsigned char data; /* body of small packets */
70};
71
72/*
73 * Determine the size of our message, the cacheline aligned size,
74 * and then the number of message will request from XPC.
75 *
76 * XPC expects each message to exist in an individual cacheline.
77 */
78#define XPNET_MSG_SIZE (L1_CACHE_BYTES - XPC_MSG_PAYLOAD_OFFSET)
79#define XPNET_MSG_DATA_MAX \
80 (XPNET_MSG_SIZE - (u64)(&((struct xpnet_message *)0)->data))
81#define XPNET_MSG_ALIGNED_SIZE (L1_CACHE_ALIGN(XPNET_MSG_SIZE))
82#define XPNET_MSG_NENTRIES (PAGE_SIZE / XPNET_MSG_ALIGNED_SIZE)
83
84
85#define XPNET_MAX_KTHREADS (XPNET_MSG_NENTRIES + 1)
86#define XPNET_MAX_IDLE_KTHREADS (XPNET_MSG_NENTRIES + 1)
87
88/*
89 * Version number of XPNET implementation. XPNET can always talk to versions
90 * with same major #, and never talk to versions with a different version.
91 */
92#define _XPNET_VERSION(_major, _minor) (((_major) << 4) | (_minor))
93#define XPNET_VERSION_MAJOR(_v) ((_v) >> 4)
94#define XPNET_VERSION_MINOR(_v) ((_v) & 0xf)
95
96#define XPNET_VERSION _XPNET_VERSION(1,0) /* version 1.0 */
97#define XPNET_VERSION_EMBED _XPNET_VERSION(1,1) /* version 1.1 */
98#define XPNET_MAGIC 0x88786984 /* "XNET" */
99
100#define XPNET_VALID_MSG(_m) \
101 ((XPNET_VERSION_MAJOR(_m->version) == XPNET_VERSION_MAJOR(XPNET_VERSION)) \
102 && (msg->magic == XPNET_MAGIC))
103
104#define XPNET_DEVICE_NAME "xp0"
105
106
107/*
108 * When messages are queued with xpc_send_notify, a kmalloc'd buffer
109 * of the following type is passed as a notification cookie. When the
110 * notification function is called, we use the cookie to decide
111 * whether all outstanding message sends have completed. The skb can
112 * then be released.
113 */
114struct xpnet_pending_msg {
115 struct list_head free_list;
116 struct sk_buff *skb;
117 atomic_t use_count;
118};
119
120/* driver specific structure pointed to by the device structure */
121struct xpnet_dev_private {
122 struct net_device_stats stats;
123};
124
125struct net_device *xpnet_device;
126
127/*
128 * When we are notified of other partitions activating, we add them to
129 * our bitmask of partitions to which we broadcast.
130 */
131static u64 xpnet_broadcast_partitions;
132/* protect above */
133static spinlock_t xpnet_broadcast_lock = SPIN_LOCK_UNLOCKED;
134
135/*
136 * Since the Block Transfer Engine (BTE) is being used for the transfer
137 * and it relies upon cache-line size transfers, we need to reserve at
138 * least one cache-line for head and tail alignment. The BTE is
139 * limited to 8MB transfers.
140 *
141 * Testing has shown that changing MTU to greater than 64KB has no effect
142 * on TCP as the two sides negotiate a Max Segment Size that is limited
143 * to 64K. Other protocols May use packets greater than this, but for
144 * now, the default is 64KB.
145 */
146#define XPNET_MAX_MTU (0x800000UL - L1_CACHE_BYTES)
147/* 32KB has been determined to be the ideal */
148#define XPNET_DEF_MTU (0x8000UL)
149
150
151/*
152 * The partition id is encapsulated in the MAC address. The following
153 * define locates the octet the partid is in.
154 */
155#define XPNET_PARTID_OCTET 1
156#define XPNET_LICENSE_OCTET 2
157
158
159/*
160 * Define the XPNET debug device structure that is to be used with dev_dbg(),
161 * dev_err(), dev_warn(), and dev_info().
162 */
163struct device_driver xpnet_dbg_name = {
164 .name = "xpnet"
165};
166
167struct device xpnet_dbg_subname = {
168 .bus_id = {0}, /* set to "" */
169 .driver = &xpnet_dbg_name
170};
171
172struct device *xpnet = &xpnet_dbg_subname;
173
174/*
175 * Packet was recevied by XPC and forwarded to us.
176 */
177static void
178xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
179{
180 struct sk_buff *skb;
181 bte_result_t bret;
182 struct xpnet_dev_private *priv =
183 (struct xpnet_dev_private *) xpnet_device->priv;
184
185
186 if (!XPNET_VALID_MSG(msg)) {
187 /*
188 * Packet with a different XPC version. Ignore.
189 */
190 xpc_received(partid, channel, (void *) msg);
191
192 priv->stats.rx_errors++;
193
194 return;
195 }
196 dev_dbg(xpnet, "received 0x%lx, %d, %d, %d\n", msg->buf_pa, msg->size,
197 msg->leadin_ignore, msg->tailout_ignore);
198
199
200 /* reserve an extra cache line */
201 skb = dev_alloc_skb(msg->size + L1_CACHE_BYTES);
202 if (!skb) {
203 dev_err(xpnet, "failed on dev_alloc_skb(%d)\n",
204 msg->size + L1_CACHE_BYTES);
205
206 xpc_received(partid, channel, (void *) msg);
207
208 priv->stats.rx_errors++;
209
210 return;
211 }
212
213 /*
214 * The allocated skb has some reserved space.
215 * In order to use bte_copy, we need to get the
216 * skb->data pointer moved forward.
217 */
218 skb_reserve(skb, (L1_CACHE_BYTES - ((u64)skb->data &
219 (L1_CACHE_BYTES - 1)) +
220 msg->leadin_ignore));
221
222 /*
223 * Update the tail pointer to indicate data actually
224 * transferred.
225 */
226 skb_put(skb, (msg->size - msg->leadin_ignore - msg->tailout_ignore));
227
228 /*
229 * Move the data over from the the other side.
230 */
231 if ((XPNET_VERSION_MINOR(msg->version) == 1) &&
232 (msg->embedded_bytes != 0)) {
233 dev_dbg(xpnet, "copying embedded message. memcpy(0x%p, 0x%p, "
234 "%lu)\n", skb->data, &msg->data,
235 (size_t) msg->embedded_bytes);
236
237 memcpy(skb->data, &msg->data, (size_t) msg->embedded_bytes);
238 } else {
239 dev_dbg(xpnet, "transferring buffer to the skb->data area;\n\t"
240 "bte_copy(0x%p, 0x%p, %hu)\n", (void *)msg->buf_pa,
241 (void *)__pa((u64)skb->data & ~(L1_CACHE_BYTES - 1)),
242 msg->size);
243
244 bret = bte_copy(msg->buf_pa,
245 __pa((u64)skb->data & ~(L1_CACHE_BYTES - 1)),
246 msg->size, (BTE_NOTIFY | BTE_WACQUIRE), NULL);
247
248 if (bret != BTE_SUCCESS) {
249 // >>> Need better way of cleaning skb. Currently skb
250 // >>> appears in_use and we can't just call
251 // >>> dev_kfree_skb.
252 dev_err(xpnet, "bte_copy(0x%p, 0x%p, 0x%hx) returned "
253 "error=0x%x\n", (void *)msg->buf_pa,
254 (void *)__pa((u64)skb->data &
255 ~(L1_CACHE_BYTES - 1)),
256 msg->size, bret);
257
258 xpc_received(partid, channel, (void *) msg);
259
260 priv->stats.rx_errors++;
261
262 return;
263 }
264 }
265
266 dev_dbg(xpnet, "<skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
267 "skb->end=0x%p skb->len=%d\n", (void *) skb->head,
268 (void *) skb->data, (void *) skb->tail, (void *) skb->end,
269 skb->len);
270
271 skb->dev = xpnet_device;
272 skb->protocol = eth_type_trans(skb, xpnet_device);
273 skb->ip_summed = CHECKSUM_UNNECESSARY;
274
275 dev_dbg(xpnet, "passing skb to network layer; \n\tskb->head=0x%p "
276 "skb->data=0x%p skb->tail=0x%p skb->end=0x%p skb->len=%d\n",
277 (void *) skb->head, (void *) skb->data, (void *) skb->tail,
278 (void *) skb->end, skb->len);
279
280
281 xpnet_device->last_rx = jiffies;
282 priv->stats.rx_packets++;
283 priv->stats.rx_bytes += skb->len + ETH_HLEN;
284
285 netif_rx_ni(skb);
286 xpc_received(partid, channel, (void *) msg);
287}
288
289
290/*
291 * This is the handler which XPC calls during any sort of change in
292 * state or message reception on a connection.
293 */
294static void
295xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
296 void *data, void *key)
297{
298 long bp;
299
300
301 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
302 DBUG_ON(channel != XPC_NET_CHANNEL);
303
304 switch(reason) {
305 case xpcMsgReceived: /* message received */
306 DBUG_ON(data == NULL);
307
308 xpnet_receive(partid, channel, (struct xpnet_message *) data);
309 break;
310
311 case xpcConnected: /* connection completed to a partition */
312 spin_lock_bh(&xpnet_broadcast_lock);
313 xpnet_broadcast_partitions |= 1UL << (partid -1 );
314 bp = xpnet_broadcast_partitions;
315 spin_unlock_bh(&xpnet_broadcast_lock);
316
317 netif_carrier_on(xpnet_device);
318
319 dev_dbg(xpnet, "%s connection created to partition %d; "
320 "xpnet_broadcast_partitions=0x%lx\n",
321 xpnet_device->name, partid, bp);
322 break;
323
324 default:
325 spin_lock_bh(&xpnet_broadcast_lock);
326 xpnet_broadcast_partitions &= ~(1UL << (partid -1 ));
327 bp = xpnet_broadcast_partitions;
328 spin_unlock_bh(&xpnet_broadcast_lock);
329
330 if (bp == 0) {
331 netif_carrier_off(xpnet_device);
332 }
333
334 dev_dbg(xpnet, "%s disconnected from partition %d; "
335 "xpnet_broadcast_partitions=0x%lx\n",
336 xpnet_device->name, partid, bp);
337 break;
338
339 }
340}
341
342
343static int
344xpnet_dev_open(struct net_device *dev)
345{
346 enum xpc_retval ret;
347
348
349 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %d, "
350 "%d)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
351 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, XPNET_MAX_KTHREADS,
352 XPNET_MAX_IDLE_KTHREADS);
353
354 ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL,
355 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES,
356 XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS);
357 if (ret != xpcSuccess) {
358 dev_err(xpnet, "ifconfig up of %s failed on XPC connect, "
359 "ret=%d\n", dev->name, ret);
360
361 return -ENOMEM;
362 }
363
364 dev_dbg(xpnet, "ifconfig up of %s; XPC connected\n", dev->name);
365
366 return 0;
367}
368
369
370static int
371xpnet_dev_stop(struct net_device *dev)
372{
373 xpc_disconnect(XPC_NET_CHANNEL);
374
375 dev_dbg(xpnet, "ifconfig down of %s; XPC disconnected\n", dev->name);
376
377 return 0;
378}
379
380
381static int
382xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
383{
384 /* 68 comes from min TCP+IP+MAC header */
385 if ((new_mtu < 68) || (new_mtu > XPNET_MAX_MTU)) {
386 dev_err(xpnet, "ifconfig %s mtu %d failed; value must be "
387 "between 68 and %ld\n", dev->name, new_mtu,
388 XPNET_MAX_MTU);
389 return -EINVAL;
390 }
391
392 dev->mtu = new_mtu;
393 dev_dbg(xpnet, "ifconfig %s mtu set to %d\n", dev->name, new_mtu);
394 return 0;
395}
396
397
398/*
399 * Required for the net_device structure.
400 */
401static int
402xpnet_dev_set_config(struct net_device *dev, struct ifmap *new_map)
403{
404 return 0;
405}
406
407
408/*
409 * Return statistics to the caller.
410 */
411static struct net_device_stats *
412xpnet_dev_get_stats(struct net_device *dev)
413{
414 struct xpnet_dev_private *priv;
415
416
417 priv = (struct xpnet_dev_private *) dev->priv;
418
419 return &priv->stats;
420}
421
422
423/*
424 * Notification that the other end has received the message and
425 * DMA'd the skb information. At this point, they are done with
426 * our side. When all recipients are done processing, we
427 * release the skb and then release our pending message structure.
428 */
429static void
430xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel,
431 void *__qm)
432{
433 struct xpnet_pending_msg *queued_msg =
434 (struct xpnet_pending_msg *) __qm;
435
436
437 DBUG_ON(queued_msg == NULL);
438
439 dev_dbg(xpnet, "message to %d notified with reason %d\n",
440 partid, reason);
441
442 if (atomic_dec_return(&queued_msg->use_count) == 0) {
443 dev_dbg(xpnet, "all acks for skb->head=-x%p\n",
444 (void *) queued_msg->skb->head);
445
446 dev_kfree_skb_any(queued_msg->skb);
447 kfree(queued_msg);
448 }
449}
450
451
452/*
453 * Network layer has formatted a packet (skb) and is ready to place it
454 * "on the wire". Prepare and send an xpnet_message to all partitions
455 * which have connected with us and are targets of this packet.
456 *
457 * MAC-NOTE: For the XPNET driver, the MAC address contains the
458 * destination partition_id. If the destination partition id word
459 * is 0xff, this packet is to broadcast to all partitions.
460 */
461static int
462xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
463{
464 struct xpnet_pending_msg *queued_msg;
465 enum xpc_retval ret;
466 struct xpnet_message *msg;
467 u64 start_addr, end_addr;
468 long dp;
469 u8 second_mac_octet;
470 partid_t dest_partid;
471 struct xpnet_dev_private *priv;
472 u16 embedded_bytes;
473
474
475 priv = (struct xpnet_dev_private *) dev->priv;
476
477
478 dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
479 "skb->end=0x%p skb->len=%d\n", (void *) skb->head,
480 (void *) skb->data, (void *) skb->tail, (void *) skb->end,
481 skb->len);
482
483
484 /*
485 * The xpnet_pending_msg tracks how many outstanding
486 * xpc_send_notifies are relying on this skb. When none
487 * remain, release the skb.
488 */
489 queued_msg = kmalloc(sizeof(struct xpnet_pending_msg), GFP_ATOMIC);
490 if (queued_msg == NULL) {
491 dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping "
492 "packet\n", sizeof(struct xpnet_pending_msg));
493
494 priv->stats.tx_errors++;
495
496 return -ENOMEM;
497 }
498
499
500 /* get the beginning of the first cacheline and end of last */
501 start_addr = ((u64) skb->data & ~(L1_CACHE_BYTES - 1));
502 end_addr = L1_CACHE_ALIGN((u64) skb->tail);
503
504 /* calculate how many bytes to embed in the XPC message */
505 embedded_bytes = 0;
506 if (unlikely(skb->len <= XPNET_MSG_DATA_MAX)) {
507 /* skb->data does fit so embed */
508 embedded_bytes = skb->len;
509 }
510
511
512 /*
513 * Since the send occurs asynchronously, we set the count to one
514 * and begin sending. Any sends that happen to complete before
515 * we are done sending will not free the skb. We will be left
516 * with that task during exit. This also handles the case of
517 * a packet destined for a partition which is no longer up.
518 */
519 atomic_set(&queued_msg->use_count, 1);
520 queued_msg->skb = skb;
521
522
523 second_mac_octet = skb->data[XPNET_PARTID_OCTET];
524 if (second_mac_octet == 0xff) {
525 /* we are being asked to broadcast to all partitions */
526 dp = xpnet_broadcast_partitions;
527 } else if (second_mac_octet != 0) {
528 dp = xpnet_broadcast_partitions &
529 (1UL << (second_mac_octet - 1));
530 } else {
531 /* 0 is an invalid partid. Ignore */
532 dp = 0;
533 }
534 dev_dbg(xpnet, "destination Partitions mask (dp) = 0x%lx\n", dp);
535
536 /*
537 * If we wanted to allow promiscous mode to work like an
538 * unswitched network, this would be a good point to OR in a
539 * mask of partitions which should be receiving all packets.
540 */
541
542 /*
543 * Main send loop.
544 */
545 for (dest_partid = 1; dp && dest_partid < XP_MAX_PARTITIONS;
546 dest_partid++) {
547
548
549 if (!(dp & (1UL << (dest_partid - 1)))) {
550 /* not destined for this partition */
551 continue;
552 }
553
554 /* remove this partition from the destinations mask */
555 dp &= ~(1UL << (dest_partid - 1));
556
557
558 /* found a partition to send to */
559
560 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL,
561 XPC_NOWAIT, (void **)&msg);
562 if (unlikely(ret != xpcSuccess)) {
563 continue;
564 }
565
566 msg->embedded_bytes = embedded_bytes;
567 if (unlikely(embedded_bytes != 0)) {
568 msg->version = XPNET_VERSION_EMBED;
569 dev_dbg(xpnet, "calling memcpy(0x%p, 0x%p, 0x%lx)\n",
570 &msg->data, skb->data, (size_t) embedded_bytes);
571 memcpy(&msg->data, skb->data, (size_t) embedded_bytes);
572 } else {
573 msg->version = XPNET_VERSION;
574 }
575 msg->magic = XPNET_MAGIC;
576 msg->size = end_addr - start_addr;
577 msg->leadin_ignore = (u64) skb->data - start_addr;
578 msg->tailout_ignore = end_addr - (u64) skb->tail;
579 msg->buf_pa = __pa(start_addr);
580
581 dev_dbg(xpnet, "sending XPC message to %d:%d\nmsg->buf_pa="
582 "0x%lx, msg->size=%u, msg->leadin_ignore=%u, "
583 "msg->tailout_ignore=%u\n", dest_partid,
584 XPC_NET_CHANNEL, msg->buf_pa, msg->size,
585 msg->leadin_ignore, msg->tailout_ignore);
586
587
588 atomic_inc(&queued_msg->use_count);
589
590 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg,
591 xpnet_send_completed, queued_msg);
592 if (unlikely(ret != xpcSuccess)) {
593 atomic_dec(&queued_msg->use_count);
594 continue;
595 }
596
597 }
598
599 if (atomic_dec_return(&queued_msg->use_count) == 0) {
600 dev_dbg(xpnet, "no partitions to receive packet destined for "
601 "%d\n", dest_partid);
602
603
604 dev_kfree_skb(skb);
605 kfree(queued_msg);
606 }
607
608 priv->stats.tx_packets++;
609 priv->stats.tx_bytes += skb->len;
610
611 return 0;
612}
613
614
615/*
616 * Deal with transmit timeouts coming from the network layer.
617 */
618static void
619xpnet_dev_tx_timeout (struct net_device *dev)
620{
621 struct xpnet_dev_private *priv;
622
623
624 priv = (struct xpnet_dev_private *) dev->priv;
625
626 priv->stats.tx_errors++;
627 return;
628}
629
630
631static int __init
632xpnet_init(void)
633{
634 int i;
635 u32 license_num;
636 int result = -ENOMEM;
637
638
639 dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME);
640
641 /*
642 * use ether_setup() to init the majority of our device
643 * structure and then override the necessary pieces.
644 */
645 xpnet_device = alloc_netdev(sizeof(struct xpnet_dev_private),
646 XPNET_DEVICE_NAME, ether_setup);
647 if (xpnet_device == NULL) {
648 return -ENOMEM;
649 }
650
651 netif_carrier_off(xpnet_device);
652
653 xpnet_device->mtu = XPNET_DEF_MTU;
654 xpnet_device->change_mtu = xpnet_dev_change_mtu;
655 xpnet_device->open = xpnet_dev_open;
656 xpnet_device->get_stats = xpnet_dev_get_stats;
657 xpnet_device->stop = xpnet_dev_stop;
658 xpnet_device->hard_start_xmit = xpnet_dev_hard_start_xmit;
659 xpnet_device->tx_timeout = xpnet_dev_tx_timeout;
660 xpnet_device->set_config = xpnet_dev_set_config;
661
662 /*
663 * Multicast assumes the LSB of the first octet is set for multicast
664 * MAC addresses. We chose the first octet of the MAC to be unlikely
665 * to collide with any vendor's officially issued MAC.
666 */
667 xpnet_device->dev_addr[0] = 0xfe;
668 xpnet_device->dev_addr[XPNET_PARTID_OCTET] = sn_partition_id;
669 license_num = sn_partition_serial_number_val();
670 for (i = 3; i >= 0; i--) {
671 xpnet_device->dev_addr[XPNET_LICENSE_OCTET + i] =
672 license_num & 0xff;
673 license_num = license_num >> 8;
674 }
675
676 /*
677 * ether_setup() sets this to a multicast device. We are
678 * really not supporting multicast at this time.
679 */
680 xpnet_device->flags &= ~IFF_MULTICAST;
681
682 /*
683 * No need to checksum as it is a DMA transfer. The BTE will
684 * report an error if the data is not retrievable and the
685 * packet will be dropped.
686 */
687 xpnet_device->features = NETIF_F_NO_CSUM;
688
689 result = register_netdev(xpnet_device);
690 if (result != 0) {
691 free_netdev(xpnet_device);
692 }
693
694 return result;
695}
696module_init(xpnet_init);
697
698
699static void __exit
700xpnet_exit(void)
701{
702 dev_info(xpnet, "unregistering network device %s\n",
703 xpnet_device[0].name);
704
705 unregister_netdev(xpnet_device);
706
707 free_netdev(xpnet_device);
708}
709module_exit(xpnet_exit);
710
711
712MODULE_AUTHOR("Silicon Graphics, Inc.");
713MODULE_DESCRIPTION("Cross Partition Network adapter (XPNET)");
714MODULE_LICENSE("GPL");
715
diff --git a/arch/ia64/sn/pci/Makefile b/arch/ia64/sn/pci/Makefile
index b5dca0097a8e..2f915bce25f9 100644
--- a/arch/ia64/sn/pci/Makefile
+++ b/arch/ia64/sn/pci/Makefile
@@ -7,4 +7,4 @@
7# 7#
8# Makefile for the sn pci general routines. 8# Makefile for the sn pci general routines.
9 9
10obj-y := pci_dma.o pcibr/ 10obj-y := pci_dma.o tioca_provider.o pcibr/
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index f680824f819d..5da9bdbde7cb 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -12,9 +12,8 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <asm/dma.h> 13#include <asm/dma.h>
14#include <asm/sn/sn_sal.h> 14#include <asm/sn/sn_sal.h>
15#include "pci/pcibus_provider_defs.h" 15#include <asm/sn/pcibus_provider_defs.h>
16#include "pci/pcidev.h" 16#include <asm/sn/pcidev.h>
17#include "pci/pcibr_provider.h"
18 17
19#define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset) 18#define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset)
20#define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG)) 19#define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG))
@@ -79,7 +78,8 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
79{ 78{
80 void *cpuaddr; 79 void *cpuaddr;
81 unsigned long phys_addr; 80 unsigned long phys_addr;
82 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(to_pci_dev(dev)); 81 struct pci_dev *pdev = to_pci_dev(dev);
82 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
83 83
84 BUG_ON(dev->bus != &pci_bus_type); 84 BUG_ON(dev->bus != &pci_bus_type);
85 85
@@ -102,8 +102,7 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
102 * resources. 102 * resources.
103 */ 103 */
104 104
105 *dma_handle = pcibr_dma_map(pcidev_info, phys_addr, size, 105 *dma_handle = provider->dma_map_consistent(pdev, phys_addr, size);
106 SN_PCIDMA_CONSISTENT);
107 if (!*dma_handle) { 106 if (!*dma_handle) {
108 printk(KERN_ERR "%s: out of ATEs\n", __FUNCTION__); 107 printk(KERN_ERR "%s: out of ATEs\n", __FUNCTION__);
109 free_pages((unsigned long)cpuaddr, get_order(size)); 108 free_pages((unsigned long)cpuaddr, get_order(size));
@@ -127,11 +126,12 @@ EXPORT_SYMBOL(sn_dma_alloc_coherent);
127void sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 126void sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
128 dma_addr_t dma_handle) 127 dma_addr_t dma_handle)
129{ 128{
130 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(to_pci_dev(dev)); 129 struct pci_dev *pdev = to_pci_dev(dev);
130 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
131 131
132 BUG_ON(dev->bus != &pci_bus_type); 132 BUG_ON(dev->bus != &pci_bus_type);
133 133
134 pcibr_dma_unmap(pcidev_info, dma_handle, 0); 134 provider->dma_unmap(pdev, dma_handle, 0);
135 free_pages((unsigned long)cpu_addr, get_order(size)); 135 free_pages((unsigned long)cpu_addr, get_order(size));
136} 136}
137EXPORT_SYMBOL(sn_dma_free_coherent); 137EXPORT_SYMBOL(sn_dma_free_coherent);
@@ -159,12 +159,13 @@ dma_addr_t sn_dma_map_single(struct device *dev, void *cpu_addr, size_t size,
159{ 159{
160 dma_addr_t dma_addr; 160 dma_addr_t dma_addr;
161 unsigned long phys_addr; 161 unsigned long phys_addr;
162 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(to_pci_dev(dev)); 162 struct pci_dev *pdev = to_pci_dev(dev);
163 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
163 164
164 BUG_ON(dev->bus != &pci_bus_type); 165 BUG_ON(dev->bus != &pci_bus_type);
165 166
166 phys_addr = __pa(cpu_addr); 167 phys_addr = __pa(cpu_addr);
167 dma_addr = pcibr_dma_map(pcidev_info, phys_addr, size, 0); 168 dma_addr = provider->dma_map(pdev, phys_addr, size);
168 if (!dma_addr) { 169 if (!dma_addr) {
169 printk(KERN_ERR "%s: out of ATEs\n", __FUNCTION__); 170 printk(KERN_ERR "%s: out of ATEs\n", __FUNCTION__);
170 return 0; 171 return 0;
@@ -187,10 +188,12 @@ EXPORT_SYMBOL(sn_dma_map_single);
187void sn_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 188void sn_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
188 int direction) 189 int direction)
189{ 190{
190 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(to_pci_dev(dev)); 191 struct pci_dev *pdev = to_pci_dev(dev);
192 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
191 193
192 BUG_ON(dev->bus != &pci_bus_type); 194 BUG_ON(dev->bus != &pci_bus_type);
193 pcibr_dma_unmap(pcidev_info, dma_addr, direction); 195
196 provider->dma_unmap(pdev, dma_addr, direction);
194} 197}
195EXPORT_SYMBOL(sn_dma_unmap_single); 198EXPORT_SYMBOL(sn_dma_unmap_single);
196 199
@@ -207,12 +210,13 @@ void sn_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
207 int nhwentries, int direction) 210 int nhwentries, int direction)
208{ 211{
209 int i; 212 int i;
210 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(to_pci_dev(dev)); 213 struct pci_dev *pdev = to_pci_dev(dev);
214 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
211 215
212 BUG_ON(dev->bus != &pci_bus_type); 216 BUG_ON(dev->bus != &pci_bus_type);
213 217
214 for (i = 0; i < nhwentries; i++, sg++) { 218 for (i = 0; i < nhwentries; i++, sg++) {
215 pcibr_dma_unmap(pcidev_info, sg->dma_address, direction); 219 provider->dma_unmap(pdev, sg->dma_address, direction);
216 sg->dma_address = (dma_addr_t) NULL; 220 sg->dma_address = (dma_addr_t) NULL;
217 sg->dma_length = 0; 221 sg->dma_length = 0;
218 } 222 }
@@ -233,7 +237,8 @@ int sn_dma_map_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
233{ 237{
234 unsigned long phys_addr; 238 unsigned long phys_addr;
235 struct scatterlist *saved_sg = sg; 239 struct scatterlist *saved_sg = sg;
236 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(to_pci_dev(dev)); 240 struct pci_dev *pdev = to_pci_dev(dev);
241 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
237 int i; 242 int i;
238 243
239 BUG_ON(dev->bus != &pci_bus_type); 244 BUG_ON(dev->bus != &pci_bus_type);
@@ -243,8 +248,8 @@ int sn_dma_map_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
243 */ 248 */
244 for (i = 0; i < nhwentries; i++, sg++) { 249 for (i = 0; i < nhwentries; i++, sg++) {
245 phys_addr = SG_ENT_PHYS_ADDRESS(sg); 250 phys_addr = SG_ENT_PHYS_ADDRESS(sg);
246 sg->dma_address = pcibr_dma_map(pcidev_info, phys_addr, 251 sg->dma_address = provider->dma_map(pdev,
247 sg->length, 0); 252 phys_addr, sg->length);
248 253
249 if (!sg->dma_address) { 254 if (!sg->dma_address) {
250 printk(KERN_ERR "%s: out of ATEs\n", __FUNCTION__); 255 printk(KERN_ERR "%s: out of ATEs\n", __FUNCTION__);
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_ate.c b/arch/ia64/sn/pci/pcibr/pcibr_ate.c
index 9d6854666f9b..0e47bce85f2d 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_ate.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_ate.c
@@ -8,8 +8,8 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <asm/sn/sn_sal.h> 10#include <asm/sn/sn_sal.h>
11#include "pci/pcibus_provider_defs.h" 11#include <asm/sn/pcibus_provider_defs.h>
12#include "pci/pcidev.h" 12#include <asm/sn/pcidev.h>
13#include "pci/pcibr_provider.h" 13#include "pci/pcibr_provider.h"
14 14
15int pcibr_invalidate_ate = 0; /* by default don't invalidate ATE on free */ 15int pcibr_invalidate_ate = 0; /* by default don't invalidate ATE on free */
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_dma.c b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
index b1d66ac065c8..64af2b2c1787 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_dma.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
@@ -12,8 +12,8 @@
12#include <asm/sn/geo.h> 12#include <asm/sn/geo.h>
13#include "xtalk/xwidgetdev.h" 13#include "xtalk/xwidgetdev.h"
14#include "xtalk/hubdev.h" 14#include "xtalk/hubdev.h"
15#include "pci/pcibus_provider_defs.h" 15#include <asm/sn/pcibus_provider_defs.h>
16#include "pci/pcidev.h" 16#include <asm/sn/pcidev.h>
17#include "pci/tiocp.h" 17#include "pci/tiocp.h"
18#include "pci/pic.h" 18#include "pci/pic.h"
19#include "pci/pcibr_provider.h" 19#include "pci/pcibr_provider.h"
@@ -40,7 +40,7 @@ extern int sn_ioif_inited;
40 * we do not have to allocate entries in the PMU. 40 * we do not have to allocate entries in the PMU.
41 */ 41 */
42 42
43static uint64_t 43static dma_addr_t
44pcibr_dmamap_ate32(struct pcidev_info *info, 44pcibr_dmamap_ate32(struct pcidev_info *info,
45 uint64_t paddr, size_t req_size, uint64_t flags) 45 uint64_t paddr, size_t req_size, uint64_t flags)
46{ 46{
@@ -109,7 +109,7 @@ pcibr_dmamap_ate32(struct pcidev_info *info,
109 return pci_addr; 109 return pci_addr;
110} 110}
111 111
112static uint64_t 112static dma_addr_t
113pcibr_dmatrans_direct64(struct pcidev_info * info, uint64_t paddr, 113pcibr_dmatrans_direct64(struct pcidev_info * info, uint64_t paddr,
114 uint64_t dma_attributes) 114 uint64_t dma_attributes)
115{ 115{
@@ -141,7 +141,7 @@ pcibr_dmatrans_direct64(struct pcidev_info * info, uint64_t paddr,
141 141
142} 142}
143 143
144static uint64_t 144static dma_addr_t
145pcibr_dmatrans_direct32(struct pcidev_info * info, 145pcibr_dmatrans_direct32(struct pcidev_info * info,
146 uint64_t paddr, size_t req_size, uint64_t flags) 146 uint64_t paddr, size_t req_size, uint64_t flags)
147{ 147{
@@ -180,11 +180,11 @@ pcibr_dmatrans_direct32(struct pcidev_info * info,
180 * DMA mappings for Direct 64 and 32 do not have any DMA maps. 180 * DMA mappings for Direct 64 and 32 do not have any DMA maps.
181 */ 181 */
182void 182void
183pcibr_dma_unmap(struct pcidev_info *pcidev_info, dma_addr_t dma_handle, 183pcibr_dma_unmap(struct pci_dev *hwdev, dma_addr_t dma_handle, int direction)
184 int direction)
185{ 184{
186 struct pcibus_info *pcibus_info = (struct pcibus_info *)pcidev_info-> 185 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
187 pdi_pcibus_info; 186 struct pcibus_info *pcibus_info =
187 (struct pcibus_info *)pcidev_info->pdi_pcibus_info;
188 188
189 if (IS_PCI32_MAPPED(dma_handle)) { 189 if (IS_PCI32_MAPPED(dma_handle)) {
190 int ate_index; 190 int ate_index;
@@ -301,7 +301,7 @@ void sn_dma_flush(uint64_t addr)
301 spin_lock_irqsave(&((struct sn_flush_device_list *)p)-> 301 spin_lock_irqsave(&((struct sn_flush_device_list *)p)->
302 sfdl_flush_lock, flags); 302 sfdl_flush_lock, flags);
303 303
304 p->sfdl_flush_value = 0; 304 *p->sfdl_flush_addr = 0;
305 305
306 /* force an interrupt. */ 306 /* force an interrupt. */
307 *(volatile uint32_t *)(p->sfdl_force_int_addr) = 1; 307 *(volatile uint32_t *)(p->sfdl_force_int_addr) = 1;
@@ -316,64 +316,63 @@ void sn_dma_flush(uint64_t addr)
316} 316}
317 317
318/* 318/*
319 * Wrapper DMA interface. Called from pci_dma.c routines. 319 * DMA interfaces. Called from pci_dma.c routines.
320 */ 320 */
321 321
322uint64_t 322dma_addr_t
323pcibr_dma_map(struct pcidev_info * pcidev_info, unsigned long phys_addr, 323pcibr_dma_map(struct pci_dev * hwdev, unsigned long phys_addr, size_t size)
324 size_t size, unsigned int flags)
325{ 324{
326 dma_addr_t dma_handle; 325 dma_addr_t dma_handle;
327 struct pci_dev *pcidev = pcidev_info->pdi_linux_pcidev; 326 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
328
329 if (flags & SN_PCIDMA_CONSISTENT) {
330 /* sn_pci_alloc_consistent interfaces */
331 if (pcidev->dev.coherent_dma_mask == ~0UL) {
332 dma_handle =
333 pcibr_dmatrans_direct64(pcidev_info, phys_addr,
334 PCI64_ATTR_BAR);
335 } else {
336 dma_handle =
337 (dma_addr_t) pcibr_dmamap_ate32(pcidev_info,
338 phys_addr, size,
339 PCI32_ATE_BAR);
340 }
341 } else {
342 /* map_sg/map_single interfaces */
343 327
344 /* SN cannot support DMA addresses smaller than 32 bits. */ 328 /* SN cannot support DMA addresses smaller than 32 bits. */
345 if (pcidev->dma_mask < 0x7fffffff) { 329 if (hwdev->dma_mask < 0x7fffffff) {
346 return 0; 330 return 0;
347 } 331 }
348 332
349 if (pcidev->dma_mask == ~0UL) { 333 if (hwdev->dma_mask == ~0UL) {
334 /*
335 * Handle the most common case: 64 bit cards. This
336 * call should always succeed.
337 */
338
339 dma_handle = pcibr_dmatrans_direct64(pcidev_info, phys_addr,
340 PCI64_ATTR_PREF);
341 } else {
342 /* Handle 32-63 bit cards via direct mapping */
343 dma_handle = pcibr_dmatrans_direct32(pcidev_info, phys_addr,
344 size, 0);
345 if (!dma_handle) {
350 /* 346 /*
351 * Handle the most common case: 64 bit cards. This 347 * It is a 32 bit card and we cannot do direct mapping,
352 * call should always succeed. 348 * so we use an ATE.
353 */ 349 */
354 350
355 dma_handle = 351 dma_handle = pcibr_dmamap_ate32(pcidev_info, phys_addr,
356 pcibr_dmatrans_direct64(pcidev_info, phys_addr, 352 size, PCI32_ATE_PREF);
357 PCI64_ATTR_PREF);
358 } else {
359 /* Handle 32-63 bit cards via direct mapping */
360 dma_handle =
361 pcibr_dmatrans_direct32(pcidev_info, phys_addr,
362 size, 0);
363 if (!dma_handle) {
364 /*
365 * It is a 32 bit card and we cannot do direct mapping,
366 * so we use an ATE.
367 */
368
369 dma_handle =
370 pcibr_dmamap_ate32(pcidev_info, phys_addr,
371 size, PCI32_ATE_PREF);
372 }
373 } 353 }
374 } 354 }
375 355
376 return dma_handle; 356 return dma_handle;
377} 357}
378 358
359dma_addr_t
360pcibr_dma_map_consistent(struct pci_dev * hwdev, unsigned long phys_addr,
361 size_t size)
362{
363 dma_addr_t dma_handle;
364 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
365
366 if (hwdev->dev.coherent_dma_mask == ~0UL) {
367 dma_handle = pcibr_dmatrans_direct64(pcidev_info, phys_addr,
368 PCI64_ATTR_BAR);
369 } else {
370 dma_handle = (dma_addr_t) pcibr_dmamap_ate32(pcidev_info,
371 phys_addr, size,
372 PCI32_ATE_BAR);
373 }
374
375 return dma_handle;
376}
377
379EXPORT_SYMBOL(sn_dma_flush); 378EXPORT_SYMBOL(sn_dma_flush);
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
index 92bd278cf7ff..3893999d23d8 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
@@ -13,8 +13,8 @@
13#include "xtalk/xwidgetdev.h" 13#include "xtalk/xwidgetdev.h"
14#include <asm/sn/geo.h> 14#include <asm/sn/geo.h>
15#include "xtalk/hubdev.h" 15#include "xtalk/hubdev.h"
16#include "pci/pcibus_provider_defs.h" 16#include <asm/sn/pcibus_provider_defs.h>
17#include "pci/pcidev.h" 17#include <asm/sn/pcidev.h>
18#include "pci/pcibr_provider.h" 18#include "pci/pcibr_provider.h"
19#include <asm/sn/addrs.h> 19#include <asm/sn/addrs.h>
20 20
@@ -168,3 +168,23 @@ void pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info)
168 pcibr_force_interrupt(sn_irq_info); 168 pcibr_force_interrupt(sn_irq_info);
169 } 169 }
170} 170}
171
172/*
173 * Provider entries for PIC/CP
174 */
175
176struct sn_pcibus_provider pcibr_provider = {
177 .dma_map = pcibr_dma_map,
178 .dma_map_consistent = pcibr_dma_map_consistent,
179 .dma_unmap = pcibr_dma_unmap,
180 .bus_fixup = pcibr_bus_fixup,
181};
182
183int
184pcibr_init_provider(void)
185{
186 sn_pci_provider[PCIIO_ASIC_TYPE_PIC] = &pcibr_provider;
187 sn_pci_provider[PCIIO_ASIC_TYPE_TIOCP] = &pcibr_provider;
188
189 return 0;
190}
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_reg.c b/arch/ia64/sn/pci/pcibr/pcibr_reg.c
index 74a74a7d2a13..865c11c3b50a 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_reg.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_reg.c
@@ -8,8 +8,8 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include "pci/pcibus_provider_defs.h" 11#include <asm/sn/pcibus_provider_defs.h>
12#include "pci/pcidev.h" 12#include <asm/sn/pcidev.h>
13#include "pci/tiocp.h" 13#include "pci/tiocp.h"
14#include "pci/pic.h" 14#include "pci/pic.h"
15#include "pci/pcibr_provider.h" 15#include "pci/pcibr_provider.h"
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
new file mode 100644
index 000000000000..8dae9eb45456
--- /dev/null
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -0,0 +1,668 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9#include <linux/types.h>
10#include <linux/interrupt.h>
11#include <linux/pci.h>
12#include <asm/sn/sn_sal.h>
13#include <asm/sn/addrs.h>
14#include <asm/sn/pcidev.h>
15#include <asm/sn/pcibus_provider_defs.h>
16#include <asm/sn/tioca_provider.h>
17
18uint32_t tioca_gart_found;
19EXPORT_SYMBOL(tioca_gart_found); /* used by agp-sgi */
20
21LIST_HEAD(tioca_list);
22EXPORT_SYMBOL(tioca_list); /* used by agp-sgi */
23
24static int tioca_gart_init(struct tioca_kernel *);
25
26/**
27 * tioca_gart_init - Initialize SGI TIOCA GART
28 * @tioca_common: ptr to common prom/kernel struct identifying the
29 *
30 * If the indicated tioca has devices present, initialize its associated
31 * GART MMR's and kernel memory.
32 */
33static int
34tioca_gart_init(struct tioca_kernel *tioca_kern)
35{
36 uint64_t ap_reg;
37 uint64_t offset;
38 struct page *tmp;
39 struct tioca_common *tioca_common;
40 volatile struct tioca *ca_base;
41
42 tioca_common = tioca_kern->ca_common;
43 ca_base = (struct tioca *)tioca_common->ca_common.bs_base;
44
45 if (list_empty(tioca_kern->ca_devices))
46 return 0;
47
48 ap_reg = 0;
49
50 /*
51 * Validate aperature size
52 */
53
54 switch (CA_APERATURE_SIZE >> 20) {
55 case 4:
56 ap_reg |= (0x3ff << CA_GART_AP_SIZE_SHFT); /* 4MB */
57 break;
58 case 8:
59 ap_reg |= (0x3fe << CA_GART_AP_SIZE_SHFT); /* 8MB */
60 break;
61 case 16:
62 ap_reg |= (0x3fc << CA_GART_AP_SIZE_SHFT); /* 16MB */
63 break;
64 case 32:
65 ap_reg |= (0x3f8 << CA_GART_AP_SIZE_SHFT); /* 32 MB */
66 break;
67 case 64:
68 ap_reg |= (0x3f0 << CA_GART_AP_SIZE_SHFT); /* 64 MB */
69 break;
70 case 128:
71 ap_reg |= (0x3e0 << CA_GART_AP_SIZE_SHFT); /* 128 MB */
72 break;
73 case 256:
74 ap_reg |= (0x3c0 << CA_GART_AP_SIZE_SHFT); /* 256 MB */
75 break;
76 case 512:
77 ap_reg |= (0x380 << CA_GART_AP_SIZE_SHFT); /* 512 MB */
78 break;
79 case 1024:
80 ap_reg |= (0x300 << CA_GART_AP_SIZE_SHFT); /* 1GB */
81 break;
82 case 2048:
83 ap_reg |= (0x200 << CA_GART_AP_SIZE_SHFT); /* 2GB */
84 break;
85 case 4096:
86 ap_reg |= (0x000 << CA_GART_AP_SIZE_SHFT); /* 4 GB */
87 break;
88 default:
89 printk(KERN_ERR "%s: Invalid CA_APERATURE_SIZE "
90 "0x%lx\n", __FUNCTION__, (ulong) CA_APERATURE_SIZE);
91 return -1;
92 }
93
94 /*
95 * Set up other aperature parameters
96 */
97
98 if (PAGE_SIZE >= 16384) {
99 tioca_kern->ca_ap_pagesize = 16384;
100 ap_reg |= CA_GART_PAGE_SIZE;
101 } else {
102 tioca_kern->ca_ap_pagesize = 4096;
103 }
104
105 tioca_kern->ca_ap_size = CA_APERATURE_SIZE;
106 tioca_kern->ca_ap_bus_base = CA_APERATURE_BASE;
107 tioca_kern->ca_gart_entries =
108 tioca_kern->ca_ap_size / tioca_kern->ca_ap_pagesize;
109
110 ap_reg |= (CA_GART_AP_ENB_AGP | CA_GART_AP_ENB_PCI);
111 ap_reg |= tioca_kern->ca_ap_bus_base;
112
113 /*
114 * Allocate and set up the GART
115 */
116
117 tioca_kern->ca_gart_size = tioca_kern->ca_gart_entries * sizeof(u64);
118 tmp =
119 alloc_pages_node(tioca_kern->ca_closest_node,
120 GFP_KERNEL | __GFP_ZERO,
121 get_order(tioca_kern->ca_gart_size));
122
123 if (!tmp) {
124 printk(KERN_ERR "%s: Could not allocate "
125 "%lu bytes (order %d) for GART\n",
126 __FUNCTION__,
127 tioca_kern->ca_gart_size,
128 get_order(tioca_kern->ca_gart_size));
129 return -ENOMEM;
130 }
131
132 tioca_kern->ca_gart = page_address(tmp);
133 tioca_kern->ca_gart_coretalk_addr =
134 PHYS_TO_TIODMA(virt_to_phys(tioca_kern->ca_gart));
135
136 /*
137 * Compute PCI/AGP convenience fields
138 */
139
140 offset = CA_PCI32_MAPPED_BASE - CA_APERATURE_BASE;
141 tioca_kern->ca_pciap_base = CA_PCI32_MAPPED_BASE;
142 tioca_kern->ca_pciap_size = CA_PCI32_MAPPED_SIZE;
143 tioca_kern->ca_pcigart_start = offset / tioca_kern->ca_ap_pagesize;
144 tioca_kern->ca_pcigart_base =
145 tioca_kern->ca_gart_coretalk_addr + offset;
146 tioca_kern->ca_pcigart =
147 &tioca_kern->ca_gart[tioca_kern->ca_pcigart_start];
148 tioca_kern->ca_pcigart_entries =
149 tioca_kern->ca_pciap_size / tioca_kern->ca_ap_pagesize;
150 tioca_kern->ca_pcigart_pagemap =
151 kcalloc(1, tioca_kern->ca_pcigart_entries / 8, GFP_KERNEL);
152 if (!tioca_kern->ca_pcigart_pagemap) {
153 free_pages((unsigned long)tioca_kern->ca_gart,
154 get_order(tioca_kern->ca_gart_size));
155 return -1;
156 }
157
158 offset = CA_AGP_MAPPED_BASE - CA_APERATURE_BASE;
159 tioca_kern->ca_gfxap_base = CA_AGP_MAPPED_BASE;
160 tioca_kern->ca_gfxap_size = CA_AGP_MAPPED_SIZE;
161 tioca_kern->ca_gfxgart_start = offset / tioca_kern->ca_ap_pagesize;
162 tioca_kern->ca_gfxgart_base =
163 tioca_kern->ca_gart_coretalk_addr + offset;
164 tioca_kern->ca_gfxgart =
165 &tioca_kern->ca_gart[tioca_kern->ca_gfxgart_start];
166 tioca_kern->ca_gfxgart_entries =
167 tioca_kern->ca_gfxap_size / tioca_kern->ca_ap_pagesize;
168
169 /*
170 * various control settings:
171 * use agp op-combining
172 * use GET semantics to fetch memory
173 * participate in coherency domain
174 * DISABLE GART PREFETCHING due to hw bug tracked in SGI PV930029
175 */
176
177 ca_base->ca_control1 |= CA_AGPDMA_OP_ENB_COMBDELAY; /* PV895469 ? */
178 ca_base->ca_control2 &= ~(CA_GART_MEM_PARAM);
179 ca_base->ca_control2 |= (0x2ull << CA_GART_MEM_PARAM_SHFT);
180 tioca_kern->ca_gart_iscoherent = 1;
181 ca_base->ca_control2 &=
182 ~(CA_GART_WR_PREFETCH_ENB | CA_GART_RD_PREFETCH_ENB);
183
184 /*
185 * Unmask GART fetch error interrupts. Clear residual errors first.
186 */
187
188 ca_base->ca_int_status_alias = CA_GART_FETCH_ERR;
189 ca_base->ca_mult_error_alias = CA_GART_FETCH_ERR;
190 ca_base->ca_int_mask &= ~CA_GART_FETCH_ERR;
191
192 /*
193 * Program the aperature and gart registers in TIOCA
194 */
195
196 ca_base->ca_gart_aperature = ap_reg;
197 ca_base->ca_gart_ptr_table = tioca_kern->ca_gart_coretalk_addr | 1;
198
199 return 0;
200}
201
202/**
203 * tioca_fastwrite_enable - enable AGP FW for a tioca and its functions
204 * @tioca_kernel: structure representing the CA
205 *
206 * Given a CA, scan all attached functions making sure they all support
207 * FastWrite. If so, enable FastWrite for all functions and the CA itself.
208 */
209
210void
211tioca_fastwrite_enable(struct tioca_kernel *tioca_kern)
212{
213 int cap_ptr;
214 uint64_t ca_control1;
215 uint32_t reg;
216 struct tioca *tioca_base;
217 struct pci_dev *pdev;
218 struct tioca_common *common;
219
220 common = tioca_kern->ca_common;
221
222 /*
223 * Scan all vga controllers on this bus making sure they all
224 * suport FW. If not, return.
225 */
226
227 list_for_each_entry(pdev, tioca_kern->ca_devices, bus_list) {
228 if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8))
229 continue;
230
231 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
232 if (!cap_ptr)
233 return; /* no AGP CAP means no FW */
234
235 pci_read_config_dword(pdev, cap_ptr + PCI_AGP_STATUS, &reg);
236 if (!(reg & PCI_AGP_STATUS_FW))
237 return; /* function doesn't support FW */
238 }
239
240 /*
241 * Set fw for all vga fn's
242 */
243
244 list_for_each_entry(pdev, tioca_kern->ca_devices, bus_list) {
245 if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8))
246 continue;
247
248 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
249 pci_read_config_dword(pdev, cap_ptr + PCI_AGP_COMMAND, &reg);
250 reg |= PCI_AGP_COMMAND_FW;
251 pci_write_config_dword(pdev, cap_ptr + PCI_AGP_COMMAND, reg);
252 }
253
254 /*
255 * Set ca's fw to match
256 */
257
258 tioca_base = (struct tioca *)common->ca_common.bs_base;
259 ca_control1 = tioca_base->ca_control1;
260 ca_control1 |= CA_AGP_FW_ENABLE;
261 tioca_base->ca_control1 = ca_control1;
262}
263
264EXPORT_SYMBOL(tioca_fastwrite_enable); /* used by agp-sgi */
265
266/**
267 * tioca_dma_d64 - create a DMA mapping using 64-bit direct mode
268 * @paddr: system physical address
269 *
270 * Map @paddr into 64-bit CA bus space. No device context is necessary.
271 * Bits 53:0 come from the coretalk address. We just need to mask in the
272 * following optional bits of the 64-bit pci address:
273 *
274 * 63:60 - Coretalk Packet Type - 0x1 for Mem Get/Put (coherent)
275 * 0x2 for PIO (non-coherent)
276 * We will always use 0x1
277 * 55:55 - Swap bytes Currently unused
278 */
279static uint64_t
280tioca_dma_d64(unsigned long paddr)
281{
282 dma_addr_t bus_addr;
283
284 bus_addr = PHYS_TO_TIODMA(paddr);
285
286 BUG_ON(!bus_addr);
287 BUG_ON(bus_addr >> 54);
288
289 /* Set upper nibble to Cache Coherent Memory op */
290 bus_addr |= (1UL << 60);
291
292 return bus_addr;
293}
294
295/**
296 * tioca_dma_d48 - create a DMA mapping using 48-bit direct mode
297 * @pdev: linux pci_dev representing the function
298 * @paddr: system physical address
299 *
300 * Map @paddr into 64-bit bus space of the CA associated with @pcidev_info.
301 *
302 * The CA agp 48 bit direct address falls out as follows:
303 *
304 * When direct mapping AGP addresses, the 48 bit AGP address is
305 * constructed as follows:
306 *
307 * [47:40] - Low 8 bits of the page Node ID extracted from coretalk
308 * address [47:40]. The upper 8 node bits are fixed
309 * and come from the xxx register bits [5:0]
310 * [39:38] - Chiplet ID extracted from coretalk address [39:38]
311 * [37:00] - node offset extracted from coretalk address [37:00]
312 *
313 * Since the node id in general will be non-zero, and the chiplet id
314 * will always be non-zero, it follows that the device must support
315 * a dma mask of at least 0xffffffffff (40 bits) to target node 0
316 * and in general should be 0xffffffffffff (48 bits) to target nodes
317 * up to 255. Nodes above 255 need the support of the xxx register,
318 * and so a given CA can only directly target nodes in the range
319 * xxx - xxx+255.
320 */
321static uint64_t
322tioca_dma_d48(struct pci_dev *pdev, uint64_t paddr)
323{
324 struct tioca_common *tioca_common;
325 struct tioca *ca_base;
326 uint64_t ct_addr;
327 dma_addr_t bus_addr;
328 uint32_t node_upper;
329 uint64_t agp_dma_extn;
330 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);
331
332 tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info;
333 ca_base = (struct tioca *)tioca_common->ca_common.bs_base;
334
335 ct_addr = PHYS_TO_TIODMA(paddr);
336 if (!ct_addr)
337 return 0;
338
339 bus_addr = (dma_addr_t) (ct_addr & 0xffffffffffff);
340 node_upper = ct_addr >> 48;
341
342 if (node_upper > 64) {
343 printk(KERN_ERR "%s: coretalk addr 0x%p node id out "
344 "of range\n", __FUNCTION__, (void *)ct_addr);
345 return 0;
346 }
347
348 agp_dma_extn = ca_base->ca_agp_dma_addr_extn;
349 if (node_upper != (agp_dma_extn >> CA_AGP_DMA_NODE_ID_SHFT)) {
350 printk(KERN_ERR "%s: coretalk upper node (%u) "
351 "mismatch with ca_agp_dma_addr_extn (%lu)\n",
352 __FUNCTION__,
353 node_upper, (agp_dma_extn >> CA_AGP_DMA_NODE_ID_SHFT));
354 return 0;
355 }
356
357 return bus_addr;
358}
359
360/**
361 * tioca_dma_mapped - create a DMA mapping using a CA GART
362 * @pdev: linux pci_dev representing the function
363 * @paddr: host physical address to map
364 * @req_size: len (bytes) to map
365 *
366 * Map @paddr into CA address space using the GART mechanism. The mapped
367 * dma_addr_t is guarenteed to be contiguous in CA bus space.
368 */
369static dma_addr_t
370tioca_dma_mapped(struct pci_dev *pdev, uint64_t paddr, size_t req_size)
371{
372 int i, ps, ps_shift, entry, entries, mapsize, last_entry;
373 uint64_t xio_addr, end_xio_addr;
374 struct tioca_common *tioca_common;
375 struct tioca_kernel *tioca_kern;
376 dma_addr_t bus_addr = 0;
377 struct tioca_dmamap *ca_dmamap;
378 void *map;
379 unsigned long flags;
380 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);;
381
382 tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info;
383 tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private;
384
385 xio_addr = PHYS_TO_TIODMA(paddr);
386 if (!xio_addr)
387 return 0;
388
389 spin_lock_irqsave(&tioca_kern->ca_lock, flags);
390
391 /*
392 * allocate a map struct
393 */
394
395 ca_dmamap = kcalloc(1, sizeof(struct tioca_dmamap), GFP_ATOMIC);
396 if (!ca_dmamap)
397 goto map_return;
398
399 /*
400 * Locate free entries that can hold req_size. Account for
401 * unaligned start/length when allocating.
402 */
403
404 ps = tioca_kern->ca_ap_pagesize; /* will be power of 2 */
405 ps_shift = ffs(ps) - 1;
406 end_xio_addr = xio_addr + req_size - 1;
407
408 entries = (end_xio_addr >> ps_shift) - (xio_addr >> ps_shift) + 1;
409
410 map = tioca_kern->ca_pcigart_pagemap;
411 mapsize = tioca_kern->ca_pcigart_entries;
412
413 entry = find_first_zero_bit(map, mapsize);
414 while (entry < mapsize) {
415 last_entry = find_next_bit(map, mapsize, entry);
416
417 if (last_entry - entry >= entries)
418 break;
419
420 entry = find_next_zero_bit(map, mapsize, last_entry);
421 }
422
423 if (entry > mapsize)
424 goto map_return;
425
426 for (i = 0; i < entries; i++)
427 set_bit(entry + i, map);
428
429 bus_addr = tioca_kern->ca_pciap_base + (entry * ps);
430
431 ca_dmamap->cad_dma_addr = bus_addr;
432 ca_dmamap->cad_gart_size = entries;
433 ca_dmamap->cad_gart_entry = entry;
434 list_add(&ca_dmamap->cad_list, &tioca_kern->ca_dmamaps);
435
436 if (xio_addr % ps) {
437 tioca_kern->ca_pcigart[entry] = tioca_paddr_to_gart(xio_addr);
438 bus_addr += xio_addr & (ps - 1);
439 xio_addr &= ~(ps - 1);
440 xio_addr += ps;
441 entry++;
442 }
443
444 while (xio_addr < end_xio_addr) {
445 tioca_kern->ca_pcigart[entry] = tioca_paddr_to_gart(xio_addr);
446 xio_addr += ps;
447 entry++;
448 }
449
450 tioca_tlbflush(tioca_kern);
451
452map_return:
453 spin_unlock_irqrestore(&tioca_kern->ca_lock, flags);
454 return bus_addr;
455}
456
457/**
458 * tioca_dma_unmap - release CA mapping resources
459 * @pdev: linux pci_dev representing the function
460 * @bus_addr: bus address returned by an earlier tioca_dma_map
461 * @dir: mapping direction (unused)
462 *
463 * Locate mapping resources associated with @bus_addr and release them.
464 * For mappings created using the direct modes (64 or 48) there are no
465 * resources to release.
466 */
467void
468tioca_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr, int dir)
469{
470 int i, entry;
471 struct tioca_common *tioca_common;
472 struct tioca_kernel *tioca_kern;
473 struct tioca_dmamap *map;
474 struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);
475 unsigned long flags;
476
477 tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info;
478 tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private;
479
480 /* return straight away if this isn't be a mapped address */
481
482 if (bus_addr < tioca_kern->ca_pciap_base ||
483 bus_addr >= (tioca_kern->ca_pciap_base + tioca_kern->ca_pciap_size))
484 return;
485
486 spin_lock_irqsave(&tioca_kern->ca_lock, flags);
487
488 list_for_each_entry(map, &tioca_kern->ca_dmamaps, cad_list)
489 if (map->cad_dma_addr == bus_addr)
490 break;
491
492 BUG_ON(map == NULL);
493
494 entry = map->cad_gart_entry;
495
496 for (i = 0; i < map->cad_gart_size; i++, entry++) {
497 clear_bit(entry, tioca_kern->ca_pcigart_pagemap);
498 tioca_kern->ca_pcigart[entry] = 0;
499 }
500 tioca_tlbflush(tioca_kern);
501
502 list_del(&map->cad_list);
503 spin_unlock_irqrestore(&tioca_kern->ca_lock, flags);
504 kfree(map);
505}
506
507/**
508 * tioca_dma_map - map pages for PCI DMA
509 * @pdev: linux pci_dev representing the function
510 * @paddr: host physical address to map
511 * @byte_count: bytes to map
512 *
513 * This is the main wrapper for mapping host physical pages to CA PCI space.
514 * The mapping mode used is based on the devices dma_mask. As a last resort
515 * use the GART mapped mode.
516 */
517uint64_t
518tioca_dma_map(struct pci_dev *pdev, uint64_t paddr, size_t byte_count)
519{
520 uint64_t mapaddr;
521
522 /*
523 * If card is 64 or 48 bit addresable, use a direct mapping. 32
524 * bit direct is so restrictive w.r.t. where the memory resides that
525 * we don't use it even though CA has some support.
526 */
527
528 if (pdev->dma_mask == ~0UL)
529 mapaddr = tioca_dma_d64(paddr);
530 else if (pdev->dma_mask == 0xffffffffffffUL)
531 mapaddr = tioca_dma_d48(pdev, paddr);
532 else
533 mapaddr = 0;
534
535 /* Last resort ... use PCI portion of CA GART */
536
537 if (mapaddr == 0)
538 mapaddr = tioca_dma_mapped(pdev, paddr, byte_count);
539
540 return mapaddr;
541}
542
543/**
544 * tioca_error_intr_handler - SGI TIO CA error interrupt handler
545 * @irq: unused
546 * @arg: pointer to tioca_common struct for the given CA
547 * @pt: unused
548 *
549 * Handle a CA error interrupt. Simply a wrapper around a SAL call which
550 * defers processing to the SGI prom.
551 */
552static irqreturn_t
553tioca_error_intr_handler(int irq, void *arg, struct pt_regs *pt)
554{
555 struct tioca_common *soft = arg;
556 struct ia64_sal_retval ret_stuff;
557 uint64_t segment;
558 uint64_t busnum;
559 ret_stuff.status = 0;
560 ret_stuff.v0 = 0;
561
562 segment = 0;
563 busnum = soft->ca_common.bs_persist_busnum;
564
565 SAL_CALL_NOLOCK(ret_stuff,
566 (u64) SN_SAL_IOIF_ERROR_INTERRUPT,
567 segment, busnum, 0, 0, 0, 0, 0);
568
569 return IRQ_HANDLED;
570}
571
572/**
573 * tioca_bus_fixup - perform final PCI fixup for a TIO CA bus
574 * @prom_bussoft: Common prom/kernel struct representing the bus
575 *
576 * Replicates the tioca_common pointed to by @prom_bussoft in kernel
577 * space. Allocates and initializes a kernel-only area for a given CA,
578 * and sets up an irq for handling CA error interrupts.
579 *
580 * On successful setup, returns the kernel version of tioca_common back to
581 * the caller.
582 */
583void *
584tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft)
585{
586 struct tioca_common *tioca_common;
587 struct tioca_kernel *tioca_kern;
588 struct pci_bus *bus;
589
590 /* sanity check prom rev */
591
592 if (sn_sal_rev_major() < 4 ||
593 (sn_sal_rev_major() == 4 && sn_sal_rev_minor() < 6)) {
594 printk
595 (KERN_ERR "%s: SGI prom rev 4.06 or greater required "
596 "for tioca support\n", __FUNCTION__);
597 return NULL;
598 }
599
600 /*
601 * Allocate kernel bus soft and copy from prom.
602 */
603
604 tioca_common = kcalloc(1, sizeof(struct tioca_common), GFP_KERNEL);
605 if (!tioca_common)
606 return NULL;
607
608 memcpy(tioca_common, prom_bussoft, sizeof(struct tioca_common));
609 tioca_common->ca_common.bs_base |= __IA64_UNCACHED_OFFSET;
610
611 /* init kernel-private area */
612
613 tioca_kern = kcalloc(1, sizeof(struct tioca_kernel), GFP_KERNEL);
614 if (!tioca_kern) {
615 kfree(tioca_common);
616 return NULL;
617 }
618
619 tioca_kern->ca_common = tioca_common;
620 spin_lock_init(&tioca_kern->ca_lock);
621 INIT_LIST_HEAD(&tioca_kern->ca_dmamaps);
622 tioca_kern->ca_closest_node =
623 nasid_to_cnodeid(tioca_common->ca_closest_nasid);
624 tioca_common->ca_kernel_private = (uint64_t) tioca_kern;
625
626 bus = pci_find_bus(0, tioca_common->ca_common.bs_persist_busnum);
627 BUG_ON(!bus);
628 tioca_kern->ca_devices = &bus->devices;
629
630 /* init GART */
631
632 if (tioca_gart_init(tioca_kern) < 0) {
633 kfree(tioca_kern);
634 kfree(tioca_common);
635 return NULL;
636 }
637
638 tioca_gart_found++;
639 list_add(&tioca_kern->ca_list, &tioca_list);
640
641 if (request_irq(SGI_TIOCA_ERROR,
642 tioca_error_intr_handler,
643 SA_SHIRQ, "TIOCA error", (void *)tioca_common))
644 printk(KERN_WARNING
645 "%s: Unable to get irq %d. "
646 "Error interrupts won't be routed for TIOCA bus %d\n",
647 __FUNCTION__, SGI_TIOCA_ERROR,
648 (int)tioca_common->ca_common.bs_persist_busnum);
649
650 return tioca_common;
651}
652
653static struct sn_pcibus_provider tioca_pci_interfaces = {
654 .dma_map = tioca_dma_map,
655 .dma_map_consistent = tioca_dma_map,
656 .dma_unmap = tioca_dma_unmap,
657 .bus_fixup = tioca_bus_fixup,
658};
659
660/**
661 * tioca_init_provider - init SN PCI provider ops for TIO CA
662 */
663int
664tioca_init_provider(void)
665{
666 sn_pci_provider[PCIIO_ASIC_TYPE_TIOCA] = &tioca_pci_interfaces;
667 return 0;
668}
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index 8b40f362dd6f..124f7c1b775e 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -24,6 +24,7 @@
24#include <linux/ptrace.h> 24#include <linux/ptrace.h>
25#include <linux/user.h> 25#include <linux/user.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/signal.h>
27 28
28#include <asm/cacheflush.h> 29#include <asm/cacheflush.h>
29#include <asm/io.h> 30#include <asm/io.h>
@@ -665,7 +666,7 @@ do_ptrace(long request, struct task_struct *child, long addr, long data)
665 case PTRACE_SYSCALL: 666 case PTRACE_SYSCALL:
666 case PTRACE_CONT: 667 case PTRACE_CONT:
667 ret = -EIO; 668 ret = -EIO;
668 if ((unsigned long) data > _NSIG) 669 if (!valid_signal(data))
669 break; 670 break;
670 if (request == PTRACE_SYSCALL) 671 if (request == PTRACE_SYSCALL)
671 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 672 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -700,7 +701,7 @@ do_ptrace(long request, struct task_struct *child, long addr, long data)
700 unsigned long pc, insn; 701 unsigned long pc, insn;
701 702
702 ret = -EIO; 703 ret = -EIO;
703 if ((unsigned long) data > _NSIG) 704 if (!valid_signal(data))
704 break; 705 break;
705 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 706 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
706 if ((child->ptrace & PT_DTRACE) == 0) { 707 if ((child->ptrace & PT_DTRACE) == 0) {
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
index 0beb53333ba3..f4e1e5eb8e12 100644
--- a/arch/m68k/kernel/ptrace.c
+++ b/arch/m68k/kernel/ptrace.c
@@ -19,6 +19,7 @@
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/user.h> 20#include <linux/user.h>
21#include <linux/config.h> 21#include <linux/config.h>
22#include <linux/signal.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/page.h> 25#include <asm/page.h>
@@ -251,7 +252,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
251 long tmp; 252 long tmp;
252 253
253 ret = -EIO; 254 ret = -EIO;
254 if ((unsigned long) data > _NSIG) 255 if (!valid_signal(data))
255 break; 256 break;
256 if (request == PTRACE_SYSCALL) { 257 if (request == PTRACE_SYSCALL) {
257 child->thread.work.syscall_trace = ~0; 258 child->thread.work.syscall_trace = ~0;
@@ -292,7 +293,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
292 long tmp; 293 long tmp;
293 294
294 ret = -EIO; 295 ret = -EIO;
295 if ((unsigned long) data > _NSIG) 296 if (!valid_signal(data))
296 break; 297 break;
297 child->thread.work.syscall_trace = 0; 298 child->thread.work.syscall_trace = 0;
298 tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); 299 tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index fc4615b6d3a9..e729bd280623 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -534,6 +534,11 @@ endchoice
534 534
535endmenu 535endmenu
536 536
537config ISA_DMA_API
538 bool
539 depends on !M5272
540 default y
541
537menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)" 542menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
538 543
539config PCI 544config PCI
diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
index 15cf79080b15..9724e1cd82e5 100644
--- a/arch/m68knommu/kernel/ptrace.c
+++ b/arch/m68knommu/kernel/ptrace.c
@@ -19,6 +19,7 @@
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/user.h> 20#include <linux/user.h>
21#include <linux/config.h> 21#include <linux/config.h>
22#include <linux/signal.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/page.h> 25#include <asm/page.h>
@@ -240,7 +241,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
240 long tmp; 241 long tmp;
241 242
242 ret = -EIO; 243 ret = -EIO;
243 if ((unsigned long) data > _NSIG) 244 if (!valid_signal(data))
244 break; 245 break;
245 if (request == PTRACE_SYSCALL) 246 if (request == PTRACE_SYSCALL)
246 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 247 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -278,7 +279,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
278 long tmp; 279 long tmp;
279 280
280 ret = -EIO; 281 ret = -EIO;
281 if ((unsigned long) data > _NSIG) 282 if (!valid_signal(data))
282 break; 283 break;
283 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 284 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
284 tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); 285 tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5e666aad8815..ab9944693f1f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1656,3 +1656,7 @@ config GENERIC_HARDIRQS
1656config GENERIC_IRQ_PROBE 1656config GENERIC_IRQ_PROBE
1657 bool 1657 bool
1658 default y 1658 default y
1659
1660config ISA_DMA_API
1661 bool
1662 default y
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 92f2c39afe27..92e70ca3bff9 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -26,6 +26,7 @@
26#include <linux/smp_lock.h> 26#include <linux/smp_lock.h>
27#include <linux/user.h> 27#include <linux/user.h>
28#include <linux/security.h> 28#include <linux/security.h>
29#include <linux/signal.h>
29 30
30#include <asm/cpu.h> 31#include <asm/cpu.h>
31#include <asm/fpu.h> 32#include <asm/fpu.h>
@@ -257,7 +258,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
257 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 258 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
258 case PTRACE_CONT: { /* restart after signal. */ 259 case PTRACE_CONT: { /* restart after signal. */
259 ret = -EIO; 260 ret = -EIO;
260 if ((unsigned long) data > _NSIG) 261 if (!valid_signal(data))
261 break; 262 break;
262 if (request == PTRACE_SYSCALL) { 263 if (request == PTRACE_SYSCALL) {
263 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 264 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -300,25 +301,38 @@ out:
300 return ret; 301 return ret;
301} 302}
302 303
304static inline int audit_arch(void)
305{
306#ifdef CONFIG_CPU_LITTLE_ENDIAN
307#ifdef CONFIG_MIPS64
308 if (!(current->thread.mflags & MF_32BIT_REGS))
309 return AUDIT_ARCH_MIPSEL64;
310#endif /* MIPS64 */
311 return AUDIT_ARCH_MIPSEL;
312
313#else /* big endian... */
314#ifdef CONFIG_MIPS64
315 if (!(current->thread.mflags & MF_32BIT_REGS))
316 return AUDIT_ARCH_MIPS64;
317#endif /* MIPS64 */
318 return AUDIT_ARCH_MIPS;
319
320#endif /* endian */
321}
322
303/* 323/*
304 * Notification of system call entry/exit 324 * Notification of system call entry/exit
305 * - triggered by current->work.syscall_trace 325 * - triggered by current->work.syscall_trace
306 */ 326 */
307asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) 327asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
308{ 328{
309 if (unlikely(current->audit_context)) { 329 if (unlikely(current->audit_context) && entryexit)
310 if (!entryexit) 330 audit_syscall_exit(current, AUDITSC_RESULT(regs->regs[2]), regs->regs[2]);
311 audit_syscall_entry(current, regs->regs[2],
312 regs->regs[4], regs->regs[5],
313 regs->regs[6], regs->regs[7]);
314 else
315 audit_syscall_exit(current, regs->regs[2]);
316 }
317 331
318 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 332 if (!test_thread_flag(TIF_SYSCALL_TRACE))
319 return; 333 goto out;
320 if (!(current->ptrace & PT_PTRACED)) 334 if (!(current->ptrace & PT_PTRACED))
321 return; 335 goto out;
322 336
323 /* The 0x80 provides a way for the tracing parent to distinguish 337 /* The 0x80 provides a way for the tracing parent to distinguish
324 between a syscall stop and SIGTRAP delivery */ 338 between a syscall stop and SIGTRAP delivery */
@@ -334,4 +348,9 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
334 send_sig(current->exit_code, current, 1); 348 send_sig(current->exit_code, current, 1);
335 current->exit_code = 0; 349 current->exit_code = 0;
336 } 350 }
351 out:
352 if (unlikely(current->audit_context) && !entryexit)
353 audit_syscall_entry(current, audit_arch(), regs->regs[2],
354 regs->regs[4], regs->regs[5],
355 regs->regs[6], regs->regs[7]);
337} 356}
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index 611dee919d50..eee207969c21 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -24,6 +24,7 @@
24#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
25#include <linux/user.h> 25#include <linux/user.h>
26#include <linux/security.h> 26#include <linux/security.h>
27#include <linux/signal.h>
27 28
28#include <asm/cpu.h> 29#include <asm/cpu.h>
29#include <asm/fpu.h> 30#include <asm/fpu.h>
@@ -241,7 +242,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
241 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 242 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
242 case PTRACE_CONT: { /* restart after signal. */ 243 case PTRACE_CONT: { /* restart after signal. */
243 ret = -EIO; 244 ret = -EIO;
244 if ((unsigned int) data > _NSIG) 245 if (!valid_signal(data))
245 break; 246 break;
246 if (request == PTRACE_SYSCALL) { 247 if (request == PTRACE_SYSCALL) {
247 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 248 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 598bfe7426a2..ae2a1312d4ef 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -374,22 +374,6 @@ asmlinkage int sys_ipc (uint call, int first, int second,
374} 374}
375 375
376/* 376/*
377 * Native ABI that is O32 or N64 version
378 */
379asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
380 int shmflg, unsigned long *addr)
381{
382 unsigned long raddr;
383 int err;
384
385 err = do_shmat(shmid, shmaddr, shmflg, &raddr);
386 if (err)
387 return err;
388
389 return put_user(raddr, addr);
390}
391
392/*
393 * No implemented yet ... 377 * No implemented yet ...
394 */ 378 */
395asmlinkage int sys_cachectl(char *addr, int nbytes, int op) 379asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 5b5cd00d98ca..e7e7c56fc212 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -45,6 +45,10 @@ config GENERIC_IRQ_PROBE
45config PM 45config PM
46 bool 46 bool
47 47
48config ISA_DMA_API
49 bool
50 default y
51
48source "init/Kconfig" 52source "init/Kconfig"
49 53
50 54
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 2937a9236384..c07db9dff7cd 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -17,6 +17,7 @@
17#include <linux/personality.h> 17#include <linux/personality.h>
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/compat.h> 19#include <linux/compat.h>
20#include <linux/signal.h>
20 21
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include <asm/pgtable.h> 23#include <asm/pgtable.h>
@@ -285,7 +286,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
285 ret = -EIO; 286 ret = -EIO;
286 DBG("sys_ptrace(%s)\n", 287 DBG("sys_ptrace(%s)\n",
287 request == PTRACE_SYSCALL ? "SYSCALL" : "CONT"); 288 request == PTRACE_SYSCALL ? "SYSCALL" : "CONT");
288 if ((unsigned long) data > _NSIG) 289 if (!valid_signal(data))
289 goto out_tsk; 290 goto out_tsk;
290 child->ptrace &= ~(PT_SINGLESTEP|PT_BLOCKSTEP); 291 child->ptrace &= ~(PT_SINGLESTEP|PT_BLOCKSTEP);
291 if (request == PTRACE_SYSCALL) { 292 if (request == PTRACE_SYSCALL) {
@@ -311,7 +312,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
311 case PTRACE_SINGLEBLOCK: 312 case PTRACE_SINGLEBLOCK:
312 DBG("sys_ptrace(SINGLEBLOCK)\n"); 313 DBG("sys_ptrace(SINGLEBLOCK)\n");
313 ret = -EIO; 314 ret = -EIO;
314 if ((unsigned long) data > _NSIG) 315 if (!valid_signal(data))
315 goto out_tsk; 316 goto out_tsk;
316 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 317 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
317 child->ptrace &= ~PT_SINGLESTEP; 318 child->ptrace &= ~PT_SINGLESTEP;
@@ -328,7 +329,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
328 case PTRACE_SINGLESTEP: 329 case PTRACE_SINGLESTEP:
329 DBG("sys_ptrace(SINGLESTEP)\n"); 330 DBG("sys_ptrace(SINGLESTEP)\n");
330 ret = -EIO; 331 ret = -EIO;
331 if ((unsigned long) data > _NSIG) 332 if (!valid_signal(data))
332 goto out_tsk; 333 goto out_tsk;
333 334
334 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 335 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 7958cd8c8bf8..d15a1d53e101 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -161,17 +161,6 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
161 } 161 }
162} 162}
163 163
164long sys_shmat_wrapper(int shmid, char __user *shmaddr, int shmflag)
165{
166 unsigned long raddr;
167 int r;
168
169 r = do_shmat(shmid, shmaddr, shmflag, &raddr);
170 if (r < 0)
171 return r;
172 return raddr;
173}
174
175/* Fucking broken ABI */ 164/* Fucking broken ABI */
176 165
177#ifdef CONFIG_64BIT 166#ifdef CONFIG_64BIT
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 779b537100ec..dcfa4d3d0e7d 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -297,7 +297,7 @@
297 ENTRY_DIFF(msgrcv) 297 ENTRY_DIFF(msgrcv)
298 ENTRY_SAME(msgget) /* 190 */ 298 ENTRY_SAME(msgget) /* 190 */
299 ENTRY_SAME(msgctl) 299 ENTRY_SAME(msgctl)
300 ENTRY_SAME(shmat_wrapper) 300 ENTRY_SAME(shmat)
301 ENTRY_SAME(shmdt) 301 ENTRY_SAME(shmdt)
302 ENTRY_SAME(shmget) 302 ENTRY_SAME(shmget)
303 ENTRY_SAME(shmctl) /* 195 */ 303 ENTRY_SAME(shmctl) /* 195 */
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 74aa1e92a395..600f23d7fd33 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -43,6 +43,10 @@ config GENERIC_NVRAM
43 bool 43 bool
44 default y 44 default y
45 45
46config SCHED_NO_NO_OMIT_FRAME_POINTER
47 bool
48 default y
49
46source "init/Kconfig" 50source "init/Kconfig"
47 51
48menu "Processor" 52menu "Processor"
@@ -53,6 +57,7 @@ choice
53 57
54config 6xx 58config 6xx
55 bool "6xx/7xx/74xx/52xx/82xx/83xx" 59 bool "6xx/7xx/74xx/52xx/82xx/83xx"
60 select PPC_FPU
56 help 61 help
57 There are four types of PowerPC chips supported. The more common 62 There are four types of PowerPC chips supported. The more common
58 types (601, 603, 604, 740, 750, 7400), the Motorola embedded 63 types (601, 603, 604, 740, 750, 7400), the Motorola embedded
@@ -72,9 +77,11 @@ config 44x
72 bool "44x" 77 bool "44x"
73 78
74config POWER3 79config POWER3
80 select PPC_FPU
75 bool "POWER3" 81 bool "POWER3"
76 82
77config POWER4 83config POWER4
84 select PPC_FPU
78 bool "POWER4 and 970 (G5)" 85 bool "POWER4 and 970 (G5)"
79 86
80config 8xx 87config 8xx
@@ -86,6 +93,9 @@ config E500
86 93
87endchoice 94endchoice
88 95
96config PPC_FPU
97 bool
98
89config BOOKE 99config BOOKE
90 bool 100 bool
91 depends on E500 101 depends on E500
@@ -1075,6 +1085,10 @@ source kernel/power/Kconfig
1075 1085
1076endmenu 1086endmenu
1077 1087
1088config ISA_DMA_API
1089 bool
1090 default y
1091
1078menu "Bus options" 1092menu "Bus options"
1079 1093
1080config ISA 1094config ISA
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 73cbdda5b597..0432a25b4735 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -53,6 +53,7 @@ head-$(CONFIG_FSL_BOOKE) := arch/ppc/kernel/head_fsl_booke.o
53 53
54head-$(CONFIG_6xx) += arch/ppc/kernel/idle_6xx.o 54head-$(CONFIG_6xx) += arch/ppc/kernel/idle_6xx.o
55head-$(CONFIG_POWER4) += arch/ppc/kernel/idle_power4.o 55head-$(CONFIG_POWER4) += arch/ppc/kernel/idle_power4.o
56head-$(CONFIG_PPC_FPU) += arch/ppc/kernel/fpu.o
56 57
57core-y += arch/ppc/kernel/ arch/ppc/platforms/ \ 58core-y += arch/ppc/kernel/ arch/ppc/platforms/ \
58 arch/ppc/mm/ arch/ppc/lib/ arch/ppc/syslib/ 59 arch/ppc/mm/ arch/ppc/lib/ arch/ppc/syslib/
diff --git a/arch/ppc/boot/images/Makefile b/arch/ppc/boot/images/Makefile
index 774de8e23871..f850fb0fb511 100644
--- a/arch/ppc/boot/images/Makefile
+++ b/arch/ppc/boot/images/Makefile
@@ -20,8 +20,9 @@ quiet_cmd_uimage = UIMAGE $@
20 20
21targets += uImage 21targets += uImage
22$(obj)/uImage: $(obj)/vmlinux.gz 22$(obj)/uImage: $(obj)/vmlinux.gz
23 $(Q)rm -f $@
23 $(call if_changed,uimage) 24 $(call if_changed,uimage)
24 @echo ' Image $@ is ready' 25 @echo ' Image: $@' $(if $(wildcard $@),'is ready','not made')
25 26
26# Files generated that shall be removed upon make clean 27# Files generated that shall be removed upon make clean
27clean-files := sImage vmapus vmlinux* miboot* zImage* uImage 28clean-files := sImage vmapus vmlinux* miboot* zImage* uImage
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
index 86bc878cb3ee..b284451802c9 100644
--- a/arch/ppc/kernel/Makefile
+++ b/arch/ppc/kernel/Makefile
@@ -9,6 +9,7 @@ extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o
9extra-$(CONFIG_8xx) := head_8xx.o 9extra-$(CONFIG_8xx) := head_8xx.o
10extra-$(CONFIG_6xx) += idle_6xx.o 10extra-$(CONFIG_6xx) += idle_6xx.o
11extra-$(CONFIG_POWER4) += idle_power4.o 11extra-$(CONFIG_POWER4) += idle_power4.o
12extra-$(CONFIG_PPC_FPU) += fpu.o
12extra-y += vmlinux.lds 13extra-y += vmlinux.lds
13 14
14obj-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 \
diff --git a/arch/ppc/kernel/align.c b/arch/ppc/kernel/align.c
index 79c929475037..ff81da9598d8 100644
--- a/arch/ppc/kernel/align.c
+++ b/arch/ppc/kernel/align.c
@@ -290,6 +290,10 @@ fix_alignment(struct pt_regs *regs)
290 /* lwm, stmw */ 290 /* lwm, stmw */
291 nb = (32 - reg) * 4; 291 nb = (32 - reg) * 4;
292 } 292 }
293
294 if (!access_ok((flags & ST? VERIFY_WRITE: VERIFY_READ), addr, nb+nb0))
295 return -EFAULT; /* bad address */
296
293 rptr = (unsigned char *) &regs->gpr[reg]; 297 rptr = (unsigned char *) &regs->gpr[reg];
294 if (flags & LD) { 298 if (flags & LD) {
295 for (i = 0; i < nb; ++i) 299 for (i = 0; i < nb; ++i)
@@ -368,16 +372,24 @@ fix_alignment(struct pt_regs *regs)
368 372
369 /* Single-precision FP load and store require conversions... */ 373 /* Single-precision FP load and store require conversions... */
370 case LD+F+S: 374 case LD+F+S:
375#ifdef CONFIG_PPC_FPU
371 preempt_disable(); 376 preempt_disable();
372 enable_kernel_fp(); 377 enable_kernel_fp();
373 cvt_fd(&data.f, &data.d, &current->thread.fpscr); 378 cvt_fd(&data.f, &data.d, &current->thread.fpscr);
374 preempt_enable(); 379 preempt_enable();
380#else
381 return 0;
382#endif
375 break; 383 break;
376 case ST+F+S: 384 case ST+F+S:
385#ifdef CONFIG_PPC_FPU
377 preempt_disable(); 386 preempt_disable();
378 enable_kernel_fp(); 387 enable_kernel_fp();
379 cvt_df(&data.d, &data.f, &current->thread.fpscr); 388 cvt_df(&data.d, &data.f, &current->thread.fpscr);
380 preempt_enable(); 389 preempt_enable();
390#else
391 return 0;
392#endif
381 break; 393 break;
382 } 394 }
383 395
diff --git a/arch/ppc/kernel/cpu_setup_6xx.S b/arch/ppc/kernel/cpu_setup_6xx.S
index 74f781b486a3..468721d9ebd2 100644
--- a/arch/ppc/kernel/cpu_setup_6xx.S
+++ b/arch/ppc/kernel/cpu_setup_6xx.S
@@ -30,12 +30,14 @@ _GLOBAL(__setup_cpu_604)
30 blr 30 blr
31_GLOBAL(__setup_cpu_750) 31_GLOBAL(__setup_cpu_750)
32 mflr r4 32 mflr r4
33 bl __init_fpu_registers
33 bl setup_common_caches 34 bl setup_common_caches
34 bl setup_750_7400_hid0 35 bl setup_750_7400_hid0
35 mtlr r4 36 mtlr r4
36 blr 37 blr
37_GLOBAL(__setup_cpu_750cx) 38_GLOBAL(__setup_cpu_750cx)
38 mflr r4 39 mflr r4
40 bl __init_fpu_registers
39 bl setup_common_caches 41 bl setup_common_caches
40 bl setup_750_7400_hid0 42 bl setup_750_7400_hid0
41 bl setup_750cx 43 bl setup_750cx
@@ -43,6 +45,7 @@ _GLOBAL(__setup_cpu_750cx)
43 blr 45 blr
44_GLOBAL(__setup_cpu_750fx) 46_GLOBAL(__setup_cpu_750fx)
45 mflr r4 47 mflr r4
48 bl __init_fpu_registers
46 bl setup_common_caches 49 bl setup_common_caches
47 bl setup_750_7400_hid0 50 bl setup_750_7400_hid0
48 bl setup_750fx 51 bl setup_750fx
@@ -50,6 +53,7 @@ _GLOBAL(__setup_cpu_750fx)
50 blr 53 blr
51_GLOBAL(__setup_cpu_7400) 54_GLOBAL(__setup_cpu_7400)
52 mflr r4 55 mflr r4
56 bl __init_fpu_registers
53 bl setup_7400_workarounds 57 bl setup_7400_workarounds
54 bl setup_common_caches 58 bl setup_common_caches
55 bl setup_750_7400_hid0 59 bl setup_750_7400_hid0
@@ -57,6 +61,7 @@ _GLOBAL(__setup_cpu_7400)
57 blr 61 blr
58_GLOBAL(__setup_cpu_7410) 62_GLOBAL(__setup_cpu_7410)
59 mflr r4 63 mflr r4
64 bl __init_fpu_registers
60 bl setup_7410_workarounds 65 bl setup_7410_workarounds
61 bl setup_common_caches 66 bl setup_common_caches
62 bl setup_750_7400_hid0 67 bl setup_750_7400_hid0
@@ -80,7 +85,7 @@ setup_common_caches:
80 bne 1f /* don't invalidate the D-cache */ 85 bne 1f /* don't invalidate the D-cache */
81 ori r8,r8,HID0_DCI /* unless it wasn't enabled */ 86 ori r8,r8,HID0_DCI /* unless it wasn't enabled */
821: sync 871: sync
83 mtspr SPRN_HID0,r8 /* enable and invalidate caches */ 88 mtspr SPRN_HID0,r8 /* enable and invalidate caches */
84 sync 89 sync
85 mtspr SPRN_HID0,r11 /* enable caches */ 90 mtspr SPRN_HID0,r11 /* enable caches */
86 sync 91 sync
@@ -152,9 +157,13 @@ setup_7410_workarounds:
152setup_750_7400_hid0: 157setup_750_7400_hid0:
153 mfspr r11,SPRN_HID0 158 mfspr r11,SPRN_HID0
154 ori r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC 159 ori r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC
160 oris r11,r11,HID0_DPM@h
155BEGIN_FTR_SECTION 161BEGIN_FTR_SECTION
156 oris r11,r11,HID0_DPM@h /* enable dynamic power mgmt */ 162 xori r11,r11,HID0_BTIC
157END_FTR_SECTION_IFCLR(CPU_FTR_NO_DPM) 163END_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC)
164BEGIN_FTR_SECTION
165 xoris r11,r11,HID0_DPM@h /* disable dynamic power mgmt */
166END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
158 li r3,HID0_SPD 167 li r3,HID0_SPD
159 andc r11,r11,r3 /* clear SPD: enable speculative */ 168 andc r11,r11,r3 /* clear SPD: enable speculative */
160 li r3,0 169 li r3,0
@@ -218,13 +227,15 @@ setup_745x_specifics:
218 227
219 /* All of the bits we have to set..... 228 /* All of the bits we have to set.....
220 */ 229 */
221 ori r11,r11,HID0_SGE | HID0_FOLD | HID0_BHTE | HID0_LRSTK | HID0_BTIC 230 ori r11,r11,HID0_SGE | HID0_FOLD | HID0_BHTE
231 ori r11,r11,HID0_LRSTK | HID0_BTIC
232 oris r11,r11,HID0_DPM@h
222BEGIN_FTR_SECTION 233BEGIN_FTR_SECTION
223 xori r11,r11,HID0_BTIC 234 xori r11,r11,HID0_BTIC
224END_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC) 235END_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC)
225BEGIN_FTR_SECTION 236BEGIN_FTR_SECTION
226 oris r11,r11,HID0_DPM@h /* enable dynamic power mgmt */ 237 xoris r11,r11,HID0_DPM@h /* disable dynamic power mgmt */
227END_FTR_SECTION_IFCLR(CPU_FTR_NO_DPM) 238END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
228 239
229 /* All of the bits we have to clear.... 240 /* All of the bits we have to clear....
230 */ 241 */
@@ -248,6 +259,25 @@ END_FTR_SECTION_IFCLR(CPU_FTR_NO_DPM)
248 isync 259 isync
249 blr 260 blr
250 261
262/*
263 * Initialize the FPU registers. This is needed to work around an errata
264 * in some 750 cpus where using a not yet initialized FPU register after
265 * power on reset may hang the CPU
266 */
267_GLOBAL(__init_fpu_registers)
268 mfmsr r10
269 ori r11,r10,MSR_FP
270 mtmsr r11
271 isync
272 addis r9,r3,empty_zero_page@ha
273 addi r9,r9,empty_zero_page@l
274 REST_32FPRS(0,r9)
275 sync
276 mtmsr r10
277 isync
278 blr
279
280
251/* Definitions for the table use to save CPU states */ 281/* Definitions for the table use to save CPU states */
252#define CS_HID0 0 282#define CS_HID0 0
253#define CS_HID1 4 283#define CS_HID1 4
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index 035217d6c0f1..5f075dbc4ee7 100644
--- a/arch/ppc/kernel/entry.S
+++ b/arch/ppc/kernel/entry.S
@@ -563,6 +563,65 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
563 addi r1,r1,INT_FRAME_SIZE 563 addi r1,r1,INT_FRAME_SIZE
564 blr 564 blr
565 565
566 .globl fast_exception_return
567fast_exception_return:
568#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
569 andi. r10,r9,MSR_RI /* check for recoverable interrupt */
570 beq 1f /* if not, we've got problems */
571#endif
572
5732: REST_4GPRS(3, r11)
574 lwz r10,_CCR(r11)
575 REST_GPR(1, r11)
576 mtcr r10
577 lwz r10,_LINK(r11)
578 mtlr r10
579 REST_GPR(10, r11)
580 mtspr SPRN_SRR1,r9
581 mtspr SPRN_SRR0,r12
582 REST_GPR(9, r11)
583 REST_GPR(12, r11)
584 lwz r11,GPR11(r11)
585 SYNC
586 RFI
587
588#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
589/* check if the exception happened in a restartable section */
5901: lis r3,exc_exit_restart_end@ha
591 addi r3,r3,exc_exit_restart_end@l
592 cmplw r12,r3
593 bge 3f
594 lis r4,exc_exit_restart@ha
595 addi r4,r4,exc_exit_restart@l
596 cmplw r12,r4
597 blt 3f
598 lis r3,fee_restarts@ha
599 tophys(r3,r3)
600 lwz r5,fee_restarts@l(r3)
601 addi r5,r5,1
602 stw r5,fee_restarts@l(r3)
603 mr r12,r4 /* restart at exc_exit_restart */
604 b 2b
605
606 .comm fee_restarts,4
607
608/* aargh, a nonrecoverable interrupt, panic */
609/* aargh, we don't know which trap this is */
610/* but the 601 doesn't implement the RI bit, so assume it's OK */
6113:
612BEGIN_FTR_SECTION
613 b 2b
614END_FTR_SECTION_IFSET(CPU_FTR_601)
615 li r10,-1
616 stw r10,TRAP(r11)
617 addi r3,r1,STACK_FRAME_OVERHEAD
618 lis r10,MSR_KERNEL@h
619 ori r10,r10,MSR_KERNEL@l
620 bl transfer_to_handler_full
621 .long nonrecoverable_exception
622 .long ret_from_except
623#endif
624
566 .globl sigreturn_exit 625 .globl sigreturn_exit
567sigreturn_exit: 626sigreturn_exit:
568 subi r1,r3,STACK_FRAME_OVERHEAD 627 subi r1,r3,STACK_FRAME_OVERHEAD
diff --git a/arch/ppc/kernel/fpu.S b/arch/ppc/kernel/fpu.S
new file mode 100644
index 000000000000..6189b26f640f
--- /dev/null
+++ b/arch/ppc/kernel/fpu.S
@@ -0,0 +1,133 @@
1/*
2 * FPU support code, moved here from head.S so that it can be used
3 * by chips which use other head-whatever.S files.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 *
10 */
11
12#include <linux/config.h>
13#include <asm/processor.h>
14#include <asm/page.h>
15#include <asm/mmu.h>
16#include <asm/pgtable.h>
17#include <asm/cputable.h>
18#include <asm/cache.h>
19#include <asm/thread_info.h>
20#include <asm/ppc_asm.h>
21#include <asm/offsets.h>
22
23/*
24 * This task wants to use the FPU now.
25 * On UP, disable FP for the task which had the FPU previously,
26 * and save its floating-point registers in its thread_struct.
27 * Load up this task's FP registers from its thread_struct,
28 * enable the FPU for the current task and return to the task.
29 */
30 .globl load_up_fpu
31load_up_fpu:
32 mfmsr r5
33 ori r5,r5,MSR_FP
34#ifdef CONFIG_PPC64BRIDGE
35 clrldi r5,r5,1 /* turn off 64-bit mode */
36#endif /* CONFIG_PPC64BRIDGE */
37 SYNC
38 MTMSRD(r5) /* enable use of fpu now */
39 isync
40/*
41 * For SMP, we don't do lazy FPU switching because it just gets too
42 * horrendously complex, especially when a task switches from one CPU
43 * to another. Instead we call giveup_fpu in switch_to.
44 */
45#ifndef CONFIG_SMP
46 tophys(r6,0) /* get __pa constant */
47 addis r3,r6,last_task_used_math@ha
48 lwz r4,last_task_used_math@l(r3)
49 cmpwi 0,r4,0
50 beq 1f
51 add r4,r4,r6
52 addi r4,r4,THREAD /* want last_task_used_math->thread */
53 SAVE_32FPRS(0, r4)
54 mffs fr0
55 stfd fr0,THREAD_FPSCR-4(r4)
56 lwz r5,PT_REGS(r4)
57 add r5,r5,r6
58 lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)
59 li r10,MSR_FP|MSR_FE0|MSR_FE1
60 andc r4,r4,r10 /* disable FP for previous task */
61 stw r4,_MSR-STACK_FRAME_OVERHEAD(r5)
621:
63#endif /* CONFIG_SMP */
64 /* enable use of FP after return */
65 mfspr r5,SPRN_SPRG3 /* current task's THREAD (phys) */
66 lwz r4,THREAD_FPEXC_MODE(r5)
67 ori r9,r9,MSR_FP /* enable FP for current */
68 or r9,r9,r4
69 lfd fr0,THREAD_FPSCR-4(r5)
70 mtfsf 0xff,fr0
71 REST_32FPRS(0, r5)
72#ifndef CONFIG_SMP
73 subi r4,r5,THREAD
74 sub r4,r4,r6
75 stw r4,last_task_used_math@l(r3)
76#endif /* CONFIG_SMP */
77 /* restore registers and return */
78 /* we haven't used ctr or xer or lr */
79 b fast_exception_return
80
81/*
82 * FP unavailable trap from kernel - print a message, but let
83 * the task use FP in the kernel until it returns to user mode.
84 */
85 .globl KernelFP
86KernelFP:
87 lwz r3,_MSR(r1)
88 ori r3,r3,MSR_FP
89 stw r3,_MSR(r1) /* enable use of FP after return */
90 lis r3,86f@h
91 ori r3,r3,86f@l
92 mr r4,r2 /* current */
93 lwz r5,_NIP(r1)
94 bl printk
95 b ret_from_except
9686: .string "floating point used in kernel (task=%p, pc=%x)\n"
97 .align 4,0
98
99/*
100 * giveup_fpu(tsk)
101 * Disable FP for the task given as the argument,
102 * and save the floating-point registers in its thread_struct.
103 * Enables the FPU for use in the kernel on return.
104 */
105 .globl giveup_fpu
106giveup_fpu:
107 mfmsr r5
108 ori r5,r5,MSR_FP
109 SYNC_601
110 ISYNC_601
111 MTMSRD(r5) /* enable use of fpu now */
112 SYNC_601
113 isync
114 cmpwi 0,r3,0
115 beqlr- /* if no previous owner, done */
116 addi r3,r3,THREAD /* want THREAD of task */
117 lwz r5,PT_REGS(r3)
118 cmpwi 0,r5,0
119 SAVE_32FPRS(0, r3)
120 mffs fr0
121 stfd fr0,THREAD_FPSCR-4(r3)
122 beq 1f
123 lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)
124 li r3,MSR_FP|MSR_FE0|MSR_FE1
125 andc r4,r4,r3 /* disable FP for previous task */
126 stw r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1271:
128#ifndef CONFIG_SMP
129 li r5,0
130 lis r4,last_task_used_math@ha
131 stw r5,last_task_used_math@l(r4)
132#endif /* CONFIG_SMP */
133 blr
diff --git a/arch/ppc/kernel/head.S b/arch/ppc/kernel/head.S
index 1a89a71e0acc..a931d773715f 100644
--- a/arch/ppc/kernel/head.S
+++ b/arch/ppc/kernel/head.S
@@ -775,133 +775,6 @@ InstructionSegment:
775 EXC_XFER_STD(0x480, UnknownException) 775 EXC_XFER_STD(0x480, UnknownException)
776#endif /* CONFIG_PPC64BRIDGE */ 776#endif /* CONFIG_PPC64BRIDGE */
777 777
778/*
779 * This task wants to use the FPU now.
780 * On UP, disable FP for the task which had the FPU previously,
781 * and save its floating-point registers in its thread_struct.
782 * Load up this task's FP registers from its thread_struct,
783 * enable the FPU for the current task and return to the task.
784 */
785load_up_fpu:
786 mfmsr r5
787 ori r5,r5,MSR_FP
788#ifdef CONFIG_PPC64BRIDGE
789 clrldi r5,r5,1 /* turn off 64-bit mode */
790#endif /* CONFIG_PPC64BRIDGE */
791 SYNC
792 MTMSRD(r5) /* enable use of fpu now */
793 isync
794/*
795 * For SMP, we don't do lazy FPU switching because it just gets too
796 * horrendously complex, especially when a task switches from one CPU
797 * to another. Instead we call giveup_fpu in switch_to.
798 */
799#ifndef CONFIG_SMP
800 tophys(r6,0) /* get __pa constant */
801 addis r3,r6,last_task_used_math@ha
802 lwz r4,last_task_used_math@l(r3)
803 cmpwi 0,r4,0
804 beq 1f
805 add r4,r4,r6
806 addi r4,r4,THREAD /* want last_task_used_math->thread */
807 SAVE_32FPRS(0, r4)
808 mffs fr0
809 stfd fr0,THREAD_FPSCR-4(r4)
810 lwz r5,PT_REGS(r4)
811 add r5,r5,r6
812 lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)
813 li r10,MSR_FP|MSR_FE0|MSR_FE1
814 andc r4,r4,r10 /* disable FP for previous task */
815 stw r4,_MSR-STACK_FRAME_OVERHEAD(r5)
8161:
817#endif /* CONFIG_SMP */
818 /* enable use of FP after return */
819 mfspr r5,SPRN_SPRG3 /* current task's THREAD (phys) */
820 lwz r4,THREAD_FPEXC_MODE(r5)
821 ori r9,r9,MSR_FP /* enable FP for current */
822 or r9,r9,r4
823 lfd fr0,THREAD_FPSCR-4(r5)
824 mtfsf 0xff,fr0
825 REST_32FPRS(0, r5)
826#ifndef CONFIG_SMP
827 subi r4,r5,THREAD
828 sub r4,r4,r6
829 stw r4,last_task_used_math@l(r3)
830#endif /* CONFIG_SMP */
831 /* restore registers and return */
832 /* we haven't used ctr or xer or lr */
833 /* fall through to fast_exception_return */
834
835 .globl fast_exception_return
836fast_exception_return:
837 andi. r10,r9,MSR_RI /* check for recoverable interrupt */
838 beq 1f /* if not, we've got problems */
8392: REST_4GPRS(3, r11)
840 lwz r10,_CCR(r11)
841 REST_GPR(1, r11)
842 mtcr r10
843 lwz r10,_LINK(r11)
844 mtlr r10
845 REST_GPR(10, r11)
846 mtspr SPRN_SRR1,r9
847 mtspr SPRN_SRR0,r12
848 REST_GPR(9, r11)
849 REST_GPR(12, r11)
850 lwz r11,GPR11(r11)
851 SYNC
852 RFI
853
854/* check if the exception happened in a restartable section */
8551: lis r3,exc_exit_restart_end@ha
856 addi r3,r3,exc_exit_restart_end@l
857 cmplw r12,r3
858 bge 3f
859 lis r4,exc_exit_restart@ha
860 addi r4,r4,exc_exit_restart@l
861 cmplw r12,r4
862 blt 3f
863 lis r3,fee_restarts@ha
864 tophys(r3,r3)
865 lwz r5,fee_restarts@l(r3)
866 addi r5,r5,1
867 stw r5,fee_restarts@l(r3)
868 mr r12,r4 /* restart at exc_exit_restart */
869 b 2b
870
871 .comm fee_restarts,4
872
873/* aargh, a nonrecoverable interrupt, panic */
874/* aargh, we don't know which trap this is */
875/* but the 601 doesn't implement the RI bit, so assume it's OK */
8763:
877BEGIN_FTR_SECTION
878 b 2b
879END_FTR_SECTION_IFSET(CPU_FTR_601)
880 li r10,-1
881 stw r10,TRAP(r11)
882 addi r3,r1,STACK_FRAME_OVERHEAD
883 li r10,MSR_KERNEL
884 bl transfer_to_handler_full
885 .long nonrecoverable_exception
886 .long ret_from_except
887
888/*
889 * FP unavailable trap from kernel - print a message, but let
890 * the task use FP in the kernel until it returns to user mode.
891 */
892KernelFP:
893 lwz r3,_MSR(r1)
894 ori r3,r3,MSR_FP
895 stw r3,_MSR(r1) /* enable use of FP after return */
896 lis r3,86f@h
897 ori r3,r3,86f@l
898 mr r4,r2 /* current */
899 lwz r5,_NIP(r1)
900 bl printk
901 b ret_from_except
90286: .string "floating point used in kernel (task=%p, pc=%x)\n"
903 .align 4,0
904
905#ifdef CONFIG_ALTIVEC 778#ifdef CONFIG_ALTIVEC
906/* Note that the AltiVec support is closely modeled after the FP 779/* Note that the AltiVec support is closely modeled after the FP
907 * support. Changes to one are likely to be applicable to the 780 * support. Changes to one are likely to be applicable to the
@@ -1016,42 +889,6 @@ giveup_altivec:
1016#endif /* CONFIG_ALTIVEC */ 889#endif /* CONFIG_ALTIVEC */
1017 890
1018/* 891/*
1019 * giveup_fpu(tsk)
1020 * Disable FP for the task given as the argument,
1021 * and save the floating-point registers in its thread_struct.
1022 * Enables the FPU for use in the kernel on return.
1023 */
1024 .globl giveup_fpu
1025giveup_fpu:
1026 mfmsr r5
1027 ori r5,r5,MSR_FP
1028 SYNC_601
1029 ISYNC_601
1030 MTMSRD(r5) /* enable use of fpu now */
1031 SYNC_601
1032 isync
1033 cmpwi 0,r3,0
1034 beqlr- /* if no previous owner, done */
1035 addi r3,r3,THREAD /* want THREAD of task */
1036 lwz r5,PT_REGS(r3)
1037 cmpwi 0,r5,0
1038 SAVE_32FPRS(0, r3)
1039 mffs fr0
1040 stfd fr0,THREAD_FPSCR-4(r3)
1041 beq 1f
1042 lwz r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1043 li r3,MSR_FP|MSR_FE0|MSR_FE1
1044 andc r4,r4,r3 /* disable FP for previous task */
1045 stw r4,_MSR-STACK_FRAME_OVERHEAD(r5)
10461:
1047#ifndef CONFIG_SMP
1048 li r5,0
1049 lis r4,last_task_used_math@ha
1050 stw r5,last_task_used_math@l(r4)
1051#endif /* CONFIG_SMP */
1052 blr
1053
1054/*
1055 * This code is jumped to from the startup code to copy 892 * This code is jumped to from the startup code to copy
1056 * the kernel image to physical address 0. 893 * the kernel image to physical address 0.
1057 */ 894 */
diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
index 9ed8165a3d6c..9b6a8e513657 100644
--- a/arch/ppc/kernel/head_44x.S
+++ b/arch/ppc/kernel/head_44x.S
@@ -426,7 +426,11 @@ interrupt_base:
426 PROGRAM_EXCEPTION 426 PROGRAM_EXCEPTION
427 427
428 /* Floating Point Unavailable Interrupt */ 428 /* Floating Point Unavailable Interrupt */
429#ifdef CONFIG_PPC_FPU
430 FP_UNAVAILABLE_EXCEPTION
431#else
429 EXCEPTION(0x2010, FloatingPointUnavailable, UnknownException, EXC_XFER_EE) 432 EXCEPTION(0x2010, FloatingPointUnavailable, UnknownException, EXC_XFER_EE)
433#endif
430 434
431 /* System Call Interrupt */ 435 /* System Call Interrupt */
432 START_EXCEPTION(SystemCall) 436 START_EXCEPTION(SystemCall)
@@ -686,8 +690,10 @@ _GLOBAL(giveup_altivec)
686 * 690 *
687 * The 44x core does not have an FPU. 691 * The 44x core does not have an FPU.
688 */ 692 */
693#ifndef CONFIG_PPC_FPU
689_GLOBAL(giveup_fpu) 694_GLOBAL(giveup_fpu)
690 blr 695 blr
696#endif
691 697
692/* 698/*
693 * extern void abort(void) 699 * extern void abort(void)
diff --git a/arch/ppc/kernel/head_booke.h b/arch/ppc/kernel/head_booke.h
index 884dac916bce..f213d12eec08 100644
--- a/arch/ppc/kernel/head_booke.h
+++ b/arch/ppc/kernel/head_booke.h
@@ -337,4 +337,11 @@ label:
337 addi r3,r1,STACK_FRAME_OVERHEAD; \ 337 addi r3,r1,STACK_FRAME_OVERHEAD; \
338 EXC_XFER_LITE(0x0900, timer_interrupt) 338 EXC_XFER_LITE(0x0900, timer_interrupt)
339 339
340#define FP_UNAVAILABLE_EXCEPTION \
341 START_EXCEPTION(FloatingPointUnavailable) \
342 NORMAL_EXCEPTION_PROLOG; \
343 bne load_up_fpu; /* if from user, just load it up */ \
344 addi r3,r1,STACK_FRAME_OVERHEAD; \
345 EXC_XFER_EE_LITE(0x800, KernelFP)
346
340#endif /* __HEAD_BOOKE_H__ */ 347#endif /* __HEAD_BOOKE_H__ */
diff --git a/arch/ppc/kernel/head_fsl_booke.S b/arch/ppc/kernel/head_fsl_booke.S
index d64bf61d2b1f..f22ddce36135 100644
--- a/arch/ppc/kernel/head_fsl_booke.S
+++ b/arch/ppc/kernel/head_fsl_booke.S
@@ -504,7 +504,11 @@ interrupt_base:
504 PROGRAM_EXCEPTION 504 PROGRAM_EXCEPTION
505 505
506 /* Floating Point Unavailable Interrupt */ 506 /* Floating Point Unavailable Interrupt */
507#ifdef CONFIG_PPC_FPU
508 FP_UNAVAILABLE_EXCEPTION
509#else
507 EXCEPTION(0x0800, FloatingPointUnavailable, UnknownException, EXC_XFER_EE) 510 EXCEPTION(0x0800, FloatingPointUnavailable, UnknownException, EXC_XFER_EE)
511#endif
508 512
509 /* System Call Interrupt */ 513 /* System Call Interrupt */
510 START_EXCEPTION(SystemCall) 514 START_EXCEPTION(SystemCall)
@@ -916,10 +920,12 @@ _GLOBAL(giveup_spe)
916/* 920/*
917 * extern void giveup_fpu(struct task_struct *prev) 921 * extern void giveup_fpu(struct task_struct *prev)
918 * 922 *
919 * The e500 core does not have an FPU. 923 * Not all FSL Book-E cores have an FPU
920 */ 924 */
925#ifndef CONFIG_PPC_FPU
921_GLOBAL(giveup_fpu) 926_GLOBAL(giveup_fpu)
922 blr 927 blr
928#endif
923 929
924/* 930/*
925 * extern void abort(void) 931 * extern void abort(void)
diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
index 73f7c23b0dd4..e4f1615ec13f 100644
--- a/arch/ppc/kernel/misc.S
+++ b/arch/ppc/kernel/misc.S
@@ -1096,17 +1096,7 @@ _GLOBAL(_get_SP)
1096 * and exceptions as if the cpu had performed the load or store. 1096 * and exceptions as if the cpu had performed the load or store.
1097 */ 1097 */
1098 1098
1099#if defined(CONFIG_4xx) || defined(CONFIG_E500) 1099#ifdef CONFIG_PPC_FPU
1100_GLOBAL(cvt_fd)
1101 lfs 0,0(r3)
1102 stfd 0,0(r4)
1103 blr
1104
1105_GLOBAL(cvt_df)
1106 lfd 0,0(r3)
1107 stfs 0,0(r4)
1108 blr
1109#else
1110_GLOBAL(cvt_fd) 1100_GLOBAL(cvt_fd)
1111 lfd 0,-4(r5) /* load up fpscr value */ 1101 lfd 0,-4(r5) /* load up fpscr value */
1112 mtfsf 0xff,0 1102 mtfsf 0xff,0
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index 98f94b60204c..47a15306823a 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -1432,7 +1432,7 @@ pci_bus_to_hose(int bus)
1432 return NULL; 1432 return NULL;
1433} 1433}
1434 1434
1435void* 1435void __iomem *
1436pci_bus_io_base(unsigned int bus) 1436pci_bus_io_base(unsigned int bus)
1437{ 1437{
1438 struct pci_controller *hose; 1438 struct pci_controller *hose;
diff --git a/arch/ppc/kernel/ptrace.c b/arch/ppc/kernel/ptrace.c
index 426b6f7d9de3..59d59a8dc249 100644
--- a/arch/ppc/kernel/ptrace.c
+++ b/arch/ppc/kernel/ptrace.c
@@ -26,6 +26,7 @@
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/user.h> 27#include <linux/user.h>
28#include <linux/security.h> 28#include <linux/security.h>
29#include <linux/signal.h>
29 30
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/page.h> 32#include <asm/page.h>
@@ -356,7 +357,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
356 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 357 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
357 case PTRACE_CONT: { /* restart after signal. */ 358 case PTRACE_CONT: { /* restart after signal. */
358 ret = -EIO; 359 ret = -EIO;
359 if ((unsigned long) data > _NSIG) 360 if (!valid_signal(data))
360 break; 361 break;
361 if (request == PTRACE_SYSCALL) { 362 if (request == PTRACE_SYSCALL) {
362 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 363 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -389,7 +390,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
389 390
390 case PTRACE_SINGLESTEP: { /* set the trap flag. */ 391 case PTRACE_SINGLESTEP: { /* set the trap flag. */
391 ret = -EIO; 392 ret = -EIO;
392 if ((unsigned long) data > _NSIG) 393 if (!valid_signal(data))
393 break; 394 break;
394 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 395 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
395 set_single_step(child); 396 set_single_step(child);
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index e97ce635b99e..5dfb42f1a152 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -221,27 +221,26 @@ int show_cpuinfo(struct seq_file *m, void *v)
221 return err; 221 return err;
222 } 222 }
223 223
224 switch (PVR_VER(pvr)) { 224 /* If we are a Freescale core do a simple check so
225 case 0x0020: /* 403 family */ 225 * we dont have to keep adding cases in the future */
226 maj = PVR_MAJ(pvr) + 1; 226 if ((PVR_VER(pvr) & 0x8000) == 0x8000) {
227 min = PVR_MIN(pvr);
228 break;
229 case 0x1008: /* 740P/750P ?? */
230 maj = ((pvr >> 8) & 0xFF) - 1;
231 min = pvr & 0xFF;
232 break;
233 case 0x8083: /* e300 */
234 maj = PVR_MAJ(pvr);
235 min = PVR_MIN(pvr);
236 break;
237 case 0x8020: /* e500 */
238 maj = PVR_MAJ(pvr); 227 maj = PVR_MAJ(pvr);
239 min = PVR_MIN(pvr); 228 min = PVR_MIN(pvr);
240 break; 229 } else {
241 default: 230 switch (PVR_VER(pvr)) {
242 maj = (pvr >> 8) & 0xFF; 231 case 0x0020: /* 403 family */
243 min = pvr & 0xFF; 232 maj = PVR_MAJ(pvr) + 1;
244 break; 233 min = PVR_MIN(pvr);
234 break;
235 case 0x1008: /* 740P/750P ?? */
236 maj = ((pvr >> 8) & 0xFF) - 1;
237 min = pvr & 0xFF;
238 break;
239 default:
240 maj = (pvr >> 8) & 0xFF;
241 min = pvr & 0xFF;
242 break;
243 }
245 } 244 }
246 245
247 seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n", 246 seq_printf(m, "revision\t: %hd.%hd (pvr %04x %04x)\n",
diff --git a/arch/ppc/kernel/signal.c b/arch/ppc/kernel/signal.c
index 645eae19805c..7c8437da09d5 100644
--- a/arch/ppc/kernel/signal.c
+++ b/arch/ppc/kernel/signal.c
@@ -511,7 +511,7 @@ int sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
511} 511}
512 512
513int sys_debug_setcontext(struct ucontext __user *ctx, 513int sys_debug_setcontext(struct ucontext __user *ctx,
514 int ndbg, struct sig_dbg_op *dbg, 514 int ndbg, struct sig_dbg_op __user *dbg,
515 int r6, int r7, int r8, 515 int r6, int r7, int r8,
516 struct pt_regs *regs) 516 struct pt_regs *regs)
517{ 517{
@@ -632,7 +632,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
632 if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler) 632 if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
633 || __put_user(oldset->sig[0], &sc->oldmask) 633 || __put_user(oldset->sig[0], &sc->oldmask)
634 || __put_user(oldset->sig[1], &sc->_unused[3]) 634 || __put_user(oldset->sig[1], &sc->_unused[3])
635 || __put_user((struct pt_regs *)frame, &sc->regs) 635 || __put_user((struct pt_regs __user *)frame, &sc->regs)
636 || __put_user(sig, &sc->signal)) 636 || __put_user(sig, &sc->signal))
637 goto badframe; 637 goto badframe;
638 638
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index 002322a1f3ce..f8e7e324a173 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -176,7 +176,7 @@ static inline int check_io_access(struct pt_regs *regs)
176#else 176#else
177#define get_mc_reason(regs) (mfspr(SPRN_MCSR)) 177#define get_mc_reason(regs) (mfspr(SPRN_MCSR))
178#endif 178#endif
179#define REASON_FP 0 179#define REASON_FP ESR_FP
180#define REASON_ILLEGAL ESR_PIL 180#define REASON_ILLEGAL ESR_PIL
181#define REASON_PRIVILEGED ESR_PPR 181#define REASON_PRIVILEGED ESR_PPR
182#define REASON_TRAP ESR_PTR 182#define REASON_TRAP ESR_PTR
@@ -403,7 +403,7 @@ static int emulate_string_inst(struct pt_regs *regs, u32 instword)
403 u8 rA = (instword >> 16) & 0x1f; 403 u8 rA = (instword >> 16) & 0x1f;
404 u8 NB_RB = (instword >> 11) & 0x1f; 404 u8 NB_RB = (instword >> 11) & 0x1f;
405 u32 num_bytes; 405 u32 num_bytes;
406 u32 EA; 406 unsigned long EA;
407 int pos = 0; 407 int pos = 0;
408 408
409 /* Early out if we are an invalid form of lswx */ 409 /* Early out if we are an invalid form of lswx */
diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S
index 0c0e714b84de..9353584fb710 100644
--- a/arch/ppc/kernel/vmlinux.lds.S
+++ b/arch/ppc/kernel/vmlinux.lds.S
@@ -145,6 +145,7 @@ SECTIONS
145 __init_end = .; 145 __init_end = .;
146 146
147 . = ALIGN(4096); 147 . = ALIGN(4096);
148 _sextratext = .;
148 __pmac_begin = .; 149 __pmac_begin = .;
149 .pmac.text : { *(.pmac.text) } 150 .pmac.text : { *(.pmac.text) }
150 .pmac.data : { *(.pmac.data) } 151 .pmac.data : { *(.pmac.data) }
@@ -171,6 +172,7 @@ SECTIONS
171 .openfirmware.data : { *(.openfirmware.data) } 172 .openfirmware.data : { *(.openfirmware.data) }
172 . = ALIGN(4096); 173 . = ALIGN(4096);
173 __openfirmware_end = .; 174 __openfirmware_end = .;
175 _eextratext = .;
174 176
175 __bss_start = .; 177 __bss_start = .;
176 .bss : 178 .bss :
diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
index f63bca83e757..cd11734ef7c5 100644
--- a/arch/ppc/platforms/4xx/ebony.c
+++ b/arch/ppc/platforms/4xx/ebony.c
@@ -149,7 +149,7 @@ ebony_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
149static void __init 149static void __init
150ebony_setup_pcix(void) 150ebony_setup_pcix(void)
151{ 151{
152 void *pcix_reg_base; 152 void __iomem *pcix_reg_base;
153 153
154 pcix_reg_base = ioremap64(PCIX0_REG_BASE, PCIX_REG_SIZE); 154 pcix_reg_base = ioremap64(PCIX0_REG_BASE, PCIX_REG_SIZE);
155 155
@@ -210,9 +210,8 @@ ebony_setup_hose(void)
210 hose->io_space.end = EBONY_PCI_UPPER_IO; 210 hose->io_space.end = EBONY_PCI_UPPER_IO;
211 hose->mem_space.start = EBONY_PCI_LOWER_MEM; 211 hose->mem_space.start = EBONY_PCI_LOWER_MEM;
212 hose->mem_space.end = EBONY_PCI_UPPER_MEM; 212 hose->mem_space.end = EBONY_PCI_UPPER_MEM;
213 isa_io_base = 213 hose->io_base_virt = ioremap64(EBONY_PCI_IO_BASE, EBONY_PCI_IO_SIZE);
214 (unsigned long)ioremap64(EBONY_PCI_IO_BASE, EBONY_PCI_IO_SIZE); 214 isa_io_base = (unsigned long)hose->io_base_virt;
215 hose->io_base_virt = (void *)isa_io_base;
216 215
217 setup_indirect_pci(hose, 216 setup_indirect_pci(hose,
218 EBONY_PCI_CFGA_PLB32, 217 EBONY_PCI_CFGA_PLB32,
diff --git a/arch/ppc/platforms/4xx/luan.c b/arch/ppc/platforms/4xx/luan.c
index 1df2339f1f6c..95359f748e7b 100644
--- a/arch/ppc/platforms/4xx/luan.c
+++ b/arch/ppc/platforms/4xx/luan.c
@@ -223,9 +223,8 @@ luan_setup_hose(struct pci_controller *hose,
223 hose->io_space.end = LUAN_PCIX_UPPER_IO; 223 hose->io_space.end = LUAN_PCIX_UPPER_IO;
224 hose->mem_space.start = lower_mem; 224 hose->mem_space.start = lower_mem;
225 hose->mem_space.end = upper_mem; 225 hose->mem_space.end = upper_mem;
226 isa_io_base = 226 hose->io_base_virt = ioremap64(pcix_io_base, PCIX_IO_SIZE);
227 (unsigned long)ioremap64(pcix_io_base, PCIX_IO_SIZE); 227 isa_io_base = (unsigned long) hose->io_base_virt;
228 hose->io_base_virt = (void *)isa_io_base;
229 228
230 setup_indirect_pci(hose, cfga, cfgd); 229 setup_indirect_pci(hose, cfga, cfgd);
231 hose->set_cfg_type = 1; 230 hose->set_cfg_type = 1;
diff --git a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
index 28de707434f1..5f82a6bc7046 100644
--- a/arch/ppc/platforms/4xx/ocotea.c
+++ b/arch/ppc/platforms/4xx/ocotea.c
@@ -227,9 +227,8 @@ ocotea_setup_hose(void)
227 hose->io_space.end = OCOTEA_PCI_UPPER_IO; 227 hose->io_space.end = OCOTEA_PCI_UPPER_IO;
228 hose->mem_space.start = OCOTEA_PCI_LOWER_MEM; 228 hose->mem_space.start = OCOTEA_PCI_LOWER_MEM;
229 hose->mem_space.end = OCOTEA_PCI_UPPER_MEM; 229 hose->mem_space.end = OCOTEA_PCI_UPPER_MEM;
230 isa_io_base = 230 hose->io_base_virt = ioremap64(OCOTEA_PCI_IO_BASE, OCOTEA_PCI_IO_SIZE);
231 (unsigned long)ioremap64(OCOTEA_PCI_IO_BASE, OCOTEA_PCI_IO_SIZE); 231 isa_io_base = (unsigned long) hose->io_base_virt;
232 hose->io_base_virt = (void *)isa_io_base;
233 232
234 setup_indirect_pci(hose, 233 setup_indirect_pci(hose,
235 OCOTEA_PCI_CFGA_PLB32, 234 OCOTEA_PCI_CFGA_PLB32,
diff --git a/arch/ppc/platforms/chrp_pci.c b/arch/ppc/platforms/chrp_pci.c
index 5bb6492ecf8c..7d0ee308f662 100644
--- a/arch/ppc/platforms/chrp_pci.c
+++ b/arch/ppc/platforms/chrp_pci.c
@@ -129,7 +129,7 @@ static struct pci_ops rtas_pci_ops =
129 rtas_write_config 129 rtas_write_config
130}; 130};
131 131
132volatile struct Hydra *Hydra = NULL; 132volatile struct Hydra __iomem *Hydra = NULL;
133 133
134int __init 134int __init
135hydra_init(void) 135hydra_init(void)
@@ -175,13 +175,14 @@ chrp_pcibios_fixup(void)
175static void __init 175static void __init
176setup_python(struct pci_controller *hose, struct device_node *dev) 176setup_python(struct pci_controller *hose, struct device_node *dev)
177{ 177{
178 u32 *reg, val; 178 u32 __iomem *reg;
179 u32 val;
179 unsigned long addr = dev->addrs[0].address; 180 unsigned long addr = dev->addrs[0].address;
180 181
181 setup_indirect_pci(hose, addr + 0xf8000, addr + 0xf8010); 182 setup_indirect_pci(hose, addr + 0xf8000, addr + 0xf8010);
182 183
183 /* Clear the magic go-slow bit */ 184 /* Clear the magic go-slow bit */
184 reg = (u32 *) ioremap(dev->addrs[0].address + 0xf6000, 0x40); 185 reg = ioremap(dev->addrs[0].address + 0xf6000, 0x40);
185 val = in_be32(&reg[12]); 186 val = in_be32(&reg[12]);
186 if (val & PRG_CL_RESET_VALID) { 187 if (val & PRG_CL_RESET_VALID) {
187 out_be32(&reg[12], val & ~PRG_CL_RESET_VALID); 188 out_be32(&reg[12], val & ~PRG_CL_RESET_VALID);
diff --git a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
index f23c4f320760..57f29ab29bda 100644
--- a/arch/ppc/platforms/chrp_setup.c
+++ b/arch/ppc/platforms/chrp_setup.c
@@ -356,7 +356,7 @@ static void __init chrp_find_openpic(void)
356 struct device_node *np; 356 struct device_node *np;
357 int len, i; 357 int len, i;
358 unsigned int *iranges; 358 unsigned int *iranges;
359 void *isu; 359 void __iomem *isu;
360 360
361 np = find_type_devices("open-pic"); 361 np = find_type_devices("open-pic");
362 if (np == NULL || np->n_addrs == 0) 362 if (np == NULL || np->n_addrs == 0)
diff --git a/arch/ppc/platforms/pmac_cache.S b/arch/ppc/platforms/pmac_cache.S
index da34a9bc9299..fb977de6b704 100644
--- a/arch/ppc/platforms/pmac_cache.S
+++ b/arch/ppc/platforms/pmac_cache.S
@@ -64,27 +64,39 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
64 mtspr SPRN_HID0,r4 /* Disable DPM */ 64 mtspr SPRN_HID0,r4 /* Disable DPM */
65 sync 65 sync
66 66
67 /* disp-flush L1 */ 67 /* Disp-flush L1. We have a weird problem here that I never
68 li r4,0x4000 68 * totally figured out. On 750FX, using the ROM for the flush
69 mtctr r4 69 * results in a non-working flush. We use that workaround for
70 * now until I finally understand what's going on. --BenH
71 */
72
73 /* ROM base by default */
70 lis r4,0xfff0 74 lis r4,0xfff0
711: lwzx r0,r0,r4 75 mfpvr r3
76 srwi r3,r3,16
77 cmplwi cr0,r3,0x7000
78 bne+ 1f
79 /* RAM base on 750FX */
80 li r4,0
811: li r4,0x4000
82 mtctr r4
831: lwz r0,0(r4)
72 addi r4,r4,32 84 addi r4,r4,32
73 bdnz 1b 85 bdnz 1b
74 sync 86 sync
75 isync 87 isync
76 88
77 /* disable / invalidate / enable L1 data */ 89 /* Disable / invalidate / enable L1 data */
78 mfspr r3,SPRN_HID0 90 mfspr r3,SPRN_HID0
79 rlwinm r0,r0,0,~HID0_DCE 91 rlwinm r3,r3,0,~(HID0_DCE | HID0_ICE)
80 mtspr SPRN_HID0,r3 92 mtspr SPRN_HID0,r3
81 sync 93 sync
82 isync 94 isync
83 ori r3,r3,HID0_DCE|HID0_DCI 95 ori r3,r3,(HID0_DCE|HID0_DCI|HID0_ICE|HID0_ICFI)
84 sync 96 sync
85 isync 97 isync
86 mtspr SPRN_HID0,r3 98 mtspr SPRN_HID0,r3
87 xori r3,r3,HID0_DCI 99 xori r3,r3,(HID0_DCI|HID0_ICFI)
88 mtspr SPRN_HID0,r3 100 mtspr SPRN_HID0,r3
89 sync 101 sync
90 102
@@ -110,11 +122,20 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
110 lis r4,2 122 lis r4,2
111 mtctr r4 123 mtctr r4
112 lis r4,0xfff0 124 lis r4,0xfff0
1131: lwzx r0,r0,r4 1251: lwz r0,0(r4)
126 addi r4,r4,32
127 bdnz 1b
128 sync
129 isync
130 lis r4,2
131 mtctr r4
132 lis r4,0xfff0
1331: dcbf 0,r4
114 addi r4,r4,32 134 addi r4,r4,32
115 bdnz 1b 135 bdnz 1b
116 sync 136 sync
117 isync 137 isync
138
118 /* now disable L2 */ 139 /* now disable L2 */
119 rlwinm r5,r5,0,~L2CR_L2E 140 rlwinm r5,r5,0,~L2CR_L2E
120 b 2f 141 b 2f
@@ -135,6 +156,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
135 mtspr SPRN_L2CR,r4 156 mtspr SPRN_L2CR,r4
136 sync 157 sync
137 isync 158 isync
159
160 /* Wait for the invalidation to complete */
1611: mfspr r3,SPRN_L2CR
162 rlwinm. r0,r3,0,31,31
163 bne 1b
164
165 /* Clear L2I */
138 xoris r4,r4,L2CR_L2I@h 166 xoris r4,r4,L2CR_L2I@h
139 sync 167 sync
140 mtspr SPRN_L2CR,r4 168 mtspr SPRN_L2CR,r4
@@ -142,14 +170,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
142 170
143 /* now disable the L1 data cache */ 171 /* now disable the L1 data cache */
144 mfspr r0,SPRN_HID0 172 mfspr r0,SPRN_HID0
145 rlwinm r0,r0,0,~HID0_DCE 173 rlwinm r0,r0,0,~(HID0_DCE|HID0_ICE)
146 mtspr SPRN_HID0,r0 174 mtspr SPRN_HID0,r0
147 sync 175 sync
148 isync 176 isync
149 177
150 /* Restore HID0[DPM] to whatever it was before */ 178 /* Restore HID0[DPM] to whatever it was before */
151 sync 179 sync
152 mtspr SPRN_HID0,r8 180 mfspr r0,SPRN_HID0
181 rlwimi r0,r8,0,11,11 /* Turn back HID0[DPM] */
182 mtspr SPRN_HID0,r0
153 sync 183 sync
154 184
155 /* restore DR and EE */ 185 /* restore DR and EE */
@@ -201,7 +231,7 @@ flush_disable_745x:
201 mtctr r4 231 mtctr r4
202 li r4,0 232 li r4,0
2031: 2331:
204 lwzx r0,r0,r4 234 lwz r0,0(r4)
205 addi r4,r4,32 /* Go to start of next cache line */ 235 addi r4,r4,32 /* Go to start of next cache line */
206 bdnz 1b 236 bdnz 1b
207 isync 237 isync
diff --git a/arch/ppc/platforms/pmac_feature.c b/arch/ppc/platforms/pmac_feature.c
index 46cbf36722db..867336ad5d36 100644
--- a/arch/ppc/platforms/pmac_feature.c
+++ b/arch/ppc/platforms/pmac_feature.c
@@ -1590,6 +1590,114 @@ intrepid_shutdown(struct macio_chip* macio, int sleep_mode)
1590 mdelay(10); 1590 mdelay(10);
1591} 1591}
1592 1592
1593
1594void __pmac pmac_tweak_clock_spreading(int enable)
1595{
1596 struct macio_chip* macio = &macio_chips[0];
1597
1598 /* Hack for doing clock spreading on some machines PowerBooks and
1599 * iBooks. This implements the "platform-do-clockspreading" OF
1600 * property as decoded manually on various models. For safety, we also
1601 * check the product ID in the device-tree in cases we'll whack the i2c
1602 * chip to make reasonably sure we won't set wrong values in there
1603 *
1604 * Of course, ultimately, we have to implement a real parser for
1605 * the platform-do-* stuff...
1606 */
1607
1608 if (macio->type == macio_intrepid) {
1609 if (enable)
1610 UN_OUT(UNI_N_CLOCK_SPREADING, 2);
1611 else
1612 UN_OUT(UNI_N_CLOCK_SPREADING, 0);
1613 mdelay(40);
1614 }
1615
1616 while (machine_is_compatible("PowerBook5,2") ||
1617 machine_is_compatible("PowerBook5,3") ||
1618 machine_is_compatible("PowerBook6,2") ||
1619 machine_is_compatible("PowerBook6,3")) {
1620 struct device_node *ui2c = of_find_node_by_type(NULL, "i2c");
1621 struct device_node *dt = of_find_node_by_name(NULL, "device-tree");
1622 u8 buffer[9];
1623 u32 *productID;
1624 int i, rc, changed = 0;
1625
1626 if (dt == NULL)
1627 break;
1628 productID = (u32 *)get_property(dt, "pid#", NULL);
1629 if (productID == NULL)
1630 break;
1631 while(ui2c) {
1632 struct device_node *p = of_get_parent(ui2c);
1633 if (p && !strcmp(p->name, "uni-n"))
1634 break;
1635 ui2c = of_find_node_by_type(ui2c, "i2c");
1636 }
1637 if (ui2c == NULL)
1638 break;
1639 DBG("Trying to bump clock speed for PID: %08x...\n", *productID);
1640 rc = pmac_low_i2c_open(ui2c, 1);
1641 if (rc != 0)
1642 break;
1643 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
1644 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
1645 DBG("read result: %d,", rc);
1646 if (rc != 0) {
1647 pmac_low_i2c_close(ui2c);
1648 break;
1649 }
1650 for (i=0; i<9; i++)
1651 DBG(" %02x", buffer[i]);
1652 DBG("\n");
1653
1654 switch(*productID) {
1655 case 0x1182: /* AlBook 12" rev 2 */
1656 case 0x1183: /* iBook G4 12" */
1657 buffer[0] = (buffer[0] & 0x8f) | 0x70;
1658 buffer[2] = (buffer[2] & 0x7f) | 0x00;
1659 buffer[5] = (buffer[5] & 0x80) | 0x31;
1660 buffer[6] = (buffer[6] & 0x40) | 0xb0;
1661 buffer[7] = (buffer[7] & 0x00) | (enable ? 0xc0 : 0xba);
1662 buffer[8] = (buffer[8] & 0x00) | 0x30;
1663 changed = 1;
1664 break;
1665 case 0x3142: /* AlBook 15" (ATI M10) */
1666 case 0x3143: /* AlBook 17" (ATI M10) */
1667 buffer[0] = (buffer[0] & 0xaf) | 0x50;
1668 buffer[2] = (buffer[2] & 0x7f) | 0x00;
1669 buffer[5] = (buffer[5] & 0x80) | 0x31;
1670 buffer[6] = (buffer[6] & 0x40) | 0xb0;
1671 buffer[7] = (buffer[7] & 0x00) | (enable ? 0xd0 : 0xc0);
1672 buffer[8] = (buffer[8] & 0x00) | 0x30;
1673 changed = 1;
1674 break;
1675 default:
1676 DBG("i2c-hwclock: Machine model not handled\n");
1677 break;
1678 }
1679 if (!changed) {
1680 pmac_low_i2c_close(ui2c);
1681 break;
1682 }
1683 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub);
1684 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9);
1685 DBG("write result: %d,", rc);
1686 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
1687 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
1688 DBG("read result: %d,", rc);
1689 if (rc != 0) {
1690 pmac_low_i2c_close(ui2c);
1691 break;
1692 }
1693 for (i=0; i<9; i++)
1694 DBG(" %02x", buffer[i]);
1695 pmac_low_i2c_close(ui2c);
1696 break;
1697 }
1698}
1699
1700
1593static int __pmac 1701static int __pmac
1594core99_sleep(void) 1702core99_sleep(void)
1595{ 1703{
@@ -1601,12 +1709,6 @@ core99_sleep(void)
1601 macio->type != macio_intrepid) 1709 macio->type != macio_intrepid)
1602 return -ENODEV; 1710 return -ENODEV;
1603 1711
1604 /* The device-tree contains that in the hwclock node */
1605 if (macio->type == macio_intrepid) {
1606 UN_OUT(UNI_N_CLOCK_SPREADING, 0);
1607 mdelay(40);
1608 }
1609
1610 /* We power off the wireless slot in case it was not done 1712 /* We power off the wireless slot in case it was not done
1611 * by the driver. We don't power it on automatically however 1713 * by the driver. We don't power it on automatically however
1612 */ 1714 */
@@ -1749,12 +1851,6 @@ core99_wake_up(void)
1749 UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl); 1851 UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl);
1750 udelay(100); 1852 udelay(100);
1751 1853
1752 /* Restore clock spreading */
1753 if (macio->type == macio_intrepid) {
1754 UN_OUT(UNI_N_CLOCK_SPREADING, 2);
1755 mdelay(40);
1756 }
1757
1758 return 0; 1854 return 0;
1759} 1855}
1760 1856
@@ -2149,7 +2245,7 @@ static struct pmac_mb_def pmac_mb_defs[] __pmacdata = {
2149 }, 2245 },
2150 { "PowerBook1,1", "PowerBook 101 (Lombard)", 2246 { "PowerBook1,1", "PowerBook 101 (Lombard)",
2151 PMAC_TYPE_101_PBOOK, paddington_features, 2247 PMAC_TYPE_101_PBOOK, paddington_features,
2152 PMAC_MB_MAY_SLEEP | PMAC_MB_MOBILE 2248 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2153 }, 2249 },
2154 { "PowerBook2,1", "iBook (first generation)", 2250 { "PowerBook2,1", "iBook (first generation)",
2155 PMAC_TYPE_ORIG_IBOOK, core99_features, 2251 PMAC_TYPE_ORIG_IBOOK, core99_features,
@@ -2718,97 +2814,11 @@ set_initial_features(void)
2718 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N); 2814 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
2719 } 2815 }
2720 2816
2721 /* Hack for bumping clock speed on the new PowerBooks and the 2817 /* Some machine models need the clock chip to be properly setup for
2722 * iBook G4. This implements the "platform-do-clockspreading" OF 2818 * clock spreading now. This should be a platform function but we
2723 * property. For safety, we also check the product ID in the 2819 * don't do these at the moment
2724 * device-tree to make reasonably sure we won't set wrong values
2725 * in the clock chip.
2726 *
2727 * Of course, ultimately, we have to implement a real parser for
2728 * the platform-do-* stuff...
2729 */ 2820 */
2730 while (machine_is_compatible("PowerBook5,2") || 2821 pmac_tweak_clock_spreading(1);
2731 machine_is_compatible("PowerBook5,3") ||
2732 machine_is_compatible("PowerBook6,2") ||
2733 machine_is_compatible("PowerBook6,3")) {
2734 struct device_node *ui2c = of_find_node_by_type(NULL, "i2c");
2735 struct device_node *dt = of_find_node_by_name(NULL, "device-tree");
2736 u8 buffer[9];
2737 u32 *productID;
2738 int i, rc, changed = 0;
2739
2740 if (dt == NULL)
2741 break;
2742 productID = (u32 *)get_property(dt, "pid#", NULL);
2743 if (productID == NULL)
2744 break;
2745 while(ui2c) {
2746 struct device_node *p = of_get_parent(ui2c);
2747 if (p && !strcmp(p->name, "uni-n"))
2748 break;
2749 ui2c = of_find_node_by_type(ui2c, "i2c");
2750 }
2751 if (ui2c == NULL)
2752 break;
2753 DBG("Trying to bump clock speed for PID: %08x...\n", *productID);
2754 rc = pmac_low_i2c_open(ui2c, 1);
2755 if (rc != 0)
2756 break;
2757 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
2758 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
2759 DBG("read result: %d,", rc);
2760 if (rc != 0) {
2761 pmac_low_i2c_close(ui2c);
2762 break;
2763 }
2764 for (i=0; i<9; i++)
2765 DBG(" %02x", buffer[i]);
2766 DBG("\n");
2767
2768 switch(*productID) {
2769 case 0x1182: /* AlBook 12" rev 2 */
2770 case 0x1183: /* iBook G4 12" */
2771 buffer[0] = (buffer[0] & 0x8f) | 0x70;
2772 buffer[2] = (buffer[2] & 0x7f) | 0x00;
2773 buffer[5] = (buffer[5] & 0x80) | 0x31;
2774 buffer[6] = (buffer[6] & 0x40) | 0xb0;
2775 buffer[7] = (buffer[7] & 0x00) | 0xc0;
2776 buffer[8] = (buffer[8] & 0x00) | 0x30;
2777 changed = 1;
2778 break;
2779 case 0x3142: /* AlBook 15" (ATI M10) */
2780 case 0x3143: /* AlBook 17" (ATI M10) */
2781 buffer[0] = (buffer[0] & 0xaf) | 0x50;
2782 buffer[2] = (buffer[2] & 0x7f) | 0x00;
2783 buffer[5] = (buffer[5] & 0x80) | 0x31;
2784 buffer[6] = (buffer[6] & 0x40) | 0xb0;
2785 buffer[7] = (buffer[7] & 0x00) | 0xd0;
2786 buffer[8] = (buffer[8] & 0x00) | 0x30;
2787 changed = 1;
2788 break;
2789 default:
2790 DBG("i2c-hwclock: Machine model not handled\n");
2791 break;
2792 }
2793 if (!changed) {
2794 pmac_low_i2c_close(ui2c);
2795 break;
2796 }
2797 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub);
2798 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9);
2799 DBG("write result: %d,", rc);
2800 pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
2801 rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
2802 DBG("read result: %d,", rc);
2803 if (rc != 0) {
2804 pmac_low_i2c_close(ui2c);
2805 break;
2806 }
2807 for (i=0; i<9; i++)
2808 DBG(" %02x", buffer[i]);
2809 pmac_low_i2c_close(ui2c);
2810 break;
2811 }
2812 2822
2813#endif /* CONFIG_POWER4 */ 2823#endif /* CONFIG_POWER4 */
2814 2824
diff --git a/arch/ppc/platforms/pmac_low_i2c.c b/arch/ppc/platforms/pmac_low_i2c.c
index d07579f2b8b9..08583fce1692 100644
--- a/arch/ppc/platforms/pmac_low_i2c.c
+++ b/arch/ppc/platforms/pmac_low_i2c.c
@@ -54,7 +54,7 @@ struct low_i2c_host
54 int mode; /* Current mode */ 54 int mode; /* Current mode */
55 int channel; /* Current channel */ 55 int channel; /* Current channel */
56 int num_channels; /* Number of channels */ 56 int num_channels; /* Number of channels */
57 unsigned long base; /* For keywest-i2c, base address */ 57 void __iomem * base; /* For keywest-i2c, base address */
58 int bsteps; /* And register stepping */ 58 int bsteps; /* And register stepping */
59 int speed; /* And speed */ 59 int speed; /* And speed */
60}; 60};
@@ -154,14 +154,12 @@ static const char *__kw_state_names[] = {
154 154
155static inline u8 __kw_read_reg(struct low_i2c_host *host, reg_t reg) 155static inline u8 __kw_read_reg(struct low_i2c_host *host, reg_t reg)
156{ 156{
157 return in_8(((volatile u8 *)host->base) 157 return in_8(host->base + (((unsigned)reg) << host->bsteps));
158 + (((unsigned)reg) << host->bsteps));
159} 158}
160 159
161static inline void __kw_write_reg(struct low_i2c_host *host, reg_t reg, u8 val) 160static inline void __kw_write_reg(struct low_i2c_host *host, reg_t reg, u8 val)
162{ 161{
163 out_8(((volatile u8 *)host->base) 162 out_8(host->base + (((unsigned)reg) << host->bsteps), val);
164 + (((unsigned)reg) << host->bsteps), val);
165 (void)__kw_read_reg(host, reg_subaddr); 163 (void)__kw_read_reg(host, reg_subaddr);
166} 164}
167 165
@@ -370,7 +368,7 @@ static void keywest_low_i2c_add(struct device_node *np)
370 break; 368 break;
371 } 369 }
372 host->mode = pmac_low_i2c_mode_std; 370 host->mode = pmac_low_i2c_mode_std;
373 host->base = (unsigned long)ioremap(np->addrs[0].address + aoffset, 371 host->base = ioremap(np->addrs[0].address + aoffset,
374 np->addrs[0].size); 372 np->addrs[0].size);
375 host->func = keywest_low_i2c_func; 373 host->func = keywest_low_i2c_func;
376} 374}
diff --git a/arch/ppc/platforms/pmac_sleep.S b/arch/ppc/platforms/pmac_sleep.S
index 3139b6766ad3..f459ade1bd63 100644
--- a/arch/ppc/platforms/pmac_sleep.S
+++ b/arch/ppc/platforms/pmac_sleep.S
@@ -267,6 +267,10 @@ grackle_wake_up:
267 /* Restore various CPU config stuffs */ 267 /* Restore various CPU config stuffs */
268 bl __restore_cpu_setup 268 bl __restore_cpu_setup
269 269
270 /* Make sure all FPRs have been initialized */
271 bl reloc_offset
272 bl __init_fpu_registers
273
270 /* Invalidate & enable L1 cache, we don't care about 274 /* Invalidate & enable L1 cache, we don't care about
271 * whatever the ROM may have tried to write to memory 275 * whatever the ROM may have tried to write to memory
272 */ 276 */
diff --git a/arch/ppc/platforms/pmac_smp.c b/arch/ppc/platforms/pmac_smp.c
index 731841f9a5b8..8e049dab4e63 100644
--- a/arch/ppc/platforms/pmac_smp.c
+++ b/arch/ppc/platforms/pmac_smp.c
@@ -91,11 +91,11 @@ extern void __secondary_start_psurge3(void); /* Temporary horrible hack */
91#define PSURGE_QUAD_BIC(r, v) (PSURGE_QUAD_OUT((r), PSURGE_QUAD_IN(r) & ~(v))) 91#define PSURGE_QUAD_BIC(r, v) (PSURGE_QUAD_OUT((r), PSURGE_QUAD_IN(r) & ~(v)))
92 92
93/* virtual addresses for the above */ 93/* virtual addresses for the above */
94static volatile u8 *hhead_base; 94static volatile u8 __iomem *hhead_base;
95static volatile u8 *quad_base; 95static volatile u8 __iomem *quad_base;
96static volatile u32 *psurge_pri_intr; 96static volatile u32 __iomem *psurge_pri_intr;
97static volatile u8 *psurge_sec_intr; 97static volatile u8 __iomem *psurge_sec_intr;
98static volatile u32 *psurge_start; 98static volatile u32 __iomem *psurge_start;
99 99
100/* values for psurge_type */ 100/* values for psurge_type */
101#define PSURGE_NONE -1 101#define PSURGE_NONE -1
@@ -322,10 +322,10 @@ static int __init smp_psurge_probe(void)
322 /* All released cards using this HW design have 4 CPUs */ 322 /* All released cards using this HW design have 4 CPUs */
323 ncpus = 4; 323 ncpus = 4;
324 } else { 324 } else {
325 iounmap((void *) quad_base); 325 iounmap(quad_base);
326 if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) { 326 if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) {
327 /* not a dual-cpu card */ 327 /* not a dual-cpu card */
328 iounmap((void *) hhead_base); 328 iounmap(hhead_base);
329 psurge_type = PSURGE_NONE; 329 psurge_type = PSURGE_NONE;
330 return 1; 330 return 1;
331 } 331 }
diff --git a/arch/ppc/platforms/pmac_time.c b/arch/ppc/platforms/pmac_time.c
index 09636546f44e..de60ccc7db9f 100644
--- a/arch/ppc/platforms/pmac_time.c
+++ b/arch/ppc/platforms/pmac_time.c
@@ -165,7 +165,7 @@ int __init
165via_calibrate_decr(void) 165via_calibrate_decr(void)
166{ 166{
167 struct device_node *vias; 167 struct device_node *vias;
168 volatile unsigned char *via; 168 volatile unsigned char __iomem *via;
169 int count = VIA_TIMER_FREQ_6 / 100; 169 int count = VIA_TIMER_FREQ_6 / 100;
170 unsigned int dstart, dend; 170 unsigned int dstart, dend;
171 171
@@ -176,8 +176,7 @@ via_calibrate_decr(void)
176 vias = find_devices("via"); 176 vias = find_devices("via");
177 if (vias == 0 || vias->n_addrs == 0) 177 if (vias == 0 || vias->n_addrs == 0)
178 return 0; 178 return 0;
179 via = (volatile unsigned char *) 179 via = ioremap(vias->addrs[0].address, vias->addrs[0].size);
180 ioremap(vias->addrs[0].address, vias->addrs[0].size);
181 180
182 /* set timer 1 for continuous interrupts */ 181 /* set timer 1 for continuous interrupts */
183 out_8(&via[ACR], (via[ACR] & ~T1MODE) | T1MODE_CONT); 182 out_8(&via[ACR], (via[ACR] & ~T1MODE) | T1MODE_CONT);
@@ -202,7 +201,7 @@ via_calibrate_decr(void)
202 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",
203 tb_ticks_per_jiffy, dstart - dend); 202 tb_ticks_per_jiffy, dstart - dend);
204 203
205 iounmap((void*)via); 204 iounmap(via);
206 205
207 return 1; 206 return 1;
208} 207}
diff --git a/arch/ppc/platforms/radstone_ppc7d.c b/arch/ppc/platforms/radstone_ppc7d.c
index 2a99b43737a8..c30607a972d8 100644
--- a/arch/ppc/platforms/radstone_ppc7d.c
+++ b/arch/ppc/platforms/radstone_ppc7d.c
@@ -68,6 +68,7 @@
68#define PPC7D_RST_PIN 17 /* GPP17 */ 68#define PPC7D_RST_PIN 17 /* GPP17 */
69 69
70extern u32 mv64360_irq_base; 70extern u32 mv64360_irq_base;
71extern spinlock_t rtc_lock;
71 72
72static struct mv64x60_handle bh; 73static struct mv64x60_handle bh;
73static int ppc7d_has_alma; 74static int ppc7d_has_alma;
@@ -75,6 +76,11 @@ static int ppc7d_has_alma;
75extern void gen550_progress(char *, unsigned short); 76extern void gen550_progress(char *, unsigned short);
76extern void gen550_init(int, struct uart_port *); 77extern void gen550_init(int, struct uart_port *);
77 78
79/* FIXME - move to h file */
80extern int ds1337_do_command(int id, int cmd, void *arg);
81#define DS1337_GET_DATE 0
82#define DS1337_SET_DATE 1
83
78/* residual data */ 84/* residual data */
79unsigned char __res[sizeof(bd_t)]; 85unsigned char __res[sizeof(bd_t)];
80 86
@@ -253,6 +259,8 @@ static int ppc7d_show_cpuinfo(struct seq_file *m)
253 u8 val1, val2; 259 u8 val1, val2;
254 static int flash_sizes[4] = { 64, 32, 0, 16 }; 260 static int flash_sizes[4] = { 64, 32, 0, 16 };
255 static int flash_banks[4] = { 4, 3, 2, 1 }; 261 static int flash_banks[4] = { 4, 3, 2, 1 };
262 static int sdram_bank_sizes[4] = { 128, 256, 512, 1 };
263 int sdram_num_banks = 2;
256 static char *pci_modes[] = { "PCI33", "PCI66", 264 static char *pci_modes[] = { "PCI33", "PCI66",
257 "Unknown", "Unknown", 265 "Unknown", "Unknown",
258 "PCIX33", "PCIX66", 266 "PCIX33", "PCIX66",
@@ -279,13 +287,17 @@ static int ppc7d_show_cpuinfo(struct seq_file *m)
279 (val1 == PPC7D_CPLD_MB_TYPE_PLL_100) ? 100 : 287 (val1 == PPC7D_CPLD_MB_TYPE_PLL_100) ? 100 :
280 (val1 == PPC7D_CPLD_MB_TYPE_PLL_64) ? 64 : 0); 288 (val1 == PPC7D_CPLD_MB_TYPE_PLL_64) ? 64 : 0);
281 289
290 val = inb(PPC7D_CPLD_MEM_CONFIG);
291 if (val & PPC7D_CPLD_SDRAM_BANK_NUM_MASK) sdram_num_banks--;
292
282 val = inb(PPC7D_CPLD_MEM_CONFIG_EXTEND); 293 val = inb(PPC7D_CPLD_MEM_CONFIG_EXTEND);
283 val1 = val & PPC7D_CPLD_SDRAM_BANK_SIZE_MASK; 294 val1 = (val & PPC7D_CPLD_SDRAM_BANK_SIZE_MASK) >> 6;
284 seq_printf(m, "SDRAM\t\t: %d%c", 295 seq_printf(m, "SDRAM\t\t: %d banks of %d%c, total %d%c",
285 (val1 == PPC7D_CPLD_SDRAM_BANK_SIZE_128M) ? 128 : 296 sdram_num_banks,
286 (val1 == PPC7D_CPLD_SDRAM_BANK_SIZE_256M) ? 256 : 297 sdram_bank_sizes[val1],
287 (val1 == PPC7D_CPLD_SDRAM_BANK_SIZE_512M) ? 512 : 1, 298 (sdram_bank_sizes[val1] < 128) ? 'G' : 'M',
288 (val1 == PPC7D_CPLD_SDRAM_BANK_SIZE_1G) ? 'G' : 'M'); 299 sdram_num_banks * sdram_bank_sizes[val1],
300 (sdram_bank_sizes[val1] < 128) ? 'G' : 'M');
289 if (val2 & PPC7D_CPLD_MB_TYPE_ECC_FITTED_MASK) { 301 if (val2 & PPC7D_CPLD_MB_TYPE_ECC_FITTED_MASK) {
290 seq_printf(m, " [ECC %sabled]", 302 seq_printf(m, " [ECC %sabled]",
291 (val2 & PPC7D_CPLD_MB_TYPE_ECC_ENABLE_MASK) ? "en" : 303 (val2 & PPC7D_CPLD_MB_TYPE_ECC_ENABLE_MASK) ? "en" :
@@ -1236,6 +1248,38 @@ static void __init ppc7d_setup_arch(void)
1236 printk(KERN_INFO "Radstone Technology PPC7D\n"); 1248 printk(KERN_INFO "Radstone Technology PPC7D\n");
1237 if (ppc_md.progress) 1249 if (ppc_md.progress)
1238 ppc_md.progress("ppc7d_setup_arch: exit", 0); 1250 ppc_md.progress("ppc7d_setup_arch: exit", 0);
1251
1252}
1253
1254/* Real Time Clock support.
1255 * PPC7D has a DS1337 accessed by I2C.
1256 */
1257static ulong ppc7d_get_rtc_time(void)
1258{
1259 struct rtc_time tm;
1260 int result;
1261
1262 spin_lock(&rtc_lock);
1263 result = ds1337_do_command(0, DS1337_GET_DATE, &tm);
1264 spin_unlock(&rtc_lock);
1265
1266 if (result == 0)
1267 result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
1268
1269 return result;
1270}
1271
1272static int ppc7d_set_rtc_time(unsigned long nowtime)
1273{
1274 struct rtc_time tm;
1275 int result;
1276
1277 spin_lock(&rtc_lock);
1278 to_tm(nowtime, &tm);
1279 result = ds1337_do_command(0, DS1337_SET_DATE, &tm);
1280 spin_unlock(&rtc_lock);
1281
1282 return result;
1239} 1283}
1240 1284
1241/* This kernel command line parameter can be used to have the target 1285/* This kernel command line parameter can be used to have the target
@@ -1293,6 +1337,10 @@ static void ppc7d_init2(void)
1293 data8 |= 0x07; 1337 data8 |= 0x07;
1294 outb(data8, PPC7D_CPLD_LEDS); 1338 outb(data8, PPC7D_CPLD_LEDS);
1295 1339
1340 /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */
1341 ppc_md.set_rtc_time = ppc7d_set_rtc_time;
1342 ppc_md.get_rtc_time = ppc7d_get_rtc_time;
1343
1296 pr_debug("%s: exit\n", __FUNCTION__); 1344 pr_debug("%s: exit\n", __FUNCTION__);
1297} 1345}
1298 1346
diff --git a/arch/ppc/platforms/radstone_ppc7d.h b/arch/ppc/platforms/radstone_ppc7d.h
index 4546fff2b0c3..938375510be4 100644
--- a/arch/ppc/platforms/radstone_ppc7d.h
+++ b/arch/ppc/platforms/radstone_ppc7d.h
@@ -240,6 +240,7 @@
240#define PPC7D_CPLD_FLASH_CNTL 0x086E 240#define PPC7D_CPLD_FLASH_CNTL 0x086E
241 241
242/* MEMORY_CONFIG_EXTEND */ 242/* MEMORY_CONFIG_EXTEND */
243#define PPC7D_CPLD_SDRAM_BANK_NUM_MASK 0x02
243#define PPC7D_CPLD_SDRAM_BANK_SIZE_MASK 0xc0 244#define PPC7D_CPLD_SDRAM_BANK_SIZE_MASK 0xc0
244#define PPC7D_CPLD_SDRAM_BANK_SIZE_128M 0 245#define PPC7D_CPLD_SDRAM_BANK_SIZE_128M 0
245#define PPC7D_CPLD_SDRAM_BANK_SIZE_256M 0x40 246#define PPC7D_CPLD_SDRAM_BANK_SIZE_256M 0x40
diff --git a/arch/ppc/syslib/cpm2_pic.c b/arch/ppc/syslib/cpm2_pic.c
index 954b07fc1df3..c867be6981cb 100644
--- a/arch/ppc/syslib/cpm2_pic.c
+++ b/arch/ppc/syslib/cpm2_pic.c
@@ -107,6 +107,11 @@ static void cpm2_end_irq(unsigned int irq_nr)
107 simr = &(cpm2_immr->im_intctl.ic_simrh); 107 simr = &(cpm2_immr->im_intctl.ic_simrh);
108 ppc_cached_irq_mask[word] |= 1 << bit; 108 ppc_cached_irq_mask[word] |= 1 << bit;
109 simr[word] = ppc_cached_irq_mask[word]; 109 simr[word] = ppc_cached_irq_mask[word];
110 /*
111 * Work around large numbers of spurious IRQs on PowerPC 82xx
112 * systems.
113 */
114 mb();
110 } 115 }
111} 116}
112 117
diff --git a/arch/ppc/syslib/m8260_pci.c b/arch/ppc/syslib/m8260_pci.c
index bd564fb35ab6..057cc3f8ff37 100644
--- a/arch/ppc/syslib/m8260_pci.c
+++ b/arch/ppc/syslib/m8260_pci.c
@@ -171,10 +171,9 @@ void __init m8260_find_bridges(void)
171 m8260_setup_pci(hose); 171 m8260_setup_pci(hose);
172 hose->pci_mem_offset = MPC826x_PCI_MEM_OFFSET; 172 hose->pci_mem_offset = MPC826x_PCI_MEM_OFFSET;
173 173
174 isa_io_base = 174 hose->io_base_virt = ioremap(MPC826x_PCI_IO_BASE,
175 (unsigned long) ioremap(MPC826x_PCI_IO_BASE,
176 MPC826x_PCI_IO_SIZE); 175 MPC826x_PCI_IO_SIZE);
177 hose->io_base_virt = (void *) isa_io_base; 176 isa_io_base = (unsigned long) hose->io_base_virt;
178 177
179 /* setup resources */ 178 /* setup resources */
180 pci_init_resource(&hose->mem_resources[0], 179 pci_init_resource(&hose->mem_resources[0],
diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c
index c723efd954a6..59cf3e8bd1a0 100644
--- a/arch/ppc/syslib/mpc52xx_pci.c
+++ b/arch/ppc/syslib/mpc52xx_pci.c
@@ -205,13 +205,11 @@ mpc52xx_find_bridges(void)
205 205
206 hose->pci_mem_offset = MPC52xx_PCI_MEM_OFFSET; 206 hose->pci_mem_offset = MPC52xx_PCI_MEM_OFFSET;
207 207
208 isa_io_base = 208 hose->io_base_virt = ioremap(MPC52xx_PCI_IO_BASE, MPC52xx_PCI_IO_SIZE);
209 (unsigned long) ioremap(MPC52xx_PCI_IO_BASE, 209 isa_io_base = (unsigned long) hose->io_base_virt;
210 MPC52xx_PCI_IO_SIZE);
211 hose->io_base_virt = (void *) isa_io_base;
212 210
213 hose->cfg_addr = &pci_regs->car; 211 hose->cfg_addr = &pci_regs->car;
214 hose->cfg_data = (void __iomem *) isa_io_base; 212 hose->cfg_data = hose->io_base_virt;
215 213
216 /* Setup resources */ 214 /* Setup resources */
217 pci_init_resource(&hose->mem_resources[0], 215 pci_init_resource(&hose->mem_resources[0],
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
index 81f1968c3269..152c3ef1312a 100644
--- a/arch/ppc/syslib/ppc85xx_setup.c
+++ b/arch/ppc/syslib/ppc85xx_setup.c
@@ -280,16 +280,14 @@ mpc85xx_setup_hose(void)
280 hose_a->io_space.end = MPC85XX_PCI1_UPPER_IO; 280 hose_a->io_space.end = MPC85XX_PCI1_UPPER_IO;
281 hose_a->io_base_phys = MPC85XX_PCI1_IO_BASE; 281 hose_a->io_base_phys = MPC85XX_PCI1_IO_BASE;
282#ifdef CONFIG_85xx_PCI2 282#ifdef CONFIG_85xx_PCI2
283 isa_io_base = 283 hose_a->io_base_virt = ioremap(MPC85XX_PCI1_IO_BASE,
284 (unsigned long) ioremap(MPC85XX_PCI1_IO_BASE,
285 MPC85XX_PCI1_IO_SIZE + 284 MPC85XX_PCI1_IO_SIZE +
286 MPC85XX_PCI2_IO_SIZE); 285 MPC85XX_PCI2_IO_SIZE);
287#else 286#else
288 isa_io_base = 287 hose_a->io_base_virt = ioremap(MPC85XX_PCI1_IO_BASE,
289 (unsigned long) ioremap(MPC85XX_PCI1_IO_BASE,
290 MPC85XX_PCI1_IO_SIZE); 288 MPC85XX_PCI1_IO_SIZE);
291#endif 289#endif
292 hose_a->io_base_virt = (void *) isa_io_base; 290 isa_io_base = (unsigned long)hose_a->io_base_virt;
293 291
294 /* setup resources */ 292 /* setup resources */
295 pci_init_resource(&hose_a->mem_resources[0], 293 pci_init_resource(&hose_a->mem_resources[0],
@@ -329,8 +327,8 @@ mpc85xx_setup_hose(void)
329 hose_b->io_space.start = MPC85XX_PCI2_LOWER_IO; 327 hose_b->io_space.start = MPC85XX_PCI2_LOWER_IO;
330 hose_b->io_space.end = MPC85XX_PCI2_UPPER_IO; 328 hose_b->io_space.end = MPC85XX_PCI2_UPPER_IO;
331 hose_b->io_base_phys = MPC85XX_PCI2_IO_BASE; 329 hose_b->io_base_phys = MPC85XX_PCI2_IO_BASE;
332 hose_b->io_base_virt = (void *) isa_io_base + MPC85XX_PCI1_IO_SIZE; 330 hose_b->io_base_virt = hose_a->io_base_virt + MPC85XX_PCI1_IO_SIZE;
333 331
334 /* setup resources */ 332 /* setup resources */
335 pci_init_resource(&hose_b->mem_resources[0], 333 pci_init_resource(&hose_b->mem_resources[0],
336 MPC85XX_PCI2_LOWER_MEM, 334 MPC85XX_PCI2_LOWER_MEM,
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index ef1f05e437c4..5cb343883e4d 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -40,6 +40,10 @@ config COMPAT
40 bool 40 bool
41 default y 41 default y
42 42
43config SCHED_NO_NO_OMIT_FRAME_POINTER
44 bool
45 default y
46
43# We optimistically allocate largepages from the VM, so make the limit 47# We optimistically allocate largepages from the VM, so make the limit
44# large enough (16MB). This badly named config option is actually 48# large enough (16MB). This badly named config option is actually
45# max order + 1 49# max order + 1
@@ -258,6 +262,7 @@ config PPC_RTAS
258config RTAS_PROC 262config RTAS_PROC
259 bool "Proc interface to RTAS" 263 bool "Proc interface to RTAS"
260 depends on PPC_RTAS 264 depends on PPC_RTAS
265 default y
261 266
262config RTAS_FLASH 267config RTAS_FLASH
263 tristate "Firmware flash interface" 268 tristate "Firmware flash interface"
@@ -293,6 +298,9 @@ config SECCOMP
293 298
294endmenu 299endmenu
295 300
301config ISA_DMA_API
302 bool
303 default y
296 304
297menu "General setup" 305menu "General setup"
298 306
diff --git a/arch/ppc64/Kconfig.debug b/arch/ppc64/Kconfig.debug
index e341a129da80..46b1ce58da3b 100644
--- a/arch/ppc64/Kconfig.debug
+++ b/arch/ppc64/Kconfig.debug
@@ -5,6 +5,9 @@ source "lib/Kconfig.debug"
5config DEBUG_STACKOVERFLOW 5config DEBUG_STACKOVERFLOW
6 bool "Check for stack overflows" 6 bool "Check for stack overflows"
7 depends on DEBUG_KERNEL 7 depends on DEBUG_KERNEL
8 help
9 This option will cause messages to be printed if free stack space
10 drops below a certain limit.
8 11
9config KPROBES 12config KPROBES
10 bool "Kprobes" 13 bool "Kprobes"
diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile
index d33e20bcc52f..691f3008e698 100644
--- a/arch/ppc64/Makefile
+++ b/arch/ppc64/Makefile
@@ -56,13 +56,20 @@ LDFLAGS_vmlinux := -Bstatic -e $(KERNELLOAD) -Ttext $(KERNELLOAD)
56CFLAGS += -msoft-float -pipe -mminimal-toc -mtraceback=none \ 56CFLAGS += -msoft-float -pipe -mminimal-toc -mtraceback=none \
57 -mcall-aixdesc 57 -mcall-aixdesc
58 58
59GCC_VERSION := $(call cc-version)
60GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi ;)
61
59ifeq ($(CONFIG_POWER4_ONLY),y) 62ifeq ($(CONFIG_POWER4_ONLY),y)
60ifeq ($(CONFIG_ALTIVEC),y) 63ifeq ($(CONFIG_ALTIVEC),y)
64ifeq ($(GCC_BROKEN_VEC),y)
61 CFLAGS += $(call cc-option,-mcpu=970) 65 CFLAGS += $(call cc-option,-mcpu=970)
62else 66else
63 CFLAGS += $(call cc-option,-mcpu=power4) 67 CFLAGS += $(call cc-option,-mcpu=power4)
64endif 68endif
65else 69else
70 CFLAGS += $(call cc-option,-mcpu=power4)
71endif
72else
66 CFLAGS += $(call cc-option,-mtune=power4) 73 CFLAGS += $(call cc-option,-mtune=power4)
67endif 74endif
68 75
diff --git a/arch/ppc64/boot/addnote.c b/arch/ppc64/boot/addnote.c
index 66ff8103bf4d..719663a694bb 100644
--- a/arch/ppc64/boot/addnote.c
+++ b/arch/ppc64/boot/addnote.c
@@ -19,6 +19,7 @@
19#include <unistd.h> 19#include <unistd.h>
20#include <string.h> 20#include <string.h>
21 21
22/* CHRP note section */
22char arch[] = "PowerPC"; 23char arch[] = "PowerPC";
23 24
24#define N_DESCR 6 25#define N_DESCR 6
@@ -31,6 +32,29 @@ unsigned int descr[N_DESCR] = {
31 0x4000, /* load-base */ 32 0x4000, /* load-base */
32}; 33};
33 34
35/* RPA note section */
36char rpaname[] = "IBM,RPA-Client-Config";
37
38/*
39 * Note: setting ignore_my_client_config *should* mean that OF ignores
40 * all the other fields, but there is a firmware bug which means that
41 * it looks at the splpar field at least. So these values need to be
42 * reasonable.
43 */
44#define N_RPA_DESCR 8
45unsigned int rpanote[N_RPA_DESCR] = {
46 0, /* lparaffinity */
47 64, /* min_rmo_size */
48 0, /* min_rmo_percent */
49 40, /* max_pft_size */
50 1, /* splpar */
51 -1, /* min_load */
52 0, /* new_mem_def */
53 1, /* ignore_my_client_config */
54};
55
56#define ROUNDUP(len) (((len) + 3) & ~3)
57
34unsigned char buf[512]; 58unsigned char buf[512];
35 59
36#define GET_16BE(off) ((buf[off] << 8) + (buf[(off)+1])) 60#define GET_16BE(off) ((buf[off] << 8) + (buf[(off)+1]))
@@ -69,7 +93,7 @@ main(int ac, char **av)
69{ 93{
70 int fd, n, i; 94 int fd, n, i;
71 int ph, ps, np; 95 int ph, ps, np;
72 int nnote, ns; 96 int nnote, nnote2, ns;
73 97
74 if (ac != 2) { 98 if (ac != 2) {
75 fprintf(stderr, "Usage: %s elf-file\n", av[0]); 99 fprintf(stderr, "Usage: %s elf-file\n", av[0]);
@@ -81,7 +105,8 @@ main(int ac, char **av)
81 exit(1); 105 exit(1);
82 } 106 }
83 107
84 nnote = strlen(arch) + 1 + (N_DESCR + 3) * 4; 108 nnote = 12 + ROUNDUP(strlen(arch) + 1) + sizeof(descr);
109 nnote2 = 12 + ROUNDUP(strlen(rpaname) + 1) + sizeof(rpanote);
85 110
86 n = read(fd, buf, sizeof(buf)); 111 n = read(fd, buf, sizeof(buf));
87 if (n < 0) { 112 if (n < 0) {
@@ -104,7 +129,7 @@ main(int ac, char **av)
104 np = GET_16BE(E_PHNUM); 129 np = GET_16BE(E_PHNUM);
105 if (ph < E_HSIZE || ps < PH_HSIZE || np < 1) 130 if (ph < E_HSIZE || ps < PH_HSIZE || np < 1)
106 goto notelf; 131 goto notelf;
107 if (ph + (np + 1) * ps + nnote > n) 132 if (ph + (np + 2) * ps + nnote + nnote2 > n)
108 goto nospace; 133 goto nospace;
109 134
110 for (i = 0; i < np; ++i) { 135 for (i = 0; i < np; ++i) {
@@ -117,12 +142,12 @@ main(int ac, char **av)
117 } 142 }
118 143
119 /* XXX check that the area we want to use is all zeroes */ 144 /* XXX check that the area we want to use is all zeroes */
120 for (i = 0; i < ps + nnote; ++i) 145 for (i = 0; i < 2 * ps + nnote + nnote2; ++i)
121 if (buf[ph + i] != 0) 146 if (buf[ph + i] != 0)
122 goto nospace; 147 goto nospace;
123 148
124 /* fill in the program header entry */ 149 /* fill in the program header entry */
125 ns = ph + ps; 150 ns = ph + 2 * ps;
126 PUT_32BE(ph + PH_TYPE, PT_NOTE); 151 PUT_32BE(ph + PH_TYPE, PT_NOTE);
127 PUT_32BE(ph + PH_OFFSET, ns); 152 PUT_32BE(ph + PH_OFFSET, ns);
128 PUT_32BE(ph + PH_FILESZ, nnote); 153 PUT_32BE(ph + PH_FILESZ, nnote);
@@ -134,11 +159,26 @@ main(int ac, char **av)
134 PUT_32BE(ns + 8, 0x1275); 159 PUT_32BE(ns + 8, 0x1275);
135 strcpy(&buf[ns + 12], arch); 160 strcpy(&buf[ns + 12], arch);
136 ns += 12 + strlen(arch) + 1; 161 ns += 12 + strlen(arch) + 1;
137 for (i = 0; i < N_DESCR; ++i) 162 for (i = 0; i < N_DESCR; ++i, ns += 4)
138 PUT_32BE(ns + i * 4, descr[i]); 163 PUT_32BE(ns, descr[i]);
164
165 /* fill in the second program header entry and the RPA note area */
166 ph += ps;
167 PUT_32BE(ph + PH_TYPE, PT_NOTE);
168 PUT_32BE(ph + PH_OFFSET, ns);
169 PUT_32BE(ph + PH_FILESZ, nnote2);
170
171 /* fill in the note area we point to */
172 PUT_32BE(ns, strlen(rpaname) + 1);
173 PUT_32BE(ns + 4, sizeof(rpanote));
174 PUT_32BE(ns + 8, 0x12759999);
175 strcpy(&buf[ns + 12], rpaname);
176 ns += 12 + ROUNDUP(strlen(rpaname) + 1);
177 for (i = 0; i < N_RPA_DESCR; ++i, ns += 4)
178 PUT_32BE(ns, rpanote[i]);
139 179
140 /* Update the number of program headers */ 180 /* Update the number of program headers */
141 PUT_16BE(E_PHNUM, np + 1); 181 PUT_16BE(E_PHNUM, np + 2);
142 182
143 /* write back */ 183 /* write back */
144 lseek(fd, (long) 0, SEEK_SET); 184 lseek(fd, (long) 0, SEEK_SET);
@@ -155,11 +195,11 @@ main(int ac, char **av)
155 exit(0); 195 exit(0);
156 196
157 notelf: 197 notelf:
158 fprintf(stderr, "%s does not appear to be an ELF file\n", av[0]); 198 fprintf(stderr, "%s does not appear to be an ELF file\n", av[1]);
159 exit(1); 199 exit(1);
160 200
161 nospace: 201 nospace:
162 fprintf(stderr, "sorry, I can't find space in %s to put the note\n", 202 fprintf(stderr, "sorry, I can't find space in %s to put the note\n",
163 av[0]); 203 av[1]);
164 exit(1); 204 exit(1);
165} 205}
diff --git a/arch/ppc64/boot/main.c b/arch/ppc64/boot/main.c
index b0fa86ad8b1b..da12ea2ca464 100644
--- a/arch/ppc64/boot/main.c
+++ b/arch/ppc64/boot/main.c
@@ -14,7 +14,6 @@
14#include <linux/string.h> 14#include <linux/string.h>
15#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/page.h> 16#include <asm/page.h>
17#include <asm/bootinfo.h>
18 17
19extern void *finddevice(const char *); 18extern void *finddevice(const char *);
20extern int getprop(void *, const char *, void *, int); 19extern int getprop(void *, const char *, void *, int);
diff --git a/arch/ppc64/boot/start.c b/arch/ppc64/boot/start.c
deleted file mode 100644
index ea247e79b55e..000000000000
--- a/arch/ppc64/boot/start.c
+++ /dev/null
@@ -1,654 +0,0 @@
1/*
2 * Copyright (C) Paul Mackerras 1997.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#include <stdarg.h>
10#include <linux/types.h>
11#include <linux/string.h>
12#include <linux/ctype.h>
13
14#include <asm/div64.h>
15
16int (*prom)(void *);
17
18void *chosen_handle;
19void *stdin;
20void *stdout;
21void *stderr;
22
23void exit(void);
24void *finddevice(const char *name);
25int getprop(void *phandle, const char *name, void *buf, int buflen);
26void chrpboot(int a1, int a2, void *prom); /* in main.c */
27
28void printk(char *fmt, ...);
29
30void
31start(int a1, int a2, void *promptr)
32{
33 prom = (int (*)(void *)) promptr;
34 chosen_handle = finddevice("/chosen");
35 if (chosen_handle == (void *) -1)
36 exit();
37 if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
38 exit();
39 stderr = stdout;
40 if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
41 exit();
42
43 chrpboot(a1, a2, promptr);
44 for (;;)
45 exit();
46}
47
48int
49write(void *handle, void *ptr, int nb)
50{
51 struct prom_args {
52 char *service;
53 int nargs;
54 int nret;
55 void *ihandle;
56 void *addr;
57 int len;
58 int actual;
59 } args;
60
61 args.service = "write";
62 args.nargs = 3;
63 args.nret = 1;
64 args.ihandle = handle;
65 args.addr = ptr;
66 args.len = nb;
67 args.actual = -1;
68 (*prom)(&args);
69 return args.actual;
70}
71
72int
73read(void *handle, void *ptr, int nb)
74{
75 struct prom_args {
76 char *service;
77 int nargs;
78 int nret;
79 void *ihandle;
80 void *addr;
81 int len;
82 int actual;
83 } args;
84
85 args.service = "read";
86 args.nargs = 3;
87 args.nret = 1;
88 args.ihandle = handle;
89 args.addr = ptr;
90 args.len = nb;
91 args.actual = -1;
92 (*prom)(&args);
93 return args.actual;
94}
95
96void
97exit()
98{
99 struct prom_args {
100 char *service;
101 } args;
102
103 for (;;) {
104 args.service = "exit";
105 (*prom)(&args);
106 }
107}
108
109void
110pause(void)
111{
112 struct prom_args {
113 char *service;
114 } args;
115
116 args.service = "enter";
117 (*prom)(&args);
118}
119
120void *
121finddevice(const char *name)
122{
123 struct prom_args {
124 char *service;
125 int nargs;
126 int nret;
127 const char *devspec;
128 void *phandle;
129 } args;
130
131 args.service = "finddevice";
132 args.nargs = 1;
133 args.nret = 1;
134 args.devspec = name;
135 args.phandle = (void *) -1;
136 (*prom)(&args);
137 return args.phandle;
138}
139
140void *
141claim(unsigned long virt, unsigned long size, unsigned long align)
142{
143 struct prom_args {
144 char *service;
145 int nargs;
146 int nret;
147 unsigned int virt;
148 unsigned int size;
149 unsigned int align;
150 void *ret;
151 } args;
152
153 args.service = "claim";
154 args.nargs = 3;
155 args.nret = 1;
156 args.virt = virt;
157 args.size = size;
158 args.align = align;
159 (*prom)(&args);
160 return args.ret;
161}
162
163int
164getprop(void *phandle, const char *name, void *buf, int buflen)
165{
166 struct prom_args {
167 char *service;
168 int nargs;
169 int nret;
170 void *phandle;
171 const char *name;
172 void *buf;
173 int buflen;
174 int size;
175 } args;
176
177 args.service = "getprop";
178 args.nargs = 4;
179 args.nret = 1;
180 args.phandle = phandle;
181 args.name = name;
182 args.buf = buf;
183 args.buflen = buflen;
184 args.size = -1;
185 (*prom)(&args);
186 return args.size;
187}
188
189int
190putc(int c, void *f)
191{
192 char ch = c;
193
194 if (c == '\n')
195 putc('\r', f);
196 return write(f, &ch, 1) == 1? c: -1;
197}
198
199int
200putchar(int c)
201{
202 return putc(c, stdout);
203}
204
205int
206fputs(char *str, void *f)
207{
208 int n = strlen(str);
209
210 return write(f, str, n) == n? 0: -1;
211}
212
213int
214readchar(void)
215{
216 char ch;
217
218 for (;;) {
219 switch (read(stdin, &ch, 1)) {
220 case 1:
221 return ch;
222 case -1:
223 printk("read(stdin) returned -1\r\n");
224 return -1;
225 }
226 }
227}
228
229static char line[256];
230static char *lineptr;
231static int lineleft;
232
233int
234getchar(void)
235{
236 int c;
237
238 if (lineleft == 0) {
239 lineptr = line;
240 for (;;) {
241 c = readchar();
242 if (c == -1 || c == 4)
243 break;
244 if (c == '\r' || c == '\n') {
245 *lineptr++ = '\n';
246 putchar('\n');
247 break;
248 }
249 switch (c) {
250 case 0177:
251 case '\b':
252 if (lineptr > line) {
253 putchar('\b');
254 putchar(' ');
255 putchar('\b');
256 --lineptr;
257 }
258 break;
259 case 'U' & 0x1F:
260 while (lineptr > line) {
261 putchar('\b');
262 putchar(' ');
263 putchar('\b');
264 --lineptr;
265 }
266 break;
267 default:
268 if (lineptr >= &line[sizeof(line) - 1])
269 putchar('\a');
270 else {
271 putchar(c);
272 *lineptr++ = c;
273 }
274 }
275 }
276 lineleft = lineptr - line;
277 lineptr = line;
278 }
279 if (lineleft == 0)
280 return -1;
281 --lineleft;
282 return *lineptr++;
283}
284
285
286
287/* String functions lifted from lib/vsprintf.c and lib/ctype.c */
288unsigned char _ctype[] = {
289_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
290_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
291_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
292_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
293_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
294_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
295_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
296_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
297_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
298_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
299_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
300_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
301_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
302_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
303_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
304_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
3050,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
3060,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
307_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */
308_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */
309_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */
310_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */
311_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */
312_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */
313
314size_t strnlen(const char * s, size_t count)
315{
316 const char *sc;
317
318 for (sc = s; count-- && *sc != '\0'; ++sc)
319 /* nothing */;
320 return sc - s;
321}
322
323unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
324{
325 unsigned long result = 0,value;
326
327 if (!base) {
328 base = 10;
329 if (*cp == '0') {
330 base = 8;
331 cp++;
332 if ((*cp == 'x') && isxdigit(cp[1])) {
333 cp++;
334 base = 16;
335 }
336 }
337 }
338 while (isxdigit(*cp) &&
339 (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
340 result = result*base + value;
341 cp++;
342 }
343 if (endp)
344 *endp = (char *)cp;
345 return result;
346}
347
348long simple_strtol(const char *cp,char **endp,unsigned int base)
349{
350 if(*cp=='-')
351 return -simple_strtoul(cp+1,endp,base);
352 return simple_strtoul(cp,endp,base);
353}
354
355static int skip_atoi(const char **s)
356{
357 int i=0;
358
359 while (isdigit(**s))
360 i = i*10 + *((*s)++) - '0';
361 return i;
362}
363
364#define ZEROPAD 1 /* pad with zero */
365#define SIGN 2 /* unsigned/signed long */
366#define PLUS 4 /* show plus */
367#define SPACE 8 /* space if plus */
368#define LEFT 16 /* left justified */
369#define SPECIAL 32 /* 0x */
370#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
371
372static char * number(char * str, long long num, int base, int size, int precision, int type)
373{
374 char c,sign,tmp[66];
375 const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
376 int i;
377
378 if (type & LARGE)
379 digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
380 if (type & LEFT)
381 type &= ~ZEROPAD;
382 if (base < 2 || base > 36)
383 return 0;
384 c = (type & ZEROPAD) ? '0' : ' ';
385 sign = 0;
386 if (type & SIGN) {
387 if (num < 0) {
388 sign = '-';
389 num = -num;
390 size--;
391 } else if (type & PLUS) {
392 sign = '+';
393 size--;
394 } else if (type & SPACE) {
395 sign = ' ';
396 size--;
397 }
398 }
399 if (type & SPECIAL) {
400 if (base == 16)
401 size -= 2;
402 else if (base == 8)
403 size--;
404 }
405 i = 0;
406 if (num == 0)
407 tmp[i++]='0';
408 else while (num != 0)
409 tmp[i++] = digits[do_div(num,base)];
410 if (i > precision)
411 precision = i;
412 size -= precision;
413 if (!(type&(ZEROPAD+LEFT)))
414 while(size-->0)
415 *str++ = ' ';
416 if (sign)
417 *str++ = sign;
418 if (type & SPECIAL) {
419 if (base==8)
420 *str++ = '0';
421 else if (base==16) {
422 *str++ = '0';
423 *str++ = digits[33];
424 }
425 }
426 if (!(type & LEFT))
427 while (size-- > 0)
428 *str++ = c;
429 while (i < precision--)
430 *str++ = '0';
431 while (i-- > 0)
432 *str++ = tmp[i];
433 while (size-- > 0)
434 *str++ = ' ';
435 return str;
436}
437
438/* Forward decl. needed for IP address printing stuff... */
439int sprintf(char * buf, const char *fmt, ...);
440
441int vsprintf(char *buf, const char *fmt, va_list args)
442{
443 int len;
444 unsigned long long num;
445 int i, base;
446 char * str;
447 const char *s;
448
449 int flags; /* flags to number() */
450
451 int field_width; /* width of output field */
452 int precision; /* min. # of digits for integers; max
453 number of chars for from string */
454 int qualifier; /* 'h', 'l', or 'L' for integer fields */
455 /* 'z' support added 23/7/1999 S.H. */
456 /* 'z' changed to 'Z' --davidm 1/25/99 */
457
458
459 for (str=buf ; *fmt ; ++fmt) {
460 if (*fmt != '%') {
461 *str++ = *fmt;
462 continue;
463 }
464
465 /* process flags */
466 flags = 0;
467 repeat:
468 ++fmt; /* this also skips first '%' */
469 switch (*fmt) {
470 case '-': flags |= LEFT; goto repeat;
471 case '+': flags |= PLUS; goto repeat;
472 case ' ': flags |= SPACE; goto repeat;
473 case '#': flags |= SPECIAL; goto repeat;
474 case '0': flags |= ZEROPAD; goto repeat;
475 }
476
477 /* get field width */
478 field_width = -1;
479 if (isdigit(*fmt))
480 field_width = skip_atoi(&fmt);
481 else if (*fmt == '*') {
482 ++fmt;
483 /* it's the next argument */
484 field_width = va_arg(args, int);
485 if (field_width < 0) {
486 field_width = -field_width;
487 flags |= LEFT;
488 }
489 }
490
491 /* get the precision */
492 precision = -1;
493 if (*fmt == '.') {
494 ++fmt;
495 if (isdigit(*fmt))
496 precision = skip_atoi(&fmt);
497 else if (*fmt == '*') {
498 ++fmt;
499 /* it's the next argument */
500 precision = va_arg(args, int);
501 }
502 if (precision < 0)
503 precision = 0;
504 }
505
506 /* get the conversion qualifier */
507 qualifier = -1;
508 if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='Z') {
509 qualifier = *fmt;
510 ++fmt;
511 }
512
513 /* default base */
514 base = 10;
515
516 switch (*fmt) {
517 case 'c':
518 if (!(flags & LEFT))
519 while (--field_width > 0)
520 *str++ = ' ';
521 *str++ = (unsigned char) va_arg(args, int);
522 while (--field_width > 0)
523 *str++ = ' ';
524 continue;
525
526 case 's':
527 s = va_arg(args, char *);
528 if (!s)
529 s = "<NULL>";
530
531 len = strnlen(s, precision);
532
533 if (!(flags & LEFT))
534 while (len < field_width--)
535 *str++ = ' ';
536 for (i = 0; i < len; ++i)
537 *str++ = *s++;
538 while (len < field_width--)
539 *str++ = ' ';
540 continue;
541
542 case 'p':
543 if (field_width == -1) {
544 field_width = 2*sizeof(void *);
545 flags |= ZEROPAD;
546 }
547 str = number(str,
548 (unsigned long) va_arg(args, void *), 16,
549 field_width, precision, flags);
550 continue;
551
552
553 case 'n':
554 if (qualifier == 'l') {
555 long * ip = va_arg(args, long *);
556 *ip = (str - buf);
557 } else if (qualifier == 'Z') {
558 size_t * ip = va_arg(args, size_t *);
559 *ip = (str - buf);
560 } else {
561 int * ip = va_arg(args, int *);
562 *ip = (str - buf);
563 }
564 continue;
565
566 case '%':
567 *str++ = '%';
568 continue;
569
570 /* integer number formats - set up the flags and "break" */
571 case 'o':
572 base = 8;
573 break;
574
575 case 'X':
576 flags |= LARGE;
577 case 'x':
578 base = 16;
579 break;
580
581 case 'd':
582 case 'i':
583 flags |= SIGN;
584 case 'u':
585 break;
586
587 default:
588 *str++ = '%';
589 if (*fmt)
590 *str++ = *fmt;
591 else
592 --fmt;
593 continue;
594 }
595 if (qualifier == 'L')
596 num = va_arg(args, long long);
597 else if (qualifier == 'l') {
598 num = va_arg(args, unsigned long);
599 if (flags & SIGN)
600 num = (signed long) num;
601 } else if (qualifier == 'Z') {
602 num = va_arg(args, size_t);
603 } else if (qualifier == 'h') {
604 num = (unsigned short) va_arg(args, int);
605 if (flags & SIGN)
606 num = (signed short) num;
607 } else {
608 num = va_arg(args, unsigned int);
609 if (flags & SIGN)
610 num = (signed int) num;
611 }
612 str = number(str, num, base, field_width, precision, flags);
613 }
614 *str = '\0';
615 return str-buf;
616}
617
618int sprintf(char * buf, const char *fmt, ...)
619{
620 va_list args;
621 int i;
622
623 va_start(args, fmt);
624 i=vsprintf(buf,fmt,args);
625 va_end(args);
626 return i;
627}
628
629static char sprint_buf[1024];
630
631void
632printk(char *fmt, ...)
633{
634 va_list args;
635 int n;
636
637 va_start(args, fmt);
638 n = vsprintf(sprint_buf, fmt, args);
639 va_end(args);
640 write(stdout, sprint_buf, n);
641}
642
643int
644printf(char *fmt, ...)
645{
646 va_list args;
647 int n;
648
649 va_start(args, fmt);
650 n = vsprintf(sprint_buf, fmt, args);
651 va_end(args);
652 write(stdout, sprint_buf, n);
653 return n;
654}
diff --git a/arch/ppc64/kernel/HvLpEvent.c b/arch/ppc64/kernel/HvLpEvent.c
index 9802beefa217..f8f19637f73f 100644
--- a/arch/ppc64/kernel/HvLpEvent.c
+++ b/arch/ppc64/kernel/HvLpEvent.c
@@ -45,7 +45,7 @@ int HvLpEvent_unregisterHandler( HvLpEvent_Type eventType )
45 /* We now sleep until all other CPUs have scheduled. This ensures that 45 /* We now sleep until all other CPUs have scheduled. This ensures that
46 * the deletion is seen by all other CPUs, and that the deleted handler 46 * the deletion is seen by all other CPUs, and that the deleted handler
47 * isn't still running on another CPU when we return. */ 47 * isn't still running on another CPU when we return. */
48 synchronize_kernel(); 48 synchronize_rcu();
49 } 49 }
50 } 50 }
51 return rc; 51 return rc;
diff --git a/arch/ppc64/kernel/misc.S b/arch/ppc64/kernel/misc.S
index 90b41f48d21c..b944717c1dbd 100644
--- a/arch/ppc64/kernel/misc.S
+++ b/arch/ppc64/kernel/misc.S
@@ -32,7 +32,7 @@
32 .text 32 .text
33 33
34/* 34/*
35 * Returns (address we're running at) - (address we were linked at) 35 * Returns (address we were linked at) - (address we are running at)
36 * for use before the text and data are mapped to KERNELBASE. 36 * for use before the text and data are mapped to KERNELBASE.
37 */ 37 */
38 38
diff --git a/arch/ppc64/kernel/nvram.c b/arch/ppc64/kernel/nvram.c
index b9069c2d1933..4e71781a4414 100644
--- a/arch/ppc64/kernel/nvram.c
+++ b/arch/ppc64/kernel/nvram.c
@@ -339,9 +339,9 @@ static int nvram_remove_os_partition(void)
339static int nvram_create_os_partition(void) 339static int nvram_create_os_partition(void)
340{ 340{
341 struct list_head * p; 341 struct list_head * p;
342 struct nvram_partition * part; 342 struct nvram_partition *part = NULL;
343 struct nvram_partition * new_part = NULL; 343 struct nvram_partition *new_part = NULL;
344 struct nvram_partition * free_part = NULL; 344 struct nvram_partition *free_part = NULL;
345 int seq_init[2] = { 0, 0 }; 345 int seq_init[2] = { 0, 0 };
346 loff_t tmp_index; 346 loff_t tmp_index;
347 long size = 0; 347 long size = 0;
@@ -364,13 +364,11 @@ static int nvram_create_os_partition(void)
364 free_part = part; 364 free_part = part;
365 } 365 }
366 } 366 }
367 if (!size) { 367 if (!size)
368 return -ENOSPC; 368 return -ENOSPC;
369 }
370 369
371 /* Create our OS partition */ 370 /* Create our OS partition */
372 new_part = (struct nvram_partition *) 371 new_part = kmalloc(sizeof(*new_part), GFP_KERNEL);
373 kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
374 if (!new_part) { 372 if (!new_part) {
375 printk(KERN_ERR "nvram_create_os_partition: kmalloc failed\n"); 373 printk(KERN_ERR "nvram_create_os_partition: kmalloc failed\n");
376 return -ENOMEM; 374 return -ENOMEM;
@@ -379,7 +377,7 @@ static int nvram_create_os_partition(void)
379 new_part->index = free_part->index; 377 new_part->index = free_part->index;
380 new_part->header.signature = NVRAM_SIG_OS; 378 new_part->header.signature = NVRAM_SIG_OS;
381 new_part->header.length = size; 379 new_part->header.length = size;
382 sprintf(new_part->header.name, "ppc64,linux"); 380 strcpy(new_part->header.name, "ppc64,linux");
383 new_part->header.checksum = nvram_checksum(&new_part->header); 381 new_part->header.checksum = nvram_checksum(&new_part->header);
384 382
385 rc = nvram_write_header(new_part); 383 rc = nvram_write_header(new_part);
@@ -394,7 +392,8 @@ static int nvram_create_os_partition(void)
394 tmp_index = new_part->index + NVRAM_HEADER_LEN; 392 tmp_index = new_part->index + NVRAM_HEADER_LEN;
395 rc = ppc_md.nvram_write((char *)&seq_init, sizeof(seq_init), &tmp_index); 393 rc = ppc_md.nvram_write((char *)&seq_init, sizeof(seq_init), &tmp_index);
396 if (rc <= 0) { 394 if (rc <= 0) {
397 printk(KERN_ERR "nvram_create_os_partition: nvram_write failed (%d)\n", rc); 395 printk(KERN_ERR "nvram_create_os_partition: nvram_write "
396 "failed (%d)\n", rc);
398 return rc; 397 return rc;
399 } 398 }
400 399
diff --git a/arch/ppc64/kernel/pSeries_hvCall.S b/arch/ppc64/kernel/pSeries_hvCall.S
index 0715d3038019..176e8da76466 100644
--- a/arch/ppc64/kernel/pSeries_hvCall.S
+++ b/arch/ppc64/kernel/pSeries_hvCall.S
@@ -28,6 +28,8 @@
28 unsigned long *out3); R10 28 unsigned long *out3); R10
29 */ 29 */
30_GLOBAL(plpar_hcall) 30_GLOBAL(plpar_hcall)
31 HMT_MEDIUM
32
31 mfcr r0 33 mfcr r0
32 34
33 std r8,STK_PARM(r8)(r1) /* Save out ptrs */ 35 std r8,STK_PARM(r8)(r1) /* Save out ptrs */
@@ -53,6 +55,8 @@ _GLOBAL(plpar_hcall)
53 55
54/* Simple interface with no output values (other than status) */ 56/* Simple interface with no output values (other than status) */
55_GLOBAL(plpar_hcall_norets) 57_GLOBAL(plpar_hcall_norets)
58 HMT_MEDIUM
59
56 mfcr r0 60 mfcr r0
57 stw r0,8(r1) 61 stw r0,8(r1)
58 62
@@ -75,6 +79,8 @@ _GLOBAL(plpar_hcall_norets)
75 unsigned long *out1); 120(R1) 79 unsigned long *out1); 120(R1)
76 */ 80 */
77_GLOBAL(plpar_hcall_8arg_2ret) 81_GLOBAL(plpar_hcall_8arg_2ret)
82 HMT_MEDIUM
83
78 mfcr r0 84 mfcr r0
79 ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */ 85 ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */
80 stw r0,8(r1) 86 stw r0,8(r1)
@@ -99,6 +105,8 @@ _GLOBAL(plpar_hcall_8arg_2ret)
99 unsigned long *out4); 112(R1) 105 unsigned long *out4); 112(R1)
100 */ 106 */
101_GLOBAL(plpar_hcall_4out) 107_GLOBAL(plpar_hcall_4out)
108 HMT_MEDIUM
109
102 mfcr r0 110 mfcr r0
103 stw r0,8(r1) 111 stw r0,8(r1)
104 112
diff --git a/arch/ppc64/kernel/pSeries_smp.c b/arch/ppc64/kernel/pSeries_smp.c
index c60d8cb2b84d..fbad349ec58c 100644
--- a/arch/ppc64/kernel/pSeries_smp.c
+++ b/arch/ppc64/kernel/pSeries_smp.c
@@ -326,13 +326,6 @@ static void __devinit smp_xics_setup_cpu(int cpu)
326 326
327 cpu_clear(cpu, of_spin_map); 327 cpu_clear(cpu, of_spin_map);
328 328
329 /*
330 * Put the calling processor into the GIQ. This is really only
331 * necessary from a secondary thread as the OF start-cpu interface
332 * performs this function for us on primary threads.
333 */
334 rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
335 (1UL << interrupt_server_size) - 1 - default_distrib_server, 1);
336} 329}
337 330
338static DEFINE_SPINLOCK(timebase_lock); 331static DEFINE_SPINLOCK(timebase_lock);
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
index be3cc387c1ec..d786d4b6af0b 100644
--- a/arch/ppc64/kernel/pci.c
+++ b/arch/ppc64/kernel/pci.c
@@ -438,7 +438,7 @@ pgprot_t pci_phys_mem_access_prot(struct file *file,
438 int i; 438 int i;
439 439
440 if (page_is_ram(offset >> PAGE_SHIFT)) 440 if (page_is_ram(offset >> PAGE_SHIFT))
441 return prot; 441 return __pgprot(prot);
442 442
443 prot |= _PAGE_NO_CACHE | _PAGE_GUARDED; 443 prot |= _PAGE_NO_CACHE | _PAGE_GUARDED;
444 444
diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c
index 45a4ad08fbc2..eb6538b58008 100644
--- a/arch/ppc64/kernel/prom.c
+++ b/arch/ppc64/kernel/prom.c
@@ -321,6 +321,10 @@ static int __devinit finish_node_interrupts(struct device_node *np,
321 char *name = get_property(ic->parent, "name", NULL); 321 char *name = get_property(ic->parent, "name", NULL);
322 if (name && !strcmp(name, "u3")) 322 if (name && !strcmp(name, "u3"))
323 np->intrs[intrcount].line += 128; 323 np->intrs[intrcount].line += 128;
324 else if (!(name && !strcmp(name, "mac-io")))
325 /* ignore other cascaded controllers, such as
326 the k2-sata-root */
327 break;
324 } 328 }
325 np->intrs[intrcount].sense = 1; 329 np->intrs[intrcount].sense = 1;
326 if (n > 1) 330 if (n > 1)
@@ -830,7 +834,7 @@ void __init unflatten_device_tree(void)
830{ 834{
831 unsigned long start, mem, size; 835 unsigned long start, mem, size;
832 struct device_node **allnextp = &allnodes; 836 struct device_node **allnextp = &allnodes;
833 char *p; 837 char *p = NULL;
834 int l = 0; 838 int l = 0;
835 839
836 DBG(" -> unflatten_device_tree()\n"); 840 DBG(" -> unflatten_device_tree()\n");
diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c
index 8dffa9ae2623..35ec42de962e 100644
--- a/arch/ppc64/kernel/prom_init.c
+++ b/arch/ppc64/kernel/prom_init.c
@@ -493,6 +493,113 @@ static void __init early_cmdline_parse(void)
493} 493}
494 494
495/* 495/*
496 * To tell the firmware what our capabilities are, we have to pass
497 * it a fake 32-bit ELF header containing a couple of PT_NOTE sections
498 * that contain structures that contain the actual values.
499 */
500static struct fake_elf {
501 Elf32_Ehdr elfhdr;
502 Elf32_Phdr phdr[2];
503 struct chrpnote {
504 u32 namesz;
505 u32 descsz;
506 u32 type;
507 char name[8]; /* "PowerPC" */
508 struct chrpdesc {
509 u32 real_mode;
510 u32 real_base;
511 u32 real_size;
512 u32 virt_base;
513 u32 virt_size;
514 u32 load_base;
515 } chrpdesc;
516 } chrpnote;
517 struct rpanote {
518 u32 namesz;
519 u32 descsz;
520 u32 type;
521 char name[24]; /* "IBM,RPA-Client-Config" */
522 struct rpadesc {
523 u32 lpar_affinity;
524 u32 min_rmo_size;
525 u32 min_rmo_percent;
526 u32 max_pft_size;
527 u32 splpar;
528 u32 min_load;
529 u32 new_mem_def;
530 u32 ignore_me;
531 } rpadesc;
532 } rpanote;
533} fake_elf = {
534 .elfhdr = {
535 .e_ident = { 0x7f, 'E', 'L', 'F',
536 ELFCLASS32, ELFDATA2MSB, EV_CURRENT },
537 .e_type = ET_EXEC, /* yeah right */
538 .e_machine = EM_PPC,
539 .e_version = EV_CURRENT,
540 .e_phoff = offsetof(struct fake_elf, phdr),
541 .e_phentsize = sizeof(Elf32_Phdr),
542 .e_phnum = 2
543 },
544 .phdr = {
545 [0] = {
546 .p_type = PT_NOTE,
547 .p_offset = offsetof(struct fake_elf, chrpnote),
548 .p_filesz = sizeof(struct chrpnote)
549 }, [1] = {
550 .p_type = PT_NOTE,
551 .p_offset = offsetof(struct fake_elf, rpanote),
552 .p_filesz = sizeof(struct rpanote)
553 }
554 },
555 .chrpnote = {
556 .namesz = sizeof("PowerPC"),
557 .descsz = sizeof(struct chrpdesc),
558 .type = 0x1275,
559 .name = "PowerPC",
560 .chrpdesc = {
561 .real_mode = ~0U, /* ~0 means "don't care" */
562 .real_base = ~0U,
563 .real_size = ~0U,
564 .virt_base = ~0U,
565 .virt_size = ~0U,
566 .load_base = ~0U
567 },
568 },
569 .rpanote = {
570 .namesz = sizeof("IBM,RPA-Client-Config"),
571 .descsz = sizeof(struct rpadesc),
572 .type = 0x12759999,
573 .name = "IBM,RPA-Client-Config",
574 .rpadesc = {
575 .lpar_affinity = 0,
576 .min_rmo_size = 64, /* in megabytes */
577 .min_rmo_percent = 0,
578 .max_pft_size = 48, /* 2^48 bytes max PFT size */
579 .splpar = 1,
580 .min_load = ~0U,
581 .new_mem_def = 0
582 }
583 }
584};
585
586static void __init prom_send_capabilities(void)
587{
588 unsigned long offset = reloc_offset();
589 ihandle elfloader;
590 int ret;
591
592 elfloader = call_prom("open", 1, 1, ADDR("/packages/elf-loader"));
593 if (elfloader == 0) {
594 prom_printf("couldn't open /packages/elf-loader\n");
595 return;
596 }
597 ret = call_prom("call-method", 3, 1, ADDR("process-elf-header"),
598 elfloader, ADDR(&fake_elf));
599 call_prom("close", 1, 0, elfloader);
600}
601
602/*
496 * Memory allocation strategy... our layout is normally: 603 * Memory allocation strategy... our layout is normally:
497 * 604 *
498 * at 14Mb or more we vmlinux, then a gap and initrd. In some rare cases, initrd 605 * at 14Mb or more we vmlinux, then a gap and initrd. In some rare cases, initrd
@@ -1448,6 +1555,12 @@ static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start,
1448 } 1555 }
1449} 1556}
1450 1557
1558/*
1559 * The Open Firmware 1275 specification states properties must be 31 bytes or
1560 * less, however not all firmwares obey this. Make it 64 bytes to be safe.
1561 */
1562#define MAX_PROPERTY_NAME 64
1563
1451static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, 1564static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
1452 unsigned long *mem_end) 1565 unsigned long *mem_end)
1453{ 1566{
@@ -1457,7 +1570,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
1457 unsigned long soff; 1570 unsigned long soff;
1458 unsigned char *valp; 1571 unsigned char *valp;
1459 unsigned long offset = reloc_offset(); 1572 unsigned long offset = reloc_offset();
1460 char pname[32]; 1573 char pname[MAX_PROPERTY_NAME];
1461 char *path; 1574 char *path;
1462 1575
1463 path = RELOC(prom_scratch); 1576 path = RELOC(prom_scratch);
diff --git a/arch/ppc64/kernel/ptrace.c b/arch/ppc64/kernel/ptrace.c
index 354a287c67eb..9f8c6087ae56 100644
--- a/arch/ppc64/kernel/ptrace.c
+++ b/arch/ppc64/kernel/ptrace.c
@@ -28,6 +28,7 @@
28#include <linux/security.h> 28#include <linux/security.h>
29#include <linux/audit.h> 29#include <linux/audit.h>
30#include <linux/seccomp.h> 30#include <linux/seccomp.h>
31#include <linux/signal.h>
31 32
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33#include <asm/page.h> 34#include <asm/page.h>
@@ -162,7 +163,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
162 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 163 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
163 case PTRACE_CONT: { /* restart after signal. */ 164 case PTRACE_CONT: { /* restart after signal. */
164 ret = -EIO; 165 ret = -EIO;
165 if ((unsigned long) data > _NSIG) 166 if (!valid_signal(data))
166 break; 167 break;
167 if (request == PTRACE_SYSCALL) 168 if (request == PTRACE_SYSCALL)
168 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 169 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -194,7 +195,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
194 195
195 case PTRACE_SINGLESTEP: { /* set the trap flag. */ 196 case PTRACE_SINGLESTEP: { /* set the trap flag. */
196 ret = -EIO; 197 ret = -EIO;
197 if ((unsigned long) data > _NSIG) 198 if (!valid_signal(data))
198 break; 199 break;
199 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 200 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
200 set_single_step(child); 201 set_single_step(child);
@@ -304,14 +305,17 @@ static void do_syscall_trace(void)
304 305
305void do_syscall_trace_enter(struct pt_regs *regs) 306void do_syscall_trace_enter(struct pt_regs *regs)
306{ 307{
308 if (test_thread_flag(TIF_SYSCALL_TRACE)
309 && (current->ptrace & PT_PTRACED))
310 do_syscall_trace();
311
307 if (unlikely(current->audit_context)) 312 if (unlikely(current->audit_context))
308 audit_syscall_entry(current, regs->gpr[0], 313 audit_syscall_entry(current,
314 test_thread_flag(TIF_32BIT)?AUDIT_ARCH_PPC:AUDIT_ARCH_PPC64,
315 regs->gpr[0],
309 regs->gpr[3], regs->gpr[4], 316 regs->gpr[3], regs->gpr[4],
310 regs->gpr[5], regs->gpr[6]); 317 regs->gpr[5], regs->gpr[6]);
311 318
312 if (test_thread_flag(TIF_SYSCALL_TRACE)
313 && (current->ptrace & PT_PTRACED))
314 do_syscall_trace();
315} 319}
316 320
317void do_syscall_trace_leave(struct pt_regs *regs) 321void do_syscall_trace_leave(struct pt_regs *regs)
@@ -319,7 +323,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
319 secure_computing(regs->gpr[0]); 323 secure_computing(regs->gpr[0]);
320 324
321 if (unlikely(current->audit_context)) 325 if (unlikely(current->audit_context))
322 audit_syscall_exit(current, regs->result); 326 audit_syscall_exit(current,
327 (regs->ccr&0x1000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
328 regs->result);
323 329
324 if ((test_thread_flag(TIF_SYSCALL_TRACE) 330 if ((test_thread_flag(TIF_SYSCALL_TRACE)
325 || test_thread_flag(TIF_SINGLESTEP)) 331 || test_thread_flag(TIF_SINGLESTEP))
diff --git a/arch/ppc64/kernel/ptrace32.c b/arch/ppc64/kernel/ptrace32.c
index ee81b1b776cc..16436426c7e2 100644
--- a/arch/ppc64/kernel/ptrace32.c
+++ b/arch/ppc64/kernel/ptrace32.c
@@ -26,6 +26,7 @@
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/user.h> 27#include <linux/user.h>
28#include <linux/security.h> 28#include <linux/security.h>
29#include <linux/signal.h>
29 30
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/page.h> 32#include <asm/page.h>
@@ -293,7 +294,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
293 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 294 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
294 case PTRACE_CONT: { /* restart after signal. */ 295 case PTRACE_CONT: { /* restart after signal. */
295 ret = -EIO; 296 ret = -EIO;
296 if ((unsigned long) data > _NSIG) 297 if (!valid_signal(data))
297 break; 298 break;
298 if (request == PTRACE_SYSCALL) 299 if (request == PTRACE_SYSCALL)
299 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 300 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -325,7 +326,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
325 326
326 case PTRACE_SINGLESTEP: { /* set the trap flag. */ 327 case PTRACE_SINGLESTEP: { /* set the trap flag. */
327 ret = -EIO; 328 ret = -EIO;
328 if ((unsigned long) data > _NSIG) 329 if (!valid_signal(data))
329 break; 330 break;
330 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 331 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
331 set_single_step(child); 332 set_single_step(child);
diff --git a/arch/ppc64/kernel/rtas_flash.c b/arch/ppc64/kernel/rtas_flash.c
index 3213837282ca..923e2e201a70 100644
--- a/arch/ppc64/kernel/rtas_flash.c
+++ b/arch/ppc64/kernel/rtas_flash.c
@@ -218,7 +218,7 @@ static void get_flash_status_msg(int status, char *buf)
218} 218}
219 219
220/* Reading the proc file will show status (not the firmware contents) */ 220/* Reading the proc file will show status (not the firmware contents) */
221static ssize_t rtas_flash_read(struct file *file, char *buf, 221static ssize_t rtas_flash_read(struct file *file, char __user *buf,
222 size_t count, loff_t *ppos) 222 size_t count, loff_t *ppos)
223{ 223{
224 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); 224 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
@@ -256,7 +256,7 @@ static ssize_t rtas_flash_read(struct file *file, char *buf,
256 * count is. If the system is low on memory it will be just as well 256 * count is. If the system is low on memory it will be just as well
257 * that we fail.... 257 * that we fail....
258 */ 258 */
259static ssize_t rtas_flash_write(struct file *file, const char *buffer, 259static ssize_t rtas_flash_write(struct file *file, const char __user *buffer,
260 size_t count, loff_t *off) 260 size_t count, loff_t *off)
261{ 261{
262 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); 262 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
@@ -356,7 +356,7 @@ static void manage_flash(struct rtas_manage_flash_t *args_buf)
356 args_buf->status = rc; 356 args_buf->status = rc;
357} 357}
358 358
359static ssize_t manage_flash_read(struct file *file, char *buf, 359static ssize_t manage_flash_read(struct file *file, char __user *buf,
360 size_t count, loff_t *ppos) 360 size_t count, loff_t *ppos)
361{ 361{
362 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); 362 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
@@ -386,7 +386,7 @@ static ssize_t manage_flash_read(struct file *file, char *buf,
386 return msglen; 386 return msglen;
387} 387}
388 388
389static ssize_t manage_flash_write(struct file *file, const char *buf, 389static ssize_t manage_flash_write(struct file *file, const char __user *buf,
390 size_t count, loff_t *off) 390 size_t count, loff_t *off)
391{ 391{
392 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); 392 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
@@ -466,7 +466,7 @@ static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf,
466 return n; 466 return n;
467} 467}
468 468
469static ssize_t validate_flash_read(struct file *file, char *buf, 469static ssize_t validate_flash_read(struct file *file, char __user *buf,
470 size_t count, loff_t *ppos) 470 size_t count, loff_t *ppos)
471{ 471{
472 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); 472 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
@@ -494,7 +494,7 @@ static ssize_t validate_flash_read(struct file *file, char *buf,
494 return msglen; 494 return msglen;
495} 495}
496 496
497static ssize_t validate_flash_write(struct file *file, const char *buf, 497static ssize_t validate_flash_write(struct file *file, const char __user *buf,
498 size_t count, loff_t *off) 498 size_t count, loff_t *off)
499{ 499{
500 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode); 500 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
diff --git a/arch/ppc64/kernel/scanlog.c b/arch/ppc64/kernel/scanlog.c
index 189b81a41987..4d70736619c7 100644
--- a/arch/ppc64/kernel/scanlog.c
+++ b/arch/ppc64/kernel/scanlog.c
@@ -43,7 +43,7 @@ static int scanlog_debug;
43static unsigned int ibm_scan_log_dump; /* RTAS token */ 43static unsigned int ibm_scan_log_dump; /* RTAS token */
44static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */ 44static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */
45 45
46static ssize_t scanlog_read(struct file *file, char *buf, 46static ssize_t scanlog_read(struct file *file, char __user *buf,
47 size_t count, loff_t *ppos) 47 size_t count, loff_t *ppos)
48{ 48{
49 struct inode * inode = file->f_dentry->d_inode; 49 struct inode * inode = file->f_dentry->d_inode;
@@ -129,7 +129,7 @@ static ssize_t scanlog_read(struct file *file, char *buf,
129 /*NOTREACHED*/ 129 /*NOTREACHED*/
130} 130}
131 131
132static ssize_t scanlog_write(struct file * file, const char * buf, 132static ssize_t scanlog_write(struct file * file, const char __user * buf,
133 size_t count, loff_t *ppos) 133 size_t count, loff_t *ppos)
134{ 134{
135 char stkbuf[20]; 135 char stkbuf[20];
diff --git a/arch/ppc64/kernel/signal.c b/arch/ppc64/kernel/signal.c
index a95a2b49a1d5..bf782276984c 100644
--- a/arch/ppc64/kernel/signal.c
+++ b/arch/ppc64/kernel/signal.c
@@ -42,11 +42,7 @@
42 42
43#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 43#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
44 44
45#ifndef MIN 45#define GP_REGS_SIZE min(sizeof(elf_gregset_t), sizeof(struct pt_regs))
46#define MIN(a,b) (((a) < (b)) ? (a) : (b))
47#endif
48
49#define GP_REGS_SIZE MIN(sizeof(elf_gregset_t), sizeof(struct pt_regs))
50#define FP_REGS_SIZE sizeof(elf_fpregset_t) 46#define FP_REGS_SIZE sizeof(elf_fpregset_t)
51 47
52#define TRAMP_TRACEBACK 3 48#define TRAMP_TRACEBACK 3
diff --git a/arch/ppc64/kernel/signal32.c b/arch/ppc64/kernel/signal32.c
index b0e167db6af9..3c2fa5c284c0 100644
--- a/arch/ppc64/kernel/signal32.c
+++ b/arch/ppc64/kernel/signal32.c
@@ -657,7 +657,7 @@ static int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
657 657
658 /* Save user registers on the stack */ 658 /* Save user registers on the stack */
659 frame = &rt_sf->uc.uc_mcontext; 659 frame = &rt_sf->uc.uc_mcontext;
660 if (put_user(regs->gpr[1], (unsigned long __user *)newsp)) 660 if (put_user(regs->gpr[1], (u32 __user *)newsp))
661 goto badframe; 661 goto badframe;
662 662
663 if (vdso32_rt_sigtramp && current->thread.vdso_base) { 663 if (vdso32_rt_sigtramp && current->thread.vdso_base) {
@@ -842,7 +842,7 @@ static int handle_signal32(unsigned long sig, struct k_sigaction *ka,
842 regs->link = (unsigned long) frame->mctx.tramp; 842 regs->link = (unsigned long) frame->mctx.tramp;
843 } 843 }
844 844
845 if (put_user(regs->gpr[1], (unsigned long __user *)newsp)) 845 if (put_user(regs->gpr[1], (u32 __user *)newsp))
846 goto badframe; 846 goto badframe;
847 regs->gpr[1] = (unsigned long) newsp; 847 regs->gpr[1] = (unsigned long) newsp;
848 regs->gpr[3] = sig; 848 regs->gpr[3] = sig;
diff --git a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c
index 1c92da3e4525..3b906cd94037 100644
--- a/arch/ppc64/kernel/smp.c
+++ b/arch/ppc64/kernel/smp.c
@@ -125,7 +125,7 @@ void __devinit smp_generic_kick_cpu(int nr)
125 * the processor will continue on to secondary_start 125 * the processor will continue on to secondary_start
126 */ 126 */
127 paca[nr].cpu_start = 1; 127 paca[nr].cpu_start = 1;
128 mb(); 128 smp_mb();
129} 129}
130 130
131#endif /* CONFIG_PPC_MULTIPLATFORM */ 131#endif /* CONFIG_PPC_MULTIPLATFORM */
@@ -256,7 +256,7 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
256 } 256 }
257 257
258 call_data = &data; 258 call_data = &data;
259 wmb(); 259 smp_wmb();
260 /* Send a message to all other CPUs and wait for them to respond */ 260 /* Send a message to all other CPUs and wait for them to respond */
261 smp_ops->message_pass(MSG_ALL_BUT_SELF, PPC_MSG_CALL_FUNCTION); 261 smp_ops->message_pass(MSG_ALL_BUT_SELF, PPC_MSG_CALL_FUNCTION);
262 262
@@ -431,7 +431,7 @@ int generic_cpu_enable(unsigned int cpu)
431 431
432 /* get the target out of it's holding state */ 432 /* get the target out of it's holding state */
433 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 433 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
434 wmb(); 434 smp_wmb();
435 435
436 while (!cpu_online(cpu)) 436 while (!cpu_online(cpu))
437 cpu_relax(); 437 cpu_relax();
@@ -447,7 +447,7 @@ void generic_cpu_die(unsigned int cpu)
447 int i; 447 int i;
448 448
449 for (i = 0; i < 100; i++) { 449 for (i = 0; i < 100; i++) {
450 rmb(); 450 smp_rmb();
451 if (per_cpu(cpu_state, cpu) == CPU_DEAD) 451 if (per_cpu(cpu_state, cpu) == CPU_DEAD)
452 return; 452 return;
453 msleep(100); 453 msleep(100);
@@ -463,7 +463,7 @@ void generic_mach_cpu_die(void)
463 cpu = smp_processor_id(); 463 cpu = smp_processor_id();
464 printk(KERN_DEBUG "CPU%d offline\n", cpu); 464 printk(KERN_DEBUG "CPU%d offline\n", cpu);
465 __get_cpu_var(cpu_state) = CPU_DEAD; 465 __get_cpu_var(cpu_state) = CPU_DEAD;
466 wmb(); 466 smp_wmb();
467 while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE) 467 while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE)
468 cpu_relax(); 468 cpu_relax();
469 469
@@ -515,7 +515,7 @@ int __devinit __cpu_up(unsigned int cpu)
515 * be written out to main store before we release 515 * be written out to main store before we release
516 * the processor. 516 * the processor.
517 */ 517 */
518 mb(); 518 smp_mb();
519 519
520 /* wake up cpus */ 520 /* wake up cpus */
521 DBG("smp: kicking cpu %d\n", cpu); 521 DBG("smp: kicking cpu %d\n", cpu);
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c
index 77ded5a363b6..772a465b49f9 100644
--- a/arch/ppc64/kernel/time.c
+++ b/arch/ppc64/kernel/time.c
@@ -221,15 +221,15 @@ static __inline__ void timer_recalc_offset(unsigned long cur_tb)
221 temp_varp->tb_to_xs = do_gtod.varp->tb_to_xs; 221 temp_varp->tb_to_xs = do_gtod.varp->tb_to_xs;
222 temp_varp->tb_orig_stamp = new_tb_orig_stamp; 222 temp_varp->tb_orig_stamp = new_tb_orig_stamp;
223 temp_varp->stamp_xsec = new_stamp_xsec; 223 temp_varp->stamp_xsec = new_stamp_xsec;
224 mb(); 224 smp_mb();
225 do_gtod.varp = temp_varp; 225 do_gtod.varp = temp_varp;
226 do_gtod.var_idx = temp_idx; 226 do_gtod.var_idx = temp_idx;
227 227
228 ++(systemcfg->tb_update_count); 228 ++(systemcfg->tb_update_count);
229 wmb(); 229 smp_wmb();
230 systemcfg->tb_orig_stamp = new_tb_orig_stamp; 230 systemcfg->tb_orig_stamp = new_tb_orig_stamp;
231 systemcfg->stamp_xsec = new_stamp_xsec; 231 systemcfg->stamp_xsec = new_stamp_xsec;
232 wmb(); 232 smp_wmb();
233 ++(systemcfg->tb_update_count); 233 ++(systemcfg->tb_update_count);
234} 234}
235 235
@@ -648,7 +648,7 @@ void ppc_adjtimex(void)
648 temp_varp->tb_to_xs = new_tb_to_xs; 648 temp_varp->tb_to_xs = new_tb_to_xs;
649 temp_varp->stamp_xsec = new_stamp_xsec; 649 temp_varp->stamp_xsec = new_stamp_xsec;
650 temp_varp->tb_orig_stamp = do_gtod.varp->tb_orig_stamp; 650 temp_varp->tb_orig_stamp = do_gtod.varp->tb_orig_stamp;
651 mb(); 651 smp_mb();
652 do_gtod.varp = temp_varp; 652 do_gtod.varp = temp_varp;
653 do_gtod.var_idx = temp_idx; 653 do_gtod.var_idx = temp_idx;
654 654
@@ -662,10 +662,10 @@ void ppc_adjtimex(void)
662 * loops back and reads them again until this criteria is met. 662 * loops back and reads them again until this criteria is met.
663 */ 663 */
664 ++(systemcfg->tb_update_count); 664 ++(systemcfg->tb_update_count);
665 wmb(); 665 smp_wmb();
666 systemcfg->tb_to_xs = new_tb_to_xs; 666 systemcfg->tb_to_xs = new_tb_to_xs;
667 systemcfg->stamp_xsec = new_stamp_xsec; 667 systemcfg->stamp_xsec = new_stamp_xsec;
668 wmb(); 668 smp_wmb();
669 ++(systemcfg->tb_update_count); 669 ++(systemcfg->tb_update_count);
670 670
671 write_sequnlock_irqrestore( &xtime_lock, flags ); 671 write_sequnlock_irqrestore( &xtime_lock, flags );
diff --git a/arch/ppc64/kernel/vdso32/Makefile b/arch/ppc64/kernel/vdso32/Makefile
index ede2f7e477c2..0b1b0df973eb 100644
--- a/arch/ppc64/kernel/vdso32/Makefile
+++ b/arch/ppc64/kernel/vdso32/Makefile
@@ -1,7 +1,7 @@
1 1
2# List of files in the vdso, has to be asm only for now 2# List of files in the vdso, has to be asm only for now
3 3
4obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o 4obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o
5 5
6# Build rules 6# Build rules
7 7
diff --git a/arch/ppc64/kernel/vdso32/cacheflush.S b/arch/ppc64/kernel/vdso32/cacheflush.S
index c74fddb6afd4..0ed7ea721715 100644
--- a/arch/ppc64/kernel/vdso32/cacheflush.S
+++ b/arch/ppc64/kernel/vdso32/cacheflush.S
@@ -47,6 +47,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
47 addi r6,r6,128 47 addi r6,r6,128
48 bdnz 1b 48 bdnz 1b
49 isync 49 isync
50 li r3,0
50 blr 51 blr
51 .cfi_endproc 52 .cfi_endproc
52V_FUNCTION_END(__kernel_sync_dicache) 53V_FUNCTION_END(__kernel_sync_dicache)
@@ -59,6 +60,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
59 .cfi_startproc 60 .cfi_startproc
60 sync 61 sync
61 isync 62 isync
63 li r3,0
62 blr 64 blr
63 .cfi_endproc 65 .cfi_endproc
64V_FUNCTION_END(__kernel_sync_dicache_p5) 66V_FUNCTION_END(__kernel_sync_dicache_p5)
diff --git a/arch/ppc64/kernel/vdso32/gettimeofday.S b/arch/ppc64/kernel/vdso32/gettimeofday.S
index ca7f415195c4..2b48bf1fb109 100644
--- a/arch/ppc64/kernel/vdso32/gettimeofday.S
+++ b/arch/ppc64/kernel/vdso32/gettimeofday.S
@@ -58,6 +58,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
58 stw r5,TZONE_TZ_DSTTIME(r11) 58 stw r5,TZONE_TZ_DSTTIME(r11)
59 59
601: mtlr r12 601: mtlr r12
61 li r3,0
61 blr 62 blr
62 63
632: mr r3,r10 642: mr r3,r10
diff --git a/arch/ppc64/kernel/vdso32/note.S b/arch/ppc64/kernel/vdso32/note.S
new file mode 100644
index 000000000000..d4b5be4f3d5f
--- /dev/null
+++ b/arch/ppc64/kernel/vdso32/note.S
@@ -0,0 +1,25 @@
1/*
2 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
3 * Here we can supply some information useful to userland.
4 */
5
6#include <linux/uts.h>
7#include <linux/version.h>
8
9#define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type) \
10 .section name, flags; \
11 .balign 4; \
12 .long 1f - 0f; /* name length */ \
13 .long 3f - 2f; /* data length */ \
14 .long type; /* note type */ \
150: .asciz vendor; /* vendor name */ \
161: .balign 4; \
172:
18
19#define ASM_ELF_NOTE_END \
203: .balign 4; /* pad out section */ \
21 .previous
22
23 ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0)
24 .long LINUX_VERSION_CODE
25 ASM_ELF_NOTE_END
diff --git a/arch/ppc64/kernel/vdso32/vdso32.lds.S b/arch/ppc64/kernel/vdso32/vdso32.lds.S
index cca27bd03a57..11290c902ba3 100644
--- a/arch/ppc64/kernel/vdso32/vdso32.lds.S
+++ b/arch/ppc64/kernel/vdso32/vdso32.lds.S
@@ -20,6 +20,8 @@ SECTIONS
20 .gnu.version_d : { *(.gnu.version_d) } 20 .gnu.version_d : { *(.gnu.version_d) }
21 .gnu.version_r : { *(.gnu.version_r) } 21 .gnu.version_r : { *(.gnu.version_r) }
22 22
23 .note : { *(.note.*) } :text :note
24
23 . = ALIGN (16); 25 . = ALIGN (16);
24 .text : 26 .text :
25 { 27 {
@@ -87,6 +89,7 @@ SECTIONS
87PHDRS 89PHDRS
88{ 90{
89 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */ 91 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
92 note PT_NOTE FLAGS(4); /* PF_R */
90 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 93 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
91 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */ 94 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
92} 95}
diff --git a/arch/ppc64/kernel/vdso64/Makefile b/arch/ppc64/kernel/vdso64/Makefile
index bd3f70b1a384..ab39988452cc 100644
--- a/arch/ppc64/kernel/vdso64/Makefile
+++ b/arch/ppc64/kernel/vdso64/Makefile
@@ -1,6 +1,6 @@
1# List of files in the vdso, has to be asm only for now 1# List of files in the vdso, has to be asm only for now
2 2
3obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o 3obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o
4 4
5# Build rules 5# Build rules
6 6
diff --git a/arch/ppc64/kernel/vdso64/cacheflush.S b/arch/ppc64/kernel/vdso64/cacheflush.S
index d9696ffcf334..e0725b7b7003 100644
--- a/arch/ppc64/kernel/vdso64/cacheflush.S
+++ b/arch/ppc64/kernel/vdso64/cacheflush.S
@@ -47,6 +47,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
47 addi r6,r6,128 47 addi r6,r6,128
48 bdnz 1b 48 bdnz 1b
49 isync 49 isync
50 li r3,0
50 blr 51 blr
51 .cfi_endproc 52 .cfi_endproc
52V_FUNCTION_END(__kernel_sync_dicache) 53V_FUNCTION_END(__kernel_sync_dicache)
@@ -59,6 +60,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
59 .cfi_startproc 60 .cfi_startproc
60 sync 61 sync
61 isync 62 isync
63 li r3,0
62 blr 64 blr
63 .cfi_endproc 65 .cfi_endproc
64V_FUNCTION_END(__kernel_sync_dicache_p5) 66V_FUNCTION_END(__kernel_sync_dicache_p5)
diff --git a/arch/ppc64/kernel/vdso64/note.S b/arch/ppc64/kernel/vdso64/note.S
new file mode 100644
index 000000000000..dc2a509f7e8a
--- /dev/null
+++ b/arch/ppc64/kernel/vdso64/note.S
@@ -0,0 +1 @@
#include "../vdso32/note.S"
diff --git a/arch/ppc64/kernel/vdso64/vdso64.lds.S b/arch/ppc64/kernel/vdso64/vdso64.lds.S
index 942c815c7bc7..9cb28181da80 100644
--- a/arch/ppc64/kernel/vdso64/vdso64.lds.S
+++ b/arch/ppc64/kernel/vdso64/vdso64.lds.S
@@ -18,12 +18,14 @@ SECTIONS
18 .gnu.version_d : { *(.gnu.version_d) } 18 .gnu.version_d : { *(.gnu.version_d) }
19 .gnu.version_r : { *(.gnu.version_r) } 19 .gnu.version_r : { *(.gnu.version_r) }
20 20
21 .note : { *(.note.*) } :text :note
22
21 . = ALIGN (16); 23 . = ALIGN (16);
22 .text : 24 .text :
23 { 25 {
24 *(.text .stub .text.* .gnu.linkonce.t.*) 26 *(.text .stub .text.* .gnu.linkonce.t.*)
25 *(.sfpr .glink) 27 *(.sfpr .glink)
26 } 28 } :text
27 PROVIDE (__etext = .); 29 PROVIDE (__etext = .);
28 PROVIDE (_etext = .); 30 PROVIDE (_etext = .);
29 PROVIDE (etext = .); 31 PROVIDE (etext = .);
@@ -88,6 +90,7 @@ SECTIONS
88PHDRS 90PHDRS
89{ 91{
90 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */ 92 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
93 note PT_NOTE FLAGS(4); /* PF_R */
91 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 94 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
92 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */ 95 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
93} 96}
diff --git a/arch/ppc64/kernel/xics.c b/arch/ppc64/kernel/xics.c
index eedd1d3c2a10..879f39b90a33 100644
--- a/arch/ppc64/kernel/xics.c
+++ b/arch/ppc64/kernel/xics.c
@@ -432,6 +432,7 @@ void xics_cause_IPI(int cpu)
432{ 432{
433 ops->qirr_info(cpu, IPI_PRIORITY); 433 ops->qirr_info(cpu, IPI_PRIORITY);
434} 434}
435#endif /* CONFIG_SMP */
435 436
436void xics_setup_cpu(void) 437void xics_setup_cpu(void)
437{ 438{
@@ -439,9 +440,17 @@ void xics_setup_cpu(void)
439 440
440 ops->cppr_info(cpu, 0xff); 441 ops->cppr_info(cpu, 0xff);
441 iosync(); 442 iosync();
442}
443 443
444#endif /* CONFIG_SMP */ 444 /*
445 * Put the calling processor into the GIQ. This is really only
446 * necessary from a secondary thread as the OF start-cpu interface
447 * performs this function for us on primary threads.
448 *
449 * XXX: undo of teardown on kexec needs this too, as may hotplug
450 */
451 rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
452 (1UL << interrupt_server_size) - 1 - default_distrib_server, 1);
453}
445 454
446void xics_init_IRQ(void) 455void xics_init_IRQ(void)
447{ 456{
@@ -563,8 +572,7 @@ nextnode:
563 for (; i < NR_IRQS; ++i) 572 for (; i < NR_IRQS; ++i)
564 get_irq_desc(i)->handler = &xics_pic; 573 get_irq_desc(i)->handler = &xics_pic;
565 574
566 ops->cppr_info(boot_cpuid, 0xff); 575 xics_setup_cpu();
567 iosync();
568 576
569 ppc64_boot_msg(0x21, "XICS Done"); 577 ppc64_boot_msg(0x21, "XICS Done");
570} 578}
diff --git a/arch/ppc64/mm/hash_low.S b/arch/ppc64/mm/hash_low.S
index 8c0156a37001..c23d46956dd9 100644
--- a/arch/ppc64/mm/hash_low.S
+++ b/arch/ppc64/mm/hash_low.S
@@ -85,7 +85,10 @@ _GLOBAL(__hash_page)
85 bne- htab_wrong_access 85 bne- htab_wrong_access
86 /* Check if PTE is busy */ 86 /* Check if PTE is busy */
87 andi. r0,r31,_PAGE_BUSY 87 andi. r0,r31,_PAGE_BUSY
88 bne- 1b 88 /* If so, just bail out and refault if needed. Someone else
89 * is changing this PTE anyway and might hash it.
90 */
91 bne- bail_ok
89 /* Prepare new PTE value (turn access RW into DIRTY, then 92 /* Prepare new PTE value (turn access RW into DIRTY, then
90 * add BUSY,HASHPTE and ACCESSED) 93 * add BUSY,HASHPTE and ACCESSED)
91 */ 94 */
@@ -215,6 +218,10 @@ _GLOBAL(htab_call_hpte_remove)
215 /* Try all again */ 218 /* Try all again */
216 b htab_insert_pte 219 b htab_insert_pte
217 220
221bail_ok:
222 li r3,0
223 b bail
224
218htab_pte_insert_ok: 225htab_pte_insert_ok:
219 /* Insert slot number & secondary bit in PTE */ 226 /* Insert slot number & secondary bit in PTE */
220 rldimi r30,r3,12,63-15 227 rldimi r30,r3,12,63-15
diff --git a/arch/ppc64/mm/hash_native.c b/arch/ppc64/mm/hash_native.c
index 144657e0c3d5..52b6b9305341 100644
--- a/arch/ppc64/mm/hash_native.c
+++ b/arch/ppc64/mm/hash_native.c
@@ -320,8 +320,7 @@ static void native_flush_hash_range(unsigned long context,
320 320
321 j = 0; 321 j = 0;
322 for (i = 0; i < number; i++) { 322 for (i = 0; i < number; i++) {
323 if ((batch->addr[i] >= USER_START) && 323 if (batch->addr[i] < KERNELBASE)
324 (batch->addr[i] <= USER_END))
325 vsid = get_vsid(context, batch->addr[i]); 324 vsid = get_vsid(context, batch->addr[i]);
326 else 325 else
327 vsid = get_kernel_vsid(batch->addr[i]); 326 vsid = get_kernel_vsid(batch->addr[i]);
diff --git a/arch/ppc64/mm/hash_utils.c b/arch/ppc64/mm/hash_utils.c
index e48be12f518c..0a0f97008d02 100644
--- a/arch/ppc64/mm/hash_utils.c
+++ b/arch/ppc64/mm/hash_utils.c
@@ -298,24 +298,23 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
298 int local = 0; 298 int local = 0;
299 cpumask_t tmp; 299 cpumask_t tmp;
300 300
301 if ((ea & ~REGION_MASK) > EADDR_MASK)
302 return 1;
303
301 switch (REGION_ID(ea)) { 304 switch (REGION_ID(ea)) {
302 case USER_REGION_ID: 305 case USER_REGION_ID:
303 user_region = 1; 306 user_region = 1;
304 mm = current->mm; 307 mm = current->mm;
305 if ((ea > USER_END) || (! mm)) 308 if (! mm)
306 return 1; 309 return 1;
307 310
308 vsid = get_vsid(mm->context.id, ea); 311 vsid = get_vsid(mm->context.id, ea);
309 break; 312 break;
310 case IO_REGION_ID: 313 case IO_REGION_ID:
311 if (ea > IMALLOC_END)
312 return 1;
313 mm = &ioremap_mm; 314 mm = &ioremap_mm;
314 vsid = get_kernel_vsid(ea); 315 vsid = get_kernel_vsid(ea);
315 break; 316 break;
316 case VMALLOC_REGION_ID: 317 case VMALLOC_REGION_ID:
317 if (ea > VMALLOC_END)
318 return 1;
319 mm = &init_mm; 318 mm = &init_mm;
320 vsid = get_kernel_vsid(ea); 319 vsid = get_kernel_vsid(ea);
321 break; 320 break;
@@ -362,7 +361,7 @@ void flush_hash_page(unsigned long context, unsigned long ea, pte_t pte,
362 unsigned long vsid, vpn, va, hash, secondary, slot; 361 unsigned long vsid, vpn, va, hash, secondary, slot;
363 unsigned long huge = pte_huge(pte); 362 unsigned long huge = pte_huge(pte);
364 363
365 if ((ea >= USER_START) && (ea <= USER_END)) 364 if (ea < KERNELBASE)
366 vsid = get_vsid(context, ea); 365 vsid = get_vsid(context, ea);
367 else 366 else
368 vsid = get_kernel_vsid(ea); 367 vsid = get_kernel_vsid(ea);
diff --git a/arch/ppc64/mm/hugetlbpage.c b/arch/ppc64/mm/hugetlbpage.c
index 390296efe3e0..d3bf86a5c1ad 100644
--- a/arch/ppc64/mm/hugetlbpage.c
+++ b/arch/ppc64/mm/hugetlbpage.c
@@ -42,7 +42,7 @@ static inline int hugepgd_index(unsigned long addr)
42 return (addr & ~REGION_MASK) >> HUGEPGDIR_SHIFT; 42 return (addr & ~REGION_MASK) >> HUGEPGDIR_SHIFT;
43} 43}
44 44
45static pgd_t *hugepgd_offset(struct mm_struct *mm, unsigned long addr) 45static pud_t *hugepgd_offset(struct mm_struct *mm, unsigned long addr)
46{ 46{
47 int index; 47 int index;
48 48
@@ -52,21 +52,21 @@ static pgd_t *hugepgd_offset(struct mm_struct *mm, unsigned long addr)
52 52
53 index = hugepgd_index(addr); 53 index = hugepgd_index(addr);
54 BUG_ON(index >= PTRS_PER_HUGEPGD); 54 BUG_ON(index >= PTRS_PER_HUGEPGD);
55 return mm->context.huge_pgdir + index; 55 return (pud_t *)(mm->context.huge_pgdir + index);
56} 56}
57 57
58static inline pte_t *hugepte_offset(pgd_t *dir, unsigned long addr) 58static inline pte_t *hugepte_offset(pud_t *dir, unsigned long addr)
59{ 59{
60 int index; 60 int index;
61 61
62 if (pgd_none(*dir)) 62 if (pud_none(*dir))
63 return NULL; 63 return NULL;
64 64
65 index = (addr >> HPAGE_SHIFT) % PTRS_PER_HUGEPTE; 65 index = (addr >> HPAGE_SHIFT) % PTRS_PER_HUGEPTE;
66 return (pte_t *)pgd_page(*dir) + index; 66 return (pte_t *)pud_page(*dir) + index;
67} 67}
68 68
69static pgd_t *hugepgd_alloc(struct mm_struct *mm, unsigned long addr) 69static pud_t *hugepgd_alloc(struct mm_struct *mm, unsigned long addr)
70{ 70{
71 BUG_ON(! in_hugepage_area(mm->context, addr)); 71 BUG_ON(! in_hugepage_area(mm->context, addr));
72 72
@@ -90,10 +90,9 @@ static pgd_t *hugepgd_alloc(struct mm_struct *mm, unsigned long addr)
90 return hugepgd_offset(mm, addr); 90 return hugepgd_offset(mm, addr);
91} 91}
92 92
93static pte_t *hugepte_alloc(struct mm_struct *mm, pgd_t *dir, 93static pte_t *hugepte_alloc(struct mm_struct *mm, pud_t *dir, unsigned long addr)
94 unsigned long addr)
95{ 94{
96 if (! pgd_present(*dir)) { 95 if (! pud_present(*dir)) {
97 pte_t *new; 96 pte_t *new;
98 97
99 spin_unlock(&mm->page_table_lock); 98 spin_unlock(&mm->page_table_lock);
@@ -104,7 +103,7 @@ static pte_t *hugepte_alloc(struct mm_struct *mm, pgd_t *dir,
104 * Because we dropped the lock, we should re-check the 103 * Because we dropped the lock, we should re-check the
105 * entry, as somebody else could have populated it.. 104 * entry, as somebody else could have populated it..
106 */ 105 */
107 if (pgd_present(*dir)) { 106 if (pud_present(*dir)) {
108 if (new) 107 if (new)
109 kmem_cache_free(zero_cache, new); 108 kmem_cache_free(zero_cache, new);
110 } else { 109 } else {
@@ -115,7 +114,7 @@ static pte_t *hugepte_alloc(struct mm_struct *mm, pgd_t *dir,
115 ptepage = virt_to_page(new); 114 ptepage = virt_to_page(new);
116 ptepage->mapping = (void *) mm; 115 ptepage->mapping = (void *) mm;
117 ptepage->index = addr & HUGEPGDIR_MASK; 116 ptepage->index = addr & HUGEPGDIR_MASK;
118 pgd_populate(mm, dir, new); 117 pud_populate(mm, dir, new);
119 } 118 }
120 } 119 }
121 120
@@ -124,28 +123,28 @@ static pte_t *hugepte_alloc(struct mm_struct *mm, pgd_t *dir,
124 123
125static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 124static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
126{ 125{
127 pgd_t *pgd; 126 pud_t *pud;
128 127
129 BUG_ON(! in_hugepage_area(mm->context, addr)); 128 BUG_ON(! in_hugepage_area(mm->context, addr));
130 129
131 pgd = hugepgd_offset(mm, addr); 130 pud = hugepgd_offset(mm, addr);
132 if (! pgd) 131 if (! pud)
133 return NULL; 132 return NULL;
134 133
135 return hugepte_offset(pgd, addr); 134 return hugepte_offset(pud, addr);
136} 135}
137 136
138static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 137static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
139{ 138{
140 pgd_t *pgd; 139 pud_t *pud;
141 140
142 BUG_ON(! in_hugepage_area(mm->context, addr)); 141 BUG_ON(! in_hugepage_area(mm->context, addr));
143 142
144 pgd = hugepgd_alloc(mm, addr); 143 pud = hugepgd_alloc(mm, addr);
145 if (! pgd) 144 if (! pud)
146 return NULL; 145 return NULL;
147 146
148 return hugepte_alloc(mm, pgd, addr); 147 return hugepte_alloc(mm, pud, addr);
149} 148}
150 149
151static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma, 150static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
@@ -709,10 +708,10 @@ void hugetlb_mm_free_pgd(struct mm_struct *mm)
709 708
710 /* cleanup any hugepte pages leftover */ 709 /* cleanup any hugepte pages leftover */
711 for (i = 0; i < PTRS_PER_HUGEPGD; i++) { 710 for (i = 0; i < PTRS_PER_HUGEPGD; i++) {
712 pgd_t *pgd = pgdir + i; 711 pud_t *pud = (pud_t *)(pgdir + i);
713 712
714 if (! pgd_none(*pgd)) { 713 if (! pud_none(*pud)) {
715 pte_t *pte = (pte_t *)pgd_page(*pgd); 714 pte_t *pte = (pte_t *)pud_page(*pud);
716 struct page *ptepage = virt_to_page(pte); 715 struct page *ptepage = virt_to_page(pte);
717 716
718 ptepage->mapping = NULL; 717 ptepage->mapping = NULL;
@@ -720,7 +719,7 @@ void hugetlb_mm_free_pgd(struct mm_struct *mm)
720 BUG_ON(memcmp(pte, empty_zero_page, PAGE_SIZE)); 719 BUG_ON(memcmp(pte, empty_zero_page, PAGE_SIZE));
721 kmem_cache_free(zero_cache, pte); 720 kmem_cache_free(zero_cache, pte);
722 } 721 }
723 pgd_clear(pgd); 722 pud_clear(pud);
724 } 723 }
725 724
726 BUG_ON(memcmp(pgdir, empty_zero_page, PAGE_SIZE)); 725 BUG_ON(memcmp(pgdir, empty_zero_page, PAGE_SIZE));
diff --git a/arch/ppc64/mm/imalloc.c b/arch/ppc64/mm/imalloc.c
index 9d92b0d9cde5..cb8727f3267a 100644
--- a/arch/ppc64/mm/imalloc.c
+++ b/arch/ppc64/mm/imalloc.c
@@ -14,6 +14,7 @@
14#include <asm/pgalloc.h> 14#include <asm/pgalloc.h>
15#include <asm/pgtable.h> 15#include <asm/pgtable.h>
16#include <asm/semaphore.h> 16#include <asm/semaphore.h>
17#include <asm/imalloc.h>
17 18
18static DECLARE_MUTEX(imlist_sem); 19static DECLARE_MUTEX(imlist_sem);
19struct vm_struct * imlist = NULL; 20struct vm_struct * imlist = NULL;
@@ -23,11 +24,11 @@ static int get_free_im_addr(unsigned long size, unsigned long *im_addr)
23 unsigned long addr; 24 unsigned long addr;
24 struct vm_struct **p, *tmp; 25 struct vm_struct **p, *tmp;
25 26
26 addr = IMALLOC_START; 27 addr = ioremap_bot;
27 for (p = &imlist; (tmp = *p) ; p = &tmp->next) { 28 for (p = &imlist; (tmp = *p) ; p = &tmp->next) {
28 if (size + addr < (unsigned long) tmp->addr) 29 if (size + addr < (unsigned long) tmp->addr)
29 break; 30 break;
30 if ((unsigned long)tmp->addr >= IMALLOC_START) 31 if ((unsigned long)tmp->addr >= ioremap_bot)
31 addr = tmp->size + (unsigned long) tmp->addr; 32 addr = tmp->size + (unsigned long) tmp->addr;
32 if (addr > IMALLOC_END-size) 33 if (addr > IMALLOC_END-size)
33 return 1; 34 return 1;
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
index a7149b9fc35c..4b42aff74d73 100644
--- a/arch/ppc64/mm/init.c
+++ b/arch/ppc64/mm/init.c
@@ -64,6 +64,7 @@
64#include <asm/iommu.h> 64#include <asm/iommu.h>
65#include <asm/abs_addr.h> 65#include <asm/abs_addr.h>
66#include <asm/vdso.h> 66#include <asm/vdso.h>
67#include <asm/imalloc.h>
67 68
68int mem_init_done; 69int mem_init_done;
69unsigned long ioremap_bot = IMALLOC_BASE; 70unsigned long ioremap_bot = IMALLOC_BASE;
@@ -136,14 +137,78 @@ void iounmap(volatile void __iomem *addr)
136 137
137#else 138#else
138 139
140static void unmap_im_area_pte(pmd_t *pmd, unsigned long addr,
141 unsigned long end)
142{
143 pte_t *pte;
144
145 pte = pte_offset_kernel(pmd, addr);
146 do {
147 pte_t ptent = ptep_get_and_clear(&ioremap_mm, addr, pte);
148 WARN_ON(!pte_none(ptent) && !pte_present(ptent));
149 } while (pte++, addr += PAGE_SIZE, addr != end);
150}
151
152static inline void unmap_im_area_pmd(pud_t *pud, unsigned long addr,
153 unsigned long end)
154{
155 pmd_t *pmd;
156 unsigned long next;
157
158 pmd = pmd_offset(pud, addr);
159 do {
160 next = pmd_addr_end(addr, end);
161 if (pmd_none_or_clear_bad(pmd))
162 continue;
163 unmap_im_area_pte(pmd, addr, next);
164 } while (pmd++, addr = next, addr != end);
165}
166
167static inline void unmap_im_area_pud(pgd_t *pgd, unsigned long addr,
168 unsigned long end)
169{
170 pud_t *pud;
171 unsigned long next;
172
173 pud = pud_offset(pgd, addr);
174 do {
175 next = pud_addr_end(addr, end);
176 if (pud_none_or_clear_bad(pud))
177 continue;
178 unmap_im_area_pmd(pud, addr, next);
179 } while (pud++, addr = next, addr != end);
180}
181
182static void unmap_im_area(unsigned long addr, unsigned long end)
183{
184 struct mm_struct *mm = &ioremap_mm;
185 unsigned long next;
186 pgd_t *pgd;
187
188 spin_lock(&mm->page_table_lock);
189
190 pgd = pgd_offset_i(addr);
191 flush_cache_vunmap(addr, end);
192 do {
193 next = pgd_addr_end(addr, end);
194 if (pgd_none_or_clear_bad(pgd))
195 continue;
196 unmap_im_area_pud(pgd, addr, next);
197 } while (pgd++, addr = next, addr != end);
198 flush_tlb_kernel_range(start, end);
199
200 spin_unlock(&mm->page_table_lock);
201}
202
139/* 203/*
140 * map_io_page currently only called by __ioremap 204 * map_io_page currently only called by __ioremap
141 * map_io_page adds an entry to the ioremap page table 205 * map_io_page adds an entry to the ioremap page table
142 * and adds an entry to the HPT, possibly bolting it 206 * and adds an entry to the HPT, possibly bolting it
143 */ 207 */
144static void map_io_page(unsigned long ea, unsigned long pa, int flags) 208static int map_io_page(unsigned long ea, unsigned long pa, int flags)
145{ 209{
146 pgd_t *pgdp; 210 pgd_t *pgdp;
211 pud_t *pudp;
147 pmd_t *pmdp; 212 pmd_t *pmdp;
148 pte_t *ptep; 213 pte_t *ptep;
149 unsigned long vsid; 214 unsigned long vsid;
@@ -151,9 +216,15 @@ static void map_io_page(unsigned long ea, unsigned long pa, int flags)
151 if (mem_init_done) { 216 if (mem_init_done) {
152 spin_lock(&ioremap_mm.page_table_lock); 217 spin_lock(&ioremap_mm.page_table_lock);
153 pgdp = pgd_offset_i(ea); 218 pgdp = pgd_offset_i(ea);
154 pmdp = pmd_alloc(&ioremap_mm, pgdp, ea); 219 pudp = pud_alloc(&ioremap_mm, pgdp, ea);
220 if (!pudp)
221 return -ENOMEM;
222 pmdp = pmd_alloc(&ioremap_mm, pudp, ea);
223 if (!pmdp)
224 return -ENOMEM;
155 ptep = pte_alloc_kernel(&ioremap_mm, pmdp, ea); 225 ptep = pte_alloc_kernel(&ioremap_mm, pmdp, ea);
156 226 if (!ptep)
227 return -ENOMEM;
157 pa = abs_to_phys(pa); 228 pa = abs_to_phys(pa);
158 set_pte_at(&ioremap_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, 229 set_pte_at(&ioremap_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT,
159 __pgprot(flags))); 230 __pgprot(flags)));
@@ -181,6 +252,7 @@ static void map_io_page(unsigned long ea, unsigned long pa, int flags)
181 panic("map_io_page: could not insert mapping"); 252 panic("map_io_page: could not insert mapping");
182 } 253 }
183 } 254 }
255 return 0;
184} 256}
185 257
186 258
@@ -194,9 +266,14 @@ static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa,
194 flags |= pgprot_val(PAGE_KERNEL); 266 flags |= pgprot_val(PAGE_KERNEL);
195 267
196 for (i = 0; i < size; i += PAGE_SIZE) 268 for (i = 0; i < size; i += PAGE_SIZE)
197 map_io_page(ea+i, pa+i, flags); 269 if (map_io_page(ea+i, pa+i, flags))
270 goto failure;
198 271
199 return (void __iomem *) (ea + (addr & ~PAGE_MASK)); 272 return (void __iomem *) (ea + (addr & ~PAGE_MASK));
273 failure:
274 if (mem_init_done)
275 unmap_im_area(ea, ea + size);
276 return NULL;
200} 277}
201 278
202 279
@@ -206,10 +283,11 @@ ioremap(unsigned long addr, unsigned long size)
206 return __ioremap(addr, size, _PAGE_NO_CACHE | _PAGE_GUARDED); 283 return __ioremap(addr, size, _PAGE_NO_CACHE | _PAGE_GUARDED);
207} 284}
208 285
209void __iomem * 286void __iomem * __ioremap(unsigned long addr, unsigned long size,
210__ioremap(unsigned long addr, unsigned long size, unsigned long flags) 287 unsigned long flags)
211{ 288{
212 unsigned long pa, ea; 289 unsigned long pa, ea;
290 void __iomem *ret;
213 291
214 /* 292 /*
215 * Choose an address to map it to. 293 * Choose an address to map it to.
@@ -232,12 +310,16 @@ __ioremap(unsigned long addr, unsigned long size, unsigned long flags)
232 if (area == NULL) 310 if (area == NULL)
233 return NULL; 311 return NULL;
234 ea = (unsigned long)(area->addr); 312 ea = (unsigned long)(area->addr);
313 ret = __ioremap_com(addr, pa, ea, size, flags);
314 if (!ret)
315 im_free(area->addr);
235 } else { 316 } else {
236 ea = ioremap_bot; 317 ea = ioremap_bot;
237 ioremap_bot += size; 318 ret = __ioremap_com(addr, pa, ea, size, flags);
319 if (ret)
320 ioremap_bot += size;
238 } 321 }
239 322 return ret;
240 return __ioremap_com(addr, pa, ea, size, flags);
241} 323}
242 324
243#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK)) 325#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK))
@@ -246,6 +328,7 @@ int __ioremap_explicit(unsigned long pa, unsigned long ea,
246 unsigned long size, unsigned long flags) 328 unsigned long size, unsigned long flags)
247{ 329{
248 struct vm_struct *area; 330 struct vm_struct *area;
331 void __iomem *ret;
249 332
250 /* For now, require page-aligned values for pa, ea, and size */ 333 /* For now, require page-aligned values for pa, ea, and size */
251 if (!IS_PAGE_ALIGNED(pa) || !IS_PAGE_ALIGNED(ea) || 334 if (!IS_PAGE_ALIGNED(pa) || !IS_PAGE_ALIGNED(ea) ||
@@ -276,7 +359,12 @@ int __ioremap_explicit(unsigned long pa, unsigned long ea,
276 } 359 }
277 } 360 }
278 361
279 if (__ioremap_com(pa, pa, ea, size, flags) != (void *) ea) { 362 ret = __ioremap_com(pa, pa, ea, size, flags);
363 if (ret == NULL) {
364 printk(KERN_ERR "ioremap_explicit() allocation failure !\n");
365 return 1;
366 }
367 if (ret != (void *) ea) {
280 printk(KERN_ERR "__ioremap_com() returned unexpected addr\n"); 368 printk(KERN_ERR "__ioremap_com() returned unexpected addr\n");
281 return 1; 369 return 1;
282 } 370 }
@@ -284,69 +372,6 @@ int __ioremap_explicit(unsigned long pa, unsigned long ea,
284 return 0; 372 return 0;
285} 373}
286 374
287static void unmap_im_area_pte(pmd_t *pmd, unsigned long address,
288 unsigned long size)
289{
290 unsigned long base, end;
291 pte_t *pte;
292
293 if (pmd_none(*pmd))
294 return;
295 if (pmd_bad(*pmd)) {
296 pmd_ERROR(*pmd);
297 pmd_clear(pmd);
298 return;
299 }
300
301 pte = pte_offset_kernel(pmd, address);
302 base = address & PMD_MASK;
303 address &= ~PMD_MASK;
304 end = address + size;
305 if (end > PMD_SIZE)
306 end = PMD_SIZE;
307
308 do {
309 pte_t page;
310 page = ptep_get_and_clear(&ioremap_mm, base + address, pte);
311 address += PAGE_SIZE;
312 pte++;
313 if (pte_none(page))
314 continue;
315 if (pte_present(page))
316 continue;
317 printk(KERN_CRIT "Whee.. Swapped out page in kernel page"
318 " table\n");
319 } while (address < end);
320}
321
322static void unmap_im_area_pmd(pgd_t *dir, unsigned long address,
323 unsigned long size)
324{
325 unsigned long base, end;
326 pmd_t *pmd;
327
328 if (pgd_none(*dir))
329 return;
330 if (pgd_bad(*dir)) {
331 pgd_ERROR(*dir);
332 pgd_clear(dir);
333 return;
334 }
335
336 pmd = pmd_offset(dir, address);
337 base = address & PGDIR_MASK;
338 address &= ~PGDIR_MASK;
339 end = address + size;
340 if (end > PGDIR_SIZE)
341 end = PGDIR_SIZE;
342
343 do {
344 unmap_im_area_pte(pmd, base + address, end - address);
345 address = (address + PMD_SIZE) & PMD_MASK;
346 pmd++;
347 } while (address < end);
348}
349
350/* 375/*
351 * Unmap an IO region and remove it from imalloc'd list. 376 * Unmap an IO region and remove it from imalloc'd list.
352 * Access to IO memory should be serialized by driver. 377 * Access to IO memory should be serialized by driver.
@@ -356,39 +381,19 @@ static void unmap_im_area_pmd(pgd_t *dir, unsigned long address,
356 */ 381 */
357void iounmap(volatile void __iomem *token) 382void iounmap(volatile void __iomem *token)
358{ 383{
359 unsigned long address, start, end, size; 384 unsigned long address, size;
360 struct mm_struct *mm;
361 pgd_t *dir;
362 void *addr; 385 void *addr;
363 386
364 if (!mem_init_done) { 387 if (!mem_init_done)
365 return; 388 return;
366 }
367 389
368 addr = (void *) ((unsigned long __force) token & PAGE_MASK); 390 addr = (void *) ((unsigned long __force) token & PAGE_MASK);
369 391
370 if ((size = im_free(addr)) == 0) { 392 if ((size = im_free(addr)) == 0)
371 return; 393 return;
372 }
373 394
374 address = (unsigned long)addr; 395 address = (unsigned long)addr;
375 start = address; 396 unmap_im_area(address, address + size);
376 end = address + size;
377
378 mm = &ioremap_mm;
379 spin_lock(&mm->page_table_lock);
380
381 dir = pgd_offset_i(address);
382 flush_cache_vunmap(address, end);
383 do {
384 unmap_im_area_pmd(dir, address, end - address);
385 address = (address + PGDIR_SIZE) & PGDIR_MASK;
386 dir++;
387 } while (address && (address < end));
388 flush_tlb_kernel_range(start, end);
389
390 spin_unlock(&mm->page_table_lock);
391 return;
392} 397}
393 398
394static int iounmap_subset_regions(unsigned long addr, unsigned long size) 399static int iounmap_subset_regions(unsigned long addr, unsigned long size)
@@ -664,7 +669,7 @@ void __init paging_init(void)
664 zones_size[ZONE_DMA] = top_of_ram >> PAGE_SHIFT; 669 zones_size[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
665 zholes_size[ZONE_DMA] = (top_of_ram - total_ram) >> PAGE_SHIFT; 670 zholes_size[ZONE_DMA] = (top_of_ram - total_ram) >> PAGE_SHIFT;
666 671
667 free_area_init_node(0, &contig_page_data, zones_size, 672 free_area_init_node(0, NODE_DATA(0), zones_size,
668 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size); 673 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
669} 674}
670#endif /* CONFIG_DISCONTIGMEM */ 675#endif /* CONFIG_DISCONTIGMEM */
diff --git a/arch/ppc64/mm/slb.c b/arch/ppc64/mm/slb.c
index 6a20773f695d..244150a0bc18 100644
--- a/arch/ppc64/mm/slb.c
+++ b/arch/ppc64/mm/slb.c
@@ -33,8 +33,8 @@ static inline unsigned long mk_vsid_data(unsigned long ea, unsigned long flags)
33 return (get_kernel_vsid(ea) << SLB_VSID_SHIFT) | flags; 33 return (get_kernel_vsid(ea) << SLB_VSID_SHIFT) | flags;
34} 34}
35 35
36static inline void create_slbe(unsigned long ea, unsigned long vsid, 36static inline void create_slbe(unsigned long ea, unsigned long flags,
37 unsigned long flags, unsigned long entry) 37 unsigned long entry)
38{ 38{
39 asm volatile("slbmte %0,%1" : 39 asm volatile("slbmte %0,%1" :
40 : "r" (mk_vsid_data(ea, flags)), 40 : "r" (mk_vsid_data(ea, flags)),
@@ -145,9 +145,8 @@ void slb_initialize(void)
145 asm volatile("isync":::"memory"); 145 asm volatile("isync":::"memory");
146 asm volatile("slbmte %0,%0"::"r" (0) : "memory"); 146 asm volatile("slbmte %0,%0"::"r" (0) : "memory");
147 asm volatile("isync; slbia; isync":::"memory"); 147 asm volatile("isync; slbia; isync":::"memory");
148 create_slbe(KERNELBASE, get_kernel_vsid(KERNELBASE), flags, 0); 148 create_slbe(KERNELBASE, flags, 0);
149 create_slbe(VMALLOCBASE, get_kernel_vsid(KERNELBASE), 149 create_slbe(VMALLOCBASE, SLB_VSID_KERNEL, 1);
150 SLB_VSID_KERNEL, 1);
151 /* We don't bolt the stack for the time being - we're in boot, 150 /* We don't bolt the stack for the time being - we're in boot,
152 * so the stack is in the bolted segment. By the time it goes 151 * so the stack is in the bolted segment. By the time it goes
153 * elsewhere, we'll call _switch() which will bolt in the new 152 * elsewhere, we'll call _switch() which will bolt in the new
diff --git a/arch/ppc64/mm/stab.c b/arch/ppc64/mm/stab.c
index 31491131d5e4..df4bbe14153c 100644
--- a/arch/ppc64/mm/stab.c
+++ b/arch/ppc64/mm/stab.c
@@ -19,6 +19,11 @@
19#include <asm/paca.h> 19#include <asm/paca.h>
20#include <asm/cputable.h> 20#include <asm/cputable.h>
21 21
22struct stab_entry {
23 unsigned long esid_data;
24 unsigned long vsid_data;
25};
26
22/* Both the segment table and SLB code uses the following cache */ 27/* Both the segment table and SLB code uses the following cache */
23#define NR_STAB_CACHE_ENTRIES 8 28#define NR_STAB_CACHE_ENTRIES 8
24DEFINE_PER_CPU(long, stab_cache_ptr); 29DEFINE_PER_CPU(long, stab_cache_ptr);
diff --git a/arch/ppc64/xmon/ppc-opc.c b/arch/ppc64/xmon/ppc-opc.c
index 1e4e7e319970..5ee8fc32f824 100644
--- a/arch/ppc64/xmon/ppc-opc.c
+++ b/arch/ppc64/xmon/ppc-opc.c
@@ -20,6 +20,7 @@
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 02111-1307, USA. */ 21 02111-1307, USA. */
22 22
23#include <linux/stddef.h>
23#include "nonstdio.h" 24#include "nonstdio.h"
24#include "ppc.h" 25#include "ppc.h"
25 26
@@ -110,12 +111,12 @@ const struct powerpc_operand powerpc_operands[] =
110 /* The zero index is used to indicate the end of the list of 111 /* The zero index is used to indicate the end of the list of
111 operands. */ 112 operands. */
112#define UNUSED 0 113#define UNUSED 0
113 { 0, 0, 0, 0, 0 }, 114 { 0, 0, NULL, NULL, 0 },
114 115
115 /* The BA field in an XL form instruction. */ 116 /* The BA field in an XL form instruction. */
116#define BA UNUSED + 1 117#define BA UNUSED + 1
117#define BA_MASK (0x1f << 16) 118#define BA_MASK (0x1f << 16)
118 { 5, 16, 0, 0, PPC_OPERAND_CR }, 119 { 5, 16, NULL, NULL, PPC_OPERAND_CR },
119 120
120 /* The BA field in an XL form instruction when it must be the same 121 /* The BA field in an XL form instruction when it must be the same
121 as the BT field in the same instruction. */ 122 as the BT field in the same instruction. */
@@ -125,7 +126,7 @@ const struct powerpc_operand powerpc_operands[] =
125 /* The BB field in an XL form instruction. */ 126 /* The BB field in an XL form instruction. */
126#define BB BAT + 1 127#define BB BAT + 1
127#define BB_MASK (0x1f << 11) 128#define BB_MASK (0x1f << 11)
128 { 5, 11, 0, 0, PPC_OPERAND_CR }, 129 { 5, 11, NULL, NULL, PPC_OPERAND_CR },
129 130
130 /* The BB field in an XL form instruction when it must be the same 131 /* The BB field in an XL form instruction when it must be the same
131 as the BA field in the same instruction. */ 132 as the BA field in the same instruction. */
@@ -168,21 +169,21 @@ const struct powerpc_operand powerpc_operands[] =
168 169
169 /* The BF field in an X or XL form instruction. */ 170 /* The BF field in an X or XL form instruction. */
170#define BF BDPA + 1 171#define BF BDPA + 1
171 { 3, 23, 0, 0, PPC_OPERAND_CR }, 172 { 3, 23, NULL, NULL, PPC_OPERAND_CR },
172 173
173 /* An optional BF field. This is used for comparison instructions, 174 /* An optional BF field. This is used for comparison instructions,
174 in which an omitted BF field is taken as zero. */ 175 in which an omitted BF field is taken as zero. */
175#define OBF BF + 1 176#define OBF BF + 1
176 { 3, 23, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, 177 { 3, 23, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
177 178
178 /* The BFA field in an X or XL form instruction. */ 179 /* The BFA field in an X or XL form instruction. */
179#define BFA OBF + 1 180#define BFA OBF + 1
180 { 3, 18, 0, 0, PPC_OPERAND_CR }, 181 { 3, 18, NULL, NULL, PPC_OPERAND_CR },
181 182
182 /* The BI field in a B form or XL form instruction. */ 183 /* The BI field in a B form or XL form instruction. */
183#define BI BFA + 1 184#define BI BFA + 1
184#define BI_MASK (0x1f << 16) 185#define BI_MASK (0x1f << 16)
185 { 5, 16, 0, 0, PPC_OPERAND_CR }, 186 { 5, 16, NULL, NULL, PPC_OPERAND_CR },
186 187
187 /* The BO field in a B form instruction. Certain values are 188 /* The BO field in a B form instruction. Certain values are
188 illegal. */ 189 illegal. */
@@ -197,36 +198,36 @@ const struct powerpc_operand powerpc_operands[] =
197 198
198 /* The BT field in an X or XL form instruction. */ 199 /* The BT field in an X or XL form instruction. */
199#define BT BOE + 1 200#define BT BOE + 1
200 { 5, 21, 0, 0, PPC_OPERAND_CR }, 201 { 5, 21, NULL, NULL, PPC_OPERAND_CR },
201 202
202 /* The condition register number portion of the BI field in a B form 203 /* The condition register number portion of the BI field in a B form
203 or XL form instruction. This is used for the extended 204 or XL form instruction. This is used for the extended
204 conditional branch mnemonics, which set the lower two bits of the 205 conditional branch mnemonics, which set the lower two bits of the
205 BI field. This field is optional. */ 206 BI field. This field is optional. */
206#define CR BT + 1 207#define CR BT + 1
207 { 3, 18, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, 208 { 3, 18, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
208 209
209 /* The CRB field in an X form instruction. */ 210 /* The CRB field in an X form instruction. */
210#define CRB CR + 1 211#define CRB CR + 1
211 { 5, 6, 0, 0, 0 }, 212 { 5, 6, NULL, NULL, 0 },
212 213
213 /* The CRFD field in an X form instruction. */ 214 /* The CRFD field in an X form instruction. */
214#define CRFD CRB + 1 215#define CRFD CRB + 1
215 { 3, 23, 0, 0, PPC_OPERAND_CR }, 216 { 3, 23, NULL, NULL, PPC_OPERAND_CR },
216 217
217 /* The CRFS field in an X form instruction. */ 218 /* The CRFS field in an X form instruction. */
218#define CRFS CRFD + 1 219#define CRFS CRFD + 1
219 { 3, 0, 0, 0, PPC_OPERAND_CR }, 220 { 3, 0, NULL, NULL, PPC_OPERAND_CR },
220 221
221 /* The CT field in an X form instruction. */ 222 /* The CT field in an X form instruction. */
222#define CT CRFS + 1 223#define CT CRFS + 1
223 { 5, 21, 0, 0, PPC_OPERAND_OPTIONAL }, 224 { 5, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
224 225
225 /* The D field in a D form instruction. This is a displacement off 226 /* The D field in a D form instruction. This is a displacement off
226 a register, and implies that the next operand is a register in 227 a register, and implies that the next operand is a register in
227 parentheses. */ 228 parentheses. */
228#define D CT + 1 229#define D CT + 1
229 { 16, 0, 0, 0, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED }, 230 { 16, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
230 231
231 /* The DE field in a DE form instruction. This is like D, but is 12 232 /* The DE field in a DE form instruction. This is like D, but is 12
232 bits only. */ 233 bits only. */
@@ -252,40 +253,40 @@ const struct powerpc_operand powerpc_operands[] =
252 253
253 /* The E field in a wrteei instruction. */ 254 /* The E field in a wrteei instruction. */
254#define E DS + 1 255#define E DS + 1
255 { 1, 15, 0, 0, 0 }, 256 { 1, 15, NULL, NULL, 0 },
256 257
257 /* The FL1 field in a POWER SC form instruction. */ 258 /* The FL1 field in a POWER SC form instruction. */
258#define FL1 E + 1 259#define FL1 E + 1
259 { 4, 12, 0, 0, 0 }, 260 { 4, 12, NULL, NULL, 0 },
260 261
261 /* The FL2 field in a POWER SC form instruction. */ 262 /* The FL2 field in a POWER SC form instruction. */
262#define FL2 FL1 + 1 263#define FL2 FL1 + 1
263 { 3, 2, 0, 0, 0 }, 264 { 3, 2, NULL, NULL, 0 },
264 265
265 /* The FLM field in an XFL form instruction. */ 266 /* The FLM field in an XFL form instruction. */
266#define FLM FL2 + 1 267#define FLM FL2 + 1
267 { 8, 17, 0, 0, 0 }, 268 { 8, 17, NULL, NULL, 0 },
268 269
269 /* The FRA field in an X or A form instruction. */ 270 /* The FRA field in an X or A form instruction. */
270#define FRA FLM + 1 271#define FRA FLM + 1
271#define FRA_MASK (0x1f << 16) 272#define FRA_MASK (0x1f << 16)
272 { 5, 16, 0, 0, PPC_OPERAND_FPR }, 273 { 5, 16, NULL, NULL, PPC_OPERAND_FPR },
273 274
274 /* The FRB field in an X or A form instruction. */ 275 /* The FRB field in an X or A form instruction. */
275#define FRB FRA + 1 276#define FRB FRA + 1
276#define FRB_MASK (0x1f << 11) 277#define FRB_MASK (0x1f << 11)
277 { 5, 11, 0, 0, PPC_OPERAND_FPR }, 278 { 5, 11, NULL, NULL, PPC_OPERAND_FPR },
278 279
279 /* The FRC field in an A form instruction. */ 280 /* The FRC field in an A form instruction. */
280#define FRC FRB + 1 281#define FRC FRB + 1
281#define FRC_MASK (0x1f << 6) 282#define FRC_MASK (0x1f << 6)
282 { 5, 6, 0, 0, PPC_OPERAND_FPR }, 283 { 5, 6, NULL, NULL, PPC_OPERAND_FPR },
283 284
284 /* The FRS field in an X form instruction or the FRT field in a D, X 285 /* The FRS field in an X form instruction or the FRT field in a D, X
285 or A form instruction. */ 286 or A form instruction. */
286#define FRS FRC + 1 287#define FRS FRC + 1
287#define FRT FRS 288#define FRT FRS
288 { 5, 21, 0, 0, PPC_OPERAND_FPR }, 289 { 5, 21, NULL, NULL, PPC_OPERAND_FPR },
289 290
290 /* The FXM field in an XFX instruction. */ 291 /* The FXM field in an XFX instruction. */
291#define FXM FRS + 1 292#define FXM FRS + 1
@@ -298,11 +299,11 @@ const struct powerpc_operand powerpc_operands[] =
298 299
299 /* The L field in a D or X form instruction. */ 300 /* The L field in a D or X form instruction. */
300#define L FXM4 + 1 301#define L FXM4 + 1
301 { 1, 21, 0, 0, PPC_OPERAND_OPTIONAL }, 302 { 1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
302 303
303 /* The LEV field in a POWER SC form instruction. */ 304 /* The LEV field in a POWER SC form instruction. */
304#define LEV L + 1 305#define LEV L + 1
305 { 7, 5, 0, 0, 0 }, 306 { 7, 5, NULL, NULL, 0 },
306 307
307 /* The LI field in an I form instruction. The lower two bits are 308 /* The LI field in an I form instruction. The lower two bits are
308 forced to zero. */ 309 forced to zero. */
@@ -316,24 +317,24 @@ const struct powerpc_operand powerpc_operands[] =
316 317
317 /* The LS field in an X (sync) form instruction. */ 318 /* The LS field in an X (sync) form instruction. */
318#define LS LIA + 1 319#define LS LIA + 1
319 { 2, 21, 0, 0, PPC_OPERAND_OPTIONAL }, 320 { 2, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
320 321
321 /* The MB field in an M form instruction. */ 322 /* The MB field in an M form instruction. */
322#define MB LS + 1 323#define MB LS + 1
323#define MB_MASK (0x1f << 6) 324#define MB_MASK (0x1f << 6)
324 { 5, 6, 0, 0, 0 }, 325 { 5, 6, NULL, NULL, 0 },
325 326
326 /* The ME field in an M form instruction. */ 327 /* The ME field in an M form instruction. */
327#define ME MB + 1 328#define ME MB + 1
328#define ME_MASK (0x1f << 1) 329#define ME_MASK (0x1f << 1)
329 { 5, 1, 0, 0, 0 }, 330 { 5, 1, NULL, NULL, 0 },
330 331
331 /* The MB and ME fields in an M form instruction expressed a single 332 /* The MB and ME fields in an M form instruction expressed a single
332 operand which is a bitmask indicating which bits to select. This 333 operand which is a bitmask indicating which bits to select. This
333 is a two operand form using PPC_OPERAND_NEXT. See the 334 is a two operand form using PPC_OPERAND_NEXT. See the
334 description in opcode/ppc.h for what this means. */ 335 description in opcode/ppc.h for what this means. */
335#define MBE ME + 1 336#define MBE ME + 1
336 { 5, 6, 0, 0, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT }, 337 { 5, 6, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT },
337 { 32, 0, insert_mbe, extract_mbe, 0 }, 338 { 32, 0, insert_mbe, extract_mbe, 0 },
338 339
339 /* The MB or ME field in an MD or MDS form instruction. The high 340 /* The MB or ME field in an MD or MDS form instruction. The high
@@ -345,7 +346,7 @@ const struct powerpc_operand powerpc_operands[] =
345 346
346 /* The MO field in an mbar instruction. */ 347 /* The MO field in an mbar instruction. */
347#define MO MB6 + 1 348#define MO MB6 + 1
348 { 5, 21, 0, 0, 0 }, 349 { 5, 21, NULL, NULL, 0 },
349 350
350 /* The NB field in an X form instruction. The value 32 is stored as 351 /* The NB field in an X form instruction. The value 32 is stored as
351 0. */ 352 0. */
@@ -361,34 +362,34 @@ const struct powerpc_operand powerpc_operands[] =
361 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */ 362 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */
362#define RA NSI + 1 363#define RA NSI + 1
363#define RA_MASK (0x1f << 16) 364#define RA_MASK (0x1f << 16)
364 { 5, 16, 0, 0, PPC_OPERAND_GPR }, 365 { 5, 16, NULL, NULL, PPC_OPERAND_GPR },
365 366
366 /* The RA field in the DQ form lq instruction, which has special 367 /* The RA field in the DQ form lq instruction, which has special
367 value restrictions. */ 368 value restrictions. */
368#define RAQ RA + 1 369#define RAQ RA + 1
369 { 5, 16, insert_raq, 0, PPC_OPERAND_GPR }, 370 { 5, 16, insert_raq, NULL, PPC_OPERAND_GPR },
370 371
371 /* The RA field in a D or X form instruction which is an updating 372 /* The RA field in a D or X form instruction which is an updating
372 load, which means that the RA field may not be zero and may not 373 load, which means that the RA field may not be zero and may not
373 equal the RT field. */ 374 equal the RT field. */
374#define RAL RAQ + 1 375#define RAL RAQ + 1
375 { 5, 16, insert_ral, 0, PPC_OPERAND_GPR }, 376 { 5, 16, insert_ral, NULL, PPC_OPERAND_GPR },
376 377
377 /* The RA field in an lmw instruction, which has special value 378 /* The RA field in an lmw instruction, which has special value
378 restrictions. */ 379 restrictions. */
379#define RAM RAL + 1 380#define RAM RAL + 1
380 { 5, 16, insert_ram, 0, PPC_OPERAND_GPR }, 381 { 5, 16, insert_ram, NULL, PPC_OPERAND_GPR },
381 382
382 /* The RA field in a D or X form instruction which is an updating 383 /* The RA field in a D or X form instruction which is an updating
383 store or an updating floating point load, which means that the RA 384 store or an updating floating point load, which means that the RA
384 field may not be zero. */ 385 field may not be zero. */
385#define RAS RAM + 1 386#define RAS RAM + 1
386 { 5, 16, insert_ras, 0, PPC_OPERAND_GPR }, 387 { 5, 16, insert_ras, NULL, PPC_OPERAND_GPR },
387 388
388 /* The RB field in an X, XO, M, or MDS form instruction. */ 389 /* The RB field in an X, XO, M, or MDS form instruction. */
389#define RB RAS + 1 390#define RB RAS + 1
390#define RB_MASK (0x1f << 11) 391#define RB_MASK (0x1f << 11)
391 { 5, 11, 0, 0, PPC_OPERAND_GPR }, 392 { 5, 11, NULL, NULL, PPC_OPERAND_GPR },
392 393
393 /* The RB field in an X form instruction when it must be the same as 394 /* The RB field in an X form instruction when it must be the same as
394 the RS field in the instruction. This is used for extended 395 the RS field in the instruction. This is used for extended
@@ -402,22 +403,22 @@ const struct powerpc_operand powerpc_operands[] =
402#define RS RBS + 1 403#define RS RBS + 1
403#define RT RS 404#define RT RS
404#define RT_MASK (0x1f << 21) 405#define RT_MASK (0x1f << 21)
405 { 5, 21, 0, 0, PPC_OPERAND_GPR }, 406 { 5, 21, NULL, NULL, PPC_OPERAND_GPR },
406 407
407 /* The RS field of the DS form stq instruction, which has special 408 /* The RS field of the DS form stq instruction, which has special
408 value restrictions. */ 409 value restrictions. */
409#define RSQ RS + 1 410#define RSQ RS + 1
410 { 5, 21, insert_rsq, 0, PPC_OPERAND_GPR }, 411 { 5, 21, insert_rsq, NULL, PPC_OPERAND_GPR },
411 412
412 /* The RT field of the DQ form lq instruction, which has special 413 /* The RT field of the DQ form lq instruction, which has special
413 value restrictions. */ 414 value restrictions. */
414#define RTQ RSQ + 1 415#define RTQ RSQ + 1
415 { 5, 21, insert_rtq, 0, PPC_OPERAND_GPR }, 416 { 5, 21, insert_rtq, NULL, PPC_OPERAND_GPR },
416 417
417 /* The SH field in an X or M form instruction. */ 418 /* The SH field in an X or M form instruction. */
418#define SH RTQ + 1 419#define SH RTQ + 1
419#define SH_MASK (0x1f << 11) 420#define SH_MASK (0x1f << 11)
420 { 5, 11, 0, 0, 0 }, 421 { 5, 11, NULL, NULL, 0 },
421 422
422 /* The SH field in an MD form instruction. This is split. */ 423 /* The SH field in an MD form instruction. This is split. */
423#define SH6 SH + 1 424#define SH6 SH + 1
@@ -426,12 +427,12 @@ const struct powerpc_operand powerpc_operands[] =
426 427
427 /* The SI field in a D form instruction. */ 428 /* The SI field in a D form instruction. */
428#define SI SH6 + 1 429#define SI SH6 + 1
429 { 16, 0, 0, 0, PPC_OPERAND_SIGNED }, 430 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED },
430 431
431 /* The SI field in a D form instruction when we accept a wide range 432 /* The SI field in a D form instruction when we accept a wide range
432 of positive values. */ 433 of positive values. */
433#define SISIGNOPT SI + 1 434#define SISIGNOPT SI + 1
434 { 16, 0, 0, 0, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT }, 435 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
435 436
436 /* The SPR field in an XFX form instruction. This is flipped--the 437 /* The SPR field in an XFX form instruction. This is flipped--the
437 lower 5 bits are stored in the upper 5 and vice- versa. */ 438 lower 5 bits are stored in the upper 5 and vice- versa. */
@@ -443,25 +444,25 @@ const struct powerpc_operand powerpc_operands[] =
443 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */ 444 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */
444#define SPRBAT SPR + 1 445#define SPRBAT SPR + 1
445#define SPRBAT_MASK (0x3 << 17) 446#define SPRBAT_MASK (0x3 << 17)
446 { 2, 17, 0, 0, 0 }, 447 { 2, 17, NULL, NULL, 0 },
447 448
448 /* The SPRG register number in an XFX form m[ft]sprg instruction. */ 449 /* The SPRG register number in an XFX form m[ft]sprg instruction. */
449#define SPRG SPRBAT + 1 450#define SPRG SPRBAT + 1
450#define SPRG_MASK (0x3 << 16) 451#define SPRG_MASK (0x3 << 16)
451 { 2, 16, 0, 0, 0 }, 452 { 2, 16, NULL, NULL, 0 },
452 453
453 /* The SR field in an X form instruction. */ 454 /* The SR field in an X form instruction. */
454#define SR SPRG + 1 455#define SR SPRG + 1
455 { 4, 16, 0, 0, 0 }, 456 { 4, 16, NULL, NULL, 0 },
456 457
457 /* The STRM field in an X AltiVec form instruction. */ 458 /* The STRM field in an X AltiVec form instruction. */
458#define STRM SR + 1 459#define STRM SR + 1
459#define STRM_MASK (0x3 << 21) 460#define STRM_MASK (0x3 << 21)
460 { 2, 21, 0, 0, 0 }, 461 { 2, 21, NULL, NULL, 0 },
461 462
462 /* The SV field in a POWER SC form instruction. */ 463 /* The SV field in a POWER SC form instruction. */
463#define SV STRM + 1 464#define SV STRM + 1
464 { 14, 2, 0, 0, 0 }, 465 { 14, 2, NULL, NULL, 0 },
465 466
466 /* The TBR field in an XFX form instruction. This is like the SPR 467 /* The TBR field in an XFX form instruction. This is like the SPR
467 field, but it is optional. */ 468 field, but it is optional. */
@@ -471,52 +472,52 @@ const struct powerpc_operand powerpc_operands[] =
471 /* The TO field in a D or X form instruction. */ 472 /* The TO field in a D or X form instruction. */
472#define TO TBR + 1 473#define TO TBR + 1
473#define TO_MASK (0x1f << 21) 474#define TO_MASK (0x1f << 21)
474 { 5, 21, 0, 0, 0 }, 475 { 5, 21, NULL, NULL, 0 },
475 476
476 /* The U field in an X form instruction. */ 477 /* The U field in an X form instruction. */
477#define U TO + 1 478#define U TO + 1
478 { 4, 12, 0, 0, 0 }, 479 { 4, 12, NULL, NULL, 0 },
479 480
480 /* The UI field in a D form instruction. */ 481 /* The UI field in a D form instruction. */
481#define UI U + 1 482#define UI U + 1
482 { 16, 0, 0, 0, 0 }, 483 { 16, 0, NULL, NULL, 0 },
483 484
484 /* The VA field in a VA, VX or VXR form instruction. */ 485 /* The VA field in a VA, VX or VXR form instruction. */
485#define VA UI + 1 486#define VA UI + 1
486#define VA_MASK (0x1f << 16) 487#define VA_MASK (0x1f << 16)
487 { 5, 16, 0, 0, PPC_OPERAND_VR }, 488 { 5, 16, NULL, NULL, PPC_OPERAND_VR },
488 489
489 /* The VB field in a VA, VX or VXR form instruction. */ 490 /* The VB field in a VA, VX or VXR form instruction. */
490#define VB VA + 1 491#define VB VA + 1
491#define VB_MASK (0x1f << 11) 492#define VB_MASK (0x1f << 11)
492 { 5, 11, 0, 0, PPC_OPERAND_VR }, 493 { 5, 11, NULL, NULL, PPC_OPERAND_VR },
493 494
494 /* The VC field in a VA form instruction. */ 495 /* The VC field in a VA form instruction. */
495#define VC VB + 1 496#define VC VB + 1
496#define VC_MASK (0x1f << 6) 497#define VC_MASK (0x1f << 6)
497 { 5, 6, 0, 0, PPC_OPERAND_VR }, 498 { 5, 6, NULL, NULL, PPC_OPERAND_VR },
498 499
499 /* The VD or VS field in a VA, VX, VXR or X form instruction. */ 500 /* The VD or VS field in a VA, VX, VXR or X form instruction. */
500#define VD VC + 1 501#define VD VC + 1
501#define VS VD 502#define VS VD
502#define VD_MASK (0x1f << 21) 503#define VD_MASK (0x1f << 21)
503 { 5, 21, 0, 0, PPC_OPERAND_VR }, 504 { 5, 21, NULL, NULL, PPC_OPERAND_VR },
504 505
505 /* The SIMM field in a VX form instruction. */ 506 /* The SIMM field in a VX form instruction. */
506#define SIMM VD + 1 507#define SIMM VD + 1
507 { 5, 16, 0, 0, PPC_OPERAND_SIGNED}, 508 { 5, 16, NULL, NULL, PPC_OPERAND_SIGNED},
508 509
509 /* The UIMM field in a VX form instruction. */ 510 /* The UIMM field in a VX form instruction. */
510#define UIMM SIMM + 1 511#define UIMM SIMM + 1
511 { 5, 16, 0, 0, 0 }, 512 { 5, 16, NULL, NULL, 0 },
512 513
513 /* The SHB field in a VA form instruction. */ 514 /* The SHB field in a VA form instruction. */
514#define SHB UIMM + 1 515#define SHB UIMM + 1
515 { 4, 6, 0, 0, 0 }, 516 { 4, 6, NULL, NULL, 0 },
516 517
517 /* The other UIMM field in a EVX form instruction. */ 518 /* The other UIMM field in a EVX form instruction. */
518#define EVUIMM SHB + 1 519#define EVUIMM SHB + 1
519 { 5, 11, 0, 0, 0 }, 520 { 5, 11, NULL, NULL, 0 },
520 521
521 /* The other UIMM field in a half word EVX form instruction. */ 522 /* The other UIMM field in a half word EVX form instruction. */
522#define EVUIMM_2 EVUIMM + 1 523#define EVUIMM_2 EVUIMM + 1
@@ -533,11 +534,11 @@ const struct powerpc_operand powerpc_operands[] =
533 /* The WS field. */ 534 /* The WS field. */
534#define WS EVUIMM_8 + 1 535#define WS EVUIMM_8 + 1
535#define WS_MASK (0x7 << 11) 536#define WS_MASK (0x7 << 11)
536 { 3, 11, 0, 0, 0 }, 537 { 3, 11, NULL, NULL, 0 },
537 538
538 /* The L field in an mtmsrd instruction */ 539 /* The L field in an mtmsrd instruction */
539#define MTMSRD_L WS + 1 540#define MTMSRD_L WS + 1
540 { 1, 16, 0, 0, PPC_OPERAND_OPTIONAL }, 541 { 1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL },
541 542
542}; 543};
543 544
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 1358b4201701..07fd0414a4bf 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.11 3# Linux kernel version: 2.6.12-rc3
4# Wed Mar 2 16:57:55 2005 4# Fri Apr 22 15:30:58 2005
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_RWSEM_XCHGADD_ALGORITHM=y 7CONFIG_RWSEM_XCHGADD_ALGORITHM=y
@@ -15,6 +15,7 @@ CONFIG_UID16=y
15CONFIG_EXPERIMENTAL=y 15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_LOCK_KERNEL=y 17CONFIG_LOCK_KERNEL=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
18 19
19# 20#
20# General setup 21# General setup
@@ -26,24 +27,25 @@ CONFIG_SYSVIPC=y
26# CONFIG_BSD_PROCESS_ACCT is not set 27# CONFIG_BSD_PROCESS_ACCT is not set
27CONFIG_SYSCTL=y 28CONFIG_SYSCTL=y
28# CONFIG_AUDIT is not set 29# CONFIG_AUDIT is not set
29CONFIG_LOG_BUF_SHIFT=17
30CONFIG_HOTPLUG=y 30CONFIG_HOTPLUG=y
31CONFIG_KOBJECT_UEVENT=y 31CONFIG_KOBJECT_UEVENT=y
32CONFIG_IKCONFIG=y 32CONFIG_IKCONFIG=y
33CONFIG_IKCONFIG_PROC=y 33CONFIG_IKCONFIG_PROC=y
34# CONFIG_CPUSETS is not set
34# CONFIG_EMBEDDED is not set 35# CONFIG_EMBEDDED is not set
35CONFIG_KALLSYMS=y 36CONFIG_KALLSYMS=y
36# CONFIG_KALLSYMS_ALL is not set 37# CONFIG_KALLSYMS_ALL is not set
37# CONFIG_KALLSYMS_EXTRA_PASS is not set 38# CONFIG_KALLSYMS_EXTRA_PASS is not set
39CONFIG_BASE_FULL=y
38CONFIG_FUTEX=y 40CONFIG_FUTEX=y
39CONFIG_EPOLL=y 41CONFIG_EPOLL=y
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
41CONFIG_SHMEM=y 42CONFIG_SHMEM=y
42CONFIG_CC_ALIGN_FUNCTIONS=0 43CONFIG_CC_ALIGN_FUNCTIONS=0
43CONFIG_CC_ALIGN_LABELS=0 44CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 45CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 46CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 47# CONFIG_TINY_SHMEM is not set
48CONFIG_BASE_SMALL=0
47 49
48# 50#
49# Loadable module support 51# Loadable module support
@@ -261,7 +263,6 @@ CONFIG_NET=y
261# 263#
262CONFIG_PACKET=y 264CONFIG_PACKET=y
263# CONFIG_PACKET_MMAP is not set 265# CONFIG_PACKET_MMAP is not set
264# CONFIG_NETLINK_DEV is not set
265CONFIG_UNIX=y 266CONFIG_UNIX=y
266CONFIG_NET_KEY=y 267CONFIG_NET_KEY=y
267CONFIG_INET=y 268CONFIG_INET=y
@@ -329,6 +330,7 @@ CONFIG_NET_SCH_DSMARK=m
329CONFIG_NET_QOS=y 330CONFIG_NET_QOS=y
330CONFIG_NET_ESTIMATOR=y 331CONFIG_NET_ESTIMATOR=y
331CONFIG_NET_CLS=y 332CONFIG_NET_CLS=y
333# CONFIG_NET_CLS_BASIC is not set
332CONFIG_NET_CLS_TCINDEX=m 334CONFIG_NET_CLS_TCINDEX=m
333CONFIG_NET_CLS_ROUTE4=m 335CONFIG_NET_CLS_ROUTE4=m
334CONFIG_NET_CLS_ROUTE=y 336CONFIG_NET_CLS_ROUTE=y
@@ -338,6 +340,7 @@ CONFIG_NET_CLS_U32=m
338# CONFIG_NET_CLS_IND is not set 340# CONFIG_NET_CLS_IND is not set
339CONFIG_NET_CLS_RSVP=m 341CONFIG_NET_CLS_RSVP=m
340CONFIG_NET_CLS_RSVP6=m 342CONFIG_NET_CLS_RSVP6=m
343# CONFIG_NET_EMATCH is not set
341# CONFIG_NET_CLS_ACT is not set 344# CONFIG_NET_CLS_ACT is not set
342CONFIG_NET_CLS_POLICE=y 345CONFIG_NET_CLS_POLICE=y
343 346
@@ -393,6 +396,8 @@ CONFIG_CTC=m
393CONFIG_IUCV=m 396CONFIG_IUCV=m
394# CONFIG_NETIUCV is not set 397# CONFIG_NETIUCV is not set
395# CONFIG_SMSGIUCV is not set 398# CONFIG_SMSGIUCV is not set
399# CONFIG_CLAW is not set
400# CONFIG_MPC is not set
396CONFIG_QETH=y 401CONFIG_QETH=y
397 402
398# 403#
@@ -532,10 +537,13 @@ CONFIG_MSDOS_PARTITION=y
532# 537#
533# Kernel hacking 538# Kernel hacking
534# 539#
540# CONFIG_PRINTK_TIME is not set
535CONFIG_DEBUG_KERNEL=y 541CONFIG_DEBUG_KERNEL=y
536CONFIG_MAGIC_SYSRQ=y 542CONFIG_MAGIC_SYSRQ=y
543CONFIG_LOG_BUF_SHIFT=17
537# CONFIG_SCHEDSTATS is not set 544# CONFIG_SCHEDSTATS is not set
538# CONFIG_DEBUG_SLAB is not set 545# CONFIG_DEBUG_SLAB is not set
546# CONFIG_DEBUG_SPINLOCK is not set
539# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 547# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
540# CONFIG_DEBUG_KOBJECT is not set 548# CONFIG_DEBUG_KOBJECT is not set
541# CONFIG_DEBUG_INFO is not set 549# CONFIG_DEBUG_INFO is not set
@@ -560,6 +568,7 @@ CONFIG_CRYPTO=y
560# CONFIG_CRYPTO_SHA256 is not set 568# CONFIG_CRYPTO_SHA256 is not set
561# CONFIG_CRYPTO_SHA512 is not set 569# CONFIG_CRYPTO_SHA512 is not set
562# CONFIG_CRYPTO_WP512 is not set 570# CONFIG_CRYPTO_WP512 is not set
571# CONFIG_CRYPTO_TGR192 is not set
563# CONFIG_CRYPTO_DES is not set 572# CONFIG_CRYPTO_DES is not set
564# CONFIG_CRYPTO_DES_Z990 is not set 573# CONFIG_CRYPTO_DES_Z990 is not set
565# CONFIG_CRYPTO_BLOWFISH is not set 574# CONFIG_CRYPTO_BLOWFISH is not set
diff --git a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
index 96571ff7115d..03d03c6d3cbb 100644
--- a/arch/s390/kernel/compat_ioctl.c
+++ b/arch/s390/kernel/compat_ioctl.c
@@ -16,6 +16,7 @@
16#define CODE 16#define CODE
17#include "../../../fs/compat_ioctl.c" 17#include "../../../fs/compat_ioctl.c"
18#include <asm/dasd.h> 18#include <asm/dasd.h>
19#include <asm/cmb.h>
19#include <asm/tape390.h> 20#include <asm/tape390.h>
20 21
21static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, 22static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
@@ -58,7 +59,11 @@ COMPATIBLE_IOCTL(BIODASDPRRD)
58COMPATIBLE_IOCTL(BIODASDPSRD) 59COMPATIBLE_IOCTL(BIODASDPSRD)
59COMPATIBLE_IOCTL(BIODASDGATTR) 60COMPATIBLE_IOCTL(BIODASDGATTR)
60COMPATIBLE_IOCTL(BIODASDSATTR) 61COMPATIBLE_IOCTL(BIODASDSATTR)
61 62#if defined(CONFIG_DASD_CMB) || defined(CONFIG_DASD_CMB_MODULE)
63COMPATIBLE_IOCTL(BIODASDCMFENABLE)
64COMPATIBLE_IOCTL(BIODASDCMFDISABLE)
65COMPATIBLE_IOCTL(BIODASDREADALLCMB)
66#endif
62#endif 67#endif
63 68
64#if defined(CONFIG_S390_TAPE) || defined(CONFIG_S390_TAPE_MODULE) 69#if defined(CONFIG_S390_TAPE) || defined(CONFIG_S390_TAPE_MODULE)
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 647233c02fc8..26889366929a 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -32,6 +32,7 @@
32#include <linux/user.h> 32#include <linux/user.h>
33#include <linux/security.h> 33#include <linux/security.h>
34#include <linux/audit.h> 34#include <linux/audit.h>
35#include <linux/signal.h>
35 36
36#include <asm/segment.h> 37#include <asm/segment.h>
37#include <asm/page.h> 38#include <asm/page.h>
@@ -609,7 +610,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data)
609 /* continue and stop at next (return from) syscall */ 610 /* continue and stop at next (return from) syscall */
610 case PTRACE_CONT: 611 case PTRACE_CONT:
611 /* restart after signal. */ 612 /* restart after signal. */
612 if ((unsigned long) data >= _NSIG) 613 if (!valid_signal(data))
613 return -EIO; 614 return -EIO;
614 if (request == PTRACE_SYSCALL) 615 if (request == PTRACE_SYSCALL)
615 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 616 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -637,7 +638,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data)
637 638
638 case PTRACE_SINGLESTEP: 639 case PTRACE_SINGLESTEP:
639 /* set the trap flag. */ 640 /* set the trap flag. */
640 if ((unsigned long) data >= _NSIG) 641 if (!valid_signal(data))
641 return -EIO; 642 return -EIO;
642 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 643 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
643 child->exit_code = data; 644 child->exit_code = data;
@@ -711,18 +712,13 @@ out:
711asmlinkage void 712asmlinkage void
712syscall_trace(struct pt_regs *regs, int entryexit) 713syscall_trace(struct pt_regs *regs, int entryexit)
713{ 714{
714 if (unlikely(current->audit_context)) { 715 if (unlikely(current->audit_context) && entryexit)
715 if (!entryexit) 716 audit_syscall_exit(current, AUDITSC_RESULT(regs->gprs[2]), regs->gprs[2]);
716 audit_syscall_entry(current, regs->gprs[2], 717
717 regs->orig_gpr2, regs->gprs[3],
718 regs->gprs[4], regs->gprs[5]);
719 else
720 audit_syscall_exit(current, regs->gprs[2]);
721 }
722 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 718 if (!test_thread_flag(TIF_SYSCALL_TRACE))
723 return; 719 goto out;
724 if (!(current->ptrace & PT_PTRACED)) 720 if (!(current->ptrace & PT_PTRACED))
725 return; 721 goto out;
726 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) 722 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
727 ? 0x80 : 0)); 723 ? 0x80 : 0));
728 724
@@ -735,4 +731,10 @@ syscall_trace(struct pt_regs *regs, int entryexit)
735 send_sig(current->exit_code, current, 1); 731 send_sig(current->exit_code, current, 1);
736 current->exit_code = 0; 732 current->exit_code = 0;
737 } 733 }
734 out:
735 if (unlikely(current->audit_context) && !entryexit)
736 audit_syscall_entry(current,
737 test_thread_flag(TIF_31BIT)?AUDIT_ARCH_S390:AUDIT_ARCH_S390X,
738 regs->gprs[2], regs->orig_gpr2, regs->gprs[3],
739 regs->gprs[4], regs->gprs[5]);
738} 740}
diff --git a/arch/s390/kernel/s390_ksyms.c b/arch/s390/kernel/s390_ksyms.c
index 11fd6d556d8f..bee654abb6d3 100644
--- a/arch/s390/kernel/s390_ksyms.c
+++ b/arch/s390/kernel/s390_ksyms.c
@@ -34,7 +34,6 @@ EXPORT_SYMBOL(__clear_user_asm);
34EXPORT_SYMBOL(__strncpy_from_user_asm); 34EXPORT_SYMBOL(__strncpy_from_user_asm);
35EXPORT_SYMBOL(__strnlen_user_asm); 35EXPORT_SYMBOL(__strnlen_user_asm);
36EXPORT_SYMBOL(diag10); 36EXPORT_SYMBOL(diag10);
37EXPORT_SYMBOL(default_storage_key);
38 37
39/* 38/*
40 * semaphore ops 39 * semaphore ops
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index c879c40aa7a5..df83215beac3 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -44,6 +44,8 @@
44#include <asm/cpcmd.h> 44#include <asm/cpcmd.h>
45#include <asm/lowcore.h> 45#include <asm/lowcore.h>
46#include <asm/irq.h> 46#include <asm/irq.h>
47#include <asm/page.h>
48#include <asm/ptrace.h>
47 49
48/* 50/*
49 * Machine setup.. 51 * Machine setup..
@@ -53,13 +55,14 @@ unsigned int console_devno = -1;
53unsigned int console_irq = -1; 55unsigned int console_irq = -1;
54unsigned long memory_size = 0; 56unsigned long memory_size = 0;
55unsigned long machine_flags = 0; 57unsigned long machine_flags = 0;
56unsigned int default_storage_key = 0;
57struct { 58struct {
58 unsigned long addr, size, type; 59 unsigned long addr, size, type;
59} memory_chunk[MEMORY_CHUNKS] = { { 0 } }; 60} memory_chunk[MEMORY_CHUNKS] = { { 0 } };
60#define CHUNK_READ_WRITE 0 61#define CHUNK_READ_WRITE 0
61#define CHUNK_READ_ONLY 1 62#define CHUNK_READ_ONLY 1
62volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */ 63volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
64unsigned long __initdata zholes_size[MAX_NR_ZONES];
65static unsigned long __initdata memory_end;
63 66
64/* 67/*
65 * Setup options 68 * Setup options
@@ -78,11 +81,15 @@ static char command_line[COMMAND_LINE_SIZE] = { 0, };
78 81
79static struct resource code_resource = { 82static struct resource code_resource = {
80 .name = "Kernel code", 83 .name = "Kernel code",
84 .start = (unsigned long) &_text,
85 .end = (unsigned long) &_etext - 1,
81 .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 86 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
82}; 87};
83 88
84static struct resource data_resource = { 89static struct resource data_resource = {
85 .name = "Kernel data", 90 .name = "Kernel data",
91 .start = (unsigned long) &_etext,
92 .end = (unsigned long) &_edata - 1,
86 .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 93 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
87}; 94};
88 95
@@ -310,90 +317,50 @@ void machine_power_off(void)
310 317
311EXPORT_SYMBOL(machine_power_off); 318EXPORT_SYMBOL(machine_power_off);
312 319
313/* 320static void __init
314 * Setup function called from init/main.c just after the banner 321add_memory_hole(unsigned long start, unsigned long end)
315 * was printed. 322{
316 */ 323 unsigned long dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT;
317extern char _pstart, _pend, _stext; 324
325 if (end <= dma_pfn)
326 zholes_size[ZONE_DMA] += end - start + 1;
327 else if (start > dma_pfn)
328 zholes_size[ZONE_NORMAL] += end - start + 1;
329 else {
330 zholes_size[ZONE_DMA] += dma_pfn - start + 1;
331 zholes_size[ZONE_NORMAL] += end - dma_pfn;
332 }
333}
318 334
319void __init setup_arch(char **cmdline_p) 335static void __init
336parse_cmdline_early(char **cmdline_p)
320{ 337{
321 unsigned long bootmap_size; 338 char c = ' ', cn, *to = command_line, *from = COMMAND_LINE;
322 unsigned long memory_start, memory_end; 339 unsigned long delay = 0;
323 char c = ' ', cn, *to = command_line, *from = COMMAND_LINE;
324 unsigned long start_pfn, end_pfn;
325 static unsigned int smptrap=0;
326 unsigned long delay = 0;
327 struct _lowcore *lc;
328 int i;
329 340
330 if (smptrap) 341 /* Save unparsed command line copy for /proc/cmdline */
331 return; 342 memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
332 smptrap=1; 343 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
333 344
334 /* 345 for (;;) {
335 * print what head.S has found out about the machine 346 /*
336 */ 347 * "mem=XXX[kKmM]" sets memsize
337#ifndef CONFIG_ARCH_S390X 348 */
338 printk((MACHINE_IS_VM) ? 349 if (c == ' ' && strncmp(from, "mem=", 4) == 0) {
339 "We are running under VM (31 bit mode)\n" : 350 memory_end = simple_strtoul(from+4, &from, 0);
340 "We are running native (31 bit mode)\n"); 351 if ( *from == 'K' || *from == 'k' ) {
341 printk((MACHINE_HAS_IEEE) ? 352 memory_end = memory_end << 10;
342 "This machine has an IEEE fpu\n" : 353 from++;
343 "This machine has no IEEE fpu\n"); 354 } else if ( *from == 'M' || *from == 'm' ) {
344#else /* CONFIG_ARCH_S390X */ 355 memory_end = memory_end << 20;
345 printk((MACHINE_IS_VM) ? 356 from++;
346 "We are running under VM (64 bit mode)\n" : 357 }
347 "We are running native (64 bit mode)\n"); 358 }
348#endif /* CONFIG_ARCH_S390X */ 359 /*
349 360 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
350 ROOT_DEV = Root_RAM0; 361 */
351 memory_start = (unsigned long) &_end; /* fixit if use $CODELO etc*/ 362 if (c == ' ' && strncmp(from, "ipldelay=", 9) == 0) {
352#ifndef CONFIG_ARCH_S390X 363 delay = simple_strtoul(from+9, &from, 0);
353 memory_end = memory_size & ~0x400000UL; /* align memory end to 4MB */
354 /*
355 * We need some free virtual space to be able to do vmalloc.
356 * On a machine with 2GB memory we make sure that we have at
357 * least 128 MB free space for vmalloc.
358 */
359 if (memory_end > 1920*1024*1024)
360 memory_end = 1920*1024*1024;
361#else /* CONFIG_ARCH_S390X */
362 memory_end = memory_size & ~0x200000UL; /* detected in head.s */
363#endif /* CONFIG_ARCH_S390X */
364 init_mm.start_code = PAGE_OFFSET;
365 init_mm.end_code = (unsigned long) &_etext;
366 init_mm.end_data = (unsigned long) &_edata;
367 init_mm.brk = (unsigned long) &_end;
368
369 code_resource.start = (unsigned long) &_text;
370 code_resource.end = (unsigned long) &_etext - 1;
371 data_resource.start = (unsigned long) &_etext;
372 data_resource.end = (unsigned long) &_edata - 1;
373
374 /* Save unparsed command line copy for /proc/cmdline */
375 memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
376 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
377
378 for (;;) {
379 /*
380 * "mem=XXX[kKmM]" sets memsize
381 */
382 if (c == ' ' && strncmp(from, "mem=", 4) == 0) {
383 memory_end = simple_strtoul(from+4, &from, 0);
384 if ( *from == 'K' || *from == 'k' ) {
385 memory_end = memory_end << 10;
386 from++;
387 } else if ( *from == 'M' || *from == 'm' ) {
388 memory_end = memory_end << 20;
389 from++;
390 }
391 }
392 /*
393 * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
394 */
395 if (c == ' ' && strncmp(from, "ipldelay=", 9) == 0) {
396 delay = simple_strtoul(from+9, &from, 0);
397 if (*from == 's' || *from == 'S') { 364 if (*from == 's' || *from == 'S') {
398 delay = delay*1000000; 365 delay = delay*1000000;
399 from++; 366 from++;
@@ -403,24 +370,110 @@ void __init setup_arch(char **cmdline_p)
403 } 370 }
404 /* now wait for the requested amount of time */ 371 /* now wait for the requested amount of time */
405 udelay(delay); 372 udelay(delay);
406 } 373 }
407 cn = *(from++); 374 cn = *(from++);
408 if (!cn) 375 if (!cn)
409 break; 376 break;
410 if (cn == '\n') 377 if (cn == '\n')
411 cn = ' '; /* replace newlines with space */ 378 cn = ' '; /* replace newlines with space */
412 if (cn == 0x0d) 379 if (cn == 0x0d)
413 cn = ' '; /* replace 0x0d with space */ 380 cn = ' '; /* replace 0x0d with space */
414 if (cn == ' ' && c == ' ') 381 if (cn == ' ' && c == ' ')
415 continue; /* remove additional spaces */ 382 continue; /* remove additional spaces */
416 c = cn; 383 c = cn;
417 if (to - command_line >= COMMAND_LINE_SIZE) 384 if (to - command_line >= COMMAND_LINE_SIZE)
418 break; 385 break;
419 *(to++) = c; 386 *(to++) = c;
420 } 387 }
421 if (c == ' ' && to > command_line) to--; 388 if (c == ' ' && to > command_line) to--;
422 *to = '\0'; 389 *to = '\0';
423 *cmdline_p = command_line; 390 *cmdline_p = command_line;
391}
392
393static void __init
394setup_lowcore(void)
395{
396 struct _lowcore *lc;
397 int lc_pages;
398
399 /*
400 * Setup lowcore for boot cpu
401 */
402 lc_pages = sizeof(void *) == 8 ? 2 : 1;
403 lc = (struct _lowcore *)
404 __alloc_bootmem(lc_pages * PAGE_SIZE, lc_pages * PAGE_SIZE, 0);
405 memset(lc, 0, lc_pages * PAGE_SIZE);
406 lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
407 lc->restart_psw.addr =
408 PSW_ADDR_AMODE | (unsigned long) restart_int_handler;
409 lc->external_new_psw.mask = PSW_KERNEL_BITS;
410 lc->external_new_psw.addr =
411 PSW_ADDR_AMODE | (unsigned long) ext_int_handler;
412 lc->svc_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_IO | PSW_MASK_EXT;
413 lc->svc_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) system_call;
414 lc->program_new_psw.mask = PSW_KERNEL_BITS;
415 lc->program_new_psw.addr =
416 PSW_ADDR_AMODE | (unsigned long)pgm_check_handler;
417 lc->mcck_new_psw.mask = PSW_KERNEL_BITS;
418 lc->mcck_new_psw.addr =
419 PSW_ADDR_AMODE | (unsigned long) mcck_int_handler;
420 lc->io_new_psw.mask = PSW_KERNEL_BITS;
421 lc->io_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) io_int_handler;
422 lc->ipl_device = S390_lowcore.ipl_device;
423 lc->jiffy_timer = -1LL;
424 lc->kernel_stack = ((unsigned long) &init_thread_union) + THREAD_SIZE;
425 lc->async_stack = (unsigned long)
426 __alloc_bootmem(ASYNC_SIZE, ASYNC_SIZE, 0) + ASYNC_SIZE;
427#ifdef CONFIG_CHECK_STACK
428 lc->panic_stack = (unsigned long)
429 __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE;
430#endif
431 lc->current_task = (unsigned long) init_thread_union.thread_info.task;
432 lc->thread_info = (unsigned long) &init_thread_union;
433#ifdef CONFIG_ARCH_S390X
434 if (MACHINE_HAS_DIAG44)
435 lc->diag44_opcode = 0x83000044;
436 else
437 lc->diag44_opcode = 0x07000700;
438#endif /* CONFIG_ARCH_S390X */
439 set_prefix((u32)(unsigned long) lc);
440}
441
442static void __init
443setup_resources(void)
444{
445 struct resource *res;
446 int i;
447
448 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
449 res = alloc_bootmem_low(sizeof(struct resource));
450 res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
451 switch (memory_chunk[i].type) {
452 case CHUNK_READ_WRITE:
453 res->name = "System RAM";
454 break;
455 case CHUNK_READ_ONLY:
456 res->name = "System ROM";
457 res->flags |= IORESOURCE_READONLY;
458 break;
459 default:
460 res->name = "reserved";
461 }
462 res->start = memory_chunk[i].addr;
463 res->end = memory_chunk[i].addr + memory_chunk[i].size - 1;
464 request_resource(&iomem_resource, res);
465 request_resource(res, &code_resource);
466 request_resource(res, &data_resource);
467 }
468}
469
470static void __init
471setup_memory(void)
472{
473 unsigned long bootmap_size;
474 unsigned long start_pfn, end_pfn, init_pfn;
475 unsigned long last_rw_end;
476 int i;
424 477
425 /* 478 /*
426 * partially used pages are not usable - thus 479 * partially used pages are not usable - thus
@@ -429,6 +482,10 @@ void __init setup_arch(char **cmdline_p)
429 start_pfn = (__pa(&_end) + PAGE_SIZE - 1) >> PAGE_SHIFT; 482 start_pfn = (__pa(&_end) + PAGE_SIZE - 1) >> PAGE_SHIFT;
430 end_pfn = max_pfn = memory_end >> PAGE_SHIFT; 483 end_pfn = max_pfn = memory_end >> PAGE_SHIFT;
431 484
485 /* Initialize storage key for kernel pages */
486 for (init_pfn = 0 ; init_pfn < start_pfn; init_pfn++)
487 page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY);
488
432 /* 489 /*
433 * Initialize the boot-time allocator (with low memory only): 490 * Initialize the boot-time allocator (with low memory only):
434 */ 491 */
@@ -437,7 +494,9 @@ void __init setup_arch(char **cmdline_p)
437 /* 494 /*
438 * Register RAM areas with the bootmem allocator. 495 * Register RAM areas with the bootmem allocator.
439 */ 496 */
440 for (i = 0; i < 16 && memory_chunk[i].size > 0; i++) { 497 last_rw_end = start_pfn;
498
499 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
441 unsigned long start_chunk, end_chunk; 500 unsigned long start_chunk, end_chunk;
442 501
443 if (memory_chunk[i].type != CHUNK_READ_WRITE) 502 if (memory_chunk[i].type != CHUNK_READ_WRITE)
@@ -450,102 +509,98 @@ void __init setup_arch(char **cmdline_p)
450 start_chunk = start_pfn; 509 start_chunk = start_pfn;
451 if (end_chunk > end_pfn) 510 if (end_chunk > end_pfn)
452 end_chunk = end_pfn; 511 end_chunk = end_pfn;
453 if (start_chunk < end_chunk) 512 if (start_chunk < end_chunk) {
513 /* Initialize storage key for RAM pages */
514 for (init_pfn = start_chunk ; init_pfn < end_chunk;
515 init_pfn++)
516 page_set_storage_key(init_pfn << PAGE_SHIFT,
517 PAGE_DEFAULT_KEY);
454 free_bootmem(start_chunk << PAGE_SHIFT, 518 free_bootmem(start_chunk << PAGE_SHIFT,
455 (end_chunk - start_chunk) << PAGE_SHIFT); 519 (end_chunk - start_chunk) << PAGE_SHIFT);
520 if (last_rw_end < start_chunk)
521 add_memory_hole(last_rw_end, start_chunk - 1);
522 last_rw_end = end_chunk;
523 }
456 } 524 }
457 525
458 /* 526 psw_set_key(PAGE_DEFAULT_KEY);
459 * Reserve the bootmem bitmap itself as well. We do this in two 527
460 * steps (first step was init_bootmem()) because this catches 528 if (last_rw_end < end_pfn - 1)
461 * the (very unlikely) case of us accidentally initializing the 529 add_memory_hole(last_rw_end, end_pfn - 1);
462 * bootmem allocator with an invalid RAM area. 530
463 */ 531 /*
464 reserve_bootmem(start_pfn << PAGE_SHIFT, bootmap_size); 532 * Reserve the bootmem bitmap itself as well. We do this in two
533 * steps (first step was init_bootmem()) because this catches
534 * the (very unlikely) case of us accidentally initializing the
535 * bootmem allocator with an invalid RAM area.
536 */
537 reserve_bootmem(start_pfn << PAGE_SHIFT, bootmap_size);
465 538
466#ifdef CONFIG_BLK_DEV_INITRD 539#ifdef CONFIG_BLK_DEV_INITRD
467 if (INITRD_START) { 540 if (INITRD_START) {
468 if (INITRD_START + INITRD_SIZE <= memory_end) { 541 if (INITRD_START + INITRD_SIZE <= memory_end) {
469 reserve_bootmem(INITRD_START, INITRD_SIZE); 542 reserve_bootmem(INITRD_START, INITRD_SIZE);
470 initrd_start = INITRD_START; 543 initrd_start = INITRD_START;
471 initrd_end = initrd_start + INITRD_SIZE; 544 initrd_end = initrd_start + INITRD_SIZE;
472 } else { 545 } else {
473 printk("initrd extends beyond end of memory " 546 printk("initrd extends beyond end of memory "
474 "(0x%08lx > 0x%08lx)\ndisabling initrd\n", 547 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
475 initrd_start + INITRD_SIZE, memory_end); 548 initrd_start + INITRD_SIZE, memory_end);
476 initrd_start = initrd_end = 0; 549 initrd_start = initrd_end = 0;
477 } 550 }
478 } 551 }
479#endif 552#endif
553}
480 554
481 for (i = 0; i < 16 && memory_chunk[i].size > 0; i++) { 555/*
482 struct resource *res; 556 * Setup function called from init/main.c just after the banner
483 557 * was printed.
484 res = alloc_bootmem_low(sizeof(struct resource)); 558 */
485 res->flags = IORESOURCE_BUSY | IORESOURCE_MEM;
486
487 switch (memory_chunk[i].type) {
488 case CHUNK_READ_WRITE:
489 res->name = "System RAM";
490 break;
491 case CHUNK_READ_ONLY:
492 res->name = "System ROM";
493 res->flags |= IORESOURCE_READONLY;
494 break;
495 default:
496 res->name = "reserved";
497 }
498 res->start = memory_chunk[i].addr;
499 res->end = memory_chunk[i].addr + memory_chunk[i].size - 1;
500 request_resource(&iomem_resource, res);
501 request_resource(res, &code_resource);
502 request_resource(res, &data_resource);
503 }
504 559
560void __init
561setup_arch(char **cmdline_p)
562{
505 /* 563 /*
506 * Setup lowcore for boot cpu 564 * print what head.S has found out about the machine
507 */ 565 */
508#ifndef CONFIG_ARCH_S390X 566#ifndef CONFIG_ARCH_S390X
509 lc = (struct _lowcore *) __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0); 567 printk((MACHINE_IS_VM) ?
510 memset(lc, 0, PAGE_SIZE); 568 "We are running under VM (31 bit mode)\n" :
569 "We are running native (31 bit mode)\n");
570 printk((MACHINE_HAS_IEEE) ?
571 "This machine has an IEEE fpu\n" :
572 "This machine has no IEEE fpu\n");
511#else /* CONFIG_ARCH_S390X */ 573#else /* CONFIG_ARCH_S390X */
512 lc = (struct _lowcore *) __alloc_bootmem(2*PAGE_SIZE, 2*PAGE_SIZE, 0); 574 printk((MACHINE_IS_VM) ?
513 memset(lc, 0, 2*PAGE_SIZE); 575 "We are running under VM (64 bit mode)\n" :
576 "We are running native (64 bit mode)\n");
514#endif /* CONFIG_ARCH_S390X */ 577#endif /* CONFIG_ARCH_S390X */
515 lc->restart_psw.mask = PSW_BASE_BITS; 578
516 lc->restart_psw.addr = 579 ROOT_DEV = Root_RAM0;
517 PSW_ADDR_AMODE | (unsigned long) restart_int_handler; 580#ifndef CONFIG_ARCH_S390X
518 lc->external_new_psw.mask = PSW_KERNEL_BITS; 581 memory_end = memory_size & ~0x400000UL; /* align memory end to 4MB */
519 lc->external_new_psw.addr = 582 /*
520 PSW_ADDR_AMODE | (unsigned long) ext_int_handler; 583 * We need some free virtual space to be able to do vmalloc.
521 lc->svc_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_IO | PSW_MASK_EXT; 584 * On a machine with 2GB memory we make sure that we have at
522 lc->svc_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) system_call; 585 * least 128 MB free space for vmalloc.
523 lc->program_new_psw.mask = PSW_KERNEL_BITS; 586 */
524 lc->program_new_psw.addr = 587 if (memory_end > 1920*1024*1024)
525 PSW_ADDR_AMODE | (unsigned long)pgm_check_handler; 588 memory_end = 1920*1024*1024;
526 lc->mcck_new_psw.mask = PSW_KERNEL_BITS; 589#else /* CONFIG_ARCH_S390X */
527 lc->mcck_new_psw.addr = 590 memory_end = memory_size & ~0x200000UL; /* detected in head.s */
528 PSW_ADDR_AMODE | (unsigned long) mcck_int_handler;
529 lc->io_new_psw.mask = PSW_KERNEL_BITS;
530 lc->io_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) io_int_handler;
531 lc->ipl_device = S390_lowcore.ipl_device;
532 lc->jiffy_timer = -1LL;
533 lc->kernel_stack = ((unsigned long) &init_thread_union) + THREAD_SIZE;
534 lc->async_stack = (unsigned long)
535 __alloc_bootmem(ASYNC_SIZE, ASYNC_SIZE, 0) + ASYNC_SIZE;
536#ifdef CONFIG_CHECK_STACK
537 lc->panic_stack = (unsigned long)
538 __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE;
539#endif
540 lc->current_task = (unsigned long) init_thread_union.thread_info.task;
541 lc->thread_info = (unsigned long) &init_thread_union;
542#ifdef CONFIG_ARCH_S390X
543 if (MACHINE_HAS_DIAG44)
544 lc->diag44_opcode = 0x83000044;
545 else
546 lc->diag44_opcode = 0x07000700;
547#endif /* CONFIG_ARCH_S390X */ 591#endif /* CONFIG_ARCH_S390X */
548 set_prefix((u32)(unsigned long) lc); 592
593 init_mm.start_code = PAGE_OFFSET;
594 init_mm.end_code = (unsigned long) &_etext;
595 init_mm.end_data = (unsigned long) &_edata;
596 init_mm.brk = (unsigned long) &_end;
597
598 parse_cmdline_early(cmdline_p);
599
600 setup_memory();
601 setup_resources();
602 setup_lowcore();
603
549 cpu_init(); 604 cpu_init();
550 __cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr; 605 __cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr;
551 606
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 061e81138dc2..8ca485676780 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -244,7 +244,7 @@ int sysctl_hz_timer = 1;
244 */ 244 */
245static inline void stop_hz_timer(void) 245static inline void stop_hz_timer(void)
246{ 246{
247 __u64 timer; 247 __u64 timer, todval;
248 248
249 if (sysctl_hz_timer != 0) 249 if (sysctl_hz_timer != 0)
250 return; 250 return;
@@ -265,8 +265,14 @@ static inline void stop_hz_timer(void)
265 * for the next event. 265 * for the next event.
266 */ 266 */
267 timer = (__u64) (next_timer_interrupt() - jiffies) + jiffies_64; 267 timer = (__u64) (next_timer_interrupt() - jiffies) + jiffies_64;
268 timer = jiffies_timer_cc + timer * CLK_TICKS_PER_JIFFY; 268 todval = -1ULL;
269 asm volatile ("SCKC %0" : : "m" (timer)); 269 /* Be careful about overflows. */
270 if (timer < (-1ULL / CLK_TICKS_PER_JIFFY)) {
271 timer = jiffies_timer_cc + timer * CLK_TICKS_PER_JIFFY;
272 if (timer >= jiffies_timer_cc)
273 todval = timer;
274 }
275 asm volatile ("SCKC %0" : : "m" (todval));
270} 276}
271 277
272/* 278/*
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index bb6cf02418a2..fa0726507b3d 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -122,12 +122,17 @@ static void start_cpu_timer(void)
122 struct vtimer_queue *vt_list; 122 struct vtimer_queue *vt_list;
123 123
124 vt_list = &per_cpu(virt_cpu_timer, smp_processor_id()); 124 vt_list = &per_cpu(virt_cpu_timer, smp_processor_id());
125 set_vtimer(vt_list->idle); 125
126 /* CPU timer interrupt is pending, don't reprogramm it */
127 if (vt_list->idle & 1LL<<63)
128 return;
129
130 if (!list_empty(&vt_list->list))
131 set_vtimer(vt_list->idle);
126} 132}
127 133
128static void stop_cpu_timer(void) 134static void stop_cpu_timer(void)
129{ 135{
130 __u64 done;
131 struct vtimer_queue *vt_list; 136 struct vtimer_queue *vt_list;
132 137
133 vt_list = &per_cpu(virt_cpu_timer, smp_processor_id()); 138 vt_list = &per_cpu(virt_cpu_timer, smp_processor_id());
@@ -138,21 +143,17 @@ static void stop_cpu_timer(void)
138 goto fire; 143 goto fire;
139 } 144 }
140 145
141 /* store progress */ 146 /* store the actual expire value */
142 asm volatile ("STPT %0" : "=m" (done)); 147 asm volatile ("STPT %0" : "=m" (vt_list->idle));
143 148
144 /* 149 /*
145 * If done is negative we do not stop the CPU timer 150 * If the CPU timer is negative we don't reprogramm
146 * because we will get instantly an interrupt that 151 * it because we will get instantly an interrupt.
147 * will start the CPU timer again.
148 */ 152 */
149 if (done & 1LL<<63) 153 if (vt_list->idle & 1LL<<63)
150 return; 154 return;
151 else
152 vt_list->offset += vt_list->to_expire - done;
153 155
154 /* save the actual expire value */ 156 vt_list->offset += vt_list->to_expire - vt_list->idle;
155 vt_list->idle = done;
156 157
157 /* 158 /*
158 * We cannot halt the CPU timer, we just write a value that 159 * We cannot halt the CPU timer, we just write a value that
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index d30cdb4248a9..f5a5bc09b8fa 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -20,6 +20,11 @@
20#include <asm/pgalloc.h> 20#include <asm/pgalloc.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22 22
23static char *sender = "VMRMSVM";
24module_param(sender, charp, 0);
25MODULE_PARM_DESC(sender,
26 "Guest name that may send SMSG messages (default VMRMSVM)");
27
23#include "../../../drivers/s390/net/smsgiucv.h" 28#include "../../../drivers/s390/net/smsgiucv.h"
24 29
25#define CMM_NR_PAGES ((PAGE_SIZE / sizeof(unsigned long)) - 2) 30#define CMM_NR_PAGES ((PAGE_SIZE / sizeof(unsigned long)) - 2)
@@ -367,10 +372,12 @@ static struct ctl_table cmm_dir_table[] = {
367#ifdef CONFIG_CMM_IUCV 372#ifdef CONFIG_CMM_IUCV
368#define SMSG_PREFIX "CMM" 373#define SMSG_PREFIX "CMM"
369static void 374static void
370cmm_smsg_target(char *msg) 375cmm_smsg_target(char *from, char *msg)
371{ 376{
372 long pages, seconds; 377 long pages, seconds;
373 378
379 if (strlen(sender) > 0 && strcmp(from, sender) != 0)
380 return;
374 if (!cmm_skip_blanks(msg + strlen(SMSG_PREFIX), &msg)) 381 if (!cmm_skip_blanks(msg + strlen(SMSG_PREFIX), &msg))
375 return; 382 return;
376 if (strncmp(msg, "SHRINK", 6) == 0) { 383 if (strncmp(msg, "SHRINK", 6) == 0) {
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 8e723bc7f795..6ec5cd981e74 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -101,6 +101,7 @@ extern unsigned long _end;
101extern unsigned long __init_begin; 101extern unsigned long __init_begin;
102extern unsigned long __init_end; 102extern unsigned long __init_end;
103 103
104extern unsigned long __initdata zholes_size[];
104/* 105/*
105 * paging_init() sets up the page tables 106 * paging_init() sets up the page tables
106 */ 107 */
@@ -163,10 +164,13 @@ void __init paging_init(void)
163 local_flush_tlb(); 164 local_flush_tlb();
164 165
165 { 166 {
166 unsigned long zones_size[MAX_NR_ZONES] = { 0, 0, 0}; 167 unsigned long zones_size[MAX_NR_ZONES];
167 168
169 memset(zones_size, 0, sizeof(zones_size));
168 zones_size[ZONE_DMA] = max_low_pfn; 170 zones_size[ZONE_DMA] = max_low_pfn;
169 free_area_init(zones_size); 171 free_area_init_node(0, &contig_page_data, zones_size,
172 __pa(PAGE_OFFSET) >> PAGE_SHIFT,
173 zholes_size);
170 } 174 }
171 return; 175 return;
172} 176}
@@ -184,9 +188,10 @@ void __init paging_init(void)
184 _KERN_REGION_TABLE; 188 _KERN_REGION_TABLE;
185 static const int ssm_mask = 0x04000000L; 189 static const int ssm_mask = 0x04000000L;
186 190
187 unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0}; 191 unsigned long zones_size[MAX_NR_ZONES];
188 unsigned long dma_pfn, high_pfn; 192 unsigned long dma_pfn, high_pfn;
189 193
194 memset(zones_size, 0, sizeof(zones_size));
190 dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT; 195 dma_pfn = MAX_DMA_ADDRESS >> PAGE_SHIFT;
191 high_pfn = max_low_pfn; 196 high_pfn = max_low_pfn;
192 197
@@ -198,8 +203,8 @@ void __init paging_init(void)
198 } 203 }
199 204
200 /* Initialize mem_map[]. */ 205 /* Initialize mem_map[]. */
201 free_area_init(zones_size); 206 free_area_init_node(0, &contig_page_data, zones_size,
202 207 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
203 208
204 /* 209 /*
205 * map whole physical memory to virtual memory (identity mapping) 210 * map whole physical memory to virtual memory (identity mapping)
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 722ea1d63c94..3468d5127223 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -693,6 +693,10 @@ config RTC_9701JE
693 693
694endmenu 694endmenu
695 695
696config ISA_DMA_API
697 bool
698 depends on MPC1211
699 default y
696 700
697menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)" 701menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
698 702
diff --git a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c
index 1b0dfb4d8ea4..b28919b65682 100644
--- a/arch/sh/kernel/ptrace.c
+++ b/arch/sh/kernel/ptrace.c
@@ -20,6 +20,7 @@
20#include <linux/user.h> 20#include <linux/user.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/security.h> 22#include <linux/security.h>
23#include <linux/signal.h>
23 24
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
@@ -197,7 +198,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
197 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 198 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
198 case PTRACE_CONT: { /* restart after signal. */ 199 case PTRACE_CONT: { /* restart after signal. */
199 ret = -EIO; 200 ret = -EIO;
200 if ((unsigned long) data > _NSIG) 201 if (!valid_signal(data))
201 break; 202 break;
202 if (request == PTRACE_SYSCALL) 203 if (request == PTRACE_SYSCALL)
203 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 204 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -228,7 +229,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
228 struct pt_regs *dummy = NULL; 229 struct pt_regs *dummy = NULL;
229 230
230 ret = -EIO; 231 ret = -EIO;
231 if ((unsigned long) data > _NSIG) 232 if (!valid_signal(data))
232 break; 233 break;
233 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 234 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
234 if ((child->ptrace & PT_DTRACE) == 0) { 235 if ((child->ptrace & PT_DTRACE) == 0) {
diff --git a/arch/sh64/kernel/ptrace.c b/arch/sh64/kernel/ptrace.c
index 800288c1562b..fd2000956dae 100644
--- a/arch/sh64/kernel/ptrace.c
+++ b/arch/sh64/kernel/ptrace.c
@@ -27,6 +27,7 @@
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/ptrace.h> 28#include <linux/ptrace.h>
29#include <linux/user.h> 29#include <linux/user.h>
30#include <linux/signal.h>
30 31
31#include <asm/io.h> 32#include <asm/io.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
@@ -255,7 +256,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
255 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 256 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
256 case PTRACE_CONT: { /* restart after signal. */ 257 case PTRACE_CONT: { /* restart after signal. */
257 ret = -EIO; 258 ret = -EIO;
258 if ((unsigned long) data > _NSIG) 259 if (!valid_signal(data))
259 break; 260 break;
260 if (request == PTRACE_SYSCALL) 261 if (request == PTRACE_SYSCALL)
261 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 262 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
@@ -285,7 +286,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
285 struct pt_regs *regs; 286 struct pt_regs *regs;
286 287
287 ret = -EIO; 288 ret = -EIO;
288 if ((unsigned long) data > _NSIG) 289 if (!valid_signal(data))
289 break; 290 break;
290 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 291 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
291 if ((child->ptrace & PT_DTRACE) == 0) { 292 if ((child->ptrace & PT_DTRACE) == 0) {
diff --git a/arch/sh64/kernel/sys_sh64.c b/arch/sh64/kernel/sys_sh64.c
index 4546845b9caf..58ff7d522d81 100644
--- a/arch/sh64/kernel/sys_sh64.c
+++ b/arch/sh64/kernel/sys_sh64.c
@@ -283,18 +283,3 @@ asmlinkage int sys_uname(struct old_utsname * name)
283 up_read(&uts_sem); 283 up_read(&uts_sem);
284 return err?-EFAULT:0; 284 return err?-EFAULT:0;
285} 285}
286
287/* Copy from mips version */
288asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr,
289 int shmflg)
290{
291 unsigned long raddr;
292 int err;
293
294 err = do_shmat(shmid, shmaddr, shmflg, &raddr);
295 if (err)
296 return err;
297
298 err = raddr;
299 return err;
300}
diff --git a/arch/sh64/kernel/syscalls.S b/arch/sh64/kernel/syscalls.S
index 8ed417df3dc6..6aabc63e4518 100644
--- a/arch/sh64/kernel/syscalls.S
+++ b/arch/sh64/kernel/syscalls.S
@@ -268,7 +268,7 @@ sys_call_table:
268 .long sys_msgrcv 268 .long sys_msgrcv
269 .long sys_msgget 269 .long sys_msgget
270 .long sys_msgctl 270 .long sys_msgctl
271 .long sys_shmatcall 271 .long sys_shmat
272 .long sys_shmdt /* 245 */ 272 .long sys_shmdt /* 245 */
273 .long sys_shmget 273 .long sys_shmget
274 .long sys_shmctl 274 .long sys_shmctl
diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
index 143fe2f3c1c4..2c216ffeea90 100644
--- a/arch/sparc/kernel/process.c
+++ b/arch/sparc/kernel/process.c
@@ -83,9 +83,6 @@ void default_idle(void)
83 */ 83 */
84void cpu_idle(void) 84void cpu_idle(void)
85{ 85{
86 if (current->pid != 0)
87 goto out;
88
89 /* endless idle loop with no priority at all */ 86 /* endless idle loop with no priority at all */
90 for (;;) { 87 for (;;) {
91 if (ARCH_SUN4C_SUN4) { 88 if (ARCH_SUN4C_SUN4) {
@@ -126,8 +123,6 @@ void cpu_idle(void)
126 schedule(); 123 schedule();
127 check_pgt_cache(); 124 check_pgt_cache();
128 } 125 }
129out:
130 return;
131} 126}
132 127
133#else 128#else
@@ -333,6 +328,17 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
333 printk("\n"); 328 printk("\n");
334} 329}
335 330
331void dump_stack(void)
332{
333 unsigned long *ksp;
334
335 __asm__ __volatile__("mov %%fp, %0"
336 : "=r" (ksp));
337 show_stack(current, ksp);
338}
339
340EXPORT_SYMBOL(dump_stack);
341
336/* 342/*
337 * Note: sparc64 has a pretty intricated thread_saved_pc, check it out. 343 * Note: sparc64 has a pretty intricated thread_saved_pc, check it out.
338 */ 344 */
diff --git a/arch/sparc/kernel/ptrace.c b/arch/sparc/kernel/ptrace.c
index c4f93bd2daf2..475c4c13462c 100644
--- a/arch/sparc/kernel/ptrace.c
+++ b/arch/sparc/kernel/ptrace.c
@@ -18,6 +18,7 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
20#include <linux/security.h> 20#include <linux/security.h>
21#include <linux/signal.h>
21 22
22#include <asm/pgtable.h> 23#include <asm/pgtable.h>
23#include <asm/system.h> 24#include <asm/system.h>
@@ -526,7 +527,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
526 addr = 1; 527 addr = 1;
527 528
528 case PTRACE_CONT: { /* restart after signal. */ 529 case PTRACE_CONT: { /* restart after signal. */
529 if (data > _NSIG) { 530 if (!valid_signal(data)) {
530 pt_error_return(regs, EIO); 531 pt_error_return(regs, EIO);
531 goto out_tsk; 532 goto out_tsk;
532 } 533 }
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index f91b0e8d0dc8..1bd430d0ca06 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -20,6 +20,7 @@
20#include <linux/in6.h> 20#include <linux/in6.h>
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/syscalls.h>
23#ifdef CONFIG_PCI 24#ifdef CONFIG_PCI
24#include <linux/pci.h> 25#include <linux/pci.h>
25#endif 26#endif
@@ -89,6 +90,9 @@ extern void ___atomic24_sub(void);
89extern void ___set_bit(void); 90extern void ___set_bit(void);
90extern void ___clear_bit(void); 91extern void ___clear_bit(void);
91extern void ___change_bit(void); 92extern void ___change_bit(void);
93extern void ___rw_read_enter(void);
94extern void ___rw_read_exit(void);
95extern void ___rw_write_enter(void);
92 96
93/* Alias functions whose names begin with "." and export the aliases. 97/* Alias functions whose names begin with "." and export the aliases.
94 * The module references will be fixed up by module_frob_arch_sections. 98 * The module references will be fixed up by module_frob_arch_sections.
@@ -121,9 +125,9 @@ EXPORT_SYMBOL(_do_write_unlock);
121#endif 125#endif
122#else 126#else
123// XXX find what uses (or used) these. 127// XXX find what uses (or used) these.
124// EXPORT_SYMBOL_PRIVATE(_rw_read_enter); 128EXPORT_SYMBOL(___rw_read_enter);
125// EXPORT_SYMBOL_PRIVATE(_rw_read_exit); 129EXPORT_SYMBOL(___rw_read_exit);
126// EXPORT_SYMBOL_PRIVATE(_rw_write_enter); 130EXPORT_SYMBOL(___rw_write_enter);
127#endif 131#endif
128/* semaphores */ 132/* semaphores */
129EXPORT_SYMBOL(__up); 133EXPORT_SYMBOL(__up);
@@ -144,6 +148,9 @@ EXPORT_SYMBOL(___set_bit);
144EXPORT_SYMBOL(___clear_bit); 148EXPORT_SYMBOL(___clear_bit);
145EXPORT_SYMBOL(___change_bit); 149EXPORT_SYMBOL(___change_bit);
146 150
151/* Per-CPU information table */
152EXPORT_PER_CPU_SYMBOL(__cpu_data);
153
147#ifdef CONFIG_SMP 154#ifdef CONFIG_SMP
148/* IRQ implementation. */ 155/* IRQ implementation. */
149EXPORT_SYMBOL(synchronize_irq); 156EXPORT_SYMBOL(synchronize_irq);
@@ -151,6 +158,10 @@ EXPORT_SYMBOL(synchronize_irq);
151/* Misc SMP information */ 158/* Misc SMP information */
152EXPORT_SYMBOL(__cpu_number_map); 159EXPORT_SYMBOL(__cpu_number_map);
153EXPORT_SYMBOL(__cpu_logical_map); 160EXPORT_SYMBOL(__cpu_logical_map);
161
162/* CPU online map and active count. */
163EXPORT_SYMBOL(cpu_online_map);
164EXPORT_SYMBOL(phys_cpu_present_map);
154#endif 165#endif
155 166
156EXPORT_SYMBOL(__udelay); 167EXPORT_SYMBOL(__udelay);
@@ -332,3 +343,6 @@ EXPORT_SYMBOL(do_BUG);
332 343
333/* Sun Power Management Idle Handler */ 344/* Sun Power Management Idle Handler */
334EXPORT_SYMBOL(pm_idle); 345EXPORT_SYMBOL(pm_idle);
346
347/* Binfmt_misc needs this */
348EXPORT_SYMBOL(sys_close);
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c
index 46aa51afec14..c20e5309f8aa 100644
--- a/arch/sparc/prom/memory.c
+++ b/arch/sparc/prom/memory.c
@@ -47,9 +47,9 @@ prom_sortmemlist(struct linux_mlist_v0 *thislist)
47 char *tmpaddr; 47 char *tmpaddr;
48 char *lowest; 48 char *lowest;
49 49
50 for(i=0; thislist[i].theres_more != 0; i++) { 50 for(i=0; thislist[i].theres_more; i++) {
51 lowest = thislist[i].start_adr; 51 lowest = thislist[i].start_adr;
52 for(mitr = i+1; thislist[mitr-1].theres_more != 0; mitr++) 52 for(mitr = i+1; thislist[mitr-1].theres_more; mitr++)
53 if(thislist[mitr].start_adr < lowest) { 53 if(thislist[mitr].start_adr < lowest) {
54 lowest = thislist[mitr].start_adr; 54 lowest = thislist[mitr].start_adr;
55 swapi = mitr; 55 swapi = mitr;
@@ -85,7 +85,7 @@ void __init prom_meminit(void)
85 prom_phys_total[iter].num_bytes = mptr->num_bytes; 85 prom_phys_total[iter].num_bytes = mptr->num_bytes;
86 prom_phys_total[iter].theres_more = &prom_phys_total[iter+1]; 86 prom_phys_total[iter].theres_more = &prom_phys_total[iter+1];
87 } 87 }
88 prom_phys_total[iter-1].theres_more = 0x0; 88 prom_phys_total[iter-1].theres_more = NULL;
89 /* Second, the total prom taken descriptors. */ 89 /* Second, the total prom taken descriptors. */
90 for(mptr = (*(romvec->pv_v0mem.v0_prommap)), iter=0; 90 for(mptr = (*(romvec->pv_v0mem.v0_prommap)), iter=0;
91 mptr; mptr=mptr->theres_more, iter++) { 91 mptr; mptr=mptr->theres_more, iter++) {
@@ -93,7 +93,7 @@ void __init prom_meminit(void)
93 prom_prom_taken[iter].num_bytes = mptr->num_bytes; 93 prom_prom_taken[iter].num_bytes = mptr->num_bytes;
94 prom_prom_taken[iter].theres_more = &prom_prom_taken[iter+1]; 94 prom_prom_taken[iter].theres_more = &prom_prom_taken[iter+1];
95 } 95 }
96 prom_prom_taken[iter-1].theres_more = 0x0; 96 prom_prom_taken[iter-1].theres_more = NULL;
97 /* Last, the available physical descriptors. */ 97 /* Last, the available physical descriptors. */
98 for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0; 98 for(mptr = (*(romvec->pv_v0mem.v0_available)), iter=0;
99 mptr; mptr=mptr->theres_more, iter++) { 99 mptr; mptr=mptr->theres_more, iter++) {
@@ -101,7 +101,7 @@ void __init prom_meminit(void)
101 prom_phys_avail[iter].num_bytes = mptr->num_bytes; 101 prom_phys_avail[iter].num_bytes = mptr->num_bytes;
102 prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1]; 102 prom_phys_avail[iter].theres_more = &prom_phys_avail[iter+1];
103 } 103 }
104 prom_phys_avail[iter-1].theres_more = 0x0; 104 prom_phys_avail[iter-1].theres_more = NULL;
105 /* Sort all the lists. */ 105 /* Sort all the lists. */
106 prom_sortmemlist(prom_phys_total); 106 prom_sortmemlist(prom_phys_total);
107 prom_sortmemlist(prom_prom_taken); 107 prom_sortmemlist(prom_prom_taken);
@@ -124,7 +124,7 @@ void __init prom_meminit(void)
124 prom_phys_avail[iter].theres_more = 124 prom_phys_avail[iter].theres_more =
125 &prom_phys_avail[iter+1]; 125 &prom_phys_avail[iter+1];
126 } 126 }
127 prom_phys_avail[iter-1].theres_more = 0x0; 127 prom_phys_avail[iter-1].theres_more = NULL;
128 128
129 num_regs = prom_getproperty(node, "reg", 129 num_regs = prom_getproperty(node, "reg",
130 (char *) prom_reg_memlist, 130 (char *) prom_reg_memlist,
@@ -138,7 +138,7 @@ void __init prom_meminit(void)
138 prom_phys_total[iter].theres_more = 138 prom_phys_total[iter].theres_more =
139 &prom_phys_total[iter+1]; 139 &prom_phys_total[iter+1];
140 } 140 }
141 prom_phys_total[iter-1].theres_more = 0x0; 141 prom_phys_total[iter-1].theres_more = NULL;
142 142
143 node = prom_getchild(prom_root_node); 143 node = prom_getchild(prom_root_node);
144 node = prom_searchsiblings(node, "virtual-memory"); 144 node = prom_searchsiblings(node, "virtual-memory");
@@ -158,7 +158,7 @@ void __init prom_meminit(void)
158 prom_prom_taken[iter].theres_more = 158 prom_prom_taken[iter].theres_more =
159 &prom_prom_taken[iter+1]; 159 &prom_prom_taken[iter+1];
160 } 160 }
161 prom_prom_taken[iter-1].theres_more = 0x0; 161 prom_prom_taken[iter-1].theres_more = NULL;
162 162
163 prom_sortmemlist(prom_prom_taken); 163 prom_sortmemlist(prom_prom_taken);
164 164
@@ -182,15 +182,15 @@ void __init prom_meminit(void)
182 case PROM_SUN4: 182 case PROM_SUN4:
183#ifdef CONFIG_SUN4 183#ifdef CONFIG_SUN4
184 /* how simple :) */ 184 /* how simple :) */
185 prom_phys_total[0].start_adr = 0x0; 185 prom_phys_total[0].start_adr = NULL;
186 prom_phys_total[0].num_bytes = *(sun4_romvec->memorysize); 186 prom_phys_total[0].num_bytes = *(sun4_romvec->memorysize);
187 prom_phys_total[0].theres_more = 0x0; 187 prom_phys_total[0].theres_more = NULL;
188 prom_prom_taken[0].start_adr = 0x0; 188 prom_prom_taken[0].start_adr = NULL;
189 prom_prom_taken[0].num_bytes = 0x0; 189 prom_prom_taken[0].num_bytes = 0x0;
190 prom_prom_taken[0].theres_more = 0x0; 190 prom_prom_taken[0].theres_more = NULL;
191 prom_phys_avail[0].start_adr = 0x0; 191 prom_phys_avail[0].start_adr = NULL;
192 prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail); 192 prom_phys_avail[0].num_bytes = *(sun4_romvec->memoryavail);
193 prom_phys_avail[0].theres_more = 0x0; 193 prom_phys_avail[0].theres_more = NULL;
194#endif 194#endif
195 break; 195 break;
196 196
diff --git a/arch/sparc/prom/sun4prom.c b/arch/sparc/prom/sun4prom.c
index 69ca735f0d4e..00390a2652aa 100644
--- a/arch/sparc/prom/sun4prom.c
+++ b/arch/sparc/prom/sun4prom.c
@@ -151,7 +151,7 @@ struct linux_romvec * __init sun4_prom_init(void)
151 * have more time, we can teach the penguin to say "By your 151 * have more time, we can teach the penguin to say "By your
152 * command" or "Activating turbo boost, Michael". :-) 152 * command" or "Activating turbo boost, Michael". :-)
153 */ 153 */
154 sun4_romvec->setLEDs(0x0); 154 sun4_romvec->setLEDs(NULL);
155 155
156 printk("PROMLIB: Old Sun4 boot PROM monitor %s, romvec version %d\n", 156 printk("PROMLIB: Old Sun4 boot PROM monitor %s, romvec version %d\n",
157 sun4_romvec->monid, 157 sun4_romvec->monid,
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index fb1189641c74..a72fd15d5ea8 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -118,6 +118,7 @@ config VT_CONSOLE
118 118
119config HW_CONSOLE 119config HW_CONSOLE
120 bool 120 bool
121 depends on VT
121 default y 122 default y
122 123
123config SMP 124config SMP
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index a38cb5036df0..4dcb8af94090 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -756,7 +756,7 @@ void handler_irq(int irq, struct pt_regs *regs)
756 clear_softint(clr_mask); 756 clear_softint(clr_mask);
757 } 757 }
758#else 758#else
759 int should_forward = 1; 759 int should_forward = 0;
760 760
761 clear_softint(1 << irq); 761 clear_softint(1 << irq);
762#endif 762#endif
@@ -1007,10 +1007,10 @@ static int retarget_one_irq(struct irqaction *p, int goal_cpu)
1007 } 1007 }
1008 upa_writel(tid | IMAP_VALID, imap); 1008 upa_writel(tid | IMAP_VALID, imap);
1009 1009
1010 while (!cpu_online(goal_cpu)) { 1010 do {
1011 if (++goal_cpu >= NR_CPUS) 1011 if (++goal_cpu >= NR_CPUS)
1012 goal_cpu = 0; 1012 goal_cpu = 0;
1013 } 1013 } while (!cpu_online(goal_cpu));
1014 1014
1015 return goal_cpu; 1015 return goal_cpu;
1016} 1016}
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 26d3ec41da1c..a0cd2b2494d6 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -62,9 +62,6 @@ void default_idle(void)
62 */ 62 */
63void cpu_idle(void) 63void cpu_idle(void)
64{ 64{
65 if (current->pid != 0)
66 return;
67
68 /* endless idle loop with no priority at all */ 65 /* endless idle loop with no priority at all */
69 for (;;) { 66 for (;;) {
70 /* If current->work.need_resched is zero we should really 67 /* If current->work.need_resched is zero we should really
@@ -80,7 +77,6 @@ void cpu_idle(void)
80 schedule(); 77 schedule();
81 check_pgt_cache(); 78 check_pgt_cache();
82 } 79 }
83 return;
84} 80}
85 81
86#else 82#else
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index 5f080cf04b33..80a76e2ad732 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -19,6 +19,7 @@
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
21#include <linux/security.h> 21#include <linux/security.h>
22#include <linux/signal.h>
22 23
23#include <asm/asi.h> 24#include <asm/asi.h>
24#include <asm/pgtable.h> 25#include <asm/pgtable.h>
@@ -559,7 +560,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
559 addr = 1; 560 addr = 1;
560 561
561 case PTRACE_CONT: { /* restart after signal. */ 562 case PTRACE_CONT: { /* restart after signal. */
562 if (data > _NSIG) { 563 if (!valid_signal(data)) {
563 pt_error_return(regs, EIO); 564 pt_error_return(regs, EIO);
564 goto out_tsk; 565 goto out_tsk;
565 } 566 }
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index cad5a1122800..e78cc53594fa 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -278,7 +278,7 @@ EXPORT_SYMBOL(verify_compat_iovec);
278 278
279EXPORT_SYMBOL(dump_thread); 279EXPORT_SYMBOL(dump_thread);
280EXPORT_SYMBOL(dump_fpu); 280EXPORT_SYMBOL(dump_fpu);
281EXPORT_SYMBOL(__pte_alloc_one_kernel); 281EXPORT_SYMBOL(pte_alloc_one_kernel);
282#ifndef CONFIG_SMP 282#ifndef CONFIG_SMP
283EXPORT_SYMBOL(pgt_quicklists); 283EXPORT_SYMBOL(pgt_quicklists);
284#endif 284#endif
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 6a717d4d2bc5..71b4e3807694 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -48,7 +48,7 @@
48 48
49DEFINE_SPINLOCK(mostek_lock); 49DEFINE_SPINLOCK(mostek_lock);
50DEFINE_SPINLOCK(rtc_lock); 50DEFINE_SPINLOCK(rtc_lock);
51unsigned long mstk48t02_regs = 0UL; 51void __iomem *mstk48t02_regs = NULL;
52#ifdef CONFIG_PCI 52#ifdef CONFIG_PCI
53unsigned long ds1287_regs = 0UL; 53unsigned long ds1287_regs = 0UL;
54#endif 54#endif
@@ -59,8 +59,8 @@ u64 jiffies_64 = INITIAL_JIFFIES;
59 59
60EXPORT_SYMBOL(jiffies_64); 60EXPORT_SYMBOL(jiffies_64);
61 61
62static unsigned long mstk48t08_regs = 0UL; 62static void __iomem *mstk48t08_regs;
63static unsigned long mstk48t59_regs = 0UL; 63static void __iomem *mstk48t59_regs;
64 64
65static int set_rtc_mmss(unsigned long); 65static int set_rtc_mmss(unsigned long);
66 66
@@ -520,7 +520,7 @@ void timer_tick_interrupt(struct pt_regs *regs)
520/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ 520/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */
521static void __init kick_start_clock(void) 521static void __init kick_start_clock(void)
522{ 522{
523 unsigned long regs = mstk48t02_regs; 523 void __iomem *regs = mstk48t02_regs;
524 u8 sec, tmp; 524 u8 sec, tmp;
525 int i, count; 525 int i, count;
526 526
@@ -604,7 +604,7 @@ static void __init kick_start_clock(void)
604/* Return nonzero if the clock chip battery is low. */ 604/* Return nonzero if the clock chip battery is low. */
605static int __init has_low_battery(void) 605static int __init has_low_battery(void)
606{ 606{
607 unsigned long regs = mstk48t02_regs; 607 void __iomem *regs = mstk48t02_regs;
608 u8 data1, data2; 608 u8 data1, data2;
609 609
610 spin_lock_irq(&mostek_lock); 610 spin_lock_irq(&mostek_lock);
@@ -623,7 +623,7 @@ static int __init has_low_battery(void)
623static void __init set_system_time(void) 623static void __init set_system_time(void)
624{ 624{
625 unsigned int year, mon, day, hour, min, sec; 625 unsigned int year, mon, day, hour, min, sec;
626 unsigned long mregs = mstk48t02_regs; 626 void __iomem *mregs = mstk48t02_regs;
627#ifdef CONFIG_PCI 627#ifdef CONFIG_PCI
628 unsigned long dregs = ds1287_regs; 628 unsigned long dregs = ds1287_regs;
629#else 629#else
@@ -843,7 +843,8 @@ void __init clock_probe(void)
843 !strcmp(model, "m5823")) { 843 !strcmp(model, "m5823")) {
844 ds1287_regs = edev->resource[0].start; 844 ds1287_regs = edev->resource[0].start;
845 } else { 845 } else {
846 mstk48t59_regs = edev->resource[0].start; 846 mstk48t59_regs = (void __iomem *)
847 edev->resource[0].start;
847 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; 848 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02;
848 } 849 }
849 break; 850 break;
@@ -865,7 +866,8 @@ try_isa_clock:
865 !strcmp(model, "m5823")) { 866 !strcmp(model, "m5823")) {
866 ds1287_regs = isadev->resource.start; 867 ds1287_regs = isadev->resource.start;
867 } else { 868 } else {
868 mstk48t59_regs = isadev->resource.start; 869 mstk48t59_regs = (void __iomem *)
870 isadev->resource.start;
869 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; 871 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02;
870 } 872 }
871 break; 873 break;
@@ -893,21 +895,24 @@ try_isa_clock:
893 } 895 }
894 896
895 if(model[5] == '0' && model[6] == '2') { 897 if(model[5] == '0' && model[6] == '2') {
896 mstk48t02_regs = (((u64)clk_reg[0].phys_addr) | 898 mstk48t02_regs = (void __iomem *)
897 (((u64)clk_reg[0].which_io)<<32UL)); 899 (((u64)clk_reg[0].phys_addr) |
900 (((u64)clk_reg[0].which_io)<<32UL));
898 } else if(model[5] == '0' && model[6] == '8') { 901 } else if(model[5] == '0' && model[6] == '8') {
899 mstk48t08_regs = (((u64)clk_reg[0].phys_addr) | 902 mstk48t08_regs = (void __iomem *)
900 (((u64)clk_reg[0].which_io)<<32UL)); 903 (((u64)clk_reg[0].phys_addr) |
904 (((u64)clk_reg[0].which_io)<<32UL));
901 mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02; 905 mstk48t02_regs = mstk48t08_regs + MOSTEK_48T08_48T02;
902 } else { 906 } else {
903 mstk48t59_regs = (((u64)clk_reg[0].phys_addr) | 907 mstk48t59_regs = (void __iomem *)
904 (((u64)clk_reg[0].which_io)<<32UL)); 908 (((u64)clk_reg[0].phys_addr) |
909 (((u64)clk_reg[0].which_io)<<32UL));
905 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02; 910 mstk48t02_regs = mstk48t59_regs + MOSTEK_48T59_48T02;
906 } 911 }
907 break; 912 break;
908 } 913 }
909 914
910 if (mstk48t02_regs != 0UL) { 915 if (mstk48t02_regs != NULL) {
911 /* Report a low battery voltage condition. */ 916 /* Report a low battery voltage condition. */
912 if (has_low_battery()) 917 if (has_low_battery())
913 prom_printf("NVRAM: Low battery voltage!\n"); 918 prom_printf("NVRAM: Low battery voltage!\n");
@@ -1087,7 +1092,7 @@ unsigned long long sched_clock(void)
1087static int set_rtc_mmss(unsigned long nowtime) 1092static int set_rtc_mmss(unsigned long nowtime)
1088{ 1093{
1089 int real_seconds, real_minutes, chip_minutes; 1094 int real_seconds, real_minutes, chip_minutes;
1090 unsigned long mregs = mstk48t02_regs; 1095 void __iomem *mregs = mstk48t02_regs;
1091#ifdef CONFIG_PCI 1096#ifdef CONFIG_PCI
1092 unsigned long dregs = ds1287_regs; 1097 unsigned long dregs = ds1287_regs;
1093#else 1098#else
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index db6fa77b4dab..9c5222075da9 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -1114,7 +1114,7 @@ struct pgtable_cache_struct pgt_quicklists;
1114#else 1114#else
1115#define DC_ALIAS_SHIFT 0 1115#define DC_ALIAS_SHIFT 0
1116#endif 1116#endif
1117pte_t *__pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 1117pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
1118{ 1118{
1119 struct page *page; 1119 struct page *page;
1120 unsigned long color; 1120 unsigned long color;
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 9a23df182123..c5292181a664 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -244,6 +244,7 @@ config KERNEL_HALF_GIGS
244 244
245config HIGHMEM 245config HIGHMEM
246 bool "Highmem support" 246 bool "Highmem support"
247 depends on !64BIT
247 248
248config KERNEL_STACK_ORDER 249config KERNEL_STACK_ORDER
249 int "Kernel stack size order" 250 int "Kernel stack size order"
diff --git a/arch/um/Kconfig_i386 b/arch/um/Kconfig_i386
index 203c242201b6..e41f3748d30f 100644
--- a/arch/um/Kconfig_i386
+++ b/arch/um/Kconfig_i386
@@ -1,4 +1,8 @@
1config 64_BIT 1config UML_X86
2 bool
3 default y
4
5config 64BIT
2 bool 6 bool
3 default n 7 default n
4 8
diff --git a/arch/um/Kconfig_x86_64 b/arch/um/Kconfig_x86_64
index 768dc6626a8d..fd8d7e8982b1 100644
--- a/arch/um/Kconfig_x86_64
+++ b/arch/um/Kconfig_x86_64
@@ -1,4 +1,8 @@
1config 64_BIT 1config UML_X86
2 bool
3 default y
4
5config 64BIT
2 bool 6 bool
3 default y 7 default y
4 8
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 97bca6b5ca95..f2a0c40a9204 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -17,7 +17,7 @@ core-y += $(ARCH_DIR)/kernel/ \
17 17
18# Have to precede the include because the included Makefiles reference them. 18# Have to precede the include because the included Makefiles reference them.
19SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ 19SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \
20 arch-signal.h module.h vm-flags.h 20 module.h vm-flags.h elf.h
21SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) 21SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
22 22
23# XXX: The "os" symlink is only used by arch/um/include/os.h, which includes 23# XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
@@ -44,6 +44,11 @@ ifneq ($(MAKEFILES-INCL),)
44endif 44endif
45 45
46ARCH_INCLUDE := -I$(ARCH_DIR)/include 46ARCH_INCLUDE := -I$(ARCH_DIR)/include
47ifneq ($(KBUILD_SRC),)
48ARCH_INCLUDE += -I$(ARCH_DIR)/include2
49ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include
50MRPROPER_DIRS += $(ARCH_DIR)/include2
51endif
47SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) 52SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
48 53
49include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) 54include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
@@ -94,17 +99,18 @@ define archhelp
94 echo ' find in the kernel root.' 99 echo ' find in the kernel root.'
95endef 100endef
96 101
102ifneq ($(KBUILD_SRC),)
103$(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig_$(SUBARCH) $(ARCH_DIR)/Kconfig_arch)
104CLEAN_FILES += $(ARCH_DIR)/Kconfig_arch
105else
97$(shell cd $(ARCH_DIR) && ln -sf Kconfig_$(SUBARCH) Kconfig_arch) 106$(shell cd $(ARCH_DIR) && ln -sf Kconfig_$(SUBARCH) Kconfig_arch)
107endif
98 108
99prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) \ 109prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
100 $(ARCH_DIR)/kernel/vmlinux.lds.S
101 110
102LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 111LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
103LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib 112LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
104 113
105LD_SCRIPT-$(CONFIG_LD_SCRIPT_STATIC) := uml.lds.S
106LD_SCRIPT-$(CONFIG_LD_SCRIPT_DYN) := dyn.lds.S
107
108CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT 114CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT
109CONFIG_KERNEL_STACK_ORDER ?= 2 115CONFIG_KERNEL_STACK_ORDER ?= 2
110STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) 116STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
@@ -126,7 +132,7 @@ define cmd_vmlinux__
126 $(CC) $(CFLAGS_vmlinux) -o $@ \ 132 $(CC) $(CFLAGS_vmlinux) -o $@ \
127 -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ 133 -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
128 -Wl,--start-group $(vmlinux-main) -Wl,--end-group \ 134 -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
129 -L/usr/lib -lutil \ 135 -lutil \
130 $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \ 136 $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \
131 FORCE ,$^) ; rm -f linux 137 FORCE ,$^) ; rm -f linux
132endef 138endef
@@ -145,31 +151,42 @@ archclean:
145 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 151 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
146 -o -name '*.gcov' \) -type f -print | xargs rm -f 152 -o -name '*.gcov' \) -type f -print | xargs rm -f
147 153
148#We need to re-preprocess this when the symlink dest changes.
149#So we touch it when needed.
150$(ARCH_DIR)/kernel/vmlinux.lds.S: FORCE
151 $(Q)if [ "$(shell readlink $@)" != "$(LD_SCRIPT-y)" ]; then \
152 echo ' SYMLINK $@'; \
153 ln -sf $(LD_SCRIPT-y) $@; \
154 touch $@; \
155 fi;
156
157$(SYMLINK_HEADERS): 154$(SYMLINK_HEADERS):
158 @echo ' SYMLINK $@' 155 @echo ' SYMLINK $@'
156ifneq ($(KBUILD_SRC),)
157 ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
158else
159 $(Q)cd $(TOPDIR)/$(dir $@) ; \ 159 $(Q)cd $(TOPDIR)/$(dir $@) ; \
160 ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@) 160 ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
161endif
161 162
162include/asm-um/arch: 163include/asm-um/arch:
163 @echo ' SYMLINK $@' 164 @echo ' SYMLINK $@'
165ifneq ($(KBUILD_SRC),)
166 $(Q)mkdir -p include/asm-um
167 $(Q)ln -fsn $(srctree)/include/asm-$(SUBARCH) include/asm-um/arch
168else
164 $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch 169 $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
170endif
165 171
166$(ARCH_DIR)/include/sysdep: 172$(ARCH_DIR)/include/sysdep:
167 @echo ' SYMLINK $@' 173 @echo ' SYMLINK $@'
174ifneq ($(KBUILD_SRC),)
175 $(Q)mkdir -p $(ARCH_DIR)/include
176 $(Q)mkdir -p $(ARCH_DIR)/include2
177 $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
178 $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep
179else
168 $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep 180 $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
181endif
169 182
170$(ARCH_DIR)/os: 183$(ARCH_DIR)/os:
171 @echo ' SYMLINK $@' 184 @echo ' SYMLINK $@'
185ifneq ($(KBUILD_SRC),)
186 $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $(ARCH_DIR)/os
187else
172 $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os 188 $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os
189endif
173 190
174# Generated files 191# Generated files
175define filechk_umlconfig 192define filechk_umlconfig
@@ -179,10 +196,31 @@ endef
179$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h 196$(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
180 $(call filechk,umlconfig) 197 $(call filechk,umlconfig)
181 198
199$(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c
200 $(CC) $(USER_CFLAGS) -S -o $@ $<
201
202$(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s
203 $(call filechk,gen-asm-offsets)
204
205CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h
206
207$(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \
208 $(ARCH_SYMLINKS) \
209 $(SYS_DIR)/sc.h \
210 include/asm include/linux/version.h \
211 include/config/MARKER \
212 $(ARCH_DIR)/include/user_constants.h
213 $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $<
214
215$(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s
216 $(call filechk,gen-asm-offsets)
217
218CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h
219
182$(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task 220$(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task
183 $(call filechk,gen_header) 221 $(call filechk,gen_header)
184 222
185$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os/util/mk_user_constants 223$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants
186 $(call filechk,gen_header) 224 $(call filechk,gen_header)
187 225
188$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants 226$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
@@ -191,20 +229,20 @@ $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
191$(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs 229$(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs
192 $(call filechk,gen_header) 230 $(call filechk,gen_header)
193 231
194$(ARCH_DIR)/os/util/mk_user_constants: $(ARCH_DIR)/os/util FORCE ; 232$(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ;
195 233
196$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ 234$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \
197 FORCE ; 235 FORCE ;
198 236
199$(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; 237$(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ;
200 238
201$(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h FORCE 239$(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE
202 $(Q)$(MAKE) $(build)=$@ 240 $(Q)$(MAKE) $(build)=$@
203 241
204$(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE 242$(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
205 $(Q)$(MAKE) $(build)=$@ 243 $(Q)$(MAKE) $(build)=$@
206 244
207$(ARCH_DIR)/os/util: scripts_basic FORCE 245$(ARCH_DIR)/os-$(OS)/util: scripts_basic FORCE
208 $(Q)$(MAKE) $(build)=$@ 246 $(Q)$(MAKE) $(build)=$@
209 247
210export SUBARCH USER_CFLAGS OS 248export SUBARCH USER_CFLAGS OS
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index 97b223bfa78e..29e182d5a83a 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -1,4 +1,4 @@
1SUBARCH_CORE := arch/um/sys-i386/ 1SUBARCH_CORE := arch/um/sys-i386/ arch/i386/crypto/
2 2
3TOP_ADDR := $(CONFIG_TOP_ADDR) 3TOP_ADDR := $(CONFIG_TOP_ADDR)
4 4
@@ -32,10 +32,10 @@ $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
32$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread 32$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread
33 $(call filechk,gen_header) 33 $(call filechk,gen_header)
34 34
35$(SYS_UTIL_DIR)/mk_sc: scripts_basic FORCE 35$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
36 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ 36 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
37 37
38$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_SYMLINKS) $(GEN_HEADERS) FORCE 38$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE
39 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ 39 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
40 40
41$(SYS_UTIL_DIR): scripts_basic include/asm FORCE 41$(SYS_UTIL_DIR): scripts_basic include/asm FORCE
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index a77971133e91..32144562c279 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -23,10 +23,10 @@ $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
23$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread 23$(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread
24 $(call filechk,gen_header) 24 $(call filechk,gen_header)
25 25
26$(SYS_UTIL_DIR)/mk_sc: scripts_basic FORCE 26$(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE
27 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ 27 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
28 28
29$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_SYMLINKS) $(GEN_HEADERS) FORCE 29$(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE
30 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ 30 $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@
31 31
32CLEAN_FILES += $(SYS_HEADERS) 32CLEAN_FILES += $(SYS_HEADERS)
diff --git a/arch/um/defconfig b/arch/um/defconfig
index fc3075c589d8..4067c3aa5b60 100644
--- a/arch/um/defconfig
+++ b/arch/um/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.12-rc1-bk1 3# Linux kernel version: 2.6.12-rc3-skas3-v9-pre2
4# Sun Mar 20 16:53:00 2005 4# Sun Apr 24 19:46:10 2005
5# 5#
6CONFIG_GENERIC_HARDIRQS=y 6CONFIG_GENERIC_HARDIRQS=y
7CONFIG_UML=y 7CONFIG_UML=y
@@ -15,7 +15,8 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
15# 15#
16CONFIG_MODE_TT=y 16CONFIG_MODE_TT=y
17CONFIG_MODE_SKAS=y 17CONFIG_MODE_SKAS=y
18# CONFIG_64_BIT is not set 18CONFIG_UML_X86=y
19# CONFIG_64BIT is not set
19CONFIG_TOP_ADDR=0xc0000000 20CONFIG_TOP_ADDR=0xc0000000
20# CONFIG_3_LEVEL_PGTABLES is not set 21# CONFIG_3_LEVEL_PGTABLES is not set
21CONFIG_ARCH_HAS_SC_SIGNALS=y 22CONFIG_ARCH_HAS_SC_SIGNALS=y
@@ -41,6 +42,7 @@ CONFIG_UML_REAL_TIME_CLOCK=y
41CONFIG_EXPERIMENTAL=y 42CONFIG_EXPERIMENTAL=y
42CONFIG_CLEAN_COMPILE=y 43CONFIG_CLEAN_COMPILE=y
43CONFIG_BROKEN_ON_SMP=y 44CONFIG_BROKEN_ON_SMP=y
45CONFIG_INIT_ENV_ARG_LIMIT=32
44 46
45# 47#
46# General setup 48# General setup
@@ -158,7 +160,6 @@ CONFIG_UML_NET_SLIRP=y
158# 160#
159CONFIG_PACKET=y 161CONFIG_PACKET=y
160CONFIG_PACKET_MMAP=y 162CONFIG_PACKET_MMAP=y
161# CONFIG_NETLINK_DEV is not set
162CONFIG_UNIX=y 163CONFIG_UNIX=y
163# CONFIG_NET_KEY is not set 164# CONFIG_NET_KEY is not set
164CONFIG_INET=y 165CONFIG_INET=y
@@ -412,6 +413,5 @@ CONFIG_DEBUG_INFO=y
412# CONFIG_DEBUG_FS is not set 413# CONFIG_DEBUG_FS is not set
413CONFIG_FRAME_POINTER=y 414CONFIG_FRAME_POINTER=y
414CONFIG_PT_PROXY=y 415CONFIG_PT_PROXY=y
415# CONFIG_GPROF is not set
416# CONFIG_GCOV is not set 416# CONFIG_GCOV is not set
417# CONFIG_SYSCALL_DEBUG is not set 417# CONFIG_SYSCALL_DEBUG is not set
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 1f77deb3fd23..0150038af795 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -22,7 +22,7 @@
22#ifdef CONFIG_NOCONFIG_CHAN 22#ifdef CONFIG_NOCONFIG_CHAN
23static void *not_configged_init(char *str, int device, struct chan_opts *opts) 23static void *not_configged_init(char *str, int device, struct chan_opts *opts)
24{ 24{
25 printk(KERN_ERR "Using a channel type which is configured out of " 25 printf(KERN_ERR "Using a channel type which is configured out of "
26 "UML\n"); 26 "UML\n");
27 return(NULL); 27 return(NULL);
28} 28}
@@ -30,27 +30,27 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts)
30static int not_configged_open(int input, int output, int primary, void *data, 30static int not_configged_open(int input, int output, int primary, void *data,
31 char **dev_out) 31 char **dev_out)
32{ 32{
33 printk(KERN_ERR "Using a channel type which is configured out of " 33 printf(KERN_ERR "Using a channel type which is configured out of "
34 "UML\n"); 34 "UML\n");
35 return(-ENODEV); 35 return(-ENODEV);
36} 36}
37 37
38static void not_configged_close(int fd, void *data) 38static void not_configged_close(int fd, void *data)
39{ 39{
40 printk(KERN_ERR "Using a channel type which is configured out of " 40 printf(KERN_ERR "Using a channel type which is configured out of "
41 "UML\n"); 41 "UML\n");
42} 42}
43 43
44static int not_configged_read(int fd, char *c_out, void *data) 44static int not_configged_read(int fd, char *c_out, void *data)
45{ 45{
46 printk(KERN_ERR "Using a channel type which is configured out of " 46 printf(KERN_ERR "Using a channel type which is configured out of "
47 "UML\n"); 47 "UML\n");
48 return(-EIO); 48 return(-EIO);
49} 49}
50 50
51static int not_configged_write(int fd, const char *buf, int len, void *data) 51static int not_configged_write(int fd, const char *buf, int len, void *data)
52{ 52{
53 printk(KERN_ERR "Using a channel type which is configured out of " 53 printf(KERN_ERR "Using a channel type which is configured out of "
54 "UML\n"); 54 "UML\n");
55 return(-EIO); 55 return(-EIO);
56} 56}
@@ -58,7 +58,7 @@ static int not_configged_write(int fd, const char *buf, int len, void *data)
58static int not_configged_console_write(int fd, const char *buf, int len, 58static int not_configged_console_write(int fd, const char *buf, int len,
59 void *data) 59 void *data)
60{ 60{
61 printk(KERN_ERR "Using a channel type which is configured out of " 61 printf(KERN_ERR "Using a channel type which is configured out of "
62 "UML\n"); 62 "UML\n");
63 return(-EIO); 63 return(-EIO);
64} 64}
@@ -66,14 +66,14 @@ static int not_configged_console_write(int fd, const char *buf, int len,
66static int not_configged_window_size(int fd, void *data, unsigned short *rows, 66static int not_configged_window_size(int fd, void *data, unsigned short *rows,
67 unsigned short *cols) 67 unsigned short *cols)
68{ 68{
69 printk(KERN_ERR "Using a channel type which is configured out of " 69 printf(KERN_ERR "Using a channel type which is configured out of "
70 "UML\n"); 70 "UML\n");
71 return(-ENODEV); 71 return(-ENODEV);
72} 72}
73 73
74static void not_configged_free(void *data) 74static void not_configged_free(void *data)
75{ 75{
76 printk(KERN_ERR "Using a channel type which is configured out of " 76 printf(KERN_ERR "Using a channel type which is configured out of "
77 "UML\n"); 77 "UML\n");
78} 78}
79 79
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 6924f273ced9..025d3be8aca4 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -39,19 +39,69 @@ static void line_timer_cb(void *arg)
39 line_interrupt(line->driver->read_irq, arg, NULL); 39 line_interrupt(line->driver->read_irq, arg, NULL);
40} 40}
41 41
42static int write_room(struct line *dev) 42/* Returns the free space inside the ring buffer of this line.
43 *
44 * Should be called while holding line->lock (this does not modify datas).
45 */
46static int write_room(struct line *line)
43{ 47{
44 int n; 48 int n;
45 49
46 if (dev->buffer == NULL) 50 if (line->buffer == NULL)
47 return (LINE_BUFSIZE - 1); 51 return LINE_BUFSIZE - 1;
52
53 /* This is for the case where the buffer is wrapped! */
54 n = line->head - line->tail;
48 55
49 n = dev->head - dev->tail;
50 if (n <= 0) 56 if (n <= 0)
51 n = LINE_BUFSIZE + n; 57 n = LINE_BUFSIZE + n; /* The other case */
52 return (n - 1); 58 return n - 1;
59}
60
61int line_write_room(struct tty_struct *tty)
62{
63 struct line *line = tty->driver_data;
64 unsigned long flags;
65 int room;
66
67 if (tty->stopped)
68 return 0;
69
70 spin_lock_irqsave(&line->lock, flags);
71 room = write_room(line);
72 spin_unlock_irqrestore(&line->lock, flags);
73
74 /*XXX: Warning to remove */
75 if (0 == room)
76 printk(KERN_DEBUG "%s: %s: no room left in buffer\n",
77 __FUNCTION__,tty->name);
78 return room;
79}
80
81int line_chars_in_buffer(struct tty_struct *tty)
82{
83 struct line *line = tty->driver_data;
84 unsigned long flags;
85 int ret;
86
87 spin_lock_irqsave(&line->lock, flags);
88
89 /*write_room subtracts 1 for the needed NULL, so we readd it.*/
90 ret = LINE_BUFSIZE - (write_room(line) + 1);
91 spin_unlock_irqrestore(&line->lock, flags);
92
93 return ret;
53} 94}
54 95
96/*
97 * This copies the content of buf into the circular buffer associated with
98 * this line.
99 * The return value is the number of characters actually copied, i.e. the ones
100 * for which there was space: this function is not supposed to ever flush out
101 * the circular buffer.
102 *
103 * Must be called while holding line->lock!
104 */
55static int buffer_data(struct line *line, const char *buf, int len) 105static int buffer_data(struct line *line, const char *buf, int len)
56{ 106{
57 int end, room; 107 int end, room;
@@ -70,48 +120,95 @@ static int buffer_data(struct line *line, const char *buf, int len)
70 len = (len > room) ? room : len; 120 len = (len > room) ? room : len;
71 121
72 end = line->buffer + LINE_BUFSIZE - line->tail; 122 end = line->buffer + LINE_BUFSIZE - line->tail;
73 if(len < end){ 123
124 if (len < end){
74 memcpy(line->tail, buf, len); 125 memcpy(line->tail, buf, len);
75 line->tail += len; 126 line->tail += len;
76 } 127 } else {
77 else { 128 /* The circular buffer is wrapping */
78 memcpy(line->tail, buf, end); 129 memcpy(line->tail, buf, end);
79 buf += end; 130 buf += end;
80 memcpy(line->buffer, buf, len - end); 131 memcpy(line->buffer, buf, len - end);
81 line->tail = line->buffer + len - end; 132 line->tail = line->buffer + len - end;
82 } 133 }
83 134
84 return(len); 135 return len;
85} 136}
86 137
138/*
139 * Flushes the ring buffer to the output channels. That is, write_chan is
140 * called, passing it line->head as buffer, and an appropriate count.
141 *
142 * On exit, returns 1 when the buffer is empty,
143 * 0 when the buffer is not empty on exit,
144 * and -errno when an error occurred.
145 *
146 * Must be called while holding line->lock!*/
87static int flush_buffer(struct line *line) 147static int flush_buffer(struct line *line)
88{ 148{
89 int n, count; 149 int n, count;
90 150
91 if ((line->buffer == NULL) || (line->head == line->tail)) 151 if ((line->buffer == NULL) || (line->head == line->tail))
92 return(1); 152 return 1;
93 153
94 if (line->tail < line->head) { 154 if (line->tail < line->head) {
155 /* line->buffer + LINE_BUFSIZE is the end of the buffer! */
95 count = line->buffer + LINE_BUFSIZE - line->head; 156 count = line->buffer + LINE_BUFSIZE - line->head;
157
96 n = write_chan(&line->chan_list, line->head, count, 158 n = write_chan(&line->chan_list, line->head, count,
97 line->driver->write_irq); 159 line->driver->write_irq);
98 if (n < 0) 160 if (n < 0)
99 return(n); 161 return n;
100 if (n == count) 162 if (n == count) {
163 /* We have flushed from ->head to buffer end, now we
164 * must flush only from the beginning to ->tail.*/
101 line->head = line->buffer; 165 line->head = line->buffer;
102 else { 166 } else {
103 line->head += n; 167 line->head += n;
104 return(0); 168 return 0;
105 } 169 }
106 } 170 }
107 171
108 count = line->tail - line->head; 172 count = line->tail - line->head;
109 n = write_chan(&line->chan_list, line->head, count, 173 n = write_chan(&line->chan_list, line->head, count,
110 line->driver->write_irq); 174 line->driver->write_irq);
111 if(n < 0) return(n); 175
176 if(n < 0)
177 return n;
112 178
113 line->head += n; 179 line->head += n;
114 return(line->head == line->tail); 180 return line->head == line->tail;
181}
182
183void line_flush_buffer(struct tty_struct *tty)
184{
185 struct line *line = tty->driver_data;
186 unsigned long flags;
187 int err;
188
189 /*XXX: copied from line_write, verify if it is correct!*/
190 if(tty->stopped)
191 return;
192 //return 0;
193
194 spin_lock_irqsave(&line->lock, flags);
195 err = flush_buffer(line);
196 /*if (err == 1)
197 err = 0;*/
198 spin_unlock_irqrestore(&line->lock, flags);
199 //return err;
200}
201
202/* We map both ->flush_chars and ->put_char (which go in pair) onto ->flush_buffer
203 * and ->write. Hope it's not that bad.*/
204void line_flush_chars(struct tty_struct *tty)
205{
206 line_flush_buffer(tty);
207}
208
209void line_put_char(struct tty_struct *tty, unsigned char ch)
210{
211 line_write(tty, &ch, sizeof(ch));
115} 212}
116 213
117int line_write(struct tty_struct *tty, const unsigned char *buf, int len) 214int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
@@ -120,38 +217,31 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
120 unsigned long flags; 217 unsigned long flags;
121 int n, err, ret = 0; 218 int n, err, ret = 0;
122 219
123 if(tty->stopped) return 0; 220 if(tty->stopped)
221 return 0;
124 222
125 down(&line->sem); 223 spin_lock_irqsave(&line->lock, flags);
126 if(line->head != line->tail){ 224 if (line->head != line->tail) {
127 local_irq_save(flags);
128 ret = buffer_data(line, buf, len); 225 ret = buffer_data(line, buf, len);
129 err = flush_buffer(line); 226 err = flush_buffer(line);
130 local_irq_restore(flags); 227 if (err <= 0 && (err != -EAGAIN || !ret))
131 if(err <= 0 && (err != -EAGAIN || !ret))
132 ret = err; 228 ret = err;
133 } 229 } else {
134 else {
135 n = write_chan(&line->chan_list, buf, len, 230 n = write_chan(&line->chan_list, buf, len,
136 line->driver->write_irq); 231 line->driver->write_irq);
137 if(n < 0){ 232 if (n < 0) {
138 ret = n; 233 ret = n;
139 goto out_up; 234 goto out_up;
140 } 235 }
141 236
142 len -= n; 237 len -= n;
143 ret += n; 238 ret += n;
144 if(len > 0) 239 if (len > 0)
145 ret += buffer_data(line, buf + n, len); 240 ret += buffer_data(line, buf + n, len);
146 } 241 }
147 out_up: 242out_up:
148 up(&line->sem); 243 spin_unlock_irqrestore(&line->lock, flags);
149 return(ret); 244 return ret;
150}
151
152void line_put_char(struct tty_struct *tty, unsigned char ch)
153{
154 line_write(tty, &ch, sizeof(ch));
155} 245}
156 246
157void line_set_termios(struct tty_struct *tty, struct termios * old) 247void line_set_termios(struct tty_struct *tty, struct termios * old)
@@ -159,11 +249,6 @@ void line_set_termios(struct tty_struct *tty, struct termios * old)
159 /* nothing */ 249 /* nothing */
160} 250}
161 251
162int line_chars_in_buffer(struct tty_struct *tty)
163{
164 return 0;
165}
166
167static struct { 252static struct {
168 int cmd; 253 int cmd;
169 char *level; 254 char *level;
@@ -250,7 +335,7 @@ int line_ioctl(struct tty_struct *tty, struct file * file,
250 ret = -ENOIOCTLCMD; 335 ret = -ENOIOCTLCMD;
251 break; 336 break;
252 } 337 }
253 return(ret); 338 return ret;
254} 339}
255 340
256static irqreturn_t line_write_interrupt(int irq, void *data, 341static irqreturn_t line_write_interrupt(int irq, void *data,
@@ -260,18 +345,23 @@ static irqreturn_t line_write_interrupt(int irq, void *data,
260 struct line *line = tty->driver_data; 345 struct line *line = tty->driver_data;
261 int err; 346 int err;
262 347
348 /* Interrupts are enabled here because we registered the interrupt with
349 * SA_INTERRUPT (see line_setup_irq).*/
350
351 spin_lock_irq(&line->lock);
263 err = flush_buffer(line); 352 err = flush_buffer(line);
264 if(err == 0) 353 if (err == 0) {
265 return(IRQ_NONE); 354 return IRQ_NONE;
266 else if(err < 0){ 355 } else if(err < 0) {
267 line->head = line->buffer; 356 line->head = line->buffer;
268 line->tail = line->buffer; 357 line->tail = line->buffer;
269 } 358 }
359 spin_unlock_irq(&line->lock);
270 360
271 if(tty == NULL) 361 if(tty == NULL)
272 return(IRQ_NONE); 362 return IRQ_NONE;
273 363
274 if(test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && 364 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
275 (tty->ldisc.write_wakeup != NULL)) 365 (tty->ldisc.write_wakeup != NULL))
276 (tty->ldisc.write_wakeup)(tty); 366 (tty->ldisc.write_wakeup)(tty);
277 367
@@ -281,9 +371,9 @@ static irqreturn_t line_write_interrupt(int irq, void *data,
281 * writes. 371 * writes.
282 */ 372 */
283 373
284 if(waitqueue_active(&tty->write_wait)) 374 if (waitqueue_active(&tty->write_wait))
285 wake_up_interruptible(&tty->write_wait); 375 wake_up_interruptible(&tty->write_wait);
286 return(IRQ_HANDLED); 376 return IRQ_HANDLED;
287} 377}
288 378
289int line_setup_irq(int fd, int input, int output, struct tty_struct *tty) 379int line_setup_irq(int fd, int input, int output, struct tty_struct *tty)
@@ -292,15 +382,18 @@ int line_setup_irq(int fd, int input, int output, struct tty_struct *tty)
292 struct line_driver *driver = line->driver; 382 struct line_driver *driver = line->driver;
293 int err = 0, flags = SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM; 383 int err = 0, flags = SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM;
294 384
295 if(input) err = um_request_irq(driver->read_irq, fd, IRQ_READ, 385 if (input)
386 err = um_request_irq(driver->read_irq, fd, IRQ_READ,
296 line_interrupt, flags, 387 line_interrupt, flags,
297 driver->read_irq_name, tty); 388 driver->read_irq_name, tty);
298 if(err) return(err); 389 if (err)
299 if(output) err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, 390 return err;
391 if (output)
392 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE,
300 line_write_interrupt, flags, 393 line_write_interrupt, flags,
301 driver->write_irq_name, tty); 394 driver->write_irq_name, tty);
302 line->have_irq = 1; 395 line->have_irq = 1;
303 return(err); 396 return err;
304} 397}
305 398
306void line_disable(struct tty_struct *tty, int current_irq) 399void line_disable(struct tty_struct *tty, int current_irq)
@@ -336,7 +429,9 @@ int line_open(struct line *lines, struct tty_struct *tty,
336 line = &lines[tty->index]; 429 line = &lines[tty->index];
337 tty->driver_data = line; 430 tty->driver_data = line;
338 431
339 down(&line->sem); 432 /* The IRQ which takes this lock is not yet enabled and won't be run
433 * before the end, so we don't need to use spin_lock_irq.*/
434 spin_lock(&line->lock);
340 if (tty->count == 1) { 435 if (tty->count == 1) {
341 if (!line->valid) { 436 if (!line->valid) {
342 err = -ENODEV; 437 err = -ENODEV;
@@ -349,6 +444,7 @@ int line_open(struct line *lines, struct tty_struct *tty,
349 err = open_chan(&line->chan_list); 444 err = open_chan(&line->chan_list);
350 if(err) goto out; 445 if(err) goto out;
351 } 446 }
447 /* Here the interrupt is registered.*/
352 enable_chan(&line->chan_list, tty); 448 enable_chan(&line->chan_list, tty);
353 INIT_WORK(&line->task, line_timer_cb, tty); 449 INIT_WORK(&line->task, line_timer_cb, tty);
354 } 450 }
@@ -362,21 +458,36 @@ int line_open(struct line *lines, struct tty_struct *tty,
362 line->count++; 458 line->count++;
363 459
364out: 460out:
365 up(&line->sem); 461 spin_unlock(&line->lock);
366 return(err); 462 return err;
367} 463}
368 464
465static void unregister_winch(struct tty_struct *tty);
466
369void line_close(struct tty_struct *tty, struct file * filp) 467void line_close(struct tty_struct *tty, struct file * filp)
370{ 468{
371 struct line *line = tty->driver_data; 469 struct line *line = tty->driver_data;
372 470
373 down(&line->sem); 471 /* XXX: I assume this should be called in process context, not with
472 * interrupts disabled!
473 */
474 spin_lock_irq(&line->lock);
475
476 /* We ignore the error anyway! */
477 flush_buffer(line);
478
374 line->count--; 479 line->count--;
375 if (tty->count == 1) { 480 if (tty->count == 1) {
376 line_disable(tty, -1); 481 line_disable(tty, -1);
377 tty->driver_data = NULL; 482 tty->driver_data = NULL;
378 } 483 }
379 up(&line->sem); 484
485 if((line->count == 0) && line->sigio){
486 unregister_winch(tty);
487 line->sigio = 0;
488 }
489
490 spin_unlock_irq(&line->lock);
380} 491}
381 492
382void close_lines(struct line *lines, int nlines) 493void close_lines(struct line *lines, int nlines)
@@ -387,31 +498,41 @@ void close_lines(struct line *lines, int nlines)
387 close_chan(&lines[i].chan_list); 498 close_chan(&lines[i].chan_list);
388} 499}
389 500
390int line_setup(struct line *lines, int num, char *init, int all_allowed) 501/* Common setup code for both startup command line and mconsole initialization.
502 * @lines contains the the array (of size @num) to modify;
503 * @init is the setup string;
504 * @all_allowed is a boolean saying if we can setup the whole @lines
505 * at once. For instance, it will be usually true for startup init. (where we
506 * can use con=xterm) and false for mconsole.*/
507
508int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed)
391{ 509{
392 int i, n; 510 int i, n;
393 char *end; 511 char *end;
394 512
395 if(*init == '=') n = -1; 513 if(*init == '=') {
396 else { 514 /* We said con=/ssl= instead of con#=, so we are configuring all
515 * consoles at once.*/
516 n = -1;
517 } else {
397 n = simple_strtoul(init, &end, 0); 518 n = simple_strtoul(init, &end, 0);
398 if(*end != '='){ 519 if(*end != '='){
399 printk(KERN_ERR "line_setup failed to parse \"%s\"\n", 520 printk(KERN_ERR "line_setup failed to parse \"%s\"\n",
400 init); 521 init);
401 return(0); 522 return 0;
402 } 523 }
403 init = end; 524 init = end;
404 } 525 }
405 init++; 526 init++;
406 if((n >= 0) && (n >= num)){ 527
528 if (n >= (signed int) num) {
407 printk("line_setup - %d out of range ((0 ... %d) allowed)\n", 529 printk("line_setup - %d out of range ((0 ... %d) allowed)\n",
408 n, num - 1); 530 n, num - 1);
409 return(0); 531 return 0;
410 } 532 } else if (n >= 0){
411 else if (n >= 0){
412 if (lines[n].count > 0) { 533 if (lines[n].count > 0) {
413 printk("line_setup - device %d is open\n", n); 534 printk("line_setup - device %d is open\n", n);
414 return(0); 535 return 0;
415 } 536 }
416 if (lines[n].init_pri <= INIT_ONE){ 537 if (lines[n].init_pri <= INIT_ONE){
417 lines[n].init_pri = INIT_ONE; 538 lines[n].init_pri = INIT_ONE;
@@ -422,13 +543,11 @@ int line_setup(struct line *lines, int num, char *init, int all_allowed)
422 lines[n].valid = 1; 543 lines[n].valid = 1;
423 } 544 }
424 } 545 }
425 } 546 } else if(!all_allowed){
426 else if(!all_allowed){
427 printk("line_setup - can't configure all devices from " 547 printk("line_setup - can't configure all devices from "
428 "mconsole\n"); 548 "mconsole\n");
429 return(0); 549 return 0;
430 } 550 } else {
431 else {
432 for(i = 0; i < num; i++){ 551 for(i = 0; i < num; i++){
433 if(lines[i].init_pri <= INIT_ALL){ 552 if(lines[i].init_pri <= INIT_ALL){
434 lines[i].init_pri = INIT_ALL; 553 lines[i].init_pri = INIT_ALL;
@@ -440,21 +559,21 @@ int line_setup(struct line *lines, int num, char *init, int all_allowed)
440 } 559 }
441 } 560 }
442 } 561 }
443 return(1); 562 return 1;
444} 563}
445 564
446int line_config(struct line *lines, int num, char *str) 565int line_config(struct line *lines, unsigned int num, char *str)
447{ 566{
448 char *new = uml_strdup(str); 567 char *new = uml_strdup(str);
449 568
450 if(new == NULL){ 569 if(new == NULL){
451 printk("line_config - uml_strdup failed\n"); 570 printk("line_config - uml_strdup failed\n");
452 return(-ENOMEM); 571 return -ENOMEM;
453 } 572 }
454 return(!line_setup(lines, num, new, 0)); 573 return !line_setup(lines, num, new, 0);
455} 574}
456 575
457int line_get_config(char *name, struct line *lines, int num, char *str, 576int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
458 int size, char **error_out) 577 int size, char **error_out)
459{ 578{
460 struct line *line; 579 struct line *line;
@@ -464,47 +583,33 @@ int line_get_config(char *name, struct line *lines, int num, char *str,
464 dev = simple_strtoul(name, &end, 0); 583 dev = simple_strtoul(name, &end, 0);
465 if((*end != '\0') || (end == name)){ 584 if((*end != '\0') || (end == name)){
466 *error_out = "line_get_config failed to parse device number"; 585 *error_out = "line_get_config failed to parse device number";
467 return(0); 586 return 0;
468 } 587 }
469 588
470 if((dev < 0) || (dev >= num)){ 589 if((dev < 0) || (dev >= num)){
471 *error_out = "device number of of range"; 590 *error_out = "device number out of range";
472 return(0); 591 return 0;
473 } 592 }
474 593
475 line = &lines[dev]; 594 line = &lines[dev];
476 595
477 down(&line->sem); 596 spin_lock(&line->lock);
478 if(!line->valid) 597 if(!line->valid)
479 CONFIG_CHUNK(str, size, n, "none", 1); 598 CONFIG_CHUNK(str, size, n, "none", 1);
480 else if(line->count == 0) 599 else if(line->count == 0)
481 CONFIG_CHUNK(str, size, n, line->init_str, 1); 600 CONFIG_CHUNK(str, size, n, line->init_str, 1);
482 else n = chan_config_string(&line->chan_list, str, size, error_out); 601 else n = chan_config_string(&line->chan_list, str, size, error_out);
483 up(&line->sem); 602 spin_unlock(&line->lock);
484 603
485 return(n); 604 return n;
486} 605}
487 606
488int line_remove(struct line *lines, int num, char *str) 607int line_remove(struct line *lines, unsigned int num, char *str)
489{ 608{
490 char config[sizeof("conxxxx=none\0")]; 609 char config[sizeof("conxxxx=none\0")];
491 610
492 sprintf(config, "%s=none", str); 611 sprintf(config, "%s=none", str);
493 return(!line_setup(lines, num, config, 0)); 612 return !line_setup(lines, num, config, 0);
494}
495
496int line_write_room(struct tty_struct *tty)
497{
498 struct line *dev = tty->driver_data;
499 int room;
500
501 if (tty->stopped)
502 return 0;
503 room = write_room(dev);
504 if (0 == room)
505 printk(KERN_DEBUG "%s: %s: no room left in buffer\n",
506 __FUNCTION__,tty->name);
507 return room;
508} 613}
509 614
510struct tty_driver *line_register_devfs(struct lines *set, 615struct tty_driver *line_register_devfs(struct lines *set,
@@ -553,7 +658,7 @@ void lines_init(struct line *lines, int nlines)
553 for(i = 0; i < nlines; i++){ 658 for(i = 0; i < nlines; i++){
554 line = &lines[i]; 659 line = &lines[i];
555 INIT_LIST_HEAD(&line->chan_list); 660 INIT_LIST_HEAD(&line->chan_list);
556 sema_init(&line->sem, 1); 661 spin_lock_init(&line->lock);
557 if(line->init_str != NULL){ 662 if(line->init_str != NULL){
558 line->init_str = uml_strdup(line->init_str); 663 line->init_str = uml_strdup(line->init_str);
559 if(line->init_str == NULL) 664 if(line->init_str == NULL)
@@ -587,7 +692,7 @@ irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
587 "errno = %d\n", -err); 692 "errno = %d\n", -err);
588 printk("fd %d is losing SIGWINCH support\n", 693 printk("fd %d is losing SIGWINCH support\n",
589 winch->tty_fd); 694 winch->tty_fd);
590 return(IRQ_HANDLED); 695 return IRQ_HANDLED;
591 } 696 }
592 goto out; 697 goto out;
593 } 698 }
@@ -603,7 +708,7 @@ irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
603 out: 708 out:
604 if(winch->fd != -1) 709 if(winch->fd != -1)
605 reactivate_fd(winch->fd, WINCH_IRQ); 710 reactivate_fd(winch->fd, WINCH_IRQ);
606 return(IRQ_HANDLED); 711 return IRQ_HANDLED;
607} 712}
608 713
609DECLARE_MUTEX(winch_handler_sem); 714DECLARE_MUTEX(winch_handler_sem);
@@ -625,7 +730,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty)
625 .pid = pid, 730 .pid = pid,
626 .tty = tty }); 731 .tty = tty });
627 list_add(&winch->list, &winch_handlers); 732 list_add(&winch->list, &winch_handlers);
628 if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, 733 if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
629 SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, 734 SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
630 "winch", winch) < 0) 735 "winch", winch) < 0)
631 printk("register_winch_irq - failed to register IRQ\n"); 736 printk("register_winch_irq - failed to register IRQ\n");
@@ -633,6 +738,34 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty)
633 up(&winch_handler_sem); 738 up(&winch_handler_sem);
634} 739}
635 740
741static void unregister_winch(struct tty_struct *tty)
742{
743 struct list_head *ele;
744 struct winch *winch, *found = NULL;
745
746 down(&winch_handler_sem);
747 list_for_each(ele, &winch_handlers){
748 winch = list_entry(ele, struct winch, list);
749 if(winch->tty == tty){
750 found = winch;
751 break;
752 }
753 }
754
755 if(found == NULL)
756 goto out;
757
758 if(winch->pid != -1)
759 os_kill_process(winch->pid, 1);
760
761 free_irq_by_irq_and_dev(WINCH_IRQ, winch);
762 free_irq(WINCH_IRQ, winch);
763 list_del(&winch->list);
764 kfree(winch);
765 out:
766 up(&winch_handler_sem);
767}
768
636static void winch_cleanup(void) 769static void winch_cleanup(void)
637{ 770{
638 struct list_head *ele; 771 struct list_head *ele;
@@ -656,26 +789,16 @@ char *add_xterm_umid(char *base)
656 int len; 789 int len;
657 790
658 umid = get_umid(1); 791 umid = get_umid(1);
659 if(umid == NULL) return(base); 792 if(umid == NULL)
793 return base;
660 794
661 len = strlen(base) + strlen(" ()") + strlen(umid) + 1; 795 len = strlen(base) + strlen(" ()") + strlen(umid) + 1;
662 title = kmalloc(len, GFP_KERNEL); 796 title = kmalloc(len, GFP_KERNEL);
663 if(title == NULL){ 797 if(title == NULL){
664 printk("Failed to allocate buffer for xterm title\n"); 798 printk("Failed to allocate buffer for xterm title\n");
665 return(base); 799 return base;
666 } 800 }
667 801
668 snprintf(title, len, "%s (%s)", base, umid); 802 snprintf(title, len, "%s (%s)", base, umid);
669 return(title); 803 return title;
670} 804}
671
672/*
673 * Overrides for Emacs so that we follow Linus's tabbing style.
674 * Emacs will notice this stuff at the end of the file and automatically
675 * adjust the settings for this buffer only. This must remain at the end
676 * of the file.
677 * ---------------------------------------------------------------------------
678 * Local variables:
679 * c-file-style: "linux"
680 * End:
681 */
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index c5839c3141f8..a2bac429f3d4 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -107,11 +107,6 @@ int ssl_open(struct tty_struct *tty, struct file *filp)
107} 107}
108 108
109#if 0 109#if 0
110static int ssl_chars_in_buffer(struct tty_struct *tty)
111{
112 return(0);
113}
114
115static void ssl_flush_buffer(struct tty_struct *tty) 110static void ssl_flush_buffer(struct tty_struct *tty)
116{ 111{
117 return; 112 return;
@@ -149,11 +144,11 @@ static struct tty_operations ssl_ops = {
149 .put_char = line_put_char, 144 .put_char = line_put_char,
150 .write_room = line_write_room, 145 .write_room = line_write_room,
151 .chars_in_buffer = line_chars_in_buffer, 146 .chars_in_buffer = line_chars_in_buffer,
147 .flush_buffer = line_flush_buffer,
148 .flush_chars = line_flush_chars,
152 .set_termios = line_set_termios, 149 .set_termios = line_set_termios,
153 .ioctl = line_ioctl, 150 .ioctl = line_ioctl,
154#if 0 151#if 0
155 .flush_chars = ssl_flush_chars,
156 .flush_buffer = ssl_flush_buffer,
157 .throttle = ssl_throttle, 152 .throttle = ssl_throttle,
158 .unthrottle = ssl_unthrottle, 153 .unthrottle = ssl_unthrottle,
159 .stop = ssl_stop, 154 .stop = ssl_stop,
@@ -171,10 +166,11 @@ static void ssl_console_write(struct console *c, const char *string,
171 unsigned len) 166 unsigned len)
172{ 167{
173 struct line *line = &serial_lines[c->index]; 168 struct line *line = &serial_lines[c->index];
169 unsigned long flags;
174 170
175 down(&line->sem); 171 spin_lock_irqsave(&line->lock, flags);
176 console_write_chan(&line->chan_list, string, len); 172 console_write_chan(&line->chan_list, string, len);
177 up(&line->sem); 173 spin_unlock_irqrestore(&line->lock, flags);
178} 174}
179 175
180static struct tty_driver *ssl_console_device(struct console *c, int *index) 176static struct tty_driver *ssl_console_device(struct console *c, int *index)
@@ -238,14 +234,3 @@ static int ssl_chan_setup(char *str)
238 234
239__setup("ssl", ssl_chan_setup); 235__setup("ssl", ssl_chan_setup);
240__channel_help(ssl_chan_setup, "ssl"); 236__channel_help(ssl_chan_setup, "ssl");
241
242/*
243 * Overrides for Emacs so that we follow Linus's tabbing style.
244 * Emacs will notice this stuff at the end of the file and automatically
245 * adjust the settings for this buffer only. This must remain at the end
246 * of the file.
247 * ---------------------------------------------------------------------------
248 * Local variables:
249 * c-file-style: "linux"
250 * End:
251 */
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index e604d7c87695..361d0be342b3 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -116,8 +116,11 @@ static struct tty_operations console_ops = {
116 .open = con_open, 116 .open = con_open,
117 .close = line_close, 117 .close = line_close,
118 .write = line_write, 118 .write = line_write,
119 .put_char = line_put_char,
119 .write_room = line_write_room, 120 .write_room = line_write_room,
120 .chars_in_buffer = line_chars_in_buffer, 121 .chars_in_buffer = line_chars_in_buffer,
122 .flush_buffer = line_flush_buffer,
123 .flush_chars = line_flush_chars,
121 .set_termios = line_set_termios, 124 .set_termios = line_set_termios,
122 .ioctl = line_ioctl, 125 .ioctl = line_ioctl,
123}; 126};
@@ -126,10 +129,11 @@ static void uml_console_write(struct console *console, const char *string,
126 unsigned len) 129 unsigned len)
127{ 130{
128 struct line *line = &vts[console->index]; 131 struct line *line = &vts[console->index];
132 unsigned long flags;
129 133
130 down(&line->sem); 134 spin_lock_irqsave(&line->lock, flags);
131 console_write_chan(&line->chan_list, string, len); 135 console_write_chan(&line->chan_list, string, len);
132 up(&line->sem); 136 spin_unlock_irqrestore(&line->lock, flags);
133} 137}
134 138
135static struct tty_driver *uml_console_device(struct console *c, int *index) 139static struct tty_driver *uml_console_device(struct console *c, int *index)
@@ -192,14 +196,3 @@ static int console_chan_setup(char *str)
192} 196}
193__setup("con", console_chan_setup); 197__setup("con", console_chan_setup);
194__channel_help(console_chan_setup, "con"); 198__channel_help(console_chan_setup, "con");
195
196/*
197 * Overrides for Emacs so that we follow Linus's tabbing style.
198 * Emacs will notice this stuff at the end of the file and automatically
199 * adjust the settings for this buffer only. This must remain at the end
200 * of the file.
201 * ---------------------------------------------------------------------------
202 * Local variables:
203 * c-file-style: "linux"
204 * End:
205 */
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 4d8b165bfa48..9a56ff94308d 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -156,6 +156,7 @@ static struct gendisk *fake_gendisk[MAX_DEV];
156static struct openflags global_openflags = OPEN_FLAGS; 156static struct openflags global_openflags = OPEN_FLAGS;
157 157
158struct cow { 158struct cow {
159 /* This is the backing file, actually */
159 char *file; 160 char *file;
160 int fd; 161 int fd;
161 unsigned long *bitmap; 162 unsigned long *bitmap;
@@ -927,10 +928,14 @@ static int ubd_open(struct inode *inode, struct file *filp)
927 } 928 }
928 } 929 }
929 dev->count++; 930 dev->count++;
930 if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){ 931 set_disk_ro(disk, !dev->openflags.w);
932
933 /* This should no more be needed. And it didn't work anyway to exclude
934 * read-write remounting of filesystems.*/
935 /*if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){
931 if(--dev->count == 0) ubd_close(dev); 936 if(--dev->count == 0) ubd_close(dev);
932 err = -EROFS; 937 err = -EROFS;
933 } 938 }*/
934 out: 939 out:
935 return(err); 940 return(err);
936} 941}
@@ -1096,6 +1101,7 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
1096 1101
1097 if(req->rq_status == RQ_INACTIVE) return(1); 1102 if(req->rq_status == RQ_INACTIVE) return(1);
1098 1103
1104 /* This should be impossible now */
1099 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ 1105 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
1100 printk("Write attempted on readonly ubd device %s\n", 1106 printk("Write attempted on readonly ubd device %s\n",
1101 disk->disk_name); 1107 disk->disk_name);
@@ -1243,6 +1249,7 @@ static int ubd_check_remapped(int fd, unsigned long address, int is_write,
1243 1249
1244 /* It's a write to a ubd device */ 1250 /* It's a write to a ubd device */
1245 1251
1252 /* This should be impossible now */
1246 if(!dev->openflags.w){ 1253 if(!dev->openflags.w){
1247 /* It's a write access on a read-only device - probably 1254 /* It's a write access on a read-only device - probably
1248 * shouldn't happen. If the kernel is trying to change 1255 * shouldn't happen. If the kernel is trying to change
@@ -1605,8 +1612,7 @@ void do_io(struct io_thread_req *req)
1605 } 1612 }
1606 } while((n < len) && (n != 0)); 1613 } while((n < len) && (n != 0));
1607 if (n < len) memset(&buf[n], 0, len - n); 1614 if (n < len) memset(&buf[n], 0, len - n);
1608 } 1615 } else {
1609 else {
1610 n = os_write_file(req->fds[bit], buf, len); 1616 n = os_write_file(req->fds[bit], buf, len);
1611 if(n != len){ 1617 if(n != len){
1612 printk("do_io - write failed err = %d " 1618 printk("do_io - write failed err = %d "
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c
index 7917b9d1cec8..a4fdf3584ad2 100644
--- a/arch/um/drivers/xterm_kern.c
+++ b/arch/um/drivers/xterm_kern.c
@@ -7,7 +7,6 @@
7#include "linux/slab.h" 7#include "linux/slab.h"
8#include "linux/signal.h" 8#include "linux/signal.h"
9#include "linux/interrupt.h" 9#include "linux/interrupt.h"
10#include "asm/semaphore.h"
11#include "asm/irq.h" 10#include "asm/irq.h"
12#include "irq_user.h" 11#include "irq_user.h"
13#include "irq_kern.h" 12#include "irq_kern.h"
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h
new file mode 100644
index 000000000000..d705daa2d854
--- /dev/null
+++ b/arch/um/include/common-offsets.h
@@ -0,0 +1,14 @@
1/* for use by sys-$SUBARCH/kernel-offsets.c */
2
3OFFSET(TASK_REGS, task_struct, thread.regs);
4OFFSET(TASK_PID, task_struct, pid);
5DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
6DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC);
7DEFINE_STR(UM_KERN_EMERG, KERN_EMERG);
8DEFINE_STR(UM_KERN_ALERT, KERN_ALERT);
9DEFINE_STR(UM_KERN_CRIT, KERN_CRIT);
10DEFINE_STR(UM_KERN_ERR, KERN_ERR);
11DEFINE_STR(UM_KERN_WARNING, KERN_WARNING);
12DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE);
13DEFINE_STR(UM_KERN_INFO, KERN_INFO);
14DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 15389c886b41..e5fec5570199 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -8,6 +8,7 @@
8 8
9#include "linux/threads.h" 9#include "linux/threads.h"
10#include "sysdep/ptrace.h" 10#include "sysdep/ptrace.h"
11#include "sysdep/faultinfo.h"
11 12
12extern int ncpus; 13extern int ncpus;
13extern char *linux_prog; 14extern char *linux_prog;
@@ -31,8 +32,8 @@ extern int current_pid(void);
31extern unsigned long alloc_stack(int order, int atomic); 32extern unsigned long alloc_stack(int order, int atomic);
32extern int do_signal(void); 33extern int do_signal(void);
33extern int is_stack_fault(unsigned long sp); 34extern int is_stack_fault(unsigned long sp);
34extern unsigned long segv(unsigned long address, unsigned long ip, 35extern unsigned long segv(struct faultinfo fi, unsigned long ip,
35 int is_write, int is_user, void *sc); 36 int is_user, void *sc);
36extern int handle_page_fault(unsigned long address, unsigned long ip, 37extern int handle_page_fault(unsigned long address, unsigned long ip,
37 int is_write, int is_user, int *code_out); 38 int is_write, int is_user, int *code_out);
38extern void syscall_ready(void); 39extern void syscall_ready(void);
@@ -82,7 +83,7 @@ extern void timer_irq(union uml_pt_regs *regs);
82extern void unprotect_stack(unsigned long stack); 83extern void unprotect_stack(unsigned long stack);
83extern void do_uml_exitcalls(void); 84extern void do_uml_exitcalls(void);
84extern int attach_debugger(int idle_pid, int pid, int stop); 85extern int attach_debugger(int idle_pid, int pid, int stop);
85extern void bad_segv(unsigned long address, unsigned long ip, int is_write); 86extern void bad_segv(struct faultinfo fi, unsigned long ip);
86extern int config_gdb(char *str); 87extern int config_gdb(char *str);
87extern int remove_gdb(void); 88extern int remove_gdb(void);
88extern char *uml_strdup(char *string); 89extern char *uml_strdup(char *string);
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 6d81ecc17be5..4c5e92c04ccb 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -10,7 +10,7 @@
10#include "linux/workqueue.h" 10#include "linux/workqueue.h"
11#include "linux/tty.h" 11#include "linux/tty.h"
12#include "linux/interrupt.h" 12#include "linux/interrupt.h"
13#include "asm/semaphore.h" 13#include "linux/spinlock.h"
14#include "chan_user.h" 14#include "chan_user.h"
15#include "mconsole_kern.h" 15#include "mconsole_kern.h"
16 16
@@ -37,10 +37,18 @@ struct line {
37 struct list_head chan_list; 37 struct list_head chan_list;
38 int valid; 38 int valid;
39 int count; 39 int count;
40 struct semaphore sem; 40 /*This lock is actually, mostly, local to*/
41 spinlock_t lock;
42
43 /* Yes, this is a real circular buffer.
44 * XXX: And this should become a struct kfifo!
45 *
46 * buffer points to a buffer allocated on demand, of length
47 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
41 char *buffer; 48 char *buffer;
42 char *head; 49 char *head;
43 char *tail; 50 char *tail;
51
44 int sigio; 52 int sigio;
45 struct work_struct task; 53 struct work_struct task;
46 struct line_driver *driver; 54 struct line_driver *driver;
@@ -52,7 +60,6 @@ struct line {
52 init_pri : INIT_STATIC, \ 60 init_pri : INIT_STATIC, \
53 chan_list : { }, \ 61 chan_list : { }, \
54 valid : 1, \ 62 valid : 1, \
55 sem : { }, \
56 buffer : NULL, \ 63 buffer : NULL, \
57 head : NULL, \ 64 head : NULL, \
58 tail : NULL, \ 65 tail : NULL, \
@@ -69,15 +76,18 @@ struct lines {
69extern void line_close(struct tty_struct *tty, struct file * filp); 76extern void line_close(struct tty_struct *tty, struct file * filp);
70extern int line_open(struct line *lines, struct tty_struct *tty, 77extern int line_open(struct line *lines, struct tty_struct *tty,
71 struct chan_opts *opts); 78 struct chan_opts *opts);
72extern int line_setup(struct line *lines, int num, char *init, 79extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init,
73 int all_allowed); 80 int all_allowed);
74extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len); 81extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len);
75extern void line_put_char(struct tty_struct *tty, unsigned char ch); 82extern void line_put_char(struct tty_struct *tty, unsigned char ch);
76extern void line_set_termios(struct tty_struct *tty, struct termios * old); 83extern void line_set_termios(struct tty_struct *tty, struct termios * old);
77extern int line_chars_in_buffer(struct tty_struct *tty); 84extern int line_chars_in_buffer(struct tty_struct *tty);
85extern void line_flush_buffer(struct tty_struct *tty);
86extern void line_flush_chars(struct tty_struct *tty);
78extern int line_write_room(struct tty_struct *tty); 87extern int line_write_room(struct tty_struct *tty);
79extern int line_ioctl(struct tty_struct *tty, struct file * file, 88extern int line_ioctl(struct tty_struct *tty, struct file * file,
80 unsigned int cmd, unsigned long arg); 89 unsigned int cmd, unsigned long arg);
90
81extern char *add_xterm_umid(char *base); 91extern char *add_xterm_umid(char *base);
82extern int line_setup_irq(int fd, int input, int output, struct tty_struct *tty); 92extern int line_setup_irq(int fd, int input, int output, struct tty_struct *tty);
83extern void line_close_chan(struct line *line); 93extern void line_close_chan(struct line *line);
@@ -89,20 +99,10 @@ extern struct tty_driver * line_register_devfs(struct lines *set,
89 int nlines); 99 int nlines);
90extern void lines_init(struct line *lines, int nlines); 100extern void lines_init(struct line *lines, int nlines);
91extern void close_lines(struct line *lines, int nlines); 101extern void close_lines(struct line *lines, int nlines);
92extern int line_config(struct line *lines, int num, char *str); 102
93extern int line_remove(struct line *lines, int num, char *str); 103extern int line_config(struct line *lines, unsigned int sizeof_lines, char *str);
94extern int line_get_config(char *dev, struct line *lines, int num, char *str, 104extern int line_remove(struct line *lines, unsigned int sizeof_lines, char *str);
105extern int line_get_config(char *dev, struct line *lines, unsigned int sizeof_lines, char *str,
95 int size, char **error_out); 106 int size, char **error_out);
96 107
97#endif 108#endif
98
99/*
100 * Overrides for Emacs so that we follow Linus's tabbing style.
101 * Emacs will notice this stuff at the end of the file and automatically
102 * adjust the settings for this buffer only. This must remain at the end
103 * of the file.
104 * ---------------------------------------------------------------------------
105 * Local variables:
106 * c-file-style: "linux"
107 * End:
108 */
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 07340c8cf203..d246d5a24609 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -160,6 +160,7 @@ extern void os_kill_process(int pid, int reap_child);
160extern void os_kill_ptraced_process(int pid, int reap_child); 160extern void os_kill_ptraced_process(int pid, int reap_child);
161extern void os_usr1_process(int pid); 161extern void os_usr1_process(int pid);
162extern int os_getpid(void); 162extern int os_getpid(void);
163extern int os_getpgrp(void);
163 164
164extern int os_map_memory(void *virt, int fd, unsigned long long off, 165extern int os_map_memory(void *virt, int fd, unsigned long long off,
165 unsigned long len, int r, int w, int x); 166 unsigned long len, int r, int w, int x);
diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h
index cfb5fb4f5b91..cd2327d09c8d 100644
--- a/arch/um/include/skas_ptrace.h
+++ b/arch/um/include/skas_ptrace.h
@@ -6,22 +6,11 @@
6#ifndef __SKAS_PTRACE_H 6#ifndef __SKAS_PTRACE_H
7#define __SKAS_PTRACE_H 7#define __SKAS_PTRACE_H
8 8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_FAULTINFO 52 9#define PTRACE_FAULTINFO 52
21#define PTRACE_SIGPENDING 53
22#define PTRACE_LDT 54
23#define PTRACE_SWITCH_MM 55 10#define PTRACE_SWITCH_MM 55
24 11
12#include "sysdep/skas_ptrace.h"
13
25#endif 14#endif
26 15
27/* 16/*
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h
index 3a2a45811aa3..764ba4db4788 100644
--- a/arch/um/include/sysdep-i386/checksum.h
+++ b/arch/um/include/sysdep-i386/checksum.h
@@ -24,19 +24,6 @@ unsigned int csum_partial(const unsigned char * buff, int len,
24 unsigned int sum); 24 unsigned int sum);
25 25
26/* 26/*
27 * the same as csum_partial, but copies from src while it
28 * checksums, and handles user-space pointer exceptions correctly, when needed.
29 *
30 * here even more important to align src and dst on a 32-bit (or even
31 * better 64-bit) boundary
32 */
33
34unsigned int csum_partial_copy_to(const unsigned char *src, unsigned char *dst,
35 int len, int sum, int *err_ptr);
36unsigned int csum_partial_copy_from(const unsigned char *src, unsigned char *dst,
37 int len, int sum, int *err_ptr);
38
39/*
40 * Note: when you get a NULL pointer exception here this means someone 27 * Note: when you get a NULL pointer exception here this means someone
41 * passed in an incorrect kernel address to one of these functions. 28 * passed in an incorrect kernel address to one of these functions.
42 * 29 *
@@ -52,11 +39,24 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
52 return(csum_partial(dst, len, sum)); 39 return(csum_partial(dst, len, sum));
53} 40}
54 41
42/*
43 * the same as csum_partial, but copies from src while it
44 * checksums, and handles user-space pointer exceptions correctly, when needed.
45 *
46 * here even more important to align src and dst on a 32-bit (or even
47 * better 64-bit) boundary
48 */
49
55static __inline__ 50static __inline__
56unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, 51unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
57 int len, int sum, int *err_ptr) 52 int len, int sum, int *err_ptr)
58{ 53{
59 return csum_partial_copy_from(src, dst, len, sum, err_ptr); 54 if(copy_from_user(dst, src, len)){
55 *err_ptr = -EFAULT;
56 return(-1);
57 }
58
59 return csum_partial(dst, len, sum);
60} 60}
61 61
62/* 62/*
@@ -67,7 +67,6 @@ unsigned int csum_partial_copy_from_user(const unsigned char *src, unsigned char
67 */ 67 */
68 68
69#define csum_partial_copy_fromuser csum_partial_copy_from_user 69#define csum_partial_copy_fromuser csum_partial_copy_from_user
70unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum);
71 70
72/* 71/*
73 * This is a version of ip_compute_csum() optimized for IP headers, 72 * This is a version of ip_compute_csum() optimized for IP headers,
@@ -196,8 +195,14 @@ static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
196 unsigned char *dst, 195 unsigned char *dst,
197 int len, int sum, int *err_ptr) 196 int len, int sum, int *err_ptr)
198{ 197{
199 if (access_ok(VERIFY_WRITE, dst, len)) 198 if (access_ok(VERIFY_WRITE, dst, len)){
200 return(csum_partial_copy_to(src, dst, len, sum, err_ptr)); 199 if(copy_to_user(dst, src, len)){
200 *err_ptr = -EFAULT;
201 return(-1);
202 }
203
204 return csum_partial(src, len, sum);
205 }
201 206
202 if (len) 207 if (len)
203 *err_ptr = -EFAULT; 208 *err_ptr = -EFAULT;
diff --git a/arch/um/include/sysdep-i386/faultinfo.h b/arch/um/include/sysdep-i386/faultinfo.h
new file mode 100644
index 000000000000..db437cc373bc
--- /dev/null
+++ b/arch/um/include/sysdep-i386/faultinfo.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
4 * Licensed under the GPL
5 */
6
7#ifndef __FAULTINFO_I386_H
8#define __FAULTINFO_I386_H
9
10/* this structure contains the full arch-specific faultinfo
11 * from the traps.
12 * On i386, ptrace_faultinfo unfortunately doesn't provide
13 * all the info, since trap_no is missing.
14 * All common elements are defined at the same position in
15 * both structures, thus making it easy to copy the
16 * contents without knowledge about the structure elements.
17 */
18struct faultinfo {
19 int error_code; /* in ptrace_faultinfo misleadingly called is_write */
20 unsigned long cr2; /* in ptrace_faultinfo called addr */
21 int trap_no; /* missing in ptrace_faultinfo */
22};
23
24#define FAULT_WRITE(fi) ((fi).error_code & 2)
25#define FAULT_ADDRESS(fi) ((fi).cr2)
26
27#define PTRACE_FULL_FAULTINFO 0
28
29#endif
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
index 661d495e2044..84ec7ff5cf8c 100644
--- a/arch/um/include/sysdep-i386/ptrace.h
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -31,6 +31,7 @@ extern int sysemu_supported;
31#ifdef UML_CONFIG_MODE_SKAS 31#ifdef UML_CONFIG_MODE_SKAS
32 32
33#include "skas_ptregs.h" 33#include "skas_ptregs.h"
34#include "sysdep/faultinfo.h"
34 35
35#define REGS_IP(r) ((r)[HOST_IP]) 36#define REGS_IP(r) ((r)[HOST_IP])
36#define REGS_SP(r) ((r)[HOST_SP]) 37#define REGS_SP(r) ((r)[HOST_SP])
@@ -53,12 +54,6 @@ extern int sysemu_supported;
53 54
54#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r)) 55#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
55 56
56#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
57
58#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
59
60#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
61
62#endif 57#endif
63#ifndef PTRACE_SYSEMU_SINGLESTEP 58#ifndef PTRACE_SYSEMU_SINGLESTEP
64#define PTRACE_SYSEMU_SINGLESTEP 32 59#define PTRACE_SYSEMU_SINGLESTEP 32
@@ -71,6 +66,7 @@ union uml_pt_regs {
71 struct tt_regs { 66 struct tt_regs {
72 long syscall; 67 long syscall;
73 void *sc; 68 void *sc;
69 struct faultinfo faultinfo;
74 } tt; 70 } tt;
75#endif 71#endif
76#ifdef UML_CONFIG_MODE_SKAS 72#ifdef UML_CONFIG_MODE_SKAS
@@ -78,9 +74,7 @@ union uml_pt_regs {
78 unsigned long regs[HOST_FRAME_SIZE]; 74 unsigned long regs[HOST_FRAME_SIZE];
79 unsigned long fp[HOST_FP_SIZE]; 75 unsigned long fp[HOST_FP_SIZE];
80 unsigned long xfp[HOST_XFP_SIZE]; 76 unsigned long xfp[HOST_XFP_SIZE];
81 unsigned long fault_addr; 77 struct faultinfo faultinfo;
82 unsigned long fault_type;
83 unsigned long trap_type;
84 long syscall; 78 long syscall;
85 int is_user; 79 int is_user;
86 } skas; 80 } skas;
@@ -217,15 +211,8 @@ struct syscall_args {
217#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r) 211#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
218#define UPT_SYSCALL_RET(r) UPT_EAX(r) 212#define UPT_SYSCALL_RET(r) UPT_EAX(r)
219 213
220#define UPT_SEGV_IS_FIXABLE(r) \ 214#define UPT_FAULTINFO(r) \
221 CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ 215 CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
222 REGS_SEGV_IS_FIXABLE(&r->skas))
223
224#define UPT_FAULT_ADDR(r) \
225 __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas))
226
227#define UPT_FAULT_WRITE(r) \
228 CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
229 216
230#endif 217#endif
231 218
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h
index dfee589de360..1fe729265167 100644
--- a/arch/um/include/sysdep-i386/sigcontext.h
+++ b/arch/um/include/sysdep-i386/sigcontext.h
@@ -13,15 +13,12 @@
13#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc)) 13#define SC_RESTART_SYSCALL(sc) IP_RESTART_SYSCALL(SC_IP(sc))
14#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result) 14#define SC_SET_SYSCALL_RETURN(sc, result) SC_EAX(sc) = (result)
15 15
16#define SC_FAULT_ADDR(sc) SC_CR2(sc) 16#define GET_FAULTINFO_FROM_SC(fi,sc) \
17#define SC_FAULT_TYPE(sc) SC_ERR(sc) 17 { \
18 18 (fi).cr2 = SC_CR2(sc); \
19#define FAULT_WRITE(err) (err & 2) 19 (fi).error_code = SC_ERR(sc); \
20#define TO_SC_ERR(is_write) ((is_write) ? 2 : 0) 20 (fi).trap_no = SC_TRAPNO(sc); \
21 21 }
22#define SC_FAULT_WRITE(sc) (FAULT_WRITE(SC_ERR(sc)))
23
24#define SC_TRAP_TYPE(sc) SC_TRAPNO(sc)
25 22
26/* ptrace expects that, at the start of a system call, %eax contains 23/* ptrace expects that, at the start of a system call, %eax contains
27 * -ENOSYS, so this makes it so. 24 * -ENOSYS, so this makes it so.
@@ -29,9 +26,7 @@
29#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0) 26#define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
30 27
31/* This is Page Fault */ 28/* This is Page Fault */
32#define SEGV_IS_FIXABLE(trap) (trap == 14) 29#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
33
34#define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
35 30
36extern unsigned long *sc_sigmask(void *sc_ptr); 31extern unsigned long *sc_sigmask(void *sc_ptr);
37extern int sc_get_fpregs(unsigned long buf, void *sc_ptr); 32extern int sc_get_fpregs(unsigned long buf, void *sc_ptr);
diff --git a/arch/um/include/sysdep-i386/signal.h b/arch/um/include/sysdep-i386/signal.h
index b1e1f7a77499..07518b162136 100644
--- a/arch/um/include/sysdep-i386/signal.h
+++ b/arch/um/include/sysdep-i386/signal.h
@@ -8,6 +8,8 @@
8 8
9#include <signal.h> 9#include <signal.h>
10 10
11#define ARCH_SIGHDLR_PARAM int sig
12
11#define ARCH_GET_SIGCONTEXT(sc, sig) \ 13#define ARCH_GET_SIGCONTEXT(sc, sig) \
12 do sc = (struct sigcontext *) (&sig + 1); while(0) 14 do sc = (struct sigcontext *) (&sig + 1); while(0)
13 15
diff --git a/arch/um/include/sysdep-i386/skas_ptrace.h b/arch/um/include/sysdep-i386/skas_ptrace.h
new file mode 100644
index 000000000000..e27b8a791773
--- /dev/null
+++ b/arch/um/include/sysdep-i386/skas_ptrace.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_I386_SKAS_PTRACE_H
7#define __SYSDEP_I386_SKAS_PTRACE_H
8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_LDT 54
21
22#endif
diff --git a/arch/um/include/sysdep-i386/syscalls.h b/arch/um/include/sysdep-i386/syscalls.h
index 5db81ec9087d..be0a3e3469eb 100644
--- a/arch/um/include/sysdep-i386/syscalls.h
+++ b/arch/um/include/sysdep-i386/syscalls.h
@@ -22,102 +22,3 @@ extern syscall_handler_t old_mmap_i386;
22extern long sys_mmap2(unsigned long addr, unsigned long len, 22extern long sys_mmap2(unsigned long addr, unsigned long len,
23 unsigned long prot, unsigned long flags, 23 unsigned long prot, unsigned long flags,
24 unsigned long fd, unsigned long pgoff); 24 unsigned long fd, unsigned long pgoff);
25
26/* On i386 they choose a meaningless naming.*/
27#define __NR_kexec_load __NR_sys_kexec_load
28
29#define ARCH_SYSCALLS \
30 [ __NR_waitpid ] = (syscall_handler_t *) sys_waitpid, \
31 [ __NR_break ] = (syscall_handler_t *) sys_ni_syscall, \
32 [ __NR_oldstat ] = (syscall_handler_t *) sys_stat, \
33 [ __NR_umount ] = (syscall_handler_t *) sys_oldumount, \
34 [ __NR_stime ] = um_stime, \
35 [ __NR_oldfstat ] = (syscall_handler_t *) sys_fstat, \
36 [ __NR_stty ] = (syscall_handler_t *) sys_ni_syscall, \
37 [ __NR_gtty ] = (syscall_handler_t *) sys_ni_syscall, \
38 [ __NR_nice ] = (syscall_handler_t *) sys_nice, \
39 [ __NR_ftime ] = (syscall_handler_t *) sys_ni_syscall, \
40 [ __NR_prof ] = (syscall_handler_t *) sys_ni_syscall, \
41 [ __NR_signal ] = (syscall_handler_t *) sys_signal, \
42 [ __NR_lock ] = (syscall_handler_t *) sys_ni_syscall, \
43 [ __NR_mpx ] = (syscall_handler_t *) sys_ni_syscall, \
44 [ __NR_ulimit ] = (syscall_handler_t *) sys_ni_syscall, \
45 [ __NR_oldolduname ] = (syscall_handler_t *) sys_olduname, \
46 [ __NR_sigaction ] = (syscall_handler_t *) sys_sigaction, \
47 [ __NR_sgetmask ] = (syscall_handler_t *) sys_sgetmask, \
48 [ __NR_ssetmask ] = (syscall_handler_t *) sys_ssetmask, \
49 [ __NR_sigsuspend ] = (syscall_handler_t *) sys_sigsuspend, \
50 [ __NR_sigpending ] = (syscall_handler_t *) sys_sigpending, \
51 [ __NR_oldlstat ] = (syscall_handler_t *) sys_lstat, \
52 [ __NR_readdir ] = old_readdir, \
53 [ __NR_profil ] = (syscall_handler_t *) sys_ni_syscall, \
54 [ __NR_socketcall ] = (syscall_handler_t *) sys_socketcall, \
55 [ __NR_olduname ] = (syscall_handler_t *) sys_uname, \
56 [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \
57 [ __NR_idle ] = (syscall_handler_t *) sys_ni_syscall, \
58 [ __NR_ipc ] = (syscall_handler_t *) sys_ipc, \
59 [ __NR_sigreturn ] = (syscall_handler_t *) sys_sigreturn, \
60 [ __NR_sigprocmask ] = (syscall_handler_t *) sys_sigprocmask, \
61 [ __NR_bdflush ] = (syscall_handler_t *) sys_bdflush, \
62 [ __NR__llseek ] = (syscall_handler_t *) sys_llseek, \
63 [ __NR__newselect ] = (syscall_handler_t *) sys_select, \
64 [ __NR_vm86 ] = (syscall_handler_t *) sys_ni_syscall, \
65 [ __NR_mmap ] = (syscall_handler_t *) old_mmap_i386, \
66 [ __NR_ugetrlimit ] = (syscall_handler_t *) sys_getrlimit, \
67 [ __NR_mmap2 ] = (syscall_handler_t *) sys_mmap2, \
68 [ __NR_truncate64 ] = (syscall_handler_t *) sys_truncate64, \
69 [ __NR_ftruncate64 ] = (syscall_handler_t *) sys_ftruncate64, \
70 [ __NR_stat64 ] = (syscall_handler_t *) sys_stat64, \
71 [ __NR_lstat64 ] = (syscall_handler_t *) sys_lstat64, \
72 [ __NR_fstat64 ] = (syscall_handler_t *) sys_fstat64, \
73 [ __NR_fcntl64 ] = (syscall_handler_t *) sys_fcntl64, \
74 [ __NR_sendfile64 ] = (syscall_handler_t *) sys_sendfile64, \
75 [ __NR_statfs64 ] = (syscall_handler_t *) sys_statfs64, \
76 [ __NR_fstatfs64 ] = (syscall_handler_t *) sys_fstatfs64, \
77 [ __NR_fadvise64_64 ] = (syscall_handler_t *) sys_fadvise64_64, \
78 [ __NR_select ] = (syscall_handler_t *) old_select, \
79 [ __NR_vm86old ] = (syscall_handler_t *) sys_ni_syscall, \
80 [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \
81 [ __NR_lchown32 ] = (syscall_handler_t *) sys_lchown, \
82 [ __NR_getuid32 ] = (syscall_handler_t *) sys_getuid, \
83 [ __NR_getgid32 ] = (syscall_handler_t *) sys_getgid, \
84 [ __NR_geteuid32 ] = (syscall_handler_t *) sys_geteuid, \
85 [ __NR_getegid32 ] = (syscall_handler_t *) sys_getegid, \
86 [ __NR_setreuid32 ] = (syscall_handler_t *) sys_setreuid, \
87 [ __NR_setregid32 ] = (syscall_handler_t *) sys_setregid, \
88 [ __NR_getgroups32 ] = (syscall_handler_t *) sys_getgroups, \
89 [ __NR_setgroups32 ] = (syscall_handler_t *) sys_setgroups, \
90 [ __NR_fchown32 ] = (syscall_handler_t *) sys_fchown, \
91 [ __NR_setresuid32 ] = (syscall_handler_t *) sys_setresuid, \
92 [ __NR_getresuid32 ] = (syscall_handler_t *) sys_getresuid, \
93 [ __NR_setresgid32 ] = (syscall_handler_t *) sys_setresgid, \
94 [ __NR_getresgid32 ] = (syscall_handler_t *) sys_getresgid, \
95 [ __NR_chown32 ] = (syscall_handler_t *) sys_chown, \
96 [ __NR_setuid32 ] = (syscall_handler_t *) sys_setuid, \
97 [ __NR_setgid32 ] = (syscall_handler_t *) sys_setgid, \
98 [ __NR_setfsuid32 ] = (syscall_handler_t *) sys_setfsuid, \
99 [ __NR_setfsgid32 ] = (syscall_handler_t *) sys_setfsgid, \
100 [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \
101 [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
102 [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
103 [ 222 ] = (syscall_handler_t *) sys_ni_syscall, \
104 [ 223 ] = (syscall_handler_t *) sys_ni_syscall, \
105 [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
106 [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
107 [ 251 ] = (syscall_handler_t *) sys_ni_syscall, \
108 [ 285 ] = (syscall_handler_t *) sys_ni_syscall,
109
110/* 222 doesn't yet have a name in include/asm-i386/unistd.h */
111
112#define LAST_ARCH_SYSCALL 285
113
114/*
115 * Overrides for Emacs so that we follow Linus's tabbing style.
116 * Emacs will notice this stuff at the end of the file and automatically
117 * adjust the settings for this buffer only. This must remain at the end
118 * of the file.
119 * ---------------------------------------------------------------------------
120 * Local variables:
121 * c-file-style: "linux"
122 * End:
123 */
diff --git a/arch/um/include/sysdep-ia64/skas_ptrace.h b/arch/um/include/sysdep-ia64/skas_ptrace.h
new file mode 100644
index 000000000000..25a38e715702
--- /dev/null
+++ b/arch/um/include/sysdep-ia64/skas_ptrace.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_IA64_SKAS_PTRACE_H
7#define __SYSDEP_IA64_SKAS_PTRACE_H
8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_LDT 54
21
22#endif
diff --git a/arch/um/include/sysdep-ppc/skas_ptrace.h b/arch/um/include/sysdep-ppc/skas_ptrace.h
new file mode 100644
index 000000000000..d9fbbac10de0
--- /dev/null
+++ b/arch/um/include/sysdep-ppc/skas_ptrace.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_PPC_SKAS_PTRACE_H
7#define __SYSDEP_PPC_SKAS_PTRACE_H
8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_LDT 54
21
22#endif
diff --git a/arch/um/include/sysdep-x86_64/faultinfo.h b/arch/um/include/sysdep-x86_64/faultinfo.h
new file mode 100644
index 000000000000..cb917b0d5660
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/faultinfo.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
4 * Licensed under the GPL
5 */
6
7#ifndef __FAULTINFO_X86_64_H
8#define __FAULTINFO_X86_64_H
9
10/* this structure contains the full arch-specific faultinfo
11 * from the traps.
12 * On i386, ptrace_faultinfo unfortunately doesn't provide
13 * all the info, since trap_no is missing.
14 * All common elements are defined at the same position in
15 * both structures, thus making it easy to copy the
16 * contents without knowledge about the structure elements.
17 */
18struct faultinfo {
19 int error_code; /* in ptrace_faultinfo misleadingly called is_write */
20 unsigned long cr2; /* in ptrace_faultinfo called addr */
21 int trap_no; /* missing in ptrace_faultinfo */
22};
23
24#define FAULT_WRITE(fi) ((fi).error_code & 2)
25#define FAULT_ADDRESS(fi) ((fi).cr2)
26
27#define PTRACE_FULL_FAULTINFO 1
28
29#endif
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 915c82daffbd..348e8fcd513f 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -9,6 +9,7 @@
9 9
10#include "uml-config.h" 10#include "uml-config.h"
11#include "user_constants.h" 11#include "user_constants.h"
12#include "sysdep/faultinfo.h"
12 13
13#define MAX_REG_OFFSET (UM_FRAME_SIZE) 14#define MAX_REG_OFFSET (UM_FRAME_SIZE)
14#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) 15#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
@@ -83,6 +84,7 @@ union uml_pt_regs {
83 long syscall; 84 long syscall;
84 unsigned long orig_rax; 85 unsigned long orig_rax;
85 void *sc; 86 void *sc;
87 struct faultinfo faultinfo;
86 } tt; 88 } tt;
87#endif 89#endif
88#ifdef UML_CONFIG_MODE_SKAS 90#ifdef UML_CONFIG_MODE_SKAS
@@ -90,9 +92,7 @@ union uml_pt_regs {
90 /* XXX */ 92 /* XXX */
91 unsigned long regs[27]; 93 unsigned long regs[27];
92 unsigned long fp[65]; 94 unsigned long fp[65];
93 unsigned long fault_addr; 95 struct faultinfo faultinfo;
94 unsigned long fault_type;
95 unsigned long trap_type;
96 long syscall; 96 long syscall;
97 int is_user; 97 int is_user;
98 } skas; 98 } skas;
@@ -241,14 +241,8 @@ struct syscall_args {
241 CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \ 241 CHOOSE_MODE(SC_SEGV_IS_FIXABLE(UPT_SC(r)), \
242 REGS_SEGV_IS_FIXABLE(&r->skas)) 242 REGS_SEGV_IS_FIXABLE(&r->skas))
243 243
244#define UPT_FAULT_ADDR(r) \ 244#define UPT_FAULTINFO(r) \
245 __CHOOSE_MODE(SC_FAULT_ADDR(UPT_SC(r)), REGS_FAULT_ADDR(&r->skas)) 245 CHOOSE_MODE((&(r)->tt.faultinfo), (&(r)->skas.faultinfo))
246
247#define UPT_FAULT_WRITE(r) \
248 CHOOSE_MODE(SC_FAULT_WRITE(UPT_SC(r)), REGS_FAULT_WRITE(&r->skas))
249
250#define UPT_TRAP(r) __CHOOSE_MODE(SC_TRAP_TYPE(UPT_SC(r)), REGS_TRAP(&r->skas))
251#define UPT_ERR(r) __CHOOSE_MODE(SC_FAULT_TYPE(UPT_SC(r)), REGS_ERR(&r->skas))
252 246
253#endif 247#endif
254 248
diff --git a/arch/um/include/sysdep-x86_64/sigcontext.h b/arch/um/include/sysdep-x86_64/sigcontext.h
index 1e38a54ff4cf..2a78260d15a0 100644
--- a/arch/um/include/sysdep-x86_64/sigcontext.h
+++ b/arch/um/include/sysdep-x86_64/sigcontext.h
@@ -17,11 +17,12 @@
17#define SC_FAULT_ADDR(sc) SC_CR2(sc) 17#define SC_FAULT_ADDR(sc) SC_CR2(sc)
18#define SC_FAULT_TYPE(sc) SC_ERR(sc) 18#define SC_FAULT_TYPE(sc) SC_ERR(sc)
19 19
20#define FAULT_WRITE(err) ((err) & 2) 20#define GET_FAULTINFO_FROM_SC(fi,sc) \
21 21 { \
22#define SC_FAULT_WRITE(sc) FAULT_WRITE(SC_FAULT_TYPE(sc)) 22 (fi).cr2 = SC_CR2(sc); \
23 23 (fi).error_code = SC_ERR(sc); \
24#define SC_TRAP_TYPE(sc) SC_TRAPNO(sc) 24 (fi).trap_no = SC_TRAPNO(sc); \
25 }
25 26
26/* ptrace expects that, at the start of a system call, %eax contains 27/* ptrace expects that, at the start of a system call, %eax contains
27 * -ENOSYS, so this makes it so. 28 * -ENOSYS, so this makes it so.
@@ -29,8 +30,8 @@
29 30
30#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)
31 32
32#define SEGV_IS_FIXABLE(trap) ((trap) == 14) 33/* This is Page Fault */
33#define SC_SEGV_IS_FIXABLE(sc) SEGV_IS_FIXABLE(SC_TRAP_TYPE(sc)) 34#define SEGV_IS_FIXABLE(fi) ((fi)->trap_no == 14)
34 35
35extern unsigned long *sc_sigmask(void *sc_ptr); 36extern unsigned long *sc_sigmask(void *sc_ptr);
36 37
diff --git a/arch/um/include/sysdep-x86_64/signal.h b/arch/um/include/sysdep-x86_64/signal.h
index e5e52756fab4..6142897af3d1 100644
--- a/arch/um/include/sysdep-x86_64/signal.h
+++ b/arch/um/include/sysdep-x86_64/signal.h
@@ -6,6 +6,8 @@
6#ifndef __X86_64_SIGNAL_H_ 6#ifndef __X86_64_SIGNAL_H_
7#define __X86_64_SIGNAL_H_ 7#define __X86_64_SIGNAL_H_
8 8
9#define ARCH_SIGHDLR_PARAM int sig
10
9#define ARCH_GET_SIGCONTEXT(sc, sig_addr) \ 11#define ARCH_GET_SIGCONTEXT(sc, sig_addr) \
10 do { \ 12 do { \
11 struct ucontext *__uc; \ 13 struct ucontext *__uc; \
diff --git a/arch/um/include/sysdep-x86_64/skas_ptrace.h b/arch/um/include/sysdep-x86_64/skas_ptrace.h
new file mode 100644
index 000000000000..95db4be786e4
--- /dev/null
+++ b/arch/um/include/sysdep-x86_64/skas_ptrace.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_X86_64_SKAS_PTRACE_H
7#define __SYSDEP_X86_64_SKAS_PTRACE_H
8
9struct ptrace_faultinfo {
10 int is_write;
11 unsigned long addr;
12};
13
14struct ptrace_ldt {
15 int func;
16 void *ptr;
17 unsigned long bytecount;
18};
19
20#define PTRACE_LDT 54
21
22#endif
diff --git a/arch/um/include/sysdep-x86_64/syscalls.h b/arch/um/include/sysdep-x86_64/syscalls.h
index b187a4157ff3..67923cca5691 100644
--- a/arch/um/include/sysdep-x86_64/syscalls.h
+++ b/arch/um/include/sysdep-x86_64/syscalls.h
@@ -26,66 +26,9 @@ extern syscall_handler_t *ia32_sys_call_table[];
26extern long old_mmap(unsigned long addr, unsigned long len, 26extern long old_mmap(unsigned long addr, unsigned long len,
27 unsigned long prot, unsigned long flags, 27 unsigned long prot, unsigned long flags,
28 unsigned long fd, unsigned long pgoff); 28 unsigned long fd, unsigned long pgoff);
29extern syscall_handler_t wrap_sys_shmat;
30extern syscall_handler_t sys_modify_ldt; 29extern syscall_handler_t sys_modify_ldt;
31extern syscall_handler_t sys_arch_prctl; 30extern syscall_handler_t sys_arch_prctl;
32 31
33#define ARCH_SYSCALLS \ 32#define NR_syscalls (__NR_syscall_max + 1)
34 [ __NR_mmap ] = (syscall_handler_t *) old_mmap, \
35 [ __NR_select ] = (syscall_handler_t *) sys_select, \
36 [ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
37 [ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
38 [ __NR_shmget ] = (syscall_handler_t *) sys_shmget, \
39 [ __NR_shmat ] = (syscall_handler_t *) wrap_sys_shmat, \
40 [ __NR_shmctl ] = (syscall_handler_t *) sys_shmctl, \
41 [ __NR_semop ] = (syscall_handler_t *) sys_semop, \
42 [ __NR_semget ] = (syscall_handler_t *) sys_semget, \
43 [ __NR_semctl ] = (syscall_handler_t *) sys_semctl, \
44 [ __NR_shmdt ] = (syscall_handler_t *) sys_shmdt, \
45 [ __NR_msgget ] = (syscall_handler_t *) sys_msgget, \
46 [ __NR_msgsnd ] = (syscall_handler_t *) sys_msgsnd, \
47 [ __NR_msgrcv ] = (syscall_handler_t *) sys_msgrcv, \
48 [ __NR_msgctl ] = (syscall_handler_t *) sys_msgctl, \
49 [ __NR_pivot_root ] = (syscall_handler_t *) sys_pivot_root, \
50 [ __NR_tuxcall ] = (syscall_handler_t *) sys_ni_syscall, \
51 [ __NR_security ] = (syscall_handler_t *) sys_ni_syscall, \
52 [ __NR_epoll_ctl_old ] = (syscall_handler_t *) sys_ni_syscall, \
53 [ __NR_epoll_wait_old ] = (syscall_handler_t *) sys_ni_syscall, \
54 [ __NR_modify_ldt ] = (syscall_handler_t *) sys_modify_ldt, \
55 [ __NR_arch_prctl ] = (syscall_handler_t *) sys_arch_prctl, \
56 [ __NR_socket ] = (syscall_handler_t *) sys_socket, \
57 [ __NR_connect ] = (syscall_handler_t *) sys_connect, \
58 [ __NR_accept ] = (syscall_handler_t *) sys_accept, \
59 [ __NR_recvfrom ] = (syscall_handler_t *) sys_recvfrom, \
60 [ __NR_recvmsg ] = (syscall_handler_t *) sys_recvmsg, \
61 [ __NR_sendmsg ] = (syscall_handler_t *) sys_sendmsg, \
62 [ __NR_bind ] = (syscall_handler_t *) sys_bind, \
63 [ __NR_listen ] = (syscall_handler_t *) sys_listen, \
64 [ __NR_getsockname ] = (syscall_handler_t *) sys_getsockname, \
65 [ __NR_getpeername ] = (syscall_handler_t *) sys_getpeername, \
66 [ __NR_socketpair ] = (syscall_handler_t *) sys_socketpair, \
67 [ __NR_sendto ] = (syscall_handler_t *) sys_sendto, \
68 [ __NR_shutdown ] = (syscall_handler_t *) sys_shutdown, \
69 [ __NR_setsockopt ] = (syscall_handler_t *) sys_setsockopt, \
70 [ __NR_getsockopt ] = (syscall_handler_t *) sys_getsockopt, \
71 [ __NR_iopl ] = (syscall_handler_t *) sys_ni_syscall, \
72 [ __NR_set_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
73 [ __NR_get_thread_area ] = (syscall_handler_t *) sys_ni_syscall, \
74 [ __NR_semtimedop ] = (syscall_handler_t *) sys_semtimedop, \
75 [ 251 ] = (syscall_handler_t *) sys_ni_syscall,
76
77#define LAST_ARCH_SYSCALL 251
78#define NR_syscalls 1024
79 33
80#endif 34#endif
81
82/*
83 * Overrides for Emacs so that we follow Linus's tabbing style.
84 * Emacs will notice this stuff at the end of the file and automatically
85 * adjust the settings for this buffer only. This must remain at the end
86 * of the file.
87 * ---------------------------------------------------------------------------
88 * Local variables:
89 * c-file-style: "linux"
90 * End:
91 */
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h
index 103cd320386c..b8c5b8a95250 100644
--- a/arch/um/include/user_util.h
+++ b/arch/um/include/user_util.h
@@ -67,7 +67,6 @@ extern void *um_kmalloc(int size);
67extern int switcheroo(int fd, int prot, void *from, void *to, int size); 67extern int switcheroo(int fd, int prot, void *from, void *to, int size);
68extern void setup_machinename(char *machine_out); 68extern void setup_machinename(char *machine_out);
69extern void setup_hostinfo(void); 69extern void setup_hostinfo(void);
70extern void add_arg(char *arg);
71extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); 70extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
72extern void init_new_thread_signals(int altstack); 71extern void init_new_thread_signals(int altstack);
73extern void do_exec(int old_pid, int new_pid); 72extern void do_exec(int old_pid, int new_pid);
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index dc796c1bf39e..9736ca27c5f0 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -4,13 +4,13 @@
4# 4#
5 5
6extra-y := vmlinux.lds 6extra-y := vmlinux.lds
7clean-files := vmlinux.lds.S config.tmp 7clean-files :=
8 8
9obj-y = checksum.o 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 mem_user.o \
11 physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \ 11 physmem.o process.o process_kern.o ptrace.o reboot.o resource.o \
12 sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ 12 sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \
13 syscall_kern.o sysrq.o sys_call_table.o tempfile.o time.o time_kern.o \ 13 syscall_kern.o sysrq.o tempfile.o time.o time_kern.o \
14 tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \ 14 tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o umid.o \
15 user_util.o 15 user_util.o
16 16
@@ -23,18 +23,14 @@ obj-$(CONFIG_SYSCALL_DEBUG) += syscall_user.o
23obj-$(CONFIG_MODE_TT) += tt/ 23obj-$(CONFIG_MODE_TT) += tt/
24obj-$(CONFIG_MODE_SKAS) += skas/ 24obj-$(CONFIG_MODE_SKAS) += skas/
25 25
26# This needs be compiled with frame pointers regardless of how the rest of the
27# kernel is built.
28CFLAGS_frame.o := -fno-omit-frame-pointer
29
30user-objs-$(CONFIG_TTY_LOG) += tty_log.o 26user-objs-$(CONFIG_TTY_LOG) += tty_log.o
31 27
32USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \ 28USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \
33 time.o tty_log.o umid.o user_util.o frame.o 29 time.o tty_log.o umid.o user_util.o
34 30
35include arch/um/scripts/Makefile.rules 31include arch/um/scripts/Makefile.rules
36 32
37targets += config.c 33targets := config.c config.tmp
38 34
39# Be careful with the below Sed code - sed is pitfall-rich! 35# Be careful with the below Sed code - sed is pitfall-rich!
40# We use sed to lower build requirements, for "embedded" builders for instance. 36# We use sed to lower build requirements, for "embedded" builders for instance.
@@ -53,6 +49,7 @@ quiet_cmd_quote2 = QUOTE $@
53 cmd_quote2 = sed -e '/CONFIG/{' \ 49 cmd_quote2 = sed -e '/CONFIG/{' \
54 -e 's/"CONFIG"\;/""/' \ 50 -e 's/"CONFIG"\;/""/' \
55 -e 'r $(obj)/config.tmp' \ 51 -e 'r $(obj)/config.tmp' \
56 -e 'a""\;' \ 52 -e 'a \' \
53 -e '""\;' \
57 -e '}' \ 54 -e '}' \
58 $< > $@ 55 $< > $@
diff --git a/arch/um/kernel/checksum.c b/arch/um/kernel/checksum.c
index e69b2be951d1..e69de29bb2d1 100644
--- a/arch/um/kernel/checksum.c
+++ b/arch/um/kernel/checksum.c
@@ -1,36 +0,0 @@
1#include "asm/uaccess.h"
2#include "linux/errno.h"
3#include "linux/module.h"
4
5unsigned int arch_csum_partial(const unsigned char *buff, int len, int sum);
6
7unsigned int csum_partial(unsigned char *buff, int len, int sum)
8{
9 return arch_csum_partial(buff, len, sum);
10}
11
12EXPORT_SYMBOL(csum_partial);
13
14unsigned int csum_partial_copy_to(const unsigned char *src,
15 unsigned char __user *dst, int len, int sum,
16 int *err_ptr)
17{
18 if(copy_to_user(dst, src, len)){
19 *err_ptr = -EFAULT;
20 return(-1);
21 }
22
23 return(arch_csum_partial(src, len, sum));
24}
25
26unsigned int csum_partial_copy_from(const unsigned char __user *src,
27 unsigned char *dst, int len, int sum,
28 int *err_ptr)
29{
30 if(copy_from_user(dst, src, len)){
31 *err_ptr = -EFAULT;
32 return(-1);
33 }
34
35 return arch_csum_partial(dst, len, sum);
36}
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index d71e8f00810f..d44fb5282547 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -163,7 +163,6 @@ void __init init_IRQ(void)
163 irq_desc[i].handler = &SIGIO_irq_type; 163 irq_desc[i].handler = &SIGIO_irq_type;
164 enable_irq(i); 164 enable_irq(i);
165 } 165 }
166 init_irq_signals(0);
167} 166}
168 167
169/* 168/*
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index b41d3397d07b..78d69dc74b26 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -10,7 +10,6 @@
10#include "linux/spinlock.h" 10#include "linux/spinlock.h"
11#include "linux/highmem.h" 11#include "linux/highmem.h"
12#include "asm/current.h" 12#include "asm/current.h"
13#include "asm/delay.h"
14#include "asm/processor.h" 13#include "asm/processor.h"
15#include "asm/unistd.h" 14#include "asm/unistd.h"
16#include "asm/pgalloc.h" 15#include "asm/pgalloc.h"
@@ -28,8 +27,6 @@ EXPORT_SYMBOL(uml_physmem);
28EXPORT_SYMBOL(set_signals); 27EXPORT_SYMBOL(set_signals);
29EXPORT_SYMBOL(get_signals); 28EXPORT_SYMBOL(get_signals);
30EXPORT_SYMBOL(kernel_thread); 29EXPORT_SYMBOL(kernel_thread);
31EXPORT_SYMBOL(__const_udelay);
32EXPORT_SYMBOL(__udelay);
33EXPORT_SYMBOL(sys_waitpid); 30EXPORT_SYMBOL(sys_waitpid);
34EXPORT_SYMBOL(task_size); 31EXPORT_SYMBOL(task_size);
35EXPORT_SYMBOL(flush_tlb_range); 32EXPORT_SYMBOL(flush_tlb_range);
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index f76a2692adca..51f8e5a8ac6a 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -65,8 +65,6 @@ void init_new_thread_signals(int altstack)
65 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 65 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
66 set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, 66 set_handler(SIGBUS, (__sighandler_t) sig_handler, flags,
67 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 67 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
68 set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags,
69 SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
70 set_handler(SIGUSR2, (__sighandler_t) sig_handler, 68 set_handler(SIGUSR2, (__sighandler_t) sig_handler,
71 flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); 69 flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
72 signal(SIGHUP, SIG_IGN); 70 signal(SIGHUP, SIG_IGN);
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index 1d719d5b4bb9..c1adf7ba3fd1 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -115,16 +115,6 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
115 return(pid); 115 return(pid);
116} 116}
117 117
118void switch_mm(struct mm_struct *prev, struct mm_struct *next,
119 struct task_struct *tsk)
120{
121 int cpu = smp_processor_id();
122
123 if (prev != next)
124 cpu_clear(cpu, prev->cpu_vm_mask);
125 cpu_set(cpu, next->cpu_vm_mask);
126}
127
128void set_current(void *t) 118void set_current(void *t)
129{ 119{
130 struct task_struct *task = t; 120 struct task_struct *task = t;
@@ -152,7 +142,6 @@ void release_thread(struct task_struct *task)
152 142
153void exit_thread(void) 143void exit_thread(void)
154{ 144{
155 CHOOSE_MODE(exit_thread_tt(), exit_thread_skas());
156 unprotect_stack((unsigned long) current_thread); 145 unprotect_stack((unsigned long) current_thread);
157} 146}
158 147
@@ -161,10 +150,6 @@ void *get_current(void)
161 return(current); 150 return(current);
162} 151}
163 152
164void prepare_to_copy(struct task_struct *tsk)
165{
166}
167
168int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, 153int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
169 unsigned long stack_top, struct task_struct * p, 154 unsigned long stack_top, struct task_struct * p,
170 struct pt_regs *regs) 155 struct pt_regs *regs)
@@ -480,12 +465,21 @@ int singlestepping(void * t)
480 return 2; 465 return 2;
481} 466}
482 467
468/*
469 * Only x86 and x86_64 have an arch_align_stack().
470 * All other arches have "#define arch_align_stack(x) (x)"
471 * in their asm/system.h
472 * As this is included in UML from asm-um/system-generic.h,
473 * we can use it to behave as the subarch does.
474 */
475#ifndef arch_align_stack
483unsigned long arch_align_stack(unsigned long sp) 476unsigned long arch_align_stack(unsigned long sp)
484{ 477{
485 if (randomize_va_space) 478 if (randomize_va_space)
486 sp -= get_random_int() % 8192; 479 sp -= get_random_int() % 8192;
487 return sp & ~0xf; 480 return sp & ~0xf;
488} 481}
482#endif
489 483
490 484
491/* 485/*
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 3a99ee6d94eb..2b75d8d9ba73 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -19,15 +19,30 @@
19#include "skas_ptrace.h" 19#include "skas_ptrace.h"
20#include "sysdep/ptrace.h" 20#include "sysdep/ptrace.h"
21 21
22static inline void set_singlestepping(struct task_struct *child, int on)
23{
24 if (on)
25 child->ptrace |= PT_DTRACE;
26 else
27 child->ptrace &= ~PT_DTRACE;
28 child->thread.singlestep_syscall = 0;
29
30#ifdef SUBARCH_SET_SINGLESTEPPING
31 SUBARCH_SET_SINGLESTEPPING(child, on)
32#endif
33 }
34
22/* 35/*
23 * Called by kernel/ptrace.c when detaching.. 36 * Called by kernel/ptrace.c when detaching..
24 */ 37 */
25void ptrace_disable(struct task_struct *child) 38void ptrace_disable(struct task_struct *child)
26{ 39{
27 child->ptrace &= ~PT_DTRACE; 40 set_singlestepping(child,0);
28 child->thread.singlestep_syscall = 0;
29} 41}
30 42
43extern int peek_user(struct task_struct * child, long addr, long data);
44extern int poke_user(struct task_struct * child, long addr, long data);
45
31long sys_ptrace(long request, long pid, long addr, long data) 46long sys_ptrace(long request, long pid, long addr, long data)
32{ 47{
33 struct task_struct *child; 48 struct task_struct *child;
@@ -67,6 +82,10 @@ long sys_ptrace(long request, long pid, long addr, long data)
67 goto out_tsk; 82 goto out_tsk;
68 } 83 }
69 84
85#ifdef SUBACH_PTRACE_SPECIAL
86 SUBARCH_PTRACE_SPECIAL(child,request,addr,data)
87#endif
88
70 ret = ptrace_check_attach(child, request == PTRACE_KILL); 89 ret = ptrace_check_attach(child, request == PTRACE_KILL);
71 if (ret < 0) 90 if (ret < 0)
72 goto out_tsk; 91 goto out_tsk;
@@ -87,26 +106,9 @@ long sys_ptrace(long request, long pid, long addr, long data)
87 } 106 }
88 107
89 /* read the word at location addr in the USER area. */ 108 /* read the word at location addr in the USER area. */
90 case PTRACE_PEEKUSR: { 109 case PTRACE_PEEKUSR:
91 unsigned long tmp; 110 ret = peek_user(child, addr, data);
92 111 break;
93 ret = -EIO;
94 if ((addr & 3) || addr < 0)
95 break;
96
97 tmp = 0; /* Default return condition */
98 if(addr < MAX_REG_OFFSET){
99 tmp = getreg(child, addr);
100 }
101 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
102 (addr <= offsetof(struct user, u_debugreg[7]))){
103 addr -= offsetof(struct user, u_debugreg[0]);
104 addr = addr >> 2;
105 tmp = child->thread.arch.debugregs[addr];
106 }
107 ret = put_user(tmp, (unsigned long __user *) data);
108 break;
109 }
110 112
111 /* when I and D space are separate, this will have to be fixed. */ 113 /* when I and D space are separate, this will have to be fixed. */
112 case PTRACE_POKETEXT: /* write the word at location addr. */ 114 case PTRACE_POKETEXT: /* write the word at location addr. */
@@ -119,35 +121,16 @@ long sys_ptrace(long request, long pid, long addr, long data)
119 break; 121 break;
120 122
121 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 123 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
122 ret = -EIO; 124 ret = poke_user(child, addr, data);
123 if ((addr & 3) || addr < 0) 125 break;
124 break;
125
126 if (addr < MAX_REG_OFFSET) {
127 ret = putreg(child, addr, data);
128 break;
129 }
130#if 0 /* XXX x86_64 */
131 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
132 (addr <= offsetof(struct user, u_debugreg[7]))){
133 addr -= offsetof(struct user, u_debugreg[0]);
134 addr = addr >> 2;
135 if((addr == 4) || (addr == 5)) break;
136 child->thread.arch.debugregs[addr] = data;
137 ret = 0;
138 }
139#endif
140
141 break;
142 126
143 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 127 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
144 case PTRACE_CONT: { /* restart after signal. */ 128 case PTRACE_CONT: { /* restart after signal. */
145 ret = -EIO; 129 ret = -EIO;
146 if ((unsigned long) data > _NSIG) 130 if (!valid_signal(data))
147 break; 131 break;
148 132
149 child->ptrace &= ~PT_DTRACE; 133 set_singlestepping(child, 0);
150 child->thread.singlestep_syscall = 0;
151 if (request == PTRACE_SYSCALL) { 134 if (request == PTRACE_SYSCALL) {
152 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 135 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
153 } 136 }
@@ -170,8 +153,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
170 if (child->exit_state == EXIT_ZOMBIE) /* already dead */ 153 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
171 break; 154 break;
172 155
173 child->ptrace &= ~PT_DTRACE; 156 set_singlestepping(child, 0);
174 child->thread.singlestep_syscall = 0;
175 child->exit_code = SIGKILL; 157 child->exit_code = SIGKILL;
176 wake_up_process(child); 158 wake_up_process(child);
177 break; 159 break;
@@ -179,11 +161,10 @@ long sys_ptrace(long request, long pid, long addr, long data)
179 161
180 case PTRACE_SINGLESTEP: { /* set the trap flag. */ 162 case PTRACE_SINGLESTEP: { /* set the trap flag. */
181 ret = -EIO; 163 ret = -EIO;
182 if ((unsigned long) data > _NSIG) 164 if (!valid_signal(data))
183 break; 165 break;
184 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 166 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
185 child->ptrace |= PT_DTRACE; 167 set_singlestepping(child, 1);
186 child->thread.singlestep_syscall = 0;
187 child->exit_code = data; 168 child->exit_code = data;
188 /* give it a chance to run. */ 169 /* give it a chance to run. */
189 wake_up_process(child); 170 wake_up_process(child);
@@ -250,23 +231,19 @@ long sys_ptrace(long request, long pid, long addr, long data)
250 break; 231 break;
251#endif 232#endif
252 case PTRACE_FAULTINFO: { 233 case PTRACE_FAULTINFO: {
253 struct ptrace_faultinfo fault; 234 /* Take the info from thread->arch->faultinfo,
254 235 * but transfer max. sizeof(struct ptrace_faultinfo).
255 fault = ((struct ptrace_faultinfo) 236 * On i386, ptrace_faultinfo is smaller!
256 { .is_write = child->thread.err, 237 */
257 .addr = child->thread.cr2 }); 238 ret = copy_to_user((unsigned long __user *) data,
258 ret = copy_to_user((unsigned long __user *) data, &fault, 239 &child->thread.arch.faultinfo,
259 sizeof(fault)); 240 sizeof(struct ptrace_faultinfo));
260 if(ret) 241 if(ret)
261 break; 242 break;
262 break; 243 break;
263 } 244 }
264 case PTRACE_SIGPENDING:
265 ret = copy_to_user((unsigned long __user *) data,
266 &child->pending.signal,
267 sizeof(child->pending.signal));
268 break;
269 245
246#ifdef PTRACE_LDT
270 case PTRACE_LDT: { 247 case PTRACE_LDT: {
271 struct ptrace_ldt ldt; 248 struct ptrace_ldt ldt;
272 249
@@ -282,6 +259,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
282 ret = -EIO; 259 ret = -EIO;
283 break; 260 break;
284 } 261 }
262#endif
285#ifdef CONFIG_PROC_MM 263#ifdef CONFIG_PROC_MM
286 case PTRACE_SWITCH_MM: { 264 case PTRACE_SWITCH_MM: {
287 struct mm_struct *old = child->mm; 265 struct mm_struct *old = child->mm;
@@ -337,15 +315,18 @@ void syscall_trace(union uml_pt_regs *regs, int entryexit)
337 315
338 if (unlikely(current->audit_context)) { 316 if (unlikely(current->audit_context)) {
339 if (!entryexit) 317 if (!entryexit)
340 audit_syscall_entry(current, 318 audit_syscall_entry(current,
341 UPT_SYSCALL_NR(&regs->regs), 319 HOST_AUDIT_ARCH,
342 UPT_SYSCALL_ARG1(&regs->regs), 320 UPT_SYSCALL_NR(regs),
343 UPT_SYSCALL_ARG2(&regs->regs), 321 UPT_SYSCALL_ARG1(regs),
344 UPT_SYSCALL_ARG3(&regs->regs), 322 UPT_SYSCALL_ARG2(regs),
345 UPT_SYSCALL_ARG4(&regs->regs)); 323 UPT_SYSCALL_ARG3(regs),
346 else 324 UPT_SYSCALL_ARG4(regs));
347 audit_syscall_exit(current, 325 else {
348 UPT_SYSCALL_RET(&regs->regs)); 326 int res = UPT_SYSCALL_RET(regs);
327 audit_syscall_exit(current, AUDITSC_RESULT(res),
328 res);
329 }
349 } 330 }
350 331
351 /* Fake a debug trap */ 332 /* Fake a debug trap */
diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c
index 668df13d8c9d..e89218958f38 100644
--- a/arch/um/kernel/sigio_user.c
+++ b/arch/um/kernel/sigio_user.c
@@ -182,6 +182,7 @@ static int write_sigio_thread(void *unused)
182 int i, n, respond_fd; 182 int i, n, respond_fd;
183 char c; 183 char c;
184 184
185 signal(SIGWINCH, SIG_IGN);
185 fds = &current_poll; 186 fds = &current_poll;
186 while(1){ 187 while(1){
187 n = poll(fds->poll, fds->used, -1); 188 n = poll(fds->poll, fds->used, -1);
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h
index 94c564962378..e48490028111 100644
--- a/arch/um/kernel/skas/include/mode_kern-skas.h
+++ b/arch/um/kernel/skas/include/mode_kern-skas.h
@@ -18,7 +18,6 @@ extern int copy_thread_skas(int nr, unsigned long clone_flags,
18 unsigned long sp, unsigned long stack_top, 18 unsigned long sp, unsigned long stack_top,
19 struct task_struct *p, struct pt_regs *regs); 19 struct task_struct *p, struct pt_regs *regs);
20extern void release_thread_skas(struct task_struct *task); 20extern void release_thread_skas(struct task_struct *task);
21extern void exit_thread_skas(void);
22extern void initial_thread_cb_skas(void (*proc)(void *), void *arg); 21extern void initial_thread_cb_skas(void (*proc)(void *), void *arg);
23extern void init_idle_skas(void); 22extern void init_idle_skas(void);
24extern void flush_tlb_kernel_range_skas(unsigned long start, 23extern void flush_tlb_kernel_range_skas(unsigned long start,
diff --git a/arch/um/kernel/skas/include/skas.h b/arch/um/kernel/skas/include/skas.h
index f0702c2c7204..96b51dba3471 100644
--- a/arch/um/kernel/skas/include/skas.h
+++ b/arch/um/kernel/skas/include/skas.h
@@ -27,9 +27,10 @@ extern void map(int fd, unsigned long virt, unsigned long len, int r, int w,
27extern int unmap(int fd, void *addr, unsigned long len); 27extern int unmap(int fd, void *addr, unsigned long len);
28extern int protect(int fd, unsigned long addr, unsigned long len, 28extern int protect(int fd, unsigned long addr, unsigned long len,
29 int r, int w, int x); 29 int r, int w, int x);
30extern void user_signal(int sig, union uml_pt_regs *regs); 30extern void user_signal(int sig, union uml_pt_regs *regs, int pid);
31extern int new_mm(int from); 31extern int new_mm(int from);
32extern void start_userspace(int cpu); 32extern void start_userspace(int cpu);
33extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
33extern long execute_syscall_skas(void *r); 34extern long execute_syscall_skas(void *r);
34 35
35#endif 36#endif
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h
index 11986c9b9ddf..cd6c280482cb 100644
--- a/arch/um/kernel/skas/include/uaccess-skas.h
+++ b/arch/um/kernel/skas/include/uaccess-skas.h
@@ -19,7 +19,7 @@
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 * addr, 21static inline int verify_area_skas(int type, const void * addr,
22 unsigned long size) 22 unsigned long size)
23{ 23{
24 return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); 24 return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
25} 25}
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index b4ffaaa81241..773cd2b525fc 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include <stdlib.h> 6#include <stdlib.h>
7#include <string.h>
7#include <unistd.h> 8#include <unistd.h>
8#include <errno.h> 9#include <errno.h>
9#include <signal.h> 10#include <signal.h>
@@ -27,27 +28,37 @@
27#include "chan_user.h" 28#include "chan_user.h"
28#include "signal_user.h" 29#include "signal_user.h"
29#include "registers.h" 30#include "registers.h"
31#include "process.h"
30 32
31int is_skas_winch(int pid, int fd, void *data) 33int is_skas_winch(int pid, int fd, void *data)
32{ 34{
33 if(pid != os_getpid()) 35 if(pid != os_getpgrp())
34 return(0); 36 return(0);
35 37
36 register_winch_irq(-1, fd, -1, data); 38 register_winch_irq(-1, fd, -1, data);
37 return(1); 39 return(1);
38} 40}
39 41
40static void handle_segv(int pid) 42void get_skas_faultinfo(int pid, struct faultinfo * fi)
41{ 43{
42 struct ptrace_faultinfo fault;
43 int err; 44 int err;
44 45
45 err = ptrace(PTRACE_FAULTINFO, pid, 0, &fault); 46 err = ptrace(PTRACE_FAULTINFO, pid, 0, fi);
46 if(err) 47 if(err)
47 panic("handle_segv - PTRACE_FAULTINFO failed, errno = %d\n", 48 panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, "
48 errno); 49 "errno = %d\n", errno);
50
51 /* Special handling for i386, which has different structs */
52 if (sizeof(struct ptrace_faultinfo) < sizeof(struct faultinfo))
53 memset((char *)fi + sizeof(struct ptrace_faultinfo), 0,
54 sizeof(struct faultinfo) -
55 sizeof(struct ptrace_faultinfo));
56}
49 57
50 segv(fault.addr, 0, FAULT_WRITE(fault.is_write), 1, NULL); 58static void handle_segv(int pid, union uml_pt_regs * regs)
59{
60 get_skas_faultinfo(pid, &regs->skas.faultinfo);
61 segv(regs->skas.faultinfo, 0, 1, NULL);
51} 62}
52 63
53/*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/ 64/*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/
@@ -163,7 +174,7 @@ void userspace(union uml_pt_regs *regs)
163 if(WIFSTOPPED(status)){ 174 if(WIFSTOPPED(status)){
164 switch(WSTOPSIG(status)){ 175 switch(WSTOPSIG(status)){
165 case SIGSEGV: 176 case SIGSEGV:
166 handle_segv(pid); 177 handle_segv(pid, regs);
167 break; 178 break;
168 case SIGTRAP + 0x80: 179 case SIGTRAP + 0x80:
169 handle_trap(pid, regs, local_using_sysemu); 180 handle_trap(pid, regs, local_using_sysemu);
@@ -177,7 +188,7 @@ void userspace(union uml_pt_regs *regs)
177 case SIGBUS: 188 case SIGBUS:
178 case SIGFPE: 189 case SIGFPE:
179 case SIGWINCH: 190 case SIGWINCH:
180 user_signal(WSTOPSIG(status), regs); 191 user_signal(WSTOPSIG(status), regs, pid);
181 break; 192 break;
182 default: 193 default:
183 printk("userspace - child stopped with signal " 194 printk("userspace - child stopped with signal "
@@ -190,6 +201,11 @@ void userspace(union uml_pt_regs *regs)
190 } 201 }
191 } 202 }
192} 203}
204#define INIT_JMP_NEW_THREAD 0
205#define INIT_JMP_REMOVE_SIGSTACK 1
206#define INIT_JMP_CALLBACK 2
207#define INIT_JMP_HALT 3
208#define INIT_JMP_REBOOT 4
193 209
194void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, 210void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
195 void (*handler)(int)) 211 void (*handler)(int))
@@ -225,7 +241,7 @@ void thread_wait(void *sw, void *fb)
225 *switch_buf = &buf; 241 *switch_buf = &buf;
226 fork_buf = fb; 242 fork_buf = fb;
227 if(sigsetjmp(buf, 1) == 0) 243 if(sigsetjmp(buf, 1) == 0)
228 siglongjmp(*fork_buf, 1); 244 siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK);
229} 245}
230 246
231void switch_threads(void *me, void *next) 247void switch_threads(void *me, void *next)
@@ -249,23 +265,31 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
249 sigjmp_buf **switch_buf = switch_buf_ptr; 265 sigjmp_buf **switch_buf = switch_buf_ptr;
250 int n; 266 int n;
251 267
268 set_handler(SIGWINCH, (__sighandler_t) sig_handler,
269 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM,
270 SIGVTALRM, -1);
271
252 *fork_buf_ptr = &initial_jmpbuf; 272 *fork_buf_ptr = &initial_jmpbuf;
253 n = sigsetjmp(initial_jmpbuf, 1); 273 n = sigsetjmp(initial_jmpbuf, 1);
254 if(n == 0) 274 switch(n){
255 new_thread_proc((void *) stack, new_thread_handler); 275 case INIT_JMP_NEW_THREAD:
256 else if(n == 1) 276 new_thread_proc((void *) stack, new_thread_handler);
257 remove_sigstack(); 277 break;
258 else if(n == 2){ 278 case INIT_JMP_REMOVE_SIGSTACK:
279 remove_sigstack();
280 break;
281 case INIT_JMP_CALLBACK:
259 (*cb_proc)(cb_arg); 282 (*cb_proc)(cb_arg);
260 siglongjmp(*cb_back, 1); 283 siglongjmp(*cb_back, 1);
261 } 284 break;
262 else if(n == 3){ 285 case INIT_JMP_HALT:
263 kmalloc_ok = 0; 286 kmalloc_ok = 0;
264 return(0); 287 return(0);
265 } 288 case INIT_JMP_REBOOT:
266 else if(n == 4){
267 kmalloc_ok = 0; 289 kmalloc_ok = 0;
268 return(1); 290 return(1);
291 default:
292 panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
269 } 293 }
270 siglongjmp(**switch_buf, 1); 294 siglongjmp(**switch_buf, 1);
271} 295}
@@ -290,7 +314,7 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
290 314
291 block_signals(); 315 block_signals();
292 if(sigsetjmp(here, 1) == 0) 316 if(sigsetjmp(here, 1) == 0)
293 siglongjmp(initial_jmpbuf, 2); 317 siglongjmp(initial_jmpbuf, INIT_JMP_CALLBACK);
294 unblock_signals(); 318 unblock_signals();
295 319
296 cb_proc = NULL; 320 cb_proc = NULL;
@@ -301,13 +325,13 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
301void halt_skas(void) 325void halt_skas(void)
302{ 326{
303 block_signals(); 327 block_signals();
304 siglongjmp(initial_jmpbuf, 3); 328 siglongjmp(initial_jmpbuf, INIT_JMP_HALT);
305} 329}
306 330
307void reboot_skas(void) 331void reboot_skas(void)
308{ 332{
309 block_signals(); 333 block_signals();
310 siglongjmp(initial_jmpbuf, 4); 334 siglongjmp(initial_jmpbuf, INIT_JMP_REBOOT);
311} 335}
312 336
313void switch_mm_skas(int mm_fd) 337void switch_mm_skas(int mm_fd)
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index 5d096ea63b97..ab5d3271da0b 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -83,10 +83,6 @@ void release_thread_skas(struct task_struct *task)
83{ 83{
84} 84}
85 85
86void exit_thread_skas(void)
87{
88}
89
90void fork_handler(int sig) 86void fork_handler(int sig)
91{ 87{
92 change_sig(SIGUSR1, 1); 88 change_sig(SIGUSR1, 1);
diff --git a/arch/um/kernel/skas/trap_user.c b/arch/um/kernel/skas/trap_user.c
index 8e9b46d4702e..0dee1d95c806 100644
--- a/arch/um/kernel/skas/trap_user.c
+++ b/arch/um/kernel/skas/trap_user.c
@@ -5,12 +5,15 @@
5 5
6#include <signal.h> 6#include <signal.h>
7#include <errno.h> 7#include <errno.h>
8#include "sysdep/ptrace.h"
9#include "signal_user.h" 8#include "signal_user.h"
10#include "user_util.h" 9#include "user_util.h"
11#include "kern_util.h" 10#include "kern_util.h"
12#include "task.h" 11#include "task.h"
13#include "sigcontext.h" 12#include "sigcontext.h"
13#include "skas.h"
14#include "ptrace_user.h"
15#include "sysdep/ptrace.h"
16#include "sysdep/ptrace_user.h"
14 17
15void sig_handler_common_skas(int sig, void *sc_ptr) 18void sig_handler_common_skas(int sig, void *sc_ptr)
16{ 19{
@@ -31,9 +34,11 @@ void sig_handler_common_skas(int sig, void *sc_ptr)
31 r = &TASK_REGS(get_current())->skas; 34 r = &TASK_REGS(get_current())->skas;
32 save_user = r->is_user; 35 save_user = r->is_user;
33 r->is_user = 0; 36 r->is_user = 0;
34 r->fault_addr = SC_FAULT_ADDR(sc); 37 if ( sig == SIGFPE || sig == SIGSEGV ||
35 r->fault_type = SC_FAULT_TYPE(sc); 38 sig == SIGBUS || sig == SIGILL ||
36 r->trap_type = SC_TRAP_TYPE(sc); 39 sig == SIGTRAP ) {
40 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
41 }
37 42
38 change_sig(SIGUSR1, 1); 43 change_sig(SIGUSR1, 1);
39 info = &sig_info[sig]; 44 info = &sig_info[sig];
@@ -45,14 +50,17 @@ void sig_handler_common_skas(int sig, void *sc_ptr)
45 r->is_user = save_user; 50 r->is_user = save_user;
46} 51}
47 52
48void user_signal(int sig, union uml_pt_regs *regs) 53extern int ptrace_faultinfo;
54
55void user_signal(int sig, union uml_pt_regs *regs, int pid)
49{ 56{
50 struct signal_info *info; 57 struct signal_info *info;
58 int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
59 (sig == SIGILL) || (sig == SIGTRAP));
51 60
52 regs->skas.is_user = 1; 61 regs->skas.is_user = 1;
53 regs->skas.fault_addr = 0; 62 if (segv)
54 regs->skas.fault_type = 0; 63 get_skas_faultinfo(pid, &regs->skas.faultinfo);
55 regs->skas.trap_type = 0;
56 info = &sig_info[sig]; 64 info = &sig_info[sig];
57 (*info->handler)(sig, regs); 65 (*info->handler)(sig, regs);
58 66
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index 7575ec489b63..75195281081e 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -3,6 +3,7 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/compiler.h"
6#include "linux/stddef.h" 7#include "linux/stddef.h"
7#include "linux/kernel.h" 8#include "linux/kernel.h"
8#include "linux/string.h" 9#include "linux/string.h"
@@ -28,9 +29,12 @@ static unsigned long maybe_map(unsigned long virt, int is_write)
28 if(IS_ERR(phys) || (is_write && !pte_write(pte))){ 29 if(IS_ERR(phys) || (is_write && !pte_write(pte))){
29 err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); 30 err = handle_page_fault(virt, 0, is_write, 1, &dummy_code);
30 if(err) 31 if(err)
31 return(0); 32 return(-1UL);
32 phys = um_virt_to_phys(current, virt, NULL); 33 phys = um_virt_to_phys(current, virt, NULL);
33 } 34 }
35 if(IS_ERR(phys))
36 phys = (void *) -1;
37
34 return((unsigned long) phys); 38 return((unsigned long) phys);
35} 39}
36 40
@@ -41,7 +45,7 @@ static int do_op(unsigned long addr, int len, int is_write,
41 int n; 45 int n;
42 46
43 addr = maybe_map(addr, is_write); 47 addr = maybe_map(addr, is_write);
44 if(addr == -1) 48 if(addr == -1UL)
45 return(-1); 49 return(-1);
46 50
47 page = phys_to_page(addr); 51 page = phys_to_page(addr);
@@ -61,8 +65,7 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr)
61 void *arg; 65 void *arg;
62 int *res; 66 int *res;
63 67
64 /* Some old gccs recognize __va_copy, but not va_copy */ 68 va_copy(args, *(va_list *)arg_ptr);
65 __va_copy(args, *(va_list *)arg_ptr);
66 addr = va_arg(args, unsigned long); 69 addr = va_arg(args, unsigned long);
67 len = va_arg(args, int); 70 len = va_arg(args, int);
68 is_write = va_arg(args, int); 71 is_write = va_arg(args, int);
diff --git a/arch/um/kernel/skas/util/Makefile b/arch/um/kernel/skas/util/Makefile
index 17f5909d60f7..f7b7eba83340 100644
--- a/arch/um/kernel/skas/util/Makefile
+++ b/arch/um/kernel/skas/util/Makefile
@@ -2,3 +2,4 @@ hostprogs-y := mk_ptregs
2always := $(hostprogs-y) 2always := $(hostprogs-y)
3 3
4mk_ptregs-objs := mk_ptregs-$(SUBARCH).o 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
index 0788dd05bcac..1f96e1eeb8a7 100644
--- a/arch/um/kernel/skas/util/mk_ptregs-i386.c
+++ b/arch/um/kernel/skas/util/mk_ptregs-i386.c
@@ -1,8 +1,7 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <asm/ptrace.h> 2#include <user-offsets.h>
3#include <asm/user.h>
4 3
5#define PRINT_REG(name, val) printf("#define HOST_%s %d\n", (name), (val)) 4#define SHOW(name) printf("#define %s %d\n", #name, name)
6 5
7int main(int argc, char **argv) 6int main(int argc, char **argv)
8{ 7{
@@ -12,28 +11,27 @@ int main(int argc, char **argv)
12 printf("#ifndef __SKAS_PT_REGS_\n"); 11 printf("#ifndef __SKAS_PT_REGS_\n");
13 printf("#define __SKAS_PT_REGS_\n"); 12 printf("#define __SKAS_PT_REGS_\n");
14 printf("\n"); 13 printf("\n");
15 printf("#define HOST_FRAME_SIZE %d\n", FRAME_SIZE); 14 SHOW(HOST_FRAME_SIZE);
16 printf("#define HOST_FP_SIZE %d\n", 15 SHOW(HOST_FP_SIZE);
17 sizeof(struct user_i387_struct) / sizeof(unsigned long)); 16 SHOW(HOST_XFP_SIZE);
18 printf("#define HOST_XFP_SIZE %d\n", 17
19 sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); 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);
20 34
21 PRINT_REG("IP", EIP);
22 PRINT_REG("SP", UESP);
23 PRINT_REG("EFLAGS", EFL);
24 PRINT_REG("EAX", EAX);
25 PRINT_REG("EBX", EBX);
26 PRINT_REG("ECX", ECX);
27 PRINT_REG("EDX", EDX);
28 PRINT_REG("ESI", ESI);
29 PRINT_REG("EDI", EDI);
30 PRINT_REG("EBP", EBP);
31 PRINT_REG("CS", CS);
32 PRINT_REG("SS", SS);
33 PRINT_REG("DS", DS);
34 PRINT_REG("FS", FS);
35 PRINT_REG("ES", ES);
36 PRINT_REG("GS", GS);
37 printf("\n"); 35 printf("\n");
38 printf("#endif\n"); 36 printf("#endif\n");
39 return(0); 37 return(0);
diff --git a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c
index 67aee92a70ef..5fccbfe35f78 100644
--- a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c
+++ b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c
@@ -5,11 +5,10 @@
5 */ 5 */
6 6
7#include <stdio.h> 7#include <stdio.h>
8#define __FRAME_OFFSETS 8#include <user-offsets.h>
9#include <asm/ptrace.h>
10 9
11#define PRINT_REG(name, val) \ 10#define SHOW(name) \
12 printf("#define HOST_%s (%d / sizeof(unsigned long))\n", (name), (val)) 11 printf("#define %s (%d / sizeof(unsigned long))\n", #name, name)
13 12
14int main(int argc, char **argv) 13int main(int argc, char **argv)
15{ 14{
@@ -18,36 +17,35 @@ int main(int argc, char **argv)
18 printf("\n"); 17 printf("\n");
19 printf("#ifndef __SKAS_PT_REGS_\n"); 18 printf("#ifndef __SKAS_PT_REGS_\n");
20 printf("#define __SKAS_PT_REGS_\n"); 19 printf("#define __SKAS_PT_REGS_\n");
21 printf("#define HOST_FRAME_SIZE (%d / sizeof(unsigned long))\n", 20 SHOW(HOST_FRAME_SIZE);
22 FRAME_SIZE); 21 SHOW(HOST_RBX);
23 PRINT_REG("RBX", RBX); 22 SHOW(HOST_RCX);
24 PRINT_REG("RCX", RCX); 23 SHOW(HOST_RDI);
25 PRINT_REG("RDI", RDI); 24 SHOW(HOST_RSI);
26 PRINT_REG("RSI", RSI); 25 SHOW(HOST_RDX);
27 PRINT_REG("RDX", RDX); 26 SHOW(HOST_RBP);
28 PRINT_REG("RBP", RBP); 27 SHOW(HOST_RAX);
29 PRINT_REG("RAX", RAX); 28 SHOW(HOST_R8);
30 PRINT_REG("R8", R8); 29 SHOW(HOST_R9);
31 PRINT_REG("R9", R9); 30 SHOW(HOST_R10);
32 PRINT_REG("R10", R10); 31 SHOW(HOST_R11);
33 PRINT_REG("R11", R11); 32 SHOW(HOST_R12);
34 PRINT_REG("R12", R12); 33 SHOW(HOST_R13);
35 PRINT_REG("R13", R13); 34 SHOW(HOST_R14);
36 PRINT_REG("R14", R14); 35 SHOW(HOST_R15);
37 PRINT_REG("R15", R15); 36 SHOW(HOST_ORIG_RAX);
38 PRINT_REG("ORIG_RAX", ORIG_RAX); 37 SHOW(HOST_CS);
39 PRINT_REG("CS", CS); 38 SHOW(HOST_SS);
40 PRINT_REG("SS", SS); 39 SHOW(HOST_EFLAGS);
41 PRINT_REG("EFLAGS", EFLAGS);
42#if 0 40#if 0
43 PRINT_REG("FS", FS); 41 SHOW(HOST_FS);
44 PRINT_REG("GS", GS); 42 SHOW(HOST_GS);
45 PRINT_REG("DS", DS); 43 SHOW(HOST_DS);
46 PRINT_REG("ES", ES); 44 SHOW(HOST_ES);
47#endif 45#endif
48 46
49 PRINT_REG("IP", RIP); 47 SHOW(HOST_IP);
50 PRINT_REG("SP", RSP); 48 SHOW(HOST_SP);
51 printf("#define HOST_FP_SIZE 0\n"); 49 printf("#define HOST_FP_SIZE 0\n");
52 printf("#define HOST_XFP_SIZE 0\n"); 50 printf("#define HOST_XFP_SIZE 0\n");
53 printf("\n"); 51 printf("\n");
diff --git a/arch/um/kernel/sys_call_table.c b/arch/um/kernel/sys_call_table.c
deleted file mode 100644
index 7fc06c85b29d..000000000000
--- a/arch/um/kernel/sys_call_table.c
+++ /dev/null
@@ -1,276 +0,0 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
5 */
6
7#include "linux/config.h"
8#include "linux/unistd.h"
9#include "linux/sys.h"
10#include "linux/swap.h"
11#include "linux/syscalls.h"
12#include "linux/sysctl.h"
13#include "asm/signal.h"
14#include "sysdep/syscalls.h"
15#include "kern_util.h"
16
17#ifdef CONFIG_NFSD
18#define NFSSERVCTL sys_nfsservctl
19#else
20#define NFSSERVCTL sys_ni_syscall
21#endif
22
23#define LAST_GENERIC_SYSCALL __NR_keyctl
24
25#if LAST_GENERIC_SYSCALL > LAST_ARCH_SYSCALL
26#define LAST_SYSCALL LAST_GENERIC_SYSCALL
27#else
28#define LAST_SYSCALL LAST_ARCH_SYSCALL
29#endif
30
31extern syscall_handler_t sys_fork;
32extern syscall_handler_t sys_execve;
33extern syscall_handler_t um_time;
34extern syscall_handler_t um_stime;
35extern syscall_handler_t sys_pipe;
36extern syscall_handler_t sys_olduname;
37extern syscall_handler_t sys_sigaction;
38extern syscall_handler_t sys_sigsuspend;
39extern syscall_handler_t old_readdir;
40extern syscall_handler_t sys_uname;
41extern syscall_handler_t sys_ipc;
42extern syscall_handler_t sys_sigreturn;
43extern syscall_handler_t sys_clone;
44extern syscall_handler_t sys_rt_sigreturn;
45extern syscall_handler_t sys_sigaltstack;
46extern syscall_handler_t sys_vfork;
47extern syscall_handler_t old_select;
48extern syscall_handler_t sys_modify_ldt;
49extern syscall_handler_t sys_rt_sigsuspend;
50extern syscall_handler_t sys_mbind;
51extern syscall_handler_t sys_get_mempolicy;
52extern syscall_handler_t sys_set_mempolicy;
53extern syscall_handler_t sys_sys_setaltroot;
54
55syscall_handler_t *sys_call_table[] = {
56 [ __NR_restart_syscall ] = (syscall_handler_t *) sys_restart_syscall,
57 [ __NR_exit ] = (syscall_handler_t *) sys_exit,
58 [ __NR_fork ] = (syscall_handler_t *) sys_fork,
59 [ __NR_read ] = (syscall_handler_t *) sys_read,
60 [ __NR_write ] = (syscall_handler_t *) sys_write,
61
62 /* These three are declared differently in asm/unistd.h */
63 [ __NR_open ] = (syscall_handler_t *) sys_open,
64 [ __NR_close ] = (syscall_handler_t *) sys_close,
65 [ __NR_creat ] = (syscall_handler_t *) sys_creat,
66 [ __NR_link ] = (syscall_handler_t *) sys_link,
67 [ __NR_unlink ] = (syscall_handler_t *) sys_unlink,
68 [ __NR_execve ] = (syscall_handler_t *) sys_execve,
69
70 /* declared differently in kern_util.h */
71 [ __NR_chdir ] = (syscall_handler_t *) sys_chdir,
72 [ __NR_time ] = um_time,
73 [ __NR_mknod ] = (syscall_handler_t *) sys_mknod,
74 [ __NR_chmod ] = (syscall_handler_t *) sys_chmod,
75 [ __NR_lchown ] = (syscall_handler_t *) sys_lchown16,
76 [ __NR_lseek ] = (syscall_handler_t *) sys_lseek,
77 [ __NR_getpid ] = (syscall_handler_t *) sys_getpid,
78 [ __NR_mount ] = (syscall_handler_t *) sys_mount,
79 [ __NR_setuid ] = (syscall_handler_t *) sys_setuid16,
80 [ __NR_getuid ] = (syscall_handler_t *) sys_getuid16,
81 [ __NR_ptrace ] = (syscall_handler_t *) sys_ptrace,
82 [ __NR_alarm ] = (syscall_handler_t *) sys_alarm,
83 [ __NR_pause ] = (syscall_handler_t *) sys_pause,
84 [ __NR_utime ] = (syscall_handler_t *) sys_utime,
85 [ __NR_access ] = (syscall_handler_t *) sys_access,
86 [ __NR_sync ] = (syscall_handler_t *) sys_sync,
87 [ __NR_kill ] = (syscall_handler_t *) sys_kill,
88 [ __NR_rename ] = (syscall_handler_t *) sys_rename,
89 [ __NR_mkdir ] = (syscall_handler_t *) sys_mkdir,
90 [ __NR_rmdir ] = (syscall_handler_t *) sys_rmdir,
91
92 /* Declared differently in asm/unistd.h */
93 [ __NR_dup ] = (syscall_handler_t *) sys_dup,
94 [ __NR_pipe ] = (syscall_handler_t *) sys_pipe,
95 [ __NR_times ] = (syscall_handler_t *) sys_times,
96 [ __NR_brk ] = (syscall_handler_t *) sys_brk,
97 [ __NR_setgid ] = (syscall_handler_t *) sys_setgid16,
98 [ __NR_getgid ] = (syscall_handler_t *) sys_getgid16,
99 [ __NR_geteuid ] = (syscall_handler_t *) sys_geteuid16,
100 [ __NR_getegid ] = (syscall_handler_t *) sys_getegid16,
101 [ __NR_acct ] = (syscall_handler_t *) sys_acct,
102 [ __NR_umount2 ] = (syscall_handler_t *) sys_umount,
103 [ __NR_ioctl ] = (syscall_handler_t *) sys_ioctl,
104 [ __NR_fcntl ] = (syscall_handler_t *) sys_fcntl,
105 [ __NR_setpgid ] = (syscall_handler_t *) sys_setpgid,
106 [ __NR_umask ] = (syscall_handler_t *) sys_umask,
107 [ __NR_chroot ] = (syscall_handler_t *) sys_chroot,
108 [ __NR_ustat ] = (syscall_handler_t *) sys_ustat,
109 [ __NR_dup2 ] = (syscall_handler_t *) sys_dup2,
110 [ __NR_getppid ] = (syscall_handler_t *) sys_getppid,
111 [ __NR_getpgrp ] = (syscall_handler_t *) sys_getpgrp,
112 [ __NR_setsid ] = (syscall_handler_t *) sys_setsid,
113 [ __NR_setreuid ] = (syscall_handler_t *) sys_setreuid16,
114 [ __NR_setregid ] = (syscall_handler_t *) sys_setregid16,
115 [ __NR_sethostname ] = (syscall_handler_t *) sys_sethostname,
116 [ __NR_setrlimit ] = (syscall_handler_t *) sys_setrlimit,
117 [ __NR_getrlimit ] = (syscall_handler_t *) sys_old_getrlimit,
118 [ __NR_getrusage ] = (syscall_handler_t *) sys_getrusage,
119 [ __NR_gettimeofday ] = (syscall_handler_t *) sys_gettimeofday,
120 [ __NR_settimeofday ] = (syscall_handler_t *) sys_settimeofday,
121 [ __NR_getgroups ] = (syscall_handler_t *) sys_getgroups16,
122 [ __NR_setgroups ] = (syscall_handler_t *) sys_setgroups16,
123 [ __NR_symlink ] = (syscall_handler_t *) sys_symlink,
124 [ __NR_readlink ] = (syscall_handler_t *) sys_readlink,
125 [ __NR_uselib ] = (syscall_handler_t *) sys_uselib,
126 [ __NR_swapon ] = (syscall_handler_t *) sys_swapon,
127 [ __NR_reboot ] = (syscall_handler_t *) sys_reboot,
128 [ __NR_munmap ] = (syscall_handler_t *) sys_munmap,
129 [ __NR_truncate ] = (syscall_handler_t *) sys_truncate,
130 [ __NR_ftruncate ] = (syscall_handler_t *) sys_ftruncate,
131 [ __NR_fchmod ] = (syscall_handler_t *) sys_fchmod,
132 [ __NR_fchown ] = (syscall_handler_t *) sys_fchown16,
133 [ __NR_getpriority ] = (syscall_handler_t *) sys_getpriority,
134 [ __NR_setpriority ] = (syscall_handler_t *) sys_setpriority,
135 [ __NR_statfs ] = (syscall_handler_t *) sys_statfs,
136 [ __NR_fstatfs ] = (syscall_handler_t *) sys_fstatfs,
137 [ __NR_ioperm ] = (syscall_handler_t *) sys_ni_syscall,
138 [ __NR_syslog ] = (syscall_handler_t *) sys_syslog,
139 [ __NR_setitimer ] = (syscall_handler_t *) sys_setitimer,
140 [ __NR_getitimer ] = (syscall_handler_t *) sys_getitimer,
141 [ __NR_stat ] = (syscall_handler_t *) sys_newstat,
142 [ __NR_lstat ] = (syscall_handler_t *) sys_newlstat,
143 [ __NR_fstat ] = (syscall_handler_t *) sys_newfstat,
144 [ __NR_vhangup ] = (syscall_handler_t *) sys_vhangup,
145 [ __NR_wait4 ] = (syscall_handler_t *) sys_wait4,
146 [ __NR_swapoff ] = (syscall_handler_t *) sys_swapoff,
147 [ __NR_sysinfo ] = (syscall_handler_t *) sys_sysinfo,
148 [ __NR_fsync ] = (syscall_handler_t *) sys_fsync,
149 [ __NR_clone ] = (syscall_handler_t *) sys_clone,
150 [ __NR_setdomainname ] = (syscall_handler_t *) sys_setdomainname,
151 [ __NR_uname ] = (syscall_handler_t *) sys_newuname,
152 [ __NR_adjtimex ] = (syscall_handler_t *) sys_adjtimex,
153 [ __NR_mprotect ] = (syscall_handler_t *) sys_mprotect,
154 [ __NR_create_module ] = (syscall_handler_t *) sys_ni_syscall,
155 [ __NR_init_module ] = (syscall_handler_t *) sys_init_module,
156 [ __NR_delete_module ] = (syscall_handler_t *) sys_delete_module,
157 [ __NR_get_kernel_syms ] = (syscall_handler_t *) sys_ni_syscall,
158 [ __NR_quotactl ] = (syscall_handler_t *) sys_quotactl,
159 [ __NR_getpgid ] = (syscall_handler_t *) sys_getpgid,
160 [ __NR_fchdir ] = (syscall_handler_t *) sys_fchdir,
161 [ __NR_sysfs ] = (syscall_handler_t *) sys_sysfs,
162 [ __NR_personality ] = (syscall_handler_t *) sys_personality,
163 [ __NR_afs_syscall ] = (syscall_handler_t *) sys_ni_syscall,
164 [ __NR_setfsuid ] = (syscall_handler_t *) sys_setfsuid16,
165 [ __NR_setfsgid ] = (syscall_handler_t *) sys_setfsgid16,
166 [ __NR_getdents ] = (syscall_handler_t *) sys_getdents,
167 [ __NR_flock ] = (syscall_handler_t *) sys_flock,
168 [ __NR_msync ] = (syscall_handler_t *) sys_msync,
169 [ __NR_readv ] = (syscall_handler_t *) sys_readv,
170 [ __NR_writev ] = (syscall_handler_t *) sys_writev,
171 [ __NR_getsid ] = (syscall_handler_t *) sys_getsid,
172 [ __NR_fdatasync ] = (syscall_handler_t *) sys_fdatasync,
173 [ __NR__sysctl ] = (syscall_handler_t *) sys_sysctl,
174 [ __NR_mlock ] = (syscall_handler_t *) sys_mlock,
175 [ __NR_munlock ] = (syscall_handler_t *) sys_munlock,
176 [ __NR_mlockall ] = (syscall_handler_t *) sys_mlockall,
177 [ __NR_munlockall ] = (syscall_handler_t *) sys_munlockall,
178 [ __NR_sched_setparam ] = (syscall_handler_t *) sys_sched_setparam,
179 [ __NR_sched_getparam ] = (syscall_handler_t *) sys_sched_getparam,
180 [ __NR_sched_setscheduler ] = (syscall_handler_t *) sys_sched_setscheduler,
181 [ __NR_sched_getscheduler ] = (syscall_handler_t *) sys_sched_getscheduler,
182 [ __NR_sched_yield ] = (syscall_handler_t *) yield,
183 [ __NR_sched_get_priority_max ] = (syscall_handler_t *) sys_sched_get_priority_max,
184 [ __NR_sched_get_priority_min ] = (syscall_handler_t *) sys_sched_get_priority_min,
185 [ __NR_sched_rr_get_interval ] = (syscall_handler_t *) sys_sched_rr_get_interval,
186 [ __NR_nanosleep ] = (syscall_handler_t *) sys_nanosleep,
187 [ __NR_mremap ] = (syscall_handler_t *) sys_mremap,
188 [ __NR_setresuid ] = (syscall_handler_t *) sys_setresuid16,
189 [ __NR_getresuid ] = (syscall_handler_t *) sys_getresuid16,
190 [ __NR_query_module ] = (syscall_handler_t *) sys_ni_syscall,
191 [ __NR_poll ] = (syscall_handler_t *) sys_poll,
192 [ __NR_nfsservctl ] = (syscall_handler_t *) NFSSERVCTL,
193 [ __NR_setresgid ] = (syscall_handler_t *) sys_setresgid16,
194 [ __NR_getresgid ] = (syscall_handler_t *) sys_getresgid16,
195 [ __NR_prctl ] = (syscall_handler_t *) sys_prctl,
196 [ __NR_rt_sigreturn ] = (syscall_handler_t *) sys_rt_sigreturn,
197 [ __NR_rt_sigaction ] = (syscall_handler_t *) sys_rt_sigaction,
198 [ __NR_rt_sigprocmask ] = (syscall_handler_t *) sys_rt_sigprocmask,
199 [ __NR_rt_sigpending ] = (syscall_handler_t *) sys_rt_sigpending,
200 [ __NR_rt_sigtimedwait ] = (syscall_handler_t *) sys_rt_sigtimedwait,
201 [ __NR_rt_sigqueueinfo ] = (syscall_handler_t *) sys_rt_sigqueueinfo,
202 [ __NR_rt_sigsuspend ] = (syscall_handler_t *) sys_rt_sigsuspend,
203 [ __NR_pread64 ] = (syscall_handler_t *) sys_pread64,
204 [ __NR_pwrite64 ] = (syscall_handler_t *) sys_pwrite64,
205 [ __NR_chown ] = (syscall_handler_t *) sys_chown16,
206 [ __NR_getcwd ] = (syscall_handler_t *) sys_getcwd,
207 [ __NR_capget ] = (syscall_handler_t *) sys_capget,
208 [ __NR_capset ] = (syscall_handler_t *) sys_capset,
209 [ __NR_sigaltstack ] = (syscall_handler_t *) sys_sigaltstack,
210 [ __NR_sendfile ] = (syscall_handler_t *) sys_sendfile,
211 [ __NR_getpmsg ] = (syscall_handler_t *) sys_ni_syscall,
212 [ __NR_putpmsg ] = (syscall_handler_t *) sys_ni_syscall,
213 [ __NR_vfork ] = (syscall_handler_t *) sys_vfork,
214 [ __NR_getdents64 ] = (syscall_handler_t *) sys_getdents64,
215 [ __NR_gettid ] = (syscall_handler_t *) sys_gettid,
216 [ __NR_readahead ] = (syscall_handler_t *) sys_readahead,
217 [ __NR_setxattr ] = (syscall_handler_t *) sys_setxattr,
218 [ __NR_lsetxattr ] = (syscall_handler_t *) sys_lsetxattr,
219 [ __NR_fsetxattr ] = (syscall_handler_t *) sys_fsetxattr,
220 [ __NR_getxattr ] = (syscall_handler_t *) sys_getxattr,
221 [ __NR_lgetxattr ] = (syscall_handler_t *) sys_lgetxattr,
222 [ __NR_fgetxattr ] = (syscall_handler_t *) sys_fgetxattr,
223 [ __NR_listxattr ] = (syscall_handler_t *) sys_listxattr,
224 [ __NR_llistxattr ] = (syscall_handler_t *) sys_llistxattr,
225 [ __NR_flistxattr ] = (syscall_handler_t *) sys_flistxattr,
226 [ __NR_removexattr ] = (syscall_handler_t *) sys_removexattr,
227 [ __NR_lremovexattr ] = (syscall_handler_t *) sys_lremovexattr,
228 [ __NR_fremovexattr ] = (syscall_handler_t *) sys_fremovexattr,
229 [ __NR_tkill ] = (syscall_handler_t *) sys_tkill,
230 [ __NR_futex ] = (syscall_handler_t *) sys_futex,
231 [ __NR_sched_setaffinity ] = (syscall_handler_t *) sys_sched_setaffinity,
232 [ __NR_sched_getaffinity ] = (syscall_handler_t *) sys_sched_getaffinity,
233 [ __NR_io_setup ] = (syscall_handler_t *) sys_io_setup,
234 [ __NR_io_destroy ] = (syscall_handler_t *) sys_io_destroy,
235 [ __NR_io_getevents ] = (syscall_handler_t *) sys_io_getevents,
236 [ __NR_io_submit ] = (syscall_handler_t *) sys_io_submit,
237 [ __NR_io_cancel ] = (syscall_handler_t *) sys_io_cancel,
238 [ __NR_exit_group ] = (syscall_handler_t *) sys_exit_group,
239 [ __NR_lookup_dcookie ] = (syscall_handler_t *) sys_lookup_dcookie,
240 [ __NR_epoll_create ] = (syscall_handler_t *) sys_epoll_create,
241 [ __NR_epoll_ctl ] = (syscall_handler_t *) sys_epoll_ctl,
242 [ __NR_epoll_wait ] = (syscall_handler_t *) sys_epoll_wait,
243 [ __NR_remap_file_pages ] = (syscall_handler_t *) sys_remap_file_pages,
244 [ __NR_set_tid_address ] = (syscall_handler_t *) sys_set_tid_address,
245 [ __NR_timer_create ] = (syscall_handler_t *) sys_timer_create,
246 [ __NR_timer_settime ] = (syscall_handler_t *) sys_timer_settime,
247 [ __NR_timer_gettime ] = (syscall_handler_t *) sys_timer_gettime,
248 [ __NR_timer_getoverrun ] = (syscall_handler_t *) sys_timer_getoverrun,
249 [ __NR_timer_delete ] = (syscall_handler_t *) sys_timer_delete,
250 [ __NR_clock_settime ] = (syscall_handler_t *) sys_clock_settime,
251 [ __NR_clock_gettime ] = (syscall_handler_t *) sys_clock_gettime,
252 [ __NR_clock_getres ] = (syscall_handler_t *) sys_clock_getres,
253 [ __NR_clock_nanosleep ] = (syscall_handler_t *) sys_clock_nanosleep,
254 [ __NR_tgkill ] = (syscall_handler_t *) sys_tgkill,
255 [ __NR_utimes ] = (syscall_handler_t *) sys_utimes,
256 [ __NR_fadvise64 ] = (syscall_handler_t *) sys_fadvise64,
257 [ __NR_vserver ] = (syscall_handler_t *) sys_ni_syscall,
258 [ __NR_mbind ] = (syscall_handler_t *) sys_mbind,
259 [ __NR_get_mempolicy ] = (syscall_handler_t *) sys_get_mempolicy,
260 [ __NR_set_mempolicy ] = (syscall_handler_t *) sys_set_mempolicy,
261 [ __NR_mq_open ] = (syscall_handler_t *) sys_mq_open,
262 [ __NR_mq_unlink ] = (syscall_handler_t *) sys_mq_unlink,
263 [ __NR_mq_timedsend ] = (syscall_handler_t *) sys_mq_timedsend,
264 [ __NR_mq_timedreceive ] = (syscall_handler_t *) sys_mq_timedreceive,
265 [ __NR_mq_notify ] = (syscall_handler_t *) sys_mq_notify,
266 [ __NR_mq_getsetattr ] = (syscall_handler_t *) sys_mq_getsetattr,
267 [ __NR_kexec_load ] = (syscall_handler_t *) sys_ni_syscall,
268 [ __NR_waitid ] = (syscall_handler_t *) sys_waitid,
269 [ __NR_add_key ] = (syscall_handler_t *) sys_add_key,
270 [ __NR_request_key ] = (syscall_handler_t *) sys_request_key,
271 [ __NR_keyctl ] = (syscall_handler_t *) sys_keyctl,
272
273 ARCH_SYSCALLS
274 [ LAST_SYSCALL + 1 ... NR_syscalls ] =
275 (syscall_handler_t *) sys_ni_syscall
276};
diff --git a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c
index 42731e04f50f..b7a55251e897 100644
--- a/arch/um/kernel/syscall_kern.c
+++ b/arch/um/kernel/syscall_kern.c
@@ -17,7 +17,6 @@
17#include "linux/utime.h" 17#include "linux/utime.h"
18#include "asm/mman.h" 18#include "asm/mman.h"
19#include "asm/uaccess.h" 19#include "asm/uaccess.h"
20#include "asm/ipc.h"
21#include "kern_util.h" 20#include "kern_util.h"
22#include "user_util.h" 21#include "user_util.h"
23#include "sysdep/syscalls.h" 22#include "sysdep/syscalls.h"
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c
index 2461cd73ca87..6516fc52afe0 100644
--- a/arch/um/kernel/time_kern.c
+++ b/arch/um/kernel/time_kern.c
@@ -48,8 +48,6 @@ static unsigned long long prev_usecs;
48static long long delta; /* Deviation per interval */ 48static long long delta; /* Deviation per interval */
49#endif 49#endif
50 50
51#define MILLION 1000000
52
53void timer_irq(union uml_pt_regs *regs) 51void timer_irq(union uml_pt_regs *regs)
54{ 52{
55 unsigned long long ticks = 0; 53 unsigned long long ticks = 0;
@@ -136,22 +134,6 @@ long um_stime(int __user *tptr)
136 return 0; 134 return 0;
137} 135}
138 136
139void __udelay(unsigned long usecs)
140{
141 int i, n;
142
143 n = (loops_per_jiffy * HZ * usecs) / MILLION;
144 for(i=0;i<n;i++) ;
145}
146
147void __const_udelay(unsigned long usecs)
148{
149 int i, n;
150
151 n = (loops_per_jiffy * HZ * usecs) / MILLION;
152 for(i=0;i<n;i++) ;
153}
154
155void timer_handler(int sig, union uml_pt_regs *regs) 137void timer_handler(int sig, union uml_pt_regs *regs)
156{ 138{
157 local_irq_disable(); 139 local_irq_disable();
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
index 47e766e6ba10..5fca2c61eb98 100644
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -48,7 +48,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
48 goto good_area; 48 goto good_area;
49 else if(!(vma->vm_flags & VM_GROWSDOWN)) 49 else if(!(vma->vm_flags & VM_GROWSDOWN))
50 goto out; 50 goto out;
51 else if(!ARCH_IS_STACKGROW(address)) 51 else if(is_user && !ARCH_IS_STACKGROW(address))
52 goto out; 52 goto out;
53 else if(expand_stack(vma, address)) 53 else if(expand_stack(vma, address))
54 goto out; 54 goto out;
@@ -133,12 +133,19 @@ static int check_remapped_addr(unsigned long address, int is_write)
133 return(0); 133 return(0);
134} 134}
135 135
136unsigned long segv(unsigned long address, unsigned long ip, int is_write, 136/*
137 int is_user, void *sc) 137 * We give a *copy* of the faultinfo in the regs to segv.
138 * This must be done, since nesting SEGVs could overwrite
139 * the info in the regs. A pointer to the info then would
140 * give us bad data!
141 */
142unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, void *sc)
138{ 143{
139 struct siginfo si; 144 struct siginfo si;
140 void *catcher; 145 void *catcher;
141 int err; 146 int err;
147 int is_write = FAULT_WRITE(fi);
148 unsigned long address = FAULT_ADDRESS(fi);
142 149
143 if(!is_user && (address >= start_vm) && (address < end_vm)){ 150 if(!is_user && (address >= start_vm) && (address < end_vm)){
144 flush_tlb_kernel_vm(); 151 flush_tlb_kernel_vm();
@@ -159,7 +166,7 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
159 } 166 }
160 else if(current->thread.fault_addr != NULL) 167 else if(current->thread.fault_addr != NULL)
161 panic("fault_addr set but no fault catcher"); 168 panic("fault_addr set but no fault catcher");
162 else if(arch_fixup(ip, sc)) 169 else if(!is_user && arch_fixup(ip, sc))
163 return(0); 170 return(0);
164 171
165 if(!is_user) 172 if(!is_user)
@@ -171,6 +178,7 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
171 si.si_errno = 0; 178 si.si_errno = 0;
172 si.si_code = BUS_ADRERR; 179 si.si_code = BUS_ADRERR;
173 si.si_addr = (void *)address; 180 si.si_addr = (void *)address;
181 current->thread.arch.faultinfo = fi;
174 force_sig_info(SIGBUS, &si, current); 182 force_sig_info(SIGBUS, &si, current);
175 } 183 }
176 else if(err == -ENOMEM){ 184 else if(err == -ENOMEM){
@@ -180,22 +188,20 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
180 else { 188 else {
181 si.si_signo = SIGSEGV; 189 si.si_signo = SIGSEGV;
182 si.si_addr = (void *) address; 190 si.si_addr = (void *) address;
183 current->thread.cr2 = address; 191 current->thread.arch.faultinfo = fi;
184 current->thread.err = is_write;
185 force_sig_info(SIGSEGV, &si, current); 192 force_sig_info(SIGSEGV, &si, current);
186 } 193 }
187 return(0); 194 return(0);
188} 195}
189 196
190void bad_segv(unsigned long address, unsigned long ip, int is_write) 197void bad_segv(struct faultinfo fi, unsigned long ip)
191{ 198{
192 struct siginfo si; 199 struct siginfo si;
193 200
194 si.si_signo = SIGSEGV; 201 si.si_signo = SIGSEGV;
195 si.si_code = SEGV_ACCERR; 202 si.si_code = SEGV_ACCERR;
196 si.si_addr = (void *) address; 203 si.si_addr = (void *) FAULT_ADDRESS(fi);
197 current->thread.cr2 = address; 204 current->thread.arch.faultinfo = fi;
198 current->thread.err = is_write;
199 force_sig_info(SIGSEGV, &si, current); 205 force_sig_info(SIGSEGV, &si, current);
200} 206}
201 207
@@ -204,6 +210,7 @@ void relay_signal(int sig, union uml_pt_regs *regs)
204 if(arch_handle_signal(sig, regs)) return; 210 if(arch_handle_signal(sig, regs)) return;
205 if(!UPT_IS_USER(regs)) 211 if(!UPT_IS_USER(regs))
206 panic("Kernel mode signal %d", sig); 212 panic("Kernel mode signal %d", sig);
213 current->thread.arch.faultinfo = *UPT_FAULTINFO(regs);
207 force_sig(sig, current); 214 force_sig(sig, current);
208} 215}
209 216
diff --git a/arch/um/kernel/trap_user.c b/arch/um/kernel/trap_user.c
index 50a4042a509f..f825a6eda3f5 100644
--- a/arch/um/kernel/trap_user.c
+++ b/arch/um/kernel/trap_user.c
@@ -54,23 +54,22 @@ struct {
54void segv_handler(int sig, union uml_pt_regs *regs) 54void segv_handler(int sig, union uml_pt_regs *regs)
55{ 55{
56 int index, max; 56 int index, max;
57 struct faultinfo * fi = UPT_FAULTINFO(regs);
57 58
58 if(UPT_IS_USER(regs) && !UPT_SEGV_IS_FIXABLE(regs)){ 59 if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
59 bad_segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), 60 bad_segv(*fi, UPT_IP(regs));
60 UPT_FAULT_WRITE(regs));
61 return; 61 return;
62 } 62 }
63 max = sizeof(segfault_record)/sizeof(segfault_record[0]); 63 max = sizeof(segfault_record)/sizeof(segfault_record[0]);
64 index = next_trap_index(max); 64 index = next_trap_index(max);
65 65
66 nsegfaults++; 66 nsegfaults++;
67 segfault_record[index].address = UPT_FAULT_ADDR(regs); 67 segfault_record[index].address = FAULT_ADDRESS(*fi);
68 segfault_record[index].pid = os_getpid(); 68 segfault_record[index].pid = os_getpid();
69 segfault_record[index].is_write = UPT_FAULT_WRITE(regs); 69 segfault_record[index].is_write = FAULT_WRITE(*fi);
70 segfault_record[index].sp = UPT_SP(regs); 70 segfault_record[index].sp = UPT_SP(regs);
71 segfault_record[index].is_user = UPT_IS_USER(regs); 71 segfault_record[index].is_user = UPT_IS_USER(regs);
72 segv(UPT_FAULT_ADDR(regs), UPT_IP(regs), UPT_FAULT_WRITE(regs), 72 segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
73 UPT_IS_USER(regs), regs);
74} 73}
75 74
76void usr2_handler(int sig, union uml_pt_regs *regs) 75void usr2_handler(int sig, union uml_pt_regs *regs)
diff --git a/arch/um/kernel/tt/Makefile b/arch/um/kernel/tt/Makefile
index 3d5177df3504..c3faea21a996 100644
--- a/arch/um/kernel/tt/Makefile
+++ b/arch/um/kernel/tt/Makefile
@@ -4,6 +4,7 @@
4# 4#
5 5
6extra-y := unmap_fin.o 6extra-y := unmap_fin.o
7targets := unmap.o
7clean-files := unmap_tmp.o 8clean-files := unmap_tmp.o
8 9
9obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \ 10obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h
index 28aaab3448fa..e0ca0e0b2516 100644
--- a/arch/um/kernel/tt/include/mode_kern-tt.h
+++ b/arch/um/kernel/tt/include/mode_kern-tt.h
@@ -19,7 +19,6 @@ extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
19 unsigned long stack_top, struct task_struct *p, 19 unsigned long stack_top, struct task_struct *p,
20 struct pt_regs *regs); 20 struct pt_regs *regs);
21extern void release_thread_tt(struct task_struct *task); 21extern void release_thread_tt(struct task_struct *task);
22extern void exit_thread_tt(void);
23extern void initial_thread_cb_tt(void (*proc)(void *), void *arg); 22extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
24extern void init_idle_tt(void); 23extern void init_idle_tt(void);
25extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end); 24extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h
index f0bad010cebd..3fbb5fe26f49 100644
--- a/arch/um/kernel/tt/include/uaccess-tt.h
+++ b/arch/um/kernel/tt/include/uaccess-tt.h
@@ -34,7 +34,7 @@ extern unsigned long uml_physmem;
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 * addr, 36static inline int verify_area_tt(int type, const void * addr,
37 unsigned long size) 37 unsigned long size)
38{ 38{
39 return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); 39 return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
40} 40}
diff --git a/arch/um/kernel/tt/mem.c b/arch/um/kernel/tt/mem.c
index 74346a04a2b2..bcb8796c3cb1 100644
--- a/arch/um/kernel/tt/mem.c
+++ b/arch/um/kernel/tt/mem.c
@@ -21,14 +21,8 @@ void before_mem_tt(unsigned long brk_start)
21 remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1); 21 remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1);
22} 22}
23 23
24#ifdef CONFIG_HOST_2G_2G
25#define TOP 0x80000000
26#else
27#define TOP 0xc0000000
28#endif
29
30#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000) 24#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000)
31#define START (TOP - SIZE) 25#define START (CONFIG_TOP_ADDR - SIZE)
32 26
33unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, 27unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
34 unsigned long *task_size_out) 28 unsigned long *task_size_out)
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index f19f7c18febe..df810ca8fc12 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -65,8 +65,7 @@ void *switch_to_tt(void *prev, void *next, void *last)
65 panic("write of switch_pipe failed, err = %d", -err); 65 panic("write of switch_pipe failed, err = %d", -err);
66 66
67 reading = 1; 67 reading = 1;
68 if((from->exit_state == EXIT_ZOMBIE) || 68 if(from->thread.mode.tt.switch_pipe[0] == -1)
69 (from->exit_state == EXIT_DEAD))
70 os_kill_process(os_getpid(), 0); 69 os_kill_process(os_getpid(), 0);
71 70
72 err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c)); 71 err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c));
@@ -81,8 +80,7 @@ void *switch_to_tt(void *prev, void *next, void *last)
81 * in case it has not already killed itself. 80 * in case it has not already killed itself.
82 */ 81 */
83 prev_sched = current->thread.prev_sched; 82 prev_sched = current->thread.prev_sched;
84 if((prev_sched->exit_state == EXIT_ZOMBIE) || 83 if(prev_sched->thread.mode.tt.switch_pipe[0] == -1)
85 (prev_sched->exit_state == EXIT_DEAD))
86 os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1); 84 os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1);
87 85
88 change_sig(SIGVTALRM, vtalrm); 86 change_sig(SIGVTALRM, vtalrm);
@@ -101,14 +99,18 @@ void release_thread_tt(struct task_struct *task)
101{ 99{
102 int pid = task->thread.mode.tt.extern_pid; 100 int pid = task->thread.mode.tt.extern_pid;
103 101
102 /*
103 * We first have to kill the other process, before
104 * closing its switch_pipe. Else it might wake up
105 * and receive "EOF" before we could kill it.
106 */
104 if(os_getpid() != pid) 107 if(os_getpid() != pid)
105 os_kill_process(pid, 0); 108 os_kill_process(pid, 0);
106}
107 109
108void exit_thread_tt(void) 110 os_close_file(task->thread.mode.tt.switch_pipe[0]);
109{ 111 os_close_file(task->thread.mode.tt.switch_pipe[1]);
110 os_close_file(current->thread.mode.tt.switch_pipe[0]); 112 /* use switch_pipe as flag: thread is released */
111 os_close_file(current->thread.mode.tt.switch_pipe[1]); 113 task->thread.mode.tt.switch_pipe[0] = -1;
112} 114}
113 115
114void suspend_new_thread(int fd) 116void suspend_new_thread(int fd)
diff --git a/arch/um/kernel/tt/syscall_user.c b/arch/um/kernel/tt/syscall_user.c
index e4e7e9c2224c..b218316cfdb2 100644
--- a/arch/um/kernel/tt/syscall_user.c
+++ b/arch/um/kernel/tt/syscall_user.c
@@ -63,6 +63,10 @@ void do_syscall(void *task, int pid, int local_using_sysemu)
63 63
64 UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs); 64 UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs);
65 65
66#ifdef UPT_ORIGGPR2
67 UPT_ORIGGPR2(TASK_REGS(task)) = REGS_ORIGGPR2(proc_regs);
68#endif
69
66 if(((unsigned long *) PT_IP(proc_regs) >= &_stext) && 70 if(((unsigned long *) PT_IP(proc_regs) >= &_stext) &&
67 ((unsigned long *) PT_IP(proc_regs) <= &_etext)) 71 ((unsigned long *) PT_IP(proc_regs) <= &_etext))
68 tracer_panic("I'm tracing myself and I can't get out"); 72 tracer_panic("I'm tracing myself and I can't get out");
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c
index 7b5d937e5955..d11e7399d7a1 100644
--- a/arch/um/kernel/tt/tracer.c
+++ b/arch/um/kernel/tt/tracer.c
@@ -26,6 +26,7 @@
26#include "kern_util.h" 26#include "kern_util.h"
27#include "chan_user.h" 27#include "chan_user.h"
28#include "ptrace_user.h" 28#include "ptrace_user.h"
29#include "irq_user.h"
29#include "mode.h" 30#include "mode.h"
30#include "tt.h" 31#include "tt.h"
31 32
@@ -33,7 +34,7 @@ static int tracer_winch[2];
33 34
34int is_tracer_winch(int pid, int fd, void *data) 35int is_tracer_winch(int pid, int fd, void *data)
35{ 36{
36 if(pid != tracing_pid) 37 if(pid != os_getpgrp())
37 return(0); 38 return(0);
38 39
39 register_winch_irq(tracer_winch[0], fd, -1, data); 40 register_winch_irq(tracer_winch[0], fd, -1, data);
@@ -89,8 +90,10 @@ void tracer_panic(char *format, ...)
89 90
90static void tracer_segv(int sig, struct sigcontext sc) 91static void tracer_segv(int sig, struct sigcontext sc)
91{ 92{
93 struct faultinfo fi;
94 GET_FAULTINFO_FROM_SC(fi, &sc);
92 printf("Tracing thread segfault at address 0x%lx, ip 0x%lx\n", 95 printf("Tracing thread segfault at address 0x%lx, ip 0x%lx\n",
93 SC_FAULT_ADDR(&sc), SC_IP(&sc)); 96 FAULT_ADDRESS(fi), SC_IP(&sc));
94 while(1) 97 while(1)
95 pause(); 98 pause();
96} 99}
@@ -117,6 +120,7 @@ static int signal_tramp(void *arg)
117 signal(SIGSEGV, (__sighandler_t) sig_handler); 120 signal(SIGSEGV, (__sighandler_t) sig_handler);
118 set_cmdline("(idle thread)"); 121 set_cmdline("(idle thread)");
119 set_init_pid(os_getpid()); 122 set_init_pid(os_getpid());
123 init_irq_signals(0);
120 proc = arg; 124 proc = arg;
121 return((*proc)(NULL)); 125 return((*proc)(NULL));
122} 126}
diff --git a/arch/um/kernel/tt/trap_user.c b/arch/um/kernel/tt/trap_user.c
index 92a3820ca543..fc108615beaf 100644
--- a/arch/um/kernel/tt/trap_user.c
+++ b/arch/um/kernel/tt/trap_user.c
@@ -7,6 +7,7 @@
7#include <errno.h> 7#include <errno.h>
8#include <signal.h> 8#include <signal.h>
9#include "sysdep/ptrace.h" 9#include "sysdep/ptrace.h"
10#include "sysdep/sigcontext.h"
10#include "signal_user.h" 11#include "signal_user.h"
11#include "user_util.h" 12#include "user_util.h"
12#include "kern_util.h" 13#include "kern_util.h"
@@ -28,6 +29,11 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
28 change_sig(SIGSEGV, 1); 29 change_sig(SIGSEGV, 1);
29 30
30 r = &TASK_REGS(get_current())->tt; 31 r = &TASK_REGS(get_current())->tt;
32 if ( sig == SIGFPE || sig == SIGSEGV ||
33 sig == SIGBUS || sig == SIGILL ||
34 sig == SIGTRAP ) {
35 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
36 }
31 save_regs = *r; 37 save_regs = *r;
32 is_user = user_context(SC_SP(sc)); 38 is_user = user_context(SC_SP(sc));
33 r->sc = sc; 39 r->sc = sc;
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 5c49d88eed3d..4d10ec372a67 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -23,6 +23,7 @@
23#include "asm/ptrace.h" 23#include "asm/ptrace.h"
24#include "asm/elf.h" 24#include "asm/elf.h"
25#include "asm/user.h" 25#include "asm/user.h"
26#include "asm/setup.h"
26#include "ubd_user.h" 27#include "ubd_user.h"
27#include "asm/current.h" 28#include "asm/current.h"
28#include "asm/setup.h" 29#include "asm/setup.h"
@@ -42,9 +43,9 @@
42#define DEFAULT_COMMAND_LINE "root=98:0" 43#define DEFAULT_COMMAND_LINE "root=98:0"
43 44
44/* Changed in linux_main and setup_arch, which run before SMP is started */ 45/* Changed in linux_main and setup_arch, which run before SMP is started */
45char command_line[COMMAND_LINE_SIZE] = { 0 }; 46static char command_line[COMMAND_LINE_SIZE] = { 0 };
46 47
47void add_arg(char *arg) 48static void add_arg(char *arg)
48{ 49{
49 if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) { 50 if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
50 printf("add_arg: Too many command line arguments!\n"); 51 printf("add_arg: Too many command line arguments!\n");
@@ -449,7 +450,7 @@ void __init setup_arch(char **cmdline_p)
449{ 450{
450 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); 451 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier);
451 paging_init(); 452 paging_init();
452 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 453 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
453 *cmdline_p = command_line; 454 *cmdline_p = command_line;
454 setup_hostinfo(); 455 setup_hostinfo();
455} 456}
diff --git a/arch/um/kernel/vmlinux.lds.S b/arch/um/kernel/vmlinux.lds.S
new file mode 100644
index 000000000000..1660a769674b
--- /dev/null
+++ b/arch/um/kernel/vmlinux.lds.S
@@ -0,0 +1,6 @@
1#include <linux/config.h>
2#ifdef CONFIG_LD_SCRIPT_STATIC
3#include "uml.lds.S"
4#else
5#include "dyn.lds.S"
6#endif
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index ba9ca1cc790a..1e126bfd31a7 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -123,6 +123,11 @@ int os_getpid(void)
123 return(getpid()); 123 return(getpid());
124} 124}
125 125
126int os_getpgrp(void)
127{
128 return getpgrp();
129}
130
126int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len, 131int os_map_memory(void *virt, int fd, unsigned long long off, unsigned long len,
127 int r, int w, int x) 132 int r, int w, int x)
128{ 133{
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 7eac1baf5975..c7bfd5ee3925 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -8,7 +8,7 @@
8#include "mode.h" 8#include "mode.h"
9#include "sysdep/signal.h" 9#include "sysdep/signal.h"
10 10
11void sig_handler(int sig) 11void sig_handler(ARCH_SIGHDLR_PARAM)
12{ 12{
13 struct sigcontext *sc; 13 struct sigcontext *sc;
14 14
@@ -19,7 +19,7 @@ void sig_handler(int sig)
19 19
20extern int timer_irq_inited; 20extern int timer_irq_inited;
21 21
22void alarm_handler(int sig) 22void alarm_handler(ARCH_SIGHDLR_PARAM)
23{ 23{
24 struct sigcontext *sc; 24 struct sigcontext *sc;
25 25
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c
index 148645b14480..9a0ad094d926 100644
--- a/arch/um/os-Linux/sys-i386/registers.c
+++ b/arch/um/os-Linux/sys-i386/registers.c
@@ -105,14 +105,15 @@ void init_registers(int pid)
105 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d", 105 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
106 err); 106 err);
107 107
108 errno = 0;
108 err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs); 109 err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs);
109 if(!err) 110 if(!err)
110 return; 111 return;
112 if(errno != EIO)
113 panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
114 errno);
111 115
112 have_fpx_regs = 0; 116 have_fpx_regs = 0;
113 if(err != EIO)
114 panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d",
115 err);
116 117
117 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs); 118 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
118 if(err) 119 if(err)
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile
index fb00ddf969bd..9778aed0c314 100644
--- a/arch/um/os-Linux/util/Makefile
+++ b/arch/um/os-Linux/util/Makefile
@@ -1,4 +1,4 @@
1hostprogs-y := mk_user_constants 1hostprogs-y := mk_user_constants
2always := $(hostprogs-y) 2always := $(hostprogs-y)
3 3
4mk_user_constants-objs := mk_user_constants.o 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
index 0933518aa8bd..4838f30eecf0 100644
--- a/arch/um/os-Linux/util/mk_user_constants.c
+++ b/arch/um/os-Linux/util/mk_user_constants.c
@@ -1,11 +1,5 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <asm/types.h> 2#include <user-offsets.h>
3/* For some reason, x86_64 nowhere defines u64 and u32, even though they're
4 * used throughout the headers.
5 */
6typedef __u64 u64;
7typedef __u32 u32;
8#include <asm/user.h>
9 3
10int main(int argc, char **argv) 4int main(int argc, char **argv)
11{ 5{
@@ -20,7 +14,7 @@ int main(int argc, char **argv)
20 * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on 14 * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on
21 * both x86_64 and i386. 15 * both x86_64 and i386.
22 */ 16 */
23 printf("#define UM_FRAME_SIZE %d\n", (int) sizeof(struct user_regs_struct)); 17 printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE);
24 18
25 printf("\n"); 19 printf("\n");
26 printf("#endif\n"); 20 printf("#endif\n");
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index 143f6fea0763..0b2491883d9c 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -2,12 +2,27 @@
2# arch/um: Generic definitions 2# arch/um: Generic definitions
3# =========================================================================== 3# ===========================================================================
4 4
5USER_SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs)) 5USER_SINGLE_OBJS := \
6USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) 6 $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs))
7 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) $(CFLAGS_$(notdir $@)) 10$(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
11 $(CFLAGS_$(notdir $@))
11 12
12quiet_cmd_make_link = SYMLINK $@ 13quiet_cmd_make_link = SYMLINK $@
13cmd_make_link = rm -f $@; ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ 14cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@
15
16# this needs to be before the foreach, because targets does not accept
17# complete paths like $(obj)/$(f). To make sure this works, use a := assignment,
18# or we will get $(obj)/$(f) in the "targets" value.
19# Also, this forces you to use the := syntax when assigning to targets.
20# Otherwise the line below will cause an infinite loop (if you don't know why,
21# just do it).
22
23targets := $(targets) $(SYMLINKS)
24
25SYMLINKS := $(foreach f,$(SYMLINKS),$(obj)/$(f))
26
27$(SYMLINKS): FORCE
28 $(call if_changed,make_link)
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 71b47e618605..fcd67c3414e4 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -1,29 +1,19 @@
1obj-y = bitops.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \ 1obj-y = bitops.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
2 ptrace_user.o semaphore.o signal.o sigcontext.o syscalls.o sysrq.o 2 ptrace_user.o semaphore.o signal.o sigcontext.o syscalls.o sysrq.o \
3 sys_call_table.o
3 4
4obj-$(CONFIG_HIGHMEM) += highmem.o 5obj-$(CONFIG_HIGHMEM) += highmem.o
5obj-$(CONFIG_MODULES) += module.o 6obj-$(CONFIG_MODULES) += module.o
6 7
7USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o 8USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
8 9
9include arch/um/scripts/Makefile.rules
10
11SYMLINKS = bitops.c semaphore.c highmem.c module.c 10SYMLINKS = bitops.c semaphore.c highmem.c module.c
12 11
13# this needs to be before the foreach, because clean-files does not accept
14# complete paths like $(src)/$f.
15clean-files := $(SYMLINKS)
16
17targets += $(SYMLINKS)
18
19SYMLINKS := $(foreach f,$(SYMLINKS),$(obj)/$f)
20
21bitops.c-dir = lib 12bitops.c-dir = lib
22semaphore.c-dir = kernel 13semaphore.c-dir = kernel
23highmem.c-dir = mm 14highmem.c-dir = mm
24module.c-dir = kernel 15module.c-dir = kernel
25 16
26$(SYMLINKS): FORCE
27 $(call if_changed,make_link)
28
29subdir- := util 17subdir- := util
18
19include arch/um/scripts/Makefile.rules
diff --git a/arch/um/sys-i386/checksum.S b/arch/um/sys-i386/checksum.S
index a11171fb6223..d98b2fff3d08 100644
--- a/arch/um/sys-i386/checksum.S
+++ b/arch/um/sys-i386/checksum.S
@@ -38,7 +38,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
38 38
39.text 39.text
40.align 4 40.align 4
41.globl arch_csum_partial 41.globl csum_partial
42 42
43#ifndef CONFIG_X86_USE_PPRO_CHECKSUM 43#ifndef CONFIG_X86_USE_PPRO_CHECKSUM
44 44
@@ -49,7 +49,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
49 * Fortunately, it is easy to convert 2-byte alignment to 4-byte 49 * Fortunately, it is easy to convert 2-byte alignment to 4-byte
50 * alignment for the unrolled loop. 50 * alignment for the unrolled loop.
51 */ 51 */
52arch_csum_partial: 52csum_partial:
53 pushl %esi 53 pushl %esi
54 pushl %ebx 54 pushl %ebx
55 movl 20(%esp),%eax # Function arg: unsigned int sum 55 movl 20(%esp),%eax # Function arg: unsigned int sum
@@ -119,7 +119,7 @@ arch_csum_partial:
119 119
120/* Version for PentiumII/PPro */ 120/* Version for PentiumII/PPro */
121 121
122arch_csum_partial: 122csum_partial:
123 pushl %esi 123 pushl %esi
124 pushl %ebx 124 pushl %ebx
125 movl 20(%esp),%eax # Function arg: unsigned int sum 125 movl 20(%esp),%eax # Function arg: unsigned int sum
diff --git a/arch/um/sys-i386/delay.c b/arch/um/sys-i386/delay.c
index 20d37dbbaf08..e9892eef51ce 100644
--- a/arch/um/sys-i386/delay.c
+++ b/arch/um/sys-i386/delay.c
@@ -1,3 +1,6 @@
1#include "linux/delay.h"
2#include "asm/param.h"
3
1void __delay(unsigned long time) 4void __delay(unsigned long time)
2{ 5{
3 /* Stolen from the i386 __loop_delay */ 6 /* Stolen from the i386 __loop_delay */
@@ -12,3 +15,18 @@ void __delay(unsigned long time)
12 :"0" (time)); 15 :"0" (time));
13} 16}
14 17
18void __udelay(unsigned long usecs)
19{
20 int i, n;
21
22 n = (loops_per_jiffy * HZ * usecs) / MILLION;
23 for(i=0;i<n;i++) ;
24}
25
26void __const_udelay(unsigned long usecs)
27{
28 int i, n;
29
30 n = (loops_per_jiffy * HZ * usecs) / MILLION;
31 for(i=0;i<n;i++) ;
32}
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/sys-i386/kernel-offsets.c
new file mode 100644
index 000000000000..9f8ecd1fdd96
--- /dev/null
+++ b/arch/um/sys-i386/kernel-offsets.c
@@ -0,0 +1,25 @@
1#include <linux/config.h>
2#include <linux/stddef.h>
3#include <linux/sched.h>
4#include <linux/time.h>
5#include <asm/page.h>
6
7#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9
10#define STR(x) #x
11#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " STR(val) " " #val: : )
12
13#define BLANK() asm volatile("\n->" : : )
14
15#define OFFSET(sym, str, mem) \
16 DEFINE(sym, offsetof(struct str, mem));
17
18void foo(void)
19{
20 OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs);
21#ifdef CONFIG_MODE_TT
22 OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
23#endif
24#include <common-offsets.h>
25}
diff --git a/arch/um/sys-i386/ksyms.c b/arch/um/sys-i386/ksyms.c
index 74f70a120458..db524ab3f743 100644
--- a/arch/um/sys-i386/ksyms.c
+++ b/arch/um/sys-i386/ksyms.c
@@ -2,6 +2,7 @@
2#include "linux/in6.h" 2#include "linux/in6.h"
3#include "linux/rwsem.h" 3#include "linux/rwsem.h"
4#include "asm/byteorder.h" 4#include "asm/byteorder.h"
5#include "asm/delay.h"
5#include "asm/semaphore.h" 6#include "asm/semaphore.h"
6#include "asm/uaccess.h" 7#include "asm/uaccess.h"
7#include "asm/checksum.h" 8#include "asm/checksum.h"
@@ -13,5 +14,8 @@ EXPORT_SYMBOL(__down_failed_trylock);
13EXPORT_SYMBOL(__up_wakeup); 14EXPORT_SYMBOL(__up_wakeup);
14 15
15/* Networking helper routines. */ 16/* Networking helper routines. */
16EXPORT_SYMBOL(csum_partial_copy_from); 17EXPORT_SYMBOL(csum_partial);
17EXPORT_SYMBOL(csum_partial_copy_to); 18
19/* delay core functions */
20EXPORT_SYMBOL(__const_udelay);
21EXPORT_SYMBOL(__udelay);
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 31bcb2f997d4..dc755b0b9db8 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -25,7 +25,7 @@ int sys_modify_ldt_tt(int func, void __user *ptr, unsigned long bytecount)
25#endif 25#endif
26 26
27#ifdef CONFIG_MODE_SKAS 27#ifdef CONFIG_MODE_SKAS
28extern int userspace_pid; 28extern int userspace_pid[];
29 29
30#include "skas_ptrace.h" 30#include "skas_ptrace.h"
31 31
@@ -56,7 +56,8 @@ int sys_modify_ldt_skas(int func, void __user *ptr, unsigned long bytecount)
56 ldt = ((struct ptrace_ldt) { .func = func, 56 ldt = ((struct ptrace_ldt) { .func = func,
57 .ptr = buf, 57 .ptr = buf,
58 .bytecount = bytecount }); 58 .bytecount = bytecount });
59 res = ptrace(PTRACE_LDT, userspace_pid, 0, (unsigned long) &ldt); 59#warning Need to look up userspace_pid by cpu
60 res = ptrace(PTRACE_LDT, userspace_pid[0], 0, (unsigned long) &ldt);
60 if(res < 0) 61 if(res < 0)
61 goto out; 62 goto out;
62 63
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index e470d28cdf84..e839ce65ad28 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -73,6 +73,25 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
73 return 0; 73 return 0;
74} 74}
75 75
76int poke_user(struct task_struct *child, long addr, long data)
77{
78 if ((addr & 3) || addr < 0)
79 return -EIO;
80
81 if (addr < MAX_REG_OFFSET)
82 return putreg(child, addr, data);
83
84 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
85 (addr <= offsetof(struct user, u_debugreg[7]))){
86 addr -= offsetof(struct user, u_debugreg[0]);
87 addr = addr >> 2;
88 if((addr == 4) || (addr == 5)) return -EIO;
89 child->thread.arch.debugregs[addr] = data;
90 return 0;
91 }
92 return -EIO;
93}
94
76unsigned long getreg(struct task_struct *child, int regno) 95unsigned long getreg(struct task_struct *child, int regno)
77{ 96{
78 unsigned long retval = ~0UL; 97 unsigned long retval = ~0UL;
@@ -93,6 +112,27 @@ unsigned long getreg(struct task_struct *child, int regno)
93 return retval; 112 return retval;
94} 113}
95 114
115int peek_user(struct task_struct *child, long addr, long data)
116{
117/* read the word at location addr in the USER area. */
118 unsigned long tmp;
119
120 if ((addr & 3) || addr < 0)
121 return -EIO;
122
123 tmp = 0; /* Default return condition */
124 if(addr < MAX_REG_OFFSET){
125 tmp = getreg(child, addr);
126 }
127 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
128 (addr <= offsetof(struct user, u_debugreg[7]))){
129 addr -= offsetof(struct user, u_debugreg[0]);
130 addr = addr >> 2;
131 tmp = child->thread.arch.debugregs[addr];
132 }
133 return put_user(tmp, (unsigned long *) data);
134}
135
96struct i387_fxsave_struct { 136struct i387_fxsave_struct {
97 unsigned short cwd; 137 unsigned short cwd;
98 unsigned short swd; 138 unsigned short swd;
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index 76ba87254b25..03913ca5d256 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -47,9 +47,6 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
47 REGS_CS(regs->regs.skas.regs) = sc.cs; 47 REGS_CS(regs->regs.skas.regs) = sc.cs;
48 REGS_EFLAGS(regs->regs.skas.regs) = sc.eflags; 48 REGS_EFLAGS(regs->regs.skas.regs) = sc.eflags;
49 REGS_SS(regs->regs.skas.regs) = sc.ss; 49 REGS_SS(regs->regs.skas.regs) = sc.ss;
50 regs->regs.skas.fault_addr = sc.cr2;
51 regs->regs.skas.fault_type = FAULT_WRITE(sc.err);
52 regs->regs.skas.trap_type = sc.trapno;
53 50
54 err = restore_fp_registers(userspace_pid[0], fpregs); 51 err = restore_fp_registers(userspace_pid[0], fpregs);
55 if(err < 0){ 52 if(err < 0){
@@ -62,11 +59,11 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
62} 59}
63 60
64int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, 61int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
65 struct pt_regs *regs, unsigned long fault_addr, 62 struct pt_regs *regs)
66 int fault_type)
67{ 63{
68 struct sigcontext sc; 64 struct sigcontext sc;
69 unsigned long fpregs[HOST_FP_SIZE]; 65 unsigned long fpregs[HOST_FP_SIZE];
66 struct faultinfo * fi = &current->thread.arch.faultinfo;
70 int err; 67 int err;
71 68
72 sc.gs = REGS_GS(regs->regs.skas.regs); 69 sc.gs = REGS_GS(regs->regs.skas.regs);
@@ -86,9 +83,9 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
86 sc.eflags = REGS_EFLAGS(regs->regs.skas.regs); 83 sc.eflags = REGS_EFLAGS(regs->regs.skas.regs);
87 sc.esp_at_signal = regs->regs.skas.regs[UESP]; 84 sc.esp_at_signal = regs->regs.skas.regs[UESP];
88 sc.ss = regs->regs.skas.regs[SS]; 85 sc.ss = regs->regs.skas.regs[SS];
89 sc.cr2 = fault_addr; 86 sc.cr2 = fi->cr2;
90 sc.err = TO_SC_ERR(fault_type); 87 sc.err = fi->error_code;
91 sc.trapno = regs->regs.skas.trap_type; 88 sc.trapno = fi->trap_no;
92 89
93 err = save_fp_registers(userspace_pid[0], fpregs); 90 err = save_fp_registers(userspace_pid[0], fpregs);
94 if(err < 0){ 91 if(err < 0){
@@ -167,9 +164,7 @@ static int copy_sc_to_user(struct sigcontext *to, struct _fpstate *fp,
167{ 164{
168 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), 165 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
169 sizeof(*fp)), 166 sizeof(*fp)),
170 copy_sc_to_user_skas(to, fp, from, 167 copy_sc_to_user_skas(to, fp, from)));
171 current->thread.cr2,
172 current->thread.err)));
173} 168}
174 169
175static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp, 170static int copy_ucontext_to_user(struct ucontext *uc, struct _fpstate *fp,
diff --git a/arch/um/sys-i386/sys_call_table.S b/arch/um/sys-i386/sys_call_table.S
new file mode 100644
index 000000000000..ad75c27afe38
--- /dev/null
+++ b/arch/um/sys-i386/sys_call_table.S
@@ -0,0 +1,16 @@
1#include <linux/linkage.h>
2/* Steal i386 syscall table for our purposes, but with some slight changes.*/
3
4#define sys_iopl sys_ni_syscall
5#define sys_ioperm sys_ni_syscall
6
7#define sys_vm86old sys_ni_syscall
8#define sys_vm86 sys_ni_syscall
9#define sys_set_thread_area sys_ni_syscall
10#define sys_get_thread_area sys_ni_syscall
11
12#define sys_stime um_stime
13#define sys_time um_time
14#define old_mmap old_mmap_i386
15
16#include "../../i386/kernel/syscall_table.S"
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
new file mode 100644
index 000000000000..3ceaabceb3d7
--- /dev/null
+++ b/arch/um/sys-i386/user-offsets.c
@@ -0,0 +1,69 @@
1#include <stdio.h>
2#include <signal.h>
3#include <asm/ptrace.h>
4#include <asm/user.h>
5#include <linux/stddef.h>
6
7#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9
10#define OFFSET(sym, str, mem) \
11 DEFINE(sym, offsetof(struct str, mem));
12
13void foo(void)
14{
15 OFFSET(SC_IP, sigcontext, eip);
16 OFFSET(SC_SP, sigcontext, esp);
17 OFFSET(SC_FS, sigcontext, fs);
18 OFFSET(SC_GS, sigcontext, gs);
19 OFFSET(SC_DS, sigcontext, ds);
20 OFFSET(SC_ES, sigcontext, es);
21 OFFSET(SC_SS, sigcontext, ss);
22 OFFSET(SC_CS, sigcontext, cs);
23 OFFSET(SC_EFLAGS, sigcontext, eflags);
24 OFFSET(SC_EAX, sigcontext, eax);
25 OFFSET(SC_EBX, sigcontext, ebx);
26 OFFSET(SC_ECX, sigcontext, ecx);
27 OFFSET(SC_EDX, sigcontext, edx);
28 OFFSET(SC_EDI, sigcontext, edi);
29 OFFSET(SC_ESI, sigcontext, esi);
30 OFFSET(SC_EBP, sigcontext, ebp);
31 OFFSET(SC_TRAPNO, sigcontext, trapno);
32 OFFSET(SC_ERR, sigcontext, err);
33 OFFSET(SC_CR2, sigcontext, cr2);
34 OFFSET(SC_FPSTATE, sigcontext, fpstate);
35 OFFSET(SC_SIGMASK, sigcontext, oldmask);
36 OFFSET(SC_FP_CW, _fpstate, cw);
37 OFFSET(SC_FP_SW, _fpstate, sw);
38 OFFSET(SC_FP_TAG, _fpstate, tag);
39 OFFSET(SC_FP_IPOFF, _fpstate, ipoff);
40 OFFSET(SC_FP_CSSEL, _fpstate, cssel);
41 OFFSET(SC_FP_DATAOFF, _fpstate, dataoff);
42 OFFSET(SC_FP_DATASEL, _fpstate, datasel);
43 OFFSET(SC_FP_ST, _fpstate, _st);
44 OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env);
45
46 DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
47 DEFINE(HOST_FP_SIZE,
48 sizeof(struct user_i387_struct) / sizeof(unsigned long));
49 DEFINE(HOST_XFP_SIZE,
50 sizeof(struct user_fxsr_struct) / sizeof(unsigned long));
51
52 DEFINE(HOST_IP, EIP);
53 DEFINE(HOST_SP, UESP);
54 DEFINE(HOST_EFLAGS, EFL);
55 DEFINE(HOST_EAX, EAX);
56 DEFINE(HOST_EBX, EBX);
57 DEFINE(HOST_ECX, ECX);
58 DEFINE(HOST_EDX, EDX);
59 DEFINE(HOST_ESI, ESI);
60 DEFINE(HOST_EDI, EDI);
61 DEFINE(HOST_EBP, EBP);
62 DEFINE(HOST_CS, CS);
63 DEFINE(HOST_SS, SS);
64 DEFINE(HOST_DS, DS);
65 DEFINE(HOST_FS, FS);
66 DEFINE(HOST_ES, ES);
67 DEFINE(HOST_GS, GS);
68 DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct));
69}
diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile
index 34860f9ca7b0..bf61afd0b045 100644
--- a/arch/um/sys-i386/util/Makefile
+++ b/arch/um/sys-i386/util/Makefile
@@ -1,8 +1,5 @@
1
2hostprogs-y := mk_sc mk_thread 1hostprogs-y := mk_sc mk_thread
3always := $(hostprogs-y) 2always := $(hostprogs-y)
4 3
5mk_thread-objs := mk_thread_kern.o mk_thread_user.o 4HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um
6 5HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um
7HOSTCFLAGS_mk_thread_kern.o := $(CFLAGS) $(CPPFLAGS)
8HOSTCFLAGS_mk_thread_user.o := $(USER_CFLAGS)
diff --git a/arch/um/sys-i386/util/mk_sc.c b/arch/um/sys-i386/util/mk_sc.c
index 85cbd30396f7..04c0d73433aa 100644
--- a/arch/um/sys-i386/util/mk_sc.c
+++ b/arch/um/sys-i386/util/mk_sc.c
@@ -1,52 +1,51 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <signal.h> 2#include <user-offsets.h>
3#include <linux/stddef.h>
4 3
5#define SC_OFFSET(name, field) \ 4#define SC_OFFSET(name, field) \
6 printf("#define " name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ 5 printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
7 offsetof(struct sigcontext, field)) 6 name)
8 7
9#define SC_FP_OFFSET(name, field) \ 8#define SC_FP_OFFSET(name, field) \
10 printf("#define " name \ 9 printf("#define " #name \
11 "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ 10 "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
12 offsetof(struct _fpstate, field)) 11 name)
13 12
14#define SC_FP_OFFSET_PTR(name, field, type) \ 13#define SC_FP_OFFSET_PTR(name, field, type) \
15 printf("#define " name \ 14 printf("#define " #name \
16 "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ 15 "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
17 offsetof(struct _fpstate, field)) 16 name)
18 17
19int main(int argc, char **argv) 18int main(int argc, char **argv)
20{ 19{
21 SC_OFFSET("SC_IP", eip); 20 SC_OFFSET(SC_IP, eip);
22 SC_OFFSET("SC_SP", esp); 21 SC_OFFSET(SC_SP, esp);
23 SC_OFFSET("SC_FS", fs); 22 SC_OFFSET(SC_FS, fs);
24 SC_OFFSET("SC_GS", gs); 23 SC_OFFSET(SC_GS, gs);
25 SC_OFFSET("SC_DS", ds); 24 SC_OFFSET(SC_DS, ds);
26 SC_OFFSET("SC_ES", es); 25 SC_OFFSET(SC_ES, es);
27 SC_OFFSET("SC_SS", ss); 26 SC_OFFSET(SC_SS, ss);
28 SC_OFFSET("SC_CS", cs); 27 SC_OFFSET(SC_CS, cs);
29 SC_OFFSET("SC_EFLAGS", eflags); 28 SC_OFFSET(SC_EFLAGS, eflags);
30 SC_OFFSET("SC_EAX", eax); 29 SC_OFFSET(SC_EAX, eax);
31 SC_OFFSET("SC_EBX", ebx); 30 SC_OFFSET(SC_EBX, ebx);
32 SC_OFFSET("SC_ECX", ecx); 31 SC_OFFSET(SC_ECX, ecx);
33 SC_OFFSET("SC_EDX", edx); 32 SC_OFFSET(SC_EDX, edx);
34 SC_OFFSET("SC_EDI", edi); 33 SC_OFFSET(SC_EDI, edi);
35 SC_OFFSET("SC_ESI", esi); 34 SC_OFFSET(SC_ESI, esi);
36 SC_OFFSET("SC_EBP", ebp); 35 SC_OFFSET(SC_EBP, ebp);
37 SC_OFFSET("SC_TRAPNO", trapno); 36 SC_OFFSET(SC_TRAPNO, trapno);
38 SC_OFFSET("SC_ERR", err); 37 SC_OFFSET(SC_ERR, err);
39 SC_OFFSET("SC_CR2", cr2); 38 SC_OFFSET(SC_CR2, cr2);
40 SC_OFFSET("SC_FPSTATE", fpstate); 39 SC_OFFSET(SC_FPSTATE, fpstate);
41 SC_OFFSET("SC_SIGMASK", oldmask); 40 SC_OFFSET(SC_SIGMASK, oldmask);
42 SC_FP_OFFSET("SC_FP_CW", cw); 41 SC_FP_OFFSET(SC_FP_CW, cw);
43 SC_FP_OFFSET("SC_FP_SW", sw); 42 SC_FP_OFFSET(SC_FP_SW, sw);
44 SC_FP_OFFSET("SC_FP_TAG", tag); 43 SC_FP_OFFSET(SC_FP_TAG, tag);
45 SC_FP_OFFSET("SC_FP_IPOFF", ipoff); 44 SC_FP_OFFSET(SC_FP_IPOFF, ipoff);
46 SC_FP_OFFSET("SC_FP_CSSEL", cssel); 45 SC_FP_OFFSET(SC_FP_CSSEL, cssel);
47 SC_FP_OFFSET("SC_FP_DATAOFF", dataoff); 46 SC_FP_OFFSET(SC_FP_DATAOFF, dataoff);
48 SC_FP_OFFSET("SC_FP_DATASEL", datasel); 47 SC_FP_OFFSET(SC_FP_DATASEL, datasel);
49 SC_FP_OFFSET_PTR("SC_FP_ST", _st, "struct _fpstate"); 48 SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate");
50 SC_FP_OFFSET_PTR("SC_FXSR_ENV", _fxsr_env, "void"); 49 SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void");
51 return(0); 50 return(0);
52} 51}
diff --git a/arch/um/sys-i386/util/mk_thread.c b/arch/um/sys-i386/util/mk_thread.c
new file mode 100644
index 000000000000..7470d0dda67e
--- /dev/null
+++ b/arch/um/sys-i386/util/mk_thread.c
@@ -0,0 +1,22 @@
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-i386/util/mk_thread_kern.c b/arch/um/sys-i386/util/mk_thread_kern.c
deleted file mode 100644
index 948b1ce85230..000000000000
--- a/arch/um/sys-i386/util/mk_thread_kern.c
+++ /dev/null
@@ -1,22 +0,0 @@
1#include "linux/config.h"
2#include "linux/stddef.h"
3#include "linux/sched.h"
4
5extern void print_head(void);
6extern void print_constant_ptr(char *name, int value);
7extern void print_constant(char *name, char *type, int value);
8extern void print_tail(void);
9
10#define THREAD_OFFSET(field) offsetof(struct task_struct, thread.field)
11
12int main(int argc, char **argv)
13{
14 print_head();
15 print_constant_ptr("TASK_DEBUGREGS", THREAD_OFFSET(arch.debugregs));
16#ifdef CONFIG_MODE_TT
17 print_constant("TASK_EXTERN_PID", "int", THREAD_OFFSET(mode.tt.extern_pid));
18#endif
19 print_tail();
20 return(0);
21}
22
diff --git a/arch/um/sys-i386/util/mk_thread_user.c b/arch/um/sys-i386/util/mk_thread_user.c
deleted file mode 100644
index 2620cd6aa1f1..000000000000
--- a/arch/um/sys-i386/util/mk_thread_user.c
+++ /dev/null
@@ -1,30 +0,0 @@
1#include <stdio.h>
2
3void print_head(void)
4{
5 printf("/*\n");
6 printf(" * Generated by mk_thread\n");
7 printf(" */\n");
8 printf("\n");
9 printf("#ifndef __UM_THREAD_H\n");
10 printf("#define __UM_THREAD_H\n");
11 printf("\n");
12}
13
14void print_constant_ptr(char *name, int value)
15{
16 printf("#define %s(task) ((unsigned long *) "
17 "&(((char *) (task))[%d]))\n", name, value);
18}
19
20void print_constant(char *name, char *type, int value)
21{
22 printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
23 value);
24}
25
26void print_tail(void)
27{
28 printf("\n");
29 printf("#endif\n");
30}
diff --git a/arch/um/sys-ppc/ptrace.c b/arch/um/sys-ppc/ptrace.c
index a971366d3277..8e71b47f2b8e 100644
--- a/arch/um/sys-ppc/ptrace.c
+++ b/arch/um/sys-ppc/ptrace.c
@@ -8,6 +8,25 @@ int putreg(struct task_struct *child, unsigned long regno,
8 return 0; 8 return 0;
9} 9}
10 10
11int poke_user(struct task_struct *child, long addr, long data)
12{
13 if ((addr & 3) || addr < 0)
14 return -EIO;
15
16 if (addr < MAX_REG_OFFSET)
17 return putreg(child, addr, data);
18
19 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
20 (addr <= offsetof(struct user, u_debugreg[7]))){
21 addr -= offsetof(struct user, u_debugreg[0]);
22 addr = addr >> 2;
23 if((addr == 4) || (addr == 5)) return -EIO;
24 child->thread.arch.debugregs[addr] = data;
25 return 0;
26 }
27 return -EIO;
28}
29
11unsigned long getreg(struct task_struct *child, unsigned long regno) 30unsigned long getreg(struct task_struct *child, unsigned long regno)
12{ 31{
13 unsigned long retval = ~0UL; 32 unsigned long retval = ~0UL;
@@ -16,6 +35,27 @@ unsigned long getreg(struct task_struct *child, unsigned long regno)
16 return retval; 35 return retval;
17} 36}
18 37
38int peek_user(struct task_struct *child, long addr, long data)
39{
40 /* read the word at location addr in the USER area. */
41 unsigned long tmp;
42
43 if ((addr & 3) || addr < 0)
44 return -EIO;
45
46 tmp = 0; /* Default return condition */
47 if(addr < MAX_REG_OFFSET){
48 tmp = getreg(child, addr);
49 }
50 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
51 (addr <= offsetof(struct user, u_debugreg[7]))){
52 addr -= offsetof(struct user, u_debugreg[0]);
53 addr = addr >> 2;
54 tmp = child->thread.arch.debugregs[addr];
55 }
56 return put_user(tmp, (unsigned long *) data);
57}
58
19/* 59/*
20 * Overrides for Emacs so that we follow Linus's tabbing style. 60 * Overrides for Emacs so that we follow Linus's tabbing style.
21 * Emacs will notice this stuff at the end of the file and automatically 61 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
index 2129e3143559..3d7da911cc8c 100644
--- a/arch/um/sys-x86_64/Makefile
+++ b/arch/um/sys-x86_64/Makefile
@@ -4,24 +4,20 @@
4# Licensed under the GPL 4# Licensed under the GPL
5# 5#
6 6
7#XXX: why into lib-y?
7lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o mem.o memcpy.o \ 8lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o mem.o memcpy.o \
8 ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o \ 9 ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o \
9 syscalls.o sysrq.o thunk.o 10 syscalls.o sysrq.o thunk.o syscall_table.o
11
12obj-y := ksyms.o
13obj-$(CONFIG_MODULES) += module.o um_module.o
10 14
11USER_OBJS := ptrace_user.o sigcontext.o 15USER_OBJS := ptrace_user.o sigcontext.o
12 16
13include arch/um/scripts/Makefile.rules 17include arch/um/scripts/Makefile.rules
14 18
15SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \ 19SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \
16 semaphore.c thunk.S 20 semaphore.c thunk.S module.c
17
18# this needs to be before the foreach, because clean-files does not accept
19# complete paths like $(src)/$f.
20clean-files := $(SYMLINKS)
21
22targets += $(SYMLINKS)
23
24SYMLINKS := $(foreach f,$(SYMLINKS),$(obj)/$f)
25 21
26bitops.c-dir = lib 22bitops.c-dir = lib
27csum-copy.S-dir = lib 23csum-copy.S-dir = lib
@@ -30,8 +26,8 @@ csum-wrappers.c-dir = lib
30memcpy.S-dir = lib 26memcpy.S-dir = lib
31semaphore.c-dir = kernel 27semaphore.c-dir = kernel
32thunk.S-dir = lib 28thunk.S-dir = lib
33 29module.c-dir = kernel
34$(SYMLINKS): FORCE
35 $(call if_changed,make_link)
36 30
37CFLAGS_csum-partial.o := -Dcsum_partial=arch_csum_partial 31CFLAGS_csum-partial.o := -Dcsum_partial=arch_csum_partial
32
33subdir- := util
diff --git a/arch/um/sys-x86_64/delay.c b/arch/um/sys-x86_64/delay.c
index f3b5187942b4..651332aeec22 100644
--- a/arch/um/sys-x86_64/delay.c
+++ b/arch/um/sys-x86_64/delay.c
@@ -5,7 +5,9 @@
5 * Licensed under the GPL 5 * Licensed under the GPL
6 */ 6 */
7 7
8#include "linux/delay.h"
8#include "asm/processor.h" 9#include "asm/processor.h"
10#include "asm/param.h"
9 11
10void __delay(unsigned long loops) 12void __delay(unsigned long loops)
11{ 13{
@@ -14,6 +16,22 @@ void __delay(unsigned long loops)
14 for(i = 0; i < loops; i++) ; 16 for(i = 0; i < loops; i++) ;
15} 17}
16 18
19void __udelay(unsigned long usecs)
20{
21 int i, n;
22
23 n = (loops_per_jiffy * HZ * usecs) / MILLION;
24 for(i=0;i<n;i++) ;
25}
26
27void __const_udelay(unsigned long usecs)
28{
29 int i, n;
30
31 n = (loops_per_jiffy * HZ * usecs) / MILLION;
32 for(i=0;i<n;i++) ;
33}
34
17/* 35/*
18 * Overrides for Emacs so that we follow Linus's tabbing style. 36 * Overrides for Emacs so that we follow Linus's tabbing style.
19 * Emacs will notice this stuff at the end of the file and automatically 37 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/sys-x86_64/kernel-offsets.c
new file mode 100644
index 000000000000..220e875cbe29
--- /dev/null
+++ b/arch/um/sys-x86_64/kernel-offsets.c
@@ -0,0 +1,24 @@
1#include <linux/config.h>
2#include <linux/stddef.h>
3#include <linux/sched.h>
4#include <linux/time.h>
5#include <asm/page.h>
6
7#define DEFINE(sym, val) \
8 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
9
10#define DEFINE_STR1(x) #x
11#define DEFINE_STR(sym, val) asm volatile("\n->" #sym " " DEFINE_STR1(val) " " #val: : )
12
13#define BLANK() asm volatile("\n->" : : )
14
15#define OFFSET(sym, str, mem) \
16 DEFINE(sym, offsetof(struct str, mem));
17
18void foo(void)
19{
20#ifdef CONFIG_MODE_TT
21 OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid);
22#endif
23#include <common-offsets.h>
24}
diff --git a/arch/um/sys-x86_64/ksyms.c b/arch/um/sys-x86_64/ksyms.c
new file mode 100644
index 000000000000..a27f0ee6a4f6
--- /dev/null
+++ b/arch/um/sys-x86_64/ksyms.c
@@ -0,0 +1,20 @@
1#include "linux/module.h"
2#include "linux/in6.h"
3#include "linux/rwsem.h"
4#include "asm/byteorder.h"
5#include "asm/semaphore.h"
6#include "asm/uaccess.h"
7#include "asm/checksum.h"
8#include "asm/errno.h"
9
10EXPORT_SYMBOL(__down_failed);
11EXPORT_SYMBOL(__down_failed_interruptible);
12EXPORT_SYMBOL(__down_failed_trylock);
13EXPORT_SYMBOL(__up_wakeup);
14
15/*XXX: we need them because they would be exported by x86_64 */
16EXPORT_SYMBOL(__memcpy);
17
18/* Networking helper routines. */
19/*EXPORT_SYMBOL(csum_partial_copy_from);
20EXPORT_SYMBOL(csum_partial_copy_to);*/
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index 8c146b2a1e00..b593bb256f2c 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -62,6 +62,27 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
62 return 0; 62 return 0;
63} 63}
64 64
65int poke_user(struct task_struct *child, long addr, long data)
66{
67 if ((addr & 3) || addr < 0)
68 return -EIO;
69
70 if (addr < MAX_REG_OFFSET)
71 return putreg(child, addr, data);
72
73#if 0 /* Need x86_64 debugregs handling */
74 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
75 (addr <= offsetof(struct user, u_debugreg[7]))){
76 addr -= offsetof(struct user, u_debugreg[0]);
77 addr = addr >> 2;
78 if((addr == 4) || (addr == 5)) return -EIO;
79 child->thread.arch.debugregs[addr] = data;
80 return 0;
81 }
82#endif
83 return -EIO;
84}
85
65unsigned long getreg(struct task_struct *child, int regno) 86unsigned long getreg(struct task_struct *child, int regno)
66{ 87{
67 unsigned long retval = ~0UL; 88 unsigned long retval = ~0UL;
@@ -84,6 +105,29 @@ unsigned long getreg(struct task_struct *child, int regno)
84 return retval; 105 return retval;
85} 106}
86 107
108int peek_user(struct task_struct *child, long addr, long data)
109{
110 /* read the word at location addr in the USER area. */
111 unsigned long tmp;
112
113 if ((addr & 3) || addr < 0)
114 return -EIO;
115
116 tmp = 0; /* Default return condition */
117 if(addr < MAX_REG_OFFSET){
118 tmp = getreg(child, addr);
119 }
120#if 0 /* Need x86_64 debugregs handling */
121 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
122 (addr <= offsetof(struct user, u_debugreg[7]))){
123 addr -= offsetof(struct user, u_debugreg[0]);
124 addr = addr >> 2;
125 tmp = child->thread.arch.debugregs[addr];
126 }
127#endif
128 return put_user(tmp, (unsigned long *) data);
129}
130
87void arch_switch(void) 131void arch_switch(void)
88{ 132{
89/* XXX 133/* XXX
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index 5bc5a0d796e5..73a7926f7370 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -57,7 +57,7 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
57int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, 57int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
58 struct pt_regs *regs, unsigned long mask) 58 struct pt_regs *regs, unsigned long mask)
59{ 59{
60 unsigned long eflags; 60 struct faultinfo * fi = &current->thread.arch.faultinfo;
61 int err = 0; 61 int err = 0;
62 62
63 err |= __put_user(0, &to->gs); 63 err |= __put_user(0, &to->gs);
@@ -84,14 +84,16 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
84 err |= PUTREG(regs, R14, to, r14); 84 err |= PUTREG(regs, R14, to, r14);
85 err |= PUTREG(regs, R15, to, r15); 85 err |= PUTREG(regs, R15, to, r15);
86 err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */ 86 err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */
87 err |= __put_user(current->thread.err, &to->err); 87
88 err |= __put_user(current->thread.trap_no, &to->trapno); 88 err |= __put_user(fi->cr2, &to->cr2);
89 err |= __put_user(fi->error_code, &to->err);
90 err |= __put_user(fi->trap_no, &to->trapno);
91
89 err |= PUTREG(regs, RIP, to, rip); 92 err |= PUTREG(regs, RIP, to, rip);
90 err |= PUTREG(regs, EFLAGS, to, eflags); 93 err |= PUTREG(regs, EFLAGS, to, eflags);
91#undef PUTREG 94#undef PUTREG
92 95
93 err |= __put_user(mask, &to->oldmask); 96 err |= __put_user(mask, &to->oldmask);
94 err |= __put_user(current->thread.cr2, &to->cr2);
95 97
96 return(err); 98 return(err);
97} 99}
@@ -166,7 +168,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
166 168
167 frame = (struct rt_sigframe __user *) 169 frame = (struct rt_sigframe __user *)
168 round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8; 170 round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8;
169 frame -= 128; 171 ((unsigned char *) frame) -= 128;
170 172
171 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) 173 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
172 goto out; 174 goto out;
diff --git a/arch/um/sys-x86_64/syscall_table.c b/arch/um/sys-x86_64/syscall_table.c
new file mode 100644
index 000000000000..34b2e842864f
--- /dev/null
+++ b/arch/um/sys-x86_64/syscall_table.c
@@ -0,0 +1,59 @@
1/* System call table for UML/x86-64, copied from arch/x86_64/kernel/syscall.c
2 * with some changes for UML. */
3
4#include <linux/linkage.h>
5#include <linux/sys.h>
6#include <linux/cache.h>
7#include <linux/config.h>
8
9#define __NO_STUBS
10
11/* Below you can see, in terms of #define's, the differences between the x86-64
12 * and the UML syscall table. */
13
14/* Not going to be implemented by UML, since we have no hardware. */
15#define stub_iopl sys_ni_syscall
16#define sys_ioperm sys_ni_syscall
17
18/* The UML TLS problem. Note that x86_64 does not implement this, so the below
19 * is needed only for the ia32 compatibility. */
20/*#define sys_set_thread_area sys_ni_syscall
21#define sys_get_thread_area sys_ni_syscall*/
22
23/* For __NR_time. The x86-64 name hopefully will change from sys_time64 to
24 * sys_time (since the current situation is bogus). I've sent a patch to cleanup
25 * this. Remove below the obsoleted line. */
26#define sys_time64 um_time
27#define sys_time um_time
28
29/* On UML we call it this way ("old" means it's not mmap2) */
30#define sys_mmap old_mmap
31/* On x86-64 sys_uname is actually sys_newuname plus a compatibility trick.
32 * See arch/x86_64/kernel/sys_x86_64.c */
33#define sys_uname sys_uname64
34
35#define stub_clone sys_clone
36#define stub_fork sys_fork
37#define stub_vfork sys_vfork
38#define stub_execve sys_execve
39#define stub_rt_sigsuspend sys_rt_sigsuspend
40#define stub_sigaltstack sys_sigaltstack
41#define stub_rt_sigreturn sys_rt_sigreturn
42
43#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
44#undef _ASM_X86_64_UNISTD_H_
45#include <asm-x86_64/unistd.h>
46
47#undef __SYSCALL
48#define __SYSCALL(nr, sym) [ nr ] = sym,
49#undef _ASM_X86_64_UNISTD_H_
50
51typedef void (*sys_call_ptr_t)(void);
52
53extern void sys_ni_syscall(void);
54
55sys_call_ptr_t sys_call_table[__NR_syscall_max+1] __cacheline_aligned = {
56 /* Smells like a like a compiler bug -- it doesn't work when the & below is removed. */
57 [0 ... __NR_syscall_max] = &sys_ni_syscall,
58#include <asm-x86_64/unistd.h>
59};
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c
index 68205a03364c..dd9914642b8e 100644
--- a/arch/um/sys-x86_64/syscalls.c
+++ b/arch/um/sys-x86_64/syscalls.c
@@ -7,6 +7,8 @@
7#include "linux/linkage.h" 7#include "linux/linkage.h"
8#include "linux/slab.h" 8#include "linux/slab.h"
9#include "linux/shm.h" 9#include "linux/shm.h"
10#include "linux/utsname.h"
11#include "linux/personality.h"
10#include "asm/uaccess.h" 12#include "asm/uaccess.h"
11#define __FRAME_OFFSETS 13#define __FRAME_OFFSETS
12#include "asm/ptrace.h" 14#include "asm/ptrace.h"
@@ -14,11 +16,15 @@
14#include "asm/prctl.h" /* XXX This should get the constants from libc */ 16#include "asm/prctl.h" /* XXX This should get the constants from libc */
15#include "choose-mode.h" 17#include "choose-mode.h"
16 18
17asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg) 19asmlinkage long sys_uname64(struct new_utsname __user * name)
18{ 20{
19 unsigned long raddr; 21 int err;
20 22 down_read(&uts_sem);
21 return do_shmat(shmid, shmaddr, shmflg, &raddr) ?: (long) raddr; 23 err = copy_to_user(name, &system_utsname, sizeof (*name));
24 up_read(&uts_sem);
25 if (personality(current->personality) == PER_LINUX32)
26 err |= copy_to_user(&name->machine, "i686", 5);
27 return err ? -EFAULT : 0;
22} 28}
23 29
24#ifdef CONFIG_MODE_TT 30#ifdef CONFIG_MODE_TT
@@ -38,6 +44,8 @@ long sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
38#ifdef CONFIG_MODE_SKAS 44#ifdef CONFIG_MODE_SKAS
39extern int userspace_pid[]; 45extern int userspace_pid[];
40 46
47#include "skas_ptrace.h"
48
41long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount) 49long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
42{ 50{
43 struct ptrace_ldt ldt; 51 struct ptrace_ldt ldt;
diff --git a/arch/um/sys-x86_64/um_module.c b/arch/um/sys-x86_64/um_module.c
new file mode 100644
index 000000000000..8b8eff1bd977
--- /dev/null
+++ b/arch/um/sys-x86_64/um_module.c
@@ -0,0 +1,19 @@
1#include <linux/vmalloc.h>
2#include <linux/moduleloader.h>
3
4/*Copied from i386 arch/i386/kernel/module.c */
5void *module_alloc(unsigned long size)
6{
7 if (size == 0)
8 return NULL;
9 return vmalloc_exec(size);
10}
11
12/* Free memory returned from module_alloc */
13void module_free(struct module *mod, void *module_region)
14{
15 vfree(module_region);
16 /* FIXME: If module_region == mod->init_region, trim exception
17 table entries. */
18}
19
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
new file mode 100644
index 000000000000..5e14792e4838
--- /dev/null
+++ b/arch/um/sys-x86_64/user-offsets.c
@@ -0,0 +1,78 @@
1#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
4#define __FRAME_OFFSETS
5#include <asm/ptrace.h>
6#include <asm/user.h>
7
8#define DEFINE(sym, val) \
9 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
10
11#define OFFSET(sym, str, mem) \
12 DEFINE(sym, offsetof(struct str, mem));
13
14void foo(void)
15{
16 OFFSET(SC_RBX, sigcontext, rbx);
17 OFFSET(SC_RCX, sigcontext, rcx);
18 OFFSET(SC_RDX, sigcontext, rdx);
19 OFFSET(SC_RSI, sigcontext, rsi);
20 OFFSET(SC_RDI, sigcontext, rdi);
21 OFFSET(SC_RBP, sigcontext, rbp);
22 OFFSET(SC_RAX, sigcontext, rax);
23 OFFSET(SC_R8, sigcontext, r8);
24 OFFSET(SC_R9, sigcontext, r9);
25 OFFSET(SC_R10, sigcontext, r10);
26 OFFSET(SC_R11, sigcontext, r11);
27 OFFSET(SC_R12, sigcontext, r12);
28 OFFSET(SC_R13, sigcontext, r13);
29 OFFSET(SC_R14, sigcontext, r14);
30 OFFSET(SC_R15, sigcontext, r15);
31 OFFSET(SC_IP, sigcontext, rip);
32 OFFSET(SC_SP, sigcontext, rsp);
33 OFFSET(SC_CR2, sigcontext, cr2);
34 OFFSET(SC_ERR, sigcontext, err);
35 OFFSET(SC_TRAPNO, sigcontext, trapno);
36 OFFSET(SC_CS, sigcontext, cs);
37 OFFSET(SC_FS, sigcontext, fs);
38 OFFSET(SC_GS, sigcontext, gs);
39 OFFSET(SC_EFLAGS, sigcontext, eflags);
40 OFFSET(SC_SIGMASK, sigcontext, oldmask);
41#if 0
42 OFFSET(SC_ORIG_RAX, sigcontext, orig_rax);
43 OFFSET(SC_DS, sigcontext, ds);
44 OFFSET(SC_ES, sigcontext, es);
45 OFFSET(SC_SS, sigcontext, ss);
46#endif
47
48 DEFINE(HOST_FRAME_SIZE, FRAME_SIZE);
49 DEFINE(HOST_RBX, RBX);
50 DEFINE(HOST_RCX, RCX);
51 DEFINE(HOST_RDI, RDI);
52 DEFINE(HOST_RSI, RSI);
53 DEFINE(HOST_RDX, RDX);
54 DEFINE(HOST_RBP, RBP);
55 DEFINE(HOST_RAX, RAX);
56 DEFINE(HOST_R8, R8);
57 DEFINE(HOST_R9, R9);
58 DEFINE(HOST_R10, R10);
59 DEFINE(HOST_R11, R11);
60 DEFINE(HOST_R12, R12);
61 DEFINE(HOST_R13, R13);
62 DEFINE(HOST_R14, R14);
63 DEFINE(HOST_R15, R15);
64 DEFINE(HOST_ORIG_RAX, ORIG_RAX);
65 DEFINE(HOST_CS, CS);
66 DEFINE(HOST_SS, SS);
67 DEFINE(HOST_EFLAGS, EFLAGS);
68#if 0
69 DEFINE(HOST_FS, FS);
70 DEFINE(HOST_GS, GS);
71 DEFINE(HOST_DS, DS);
72 DEFINE(HOST_ES, ES);
73#endif
74
75 DEFINE(HOST_IP, RIP);
76 DEFINE(HOST_SP, RSP);
77 DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct));
78}
diff --git a/arch/um/sys-x86_64/util/Makefile b/arch/um/sys-x86_64/util/Makefile
index 002607980864..75b052cfc206 100644
--- a/arch/um/sys-x86_64/util/Makefile
+++ b/arch/um/sys-x86_64/util/Makefile
@@ -4,7 +4,5 @@
4hostprogs-y := mk_sc mk_thread 4hostprogs-y := mk_sc mk_thread
5always := $(hostprogs-y) 5always := $(hostprogs-y)
6 6
7mk_thread-objs := mk_thread_kern.o mk_thread_user.o 7HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um
8 8HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um
9HOSTCFLAGS_mk_thread_kern.o := $(CFLAGS) $(CPPFLAGS)
10HOSTCFLAGS_mk_thread_user.o := $(USER_CFLAGS)
diff --git a/arch/um/sys-x86_64/util/mk_sc.c b/arch/um/sys-x86_64/util/mk_sc.c
index c236e213918d..7619bc377c1f 100644
--- a/arch/um/sys-x86_64/util/mk_sc.c
+++ b/arch/um/sys-x86_64/util/mk_sc.c
@@ -3,56 +3,45 @@
3 */ 3 */
4 4
5#include <stdio.h> 5#include <stdio.h>
6#include <signal.h> 6#include <user-offsets.h>
7#include <linux/stddef.h>
8 7
9#define SC_OFFSET(name, field) \ 8#define SC_OFFSET(name) \
10 printf("#define " name \ 9 printf("#define " #name \
11 "(sc) *((unsigned long *) &(((char *) (sc))[%ld]))\n",\ 10 "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\
12 offsetof(struct sigcontext, field)) 11 name)
13
14#define SC_FP_OFFSET(name, field) \
15 printf("#define " name \
16 "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%ld]))\n",\
17 offsetof(struct _fpstate, field))
18
19#define SC_FP_OFFSET_PTR(name, field, type) \
20 printf("#define " name \
21 "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\
22 offsetof(struct _fpstate, field))
23 12
24int main(int argc, char **argv) 13int main(int argc, char **argv)
25{ 14{
26 SC_OFFSET("SC_RBX", rbx); 15 SC_OFFSET(SC_RBX);
27 SC_OFFSET("SC_RCX", rcx); 16 SC_OFFSET(SC_RCX);
28 SC_OFFSET("SC_RDX", rdx); 17 SC_OFFSET(SC_RDX);
29 SC_OFFSET("SC_RSI", rsi); 18 SC_OFFSET(SC_RSI);
30 SC_OFFSET("SC_RDI", rdi); 19 SC_OFFSET(SC_RDI);
31 SC_OFFSET("SC_RBP", rbp); 20 SC_OFFSET(SC_RBP);
32 SC_OFFSET("SC_RAX", rax); 21 SC_OFFSET(SC_RAX);
33 SC_OFFSET("SC_R8", r8); 22 SC_OFFSET(SC_R8);
34 SC_OFFSET("SC_R9", r9); 23 SC_OFFSET(SC_R9);
35 SC_OFFSET("SC_R10", r10); 24 SC_OFFSET(SC_R10);
36 SC_OFFSET("SC_R11", r11); 25 SC_OFFSET(SC_R11);
37 SC_OFFSET("SC_R12", r12); 26 SC_OFFSET(SC_R12);
38 SC_OFFSET("SC_R13", r13); 27 SC_OFFSET(SC_R13);
39 SC_OFFSET("SC_R14", r14); 28 SC_OFFSET(SC_R14);
40 SC_OFFSET("SC_R15", r15); 29 SC_OFFSET(SC_R15);
41 SC_OFFSET("SC_IP", rip); 30 SC_OFFSET(SC_IP);
42 SC_OFFSET("SC_SP", rsp); 31 SC_OFFSET(SC_SP);
43 SC_OFFSET("SC_CR2", cr2); 32 SC_OFFSET(SC_CR2);
44 SC_OFFSET("SC_ERR", err); 33 SC_OFFSET(SC_ERR);
45 SC_OFFSET("SC_TRAPNO", trapno); 34 SC_OFFSET(SC_TRAPNO);
46 SC_OFFSET("SC_CS", cs); 35 SC_OFFSET(SC_CS);
47 SC_OFFSET("SC_FS", fs); 36 SC_OFFSET(SC_FS);
48 SC_OFFSET("SC_GS", gs); 37 SC_OFFSET(SC_GS);
49 SC_OFFSET("SC_EFLAGS", eflags); 38 SC_OFFSET(SC_EFLAGS);
50 SC_OFFSET("SC_SIGMASK", oldmask); 39 SC_OFFSET(SC_SIGMASK);
51#if 0 40#if 0
52 SC_OFFSET("SC_ORIG_RAX", orig_rax); 41 SC_OFFSET(SC_ORIG_RAX);
53 SC_OFFSET("SC_DS", ds); 42 SC_OFFSET(SC_DS);
54 SC_OFFSET("SC_ES", es); 43 SC_OFFSET(SC_ES);
55 SC_OFFSET("SC_SS", ss); 44 SC_OFFSET(SC_SS);
56#endif 45#endif
57 return(0); 46 return(0);
58} 47}
diff --git a/arch/um/sys-x86_64/util/mk_thread.c b/arch/um/sys-x86_64/util/mk_thread.c
new file mode 100644
index 000000000000..15517396e9cf
--- /dev/null
+++ b/arch/um/sys-x86_64/util/mk_thread.c
@@ -0,0 +1,20 @@
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/sys-x86_64/util/mk_thread_kern.c b/arch/um/sys-x86_64/util/mk_thread_kern.c
deleted file mode 100644
index a281673f02b2..000000000000
--- a/arch/um/sys-x86_64/util/mk_thread_kern.c
+++ /dev/null
@@ -1,21 +0,0 @@
1#include "linux/config.h"
2#include "linux/stddef.h"
3#include "linux/sched.h"
4
5extern void print_head(void);
6extern void print_constant_ptr(char *name, int value);
7extern void print_constant(char *name, char *type, int value);
8extern void print_tail(void);
9
10#define THREAD_OFFSET(field) offsetof(struct task_struct, thread.field)
11
12int main(int argc, char **argv)
13{
14 print_head();
15#ifdef CONFIG_MODE_TT
16 print_constant("TASK_EXTERN_PID", "int", THREAD_OFFSET(mode.tt.extern_pid));
17#endif
18 print_tail();
19 return(0);
20}
21
diff --git a/arch/um/sys-x86_64/util/mk_thread_user.c b/arch/um/sys-x86_64/util/mk_thread_user.c
deleted file mode 100644
index 7989725568b8..000000000000
--- a/arch/um/sys-x86_64/util/mk_thread_user.c
+++ /dev/null
@@ -1,30 +0,0 @@
1#include <stdio.h>
2
3void print_head(void)
4{
5 printf("/*\n");
6 printf(" * Generated by mk_thread\n");
7 printf(" */\n");
8 printf("\n");
9 printf("#ifndef __UM_THREAD_H\n");
10 printf("#define __UM_THREAD_H\n");
11 printf("\n");
12}
13
14void print_constant_ptr(char *name, int value)
15{
16 printf("#define %s(task) ((unsigned long *) "
17 "&(((char *) (task))[%d]))\n", name, value);
18}
19
20void print_constant(char *name, char *type, int value)
21{
22 printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
23 value);
24}
25
26void print_tail(void)
27{
28 printf("\n");
29 printf("#endif\n");
30}
diff --git a/arch/um/util/Makefile b/arch/um/util/Makefile
index e2ab71209f3f..4c7551c28033 100644
--- a/arch/um/util/Makefile
+++ b/arch/um/util/Makefile
@@ -1,8 +1,5 @@
1hostprogs-y := mk_task mk_constants 1hostprogs-y := mk_task mk_constants
2always := $(hostprogs-y) 2always := $(hostprogs-y)
3 3
4mk_task-objs := mk_task_user.o mk_task_kern.o 4HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um
5mk_constants-objs := mk_constants_user.o mk_constants_kern.o 5HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um
6
7HOSTCFLAGS_mk_task_kern.o := $(CFLAGS) $(CPPFLAGS)
8HOSTCFLAGS_mk_constants_kern.o := $(CFLAGS) $(CPPFLAGS)
diff --git a/arch/um/util/mk_constants.c b/arch/um/util/mk_constants.c
new file mode 100644
index 000000000000..ab217becc36a
--- /dev/null
+++ b/arch/um/util/mk_constants.c
@@ -0,0 +1,32 @@
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_constants_kern.c b/arch/um/util/mk_constants_kern.c
deleted file mode 100644
index cdcb1232a1ea..000000000000
--- a/arch/um/util/mk_constants_kern.c
+++ /dev/null
@@ -1,28 +0,0 @@
1#include "linux/kernel.h"
2#include "linux/stringify.h"
3#include "linux/time.h"
4#include "asm/page.h"
5
6extern void print_head(void);
7extern void print_constant_str(char *name, char *value);
8extern void print_constant_int(char *name, int value);
9extern void print_tail(void);
10
11int main(int argc, char **argv)
12{
13 print_head();
14 print_constant_int("UM_KERN_PAGE_SIZE", PAGE_SIZE);
15
16 print_constant_str("UM_KERN_EMERG", KERN_EMERG);
17 print_constant_str("UM_KERN_ALERT", KERN_ALERT);
18 print_constant_str("UM_KERN_CRIT", KERN_CRIT);
19 print_constant_str("UM_KERN_ERR", KERN_ERR);
20 print_constant_str("UM_KERN_WARNING", KERN_WARNING);
21 print_constant_str("UM_KERN_NOTICE", KERN_NOTICE);
22 print_constant_str("UM_KERN_INFO", KERN_INFO);
23 print_constant_str("UM_KERN_DEBUG", KERN_DEBUG);
24
25 print_constant_int("UM_NSEC_PER_SEC", NSEC_PER_SEC);
26 print_tail();
27 return(0);
28}
diff --git a/arch/um/util/mk_constants_user.c b/arch/um/util/mk_constants_user.c
deleted file mode 100644
index 8f4d7e50be7c..000000000000
--- a/arch/um/util/mk_constants_user.c
+++ /dev/null
@@ -1,28 +0,0 @@
1#include <stdio.h>
2
3void print_head(void)
4{
5 printf("/*\n");
6 printf(" * Generated by mk_constants\n");
7 printf(" */\n");
8 printf("\n");
9 printf("#ifndef __UM_CONSTANTS_H\n");
10 printf("#define __UM_CONSTANTS_H\n");
11 printf("\n");
12}
13
14void print_constant_str(char *name, char *value)
15{
16 printf("#define %s \"%s\"\n", name, value);
17}
18
19void print_constant_int(char *name, int value)
20{
21 printf("#define %s %d\n", name, value);
22}
23
24void print_tail(void)
25{
26 printf("\n");
27 printf("#endif\n");
28}
diff --git a/arch/um/util/mk_task_user.c b/arch/um/util/mk_task.c
index 9db849f3f3ac..36c9606505e2 100644
--- a/arch/um/util/mk_task_user.c
+++ b/arch/um/util/mk_task.c
@@ -1,18 +1,19 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <kernel-offsets.h>
2 3
3void print(char *name, char *type, int offset) 4void print_ptr(char *name, char *type, int offset)
4{ 5{
5 printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, 6 printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type,
6 offset); 7 offset);
7} 8}
8 9
9void print_ptr(char *name, char *type, int offset) 10void print(char *name, char *type, int offset)
10{ 11{
11 printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type, 12 printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type,
12 offset); 13 offset);
13} 14}
14 15
15void print_head(void) 16int main(int argc, char **argv)
16{ 17{
17 printf("/*\n"); 18 printf("/*\n");
18 printf(" * Generated by mk_task\n"); 19 printf(" * Generated by mk_task\n");
@@ -21,10 +22,9 @@ void print_head(void)
21 printf("#ifndef __TASK_H\n"); 22 printf("#ifndef __TASK_H\n");
22 printf("#define __TASK_H\n"); 23 printf("#define __TASK_H\n");
23 printf("\n"); 24 printf("\n");
24} 25 print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS);
25 26 print("TASK_PID", "int", TASK_PID);
26void print_tail(void)
27{
28 printf("\n"); 27 printf("\n");
29 printf("#endif\n"); 28 printf("#endif\n");
29 return(0);
30} 30}
diff --git a/arch/um/util/mk_task_kern.c b/arch/um/util/mk_task_kern.c
deleted file mode 100644
index c218103315ed..000000000000
--- a/arch/um/util/mk_task_kern.c
+++ /dev/null
@@ -1,17 +0,0 @@
1#include "linux/sched.h"
2#include "linux/stddef.h"
3
4extern void print(char *name, char *type, int offset);
5extern void print_ptr(char *name, char *type, int offset);
6extern void print_head(void);
7extern void print_tail(void);
8
9int main(int argc, char **argv)
10{
11 print_head();
12 print_ptr("TASK_REGS", "union uml_pt_regs",
13 offsetof(struct task_struct, thread.regs));
14 print("TASK_PID", "int", offsetof(struct task_struct, pid));
15 print_tail();
16 return(0);
17}
diff --git a/arch/v850/kernel/ptrace.c b/arch/v850/kernel/ptrace.c
index 8fa780757dcd..4726b87f5e5a 100644
--- a/arch/v850/kernel/ptrace.c
+++ b/arch/v850/kernel/ptrace.c
@@ -23,6 +23,7 @@
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
25#include <linux/ptrace.h> 25#include <linux/ptrace.h>
26#include <linux/signal.h>
26 27
27#include <asm/errno.h> 28#include <asm/errno.h>
28#include <asm/ptrace.h> 29#include <asm/ptrace.h>
@@ -208,7 +209,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
208 /* Execute a single instruction. */ 209 /* Execute a single instruction. */
209 case PTRACE_SINGLESTEP: 210 case PTRACE_SINGLESTEP:
210 rval = -EIO; 211 rval = -EIO;
211 if ((unsigned long) data > _NSIG) 212 if (!valid_signal(data))
212 break; 213 break;
213 214
214 /* Turn CHILD's single-step flag on or off. */ 215 /* Turn CHILD's single-step flag on or off. */
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 80c38c5d71fe..44ee7f6acf7b 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -379,6 +379,11 @@ config GENERIC_IRQ_PROBE
379 bool 379 bool
380 default y 380 default y
381 381
382# we have no ISA slots, but we do have ISA-style DMA.
383config ISA_DMA_API
384 bool
385 default y
386
382menu "Power management options" 387menu "Power management options"
383 388
384source kernel/power/Kconfig 389source kernel/power/Kconfig
diff --git a/arch/x86_64/boot/bootsect.S b/arch/x86_64/boot/bootsect.S
index bb15d406ee95..011b7a4993d4 100644
--- a/arch/x86_64/boot/bootsect.S
+++ b/arch/x86_64/boot/bootsect.S
@@ -63,7 +63,7 @@ msg_loop:
63 jz die 63 jz die
64 movb $0xe, %ah 64 movb $0xe, %ah
65 movw $7, %bx 65 movw $7, %bx
66 int $0x10 66 int $0x10
67 jmp msg_loop 67 jmp msg_loop
68 68
69die: 69die:
@@ -71,7 +71,7 @@ die:
71 xorw %ax, %ax 71 xorw %ax, %ax
72 int $0x16 72 int $0x16
73 int $0x19 73 int $0x19
74 74
75 # int 0x19 should never return. In case it does anyway, 75 # int 0x19 should never return. In case it does anyway,
76 # invoke the BIOS reset code... 76 # invoke the BIOS reset code...
77 ljmp $0xf000,$0xfff0 77 ljmp $0xf000,$0xfff0
diff --git a/arch/x86_64/boot/setup.S b/arch/x86_64/boot/setup.S
index 3e838be9dbe7..75d4d2ad93b3 100644
--- a/arch/x86_64/boot/setup.S
+++ b/arch/x86_64/boot/setup.S
@@ -160,7 +160,7 @@ ramdisk_max: .long 0xffffffff
160trampoline: call start_of_setup 160trampoline: call start_of_setup
161 .align 16 161 .align 16
162 # The offset at this point is 0x240 162 # The offset at this point is 0x240
163 .space (0x7ff-0x240+1) # E820 & EDD space (ending at 0x7ff) 163 .space (0xeff-0x240+1) # E820 & EDD space (ending at 0xeff)
164# End of setup header ##################################################### 164# End of setup header #####################################################
165 165
166start_of_setup: 166start_of_setup:
@@ -412,9 +412,9 @@ jmpe820:
412 # sizeof(e820rec). 412 # sizeof(e820rec).
413 # 413 #
414good820: 414good820:
415 movb (E820NR), %al # up to 32 entries 415 movb (E820NR), %al # up to 128 entries
416 cmpb $E820MAX, %al 416 cmpb $E820MAX, %al
417 jnl bail820 417 jae bail820
418 418
419 incb (E820NR) 419 incb (E820NR)
420 movw %di, %ax 420 movw %di, %ax
diff --git a/arch/x86_64/ia32/vsyscall.lds b/arch/x86_64/ia32/vsyscall.lds
index fa4b4dd4a9ff..f2e75ed4c6c7 100644
--- a/arch/x86_64/ia32/vsyscall.lds
+++ b/arch/x86_64/ia32/vsyscall.lds
@@ -36,6 +36,7 @@ SECTIONS
36 36
37 .text.rtsigreturn : { *(.text.rtsigreturn) } :text =0x90909090 37 .text.rtsigreturn : { *(.text.rtsigreturn) } :text =0x90909090
38 38
39 .note : { *(.note.*) } :text :note
39 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr 40 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
40 .eh_frame : { KEEP (*(.eh_frame)) } :text 41 .eh_frame : { KEEP (*(.eh_frame)) } :text
41 .dynamic : { *(.dynamic) } :text :dynamic 42 .dynamic : { *(.dynamic) } :text :dynamic
@@ -55,6 +56,7 @@ PHDRS
55{ 56{
56 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */ 57 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
57 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 58 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
59 note PT_NOTE FLAGS(4); /* PF_R */
58 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */ 60 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
59} 61}
60 62
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 56516ac92e5d..7c154dfff64a 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -2,6 +2,12 @@
2 * Handle the memory map. 2 * Handle the memory map.
3 * The functions here do the job until bootmem takes over. 3 * The functions here do the job until bootmem takes over.
4 * $Id: e820.c,v 1.4 2002/09/19 19:25:32 ak Exp $ 4 * $Id: e820.c,v 1.4 2002/09/19 19:25:32 ak Exp $
5 *
6 * Getting sanitize_e820_map() in sync with i386 version by applying change:
7 * - Provisions for empty E820 memory regions (reported by certain BIOSes).
8 * Alex Achenbach <xela@slit.de>, December 2002.
9 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
10 *
5 */ 11 */
6#include <linux/config.h> 12#include <linux/config.h>
7#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -277,7 +283,7 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
277 int chgidx, still_changing; 283 int chgidx, still_changing;
278 int overlap_entries; 284 int overlap_entries;
279 int new_bios_entry; 285 int new_bios_entry;
280 int old_nr, new_nr; 286 int old_nr, new_nr, chg_nr;
281 int i; 287 int i;
282 288
283 /* 289 /*
@@ -331,20 +337,24 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
331 for (i=0; i < 2*old_nr; i++) 337 for (i=0; i < 2*old_nr; i++)
332 change_point[i] = &change_point_list[i]; 338 change_point[i] = &change_point_list[i];
333 339
334 /* record all known change-points (starting and ending addresses) */ 340 /* record all known change-points (starting and ending addresses),
341 omitting those that are for empty memory regions */
335 chgidx = 0; 342 chgidx = 0;
336 for (i=0; i < old_nr; i++) { 343 for (i=0; i < old_nr; i++) {
337 change_point[chgidx]->addr = biosmap[i].addr; 344 if (biosmap[i].size != 0) {
338 change_point[chgidx++]->pbios = &biosmap[i]; 345 change_point[chgidx]->addr = biosmap[i].addr;
339 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size; 346 change_point[chgidx++]->pbios = &biosmap[i];
340 change_point[chgidx++]->pbios = &biosmap[i]; 347 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
348 change_point[chgidx++]->pbios = &biosmap[i];
349 }
341 } 350 }
351 chg_nr = chgidx;
342 352
343 /* sort change-point list by memory addresses (low -> high) */ 353 /* sort change-point list by memory addresses (low -> high) */
344 still_changing = 1; 354 still_changing = 1;
345 while (still_changing) { 355 while (still_changing) {
346 still_changing = 0; 356 still_changing = 0;
347 for (i=1; i < 2*old_nr; i++) { 357 for (i=1; i < chg_nr; i++) {
348 /* if <current_addr> > <last_addr>, swap */ 358 /* if <current_addr> > <last_addr>, swap */
349 /* or, if current=<start_addr> & last=<end_addr>, swap */ 359 /* or, if current=<start_addr> & last=<end_addr>, swap */
350 if ((change_point[i]->addr < change_point[i-1]->addr) || 360 if ((change_point[i]->addr < change_point[i-1]->addr) ||
@@ -367,7 +377,7 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
367 last_type = 0; /* start with undefined memory type */ 377 last_type = 0; /* start with undefined memory type */
368 last_addr = 0; /* start with 0 as last starting address */ 378 last_addr = 0; /* start with 0 as last starting address */
369 /* loop through change-points, determining affect on the new bios map */ 379 /* loop through change-points, determining affect on the new bios map */
370 for (chgidx=0; chgidx < 2*old_nr; chgidx++) 380 for (chgidx=0; chgidx < chg_nr; chgidx++)
371 { 381 {
372 /* keep track of all overlapping bios entries */ 382 /* keep track of all overlapping bios entries */
373 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr) 383 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 750bcd0655dc..e3a19e8ebbf8 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -60,7 +60,7 @@ static struct console early_vga_console = {
60 60
61/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */ 61/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
62 62
63int early_serial_base = 0x3f8; /* ttyS0 */ 63static int early_serial_base = 0x3f8; /* ttyS0 */
64 64
65#define XMTRDY 0x20 65#define XMTRDY 0x20
66 66
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 3233a15cc4e0..1086b5fcac21 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -296,6 +296,7 @@ int_very_careful:
296 call syscall_trace_leave 296 call syscall_trace_leave
297 popq %rdi 297 popq %rdi
298 andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi 298 andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi
299 cli
299 jmp int_restore_rest 300 jmp int_restore_rest
300 301
301int_signal: 302int_signal:
@@ -307,6 +308,7 @@ int_signal:
3071: movl $_TIF_NEED_RESCHED,%edi 3081: movl $_TIF_NEED_RESCHED,%edi
308int_restore_rest: 309int_restore_rest:
309 RESTORE_REST 310 RESTORE_REST
311 cli
310 jmp int_with_check 312 jmp int_with_check
311 CFI_ENDPROC 313 CFI_ENDPROC
312 314
@@ -490,7 +492,8 @@ retint_signal:
490 call do_notify_resume 492 call do_notify_resume
491 RESTORE_REST 493 RESTORE_REST
492 cli 494 cli
493 GET_THREAD_INFO(%rcx) 495 GET_THREAD_INFO(%rcx)
496 movl $_TIF_WORK_MASK,%edi
494 jmp retint_check 497 jmp retint_check
495 498
496#ifdef CONFIG_PREEMPT 499#ifdef CONFIG_PREEMPT
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index 6cad46c98a23..0f8c78dcd38c 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -29,8 +29,6 @@ static void __init clear_bss(void)
29 (unsigned long) __bss_end - (unsigned long) __bss_start); 29 (unsigned long) __bss_end - (unsigned long) __bss_start);
30} 30}
31 31
32extern char x86_boot_params[2048];
33
34#define NEW_CL_POINTER 0x228 /* Relative to real mode data */ 32#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
35#define OLD_CL_MAGIC_ADDR 0x90020 33#define OLD_CL_MAGIC_ADDR 0x90020
36#define OLD_CL_MAGIC 0xA33F 34#define OLD_CL_MAGIC 0xA33F
@@ -44,7 +42,7 @@ static void __init copy_bootdata(char *real_mode_data)
44 int new_data; 42 int new_data;
45 char * command_line; 43 char * command_line;
46 44
47 memcpy(x86_boot_params, real_mode_data, 2048); 45 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
48 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER); 46 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
49 if (!new_data) { 47 if (!new_data) {
50 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) { 48 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
@@ -93,9 +91,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
93#ifdef CONFIG_SMP 91#ifdef CONFIG_SMP
94 cpu_set(0, cpu_online_map); 92 cpu_set(0, cpu_online_map);
95#endif 93#endif
96 /* default console: */
97 if (!strstr(saved_command_line, "console="))
98 strcat(saved_command_line, " console=tty0");
99 s = strstr(saved_command_line, "earlyprintk="); 94 s = strstr(saved_command_line, "earlyprintk=");
100 if (s != NULL) 95 if (s != NULL)
101 setup_early_printk(s); 96 setup_early_printk(s);
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 29a257295484..60be58617eb9 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -1607,7 +1607,6 @@ static inline void check_timer(void)
1607 disable_8259A_irq(0); 1607 disable_8259A_irq(0);
1608 setup_nmi(); 1608 setup_nmi();
1609 enable_8259A_irq(0); 1609 enable_8259A_irq(0);
1610 check_nmi_watchdog();
1611 } 1610 }
1612 return; 1611 return;
1613 } 1612 }
@@ -1627,7 +1626,6 @@ static inline void check_timer(void)
1627 nmi_watchdog_default(); 1626 nmi_watchdog_default();
1628 if (nmi_watchdog == NMI_IO_APIC) { 1627 if (nmi_watchdog == NMI_IO_APIC) {
1629 setup_nmi(); 1628 setup_nmi();
1630 check_nmi_watchdog();
1631 } 1629 }
1632 return; 1630 return;
1633 } 1631 }
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index 4f2a852299b6..f77f8a0ff187 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -355,6 +355,13 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs)
355 *tos &= ~(TF_MASK | IF_MASK); 355 *tos &= ~(TF_MASK | IF_MASK);
356 *tos |= kprobe_old_rflags; 356 *tos |= kprobe_old_rflags;
357 break; 357 break;
358 case 0xc3: /* ret/lret */
359 case 0xcb:
360 case 0xc2:
361 case 0xca:
362 regs->eflags &= ~TF_MASK;
363 /* rip is already adjusted, no more changes required*/
364 return;
358 case 0xe8: /* call relative - Fix return addr */ 365 case 0xe8: /* call relative - Fix return addr */
359 *tos = orig_rip + (*tos - copy_rip); 366 *tos = orig_rip + (*tos - copy_rip);
360 break; 367 break;
diff --git a/arch/x86_64/kernel/module.c b/arch/x86_64/kernel/module.c
index c2ffea8845ed..bac195c74bcc 100644
--- a/arch/x86_64/kernel/module.c
+++ b/arch/x86_64/kernel/module.c
@@ -30,9 +30,12 @@
30 30
31#define DEBUGP(fmt...) 31#define DEBUGP(fmt...)
32 32
33#ifndef CONFIG_UML
33void module_free(struct module *mod, void *module_region) 34void module_free(struct module *mod, void *module_region)
34{ 35{
35 vfree(module_region); 36 vfree(module_region);
37 /* FIXME: If module_region == mod->init_region, trim exception
38 table entries. */
36} 39}
37 40
38void *module_alloc(unsigned long size) 41void *module_alloc(unsigned long size)
@@ -51,6 +54,7 @@ void *module_alloc(unsigned long size)
51 54
52 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC); 55 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
53} 56}
57#endif
54 58
55/* We don't need anything special. */ 59/* We don't need anything special. */
56int module_frob_arch_sections(Elf_Ehdr *hdr, 60int module_frob_arch_sections(Elf_Ehdr *hdr,
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index e00d4adec36b..61de0b34a01e 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -112,17 +112,20 @@ static __init int cpu_has_lapic(void)
112 } 112 }
113} 113}
114 114
115int __init check_nmi_watchdog (void) 115static int __init check_nmi_watchdog (void)
116{ 116{
117 int counts[NR_CPUS]; 117 int counts[NR_CPUS];
118 int cpu; 118 int cpu;
119 119
120 if (nmi_watchdog == NMI_NONE)
121 return 0;
122
120 if (nmi_watchdog == NMI_LOCAL_APIC && !cpu_has_lapic()) { 123 if (nmi_watchdog == NMI_LOCAL_APIC && !cpu_has_lapic()) {
121 nmi_watchdog = NMI_NONE; 124 nmi_watchdog = NMI_NONE;
122 return -1; 125 return -1;
123 } 126 }
124 127
125 printk(KERN_INFO "testing NMI watchdog ... "); 128 printk(KERN_INFO "Testing NMI watchdog ... ");
126 129
127 for (cpu = 0; cpu < NR_CPUS; cpu++) 130 for (cpu = 0; cpu < NR_CPUS; cpu++)
128 counts[cpu] = cpu_pda[cpu].__nmi_count; 131 counts[cpu] = cpu_pda[cpu].__nmi_count;
@@ -148,6 +151,8 @@ int __init check_nmi_watchdog (void)
148 151
149 return 0; 152 return 0;
150} 153}
154/* Have this called later during boot so counters are updating */
155late_initcall(check_nmi_watchdog);
151 156
152int __init setup_nmi_watchdog(char *str) 157int __init setup_nmi_watchdog(char *str)
153{ 158{
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 9922d2ba24a3..761b6d35e338 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -402,10 +402,10 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long rsp,
402 p->thread.fs = me->thread.fs; 402 p->thread.fs = me->thread.fs;
403 p->thread.gs = me->thread.gs; 403 p->thread.gs = me->thread.gs;
404 404
405 asm("movl %%gs,%0" : "=m" (p->thread.gsindex)); 405 asm("mov %%gs,%0" : "=m" (p->thread.gsindex));
406 asm("movl %%fs,%0" : "=m" (p->thread.fsindex)); 406 asm("mov %%fs,%0" : "=m" (p->thread.fsindex));
407 asm("movl %%es,%0" : "=m" (p->thread.es)); 407 asm("mov %%es,%0" : "=m" (p->thread.es));
408 asm("movl %%ds,%0" : "=m" (p->thread.ds)); 408 asm("mov %%ds,%0" : "=m" (p->thread.ds));
409 409
410 if (unlikely(me->thread.io_bitmap_ptr != NULL)) { 410 if (unlikely(me->thread.io_bitmap_ptr != NULL)) {
411 p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL); 411 p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
@@ -468,11 +468,11 @@ struct task_struct *__switch_to(struct task_struct *prev_p, struct task_struct *
468 * Switch DS and ES. 468 * Switch DS and ES.
469 * This won't pick up thread selector changes, but I guess that is ok. 469 * This won't pick up thread selector changes, but I guess that is ok.
470 */ 470 */
471 asm volatile("movl %%es,%0" : "=m" (prev->es)); 471 asm volatile("mov %%es,%0" : "=m" (prev->es));
472 if (unlikely(next->es | prev->es)) 472 if (unlikely(next->es | prev->es))
473 loadsegment(es, next->es); 473 loadsegment(es, next->es);
474 474
475 asm volatile ("movl %%ds,%0" : "=m" (prev->ds)); 475 asm volatile ("mov %%ds,%0" : "=m" (prev->ds));
476 if (unlikely(next->ds | prev->ds)) 476 if (unlikely(next->ds | prev->ds))
477 loadsegment(ds, next->ds); 477 loadsegment(ds, next->ds);
478 478
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index c7011675007d..e26e86bb56fe 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -18,6 +18,7 @@
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/audit.h> 19#include <linux/audit.h>
20#include <linux/seccomp.h> 20#include <linux/seccomp.h>
21#include <linux/signal.h>
21 22
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
@@ -467,7 +468,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
467 case PTRACE_CONT: /* restart after signal. */ 468 case PTRACE_CONT: /* restart after signal. */
468 469
469 ret = -EIO; 470 ret = -EIO;
470 if ((unsigned long) data > _NSIG) 471 if (!valid_signal(data))
471 break; 472 break;
472 if (request == PTRACE_SYSCALL) 473 if (request == PTRACE_SYSCALL)
473 set_tsk_thread_flag(child,TIF_SYSCALL_TRACE); 474 set_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
@@ -529,7 +530,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
529 530
530 case PTRACE_SINGLESTEP: /* set the trap flag. */ 531 case PTRACE_SINGLESTEP: /* set the trap flag. */
531 ret = -EIO; 532 ret = -EIO;
532 if ((unsigned long) data > _NSIG) 533 if (!valid_signal(data))
533 break; 534 break;
534 clear_tsk_thread_flag(child,TIF_SYSCALL_TRACE); 535 clear_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
535 set_singlestep(child); 536 set_singlestep(child);
@@ -634,20 +635,29 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
634 /* do the secure computing check first */ 635 /* do the secure computing check first */
635 secure_computing(regs->orig_rax); 636 secure_computing(regs->orig_rax);
636 637
637 if (unlikely(current->audit_context))
638 audit_syscall_entry(current, regs->orig_rax,
639 regs->rdi, regs->rsi,
640 regs->rdx, regs->r10);
641
642 if (test_thread_flag(TIF_SYSCALL_TRACE) 638 if (test_thread_flag(TIF_SYSCALL_TRACE)
643 && (current->ptrace & PT_PTRACED)) 639 && (current->ptrace & PT_PTRACED))
644 syscall_trace(regs); 640 syscall_trace(regs);
641
642 if (unlikely(current->audit_context)) {
643 if (test_thread_flag(TIF_IA32)) {
644 audit_syscall_entry(current, AUDIT_ARCH_I386,
645 regs->orig_rax,
646 regs->rbx, regs->rcx,
647 regs->rdx, regs->rsi);
648 } else {
649 audit_syscall_entry(current, AUDIT_ARCH_X86_64,
650 regs->orig_rax,
651 regs->rdi, regs->rsi,
652 regs->rdx, regs->r10);
653 }
654 }
645} 655}
646 656
647asmlinkage void syscall_trace_leave(struct pt_regs *regs) 657asmlinkage void syscall_trace_leave(struct pt_regs *regs)
648{ 658{
649 if (unlikely(current->audit_context)) 659 if (unlikely(current->audit_context))
650 audit_syscall_exit(current, regs->rax); 660 audit_syscall_exit(current, AUDITSC_RESULT(regs->rax), regs->rax);
651 661
652 if ((test_thread_flag(TIF_SYSCALL_TRACE) 662 if ((test_thread_flag(TIF_SYSCALL_TRACE)
653 || test_thread_flag(TIF_SINGLESTEP)) 663 || test_thread_flag(TIF_SINGLESTEP))
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index b18c114c7648..2129cf9ba6b2 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -977,7 +977,7 @@ void __init identify_cpu(struct cpuinfo_x86 *c)
977 if ((xlvl & 0xffff0000) == 0x80000000) { 977 if ((xlvl & 0xffff0000) == 0x80000000) {
978 if (xlvl >= 0x80000001) { 978 if (xlvl >= 0x80000001) {
979 c->x86_capability[1] = cpuid_edx(0x80000001); 979 c->x86_capability[1] = cpuid_edx(0x80000001);
980 c->x86_capability[5] = cpuid_ecx(0x80000001); 980 c->x86_capability[6] = cpuid_ecx(0x80000001);
981 } 981 }
982 if (xlvl >= 0x80000004) 982 if (xlvl >= 0x80000004)
983 get_model_name(c); /* Default name */ 983 get_model_name(c); /* Default name */
@@ -1076,7 +1076,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1076 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL, 1076 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", NULL,
1077 1077
1078 /* AMD-defined */ 1078 /* AMD-defined */
1079 "pni", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1079 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1080 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL, 1080 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
1081 NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL, 1081 NULL, NULL, NULL, NULL, "nx", NULL, "mmxext", NULL,
1082 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow", 1082 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
@@ -1100,11 +1100,17 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1100 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1100 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1101 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1101 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1102 1102
1103 /* VIA/Cyrix/Centaur-defined */
1104 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
1105 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1106 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1107 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1108
1103 /* AMD-defined (#2) */ 1109 /* AMD-defined (#2) */
1104 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL, 1110 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL,
1105 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1111 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1106 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1112 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1107 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL 1113 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1108 }; 1114 };
1109 static char *x86_power_flags[] = { 1115 static char *x86_power_flags[] = {
1110 "ts", /* temperature sensor */ 1116 "ts", /* temperature sensor */
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index b5305b04bc40..678b7ac33b8b 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -12,6 +12,7 @@
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/bitops.h> 14#include <linux/bitops.h>
15#include <asm/bootsetup.h>
15#include <asm/pda.h> 16#include <asm/pda.h>
16#include <asm/pgtable.h> 17#include <asm/pgtable.h>
17#include <asm/processor.h> 18#include <asm/processor.h>
@@ -26,7 +27,7 @@
26#include <asm/mman.h> 27#include <asm/mman.h>
27#include <asm/numa.h> 28#include <asm/numa.h>
28 29
29char x86_boot_params[2048] __initdata = {0,}; 30char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
30 31
31cpumask_t cpu_initialized __initdata = CPU_MASK_NONE; 32cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
32 33
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 7760224cdfe3..d439ced150c6 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -83,7 +83,7 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
83 83
84struct rt_sigframe 84struct rt_sigframe
85{ 85{
86 char *pretcode; 86 char __user *pretcode;
87 struct ucontext uc; 87 struct ucontext uc;
88 struct siginfo info; 88 struct siginfo info;
89}; 89};
diff --git a/arch/x86_64/kernel/sys_x86_64.c b/arch/x86_64/kernel/sys_x86_64.c
index 477d8be57d64..dbebd5ccba6b 100644
--- a/arch/x86_64/kernel/sys_x86_64.c
+++ b/arch/x86_64/kernel/sys_x86_64.c
@@ -152,12 +152,6 @@ asmlinkage long sys_uname(struct new_utsname __user * name)
152 return err ? -EFAULT : 0; 152 return err ? -EFAULT : 0;
153} 153}
154 154
155asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
156{
157 unsigned long raddr;
158 return do_shmat(shmid,shmaddr,shmflg,&raddr) ?: (long)raddr;
159}
160
161asmlinkage long sys_time64(long __user * tloc) 155asmlinkage long sys_time64(long __user * tloc)
162{ 156{
163 struct timeval now; 157 struct timeval now;
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index 88626e626886..a43dedb58fa2 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -139,35 +139,23 @@ EXPORT_SYMBOL_GPL(unset_nmi_callback);
139#undef memmove 139#undef memmove
140#undef memchr 140#undef memchr
141#undef strlen 141#undef strlen
142#undef strcpy
143#undef strncmp 142#undef strncmp
144#undef strncpy 143#undef strncpy
145#undef strchr 144#undef strchr
146#undef strcmp
147#undef strcpy
148#undef strcat
149#undef memcmp
150 145
151extern void * memset(void *,int,__kernel_size_t); 146extern void * memset(void *,int,__kernel_size_t);
152extern size_t strlen(const char *); 147extern size_t strlen(const char *);
153extern void * memmove(void * dest,const void *src,size_t count); 148extern void * memmove(void * dest,const void *src,size_t count);
154extern char * strcpy(char * dest,const char *src);
155extern int strcmp(const char * cs,const char * ct);
156extern void *memchr(const void *s, int c, size_t n); 149extern void *memchr(const void *s, int c, size_t n);
157extern void * memcpy(void *,const void *,__kernel_size_t); 150extern void * memcpy(void *,const void *,__kernel_size_t);
158extern void * __memcpy(void *,const void *,__kernel_size_t); 151extern void * __memcpy(void *,const void *,__kernel_size_t);
159extern char * strcat(char *, const char *);
160extern int memcmp(const void * cs,const void * ct,size_t count);
161 152
162EXPORT_SYMBOL(memset); 153EXPORT_SYMBOL(memset);
163EXPORT_SYMBOL(strlen); 154EXPORT_SYMBOL(strlen);
164EXPORT_SYMBOL(memmove); 155EXPORT_SYMBOL(memmove);
165EXPORT_SYMBOL(strcpy);
166EXPORT_SYMBOL(strncmp); 156EXPORT_SYMBOL(strncmp);
167EXPORT_SYMBOL(strncpy); 157EXPORT_SYMBOL(strncpy);
168EXPORT_SYMBOL(strchr); 158EXPORT_SYMBOL(strchr);
169EXPORT_SYMBOL(strcmp);
170EXPORT_SYMBOL(strcat);
171EXPORT_SYMBOL(strncat); 159EXPORT_SYMBOL(strncat);
172EXPORT_SYMBOL(memchr); 160EXPORT_SYMBOL(memchr);
173EXPORT_SYMBOL(strrchr); 161EXPORT_SYMBOL(strrchr);
@@ -175,7 +163,6 @@ EXPORT_SYMBOL(strnlen);
175EXPORT_SYMBOL(memscan); 163EXPORT_SYMBOL(memscan);
176EXPORT_SYMBOL(memcpy); 164EXPORT_SYMBOL(memcpy);
177EXPORT_SYMBOL(__memcpy); 165EXPORT_SYMBOL(__memcpy);
178EXPORT_SYMBOL(memcmp);
179 166
180#ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM 167#ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
181/* prototypes are wrong, these are assembly with custom calling functions */ 168/* prototypes are wrong, these are assembly with custom calling functions */
diff --git a/arch/x86_64/lib/putuser.S b/arch/x86_64/lib/putuser.S
index d9d3e5ec9ad1..5828b8191667 100644
--- a/arch/x86_64/lib/putuser.S
+++ b/arch/x86_64/lib/putuser.S
@@ -49,8 +49,8 @@ __put_user_2:
49 jc 20f 49 jc 20f
50 cmpq threadinfo_addr_limit(%r8),%rcx 50 cmpq threadinfo_addr_limit(%r8),%rcx
51 jae 20f 51 jae 20f
522: decq %rcx 52 decq %rcx
53 movw %dx,(%rcx) 532: movw %dx,(%rcx)
54 xorl %eax,%eax 54 xorl %eax,%eax
55 ret 55 ret
5620: decq %rcx 5620: decq %rcx
@@ -64,8 +64,8 @@ __put_user_4:
64 jc 30f 64 jc 30f
65 cmpq threadinfo_addr_limit(%r8),%rcx 65 cmpq threadinfo_addr_limit(%r8),%rcx
66 jae 30f 66 jae 30f
673: subq $3,%rcx 67 subq $3,%rcx
68 movl %edx,(%rcx) 683: movl %edx,(%rcx)
69 xorl %eax,%eax 69 xorl %eax,%eax
70 ret 70 ret
7130: subq $3,%rcx 7130: subq $3,%rcx
@@ -79,8 +79,8 @@ __put_user_8:
79 jc 40f 79 jc 40f
80 cmpq threadinfo_addr_limit(%r8),%rcx 80 cmpq threadinfo_addr_limit(%r8),%rcx
81 jae 40f 81 jae 40f
824: subq $7,%rcx 82 subq $7,%rcx
83 movq %rdx,(%rcx) 834: movq %rdx,(%rcx)
84 xorl %eax,%eax 84 xorl %eax,%eax
85 ret 85 ret
8640: subq $7,%rcx 8640: subq $7,%rcx
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 536754faf4d2..90d6089d60ed 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -146,7 +146,7 @@ config CRYPTO_SERPENT
146 146
147config CRYPTO_AES 147config CRYPTO_AES
148 tristate "AES cipher algorithms" 148 tristate "AES cipher algorithms"
149 depends on CRYPTO && !(X86 && !X86_64) 149 depends on CRYPTO && !((X86 || UML_X86) && !64BIT)
150 help 150 help
151 AES cipher algorithms (FIPS-197). AES uses the Rijndael 151 AES cipher algorithms (FIPS-197). AES uses the Rijndael
152 algorithm. 152 algorithm.
@@ -166,7 +166,7 @@ config CRYPTO_AES
166 166
167config CRYPTO_AES_586 167config CRYPTO_AES_586
168 tristate "AES cipher algorithms (i586)" 168 tristate "AES cipher algorithms (i586)"
169 depends on CRYPTO && (X86 && !X86_64) 169 depends on CRYPTO && ((X86 || UML_X86) && !64BIT)
170 help 170 help
171 AES cipher algorithms (FIPS-197). AES uses the Rijndael 171 AES cipher algorithms (FIPS-197). AES uses the Rijndael
172 algorithm. 172 algorithm.
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 05a17812d521..ff64d333e95f 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -838,7 +838,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
838 838
839 /* Fall back to the default idle loop */ 839 /* Fall back to the default idle loop */
840 pm_idle = pm_idle_save; 840 pm_idle = pm_idle_save;
841 synchronize_kernel(); 841 synchronize_sched(); /* Relies on interrupts forcing exit from idle. */
842 842
843 pr->flags.power = 0; 843 pr->flags.power = 0;
844 result = acpi_processor_get_power_info(pr); 844 result = acpi_processor_get_power_info(pr);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e7ca06626566..119c94093a13 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -379,8 +379,8 @@ ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
379 379
380/** 380/**
381 * setup_sys_fs_device_files - sets up the device files under device namespace 381 * setup_sys_fs_device_files - sets up the device files under device namespace
382 * @@dev: acpi_device object 382 * @dev: acpi_device object
383 * @@func: function pointer to create or destroy the device file 383 * @func: function pointer to create or destroy the device file
384 */ 384 */
385static void 385static void
386setup_sys_fs_device_files ( 386setup_sys_fs_device_files (
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 78e34ee79df8..10da36934769 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -59,7 +59,6 @@
59 * - doesn't support OAM cells 59 * - doesn't support OAM cells
60 * - eni_put_free may hang if not putting memory fragments that _complete_ 60 * - eni_put_free may hang if not putting memory fragments that _complete_
61 * 2^n block (never happens in real life, though) 61 * 2^n block (never happens in real life, though)
62 * - keeps IRQ even if initialization fails
63 */ 62 */
64 63
65 64
@@ -1802,22 +1801,22 @@ static int __devinit eni_start(struct atm_dev *dev)
1802 if (request_irq(eni_dev->irq,&eni_int,SA_SHIRQ,DEV_LABEL,dev)) { 1801 if (request_irq(eni_dev->irq,&eni_int,SA_SHIRQ,DEV_LABEL,dev)) {
1803 printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n", 1802 printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n",
1804 dev->number,eni_dev->irq); 1803 dev->number,eni_dev->irq);
1805 return -EAGAIN; 1804 error = -EAGAIN;
1805 goto out;
1806 } 1806 }
1807 /* @@@ should release IRQ on error */
1808 pci_set_master(eni_dev->pci_dev); 1807 pci_set_master(eni_dev->pci_dev);
1809 if ((error = pci_write_config_word(eni_dev->pci_dev,PCI_COMMAND, 1808 if ((error = pci_write_config_word(eni_dev->pci_dev,PCI_COMMAND,
1810 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | 1809 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
1811 (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) { 1810 (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) {
1812 printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory+" 1811 printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory+"
1813 "master (0x%02x)\n",dev->number,error); 1812 "master (0x%02x)\n",dev->number,error);
1814 return error; 1813 goto free_irq;
1815 } 1814 }
1816 if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL, 1815 if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,
1817 END_SWAP_DMA))) { 1816 END_SWAP_DMA))) {
1818 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap " 1817 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap "
1819 "(0x%02x)\n",dev->number,error); 1818 "(0x%02x)\n",dev->number,error);
1820 return error; 1819 goto free_irq;
1821 } 1820 }
1822 /* determine addresses of internal tables */ 1821 /* determine addresses of internal tables */
1823 eni_dev->vci = eni_dev->ram; 1822 eni_dev->vci = eni_dev->ram;
@@ -1839,7 +1838,8 @@ static int __devinit eni_start(struct atm_dev *dev)
1839 if (!eni_dev->free_list) { 1838 if (!eni_dev->free_list) {
1840 printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", 1839 printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n",
1841 dev->number); 1840 dev->number);
1842 return -ENOMEM; 1841 error = -ENOMEM;
1842 goto free_irq;
1843 } 1843 }
1844 eni_dev->free_len = 0; 1844 eni_dev->free_len = 0;
1845 eni_put_free(eni_dev,buf,buffer_mem); 1845 eni_put_free(eni_dev,buf,buffer_mem);
@@ -1855,17 +1855,26 @@ static int __devinit eni_start(struct atm_dev *dev)
1855 */ 1855 */
1856 eni_out(0xffffffff,MID_IE); 1856 eni_out(0xffffffff,MID_IE);
1857 error = start_tx(dev); 1857 error = start_tx(dev);
1858 if (error) return error; 1858 if (error) goto free_list;
1859 error = start_rx(dev); 1859 error = start_rx(dev);
1860 if (error) return error; 1860 if (error) goto free_list;
1861 error = dev->phy->start(dev); 1861 error = dev->phy->start(dev);
1862 if (error) return error; 1862 if (error) goto free_list;
1863 eni_out(eni_in(MID_MC_S) | (1 << MID_INT_SEL_SHIFT) | 1863 eni_out(eni_in(MID_MC_S) | (1 << MID_INT_SEL_SHIFT) |
1864 MID_TX_LOCK_MODE | MID_DMA_ENABLE | MID_TX_ENABLE | MID_RX_ENABLE, 1864 MID_TX_LOCK_MODE | MID_DMA_ENABLE | MID_TX_ENABLE | MID_RX_ENABLE,
1865 MID_MC_S); 1865 MID_MC_S);
1866 /* Tonga uses SBus INTReq1 */ 1866 /* Tonga uses SBus INTReq1 */
1867 (void) eni_in(MID_ISA); /* clear Midway interrupts */ 1867 (void) eni_in(MID_ISA); /* clear Midway interrupts */
1868 return 0; 1868 return 0;
1869
1870free_list:
1871 kfree(eni_dev->free_list);
1872
1873free_irq:
1874 free_irq(eni_dev->irq, eni_dev);
1875
1876out:
1877 return error;
1869} 1878}
1870 1879
1871 1880
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 196b33644627..9e65bfb85ba3 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -2792,8 +2792,6 @@ static void __devexit fore200e_pca_remove_one(struct pci_dev *pci_dev)
2792 2792
2793 fore200e = pci_get_drvdata(pci_dev); 2793 fore200e = pci_get_drvdata(pci_dev);
2794 2794
2795 list_del(&fore200e->entry);
2796
2797 fore200e_shutdown(fore200e); 2795 fore200e_shutdown(fore200e);
2798 kfree(fore200e); 2796 kfree(fore200e);
2799 pci_disable_device(pci_dev); 2797 pci_disable_device(pci_dev);
@@ -2850,7 +2848,7 @@ fore200e_module_init(void)
2850 } 2848 }
2851 2849
2852#ifdef CONFIG_ATM_FORE200E_PCA 2850#ifdef CONFIG_ATM_FORE200E_PCA
2853 if (!pci_module_init(&fore200e_pca_driver)) 2851 if (!pci_register_driver(&fore200e_pca_driver))
2854 return 0; 2852 return 0;
2855#endif 2853#endif
2856 2854
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index c2c31a5f4513..3022c548a132 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -70,6 +70,7 @@
70#include <linux/sched.h> 70#include <linux/sched.h>
71#include <linux/timer.h> 71#include <linux/timer.h>
72#include <linux/interrupt.h> 72#include <linux/interrupt.h>
73#include <linux/dma-mapping.h>
73#include <asm/io.h> 74#include <asm/io.h>
74#include <asm/byteorder.h> 75#include <asm/byteorder.h>
75#include <asm/uaccess.h> 76#include <asm/uaccess.h>
@@ -371,7 +372,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
371 372
372 if (pci_enable_device(pci_dev)) 373 if (pci_enable_device(pci_dev))
373 return -EIO; 374 return -EIO;
374 if (pci_set_dma_mask(pci_dev, HE_DMA_MASK) != 0) { 375 if (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK) != 0) {
375 printk(KERN_WARNING "he: no suitable dma available\n"); 376 printk(KERN_WARNING "he: no suitable dma available\n");
376 err = -EIO; 377 err = -EIO;
377 goto init_one_failure; 378 goto init_one_failure;
diff --git a/drivers/atm/he.h b/drivers/atm/he.h
index 1a903859343a..1dc277547a73 100644
--- a/drivers/atm/he.h
+++ b/drivers/atm/he.h
@@ -380,8 +380,6 @@ struct he_vcc
380#define PCI_VENDOR_ID_FORE 0x1127 380#define PCI_VENDOR_ID_FORE 0x1127
381#define PCI_DEVICE_ID_FORE_HE 0x400 381#define PCI_DEVICE_ID_FORE_HE 0x400
382 382
383#define HE_DMA_MASK 0xffffffff
384
385#define GEN_CNTL_0 0x40 383#define GEN_CNTL_0 0x40
386#define INT_PROC_ENBL (1<<25) 384#define INT_PROC_ENBL (1<<25)
387#define SLAVE_ENDIAN_MODE (1<<16) 385#define SLAVE_ENDIAN_MODE (1<<16)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index f4fa27315fb4..2b3902c867da 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -405,9 +405,8 @@ void device_release_driver(struct device * dev)
405 405
406static void driver_detach(struct device_driver * drv) 406static void driver_detach(struct device_driver * drv)
407{ 407{
408 struct list_head * entry, * next; 408 while (!list_empty(&drv->devices)) {
409 list_for_each_safe(entry, next, &drv->devices) { 409 struct device * dev = container_of(drv->devices.next, struct device, driver_list);
410 struct device * dev = container_of(entry, struct device, driver_list);
411 device_release_driver(dev); 410 device_release_driver(dev);
412 } 411 }
413} 412}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a7cedd8cefe5..268a9c8d168b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -139,7 +139,7 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
139 buffer = &buffer[length]; 139 buffer = &buffer[length];
140 buffer_size -= length; 140 buffer_size -= length;
141 141
142 if (dev->bus->hotplug) { 142 if (dev->bus && dev->bus->hotplug) {
143 /* have the bus specific function add its stuff */ 143 /* have the bus specific function add its stuff */
144 retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size); 144 retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size);
145 if (retval) { 145 if (retval) {
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index cd6453905a9b..3a5f4c991797 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -115,7 +115,7 @@ int platform_add_devices(struct platform_device **devs, int num)
115 115
116/** 116/**
117 * platform_device_register - add a platform-level device 117 * platform_device_register - add a platform-level device
118 * @dev: platform device we're adding 118 * @pdev: platform device we're adding
119 * 119 *
120 */ 120 */
121int platform_device_register(struct platform_device * pdev) 121int platform_device_register(struct platform_device * pdev)
@@ -174,7 +174,7 @@ int platform_device_register(struct platform_device * pdev)
174 174
175/** 175/**
176 * platform_device_unregister - remove a platform-level device 176 * platform_device_unregister - remove a platform-level device
177 * @dev: platform device we're removing 177 * @pdev: platform device we're removing
178 * 178 *
179 * Note that this function will also release all memory- and port-based 179 * Note that this function will also release all memory- and port-based
180 * resources owned by the device (@dev->resource). 180 * resources owned by the device (@dev->resource).
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 423bbf2000d2..3760edfdc65c 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -3,6 +3,7 @@
3 Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers 3 Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
4 4
5 Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com> 5 Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com>
6 Portions Copyright 2002 by Mylex (An IBM Business Unit)
6 7
7 This program is free software; you may redistribute and/or modify it under 8 This program is free software; you may redistribute and/or modify it under
8 the terms of the GNU General Public License Version 2 as published by the 9 the terms of the GNU General Public License Version 2 as published by the
@@ -532,6 +533,34 @@ static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
532 spin_lock_irq(&Controller->queue_lock); 533 spin_lock_irq(&Controller->queue_lock);
533} 534}
534 535
536/*
537 DAC960_GEM_QueueCommand queues Command for DAC960 GEM Series Controllers.
538*/
539
540static void DAC960_GEM_QueueCommand(DAC960_Command_T *Command)
541{
542 DAC960_Controller_T *Controller = Command->Controller;
543 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
544 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
545 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
546 Controller->V2.NextCommandMailbox;
547
548 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
549 DAC960_GEM_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
550
551 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
552 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
553 DAC960_GEM_MemoryMailboxNewCommand(ControllerBaseAddress);
554
555 Controller->V2.PreviousCommandMailbox2 =
556 Controller->V2.PreviousCommandMailbox1;
557 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
558
559 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
560 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
561
562 Controller->V2.NextCommandMailbox = NextCommandMailbox;
563}
535 564
536/* 565/*
537 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers. 566 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers.
@@ -1464,6 +1493,17 @@ static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1464 Controller->V2.FirstStatusMailboxDMA; 1493 Controller->V2.FirstStatusMailboxDMA;
1465 switch (Controller->HardwareType) 1494 switch (Controller->HardwareType)
1466 { 1495 {
1496 case DAC960_GEM_Controller:
1497 while (DAC960_GEM_HardwareMailboxFullP(ControllerBaseAddress))
1498 udelay(1);
1499 DAC960_GEM_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1500 DAC960_GEM_HardwareMailboxNewCommand(ControllerBaseAddress);
1501 while (!DAC960_GEM_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1502 udelay(1);
1503 CommandStatus = DAC960_GEM_ReadCommandStatus(ControllerBaseAddress);
1504 DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1505 DAC960_GEM_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1506 break;
1467 case DAC960_BA_Controller: 1507 case DAC960_BA_Controller:
1468 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress)) 1508 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
1469 udelay(1); 1509 udelay(1);
@@ -2627,6 +2667,9 @@ static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
2627 if (Controller->MemoryMappedAddress) { 2667 if (Controller->MemoryMappedAddress) {
2628 switch(Controller->HardwareType) 2668 switch(Controller->HardwareType)
2629 { 2669 {
2670 case DAC960_GEM_Controller:
2671 DAC960_GEM_DisableInterrupts(Controller->BaseAddress);
2672 break;
2630 case DAC960_BA_Controller: 2673 case DAC960_BA_Controller:
2631 DAC960_BA_DisableInterrupts(Controller->BaseAddress); 2674 DAC960_BA_DisableInterrupts(Controller->BaseAddress);
2632 break; 2675 break;
@@ -2705,6 +2748,9 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2705 2748
2706 switch (Controller->HardwareType) 2749 switch (Controller->HardwareType)
2707 { 2750 {
2751 case DAC960_GEM_Controller:
2752 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2753 break;
2708 case DAC960_BA_Controller: 2754 case DAC960_BA_Controller:
2709 Controller->PCI_Address = pci_resource_start(PCI_Device, 0); 2755 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2710 break; 2756 break;
@@ -2756,6 +2802,36 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2756 BaseAddress = Controller->BaseAddress; 2802 BaseAddress = Controller->BaseAddress;
2757 switch (Controller->HardwareType) 2803 switch (Controller->HardwareType)
2758 { 2804 {
2805 case DAC960_GEM_Controller:
2806 DAC960_GEM_DisableInterrupts(BaseAddress);
2807 DAC960_GEM_AcknowledgeHardwareMailboxStatus(BaseAddress);
2808 udelay(1000);
2809 while (DAC960_GEM_InitializationInProgressP(BaseAddress))
2810 {
2811 if (DAC960_GEM_ReadErrorStatus(BaseAddress, &ErrorStatus,
2812 &Parameter0, &Parameter1) &&
2813 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2814 Parameter0, Parameter1))
2815 goto Failure;
2816 udelay(10);
2817 }
2818 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2819 {
2820 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2821 "for Controller at\n", Controller);
2822 goto Failure;
2823 }
2824 DAC960_GEM_EnableInterrupts(BaseAddress);
2825 Controller->QueueCommand = DAC960_GEM_QueueCommand;
2826 Controller->ReadControllerConfiguration =
2827 DAC960_V2_ReadControllerConfiguration;
2828 Controller->ReadDeviceConfiguration =
2829 DAC960_V2_ReadDeviceConfiguration;
2830 Controller->ReportDeviceConfiguration =
2831 DAC960_V2_ReportDeviceConfiguration;
2832 Controller->QueueReadWriteCommand =
2833 DAC960_V2_QueueReadWriteCommand;
2834 break;
2759 case DAC960_BA_Controller: 2835 case DAC960_BA_Controller:
2760 DAC960_BA_DisableInterrupts(BaseAddress); 2836 DAC960_BA_DisableInterrupts(BaseAddress);
2761 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress); 2837 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
@@ -5189,6 +5265,47 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
5189 wake_up(&Controller->CommandWaitQueue); 5265 wake_up(&Controller->CommandWaitQueue);
5190} 5266}
5191 5267
5268/*
5269 DAC960_GEM_InterruptHandler handles hardware interrupts from DAC960 GEM Series
5270 Controllers.
5271*/
5272
5273static irqreturn_t DAC960_GEM_InterruptHandler(int IRQ_Channel,
5274 void *DeviceIdentifier,
5275 struct pt_regs *InterruptRegisters)
5276{
5277 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5278 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5279 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5280 unsigned long flags;
5281
5282 spin_lock_irqsave(&Controller->queue_lock, flags);
5283 DAC960_GEM_AcknowledgeInterrupt(ControllerBaseAddress);
5284 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5285 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5286 {
5287 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5288 NextStatusMailbox->Fields.CommandIdentifier;
5289 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5290 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5291 Command->V2.RequestSenseLength =
5292 NextStatusMailbox->Fields.RequestSenseLength;
5293 Command->V2.DataTransferResidue =
5294 NextStatusMailbox->Fields.DataTransferResidue;
5295 NextStatusMailbox->Words[0] = 0;
5296 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5297 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5298 DAC960_V2_ProcessCompletedCommand(Command);
5299 }
5300 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5301 /*
5302 Attempt to remove additional I/O Requests from the Controller's
5303 I/O Request Queue and queue them to the Controller.
5304 */
5305 DAC960_ProcessRequest(Controller);
5306 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5307 return IRQ_HANDLED;
5308}
5192 5309
5193/* 5310/*
5194 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series 5311 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series
@@ -6962,6 +7079,14 @@ static void DAC960_gam_cleanup(void)
6962 7079
6963#endif /* DAC960_GAM_MINOR */ 7080#endif /* DAC960_GAM_MINOR */
6964 7081
7082static struct DAC960_privdata DAC960_GEM_privdata = {
7083 .HardwareType = DAC960_GEM_Controller,
7084 .FirmwareType = DAC960_V2_Controller,
7085 .InterruptHandler = DAC960_GEM_InterruptHandler,
7086 .MemoryWindowSize = DAC960_GEM_RegisterWindowSize,
7087};
7088
7089
6965static struct DAC960_privdata DAC960_BA_privdata = { 7090static struct DAC960_privdata DAC960_BA_privdata = {
6966 .HardwareType = DAC960_BA_Controller, 7091 .HardwareType = DAC960_BA_Controller,
6967 .FirmwareType = DAC960_V2_Controller, 7092 .FirmwareType = DAC960_V2_Controller,
@@ -7007,6 +7132,13 @@ static struct DAC960_privdata DAC960_P_privdata = {
7007static struct pci_device_id DAC960_id_table[] = { 7132static struct pci_device_id DAC960_id_table[] = {
7008 { 7133 {
7009 .vendor = PCI_VENDOR_ID_MYLEX, 7134 .vendor = PCI_VENDOR_ID_MYLEX,
7135 .device = PCI_DEVICE_ID_MYLEX_DAC960_GEM,
7136 .subvendor = PCI_ANY_ID,
7137 .subdevice = PCI_ANY_ID,
7138 .driver_data = (unsigned long) &DAC960_GEM_privdata,
7139 },
7140 {
7141 .vendor = PCI_VENDOR_ID_MYLEX,
7010 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA, 7142 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA,
7011 .subvendor = PCI_ANY_ID, 7143 .subvendor = PCI_ANY_ID,
7012 .subdevice = PCI_ANY_ID, 7144 .subdevice = PCI_ANY_ID,
diff --git a/drivers/block/DAC960.h b/drivers/block/DAC960.h
index d5e8e7190c90..a82f37f749a5 100644
--- a/drivers/block/DAC960.h
+++ b/drivers/block/DAC960.h
@@ -2114,7 +2114,8 @@ typedef enum
2114 DAC960_LA_Controller = 3, /* DAC1164P */ 2114 DAC960_LA_Controller = 3, /* DAC1164P */
2115 DAC960_PG_Controller = 4, /* DAC960PTL/PJ/PG */ 2115 DAC960_PG_Controller = 4, /* DAC960PTL/PJ/PG */
2116 DAC960_PD_Controller = 5, /* DAC960PU/PD/PL/P */ 2116 DAC960_PD_Controller = 5, /* DAC960PU/PD/PL/P */
2117 DAC960_P_Controller = 6 /* DAC960PU/PD/PL/P */ 2117 DAC960_P_Controller = 6, /* DAC960PU/PD/PL/P */
2118 DAC960_GEM_Controller = 7, /* AcceleRAID 4/5/600 */
2118} 2119}
2119DAC960_HardwareType_T; 2120DAC960_HardwareType_T;
2120 2121
@@ -2541,6 +2542,320 @@ void dma_addr_writeql(dma_addr_t addr, void __iomem *write_address)
2541} 2542}
2542 2543
2543/* 2544/*
2545 Define the DAC960 GEM Series Controller Interface Register Offsets.
2546 */
2547
2548#define DAC960_GEM_RegisterWindowSize 0x600
2549
2550typedef enum
2551{
2552 DAC960_GEM_InboundDoorBellRegisterReadSetOffset = 0x214,
2553 DAC960_GEM_InboundDoorBellRegisterClearOffset = 0x218,
2554 DAC960_GEM_OutboundDoorBellRegisterReadSetOffset = 0x224,
2555 DAC960_GEM_OutboundDoorBellRegisterClearOffset = 0x228,
2556 DAC960_GEM_InterruptStatusRegisterOffset = 0x208,
2557 DAC960_GEM_InterruptMaskRegisterReadSetOffset = 0x22C,
2558 DAC960_GEM_InterruptMaskRegisterClearOffset = 0x230,
2559 DAC960_GEM_CommandMailboxBusAddressOffset = 0x510,
2560 DAC960_GEM_CommandStatusOffset = 0x518,
2561 DAC960_GEM_ErrorStatusRegisterReadSetOffset = 0x224,
2562 DAC960_GEM_ErrorStatusRegisterClearOffset = 0x228,
2563}
2564DAC960_GEM_RegisterOffsets_T;
2565
2566/*
2567 Define the structure of the DAC960 GEM Series Inbound Door Bell
2568 */
2569
2570typedef union DAC960_GEM_InboundDoorBellRegister
2571{
2572 unsigned int All;
2573 struct {
2574 unsigned int :24;
2575 boolean HardwareMailboxNewCommand:1;
2576 boolean AcknowledgeHardwareMailboxStatus:1;
2577 boolean GenerateInterrupt:1;
2578 boolean ControllerReset:1;
2579 boolean MemoryMailboxNewCommand:1;
2580 unsigned int :3;
2581 } Write;
2582 struct {
2583 unsigned int :24;
2584 boolean HardwareMailboxFull:1;
2585 boolean InitializationInProgress:1;
2586 unsigned int :6;
2587 } Read;
2588}
2589DAC960_GEM_InboundDoorBellRegister_T;
2590
2591/*
2592 Define the structure of the DAC960 GEM Series Outbound Door Bell Register.
2593 */
2594typedef union DAC960_GEM_OutboundDoorBellRegister
2595{
2596 unsigned int All;
2597 struct {
2598 unsigned int :24;
2599 boolean AcknowledgeHardwareMailboxInterrupt:1;
2600 boolean AcknowledgeMemoryMailboxInterrupt:1;
2601 unsigned int :6;
2602 } Write;
2603 struct {
2604 unsigned int :24;
2605 boolean HardwareMailboxStatusAvailable:1;
2606 boolean MemoryMailboxStatusAvailable:1;
2607 unsigned int :6;
2608 } Read;
2609}
2610DAC960_GEM_OutboundDoorBellRegister_T;
2611
2612/*
2613 Define the structure of the DAC960 GEM Series Interrupt Mask Register.
2614 */
2615typedef union DAC960_GEM_InterruptMaskRegister
2616{
2617 unsigned int All;
2618 struct {
2619 unsigned int :16;
2620 unsigned int :8;
2621 unsigned int HardwareMailboxInterrupt:1;
2622 unsigned int MemoryMailboxInterrupt:1;
2623 unsigned int :6;
2624 } Bits;
2625}
2626DAC960_GEM_InterruptMaskRegister_T;
2627
2628/*
2629 Define the structure of the DAC960 GEM Series Error Status Register.
2630 */
2631
2632typedef union DAC960_GEM_ErrorStatusRegister
2633{
2634 unsigned int All;
2635 struct {
2636 unsigned int :24;
2637 unsigned int :5;
2638 boolean ErrorStatusPending:1;
2639 unsigned int :2;
2640 } Bits;
2641}
2642DAC960_GEM_ErrorStatusRegister_T;
2643
2644/*
2645 Define inline functions to provide an abstraction for reading and writing the
2646 DAC960 GEM Series Controller Interface Registers.
2647*/
2648
2649static inline
2650void DAC960_GEM_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
2651{
2652 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2653 InboundDoorBellRegister.All = 0;
2654 InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
2655 writel(InboundDoorBellRegister.All,
2656 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2657}
2658
2659static inline
2660void DAC960_GEM_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
2661{
2662 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2663 InboundDoorBellRegister.All = 0;
2664 InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
2665 writel(InboundDoorBellRegister.All,
2666 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterClearOffset);
2667}
2668
2669static inline
2670void DAC960_GEM_GenerateInterrupt(void __iomem *ControllerBaseAddress)
2671{
2672 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2673 InboundDoorBellRegister.All = 0;
2674 InboundDoorBellRegister.Write.GenerateInterrupt = true;
2675 writel(InboundDoorBellRegister.All,
2676 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2677}
2678
2679static inline
2680void DAC960_GEM_ControllerReset(void __iomem *ControllerBaseAddress)
2681{
2682 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2683 InboundDoorBellRegister.All = 0;
2684 InboundDoorBellRegister.Write.ControllerReset = true;
2685 writel(InboundDoorBellRegister.All,
2686 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2687}
2688
2689static inline
2690void DAC960_GEM_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
2691{
2692 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2693 InboundDoorBellRegister.All = 0;
2694 InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
2695 writel(InboundDoorBellRegister.All,
2696 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2697}
2698
2699static inline
2700boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
2701{
2702 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2703 InboundDoorBellRegister.All =
2704 readl(ControllerBaseAddress +
2705 DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2706 return InboundDoorBellRegister.Read.HardwareMailboxFull;
2707}
2708
2709static inline
2710boolean DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress)
2711{
2712 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2713 InboundDoorBellRegister.All =
2714 readl(ControllerBaseAddress +
2715 DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2716 return InboundDoorBellRegister.Read.InitializationInProgress;
2717}
2718
2719static inline
2720void DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
2721{
2722 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2723 OutboundDoorBellRegister.All = 0;
2724 OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
2725 writel(OutboundDoorBellRegister.All,
2726 ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
2727}
2728
2729static inline
2730void DAC960_GEM_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
2731{
2732 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2733 OutboundDoorBellRegister.All = 0;
2734 OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
2735 writel(OutboundDoorBellRegister.All,
2736 ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
2737}
2738
2739static inline
2740void DAC960_GEM_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
2741{
2742 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2743 OutboundDoorBellRegister.All = 0;
2744 OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
2745 OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
2746 writel(OutboundDoorBellRegister.All,
2747 ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
2748}
2749
2750static inline
2751boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
2752{
2753 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2754 OutboundDoorBellRegister.All =
2755 readl(ControllerBaseAddress +
2756 DAC960_GEM_OutboundDoorBellRegisterReadSetOffset);
2757 return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
2758}
2759
2760static inline
2761boolean DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
2762{
2763 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2764 OutboundDoorBellRegister.All =
2765 readl(ControllerBaseAddress +
2766 DAC960_GEM_OutboundDoorBellRegisterReadSetOffset);
2767 return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
2768}
2769
2770static inline
2771void DAC960_GEM_EnableInterrupts(void __iomem *ControllerBaseAddress)
2772{
2773 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2774 InterruptMaskRegister.All = 0;
2775 InterruptMaskRegister.Bits.HardwareMailboxInterrupt = true;
2776 InterruptMaskRegister.Bits.MemoryMailboxInterrupt = true;
2777 writel(InterruptMaskRegister.All,
2778 ControllerBaseAddress + DAC960_GEM_InterruptMaskRegisterClearOffset);
2779}
2780
2781static inline
2782void DAC960_GEM_DisableInterrupts(void __iomem *ControllerBaseAddress)
2783{
2784 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2785 InterruptMaskRegister.All = 0;
2786 InterruptMaskRegister.Bits.HardwareMailboxInterrupt = true;
2787 InterruptMaskRegister.Bits.MemoryMailboxInterrupt = true;
2788 writel(InterruptMaskRegister.All,
2789 ControllerBaseAddress + DAC960_GEM_InterruptMaskRegisterReadSetOffset);
2790}
2791
2792static inline
2793boolean DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
2794{
2795 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2796 InterruptMaskRegister.All =
2797 readl(ControllerBaseAddress +
2798 DAC960_GEM_InterruptMaskRegisterReadSetOffset);
2799 return !(InterruptMaskRegister.Bits.HardwareMailboxInterrupt ||
2800 InterruptMaskRegister.Bits.MemoryMailboxInterrupt);
2801}
2802
2803static inline
2804void DAC960_GEM_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
2805 *MemoryCommandMailbox,
2806 DAC960_V2_CommandMailbox_T
2807 *CommandMailbox)
2808{
2809 memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
2810 sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
2811 wmb();
2812 MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
2813 mb();
2814}
2815
2816static inline
2817void DAC960_GEM_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
2818 dma_addr_t CommandMailboxDMA)
2819{
2820 dma_addr_writeql(CommandMailboxDMA,
2821 ControllerBaseAddress +
2822 DAC960_GEM_CommandMailboxBusAddressOffset);
2823}
2824
2825static inline DAC960_V2_CommandIdentifier_T
2826DAC960_GEM_ReadCommandIdentifier(void __iomem *ControllerBaseAddress)
2827{
2828 return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset);
2829}
2830
2831static inline DAC960_V2_CommandStatus_T
2832DAC960_GEM_ReadCommandStatus(void __iomem *ControllerBaseAddress)
2833{
2834 return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset + 2);
2835}
2836
2837static inline boolean
2838DAC960_GEM_ReadErrorStatus(void __iomem *ControllerBaseAddress,
2839 unsigned char *ErrorStatus,
2840 unsigned char *Parameter0,
2841 unsigned char *Parameter1)
2842{
2843 DAC960_GEM_ErrorStatusRegister_T ErrorStatusRegister;
2844 ErrorStatusRegister.All =
2845 readl(ControllerBaseAddress + DAC960_GEM_ErrorStatusRegisterReadSetOffset);
2846 if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
2847 ErrorStatusRegister.Bits.ErrorStatusPending = false;
2848 *ErrorStatus = ErrorStatusRegister.All;
2849 *Parameter0 =
2850 readb(ControllerBaseAddress + DAC960_GEM_CommandMailboxBusAddressOffset + 0);
2851 *Parameter1 =
2852 readb(ControllerBaseAddress + DAC960_GEM_CommandMailboxBusAddressOffset + 1);
2853 writel(0x03000000, ControllerBaseAddress +
2854 DAC960_GEM_ErrorStatusRegisterClearOffset);
2855 return true;
2856}
2857
2858/*
2544 Define the DAC960 BA Series Controller Interface Register Offsets. 2859 Define the DAC960 BA Series Controller Interface Register Offsets.
2545*/ 2860*/
2546 2861
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e830be1a3ae6..b594768b0241 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -6,7 +6,7 @@ menu "Block devices"
6 6
7config BLK_DEV_FD 7config BLK_DEV_FD
8 tristate "Normal floppy disk support" 8 tristate "Normal floppy disk support"
9 depends on (!ARCH_S390 && !M68K && !IA64 && !UML) || Q40 || (SUN3X && BROKEN) || ARCH_RPC || ARCH_EBSA285 9 depends on (!ARCH_S390 && !M68K && !IA64 && !UML && !ARM) || Q40 || (SUN3X && BROKEN) || ARCH_RPC || ARCH_EBSA285
10 ---help--- 10 ---help---
11 If you want to use the floppy disk drive(s) of your PC under Linux, 11 If you want to use the floppy disk drive(s) of your PC under Linux,
12 say Y. Information about this driver, especially important for IBM 12 say Y. Information about this driver, especially important for IBM
@@ -105,7 +105,7 @@ config ATARI_SLM
105 105
106config BLK_DEV_XD 106config BLK_DEV_XD
107 tristate "XT hard disk support" 107 tristate "XT hard disk support"
108 depends on ISA 108 depends on ISA && ISA_DMA_API
109 help 109 help
110 Very old 8 bit hard disk controllers used in the IBM XT computer 110 Very old 8 bit hard disk controllers used in the IBM XT computer
111 will be supported if you say Y here. 111 will be supported if you say Y here.
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index aa8b547ffafa..721ba8086043 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "6" 2#define VERSION "10"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 4780f7926d42..0e97fcb9f3a1 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -37,6 +37,13 @@ static ssize_t aoedisk_show_netif(struct gendisk * disk, char *page)
37 37
38 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name); 38 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name);
39} 39}
40/* firmware version */
41static ssize_t aoedisk_show_fwver(struct gendisk * disk, char *page)
42{
43 struct aoedev *d = disk->private_data;
44
45 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver);
46}
40 47
41static struct disk_attribute disk_attr_state = { 48static struct disk_attribute disk_attr_state = {
42 .attr = {.name = "state", .mode = S_IRUGO }, 49 .attr = {.name = "state", .mode = S_IRUGO },
@@ -50,6 +57,10 @@ static struct disk_attribute disk_attr_netif = {
50 .attr = {.name = "netif", .mode = S_IRUGO }, 57 .attr = {.name = "netif", .mode = S_IRUGO },
51 .show = aoedisk_show_netif 58 .show = aoedisk_show_netif
52}; 59};
60static struct disk_attribute disk_attr_fwver = {
61 .attr = {.name = "firmware-version", .mode = S_IRUGO },
62 .show = aoedisk_show_fwver
63};
53 64
54static void 65static void
55aoedisk_add_sysfs(struct aoedev *d) 66aoedisk_add_sysfs(struct aoedev *d)
@@ -57,6 +68,7 @@ aoedisk_add_sysfs(struct aoedev *d)
57 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); 68 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
58 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr); 69 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
59 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr); 70 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
71 sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
60} 72}
61void 73void
62aoedisk_rm_sysfs(struct aoedev *d) 74aoedisk_rm_sysfs(struct aoedev *d)
@@ -64,6 +76,7 @@ aoedisk_rm_sysfs(struct aoedev *d)
64 sysfs_remove_link(&d->gd->kobj, "state"); 76 sysfs_remove_link(&d->gd->kobj, "state");
65 sysfs_remove_link(&d->gd->kobj, "mac"); 77 sysfs_remove_link(&d->gd->kobj, "mac");
66 sysfs_remove_link(&d->gd->kobj, "netif"); 78 sysfs_remove_link(&d->gd->kobj, "netif");
79 sysfs_remove_link(&d->gd->kobj, "firmware-version");
67} 80}
68 81
69static int 82static int
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index ec16c64dd114..6e231c5a1199 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -109,25 +109,22 @@ aoedev_set(ulong sysminor, unsigned char *addr, struct net_device *ifp, ulong bu
109 spin_lock_irqsave(&devlist_lock, flags); 109 spin_lock_irqsave(&devlist_lock, flags);
110 110
111 for (d=devlist; d; d=d->next) 111 for (d=devlist; d; d=d->next)
112 if (d->sysminor == sysminor 112 if (d->sysminor == sysminor)
113 || memcmp(d->addr, addr, sizeof d->addr) == 0)
114 break; 113 break;
115 114
116 if (d == NULL && (d = aoedev_newdev(bufcnt)) == NULL) { 115 if (d == NULL && (d = aoedev_newdev(bufcnt)) == NULL) {
117 spin_unlock_irqrestore(&devlist_lock, flags); 116 spin_unlock_irqrestore(&devlist_lock, flags);
118 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); 117 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n");
119 return NULL; 118 return NULL;
120 } 119 } /* if newdev, (d->flags & DEVFL_UP) == 0 for below */
121 120
122 spin_unlock_irqrestore(&devlist_lock, flags); 121 spin_unlock_irqrestore(&devlist_lock, flags);
123 spin_lock_irqsave(&d->lock, flags); 122 spin_lock_irqsave(&d->lock, flags);
124 123
125 d->ifp = ifp; 124 d->ifp = ifp;
126 125 memcpy(d->addr, addr, sizeof d->addr);
127 if (d->sysminor != sysminor 126 if ((d->flags & DEVFL_UP) == 0) {
128 || (d->flags & DEVFL_UP) == 0) {
129 aoedev_downdev(d); /* flushes outstanding frames */ 127 aoedev_downdev(d); /* flushes outstanding frames */
130 memcpy(d->addr, addr, sizeof d->addr);
131 d->sysminor = sysminor; 128 d->sysminor = sysminor;
132 d->aoemajor = AOEMAJOR(sysminor); 129 d->aoemajor = AOEMAJOR(sysminor);
133 d->aoeminor = AOEMINOR(sysminor); 130 d->aoeminor = AOEMINOR(sysminor);
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index bc92aacb6dad..9e6f51c528b0 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -7,6 +7,7 @@
7#include <linux/hdreg.h> 7#include <linux/hdreg.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/moduleparam.h>
10#include "aoe.h" 11#include "aoe.h"
11 12
12#define NECODES 5 13#define NECODES 5
@@ -26,6 +27,19 @@ enum {
26}; 27};
27 28
28static char aoe_iflist[IFLISTSZ]; 29static char aoe_iflist[IFLISTSZ];
30module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600);
31MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\"\n");
32
33#ifndef MODULE
34static int __init aoe_iflist_setup(char *str)
35{
36 strncpy(aoe_iflist, str, IFLISTSZ);
37 aoe_iflist[IFLISTSZ - 1] = '\0';
38 return 1;
39}
40
41__setup("aoe_iflist=", aoe_iflist_setup);
42#endif
29 43
30int 44int
31is_aoe_netif(struct net_device *ifp) 45is_aoe_netif(struct net_device *ifp)
@@ -36,7 +50,8 @@ is_aoe_netif(struct net_device *ifp)
36 if (aoe_iflist[0] == '\0') 50 if (aoe_iflist[0] == '\0')
37 return 1; 51 return 1;
38 52
39 for (p = aoe_iflist; *p; p = q + strspn(q, WHITESPACE)) { 53 p = aoe_iflist + strspn(aoe_iflist, WHITESPACE);
54 for (; *p; p = q + strspn(q, WHITESPACE)) {
40 q = p + strcspn(p, WHITESPACE); 55 q = p + strcspn(p, WHITESPACE);
41 if (q != p) 56 if (q != p)
42 len = q - p; 57 len = q - p;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 42dfa281a880..f0c1084b840f 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3345,7 +3345,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3345 struct block_device *bdev = opened_bdev[cnt]; 3345 struct block_device *bdev = opened_bdev[cnt];
3346 if (!bdev || ITYPE(drive_state[cnt].fd_device) != type) 3346 if (!bdev || ITYPE(drive_state[cnt].fd_device) != type)
3347 continue; 3347 continue;
3348 __invalidate_device(bdev, 0); 3348 __invalidate_device(bdev);
3349 } 3349 }
3350 up(&open_lock); 3350 up(&open_lock);
3351 } else { 3351 } else {
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index ab4db71375e0..8bbe01d4b487 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -14,6 +14,7 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/kmod.h> 15#include <linux/kmod.h>
16#include <linux/kobj_map.h> 16#include <linux/kobj_map.h>
17#include <linux/buffer_head.h>
17 18
18#define MAX_PROBE_HASH 255 /* random */ 19#define MAX_PROBE_HASH 255 /* random */
19 20
@@ -676,7 +677,8 @@ int invalidate_partition(struct gendisk *disk, int index)
676 int res = 0; 677 int res = 0;
677 struct block_device *bdev = bdget_disk(disk, index); 678 struct block_device *bdev = bdget_disk(disk, index);
678 if (bdev) { 679 if (bdev) {
679 res = __invalidate_device(bdev, 1); 680 fsync_bdev(bdev);
681 res = __invalidate_device(bdev);
680 bdput(bdev); 682 bdput(bdev);
681 } 683 }
682 return res; 684 return res;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index efdf04450bf7..9e268ddedfbd 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -78,6 +78,7 @@
78#define DBG_RX 0x0200 78#define DBG_RX 0x0200
79#define DBG_TX 0x0400 79#define DBG_TX 0x0400
80static unsigned int debugflags; 80static unsigned int debugflags;
81static unsigned int nbds_max = 16;
81#endif /* NDEBUG */ 82#endif /* NDEBUG */
82 83
83static struct nbd_device nbd_dev[MAX_NBD]; 84static struct nbd_device nbd_dev[MAX_NBD];
@@ -647,7 +648,13 @@ static int __init nbd_init(void)
647 return -EIO; 648 return -EIO;
648 } 649 }
649 650
650 for (i = 0; i < MAX_NBD; i++) { 651 if (nbds_max > MAX_NBD) {
652 printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
653 nbds_max);
654 return -EINVAL;
655 }
656
657 for (i = 0; i < nbds_max; i++) {
651 struct gendisk *disk = alloc_disk(1); 658 struct gendisk *disk = alloc_disk(1);
652 if (!disk) 659 if (!disk)
653 goto out; 660 goto out;
@@ -673,7 +680,7 @@ static int __init nbd_init(void)
673 dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags); 680 dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags);
674 681
675 devfs_mk_dir("nbd"); 682 devfs_mk_dir("nbd");
676 for (i = 0; i < MAX_NBD; i++) { 683 for (i = 0; i < nbds_max; i++) {
677 struct gendisk *disk = nbd_dev[i].disk; 684 struct gendisk *disk = nbd_dev[i].disk;
678 nbd_dev[i].file = NULL; 685 nbd_dev[i].file = NULL;
679 nbd_dev[i].magic = LO_MAGIC; 686 nbd_dev[i].magic = LO_MAGIC;
@@ -706,8 +713,9 @@ out:
706static void __exit nbd_cleanup(void) 713static void __exit nbd_cleanup(void)
707{ 714{
708 int i; 715 int i;
709 for (i = 0; i < MAX_NBD; i++) { 716 for (i = 0; i < nbds_max; i++) {
710 struct gendisk *disk = nbd_dev[i].disk; 717 struct gendisk *disk = nbd_dev[i].disk;
718 nbd_dev[i].magic = 0;
711 if (disk) { 719 if (disk) {
712 del_gendisk(disk); 720 del_gendisk(disk);
713 blk_cleanup_queue(disk->queue); 721 blk_cleanup_queue(disk->queue);
@@ -725,6 +733,8 @@ module_exit(nbd_cleanup);
725MODULE_DESCRIPTION("Network Block Device"); 733MODULE_DESCRIPTION("Network Block Device");
726MODULE_LICENSE("GPL"); 734MODULE_LICENSE("GPL");
727 735
736module_param(nbds_max, int, 0444);
737MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize.");
728#ifndef NDEBUG 738#ifndef NDEBUG
729module_param(debugflags, int, 0644); 739module_param(debugflags, int, 0644);
730MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); 740MODULE_PARM_DESC(debugflags, "flags for controlling debug output");
diff --git a/drivers/block/noop-iosched.c b/drivers/block/noop-iosched.c
index 888c477e02b3..b1730b62c37e 100644
--- a/drivers/block/noop-iosched.c
+++ b/drivers/block/noop-iosched.c
@@ -13,34 +13,13 @@
13static int elevator_noop_merge(request_queue_t *q, struct request **req, 13static int elevator_noop_merge(request_queue_t *q, struct request **req,
14 struct bio *bio) 14 struct bio *bio)
15{ 15{
16 struct list_head *entry = &q->queue_head;
17 struct request *__rq;
18 int ret; 16 int ret;
19 17
20 if ((ret = elv_try_last_merge(q, bio))) { 18 ret = elv_try_last_merge(q, bio);
19 if (ret != ELEVATOR_NO_MERGE)
21 *req = q->last_merge; 20 *req = q->last_merge;
22 return ret;
23 }
24 21
25 while ((entry = entry->prev) != &q->queue_head) { 22 return ret;
26 __rq = list_entry_rq(entry);
27
28 if (__rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER))
29 break;
30 else if (__rq->flags & REQ_STARTED)
31 break;
32
33 if (!blk_fs_request(__rq))
34 continue;
35
36 if ((ret = elv_try_merge(__rq, bio))) {
37 *req = __rq;
38 q->last_merge = __rq;
39 return ret;
40 }
41 }
42
43 return ELEVATOR_NO_MERGE;
44} 23}
45 24
46static void elevator_noop_merge_requests(request_queue_t *q, struct request *req, 25static void elevator_noop_merge_requests(request_queue_t *q, struct request *req,
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 9deca49c71f0..beaa561f2ed8 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -645,7 +645,7 @@ static int cdrom_mrw_exit(struct cdrom_device_info *cdi)
645 ret = cdrom_mrw_bgformat_susp(cdi, 0); 645 ret = cdrom_mrw_bgformat_susp(cdi, 0);
646 } 646 }
647 647
648 if (!ret) 648 if (!ret && cdi->media_written)
649 ret = cdrom_flush_cache(cdi); 649 ret = cdrom_flush_cache(cdi);
650 650
651 return ret; 651 return ret;
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
index 647a71b12a2a..ac96de15d833 100644
--- a/drivers/cdrom/cdu31a.c
+++ b/drivers/cdrom/cdu31a.c
@@ -292,7 +292,7 @@ module_param(cdu31a_irq, int, 0);
292 292
293/* The interrupt handler will wake this queue up when it gets an 293/* The interrupt handler will wake this queue up when it gets an
294 interrupts. */ 294 interrupts. */
295DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait); 295static DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait);
296static int irq_flag = 0; 296static int irq_flag = 0;
297 297
298static int curr_control_reg = 0; /* Current value of the control register */ 298static int curr_control_reg = 0; /* Current value of the control register */
@@ -2947,7 +2947,7 @@ static int scd_block_media_changed(struct gendisk *disk)
2947 return cdrom_media_changed(&scd_info); 2947 return cdrom_media_changed(&scd_info);
2948} 2948}
2949 2949
2950struct block_device_operations scd_bdops = 2950static struct block_device_operations scd_bdops =
2951{ 2951{
2952 .owner = THIS_MODULE, 2952 .owner = THIS_MODULE,
2953 .open = scd_block_open, 2953 .open = scd_block_open,
@@ -3216,7 +3216,7 @@ errout3:
3216} 3216}
3217 3217
3218 3218
3219void __exit cdu31a_exit(void) 3219static void __exit cdu31a_exit(void)
3220{ 3220{
3221 del_gendisk(scd_gendisk); 3221 del_gendisk(scd_gendisk);
3222 put_disk(scd_gendisk); 3222 put_disk(scd_gendisk);
diff --git a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
index ccde7ab491d4..07bbd24e3c18 100644
--- a/drivers/cdrom/mcdx.c
+++ b/drivers/cdrom/mcdx.c
@@ -107,20 +107,20 @@ static const char *mcdx_c_version
107 The _direct_ size is the number of sectors we're allowed to skip 107 The _direct_ size is the number of sectors we're allowed to skip
108 directly (performing a read instead of requesting the new sector 108 directly (performing a read instead of requesting the new sector
109 needed */ 109 needed */
110const int REQUEST_SIZE = 800; /* should be less then 255 * 4 */ 110static const int REQUEST_SIZE = 800; /* should be less then 255 * 4 */
111const int DIRECT_SIZE = 400; /* should be less then REQUEST_SIZE */ 111static const int DIRECT_SIZE = 400; /* should be less then REQUEST_SIZE */
112 112
113enum drivemodes { TOC, DATA, RAW, COOKED }; 113enum drivemodes { TOC, DATA, RAW, COOKED };
114enum datamodes { MODE0, MODE1, MODE2 }; 114enum datamodes { MODE0, MODE1, MODE2 };
115enum resetmodes { SOFT, HARD }; 115enum resetmodes { SOFT, HARD };
116 116
117const int SINGLE = 0x01; /* single speed drive (FX001S, LU) */ 117static const int SINGLE = 0x01; /* single speed drive (FX001S, LU) */
118const int DOUBLE = 0x02; /* double speed drive (FX001D, ..? */ 118static const int DOUBLE = 0x02; /* double speed drive (FX001D, ..? */
119const int DOOR = 0x04; /* door locking capability */ 119static const int DOOR = 0x04; /* door locking capability */
120const int MULTI = 0x08; /* multi session capability */ 120static const int MULTI = 0x08; /* multi session capability */
121 121
122const unsigned char READ1X = 0xc0; 122static const unsigned char READ1X = 0xc0;
123const unsigned char READ2X = 0xc1; 123static const unsigned char READ2X = 0xc1;
124 124
125 125
126/* DECLARATIONS ****************************************************/ 126/* DECLARATIONS ****************************************************/
@@ -210,9 +210,7 @@ struct s_drive_stuff {
210 repeated here to show what's going on. And to sense, if they're 210 repeated here to show what's going on. And to sense, if they're
211 changed elsewhere. */ 211 changed elsewhere. */
212 212
213/* declared in blk.h */ 213static int mcdx_init(void);
214int mcdx_init(void);
215void do_mcdx_request(request_queue_t * q);
216 214
217static int mcdx_block_open(struct inode *inode, struct file *file) 215static int mcdx_block_open(struct inode *inode, struct file *file)
218{ 216{
@@ -569,7 +567,7 @@ static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
569 } 567 }
570} 568}
571 569
572void do_mcdx_request(request_queue_t * q) 570static void do_mcdx_request(request_queue_t * q)
573{ 571{
574 struct s_drive_stuff *stuffp; 572 struct s_drive_stuff *stuffp;
575 struct request *req; 573 struct request *req;
@@ -1028,7 +1026,7 @@ int __mcdx_init(void)
1028 return 0; 1026 return 0;
1029} 1027}
1030 1028
1031void __exit mcdx_exit(void) 1029static void __exit mcdx_exit(void)
1032{ 1030{
1033 int i; 1031 int i;
1034 1032
@@ -1075,7 +1073,7 @@ module_exit(mcdx_exit);
1075 1073
1076/* Support functions ************************************************/ 1074/* Support functions ************************************************/
1077 1075
1078int __init mcdx_init_drive(int drive) 1076static int __init mcdx_init_drive(int drive)
1079{ 1077{
1080 struct s_version version; 1078 struct s_version version;
1081 struct gendisk *disk; 1079 struct gendisk *disk;
@@ -1261,7 +1259,7 @@ int __init mcdx_init_drive(int drive)
1261 return 0; 1259 return 0;
1262} 1260}
1263 1261
1264int __init mcdx_init(void) 1262static int __init mcdx_init(void)
1265{ 1263{
1266 int drive; 1264 int drive;
1267 xwarn("Version 2.14(hs) \n"); 1265 xwarn("Version 2.14(hs) \n");
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index fc2c433f6a29..452d34675159 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -5895,7 +5895,7 @@ int __init sbpcd_init(void)
5895} 5895}
5896/*==========================================================================*/ 5896/*==========================================================================*/
5897#ifdef MODULE 5897#ifdef MODULE
5898void sbpcd_exit(void) 5898static void sbpcd_exit(void)
5899{ 5899{
5900 int j; 5900 int j;
5901 5901
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 096a1202ea07..5ed6515ae01f 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -153,7 +153,7 @@ config DIGIEPCA
153 153
154config ESPSERIAL 154config ESPSERIAL
155 tristate "Hayes ESP serial port support" 155 tristate "Hayes ESP serial port support"
156 depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP 156 depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP && ISA_DMA_API
157 help 157 help
158 This is a driver which supports Hayes ESP serial ports. Both single 158 This is a driver which supports Hayes ESP serial ports. Both single
159 port cards and multiport cards are supported. Make sure to read 159 port cards and multiport cards are supported. Make sure to read
@@ -195,7 +195,7 @@ config ISI
195 195
196config SYNCLINK 196config SYNCLINK
197 tristate "Microgate SyncLink card support" 197 tristate "Microgate SyncLink card support"
198 depends on SERIAL_NONSTANDARD && PCI 198 depends on SERIAL_NONSTANDARD && PCI && ISA_DMA_API
199 help 199 help
200 Provides support for the SyncLink ISA and PCI multiprotocol serial 200 Provides support for the SyncLink ISA and PCI multiprotocol serial
201 adapters. These adapters support asynchronous and HDLC bit 201 adapters. These adapters support asynchronous and HDLC bit
@@ -399,6 +399,20 @@ config SGI_SNSC
399 controller communication from user space (you want this!), 399 controller communication from user space (you want this!),
400 say Y. Otherwise, say N. 400 say Y. Otherwise, say N.
401 401
402config SGI_TIOCX
403 bool "SGI TIO CX driver support"
404 depends on (IA64_SGI_SN2 || IA64_GENERIC)
405 help
406 If you have an SGI Altix and you have fpga devices attached
407 to your TIO, say Y here, otherwise say N.
408
409config SGI_MBCS
410 tristate "SGI FPGA Core Services driver support"
411 depends on SGI_TIOCX
412 help
413 If you have an SGI Altix with an attached SABrick
414 say Y or M here, otherwise say N.
415
402source "drivers/serial/Kconfig" 416source "drivers/serial/Kconfig"
403 417
404config UNIX98_PTYS 418config UNIX98_PTYS
@@ -968,7 +982,7 @@ config MAX_RAW_DEVS
968 982
969config HANGCHECK_TIMER 983config HANGCHECK_TIMER
970 tristate "Hangcheck timer" 984 tristate "Hangcheck timer"
971 depends on X86_64 || X86 985 depends on X86_64 || X86 || IA64 || PPC64 || ARCH_S390
972 help 986 help
973 The hangcheck-timer module detects when the system has gone 987 The hangcheck-timer module detects when the system has gone
974 out to lunch past a certain margin. It can reboot the system 988 out to lunch past a certain margin. It can reboot the system
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 54ed76af1a47..e3f5c32aac55 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -42,11 +42,12 @@ obj-$(CONFIG_SX) += sx.o generic_serial.o
42obj-$(CONFIG_RIO) += rio/ generic_serial.o 42obj-$(CONFIG_RIO) += rio/ generic_serial.o
43obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvsi.o 43obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvsi.o
44obj-$(CONFIG_RAW_DRIVER) += raw.o 44obj-$(CONFIG_RAW_DRIVER) += raw.o
45obj-$(CONFIG_SGI_SNSC) += snsc.o 45obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
46obj-$(CONFIG_MMTIMER) += mmtimer.o 46obj-$(CONFIG_MMTIMER) += mmtimer.o
47obj-$(CONFIG_VIOCONS) += viocons.o 47obj-$(CONFIG_VIOCONS) += viocons.o
48obj-$(CONFIG_VIOTAPE) += viotape.o 48obj-$(CONFIG_VIOTAPE) += viotape.o
49obj-$(CONFIG_HVCS) += hvcs.o 49obj-$(CONFIG_HVCS) += hvcs.o
50obj-$(CONFIG_SGI_MBCS) += mbcs.o
50 51
51obj-$(CONFIG_PRINTER) += lp.o 52obj-$(CONFIG_PRINTER) += lp.o
52obj-$(CONFIG_TIPAR) += tipar.o 53obj-$(CONFIG_TIPAR) += tipar.o
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index c86a22c5499b..0212febda654 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -192,7 +192,7 @@ static struct aper_size_info_32 ali_generic_sizes[7] =
192 {4, 1024, 0, 3} 192 {4, 1024, 0, 3}
193}; 193};
194 194
195struct agp_bridge_driver ali_generic_bridge = { 195static struct agp_bridge_driver ali_generic_bridge = {
196 .owner = THIS_MODULE, 196 .owner = THIS_MODULE,
197 .aperture_sizes = ali_generic_sizes, 197 .aperture_sizes = ali_generic_sizes,
198 .size_type = U32_APER_SIZE, 198 .size_type = U32_APER_SIZE,
@@ -215,7 +215,7 @@ struct agp_bridge_driver ali_generic_bridge = {
215 .agp_destroy_page = ali_destroy_page, 215 .agp_destroy_page = ali_destroy_page,
216}; 216};
217 217
218struct agp_bridge_driver ali_m1541_bridge = { 218static struct agp_bridge_driver ali_m1541_bridge = {
219 .owner = THIS_MODULE, 219 .owner = THIS_MODULE,
220 .aperture_sizes = ali_generic_sizes, 220 .aperture_sizes = ali_generic_sizes,
221 .size_type = U32_APER_SIZE, 221 .size_type = U32_APER_SIZE,
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index f1ea87ea6b65..e62a3c2c44a9 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -358,7 +358,7 @@ static struct gatt_mask amd_irongate_masks[] =
358 {.mask = 1, .type = 0} 358 {.mask = 1, .type = 0}
359}; 359};
360 360
361struct agp_bridge_driver amd_irongate_driver = { 361static struct agp_bridge_driver amd_irongate_driver = {
362 .owner = THIS_MODULE, 362 .owner = THIS_MODULE,
363 .aperture_sizes = amd_irongate_sizes, 363 .aperture_sizes = amd_irongate_sizes,
364 .size_type = LVL2_APER_SIZE, 364 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 905f0629c44f..399c042f68f0 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -243,7 +243,7 @@ static void amd64_cleanup(void)
243} 243}
244 244
245 245
246struct agp_bridge_driver amd_8151_driver = { 246static struct agp_bridge_driver amd_8151_driver = {
247 .owner = THIS_MODULE, 247 .owner = THIS_MODULE,
248 .aperture_sizes = amd_8151_sizes, 248 .aperture_sizes = amd_8151_sizes,
249 .size_type = U32_APER_SIZE, 249 .size_type = U32_APER_SIZE,
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 757dde006fc9..a65f8827c283 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -393,7 +393,7 @@ static int ati_free_gatt_table(struct agp_bridge_data *bridge)
393 return 0; 393 return 0;
394} 394}
395 395
396struct agp_bridge_driver ati_generic_bridge = { 396static struct agp_bridge_driver ati_generic_bridge = {
397 .owner = THIS_MODULE, 397 .owner = THIS_MODULE,
398 .aperture_sizes = ati_generic_sizes, 398 .aperture_sizes = ati_generic_sizes,
399 .size_type = LVL2_APER_SIZE, 399 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index c3442f3c6480..2f3dfb63bdc6 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -97,7 +97,7 @@ void agp_backend_release(struct agp_bridge_data *bridge)
97EXPORT_SYMBOL(agp_backend_release); 97EXPORT_SYMBOL(agp_backend_release);
98 98
99 99
100struct { int mem, agp; } maxes_table[] = { 100static struct { int mem, agp; } maxes_table[] = {
101 {0, 0}, 101 {0, 0},
102 {32, 4}, 102 {32, 4},
103 {64, 28}, 103 {64, 28},
@@ -322,7 +322,7 @@ static int __init agp_init(void)
322 return 0; 322 return 0;
323} 323}
324 324
325void __exit agp_exit(void) 325static void __exit agp_exit(void)
326{ 326{
327} 327}
328 328
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 2a87cecdc912..1383c3165ea1 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -303,7 +303,7 @@ static int efficeon_remove_memory(struct agp_memory * mem, off_t pg_start, int t
303} 303}
304 304
305 305
306struct agp_bridge_driver efficeon_driver = { 306static struct agp_bridge_driver efficeon_driver = {
307 .owner = THIS_MODULE, 307 .owner = THIS_MODULE,
308 .aperture_sizes = efficeon_generic_sizes, 308 .aperture_sizes = efficeon_generic_sizes,
309 .size_type = LVL2_APER_SIZE, 309 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index f633623ac802..3dfb6648547b 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -235,7 +235,7 @@ static void agp_insert_into_pool(struct agp_memory * temp)
235 235
236/* File private list routines */ 236/* File private list routines */
237 237
238struct agp_file_private *agp_find_private(pid_t pid) 238static struct agp_file_private *agp_find_private(pid_t pid)
239{ 239{
240 struct agp_file_private *curr; 240 struct agp_file_private *curr;
241 241
@@ -250,7 +250,7 @@ struct agp_file_private *agp_find_private(pid_t pid)
250 return NULL; 250 return NULL;
251} 251}
252 252
253void agp_insert_file_private(struct agp_file_private * priv) 253static void agp_insert_file_private(struct agp_file_private * priv)
254{ 254{
255 struct agp_file_private *prev; 255 struct agp_file_private *prev;
256 256
@@ -262,7 +262,7 @@ void agp_insert_file_private(struct agp_file_private * priv)
262 agp_fe.file_priv_list = priv; 262 agp_fe.file_priv_list = priv;
263} 263}
264 264
265void agp_remove_file_private(struct agp_file_private * priv) 265static void agp_remove_file_private(struct agp_file_private * priv)
266{ 266{
267 struct agp_file_private *next; 267 struct agp_file_private *next;
268 struct agp_file_private *prev; 268 struct agp_file_private *prev;
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 4f7a3e8bc919..80dafa3030bd 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -288,7 +288,7 @@ static struct gatt_mask nvidia_generic_masks[] =
288}; 288};
289 289
290 290
291struct agp_bridge_driver nvidia_driver = { 291static struct agp_bridge_driver nvidia_driver = {
292 .owner = THIS_MODULE, 292 .owner = THIS_MODULE,
293 .aperture_sizes = nvidia_generic_sizes, 293 .aperture_sizes = nvidia_generic_sizes,
294 .size_type = U8_APER_SIZE, 294 .size_type = U8_APER_SIZE,
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index cfccacb2a647..ebc05554045c 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -119,7 +119,7 @@ static struct aper_size_info_8 sis_generic_sizes[7] =
119 {4, 1024, 0, 3} 119 {4, 1024, 0, 3}
120}; 120};
121 121
122struct agp_bridge_driver sis_driver = { 122static struct agp_bridge_driver sis_driver = {
123 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
124 .aperture_sizes = sis_generic_sizes, 124 .aperture_sizes = sis_generic_sizes,
125 .size_type = U8_APER_SIZE, 125 .size_type = U8_APER_SIZE,
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index bb338d9134e0..10c23302dd84 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -409,7 +409,7 @@ static void serverworks_agp_enable(struct agp_bridge_data *bridge, u32 mode)
409 agp_device_command(command, 0); 409 agp_device_command(command, 0);
410} 410}
411 411
412struct agp_bridge_driver sworks_driver = { 412static struct agp_bridge_driver sworks_driver = {
413 .owner = THIS_MODULE, 413 .owner = THIS_MODULE,
414 .aperture_sizes = serverworks_sizes, 414 .aperture_sizes = serverworks_sizes,
415 .size_type = LVL2_APER_SIZE, 415 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index e1451dd9b6a7..c847df575cf5 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -170,7 +170,7 @@ static void via_tlbflush_agp3(struct agp_memory *mem)
170} 170}
171 171
172 172
173struct agp_bridge_driver via_agp3_driver = { 173static struct agp_bridge_driver via_agp3_driver = {
174 .owner = THIS_MODULE, 174 .owner = THIS_MODULE,
175 .aperture_sizes = agp3_generic_sizes, 175 .aperture_sizes = agp3_generic_sizes,
176 .size_type = U8_APER_SIZE, 176 .size_type = U8_APER_SIZE,
@@ -193,7 +193,7 @@ struct agp_bridge_driver via_agp3_driver = {
193 .agp_destroy_page = agp_generic_destroy_page, 193 .agp_destroy_page = agp_generic_destroy_page,
194}; 194};
195 195
196struct agp_bridge_driver via_driver = { 196static struct agp_bridge_driver via_driver = {
197 .owner = THIS_MODULE, 197 .owner = THIS_MODULE,
198 .aperture_sizes = via_generic_sizes, 198 .aperture_sizes = via_generic_sizes,
199 .size_type = U8_APER_SIZE, 199 .size_type = U8_APER_SIZE,
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 903e4c3cc209..a229915ce1b2 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -52,7 +52,7 @@
52#define KERNEL 52#define KERNEL
53#include <linux/types.h> 53#include <linux/types.h>
54#include <linux/fs.h> 54#include <linux/fs.h>
55#include <linux/mm.h> /* for verify_area */ 55#include <linux/mm.h>
56#include <linux/errno.h> /* for -EBUSY */ 56#include <linux/errno.h> /* for -EBUSY */
57#include <linux/ioport.h> /* for request_region */ 57#include <linux/ioport.h> /* for request_region */
58#include <linux/delay.h> /* for loops_per_jiffy */ 58#include <linux/delay.h> /* for loops_per_jiffy */
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index 83d6b37b36cd..78e650fc5b41 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Driver for a little io fencing timer. 4 * Driver for a little io fencing timer.
5 * 5 *
6 * Copyright (C) 2002 Oracle Corporation. All rights reserved. 6 * Copyright (C) 2002, 2003 Oracle. All rights reserved.
7 * 7 *
8 * Author: Joel Becker <joel.becker@oracle.com> 8 * Author: Joel Becker <joel.becker@oracle.com>
9 * 9 *
@@ -44,11 +44,14 @@
44#include <linux/fs.h> 44#include <linux/fs.h>
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/reboot.h> 46#include <linux/reboot.h>
47#include <linux/smp_lock.h>
47#include <linux/init.h> 48#include <linux/init.h>
49#include <linux/delay.h>
48#include <asm/uaccess.h> 50#include <asm/uaccess.h>
51#include <linux/sysrq.h>
49 52
50 53
51#define VERSION_STR "0.5.0" 54#define VERSION_STR "0.9.0"
52 55
53#define DEFAULT_IOFENCE_MARGIN 60 /* Default fudge factor, in seconds */ 56#define DEFAULT_IOFENCE_MARGIN 60 /* Default fudge factor, in seconds */
54#define DEFAULT_IOFENCE_TICK 180 /* Default timer timeout, in seconds */ 57#define DEFAULT_IOFENCE_TICK 180 /* Default timer timeout, in seconds */
@@ -56,18 +59,89 @@
56static int hangcheck_tick = DEFAULT_IOFENCE_TICK; 59static int hangcheck_tick = DEFAULT_IOFENCE_TICK;
57static int hangcheck_margin = DEFAULT_IOFENCE_MARGIN; 60static int hangcheck_margin = DEFAULT_IOFENCE_MARGIN;
58static int hangcheck_reboot; /* Defaults to not reboot */ 61static int hangcheck_reboot; /* Defaults to not reboot */
62static int hangcheck_dump_tasks; /* Defaults to not dumping SysRQ T */
59 63
60/* Driver options */ 64/* options - modular */
61module_param(hangcheck_tick, int, 0); 65module_param(hangcheck_tick, int, 0);
62MODULE_PARM_DESC(hangcheck_tick, "Timer delay."); 66MODULE_PARM_DESC(hangcheck_tick, "Timer delay.");
63module_param(hangcheck_margin, int, 0); 67module_param(hangcheck_margin, int, 0);
64MODULE_PARM_DESC(hangcheck_margin, "If the hangcheck timer has been delayed more than hangcheck_margin seconds, the driver will fire."); 68MODULE_PARM_DESC(hangcheck_margin, "If the hangcheck timer has been delayed more than hangcheck_margin seconds, the driver will fire.");
65module_param(hangcheck_reboot, int, 0); 69module_param(hangcheck_reboot, int, 0);
66MODULE_PARM_DESC(hangcheck_reboot, "If nonzero, the machine will reboot when the timer margin is exceeded."); 70MODULE_PARM_DESC(hangcheck_reboot, "If nonzero, the machine will reboot when the timer margin is exceeded.");
71module_param(hangcheck_dump_tasks, int, 0);
72MODULE_PARM_DESC(hangcheck_dump_tasks, "If nonzero, the machine will dump the system task state when the timer margin is exceeded.");
67 73
68MODULE_AUTHOR("Joel Becker"); 74MODULE_AUTHOR("Oracle");
69MODULE_DESCRIPTION("Hangcheck-timer detects when the system has gone out to lunch past a certain margin."); 75MODULE_DESCRIPTION("Hangcheck-timer detects when the system has gone out to lunch past a certain margin.");
70MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
77MODULE_VERSION(VERSION_STR);
78
79/* options - nonmodular */
80#ifndef MODULE
81
82static int __init hangcheck_parse_tick(char *str)
83{
84 int par;
85 if (get_option(&str,&par))
86 hangcheck_tick = par;
87 return 1;
88}
89
90static int __init hangcheck_parse_margin(char *str)
91{
92 int par;
93 if (get_option(&str,&par))
94 hangcheck_margin = par;
95 return 1;
96}
97
98static int __init hangcheck_parse_reboot(char *str)
99{
100 int par;
101 if (get_option(&str,&par))
102 hangcheck_reboot = par;
103 return 1;
104}
105
106static int __init hangcheck_parse_dump_tasks(char *str)
107{
108 int par;
109 if (get_option(&str,&par))
110 hangcheck_dump_tasks = par;
111 return 1;
112}
113
114__setup("hcheck_tick", hangcheck_parse_tick);
115__setup("hcheck_margin", hangcheck_parse_margin);
116__setup("hcheck_reboot", hangcheck_parse_reboot);
117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118#endif /* not MODULE */
119
120#if defined(CONFIG_X86) || defined(CONFIG_X86_64)
121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_ARCH_S390)
124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */
125# define TIMER_FREQ 0xFA240000ULL
126#elif defined(CONFIG_IA64)
127# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq)
128#elif defined(CONFIG_PPC64)
129# define TIMER_FREQ (HZ*loops_per_jiffy)
130#endif
131
132#ifdef HAVE_MONOTONIC
133extern unsigned long long monotonic_clock(void);
134#else
135static inline unsigned long long monotonic_clock(void)
136{
137# ifdef __s390__
138 /* returns the TOD. see 4-38 Principles of Op of zSeries */
139 return get_clock();
140# else
141 return get_cycles();
142# endif /* __s390__ */
143}
144#endif /* HAVE_MONOTONIC */
71 145
72 146
73/* Last time scheduled */ 147/* Last time scheduled */
@@ -78,7 +152,6 @@ static void hangcheck_fire(unsigned long);
78static struct timer_list hangcheck_ticktock = 152static struct timer_list hangcheck_ticktock =
79 TIMER_INITIALIZER(hangcheck_fire, 0, 0); 153 TIMER_INITIALIZER(hangcheck_fire, 0, 0);
80 154
81extern unsigned long long monotonic_clock(void);
82 155
83static void hangcheck_fire(unsigned long data) 156static void hangcheck_fire(unsigned long data)
84{ 157{
@@ -92,6 +165,12 @@ static void hangcheck_fire(unsigned long data)
92 tsc_diff = (cur_tsc + (~0ULL - hangcheck_tsc)); /* or something */ 165 tsc_diff = (cur_tsc + (~0ULL - hangcheck_tsc)); /* or something */
93 166
94 if (tsc_diff > hangcheck_tsc_margin) { 167 if (tsc_diff > hangcheck_tsc_margin) {
168 if (hangcheck_dump_tasks) {
169 printk(KERN_CRIT "Hangcheck: Task state:\n");
170#ifdef CONFIG_MAGIC_SYSRQ
171 handle_sysrq('t', NULL, NULL);
172#endif /* CONFIG_MAGIC_SYSRQ */
173 }
95 if (hangcheck_reboot) { 174 if (hangcheck_reboot) {
96 printk(KERN_CRIT "Hangcheck: hangcheck is restarting the machine.\n"); 175 printk(KERN_CRIT "Hangcheck: hangcheck is restarting the machine.\n");
97 machine_restart(NULL); 176 machine_restart(NULL);
@@ -108,10 +187,16 @@ static int __init hangcheck_init(void)
108{ 187{
109 printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", 188 printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n",
110 VERSION_STR, hangcheck_tick, hangcheck_margin); 189 VERSION_STR, hangcheck_tick, hangcheck_margin);
111 190#if defined (HAVE_MONOTONIC)
112 hangcheck_tsc_margin = hangcheck_margin + hangcheck_tick; 191 printk("Hangcheck: Using monotonic_clock().\n");
113 hangcheck_tsc_margin *= 1000000000; 192#elif defined(__s390__)
114 193 printk("Hangcheck: Using TOD.\n");
194#else
195 printk("Hangcheck: Using get_cycles().\n");
196#endif /* HAVE_MONOTONIC */
197 hangcheck_tsc_margin =
198 (unsigned long long)(hangcheck_margin + hangcheck_tick);
199 hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ;
115 200
116 hangcheck_tsc = monotonic_clock(); 201 hangcheck_tsc = monotonic_clock();
117 mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); 202 mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ));
@@ -123,6 +208,7 @@ static int __init hangcheck_init(void)
123static void __exit hangcheck_exit(void) 208static void __exit hangcheck_exit(void)
124{ 209{
125 del_timer_sync(&hangcheck_ticktock); 210 del_timer_sync(&hangcheck_ticktock);
211 printk("Hangcheck: Stopped hangcheck timer.\n");
126} 212}
127 213
128module_init(hangcheck_init); 214module_init(hangcheck_init);
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index 225b330115bb..5ce9c6269033 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -235,7 +235,6 @@ static void reset_flags(struct si_sm_data *bt)
235 if (BT_STATUS & BT_B_BUSY) BT_CONTROL(BT_B_BUSY); 235 if (BT_STATUS & BT_B_BUSY) BT_CONTROL(BT_B_BUSY);
236 BT_CONTROL(BT_CLR_WR_PTR); 236 BT_CONTROL(BT_CLR_WR_PTR);
237 BT_CONTROL(BT_SMS_ATN); 237 BT_CONTROL(BT_SMS_ATN);
238 BT_INTMASK_W(BT_BMC_HWRST);
239#ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION 238#ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION
240 if (BT_STATUS & BT_B2H_ATN) { 239 if (BT_STATUS & BT_B2H_ATN) {
241 int i; 240 int i;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index a6606a1aced7..d7fb452af7f9 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2588,28 +2588,20 @@ handle_msg_timeout(struct ipmi_recv_msg *msg)
2588 deliver_response(msg); 2588 deliver_response(msg);
2589} 2589}
2590 2590
2591static void 2591static struct ipmi_smi_msg *
2592send_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, 2592smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
2593 struct ipmi_smi_msg *smi_msg, 2593 unsigned char seq, long seqid)
2594 unsigned char seq, long seqid)
2595{ 2594{
2596 if (!smi_msg) 2595 struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg();
2597 smi_msg = ipmi_alloc_smi_msg();
2598 if (!smi_msg) 2596 if (!smi_msg)
2599 /* If we can't allocate the message, then just return, we 2597 /* If we can't allocate the message, then just return, we
2600 get 4 retries, so this should be ok. */ 2598 get 4 retries, so this should be ok. */
2601 return; 2599 return NULL;
2602 2600
2603 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len); 2601 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len);
2604 smi_msg->data_size = recv_msg->msg.data_len; 2602 smi_msg->data_size = recv_msg->msg.data_len;
2605 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid); 2603 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid);
2606 2604
2607 /* Send the new message. We send with a zero priority. It
2608 timed out, I doubt time is that critical now, and high
2609 priority messages are really only for messages to the local
2610 MC, which don't get resent. */
2611 intf->handlers->sender(intf->send_info, smi_msg, 0);
2612
2613#ifdef DEBUG_MSGING 2605#ifdef DEBUG_MSGING
2614 { 2606 {
2615 int m; 2607 int m;
@@ -2619,6 +2611,7 @@ send_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
2619 printk("\n"); 2611 printk("\n");
2620 } 2612 }
2621#endif 2613#endif
2614 return smi_msg;
2622} 2615}
2623 2616
2624static void 2617static void
@@ -2683,14 +2676,13 @@ ipmi_timeout_handler(long timeout_period)
2683 intf->timed_out_ipmb_commands++; 2676 intf->timed_out_ipmb_commands++;
2684 spin_unlock(&intf->counter_lock); 2677 spin_unlock(&intf->counter_lock);
2685 } else { 2678 } else {
2679 struct ipmi_smi_msg *smi_msg;
2686 /* More retries, send again. */ 2680 /* More retries, send again. */
2687 2681
2688 /* Start with the max timer, set to normal 2682 /* Start with the max timer, set to normal
2689 timer after the message is sent. */ 2683 timer after the message is sent. */
2690 ent->timeout = MAX_MSG_TIMEOUT; 2684 ent->timeout = MAX_MSG_TIMEOUT;
2691 ent->retries_left--; 2685 ent->retries_left--;
2692 send_from_recv_msg(intf, ent->recv_msg, NULL,
2693 j, ent->seqid);
2694 spin_lock(&intf->counter_lock); 2686 spin_lock(&intf->counter_lock);
2695 if (ent->recv_msg->addr.addr_type 2687 if (ent->recv_msg->addr.addr_type
2696 == IPMI_LAN_ADDR_TYPE) 2688 == IPMI_LAN_ADDR_TYPE)
@@ -2698,6 +2690,20 @@ ipmi_timeout_handler(long timeout_period)
2698 else 2690 else
2699 intf->retransmitted_ipmb_commands++; 2691 intf->retransmitted_ipmb_commands++;
2700 spin_unlock(&intf->counter_lock); 2692 spin_unlock(&intf->counter_lock);
2693 smi_msg = smi_from_recv_msg(intf,
2694 ent->recv_msg, j, ent->seqid);
2695 if(!smi_msg)
2696 continue;
2697
2698 spin_unlock_irqrestore(&(intf->seq_lock),flags);
2699 /* Send the new message. We send with a zero
2700 * priority. It timed out, I doubt time is
2701 * that critical now, and high priority
2702 * messages are really only for messages to the
2703 * local MC, which don't get resent. */
2704 intf->handlers->sender(intf->send_info,
2705 smi_msg, 0);
2706 spin_lock_irqsave(&(intf->seq_lock), flags);
2701 } 2707 }
2702 } 2708 }
2703 spin_unlock_irqrestore(&(intf->seq_lock), flags); 2709 spin_unlock_irqrestore(&(intf->seq_lock), flags);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 29de259a981e..298574e16061 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -100,6 +100,11 @@ enum si_intf_state {
100 /* FIXME - add watchdog stuff. */ 100 /* FIXME - add watchdog stuff. */
101}; 101};
102 102
103/* Some BT-specific defines we need here. */
104#define IPMI_BT_INTMASK_REG 2
105#define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
106#define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
107
103enum si_type { 108enum si_type {
104 SI_KCS, SI_SMIC, SI_BT 109 SI_KCS, SI_SMIC, SI_BT
105}; 110};
@@ -875,6 +880,17 @@ static irqreturn_t si_irq_handler(int irq, void *data, struct pt_regs *regs)
875 return IRQ_HANDLED; 880 return IRQ_HANDLED;
876} 881}
877 882
883static irqreturn_t si_bt_irq_handler(int irq, void *data, struct pt_regs *regs)
884{
885 struct smi_info *smi_info = data;
886 /* We need to clear the IRQ flag for the BT interface. */
887 smi_info->io.outputb(&smi_info->io, IPMI_BT_INTMASK_REG,
888 IPMI_BT_INTMASK_CLEAR_IRQ_BIT
889 | IPMI_BT_INTMASK_ENABLE_IRQ_BIT);
890 return si_irq_handler(irq, data, regs);
891}
892
893
878static struct ipmi_smi_handlers handlers = 894static struct ipmi_smi_handlers handlers =
879{ 895{
880 .owner = THIS_MODULE, 896 .owner = THIS_MODULE,
@@ -1001,11 +1017,22 @@ static int std_irq_setup(struct smi_info *info)
1001 if (!info->irq) 1017 if (!info->irq)
1002 return 0; 1018 return 0;
1003 1019
1004 rv = request_irq(info->irq, 1020 if (info->si_type == SI_BT) {
1005 si_irq_handler, 1021 rv = request_irq(info->irq,
1006 SA_INTERRUPT, 1022 si_bt_irq_handler,
1007 DEVICE_NAME, 1023 SA_INTERRUPT,
1008 info); 1024 DEVICE_NAME,
1025 info);
1026 if (!rv)
1027 /* Enable the interrupt in the BT interface. */
1028 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG,
1029 IPMI_BT_INTMASK_ENABLE_IRQ_BIT);
1030 } else
1031 rv = request_irq(info->irq,
1032 si_irq_handler,
1033 SA_INTERRUPT,
1034 DEVICE_NAME,
1035 info);
1009 if (rv) { 1036 if (rv) {
1010 printk(KERN_WARNING 1037 printk(KERN_WARNING
1011 "ipmi_si: %s unable to claim interrupt %d," 1038 "ipmi_si: %s unable to claim interrupt %d,"
@@ -1024,6 +1051,9 @@ static void std_irq_cleanup(struct smi_info *info)
1024 if (!info->irq) 1051 if (!info->irq)
1025 return; 1052 return;
1026 1053
1054 if (info->si_type == SI_BT)
1055 /* Disable the interrupt in the BT interface. */
1056 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, 0);
1027 free_irq(info->irq, info); 1057 free_irq(info->irq, info);
1028} 1058}
1029 1059
@@ -1526,8 +1556,17 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1526 info->irq_setup = NULL; 1556 info->irq_setup = NULL;
1527 } 1557 }
1528 1558
1529 regspacings[intf_num] = spmi->addr.register_bit_width / 8; 1559 if (spmi->addr.register_bit_width) {
1530 info->io.regspacing = spmi->addr.register_bit_width / 8; 1560 /* A (hopefully) properly formed register bit width. */
1561 regspacings[intf_num] = spmi->addr.register_bit_width / 8;
1562 info->io.regspacing = spmi->addr.register_bit_width / 8;
1563 } else {
1564 /* Some broken systems get this wrong and set the value
1565 * to zero. Assume it is the default spacing. If that
1566 * is wrong, too bad, the vendor should fix the tables. */
1567 regspacings[intf_num] = DEFAULT_REGSPACING;
1568 info->io.regspacing = DEFAULT_REGSPACING;
1569 }
1531 regsizes[intf_num] = regspacings[intf_num]; 1570 regsizes[intf_num] = regspacings[intf_num];
1532 info->io.regsize = regsizes[intf_num]; 1571 info->io.regsize = regsizes[intf_num];
1533 regshifts[intf_num] = spmi->addr.register_bit_offset; 1572 regshifts[intf_num] = spmi->addr.register_bit_offset;
@@ -1578,15 +1617,15 @@ typedef struct dmi_header
1578 u16 handle; 1617 u16 handle;
1579} dmi_header_t; 1618} dmi_header_t;
1580 1619
1581static int decode_dmi(dmi_header_t *dm, int intf_num) 1620static int decode_dmi(dmi_header_t __iomem *dm, int intf_num)
1582{ 1621{
1583 u8 *data = (u8 *)dm; 1622 u8 __iomem *data = (u8 __iomem *)dm;
1584 unsigned long base_addr; 1623 unsigned long base_addr;
1585 u8 reg_spacing; 1624 u8 reg_spacing;
1586 u8 len = dm->length; 1625 u8 len = readb(&dm->length);
1587 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; 1626 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num;
1588 1627
1589 ipmi_data->type = data[4]; 1628 ipmi_data->type = readb(&data[4]);
1590 1629
1591 memcpy(&base_addr, data+8, sizeof(unsigned long)); 1630 memcpy(&base_addr, data+8, sizeof(unsigned long));
1592 if (len >= 0x11) { 1631 if (len >= 0x11) {
@@ -1601,12 +1640,12 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1601 } 1640 }
1602 /* If bit 4 of byte 0x10 is set, then the lsb for the address 1641 /* If bit 4 of byte 0x10 is set, then the lsb for the address
1603 is odd. */ 1642 is odd. */
1604 ipmi_data->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); 1643 ipmi_data->base_addr = base_addr | ((readb(&data[0x10]) & 0x10) >> 4);
1605 1644
1606 ipmi_data->irq = data[0x11]; 1645 ipmi_data->irq = readb(&data[0x11]);
1607 1646
1608 /* The top two bits of byte 0x10 hold the register spacing. */ 1647 /* The top two bits of byte 0x10 hold the register spacing. */
1609 reg_spacing = (data[0x10] & 0xC0) >> 6; 1648 reg_spacing = (readb(&data[0x10]) & 0xC0) >> 6;
1610 switch(reg_spacing){ 1649 switch(reg_spacing){
1611 case 0x00: /* Byte boundaries */ 1650 case 0x00: /* Byte boundaries */
1612 ipmi_data->offset = 1; 1651 ipmi_data->offset = 1;
@@ -1623,12 +1662,18 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1623 } 1662 }
1624 } else { 1663 } else {
1625 /* Old DMI spec. */ 1664 /* Old DMI spec. */
1626 ipmi_data->base_addr = base_addr; 1665 /* Note that technically, the lower bit of the base
1666 * address should be 1 if the address is I/O and 0 if
1667 * the address is in memory. So many systems get that
1668 * wrong (and all that I have seen are I/O) so we just
1669 * ignore that bit and assume I/O. Systems that use
1670 * memory should use the newer spec, anyway. */
1671 ipmi_data->base_addr = base_addr & 0xfffe;
1627 ipmi_data->addr_space = IPMI_IO_ADDR_SPACE; 1672 ipmi_data->addr_space = IPMI_IO_ADDR_SPACE;
1628 ipmi_data->offset = 1; 1673 ipmi_data->offset = 1;
1629 } 1674 }
1630 1675
1631 ipmi_data->slave_addr = data[6]; 1676 ipmi_data->slave_addr = readb(&data[6]);
1632 1677
1633 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) { 1678 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) {
1634 dmi_data_entries++; 1679 dmi_data_entries++;
@@ -1642,9 +1687,9 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1642 1687
1643static int dmi_table(u32 base, int len, int num) 1688static int dmi_table(u32 base, int len, int num)
1644{ 1689{
1645 u8 *buf; 1690 u8 __iomem *buf;
1646 struct dmi_header *dm; 1691 struct dmi_header __iomem *dm;
1647 u8 *data; 1692 u8 __iomem *data;
1648 int i=1; 1693 int i=1;
1649 int status=-1; 1694 int status=-1;
1650 int intf_num = 0; 1695 int intf_num = 0;
@@ -1657,12 +1702,12 @@ static int dmi_table(u32 base, int len, int num)
1657 1702
1658 while(i<num && (data - buf) < len) 1703 while(i<num && (data - buf) < len)
1659 { 1704 {
1660 dm=(dmi_header_t *)data; 1705 dm=(dmi_header_t __iomem *)data;
1661 1706
1662 if((data-buf+dm->length) >= len) 1707 if((data-buf+readb(&dm->length)) >= len)
1663 break; 1708 break;
1664 1709
1665 if (dm->type == 38) { 1710 if (readb(&dm->type) == 38) {
1666 if (decode_dmi(dm, intf_num) == 0) { 1711 if (decode_dmi(dm, intf_num) == 0) {
1667 intf_num++; 1712 intf_num++;
1668 if (intf_num >= SI_MAX_DRIVERS) 1713 if (intf_num >= SI_MAX_DRIVERS)
@@ -1670,8 +1715,8 @@ static int dmi_table(u32 base, int len, int num)
1670 } 1715 }
1671 } 1716 }
1672 1717
1673 data+=dm->length; 1718 data+=readb(&dm->length);
1674 while((data-buf) < len && (*data || data[1])) 1719 while((data-buf) < len && (readb(data)||readb(data+1)))
1675 data++; 1720 data++;
1676 data+=2; 1721 data+=2;
1677 i++; 1722 i++;
@@ -2199,7 +2244,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2199 /* Wait until we know that we are out of any interrupt 2244 /* Wait until we know that we are out of any interrupt
2200 handlers might have been running before we freed the 2245 handlers might have been running before we freed the
2201 interrupt. */ 2246 interrupt. */
2202 synchronize_kernel(); 2247 synchronize_sched();
2203 2248
2204 if (new_smi->si_sm) { 2249 if (new_smi->si_sm) {
2205 if (new_smi->handlers) 2250 if (new_smi->handlers)
@@ -2312,7 +2357,7 @@ static void __exit cleanup_one_si(struct smi_info *to_clean)
2312 /* Wait until we know that we are out of any interrupt 2357 /* Wait until we know that we are out of any interrupt
2313 handlers might have been running before we freed the 2358 handlers might have been running before we freed the
2314 interrupt. */ 2359 interrupt. */
2315 synchronize_kernel(); 2360 synchronize_sched();
2316 2361
2317 /* Wait for the timer to stop. This avoids problems with race 2362 /* Wait for the timer to stop. This avoids problems with race
2318 conditions removing the timer here. */ 2363 conditions removing the timer here. */
diff --git a/drivers/char/ipmi/ipmi_si_sm.h b/drivers/char/ipmi/ipmi_si_sm.h
index a0212b004016..62791dd42985 100644
--- a/drivers/char/ipmi/ipmi_si_sm.h
+++ b/drivers/char/ipmi/ipmi_si_sm.h
@@ -51,7 +51,7 @@ struct si_sm_io
51 /* Generic info used by the actual handling routines, the 51 /* Generic info used by the actual handling routines, the
52 state machine shouldn't touch these. */ 52 state machine shouldn't touch these. */
53 void *info; 53 void *info;
54 void *addr; 54 void __iomem *addr;
55 int regspacing; 55 int regspacing;
56 int regsize; 56 int regsize;
57 int regshift; 57 int regshift;
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index fd7093879c66..fcd1c02a32cb 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -709,11 +709,11 @@ static int ipmi_close(struct inode *ino, struct file *filep)
709 if (expect_close == 42) { 709 if (expect_close == 42) {
710 ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 710 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
711 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); 711 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
712 clear_bit(0, &ipmi_wdog_open);
713 } else { 712 } else {
714 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); 713 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
715 ipmi_heartbeat(); 714 ipmi_heartbeat();
716 } 715 }
716 clear_bit(0, &ipmi_wdog_open);
717 } 717 }
718 718
719 ipmi_fasync (-1, filep, 0); 719 ipmi_fasync (-1, filep, 0);
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 3ce51c6a1b18..7b19e02f112f 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1026,7 +1026,8 @@ static void kbd_rawcode(unsigned char data)
1026 put_queue(vc, data); 1026 put_queue(vc, data);
1027} 1027}
1028 1028
1029void kbd_keycode(unsigned int keycode, int down, int hw_raw, struct pt_regs *regs) 1029static void kbd_keycode(unsigned int keycode, int down,
1030 int hw_raw, struct pt_regs *regs)
1030{ 1031{
1031 struct vc_data *vc = vc_cons[fg_console].d; 1032 struct vc_data *vc = vc_cons[fg_console].d;
1032 unsigned short keysym, *key_map; 1033 unsigned short keysym, *key_map;
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
new file mode 100644
index 000000000000..ac9cfa9701ea
--- /dev/null
+++ b/drivers/char/mbcs.c
@@ -0,0 +1,849 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9/*
10 * MOATB Core Services driver.
11 */
12
13#include <linux/config.h>
14#include <linux/interrupt.h>
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/types.h>
18#include <linux/ioport.h>
19#include <linux/notifier.h>
20#include <linux/reboot.h>
21#include <linux/init.h>
22#include <linux/fs.h>
23#include <linux/delay.h>
24#include <linux/device.h>
25#include <linux/mm.h>
26#include <linux/uio.h>
27#include <asm/io.h>
28#include <asm/uaccess.h>
29#include <asm/system.h>
30#include <asm/pgtable.h>
31#include <asm/sn/addrs.h>
32#include <asm/sn/intr.h>
33#include <asm/sn/tiocx.h>
34#include "mbcs.h"
35
36#define MBCS_DEBUG 0
37#if MBCS_DEBUG
38#define DBG(fmt...) printk(KERN_ALERT fmt)
39#else
40#define DBG(fmt...)
41#endif
42int mbcs_major;
43
44LIST_HEAD(soft_list);
45
46/*
47 * file operations
48 */
49struct file_operations mbcs_ops = {
50 .open = mbcs_open,
51 .llseek = mbcs_sram_llseek,
52 .read = mbcs_sram_read,
53 .write = mbcs_sram_write,
54 .mmap = mbcs_gscr_mmap,
55};
56
57struct mbcs_callback_arg {
58 int minor;
59 struct cx_dev *cx_dev;
60};
61
62static inline void mbcs_getdma_init(struct getdma *gdma)
63{
64 memset(gdma, 0, sizeof(struct getdma));
65 gdma->DoneIntEnable = 1;
66}
67
68static inline void mbcs_putdma_init(struct putdma *pdma)
69{
70 memset(pdma, 0, sizeof(struct putdma));
71 pdma->DoneIntEnable = 1;
72}
73
74static inline void mbcs_algo_init(struct algoblock *algo_soft)
75{
76 memset(algo_soft, 0, sizeof(struct algoblock));
77}
78
79static inline void mbcs_getdma_set(void *mmr,
80 uint64_t hostAddr,
81 uint64_t localAddr,
82 uint64_t localRamSel,
83 uint64_t numPkts,
84 uint64_t amoEnable,
85 uint64_t intrEnable,
86 uint64_t peerIO,
87 uint64_t amoHostDest,
88 uint64_t amoModType, uint64_t intrHostDest,
89 uint64_t intrVector)
90{
91 union dma_control rdma_control;
92 union dma_amo_dest amo_dest;
93 union intr_dest intr_dest;
94 union dma_localaddr local_addr;
95 union dma_hostaddr host_addr;
96
97 rdma_control.dma_control_reg = 0;
98 amo_dest.dma_amo_dest_reg = 0;
99 intr_dest.intr_dest_reg = 0;
100 local_addr.dma_localaddr_reg = 0;
101 host_addr.dma_hostaddr_reg = 0;
102
103 host_addr.dma_sys_addr = hostAddr;
104 MBCS_MMR_SET(mmr, MBCS_RD_DMA_SYS_ADDR, host_addr.dma_hostaddr_reg);
105
106 local_addr.dma_ram_addr = localAddr;
107 local_addr.dma_ram_sel = localRamSel;
108 MBCS_MMR_SET(mmr, MBCS_RD_DMA_LOC_ADDR, local_addr.dma_localaddr_reg);
109
110 rdma_control.dma_op_length = numPkts;
111 rdma_control.done_amo_en = amoEnable;
112 rdma_control.done_int_en = intrEnable;
113 rdma_control.pio_mem_n = peerIO;
114 MBCS_MMR_SET(mmr, MBCS_RD_DMA_CTRL, rdma_control.dma_control_reg);
115
116 amo_dest.dma_amo_sys_addr = amoHostDest;
117 amo_dest.dma_amo_mod_type = amoModType;
118 MBCS_MMR_SET(mmr, MBCS_RD_DMA_AMO_DEST, amo_dest.dma_amo_dest_reg);
119
120 intr_dest.address = intrHostDest;
121 intr_dest.int_vector = intrVector;
122 MBCS_MMR_SET(mmr, MBCS_RD_DMA_INT_DEST, intr_dest.intr_dest_reg);
123
124}
125
126static inline void mbcs_putdma_set(void *mmr,
127 uint64_t hostAddr,
128 uint64_t localAddr,
129 uint64_t localRamSel,
130 uint64_t numPkts,
131 uint64_t amoEnable,
132 uint64_t intrEnable,
133 uint64_t peerIO,
134 uint64_t amoHostDest,
135 uint64_t amoModType,
136 uint64_t intrHostDest, uint64_t intrVector)
137{
138 union dma_control wdma_control;
139 union dma_amo_dest amo_dest;
140 union intr_dest intr_dest;
141 union dma_localaddr local_addr;
142 union dma_hostaddr host_addr;
143
144 wdma_control.dma_control_reg = 0;
145 amo_dest.dma_amo_dest_reg = 0;
146 intr_dest.intr_dest_reg = 0;
147 local_addr.dma_localaddr_reg = 0;
148 host_addr.dma_hostaddr_reg = 0;
149
150 host_addr.dma_sys_addr = hostAddr;
151 MBCS_MMR_SET(mmr, MBCS_WR_DMA_SYS_ADDR, host_addr.dma_hostaddr_reg);
152
153 local_addr.dma_ram_addr = localAddr;
154 local_addr.dma_ram_sel = localRamSel;
155 MBCS_MMR_SET(mmr, MBCS_WR_DMA_LOC_ADDR, local_addr.dma_localaddr_reg);
156
157 wdma_control.dma_op_length = numPkts;
158 wdma_control.done_amo_en = amoEnable;
159 wdma_control.done_int_en = intrEnable;
160 wdma_control.pio_mem_n = peerIO;
161 MBCS_MMR_SET(mmr, MBCS_WR_DMA_CTRL, wdma_control.dma_control_reg);
162
163 amo_dest.dma_amo_sys_addr = amoHostDest;
164 amo_dest.dma_amo_mod_type = amoModType;
165 MBCS_MMR_SET(mmr, MBCS_WR_DMA_AMO_DEST, amo_dest.dma_amo_dest_reg);
166
167 intr_dest.address = intrHostDest;
168 intr_dest.int_vector = intrVector;
169 MBCS_MMR_SET(mmr, MBCS_WR_DMA_INT_DEST, intr_dest.intr_dest_reg);
170
171}
172
173static inline void mbcs_algo_set(void *mmr,
174 uint64_t amoHostDest,
175 uint64_t amoModType,
176 uint64_t intrHostDest,
177 uint64_t intrVector, uint64_t algoStepCount)
178{
179 union dma_amo_dest amo_dest;
180 union intr_dest intr_dest;
181 union algo_step step;
182
183 step.algo_step_reg = 0;
184 intr_dest.intr_dest_reg = 0;
185 amo_dest.dma_amo_dest_reg = 0;
186
187 amo_dest.dma_amo_sys_addr = amoHostDest;
188 amo_dest.dma_amo_mod_type = amoModType;
189 MBCS_MMR_SET(mmr, MBCS_ALG_AMO_DEST, amo_dest.dma_amo_dest_reg);
190
191 intr_dest.address = intrHostDest;
192 intr_dest.int_vector = intrVector;
193 MBCS_MMR_SET(mmr, MBCS_ALG_INT_DEST, intr_dest.intr_dest_reg);
194
195 step.alg_step_cnt = algoStepCount;
196 MBCS_MMR_SET(mmr, MBCS_ALG_STEP, step.algo_step_reg);
197}
198
199static inline int mbcs_getdma_start(struct mbcs_soft *soft)
200{
201 void *mmr_base;
202 struct getdma *gdma;
203 uint64_t numPkts;
204 union cm_control cm_control;
205
206 mmr_base = soft->mmr_base;
207 gdma = &soft->getdma;
208
209 /* check that host address got setup */
210 if (!gdma->hostAddr)
211 return -1;
212
213 numPkts =
214 (gdma->bytes + (MBCS_CACHELINE_SIZE - 1)) / MBCS_CACHELINE_SIZE;
215
216 /* program engine */
217 mbcs_getdma_set(mmr_base, tiocx_dma_addr(gdma->hostAddr),
218 gdma->localAddr,
219 (gdma->localAddr < MB2) ? 0 :
220 (gdma->localAddr < MB4) ? 1 :
221 (gdma->localAddr < MB6) ? 2 : 3,
222 numPkts,
223 gdma->DoneAmoEnable,
224 gdma->DoneIntEnable,
225 gdma->peerIO,
226 gdma->amoHostDest,
227 gdma->amoModType,
228 gdma->intrHostDest, gdma->intrVector);
229
230 /* start engine */
231 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
232 cm_control.rd_dma_go = 1;
233 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
234
235 return 0;
236
237}
238
239static inline int mbcs_putdma_start(struct mbcs_soft *soft)
240{
241 void *mmr_base;
242 struct putdma *pdma;
243 uint64_t numPkts;
244 union cm_control cm_control;
245
246 mmr_base = soft->mmr_base;
247 pdma = &soft->putdma;
248
249 /* check that host address got setup */
250 if (!pdma->hostAddr)
251 return -1;
252
253 numPkts =
254 (pdma->bytes + (MBCS_CACHELINE_SIZE - 1)) / MBCS_CACHELINE_SIZE;
255
256 /* program engine */
257 mbcs_putdma_set(mmr_base, tiocx_dma_addr(pdma->hostAddr),
258 pdma->localAddr,
259 (pdma->localAddr < MB2) ? 0 :
260 (pdma->localAddr < MB4) ? 1 :
261 (pdma->localAddr < MB6) ? 2 : 3,
262 numPkts,
263 pdma->DoneAmoEnable,
264 pdma->DoneIntEnable,
265 pdma->peerIO,
266 pdma->amoHostDest,
267 pdma->amoModType,
268 pdma->intrHostDest, pdma->intrVector);
269
270 /* start engine */
271 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
272 cm_control.wr_dma_go = 1;
273 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
274
275 return 0;
276
277}
278
279static inline int mbcs_algo_start(struct mbcs_soft *soft)
280{
281 struct algoblock *algo_soft = &soft->algo;
282 void *mmr_base = soft->mmr_base;
283 union cm_control cm_control;
284
285 if (down_interruptible(&soft->algolock))
286 return -ERESTARTSYS;
287
288 atomic_set(&soft->algo_done, 0);
289
290 mbcs_algo_set(mmr_base,
291 algo_soft->amoHostDest,
292 algo_soft->amoModType,
293 algo_soft->intrHostDest,
294 algo_soft->intrVector, algo_soft->algoStepCount);
295
296 /* start algorithm */
297 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
298 cm_control.alg_done_int_en = 1;
299 cm_control.alg_go = 1;
300 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
301
302 up(&soft->algolock);
303
304 return 0;
305}
306
307static inline ssize_t
308do_mbcs_sram_dmawrite(struct mbcs_soft *soft, uint64_t hostAddr,
309 size_t len, loff_t * off)
310{
311 int rv = 0;
312
313 if (down_interruptible(&soft->dmawritelock))
314 return -ERESTARTSYS;
315
316 atomic_set(&soft->dmawrite_done, 0);
317
318 soft->putdma.hostAddr = hostAddr;
319 soft->putdma.localAddr = *off;
320 soft->putdma.bytes = len;
321
322 if (mbcs_putdma_start(soft) < 0) {
323 DBG(KERN_ALERT "do_mbcs_sram_dmawrite: "
324 "mbcs_putdma_start failed\n");
325 rv = -EAGAIN;
326 goto dmawrite_exit;
327 }
328
329 if (wait_event_interruptible(soft->dmawrite_queue,
330 atomic_read(&soft->dmawrite_done))) {
331 rv = -ERESTARTSYS;
332 goto dmawrite_exit;
333 }
334
335 rv = len;
336 *off += len;
337
338dmawrite_exit:
339 up(&soft->dmawritelock);
340
341 return rv;
342}
343
344static inline ssize_t
345do_mbcs_sram_dmaread(struct mbcs_soft *soft, uint64_t hostAddr,
346 size_t len, loff_t * off)
347{
348 int rv = 0;
349
350 if (down_interruptible(&soft->dmareadlock))
351 return -ERESTARTSYS;
352
353 atomic_set(&soft->dmawrite_done, 0);
354
355 soft->getdma.hostAddr = hostAddr;
356 soft->getdma.localAddr = *off;
357 soft->getdma.bytes = len;
358
359 if (mbcs_getdma_start(soft) < 0) {
360 DBG(KERN_ALERT "mbcs_strategy: mbcs_getdma_start failed\n");
361 rv = -EAGAIN;
362 goto dmaread_exit;
363 }
364
365 if (wait_event_interruptible(soft->dmaread_queue,
366 atomic_read(&soft->dmaread_done))) {
367 rv = -ERESTARTSYS;
368 goto dmaread_exit;
369 }
370
371 rv = len;
372 *off += len;
373
374dmaread_exit:
375 up(&soft->dmareadlock);
376
377 return rv;
378}
379
380int mbcs_open(struct inode *ip, struct file *fp)
381{
382 struct mbcs_soft *soft;
383 int minor;
384
385 minor = iminor(ip);
386
387 list_for_each_entry(soft, &soft_list, list) {
388 if (soft->nasid == minor) {
389 fp->private_data = soft->cxdev;
390 return 0;
391 }
392 }
393
394 return -ENODEV;
395}
396
397ssize_t mbcs_sram_read(struct file * fp, char __user *buf, size_t len, loff_t * off)
398{
399 struct cx_dev *cx_dev = fp->private_data;
400 struct mbcs_soft *soft = cx_dev->soft;
401 uint64_t hostAddr;
402 int rv = 0;
403
404 hostAddr = __get_dma_pages(GFP_KERNEL, get_order(len));
405 if (hostAddr == 0)
406 return -ENOMEM;
407
408 rv = do_mbcs_sram_dmawrite(soft, hostAddr, len, off);
409 if (rv < 0)
410 goto exit;
411
412 if (copy_to_user(buf, (void *)hostAddr, len))
413 rv = -EFAULT;
414
415 exit:
416 free_pages(hostAddr, get_order(len));
417
418 return rv;
419}
420
421ssize_t
422mbcs_sram_write(struct file * fp, const char __user *buf, size_t len, loff_t * off)
423{
424 struct cx_dev *cx_dev = fp->private_data;
425 struct mbcs_soft *soft = cx_dev->soft;
426 uint64_t hostAddr;
427 int rv = 0;
428
429 hostAddr = __get_dma_pages(GFP_KERNEL, get_order(len));
430 if (hostAddr == 0)
431 return -ENOMEM;
432
433 if (copy_from_user((void *)hostAddr, buf, len)) {
434 rv = -EFAULT;
435 goto exit;
436 }
437
438 rv = do_mbcs_sram_dmaread(soft, hostAddr, len, off);
439
440 exit:
441 free_pages(hostAddr, get_order(len));
442
443 return rv;
444}
445
446loff_t mbcs_sram_llseek(struct file * filp, loff_t off, int whence)
447{
448 loff_t newpos;
449
450 switch (whence) {
451 case 0: /* SEEK_SET */
452 newpos = off;
453 break;
454
455 case 1: /* SEEK_CUR */
456 newpos = filp->f_pos + off;
457 break;
458
459 case 2: /* SEEK_END */
460 newpos = MBCS_SRAM_SIZE + off;
461 break;
462
463 default: /* can't happen */
464 return -EINVAL;
465 }
466
467 if (newpos < 0)
468 return -EINVAL;
469
470 filp->f_pos = newpos;
471
472 return newpos;
473}
474
475static uint64_t mbcs_pioaddr(struct mbcs_soft *soft, uint64_t offset)
476{
477 uint64_t mmr_base;
478
479 mmr_base = (uint64_t) (soft->mmr_base + offset);
480
481 return mmr_base;
482}
483
484static void mbcs_debug_pioaddr_set(struct mbcs_soft *soft)
485{
486 soft->debug_addr = mbcs_pioaddr(soft, MBCS_DEBUG_START);
487}
488
489static void mbcs_gscr_pioaddr_set(struct mbcs_soft *soft)
490{
491 soft->gscr_addr = mbcs_pioaddr(soft, MBCS_GSCR_START);
492}
493
494int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma)
495{
496 struct cx_dev *cx_dev = fp->private_data;
497 struct mbcs_soft *soft = cx_dev->soft;
498
499 if (vma->vm_pgoff != 0)
500 return -EINVAL;
501
502 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
503
504 /* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
505 if (remap_pfn_range(vma,
506 vma->vm_start,
507 __pa(soft->gscr_addr) >> PAGE_SHIFT,
508 PAGE_SIZE,
509 vma->vm_page_prot))
510 return -EAGAIN;
511
512 return 0;
513}
514
515/**
516 * mbcs_completion_intr_handler - Primary completion handler.
517 * @irq: irq
518 * @arg: soft struct for device
519 * @ep: regs
520 *
521 */
522static irqreturn_t
523mbcs_completion_intr_handler(int irq, void *arg, struct pt_regs *ep)
524{
525 struct mbcs_soft *soft = (struct mbcs_soft *)arg;
526 void *mmr_base;
527 union cm_status cm_status;
528 union cm_control cm_control;
529
530 mmr_base = soft->mmr_base;
531 cm_status.cm_status_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_STATUS);
532
533 if (cm_status.rd_dma_done) {
534 /* stop dma-read engine, clear status */
535 cm_control.cm_control_reg =
536 MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
537 cm_control.rd_dma_clr = 1;
538 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL,
539 cm_control.cm_control_reg);
540 atomic_set(&soft->dmaread_done, 1);
541 wake_up(&soft->dmaread_queue);
542 }
543 if (cm_status.wr_dma_done) {
544 /* stop dma-write engine, clear status */
545 cm_control.cm_control_reg =
546 MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
547 cm_control.wr_dma_clr = 1;
548 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL,
549 cm_control.cm_control_reg);
550 atomic_set(&soft->dmawrite_done, 1);
551 wake_up(&soft->dmawrite_queue);
552 }
553 if (cm_status.alg_done) {
554 /* clear status */
555 cm_control.cm_control_reg =
556 MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
557 cm_control.alg_done_clr = 1;
558 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL,
559 cm_control.cm_control_reg);
560 atomic_set(&soft->algo_done, 1);
561 wake_up(&soft->algo_queue);
562 }
563
564 return IRQ_HANDLED;
565}
566
567/**
568 * mbcs_intr_alloc - Allocate interrupts.
569 * @dev: device pointer
570 *
571 */
572static int mbcs_intr_alloc(struct cx_dev *dev)
573{
574 struct sn_irq_info *sn_irq;
575 struct mbcs_soft *soft;
576 struct getdma *getdma;
577 struct putdma *putdma;
578 struct algoblock *algo;
579
580 soft = dev->soft;
581 getdma = &soft->getdma;
582 putdma = &soft->putdma;
583 algo = &soft->algo;
584
585 soft->get_sn_irq = NULL;
586 soft->put_sn_irq = NULL;
587 soft->algo_sn_irq = NULL;
588
589 sn_irq = tiocx_irq_alloc(dev->cx_id.nasid, TIOCX_CORELET, -1, -1, -1);
590 if (sn_irq == NULL)
591 return -EAGAIN;
592 soft->get_sn_irq = sn_irq;
593 getdma->intrHostDest = sn_irq->irq_xtalkaddr;
594 getdma->intrVector = sn_irq->irq_irq;
595 if (request_irq(sn_irq->irq_irq,
596 (void *)mbcs_completion_intr_handler, SA_SHIRQ,
597 "MBCS get intr", (void *)soft)) {
598 tiocx_irq_free(soft->get_sn_irq);
599 return -EAGAIN;
600 }
601
602 sn_irq = tiocx_irq_alloc(dev->cx_id.nasid, TIOCX_CORELET, -1, -1, -1);
603 if (sn_irq == NULL) {
604 free_irq(soft->get_sn_irq->irq_irq, soft);
605 tiocx_irq_free(soft->get_sn_irq);
606 return -EAGAIN;
607 }
608 soft->put_sn_irq = sn_irq;
609 putdma->intrHostDest = sn_irq->irq_xtalkaddr;
610 putdma->intrVector = sn_irq->irq_irq;
611 if (request_irq(sn_irq->irq_irq,
612 (void *)mbcs_completion_intr_handler, SA_SHIRQ,
613 "MBCS put intr", (void *)soft)) {
614 tiocx_irq_free(soft->put_sn_irq);
615 free_irq(soft->get_sn_irq->irq_irq, soft);
616 tiocx_irq_free(soft->get_sn_irq);
617 return -EAGAIN;
618 }
619
620 sn_irq = tiocx_irq_alloc(dev->cx_id.nasid, TIOCX_CORELET, -1, -1, -1);
621 if (sn_irq == NULL) {
622 free_irq(soft->put_sn_irq->irq_irq, soft);
623 tiocx_irq_free(soft->put_sn_irq);
624 free_irq(soft->get_sn_irq->irq_irq, soft);
625 tiocx_irq_free(soft->get_sn_irq);
626 return -EAGAIN;
627 }
628 soft->algo_sn_irq = sn_irq;
629 algo->intrHostDest = sn_irq->irq_xtalkaddr;
630 algo->intrVector = sn_irq->irq_irq;
631 if (request_irq(sn_irq->irq_irq,
632 (void *)mbcs_completion_intr_handler, SA_SHIRQ,
633 "MBCS algo intr", (void *)soft)) {
634 tiocx_irq_free(soft->algo_sn_irq);
635 free_irq(soft->put_sn_irq->irq_irq, soft);
636 tiocx_irq_free(soft->put_sn_irq);
637 free_irq(soft->get_sn_irq->irq_irq, soft);
638 tiocx_irq_free(soft->get_sn_irq);
639 return -EAGAIN;
640 }
641
642 return 0;
643}
644
645/**
646 * mbcs_intr_dealloc - Remove interrupts.
647 * @dev: device pointer
648 *
649 */
650static void mbcs_intr_dealloc(struct cx_dev *dev)
651{
652 struct mbcs_soft *soft;
653
654 soft = dev->soft;
655
656 free_irq(soft->get_sn_irq->irq_irq, soft);
657 tiocx_irq_free(soft->get_sn_irq);
658 free_irq(soft->put_sn_irq->irq_irq, soft);
659 tiocx_irq_free(soft->put_sn_irq);
660 free_irq(soft->algo_sn_irq->irq_irq, soft);
661 tiocx_irq_free(soft->algo_sn_irq);
662}
663
664static inline int mbcs_hw_init(struct mbcs_soft *soft)
665{
666 void *mmr_base = soft->mmr_base;
667 union cm_control cm_control;
668 union cm_req_timeout cm_req_timeout;
669 uint64_t err_stat;
670
671 cm_req_timeout.cm_req_timeout_reg =
672 MBCS_MMR_GET(mmr_base, MBCS_CM_REQ_TOUT);
673
674 cm_req_timeout.time_out = MBCS_CM_CONTROL_REQ_TOUT_MASK;
675 MBCS_MMR_SET(mmr_base, MBCS_CM_REQ_TOUT,
676 cm_req_timeout.cm_req_timeout_reg);
677
678 mbcs_gscr_pioaddr_set(soft);
679 mbcs_debug_pioaddr_set(soft);
680
681 /* clear errors */
682 err_stat = MBCS_MMR_GET(mmr_base, MBCS_CM_ERR_STAT);
683 MBCS_MMR_SET(mmr_base, MBCS_CM_CLR_ERR_STAT, err_stat);
684 MBCS_MMR_ZERO(mmr_base, MBCS_CM_ERROR_DETAIL1);
685
686 /* enable interrupts */
687 /* turn off 2^23 (INT_EN_PIO_REQ_ADDR_INV) */
688 MBCS_MMR_SET(mmr_base, MBCS_CM_ERR_INT_EN, 0x3ffffff7e00ffUL);
689
690 /* arm status regs and clear engines */
691 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
692 cm_control.rearm_stat_regs = 1;
693 cm_control.alg_clr = 1;
694 cm_control.wr_dma_clr = 1;
695 cm_control.rd_dma_clr = 1;
696
697 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
698
699 return 0;
700}
701
702static ssize_t show_algo(struct device *dev, char *buf)
703{
704 struct cx_dev *cx_dev = to_cx_dev(dev);
705 struct mbcs_soft *soft = cx_dev->soft;
706 uint64_t debug0;
707
708 /*
709 * By convention, the first debug register contains the
710 * algorithm number and revision.
711 */
712 debug0 = *(uint64_t *) soft->debug_addr;
713
714 return sprintf(buf, "0x%lx 0x%lx\n",
715 (debug0 >> 32), (debug0 & 0xffffffff));
716}
717
718static ssize_t store_algo(struct device *dev, const char *buf, size_t count)
719{
720 int n;
721 struct cx_dev *cx_dev = to_cx_dev(dev);
722 struct mbcs_soft *soft = cx_dev->soft;
723
724 if (count <= 0)
725 return 0;
726
727 n = simple_strtoul(buf, NULL, 0);
728
729 if (n == 1) {
730 mbcs_algo_start(soft);
731 if (wait_event_interruptible(soft->algo_queue,
732 atomic_read(&soft->algo_done)))
733 return -ERESTARTSYS;
734 }
735
736 return count;
737}
738
739DEVICE_ATTR(algo, 0644, show_algo, store_algo);
740
741/**
742 * mbcs_probe - Initialize for device
743 * @dev: device pointer
744 * @device_id: id table pointer
745 *
746 */
747static int mbcs_probe(struct cx_dev *dev, const struct cx_device_id *id)
748{
749 struct mbcs_soft *soft;
750
751 dev->soft = NULL;
752
753 soft = kcalloc(1, sizeof(struct mbcs_soft), GFP_KERNEL);
754 if (soft == NULL)
755 return -ENOMEM;
756
757 soft->nasid = dev->cx_id.nasid;
758 list_add(&soft->list, &soft_list);
759 soft->mmr_base = (void *)tiocx_swin_base(dev->cx_id.nasid);
760 dev->soft = soft;
761 soft->cxdev = dev;
762
763 init_waitqueue_head(&soft->dmawrite_queue);
764 init_waitqueue_head(&soft->dmaread_queue);
765 init_waitqueue_head(&soft->algo_queue);
766
767 init_MUTEX(&soft->dmawritelock);
768 init_MUTEX(&soft->dmareadlock);
769 init_MUTEX(&soft->algolock);
770
771 mbcs_getdma_init(&soft->getdma);
772 mbcs_putdma_init(&soft->putdma);
773 mbcs_algo_init(&soft->algo);
774
775 mbcs_hw_init(soft);
776
777 /* Allocate interrupts */
778 mbcs_intr_alloc(dev);
779
780 device_create_file(&dev->dev, &dev_attr_algo);
781
782 return 0;
783}
784
785static int mbcs_remove(struct cx_dev *dev)
786{
787 if (dev->soft) {
788 mbcs_intr_dealloc(dev);
789 kfree(dev->soft);
790 }
791
792 device_remove_file(&dev->dev, &dev_attr_algo);
793
794 return 0;
795}
796
797const struct cx_device_id __devinitdata mbcs_id_table[] = {
798 {
799 .part_num = MBCS_PART_NUM,
800 .mfg_num = MBCS_MFG_NUM,
801 },
802 {
803 .part_num = MBCS_PART_NUM_ALG0,
804 .mfg_num = MBCS_MFG_NUM,
805 },
806 {0, 0}
807};
808
809MODULE_DEVICE_TABLE(cx, mbcs_id_table);
810
811struct cx_drv mbcs_driver = {
812 .name = DEVICE_NAME,
813 .id_table = mbcs_id_table,
814 .probe = mbcs_probe,
815 .remove = mbcs_remove,
816};
817
818static void __exit mbcs_exit(void)
819{
820 int rv;
821
822 rv = unregister_chrdev(mbcs_major, DEVICE_NAME);
823 if (rv < 0)
824 DBG(KERN_ALERT "Error in unregister_chrdev: %d\n", rv);
825
826 cx_driver_unregister(&mbcs_driver);
827}
828
829static int __init mbcs_init(void)
830{
831 int rv;
832
833 // Put driver into chrdevs[]. Get major number.
834 rv = register_chrdev(mbcs_major, DEVICE_NAME, &mbcs_ops);
835 if (rv < 0) {
836 DBG(KERN_ALERT "mbcs_init: can't get major number. %d\n", rv);
837 return rv;
838 }
839 mbcs_major = rv;
840
841 return cx_driver_register(&mbcs_driver);
842}
843
844module_init(mbcs_init);
845module_exit(mbcs_exit);
846
847MODULE_AUTHOR("Bruce Losure <blosure@sgi.com>");
848MODULE_DESCRIPTION("Driver for MOATB Core Services");
849MODULE_LICENSE("GPL");
diff --git a/drivers/char/mbcs.h b/drivers/char/mbcs.h
new file mode 100644
index 000000000000..e7fd47e43257
--- /dev/null
+++ b/drivers/char/mbcs.h
@@ -0,0 +1,553 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#ifndef __MBCS_H__
10#define __MBCS_H__
11
12/*
13 * General macros
14 */
15#define MB (1024*1024)
16#define MB2 (2*MB)
17#define MB4 (4*MB)
18#define MB6 (6*MB)
19
20/*
21 * Offsets and masks
22 */
23#define MBCS_CM_ID 0x0000 /* Identification */
24#define MBCS_CM_STATUS 0x0008 /* Status */
25#define MBCS_CM_ERROR_DETAIL1 0x0010 /* Error Detail1 */
26#define MBCS_CM_ERROR_DETAIL2 0x0018 /* Error Detail2 */
27#define MBCS_CM_CONTROL 0x0020 /* Control */
28#define MBCS_CM_REQ_TOUT 0x0028 /* Request Time-out */
29#define MBCS_CM_ERR_INT_DEST 0x0038 /* Error Interrupt Destination */
30#define MBCS_CM_TARG_FL 0x0050 /* Target Flush */
31#define MBCS_CM_ERR_STAT 0x0060 /* Error Status */
32#define MBCS_CM_CLR_ERR_STAT 0x0068 /* Clear Error Status */
33#define MBCS_CM_ERR_INT_EN 0x0070 /* Error Interrupt Enable */
34#define MBCS_RD_DMA_SYS_ADDR 0x0100 /* Read DMA System Address */
35#define MBCS_RD_DMA_LOC_ADDR 0x0108 /* Read DMA Local Address */
36#define MBCS_RD_DMA_CTRL 0x0110 /* Read DMA Control */
37#define MBCS_RD_DMA_AMO_DEST 0x0118 /* Read DMA AMO Destination */
38#define MBCS_RD_DMA_INT_DEST 0x0120 /* Read DMA Interrupt Destination */
39#define MBCS_RD_DMA_AUX_STAT 0x0130 /* Read DMA Auxillary Status */
40#define MBCS_WR_DMA_SYS_ADDR 0x0200 /* Write DMA System Address */
41#define MBCS_WR_DMA_LOC_ADDR 0x0208 /* Write DMA Local Address */
42#define MBCS_WR_DMA_CTRL 0x0210 /* Write DMA Control */
43#define MBCS_WR_DMA_AMO_DEST 0x0218 /* Write DMA AMO Destination */
44#define MBCS_WR_DMA_INT_DEST 0x0220 /* Write DMA Interrupt Destination */
45#define MBCS_WR_DMA_AUX_STAT 0x0230 /* Write DMA Auxillary Status */
46#define MBCS_ALG_AMO_DEST 0x0300 /* Algorithm AMO Destination */
47#define MBCS_ALG_INT_DEST 0x0308 /* Algorithm Interrupt Destination */
48#define MBCS_ALG_OFFSETS 0x0310
49#define MBCS_ALG_STEP 0x0318 /* Algorithm Step */
50
51#define MBCS_GSCR_START 0x0000000
52#define MBCS_DEBUG_START 0x0100000
53#define MBCS_RAM0_START 0x0200000
54#define MBCS_RAM1_START 0x0400000
55#define MBCS_RAM2_START 0x0600000
56
57#define MBCS_CM_CONTROL_REQ_TOUT_MASK 0x0000000000ffffffUL
58//#define PIO_BASE_ADDR_BASE_OFFSET_MASK 0x00fffffffff00000UL
59
60#define MBCS_SRAM_SIZE (1024*1024)
61#define MBCS_CACHELINE_SIZE 128
62
63/*
64 * MMR get's and put's
65 */
66#define MBCS_MMR_ADDR(mmr_base, offset)((uint64_t *)(mmr_base + offset))
67#define MBCS_MMR_SET(mmr_base, offset, value) { \
68 uint64_t *mbcs_mmr_set_u64p, readback; \
69 mbcs_mmr_set_u64p = (uint64_t *)(mmr_base + offset); \
70 *mbcs_mmr_set_u64p = value; \
71 readback = *mbcs_mmr_set_u64p; \
72}
73#define MBCS_MMR_GET(mmr_base, offset) *(uint64_t *)(mmr_base + offset)
74#define MBCS_MMR_ZERO(mmr_base, offset) MBCS_MMR_SET(mmr_base, offset, 0)
75
76/*
77 * MBCS mmr structures
78 */
79union cm_id {
80 uint64_t cm_id_reg;
81 struct {
82 uint64_t always_one:1, // 0
83 mfg_id:11, // 11:1
84 part_num:16, // 27:12
85 bitstream_rev:8, // 35:28
86 :28; // 63:36
87 };
88};
89
90union cm_status {
91 uint64_t cm_status_reg;
92 struct {
93 uint64_t pending_reads:8, // 7:0
94 pending_writes:8, // 15:8
95 ice_rsp_credits:8, // 23:16
96 ice_req_credits:8, // 31:24
97 cm_req_credits:8, // 39:32
98 :1, // 40
99 rd_dma_in_progress:1, // 41
100 rd_dma_done:1, // 42
101 :1, // 43
102 wr_dma_in_progress:1, // 44
103 wr_dma_done:1, // 45
104 alg_waiting:1, // 46
105 alg_pipe_running:1, // 47
106 alg_done:1, // 48
107 :3, // 51:49
108 pending_int_reqs:8, // 59:52
109 :3, // 62:60
110 alg_half_speed_sel:1; // 63
111 };
112};
113
114union cm_error_detail1 {
115 uint64_t cm_error_detail1_reg;
116 struct {
117 uint64_t packet_type:4, // 3:0
118 source_id:2, // 5:4
119 data_size:2, // 7:6
120 tnum:8, // 15:8
121 byte_enable:8, // 23:16
122 gfx_cred:8, // 31:24
123 read_type:2, // 33:32
124 pio_or_memory:1, // 34
125 head_cw_error:1, // 35
126 :12, // 47:36
127 head_error_bit:1, // 48
128 data_error_bit:1, // 49
129 :13, // 62:50
130 valid:1; // 63
131 };
132};
133
134union cm_error_detail2 {
135 uint64_t cm_error_detail2_reg;
136 struct {
137 uint64_t address:56, // 55:0
138 :8; // 63:56
139 };
140};
141
142union cm_control {
143 uint64_t cm_control_reg;
144 struct {
145 uint64_t cm_id:2, // 1:0
146 :2, // 3:2
147 max_trans:5, // 8:4
148 :3, // 11:9
149 address_mode:1, // 12
150 :7, // 19:13
151 credit_limit:8, // 27:20
152 :5, // 32:28
153 rearm_stat_regs:1, // 33
154 prescalar_byp:1, // 34
155 force_gap_war:1, // 35
156 rd_dma_go:1, // 36
157 wr_dma_go:1, // 37
158 alg_go:1, // 38
159 rd_dma_clr:1, // 39
160 wr_dma_clr:1, // 40
161 alg_clr:1, // 41
162 :2, // 43:42
163 alg_wait_step:1, // 44
164 alg_done_amo_en:1, // 45
165 alg_done_int_en:1, // 46
166 :1, // 47
167 alg_sram0_locked:1, // 48
168 alg_sram1_locked:1, // 49
169 alg_sram2_locked:1, // 50
170 alg_done_clr:1, // 51
171 :12; // 63:52
172 };
173};
174
175union cm_req_timeout {
176 uint64_t cm_req_timeout_reg;
177 struct {
178 uint64_t time_out:24, // 23:0
179 :40; // 63:24
180 };
181};
182
183union intr_dest {
184 uint64_t intr_dest_reg;
185 struct {
186 uint64_t address:56, // 55:0
187 int_vector:8; // 63:56
188 };
189};
190
191union cm_error_status {
192 uint64_t cm_error_status_reg;
193 struct {
194 uint64_t ecc_sbe:1, // 0
195 ecc_mbe:1, // 1
196 unsupported_req:1, // 2
197 unexpected_rsp:1, // 3
198 bad_length:1, // 4
199 bad_datavalid:1, // 5
200 buffer_overflow:1, // 6
201 request_timeout:1, // 7
202 :8, // 15:8
203 head_inv_data_size:1, // 16
204 rsp_pactype_inv:1, // 17
205 head_sb_err:1, // 18
206 missing_head:1, // 19
207 head_inv_rd_type:1, // 20
208 head_cmd_err_bit:1, // 21
209 req_addr_align_inv:1, // 22
210 pio_req_addr_inv:1, // 23
211 req_range_dsize_inv:1, // 24
212 early_term:1, // 25
213 early_tail:1, // 26
214 missing_tail:1, // 27
215 data_flit_sb_err:1, // 28
216 cm2hcm_req_cred_of:1, // 29
217 cm2hcm_rsp_cred_of:1, // 30
218 rx_bad_didn:1, // 31
219 rd_dma_err_rsp:1, // 32
220 rd_dma_tnum_tout:1, // 33
221 rd_dma_multi_tnum_tou:1, // 34
222 wr_dma_err_rsp:1, // 35
223 wr_dma_tnum_tout:1, // 36
224 wr_dma_multi_tnum_tou:1, // 37
225 alg_data_overflow:1, // 38
226 alg_data_underflow:1, // 39
227 ram0_access_conflict:1, // 40
228 ram1_access_conflict:1, // 41
229 ram2_access_conflict:1, // 42
230 ram0_perr:1, // 43
231 ram1_perr:1, // 44
232 ram2_perr:1, // 45
233 int_gen_rsp_err:1, // 46
234 int_gen_tnum_tout:1, // 47
235 rd_dma_prog_err:1, // 48
236 wr_dma_prog_err:1, // 49
237 :14; // 63:50
238 };
239};
240
241union cm_clr_error_status {
242 uint64_t cm_clr_error_status_reg;
243 struct {
244 uint64_t clr_ecc_sbe:1, // 0
245 clr_ecc_mbe:1, // 1
246 clr_unsupported_req:1, // 2
247 clr_unexpected_rsp:1, // 3
248 clr_bad_length:1, // 4
249 clr_bad_datavalid:1, // 5
250 clr_buffer_overflow:1, // 6
251 clr_request_timeout:1, // 7
252 :8, // 15:8
253 clr_head_inv_data_siz:1, // 16
254 clr_rsp_pactype_inv:1, // 17
255 clr_head_sb_err:1, // 18
256 clr_missing_head:1, // 19
257 clr_head_inv_rd_type:1, // 20
258 clr_head_cmd_err_bit:1, // 21
259 clr_req_addr_align_in:1, // 22
260 clr_pio_req_addr_inv:1, // 23
261 clr_req_range_dsize_i:1, // 24
262 clr_early_term:1, // 25
263 clr_early_tail:1, // 26
264 clr_missing_tail:1, // 27
265 clr_data_flit_sb_err:1, // 28
266 clr_cm2hcm_req_cred_o:1, // 29
267 clr_cm2hcm_rsp_cred_o:1, // 30
268 clr_rx_bad_didn:1, // 31
269 clr_rd_dma_err_rsp:1, // 32
270 clr_rd_dma_tnum_tout:1, // 33
271 clr_rd_dma_multi_tnum:1, // 34
272 clr_wr_dma_err_rsp:1, // 35
273 clr_wr_dma_tnum_tout:1, // 36
274 clr_wr_dma_multi_tnum:1, // 37
275 clr_alg_data_overflow:1, // 38
276 clr_alg_data_underflo:1, // 39
277 clr_ram0_access_confl:1, // 40
278 clr_ram1_access_confl:1, // 41
279 clr_ram2_access_confl:1, // 42
280 clr_ram0_perr:1, // 43
281 clr_ram1_perr:1, // 44
282 clr_ram2_perr:1, // 45
283 clr_int_gen_rsp_err:1, // 46
284 clr_int_gen_tnum_tout:1, // 47
285 clr_rd_dma_prog_err:1, // 48
286 clr_wr_dma_prog_err:1, // 49
287 :14; // 63:50
288 };
289};
290
291union cm_error_intr_enable {
292 uint64_t cm_error_intr_enable_reg;
293 struct {
294 uint64_t int_en_ecc_sbe:1, // 0
295 int_en_ecc_mbe:1, // 1
296 int_en_unsupported_re:1, // 2
297 int_en_unexpected_rsp:1, // 3
298 int_en_bad_length:1, // 4
299 int_en_bad_datavalid:1, // 5
300 int_en_buffer_overflo:1, // 6
301 int_en_request_timeou:1, // 7
302 :8, // 15:8
303 int_en_head_inv_data_:1, // 16
304 int_en_rsp_pactype_in:1, // 17
305 int_en_head_sb_err:1, // 18
306 int_en_missing_head:1, // 19
307 int_en_head_inv_rd_ty:1, // 20
308 int_en_head_cmd_err_b:1, // 21
309 int_en_req_addr_align:1, // 22
310 int_en_pio_req_addr_i:1, // 23
311 int_en_req_range_dsiz:1, // 24
312 int_en_early_term:1, // 25
313 int_en_early_tail:1, // 26
314 int_en_missing_tail:1, // 27
315 int_en_data_flit_sb_e:1, // 28
316 int_en_cm2hcm_req_cre:1, // 29
317 int_en_cm2hcm_rsp_cre:1, // 30
318 int_en_rx_bad_didn:1, // 31
319 int_en_rd_dma_err_rsp:1, // 32
320 int_en_rd_dma_tnum_to:1, // 33
321 int_en_rd_dma_multi_t:1, // 34
322 int_en_wr_dma_err_rsp:1, // 35
323 int_en_wr_dma_tnum_to:1, // 36
324 int_en_wr_dma_multi_t:1, // 37
325 int_en_alg_data_overf:1, // 38
326 int_en_alg_data_under:1, // 39
327 int_en_ram0_access_co:1, // 40
328 int_en_ram1_access_co:1, // 41
329 int_en_ram2_access_co:1, // 42
330 int_en_ram0_perr:1, // 43
331 int_en_ram1_perr:1, // 44
332 int_en_ram2_perr:1, // 45
333 int_en_int_gen_rsp_er:1, // 46
334 int_en_int_gen_tnum_t:1, // 47
335 int_en_rd_dma_prog_er:1, // 48
336 int_en_wr_dma_prog_er:1, // 49
337 :14; // 63:50
338 };
339};
340
341struct cm_mmr {
342 union cm_id id;
343 union cm_status status;
344 union cm_error_detail1 err_detail1;
345 union cm_error_detail2 err_detail2;
346 union cm_control control;
347 union cm_req_timeout req_timeout;
348 uint64_t reserved1[1];
349 union intr_dest int_dest;
350 uint64_t reserved2[2];
351 uint64_t targ_flush;
352 uint64_t reserved3[1];
353 union cm_error_status err_status;
354 union cm_clr_error_status clr_err_status;
355 union cm_error_intr_enable int_enable;
356};
357
358union dma_hostaddr {
359 uint64_t dma_hostaddr_reg;
360 struct {
361 uint64_t dma_sys_addr:56, // 55:0
362 :8; // 63:56
363 };
364};
365
366union dma_localaddr {
367 uint64_t dma_localaddr_reg;
368 struct {
369 uint64_t dma_ram_addr:21, // 20:0
370 dma_ram_sel:2, // 22:21
371 :41; // 63:23
372 };
373};
374
375union dma_control {
376 uint64_t dma_control_reg;
377 struct {
378 uint64_t dma_op_length:16, // 15:0
379 :18, // 33:16
380 done_amo_en:1, // 34
381 done_int_en:1, // 35
382 :1, // 36
383 pio_mem_n:1, // 37
384 :26; // 63:38
385 };
386};
387
388union dma_amo_dest {
389 uint64_t dma_amo_dest_reg;
390 struct {
391 uint64_t dma_amo_sys_addr:56, // 55:0
392 dma_amo_mod_type:3, // 58:56
393 :5; // 63:59
394 };
395};
396
397union rdma_aux_status {
398 uint64_t rdma_aux_status_reg;
399 struct {
400 uint64_t op_num_pacs_left:17, // 16:0
401 :5, // 21:17
402 lrsp_buff_empty:1, // 22
403 :17, // 39:23
404 pending_reqs_left:6, // 45:40
405 :18; // 63:46
406 };
407};
408
409struct rdma_mmr {
410 union dma_hostaddr host_addr;
411 union dma_localaddr local_addr;
412 union dma_control control;
413 union dma_amo_dest amo_dest;
414 union intr_dest intr_dest;
415 union rdma_aux_status aux_status;
416};
417
418union wdma_aux_status {
419 uint64_t wdma_aux_status_reg;
420 struct {
421 uint64_t op_num_pacs_left:17, // 16:0
422 :4, // 20:17
423 lreq_buff_empty:1, // 21
424 :18, // 39:22
425 pending_reqs_left:6, // 45:40
426 :18; // 63:46
427 };
428};
429
430struct wdma_mmr {
431 union dma_hostaddr host_addr;
432 union dma_localaddr local_addr;
433 union dma_control control;
434 union dma_amo_dest amo_dest;
435 union intr_dest intr_dest;
436 union wdma_aux_status aux_status;
437};
438
439union algo_step {
440 uint64_t algo_step_reg;
441 struct {
442 uint64_t alg_step_cnt:16, // 15:0
443 :48; // 63:16
444 };
445};
446
447struct algo_mmr {
448 union dma_amo_dest amo_dest;
449 union intr_dest intr_dest;
450 union {
451 uint64_t algo_offset_reg;
452 struct {
453 uint64_t sram0_offset:7, // 6:0
454 reserved0:1, // 7
455 sram1_offset:7, // 14:8
456 reserved1:1, // 15
457 sram2_offset:7, // 22:16
458 reserved2:14; // 63:23
459 };
460 } sram_offset;
461 union algo_step step;
462};
463
464struct mbcs_mmr {
465 struct cm_mmr cm;
466 uint64_t reserved1[17];
467 struct rdma_mmr rdDma;
468 uint64_t reserved2[25];
469 struct wdma_mmr wrDma;
470 uint64_t reserved3[25];
471 struct algo_mmr algo;
472 uint64_t reserved4[156];
473};
474
475/*
476 * defines
477 */
478#define DEVICE_NAME "mbcs"
479#define MBCS_PART_NUM 0xfff0
480#define MBCS_PART_NUM_ALG0 0xf001
481#define MBCS_MFG_NUM 0x1
482
483struct algoblock {
484 uint64_t amoHostDest;
485 uint64_t amoModType;
486 uint64_t intrHostDest;
487 uint64_t intrVector;
488 uint64_t algoStepCount;
489};
490
491struct getdma {
492 uint64_t hostAddr;
493 uint64_t localAddr;
494 uint64_t bytes;
495 uint64_t DoneAmoEnable;
496 uint64_t DoneIntEnable;
497 uint64_t peerIO;
498 uint64_t amoHostDest;
499 uint64_t amoModType;
500 uint64_t intrHostDest;
501 uint64_t intrVector;
502};
503
504struct putdma {
505 uint64_t hostAddr;
506 uint64_t localAddr;
507 uint64_t bytes;
508 uint64_t DoneAmoEnable;
509 uint64_t DoneIntEnable;
510 uint64_t peerIO;
511 uint64_t amoHostDest;
512 uint64_t amoModType;
513 uint64_t intrHostDest;
514 uint64_t intrVector;
515};
516
517struct mbcs_soft {
518 struct list_head list;
519 struct cx_dev *cxdev;
520 int major;
521 int nasid;
522 void *mmr_base;
523 wait_queue_head_t dmawrite_queue;
524 wait_queue_head_t dmaread_queue;
525 wait_queue_head_t algo_queue;
526 struct sn_irq_info *get_sn_irq;
527 struct sn_irq_info *put_sn_irq;
528 struct sn_irq_info *algo_sn_irq;
529 struct getdma getdma;
530 struct putdma putdma;
531 struct algoblock algo;
532 uint64_t gscr_addr; // pio addr
533 uint64_t ram0_addr; // pio addr
534 uint64_t ram1_addr; // pio addr
535 uint64_t ram2_addr; // pio addr
536 uint64_t debug_addr; // pio addr
537 atomic_t dmawrite_done;
538 atomic_t dmaread_done;
539 atomic_t algo_done;
540 struct semaphore dmawritelock;
541 struct semaphore dmareadlock;
542 struct semaphore algolock;
543};
544
545extern int mbcs_open(struct inode *ip, struct file *fp);
546extern ssize_t mbcs_sram_read(struct file *fp, char __user *buf, size_t len,
547 loff_t * off);
548extern ssize_t mbcs_sram_write(struct file *fp, const char __user *buf, size_t len,
549 loff_t * off);
550extern loff_t mbcs_sram_llseek(struct file *filp, loff_t off, int whence);
551extern int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma);
552
553#endif // __MBCS_H__
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index a91ae271cf0a..763893e289b3 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -221,7 +221,7 @@ static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000};
221/* Set the mask to all-ones. This alas, only supports 32 interrupts. 221/* Set the mask to all-ones. This alas, only supports 32 interrupts.
222 Some architectures may need more. -- Changed to LONG to 222 Some architectures may need more. -- Changed to LONG to
223 support up to 64 bits on 64bit architectures. -- REW 20/06/99 */ 223 support up to 64 bits on 64bit architectures. -- REW 20/06/99 */
224long rio_irqmask = -1; 224static long rio_irqmask = -1;
225 225
226MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>"); 226MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>");
227MODULE_DESCRIPTION("RIO driver"); 227MODULE_DESCRIPTION("RIO driver");
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
index 8e61be34a1d3..ed867db550a9 100644
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -116,7 +116,7 @@ static void s3c2410_rtc_setfreq(int freq)
116 116
117/* Time read/write */ 117/* Time read/write */
118 118
119static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm) 119static int s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
120{ 120{
121 unsigned int have_retried = 0; 121 unsigned int have_retried = 0;
122 122
@@ -151,6 +151,8 @@ static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
151 151
152 rtc_tm->tm_year += 100; 152 rtc_tm->tm_year += 100;
153 rtc_tm->tm_mon -= 1; 153 rtc_tm->tm_mon -= 1;
154
155 return 0;
154} 156}
155 157
156 158
@@ -171,7 +173,7 @@ static int s3c2410_rtc_settime(struct rtc_time *tm)
171 return 0; 173 return 0;
172} 174}
173 175
174static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) 176static int s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
175{ 177{
176 struct rtc_time *alm_tm = &alrm->time; 178 struct rtc_time *alm_tm = &alrm->time;
177 unsigned int alm_en; 179 unsigned int alm_en;
@@ -231,6 +233,8 @@ static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
231 } 233 }
232 234
233 /* todo - set alrm->enabled ? */ 235 /* todo - set alrm->enabled ? */
236
237 return 0;
234} 238}
235 239
236static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm) 240static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index ffb9143376bb..e3c0b52d943f 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -374,6 +374,7 @@ scdrv_init(void)
374 void *salbuf; 374 void *salbuf;
375 struct class_simple *snsc_class; 375 struct class_simple *snsc_class;
376 dev_t first_dev, dev; 376 dev_t first_dev, dev;
377 nasid_t event_nasid = ia64_sn_get_console_nasid();
377 378
378 if (alloc_chrdev_region(&first_dev, 0, numionodes, 379 if (alloc_chrdev_region(&first_dev, 0, numionodes,
379 SYSCTL_BASENAME) < 0) { 380 SYSCTL_BASENAME) < 0) {
@@ -441,6 +442,13 @@ scdrv_init(void)
441 ia64_sn_irtr_intr_enable(scd->scd_nasid, 442 ia64_sn_irtr_intr_enable(scd->scd_nasid,
442 0 /*ignored */ , 443 0 /*ignored */ ,
443 SAL_IROUTER_INTR_RECV); 444 SAL_IROUTER_INTR_RECV);
445
446 /* on the console nasid, prepare to receive
447 * system controller environmental events
448 */
449 if(scd->scd_nasid == event_nasid) {
450 scdrv_event_init(scd);
451 }
444 } 452 }
445 return 0; 453 return 0;
446} 454}
diff --git a/drivers/char/snsc.h b/drivers/char/snsc.h
index c22c6c55e254..a9efc13cc858 100644
--- a/drivers/char/snsc.h
+++ b/drivers/char/snsc.h
@@ -47,4 +47,44 @@ struct sysctl_data_s {
47 nasid_t scd_nasid; /* Node on which subchannels are opened. */ 47 nasid_t scd_nasid; /* Node on which subchannels are opened. */
48}; 48};
49 49
50
51/* argument types */
52#define IR_ARG_INT 0x00 /* 4-byte integer (big-endian) */
53#define IR_ARG_ASCII 0x01 /* null-terminated ASCII string */
54#define IR_ARG_UNKNOWN 0x80 /* unknown data type. The low
55 * 7 bits will contain the data
56 * length. */
57#define IR_ARG_UNKNOWN_LENGTH_MASK 0x7f
58
59
60/* system controller event codes */
61#define EV_CLASS_MASK 0xf000ul
62#define EV_SEVERITY_MASK 0x0f00ul
63#define EV_COMPONENT_MASK 0x00fful
64
65#define EV_CLASS_POWER 0x1000ul
66#define EV_CLASS_FAN 0x2000ul
67#define EV_CLASS_TEMP 0x3000ul
68#define EV_CLASS_ENV 0x4000ul
69#define EV_CLASS_TEST_FAULT 0x5000ul
70#define EV_CLASS_TEST_WARNING 0x6000ul
71#define EV_CLASS_PWRD_NOTIFY 0x8000ul
72
73#define EV_SEVERITY_POWER_STABLE 0x0000ul
74#define EV_SEVERITY_POWER_LOW_WARNING 0x0100ul
75#define EV_SEVERITY_POWER_HIGH_WARNING 0x0200ul
76#define EV_SEVERITY_POWER_HIGH_FAULT 0x0300ul
77#define EV_SEVERITY_POWER_LOW_FAULT 0x0400ul
78
79#define EV_SEVERITY_FAN_STABLE 0x0000ul
80#define EV_SEVERITY_FAN_WARNING 0x0100ul
81#define EV_SEVERITY_FAN_FAULT 0x0200ul
82
83#define EV_SEVERITY_TEMP_STABLE 0x0000ul
84#define EV_SEVERITY_TEMP_ADVISORY 0x0100ul
85#define EV_SEVERITY_TEMP_CRITICAL 0x0200ul
86#define EV_SEVERITY_TEMP_FAULT 0x0300ul
87
88void scdrv_event_init(struct sysctl_data_s *);
89
50#endif /* _SN_SYSCTL_H_ */ 90#endif /* _SN_SYSCTL_H_ */
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
new file mode 100644
index 000000000000..d692af57213a
--- /dev/null
+++ b/drivers/char/snsc_event.c
@@ -0,0 +1,304 @@
1/*
2 * SN Platform system controller communication support
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
9 */
10
11/*
12 * System controller event handler
13 *
14 * These routines deal with environmental events arriving from the
15 * system controllers.
16 */
17
18#include <linux/interrupt.h>
19#include <linux/sched.h>
20#include <linux/byteorder/generic.h>
21#include <asm/sn/sn_sal.h>
22#include "snsc.h"
23
24static struct subch_data_s *event_sd;
25
26void scdrv_event(unsigned long);
27DECLARE_TASKLET(sn_sysctl_event, scdrv_event, 0);
28
29/*
30 * scdrv_event_interrupt
31 *
32 * Pull incoming environmental events off the physical link to the
33 * system controller and put them in a temporary holding area in SAL.
34 * Schedule scdrv_event() to move them along to their ultimate
35 * destination.
36 */
37static irqreturn_t
38scdrv_event_interrupt(int irq, void *subch_data, struct pt_regs *regs)
39{
40 struct subch_data_s *sd = subch_data;
41 unsigned long flags;
42 int status;
43
44 spin_lock_irqsave(&sd->sd_rlock, flags);
45 status = ia64_sn_irtr_intr(sd->sd_nasid, sd->sd_subch);
46
47 if ((status > 0) && (status & SAL_IROUTER_INTR_RECV)) {
48 tasklet_schedule(&sn_sysctl_event);
49 }
50 spin_unlock_irqrestore(&sd->sd_rlock, flags);
51 return IRQ_HANDLED;
52}
53
54
55/*
56 * scdrv_parse_event
57 *
58 * Break an event (as read from SAL) into useful pieces so we can decide
59 * what to do with it.
60 */
61static int
62scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc)
63{
64 char *desc_end;
65
66 /* record event source address */
67 *src = be32_to_cpup((__be32 *)event);
68 event += 4; /* move on to event code */
69
70 /* record the system controller's event code */
71 *code = be32_to_cpup((__be32 *)event);
72 event += 4; /* move on to event arguments */
73
74 /* how many arguments are in the packet? */
75 if (*event++ != 2) {
76 /* if not 2, give up */
77 return -1;
78 }
79
80 /* parse out the ESP code */
81 if (*event++ != IR_ARG_INT) {
82 /* not an integer argument, so give up */
83 return -1;
84 }
85 *esp_code = be32_to_cpup((__be32 *)event);
86 event += 4;
87
88 /* parse out the event description */
89 if (*event++ != IR_ARG_ASCII) {
90 /* not an ASCII string, so give up */
91 return -1;
92 }
93 event[CHUNKSIZE-1] = '\0'; /* ensure this string ends! */
94 event += 2; /* skip leading CR/LF */
95 desc_end = desc + sprintf(desc, "%s", event);
96
97 /* strip trailing CR/LF (if any) */
98 for (desc_end--;
99 (desc_end != desc) && ((*desc_end == 0xd) || (*desc_end == 0xa));
100 desc_end--) {
101 *desc_end = '\0';
102 }
103
104 return 0;
105}
106
107
108/*
109 * scdrv_event_severity
110 *
111 * Figure out how urgent a message we should write to the console/syslog
112 * via printk.
113 */
114static char *
115scdrv_event_severity(int code)
116{
117 int ev_class = (code & EV_CLASS_MASK);
118 int ev_severity = (code & EV_SEVERITY_MASK);
119 char *pk_severity = KERN_NOTICE;
120
121 switch (ev_class) {
122 case EV_CLASS_POWER:
123 switch (ev_severity) {
124 case EV_SEVERITY_POWER_LOW_WARNING:
125 case EV_SEVERITY_POWER_HIGH_WARNING:
126 pk_severity = KERN_WARNING;
127 break;
128 case EV_SEVERITY_POWER_HIGH_FAULT:
129 case EV_SEVERITY_POWER_LOW_FAULT:
130 pk_severity = KERN_ALERT;
131 break;
132 }
133 break;
134 case EV_CLASS_FAN:
135 switch (ev_severity) {
136 case EV_SEVERITY_FAN_WARNING:
137 pk_severity = KERN_WARNING;
138 break;
139 case EV_SEVERITY_FAN_FAULT:
140 pk_severity = KERN_CRIT;
141 break;
142 }
143 break;
144 case EV_CLASS_TEMP:
145 switch (ev_severity) {
146 case EV_SEVERITY_TEMP_ADVISORY:
147 pk_severity = KERN_WARNING;
148 break;
149 case EV_SEVERITY_TEMP_CRITICAL:
150 pk_severity = KERN_CRIT;
151 break;
152 case EV_SEVERITY_TEMP_FAULT:
153 pk_severity = KERN_ALERT;
154 break;
155 }
156 break;
157 case EV_CLASS_ENV:
158 pk_severity = KERN_ALERT;
159 break;
160 case EV_CLASS_TEST_FAULT:
161 pk_severity = KERN_ALERT;
162 break;
163 case EV_CLASS_TEST_WARNING:
164 pk_severity = KERN_WARNING;
165 break;
166 case EV_CLASS_PWRD_NOTIFY:
167 pk_severity = KERN_ALERT;
168 break;
169 }
170
171 return pk_severity;
172}
173
174
175/*
176 * scdrv_dispatch_event
177 *
178 * Do the right thing with an incoming event. That's often nothing
179 * more than printing it to the system log. For power-down notifications
180 * we start a graceful shutdown.
181 */
182static void
183scdrv_dispatch_event(char *event, int len)
184{
185 int code, esp_code, src;
186 char desc[CHUNKSIZE];
187 char *severity;
188
189 if (scdrv_parse_event(event, &src, &code, &esp_code, desc) < 0) {
190 /* ignore uninterpretible event */
191 return;
192 }
193
194 /* how urgent is the message? */
195 severity = scdrv_event_severity(code);
196
197 if ((code & EV_CLASS_MASK) == EV_CLASS_PWRD_NOTIFY) {
198 struct task_struct *p;
199
200 /* give a SIGPWR signal to init proc */
201
202 /* first find init's task */
203 read_lock(&tasklist_lock);
204 for_each_process(p) {
205 if (p->pid == 1)
206 break;
207 }
208 if (p) { /* we found init's task */
209 printk(KERN_EMERG "Power off indication received. Initiating power fail sequence...\n");
210 force_sig(SIGPWR, p);
211 } else { /* failed to find init's task - just give message(s) */
212 printk(KERN_WARNING "Failed to find init proc to handle power off!\n");
213 printk("%s|$(0x%x)%s\n", severity, esp_code, desc);
214 }
215 read_unlock(&tasklist_lock);
216 } else {
217 /* print to system log */
218 printk("%s|$(0x%x)%s\n", severity, esp_code, desc);
219 }
220}
221
222
223/*
224 * scdrv_event
225 *
226 * Called as a tasklet when an event arrives from the L1. Read the event
227 * from where it's temporarily stored in SAL and call scdrv_dispatch_event()
228 * to send it on its way. Keep trying to read events until SAL indicates
229 * that there are no more immediately available.
230 */
231void
232scdrv_event(unsigned long dummy)
233{
234 int status;
235 int len;
236 unsigned long flags;
237 struct subch_data_s *sd = event_sd;
238
239 /* anything to read? */
240 len = CHUNKSIZE;
241 spin_lock_irqsave(&sd->sd_rlock, flags);
242 status = ia64_sn_irtr_recv(sd->sd_nasid, sd->sd_subch,
243 sd->sd_rb, &len);
244
245 while (!(status < 0)) {
246 spin_unlock_irqrestore(&sd->sd_rlock, flags);
247 scdrv_dispatch_event(sd->sd_rb, len);
248 len = CHUNKSIZE;
249 spin_lock_irqsave(&sd->sd_rlock, flags);
250 status = ia64_sn_irtr_recv(sd->sd_nasid, sd->sd_subch,
251 sd->sd_rb, &len);
252 }
253 spin_unlock_irqrestore(&sd->sd_rlock, flags);
254}
255
256
257/*
258 * scdrv_event_init
259 *
260 * Sets up a system controller subchannel to begin receiving event
261 * messages. This is sort of a specialized version of scdrv_open()
262 * in drivers/char/sn_sysctl.c.
263 */
264void
265scdrv_event_init(struct sysctl_data_s *scd)
266{
267 int rv;
268
269 event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL);
270 if (event_sd == NULL) {
271 printk(KERN_WARNING "%s: couldn't allocate subchannel info"
272 " for event monitoring\n", __FUNCTION__);
273 return;
274 }
275
276 /* initialize subch_data_s fields */
277 memset(event_sd, 0, sizeof (struct subch_data_s));
278 event_sd->sd_nasid = scd->scd_nasid;
279 spin_lock_init(&event_sd->sd_rlock);
280
281 /* ask the system controllers to send events to this node */
282 event_sd->sd_subch = ia64_sn_sysctl_event_init(scd->scd_nasid);
283
284 if (event_sd->sd_subch < 0) {
285 kfree(event_sd);
286 printk(KERN_WARNING "%s: couldn't open event subchannel\n",
287 __FUNCTION__);
288 return;
289 }
290
291 /* hook event subchannel up to the system controller interrupt */
292 rv = request_irq(SGI_UART_VECTOR, scdrv_event_interrupt,
293 SA_SHIRQ | SA_INTERRUPT,
294 "system controller events", event_sd);
295 if (rv) {
296 printk(KERN_WARNING "%s: irq request failed (%d)\n",
297 __FUNCTION__, rv);
298 ia64_sn_irtr_close(event_sd->sd_nasid, event_sd->sd_subch);
299 kfree(event_sd);
300 return;
301 }
302}
303
304
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c812191417c3..fd042060809a 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1021,11 +1021,11 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1021 ret = -EIO; 1021 ret = -EIO;
1022 break; 1022 break;
1023 } 1023 }
1024 if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) 1024 if (copy_to_user(argp, &val8, sizeof(val8)))
1025 ret = -EFAULT; 1025 ret = -EFAULT;
1026 break; 1026 break;
1027 case SONYPI_IOCSFAN: 1027 case SONYPI_IOCSFAN:
1028 if (copy_from_user(&val8, (u8 *)arg, sizeof(val8))) { 1028 if (copy_from_user(&val8, argp, sizeof(val8))) {
1029 ret = -EFAULT; 1029 ret = -EFAULT;
1030 break; 1030 break;
1031 } 1031 }
@@ -1038,7 +1038,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1038 ret = -EIO; 1038 ret = -EIO;
1039 break; 1039 break;
1040 } 1040 }
1041 if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) 1041 if (copy_to_user(argp, &val8, sizeof(val8)))
1042 ret = -EFAULT; 1042 ret = -EFAULT;
1043 break; 1043 break;
1044 default: 1044 default:
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index c789d5ceac76..50e0b612a8a2 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -1987,10 +1987,9 @@ static inline int sx_set_serial_info(struct specialix_port * port,
1987 1987
1988 func_enter(); 1988 func_enter();
1989 /* 1989 /*
1990 error = verify_area(VERIFY_READ, (void *) newinfo, sizeof(tmp)); 1990 if (!access_ok(VERIFY_READ, (void *) newinfo, sizeof(tmp))) {
1991 if (error) {
1992 func_exit(); 1991 func_exit();
1993 return error; 1992 return -EFAULT;
1994 } 1993 }
1995 */ 1994 */
1996 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) { 1995 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) {
@@ -2046,14 +2045,12 @@ static inline int sx_get_serial_info(struct specialix_port * port,
2046{ 2045{
2047 struct serial_struct tmp; 2046 struct serial_struct tmp;
2048 struct specialix_board *bp = port_Board(port); 2047 struct specialix_board *bp = port_Board(port);
2049 // int error;
2050 2048
2051 func_enter(); 2049 func_enter();
2052 2050
2053 /* 2051 /*
2054 error = verify_area(VERIFY_WRITE, (void *) retinfo, sizeof(tmp)); 2052 if (!access_ok(VERIFY_WRITE, (void *) retinfo, sizeof(tmp)))
2055 if (error) 2053 return -EFAULT;
2056 return error;
2057 */ 2054 */
2058 2055
2059 memset(&tmp, 0, sizeof(tmp)); 2056 memset(&tmp, 0, sizeof(tmp));
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index de166608c59e..b8899f560b5e 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -466,7 +466,7 @@ static int stl_parsebrd(stlconf_t *confp, char **argp);
466 466
467static unsigned long stl_atol(char *str); 467static unsigned long stl_atol(char *str);
468 468
469int stl_init(void); 469static int stl_init(void);
470static int stl_open(struct tty_struct *tty, struct file *filp); 470static int stl_open(struct tty_struct *tty, struct file *filp);
471static void stl_close(struct tty_struct *tty, struct file *filp); 471static void stl_close(struct tty_struct *tty, struct file *filp);
472static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count); 472static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count);
@@ -3063,7 +3063,7 @@ static struct tty_operations stl_ops = {
3063 3063
3064/*****************************************************************************/ 3064/*****************************************************************************/
3065 3065
3066int __init stl_init(void) 3066static int __init stl_init(void)
3067{ 3067{
3068 int i; 3068 int i;
3069 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); 3069 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ca36087d4f8a..87235330fdbe 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -143,7 +143,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
143 return -ENODATA; 143 return -ENODATA;
144 if (count > bufsiz) { 144 if (count > bufsiz) {
145 dev_err(&chip->pci_dev->dev, 145 dev_err(&chip->pci_dev->dev,
146 "invalid count value %x %x \n", count, bufsiz); 146 "invalid count value %x %zx \n", count, bufsiz);
147 return -E2BIG; 147 return -E2BIG;
148 } 148 }
149 149
@@ -151,7 +151,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
151 151
152 if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) { 152 if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) {
153 dev_err(&chip->pci_dev->dev, 153 dev_err(&chip->pci_dev->dev,
154 "tpm_transmit: tpm_send: error %d\n", len); 154 "tpm_transmit: tpm_send: error %zd\n", len);
155 return len; 155 return len;
156 } 156 }
157 157
@@ -188,7 +188,7 @@ out_recv:
188 len = chip->vendor->recv(chip, (u8 *) buf, bufsiz); 188 len = chip->vendor->recv(chip, (u8 *) buf, bufsiz);
189 if (len < 0) 189 if (len < 0)
190 dev_err(&chip->pci_dev->dev, 190 dev_err(&chip->pci_dev->dev,
191 "tpm_transmit: tpm_recv: error %d\n", len); 191 "tpm_transmit: tpm_recv: error %zd\n", len);
192 up(&chip->tpm_mutex); 192 up(&chip->tpm_mutex);
193 return len; 193 return len;
194} 194}
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 06e5a3f1836d..26e5e19ed854 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -185,7 +185,7 @@ char *tty_name(struct tty_struct *tty, char *buf)
185 185
186EXPORT_SYMBOL(tty_name); 186EXPORT_SYMBOL(tty_name);
187 187
188inline int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, 188int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
189 const char *routine) 189 const char *routine)
190{ 190{
191#ifdef TTY_PARANOIA_CHECK 191#ifdef TTY_PARANOIA_CHECK
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 5d386f4bea49..8971484b956b 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -24,6 +24,7 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/console.h> 26#include <linux/console.h>
27#include <linux/signal.h>
27 28
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -641,7 +642,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
641 extern int spawnpid, spawnsig; 642 extern int spawnpid, spawnsig;
642 if (!perm || !capable(CAP_KILL)) 643 if (!perm || !capable(CAP_KILL))
643 return -EPERM; 644 return -EPERM;
644 if (arg < 1 || arg > _NSIG || arg == SIGKILL) 645 if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
645 return -EINVAL; 646 return -EINVAL;
646 spawnpid = current->pid; 647 spawnpid = current->pid;
647 spawnsig = arg; 648 spawnsig = arg;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b30001f31610..8e561313d094 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -223,7 +223,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
223 } 223 }
224 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || 224 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) ||
225 (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) || 225 (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) ||
226 (val == CPUFREQ_RESUMECHANGE)) { 226 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
227 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new); 227 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new);
228 dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new); 228 dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new);
229 } 229 }
@@ -866,11 +866,90 @@ EXPORT_SYMBOL(cpufreq_get);
866 866
867 867
868/** 868/**
869 * cpufreq_suspend - let the low level driver prepare for suspend
870 */
871
872static int cpufreq_suspend(struct sys_device * sysdev, u32 state)
873{
874 int cpu = sysdev->id;
875 unsigned int ret = 0;
876 unsigned int cur_freq = 0;
877 struct cpufreq_policy *cpu_policy;
878
879 dprintk("resuming cpu %u\n", cpu);
880
881 if (!cpu_online(cpu))
882 return 0;
883
884 /* we may be lax here as interrupts are off. Nonetheless
885 * we need to grab the correct cpu policy, as to check
886 * whether we really run on this CPU.
887 */
888
889 cpu_policy = cpufreq_cpu_get(cpu);
890 if (!cpu_policy)
891 return -EINVAL;
892
893 /* only handle each CPU group once */
894 if (unlikely(cpu_policy->cpu != cpu)) {
895 cpufreq_cpu_put(cpu_policy);
896 return 0;
897 }
898
899 if (cpufreq_driver->suspend) {
900 ret = cpufreq_driver->suspend(cpu_policy, state);
901 if (ret) {
902 printk(KERN_ERR "cpufreq: suspend failed in ->suspend "
903 "step on CPU %u\n", cpu_policy->cpu);
904 cpufreq_cpu_put(cpu_policy);
905 return ret;
906 }
907 }
908
909
910 if (cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)
911 goto out;
912
913 if (cpufreq_driver->get)
914 cur_freq = cpufreq_driver->get(cpu_policy->cpu);
915
916 if (!cur_freq || !cpu_policy->cur) {
917 printk(KERN_ERR "cpufreq: suspend failed to assert current "
918 "frequency is what timing core thinks it is.\n");
919 goto out;
920 }
921
922 if (unlikely(cur_freq != cpu_policy->cur)) {
923 struct cpufreq_freqs freqs;
924
925 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
926 printk(KERN_DEBUG "Warning: CPU frequency is %u, "
927 "cpufreq assumed %u kHz.\n",
928 cur_freq, cpu_policy->cur);
929
930 freqs.cpu = cpu;
931 freqs.old = cpu_policy->cur;
932 freqs.new = cur_freq;
933
934 notifier_call_chain(&cpufreq_transition_notifier_list,
935 CPUFREQ_SUSPENDCHANGE, &freqs);
936 adjust_jiffies(CPUFREQ_SUSPENDCHANGE, &freqs);
937
938 cpu_policy->cur = cur_freq;
939 }
940
941 out:
942 cpufreq_cpu_put(cpu_policy);
943 return 0;
944}
945
946/**
869 * cpufreq_resume - restore proper CPU frequency handling after resume 947 * cpufreq_resume - restore proper CPU frequency handling after resume
870 * 948 *
871 * 1.) resume CPUfreq hardware support (cpufreq_driver->resume()) 949 * 1.) resume CPUfreq hardware support (cpufreq_driver->resume())
872 * 2.) if ->target and !CPUFREQ_CONST_LOOPS: verify we're in sync 950 * 2.) if ->target and !CPUFREQ_CONST_LOOPS: verify we're in sync
873 * 3.) schedule call cpufreq_update_policy() ASAP as interrupts are restored. 951 * 3.) schedule call cpufreq_update_policy() ASAP as interrupts are
952 * restored.
874 */ 953 */
875static int cpufreq_resume(struct sys_device * sysdev) 954static int cpufreq_resume(struct sys_device * sysdev)
876{ 955{
@@ -915,21 +994,26 @@ static int cpufreq_resume(struct sys_device * sysdev)
915 cur_freq = cpufreq_driver->get(cpu_policy->cpu); 994 cur_freq = cpufreq_driver->get(cpu_policy->cpu);
916 995
917 if (!cur_freq || !cpu_policy->cur) { 996 if (!cur_freq || !cpu_policy->cur) {
918 printk(KERN_ERR "cpufreq: resume failed to assert current frequency is what timing core thinks it is.\n"); 997 printk(KERN_ERR "cpufreq: resume failed to assert "
998 "current frequency is what timing core "
999 "thinks it is.\n");
919 goto out; 1000 goto out;
920 } 1001 }
921 1002
922 if (unlikely(cur_freq != cpu_policy->cur)) { 1003 if (unlikely(cur_freq != cpu_policy->cur)) {
923 struct cpufreq_freqs freqs; 1004 struct cpufreq_freqs freqs;
924 1005
925 printk(KERN_WARNING "Warning: CPU frequency is %u, " 1006 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
926 "cpufreq assumed %u kHz.\n", cur_freq, cpu_policy->cur); 1007 printk(KERN_WARNING "Warning: CPU frequency"
1008 "is %u, cpufreq assumed %u kHz.\n",
1009 cur_freq, cpu_policy->cur);
927 1010
928 freqs.cpu = cpu; 1011 freqs.cpu = cpu;
929 freqs.old = cpu_policy->cur; 1012 freqs.old = cpu_policy->cur;
930 freqs.new = cur_freq; 1013 freqs.new = cur_freq;
931 1014
932 notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_RESUMECHANGE, &freqs); 1015 notifier_call_chain(&cpufreq_transition_notifier_list,
1016 CPUFREQ_RESUMECHANGE, &freqs);
933 adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs); 1017 adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs);
934 1018
935 cpu_policy->cur = cur_freq; 1019 cpu_policy->cur = cur_freq;
@@ -945,6 +1029,7 @@ out:
945static struct sysdev_driver cpufreq_sysdev_driver = { 1029static struct sysdev_driver cpufreq_sysdev_driver = {
946 .add = cpufreq_add_dev, 1030 .add = cpufreq_add_dev,
947 .remove = cpufreq_remove_dev, 1031 .remove = cpufreq_remove_dev,
1032 .suspend = cpufreq_suspend,
948 .resume = cpufreq_resume, 1033 .resume = cpufreq_resume,
949}; 1034};
950 1035
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a2827e43f0fe..a0018de3bef4 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -237,7 +237,7 @@ config I2C_KEYWEST
237 237
238config I2C_MPC 238config I2C_MPC
239 tristate "MPC107/824x/85xx/52xx" 239 tristate "MPC107/824x/85xx/52xx"
240 depends on I2C && PPC 240 depends on I2C && PPC32
241 help 241 help
242 If you say yes to this option, support will be included for the 242 If you say yes to this option, support will be included for the
243 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and 243 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 75b8d867dae1..6f33496d31c3 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -55,7 +55,7 @@
55#define CSR_RXAK 0x01 55#define CSR_RXAK 0x01
56 56
57struct mpc_i2c { 57struct mpc_i2c {
58 char *base; 58 void __iomem *base;
59 u32 interrupt; 59 u32 interrupt;
60 wait_queue_head_t queue; 60 wait_queue_head_t queue;
61 struct i2c_adapter adap; 61 struct i2c_adapter adap;
@@ -444,7 +444,7 @@ static int fsl_i2c_probe(struct device *device)
444 444
445 fail_add: 445 fail_add:
446 if (i2c->irq != 0) 446 if (i2c->irq != 0)
447 free_irq(i2c->irq, 0); 447 free_irq(i2c->irq, NULL);
448 fail_irq: 448 fail_irq:
449 iounmap(i2c->base); 449 iounmap(i2c->base);
450 fail_map: 450 fail_map:
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 9d70ba5ea59b..16b3e2d8bfb1 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -726,7 +726,7 @@ static int sis5513_config_xfer_rate (ide_drive_t *drive)
726*/ 726*/
727 727
728/* Chip detection and general config */ 728/* Chip detection and general config */
729static unsigned int __init init_chipset_sis5513 (struct pci_dev *dev, const char *name) 729static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name)
730{ 730{
731 struct pci_dev *host; 731 struct pci_dev *host;
732 int i = 0; 732 int i = 0;
@@ -879,7 +879,7 @@ static unsigned int __init init_chipset_sis5513 (struct pci_dev *dev, const char
879 return 0; 879 return 0;
880} 880}
881 881
882static unsigned int __init ata66_sis5513 (ide_hwif_t *hwif) 882static unsigned int __devinit ata66_sis5513 (ide_hwif_t *hwif)
883{ 883{
884 u8 ata66 = 0; 884 u8 ata66 = 0;
885 885
@@ -897,7 +897,7 @@ static unsigned int __init ata66_sis5513 (ide_hwif_t *hwif)
897 return ata66; 897 return ata66;
898} 898}
899 899
900static void __init init_hwif_sis5513 (ide_hwif_t *hwif) 900static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
901{ 901{
902 hwif->autodma = 0; 902 hwif->autodma = 0;
903 903
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 6dc273a81327..569f16767442 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1204,6 +1204,8 @@ pmac_ide_do_suspend(ide_hwif_t *hwif)
1204 } 1204 }
1205#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */ 1205#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
1206 1206
1207 disable_irq(pmif->irq);
1208
1207 /* The media bay will handle itself just fine */ 1209 /* The media bay will handle itself just fine */
1208 if (pmif->mediabay) 1210 if (pmif->mediabay)
1209 return 0; 1211 return 0;
@@ -1236,7 +1238,6 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
1236 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1); 1238 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1);
1237 msleep(10); 1239 msleep(10);
1238 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0); 1240 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0);
1239 msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
1240 1241
1241 /* Kauai has it different */ 1242 /* Kauai has it different */
1242 if (pmif->kauai_fcr) { 1243 if (pmif->kauai_fcr) {
@@ -1244,11 +1245,15 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
1244 fcr |= KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE; 1245 fcr |= KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE;
1245 writel(fcr, pmif->kauai_fcr); 1246 writel(fcr, pmif->kauai_fcr);
1246 } 1247 }
1248
1249 msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
1247 } 1250 }
1248 1251
1249 /* Sanitize drive timings */ 1252 /* Sanitize drive timings */
1250 sanitize_timings(pmif); 1253 sanitize_timings(pmif);
1251 1254
1255 enable_irq(pmif->irq);
1256
1252 return 0; 1257 return 0;
1253} 1258}
1254 1259
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 97ff364c0434..6cb0b586c297 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -539,10 +539,8 @@ static void ohci_initialize(struct ti_ohci *ohci)
539 initialize_dma_trm_ctx(&ohci->at_req_context); 539 initialize_dma_trm_ctx(&ohci->at_req_context);
540 initialize_dma_trm_ctx(&ohci->at_resp_context); 540 initialize_dma_trm_ctx(&ohci->at_resp_context);
541 541
542 /* Initialize IR Legacy DMA */ 542 /* Initialize IR Legacy DMA channel mask */
543 ohci->ir_legacy_channels = 0; 543 ohci->ir_legacy_channels = 0;
544 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
545 DBGMSG("ISO receive legacy context activated");
546 544
547 /* 545 /*
548 * Accept AT requests from all nodes. This probably 546 * Accept AT requests from all nodes. This probably
@@ -1032,6 +1030,8 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1032 case ISO_LISTEN_CHANNEL: 1030 case ISO_LISTEN_CHANNEL:
1033 { 1031 {
1034 u64 mask; 1032 u64 mask;
1033 struct dma_rcv_ctx *d = &ohci->ir_legacy_context;
1034 int ir_legacy_active;
1035 1035
1036 if (arg<0 || arg>63) { 1036 if (arg<0 || arg>63) {
1037 PRINT(KERN_ERR, 1037 PRINT(KERN_ERR,
@@ -1052,9 +1052,37 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1052 return -EFAULT; 1052 return -EFAULT;
1053 } 1053 }
1054 1054
1055 ir_legacy_active = ohci->ir_legacy_channels;
1056
1055 ohci->ISO_channel_usage |= mask; 1057 ohci->ISO_channel_usage |= mask;
1056 ohci->ir_legacy_channels |= mask; 1058 ohci->ir_legacy_channels |= mask;
1057 1059
1060 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
1061
1062 if (!ir_legacy_active) {
1063 if (ohci1394_register_iso_tasklet(ohci,
1064 &ohci->ir_legacy_tasklet) < 0) {
1065 PRINT(KERN_ERR, "No IR DMA context available");
1066 return -EBUSY;
1067 }
1068
1069 /* the IR context can be assigned to any DMA context
1070 * by ohci1394_register_iso_tasklet */
1071 d->ctx = ohci->ir_legacy_tasklet.context;
1072 d->ctrlSet = OHCI1394_IsoRcvContextControlSet +
1073 32*d->ctx;
1074 d->ctrlClear = OHCI1394_IsoRcvContextControlClear +
1075 32*d->ctx;
1076 d->cmdPtr = OHCI1394_IsoRcvCommandPtr + 32*d->ctx;
1077 d->ctxtMatch = OHCI1394_IsoRcvContextMatch + 32*d->ctx;
1078
1079 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
1080
1081 PRINT(KERN_ERR, "IR legacy activated");
1082 }
1083
1084 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
1085
1058 if (arg>31) 1086 if (arg>31)
1059 reg_write(ohci, OHCI1394_IRMultiChanMaskHiSet, 1087 reg_write(ohci, OHCI1394_IRMultiChanMaskHiSet,
1060 1<<(arg-32)); 1088 1<<(arg-32));
@@ -1101,6 +1129,12 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1101 1129
1102 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags); 1130 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
1103 DBGMSG("Listening disabled on channel %d", arg); 1131 DBGMSG("Listening disabled on channel %d", arg);
1132
1133 if (ohci->ir_legacy_channels == 0) {
1134 stop_dma_rcv_ctx(&ohci->ir_legacy_context);
1135 DBGMSG("ISO legacy receive context stopped");
1136 }
1137
1104 break; 1138 break;
1105 } 1139 }
1106 default: 1140 default:
@@ -1270,8 +1304,10 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
1270 OHCI_ISO_RECEIVE, 1304 OHCI_ISO_RECEIVE,
1271 ohci_iso_recv_task, (unsigned long) iso); 1305 ohci_iso_recv_task, (unsigned long) iso);
1272 1306
1273 if (ohci1394_register_iso_tasklet(recv->ohci, &recv->task) < 0) 1307 if (ohci1394_register_iso_tasklet(recv->ohci, &recv->task) < 0) {
1308 ret = -EBUSY;
1274 goto err; 1309 goto err;
1310 }
1275 1311
1276 recv->task_active = 1; 1312 recv->task_active = 1;
1277 1313
@@ -1896,8 +1932,10 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
1896 ohci1394_init_iso_tasklet(&xmit->task, OHCI_ISO_TRANSMIT, 1932 ohci1394_init_iso_tasklet(&xmit->task, OHCI_ISO_TRANSMIT,
1897 ohci_iso_xmit_task, (unsigned long) iso); 1933 ohci_iso_xmit_task, (unsigned long) iso);
1898 1934
1899 if (ohci1394_register_iso_tasklet(xmit->ohci, &xmit->task) < 0) 1935 if (ohci1394_register_iso_tasklet(xmit->ohci, &xmit->task) < 0) {
1936 ret = -EBUSY;
1900 goto err; 1937 goto err;
1938 }
1901 1939
1902 xmit->task_active = 1; 1940 xmit->task_active = 1;
1903 1941
@@ -2691,7 +2729,7 @@ static void dma_rcv_tasklet (unsigned long data)
2691 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f, 2729 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f,
2692 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>21)&0x3, 2730 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>21)&0x3,
2693 tcode, length, d->ctx, 2731 tcode, length, d->ctx,
2694 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>10)&0x3f); 2732 (cond_le32_to_cpu(d->spb[0], ohci->no_swap_incoming)>>10)&0x3f);
2695 2733
2696 ack = (((cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f) 2734 ack = (((cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f)
2697 == 0x11) ? 1 : 0; 2735 == 0x11) ? 1 : 0;
@@ -2754,7 +2792,7 @@ static void dma_trm_tasklet (unsigned long data)
2754 d->ctx); 2792 d->ctx);
2755 else 2793 else
2756 DBGMSG("Packet sent to node %d tcode=0x%X tLabel=" 2794 DBGMSG("Packet sent to node %d tcode=0x%X tLabel="
2757 "0x%02X ack=0x%X spd=%d dataLength=%d ctx=%d", 2795 "%d ack=0x%X spd=%d dataLength=%d ctx=%d",
2758 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16)&0x3f, 2796 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16)&0x3f,
2759 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf, 2797 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf,
2760 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>10)&0x3f, 2798 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>10)&0x3f,
@@ -2763,7 +2801,7 @@ static void dma_trm_tasklet (unsigned long data)
2763 d->ctx); 2801 d->ctx);
2764 else 2802 else
2765 DBGMSG("Packet sent to node %d tcode=0x%X tLabel=" 2803 DBGMSG("Packet sent to node %d tcode=0x%X tLabel="
2766 "0x%02X ack=0x%X spd=%d data=0x%08X ctx=%d", 2804 "%d ack=0x%X spd=%d data=0x%08X ctx=%d",
2767 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1]) 2805 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])
2768 >>16)&0x3f, 2806 >>16)&0x3f,
2769 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0]) 2807 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])
@@ -2999,20 +3037,6 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
2999 ohci1394_init_iso_tasklet(&ohci->ir_legacy_tasklet, 3037 ohci1394_init_iso_tasklet(&ohci->ir_legacy_tasklet,
3000 OHCI_ISO_MULTICHANNEL_RECEIVE, 3038 OHCI_ISO_MULTICHANNEL_RECEIVE,
3001 dma_rcv_tasklet, (unsigned long) d); 3039 dma_rcv_tasklet, (unsigned long) d);
3002 if (ohci1394_register_iso_tasklet(ohci,
3003 &ohci->ir_legacy_tasklet) < 0) {
3004 PRINT(KERN_ERR, "No IR DMA context available");
3005 free_dma_rcv_ctx(d);
3006 return -EBUSY;
3007 }
3008
3009 /* the IR context can be assigned to any DMA context
3010 * by ohci1394_register_iso_tasklet */
3011 d->ctx = ohci->ir_legacy_tasklet.context;
3012 d->ctrlSet = OHCI1394_IsoRcvContextControlSet + 32*d->ctx;
3013 d->ctrlClear = OHCI1394_IsoRcvContextControlClear + 32*d->ctx;
3014 d->cmdPtr = OHCI1394_IsoRcvCommandPtr + 32*d->ctx;
3015 d->ctxtMatch = OHCI1394_IsoRcvContextMatch + 32*d->ctx;
3016 } else { 3040 } else {
3017 d->ctrlSet = context_base + OHCI1394_ContextControlSet; 3041 d->ctrlSet = context_base + OHCI1394_ContextControlSet;
3018 d->ctrlClear = context_base + OHCI1394_ContextControlClear; 3042 d->ctrlClear = context_base + OHCI1394_ContextControlClear;
@@ -3413,7 +3437,6 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
3413 3437
3414 switch (ohci->init_state) { 3438 switch (ohci->init_state) {
3415 case OHCI_INIT_DONE: 3439 case OHCI_INIT_DONE:
3416 stop_dma_rcv_ctx(&ohci->ir_legacy_context);
3417 hpsb_remove_host(ohci->host); 3440 hpsb_remove_host(ohci->host);
3418 3441
3419 /* Clear out BUS Options */ 3442 /* Clear out BUS Options */
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 5824b6d3769f..637b30e35592 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -32,6 +32,8 @@
32 * $Id$ 32 * $Id$
33 */ 33 */
34 34
35#include <linux/mm.h>
36
35#include "mthca_memfree.h" 37#include "mthca_memfree.h"
36#include "mthca_dev.h" 38#include "mthca_dev.h"
37#include "mthca_cmd.h" 39#include "mthca_cmd.h"
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index c76cf8ff29c0..874367bfab08 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -116,7 +116,7 @@ static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *r
116 116
117 case 'K': /* Button data */ 117 case 'K': /* Button data */
118 if (spaceorb->idx != 5) return; 118 if (spaceorb->idx != 5) return;
119 for (i = 0; i < 7; i++) 119 for (i = 0; i < 6; i++)
120 input_report_key(dev, spaceorb_buttons[i], (data[2] >> i) & 1); 120 input_report_key(dev, spaceorb_buttons[i], (data[2] >> i) & 1);
121 121
122 break; 122 break;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index f7304f0ce542..ff66ed4ee2cd 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -678,7 +678,7 @@ static void atkbd_disconnect(struct serio *serio)
678 atkbd_disable(atkbd); 678 atkbd_disable(atkbd);
679 679
680 /* make sure we don't have a command in flight */ 680 /* make sure we don't have a command in flight */
681 synchronize_kernel(); 681 synchronize_sched(); /* Allow atkbd_interrupt()s to complete. */
682 flush_scheduled_work(); 682 flush_scheduled_work();
683 683
684 device_remove_file(&serio->dev, &atkbd_attr_extra); 684 device_remove_file(&serio->dev, &atkbd_attr_extra);
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 06163538bb20..12dee8e9fbbe 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -60,12 +60,12 @@ MODULE_LICENSE("GPL");
60 60
61static struct class_simple *capi_class; 61static struct class_simple *capi_class;
62 62
63int capi_major = 68; /* allocated */ 63static int capi_major = 68; /* allocated */
64#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 64#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
65#define CAPINC_NR_PORTS 32 65#define CAPINC_NR_PORTS 32
66#define CAPINC_MAX_PORTS 256 66#define CAPINC_MAX_PORTS 256
67int capi_ttymajor = 191; 67static int capi_ttymajor = 191;
68int capi_ttyminors = CAPINC_NR_PORTS; 68static int capi_ttyminors = CAPINC_NR_PORTS;
69#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ 69#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
70 70
71module_param_named(major, capi_major, uint, 0); 71module_param_named(major, capi_major, uint, 0);
@@ -268,7 +268,7 @@ static void capiminor_free(struct capiminor *mp)
268 kfree(mp); 268 kfree(mp);
269} 269}
270 270
271struct capiminor *capiminor_find(unsigned int minor) 271static struct capiminor *capiminor_find(unsigned int minor)
272{ 272{
273 struct list_head *l; 273 struct list_head *l;
274 struct capiminor *p = NULL; 274 struct capiminor *p = NULL;
@@ -1166,7 +1166,7 @@ static int capinc_tty_write_room(struct tty_struct *tty)
1166 return room; 1166 return room;
1167} 1167}
1168 1168
1169int capinc_tty_chars_in_buffer(struct tty_struct *tty) 1169static int capinc_tty_chars_in_buffer(struct tty_struct *tty)
1170{ 1170{
1171 struct capiminor *mp = (struct capiminor *)tty->driver_data; 1171 struct capiminor *mp = (struct capiminor *)tty->driver_data;
1172 if (!mp || !mp->nccip) { 1172 if (!mp || !mp->nccip) {
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 16dc5418ff41..2cc8b27e4c3b 100644
--- a/drivers/isdn/capi/kcapi_proc.c
+++ b/drivers/isdn/capi/kcapi_proc.c
@@ -89,14 +89,14 @@ static int contrstats_show(struct seq_file *seq, void *v)
89 return 0; 89 return 0;
90} 90}
91 91
92struct seq_operations seq_controller_ops = { 92static struct seq_operations seq_controller_ops = {
93 .start = controller_start, 93 .start = controller_start,
94 .next = controller_next, 94 .next = controller_next,
95 .stop = controller_stop, 95 .stop = controller_stop,
96 .show = controller_show, 96 .show = controller_show,
97}; 97};
98 98
99struct seq_operations seq_contrstats_ops = { 99static struct seq_operations seq_contrstats_ops = {
100 .start = controller_start, 100 .start = controller_start,
101 .next = controller_next, 101 .next = controller_next,
102 .stop = controller_stop, 102 .stop = controller_stop,
@@ -192,14 +192,14 @@ applstats_show(struct seq_file *seq, void *v)
192 return 0; 192 return 0;
193} 193}
194 194
195struct seq_operations seq_applications_ops = { 195static struct seq_operations seq_applications_ops = {
196 .start = applications_start, 196 .start = applications_start,
197 .next = applications_next, 197 .next = applications_next,
198 .stop = applications_stop, 198 .stop = applications_stop,
199 .show = applications_show, 199 .show = applications_show,
200}; 200};
201 201
202struct seq_operations seq_applstats_ops = { 202static struct seq_operations seq_applstats_ops = {
203 .start = applications_start, 203 .start = applications_start,
204 .next = applications_next, 204 .next = applications_next,
205 .stop = applications_stop, 205 .stop = applications_stop,
@@ -287,7 +287,7 @@ static int capi_driver_show(struct seq_file *seq, void *v)
287 return 0; 287 return 0;
288} 288}
289 289
290struct seq_operations seq_capi_driver_ops = { 290static struct seq_operations seq_capi_driver_ops = {
291 .start = capi_driver_start, 291 .start = capi_driver_start,
292 .next = capi_driver_next, 292 .next = capi_driver_next,
293 .stop = capi_driver_stop, 293 .stop = capi_driver_stop,
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 1eb112213f0c..0bfd698726a6 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -383,7 +383,7 @@ divert_rule *getruleptr(int idx)
383/*************************************************/ 383/*************************************************/
384/* called from common module on an incoming call */ 384/* called from common module on an incoming call */
385/*************************************************/ 385/*************************************************/
386int isdn_divert_icall(isdn_ctrl *ic) 386static int isdn_divert_icall(isdn_ctrl *ic)
387{ int retval = 0; 387{ int retval = 0;
388 unsigned long flags; 388 unsigned long flags;
389 struct call_struc *cs = NULL; 389 struct call_struc *cs = NULL;
@@ -552,7 +552,7 @@ void deleteprocs(void)
552/****************************************************/ 552/****************************************************/
553/* put a address including address type into buffer */ 553/* put a address including address type into buffer */
554/****************************************************/ 554/****************************************************/
555int put_address(char *st, u_char *p, int len) 555static int put_address(char *st, u_char *p, int len)
556{ u_char retval = 0; 556{ u_char retval = 0;
557 u_char adr_typ = 0; /* network standard */ 557 u_char adr_typ = 0; /* network standard */
558 558
@@ -595,7 +595,7 @@ int put_address(char *st, u_char *p, int len)
595/*************************************/ 595/*************************************/
596/* report a succesfull interrogation */ 596/* report a succesfull interrogation */
597/*************************************/ 597/*************************************/
598int interrogate_success(isdn_ctrl *ic, struct call_struc *cs) 598static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
599{ char *src = ic->parm.dss1_io.data; 599{ char *src = ic->parm.dss1_io.data;
600 int restlen = ic->parm.dss1_io.datalen; 600 int restlen = ic->parm.dss1_io.datalen;
601 int cnt = 1; 601 int cnt = 1;
@@ -689,7 +689,7 @@ int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
689/*********************************************/ 689/*********************************************/
690/* callback for protocol specific extensions */ 690/* callback for protocol specific extensions */
691/*********************************************/ 691/*********************************************/
692int prot_stat_callback(isdn_ctrl *ic) 692static int prot_stat_callback(isdn_ctrl *ic)
693{ struct call_struc *cs, *cs1; 693{ struct call_struc *cs, *cs1;
694 int i; 694 int i;
695 unsigned long flags; 695 unsigned long flags;
@@ -781,7 +781,7 @@ int prot_stat_callback(isdn_ctrl *ic)
781/***************************/ 781/***************************/
782/* status callback from HL */ 782/* status callback from HL */
783/***************************/ 783/***************************/
784int isdn_divert_stat_callback(isdn_ctrl *ic) 784static int isdn_divert_stat_callback(isdn_ctrl *ic)
785{ struct call_struc *cs, *cs1; 785{ struct call_struc *cs, *cs1;
786 unsigned long flags; 786 unsigned long flags;
787 int retval; 787 int retval;
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index 1ac46c26b936..ba1d028343ec 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -29,6 +29,7 @@
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/skbuff.h> 30#include <linux/skbuff.h>
31#include <linux/wait.h> 31#include <linux/wait.h>
32#include <asm/io.h>
32#include "hisax_if.h" 33#include "hisax_if.h"
33#include "hfc4s8s_l1.h" 34#include "hfc4s8s_l1.h"
34 35
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index 8f93d01d8928..db654e8bd67e 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -555,6 +555,42 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
555#endif /* CONFIG_PMAC_BACKLIGHT */ 555#endif /* CONFIG_PMAC_BACKLIGHT */
556 input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSUP, down); 556 input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSUP, down);
557 break; 557 break;
558
559 case 0xc: /* videomode switch */
560 input_report_key(&adbhid[id]->input, KEY_SWITCHVIDEOMODE, down);
561 break;
562
563 case 0xd: /* keyboard illumination toggle */
564 input_report_key(&adbhid[id]->input, KEY_KBDILLUMTOGGLE, down);
565 break;
566
567 case 0xe: /* keyboard illumination decrease */
568 input_report_key(&adbhid[id]->input, KEY_KBDILLUMDOWN, down);
569 break;
570
571 case 0xf:
572 switch (data[1]) {
573 case 0x8f:
574 case 0x0f:
575 /* keyboard illumination increase */
576 input_report_key(&adbhid[id]->input, KEY_KBDILLUMUP, down);
577 break;
578
579 case 0x7f:
580 case 0xff:
581 /* keypad overlay toogle */
582 break;
583
584 default:
585 printk(KERN_INFO "Unhandled ADB_MISC event %02x, %02x, %02x, %02x\n",
586 data[0], data[1], data[2], data[3]);
587 break;
588 }
589 break;
590 default:
591 printk(KERN_INFO "Unhandled ADB_MISC event %02x, %02x, %02x, %02x\n",
592 data[0], data[1], data[2], data[3]);
593 break;
558 } 594 }
559 } 595 }
560 break; 596 break;
@@ -775,6 +811,10 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
775 set_bit(KEY_BRIGHTNESSUP, adbhid[id]->input.keybit); 811 set_bit(KEY_BRIGHTNESSUP, adbhid[id]->input.keybit);
776 set_bit(KEY_BRIGHTNESSDOWN, adbhid[id]->input.keybit); 812 set_bit(KEY_BRIGHTNESSDOWN, adbhid[id]->input.keybit);
777 set_bit(KEY_EJECTCD, adbhid[id]->input.keybit); 813 set_bit(KEY_EJECTCD, adbhid[id]->input.keybit);
814 set_bit(KEY_SWITCHVIDEOMODE, adbhid[id]->input.keybit);
815 set_bit(KEY_KBDILLUMTOGGLE, adbhid[id]->input.keybit);
816 set_bit(KEY_KBDILLUMDOWN, adbhid[id]->input.keybit);
817 set_bit(KEY_KBDILLUMUP, adbhid[id]->input.keybit);
778 break; 818 break;
779 } 819 }
780 if (adbhid[id]->name[0]) 820 if (adbhid[id]->name[0])
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index fdea1a3a631d..e654aa5eecd4 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2351,6 +2351,10 @@ pmac_suspend_devices(void)
2351 return -EBUSY; 2351 return -EBUSY;
2352 } 2352 }
2353 2353
2354 /* Disable clock spreading on some machines */
2355 pmac_tweak_clock_spreading(0);
2356
2357 /* Stop preemption */
2354 preempt_disable(); 2358 preempt_disable();
2355 2359
2356 /* Make sure the decrementer won't interrupt us */ 2360 /* Make sure the decrementer won't interrupt us */
@@ -2417,11 +2421,12 @@ pmac_wakeup_devices(void)
2417 2421
2418 /* Re-enable local CPU interrupts */ 2422 /* Re-enable local CPU interrupts */
2419 local_irq_enable(); 2423 local_irq_enable();
2420
2421 mdelay(100); 2424 mdelay(100);
2422
2423 preempt_enable(); 2425 preempt_enable();
2424 2426
2427 /* Re-enable clock spreading on some machines */
2428 pmac_tweak_clock_spreading(1);
2429
2425 /* Resume devices */ 2430 /* Resume devices */
2426 device_resume(); 2431 device_resume();
2427 2432
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 77619a56e2bf..0dd6c2b5391b 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -331,25 +331,19 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size,
331 struct bio *bio; 331 struct bio *bio;
332 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 332 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
333 int gfp_mask = GFP_NOIO | __GFP_HIGHMEM; 333 int gfp_mask = GFP_NOIO | __GFP_HIGHMEM;
334 unsigned long flags = current->flags;
335 unsigned int i; 334 unsigned int i;
336 335
337 /* 336 /*
338 * Tell VM to act less aggressively and fail earlier. 337 * Use __GFP_NOMEMALLOC to tell the VM to act less aggressively and
339 * This is not necessary but increases throughput. 338 * to fail earlier. This is not necessary but increases throughput.
340 * FIXME: Is this really intelligent? 339 * FIXME: Is this really intelligent?
341 */ 340 */
342 current->flags &= ~PF_MEMALLOC;
343
344 if (base_bio) 341 if (base_bio)
345 bio = bio_clone(base_bio, GFP_NOIO); 342 bio = bio_clone(base_bio, GFP_NOIO|__GFP_NOMEMALLOC);
346 else 343 else
347 bio = bio_alloc(GFP_NOIO, nr_iovecs); 344 bio = bio_alloc(GFP_NOIO|__GFP_NOMEMALLOC, nr_iovecs);
348 if (!bio) { 345 if (!bio)
349 if (flags & PF_MEMALLOC)
350 current->flags |= PF_MEMALLOC;
351 return NULL; 346 return NULL;
352 }
353 347
354 /* if the last bio was not complete, continue where that one ended */ 348 /* if the last bio was not complete, continue where that one ended */
355 bio->bi_idx = *bio_vec_idx; 349 bio->bi_idx = *bio_vec_idx;
@@ -386,9 +380,6 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size,
386 size -= bv->bv_len; 380 size -= bv->bv_len;
387 } 381 }
388 382
389 if (flags & PF_MEMALLOC)
390 current->flags |= PF_MEMALLOC;
391
392 if (!bio->bi_size) { 383 if (!bio->bi_size) {
393 bio_put(bio); 384 bio_put(bio);
394 return NULL; 385 return NULL;
diff --git a/drivers/md/dm-emc.c b/drivers/md/dm-emc.c
index 700658664594..c7067674dcb7 100644
--- a/drivers/md/dm-emc.c
+++ b/drivers/md/dm-emc.c
@@ -223,8 +223,10 @@ static struct emc_handler *alloc_emc_handler(void)
223{ 223{
224 struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL); 224 struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
225 225
226 if (h) 226 if (h) {
227 memset(h, 0, sizeof(*h));
227 spin_lock_init(&h->lock); 228 spin_lock_init(&h->lock);
229 }
228 230
229 return h; 231 return h;
230} 232}
@@ -259,8 +261,6 @@ static int emc_create(struct hw_handler *hwh, unsigned argc, char **argv)
259 if (!h) 261 if (!h)
260 return -ENOMEM; 262 return -ENOMEM;
261 263
262 memset(h, 0, sizeof(*h));
263
264 hwh->context = h; 264 hwh->context = h;
265 265
266 if ((h->short_trespass = short_trespass)) 266 if ((h->short_trespass = short_trespass))
diff --git a/drivers/md/dm-hw-handler.c b/drivers/md/dm-hw-handler.c
index ae63772e44c9..4cc0010e0156 100644
--- a/drivers/md/dm-hw-handler.c
+++ b/drivers/md/dm-hw-handler.c
@@ -23,7 +23,7 @@ struct hwh_internal {
23static LIST_HEAD(_hw_handlers); 23static LIST_HEAD(_hw_handlers);
24static DECLARE_RWSEM(_hwh_lock); 24static DECLARE_RWSEM(_hwh_lock);
25 25
26struct hwh_internal *__find_hw_handler_type(const char *name) 26static struct hwh_internal *__find_hw_handler_type(const char *name)
27{ 27{
28 struct hwh_internal *hwhi; 28 struct hwh_internal *hwhi;
29 29
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 43763a0bd096..1e97b3c12bd5 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -101,6 +101,7 @@ typedef int (*action_fn) (struct pgpath *pgpath);
101 101
102static kmem_cache_t *_mpio_cache; 102static kmem_cache_t *_mpio_cache;
103 103
104struct workqueue_struct *kmultipathd;
104static void process_queued_ios(void *data); 105static void process_queued_ios(void *data);
105static void trigger_event(void *data); 106static void trigger_event(void *data);
106 107
@@ -308,7 +309,7 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
308 bio_list_add(&m->queued_ios, bio); 309 bio_list_add(&m->queued_ios, bio);
309 m->queue_size++; 310 m->queue_size++;
310 if (m->pg_init_required || !m->queue_io) 311 if (m->pg_init_required || !m->queue_io)
311 schedule_work(&m->process_queued_ios); 312 queue_work(kmultipathd, &m->process_queued_ios);
312 pgpath = NULL; 313 pgpath = NULL;
313 r = 0; 314 r = 0;
314 } else if (!pgpath) 315 } else if (!pgpath)
@@ -334,7 +335,7 @@ static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path)
334 335
335 m->queue_if_no_path = queue_if_no_path; 336 m->queue_if_no_path = queue_if_no_path;
336 if (!m->queue_if_no_path) 337 if (!m->queue_if_no_path)
337 schedule_work(&m->process_queued_ios); 338 queue_work(kmultipathd, &m->process_queued_ios);
338 339
339 spin_unlock_irqrestore(&m->lock, flags); 340 spin_unlock_irqrestore(&m->lock, flags);
340 341
@@ -800,7 +801,7 @@ static int fail_path(struct pgpath *pgpath)
800 if (pgpath == m->current_pgpath) 801 if (pgpath == m->current_pgpath)
801 m->current_pgpath = NULL; 802 m->current_pgpath = NULL;
802 803
803 schedule_work(&m->trigger_event); 804 queue_work(kmultipathd, &m->trigger_event);
804 805
805out: 806out:
806 spin_unlock_irqrestore(&m->lock, flags); 807 spin_unlock_irqrestore(&m->lock, flags);
@@ -837,9 +838,9 @@ static int reinstate_path(struct pgpath *pgpath)
837 838
838 m->current_pgpath = NULL; 839 m->current_pgpath = NULL;
839 if (!m->nr_valid_paths++) 840 if (!m->nr_valid_paths++)
840 schedule_work(&m->process_queued_ios); 841 queue_work(kmultipathd, &m->process_queued_ios);
841 842
842 schedule_work(&m->trigger_event); 843 queue_work(kmultipathd, &m->trigger_event);
843 844
844out: 845out:
845 spin_unlock_irqrestore(&m->lock, flags); 846 spin_unlock_irqrestore(&m->lock, flags);
@@ -883,7 +884,7 @@ static void bypass_pg(struct multipath *m, struct priority_group *pg,
883 884
884 spin_unlock_irqrestore(&m->lock, flags); 885 spin_unlock_irqrestore(&m->lock, flags);
885 886
886 schedule_work(&m->trigger_event); 887 queue_work(kmultipathd, &m->trigger_event);
887} 888}
888 889
889/* 890/*
@@ -913,7 +914,7 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
913 } 914 }
914 spin_unlock_irqrestore(&m->lock, flags); 915 spin_unlock_irqrestore(&m->lock, flags);
915 916
916 schedule_work(&m->trigger_event); 917 queue_work(kmultipathd, &m->trigger_event);
917 return 0; 918 return 0;
918} 919}
919 920
@@ -968,7 +969,7 @@ void dm_pg_init_complete(struct path *path, unsigned err_flags)
968 m->current_pgpath = NULL; 969 m->current_pgpath = NULL;
969 m->current_pg = NULL; 970 m->current_pg = NULL;
970 } 971 }
971 schedule_work(&m->process_queued_ios); 972 queue_work(kmultipathd, &m->process_queued_ios);
972 spin_unlock_irqrestore(&m->lock, flags); 973 spin_unlock_irqrestore(&m->lock, flags);
973} 974}
974 975
@@ -1018,7 +1019,7 @@ static int do_end_io(struct multipath *m, struct bio *bio,
1018 bio_list_add(&m->queued_ios, bio); 1019 bio_list_add(&m->queued_ios, bio);
1019 m->queue_size++; 1020 m->queue_size++;
1020 if (!m->queue_io) 1021 if (!m->queue_io)
1021 schedule_work(&m->process_queued_ios); 1022 queue_work(kmultipathd, &m->process_queued_ios);
1022 spin_unlock(&m->lock); 1023 spin_unlock(&m->lock);
1023 1024
1024 return 1; /* io not complete */ 1025 return 1; /* io not complete */
@@ -1057,7 +1058,7 @@ static void multipath_presuspend(struct dm_target *ti)
1057 spin_lock_irqsave(&m->lock, flags); 1058 spin_lock_irqsave(&m->lock, flags);
1058 m->suspended = 1; 1059 m->suspended = 1;
1059 if (m->queue_if_no_path) 1060 if (m->queue_if_no_path)
1060 schedule_work(&m->process_queued_ios); 1061 queue_work(kmultipathd, &m->process_queued_ios);
1061 spin_unlock_irqrestore(&m->lock, flags); 1062 spin_unlock_irqrestore(&m->lock, flags);
1062} 1063}
1063 1064
@@ -1274,6 +1275,15 @@ static int __init dm_multipath_init(void)
1274 return -EINVAL; 1275 return -EINVAL;
1275 } 1276 }
1276 1277
1278 kmultipathd = create_workqueue("kmpathd");
1279 if (!kmultipathd) {
1280 DMERR("%s: failed to create workqueue kmpathd",
1281 multipath_target.name);
1282 dm_unregister_target(&multipath_target);
1283 kmem_cache_destroy(_mpio_cache);
1284 return -ENOMEM;
1285 }
1286
1277 DMINFO("dm-multipath version %u.%u.%u loaded", 1287 DMINFO("dm-multipath version %u.%u.%u loaded",
1278 multipath_target.version[0], multipath_target.version[1], 1288 multipath_target.version[0], multipath_target.version[1],
1279 multipath_target.version[2]); 1289 multipath_target.version[2]);
@@ -1285,6 +1295,8 @@ static void __exit dm_multipath_exit(void)
1285{ 1295{
1286 int r; 1296 int r;
1287 1297
1298 destroy_workqueue(kmultipathd);
1299
1288 r = dm_unregister_target(&multipath_target); 1300 r = dm_unregister_target(&multipath_target);
1289 if (r < 0) 1301 if (r < 0)
1290 DMERR("%s: target unregister failed %d", 1302 DMERR("%s: target unregister failed %d",
diff --git a/drivers/md/dm-path-selector.c b/drivers/md/dm-path-selector.c
index ac5c4bbec6c1..a28c1c2b4ef5 100644
--- a/drivers/md/dm-path-selector.c
+++ b/drivers/md/dm-path-selector.c
@@ -26,7 +26,7 @@ struct ps_internal {
26static LIST_HEAD(_path_selectors); 26static LIST_HEAD(_path_selectors);
27static DECLARE_RWSEM(_ps_lock); 27static DECLARE_RWSEM(_ps_lock);
28 28
29struct ps_internal *__find_path_selector_type(const char *name) 29static struct ps_internal *__find_path_selector_type(const char *name)
30{ 30{
31 struct ps_internal *psi; 31 struct ps_internal *psi;
32 32
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index ee175d4906c4..18e9b9953fcd 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -242,7 +242,7 @@ static void free_devices(struct list_head *devices)
242 } 242 }
243} 243}
244 244
245void table_destroy(struct dm_table *t) 245static void table_destroy(struct dm_table *t)
246{ 246{
247 unsigned int i; 247 unsigned int i;
248 248
diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c
index 7febc2cac73d..51c0639b2487 100644
--- a/drivers/md/dm-zero.c
+++ b/drivers/md/dm-zero.c
@@ -55,7 +55,7 @@ static struct target_type zero_target = {
55 .map = zero_map, 55 .map = zero_map,
56}; 56};
57 57
58int __init dm_zero_init(void) 58static int __init dm_zero_init(void)
59{ 59{
60 int r = dm_register_target(&zero_target); 60 int r = dm_register_target(&zero_target);
61 61
@@ -65,7 +65,7 @@ int __init dm_zero_init(void)
65 return r; 65 return r;
66} 66}
67 67
68void __exit dm_zero_exit(void) 68static void __exit dm_zero_exit(void)
69{ 69{
70 int r = dm_unregister_target(&zero_target); 70 int r = dm_unregister_target(&zero_target);
71 71
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 243ff6884e83..f6b03957efc7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -97,6 +97,7 @@ struct mapped_device {
97 * freeze/thaw support require holding onto a super block 97 * freeze/thaw support require holding onto a super block
98 */ 98 */
99 struct super_block *frozen_sb; 99 struct super_block *frozen_sb;
100 struct block_device *frozen_bdev;
100}; 101};
101 102
102#define MIN_IOS 256 103#define MIN_IOS 256
@@ -990,44 +991,50 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
990 */ 991 */
991static int __lock_fs(struct mapped_device *md) 992static int __lock_fs(struct mapped_device *md)
992{ 993{
993 struct block_device *bdev; 994 int error = -ENOMEM;
994 995
995 if (test_and_set_bit(DMF_FS_LOCKED, &md->flags)) 996 if (test_and_set_bit(DMF_FS_LOCKED, &md->flags))
996 return 0; 997 return 0;
997 998
998 bdev = bdget_disk(md->disk, 0); 999 md->frozen_bdev = bdget_disk(md->disk, 0);
999 if (!bdev) { 1000 if (!md->frozen_bdev) {
1000 DMWARN("bdget failed in __lock_fs"); 1001 DMWARN("bdget failed in __lock_fs");
1001 return -ENOMEM; 1002 goto out;
1002 } 1003 }
1003 1004
1004 WARN_ON(md->frozen_sb); 1005 WARN_ON(md->frozen_sb);
1005 md->frozen_sb = freeze_bdev(bdev); 1006
1007 md->frozen_sb = freeze_bdev(md->frozen_bdev);
1008 if (IS_ERR(md->frozen_sb)) {
1009 error = PTR_ERR(md->frozen_sb);
1010 goto out_bdput;
1011 }
1012
1006 /* don't bdput right now, we don't want the bdev 1013 /* don't bdput right now, we don't want the bdev
1007 * to go away while it is locked. We'll bdput 1014 * to go away while it is locked. We'll bdput
1008 * in __unlock_fs 1015 * in __unlock_fs
1009 */ 1016 */
1010 return 0; 1017 return 0;
1018
1019out_bdput:
1020 bdput(md->frozen_bdev);
1021 md->frozen_sb = NULL;
1022 md->frozen_bdev = NULL;
1023out:
1024 clear_bit(DMF_FS_LOCKED, &md->flags);
1025 return error;
1011} 1026}
1012 1027
1013static int __unlock_fs(struct mapped_device *md) 1028static void __unlock_fs(struct mapped_device *md)
1014{ 1029{
1015 struct block_device *bdev;
1016
1017 if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags)) 1030 if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags))
1018 return 0; 1031 return;
1019 1032
1020 bdev = bdget_disk(md->disk, 0); 1033 thaw_bdev(md->frozen_bdev, md->frozen_sb);
1021 if (!bdev) { 1034 bdput(md->frozen_bdev);
1022 DMWARN("bdget failed in __unlock_fs");
1023 return -ENOMEM;
1024 }
1025 1035
1026 thaw_bdev(bdev, md->frozen_sb);
1027 md->frozen_sb = NULL; 1036 md->frozen_sb = NULL;
1028 bdput(bdev); 1037 md->frozen_bdev = NULL;
1029 bdput(bdev);
1030 return 0;
1031} 1038}
1032 1039
1033/* 1040/*
@@ -1041,37 +1048,37 @@ int dm_suspend(struct mapped_device *md)
1041{ 1048{
1042 struct dm_table *map; 1049 struct dm_table *map;
1043 DECLARE_WAITQUEUE(wait, current); 1050 DECLARE_WAITQUEUE(wait, current);
1051 int error = -EINVAL;
1044 1052
1045 /* Flush I/O to the device. */ 1053 /* Flush I/O to the device. */
1046 down_read(&md->lock); 1054 down_read(&md->lock);
1047 if (test_bit(DMF_BLOCK_IO, &md->flags)) { 1055 if (test_bit(DMF_BLOCK_IO, &md->flags))
1048 up_read(&md->lock); 1056 goto out_read_unlock;
1049 return -EINVAL; 1057
1050 } 1058 error = __lock_fs(md);
1059 if (error)
1060 goto out_read_unlock;
1051 1061
1052 map = dm_get_table(md); 1062 map = dm_get_table(md);
1053 if (map) 1063 if (map)
1054 dm_table_presuspend_targets(map); 1064 dm_table_presuspend_targets(map);
1055 __lock_fs(md);
1056 1065
1057 up_read(&md->lock); 1066 up_read(&md->lock);
1058 1067
1059 /* 1068 /*
1060 * First we set the BLOCK_IO flag so no more ios will be 1069 * First we set the BLOCK_IO flag so no more ios will be mapped.
1061 * mapped. 1070 *
1071 * If the flag is already set we know another thread is trying to
1072 * suspend as well, so we leave the fs locked for this thread.
1062 */ 1073 */
1074 error = -EINVAL;
1063 down_write(&md->lock); 1075 down_write(&md->lock);
1064 if (test_bit(DMF_BLOCK_IO, &md->flags)) { 1076 if (test_and_set_bit(DMF_BLOCK_IO, &md->flags)) {
1065 /* 1077 if (map)
1066 * If we get here we know another thread is 1078 dm_table_put(map);
1067 * trying to suspend as well, so we leave the fs 1079 goto out_write_unlock;
1068 * locked for this thread.
1069 */
1070 up_write(&md->lock);
1071 return -EINVAL;
1072 } 1080 }
1073 1081
1074 set_bit(DMF_BLOCK_IO, &md->flags);
1075 add_wait_queue(&md->wait, &wait); 1082 add_wait_queue(&md->wait, &wait);
1076 up_write(&md->lock); 1083 up_write(&md->lock);
1077 1084
@@ -1099,12 +1106,9 @@ int dm_suspend(struct mapped_device *md)
1099 remove_wait_queue(&md->wait, &wait); 1106 remove_wait_queue(&md->wait, &wait);
1100 1107
1101 /* were we interrupted ? */ 1108 /* were we interrupted ? */
1102 if (atomic_read(&md->pending)) { 1109 error = -EINTR;
1103 __unlock_fs(md); 1110 if (atomic_read(&md->pending))
1104 clear_bit(DMF_BLOCK_IO, &md->flags); 1111 goto out_unfreeze;
1105 up_write(&md->lock);
1106 return -EINTR;
1107 }
1108 1112
1109 set_bit(DMF_SUSPENDED, &md->flags); 1113 set_bit(DMF_SUSPENDED, &md->flags);
1110 1114
@@ -1115,6 +1119,18 @@ int dm_suspend(struct mapped_device *md)
1115 up_write(&md->lock); 1119 up_write(&md->lock);
1116 1120
1117 return 0; 1121 return 0;
1122
1123out_unfreeze:
1124 /* FIXME Undo dm_table_presuspend_targets */
1125 __unlock_fs(md);
1126 clear_bit(DMF_BLOCK_IO, &md->flags);
1127out_write_unlock:
1128 up_write(&md->lock);
1129 return error;
1130
1131out_read_unlock:
1132 up_read(&md->lock);
1133 return error;
1118} 1134}
1119 1135
1120int dm_resume(struct mapped_device *md) 1136int dm_resume(struct mapped_device *md)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 97af857d8a88..d899204d3743 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -957,7 +957,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
957} 957}
958 958
959 959
960struct super_type super_types[] = { 960static struct super_type super_types[] = {
961 [0] = { 961 [0] = {
962 .name = "0.90.0", 962 .name = "0.90.0",
963 .owner = THIS_MODULE, 963 .owner = THIS_MODULE,
@@ -2740,7 +2740,7 @@ static struct block_device_operations md_fops =
2740 .revalidate_disk= md_revalidate, 2740 .revalidate_disk= md_revalidate,
2741}; 2741};
2742 2742
2743int md_thread(void * arg) 2743static int md_thread(void * arg)
2744{ 2744{
2745 mdk_thread_t *thread = arg; 2745 mdk_thread_t *thread = arg;
2746 2746
@@ -3232,7 +3232,7 @@ void md_handle_safemode(mddev_t *mddev)
3232} 3232}
3233 3233
3234 3234
3235DECLARE_WAIT_QUEUE_HEAD(resync_wait); 3235static DECLARE_WAIT_QUEUE_HEAD(resync_wait);
3236 3236
3237#define SYNC_MARKS 10 3237#define SYNC_MARKS 10
3238#define SYNC_MARK_STEP (3*HZ) 3238#define SYNC_MARK_STEP (3*HZ)
@@ -3575,8 +3575,8 @@ void md_check_recovery(mddev_t *mddev)
3575 } 3575 }
3576} 3576}
3577 3577
3578int md_notify_reboot(struct notifier_block *this, 3578static int md_notify_reboot(struct notifier_block *this,
3579 unsigned long code, void *x) 3579 unsigned long code, void *x)
3580{ 3580{
3581 struct list_head *tmp; 3581 struct list_head *tmp;
3582 mddev_t *mddev; 3582 mddev_t *mddev;
@@ -3599,7 +3599,7 @@ int md_notify_reboot(struct notifier_block *this,
3599 return NOTIFY_DONE; 3599 return NOTIFY_DONE;
3600} 3600}
3601 3601
3602struct notifier_block md_notifier = { 3602static struct notifier_block md_notifier = {
3603 .notifier_call = md_notify_reboot, 3603 .notifier_call = md_notify_reboot,
3604 .next = NULL, 3604 .next = NULL,
3605 .priority = INT_MAX, /* before any real devices */ 3605 .priority = INT_MAX, /* before any real devices */
@@ -3616,7 +3616,7 @@ static void md_geninit(void)
3616 p->proc_fops = &md_seq_fops; 3616 p->proc_fops = &md_seq_fops;
3617} 3617}
3618 3618
3619int __init md_init(void) 3619static int __init md_init(void)
3620{ 3620{
3621 int minor; 3621 int minor;
3622 3622
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index c9b134cd1532..4e4bfde3db5d 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -103,7 +103,8 @@ static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err)
103 mempool_free(mp_bh, conf->pool); 103 mempool_free(mp_bh, conf->pool);
104} 104}
105 105
106int multipath_end_request(struct bio *bio, unsigned int bytes_done, int error) 106static int multipath_end_request(struct bio *bio, unsigned int bytes_done,
107 int error)
107{ 108{
108 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 109 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
109 struct multipath_bh * mp_bh = (struct multipath_bh *)(bio->bi_private); 110 struct multipath_bh * mp_bh = (struct multipath_bh *)(bio->bi_private);
@@ -355,7 +356,7 @@ static int multipath_remove_disk(mddev_t *mddev, int number)
355 goto abort; 356 goto abort;
356 } 357 }
357 p->rdev = NULL; 358 p->rdev = NULL;
358 synchronize_kernel(); 359 synchronize_rcu();
359 if (atomic_read(&rdev->nr_pending)) { 360 if (atomic_read(&rdev->nr_pending)) {
360 /* lost the race, try later */ 361 /* lost the race, try later */
361 err = -EBUSY; 362 err = -EBUSY;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a389394b52f6..83380b5d6593 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -797,7 +797,7 @@ static int raid1_remove_disk(mddev_t *mddev, int number)
797 goto abort; 797 goto abort;
798 } 798 }
799 p->rdev = NULL; 799 p->rdev = NULL;
800 synchronize_kernel(); 800 synchronize_rcu();
801 if (atomic_read(&rdev->nr_pending)) { 801 if (atomic_read(&rdev->nr_pending)) {
802 /* lost the race, try later */ 802 /* lost the race, try later */
803 err = -EBUSY; 803 err = -EBUSY;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index b100bfe4fdca..e9dc2876a626 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -977,7 +977,7 @@ static int raid10_remove_disk(mddev_t *mddev, int number)
977 goto abort; 977 goto abort;
978 } 978 }
979 p->rdev = NULL; 979 p->rdev = NULL;
980 synchronize_kernel(); 980 synchronize_rcu();
981 if (atomic_read(&rdev->nr_pending)) { 981 if (atomic_read(&rdev->nr_pending)) {
982 /* lost the race, try later */ 982 /* lost the race, try later */
983 err = -EBUSY; 983 err = -EBUSY;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 52c3a81c4aa7..e96e2a10a9c9 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1873,7 +1873,7 @@ static int raid5_remove_disk(mddev_t *mddev, int number)
1873 goto abort; 1873 goto abort;
1874 } 1874 }
1875 p->rdev = NULL; 1875 p->rdev = NULL;
1876 synchronize_kernel(); 1876 synchronize_rcu();
1877 if (atomic_read(&rdev->nr_pending)) { 1877 if (atomic_read(&rdev->nr_pending)) {
1878 /* lost the race, try later */ 1878 /* lost the race, try later */
1879 err = -EBUSY; 1879 err = -EBUSY;
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 7e30ab29691a..8a33f351e092 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -2038,7 +2038,7 @@ static int raid6_remove_disk(mddev_t *mddev, int number)
2038 goto abort; 2038 goto abort;
2039 } 2039 }
2040 p->rdev = NULL; 2040 p->rdev = NULL;
2041 synchronize_kernel(); 2041 synchronize_rcu();
2042 if (atomic_read(&rdev->nr_pending)) { 2042 if (atomic_read(&rdev->nr_pending)) {
2043 /* lost the race, try later */ 2043 /* lost the race, try later */
2044 err = -EBUSY; 2044 err = -EBUSY;
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index 8c842e2f59a2..84a49d2ec919 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -131,10 +131,10 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
131 [ 18 ] = KEY_KP0, 131 [ 18 ] = KEY_KP0,
132 132
133 [ 0 ] = KEY_POWER, 133 [ 0 ] = KEY_POWER,
134// [ 27 ] = MTS button 134 [ 27 ] = KEY_LANGUAGE, //MTS button
135 [ 2 ] = KEY_TUNER, // TV/FM 135 [ 2 ] = KEY_TUNER, // TV/FM
136 [ 30 ] = KEY_VIDEO, 136 [ 30 ] = KEY_VIDEO,
137// [ 22 ] = display button 137 [ 22 ] = KEY_INFO, //display button
138 [ 4 ] = KEY_VOLUMEUP, 138 [ 4 ] = KEY_VOLUMEUP,
139 [ 8 ] = KEY_VOLUMEDOWN, 139 [ 8 ] = KEY_VOLUMEDOWN,
140 [ 12 ] = KEY_CHANNELUP, 140 [ 12 ] = KEY_CHANNELUP,
@@ -142,7 +142,7 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
142 [ 3 ] = KEY_ZOOM, // fullscreen 142 [ 3 ] = KEY_ZOOM, // fullscreen
143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext 143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext
144 [ 32 ] = KEY_SLEEP, 144 [ 32 ] = KEY_SLEEP,
145// [ 41 ] = boss key 145 [ 41 ] = KEY_SEARCH, //boss key
146 [ 20 ] = KEY_MUTE, 146 [ 20 ] = KEY_MUTE,
147 [ 43 ] = KEY_RED, 147 [ 43 ] = KEY_RED,
148 [ 44 ] = KEY_GREEN, 148 [ 44 ] = KEY_GREEN,
@@ -150,17 +150,17 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
150 [ 46 ] = KEY_BLUE, 150 [ 46 ] = KEY_BLUE,
151 [ 24 ] = KEY_KPPLUS, //fine tune + 151 [ 24 ] = KEY_KPPLUS, //fine tune +
152 [ 25 ] = KEY_KPMINUS, //fine tune - 152 [ 25 ] = KEY_KPMINUS, //fine tune -
153// [ 42 ] = picture in picture 153 [ 42 ] = KEY_ANGLE, //picture in picture
154 [ 33 ] = KEY_KPDOT, 154 [ 33 ] = KEY_KPDOT,
155 [ 19 ] = KEY_KPENTER, 155 [ 19 ] = KEY_KPENTER,
156// [ 17 ] = recall 156 [ 17 ] = KEY_AGAIN, //recall
157 [ 34 ] = KEY_BACK, 157 [ 34 ] = KEY_BACK,
158 [ 35 ] = KEY_PLAYPAUSE, 158 [ 35 ] = KEY_PLAYPAUSE,
159 [ 36 ] = KEY_NEXT, 159 [ 36 ] = KEY_NEXT,
160// [ 37 ] = time shifting 160 [ 37 ] = KEY_T, //time shifting
161 [ 38 ] = KEY_STOP, 161 [ 38 ] = KEY_STOP,
162 [ 39 ] = KEY_RECORD 162 [ 39 ] = KEY_RECORD,
163// [ 40 ] = snapshot 163 [ 40 ] = KEY_SHUFFLE //snapshot
164}; 164};
165EXPORT_SYMBOL_GPL(ir_codes_winfast); 165EXPORT_SYMBOL_GPL(ir_codes_winfast);
166 166
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 1930b513eefa..011860ce36cc 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -32,6 +32,7 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include "dvb_frontend.h" 34#include "dvb_frontend.h"
35#include "dvb-pll.h"
35#include "cx22702.h" 36#include "cx22702.h"
36 37
37 38
@@ -203,7 +204,19 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
203 204
204 /* set PLL */ 205 /* set PLL */
205 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe); 206 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
206 state->config->pll_set(fe, p); 207 if (state->config->pll_set) {
208 state->config->pll_set(fe, p);
209 } else if (state->config->pll_desc) {
210 u8 pllbuf[4];
211 struct i2c_msg msg = { .addr = state->config->pll_address,
212 .buf = pllbuf, .len = 4 };
213 dvb_pll_configure(state->config->pll_desc, pllbuf,
214 p->frequency,
215 p->u.ofdm.bandwidth);
216 i2c_transfer(state->i2c, &msg, 1);
217 } else {
218 BUG();
219 }
207 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1); 220 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
208 221
209 /* set inversion */ 222 /* set inversion */
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 6e34f997aba2..559fdb906669 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -36,6 +36,9 @@ struct cx22702_config
36 u8 demod_address; 36 u8 demod_address;
37 37
38 /* PLL maintenance */ 38 /* PLL maintenance */
39 u8 pll_address;
40 struct dvb_pll_desc *pll_desc;
41
39 int (*pll_init)(struct dvb_frontend* fe); 42 int (*pll_init)(struct dvb_frontend* fe);
40 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 43 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
41}; 44};
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c1b3542dad88..d3dd4228b72d 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -252,6 +252,7 @@ config VIDEO_SAA7134_DVB
252 depends on VIDEO_SAA7134 && DVB_CORE 252 depends on VIDEO_SAA7134 && DVB_CORE
253 select VIDEO_BUF_DVB 253 select VIDEO_BUF_DVB
254 select DVB_MT352 254 select DVB_MT352
255 select DVB_CX22702
255 ---help--- 256 ---help---
256 This adds support for DVB cards based on the 257 This adds support for DVB cards based on the
257 Philips saa7134 chip. 258 Philips saa7134 chip.
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index c13f222fe6bd..033cc5498f23 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -3169,7 +3169,7 @@ static struct video_device radio_template =
3169/* ----------------------------------------------------------------------- */ 3169/* ----------------------------------------------------------------------- */
3170/* some debug code */ 3170/* some debug code */
3171 3171
3172int bttv_risc_decode(u32 risc) 3172static int bttv_risc_decode(u32 risc)
3173{ 3173{
3174 static char *instr[16] = { 3174 static char *instr[16] = {
3175 [ BT848_RISC_WRITE >> 28 ] = "write", 3175 [ BT848_RISC_WRITE >> 28 ] = "write",
@@ -3206,8 +3206,8 @@ int bttv_risc_decode(u32 risc)
3206 return incr[risc >> 28] ? incr[risc >> 28] : 1; 3206 return incr[risc >> 28] ? incr[risc >> 28] : 1;
3207} 3207}
3208 3208
3209void bttv_risc_disasm(struct bttv *btv, 3209static void bttv_risc_disasm(struct bttv *btv,
3210 struct btcx_riscmem *risc) 3210 struct btcx_riscmem *risc)
3211{ 3211{
3212 unsigned int i,j,n; 3212 unsigned int i,j,n;
3213 3213
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index e42f1ec13f3e..e3f477dff827 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -29,6 +29,7 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/jiffies.h>
32#include <asm/io.h> 33#include <asm/io.h>
33 34
34#include "bttvp.h" 35#include "bttvp.h"
@@ -130,17 +131,14 @@ static u32 functionality(struct i2c_adapter *adap)
130static int 131static int
131bttv_i2c_wait_done(struct bttv *btv) 132bttv_i2c_wait_done(struct bttv *btv)
132{ 133{
133 DECLARE_WAITQUEUE(wait, current);
134 int rc = 0; 134 int rc = 0;
135 135
136 add_wait_queue(&btv->i2c_queue, &wait); 136 /* timeout */
137 if (0 == btv->i2c_done) 137 if (wait_event_interruptible_timeout(btv->i2c_queue,
138 msleep_interruptible(20); 138 btv->i2c_done, msecs_to_jiffies(85)) == -ERESTARTSYS)
139 remove_wait_queue(&btv->i2c_queue, &wait); 139
140 rc = -EIO;
140 141
141 if (0 == btv->i2c_done)
142 /* timeout */
143 rc = -EIO;
144 if (btv->i2c_done & BT848_INT_RACK) 142 if (btv->i2c_done & BT848_INT_RACK)
145 rc = 1; 143 rc = 1;
146 btv->i2c_done = 0; 144 btv->i2c_done = 0;
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 26a6138015cb..1ff79b5a8835 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -429,7 +429,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
429/* ------------------------------------------------------------------ */ 429/* ------------------------------------------------------------------ */
430/* debug helper code */ 430/* debug helper code */
431 431
432int cx88_risc_decode(u32 risc) 432static int cx88_risc_decode(u32 risc)
433{ 433{
434 static char *instr[16] = { 434 static char *instr[16] = {
435 [ RISC_SYNC >> 28 ] = "sync", 435 [ RISC_SYNC >> 28 ] = "sync",
@@ -542,7 +542,7 @@ void cx88_sram_channel_dump(struct cx88_core *core,
542 core->name,cx_read(ch->cnt2_reg)); 542 core->name,cx_read(ch->cnt2_reg));
543} 543}
544 544
545char *cx88_pci_irqs[32] = { 545static char *cx88_pci_irqs[32] = {
546 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", 546 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
547 "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err", 547 "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
548 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err", 548 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
@@ -1206,7 +1206,6 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1206/* ------------------------------------------------------------------ */ 1206/* ------------------------------------------------------------------ */
1207 1207
1208EXPORT_SYMBOL(cx88_print_ioctl); 1208EXPORT_SYMBOL(cx88_print_ioctl);
1209EXPORT_SYMBOL(cx88_pci_irqs);
1210EXPORT_SYMBOL(cx88_vid_irqs); 1209EXPORT_SYMBOL(cx88_vid_irqs);
1211EXPORT_SYMBOL(cx88_mpeg_irqs); 1210EXPORT_SYMBOL(cx88_mpeg_irqs);
1212EXPORT_SYMBOL(cx88_print_irqbits); 1211EXPORT_SYMBOL(cx88_print_irqbits);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index bc6f18c45357..9d15d3d5a2b7 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -31,7 +31,7 @@
31#include <linux/suspend.h> 31#include <linux/suspend.h>
32 32
33/* those two frontends need merging via linuxtv cvs ... */ 33/* those two frontends need merging via linuxtv cvs ... */
34#define HAVE_CX22702 0 34#define HAVE_CX22702 1
35#define HAVE_OR51132 1 35#define HAVE_OR51132 1
36 36
37#include "cx88.h" 37#include "cx88.h"
@@ -91,7 +91,7 @@ static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb
91 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb); 91 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
92} 92}
93 93
94struct videobuf_queue_ops dvb_qops = { 94static struct videobuf_queue_ops dvb_qops = {
95 .buf_setup = dvb_buf_setup, 95 .buf_setup = dvb_buf_setup,
96 .buf_prepare = dvb_buf_prepare, 96 .buf_prepare = dvb_buf_prepare,
97 .buf_queue = dvb_buf_queue, 97 .buf_queue = dvb_buf_queue,
@@ -191,7 +191,7 @@ static int or51132_set_ts_param(struct dvb_frontend* fe,
191 return 0; 191 return 0;
192} 192}
193 193
194struct or51132_config pchdtv_hd3000 = { 194static struct or51132_config pchdtv_hd3000 = {
195 .demod_address = 0x15, 195 .demod_address = 0x15,
196 .pll_address = 0x61, 196 .pll_address = 0x61,
197 .pll_desc = &dvb_pll_thomson_dtt7610, 197 .pll_desc = &dvb_pll_thomson_dtt7610,
@@ -243,10 +243,8 @@ static int dvb_register(struct cx8802_dev *dev)
243 break; 243 break;
244#endif 244#endif
245 default: 245 default:
246 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n" 246 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
247 "%s: you might want to look out for patches here:\n" 247 dev->core->name);
248 "%s: http://dl.bytesex.org/patches/\n",
249 dev->core->name, dev->core->name, dev->core->name);
250 break; 248 break;
251 } 249 }
252 if (NULL == dev->dvb.frontend) { 250 if (NULL == dev->dvb.frontend) {
@@ -308,9 +306,11 @@ static int __devinit dvb_probe(struct pci_dev *pci_dev,
308 dev); 306 dev);
309 err = dvb_register(dev); 307 err = dvb_register(dev);
310 if (0 != err) 308 if (0 != err)
311 goto fail_free; 309 goto fail_fini;
312 return 0; 310 return 0;
313 311
312 fail_fini:
313 cx8802_fini_common(dev);
314 fail_free: 314 fail_free:
315 kfree(dev); 315 kfree(dev);
316 fail_core: 316 fail_core:
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 60800172c026..0725b1288f4f 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -45,7 +45,7 @@ MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
45 45
46/* ----------------------------------------------------------------------- */ 46/* ----------------------------------------------------------------------- */
47 47
48void cx8800_bit_setscl(void *data, int state) 48static void cx8800_bit_setscl(void *data, int state)
49{ 49{
50 struct cx88_core *core = data; 50 struct cx88_core *core = data;
51 51
@@ -57,7 +57,7 @@ void cx8800_bit_setscl(void *data, int state)
57 cx_read(MO_I2C); 57 cx_read(MO_I2C);
58} 58}
59 59
60void cx8800_bit_setsda(void *data, int state) 60static void cx8800_bit_setsda(void *data, int state)
61{ 61{
62 struct cx88_core *core = data; 62 struct cx88_core *core = data;
63 63
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 471e508b0746..0584ff476387 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -46,9 +46,9 @@ void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f)
46 } 46 }
47} 47}
48 48
49int cx8800_start_vbi_dma(struct cx8800_dev *dev, 49static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
50 struct cx88_dmaqueue *q, 50 struct cx88_dmaqueue *q,
51 struct cx88_buffer *buf) 51 struct cx88_buffer *buf)
52{ 52{
53 struct cx88_core *core = dev->core; 53 struct cx88_core *core = dev->core;
54 54
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 701f594e1816..d1f5c92f0ce5 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -325,7 +325,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
325 .shift = 0, 325 .shift = 0,
326 } 326 }
327}; 327};
328const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); 328static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
329 329
330/* ------------------------------------------------------------------- */ 330/* ------------------------------------------------------------------- */
331/* resource management */ 331/* resource management */
@@ -665,7 +665,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
665 cx88_free_buffer(fh->dev->pci,buf); 665 cx88_free_buffer(fh->dev->pci,buf);
666} 666}
667 667
668struct videobuf_queue_ops cx8800_video_qops = { 668static struct videobuf_queue_ops cx8800_video_qops = {
669 .buf_setup = buffer_setup, 669 .buf_setup = buffer_setup,
670 .buf_prepare = buffer_prepare, 670 .buf_prepare = buffer_prepare,
671 .buf_queue = buffer_queue, 671 .buf_queue = buffer_queue,
@@ -1924,7 +1924,7 @@ static struct file_operations video_fops =
1924 .llseek = no_llseek, 1924 .llseek = no_llseek,
1925}; 1925};
1926 1926
1927struct video_device cx8800_video_template = 1927static struct video_device cx8800_video_template =
1928{ 1928{
1929 .name = "cx8800-video", 1929 .name = "cx8800-video",
1930 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES, 1930 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES,
@@ -1933,7 +1933,7 @@ struct video_device cx8800_video_template =
1933 .minor = -1, 1933 .minor = -1,
1934}; 1934};
1935 1935
1936struct video_device cx8800_vbi_template = 1936static struct video_device cx8800_vbi_template =
1937{ 1937{
1938 .name = "cx8800-vbi", 1938 .name = "cx8800-vbi",
1939 .type = VID_TYPE_TELETEXT|VID_TYPE_TUNER, 1939 .type = VID_TYPE_TELETEXT|VID_TYPE_TUNER,
@@ -1951,7 +1951,7 @@ static struct file_operations radio_fops =
1951 .llseek = no_llseek, 1951 .llseek = no_llseek,
1952}; 1952};
1953 1953
1954struct video_device cx8800_radio_template = 1954static struct video_device cx8800_radio_template =
1955{ 1955{
1956 .name = "cx8800-radio", 1956 .name = "cx8800-radio",
1957 .type = VID_TYPE_TUNER, 1957 .type = VID_TYPE_TUNER,
@@ -2226,7 +2226,7 @@ static int cx8800_resume(struct pci_dev *pci_dev)
2226 2226
2227/* ----------------------------------------------------------- */ 2227/* ----------------------------------------------------------- */
2228 2228
2229struct pci_device_id cx8800_pci_tbl[] = { 2229static struct pci_device_id cx8800_pci_tbl[] = {
2230 { 2230 {
2231 .vendor = 0x14f1, 2231 .vendor = 0x14f1,
2232 .device = 0x8800, 2232 .device = 0x8800,
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index b351d9eae615..88eaaaba5ad8 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -420,7 +420,6 @@ struct cx8802_dev {
420/* ----------------------------------------------------------- */ 420/* ----------------------------------------------------------- */
421/* cx88-core.c */ 421/* cx88-core.c */
422 422
423extern char *cx88_pci_irqs[32];
424extern char *cx88_vid_irqs[32]; 423extern char *cx88_vid_irqs[32];
425extern char *cx88_mpeg_irqs[32]; 424extern char *cx88_mpeg_irqs[32];
426extern void cx88_print_irqbits(char *name, char *tag, char **strings, 425extern void cx88_print_irqbits(char *name, char *tag, char **strings,
@@ -472,9 +471,6 @@ extern void cx88_core_put(struct cx88_core *core,
472/* cx88-vbi.c */ 471/* cx88-vbi.c */
473 472
474void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f); 473void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f);
475int cx8800_start_vbi_dma(struct cx8800_dev *dev,
476 struct cx88_dmaqueue *q,
477 struct cx88_buffer *buf);
478int cx8800_stop_vbi_dma(struct cx8800_dev *dev); 474int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
479int cx8800_restart_vbi_queue(struct cx8800_dev *dev, 475int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
480 struct cx88_dmaqueue *q); 476 struct cx88_dmaqueue *q);
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index c97df705df5e..7fbb8581a87d 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -380,7 +380,9 @@ static void msp3400c_setvolume(struct i2c_client *client,
380 int val = 0, bal = 0; 380 int val = 0, bal = 0;
381 381
382 if (!muted) { 382 if (!muted) {
383 val = (volume * 0x7F / 65535) << 8; 383 /* 0x7f instead if 0x73 here has sound quality issues,
384 * probably due to overmodulation + clipping ... */
385 val = (volume * 0x73 / 65535) << 8;
384 } 386 }
385 if (val) { 387 if (val) {
386 bal = (balance / 256) - 128; 388 bal = (balance / 256) - 128;
@@ -997,7 +999,13 @@ static int msp34xx_modus(int norm)
997{ 999{
998 switch (norm) { 1000 switch (norm) {
999 case VIDEO_MODE_PAL: 1001 case VIDEO_MODE_PAL:
1002#if 1
1003 /* experimental: not sure this works with all chip versions */
1004 return 0x7003;
1005#else
1006 /* previous value, try this if it breaks ... */
1000 return 0x1003; 1007 return 0x1003;
1008#endif
1001 case VIDEO_MODE_NTSC: /* BTSC */ 1009 case VIDEO_MODE_NTSC: /* BTSC */
1002 return 0x2003; 1010 return 0x2003;
1003 case VIDEO_MODE_SECAM: 1011 case VIDEO_MODE_SECAM:
@@ -1264,6 +1272,7 @@ static int msp34xxg_thread(void *data)
1264 int val, std, i; 1272 int val, std, i;
1265 1273
1266 printk("msp34xxg: daemon started\n"); 1274 printk("msp34xxg: daemon started\n");
1275 msp->source = 1; /* default */
1267 for (;;) { 1276 for (;;) {
1268 d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n"); 1277 d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n");
1269 msp34xx_sleep(msp,-1); 1278 msp34xx_sleep(msp,-1);
@@ -1334,8 +1343,9 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
1334 1343
1335 /* fix matrix mode to stereo and let the msp choose what 1344 /* fix matrix mode to stereo and let the msp choose what
1336 * to output according to 'source', as recommended 1345 * to output according to 'source', as recommended
1346 * for MONO (source==0) downmixing set bit[7:0] to 0x30
1337 */ 1347 */
1338 int value = (source&0x07)<<8|(source==0 ? 0x00:0x20); 1348 int value = (source&0x07)<<8|(source==0 ? 0x30:0x20);
1339 dprintk("msp34xxg: set source to %d (0x%x)\n", source, value); 1349 dprintk("msp34xxg: set source to %d (0x%x)\n", source, value);
1340 msp3400c_write(client, 1350 msp3400c_write(client,
1341 I2C_MSP3400C_DFP, 1351 I2C_MSP3400C_DFP,
@@ -1359,7 +1369,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
1359 msp3400c_write(client, 1369 msp3400c_write(client,
1360 I2C_MSP3400C_DEM, 1370 I2C_MSP3400C_DEM,
1361 0x22, /* a2 threshold for stereo/bilingual */ 1371 0x22, /* a2 threshold for stereo/bilingual */
1362 source==0 ? 0x7f0:stereo_threshold); 1372 stereo_threshold);
1363 msp->source=source; 1373 msp->source=source;
1364} 1374}
1365 1375
@@ -1394,7 +1404,7 @@ static void msp34xxg_detect_stereo(struct i2c_client *client)
1394static void msp34xxg_set_audmode(struct i2c_client *client, int audmode) 1404static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
1395{ 1405{
1396 struct msp3400c *msp = i2c_get_clientdata(client); 1406 struct msp3400c *msp = i2c_get_clientdata(client);
1397 int source = 0; 1407 int source;
1398 1408
1399 switch (audmode) { 1409 switch (audmode) {
1400 case V4L2_TUNER_MODE_MONO: 1410 case V4L2_TUNER_MODE_MONO:
@@ -1410,9 +1420,10 @@ static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
1410 case V4L2_TUNER_MODE_LANG2: 1420 case V4L2_TUNER_MODE_LANG2:
1411 source=4; /* stereo or B */ 1421 source=4; /* stereo or B */
1412 break; 1422 break;
1413 default: /* doing nothing: a safe, sane default */ 1423 default:
1414 audmode = 0; 1424 audmode = 0;
1415 return; 1425 source = 1;
1426 break;
1416 } 1427 }
1417 msp->audmode = audmode; 1428 msp->audmode = audmode;
1418 msp34xxg_set_source(client, source); 1429 msp34xxg_set_source(client, source);
@@ -1514,12 +1525,9 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
1514 1525
1515 msp->opmode = opmode; 1526 msp->opmode = opmode;
1516 if (OPMODE_AUTO == msp->opmode) { 1527 if (OPMODE_AUTO == msp->opmode) {
1517#if 0 /* seems to work for ivtv only, disable by default for now ... */
1518 if (HAVE_SIMPLER(msp)) 1528 if (HAVE_SIMPLER(msp))
1519 msp->opmode = OPMODE_SIMPLER; 1529 msp->opmode = OPMODE_SIMPLER;
1520 else 1530 else if (HAVE_SIMPLE(msp))
1521#endif
1522 if (HAVE_SIMPLE(msp))
1523 msp->opmode = OPMODE_SIMPLE; 1531 msp->opmode = OPMODE_SIMPLE;
1524 else 1532 else
1525 msp->opmode = OPMODE_MANUAL; 1533 msp->opmode = OPMODE_MANUAL;
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index cee13584c9cf..fe6abe34168c 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -32,9 +32,32 @@ MODULE_LICENSE("GPL");
32static struct i2c_driver driver; 32static struct i2c_driver driver;
33static struct i2c_client client_template; 33static struct i2c_client client_template;
34 34
35enum saa6752hs_videoformat {
36 SAA6752HS_VF_D1 = 0, /* standard D1 video format: 720x576 */
37 SAA6752HS_VF_2_3_D1 = 1,/* 2/3D1 video format: 480x576 */
38 SAA6752HS_VF_1_2_D1 = 2,/* 1/2D1 video format: 352x576 */
39 SAA6752HS_VF_SIF = 3, /* SIF video format: 352x288 */
40 SAA6752HS_VF_UNKNOWN,
41};
42
43static const struct v4l2_format v4l2_format_table[] =
44{
45 [SAA6752HS_VF_D1] = {
46 .fmt.pix.width = 720, .fmt.pix.height = 576 },
47 [SAA6752HS_VF_2_3_D1] = {
48 .fmt.pix.width = 480, .fmt.pix.height = 576 },
49 [SAA6752HS_VF_1_2_D1] = {
50 .fmt.pix.width = 352, .fmt.pix.height = 576 },
51 [SAA6752HS_VF_SIF] = {
52 .fmt.pix.width = 352, .fmt.pix.height = 288 },
53 [SAA6752HS_VF_UNKNOWN] = {
54 .fmt.pix.width = 0, .fmt.pix.height = 0},
55};
56
35struct saa6752hs_state { 57struct saa6752hs_state {
36 struct i2c_client client; 58 struct i2c_client client;
37 struct v4l2_mpeg_compression params; 59 struct v4l2_mpeg_compression params;
60 enum saa6752hs_videoformat video_format;
38}; 61};
39 62
40enum saa6752hs_command { 63enum saa6752hs_command {
@@ -256,6 +279,51 @@ static int saa6752hs_set_bitrate(struct i2c_client* client,
256 return 0; 279 return 0;
257} 280}
258 281
282static void saa6752hs_set_subsampling(struct i2c_client* client,
283 struct v4l2_format* f)
284{
285 struct saa6752hs_state *h = i2c_get_clientdata(client);
286 int dist_352, dist_480, dist_720;
287
288 /*
289 FIXME: translate and round width/height into EMPRESS
290 subsample type:
291
292 type | PAL | NTSC
293 ---------------------------
294 SIF | 352x288 | 352x240
295 1/2 D1 | 352x576 | 352x480
296 2/3 D1 | 480x576 | 480x480
297 D1 | 720x576 | 720x480
298 */
299
300 dist_352 = abs(f->fmt.pix.width - 352);
301 dist_480 = abs(f->fmt.pix.width - 480);
302 dist_720 = abs(f->fmt.pix.width - 720);
303 if (dist_720 < dist_480) {
304 f->fmt.pix.width = 720;
305 f->fmt.pix.height = 576;
306 h->video_format = SAA6752HS_VF_D1;
307 }
308 else if (dist_480 < dist_352) {
309 f->fmt.pix.width = 480;
310 f->fmt.pix.height = 576;
311 h->video_format = SAA6752HS_VF_2_3_D1;
312 }
313 else {
314 f->fmt.pix.width = 352;
315 if (abs(f->fmt.pix.height - 576) <
316 abs(f->fmt.pix.height - 288)) {
317 f->fmt.pix.height = 576;
318 h->video_format = SAA6752HS_VF_1_2_D1;
319 }
320 else {
321 f->fmt.pix.height = 288;
322 h->video_format = SAA6752HS_VF_SIF;
323 }
324 }
325}
326
259 327
260static void saa6752hs_set_params(struct i2c_client* client, 328static void saa6752hs_set_params(struct i2c_client* client,
261 struct v4l2_mpeg_compression* params) 329 struct v4l2_mpeg_compression* params)
@@ -315,7 +383,7 @@ static int saa6752hs_init(struct i2c_client* client)
315 383
316 // Set video format - must be done first as it resets other settings 384 // Set video format - must be done first as it resets other settings
317 buf[0] = 0x41; 385 buf[0] = 0x41;
318 buf[1] = 0 /* MPEG_VIDEO_FORMAT_D1 */; 386 buf[1] = h->video_format;
319 i2c_master_send(client, buf, 2); 387 i2c_master_send(client, buf, 2);
320 388
321 // set bitrate 389 // set bitrate
@@ -494,6 +562,25 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
494 case VIDIOC_G_MPEGCOMP: 562 case VIDIOC_G_MPEGCOMP:
495 *params = h->params; 563 *params = h->params;
496 break; 564 break;
565 case VIDIOC_G_FMT:
566 {
567 struct v4l2_format *f = arg;
568
569 if (h->video_format == SAA6752HS_VF_UNKNOWN)
570 h->video_format = SAA6752HS_VF_D1;
571 f->fmt.pix.width =
572 v4l2_format_table[h->video_format].fmt.pix.width;
573 f->fmt.pix.height =
574 v4l2_format_table[h->video_format].fmt.pix.height;
575 break ;
576 }
577 case VIDIOC_S_FMT:
578 {
579 struct v4l2_format *f = arg;
580
581 saa6752hs_set_subsampling(client, f);
582 break;
583 }
497 default: 584 default:
498 /* nothing */ 585 /* nothing */
499 break; 586 break;
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 180d3175ea5b..c51eb7f078d3 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -183,12 +183,12 @@ struct saa7134_board saa7134_boards[] = {
183 .name = "LifeView FlyTV Platinum FM", 183 .name = "LifeView FlyTV Platinum FM",
184 .audio_clock = 0x00200000, 184 .audio_clock = 0x00200000,
185 .tuner_type = TUNER_PHILIPS_TDA8290, 185 .tuner_type = TUNER_PHILIPS_TDA8290,
186// .gpiomask = 0xe000, 186 .gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */
187 .inputs = {{ 187 .inputs = {{
188 .name = name_tv, 188 .name = name_tv,
189 .vmux = 1, 189 .vmux = 1,
190 .amux = TV, 190 .amux = TV,
191// .gpio = 0x0000, 191 .gpio = 0x10000, /* GP16=1 selects TV input */
192 .tv = 1, 192 .tv = 1,
193 },{ 193 },{
194/* .name = name_tv_mono, 194/* .name = name_tv_mono,
@@ -212,12 +212,12 @@ struct saa7134_board saa7134_boards[] = {
212 .amux = LINE2, 212 .amux = LINE2,
213// .gpio = 0x4000, 213// .gpio = 0x4000,
214 }}, 214 }},
215/* .radio = { 215 .radio = {
216 .name = name_radio, 216 .name = name_radio,
217 .amux = LINE2, 217 .amux = TV,
218 .gpio = 0x2000, 218 .gpio = 0x00000, /* GP16=0 selects FM radio antenna */
219 }, 219 },
220*/ }, 220 },
221 [SAA7134_BOARD_EMPRESS] = { 221 [SAA7134_BOARD_EMPRESS] = {
222 /* "Gert Vervoort" <gert.vervoort@philips.com> */ 222 /* "Gert Vervoort" <gert.vervoort@philips.com> */
223 .name = "EMPRESS", 223 .name = "EMPRESS",
@@ -1628,11 +1628,17 @@ struct pci_device_id saa7134_pci_tbl[] = {
1628 },{ 1628 },{
1629 .vendor = PCI_VENDOR_ID_PHILIPS, 1629 .vendor = PCI_VENDOR_ID_PHILIPS,
1630 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 1630 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1631 .subvendor = 0x5168, 1631 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
1632 .subdevice = 0x0214, /* Standard PCI, LR214WF */ 1632 .subdevice = 0x0214, /* Standard PCI, LR214WF */
1633 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, 1633 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
1634 },{ 1634 },{
1635 .vendor = PCI_VENDOR_ID_PHILIPS, 1635 .vendor = PCI_VENDOR_ID_PHILIPS,
1636 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1637 .subvendor = 0x1489, /* KYE */
1638 .subdevice = 0x0214, /* Genius VideoWonder ProTV */
1639 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, /* is an LR214WF actually */
1640 },{
1641 .vendor = PCI_VENDOR_ID_PHILIPS,
1636 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 1642 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1637 .subvendor = 0x16be, 1643 .subvendor = 0x16be,
1638 .subdevice = 0x0003, 1644 .subdevice = 0x0003,
@@ -1948,6 +1954,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
1948 dev->has_remote = 1; 1954 dev->has_remote = 1;
1949 board_flyvideo(dev); 1955 board_flyvideo(dev);
1950 break; 1956 break;
1957 case SAA7134_BOARD_FLYTVPLATINUM_FM:
1951 case SAA7134_BOARD_CINERGY400: 1958 case SAA7134_BOARD_CINERGY400:
1952 case SAA7134_BOARD_CINERGY600: 1959 case SAA7134_BOARD_CINERGY600:
1953 case SAA7134_BOARD_CINERGY600_MK3: 1960 case SAA7134_BOARD_CINERGY600_MK3:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index dd4a6c8ee65f..c2873ae029f9 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -172,7 +172,7 @@ static int fe_request_firmware(struct dvb_frontend* fe,
172 return request_firmware(fw, name, &dev->pci->dev); 172 return request_firmware(fw, name, &dev->pci->dev);
173} 173}
174 174
175struct tda1004x_config medion_cardbus = { 175static struct tda1004x_config medion_cardbus = {
176 .demod_address = 0x08, /* not sure this is correct */ 176 .demod_address = 0x08, /* not sure this is correct */
177 .invert = 0, 177 .invert = 0,
178 .invert_oclk = 0, 178 .invert_oclk = 0,
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 2021e099e35a..fa1357336907 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -233,10 +233,7 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
233 memset(f,0,sizeof(*f)); 233 memset(f,0,sizeof(*f));
234 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 234 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
235 235
236 /* FIXME: translate subsampling type EMPRESS into 236 saa7134_i2c_call_clients(dev, cmd, arg);
237 * width/height: */
238 f->fmt.pix.width = 720; /* D1 */
239 f->fmt.pix.height = 576;
240 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 237 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
241 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; 238 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
242 return 0; 239 return 0;
@@ -249,20 +246,7 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
249 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 246 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
250 return -EINVAL; 247 return -EINVAL;
251 248
252 /* 249 saa7134_i2c_call_clients(dev, cmd, arg);
253 FIXME: translate and round width/height into EMPRESS
254 subsample type:
255
256 type | PAL | NTSC
257 ---------------------------
258 SIF | 352x288 | 352x240
259 1/2 D1 | 352x576 | 352x480
260 2/3 D1 | 480x576 | 480x480
261 D1 | 720x576 | 720x480
262 */
263
264 f->fmt.pix.width = 720; /* D1 */
265 f->fmt.pix.height = 576;
266 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 250 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
267 f->fmt.pix.sizeimage = TS_PACKET_SIZE* dev->ts.nr_packets; 251 f->fmt.pix.sizeimage = TS_PACKET_SIZE* dev->ts.nr_packets;
268 return 0; 252 return 0;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 727d437e07df..ca50cf531f20 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -379,6 +379,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
379 switch (dev->board) { 379 switch (dev->board) {
380 case SAA7134_BOARD_FLYVIDEO2000: 380 case SAA7134_BOARD_FLYVIDEO2000:
381 case SAA7134_BOARD_FLYVIDEO3000: 381 case SAA7134_BOARD_FLYVIDEO3000:
382 case SAA7134_BOARD_FLYTVPLATINUM_FM:
382 ir_codes = flyvideo_codes; 383 ir_codes = flyvideo_codes;
383 mask_keycode = 0xEC00000; 384 mask_keycode = 0xEC00000;
384 mask_keydown = 0x0040000; 385 mask_keydown = 0x0040000;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 881a0539fc17..6212388edb75 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -357,8 +357,16 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
357 V4L2_TUNER_RADIO != t->mode) 357 V4L2_TUNER_RADIO != t->mode)
358 set_tv_freq(client,400*16); 358 set_tv_freq(client,400*16);
359 t->mode = f->type; 359 t->mode = f->type;
360 t->freq = f->frequency; 360 set_freq(client,f->frequency);
361 set_freq(client,t->freq); 361 break;
362 }
363 case VIDIOC_G_FREQUENCY:
364 {
365 struct v4l2_frequency *f = arg;
366
367 SWITCH_V4L2;
368 f->type = t->mode;
369 f->frequency = t->freq;
362 break; 370 break;
363 } 371 }
364 case VIDIOC_G_TUNER: 372 case VIDIOC_G_TUNER:
@@ -368,6 +376,8 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
368 SWITCH_V4L2; 376 SWITCH_V4L2;
369 if (V4L2_TUNER_RADIO == t->mode && t->has_signal) 377 if (V4L2_TUNER_RADIO == t->mode && t->has_signal)
370 tuner->signal = t->has_signal(client); 378 tuner->signal = t->has_signal(client);
379 tuner->rangelow = tv_range[0] * 16;
380 tuner->rangehigh = tv_range[1] * 16;
371 break; 381 break;
372 } 382 }
373 default: 383 default:
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 065eb4007b1d..80dc34f18c2c 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -991,7 +991,7 @@ static int tda9874a_initialize(struct CHIPSTATE *chip)
991{ 991{
992 if (tda9874a_SIF > 2) 992 if (tda9874a_SIF > 2)
993 tda9874a_SIF = 1; 993 tda9874a_SIF = 1;
994 if (tda9874a_STD >= 8) 994 if (tda9874a_STD > 8)
995 tda9874a_STD = 0; 995 tda9874a_STD = 0;
996 if(tda9874a_AMSEL > 1) 996 if(tda9874a_AMSEL > 1)
997 tda9874a_AMSEL = 0; 997 tda9874a_AMSEL = 0;
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 72f2b466b816..2e70d74fbdee 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,7 +51,7 @@ config MMC_PXA
51 51
52config MMC_WBSD 52config MMC_WBSD
53 tristate "Winbond W83L51xD SD/MMC Card Interface support" 53 tristate "Winbond W83L51xD SD/MMC Card Interface support"
54 depends on MMC && ISA 54 depends on MMC && ISA && ISA_DMA_API
55 help 55 help
56 This selects the Winbond(R) W83L51xD Secure digital and 56 This selects the Winbond(R) W83L51xD Secure digital and
57 Multimedia card Interface. 57 Multimedia card Interface.
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 43e2ac532f82..b5e076043431 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1581,7 +1581,8 @@ vortex_up(struct net_device *dev)
1581 1581
1582 if (VORTEX_PCI(vp)) { 1582 if (VORTEX_PCI(vp)) {
1583 pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ 1583 pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */
1584 pci_restore_state(VORTEX_PCI(vp)); 1584 if (vp->pm_state_valid)
1585 pci_restore_state(VORTEX_PCI(vp));
1585 pci_enable_device(VORTEX_PCI(vp)); 1586 pci_enable_device(VORTEX_PCI(vp));
1586 } 1587 }
1587 1588
@@ -2741,6 +2742,7 @@ vortex_down(struct net_device *dev, int final_down)
2741 outl(0, ioaddr + DownListPtr); 2742 outl(0, ioaddr + DownListPtr);
2742 2743
2743 if (final_down && VORTEX_PCI(vp)) { 2744 if (final_down && VORTEX_PCI(vp)) {
2745 vp->pm_state_valid = 1;
2744 pci_save_state(VORTEX_PCI(vp)); 2746 pci_save_state(VORTEX_PCI(vp));
2745 acpi_set_WOL(dev); 2747 acpi_set_WOL(dev);
2746 } 2748 }
@@ -3243,9 +3245,10 @@ static void acpi_set_WOL(struct net_device *dev)
3243 outw(RxEnable, ioaddr + EL3_CMD); 3245 outw(RxEnable, ioaddr + EL3_CMD);
3244 3246
3245 pci_enable_wake(VORTEX_PCI(vp), 0, 1); 3247 pci_enable_wake(VORTEX_PCI(vp), 0, 1);
3248
3249 /* Change the power state to D3; RxEnable doesn't take effect. */
3250 pci_set_power_state(VORTEX_PCI(vp), PCI_D3hot);
3246 } 3251 }
3247 /* Change the power state to D3; RxEnable doesn't take effect. */
3248 pci_set_power_state(VORTEX_PCI(vp), PCI_D3hot);
3249} 3252}
3250 3253
3251 3254
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 68242bda4b9c..3a0a55b62aaf 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -589,7 +589,7 @@ config EL2
589 589
590config ELPLUS 590config ELPLUS
591 tristate "3c505 \"EtherLink Plus\" support" 591 tristate "3c505 \"EtherLink Plus\" support"
592 depends on NET_VENDOR_3COM && ISA 592 depends on NET_VENDOR_3COM && ISA && ISA_DMA_API
593 ---help--- 593 ---help---
594 Information about this network (Ethernet) card can be found in 594 Information about this network (Ethernet) card can be found in
595 <file:Documentation/networking/3c505.txt>. If you have a card of 595 <file:Documentation/networking/3c505.txt>. If you have a card of
@@ -630,7 +630,7 @@ config EL3
630 630
631config 3C515 631config 3C515
632 tristate "3c515 ISA \"Fast EtherLink\"" 632 tristate "3c515 ISA \"Fast EtherLink\""
633 depends on NET_VENDOR_3COM && (ISA || EISA) 633 depends on NET_VENDOR_3COM && (ISA || EISA) && ISA_DMA_API
634 help 634 help
635 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet 635 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet
636 network card, say Y and read the Ethernet-HOWTO, available from 636 network card, say Y and read the Ethernet-HOWTO, available from
@@ -708,7 +708,7 @@ config TYPHOON
708 708
709config LANCE 709config LANCE
710 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support" 710 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support"
711 depends on NET_ETHERNET && ISA 711 depends on NET_ETHERNET && ISA && ISA_DMA_API
712 help 712 help
713 If you have a network (Ethernet) card of this type, say Y and read 713 If you have a network (Ethernet) card of this type, say Y and read
714 the Ethernet-HOWTO, available from 714 the Ethernet-HOWTO, available from
@@ -864,7 +864,7 @@ config NI52
864 864
865config NI65 865config NI65
866 tristate "NI6510 support" 866 tristate "NI6510 support"
867 depends on NET_VENDOR_RACAL && ISA 867 depends on NET_VENDOR_RACAL && ISA && ISA_DMA_API
868 help 868 help
869 If you have a network (Ethernet) card of this type, say Y and read 869 If you have a network (Ethernet) card of this type, say Y and read
870 the Ethernet-HOWTO, available from 870 the Ethernet-HOWTO, available from
@@ -1072,7 +1072,7 @@ config NE2000
1072 1072
1073config ZNET 1073config ZNET
1074 tristate "Zenith Z-Note support (EXPERIMENTAL)" 1074 tristate "Zenith Z-Note support (EXPERIMENTAL)"
1075 depends on NET_ISA && EXPERIMENTAL 1075 depends on NET_ISA && EXPERIMENTAL && ISA_DMA_API
1076 help 1076 help
1077 The Zenith Z-Note notebook computer has a built-in network 1077 The Zenith Z-Note notebook computer has a built-in network
1078 (Ethernet) card, and this is the Linux driver for it. Note that the 1078 (Ethernet) card, and this is the Linux driver for it. Note that the
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index fc519377b5aa..fb433325aa27 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)Space.c 1.0.7 08/12/93 8 * Version: @(#)Space.c 1.0.7 08/12/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald J. Becker, <becker@scyld.com> 12 * Donald J. Becker, <becker@scyld.com>
13 * 13 *
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 60b19679ca5c..69c488d933a2 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -13,7 +13,7 @@ config DEV_APPLETALK
13 13
14config LTPC 14config LTPC
15 tristate "Apple/Farallon LocalTalk PC support" 15 tristate "Apple/Farallon LocalTalk PC support"
16 depends on DEV_APPLETALK && (ISA || EISA) 16 depends on DEV_APPLETALK && (ISA || EISA) && ISA_DMA_API
17 help 17 help
18 This allows you to use the AppleTalk PC card to connect to LocalTalk 18 This allows you to use the AppleTalk PC card to connect to LocalTalk
19 networks. The card is also known as the Farallon PhoneNet PC card. 19 networks. The card is also known as the Farallon PhoneNet PC card.
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 2161c2d585f0..9edaa183227a 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -65,7 +65,7 @@ static const char *version =
65#include <linux/etherdevice.h> 65#include <linux/etherdevice.h>
66#include <linux/skbuff.h> 66#include <linux/skbuff.h>
67#include <linux/if_arp.h> 67#include <linux/if_arp.h>
68#include <linux/if_ltalk.h> /* For ltalk_setup() */ 68#include <linux/if_ltalk.h>
69#include <linux/delay.h> /* For udelay() */ 69#include <linux/delay.h> /* For udelay() */
70#include <linux/atalk.h> 70#include <linux/atalk.h>
71#include <linux/spinlock.h> 71#include <linux/spinlock.h>
@@ -223,7 +223,7 @@ struct net_device * __init cops_probe(int unit)
223 int base_addr; 223 int base_addr;
224 int err = 0; 224 int err = 0;
225 225
226 dev = alloc_netdev(sizeof(struct cops_local), "lt%d", ltalk_setup); 226 dev = alloc_ltalkdev(sizeof(struct cops_local));
227 if (!dev) 227 if (!dev)
228 return ERR_PTR(-ENOMEM); 228 return ERR_PTR(-ENOMEM);
229 229
diff --git a/drivers/net/appletalk/cops_ffdrv.h b/drivers/net/appletalk/cops_ffdrv.h
index 4131b4a7a65b..31cf8c9c947f 100644
--- a/drivers/net/appletalk/cops_ffdrv.h
+++ b/drivers/net/appletalk/cops_ffdrv.h
@@ -28,7 +28,7 @@
28 28
29#ifdef CONFIG_COPS_DAYNA 29#ifdef CONFIG_COPS_DAYNA
30 30
31unsigned char ffdrv_code[] = { 31static const unsigned char ffdrv_code[] = {
32 58,3,0,50,228,149,33,255,255,34,226,149, 32 58,3,0,50,228,149,33,255,255,34,226,149,
33 249,17,40,152,33,202,154,183,237,82,77,68, 33 249,17,40,152,33,202,154,183,237,82,77,68,
34 11,107,98,19,54,0,237,176,175,50,80,0, 34 11,107,98,19,54,0,237,176,175,50,80,0,
diff --git a/drivers/net/appletalk/cops_ltdrv.h b/drivers/net/appletalk/cops_ltdrv.h
index 05de66dd9206..4afb8e18ba65 100644
--- a/drivers/net/appletalk/cops_ltdrv.h
+++ b/drivers/net/appletalk/cops_ltdrv.h
@@ -27,7 +27,7 @@
27 27
28#ifdef CONFIG_COPS_TANGENT 28#ifdef CONFIG_COPS_TANGENT
29 29
30unsigned char ltdrv_code[] = { 30static const unsigned char ltdrv_code[] = {
31 58,3,0,50,148,10,33,143,15,62,85,119, 31 58,3,0,50,148,10,33,143,15,62,85,119,
32 190,32,9,62,170,119,190,32,3,35,24,241, 32 190,32,9,62,170,119,190,32,3,35,24,241,
33 34,146,10,249,17,150,10,33,143,15,183,237, 33 34,146,10,249,17,150,10,33,143,15,183,237,
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index ad8e943231a1..db4f369637b6 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1039,7 +1039,7 @@ struct net_device * __init ltpc_probe(void)
1039 unsigned long f; 1039 unsigned long f;
1040 unsigned long timeout; 1040 unsigned long timeout;
1041 1041
1042 dev = alloc_netdev(sizeof(struct ltpc_private), "lt%d", ltalk_setup); 1042 dev = alloc_ltalkdev(sizeof(struct ltpc_private));
1043 if (!dev) 1043 if (!dev)
1044 goto out; 1044 goto out;
1045 1045
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 16e155b04129..66485585ab39 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -48,7 +48,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
48static int ack_tx(struct net_device *dev, int acked); 48static int ack_tx(struct net_device *dev, int acked);
49 49
50 50
51struct ArcProto capmode_proto = 51static struct ArcProto capmode_proto =
52{ 52{
53 'r', 53 'r',
54 XMTU, 54 XMTU,
diff --git a/drivers/net/gt96100eth.h b/drivers/net/gt96100eth.h
index 2f4bfd4dacbe..395869c5ed3e 100644
--- a/drivers/net/gt96100eth.h
+++ b/drivers/net/gt96100eth.h
@@ -214,7 +214,7 @@ typedef struct {
214 u32 cmdstat; 214 u32 cmdstat;
215 u32 next; 215 u32 next;
216 u32 buff_ptr; 216 u32 buff_ptr;
217} gt96100_td_t __attribute__ ((packed)); 217} __attribute__ ((packed)) gt96100_td_t;
218 218
219typedef struct { 219typedef struct {
220#ifdef DESC_BE 220#ifdef DESC_BE
@@ -227,7 +227,7 @@ typedef struct {
227 u32 cmdstat; 227 u32 cmdstat;
228 u32 next; 228 u32 next;
229 u32 buff_ptr; 229 u32 buff_ptr;
230} gt96100_rd_t __attribute__ ((packed)); 230} __attribute__ ((packed)) gt96100_rd_t;
231 231
232 232
233/* Values for the Tx command-status descriptor entry. */ 233/* Values for the Tx command-status descriptor entry. */
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 067b353e1cbd..89454915b857 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -394,13 +394,11 @@ static void sp_bump(struct sixpack *sp, char cmd)
394 if ((skb = dev_alloc_skb(count)) == NULL) 394 if ((skb = dev_alloc_skb(count)) == NULL)
395 goto out_mem; 395 goto out_mem;
396 396
397 skb->dev = sp->dev;
398 ptr = skb_put(skb, count); 397 ptr = skb_put(skb, count);
399 *ptr++ = cmd; /* KISS command */ 398 *ptr++ = cmd; /* KISS command */
400 399
401 memcpy(ptr, sp->cooked_buf + 1, count); 400 memcpy(ptr, sp->cooked_buf + 1, count);
402 skb->mac.raw = skb->data; 401 skb->protocol = ax25_type_trans(skb, sp->dev);
403 skb->protocol = htons(ETH_P_AX25);
404 netif_rx(skb); 402 netif_rx(skb);
405 sp->dev->last_rx = jiffies; 403 sp->dev->last_rx = jiffies;
406 sp->stats.rx_packets++; 404 sp->stats.rx_packets++;
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
index 34068f81d45e..7cdebe1a0b61 100644
--- a/drivers/net/hamradio/Kconfig
+++ b/drivers/net/hamradio/Kconfig
@@ -45,7 +45,7 @@ config BPQETHER
45 45
46config DMASCC 46config DMASCC
47 tristate "High-speed (DMA) SCC driver for AX.25" 47 tristate "High-speed (DMA) SCC driver for AX.25"
48 depends on ISA && AX25 && BROKEN_ON_SMP 48 depends on ISA && AX25 && BROKEN_ON_SMP && ISA_DMA_API
49 ---help--- 49 ---help---
50 This is a driver for high-speed SCC boards, i.e. those supporting 50 This is a driver for high-speed SCC boards, i.e. those supporting
51 DMA on one port. You usually use those boards to connect your 51 DMA on one port. You usually use those boards to connect your
@@ -78,7 +78,7 @@ config DMASCC
78 78
79config SCC 79config SCC
80 tristate "Z8530 SCC driver" 80 tristate "Z8530 SCC driver"
81 depends on ISA && AX25 81 depends on ISA && AX25 && ISA_DMA_API
82 ---help--- 82 ---help---
83 These cards are used to connect your Linux box to an amateur radio 83 These cards are used to connect your Linux box to an amateur radio
84 in order to communicate with other computers. If you want to use 84 in order to communicate with other computers. If you want to use
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index e8cb87d906fc..1c563f905a59 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -601,12 +601,10 @@ static void do_rxpacket(struct net_device *dev)
601 bc->stats.rx_dropped++; 601 bc->stats.rx_dropped++;
602 return; 602 return;
603 } 603 }
604 skb->dev = dev;
605 cp = skb_put(skb, pktlen); 604 cp = skb_put(skb, pktlen);
606 *cp++ = 0; /* KISS kludge */ 605 *cp++ = 0; /* KISS kludge */
607 memcpy(cp, bc->hdlcrx.buf, pktlen - 1); 606 memcpy(cp, bc->hdlcrx.buf, pktlen - 1);
608 skb->protocol = htons(ETH_P_AX25); 607 skb->protocol = ax25_type_trans(skb, dev);
609 skb->mac.raw = skb->data;
610 netif_rx(skb); 608 netif_rx(skb);
611 dev->last_rx = jiffies; 609 dev->last_rx = jiffies;
612 bc->stats.rx_packets++; 610 bc->stats.rx_packets++;
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index ef1a359e2273..ba9f0580e1f9 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -211,11 +211,7 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
211 ptr = skb_push(skb, 1); 211 ptr = skb_push(skb, 1);
212 *ptr = 0; 212 *ptr = 0;
213 213
214 skb->dev = dev; 214 skb->protocol = ax25_type_trans(skb, dev);
215 skb->protocol = htons(ETH_P_AX25);
216 skb->mac.raw = skb->data;
217 skb->pkt_type = PACKET_HOST;
218
219 netif_rx(skb); 215 netif_rx(skb);
220 dev->last_rx = jiffies; 216 dev->last_rx = jiffies;
221unlock: 217unlock:
@@ -272,8 +268,6 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
272 skb = newskb; 268 skb = newskb;
273 } 269 }
274 270
275 skb->protocol = htons(ETH_P_AX25);
276
277 ptr = skb_push(skb, 2); 271 ptr = skb_push(skb, 2);
278 272
279 *ptr++ = (size + 5) % 256; 273 *ptr++ = (size + 5) % 256;
@@ -287,7 +281,7 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
287 return -ENODEV; 281 return -ENODEV;
288 } 282 }
289 283
290 skb->dev = dev; 284 skb->protocol = ax25_type_trans(skb, dev);
291 skb->nh.raw = skb->data; 285 skb->nh.raw = skb->data;
292 dev->hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0); 286 dev->hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0);
293 bpq->stats.tx_packets++; 287 bpq->stats.tx_packets++;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index f3269b70a8c5..f515245a3fd0 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -1306,9 +1306,7 @@ static void rx_bh(void *arg)
1306 data = skb_put(skb, cb + 1); 1306 data = skb_put(skb, cb + 1);
1307 data[0] = 0; 1307 data[0] = 0;
1308 memcpy(&data[1], priv->rx_buf[i], cb); 1308 memcpy(&data[1], priv->rx_buf[i], cb);
1309 skb->dev = priv->dev; 1309 skb->protocol = ax25_type_trans(skb, priv->dev);
1310 skb->protocol = ntohs(ETH_P_AX25);
1311 skb->mac.raw = skb->data;
1312 netif_rx(skb); 1310 netif_rx(skb);
1313 priv->dev->last_rx = jiffies; 1311 priv->dev->last_rx = jiffies;
1314 priv->stats.rx_packets++; 1312 priv->stats.rx_packets++;
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index b89959a596d7..b4c836e4fe86 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -174,12 +174,10 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
174 s->stats.rx_dropped++; 174 s->stats.rx_dropped++;
175 return; 175 return;
176 } 176 }
177 skb->dev = dev;
178 cp = skb_put(skb, pkt_len); 177 cp = skb_put(skb, pkt_len);
179 *cp++ = 0; /* KISS kludge */ 178 *cp++ = 0; /* KISS kludge */
180 memcpy(cp, s->hdlcrx.buffer, pkt_len - 1); 179 memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
181 skb->protocol = htons(ETH_P_AX25); 180 skb->protocol = ax25_type_trans(skb, dev);
182 skb->mac.raw = skb->data;
183 netif_rx(skb); 181 netif_rx(skb);
184 dev->last_rx = jiffies; 182 dev->last_rx = jiffies;
185 s->stats.rx_packets++; 183 s->stats.rx_packets++;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index d9ea080aea0f..62790511098f 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -332,12 +332,10 @@ static void ax_bump(struct ax_disp *ax)
332 return; 332 return;
333 } 333 }
334 334
335 skb->dev = ax->dev;
336 spin_lock_bh(&ax->buflock); 335 spin_lock_bh(&ax->buflock);
337 memcpy(skb_put(skb,count), ax->rbuff, count); 336 memcpy(skb_put(skb,count), ax->rbuff, count);
338 spin_unlock_bh(&ax->buflock); 337 spin_unlock_bh(&ax->buflock);
339 skb->mac.raw = skb->data; 338 skb->protocol = ax25_type_trans(skb, ax->dev);
340 skb->protocol = htons(ETH_P_AX25);
341 netif_rx(skb); 339 netif_rx(skb);
342 ax->dev->last_rx = jiffies; 340 ax->dev->last_rx = jiffies;
343 ax->rx_packets++; 341 ax->rx_packets++;
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index ce9e7af020da..ece1b1a13186 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1630,10 +1630,7 @@ static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
1630 scc->dev_stat.rx_packets++; 1630 scc->dev_stat.rx_packets++;
1631 scc->dev_stat.rx_bytes += skb->len; 1631 scc->dev_stat.rx_bytes += skb->len;
1632 1632
1633 skb->dev = scc->dev; 1633 skb->protocol = ax25_type_trans(skb, scc->dev);
1634 skb->protocol = htons(ETH_P_AX25);
1635 skb->mac.raw = skb->data;
1636 skb->pkt_type = PACKET_HOST;
1637 1634
1638 netif_rx(skb); 1635 netif_rx(skb);
1639 scc->dev->last_rx = jiffies; 1636 scc->dev->last_rx = jiffies;
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index fd7b00fe38e5..41213ef602dc 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -522,12 +522,10 @@ static inline void yam_rx_flag(struct net_device *dev, struct yam_port *yp)
522 ++yp->stats.rx_dropped; 522 ++yp->stats.rx_dropped;
523 } else { 523 } else {
524 unsigned char *cp; 524 unsigned char *cp;
525 skb->dev = dev;
526 cp = skb_put(skb, pkt_len); 525 cp = skb_put(skb, pkt_len);
527 *cp++ = 0; /* KISS kludge */ 526 *cp++ = 0; /* KISS kludge */
528 memcpy(cp, yp->rx_buf, pkt_len - 1); 527 memcpy(cp, yp->rx_buf, pkt_len - 1);
529 skb->protocol = htons(ETH_P_AX25); 528 skb->protocol = ax25_type_trans(skb, dev);
530 skb->mac.raw = skb->data;
531 netif_rx(skb); 529 netif_rx(skb);
532 dev->last_rx = jiffies; 530 dev->last_rx = jiffies;
533 ++yp->stats.rx_packets; 531 ++yp->stats.rx_packets;
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index acb170152bbd..b3a898c5a585 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -13,8 +13,8 @@
13** This driver has only been tested with 13** This driver has only been tested with
14** -- HP J2585B 10/100 Mbit/s PCI Busmaster 14** -- HP J2585B 10/100 Mbit/s PCI Busmaster
15** -- HP J2585A 10/100 Mbit/s PCI 15** -- HP J2585A 10/100 Mbit/s PCI
16** -- HP J2970 10 Mbit/s PCI Combo 10base-T/BNC 16** -- HP J2970A 10 Mbit/s PCI Combo 10base-T/BNC
17** -- HP J2973 10 Mbit/s PCI 10base-T 17** -- HP J2973A 10 Mbit/s PCI 10base-T
18** -- HP J2573 10/100 ISA 18** -- HP J2573 10/100 ISA
19** -- Compex ReadyLink ENET100-VG4 10/100 Mbit/s PCI / EISA 19** -- Compex ReadyLink ENET100-VG4 10/100 Mbit/s PCI / EISA
20** -- Compex FreedomLine 100/VG 10/100 Mbit/s ISA / EISA / PCI 20** -- Compex FreedomLine 100/VG 10/100 Mbit/s ISA / EISA / PCI
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 6bf76a444d48..1c553d7efdd9 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -310,7 +310,7 @@ config SIGMATEL_FIR
310 310
311config NSC_FIR 311config NSC_FIR
312 tristate "NSC PC87108/PC87338" 312 tristate "NSC PC87108/PC87338"
313 depends on IRDA 313 depends on IRDA && ISA_DMA_API
314 help 314 help
315 Say Y here if you want to build support for the NSC PC87108 and 315 Say Y here if you want to build support for the NSC PC87108 and
316 PC87338 IrDA chipsets. This driver supports SIR, 316 PC87338 IrDA chipsets. This driver supports SIR,
@@ -321,7 +321,7 @@ config NSC_FIR
321 321
322config WINBOND_FIR 322config WINBOND_FIR
323 tristate "Winbond W83977AF (IR)" 323 tristate "Winbond W83977AF (IR)"
324 depends on IRDA 324 depends on IRDA && ISA_DMA_API
325 help 325 help
326 Say Y here if you want to build IrDA support for the Winbond 326 Say Y here if you want to build IrDA support for the Winbond
327 W83977AF super-io chipset. This driver should be used for the IrDA 327 W83977AF super-io chipset. This driver should be used for the IrDA
@@ -347,7 +347,7 @@ config AU1000_FIR
347 347
348config SMC_IRCC_FIR 348config SMC_IRCC_FIR
349 tristate "SMSC IrCC (EXPERIMENTAL)" 349 tristate "SMSC IrCC (EXPERIMENTAL)"
350 depends on EXPERIMENTAL && IRDA 350 depends on EXPERIMENTAL && IRDA && ISA_DMA_API
351 help 351 help
352 Say Y here if you want to build support for the SMC Infrared 352 Say Y here if you want to build support for the SMC Infrared
353 Communications Controller. It is used in a wide variety of 353 Communications Controller. It is used in a wide variety of
@@ -357,7 +357,7 @@ config SMC_IRCC_FIR
357 357
358config ALI_FIR 358config ALI_FIR
359 tristate "ALi M5123 FIR (EXPERIMENTAL)" 359 tristate "ALi M5123 FIR (EXPERIMENTAL)"
360 depends on EXPERIMENTAL && IRDA 360 depends on EXPERIMENTAL && IRDA && ISA_DMA_API
361 help 361 help
362 Say Y here if you want to build support for the ALi M5123 FIR 362 Say Y here if you want to build support for the ALi M5123 FIR
363 Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C, 363 Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C,
@@ -385,7 +385,7 @@ config SA1100_FIR
385 385
386config VIA_FIR 386config VIA_FIR
387 tristate "VIA VT8231/VT1211 SIR/MIR/FIR" 387 tristate "VIA VT8231/VT1211 SIR/MIR/FIR"
388 depends on IRDA 388 depends on IRDA && ISA_DMA_API
389 help 389 help
390 Say Y here if you want to build support for the VIA VT8231 390 Say Y here if you want to build support for the VIA VT8231
391 and VIA VT1211 IrDA controllers, found on the motherboards using 391 and VIA VT1211 IrDA controllers, found on the motherboards using
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 2ffc31708d5f..b33111e21313 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)loopback.c 1.0.4b 08/16/93 8 * Version: @(#)loopback.c 1.0.4b 08/16/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald Becker, <becker@scyld.com> 12 * Donald Becker, <becker@scyld.com>
13 * 13 *
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 7e94d455533c..0405e1f0d3df 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -99,7 +99,7 @@ static spinlock_t mv643xx_eth_phy_lock = SPIN_LOCK_UNLOCKED;
99 99
100static inline u32 mv_read(int offset) 100static inline u32 mv_read(int offset)
101{ 101{
102 void *__iomem reg_base; 102 void __iomem *reg_base;
103 103
104 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS; 104 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS;
105 105
@@ -108,7 +108,7 @@ static inline u32 mv_read(int offset)
108 108
109static inline void mv_write(int offset, u32 data) 109static inline void mv_write(int offset, u32 data)
110{ 110{
111 void * __iomem reg_base; 111 void __iomem *reg_base;
112 112
113 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS; 113 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS;
114 writel(data, reg_base + offset); 114 writel(data, reg_base + offset);
diff --git a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c
index 507d6328d4eb..3872088fdd10 100644
--- a/drivers/net/ppp_deflate.c
+++ b/drivers/net/ppp_deflate.c
@@ -87,8 +87,7 @@ static void z_comp_free(void *arg)
87 87
88 if (state) { 88 if (state) {
89 zlib_deflateEnd(&state->strm); 89 zlib_deflateEnd(&state->strm);
90 if (state->strm.workspace) 90 vfree(state->strm.workspace);
91 vfree(state->strm.workspace);
92 kfree(state); 91 kfree(state);
93 } 92 }
94} 93}
@@ -308,8 +307,7 @@ static void z_decomp_free(void *arg)
308 307
309 if (state) { 308 if (state) {
310 zlib_inflateEnd(&state->strm); 309 zlib_inflateEnd(&state->strm);
311 if (state->strm.workspace) 310 kfree(state->strm.workspace);
312 kfree(state->strm.workspace);
313 kfree(state); 311 kfree(state);
314 } 312 }
315} 313}
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index c456dc81b873..3b377f6cd4a0 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2467,14 +2467,10 @@ static void ppp_destroy_interface(struct ppp *ppp)
2467 skb_queue_purge(&ppp->mrq); 2467 skb_queue_purge(&ppp->mrq);
2468#endif /* CONFIG_PPP_MULTILINK */ 2468#endif /* CONFIG_PPP_MULTILINK */
2469#ifdef CONFIG_PPP_FILTER 2469#ifdef CONFIG_PPP_FILTER
2470 if (ppp->pass_filter) { 2470 kfree(ppp->pass_filter);
2471 kfree(ppp->pass_filter); 2471 ppp->pass_filter = NULL;
2472 ppp->pass_filter = NULL; 2472 kfree(ppp->active_filter);
2473 } 2473 ppp->active_filter = NULL;
2474 if (ppp->active_filter) {
2475 kfree(ppp->active_filter);
2476 ppp->active_filter = NULL;
2477 }
2478#endif /* CONFIG_PPP_FILTER */ 2474#endif /* CONFIG_PPP_FILTER */
2479 2475
2480 kfree(ppp); 2476 kfree(ppp);
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 07e2df09491f..c59507f8a76b 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -2385,7 +2385,7 @@ core_down:
2385 } 2385 }
2386 2386
2387 /* Give a racing hard_start_xmit a few cycles to complete. */ 2387 /* Give a racing hard_start_xmit a few cycles to complete. */
2388 synchronize_kernel(); 2388 synchronize_sched(); /* FIXME: should this be synchronize_irq()? */
2389 2389
2390 /* 2390 /*
2391 * And now for the 50k$ question: are IRQ disabled or not ? 2391 * And now for the 50k$ question: are IRQ disabled or not ?
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 4ce52f5f2419..8f7841c0374d 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -185,15 +185,12 @@ sl_alloc_bufs(struct slip *sl, int mtu)
185 /* Cleanup */ 185 /* Cleanup */
186err_exit: 186err_exit:
187#ifdef SL_INCLUDE_CSLIP 187#ifdef SL_INCLUDE_CSLIP
188 if (cbuff) 188 kfree(cbuff);
189 kfree(cbuff);
190 if (slcomp) 189 if (slcomp)
191 slhc_free(slcomp); 190 slhc_free(slcomp);
192#endif 191#endif
193 if (xbuff) 192 kfree(xbuff);
194 kfree(xbuff); 193 kfree(rbuff);
195 if (rbuff)
196 kfree(rbuff);
197 return err; 194 return err;
198} 195}
199 196
@@ -204,13 +201,13 @@ sl_free_bufs(struct slip *sl)
204 void * tmp; 201 void * tmp;
205 202
206 /* Free all SLIP frame buffers. */ 203 /* Free all SLIP frame buffers. */
207 if ((tmp = xchg(&sl->rbuff, NULL)) != NULL) 204 tmp = xchg(&sl->rbuff, NULL);
208 kfree(tmp); 205 kfree(tmp);
209 if ((tmp = xchg(&sl->xbuff, NULL)) != NULL) 206 tmp = xchg(&sl->xbuff, NULL);
210 kfree(tmp); 207 kfree(tmp);
211#ifdef SL_INCLUDE_CSLIP 208#ifdef SL_INCLUDE_CSLIP
212 if ((tmp = xchg(&sl->cbuff, NULL)) != NULL) 209 tmp = xchg(&sl->cbuff, NULL);
213 kfree(tmp); 210 kfree(tmp);
214 if ((tmp = xchg(&sl->slcomp, NULL)) != NULL) 211 if ((tmp = xchg(&sl->slcomp, NULL)) != NULL)
215 slhc_free(tmp); 212 slhc_free(tmp);
216#endif 213#endif
@@ -297,13 +294,10 @@ done_on_bh:
297 spin_unlock_bh(&sl->lock); 294 spin_unlock_bh(&sl->lock);
298 295
299done: 296done:
300 if (xbuff) 297 kfree(xbuff);
301 kfree(xbuff); 298 kfree(rbuff);
302 if (rbuff)
303 kfree(rbuff);
304#ifdef SL_INCLUDE_CSLIP 299#ifdef SL_INCLUDE_CSLIP
305 if (cbuff) 300 kfree(cbuff);
306 kfree(cbuff);
307#endif 301#endif
308 return err; 302 return err;
309} 303}
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 025dcd867eaa..f88f5e32b714 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -37,8 +37,18 @@
37 37
38#include "sunbmac.h" 38#include "sunbmac.h"
39 39
40#define DRV_NAME "sunbmac"
41#define DRV_VERSION "2.0"
42#define DRV_RELDATE "11/24/03"
43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
44
40static char version[] __initdata = 45static char version[] __initdata =
41 "sunbmac.c:v2.0 24/Nov/03 David S. Miller (davem@redhat.com)\n"; 46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
47
48MODULE_VERSION(DRV_VERSION);
49MODULE_AUTHOR(DRV_AUTHOR);
50MODULE_DESCRIPTION("Sun BigMAC 100baseT ethernet driver");
51MODULE_LICENSE("GPL");
42 52
43#undef DEBUG_PROBE 53#undef DEBUG_PROBE
44#undef DEBUG_TX 54#undef DEBUG_TX
@@ -1321,4 +1331,3 @@ static void __exit bigmac_cleanup(void)
1321 1331
1322module_init(bigmac_probe); 1332module_init(bigmac_probe);
1323module_exit(bigmac_cleanup); 1333module_exit(bigmac_cleanup);
1324MODULE_LICENSE("GPL");
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index d837b3c35723..f02fe4119b2c 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -13,9 +13,6 @@
13 * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50 13 * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
14 */ 14 */
15 15
16static char version[] =
17 "sunhme.c:v2.02 24/Aug/2003 David S. Miller (davem@redhat.com)\n";
18
19#include <linux/config.h> 16#include <linux/config.h>
20#include <linux/module.h> 17#include <linux/module.h>
21#include <linux/kernel.h> 18#include <linux/kernel.h>
@@ -67,15 +64,24 @@ static char version[] =
67 64
68#include "sunhme.h" 65#include "sunhme.h"
69 66
67#define DRV_NAME "sunhme"
68#define DRV_VERSION "2.02"
69#define DRV_RELDATE "8/24/03"
70#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
71
72static char version[] =
73 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
70 74
71#define DRV_NAME "sunhme" 75MODULE_VERSION(DRV_VERSION);
76MODULE_AUTHOR(DRV_AUTHOR);
77MODULE_DESCRIPTION("Sun HappyMealEthernet(HME) 10/100baseT ethernet driver");
78MODULE_LICENSE("GPL");
72 79
73static int macaddr[6]; 80static int macaddr[6];
74 81
75/* accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */ 82/* accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */
76module_param_array(macaddr, int, NULL, 0); 83module_param_array(macaddr, int, NULL, 0);
77MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set"); 84MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set");
78MODULE_LICENSE("GPL");
79 85
80static struct happy_meal *root_happy_dev; 86static struct happy_meal *root_happy_dev;
81 87
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 62d464c7ef51..b7d87d4690b4 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -69,9 +69,6 @@
69 69
70#undef DEBUG_DRIVER 70#undef DEBUG_DRIVER
71 71
72static char version[] =
73 "sunlance.c:v2.02 24/Aug/03 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
74
75static char lancestr[] = "LANCE"; 72static char lancestr[] = "LANCE";
76 73
77#include <linux/config.h> 74#include <linux/config.h>
@@ -108,6 +105,19 @@ static char lancestr[] = "LANCE";
108#include <asm/auxio.h> /* For tpe-link-test? setting */ 105#include <asm/auxio.h> /* For tpe-link-test? setting */
109#include <asm/irq.h> 106#include <asm/irq.h>
110 107
108#define DRV_NAME "sunlance"
109#define DRV_VERSION "2.02"
110#define DRV_RELDATE "8/24/03"
111#define DRV_AUTHOR "Miguel de Icaza (miguel@nuclecu.unam.mx)"
112
113static char version[] =
114 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
115
116MODULE_VERSION(DRV_VERSION);
117MODULE_AUTHOR(DRV_AUTHOR);
118MODULE_DESCRIPTION("Sun Lance ethernet driver");
119MODULE_LICENSE("GPL");
120
111/* Define: 2^4 Tx buffers and 2^4 Rx buffers */ 121/* Define: 2^4 Tx buffers and 2^4 Rx buffers */
112#ifndef LANCE_LOG_TX_BUFFERS 122#ifndef LANCE_LOG_TX_BUFFERS
113#define LANCE_LOG_TX_BUFFERS 4 123#define LANCE_LOG_TX_BUFFERS 4
@@ -1611,4 +1621,3 @@ static void __exit sparc_lance_cleanup(void)
1611 1621
1612module_init(sparc_lance_probe); 1622module_init(sparc_lance_probe);
1613module_exit(sparc_lance_cleanup); 1623module_exit(sparc_lance_cleanup);
1614MODULE_LICENSE("GPL");
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index 37ef1b82a6cb..1f2323be60d4 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -7,9 +7,6 @@
7 * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com) 7 * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com)
8 */ 8 */
9 9
10static char version[] =
11 "sunqe.c:v3.0 8/24/03 David S. Miller (davem@redhat.com)\n";
12
13#include <linux/module.h> 10#include <linux/module.h>
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/types.h> 12#include <linux/types.h>
@@ -43,6 +40,19 @@ static char version[] =
43 40
44#include "sunqe.h" 41#include "sunqe.h"
45 42
43#define DRV_NAME "sunqe"
44#define DRV_VERSION "3.0"
45#define DRV_RELDATE "8/24/03"
46#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
47
48static char version[] =
49 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
50
51MODULE_VERSION(DRV_VERSION);
52MODULE_AUTHOR(DRV_AUTHOR);
53MODULE_DESCRIPTION("Sun QuadEthernet 10baseT SBUS card driver");
54MODULE_LICENSE("GPL");
55
46static struct sunqec *root_qec_dev; 56static struct sunqec *root_qec_dev;
47 57
48static void qe_set_multicast(struct net_device *dev); 58static void qe_set_multicast(struct net_device *dev);
@@ -1040,4 +1050,3 @@ static void __exit qec_cleanup(void)
1040 1050
1041module_init(qec_probe); 1051module_init(qec_probe);
1042module_exit(qec_cleanup); 1052module_exit(qec_cleanup);
1043MODULE_LICENSE("GPL");
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 12de80884b1a..f79b02e80e75 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -61,8 +61,8 @@
61 61
62#define DRV_MODULE_NAME "tg3" 62#define DRV_MODULE_NAME "tg3"
63#define PFX DRV_MODULE_NAME ": " 63#define PFX DRV_MODULE_NAME ": "
64#define DRV_MODULE_VERSION "3.25" 64#define DRV_MODULE_VERSION "3.27"
65#define DRV_MODULE_RELDATE "March 24, 2005" 65#define DRV_MODULE_RELDATE "May 5, 2005"
66 66
67#define TG3_DEF_MAC_MODE 0 67#define TG3_DEF_MAC_MODE 0
68#define TG3_DEF_RX_MODE 0 68#define TG3_DEF_RX_MODE 0
@@ -85,8 +85,7 @@
85/* hardware minimum and maximum for a single frame's data payload */ 85/* hardware minimum and maximum for a single frame's data payload */
86#define TG3_MIN_MTU 60 86#define TG3_MIN_MTU 60
87#define TG3_MAX_MTU(tp) \ 87#define TG3_MAX_MTU(tp) \
88 ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && \ 88 (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ? 9000 : 1500)
89 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) ? 9000 : 1500)
90 89
91/* These numbers seem to be hard coded in the NIC firmware somehow. 90/* These numbers seem to be hard coded in the NIC firmware somehow.
92 * You can't change the ring sizes, but you can change where you place 91 * You can't change the ring sizes, but you can change where you place
@@ -205,6 +204,8 @@ static struct pci_device_id tg3_pci_tbl[] = {
205 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 204 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
206 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F, 205 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F,
207 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 206 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
207 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5752,
208 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
208 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753, 209 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753,
209 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 210 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
210 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M, 211 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M,
@@ -425,9 +426,30 @@ static void tg3_enable_ints(struct tg3 *tp)
425 tg3_cond_int(tp); 426 tg3_cond_int(tp);
426} 427}
427 428
429static inline unsigned int tg3_has_work(struct tg3 *tp)
430{
431 struct tg3_hw_status *sblk = tp->hw_status;
432 unsigned int work_exists = 0;
433
434 /* check for phy events */
435 if (!(tp->tg3_flags &
436 (TG3_FLAG_USE_LINKCHG_REG |
437 TG3_FLAG_POLL_SERDES))) {
438 if (sblk->status & SD_STATUS_LINK_CHG)
439 work_exists = 1;
440 }
441 /* check for RX/TX work to do */
442 if (sblk->idx[0].tx_consumer != tp->tx_cons ||
443 sblk->idx[0].rx_producer != tp->rx_rcb_ptr)
444 work_exists = 1;
445
446 return work_exists;
447}
448
428/* tg3_restart_ints 449/* tg3_restart_ints
429 * similar to tg3_enable_ints, but it can return without flushing the 450 * similar to tg3_enable_ints, but it accurately determines whether there
430 * PIO write which reenables interrupts 451 * is new work pending and can return without flushing the PIO write
452 * which reenables interrupts
431 */ 453 */
432static void tg3_restart_ints(struct tg3 *tp) 454static void tg3_restart_ints(struct tg3 *tp)
433{ 455{
@@ -436,7 +458,9 @@ static void tg3_restart_ints(struct tg3 *tp)
436 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); 458 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000);
437 mmiowb(); 459 mmiowb();
438 460
439 tg3_cond_int(tp); 461 if (tg3_has_work(tp))
462 tw32(HOSTCC_MODE, tp->coalesce_mode |
463 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));
440} 464}
441 465
442static inline void tg3_netif_stop(struct tg3 *tp) 466static inline void tg3_netif_stop(struct tg3 *tp)
@@ -860,8 +884,7 @@ out:
860 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { 884 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
861 /* Cannot do read-modify-write on 5401 */ 885 /* Cannot do read-modify-write on 5401 */
862 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); 886 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20);
863 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 887 } else if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
864 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
865 u32 phy_reg; 888 u32 phy_reg;
866 889
867 /* Set bit 14 with read-modify-write to preserve other bits */ 890 /* Set bit 14 with read-modify-write to preserve other bits */
@@ -873,8 +896,7 @@ out:
873 /* Set phy register 0x10 bit 0 to high fifo elasticity to support 896 /* Set phy register 0x10 bit 0 to high fifo elasticity to support
874 * jumbo frames transmission. 897 * jumbo frames transmission.
875 */ 898 */
876 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 899 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
877 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
878 u32 phy_reg; 900 u32 phy_reg;
879 901
880 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) 902 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg))
@@ -1006,8 +1028,13 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1006 pci_write_config_word(tp->pdev, 1028 pci_write_config_word(tp->pdev,
1007 pm + PCI_PM_CTRL, 1029 pm + PCI_PM_CTRL,
1008 power_control); 1030 power_control);
1009 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1031 udelay(100); /* Delay after power state change */
1010 udelay(100); 1032
1033 /* Switch out of Vaux if it is not a LOM */
1034 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) {
1035 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
1036 udelay(100);
1037 }
1011 1038
1012 return 0; 1039 return 0;
1013 1040
@@ -1068,7 +1095,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1068 mac_mode = MAC_MODE_PORT_MODE_TBI; 1095 mac_mode = MAC_MODE_PORT_MODE_TBI;
1069 } 1096 }
1070 1097
1071 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) 1098 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
1072 tw32(MAC_LED_CTRL, tp->led_ctrl); 1099 tw32(MAC_LED_CTRL, tp->led_ctrl);
1073 1100
1074 if (((power_caps & PCI_PM_CAP_PME_D3cold) && 1101 if (((power_caps & PCI_PM_CAP_PME_D3cold) &&
@@ -1095,7 +1122,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1095 CLOCK_CTRL_ALTCLK | 1122 CLOCK_CTRL_ALTCLK |
1096 CLOCK_CTRL_PWRDOWN_PLL133); 1123 CLOCK_CTRL_PWRDOWN_PLL133);
1097 udelay(40); 1124 udelay(40);
1098 } else if (!((GET_ASIC_REV(tp->pci_chip_rev_id) == 5750) && 1125 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
1099 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { 1126 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) {
1100 u32 newbits1, newbits2; 1127 u32 newbits1, newbits2;
1101 1128
@@ -1152,6 +1179,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1152 1179
1153 /* Finally, set the new power state. */ 1180 /* Finally, set the new power state. */
1154 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); 1181 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
1182 udelay(100); /* Delay after power state change */
1155 1183
1156 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); 1184 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
1157 1185
@@ -2681,8 +2709,8 @@ static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag)
2681static int tg3_rx(struct tg3 *tp, int budget) 2709static int tg3_rx(struct tg3 *tp, int budget)
2682{ 2710{
2683 u32 work_mask; 2711 u32 work_mask;
2684 u32 rx_rcb_ptr = tp->rx_rcb_ptr; 2712 u32 sw_idx = tp->rx_rcb_ptr;
2685 u16 hw_idx, sw_idx; 2713 u16 hw_idx;
2686 int received; 2714 int received;
2687 2715
2688 hw_idx = tp->hw_status->idx[0].rx_producer; 2716 hw_idx = tp->hw_status->idx[0].rx_producer;
@@ -2691,7 +2719,6 @@ static int tg3_rx(struct tg3 *tp, int budget)
2691 * the opaque cookie. 2719 * the opaque cookie.
2692 */ 2720 */
2693 rmb(); 2721 rmb();
2694 sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
2695 work_mask = 0; 2722 work_mask = 0;
2696 received = 0; 2723 received = 0;
2697 while (sw_idx != hw_idx && budget > 0) { 2724 while (sw_idx != hw_idx && budget > 0) {
@@ -2796,14 +2823,19 @@ static int tg3_rx(struct tg3 *tp, int budget)
2796next_pkt: 2823next_pkt:
2797 (*post_ptr)++; 2824 (*post_ptr)++;
2798next_pkt_nopost: 2825next_pkt_nopost:
2799 rx_rcb_ptr++; 2826 sw_idx++;
2800 sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp); 2827 sw_idx %= TG3_RX_RCB_RING_SIZE(tp);
2828
2829 /* Refresh hw_idx to see if there is new work */
2830 if (sw_idx == hw_idx) {
2831 hw_idx = tp->hw_status->idx[0].rx_producer;
2832 rmb();
2833 }
2801 } 2834 }
2802 2835
2803 /* ACK the status ring. */ 2836 /* ACK the status ring. */
2804 tp->rx_rcb_ptr = rx_rcb_ptr; 2837 tp->rx_rcb_ptr = sw_idx;
2805 tw32_rx_mbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, 2838 tw32_rx_mbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, sw_idx);
2806 (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp)));
2807 2839
2808 /* Refill RX ring(s). */ 2840 /* Refill RX ring(s). */
2809 if (work_mask & RXD_OPAQUE_RING_STD) { 2841 if (work_mask & RXD_OPAQUE_RING_STD) {
@@ -2882,24 +2914,41 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2882 return (done ? 0 : 1); 2914 return (done ? 0 : 1);
2883} 2915}
2884 2916
2885static inline unsigned int tg3_has_work(struct net_device *dev, struct tg3 *tp) 2917/* MSI ISR - No need to check for interrupt sharing and no need to
2918 * flush status block and interrupt mailbox. PCI ordering rules
2919 * guarantee that MSI will arrive after the status block.
2920 */
2921static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2886{ 2922{
2923 struct net_device *dev = dev_id;
2924 struct tg3 *tp = netdev_priv(dev);
2887 struct tg3_hw_status *sblk = tp->hw_status; 2925 struct tg3_hw_status *sblk = tp->hw_status;
2888 unsigned int work_exists = 0; 2926 unsigned long flags;
2889 2927
2890 /* check for phy events */ 2928 spin_lock_irqsave(&tp->lock, flags);
2891 if (!(tp->tg3_flags & 2929
2892 (TG3_FLAG_USE_LINKCHG_REG | 2930 /*
2893 TG3_FLAG_POLL_SERDES))) { 2931 * writing any value to intr-mbox-0 clears PCI INTA# and
2894 if (sblk->status & SD_STATUS_LINK_CHG) 2932 * chip-internal interrupt pending events.
2895 work_exists = 1; 2933 * writing non-zero to intr-mbox-0 additional tells the
2934 * NIC to stop sending us irqs, engaging "in-intr-handler"
2935 * event coalescing.
2936 */
2937 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
2938 sblk->status &= ~SD_STATUS_UPDATED;
2939
2940 if (likely(tg3_has_work(tp)))
2941 netif_rx_schedule(dev); /* schedule NAPI poll */
2942 else {
2943 /* no work, re-enable interrupts
2944 */
2945 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2946 0x00000000);
2896 } 2947 }
2897 /* check for RX/TX work to do */
2898 if (sblk->idx[0].tx_consumer != tp->tx_cons ||
2899 sblk->idx[0].rx_producer != tp->rx_rcb_ptr)
2900 work_exists = 1;
2901 2948
2902 return work_exists; 2949 spin_unlock_irqrestore(&tp->lock, flags);
2950
2951 return IRQ_RETVAL(1);
2903} 2952}
2904 2953
2905static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) 2954static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -2935,7 +2984,7 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2935 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 2984 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
2936 sblk->status &= ~SD_STATUS_UPDATED; 2985 sblk->status &= ~SD_STATUS_UPDATED;
2937 2986
2938 if (likely(tg3_has_work(dev, tp))) 2987 if (likely(tg3_has_work(tp)))
2939 netif_rx_schedule(dev); /* schedule NAPI poll */ 2988 netif_rx_schedule(dev); /* schedule NAPI poll */
2940 else { 2989 else {
2941 /* no work, shared interrupt perhaps? re-enable 2990 /* no work, shared interrupt perhaps? re-enable
@@ -2954,13 +3003,31 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2954 return IRQ_RETVAL(handled); 3003 return IRQ_RETVAL(handled);
2955} 3004}
2956 3005
3006/* ISR for interrupt test */
3007static irqreturn_t tg3_test_isr(int irq, void *dev_id,
3008 struct pt_regs *regs)
3009{
3010 struct net_device *dev = dev_id;
3011 struct tg3 *tp = netdev_priv(dev);
3012 struct tg3_hw_status *sblk = tp->hw_status;
3013
3014 if (sblk->status & SD_STATUS_UPDATED) {
3015 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3016 0x00000001);
3017 return IRQ_RETVAL(1);
3018 }
3019 return IRQ_RETVAL(0);
3020}
3021
2957static int tg3_init_hw(struct tg3 *); 3022static int tg3_init_hw(struct tg3 *);
2958static int tg3_halt(struct tg3 *); 3023static int tg3_halt(struct tg3 *, int);
2959 3024
2960#ifdef CONFIG_NET_POLL_CONTROLLER 3025#ifdef CONFIG_NET_POLL_CONTROLLER
2961static void tg3_poll_controller(struct net_device *dev) 3026static void tg3_poll_controller(struct net_device *dev)
2962{ 3027{
2963 tg3_interrupt(dev->irq, dev, NULL); 3028 struct tg3 *tp = netdev_priv(dev);
3029
3030 tg3_interrupt(tp->pdev->irq, dev, NULL);
2964} 3031}
2965#endif 3032#endif
2966 3033
@@ -2977,7 +3044,7 @@ static void tg3_reset_task(void *_data)
2977 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER; 3044 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER;
2978 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; 3045 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER;
2979 3046
2980 tg3_halt(tp); 3047 tg3_halt(tp, 0);
2981 tg3_init_hw(tp); 3048 tg3_init_hw(tp);
2982 3049
2983 tg3_netif_start(tp); 3050 tg3_netif_start(tp);
@@ -3323,7 +3390,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu)
3323 spin_lock_irq(&tp->lock); 3390 spin_lock_irq(&tp->lock);
3324 spin_lock(&tp->tx_lock); 3391 spin_lock(&tp->tx_lock);
3325 3392
3326 tg3_halt(tp); 3393 tg3_halt(tp, 1);
3327 3394
3328 tg3_set_mtu(dev, tp, new_mtu); 3395 tg3_set_mtu(dev, tp, new_mtu);
3329 3396
@@ -3590,7 +3657,7 @@ err_out:
3590/* To stop a block, clear the enable bit and poll till it 3657/* To stop a block, clear the enable bit and poll till it
3591 * clears. tp->lock is held. 3658 * clears. tp->lock is held.
3592 */ 3659 */
3593static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit) 3660static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit, int silent)
3594{ 3661{
3595 unsigned int i; 3662 unsigned int i;
3596 u32 val; 3663 u32 val;
@@ -3623,7 +3690,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit)
3623 break; 3690 break;
3624 } 3691 }
3625 3692
3626 if (i == MAX_WAIT_CNT) { 3693 if (i == MAX_WAIT_CNT && !silent) {
3627 printk(KERN_ERR PFX "tg3_stop_block timed out, " 3694 printk(KERN_ERR PFX "tg3_stop_block timed out, "
3628 "ofs=%lx enable_bit=%x\n", 3695 "ofs=%lx enable_bit=%x\n",
3629 ofs, enable_bit); 3696 ofs, enable_bit);
@@ -3634,7 +3701,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit)
3634} 3701}
3635 3702
3636/* tp->lock is held. */ 3703/* tp->lock is held. */
3637static int tg3_abort_hw(struct tg3 *tp) 3704static int tg3_abort_hw(struct tg3 *tp, int silent)
3638{ 3705{
3639 int i, err; 3706 int i, err;
3640 3707
@@ -3644,22 +3711,20 @@ static int tg3_abort_hw(struct tg3 *tp)
3644 tw32_f(MAC_RX_MODE, tp->rx_mode); 3711 tw32_f(MAC_RX_MODE, tp->rx_mode);
3645 udelay(10); 3712 udelay(10);
3646 3713
3647 err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE); 3714 err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE, silent);
3648 err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE); 3715 err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE, silent);
3649 err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE); 3716 err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE, silent);
3650 err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE); 3717 err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE, silent);
3651 err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE); 3718 err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE, silent);
3652 err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE); 3719 err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE, silent);
3653 3720
3654 err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE); 3721 err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE, silent);
3655 err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE); 3722 err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE, silent);
3656 err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE); 3723 err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE, silent);
3657 err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE); 3724 err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE, silent);
3658 err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE); 3725 err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE, silent);
3659 err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE); 3726 err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE, silent);
3660 err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE); 3727 err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE, silent);
3661 if (err)
3662 goto out;
3663 3728
3664 tp->mac_mode &= ~MAC_MODE_TDE_ENABLE; 3729 tp->mac_mode &= ~MAC_MODE_TDE_ENABLE;
3665 tw32_f(MAC_MODE, tp->mac_mode); 3730 tw32_f(MAC_MODE, tp->mac_mode);
@@ -3677,27 +3742,24 @@ static int tg3_abort_hw(struct tg3 *tp)
3677 printk(KERN_ERR PFX "tg3_abort_hw timed out for %s, " 3742 printk(KERN_ERR PFX "tg3_abort_hw timed out for %s, "
3678 "TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n", 3743 "TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n",
3679 tp->dev->name, tr32(MAC_TX_MODE)); 3744 tp->dev->name, tr32(MAC_TX_MODE));
3680 return -ENODEV; 3745 err |= -ENODEV;
3681 } 3746 }
3682 3747
3683 err = tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE); 3748 err |= tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE, silent);
3684 err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE); 3749 err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE, silent);
3685 err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE); 3750 err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE, silent);
3686 3751
3687 tw32(FTQ_RESET, 0xffffffff); 3752 tw32(FTQ_RESET, 0xffffffff);
3688 tw32(FTQ_RESET, 0x00000000); 3753 tw32(FTQ_RESET, 0x00000000);
3689 3754
3690 err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE); 3755 err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE, silent);
3691 err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE); 3756 err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE, silent);
3692 if (err)
3693 goto out;
3694 3757
3695 if (tp->hw_status) 3758 if (tp->hw_status)
3696 memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE); 3759 memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
3697 if (tp->hw_stats) 3760 if (tp->hw_stats)
3698 memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats)); 3761 memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats));
3699 3762
3700out:
3701 return err; 3763 return err;
3702} 3764}
3703 3765
@@ -3727,6 +3789,28 @@ static void tg3_nvram_unlock(struct tg3 *tp)
3727} 3789}
3728 3790
3729/* tp->lock is held. */ 3791/* tp->lock is held. */
3792static void tg3_enable_nvram_access(struct tg3 *tp)
3793{
3794 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
3795 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) {
3796 u32 nvaccess = tr32(NVRAM_ACCESS);
3797
3798 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
3799 }
3800}
3801
3802/* tp->lock is held. */
3803static void tg3_disable_nvram_access(struct tg3 *tp)
3804{
3805 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
3806 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) {
3807 u32 nvaccess = tr32(NVRAM_ACCESS);
3808
3809 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
3810 }
3811}
3812
3813/* tp->lock is held. */
3730static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) 3814static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind)
3731{ 3815{
3732 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) 3816 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
@@ -3967,7 +4051,7 @@ static int tg3_chip_reset(struct tg3 *tp)
3967 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 4051 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
3968 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 4052 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
3969 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 4053 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
3970 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 4054 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
3971 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 4055 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
3972 } 4056 }
3973 } 4057 }
@@ -3997,7 +4081,7 @@ static void tg3_stop_fw(struct tg3 *tp)
3997} 4081}
3998 4082
3999/* tp->lock is held. */ 4083/* tp->lock is held. */
4000static int tg3_halt(struct tg3 *tp) 4084static int tg3_halt(struct tg3 *tp, int silent)
4001{ 4085{
4002 int err; 4086 int err;
4003 4087
@@ -4005,7 +4089,7 @@ static int tg3_halt(struct tg3 *tp)
4005 4089
4006 tg3_write_sig_pre_reset(tp, RESET_KIND_SHUTDOWN); 4090 tg3_write_sig_pre_reset(tp, RESET_KIND_SHUTDOWN);
4007 4091
4008 tg3_abort_hw(tp); 4092 tg3_abort_hw(tp, silent);
4009 err = tg3_chip_reset(tp); 4093 err = tg3_chip_reset(tp);
4010 4094
4011 tg3_write_sig_legacy(tp, RESET_KIND_SHUTDOWN); 4095 tg3_write_sig_legacy(tp, RESET_KIND_SHUTDOWN);
@@ -4974,9 +5058,7 @@ static int tg3_reset_hw(struct tg3 *tp)
4974 tg3_write_sig_pre_reset(tp, RESET_KIND_INIT); 5058 tg3_write_sig_pre_reset(tp, RESET_KIND_INIT);
4975 5059
4976 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) { 5060 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) {
4977 err = tg3_abort_hw(tp); 5061 tg3_abort_hw(tp, 1);
4978 if (err)
4979 return err;
4980 } 5062 }
4981 5063
4982 err = tg3_chip_reset(tp); 5064 err = tg3_chip_reset(tp);
@@ -5041,7 +5123,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5041 tw32(GRC_MISC_CFG, val); 5123 tw32(GRC_MISC_CFG, val);
5042 5124
5043 /* Initialize MBUF/DESC pool. */ 5125 /* Initialize MBUF/DESC pool. */
5044 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 5126 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
5045 /* Do nothing. */ 5127 /* Do nothing. */
5046 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) { 5128 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
5047 tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE); 5129 tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
@@ -5238,6 +5320,8 @@ static int tg3_reset_hw(struct tg3 *tp)
5238 RDMAC_MODE_LNGREAD_ENAB); 5320 RDMAC_MODE_LNGREAD_ENAB);
5239 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) 5321 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
5240 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE; 5322 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
5323
5324 /* If statement applies to 5705 and 5750 PCI devices only */
5241 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 5325 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
5242 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 5326 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
5243 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) { 5327 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) {
@@ -5251,6 +5335,9 @@ static int tg3_reset_hw(struct tg3 *tp)
5251 } 5335 }
5252 } 5336 }
5253 5337
5338 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)
5339 rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
5340
5254#if TG3_TSO_SUPPORT != 0 5341#if TG3_TSO_SUPPORT != 0
5255 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 5342 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
5256 rdmac_mode |= (1 << 27); 5343 rdmac_mode |= (1 << 27);
@@ -5332,10 +5419,28 @@ static int tg3_reset_hw(struct tg3 *tp)
5332 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR); 5419 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR);
5333 udelay(40); 5420 udelay(40);
5334 5421
5335 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM; 5422 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants().
5336 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) 5423 * If TG3_FLAG_EEPROM_WRITE_PROT is set, we should read the
5424 * register to preserve the GPIO settings for LOMs. The GPIOs,
5425 * whether used as inputs or outputs, are set by boot code after
5426 * reset.
5427 */
5428 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
5429 u32 gpio_mask;
5430
5431 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE2 |
5432 GRC_LCLCTRL_GPIO_OUTPUT0 | GRC_LCLCTRL_GPIO_OUTPUT2;
5433
5434 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
5435 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
5436 GRC_LCLCTRL_GPIO_OUTPUT3;
5437
5438 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
5439
5440 /* GPIO1 must be driven high for eeprom write protect */
5337 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | 5441 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
5338 GRC_LCLCTRL_GPIO_OUTPUT1); 5442 GRC_LCLCTRL_GPIO_OUTPUT1);
5443 }
5339 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 5444 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
5340 udelay(100); 5445 udelay(100);
5341 5446
@@ -5353,6 +5458,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5353 WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB | 5458 WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
5354 WDMAC_MODE_LNGREAD_ENAB); 5459 WDMAC_MODE_LNGREAD_ENAB);
5355 5460
5461 /* If statement applies to 5705 and 5750 PCI devices only */
5356 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 5462 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
5357 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 5463 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
5358 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 5464 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
@@ -5706,6 +5812,118 @@ static void tg3_timer(unsigned long __opaque)
5706 add_timer(&tp->timer); 5812 add_timer(&tp->timer);
5707} 5813}
5708 5814
5815static int tg3_test_interrupt(struct tg3 *tp)
5816{
5817 struct net_device *dev = tp->dev;
5818 int err, i;
5819 u32 int_mbox = 0;
5820
5821 tg3_disable_ints(tp);
5822
5823 free_irq(tp->pdev->irq, dev);
5824
5825 err = request_irq(tp->pdev->irq, tg3_test_isr,
5826 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5827 if (err)
5828 return err;
5829
5830 tg3_enable_ints(tp);
5831
5832 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE |
5833 HOSTCC_MODE_NOW);
5834
5835 for (i = 0; i < 5; i++) {
5836 int_mbox = tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
5837 if (int_mbox != 0)
5838 break;
5839 msleep(10);
5840 }
5841
5842 tg3_disable_ints(tp);
5843
5844 free_irq(tp->pdev->irq, dev);
5845
5846 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5847 err = request_irq(tp->pdev->irq, tg3_msi,
5848 SA_SAMPLE_RANDOM, dev->name, dev);
5849 else
5850 err = request_irq(tp->pdev->irq, tg3_interrupt,
5851 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5852
5853 if (err)
5854 return err;
5855
5856 if (int_mbox != 0)
5857 return 0;
5858
5859 return -EIO;
5860}
5861
5862/* Returns 0 if MSI test succeeds or MSI test fails and INTx mode is
5863 * successfully restored
5864 */
5865static int tg3_test_msi(struct tg3 *tp)
5866{
5867 struct net_device *dev = tp->dev;
5868 int err;
5869 u16 pci_cmd;
5870
5871 if (!(tp->tg3_flags2 & TG3_FLG2_USING_MSI))
5872 return 0;
5873
5874 /* Turn off SERR reporting in case MSI terminates with Master
5875 * Abort.
5876 */
5877 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd);
5878 pci_write_config_word(tp->pdev, PCI_COMMAND,
5879 pci_cmd & ~PCI_COMMAND_SERR);
5880
5881 err = tg3_test_interrupt(tp);
5882
5883 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
5884
5885 if (!err)
5886 return 0;
5887
5888 /* other failures */
5889 if (err != -EIO)
5890 return err;
5891
5892 /* MSI test failed, go back to INTx mode */
5893 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
5894 "switching to INTx mode. Please report this failure to "
5895 "the PCI maintainer and include system chipset information.\n",
5896 tp->dev->name);
5897
5898 free_irq(tp->pdev->irq, dev);
5899 pci_disable_msi(tp->pdev);
5900
5901 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5902
5903 err = request_irq(tp->pdev->irq, tg3_interrupt,
5904 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5905
5906 if (err)
5907 return err;
5908
5909 /* Need to reset the chip because the MSI cycle may have terminated
5910 * with Master Abort.
5911 */
5912 spin_lock_irq(&tp->lock);
5913 spin_lock(&tp->tx_lock);
5914
5915 tg3_halt(tp, 1);
5916 err = tg3_init_hw(tp);
5917
5918 spin_unlock(&tp->tx_lock);
5919 spin_unlock_irq(&tp->lock);
5920
5921 if (err)
5922 free_irq(tp->pdev->irq, dev);
5923
5924 return err;
5925}
5926
5709static int tg3_open(struct net_device *dev) 5927static int tg3_open(struct net_device *dev)
5710{ 5928{
5711 struct tg3 *tp = netdev_priv(dev); 5929 struct tg3 *tp = netdev_priv(dev);
@@ -5727,10 +5945,29 @@ static int tg3_open(struct net_device *dev)
5727 if (err) 5945 if (err)
5728 return err; 5946 return err;
5729 5947
5730 err = request_irq(dev->irq, tg3_interrupt, 5948 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
5731 SA_SHIRQ, dev->name, dev); 5949 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&
5950 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) {
5951 if (pci_enable_msi(tp->pdev) == 0) {
5952 u32 msi_mode;
5953
5954 msi_mode = tr32(MSGINT_MODE);
5955 tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE);
5956 tp->tg3_flags2 |= TG3_FLG2_USING_MSI;
5957 }
5958 }
5959 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5960 err = request_irq(tp->pdev->irq, tg3_msi,
5961 SA_SAMPLE_RANDOM, dev->name, dev);
5962 else
5963 err = request_irq(tp->pdev->irq, tg3_interrupt,
5964 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5732 5965
5733 if (err) { 5966 if (err) {
5967 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
5968 pci_disable_msi(tp->pdev);
5969 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5970 }
5734 tg3_free_consistent(tp); 5971 tg3_free_consistent(tp);
5735 return err; 5972 return err;
5736 } 5973 }
@@ -5740,7 +5977,7 @@ static int tg3_open(struct net_device *dev)
5740 5977
5741 err = tg3_init_hw(tp); 5978 err = tg3_init_hw(tp);
5742 if (err) { 5979 if (err) {
5743 tg3_halt(tp); 5980 tg3_halt(tp, 1);
5744 tg3_free_rings(tp); 5981 tg3_free_rings(tp);
5745 } else { 5982 } else {
5746 tp->timer_offset = HZ / 10; 5983 tp->timer_offset = HZ / 10;
@@ -5751,23 +5988,47 @@ static int tg3_open(struct net_device *dev)
5751 tp->timer.expires = jiffies + tp->timer_offset; 5988 tp->timer.expires = jiffies + tp->timer_offset;
5752 tp->timer.data = (unsigned long) tp; 5989 tp->timer.data = (unsigned long) tp;
5753 tp->timer.function = tg3_timer; 5990 tp->timer.function = tg3_timer;
5754 add_timer(&tp->timer);
5755
5756 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
5757 } 5991 }
5758 5992
5759 spin_unlock(&tp->tx_lock); 5993 spin_unlock(&tp->tx_lock);
5760 spin_unlock_irq(&tp->lock); 5994 spin_unlock_irq(&tp->lock);
5761 5995
5762 if (err) { 5996 if (err) {
5763 free_irq(dev->irq, dev); 5997 free_irq(tp->pdev->irq, dev);
5998 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
5999 pci_disable_msi(tp->pdev);
6000 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6001 }
5764 tg3_free_consistent(tp); 6002 tg3_free_consistent(tp);
5765 return err; 6003 return err;
5766 } 6004 }
5767 6005
6006 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6007 err = tg3_test_msi(tp);
6008 if (err) {
6009 spin_lock_irq(&tp->lock);
6010 spin_lock(&tp->tx_lock);
6011
6012 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6013 pci_disable_msi(tp->pdev);
6014 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6015 }
6016 tg3_halt(tp, 1);
6017 tg3_free_rings(tp);
6018 tg3_free_consistent(tp);
6019
6020 spin_unlock(&tp->tx_lock);
6021 spin_unlock_irq(&tp->lock);
6022
6023 return err;
6024 }
6025 }
6026
5768 spin_lock_irq(&tp->lock); 6027 spin_lock_irq(&tp->lock);
5769 spin_lock(&tp->tx_lock); 6028 spin_lock(&tp->tx_lock);
5770 6029
6030 add_timer(&tp->timer);
6031 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
5771 tg3_enable_ints(tp); 6032 tg3_enable_ints(tp);
5772 6033
5773 spin_unlock(&tp->tx_lock); 6034 spin_unlock(&tp->tx_lock);
@@ -6025,7 +6286,7 @@ static int tg3_close(struct net_device *dev)
6025 6286
6026 tg3_disable_ints(tp); 6287 tg3_disable_ints(tp);
6027 6288
6028 tg3_halt(tp); 6289 tg3_halt(tp, 1);
6029 tg3_free_rings(tp); 6290 tg3_free_rings(tp);
6030 tp->tg3_flags &= 6291 tp->tg3_flags &=
6031 ~(TG3_FLAG_INIT_COMPLETE | 6292 ~(TG3_FLAG_INIT_COMPLETE |
@@ -6035,7 +6296,11 @@ static int tg3_close(struct net_device *dev)
6035 spin_unlock(&tp->tx_lock); 6296 spin_unlock(&tp->tx_lock);
6036 spin_unlock_irq(&tp->lock); 6297 spin_unlock_irq(&tp->lock);
6037 6298
6038 free_irq(dev->irq, dev); 6299 free_irq(tp->pdev->irq, dev);
6300 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6301 pci_disable_msi(tp->pdev);
6302 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6303 }
6039 6304
6040 memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev), 6305 memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev),
6041 sizeof(tp->net_stats_prev)); 6306 sizeof(tp->net_stats_prev));
@@ -6509,10 +6774,12 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
6509 start = cpu_to_le32(start); 6774 start = cpu_to_le32(start);
6510 len += b_offset; 6775 len += b_offset;
6511 offset &= ~3; 6776 offset &= ~3;
6777 if (len < 4)
6778 len = 4;
6512 } 6779 }
6513 6780
6514 odd_len = 0; 6781 odd_len = 0;
6515 if ((len & 3) && ((len > 4) || (b_offset == 0))) { 6782 if (len & 3) {
6516 /* adjustments to end on required 4 byte boundary */ 6783 /* adjustments to end on required 4 byte boundary */
6517 odd_len = 1; 6784 odd_len = 1;
6518 len = (len + 3) & ~3; 6785 len = (len + 3) & ~3;
@@ -6739,7 +7006,7 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e
6739 tp->tx_pending = ering->tx_pending; 7006 tp->tx_pending = ering->tx_pending;
6740 7007
6741 if (netif_running(dev)) { 7008 if (netif_running(dev)) {
6742 tg3_halt(tp); 7009 tg3_halt(tp, 1);
6743 tg3_init_hw(tp); 7010 tg3_init_hw(tp);
6744 tg3_netif_start(tp); 7011 tg3_netif_start(tp);
6745 } 7012 }
@@ -6782,7 +7049,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam
6782 tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE; 7049 tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE;
6783 7050
6784 if (netif_running(dev)) { 7051 if (netif_running(dev)) {
6785 tg3_halt(tp); 7052 tg3_halt(tp, 1);
6786 tg3_init_hw(tp); 7053 tg3_init_hw(tp);
6787 tg3_netif_start(tp); 7054 tg3_netif_start(tp);
6788 } 7055 }
@@ -7067,6 +7334,67 @@ static void __devinit tg3_get_nvram_info(struct tg3 *tp)
7067 } 7334 }
7068} 7335}
7069 7336
7337static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)
7338{
7339 u32 nvcfg1;
7340
7341 nvcfg1 = tr32(NVRAM_CFG1);
7342
7343 /* NVRAM protection for TPM */
7344 if (nvcfg1 & (1 << 27))
7345 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
7346
7347 switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) {
7348 case FLASH_5752VENDOR_ATMEL_EEPROM_64KHZ:
7349 case FLASH_5752VENDOR_ATMEL_EEPROM_376KHZ:
7350 tp->nvram_jedecnum = JEDEC_ATMEL;
7351 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7352 break;
7353 case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
7354 tp->nvram_jedecnum = JEDEC_ATMEL;
7355 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7356 tp->tg3_flags2 |= TG3_FLG2_FLASH;
7357 break;
7358 case FLASH_5752VENDOR_ST_M45PE10:
7359 case FLASH_5752VENDOR_ST_M45PE20:
7360 case FLASH_5752VENDOR_ST_M45PE40:
7361 tp->nvram_jedecnum = JEDEC_ST;
7362 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7363 tp->tg3_flags2 |= TG3_FLG2_FLASH;
7364 break;
7365 }
7366
7367 if (tp->tg3_flags2 & TG3_FLG2_FLASH) {
7368 switch (nvcfg1 & NVRAM_CFG1_5752PAGE_SIZE_MASK) {
7369 case FLASH_5752PAGE_SIZE_256:
7370 tp->nvram_pagesize = 256;
7371 break;
7372 case FLASH_5752PAGE_SIZE_512:
7373 tp->nvram_pagesize = 512;
7374 break;
7375 case FLASH_5752PAGE_SIZE_1K:
7376 tp->nvram_pagesize = 1024;
7377 break;
7378 case FLASH_5752PAGE_SIZE_2K:
7379 tp->nvram_pagesize = 2048;
7380 break;
7381 case FLASH_5752PAGE_SIZE_4K:
7382 tp->nvram_pagesize = 4096;
7383 break;
7384 case FLASH_5752PAGE_SIZE_264:
7385 tp->nvram_pagesize = 264;
7386 break;
7387 }
7388 }
7389 else {
7390 /* For eeprom, set pagesize to maximum eeprom size */
7391 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
7392
7393 nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
7394 tw32(NVRAM_CFG1, nvcfg1);
7395 }
7396}
7397
7070/* Chips other than 5700/5701 use the NVRAM for fetching info. */ 7398/* Chips other than 5700/5701 use the NVRAM for fetching info. */
7071static void __devinit tg3_nvram_init(struct tg3 *tp) 7399static void __devinit tg3_nvram_init(struct tg3 *tp)
7072{ 7400{
@@ -7093,20 +7421,16 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
7093 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { 7421 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
7094 tp->tg3_flags |= TG3_FLAG_NVRAM; 7422 tp->tg3_flags |= TG3_FLAG_NVRAM;
7095 7423
7096 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7424 tg3_enable_nvram_access(tp);
7097 u32 nvaccess = tr32(NVRAM_ACCESS);
7098 7425
7099 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE); 7426 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
7100 } 7427 tg3_get_5752_nvram_info(tp);
7428 else
7429 tg3_get_nvram_info(tp);
7101 7430
7102 tg3_get_nvram_info(tp);
7103 tg3_get_nvram_size(tp); 7431 tg3_get_nvram_size(tp);
7104 7432
7105 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7433 tg3_disable_nvram_access(tp);
7106 u32 nvaccess = tr32(NVRAM_ACCESS);
7107
7108 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7109 }
7110 7434
7111 } else { 7435 } else {
7112 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); 7436 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
@@ -7195,11 +7519,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
7195 7519
7196 tg3_nvram_lock(tp); 7520 tg3_nvram_lock(tp);
7197 7521
7198 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7522 tg3_enable_nvram_access(tp);
7199 u32 nvaccess = tr32(NVRAM_ACCESS);
7200
7201 tw32_f(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7202 }
7203 7523
7204 tw32(NVRAM_ADDR, offset); 7524 tw32(NVRAM_ADDR, offset);
7205 ret = tg3_nvram_exec_cmd(tp, NVRAM_CMD_RD | NVRAM_CMD_GO | 7525 ret = tg3_nvram_exec_cmd(tp, NVRAM_CMD_RD | NVRAM_CMD_GO |
@@ -7210,11 +7530,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
7210 7530
7211 tg3_nvram_unlock(tp); 7531 tg3_nvram_unlock(tp);
7212 7532
7213 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7533 tg3_disable_nvram_access(tp);
7214 u32 nvaccess = tr32(NVRAM_ACCESS);
7215
7216 tw32_f(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7217 }
7218 7534
7219 return ret; 7535 return ret;
7220} 7536}
@@ -7277,7 +7593,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
7277 7593
7278 while (len) { 7594 while (len) {
7279 int j; 7595 int j;
7280 u32 phy_addr, page_off, size, nvaccess; 7596 u32 phy_addr, page_off, size;
7281 7597
7282 phy_addr = offset & ~pagemask; 7598 phy_addr = offset & ~pagemask;
7283 7599
@@ -7300,8 +7616,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
7300 7616
7301 offset = offset + (pagesize - page_off); 7617 offset = offset + (pagesize - page_off);
7302 7618
7303 nvaccess = tr32(NVRAM_ACCESS); 7619 tg3_enable_nvram_access(tp);
7304 tw32_f(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7305 7620
7306 /* 7621 /*
7307 * Before we can erase the flash page, we need 7622 * Before we can erase the flash page, we need
@@ -7425,8 +7740,8 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7425 } 7740 }
7426 7741
7427 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 7742 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
7428 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 7743 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
7429 GRC_LCLCTRL_GPIO_OE1); 7744 ~GRC_LCLCTRL_GPIO_OUTPUT1);
7430 udelay(40); 7745 udelay(40);
7431 } 7746 }
7432 7747
@@ -7438,13 +7753,10 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7438 7753
7439 tg3_nvram_lock(tp); 7754 tg3_nvram_lock(tp);
7440 7755
7441 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7756 tg3_enable_nvram_access(tp);
7442 u32 nvaccess = tr32(NVRAM_ACCESS); 7757 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
7443 7758 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM))
7444 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7445
7446 tw32(NVRAM_WRITE1, 0x406); 7759 tw32(NVRAM_WRITE1, 0x406);
7447 }
7448 7760
7449 grc_mode = tr32(GRC_MODE); 7761 grc_mode = tr32(GRC_MODE);
7450 tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE); 7762 tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE);
@@ -7463,17 +7775,12 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7463 grc_mode = tr32(GRC_MODE); 7775 grc_mode = tr32(GRC_MODE);
7464 tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE); 7776 tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE);
7465 7777
7466 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7778 tg3_disable_nvram_access(tp);
7467 u32 nvaccess = tr32(NVRAM_ACCESS);
7468
7469 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7470 }
7471 tg3_nvram_unlock(tp); 7779 tg3_nvram_unlock(tp);
7472 } 7780 }
7473 7781
7474 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 7782 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
7475 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 7783 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
7476 GRC_LCLCTRL_GPIO_OE1 | GRC_LCLCTRL_GPIO_OUTPUT1);
7477 udelay(40); 7784 udelay(40);
7478 } 7785 }
7479 7786
@@ -7537,21 +7844,27 @@ static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp)
7537 return NULL; 7844 return NULL;
7538} 7845}
7539 7846
7540static int __devinit tg3_phy_probe(struct tg3 *tp) 7847/* Since this function may be called in D3-hot power state during
7848 * tg3_init_one(), only config cycles are allowed.
7849 */
7850static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
7541{ 7851{
7542 u32 eeprom_phy_id, hw_phy_id_1, hw_phy_id_2;
7543 u32 hw_phy_id, hw_phy_id_masked;
7544 u32 val; 7852 u32 val;
7545 int eeprom_signature_found, eeprom_phy_serdes, err; 7853
7854 /* Make sure register accesses (indirect or otherwise)
7855 * will function correctly.
7856 */
7857 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
7858 tp->misc_host_ctrl);
7546 7859
7547 tp->phy_id = PHY_ID_INVALID; 7860 tp->phy_id = PHY_ID_INVALID;
7548 eeprom_phy_id = PHY_ID_INVALID; 7861 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
7549 eeprom_phy_serdes = 0; 7862
7550 eeprom_signature_found = 0;
7551 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 7863 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
7552 if (val == NIC_SRAM_DATA_SIG_MAGIC) { 7864 if (val == NIC_SRAM_DATA_SIG_MAGIC) {
7553 u32 nic_cfg, led_cfg; 7865 u32 nic_cfg, led_cfg;
7554 u32 nic_phy_id, ver, cfg2 = 0; 7866 u32 nic_phy_id, ver, cfg2 = 0, eeprom_phy_id;
7867 int eeprom_phy_serdes = 0;
7555 7868
7556 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 7869 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
7557 tp->nic_sram_data_cfg = nic_cfg; 7870 tp->nic_sram_data_cfg = nic_cfg;
@@ -7564,8 +7877,6 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7564 (ver > 0) && (ver < 0x100)) 7877 (ver > 0) && (ver < 0x100))
7565 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2); 7878 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2);
7566 7879
7567 eeprom_signature_found = 1;
7568
7569 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) == 7880 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) ==
7570 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER) 7881 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER)
7571 eeprom_phy_serdes = 1; 7882 eeprom_phy_serdes = 1;
@@ -7581,10 +7892,14 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7581 } else 7892 } else
7582 eeprom_phy_id = 0; 7893 eeprom_phy_id = 0;
7583 7894
7584 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7895 tp->phy_id = eeprom_phy_id;
7896 if (eeprom_phy_serdes)
7897 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
7898
7899 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7585 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK | 7900 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK |
7586 SHASTA_EXT_LED_MODE_MASK); 7901 SHASTA_EXT_LED_MODE_MASK);
7587 } else 7902 else
7588 led_cfg = nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK; 7903 led_cfg = nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK;
7589 7904
7590 switch (led_cfg) { 7905 switch (led_cfg) {
@@ -7634,7 +7949,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7634 7949
7635 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 7950 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
7636 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 7951 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
7637 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 7952 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7638 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 7953 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
7639 } 7954 }
7640 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL) 7955 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)
@@ -7648,6 +7963,13 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7648 if (cfg2 & (1 << 18)) 7963 if (cfg2 & (1 << 18))
7649 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS; 7964 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS;
7650 } 7965 }
7966}
7967
7968static int __devinit tg3_phy_probe(struct tg3 *tp)
7969{
7970 u32 hw_phy_id_1, hw_phy_id_2;
7971 u32 hw_phy_id, hw_phy_id_masked;
7972 int err;
7651 7973
7652 /* Reading the PHY ID register can conflict with ASF 7974 /* Reading the PHY ID register can conflict with ASF
7653 * firwmare access to the PHY hardware. 7975 * firwmare access to the PHY hardware.
@@ -7676,10 +7998,10 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7676 if (hw_phy_id_masked == PHY_ID_BCM8002) 7998 if (hw_phy_id_masked == PHY_ID_BCM8002)
7677 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 7999 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
7678 } else { 8000 } else {
7679 if (eeprom_signature_found) { 8001 if (tp->phy_id != PHY_ID_INVALID) {
7680 tp->phy_id = eeprom_phy_id; 8002 /* Do nothing, phy ID already set up in
7681 if (eeprom_phy_serdes) 8003 * tg3_get_eeprom_hw_cfg().
7682 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 8004 */
7683 } else { 8005 } else {
7684 struct subsys_tbl_ent *p; 8006 struct subsys_tbl_ent *p;
7685 8007
@@ -7750,9 +8072,6 @@ skip_phy_reset:
7750 err = tg3_init_5401phy_dsp(tp); 8072 err = tg3_init_5401phy_dsp(tp);
7751 } 8073 }
7752 8074
7753 if (!eeprom_signature_found)
7754 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
7755
7756 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 8075 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
7757 tp->link_config.advertising = 8076 tp->link_config.advertising =
7758 (ADVERTISED_1000baseT_Half | 8077 (ADVERTISED_1000baseT_Half |
@@ -7917,6 +8236,12 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
7917 tp->pci_chip_rev_id = (misc_ctrl_reg >> 8236 tp->pci_chip_rev_id = (misc_ctrl_reg >>
7918 MISC_HOST_CTRL_CHIPREV_SHIFT); 8237 MISC_HOST_CTRL_CHIPREV_SHIFT);
7919 8238
8239 /* Wrong chip ID in 5752 A0. This code can be removed later
8240 * as A0 is not in production.
8241 */
8242 if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW)
8243 tp->pci_chip_rev_id = CHIPREV_ID_5752_A0;
8244
7920 /* Initialize misc host control in PCI block. */ 8245 /* Initialize misc host control in PCI block. */
7921 tp->misc_host_ctrl |= (misc_ctrl_reg & 8246 tp->misc_host_ctrl |= (misc_ctrl_reg &
7922 MISC_HOST_CTRL_CHIPREV); 8247 MISC_HOST_CTRL_CHIPREV);
@@ -7931,11 +8256,15 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
7931 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff; 8256 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff;
7932 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff; 8257 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
7933 8258
8259 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
8260 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
8261 tp->tg3_flags2 |= TG3_FLG2_5750_PLUS;
8262
7934 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) || 8263 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) ||
7935 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) 8264 (tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
7936 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; 8265 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
7937 8266
7938 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 8267 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7939 tp->tg3_flags2 |= TG3_FLG2_HW_TSO; 8268 tp->tg3_flags2 |= TG3_FLG2_HW_TSO;
7940 8269
7941 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 8270 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0)
@@ -8013,6 +8342,31 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8013 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg); 8342 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg);
8014 } 8343 }
8015 8344
8345 /* Get eeprom hw config before calling tg3_set_power_state().
8346 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be
8347 * determined before calling tg3_set_power_state() so that
8348 * we know whether or not to switch out of Vaux power.
8349 * When the flag is set, it means that GPIO1 is used for eeprom
8350 * write protect and also implies that it is a LOM where GPIOs
8351 * are not used to switch power.
8352 */
8353 tg3_get_eeprom_hw_cfg(tp);
8354
8355 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state().
8356 * GPIO1 driven high will bring 5700's external PHY out of reset.
8357 * It is also used as eeprom write protect on LOMs.
8358 */
8359 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM;
8360 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
8361 (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
8362 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
8363 GRC_LCLCTRL_GPIO_OUTPUT1);
8364 /* Unused GPIO3 must be driven as output on 5752 because there
8365 * are no pull-up resistors on unused GPIO pins.
8366 */
8367 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
8368 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
8369
8016 /* Force the chip into D0. */ 8370 /* Force the chip into D0. */
8017 err = tg3_set_power_state(tp, 0); 8371 err = tg3_set_power_state(tp, 0);
8018 if (err) { 8372 if (err) {
@@ -8065,8 +8419,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8065 if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) 8419 if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0)
8066 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; 8420 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG;
8067 8421
8068 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 || 8422 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
8069 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
8070 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; 8423 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
8071 8424
8072 /* Only 5701 and later support tagged irq status mode. 8425 /* Only 5701 and later support tagged irq status mode.
@@ -8628,6 +8981,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
8628 case PHY_ID_BCM5704: return "5704"; 8981 case PHY_ID_BCM5704: return "5704";
8629 case PHY_ID_BCM5705: return "5705"; 8982 case PHY_ID_BCM5705: return "5705";
8630 case PHY_ID_BCM5750: return "5750"; 8983 case PHY_ID_BCM5750: return "5750";
8984 case PHY_ID_BCM5752: return "5752";
8631 case PHY_ID_BCM8002: return "8002/serdes"; 8985 case PHY_ID_BCM8002: return "8002/serdes";
8632 case 0: return "serdes"; 8986 case 0: return "serdes";
8633 default: return "unknown"; 8987 default: return "unknown";
@@ -8878,7 +9232,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
8878 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 9232 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
8879 pci_save_state(tp->pdev); 9233 pci_save_state(tp->pdev);
8880 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); 9234 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
8881 tg3_halt(tp); 9235 tg3_halt(tp, 1);
8882 } 9236 }
8883 9237
8884 err = tg3_test_dma(tp); 9238 err = tg3_test_dma(tp);
@@ -9001,7 +9355,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
9001 9355
9002 spin_lock_irq(&tp->lock); 9356 spin_lock_irq(&tp->lock);
9003 spin_lock(&tp->tx_lock); 9357 spin_lock(&tp->tx_lock);
9004 tg3_halt(tp); 9358 tg3_halt(tp, 1);
9005 spin_unlock(&tp->tx_lock); 9359 spin_unlock(&tp->tx_lock);
9006 spin_unlock_irq(&tp->lock); 9360 spin_unlock_irq(&tp->lock);
9007 9361
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index d48887d90325..8de6f21037ba 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -125,6 +125,9 @@
125#define CHIPREV_ID_5750_A0 0x4000 125#define CHIPREV_ID_5750_A0 0x4000
126#define CHIPREV_ID_5750_A1 0x4001 126#define CHIPREV_ID_5750_A1 0x4001
127#define CHIPREV_ID_5750_A3 0x4003 127#define CHIPREV_ID_5750_A3 0x4003
128#define CHIPREV_ID_5752_A0_HW 0x5000
129#define CHIPREV_ID_5752_A0 0x6000
130#define CHIPREV_ID_5752_A1 0x6001
128#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) 131#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
129#define ASIC_REV_5700 0x07 132#define ASIC_REV_5700 0x07
130#define ASIC_REV_5701 0x00 133#define ASIC_REV_5701 0x00
@@ -132,6 +135,7 @@
132#define ASIC_REV_5704 0x02 135#define ASIC_REV_5704 0x02
133#define ASIC_REV_5705 0x03 136#define ASIC_REV_5705 0x03
134#define ASIC_REV_5750 0x04 137#define ASIC_REV_5750 0x04
138#define ASIC_REV_5752 0x06
135#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) 139#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
136#define CHIPREV_5700_AX 0x70 140#define CHIPREV_5700_AX 0x70
137#define CHIPREV_5700_BX 0x71 141#define CHIPREV_5700_BX 0x71
@@ -1307,6 +1311,9 @@
1307#define GRC_LCLCTRL_CLEARINT 0x00000002 1311#define GRC_LCLCTRL_CLEARINT 0x00000002
1308#define GRC_LCLCTRL_SETINT 0x00000004 1312#define GRC_LCLCTRL_SETINT 0x00000004
1309#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 1313#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
1314#define GRC_LCLCTRL_GPIO_INPUT3 0x00000020
1315#define GRC_LCLCTRL_GPIO_OE3 0x00000040
1316#define GRC_LCLCTRL_GPIO_OUTPUT3 0x00000080
1310#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100 1317#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100
1311#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200 1318#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200
1312#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400 1319#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400
@@ -1392,6 +1399,20 @@
1392#define FLASH_VENDOR_SAIFUN 0x01000003 1399#define FLASH_VENDOR_SAIFUN 0x01000003
1393#define FLASH_VENDOR_SST_SMALL 0x00000001 1400#define FLASH_VENDOR_SST_SMALL 0x00000001
1394#define FLASH_VENDOR_SST_LARGE 0x02000001 1401#define FLASH_VENDOR_SST_LARGE 0x02000001
1402#define NVRAM_CFG1_5752VENDOR_MASK 0x03c00003
1403#define FLASH_5752VENDOR_ATMEL_EEPROM_64KHZ 0x00000000
1404#define FLASH_5752VENDOR_ATMEL_EEPROM_376KHZ 0x02000000
1405#define FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED 0x02000003
1406#define FLASH_5752VENDOR_ST_M45PE10 0x02400000
1407#define FLASH_5752VENDOR_ST_M45PE20 0x02400002
1408#define FLASH_5752VENDOR_ST_M45PE40 0x02400001
1409#define NVRAM_CFG1_5752PAGE_SIZE_MASK 0x70000000
1410#define FLASH_5752PAGE_SIZE_256 0x00000000
1411#define FLASH_5752PAGE_SIZE_512 0x10000000
1412#define FLASH_5752PAGE_SIZE_1K 0x20000000
1413#define FLASH_5752PAGE_SIZE_2K 0x30000000
1414#define FLASH_5752PAGE_SIZE_4K 0x40000000
1415#define FLASH_5752PAGE_SIZE_264 0x50000000
1395#define NVRAM_CFG2 0x00007018 1416#define NVRAM_CFG2 0x00007018
1396#define NVRAM_CFG3 0x0000701c 1417#define NVRAM_CFG3 0x0000701c
1397#define NVRAM_SWARB 0x00007020 1418#define NVRAM_SWARB 0x00007020
@@ -2100,6 +2121,9 @@ struct tg3 {
2100#define TG3_FLG2_HW_TSO 0x00010000 2121#define TG3_FLG2_HW_TSO 0x00010000
2101#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000 2122#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000
2102#define TG3_FLG2_5705_PLUS 0x00040000 2123#define TG3_FLG2_5705_PLUS 0x00040000
2124#define TG3_FLG2_5750_PLUS 0x00080000
2125#define TG3_FLG2_PROTECTED_NVRAM 0x00100000
2126#define TG3_FLG2_USING_MSI 0x00200000
2103 2127
2104 u32 split_mode_max_reqs; 2128 u32 split_mode_max_reqs;
2105#define SPLIT_MODE_5704_MAX_REQ 3 2129#define SPLIT_MODE_5704_MAX_REQ 3
@@ -2145,6 +2169,7 @@ struct tg3 {
2145#define PHY_ID_BCM5704 0x60008190 2169#define PHY_ID_BCM5704 0x60008190
2146#define PHY_ID_BCM5705 0x600081a0 2170#define PHY_ID_BCM5705 0x600081a0
2147#define PHY_ID_BCM5750 0x60008180 2171#define PHY_ID_BCM5750 0x60008180
2172#define PHY_ID_BCM5752 0x60008100
2148#define PHY_ID_BCM8002 0x60010140 2173#define PHY_ID_BCM8002 0x60010140
2149#define PHY_ID_INVALID 0xffffffff 2174#define PHY_ID_INVALID 0xffffffff
2150#define PHY_ID_REV_MASK 0x0000000f 2175#define PHY_ID_REV_MASK 0x0000000f
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 35791934a602..66b94668ddd8 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -26,7 +26,7 @@ config WAN
26# There is no way to detect a comtrol sv11 - force it modular for now. 26# There is no way to detect a comtrol sv11 - force it modular for now.
27config HOSTESS_SV11 27config HOSTESS_SV11
28 tristate "Comtrol Hostess SV-11 support" 28 tristate "Comtrol Hostess SV-11 support"
29 depends on WAN && ISA && m 29 depends on WAN && ISA && m && ISA_DMA_API
30 help 30 help
31 Driver for Comtrol Hostess SV-11 network card which 31 Driver for Comtrol Hostess SV-11 network card which
32 operates on low speed synchronous serial links at up to 32 operates on low speed synchronous serial links at up to
@@ -38,7 +38,7 @@ config HOSTESS_SV11
38# The COSA/SRP driver has not been tested as non-modular yet. 38# The COSA/SRP driver has not been tested as non-modular yet.
39config COSA 39config COSA
40 tristate "COSA/SRP sync serial boards support" 40 tristate "COSA/SRP sync serial boards support"
41 depends on WAN && ISA && m 41 depends on WAN && ISA && m && ISA_DMA_API
42 ---help--- 42 ---help---
43 Driver for COSA and SRP synchronous serial boards. 43 Driver for COSA and SRP synchronous serial boards.
44 44
@@ -127,7 +127,7 @@ config LANMEDIA
127# There is no way to detect a Sealevel board. Force it modular 127# There is no way to detect a Sealevel board. Force it modular
128config SEALEVEL_4021 128config SEALEVEL_4021
129 tristate "Sealevel Systems 4021 support" 129 tristate "Sealevel Systems 4021 support"
130 depends on WAN && ISA && m 130 depends on WAN && ISA && m && ISA_DMA_API
131 help 131 help
132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
133 133
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 5b48cd8568f5..02d57c0b4243 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -436,9 +436,7 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
436 } 436 }
437 437
438 if (err) { 438 if (err) {
439 if (chan->local_addr) 439 kfree(chan->local_addr);
440 kfree(chan->local_addr);
441
442 kfree(chan); 440 kfree(chan);
443 return err; 441 return err;
444 } 442 }
@@ -458,9 +456,7 @@ static int cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev)
458 struct cycx_x25_channel *chan = dev->priv; 456 struct cycx_x25_channel *chan = dev->priv;
459 457
460 if (chan->svc) { 458 if (chan->svc) {
461 if (chan->local_addr) 459 kfree(chan->local_addr);
462 kfree(chan->local_addr);
463
464 if (chan->state == WAN_CONNECTED) 460 if (chan->state == WAN_CONNECTED)
465 del_timer(&chan->timer); 461 del_timer(&chan->timer);
466 } 462 }
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index d67be2587d4d..3e7753b10717 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3427,7 +3427,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3427{ 3427{
3428 static int first_time = 1; 3428 static int first_time = 1;
3429 ucchar cpc_rev_id; 3429 ucchar cpc_rev_id;
3430 int err = 0, eeprom_outdated = 0; 3430 int err, eeprom_outdated = 0;
3431 ucshort device_id; 3431 ucshort device_id;
3432 pc300_t *card; 3432 pc300_t *card;
3433 3433
@@ -3439,15 +3439,21 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3439#endif 3439#endif
3440 } 3440 }
3441 3441
3442 if ((err = pci_enable_device(pdev)) < 0)
3443 return err;
3444
3442 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); 3445 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);
3443 if (card == NULL) { 3446 if (card == NULL) {
3444 printk("PC300 found at RAM 0x%08lx, " 3447 printk("PC300 found at RAM 0x%08lx, "
3445 "but could not allocate card structure.\n", 3448 "but could not allocate card structure.\n",
3446 pci_resource_start(pdev, 3)); 3449 pci_resource_start(pdev, 3));
3447 return -ENOMEM; 3450 err = -ENOMEM;
3451 goto err_disable_dev;
3448 } 3452 }
3449 memset(card, 0, sizeof(pc300_t)); 3453 memset(card, 0, sizeof(pc300_t));
3450 3454
3455 err = -ENODEV;
3456
3451 /* read PCI configuration area */ 3457 /* read PCI configuration area */
3452 device_id = ent->device; 3458 device_id = ent->device;
3453 card->hw.irq = pdev->irq; 3459 card->hw.irq = pdev->irq;
@@ -3507,7 +3513,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3507 printk("PC300 found at RAM 0x%08x, " 3513 printk("PC300 found at RAM 0x%08x, "
3508 "but could not allocate PLX mem region.\n", 3514 "but could not allocate PLX mem region.\n",
3509 card->hw.ramphys); 3515 card->hw.ramphys);
3510 err = -ENODEV;
3511 goto err_release_io; 3516 goto err_release_io;
3512 } 3517 }
3513 if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize, 3518 if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,
@@ -3515,7 +3520,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3515 printk("PC300 found at RAM 0x%08x, " 3520 printk("PC300 found at RAM 0x%08x, "
3516 "but could not allocate RAM mem region.\n", 3521 "but could not allocate RAM mem region.\n",
3517 card->hw.ramphys); 3522 card->hw.ramphys);
3518 err = -ENODEV;
3519 goto err_release_plx; 3523 goto err_release_plx;
3520 } 3524 }
3521 if (!request_mem_region(card->hw.scaphys, card->hw.scasize, 3525 if (!request_mem_region(card->hw.scaphys, card->hw.scasize,
@@ -3523,13 +3527,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3523 printk("PC300 found at RAM 0x%08x, " 3527 printk("PC300 found at RAM 0x%08x, "
3524 "but could not allocate SCA mem region.\n", 3528 "but could not allocate SCA mem region.\n",
3525 card->hw.ramphys); 3529 card->hw.ramphys);
3526 err = -ENODEV;
3527 goto err_release_ram; 3530 goto err_release_ram;
3528 } 3531 }
3529 3532
3530 if ((err = pci_enable_device(pdev)) != 0)
3531 goto err_release_sca;
3532
3533 card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize); 3533 card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize);
3534 card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize); 3534 card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize);
3535 card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize); 3535 card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize);
@@ -3619,7 +3619,6 @@ err_io_unmap:
3619 iounmap(card->hw.falcbase); 3619 iounmap(card->hw.falcbase);
3620 release_mem_region(card->hw.falcphys, card->hw.falcsize); 3620 release_mem_region(card->hw.falcphys, card->hw.falcsize);
3621 } 3621 }
3622err_release_sca:
3623 release_mem_region(card->hw.scaphys, card->hw.scasize); 3622 release_mem_region(card->hw.scaphys, card->hw.scasize);
3624err_release_ram: 3623err_release_ram:
3625 release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize); 3624 release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
@@ -3628,7 +3627,9 @@ err_release_plx:
3628err_release_io: 3627err_release_io:
3629 release_region(card->hw.iophys, card->hw.iosize); 3628 release_region(card->hw.iophys, card->hw.iosize);
3630 kfree(card); 3629 kfree(card);
3631 return -ENODEV; 3630err_disable_dev:
3631 pci_disable_device(pdev);
3632 return err;
3632} 3633}
3633 3634
3634static void __devexit cpc_remove_one(struct pci_dev *pdev) 3635static void __devexit cpc_remove_one(struct pci_dev *pdev)
@@ -3662,6 +3663,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev)
3662 if (card->hw.irq) 3663 if (card->hw.irq)
3663 free_irq(card->hw.irq, card); 3664 free_irq(card->hw.irq, card);
3664 kfree(card); 3665 kfree(card);
3666 pci_disable_device(pdev);
3665 } 3667 }
3666} 3668}
3667 3669
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 29f84ad08730..8454bf6caaa7 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -400,10 +400,8 @@ static void cpc_tty_close(struct tty_struct *tty, struct file *flip)
400 cpc_tty->buf_rx.last = NULL; 400 cpc_tty->buf_rx.last = NULL;
401 } 401 }
402 402
403 if (cpc_tty->buf_tx) { 403 kfree(cpc_tty->buf_tx);
404 kfree(cpc_tty->buf_tx); 404 cpc_tty->buf_tx = NULL;
405 cpc_tty->buf_tx = NULL;
406 }
407 405
408 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name); 406 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name);
409 407
@@ -666,7 +664,7 @@ static void cpc_tty_rx_work(void * data)
666 unsigned long port; 664 unsigned long port;
667 int i, j; 665 int i, j;
668 st_cpc_tty_area *cpc_tty; 666 st_cpc_tty_area *cpc_tty;
669 volatile st_cpc_rx_buf * buf; 667 volatile st_cpc_rx_buf *buf;
670 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
671 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
672 670
@@ -680,9 +678,9 @@ static void cpc_tty_rx_work(void * data)
680 cpc_tty = &cpc_tty_area[port]; 678 cpc_tty = &cpc_tty_area[port];
681 679
682 if ((buf=cpc_tty->buf_rx.first) != 0) { 680 if ((buf=cpc_tty->buf_rx.first) != 0) {
683 if(cpc_tty->tty) { 681 if (cpc_tty->tty) {
684 ld = tty_ldisc_ref(cpc_tty->tty); 682 ld = tty_ldisc_ref(cpc_tty->tty);
685 if(ld) { 683 if (ld) {
686 if (ld->receive_buf) { 684 if (ld->receive_buf) {
687 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name); 685 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
688 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); 686 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
@@ -691,7 +689,7 @@ static void cpc_tty_rx_work(void * data)
691 } 689 }
692 } 690 }
693 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next; 691 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next;
694 kfree((unsigned char *)buf); 692 kfree(buf);
695 buf = cpc_tty->buf_rx.first; 693 buf = cpc_tty->buf_rx.first;
696 flg_rx = 1; 694 flg_rx = 1;
697 } 695 }
@@ -733,7 +731,7 @@ static void cpc_tty_rx_disc_frame(pc300ch_t *pc300chan)
733 731
734void cpc_tty_receive(pc300dev_t *pc300dev) 732void cpc_tty_receive(pc300dev_t *pc300dev)
735{ 733{
736 st_cpc_tty_area *cpc_tty; 734 st_cpc_tty_area *cpc_tty;
737 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan; 735 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
738 pc300_t *card = (pc300_t *)pc300chan->card; 736 pc300_t *card = (pc300_t *)pc300chan->card;
739 int ch = pc300chan->channel; 737 int ch = pc300chan->channel;
@@ -742,7 +740,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
742 int rx_len, rx_aux; 740 int rx_len, rx_aux;
743 volatile unsigned char status; 741 volatile unsigned char status;
744 unsigned short first_bd = pc300chan->rx_first_bd; 742 unsigned short first_bd = pc300chan->rx_first_bd;
745 st_cpc_rx_buf *new=NULL; 743 st_cpc_rx_buf *new = NULL;
746 unsigned char dsr_rx; 744 unsigned char dsr_rx;
747 745
748 if (pc300dev->cpc_tty == NULL) { 746 if (pc300dev->cpc_tty == NULL) {
@@ -762,7 +760,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
762 if (status & DST_EOM) { 760 if (status & DST_EOM) {
763 break; 761 break;
764 } 762 }
765 ptdescr=(pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next)); 763 ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));
766 } 764 }
767 765
768 if (!rx_len) { 766 if (!rx_len) {
@@ -771,10 +769,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
771 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 769 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
772 RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 770 RX_BD_ADDR(ch, pc300chan->rx_last_bd));
773 } 771 }
774 if (new) { 772 kfree(new);
775 kfree(new);
776 new = NULL;
777 }
778 return; 773 return;
779 } 774 }
780 775
@@ -787,7 +782,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
787 continue; 782 continue;
788 } 783 }
789 784
790 new = (st_cpc_rx_buf *) kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); 785 new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
791 if (new == 0) { 786 if (new == 0) {
792 cpc_tty_rx_disc_frame(pc300chan); 787 cpc_tty_rx_disc_frame(pc300chan);
793 continue; 788 continue;
diff --git a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c
index afbe0024e3e1..496d29237e92 100644
--- a/drivers/net/wan/sdla_chdlc.c
+++ b/drivers/net/wan/sdla_chdlc.c
@@ -3664,15 +3664,10 @@ static void wanpipe_tty_close(struct tty_struct *tty, struct file * filp)
3664 chdlc_disable_comm_shutdown(card); 3664 chdlc_disable_comm_shutdown(card);
3665 unlock_adapter_irq(&card->wandev.lock,&smp_flags); 3665 unlock_adapter_irq(&card->wandev.lock,&smp_flags);
3666 3666
3667 if (card->tty_buf){ 3667 kfree(card->tty_buf);
3668 kfree(card->tty_buf); 3668 card->tty_buf = NULL;
3669 card->tty_buf=NULL; 3669 kfree(card->tty_rx);
3670 } 3670 card->tty_rx = NULL;
3671
3672 if (card->tty_rx){
3673 kfree(card->tty_rx);
3674 card->tty_rx=NULL;
3675 }
3676 } 3671 }
3677 return; 3672 return;
3678} 3673}
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 8c5cfcb55826..1c540d825551 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -107,13 +107,9 @@ static struct x25_asy *x25_asy_alloc(void)
107static void x25_asy_free(struct x25_asy *sl) 107static void x25_asy_free(struct x25_asy *sl)
108{ 108{
109 /* Free all X.25 frame buffers. */ 109 /* Free all X.25 frame buffers. */
110 if (sl->rbuff) { 110 kfree(sl->rbuff);
111 kfree(sl->rbuff);
112 }
113 sl->rbuff = NULL; 111 sl->rbuff = NULL;
114 if (sl->xbuff) { 112 kfree(sl->xbuff);
115 kfree(sl->xbuff);
116 }
117 sl->xbuff = NULL; 113 sl->xbuff = NULL;
118 114
119 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { 115 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) {
@@ -134,10 +130,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
134 { 130 {
135 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", 131 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n",
136 dev->name); 132 dev->name);
137 if (xbuff != NULL) 133 kfree(xbuff);
138 kfree(xbuff); 134 kfree(rbuff);
139 if (rbuff != NULL)
140 kfree(rbuff);
141 return -ENOMEM; 135 return -ENOMEM;
142 } 136 }
143 137
@@ -169,10 +163,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
169 163
170 spin_unlock_bh(&sl->lock); 164 spin_unlock_bh(&sl->lock);
171 165
172 if (xbuff != NULL) 166 kfree(xbuff);
173 kfree(xbuff); 167 kfree(rbuff);
174 if (rbuff != NULL)
175 kfree(rbuff);
176 return 0; 168 return 0;
177} 169}
178 170
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
index 9abedeaa567c..a72006c08f2b 100644
--- a/drivers/oprofile/oprofile_files.c
+++ b/drivers/oprofile/oprofile_files.c
@@ -18,13 +18,13 @@ unsigned long fs_buffer_size = 131072;
18unsigned long fs_cpu_buffer_size = 8192; 18unsigned long fs_cpu_buffer_size = 8192;
19unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ 19unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
20 20
21static ssize_t depth_read(struct file * file, char * buf, size_t count, loff_t * offset) 21static ssize_t depth_read(struct file * file, char __user * buf, size_t count, loff_t * offset)
22{ 22{
23 return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); 23 return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset);
24} 24}
25 25
26 26
27static ssize_t depth_write(struct file * file, char const * buf, size_t count, loff_t * offset) 27static ssize_t depth_write(struct file * file, char const __user * buf, size_t count, loff_t * offset)
28{ 28{
29 unsigned long val; 29 unsigned long val;
30 int retval; 30 int retval;
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 731010e0e6f6..16a2e6ae37f4 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -34,7 +34,7 @@ config PARPORT
34 34
35config PARPORT_PC 35config PARPORT_PC
36 tristate "PC-style hardware" 36 tristate "PC-style hardware"
37 depends on PARPORT && (!SPARC64 || PCI) && (!SPARC32 || BROKEN) 37 depends on PARPORT && (!SPARC64 || PCI) && !SPARC32
38 ---help--- 38 ---help---
39 You should say Y here if you have a PC-style parallel port. All 39 You should say Y here if you have a PC-style parallel port. All
40 IBM PC compatible computers and some Alphas have PC-style 40 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index c5774e7855d0..e7f3bcb79000 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -67,6 +67,10 @@
67 67
68#define PARPORT_PC_MAX_PORTS PARPORT_MAX 68#define PARPORT_PC_MAX_PORTS PARPORT_MAX
69 69
70#ifdef CONFIG_ISA_DMA_API
71#define HAS_DMA
72#endif
73
70/* ECR modes */ 74/* ECR modes */
71#define ECR_SPP 00 75#define ECR_SPP 00
72#define ECR_PS2 01 76#define ECR_PS2 01
@@ -610,6 +614,7 @@ dump_parport_state ("leave fifo_write_block_pio", port);
610 return length - left; 614 return length - left;
611} 615}
612 616
617#ifdef HAS_DMA
613static size_t parport_pc_fifo_write_block_dma (struct parport *port, 618static size_t parport_pc_fifo_write_block_dma (struct parport *port,
614 const void *buf, size_t length) 619 const void *buf, size_t length)
615{ 620{
@@ -732,6 +737,17 @@ dump_parport_state ("enter fifo_write_block_dma", port);
732dump_parport_state ("leave fifo_write_block_dma", port); 737dump_parport_state ("leave fifo_write_block_dma", port);
733 return length - left; 738 return length - left;
734} 739}
740#endif
741
742static inline size_t parport_pc_fifo_write_block(struct parport *port,
743 const void *buf, size_t length)
744{
745#ifdef HAS_DMA
746 if (port->dma != PARPORT_DMA_NONE)
747 return parport_pc_fifo_write_block_dma (port, buf, length);
748#endif
749 return parport_pc_fifo_write_block_pio (port, buf, length);
750}
735 751
736/* Parallel Port FIFO mode (ECP chipsets) */ 752/* Parallel Port FIFO mode (ECP chipsets) */
737static size_t parport_pc_compat_write_block_pio (struct parport *port, 753static size_t parport_pc_compat_write_block_pio (struct parport *port,
@@ -758,10 +774,7 @@ static size_t parport_pc_compat_write_block_pio (struct parport *port,
758 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 774 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
759 775
760 /* Write the data to the FIFO. */ 776 /* Write the data to the FIFO. */
761 if (port->dma != PARPORT_DMA_NONE) 777 written = parport_pc_fifo_write_block(port, buf, length);
762 written = parport_pc_fifo_write_block_dma (port, buf, length);
763 else
764 written = parport_pc_fifo_write_block_pio (port, buf, length);
765 778
766 /* Finish up. */ 779 /* Finish up. */
767 /* For some hardware we don't want to touch the mode until 780 /* For some hardware we don't want to touch the mode until
@@ -856,10 +869,7 @@ static size_t parport_pc_ecp_write_block_pio (struct parport *port,
856 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 869 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
857 870
858 /* Write the data to the FIFO. */ 871 /* Write the data to the FIFO. */
859 if (port->dma != PARPORT_DMA_NONE) 872 written = parport_pc_fifo_write_block(port, buf, length);
860 written = parport_pc_fifo_write_block_dma (port, buf, length);
861 else
862 written = parport_pc_fifo_write_block_pio (port, buf, length);
863 873
864 /* Finish up. */ 874 /* Finish up. */
865 /* For some hardware we don't want to touch the mode until 875 /* For some hardware we don't want to touch the mode until
@@ -2285,6 +2295,7 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2285 } 2295 }
2286 2296
2287#ifdef CONFIG_PARPORT_PC_FIFO 2297#ifdef CONFIG_PARPORT_PC_FIFO
2298#ifdef HAS_DMA
2288 if (p->dma != PARPORT_DMA_NONE) { 2299 if (p->dma != PARPORT_DMA_NONE) {
2289 if (request_dma (p->dma, p->name)) { 2300 if (request_dma (p->dma, p->name)) {
2290 printk (KERN_WARNING "%s: dma %d in use, " 2301 printk (KERN_WARNING "%s: dma %d in use, "
@@ -2306,7 +2317,8 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2306 } 2317 }
2307 } 2318 }
2308 } 2319 }
2309#endif /* CONFIG_PARPORT_PC_FIFO */ 2320#endif
2321#endif
2310 } 2322 }
2311 2323
2312 /* Done probing. Now put the port into a sensible start-up state. */ 2324 /* Done probing. Now put the port into a sensible start-up state. */
@@ -2367,11 +2379,13 @@ void parport_pc_unregister_port (struct parport *p)
2367 if (p->modes & PARPORT_MODE_ECP) 2379 if (p->modes & PARPORT_MODE_ECP)
2368 release_region(p->base_hi, 3); 2380 release_region(p->base_hi, 3);
2369#ifdef CONFIG_PARPORT_PC_FIFO 2381#ifdef CONFIG_PARPORT_PC_FIFO
2382#ifdef HAS_DMA
2370 if (priv->dma_buf) 2383 if (priv->dma_buf)
2371 pci_free_consistent(priv->dev, PAGE_SIZE, 2384 pci_free_consistent(priv->dev, PAGE_SIZE,
2372 priv->dma_buf, 2385 priv->dma_buf,
2373 priv->dma_handle); 2386 priv->dma_handle);
2374#endif /* CONFIG_PARPORT_PC_FIFO */ 2387#endif
2388#endif
2375 kfree (p->private_data); 2389 kfree (p->private_data);
2376 parport_put_port(p); 2390 parport_put_port(p);
2377 kfree (ops); /* hope no-one cached it */ 2391 kfree (ops); /* hope no-one cached it */
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index d471b3ea5d12..021d0f76bc4c 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -120,6 +120,10 @@ static int pci_visit_bridge (struct pci_visit * fn,
120 120
121/** 121/**
122 * pci_visit_dev - scans the pci buses. 122 * pci_visit_dev - scans the pci buses.
123 * @fn: callback functions that are called while visiting
124 * @wrapped_dev: the device to scan
125 * @wrapped_parent: the bus where @wrapped_dev is connected to
126 *
123 * Every bus and every function is presented to a custom 127 * Every bus and every function is presented to a custom
124 * function that can act upon it. 128 * function that can act upon it.
125 */ 129 */
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index 5bc039da647f..c22e0284d7b1 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -196,7 +196,7 @@ struct ebda_hpc_bus {
196 196
197 197
198/******************************************************************** 198/********************************************************************
199* THREE TYPE OF HOT PLUG CONTROLER * 199* THREE TYPE OF HOT PLUG CONTROLLER *
200********************************************************************/ 200********************************************************************/
201 201
202struct isa_ctlr_access { 202struct isa_ctlr_access {
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 6894b548c8ca..1a3eb8d3d4cb 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -64,7 +64,7 @@ static int to_debug = FALSE;
64#define WPG_I2C_OR 0x2000 // I2C OR operation 64#define WPG_I2C_OR 0x2000 // I2C OR operation
65 65
66//---------------------------------------------------------------------------- 66//----------------------------------------------------------------------------
67// Command set for I2C Master Operation Setup Regisetr 67// Command set for I2C Master Operation Setup Register
68//---------------------------------------------------------------------------- 68//----------------------------------------------------------------------------
69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index 69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index
70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index 70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index
@@ -835,7 +835,7 @@ static void poll_hpc (void)
835 if (ibmphp_shutdown) 835 if (ibmphp_shutdown)
836 break; 836 break;
837 837
838 /* try to get the lock to do some kind of harware access */ 838 /* try to get the lock to do some kind of hardware access */
839 down (&semOperations); 839 down (&semOperations);
840 840
841 switch (poll_state) { 841 switch (poll_state) {
@@ -906,7 +906,7 @@ static void poll_hpc (void)
906 poll_state = POLL_LATCH_REGISTER; 906 poll_state = POLL_LATCH_REGISTER;
907 break; 907 break;
908 } 908 }
909 /* give up the harware semaphore */ 909 /* give up the hardware semaphore */
910 up (&semOperations); 910 up (&semOperations);
911 /* sleep for a short time just for good measure */ 911 /* sleep for a short time just for good measure */
912 msleep(100); 912 msleep(100);
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 2335fac65fb4..8122fe734aa7 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1308,10 +1308,10 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1309 } else { 1309 } else {
1310 /* This is Memory */ 1310 /* This is Memory */
1311 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1312 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1311 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1313 /* pfmem */ 1312 /* pfmem */
1314 debug ("start address of pfmem is %x\n", start_address); 1313 debug ("start address of pfmem is %x\n", start_address);
1314 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1315 1315
1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1317 err ("cannot find corresponding PFMEM resource to remove\n"); 1317 err ("cannot find corresponding PFMEM resource to remove\n");
@@ -1325,6 +1325,8 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1325 } else { 1325 } else {
1326 /* regular memory */ 1326 /* regular memory */
1327 debug ("start address of mem is %x\n", start_address); 1327 debug ("start address of mem is %x\n", start_address);
1328 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1329
1328 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1330 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1329 err ("cannot find corresponding MEM resource to remove\n"); 1331 err ("cannot find corresponding MEM resource to remove\n");
1330 return -EIO; 1332 return -EIO;
@@ -1422,9 +1424,9 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1422 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1424 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1423 } else { 1425 } else {
1424 /* This is Memory */ 1426 /* This is Memory */
1425 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1426 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1427 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1427 /* pfmem */ 1428 /* pfmem */
1429 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1428 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1430 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1429 err ("cannot find corresponding PFMEM resource to remove\n"); 1431 err ("cannot find corresponding PFMEM resource to remove\n");
1430 return -EINVAL; 1432 return -EINVAL;
@@ -1436,6 +1438,7 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1436 } 1438 }
1437 } else { 1439 } else {
1438 /* regular memory */ 1440 /* regular memory */
1441 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1439 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1442 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1440 err ("cannot find corresponding MEM resource to remove\n"); 1443 err ("cannot find corresponding MEM resource to remove\n");
1441 return -EINVAL; 1444 return -EINVAL;
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index 57ace325168d..88d44f7fef29 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -150,7 +150,7 @@ struct hotplug_slot_info {
150 * @name: the name of the slot being registered. This string must 150 * @name: the name of the slot being registered. This string must
151 * be unique amoung slots registered on this system. 151 * be unique amoung slots registered on this system.
152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot 152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
153 * @info: pointer to the &struct hotplug_slot_info for the inital values for 153 * @info: pointer to the &struct hotplug_slot_info for the initial values for
154 * this slot. 154 * this slot.
155 * @release: called during pci_hp_deregister to free memory allocated in a 155 * @release: called during pci_hp_deregister to free memory allocated in a
156 * hotplug_slot structure. 156 * hotplug_slot structure.
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 72baf749e65e..ed1fd8d6178d 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -90,6 +90,22 @@ static struct hotplug_slot_ops pciehp_hotplug_slot_ops = {
90 .get_cur_bus_speed = get_cur_bus_speed, 90 .get_cur_bus_speed = get_cur_bus_speed,
91}; 91};
92 92
93/**
94 * release_slot - free up the memory used by a slot
95 * @hotplug_slot: slot to free
96 */
97static void release_slot(struct hotplug_slot *hotplug_slot)
98{
99 struct slot *slot = hotplug_slot->private;
100
101 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
102
103 kfree(slot->hotplug_slot->info);
104 kfree(slot->hotplug_slot->name);
105 kfree(slot->hotplug_slot);
106 kfree(slot);
107}
108
93static int init_slots(struct controller *ctrl) 109static int init_slots(struct controller *ctrl)
94{ 110{
95 struct slot *new_slot; 111 struct slot *new_slot;
@@ -139,7 +155,8 @@ static int init_slots(struct controller *ctrl)
139 155
140 /* register this slot with the hotplug pci core */ 156 /* register this slot with the hotplug pci core */
141 new_slot->hotplug_slot->private = new_slot; 157 new_slot->hotplug_slot->private = new_slot;
142 make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); 158 new_slot->hotplug_slot->release = &release_slot;
159 make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
143 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; 160 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops;
144 161
145 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); 162 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
@@ -188,10 +205,6 @@ static int cleanup_slots (struct controller * ctrl)
188 while (old_slot) { 205 while (old_slot) {
189 next_slot = old_slot->next; 206 next_slot = old_slot->next;
190 pci_hp_deregister (old_slot->hotplug_slot); 207 pci_hp_deregister (old_slot->hotplug_slot);
191 kfree(old_slot->hotplug_slot->info);
192 kfree(old_slot->hotplug_slot->name);
193 kfree(old_slot->hotplug_slot);
194 kfree(old_slot);
195 old_slot = next_slot; 208 old_slot = next_slot;
196 } 209 }
197 210
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 6605d6bda529..3194d51c6ec9 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -297,7 +297,7 @@ static int __init init_slots(void)
297 hotplug_slot->ops = &skel_hotplug_slot_ops; 297 hotplug_slot->ops = &skel_hotplug_slot_ops;
298 298
299 /* 299 /*
300 * Initilize the slot info structure with some known 300 * Initialize the slot info structure with some known
301 * good values. 301 * good values.
302 */ 302 */
303 info->power_status = get_power_status(slot); 303 info->power_status = get_power_status(slot);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 22ecd3b058be..30206ac43c44 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -522,7 +522,7 @@ void pci_scan_msi_device(struct pci_dev *dev)
522 * msi_capability_init - configure device's MSI capability structure 522 * msi_capability_init - configure device's MSI capability structure
523 * @dev: pointer to the pci_dev data structure of MSI device function 523 * @dev: pointer to the pci_dev data structure of MSI device function
524 * 524 *
525 * Setup the MSI capability structure of device funtion with a single 525 * Setup the MSI capability structure of device function with a single
526 * MSI vector, regardless of device function is capable of handling 526 * MSI vector, regardless of device function is capable of handling
527 * multiple messages. A return of zero indicates the successful setup 527 * multiple messages. A return of zero indicates the successful setup
528 * of an entry zero with the new MSI vector or non-zero for otherwise. 528 * of an entry zero with the new MSI vector or non-zero for otherwise.
@@ -599,7 +599,7 @@ static int msi_capability_init(struct pci_dev *dev)
599 * msix_capability_init - configure device's MSI-X capability 599 * msix_capability_init - configure device's MSI-X capability
600 * @dev: pointer to the pci_dev data structure of MSI-X device function 600 * @dev: pointer to the pci_dev data structure of MSI-X device function
601 * 601 *
602 * Setup the MSI-X capability structure of device funtion with a 602 * Setup the MSI-X capability structure of device function with a
603 * single MSI-X vector. A return of zero indicates the successful setup of 603 * single MSI-X vector. A return of zero indicates the successful setup of
604 * requested MSI-X entries with allocated vectors or non-zero for otherwise. 604 * requested MSI-X entries with allocated vectors or non-zero for otherwise.
605 **/ 605 **/
@@ -1074,7 +1074,7 @@ void pci_disable_msix(struct pci_dev* dev)
1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state 1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state
1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function 1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function
1076 * 1076 *
1077 * Being called during hotplug remove, from which the device funciton 1077 * Being called during hotplug remove, from which the device function
1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if 1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if
1079 * allocated for this device function, are reclaimed to unused state, 1079 * allocated for this device function, are reclaimed to unused state,
1080 * which may be used later on. 1080 * which may be used later on.
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 968eb32f292d..bc01d34e2634 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -19,7 +19,7 @@
19 19
20static u32 ctrlset_buf[3] = {0, 0, 0}; 20static u32 ctrlset_buf[3] = {0, 0, 0};
21static u32 global_ctrlsets = 0; 21static u32 global_ctrlsets = 0;
22u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 22static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
23 23
24static acpi_status 24static acpi_status
25acpi_query_osc ( 25acpi_query_osc (
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 37b7961efc44..fe98553c978f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -318,6 +318,14 @@ static int pci_device_resume(struct device * dev)
318 return 0; 318 return 0;
319} 319}
320 320
321static void pci_device_shutdown(struct device *dev)
322{
323 struct pci_dev *pci_dev = to_pci_dev(dev);
324 struct pci_driver *drv = pci_dev->driver;
325
326 if (drv && drv->shutdown)
327 drv->shutdown(pci_dev);
328}
321 329
322#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj) 330#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
323#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr) 331#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
@@ -373,7 +381,7 @@ pci_populate_driver_dir(struct pci_driver *drv)
373 * 381 *
374 * Adds the driver structure to the list of registered drivers. 382 * Adds the driver structure to the list of registered drivers.
375 * Returns a negative value on error, otherwise 0. 383 * Returns a negative value on error, otherwise 0.
376 * If no error occured, the driver remains registered even if 384 * If no error occurred, the driver remains registered even if
377 * no device was claimed during registration. 385 * no device was claimed during registration.
378 */ 386 */
379int pci_register_driver(struct pci_driver *drv) 387int pci_register_driver(struct pci_driver *drv)
@@ -385,6 +393,7 @@ int pci_register_driver(struct pci_driver *drv)
385 drv->driver.bus = &pci_bus_type; 393 drv->driver.bus = &pci_bus_type;
386 drv->driver.probe = pci_device_probe; 394 drv->driver.probe = pci_device_probe;
387 drv->driver.remove = pci_device_remove; 395 drv->driver.remove = pci_device_remove;
396 drv->driver.shutdown = pci_device_shutdown,
388 drv->driver.owner = drv->owner; 397 drv->driver.owner = drv->owner;
389 drv->driver.kobj.ktype = &pci_driver_kobj_type; 398 drv->driver.kobj.ktype = &pci_driver_kobj_type;
390 pci_init_dynids(&drv->dynids); 399 pci_init_dynids(&drv->dynids);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d57ae71d32b1..8568b207f189 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -91,6 +91,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
92 unsigned int size = 64; 92 unsigned int size = 64;
93 loff_t init_off = off; 93 loff_t init_off = off;
94 u8 *data = (u8*) buf;
94 95
95 /* Several chips lock up trying to read undefined config space */ 96 /* Several chips lock up trying to read undefined config space */
96 if (capable(CAP_SYS_ADMIN)) { 97 if (capable(CAP_SYS_ADMIN)) {
@@ -108,30 +109,47 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
108 size = count; 109 size = count;
109 } 110 }
110 111
111 while (off & 3) { 112 if ((off & 1) && size) {
112 unsigned char val; 113 u8 val;
113 pci_read_config_byte(dev, off, &val); 114 pci_read_config_byte(dev, off, &val);
114 buf[off - init_off] = val; 115 data[off - init_off] = val;
115 off++; 116 off++;
116 if (--size == 0) 117 size--;
117 break; 118 }
119
120 if ((off & 3) && size > 2) {
121 u16 val;
122 pci_read_config_word(dev, off, &val);
123 data[off - init_off] = val & 0xff;
124 data[off - init_off + 1] = (val >> 8) & 0xff;
125 off += 2;
126 size -= 2;
118 } 127 }
119 128
120 while (size > 3) { 129 while (size > 3) {
121 unsigned int val; 130 u32 val;
122 pci_read_config_dword(dev, off, &val); 131 pci_read_config_dword(dev, off, &val);
123 buf[off - init_off] = val & 0xff; 132 data[off - init_off] = val & 0xff;
124 buf[off - init_off + 1] = (val >> 8) & 0xff; 133 data[off - init_off + 1] = (val >> 8) & 0xff;
125 buf[off - init_off + 2] = (val >> 16) & 0xff; 134 data[off - init_off + 2] = (val >> 16) & 0xff;
126 buf[off - init_off + 3] = (val >> 24) & 0xff; 135 data[off - init_off + 3] = (val >> 24) & 0xff;
127 off += 4; 136 off += 4;
128 size -= 4; 137 size -= 4;
129 } 138 }
130 139
131 while (size > 0) { 140 if (size >= 2) {
132 unsigned char val; 141 u16 val;
142 pci_read_config_word(dev, off, &val);
143 data[off - init_off] = val & 0xff;
144 data[off - init_off + 1] = (val >> 8) & 0xff;
145 off += 2;
146 size -= 2;
147 }
148
149 if (size > 0) {
150 u8 val;
133 pci_read_config_byte(dev, off, &val); 151 pci_read_config_byte(dev, off, &val);
134 buf[off - init_off] = val; 152 data[off - init_off] = val;
135 off++; 153 off++;
136 --size; 154 --size;
137 } 155 }
@@ -145,6 +163,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
145 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 163 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
146 unsigned int size = count; 164 unsigned int size = count;
147 loff_t init_off = off; 165 loff_t init_off = off;
166 u8 *data = (u8*) buf;
148 167
149 if (off > dev->cfg_size) 168 if (off > dev->cfg_size)
150 return 0; 169 return 0;
@@ -152,26 +171,41 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
152 size = dev->cfg_size - off; 171 size = dev->cfg_size - off;
153 count = size; 172 count = size;
154 } 173 }
155 174
156 while (off & 3) { 175 if ((off & 1) && size) {
157 pci_write_config_byte(dev, off, buf[off - init_off]); 176 pci_write_config_byte(dev, off, data[off - init_off]);
158 off++; 177 off++;
159 if (--size == 0) 178 size--;
160 break;
161 } 179 }
180
181 if ((off & 3) && size > 2) {
182 u16 val = data[off - init_off];
183 val |= (u16) data[off - init_off + 1] << 8;
184 pci_write_config_word(dev, off, val);
185 off += 2;
186 size -= 2;
187 }
162 188
163 while (size > 3) { 189 while (size > 3) {
164 unsigned int val = buf[off - init_off]; 190 u32 val = data[off - init_off];
165 val |= (unsigned int) buf[off - init_off + 1] << 8; 191 val |= (u32) data[off - init_off + 1] << 8;
166 val |= (unsigned int) buf[off - init_off + 2] << 16; 192 val |= (u32) data[off - init_off + 2] << 16;
167 val |= (unsigned int) buf[off - init_off + 3] << 24; 193 val |= (u32) data[off - init_off + 3] << 24;
168 pci_write_config_dword(dev, off, val); 194 pci_write_config_dword(dev, off, val);
169 off += 4; 195 off += 4;
170 size -= 4; 196 size -= 4;
171 } 197 }
198
199 if (size >= 2) {
200 u16 val = data[off - init_off];
201 val |= (u16) data[off - init_off + 1] << 8;
202 pci_write_config_word(dev, off, val);
203 off += 2;
204 size -= 2;
205 }
172 206
173 while (size > 0) { 207 if (size) {
174 pci_write_config_byte(dev, off, buf[off - init_off]); 208 pci_write_config_byte(dev, off, data[off - init_off]);
175 off++; 209 off++;
176 --size; 210 --size;
177 } 211 }
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bfbff8335268..f04b9ffe4153 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <asm/dma.h> /* isa_dma_bridge_buggy */ 18#include <asm/dma.h> /* isa_dma_bridge_buggy */
19#include "pci.h"
19 20
20 21
21/** 22/**
@@ -398,10 +399,10 @@ pci_enable_device(struct pci_dev *dev)
398{ 399{
399 int err; 400 int err;
400 401
401 dev->is_enabled = 1;
402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1))) 402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1)))
403 return err; 403 return err;
404 pci_fixup_device(pci_fixup_enable, dev); 404 pci_fixup_device(pci_fixup_enable, dev);
405 dev->is_enabled = 1;
405 return 0; 406 return 0;
406} 407}
407 408
@@ -427,16 +428,15 @@ pci_disable_device(struct pci_dev *dev)
427{ 428{
428 u16 pci_command; 429 u16 pci_command;
429 430
430 dev->is_enabled = 0;
431 dev->is_busmaster = 0;
432
433 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 431 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
434 if (pci_command & PCI_COMMAND_MASTER) { 432 if (pci_command & PCI_COMMAND_MASTER) {
435 pci_command &= ~PCI_COMMAND_MASTER; 433 pci_command &= ~PCI_COMMAND_MASTER;
436 pci_write_config_word(dev, PCI_COMMAND, pci_command); 434 pci_write_config_word(dev, PCI_COMMAND, pci_command);
437 } 435 }
436 dev->is_busmaster = 0;
438 437
439 pcibios_disable_device(dev); 438 pcibios_disable_device(dev);
439 dev->is_enabled = 0;
440} 440}
441 441
442/** 442/**
@@ -749,17 +749,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
749} 749}
750 750
751int 751int
752pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
753{
754 if (!pci_dac_dma_supported(dev, mask))
755 return -EIO;
756
757 dev->dma_mask = mask;
758
759 return 0;
760}
761
762int
763pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 752pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
764{ 753{
765 if (!pci_dma_supported(dev, mask)) 754 if (!pci_dma_supported(dev, mask))
@@ -821,7 +810,6 @@ EXPORT_SYMBOL(pci_set_master);
821EXPORT_SYMBOL(pci_set_mwi); 810EXPORT_SYMBOL(pci_set_mwi);
822EXPORT_SYMBOL(pci_clear_mwi); 811EXPORT_SYMBOL(pci_clear_mwi);
823EXPORT_SYMBOL(pci_set_dma_mask); 812EXPORT_SYMBOL(pci_set_dma_mask);
824EXPORT_SYMBOL(pci_dac_set_dma_mask);
825EXPORT_SYMBOL(pci_set_consistent_dma_mask); 813EXPORT_SYMBOL(pci_set_consistent_dma_mask);
826EXPORT_SYMBOL(pci_assign_resource); 814EXPORT_SYMBOL(pci_assign_resource);
827EXPORT_SYMBOL(pci_find_parent_resource); 815EXPORT_SYMBOL(pci_find_parent_resource);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6f0edadd132c..b7ae87823c69 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -9,6 +9,7 @@
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include "pci.h"
12 13
13#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 14#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
14#define CARDBUS_RESERVE_BUSNR 3 15#define CARDBUS_RESERVE_BUSNR 3
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 84cc4f620d8d..e68bbfb1e7c3 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -15,6 +15,7 @@
15 15
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18#include "pci.h"
18 19
19static int proc_initialized; /* = 0 */ 20static int proc_initialized; /* = 0 */
20 21
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 15a398051682..026aa04669a2 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -18,6 +18,7 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include "pci.h"
21 22
22/* Deal with broken BIOS'es that neglect to enable passive release, 23/* Deal with broken BIOS'es that neglect to enable passive release,
23 which can cause problems in combination with the 82441FX/PPro MTRRs */ 24 which can cause problems in combination with the 82441FX/PPro MTRRs */
@@ -328,6 +329,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
328DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi ); 329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi );
329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi ); 330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi );
330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi ); 331DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi );
332DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi );
331 333
332/* 334/*
333 * VIA ACPI: One IO region pointed to by longword at 335 * VIA ACPI: One IO region pointed to by longword at
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 3e64ff64b38c..838575e3fac6 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -14,7 +14,7 @@
14 14
15/** 15/**
16 * pci_enable_rom - enable ROM decoding for a PCI device 16 * pci_enable_rom - enable ROM decoding for a PCI device
17 * @dev: PCI device to enable 17 * @pdev: PCI device to enable
18 * 18 *
19 * Enable ROM decoding on @dev. This involves simply turning on the last 19 * Enable ROM decoding on @dev. This involves simply turning on the last
20 * bit of the PCI ROM BAR. Note that some cards may share address decoders 20 * bit of the PCI ROM BAR. Note that some cards may share address decoders
@@ -32,7 +32,7 @@ static void pci_enable_rom(struct pci_dev *pdev)
32 32
33/** 33/**
34 * pci_disable_rom - disable ROM decoding for a PCI device 34 * pci_disable_rom - disable ROM decoding for a PCI device
35 * @dev: PCI device to disable 35 * @pdev: PCI device to disable
36 * 36 *
37 * Disable ROM decoding on a PCI device by turning off the last bit in the 37 * Disable ROM decoding on a PCI device by turning off the last bit in the
38 * ROM BAR. 38 * ROM BAR.
@@ -47,7 +47,7 @@ static void pci_disable_rom(struct pci_dev *pdev)
47 47
48/** 48/**
49 * pci_map_rom - map a PCI ROM to kernel space 49 * pci_map_rom - map a PCI ROM to kernel space
50 * @dev: pointer to pci device struct 50 * @pdev: pointer to pci device struct
51 * @size: pointer to receive size of pci window over ROM 51 * @size: pointer to receive size of pci window over ROM
52 * @return: kernel virtual pointer to image of ROM 52 * @return: kernel virtual pointer to image of ROM
53 * 53 *
@@ -132,7 +132,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
132 132
133/** 133/**
134 * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy 134 * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy
135 * @dev: pointer to pci device struct 135 * @pdev: pointer to pci device struct
136 * @size: pointer to receive size of pci window over ROM 136 * @size: pointer to receive size of pci window over ROM
137 * @return: kernel virtual pointer to image of ROM 137 * @return: kernel virtual pointer to image of ROM
138 * 138 *
@@ -166,7 +166,7 @@ void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
166 166
167/** 167/**
168 * pci_unmap_rom - unmap the ROM from kernel space 168 * pci_unmap_rom - unmap the ROM from kernel space
169 * @dev: pointer to pci device struct 169 * @pdev: pointer to pci device struct
170 * @rom: virtual address of the previous mapping 170 * @rom: virtual address of the previous mapping
171 * 171 *
172 * Remove a mapping of a previously mapped ROM 172 * Remove a mapping of a previously mapped ROM
@@ -187,7 +187,7 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
187 187
188/** 188/**
189 * pci_remove_rom - disable the ROM and remove its sysfs attribute 189 * pci_remove_rom - disable the ROM and remove its sysfs attribute
190 * @dev: pointer to pci device struct 190 * @pdev: pointer to pci device struct
191 * 191 *
192 * Remove the rom file in sysfs and disable ROM decoding. 192 * Remove the rom file in sysfs and disable ROM decoding.
193 */ 193 */
@@ -206,7 +206,7 @@ void pci_remove_rom(struct pci_dev *pdev)
206/** 206/**
207 * pci_cleanup_rom - internal routine for freeing the ROM copy created 207 * pci_cleanup_rom - internal routine for freeing the ROM copy created
208 * by pci_map_rom_copy called from remove.c 208 * by pci_map_rom_copy called from remove.c
209 * @dev: pointer to pci device struct 209 * @pdev: pointer to pci device struct
210 * 210 *
211 * Free the copied ROM if we allocated one. 211 * Free the copied ROM if we allocated one.
212 */ 212 */
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 3f4364341d8d..20642f0e7bfe 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -744,7 +744,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
744 744
745 for (i = 0; i < MAX_SOCKETS; i++) { 745 for (i = 0; i < MAX_SOCKETS; i++) {
746 socket[i].io_base = pci_resource_start(dev, 0); 746 socket[i].io_base = pci_resource_start(dev, 0);
747 socket[i].socket.features |= SS_CAP_PCCARD; 747 socket[i].socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
748 socket[i].socket.map_size = 0x1000; 748 socket[i].socket.map_size = 0x1000;
749 socket[i].socket.irq_mask = mask; 749 socket[i].socket.irq_mask = mask;
750 socket[i].socket.pci_irq = dev->irq; 750 socket[i].socket.pci_irq = dev->irq;
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index 52c073a9d7e4..a8a1d104524a 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -442,6 +442,25 @@ out:
442} 442}
443 443
444 444
445/* changes the irq of func1 to match that of func0 */
446static int ti12xx_align_irqs(struct yenta_socket *socket, int *old_irq)
447{
448 struct pci_dev *func0;
449
450 /* find func0 device */
451 func0 = pci_get_slot(socket->dev->bus, socket->dev->devfn & ~0x07);
452 if (!func0)
453 return 0;
454
455 if (old_irq)
456 *old_irq = socket->cb_irq;
457 socket->cb_irq = socket->dev->irq = func0->irq;
458
459 pci_dev_put(func0);
460
461 return 1;
462}
463
445/* 464/*
446 * ties INTA and INTB together. also changes the devices irq to that of 465 * ties INTA and INTB together. also changes the devices irq to that of
447 * the function 0 device. call from func1 only. 466 * the function 0 device. call from func1 only.
@@ -449,26 +468,22 @@ out:
449 */ 468 */
450static int ti12xx_tie_interrupts(struct yenta_socket *socket, int *old_irq) 469static int ti12xx_tie_interrupts(struct yenta_socket *socket, int *old_irq)
451{ 470{
452 struct pci_dev *func0;
453 u32 sysctl; 471 u32 sysctl;
472 int ret;
454 473
455 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 474 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
456 if (sysctl & TI122X_SCR_INTRTIE) 475 if (sysctl & TI122X_SCR_INTRTIE)
457 return 0; 476 return 0;
458 477
459 /* find func0 device */ 478 /* align */
460 func0 = pci_get_slot(socket->dev->bus, socket->dev->devfn & ~0x07); 479 ret = ti12xx_align_irqs(socket, old_irq);
461 if (!func0) 480 if (!ret)
462 return 0; 481 return 0;
463 482
464 /* change the interrupt to match func0, tie 'em up */ 483 /* tie */
465 *old_irq = socket->cb_irq;
466 socket->cb_irq = socket->dev->irq = func0->irq;
467 sysctl |= TI122X_SCR_INTRTIE; 484 sysctl |= TI122X_SCR_INTRTIE;
468 config_writel(socket, TI113X_SYSTEM_CONTROL, sysctl); 485 config_writel(socket, TI113X_SYSTEM_CONTROL, sysctl);
469 486
470 pci_dev_put(func0);
471
472 return 1; 487 return 1;
473} 488}
474 489
@@ -489,7 +504,7 @@ static void ti12xx_untie_interrupts(struct yenta_socket *socket, int old_irq)
489 */ 504 */
490static void ti12xx_irqroute_func1(struct yenta_socket *socket) 505static void ti12xx_irqroute_func1(struct yenta_socket *socket)
491{ 506{
492 u32 mfunc, mfunc_old, devctl; 507 u32 mfunc, mfunc_old, devctl, sysctl;
493 int pci_irq_status; 508 int pci_irq_status;
494 509
495 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 510 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC);
@@ -497,6 +512,11 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
497 printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", 512 printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n",
498 pci_name(socket->dev), mfunc, devctl); 513 pci_name(socket->dev), mfunc, devctl);
499 514
515 /* if IRQs are configured as tied, align irq of func1 with func0 */
516 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
517 if (sysctl & TI122X_SCR_INTRTIE)
518 ti12xx_align_irqs(socket, NULL);
519
500 /* make sure PCI interrupts are enabled before probing */ 520 /* make sure PCI interrupts are enabled before probing */
501 ti_init(socket); 521 ti_init(socket);
502 522
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 639e04253482..65ecef738537 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -253,7 +253,7 @@ void pnp_init_resource_table(struct pnp_resource_table *table)
253 253
254/** 254/**
255 * pnp_clean_resources - clears resources that were not manually set 255 * pnp_clean_resources - clears resources that were not manually set
256 * @res - the resources to clean 256 * @res: the resources to clean
257 * 257 *
258 */ 258 */
259static void pnp_clean_resource_table(struct pnp_resource_table * res) 259static void pnp_clean_resource_table(struct pnp_resource_table * res)
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index c0ddb1eb8c4d..dd61e09029b1 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -94,8 +94,8 @@ static void
94pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 94pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
95{ 95{
96 int i = 0; 96 int i = 0;
97 while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) && 97 while (i < PNP_MAX_DMA &&
98 i < PNP_MAX_DMA) 98 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
99 i++; 99 i++;
100 if (i < PNP_MAX_DMA) { 100 if (i < PNP_MAX_DMA) {
101 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 101 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 618ac15a9e90..79bce7b75740 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -72,7 +72,9 @@ static void
72pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 72pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
73{ 73{
74 int i = 0; 74 int i = 0;
75 while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_DMA) i++; 75 while (i < PNP_MAX_DMA &&
76 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
77 i++;
76 if (i < PNP_MAX_DMA) { 78 if (i < PNP_MAX_DMA) {
77 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 79 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
78 if (dma == -1) { 80 if (dma == -1) {
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index b755bac6ccbc..02cfe244e069 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.158 $ 10 * $Revision: 1.161 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -1131,13 +1131,17 @@ __dasd_process_blk_queue(struct dasd_device * device)
1131 request_queue_t *queue; 1131 request_queue_t *queue;
1132 struct request *req; 1132 struct request *req;
1133 struct dasd_ccw_req *cqr; 1133 struct dasd_ccw_req *cqr;
1134 int nr_queued; 1134 int nr_queued, feature_ro;
1135 1135
1136 queue = device->request_queue; 1136 queue = device->request_queue;
1137 /* No queue ? Then there is nothing to do. */ 1137 /* No queue ? Then there is nothing to do. */
1138 if (queue == NULL) 1138 if (queue == NULL)
1139 return; 1139 return;
1140 1140
1141 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
1142 if (feature_ro < 0) /* no devmap */
1143 return;
1144
1141 /* 1145 /*
1142 * We requeue request from the block device queue to the ccw 1146 * We requeue request from the block device queue to the ccw
1143 * queue only in two states. In state DASD_STATE_READY the 1147 * queue only in two states. In state DASD_STATE_READY the
@@ -1157,8 +1161,8 @@ __dasd_process_blk_queue(struct dasd_device * device)
1157 elv_next_request(queue) && 1161 elv_next_request(queue) &&
1158 nr_queued < DASD_CHANQ_MAX_SIZE) { 1162 nr_queued < DASD_CHANQ_MAX_SIZE) {
1159 req = elv_next_request(queue); 1163 req = elv_next_request(queue);
1160 if (test_bit(DASD_FLAG_RO, &device->flags) && 1164
1161 rq_data_dir(req) == WRITE) { 1165 if (feature_ro && rq_data_dir(req) == WRITE) {
1162 DBF_DEV_EVENT(DBF_ERR, device, 1166 DBF_DEV_EVENT(DBF_ERR, device,
1163 "Rejecting write request %p", 1167 "Rejecting write request %p",
1164 req); 1168 req);
@@ -1631,6 +1635,7 @@ dasd_setup_queue(struct dasd_device * device)
1631 blk_queue_max_hw_segments(device->request_queue, -1L); 1635 blk_queue_max_hw_segments(device->request_queue, -1L);
1632 blk_queue_max_segment_size(device->request_queue, -1L); 1636 blk_queue_max_segment_size(device->request_queue, -1L);
1633 blk_queue_segment_boundary(device->request_queue, -1L); 1637 blk_queue_segment_boundary(device->request_queue, -1L);
1638 blk_queue_ordered(device->request_queue, 1);
1634} 1639}
1635 1640
1636/* 1641/*
@@ -1803,13 +1808,17 @@ dasd_generic_set_online (struct ccw_device *cdev,
1803 1808
1804{ 1809{
1805 struct dasd_device *device; 1810 struct dasd_device *device;
1806 int rc; 1811 int feature_diag, rc;
1812
1813 feature_diag = dasd_get_feature(cdev, DASD_FEATURE_USEDIAG);
1814 if (feature_diag < 0)
1815 return feature_diag;
1807 1816
1808 device = dasd_create_device(cdev); 1817 device = dasd_create_device(cdev);
1809 if (IS_ERR(device)) 1818 if (IS_ERR(device))
1810 return PTR_ERR(device); 1819 return PTR_ERR(device);
1811 1820
1812 if (test_bit(DASD_FLAG_USE_DIAG, &device->flags)) { 1821 if (feature_diag) {
1813 if (!dasd_diag_discipline_pointer) { 1822 if (!dasd_diag_discipline_pointer) {
1814 printk (KERN_WARNING 1823 printk (KERN_WARNING
1815 "dasd_generic couldn't online device %s " 1824 "dasd_generic couldn't online device %s "
diff --git a/drivers/s390/block/dasd_cmb.c b/drivers/s390/block/dasd_cmb.c
index ed1ab474c0c6..4f365bff275c 100644
--- a/drivers/s390/block/dasd_cmb.c
+++ b/drivers/s390/block/dasd_cmb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.6 $) 2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.9 $)
3 * 3 *
4 * Linux on zSeries Channel Measurement Facility support 4 * Linux on zSeries Channel Measurement Facility support
5 * (dasd device driver interface) 5 * (dasd device driver interface)
@@ -23,7 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/ioctl32.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <asm/ccwdev.h> 27#include <asm/ccwdev.h>
29#include <asm/cmb.h> 28#include <asm/cmb.h>
@@ -84,27 +83,13 @@ dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
84static inline int 83static inline int
85ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler) 84ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
86{ 85{
87 int ret; 86 return dasd_ioctl_no_register(THIS_MODULE, no, handler);
88 ret = dasd_ioctl_no_register(THIS_MODULE, no, handler);
89#ifdef CONFIG_COMPAT
90 if (ret)
91 return ret;
92
93 ret = register_ioctl32_conversion(no, NULL);
94 if (ret)
95 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
96#endif
97 return ret;
98} 87}
99 88
100static inline void 89static inline void
101ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler) 90ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
102{ 91{
103 dasd_ioctl_no_unregister(THIS_MODULE, no, handler); 92 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
104#ifdef CONFIG_COMPAT
105 unregister_ioctl32_conversion(no);
106#endif
107
108} 93}
109 94
110static void 95static void
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index ad1841a96c87..1aedc48e5f85 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -11,7 +11,7 @@
11 * functions may not be called from interrupt context. In particular 11 * functions may not be called from interrupt context. In particular
12 * dasd_get_device is a no-no from interrupt context. 12 * dasd_get_device is a no-no from interrupt context.
13 * 13 *
14 * $Revision: 1.37 $ 14 * $Revision: 1.40 $
15 */ 15 */
16 16
17#include <linux/config.h> 17#include <linux/config.h>
@@ -513,14 +513,6 @@ dasd_create_device(struct ccw_device *cdev)
513 if (!devmap->device) { 513 if (!devmap->device) {
514 devmap->device = device; 514 devmap->device = device;
515 device->devindex = devmap->devindex; 515 device->devindex = devmap->devindex;
516 if (devmap->features & DASD_FEATURE_READONLY)
517 set_bit(DASD_FLAG_RO, &device->flags);
518 else
519 clear_bit(DASD_FLAG_RO, &device->flags);
520 if (devmap->features & DASD_FEATURE_USEDIAG)
521 set_bit(DASD_FLAG_USE_DIAG, &device->flags);
522 else
523 clear_bit(DASD_FLAG_USE_DIAG, &device->flags);
524 get_device(&cdev->dev); 516 get_device(&cdev->dev);
525 device->cdev = cdev; 517 device->cdev = cdev;
526 rc = 0; 518 rc = 0;
@@ -651,14 +643,8 @@ dasd_ro_store(struct device *dev, const char *buf, size_t count)
651 devmap->features |= DASD_FEATURE_READONLY; 643 devmap->features |= DASD_FEATURE_READONLY;
652 else 644 else
653 devmap->features &= ~DASD_FEATURE_READONLY; 645 devmap->features &= ~DASD_FEATURE_READONLY;
654 if (devmap->device) { 646 if (devmap->device && devmap->device->gdp)
655 if (devmap->device->gdp) 647 set_disk_ro(devmap->device->gdp, ro_flag);
656 set_disk_ro(devmap->device->gdp, ro_flag);
657 if (ro_flag)
658 set_bit(DASD_FLAG_RO, &devmap->device->flags);
659 else
660 clear_bit(DASD_FLAG_RO, &devmap->device->flags);
661 }
662 spin_unlock(&dasd_devmap_lock); 648 spin_unlock(&dasd_devmap_lock);
663 return count; 649 return count;
664} 650}
@@ -739,6 +725,45 @@ static struct attribute_group dasd_attr_group = {
739 .attrs = dasd_attrs, 725 .attrs = dasd_attrs,
740}; 726};
741 727
728/*
729 * Return value of the specified feature.
730 */
731int
732dasd_get_feature(struct ccw_device *cdev, int feature)
733{
734 struct dasd_devmap *devmap;
735
736 devmap = dasd_find_busid(cdev->dev.bus_id);
737 if (IS_ERR(devmap))
738 return (int) PTR_ERR(devmap);
739
740 return ((devmap->features & feature) != 0);
741}
742
743/*
744 * Set / reset given feature.
745 * Flag indicates wether to set (!=0) or the reset (=0) the feature.
746 */
747int
748dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
749{
750 struct dasd_devmap *devmap;
751
752 devmap = dasd_find_busid(cdev->dev.bus_id);
753 if (IS_ERR(devmap))
754 return (int) PTR_ERR(devmap);
755
756 spin_lock(&dasd_devmap_lock);
757 if (flag)
758 devmap->features |= feature;
759 else
760 devmap->features &= ~feature;
761
762 spin_unlock(&dasd_devmap_lock);
763 return 0;
764}
765
766
742int 767int
743dasd_add_sysfs_files(struct ccw_device *cdev) 768dasd_add_sysfs_files(struct ccw_device *cdev)
744{ 769{
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 838aedf78a56..811060e10c00 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
9 * 9 *
10 * $Revision: 1.69 $ 10 * $Revision: 1.71 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -1101,7 +1101,8 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1101 if (dasd_eckd_cdl_special(blk_per_trk, recid)){ 1101 if (dasd_eckd_cdl_special(blk_per_trk, recid)){
1102 rcmd |= 0x8; 1102 rcmd |= 0x8;
1103 count = dasd_eckd_cdl_reclen(recid); 1103 count = dasd_eckd_cdl_reclen(recid);
1104 if (count < blksize) 1104 if (count < blksize &&
1105 rq_data_dir(req) == READ)
1105 memset(dst + count, 0xe5, 1106 memset(dst + count, 0xe5,
1106 blksize - count); 1107 blksize - count);
1107 } 1108 }
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 1d52db406b2e..96c49349701f 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * gendisk related functions for the dasd driver. 10 * gendisk related functions for the dasd driver.
11 * 11 *
12 * $Revision: 1.48 $ 12 * $Revision: 1.50 $
13 */ 13 */
14 14
15#include <linux/config.h> 15#include <linux/config.h>
@@ -31,12 +31,16 @@ int
31dasd_gendisk_alloc(struct dasd_device *device) 31dasd_gendisk_alloc(struct dasd_device *device)
32{ 32{
33 struct gendisk *gdp; 33 struct gendisk *gdp;
34 int len; 34 int len, feature_ro;
35 35
36 /* Make sure the minor for this device exists. */ 36 /* Make sure the minor for this device exists. */
37 if (device->devindex >= DASD_PER_MAJOR) 37 if (device->devindex >= DASD_PER_MAJOR)
38 return -EBUSY; 38 return -EBUSY;
39 39
40 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
41 if (feature_ro < 0)
42 return feature_ro;
43
40 gdp = alloc_disk(1 << DASD_PARTN_BITS); 44 gdp = alloc_disk(1 << DASD_PARTN_BITS);
41 if (!gdp) 45 if (!gdp)
42 return -ENOMEM; 46 return -ENOMEM;
@@ -71,7 +75,7 @@ dasd_gendisk_alloc(struct dasd_device *device)
71 75
72 sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id); 76 sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id);
73 77
74 if (test_bit(DASD_FLAG_RO, &device->flags)) 78 if (feature_ro)
75 set_disk_ro(gdp, 1); 79 set_disk_ro(gdp, 1);
76 gdp->private_data = device; 80 gdp->private_data = device;
77 gdp->queue = device->request_queue; 81 gdp->queue = device->request_queue;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 4586e0ecc526..a9f38b235981 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.63 $ 9 * $Revision: 1.64 $
10 */ 10 */
11 11
12#ifndef DASD_INT_H 12#ifndef DASD_INT_H
@@ -329,8 +329,6 @@ struct dasd_device {
329#define DASD_STOPPED_DC_EIO 16 /* disconnected, return -EIO */ 329#define DASD_STOPPED_DC_EIO 16 /* disconnected, return -EIO */
330 330
331/* per device flags */ 331/* per device flags */
332#define DASD_FLAG_RO 0 /* device is read-only */
333#define DASD_FLAG_USE_DIAG 1 /* use diag disciplnie */
334#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */ 332#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */
335#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */ 333#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */
336 334
@@ -501,6 +499,9 @@ void dasd_devmap_exit(void);
501struct dasd_device *dasd_create_device(struct ccw_device *); 499struct dasd_device *dasd_create_device(struct ccw_device *);
502void dasd_delete_device(struct dasd_device *); 500void dasd_delete_device(struct dasd_device *);
503 501
502int dasd_get_feature(struct ccw_device *, int);
503int dasd_set_feature(struct ccw_device *, int, int);
504
504int dasd_add_sysfs_files(struct ccw_device *); 505int dasd_add_sysfs_files(struct ccw_device *);
505void dasd_remove_sysfs_files(struct ccw_device *); 506void dasd_remove_sysfs_files(struct ccw_device *);
506 507
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index f1892baa3b18..980c555aa538 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -7,6 +7,8 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.45 $
11 *
10 * i/o controls for the dasd driver. 12 * i/o controls for the dasd driver.
11 */ 13 */
12#include <linux/config.h> 14#include <linux/config.h>
@@ -294,6 +296,7 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
294{ 296{
295 struct dasd_device *device; 297 struct dasd_device *device;
296 struct format_data_t fdata; 298 struct format_data_t fdata;
299 int feature_ro;
297 300
298 if (!capable(CAP_SYS_ADMIN)) 301 if (!capable(CAP_SYS_ADMIN))
299 return -EACCES; 302 return -EACCES;
@@ -304,7 +307,11 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
304 307
305 if (device == NULL) 308 if (device == NULL)
306 return -ENODEV; 309 return -ENODEV;
307 if (test_bit(DASD_FLAG_RO, &device->flags)) 310
311 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
312 if (feature_ro < 0)
313 return feature_ro;
314 if (feature_ro)
308 return -EROFS; 315 return -EROFS;
309 if (copy_from_user(&fdata, (void __user *) args, 316 if (copy_from_user(&fdata, (void __user *) args,
310 sizeof (struct format_data_t))) 317 sizeof (struct format_data_t)))
@@ -377,7 +384,7 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
377 struct dasd_device *device; 384 struct dasd_device *device;
378 struct dasd_information2_t *dasd_info; 385 struct dasd_information2_t *dasd_info;
379 unsigned long flags; 386 unsigned long flags;
380 int rc; 387 int rc, feature_ro;
381 struct ccw_device *cdev; 388 struct ccw_device *cdev;
382 389
383 device = bdev->bd_disk->private_data; 390 device = bdev->bd_disk->private_data;
@@ -387,6 +394,10 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
387 if (!device->discipline->fill_info) 394 if (!device->discipline->fill_info)
388 return -EINVAL; 395 return -EINVAL;
389 396
397 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
398 if (feature_ro < 0)
399 return feature_ro;
400
390 dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); 401 dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
391 if (dasd_info == NULL) 402 if (dasd_info == NULL)
392 return -ENOMEM; 403 return -ENOMEM;
@@ -415,9 +426,8 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
415 if ((device->state < DASD_STATE_READY) || 426 if ((device->state < DASD_STATE_READY) ||
416 (dasd_check_blocksize(device->bp_block))) 427 (dasd_check_blocksize(device->bp_block)))
417 dasd_info->format = DASD_FORMAT_NONE; 428 dasd_info->format = DASD_FORMAT_NONE;
418 429
419 dasd_info->features |= test_bit(DASD_FLAG_RO, &device->flags) ? 430 dasd_info->features |= feature_ro;
420 DASD_FEATURE_READONLY : DASD_FEATURE_DEFAULT;
421 431
422 if (device->discipline) 432 if (device->discipline)
423 memcpy(dasd_info->type, device->discipline->name, 4); 433 memcpy(dasd_info->type, device->discipline->name, 4);
@@ -460,7 +470,7 @@ static int
460dasd_ioctl_set_ro(struct block_device *bdev, int no, long args) 470dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
461{ 471{
462 struct dasd_device *device; 472 struct dasd_device *device;
463 int intval; 473 int intval, rc;
464 474
465 if (!capable(CAP_SYS_ADMIN)) 475 if (!capable(CAP_SYS_ADMIN))
466 return -EACCES; 476 return -EACCES;
@@ -472,12 +482,11 @@ dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
472 device = bdev->bd_disk->private_data; 482 device = bdev->bd_disk->private_data;
473 if (device == NULL) 483 if (device == NULL)
474 return -ENODEV; 484 return -ENODEV;
485
475 set_disk_ro(bdev->bd_disk, intval); 486 set_disk_ro(bdev->bd_disk, intval);
476 if (intval) 487 rc = dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval);
477 set_bit(DASD_FLAG_RO, &device->flags); 488
478 else 489 return rc;
479 clear_bit(DASD_FLAG_RO, &device->flags);
480 return 0;
481} 490}
482 491
483/* 492/*
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 353d41118c62..d7f19745911f 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * /proc interface for the dasd driver. 10 * /proc interface for the dasd driver.
11 * 11 *
12 * $Revision: 1.30 $ 12 * $Revision: 1.31 $
13 */ 13 */
14 14
15#include <linux/config.h> 15#include <linux/config.h>
@@ -54,6 +54,7 @@ dasd_devices_show(struct seq_file *m, void *v)
54{ 54{
55 struct dasd_device *device; 55 struct dasd_device *device;
56 char *substr; 56 char *substr;
57 int feature;
57 58
58 device = dasd_device_from_devindex((unsigned long) v - 1); 59 device = dasd_device_from_devindex((unsigned long) v - 1);
59 if (IS_ERR(device)) 60 if (IS_ERR(device))
@@ -77,7 +78,10 @@ dasd_devices_show(struct seq_file *m, void *v)
77 else 78 else
78 seq_printf(m, " is ????????"); 79 seq_printf(m, " is ????????");
79 /* Print devices features. */ 80 /* Print devices features. */
80 substr = test_bit(DASD_FLAG_RO, &device->flags) ? "(ro)" : " "; 81 feature = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
82 if (feature < 0)
83 return 0;
84 substr = feature ? "(ro)" : " ";
81 seq_printf(m, "%4s: ", substr); 85 seq_printf(m, "%4s: ", substr);
82 /* Print device status information. */ 86 /* Print device status information. */
83 switch ((device != NULL) ? device->state : -1) { 87 switch ((device != NULL) ? device->state : -1) {
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c
index 3720e77b465f..83e6a060668e 100644
--- a/drivers/s390/cio/airq.c
+++ b/drivers/s390/cio/airq.c
@@ -45,7 +45,7 @@ s390_register_adapter_interrupt (adapter_int_handler_t handler)
45 else 45 else
46 ret = (cmpxchg(&adapter_handler, NULL, handler) ? -EBUSY : 0); 46 ret = (cmpxchg(&adapter_handler, NULL, handler) ? -EBUSY : 0);
47 if (!ret) 47 if (!ret)
48 synchronize_kernel(); 48 synchronize_sched(); /* Allow interrupts to complete. */
49 49
50 sprintf (dbf_txt, "ret:%d", ret); 50 sprintf (dbf_txt, "ret:%d", ret);
51 CIO_TRACE_EVENT (4, dbf_txt); 51 CIO_TRACE_EVENT (4, dbf_txt);
@@ -65,7 +65,7 @@ s390_unregister_adapter_interrupt (adapter_int_handler_t handler)
65 ret = -EINVAL; 65 ret = -EINVAL;
66 else { 66 else {
67 adapter_handler = NULL; 67 adapter_handler = NULL;
68 synchronize_kernel(); 68 synchronize_sched(); /* Allow interrupts to complete. */
69 ret = 0; 69 ret = 0;
70 } 70 }
71 sprintf (dbf_txt, "ret:%d", ret); 71 sprintf (dbf_txt, "ret:%d", ret);
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 99ce5a567982..1d9b3f18d8de 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/cio.c 2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls 3 * S/390 common I/O routines -- low level i/o calls
4 * $Revision: 1.131 $ 4 * $Revision: 1.133 $
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
@@ -228,7 +228,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */
228int 228int
229cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm) 229cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
230{ 230{
231 return cio_start_key(sch, cpa, lpm, default_storage_key); 231 return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
232} 232}
233 233
234/* 234/*
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 11e260e0b9c9..02d01a0de16c 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/device_ops.c 2 * drivers/s390/cio/device_ops.c
3 * 3 *
4 * $Revision: 1.55 $ 4 * $Revision: 1.56 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -128,7 +128,7 @@ ccw_device_start(struct ccw_device *cdev, struct ccw1 *cpa,
128 unsigned long intparm, __u8 lpm, unsigned long flags) 128 unsigned long intparm, __u8 lpm, unsigned long flags)
129{ 129{
130 return ccw_device_start_key(cdev, cpa, intparm, lpm, 130 return ccw_device_start_key(cdev, cpa, intparm, lpm,
131 default_storage_key, flags); 131 PAGE_DEFAULT_KEY, flags);
132} 132}
133 133
134int 134int
@@ -137,7 +137,7 @@ ccw_device_start_timeout(struct ccw_device *cdev, struct ccw1 *cpa,
137 int expires) 137 int expires)
138{ 138{
139 return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm, 139 return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm,
140 default_storage_key, flags, 140 PAGE_DEFAULT_KEY, flags,
141 expires); 141 expires);
142} 142}
143 143
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index 9ad14db24143..b6daadac4e8b 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -1,7 +1,9 @@
1#ifndef _CIO_QDIO_H 1#ifndef _CIO_QDIO_H
2#define _CIO_QDIO_H 2#define _CIO_QDIO_H
3 3
4#define VERSION_CIO_QDIO_H "$Revision: 1.26 $" 4#include <asm/page.h>
5
6#define VERSION_CIO_QDIO_H "$Revision: 1.32 $"
5 7
6#ifdef CONFIG_QDIO_DEBUG 8#ifdef CONFIG_QDIO_DEBUG
7#define QDIO_VERBOSE_LEVEL 9 9#define QDIO_VERBOSE_LEVEL 9
@@ -42,7 +44,7 @@
42 44
43#define QDIO_Q_LAPS 5 45#define QDIO_Q_LAPS 5
44 46
45#define QDIO_STORAGE_KEY 0 47#define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
46 48
47#define L2_CACHELINE_SIZE 256 49#define L2_CACHELINE_SIZE 256
48#define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32)) 50#define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index a98c00c02559..9ec29bb41b28 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -385,8 +385,8 @@ static int z90crypt_release(struct inode *, struct file *);
385static ssize_t z90crypt_read(struct file *, char __user *, size_t, loff_t *); 385static ssize_t z90crypt_read(struct file *, char __user *, size_t, loff_t *);
386static ssize_t z90crypt_write(struct file *, const char __user *, 386static ssize_t z90crypt_write(struct file *, const char __user *,
387 size_t, loff_t *); 387 size_t, loff_t *);
388static int z90crypt_ioctl(struct inode *, struct file *, 388static long z90crypt_unlocked_ioctl(struct file *, unsigned int, unsigned long);
389 unsigned int, unsigned long); 389static long z90crypt_compat_ioctl(struct file *, unsigned int, unsigned long);
390 390
391static void z90crypt_reader_task(unsigned long); 391static void z90crypt_reader_task(unsigned long);
392static void z90crypt_schedule_reader_task(unsigned long); 392static void z90crypt_schedule_reader_task(unsigned long);
@@ -433,12 +433,15 @@ static atomic_t total_open;
433static atomic_t z90crypt_step; 433static atomic_t z90crypt_step;
434 434
435static struct file_operations z90crypt_fops = { 435static struct file_operations z90crypt_fops = {
436 .owner = THIS_MODULE, 436 .owner = THIS_MODULE,
437 .read = z90crypt_read, 437 .read = z90crypt_read,
438 .write = z90crypt_write, 438 .write = z90crypt_write,
439 .ioctl = z90crypt_ioctl, 439 .unlocked_ioctl = z90crypt_unlocked_ioctl,
440 .open = z90crypt_open, 440#ifdef CONFIG_COMPAT
441 .release = z90crypt_release 441 .compat_ioctl = z90crypt_compat_ioctl,
442#endif
443 .open = z90crypt_open,
444 .release = z90crypt_release
442}; 445};
443 446
444#ifndef Z90CRYPT_USE_HOTPLUG 447#ifndef Z90CRYPT_USE_HOTPLUG
@@ -474,14 +477,13 @@ struct ica_rsa_modexpo_32 { // For 32-bit callers
474 compat_uptr_t n_modulus; 477 compat_uptr_t n_modulus;
475}; 478};
476 479
477static int 480static long
478trans_modexpo32(unsigned int fd, unsigned int cmd, unsigned long arg, 481trans_modexpo32(struct file *filp, unsigned int cmd, unsigned long arg)
479 struct file *file)
480{ 482{
481 struct ica_rsa_modexpo_32 __user *mex32u = compat_ptr(arg); 483 struct ica_rsa_modexpo_32 __user *mex32u = compat_ptr(arg);
482 struct ica_rsa_modexpo_32 mex32k; 484 struct ica_rsa_modexpo_32 mex32k;
483 struct ica_rsa_modexpo __user *mex64; 485 struct ica_rsa_modexpo __user *mex64;
484 int ret = 0; 486 long ret = 0;
485 unsigned int i; 487 unsigned int i;
486 488
487 if (!access_ok(VERIFY_WRITE, mex32u, sizeof(struct ica_rsa_modexpo_32))) 489 if (!access_ok(VERIFY_WRITE, mex32u, sizeof(struct ica_rsa_modexpo_32)))
@@ -498,7 +500,7 @@ trans_modexpo32(unsigned int fd, unsigned int cmd, unsigned long arg,
498 __put_user(compat_ptr(mex32k.b_key), &mex64->b_key) || 500 __put_user(compat_ptr(mex32k.b_key), &mex64->b_key) ||
499 __put_user(compat_ptr(mex32k.n_modulus), &mex64->n_modulus)) 501 __put_user(compat_ptr(mex32k.n_modulus), &mex64->n_modulus))
500 return -EFAULT; 502 return -EFAULT;
501 ret = sys_ioctl(fd, cmd, (unsigned long)mex64); 503 ret = z90crypt_unlocked_ioctl(filp, cmd, (unsigned long)mex64);
502 if (!ret) 504 if (!ret)
503 if (__get_user(i, &mex64->outputdatalength) || 505 if (__get_user(i, &mex64->outputdatalength) ||
504 __put_user(i, &mex32u->outputdatalength)) 506 __put_user(i, &mex32u->outputdatalength))
@@ -518,14 +520,13 @@ struct ica_rsa_modexpo_crt_32 { // For 32-bit callers
518 compat_uptr_t u_mult_inv; 520 compat_uptr_t u_mult_inv;
519}; 521};
520 522
521static int 523static long
522trans_modexpo_crt32(unsigned int fd, unsigned int cmd, unsigned long arg, 524trans_modexpo_crt32(struct file *filp, unsigned int cmd, unsigned long arg)
523 struct file *file)
524{ 525{
525 struct ica_rsa_modexpo_crt_32 __user *crt32u = compat_ptr(arg); 526 struct ica_rsa_modexpo_crt_32 __user *crt32u = compat_ptr(arg);
526 struct ica_rsa_modexpo_crt_32 crt32k; 527 struct ica_rsa_modexpo_crt_32 crt32k;
527 struct ica_rsa_modexpo_crt __user *crt64; 528 struct ica_rsa_modexpo_crt __user *crt64;
528 int ret = 0; 529 long ret = 0;
529 unsigned int i; 530 unsigned int i;
530 531
531 if (!access_ok(VERIFY_WRITE, crt32u, 532 if (!access_ok(VERIFY_WRITE, crt32u,
@@ -546,9 +547,8 @@ trans_modexpo_crt32(unsigned int fd, unsigned int cmd, unsigned long arg,
546 __put_user(compat_ptr(crt32k.np_prime), &crt64->np_prime) || 547 __put_user(compat_ptr(crt32k.np_prime), &crt64->np_prime) ||
547 __put_user(compat_ptr(crt32k.nq_prime), &crt64->nq_prime) || 548 __put_user(compat_ptr(crt32k.nq_prime), &crt64->nq_prime) ||
548 __put_user(compat_ptr(crt32k.u_mult_inv), &crt64->u_mult_inv)) 549 __put_user(compat_ptr(crt32k.u_mult_inv), &crt64->u_mult_inv))
549 ret = -EFAULT; 550 return -EFAULT;
550 if (!ret) 551 ret = z90crypt_unlocked_ioctl(filp, cmd, (unsigned long)crt64);
551 ret = sys_ioctl(fd, cmd, (unsigned long)crt64);
552 if (!ret) 552 if (!ret)
553 if (__get_user(i, &crt64->outputdatalength) || 553 if (__get_user(i, &crt64->outputdatalength) ||
554 __put_user(i, &crt32u->outputdatalength)) 554 __put_user(i, &crt32u->outputdatalength))
@@ -556,66 +556,34 @@ trans_modexpo_crt32(unsigned int fd, unsigned int cmd, unsigned long arg,
556 return ret; 556 return ret;
557} 557}
558 558
559static int compatible_ioctls[] = { 559static long
560 ICAZ90STATUS, Z90QUIESCE, Z90STAT_TOTALCOUNT, Z90STAT_PCICACOUNT, 560z90crypt_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
561 Z90STAT_PCICCCOUNT, Z90STAT_PCIXCCCOUNT, Z90STAT_PCIXCCMCL2COUNT,
562 Z90STAT_PCIXCCMCL3COUNT, Z90STAT_CEX2CCOUNT, Z90STAT_REQUESTQ_COUNT,
563 Z90STAT_PENDINGQ_COUNT, Z90STAT_TOTALOPEN_COUNT, Z90STAT_DOMAIN_INDEX,
564 Z90STAT_STATUS_MASK, Z90STAT_QDEPTH_MASK, Z90STAT_PERDEV_REQCNT,
565};
566
567static void z90_unregister_ioctl32s(void)
568{
569 int i;
570
571 unregister_ioctl32_conversion(ICARSAMODEXPO);
572 unregister_ioctl32_conversion(ICARSACRT);
573
574 for(i = 0; i < ARRAY_SIZE(compatible_ioctls); i++)
575 unregister_ioctl32_conversion(compatible_ioctls[i]);
576}
577
578static int z90_register_ioctl32s(void)
579{
580 int result, i;
581
582 result = register_ioctl32_conversion(ICARSAMODEXPO, trans_modexpo32);
583 if (result == -EBUSY) {
584 unregister_ioctl32_conversion(ICARSAMODEXPO);
585 result = register_ioctl32_conversion(ICARSAMODEXPO,
586 trans_modexpo32);
587 }
588 if (result)
589 return result;
590 result = register_ioctl32_conversion(ICARSACRT, trans_modexpo_crt32);
591 if (result == -EBUSY) {
592 unregister_ioctl32_conversion(ICARSACRT);
593 result = register_ioctl32_conversion(ICARSACRT,
594 trans_modexpo_crt32);
595 }
596 if (result)
597 return result;
598
599 for(i = 0; i < ARRAY_SIZE(compatible_ioctls); i++) {
600 result = register_ioctl32_conversion(compatible_ioctls[i], 0);
601 if (result == -EBUSY) {
602 unregister_ioctl32_conversion(compatible_ioctls[i]);
603 result = register_ioctl32_conversion(
604 compatible_ioctls[i], 0);
605 }
606 if (result)
607 return result;
608 }
609 return 0;
610}
611#else // !CONFIG_COMPAT
612static inline void z90_unregister_ioctl32s(void)
613{
614}
615
616static inline int z90_register_ioctl32s(void)
617{ 561{
618 return 0; 562 switch (cmd) {
563 case ICAZ90STATUS:
564 case Z90QUIESCE:
565 case Z90STAT_TOTALCOUNT:
566 case Z90STAT_PCICACOUNT:
567 case Z90STAT_PCICCCOUNT:
568 case Z90STAT_PCIXCCCOUNT:
569 case Z90STAT_PCIXCCMCL2COUNT:
570 case Z90STAT_PCIXCCMCL3COUNT:
571 case Z90STAT_CEX2CCOUNT:
572 case Z90STAT_REQUESTQ_COUNT:
573 case Z90STAT_PENDINGQ_COUNT:
574 case Z90STAT_TOTALOPEN_COUNT:
575 case Z90STAT_DOMAIN_INDEX:
576 case Z90STAT_STATUS_MASK:
577 case Z90STAT_QDEPTH_MASK:
578 case Z90STAT_PERDEV_REQCNT:
579 return z90crypt_unlocked_ioctl(filp, cmd, arg);
580 case ICARSAMODEXPO:
581 return trans_modexpo32(filp, cmd, arg);
582 case ICARSACRT:
583 return trans_modexpo_crt32(filp, cmd, arg);
584 default:
585 return -ENOIOCTLCMD;
586 }
619} 587}
620#endif 588#endif
621 589
@@ -730,14 +698,9 @@ z90crypt_init_module(void)
730 reader_timer.expires = jiffies + (READERTIME * HZ / 1000); 698 reader_timer.expires = jiffies + (READERTIME * HZ / 1000);
731 add_timer(&reader_timer); 699 add_timer(&reader_timer);
732 700
733 if ((result = z90_register_ioctl32s()))
734 goto init_module_cleanup;
735
736 return 0; // success 701 return 0; // success
737 702
738init_module_cleanup: 703init_module_cleanup:
739 z90_unregister_ioctl32s();
740
741#ifndef Z90CRYPT_USE_HOTPLUG 704#ifndef Z90CRYPT_USE_HOTPLUG
742 if ((nresult = misc_deregister(&z90crypt_misc_device))) 705 if ((nresult = misc_deregister(&z90crypt_misc_device)))
743 PRINTK("misc_deregister failed with %d.\n", nresult); 706 PRINTK("misc_deregister failed with %d.\n", nresult);
@@ -763,8 +726,6 @@ z90crypt_cleanup_module(void)
763 726
764 PDEBUG("PID %d\n", PID()); 727 PDEBUG("PID %d\n", PID());
765 728
766 z90_unregister_ioctl32s();
767
768 remove_proc_entry("driver/z90crypt", 0); 729 remove_proc_entry("driver/z90crypt", 0);
769 730
770#ifndef Z90CRYPT_USE_HOTPLUG 731#ifndef Z90CRYPT_USE_HOTPLUG
@@ -800,7 +761,7 @@ z90crypt_cleanup_module(void)
800 * z90crypt_release 761 * z90crypt_release
801 * z90crypt_read 762 * z90crypt_read
802 * z90crypt_write 763 * z90crypt_write
803 * z90crypt_ioctl 764 * z90crypt_unlocked_ioctl
804 * z90crypt_status 765 * z90crypt_status
805 * z90crypt_status_write 766 * z90crypt_status_write
806 * disable_card 767 * disable_card
@@ -1804,9 +1765,8 @@ z90crypt_rsa(struct priv_data *private_data_p, pid_t pid,
1804 * This function is a little long, but it's really just one large switch 1765 * This function is a little long, but it's really just one large switch
1805 * statement. 1766 * statement.
1806 */ 1767 */
1807static int 1768static long
1808z90crypt_ioctl(struct inode *inode, struct file *filp, 1769z90crypt_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1809 unsigned int cmd, unsigned long arg)
1810{ 1770{
1811 struct priv_data *private_data_p = filp->private_data; 1771 struct priv_data *private_data_p = filp->private_data;
1812 unsigned char *status; 1772 unsigned char *status;
diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c
index a3d285859564..1e3f7f3c662f 100644
--- a/drivers/s390/net/smsgiucv.c
+++ b/drivers/s390/net/smsgiucv.c
@@ -32,7 +32,7 @@ struct smsg_callback {
32 struct list_head list; 32 struct list_head list;
33 char *prefix; 33 char *prefix;
34 int len; 34 int len;
35 void (*callback)(char *str); 35 void (*callback)(char *from, char *str);
36}; 36};
37 37
38MODULE_AUTHOR 38MODULE_AUTHOR
@@ -55,8 +55,9 @@ smsg_message_pending(iucv_MessagePending *eib, void *pgm_data)
55{ 55{
56 struct smsg_callback *cb; 56 struct smsg_callback *cb;
57 unsigned char *msg; 57 unsigned char *msg;
58 unsigned char sender[9];
58 unsigned short len; 59 unsigned short len;
59 int rc; 60 int rc, i;
60 61
61 len = eib->ln1msg2.ipbfln1f; 62 len = eib->ln1msg2.ipbfln1f;
62 msg = kmalloc(len + 1, GFP_ATOMIC|GFP_DMA); 63 msg = kmalloc(len + 1, GFP_ATOMIC|GFP_DMA);
@@ -69,10 +70,18 @@ smsg_message_pending(iucv_MessagePending *eib, void *pgm_data)
69 if (rc == 0) { 70 if (rc == 0) {
70 msg[len] = 0; 71 msg[len] = 0;
71 EBCASC(msg, len); 72 EBCASC(msg, len);
73 memcpy(sender, msg, 8);
74 sender[8] = 0;
75 /* Remove trailing whitespace from the sender name. */
76 for (i = 7; i >= 0; i--) {
77 if (sender[i] != ' ' && sender[i] != '\t')
78 break;
79 sender[i] = 0;
80 }
72 spin_lock(&smsg_list_lock); 81 spin_lock(&smsg_list_lock);
73 list_for_each_entry(cb, &smsg_list, list) 82 list_for_each_entry(cb, &smsg_list, list)
74 if (strncmp(msg + 8, cb->prefix, cb->len) == 0) { 83 if (strncmp(msg + 8, cb->prefix, cb->len) == 0) {
75 cb->callback(msg + 8); 84 cb->callback(sender, msg + 8);
76 break; 85 break;
77 } 86 }
78 spin_unlock(&smsg_list_lock); 87 spin_unlock(&smsg_list_lock);
@@ -91,7 +100,7 @@ static struct device_driver smsg_driver = {
91}; 100};
92 101
93int 102int
94smsg_register_callback(char *prefix, void (*callback)(char *str)) 103smsg_register_callback(char *prefix, void (*callback)(char *from, char *str))
95{ 104{
96 struct smsg_callback *cb; 105 struct smsg_callback *cb;
97 106
@@ -108,7 +117,7 @@ smsg_register_callback(char *prefix, void (*callback)(char *str))
108} 117}
109 118
110void 119void
111smsg_unregister_callback(char *prefix, void (*callback)(char *str)) 120smsg_unregister_callback(char *prefix, void (*callback)(char *from, char *str))
112{ 121{
113 struct smsg_callback *cb, *tmp; 122 struct smsg_callback *cb, *tmp;
114 123
diff --git a/drivers/s390/net/smsgiucv.h b/drivers/s390/net/smsgiucv.h
index 04cd87152964..67f5d4f8378d 100644
--- a/drivers/s390/net/smsgiucv.h
+++ b/drivers/s390/net/smsgiucv.h
@@ -5,6 +5,6 @@
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 */ 6 */
7 7
8int smsg_register_callback(char *, void (*)(char *)); 8int smsg_register_callback(char *, void (*)(char *, char *));
9void smsg_unregister_callback(char *, void (*)(char *)); 9void smsg_unregister_callback(char *, void (*)(char *, char *));
10 10
diff --git a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c
index bf3273eb1c8b..9b988baf0b51 100644
--- a/drivers/sbus/char/rtc.c
+++ b/drivers/sbus/char/rtc.c
@@ -28,10 +28,46 @@
28 28
29static int rtc_busy = 0; 29static int rtc_busy = 0;
30 30
31/* This is the structure layout used by drivers/char/rtc.c, we
32 * support that driver's ioctls so that things are less messy in
33 * userspace.
34 */
35struct rtc_time_generic {
36 int tm_sec;
37 int tm_min;
38 int tm_hour;
39 int tm_mday;
40 int tm_mon;
41 int tm_year;
42 int tm_wday;
43 int tm_yday;
44 int tm_isdst;
45};
46#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */
47#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */
48#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */
49#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */
50#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */
51#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */
52#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */
53#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */
54#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time_generic) /* Read RTC time */
55#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time_generic) /* Set RTC time */
56#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */
57#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */
58#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */
59#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */
60#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */
61#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */
62#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/
63#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/
64#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */
65#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */
66
31/* Retrieve the current date and time from the real time clock. */ 67/* Retrieve the current date and time from the real time clock. */
32static void get_rtc_time(struct rtc_time *t) 68static void get_rtc_time(struct rtc_time *t)
33{ 69{
34 void * __iomem regs = mstk48t02_regs; 70 void __iomem *regs = mstk48t02_regs;
35 u8 tmp; 71 u8 tmp;
36 72
37 spin_lock_irq(&mostek_lock); 73 spin_lock_irq(&mostek_lock);
@@ -58,7 +94,7 @@ static void get_rtc_time(struct rtc_time *t)
58/* Set the current date and time inthe real time clock. */ 94/* Set the current date and time inthe real time clock. */
59void set_rtc_time(struct rtc_time *t) 95void set_rtc_time(struct rtc_time *t)
60{ 96{
61 void * __iomem regs = mstk48t02_regs; 97 void __iomem *regs = mstk48t02_regs;
62 u8 tmp; 98 u8 tmp;
63 99
64 spin_lock_irq(&mostek_lock); 100 spin_lock_irq(&mostek_lock);
@@ -82,29 +118,87 @@ void set_rtc_time(struct rtc_time *t)
82 spin_unlock_irq(&mostek_lock); 118 spin_unlock_irq(&mostek_lock);
83} 119}
84 120
121static int put_rtc_time_generic(void __user *argp, struct rtc_time *tm)
122{
123 struct rtc_time_generic __user *utm = argp;
124
125 if (__put_user(tm->sec, &utm->tm_sec) ||
126 __put_user(tm->min, &utm->tm_min) ||
127 __put_user(tm->hour, &utm->tm_hour) ||
128 __put_user(tm->dom, &utm->tm_mday) ||
129 __put_user(tm->month, &utm->tm_mon) ||
130 __put_user(tm->year, &utm->tm_year) ||
131 __put_user(tm->dow, &utm->tm_wday) ||
132 __put_user(0, &utm->tm_yday) ||
133 __put_user(0, &utm->tm_isdst))
134 return -EFAULT;
135
136 return 0;
137}
138
139static int get_rtc_time_generic(struct rtc_time *tm, void __user *argp)
140{
141 struct rtc_time_generic __user *utm = argp;
142
143 if (__get_user(tm->sec, &utm->tm_sec) ||
144 __get_user(tm->min, &utm->tm_min) ||
145 __get_user(tm->hour, &utm->tm_hour) ||
146 __get_user(tm->dom, &utm->tm_mday) ||
147 __get_user(tm->month, &utm->tm_mon) ||
148 __get_user(tm->year, &utm->tm_year) ||
149 __get_user(tm->dow, &utm->tm_wday))
150 return -EFAULT;
151
152 return 0;
153}
154
85static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 155static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
86 unsigned long arg) 156 unsigned long arg)
87{ 157{
88 struct rtc_time rtc_tm; 158 struct rtc_time rtc_tm;
89 void __user *argp = (void __user *)arg; 159 void __user *argp = (void __user *)arg;
90 160
91 switch (cmd) 161 switch (cmd) {
92 { 162 /* No interrupt support, return an error
163 * compatible with drivers/char/rtc.c
164 */
165 case RTC_AIE_OFF:
166 case RTC_AIE_ON:
167 case RTC_PIE_OFF:
168 case RTC_PIE_ON:
169 case RTC_UIE_OFF:
170 case RTC_UIE_ON:
171 case RTC_IRQP_READ:
172 case RTC_IRQP_SET:
173 case RTC_EPOCH_SET:
174 case RTC_EPOCH_READ:
175 return -EINVAL;
176
93 case RTCGET: 177 case RTCGET:
178 case RTC_RD_TIME:
94 memset(&rtc_tm, 0, sizeof(struct rtc_time)); 179 memset(&rtc_tm, 0, sizeof(struct rtc_time));
95 get_rtc_time(&rtc_tm); 180 get_rtc_time(&rtc_tm);
96 181
97 if (copy_to_user(argp, &rtc_tm, sizeof(struct rtc_time))) 182 if (cmd == RTCGET) {
183 if (copy_to_user(argp, &rtc_tm,
184 sizeof(struct rtc_time)))
185 return -EFAULT;
186 } else if (put_rtc_time_generic(argp, &rtc_tm))
98 return -EFAULT; 187 return -EFAULT;
99 188
100 return 0; 189 return 0;
101 190
102 191
103 case RTCSET: 192 case RTCSET:
193 case RTC_SET_TIME:
104 if (!capable(CAP_SYS_TIME)) 194 if (!capable(CAP_SYS_TIME))
105 return -EPERM; 195 return -EPERM;
106 196
107 if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time))) 197 if (cmd == RTCSET) {
198 if (copy_from_user(&rtc_tm, argp,
199 sizeof(struct rtc_time)))
200 return -EFAULT;
201 } else if (get_rtc_time_generic(&rtc_tm, argp))
108 return -EFAULT; 202 return -EFAULT;
109 203
110 set_rtc_time(&rtc_tm); 204 set_rtc_time(&rtc_tm);
@@ -156,7 +250,7 @@ static int __init rtc_sun_init(void)
156 /* It is possible we are being driven by some other RTC chip 250 /* It is possible we are being driven by some other RTC chip
157 * and thus another RTC driver is handling things. 251 * and thus another RTC driver is handling things.
158 */ 252 */
159 if (mstk48t02_regs == 0) 253 if (!mstk48t02_regs)
160 return -ENODEV; 254 return -ENODEV;
161 255
162 error = misc_register(&rtc_dev); 256 error = misc_register(&rtc_dev);
@@ -164,6 +258,7 @@ static int __init rtc_sun_init(void)
164 printk(KERN_ERR "rtc: unable to get misc minor for Mostek\n"); 258 printk(KERN_ERR "rtc: unable to get misc minor for Mostek\n");
165 return error; 259 return error;
166 } 260 }
261 printk("rtc_sun_init: Registered Mostek RTC driver.\n");
167 262
168 return 0; 263 return 0;
169} 264}
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index ba88be399a59..88e34095ca4e 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -278,7 +278,7 @@ config SCSI_3W_9XXX
278 278
279config SCSI_7000FASST 279config SCSI_7000FASST
280 tristate "7000FASST SCSI support" 280 tristate "7000FASST SCSI support"
281 depends on ISA && SCSI 281 depends on ISA && SCSI && ISA_DMA_API
282 help 282 help
283 This driver supports the Western Digital 7000 SCSI host adapter 283 This driver supports the Western Digital 7000 SCSI host adapter
284 family. Some information is in the source: 284 family. Some information is in the source:
@@ -313,7 +313,7 @@ config SCSI_AHA152X
313 313
314config SCSI_AHA1542 314config SCSI_AHA1542
315 tristate "Adaptec AHA1542 support" 315 tristate "Adaptec AHA1542 support"
316 depends on ISA && SCSI 316 depends on ISA && SCSI && ISA_DMA_API
317 ---help--- 317 ---help---
318 This is support for a SCSI host adapter. It is explained in section 318 This is support for a SCSI host adapter. It is explained in section
319 3.4 of the SCSI-HOWTO, available from 319 3.4 of the SCSI-HOWTO, available from
@@ -533,7 +533,7 @@ config SCSI_SATA_VITESSE
533 533
534config SCSI_BUSLOGIC 534config SCSI_BUSLOGIC
535 tristate "BusLogic SCSI support" 535 tristate "BusLogic SCSI support"
536 depends on (PCI || ISA || MCA) && SCSI && (BROKEN || !SPARC64) 536 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
537 ---help--- 537 ---help---
538 This is support for BusLogic MultiMaster and FlashPoint SCSI Host 538 This is support for BusLogic MultiMaster and FlashPoint SCSI Host
539 Adapters. Consult the SCSI-HOWTO, available from 539 Adapters. Consult the SCSI-HOWTO, available from
@@ -589,7 +589,7 @@ config SCSI_DTC3280
589 589
590config SCSI_EATA 590config SCSI_EATA
591 tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support" 591 tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support"
592 depends on (ISA || EISA || PCI) && SCSI && (BROKEN || !SPARC64) 592 depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
593 ---help--- 593 ---help---
594 This driver supports all EATA/DMA-compliant SCSI host adapters. DPT 594 This driver supports all EATA/DMA-compliant SCSI host adapters. DPT
595 ISA and all EISA I/O addresses are probed looking for the "EATA" 595 ISA and all EISA I/O addresses are probed looking for the "EATA"
@@ -683,7 +683,7 @@ config SCSI_FD_MCS
683 683
684config SCSI_GDTH 684config SCSI_GDTH
685 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" 685 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
686 depends on (ISA || EISA || PCI) && SCSI && (BROKEN || !SPARC64) 686 depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
687 ---help--- 687 ---help---
688 Formerly called GDT SCSI Disk Array Controller Support. 688 Formerly called GDT SCSI Disk Array Controller Support.
689 689
@@ -1412,7 +1412,7 @@ config SCSI_T128
1412 1412
1413config SCSI_U14_34F 1413config SCSI_U14_34F
1414 tristate "UltraStor 14F/34F support" 1414 tristate "UltraStor 14F/34F support"
1415 depends on ISA && SCSI 1415 depends on ISA && SCSI && ISA_DMA_API
1416 ---help--- 1416 ---help---
1417 This is support for the UltraStor 14F and 34F SCSI-2 host adapters. 1417 This is support for the UltraStor 14F and 34F SCSI-2 host adapters.
1418 The source at <file:drivers/scsi/u14-34f.c> contains some 1418 The source at <file:drivers/scsi/u14-34f.c> contains some
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 74293f62a622..064781a2cb1a 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -1824,7 +1824,10 @@ static int esp_do_data(struct NCR_ESP *esp, struct ESP_regs *eregs)
1824 /* loop */ 1824 /* loop */
1825 while (hmuch) { 1825 while (hmuch) {
1826 int j, fifo_stuck = 0, newphase; 1826 int j, fifo_stuck = 0, newphase;
1827 unsigned long flags, timeout; 1827 unsigned long timeout;
1828#if 0
1829 unsigned long flags;
1830#endif
1828#if 0 1831#if 0
1829 if ( i % 10 ) 1832 if ( i % 10 )
1830 ESPDATA(("\r")); 1833 ESPDATA(("\r"));
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 7e9e6b3186ae..5fd8f3ee9804 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -450,7 +450,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
450 } 450 }
451 } 451 }
452 452
453 return 0; 453 return err;
454} 454}
455 455
456/** 456/**
diff --git a/drivers/scsi/esp.c b/drivers/scsi/esp.c
index d8ab73b68031..f6900538be90 100644
--- a/drivers/scsi/esp.c
+++ b/drivers/scsi/esp.c
@@ -49,6 +49,8 @@
49#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
50#include <scsi/scsi_tcq.h> 50#include <scsi/scsi_tcq.h>
51 51
52#define DRV_VERSION "1.101"
53
52#define DEBUG_ESP 54#define DEBUG_ESP
53/* #define DEBUG_ESP_HME */ 55/* #define DEBUG_ESP_HME */
54/* #define DEBUG_ESP_DATA */ 56/* #define DEBUG_ESP_DATA */
@@ -1145,7 +1147,7 @@ static int __init esp_detect(struct scsi_host_template *tpnt)
1145 static struct sbus_dev esp_dev; 1147 static struct sbus_dev esp_dev;
1146 int esps_in_use = 0; 1148 int esps_in_use = 0;
1147 1149
1148 espchain = 0; 1150 espchain = NULL;
1149 1151
1150 if (sun4_esp_physaddr) { 1152 if (sun4_esp_physaddr) {
1151 memset (&esp_dev, 0, sizeof(esp_dev)); 1153 memset (&esp_dev, 0, sizeof(esp_dev));
@@ -2511,7 +2513,7 @@ static inline void esp_reconnect(struct esp *esp, struct scsi_cmnd *sp)
2511 ESPLOG(("esp%d: Weird, being reselected but disconnected " 2513 ESPLOG(("esp%d: Weird, being reselected but disconnected "
2512 "command queue is empty.\n", esp->esp_id)); 2514 "command queue is empty.\n", esp->esp_id));
2513 esp->snip = 0; 2515 esp->snip = 0;
2514 esp->current_SC = 0; 2516 esp->current_SC = NULL;
2515 sp->SCp.phase = not_issued; 2517 sp->SCp.phase = not_issued;
2516 append_SC(&esp->issue_SC, sp); 2518 append_SC(&esp->issue_SC, sp);
2517} 2519}
@@ -4146,7 +4148,7 @@ static int esp_work_bus(struct esp *esp)
4146} 4148}
4147 4149
4148static espfunc_t isvc_vector[] = { 4150static espfunc_t isvc_vector[] = {
4149 0, 4151 NULL,
4150 esp_do_phase_determine, 4152 esp_do_phase_determine,
4151 esp_do_resetbus, 4153 esp_do_resetbus,
4152 esp_finish_reset, 4154 esp_finish_reset,
@@ -4398,5 +4400,8 @@ static struct scsi_host_template driver_template = {
4398 4400
4399#include "scsi_module.c" 4401#include "scsi_module.c"
4400 4402
4403MODULE_DESCRIPTION("EnhancedScsiProcessor Sun SCSI driver");
4404MODULE_AUTHOR("David S. Miller (davem@redhat.com)");
4401MODULE_LICENSE("GPL"); 4405MODULE_LICENSE("GPL");
4406MODULE_VERSION(DRV_VERSION);
4402 4407
diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
index e70dedb0d0a5..7976947c0322 100644
--- a/drivers/scsi/pas16.c
+++ b/drivers/scsi/pas16.c
@@ -137,7 +137,7 @@ static unsigned short pas16_addr = 0;
137static int pas16_irq = 0; 137static int pas16_irq = 0;
138 138
139 139
140int scsi_irq_translate[] = 140static const int scsi_irq_translate[] =
141 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 }; 141 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 };
142 142
143/* The default_irqs array contains values used to set the irq into the 143/* The default_irqs array contains values used to set the irq into the
@@ -145,7 +145,7 @@ int scsi_irq_translate[] =
145 * irq jumpers on the board). The first value in the array will be 145 * irq jumpers on the board). The first value in the array will be
146 * assigned to logical board 0, the next to board 1, etc. 146 * assigned to logical board 0, the next to board 1, etc.
147 */ 147 */
148int default_irqs[] __initdata = 148static int default_irqs[] __initdata =
149 { PAS16_DEFAULT_BOARD_1_IRQ, 149 { PAS16_DEFAULT_BOARD_1_IRQ,
150 PAS16_DEFAULT_BOARD_2_IRQ, 150 PAS16_DEFAULT_BOARD_2_IRQ,
151 PAS16_DEFAULT_BOARD_3_IRQ, 151 PAS16_DEFAULT_BOARD_3_IRQ,
@@ -177,7 +177,7 @@ static struct base {
177 177
178#define NO_BASES (sizeof (bases) / sizeof (struct base)) 178#define NO_BASES (sizeof (bases) / sizeof (struct base))
179 179
180unsigned short pas16_offset[ 8 ] = 180static const unsigned short pas16_offset[ 8 ] =
181 { 181 {
182 0x1c00, /* OUTPUT_DATA_REG */ 182 0x1c00, /* OUTPUT_DATA_REG */
183 0x1c01, /* INITIATOR_COMMAND_REG */ 183 0x1c01, /* INITIATOR_COMMAND_REG */
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index 7bb0a2e56743..c01b7191fcf5 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -45,7 +45,7 @@ static struct ctrl_inquiry {
45 Scsi_Cmnd cmd; 45 Scsi_Cmnd cmd;
46 char inquiry[256]; 46 char inquiry[256];
47 fc_channel *fc; 47 fc_channel *fc;
48} *fcs __initdata = { 0 }; 48} *fcs __initdata;
49static int fcscount __initdata = 0; 49static int fcscount __initdata = 0;
50static atomic_t fcss __initdata = ATOMIC_INIT(0); 50static atomic_t fcss __initdata = ATOMIC_INIT(0);
51DECLARE_MUTEX_LOCKED(fc_sem); 51DECLARE_MUTEX_LOCKED(fc_sem);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 0d730f646bce..5578ae9a9e45 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -542,7 +542,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
542 * that the device is no longer present */ 542 * that the device is no longer present */
543 cmd->result = DID_NO_CONNECT << 16; 543 cmd->result = DID_NO_CONNECT << 16;
544 atomic_inc(&cmd->device->iorequest_cnt); 544 atomic_inc(&cmd->device->iorequest_cnt);
545 scsi_done(cmd); 545 __scsi_done(cmd);
546 /* return 0 (because the command has been processed) */ 546 /* return 0 (because the command has been processed) */
547 goto out; 547 goto out;
548 } 548 }
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 103558574662..cb789c35262c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -582,7 +582,7 @@ static int scsi_request_sense(struct scsi_cmnd *scmd)
582 582
583 memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense)); 583 memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense));
584 584
585 scsi_result = kmalloc(252, GFP_ATOMIC | (scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0); 585 scsi_result = kmalloc(252, GFP_ATOMIC | ((scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0));
586 586
587 587
588 if (unlikely(!scsi_result)) { 588 if (unlikely(!scsi_result)) {
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 287d197a7c17..cca772624ae7 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -801,7 +801,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
801 if (!sreq) 801 if (!sreq)
802 goto out_free_sdev; 802 goto out_free_sdev;
803 result = kmalloc(256, GFP_ATOMIC | 803 result = kmalloc(256, GFP_ATOMIC |
804 (shost->unchecked_isa_dma) ? __GFP_DMA : 0); 804 ((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
805 if (!result) 805 if (!result)
806 goto out_free_sreq; 806 goto out_free_sreq;
807 807
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 303d7656f710..28966d05435c 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/blkdev.h>
25#include <asm/semaphore.h> 26#include <asm/semaphore.h>
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include "scsi_priv.h" 28#include "scsi_priv.h"
@@ -41,6 +42,11 @@
41 42
42#define SPI_MAX_ECHO_BUFFER_SIZE 4096 43#define SPI_MAX_ECHO_BUFFER_SIZE 4096
43 44
45#define DV_LOOPS 3
46#define DV_TIMEOUT (10*HZ)
47#define DV_RETRIES 3 /* should only need at most
48 * two cc/ua clears */
49
44/* Private data accessors (keep these out of the header file) */ 50/* Private data accessors (keep these out of the header file) */
45#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending) 51#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
46#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem) 52#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem)
@@ -100,6 +106,29 @@ static int sprint_frac(char *dest, int value, int denom)
100 return result; 106 return result;
101} 107}
102 108
109/* Modification of scsi_wait_req that will clear UNIT ATTENTION conditions
110 * resulting from (likely) bus and device resets */
111static void spi_wait_req(struct scsi_request *sreq, const void *cmd,
112 void *buffer, unsigned bufflen)
113{
114 int i;
115
116 for(i = 0; i < DV_RETRIES; i++) {
117 sreq->sr_request->flags |= REQ_FAILFAST;
118
119 scsi_wait_req(sreq, cmd, buffer, bufflen,
120 DV_TIMEOUT, /* retries */ 1);
121 if (sreq->sr_result & DRIVER_SENSE) {
122 struct scsi_sense_hdr sshdr;
123
124 if (scsi_request_normalize_sense(sreq, &sshdr)
125 && sshdr.sense_key == UNIT_ATTENTION)
126 continue;
127 }
128 break;
129 }
130}
131
103static struct { 132static struct {
104 enum spi_signal_type value; 133 enum spi_signal_type value;
105 char *name; 134 char *name;
@@ -378,11 +407,6 @@ static CLASS_DEVICE_ATTR(signalling, S_IRUGO | S_IWUSR,
378 if(i->f->set_##x) \ 407 if(i->f->set_##x) \
379 i->f->set_##x(sdev->sdev_target, y) 408 i->f->set_##x(sdev->sdev_target, y)
380 409
381#define DV_LOOPS 3
382#define DV_TIMEOUT (10*HZ)
383#define DV_RETRIES 3 /* should only need at most
384 * two cc/ua clears */
385
386enum spi_compare_returns { 410enum spi_compare_returns {
387 SPI_COMPARE_SUCCESS, 411 SPI_COMPARE_SUCCESS,
388 SPI_COMPARE_FAILURE, 412 SPI_COMPARE_FAILURE,
@@ -446,8 +470,7 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
446 for (r = 0; r < retries; r++) { 470 for (r = 0; r < retries; r++) {
447 sreq->sr_cmd_len = 0; /* wait_req to fill in */ 471 sreq->sr_cmd_len = 0; /* wait_req to fill in */
448 sreq->sr_data_direction = DMA_TO_DEVICE; 472 sreq->sr_data_direction = DMA_TO_DEVICE;
449 scsi_wait_req(sreq, spi_write_buffer, buffer, len, 473 spi_wait_req(sreq, spi_write_buffer, buffer, len);
450 DV_TIMEOUT, DV_RETRIES);
451 if(sreq->sr_result || !scsi_device_online(sdev)) { 474 if(sreq->sr_result || !scsi_device_online(sdev)) {
452 struct scsi_sense_hdr sshdr; 475 struct scsi_sense_hdr sshdr;
453 476
@@ -471,8 +494,7 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
471 memset(ptr, 0, len); 494 memset(ptr, 0, len);
472 sreq->sr_cmd_len = 0; /* wait_req to fill in */ 495 sreq->sr_cmd_len = 0; /* wait_req to fill in */
473 sreq->sr_data_direction = DMA_FROM_DEVICE; 496 sreq->sr_data_direction = DMA_FROM_DEVICE;
474 scsi_wait_req(sreq, spi_read_buffer, ptr, len, 497 spi_wait_req(sreq, spi_read_buffer, ptr, len);
475 DV_TIMEOUT, DV_RETRIES);
476 scsi_device_set_state(sdev, SDEV_QUIESCE); 498 scsi_device_set_state(sdev, SDEV_QUIESCE);
477 499
478 if (memcmp(buffer, ptr, len) != 0) 500 if (memcmp(buffer, ptr, len) != 0)
@@ -500,8 +522,7 @@ spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer,
500 522
501 memset(ptr, 0, len); 523 memset(ptr, 0, len);
502 524
503 scsi_wait_req(sreq, spi_inquiry, ptr, len, 525 spi_wait_req(sreq, spi_inquiry, ptr, len);
504 DV_TIMEOUT, DV_RETRIES);
505 526
506 if(sreq->sr_result || !scsi_device_online(sdev)) { 527 if(sreq->sr_result || !scsi_device_online(sdev)) {
507 scsi_device_set_state(sdev, SDEV_QUIESCE); 528 scsi_device_set_state(sdev, SDEV_QUIESCE);
@@ -593,8 +614,7 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
593 * (reservation conflict, device not ready, etc) just 614 * (reservation conflict, device not ready, etc) just
594 * skip the write tests */ 615 * skip the write tests */
595 for (l = 0; ; l++) { 616 for (l = 0; ; l++) {
596 scsi_wait_req(sreq, spi_test_unit_ready, NULL, 0, 617 spi_wait_req(sreq, spi_test_unit_ready, NULL, 0);
597 DV_TIMEOUT, DV_RETRIES);
598 618
599 if(sreq->sr_result) { 619 if(sreq->sr_result) {
600 if(l >= 3) 620 if(l >= 3)
@@ -608,8 +628,7 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
608 sreq->sr_cmd_len = 0; 628 sreq->sr_cmd_len = 0;
609 sreq->sr_data_direction = DMA_FROM_DEVICE; 629 sreq->sr_data_direction = DMA_FROM_DEVICE;
610 630
611 scsi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4, 631 spi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4);
612 DV_TIMEOUT, DV_RETRIES);
613 632
614 if (sreq->sr_result) 633 if (sreq->sr_result)
615 /* Device has no echo buffer */ 634 /* Device has no echo buffer */
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 5ff83d214f12..5b07c6ec3ecc 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2038,8 +2038,9 @@ static void sym2_set_period(struct scsi_target *starget, int period)
2038 struct sym_hcb *np = sym_get_hcb(shost); 2038 struct sym_hcb *np = sym_get_hcb(shost);
2039 struct sym_tcb *tp = &np->target[starget->id]; 2039 struct sym_tcb *tp = &np->target[starget->id];
2040 2040
2041 /* have to have DT for these transfers */ 2041 /* have to have DT for these transfers, but DT will also
2042 if (period <= np->minsync) 2042 * set width, so check that this is allowed */
2043 if (period <= np->minsync && spi_width(starget))
2043 tp->tgoal.dt = 1; 2044 tp->tgoal.dt = 1;
2044 2045
2045 tp->tgoal.period = period; 2046 tp->tgoal.period = period;
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index f8504b0adebc..33fbda79f350 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -110,7 +110,7 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id, struct pt_regs *r
110 port->icount.rx++; 110 port->icount.rx++;
111 111
112 rxs = *CSR_RXSTAT | RXSTAT_DUMMY_READ; 112 rxs = *CSR_RXSTAT | RXSTAT_DUMMY_READ;
113 if (rxs & RXSTAT_ANYERR) { 113 if (unlikely(rxs & RXSTAT_ANYERR)) {
114 if (rxs & RXSTAT_PARITY) 114 if (rxs & RXSTAT_PARITY)
115 port->icount.parity++; 115 port->icount.parity++;
116 else if (rxs & RXSTAT_FRAME) 116 else if (rxs & RXSTAT_FRAME)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 218b69372c0b..0d9358608fdf 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -51,7 +51,7 @@
51 * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option 51 * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option
52 * is unsafe when used on edge-triggered interrupts. 52 * is unsafe when used on edge-triggered interrupts.
53 */ 53 */
54unsigned int share_irqs = SERIAL8250_SHARE_IRQS; 54static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
55 55
56/* 56/*
57 * Debugging. 57 * Debugging.
diff --git a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
index b8d51eb56bff..4315afe9c080 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/serial/8250_hp300.c
@@ -9,15 +9,15 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/tty.h>
13#include <linux/serial.h> 12#include <linux/serial.h>
14#include <linux/serialP.h>
15#include <linux/serial_core.h> 13#include <linux/serial_core.h>
16#include <linux/delay.h> 14#include <linux/delay.h>
17#include <linux/dio.h> 15#include <linux/dio.h>
18#include <linux/console.h> 16#include <linux/console.h>
19#include <asm/io.h> 17#include <asm/io.h>
20 18
19#include "8250.h"
20
21#if !defined(CONFIG_HPDCA) && !defined(CONFIG_HPAPCI) 21#if !defined(CONFIG_HPDCA) && !defined(CONFIG_HPAPCI)
22#warning CONFIG_8250 defined but neither CONFIG_HPDCA nor CONFIG_HPAPCI defined, are you sure? 22#warning CONFIG_8250 defined but neither CONFIG_HPDCA nor CONFIG_HPAPCI defined, are you sure?
23#endif 23#endif
@@ -163,7 +163,7 @@ int __init hp300_setup_serial_console(void)
163static int __devinit hpdca_init_one(struct dio_dev *d, 163static int __devinit hpdca_init_one(struct dio_dev *d,
164 const struct dio_device_id *ent) 164 const struct dio_device_id *ent)
165{ 165{
166 struct serial_struct serial_req; 166 struct uart_port port;
167 int line; 167 int line;
168 168
169#ifdef CONFIG_SERIAL_8250_CONSOLE 169#ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -172,21 +172,22 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
172 return 0; 172 return 0;
173 } 173 }
174#endif 174#endif
175 memset(&serial_req, 0, sizeof(struct serial_struct)); 175 memset(&port, 0, sizeof(struct uart_port));
176 176
177 /* Memory mapped I/O */ 177 /* Memory mapped I/O */
178 serial_req.io_type = SERIAL_IO_MEM; 178 port.iotype = UPIO_MEM;
179 serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF; 179 port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
180 serial_req.irq = d->ipl; 180 port.irq = d->ipl;
181 serial_req.baud_base = HPDCA_BAUD_BASE; 181 port.uartclk = HPDCA_BAUD_BASE * 16;
182 serial_req.iomap_base = (d->resource.start + UART_OFFSET); 182 port.mapbase = (d->resource.start + UART_OFFSET);
183 serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE); 183 port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE);
184 serial_req.iomem_reg_shift = 1; 184 port.regshift = 1;
185 line = register_serial(&serial_req); 185 port.dev = &d->dev;
186 line = serial8250_register_port(&port);
186 187
187 if (line < 0) { 188 if (line < 0) {
188 printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d" 189 printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d"
189 " irq %d failed\n", d->scode, serial_req.irq); 190 " irq %d failed\n", d->scode, port.irq);
190 return -ENOMEM; 191 return -ENOMEM;
191 } 192 }
192 193
@@ -209,7 +210,7 @@ static int __init hp300_8250_init(void)
209#ifdef CONFIG_HPAPCI 210#ifdef CONFIG_HPAPCI
210 int line; 211 int line;
211 unsigned long base; 212 unsigned long base;
212 struct serial_struct serial_req; 213 struct uart_port uport;
213 struct hp300_port *port; 214 struct hp300_port *port;
214 int i; 215 int i;
215#endif 216#endif
@@ -251,25 +252,25 @@ static int __init hp300_8250_init(void)
251 if (!port) 252 if (!port)
252 return -ENOMEM; 253 return -ENOMEM;
253 254
254 memset(&serial_req, 0, sizeof(struct serial_struct)); 255 memset(&uport, 0, sizeof(struct uart_port));
255 256
256 base = (FRODO_BASE + FRODO_APCI_OFFSET(i)); 257 base = (FRODO_BASE + FRODO_APCI_OFFSET(i));
257 258
258 /* Memory mapped I/O */ 259 /* Memory mapped I/O */
259 serial_req.io_type = SERIAL_IO_MEM; 260 uport.iotype = UPIO_MEM;
260 serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF; 261 uport.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
261 /* XXX - no interrupt support yet */ 262 /* XXX - no interrupt support yet */
262 serial_req.irq = 0; 263 uport.irq = 0;
263 serial_req.baud_base = HPAPCI_BAUD_BASE; 264 uport.uartclk = HPAPCI_BAUD_BASE * 16;
264 serial_req.iomap_base = base; 265 uport.mapbase = base;
265 serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE); 266 uport.membase = (char *)(base + DIO_VIRADDRBASE);
266 serial_req.iomem_reg_shift = 2; 267 uport.regshift = 2;
267 268
268 line = register_serial(&serial_req); 269 line = serial8250_register_port(&uport);
269 270
270 if (line < 0) { 271 if (line < 0) {
271 printk(KERN_NOTICE "8250_hp300: register_serial() APCI %d" 272 printk(KERN_NOTICE "8250_hp300: register_serial() APCI %d"
272 " irq %d failed\n", i, serial_req.irq); 273 " irq %d failed\n", i, uport.irq);
273 kfree(port); 274 kfree(port);
274 continue; 275 continue;
275 } 276 }
@@ -299,7 +300,7 @@ static void __devexit hpdca_remove_one(struct dio_dev *d)
299 /* Disable board-interrupts */ 300 /* Disable board-interrupts */
300 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0); 301 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0);
301 } 302 }
302 unregister_serial(line); 303 serial8250_unregister_port(line);
303} 304}
304#endif 305#endif
305 306
@@ -309,7 +310,7 @@ static void __exit hp300_8250_exit(void)
309 struct hp300_port *port, *to_free; 310 struct hp300_port *port, *to_free;
310 311
311 for (port = hp300_ports; port; ) { 312 for (port = hp300_ports; port; ) {
312 unregister_serial(port->line); 313 serial8250_unregister_port(port->line);
313 to_free = port; 314 to_free = port;
314 port = port->next; 315 port = port->next;
315 kfree(to_free); 316 kfree(to_free);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index f8d90d0ecfea..de54bdc5398b 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -1009,6 +1009,8 @@ get_pci_irq(struct pci_dev *dev, struct pci_board *board, int idx)
1009 * n = number of serial ports 1009 * n = number of serial ports
1010 * baud = baud rate 1010 * baud = baud rate
1011 * 1011 *
1012 * This table is sorted by (in order): baud, bt, bn, n.
1013 *
1012 * Please note: in theory if n = 1, _bt infix should make no difference. 1014 * Please note: in theory if n = 1, _bt infix should make no difference.
1013 * ie, pbn_b0_1_115200 is the same as pbn_b0_bt_1_115200 1015 * ie, pbn_b0_1_115200 is the same as pbn_b0_bt_1_115200
1014 */ 1016 */
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 484f6fb900b5..f2a5e2933c47 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -172,7 +172,7 @@ pl010_rx_chars(struct uart_port *port)
172 * out of the main execution path 172 * out of the main execution path
173 */ 173 */
174 rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX; 174 rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX;
175 if (rsr & UART01x_RSR_ANY) { 175 if (unlikely(rsr & UART01x_RSR_ANY)) {
176 if (rsr & UART01x_RSR_BE) { 176 if (rsr & UART01x_RSR_BE) {
177 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 177 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
178 port->icount.brk++; 178 port->icount.brk++;
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index ff658a830f34..d5cbef3fe8b6 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -137,7 +137,7 @@ pl011_rx_chars(struct uart_amba_port *uap)
137 * out of the main execution path 137 * out of the main execution path
138 */ 138 */
139 rsr = readw(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX; 139 rsr = readw(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
140 if (rsr & UART01x_RSR_ANY) { 140 if (unlikely(rsr & UART01x_RSR_ANY)) {
141 if (rsr & UART01x_RSR_BE) { 141 if (rsr & UART01x_RSR_BE) {
142 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 142 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
143 uap->port.icount.brk++; 143 uap->port.icount.brk++;
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 16592fae47f3..6242f3090a96 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -116,54 +116,43 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re
116 * Note that the error handling code is 116 * Note that the error handling code is
117 * out of the main execution path 117 * out of the main execution path
118 */ 118 */
119 if (ch & UART_ANY_ERR) 119 if (unlikely(ch & UART_ANY_ERR)) {
120 goto handle_error; 120 if (ch & UARTDR_PARERR)
121 port->icount.parity++;
122 else if (ch & UARTDR_FRMERR)
123 port->icount.frame++;
124 if (ch & UARTDR_OVERR)
125 port->icount.overrun++;
121 126
122 if (uart_handle_sysrq_char(port, ch, regs)) 127 ch &= port->read_status_mask;
123 goto ignore_char;
124 128
125 error_return: 129 if (ch & UARTDR_PARERR)
126 tty_insert_flip_char(tty, ch, flg); 130 flg = TTY_PARITY;
127 ignore_char: 131 else if (ch & UARTDR_FRMERR)
128 status = clps_readl(SYSFLG(port)); 132 flg = TTY_FRAME;
129 }
130 out:
131 tty_flip_buffer_push(tty);
132 return IRQ_HANDLED;
133 133
134 handle_error: 134#ifdef SUPPORT_SYSRQ
135 if (ch & UARTDR_PARERR) 135 port->sysrq = 0;
136 port->icount.parity++; 136#endif
137 else if (ch & UARTDR_FRMERR) 137 }
138 port->icount.frame++;
139 if (ch & UARTDR_OVERR)
140 port->icount.overrun++;
141
142 if (ch & port->ignore_status_mask) {
143 if (++ignored > 100)
144 goto out;
145 goto ignore_char;
146 }
147 ch &= port->read_status_mask;
148 138
149 if (ch & UARTDR_PARERR) 139 if (uart_handle_sysrq_char(port, ch, regs))
150 flg = TTY_PARITY; 140 goto ignore_char;
151 else if (ch & UARTDR_FRMERR)
152 flg = TTY_FRAME;
153 141
154 if (ch & UARTDR_OVERR) {
155 /* 142 /*
156 * CHECK: does overrun affect the current character? 143 * CHECK: does overrun affect the current character?
157 * ASSUMPTION: it does not. 144 * ASSUMPTION: it does not.
158 */ 145 */
159 tty_insert_flip_char(tty, ch, flg); 146 if ((ch & port->ignore_status_mask & ~RXSTAT_OVERRUN) == 0)
160 ch = 0; 147 tty_insert_flip_char(tty, ch, flg);
161 flg = TTY_OVERRUN; 148 if ((ch & ~port->ignore_status_mask & RXSTAT_OVERRUN) == 0)
149 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
150
151 ignore_char:
152 status = clps_readl(SYSFLG(port));
162 } 153 }
163#ifdef SUPPORT_SYSRQ 154 tty_flip_buffer_push(tty);
164 port->sysrq = 0; 155 return IRQ_HANDLED;
165#endif
166 goto error_return;
167} 156}
168 157
169static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs) 158static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index c682c6308cde..01a8726a3f97 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -321,18 +321,39 @@ static void imx_break_ctl(struct uart_port *port, int break_state)
321#define TXTL 2 /* reset default */ 321#define TXTL 2 /* reset default */
322#define RXTL 1 /* reset default */ 322#define RXTL 1 /* reset default */
323 323
324static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
325{
326 unsigned int val;
327 unsigned int ufcr_rfdiv;
328
329 /* set receiver / transmitter trigger level.
330 * RFDIV is set such way to satisfy requested uartclk value
331 */
332 val = TXTL<<10 | RXTL;
333 ufcr_rfdiv = (imx_get_perclk1() + sport->port.uartclk / 2) / sport->port.uartclk;
334
335 if(!ufcr_rfdiv)
336 ufcr_rfdiv = 1;
337
338 if(ufcr_rfdiv >= 7)
339 ufcr_rfdiv = 6;
340 else
341 ufcr_rfdiv = 6 - ufcr_rfdiv;
342
343 val |= UFCR_RFDIV & (ufcr_rfdiv << 7);
344
345 UFCR((u32)sport->port.membase) = val;
346
347 return 0;
348}
349
324static int imx_startup(struct uart_port *port) 350static int imx_startup(struct uart_port *port)
325{ 351{
326 struct imx_port *sport = (struct imx_port *)port; 352 struct imx_port *sport = (struct imx_port *)port;
327 int retval; 353 int retval;
328 unsigned int val;
329 unsigned long flags; 354 unsigned long flags;
330 355
331 /* set receiver / transmitter trigger level. We assume 356 imx_setup_ufcr(sport, 0);
332 * that RFDIV has been set by the arch setup or by the bootloader.
333 */
334 val = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) | TXTL<<10 | RXTL;
335 UFCR((u32)sport->port.membase) = val;
336 357
337 /* disable the DREN bit (Data Ready interrupt enable) before 358 /* disable the DREN bit (Data Ready interrupt enable) before
338 * requesting IRQs 359 * requesting IRQs
@@ -737,9 +758,12 @@ static void __init
737imx_console_get_options(struct imx_port *sport, int *baud, 758imx_console_get_options(struct imx_port *sport, int *baud,
738 int *parity, int *bits) 759 int *parity, int *bits)
739{ 760{
761
740 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) { 762 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) {
741 /* ok, the port was enabled */ 763 /* ok, the port was enabled */
742 unsigned int ucr2, ubir,ubmr, uartclk; 764 unsigned int ucr2, ubir,ubmr, uartclk;
765 unsigned int baud_raw;
766 unsigned int ucfr_rfdiv;
743 767
744 ucr2 = UCR2((u32)sport->port.membase); 768 ucr2 = UCR2((u32)sport->port.membase);
745 769
@@ -758,9 +782,35 @@ imx_console_get_options(struct imx_port *sport, int *baud,
758 782
759 ubir = UBIR((u32)sport->port.membase) & 0xffff; 783 ubir = UBIR((u32)sport->port.membase) & 0xffff;
760 ubmr = UBMR((u32)sport->port.membase) & 0xffff; 784 ubmr = UBMR((u32)sport->port.membase) & 0xffff;
761 uartclk = sport->port.uartclk;
762 785
763 *baud = ((uartclk/16) * (ubir + 1)) / (ubmr + 1); 786
787 ucfr_rfdiv = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) >> 7;
788 if (ucfr_rfdiv == 6)
789 ucfr_rfdiv = 7;
790 else
791 ucfr_rfdiv = 6 - ucfr_rfdiv;
792
793 uartclk = imx_get_perclk1();
794 uartclk /= ucfr_rfdiv;
795
796 { /*
797 * The next code provides exact computation of
798 * baud_raw = round(((uartclk/16) * (ubir + 1)) / (ubmr + 1))
799 * without need of float support or long long division,
800 * which would be required to prevent 32bit arithmetic overflow
801 */
802 unsigned int mul = ubir + 1;
803 unsigned int div = 16 * (ubmr + 1);
804 unsigned int rem = uartclk % div;
805
806 baud_raw = (uartclk / div) * mul;
807 baud_raw += (rem * mul + div / 2) / div;
808 *baud = (baud_raw + 50) / 100 * 100;
809 }
810
811 if(*baud != baud_raw)
812 printk(KERN_INFO "Serial: Console IMX rounded baud rate from %d to %d\n",
813 baud_raw, *baud);
764 } 814 }
765} 815}
766 816
@@ -787,6 +837,8 @@ imx_console_setup(struct console *co, char *options)
787 else 837 else
788 imx_console_get_options(sport, &baud, &parity, &bits); 838 imx_console_get_options(sport, &baud, &parity, &bits);
789 839
840 imx_setup_ufcr(sport, 0);
841
790 return uart_set_options(&sport->port, co, baud, parity, bits, flow); 842 return uart_set_options(&sport->port, co, baud, parity, bits, flow);
791} 843}
792 844
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index d054f1265701..ba4e13a22a50 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -838,7 +838,7 @@ static int inline port_init(struct ioc4_port *port)
838 port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK; 838 port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK;
839 writel(port->ip_tx_prod, &port->ip_serial_regs->stpir); 839 writel(port->ip_tx_prod, &port->ip_serial_regs->stpir);
840 port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK; 840 port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK;
841 writel(port->ip_rx_cons, &port->ip_serial_regs->srcir); 841 writel(port->ip_rx_cons | IOC4_SRCIR_ARM, &port->ip_serial_regs->srcir);
842 842
843 /* Disable interrupts for this 16550 */ 843 /* Disable interrupts for this 16550 */
844 uart = port->ip_uart_regs; 844 uart = port->ip_uart_regs;
@@ -1272,8 +1272,9 @@ static inline int set_rx_timeout(struct ioc4_port *port, int timeout)
1272 * and set the rx threshold to that amount. There are 4 chars 1272 * and set the rx threshold to that amount. There are 4 chars
1273 * per ring entry, so we'll divide the number of chars that will 1273 * per ring entry, so we'll divide the number of chars that will
1274 * arrive in timeout by 4. 1274 * arrive in timeout by 4.
1275 * So .... timeout * baud / 10 / HZ / 4, with HZ = 100.
1275 */ 1276 */
1276 threshold = timeout * port->ip_baud / 10 / HZ / 4; 1277 threshold = timeout * port->ip_baud / 4000;
1277 if (threshold == 0) 1278 if (threshold == 0)
1278 threshold = 1; /* otherwise we'll intr all the time! */ 1279 threshold = 1; /* otherwise we'll intr all the time! */
1279 1280
@@ -1285,8 +1286,10 @@ static inline int set_rx_timeout(struct ioc4_port *port, int timeout)
1285 1286
1286 writel(port->ip_sscr, &port->ip_serial_regs->sscr); 1287 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1287 1288
1288 /* Now set the rx timeout to the given value */ 1289 /* Now set the rx timeout to the given value
1289 timeout = timeout * IOC4_SRTR_HZ / HZ; 1290 * again timeout * IOC4_SRTR_HZ / HZ
1291 */
1292 timeout = timeout * IOC4_SRTR_HZ / 100;
1290 if (timeout > IOC4_SRTR_CNT) 1293 if (timeout > IOC4_SRTR_CNT)
1291 timeout = IOC4_SRTR_CNT; 1294 timeout = IOC4_SRTR_CNT;
1292 1295
@@ -1380,7 +1383,7 @@ config_port(struct ioc4_port *port,
1380 if (port->ip_tx_lowat == 0) 1383 if (port->ip_tx_lowat == 0)
1381 port->ip_tx_lowat = 1; 1384 port->ip_tx_lowat = 1;
1382 1385
1383 set_rx_timeout(port, port->ip_rx_timeout); 1386 set_rx_timeout(port, 2);
1384 1387
1385 return 0; 1388 return 0;
1386} 1389}
@@ -1685,8 +1688,8 @@ ioc4_change_speed(struct uart_port *the_port,
1685{ 1688{
1686 struct ioc4_port *port = get_ioc4_port(the_port); 1689 struct ioc4_port *port = get_ioc4_port(the_port);
1687 int baud, bits; 1690 int baud, bits;
1688 unsigned cflag, cval; 1691 unsigned cflag;
1689 int new_parity = 0, new_parity_enable = 0, new_stop = 1, new_data = 8; 1692 int new_parity = 0, new_parity_enable = 0, new_stop = 0, new_data = 8;
1690 struct uart_info *info = the_port->info; 1693 struct uart_info *info = the_port->info;
1691 1694
1692 cflag = new_termios->c_cflag; 1695 cflag = new_termios->c_cflag;
@@ -1694,48 +1697,35 @@ ioc4_change_speed(struct uart_port *the_port,
1694 switch (cflag & CSIZE) { 1697 switch (cflag & CSIZE) {
1695 case CS5: 1698 case CS5:
1696 new_data = 5; 1699 new_data = 5;
1697 cval = 0x00;
1698 bits = 7; 1700 bits = 7;
1699 break; 1701 break;
1700 case CS6: 1702 case CS6:
1701 new_data = 6; 1703 new_data = 6;
1702 cval = 0x01;
1703 bits = 8; 1704 bits = 8;
1704 break; 1705 break;
1705 case CS7: 1706 case CS7:
1706 new_data = 7; 1707 new_data = 7;
1707 cval = 0x02;
1708 bits = 9; 1708 bits = 9;
1709 break; 1709 break;
1710 case CS8: 1710 case CS8:
1711 new_data = 8; 1711 new_data = 8;
1712 cval = 0x03;
1713 bits = 10; 1712 bits = 10;
1714 break; 1713 break;
1715 default: 1714 default:
1716 /* cuz we always need a default ... */ 1715 /* cuz we always need a default ... */
1717 new_data = 5; 1716 new_data = 5;
1718 cval = 0x00;
1719 bits = 7; 1717 bits = 7;
1720 break; 1718 break;
1721 } 1719 }
1722 if (cflag & CSTOPB) { 1720 if (cflag & CSTOPB) {
1723 cval |= 0x04;
1724 bits++; 1721 bits++;
1725 new_stop = 1; 1722 new_stop = 1;
1726 } 1723 }
1727 if (cflag & PARENB) { 1724 if (cflag & PARENB) {
1728 cval |= UART_LCR_PARITY;
1729 bits++; 1725 bits++;
1730 new_parity_enable = 1; 1726 new_parity_enable = 1;
1731 } 1727 if (cflag & PARODD)
1732 if (cflag & PARODD) { 1728 new_parity = 1;
1733 cval |= UART_LCR_EPAR;
1734 new_parity = 1;
1735 }
1736 if (cflag & IGNPAR) {
1737 cval &= ~UART_LCR_PARITY;
1738 new_parity_enable = 0;
1739 } 1729 }
1740 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 1730 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
1741 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 1731 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
@@ -1765,10 +1755,15 @@ ioc4_change_speed(struct uart_port *the_port,
1765 the_port->ignore_status_mask &= ~N_DATA_READY; 1755 the_port->ignore_status_mask &= ~N_DATA_READY;
1766 } 1756 }
1767 1757
1768 if (cflag & CRTSCTS) 1758 if (cflag & CRTSCTS) {
1769 info->flags |= ASYNC_CTS_FLOW; 1759 info->flags |= ASYNC_CTS_FLOW;
1770 else 1760 port->ip_sscr |= IOC4_SSCR_HFC_EN;
1761 }
1762 else {
1771 info->flags &= ~ASYNC_CTS_FLOW; 1763 info->flags &= ~ASYNC_CTS_FLOW;
1764 port->ip_sscr &= ~IOC4_SSCR_HFC_EN;
1765 }
1766 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1772 1767
1773 /* Set the configuration and proper notification call */ 1768 /* Set the configuration and proper notification call */
1774 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o " 1769 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o "
@@ -1825,12 +1820,6 @@ static inline int ic4_startup_local(struct uart_port *the_port)
1825 /* set the speed of the serial port */ 1820 /* set the speed of the serial port */
1826 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0); 1821 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0);
1827 1822
1828 /* enable hardware flow control - after ioc4_change_speed because
1829 * ASYNC_CTS_FLOW is set there */
1830 if (info->flags & ASYNC_CTS_FLOW) {
1831 port->ip_sscr |= IOC4_SSCR_HFC_EN;
1832 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1833 }
1834 info->flags |= UIF_INITIALIZED; 1823 info->flags |= UIF_INITIALIZED;
1835 return 0; 1824 return 0;
1836} 1825}
@@ -1847,7 +1836,6 @@ static void ioc4_cb_output_lowat(struct ioc4_port *port)
1847 } 1836 }
1848} 1837}
1849 1838
1850
1851/** 1839/**
1852 * handle_intr - service any interrupts for the given port - 2nd level 1840 * handle_intr - service any interrupts for the given port - 2nd level
1853 * called via sd_intr 1841 * called via sd_intr
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index e0717611c940..777829fa3300 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -393,7 +393,6 @@ int jsm_tty_init(struct jsm_board *);
393int jsm_uart_port_init(struct jsm_board *); 393int jsm_uart_port_init(struct jsm_board *);
394int jsm_remove_uart_port(struct jsm_board *); 394int jsm_remove_uart_port(struct jsm_board *);
395void jsm_input(struct jsm_channel *ch); 395void jsm_input(struct jsm_channel *ch);
396void jsm_carrier(struct jsm_channel *ch);
397void jsm_check_queue_flow_control(struct jsm_channel *ch); 396void jsm_check_queue_flow_control(struct jsm_channel *ch);
398 397
399#endif 398#endif
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index 9b79c1ff6c72..3a11a69feb44 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -688,7 +688,7 @@ static void neo_flush_uart_read(struct jsm_channel *ch)
688/* 688/*
689 * No locks are assumed to be held when calling this function. 689 * No locks are assumed to be held when calling this function.
690 */ 690 */
691void neo_clear_break(struct jsm_channel *ch, int force) 691static void neo_clear_break(struct jsm_channel *ch, int force)
692{ 692{
693 unsigned long lock_flags; 693 unsigned long lock_flags;
694 694
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 24fe76c28833..98de2258fd06 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -31,6 +31,8 @@
31 31
32#include "jsm.h" 32#include "jsm.h"
33 33
34static void jsm_carrier(struct jsm_channel *ch);
35
34static inline int jsm_get_mstat(struct jsm_channel *ch) 36static inline int jsm_get_mstat(struct jsm_channel *ch)
35{ 37{
36 unsigned char mstat; 38 unsigned char mstat;
@@ -755,7 +757,7 @@ void jsm_input(struct jsm_channel *ch)
755 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 757 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n");
756} 758}
757 759
758void jsm_carrier(struct jsm_channel *ch) 760static void jsm_carrier(struct jsm_channel *ch)
759{ 761{
760 struct jsm_board *bd; 762 struct jsm_board *bd;
761 763
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index d0dfc3cf9245..a8314aee2ab8 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -329,8 +329,8 @@ mpsc_sdma_stop(struct mpsc_port_info *pi)
329 mpsc_sdma_cmd(pi, SDMA_SDCM_AR | SDMA_SDCM_AT); 329 mpsc_sdma_cmd(pi, SDMA_SDCM_AR | SDMA_SDCM_AT);
330 330
331 /* Clear the SDMA current and first TX and RX pointers */ 331 /* Clear the SDMA current and first TX and RX pointers */
332 mpsc_sdma_set_tx_ring(pi, 0); 332 mpsc_sdma_set_tx_ring(pi, NULL);
333 mpsc_sdma_set_rx_ring(pi, 0); 333 mpsc_sdma_set_rx_ring(pi, NULL);
334 334
335 /* Disable interrupts */ 335 /* Disable interrupts */
336 mpsc_sdma_intr_mask(pi, 0xf); 336 mpsc_sdma_intr_mask(pi, 0xf);
@@ -1540,8 +1540,8 @@ mpsc_shared_unmap_regs(void)
1540 MPSC_SDMA_INTR_REG_BLOCK_SIZE); 1540 MPSC_SDMA_INTR_REG_BLOCK_SIZE);
1541 } 1541 }
1542 1542
1543 mpsc_shared_regs.mpsc_routing_base = 0; 1543 mpsc_shared_regs.mpsc_routing_base = NULL;
1544 mpsc_shared_regs.sdma_intr_base = 0; 1544 mpsc_shared_regs.sdma_intr_base = NULL;
1545 1545
1546 mpsc_shared_regs.mpsc_routing_base_p = 0; 1546 mpsc_shared_regs.mpsc_routing_base_p = 0;
1547 mpsc_shared_regs.sdma_intr_base_p = 0; 1547 mpsc_shared_regs.sdma_intr_base_p = 0;
@@ -1678,9 +1678,9 @@ mpsc_drv_unmap_regs(struct mpsc_port_info *pi)
1678 release_mem_region(pi->brg_base_p, MPSC_BRG_REG_BLOCK_SIZE); 1678 release_mem_region(pi->brg_base_p, MPSC_BRG_REG_BLOCK_SIZE);
1679 } 1679 }
1680 1680
1681 pi->mpsc_base = 0; 1681 pi->mpsc_base = NULL;
1682 pi->sdma_base = 0; 1682 pi->sdma_base = NULL;
1683 pi->brg_base = 0; 1683 pi->brg_base = NULL;
1684 1684
1685 pi->mpsc_base_p = 0; 1685 pi->mpsc_base_p = 0;
1686 pi->sdma_base_p = 0; 1686 pi->sdma_base_p = 0;
diff --git a/drivers/serial/mpsc.h b/drivers/serial/mpsc.h
index 1f7294b7095f..678dbcf06c8f 100644
--- a/drivers/serial/mpsc.h
+++ b/drivers/serial/mpsc.h
@@ -83,8 +83,8 @@ struct mpsc_shared_regs {
83 phys_addr_t mpsc_routing_base_p; 83 phys_addr_t mpsc_routing_base_p;
84 phys_addr_t sdma_intr_base_p; 84 phys_addr_t sdma_intr_base_p;
85 85
86 void *mpsc_routing_base; 86 void __iomem *mpsc_routing_base;
87 void *sdma_intr_base; 87 void __iomem *sdma_intr_base;
88 88
89 u32 MPSC_MRR_m; 89 u32 MPSC_MRR_m;
90 u32 MPSC_RCRR_m; 90 u32 MPSC_RCRR_m;
@@ -120,9 +120,9 @@ struct mpsc_port_info {
120 phys_addr_t brg_base_p; 120 phys_addr_t brg_base_p;
121 121
122 /* Virtual addresses of various blocks of registers (from platform) */ 122 /* Virtual addresses of various blocks of registers (from platform) */
123 void *mpsc_base; 123 void __iomem *mpsc_base;
124 void *sdma_base; 124 void __iomem *sdma_base;
125 void *brg_base; 125 void __iomem *brg_base;
126 126
127 /* Descriptor ring and buffer allocations */ 127 /* Descriptor ring and buffer allocations */
128 void *dma_region; 128 void *dma_region;
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index bd6782aeb831..435750d40a47 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -364,7 +364,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
364 flag = TTY_NORMAL; 364 flag = TTY_NORMAL;
365 port->icount.rx++; 365 port->icount.rx++;
366 366
367 if (uerstat & S3C2410_UERSTAT_ANY) { 367 if (unlikely(uerstat & S3C2410_UERSTAT_ANY)) {
368 dbg("rxerr: port ch=0x%02x, rxs=0x%08x\n", 368 dbg("rxerr: port ch=0x%02x, rxs=0x%08x\n",
369 ch, uerstat); 369 ch, uerstat);
370 370
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 086065210d1e..157218bc6c6f 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -214,56 +214,39 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs)
214 * note that the error handling code is 214 * note that the error handling code is
215 * out of the main execution path 215 * out of the main execution path
216 */ 216 */
217 if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) 217 if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) {
218 goto handle_error; 218 if (status & UTSR1_TO_SM(UTSR1_PRE))
219 sport->port.icount.parity++;
220 else if (status & UTSR1_TO_SM(UTSR1_FRE))
221 sport->port.icount.frame++;
222 if (status & UTSR1_TO_SM(UTSR1_ROR))
223 sport->port.icount.overrun++;
224
225 status &= sport->port.read_status_mask;
226
227 if (status & UTSR1_TO_SM(UTSR1_PRE))
228 flg = TTY_PARITY;
229 else if (status & UTSR1_TO_SM(UTSR1_FRE))
230 flg = TTY_FRAME;
231
232#ifdef SUPPORT_SYSRQ
233 sport->port.sysrq = 0;
234#endif
235 }
219 236
220 if (uart_handle_sysrq_char(&sport->port, ch, regs)) 237 if (uart_handle_sysrq_char(&sport->port, ch, regs))
221 goto ignore_char; 238 goto ignore_char;
222 239
223 error_return: 240 if ((status & port->ignore_status_mask & ~UTSR1_TO_SM(UTSR1_ROR)) == 0)
224 tty_insert_flip_char(tty, ch, flg); 241 tty_insert_flip_char(tty, ch, flg);
242 if (status & ~port->ignore_status_mask & UTSR1_TO_SM(UTSR1_ROR))
243 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
244
225 ignore_char: 245 ignore_char:
226 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 246 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
227 UTSR0_TO_SM(UART_GET_UTSR0(sport)); 247 UTSR0_TO_SM(UART_GET_UTSR0(sport));
228 } 248 }
229 out:
230 tty_flip_buffer_push(tty); 249 tty_flip_buffer_push(tty);
231 return;
232
233 handle_error:
234 if (status & UTSR1_TO_SM(UTSR1_PRE))
235 sport->port.icount.parity++;
236 else if (status & UTSR1_TO_SM(UTSR1_FRE))
237 sport->port.icount.frame++;
238 if (status & UTSR1_TO_SM(UTSR1_ROR))
239 sport->port.icount.overrun++;
240
241 if (status & sport->port.ignore_status_mask) {
242 if (++ignored > 100)
243 goto out;
244 goto ignore_char;
245 }
246
247 status &= sport->port.read_status_mask;
248
249 if (status & UTSR1_TO_SM(UTSR1_PRE))
250 flg = TTY_PARITY;
251 else if (status & UTSR1_TO_SM(UTSR1_FRE))
252 flg = TTY_FRAME;
253
254 if (status & UTSR1_TO_SM(UTSR1_ROR)) {
255 /*
256 * overrun does *not* affect the character
257 * we read from the FIFO
258 */
259 tty_insert_flip_char(tty, ch, flg);
260 ch = 0;
261 flg = TTY_OVERRUN;
262 }
263#ifdef SUPPORT_SYSRQ
264 sport->port.sysrq = 0;
265#endif
266 goto error_return;
267} 250}
268 251
269static void sa1100_tx_chars(struct sa1100_port *sport) 252static void sa1100_tx_chars(struct sa1100_port *sport)
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 9034f9ad37c7..6eeb48f6a482 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -107,6 +107,13 @@ struct serial_info {
107 int line[4]; 107 int line[4];
108}; 108};
109 109
110struct serial_cfg_mem {
111 tuple_t tuple;
112 cisparse_t parse;
113 u_char buf[256];
114};
115
116
110static void serial_config(dev_link_t * link); 117static void serial_config(dev_link_t * link);
111static int serial_event(event_t event, int priority, 118static int serial_event(event_t event, int priority,
112 event_callback_args_t * args); 119 event_callback_args_t * args);
@@ -357,14 +364,24 @@ static int simple_config(dev_link_t *link)
357 static int size_table[2] = { 8, 16 }; 364 static int size_table[2] = { 8, 16 };
358 client_handle_t handle = link->handle; 365 client_handle_t handle = link->handle;
359 struct serial_info *info = link->priv; 366 struct serial_info *info = link->priv;
360 tuple_t tuple; 367 struct serial_cfg_mem *cfg_mem;
361 u_char buf[256]; 368 tuple_t *tuple;
362 cisparse_t parse; 369 u_char *buf;
363 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 370 cisparse_t *parse;
371 cistpl_cftable_entry_t *cf;
364 config_info_t config; 372 config_info_t config;
365 int i, j, try; 373 int i, j, try;
366 int s; 374 int s;
367 375
376 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
377 if (!cfg_mem)
378 return -1;
379
380 tuple = &cfg_mem->tuple;
381 parse = &cfg_mem->parse;
382 cf = &parse->cftable_entry;
383 buf = cfg_mem->buf;
384
368 /* If the card is already configured, look up the port and irq */ 385 /* If the card is already configured, look up the port and irq */
369 i = pcmcia_get_configuration_info(handle, &config); 386 i = pcmcia_get_configuration_info(handle, &config);
370 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) { 387 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) {
@@ -377,21 +394,23 @@ static int simple_config(dev_link_t *link)
377 port = config.BasePort1 + 0x28; 394 port = config.BasePort1 + 0x28;
378 info->slave = 1; 395 info->slave = 1;
379 } 396 }
380 if (info->slave) 397 if (info->slave) {
398 kfree(cfg_mem);
381 return setup_serial(handle, info, port, config.AssignedIRQ); 399 return setup_serial(handle, info, port, config.AssignedIRQ);
400 }
382 } 401 }
383 link->conf.Vcc = config.Vcc; 402 link->conf.Vcc = config.Vcc;
384 403
385 /* First pass: look for a config entry that looks normal. */ 404 /* First pass: look for a config entry that looks normal. */
386 tuple.TupleData = (cisdata_t *) buf; 405 tuple->TupleData = (cisdata_t *) buf;
387 tuple.TupleOffset = 0; 406 tuple->TupleOffset = 0;
388 tuple.TupleDataMax = 255; 407 tuple->TupleDataMax = 255;
389 tuple.Attributes = 0; 408 tuple->Attributes = 0;
390 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 409 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
391 /* Two tries: without IO aliases, then with aliases */ 410 /* Two tries: without IO aliases, then with aliases */
392 for (s = 0; s < 2; s++) { 411 for (s = 0; s < 2; s++) {
393 for (try = 0; try < 2; try++) { 412 for (try = 0; try < 2; try++) {
394 i = first_tuple(handle, &tuple, &parse); 413 i = first_tuple(handle, tuple, parse);
395 while (i != CS_NO_MORE_ITEMS) { 414 while (i != CS_NO_MORE_ITEMS) {
396 if (i != CS_SUCCESS) 415 if (i != CS_SUCCESS)
397 goto next_entry; 416 goto next_entry;
@@ -409,14 +428,14 @@ static int simple_config(dev_link_t *link)
409 goto found_port; 428 goto found_port;
410 } 429 }
411next_entry: 430next_entry:
412 i = next_tuple(handle, &tuple, &parse); 431 i = next_tuple(handle, tuple, parse);
413 } 432 }
414 } 433 }
415 } 434 }
416 /* Second pass: try to find an entry that isn't picky about 435 /* Second pass: try to find an entry that isn't picky about
417 its base address, then try to grab any standard serial port 436 its base address, then try to grab any standard serial port
418 address, and finally try to get any free port. */ 437 address, and finally try to get any free port. */
419 i = first_tuple(handle, &tuple, &parse); 438 i = first_tuple(handle, tuple, parse);
420 while (i != CS_NO_MORE_ITEMS) { 439 while (i != CS_NO_MORE_ITEMS) {
421 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && 440 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) &&
422 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 441 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
@@ -429,7 +448,7 @@ next_entry:
429 goto found_port; 448 goto found_port;
430 } 449 }
431 } 450 }
432 i = next_tuple(handle, &tuple, &parse); 451 i = next_tuple(handle, tuple, parse);
433 } 452 }
434 453
435 found_port: 454 found_port:
@@ -437,6 +456,7 @@ next_entry:
437 printk(KERN_NOTICE 456 printk(KERN_NOTICE
438 "serial_cs: no usable port range found, giving up\n"); 457 "serial_cs: no usable port range found, giving up\n");
439 cs_error(link->handle, RequestIO, i); 458 cs_error(link->handle, RequestIO, i);
459 kfree(cfg_mem);
440 return -1; 460 return -1;
441 } 461 }
442 462
@@ -450,9 +470,10 @@ next_entry:
450 i = pcmcia_request_configuration(link->handle, &link->conf); 470 i = pcmcia_request_configuration(link->handle, &link->conf);
451 if (i != CS_SUCCESS) { 471 if (i != CS_SUCCESS) {
452 cs_error(link->handle, RequestConfiguration, i); 472 cs_error(link->handle, RequestConfiguration, i);
473 kfree(cfg_mem);
453 return -1; 474 return -1;
454 } 475 }
455 476 kfree(cfg_mem);
456 return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 477 return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
457} 478}
458 479
@@ -460,29 +481,39 @@ static int multi_config(dev_link_t * link)
460{ 481{
461 client_handle_t handle = link->handle; 482 client_handle_t handle = link->handle;
462 struct serial_info *info = link->priv; 483 struct serial_info *info = link->priv;
463 tuple_t tuple; 484 struct serial_cfg_mem *cfg_mem;
464 u_char buf[256]; 485 tuple_t *tuple;
465 cisparse_t parse; 486 u_char *buf;
466 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 487 cisparse_t *parse;
488 cistpl_cftable_entry_t *cf;
467 config_info_t config; 489 config_info_t config;
468 int i, base2 = 0; 490 int i, rc, base2 = 0;
491
492 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
493 if (!cfg_mem)
494 return -1;
495 tuple = &cfg_mem->tuple;
496 parse = &cfg_mem->parse;
497 cf = &parse->cftable_entry;
498 buf = cfg_mem->buf;
469 499
470 i = pcmcia_get_configuration_info(handle, &config); 500 i = pcmcia_get_configuration_info(handle, &config);
471 if (i != CS_SUCCESS) { 501 if (i != CS_SUCCESS) {
472 cs_error(handle, GetConfigurationInfo, i); 502 cs_error(handle, GetConfigurationInfo, i);
473 return -1; 503 rc = -1;
504 goto free_cfg_mem;
474 } 505 }
475 link->conf.Vcc = config.Vcc; 506 link->conf.Vcc = config.Vcc;
476 507
477 tuple.TupleData = (cisdata_t *) buf; 508 tuple->TupleData = (cisdata_t *) buf;
478 tuple.TupleOffset = 0; 509 tuple->TupleOffset = 0;
479 tuple.TupleDataMax = 255; 510 tuple->TupleDataMax = 255;
480 tuple.Attributes = 0; 511 tuple->Attributes = 0;
481 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 512 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
482 513
483 /* First, look for a generic full-sized window */ 514 /* First, look for a generic full-sized window */
484 link->io.NumPorts1 = info->multi * 8; 515 link->io.NumPorts1 = info->multi * 8;
485 i = first_tuple(handle, &tuple, &parse); 516 i = first_tuple(handle, tuple, parse);
486 while (i != CS_NO_MORE_ITEMS) { 517 while (i != CS_NO_MORE_ITEMS) {
487 /* The quad port cards have bad CIS's, so just look for a 518 /* The quad port cards have bad CIS's, so just look for a
488 window larger than 8 ports and assume it will be right */ 519 window larger than 8 ports and assume it will be right */
@@ -497,14 +528,14 @@ static int multi_config(dev_link_t * link)
497 if (i == CS_SUCCESS) 528 if (i == CS_SUCCESS)
498 break; 529 break;
499 } 530 }
500 i = next_tuple(handle, &tuple, &parse); 531 i = next_tuple(handle, tuple, parse);
501 } 532 }
502 533
503 /* If that didn't work, look for two windows */ 534 /* If that didn't work, look for two windows */
504 if (i != CS_SUCCESS) { 535 if (i != CS_SUCCESS) {
505 link->io.NumPorts1 = link->io.NumPorts2 = 8; 536 link->io.NumPorts1 = link->io.NumPorts2 = 8;
506 info->multi = 2; 537 info->multi = 2;
507 i = first_tuple(handle, &tuple, &parse); 538 i = first_tuple(handle, tuple, parse);
508 while (i != CS_NO_MORE_ITEMS) { 539 while (i != CS_NO_MORE_ITEMS) {
509 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) { 540 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) {
510 link->conf.ConfigIndex = cf->index; 541 link->conf.ConfigIndex = cf->index;
@@ -517,13 +548,14 @@ static int multi_config(dev_link_t * link)
517 if (i == CS_SUCCESS) 548 if (i == CS_SUCCESS)
518 break; 549 break;
519 } 550 }
520 i = next_tuple(handle, &tuple, &parse); 551 i = next_tuple(handle, tuple, parse);
521 } 552 }
522 } 553 }
523 554
524 if (i != CS_SUCCESS) { 555 if (i != CS_SUCCESS) {
525 cs_error(link->handle, RequestIO, i); 556 cs_error(link->handle, RequestIO, i);
526 return -1; 557 rc = -1;
558 goto free_cfg_mem;
527 } 559 }
528 560
529 i = pcmcia_request_irq(link->handle, &link->irq); 561 i = pcmcia_request_irq(link->handle, &link->irq);
@@ -541,7 +573,8 @@ static int multi_config(dev_link_t * link)
541 i = pcmcia_request_configuration(link->handle, &link->conf); 573 i = pcmcia_request_configuration(link->handle, &link->conf);
542 if (i != CS_SUCCESS) { 574 if (i != CS_SUCCESS) {
543 cs_error(link->handle, RequestConfiguration, i); 575 cs_error(link->handle, RequestConfiguration, i);
544 return -1; 576 rc = -1;
577 goto free_cfg_mem;
545 } 578 }
546 579
547 /* The Oxford Semiconductor OXCF950 cards are in fact single-port: 580 /* The Oxford Semiconductor OXCF950 cards are in fact single-port:
@@ -554,17 +587,23 @@ static int multi_config(dev_link_t * link)
554 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 587 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
555 outb(12, base2 + 1); 588 outb(12, base2 + 1);
556 } 589 }
557 return 0; 590 rc = 0;
591 goto free_cfg_mem;
558 } 592 }
559 593
560 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 594 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
561 /* The Nokia cards are not really multiport cards */ 595 /* The Nokia cards are not really multiport cards */
562 if (info->manfid == MANFID_NOKIA) 596 if (info->manfid == MANFID_NOKIA) {
563 return 0; 597 rc = 0;
598 goto free_cfg_mem;
599 }
564 for (i = 0; i < info->multi - 1; i++) 600 for (i = 0; i < info->multi - 1; i++)
565 setup_serial(handle, info, base2 + (8 * i), link->irq.AssignedIRQ); 601 setup_serial(handle, info, base2 + (8 * i),
566 602 link->irq.AssignedIRQ);
567 return 0; 603 rc = 0;
604free_cfg_mem:
605 kfree(cfg_mem);
606 return rc;
568} 607}
569 608
570/*====================================================================== 609/*======================================================================
@@ -579,39 +618,49 @@ void serial_config(dev_link_t * link)
579{ 618{
580 client_handle_t handle = link->handle; 619 client_handle_t handle = link->handle;
581 struct serial_info *info = link->priv; 620 struct serial_info *info = link->priv;
582 tuple_t tuple; 621 struct serial_cfg_mem *cfg_mem;
583 u_short buf[128]; 622 tuple_t *tuple;
584 cisparse_t parse; 623 u_char *buf;
585 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 624 cisparse_t *parse;
625 cistpl_cftable_entry_t *cf;
586 int i, last_ret, last_fn; 626 int i, last_ret, last_fn;
587 627
588 DEBUG(0, "serial_config(0x%p)\n", link); 628 DEBUG(0, "serial_config(0x%p)\n", link);
589 629
590 tuple.TupleData = (cisdata_t *) buf; 630 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
591 tuple.TupleOffset = 0; 631 if (!cfg_mem)
592 tuple.TupleDataMax = 255; 632 goto failed;
593 tuple.Attributes = 0; 633
634 tuple = &cfg_mem->tuple;
635 parse = &cfg_mem->parse;
636 cf = &parse->cftable_entry;
637 buf = cfg_mem->buf;
638
639 tuple->TupleData = (cisdata_t *) buf;
640 tuple->TupleOffset = 0;
641 tuple->TupleDataMax = 255;
642 tuple->Attributes = 0;
594 /* Get configuration register information */ 643 /* Get configuration register information */
595 tuple.DesiredTuple = CISTPL_CONFIG; 644 tuple->DesiredTuple = CISTPL_CONFIG;
596 last_ret = first_tuple(handle, &tuple, &parse); 645 last_ret = first_tuple(handle, tuple, parse);
597 if (last_ret != CS_SUCCESS) { 646 if (last_ret != CS_SUCCESS) {
598 last_fn = ParseTuple; 647 last_fn = ParseTuple;
599 goto cs_failed; 648 goto cs_failed;
600 } 649 }
601 link->conf.ConfigBase = parse.config.base; 650 link->conf.ConfigBase = parse->config.base;
602 link->conf.Present = parse.config.rmask[0]; 651 link->conf.Present = parse->config.rmask[0];
603 652
604 /* Configure card */ 653 /* Configure card */
605 link->state |= DEV_CONFIG; 654 link->state |= DEV_CONFIG;
606 655
607 /* Is this a compliant multifunction card? */ 656 /* Is this a compliant multifunction card? */
608 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 657 tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
609 tuple.Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; 658 tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
610 info->multi = (first_tuple(handle, &tuple, &parse) == CS_SUCCESS); 659 info->multi = (first_tuple(handle, tuple, parse) == CS_SUCCESS);
611 660
612 /* Is this a multiport card? */ 661 /* Is this a multiport card? */
613 tuple.DesiredTuple = CISTPL_MANFID; 662 tuple->DesiredTuple = CISTPL_MANFID;
614 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 663 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
615 info->manfid = le16_to_cpu(buf[0]); 664 info->manfid = le16_to_cpu(buf[0]);
616 for (i = 0; i < MULTI_COUNT; i++) 665 for (i = 0; i < MULTI_COUNT; i++)
617 if ((info->manfid == multi_id[i].manfid) && 666 if ((info->manfid == multi_id[i].manfid) &&
@@ -623,13 +672,13 @@ void serial_config(dev_link_t * link)
623 672
624 /* Another check for dual-serial cards: look for either serial or 673 /* Another check for dual-serial cards: look for either serial or
625 multifunction cards that ask for appropriate IO port ranges */ 674 multifunction cards that ask for appropriate IO port ranges */
626 tuple.DesiredTuple = CISTPL_FUNCID; 675 tuple->DesiredTuple = CISTPL_FUNCID;
627 if ((info->multi == 0) && 676 if ((info->multi == 0) &&
628 ((first_tuple(handle, &tuple, &parse) != CS_SUCCESS) || 677 ((first_tuple(handle, tuple, parse) != CS_SUCCESS) ||
629 (parse.funcid.func == CISTPL_FUNCID_MULTI) || 678 (parse->funcid.func == CISTPL_FUNCID_MULTI) ||
630 (parse.funcid.func == CISTPL_FUNCID_SERIAL))) { 679 (parse->funcid.func == CISTPL_FUNCID_SERIAL))) {
631 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 680 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
632 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 681 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
633 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 682 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0))
634 info->multi = cf->io.win[0].len >> 3; 683 info->multi = cf->io.win[0].len >> 3;
635 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && 684 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) &&
@@ -664,6 +713,7 @@ void serial_config(dev_link_t * link)
664 713
665 link->dev = &info->node[0]; 714 link->dev = &info->node[0];
666 link->state &= ~DEV_CONFIG_PENDING; 715 link->state &= ~DEV_CONFIG_PENDING;
716 kfree(cfg_mem);
667 return; 717 return;
668 718
669 cs_failed: 719 cs_failed:
@@ -671,6 +721,7 @@ void serial_config(dev_link_t * link)
671 failed: 721 failed:
672 serial_remove(link); 722 serial_remove(link);
673 link->state &= ~DEV_CONFIG_PENDING; 723 link->state &= ~DEV_CONFIG_PENDING;
724 kfree(cfg_mem);
674} 725}
675 726
676/*====================================================================== 727/*======================================================================
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 4ce3a41f1611..85cfa08d3bad 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -162,7 +162,7 @@ lh7a40xuart_rx_chars (struct uart_port* port)
162 flag = TTY_NORMAL; 162 flag = TTY_NORMAL;
163 ++port->icount.rx; 163 ++port->icount.rx;
164 164
165 if (data & RxError) { /* Quick check, short-circuit */ 165 if (unlikely(data & RxError)) { /* Quick check, short-circuit */
166 if (data & RxBreak) { 166 if (data & RxBreak) {
167 data &= ~(RxFramingError | RxParityError); 167 data &= ~(RxFramingError | RxParityError);
168 ++port->icount.brk; 168 ++port->icount.brk;
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index ffaab9b90fd8..fee6418e84c4 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -787,7 +787,7 @@ static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port)
787 787
788static void sn_sal_console_write(struct console *, const char *, unsigned); 788static void sn_sal_console_write(struct console *, const char *, unsigned);
789static int __init sn_sal_console_setup(struct console *, char *); 789static int __init sn_sal_console_setup(struct console *, char *);
790extern struct uart_driver sal_console_uart; 790static struct uart_driver sal_console_uart;
791extern struct tty_driver *uart_console_device(struct console *, int *); 791extern struct tty_driver *uart_console_device(struct console *, int *);
792 792
793static struct console sal_console = { 793static struct console sal_console = {
@@ -801,7 +801,7 @@ static struct console sal_console = {
801 801
802#define SAL_CONSOLE &sal_console 802#define SAL_CONSOLE &sal_console
803 803
804struct uart_driver sal_console_uart = { 804static struct uart_driver sal_console_uart = {
805 .owner = THIS_MODULE, 805 .owner = THIS_MODULE,
806 .driver_name = "sn_console", 806 .driver_name = "sn_console",
807 .dev_name = DEVICE_NAME, 807 .dev_name = DEVICE_NAME,
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index 8caaf2e5e47c..39b788d95e39 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -682,7 +682,8 @@ static void calc_ebrg(int baud, int *n_ret, int *m_ret)
682 682
683/* Internal routine, port->lock is held and local interrupts are disabled. */ 683/* Internal routine, port->lock is held and local interrupts are disabled. */
684static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag, 684static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag,
685 unsigned int iflag, int baud) 685 unsigned int iflag, unsigned int baud,
686 unsigned int quot)
686{ 687{
687 unsigned int ebrg; 688 unsigned int ebrg;
688 unsigned char dafo; 689 unsigned char dafo;
@@ -766,6 +767,9 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
766 up->port.ignore_status_mask |= (SAB82532_ISR0_RPF | 767 up->port.ignore_status_mask |= (SAB82532_ISR0_RPF |
767 SAB82532_ISR0_TCD); 768 SAB82532_ISR0_TCD);
768 769
770 uart_update_timeout(&up->port, cflag,
771 (up->port.uartclk / (16 * quot)));
772
769 /* Now bang the new settings into the chip. */ 773 /* Now bang the new settings into the chip. */
770 sunsab_cec_wait(up); 774 sunsab_cec_wait(up);
771 sunsab_tec_wait(up); 775 sunsab_tec_wait(up);
@@ -784,10 +788,11 @@ static void sunsab_set_termios(struct uart_port *port, struct termios *termios,
784{ 788{
785 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 789 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
786 unsigned long flags; 790 unsigned long flags;
787 int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); 791 unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
792 unsigned int quot = uart_get_divisor(port, baud);
788 793
789 spin_lock_irqsave(&up->port.lock, flags); 794 spin_lock_irqsave(&up->port.lock, flags);
790 sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud); 795 sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud, quot);
791 spin_unlock_irqrestore(&up->port.lock, flags); 796 spin_unlock_irqrestore(&up->port.lock, flags);
792} 797}
793 798
@@ -880,7 +885,7 @@ static int sunsab_console_setup(struct console *con, char *options)
880{ 885{
881 struct uart_sunsab_port *up = &sunsab_ports[con->index]; 886 struct uart_sunsab_port *up = &sunsab_ports[con->index];
882 unsigned long flags; 887 unsigned long flags;
883 int baud; 888 unsigned int baud, quot;
884 889
885 printk("Console: ttyS%d (SAB82532)\n", 890 printk("Console: ttyS%d (SAB82532)\n",
886 (sunsab_reg.minor - 64) + con->index); 891 (sunsab_reg.minor - 64) + con->index);
@@ -926,7 +931,8 @@ static int sunsab_console_setup(struct console *con, char *options)
926 SAB82532_IMR1_XPR; 931 SAB82532_IMR1_XPR;
927 writeb(up->interrupt_mask1, &up->regs->w.imr1); 932 writeb(up->interrupt_mask1, &up->regs->w.imr1);
928 933
929 sunsab_convert_to_sab(up, con->cflag, 0, baud); 934 quot = uart_get_divisor(&up->port, baud);
935 sunsab_convert_to_sab(up, con->cflag, 0, baud, quot);
930 sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); 936 sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS);
931 937
932 spin_unlock_irqrestore(&up->port.lock, flags); 938 spin_unlock_irqrestore(&up->port.lock, flags);
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 23d19d394320..ddc97c905e14 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1285,6 +1285,7 @@ static struct uart_driver sunsu_reg = {
1285 1285
1286static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) 1286static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1287{ 1287{
1288 int quot, baud;
1288#ifdef CONFIG_SERIO 1289#ifdef CONFIG_SERIO
1289 struct serio *serio; 1290 struct serio *serio;
1290#endif 1291#endif
@@ -1293,10 +1294,14 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1293 up->port.type = PORT_UNKNOWN; 1294 up->port.type = PORT_UNKNOWN;
1294 up->port.uartclk = (SU_BASE_BAUD * 16); 1295 up->port.uartclk = (SU_BASE_BAUD * 16);
1295 1296
1296 if (up->su_type == SU_PORT_KBD) 1297 if (up->su_type == SU_PORT_KBD) {
1297 up->cflag = B1200 | CS8 | CLOCAL | CREAD; 1298 up->cflag = B1200 | CS8 | CLOCAL | CREAD;
1298 else 1299 baud = 1200;
1300 } else {
1299 up->cflag = B4800 | CS8 | CLOCAL | CREAD; 1301 up->cflag = B4800 | CS8 | CLOCAL | CREAD;
1302 baud = 4800;
1303 }
1304 quot = up->port.uartclk / (16 * baud);
1300 1305
1301 sunsu_autoconfig(up); 1306 sunsu_autoconfig(up);
1302 if (up->port.type == PORT_UNKNOWN) 1307 if (up->port.type == PORT_UNKNOWN)
@@ -1337,6 +1342,8 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1337 } 1342 }
1338#endif 1343#endif
1339 1344
1345 sunsu_change_speed(&up->port, up->cflag, 0, quot);
1346
1340 sunsu_startup(&up->port); 1347 sunsu_startup(&up->port);
1341 return 0; 1348 return 0;
1342} 1349}
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index 5538756f13ba..d5863b8b56ee 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -41,9 +41,6 @@
41 * 41 *
42 ***************************************************************************/ 42 ***************************************************************************/
43 43
44static char ixj_c_rcsid[] = "$Id: ixj.c,v 4.7 2001/08/13 06:19:33 craigs Exp $";
45static char ixj_c_revision[] = "$Revision: 4.7 $";
46
47/* 44/*
48 * $Log: ixj.c,v $ 45 * $Log: ixj.c,v $
49 * 46 *
@@ -6172,8 +6169,14 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd,
6172 retval = j->serial; 6169 retval = j->serial;
6173 break; 6170 break;
6174 case IXJCTL_VERSION: 6171 case IXJCTL_VERSION:
6175 if (copy_to_user(argp, ixj_c_revision, strlen(ixj_c_revision))) 6172 {
6176 retval = -EFAULT; 6173 char arg_str[100];
6174 snprintf(arg_str, sizeof(arg_str),
6175 "\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
6176 IXJ_VER_MINOR, IXJ_BLD_VER);
6177 if (copy_to_user(argp, arg_str, strlen(arg_str)))
6178 retval = -EFAULT;
6179 }
6177 break; 6180 break;
6178 case PHONE_RING_CADENCE: 6181 case PHONE_RING_CADENCE:
6179 j->ring_cadence = arg; 6182 j->ring_cadence = arg;
@@ -7168,9 +7171,6 @@ static int ixj_get_status_proc(char *buf)
7168 int cnt; 7171 int cnt;
7169 IXJ *j; 7172 IXJ *j;
7170 len = 0; 7173 len = 0;
7171 len += sprintf(buf + len, "%s", ixj_c_rcsid);
7172 len += sprintf(buf + len, "\n%s", ixj_h_rcsid);
7173 len += sprintf(buf + len, "\n%s", ixjuser_h_rcsid);
7174 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER); 7174 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
7175 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ)); 7175 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
7176 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS)); 7176 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
@@ -7790,7 +7790,7 @@ static int __init ixj_init(void)
7790 if ((probe = ixj_probe_pci(&cnt)) < 0) { 7790 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7791 return probe; 7791 return probe;
7792 } 7792 }
7793 printk("%s\n", ixj_c_rcsid); 7793 printk(KERN_INFO "ixj driver initialized.\n");
7794 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL); 7794 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
7795 return probe; 7795 return probe;
7796} 7796}
diff --git a/drivers/telephony/ixj.h b/drivers/telephony/ixj.h
index 143818a56121..51e3f7f6597b 100644
--- a/drivers/telephony/ixj.h
+++ b/drivers/telephony/ixj.h
@@ -38,8 +38,6 @@
38 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 38 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
39 * 39 *
40 *****************************************************************************/ 40 *****************************************************************************/
41static char ixj_h_rcsid[] = "$Id: ixj.h,v 4.1 2001/08/04 14:49:27 craigs Exp $";
42
43#define IXJ_VERSION 3031 41#define IXJ_VERSION 3031
44 42
45#include <linux/version.h> 43#include <linux/version.h>
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index e12c5be1e0a3..f50aaf25c98e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -431,7 +431,7 @@ nomem:
431 * (2) error, where io->status is a negative errno value. The number 431 * (2) error, where io->status is a negative errno value. The number
432 * of io->bytes transferred before the error is usually less 432 * of io->bytes transferred before the error is usually less
433 * than requested, and can be nonzero. 433 * than requested, and can be nonzero.
434 * (3) cancelation, a type of error with status -ECONNRESET that 434 * (3) cancellation, a type of error with status -ECONNRESET that
435 * is initiated by usb_sg_cancel(). 435 * is initiated by usb_sg_cancel().
436 * 436 *
437 * When this function returns, all memory allocated through usb_sg_init() or 437 * When this function returns, all memory allocated through usb_sg_init() or
@@ -1282,7 +1282,7 @@ static void release_interface(struct device *dev)
1282 * bus rwsem; usb device driver probe() methods cannot use this routine. 1282 * bus rwsem; usb device driver probe() methods cannot use this routine.
1283 * 1283 *
1284 * Returns zero on success, or else the status code returned by the 1284 * Returns zero on success, or else the status code returned by the
1285 * underlying call that failed. On succesful completion, each interface 1285 * underlying call that failed. On successful completion, each interface
1286 * in the original device configuration has been destroyed, and each one 1286 * in the original device configuration has been destroyed, and each one
1287 * in the new configuration has been probed by all relevant usb device 1287 * in the new configuration has been probed by all relevant usb device
1288 * drivers currently known to the kernel. 1288 * drivers currently known to the kernel.
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 16972159a57a..0faf18d511de 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -121,7 +121,7 @@ struct urb * usb_get_urb(struct urb *urb)
121 * describing that request to the USB subsystem. Request completion will 121 * describing that request to the USB subsystem. Request completion will
122 * be indicated later, asynchronously, by calling the completion handler. 122 * be indicated later, asynchronously, by calling the completion handler.
123 * The three types of completion are success, error, and unlink 123 * The three types of completion are success, error, and unlink
124 * (a software-induced fault, also called "request cancelation"). 124 * (a software-induced fault, also called "request cancellation").
125 * 125 *
126 * URBs may be submitted in interrupt context. 126 * URBs may be submitted in interrupt context.
127 * 127 *
@@ -170,7 +170,7 @@ struct urb * usb_get_urb(struct urb *urb)
170 * As of Linux 2.6, all USB endpoint transfer queues support depths greater 170 * As of Linux 2.6, all USB endpoint transfer queues support depths greater
171 * than one. This was previously a HCD-specific behavior, except for ISO 171 * than one. This was previously a HCD-specific behavior, except for ISO
172 * transfers. Non-isochronous endpoint queues are inactive during cleanup 172 * transfers. Non-isochronous endpoint queues are inactive during cleanup
173 * after faults (transfer errors or cancelation). 173 * after faults (transfer errors or cancellation).
174 * 174 *
175 * Reserved Bandwidth Transfers: 175 * Reserved Bandwidth Transfers:
176 * 176 *
@@ -395,7 +395,7 @@ int usb_submit_urb(struct urb *urb, int mem_flags)
395 * 395 *
396 * This routine cancels an in-progress request. URBs complete only 396 * This routine cancels an in-progress request. URBs complete only
397 * once per submission, and may be canceled only once per submission. 397 * once per submission, and may be canceled only once per submission.
398 * Successful cancelation means the requests's completion handler will 398 * Successful cancellation means the requests's completion handler will
399 * be called with a status code indicating that the request has been 399 * be called with a status code indicating that the request has been
400 * canceled (rather than any other code) and will quickly be removed 400 * canceled (rather than any other code) and will quickly be removed
401 * from host controller data structures. 401 * from host controller data structures.
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index c231b4bef314..25cf7e9eccfa 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -611,11 +611,10 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
611 611
612 if (add_hotplug_env_var(envp, num_envp, &i, 612 if (add_hotplug_env_var(envp, num_envp, &i,
613 buffer, buffer_size, &length, 613 buffer, buffer_size, &length,
614 "MODALIAS=usb:v%04Xp%04Xdl%04Xdh%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 614 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
615 le16_to_cpu(usb_dev->descriptor.idVendor), 615 le16_to_cpu(usb_dev->descriptor.idVendor),
616 le16_to_cpu(usb_dev->descriptor.idProduct), 616 le16_to_cpu(usb_dev->descriptor.idProduct),
617 le16_to_cpu(usb_dev->descriptor.bcdDevice), 617 le16_to_cpu(usb_dev->descriptor.bcdDevice),
618 le16_to_cpu(usb_dev->descriptor.bcdDevice),
619 usb_dev->descriptor.bDeviceClass, 618 usb_dev->descriptor.bDeviceClass,
620 usb_dev->descriptor.bDeviceSubClass, 619 usb_dev->descriptor.bDeviceSubClass,
621 usb_dev->descriptor.bDeviceProtocol, 620 usb_dev->descriptor.bDeviceProtocol,
@@ -626,11 +625,10 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
626 } else { 625 } else {
627 if (add_hotplug_env_var(envp, num_envp, &i, 626 if (add_hotplug_env_var(envp, num_envp, &i,
628 buffer, buffer_size, &length, 627 buffer, buffer_size, &length,
629 "MODALIAS=usb:v%04Xp%04Xdl%04Xdh%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*", 628 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*",
630 le16_to_cpu(usb_dev->descriptor.idVendor), 629 le16_to_cpu(usb_dev->descriptor.idVendor),
631 le16_to_cpu(usb_dev->descriptor.idProduct), 630 le16_to_cpu(usb_dev->descriptor.idProduct),
632 le16_to_cpu(usb_dev->descriptor.bcdDevice), 631 le16_to_cpu(usb_dev->descriptor.bcdDevice),
633 le16_to_cpu(usb_dev->descriptor.bcdDevice),
634 usb_dev->descriptor.bDeviceClass, 632 usb_dev->descriptor.bDeviceClass,
635 usb_dev->descriptor.bDeviceSubClass, 633 usb_dev->descriptor.bDeviceSubClass,
636 usb_dev->descriptor.bDeviceProtocol)) 634 usb_dev->descriptor.bDeviceProtocol))
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3993156c2e82..3f783cbdc7c3 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -569,7 +569,7 @@ static const struct usb_cdc_ether_desc ether_desc = {
569 569
570/* include the status endpoint if we can, even where it's optional. 570/* include the status endpoint if we can, even where it's optional.
571 * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one 571 * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one
572 * packet, to simplify cancelation; and a big transfer interval, to 572 * packet, to simplify cancellation; and a big transfer interval, to
573 * waste less bandwidth. 573 * waste less bandwidth.
574 * 574 *
575 * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even 575 * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 2cff67ccce45..1e5e6ddef787 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -275,7 +275,7 @@ static const char *CHIP;
275 * 275 *
276 * After opening, configure non-control endpoints. Then use normal 276 * After opening, configure non-control endpoints. Then use normal
277 * stream read() and write() requests; and maybe ioctl() to get more 277 * stream read() and write() requests; and maybe ioctl() to get more
278 * precise FIFO status when recovering from cancelation. 278 * precise FIFO status when recovering from cancellation.
279 */ 279 */
280 280
281static void epio_complete (struct usb_ep *ep, struct usb_request *req) 281static void epio_complete (struct usb_ep *ep, struct usb_request *req)
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 0def9f70e889..df75ab65a5ec 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -705,7 +705,7 @@ void nuke(struct lh7a40x_ep *ep, int status)
705 done(ep, req, status); 705 done(ep, req, status);
706 } 706 }
707 707
708 /* Disable IRQ if EP is enabled (has decriptor) */ 708 /* Disable IRQ if EP is enabled (has descriptor) */
709 if (ep->desc) 709 if (ep->desc)
710 pio_irq_disable(ep_index(ep)); 710 pio_irq_disable(ep_index(ep));
711} 711}
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index f1762ed6db63..4d591c764e38 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -240,7 +240,7 @@ struct gs_dev {
240 struct usb_ep *dev_notify_ep; /* address of notify endpoint */ 240 struct usb_ep *dev_notify_ep; /* address of notify endpoint */
241 struct usb_ep *dev_in_ep; /* address of in endpoint */ 241 struct usb_ep *dev_in_ep; /* address of in endpoint */
242 struct usb_ep *dev_out_ep; /* address of out endpoint */ 242 struct usb_ep *dev_out_ep; /* address of out endpoint */
243 struct usb_endpoint_descriptor /* desciptor of notify ep */ 243 struct usb_endpoint_descriptor /* descriptor of notify ep */
244 *dev_notify_ep_desc; 244 *dev_notify_ep_desc;
245 struct usb_endpoint_descriptor /* descriptor of in endpoint */ 245 struct usb_endpoint_descriptor /* descriptor of in endpoint */
246 *dev_in_ep_desc; 246 *dev_in_ep_desc;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 84d2b93aca37..bc69bd7acebe 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -346,6 +346,22 @@ ehci_reboot (struct notifier_block *self, unsigned long code, void *null)
346 return 0; 346 return 0;
347} 347}
348 348
349static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
350{
351 unsigned port;
352
353 if (!HCS_PPC (ehci->hcs_params))
354 return;
355
356 ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
357 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
358 (void) ehci_hub_control(ehci_to_hcd(ehci),
359 is_on ? SetPortFeature : ClearPortFeature,
360 USB_PORT_FEAT_POWER,
361 port--, NULL, 0);
362 msleep(20);
363}
364
349 365
350/* called by khubd or root hub init threads */ 366/* called by khubd or root hub init threads */
351 367
@@ -362,8 +378,10 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
362 dbg_hcs_params (ehci, "reset"); 378 dbg_hcs_params (ehci, "reset");
363 dbg_hcc_params (ehci, "reset"); 379 dbg_hcc_params (ehci, "reset");
364 380
381 /* cache this readonly data; minimize chip reads */
382 ehci->hcs_params = readl (&ehci->caps->hcs_params);
383
365#ifdef CONFIG_PCI 384#ifdef CONFIG_PCI
366 /* EHCI 0.96 and later may have "extended capabilities" */
367 if (hcd->self.controller->bus == &pci_bus_type) { 385 if (hcd->self.controller->bus == &pci_bus_type) {
368 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 386 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
369 387
@@ -383,9 +401,30 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
383 break; 401 break;
384 } 402 }
385 403
404 /* optional debug port, normally in the first BAR */
405 temp = pci_find_capability (pdev, 0x0a);
406 if (temp) {
407 pci_read_config_dword(pdev, temp, &temp);
408 temp >>= 16;
409 if ((temp & (3 << 13)) == (1 << 13)) {
410 temp &= 0x1fff;
411 ehci->debug = hcd->regs + temp;
412 temp = readl (&ehci->debug->control);
413 ehci_info (ehci, "debug port %d%s\n",
414 HCS_DEBUG_PORT(ehci->hcs_params),
415 (temp & DBGP_ENABLED)
416 ? " IN USE"
417 : "");
418 if (!(temp & DBGP_ENABLED))
419 ehci->debug = NULL;
420 }
421 }
422
386 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); 423 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
387 } else 424 } else
388 temp = 0; 425 temp = 0;
426
427 /* EHCI 0.96 and later may have "extended capabilities" */
389 while (temp && count--) { 428 while (temp && count--) {
390 u32 cap; 429 u32 cap;
391 430
@@ -414,8 +453,7 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
414 ehci_reset (ehci); 453 ehci_reset (ehci);
415#endif 454#endif
416 455
417 /* cache this readonly data; minimize PCI reads */ 456 ehci_port_power (ehci, 0);
418 ehci->hcs_params = readl (&ehci->caps->hcs_params);
419 457
420 /* at least the Genesys GL880S needs fixup here */ 458 /* at least the Genesys GL880S needs fixup here */
421 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 459 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
@@ -657,16 +695,11 @@ done2:
657static void ehci_stop (struct usb_hcd *hcd) 695static void ehci_stop (struct usb_hcd *hcd)
658{ 696{
659 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 697 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
660 u8 rh_ports, port;
661 698
662 ehci_dbg (ehci, "stop\n"); 699 ehci_dbg (ehci, "stop\n");
663 700
664 /* Turn off port power on all root hub ports. */ 701 /* Turn off port power on all root hub ports. */
665 rh_ports = HCS_N_PORTS (ehci->hcs_params); 702 ehci_port_power (ehci, 0);
666 for (port = 1; port <= rh_ports; port++)
667 (void) ehci_hub_control(hcd,
668 ClearPortFeature, USB_PORT_FEAT_POWER,
669 port, NULL, 0);
670 703
671 /* no more interrupts ... */ 704 /* no more interrupts ... */
672 del_timer_sync (&ehci->watchdog); 705 del_timer_sync (&ehci->watchdog);
@@ -748,7 +781,6 @@ static int ehci_resume (struct usb_hcd *hcd)
748 unsigned port; 781 unsigned port;
749 struct usb_device *root = hcd->self.root_hub; 782 struct usb_device *root = hcd->self.root_hub;
750 int retval = -EINVAL; 783 int retval = -EINVAL;
751 int powerup = 0;
752 784
753 // maybe restore (PCI) FLADJ 785 // maybe restore (PCI) FLADJ
754 786
@@ -766,8 +798,6 @@ static int ehci_resume (struct usb_hcd *hcd)
766 up (&hcd->self.root_hub->serialize); 798 up (&hcd->self.root_hub->serialize);
767 break; 799 break;
768 } 800 }
769 if ((status & PORT_POWER) == 0)
770 powerup = 1;
771 if (!root->children [port]) 801 if (!root->children [port])
772 continue; 802 continue;
773 dbg_port (ehci, __FUNCTION__, port + 1, status); 803 dbg_port (ehci, __FUNCTION__, port + 1, status);
@@ -794,16 +824,9 @@ static int ehci_resume (struct usb_hcd *hcd)
794 retval = ehci_start (hcd); 824 retval = ehci_start (hcd);
795 825
796 /* here we "know" root ports should always stay powered; 826 /* here we "know" root ports should always stay powered;
797 * but some controllers may lost all power. 827 * but some controllers may lose all power.
798 */ 828 */
799 if (powerup) { 829 ehci_port_power (ehci, 1);
800 ehci_dbg (ehci, "...powerup ports...\n");
801 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
802 (void) ehci_hub_control(hcd,
803 SetPortFeature, USB_PORT_FEAT_POWER,
804 port--, NULL, 0);
805 msleep(20);
806 }
807 } 830 }
808 831
809 return retval; 832 return retval;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 2373537fabed..02fefab3501e 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -281,6 +281,8 @@ ehci_hub_descriptor (
281 temp = 0x0008; /* per-port overcurrent reporting */ 281 temp = 0x0008; /* per-port overcurrent reporting */
282 if (HCS_PPC (ehci->hcs_params)) 282 if (HCS_PPC (ehci->hcs_params))
283 temp |= 0x0001; /* per-port power control */ 283 temp |= 0x0001; /* per-port power control */
284 else
285 temp |= 0x0002; /* no power switching */
284#if 0 286#if 0
285// re-enable when we support USB_PORT_FEAT_INDICATOR below. 287// re-enable when we support USB_PORT_FEAT_INDICATOR below.
286 if (HCS_INDICATOR (ehci->hcs_params)) 288 if (HCS_INDICATOR (ehci->hcs_params))
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index e763a8399a75..4df498231752 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -47,6 +47,12 @@ struct ehci_stats {
47#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */ 47#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */
48 48
49struct ehci_hcd { /* one per controller */ 49struct ehci_hcd { /* one per controller */
50 /* glue to PCI and HCD framework */
51 struct ehci_caps __iomem *caps;
52 struct ehci_regs __iomem *regs;
53 struct ehci_dbg_port __iomem *debug;
54
55 __u32 hcs_params; /* cached register copy */
50 spinlock_t lock; 56 spinlock_t lock;
51 57
52 /* async schedule support */ 58 /* async schedule support */
@@ -84,11 +90,6 @@ struct ehci_hcd { /* one per controller */
84 90
85 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */ 91 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */
86 92
87 /* glue to PCI and HCD framework */
88 struct ehci_caps __iomem *caps;
89 struct ehci_regs __iomem *regs;
90 __u32 hcs_params; /* cached register copy */
91
92 /* irq statistics */ 93 /* irq statistics */
93#ifdef EHCI_STATS 94#ifdef EHCI_STATS
94 struct ehci_stats stats; 95 struct ehci_stats stats;
@@ -165,7 +166,7 @@ struct ehci_caps {
165 /* these fields are specified as 8 and 16 bit registers, 166 /* these fields are specified as 8 and 16 bit registers,
166 * but some hosts can't perform 8 or 16 bit PCI accesses. 167 * but some hosts can't perform 8 or 16 bit PCI accesses.
167 */ 168 */
168 u32 hc_capbase; 169 u32 hc_capbase;
169#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ 170#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
170#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */ 171#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
171 u32 hcs_params; /* HCSPARAMS - offset 0x4 */ 172 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
@@ -273,7 +274,7 @@ struct ehci_dbg_port {
273#define DBGP_ENABLED (1<<28) 274#define DBGP_ENABLED (1<<28)
274#define DBGP_DONE (1<<16) 275#define DBGP_DONE (1<<16)
275#define DBGP_INUSE (1<<10) 276#define DBGP_INUSE (1<<10)
276#define DBGP_ERRCODE(x) (((x)>>7)&0x0f) 277#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
277# define DBGP_ERR_BAD 1 278# define DBGP_ERR_BAD 1
278# define DBGP_ERR_SIGNAL 2 279# define DBGP_ERR_SIGNAL 2
279#define DBGP_ERROR (1<<6) 280#define DBGP_ERROR (1<<6)
@@ -282,11 +283,11 @@ struct ehci_dbg_port {
282#define DBGP_LEN(x) (((x)>>0)&0x0f) 283#define DBGP_LEN(x) (((x)>>0)&0x0f)
283 u32 pids; 284 u32 pids;
284#define DBGP_PID_GET(x) (((x)>>16)&0xff) 285#define DBGP_PID_GET(x) (((x)>>16)&0xff)
285#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok)); 286#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok))
286 u32 data03; 287 u32 data03;
287 u32 data47; 288 u32 data47;
288 u32 address; 289 u32 address;
289#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep)); 290#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep))
290} __attribute__ ((packed)); 291} __attribute__ ((packed));
291 292
292/*-------------------------------------------------------------------------*/ 293/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 376f8a034f65..d9883d774d3a 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -4329,7 +4329,7 @@ static int __init etrax_usb_hc_init(void)
4329 bus->bus_name="ETRAX 100LX"; 4329 bus->bus_name="ETRAX 100LX";
4330 bus->hcpriv = hc; 4330 bus->hcpriv = hc;
4331 4331
4332 /* Initalize RH to the default address. 4332 /* Initialize RH to the default address.
4333 And make sure that we have no status change indication */ 4333 And make sure that we have no status change indication */
4334 hc->rh.numports = 2; /* The RH has two ports */ 4334 hc->rh.numports = 2; /* The RH has two ports */
4335 hc->rh.devnum = 1; 4335 hc->rh.devnum = 1;
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index d309e292198e..a374b7692073 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -134,7 +134,7 @@ static void port_power(struct sl811 *sl811, int is_on)
134 134
135/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue, 135/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue,
136 * and may start I/O. Endpoint queues are scanned during completion irq 136 * and may start I/O. Endpoint queues are scanned during completion irq
137 * handlers (one per packet: ACK, NAK, faults, etc) and urb cancelation. 137 * handlers (one per packet: ACK, NAK, faults, etc) and urb cancellation.
138 * 138 *
139 * Using an external DMA engine to copy a packet at a time could work, 139 * Using an external DMA engine to copy a packet at a time could work,
140 * though setup/teardown costs may be too big to make it worthwhile. 140 * though setup/teardown costs may be too big to make it worthwhile.
@@ -738,7 +738,7 @@ retry:
738 } 738 }
739#endif 739#endif
740 740
741 /* port status seems wierd until after reset, so 741 /* port status seems weird until after reset, so
742 * force the reset and make khubd clean up later. 742 * force the reset and make khubd clean up later.
743 */ 743 */
744 sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION) 744 sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION)
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 5791723e6083..a330a4b50e16 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -23,7 +23,7 @@
23 * 23 *
24 * 24 *
25 * The driver brings the USB functions of the MDC800 to Linux. 25 * The driver brings the USB functions of the MDC800 to Linux.
26 * To use the Camera you must support the USB Protocoll of the camera 26 * To use the Camera you must support the USB Protocol of the camera
27 * to the Kernel Node. 27 * to the Kernel Node.
28 * The Driver uses a misc device Node. Create it with : 28 * The Driver uses a misc device Node. Create it with :
29 * mknod /dev/mustek c 180 32 29 * mknod /dev/mustek c 180 32
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index cab89a970c7f..7d21a4f5c425 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -335,7 +335,7 @@ static int mts_scsi_abort (Scsi_Cmnd *srb)
335 335
336 mts_urb_abort(desc); 336 mts_urb_abort(desc);
337 337
338 return FAILURE; 338 return FAILED;
339} 339}
340 340
341static int mts_scsi_host_reset (Scsi_Cmnd *srb) 341static int mts_scsi_host_reset (Scsi_Cmnd *srb)
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 2d76be62f4e0..94ce2a9ad50f 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -386,7 +386,7 @@ static int aiptek_convert_from_2s_complement(unsigned char c)
386 * convention above.) I therefore have taken over REL_MISC and ABS_MISC 386 * convention above.) I therefore have taken over REL_MISC and ABS_MISC
387 * (for relative and absolute reports, respectively) for communicating 387 * (for relative and absolute reports, respectively) for communicating
388 * Proximity. Why two events? I thought it interesting to know if the 388 * Proximity. Why two events? I thought it interesting to know if the
389 * Proximity event occured while the tablet was in absolute or relative 389 * Proximity event occurred while the tablet was in absolute or relative
390 * mode. 390 * mode.
391 * 391 *
392 * Other tablets use the notion of a certain minimum stylus pressure 392 * Other tablets use the notion of a certain minimum stylus pressure
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 355add5c29f5..860df26323b1 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -619,7 +619,7 @@ static void ati_remote_delete(struct ati_remote *ati_remote)
619 619
620 if (ati_remote->outbuf) 620 if (ati_remote->outbuf)
621 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 621 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
622 ati_remote->inbuf, ati_remote->outbuf_dma); 622 ati_remote->outbuf, ati_remote->outbuf_dma);
623 623
624 if (ati_remote->irq_urb) 624 if (ati_remote->irq_urb)
625 usb_free_urb(ati_remote->irq_urb); 625 usb_free_urb(ati_remote->irq_urb);
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 6b45a66d58c1..ab1a2a30ce7c 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -32,7 +32,7 @@
32 * Changed reset from standard USB dev reset to vendor reset 32 * Changed reset from standard USB dev reset to vendor reset
33 * Changed data sent to host from compensated to raw coordinates 33 * Changed data sent to host from compensated to raw coordinates
34 * Eliminated vendor/product module params 34 * Eliminated vendor/product module params
35 * Performed multiple successfull tests with an EXII-5010UC 35 * Performed multiple successful tests with an EXII-5010UC
36 * 36 *
37 * 1.5 02/27/2005 ddstreet@ieee.org 37 * 1.5 02/27/2005 ddstreet@ieee.org
38 * Added module parameter to select raw or hw-calibrated coordinate reporting 38 * Added module parameter to select raw or hw-calibrated coordinate reporting
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index 01514b0551b8..7038fb9d1ced 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -133,7 +133,8 @@ resubmit:
133 kbd->usbdev->devpath, i); 133 kbd->usbdev->devpath, i);
134} 134}
135 135
136int usb_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 136static int usb_kbd_event(struct input_dev *dev, unsigned int type,
137 unsigned int code, int value)
137{ 138{
138 struct usb_kbd *kbd = dev->private; 139 struct usb_kbd *kbd = dev->private;
139 140
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index d6051822416e..036c485d1d1e 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -5041,7 +5041,7 @@ ov6xx0_configure(struct usb_ov511 *ov)
5041 { OV511_I2C_BUS, 0x2a, 0x04 }, /* Disable framerate adjust */ 5041 { OV511_I2C_BUS, 0x2a, 0x04 }, /* Disable framerate adjust */
5042// { OV511_I2C_BUS, 0x2b, 0xac }, /* Framerate; Set 2a[7] first */ 5042// { OV511_I2C_BUS, 0x2b, 0xac }, /* Framerate; Set 2a[7] first */
5043 { OV511_I2C_BUS, 0x2d, 0x99 }, 5043 { OV511_I2C_BUS, 0x2d, 0x99 },
5044 { OV511_I2C_BUS, 0x33, 0xa0 }, /* Color Procesing Parameter */ 5044 { OV511_I2C_BUS, 0x33, 0xa0 }, /* Color Processing Parameter */
5045 { OV511_I2C_BUS, 0x34, 0xd2 }, /* Max A/D range */ 5045 { OV511_I2C_BUS, 0x34, 0xd2 }, /* Max A/D range */
5046 { OV511_I2C_BUS, 0x38, 0x8b }, 5046 { OV511_I2C_BUS, 0x38, 0x8b },
5047 { OV511_I2C_BUS, 0x39, 0x40 }, 5047 { OV511_I2C_BUS, 0x39, 0x40 },
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 26aa914bc541..42ec468d52d6 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -418,6 +418,44 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
418 418
419 419
420 420
421static void pwc_set_image_buffer_size(struct pwc_device *pdev)
422{
423 int i, factor = 0, filler = 0;
424
425 /* for PALETTE_YUV420P */
426 switch(pdev->vpalette)
427 {
428 case VIDEO_PALETTE_YUV420P:
429 factor = 6;
430 filler = 128;
431 break;
432 case VIDEO_PALETTE_RAW:
433 factor = 6; /* can be uncompressed YUV420P */
434 filler = 0;
435 break;
436 }
437
438 /* Set sizes in bytes */
439 pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
440 pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
441
442 /* Align offset, or you'll get some very weird results in
443 YUV420 mode... x must be multiple of 4 (to get the Y's in
444 place), and y even (or you'll mixup U & V). This is less of a
445 problem for YUV420P.
446 */
447 pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
448 pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
449
450 /* Fill buffers with gray or black */
451 for (i = 0; i < MAX_IMAGES; i++) {
452 if (pdev->image_ptr[i] != NULL)
453 memset(pdev->image_ptr[i], filler, pdev->view.size);
454 }
455}
456
457
458
421/** 459/**
422 @pdev: device structure 460 @pdev: device structure
423 @width: viewport width 461 @width: viewport width
@@ -475,44 +513,6 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
475} 513}
476 514
477 515
478void pwc_set_image_buffer_size(struct pwc_device *pdev)
479{
480 int i, factor = 0, filler = 0;
481
482 /* for PALETTE_YUV420P */
483 switch(pdev->vpalette)
484 {
485 case VIDEO_PALETTE_YUV420P:
486 factor = 6;
487 filler = 128;
488 break;
489 case VIDEO_PALETTE_RAW:
490 factor = 6; /* can be uncompressed YUV420P */
491 filler = 0;
492 break;
493 }
494
495 /* Set sizes in bytes */
496 pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
497 pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
498
499 /* Align offset, or you'll get some very weird results in
500 YUV420 mode... x must be multiple of 4 (to get the Y's in
501 place), and y even (or you'll mixup U & V). This is less of a
502 problem for YUV420P.
503 */
504 pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
505 pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
506
507 /* Fill buffers with gray or black */
508 for (i = 0; i < MAX_IMAGES; i++) {
509 if (pdev->image_ptr[i] != NULL)
510 memset(pdev->image_ptr[i], filler, pdev->view.size);
511 }
512}
513
514
515
516/* BRIGHTNESS */ 516/* BRIGHTNESS */
517 517
518int pwc_get_brightness(struct pwc_device *pdev) 518int pwc_get_brightness(struct pwc_device *pdev)
@@ -949,7 +949,7 @@ int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
949 return SendControlMsg(SET_STATUS_CTL, LED_FORMATTER, 2); 949 return SendControlMsg(SET_STATUS_CTL, LED_FORMATTER, 2);
950} 950}
951 951
952int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value) 952static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
953{ 953{
954 unsigned char buf[2]; 954 unsigned char buf[2];
955 int ret; 955 int ret;
@@ -1100,7 +1100,7 @@ static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
1100 unsigned char buf[4]; 1100 unsigned char buf[4];
1101 1101
1102 /* set new relative angle; angles are expressed in degrees * 100, 1102 /* set new relative angle; angles are expressed in degrees * 100,
1103 but cam as .5 degree resolution, hence devide by 200. Also 1103 but cam as .5 degree resolution, hence divide by 200. Also
1104 the angle must be multiplied by 64 before it's send to 1104 the angle must be multiplied by 64 before it's send to
1105 the cam (??) 1105 the cam (??)
1106 */ 1106 */
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
index 100a5a4f03a3..cca47f480a8b 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/usb/media/pwc/pwc-if.c
@@ -129,7 +129,7 @@ static int default_mbufs = 2; /* Default number of mmap() buffers */
129 int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX; 129 int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX;
130static int power_save = 0; 130static int power_save = 0;
131static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */ 131static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */
132 int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */ 132static int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */
133static struct { 133static struct {
134 int type; 134 int type;
135 char serial_number[30]; 135 char serial_number[30];
@@ -272,7 +272,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
272 return -ENXIO; 272 return -ENXIO;
273 } 273 }
274#endif 274#endif
275 /* Allocate Isochronuous pipe buffers */ 275 /* Allocate Isochronous pipe buffers */
276 for (i = 0; i < MAX_ISO_BUFS; i++) { 276 for (i = 0; i < MAX_ISO_BUFS; i++) {
277 if (pdev->sbuf[i].data == NULL) { 277 if (pdev->sbuf[i].data == NULL) {
278 kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL); 278 kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL);
@@ -322,7 +322,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
322 case 730: 322 case 730:
323 case 740: 323 case 740:
324 case 750: 324 case 750:
325 Trace(TRACE_MEMORY,"private_data(%Zd)\n",sizeof(struct pwc_dec23_private)); 325 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
326 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */ 326 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */
327 break; 327 break;
328 case 645: 328 case 645:
@@ -850,7 +850,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
850 850
851 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { 851 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
852 Err("Failed to find packet size for video endpoint in current alternate setting.\n"); 852 Err("Failed to find packet size for video endpoint in current alternate setting.\n");
853 return -ENFILE; /* Odd error, that should be noticable */ 853 return -ENFILE; /* Odd error, that should be noticeable */
854 } 854 }
855 855
856 /* Set alternate interface */ 856 /* Set alternate interface */
@@ -1179,7 +1179,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1179 DECLARE_WAITQUEUE(wait, current); 1179 DECLARE_WAITQUEUE(wait, current);
1180 int bytes_to_read; 1180 int bytes_to_read;
1181 1181
1182 Trace(TRACE_READ, "video_read(0x%p, %p, %Zd) called.\n", vdev, buf, count); 1182 Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count);
1183 if (vdev == NULL) 1183 if (vdev == NULL)
1184 return -EFAULT; 1184 return -EFAULT;
1185 pdev = vdev->priv; 1185 pdev = vdev->priv;
@@ -2128,7 +2128,7 @@ static int __init usb_pwc_init(void)
2128 if (leds[1] >= 0) 2128 if (leds[1] >= 0)
2129 led_off = leds[1]; 2129 led_off = leds[1];
2130 2130
2131 /* Big device node whoopla. Basicly, it allows you to assign a 2131 /* Big device node whoopla. Basically, it allows you to assign a
2132 device node (/dev/videoX) to a camera, based on its type 2132 device node (/dev/videoX) to a camera, based on its type
2133 & serial number. The format is [type[.serialnumber]:]node. 2133 & serial number. The format is [type[.serialnumber]:]node.
2134 2134
diff --git a/drivers/usb/media/pwc/pwc-ioctl.h b/drivers/usb/media/pwc/pwc-ioctl.h
index 65805eaa9a1c..5f9cb08bc02e 100644
--- a/drivers/usb/media/pwc/pwc-ioctl.h
+++ b/drivers/usb/media/pwc/pwc-ioctl.h
@@ -75,7 +75,7 @@
75#define PWC_FPS_SNAPSHOT 0x00400000 75#define PWC_FPS_SNAPSHOT 0x00400000
76 76
77 77
78/* structure for transfering x & y coordinates */ 78/* structure for transferring x & y coordinates */
79struct pwc_coord 79struct pwc_coord
80{ 80{
81 int x, y; /* guess what */ 81 int x, y; /* guess what */
diff --git a/drivers/usb/media/pwc/pwc.h b/drivers/usb/media/pwc/pwc.h
index 53b516d29cf5..267869dab185 100644
--- a/drivers/usb/media/pwc/pwc.h
+++ b/drivers/usb/media/pwc/pwc.h
@@ -226,9 +226,8 @@ struct pwc_device
226extern "C" { 226extern "C" {
227#endif 227#endif
228 228
229/* Global variables */ 229/* Global variable */
230extern int pwc_trace; 230extern int pwc_trace;
231extern int pwc_preferred_compression;
232 231
233/** functions in pwc-if.c */ 232/** functions in pwc-if.c */
234int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot); 233int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot);
@@ -243,8 +242,6 @@ void pwc_construct(struct pwc_device *pdev);
243/** Functions in pwc-ctrl.c */ 242/** Functions in pwc-ctrl.c */
244/* Request a certain video mode. Returns < 0 if not possible */ 243/* Request a certain video mode. Returns < 0 if not possible */
245extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot); 244extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot);
246/* Calculate the number of bytes per image (not frame) */
247extern void pwc_set_image_buffer_size(struct pwc_device *pdev);
248 245
249/* Various controls; should be obvious. Value 0..65535, or < 0 on error */ 246/* Various controls; should be obvious. Value 0..65535, or < 0 on error */
250extern int pwc_get_brightness(struct pwc_device *pdev); 247extern int pwc_get_brightness(struct pwc_device *pdev);
@@ -256,7 +253,6 @@ extern int pwc_set_gamma(struct pwc_device *pdev, int value);
256extern int pwc_get_saturation(struct pwc_device *pdev); 253extern int pwc_get_saturation(struct pwc_device *pdev);
257extern int pwc_set_saturation(struct pwc_device *pdev, int value); 254extern int pwc_set_saturation(struct pwc_device *pdev, int value);
258extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); 255extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
259extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value);
260extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor); 256extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
261 257
262/* Power down or up the camera; not supported by all models */ 258/* Power down or up the camera; not supported by all models */
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index 898401cf7dcc..31d57400d5be 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -429,7 +429,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam,
429} 429}
430 430
431 431
432int 432static int
433sn9c102_i2c_try_write(struct sn9c102_device* cam, 433sn9c102_i2c_try_write(struct sn9c102_device* cam,
434 struct sn9c102_sensor* sensor, u8 address, u8 value) 434 struct sn9c102_sensor* sensor, u8 address, u8 value)
435{ 435{
@@ -785,7 +785,7 @@ static int sn9c102_stop_transfer(struct sn9c102_device* cam)
785} 785}
786 786
787 787
788int sn9c102_stream_interrupt(struct sn9c102_device* cam) 788static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
789{ 789{
790 int err = 0; 790 int err = 0;
791 791
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/usb/media/sn9c102_sensor.h
index 16f7483559f0..6a7adebcb4bf 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/usb/media/sn9c102_sensor.h
@@ -145,8 +145,6 @@ static const struct usb_device_id sn9c102_id_table[] = { \
145*/ 145*/
146 146
147/* The "try" I2C I/O versions are used when probing the sensor */ 147/* The "try" I2C I/O versions are used when probing the sensor */
148extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
149 u8 address, u8 value);
150extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 148extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
151 u8 address); 149 u8 address);
152 150
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index dd4580cb57e0..7d06105763d4 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -859,7 +859,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
859 info ("udev is NULL."); 859 info ("udev is NULL.");
860 } 860 }
861 861
862 /* allocate memory for our device state and intialize it */ 862 /* allocate memory for our device state and initialize it */
863 863
864 dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL); 864 dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL);
865 865
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 57b82d53a940..2fd12264fd53 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -983,7 +983,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
983 msgcount++; 983 msgcount++;
984 if (msgcount < 500) 984 if (msgcount < 500)
985 printk(KERN_ERR 985 printk(KERN_ERR
986 "sisusbvga[%d]: Wrote %Zd of " 986 "sisusbvga[%d]: Wrote %zd of "
987 "%d bytes, error %d\n", 987 "%d bytes, error %d\n",
988 sisusb->minor, *bytes_written, 988 sisusb->minor, *bytes_written,
989 length, ret); 989 length, ret);
@@ -3105,6 +3105,7 @@ static void sisusb_disconnect(struct usb_interface *intf)
3105static struct usb_device_id sisusb_table [] = { 3105static struct usb_device_id sisusb_table [] = {
3106 { USB_DEVICE(0x0711, 0x0900) }, 3106 { USB_DEVICE(0x0711, 0x0900) },
3107 { USB_DEVICE(0x182d, 0x021c) }, 3107 { USB_DEVICE(0x182d, 0x021c) },
3108 { USB_DEVICE(0x182d, 0x0269) },
3108 { } 3109 { }
3109}; 3110};
3110 3111
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index a02be795d63e..d976790312aa 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -1388,11 +1388,11 @@ static int pegasus_resume (struct usb_interface *intf)
1388 if (netif_running(pegasus->net)) { 1388 if (netif_running(pegasus->net)) {
1389 pegasus->rx_urb->status = 0; 1389 pegasus->rx_urb->status = 0;
1390 pegasus->rx_urb->actual_length = 0; 1390 pegasus->rx_urb->actual_length = 0;
1391 read_bulk_callback(pegasus->rx_urb, 0); 1391 read_bulk_callback(pegasus->rx_urb, NULL);
1392 1392
1393 pegasus->intr_urb->status = 0; 1393 pegasus->intr_urb->status = 0;
1394 pegasus->intr_urb->actual_length = 0; 1394 pegasus->intr_urb->actual_length = 0;
1395 intr_callback(pegasus->intr_urb, 0); 1395 intr_callback(pegasus->intr_urb, NULL);
1396 1396
1397 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1397 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
1398 CARRIER_CHECK_DELAY); 1398 CARRIER_CHECK_DELAY);
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index bbaef047d532..f6bc6b3b333c 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * USB Networking Links 2 * USB Networking Links
3 * Copyright (C) 2000-2003 by David Brownell <dbrownell@users.sourceforge.net> 3 * Copyright (C) 2000-2005 by David Brownell <dbrownell@users.sourceforge.net>
4 * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz> 4 * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz>
5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> 5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
6 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net> 6 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
@@ -210,6 +210,7 @@ struct usbnet {
210# define EVENT_RX_HALT 1 210# define EVENT_RX_HALT 1
211# define EVENT_RX_MEMORY 2 211# define EVENT_RX_MEMORY 2
212# define EVENT_STS_SPLIT 3 212# define EVENT_STS_SPLIT 3
213# define EVENT_LINK_RESET 4
213}; 214};
214 215
215// device-specific info used by the driver 216// device-specific info used by the driver
@@ -243,6 +244,9 @@ struct driver_info {
243 /* for status polling */ 244 /* for status polling */
244 void (*status)(struct usbnet *, struct urb *); 245 void (*status)(struct usbnet *, struct urb *);
245 246
247 /* link reset handling, called from defer_kevent */
248 int (*link_reset)(struct usbnet *);
249
246 /* fixup rx packet (strip framing) */ 250 /* fixup rx packet (strip framing) */
247 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb); 251 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
248 252
@@ -304,6 +308,7 @@ static void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
304static u32 usbnet_get_link (struct net_device *); 308static u32 usbnet_get_link (struct net_device *);
305static u32 usbnet_get_msglevel (struct net_device *); 309static u32 usbnet_get_msglevel (struct net_device *);
306static void usbnet_set_msglevel (struct net_device *, u32); 310static void usbnet_set_msglevel (struct net_device *, u32);
311static void defer_kevent (struct usbnet *, int);
307 312
308/* mostly for PDA style devices, which are always connected if present */ 313/* mostly for PDA style devices, which are always connected if present */
309static int always_connected (struct usbnet *dev) 314static int always_connected (struct usbnet *dev)
@@ -426,7 +431,7 @@ static void skb_return (struct usbnet *dev, struct sk_buff *skb)
426 dev->stats.rx_bytes += skb->len; 431 dev->stats.rx_bytes += skb->len;
427 432
428 if (netif_msg_rx_status (dev)) 433 if (netif_msg_rx_status (dev))
429 devdbg (dev, "< rx, len %zd, type 0x%x", 434 devdbg (dev, "< rx, len %zu, type 0x%x",
430 skb->len + sizeof (struct ethhdr), skb->protocol); 435 skb->len + sizeof (struct ethhdr), skb->protocol);
431 memset (skb->cb, 0, sizeof (struct skb_data)); 436 memset (skb->cb, 0, sizeof (struct skb_data));
432 status = netif_rx (skb); 437 status = netif_rx (skb);
@@ -501,6 +506,7 @@ static const struct driver_info an2720_info = {
501#define AX_CMD_WRITE_MULTI_FILTER 0x16 506#define AX_CMD_WRITE_MULTI_FILTER 0x16
502#define AX_CMD_READ_NODE_ID 0x17 507#define AX_CMD_READ_NODE_ID 0x17
503#define AX_CMD_READ_PHY_ID 0x19 508#define AX_CMD_READ_PHY_ID 0x19
509#define AX_CMD_READ_MEDIUM_STATUS 0x1a
504#define AX_CMD_WRITE_MEDIUM_MODE 0x1b 510#define AX_CMD_WRITE_MEDIUM_MODE 0x1b
505#define AX_CMD_READ_MONITOR_MODE 0x1c 511#define AX_CMD_READ_MONITOR_MODE 0x1c
506#define AX_CMD_WRITE_MONITOR_MODE 0x1d 512#define AX_CMD_WRITE_MONITOR_MODE 0x1d
@@ -515,11 +521,14 @@ static const struct driver_info an2720_info = {
515#define AX_MONITOR_MAGIC 0x04 521#define AX_MONITOR_MAGIC 0x04
516#define AX_MONITOR_HSFS 0x10 522#define AX_MONITOR_HSFS 0x10
517 523
524/* AX88172 Medium Status Register values */
525#define AX_MEDIUM_FULL_DUPLEX 0x02
526#define AX_MEDIUM_TX_ABORT_ALLOW 0x04
527#define AX_MEDIUM_FLOW_CONTROL_EN 0x10
528
518#define AX_MCAST_FILTER_SIZE 8 529#define AX_MCAST_FILTER_SIZE 8
519#define AX_MAX_MCAST 64 530#define AX_MAX_MCAST 64
520 531
521#define AX_INTERRUPT_BUFSIZE 8
522
523#define AX_EEPROM_LEN 0x40 532#define AX_EEPROM_LEN 0x40
524 533
525#define AX_SWRESET_CLEAR 0x00 534#define AX_SWRESET_CLEAR 0x00
@@ -535,15 +544,33 @@ static const struct driver_info an2720_info = {
535#define AX88772_IPG1_DEFAULT 0x0c 544#define AX88772_IPG1_DEFAULT 0x0c
536#define AX88772_IPG2_DEFAULT 0x12 545#define AX88772_IPG2_DEFAULT 0x12
537 546
547#define AX88772_MEDIUM_FULL_DUPLEX 0x0002
548#define AX88772_MEDIUM_RESERVED 0x0004
549#define AX88772_MEDIUM_RX_FC_ENABLE 0x0010
550#define AX88772_MEDIUM_TX_FC_ENABLE 0x0020
551#define AX88772_MEDIUM_PAUSE_FORMAT 0x0080
552#define AX88772_MEDIUM_RX_ENABLE 0x0100
553#define AX88772_MEDIUM_100MB 0x0200
554#define AX88772_MEDIUM_DEFAULT \
555 (AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \
556 AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \
557 AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE )
558
538#define AX_EEPROM_MAGIC 0xdeadbeef 559#define AX_EEPROM_MAGIC 0xdeadbeef
539 560
540/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ 561/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
541struct ax8817x_data { 562struct ax8817x_data {
542 u8 multi_filter[AX_MCAST_FILTER_SIZE]; 563 u8 multi_filter[AX_MCAST_FILTER_SIZE];
543 struct urb *int_urb;
544 u8 *int_buf;
545}; 564};
546 565
566struct ax88172_int_data {
567 u16 res1;
568 u8 link;
569 u16 res2;
570 u8 status;
571 u16 res3;
572} __attribute__ ((packed));
573
547static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 574static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
548 u16 size, void *data) 575 u16 size, void *data)
549{ 576{
@@ -586,25 +613,23 @@ static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs)
586 usb_free_urb(urb); 613 usb_free_urb(urb);
587} 614}
588 615
589static void ax8817x_interrupt_complete(struct urb *urb, struct pt_regs *regs) 616static void ax8817x_status(struct usbnet *dev, struct urb *urb)
590{ 617{
591 struct usbnet *dev = (struct usbnet *)urb->context; 618 struct ax88172_int_data *event;
592 struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
593 int link; 619 int link;
594 620
595 if (urb->status < 0) { 621 if (urb->actual_length < 8)
596 devdbg(dev,"ax8817x_interrupt_complete() failed with %d", 622 return;
597 urb->status); 623
598 } else { 624 event = urb->transfer_buffer;
599 link = data->int_buf[2] & 0x01; 625 link = event->link & 0x01;
600 if (netif_carrier_ok(dev->net) != link) { 626 if (netif_carrier_ok(dev->net) != link) {
601 if (link) 627 if (link) {
602 netif_carrier_on(dev->net); 628 netif_carrier_on(dev->net);
603 else 629 defer_kevent (dev, EVENT_LINK_RESET );
604 netif_carrier_off(dev->net); 630 } else
605 devdbg(dev, "ax8817x - Link Status is: %d", link); 631 netif_carrier_off(dev->net);
606 } 632 devdbg(dev, "ax8817x - Link Status is: %d", link);
607 usb_submit_urb(data->int_urb, GFP_ATOMIC);
608 } 633 }
609} 634}
610 635
@@ -711,6 +736,20 @@ static void ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, i
711 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); 736 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
712} 737}
713 738
739static int ax88172_link_reset(struct usbnet *dev)
740{
741 u16 lpa;
742 u8 mode;
743
744 mode = AX_MEDIUM_TX_ABORT_ALLOW | AX_MEDIUM_FLOW_CONTROL_EN;
745 lpa = ax8817x_mdio_read(dev->net, dev->mii.phy_id, MII_LPA);
746 if (lpa & LPA_DUPLEX)
747 mode |= AX_MEDIUM_FULL_DUPLEX;
748 ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
749
750 return 0;
751}
752
714static void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) 753static void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
715{ 754{
716 struct usbnet *dev = netdev_priv(net); 755 struct usbnet *dev = netdev_priv(net);
@@ -824,35 +863,13 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
824 void *buf; 863 void *buf;
825 int i; 864 int i;
826 unsigned long gpio_bits = dev->driver_info->data; 865 unsigned long gpio_bits = dev->driver_info->data;
827 struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
828 866
829 get_endpoints(dev,intf); 867 get_endpoints(dev,intf);
830 868
831 if ((data->int_urb = usb_alloc_urb (0, GFP_KERNEL)) == NULL) {
832 dbg ("%s: cannot allocate interrupt URB",
833 dev->net->name);
834 ret = -ENOMEM;
835 goto out1;
836 }
837
838 if ((data->int_buf = kmalloc(AX_INTERRUPT_BUFSIZE, GFP_KERNEL)) == NULL) {
839 dbg ("%s: cannot allocate memory for interrupt buffer",
840 dev->net->name);
841 ret = -ENOMEM;
842 goto out1;
843 }
844 memset(data->int_buf, 0, AX_INTERRUPT_BUFSIZE);
845
846 usb_fill_int_urb (data->int_urb, dev->udev,
847 usb_rcvintpipe (dev->udev, 1),
848 data->int_buf, AX_INTERRUPT_BUFSIZE,
849 ax8817x_interrupt_complete, dev,
850 dev->udev->speed == USB_SPEED_HIGH ? 8 : 100);
851
852 buf = kmalloc(ETH_ALEN, GFP_KERNEL); 869 buf = kmalloc(ETH_ALEN, GFP_KERNEL);
853 if(!buf) { 870 if(!buf) {
854 ret = -ENOMEM; 871 ret = -ENOMEM;
855 goto out2; 872 goto out1;
856 } 873 }
857 874
858 /* Toggle the GPIOs in a manufacturer/model specific way */ 875 /* Toggle the GPIOs in a manufacturer/model specific way */
@@ -860,32 +877,32 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
860 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, 877 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
861 (gpio_bits >> (i * 8)) & 0xff, 0, 0, 878 (gpio_bits >> (i * 8)) & 0xff, 0, 0,
862 buf)) < 0) 879 buf)) < 0)
863 goto out3; 880 goto out2;
864 msleep(5); 881 msleep(5);
865 } 882 }
866 883
867 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) { 884 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) {
868 dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret); 885 dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret);
869 goto out3; 886 goto out2;
870 } 887 }
871 888
872 /* Get the MAC address */ 889 /* Get the MAC address */
873 memset(buf, 0, ETH_ALEN); 890 memset(buf, 0, ETH_ALEN);
874 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) { 891 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) {
875 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); 892 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
876 goto out3; 893 goto out2;
877 } 894 }
878 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 895 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
879 896
880 /* Get the PHY id */ 897 /* Get the PHY id */
881 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) { 898 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) {
882 dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret); 899 dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret);
883 goto out3; 900 goto out2;
884 } else if (ret < 2) { 901 } else if (ret < 2) {
885 /* this should always return 2 bytes */ 902 /* this should always return 2 bytes */
886 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret); 903 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret);
887 ret = -EIO; 904 ret = -EIO;
888 goto out3; 905 goto out2;
889 } 906 }
890 907
891 /* Initialize MII structure */ 908 /* Initialize MII structure */
@@ -899,36 +916,18 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
899 dev->net->set_multicast_list = ax8817x_set_multicast; 916 dev->net->set_multicast_list = ax8817x_set_multicast;
900 dev->net->ethtool_ops = &ax8817x_ethtool_ops; 917 dev->net->ethtool_ops = &ax8817x_ethtool_ops;
901 918
902 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, 919 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
903 cpu_to_le16(BMCR_RESET));
904 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, 920 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
905 cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA | 0x0400)); 921 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
906 mii_nway_restart(&dev->mii); 922 mii_nway_restart(&dev->mii);
907 923
908 if((ret = usb_submit_urb(data->int_urb, GFP_KERNEL)) < 0) {
909 dbg("Failed to submit interrupt URB: %02x", ret);
910 goto out2;
911 }
912
913 return 0; 924 return 0;
914out3:
915 kfree(buf);
916out2: 925out2:
917 kfree(data->int_buf); 926 kfree(buf);
918out1: 927out1:
919 usb_free_urb(data->int_urb);
920 return ret; 928 return ret;
921} 929}
922 930
923static void ax8817x_unbind(struct usbnet *dev, struct usb_interface *intf)
924{
925 struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
926
927 usb_kill_urb(data->int_urb);
928 usb_free_urb(data->int_urb);
929 kfree(data->int_buf);
930}
931
932static struct ethtool_ops ax88772_ethtool_ops = { 931static struct ethtool_ops ax88772_ethtool_ops = {
933 .get_drvinfo = ax8817x_get_drvinfo, 932 .get_drvinfo = ax8817x_get_drvinfo,
934 .get_link = ethtool_op_get_link, 933 .get_link = ethtool_op_get_link,
@@ -946,64 +945,44 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
946{ 945{
947 int ret; 946 int ret;
948 void *buf; 947 void *buf;
949 struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
950 948
951 get_endpoints(dev,intf); 949 get_endpoints(dev,intf);
952 950
953 if ((data->int_urb = usb_alloc_urb (0, GFP_KERNEL)) == 0) {
954 dbg ("Cannot allocate interrupt URB");
955 ret = -ENOMEM;
956 goto out1;
957 }
958
959 if ((data->int_buf = kmalloc(AX_INTERRUPT_BUFSIZE, GFP_KERNEL)) == NULL) {
960 dbg ("Cannot allocate memory for interrupt buffer");
961 ret = -ENOMEM;
962 goto out1;
963 }
964 memset(data->int_buf, 0, AX_INTERRUPT_BUFSIZE);
965
966 usb_fill_int_urb (data->int_urb, dev->udev,
967 usb_rcvintpipe (dev->udev, 1),
968 data->int_buf, AX_INTERRUPT_BUFSIZE,
969 ax8817x_interrupt_complete, dev,
970 dev->udev->speed == USB_SPEED_HIGH ? 8 : 100);
971
972 buf = kmalloc(6, GFP_KERNEL); 951 buf = kmalloc(6, GFP_KERNEL);
973 if(!buf) { 952 if(!buf) {
974 dbg ("Cannot allocate memory for buffer"); 953 dbg ("Cannot allocate memory for buffer");
975 ret = -ENOMEM; 954 ret = -ENOMEM;
976 goto out2; 955 goto out1;
977 } 956 }
978 957
979 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, 958 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
980 0x00B0, 0, 0, buf)) < 0) 959 0x00B0, 0, 0, buf)) < 0)
981 goto out3; 960 goto out2;
982 961
983 msleep(5); 962 msleep(5);
984 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0x0001, 0, 0, buf)) < 0) { 963 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0x0001, 0, 0, buf)) < 0) {
985 dbg("Select PHY #1 failed: %d", ret); 964 dbg("Select PHY #1 failed: %d", ret);
986 goto out3; 965 goto out2;
987 } 966 }
988 967
989 if ((ret = 968 if ((ret =
990 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD, 0, 0, buf)) < 0) { 969 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD, 0, 0, buf)) < 0) {
991 dbg("Failed to power down internal PHY: %d", ret); 970 dbg("Failed to power down internal PHY: %d", ret);
992 goto out3; 971 goto out2;
993 } 972 }
994 973
995 msleep(150); 974 msleep(150);
996 if ((ret = 975 if ((ret =
997 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR, 0, 0, buf)) < 0) { 976 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR, 0, 0, buf)) < 0) {
998 dbg("Failed to perform software reset: %d", ret); 977 dbg("Failed to perform software reset: %d", ret);
999 goto out3; 978 goto out2;
1000 } 979 }
1001 980
1002 msleep(150); 981 msleep(150);
1003 if ((ret = 982 if ((ret =
1004 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) { 983 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) {
1005 dbg("Failed to set Internal/External PHY reset control: %d", ret); 984 dbg("Failed to set Internal/External PHY reset control: %d", ret);
1006 goto out3; 985 goto out2;
1007 } 986 }
1008 987
1009 msleep(150); 988 msleep(150);
@@ -1011,27 +990,27 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1011 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0000, 0, 0, 990 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0000, 0, 0,
1012 buf)) < 0) { 991 buf)) < 0) {
1013 dbg("Failed to reset RX_CTL: %d", ret); 992 dbg("Failed to reset RX_CTL: %d", ret);
1014 goto out3; 993 goto out2;
1015 } 994 }
1016 995
1017 /* Get the MAC address */ 996 /* Get the MAC address */
1018 memset(buf, 0, ETH_ALEN); 997 memset(buf, 0, ETH_ALEN);
1019 if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf)) < 0) { 998 if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf)) < 0) {
1020 dbg("Failed to read MAC address: %d", ret); 999 dbg("Failed to read MAC address: %d", ret);
1021 goto out3; 1000 goto out2;
1022 } 1001 }
1023 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 1002 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
1024 1003
1025 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, buf)) < 0) { 1004 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, buf)) < 0) {
1026 dbg("Enabling software MII failed: %d", ret); 1005 dbg("Enabling software MII failed: %d", ret);
1027 goto out3; 1006 goto out2;
1028 } 1007 }
1029 1008
1030 if (((ret = 1009 if (((ret =
1031 ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, 0x0010, 2, 2, buf)) < 0) 1010 ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, 0x0010, 2, 2, buf)) < 0)
1032 || (*((u16 *)buf) != 0x003b)) { 1011 || (*((u16 *)buf) != 0x003b)) {
1033 dbg("Read PHY register 2 must be 0x3b00: %d", ret); 1012 dbg("Read PHY register 2 must be 0x3b00: %d", ret);
1034 goto out3; 1013 goto out2;
1035 } 1014 }
1036 1015
1037 /* Initialize MII structure */ 1016 /* Initialize MII structure */
@@ -1044,26 +1023,26 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1044 /* Get the PHY id */ 1023 /* Get the PHY id */
1045 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) { 1024 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) {
1046 dbg("Error reading PHY ID: %02x", ret); 1025 dbg("Error reading PHY ID: %02x", ret);
1047 goto out3; 1026 goto out2;
1048 } else if (ret < 2) { 1027 } else if (ret < 2) {
1049 /* this should always return 2 bytes */ 1028 /* this should always return 2 bytes */
1050 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", 1029 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x",
1051 ret); 1030 ret);
1052 ret = -EIO; 1031 ret = -EIO;
1053 goto out3; 1032 goto out2;
1054 } 1033 }
1055 dev->mii.phy_id = *((u8 *)buf + 1); 1034 dev->mii.phy_id = *((u8 *)buf + 1);
1056 1035
1057 if ((ret = 1036 if ((ret =
1058 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL, 0, 0, buf)) < 0) { 1037 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL, 0, 0, buf)) < 0) {
1059 dbg("Set external PHY reset pin level: %d", ret); 1038 dbg("Set external PHY reset pin level: %d", ret);
1060 goto out3; 1039 goto out2;
1061 } 1040 }
1062 msleep(150); 1041 msleep(150);
1063 if ((ret = 1042 if ((ret =
1064 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) { 1043 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) {
1065 dbg("Set Internal/External PHY reset control: %d", ret); 1044 dbg("Set Internal/External PHY reset control: %d", ret);
1066 goto out3; 1045 goto out2;
1067 } 1046 }
1068 msleep(150); 1047 msleep(150);
1069 1048
@@ -1071,25 +1050,24 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1071 dev->net->set_multicast_list = ax8817x_set_multicast; 1050 dev->net->set_multicast_list = ax8817x_set_multicast;
1072 dev->net->ethtool_ops = &ax88772_ethtool_ops; 1051 dev->net->ethtool_ops = &ax88772_ethtool_ops;
1073 1052
1074 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, 1053 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
1075 cpu_to_le16(BMCR_RESET));
1076 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, 1054 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
1077 cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA)); 1055 ADVERTISE_ALL | ADVERTISE_CSMA);
1078 mii_nway_restart(&dev->mii); 1056 mii_nway_restart(&dev->mii);
1079 1057
1080 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, 0x0336, 0, 0, buf)) < 0) { 1058 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, AX88772_MEDIUM_DEFAULT, 0, 0, buf)) < 0) {
1081 dbg("Write medium mode register: %d", ret); 1059 dbg("Write medium mode register: %d", ret);
1082 goto out3; 1060 goto out2;
1083 } 1061 }
1084 1062
1085 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,AX88772_IPG2_DEFAULT, 0, buf)) < 0) { 1063 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,AX88772_IPG2_DEFAULT, 0, buf)) < 0) {
1086 dbg("Write IPG,IPG1,IPG2 failed: %d", ret); 1064 dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
1087 goto out3; 1065 goto out2;
1088 } 1066 }
1089 if ((ret = 1067 if ((ret =
1090 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) { 1068 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) {
1091 dbg("Failed to set hardware MII: %02x", ret); 1069 dbg("Failed to set hardware MII: %02x", ret);
1092 goto out3; 1070 goto out2;
1093 } 1071 }
1094 1072
1095 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 1073 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
@@ -1097,25 +1075,16 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1097 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0, 1075 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0,
1098 buf)) < 0) { 1076 buf)) < 0) {
1099 dbg("Reset RX_CTL failed: %d", ret); 1077 dbg("Reset RX_CTL failed: %d", ret);
1100 goto out3; 1078 goto out2;
1101 }
1102
1103 if((ret = usb_submit_urb(data->int_urb, GFP_KERNEL)) < 0) {
1104 dbg("Failed to submit interrupt URB: %02x", ret);
1105 goto out3;
1106 } 1079 }
1107 1080
1108 kfree(buf); 1081 kfree(buf);
1109 1082
1110 return 0; 1083 return 0;
1111 1084
1112out3:
1113 kfree(buf);
1114out2: 1085out2:
1115 kfree(data->int_buf); 1086 kfree(buf);
1116out1: 1087out1:
1117 usb_free_urb(data->int_urb);
1118
1119 return ret; 1088 return ret;
1120} 1089}
1121 1090
@@ -1213,10 +1182,29 @@ static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
1213 return skb; 1182 return skb;
1214} 1183}
1215 1184
1185static int ax88772_link_reset(struct usbnet *dev)
1186{
1187 u16 lpa;
1188 u16 mode;
1189
1190 mode = AX88772_MEDIUM_DEFAULT;
1191 lpa = ax8817x_mdio_read(dev->net, dev->mii.phy_id, MII_LPA);
1192
1193 if ((lpa & LPA_DUPLEX) == 0)
1194 mode &= ~AX88772_MEDIUM_FULL_DUPLEX;
1195 if ((lpa & LPA_100) == 0)
1196 mode &= ~AX88772_MEDIUM_100MB;
1197 ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
1198
1199 return 0;
1200}
1201
1216static const struct driver_info ax8817x_info = { 1202static const struct driver_info ax8817x_info = {
1217 .description = "ASIX AX8817x USB 2.0 Ethernet", 1203 .description = "ASIX AX8817x USB 2.0 Ethernet",
1218 .bind = ax8817x_bind, 1204 .bind = ax8817x_bind,
1219 .unbind = ax8817x_unbind, 1205 .status = ax8817x_status,
1206 .link_reset = ax88172_link_reset,
1207 .reset = ax88172_link_reset,
1220 .flags = FLAG_ETHER, 1208 .flags = FLAG_ETHER,
1221 .data = 0x00130103, 1209 .data = 0x00130103,
1222}; 1210};
@@ -1224,7 +1212,9 @@ static const struct driver_info ax8817x_info = {
1224static const struct driver_info dlink_dub_e100_info = { 1212static const struct driver_info dlink_dub_e100_info = {
1225 .description = "DLink DUB-E100 USB Ethernet", 1213 .description = "DLink DUB-E100 USB Ethernet",
1226 .bind = ax8817x_bind, 1214 .bind = ax8817x_bind,
1227 .unbind = ax8817x_unbind, 1215 .status = ax8817x_status,
1216 .link_reset = ax88172_link_reset,
1217 .reset = ax88172_link_reset,
1228 .flags = FLAG_ETHER, 1218 .flags = FLAG_ETHER,
1229 .data = 0x009f9d9f, 1219 .data = 0x009f9d9f,
1230}; 1220};
@@ -1232,7 +1222,9 @@ static const struct driver_info dlink_dub_e100_info = {
1232static const struct driver_info netgear_fa120_info = { 1222static const struct driver_info netgear_fa120_info = {
1233 .description = "Netgear FA-120 USB Ethernet", 1223 .description = "Netgear FA-120 USB Ethernet",
1234 .bind = ax8817x_bind, 1224 .bind = ax8817x_bind,
1235 .unbind = ax8817x_unbind, 1225 .status = ax8817x_status,
1226 .link_reset = ax88172_link_reset,
1227 .reset = ax88172_link_reset,
1236 .flags = FLAG_ETHER, 1228 .flags = FLAG_ETHER,
1237 .data = 0x00130103, 1229 .data = 0x00130103,
1238}; 1230};
@@ -1240,7 +1232,9 @@ static const struct driver_info netgear_fa120_info = {
1240static const struct driver_info hawking_uf200_info = { 1232static const struct driver_info hawking_uf200_info = {
1241 .description = "Hawking UF200 USB Ethernet", 1233 .description = "Hawking UF200 USB Ethernet",
1242 .bind = ax8817x_bind, 1234 .bind = ax8817x_bind,
1243 .unbind = ax8817x_unbind, 1235 .status = ax8817x_status,
1236 .link_reset = ax88172_link_reset,
1237 .reset = ax88172_link_reset,
1244 .flags = FLAG_ETHER, 1238 .flags = FLAG_ETHER,
1245 .data = 0x001f1d1f, 1239 .data = 0x001f1d1f,
1246}; 1240};
@@ -1248,7 +1242,9 @@ static const struct driver_info hawking_uf200_info = {
1248static const struct driver_info ax88772_info = { 1242static const struct driver_info ax88772_info = {
1249 .description = "ASIX AX88772 USB 2.0 Ethernet", 1243 .description = "ASIX AX88772 USB 2.0 Ethernet",
1250 .bind = ax88772_bind, 1244 .bind = ax88772_bind,
1251 .unbind = ax8817x_unbind, 1245 .status = ax8817x_status,
1246 .link_reset = ax88772_link_reset,
1247 .reset = ax88772_link_reset,
1252 .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1248 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1253 .rx_fixup = ax88772_rx_fixup, 1249 .rx_fixup = ax88772_rx_fixup,
1254 .tx_fixup = ax88772_tx_fixup, 1250 .tx_fixup = ax88772_tx_fixup,
@@ -2661,7 +2657,7 @@ static const struct driver_info blob_info = {
2661 * All known Zaurii lie about their standards conformance. Most lie by 2657 * All known Zaurii lie about their standards conformance. Most lie by
2662 * saying they support CDC Ethernet. Some lie and say they support CDC 2658 * saying they support CDC Ethernet. Some lie and say they support CDC
2663 * MDLM (as if for access to cell phone modems). Someone, please beat 2659 * MDLM (as if for access to cell phone modems). Someone, please beat
2664 * on Sharp for a while with a cluestick. 2660 * on Sharp (and other such vendors) for a while with a cluestick.
2665 * 2661 *
2666 *-------------------------------------------------------------------------*/ 2662 *-------------------------------------------------------------------------*/
2667 2663
@@ -2714,13 +2710,6 @@ static const struct driver_info zaurus_pxa_info = {
2714}; 2710};
2715#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info) 2711#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info)
2716 2712
2717static const struct driver_info zaurus_pxa_mdlm_info = {
2718 .description = "Sharp Zaurus, PXA-255 based",
2719 .flags = FLAG_FRAMING_Z,
2720 .check_connect = always_connected,
2721 .tx_fixup = zaurus_tx_fixup,
2722};
2723
2724static const struct driver_info olympus_mxl_info = { 2713static const struct driver_info olympus_mxl_info = {
2725 .description = "Olympus R1000", 2714 .description = "Olympus R1000",
2726 .flags = FLAG_FRAMING_Z, 2715 .flags = FLAG_FRAMING_Z,
@@ -2731,6 +2720,133 @@ static const struct driver_info olympus_mxl_info = {
2731}; 2720};
2732#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info) 2721#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info)
2733 2722
2723
2724/* Some more recent products using Lineo/Belcarra code will wrongly claim
2725 * CDC MDLM conformance. They aren't conformant: data endpoints live
2726 * in the control interface, there's no data interface, and it's not used
2727 * to talk to a cell phone radio. But at least we can detect these two
2728 * pseudo-classes, rather than growing this product list with entries for
2729 * each new nonconformant product (sigh).
2730 */
2731static const u8 safe_guid[16] = {
2732 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6,
2733 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f,
2734};
2735static const u8 blan_guid[16] = {
2736 0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70,
2737 0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37,
2738};
2739
2740static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf)
2741{
2742 u8 *buf = intf->cur_altsetting->extra;
2743 int len = intf->cur_altsetting->extralen;
2744 struct usb_cdc_mdlm_desc *desc = NULL;
2745 struct usb_cdc_mdlm_detail_desc *detail = NULL;
2746
2747 while (len > 3) {
2748 if (buf [1] != USB_DT_CS_INTERFACE)
2749 goto next_desc;
2750
2751 /* use bDescriptorSubType, and just verify that we get a
2752 * "BLAN" (or "SAFE") descriptor.
2753 */
2754 switch (buf [2]) {
2755 case USB_CDC_MDLM_TYPE:
2756 if (desc) {
2757 dev_dbg (&intf->dev, "extra MDLM\n");
2758 goto bad_desc;
2759 }
2760 desc = (void *) buf;
2761 if (desc->bLength != sizeof *desc) {
2762 dev_dbg (&intf->dev, "MDLM len %u\n",
2763 desc->bLength);
2764 goto bad_desc;
2765 }
2766 /* expect bcdVersion 1.0, ignore */
2767 if (memcmp(&desc->bGUID, blan_guid, 16)
2768 || memcmp(&desc->bGUID, blan_guid, 16) ) {
2769 /* hey, this one might _really_ be MDLM! */
2770 dev_dbg (&intf->dev, "MDLM guid\n");
2771 goto bad_desc;
2772 }
2773 break;
2774 case USB_CDC_MDLM_DETAIL_TYPE:
2775 if (detail) {
2776 dev_dbg (&intf->dev, "extra MDLM detail\n");
2777 goto bad_desc;
2778 }
2779 detail = (void *) buf;
2780 switch (detail->bGuidDescriptorType) {
2781 case 0: /* "SAFE" */
2782 if (detail->bLength != (sizeof *detail + 2))
2783 goto bad_detail;
2784 break;
2785 case 1: /* "BLAN" */
2786 if (detail->bLength != (sizeof *detail + 3))
2787 goto bad_detail;
2788 break;
2789 default:
2790 goto bad_detail;
2791 }
2792
2793 /* assuming we either noticed BLAN already, or will
2794 * find it soon, there are some data bytes here:
2795 * - bmNetworkCapabilities (unused)
2796 * - bmDataCapabilities (bits, see below)
2797 * - bPad (ignored, for PADAFTER -- BLAN-only)
2798 * bits are:
2799 * - 0x01 -- Zaurus framing (add CRC)
2800 * - 0x02 -- PADBEFORE
2801 * - 0x04 -- PADAFTER
2802 * - 0x08 -- "fermat" packet mangling (for hw bugs)
2803 */
2804 if (detail->bDetailData[1] != 0x01) {
2805 /* bmDataCapabilites == 0 would be fine too,
2806 * but framing is minidriver-coupled for now.
2807 */
2808bad_detail:
2809 dev_dbg (&intf->dev,
2810 "bad MDLM detail, %d %d %d\n",
2811 detail->bLength,
2812 detail->bDetailData[0],
2813 detail->bDetailData[2]);
2814 goto bad_desc;
2815 }
2816 break;
2817 }
2818next_desc:
2819 len -= buf [0]; /* bLength */
2820 buf += buf [0];
2821 }
2822
2823 if (!desc || !detail) {
2824 dev_dbg (&intf->dev, "missing cdc mdlm %s%sdescriptor\n",
2825 desc ? "" : "func ",
2826 detail ? "" : "detail ");
2827 goto bad_desc;
2828 }
2829
2830 /* There's probably a CDC Ethernet descriptor there, but we can't
2831 * rely on the Ethernet address it provides since not all vendors
2832 * bother to make it unique. Likewise there's no point in tracking
2833 * of the CDC event notifications.
2834 */
2835 return get_endpoints (dev, intf);
2836
2837bad_desc:
2838 dev_info (&dev->udev->dev, "unsupported MDLM descriptors\n");
2839 return -ENODEV;
2840}
2841
2842static const struct driver_info bogus_mdlm_info = {
2843 .description = "pseudo-MDLM (BLAN) device",
2844 .flags = FLAG_FRAMING_Z,
2845 .check_connect = always_connected,
2846 .tx_fixup = zaurus_tx_fixup,
2847 .bind = blan_mdlm_bind,
2848};
2849
2734#else 2850#else
2735 2851
2736/* blacklist all those devices */ 2852/* blacklist all those devices */
@@ -3307,6 +3423,19 @@ kevent (void *data)
3307 } 3423 }
3308 } 3424 }
3309 3425
3426 if (test_bit (EVENT_LINK_RESET, &dev->flags)) {
3427 struct driver_info *info = dev->driver_info;
3428 int retval = 0;
3429
3430 clear_bit (EVENT_LINK_RESET, &dev->flags);
3431 if(info->link_reset && (retval = info->link_reset(dev)) < 0) {
3432 devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s",
3433 retval,
3434 dev->udev->bus->bus_name, dev->udev->devpath,
3435 info->description);
3436 }
3437 }
3438
3310 if (dev->flags) 3439 if (dev->flags)
3311 devdbg (dev, "kevent done, flags = 0x%lx", 3440 devdbg (dev, "kevent done, flags = 0x%lx",
3312 dev->flags); 3441 dev->flags);
@@ -3942,6 +4071,9 @@ static const struct usb_device_id products [] = {
3942 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader 4071 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
3943 .driver_info = (unsigned long) &blob_info, 4072 .driver_info = (unsigned long) &blob_info,
3944}, { 4073}, {
4074 USB_DEVICE (0x22b8, 0x600c), // USBNET Motorola E680
4075 .driver_info = (unsigned long) &linuxdev_info,
4076}, {
3945 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x 4077 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x
3946 // e.g. Gumstix, current OpenZaurus, ... 4078 // e.g. Gumstix, current OpenZaurus, ...
3947 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), 4079 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
@@ -4020,30 +4152,14 @@ static const struct usb_device_id products [] = {
4020}, 4152},
4021 4153
4022#ifdef CONFIG_USB_ZAURUS 4154#ifdef CONFIG_USB_ZAURUS
4023 /* at least some (reports vary) PXA units have very different 4155 /* At least some (reports vary) PXA units have very different lies
4024 * lies about their standards support: they claim to be cell 4156 * about their standards support: they claim to be cell phones with
4025 * phones giving direct radio access (which they aren't). 4157 * direct access to their radios. (They don't conform to CDC MDLM.)
4026 */ 4158 */
4027{ 4159{
4028 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 4160 USB_INTERFACE_INFO (USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
4029 | USB_DEVICE_ID_MATCH_DEVICE, 4161 USB_CDC_PROTO_NONE),
4030 .idVendor = 0x04DD, 4162 .driver_info = (unsigned long) &bogus_mdlm_info,
4031 /* Sharp ROM v1.32 */
4032 .idProduct = 0x8006, /* SL-5600 */
4033 .bInterfaceClass = USB_CLASS_COMM,
4034 .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM,
4035 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
4036 .driver_info = (unsigned long) &zaurus_pxa_mdlm_info,
4037}, {
4038 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
4039 | USB_DEVICE_ID_MATCH_DEVICE,
4040 .idVendor = 0x04DD,
4041 /* reported with some C860 units */
4042 .idProduct = 0x9031, /* C-860 */
4043 .bInterfaceClass = USB_CLASS_COMM,
4044 .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM,
4045 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
4046 .driver_info = (unsigned long) &zaurus_pxa_mdlm_info,
4047}, 4163},
4048#endif 4164#endif
4049 4165
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index c81cd0a619bf..341ae5f732dd 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -45,7 +45,7 @@ MODULE_PARM_DESC(ap, "If non-zero Access Point firmware will be loaded");
45MODULE_DEVICE_TABLE(usb, zd1201_table); 45MODULE_DEVICE_TABLE(usb, zd1201_table);
46 46
47 47
48int zd1201_fw_upload(struct usb_device *dev, int apfw) 48static int zd1201_fw_upload(struct usb_device *dev, int apfw)
49{ 49{
50 const struct firmware *fw_entry; 50 const struct firmware *fw_entry;
51 char* data; 51 char* data;
@@ -111,7 +111,7 @@ exit:
111 return err; 111 return err;
112} 112}
113 113
114void zd1201_usbfree(struct urb *urb, struct pt_regs *regs) 114static void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
115{ 115{
116 struct zd1201 *zd = urb->context; 116 struct zd1201 *zd = urb->context;
117 117
@@ -142,7 +142,8 @@ void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
142 142
143 total: 4 + 2 + 2 + 2 + 2 + 4 = 16 143 total: 4 + 2 + 2 + 2 + 2 + 4 = 16
144*/ 144*/
145int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0, int parm1, int parm2) 145static int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0,
146 int parm1, int parm2)
146{ 147{
147 unsigned char *command; 148 unsigned char *command;
148 int ret; 149 int ret;
@@ -175,15 +176,15 @@ int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0, int parm1, int parm2)
175} 176}
176 177
177/* Callback after sending out a packet */ 178/* Callback after sending out a packet */
178void zd1201_usbtx(struct urb *urb, struct pt_regs *regs) 179static void zd1201_usbtx(struct urb *urb, struct pt_regs *regs)
179{ 180{
180 struct zd1201 *zd = urb->context; 181 struct zd1201 *zd = urb->context;
181 netif_wake_queue(zd->dev); 182 netif_wake_queue(zd->dev);
182 return; 183 return;
183} 184}
184 185
185/* Incomming data */ 186/* Incoming data */
186void zd1201_usbrx(struct urb *urb, struct pt_regs *regs) 187static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
187{ 188{
188 struct zd1201 *zd = urb->context; 189 struct zd1201 *zd = urb->context;
189 int free = 0; 190 int free = 0;
@@ -613,7 +614,7 @@ static inline int zd1201_setconfig16(struct zd1201 *zd, int rid, short val)
613 return (zd1201_setconfig(zd, rid, &zdval, sizeof(__le16), 1)); 614 return (zd1201_setconfig(zd, rid, &zdval, sizeof(__le16), 1));
614} 615}
615 616
616int zd1201_drvr_start(struct zd1201 *zd) 617static int zd1201_drvr_start(struct zd1201 *zd)
617{ 618{
618 int err, i; 619 int err, i;
619 short max; 620 short max;
@@ -771,7 +772,7 @@ static int zd1201_net_stop(struct net_device *dev)
771/* 772/*
772 RFC 1042 encapsulates Ethernet frames in 802.11 frames 773 RFC 1042 encapsulates Ethernet frames in 802.11 frames
773 by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0 774 by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0
774 (0x00, 0x00, 0x00). Zd requires an additionnal padding, copy 775 (0x00, 0x00, 0x00). Zd requires an additional padding, copy
775 of ethernet addresses, length of the standard RFC 1042 packet 776 of ethernet addresses, length of the standard RFC 1042 packet
776 and a command byte (which is nul for tx). 777 and a command byte (which is nul for tx).
777 778
@@ -1097,7 +1098,7 @@ static int zd1201_get_range(struct net_device *dev,
1097 1098
1098/* Little bit of magic here: we only get the quality if we poll 1099/* Little bit of magic here: we only get the quality if we poll
1099 * for it, and we never get an actual request to trigger such 1100 * for it, and we never get an actual request to trigger such
1100 * a poll. Therefore we 'asume' that the user will soon ask for 1101 * a poll. Therefore we 'assume' that the user will soon ask for
1101 * the stats after asking the bssid. 1102 * the stats after asking the bssid.
1102 */ 1103 */
1103static int zd1201_get_wap(struct net_device *dev, 1104static int zd1201_get_wap(struct net_device *dev,
@@ -1107,7 +1108,7 @@ static int zd1201_get_wap(struct net_device *dev,
1107 unsigned char buffer[6]; 1108 unsigned char buffer[6];
1108 1109
1109 if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) { 1110 if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
1110 /* Unfortunatly the quality and noise reported is useless. 1111 /* Unfortunately the quality and noise reported is useless.
1111 they seem to be accumulators that increase until you 1112 they seem to be accumulators that increase until you
1112 read them, unless we poll on a fixed interval we can't 1113 read them, unless we poll on a fixed interval we can't
1113 use them 1114 use them
@@ -1739,7 +1740,8 @@ static const struct iw_handler_def zd1201_iw_handlers = {
1739 .private_args = (struct iw_priv_args *) zd1201_private_args, 1740 .private_args = (struct iw_priv_args *) zd1201_private_args,
1740}; 1741};
1741 1742
1742int zd1201_probe(struct usb_interface *interface, const struct usb_device_id *id) 1743static int zd1201_probe(struct usb_interface *interface,
1744 const struct usb_device_id *id)
1743{ 1745{
1744 struct zd1201 *zd; 1746 struct zd1201 *zd;
1745 struct usb_device *usb; 1747 struct usb_device *usb;
@@ -1851,7 +1853,7 @@ err_zd:
1851 return err; 1853 return err;
1852} 1854}
1853 1855
1854void zd1201_disconnect(struct usb_interface *interface) 1856static void zd1201_disconnect(struct usb_interface *interface)
1855{ 1857{
1856 struct zd1201 *zd=(struct zd1201 *)usb_get_intfdata(interface); 1858 struct zd1201 *zd=(struct zd1201 *)usb_get_intfdata(interface);
1857 struct hlist_node *node, *node2; 1859 struct hlist_node *node, *node2;
@@ -1882,7 +1884,7 @@ void zd1201_disconnect(struct usb_interface *interface)
1882 kfree(zd); 1884 kfree(zd);
1883} 1885}
1884 1886
1885struct usb_driver zd1201_usb = { 1887static struct usb_driver zd1201_usb = {
1886 .owner = THIS_MODULE, 1888 .owner = THIS_MODULE,
1887 .name = "zd1201", 1889 .name = "zd1201",
1888 .probe = zd1201_probe, 1890 .probe = zd1201_probe,
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index b869076d9c7c..bc798edf0358 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -53,6 +53,15 @@ config USB_SERIAL_GENERIC
53 support" be compiled as a module for this driver to be used 53 support" be compiled as a module for this driver to be used
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRPRIME
57 tristate "USB AirPrime CDMA Wireless Driver"
58 depends on USB_SERIAL
59 help
60 Say Y here if you want to use a AirPrime CDMA Wireless PC card.
61
62 To compile this driver as a module, choose M here: the
63 module will be called airprime.
64
56config USB_SERIAL_BELKIN 65config USB_SERIAL_BELKIN
57 tristate "USB Belkin and Peracom Single Port Serial Driver" 66 tristate "USB Belkin and Peracom Single Port Serial Driver"
58 depends on USB_SERIAL 67 depends on USB_SERIAL
@@ -395,6 +404,15 @@ config USB_SERIAL_PL2303
395 To compile this driver as a module, choose M here: the 404 To compile this driver as a module, choose M here: the
396 module will be called pl2303. 405 module will be called pl2303.
397 406
407config USB_SERIAL_HP4X
408 tristate "USB HP4x Calculators support"
409 depends on USB_SERIAL
410 help
411 Say Y here if you want to use an Hewlett-Packard 4x Calculator.
412
413 To compile this driver as a module, choose M here: the
414 module will be called hp4x.
415
398config USB_SERIAL_SAFE 416config USB_SERIAL_SAFE
399 tristate "USB Safe Serial (Encapsulated) Driver (EXPERIMENTAL)" 417 tristate "USB Safe Serial (Encapsulated) Driver (EXPERIMENTAL)"
400 depends on USB_SERIAL && EXPERIMENTAL 418 depends on USB_SERIAL && EXPERIMENTAL
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 351b81855b18..d56ff6d86cce 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -11,6 +11,7 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
11 11
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
13 13
14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o
14obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 15obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
15obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 16obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
16obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 17obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
@@ -21,6 +22,7 @@ obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o
21obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o 22obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o
22obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o 23obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o
23obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o 24obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o
25obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o
24obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o 26obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o
25obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o 27obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o
26obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o 28obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
new file mode 100644
index 000000000000..a4ce0008d69b
--- /dev/null
+++ b/drivers/usb/serial/airprime.c
@@ -0,0 +1,63 @@
1/*
2 * AirPrime CDMA Wireless Serial USB driver
3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
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 version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include "usb-serial.h"
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0xf3d, 0x0112) },
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24static struct usb_driver airprime_driver = {
25 .owner = THIS_MODULE,
26 .name = "airprime",
27 .probe = usb_serial_probe,
28 .disconnect = usb_serial_disconnect,
29 .id_table = id_table,
30};
31
32static struct usb_serial_device_type airprime_device = {
33 .owner = THIS_MODULE,
34 .name = "airprime",
35 .id_table = id_table,
36 .num_interrupt_in = NUM_DONT_CARE,
37 .num_bulk_in = NUM_DONT_CARE,
38 .num_bulk_out = NUM_DONT_CARE,
39 .num_ports = 1,
40};
41
42static int __init airprime_init(void)
43{
44 int retval;
45
46 retval = usb_serial_register(&airprime_device);
47 if (retval)
48 return retval;
49 retval = usb_register(&airprime_driver);
50 if (retval)
51 usb_serial_deregister(&airprime_device);
52 return retval;
53}
54
55static void __exit airprime_exit(void)
56{
57 usb_deregister(&airprime_driver);
58 usb_serial_deregister(&airprime_device);
59}
60
61module_init(airprime_init);
62module_exit(airprime_exit);
63MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index d165f42d560d..f34a9bb6a219 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -16,6 +16,14 @@
16 * See http://geocities.com/i0xox0i for information on this driver and the 16 * See http://geocities.com/i0xox0i for information on this driver and the
17 * earthmate usb device. 17 * earthmate usb device.
18 * 18 *
19 * Lonnie Mendez <dignome@gmail.com>
20 * 4-29-2005
21 * Fixed problem where setting or retreiving the serial config would fail with
22 * EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial
23 * adapters. Issued new interval of 1ms instead of the default 10ms. As a
24 * result, transfer speed has been substantially increased. From avg. 850bps to
25 * avg. 3300bps. initial termios has also been modified. Cleaned up code and
26 * formatting issues so it is more readable. Replaced the C++ style comments.
19 * 27 *
20 * Lonnie Mendez <dignome@gmail.com> 28 * Lonnie Mendez <dignome@gmail.com>
21 * 12-15-2004 29 * 12-15-2004
@@ -32,12 +40,6 @@
32 * 10-2003 40 * 10-2003
33 * Driver first released. 41 * Driver first released.
34 * 42 *
35 *
36 * Long Term TODO:
37 * Improve transfer speeds - both read/write are somewhat slow
38 * at this point.
39 * Improve debugging. Show modem line status with debug output and
40 * implement filtering for certain data as a module parameter.
41 */ 43 */
42 44
43/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */ 45/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */
@@ -72,11 +74,12 @@
72 static int debug; 74 static int debug;
73#endif 75#endif
74static int stats; 76static int stats;
77static int interval;
75 78
76/* 79/*
77 * Version Information 80 * Version Information
78 */ 81 */
79#define DRIVER_VERSION "v1.08" 82#define DRIVER_VERSION "v1.09"
80#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>" 83#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
81#define DRIVER_DESC "Cypress USB to Serial Driver" 84#define DRIVER_DESC "Cypress USB to Serial Driver"
82 85
@@ -130,7 +133,6 @@ struct cypress_private {
130 char prev_status, diff_status; /* used for TIOCMIWAIT */ 133 char prev_status, diff_status; /* used for TIOCMIWAIT */
131 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */ 134 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
132 struct termios tmp_termios; /* stores the old termios settings */ 135 struct termios tmp_termios; /* stores the old termios settings */
133 char calledfromopen; /* used when issuing lines on open - fixes rts drop bug */
134}; 136};
135 137
136/* write buffer structure */ 138/* write buffer structure */
@@ -168,10 +170,8 @@ static void cypress_buf_free(struct cypress_buf *cb);
168static void cypress_buf_clear(struct cypress_buf *cb); 170static void cypress_buf_clear(struct cypress_buf *cb);
169static unsigned int cypress_buf_data_avail(struct cypress_buf *cb); 171static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
170static unsigned int cypress_buf_space_avail(struct cypress_buf *cb); 172static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
171static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, 173static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count);
172 unsigned int count); 174static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
173static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,
174 unsigned int count);
175 175
176 176
177static struct usb_serial_device_type cypress_earthmate_device = { 177static struct usb_serial_device_type cypress_earthmate_device = {
@@ -234,14 +234,13 @@ static struct usb_serial_device_type cypress_hidcom_device = {
234 *****************************************************************************/ 234 *****************************************************************************/
235 235
236 236
237/* This function can either set or retreive the current serial line settings */ 237/* This function can either set or retrieve the current serial line settings */
238static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits, 238static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,
239 int parity_enable, int parity_type, int reset, int cypress_request_type) 239 int parity_enable, int parity_type, int reset, int cypress_request_type)
240{ 240{
241 int i, n_baud_rate = 0, retval = 0; 241 int new_baudrate = 0, retval = 0, tries = 0;
242 struct cypress_private *priv; 242 struct cypress_private *priv;
243 __u8 feature_buffer[5]; 243 __u8 feature_buffer[8];
244 __u8 config;
245 unsigned long flags; 244 unsigned long flags;
246 245
247 dbg("%s", __FUNCTION__); 246 dbg("%s", __FUNCTION__);
@@ -256,7 +255,8 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
256 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose 255 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose
257 * firmware or not), if you need to modify this speed setting for your own 256 * firmware or not), if you need to modify this speed setting for your own
258 * project please add your own chiptype and modify the code likewise. The 257 * project please add your own chiptype and modify the code likewise. The
259 * Cypress HID->COM device will work successfully up to 115200bps. 258 * Cypress HID->COM device will work successfully up to 115200bps (but the
259 * actual throughput is around 3kBps).
260 */ 260 */
261 if (baud_mask != priv->cbr_mask) { 261 if (baud_mask != priv->cbr_mask) {
262 dbg("%s - baud rate is changing", __FUNCTION__); 262 dbg("%s - baud rate is changing", __FUNCTION__);
@@ -265,109 +265,114 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
265 * but are not used with NMEA and SiRF protocols */ 265 * but are not used with NMEA and SiRF protocols */
266 266
267 if ( (baud_mask == B300) || (baud_mask == B600) ) { 267 if ( (baud_mask == B300) || (baud_mask == B600) ) {
268 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 268 err("%s - failed setting baud rate, unsupported speed",
269 __FUNCTION__); 269 __FUNCTION__);
270 n_baud_rate = 4800; 270 new_baudrate = priv->baud_rate;
271 } else if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 271 } else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
272 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 272 err("%s - failed setting baud rate, unsupported speed",
273 __FUNCTION__); 273 __FUNCTION__);
274 n_baud_rate = 4800; 274 new_baudrate = priv->baud_rate;
275 } 275 }
276 } else if (priv->chiptype == CT_CYPHIDCOM) { 276 } else if (priv->chiptype == CT_CYPHIDCOM) {
277 if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 277 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
278 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 278 err("%s - failed setting baud rate, unsupported speed",
279 __FUNCTION__); 279 __FUNCTION__);
280 n_baud_rate = 4800; 280 new_baudrate = priv->baud_rate;
281 } 281 }
282 } else if (priv->chiptype == CT_GENERIC) { 282 } else if (priv->chiptype == CT_GENERIC) {
283 if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 283 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
284 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 284 err("%s - failed setting baud rate, unsupported speed",
285 __FUNCTION__); 285 __FUNCTION__);
286 n_baud_rate = 4800; 286 new_baudrate = priv->baud_rate;
287 } 287 }
288 } else { 288 } else {
289 info("%s - please define your chiptype, using 4800bps default", __FUNCTION__); 289 info("%s - please define your chiptype", __FUNCTION__);
290 n_baud_rate = 4800; 290 new_baudrate = priv->baud_rate;
291 } 291 }
292 } else { /* baud rate not changing, keep the old */ 292 } else { /* baud rate not changing, keep the old */
293 n_baud_rate = priv->baud_rate; 293 new_baudrate = priv->baud_rate;
294 } 294 }
295 dbg("%s - baud rate is being sent as %d", __FUNCTION__, n_baud_rate); 295 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate);
296
297 296
298 /* 297 memset(feature_buffer, 0, 8);
299 * This algorithm accredited to Jiang Jay Zhang... thanks for all the help! 298 /* fill the feature_buffer with new configuration */
300 */ 299 *((u_int32_t *)feature_buffer) = new_baudrate;
301 for (i = 0; i < 4; ++i) {
302 feature_buffer[i] = ( n_baud_rate >> (i*8) & 0xFF );
303 }
304 300
305 config = 0; // reset config byte 301 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
306 config |= data_bits; // assign data bits in 2 bit space ( max 3 )
307 /* 1 bit gap */ 302 /* 1 bit gap */
308 config |= (stop_bits << 3); // assign stop bits in 1 bit space 303 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
309 config |= (parity_enable << 4); // assign parity flag in 1 bit space 304 feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */
310 config |= (parity_type << 5); // assign parity type in 1 bit space 305 feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */
311 /* 1 bit gap */ 306 /* 1 bit gap */
312 config |= (reset << 7); // assign reset at end of byte, 1 bit space 307 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
313
314 feature_buffer[4] = config;
315 308
316 dbg("%s - device is being sent this feature report:", __FUNCTION__); 309 dbg("%s - device is being sent this feature report:", __FUNCTION__);
317 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1], 310 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1],
318 feature_buffer[2], feature_buffer[3], feature_buffer[4]); 311 feature_buffer[2], feature_buffer[3], feature_buffer[4]);
319 312
313 do {
320 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 314 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
321 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 315 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
322 0x0300, 0, feature_buffer, 5, 500); 316 0x0300, 0, feature_buffer, 8, 500);
317
318 if (tries++ >= 3)
319 break;
323 320
324 if (retval != 5) 321 if (retval == EPIPE)
322 usb_clear_halt(port->serial->dev, 0x00);
323 } while (retval != 8 && retval != ENODEV);
324
325 if (retval != 8)
325 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); 326 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
326 else { 327 else {
327 spin_lock_irqsave(&priv->lock, flags); 328 spin_lock_irqsave(&priv->lock, flags);
328 priv->baud_rate = n_baud_rate; 329 priv->baud_rate = new_baudrate;
329 priv->cbr_mask = baud_mask; 330 priv->cbr_mask = baud_mask;
330 priv->current_config = config; 331 priv->current_config = feature_buffer[4];
331 ++priv->cmd_count;
332 spin_unlock_irqrestore(&priv->lock, flags); 332 spin_unlock_irqrestore(&priv->lock, flags);
333 } 333 }
334 break; 334 break;
335 case CYPRESS_GET_CONFIG: 335 case CYPRESS_GET_CONFIG:
336 dbg("%s - retreiving serial line settings", __FUNCTION__); 336 dbg("%s - retreiving serial line settings", __FUNCTION__);
337 /* reset values in feature buffer */ 337 /* set initial values in feature buffer */
338 memset(feature_buffer, 0, 5); 338 memset(feature_buffer, 0, 8);
339 339
340 do {
340 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), 341 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
341 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 342 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
342 0x0300, 0, feature_buffer, 5, 500); 343 0x0300, 0, feature_buffer, 8, 500);
344
345 if (tries++ >= 3)
346 break;
347
348 if (retval == EPIPE)
349 usb_clear_halt(port->serial->dev, 0x00);
350 } while (retval != 5 && retval != ENODEV);
351
343 if (retval != 5) { 352 if (retval != 5) {
344 err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval); 353 err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval);
345 return retval; 354 return retval;
346 } else { 355 } else {
347 spin_lock_irqsave(&priv->lock, flags); 356 spin_lock_irqsave(&priv->lock, flags);
357
348 /* store the config in one byte, and later use bit masks to check values */ 358 /* store the config in one byte, and later use bit masks to check values */
349 priv->current_config = feature_buffer[4]; 359 priv->current_config = feature_buffer[4];
350 /* reverse the process above to get the baud_mask value */ 360 priv->baud_rate = *((u_int32_t *)feature_buffer);
351 n_baud_rate = 0; // reset bits
352 for (i = 0; i < 4; ++i) {
353 n_baud_rate |= ( feature_buffer[i] << (i*8) );
354 }
355 361
356 priv->baud_rate = n_baud_rate; 362 if ( (priv->cbr_mask = rate_to_mask(priv->baud_rate)) == 0x40)
357 if ( (priv->cbr_mask = rate_to_mask(n_baud_rate)) == 0x40)
358 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__); 363 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__);
359 ++priv->cmd_count;
360 spin_unlock_irqrestore(&priv->lock, flags); 364 spin_unlock_irqrestore(&priv->lock, flags);
361 } 365 }
362 break;
363 default:
364 err("%s - unsupported serial control command issued", __FUNCTION__);
365 } 366 }
367 spin_lock_irqsave(&priv->lock, flags);
368 ++priv->cmd_count;
369 spin_unlock_irqrestore(&priv->lock, flags);
370
366 return retval; 371 return retval;
367} /* cypress_serial_control */ 372} /* cypress_serial_control */
368 373
369 374
370/* given a baud mask, it will return speed on success */ 375/* given a baud mask, it will return integer baud on success */
371static int mask_to_rate (unsigned mask) 376static int mask_to_rate (unsigned mask)
372{ 377{
373 int rate; 378 int rate;
@@ -438,11 +443,12 @@ static int generic_startup (struct usb_serial *serial)
438 443
439 usb_reset_configuration (serial->dev); 444 usb_reset_configuration (serial->dev);
440 445
446 interval = 1;
441 priv->cmd_ctrl = 0; 447 priv->cmd_ctrl = 0;
442 priv->line_control = 0; 448 priv->line_control = 0;
443 priv->termios_initialized = 0; 449 priv->termios_initialized = 0;
444 priv->calledfromopen = 0;
445 priv->rx_flags = 0; 450 priv->rx_flags = 0;
451 priv->cbr_mask = B300;
446 usb_set_serial_port_data(serial->port[0], priv); 452 usb_set_serial_port_data(serial->port[0], priv);
447 453
448 return (0); 454 return (0);
@@ -513,7 +519,6 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
513 dbg("%s - port %d", __FUNCTION__, port->number); 519 dbg("%s - port %d", __FUNCTION__, port->number);
514 520
515 /* clear halts before open */ 521 /* clear halts before open */
516 usb_clear_halt(serial->dev, 0x00);
517 usb_clear_halt(serial->dev, 0x81); 522 usb_clear_halt(serial->dev, 0x81);
518 usb_clear_halt(serial->dev, 0x02); 523 usb_clear_halt(serial->dev, 0x02);
519 524
@@ -531,7 +536,6 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
531 /* raise both lines and set termios */ 536 /* raise both lines and set termios */
532 spin_lock_irqsave(&priv->lock, flags); 537 spin_lock_irqsave(&priv->lock, flags);
533 priv->line_control = CONTROL_DTR | CONTROL_RTS; 538 priv->line_control = CONTROL_DTR | CONTROL_RTS;
534 priv->calledfromopen = 1;
535 priv->cmd_ctrl = 1; 539 priv->cmd_ctrl = 1;
536 spin_unlock_irqrestore(&priv->lock, flags); 540 spin_unlock_irqrestore(&priv->lock, flags);
537 result = cypress_write(port, NULL, 0); 541 result = cypress_write(port, NULL, 0);
@@ -553,7 +557,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
553 usb_fill_int_urb(port->interrupt_in_urb, serial->dev, 557 usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
554 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), 558 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
555 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, 559 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
556 cypress_read_int_callback, port, port->interrupt_in_urb->interval); 560 cypress_read_int_callback, port, interval);
557 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 561 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
558 562
559 if (result){ 563 if (result){
@@ -680,12 +684,12 @@ static void cypress_send(struct usb_serial_port *port)
680 spin_lock_irqsave(&priv->lock, flags); 684 spin_lock_irqsave(&priv->lock, flags);
681 switch (port->interrupt_out_size) { 685 switch (port->interrupt_out_size) {
682 case 32: 686 case 32:
683 // this is for the CY7C64013... 687 /* this is for the CY7C64013... */
684 offset = 2; 688 offset = 2;
685 port->interrupt_out_buffer[0] = priv->line_control; 689 port->interrupt_out_buffer[0] = priv->line_control;
686 break; 690 break;
687 case 8: 691 case 8:
688 // this is for the CY7C63743... 692 /* this is for the CY7C63743... */
689 offset = 1; 693 offset = 1;
690 port->interrupt_out_buffer[0] = priv->line_control; 694 port->interrupt_out_buffer[0] = priv->line_control;
691 break; 695 break;
@@ -738,6 +742,7 @@ send:
738 742
739 port->interrupt_out_urb->transfer_buffer_length = actual_size; 743 port->interrupt_out_urb->transfer_buffer_length = actual_size;
740 port->interrupt_out_urb->dev = port->serial->dev; 744 port->interrupt_out_urb->dev = port->serial->dev;
745 port->interrupt_out_urb->interval = interval;
741 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); 746 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
742 if (result) { 747 if (result) {
743 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, 748 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__,
@@ -910,7 +915,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
910 unsigned cflag, iflag, baud_mask; 915 unsigned cflag, iflag, baud_mask;
911 unsigned long flags; 916 unsigned long flags;
912 __u8 oldlines; 917 __u8 oldlines;
913 int linechange; 918 int linechange = 0;
914 919
915 dbg("%s - port %d", __FUNCTION__, port->number); 920 dbg("%s - port %d", __FUNCTION__, port->number);
916 921
@@ -996,15 +1001,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
996 case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break; 1001 case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break;
997 default: dbg("%s - unknown masked baud rate", __FUNCTION__); 1002 default: dbg("%s - unknown masked baud rate", __FUNCTION__);
998 } 1003 }
999 priv->line_control |= CONTROL_DTR; 1004 priv->line_control = (CONTROL_DTR | CONTROL_RTS);
1000
1001 /* toggle CRTSCTS? - don't do this if being called from cypress_open */
1002 if (!priv->calledfromopen) {
1003 if (cflag & CRTSCTS)
1004 priv->line_control |= CONTROL_RTS;
1005 else
1006 priv->line_control &= ~CONTROL_RTS;
1007 }
1008 } 1005 }
1009 spin_unlock_irqrestore(&priv->lock, flags); 1006 spin_unlock_irqrestore(&priv->lock, flags);
1010 1007
@@ -1014,8 +1011,6 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1014 cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable, 1011 cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable,
1015 parity_type, 0, CYPRESS_SET_CONFIG); 1012 parity_type, 0, CYPRESS_SET_CONFIG);
1016 1013
1017 msleep(50); /* give some time between change and read (50ms) */
1018
1019 /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure 1014 /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure
1020 * this should confirm that all is working if it returns what we just set */ 1015 * this should confirm that all is working if it returns what we just set */
1021 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); 1016 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
@@ -1031,7 +1026,6 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1031 dbg("Using custom termios settings for a baud rate of 4800bps."); 1026 dbg("Using custom termios settings for a baud rate of 4800bps.");
1032 /* define custom termios settings for NMEA protocol */ 1027 /* define custom termios settings for NMEA protocol */
1033 1028
1034
1035 tty->termios->c_iflag /* input modes - */ 1029 tty->termios->c_iflag /* input modes - */
1036 &= ~(IGNBRK /* disable ignore break */ 1030 &= ~(IGNBRK /* disable ignore break */
1037 | BRKINT /* disable break causes interrupt */ 1031 | BRKINT /* disable break causes interrupt */
@@ -1052,23 +1046,16 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1052 | ISIG /* disable interrupt, quit, and suspend special characters */ 1046 | ISIG /* disable interrupt, quit, and suspend special characters */
1053 | IEXTEN); /* disable non-POSIX special characters */ 1047 | IEXTEN); /* disable non-POSIX special characters */
1054 1048
1055 } else if (priv->chiptype == CT_CYPHIDCOM) { 1049 } /* CT_CYPHIDCOM: Application should handle this for device */
1056
1057 // Software app handling it for device...
1058 1050
1059 }
1060 linechange = (priv->line_control != oldlines); 1051 linechange = (priv->line_control != oldlines);
1061 spin_unlock_irqrestore(&priv->lock, flags); 1052 spin_unlock_irqrestore(&priv->lock, flags);
1062 1053
1063 /* if necessary, set lines */ 1054 /* if necessary, set lines */
1064 if (!priv->calledfromopen && linechange) { 1055 if (linechange) {
1065 priv->cmd_ctrl = 1; 1056 priv->cmd_ctrl = 1;
1066 cypress_write(port, NULL, 0); 1057 cypress_write(port, NULL, 0);
1067 } 1058 }
1068
1069 if (priv->calledfromopen)
1070 priv->calledfromopen = 0;
1071
1072} /* cypress_set_termios */ 1059} /* cypress_set_termios */
1073 1060
1074 1061
@@ -1164,7 +1151,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1164 spin_lock_irqsave(&priv->lock, flags); 1151 spin_lock_irqsave(&priv->lock, flags);
1165 switch(urb->actual_length) { 1152 switch(urb->actual_length) {
1166 case 32: 1153 case 32:
1167 // This is for the CY7C64013... 1154 /* This is for the CY7C64013... */
1168 priv->current_status = data[0] & 0xF8; 1155 priv->current_status = data[0] & 0xF8;
1169 bytes = data[1]+2; 1156 bytes = data[1]+2;
1170 i=2; 1157 i=2;
@@ -1172,7 +1159,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1172 havedata = 1; 1159 havedata = 1;
1173 break; 1160 break;
1174 case 8: 1161 case 8:
1175 // This is for the CY7C63743... 1162 /* This is for the CY7C63743... */
1176 priv->current_status = data[0] & 0xF8; 1163 priv->current_status = data[0] & 0xF8;
1177 bytes = (data[0] & 0x07)+1; 1164 bytes = (data[0] & 0x07)+1;
1178 i=1; 1165 i=1;
@@ -1245,7 +1232,7 @@ continue_read:
1245 port->interrupt_in_urb->transfer_buffer, 1232 port->interrupt_in_urb->transfer_buffer,
1246 port->interrupt_in_urb->transfer_buffer_length, 1233 port->interrupt_in_urb->transfer_buffer_length,
1247 cypress_read_int_callback, port, 1234 cypress_read_int_callback, port,
1248 port->interrupt_in_urb->interval); 1235 interval);
1249 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1236 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1250 if (result) 1237 if (result)
1251 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 1238 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
@@ -1274,6 +1261,8 @@ static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs)
1274 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 1261 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
1275 priv->write_urb_in_use = 0; 1262 priv->write_urb_in_use = 0;
1276 return; 1263 return;
1264 case -EPIPE: /* no break needed */
1265 usb_clear_halt(port->serial->dev, 0x02);
1277 default: 1266 default:
1278 /* error in the urb, so we have to resubmit it */ 1267 /* error in the urb, so we have to resubmit it */
1279 dbg("%s - Overflow in write", __FUNCTION__); 1268 dbg("%s - Overflow in write", __FUNCTION__);
@@ -1535,3 +1524,5 @@ module_param(debug, bool, S_IRUGO | S_IWUSR);
1535MODULE_PARM_DESC(debug, "Debug enabled or not"); 1524MODULE_PARM_DESC(debug, "Debug enabled or not");
1536module_param(stats, bool, S_IRUGO | S_IWUSR); 1525module_param(stats, bool, S_IRUGO | S_IWUSR);
1537MODULE_PARM_DESC(stats, "Enable statistics or not"); 1526MODULE_PARM_DESC(stats, "Enable statistics or not");
1527module_param(interval, int, S_IRUGO | S_IWUSR);
1528MODULE_PARM_DESC(interval, "Overrides interrupt interval");
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4c788c767a97..52394f08a947 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -76,7 +76,7 @@
76 * Defererence pointers after any paranoid checks, not before. 76 * Defererence pointers after any paranoid checks, not before.
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR tranceiver using FT232BM chip. 79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip.
80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly 80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly
81 * at 100000 and RTS-CTS, so set custom divisor mode on startup. 81 * at 100000 and RTS-CTS, so set custom divisor mode on startup.
82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates.
@@ -91,7 +91,7 @@
91 * Minor whitespace and comment changes. 91 * Minor whitespace and comment changes.
92 * 92 *
93 * (12/Jun/2003) David Norwood 93 * (12/Jun/2003) David Norwood
94 * Added support for USB-UIRT IR tranceiver using 8U232AM chip. 94 * Added support for USB-UIRT IR transceiver using 8U232AM chip.
95 * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only 95 * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only
96 * operates properly at 312500, so set custom divisor mode on startup. 96 * operates properly at 312500, so set custom divisor mode on startup.
97 * 97 *
@@ -272,6 +272,7 @@ static int debug;
272 272
273static struct usb_device_id id_table_sio [] = { 273static struct usb_device_id id_table_sio [] = {
274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
275 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
275 { } /* Terminating entry */ 276 { } /* Terminating entry */
276}; 277};
277 278
@@ -296,7 +297,6 @@ static struct usb_device_id id_table_8U232AM [] = {
296 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) }, 297 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) },
297 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) }, 298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) },
298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) }, 299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) },
299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID, 0, 0x3ff) },
300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) }, 300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) },
301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
@@ -369,11 +369,14 @@ static struct usb_device_id id_table_8U232AM [] = {
369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) }, 369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
370 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) }, 370 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) },
371 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) }, 371 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) },
372 { USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0, 0x3ff) }, 372 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0, 0x3ff) },
373 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) }, 373 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) },
374 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) }, 374 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) },
375 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) }, 375 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) },
376 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) }, 376 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) },
377 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0, 0x3ff) },
378 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0, 0x3ff) },
379 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0, 0x3ff) },
377 { } /* Terminating entry */ 380 { } /* Terminating entry */
378}; 381};
379 382
@@ -382,7 +385,6 @@ static struct usb_device_id id_table_FT232BM [] = {
382 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) }, 385 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) },
383 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) }, 386 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) },
384 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) }, 387 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) },
385 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID, 0x400, 0xffff) },
386 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) }, 388 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) },
387 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) }, 389 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) },
388 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) }, 390 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) },
@@ -485,11 +487,15 @@ static struct usb_device_id id_table_FT232BM [] = {
485 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) }, 487 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) },
486 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) }, 488 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) },
487 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) }, 489 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) },
488 { USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0x400, 0xffff) }, 490 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0x400, 0xffff) },
489 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) }, 491 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) },
490 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) }, 492 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) },
491 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) }, 493 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) },
492 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) }, 494 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) },
495 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0x400, 0xffff) },
496 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0x400, 0xffff) },
497 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0x400, 0xffff) },
498 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
493 { } /* Terminating entry */ 499 { } /* Terminating entry */
494}; 500};
495 501
@@ -517,7 +523,6 @@ static struct usb_device_id id_table_combined [] = {
517 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 523 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
518 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 524 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
519 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 525 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
520 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID) },
521 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 526 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
522 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 527 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
523 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 528 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
@@ -596,6 +601,22 @@ static struct usb_device_id id_table_combined [] = {
596 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) }, 601 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
597 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) }, 602 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
598 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) }, 603 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
604 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) },
605 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) },
606 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) },
607 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) },
608 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) },
609 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) },
610 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) },
611 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) },
612 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) },
613 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) },
614 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) },
615 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) },
616 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) },
617 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) },
618 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
619 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
599 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, 620 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
600 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, 621 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
601 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, 622 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
@@ -609,11 +630,16 @@ static struct usb_device_id id_table_combined [] = {
609 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 630 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
610 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, 631 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) },
611 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, 632 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) },
612 { USB_DEVICE(FTDI_RM_VID, FTDI_RMCANVIEW_PID) }, 633 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
613 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 634 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
614 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 635 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
615 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, 636 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
616 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) }, 637 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) },
638 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID) },
639 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
640 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
641 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
642 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
617 { } /* Terminating entry */ 643 { } /* Terminating entry */
618}; 644};
619 645
@@ -1457,10 +1483,10 @@ static int ftdi_FT2232C_startup (struct usb_serial *serial)
1457 inter = serial->interface->altsetting->desc.bInterfaceNumber; 1483 inter = serial->interface->altsetting->desc.bInterfaceNumber;
1458 1484
1459 if (inter) { 1485 if (inter) {
1460 priv->interface = INTERFACE_B; 1486 priv->interface = PIT_SIOB;
1461 } 1487 }
1462 else { 1488 else {
1463 priv->interface = INTERFACE_A; 1489 priv->interface = PIT_SIOA;
1464 } 1490 }
1465 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */ 1491 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */
1466 1492
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index be5d60bf90b9..a52bb13a9ce4 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -26,7 +26,6 @@
26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */ 27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
29#define FTDI_8U232AM_ALT_ALT_PID 0xf3c0 /* FTDI's second alternate PID for above */
30#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 29#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
31#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ 30#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
32#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ 31#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
@@ -137,7 +136,7 @@
137/* 136/*
138 * Home Electronics (www.home-electro.com) USB gadgets 137 * Home Electronics (www.home-electro.com) USB gadgets
139 */ 138 */
140#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR tranceiver */ 139#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */
141 140
142/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */ 141/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
143/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */ 142/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
@@ -157,7 +156,8 @@
157 */ 156 */
158#define OCT_VID 0x0B39 /* OCT vendor ID */ 157#define OCT_VID 0x0B39 /* OCT vendor ID */
159/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */ 158/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
160/* Also rebadged as SIIG Inc. model US2308 */ 159/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
160/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
161#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */ 161#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
162 162
163/* an infrared receiver for user access control with IR tags */ 163/* an infrared receiver for user access control with IR tags */
@@ -236,10 +236,10 @@
236 236
237/* 237/*
238 * RM Michaelides CANview USB (http://www.rmcan.com) 238 * RM Michaelides CANview USB (http://www.rmcan.com)
239 * CAN filedbus interface adapter, addad by port GmbH www.port.de) 239 * CAN fieldbus interface adapter, added by port GmbH www.port.de)
240 * Ian Abbott changed the macro names for consistency.
240 */ 241 */
241#define FTDI_RM_VID 0x0403 /* Vendor Id */ 242#define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */
242#define FTDI_RMCANVIEW_PID 0xfd60 /* Product Id */
243 243
244/* 244/*
245 * EVER Eco Pro UPS (http://www.ever.com.pl/) 245 * EVER Eco Pro UPS (http://www.ever.com.pl/)
@@ -247,6 +247,26 @@
247 247
248#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */ 248#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */
249 249
250/*
251 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
252 * USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices
253 * and I'm not entirely sure which are used by which.
254 */
255#define FTDI_4N_GALAXY_DE_0_PID 0x8372
256#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
257#define FTDI_4N_GALAXY_DE_2_PID 0xF3C1
258
259/*
260 * Mobility Electronics products.
261 */
262#define MOBILITY_VID 0x1342
263#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
264
265/*
266 * Active Robots product ids.
267 */
268#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
269
250/* Commands */ 270/* Commands */
251#define FTDI_SIO_RESET 0 /* Reset the port */ 271#define FTDI_SIO_RESET 0 /* Reset the port */
252#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 272#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
@@ -259,10 +279,6 @@
259#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 279#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
260#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 280#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
261 281
262/* Port interface code for FT2232C */
263#define INTERFACE_A 1
264#define INTERFACE_B 2
265
266 282
267/* 283/*
268 * BmRequestType: 1100 0000b 284 * BmRequestType: 1100 0000b
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
new file mode 100644
index 000000000000..64d55fbd206e
--- /dev/null
+++ b/drivers/usb/serial/hp4x.c
@@ -0,0 +1,85 @@
1/*
2 * HP4x Calculators Serial USB driver
3 *
4 * Copyright (C) 2005 Arthur Huillet (ahuillet@users.sf.net)
5 * Copyright (C) 2001-2005 Greg Kroah-Hartman (greg@kroah.com)
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 * See Documentation/usb/usb-serial.txt for more information on using this driver
13 */
14
15#include <linux/config.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/tty.h>
19#include <linux/module.h>
20#include <linux/usb.h>
21#include "usb-serial.h"
22
23/*
24 * Version Information
25 */
26#define DRIVER_VERSION "v1.00"
27#define DRIVER_DESC "HP4x (48/49) Generic Serial driver"
28
29#define HP_VENDOR_ID 0x03f0
30#define HP49GP_PRODUCT_ID 0x0121
31
32static struct usb_device_id id_table [] = {
33 { USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) },
34 { } /* Terminating entry */
35};
36
37MODULE_DEVICE_TABLE(usb, id_table);
38
39static struct usb_driver hp49gp_driver = {
40 .owner = THIS_MODULE,
41 .name = "HP4X",
42 .probe = usb_serial_probe,
43 .disconnect = usb_serial_disconnect,
44 .id_table = id_table,
45};
46
47static struct usb_serial_device_type hp49gp_device = {
48 .owner = THIS_MODULE,
49 .name = "HP4X",
50 .id_table = id_table,
51 .num_interrupt_in = NUM_DONT_CARE,
52 .num_bulk_in = NUM_DONT_CARE,
53 .num_bulk_out = NUM_DONT_CARE,
54 .num_ports = 1,
55};
56
57static int __init hp49gp_init(void)
58{
59 int retval;
60 retval = usb_serial_register(&hp49gp_device);
61 if (retval)
62 goto failed_usb_serial_register;
63 retval = usb_register(&hp49gp_driver);
64 if (retval)
65 goto failed_usb_register;
66 info(DRIVER_DESC " " DRIVER_VERSION);
67 return 0;
68failed_usb_register:
69 usb_serial_deregister(&hp49gp_device);
70failed_usb_serial_register:
71 return retval;
72}
73
74static void __exit hp49gp_exit(void)
75{
76 usb_deregister(&hp49gp_driver);
77 usb_serial_deregister(&hp49gp_device);
78}
79
80module_init(hp49gp_init);
81module_exit(hp49gp_exit);
82
83MODULE_DESCRIPTION(DRIVER_DESC);
84MODULE_VERSION(DRIVER_VERSION);
85MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
index 8c1fa5e722b1..f1804fd5a3dd 100644
--- a/drivers/usb/serial/io_usbvend.h
+++ b/drivers/usb/serial/io_usbvend.h
@@ -289,7 +289,7 @@
289// 289//
290 290
291// 291//
292// Edgeport Compatiblity Descriptor 292// Edgeport Compatibility Descriptor
293// 293//
294// This descriptor is only returned by Edgeport-compatible devices 294// This descriptor is only returned by Edgeport-compatible devices
295// supporting the EPiC spec. True ION devices do not return this 295// supporting the EPiC spec. True ION devices do not return this
diff --git a/drivers/usb/serial/keyspan_usa90msg.h b/drivers/usb/serial/keyspan_usa90msg.h
index dd935b62c1a8..86708ecd8735 100644
--- a/drivers/usb/serial/keyspan_usa90msg.h
+++ b/drivers/usb/serial/keyspan_usa90msg.h
@@ -19,7 +19,7 @@
19 19
20 This file is available under a BSD-style copyright 20 This file is available under a BSD-style copyright
21 21
22 2. The name of InnoSys Incorprated may not be used to endorse or promote 22 2. The name of InnoSys Incorporated may not be used to endorse or promote
23 products derived from this software without specific prior written 23 products derived from this software without specific prior written
24 permission. 24 permission.
25 25
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index d76483706bc9..5a9321705a74 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -47,6 +47,7 @@
47#include <linux/cdrom.h> 47#include <linux/cdrom.h>
48#include <scsi/scsi.h> 48#include <scsi/scsi.h>
49#include <scsi/scsi_cmnd.h> 49#include <scsi/scsi_cmnd.h>
50#include <scsi/scsi_dbg.h>
50 51
51#include "debug.h" 52#include "debug.h"
52#include "scsi.h" 53#include "scsi.h"
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 7eff03d9b041..f3b60288696c 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -786,7 +786,7 @@ static int usbat_flash_check_media(struct us_data *us,
786 if (rc != USB_STOR_XFER_GOOD) 786 if (rc != USB_STOR_XFER_GOOD)
787 return USB_STOR_TRANSPORT_ERROR; 787 return USB_STOR_TRANSPORT_ERROR;
788 788
789 // Check for media existance 789 // Check for media existence
790 rc = usbat_flash_check_media_present(uio); 790 rc = usbat_flash_check_media_present(uio);
791 if (rc == USBAT_FLASH_MEDIA_NONE) { 791 if (rc == USBAT_FLASH_MEDIA_NONE) {
792 info->sense_key = 0x02; 792 info->sense_key = 0x02;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index fa68dea6bc6f..d2891f475793 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1,5 +1,5 @@
1/* Driver for USB Mass Storage compliant devices 1/* Driver for USB Mass Storage compliant devices
2 * Ununsual Devices File 2 * Unusual Devices File
3 * 3 *
4 * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $ 4 * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $
5 * 5 *
@@ -48,6 +48,14 @@
48 * USB development list <linux-usb-devel@lists.sourceforge.net>. 48 * USB development list <linux-usb-devel@lists.sourceforge.net>.
49 */ 49 */
50 50
51/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr>
52 */
53UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
54 "ATMEL",
55 "SND1 Storage",
56 US_SC_DEVICE, US_PR_DEVICE, NULL,
57 US_FL_IGNORE_RESIDUE),
58
51UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, 59UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100,
52 "Mitsumi", 60 "Mitsumi",
53 "USB FDD", 61 "USB FDD",
@@ -517,14 +525,32 @@ UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110,
517 0 ), 525 0 ),
518#endif 526#endif
519 527
528/* Submitted by Sven Anderson <sven-linux@anderson.de>
529 * There are at least four ProductIDs used for iPods, so I added 0x1202 and
530 * 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice appears
531 * to change with firmware updates, I changed the range to maximum for all
532 * iPod entries.
533 */
534UNUSUAL_DEV( 0x05ac, 0x1202, 0x0000, 0x9999,
535 "Apple",
536 "iPod",
537 US_SC_DEVICE, US_PR_DEVICE, NULL,
538 US_FL_FIX_CAPACITY ),
539
520/* Reported by Avi Kivity <avi@argo.co.il> */ 540/* Reported by Avi Kivity <avi@argo.co.il> */
521UNUSUAL_DEV( 0x05ac, 0x1203, 0x0001, 0x0001, 541UNUSUAL_DEV( 0x05ac, 0x1203, 0x0000, 0x9999,
522 "Apple", 542 "Apple",
523 "iPod", 543 "iPod",
524 US_SC_DEVICE, US_PR_DEVICE, NULL, 544 US_SC_DEVICE, US_PR_DEVICE, NULL,
525 US_FL_FIX_CAPACITY ), 545 US_FL_FIX_CAPACITY ),
526 546
527UNUSUAL_DEV( 0x05ac, 0x1205, 0x0001, 0x0001, 547UNUSUAL_DEV( 0x05ac, 0x1204, 0x0000, 0x9999,
548 "Apple",
549 "iPod",
550 US_SC_DEVICE, US_PR_DEVICE, NULL,
551 US_FL_FIX_CAPACITY ),
552
553UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
528 "Apple", 554 "Apple",
529 "iPod", 555 "iPod",
530 US_SC_DEVICE, US_PR_DEVICE, NULL, 556 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -976,6 +1002,13 @@ UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x9999,
976 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1002 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
977 0 ), 1003 0 ),
978 1004
1005/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1006UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1007 "Minolta",
1008 "Dimage Z10",
1009 US_SC_DEVICE, US_PR_DEVICE, NULL,
1010 0 ),
1011
979/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */ 1012/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */
980UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110, 1013UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110,
981 "SWISSBIT", 1014 "SWISSBIT",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 2a1c5965de22..6be8fbec0a0e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -198,6 +198,14 @@ config FB_SA1100
198 If you plan to use the LCD display with your SA-1100 system, say 198 If you plan to use the LCD display with your SA-1100 system, say
199 Y here. 199 Y here.
200 200
201config FB_IMX
202 tristate "Motorola i.MX LCD support"
203 depends on FB && ARM && ARCH_IMX
204 select FB_CFB_FILLRECT
205 select FB_CFB_COPYAREA
206 select FB_CFB_IMAGEBLIT
207 select FB_SOFT_CURSOR
208
201config FB_CYBER2000 209config FB_CYBER2000
202 tristate "CyberPro 2000/2010/5000 support" 210 tristate "CyberPro 2000/2010/5000 support"
203 depends on FB && PCI && (BROKEN || !SPARC64) 211 depends on FB && PCI && (BROKEN || !SPARC64)
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 92265b741dc3..bd8dc0ffe723 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -90,6 +90,7 @@ obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
90obj-$(CONFIG_FB_MAXINE) += maxinefb.o 90obj-$(CONFIG_FB_MAXINE) += maxinefb.o
91obj-$(CONFIG_FB_TX3912) += tx3912fb.o 91obj-$(CONFIG_FB_TX3912) += tx3912fb.o
92obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o 92obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o
93obj-$(CONFIG_FB_IMX) += imxfb.o
93 94
94# Platform or fallback drivers go here 95# Platform or fallback drivers go here
95obj-$(CONFIG_FB_VESA) += vesafb.o 96obj-$(CONFIG_FB_VESA) += vesafb.o
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index acdba0c67fb8..321dbe91dc14 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -125,28 +125,28 @@ clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
125 case 2: 125 case 2:
126 case 4: 126 case 4:
127 case 8: 127 case 8:
128 var->red.length = 8; 128 var->red.length = var->bits_per_pixel;
129 var->red.offset = 0; 129 var->red.offset = 0;
130 var->green.length = 8; 130 var->green.length = var->bits_per_pixel;
131 var->green.offset = 0; 131 var->green.offset = 0;
132 var->blue.length = 8; 132 var->blue.length = var->bits_per_pixel;
133 var->blue.offset = 0; 133 var->blue.offset = 0;
134 break; 134 break;
135 case 16: 135 case 16:
136 var->red.length = 5; 136 var->red.length = 5;
137 var->green.length = 5; 137 var->green.length = 6;
138 var->blue.length = 5; 138 var->blue.length = 5;
139 if (fb->panel->cntl & CNTL_BGR) { 139 if (fb->panel->cntl & CNTL_BGR) {
140 var->red.offset = 10; 140 var->red.offset = 11;
141 var->green.offset = 5; 141 var->green.offset = 5;
142 var->blue.offset = 0; 142 var->blue.offset = 0;
143 } else { 143 } else {
144 var->red.offset = 0; 144 var->red.offset = 0;
145 var->green.offset = 5; 145 var->green.offset = 5;
146 var->blue.offset = 10; 146 var->blue.offset = 11;
147 } 147 }
148 break; 148 break;
149 case 24: 149 case 32:
150 if (fb->panel->cntl & CNTL_LCDTFT) { 150 if (fb->panel->cntl & CNTL_LCDTFT) {
151 var->red.length = 8; 151 var->red.length = 8;
152 var->green.length = 8; 152 var->green.length = 8;
@@ -178,6 +178,12 @@ static int clcdfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
178 178
179 if (fb->board->check) 179 if (fb->board->check)
180 ret = fb->board->check(fb, var); 180 ret = fb->board->check(fb, var);
181
182 if (ret == 0 &&
183 var->xres_virtual * var->bits_per_pixel / 8 *
184 var->yres_virtual > fb->fb.fix.smem_len)
185 ret = -EINVAL;
186
181 if (ret == 0) 187 if (ret == 0)
182 ret = clcdfb_set_bitfields(fb, var); 188 ret = clcdfb_set_bitfields(fb, var);
183 189
@@ -250,7 +256,7 @@ clcdfb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,
250 convert_bitfield(green, &fb->fb.var.green) | 256 convert_bitfield(green, &fb->fb.var.green) |
251 convert_bitfield(red, &fb->fb.var.red); 257 convert_bitfield(red, &fb->fb.var.red);
252 258
253 if (fb->fb.var.bits_per_pixel == 8 && regno < 256) { 259 if (fb->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) {
254 int hw_reg = CLCD_PALETTE + ((regno * 2) & ~3); 260 int hw_reg = CLCD_PALETTE + ((regno * 2) & ~3);
255 u32 val, mask, newval; 261 u32 val, mask, newval;
256 262
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index e8eb124754b1..ee25b9e8db60 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -1057,13 +1057,14 @@ static int radeonfb_blank (int blank, struct fb_info *info)
1057 return radeon_screen_blank(rinfo, blank, 0); 1057 return radeon_screen_blank(rinfo, blank, 0);
1058} 1058}
1059 1059
1060static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green, 1060static int radeon_setcolreg (unsigned regno, unsigned red, unsigned green,
1061 unsigned blue, unsigned transp, struct fb_info *info) 1061 unsigned blue, unsigned transp,
1062 struct radeonfb_info *rinfo)
1062{ 1063{
1063 struct radeonfb_info *rinfo = info->par;
1064 u32 pindex; 1064 u32 pindex;
1065 unsigned int i; 1065 unsigned int i;
1066 1066
1067
1067 if (regno > 255) 1068 if (regno > 255)
1068 return 1; 1069 return 1;
1069 1070
@@ -1078,20 +1079,7 @@ static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1078 pindex = regno; 1079 pindex = regno;
1079 1080
1080 if (!rinfo->asleep) { 1081 if (!rinfo->asleep) {
1081 u32 dac_cntl2, vclk_cntl = 0;
1082
1083 radeon_fifo_wait(9); 1082 radeon_fifo_wait(9);
1084 if (rinfo->is_mobility) {
1085 vclk_cntl = INPLL(VCLK_ECP_CNTL);
1086 OUTPLL(VCLK_ECP_CNTL, vclk_cntl & ~PIXCLK_DAC_ALWAYS_ONb);
1087 }
1088
1089 /* Make sure we are on first palette */
1090 if (rinfo->has_CRTC2) {
1091 dac_cntl2 = INREG(DAC_CNTL2);
1092 dac_cntl2 &= ~DAC2_PALETTE_ACCESS_CNTL;
1093 OUTREG(DAC_CNTL2, dac_cntl2);
1094 }
1095 1083
1096 if (rinfo->bpp == 16) { 1084 if (rinfo->bpp == 16) {
1097 pindex = regno * 8; 1085 pindex = regno * 8;
@@ -1101,24 +1089,27 @@ static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1101 if (rinfo->depth == 15 && regno > 31) 1089 if (rinfo->depth == 15 && regno > 31)
1102 return 1; 1090 return 1;
1103 1091
1104 /* For 565, the green component is mixed one order below */ 1092 /* For 565, the green component is mixed one order
1093 * below
1094 */
1105 if (rinfo->depth == 16) { 1095 if (rinfo->depth == 16) {
1106 OUTREG(PALETTE_INDEX, pindex>>1); 1096 OUTREG(PALETTE_INDEX, pindex>>1);
1107 OUTREG(PALETTE_DATA, (rinfo->palette[regno>>1].red << 16) | 1097 OUTREG(PALETTE_DATA,
1108 (green << 8) | (rinfo->palette[regno>>1].blue)); 1098 (rinfo->palette[regno>>1].red << 16) |
1099 (green << 8) |
1100 (rinfo->palette[regno>>1].blue));
1109 green = rinfo->palette[regno<<1].green; 1101 green = rinfo->palette[regno<<1].green;
1110 } 1102 }
1111 } 1103 }
1112 1104
1113 if (rinfo->depth != 16 || regno < 32) { 1105 if (rinfo->depth != 16 || regno < 32) {
1114 OUTREG(PALETTE_INDEX, pindex); 1106 OUTREG(PALETTE_INDEX, pindex);
1115 OUTREG(PALETTE_DATA, (red << 16) | (green << 8) | blue); 1107 OUTREG(PALETTE_DATA, (red << 16) |
1108 (green << 8) | blue);
1116 } 1109 }
1117 if (rinfo->is_mobility)
1118 OUTPLL(VCLK_ECP_CNTL, vclk_cntl);
1119 } 1110 }
1120 if (regno < 16) { 1111 if (regno < 16) {
1121 u32 *pal = info->pseudo_palette; 1112 u32 *pal = rinfo->info->pseudo_palette;
1122 switch (rinfo->depth) { 1113 switch (rinfo->depth) {
1123 case 15: 1114 case 15:
1124 pal[regno] = (regno << 10) | (regno << 5) | regno; 1115 pal[regno] = (regno << 10) | (regno << 5) | regno;
@@ -1138,6 +1129,84 @@ static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1138 return 0; 1129 return 0;
1139} 1130}
1140 1131
1132static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1133 unsigned blue, unsigned transp,
1134 struct fb_info *info)
1135{
1136 struct radeonfb_info *rinfo = info->par;
1137 u32 dac_cntl2, vclk_cntl = 0;
1138 int rc;
1139
1140 if (!rinfo->asleep) {
1141 if (rinfo->is_mobility) {
1142 vclk_cntl = INPLL(VCLK_ECP_CNTL);
1143 OUTPLL(VCLK_ECP_CNTL,
1144 vclk_cntl & ~PIXCLK_DAC_ALWAYS_ONb);
1145 }
1146
1147 /* Make sure we are on first palette */
1148 if (rinfo->has_CRTC2) {
1149 dac_cntl2 = INREG(DAC_CNTL2);
1150 dac_cntl2 &= ~DAC2_PALETTE_ACCESS_CNTL;
1151 OUTREG(DAC_CNTL2, dac_cntl2);
1152 }
1153 }
1154
1155 rc = radeon_setcolreg (regno, red, green, blue, transp, rinfo);
1156
1157 if (!rinfo->asleep && rinfo->is_mobility)
1158 OUTPLL(VCLK_ECP_CNTL, vclk_cntl);
1159
1160 return rc;
1161}
1162
1163static int radeonfb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
1164{
1165 struct radeonfb_info *rinfo = info->par;
1166 u16 *red, *green, *blue, *transp;
1167 u32 dac_cntl2, vclk_cntl = 0;
1168 int i, start, rc = 0;
1169
1170 if (!rinfo->asleep) {
1171 if (rinfo->is_mobility) {
1172 vclk_cntl = INPLL(VCLK_ECP_CNTL);
1173 OUTPLL(VCLK_ECP_CNTL,
1174 vclk_cntl & ~PIXCLK_DAC_ALWAYS_ONb);
1175 }
1176
1177 /* Make sure we are on first palette */
1178 if (rinfo->has_CRTC2) {
1179 dac_cntl2 = INREG(DAC_CNTL2);
1180 dac_cntl2 &= ~DAC2_PALETTE_ACCESS_CNTL;
1181 OUTREG(DAC_CNTL2, dac_cntl2);
1182 }
1183 }
1184
1185 red = cmap->red;
1186 green = cmap->green;
1187 blue = cmap->blue;
1188 transp = cmap->transp;
1189 start = cmap->start;
1190
1191 for (i = 0; i < cmap->len; i++) {
1192 u_int hred, hgreen, hblue, htransp = 0xffff;
1193
1194 hred = *red++;
1195 hgreen = *green++;
1196 hblue = *blue++;
1197 if (transp)
1198 htransp = *transp++;
1199 rc = radeon_setcolreg (start++, hred, hgreen, hblue, htransp,
1200 rinfo);
1201 if (rc)
1202 break;
1203 }
1204
1205 if (!rinfo->asleep && rinfo->is_mobility)
1206 OUTPLL(VCLK_ECP_CNTL, vclk_cntl);
1207
1208 return rc;
1209}
1141 1210
1142static void radeon_save_state (struct radeonfb_info *rinfo, 1211static void radeon_save_state (struct radeonfb_info *rinfo,
1143 struct radeon_regs *save) 1212 struct radeon_regs *save)
@@ -1796,6 +1865,7 @@ static struct fb_ops radeonfb_ops = {
1796 .fb_check_var = radeonfb_check_var, 1865 .fb_check_var = radeonfb_check_var,
1797 .fb_set_par = radeonfb_set_par, 1866 .fb_set_par = radeonfb_set_par,
1798 .fb_setcolreg = radeonfb_setcolreg, 1867 .fb_setcolreg = radeonfb_setcolreg,
1868 .fb_setcmap = radeonfb_setcmap,
1799 .fb_pan_display = radeonfb_pan_display, 1869 .fb_pan_display = radeonfb_pan_display,
1800 .fb_blank = radeonfb_blank, 1870 .fb_blank = radeonfb_blank,
1801 .fb_ioctl = radeonfb_ioctl, 1871 .fb_ioctl = radeonfb_ioctl,
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 59e3b4b4e7e3..b209adbd508a 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -906,10 +906,13 @@ static void fbcon_init(struct vc_data *vc, int init)
906 struct vc_data *svc = *default_mode; 906 struct vc_data *svc = *default_mode;
907 struct display *t, *p = &fb_display[vc->vc_num]; 907 struct display *t, *p = &fb_display[vc->vc_num];
908 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; 908 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
909 int cap = info->flags; 909 int cap;
910 910
911 if (info_idx == -1 || info == NULL) 911 if (info_idx == -1 || info == NULL)
912 return; 912 return;
913
914 cap = info->flags;
915
913 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || 916 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
914 (info->fix.type == FB_TYPE_TEXT)) 917 (info->fix.type == FB_TYPE_TEXT))
915 logo = 0; 918 logo = 0;
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 7d1ae06667c6..bcf59b28a14f 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -337,6 +337,8 @@ static void vgacon_init(struct vc_data *c, int init)
337 c->vc_scan_lines = vga_scan_lines; 337 c->vc_scan_lines = vga_scan_lines;
338 c->vc_font.height = vga_video_font_height; 338 c->vc_font.height = vga_video_font_height;
339 c->vc_complement_mask = 0x7700; 339 c->vc_complement_mask = 0x7700;
340 if (vga_512_chars)
341 c->vc_hi_font_mask = 0x0800;
340 p = *c->vc_uni_pagedir_loc; 342 p = *c->vc_uni_pagedir_loc;
341 if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir || 343 if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir ||
342 !--c->vc_uni_pagedir_loc[1]) 344 !--c->vc_uni_pagedir_loc[1])
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 8b1b7c687a99..3894b2a501d6 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -90,6 +90,8 @@ struct cfb_info {
90 */ 90 */
91 u_char ramdac_ctrl; 91 u_char ramdac_ctrl;
92 u_char ramdac_powerdown; 92 u_char ramdac_powerdown;
93
94 u32 pseudo_palette[16];
93}; 95};
94 96
95static char *default_font = "Acorn8x8"; 97static char *default_font = "Acorn8x8";
@@ -1223,9 +1225,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
1223{ 1225{
1224 struct cfb_info *cfb; 1226 struct cfb_info *cfb;
1225 1227
1226 cfb = kmalloc(sizeof(struct cfb_info) + 1228 cfb = kmalloc(sizeof(struct cfb_info), GFP_KERNEL);
1227 sizeof(u32) * 16, GFP_KERNEL);
1228
1229 if (!cfb) 1229 if (!cfb)
1230 return NULL; 1230 return NULL;
1231 1231
@@ -1281,7 +1281,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
1281 1281
1282 cfb->fb.fbops = &cyber2000fb_ops; 1282 cfb->fb.fbops = &cyber2000fb_ops;
1283 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 1283 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1284 cfb->fb.pseudo_palette = (void *)(cfb + 1); 1284 cfb->fb.pseudo_palette = cfb->pseudo_palette;
1285 1285
1286 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0); 1286 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0);
1287 1287
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index c51f8fb5c1de..4e5ce8f7d65e 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -222,8 +222,11 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
222 transp = cmap->transp; 222 transp = cmap->transp;
223 start = cmap->start; 223 start = cmap->start;
224 224
225 if (start < 0 || !info->fbops->fb_setcolreg) 225 if (start < 0 || (!info->fbops->fb_setcolreg &&
226 !info->fbops->fb_setcmap))
226 return -EINVAL; 227 return -EINVAL;
228 if (info->fbops->fb_setcmap)
229 return info->fbops->fb_setcmap(cmap, info);
227 for (i = 0; i < cmap->len; i++) { 230 for (i = 0; i < cmap->len; i++) {
228 hred = *red++; 231 hred = *red++;
229 hgreen = *green++; 232 hgreen = *green++;
@@ -250,8 +253,33 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
250 transp = cmap->transp; 253 transp = cmap->transp;
251 start = cmap->start; 254 start = cmap->start;
252 255
253 if (start < 0 || !info->fbops->fb_setcolreg) 256 if (start < 0 || (!info->fbops->fb_setcolreg &&
257 !info->fbops->fb_setcmap))
254 return -EINVAL; 258 return -EINVAL;
259
260 /* If we can batch, do it */
261 if (info->fbops->fb_setcmap && cmap->len > 1) {
262 struct fb_cmap umap;
263 int size = cmap->len * sizeof(u16);
264 int rc;
265
266 memset(&umap, 0, sizeof(struct fb_cmap));
267 rc = fb_alloc_cmap(&umap, cmap->len, transp != NULL);
268 if (rc)
269 return rc;
270 if (copy_from_user(umap.red, red, size) ||
271 copy_from_user(umap.green, green, size) ||
272 copy_from_user(umap.blue, blue, size) ||
273 (transp && copy_from_user(umap.transp, transp, size))) {
274 rc = -EFAULT;
275 }
276 umap.start = start;
277 if (rc == 0)
278 rc = info->fbops->fb_setcmap(&umap, info);
279 fb_dealloc_cmap(&umap);
280 return rc;
281 }
282
255 for (i = 0; i < cmap->len; i++, red++, blue++, green++) { 283 for (i = 0; i < cmap->len; i++, red++, blue++, green++) {
256 if (get_user(hred, red) || 284 if (get_user(hred, red) ||
257 get_user(hgreen, green) || 285 get_user(hgreen, green) ||
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 25f460ca0daf..7705070191d9 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1257,6 +1257,8 @@ int fb_new_modelist(struct fb_info *info)
1257static char *video_options[FB_MAX]; 1257static char *video_options[FB_MAX];
1258static int ofonly; 1258static int ofonly;
1259 1259
1260extern const char *global_mode_option;
1261
1260/** 1262/**
1261 * fb_get_options - get kernel boot parameters 1263 * fb_get_options - get kernel boot parameters
1262 * @name: framebuffer name as it would appear in 1264 * @name: framebuffer name as it would appear in
@@ -1297,9 +1299,6 @@ int fb_get_options(char *name, char **option)
1297 return retval; 1299 return retval;
1298} 1300}
1299 1301
1300
1301extern const char *global_mode_option;
1302
1303/** 1302/**
1304 * video_setup - process command line options 1303 * video_setup - process command line options
1305 * @options: string of options 1304 * @options: string of options
@@ -1313,7 +1312,7 @@ extern const char *global_mode_option;
1313 * Returns zero. 1312 * Returns zero.
1314 * 1313 *
1315 */ 1314 */
1316int __init video_setup(char *options) 1315static int __init video_setup(char *options)
1317{ 1316{
1318 int i, global = 0; 1317 int i, global = 0;
1319 1318
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 978def013587..6cd1976548d4 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -34,7 +34,6 @@
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/pci-bridge.h> 35#include <asm/pci-bridge.h>
36#endif 36#endif
37#include <video/edid.h>
38#include "edid.h" 37#include "edid.h"
39 38
40/* 39/*
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 2bdda4010b81..c78a2c5961d3 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -354,7 +354,7 @@ static ssize_t show_pan(struct class_device *class_device, char *buf)
354 fb_info->var.xoffset); 354 fb_info->var.xoffset);
355} 355}
356 356
357struct class_device_attribute class_device_attrs[] = { 357static struct class_device_attribute class_device_attrs[] = {
358 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), 358 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp),
359 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), 359 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank),
360 __ATTR(color_map, S_IRUGO|S_IWUSR, show_cmap, store_cmap), 360 __ATTR(color_map, S_IRUGO|S_IWUSR, show_cmap, store_cmap),
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 9ec8781794c0..a9a618f2aa6a 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -999,8 +999,16 @@ static int i810_check_params(struct fb_var_screeninfo *var,
999 info->monspecs.dclkmin = 15000000; 999 info->monspecs.dclkmin = 15000000;
1000 1000
1001 if (fb_validate_mode(var, info)) { 1001 if (fb_validate_mode(var, info)) {
1002 if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) 1002 if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) {
1003 int default_sync = (info->monspecs.hfmin-HFMIN)
1004 |(info->monspecs.hfmax-HFMAX)
1005 |(info->monspecs.vfmin-VFMIN)
1006 |(info->monspecs.vfmax-VFMAX);
1007 printk("i810fb: invalid video mode%s\n",
1008 default_sync ? "" :
1009 ". Specifying vsyncN/hsyncN parameters may help");
1003 return -EINVAL; 1010 return -EINVAL;
1011 }
1004 } 1012 }
1005 1013
1006 var->xres = xres; 1014 var->xres = xres;
@@ -2023,10 +2031,10 @@ MODULE_PARM_DESC(vyres, "Virtual vertical resolution in scanlines"
2023 " (default = 480)"); 2031 " (default = 480)");
2024module_param(hsync1, int, 0); 2032module_param(hsync1, int, 0);
2025MODULE_PARM_DESC(hsync1, "Minimum horizontal frequency of monitor in KHz" 2033MODULE_PARM_DESC(hsync1, "Minimum horizontal frequency of monitor in KHz"
2026 " (default = 31)"); 2034 " (default = 29)");
2027module_param(hsync2, int, 0); 2035module_param(hsync2, int, 0);
2028MODULE_PARM_DESC(hsync2, "Maximum horizontal frequency of monitor in KHz" 2036MODULE_PARM_DESC(hsync2, "Maximum horizontal frequency of monitor in KHz"
2029 " (default = 31)"); 2037 " (default = 30)");
2030module_param(vsync1, int, 0); 2038module_param(vsync1, int, 0);
2031MODULE_PARM_DESC(vsync1, "Minimum vertical frequency of monitor in Hz" 2039MODULE_PARM_DESC(vsync1, "Minimum vertical frequency of monitor in Hz"
2032 " (default = 50)"); 2040 " (default = 50)");
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 5a72ca3c0138..7b9bf45ab6fe 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -1287,12 +1287,12 @@ imsttfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
1287 case FBIMSTT_SETCMAPREG: 1287 case FBIMSTT_SETCMAPREG:
1288 if (copy_from_user(reg, argp, 8) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0])) 1288 if (copy_from_user(reg, argp, 8) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0]))
1289 return -EFAULT; 1289 return -EFAULT;
1290 write_reg_le32(((u_int *)par->cmap_regs), reg[0], reg[1]); 1290 write_reg_le32(((u_int __iomem *)par->cmap_regs), reg[0], reg[1]);
1291 return 0; 1291 return 0;
1292 case FBIMSTT_GETCMAPREG: 1292 case FBIMSTT_GETCMAPREG:
1293 if (copy_from_user(reg, argp, 4) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0])) 1293 if (copy_from_user(reg, argp, 4) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0]))
1294 return -EFAULT; 1294 return -EFAULT;
1295 reg[1] = read_reg_le32(((u_int *)par->cmap_regs), reg[0]); 1295 reg[1] = read_reg_le32(((u_int __iomem *)par->cmap_regs), reg[0]);
1296 if (copy_to_user((void __user *)(arg + 4), &reg[1], 4)) 1296 if (copy_to_user((void __user *)(arg + 4), &reg[1], 4))
1297 return -EFAULT; 1297 return -EFAULT;
1298 return 0; 1298 return 0;
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
new file mode 100644
index 000000000000..8fe1c12a17bd
--- /dev/null
+++ b/drivers/video/imxfb.c
@@ -0,0 +1,695 @@
1/*
2 * linux/drivers/video/imxfb.c
3 *
4 * Freescale i.MX Frame Buffer device driver
5 *
6 * Copyright (C) 2004 Sascha Hauer, Pengutronix
7 * Based on acornfb.c Copyright (C) Russell King.
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file COPYING in the main directory of this archive for
11 * more details.
12 *
13 * Please direct your questions and comments on this driver to the following
14 * email address:
15 *
16 * linux-arm-kernel@lists.arm.linux.org.uk
17 */
18
19//#define DEBUG 1
20
21#include <linux/config.h>
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/sched.h>
25#include <linux/errno.h>
26#include <linux/string.h>
27#include <linux/interrupt.h>
28#include <linux/slab.h>
29#include <linux/fb.h>
30#include <linux/delay.h>
31#include <linux/init.h>
32#include <linux/ioport.h>
33#include <linux/cpufreq.h>
34#include <linux/device.h>
35#include <linux/dma-mapping.h>
36
37#include <asm/hardware.h>
38#include <asm/io.h>
39#include <asm/mach-types.h>
40#include <asm/uaccess.h>
41#include <asm/arch/imxfb.h>
42
43/*
44 * Complain if VAR is out of range.
45 */
46#define DEBUG_VAR 1
47
48#include "imxfb.h"
49
50static struct imxfb_rgb def_rgb_16 = {
51 .red = { .offset = 8, .length = 4, },
52 .green = { .offset = 4, .length = 4, },
53 .blue = { .offset = 0, .length = 4, },
54 .transp = { .offset = 0, .length = 0, },
55};
56
57static struct imxfb_rgb def_rgb_8 = {
58 .red = { .offset = 0, .length = 8, },
59 .green = { .offset = 0, .length = 8, },
60 .blue = { .offset = 0, .length = 8, },
61 .transp = { .offset = 0, .length = 0, },
62};
63
64static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info);
65
66static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
67{
68 chan &= 0xffff;
69 chan >>= 16 - bf->length;
70 return chan << bf->offset;
71}
72
73#define LCDC_PALETTE(x) __REG2(IMX_LCDC_BASE+0x800, (x)<<2)
74static int
75imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
76 u_int trans, struct fb_info *info)
77{
78 struct imxfb_info *fbi = info->par;
79 u_int val, ret = 1;
80
81#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
82 if (regno < fbi->palette_size) {
83 val = (CNVT_TOHW(red, 4) << 8) |
84 (CNVT_TOHW(green,4) << 4) |
85 CNVT_TOHW(blue, 4);
86
87 LCDC_PALETTE(regno) = val;
88 ret = 0;
89 }
90 return ret;
91}
92
93static int
94imxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
95 u_int trans, struct fb_info *info)
96{
97 struct imxfb_info *fbi = info->par;
98 unsigned int val;
99 int ret = 1;
100
101 /*
102 * If inverse mode was selected, invert all the colours
103 * rather than the register number. The register number
104 * is what you poke into the framebuffer to produce the
105 * colour you requested.
106 */
107 if (fbi->cmap_inverse) {
108 red = 0xffff - red;
109 green = 0xffff - green;
110 blue = 0xffff - blue;
111 }
112
113 /*
114 * If greyscale is true, then we convert the RGB value
115 * to greyscale no mater what visual we are using.
116 */
117 if (info->var.grayscale)
118 red = green = blue = (19595 * red + 38470 * green +
119 7471 * blue) >> 16;
120
121 switch (info->fix.visual) {
122 case FB_VISUAL_TRUECOLOR:
123 /*
124 * 12 or 16-bit True Colour. We encode the RGB value
125 * according to the RGB bitfield information.
126 */
127 if (regno < 16) {
128 u32 *pal = info->pseudo_palette;
129
130 val = chan_to_field(red, &info->var.red);
131 val |= chan_to_field(green, &info->var.green);
132 val |= chan_to_field(blue, &info->var.blue);
133
134 pal[regno] = val;
135 ret = 0;
136 }
137 break;
138
139 case FB_VISUAL_STATIC_PSEUDOCOLOR:
140 case FB_VISUAL_PSEUDOCOLOR:
141 ret = imxfb_setpalettereg(regno, red, green, blue, trans, info);
142 break;
143 }
144
145 return ret;
146}
147
148/*
149 * imxfb_check_var():
150 * Round up in the following order: bits_per_pixel, xres,
151 * yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
152 * bitfields, horizontal timing, vertical timing.
153 */
154static int
155imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
156{
157 struct imxfb_info *fbi = info->par;
158 int rgbidx;
159
160 if (var->xres < MIN_XRES)
161 var->xres = MIN_XRES;
162 if (var->yres < MIN_YRES)
163 var->yres = MIN_YRES;
164 if (var->xres > fbi->max_xres)
165 var->xres = fbi->max_xres;
166 if (var->yres > fbi->max_yres)
167 var->yres = fbi->max_yres;
168 var->xres_virtual = max(var->xres_virtual, var->xres);
169 var->yres_virtual = max(var->yres_virtual, var->yres);
170
171 pr_debug("var->bits_per_pixel=%d\n", var->bits_per_pixel);
172 switch (var->bits_per_pixel) {
173 case 16:
174 rgbidx = RGB_16;
175 break;
176 case 8:
177 rgbidx = RGB_8;
178 break;
179 default:
180 rgbidx = RGB_16;
181 }
182
183 /*
184 * Copy the RGB parameters for this display
185 * from the machine specific parameters.
186 */
187 var->red = fbi->rgb[rgbidx]->red;
188 var->green = fbi->rgb[rgbidx]->green;
189 var->blue = fbi->rgb[rgbidx]->blue;
190 var->transp = fbi->rgb[rgbidx]->transp;
191
192 pr_debug("RGBT length = %d:%d:%d:%d\n",
193 var->red.length, var->green.length, var->blue.length,
194 var->transp.length);
195
196 pr_debug("RGBT offset = %d:%d:%d:%d\n",
197 var->red.offset, var->green.offset, var->blue.offset,
198 var->transp.offset);
199
200 return 0;
201}
202
203/*
204 * imxfb_set_par():
205 * Set the user defined part of the display for the specified console
206 */
207static int imxfb_set_par(struct fb_info *info)
208{
209 struct imxfb_info *fbi = info->par;
210 struct fb_var_screeninfo *var = &info->var;
211
212 pr_debug("set_par\n");
213
214 if (var->bits_per_pixel == 16)
215 info->fix.visual = FB_VISUAL_TRUECOLOR;
216 else if (!fbi->cmap_static)
217 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
218 else {
219 /*
220 * Some people have weird ideas about wanting static
221 * pseudocolor maps. I suspect their user space
222 * applications are broken.
223 */
224 info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
225 }
226
227 info->fix.line_length = var->xres_virtual *
228 var->bits_per_pixel / 8;
229 fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16;
230
231 imxfb_activate_var(var, info);
232
233 return 0;
234}
235
236static void imxfb_enable_controller(struct imxfb_info *fbi)
237{
238 pr_debug("Enabling LCD controller\n");
239
240 /* initialize LCDC */
241 LCDC_RMCR &= ~RMCR_LCDC_EN; /* just to be safe... */
242
243 LCDC_SSA = fbi->screen_dma;
244 /* physical screen start address */
245 LCDC_VPW = VPW_VPW(fbi->max_xres * fbi->max_bpp / 8 / 4);
246
247 LCDC_POS = 0x00000000; /* panning offset 0 (0 pixel offset) */
248
249 /* disable hardware cursor */
250 LCDC_CPOS &= ~(CPOS_CC0 | CPOS_CC1);
251
252 /* fixed burst length (see erratum 11) */
253 LCDC_DMACR = DMACR_BURST | DMACR_HM(8) | DMACR_TM(2);
254
255 LCDC_RMCR = RMCR_LCDC_EN;
256
257 if(fbi->backlight_power)
258 fbi->backlight_power(1);
259 if(fbi->lcd_power)
260 fbi->lcd_power(1);
261}
262
263static void imxfb_disable_controller(struct imxfb_info *fbi)
264{
265 pr_debug("Disabling LCD controller\n");
266
267 if(fbi->backlight_power)
268 fbi->backlight_power(0);
269 if(fbi->lcd_power)
270 fbi->lcd_power(0);
271
272 LCDC_RMCR = 0;
273}
274
275static int imxfb_blank(int blank, struct fb_info *info)
276{
277 struct imxfb_info *fbi = info->par;
278
279 pr_debug("imxfb_blank: blank=%d\n", blank);
280
281 switch (blank) {
282 case FB_BLANK_POWERDOWN:
283 case FB_BLANK_VSYNC_SUSPEND:
284 case FB_BLANK_HSYNC_SUSPEND:
285 case FB_BLANK_NORMAL:
286 imxfb_disable_controller(fbi);
287 break;
288
289 case FB_BLANK_UNBLANK:
290 imxfb_enable_controller(fbi);
291 break;
292 }
293 return 0;
294}
295
296static struct fb_ops imxfb_ops = {
297 .owner = THIS_MODULE,
298 .fb_check_var = imxfb_check_var,
299 .fb_set_par = imxfb_set_par,
300 .fb_setcolreg = imxfb_setcolreg,
301 .fb_fillrect = cfb_fillrect,
302 .fb_copyarea = cfb_copyarea,
303 .fb_imageblit = cfb_imageblit,
304 .fb_blank = imxfb_blank,
305 .fb_cursor = soft_cursor, /* FIXME: i.MX can do hardware cursor */
306};
307
308/*
309 * imxfb_activate_var():
310 * Configures LCD Controller based on entries in var parameter. Settings are
311 * only written to the controller if changes were made.
312 */
313static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info)
314{
315 struct imxfb_info *fbi = info->par;
316 pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n",
317 var->xres, var->hsync_len,
318 var->left_margin, var->right_margin);
319 pr_debug("var: yres=%d vslen=%d um=%d bm=%d\n",
320 var->yres, var->vsync_len,
321 var->upper_margin, var->lower_margin);
322
323#if DEBUG_VAR
324 if (var->xres < 16 || var->xres > 1024)
325 printk(KERN_ERR "%s: invalid xres %d\n",
326 info->fix.id, var->xres);
327 if (var->hsync_len < 1 || var->hsync_len > 64)
328 printk(KERN_ERR "%s: invalid hsync_len %d\n",
329 info->fix.id, var->hsync_len);
330 if (var->left_margin > 255)
331 printk(KERN_ERR "%s: invalid left_margin %d\n",
332 info->fix.id, var->left_margin);
333 if (var->right_margin > 255)
334 printk(KERN_ERR "%s: invalid right_margin %d\n",
335 info->fix.id, var->right_margin);
336 if (var->yres < 1 || var->yres > 511)
337 printk(KERN_ERR "%s: invalid yres %d\n",
338 info->fix.id, var->yres);
339 if (var->vsync_len > 100)
340 printk(KERN_ERR "%s: invalid vsync_len %d\n",
341 info->fix.id, var->vsync_len);
342 if (var->upper_margin > 63)
343 printk(KERN_ERR "%s: invalid upper_margin %d\n",
344 info->fix.id, var->upper_margin);
345 if (var->lower_margin > 255)
346 printk(KERN_ERR "%s: invalid lower_margin %d\n",
347 info->fix.id, var->lower_margin);
348#endif
349
350 LCDC_HCR = HCR_H_WIDTH(var->hsync_len) |
351 HCR_H_WAIT_1(var->left_margin) |
352 HCR_H_WAIT_2(var->right_margin);
353
354 LCDC_VCR = VCR_V_WIDTH(var->vsync_len) |
355 VCR_V_WAIT_1(var->upper_margin) |
356 VCR_V_WAIT_2(var->lower_margin);
357
358 LCDC_SIZE = SIZE_XMAX(var->xres) | SIZE_YMAX(var->yres);
359 LCDC_PCR = fbi->pcr;
360 LCDC_PWMR = fbi->pwmr;
361 LCDC_LSCR1 = fbi->lscr1;
362
363 return 0;
364}
365
366static void imxfb_setup_gpio(struct imxfb_info *fbi)
367{
368 int width;
369
370 LCDC_RMCR &= ~(RMCR_LCDC_EN | RMCR_SELF_REF);
371
372 if( fbi->pcr & PCR_TFT )
373 width = 16;
374 else
375 width = 1 << ((fbi->pcr >> 28) & 0x3);
376
377 switch(width) {
378 case 16:
379 imx_gpio_mode(PD30_PF_LD15);
380 imx_gpio_mode(PD29_PF_LD14);
381 imx_gpio_mode(PD28_PF_LD13);
382 imx_gpio_mode(PD27_PF_LD12);
383 imx_gpio_mode(PD26_PF_LD11);
384 imx_gpio_mode(PD25_PF_LD10);
385 imx_gpio_mode(PD24_PF_LD9);
386 imx_gpio_mode(PD23_PF_LD8);
387 case 8:
388 imx_gpio_mode(PD22_PF_LD7);
389 imx_gpio_mode(PD21_PF_LD6);
390 imx_gpio_mode(PD20_PF_LD5);
391 imx_gpio_mode(PD19_PF_LD4);
392 case 4:
393 imx_gpio_mode(PD18_PF_LD3);
394 imx_gpio_mode(PD17_PF_LD2);
395 case 2:
396 imx_gpio_mode(PD16_PF_LD1);
397 case 1:
398 imx_gpio_mode(PD15_PF_LD0);
399 }
400
401 /* initialize GPIOs */
402 imx_gpio_mode(PD6_PF_LSCLK);
403 imx_gpio_mode(PD10_PF_SPL_SPR);
404 imx_gpio_mode(PD11_PF_CONTRAST);
405 imx_gpio_mode(PD14_PF_FLM_VSYNC);
406 imx_gpio_mode(PD13_PF_LP_HSYNC);
407 imx_gpio_mode(PD7_PF_REV);
408 imx_gpio_mode(PD8_PF_CLS);
409
410#ifndef CONFIG_MACH_PIMX1
411 /* on PiMX1 used as buffers enable signal
412 */
413 imx_gpio_mode(PD9_PF_PS);
414#endif
415
416#ifndef CONFIG_MACH_MX1FS2
417 /* on mx1fs2 this pin is used to (de)activate the display, so we need
418 * it as a normal gpio
419 */
420 imx_gpio_mode(PD12_PF_ACD_OE);
421#endif
422
423}
424
425#ifdef CONFIG_PM
426/*
427 * Power management hooks. Note that we won't be called from IRQ context,
428 * unlike the blank functions above, so we may sleep.
429 */
430static int imxfb_suspend(struct device *dev, u32 state, u32 level)
431{
432 struct imxfb_info *fbi = dev_get_drvdata(dev);
433 pr_debug("%s\n",__FUNCTION__);
434
435 if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN)
436 imxfb_disable_controller(fbi);
437 return 0;
438}
439
440static int imxfb_resume(struct device *dev, u32 level)
441{
442 struct imxfb_info *fbi = dev_get_drvdata(dev);
443 pr_debug("%s\n",__FUNCTION__);
444
445 if (level == RESUME_ENABLE)
446 imxfb_enable_controller(fbi);
447 return 0;
448}
449#else
450#define imxfb_suspend NULL
451#define imxfb_resume NULL
452#endif
453
454static int __init imxfb_init_fbinfo(struct device *dev)
455{
456 struct imxfb_mach_info *inf = dev->platform_data;
457 struct fb_info *info = dev_get_drvdata(dev);
458 struct imxfb_info *fbi = info->par;
459
460 pr_debug("%s\n",__FUNCTION__);
461
462 info->pseudo_palette = kmalloc( sizeof(u32) * 16, GFP_KERNEL);
463 if (!info->pseudo_palette)
464 return -ENOMEM;
465
466 memset(fbi, 0, sizeof(struct imxfb_info));
467 fbi->dev = dev;
468
469 strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
470
471 info->fix.type = FB_TYPE_PACKED_PIXELS;
472 info->fix.type_aux = 0;
473 info->fix.xpanstep = 0;
474 info->fix.ypanstep = 0;
475 info->fix.ywrapstep = 0;
476 info->fix.accel = FB_ACCEL_NONE;
477
478 info->var.nonstd = 0;
479 info->var.activate = FB_ACTIVATE_NOW;
480 info->var.height = -1;
481 info->var.width = -1;
482 info->var.accel_flags = 0;
483 info->var.vmode = FB_VMODE_NONINTERLACED;
484
485 info->fbops = &imxfb_ops;
486 info->flags = FBINFO_FLAG_DEFAULT;
487 info->pseudo_palette = (fbi + 1);
488
489 fbi->rgb[RGB_16] = &def_rgb_16;
490 fbi->rgb[RGB_8] = &def_rgb_8;
491
492 fbi->max_xres = inf->xres;
493 info->var.xres = inf->xres;
494 info->var.xres_virtual = inf->xres;
495 fbi->max_yres = inf->yres;
496 info->var.yres = inf->yres;
497 info->var.yres_virtual = inf->yres;
498 fbi->max_bpp = inf->bpp;
499 info->var.bits_per_pixel = inf->bpp;
500 info->var.pixclock = inf->pixclock;
501 info->var.hsync_len = inf->hsync_len;
502 info->var.left_margin = inf->left_margin;
503 info->var.right_margin = inf->right_margin;
504 info->var.vsync_len = inf->vsync_len;
505 info->var.upper_margin = inf->upper_margin;
506 info->var.lower_margin = inf->lower_margin;
507 info->var.sync = inf->sync;
508 info->var.grayscale = inf->cmap_greyscale;
509 fbi->cmap_inverse = inf->cmap_inverse;
510 fbi->pcr = inf->pcr;
511 fbi->lscr1 = inf->lscr1;
512 fbi->pwmr = inf->pwmr;
513 fbi->lcd_power = inf->lcd_power;
514 fbi->backlight_power = inf->backlight_power;
515 info->fix.smem_len = fbi->max_xres * fbi->max_yres *
516 fbi->max_bpp / 8;
517
518 return 0;
519}
520
521/*
522 * Allocates the DRAM memory for the frame buffer. This buffer is
523 * remapped into a non-cached, non-buffered, memory region to
524 * allow pixel writes to occur without flushing the cache.
525 * Once this area is remapped, all virtual memory access to the
526 * video memory should occur at the new region.
527 */
528static int __init imxfb_map_video_memory(struct fb_info *info)
529{
530 struct imxfb_info *fbi = info->par;
531
532 fbi->map_size = PAGE_ALIGN(info->fix.smem_len);
533 fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
534 &fbi->map_dma,GFP_KERNEL);
535
536 if (fbi->map_cpu) {
537 info->screen_base = fbi->map_cpu;
538 fbi->screen_cpu = fbi->map_cpu;
539 fbi->screen_dma = fbi->map_dma;
540 info->fix.smem_start = fbi->screen_dma;
541 }
542
543 return fbi->map_cpu ? 0 : -ENOMEM;
544}
545
546static int __init imxfb_probe(struct device *dev)
547{
548 struct platform_device *pdev = to_platform_device(dev);
549 struct imxfb_info *fbi;
550 struct fb_info *info;
551 struct imxfb_mach_info *inf;
552 struct resource *res;
553 int ret;
554
555 printk("i.MX Framebuffer driver\n");
556
557 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
558 if(!res)
559 return -ENODEV;
560
561 inf = dev->platform_data;
562 if(!inf) {
563 dev_err(dev,"No platform_data available\n");
564 return -ENOMEM;
565 }
566
567 info = framebuffer_alloc(sizeof(struct imxfb_info), dev);
568 if(!info)
569 return -ENOMEM;
570
571 fbi = info->par;
572
573 dev_set_drvdata(dev, info);
574
575 ret = imxfb_init_fbinfo(dev);
576 if( ret < 0 )
577 goto failed_init;
578
579 res = request_mem_region(res->start, res->end - res->start + 1, "IMXFB");
580 if (!res) {
581 ret = -EBUSY;
582 goto failed_regs;
583 }
584
585 if (!inf->fixed_screen_cpu) {
586 ret = imxfb_map_video_memory(info);
587 if (ret) {
588 dev_err(dev, "Failed to allocate video RAM: %d\n", ret);
589 ret = -ENOMEM;
590 goto failed_map;
591 }
592 } else {
593 /* Fixed framebuffer mapping enables location of the screen in eSRAM */
594 fbi->map_cpu = inf->fixed_screen_cpu;
595 fbi->map_dma = inf->fixed_screen_dma;
596 info->screen_base = fbi->map_cpu;
597 fbi->screen_cpu = fbi->map_cpu;
598 fbi->screen_dma = fbi->map_dma;
599 info->fix.smem_start = fbi->screen_dma;
600 }
601
602 /*
603 * This makes sure that our colour bitfield
604 * descriptors are correctly initialised.
605 */
606 imxfb_check_var(&info->var, info);
607
608 ret = fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
609 if (ret < 0)
610 goto failed_cmap;
611
612 imxfb_setup_gpio(fbi);
613
614 imxfb_set_par(info);
615 ret = register_framebuffer(info);
616 if (ret < 0) {
617 dev_err(dev, "failed to register framebuffer\n");
618 goto failed_register;
619 }
620
621 imxfb_enable_controller(fbi);
622
623 return 0;
624
625failed_register:
626 fb_dealloc_cmap(&info->cmap);
627failed_cmap:
628 if (!inf->fixed_screen_cpu)
629 dma_free_writecombine(dev,fbi->map_size,fbi->map_cpu,
630 fbi->map_dma);
631failed_map:
632 kfree(info->pseudo_palette);
633failed_regs:
634 release_mem_region(res->start, res->end - res->start);
635failed_init:
636 dev_set_drvdata(dev, NULL);
637 framebuffer_release(info);
638 return ret;
639}
640
641static int imxfb_remove(struct device *dev)
642{
643 struct platform_device *pdev = to_platform_device(dev);
644 struct fb_info *info = dev_get_drvdata(dev);
645 struct resource *res;
646
647 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
648
649 /* disable LCD controller */
650 LCDC_RMCR &= ~RMCR_LCDC_EN;
651
652 unregister_framebuffer(info);
653
654 fb_dealloc_cmap(&info->cmap);
655 kfree(info->pseudo_palette);
656 framebuffer_release(info);
657
658 release_mem_region(res->start, res->end - res->start + 1);
659 dev_set_drvdata(dev, NULL);
660
661 return 0;
662}
663
664void imxfb_shutdown(struct device * dev)
665{
666 /* disable LCD Controller */
667 LCDC_RMCR &= ~RMCR_LCDC_EN;
668}
669
670static struct device_driver imxfb_driver = {
671 .name = "imx-fb",
672 .bus = &platform_bus_type,
673 .probe = imxfb_probe,
674 .suspend = imxfb_suspend,
675 .resume = imxfb_resume,
676 .remove = imxfb_remove,
677 .shutdown = imxfb_shutdown,
678};
679
680int __init imxfb_init(void)
681{
682 return driver_register(&imxfb_driver);
683}
684
685static void __exit imxfb_cleanup(void)
686{
687 driver_unregister(&imxfb_driver);
688}
689
690module_init(imxfb_init);
691module_exit(imxfb_cleanup);
692
693MODULE_DESCRIPTION("Motorola i.MX framebuffer driver");
694MODULE_AUTHOR("Sascha Hauer, Pengutronix");
695MODULE_LICENSE("GPL");
diff --git a/drivers/video/imxfb.h b/drivers/video/imxfb.h
new file mode 100644
index 000000000000..128c3ee515c7
--- /dev/null
+++ b/drivers/video/imxfb.h
@@ -0,0 +1,72 @@
1/*
2 * linux/drivers/video/imxfb.h
3 *
4 * Freescale i.MX Frame Buffer device driver
5 *
6 * Copyright (C) 2004 S.Hauer, Pengutronix
7 *
8 * Copyright (C) 1999 Eric A. Thomas
9 * Based on acornfb.c Copyright (C) Russell King.
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file COPYING in the main directory of this archive
13 * for more details.
14 */
15
16/*
17 * These are the bitfields for each
18 * display depth that we support.
19 */
20struct imxfb_rgb {
21 struct fb_bitfield red;
22 struct fb_bitfield green;
23 struct fb_bitfield blue;
24 struct fb_bitfield transp;
25};
26
27#define RGB_16 (0)
28#define RGB_8 (1)
29#define NR_RGB 2
30
31struct imxfb_info {
32 struct device *dev;
33 struct imxfb_rgb *rgb[NR_RGB];
34
35 u_int max_bpp;
36 u_int max_xres;
37 u_int max_yres;
38
39 /*
40 * These are the addresses we mapped
41 * the framebuffer memory region to.
42 */
43 dma_addr_t map_dma;
44 u_char * map_cpu;
45 u_int map_size;
46
47 u_char * screen_cpu;
48 dma_addr_t screen_dma;
49 u_int palette_size;
50
51 dma_addr_t dbar1;
52 dma_addr_t dbar2;
53
54 u_int pcr;
55 u_int pwmr;
56 u_int lscr1;
57 u_int cmap_inverse:1,
58 cmap_static:1,
59 unused:30;
60
61 void (*lcd_power)(int);
62 void (*backlight_power)(int);
63};
64
65#define IMX_NAME "IMX"
66
67/*
68 * Minimum X and Y resolutions
69 */
70#define MIN_XRES 64
71#define MIN_YRES 64
72
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 6a05b7000830..549e22939260 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -135,9 +135,45 @@
135#endif 135#endif
136 136
137#include "intelfb.h" 137#include "intelfb.h"
138#include "intelfbdrv.h"
139#include "intelfbhw.h" 138#include "intelfbhw.h"
140 139
140static void __devinit get_initial_mode(struct intelfb_info *dinfo);
141static void update_dinfo(struct intelfb_info *dinfo,
142 struct fb_var_screeninfo *var);
143static int intelfb_get_fix(struct fb_fix_screeninfo *fix,
144 struct fb_info *info);
145
146static int intelfb_check_var(struct fb_var_screeninfo *var,
147 struct fb_info *info);
148static int intelfb_set_par(struct fb_info *info);
149static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
150 unsigned blue, unsigned transp,
151 struct fb_info *info);
152
153static int intelfb_blank(int blank, struct fb_info *info);
154static int intelfb_pan_display(struct fb_var_screeninfo *var,
155 struct fb_info *info);
156
157static void intelfb_fillrect(struct fb_info *info,
158 const struct fb_fillrect *rect);
159static void intelfb_copyarea(struct fb_info *info,
160 const struct fb_copyarea *region);
161static void intelfb_imageblit(struct fb_info *info,
162 const struct fb_image *image);
163static int intelfb_cursor(struct fb_info *info,
164 struct fb_cursor *cursor);
165
166static int intelfb_sync(struct fb_info *info);
167
168static int intelfb_ioctl(struct inode *inode, struct file *file,
169 unsigned int cmd, unsigned long arg,
170 struct fb_info *info);
171
172static int __devinit intelfb_pci_register(struct pci_dev *pdev,
173 const struct pci_device_id *ent);
174static void __devexit intelfb_pci_unregister(struct pci_dev *pdev);
175static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo);
176
141/* 177/*
142 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the 178 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the
143 * mobile chipsets from being registered. 179 * mobile chipsets from being registered.
diff --git a/drivers/video/intelfb/intelfbdrv.h b/drivers/video/intelfb/intelfbdrv.h
deleted file mode 100644
index cc3058128884..000000000000
--- a/drivers/video/intelfb/intelfbdrv.h
+++ /dev/null
@@ -1,68 +0,0 @@
1#ifndef _INTELFBDRV_H
2#define _INTELFBDRV_H
3
4/*
5 ******************************************************************************
6 * intelfb
7 *
8 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G
9 * integrated graphics chips.
10 *
11 * Copyright © 2004 Sylvain Meyer
12 *
13 * Author: Sylvain Meyer
14 *
15 ******************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29*/
30
31static void __devinit get_initial_mode(struct intelfb_info *dinfo);
32static void update_dinfo(struct intelfb_info *dinfo,
33 struct fb_var_screeninfo *var);
34static int intelfb_get_fix(struct fb_fix_screeninfo *fix,
35 struct fb_info *info);
36
37static int intelfb_check_var(struct fb_var_screeninfo *var,
38 struct fb_info *info);
39static int intelfb_set_par(struct fb_info *info);
40static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
41 unsigned blue, unsigned transp,
42 struct fb_info *info);
43
44static int intelfb_blank(int blank, struct fb_info *info);
45static int intelfb_pan_display(struct fb_var_screeninfo *var,
46 struct fb_info *info);
47
48static void intelfb_fillrect(struct fb_info *info,
49 const struct fb_fillrect *rect);
50static void intelfb_copyarea(struct fb_info *info,
51 const struct fb_copyarea *region);
52static void intelfb_imageblit(struct fb_info *info,
53 const struct fb_image *image);
54static int intelfb_cursor(struct fb_info *info,
55 struct fb_cursor *cursor);
56
57static int intelfb_sync(struct fb_info *info);
58
59static int intelfb_ioctl(struct inode *inode, struct file *file,
60 unsigned int cmd, unsigned long arg,
61 struct fb_info *info);
62
63static int __devinit intelfb_pci_register(struct pci_dev *pdev,
64 const struct pci_device_id *ent);
65static void __devexit intelfb_pci_unregister(struct pci_dev *pdev);
66static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo);
67
68#endif
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 849b47b210ec..6ba10e3aceff 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -45,7 +45,7 @@ config LOGO_SGI_CLUT224
45 45
46config LOGO_SUN_CLUT224 46config LOGO_SUN_CLUT224
47 bool "224-color Sun Linux logo" 47 bool "224-color Sun Linux logo"
48 depends on LOGO && (SPARC || SPARC64) 48 depends on LOGO && (SPARC32 || SPARC64)
49 default y 49 default y
50 50
51config LOGO_SUPERH_MONO 51config LOGO_SUPERH_MONO
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 3a6555a8aaa2..47733f58153b 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -408,6 +408,7 @@ static int hwcur __devinitdata = 0;
408static int noaccel __devinitdata = 0; 408static int noaccel __devinitdata = 0;
409static int noscale __devinitdata = 0; 409static int noscale __devinitdata = 0;
410static int paneltweak __devinitdata = 0; 410static int paneltweak __devinitdata = 0;
411static int vram __devinitdata = 0;
411#ifdef CONFIG_MTRR 412#ifdef CONFIG_MTRR
412static int nomtrr __devinitdata = 0; 413static int nomtrr __devinitdata = 0;
413#endif 414#endif
@@ -1180,7 +1181,7 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,
1180 1181
1181 var->xres_virtual = (var->xres_virtual + 63) & ~63; 1182 var->xres_virtual = (var->xres_virtual + 63) & ~63;
1182 1183
1183 vramlen = info->fix.smem_len; 1184 vramlen = info->screen_size;
1184 pitch = ((var->xres_virtual * var->bits_per_pixel) + 7) / 8; 1185 pitch = ((var->xres_virtual * var->bits_per_pixel) + 7) / 8;
1185 memlen = pitch * var->yres_virtual; 1186 memlen = pitch * var->yres_virtual;
1186 1187
@@ -1343,7 +1344,7 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info)
1343 /* maximize virtual vertical length */ 1344 /* maximize virtual vertical length */
1344 lpitch = info->var.xres_virtual * 1345 lpitch = info->var.xres_virtual *
1345 ((info->var.bits_per_pixel + 7) >> 3); 1346 ((info->var.bits_per_pixel + 7) >> 3);
1346 info->var.yres_virtual = info->fix.smem_len / lpitch; 1347 info->var.yres_virtual = info->screen_size / lpitch;
1347 1348
1348 info->pixmap.scan_align = 4; 1349 info->pixmap.scan_align = 4;
1349 info->pixmap.buf_align = 4; 1350 info->pixmap.buf_align = 4;
@@ -1507,12 +1508,20 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1507 1508
1508 par->FbAddress = nvidiafb_fix.smem_start; 1509 par->FbAddress = nvidiafb_fix.smem_start;
1509 par->FbMapSize = par->RamAmountKBytes * 1024; 1510 par->FbMapSize = par->RamAmountKBytes * 1024;
1511 if (vram && vram * 1024 * 1024 < par->FbMapSize)
1512 par->FbMapSize = vram * 1024 * 1024;
1513
1514 /* Limit amount of vram to 64 MB */
1515 if (par->FbMapSize > 64 * 1024 * 1024)
1516 par->FbMapSize = 64 * 1024 * 1024;
1517
1510 par->FbUsableSize = par->FbMapSize - (128 * 1024); 1518 par->FbUsableSize = par->FbMapSize - (128 * 1024);
1511 par->ScratchBufferSize = (par->Architecture < NV_ARCH_10) ? 8 * 1024 : 1519 par->ScratchBufferSize = (par->Architecture < NV_ARCH_10) ? 8 * 1024 :
1512 16 * 1024; 1520 16 * 1024;
1513 par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize; 1521 par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize;
1514 info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize); 1522 info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize);
1515 nvidiafb_fix.smem_len = par->FbUsableSize; 1523 info->screen_size = par->FbUsableSize;
1524 nvidiafb_fix.smem_len = par->RamAmountKBytes * 1024;
1516 1525
1517 if (!info->screen_base) { 1526 if (!info->screen_base) {
1518 printk(KERN_ERR PFX "cannot ioremap FB base\n"); 1527 printk(KERN_ERR PFX "cannot ioremap FB base\n");
@@ -1524,7 +1533,8 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1524#ifdef CONFIG_MTRR 1533#ifdef CONFIG_MTRR
1525 if (!nomtrr) { 1534 if (!nomtrr) {
1526 par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start, 1535 par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start,
1527 par->FbMapSize, MTRR_TYPE_WRCOMB, 1); 1536 par->RamAmountKBytes * 1024,
1537 MTRR_TYPE_WRCOMB, 1);
1528 if (par->mtrr.vram < 0) { 1538 if (par->mtrr.vram < 0) {
1529 printk(KERN_ERR PFX "unable to setup MTRR\n"); 1539 printk(KERN_ERR PFX "unable to setup MTRR\n");
1530 } else { 1540 } else {
@@ -1566,9 +1576,9 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1566 1576
1567 err_out_iounmap_fb: 1577 err_out_iounmap_fb:
1568 iounmap(info->screen_base); 1578 iounmap(info->screen_base);
1579 err_out_free_base1:
1569 fb_destroy_modedb(info->monspecs.modedb); 1580 fb_destroy_modedb(info->monspecs.modedb);
1570 nvidia_delete_i2c_busses(par); 1581 nvidia_delete_i2c_busses(par);
1571 err_out_free_base1:
1572 iounmap(par->REGS); 1582 iounmap(par->REGS);
1573 err_out_free_base0: 1583 err_out_free_base0:
1574 pci_release_regions(pd); 1584 pci_release_regions(pd);
@@ -1645,6 +1655,8 @@ static int __devinit nvidiafb_setup(char *options)
1645 noscale = 1; 1655 noscale = 1;
1646 } else if (!strncmp(this_opt, "paneltweak:", 11)) { 1656 } else if (!strncmp(this_opt, "paneltweak:", 11)) {
1647 paneltweak = simple_strtoul(this_opt+11, NULL, 0); 1657 paneltweak = simple_strtoul(this_opt+11, NULL, 0);
1658 } else if (!strncmp(this_opt, "vram:", 5)) {
1659 vram = simple_strtoul(this_opt+5, NULL, 0);
1648#ifdef CONFIG_MTRR 1660#ifdef CONFIG_MTRR
1649 } else if (!strncmp(this_opt, "nomtrr", 6)) { 1661 } else if (!strncmp(this_opt, "nomtrr", 6)) {
1650 nomtrr = 1; 1662 nomtrr = 1;
@@ -1716,6 +1728,10 @@ module_param(forceCRTC, int, 0);
1716MODULE_PARM_DESC(forceCRTC, 1728MODULE_PARM_DESC(forceCRTC,
1717 "Forces usage of a particular CRTC in case autodetection " 1729 "Forces usage of a particular CRTC in case autodetection "
1718 "fails. (0 or 1) (default=autodetect)"); 1730 "fails. (0 or 1) (default=autodetect)");
1731module_param(vram, int, 0);
1732MODULE_PARM_DESC(vram,
1733 "amount of framebuffer memory to remap in MiB"
1734 "(default=0 - remap entire memory)");
1719#ifdef CONFIG_MTRR 1735#ifdef CONFIG_MTRR
1720module_param(nomtrr, bool, 0); 1736module_param(nomtrr, bool, 0);
1721MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) " 1737MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) "
diff --git a/drivers/video/radeonfb.c b/drivers/video/radeonfb.c
index d9a084e77a63..c46387024b1d 100644
--- a/drivers/video/radeonfb.c
+++ b/drivers/video/radeonfb.c
@@ -2107,7 +2107,7 @@ static void radeon_write_mode (struct radeonfb_info *rinfo,
2107 2107
2108 2108
2109 if (rinfo->arch == RADEON_M6) { 2109 if (rinfo->arch == RADEON_M6) {
2110 for (i=0; i<8; i++) 2110 for (i=0; i<7; i++)
2111 OUTREG(common_regs_m6[i].reg, common_regs_m6[i].val); 2111 OUTREG(common_regs_m6[i].reg, common_regs_m6[i].val);
2112 } else { 2112 } else {
2113 for (i=0; i<9; i++) 2113 for (i=0; i<9; i++)
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 5bb8d60f35c4..03d74e8ee067 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -1498,7 +1498,7 @@ static int __devinit savage_map_mmio (struct fb_info *info)
1498 info->fix.mmio_start = par->mmio.pbase; 1498 info->fix.mmio_start = par->mmio.pbase;
1499 info->fix.mmio_len = par->mmio.len; 1499 info->fix.mmio_len = par->mmio.len;
1500 1500
1501 par->bci_base = (u32*)(par->mmio.vbase + BCI_BUFFER_OFFSET); 1501 par->bci_base = (u32 __iomem *)(par->mmio.vbase + BCI_BUFFER_OFFSET);
1502 par->bci_ptr = 0; 1502 par->bci_ptr = 0;
1503 1503
1504 savage_enable_mmio (par); 1504 savage_enable_mmio (par);
@@ -1514,7 +1514,7 @@ static void __devinit savage_unmap_mmio (struct fb_info *info)
1514 savage_disable_mmio(par); 1514 savage_disable_mmio(par);
1515 1515
1516 if (par->mmio.vbase) { 1516 if (par->mmio.vbase) {
1517 iounmap ((void *)par->mmio.vbase); 1517 iounmap(par->mmio.vbase);
1518 par->mmio.vbase = NULL; 1518 par->mmio.vbase = NULL;
1519 } 1519 }
1520} 1520}
@@ -1553,7 +1553,7 @@ static int __devinit savage_map_video (struct fb_info *info,
1553#endif 1553#endif
1554 1554
1555 /* Clear framebuffer, it's all white in memory after boot */ 1555 /* Clear framebuffer, it's all white in memory after boot */
1556 memset (par->video.vbase, 0, par->video.len); 1556 memset_io (par->video.vbase, 0, par->video.len);
1557 1557
1558 return 0; 1558 return 0;
1559} 1559}
diff --git a/drivers/video/sis/init.c b/drivers/video/sis/init.c
index 1994054d45ff..ecfd72178dbb 100644
--- a/drivers/video/sis/init.c
+++ b/drivers/video/sis/init.c
@@ -1384,7 +1384,7 @@ SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1384/* HELPER: SetLVDSetc */ 1384/* HELPER: SetLVDSetc */
1385/*********************************************/ 1385/*********************************************/
1386 1386
1387void 1387static void
1388SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 1388SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1389{ 1389{
1390 USHORT temp; 1390 USHORT temp;
@@ -1625,7 +1625,7 @@ SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo)
1625/* HELPER: GetVBType */ 1625/* HELPER: GetVBType */
1626/*********************************************/ 1626/*********************************************/
1627 1627
1628void 1628static void
1629SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 1629SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1630{ 1630{
1631 USHORT flag=0, rev=0, nolcd=0, p4_0f, p4_25, p4_27; 1631 USHORT flag=0, rev=0, nolcd=0, p4_0f, p4_25, p4_27;
diff --git a/drivers/video/sis/init.h b/drivers/video/sis/init.h
index 35030d300431..7e36b7ac1470 100644
--- a/drivers/video/sis/init.h
+++ b/drivers/video/sis/init.h
@@ -2394,11 +2394,9 @@ void SiS_SetRegOR(SISIOADDRESS Port,USHORT Index, USHORT DataOR);
2394void SiS_DisplayOn(SiS_Private *SiS_Pr); 2394void SiS_DisplayOn(SiS_Private *SiS_Pr);
2395void SiS_DisplayOff(SiS_Private *SiS_Pr); 2395void SiS_DisplayOff(SiS_Private *SiS_Pr);
2396void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); 2396void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
2397void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2398BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 2397BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2399void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); 2398void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable);
2400void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); 2399void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable);
2401void SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2402BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex); 2400BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex);
2403UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); 2401UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
2404USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); 2402USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
@@ -2444,7 +2442,6 @@ extern void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT Mod
2444extern void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 2442extern void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2445extern void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); 2443extern void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo);
2446extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 2444extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2447extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2448extern void SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO); 2445extern void SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO);
2449extern BOOLEAN SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT); 2446extern BOOLEAN SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT);
2450extern USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 2447extern USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
diff --git a/drivers/video/sis/init301.c b/drivers/video/sis/init301.c
index 2bc5b8097910..274dacd54bb8 100644
--- a/drivers/video/sis/init301.c
+++ b/drivers/video/sis/init301.c
@@ -86,6 +86,7 @@
86#define SiS_I2CDELAYSHORT 150 86#define SiS_I2CDELAYSHORT 150
87 87
88static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr); 88static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr);
89static void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx);
89 90
90/*********************************************/ 91/*********************************************/
91/* HELPER: Lock/Unlock CRT2 */ 92/* HELPER: Lock/Unlock CRT2 */
@@ -100,7 +101,7 @@ SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
100 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); 101 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
101} 102}
102 103
103void 104static void
104SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 105SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
105{ 106{
106 if(HwInfo->jChipType >= SIS_315H) 107 if(HwInfo->jChipType >= SIS_315H)
@@ -4236,7 +4237,7 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4236 * from outside the context of a mode switch! 4237 * from outside the context of a mode switch!
4237 * MUST call getVBType before calling this 4238 * MUST call getVBType before calling this
4238 */ 4239 */
4239void 4240static void
4240SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 4241SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4241{ 4242{
4242 USHORT temp=0,tempah; 4243 USHORT temp=0,tempah;
@@ -9219,7 +9220,7 @@ SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
9219 SiS_SetChReg(SiS_Pr, tempbx, 0); 9220 SiS_SetChReg(SiS_Pr, tempbx, 0);
9220} 9221}
9221 9222
9222void 9223static void
9223SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) 9224SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
9224{ 9225{
9225 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 9226 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
@@ -9323,7 +9324,7 @@ SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
9323 9324
9324/* Read from Chrontel 70xx */ 9325/* Read from Chrontel 70xx */
9325/* Parameter is [Register no (S7-S0)] */ 9326/* Parameter is [Register no (S7-S0)] */
9326USHORT 9327static USHORT
9327SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) 9328SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
9328{ 9329{
9329 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 9330 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
diff --git a/drivers/video/sis/init301.h b/drivers/video/sis/init301.h
index f05aebc994b4..f84eb54164a5 100644
--- a/drivers/video/sis/init301.h
+++ b/drivers/video/sis/init301.h
@@ -293,7 +293,6 @@ static UCHAR SiS300_TrumpionData[7][80] = {
293#endif 293#endif
294 294
295void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 295void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
296void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
297void SiS_EnableCRT2(SiS_Private *SiS_Pr); 296void SiS_EnableCRT2(SiS_Private *SiS_Pr);
298USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); 297USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo);
299void SiS_WaitRetrace1(SiS_Private *SiS_Pr); 298void SiS_WaitRetrace1(SiS_Private *SiS_Pr);
@@ -310,7 +309,6 @@ USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
310 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); 309 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo);
311USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); 310USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex);
312void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 311void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
313void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
314BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo); 312BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo);
315void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 313void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
316void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 314void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
@@ -319,8 +317,6 @@ void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax);
319USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); 317USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax);
320void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); 318void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax);
321USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); 319USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax);
322void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax);
323USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax);
324void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); 320void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh);
325#ifdef SIS315H 321#ifdef SIS315H
326static void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 322static void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index b773c98f6513..698266036819 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -4762,7 +4762,8 @@ static void __devinit sisfb_post_sis315330(struct pci_dev *pdev)
4762#endif 4762#endif
4763 4763
4764 4764
4765int __devinit sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 4765static int __devinit sisfb_probe(struct pci_dev *pdev,
4766 const struct pci_device_id *ent)
4766{ 4767{
4767 struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data]; 4768 struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data];
4768 struct sis_video_info *ivideo = NULL; 4769 struct sis_video_info *ivideo = NULL;
@@ -5940,7 +5941,7 @@ MODULE_PARM_DESC(videoram,
5940#endif 5941#endif
5941#endif 5942#endif
5942 5943
5943int __devinit sisfb_init_module(void) 5944static int __devinit sisfb_init_module(void)
5944{ 5945{
5945 sisfb_setdefaultparms(); 5946 sisfb_setdefaultparms();
5946 5947
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index e2fa9e1ddc3b..1986a8b3833c 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -36,6 +36,7 @@ static int tcx_blank(int, struct fb_info *);
36static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *); 36static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
37static int tcx_ioctl(struct inode *, struct file *, unsigned int, 37static int tcx_ioctl(struct inode *, struct file *, unsigned int,
38 unsigned long, struct fb_info *); 38 unsigned long, struct fb_info *);
39static int tcx_pan_display(struct fb_var_screeninfo *, struct fb_info *);
39 40
40/* 41/*
41 * Frame buffer operations 42 * Frame buffer operations
@@ -45,6 +46,7 @@ static struct fb_ops tcx_ops = {
45 .owner = THIS_MODULE, 46 .owner = THIS_MODULE,
46 .fb_setcolreg = tcx_setcolreg, 47 .fb_setcolreg = tcx_setcolreg,
47 .fb_blank = tcx_blank, 48 .fb_blank = tcx_blank,
49 .fb_pan_display = tcx_pan_display,
48 .fb_fillrect = cfb_fillrect, 50 .fb_fillrect = cfb_fillrect,
49 .fb_copyarea = cfb_copyarea, 51 .fb_copyarea = cfb_copyarea,
50 .fb_imageblit = cfb_imageblit, 52 .fb_imageblit = cfb_imageblit,
@@ -153,6 +155,12 @@ static void tcx_reset (struct fb_info *info)
153 spin_unlock_irqrestore(&par->lock, flags); 155 spin_unlock_irqrestore(&par->lock, flags);
154} 156}
155 157
158static int tcx_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
159{
160 tcx_reset(info);
161 return 0;
162}
163
156/** 164/**
157 * tcx_setcolreg - Optional function. Sets a color register. 165 * tcx_setcolreg - Optional function. Sets a color register.
158 * @regno: boolean, 0 copy local, 1 get_user() function 166 * @regno: boolean, 0 copy local, 1 get_user() function
@@ -366,6 +374,9 @@ static void tcx_init_one(struct sbus_dev *sdev)
366 all->par.lowdepth = prom_getbool(sdev->prom_node, "tcx-8-bit"); 374 all->par.lowdepth = prom_getbool(sdev->prom_node, "tcx-8-bit");
367 375
368 sbusfb_fill_var(&all->info.var, sdev->prom_node, 8); 376 sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
377 all->info.var.red.length = 8;
378 all->info.var.green.length = 8;
379 all->info.var.blue.length = 8;
369 380
370 linebytes = prom_getintdefault(sdev->prom_node, "linebytes", 381 linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
371 all->info.var.xres); 382 all->info.var.xres);
@@ -439,6 +450,7 @@ static void tcx_init_one(struct sbus_dev *sdev)
439 return; 450 return;
440 } 451 }
441 452
453 fb_set_cmap(&all->info.cmap, &all->info);
442 tcx_init_fix(&all->info, linebytes); 454 tcx_init_fix(&all->info, linebytes);
443 455
444 if (register_framebuffer(&all->info) < 0) { 456 if (register_framebuffer(&all->info) < 0) {
@@ -466,7 +478,7 @@ int __init tcx_init(void)
466 return -ENODEV; 478 return -ENODEV;
467 479
468 for_all_sbusdev(sdev, sbus) { 480 for_all_sbusdev(sdev, sbus) {
469 if (!strcmp(sdev->prom_name, "tcx")) 481 if (!strcmp(sdev->prom_name, "SUNW,tcx"))
470 tcx_init_one(sdev); 482 tcx_init_one(sdev);
471 } 483 }
472 484
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index c34ba39b6f7e..7044226c5d4c 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -317,30 +317,49 @@ static inline void do_setpalentry(struct tdfx_par *par, unsigned regno, u32 c)
317 317
318static u32 do_calc_pll(int freq, int* freq_out) 318static u32 do_calc_pll(int freq, int* freq_out)
319{ 319{
320 int m, n, k, best_m, best_n, best_k, f_cur, best_error; 320 int m, n, k, best_m, best_n, best_k, best_error;
321 int fref = 14318; 321 int fref = 14318;
322 322
323 /* this really could be done with more intelligence --
324 255*63*4 = 64260 iterations is silly */
325 best_error = freq; 323 best_error = freq;
326 best_n = best_m = best_k = 0; 324 best_n = best_m = best_k = 0;
327 for (n = 1; n < 256; n++) { 325
328 for (m = 1; m < 64; m++) { 326 for (k = 3; k >= 0; k--) {
329 for (k = 0; k < 4; k++) { 327 for (m = 63; m >= 0; m--) {
330 f_cur = fref*(n + 2)/(m + 2)/(1 << k); 328 /*
331 if (abs(f_cur - freq) < best_error) { 329 * Estimate value of n that produces target frequency
332 best_error = abs(f_cur-freq); 330 * with current m and k
333 best_n = n; 331 */
334 best_m = m; 332 int n_estimated = (freq * (m + 2) * (1 << k) / fref) - 2;
335 best_k = k; 333
334 /* Search neighborhood of estimated n */
335 for (n = max(0, n_estimated - 1);
336 n <= min(255, n_estimated + 1); n++) {
337 /*
338 * Calculate PLL freqency with current m, k and
339 * estimated n
340 */
341 int f = fref * (n + 2) / (m + 2) / (1 << k);
342 int error = abs (f - freq);
343
344 /*
345 * If this is the closest we've come to the
346 * target frequency then remember n, m and k
347 */
348 if (error < best_error) {
349 best_error = error;
350 best_n = n;
351 best_m = m;
352 best_k = k;
336 } 353 }
337 } 354 }
338 } 355 }
339 } 356 }
357
340 n = best_n; 358 n = best_n;
341 m = best_m; 359 m = best_m;
342 k = best_k; 360 k = best_k;
343 *freq_out = fref*(n + 2)/(m + 2)/(1 << k); 361 *freq_out = fref*(n + 2)/(m + 2)/(1 << k);
362
344 return (n << 8) | (m << 2) | k; 363 return (n << 8) | (m << 2) | k;
345} 364}
346 365
@@ -411,36 +430,35 @@ static void do_write_regs(struct fb_info *info, struct banshee_reg* reg)
411 430
412static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id) 431static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id)
413{ 432{
414 u32 draminit0 = 0; 433 u32 draminit0;
415 u32 draminit1 = 0; 434 u32 draminit1;
416 u32 miscinit1 = 0; 435 u32 miscinit1;
417 u32 lfbsize = 0; 436
418 int sgram_p = 0; 437 int num_chips;
438 int chip_size; /* in MB */
439 u32 lfbsize;
440 int has_sgram;
419 441
420 draminit0 = tdfx_inl(par, DRAMINIT0); 442 draminit0 = tdfx_inl(par, DRAMINIT0);
421 draminit1 = tdfx_inl(par, DRAMINIT1); 443 draminit1 = tdfx_inl(par, DRAMINIT1);
444
445 num_chips = (draminit0 & DRAMINIT0_SGRAM_NUM) ? 8 : 4;
422 446
423 if ((dev_id == PCI_DEVICE_ID_3DFX_BANSHEE) || 447 if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) {
424 (dev_id == PCI_DEVICE_ID_3DFX_VOODOO3)) { 448 /* Banshee/Voodoo3 */
425 sgram_p = (draminit1 & DRAMINIT1_MEM_SDRAM) ? 0 : 1; 449 has_sgram = draminit1 & DRAMINIT1_MEM_SDRAM;
426 450 chip_size = has_sgram ? ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 2 : 1)
427 lfbsize = sgram_p ? 451 : 2;
428 (((draminit0 & DRAMINIT0_SGRAM_NUM) ? 2 : 1) *
429 ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 8 : 4) * 1024 * 1024) :
430 16 * 1024 * 1024;
431 } else { 452 } else {
432 /* Voodoo4/5 */ 453 /* Voodoo4/5 */
433 u32 chips, psize, banks; 454 has_sgram = 0;
434 455 chip_size = 1 << ((draminit0 & DRAMINIT0_SGRAM_TYPE_MASK) >> DRAMINIT0_SGRAM_TYPE_SHIFT);
435 chips = ((draminit0 & (1 << 26)) == 0) ? 4 : 8; 456 }
436 psize = 1 << ((draminit0 & 0x38000000) >> 28); 457 lfbsize = num_chips * chip_size * 1024 * 1024;
437 banks = ((draminit0 & (1 << 30)) == 0) ? 2 : 4; 458
438 lfbsize = chips * psize * banks; 459 /* disable block writes for SDRAM */
439 lfbsize <<= 20;
440 }
441 /* disable block writes for SDRAM (why?) */
442 miscinit1 = tdfx_inl(par, MISCINIT1); 460 miscinit1 = tdfx_inl(par, MISCINIT1);
443 miscinit1 |= sgram_p ? 0 : MISCINIT1_2DBLOCK_DIS; 461 miscinit1 |= has_sgram ? 0 : MISCINIT1_2DBLOCK_DIS;
444 miscinit1 |= MISCINIT1_CLUT_INV; 462 miscinit1 |= MISCINIT1_CLUT_INV;
445 463
446 banshee_make_room(par, 1); 464 banshee_make_room(par, 1);
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index 3099630d0c3d..9d9d2009ad8c 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -45,9 +45,7 @@ static void tgafb_fillrect(struct fb_info *, const struct fb_fillrect *);
45static void tgafb_copyarea(struct fb_info *, const struct fb_copyarea *); 45static void tgafb_copyarea(struct fb_info *, const struct fb_copyarea *);
46 46
47static int tgafb_pci_register(struct pci_dev *, const struct pci_device_id *); 47static int tgafb_pci_register(struct pci_dev *, const struct pci_device_id *);
48#ifdef MODULE
49static void tgafb_pci_unregister(struct pci_dev *); 48static void tgafb_pci_unregister(struct pci_dev *);
50#endif
51 49
52static const char *mode_option = "640x480@60"; 50static const char *mode_option = "640x480@60";
53 51
@@ -1484,7 +1482,6 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1484 return ret; 1482 return ret;
1485} 1483}
1486 1484
1487#ifdef MODULE
1488static void __exit 1485static void __exit
1489tgafb_pci_unregister(struct pci_dev *pdev) 1486tgafb_pci_unregister(struct pci_dev *pdev)
1490{ 1487{
@@ -1500,6 +1497,7 @@ tgafb_pci_unregister(struct pci_dev *pdev)
1500 kfree(info); 1497 kfree(info);
1501} 1498}
1502 1499
1500#ifdef MODULE
1503static void __exit 1501static void __exit
1504tgafb_exit(void) 1502tgafb_exit(void)
1505{ 1503{
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 8fc1278d7fbd..3027841f9c24 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -19,9 +19,6 @@
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#ifdef __i386__
23#include <video/edid.h>
24#endif
25#include <asm/io.h> 22#include <asm/io.h>
26#include <asm/mtrr.h> 23#include <asm/mtrr.h>
27 24
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 6b6bb7c8abf6..23c125128024 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -131,8 +131,7 @@ static int afs_file_readpage(struct file *file, struct page *page)
131 131
132 vnode = AFS_FS_I(inode); 132 vnode = AFS_FS_I(inode);
133 133
134 if (!PageLocked(page)) 134 BUG_ON(!PageLocked(page));
135 PAGE_BUG(page);
136 135
137 ret = -ESTALE; 136 ret = -ESTALE;
138 if (vnode->flags & AFS_VNODE_DELETED) 137 if (vnode->flags & AFS_VNODE_DELETED)
diff --git a/fs/aio.c b/fs/aio.c
index d06a266769bc..7afa222f6802 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -40,9 +40,6 @@
40#define dprintk(x...) do { ; } while (0) 40#define dprintk(x...) do { ; } while (0)
41#endif 41#endif
42 42
43long aio_run = 0; /* for testing only */
44long aio_wakeups = 0; /* for testing only */
45
46/*------ sysctl variables----*/ 43/*------ sysctl variables----*/
47atomic_t aio_nr = ATOMIC_INIT(0); /* current system wide number of aio requests */ 44atomic_t aio_nr = ATOMIC_INIT(0); /* current system wide number of aio requests */
48unsigned aio_max_nr = 0x10000; /* system wide maximum number of aio requests */ 45unsigned aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
@@ -58,7 +55,7 @@ static void aio_fput_routine(void *);
58static DECLARE_WORK(fput_work, aio_fput_routine, NULL); 55static DECLARE_WORK(fput_work, aio_fput_routine, NULL);
59 56
60static DEFINE_SPINLOCK(fput_lock); 57static DEFINE_SPINLOCK(fput_lock);
61LIST_HEAD(fput_head); 58static LIST_HEAD(fput_head);
62 59
63static void aio_kick_handler(void *); 60static void aio_kick_handler(void *);
64 61
@@ -290,7 +287,7 @@ static void aio_cancel_all(struct kioctx *ctx)
290 spin_unlock_irq(&ctx->ctx_lock); 287 spin_unlock_irq(&ctx->ctx_lock);
291} 288}
292 289
293void wait_for_all_aios(struct kioctx *ctx) 290static void wait_for_all_aios(struct kioctx *ctx)
294{ 291{
295 struct task_struct *tsk = current; 292 struct task_struct *tsk = current;
296 DECLARE_WAITQUEUE(wait, tsk); 293 DECLARE_WAITQUEUE(wait, tsk);
@@ -405,7 +402,6 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx)
405 req->ki_ctx = ctx; 402 req->ki_ctx = ctx;
406 req->ki_cancel = NULL; 403 req->ki_cancel = NULL;
407 req->ki_retry = NULL; 404 req->ki_retry = NULL;
408 req->ki_obj.user = NULL;
409 req->ki_dtor = NULL; 405 req->ki_dtor = NULL;
410 req->private = NULL; 406 req->private = NULL;
411 INIT_LIST_HEAD(&req->ki_run_list); 407 INIT_LIST_HEAD(&req->ki_run_list);
@@ -451,11 +447,6 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
451{ 447{
452 if (req->ki_dtor) 448 if (req->ki_dtor)
453 req->ki_dtor(req); 449 req->ki_dtor(req);
454 req->ki_ctx = NULL;
455 req->ki_filp = NULL;
456 req->ki_obj.user = NULL;
457 req->ki_dtor = NULL;
458 req->private = NULL;
459 kmem_cache_free(kiocb_cachep, req); 450 kmem_cache_free(kiocb_cachep, req);
460 ctx->reqs_active--; 451 ctx->reqs_active--;
461 452
@@ -592,7 +583,7 @@ static void use_mm(struct mm_struct *mm)
592 * Comments: Called with ctx->ctx_lock held. This nests 583 * Comments: Called with ctx->ctx_lock held. This nests
593 * task_lock instead ctx_lock. 584 * task_lock instead ctx_lock.
594 */ 585 */
595void unuse_mm(struct mm_struct *mm) 586static void unuse_mm(struct mm_struct *mm)
596{ 587{
597 struct task_struct *tsk = current; 588 struct task_struct *tsk = current;
598 589
@@ -623,7 +614,6 @@ static inline int __queue_kicked_iocb(struct kiocb *iocb)
623 if (list_empty(&iocb->ki_run_list)) { 614 if (list_empty(&iocb->ki_run_list)) {
624 list_add_tail(&iocb->ki_run_list, 615 list_add_tail(&iocb->ki_run_list,
625 &ctx->run_list); 616 &ctx->run_list);
626 iocb->ki_queued++;
627 return 1; 617 return 1;
628 } 618 }
629 return 0; 619 return 0;
@@ -664,10 +654,8 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
664 } 654 }
665 655
666 if (!(iocb->ki_retried & 0xff)) { 656 if (!(iocb->ki_retried & 0xff)) {
667 pr_debug("%ld retry: %d of %d (kick %ld, Q %ld run %ld, wake %ld)\n", 657 pr_debug("%ld retry: %d of %d\n", iocb->ki_retried,
668 iocb->ki_retried, 658 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
669 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes,
670 iocb->ki_kicked, iocb->ki_queued, aio_run, aio_wakeups);
671 } 659 }
672 660
673 if (!(retry = iocb->ki_retry)) { 661 if (!(retry = iocb->ki_retry)) {
@@ -774,7 +762,6 @@ out:
774static int __aio_run_iocbs(struct kioctx *ctx) 762static int __aio_run_iocbs(struct kioctx *ctx)
775{ 763{
776 struct kiocb *iocb; 764 struct kiocb *iocb;
777 int count = 0;
778 LIST_HEAD(run_list); 765 LIST_HEAD(run_list);
779 766
780 list_splice_init(&ctx->run_list, &run_list); 767 list_splice_init(&ctx->run_list, &run_list);
@@ -789,9 +776,7 @@ static int __aio_run_iocbs(struct kioctx *ctx)
789 aio_run_iocb(iocb); 776 aio_run_iocb(iocb);
790 if (__aio_put_req(ctx, iocb)) /* drop extra ref */ 777 if (__aio_put_req(ctx, iocb)) /* drop extra ref */
791 put_ioctx(ctx); 778 put_ioctx(ctx);
792 count++;
793 } 779 }
794 aio_run++;
795 if (!list_empty(&ctx->run_list)) 780 if (!list_empty(&ctx->run_list))
796 return 1; 781 return 1;
797 return 0; 782 return 0;
@@ -879,7 +864,7 @@ static void aio_kick_handler(void *data)
879 * and if required activate the aio work queue to process 864 * and if required activate the aio work queue to process
880 * it 865 * it
881 */ 866 */
882void queue_kicked_iocb(struct kiocb *iocb) 867static void queue_kicked_iocb(struct kiocb *iocb)
883{ 868{
884 struct kioctx *ctx = iocb->ki_ctx; 869 struct kioctx *ctx = iocb->ki_ctx;
885 unsigned long flags; 870 unsigned long flags;
@@ -890,10 +875,8 @@ void queue_kicked_iocb(struct kiocb *iocb)
890 spin_lock_irqsave(&ctx->ctx_lock, flags); 875 spin_lock_irqsave(&ctx->ctx_lock, flags);
891 run = __queue_kicked_iocb(iocb); 876 run = __queue_kicked_iocb(iocb);
892 spin_unlock_irqrestore(&ctx->ctx_lock, flags); 877 spin_unlock_irqrestore(&ctx->ctx_lock, flags);
893 if (run) { 878 if (run)
894 aio_queue_work(ctx); 879 aio_queue_work(ctx);
895 aio_wakeups++;
896 }
897} 880}
898 881
899/* 882/*
@@ -913,7 +896,6 @@ void fastcall kick_iocb(struct kiocb *iocb)
913 return; 896 return;
914 } 897 }
915 898
916 iocb->ki_kicked++;
917 /* If its already kicked we shouldn't queue it again */ 899 /* If its already kicked we shouldn't queue it again */
918 if (!kiocbTryKick(iocb)) { 900 if (!kiocbTryKick(iocb)) {
919 queue_kicked_iocb(iocb); 901 queue_kicked_iocb(iocb);
@@ -984,7 +966,8 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
984 966
985 tail = info->tail; 967 tail = info->tail;
986 event = aio_ring_event(info, tail, KM_IRQ0); 968 event = aio_ring_event(info, tail, KM_IRQ0);
987 tail = (tail + 1) % info->nr; 969 if (++tail >= info->nr)
970 tail = 0;
988 971
989 event->obj = (u64)(unsigned long)iocb->ki_obj.user; 972 event->obj = (u64)(unsigned long)iocb->ki_obj.user;
990 event->data = iocb->ki_user_data; 973 event->data = iocb->ki_user_data;
@@ -1008,10 +991,8 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
1008 991
1009 pr_debug("added to ring %p at [%lu]\n", iocb, tail); 992 pr_debug("added to ring %p at [%lu]\n", iocb, tail);
1010 993
1011 pr_debug("%ld retries: %d of %d (kicked %ld, Q %ld run %ld wake %ld)\n", 994 pr_debug("%ld retries: %d of %d\n", iocb->ki_retried,
1012 iocb->ki_retried, 995 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
1013 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes,
1014 iocb->ki_kicked, iocb->ki_queued, aio_run, aio_wakeups);
1015put_rq: 996put_rq:
1016 /* everything turned out well, dispose of the aiocb. */ 997 /* everything turned out well, dispose of the aiocb. */
1017 ret = __aio_put_req(ctx, iocb); 998 ret = __aio_put_req(ctx, iocb);
@@ -1119,7 +1100,6 @@ static int read_events(struct kioctx *ctx,
1119 int i = 0; 1100 int i = 0;
1120 struct io_event ent; 1101 struct io_event ent;
1121 struct aio_timeout to; 1102 struct aio_timeout to;
1122 int event_loop = 0; /* testing only */
1123 int retry = 0; 1103 int retry = 0;
1124 1104
1125 /* needed to zero any padding within an entry (there shouldn't be 1105 /* needed to zero any padding within an entry (there shouldn't be
@@ -1186,7 +1166,6 @@ retry:
1186 if (to.timed_out) /* Only check after read evt */ 1166 if (to.timed_out) /* Only check after read evt */
1187 break; 1167 break;
1188 schedule(); 1168 schedule();
1189 event_loop++;
1190 if (signal_pending(tsk)) { 1169 if (signal_pending(tsk)) {
1191 ret = -EINTR; 1170 ret = -EINTR;
1192 break; 1171 break;
@@ -1214,9 +1193,6 @@ retry:
1214 if (timeout) 1193 if (timeout)
1215 clear_timeout(&to); 1194 clear_timeout(&to);
1216out: 1195out:
1217 pr_debug("event loop executed %d times\n", event_loop);
1218 pr_debug("aio_run %ld\n", aio_run);
1219 pr_debug("aio_wakeups %ld\n", aio_wakeups);
1220 return i ? i : ret; 1196 return i ? i : ret;
1221} 1197}
1222 1198
@@ -1401,7 +1377,7 @@ static ssize_t aio_fsync(struct kiocb *iocb)
1401 * Performs the initial checks and aio retry method 1377 * Performs the initial checks and aio retry method
1402 * setup for the kiocb at the time of io submission. 1378 * setup for the kiocb at the time of io submission.
1403 */ 1379 */
1404ssize_t aio_setup_iocb(struct kiocb *kiocb) 1380static ssize_t aio_setup_iocb(struct kiocb *kiocb)
1405{ 1381{
1406 struct file *file = kiocb->ki_filp; 1382 struct file *file = kiocb->ki_filp;
1407 ssize_t ret = 0; 1383 ssize_t ret = 0;
@@ -1470,7 +1446,8 @@ ssize_t aio_setup_iocb(struct kiocb *kiocb)
1470 * because this callback isn't used for wait queues which 1446 * because this callback isn't used for wait queues which
1471 * are nested inside ioctx lock (i.e. ctx->wait) 1447 * are nested inside ioctx lock (i.e. ctx->wait)
1472 */ 1448 */
1473int aio_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key) 1449static int aio_wake_function(wait_queue_t *wait, unsigned mode,
1450 int sync, void *key)
1474{ 1451{
1475 struct kiocb *iocb = container_of(wait, struct kiocb, ki_wait); 1452 struct kiocb *iocb = container_of(wait, struct kiocb, ki_wait);
1476 1453
@@ -1514,8 +1491,7 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1514 } 1491 }
1515 1492
1516 req->ki_filp = file; 1493 req->ki_filp = file;
1517 iocb->aio_key = req->ki_key; 1494 ret = put_user(req->ki_key, &user_iocb->aio_key);
1518 ret = put_user(iocb->aio_key, &user_iocb->aio_key);
1519 if (unlikely(ret)) { 1495 if (unlikely(ret)) {
1520 dprintk("EFAULT: aio_key\n"); 1496 dprintk("EFAULT: aio_key\n");
1521 goto out_put_req; 1497 goto out_put_req;
@@ -1530,13 +1506,7 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1530 req->ki_opcode = iocb->aio_lio_opcode; 1506 req->ki_opcode = iocb->aio_lio_opcode;
1531 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function); 1507 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
1532 INIT_LIST_HEAD(&req->ki_wait.task_list); 1508 INIT_LIST_HEAD(&req->ki_wait.task_list);
1533 req->ki_run_list.next = req->ki_run_list.prev = NULL;
1534 req->ki_retry = NULL;
1535 req->ki_retried = 0; 1509 req->ki_retried = 0;
1536 req->ki_kicked = 0;
1537 req->ki_queued = 0;
1538 aio_run = 0;
1539 aio_wakeups = 0;
1540 1510
1541 ret = aio_setup_iocb(req); 1511 ret = aio_setup_iocb(req);
1542 1512
@@ -1544,10 +1514,14 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1544 goto out_put_req; 1514 goto out_put_req;
1545 1515
1546 spin_lock_irq(&ctx->ctx_lock); 1516 spin_lock_irq(&ctx->ctx_lock);
1547 list_add_tail(&req->ki_run_list, &ctx->run_list); 1517 if (likely(list_empty(&ctx->run_list))) {
1548 /* drain the run list */ 1518 aio_run_iocb(req);
1549 while (__aio_run_iocbs(ctx)) 1519 } else {
1550 ; 1520 list_add_tail(&req->ki_run_list, &ctx->run_list);
1521 /* drain the run list */
1522 while (__aio_run_iocbs(ctx))
1523 ;
1524 }
1551 spin_unlock_irq(&ctx->ctx_lock); 1525 spin_unlock_irq(&ctx->ctx_lock);
1552 aio_put_req(req); /* drop extra ref to req */ 1526 aio_put_req(req); /* drop extra ref to req */
1553 return 0; 1527 return 0;
@@ -1620,7 +1594,8 @@ asmlinkage long sys_io_submit(aio_context_t ctx_id, long nr,
1620 * Finds a given iocb for cancellation. 1594 * Finds a given iocb for cancellation.
1621 * MUST be called with ctx->ctx_lock held. 1595 * MUST be called with ctx->ctx_lock held.
1622 */ 1596 */
1623struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb, u32 key) 1597static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb,
1598 u32 key)
1624{ 1599{
1625 struct list_head *pos; 1600 struct list_head *pos;
1626 /* TODO: use a hash or array, this sucks. */ 1601 /* TODO: use a hash or array, this sucks. */
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index f5a52c871726..c7b2b8890188 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -84,6 +84,7 @@ struct autofs_wait_queue {
84 char *name; 84 char *name;
85 /* This is for status reporting upon return */ 85 /* This is for status reporting upon return */
86 int status; 86 int status;
87 atomic_t notified;
87 atomic_t wait_ctr; 88 atomic_t wait_ctr;
88}; 89};
89 90
@@ -101,6 +102,7 @@ struct autofs_sb_info {
101 int needs_reghost; 102 int needs_reghost;
102 struct super_block *sb; 103 struct super_block *sb;
103 struct semaphore wq_sem; 104 struct semaphore wq_sem;
105 spinlock_t fs_lock;
104 struct autofs_wait_queue *queues; /* Wait queue pointer */ 106 struct autofs_wait_queue *queues; /* Wait queue pointer */
105}; 107};
106 108
@@ -126,9 +128,18 @@ static inline int autofs4_oz_mode(struct autofs_sb_info *sbi) {
126static inline int autofs4_ispending(struct dentry *dentry) 128static inline int autofs4_ispending(struct dentry *dentry)
127{ 129{
128 struct autofs_info *inf = autofs4_dentry_ino(dentry); 130 struct autofs_info *inf = autofs4_dentry_ino(dentry);
131 int pending = 0;
129 132
130 return (dentry->d_flags & DCACHE_AUTOFS_PENDING) || 133 if (dentry->d_flags & DCACHE_AUTOFS_PENDING)
131 (inf != NULL && inf->flags & AUTOFS_INF_EXPIRING); 134 return 1;
135
136 if (inf) {
137 spin_lock(&inf->sbi->fs_lock);
138 pending = inf->flags & AUTOFS_INF_EXPIRING;
139 spin_unlock(&inf->sbi->fs_lock);
140 }
141
142 return pending;
132} 143}
133 144
134static inline void autofs4_copy_atime(struct file *src, struct file *dst) 145static inline void autofs4_copy_atime(struct file *src, struct file *dst)
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 31540a6404d9..500425e24fba 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -99,6 +99,10 @@ static int autofs4_check_tree(struct vfsmount *mnt,
99 if (!autofs4_can_expire(top, timeout, do_now)) 99 if (!autofs4_can_expire(top, timeout, do_now))
100 return 0; 100 return 0;
101 101
102 /* Is someone visiting anywhere in the tree ? */
103 if (may_umount_tree(mnt))
104 return 0;
105
102 spin_lock(&dcache_lock); 106 spin_lock(&dcache_lock);
103repeat: 107repeat:
104 next = this_parent->d_subdirs.next; 108 next = this_parent->d_subdirs.next;
@@ -270,10 +274,18 @@ static struct dentry *autofs4_expire(struct super_block *sb,
270 274
271 /* Case 2: tree mount, expire iff entire tree is not busy */ 275 /* Case 2: tree mount, expire iff entire tree is not busy */
272 if (!exp_leaves) { 276 if (!exp_leaves) {
277 /* Lock the tree as we must expire as a whole */
278 spin_lock(&sbi->fs_lock);
273 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) { 279 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) {
274 expired = dentry; 280 struct autofs_info *inf = autofs4_dentry_ino(dentry);
275 break; 281
282 /* Set this flag early to catch sys_chdir and the like */
283 inf->flags |= AUTOFS_INF_EXPIRING;
284 spin_unlock(&sbi->fs_lock);
285 expired = dentry;
286 break;
276 } 287 }
288 spin_unlock(&sbi->fs_lock);
277 /* Case 3: direct mount, expire individual leaves */ 289 /* Case 3: direct mount, expire individual leaves */
278 } else { 290 } else {
279 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); 291 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index a52560746628..4bb14cc68040 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -206,6 +206,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
206 sbi->version = 0; 206 sbi->version = 0;
207 sbi->sub_version = 0; 207 sbi->sub_version = 0;
208 init_MUTEX(&sbi->wq_sem); 208 init_MUTEX(&sbi->wq_sem);
209 spin_lock_init(&sbi->fs_lock);
209 sbi->queues = NULL; 210 sbi->queues = NULL;
210 s->s_blocksize = 1024; 211 s->s_blocksize = 1024;
211 s->s_blocksize_bits = 10; 212 s->s_blocksize_bits = 10;
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 1ab24a662e09..5a40d36e5a51 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -210,17 +210,8 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
210 wq->len = len; 210 wq->len = len;
211 wq->status = -EINTR; /* Status return if interrupted */ 211 wq->status = -EINTR; /* Status return if interrupted */
212 atomic_set(&wq->wait_ctr, 2); 212 atomic_set(&wq->wait_ctr, 2);
213 atomic_set(&wq->notified, 1);
213 up(&sbi->wq_sem); 214 up(&sbi->wq_sem);
214
215 DPRINTK("new wait id = 0x%08lx, name = %.*s, nfy=%d",
216 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
217 /* autofs4_notify_daemon() may block */
218 if (notify != NFY_NONE) {
219 autofs4_notify_daemon(sbi,wq,
220 notify == NFY_MOUNT ?
221 autofs_ptype_missing :
222 autofs_ptype_expire_multi);
223 }
224 } else { 215 } else {
225 atomic_inc(&wq->wait_ctr); 216 atomic_inc(&wq->wait_ctr);
226 up(&sbi->wq_sem); 217 up(&sbi->wq_sem);
@@ -229,6 +220,17 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
229 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify); 220 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
230 } 221 }
231 222
223 if (notify != NFY_NONE && atomic_dec_and_test(&wq->notified)) {
224 int type = (notify == NFY_MOUNT ?
225 autofs_ptype_missing : autofs_ptype_expire_multi);
226
227 DPRINTK(("new wait id = 0x%08lx, name = %.*s, nfy=%d\n",
228 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify));
229
230 /* autofs4_notify_daemon() may block */
231 autofs4_notify_daemon(sbi, wq, type);
232 }
233
232 /* wq->name is NULL if and only if the lock is already released */ 234 /* wq->name is NULL if and only if the lock is already released */
233 235
234 if ( sbi->catatonic ) { 236 if ( sbi->catatonic ) {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 672a31924f3c..e172180a1d8c 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -47,7 +47,7 @@ static struct file_operations bad_file_ops =
47 .get_unmapped_area = EIO_ERROR, 47 .get_unmapped_area = EIO_ERROR,
48}; 48};
49 49
50struct inode_operations bad_inode_ops = 50static struct inode_operations bad_inode_ops =
51{ 51{
52 .create = EIO_ERROR, 52 .create = EIO_ERROR,
53 .lookup = EIO_ERROR, 53 .lookup = EIO_ERROR,
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 6ae62cbf7c2e..ce9423bb2de3 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -945,7 +945,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
945 retval = arch_setup_additional_pages(bprm, executable_stack); 945 retval = arch_setup_additional_pages(bprm, executable_stack);
946 if (retval < 0) { 946 if (retval < 0) {
947 send_sig(SIGKILL, current, 0); 947 send_sig(SIGKILL, current, 0);
948 goto out_free_dentry; 948 goto out;
949 } 949 }
950#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ 950#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */
951 951
diff --git a/fs/bio.c b/fs/bio.c
index e5349e834563..3a1472acc361 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -140,6 +140,7 @@ inline void bio_init(struct bio *bio)
140 * bio_alloc_bioset - allocate a bio for I/O 140 * bio_alloc_bioset - allocate a bio for I/O
141 * @gfp_mask: the GFP_ mask given to the slab allocator 141 * @gfp_mask: the GFP_ mask given to the slab allocator
142 * @nr_iovecs: number of iovecs to pre-allocate 142 * @nr_iovecs: number of iovecs to pre-allocate
143 * @bs: the bio_set to allocate from
143 * 144 *
144 * Description: 145 * Description:
145 * bio_alloc_bioset will first try it's on mempool to satisfy the allocation. 146 * bio_alloc_bioset will first try it's on mempool to satisfy the allocation.
@@ -629,6 +630,7 @@ out:
629 630
630/** 631/**
631 * bio_map_user - map user address into bio 632 * bio_map_user - map user address into bio
633 * @q: the request_queue_t for the bio
632 * @bdev: destination block device 634 * @bdev: destination block device
633 * @uaddr: start of user address 635 * @uaddr: start of user address
634 * @len: length in bytes 636 * @len: length in bytes
diff --git a/fs/block_dev.c b/fs/block_dev.c
index d19d07c49ad3..c0cbd1bc1a02 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -530,7 +530,7 @@ int check_disk_change(struct block_device *bdev)
530 if (!bdops->media_changed(bdev->bd_disk)) 530 if (!bdops->media_changed(bdev->bd_disk))
531 return 0; 531 return 0;
532 532
533 if (__invalidate_device(bdev, 0)) 533 if (__invalidate_device(bdev))
534 printk("VFS: busy inodes on changed media.\n"); 534 printk("VFS: busy inodes on changed media.\n");
535 535
536 if (bdops->revalidate_disk) 536 if (bdops->revalidate_disk)
diff --git a/fs/buffer.c b/fs/buffer.c
index 3b12cf947aba..6f88dcc6d002 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -218,7 +218,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
218 sb = get_super(bdev); 218 sb = get_super(bdev);
219 if (sb && !(sb->s_flags & MS_RDONLY)) { 219 if (sb && !(sb->s_flags & MS_RDONLY)) {
220 sb->s_frozen = SB_FREEZE_WRITE; 220 sb->s_frozen = SB_FREEZE_WRITE;
221 wmb(); 221 smp_wmb();
222 222
223 sync_inodes_sb(sb, 0); 223 sync_inodes_sb(sb, 0);
224 DQUOT_SYNC(sb); 224 DQUOT_SYNC(sb);
@@ -235,7 +235,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
235 sync_inodes_sb(sb, 1); 235 sync_inodes_sb(sb, 1);
236 236
237 sb->s_frozen = SB_FREEZE_TRANS; 237 sb->s_frozen = SB_FREEZE_TRANS;
238 wmb(); 238 smp_wmb();
239 239
240 sync_blockdev(sb->s_bdev); 240 sync_blockdev(sb->s_bdev);
241 241
@@ -263,7 +263,7 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb)
263 if (sb->s_op->unlockfs) 263 if (sb->s_op->unlockfs)
264 sb->s_op->unlockfs(sb); 264 sb->s_op->unlockfs(sb);
265 sb->s_frozen = SB_UNFROZEN; 265 sb->s_frozen = SB_UNFROZEN;
266 wmb(); 266 smp_wmb();
267 wake_up(&sb->s_wait_unfrozen); 267 wake_up(&sb->s_wait_unfrozen);
268 drop_super(sb); 268 drop_super(sb);
269 } 269 }
@@ -774,15 +774,14 @@ repeat:
774/** 774/**
775 * sync_mapping_buffers - write out and wait upon a mapping's "associated" 775 * sync_mapping_buffers - write out and wait upon a mapping's "associated"
776 * buffers 776 * buffers
777 * @buffer_mapping - the mapping which backs the buffers' data 777 * @mapping: the mapping which wants those buffers written
778 * @mapping - the mapping which wants those buffers written
779 * 778 *
780 * Starts I/O against the buffers at mapping->private_list, and waits upon 779 * Starts I/O against the buffers at mapping->private_list, and waits upon
781 * that I/O. 780 * that I/O.
782 * 781 *
783 * Basically, this is a convenience function for fsync(). @buffer_mapping is 782 * Basically, this is a convenience function for fsync().
784 * the blockdev which "owns" the buffers and @mapping is a file or directory 783 * @mapping is a file or directory which needs those buffers to be written for
785 * which needs those buffers to be written for a successful fsync(). 784 * a successful fsync().
786 */ 785 */
787int sync_mapping_buffers(struct address_space *mapping) 786int sync_mapping_buffers(struct address_space *mapping)
788{ 787{
@@ -1211,7 +1210,7 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
1211 return 1; 1210 return 1;
1212} 1211}
1213 1212
1214struct buffer_head * 1213static struct buffer_head *
1215__getblk_slow(struct block_device *bdev, sector_t block, int size) 1214__getblk_slow(struct block_device *bdev, sector_t block, int size)
1216{ 1215{
1217 /* Size must be multiple of hard sectorsize */ 1216 /* Size must be multiple of hard sectorsize */
@@ -1263,6 +1262,7 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size)
1263 1262
1264/** 1263/**
1265 * mark_buffer_dirty - mark a buffer_head as needing writeout 1264 * mark_buffer_dirty - mark a buffer_head as needing writeout
1265 * @bh: the buffer_head to mark dirty
1266 * 1266 *
1267 * mark_buffer_dirty() will set the dirty bit against the buffer, then set its 1267 * mark_buffer_dirty() will set the dirty bit against the buffer, then set its
1268 * backing page dirty, then tag the page as dirty in its address_space's radix 1268 * backing page dirty, then tag the page as dirty in its address_space's radix
@@ -1501,6 +1501,7 @@ EXPORT_SYMBOL(__breadahead);
1501 1501
1502/** 1502/**
1503 * __bread() - reads a specified block and returns the bh 1503 * __bread() - reads a specified block and returns the bh
1504 * @bdev: the block_device to read from
1504 * @block: number of block 1505 * @block: number of block
1505 * @size: size (in bytes) to read 1506 * @size: size (in bytes) to read
1506 * 1507 *
@@ -1808,7 +1809,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1808 } while (bh != head); 1809 } while (bh != head);
1809 1810
1810 do { 1811 do {
1811 get_bh(bh);
1812 if (!buffer_mapped(bh)) 1812 if (!buffer_mapped(bh))
1813 continue; 1813 continue;
1814 /* 1814 /*
@@ -1837,7 +1837,6 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1837 */ 1837 */
1838 BUG_ON(PageWriteback(page)); 1838 BUG_ON(PageWriteback(page));
1839 set_page_writeback(page); 1839 set_page_writeback(page);
1840 unlock_page(page);
1841 1840
1842 do { 1841 do {
1843 struct buffer_head *next = bh->b_this_page; 1842 struct buffer_head *next = bh->b_this_page;
@@ -1845,9 +1844,9 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1845 submit_bh(WRITE, bh); 1844 submit_bh(WRITE, bh);
1846 nr_underway++; 1845 nr_underway++;
1847 } 1846 }
1848 put_bh(bh);
1849 bh = next; 1847 bh = next;
1850 } while (bh != head); 1848 } while (bh != head);
1849 unlock_page(page);
1851 1850
1852 err = 0; 1851 err = 0;
1853done: 1852done:
@@ -1886,7 +1885,6 @@ recover:
1886 bh = head; 1885 bh = head;
1887 /* Recovery: lock and submit the mapped buffers */ 1886 /* Recovery: lock and submit the mapped buffers */
1888 do { 1887 do {
1889 get_bh(bh);
1890 if (buffer_mapped(bh) && buffer_dirty(bh)) { 1888 if (buffer_mapped(bh) && buffer_dirty(bh)) {
1891 lock_buffer(bh); 1889 lock_buffer(bh);
1892 mark_buffer_async_write(bh); 1890 mark_buffer_async_write(bh);
@@ -1909,7 +1907,6 @@ recover:
1909 submit_bh(WRITE, bh); 1907 submit_bh(WRITE, bh);
1910 nr_underway++; 1908 nr_underway++;
1911 } 1909 }
1912 put_bh(bh);
1913 bh = next; 1910 bh = next;
1914 } while (bh != head); 1911 } while (bh != head);
1915 goto done; 1912 goto done;
@@ -1952,7 +1949,7 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
1952 if (!buffer_mapped(bh)) { 1949 if (!buffer_mapped(bh)) {
1953 err = get_block(inode, block, bh, 1); 1950 err = get_block(inode, block, bh, 1);
1954 if (err) 1951 if (err)
1955 goto out; 1952 break;
1956 if (buffer_new(bh)) { 1953 if (buffer_new(bh)) {
1957 clear_buffer_new(bh); 1954 clear_buffer_new(bh);
1958 unmap_underlying_metadata(bh->b_bdev, 1955 unmap_underlying_metadata(bh->b_bdev,
@@ -1994,10 +1991,12 @@ static int __block_prepare_write(struct inode *inode, struct page *page,
1994 while(wait_bh > wait) { 1991 while(wait_bh > wait) {
1995 wait_on_buffer(*--wait_bh); 1992 wait_on_buffer(*--wait_bh);
1996 if (!buffer_uptodate(*wait_bh)) 1993 if (!buffer_uptodate(*wait_bh))
1997 return -EIO; 1994 err = -EIO;
1998 } 1995 }
1999 return 0; 1996 if (!err)
2000out: 1997 return err;
1998
1999 /* Error case: */
2001 /* 2000 /*
2002 * Zero out any newly allocated blocks to avoid exposing stale 2001 * Zero out any newly allocated blocks to avoid exposing stale
2003 * data. If BH_New is set, we know that the block was newly 2002 * data. If BH_New is set, we know that the block was newly
@@ -2078,8 +2077,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
2078 int nr, i; 2077 int nr, i;
2079 int fully_mapped = 1; 2078 int fully_mapped = 1;
2080 2079
2081 if (!PageLocked(page)) 2080 BUG_ON(!PageLocked(page));
2082 PAGE_BUG(page);
2083 blocksize = 1 << inode->i_blkbits; 2081 blocksize = 1 << inode->i_blkbits;
2084 if (!page_has_buffers(page)) 2082 if (!page_has_buffers(page))
2085 create_empty_buffers(page, blocksize, 0); 2083 create_empty_buffers(page, blocksize, 0);
@@ -2917,7 +2915,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free)
2917 2915
2918 bh = head; 2916 bh = head;
2919 do { 2917 do {
2920 if (buffer_write_io_error(bh)) 2918 if (buffer_write_io_error(bh) && page->mapping)
2921 set_bit(AS_EIO, &page->mapping->flags); 2919 set_bit(AS_EIO, &page->mapping->flags);
2922 if (buffer_busy(bh)) 2920 if (buffer_busy(bh))
2923 goto failed; 2921 goto failed;
@@ -3115,7 +3113,7 @@ void __init buffer_init(void)
3115 3113
3116 bh_cachep = kmem_cache_create("buffer_head", 3114 bh_cachep = kmem_cache_create("buffer_head",
3117 sizeof(struct buffer_head), 0, 3115 sizeof(struct buffer_head), 0,
3118 SLAB_PANIC, init_buffer_head, NULL); 3116 SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, init_buffer_head, NULL);
3119 3117
3120 /* 3118 /*
3121 * Limit the bh occupancy to 10% of ZONE_NORMAL 3119 * Limit the bh occupancy to 10% of ZONE_NORMAL
diff --git a/fs/char_dev.c b/fs/char_dev.c
index a745b1d9e545..c1e3537909fc 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -328,7 +328,7 @@ void cd_forget(struct inode *inode)
328 spin_unlock(&cdev_lock); 328 spin_unlock(&cdev_lock);
329} 329}
330 330
331void cdev_purge(struct cdev *cdev) 331static void cdev_purge(struct cdev *cdev)
332{ 332{
333 spin_lock(&cdev_lock); 333 spin_lock(&cdev_lock);
334 while (!list_empty(&cdev->list)) { 334 while (!list_empty(&cdev->list)) {
diff --git a/fs/cifs/AUTHORS b/fs/cifs/AUTHORS
index acce36e25d2e..72fdc10dfdd7 100644
--- a/fs/cifs/AUTHORS
+++ b/fs/cifs/AUTHORS
@@ -4,13 +4,16 @@ Steve French (sfrench@samba.org)
4 4
5The author wishes to express his appreciation and thanks to: 5The author wishes to express his appreciation and thanks to:
6Andrew Tridgell (Samba team) for his early suggestions about smb/cifs VFS 6Andrew Tridgell (Samba team) for his early suggestions about smb/cifs VFS
7improvements. Thanks to IBM for allowing me the time and test resources to pursue 7improvements. Thanks to IBM for allowing me time and test resources to pursue
8this project. Jim McDonough from IBM (and the Samba Team) for his help. 8this project, to Jim McDonough from IBM (and the Samba Team) for his help, to
9The IBM Linux JFS team for explaining many esoteric Linux filesystem features. 9the IBM Linux JFS team for explaining many esoteric Linux filesystem features.
10Jeremy Allison of the Samba team has done invaluable work in adding the server
11side of the original CIFS Unix extensions and reviewing and implementing
12portions of the newer CIFS POSIX extensions into the Samba 3 file server. Thank
10Dave Boutcher of IBM Rochester (author of the OS/400 smb/cifs filesystem client) 13Dave Boutcher of IBM Rochester (author of the OS/400 smb/cifs filesystem client)
11for proving years ago that a very good smb/cifs client could be done on a Unix like 14for proving years ago that very good smb/cifs clients could be done on Unix-like
12operating system. Volker Lendecke, Andrew Tridgell, Urban Widmark, John Newbigin 15operating systems. Volker Lendecke, Andrew Tridgell, Urban Widmark, John
13and others for their work on the Linux smbfs module over the years. Thanks to 16Newbigin and others for their work on the Linux smbfs module. Thanks to
14the other members of the Storage Network Industry Association CIFS Technical 17the other members of the Storage Network Industry Association CIFS Technical
15Workgroup for their work specifying this highly complex protocol and finally 18Workgroup for their work specifying this highly complex protocol and finally
16thanks to the Samba team for their technical advice and encouragement. 19thanks to the Samba team for their technical advice and encouragement.
@@ -24,9 +27,11 @@ Shobhit Dayal
24Sergey Vlasov 27Sergey Vlasov
25Richard Hughes 28Richard Hughes
26Yury Umanets 29Yury Umanets
27Mark Hamzy 30Mark Hamzy (for some of the early cifs IPv6 work)
28Domen Puncer 31Domen Puncer
29Jesper Juhl 32Jesper Juhl (in particular for lots of whitespace/formatting cleanup)
33Vince Negri and Dave Stahl (for finding an important caching bug)
34Adrian Bunk (kcalloc cleanups)
30 35
31Test case and Bug Report contributors 36Test case and Bug Report contributors
32------------------------------------- 37-------------------------------------
@@ -36,7 +41,8 @@ Rene Scharfe, Martin Josefsson, Alexander Wild, Anthony Liguori,
36Lars Muller, Urban Widmark, Massimiliano Ferrero, Howard Owen, 41Lars Muller, Urban Widmark, Massimiliano Ferrero, Howard Owen,
37Olaf Kirch, Kieron Briggs, Nick Millington and others. Also special 42Olaf Kirch, Kieron Briggs, Nick Millington and others. Also special
38mention to the Stanford Checker (SWAT) which pointed out many minor 43mention to the Stanford Checker (SWAT) which pointed out many minor
39bugs in error paths. 44bugs in error paths. Valuable suggestions also have come from Al Viro
45and Dave Miller.
40 46
41And thanks to the IBM LTC and Power test teams and SuSE testers for 47And thanks to the IBM LTC and Power test teams and SuSE testers for
42finding multiple bugs during excellent stress test runs. 48finding multiple bugs during excellent stress test runs.
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 5316c8dd6bff..95483baab706 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,7 +1,44 @@
1Version 1.31 1Version 1.34
2------------
3Fix error mapping of the TOO_MANY_LINKS (hardlinks) case.
4Do not oops if root user kills cifs oplock kernel thread or
5kills the cifsd thread (NB: killing the cifs kernel threads is not
6recommended, unmount and rmmod cifs will kill them when they are
7no longer needed). Fix readdir to ASCII servers (ie older servers
8which do not support Unicode) and also require asterik.
9
10
11Version 1.33
12------------
13Fix caching problem, in which readdir of directory containing a file
14which was cached could cause the file's time stamp to be updated
15without invalidating the readahead data (so we could get stale
16file data on the client for that file even as the server copy changed).
17Cleanup response processing so cifsd can not loop when abnormally
18terminated.
19
20
21Version 1.32
2------------ 22------------
3Fix oops in ls when Transact2 FindFirst (or FindNext) returns more than one 23Fix oops in ls when Transact2 FindFirst (or FindNext) returns more than one
4transact response for an SMB request and search entry split across two frames. 24transact response for an SMB request and search entry split across two frames.
25Add support for lsattr (getting ext2/ext3/reiserfs attr flags from the server)
26as new protocol extensions. Do not send Get/Set calls for POSIX ACLs
27unless server explicitly claims to support them in CIFS Unix extensions
28POSIX ACL capability bit. Fix packet signing when multiuser mounting with
29different users from the same client to the same server. Fix oops in
30cifs_close. Add mount option for remapping reserved characters in
31filenames (also allow recognizing files with created by SFU which have any
32of these seven reserved characters, except backslash, to be recognized).
33Fix invalid transact2 message (we were sometimes trying to interpret
34oplock breaks as SMB responses). Add ioctl for checking that the
35current uid matches the uid of the mounter (needed by umount.cifs).
36Reduce the number of large buffer allocations in cifs response processing
37(significantly reduces memory pressure under heavy stress with multiple
38processes accessing the same server at the same time).
39
40Version 1.31
41------------
5Fix updates of DOS attributes and time fields so that files on NT4 servers 42Fix updates of DOS attributes and time fields so that files on NT4 servers
6do not get marked delete on close. Display sizes of cifs buffer pools in 43do not get marked delete on close. Display sizes of cifs buffer pools in
7cifs stats. Fix oops in unmount when cifsd thread being killed by 44cifs stats. Fix oops in unmount when cifsd thread being killed by
diff --git a/fs/cifs/README b/fs/cifs/README
index 0f20edc935b5..e74df0c73256 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -32,9 +32,9 @@ the cifs download to your kernel build directory e.g.
326) make modules (or "make" if CIFS VFS not to be built as a module) 326) make modules (or "make" if CIFS VFS not to be built as a module)
33 33
34For Linux 2.6: 34For Linux 2.6:
351) Download the kernel (e.g. from http://www.kernel.org or from bitkeeper 351) Download the kernel (e.g. from http://www.kernel.org)
36at bk://linux.bkbits.net/linux-2.5) and change directory into the top 36and change directory into the top of the kernel directory tree
37of the kernel directory tree (e.g. /usr/src/linux-2.5.73) 37(e.g. /usr/src/linux-2.5.73)
382) make menuconfig (or make xconfig) 382) make menuconfig (or make xconfig)
393) select cifs from within the network filesystem choices 393) select cifs from within the network filesystem choices
404) save and exit 404) save and exit
@@ -75,7 +75,7 @@ Allowing User Mounts
75==================== 75====================
76To permit users to mount and unmount over directories they own is possible 76To permit users to mount and unmount over directories they own is possible
77with the cifs vfs. A way to enable such mounting is to mark the mount.cifs 77with the cifs vfs. A way to enable such mounting is to mark the mount.cifs
78utility as suid (e.g. "chmod +s /sbin/mount/cifs). To enable users to 78utility as suid (e.g. "chmod +s /sbin/mount.cifs). To enable users to
79umount shares they mount requires 79umount shares they mount requires
801) mount.cifs version 1.4 or later 801) mount.cifs version 1.4 or later
812) an entry for the share in /etc/fstab indicating that a user may 812) an entry for the share in /etc/fstab indicating that a user may
@@ -97,6 +97,26 @@ mount.cifs with the following flag:
97There is a corresponding manual page for cifs mounting in the Samba 3.0 and 97There is a corresponding manual page for cifs mounting in the Samba 3.0 and
98later source tree in docs/manpages/mount.cifs.8 98later source tree in docs/manpages/mount.cifs.8
99 99
100Allowing User Unmounts
101======================
102To permit users to ummount directories that they have user mounted (see above),
103the utility umount.cifs may be used. It may be invoked directly, or if
104umount.cifs is placed in /sbin, umount can invoke the cifs umount helper
105(at least for most versions of the umount utility) for umount of cifs
106mounts, unless umount is invoked with -i (which will avoid invoking a umount
107helper). As with mount.cifs, to enable user unmounts umount.cifs must be marked
108as suid (e.g. "chmod +s /sbin/umount.cifs") or equivalent (some distributions
109allow adding entries to a file to the /etc/permissions file to achieve the
110equivalent suid effect). For this utility to succeed the target path
111must be a cifs mount, and the uid of the current user must match the uid
112of the user who mounted the resource.
113
114Also note that the customary way of allowing user mounts and unmounts is
115(instead of using mount.cifs and unmount.cifs as suid) to add a line
116to the file /etc/fstab for each //server/share you wish to mount, but
117this can become unwieldy when potential mount targets include many
118or unpredictable UNC names.
119
100Samba Considerations 120Samba Considerations
101==================== 121====================
102To get the maximum benefit from the CIFS VFS, we recommend using a server that 122To get the maximum benefit from the CIFS VFS, we recommend using a server that
@@ -376,6 +396,19 @@ A partial list of the supported mount options follows:
376 attributes) to the server (default) e.g. via setfattr 396 attributes) to the server (default) e.g. via setfattr
377 and getfattr utilities. 397 and getfattr utilities.
378 nouser_xattr Do not allow getfattr/setfattr to get/set xattrs 398 nouser_xattr Do not allow getfattr/setfattr to get/set xattrs
399 mapchars Translate six of the seven reserved characters (not backslash)
400 *?<>|:
401 to the remap range (above 0xF000), which also
402 allows the CIFS client to recognize files created with
403 such characters by Windows's POSIX emulation. This can
404 also be useful when mounting to most versions of Samba
405 (which also forbids creating and opening files
406 whose names contain any of these seven characters).
407 This has no effect if the server does not support
408 Unicode on the wire.
409 nomapchars Do not translate any of these seven characters (default).
410 remount remount the share (often used to change from ro to rw mounts
411 or vice versa)
379 412
380The mount.cifs mount helper also accepts a few mount options before -o 413The mount.cifs mount helper also accepts a few mount options before -o
381including: 414including:
@@ -392,7 +425,7 @@ Misc /proc/fs/cifs Flags and Debug Info
392======================================= 425=======================================
393Informational pseudo-files: 426Informational pseudo-files:
394DebugData Displays information about active CIFS sessions 427DebugData Displays information about active CIFS sessions
395 and shares. 428 and shares, as well as the cifs.ko version.
396Stats Lists summary resource usage information as well as per 429Stats Lists summary resource usage information as well as per
397 share statistics, if CONFIG_CIFS_STATS in enabled 430 share statistics, if CONFIG_CIFS_STATS in enabled
398 in the kernel configuration. 431 in the kernel configuration.
@@ -449,7 +482,7 @@ and for more extensive tracing including the start of smb requests and responses
449Two other experimental features are under development and to test 482Two other experimental features are under development and to test
450require enabling CONFIG_CIFS_EXPERIMENTAL 483require enabling CONFIG_CIFS_EXPERIMENTAL
451 484
452 More efficient write operations and SMB buffer handling 485 More efficient write operations
453 486
454 DNOTIFY fcntl: needed for support of directory change 487 DNOTIFY fcntl: needed for support of directory change
455 notification and perhaps later for file leases) 488 notification and perhaps later for file leases)
@@ -467,8 +500,8 @@ returned success.
467 500
468Also note that "cat /proc/fs/cifs/DebugData" will display information about 501Also note that "cat /proc/fs/cifs/DebugData" will display information about
469the active sessions and the shares that are mounted. Note: NTLMv2 enablement 502the active sessions and the shares that are mounted. Note: NTLMv2 enablement
470will not work since they its implementation is not quite complete yet. 503will not work since its implementation is not quite complete yet. Do not alter
471Do not alter these configuration values unless you are doing specific testing. 504the ExtendedSecurity configuration value unless you are doing specific testing.
472Enabling extended security works to Windows 2000 Workstations and XP but not to 505Enabling extended security works to Windows 2000 Workstations and XP but not to
473Windows 2000 server or Samba since it does not usually send "raw NTLMSSP" 506Windows 2000 server or Samba since it does not usually send "raw NTLMSSP"
474(instead it sends NTLMSSP encapsulated in SPNEGO/GSSAPI, which support is not 507(instead it sends NTLMSSP encapsulated in SPNEGO/GSSAPI, which support is not
diff --git a/fs/cifs/TODO b/fs/cifs/TODO
index f4e3e1f67ee4..8cc881694e29 100644
--- a/fs/cifs/TODO
+++ b/fs/cifs/TODO
@@ -1,4 +1,4 @@
1version 1.22 July 30, 2004 1version 1.34 April 29, 2005
2 2
3A Partial List of Missing Features 3A Partial List of Missing Features
4================================== 4==================================
@@ -14,7 +14,7 @@ b) Better pam/winbind integration (e.g. to handle uid mapping
14better) 14better)
15 15
16c) multi-user mounts - multiplexed sessionsetups over single vc 16c) multi-user mounts - multiplexed sessionsetups over single vc
17(ie tcp session) - prettying up needed, and more testing needed 17(ie tcp session) - more testing needed
18 18
19d) Kerberos/SPNEGO session setup support - (started) 19d) Kerberos/SPNEGO session setup support - (started)
20 20
@@ -67,12 +67,26 @@ q) implement support for security and trusted categories of xattrs
67 67
68r) Implement O_DIRECT flag on open (already supported on mount) 68r) Implement O_DIRECT flag on open (already supported on mount)
69 69
70KNOWN BUGS (updated December 10, 2004) 70s) Allow remapping of last remaining character (\) to +0xF000 which
71(this character is valid for POSIX but not for Windows)
72
73t) Create UID mapping facility so server UIDs can be mapped on a per
74mount or a per server basis to client UIDs or nobody if no mapping
75exists. This is helpful when Unix extensions are negotiated to
76allow better permission checking when UIDs differ on the server
77and client. Add new protocol request to the CIFS protocol
78standard for asking the server for the corresponding name of a
79particular uid.
80
81KNOWN BUGS (updated April 29, 2005)
71==================================== 82====================================
83See http://bugzilla.samba.org - search on product "CifsVFS" for
84current bug list.
85
721) existing symbolic links (Windows reparse points) are recognized but 861) existing symbolic links (Windows reparse points) are recognized but
73can not be created remotely. They are implemented for Samba and those that 87can not be created remotely. They are implemented for Samba and those that
74support the CIFS Unix extensions but Samba has a bug currently handling 88support the CIFS Unix extensions, although earlier versions of Samba
75symlink text beginning with slash 89overly restrict the pathnames.
762) follow_link and readdir code does not follow dfs junctions 902) follow_link and readdir code does not follow dfs junctions
77but recognizes them 91but recognizes them
783) create of new files to FAT partitions on Windows servers can 923) create of new files to FAT partitions on Windows servers can
@@ -98,7 +112,5 @@ there are some easy changes that can be done to parallelize sequential writes,
98and when signing is disabled to request larger read sizes (larger than 112and when signing is disabled to request larger read sizes (larger than
99negotiated size) and send larger write sizes to modern servers. 113negotiated size) and send larger write sizes to modern servers.
100 114
1014) More exhaustively test the recently added NT4 support against various 1154) More exhaustively test against less common servers. More testing
102NT4 service pack levels, and fix cifs_setattr for setting file times and 116against Windows 9x, Windows ME servers.
103size to fall back to level 1 when error invalid level returned.
104
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index db28b561cd4b..4061e43471c1 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs_debug.c 2 * fs/cifs_debug.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2000,2003 4 * Copyright (C) International Business Machines Corp., 2000,2005
5 * 5 *
6 * Modified by Steve French (sfrench@us.ibm.com) 6 * Modified by Steve French (sfrench@us.ibm.com)
7 * 7 *
@@ -29,6 +29,7 @@
29#include "cifsglob.h" 29#include "cifsglob.h"
30#include "cifsproto.h" 30#include "cifsproto.h"
31#include "cifs_debug.h" 31#include "cifs_debug.h"
32#include "cifsfs.h"
32 33
33void 34void
34cifs_dump_mem(char *label, void *data, int length) 35cifs_dump_mem(char *label, void *data, int length)
@@ -78,8 +79,9 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
78 "Display Internal CIFS Data Structures for Debugging\n" 79 "Display Internal CIFS Data Structures for Debugging\n"
79 "---------------------------------------------------\n"); 80 "---------------------------------------------------\n");
80 buf += length; 81 buf += length;
81 82 length = sprintf(buf,"CIFS Version %s\n",CIFS_VERSION);
82 length = sprintf(buf, "Servers:\n"); 83 buf += length;
84 length = sprintf(buf, "Servers:");
83 buf += length; 85 buf += length;
84 86
85 i = 0; 87 i = 0;
@@ -87,12 +89,21 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
87 list_for_each(tmp, &GlobalSMBSessionList) { 89 list_for_each(tmp, &GlobalSMBSessionList) {
88 i++; 90 i++;
89 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 91 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
90 length = 92 if((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
91 sprintf(buf, 93 (ses->serverNOS == NULL)) {
92 "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\t", 94 buf += sprintf("\nentry for %s not fully displayed\n\t",
93 i, ses->serverName, ses->serverDomain, atomic_read(&ses->inUse), 95 ses->serverName);
94 ses->serverOS, ses->serverNOS, ses->capabilities,ses->status); 96
95 buf += length; 97 } else {
98 length =
99 sprintf(buf,
100 "\n%d) Name: %s Domain: %s Mounts: %d ServerOS: %s \n\tServerNOS: %s\tCapabilities: 0x%x\n\tSMB session status: %d\t",
101 i, ses->serverName, ses->serverDomain,
102 atomic_read(&ses->inUse),
103 ses->serverOS, ses->serverNOS,
104 ses->capabilities,ses->status);
105 buf += length;
106 }
96 if(ses->server) { 107 if(ses->server) {
97 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d", 108 buf += sprintf(buf, "TCP status: %d\n\tLocal Users To Server: %d SecMode: 0x%x Req Active: %d",
98 ses->server->tcpStatus, 109 ses->server->tcpStatus,
@@ -100,7 +111,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
100 ses->server->secMode, 111 ses->server->secMode,
101 atomic_read(&ses->server->inFlight)); 112 atomic_read(&ses->server->inFlight));
102 113
103 length = sprintf(buf, "\nMIDs: \n"); 114 length = sprintf(buf, "\nMIDs:\n");
104 buf += length; 115 buf += length;
105 116
106 spin_lock(&GlobalMid_Lock); 117 spin_lock(&GlobalMid_Lock);
@@ -109,7 +120,12 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
109 mid_q_entry, 120 mid_q_entry,
110 qhead); 121 qhead);
111 if(mid_entry) { 122 if(mid_entry) {
112 length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",mid_entry->midState,mid_entry->command,mid_entry->pid,mid_entry->tsk,mid_entry->mid); 123 length = sprintf(buf,"State: %d com: %d pid: %d tsk: %p mid %d\n",
124 mid_entry->midState,
125 (int)mid_entry->command,
126 mid_entry->pid,
127 mid_entry->tsk,
128 mid_entry->mid);
113 buf += length; 129 buf += length;
114 } 130 }
115 } 131 }
@@ -121,7 +137,7 @@ cifs_debug_data_read(char *buf, char **beginBuffer, off_t offset,
121 sprintf(buf, "\n"); 137 sprintf(buf, "\n");
122 buf++; 138 buf++;
123 139
124 length = sprintf(buf, "\nShares:\n"); 140 length = sprintf(buf, "Shares:");
125 buf += length; 141 buf += length;
126 142
127 i = 0; 143 i = 0;
@@ -200,7 +216,8 @@ cifs_stats_read(char *buf, char **beginBuffer, off_t offset,
200 buf += item_length; 216 buf += item_length;
201 item_length = 217 item_length =
202 sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n", 218 sprintf(buf,"SMB Request/Response Buffer: %d Pool size: %d\n",
203 bufAllocCount.counter,cifs_min_rcv + tcpSesAllocCount.counter); 219 bufAllocCount.counter,
220 cifs_min_rcv + tcpSesAllocCount.counter);
204 length += item_length; 221 length += item_length;
205 buf += item_length; 222 buf += item_length;
206 item_length = 223 item_length =
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
index 77da902d8f32..ec00d61d5308 100644
--- a/fs/cifs/cifs_fs_sb.h
+++ b/fs/cifs/cifs_fs_sb.h
@@ -23,6 +23,7 @@
23#define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */ 23#define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */
24#define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */ 24#define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */
25#define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */ 25#define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */
26#define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */
26 27
27struct cifs_sb_info { 28struct cifs_sb_info {
28 struct cifsTconInfo *tcon; /* primary mount */ 29 struct cifsTconInfo *tcon; /* primary mount */
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index a17adf4cb9ba..99a096d3f84d 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -76,8 +76,8 @@ cifs_strtoUCS(wchar_t * to, const char *from, int len,
76 charlen)); 76 charlen));
77 to[i] = cpu_to_le16(0x003f); /* a question mark */ 77 to[i] = cpu_to_le16(0x003f); /* a question mark */
78 charlen = 1; 78 charlen = 1;
79 } 79 } else
80 to[i] = cpu_to_le16(to[i]); 80 to[i] = cpu_to_le16(to[i]);
81 81
82 } 82 }
83 83
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 78829e7d8cd0..1959c7c4b185 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -50,7 +50,7 @@ static int cifs_calculate_signature(const struct smb_hdr * cifs_pdu, const char
50 return 0; 50 return 0;
51} 51}
52 52
53int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct cifsSesInfo * ses, 53int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct TCP_Server_Info * server,
54 __u32 * pexpected_response_sequence_number) 54 __u32 * pexpected_response_sequence_number)
55{ 55{
56 int rc = 0; 56 int rc = 0;
@@ -59,21 +59,21 @@ int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct cifsSesInfo * ses,
59 /* BB remember to initialize sequence number elsewhere and initialize mac_signing key elsewhere BB */ 59 /* BB remember to initialize sequence number elsewhere and initialize mac_signing key elsewhere BB */
60 /* BB remember to add code to save expected sequence number in midQ entry BB */ 60 /* BB remember to add code to save expected sequence number in midQ entry BB */
61 61
62 if((cifs_pdu == NULL) || (ses == NULL)) 62 if((cifs_pdu == NULL) || (server == NULL))
63 return -EINVAL; 63 return -EINVAL;
64 64
65 if((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0) 65 if((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0)
66 return rc; 66 return rc;
67 67
68 spin_lock(&GlobalMid_Lock); 68 spin_lock(&GlobalMid_Lock);
69 cifs_pdu->Signature.Sequence.SequenceNumber = cpu_to_le32(ses->sequence_number); 69 cifs_pdu->Signature.Sequence.SequenceNumber = cpu_to_le32(server->sequence_number);
70 cifs_pdu->Signature.Sequence.Reserved = 0; 70 cifs_pdu->Signature.Sequence.Reserved = 0;
71 71
72 *pexpected_response_sequence_number = ses->sequence_number++; 72 *pexpected_response_sequence_number = server->sequence_number++;
73 ses->sequence_number++; 73 server->sequence_number++;
74 spin_unlock(&GlobalMid_Lock); 74 spin_unlock(&GlobalMid_Lock);
75 75
76 rc = cifs_calculate_signature(cifs_pdu, ses->mac_signing_key,smb_signature); 76 rc = cifs_calculate_signature(cifs_pdu, server->mac_signing_key,smb_signature);
77 if(rc) 77 if(rc)
78 memset(cifs_pdu->Signature.SecuritySignature, 0, 8); 78 memset(cifs_pdu->Signature.SecuritySignature, 0, 8);
79 else 79 else
@@ -190,7 +190,7 @@ int CalcNTLMv2_partial_mac_key(struct cifsSesInfo * ses, struct nls_table * nls_
190 hmac_md5_update((const unsigned char *) unicode_buf, 190 hmac_md5_update((const unsigned char *) unicode_buf,
191 (user_name_len+dom_name_len)*2,&ctx); 191 (user_name_len+dom_name_len)*2,&ctx);
192 192
193 hmac_md5_final(ses->mac_signing_key,&ctx); 193 hmac_md5_final(ses->server->mac_signing_key,&ctx);
194 kfree(ucase_buf); 194 kfree(ucase_buf);
195 kfree(unicode_buf); 195 kfree(unicode_buf);
196 return 0; 196 return 0;
@@ -200,7 +200,7 @@ void CalcNTLMv2_response(const struct cifsSesInfo * ses,char * v2_session_respon
200 struct HMACMD5Context context; 200 struct HMACMD5Context context;
201 memcpy(v2_session_response + 8, ses->server->cryptKey,8); 201 memcpy(v2_session_response + 8, ses->server->cryptKey,8);
202 /* gen_blob(v2_session_response + 16); */ 202 /* gen_blob(v2_session_response + 16); */
203 hmac_md5_init_limK_to_64(ses->mac_signing_key, 16, &context); 203 hmac_md5_init_limK_to_64(ses->server->mac_signing_key, 16, &context);
204 204
205 hmac_md5_update(ses->server->cryptKey,8,&context); 205 hmac_md5_update(ses->server->cryptKey,8,&context);
206/* hmac_md5_update(v2_session_response+16)client thing,8,&context); */ /* BB fix */ 206/* hmac_md5_update(v2_session_response+16)client thing,8,&context); */ /* BB fix */
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 5082fce3c566..8cc23e7d0d5d 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -169,7 +169,8 @@ cifs_put_super(struct super_block *sb)
169static int 169static int
170cifs_statfs(struct super_block *sb, struct kstatfs *buf) 170cifs_statfs(struct super_block *sb, struct kstatfs *buf)
171{ 171{
172 int xid, rc = -EOPNOTSUPP; 172 int xid;
173 int rc = -EOPNOTSUPP;
173 struct cifs_sb_info *cifs_sb; 174 struct cifs_sb_info *cifs_sb;
174 struct cifsTconInfo *pTcon; 175 struct cifsTconInfo *pTcon;
175 176
@@ -181,31 +182,34 @@ cifs_statfs(struct super_block *sb, struct kstatfs *buf)
181 buf->f_type = CIFS_MAGIC_NUMBER; 182 buf->f_type = CIFS_MAGIC_NUMBER;
182 183
183 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ 184 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
184 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would presumably 185 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
185 be length of total path, note that some servers may be 186 presumably be total path, but note
186 able to support more than this, but best to be safe 187 that some servers (includinng Samba 3)
187 since Win2k and others can not handle very long filenames */ 188 have a shorter maximum path */
188 buf->f_files = 0; /* undefined */ 189 buf->f_files = 0; /* undefined */
189 buf->f_ffree = 0; /* unlimited */ 190 buf->f_ffree = 0; /* unlimited */
190 191
191#ifdef CONFIG_CIFS_EXPERIMENTAL 192#ifdef CONFIG_CIFS_EXPERIMENTAL
192/* BB we could add a second check for a QFS Unix capability bit */ 193/* BB we could add a second check for a QFS Unix capability bit */
193 if (pTcon->ses->capabilities & CAP_UNIX) 194/* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */
194 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf, cifs_sb->local_nls); 195 if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS &
196 le64_to_cpu(pTcon->fsUnixInfo.Capability)))
197 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf);
195 198
196 /* Only need to call the old QFSInfo if failed 199 /* Only need to call the old QFSInfo if failed
197 on newer one */ 200 on newer one */
198 if(rc) 201 if(rc)
199#endif /* CIFS_EXPERIMENTAL */ 202#endif /* CIFS_EXPERIMENTAL */
200 rc = CIFSSMBQFSInfo(xid, pTcon, buf, cifs_sb->local_nls); 203 rc = CIFSSMBQFSInfo(xid, pTcon, buf);
201 204
202 /* 205 /*
203 int f_type; 206 int f_type;
204 __fsid_t f_fsid; 207 __fsid_t f_fsid;
205 int f_namelen; */ 208 int f_namelen; */
206 /* BB get from info put in tcon struct at mount time with call to QFSAttrInfo */ 209 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
207 FreeXid(xid); 210 FreeXid(xid);
208 return 0; /* always return success? what if volume is no longer available? */ 211 return 0; /* always return success? what if volume is no
212 longer available? */
209} 213}
210 214
211static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd) 215static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
@@ -559,6 +563,10 @@ struct file_operations cifs_file_ops = {
559 .flush = cifs_flush, 563 .flush = cifs_flush,
560 .mmap = cifs_file_mmap, 564 .mmap = cifs_file_mmap,
561 .sendfile = generic_file_sendfile, 565 .sendfile = generic_file_sendfile,
566#ifdef CONFIG_CIFS_POSIX
567 .ioctl = cifs_ioctl,
568#endif /* CONFIG_CIFS_POSIX */
569
562#ifdef CONFIG_CIFS_EXPERIMENTAL 570#ifdef CONFIG_CIFS_EXPERIMENTAL
563 .readv = generic_file_readv, 571 .readv = generic_file_readv,
564 .writev = generic_file_writev, 572 .writev = generic_file_writev,
@@ -579,6 +587,10 @@ struct file_operations cifs_file_direct_ops = {
579 .fsync = cifs_fsync, 587 .fsync = cifs_fsync,
580 .flush = cifs_flush, 588 .flush = cifs_flush,
581 .sendfile = generic_file_sendfile, /* BB removeme BB */ 589 .sendfile = generic_file_sendfile, /* BB removeme BB */
590#ifdef CONFIG_CIFS_POSIX
591 .ioctl = cifs_ioctl,
592#endif /* CONFIG_CIFS_POSIX */
593
582#ifdef CONFIG_CIFS_EXPERIMENTAL 594#ifdef CONFIG_CIFS_EXPERIMENTAL
583 .dir_notify = cifs_dir_notify, 595 .dir_notify = cifs_dir_notify,
584#endif /* CONFIG_CIFS_EXPERIMENTAL */ 596#endif /* CONFIG_CIFS_EXPERIMENTAL */
@@ -591,6 +603,7 @@ struct file_operations cifs_dir_ops = {
591#ifdef CONFIG_CIFS_EXPERIMENTAL 603#ifdef CONFIG_CIFS_EXPERIMENTAL
592 .dir_notify = cifs_dir_notify, 604 .dir_notify = cifs_dir_notify,
593#endif /* CONFIG_CIFS_EXPERIMENTAL */ 605#endif /* CONFIG_CIFS_EXPERIMENTAL */
606 .ioctl = cifs_ioctl,
594}; 607};
595 608
596static void 609static void
@@ -822,6 +835,7 @@ static int cifs_oplock_thread(void * dummyarg)
822 } 835 }
823 } while(!signal_pending(current)); 836 } while(!signal_pending(current));
824 complete_and_exit (&cifs_oplock_exited, 0); 837 complete_and_exit (&cifs_oplock_exited, 0);
838 oplockThread = NULL;
825} 839}
826 840
827static int __init 841static int __init
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 451f18af3206..d00b3bfe1a52 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/cifsfs.h 2 * fs/cifs/cifsfs.h
3 * 3 *
4 * Copyright (c) International Business Machines Corp., 2002 4 * Copyright (c) International Business Machines Corp., 2002, 2005
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -91,8 +91,10 @@ extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
91 const char *symname); 91 const char *symname);
92extern int cifs_removexattr(struct dentry *, const char *); 92extern int cifs_removexattr(struct dentry *, const char *);
93extern int cifs_setxattr(struct dentry *, const char *, const void *, 93extern int cifs_setxattr(struct dentry *, const char *, const void *,
94 size_t, int); 94 size_t, int);
95extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t); 95extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
96extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); 96extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
97#define CIFS_VERSION "1.31" 97extern int cifs_ioctl (struct inode * inode, struct file * filep,
98 unsigned int command, unsigned long arg);
99#define CIFS_VERSION "1.34"
98#endif /* _CIFSFS_H */ 100#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 69aff1a7da9b..81babab265e1 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/cifsglob.h 2 * fs/cifs/cifsglob.h
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2003 4 * Copyright (C) International Business Machines Corp., 2002,2005
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -149,6 +149,8 @@ struct TCP_Server_Info {
149 __u16 timeZone; 149 __u16 timeZone;
150 char cryptKey[CIFS_CRYPTO_KEY_SIZE]; 150 char cryptKey[CIFS_CRYPTO_KEY_SIZE];
151 char workstation_RFC1001_name[16]; /* 16th byte is always zero */ 151 char workstation_RFC1001_name[16]; /* 16th byte is always zero */
152 __u32 sequence_number; /* needed for CIFS PDU signature */
153 char mac_signing_key[CIFS_SESSION_KEY_SIZE + 16];
152}; 154};
153 155
154/* 156/*
@@ -174,17 +176,16 @@ struct cifsSesInfo {
174 struct TCP_Server_Info *server; /* pointer to server info */ 176 struct TCP_Server_Info *server; /* pointer to server info */
175 atomic_t inUse; /* # of mounts (tree connections) on this ses */ 177 atomic_t inUse; /* # of mounts (tree connections) on this ses */
176 enum statusEnum status; 178 enum statusEnum status;
177 __u32 sequence_number; /* needed for CIFS PDU signature */
178 __u16 ipc_tid; /* special tid for connection to IPC share */ 179 __u16 ipc_tid; /* special tid for connection to IPC share */
179 __u16 flags; 180 __u16 flags;
180 char mac_signing_key[CIFS_SESSION_KEY_SIZE + 16]; 181 char *serverOS; /* name of operating system underlying server */
181 char *serverOS; /* name of operating system underlying the server */ 182 char *serverNOS; /* name of network operating system of server */
182 char *serverNOS; /* name of network operating system that the server is running */
183 char *serverDomain; /* security realm of server */ 183 char *serverDomain; /* security realm of server */
184 int Suid; /* remote smb uid */ 184 int Suid; /* remote smb uid */
185 uid_t linux_uid; /* local Linux uid */ 185 uid_t linux_uid; /* local Linux uid */
186 int capabilities; 186 int capabilities;
187 char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for tcp names - will ipv6 and sctp addresses fit here?? */ 187 char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
188 TCP names - will ipv6 and sctp addresses fit? */
188 char userName[MAX_USERNAME_SIZE + 1]; 189 char userName[MAX_USERNAME_SIZE + 1];
189 char domainName[MAX_USERNAME_SIZE + 1]; 190 char domainName[MAX_USERNAME_SIZE + 1];
190 char * password; 191 char * password;
@@ -312,12 +313,15 @@ struct mid_q_entry {
312 __u16 mid; /* multiplex id */ 313 __u16 mid; /* multiplex id */
313 __u16 pid; /* process id */ 314 __u16 pid; /* process id */
314 __u32 sequence_number; /* for CIFS signing */ 315 __u32 sequence_number; /* for CIFS signing */
315 __u16 command; /* smb command code */
316 struct timeval when_sent; /* time when smb sent */ 316 struct timeval when_sent; /* time when smb sent */
317 struct cifsSesInfo *ses; /* smb was sent to this server */ 317 struct cifsSesInfo *ses; /* smb was sent to this server */
318 struct task_struct *tsk; /* task waiting for response */ 318 struct task_struct *tsk; /* task waiting for response */
319 struct smb_hdr *resp_buf; /* response buffer */ 319 struct smb_hdr *resp_buf; /* response buffer */
320 int midState; /* wish this were enum but can not pass to wait_event */ 320 int midState; /* wish this were enum but can not pass to wait_event */
321 __u8 command; /* smb command code */
322 unsigned multiPart:1; /* multiple responses to one SMB request */
323 unsigned largeBuf:1; /* if valid response, is pointer to large buf */
324 unsigned multiResp:1; /* multiple trans2 responses for one request */
321}; 325};
322 326
323struct oplock_q_entry { 327struct oplock_q_entry {
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index bcd4a6136f08..aede6a813167 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -330,7 +330,7 @@ struct smb_hdr {
330}; 330};
331/* given a pointer to an smb_hdr retrieve the value of byte count */ 331/* given a pointer to an smb_hdr retrieve the value of byte count */
332#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) ) 332#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
333 333#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
334/* given a pointer to an smb_hdr retrieve the pointer to the byte area */ 334/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
335#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 ) 335#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
336 336
@@ -762,6 +762,16 @@ typedef struct smb_com_lock_req {
762 LOCKING_ANDX_RANGE Locks[1]; 762 LOCKING_ANDX_RANGE Locks[1];
763} LOCK_REQ; 763} LOCK_REQ;
764 764
765
766typedef struct cifs_posix_lock {
767 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
768 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
769 __le32 pid;
770 __le64 start;
771 __le64 length;
772 /* BB what about additional owner info to identify network client */
773} CIFS_POSIX_LOCK;
774
765typedef struct smb_com_lock_rsp { 775typedef struct smb_com_lock_rsp {
766 struct smb_hdr hdr; /* wct = 2 */ 776 struct smb_hdr hdr; /* wct = 2 */
767 __u8 AndXCommand; 777 __u8 AndXCommand;
@@ -1098,6 +1108,8 @@ struct smb_t2_rsp {
1098#define SMB_QUERY_POSIX_ACL 0x204 1108#define SMB_QUERY_POSIX_ACL 0x204
1099#define SMB_QUERY_XATTR 0x205 1109#define SMB_QUERY_XATTR 0x205
1100#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */ 1110#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1111#define SMB_QUERY_POSIX_PERMISSION 0x207
1112#define SMB_QUERY_POSIX_LOCK 0x208
1101#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee 1113#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1102#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0 1114#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1103#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */ 1115#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
@@ -1116,6 +1128,7 @@ struct smb_t2_rsp {
1116#define SMB_SET_POSIX_ACL 0x204 1128#define SMB_SET_POSIX_ACL 0x204
1117#define SMB_SET_XATTR 0x205 1129#define SMB_SET_XATTR 0x205
1118#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */ 1130#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1131#define SMB_SET_POSIX_LOCK 0x208
1119#define SMB_SET_FILE_BASIC_INFO2 0x3ec 1132#define SMB_SET_FILE_BASIC_INFO2 0x3ec
1120#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */ 1133#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */
1121#define SMB_FILE_ALL_INFO2 0x3fa 1134#define SMB_FILE_ALL_INFO2 0x3fa
@@ -1237,9 +1250,25 @@ struct smb_com_transaction2_sfi_rsp {
1237 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1250 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1238 struct trans2_resp t2; 1251 struct trans2_resp t2;
1239 __u16 ByteCount; 1252 __u16 ByteCount;
1240 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ 1253 __u16 Reserved2; /* parameter word reserved -
1254 present for infolevels > 100 */
1255};
1256
1257struct smb_t2_qfi_req {
1258 struct smb_hdr hdr;
1259 struct trans2_req t2;
1260 __u8 Pad;
1261 __u16 Fid;
1262 __le16 InformationLevel;
1241}; 1263};
1242 1264
1265struct smb_t2_qfi_rsp {
1266 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1267 struct trans2_resp t2;
1268 __u16 ByteCount;
1269 __u16 Reserved2; /* parameter word reserved -
1270 present for infolevels > 100 */
1271};
1243 1272
1244/* 1273/*
1245 * Flags on T2 FINDFIRST and FINDNEXT 1274 * Flags on T2 FINDFIRST and FINDNEXT
@@ -1524,9 +1553,10 @@ typedef struct {
1524} FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */ 1553} FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */
1525/* Linux/Unix extensions capability flags */ 1554/* Linux/Unix extensions capability flags */
1526#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */ 1555#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1527#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 1556#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1528#define CIFS_UNIX_XATTR_CAP 0x00000004 /*support for new namespace*/ 1557#define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1529 1558#define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1559#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1530typedef struct { 1560typedef struct {
1531 /* For undefined recommended transfer size return -1 in that field */ 1561 /* For undefined recommended transfer size return -1 in that field */
1532 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ 1562 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
@@ -1971,14 +2001,39 @@ struct xsymlink {
1971 char path[1024]; 2001 char path[1024];
1972}; 2002};
1973 2003
1974typedef struct { 2004typedef struct file_xattr_info {
1975 /* BB do we need another field for flags? BB */ 2005 /* BB do we need another field for flags? BB */
1976 __u32 xattr_name_len; 2006 __u32 xattr_name_len;
1977 __u32 xattr_value_len; 2007 __u32 xattr_value_len;
1978 char xattr_name[0]; 2008 char xattr_name[0];
1979 /* followed by xattr_value[xattr_value_len], no pad */ 2009 /* followed by xattr_value[xattr_value_len], no pad */
1980} FILE_XATTR_INFO; /* extended attribute, info level 205 */ 2010} FILE_XATTR_INFO; /* extended attribute, info level 0x205 */
1981 2011
2012
2013/* flags for chattr command */
2014#define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2015#define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2016/* Reserved for compress file 0x4 */
2017#define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2018#define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2019#define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2020#define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2021#define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2022/* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2023#define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2024/* 0x2000 reserved for IMAGIC_FL */
2025#define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2026/* 0x8000 reserved for EXT3_NOTAIL_FL */
2027#define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2028#define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2029
2030#define EXT_SET_MASK 0x000300FF
2031#define EXT_GET_MASK 0x0003DFFF
2032
2033typedef struct file_chattr_info {
2034 __le64 mask; /* list of all possible attribute bits */
2035 __le64 mode; /* list of actual attribute bits on this inode */
2036} FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */
1982 2037
1983#endif 2038#endif
1984 2039
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 787eef4d86d3..0010511083fc 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -57,10 +57,11 @@ extern int decode_negTokenInit(unsigned char *security_blob, int length,
57extern int cifs_inet_pton(int, char * source, void *dst); 57extern int cifs_inet_pton(int, char * source, void *dst);
58extern int map_smb_to_linux_error(struct smb_hdr *smb); 58extern int map_smb_to_linux_error(struct smb_hdr *smb);
59extern void header_assemble(struct smb_hdr *, char /* command */ , 59extern void header_assemble(struct smb_hdr *, char /* command */ ,
60 const struct cifsTconInfo *, int 60 const struct cifsTconInfo *, int /* specifies length
61 /* length of fixed section (word count) in two byte units */ 61 of fixed section (word count) in two byte units */
62 ); 62 );
63extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, struct cifsTconInfo *); 63extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16,
64 struct cifsTconInfo *);
64extern void DeleteOplockQEntry(struct oplock_q_entry *); 65extern void DeleteOplockQEntry(struct oplock_q_entry *);
65extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ ); 66extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ );
66extern u64 cifs_UnixTimeToNT(struct timespec); 67extern u64 cifs_UnixTimeToNT(struct timespec);
@@ -88,7 +89,7 @@ extern int CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
88 89
89extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon, 90extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
90 const char *searchName, const struct nls_table *nls_codepage, 91 const char *searchName, const struct nls_table *nls_codepage,
91 __u16 *searchHandle, struct cifs_search_info * psrch_inf); 92 __u16 *searchHandle, struct cifs_search_info * psrch_inf, int map);
92 93
93extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, 94extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
94 __u16 searchHandle, struct cifs_search_info * psrch_inf); 95 __u16 searchHandle, struct cifs_search_info * psrch_inf);
@@ -99,42 +100,42 @@ extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,
99extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 100extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
100 const unsigned char *searchName, 101 const unsigned char *searchName,
101 FILE_ALL_INFO * findData, 102 FILE_ALL_INFO * findData,
102 const struct nls_table *nls_codepage); 103 const struct nls_table *nls_codepage, int remap);
103 104
104extern int CIFSSMBUnixQPathInfo(const int xid, 105extern int CIFSSMBUnixQPathInfo(const int xid,
105 struct cifsTconInfo *tcon, 106 struct cifsTconInfo *tcon,
106 const unsigned char *searchName, 107 const unsigned char *searchName,
107 FILE_UNIX_BASIC_INFO * pFindData, 108 FILE_UNIX_BASIC_INFO * pFindData,
108 const struct nls_table *nls_codepage); 109 const struct nls_table *nls_codepage, int remap);
109 110
110extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses, 111extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
111 const unsigned char *searchName, 112 const unsigned char *searchName,
112 unsigned char **targetUNCs, 113 unsigned char **targetUNCs,
113 unsigned int *number_of_UNC_in_array, 114 unsigned int *number_of_UNC_in_array,
114 const struct nls_table *nls_codepage); 115 const struct nls_table *nls_codepage, int remap);
115 116
116extern int connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, 117extern int connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
117 const char *old_path, 118 const char *old_path,
118 const struct nls_table *nls_codepage); 119 const struct nls_table *nls_codepage, int remap);
119extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, 120extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
120 const char *old_path, const struct nls_table *nls_codepage, 121 const char *old_path,
121 unsigned int *pnum_referrals, unsigned char ** preferrals); 122 const struct nls_table *nls_codepage,
123 unsigned int *pnum_referrals,
124 unsigned char ** preferrals,
125 int remap);
122extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, 126extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon,
123 struct kstatfs *FSData, 127 struct kstatfs *FSData);
124 const struct nls_table *nls_codepage);
125extern int CIFSSMBQFSAttributeInfo(const int xid, 128extern int CIFSSMBQFSAttributeInfo(const int xid,
126 struct cifsTconInfo *tcon, 129 struct cifsTconInfo *tcon);
127 const struct nls_table *nls_codepage); 130extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon);
128extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon, 131extern int CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon);
129 const struct nls_table *nls_codepage);
130extern int CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon,
131 const struct nls_table *nls_codepage);
132extern int CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, 132extern int CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon,
133 struct kstatfs *FSData, const struct nls_table *nls_codepage); 133 struct kstatfs *FSData);
134 134
135extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, 135extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon,
136 const char *fileName, const FILE_BASIC_INFO * data, 136 const char *fileName, const FILE_BASIC_INFO * data,
137 const struct nls_table *nls_codepage); 137 const struct nls_table *nls_codepage,
138 int remap_special_chars);
138extern int CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, 139extern int CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon,
139 const FILE_BASIC_INFO * data, __u16 fid); 140 const FILE_BASIC_INFO * data, __u16 fid);
140#if 0 141#if 0
@@ -143,36 +144,49 @@ extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon,
143 const struct nls_table *nls_codepage); 144 const struct nls_table *nls_codepage);
144#endif /* possibly unneeded function */ 145#endif /* possibly unneeded function */
145extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, 146extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon,
146 const char *fileName, __u64 size,int setAllocationSizeFlag, 147 const char *fileName, __u64 size,
147 const struct nls_table *nls_codepage); 148 int setAllocationSizeFlag,
149 const struct nls_table *nls_codepage,
150 int remap_special_chars);
148extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, 151extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
149 __u64 size, __u16 fileHandle,__u32 opener_pid, int AllocSizeFlag); 152 __u64 size, __u16 fileHandle,__u32 opener_pid,
153 int AllocSizeFlag);
150extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon, 154extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
151 char *full_path, __u64 mode, __u64 uid, 155 char *full_path, __u64 mode, __u64 uid,
152 __u64 gid, dev_t dev, const struct nls_table *nls_codepage); 156 __u64 gid, dev_t dev,
157 const struct nls_table *nls_codepage,
158 int remap_special_chars);
153 159
154extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, 160extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
155 const char *newName, 161 const char *newName,
156 const struct nls_table *nls_codepage); 162 const struct nls_table *nls_codepage,
163 int remap_special_chars);
157extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, 164extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon,
158 const char *name, const struct nls_table *nls_codepage); 165 const char *name, const struct nls_table *nls_codepage,
166 int remap_special_chars);
159 167
160extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, 168extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon,
161 const char *name, 169 const char *name,
162 const struct nls_table *nls_codepage); 170 const struct nls_table *nls_codepage,
171 int remap_special_chars);
163extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, 172extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon,
164 const char *fromName, const char *toName, 173 const char *fromName, const char *toName,
165 const struct nls_table *nls_codepage); 174 const struct nls_table *nls_codepage,
175 int remap_special_chars);
166extern int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, 176extern int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
167 int netfid, char * target_name, const struct nls_table *nls_codepage); 177 int netfid, char * target_name,
178 const struct nls_table *nls_codepage,
179 int remap_special_chars);
168extern int CIFSCreateHardLink(const int xid, 180extern int CIFSCreateHardLink(const int xid,
169 struct cifsTconInfo *tcon, 181 struct cifsTconInfo *tcon,
170 const char *fromName, const char *toName, 182 const char *fromName, const char *toName,
171 const struct nls_table *nls_codepage); 183 const struct nls_table *nls_codepage,
184 int remap_special_chars);
172extern int CIFSUnixCreateHardLink(const int xid, 185extern int CIFSUnixCreateHardLink(const int xid,
173 struct cifsTconInfo *tcon, 186 struct cifsTconInfo *tcon,
174 const char *fromName, const char *toName, 187 const char *fromName, const char *toName,
175 const struct nls_table *nls_codepage); 188 const struct nls_table *nls_codepage,
189 int remap_special_chars);
176extern int CIFSUnixCreateSymLink(const int xid, 190extern int CIFSUnixCreateSymLink(const int xid,
177 struct cifsTconInfo *tcon, 191 struct cifsTconInfo *tcon,
178 const char *fromName, const char *toName, 192 const char *fromName, const char *toName,
@@ -192,7 +206,7 @@ extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
192 const char *fileName, const int disposition, 206 const char *fileName, const int disposition,
193 const int access_flags, const int omode, 207 const int access_flags, const int omode,
194 __u16 * netfid, int *pOplock, FILE_ALL_INFO *, 208 __u16 * netfid, int *pOplock, FILE_ALL_INFO *,
195 const struct nls_table *nls_codepage); 209 const struct nls_table *nls_codepage, int remap);
196extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, 210extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon,
197 const int smb_file_id); 211 const int smb_file_id);
198 212
@@ -211,8 +225,13 @@ extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
211 const char __user *buf,const int long_op); 225 const char __user *buf,const int long_op);
212extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 226extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
213 const unsigned char *searchName, __u64 * inode_number, 227 const unsigned char *searchName, __u64 * inode_number,
214 const struct nls_table *nls_codepage); 228 const struct nls_table *nls_codepage,
229 int remap_special_chars);
215#endif /* CONFIG_CIFS_EXPERIMENTAL */ 230#endif /* CONFIG_CIFS_EXPERIMENTAL */
231extern int cifs_convertUCSpath(char *target, const __u16 *source, int maxlen,
232 const struct nls_table * codepage);
233extern int cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
234 const struct nls_table * cp, int mapChars);
216 235
217extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, 236extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
218 const __u16 netfid, const __u64 len, 237 const __u16 netfid, const __u64 len,
@@ -230,7 +249,7 @@ extern void tconInfoFree(struct cifsTconInfo *);
230 249
231extern int cifs_reconnect(struct TCP_Server_Info *server); 250extern int cifs_reconnect(struct TCP_Server_Info *server);
232 251
233extern int cifs_sign_smb(struct smb_hdr *, struct cifsSesInfo *,__u32 *); 252extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *,__u32 *);
234extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key, 253extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key,
235 __u32 expected_sequence_number); 254 __u32 expected_sequence_number);
236extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); 255extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass);
@@ -241,29 +260,31 @@ extern int CIFSSMBCopy(int xid,
241 const char *fromName, 260 const char *fromName,
242 const __u16 target_tid, 261 const __u16 target_tid,
243 const char *toName, const int flags, 262 const char *toName, const int flags,
244 const struct nls_table *nls_codepage); 263 const struct nls_table *nls_codepage,
264 int remap_special_chars);
245extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, 265extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
246 const int notify_subdirs,const __u16 netfid,__u32 filter, 266 const int notify_subdirs,const __u16 netfid,
247 const struct nls_table *nls_codepage); 267 __u32 filter, const struct nls_table *nls_codepage);
248extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, 268extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
249 const unsigned char *searchName, char * EAData, 269 const unsigned char *searchName, char * EAData,
250 size_t bufsize, const struct nls_table *nls_codepage); 270 size_t bufsize, const struct nls_table *nls_codepage,
271 int remap_special_chars);
251extern ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, 272extern ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
252 const unsigned char * searchName,const unsigned char * ea_name, 273 const unsigned char * searchName,const unsigned char * ea_name,
253 unsigned char * ea_value, size_t buf_size, 274 unsigned char * ea_value, size_t buf_size,
254 const struct nls_table *nls_codepage); 275 const struct nls_table *nls_codepage, int remap_special_chars);
255extern int CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, 276extern int CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon,
256 const char *fileName, const char * ea_name, 277 const char *fileName, const char * ea_name,
257 const void * ea_value, const __u16 ea_value_len, 278 const void * ea_value, const __u16 ea_value_len,
258 const struct nls_table *nls_codepage); 279 const struct nls_table *nls_codepage, int remap_special_chars);
259extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, 280extern int CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon,
260 const unsigned char *searchName, 281 const unsigned char *searchName,
261 char *acl_inf, const int buflen,const int acl_type, 282 char *acl_inf, const int buflen,const int acl_type,
262 const struct nls_table *nls_codepage); 283 const struct nls_table *nls_codepage, int remap_special_chars);
263extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, 284extern int CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
264 const unsigned char *fileName, 285 const unsigned char *fileName,
265 const char *local_acl, const int buflen, const int acl_type, 286 const char *local_acl, const int buflen, const int acl_type,
266 const struct nls_table *nls_codepage); 287 const struct nls_table *nls_codepage, int remap_special_chars);
267int cifs_ioctl (struct inode * inode, struct file * filep, 288extern int CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
268 unsigned int command, unsigned long arg); 289 const int netfid, __u64 * pExtAttrBits, __u64 *pMask);
269#endif /* _CIFSPROTO_H */ 290#endif /* _CIFSPROTO_H */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index df6a619a6821..741ff0c69f37 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -75,7 +75,8 @@ static void mark_open_files_invalid(struct cifsTconInfo * pTcon)
75 } 75 }
76 } 76 }
77 write_unlock(&GlobalSMBSeslock); 77 write_unlock(&GlobalSMBSeslock);
78 /* BB Add call to invalidate_inodes(sb) for all superblocks mounted to this tcon */ 78 /* BB Add call to invalidate_inodes(sb) for all superblocks mounted
79 to this tcon */
79} 80}
80 81
81/* If the return code is zero, this function must fill in request_buf pointer */ 82/* If the return code is zero, this function must fill in request_buf pointer */
@@ -89,11 +90,12 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
89 check for tcp and smb session status done differently 90 check for tcp and smb session status done differently
90 for those three - in the calling routine */ 91 for those three - in the calling routine */
91 if(tcon) { 92 if(tcon) {
92 if((tcon->ses) && (tcon->ses->server)){ 93 if((tcon->ses) && (tcon->ses->status != CifsExiting) &&
94 (tcon->ses->server)){
93 struct nls_table *nls_codepage; 95 struct nls_table *nls_codepage;
94 /* Give Demultiplex thread up to 10 seconds to 96 /* Give Demultiplex thread up to 10 seconds to
95 reconnect, should be greater than cifs socket 97 reconnect, should be greater than cifs socket
96 timeout which is 7 seconds */ 98 timeout which is 7 seconds */
97 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 99 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
98 wait_event_interruptible_timeout(tcon->ses->server->response_q, 100 wait_event_interruptible_timeout(tcon->ses->server->response_q,
99 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); 101 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
@@ -103,8 +105,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
103 (tcon->ses->status == CifsExiting)) { 105 (tcon->ses->status == CifsExiting)) {
104 cFYI(1,("gave up waiting on reconnect in smb_init")); 106 cFYI(1,("gave up waiting on reconnect in smb_init"));
105 return -EHOSTDOWN; 107 return -EHOSTDOWN;
106 } /* else "hard" mount - keep retrying until 108 } /* else "hard" mount - keep retrying
107 process is killed or server comes back up */ 109 until process is killed or server
110 comes back on-line */
108 } else /* TCP session is reestablished now */ 111 } else /* TCP session is reestablished now */
109 break; 112 break;
110 113
@@ -115,23 +118,24 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
115 simultaneously reconnect the same SMB session */ 118 simultaneously reconnect the same SMB session */
116 down(&tcon->ses->sesSem); 119 down(&tcon->ses->sesSem);
117 if(tcon->ses->status == CifsNeedReconnect) 120 if(tcon->ses->status == CifsNeedReconnect)
118 rc = cifs_setup_session(0, tcon->ses, nls_codepage); 121 rc = cifs_setup_session(0, tcon->ses,
122 nls_codepage);
119 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 123 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
120 mark_open_files_invalid(tcon); 124 mark_open_files_invalid(tcon);
121 rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon, 125 rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon
122 nls_codepage); 126 , nls_codepage);
123 up(&tcon->ses->sesSem); 127 up(&tcon->ses->sesSem);
124 if(rc == 0) 128 if(rc == 0)
125 atomic_inc(&tconInfoReconnectCount); 129 atomic_inc(&tconInfoReconnectCount);
126 130
127 cFYI(1, ("reconnect tcon rc = %d", rc)); 131 cFYI(1, ("reconnect tcon rc = %d", rc));
128 /* Removed call to reopen open files here - 132 /* Removed call to reopen open files here -
129 it is safer (and faster) to reopen files 133 it is safer (and faster) to reopen files
130 one at a time as needed in read and write */ 134 one at a time as needed in read and write */
131 135
132 /* Check if handle based operation so we 136 /* Check if handle based operation so we
133 know whether we can continue or not without 137 know whether we can continue or not without
134 returning to caller to reset file handle */ 138 returning to caller to reset file handle */
135 switch(smb_command) { 139 switch(smb_command) {
136 case SMB_COM_READ_ANDX: 140 case SMB_COM_READ_ANDX:
137 case SMB_COM_WRITE_ANDX: 141 case SMB_COM_WRITE_ANDX:
@@ -182,22 +186,25 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
182 check for tcp and smb session status done differently 186 check for tcp and smb session status done differently
183 for those three - in the calling routine */ 187 for those three - in the calling routine */
184 if(tcon) { 188 if(tcon) {
185 if((tcon->ses) && (tcon->ses->server)){ 189 if((tcon->ses) && (tcon->ses->status != CifsExiting) &&
190 (tcon->ses->server)){
186 struct nls_table *nls_codepage; 191 struct nls_table *nls_codepage;
187 /* Give Demultiplex thread up to 10 seconds to 192 /* Give Demultiplex thread up to 10 seconds to
188 reconnect, should be greater than cifs socket 193 reconnect, should be greater than cifs socket
189 timeout which is 7 seconds */ 194 timeout which is 7 seconds */
190 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 195 while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
191 wait_event_interruptible_timeout(tcon->ses->server->response_q, 196 wait_event_interruptible_timeout(tcon->ses->server->response_q,
192 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ); 197 (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
193 if(tcon->ses->server->tcpStatus == CifsNeedReconnect) { 198 if(tcon->ses->server->tcpStatus ==
199 CifsNeedReconnect) {
194 /* on "soft" mounts we wait once */ 200 /* on "soft" mounts we wait once */
195 if((tcon->retry == FALSE) || 201 if((tcon->retry == FALSE) ||
196 (tcon->ses->status == CifsExiting)) { 202 (tcon->ses->status == CifsExiting)) {
197 cFYI(1,("gave up waiting on reconnect in smb_init")); 203 cFYI(1,("gave up waiting on reconnect in smb_init"));
198 return -EHOSTDOWN; 204 return -EHOSTDOWN;
199 } /* else "hard" mount - keep retrying until 205 } /* else "hard" mount - keep retrying
200 process is killed or server comes back up */ 206 until process is killed or server
207 comes on-line */
201 } else /* TCP session is reestablished now */ 208 } else /* TCP session is reestablished now */
202 break; 209 break;
203 210
@@ -208,23 +215,24 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
208 simultaneously reconnect the same SMB session */ 215 simultaneously reconnect the same SMB session */
209 down(&tcon->ses->sesSem); 216 down(&tcon->ses->sesSem);
210 if(tcon->ses->status == CifsNeedReconnect) 217 if(tcon->ses->status == CifsNeedReconnect)
211 rc = cifs_setup_session(0, tcon->ses, nls_codepage); 218 rc = cifs_setup_session(0, tcon->ses,
219 nls_codepage);
212 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 220 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
213 mark_open_files_invalid(tcon); 221 mark_open_files_invalid(tcon);
214 rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon, 222 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
215 nls_codepage); 223 tcon, nls_codepage);
216 up(&tcon->ses->sesSem); 224 up(&tcon->ses->sesSem);
217 if(rc == 0) 225 if(rc == 0)
218 atomic_inc(&tconInfoReconnectCount); 226 atomic_inc(&tconInfoReconnectCount);
219 227
220 cFYI(1, ("reconnect tcon rc = %d", rc)); 228 cFYI(1, ("reconnect tcon rc = %d", rc));
221 /* Removed call to reopen open files here - 229 /* Removed call to reopen open files here -
222 it is safer (and faster) to reopen files 230 it is safer (and faster) to reopen files
223 one at a time as needed in read and write */ 231 one at a time as needed in read and write */
224 232
225 /* Check if handle based operation so we 233 /* Check if handle based operation so we
226 know whether we can continue or not without 234 know whether we can continue or not without
227 returning to caller to reset file handle */ 235 returning to caller to reset file handle */
228 switch(smb_command) { 236 switch(smb_command) {
229 case SMB_COM_READ_ANDX: 237 case SMB_COM_READ_ANDX:
230 case SMB_COM_WRITE_ANDX: 238 case SMB_COM_WRITE_ANDX:
@@ -286,7 +294,8 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
286 if(total_size < 512) { 294 if(total_size < 512) {
287 total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount); 295 total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount);
288 /* BCC le converted in SendReceive */ 296 /* BCC le converted in SendReceive */
289 pBCC = (pSMB->hdr.WordCount * 2) + sizeof(struct smb_hdr) + 297 pBCC = (pSMB->hdr.WordCount * 2) +
298 sizeof(struct smb_hdr) +
290 (char *)pSMB; 299 (char *)pSMB;
291 if((total_size <= (*(u16 *)pBCC)) && 300 if((total_size <= (*(u16 *)pBCC)) &&
292 (total_size < 301 (total_size <
@@ -337,8 +346,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
337 (struct smb_hdr *) pSMBr, &bytes_returned, 0); 346 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
338 if (rc == 0) { 347 if (rc == 0) {
339 server->secMode = pSMBr->SecurityMode; 348 server->secMode = pSMBr->SecurityMode;
340 server->secType = NTLM; /* BB override default for NTLMv2 or krb*/ 349 server->secType = NTLM; /* BB override default for
341 /* one byte - no need to convert this or EncryptionKeyLen from le,*/ 350 NTLMv2 or kerberos v5 */
351 /* one byte - no need to convert this or EncryptionKeyLen
352 from little endian */
342 server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount); 353 server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount);
343 /* probably no need to store and check maxvcs */ 354 /* probably no need to store and check maxvcs */
344 server->maxBuf = 355 server->maxBuf =
@@ -374,7 +385,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
374 pSMBr->u.extended_response. 385 pSMBr->u.extended_response.
375 GUID, 16) != 0) { 386 GUID, 16) != 0) {
376 cFYI(1, 387 cFYI(1,
377 ("UID of server does not match previous connection to same ip address")); 388 ("UID of server does not match previous connection to same ip address"));
378 memcpy(server-> 389 memcpy(server->
379 server_GUID, 390 server_GUID,
380 pSMBr->u. 391 pSMBr->u.
@@ -454,17 +465,18 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
454 up(&tcon->tconSem); 465 up(&tcon->tconSem);
455 return -EIO; 466 return -EIO;
456 } 467 }
457 rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, (void **)&smb_buffer); 468 rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon,
469 (void **)&smb_buffer);
458 if (rc) { 470 if (rc) {
459 up(&tcon->tconSem); 471 up(&tcon->tconSem);
460 return rc; 472 return rc;
461 } else { 473 } else {
462 smb_buffer_response = smb_buffer; /* BB removeme BB */ 474 smb_buffer_response = smb_buffer; /* BB removeme BB */
463 } 475 }
464 rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response, 476 rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response,
465 &length, 0); 477 &length, 0);
466 if (rc) 478 if (rc)
467 cFYI(1, (" Tree disconnect failed %d", rc)); 479 cFYI(1, ("Tree disconnect failed %d", rc));
468 480
469 if (smb_buffer) 481 if (smb_buffer)
470 cifs_small_buf_release(smb_buffer); 482 cifs_small_buf_release(smb_buffer);
@@ -538,8 +550,8 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
538} 550}
539 551
540int 552int
541CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, 553CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon, const char *fileName,
542 const char *fileName, const struct nls_table *nls_codepage) 554 const struct nls_table *nls_codepage, int remap)
543{ 555{
544 DELETE_FILE_REQ *pSMB = NULL; 556 DELETE_FILE_REQ *pSMB = NULL;
545 DELETE_FILE_RSP *pSMBr = NULL; 557 DELETE_FILE_RSP *pSMBr = NULL;
@@ -555,12 +567,11 @@ DelFileRetry:
555 567
556 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 568 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
557 name_len = 569 name_len =
558 cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, PATH_MAX 570 cifsConvertToUCS((__u16 *) pSMB->fileName, fileName,
559 /* find define for this maxpathcomponent */ 571 PATH_MAX, nls_codepage, remap);
560 , nls_codepage);
561 name_len++; /* trailing null */ 572 name_len++; /* trailing null */
562 name_len *= 2; 573 name_len *= 2;
563 } else { /* BB improve the check for buffer overruns BB */ 574 } else { /* BB improve check for buffer overruns BB */
564 name_len = strnlen(fileName, PATH_MAX); 575 name_len = strnlen(fileName, PATH_MAX);
565 name_len++; /* trailing null */ 576 name_len++; /* trailing null */
566 strncpy(pSMB->fileName, fileName, name_len); 577 strncpy(pSMB->fileName, fileName, name_len);
@@ -589,8 +600,8 @@ DelFileRetry:
589} 600}
590 601
591int 602int
592CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, 603CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon, const char *dirName,
593 const char *dirName, const struct nls_table *nls_codepage) 604 const struct nls_table *nls_codepage, int remap)
594{ 605{
595 DELETE_DIRECTORY_REQ *pSMB = NULL; 606 DELETE_DIRECTORY_REQ *pSMB = NULL;
596 DELETE_DIRECTORY_RSP *pSMBr = NULL; 607 DELETE_DIRECTORY_RSP *pSMBr = NULL;
@@ -606,12 +617,11 @@ RmDirRetry:
606 return rc; 617 return rc;
607 618
608 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 619 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
609 name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, dirName, PATH_MAX 620 name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, dirName,
610 /* find define for this maxpathcomponent */ 621 PATH_MAX, nls_codepage, remap);
611 , nls_codepage);
612 name_len++; /* trailing null */ 622 name_len++; /* trailing null */
613 name_len *= 2; 623 name_len *= 2;
614 } else { /* BB improve the check for buffer overruns BB */ 624 } else { /* BB improve check for buffer overruns BB */
615 name_len = strnlen(dirName, PATH_MAX); 625 name_len = strnlen(dirName, PATH_MAX);
616 name_len++; /* trailing null */ 626 name_len++; /* trailing null */
617 strncpy(pSMB->DirName, dirName, name_len); 627 strncpy(pSMB->DirName, dirName, name_len);
@@ -639,7 +649,7 @@ RmDirRetry:
639 649
640int 650int
641CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon, 651CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
642 const char *name, const struct nls_table *nls_codepage) 652 const char *name, const struct nls_table *nls_codepage, int remap)
643{ 653{
644 int rc = 0; 654 int rc = 0;
645 CREATE_DIRECTORY_REQ *pSMB = NULL; 655 CREATE_DIRECTORY_REQ *pSMB = NULL;
@@ -655,12 +665,11 @@ MkDirRetry:
655 return rc; 665 return rc;
656 666
657 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 667 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
658 name_len = cifs_strtoUCS((wchar_t *) pSMB->DirName, name, PATH_MAX 668 name_len = cifsConvertToUCS((__u16 *) pSMB->DirName, name,
659 /* find define for this maxpathcomponent */ 669 PATH_MAX, nls_codepage, remap);
660 , nls_codepage);
661 name_len++; /* trailing null */ 670 name_len++; /* trailing null */
662 name_len *= 2; 671 name_len *= 2;
663 } else { /* BB improve the check for buffer overruns BB */ 672 } else { /* BB improve check for buffer overruns BB */
664 name_len = strnlen(name, PATH_MAX); 673 name_len = strnlen(name, PATH_MAX);
665 name_len++; /* trailing null */ 674 name_len++; /* trailing null */
666 strncpy(pSMB->DirName, name, name_len); 675 strncpy(pSMB->DirName, name, name_len);
@@ -690,7 +699,7 @@ CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
690 const char *fileName, const int openDisposition, 699 const char *fileName, const int openDisposition,
691 const int access_flags, const int create_options, __u16 * netfid, 700 const int access_flags, const int create_options, __u16 * netfid,
692 int *pOplock, FILE_ALL_INFO * pfile_info, 701 int *pOplock, FILE_ALL_INFO * pfile_info,
693 const struct nls_table *nls_codepage) 702 const struct nls_table *nls_codepage, int remap)
694{ 703{
695 int rc = -EACCES; 704 int rc = -EACCES;
696 OPEN_REQ *pSMB = NULL; 705 OPEN_REQ *pSMB = NULL;
@@ -710,14 +719,12 @@ openRetry:
710 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 719 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
711 count = 1; /* account for one byte pad to word boundary */ 720 count = 1; /* account for one byte pad to word boundary */
712 name_len = 721 name_len =
713 cifs_strtoUCS((wchar_t *) (pSMB->fileName + 1), 722 cifsConvertToUCS((__u16 *) (pSMB->fileName + 1),
714 fileName, PATH_MAX 723 fileName, PATH_MAX, nls_codepage, remap);
715 /* find define for this maxpathcomponent */
716 , nls_codepage);
717 name_len++; /* trailing null */ 724 name_len++; /* trailing null */
718 name_len *= 2; 725 name_len *= 2;
719 pSMB->NameLength = cpu_to_le16(name_len); 726 pSMB->NameLength = cpu_to_le16(name_len);
720 } else { /* BB improve the check for buffer overruns BB */ 727 } else { /* BB improve check for buffer overruns BB */
721 count = 0; /* no pad */ 728 count = 0; /* no pad */
722 name_len = strnlen(fileName, PATH_MAX); 729 name_len = strnlen(fileName, PATH_MAX);
723 name_len++; /* trailing null */ 730 name_len++; /* trailing null */
@@ -746,7 +753,8 @@ openRetry:
746 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); 753 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
747 pSMB->CreateDisposition = cpu_to_le32(openDisposition); 754 pSMB->CreateDisposition = cpu_to_le32(openDisposition);
748 pSMB->CreateOptions = cpu_to_le32(create_options); 755 pSMB->CreateOptions = cpu_to_le32(create_options);
749 pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION); /* BB ??*/ 756 /* BB Expirement with various impersonation levels and verify */
757 pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION);
750 pSMB->SecurityFlags = 758 pSMB->SecurityFlags =
751 SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY; 759 SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY;
752 760
@@ -760,7 +768,7 @@ openRetry:
760 if (rc) { 768 if (rc) {
761 cFYI(1, ("Error in Open = %d", rc)); 769 cFYI(1, ("Error in Open = %d", rc));
762 } else { 770 } else {
763 *pOplock = pSMBr->OplockLevel; /* one byte no need to le_to_cpu */ 771 *pOplock = pSMBr->OplockLevel; /* 1 byte no need to le_to_cpu */
764 *netfid = pSMBr->Fid; /* cifs fid stays in le */ 772 *netfid = pSMBr->Fid; /* cifs fid stays in le */
765 /* Let caller know file was created so we can set the mode. */ 773 /* Let caller know file was created so we can set the mode. */
766 /* Do we care about the CreateAction in any other cases? */ 774 /* Do we care about the CreateAction in any other cases? */
@@ -1017,11 +1025,13 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1017 __u16 count; 1025 __u16 count;
1018 1026
1019 cFYI(1, ("In CIFSSMBLock - timeout %d numLock %d",waitFlag,numLock)); 1027 cFYI(1, ("In CIFSSMBLock - timeout %d numLock %d",waitFlag,numLock));
1020 rc = smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB, 1028 rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB);
1021 (void **) &pSMBr); 1029
1022 if (rc) 1030 if (rc)
1023 return rc; 1031 return rc;
1024 1032
1033 pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */
1034
1025 if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 1035 if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
1026 timeout = -1; /* no response expected */ 1036 timeout = -1; /* no response expected */
1027 pSMB->Timeout = 0; 1037 pSMB->Timeout = 0;
@@ -1059,7 +1069,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1059 if (rc) { 1069 if (rc) {
1060 cFYI(1, ("Send error in Lock = %d", rc)); 1070 cFYI(1, ("Send error in Lock = %d", rc));
1061 } 1071 }
1062 cifs_buf_release(pSMB); 1072 cifs_small_buf_release(pSMB);
1063 1073
1064 /* Note: On -EAGAIN error only caller can retry on handle based calls 1074 /* Note: On -EAGAIN error only caller can retry on handle based calls
1065 since file handle passed in no longer valid */ 1075 since file handle passed in no longer valid */
@@ -1108,7 +1118,7 @@ CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, int smb_file_id)
1108int 1118int
1109CIFSSMBRename(const int xid, struct cifsTconInfo *tcon, 1119CIFSSMBRename(const int xid, struct cifsTconInfo *tcon,
1110 const char *fromName, const char *toName, 1120 const char *fromName, const char *toName,
1111 const struct nls_table *nls_codepage) 1121 const struct nls_table *nls_codepage, int remap)
1112{ 1122{
1113 int rc = 0; 1123 int rc = 0;
1114 RENAME_REQ *pSMB = NULL; 1124 RENAME_REQ *pSMB = NULL;
@@ -1131,18 +1141,16 @@ renameRetry:
1131 1141
1132 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1142 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1133 name_len = 1143 name_len =
1134 cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, PATH_MAX 1144 cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName,
1135 /* find define for this maxpathcomponent */ 1145 PATH_MAX, nls_codepage, remap);
1136 , nls_codepage);
1137 name_len++; /* trailing null */ 1146 name_len++; /* trailing null */
1138 name_len *= 2; 1147 name_len *= 2;
1139 pSMB->OldFileName[name_len] = 0x04; /* pad */ 1148 pSMB->OldFileName[name_len] = 0x04; /* pad */
1140 /* protocol requires ASCII signature byte on Unicode string */ 1149 /* protocol requires ASCII signature byte on Unicode string */
1141 pSMB->OldFileName[name_len + 1] = 0x00; 1150 pSMB->OldFileName[name_len + 1] = 0x00;
1142 name_len2 = 1151 name_len2 =
1143 cifs_strtoUCS((wchar_t *) & pSMB-> 1152 cifsConvertToUCS((__u16 *) &pSMB->OldFileName[name_len + 2],
1144 OldFileName[name_len + 2], toName, PATH_MAX, 1153 toName, PATH_MAX, nls_codepage, remap);
1145 nls_codepage);
1146 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1154 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1147 name_len2 *= 2; /* convert to bytes */ 1155 name_len2 *= 2; /* convert to bytes */
1148 } else { /* BB improve the check for buffer overruns BB */ 1156 } else { /* BB improve the check for buffer overruns BB */
@@ -1182,7 +1190,8 @@ renameRetry:
1182} 1190}
1183 1191
1184int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, 1192int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1185 int netfid, char * target_name, const struct nls_table * nls_codepage) 1193 int netfid, char * target_name,
1194 const struct nls_table * nls_codepage, int remap)
1186{ 1195{
1187 struct smb_com_transaction2_sfi_req *pSMB = NULL; 1196 struct smb_com_transaction2_sfi_req *pSMB = NULL;
1188 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; 1197 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
@@ -1227,9 +1236,11 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1227 /* unicode only call */ 1236 /* unicode only call */
1228 if(target_name == NULL) { 1237 if(target_name == NULL) {
1229 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); 1238 sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid);
1230 len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, dummy_string, 24, nls_codepage); 1239 len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name,
1240 dummy_string, 24, nls_codepage, remap);
1231 } else { 1241 } else {
1232 len_of_str = cifs_strtoUCS((wchar_t *) rename_info->target_name, target_name, PATH_MAX, nls_codepage); 1242 len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name,
1243 target_name, PATH_MAX, nls_codepage, remap);
1233 } 1244 }
1234 rename_info->target_name_len = cpu_to_le32(2 * len_of_str); 1245 rename_info->target_name_len = cpu_to_le32(2 * len_of_str);
1235 count = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2; 1246 count = 12 /* sizeof(struct set_file_rename) */ + (2 * len_of_str) + 2;
@@ -1263,7 +1274,7 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
1263int 1274int
1264CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char * fromName, 1275CIFSSMBCopy(const int xid, struct cifsTconInfo *tcon, const char * fromName,
1265 const __u16 target_tid, const char *toName, const int flags, 1276 const __u16 target_tid, const char *toName, const int flags,
1266 const struct nls_table *nls_codepage) 1277 const struct nls_table *nls_codepage, int remap)
1267{ 1278{
1268 int rc = 0; 1279 int rc = 0;
1269 COPY_REQ *pSMB = NULL; 1280 COPY_REQ *pSMB = NULL;
@@ -1285,18 +1296,16 @@ copyRetry:
1285 pSMB->Flags = cpu_to_le16(flags & COPY_TREE); 1296 pSMB->Flags = cpu_to_le16(flags & COPY_TREE);
1286 1297
1287 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1298 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1288 name_len = cifs_strtoUCS((wchar_t *) pSMB->OldFileName, 1299 name_len = cifsConvertToUCS((__u16 *) pSMB->OldFileName,
1289 fromName, 1300 fromName, PATH_MAX, nls_codepage,
1290 PATH_MAX /* find define for this maxpathcomponent */, 1301 remap);
1291 nls_codepage);
1292 name_len++; /* trailing null */ 1302 name_len++; /* trailing null */
1293 name_len *= 2; 1303 name_len *= 2;
1294 pSMB->OldFileName[name_len] = 0x04; /* pad */ 1304 pSMB->OldFileName[name_len] = 0x04; /* pad */
1295 /* protocol requires ASCII signature byte on Unicode string */ 1305 /* protocol requires ASCII signature byte on Unicode string */
1296 pSMB->OldFileName[name_len + 1] = 0x00; 1306 pSMB->OldFileName[name_len + 1] = 0x00;
1297 name_len2 = cifs_strtoUCS((wchar_t *) & pSMB-> 1307 name_len2 = cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2],
1298 OldFileName[name_len + 2], toName, PATH_MAX, 1308 toName, PATH_MAX, nls_codepage, remap);
1299 nls_codepage);
1300 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1309 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1301 name_len2 *= 2; /* convert to bytes */ 1310 name_len2 *= 2; /* convert to bytes */
1302 } else { /* BB improve the check for buffer overruns BB */ 1311 } else { /* BB improve the check for buffer overruns BB */
@@ -1425,7 +1434,7 @@ createSymLinkRetry:
1425int 1434int
1426CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon, 1435CIFSUnixCreateHardLink(const int xid, struct cifsTconInfo *tcon,
1427 const char *fromName, const char *toName, 1436 const char *fromName, const char *toName,
1428 const struct nls_table *nls_codepage) 1437 const struct nls_table *nls_codepage, int remap)
1429{ 1438{
1430 TRANSACTION2_SPI_REQ *pSMB = NULL; 1439 TRANSACTION2_SPI_REQ *pSMB = NULL;
1431 TRANSACTION2_SPI_RSP *pSMBr = NULL; 1440 TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -1444,9 +1453,8 @@ createHardLinkRetry:
1444 return rc; 1453 return rc;
1445 1454
1446 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1455 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1447 name_len = cifs_strtoUCS((wchar_t *) pSMB->FileName, toName, PATH_MAX 1456 name_len = cifsConvertToUCS((__u16 *) pSMB->FileName, toName,
1448 /* find define for this maxpathcomponent */ 1457 PATH_MAX, nls_codepage, remap);
1449 , nls_codepage);
1450 name_len++; /* trailing null */ 1458 name_len++; /* trailing null */
1451 name_len *= 2; 1459 name_len *= 2;
1452 1460
@@ -1468,9 +1476,8 @@ createHardLinkRetry:
1468 data_offset = (char *) (&pSMB->hdr.Protocol) + offset; 1476 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
1469 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1477 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1470 name_len_target = 1478 name_len_target =
1471 cifs_strtoUCS((wchar_t *) data_offset, fromName, PATH_MAX 1479 cifsConvertToUCS((__u16 *) data_offset, fromName, PATH_MAX,
1472 /* find define for this maxpathcomponent */ 1480 nls_codepage, remap);
1473 , nls_codepage);
1474 name_len_target++; /* trailing null */ 1481 name_len_target++; /* trailing null */
1475 name_len_target *= 2; 1482 name_len_target *= 2;
1476 } else { /* BB improve the check for buffer overruns BB */ 1483 } else { /* BB improve the check for buffer overruns BB */
@@ -1512,7 +1519,7 @@ createHardLinkRetry:
1512int 1519int
1513CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon, 1520CIFSCreateHardLink(const int xid, struct cifsTconInfo *tcon,
1514 const char *fromName, const char *toName, 1521 const char *fromName, const char *toName,
1515 const struct nls_table *nls_codepage) 1522 const struct nls_table *nls_codepage, int remap)
1516{ 1523{
1517 int rc = 0; 1524 int rc = 0;
1518 NT_RENAME_REQ *pSMB = NULL; 1525 NT_RENAME_REQ *pSMB = NULL;
@@ -1539,17 +1546,15 @@ winCreateHardLinkRetry:
1539 1546
1540 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1547 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1541 name_len = 1548 name_len =
1542 cifs_strtoUCS((wchar_t *) pSMB->OldFileName, fromName, PATH_MAX 1549 cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName,
1543 /* find define for this maxpathcomponent */ 1550 PATH_MAX, nls_codepage, remap);
1544 , nls_codepage);
1545 name_len++; /* trailing null */ 1551 name_len++; /* trailing null */
1546 name_len *= 2; 1552 name_len *= 2;
1547 pSMB->OldFileName[name_len] = 0; /* pad */ 1553 pSMB->OldFileName[name_len] = 0; /* pad */
1548 pSMB->OldFileName[name_len + 1] = 0x04; 1554 pSMB->OldFileName[name_len + 1] = 0x04;
1549 name_len2 = 1555 name_len2 =
1550 cifs_strtoUCS((wchar_t *) & pSMB-> 1556 cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2],
1551 OldFileName[name_len + 2], toName, PATH_MAX, 1557 toName, PATH_MAX, nls_codepage, remap);
1552 nls_codepage);
1553 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; 1558 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
1554 name_len2 *= 2; /* convert to bytes */ 1559 name_len2 *= 2; /* convert to bytes */
1555 } else { /* BB improve the check for buffer overruns BB */ 1560 } else { /* BB improve the check for buffer overruns BB */
@@ -1659,6 +1664,7 @@ querySymLinkRetry:
1659 name_len = UniStrnlen((wchar_t *) ((char *) 1664 name_len = UniStrnlen((wchar_t *) ((char *)
1660 &pSMBr->hdr.Protocol +data_offset), 1665 &pSMBr->hdr.Protocol +data_offset),
1661 min_t(const int, buflen,count) / 2); 1666 min_t(const int, buflen,count) / 2);
1667 /* BB FIXME investigate remapping reserved chars here */
1662 cifs_strfromUCS_le(symlinkinfo, 1668 cifs_strfromUCS_le(symlinkinfo,
1663 (wchar_t *) ((char *)&pSMBr->hdr.Protocol + 1669 (wchar_t *) ((char *)&pSMBr->hdr.Protocol +
1664 data_offset), 1670 data_offset),
@@ -1793,7 +1799,8 @@ static void cifs_convert_ace(posix_acl_xattr_entry * ace, struct cifs_posix_ace
1793} 1799}
1794 1800
1795/* Convert ACL from CIFS POSIX wire format to local Linux POSIX ACL xattr */ 1801/* Convert ACL from CIFS POSIX wire format to local Linux POSIX ACL xattr */
1796static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,const int acl_type,const int size_of_data_area) 1802static int cifs_copy_posix_acl(char * trgt,char * src, const int buflen,
1803 const int acl_type,const int size_of_data_area)
1797{ 1804{
1798 int size = 0; 1805 int size = 0;
1799 int i; 1806 int i;
@@ -1912,7 +1919,7 @@ int
1912CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon, 1919CIFSSMBGetPosixACL(const int xid, struct cifsTconInfo *tcon,
1913 const unsigned char *searchName, 1920 const unsigned char *searchName,
1914 char *acl_inf, const int buflen, const int acl_type, 1921 char *acl_inf, const int buflen, const int acl_type,
1915 const struct nls_table *nls_codepage) 1922 const struct nls_table *nls_codepage, int remap)
1916{ 1923{
1917/* SMB_QUERY_POSIX_ACL */ 1924/* SMB_QUERY_POSIX_ACL */
1918 TRANSACTION2_QPI_REQ *pSMB = NULL; 1925 TRANSACTION2_QPI_REQ *pSMB = NULL;
@@ -1932,8 +1939,8 @@ queryAclRetry:
1932 1939
1933 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 1940 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1934 name_len = 1941 name_len =
1935 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 1942 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
1936 , nls_codepage); 1943 PATH_MAX, nls_codepage, remap);
1937 name_len++; /* trailing null */ 1944 name_len++; /* trailing null */
1938 name_len *= 2; 1945 name_len *= 2;
1939 pSMB->FileName[name_len] = 0; 1946 pSMB->FileName[name_len] = 0;
@@ -1997,8 +2004,9 @@ queryAclRetry:
1997int 2004int
1998CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon, 2005CIFSSMBSetPosixACL(const int xid, struct cifsTconInfo *tcon,
1999 const unsigned char *fileName, 2006 const unsigned char *fileName,
2000 const char *local_acl, const int buflen, const int acl_type, 2007 const char *local_acl, const int buflen,
2001 const struct nls_table *nls_codepage) 2008 const int acl_type,
2009 const struct nls_table *nls_codepage, int remap)
2002{ 2010{
2003 struct smb_com_transaction2_spi_req *pSMB = NULL; 2011 struct smb_com_transaction2_spi_req *pSMB = NULL;
2004 struct smb_com_transaction2_spi_rsp *pSMBr = NULL; 2012 struct smb_com_transaction2_spi_rsp *pSMBr = NULL;
@@ -2016,8 +2024,8 @@ setAclRetry:
2016 return rc; 2024 return rc;
2017 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2025 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2018 name_len = 2026 name_len =
2019 cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX 2027 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
2020 , nls_codepage); 2028 PATH_MAX, nls_codepage, remap);
2021 name_len++; /* trailing null */ 2029 name_len++; /* trailing null */
2022 name_len *= 2; 2030 name_len *= 2;
2023 } else { /* BB improve the check for buffer overruns BB */ 2031 } else { /* BB improve the check for buffer overruns BB */
@@ -2072,13 +2080,96 @@ setACLerrorExit:
2072 return rc; 2080 return rc;
2073} 2081}
2074 2082
2075#endif 2083/* BB fix tabs in this function FIXME BB */
2084int
2085CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
2086 const int netfid, __u64 * pExtAttrBits, __u64 *pMask)
2087{
2088 int rc = 0;
2089 struct smb_t2_qfi_req *pSMB = NULL;
2090 struct smb_t2_qfi_rsp *pSMBr = NULL;
2091 int bytes_returned;
2092 __u16 params, byte_count;
2093
2094 cFYI(1,("In GetExtAttr"));
2095 if(tcon == NULL)
2096 return -ENODEV;
2097
2098GetExtAttrRetry:
2099 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
2100 (void **) &pSMBr);
2101 if (rc)
2102 return rc;
2103
2104 params = 2 /* level */ +2 /* fid */;
2105 pSMB->t2.TotalDataCount = 0;
2106 pSMB->t2.MaxParameterCount = cpu_to_le16(4);
2107 /* BB find exact max data count below from sess structure BB */
2108 pSMB->t2.MaxDataCount = cpu_to_le16(4000);
2109 pSMB->t2.MaxSetupCount = 0;
2110 pSMB->t2.Reserved = 0;
2111 pSMB->t2.Flags = 0;
2112 pSMB->t2.Timeout = 0;
2113 pSMB->t2.Reserved2 = 0;
2114 pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req,
2115 Fid) - 4);
2116 pSMB->t2.DataCount = 0;
2117 pSMB->t2.DataOffset = 0;
2118 pSMB->t2.SetupCount = 1;
2119 pSMB->t2.Reserved3 = 0;
2120 pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
2121 byte_count = params + 1 /* pad */ ;
2122 pSMB->t2.TotalParameterCount = cpu_to_le16(params);
2123 pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount;
2124 pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS);
2125 pSMB->Pad = 0;
2126 pSMB->Fid = netfid;
2127 pSMB->hdr.smb_buf_length += byte_count;
2128 pSMB->t2.ByteCount = cpu_to_le16(byte_count);
2129
2130 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
2131 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
2132 if (rc) {
2133 cFYI(1, ("error %d in GetExtAttr", rc));
2134 } else {
2135 /* decode response */
2136 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
2137 if (rc || (pSMBr->ByteCount < 2))
2138 /* BB also check enough total bytes returned */
2139 /* If rc should we check for EOPNOSUPP and
2140 disable the srvino flag? or in caller? */
2141 rc = -EIO; /* bad smb */
2142 else {
2143 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
2144 __u16 count = le16_to_cpu(pSMBr->t2.DataCount);
2145 struct file_chattr_info * pfinfo;
2146 /* BB Do we need a cast or hash here ? */
2147 if(count != 16) {
2148 cFYI(1, ("Illegal size ret in GetExtAttr"));
2149 rc = -EIO;
2150 goto GetExtAttrOut;
2151 }
2152 pfinfo = (struct file_chattr_info *)
2153 (data_offset + (char *) &pSMBr->hdr.Protocol);
2154 *pExtAttrBits = le64_to_cpu(pfinfo->mode);
2155 *pMask = le64_to_cpu(pfinfo->mask);
2156 }
2157 }
2158GetExtAttrOut:
2159 cifs_buf_release(pSMB);
2160 if (rc == -EAGAIN)
2161 goto GetExtAttrRetry;
2162 return rc;
2163}
2164
2165
2166#endif /* CONFIG_POSIX */
2076 2167
2077int 2168int
2078CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon, 2169CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
2079 const unsigned char *searchName, 2170 const unsigned char *searchName,
2080 FILE_ALL_INFO * pFindData, 2171 FILE_ALL_INFO * pFindData,
2081 const struct nls_table *nls_codepage) 2172 const struct nls_table *nls_codepage, int remap)
2082{ 2173{
2083/* level 263 SMB_QUERY_FILE_ALL_INFO */ 2174/* level 263 SMB_QUERY_FILE_ALL_INFO */
2084 TRANSACTION2_QPI_REQ *pSMB = NULL; 2175 TRANSACTION2_QPI_REQ *pSMB = NULL;
@@ -2097,9 +2188,8 @@ QPathInfoRetry:
2097 2188
2098 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2189 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2099 name_len = 2190 name_len =
2100 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 2191 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
2101 /* find define for this maxpathcomponent */ 2192 PATH_MAX, nls_codepage, remap);
2102 , nls_codepage);
2103 name_len++; /* trailing null */ 2193 name_len++; /* trailing null */
2104 name_len *= 2; 2194 name_len *= 2;
2105 } else { /* BB improve the check for buffer overruns BB */ 2195 } else { /* BB improve the check for buffer overruns BB */
@@ -2160,7 +2250,7 @@ int
2160CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon, 2250CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon,
2161 const unsigned char *searchName, 2251 const unsigned char *searchName,
2162 FILE_UNIX_BASIC_INFO * pFindData, 2252 FILE_UNIX_BASIC_INFO * pFindData,
2163 const struct nls_table *nls_codepage) 2253 const struct nls_table *nls_codepage, int remap)
2164{ 2254{
2165/* SMB_QUERY_FILE_UNIX_BASIC */ 2255/* SMB_QUERY_FILE_UNIX_BASIC */
2166 TRANSACTION2_QPI_REQ *pSMB = NULL; 2256 TRANSACTION2_QPI_REQ *pSMB = NULL;
@@ -2179,9 +2269,8 @@ UnixQPathInfoRetry:
2179 2269
2180 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2270 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2181 name_len = 2271 name_len =
2182 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 2272 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
2183 /* find define for this maxpathcomponent */ 2273 PATH_MAX, nls_codepage, remap);
2184 , nls_codepage);
2185 name_len++; /* trailing null */ 2274 name_len++; /* trailing null */
2186 name_len *= 2; 2275 name_len *= 2;
2187 } else { /* BB improve the check for buffer overruns BB */ 2276 } else { /* BB improve the check for buffer overruns BB */
@@ -2261,7 +2350,7 @@ findUniqueRetry:
2261 2350
2262 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2351 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2263 name_len = 2352 name_len =
2264 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 2353 cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
2265 /* find define for this maxpathcomponent */ 2354 /* find define for this maxpathcomponent */
2266 , nls_codepage); 2355 , nls_codepage);
2267 name_len++; /* trailing null */ 2356 name_len++; /* trailing null */
@@ -2325,7 +2414,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
2325 const char *searchName, 2414 const char *searchName,
2326 const struct nls_table *nls_codepage, 2415 const struct nls_table *nls_codepage,
2327 __u16 * pnetfid, 2416 __u16 * pnetfid,
2328 struct cifs_search_info * psrch_inf) 2417 struct cifs_search_info * psrch_inf, int remap)
2329{ 2418{
2330/* level 257 SMB_ */ 2419/* level 257 SMB_ */
2331 TRANSACTION2_FFIRST_REQ *pSMB = NULL; 2420 TRANSACTION2_FFIRST_REQ *pSMB = NULL;
@@ -2336,7 +2425,7 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
2336 int name_len; 2425 int name_len;
2337 __u16 params, byte_count; 2426 __u16 params, byte_count;
2338 2427
2339 cFYI(1, ("In FindFirst")); 2428 cFYI(1, ("In FindFirst for %s",searchName));
2340 2429
2341findFirstRetry: 2430findFirstRetry:
2342 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 2431 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
@@ -2346,20 +2435,30 @@ findFirstRetry:
2346 2435
2347 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2436 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2348 name_len = 2437 name_len =
2349 cifs_strtoUCS((wchar_t *) pSMB->FileName,searchName, 2438 cifsConvertToUCS((__u16 *) pSMB->FileName,searchName,
2350 PATH_MAX, nls_codepage); 2439 PATH_MAX, nls_codepage, remap);
2351 name_len++; /* trailing null */ 2440 /* We can not add the asterik earlier in case
2441 it got remapped to 0xF03A as if it were part of the
2442 directory name instead of a wildcard */
2352 name_len *= 2; 2443 name_len *= 2;
2444 pSMB->FileName[name_len] = '\\';
2445 pSMB->FileName[name_len+1] = 0;
2446 pSMB->FileName[name_len+2] = '*';
2447 pSMB->FileName[name_len+3] = 0;
2448 name_len += 4; /* now the trailing null */
2353 pSMB->FileName[name_len] = 0; /* null terminate just in case */ 2449 pSMB->FileName[name_len] = 0; /* null terminate just in case */
2354 pSMB->FileName[name_len+1] = 0; 2450 pSMB->FileName[name_len+1] = 0;
2451 name_len += 2;
2355 } else { /* BB add check for overrun of SMB buf BB */ 2452 } else { /* BB add check for overrun of SMB buf BB */
2356 name_len = strnlen(searchName, PATH_MAX); 2453 name_len = strnlen(searchName, PATH_MAX);
2357 name_len++; /* trailing null */
2358/* BB fix here and in unicode clause above ie 2454/* BB fix here and in unicode clause above ie
2359 if(name_len > buffersize-header) 2455 if(name_len > buffersize-header)
2360 free buffer exit; BB */ 2456 free buffer exit; BB */
2361 strncpy(pSMB->FileName, searchName, name_len); 2457 strncpy(pSMB->FileName, searchName, name_len);
2362 pSMB->FileName[name_len] = 0; /* just in case */ 2458 pSMB->FileName[name_len] = '\\';
2459 pSMB->FileName[name_len+1] = '*';
2460 pSMB->FileName[name_len+2] = 0;
2461 name_len += 3;
2363 } 2462 }
2364 2463
2365 params = 12 + name_len /* includes null */ ; 2464 params = 12 + name_len /* includes null */ ;
@@ -2422,7 +2521,6 @@ findFirstRetry:
2422 psrch_inf->srch_entries_start = 2521 psrch_inf->srch_entries_start =
2423 (char *) &pSMBr->hdr.Protocol + 2522 (char *) &pSMBr->hdr.Protocol +
2424 le16_to_cpu(pSMBr->t2.DataOffset); 2523 le16_to_cpu(pSMBr->t2.DataOffset);
2425
2426 parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol + 2524 parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
2427 le16_to_cpu(pSMBr->t2.ParameterOffset)); 2525 le16_to_cpu(pSMBr->t2.ParameterOffset));
2428 2526
@@ -2434,7 +2532,6 @@ findFirstRetry:
2434 psrch_inf->entries_in_buffer = le16_to_cpu(parms->SearchCount); 2532 psrch_inf->entries_in_buffer = le16_to_cpu(parms->SearchCount);
2435 psrch_inf->index_of_last_entry = 2533 psrch_inf->index_of_last_entry =
2436 psrch_inf->entries_in_buffer; 2534 psrch_inf->entries_in_buffer;
2437/*cFYI(1,("entries in buf %d index_of_last %d",psrch_inf->entries_in_buffer,psrch_inf->index_of_last_entry)); */
2438 *pnetfid = parms->SearchHandle; 2535 *pnetfid = parms->SearchHandle;
2439 } else { 2536 } else {
2440 cifs_buf_release(pSMB); 2537 cifs_buf_release(pSMB);
@@ -2608,7 +2705,7 @@ int
2608CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 2705CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
2609 const unsigned char *searchName, 2706 const unsigned char *searchName,
2610 __u64 * inode_number, 2707 __u64 * inode_number,
2611 const struct nls_table *nls_codepage) 2708 const struct nls_table *nls_codepage, int remap)
2612{ 2709{
2613 int rc = 0; 2710 int rc = 0;
2614 TRANSACTION2_QPI_REQ *pSMB = NULL; 2711 TRANSACTION2_QPI_REQ *pSMB = NULL;
@@ -2629,8 +2726,8 @@ GetInodeNumberRetry:
2629 2726
2630 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 2727 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2631 name_len = 2728 name_len =
2632 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, 2729 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
2633 PATH_MAX,nls_codepage); 2730 PATH_MAX,nls_codepage, remap);
2634 name_len++; /* trailing null */ 2731 name_len++; /* trailing null */
2635 name_len *= 2; 2732 name_len *= 2;
2636 } else { /* BB improve the check for buffer overruns BB */ 2733 } else { /* BB improve the check for buffer overruns BB */
@@ -2704,7 +2801,7 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
2704 const unsigned char *searchName, 2801 const unsigned char *searchName,
2705 unsigned char **targetUNCs, 2802 unsigned char **targetUNCs,
2706 unsigned int *number_of_UNC_in_array, 2803 unsigned int *number_of_UNC_in_array,
2707 const struct nls_table *nls_codepage) 2804 const struct nls_table *nls_codepage, int remap)
2708{ 2805{
2709/* TRANS2_GET_DFS_REFERRAL */ 2806/* TRANS2_GET_DFS_REFERRAL */
2710 TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL; 2807 TRANSACTION2_GET_DFS_REFER_REQ *pSMB = NULL;
@@ -2740,10 +2837,8 @@ getDFSRetry:
2740 if (ses->capabilities & CAP_UNICODE) { 2837 if (ses->capabilities & CAP_UNICODE) {
2741 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; 2838 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
2742 name_len = 2839 name_len =
2743 cifs_strtoUCS((wchar_t *) pSMB->RequestFileName, 2840 cifsConvertToUCS((__u16 *) pSMB->RequestFileName,
2744 searchName, PATH_MAX 2841 searchName, PATH_MAX, nls_codepage, remap);
2745 /* find define for this maxpathcomponent */
2746 , nls_codepage);
2747 name_len++; /* trailing null */ 2842 name_len++; /* trailing null */
2748 name_len *= 2; 2843 name_len *= 2;
2749 } else { /* BB improve the check for buffer overruns BB */ 2844 } else { /* BB improve the check for buffer overruns BB */
@@ -2871,8 +2966,7 @@ GetDFSRefExit:
2871} 2966}
2872 2967
2873int 2968int
2874CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, 2969CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, struct kstatfs *FSData)
2875 struct kstatfs *FSData, const struct nls_table *nls_codepage)
2876{ 2970{
2877/* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */ 2971/* level 0x103 SMB_QUERY_FILE_SYSTEM_INFO */
2878 TRANSACTION2_QFSI_REQ *pSMB = NULL; 2972 TRANSACTION2_QFSI_REQ *pSMB = NULL;
@@ -2955,8 +3049,7 @@ QFSInfoRetry:
2955} 3049}
2956 3050
2957int 3051int
2958CIFSSMBQFSAttributeInfo(const int xid, struct cifsTconInfo *tcon, 3052CIFSSMBQFSAttributeInfo(const int xid, struct cifsTconInfo *tcon)
2959 const struct nls_table *nls_codepage)
2960{ 3053{
2961/* level 0x105 SMB_QUERY_FILE_SYSTEM_INFO */ 3054/* level 0x105 SMB_QUERY_FILE_SYSTEM_INFO */
2962 TRANSACTION2_QFSI_REQ *pSMB = NULL; 3055 TRANSACTION2_QFSI_REQ *pSMB = NULL;
@@ -3024,8 +3117,7 @@ QFSAttributeRetry:
3024} 3117}
3025 3118
3026int 3119int
3027CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon, 3120CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon)
3028 const struct nls_table *nls_codepage)
3029{ 3121{
3030/* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */ 3122/* level 0x104 SMB_QUERY_FILE_SYSTEM_INFO */
3031 TRANSACTION2_QFSI_REQ *pSMB = NULL; 3123 TRANSACTION2_QFSI_REQ *pSMB = NULL;
@@ -3078,8 +3170,8 @@ QFSDeviceRetry:
3078 else { 3170 else {
3079 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); 3171 __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
3080 response_data = 3172 response_data =
3081 (FILE_SYSTEM_DEVICE_INFO 3173 (FILE_SYSTEM_DEVICE_INFO *)
3082 *) (((char *) &pSMBr->hdr.Protocol) + 3174 (((char *) &pSMBr->hdr.Protocol) +
3083 data_offset); 3175 data_offset);
3084 memcpy(&tcon->fsDevInfo, response_data, 3176 memcpy(&tcon->fsDevInfo, response_data,
3085 sizeof (FILE_SYSTEM_DEVICE_INFO)); 3177 sizeof (FILE_SYSTEM_DEVICE_INFO));
@@ -3094,8 +3186,7 @@ QFSDeviceRetry:
3094} 3186}
3095 3187
3096int 3188int
3097CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon, 3189CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon)
3098 const struct nls_table *nls_codepage)
3099{ 3190{
3100/* level 0x200 SMB_QUERY_CIFS_UNIX_INFO */ 3191/* level 0x200 SMB_QUERY_CIFS_UNIX_INFO */
3101 TRANSACTION2_QFSI_REQ *pSMB = NULL; 3192 TRANSACTION2_QFSI_REQ *pSMB = NULL;
@@ -3166,7 +3257,7 @@ QFSUnixRetry:
3166 3257
3167int 3258int
3168CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon, 3259CIFSSMBQFSPosixInfo(const int xid, struct cifsTconInfo *tcon,
3169 struct kstatfs *FSData, const struct nls_table *nls_codepage) 3260 struct kstatfs *FSData)
3170{ 3261{
3171/* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */ 3262/* level 0x201 SMB_QUERY_CIFS_POSIX_INFO */
3172 TRANSACTION2_QFSI_REQ *pSMB = NULL; 3263 TRANSACTION2_QFSI_REQ *pSMB = NULL;
@@ -3258,7 +3349,8 @@ QFSPosixRetry:
3258 3349
3259int 3350int
3260CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, 3351CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName,
3261 __u64 size, int SetAllocation, const struct nls_table *nls_codepage) 3352 __u64 size, int SetAllocation,
3353 const struct nls_table *nls_codepage, int remap)
3262{ 3354{
3263 struct smb_com_transaction2_spi_req *pSMB = NULL; 3355 struct smb_com_transaction2_spi_req *pSMB = NULL;
3264 struct smb_com_transaction2_spi_rsp *pSMBr = NULL; 3356 struct smb_com_transaction2_spi_rsp *pSMBr = NULL;
@@ -3277,9 +3369,8 @@ SetEOFRetry:
3277 3369
3278 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3370 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3279 name_len = 3371 name_len =
3280 cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX 3372 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
3281 /* find define for this maxpathcomponent */ 3373 PATH_MAX, nls_codepage, remap);
3282 , nls_codepage);
3283 name_len++; /* trailing null */ 3374 name_len++; /* trailing null */
3284 name_len *= 2; 3375 name_len *= 2;
3285 } else { /* BB improve the check for buffer overruns BB */ 3376 } else { /* BB improve the check for buffer overruns BB */
@@ -3360,11 +3451,13 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
3360 3451
3361 cFYI(1, ("SetFileSize (via SetFileInfo) %lld", 3452 cFYI(1, ("SetFileSize (via SetFileInfo) %lld",
3362 (long long)size)); 3453 (long long)size));
3363 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 3454 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
3364 (void **) &pSMBr); 3455
3365 if (rc) 3456 if (rc)
3366 return rc; 3457 return rc;
3367 3458
3459 pSMBr = (struct smb_com_transaction2_sfi_rsp *)pSMB;
3460
3368 pSMB->hdr.Pid = cpu_to_le16((__u16)pid_of_opener); 3461 pSMB->hdr.Pid = cpu_to_le16((__u16)pid_of_opener);
3369 pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid_of_opener >> 16)); 3462 pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid_of_opener >> 16));
3370 3463
@@ -3424,7 +3517,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
3424 } 3517 }
3425 3518
3426 if (pSMB) 3519 if (pSMB)
3427 cifs_buf_release(pSMB); 3520 cifs_small_buf_release(pSMB);
3428 3521
3429 /* Note: On -EAGAIN error only caller can retry on handle based calls 3522 /* Note: On -EAGAIN error only caller can retry on handle based calls
3430 since file handle passed in no longer valid */ 3523 since file handle passed in no longer valid */
@@ -3450,11 +3543,13 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I
3450 __u16 params, param_offset, offset, byte_count, count; 3543 __u16 params, param_offset, offset, byte_count, count;
3451 3544
3452 cFYI(1, ("Set Times (via SetFileInfo)")); 3545 cFYI(1, ("Set Times (via SetFileInfo)"));
3453 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 3546 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
3454 (void **) &pSMBr); 3547
3455 if (rc) 3548 if (rc)
3456 return rc; 3549 return rc;
3457 3550
3551 pSMBr = (struct smb_com_transaction2_sfi_rsp *)pSMB;
3552
3458 /* At this point there is no need to override the current pid 3553 /* At this point there is no need to override the current pid
3459 with the pid of the opener, but that could change if we someday 3554 with the pid of the opener, but that could change if we someday
3460 use an existing handle (rather than opening one on the fly) */ 3555 use an existing handle (rather than opening one on the fly) */
@@ -3500,7 +3595,7 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I
3500 cFYI(1,("Send error in Set Time (SetFileInfo) = %d",rc)); 3595 cFYI(1,("Send error in Set Time (SetFileInfo) = %d",rc));
3501 } 3596 }
3502 3597
3503 cifs_buf_release(pSMB); 3598 cifs_small_buf_release(pSMB);
3504 3599
3505 /* Note: On -EAGAIN error only caller can retry on handle based calls 3600 /* Note: On -EAGAIN error only caller can retry on handle based calls
3506 since file handle passed in no longer valid */ 3601 since file handle passed in no longer valid */
@@ -3512,7 +3607,7 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I
3512int 3607int
3513CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, const char *fileName, 3608CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon, const char *fileName,
3514 const FILE_BASIC_INFO * data, 3609 const FILE_BASIC_INFO * data,
3515 const struct nls_table *nls_codepage) 3610 const struct nls_table *nls_codepage, int remap)
3516{ 3611{
3517 TRANSACTION2_SPI_REQ *pSMB = NULL; 3612 TRANSACTION2_SPI_REQ *pSMB = NULL;
3518 TRANSACTION2_SPI_RSP *pSMBr = NULL; 3613 TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -3532,9 +3627,8 @@ SetTimesRetry:
3532 3627
3533 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3628 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3534 name_len = 3629 name_len =
3535 cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX 3630 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
3536 /* find define for this maxpathcomponent */ 3631 PATH_MAX, nls_codepage, remap);
3537 , nls_codepage);
3538 name_len++; /* trailing null */ 3632 name_len++; /* trailing null */
3539 name_len *= 2; 3633 name_len *= 2;
3540 } else { /* BB improve the check for buffer overruns BB */ 3634 } else { /* BB improve the check for buffer overruns BB */
@@ -3614,7 +3708,7 @@ SetAttrLgcyRetry:
3614 3708
3615 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3709 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3616 name_len = 3710 name_len =
3617 cifs_strtoUCS((wchar_t *) pSMB->fileName, fileName, 3711 ConvertToUCS((wchar_t *) pSMB->fileName, fileName,
3618 PATH_MAX, nls_codepage); 3712 PATH_MAX, nls_codepage);
3619 name_len++; /* trailing null */ 3713 name_len++; /* trailing null */
3620 name_len *= 2; 3714 name_len *= 2;
@@ -3644,8 +3738,9 @@ SetAttrLgcyRetry:
3644 3738
3645int 3739int
3646CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon, 3740CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
3647 char *fileName, __u64 mode, __u64 uid, __u64 gid, 3741 char *fileName, __u64 mode, __u64 uid, __u64 gid,
3648 dev_t device, const struct nls_table *nls_codepage) 3742 dev_t device, const struct nls_table *nls_codepage,
3743 int remap)
3649{ 3744{
3650 TRANSACTION2_SPI_REQ *pSMB = NULL; 3745 TRANSACTION2_SPI_REQ *pSMB = NULL;
3651 TRANSACTION2_SPI_RSP *pSMBr = NULL; 3746 TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -3664,9 +3759,8 @@ setPermsRetry:
3664 3759
3665 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3760 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3666 name_len = 3761 name_len =
3667 cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX 3762 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
3668 /* find define for this maxpathcomponent */ 3763 PATH_MAX, nls_codepage, remap);
3669 , nls_codepage);
3670 name_len++; /* trailing null */ 3764 name_len++; /* trailing null */
3671 name_len *= 2; 3765 name_len *= 2;
3672 } else { /* BB improve the check for buffer overruns BB */ 3766 } else { /* BB improve the check for buffer overruns BB */
@@ -3789,7 +3883,7 @@ ssize_t
3789CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon, 3883CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
3790 const unsigned char *searchName, 3884 const unsigned char *searchName,
3791 char * EAData, size_t buf_size, 3885 char * EAData, size_t buf_size,
3792 const struct nls_table *nls_codepage) 3886 const struct nls_table *nls_codepage, int remap)
3793{ 3887{
3794 /* BB assumes one setup word */ 3888 /* BB assumes one setup word */
3795 TRANSACTION2_QPI_REQ *pSMB = NULL; 3889 TRANSACTION2_QPI_REQ *pSMB = NULL;
@@ -3810,9 +3904,8 @@ QAllEAsRetry:
3810 3904
3811 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 3905 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3812 name_len = 3906 name_len =
3813 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 3907 cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName,
3814 /* find define for this maxpathcomponent */ 3908 PATH_MAX, nls_codepage, remap);
3815 , nls_codepage);
3816 name_len++; /* trailing null */ 3909 name_len++; /* trailing null */
3817 name_len *= 2; 3910 name_len *= 2;
3818 } else { /* BB improve the check for buffer overruns BB */ 3911 } else { /* BB improve the check for buffer overruns BB */
@@ -3934,7 +4027,7 @@ QAllEAsRetry:
3934ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon, 4027ssize_t CIFSSMBQueryEA(const int xid,struct cifsTconInfo * tcon,
3935 const unsigned char * searchName,const unsigned char * ea_name, 4028 const unsigned char * searchName,const unsigned char * ea_name,
3936 unsigned char * ea_value, size_t buf_size, 4029 unsigned char * ea_value, size_t buf_size,
3937 const struct nls_table *nls_codepage) 4030 const struct nls_table *nls_codepage, int remap)
3938{ 4031{
3939 TRANSACTION2_QPI_REQ *pSMB = NULL; 4032 TRANSACTION2_QPI_REQ *pSMB = NULL;
3940 TRANSACTION2_QPI_RSP *pSMBr = NULL; 4033 TRANSACTION2_QPI_RSP *pSMBr = NULL;
@@ -3954,9 +4047,8 @@ QEARetry:
3954 4047
3955 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 4048 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3956 name_len = 4049 name_len =
3957 cifs_strtoUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX 4050 cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
3958 /* find define for this maxpathcomponent */ 4051 PATH_MAX, nls_codepage, remap);
3959 , nls_codepage);
3960 name_len++; /* trailing null */ 4052 name_len++; /* trailing null */
3961 name_len *= 2; 4053 name_len *= 2;
3962 } else { /* BB improve the check for buffer overruns BB */ 4054 } else { /* BB improve the check for buffer overruns BB */
@@ -4082,7 +4174,8 @@ QEARetry:
4082int 4174int
4083CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName, 4175CIFSSMBSetEA(const int xid, struct cifsTconInfo *tcon, const char *fileName,
4084 const char * ea_name, const void * ea_value, 4176 const char * ea_name, const void * ea_value,
4085 const __u16 ea_value_len, const struct nls_table *nls_codepage) 4177 const __u16 ea_value_len, const struct nls_table *nls_codepage,
4178 int remap)
4086{ 4179{
4087 struct smb_com_transaction2_spi_req *pSMB = NULL; 4180 struct smb_com_transaction2_spi_req *pSMB = NULL;
4088 struct smb_com_transaction2_spi_rsp *pSMBr = NULL; 4181 struct smb_com_transaction2_spi_rsp *pSMBr = NULL;
@@ -4101,9 +4194,8 @@ SetEARetry:
4101 4194
4102 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { 4195 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4103 name_len = 4196 name_len =
4104 cifs_strtoUCS((wchar_t *) pSMB->FileName, fileName, PATH_MAX 4197 cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
4105 /* find define for this maxpathcomponent */ 4198 PATH_MAX, nls_codepage, remap);
4106 , nls_codepage);
4107 name_len++; /* trailing null */ 4199 name_len++; /* trailing null */
4108 name_len *= 2; 4200 name_len *= 2;
4109 } else { /* BB improve the check for buffer overruns BB */ 4201 } else { /* BB improve the check for buffer overruns BB */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 40470b9d5477..e568cc47a7f9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/connect.c 2 * fs/cifs/connect.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2004 4 * Copyright (C) International Business Machines Corp., 2002,2005
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/utsname.h> 29#include <linux/utsname.h>
30#include <linux/mempool.h> 30#include <linux/mempool.h>
31#include <linux/delay.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/processor.h> 33#include <asm/processor.h>
33#include "cifspdu.h" 34#include "cifspdu.h"
@@ -72,6 +73,7 @@ struct smb_vol {
72 unsigned no_xattr:1; /* set if xattr (EA) support should be disabled*/ 73 unsigned no_xattr:1; /* set if xattr (EA) support should be disabled*/
73 unsigned server_ino:1; /* use inode numbers from server ie UniqueId */ 74 unsigned server_ino:1; /* use inode numbers from server ie UniqueId */
74 unsigned direct_io:1; 75 unsigned direct_io:1;
76 unsigned remap:1; /* set to remap seven reserved chars in filenames */
75 unsigned int rsize; 77 unsigned int rsize;
76 unsigned int wsize; 78 unsigned int wsize;
77 unsigned int sockopt; 79 unsigned int sockopt;
@@ -114,7 +116,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
114 spin_unlock(&GlobalMid_Lock); 116 spin_unlock(&GlobalMid_Lock);
115 server->maxBuf = 0; 117 server->maxBuf = 0;
116 118
117 cFYI(1, ("Reconnecting tcp session ")); 119 cFYI(1, ("Reconnecting tcp session"));
118 120
119 /* before reconnecting the tcp session, mark the smb session (uid) 121 /* before reconnecting the tcp session, mark the smb session (uid)
120 and the tid bad so they are not used until reconnected */ 122 and the tid bad so they are not used until reconnected */
@@ -155,9 +157,10 @@ cifs_reconnect(struct TCP_Server_Info *server)
155 qhead); 157 qhead);
156 if(mid_entry) { 158 if(mid_entry) {
157 if(mid_entry->midState == MID_REQUEST_SUBMITTED) { 159 if(mid_entry->midState == MID_REQUEST_SUBMITTED) {
158 /* Mark other intransit requests as needing retry so 160 /* Mark other intransit requests as needing
159 we do not immediately mark the session bad again 161 retry so we do not immediately mark the
160 (ie after we reconnect below) as they timeout too */ 162 session bad again (ie after we reconnect
163 below) as they timeout too */
161 mid_entry->midState = MID_RETRY_NEEDED; 164 mid_entry->midState = MID_RETRY_NEEDED;
162 } 165 }
163 } 166 }
@@ -175,14 +178,14 @@ cifs_reconnect(struct TCP_Server_Info *server)
175 server->workstation_RFC1001_name); 178 server->workstation_RFC1001_name);
176 } 179 }
177 if(rc) { 180 if(rc) {
178 set_current_state(TASK_INTERRUPTIBLE); 181 msleep(3000);
179 schedule_timeout(3 * HZ);
180 } else { 182 } else {
181 atomic_inc(&tcpSesReconnectCount); 183 atomic_inc(&tcpSesReconnectCount);
182 spin_lock(&GlobalMid_Lock); 184 spin_lock(&GlobalMid_Lock);
183 if(server->tcpStatus != CifsExiting) 185 if(server->tcpStatus != CifsExiting)
184 server->tcpStatus = CifsGood; 186 server->tcpStatus = CifsGood;
185 spin_unlock(&GlobalMid_Lock); 187 server->sequence_number = 0;
188 spin_unlock(&GlobalMid_Lock);
186 /* atomic_set(&server->inFlight,0);*/ 189 /* atomic_set(&server->inFlight,0);*/
187 wake_up(&server->response_q); 190 wake_up(&server->response_q);
188 } 191 }
@@ -190,12 +193,129 @@ cifs_reconnect(struct TCP_Server_Info *server)
190 return rc; 193 return rc;
191} 194}
192 195
196/*
197 return codes:
198 0 not a transact2, or all data present
199 >0 transact2 with that much data missing
200 -EINVAL = invalid transact2
201
202 */
203static int check2ndT2(struct smb_hdr * pSMB, unsigned int maxBufSize)
204{
205 struct smb_t2_rsp * pSMBt;
206 int total_data_size;
207 int data_in_this_rsp;
208 int remaining;
209
210 if(pSMB->Command != SMB_COM_TRANSACTION2)
211 return 0;
212
213 /* check for plausible wct, bcc and t2 data and parm sizes */
214 /* check for parm and data offset going beyond end of smb */
215 if(pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
216 cFYI(1,("invalid transact2 word count"));
217 return -EINVAL;
218 }
219
220 pSMBt = (struct smb_t2_rsp *)pSMB;
221
222 total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount);
223 data_in_this_rsp = le16_to_cpu(pSMBt->t2_rsp.DataCount);
224
225 remaining = total_data_size - data_in_this_rsp;
226
227 if(remaining == 0)
228 return 0;
229 else if(remaining < 0) {
230 cFYI(1,("total data %d smaller than data in frame %d",
231 total_data_size, data_in_this_rsp));
232 return -EINVAL;
233 } else {
234 cFYI(1,("missing %d bytes from transact2, check next response",
235 remaining));
236 if(total_data_size > maxBufSize) {
237 cERROR(1,("TotalDataSize %d is over maximum buffer %d",
238 total_data_size,maxBufSize));
239 return -EINVAL;
240 }
241 return remaining;
242 }
243}
244
245static int coalesce_t2(struct smb_hdr * psecond, struct smb_hdr *pTargetSMB)
246{
247 struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond;
248 struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB;
249 int total_data_size;
250 int total_in_buf;
251 int remaining;
252 int total_in_buf2;
253 char * data_area_of_target;
254 char * data_area_of_buf2;
255 __u16 byte_count;
256
257 total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount);
258
259 if(total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) {
260 cFYI(1,("total data sizes of primary and secondary t2 differ"));
261 }
262
263 total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount);
264
265 remaining = total_data_size - total_in_buf;
266
267 if(remaining < 0)
268 return -EINVAL;
269
270 if(remaining == 0) /* nothing to do, ignore */
271 return 0;
272
273 total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount);
274 if(remaining < total_in_buf2) {
275 cFYI(1,("transact2 2nd response contains too much data"));
276 }
277
278 /* find end of first SMB data area */
279 data_area_of_target = (char *)&pSMBt->hdr.Protocol +
280 le16_to_cpu(pSMBt->t2_rsp.DataOffset);
281 /* validate target area */
282
283 data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol +
284 le16_to_cpu(pSMB2->t2_rsp.DataOffset);
285
286 data_area_of_target += total_in_buf;
287
288 /* copy second buffer into end of first buffer */
289 memcpy(data_area_of_target,data_area_of_buf2,total_in_buf2);
290 total_in_buf += total_in_buf2;
291 pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf);
292 byte_count = le16_to_cpu(BCC_LE(pTargetSMB));
293 byte_count += total_in_buf2;
294 BCC_LE(pTargetSMB) = cpu_to_le16(byte_count);
295
296 byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
297 byte_count += total_in_buf2;
298
299 /* BB also add check that we are not beyond maximum buffer size */
300
301 pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);
302
303 if(remaining == total_in_buf2) {
304 cFYI(1,("found the last secondary response"));
305 return 0; /* we are done */
306 } else /* more responses to go */
307 return 1;
308
309}
310
193static int 311static int
194cifs_demultiplex_thread(struct TCP_Server_Info *server) 312cifs_demultiplex_thread(struct TCP_Server_Info *server)
195{ 313{
196 int length; 314 int length;
197 unsigned int pdu_length, total_read; 315 unsigned int pdu_length, total_read;
198 struct smb_hdr *smb_buffer = NULL; 316 struct smb_hdr *smb_buffer = NULL;
317 struct smb_hdr *bigbuf = NULL;
318 struct smb_hdr *smallbuf = NULL;
199 struct msghdr smb_msg; 319 struct msghdr smb_msg;
200 struct kvec iov; 320 struct kvec iov;
201 struct socket *csocket = server->ssocket; 321 struct socket *csocket = server->ssocket;
@@ -204,6 +324,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
204 struct task_struct *task_to_wake = NULL; 324 struct task_struct *task_to_wake = NULL;
205 struct mid_q_entry *mid_entry; 325 struct mid_q_entry *mid_entry;
206 char *temp; 326 char *temp;
327 int isLargeBuf = FALSE;
328 int isMultiRsp;
329 int reconnect;
207 330
208 daemonize("cifsd"); 331 daemonize("cifsd");
209 allow_signal(SIGKILL); 332 allow_signal(SIGKILL);
@@ -221,17 +344,34 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
221 } 344 }
222 345
223 while (server->tcpStatus != CifsExiting) { 346 while (server->tcpStatus != CifsExiting) {
224 if (smb_buffer == NULL) 347 if (bigbuf == NULL) {
225 smb_buffer = cifs_buf_get(); 348 bigbuf = cifs_buf_get();
226 else 349 if(bigbuf == NULL) {
227 memset(smb_buffer, 0, sizeof (struct smb_hdr)); 350 cERROR(1,("No memory for large SMB response"));
228 351 msleep(3000);
229 if (smb_buffer == NULL) { 352 /* retry will check if exiting */
230 cERROR(1,("Can not get memory for SMB response")); 353 continue;
231 set_current_state(TASK_INTERRUPTIBLE); 354 }
232 schedule_timeout(HZ * 3); /* give system time to free memory */ 355 } else if(isLargeBuf) {
233 continue; 356 /* we are reusing a dirtry large buf, clear its start */
357 memset(bigbuf, 0, sizeof (struct smb_hdr));
234 } 358 }
359
360 if (smallbuf == NULL) {
361 smallbuf = cifs_small_buf_get();
362 if(smallbuf == NULL) {
363 cERROR(1,("No memory for SMB response"));
364 msleep(1000);
365 /* retry will check if exiting */
366 continue;
367 }
368 /* beginning of smb buffer is cleared in our buf_get */
369 } else /* if existing small buf clear beginning */
370 memset(smallbuf, 0, sizeof (struct smb_hdr));
371
372 isLargeBuf = FALSE;
373 isMultiRsp = FALSE;
374 smb_buffer = smallbuf;
235 iov.iov_base = smb_buffer; 375 iov.iov_base = smb_buffer;
236 iov.iov_len = 4; 376 iov.iov_len = 4;
237 smb_msg.msg_control = NULL; 377 smb_msg.msg_control = NULL;
@@ -243,176 +383,257 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
243 if(server->tcpStatus == CifsExiting) { 383 if(server->tcpStatus == CifsExiting) {
244 break; 384 break;
245 } else if (server->tcpStatus == CifsNeedReconnect) { 385 } else if (server->tcpStatus == CifsNeedReconnect) {
246 cFYI(1,("Reconnecting after server stopped responding")); 386 cFYI(1,("Reconnect after server stopped responding"));
247 cifs_reconnect(server); 387 cifs_reconnect(server);
248 cFYI(1,("call to reconnect done")); 388 cFYI(1,("call to reconnect done"));
249 csocket = server->ssocket; 389 csocket = server->ssocket;
250 continue; 390 continue;
251 } else if ((length == -ERESTARTSYS) || (length == -EAGAIN)) { 391 } else if ((length == -ERESTARTSYS) || (length == -EAGAIN)) {
252 set_current_state(TASK_INTERRUPTIBLE); 392 msleep(1); /* minimum sleep to prevent looping
253 schedule_timeout(1); /* minimum sleep to prevent looping
254 allowing socket to clear and app threads to set 393 allowing socket to clear and app threads to set
255 tcpStatus CifsNeedReconnect if server hung */ 394 tcpStatus CifsNeedReconnect if server hung */
256 continue; 395 continue;
257 } else if (length <= 0) { 396 } else if (length <= 0) {
258 if(server->tcpStatus == CifsNew) { 397 if(server->tcpStatus == CifsNew) {
259 cFYI(1,("tcp session abended prematurely (after SMBnegprot)")); 398 cFYI(1,("tcp session abend after SMBnegprot"));
260 /* some servers kill tcp session rather than returning 399 /* some servers kill the TCP session rather than
261 smb negprot error in which case reconnecting here is 400 returning an SMB negprot error, in which
262 not going to help - return error to mount */ 401 case reconnecting here is not going to help,
402 and so simply return error to mount */
263 break; 403 break;
264 } 404 }
265 if(length == -EINTR) { 405 if(length == -EINTR) {
266 cFYI(1,("cifsd thread killed")); 406 cFYI(1,("cifsd thread killed"));
267 break; 407 break;
268 } 408 }
269 cFYI(1,("Reconnecting after unexpected peek error %d",length)); 409 cFYI(1,("Reconnect after unexpected peek error %d",
410 length));
270 cifs_reconnect(server); 411 cifs_reconnect(server);
271 csocket = server->ssocket; 412 csocket = server->ssocket;
272 wake_up(&server->response_q); 413 wake_up(&server->response_q);
273 continue; 414 continue;
274 } else if (length > 3) { 415 } else if (length < 4) {
275 pdu_length = ntohl(smb_buffer->smb_buf_length); 416 cFYI(1,
276 /* Only read pdu_length after below checks for too short (due 417 ("Frame under four bytes received (%d bytes long)",
277 to e.g. int overflow) and too long ie beyond end of buf */ 418 length));
278 cFYI(1,("rfc1002 length(big endian)0x%x)", pdu_length+4)); 419 cifs_reconnect(server);
279 420 csocket = server->ssocket;
280 temp = (char *) smb_buffer; 421 wake_up(&server->response_q);
281 if (temp[0] == (char) RFC1002_SESSION_KEEP_ALIVE) { 422 continue;
282 cFYI(0,("Received 4 byte keep alive packet")); 423 }
283 } else if (temp[0] == (char) RFC1002_POSITIVE_SESSION_RESPONSE) {
284 cFYI(1,("Good RFC 1002 session rsp"));
285 } else if (temp[0] == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) {
286 /* we get this from Windows 98 instead of error on SMB negprot response */
287 cFYI(1,("Negative RFC 1002 Session Response Error 0x%x)",temp[4]));
288 if(server->tcpStatus == CifsNew) {
289 /* if nack on negprot (rather than
290 ret of smb negprot error) reconnecting
291 not going to help, ret error to mount */
292 break;
293 } else {
294 /* give server a second to
295 clean up before reconnect attempt */
296 set_current_state(TASK_INTERRUPTIBLE);
297 schedule_timeout(HZ);
298 /* always try 445 first on reconnect
299 since we get NACK on some if we ever
300 connected to port 139 (the NACK is
301 since we do not begin with RFC1001
302 session initialize frame) */
303 server->addr.sockAddr.sin_port = htons(CIFS_PORT);
304 cifs_reconnect(server);
305 csocket = server->ssocket;
306 wake_up(&server->response_q);
307 continue;
308 }
309 } else if (temp[0] != (char) 0) {
310 cERROR(1,("Unknown RFC 1002 frame"));
311 cifs_dump_mem(" Received Data: ", temp, length);
312 cifs_reconnect(server);
313 csocket = server->ssocket;
314 continue;
315 } else {
316 if((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)
317 || (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) {
318 cERROR(1,
319 ("Invalid size SMB length %d and pdu_length %d",
320 length, pdu_length+4));
321 cifs_reconnect(server);
322 csocket = server->ssocket;
323 wake_up(&server->response_q);
324 continue;
325 } else { /* length ok */
326 length = 0;
327 iov.iov_base = 4 + (char *)smb_buffer;
328 iov.iov_len = pdu_length;
329 for (total_read = 0;
330 total_read < pdu_length;
331 total_read += length) {
332 length = kernel_recvmsg(csocket, &smb_msg,
333 &iov, 1,
334 pdu_length - total_read, 0);
335 if (length == 0) {
336 cERROR(1,
337 ("Zero length receive when expecting %d ",
338 pdu_length - total_read));
339 cifs_reconnect(server);
340 csocket = server->ssocket;
341 wake_up(&server->response_q);
342 continue;
343 }
344 }
345 length += 4; /* account for rfc1002 hdr */
346 }
347 424
348 dump_smb(smb_buffer, length); 425 /* the right amount was read from socket - 4 bytes */
349 if (checkSMB
350 (smb_buffer, smb_buffer->Mid, total_read+4)) {
351 cERROR(1, ("Bad SMB Received "));
352 continue;
353 }
354 426
355 task_to_wake = NULL; 427 pdu_length = ntohl(smb_buffer->smb_buf_length);
356 spin_lock(&GlobalMid_Lock); 428 cFYI(1,("rfc1002 length(big endian)0x%x)", pdu_length+4));
357 list_for_each(tmp, &server->pending_mid_q) {
358 mid_entry = list_entry(tmp, struct
359 mid_q_entry,
360 qhead);
361 429
362 if ((mid_entry->mid == smb_buffer->Mid) && (mid_entry->midState == MID_REQUEST_SUBMITTED)) { 430 temp = (char *) smb_buffer;
363 cFYI(1, 431 if (temp[0] == (char) RFC1002_SESSION_KEEP_ALIVE) {
364 (" Mid 0x%x matched - waking up ",mid_entry->mid)); 432 continue;
365 task_to_wake = mid_entry->tsk; 433 } else if (temp[0] == (char)RFC1002_POSITIVE_SESSION_RESPONSE) {
366 mid_entry->resp_buf = 434 cFYI(1,("Good RFC 1002 session rsp"));
367 smb_buffer; 435 continue;
368 mid_entry->midState = 436 } else if (temp[0] == (char)RFC1002_NEGATIVE_SESSION_RESPONSE) {
369 MID_RESPONSE_RECEIVED; 437 /* we get this from Windows 98 instead of
370 } 438 an error on SMB negprot response */
371 } 439 cFYI(1,("Negative RFC1002 Session Response Error 0x%x)",
372 spin_unlock(&GlobalMid_Lock); 440 temp[4]));
373 if (task_to_wake) { 441 if(server->tcpStatus == CifsNew) {
374 smb_buffer = NULL; /* will be freed by users thread after he is done */ 442 /* if nack on negprot (rather than
375 wake_up_process(task_to_wake); 443 ret of smb negprot error) reconnecting
376 } else if (is_valid_oplock_break(smb_buffer) == FALSE) { 444 not going to help, ret error to mount */
377 cERROR(1, ("No task to wake, unknown frame rcvd!")); 445 break;
378 cifs_dump_mem("Received Data is: ",temp,sizeof(struct smb_hdr)); 446 } else {
379 } 447 /* give server a second to
448 clean up before reconnect attempt */
449 msleep(1000);
450 /* always try 445 first on reconnect
451 since we get NACK on some if we ever
452 connected to port 139 (the NACK is
453 since we do not begin with RFC1001
454 session initialize frame) */
455 server->addr.sockAddr.sin_port =
456 htons(CIFS_PORT);
457 cifs_reconnect(server);
458 csocket = server->ssocket;
459 wake_up(&server->response_q);
460 continue;
380 } 461 }
381 } else { 462 } else if (temp[0] != (char) 0) {
382 cFYI(1, 463 cERROR(1,("Unknown RFC 1002 frame"));
383 ("Frame less than four bytes received %d bytes long.", 464 cifs_dump_mem(" Received Data: ", temp, length);
384 length)); 465 cifs_reconnect(server);
466 csocket = server->ssocket;
467 continue;
468 }
469
470 /* else we have an SMB response */
471 if((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) ||
472 (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) {
473 cERROR(1, ("Invalid size SMB length %d pdu_length %d",
474 length, pdu_length+4));
385 cifs_reconnect(server); 475 cifs_reconnect(server);
386 csocket = server->ssocket; 476 csocket = server->ssocket;
387 wake_up(&server->response_q); 477 wake_up(&server->response_q);
388 continue; 478 continue;
479 }
480
481 /* else length ok */
482 reconnect = 0;
483
484 if(pdu_length > MAX_CIFS_HDR_SIZE - 4) {
485 isLargeBuf = TRUE;
486 memcpy(bigbuf, smallbuf, 4);
487 smb_buffer = bigbuf;
389 } 488 }
390 } 489 length = 0;
490 iov.iov_base = 4 + (char *)smb_buffer;
491 iov.iov_len = pdu_length;
492 for (total_read = 0; total_read < pdu_length;
493 total_read += length) {
494 length = kernel_recvmsg(csocket, &smb_msg, &iov, 1,
495 pdu_length - total_read, 0);
496 if((server->tcpStatus == CifsExiting) ||
497 (length == -EINTR)) {
498 /* then will exit */
499 reconnect = 2;
500 break;
501 } else if (server->tcpStatus == CifsNeedReconnect) {
502 cifs_reconnect(server);
503 csocket = server->ssocket;
504 /* Reconnect wakes up rspns q */
505 /* Now we will reread sock */
506 reconnect = 1;
507 break;
508 } else if ((length == -ERESTARTSYS) ||
509 (length == -EAGAIN)) {
510 msleep(1); /* minimum sleep to prevent looping,
511 allowing socket to clear and app
512 threads to set tcpStatus
513 CifsNeedReconnect if server hung*/
514 continue;
515 } else if (length <= 0) {
516 cERROR(1,("Received no data, expecting %d",
517 pdu_length - total_read));
518 cifs_reconnect(server);
519 csocket = server->ssocket;
520 reconnect = 1;
521 break;
522 }
523 }
524 if(reconnect == 2)
525 break;
526 else if(reconnect == 1)
527 continue;
528
529 length += 4; /* account for rfc1002 hdr */
530
531
532 dump_smb(smb_buffer, length);
533 if (checkSMB (smb_buffer, smb_buffer->Mid, total_read+4)) {
534 cERROR(1, ("Bad SMB Received "));
535 continue;
536 }
537
538
539 task_to_wake = NULL;
540 spin_lock(&GlobalMid_Lock);
541 list_for_each(tmp, &server->pending_mid_q) {
542 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
543
544 if ((mid_entry->mid == smb_buffer->Mid) &&
545 (mid_entry->midState == MID_REQUEST_SUBMITTED) &&
546 (mid_entry->command == smb_buffer->Command)) {
547 if(check2ndT2(smb_buffer,server->maxBuf) > 0) {
548 /* We have a multipart transact2 resp */
549 isMultiRsp = TRUE;
550 if(mid_entry->resp_buf) {
551 /* merge response - fix up 1st*/
552 if(coalesce_t2(smb_buffer,
553 mid_entry->resp_buf)) {
554 break;
555 } else {
556 /* all parts received */
557 goto multi_t2_fnd;
558 }
559 } else {
560 if(!isLargeBuf) {
561 cERROR(1,("1st trans2 resp needs bigbuf"));
562 /* BB maybe we can fix this up, switch
563 to already allocated large buffer? */
564 } else {
565 /* Have first buffer */
566 mid_entry->resp_buf =
567 smb_buffer;
568 mid_entry->largeBuf = 1;
569 bigbuf = NULL;
570 }
571 }
572 break;
573 }
574 mid_entry->resp_buf = smb_buffer;
575 if(isLargeBuf)
576 mid_entry->largeBuf = 1;
577 else
578 mid_entry->largeBuf = 0;
579multi_t2_fnd:
580 task_to_wake = mid_entry->tsk;
581 mid_entry->midState = MID_RESPONSE_RECEIVED;
582 break;
583 }
584 }
585 spin_unlock(&GlobalMid_Lock);
586 if (task_to_wake) {
587 /* Was previous buf put in mpx struct for multi-rsp? */
588 if(!isMultiRsp) {
589 /* smb buffer will be freed by user thread */
590 if(isLargeBuf) {
591 bigbuf = NULL;
592 } else
593 smallbuf = NULL;
594 }
595 wake_up_process(task_to_wake);
596 } else if ((is_valid_oplock_break(smb_buffer) == FALSE)
597 && (isMultiRsp == FALSE)) {
598 cERROR(1, ("No task to wake, unknown frame rcvd!"));
599 cifs_dump_mem("Received Data is: ",temp,sizeof(struct smb_hdr));
600 }
601 } /* end while !EXITING */
602
391 spin_lock(&GlobalMid_Lock); 603 spin_lock(&GlobalMid_Lock);
392 server->tcpStatus = CifsExiting; 604 server->tcpStatus = CifsExiting;
393 server->tsk = NULL; 605 server->tsk = NULL;
394 atomic_set(&server->inFlight, 0); 606 /* check if we have blocked requests that need to free */
607 /* Note that cifs_max_pending is normally 50, but
608 can be set at module install time to as little as two */
609 if(atomic_read(&server->inFlight) >= cifs_max_pending)
610 atomic_set(&server->inFlight, cifs_max_pending - 1);
611 /* We do not want to set the max_pending too low or we
612 could end up with the counter going negative */
395 spin_unlock(&GlobalMid_Lock); 613 spin_unlock(&GlobalMid_Lock);
396 /* Although there should not be any requests blocked on 614 /* Although there should not be any requests blocked on
397 this queue it can not hurt to be paranoid and try to wake up requests 615 this queue it can not hurt to be paranoid and try to wake up requests
398 that may haven been blocked when more than 50 at time were on the wire 616 that may haven been blocked when more than 50 at time were on the wire
399 to the same server - they now will see the session is in exit state 617 to the same server - they now will see the session is in exit state
400 and get out of SendReceive. */ 618 and get out of SendReceive. */
401 wake_up_all(&server->request_q); 619 wake_up_all(&server->request_q);
402 /* give those requests time to exit */ 620 /* give those requests time to exit */
403 set_current_state(TASK_INTERRUPTIBLE); 621 msleep(125);
404 schedule_timeout(HZ/8); 622
405
406 if(server->ssocket) { 623 if(server->ssocket) {
407 sock_release(csocket); 624 sock_release(csocket);
408 server->ssocket = NULL; 625 server->ssocket = NULL;
409 } 626 }
410 if (smb_buffer) /* buffer usually freed in free_mid - need to free it on error or exit */ 627 /* buffer usuallly freed in free_mid - need to free it here on exit */
411 cifs_buf_release(smb_buffer); 628 if (bigbuf != NULL)
629 cifs_buf_release(bigbuf);
630 if (smallbuf != NULL)
631 cifs_small_buf_release(smallbuf);
412 632
413 read_lock(&GlobalSMBSeslock); 633 read_lock(&GlobalSMBSeslock);
414 if (list_empty(&server->pending_mid_q)) { 634 if (list_empty(&server->pending_mid_q)) {
415 /* loop through server session structures attached to this and mark them dead */ 635 /* loop through server session structures attached to this and
636 mark them dead */
416 list_for_each(tmp, &GlobalSMBSessionList) { 637 list_for_each(tmp, &GlobalSMBSessionList) {
417 ses = 638 ses =
418 list_entry(tmp, struct cifsSesInfo, 639 list_entry(tmp, struct cifsSesInfo,
@@ -424,12 +645,23 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
424 } 645 }
425 read_unlock(&GlobalSMBSeslock); 646 read_unlock(&GlobalSMBSeslock);
426 } else { 647 } else {
648 /* although we can not zero the server struct pointer yet,
649 since there are active requests which may depnd on them,
650 mark the corresponding SMB sessions as exiting too */
651 list_for_each(tmp, &GlobalSMBSessionList) {
652 ses = list_entry(tmp, struct cifsSesInfo,
653 cifsSessionList);
654 if (ses->server == server) {
655 ses->status = CifsExiting;
656 }
657 }
658
427 spin_lock(&GlobalMid_Lock); 659 spin_lock(&GlobalMid_Lock);
428 list_for_each(tmp, &server->pending_mid_q) { 660 list_for_each(tmp, &server->pending_mid_q) {
429 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 661 mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
430 if (mid_entry->midState == MID_REQUEST_SUBMITTED) { 662 if (mid_entry->midState == MID_REQUEST_SUBMITTED) {
431 cFYI(1, 663 cFYI(1,
432 (" Clearing Mid 0x%x - waking up ",mid_entry->mid)); 664 ("Clearing Mid 0x%x - waking up ",mid_entry->mid));
433 task_to_wake = mid_entry->tsk; 665 task_to_wake = mid_entry->tsk;
434 if(task_to_wake) { 666 if(task_to_wake) {
435 wake_up_process(task_to_wake); 667 wake_up_process(task_to_wake);
@@ -438,47 +670,51 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
438 } 670 }
439 spin_unlock(&GlobalMid_Lock); 671 spin_unlock(&GlobalMid_Lock);
440 read_unlock(&GlobalSMBSeslock); 672 read_unlock(&GlobalSMBSeslock);
441 set_current_state(TASK_INTERRUPTIBLE);
442 /* 1/8th of sec is more than enough time for them to exit */ 673 /* 1/8th of sec is more than enough time for them to exit */
443 schedule_timeout(HZ/8); 674 msleep(125);
444 } 675 }
445 676
446 if (list_empty(&server->pending_mid_q)) { 677 if (list_empty(&server->pending_mid_q)) {
447 /* mpx threads have not exited yet give them 678 /* mpx threads have not exited yet give them
448 at least the smb send timeout time for long ops */ 679 at least the smb send timeout time for long ops */
680 /* due to delays on oplock break requests, we need
681 to wait at least 45 seconds before giving up
682 on a request getting a response and going ahead
683 and killing cifsd */
449 cFYI(1, ("Wait for exit from demultiplex thread")); 684 cFYI(1, ("Wait for exit from demultiplex thread"));
450 set_current_state(TASK_INTERRUPTIBLE); 685 msleep(46000);
451 schedule_timeout(46 * HZ);
452 /* if threads still have not exited they are probably never 686 /* if threads still have not exited they are probably never
453 coming home not much else we can do but free the memory */ 687 coming home not much else we can do but free the memory */
454 } 688 }
455 kfree(server);
456 689
457 write_lock(&GlobalSMBSeslock); 690 write_lock(&GlobalSMBSeslock);
458 atomic_dec(&tcpSesAllocCount); 691 atomic_dec(&tcpSesAllocCount);
459 length = tcpSesAllocCount.counter; 692 length = tcpSesAllocCount.counter;
693
694 /* last chance to mark ses pointers invalid
695 if there are any pointing to this (e.g
696 if a crazy root user tried to kill cifsd
697 kernel thread explicitly this might happen) */
698 list_for_each(tmp, &GlobalSMBSessionList) {
699 ses = list_entry(tmp, struct cifsSesInfo,
700 cifsSessionList);
701 if (ses->server == server) {
702 ses->server = NULL;
703 }
704 }
460 write_unlock(&GlobalSMBSeslock); 705 write_unlock(&GlobalSMBSeslock);
706
707 kfree(server);
461 if(length > 0) { 708 if(length > 0) {
462 mempool_resize(cifs_req_poolp, 709 mempool_resize(cifs_req_poolp,
463 length + cifs_min_rcv, 710 length + cifs_min_rcv,
464 GFP_KERNEL); 711 GFP_KERNEL);
465 } 712 }
466 713
467 set_current_state(TASK_INTERRUPTIBLE); 714 msleep(250);
468 schedule_timeout(HZ/4);
469 return 0; 715 return 0;
470} 716}
471 717
472static void *
473cifs_kcalloc(size_t size, unsigned int __nocast type)
474{
475 void *addr;
476 addr = kmalloc(size, type);
477 if (addr)
478 memset(addr, 0, size);
479 return addr;
480}
481
482static int 718static int
483cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) 719cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
484{ 720{
@@ -495,7 +731,8 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
495 /* does not have to be a perfect mapping since the field is 731 /* does not have to be a perfect mapping since the field is
496 informational, only used for servers that do not support 732 informational, only used for servers that do not support
497 port 445 and it can be overridden at mount time */ 733 port 445 and it can be overridden at mount time */
498 vol->source_rfc1001_name[i] = toupper(system_utsname.nodename[i]); 734 vol->source_rfc1001_name[i] =
735 toupper(system_utsname.nodename[i]);
499 } 736 }
500 vol->source_rfc1001_name[15] = 0; 737 vol->source_rfc1001_name[15] = 0;
501 738
@@ -570,14 +807,17 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
570 /* NB: password legally can have multiple commas and 807 /* NB: password legally can have multiple commas and
571 the only illegal character in a password is null */ 808 the only illegal character in a password is null */
572 809
573 if ((value[temp_len] == 0) && (value[temp_len+1] == separator[0])) { 810 if ((value[temp_len] == 0) &&
811 (value[temp_len+1] == separator[0])) {
574 /* reinsert comma */ 812 /* reinsert comma */
575 value[temp_len] = separator[0]; 813 value[temp_len] = separator[0];
576 temp_len+=2; /* move after the second comma */ 814 temp_len+=2; /* move after the second comma */
577 while(value[temp_len] != 0) { 815 while(value[temp_len] != 0) {
578 if (value[temp_len] == separator[0]) { 816 if (value[temp_len] == separator[0]) {
579 if (value[temp_len+1] == separator[0]) { 817 if (value[temp_len+1] ==
580 temp_len++; /* skip second comma */ 818 separator[0]) {
819 /* skip second comma */
820 temp_len++;
581 } else { 821 } else {
582 /* single comma indicating start 822 /* single comma indicating start
583 of next parm */ 823 of next parm */
@@ -596,17 +836,26 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
596 /* go from value to value + temp_len condensing 836 /* go from value to value + temp_len condensing
597 double commas to singles. Note that this ends up 837 double commas to singles. Note that this ends up
598 allocating a few bytes too many, which is ok */ 838 allocating a few bytes too many, which is ok */
599 vol->password = cifs_kcalloc(temp_len, GFP_KERNEL); 839 vol->password = kcalloc(1, temp_len, GFP_KERNEL);
840 if(vol->password == NULL) {
841 printk("CIFS: no memory for pass\n");
842 return 1;
843 }
600 for(i=0,j=0;i<temp_len;i++,j++) { 844 for(i=0,j=0;i<temp_len;i++,j++) {
601 vol->password[j] = value[i]; 845 vol->password[j] = value[i];
602 if(value[i] == separator[0] && value[i+1] == separator[0]) { 846 if(value[i] == separator[0]
847 && value[i+1] == separator[0]) {
603 /* skip second comma */ 848 /* skip second comma */
604 i++; 849 i++;
605 } 850 }
606 } 851 }
607 vol->password[j] = 0; 852 vol->password[j] = 0;
608 } else { 853 } else {
609 vol->password = cifs_kcalloc(temp_len + 1, GFP_KERNEL); 854 vol->password = kcalloc(1, temp_len+1, GFP_KERNEL);
855 if(vol->password == NULL) {
856 printk("CIFS: no memory for pass\n");
857 return 1;
858 }
610 strcpy(vol->password, value); 859 strcpy(vol->password, value);
611 } 860 }
612 } else if (strnicmp(data, "ip", 2) == 0) { 861 } else if (strnicmp(data, "ip", 2) == 0) {
@@ -770,6 +1019,10 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
770 vol->noperm = 0; 1019 vol->noperm = 0;
771 } else if (strnicmp(data, "noperm", 6) == 0) { 1020 } else if (strnicmp(data, "noperm", 6) == 0) {
772 vol->noperm = 1; 1021 vol->noperm = 1;
1022 } else if (strnicmp(data, "mapchars", 8) == 0) {
1023 vol->remap = 1;
1024 } else if (strnicmp(data, "nomapchars", 10) == 0) {
1025 vol->remap = 0;
773 } else if (strnicmp(data, "setuids", 7) == 0) { 1026 } else if (strnicmp(data, "setuids", 7) == 0) {
774 vol->setuids = 1; 1027 vol->setuids = 1;
775 } else if (strnicmp(data, "nosetuids", 9) == 0) { 1028 } else if (strnicmp(data, "nosetuids", 9) == 0) {
@@ -918,14 +1171,15 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName)
918 1171
919int 1172int
920connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo, 1173connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
921 const char *old_path, const struct nls_table *nls_codepage) 1174 const char *old_path, const struct nls_table *nls_codepage,
1175 int remap)
922{ 1176{
923 unsigned char *referrals = NULL; 1177 unsigned char *referrals = NULL;
924 unsigned int num_referrals; 1178 unsigned int num_referrals;
925 int rc = 0; 1179 int rc = 0;
926 1180
927 rc = get_dfs_path(xid, pSesInfo,old_path, nls_codepage, 1181 rc = get_dfs_path(xid, pSesInfo,old_path, nls_codepage,
928 &num_referrals, &referrals); 1182 &num_referrals, &referrals, remap);
929 1183
930 /* BB Add in code to: if valid refrl, if not ip address contact 1184 /* BB Add in code to: if valid refrl, if not ip address contact
931 the helper that resolves tcp names, mount to it, try to 1185 the helper that resolves tcp names, mount to it, try to
@@ -940,7 +1194,8 @@ connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
940int 1194int
941get_dfs_path(int xid, struct cifsSesInfo *pSesInfo, 1195get_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
942 const char *old_path, const struct nls_table *nls_codepage, 1196 const char *old_path, const struct nls_table *nls_codepage,
943 unsigned int *pnum_referrals, unsigned char ** preferrals) 1197 unsigned int *pnum_referrals,
1198 unsigned char ** preferrals, int remap)
944{ 1199{
945 char *temp_unc; 1200 char *temp_unc;
946 int rc = 0; 1201 int rc = 0;
@@ -965,7 +1220,7 @@ get_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
965 } 1220 }
966 if (rc == 0) 1221 if (rc == 0)
967 rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals, 1222 rc = CIFSGetDFSRefer(xid, pSesInfo, old_path, preferrals,
968 pnum_referrals, nls_codepage); 1223 pnum_referrals, nls_codepage, remap);
969 1224
970 return rc; 1225 return rc;
971} 1226}
@@ -1062,7 +1317,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
1062 sessinit is sent but no second negprot */ 1317 sessinit is sent but no second negprot */
1063 struct rfc1002_session_packet * ses_init_buf; 1318 struct rfc1002_session_packet * ses_init_buf;
1064 struct smb_hdr * smb_buf; 1319 struct smb_hdr * smb_buf;
1065 ses_init_buf = cifs_kcalloc(sizeof(struct rfc1002_session_packet), GFP_KERNEL); 1320 ses_init_buf = kcalloc(1, sizeof(struct rfc1002_session_packet), GFP_KERNEL);
1066 if(ses_init_buf) { 1321 if(ses_init_buf) {
1067 ses_init_buf->trailer.session_req.called_len = 32; 1322 ses_init_buf->trailer.session_req.called_len = 32;
1068 rfc1002mangle(ses_init_buf->trailer.session_req.called_name, 1323 rfc1002mangle(ses_init_buf->trailer.session_req.called_name,
@@ -1352,6 +1607,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1352 } else 1607 } else
1353 rc = 0; 1608 rc = 0;
1354 memcpy(srvTcp->workstation_RFC1001_name, volume_info.source_rfc1001_name,16); 1609 memcpy(srvTcp->workstation_RFC1001_name, volume_info.source_rfc1001_name,16);
1610 srvTcp->sequence_number = 0;
1355 } 1611 }
1356 } 1612 }
1357 1613
@@ -1419,6 +1675,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1419 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; 1675 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
1420 if(volume_info.server_ino) 1676 if(volume_info.server_ino)
1421 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; 1677 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
1678 if(volume_info.remap)
1679 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
1422 if(volume_info.no_xattr) 1680 if(volume_info.no_xattr)
1423 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; 1681 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
1424 if(volume_info.direct_io) { 1682 if(volume_info.direct_io) {
@@ -1447,11 +1705,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1447 if ((strchr(volume_info.UNC + 3, '\\') == NULL) 1705 if ((strchr(volume_info.UNC + 3, '\\') == NULL)
1448 && (strchr(volume_info.UNC + 3, '/') == 1706 && (strchr(volume_info.UNC + 3, '/') ==
1449 NULL)) { 1707 NULL)) {
1450 rc = connect_to_dfs_path(xid, 1708 rc = connect_to_dfs_path(xid, pSesInfo,
1451 pSesInfo, 1709 "", cifs_sb->local_nls,
1452 "", 1710 cifs_sb->mnt_cifs_flags &
1453 cifs_sb-> 1711 CIFS_MOUNT_MAP_SPECIAL_CHR);
1454 local_nls);
1455 if(volume_info.UNC) 1712 if(volume_info.UNC)
1456 kfree(volume_info.UNC); 1713 kfree(volume_info.UNC);
1457 FreeXid(xid); 1714 FreeXid(xid);
@@ -1514,10 +1771,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1514 tcon->ses = pSesInfo; 1771 tcon->ses = pSesInfo;
1515 1772
1516 /* do not care if following two calls succeed - informational only */ 1773 /* do not care if following two calls succeed - informational only */
1517 CIFSSMBQFSDeviceInfo(xid, tcon, cifs_sb->local_nls); 1774 CIFSSMBQFSDeviceInfo(xid, tcon);
1518 CIFSSMBQFSAttributeInfo(xid, tcon, cifs_sb->local_nls); 1775 CIFSSMBQFSAttributeInfo(xid, tcon);
1519 if (tcon->ses->capabilities & CAP_UNIX) { 1776 if (tcon->ses->capabilities & CAP_UNIX) {
1520 if(!CIFSSMBQFSUnixInfo(xid, tcon, cifs_sb->local_nls)) { 1777 if(!CIFSSMBQFSUnixInfo(xid, tcon)) {
1521 if(!volume_info.no_psx_acl) { 1778 if(!volume_info.no_psx_acl) {
1522 if(CIFS_UNIX_POSIX_ACL_CAP & 1779 if(CIFS_UNIX_POSIX_ACL_CAP &
1523 le64_to_cpu(tcon->fsUnixInfo.Capability)) 1780 le64_to_cpu(tcon->fsUnixInfo.Capability))
@@ -1707,7 +1964,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1707/* We look for obvious messed up bcc or strings in response so we do not go off 1964/* We look for obvious messed up bcc or strings in response so we do not go off
1708 the end since (at least) WIN2K and Windows XP have a major bug in not null 1965 the end since (at least) WIN2K and Windows XP have a major bug in not null
1709 terminating last Unicode string in response */ 1966 terminating last Unicode string in response */
1710 ses->serverOS = cifs_kcalloc(2 * (len + 1), GFP_KERNEL); 1967 ses->serverOS = kcalloc(1, 2 * (len + 1), GFP_KERNEL);
1968 if(ses->serverOS == NULL)
1969 goto sesssetup_nomem;
1711 cifs_strfromUCS_le(ses->serverOS, 1970 cifs_strfromUCS_le(ses->serverOS,
1712 (wchar_t *)bcc_ptr, len,nls_codepage); 1971 (wchar_t *)bcc_ptr, len,nls_codepage);
1713 bcc_ptr += 2 * (len + 1); 1972 bcc_ptr += 2 * (len + 1);
@@ -1717,7 +1976,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1717 if (remaining_words > 0) { 1976 if (remaining_words > 0) {
1718 len = UniStrnlen((wchar_t *)bcc_ptr, 1977 len = UniStrnlen((wchar_t *)bcc_ptr,
1719 remaining_words-1); 1978 remaining_words-1);
1720 ses->serverNOS =cifs_kcalloc(2 * (len + 1),GFP_KERNEL); 1979 ses->serverNOS = kcalloc(1, 2 * (len + 1),GFP_KERNEL);
1980 if(ses->serverNOS == NULL)
1981 goto sesssetup_nomem;
1721 cifs_strfromUCS_le(ses->serverNOS, 1982 cifs_strfromUCS_le(ses->serverNOS,
1722 (wchar_t *)bcc_ptr,len,nls_codepage); 1983 (wchar_t *)bcc_ptr,len,nls_codepage);
1723 bcc_ptr += 2 * (len + 1); 1984 bcc_ptr += 2 * (len + 1);
@@ -1730,10 +1991,12 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1730 } 1991 }
1731 remaining_words -= len + 1; 1992 remaining_words -= len + 1;
1732 if (remaining_words > 0) { 1993 if (remaining_words > 0) {
1733 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 1994 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
1734 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 1995 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
1735 ses->serverDomain = 1996 ses->serverDomain =
1736 cifs_kcalloc(2*(len+1),GFP_KERNEL); 1997 kcalloc(1, 2*(len+1),GFP_KERNEL);
1998 if(ses->serverDomain == NULL)
1999 goto sesssetup_nomem;
1737 cifs_strfromUCS_le(ses->serverDomain, 2000 cifs_strfromUCS_le(ses->serverDomain,
1738 (wchar_t *)bcc_ptr,len,nls_codepage); 2001 (wchar_t *)bcc_ptr,len,nls_codepage);
1739 bcc_ptr += 2 * (len + 1); 2002 bcc_ptr += 2 * (len + 1);
@@ -1741,21 +2004,25 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1741 ses->serverDomain[1+(2*len)] = 0; 2004 ses->serverDomain[1+(2*len)] = 0;
1742 } /* else no more room so create dummy domain string */ 2005 } /* else no more room so create dummy domain string */
1743 else 2006 else
1744 ses->serverDomain = 2007 ses->serverDomain =
1745 cifs_kcalloc(2, 2008 kcalloc(1, 2, GFP_KERNEL);
1746 GFP_KERNEL);
1747 } else { /* no room so create dummy domain and NOS string */ 2009 } else { /* no room so create dummy domain and NOS string */
2010 /* if these kcallocs fail not much we
2011 can do, but better to not fail the
2012 sesssetup itself */
1748 ses->serverDomain = 2013 ses->serverDomain =
1749 cifs_kcalloc(2, GFP_KERNEL); 2014 kcalloc(1, 2, GFP_KERNEL);
1750 ses->serverNOS = 2015 ses->serverNOS =
1751 cifs_kcalloc(2, GFP_KERNEL); 2016 kcalloc(1, 2, GFP_KERNEL);
1752 } 2017 }
1753 } else { /* ASCII */ 2018 } else { /* ASCII */
1754 len = strnlen(bcc_ptr, 1024); 2019 len = strnlen(bcc_ptr, 1024);
1755 if (((long) bcc_ptr + len) - (long) 2020 if (((long) bcc_ptr + len) - (long)
1756 pByteArea(smb_buffer_response) 2021 pByteArea(smb_buffer_response)
1757 <= BCC(smb_buffer_response)) { 2022 <= BCC(smb_buffer_response)) {
1758 ses->serverOS = cifs_kcalloc(len + 1,GFP_KERNEL); 2023 ses->serverOS = kcalloc(1, len + 1,GFP_KERNEL);
2024 if(ses->serverOS == NULL)
2025 goto sesssetup_nomem;
1759 strncpy(ses->serverOS,bcc_ptr, len); 2026 strncpy(ses->serverOS,bcc_ptr, len);
1760 2027
1761 bcc_ptr += len; 2028 bcc_ptr += len;
@@ -1763,14 +2030,18 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1763 bcc_ptr++; 2030 bcc_ptr++;
1764 2031
1765 len = strnlen(bcc_ptr, 1024); 2032 len = strnlen(bcc_ptr, 1024);
1766 ses->serverNOS = cifs_kcalloc(len + 1,GFP_KERNEL); 2033 ses->serverNOS = kcalloc(1, len + 1,GFP_KERNEL);
2034 if(ses->serverNOS == NULL)
2035 goto sesssetup_nomem;
1767 strncpy(ses->serverNOS, bcc_ptr, len); 2036 strncpy(ses->serverNOS, bcc_ptr, len);
1768 bcc_ptr += len; 2037 bcc_ptr += len;
1769 bcc_ptr[0] = 0; 2038 bcc_ptr[0] = 0;
1770 bcc_ptr++; 2039 bcc_ptr++;
1771 2040
1772 len = strnlen(bcc_ptr, 1024); 2041 len = strnlen(bcc_ptr, 1024);
1773 ses->serverDomain = cifs_kcalloc(len + 1,GFP_KERNEL); 2042 ses->serverDomain = kcalloc(1, len + 1,GFP_KERNEL);
2043 if(ses->serverDomain == NULL)
2044 goto sesssetup_nomem;
1774 strncpy(ses->serverDomain, bcc_ptr, len); 2045 strncpy(ses->serverDomain, bcc_ptr, len);
1775 bcc_ptr += len; 2046 bcc_ptr += len;
1776 bcc_ptr[0] = 0; 2047 bcc_ptr[0] = 0;
@@ -1790,7 +2061,9 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1790 smb_buffer_response->WordCount)); 2061 smb_buffer_response->WordCount));
1791 rc = -EIO; 2062 rc = -EIO;
1792 } 2063 }
1793 2064sesssetup_nomem: /* do not return an error on nomem for the info strings,
2065 since that could make reconnection harder, and
2066 reconnection might be needed to free memory */
1794 if (smb_buffer) 2067 if (smb_buffer)
1795 cifs_buf_release(smb_buffer); 2068 cifs_buf_release(smb_buffer);
1796 2069
@@ -1967,7 +2240,7 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1967 the end since (at least) WIN2K and Windows XP have a major bug in not null 2240 the end since (at least) WIN2K and Windows XP have a major bug in not null
1968 terminating last Unicode string in response */ 2241 terminating last Unicode string in response */
1969 ses->serverOS = 2242 ses->serverOS =
1970 cifs_kcalloc(2 * (len + 1), GFP_KERNEL); 2243 kcalloc(1, 2 * (len + 1), GFP_KERNEL);
1971 cifs_strfromUCS_le(ses->serverOS, 2244 cifs_strfromUCS_le(ses->serverOS,
1972 (wchar_t *) 2245 (wchar_t *)
1973 bcc_ptr, len, 2246 bcc_ptr, len,
@@ -1981,7 +2254,7 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1981 remaining_words 2254 remaining_words
1982 - 1); 2255 - 1);
1983 ses->serverNOS = 2256 ses->serverNOS =
1984 cifs_kcalloc(2 * (len + 1), 2257 kcalloc(1, 2 * (len + 1),
1985 GFP_KERNEL); 2258 GFP_KERNEL);
1986 cifs_strfromUCS_le(ses->serverNOS, 2259 cifs_strfromUCS_le(ses->serverNOS,
1987 (wchar_t *)bcc_ptr, 2260 (wchar_t *)bcc_ptr,
@@ -1994,7 +2267,7 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
1994 if (remaining_words > 0) { 2267 if (remaining_words > 0) {
1995 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2268 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
1996 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2269 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
1997 ses->serverDomain = cifs_kcalloc(2*(len+1),GFP_KERNEL); 2270 ses->serverDomain = kcalloc(1, 2*(len+1),GFP_KERNEL);
1998 cifs_strfromUCS_le(ses->serverDomain, 2271 cifs_strfromUCS_le(ses->serverDomain,
1999 (wchar_t *)bcc_ptr, 2272 (wchar_t *)bcc_ptr,
2000 len, 2273 len,
@@ -2005,10 +2278,10 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2005 } /* else no more room so create dummy domain string */ 2278 } /* else no more room so create dummy domain string */
2006 else 2279 else
2007 ses->serverDomain = 2280 ses->serverDomain =
2008 cifs_kcalloc(2,GFP_KERNEL); 2281 kcalloc(1, 2,GFP_KERNEL);
2009 } else { /* no room so create dummy domain and NOS string */ 2282 } else { /* no room so create dummy domain and NOS string */
2010 ses->serverDomain = cifs_kcalloc(2, GFP_KERNEL); 2283 ses->serverDomain = kcalloc(1, 2, GFP_KERNEL);
2011 ses->serverNOS = cifs_kcalloc(2, GFP_KERNEL); 2284 ses->serverNOS = kcalloc(1, 2, GFP_KERNEL);
2012 } 2285 }
2013 } else { /* ASCII */ 2286 } else { /* ASCII */
2014 2287
@@ -2016,7 +2289,7 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2016 if (((long) bcc_ptr + len) - (long) 2289 if (((long) bcc_ptr + len) - (long)
2017 pByteArea(smb_buffer_response) 2290 pByteArea(smb_buffer_response)
2018 <= BCC(smb_buffer_response)) { 2291 <= BCC(smb_buffer_response)) {
2019 ses->serverOS = cifs_kcalloc(len + 1, GFP_KERNEL); 2292 ses->serverOS = kcalloc(1, len + 1, GFP_KERNEL);
2020 strncpy(ses->serverOS, bcc_ptr, len); 2293 strncpy(ses->serverOS, bcc_ptr, len);
2021 2294
2022 bcc_ptr += len; 2295 bcc_ptr += len;
@@ -2024,14 +2297,14 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2024 bcc_ptr++; 2297 bcc_ptr++;
2025 2298
2026 len = strnlen(bcc_ptr, 1024); 2299 len = strnlen(bcc_ptr, 1024);
2027 ses->serverNOS = cifs_kcalloc(len + 1,GFP_KERNEL); 2300 ses->serverNOS = kcalloc(1, len + 1,GFP_KERNEL);
2028 strncpy(ses->serverNOS, bcc_ptr, len); 2301 strncpy(ses->serverNOS, bcc_ptr, len);
2029 bcc_ptr += len; 2302 bcc_ptr += len;
2030 bcc_ptr[0] = 0; 2303 bcc_ptr[0] = 0;
2031 bcc_ptr++; 2304 bcc_ptr++;
2032 2305
2033 len = strnlen(bcc_ptr, 1024); 2306 len = strnlen(bcc_ptr, 1024);
2034 ses->serverDomain = cifs_kcalloc(len + 1, GFP_KERNEL); 2307 ses->serverDomain = kcalloc(1, len + 1, GFP_KERNEL);
2035 strncpy(ses->serverDomain, bcc_ptr, len); 2308 strncpy(ses->serverDomain, bcc_ptr, len);
2036 bcc_ptr += len; 2309 bcc_ptr += len;
2037 bcc_ptr[0] = 0; 2310 bcc_ptr[0] = 0;
@@ -2281,7 +2554,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2281 the end since (at least) WIN2K and Windows XP have a major bug in not null 2554 the end since (at least) WIN2K and Windows XP have a major bug in not null
2282 terminating last Unicode string in response */ 2555 terminating last Unicode string in response */
2283 ses->serverOS = 2556 ses->serverOS =
2284 cifs_kcalloc(2 * (len + 1), GFP_KERNEL); 2557 kcalloc(1, 2 * (len + 1), GFP_KERNEL);
2285 cifs_strfromUCS_le(ses->serverOS, 2558 cifs_strfromUCS_le(ses->serverOS,
2286 (wchar_t *) 2559 (wchar_t *)
2287 bcc_ptr, len, 2560 bcc_ptr, len,
@@ -2296,7 +2569,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2296 remaining_words 2569 remaining_words
2297 - 1); 2570 - 1);
2298 ses->serverNOS = 2571 ses->serverNOS =
2299 cifs_kcalloc(2 * (len + 1), 2572 kcalloc(1, 2 * (len + 1),
2300 GFP_KERNEL); 2573 GFP_KERNEL);
2301 cifs_strfromUCS_le(ses-> 2574 cifs_strfromUCS_le(ses->
2302 serverNOS, 2575 serverNOS,
@@ -2313,7 +2586,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2313 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2586 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2314 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ 2587 /* last string is not always null terminated (for e.g. for Windows XP & 2000) */
2315 ses->serverDomain = 2588 ses->serverDomain =
2316 cifs_kcalloc(2 * 2589 kcalloc(1, 2 *
2317 (len + 2590 (len +
2318 1), 2591 1),
2319 GFP_KERNEL); 2592 GFP_KERNEL);
@@ -2339,13 +2612,13 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2339 } /* else no more room so create dummy domain string */ 2612 } /* else no more room so create dummy domain string */
2340 else 2613 else
2341 ses->serverDomain = 2614 ses->serverDomain =
2342 cifs_kcalloc(2, 2615 kcalloc(1, 2,
2343 GFP_KERNEL); 2616 GFP_KERNEL);
2344 } else { /* no room so create dummy domain and NOS string */ 2617 } else { /* no room so create dummy domain and NOS string */
2345 ses->serverDomain = 2618 ses->serverDomain =
2346 cifs_kcalloc(2, GFP_KERNEL); 2619 kcalloc(1, 2, GFP_KERNEL);
2347 ses->serverNOS = 2620 ses->serverNOS =
2348 cifs_kcalloc(2, GFP_KERNEL); 2621 kcalloc(1, 2, GFP_KERNEL);
2349 } 2622 }
2350 } else { /* ASCII */ 2623 } else { /* ASCII */
2351 len = strnlen(bcc_ptr, 1024); 2624 len = strnlen(bcc_ptr, 1024);
@@ -2353,7 +2626,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2353 pByteArea(smb_buffer_response) 2626 pByteArea(smb_buffer_response)
2354 <= BCC(smb_buffer_response)) { 2627 <= BCC(smb_buffer_response)) {
2355 ses->serverOS = 2628 ses->serverOS =
2356 cifs_kcalloc(len + 1, 2629 kcalloc(1, len + 1,
2357 GFP_KERNEL); 2630 GFP_KERNEL);
2358 strncpy(ses->serverOS, 2631 strncpy(ses->serverOS,
2359 bcc_ptr, len); 2632 bcc_ptr, len);
@@ -2364,7 +2637,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2364 2637
2365 len = strnlen(bcc_ptr, 1024); 2638 len = strnlen(bcc_ptr, 1024);
2366 ses->serverNOS = 2639 ses->serverNOS =
2367 cifs_kcalloc(len + 1, 2640 kcalloc(1, len + 1,
2368 GFP_KERNEL); 2641 GFP_KERNEL);
2369 strncpy(ses->serverNOS, bcc_ptr, len); 2642 strncpy(ses->serverNOS, bcc_ptr, len);
2370 bcc_ptr += len; 2643 bcc_ptr += len;
@@ -2373,7 +2646,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2373 2646
2374 len = strnlen(bcc_ptr, 1024); 2647 len = strnlen(bcc_ptr, 1024);
2375 ses->serverDomain = 2648 ses->serverDomain =
2376 cifs_kcalloc(len + 1, 2649 kcalloc(1, len + 1,
2377 GFP_KERNEL); 2650 GFP_KERNEL);
2378 strncpy(ses->serverDomain, bcc_ptr, len); 2651 strncpy(ses->serverDomain, bcc_ptr, len);
2379 bcc_ptr += len; 2652 bcc_ptr += len;
@@ -2675,7 +2948,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2675 the end since (at least) WIN2K and Windows XP have a major bug in not null 2948 the end since (at least) WIN2K and Windows XP have a major bug in not null
2676 terminating last Unicode string in response */ 2949 terminating last Unicode string in response */
2677 ses->serverOS = 2950 ses->serverOS =
2678 cifs_kcalloc(2 * (len + 1), GFP_KERNEL); 2951 kcalloc(1, 2 * (len + 1), GFP_KERNEL);
2679 cifs_strfromUCS_le(ses->serverOS, 2952 cifs_strfromUCS_le(ses->serverOS,
2680 (wchar_t *) 2953 (wchar_t *)
2681 bcc_ptr, len, 2954 bcc_ptr, len,
@@ -2690,7 +2963,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2690 remaining_words 2963 remaining_words
2691 - 1); 2964 - 1);
2692 ses->serverNOS = 2965 ses->serverNOS =
2693 cifs_kcalloc(2 * (len + 1), 2966 kcalloc(1, 2 * (len + 1),
2694 GFP_KERNEL); 2967 GFP_KERNEL);
2695 cifs_strfromUCS_le(ses-> 2968 cifs_strfromUCS_le(ses->
2696 serverNOS, 2969 serverNOS,
@@ -2706,7 +2979,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2706 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); 2979 len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
2707 /* last string not always null terminated (e.g. for Windows XP & 2000) */ 2980 /* last string not always null terminated (e.g. for Windows XP & 2000) */
2708 ses->serverDomain = 2981 ses->serverDomain =
2709 cifs_kcalloc(2 * 2982 kcalloc(1, 2 *
2710 (len + 2983 (len +
2711 1), 2984 1),
2712 GFP_KERNEL); 2985 GFP_KERNEL);
@@ -2731,17 +3004,17 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2731 = 0; 3004 = 0;
2732 } /* else no more room so create dummy domain string */ 3005 } /* else no more room so create dummy domain string */
2733 else 3006 else
2734 ses->serverDomain = cifs_kcalloc(2,GFP_KERNEL); 3007 ses->serverDomain = kcalloc(1, 2,GFP_KERNEL);
2735 } else { /* no room so create dummy domain and NOS string */ 3008 } else { /* no room so create dummy domain and NOS string */
2736 ses->serverDomain = cifs_kcalloc(2, GFP_KERNEL); 3009 ses->serverDomain = kcalloc(1, 2, GFP_KERNEL);
2737 ses->serverNOS = cifs_kcalloc(2, GFP_KERNEL); 3010 ses->serverNOS = kcalloc(1, 2, GFP_KERNEL);
2738 } 3011 }
2739 } else { /* ASCII */ 3012 } else { /* ASCII */
2740 len = strnlen(bcc_ptr, 1024); 3013 len = strnlen(bcc_ptr, 1024);
2741 if (((long) bcc_ptr + len) - 3014 if (((long) bcc_ptr + len) -
2742 (long) pByteArea(smb_buffer_response) 3015 (long) pByteArea(smb_buffer_response)
2743 <= BCC(smb_buffer_response)) { 3016 <= BCC(smb_buffer_response)) {
2744 ses->serverOS = cifs_kcalloc(len + 1,GFP_KERNEL); 3017 ses->serverOS = kcalloc(1, len + 1,GFP_KERNEL);
2745 strncpy(ses->serverOS,bcc_ptr, len); 3018 strncpy(ses->serverOS,bcc_ptr, len);
2746 3019
2747 bcc_ptr += len; 3020 bcc_ptr += len;
@@ -2749,14 +3022,14 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2749 bcc_ptr++; 3022 bcc_ptr++;
2750 3023
2751 len = strnlen(bcc_ptr, 1024); 3024 len = strnlen(bcc_ptr, 1024);
2752 ses->serverNOS = cifs_kcalloc(len+1,GFP_KERNEL); 3025 ses->serverNOS = kcalloc(1, len+1,GFP_KERNEL);
2753 strncpy(ses->serverNOS, bcc_ptr, len); 3026 strncpy(ses->serverNOS, bcc_ptr, len);
2754 bcc_ptr += len; 3027 bcc_ptr += len;
2755 bcc_ptr[0] = 0; 3028 bcc_ptr[0] = 0;
2756 bcc_ptr++; 3029 bcc_ptr++;
2757 3030
2758 len = strnlen(bcc_ptr, 1024); 3031 len = strnlen(bcc_ptr, 1024);
2759 ses->serverDomain = cifs_kcalloc(len+1,GFP_KERNEL); 3032 ses->serverDomain = kcalloc(1, len+1,GFP_KERNEL);
2760 strncpy(ses->serverDomain, bcc_ptr, len); 3033 strncpy(ses->serverDomain, bcc_ptr, len);
2761 bcc_ptr += len; 3034 bcc_ptr += len;
2762 bcc_ptr[0] = 0; 3035 bcc_ptr[0] = 0;
@@ -2868,7 +3141,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
2868 if(tcon->nativeFileSystem) 3141 if(tcon->nativeFileSystem)
2869 kfree(tcon->nativeFileSystem); 3142 kfree(tcon->nativeFileSystem);
2870 tcon->nativeFileSystem = 3143 tcon->nativeFileSystem =
2871 cifs_kcalloc(length + 2, GFP_KERNEL); 3144 kcalloc(1, length + 2, GFP_KERNEL);
2872 cifs_strfromUCS_le(tcon->nativeFileSystem, 3145 cifs_strfromUCS_le(tcon->nativeFileSystem,
2873 (wchar_t *) bcc_ptr, 3146 (wchar_t *) bcc_ptr,
2874 length, nls_codepage); 3147 length, nls_codepage);
@@ -2886,7 +3159,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
2886 if(tcon->nativeFileSystem) 3159 if(tcon->nativeFileSystem)
2887 kfree(tcon->nativeFileSystem); 3160 kfree(tcon->nativeFileSystem);
2888 tcon->nativeFileSystem = 3161 tcon->nativeFileSystem =
2889 cifs_kcalloc(length + 1, GFP_KERNEL); 3162 kcalloc(1, length + 1, GFP_KERNEL);
2890 strncpy(tcon->nativeFileSystem, bcc_ptr, 3163 strncpy(tcon->nativeFileSystem, bcc_ptr,
2891 length); 3164 length);
2892 } 3165 }
@@ -2959,6 +3232,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
2959 int rc = 0; 3232 int rc = 0;
2960 char ntlm_session_key[CIFS_SESSION_KEY_SIZE]; 3233 char ntlm_session_key[CIFS_SESSION_KEY_SIZE];
2961 int ntlmv2_flag = FALSE; 3234 int ntlmv2_flag = FALSE;
3235 int first_time = 0;
2962 3236
2963 /* what if server changes its buffer size after dropping the session? */ 3237 /* what if server changes its buffer size after dropping the session? */
2964 if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ { 3238 if(pSesInfo->server->maxBuf == 0) /* no need to send on reconnect */ {
@@ -2977,12 +3251,13 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
2977 spin_unlock(&GlobalMid_Lock); 3251 spin_unlock(&GlobalMid_Lock);
2978 3252
2979 } 3253 }
3254 first_time = 1;
2980 } 3255 }
2981 if (!rc) { 3256 if (!rc) {
2982 pSesInfo->capabilities = pSesInfo->server->capabilities; 3257 pSesInfo->capabilities = pSesInfo->server->capabilities;
2983 if(linuxExtEnabled == 0) 3258 if(linuxExtEnabled == 0)
2984 pSesInfo->capabilities &= (~CAP_UNIX); 3259 pSesInfo->capabilities &= (~CAP_UNIX);
2985 pSesInfo->sequence_number = 0; 3260 /* pSesInfo->sequence_number = 0;*/
2986 cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x Time Zone: %d", 3261 cFYI(1,("Security Mode: 0x%x Capabilities: 0x%x Time Zone: %d",
2987 pSesInfo->server->secMode, 3262 pSesInfo->server->secMode,
2988 pSesInfo->server->capabilities, 3263 pSesInfo->server->capabilities,
@@ -3015,7 +3290,10 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3015 v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL); 3290 v2_response = kmalloc(16 + 64 /* blob */, GFP_KERNEL);
3016 if(v2_response) { 3291 if(v2_response) {
3017 CalcNTLMv2_response(pSesInfo,v2_response); 3292 CalcNTLMv2_response(pSesInfo,v2_response);
3018/* cifs_calculate_ntlmv2_mac_key(pSesInfo->mac_signing_key, response, ntlm_session_key, */ 3293 /* if(first_time)
3294 cifs_calculate_ntlmv2_mac_key(
3295 pSesInfo->server->mac_signing_key,
3296 response, ntlm_session_key, */
3019 kfree(v2_response); 3297 kfree(v2_response);
3020 /* BB Put dummy sig in SessSetup PDU? */ 3298 /* BB Put dummy sig in SessSetup PDU? */
3021 } else { 3299 } else {
@@ -3028,9 +3306,11 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3028 pSesInfo->server->cryptKey, 3306 pSesInfo->server->cryptKey,
3029 ntlm_session_key); 3307 ntlm_session_key);
3030 3308
3031 cifs_calculate_mac_key(pSesInfo->mac_signing_key, 3309 if(first_time)
3032 ntlm_session_key, 3310 cifs_calculate_mac_key(
3033 pSesInfo->password); 3311 pSesInfo->server->mac_signing_key,
3312 ntlm_session_key,
3313 pSesInfo->password);
3034 } 3314 }
3035 /* for better security the weaker lanman hash not sent 3315 /* for better security the weaker lanman hash not sent
3036 in AuthSessSetup so we no longer calculate it */ 3316 in AuthSessSetup so we no longer calculate it */
@@ -3046,8 +3326,11 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3046 pSesInfo->server->cryptKey, 3326 pSesInfo->server->cryptKey,
3047 ntlm_session_key); 3327 ntlm_session_key);
3048 3328
3049 cifs_calculate_mac_key(pSesInfo->mac_signing_key, 3329 if(first_time)
3050 ntlm_session_key, pSesInfo->password); 3330 cifs_calculate_mac_key(
3331 pSesInfo->server->mac_signing_key,
3332 ntlm_session_key, pSesInfo->password);
3333
3051 rc = CIFSSessSetup(xid, pSesInfo, 3334 rc = CIFSSessSetup(xid, pSesInfo,
3052 ntlm_session_key, nls_info); 3335 ntlm_session_key, nls_info);
3053 } 3336 }
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f54e1866f0f4..e3137aa48cdd 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -101,68 +101,15 @@ cifs_bp_rename_retry:
101 return full_path; 101 return full_path;
102} 102}
103 103
104/* Note: caller must free return buffer */ 104/* char * build_wildcard_path_from_dentry(struct dentry *direntry)
105char *
106build_wildcard_path_from_dentry(struct dentry *direntry)
107{ 105{
108 struct dentry *temp;
109 int namelen = 0;
110 char *full_path;
111
112 if(direntry == NULL)
113 return NULL; /* not much we can do if dentry is freed and
114 we need to reopen the file after it was closed implicitly
115 when the server crashed */
116
117cifs_bwp_rename_retry:
118 for (temp = direntry; !IS_ROOT(temp);) {
119 namelen += (1 + temp->d_name.len);
120 temp = temp->d_parent;
121 if(temp == NULL) {
122 cERROR(1,("corrupt dentry"));
123 return NULL;
124 }
125 }
126
127 full_path = kmalloc(namelen+3, GFP_KERNEL);
128 if(full_path == NULL) 106 if(full_path == NULL)
129 return full_path; 107 return full_path;
130 108
131 full_path[namelen] = '\\'; 109 full_path[namelen] = '\\';
132 full_path[namelen+1] = '*'; 110 full_path[namelen+1] = '*';
133 full_path[namelen+2] = 0; /* trailing null */ 111 full_path[namelen+2] = 0;
134 112BB remove above eight lines BB */
135 for (temp = direntry; !IS_ROOT(temp);) {
136 namelen -= 1 + temp->d_name.len;
137 if (namelen < 0) {
138 break;
139 } else {
140 full_path[namelen] = '\\';
141 strncpy(full_path + namelen + 1, temp->d_name.name,
142 temp->d_name.len);
143 cFYI(0, (" name: %s ", full_path + namelen));
144 }
145 temp = temp->d_parent;
146 if(temp == NULL) {
147 cERROR(1,("corrupt dentry"));
148 kfree(full_path);
149 return NULL;
150 }
151 }
152 if (namelen != 0) {
153 cERROR(1,
154 ("We did not end path lookup where we expected namelen is %d",
155 namelen));
156 /* presumably this is only possible if we were racing with a rename
157 of one of the parent directories (we can not lock the dentries
158 above us to prevent this, but retrying should be harmless) */
159 kfree(full_path);
160 namelen = 0;
161 goto cifs_bwp_rename_retry;
162 }
163
164 return full_path;
165}
166 113
167/* Inode operations in similar order to how they appear in the Linux file fs.h */ 114/* Inode operations in similar order to how they appear in the Linux file fs.h */
168 115
@@ -235,7 +182,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
235 182
236 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 183 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
237 desiredAccess, CREATE_NOT_DIR, 184 desiredAccess, CREATE_NOT_DIR,
238 &fileHandle, &oplock, buf, cifs_sb->local_nls); 185 &fileHandle, &oplock, buf, cifs_sb->local_nls,
186 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
239 if (rc) { 187 if (rc) {
240 cFYI(1, ("cifs_create returned 0x%x ", rc)); 188 cFYI(1, ("cifs_create returned 0x%x ", rc));
241 } else { 189 } else {
@@ -248,13 +196,17 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
248 (__u64)current->euid, 196 (__u64)current->euid,
249 (__u64)current->egid, 197 (__u64)current->egid,
250 0 /* dev */, 198 0 /* dev */,
251 cifs_sb->local_nls); 199 cifs_sb->local_nls,
200 cifs_sb->mnt_cifs_flags &
201 CIFS_MOUNT_MAP_SPECIAL_CHR);
252 } else { 202 } else {
253 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 203 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
254 (__u64)-1, 204 (__u64)-1,
255 (__u64)-1, 205 (__u64)-1,
256 0 /* dev */, 206 0 /* dev */,
257 cifs_sb->local_nls); 207 cifs_sb->local_nls,
208 cifs_sb->mnt_cifs_flags &
209 CIFS_MOUNT_MAP_SPECIAL_CHR);
258 } 210 }
259 else { 211 else {
260 /* BB implement via Windows security descriptors */ 212 /* BB implement via Windows security descriptors */
@@ -284,51 +236,48 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
284 /* mknod case - do not leave file open */ 236 /* mknod case - do not leave file open */
285 CIFSSMBClose(xid, pTcon, fileHandle); 237 CIFSSMBClose(xid, pTcon, fileHandle);
286 } else if(newinode) { 238 } else if(newinode) {
287 pCifsFile = (struct cifsFileInfo *) 239 pCifsFile =
288 kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL); 240 kmalloc(sizeof (struct cifsFileInfo), GFP_KERNEL);
289 241
290 if (pCifsFile) { 242 if(pCifsFile == NULL)
291 memset((char *)pCifsFile, 0, 243 goto cifs_create_out;
292 sizeof (struct cifsFileInfo)); 244 memset((char *)pCifsFile, 0,
293 pCifsFile->netfid = fileHandle; 245 sizeof (struct cifsFileInfo));
294 pCifsFile->pid = current->tgid; 246 pCifsFile->netfid = fileHandle;
295 pCifsFile->pInode = newinode; 247 pCifsFile->pid = current->tgid;
296 pCifsFile->invalidHandle = FALSE; 248 pCifsFile->pInode = newinode;
297 pCifsFile->closePend = FALSE; 249 pCifsFile->invalidHandle = FALSE;
298 init_MUTEX(&pCifsFile->fh_sem); 250 pCifsFile->closePend = FALSE;
299 /* put the following in at open now */ 251 init_MUTEX(&pCifsFile->fh_sem);
300 /* pCifsFile->pfile = file; */ 252 /* set the following in open now
301 write_lock(&GlobalSMBSeslock); 253 pCifsFile->pfile = file; */
302 list_add(&pCifsFile->tlist,&pTcon->openFileList); 254 write_lock(&GlobalSMBSeslock);
303 pCifsInode = CIFS_I(newinode); 255 list_add(&pCifsFile->tlist,&pTcon->openFileList);
304 if(pCifsInode) { 256 pCifsInode = CIFS_I(newinode);
257 if(pCifsInode) {
305 /* if readable file instance put first in list*/ 258 /* if readable file instance put first in list*/
306 if (write_only == TRUE) { 259 if (write_only == TRUE) {
307 list_add_tail(&pCifsFile->flist, 260 list_add_tail(&pCifsFile->flist,
308 &pCifsInode->openFileList); 261 &pCifsInode->openFileList);
309 } else { 262 } else {
310 list_add(&pCifsFile->flist, 263 list_add(&pCifsFile->flist,
311 &pCifsInode->openFileList); 264 &pCifsInode->openFileList);
312 }
313 if((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
314 pCifsInode->clientCanCacheAll = TRUE;
315 pCifsInode->clientCanCacheRead = TRUE;
316 cFYI(1,("Exclusive Oplock granted on inode %p",
317 newinode));
318 } else if((oplock & 0xF) == OPLOCK_READ)
319 pCifsInode->clientCanCacheRead = TRUE;
320 } 265 }
321 write_unlock(&GlobalSMBSeslock); 266 if((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
267 pCifsInode->clientCanCacheAll = TRUE;
268 pCifsInode->clientCanCacheRead = TRUE;
269 cFYI(1,("Exclusive Oplock for inode %p",
270 newinode));
271 } else if((oplock & 0xF) == OPLOCK_READ)
272 pCifsInode->clientCanCacheRead = TRUE;
322 } 273 }
274 write_unlock(&GlobalSMBSeslock);
323 } 275 }
324 } 276 }
325 277cifs_create_out:
326 if (buf) 278 kfree(buf);
327 kfree(buf); 279 kfree(full_path);
328 if (full_path)
329 kfree(full_path);
330 FreeXid(xid); 280 FreeXid(xid);
331
332 return rc; 281 return rc;
333} 282}
334 283
@@ -359,11 +308,15 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t dev
359 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 308 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
360 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, 309 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
361 mode,(__u64)current->euid,(__u64)current->egid, 310 mode,(__u64)current->euid,(__u64)current->egid,
362 device_number, cifs_sb->local_nls); 311 device_number, cifs_sb->local_nls,
312 cifs_sb->mnt_cifs_flags &
313 CIFS_MOUNT_MAP_SPECIAL_CHR);
363 } else { 314 } else {
364 rc = CIFSSMBUnixSetPerms(xid, pTcon, 315 rc = CIFSSMBUnixSetPerms(xid, pTcon,
365 full_path, mode, (__u64)-1, (__u64)-1, 316 full_path, mode, (__u64)-1, (__u64)-1,
366 device_number, cifs_sb->local_nls); 317 device_number, cifs_sb->local_nls,
318 cifs_sb->mnt_cifs_flags &
319 CIFS_MOUNT_MAP_SPECIAL_CHR);
367 } 320 }
368 321
369 if(!rc) { 322 if(!rc) {
@@ -375,10 +328,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, dev_t dev
375 } 328 }
376 } 329 }
377 330
378 if (full_path) 331 kfree(full_path);
379 kfree(full_path);
380 FreeXid(xid); 332 FreeXid(xid);
381
382 return rc; 333 return rc;
383} 334}
384 335
@@ -447,43 +398,11 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name
447 if file exists or not but no access BB */ 398 if file exists or not but no access BB */
448 } 399 }
449 400
450 if (full_path) 401 kfree(full_path);
451 kfree(full_path);
452 FreeXid(xid); 402 FreeXid(xid);
453 return ERR_PTR(rc); 403 return ERR_PTR(rc);
454} 404}
455 405
456int
457cifs_dir_open(struct inode *inode, struct file *file)
458{ /* NB: currently unused since searches are opened in readdir */
459 int rc = 0;
460 int xid;
461 struct cifs_sb_info *cifs_sb;
462 struct cifsTconInfo *pTcon;
463 char *full_path = NULL;
464
465 xid = GetXid();
466
467 cifs_sb = CIFS_SB(inode->i_sb);
468 pTcon = cifs_sb->tcon;
469
470 if(file->f_dentry) {
471 down(&file->f_dentry->d_sb->s_vfs_rename_sem);
472 full_path = build_wildcard_path_from_dentry(file->f_dentry);
473 up(&file->f_dentry->d_sb->s_vfs_rename_sem);
474 } else {
475 FreeXid(xid);
476 return -EIO;
477 }
478
479 cFYI(1, ("inode = 0x%p and full path is %s", inode, full_path));
480
481 if (full_path)
482 kfree(full_path);
483 FreeXid(xid);
484 return rc;
485}
486
487static int 406static int
488cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd) 407cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
489{ 408{
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index 9d24c40f1967..7d2a9202c39a 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -92,7 +92,8 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
92 cERROR(1,("cifs dir notify on file %s with arg 0x%lx",full_path,arg)); /* BB removeme BB */ 92 cERROR(1,("cifs dir notify on file %s with arg 0x%lx",full_path,arg)); /* BB removeme BB */
93 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 93 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
94 GENERIC_READ | SYNCHRONIZE, 0 /* create options */, 94 GENERIC_READ | SYNCHRONIZE, 0 /* create options */,
95 &netfid, &oplock,NULL, cifs_sb->local_nls); 95 &netfid, &oplock,NULL, cifs_sb->local_nls,
96 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
96 /* BB fixme - add this handle to a notify handle list */ 97 /* BB fixme - add this handle to a notify handle list */
97 if(rc) { 98 if(rc) {
98 cERROR(1,("Could not open directory for notify")); /* BB remove BB */ 99 cERROR(1,("Could not open directory for notify")); /* BB remove BB */
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index dcab7cf1b53b..dde2d251fc3d 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -254,7 +254,8 @@ int cifs_open(struct inode *inode, struct file *file)
254 } 254 }
255 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, 255 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
256 CREATE_NOT_DIR, &netfid, &oplock, buf, 256 CREATE_NOT_DIR, &netfid, &oplock, buf,
257 cifs_sb->local_nls); 257 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
258 & CIFS_MOUNT_MAP_SPECIAL_CHR);
258 if (rc) { 259 if (rc) {
259 cFYI(1, ("cifs_open returned 0x%x ", rc)); 260 cFYI(1, ("cifs_open returned 0x%x ", rc));
260 goto out; 261 goto out;
@@ -287,7 +288,9 @@ int cifs_open(struct inode *inode, struct file *file)
287 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 288 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
288 inode->i_mode, 289 inode->i_mode,
289 (__u64)-1, (__u64)-1, 0 /* dev */, 290 (__u64)-1, (__u64)-1, 0 /* dev */,
290 cifs_sb->local_nls); 291 cifs_sb->local_nls,
292 cifs_sb->mnt_cifs_flags &
293 CIFS_MOUNT_MAP_SPECIAL_CHR);
291 } else { 294 } else {
292 /* BB implement via Windows security descriptors eg 295 /* BB implement via Windows security descriptors eg
293 CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 296 CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
@@ -387,7 +390,8 @@ static int cifs_reopen_file(struct inode *inode, struct file *file,
387 } */ 390 } */
388 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, 391 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess,
389 CREATE_NOT_DIR, &netfid, &oplock, NULL, 392 CREATE_NOT_DIR, &netfid, &oplock, NULL,
390 cifs_sb->local_nls); 393 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
394 CIFS_MOUNT_MAP_SPECIAL_CHR);
391 if (rc) { 395 if (rc) {
392 up(&pCifsFile->fh_sem); 396 up(&pCifsFile->fh_sem);
393 cFYI(1, ("cifs_open returned 0x%x ", rc)); 397 cFYI(1, ("cifs_open returned 0x%x ", rc));
@@ -465,8 +469,10 @@ int cifs_close(struct inode *inode, struct file *file)
465 write_lock(&file->f_owner.lock); 469 write_lock(&file->f_owner.lock);
466 } 470 }
467 } 471 }
472 write_lock(&GlobalSMBSeslock);
468 list_del(&pSMBFile->flist); 473 list_del(&pSMBFile->flist);
469 list_del(&pSMBFile->tlist); 474 list_del(&pSMBFile->tlist);
475 write_unlock(&GlobalSMBSeslock);
470 write_unlock(&file->f_owner.lock); 476 write_unlock(&file->f_owner.lock);
471 kfree(pSMBFile->search_resume_name); 477 kfree(pSMBFile->search_resume_name);
472 kfree(file->private_data); 478 kfree(file->private_data);
@@ -506,7 +512,8 @@ int cifs_closedir(struct inode *inode, struct file *file)
506 pTcon = cifs_sb->tcon; 512 pTcon = cifs_sb->tcon;
507 513
508 cFYI(1, ("Freeing private data in close dir")); 514 cFYI(1, ("Freeing private data in close dir"));
509 if (pCFileStruct->srch_inf.endOfSearch == FALSE) { 515 if ((pCFileStruct->srch_inf.endOfSearch == FALSE) &&
516 (pCFileStruct->invalidHandle == FALSE)) {
510 pCFileStruct->invalidHandle = TRUE; 517 pCFileStruct->invalidHandle = TRUE;
511 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 518 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
512 cFYI(1, ("Closing uncompleted readdir with rc %d", 519 cFYI(1, ("Closing uncompleted readdir with rc %d",
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index d73b0aa86775..670947288262 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -44,7 +44,8 @@ int cifs_get_inode_info_unix(struct inode **pinode,
44 cFYI(1, (" Getting info on %s ", search_path)); 44 cFYI(1, (" Getting info on %s ", search_path));
45 /* could have done a find first instead but this returns more info */ 45 /* could have done a find first instead but this returns more info */
46 rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData, 46 rc = CIFSSMBUnixQPathInfo(xid, pTcon, search_path, &findData,
47 cifs_sb->local_nls); 47 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
48 CIFS_MOUNT_MAP_SPECIAL_CHR);
48/* dump_mem("\nUnixQPathInfo return data", &findData, 49/* dump_mem("\nUnixQPathInfo return data", &findData,
49 sizeof(findData)); */ 50 sizeof(findData)); */
50 if (rc) { 51 if (rc) {
@@ -63,7 +64,9 @@ int cifs_get_inode_info_unix(struct inode **pinode,
63 strncat(tmp_path, search_path, MAX_PATHCONF); 64 strncat(tmp_path, search_path, MAX_PATHCONF);
64 rc = connect_to_dfs_path(xid, pTcon->ses, 65 rc = connect_to_dfs_path(xid, pTcon->ses,
65 /* treename + */ tmp_path, 66 /* treename + */ tmp_path,
66 cifs_sb->local_nls); 67 cifs_sb->local_nls,
68 cifs_sb->mnt_cifs_flags &
69 CIFS_MOUNT_MAP_SPECIAL_CHR);
67 kfree(tmp_path); 70 kfree(tmp_path);
68 71
69 /* BB fix up inode etc. */ 72 /* BB fix up inode etc. */
@@ -210,7 +213,8 @@ int cifs_get_inode_info(struct inode **pinode,
210 pfindData = (FILE_ALL_INFO *)buf; 213 pfindData = (FILE_ALL_INFO *)buf;
211 /* could do find first instead but this returns more info */ 214 /* could do find first instead but this returns more info */
212 rc = CIFSSMBQPathInfo(xid, pTcon, search_path, pfindData, 215 rc = CIFSSMBQPathInfo(xid, pTcon, search_path, pfindData,
213 cifs_sb->local_nls); 216 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
217 CIFS_MOUNT_MAP_SPECIAL_CHR);
214 } 218 }
215 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ 219 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */
216 if (rc) { 220 if (rc) {
@@ -230,7 +234,9 @@ int cifs_get_inode_info(struct inode **pinode,
230 strncat(tmp_path, search_path, MAX_PATHCONF); 234 strncat(tmp_path, search_path, MAX_PATHCONF);
231 rc = connect_to_dfs_path(xid, pTcon->ses, 235 rc = connect_to_dfs_path(xid, pTcon->ses,
232 /* treename + */ tmp_path, 236 /* treename + */ tmp_path,
233 cifs_sb->local_nls); 237 cifs_sb->local_nls,
238 cifs_sb->mnt_cifs_flags &
239 CIFS_MOUNT_MAP_SPECIAL_CHR);
234 kfree(tmp_path); 240 kfree(tmp_path);
235 /* BB fix up inode etc. */ 241 /* BB fix up inode etc. */
236 } else if (rc) { 242 } else if (rc) {
@@ -268,7 +274,9 @@ int cifs_get_inode_info(struct inode **pinode,
268 274
269 rc1 = CIFSGetSrvInodeNumber(xid, pTcon, 275 rc1 = CIFSGetSrvInodeNumber(xid, pTcon,
270 search_path, &inode_num, 276 search_path, &inode_num,
271 cifs_sb->local_nls); 277 cifs_sb->local_nls,
278 cifs_sb->mnt_cifs_flags &
279 CIFS_MOUNT_MAP_SPECIAL_CHR);
272 if(rc1) { 280 if(rc1) {
273 cFYI(1,("GetSrvInodeNum rc %d", rc1)); 281 cFYI(1,("GetSrvInodeNum rc %d", rc1));
274 /* BB EOPNOSUPP disable SERVER_INUM? */ 282 /* BB EOPNOSUPP disable SERVER_INUM? */
@@ -410,7 +418,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
410 FreeXid(xid); 418 FreeXid(xid);
411 return -ENOMEM; 419 return -ENOMEM;
412 } 420 }
413 rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls); 421 rc = CIFSSMBDelFile(xid, pTcon, full_path, cifs_sb->local_nls,
422 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
414 423
415 if (!rc) { 424 if (!rc) {
416 direntry->d_inode->i_nlink--; 425 direntry->d_inode->i_nlink--;
@@ -422,10 +431,14 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
422 431
423 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, 432 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE,
424 CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE, 433 CREATE_NOT_DIR | CREATE_DELETE_ON_CLOSE,
425 &netfid, &oplock, NULL, cifs_sb->local_nls); 434 &netfid, &oplock, NULL, cifs_sb->local_nls,
435 cifs_sb->mnt_cifs_flags &
436 CIFS_MOUNT_MAP_SPECIAL_CHR);
426 if (rc==0) { 437 if (rc==0) {
427 CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL, 438 CIFSSMBRenameOpenFile(xid, pTcon, netfid, NULL,
428 cifs_sb->local_nls); 439 cifs_sb->local_nls,
440 cifs_sb->mnt_cifs_flags &
441 CIFS_MOUNT_MAP_SPECIAL_CHR);
429 CIFSSMBClose(xid, pTcon, netfid); 442 CIFSSMBClose(xid, pTcon, netfid);
430 direntry->d_inode->i_nlink--; 443 direntry->d_inode->i_nlink--;
431 } 444 }
@@ -439,7 +452,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
439 if (!(pTcon->ses->flags & CIFS_SES_NT4)) 452 if (!(pTcon->ses->flags & CIFS_SES_NT4))
440 rc = CIFSSMBSetTimes(xid, pTcon, full_path, 453 rc = CIFSSMBSetTimes(xid, pTcon, full_path,
441 pinfo_buf, 454 pinfo_buf,
442 cifs_sb->local_nls); 455 cifs_sb->local_nls,
456 cifs_sb->mnt_cifs_flags &
457 CIFS_MOUNT_MAP_SPECIAL_CHR);
443 else 458 else
444 rc = -EOPNOTSUPP; 459 rc = -EOPNOTSUPP;
445 460
@@ -461,7 +476,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
461 FILE_OPEN, SYNCHRONIZE | 476 FILE_OPEN, SYNCHRONIZE |
462 FILE_WRITE_ATTRIBUTES, 0, 477 FILE_WRITE_ATTRIBUTES, 0,
463 &netfid, &oplock, NULL, 478 &netfid, &oplock, NULL,
464 cifs_sb->local_nls); 479 cifs_sb->local_nls,
480 cifs_sb->mnt_cifs_flags &
481 CIFS_MOUNT_MAP_SPECIAL_CHR);
465 if (rc==0) { 482 if (rc==0) {
466 rc = CIFSSMBSetFileTimes(xid, pTcon, 483 rc = CIFSSMBSetFileTimes(xid, pTcon,
467 pinfo_buf, 484 pinfo_buf,
@@ -472,8 +489,10 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
472 kfree(pinfo_buf); 489 kfree(pinfo_buf);
473 } 490 }
474 if (rc==0) { 491 if (rc==0) {
475 rc = CIFSSMBDelFile(xid, pTcon, full_path, 492 rc = CIFSSMBDelFile(xid, pTcon, full_path,
476 cifs_sb->local_nls); 493 cifs_sb->local_nls,
494 cifs_sb->mnt_cifs_flags &
495 CIFS_MOUNT_MAP_SPECIAL_CHR);
477 if (!rc) { 496 if (!rc) {
478 direntry->d_inode->i_nlink--; 497 direntry->d_inode->i_nlink--;
479 } else if (rc == -ETXTBSY) { 498 } else if (rc == -ETXTBSY) {
@@ -485,11 +504,15 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
485 CREATE_NOT_DIR | 504 CREATE_NOT_DIR |
486 CREATE_DELETE_ON_CLOSE, 505 CREATE_DELETE_ON_CLOSE,
487 &netfid, &oplock, NULL, 506 &netfid, &oplock, NULL,
488 cifs_sb->local_nls); 507 cifs_sb->local_nls,
508 cifs_sb->mnt_cifs_flags &
509 CIFS_MOUNT_MAP_SPECIAL_CHR);
489 if (rc==0) { 510 if (rc==0) {
490 CIFSSMBRenameOpenFile(xid, pTcon, 511 CIFSSMBRenameOpenFile(xid, pTcon,
491 netfid, NULL, 512 netfid, NULL,
492 cifs_sb->local_nls); 513 cifs_sb->local_nls,
514 cifs_sb->mnt_cifs_flags &
515 CIFS_MOUNT_MAP_SPECIAL_CHR);
493 CIFSSMBClose(xid, pTcon, netfid); 516 CIFSSMBClose(xid, pTcon, netfid);
494 direntry->d_inode->i_nlink--; 517 direntry->d_inode->i_nlink--;
495 } 518 }
@@ -534,7 +557,8 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
534 return -ENOMEM; 557 return -ENOMEM;
535 } 558 }
536 /* BB add setting the equivalent of mode via CreateX w/ACLs */ 559 /* BB add setting the equivalent of mode via CreateX w/ACLs */
537 rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls); 560 rc = CIFSSMBMkDir(xid, pTcon, full_path, cifs_sb->local_nls,
561 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
538 if (rc) { 562 if (rc) {
539 cFYI(1, ("cifs_mkdir returned 0x%x ", rc)); 563 cFYI(1, ("cifs_mkdir returned 0x%x ", rc));
540 d_drop(direntry); 564 d_drop(direntry);
@@ -558,12 +582,16 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
558 (__u64)current->euid, 582 (__u64)current->euid,
559 (__u64)current->egid, 583 (__u64)current->egid,
560 0 /* dev_t */, 584 0 /* dev_t */,
561 cifs_sb->local_nls); 585 cifs_sb->local_nls,
586 cifs_sb->mnt_cifs_flags &
587 CIFS_MOUNT_MAP_SPECIAL_CHR);
562 } else { 588 } else {
563 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 589 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
564 mode, (__u64)-1, 590 mode, (__u64)-1,
565 (__u64)-1, 0 /* dev_t */, 591 (__u64)-1, 0 /* dev_t */,
566 cifs_sb->local_nls); 592 cifs_sb->local_nls,
593 cifs_sb->mnt_cifs_flags &
594 CIFS_MOUNT_MAP_SPECIAL_CHR);
567 } 595 }
568 else { 596 else {
569 /* BB to be implemented via Windows secrty descriptors 597 /* BB to be implemented via Windows secrty descriptors
@@ -600,7 +628,8 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
600 return -ENOMEM; 628 return -ENOMEM;
601 } 629 }
602 630
603 rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls); 631 rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls,
632 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
604 633
605 if (!rc) { 634 if (!rc) {
606 inode->i_nlink--; 635 inode->i_nlink--;
@@ -653,7 +682,9 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
653 } 682 }
654 683
655 rc = CIFSSMBRename(xid, pTcon, fromName, toName, 684 rc = CIFSSMBRename(xid, pTcon, fromName, toName,
656 cifs_sb_source->local_nls); 685 cifs_sb_source->local_nls,
686 cifs_sb_source->mnt_cifs_flags &
687 CIFS_MOUNT_MAP_SPECIAL_CHR);
657 if (rc == -EEXIST) { 688 if (rc == -EEXIST) {
658 /* check if they are the same file because rename of hardlinked 689 /* check if they are the same file because rename of hardlinked
659 files is a noop */ 690 files is a noop */
@@ -665,11 +696,16 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
665 if (info_buf_source != NULL) { 696 if (info_buf_source != NULL) {
666 info_buf_target = info_buf_source + 1; 697 info_buf_target = info_buf_source + 1;
667 rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName, 698 rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
668 info_buf_source, cifs_sb_source->local_nls); 699 info_buf_source, cifs_sb_source->local_nls,
700 cifs_sb_source->mnt_cifs_flags &
701 CIFS_MOUNT_MAP_SPECIAL_CHR);
669 if (rc == 0) { 702 if (rc == 0) {
670 rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName, 703 rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName,
671 info_buf_target, 704 info_buf_target,
672 cifs_sb_target->local_nls); 705 cifs_sb_target->local_nls,
706 /* remap based on source sb */
707 cifs_sb_source->mnt_cifs_flags &
708 CIFS_MOUNT_MAP_SPECIAL_CHR);
673 } 709 }
674 if ((rc == 0) && 710 if ((rc == 0) &&
675 (info_buf_source->UniqueId == 711 (info_buf_source->UniqueId ==
@@ -685,7 +721,9 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
685 cifs_unlink(target_inode, target_direntry); 721 cifs_unlink(target_inode, target_direntry);
686 rc = CIFSSMBRename(xid, pTcon, fromName, 722 rc = CIFSSMBRename(xid, pTcon, fromName,
687 toName, 723 toName,
688 cifs_sb_source->local_nls); 724 cifs_sb_source->local_nls,
725 cifs_sb_source->mnt_cifs_flags
726 & CIFS_MOUNT_MAP_SPECIAL_CHR);
689 } 727 }
690 kfree(info_buf_source); 728 kfree(info_buf_source);
691 } /* if we can not get memory just leave rc as EEXIST */ 729 } /* if we can not get memory just leave rc as EEXIST */
@@ -705,10 +743,14 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
705 might not right be right access to request */ 743 might not right be right access to request */
706 rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ, 744 rc = CIFSSMBOpen(xid, pTcon, fromName, FILE_OPEN, GENERIC_READ,
707 CREATE_NOT_DIR, &netfid, &oplock, NULL, 745 CREATE_NOT_DIR, &netfid, &oplock, NULL,
708 cifs_sb_source->local_nls); 746 cifs_sb_source->local_nls,
747 cifs_sb_source->mnt_cifs_flags &
748 CIFS_MOUNT_MAP_SPECIAL_CHR);
709 if (rc==0) { 749 if (rc==0) {
710 CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName, 750 CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
711 cifs_sb_source->local_nls); 751 cifs_sb_source->local_nls,
752 cifs_sb_source->mnt_cifs_flags &
753 CIFS_MOUNT_MAP_SPECIAL_CHR);
712 CIFSSMBClose(xid, pTcon, netfid); 754 CIFSSMBClose(xid, pTcon, netfid);
713 } 755 }
714 } 756 }
@@ -962,7 +1004,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
962 it by handle */ 1004 it by handle */
963 rc = CIFSSMBSetEOF(xid, pTcon, full_path, 1005 rc = CIFSSMBSetEOF(xid, pTcon, full_path,
964 attrs->ia_size, FALSE, 1006 attrs->ia_size, FALSE,
965 cifs_sb->local_nls); 1007 cifs_sb->local_nls,
1008 cifs_sb->mnt_cifs_flags &
1009 CIFS_MOUNT_MAP_SPECIAL_CHR);
966 cFYI(1, (" SetEOF by path (setattrs) rc = %d", rc)); 1010 cFYI(1, (" SetEOF by path (setattrs) rc = %d", rc));
967 } 1011 }
968 1012
@@ -999,7 +1043,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
999 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX) 1043 if ((cifs_sb->tcon->ses->capabilities & CAP_UNIX)
1000 && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) 1044 && (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))
1001 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid, 1045 rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,
1002 0 /* dev_t */, cifs_sb->local_nls); 1046 0 /* dev_t */, cifs_sb->local_nls,
1047 cifs_sb->mnt_cifs_flags &
1048 CIFS_MOUNT_MAP_SPECIAL_CHR);
1003 else if (attrs->ia_valid & ATTR_MODE) { 1049 else if (attrs->ia_valid & ATTR_MODE) {
1004 if ((mode & S_IWUGO) == 0) /* not writeable */ { 1050 if ((mode & S_IWUGO) == 0) /* not writeable */ {
1005 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0) 1051 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0)
@@ -1048,7 +1094,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1048 via Handle (SetFileInfo) instead of by path */ 1094 via Handle (SetFileInfo) instead of by path */
1049 if (!(pTcon->ses->flags & CIFS_SES_NT4)) 1095 if (!(pTcon->ses->flags & CIFS_SES_NT4))
1050 rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf, 1096 rc = CIFSSMBSetTimes(xid, pTcon, full_path, &time_buf,
1051 cifs_sb->local_nls); 1097 cifs_sb->local_nls,
1098 cifs_sb->mnt_cifs_flags &
1099 CIFS_MOUNT_MAP_SPECIAL_CHR);
1052 else 1100 else
1053 rc = -EOPNOTSUPP; 1101 rc = -EOPNOTSUPP;
1054 1102
@@ -1063,7 +1111,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1063 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 1111 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN,
1064 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, 1112 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES,
1065 CREATE_NOT_DIR, &netfid, &oplock, 1113 CREATE_NOT_DIR, &netfid, &oplock,
1066 NULL, cifs_sb->local_nls); 1114 NULL, cifs_sb->local_nls,
1115 cifs_sb->mnt_cifs_flags &
1116 CIFS_MOUNT_MAP_SPECIAL_CHR);
1067 if (rc==0) { 1117 if (rc==0) {
1068 rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf, 1118 rc = CIFSSMBSetFileTimes(xid, pTcon, &time_buf,
1069 netfid); 1119 netfid);
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index b4b8e201d428..b0ea6687ab55 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -20,30 +20,93 @@
20 * along with this library; if not, write to the Free Software 20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23
23#include <linux/fs.h> 24#include <linux/fs.h>
24#include <linux/ext2_fs.h> 25#include <linux/ext2_fs.h>
25#include "cifspdu.h" 26#include "cifspdu.h"
26#include "cifsglob.h" 27#include "cifsglob.h"
27#include "cifsproto.h" 28#include "cifsproto.h"
28#include "cifs_debug.h" 29#include "cifs_debug.h"
30#include "cifsfs.h"
31
32#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
29 33
30int cifs_ioctl (struct inode * inode, struct file * filep, 34int cifs_ioctl (struct inode * inode, struct file * filep,
31 unsigned int command, unsigned long arg) 35 unsigned int command, unsigned long arg)
32{ 36{
33 int rc = -ENOTTY; /* strange error - but the precedent */ 37 int rc = -ENOTTY; /* strange error - but the precedent */
38 int xid;
39 struct cifs_sb_info *cifs_sb;
40#ifdef CONFIG_CIFS_POSIX
41 __u64 ExtAttrBits = 0;
42 __u64 ExtAttrMask = 0;
43 __u64 caps;
44 struct cifsTconInfo *tcon;
45 struct cifsFileInfo *pSMBFile =
46 (struct cifsFileInfo *)filep->private_data;
47#endif /* CONFIG_CIFS_POSIX */
48
49 xid = GetXid();
50
51 cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg));
52
53 cifs_sb = CIFS_SB(inode->i_sb);
54
34#ifdef CONFIG_CIFS_POSIX 55#ifdef CONFIG_CIFS_POSIX
35 cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg)); 56 tcon = cifs_sb->tcon;
57 if(tcon)
58 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
59 else {
60 rc = -EIO;
61 FreeXid(xid);
62 return -EIO;
63 }
64#endif /* CONFIG_CIFS_POSIX */
65
36 switch(command) { 66 switch(command) {
67 case CIFS_IOC_CHECKUMOUNT:
68 cFYI(1,("User unmount attempted"));
69 if(cifs_sb->mnt_uid == current->uid)
70 rc = 0;
71 else {
72 rc = -EACCES;
73 cFYI(1,("uids do not match"));
74 }
75 break;
76#ifdef CONFIG_CIFS_POSIX
37 case EXT2_IOC_GETFLAGS: 77 case EXT2_IOC_GETFLAGS:
38 cFYI(1,("get flags not implemented yet")); 78 if(CIFS_UNIX_EXTATTR_CAP & caps) {
39 return -EOPNOTSUPP; 79 if (pSMBFile == NULL)
80 break;
81 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
82 &ExtAttrBits, &ExtAttrMask);
83 if(rc == 0)
84 rc = put_user(ExtAttrBits &
85 EXT2_FL_USER_VISIBLE,
86 (int __user *)arg);
87 }
88 break;
89
40 case EXT2_IOC_SETFLAGS: 90 case EXT2_IOC_SETFLAGS:
91 if(CIFS_UNIX_EXTATTR_CAP & caps) {
92 if(get_user(ExtAttrBits,(int __user *)arg)) {
93 rc = -EFAULT;
94 break;
95 }
96 if (pSMBFile == NULL)
97 break;
98 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
99 extAttrBits, &ExtAttrMask);*/
100
101 }
41 cFYI(1,("set flags not implemented yet")); 102 cFYI(1,("set flags not implemented yet"));
42 return -EOPNOTSUPP; 103 break;
104#endif /* CONFIG_CIFS_POSIX */
43 default: 105 default:
44 cFYI(1,("unsupported ioctl")); 106 cFYI(1,("unsupported ioctl"));
45 return rc; 107 break;
46 } 108 }
47#endif /* CONFIG_CIFS_POSIX */ 109
110 FreeXid(xid);
48 return rc; 111 return rc;
49} 112}
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 1455810ba1cb..bde0fabfece0 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -59,10 +59,14 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
59 59
60 if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX) 60 if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)
61 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, 61 rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
62 cifs_sb_target->local_nls); 62 cifs_sb_target->local_nls,
63 cifs_sb_target->mnt_cifs_flags &
64 CIFS_MOUNT_MAP_SPECIAL_CHR);
63 else { 65 else {
64 rc = CIFSCreateHardLink(xid, pTcon, fromName, toName, 66 rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
65 cifs_sb_target->local_nls); 67 cifs_sb_target->local_nls,
68 cifs_sb_target->mnt_cifs_flags &
69 CIFS_MOUNT_MAP_SPECIAL_CHR);
66 if(rc == -EIO) 70 if(rc == -EIO)
67 rc = -EOPNOTSUPP; 71 rc = -EOPNOTSUPP;
68 } 72 }
@@ -260,7 +264,10 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
260 cifs_sb->local_nls); 264 cifs_sb->local_nls);
261 else { 265 else {
262 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, 266 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
263 OPEN_REPARSE_POINT,&fid, &oplock, NULL, cifs_sb->local_nls); 267 OPEN_REPARSE_POINT,&fid, &oplock, NULL,
268 cifs_sb->local_nls,
269 cifs_sb->mnt_cifs_flags &
270 CIFS_MOUNT_MAP_SPECIAL_CHR);
264 if(!rc) { 271 if(!rc) {
265 rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, 272 rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path,
266 tmpbuffer, 273 tmpbuffer,
@@ -279,7 +286,10 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
279 strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE); 286 strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE);
280 strncat(tmp_path, full_path, MAX_PATHCONF); 287 strncat(tmp_path, full_path, MAX_PATHCONF);
281 rc = get_dfs_path(xid, pTcon->ses, tmp_path, 288 rc = get_dfs_path(xid, pTcon->ses, tmp_path,
282 cifs_sb->local_nls, &num_referrals, &referrals); 289 cifs_sb->local_nls,
290 &num_referrals, &referrals,
291 cifs_sb->mnt_cifs_flags &
292 CIFS_MOUNT_MAP_SPECIAL_CHR);
283 cFYI(1,("Get DFS for %s rc = %d ",tmp_path, rc)); 293 cFYI(1,("Get DFS for %s rc = %d ",tmp_path, rc));
284 if((num_referrals == 0) && (rc == 0)) 294 if((num_referrals == 0) && (rc == 0))
285 rc = -EACCES; 295 rc = -EACCES;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 7b38d3059a83..db14b503d89e 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -28,6 +28,7 @@
28#include "cifs_debug.h" 28#include "cifs_debug.h"
29#include "smberr.h" 29#include "smberr.h"
30#include "nterr.h" 30#include "nterr.h"
31#include "cifs_unicode.h"
31 32
32extern mempool_t *cifs_sm_req_poolp; 33extern mempool_t *cifs_sm_req_poolp;
33extern mempool_t *cifs_req_poolp; 34extern mempool_t *cifs_req_poolp;
@@ -451,25 +452,30 @@ is_valid_oplock_break(struct smb_hdr *buf)
451 atomic_inc(&tcon->num_oplock_brks); 452 atomic_inc(&tcon->num_oplock_brks);
452#endif 453#endif
453 list_for_each(tmp1,&tcon->openFileList){ 454 list_for_each(tmp1,&tcon->openFileList){
454 netfile = list_entry(tmp1,struct cifsFileInfo,tlist); 455 netfile = list_entry(tmp1,struct cifsFileInfo,
456 tlist);
455 if(pSMB->Fid == netfile->netfid) { 457 if(pSMB->Fid == netfile->netfid) {
456 struct cifsInodeInfo *pCifsInode; 458 struct cifsInodeInfo *pCifsInode;
457 read_unlock(&GlobalSMBSeslock); 459 read_unlock(&GlobalSMBSeslock);
458 cFYI(1,("Matching file id, processing oplock break")); 460 cFYI(1,("file id match, oplock break"));
459 pCifsInode = 461 pCifsInode =
460 CIFS_I(netfile->pInode); 462 CIFS_I(netfile->pInode);
461 pCifsInode->clientCanCacheAll = FALSE; 463 pCifsInode->clientCanCacheAll = FALSE;
462 if(pSMB->OplockLevel == 0) 464 if(pSMB->OplockLevel == 0)
463 pCifsInode->clientCanCacheRead = FALSE; 465 pCifsInode->clientCanCacheRead
466 = FALSE;
464 pCifsInode->oplockPending = TRUE; 467 pCifsInode->oplockPending = TRUE;
465 AllocOplockQEntry(netfile->pInode, netfile->netfid, tcon); 468 AllocOplockQEntry(netfile->pInode,
469 netfile->netfid,
470 tcon);
466 cFYI(1,("about to wake up oplock thd")); 471 cFYI(1,("about to wake up oplock thd"));
467 wake_up_process(oplockThread); 472 if(oplockThread)
473 wake_up_process(oplockThread);
468 return TRUE; 474 return TRUE;
469 } 475 }
470 } 476 }
471 read_unlock(&GlobalSMBSeslock); 477 read_unlock(&GlobalSMBSeslock);
472 cFYI(1,("No matching file for oplock break on connection")); 478 cFYI(1,("No matching file for oplock break"));
473 return TRUE; 479 return TRUE;
474 } 480 }
475 } 481 }
@@ -490,7 +496,7 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
490 496
491 buffer = (unsigned char *) smb_buf; 497 buffer = (unsigned char *) smb_buf;
492 for (i = 0, j = 0; i < smb_buf_length; i++, j++) { 498 for (i = 0, j = 0; i < smb_buf_length; i++, j++) {
493 if (i % 8 == 0) { /* we have reached the beginning of line */ 499 if (i % 8 == 0) { /* have reached the beginning of line */
494 printk(KERN_DEBUG "| "); 500 printk(KERN_DEBUG "| ");
495 j = 0; 501 j = 0;
496 } 502 }
@@ -501,7 +507,7 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
501 else 507 else
502 debug_line[1 + (2 * j)] = '_'; 508 debug_line[1 + (2 * j)] = '_';
503 509
504 if (i % 8 == 7) { /* we have reached end of line, time to print ascii */ 510 if (i % 8 == 7) { /* reached end of line, time to print ascii */
505 debug_line[16] = 0; 511 debug_line[16] = 0;
506 printk(" | %s\n", debug_line); 512 printk(" | %s\n", debug_line);
507 } 513 }
@@ -514,3 +520,141 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length)
514 printk( " | %s\n", debug_line); 520 printk( " | %s\n", debug_line);
515 return; 521 return;
516} 522}
523
524/* Windows maps these to the user defined 16 bit Unicode range since they are
525 reserved symbols (along with \ and /), otherwise illegal to store
526 in filenames in NTFS */
527#define UNI_ASTERIK (__u16) ('*' + 0xF000)
528#define UNI_QUESTION (__u16) ('?' + 0xF000)
529#define UNI_COLON (__u16) (':' + 0xF000)
530#define UNI_GRTRTHAN (__u16) ('>' + 0xF000)
531#define UNI_LESSTHAN (__u16) ('<' + 0xF000)
532#define UNI_PIPE (__u16) ('|' + 0xF000)
533#define UNI_SLASH (__u16) ('\\' + 0xF000)
534
535/* Convert 16 bit Unicode pathname from wire format to string in current code
536 page. Conversion may involve remapping up the seven characters that are
537 only legal in POSIX-like OS (if they are present in the string). Path
538 names are little endian 16 bit Unicode on the wire */
539int
540cifs_convertUCSpath(char *target, const __le16 * source, int maxlen,
541 const struct nls_table * cp)
542{
543 int i,j,len;
544 __u16 src_char;
545
546 for(i = 0, j = 0; i < maxlen; i++) {
547 src_char = le16_to_cpu(source[i]);
548 switch (src_char) {
549 case 0:
550 goto cUCS_out; /* BB check this BB */
551 case UNI_COLON:
552 target[j] = ':';
553 break;
554 case UNI_ASTERIK:
555 target[j] = '*';
556 break;
557 case UNI_QUESTION:
558 target[j] = '?';
559 break;
560 /* BB We can not handle remapping slash until
561 all the calls to build_path_from_dentry
562 are modified, as they use slash as separator BB */
563 /* case UNI_SLASH:
564 target[j] = '\\';
565 break;*/
566 case UNI_PIPE:
567 target[j] = '|';
568 break;
569 case UNI_GRTRTHAN:
570 target[j] = '>';
571 break;
572 case UNI_LESSTHAN:
573 target[j] = '<';
574 default:
575 len = cp->uni2char(src_char, &target[j],
576 NLS_MAX_CHARSET_SIZE);
577 if(len > 0) {
578 j += len;
579 continue;
580 } else {
581 target[j] = '?';
582 }
583 }
584 j++;
585 /* make sure we do not overrun callers allocated temp buffer */
586 if(j >= (2 * NAME_MAX))
587 break;
588 }
589cUCS_out:
590 target[j] = 0;
591 return j;
592}
593
594/* Convert 16 bit Unicode pathname to wire format from string in current code
595 page. Conversion may involve remapping up the seven characters that are
596 only legal in POSIX-like OS (if they are present in the string). Path
597 names are little endian 16 bit Unicode on the wire */
598int
599cifsConvertToUCS(__le16 * target, const char *source, int maxlen,
600 const struct nls_table * cp, int mapChars)
601{
602 int i,j,charlen;
603 int len_remaining = maxlen;
604 char src_char;
605
606 if(!mapChars)
607 return cifs_strtoUCS((wchar_t *) target, source, PATH_MAX, cp);
608
609 for(i = 0, j = 0; i < maxlen; j++) {
610 src_char = source[i];
611 switch (src_char) {
612 case 0:
613 goto ctoUCS_out;
614 case ':':
615 target[j] = cpu_to_le16(UNI_COLON);
616 break;
617 case '*':
618 target[j] = cpu_to_le16(UNI_ASTERIK);
619 break;
620 case '?':
621 target[j] = cpu_to_le16(UNI_QUESTION);
622 break;
623 case '<':
624 target[j] = cpu_to_le16(UNI_LESSTHAN);
625 break;
626 case '>':
627 target[j] = cpu_to_le16(UNI_GRTRTHAN);
628 break;
629 case '|':
630 target[j] = cpu_to_le16(UNI_PIPE);
631 break;
632 /* BB We can not handle remapping slash until
633 all the calls to build_path_from_dentry
634 are modified, as they use slash as separator BB */
635 /* case '\\':
636 target[j] = cpu_to_le16(UNI_SLASH);
637 break;*/
638 default:
639 charlen = cp->char2uni(source+i,
640 len_remaining, target+j);
641 /* if no match, use question mark, which
642 at least in some cases servers as wild card */
643 if(charlen < 1) {
644 target[j] = cpu_to_le16(0x003f);
645 charlen = 1;
646 }
647 len_remaining -= charlen;
648 /* character may take more than one byte in the
649 the source string, but will take exactly two
650 bytes in the target string */
651 i+= charlen;
652 continue;
653 }
654 i++; /* move to next char in source string */
655 len_remaining--;
656 }
657
658ctoUCS_out:
659 return i;
660}
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 4e34c89cec5d..a92af41d4411 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -78,6 +78,7 @@ static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
78 {ErrQuota, -EDQUOT}, 78 {ErrQuota, -EDQUOT},
79 {ErrNotALink, -ENOLINK}, 79 {ErrNotALink, -ENOLINK},
80 {ERRnetlogonNotStarted,-ENOPROTOOPT}, 80 {ERRnetlogonNotStarted,-ENOPROTOOPT},
81 {ErrTooManyLinks,-EMLINK},
81 {0, 0} 82 {0, 0}
82}; 83};
83 84
@@ -206,7 +207,7 @@ static const struct {
206 { 207 {
207 ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, { 208 ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {
208 ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, { 209 ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {
209 ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, { 210 ERRDOS, ERRinvlevel, NT_STATUS_INVALID_INFO_CLASS}, {
210 ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, { 211 ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {
211 ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, { 212 ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {
212 ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, { 213 ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {
@@ -742,7 +743,7 @@ static const struct {
742 ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, { 743 ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {
743 ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, { 744 ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {
744 ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, { 745 ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {
745 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LINKS}, { 746 ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {
746 ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, { 747 ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {
747 ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, { 748 ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {
748 ERRDOS, 21, 0xc000026e}, { 749 ERRDOS, 21, 0xc000026e}, {
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index f8bea395ec9e..22557716f9af 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Directory search handling 4 * Directory search handling
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2004 6 * Copyright (C) International Business Machines Corp., 2004, 2005
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or modify 9 * This library is free software; you can redistribute it and/or modify
@@ -65,14 +65,14 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
65 struct cifsTconInfo *pTcon; 65 struct cifsTconInfo *pTcon;
66 int rc = 0; 66 int rc = 0;
67 67
68 cFYI(1, ("For %s ", qstring->name)); 68 cFYI(1, ("For %s", qstring->name));
69 cifs_sb = CIFS_SB(file->f_dentry->d_sb); 69 cifs_sb = CIFS_SB(file->f_dentry->d_sb);
70 pTcon = cifs_sb->tcon; 70 pTcon = cifs_sb->tcon;
71 71
72 qstring->hash = full_name_hash(qstring->name, qstring->len); 72 qstring->hash = full_name_hash(qstring->name, qstring->len);
73 tmp_dentry = d_lookup(file->f_dentry, qstring); 73 tmp_dentry = d_lookup(file->f_dentry, qstring);
74 if (tmp_dentry) { 74 if (tmp_dentry) {
75 cFYI(0, (" existing dentry with inode 0x%p", tmp_dentry->d_inode)); 75 cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode));
76 *ptmp_inode = tmp_dentry->d_inode; 76 *ptmp_inode = tmp_dentry->d_inode;
77/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/ 77/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
78 if(*ptmp_inode == NULL) { 78 if(*ptmp_inode == NULL) {
@@ -105,8 +105,11 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
105} 105}
106 106
107static void fill_in_inode(struct inode *tmp_inode, 107static void fill_in_inode(struct inode *tmp_inode,
108 FILE_DIRECTORY_INFO *pfindData, int *pobject_type) 108 FILE_DIRECTORY_INFO *pfindData, int *pobject_type, int isNewInode)
109{ 109{
110 loff_t local_size;
111 struct timespec local_mtime;
112
110 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); 113 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
111 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); 114 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
112 __u32 attr = le32_to_cpu(pfindData->ExtFileAttributes); 115 __u32 attr = le32_to_cpu(pfindData->ExtFileAttributes);
@@ -116,6 +119,10 @@ static void fill_in_inode(struct inode *tmp_inode,
116 cifsInfo->cifsAttrs = attr; 119 cifsInfo->cifsAttrs = attr;
117 cifsInfo->time = jiffies; 120 cifsInfo->time = jiffies;
118 121
122 /* save mtime and size */
123 local_mtime = tmp_inode->i_mtime;
124 local_size = tmp_inode->i_size;
125
119 /* Linux can not store file creation time unfortunately so ignore it */ 126 /* Linux can not store file creation time unfortunately so ignore it */
120 tmp_inode->i_atime = 127 tmp_inode->i_atime =
121 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); 128 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime));
@@ -134,7 +141,6 @@ static void fill_in_inode(struct inode *tmp_inode,
134 tmp_inode->i_mode = cifs_sb->mnt_file_mode; 141 tmp_inode->i_mode = cifs_sb->mnt_file_mode;
135 } 142 }
136 143
137 cFYI(0,("CIFS FFIRST: Attributes came in as 0x%x",attr));
138 if (attr & ATTR_DIRECTORY) { 144 if (attr & ATTR_DIRECTORY) {
139 *pobject_type = DT_DIR; 145 *pobject_type = DT_DIR;
140 /* override default perms since we do not lock dirs */ 146 /* override default perms since we do not lock dirs */
@@ -175,30 +181,46 @@ static void fill_in_inode(struct inode *tmp_inode,
175 (unsigned long)tmp_inode->i_size, tmp_inode->i_blocks, 181 (unsigned long)tmp_inode->i_size, tmp_inode->i_blocks,
176 tmp_inode->i_blksize)); 182 tmp_inode->i_blksize));
177 if (S_ISREG(tmp_inode->i_mode)) { 183 if (S_ISREG(tmp_inode->i_mode)) {
178 cFYI(1, (" File inode ")); 184 cFYI(1, ("File inode"));
179 tmp_inode->i_op = &cifs_file_inode_ops; 185 tmp_inode->i_op = &cifs_file_inode_ops;
180 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) 186 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
181 tmp_inode->i_fop = &cifs_file_direct_ops; 187 tmp_inode->i_fop = &cifs_file_direct_ops;
182 else 188 else
183 tmp_inode->i_fop = &cifs_file_ops; 189 tmp_inode->i_fop = &cifs_file_ops;
184 tmp_inode->i_data.a_ops = &cifs_addr_ops; 190 tmp_inode->i_data.a_ops = &cifs_addr_ops;
191
192 if(isNewInode)
193 return; /* No sense invalidating pages for new inode since we
194 have not started caching readahead file data yet */
195
196 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
197 (local_size == tmp_inode->i_size)) {
198 cFYI(1, ("inode exists but unchanged"));
199 } else {
200 /* file may have changed on server */
201 cFYI(1, ("invalidate inode, readdir detected change"));
202 invalidate_remote_inode(tmp_inode);
203 }
185 } else if (S_ISDIR(tmp_inode->i_mode)) { 204 } else if (S_ISDIR(tmp_inode->i_mode)) {
186 cFYI(1, (" Directory inode")); 205 cFYI(1, ("Directory inode"));
187 tmp_inode->i_op = &cifs_dir_inode_ops; 206 tmp_inode->i_op = &cifs_dir_inode_ops;
188 tmp_inode->i_fop = &cifs_dir_ops; 207 tmp_inode->i_fop = &cifs_dir_ops;
189 } else if (S_ISLNK(tmp_inode->i_mode)) { 208 } else if (S_ISLNK(tmp_inode->i_mode)) {
190 cFYI(1, (" Symbolic Link inode ")); 209 cFYI(1, ("Symbolic Link inode"));
191 tmp_inode->i_op = &cifs_symlink_inode_ops; 210 tmp_inode->i_op = &cifs_symlink_inode_ops;
192 } else { 211 } else {
193 cFYI(1, (" Init special inode ")); 212 cFYI(1, ("Init special inode"));
194 init_special_inode(tmp_inode, tmp_inode->i_mode, 213 init_special_inode(tmp_inode, tmp_inode->i_mode,
195 tmp_inode->i_rdev); 214 tmp_inode->i_rdev);
196 } 215 }
197} 216}
198 217
199static void unix_fill_in_inode(struct inode *tmp_inode, 218static void unix_fill_in_inode(struct inode *tmp_inode,
200 FILE_UNIX_INFO *pfindData, int *pobject_type) 219 FILE_UNIX_INFO *pfindData, int *pobject_type, int isNewInode)
201{ 220{
221 loff_t local_size;
222 struct timespec local_mtime;
223
202 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); 224 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
203 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); 225 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
204 226
@@ -208,6 +230,10 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
208 cifsInfo->time = jiffies; 230 cifsInfo->time = jiffies;
209 atomic_inc(&cifsInfo->inUse); 231 atomic_inc(&cifsInfo->inUse);
210 232
233 /* save mtime and size */
234 local_mtime = tmp_inode->i_mtime;
235 local_size = tmp_inode->i_size;
236
211 tmp_inode->i_atime = 237 tmp_inode->i_atime =
212 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); 238 cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime));
213 tmp_inode->i_mtime = 239 tmp_inode->i_mtime =
@@ -265,6 +291,19 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
265 else 291 else
266 tmp_inode->i_fop = &cifs_file_ops; 292 tmp_inode->i_fop = &cifs_file_ops;
267 tmp_inode->i_data.a_ops = &cifs_addr_ops; 293 tmp_inode->i_data.a_ops = &cifs_addr_ops;
294
295 if(isNewInode)
296 return; /* No sense invalidating pages for new inode since we
297 have not started caching readahead file data yet */
298
299 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
300 (local_size == tmp_inode->i_size)) {
301 cFYI(1, ("inode exists but unchanged"));
302 } else {
303 /* file may have changed on server */
304 cFYI(1, ("invalidate inode, readdir detected change"));
305 invalidate_remote_inode(tmp_inode);
306 }
268 } else if (S_ISDIR(tmp_inode->i_mode)) { 307 } else if (S_ISDIR(tmp_inode->i_mode)) {
269 cFYI(1, ("Directory inode")); 308 cFYI(1, ("Directory inode"));
270 tmp_inode->i_op = &cifs_dir_inode_ops; 309 tmp_inode->i_op = &cifs_dir_inode_ops;
@@ -314,15 +353,16 @@ static int initiate_cifs_search(const int xid, struct file *file)
314 return -EINVAL; 353 return -EINVAL;
315 354
316 down(&file->f_dentry->d_sb->s_vfs_rename_sem); 355 down(&file->f_dentry->d_sb->s_vfs_rename_sem);
317 full_path = build_wildcard_path_from_dentry(file->f_dentry); 356 full_path = build_path_from_dentry(file->f_dentry);
318 up(&file->f_dentry->d_sb->s_vfs_rename_sem); 357 up(&file->f_dentry->d_sb->s_vfs_rename_sem);
319 358
320 if(full_path == NULL) { 359 if(full_path == NULL) {
321 return -ENOMEM; 360 return -ENOMEM;
322 } 361 }
323 362
324 cFYI(1, ("Full path: %s start at: %lld ", full_path, file->f_pos)); 363 cFYI(1, ("Full path: %s start at: %lld", full_path, file->f_pos));
325 364
365ffirst_retry:
326 /* test for Unix extensions */ 366 /* test for Unix extensions */
327 if (pTcon->ses->capabilities & CAP_UNIX) { 367 if (pTcon->ses->capabilities & CAP_UNIX) {
328 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; 368 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
@@ -332,10 +372,16 @@ static int initiate_cifs_search(const int xid, struct file *file)
332 cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO; 372 cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO;
333 } 373 }
334 374
335 rc = CIFSFindFirst(xid, pTcon,full_path,cifs_sb->local_nls, 375 rc = CIFSFindFirst(xid, pTcon,full_path,cifs_sb->local_nls,
336 &cifsFile->netfid, &cifsFile->srch_inf); 376 &cifsFile->netfid, &cifsFile->srch_inf,
377 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
337 if(rc == 0) 378 if(rc == 0)
338 cifsFile->invalidHandle = FALSE; 379 cifsFile->invalidHandle = FALSE;
380 if((rc == -EOPNOTSUPP) &&
381 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
382 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
383 goto ffirst_retry;
384 }
339 kfree(full_path); 385 kfree(full_path);
340 return rc; 386 return rc;
341} 387}
@@ -363,10 +409,15 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb)
363 cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); 409 cFYI(1,("new entry %p old entry %p",new_entry,old_entry));
364 /* validate that new_entry is not past end of SMB */ 410 /* validate that new_entry is not past end of SMB */
365 if(new_entry >= end_of_smb) { 411 if(new_entry >= end_of_smb) {
366 cFYI(1,("search entry %p began after end of SMB %p old entry %p", 412 cERROR(1,
367 new_entry,end_of_smb,old_entry)); 413 ("search entry %p began after end of SMB %p old entry %p",
414 new_entry, end_of_smb, old_entry));
368 return NULL; 415 return NULL;
369 } else 416 } else if (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb) {
417 cERROR(1,("search entry %p extends after end of SMB %p",
418 new_entry, end_of_smb));
419 return NULL;
420 } else
370 return new_entry; 421 return new_entry;
371 422
372} 423}
@@ -594,7 +645,12 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
594 if(unicode) { 645 if(unicode) {
595 /* BB fixme - test with long names */ 646 /* BB fixme - test with long names */
596 /* Note converted filename can be longer than in unicode */ 647 /* Note converted filename can be longer than in unicode */
597 pqst->len = cifs_strfromUCS_le((char *)pqst->name,(wchar_t *)filename,len/2,nlt); 648 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
649 pqst->len = cifs_convertUCSpath((char *)pqst->name,
650 (__le16 *)filename, len/2, nlt);
651 else
652 pqst->len = cifs_strfromUCS_le((char *)pqst->name,
653 (wchar_t *)filename,len/2,nlt);
598 } else { 654 } else {
599 pqst->name = filename; 655 pqst->name = filename;
600 pqst->len = len; 656 pqst->len = len;
@@ -654,10 +710,15 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
654 insert_inode_hash(tmp_inode); 710 insert_inode_hash(tmp_inode);
655 } 711 }
656 712
713 /* we pass in rc below, indicating whether it is a new inode,
714 so we can figure out whether to invalidate the inode cached
715 data if the file has changed */
657 if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) { 716 if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
658 unix_fill_in_inode(tmp_inode,(FILE_UNIX_INFO *)pfindEntry,&obj_type); 717 unix_fill_in_inode(tmp_inode,
718 (FILE_UNIX_INFO *)pfindEntry,&obj_type, rc);
659 } else { 719 } else {
660 fill_in_inode(tmp_inode,(FILE_DIRECTORY_INFO *)pfindEntry,&obj_type); 720 fill_in_inode(tmp_inode,
721 (FILE_DIRECTORY_INFO *)pfindEntry,&obj_type, rc);
661 } 722 }
662 723
663 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,tmp_inode->i_ino,obj_type); 724 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,tmp_inode->i_ino,obj_type);
@@ -823,7 +884,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
823 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + 884 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start +
824 smbCalcSize((struct smb_hdr *) 885 smbCalcSize((struct smb_hdr *)
825 cifsFile->srch_inf.ntwrk_buf_start); 886 cifsFile->srch_inf.ntwrk_buf_start);
826 tmp_buf = kmalloc(NAME_MAX+1,GFP_KERNEL); 887 /* To be safe - for UCS to UTF-8 with strings loaded
888 with the rare long characters alloc more to account for
889 such multibyte target UTF-8 characters. cifs_unicode.c,
890 which actually does the conversion, has the same limit */
891 tmp_buf = kmalloc((2 * NAME_MAX) + 4, GFP_KERNEL);
827 for(i=0;(i<num_to_fill) && (rc == 0);i++) { 892 for(i=0;(i<num_to_fill) && (rc == 0);i++) {
828 if(current_entry == NULL) { 893 if(current_entry == NULL) {
829 /* evaluate whether this case is an error */ 894 /* evaluate whether this case is an error */
@@ -832,19 +897,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
832 break; 897 break;
833 } 898 }
834 899
835 /* BB FIXME - need to enable the below code BB */
836
837 /* if((!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) ||
838 (cifsFile->srch_inf.info_level !=
839 something that supports server inodes)) {
840 create dentry
841 create inode
842 fill in inode new_inode (getting local i_ino)
843 }
844 also create local inode for performance reasons (so we
845 have a cache of inode metadata) unless this new mount
846 parm says otherwise */
847
848 rc = cifs_filldir(current_entry, file, 900 rc = cifs_filldir(current_entry, file,
849 filldir, direntry,tmp_buf); 901 filldir, direntry,tmp_buf);
850 file->f_pos++; 902 file->f_pos++;
diff --git a/fs/cifs/smberr.h b/fs/cifs/smberr.h
index e21f1384661f..cd41c67ff8d3 100644
--- a/fs/cifs/smberr.h
+++ b/fs/cifs/smberr.h
@@ -22,94 +22,159 @@
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */ 23 */
24 24
25#define SUCCESS 0 /* The request was successful. */ 25#define SUCCESS 0x00 /* The request was successful. */
26#define ERRDOS 0x01 /* Error is from the core DOS operating system set */ 26#define ERRDOS 0x01 /* Error is from the core DOS operating system set */
27#define ERRSRV 0x02 /* Error is generated by the file server daemon */ 27#define ERRSRV 0x02 /* Error is generated by the file server daemon */
28#define ERRHRD 0x03 /* Error is a hardware error. */ 28#define ERRHRD 0x03 /* Error is a hardware error. */
29#define ERRCMD 0xFF /* Command was not in the "SMB" format. */ 29#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
30 30
31/* The following error codes may be generated with the SUCCESS error class.*/ 31/* The following error codes may be generated with the SUCCESS error class.*/
32 32
33#define SUCCESS 0 /* The request was successful. */ 33/*#define SUCCESS 0 The request was successful. */
34 34
35/* The following error codes may be generated with the ERRDOS error class.*/ 35/* The following error codes may be generated with the ERRDOS error class.*/
36 36
37#define ERRbadfunc 1 /* Invalid function. The server did not recognize or could not perform a system call generated by the server, e.g., set the DIRECTORY attribute on a data file, invalid seek mode. */ 37#define ERRbadfunc 1 /* Invalid function. The server did not
38#define ERRbadfile 2 /*File not found. The last component of a file's pathname could not be found. */ 38 recognize or could not perform a
39#define ERRbadpath 3 /* Directory invalid. A directory component in a pathname could not be found. */ 39 system call generated by the server,
40#define ERRnofids 4 /* Too many open files. The server has no file handles available. */ 40 e.g., set the DIRECTORY attribute on
41#define ERRnoaccess 5 /* Access denied, the client's context does not permit the requested function. This includes the following conditions: invalid rename command, write to Fid open for read only, read on Fid open for write only, attempt to delete a non-empty directory */ 41 a data file, invalid seek mode. */
42#define ERRbadfid 6 /* Invalid file handle. The file handle specified was not recognized by the server. */ 42#define ERRbadfile 2 /* File not found. The last component
43#define ERRbadmcb 7 /* Memory control blocks destroyed. */ 43 of a file's pathname could not be
44#define ERRnomem 8 /* Insufficient server memory to perform the requested function. */ 44 found. */
45#define ERRbadmem 9 /* Invalid memory block address. */ 45#define ERRbadpath 3 /* Directory invalid. A directory
46#define ERRbadenv 10 /* Invalid environment. */ 46 component in a pathname could not be
47#define ERRbadformat 11 /* Invalid format. */ 47 found. */
48#define ERRbadaccess 12 /* Invalid open mode. */ 48#define ERRnofids 4 /* Too many open files. The server has
49#define ERRbaddata 13 /* Invalid data (generated only by IOCTL calls within the server). */ 49 no file handles available. */
50#define ERRbaddrive 15 /* Invalid drive specified. */ 50#define ERRnoaccess 5 /* Access denied, the client's context
51#define ERRremcd 16 /* A Delete Directory request attempted to remove the server's current directory. */ 51 does not permit the requested
52#define ERRdiffdevice 17 /* Not same device (e.g., a cross volume rename was attempted */ 52 function. This includes the
53#define ERRnofiles 18 /* A File Search command can find no more files matching the specified criteria. */ 53 following conditions: invalid rename
54#define ERRgeneral 31 54 command, write to Fid open for read
55#define ERRbadshare 32 /* The sharing mode specified for an Open conflicts with existing FIDs on the file. */ 55 only, read on Fid open for write
56#define ERRlock 33 /* A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process. */ 56 only, attempt to delete a non-empty
57#define ERRunsup 50 57 directory */
58#define ERRnosuchshare 67 58#define ERRbadfid 6 /* Invalid file handle. The file handle
59#define ERRfilexists 80 /* The file named in the request already exists. */ 59 specified was not recognized by the
60#define ERRinvparm 87 60 server. */
61#define ERRdiskfull 112 61#define ERRbadmcb 7 /* Memory control blocks destroyed. */
62#define ERRinvname 123 62#define ERRnomem 8 /* Insufficient server memory to
63#define ERRinvlevel 124 63 perform the requested function. */
64#define ERRdirnotempty 145 64#define ERRbadmem 9 /* Invalid memory block address. */
65#define ERRnotlocked 158 65#define ERRbadenv 10 /* Invalid environment. */
66#define ERRalreadyexists 183 66#define ERRbadformat 11 /* Invalid format. */
67#define ERRbadpipe 230 67#define ERRbadaccess 12 /* Invalid open mode. */
68#define ERRpipebusy 231 68#define ERRbaddata 13 /* Invalid data (generated only by
69#define ERRpipeclosing 232 69 IOCTL calls within the server). */
70#define ERRnotconnected 233 70#define ERRbaddrive 15 /* Invalid drive specified. */
71#define ERRmoredata 234 71#define ERRremcd 16 /* A Delete Directory request attempted
72#define ERReasnotsupported 282 72 to remove the server's current
73#define ErrQuota 0x200 /* The operation would cause a quota limit to be exceeded. */ 73 directory. */
74#define ErrNotALink 0x201 /* A link operation was performed on a pathname that 74#define ERRdiffdevice 17 /* Not same device (e.g., a cross
75 was not a link. */ 75 volume rename was attempted */
76#define ERRnofiles 18 /* A File Search command can find no
77 more files matching the specified
78 criteria. */
79#define ERRgeneral 31
80#define ERRbadshare 32 /* The sharing mode specified for an
81 Open conflicts with existing FIDs on
82 the file. */
83#define ERRlock 33 /* A Lock request conflicted with an
84 existing lock or specified an
85 invalid mode, or an Unlock requested
86 attempted to remove a lock held by
87 another process. */
88#define ERRunsup 50
89#define ERRnosuchshare 67
90#define ERRfilexists 80 /* The file named in the request
91 already exists. */
92#define ERRinvparm 87
93#define ERRdiskfull 112
94#define ERRinvname 123
95#define ERRinvlevel 124
96#define ERRdirnotempty 145
97#define ERRnotlocked 158
98#define ERRalreadyexists 183
99#define ERRbadpipe 230
100#define ERRpipebusy 231
101#define ERRpipeclosing 232
102#define ERRnotconnected 233
103#define ERRmoredata 234
104#define ERReasnotsupported 282
105#define ErrQuota 0x200 /* The operation would cause a quota
106 limit to be exceeded. */
107#define ErrNotALink 0x201 /* A link operation was performed on a
108 pathname that was not a link. */
76 109
77/* Following error codes may be generated with the ERRSRV error 110/* Below errors are used internally (do not come over the wire) for passthrough
78class.*/ 111 from STATUS codes to POSIX only */
112#define ErrTooManyLinks 0xFFFE
79 113
80#define ERRerror 1 /* Non-specific error code. It is returned under the following conditions: resource other than disk space exhausted (e.g. TIDs), first SMB command was not negotiate, multiple negotiates attempted, and internal server error. */ 114/* Following error codes may be generated with the ERRSRV error class.*/
81#define ERRbadpw 2 /* Bad password - name/password pair in a TreeConnect or Session Setup are invalid. */ 115
82#define ERRbadtype 3 /* used for indicating DFS referral needed */ 116#define ERRerror 1 /* Non-specific error code. It is
83#define ERRaccess 4 /* The client does not have the necessary access rights within the specified context for requested function. */ 117 returned under the following
84#define ERRinvtid 5 /* The Tid specified in a command was invalid. */ 118 conditions: resource other than disk
85#define ERRinvnetname 6 /* Invalid network name in tree connect. */ 119 space exhausted (e.g. TIDs), first
86#define ERRinvdevice 7 /* Invalid device - printer request made to non-printer connection or non-printer request made to printer connection. */ 120 SMB command was not negotiate,
87#define ERRqfull 49 /* Print queue full (files) -- returned by open print file. */ 121 multiple negotiates attempted, and
88#define ERRqtoobig 50 /* Print queue full -- no space. */ 122 internal server error. */
89#define ERRqeof 51 /* EOF on print queue dump */ 123#define ERRbadpw 2 /* Bad password - name/password pair in
90#define ERRinvpfid 52 /* Invalid print file FID. */ 124 a TreeConnect or Session Setup are
91#define ERRsmbcmd 64 /* The server did not recognize the command received. */ 125 invalid. */
92#define ERRsrverror 65 /* The server encountered an internal error, e.g., system file unavailable. */ 126#define ERRbadtype 3 /* used for indicating DFS referral
93#define ERRbadBID 66 /* (obsolete) */ 127 needed */
94#define ERRfilespecs 67 /* The Fid and pathname parameters contained an invalid combination of values. */ 128#define ERRaccess 4 /* The client does not have the
95#define ERRbadLink 68 /* (obsolete) */ 129 necessary access rights within the
96#define ERRbadpermits 69 /* The access permissions specified for a file or directory are not a valid combination. */ 130 specified context for requested
97#define ERRbadPID 70 131 function. */
98#define ERRsetattrmode 71 /* attribute (mode) is invalid */ 132#define ERRinvtid 5 /* The Tid specified in a command was
99#define ERRpaused 81 /* Server is paused */ 133 invalid. */
100#define ERRmsgoff 82 /* reserved - messaging off */ 134#define ERRinvnetname 6 /* Invalid network name in tree
101#define ERRnoroom 83 /* reserved - no room for message */ 135 connect. */
102#define ERRrmuns 87 /* reserved - too many remote names */ 136#define ERRinvdevice 7 /* Invalid device - printer request
103#define ERRtimeout 88 /* operation timed out */ 137 made to non-printer connection or
104#define ERRnoresource 89 /* No resources available for request */ 138 non-printer request made to printer
105#define ERRtoomanyuids 90 /* Too many UIDs active on this session */ 139 connection. */
106#define ERRbaduid 91 /* The UID is not known as a valid user */ 140#define ERRqfull 49 /* Print queue full (files) -- returned
107#define ERRusempx 250 /* temporarily unable to use raw */ 141 by open print file. */
108#define ERRusestd 251 /* temporarily unable to use either raw or mpx */ 142#define ERRqtoobig 50 /* Print queue full -- no space. */
109#define ERR_NOTIFY_ENUM_DIR 1024 143#define ERRqeof 51 /* EOF on print queue dump */
110#define ERRaccountexpired 2239 144#define ERRinvpfid 52 /* Invalid print file FID. */
111#define ERRbadclient 2240 145#define ERRsmbcmd 64 /* The server did not recognize the
112#define ERRbadLogonTime 2241 146 command received. */
113#define ERRpasswordExpired 2242 147#define ERRsrverror 65 /* The server encountered an internal
114#define ERRnetlogonNotStarted 2455 148 error, e.g., system file
115#define ERRnosupport 0xFFFF 149 unavailable. */
150#define ERRbadBID 66 /* (obsolete) */
151#define ERRfilespecs 67 /* The Fid and pathname parameters
152 contained an invalid combination of
153 values. */
154#define ERRbadLink 68 /* (obsolete) */
155#define ERRbadpermits 69 /* The access permissions specified for
156 a file or directory are not a valid
157 combination. */
158#define ERRbadPID 70
159#define ERRsetattrmode 71 /* attribute (mode) is invalid */
160#define ERRpaused 81 /* Server is paused */
161#define ERRmsgoff 82 /* reserved - messaging off */
162#define ERRnoroom 83 /* reserved - no room for message */
163#define ERRrmuns 87 /* reserved - too many remote names */
164#define ERRtimeout 88 /* operation timed out */
165#define ERRnoresource 89 /* No resources available for request
166 */
167#define ERRtoomanyuids 90 /* Too many UIDs active on this session
168 */
169#define ERRbaduid 91 /* The UID is not known as a valid user
170 */
171#define ERRusempx 250 /* temporarily unable to use raw */
172#define ERRusestd 251 /* temporarily unable to use either raw
173 or mpx */
174#define ERR_NOTIFY_ENUM_DIR 1024
175#define ERRaccountexpired 2239
176#define ERRbadclient 2240
177#define ERRbadLogonTime 2241
178#define ERRpasswordExpired 2242
179#define ERRnetlogonNotStarted 2455
180#define ERRnosupport 0xFFFF
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index af13e526b150..0046c219833d 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/transport.c 2 * fs/cifs/transport.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2002,2004 4 * Copyright (C) International Business Machines Corp., 2002,2005
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -41,7 +41,7 @@ AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
41 struct mid_q_entry *temp; 41 struct mid_q_entry *temp;
42 42
43 if (ses == NULL) { 43 if (ses == NULL) {
44 cERROR(1, ("Null session passed in to AllocMidQEntry ")); 44 cERROR(1, ("Null session passed in to AllocMidQEntry"));
45 return NULL; 45 return NULL;
46 } 46 }
47 if (ses->server == NULL) { 47 if (ses->server == NULL) {
@@ -79,7 +79,10 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
79 list_del(&midEntry->qhead); 79 list_del(&midEntry->qhead);
80 atomic_dec(&midCount); 80 atomic_dec(&midCount);
81 spin_unlock(&GlobalMid_Lock); 81 spin_unlock(&GlobalMid_Lock);
82 cifs_buf_release(midEntry->resp_buf); 82 if(midEntry->largeBuf)
83 cifs_buf_release(midEntry->resp_buf);
84 else
85 cifs_small_buf_release(midEntry->resp_buf);
83 mempool_free(midEntry, cifs_mid_poolp); 86 mempool_free(midEntry, cifs_mid_poolp);
84} 87}
85 88
@@ -182,14 +185,14 @@ smb_send(struct socket *ssocket, struct smb_hdr *smb_buffer,
182 185
183int 186int
184smb_sendv(struct socket *ssocket, struct smb_hdr *smb_buffer, 187smb_sendv(struct socket *ssocket, struct smb_hdr *smb_buffer,
185 unsigned int smb_buf_length, struct kvec * write_vector /* page list */, struct sockaddr *sin) 188 unsigned int smb_buf_length, struct kvec * write_vector
189 /* page list */, struct sockaddr *sin)
186{ 190{
187 int rc = 0; 191 int rc = 0;
188 int i = 0; 192 int i = 0;
189 struct msghdr smb_msg; 193 struct msghdr smb_msg;
190 number_of_pages += 1; /* account for SMB header */ 194 number_of_pages += 1; /* account for SMB header */
191 struct kvec * piov = kmalloc(number_of_pages * sizeof(struct kvec)); 195 struct kvec * piov = kmalloc(number_of_pages * sizeof(struct kvec));
192 if(i=0;i<num_pages-1;i++
193 unsigned len = smb_buf_length + 4; 196 unsigned len = smb_buf_length + 4;
194 197
195 if(ssocket == NULL) 198 if(ssocket == NULL)
@@ -213,7 +216,8 @@ smb_sendv(struct socket *ssocket, struct smb_hdr *smb_buffer,
213 dump_smb(smb_buffer, len); 216 dump_smb(smb_buffer, len);
214 217
215 while (len > 0) { 218 while (len > 0) {
216 rc = kernel_sendmsg(ssocket, &smb_msg, &iov, number_of_pages, len?); 219 rc = kernel_sendmsg(ssocket, &smb_msg, &iov, number_of_pages,
220 len);
217 if ((rc == -ENOSPC) || (rc == -EAGAIN)) { 221 if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
218 i++; 222 i++;
219 if(i > 60) { 223 if(i > 60) {
@@ -266,6 +270,9 @@ CIFSSendRcv(const unsigned int xid, struct cifsSesInfo *ses,
266 270
267 271
268 272
273 if(ses->server->tcpStatus == CIFS_EXITING)
274 return -ENOENT;
275
269 /* Ensure that we do not send more than 50 overlapping requests 276 /* Ensure that we do not send more than 50 overlapping requests
270 to the same server. We may make this configurable later or 277 to the same server. We may make this configurable later or
271 use ses->maxReq */ 278 use ses->maxReq */
@@ -346,11 +353,12 @@ CIFSSendRcv(const unsigned int xid, struct cifsSesInfo *ses,
346 } 353 }
347 354
348 /* BB can we sign efficiently in this path? */ 355 /* BB can we sign efficiently in this path? */
349 rc = cifs_sign_smb(in_buf, ses, &midQ->sequence_number); 356 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
350 357
351 midQ->midState = MID_REQUEST_SUBMITTED; 358 midQ->midState = MID_REQUEST_SUBMITTED;
352/* rc = smb_sendv(ses->server->ssocket, in_buf, in_buf->smb_buf_length, piovec, 359/* rc = smb_sendv(ses->server->ssocket, in_buf, in_buf->smb_buf_length,
353 (struct sockaddr *) &(ses->server->addr.sockAddr));*/ 360 piovec,
361 (struct sockaddr *) &(ses->server->addr.sockAddr));*/
354 if(rc < 0) { 362 if(rc < 0) {
355 DeleteMidQEntry(midQ); 363 DeleteMidQEntry(midQ);
356 up(&ses->server->tcpSem); 364 up(&ses->server->tcpSem);
@@ -396,6 +404,9 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
396 return -EIO; 404 return -EIO;
397 } 405 }
398 406
407 if(ses->server->tcpStatus == CifsExiting)
408 return -ENOENT;
409
399 /* Ensure that we do not send more than 50 overlapping requests 410 /* Ensure that we do not send more than 50 overlapping requests
400 to the same server. We may make this configurable later or 411 to the same server. We may make this configurable later or
401 use ses->maxReq */ 412 use ses->maxReq */
@@ -405,7 +416,8 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
405 } else { 416 } else {
406 spin_lock(&GlobalMid_Lock); 417 spin_lock(&GlobalMid_Lock);
407 while(1) { 418 while(1) {
408 if(atomic_read(&ses->server->inFlight) >= cifs_max_pending){ 419 if(atomic_read(&ses->server->inFlight) >=
420 cifs_max_pending){
409 spin_unlock(&GlobalMid_Lock); 421 spin_unlock(&GlobalMid_Lock);
410 wait_event(ses->server->request_q, 422 wait_event(ses->server->request_q,
411 atomic_read(&ses->server->inFlight) 423 atomic_read(&ses->server->inFlight)
@@ -475,7 +487,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
475 return -EIO; 487 return -EIO;
476 } 488 }
477 489
478 rc = cifs_sign_smb(in_buf, ses, &midQ->sequence_number); 490 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
479 491
480 midQ->midState = MID_REQUEST_SUBMITTED; 492 midQ->midState = MID_REQUEST_SUBMITTED;
481 rc = smb_send(ses->server->ssocket, in_buf, in_buf->smb_buf_length, 493 rc = smb_send(ses->server->ssocket, in_buf, in_buf->smb_buf_length,
@@ -493,7 +505,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
493 up(&ses->server->tcpSem); 505 up(&ses->server->tcpSem);
494 if (long_op == -1) 506 if (long_op == -1)
495 goto cifs_no_response_exit; 507 goto cifs_no_response_exit;
496 else if (long_op == 2) /* writes past end of file can take looooong time */ 508 else if (long_op == 2) /* writes past end of file can take loong time */
497 timeout = 300 * HZ; 509 timeout = 300 * HZ;
498 else if (long_op == 1) 510 else if (long_op == 1)
499 timeout = 45 * HZ; /* should be greater than 511 timeout = 45 * HZ; /* should be greater than
@@ -559,8 +571,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
559 } 571 }
560 572
561 if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { 573 if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
562 cERROR(1, 574 cERROR(1, ("Frame too large received. Length: %d Xid: %d",
563 ("Frame too large received. Length: %d Xid: %d",
564 receive_len, xid)); 575 receive_len, xid));
565 rc = -EIO; 576 rc = -EIO;
566 } else { /* rcvd frame is ok */ 577 } else { /* rcvd frame is ok */
@@ -575,15 +586,20 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
575 dump_smb(out_buf, 92); 586 dump_smb(out_buf, 92);
576 /* convert the length into a more usable form */ 587 /* convert the length into a more usable form */
577 if((receive_len > 24) && 588 if((receive_len > 24) &&
578 (ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))) { 589 (ses->server->secMode & (SECMODE_SIGN_REQUIRED |
579 rc = cifs_verify_signature(out_buf, ses->mac_signing_key,midQ->sequence_number); /* BB fix BB */ 590 SECMODE_SIGN_ENABLED))) {
580 if(rc) 591 rc = cifs_verify_signature(out_buf,
581 cFYI(1,("Unexpected signature received from server")); 592 ses->server->mac_signing_key,
593 midQ->sequence_number+1);
594 if(rc) {
595 cERROR(1,("Unexpected SMB signature"));
596 /* BB FIXME add code to kill session */
597 }
582 } 598 }
583 599
584 *pbytes_returned = out_buf->smb_buf_length; 600 *pbytes_returned = out_buf->smb_buf_length;
585 601
586 /* BB special case reconnect tid and reconnect uid here? */ 602 /* BB special case reconnect tid and uid here? */
587 rc = map_smb_to_linux_error(out_buf); 603 rc = map_smb_to_linux_error(out_buf);
588 604
589 /* convert ByteCount if necessary */ 605 /* convert ByteCount if necessary */
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 549afa184fd6..c1e02eff1d25 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -83,7 +83,8 @@ int cifs_removexattr(struct dentry * direntry, const char * ea_name)
83 83
84 ea_name+=5; /* skip past user. prefix */ 84 ea_name+=5; /* skip past user. prefix */
85 rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,NULL, 85 rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,NULL,
86 (__u16)0, cifs_sb->local_nls); 86 (__u16)0, cifs_sb->local_nls,
87 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
87 } 88 }
88remove_ea_exit: 89remove_ea_exit:
89 if (full_path) 90 if (full_path)
@@ -147,32 +148,40 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name,
147 } 148 }
148 ea_name += 5; /* skip past user. prefix */ 149 ea_name += 5; /* skip past user. prefix */
149 rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value, 150 rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value,
150 (__u16)value_size, cifs_sb->local_nls); 151 (__u16)value_size, cifs_sb->local_nls,
152 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
151 } else if(strncmp(ea_name, CIFS_XATTR_OS2_PREFIX,4) == 0) { 153 } else if(strncmp(ea_name, CIFS_XATTR_OS2_PREFIX,4) == 0) {
152 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 154 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
153 goto set_ea_exit; 155 goto set_ea_exit;
154 156
155 ea_name += 4; /* skip past os2. prefix */ 157 ea_name += 4; /* skip past os2. prefix */
156 rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value, 158 rc = CIFSSMBSetEA(xid,pTcon,full_path,ea_name,ea_value,
157 (__u16)value_size, cifs_sb->local_nls); 159 (__u16)value_size, cifs_sb->local_nls,
160 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
158 } else { 161 } else {
159 int temp; 162 int temp;
160 temp = strncmp(ea_name,POSIX_ACL_XATTR_ACCESS, 163 temp = strncmp(ea_name,POSIX_ACL_XATTR_ACCESS,
161 strlen(POSIX_ACL_XATTR_ACCESS)); 164 strlen(POSIX_ACL_XATTR_ACCESS));
162 if (temp == 0) { 165 if (temp == 0) {
163#ifdef CONFIG_CIFS_POSIX 166#ifdef CONFIG_CIFS_POSIX
164 rc = CIFSSMBSetPosixACL(xid, pTcon,full_path,ea_value, 167 if(sb->s_flags & MS_POSIXACL)
165 (const int)value_size, ACL_TYPE_ACCESS, 168 rc = CIFSSMBSetPosixACL(xid, pTcon,full_path,
166 cifs_sb->local_nls); 169 ea_value, (const int)value_size,
170 ACL_TYPE_ACCESS,cifs_sb->local_nls,
171 cifs_sb->mnt_cifs_flags &
172 CIFS_MOUNT_MAP_SPECIAL_CHR);
167 cFYI(1,("set POSIX ACL rc %d",rc)); 173 cFYI(1,("set POSIX ACL rc %d",rc));
168#else 174#else
169 cFYI(1,("set POSIX ACL not supported")); 175 cFYI(1,("set POSIX ACL not supported"));
170#endif 176#endif
171 } else if(strncmp(ea_name,POSIX_ACL_XATTR_DEFAULT,strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) { 177 } else if(strncmp(ea_name,POSIX_ACL_XATTR_DEFAULT,strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
172#ifdef CONFIG_CIFS_POSIX 178#ifdef CONFIG_CIFS_POSIX
173 rc = CIFSSMBSetPosixACL(xid, pTcon,full_path,ea_value, 179 if(sb->s_flags & MS_POSIXACL)
174 (const int)value_size, ACL_TYPE_DEFAULT, 180 rc = CIFSSMBSetPosixACL(xid, pTcon,full_path,
175 cifs_sb->local_nls); 181 ea_value, (const int)value_size,
182 ACL_TYPE_DEFAULT, cifs_sb->local_nls,
183 cifs_sb->mnt_cifs_flags &
184 CIFS_MOUNT_MAP_SPECIAL_CHR);
176 cFYI(1,("set POSIX default ACL rc %d",rc)); 185 cFYI(1,("set POSIX default ACL rc %d",rc));
177#else 186#else
178 cFYI(1,("set default POSIX ACL not supported")); 187 cFYI(1,("set default POSIX ACL not supported"));
@@ -238,27 +247,35 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name,
238 } /* BB add else when above is implemented */ 247 } /* BB add else when above is implemented */
239 ea_name += 5; /* skip past user. prefix */ 248 ea_name += 5; /* skip past user. prefix */
240 rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value, 249 rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value,
241 buf_size, cifs_sb->local_nls); 250 buf_size, cifs_sb->local_nls,
251 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
242 } else if(strncmp(ea_name, CIFS_XATTR_OS2_PREFIX,4) == 0) { 252 } else if(strncmp(ea_name, CIFS_XATTR_OS2_PREFIX,4) == 0) {
243 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 253 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
244 goto get_ea_exit; 254 goto get_ea_exit;
245 255
246 ea_name += 4; /* skip past os2. prefix */ 256 ea_name += 4; /* skip past os2. prefix */
247 rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value, 257 rc = CIFSSMBQueryEA(xid,pTcon,full_path,ea_name,ea_value,
248 buf_size, cifs_sb->local_nls); 258 buf_size, cifs_sb->local_nls,
259 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
249 } else if(strncmp(ea_name,POSIX_ACL_XATTR_ACCESS,strlen(POSIX_ACL_XATTR_ACCESS)) == 0) { 260 } else if(strncmp(ea_name,POSIX_ACL_XATTR_ACCESS,strlen(POSIX_ACL_XATTR_ACCESS)) == 0) {
250#ifdef CONFIG_CIFS_POSIX 261#ifdef CONFIG_CIFS_POSIX
251 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, 262 if(sb->s_flags & MS_POSIXACL)
263 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
252 ea_value, buf_size, ACL_TYPE_ACCESS, 264 ea_value, buf_size, ACL_TYPE_ACCESS,
253 cifs_sb->local_nls); 265 cifs_sb->local_nls,
266 cifs_sb->mnt_cifs_flags &
267 CIFS_MOUNT_MAP_SPECIAL_CHR);
254#else 268#else
255 cFYI(1,("query POSIX ACL not supported yet")); 269 cFYI(1,("query POSIX ACL not supported yet"));
256#endif /* CONFIG_CIFS_POSIX */ 270#endif /* CONFIG_CIFS_POSIX */
257 } else if(strncmp(ea_name,POSIX_ACL_XATTR_DEFAULT,strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) { 271 } else if(strncmp(ea_name,POSIX_ACL_XATTR_DEFAULT,strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
258#ifdef CONFIG_CIFS_POSIX 272#ifdef CONFIG_CIFS_POSIX
259 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, 273 if(sb->s_flags & MS_POSIXACL)
274 rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
260 ea_value, buf_size, ACL_TYPE_DEFAULT, 275 ea_value, buf_size, ACL_TYPE_DEFAULT,
261 cifs_sb->local_nls); 276 cifs_sb->local_nls,
277 cifs_sb->mnt_cifs_flags &
278 CIFS_MOUNT_MAP_SPECIAL_CHR);
262#else 279#else
263 cFYI(1,("query POSIX default ACL not supported yet")); 280 cFYI(1,("query POSIX default ACL not supported yet"));
264#endif 281#endif
@@ -324,7 +341,9 @@ ssize_t cifs_listxattr(struct dentry * direntry, char * data, size_t buf_size)
324 search server for EAs or streams to 341 search server for EAs or streams to
325 returns as xattrs */ 342 returns as xattrs */
326 rc = CIFSSMBQAllEAs(xid,pTcon,full_path,data,buf_size, 343 rc = CIFSSMBQAllEAs(xid,pTcon,full_path,data,buf_size,
327 cifs_sb->local_nls); 344 cifs_sb->local_nls,
345 cifs_sb->mnt_cifs_flags &
346 CIFS_MOUNT_MAP_SPECIAL_CHR);
328 347
329 if (full_path) 348 if (full_path)
330 kfree(full_path); 349 kfree(full_path);
diff --git a/fs/compat.c b/fs/compat.c
index 67c0b94d1148..728cd8365384 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -809,7 +809,7 @@ static void *do_smb_super_data_conv(void *raw_data)
809 809
810struct compat_nfs_string { 810struct compat_nfs_string {
811 compat_uint_t len; 811 compat_uint_t len;
812 compat_uptr_t __user data; 812 compat_uptr_t data;
813}; 813};
814 814
815static inline void compat_nfs_string(struct nfs_string *dst, 815static inline void compat_nfs_string(struct nfs_string *dst,
@@ -834,10 +834,10 @@ struct compat_nfs4_mount_data_v1 {
834 struct compat_nfs_string mnt_path; 834 struct compat_nfs_string mnt_path;
835 struct compat_nfs_string hostname; 835 struct compat_nfs_string hostname;
836 compat_uint_t host_addrlen; 836 compat_uint_t host_addrlen;
837 compat_uptr_t __user host_addr; 837 compat_uptr_t host_addr;
838 compat_int_t proto; 838 compat_int_t proto;
839 compat_int_t auth_flavourlen; 839 compat_int_t auth_flavourlen;
840 compat_uptr_t __user auth_flavours; 840 compat_uptr_t auth_flavours;
841}; 841};
842 842
843static int do_nfs4_super_data_conv(void *raw_data) 843static int do_nfs4_super_data_conv(void *raw_data)
diff --git a/fs/dcache.c b/fs/dcache.c
index 496a4e08369c..3aa8a7e980d8 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -39,7 +39,7 @@ int sysctl_vfs_cache_pressure = 100;
39EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure); 39EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure);
40 40
41 __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock); 41 __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock);
42seqlock_t rename_lock __cacheline_aligned_in_smp = SEQLOCK_UNLOCKED; 42static seqlock_t rename_lock __cacheline_aligned_in_smp = SEQLOCK_UNLOCKED;
43 43
44EXPORT_SYMBOL(dcache_lock); 44EXPORT_SYMBOL(dcache_lock);
45 45
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 05b966cd6f76..9900e333655a 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -320,7 +320,7 @@ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
320/* 320/*
321 * This semaphore is used to serialize ep_free() and eventpoll_release_file(). 321 * This semaphore is used to serialize ep_free() and eventpoll_release_file().
322 */ 322 */
323struct semaphore epsem; 323static struct semaphore epsem;
324 324
325/* Safe wake up implementation */ 325/* Safe wake up implementation */
326static struct poll_safewake psw; 326static struct poll_safewake psw;
diff --git a/fs/exec.c b/fs/exec.c
index a8394499926c..e56ee2437025 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -197,7 +197,8 @@ static int count(char __user * __user * argv, int max)
197 * memory to free pages in kernel mem. These are in a format ready 197 * memory to free pages in kernel mem. These are in a format ready
198 * to be put directly into the top of new user memory. 198 * to be put directly into the top of new user memory.
199 */ 199 */
200int copy_strings(int argc,char __user * __user * argv, struct linux_binprm *bprm) 200static int copy_strings(int argc, char __user * __user * argv,
201 struct linux_binprm *bprm)
201{ 202{
202 struct page *kmapped_page = NULL; 203 struct page *kmapped_page = NULL;
203 char *kaddr = NULL; 204 char *kaddr = NULL;
@@ -868,9 +869,11 @@ int flush_old_exec(struct linux_binprm * bprm)
868 if (current->euid == current->uid && current->egid == current->gid) 869 if (current->euid == current->uid && current->egid == current->gid)
869 current->mm->dumpable = 1; 870 current->mm->dumpable = 1;
870 name = bprm->filename; 871 name = bprm->filename;
872
873 /* Copies the binary name from after last slash */
871 for (i=0; (ch = *(name++)) != '\0';) { 874 for (i=0; (ch = *(name++)) != '\0';) {
872 if (ch == '/') 875 if (ch == '/')
873 i = 0; 876 i = 0; /* overwrite what we wrote */
874 else 877 else
875 if (i < (sizeof(tcomm) - 1)) 878 if (i < (sizeof(tcomm) - 1))
876 tcomm[i++] = ch; 879 tcomm[i++] = ch;
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 040eb288bb1c..0d5fa73b18dc 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -455,12 +455,11 @@ static unsigned long ext3_find_near(struct inode *inode, Indirect *ind)
455 * @goal: place to store the result. 455 * @goal: place to store the result.
456 * 456 *
457 * Normally this function find the prefered place for block allocation, 457 * Normally this function find the prefered place for block allocation,
458 * stores it in *@goal and returns zero. If the branch had been changed 458 * stores it in *@goal and returns zero.
459 * under us we return -EAGAIN.
460 */ 459 */
461 460
462static int ext3_find_goal(struct inode *inode, long block, Indirect chain[4], 461static unsigned long ext3_find_goal(struct inode *inode, long block,
463 Indirect *partial, unsigned long *goal) 462 Indirect chain[4], Indirect *partial)
464{ 463{
465 struct ext3_block_alloc_info *block_i = EXT3_I(inode)->i_block_alloc_info; 464 struct ext3_block_alloc_info *block_i = EXT3_I(inode)->i_block_alloc_info;
466 465
@@ -470,15 +469,10 @@ static int ext3_find_goal(struct inode *inode, long block, Indirect chain[4],
470 */ 469 */
471 if (block_i && (block == block_i->last_alloc_logical_block + 1) 470 if (block_i && (block == block_i->last_alloc_logical_block + 1)
472 && (block_i->last_alloc_physical_block != 0)) { 471 && (block_i->last_alloc_physical_block != 0)) {
473 *goal = block_i->last_alloc_physical_block + 1; 472 return block_i->last_alloc_physical_block + 1;
474 return 0;
475 } 473 }
476 474
477 if (verify_chain(chain, partial)) { 475 return ext3_find_near(inode, partial);
478 *goal = ext3_find_near(inode, partial);
479 return 0;
480 }
481 return -EAGAIN;
482} 476}
483 477
484/** 478/**
@@ -582,12 +576,9 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
582 * @where: location of missing link 576 * @where: location of missing link
583 * @num: number of blocks we are adding 577 * @num: number of blocks we are adding
584 * 578 *
585 * This function verifies that chain (up to the missing link) had not 579 * This function fills the missing link and does all housekeeping needed in
586 * changed, fills the missing link and does all housekeeping needed in
587 * inode (->i_blocks, etc.). In case of success we end up with the full 580 * inode (->i_blocks, etc.). In case of success we end up with the full
588 * chain to new block and return 0. Otherwise (== chain had been changed) 581 * chain to new block and return 0.
589 * we free the new blocks (forgetting their buffer_heads, indeed) and
590 * return -EAGAIN.
591 */ 582 */
592 583
593static int ext3_splice_branch(handle_t *handle, struct inode *inode, long block, 584static int ext3_splice_branch(handle_t *handle, struct inode *inode, long block,
@@ -608,12 +599,6 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode, long block,
608 if (err) 599 if (err)
609 goto err_out; 600 goto err_out;
610 } 601 }
611 /* Verify that place we are splicing to is still there and vacant */
612
613 if (!verify_chain(chain, where-1) || *where->p)
614 /* Writer: end */
615 goto changed;
616
617 /* That's it */ 602 /* That's it */
618 603
619 *where->p = where->key; 604 *where->p = where->key;
@@ -657,26 +642,11 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode, long block,
657 } 642 }
658 return err; 643 return err;
659 644
660changed:
661 /*
662 * AKPM: if where[i].bh isn't part of the current updating
663 * transaction then we explode nastily. Test this code path.
664 */
665 jbd_debug(1, "the chain changed: try again\n");
666 err = -EAGAIN;
667
668err_out: 645err_out:
669 for (i = 1; i < num; i++) { 646 for (i = 1; i < num; i++) {
670 BUFFER_TRACE(where[i].bh, "call journal_forget"); 647 BUFFER_TRACE(where[i].bh, "call journal_forget");
671 ext3_journal_forget(handle, where[i].bh); 648 ext3_journal_forget(handle, where[i].bh);
672 } 649 }
673 /* For the normal collision cleanup case, we free up the blocks.
674 * On genuine filesystem errors we don't even think about doing
675 * that. */
676 if (err == -EAGAIN)
677 for (i = 0; i < num; i++)
678 ext3_free_blocks(handle, inode,
679 le32_to_cpu(where[i].key), 1);
680 return err; 650 return err;
681} 651}
682 652
@@ -708,7 +678,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
708 unsigned long goal; 678 unsigned long goal;
709 int left; 679 int left;
710 int boundary = 0; 680 int boundary = 0;
711 int depth = ext3_block_to_path(inode, iblock, offsets, &boundary); 681 const int depth = ext3_block_to_path(inode, iblock, offsets, &boundary);
712 struct ext3_inode_info *ei = EXT3_I(inode); 682 struct ext3_inode_info *ei = EXT3_I(inode);
713 683
714 J_ASSERT(handle != NULL || create == 0); 684 J_ASSERT(handle != NULL || create == 0);
@@ -716,54 +686,55 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
716 if (depth == 0) 686 if (depth == 0)
717 goto out; 687 goto out;
718 688
719reread:
720 partial = ext3_get_branch(inode, depth, offsets, chain, &err); 689 partial = ext3_get_branch(inode, depth, offsets, chain, &err);
721 690
722 /* Simplest case - block found, no allocation needed */ 691 /* Simplest case - block found, no allocation needed */
723 if (!partial) { 692 if (!partial) {
724 clear_buffer_new(bh_result); 693 clear_buffer_new(bh_result);
725got_it: 694 goto got_it;
726 map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key));
727 if (boundary)
728 set_buffer_boundary(bh_result);
729 /* Clean up and exit */
730 partial = chain+depth-1; /* the whole chain */
731 goto cleanup;
732 } 695 }
733 696
734 /* Next simple case - plain lookup or failed read of indirect block */ 697 /* Next simple case - plain lookup or failed read of indirect block */
735 if (!create || err == -EIO) { 698 if (!create || err == -EIO)
736cleanup: 699 goto cleanup;
700
701 down(&ei->truncate_sem);
702
703 /*
704 * If the indirect block is missing while we are reading
705 * the chain(ext3_get_branch() returns -EAGAIN err), or
706 * if the chain has been changed after we grab the semaphore,
707 * (either because another process truncated this branch, or
708 * another get_block allocated this branch) re-grab the chain to see if
709 * the request block has been allocated or not.
710 *
711 * Since we already block the truncate/other get_block
712 * at this point, we will have the current copy of the chain when we
713 * splice the branch into the tree.
714 */
715 if (err == -EAGAIN || !verify_chain(chain, partial)) {
737 while (partial > chain) { 716 while (partial > chain) {
738 BUFFER_TRACE(partial->bh, "call brelse");
739 brelse(partial->bh); 717 brelse(partial->bh);
740 partial--; 718 partial--;
741 } 719 }
742 BUFFER_TRACE(bh_result, "returned"); 720 partial = ext3_get_branch(inode, depth, offsets, chain, &err);
743out: 721 if (!partial) {
744 return err; 722 up(&ei->truncate_sem);
723 if (err)
724 goto cleanup;
725 clear_buffer_new(bh_result);
726 goto got_it;
727 }
745 } 728 }
746 729
747 /* 730 /*
748 * Indirect block might be removed by truncate while we were 731 * Okay, we need to do block allocation. Lazily initialize the block
749 * reading it. Handling of that case (forget what we've got and 732 * allocation info here if necessary
750 * reread) is taken out of the main path. 733 */
751 */ 734 if (S_ISREG(inode->i_mode) && (!ei->i_block_alloc_info))
752 if (err == -EAGAIN)
753 goto changed;
754
755 goal = 0;
756 down(&ei->truncate_sem);
757
758 /* lazy initialize the block allocation info here if necessary */
759 if (S_ISREG(inode->i_mode) && (!ei->i_block_alloc_info)) {
760 ext3_init_block_alloc_info(inode); 735 ext3_init_block_alloc_info(inode);
761 }
762 736
763 if (ext3_find_goal(inode, iblock, chain, partial, &goal) < 0) { 737 goal = ext3_find_goal(inode, iblock, chain, partial);
764 up(&ei->truncate_sem);
765 goto changed;
766 }
767 738
768 left = (chain + depth) - partial; 739 left = (chain + depth) - partial;
769 740
@@ -771,38 +742,45 @@ out:
771 * Block out ext3_truncate while we alter the tree 742 * Block out ext3_truncate while we alter the tree
772 */ 743 */
773 err = ext3_alloc_branch(handle, inode, left, goal, 744 err = ext3_alloc_branch(handle, inode, left, goal,
774 offsets+(partial-chain), partial); 745 offsets + (partial - chain), partial);
775 746
776 /* The ext3_splice_branch call will free and forget any buffers 747 /*
748 * The ext3_splice_branch call will free and forget any buffers
777 * on the new chain if there is a failure, but that risks using 749 * on the new chain if there is a failure, but that risks using
778 * up transaction credits, especially for bitmaps where the 750 * up transaction credits, especially for bitmaps where the
779 * credits cannot be returned. Can we handle this somehow? We 751 * credits cannot be returned. Can we handle this somehow? We
780 * may need to return -EAGAIN upwards in the worst case. --sct */ 752 * may need to return -EAGAIN upwards in the worst case. --sct
753 */
781 if (!err) 754 if (!err)
782 err = ext3_splice_branch(handle, inode, iblock, chain, 755 err = ext3_splice_branch(handle, inode, iblock, chain,
783 partial, left); 756 partial, left);
784 /* i_disksize growing is protected by truncate_sem 757 /*
785 * don't forget to protect it if you're about to implement 758 * i_disksize growing is protected by truncate_sem. Don't forget to
786 * concurrent ext3_get_block() -bzzz */ 759 * protect it if you're about to implement concurrent
760 * ext3_get_block() -bzzz
761 */
787 if (!err && extend_disksize && inode->i_size > ei->i_disksize) 762 if (!err && extend_disksize && inode->i_size > ei->i_disksize)
788 ei->i_disksize = inode->i_size; 763 ei->i_disksize = inode->i_size;
789 up(&ei->truncate_sem); 764 up(&ei->truncate_sem);
790 if (err == -EAGAIN)
791 goto changed;
792 if (err) 765 if (err)
793 goto cleanup; 766 goto cleanup;
794 767
795 set_buffer_new(bh_result); 768 set_buffer_new(bh_result);
796 goto got_it; 769got_it:
797 770 map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key));
798changed: 771 if (boundary)
772 set_buffer_boundary(bh_result);
773 /* Clean up and exit */
774 partial = chain + depth - 1; /* the whole chain */
775cleanup:
799 while (partial > chain) { 776 while (partial > chain) {
800 jbd_debug(1, "buffer chain changed, retrying\n"); 777 BUFFER_TRACE(partial->bh, "call brelse");
801 BUFFER_TRACE(partial->bh, "brelsing");
802 brelse(partial->bh); 778 brelse(partial->bh);
803 partial--; 779 partial--;
804 } 780 }
805 goto reread; 781 BUFFER_TRACE(bh_result, "returned");
782out:
783 return err;
806} 784}
807 785
808static int ext3_get_block(struct inode *inode, sector_t iblock, 786static int ext3_get_block(struct inode *inode, sector_t iblock,
@@ -866,12 +844,6 @@ get_block:
866 return ret; 844 return ret;
867} 845}
868 846
869static int ext3_writepages_get_block(struct inode *inode, sector_t iblock,
870 struct buffer_head *bh, int create)
871{
872 return ext3_direct_io_get_blocks(inode, iblock, 1, bh, create);
873}
874
875/* 847/*
876 * `handle' can be NULL if create is zero 848 * `handle' can be NULL if create is zero
877 */ 849 */
@@ -1345,45 +1317,6 @@ out_fail:
1345 return ret; 1317 return ret;
1346} 1318}
1347 1319
1348static int
1349ext3_writeback_writepage_helper(struct page *page,
1350 struct writeback_control *wbc)
1351{
1352 return block_write_full_page(page, ext3_get_block, wbc);
1353}
1354
1355static int
1356ext3_writeback_writepages(struct address_space *mapping,
1357 struct writeback_control *wbc)
1358{
1359 struct inode *inode = mapping->host;
1360 handle_t *handle = NULL;
1361 int err, ret = 0;
1362
1363 if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
1364 return ret;
1365
1366 handle = ext3_journal_start(inode, ext3_writepage_trans_blocks(inode));
1367 if (IS_ERR(handle)) {
1368 ret = PTR_ERR(handle);
1369 return ret;
1370 }
1371
1372 ret = __mpage_writepages(mapping, wbc, ext3_writepages_get_block,
1373 ext3_writeback_writepage_helper);
1374
1375 /*
1376 * Need to reaquire the handle since ext3_writepages_get_block()
1377 * can restart the handle
1378 */
1379 handle = journal_current_handle();
1380
1381 err = ext3_journal_stop(handle);
1382 if (!ret)
1383 ret = err;
1384 return ret;
1385}
1386
1387static int ext3_writeback_writepage(struct page *page, 1320static int ext3_writeback_writepage(struct page *page,
1388 struct writeback_control *wbc) 1321 struct writeback_control *wbc)
1389{ 1322{
@@ -1621,7 +1554,6 @@ static struct address_space_operations ext3_writeback_aops = {
1621 .readpage = ext3_readpage, 1554 .readpage = ext3_readpage,
1622 .readpages = ext3_readpages, 1555 .readpages = ext3_readpages,
1623 .writepage = ext3_writeback_writepage, 1556 .writepage = ext3_writeback_writepage,
1624 .writepages = ext3_writeback_writepages,
1625 .sync_page = block_sync_page, 1557 .sync_page = block_sync_page,
1626 .prepare_write = ext3_prepare_write, 1558 .prepare_write = ext3_prepare_write,
1627 .commit_write = ext3_writeback_commit_write, 1559 .commit_write = ext3_writeback_commit_write,
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 3e7ab16ed154..286a9f8f3d49 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -15,6 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/security.h> 16#include <linux/security.h>
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/signal.h>
18 19
19#include <asm/poll.h> 20#include <asm/poll.h>
20#include <asm/siginfo.h> 21#include <asm/siginfo.h>
@@ -308,7 +309,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
308 break; 309 break;
309 case F_SETSIG: 310 case F_SETSIG:
310 /* arg == 0 restores default behaviour. */ 311 /* arg == 0 restores default behaviour. */
311 if (arg < 0 || arg > _NSIG) { 312 if (!valid_signal(arg)) {
312 break; 313 break;
313 } 314 }
314 err = 0; 315 err = 0;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index d6efb36cab2a..8e050fa58218 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -512,7 +512,8 @@ restart:
512} 512}
513 513
514/** 514/**
515 * sync_inodes 515 * sync_inodes - writes all inodes to disk
516 * @wait: wait for completion
516 * 517 *
517 * sync_inodes() goes through each super block's dirty inode list, writes the 518 * sync_inodes() goes through each super block's dirty inode list, writes the
518 * inodes out, waits on the writeout and puts the inodes back on the normal 519 * inodes out, waits on the writeout and puts the inodes back on the normal
@@ -604,6 +605,7 @@ EXPORT_SYMBOL(sync_inode);
604/** 605/**
605 * generic_osync_inode - flush all dirty data for a given inode to disk 606 * generic_osync_inode - flush all dirty data for a given inode to disk
606 * @inode: inode to write 607 * @inode: inode to write
608 * @mapping: the address_space that should be flushed
607 * @what: what to write and wait upon 609 * @what: what to write and wait upon
608 * 610 *
609 * This can be called by file_write functions for files which have the 611 * This can be called by file_write functions for files which have the
diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index 4efb640c4d0c..217e32f37e0b 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -333,6 +333,8 @@ void hfs_mdb_close(struct super_block *sb)
333 * Release the resources associated with the in-core MDB. */ 333 * Release the resources associated with the in-core MDB. */
334void hfs_mdb_put(struct super_block *sb) 334void hfs_mdb_put(struct super_block *sb)
335{ 335{
336 if (!HFS_SB(sb))
337 return;
336 /* free the B-trees */ 338 /* free the B-trees */
337 hfs_btree_close(HFS_SB(sb)->ext_tree); 339 hfs_btree_close(HFS_SB(sb)->ext_tree);
338 hfs_btree_close(HFS_SB(sb)->cat_tree); 340 hfs_btree_close(HFS_SB(sb)->cat_tree);
@@ -340,4 +342,7 @@ void hfs_mdb_put(struct super_block *sb)
340 /* free the buffers holding the primary and alternate MDBs */ 342 /* free the buffers holding the primary and alternate MDBs */
341 brelse(HFS_SB(sb)->mdb_bh); 343 brelse(HFS_SB(sb)->mdb_bh);
342 brelse(HFS_SB(sb)->alt_mdb_bh); 344 brelse(HFS_SB(sb)->alt_mdb_bh);
345
346 kfree(HFS_SB(sb));
347 sb->s_fs_info = NULL;
343} 348}
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 1e2c193134cc..ab783f6afa3b 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -297,7 +297,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
297 res = -EINVAL; 297 res = -EINVAL;
298 if (!parse_options((char *)data, sbi)) { 298 if (!parse_options((char *)data, sbi)) {
299 hfs_warn("hfs_fs: unable to parse mount options.\n"); 299 hfs_warn("hfs_fs: unable to parse mount options.\n");
300 goto bail3; 300 goto bail;
301 } 301 }
302 302
303 sb->s_op = &hfs_super_operations; 303 sb->s_op = &hfs_super_operations;
@@ -310,7 +310,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
310 hfs_warn("VFS: Can't find a HFS filesystem on dev %s.\n", 310 hfs_warn("VFS: Can't find a HFS filesystem on dev %s.\n",
311 hfs_mdb_name(sb)); 311 hfs_mdb_name(sb));
312 res = -EINVAL; 312 res = -EINVAL;
313 goto bail2; 313 goto bail;
314 } 314 }
315 315
316 /* try to get the root inode */ 316 /* try to get the root inode */
@@ -340,10 +340,8 @@ bail_iput:
340 iput(root_inode); 340 iput(root_inode);
341bail_no_root: 341bail_no_root:
342 hfs_warn("hfs_fs: get root inode failed.\n"); 342 hfs_warn("hfs_fs: get root inode failed.\n");
343bail:
343 hfs_mdb_put(sb); 344 hfs_mdb_put(sb);
344bail2:
345bail3:
346 kfree(sbi);
347 return res; 345 return res;
348} 346}
349 347
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 5f8044664a3c..d55ad67b8e42 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -208,7 +208,9 @@ static void hfsplus_write_super(struct super_block *sb)
208static void hfsplus_put_super(struct super_block *sb) 208static void hfsplus_put_super(struct super_block *sb)
209{ 209{
210 dprint(DBG_SUPER, "hfsplus_put_super\n"); 210 dprint(DBG_SUPER, "hfsplus_put_super\n");
211 if (!(sb->s_flags & MS_RDONLY)) { 211 if (!sb->s_fs_info)
212 return;
213 if (!(sb->s_flags & MS_RDONLY) && HFSPLUS_SB(sb).s_vhdr) {
212 struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr; 214 struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
213 215
214 vhdr->modify_date = hfsp_now2mt(); 216 vhdr->modify_date = hfsp_now2mt();
@@ -226,6 +228,8 @@ static void hfsplus_put_super(struct super_block *sb)
226 brelse(HFSPLUS_SB(sb).s_vhbh); 228 brelse(HFSPLUS_SB(sb).s_vhbh);
227 if (HFSPLUS_SB(sb).nls) 229 if (HFSPLUS_SB(sb).nls)
228 unload_nls(HFSPLUS_SB(sb).nls); 230 unload_nls(HFSPLUS_SB(sb).nls);
231 kfree(sb->s_fs_info);
232 sb->s_fs_info = NULL;
229} 233}
230 234
231static int hfsplus_statfs(struct super_block *sb, struct kstatfs *buf) 235static int hfsplus_statfs(struct super_block *sb, struct kstatfs *buf)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index a88ad2924851..14a0d339d036 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -521,7 +521,7 @@ int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
521static struct address_space_operations hostfs_aops = { 521static struct address_space_operations hostfs_aops = {
522 .writepage = hostfs_writepage, 522 .writepage = hostfs_writepage,
523 .readpage = hostfs_readpage, 523 .readpage = hostfs_readpage,
524/* .set_page_dirty = __set_page_dirty_nobuffers, */ 524 .set_page_dirty = __set_page_dirty_nobuffers,
525 .prepare_write = hostfs_prepare_write, 525 .prepare_write = hostfs_prepare_write,
526 .commit_write = hostfs_commit_write 526 .commit_write = hostfs_commit_write
527}; 527};
@@ -991,13 +991,17 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
991 goto out_put; 991 goto out_put;
992 992
993 err = read_inode(root_inode); 993 err = read_inode(root_inode);
994 if(err) 994 if(err){
995 goto out_put; 995 /* No iput in this case because the dput does that for us */
996 dput(sb->s_root);
997 sb->s_root = NULL;
998 goto out_free;
999 }
996 1000
997 return(0); 1001 return(0);
998 1002
999 out_put: 1003 out_put:
1000 iput(root_inode); 1004 iput(root_inode);
1001 out_free: 1005 out_free:
1002 kfree(name); 1006 kfree(name);
1003 out: 1007 out:
diff --git a/fs/inode.c b/fs/inode.c
index af8fd78d2099..801fe7f36280 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -26,7 +26,6 @@
26 * This is needed for the following functions: 26 * This is needed for the following functions:
27 * - inode_has_buffers 27 * - inode_has_buffers
28 * - invalidate_inode_buffers 28 * - invalidate_inode_buffers
29 * - fsync_bdev
30 * - invalidate_bdev 29 * - invalidate_bdev
31 * 30 *
32 * FIXME: remove all knowledge of the buffer layer from this file 31 * FIXME: remove all knowledge of the buffer layer from this file
@@ -332,14 +331,6 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
332 return busy; 331 return busy;
333} 332}
334 333
335/*
336 * This is a two-stage process. First we collect all
337 * offending inodes onto the throw-away list, and in
338 * the second stage we actually dispose of them. This
339 * is because we don't want to sleep while messing
340 * with the global lists..
341 */
342
343/** 334/**
344 * invalidate_inodes - discard the inodes on a device 335 * invalidate_inodes - discard the inodes on a device
345 * @sb: superblock 336 * @sb: superblock
@@ -366,16 +357,11 @@ int invalidate_inodes(struct super_block * sb)
366 357
367EXPORT_SYMBOL(invalidate_inodes); 358EXPORT_SYMBOL(invalidate_inodes);
368 359
369int __invalidate_device(struct block_device *bdev, int do_sync) 360int __invalidate_device(struct block_device *bdev)
370{ 361{
371 struct super_block *sb; 362 struct super_block *sb = get_super(bdev);
372 int res; 363 int res = 0;
373 364
374 if (do_sync)
375 fsync_bdev(bdev);
376
377 res = 0;
378 sb = get_super(bdev);
379 if (sb) { 365 if (sb) {
380 /* 366 /*
381 * no need to lock the super, get_super holds the 367 * no need to lock the super, get_super holds the
@@ -390,7 +376,6 @@ int __invalidate_device(struct block_device *bdev, int do_sync)
390 invalidate_bdev(bdev, 0); 376 invalidate_bdev(bdev, 0);
391 return res; 377 return res;
392} 378}
393
394EXPORT_SYMBOL(__invalidate_device); 379EXPORT_SYMBOL(__invalidate_device);
395 380
396static int can_unuse(struct inode *inode) 381static int can_unuse(struct inode *inode)
@@ -1336,7 +1321,7 @@ void __init inode_init(unsigned long mempages)
1336 1321
1337 /* inode slab cache */ 1322 /* inode slab cache */
1338 inode_cachep = kmem_cache_create("inode_cache", sizeof(struct inode), 1323 inode_cachep = kmem_cache_create("inode_cache", sizeof(struct inode),
1339 0, SLAB_PANIC, init_once, NULL); 1324 0, SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, init_once, NULL);
1340 set_shrinker(DEFAULT_SEEKS, shrink_icache_memory); 1325 set_shrinker(DEFAULT_SEEKS, shrink_icache_memory);
1341 1326
1342 /* Hash may have been set up in inode_init_early */ 1327 /* Hash may have been set up in inode_init_early */
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index fb42c3f3bf0d..34a44e451689 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -18,29 +18,12 @@
18 18
19#include <linux/config.h> 19#include <linux/config.h>
20#include <linux/module.h> 20#include <linux/module.h>
21
22#include <linux/stat.h>
23#include <linux/time.h>
24#include <linux/iso_fs.h>
25#include <linux/kernel.h>
26#include <linux/major.h>
27#include <linux/mm.h>
28#include <linux/string.h>
29#include <linux/slab.h>
30#include <linux/errno.h>
31#include <linux/init.h> 21#include <linux/init.h>
32#include <linux/nls.h> 22
33#include <linux/ctype.h>
34#include <linux/smp_lock.h>
35#include <linux/blkdev.h>
36#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
37#include <linux/zlib.h> 24#include <linux/zlib.h>
38#include <linux/buffer_head.h>
39
40#include <asm/system.h>
41#include <asm/uaccess.h>
42#include <asm/semaphore.h>
43 25
26#include "isofs.h"
44#include "zisofs.h" 27#include "zisofs.h"
45 28
46/* This should probably be global. */ 29/* This should probably be global. */
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index 14d86de6637d..6030956b894b 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -10,20 +10,9 @@
10 * 10 *
11 * isofs directory handling functions 11 * isofs directory handling functions
12 */ 12 */
13#include <linux/errno.h>
14#include <linux/fs.h>
15#include <linux/iso_fs.h>
16#include <linux/kernel.h>
17#include <linux/stat.h>
18#include <linux/string.h>
19#include <linux/mm.h>
20#include <linux/slab.h>
21#include <linux/time.h>
22#include <linux/config.h> 13#include <linux/config.h>
23#include <linux/smp_lock.h> 14#include <linux/smp_lock.h>
24#include <linux/buffer_head.h> 15#include "isofs.h"
25
26#include <asm/uaccess.h>
27 16
28static int isofs_readdir(struct file *, void *, filldir_t); 17static int isofs_readdir(struct file *, void *, filldir_t);
29 18
diff --git a/fs/isofs/export.c b/fs/isofs/export.c
index e4252c960871..4af856a7fda7 100644
--- a/fs/isofs/export.c
+++ b/fs/isofs/export.c
@@ -13,11 +13,7 @@
13 * fs/exportfs/expfs.c. 13 * fs/exportfs/expfs.c.
14 */ 14 */
15 15
16#include <linux/buffer_head.h> 16#include "isofs.h"
17#include <linux/errno.h>
18#include <linux/fs.h>
19#include <linux/iso_fs.h>
20#include <linux/kernel.h>
21 17
22static struct dentry * 18static struct dentry *
23isofs_export_iget(struct super_block *sb, 19isofs_export_iget(struct super_block *sb,
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index b9256e65e144..abd7b12eeca7 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -12,29 +12,18 @@
12 */ 12 */
13 13
14#include <linux/config.h> 14#include <linux/config.h>
15#include <linux/init.h>
15#include <linux/module.h> 16#include <linux/module.h>
16 17
17#include <linux/stat.h>
18#include <linux/time.h>
19#include <linux/iso_fs.h>
20#include <linux/kernel.h>
21#include <linux/major.h>
22#include <linux/mm.h>
23#include <linux/string.h>
24#include <linux/slab.h> 18#include <linux/slab.h>
25#include <linux/errno.h>
26#include <linux/cdrom.h>
27#include <linux/init.h>
28#include <linux/nls.h> 19#include <linux/nls.h>
29#include <linux/ctype.h> 20#include <linux/ctype.h>
30#include <linux/smp_lock.h> 21#include <linux/smp_lock.h>
31#include <linux/blkdev.h> 22#include <linux/statfs.h>
32#include <linux/buffer_head.h> 23#include <linux/cdrom.h>
33#include <linux/vfs.h>
34#include <linux/parser.h> 24#include <linux/parser.h>
35#include <asm/system.h>
36#include <asm/uaccess.h>
37 25
26#include "isofs.h"
38#include "zisofs.h" 27#include "zisofs.h"
39 28
40#define BEQUIET 29#define BEQUIET
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
new file mode 100644
index 000000000000..9ce7b51fb614
--- /dev/null
+++ b/fs/isofs/isofs.h
@@ -0,0 +1,190 @@
1#include <linux/fs.h>
2#include <linux/buffer_head.h>
3#include <linux/iso_fs.h>
4#include <asm/unaligned.h>
5
6enum isofs_file_format {
7 isofs_file_normal = 0,
8 isofs_file_sparse = 1,
9 isofs_file_compressed = 2,
10};
11
12/*
13 * iso fs inode data in memory
14 */
15struct iso_inode_info {
16 unsigned long i_iget5_block;
17 unsigned long i_iget5_offset;
18 unsigned int i_first_extent;
19 unsigned char i_file_format;
20 unsigned char i_format_parm[3];
21 unsigned long i_next_section_block;
22 unsigned long i_next_section_offset;
23 off_t i_section_size;
24 struct inode vfs_inode;
25};
26
27/*
28 * iso9660 super-block data in memory
29 */
30struct isofs_sb_info {
31 unsigned long s_ninodes;
32 unsigned long s_nzones;
33 unsigned long s_firstdatazone;
34 unsigned long s_log_zone_size;
35 unsigned long s_max_size;
36
37 unsigned char s_high_sierra; /* A simple flag */
38 unsigned char s_mapping;
39 int s_rock_offset; /* offset of SUSP fields within SU area */
40 unsigned char s_rock;
41 unsigned char s_joliet_level;
42 unsigned char s_utf8;
43 unsigned char s_cruft; /* Broken disks with high
44 byte of length containing
45 junk */
46 unsigned char s_unhide;
47 unsigned char s_nosuid;
48 unsigned char s_nodev;
49 unsigned char s_nocompress;
50
51 mode_t s_mode;
52 gid_t s_gid;
53 uid_t s_uid;
54 struct nls_table *s_nls_iocharset; /* Native language support table */
55};
56
57static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb)
58{
59 return sb->s_fs_info;
60}
61
62static inline struct iso_inode_info *ISOFS_I(struct inode *inode)
63{
64 return container_of(inode, struct iso_inode_info, vfs_inode);
65}
66
67static inline int isonum_711(char *p)
68{
69 return *(u8 *)p;
70}
71static inline int isonum_712(char *p)
72{
73 return *(s8 *)p;
74}
75static inline unsigned int isonum_721(char *p)
76{
77 return le16_to_cpu(get_unaligned((__le16 *)p));
78}
79static inline unsigned int isonum_722(char *p)
80{
81 return be16_to_cpu(get_unaligned((__le16 *)p));
82}
83static inline unsigned int isonum_723(char *p)
84{
85 /* Ignore bigendian datum due to broken mastering programs */
86 return le16_to_cpu(get_unaligned((__le16 *)p));
87}
88static inline unsigned int isonum_731(char *p)
89{
90 return le32_to_cpu(get_unaligned((__le32 *)p));
91}
92static inline unsigned int isonum_732(char *p)
93{
94 return be32_to_cpu(get_unaligned((__le32 *)p));
95}
96static inline unsigned int isonum_733(char *p)
97{
98 /* Ignore bigendian datum due to broken mastering programs */
99 return le32_to_cpu(get_unaligned((__le32 *)p));
100}
101extern int iso_date(char *, int);
102
103struct inode; /* To make gcc happy */
104
105extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *);
106extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
107extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
108
109int get_joliet_filename(struct iso_directory_record *, unsigned char *, struct inode *);
110int get_acorn_filename(struct iso_directory_record *, char *, struct inode *);
111
112extern struct dentry *isofs_lookup(struct inode *, struct dentry *, struct nameidata *);
113extern struct buffer_head *isofs_bread(struct inode *, sector_t);
114extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long);
115
116extern struct inode *isofs_iget(struct super_block *sb,
117 unsigned long block,
118 unsigned long offset);
119
120/* Because the inode number is no longer relevant to finding the
121 * underlying meta-data for an inode, we are free to choose a more
122 * convenient 32-bit number as the inode number. The inode numbering
123 * scheme was recommended by Sergey Vlasov and Eric Lammerts. */
124static inline unsigned long isofs_get_ino(unsigned long block,
125 unsigned long offset,
126 unsigned long bufbits)
127{
128 return (block << (bufbits - 5)) | (offset >> 5);
129}
130
131/* Every directory can have many redundant directory entries scattered
132 * throughout the directory tree. First there is the directory entry
133 * with the name of the directory stored in the parent directory.
134 * Then, there is the "." directory entry stored in the directory
135 * itself. Finally, there are possibly many ".." directory entries
136 * stored in all the subdirectories.
137 *
138 * In order for the NFS get_parent() method to work and for the
139 * general consistency of the dcache, we need to make sure the
140 * "i_iget5_block" and "i_iget5_offset" all point to exactly one of
141 * the many redundant entries for each directory. We normalize the
142 * block and offset by always making them point to the "." directory.
143 *
144 * Notice that we do not use the entry for the directory with the name
145 * that is located in the parent directory. Even though choosing this
146 * first directory is more natural, it is much easier to find the "."
147 * entry in the NFS get_parent() method because it is implicitly
148 * encoded in the "extent + ext_attr_length" fields of _all_ the
149 * redundant entries for the directory. Thus, it can always be
150 * reached regardless of which directory entry you have in hand.
151 *
152 * This works because the "." entry is simply the first directory
153 * record when you start reading the file that holds all the directory
154 * records, and this file starts at "extent + ext_attr_length" blocks.
155 * Because the "." entry is always the first entry listed in the
156 * directories file, the normalized "offset" value is always 0.
157 *
158 * You should pass the directory entry in "de". On return, "block"
159 * and "offset" will hold normalized values. Only directories are
160 * affected making it safe to call even for non-directory file
161 * types. */
162static inline void
163isofs_normalize_block_and_offset(struct iso_directory_record* de,
164 unsigned long *block,
165 unsigned long *offset)
166{
167 /* Only directories are normalized. */
168 if (de->flags[0] & 2) {
169 *offset = 0;
170 *block = (unsigned long)isonum_733(de->extent)
171 + (unsigned long)isonum_711(de->ext_attr_length);
172 }
173}
174
175extern struct inode_operations isofs_dir_inode_operations;
176extern struct file_operations isofs_dir_operations;
177extern struct address_space_operations isofs_symlink_aops;
178extern struct export_operations isofs_export_ops;
179
180/* The following macros are used to check for memory leaks. */
181#ifdef LEAK_CHECK
182#define free_s leak_check_free_s
183#define malloc leak_check_malloc
184#define sb_bread leak_check_bread
185#define brelse leak_check_brelse
186extern void * leak_check_malloc(unsigned int size);
187extern void leak_check_free_s(void * obj, int size);
188extern struct buffer_head * leak_check_bread(struct super_block *sb, int block);
189extern void leak_check_brelse(struct buffer_head * bh);
190#endif /* LEAK_CHECK */
diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c
index 86c50e22fc87..2931de7f1a6a 100644
--- a/fs/isofs/joliet.c
+++ b/fs/isofs/joliet.c
@@ -6,11 +6,9 @@
6 * Joliet: Microsoft's Unicode extensions to iso9660 6 * Joliet: Microsoft's Unicode extensions to iso9660
7 */ 7 */
8 8
9#include <linux/string.h> 9#include <linux/types.h>
10#include <linux/nls.h> 10#include <linux/nls.h>
11#include <linux/mm.h> 11#include "isofs.h"
12#include <linux/iso_fs.h>
13#include <asm/unaligned.h>
14 12
15/* 13/*
16 * Convert Unicode 16 to UTF8 or ASCII. 14 * Convert Unicode 16 to UTF8 or ASCII.
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 9569fc44102d..690edf37173c 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -6,20 +6,9 @@
6 * (C) 1991 Linus Torvalds - minix filesystem 6 * (C) 1991 Linus Torvalds - minix filesystem
7 */ 7 */
8 8
9#include <linux/time.h>
10#include <linux/iso_fs.h>
11#include <linux/kernel.h>
12#include <linux/string.h>
13#include <linux/stat.h>
14#include <linux/fcntl.h>
15#include <linux/mm.h>
16#include <linux/errno.h>
17#include <linux/config.h> /* Joliet? */ 9#include <linux/config.h> /* Joliet? */
18#include <linux/smp_lock.h> 10#include <linux/smp_lock.h>
19#include <linux/buffer_head.h> 11#include "isofs.h"
20#include <linux/dcache.h>
21
22#include <asm/uaccess.h>
23 12
24/* 13/*
25 * ok, we cannot use strncmp, as the name is not in our data space. 14 * ok, we cannot use strncmp, as the name is not in our data space.
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 8bdd3e409543..089e79c65585 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -6,17 +6,11 @@
6 * Rock Ridge Extensions to iso9660 6 * Rock Ridge Extensions to iso9660
7 */ 7 */
8 8
9#include <linux/stat.h>
10#include <linux/time.h>
11#include <linux/iso_fs.h>
12#include <linux/string.h>
13#include <linux/mm.h>
14#include <linux/slab.h> 9#include <linux/slab.h>
15#include <linux/pagemap.h> 10#include <linux/pagemap.h>
16#include <linux/smp_lock.h> 11#include <linux/smp_lock.h>
17#include <linux/buffer_head.h>
18#include <asm/page.h>
19 12
13#include "isofs.h"
20#include "rock.h" 14#include "rock.h"
21 15
22/* These functions are designed to read the system areas of a directory record 16/* These functions are designed to read the system areas of a directory record
diff --git a/fs/isofs/util.c b/fs/isofs/util.c
index 3f6d9c1ac95a..01e1ee7a998b 100644
--- a/fs/isofs/util.c
+++ b/fs/isofs/util.c
@@ -2,9 +2,7 @@
2 * linux/fs/isofs/util.c 2 * linux/fs/isofs/util.c
3 */ 3 */
4 4
5#include <linux/time.h> 5#include "isofs.h"
6#include <linux/fs.h>
7#include <linux/iso_fs.h>
8 6
9/* 7/*
10 * We have to convert from a MM/DD/YY format to the Unix ctime format. 8 * We have to convert from a MM/DD/YY format to the Unix ctime format.
@@ -80,4 +78,3 @@ int iso_date(char * p, int flag)
80 } 78 }
81 return crtime; 79 return crtime;
82} 80}
83
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c
index 450d6624181f..09422388fb96 100644
--- a/fs/jffs2/compr_rubin.c
+++ b/fs/jffs2/compr_rubin.c
@@ -228,8 +228,10 @@ int jffs2_rubinmips_compress(unsigned char *data_in, unsigned char *cpage_out,
228 return rubin_do_compress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen); 228 return rubin_do_compress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen);
229} 229}
230#endif 230#endif
231int jffs2_dynrubin_compress(unsigned char *data_in, unsigned char *cpage_out, 231static int jffs2_dynrubin_compress(unsigned char *data_in,
232 uint32_t *sourcelen, uint32_t *dstlen, void *model) 232 unsigned char *cpage_out,
233 uint32_t *sourcelen, uint32_t *dstlen,
234 void *model)
233{ 235{
234 int bits[8]; 236 int bits[8];
235 unsigned char histo[256]; 237 unsigned char histo[256];
@@ -306,15 +308,19 @@ static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata
306} 308}
307 309
308 310
309int jffs2_rubinmips_decompress(unsigned char *data_in, unsigned char *cpage_out, 311static int jffs2_rubinmips_decompress(unsigned char *data_in,
310 uint32_t sourcelen, uint32_t dstlen, void *model) 312 unsigned char *cpage_out,
313 uint32_t sourcelen, uint32_t dstlen,
314 void *model)
311{ 315{
312 rubin_do_decompress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen); 316 rubin_do_decompress(BIT_DIVIDER_MIPS, bits_mips, data_in, cpage_out, sourcelen, dstlen);
313 return 0; 317 return 0;
314} 318}
315 319
316int jffs2_dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, 320static int jffs2_dynrubin_decompress(unsigned char *data_in,
317 uint32_t sourcelen, uint32_t dstlen, void *model) 321 unsigned char *cpage_out,
322 uint32_t sourcelen, uint32_t dstlen,
323 void *model)
318{ 324{
319 int bits[8]; 325 int bits[8];
320 int c; 326 int c;
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c
index 9f9932c22adb..078a30e406b5 100644
--- a/fs/jffs2/compr_zlib.c
+++ b/fs/jffs2/compr_zlib.c
@@ -69,8 +69,10 @@ static void free_workspaces(void)
69#define free_workspaces() do { } while(0) 69#define free_workspaces() do { } while(0)
70#endif /* __KERNEL__ */ 70#endif /* __KERNEL__ */
71 71
72int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out, 72static int jffs2_zlib_compress(unsigned char *data_in,
73 uint32_t *sourcelen, uint32_t *dstlen, void *model) 73 unsigned char *cpage_out,
74 uint32_t *sourcelen, uint32_t *dstlen,
75 void *model)
74{ 76{
75 int ret; 77 int ret;
76 78
@@ -135,8 +137,10 @@ int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out,
135 return ret; 137 return ret;
136} 138}
137 139
138int jffs2_zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, 140static int jffs2_zlib_decompress(unsigned char *data_in,
139 uint32_t srclen, uint32_t destlen, void *model) 141 unsigned char *cpage_out,
142 uint32_t srclen, uint32_t destlen,
143 void *model)
140{ 144{
141 int ret; 145 int ret;
142 int wbits = MAX_WBITS; 146 int wbits = MAX_WBITS;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 0c607c1388f4..771a554701d6 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -79,8 +79,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
79 79
80 D2(printk(KERN_DEBUG "jffs2_do_readpage_nolock(): ino #%lu, page at offset 0x%lx\n", inode->i_ino, pg->index << PAGE_CACHE_SHIFT)); 80 D2(printk(KERN_DEBUG "jffs2_do_readpage_nolock(): ino #%lu, page at offset 0x%lx\n", inode->i_ino, pg->index << PAGE_CACHE_SHIFT));
81 81
82 if (!PageLocked(pg)) 82 BUG_ON(!PageLocked(pg));
83 PAGE_BUG(pg);
84 83
85 pg_buf = kmap(pg); 84 pg_buf = kmap(pg);
86 /* FIXME: Can kmap fail? */ 85 /* FIXME: Can kmap fail? */
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 7bc906677b0d..24a689179af2 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -175,31 +175,22 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
175{ 175{
176 s64 lblock64 = lblock; 176 s64 lblock64 = lblock;
177 int rc = 0; 177 int rc = 0;
178 int take_locks;
179 xad_t xad; 178 xad_t xad;
180 s64 xaddr; 179 s64 xaddr;
181 int xflag; 180 int xflag;
182 s32 xlen; 181 s32 xlen = max_blocks;
183
184 /*
185 * If this is a special inode (imap, dmap)
186 * the lock should already be taken
187 */
188 take_locks = (JFS_IP(ip)->fileset != AGGREGATE_I);
189 182
190 /* 183 /*
191 * Take appropriate lock on inode 184 * Take appropriate lock on inode
192 */ 185 */
193 if (take_locks) { 186 if (create)
194 if (create) 187 IWRITE_LOCK(ip);
195 IWRITE_LOCK(ip); 188 else
196 else 189 IREAD_LOCK(ip);
197 IREAD_LOCK(ip);
198 }
199 190
200 if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) && 191 if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) &&
201 (xtLookup(ip, lblock64, max_blocks, &xflag, &xaddr, &xlen, 0) 192 (!xtLookup(ip, lblock64, max_blocks, &xflag, &xaddr, &xlen, 0)) &&
202 == 0) && xlen) { 193 xaddr) {
203 if (xflag & XAD_NOTRECORDED) { 194 if (xflag & XAD_NOTRECORDED) {
204 if (!create) 195 if (!create)
205 /* 196 /*
@@ -238,7 +229,7 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
238#ifdef _JFS_4K 229#ifdef _JFS_4K
239 if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad))) 230 if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad)))
240 goto unlock; 231 goto unlock;
241 rc = extAlloc(ip, max_blocks, lblock64, &xad, FALSE); 232 rc = extAlloc(ip, xlen, lblock64, &xad, FALSE);
242 if (rc) 233 if (rc)
243 goto unlock; 234 goto unlock;
244 235
@@ -258,12 +249,10 @@ jfs_get_blocks(struct inode *ip, sector_t lblock, unsigned long max_blocks,
258 /* 249 /*
259 * Release lock on inode 250 * Release lock on inode
260 */ 251 */
261 if (take_locks) { 252 if (create)
262 if (create) 253 IWRITE_UNLOCK(ip);
263 IWRITE_UNLOCK(ip); 254 else
264 else 255 IREAD_UNLOCK(ip);
265 IREAD_UNLOCK(ip);
266 }
267 return rc; 256 return rc;
268} 257}
269 258
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index d86e467c6e42..69007fd546ef 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -471,6 +471,7 @@ dbUpdatePMap(struct inode *ipbmap,
471 struct metapage *mp; 471 struct metapage *mp;
472 struct jfs_log *log; 472 struct jfs_log *log;
473 int lsn, difft, diffp; 473 int lsn, difft, diffp;
474 unsigned long flags;
474 475
475 /* the blocks better be within the mapsize. */ 476 /* the blocks better be within the mapsize. */
476 if (blkno + nblocks > bmp->db_mapsize) { 477 if (blkno + nblocks > bmp->db_mapsize) {
@@ -504,6 +505,7 @@ dbUpdatePMap(struct inode *ipbmap,
504 0); 505 0);
505 if (mp == NULL) 506 if (mp == NULL)
506 return -EIO; 507 return -EIO;
508 metapage_wait_for_io(mp);
507 } 509 }
508 dp = (struct dmap *) mp->data; 510 dp = (struct dmap *) mp->data;
509 511
@@ -578,34 +580,32 @@ dbUpdatePMap(struct inode *ipbmap,
578 if (mp->lsn != 0) { 580 if (mp->lsn != 0) {
579 /* inherit older/smaller lsn */ 581 /* inherit older/smaller lsn */
580 logdiff(diffp, mp->lsn, log); 582 logdiff(diffp, mp->lsn, log);
583 LOGSYNC_LOCK(log, flags);
581 if (difft < diffp) { 584 if (difft < diffp) {
582 mp->lsn = lsn; 585 mp->lsn = lsn;
583 586
584 /* move bp after tblock in logsync list */ 587 /* move bp after tblock in logsync list */
585 LOGSYNC_LOCK(log);
586 list_move(&mp->synclist, &tblk->synclist); 588 list_move(&mp->synclist, &tblk->synclist);
587 LOGSYNC_UNLOCK(log);
588 } 589 }
589 590
590 /* inherit younger/larger clsn */ 591 /* inherit younger/larger clsn */
591 LOGSYNC_LOCK(log);
592 logdiff(difft, tblk->clsn, log); 592 logdiff(difft, tblk->clsn, log);
593 logdiff(diffp, mp->clsn, log); 593 logdiff(diffp, mp->clsn, log);
594 if (difft > diffp) 594 if (difft > diffp)
595 mp->clsn = tblk->clsn; 595 mp->clsn = tblk->clsn;
596 LOGSYNC_UNLOCK(log); 596 LOGSYNC_UNLOCK(log, flags);
597 } else { 597 } else {
598 mp->log = log; 598 mp->log = log;
599 mp->lsn = lsn; 599 mp->lsn = lsn;
600 600
601 /* insert bp after tblock in logsync list */ 601 /* insert bp after tblock in logsync list */
602 LOGSYNC_LOCK(log); 602 LOGSYNC_LOCK(log, flags);
603 603
604 log->count++; 604 log->count++;
605 list_add(&mp->synclist, &tblk->synclist); 605 list_add(&mp->synclist, &tblk->synclist);
606 606
607 mp->clsn = tblk->clsn; 607 mp->clsn = tblk->clsn;
608 LOGSYNC_UNLOCK(log); 608 LOGSYNC_UNLOCK(log, flags);
609 } 609 }
610 } 610 }
611 611
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index e357890adfb2..ac41f72d6d50 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -212,7 +212,7 @@ static struct metapage *read_index_page(struct inode *inode, s64 blkno)
212 s32 xlen; 212 s32 xlen;
213 213
214 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1); 214 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
215 if (rc || (xlen == 0)) 215 if (rc || (xaddr == 0))
216 return NULL; 216 return NULL;
217 217
218 return read_metapage(inode, xaddr, PSIZE, 1); 218 return read_metapage(inode, xaddr, PSIZE, 1);
@@ -231,7 +231,7 @@ static struct metapage *get_index_page(struct inode *inode, s64 blkno)
231 s32 xlen; 231 s32 xlen;
232 232
233 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1); 233 rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
234 if (rc || (xlen == 0)) 234 if (rc || (xaddr == 0))
235 return NULL; 235 return NULL;
236 236
237 return get_metapage(inode, xaddr, PSIZE, 1); 237 return get_metapage(inode, xaddr, PSIZE, 1);
@@ -3181,7 +3181,7 @@ int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
3181 d = (struct ldtentry *) & p->slot[stbl[i]]; 3181 d = (struct ldtentry *) & p->slot[stbl[i]];
3182 3182
3183 if (((long) jfs_dirent + d->namlen + 1) > 3183 if (((long) jfs_dirent + d->namlen + 1) >
3184 (dirent_buf + PSIZE)) { 3184 (dirent_buf + PAGE_SIZE)) {
3185 /* DBCS codepages could overrun dirent_buf */ 3185 /* DBCS codepages could overrun dirent_buf */
3186 index = i; 3186 index = i;
3187 overflow = 1; 3187 overflow = 1;
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 783831301625..7acff2ce3c80 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -502,7 +502,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
502 502
503 } 503 }
504 504
505 ip->i_mapping->a_ops = &jfs_aops; 505 ip->i_mapping->a_ops = &jfs_metapage_aops;
506 mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS); 506 mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS);
507 507
508 /* Allocations to metadata inodes should not affect quotas */ 508 /* Allocations to metadata inodes should not affect quotas */
@@ -2573,9 +2573,18 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
2573 goto out; 2573 goto out;
2574 } 2574 }
2575 2575
2576 /* assign a buffer for the page */ 2576 /*
2577 mp = get_metapage(ipimap, xaddr, PSIZE, 1); 2577 * start transaction of update of the inode map
2578 if (!mp) { 2578 * addressing structure pointing to the new iag page;
2579 */
2580 tid = txBegin(sb, COMMIT_FORCE);
2581 down(&JFS_IP(ipimap)->commit_sem);
2582
2583 /* update the inode map addressing structure to point to it */
2584 if ((rc =
2585 xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
2586 txEnd(tid);
2587 up(&JFS_IP(ipimap)->commit_sem);
2579 /* Free the blocks allocated for the iag since it was 2588 /* Free the blocks allocated for the iag since it was
2580 * not successfully added to the inode map 2589 * not successfully added to the inode map
2581 */ 2590 */
@@ -2584,6 +2593,29 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
2584 /* release the inode map lock */ 2593 /* release the inode map lock */
2585 IWRITE_UNLOCK(ipimap); 2594 IWRITE_UNLOCK(ipimap);
2586 2595
2596 goto out;
2597 }
2598
2599 /* update the inode map's inode to reflect the extension */
2600 ipimap->i_size += PSIZE;
2601 inode_add_bytes(ipimap, PSIZE);
2602
2603 /* assign a buffer for the page */
2604 mp = get_metapage(ipimap, blkno, PSIZE, 0);
2605 if (!mp) {
2606 /*
2607 * This is very unlikely since we just created the
2608 * extent, but let's try to handle it correctly
2609 */
2610 xtTruncate(tid, ipimap, ipimap->i_size - PSIZE,
2611 COMMIT_PWMAP);
2612
2613 txAbort(tid, 0);
2614 txEnd(tid);
2615
2616 /* release the inode map lock */
2617 IWRITE_UNLOCK(ipimap);
2618
2587 rc = -EIO; 2619 rc = -EIO;
2588 goto out; 2620 goto out;
2589 } 2621 }
@@ -2605,41 +2637,11 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
2605 iagp->inosmap[i] = cpu_to_le32(ONES); 2637 iagp->inosmap[i] = cpu_to_le32(ONES);
2606 2638
2607 /* 2639 /*
2608 * Invalidate the page after writing and syncing it. 2640 * Write and sync the metapage
2609 * After it's initialized, we access it in a different
2610 * address space
2611 */ 2641 */
2612 set_bit(META_discard, &mp->flag);
2613 flush_metapage(mp); 2642 flush_metapage(mp);
2614 2643
2615 /* 2644 /*
2616 * start tyransaction of update of the inode map
2617 * addressing structure pointing to the new iag page;
2618 */
2619 tid = txBegin(sb, COMMIT_FORCE);
2620 down(&JFS_IP(ipimap)->commit_sem);
2621
2622 /* update the inode map addressing structure to point to it */
2623 if ((rc =
2624 xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
2625 txEnd(tid);
2626 up(&JFS_IP(ipimap)->commit_sem);
2627 /* Free the blocks allocated for the iag since it was
2628 * not successfully added to the inode map
2629 */
2630 dbFree(ipimap, xaddr, (s64) xlen);
2631
2632 /* release the inode map lock */
2633 IWRITE_UNLOCK(ipimap);
2634
2635 goto out;
2636 }
2637
2638 /* update the inode map's inode to reflect the extension */
2639 ipimap->i_size += PSIZE;
2640 inode_add_bytes(ipimap, PSIZE);
2641
2642 /*
2643 * txCommit(COMMIT_FORCE) will synchronously write address 2645 * txCommit(COMMIT_FORCE) will synchronously write address
2644 * index pages and inode after commit in careful update order 2646 * index pages and inode after commit in careful update order
2645 * of address index pages (right to left, bottom up); 2647 * of address index pages (right to left, bottom up);
@@ -2789,6 +2791,7 @@ diUpdatePMap(struct inode *ipimap,
2789 u32 mask; 2791 u32 mask;
2790 struct jfs_log *log; 2792 struct jfs_log *log;
2791 int lsn, difft, diffp; 2793 int lsn, difft, diffp;
2794 unsigned long flags;
2792 2795
2793 imap = JFS_IP(ipimap)->i_imap; 2796 imap = JFS_IP(ipimap)->i_imap;
2794 /* get the iag number containing the inode */ 2797 /* get the iag number containing the inode */
@@ -2805,6 +2808,7 @@ diUpdatePMap(struct inode *ipimap,
2805 IREAD_UNLOCK(ipimap); 2808 IREAD_UNLOCK(ipimap);
2806 if (rc) 2809 if (rc)
2807 return (rc); 2810 return (rc);
2811 metapage_wait_for_io(mp);
2808 iagp = (struct iag *) mp->data; 2812 iagp = (struct iag *) mp->data;
2809 /* get the inode number and extent number of the inode within 2813 /* get the inode number and extent number of the inode within
2810 * the iag and the inode number within the extent. 2814 * the iag and the inode number within the extent.
@@ -2868,30 +2872,28 @@ diUpdatePMap(struct inode *ipimap,
2868 /* inherit older/smaller lsn */ 2872 /* inherit older/smaller lsn */
2869 logdiff(difft, lsn, log); 2873 logdiff(difft, lsn, log);
2870 logdiff(diffp, mp->lsn, log); 2874 logdiff(diffp, mp->lsn, log);
2875 LOGSYNC_LOCK(log, flags);
2871 if (difft < diffp) { 2876 if (difft < diffp) {
2872 mp->lsn = lsn; 2877 mp->lsn = lsn;
2873 /* move mp after tblock in logsync list */ 2878 /* move mp after tblock in logsync list */
2874 LOGSYNC_LOCK(log);
2875 list_move(&mp->synclist, &tblk->synclist); 2879 list_move(&mp->synclist, &tblk->synclist);
2876 LOGSYNC_UNLOCK(log);
2877 } 2880 }
2878 /* inherit younger/larger clsn */ 2881 /* inherit younger/larger clsn */
2879 LOGSYNC_LOCK(log);
2880 assert(mp->clsn); 2882 assert(mp->clsn);
2881 logdiff(difft, tblk->clsn, log); 2883 logdiff(difft, tblk->clsn, log);
2882 logdiff(diffp, mp->clsn, log); 2884 logdiff(diffp, mp->clsn, log);
2883 if (difft > diffp) 2885 if (difft > diffp)
2884 mp->clsn = tblk->clsn; 2886 mp->clsn = tblk->clsn;
2885 LOGSYNC_UNLOCK(log); 2887 LOGSYNC_UNLOCK(log, flags);
2886 } else { 2888 } else {
2887 mp->log = log; 2889 mp->log = log;
2888 mp->lsn = lsn; 2890 mp->lsn = lsn;
2889 /* insert mp after tblock in logsync list */ 2891 /* insert mp after tblock in logsync list */
2890 LOGSYNC_LOCK(log); 2892 LOGSYNC_LOCK(log, flags);
2891 log->count++; 2893 log->count++;
2892 list_add(&mp->synclist, &tblk->synclist); 2894 list_add(&mp->synclist, &tblk->synclist);
2893 mp->clsn = tblk->clsn; 2895 mp->clsn = tblk->clsn;
2894 LOGSYNC_UNLOCK(log); 2896 LOGSYNC_UNLOCK(log, flags);
2895 } 2897 }
2896 write_metapage(mp); 2898 write_metapage(mp);
2897 return (0); 2899 return (0);
diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
index ebd77c1bed66..c0fd7b3eadc6 100644
--- a/fs/jfs/jfs_incore.h
+++ b/fs/jfs/jfs_incore.h
@@ -165,6 +165,7 @@ struct jfs_sb_info {
165 /* Formerly in ipbmap */ 165 /* Formerly in ipbmap */
166 struct bmap *bmap; /* incore bmap descriptor */ 166 struct bmap *bmap; /* incore bmap descriptor */
167 struct nls_table *nls_tab; /* current codepage */ 167 struct nls_table *nls_tab; /* current codepage */
168 struct inode *direct_inode; /* metadata inode */
168 uint state; /* mount/recovery state */ 169 uint state; /* mount/recovery state */
169 unsigned long flag; /* mount time flags */ 170 unsigned long flag; /* mount time flags */
170 uint p_state; /* state prior to going no integrity */ 171 uint p_state; /* state prior to going no integrity */
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index b6a6869ebb4f..dfa1200daa61 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -234,6 +234,7 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
234 int lsn; 234 int lsn;
235 int diffp, difft; 235 int diffp, difft;
236 struct metapage *mp = NULL; 236 struct metapage *mp = NULL;
237 unsigned long flags;
237 238
238 jfs_info("lmLog: log:0x%p tblk:0x%p, lrd:0x%p tlck:0x%p", 239 jfs_info("lmLog: log:0x%p tblk:0x%p, lrd:0x%p tlck:0x%p",
239 log, tblk, lrd, tlck); 240 log, tblk, lrd, tlck);
@@ -254,7 +255,7 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
254 */ 255 */
255 lsn = log->lsn; 256 lsn = log->lsn;
256 257
257 LOGSYNC_LOCK(log); 258 LOGSYNC_LOCK(log, flags);
258 259
259 /* 260 /*
260 * initialize page lsn if first log write of the page 261 * initialize page lsn if first log write of the page
@@ -310,7 +311,7 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
310 } 311 }
311 } 312 }
312 313
313 LOGSYNC_UNLOCK(log); 314 LOGSYNC_UNLOCK(log, flags);
314 315
315 /* 316 /*
316 * write the log record 317 * write the log record
@@ -334,7 +335,6 @@ int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
334 return lsn; 335 return lsn;
335} 336}
336 337
337
338/* 338/*
339 * NAME: lmWriteRecord() 339 * NAME: lmWriteRecord()
340 * 340 *
@@ -927,9 +927,8 @@ static void lmPostGC(struct lbuf * bp)
927 * calculate new value of i_nextsync which determines when 927 * calculate new value of i_nextsync which determines when
928 * this code is called again. 928 * this code is called again.
929 * 929 *
930 * this is called only from lmLog(). 930 * PARAMETERS: log - log structure
931 * 931 * nosyncwait - 1 if called asynchronously
932 * PARAMETER: ip - pointer to logs inode.
933 * 932 *
934 * RETURN: 0 933 * RETURN: 0
935 * 934 *
@@ -945,6 +944,15 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
945 struct lrd lrd; 944 struct lrd lrd;
946 int lsn; 945 int lsn;
947 struct logsyncblk *lp; 946 struct logsyncblk *lp;
947 struct jfs_sb_info *sbi;
948 unsigned long flags;
949
950 /* push dirty metapages out to disk */
951 list_for_each_entry(sbi, &log->sb_list, log_list) {
952 filemap_flush(sbi->ipbmap->i_mapping);
953 filemap_flush(sbi->ipimap->i_mapping);
954 filemap_flush(sbi->direct_inode->i_mapping);
955 }
948 956
949 /* 957 /*
950 * forward syncpt 958 * forward syncpt
@@ -954,10 +962,7 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
954 */ 962 */
955 963
956 if (log->sync == log->syncpt) { 964 if (log->sync == log->syncpt) {
957 LOGSYNC_LOCK(log); 965 LOGSYNC_LOCK(log, flags);
958 /* ToDo: push dirty metapages out to disk */
959// bmLogSync(log);
960
961 if (list_empty(&log->synclist)) 966 if (list_empty(&log->synclist))
962 log->sync = log->lsn; 967 log->sync = log->lsn;
963 else { 968 else {
@@ -965,7 +970,7 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
965 struct logsyncblk, synclist); 970 struct logsyncblk, synclist);
966 log->sync = lp->lsn; 971 log->sync = lp->lsn;
967 } 972 }
968 LOGSYNC_UNLOCK(log); 973 LOGSYNC_UNLOCK(log, flags);
969 974
970 } 975 }
971 976
@@ -974,27 +979,6 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
974 * reset syncpt = sync 979 * reset syncpt = sync
975 */ 980 */
976 if (log->sync != log->syncpt) { 981 if (log->sync != log->syncpt) {
977 struct jfs_sb_info *sbi;
978
979 /*
980 * We need to make sure all of the "written" metapages
981 * actually make it to disk
982 */
983 list_for_each_entry(sbi, &log->sb_list, log_list) {
984 if (sbi->flag & JFS_NOINTEGRITY)
985 continue;
986 filemap_fdatawrite(sbi->ipbmap->i_mapping);
987 filemap_fdatawrite(sbi->ipimap->i_mapping);
988 filemap_fdatawrite(sbi->sb->s_bdev->bd_inode->i_mapping);
989 }
990 list_for_each_entry(sbi, &log->sb_list, log_list) {
991 if (sbi->flag & JFS_NOINTEGRITY)
992 continue;
993 filemap_fdatawait(sbi->ipbmap->i_mapping);
994 filemap_fdatawait(sbi->ipimap->i_mapping);
995 filemap_fdatawait(sbi->sb->s_bdev->bd_inode->i_mapping);
996 }
997
998 lrd.logtid = 0; 982 lrd.logtid = 0;
999 lrd.backchain = 0; 983 lrd.backchain = 0;
1000 lrd.type = cpu_to_le16(LOG_SYNCPT); 984 lrd.type = cpu_to_le16(LOG_SYNCPT);
@@ -1066,6 +1050,18 @@ static int lmLogSync(struct jfs_log * log, int nosyncwait)
1066 return lsn; 1050 return lsn;
1067} 1051}
1068 1052
1053/*
1054 * NAME: jfs_syncpt
1055 *
1056 * FUNCTION: write log SYNCPT record for specified log
1057 *
1058 * PARAMETERS: log - log structure
1059 */
1060void jfs_syncpt(struct jfs_log *log)
1061{ LOG_LOCK(log);
1062 lmLogSync(log, 1);
1063 LOG_UNLOCK(log);
1064}
1069 1065
1070/* 1066/*
1071 * NAME: lmLogOpen() 1067 * NAME: lmLogOpen()
@@ -1547,6 +1543,7 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1547{ 1543{
1548 int i; 1544 int i;
1549 struct tblock *target = NULL; 1545 struct tblock *target = NULL;
1546 struct jfs_sb_info *sbi;
1550 1547
1551 /* jfs_write_inode may call us during read-only mount */ 1548 /* jfs_write_inode may call us during read-only mount */
1552 if (!log) 1549 if (!log)
@@ -1608,12 +1605,18 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1608 if (wait < 2) 1605 if (wait < 2)
1609 return; 1606 return;
1610 1607
1608 list_for_each_entry(sbi, &log->sb_list, log_list) {
1609 filemap_fdatawrite(sbi->ipbmap->i_mapping);
1610 filemap_fdatawrite(sbi->ipimap->i_mapping);
1611 filemap_fdatawrite(sbi->direct_inode->i_mapping);
1612 }
1613
1611 /* 1614 /*
1612 * If there was recent activity, we may need to wait 1615 * If there was recent activity, we may need to wait
1613 * for the lazycommit thread to catch up 1616 * for the lazycommit thread to catch up
1614 */ 1617 */
1615 if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) { 1618 if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) {
1616 for (i = 0; i < 800; i++) { /* Too much? */ 1619 for (i = 0; i < 200; i++) { /* Too much? */
1617 msleep(250); 1620 msleep(250);
1618 if (list_empty(&log->cqueue) && 1621 if (list_empty(&log->cqueue) &&
1619 list_empty(&log->synclist)) 1622 list_empty(&log->synclist))
@@ -1621,7 +1624,24 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1621 } 1624 }
1622 } 1625 }
1623 assert(list_empty(&log->cqueue)); 1626 assert(list_empty(&log->cqueue));
1624 assert(list_empty(&log->synclist)); 1627 if (!list_empty(&log->synclist)) {
1628 struct logsyncblk *lp;
1629
1630 list_for_each_entry(lp, &log->synclist, synclist) {
1631 if (lp->xflag & COMMIT_PAGE) {
1632 struct metapage *mp = (struct metapage *)lp;
1633 dump_mem("orphan metapage", lp,
1634 sizeof(struct metapage));
1635 dump_mem("page", mp->page, sizeof(struct page));
1636 }
1637 else
1638 dump_mem("orphan tblock", lp,
1639 sizeof(struct tblock));
1640 }
1641// current->state = TASK_INTERRUPTIBLE;
1642// schedule();
1643 }
1644 //assert(list_empty(&log->synclist));
1625 clear_bit(log_FLUSH, &log->flag); 1645 clear_bit(log_FLUSH, &log->flag);
1626} 1646}
1627 1647
@@ -1669,6 +1689,7 @@ int lmLogShutdown(struct jfs_log * log)
1669 lp->h.eor = lp->t.eor = cpu_to_le16(bp->l_eor); 1689 lp->h.eor = lp->t.eor = cpu_to_le16(bp->l_eor);
1670 lbmWrite(log, log->bp, lbmWRITE | lbmRELEASE | lbmSYNC, 0); 1690 lbmWrite(log, log->bp, lbmWRITE | lbmRELEASE | lbmSYNC, 0);
1671 lbmIOWait(log->bp, lbmFREE); 1691 lbmIOWait(log->bp, lbmFREE);
1692 log->bp = NULL;
1672 1693
1673 /* 1694 /*
1674 * synchronous update log superblock 1695 * synchronous update log superblock
@@ -1819,20 +1840,34 @@ static int lbmLogInit(struct jfs_log * log)
1819 1840
1820 log->lbuf_free = NULL; 1841 log->lbuf_free = NULL;
1821 1842
1822 for (i = 0; i < LOGPAGES; i++) { 1843 for (i = 0; i < LOGPAGES;) {
1823 lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL); 1844 char *buffer;
1824 if (lbuf == 0) 1845 uint offset;
1825 goto error; 1846 struct page *page;
1826 lbuf->l_ldata = (char *) get_zeroed_page(GFP_KERNEL); 1847
1827 if (lbuf->l_ldata == 0) { 1848 buffer = (char *) get_zeroed_page(GFP_KERNEL);
1828 kfree(lbuf); 1849 if (buffer == NULL)
1829 goto error; 1850 goto error;
1851 page = virt_to_page(buffer);
1852 for (offset = 0; offset < PAGE_SIZE; offset += LOGPSIZE) {
1853 lbuf = kmalloc(sizeof(struct lbuf), GFP_KERNEL);
1854 if (lbuf == NULL) {
1855 if (offset == 0)
1856 free_page((unsigned long) buffer);
1857 goto error;
1858 }
1859 if (offset) /* we already have one reference */
1860 get_page(page);
1861 lbuf->l_offset = offset;
1862 lbuf->l_ldata = buffer + offset;
1863 lbuf->l_page = page;
1864 lbuf->l_log = log;
1865 init_waitqueue_head(&lbuf->l_ioevent);
1866
1867 lbuf->l_freelist = log->lbuf_free;
1868 log->lbuf_free = lbuf;
1869 i++;
1830 } 1870 }
1831 lbuf->l_log = log;
1832 init_waitqueue_head(&lbuf->l_ioevent);
1833
1834 lbuf->l_freelist = log->lbuf_free;
1835 log->lbuf_free = lbuf;
1836 } 1871 }
1837 1872
1838 return (0); 1873 return (0);
@@ -1857,12 +1892,10 @@ static void lbmLogShutdown(struct jfs_log * log)
1857 lbuf = log->lbuf_free; 1892 lbuf = log->lbuf_free;
1858 while (lbuf) { 1893 while (lbuf) {
1859 struct lbuf *next = lbuf->l_freelist; 1894 struct lbuf *next = lbuf->l_freelist;
1860 free_page((unsigned long) lbuf->l_ldata); 1895 __free_page(lbuf->l_page);
1861 kfree(lbuf); 1896 kfree(lbuf);
1862 lbuf = next; 1897 lbuf = next;
1863 } 1898 }
1864
1865 log->bp = NULL;
1866} 1899}
1867 1900
1868 1901
@@ -1974,9 +2007,9 @@ static int lbmRead(struct jfs_log * log, int pn, struct lbuf ** bpp)
1974 2007
1975 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9); 2008 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9);
1976 bio->bi_bdev = log->bdev; 2009 bio->bi_bdev = log->bdev;
1977 bio->bi_io_vec[0].bv_page = virt_to_page(bp->l_ldata); 2010 bio->bi_io_vec[0].bv_page = bp->l_page;
1978 bio->bi_io_vec[0].bv_len = LOGPSIZE; 2011 bio->bi_io_vec[0].bv_len = LOGPSIZE;
1979 bio->bi_io_vec[0].bv_offset = 0; 2012 bio->bi_io_vec[0].bv_offset = bp->l_offset;
1980 2013
1981 bio->bi_vcnt = 1; 2014 bio->bi_vcnt = 1;
1982 bio->bi_idx = 0; 2015 bio->bi_idx = 0;
@@ -2115,9 +2148,9 @@ static void lbmStartIO(struct lbuf * bp)
2115 bio = bio_alloc(GFP_NOFS, 1); 2148 bio = bio_alloc(GFP_NOFS, 1);
2116 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9); 2149 bio->bi_sector = bp->l_blkno << (log->l2bsize - 9);
2117 bio->bi_bdev = log->bdev; 2150 bio->bi_bdev = log->bdev;
2118 bio->bi_io_vec[0].bv_page = virt_to_page(bp->l_ldata); 2151 bio->bi_io_vec[0].bv_page = bp->l_page;
2119 bio->bi_io_vec[0].bv_len = LOGPSIZE; 2152 bio->bi_io_vec[0].bv_len = LOGPSIZE;
2120 bio->bi_io_vec[0].bv_offset = 0; 2153 bio->bi_io_vec[0].bv_offset = bp->l_offset;
2121 2154
2122 bio->bi_vcnt = 1; 2155 bio->bi_vcnt = 1;
2123 bio->bi_idx = 0; 2156 bio->bi_idx = 0;
@@ -2127,16 +2160,13 @@ static void lbmStartIO(struct lbuf * bp)
2127 bio->bi_private = bp; 2160 bio->bi_private = bp;
2128 2161
2129 /* check if journaling to disk has been disabled */ 2162 /* check if journaling to disk has been disabled */
2130 if (!log->no_integrity) { 2163 if (log->no_integrity) {
2164 bio->bi_size = 0;
2165 lbmIODone(bio, 0, 0);
2166 } else {
2131 submit_bio(WRITE_SYNC, bio); 2167 submit_bio(WRITE_SYNC, bio);
2132 INCREMENT(lmStat.submitted); 2168 INCREMENT(lmStat.submitted);
2133 } 2169 }
2134 else {
2135 bio->bi_size = 0;
2136 lbmIODone(bio, 0, 0); /* 2nd argument appears to not be used => 0
2137 * 3rd argument appears to not be used => 0
2138 */
2139 }
2140} 2170}
2141 2171
2142 2172
diff --git a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
index 141ad74010c9..51291fbc420c 100644
--- a/fs/jfs/jfs_logmgr.h
+++ b/fs/jfs/jfs_logmgr.h
@@ -463,9 +463,10 @@ struct lbuf {
463 463
464 s64 l_blkno; /* 8: log page block number */ 464 s64 l_blkno; /* 8: log page block number */
465 caddr_t l_ldata; /* 4: data page */ 465 caddr_t l_ldata; /* 4: data page */
466 struct page *l_page; /* The page itself */
467 uint l_offset; /* Offset of l_ldata within the page */
466 468
467 wait_queue_head_t l_ioevent; /* 4: i/o done event */ 469 wait_queue_head_t l_ioevent; /* 4: i/o done event */
468 struct page *l_page; /* The page itself */
469}; 470};
470 471
471/* Reuse l_freelist for redrive list */ 472/* Reuse l_freelist for redrive list */
@@ -489,8 +490,9 @@ struct logsyncblk {
489 */ 490 */
490 491
491#define LOGSYNC_LOCK_INIT(log) spin_lock_init(&(log)->synclock) 492#define LOGSYNC_LOCK_INIT(log) spin_lock_init(&(log)->synclock)
492#define LOGSYNC_LOCK(log) spin_lock(&(log)->synclock) 493#define LOGSYNC_LOCK(log, flags) spin_lock_irqsave(&(log)->synclock, flags)
493#define LOGSYNC_UNLOCK(log) spin_unlock(&(log)->synclock) 494#define LOGSYNC_UNLOCK(log, flags) \
495 spin_unlock_irqrestore(&(log)->synclock, flags)
494 496
495/* compute the difference in bytes of lsn from sync point */ 497/* compute the difference in bytes of lsn from sync point */
496#define logdiff(diff, lsn, log)\ 498#define logdiff(diff, lsn, log)\
@@ -506,5 +508,6 @@ extern int lmLogShutdown(struct jfs_log * log);
506extern int lmLogInit(struct jfs_log * log); 508extern int lmLogInit(struct jfs_log * log);
507extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize); 509extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize);
508extern void jfs_flush_journal(struct jfs_log * log, int wait); 510extern void jfs_flush_journal(struct jfs_log * log, int wait);
511extern void jfs_syncpt(struct jfs_log *log);
509 512
510#endif /* _H_JFS_LOGMGR */ 513#endif /* _H_JFS_LOGMGR */
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 4c0a3ac75c08..41bf078dce05 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) International Business Machines Corp., 2000-2003 2 * Copyright (C) International Business Machines Corp., 2000-2005
3 * Portions Copyright (C) Christoph Hellwig, 2001-2002 3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
@@ -18,10 +18,11 @@
18 */ 18 */
19 19
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/mm.h>
22#include <linux/bio.h>
21#include <linux/init.h> 23#include <linux/init.h>
22#include <linux/buffer_head.h> 24#include <linux/buffer_head.h>
23#include <linux/mempool.h> 25#include <linux/mempool.h>
24#include <linux/delay.h>
25#include "jfs_incore.h" 26#include "jfs_incore.h"
26#include "jfs_superblock.h" 27#include "jfs_superblock.h"
27#include "jfs_filsys.h" 28#include "jfs_filsys.h"
@@ -29,8 +30,6 @@
29#include "jfs_txnmgr.h" 30#include "jfs_txnmgr.h"
30#include "jfs_debug.h" 31#include "jfs_debug.h"
31 32
32static DEFINE_SPINLOCK(meta_lock);
33
34#ifdef CONFIG_JFS_STATISTICS 33#ifdef CONFIG_JFS_STATISTICS
35static struct { 34static struct {
36 uint pagealloc; /* # of page allocations */ 35 uint pagealloc; /* # of page allocations */
@@ -39,22 +38,8 @@ static struct {
39} mpStat; 38} mpStat;
40#endif 39#endif
41 40
42 41#define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)
43#define HASH_BITS 10 /* This makes hash_table 1 4K page */ 42#define trylock_metapage(mp) test_and_set_bit(META_locked, &(mp)->flag)
44#define HASH_SIZE (1 << HASH_BITS)
45static struct metapage **hash_table = NULL;
46static unsigned long hash_order;
47
48
49static inline int metapage_locked(struct metapage *mp)
50{
51 return test_bit(META_locked, &mp->flag);
52}
53
54static inline int trylock_metapage(struct metapage *mp)
55{
56 return test_and_set_bit(META_locked, &mp->flag);
57}
58 43
59static inline void unlock_metapage(struct metapage *mp) 44static inline void unlock_metapage(struct metapage *mp)
60{ 45{
@@ -62,26 +47,26 @@ static inline void unlock_metapage(struct metapage *mp)
62 wake_up(&mp->wait); 47 wake_up(&mp->wait);
63} 48}
64 49
65static void __lock_metapage(struct metapage *mp) 50static inline void __lock_metapage(struct metapage *mp)
66{ 51{
67 DECLARE_WAITQUEUE(wait, current); 52 DECLARE_WAITQUEUE(wait, current);
68
69 INCREMENT(mpStat.lockwait); 53 INCREMENT(mpStat.lockwait);
70
71 add_wait_queue_exclusive(&mp->wait, &wait); 54 add_wait_queue_exclusive(&mp->wait, &wait);
72 do { 55 do {
73 set_current_state(TASK_UNINTERRUPTIBLE); 56 set_current_state(TASK_UNINTERRUPTIBLE);
74 if (metapage_locked(mp)) { 57 if (metapage_locked(mp)) {
75 spin_unlock(&meta_lock); 58 unlock_page(mp->page);
76 schedule(); 59 schedule();
77 spin_lock(&meta_lock); 60 lock_page(mp->page);
78 } 61 }
79 } while (trylock_metapage(mp)); 62 } while (trylock_metapage(mp));
80 __set_current_state(TASK_RUNNING); 63 __set_current_state(TASK_RUNNING);
81 remove_wait_queue(&mp->wait, &wait); 64 remove_wait_queue(&mp->wait, &wait);
82} 65}
83 66
84/* needs meta_lock */ 67/*
68 * Must have mp->page locked
69 */
85static inline void lock_metapage(struct metapage *mp) 70static inline void lock_metapage(struct metapage *mp)
86{ 71{
87 if (trylock_metapage(mp)) 72 if (trylock_metapage(mp))
@@ -92,6 +77,110 @@ static inline void lock_metapage(struct metapage *mp)
92static kmem_cache_t *metapage_cache; 77static kmem_cache_t *metapage_cache;
93static mempool_t *metapage_mempool; 78static mempool_t *metapage_mempool;
94 79
80#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE)
81
82#if MPS_PER_PAGE > 1
83
84struct meta_anchor {
85 int mp_count;
86 atomic_t io_count;
87 struct metapage *mp[MPS_PER_PAGE];
88};
89#define mp_anchor(page) ((struct meta_anchor *)page->private)
90
91static inline struct metapage *page_to_mp(struct page *page, uint offset)
92{
93 if (!PagePrivate(page))
94 return NULL;
95 return mp_anchor(page)->mp[offset >> L2PSIZE];
96}
97
98static inline int insert_metapage(struct page *page, struct metapage *mp)
99{
100 struct meta_anchor *a;
101 int index;
102 int l2mp_blocks; /* log2 blocks per metapage */
103
104 if (PagePrivate(page))
105 a = mp_anchor(page);
106 else {
107 a = kmalloc(sizeof(struct meta_anchor), GFP_NOFS);
108 if (!a)
109 return -ENOMEM;
110 memset(a, 0, sizeof(struct meta_anchor));
111 page->private = (unsigned long)a;
112 SetPagePrivate(page);
113 kmap(page);
114 }
115
116 if (mp) {
117 l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
118 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
119 a->mp_count++;
120 a->mp[index] = mp;
121 }
122
123 return 0;
124}
125
126static inline void remove_metapage(struct page *page, struct metapage *mp)
127{
128 struct meta_anchor *a = mp_anchor(page);
129 int l2mp_blocks = L2PSIZE - page->mapping->host->i_blkbits;
130 int index;
131
132 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1);
133
134 BUG_ON(a->mp[index] != mp);
135
136 a->mp[index] = NULL;
137 if (--a->mp_count == 0) {
138 kfree(a);
139 page->private = 0;
140 ClearPagePrivate(page);
141 kunmap(page);
142 }
143}
144
145static inline void inc_io(struct page *page)
146{
147 atomic_inc(&mp_anchor(page)->io_count);
148}
149
150static inline void dec_io(struct page *page, void (*handler) (struct page *))
151{
152 if (atomic_dec_and_test(&mp_anchor(page)->io_count))
153 handler(page);
154}
155
156#else
157static inline struct metapage *page_to_mp(struct page *page, uint offset)
158{
159 return PagePrivate(page) ? (struct metapage *)page->private : NULL;
160}
161
162static inline int insert_metapage(struct page *page, struct metapage *mp)
163{
164 if (mp) {
165 page->private = (unsigned long)mp;
166 SetPagePrivate(page);
167 kmap(page);
168 }
169 return 0;
170}
171
172static inline void remove_metapage(struct page *page, struct metapage *mp)
173{
174 page->private = 0;
175 ClearPagePrivate(page);
176 kunmap(page);
177}
178
179#define inc_io(page) do {} while(0)
180#define dec_io(page, handler) handler(page)
181
182#endif
183
95static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 184static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
96{ 185{
97 struct metapage *mp = (struct metapage *)foo; 186 struct metapage *mp = (struct metapage *)foo;
@@ -139,16 +228,6 @@ int __init metapage_init(void)
139 kmem_cache_destroy(metapage_cache); 228 kmem_cache_destroy(metapage_cache);
140 return -ENOMEM; 229 return -ENOMEM;
141 } 230 }
142 /*
143 * Now the hash list
144 */
145 for (hash_order = 0;
146 ((PAGE_SIZE << hash_order) / sizeof(void *)) < HASH_SIZE;
147 hash_order++);
148 hash_table =
149 (struct metapage **) __get_free_pages(GFP_KERNEL, hash_order);
150 assert(hash_table);
151 memset(hash_table, 0, PAGE_SIZE << hash_order);
152 231
153 return 0; 232 return 0;
154} 233}
@@ -159,73 +238,388 @@ void metapage_exit(void)
159 kmem_cache_destroy(metapage_cache); 238 kmem_cache_destroy(metapage_cache);
160} 239}
161 240
241static inline void drop_metapage(struct page *page, struct metapage *mp)
242{
243 if (mp->count || mp->nohomeok || test_bit(META_dirty, &mp->flag) ||
244 test_bit(META_io, &mp->flag))
245 return;
246 remove_metapage(page, mp);
247 INCREMENT(mpStat.pagefree);
248 free_metapage(mp);
249}
250
162/* 251/*
163 * Basically same hash as in pagemap.h, but using our hash table 252 * Metapage address space operations
164 */ 253 */
165static struct metapage **meta_hash(struct address_space *mapping, 254
166 unsigned long index) 255static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
256 unsigned int *len)
167{ 257{
168#define i (((unsigned long)mapping)/ \ 258 int rc = 0;
169 (sizeof(struct inode) & ~(sizeof(struct inode) -1 ))) 259 int xflag;
170#define s(x) ((x) + ((x) >> HASH_BITS)) 260 s64 xaddr;
171 return hash_table + (s(i + index) & (HASH_SIZE - 1)); 261 sector_t file_blocks = (inode->i_size + inode->i_blksize - 1) >>
172#undef i 262 inode->i_blkbits;
173#undef s 263
264 if (lblock >= file_blocks)
265 return 0;
266 if (lblock + *len > file_blocks)
267 *len = file_blocks - lblock;
268
269 if (inode->i_ino) {
270 rc = xtLookup(inode, (s64)lblock, *len, &xflag, &xaddr, len, 0);
271 if ((rc == 0) && *len)
272 lblock = (sector_t)xaddr;
273 else
274 lblock = 0;
275 } /* else no mapping */
276
277 return lblock;
174} 278}
175 279
176static struct metapage *search_hash(struct metapage ** hash_ptr, 280static void last_read_complete(struct page *page)
177 struct address_space *mapping,
178 unsigned long index)
179{ 281{
180 struct metapage *ptr; 282 if (!PageError(page))
283 SetPageUptodate(page);
284 unlock_page(page);
285}
286
287static int metapage_read_end_io(struct bio *bio, unsigned int bytes_done,
288 int err)
289{
290 struct page *page = bio->bi_private;
291
292 if (bio->bi_size)
293 return 1;
181 294
182 for (ptr = *hash_ptr; ptr; ptr = ptr->hash_next) { 295 if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
183 if ((ptr->mapping == mapping) && (ptr->index == index)) 296 printk(KERN_ERR "metapage_read_end_io: I/O error\n");
184 return ptr; 297 SetPageError(page);
185 } 298 }
186 299
187 return NULL; 300 dec_io(page, last_read_complete);
301 bio_put(bio);
302
303 return 0;
188} 304}
189 305
190static void add_to_hash(struct metapage * mp, struct metapage ** hash_ptr) 306static void remove_from_logsync(struct metapage *mp)
191{ 307{
192 if (*hash_ptr) 308 struct jfs_log *log = mp->log;
193 (*hash_ptr)->hash_prev = mp; 309 unsigned long flags;
310/*
311 * This can race. Recheck that log hasn't been set to null, and after
312 * acquiring logsync lock, recheck lsn
313 */
314 if (!log)
315 return;
316
317 LOGSYNC_LOCK(log, flags);
318 if (mp->lsn) {
319 mp->log = NULL;
320 mp->lsn = 0;
321 mp->clsn = 0;
322 log->count--;
323 list_del(&mp->synclist);
324 }
325 LOGSYNC_UNLOCK(log, flags);
326}
194 327
195 mp->hash_prev = NULL; 328static void last_write_complete(struct page *page)
196 mp->hash_next = *hash_ptr; 329{
197 *hash_ptr = mp; 330 struct metapage *mp;
331 unsigned int offset;
332
333 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
334 mp = page_to_mp(page, offset);
335 if (mp && test_bit(META_io, &mp->flag)) {
336 if (mp->lsn)
337 remove_from_logsync(mp);
338 clear_bit(META_io, &mp->flag);
339 }
340 /*
341 * I'd like to call drop_metapage here, but I don't think it's
342 * safe unless I have the page locked
343 */
344 }
345 end_page_writeback(page);
198} 346}
199 347
200static void remove_from_hash(struct metapage * mp, struct metapage ** hash_ptr) 348static int metapage_write_end_io(struct bio *bio, unsigned int bytes_done,
349 int err)
201{ 350{
202 if (mp->hash_prev) 351 struct page *page = bio->bi_private;
203 mp->hash_prev->hash_next = mp->hash_next; 352
204 else { 353 BUG_ON(!PagePrivate(page));
205 assert(*hash_ptr == mp); 354
206 *hash_ptr = mp->hash_next; 355 if (bio->bi_size)
356 return 1;
357
358 if (! test_bit(BIO_UPTODATE, &bio->bi_flags)) {
359 printk(KERN_ERR "metapage_write_end_io: I/O error\n");
360 SetPageError(page);
361 }
362 dec_io(page, last_write_complete);
363 bio_put(bio);
364 return 0;
365}
366
367static int metapage_writepage(struct page *page, struct writeback_control *wbc)
368{
369 struct bio *bio = NULL;
370 unsigned int block_offset; /* block offset of mp within page */
371 struct inode *inode = page->mapping->host;
372 unsigned int blocks_per_mp = JFS_SBI(inode->i_sb)->nbperpage;
373 unsigned int len;
374 unsigned int xlen;
375 struct metapage *mp;
376 int redirty = 0;
377 sector_t lblock;
378 sector_t pblock;
379 sector_t next_block = 0;
380 sector_t page_start;
381 unsigned long bio_bytes = 0;
382 unsigned long bio_offset = 0;
383 unsigned int offset;
384
385 page_start = (sector_t)page->index <<
386 (PAGE_CACHE_SHIFT - inode->i_blkbits);
387 BUG_ON(!PageLocked(page));
388 BUG_ON(PageWriteback(page));
389
390 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
391 mp = page_to_mp(page, offset);
392
393 if (!mp || !test_bit(META_dirty, &mp->flag))
394 continue;
395
396 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) {
397 redirty = 1;
398 continue;
399 }
400
401 clear_bit(META_dirty, &mp->flag);
402 block_offset = offset >> inode->i_blkbits;
403 lblock = page_start + block_offset;
404 if (bio) {
405 if (xlen && lblock == next_block) {
406 /* Contiguous, in memory & on disk */
407 len = min(xlen, blocks_per_mp);
408 xlen -= len;
409 bio_bytes += len << inode->i_blkbits;
410 set_bit(META_io, &mp->flag);
411 continue;
412 }
413 /* Not contiguous */
414 if (bio_add_page(bio, page, bio_bytes, bio_offset) <
415 bio_bytes)
416 goto add_failed;
417 /*
418 * Increment counter before submitting i/o to keep
419 * count from hitting zero before we're through
420 */
421 inc_io(page);
422 if (!bio->bi_size)
423 goto dump_bio;
424 submit_bio(WRITE, bio);
425 bio = NULL;
426 } else {
427 set_page_writeback(page);
428 inc_io(page);
429 }
430 xlen = (PAGE_CACHE_SIZE - offset) >> inode->i_blkbits;
431 pblock = metapage_get_blocks(inode, lblock, &xlen);
432 if (!pblock) {
433 /* Need better error handling */
434 printk(KERN_ERR "JFS: metapage_get_blocks failed\n");
435 dec_io(page, last_write_complete);
436 continue;
437 }
438 set_bit(META_io, &mp->flag);
439 len = min(xlen, (uint) JFS_SBI(inode->i_sb)->nbperpage);
440
441 bio = bio_alloc(GFP_NOFS, 1);
442 bio->bi_bdev = inode->i_sb->s_bdev;
443 bio->bi_sector = pblock << (inode->i_blkbits - 9);
444 bio->bi_end_io = metapage_write_end_io;
445 bio->bi_private = page;
446
447 /* Don't call bio_add_page yet, we may add to this vec */
448 bio_offset = offset;
449 bio_bytes = len << inode->i_blkbits;
450
451 xlen -= len;
452 next_block = lblock + len;
453 }
454 if (bio) {
455 if (bio_add_page(bio, page, bio_bytes, bio_offset) < bio_bytes)
456 goto add_failed;
457 if (!bio->bi_size)
458 goto dump_bio;
459
460 submit_bio(WRITE, bio);
461 }
462 if (redirty)
463 redirty_page_for_writepage(wbc, page);
464
465 unlock_page(page);
466
467 return 0;
468add_failed:
469 /* We should never reach here, since we're only adding one vec */
470 printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
471 goto skip;
472dump_bio:
473 dump_mem("bio", bio, sizeof(*bio));
474skip:
475 bio_put(bio);
476 unlock_page(page);
477 dec_io(page, last_write_complete);
478
479 return -EIO;
480}
481
482static int metapage_readpage(struct file *fp, struct page *page)
483{
484 struct inode *inode = page->mapping->host;
485 struct bio *bio = NULL;
486 unsigned int block_offset;
487 unsigned int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
488 sector_t page_start; /* address of page in fs blocks */
489 sector_t pblock;
490 unsigned int xlen;
491 unsigned int len;
492 unsigned int offset;
493
494 BUG_ON(!PageLocked(page));
495 page_start = (sector_t)page->index <<
496 (PAGE_CACHE_SHIFT - inode->i_blkbits);
497
498 block_offset = 0;
499 while (block_offset < blocks_per_page) {
500 xlen = blocks_per_page - block_offset;
501 pblock = metapage_get_blocks(inode, page_start + block_offset,
502 &xlen);
503 if (pblock) {
504 if (!PagePrivate(page))
505 insert_metapage(page, NULL);
506 inc_io(page);
507 if (bio)
508 submit_bio(READ, bio);
509
510 bio = bio_alloc(GFP_NOFS, 1);
511 bio->bi_bdev = inode->i_sb->s_bdev;
512 bio->bi_sector = pblock << (inode->i_blkbits - 9);
513 bio->bi_end_io = metapage_read_end_io;
514 bio->bi_private = page;
515 len = xlen << inode->i_blkbits;
516 offset = block_offset << inode->i_blkbits;
517 if (bio_add_page(bio, page, len, offset) < len)
518 goto add_failed;
519 block_offset += xlen;
520 } else
521 block_offset++;
207 } 522 }
523 if (bio)
524 submit_bio(READ, bio);
525 else
526 unlock_page(page);
527
528 return 0;
208 529
209 if (mp->hash_next) 530add_failed:
210 mp->hash_next->hash_prev = mp->hash_prev; 531 printk(KERN_ERR "JFS: bio_add_page failed unexpectedly\n");
532 bio_put(bio);
533 dec_io(page, last_read_complete);
534 return -EIO;
211} 535}
212 536
537static int metapage_releasepage(struct page *page, int gfp_mask)
538{
539 struct metapage *mp;
540 int busy = 0;
541 unsigned int offset;
542
543 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
544 mp = page_to_mp(page, offset);
545
546 if (!mp)
547 continue;
548
549 jfs_info("metapage_releasepage: mp = 0x%p", mp);
550 if (mp->count || mp->nohomeok) {
551 jfs_info("count = %ld, nohomeok = %d", mp->count,
552 mp->nohomeok);
553 busy = 1;
554 continue;
555 }
556 wait_on_page_writeback(page);
557 //WARN_ON(test_bit(META_dirty, &mp->flag));
558 if (test_bit(META_dirty, &mp->flag)) {
559 dump_mem("dirty mp in metapage_releasepage", mp,
560 sizeof(struct metapage));
561 dump_mem("page", page, sizeof(struct page));
562 dump_stack();
563 }
564 WARN_ON(mp->lsn);
565 if (mp->lsn)
566 remove_from_logsync(mp);
567 remove_metapage(page, mp);
568 INCREMENT(mpStat.pagefree);
569 free_metapage(mp);
570 }
571 if (busy)
572 return -1;
573
574 return 0;
575}
576
577static int metapage_invalidatepage(struct page *page, unsigned long offset)
578{
579 BUG_ON(offset);
580
581 if (PageWriteback(page))
582 return 0;
583
584 return metapage_releasepage(page, 0);
585}
586
587struct address_space_operations jfs_metapage_aops = {
588 .readpage = metapage_readpage,
589 .writepage = metapage_writepage,
590 .sync_page = block_sync_page,
591 .releasepage = metapage_releasepage,
592 .invalidatepage = metapage_invalidatepage,
593 .set_page_dirty = __set_page_dirty_nobuffers,
594};
595
213struct metapage *__get_metapage(struct inode *inode, unsigned long lblock, 596struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
214 unsigned int size, int absolute, 597 unsigned int size, int absolute,
215 unsigned long new) 598 unsigned long new)
216{ 599{
217 struct metapage **hash_ptr;
218 int l2BlocksPerPage; 600 int l2BlocksPerPage;
219 int l2bsize; 601 int l2bsize;
220 struct address_space *mapping; 602 struct address_space *mapping;
221 struct metapage *mp; 603 struct metapage *mp = NULL;
604 struct page *page;
222 unsigned long page_index; 605 unsigned long page_index;
223 unsigned long page_offset; 606 unsigned long page_offset;
224 607
225 jfs_info("__get_metapage: inode = 0x%p, lblock = 0x%lx", inode, lblock); 608 jfs_info("__get_metapage: ino = %ld, lblock = 0x%lx, abs=%d",
226 609 inode->i_ino, lblock, absolute);
610
611 l2bsize = inode->i_blkbits;
612 l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
613 page_index = lblock >> l2BlocksPerPage;
614 page_offset = (lblock - (page_index << l2BlocksPerPage)) << l2bsize;
615 if ((page_offset + size) > PAGE_CACHE_SIZE) {
616 jfs_err("MetaData crosses page boundary!!");
617 jfs_err("lblock = %lx, size = %d", lblock, size);
618 dump_stack();
619 return NULL;
620 }
227 if (absolute) 621 if (absolute)
228 mapping = inode->i_sb->s_bdev->bd_inode->i_mapping; 622 mapping = JFS_SBI(inode->i_sb)->direct_inode->i_mapping;
229 else { 623 else {
230 /* 624 /*
231 * If an nfs client tries to read an inode that is larger 625 * If an nfs client tries to read an inode that is larger
@@ -237,312 +631,212 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
237 mapping = inode->i_mapping; 631 mapping = inode->i_mapping;
238 } 632 }
239 633
240 hash_ptr = meta_hash(mapping, lblock); 634 if (new && (PSIZE == PAGE_CACHE_SIZE)) {
241again: 635 page = grab_cache_page(mapping, page_index);
242 spin_lock(&meta_lock); 636 if (!page) {
243 mp = search_hash(hash_ptr, mapping, lblock); 637 jfs_err("grab_cache_page failed!");
638 return NULL;
639 }
640 SetPageUptodate(page);
641 } else {
642 page = read_cache_page(mapping, page_index,
643 (filler_t *)mapping->a_ops->readpage, NULL);
644 if (IS_ERR(page)) {
645 jfs_err("read_cache_page failed!");
646 return NULL;
647 }
648 lock_page(page);
649 }
650
651 mp = page_to_mp(page, page_offset);
244 if (mp) { 652 if (mp) {
245 page_found: 653 if (mp->logical_size != size) {
246 if (test_bit(META_stale, &mp->flag)) { 654 jfs_error(inode->i_sb,
247 spin_unlock(&meta_lock); 655 "__get_metapage: mp->logical_size != size");
248 msleep(1); 656 jfs_err("logical_size = %d, size = %d",
249 goto again; 657 mp->logical_size, size);
658 dump_stack();
659 goto unlock;
250 } 660 }
251 mp->count++; 661 mp->count++;
252 lock_metapage(mp); 662 lock_metapage(mp);
253 spin_unlock(&meta_lock);
254 if (test_bit(META_discard, &mp->flag)) { 663 if (test_bit(META_discard, &mp->flag)) {
255 if (!new) { 664 if (!new) {
256 jfs_error(inode->i_sb, 665 jfs_error(inode->i_sb,
257 "__get_metapage: using a " 666 "__get_metapage: using a "
258 "discarded metapage"); 667 "discarded metapage");
259 release_metapage(mp); 668 discard_metapage(mp);
260 return NULL; 669 goto unlock;
261 } 670 }
262 clear_bit(META_discard, &mp->flag); 671 clear_bit(META_discard, &mp->flag);
263 } 672 }
264 jfs_info("__get_metapage: found 0x%p, in hash", mp);
265 if (mp->logical_size != size) {
266 jfs_error(inode->i_sb,
267 "__get_metapage: mp->logical_size != size");
268 release_metapage(mp);
269 return NULL;
270 }
271 } else { 673 } else {
272 l2bsize = inode->i_blkbits; 674 INCREMENT(mpStat.pagealloc);
273 l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize; 675 mp = alloc_metapage(GFP_NOFS);
274 page_index = lblock >> l2BlocksPerPage; 676 mp->page = page;
275 page_offset = (lblock - (page_index << l2BlocksPerPage)) <<
276 l2bsize;
277 if ((page_offset + size) > PAGE_CACHE_SIZE) {
278 spin_unlock(&meta_lock);
279 jfs_err("MetaData crosses page boundary!!");
280 return NULL;
281 }
282
283 /*
284 * Locks held on aggregate inode pages are usually
285 * not held long, and they are taken in critical code
286 * paths (committing dirty inodes, txCommit thread)
287 *
288 * Attempt to get metapage without blocking, tapping into
289 * reserves if necessary.
290 */
291 mp = NULL;
292 if (JFS_IP(inode)->fileset == AGGREGATE_I) {
293 mp = alloc_metapage(GFP_ATOMIC);
294 if (!mp) {
295 /*
296 * mempool is supposed to protect us from
297 * failing here. We will try a blocking
298 * call, but a deadlock is possible here
299 */
300 printk(KERN_WARNING
301 "__get_metapage: atomic call to mempool_alloc failed.\n");
302 printk(KERN_WARNING
303 "Will attempt blocking call\n");
304 }
305 }
306 if (!mp) {
307 struct metapage *mp2;
308
309 spin_unlock(&meta_lock);
310 mp = alloc_metapage(GFP_NOFS);
311 spin_lock(&meta_lock);
312
313 /* we dropped the meta_lock, we need to search the
314 * hash again.
315 */
316 mp2 = search_hash(hash_ptr, mapping, lblock);
317 if (mp2) {
318 free_metapage(mp);
319 mp = mp2;
320 goto page_found;
321 }
322 }
323 mp->flag = 0; 677 mp->flag = 0;
324 lock_metapage(mp);
325 if (absolute)
326 set_bit(META_absolute, &mp->flag);
327 mp->xflag = COMMIT_PAGE; 678 mp->xflag = COMMIT_PAGE;
328 mp->count = 1; 679 mp->count = 1;
329 atomic_set(&mp->nohomeok,0); 680 mp->nohomeok = 0;
330 mp->mapping = mapping;
331 mp->index = lblock;
332 mp->page = NULL;
333 mp->logical_size = size; 681 mp->logical_size = size;
334 add_to_hash(mp, hash_ptr); 682 mp->data = page_address(page) + page_offset;
335 spin_unlock(&meta_lock); 683 mp->index = lblock;
336 684 if (unlikely(insert_metapage(page, mp))) {
337 if (new) { 685 free_metapage(mp);
338 jfs_info("__get_metapage: Calling grab_cache_page"); 686 goto unlock;
339 mp->page = grab_cache_page(mapping, page_index);
340 if (!mp->page) {
341 jfs_err("grab_cache_page failed!");
342 goto freeit;
343 } else {
344 INCREMENT(mpStat.pagealloc);
345 unlock_page(mp->page);
346 }
347 } else {
348 jfs_info("__get_metapage: Calling read_cache_page");
349 mp->page = read_cache_page(mapping, lblock,
350 (filler_t *)mapping->a_ops->readpage, NULL);
351 if (IS_ERR(mp->page)) {
352 jfs_err("read_cache_page failed!");
353 goto freeit;
354 } else
355 INCREMENT(mpStat.pagealloc);
356 } 687 }
357 mp->data = kmap(mp->page) + page_offset; 688 lock_metapage(mp);
358 } 689 }
359 690
360 if (new) 691 if (new) {
692 jfs_info("zeroing mp = 0x%p", mp);
361 memset(mp->data, 0, PSIZE); 693 memset(mp->data, 0, PSIZE);
694 }
362 695
363 jfs_info("__get_metapage: returning = 0x%p", mp); 696 unlock_page(page);
697 jfs_info("__get_metapage: returning = 0x%p data = 0x%p", mp, mp->data);
364 return mp; 698 return mp;
365 699
366freeit: 700unlock:
367 spin_lock(&meta_lock); 701 unlock_page(page);
368 remove_from_hash(mp, hash_ptr);
369 free_metapage(mp);
370 spin_unlock(&meta_lock);
371 return NULL; 702 return NULL;
372} 703}
373 704
374void hold_metapage(struct metapage * mp, int force) 705void grab_metapage(struct metapage * mp)
375{ 706{
376 spin_lock(&meta_lock); 707 jfs_info("grab_metapage: mp = 0x%p", mp);
377 708 page_cache_get(mp->page);
709 lock_page(mp->page);
378 mp->count++; 710 mp->count++;
379 711 lock_metapage(mp);
380 if (force) { 712 unlock_page(mp->page);
381 ASSERT (!(test_bit(META_forced, &mp->flag)));
382 if (trylock_metapage(mp))
383 set_bit(META_forced, &mp->flag);
384 } else
385 lock_metapage(mp);
386
387 spin_unlock(&meta_lock);
388} 713}
389 714
390static void __write_metapage(struct metapage * mp) 715void force_metapage(struct metapage *mp)
391{ 716{
392 int l2bsize = mp->mapping->host->i_blkbits; 717 struct page *page = mp->page;
393 int l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize; 718 jfs_info("force_metapage: mp = 0x%p", mp);
394 unsigned long page_index; 719 set_bit(META_forcewrite, &mp->flag);
395 unsigned long page_offset; 720 clear_bit(META_sync, &mp->flag);
396 int rc; 721 page_cache_get(page);
397 722 lock_page(page);
398 jfs_info("__write_metapage: mp = 0x%p", mp); 723 set_page_dirty(page);
399 724 write_one_page(page, 1);
400 page_index = mp->page->index; 725 clear_bit(META_forcewrite, &mp->flag);
401 page_offset = 726 page_cache_release(page);
402 (mp->index - (page_index << l2BlocksPerPage)) << l2bsize; 727}
403 728
729extern void hold_metapage(struct metapage *mp)
730{
404 lock_page(mp->page); 731 lock_page(mp->page);
405 rc = mp->mapping->a_ops->prepare_write(NULL, mp->page, page_offset, 732}
406 page_offset + 733
407 mp->logical_size); 734extern void put_metapage(struct metapage *mp)
408 if (rc) { 735{
409 jfs_err("prepare_write return %d!", rc); 736 if (mp->count || mp->nohomeok) {
410 ClearPageUptodate(mp->page); 737 /* Someone else will release this */
411 unlock_page(mp->page); 738 unlock_page(mp->page);
412 clear_bit(META_dirty, &mp->flag);
413 return; 739 return;
414 } 740 }
415 rc = mp->mapping->a_ops->commit_write(NULL, mp->page, page_offset, 741 page_cache_get(mp->page);
416 page_offset + 742 mp->count++;
417 mp->logical_size); 743 lock_metapage(mp);
418 if (rc) {
419 jfs_err("commit_write returned %d", rc);
420 }
421
422 unlock_page(mp->page); 744 unlock_page(mp->page);
423 clear_bit(META_dirty, &mp->flag); 745 release_metapage(mp);
424
425 jfs_info("__write_metapage done");
426}
427
428static inline void sync_metapage(struct metapage *mp)
429{
430 struct page *page = mp->page;
431
432 page_cache_get(page);
433 lock_page(page);
434
435 /* we're done with this page - no need to check for errors */
436 if (page_has_buffers(page))
437 write_one_page(page, 1);
438 else
439 unlock_page(page);
440 page_cache_release(page);
441} 746}
442 747
443void release_metapage(struct metapage * mp) 748void release_metapage(struct metapage * mp)
444{ 749{
445 struct jfs_log *log; 750 struct page *page = mp->page;
446
447 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag); 751 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag);
448 752
449 spin_lock(&meta_lock); 753 BUG_ON(!page);
450 if (test_bit(META_forced, &mp->flag)) { 754
451 clear_bit(META_forced, &mp->flag); 755 lock_page(page);
452 mp->count--; 756 unlock_metapage(mp);
453 spin_unlock(&meta_lock);
454 return;
455 }
456 757
457 assert(mp->count); 758 assert(mp->count);
458 if (--mp->count || atomic_read(&mp->nohomeok)) { 759 if (--mp->count || mp->nohomeok) {
459 unlock_metapage(mp); 760 unlock_page(page);
460 spin_unlock(&meta_lock); 761 page_cache_release(page);
461 return; 762 return;
462 } 763 }
463 764
464 if (mp->page) { 765 if (test_bit(META_dirty, &mp->flag)) {
465 set_bit(META_stale, &mp->flag); 766 set_page_dirty(page);
466 spin_unlock(&meta_lock);
467 kunmap(mp->page);
468 mp->data = NULL;
469 if (test_bit(META_dirty, &mp->flag))
470 __write_metapage(mp);
471 if (test_bit(META_sync, &mp->flag)) { 767 if (test_bit(META_sync, &mp->flag)) {
472 sync_metapage(mp);
473 clear_bit(META_sync, &mp->flag); 768 clear_bit(META_sync, &mp->flag);
769 write_one_page(page, 1);
770 lock_page(page); /* write_one_page unlocks the page */
474 } 771 }
772 } else if (mp->lsn) /* discard_metapage doesn't remove it */
773 remove_from_logsync(mp);
475 774
476 if (test_bit(META_discard, &mp->flag)) { 775#if MPS_PER_PAGE == 1
477 lock_page(mp->page); 776 /*
478 block_invalidatepage(mp->page, 0); 777 * If we know this is the only thing in the page, we can throw
479 unlock_page(mp->page); 778 * the page out of the page cache. If pages are larger, we
480 } 779 * don't want to do this.
481 780 */
482 page_cache_release(mp->page);
483 mp->page = NULL;
484 INCREMENT(mpStat.pagefree);
485 spin_lock(&meta_lock);
486 }
487 781
488 if (mp->lsn) { 782 /* Retest mp->count since we may have released page lock */
489 /* 783 if (test_bit(META_discard, &mp->flag) && !mp->count) {
490 * Remove metapage from logsynclist. 784 clear_page_dirty(page);
491 */ 785 ClearPageUptodate(page);
492 log = mp->log; 786#ifdef _NOT_YET
493 LOGSYNC_LOCK(log); 787 if (page->mapping) {
494 mp->log = NULL; 788 /* Remove from page cache and page cache reference */
495 mp->lsn = 0; 789 remove_from_page_cache(page);
496 mp->clsn = 0; 790 page_cache_release(page);
497 log->count--; 791 metapage_releasepage(page, 0);
498 list_del(&mp->synclist); 792 }
499 LOGSYNC_UNLOCK(log); 793#endif
500 } 794 }
501 remove_from_hash(mp, meta_hash(mp->mapping, mp->index)); 795#else
502 spin_unlock(&meta_lock); 796 /* Try to keep metapages from using up too much memory */
503 797 drop_metapage(page, mp);
504 free_metapage(mp); 798#endif
799 unlock_page(page);
800 page_cache_release(page);
505} 801}
506 802
507void __invalidate_metapages(struct inode *ip, s64 addr, int len) 803void __invalidate_metapages(struct inode *ip, s64 addr, int len)
508{ 804{
509 struct metapage **hash_ptr; 805 sector_t lblock;
510 unsigned long lblock;
511 int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits; 806 int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits;
807 int BlocksPerPage = 1 << l2BlocksPerPage;
512 /* All callers are interested in block device's mapping */ 808 /* All callers are interested in block device's mapping */
513 struct address_space *mapping = ip->i_sb->s_bdev->bd_inode->i_mapping; 809 struct address_space *mapping =
810 JFS_SBI(ip->i_sb)->direct_inode->i_mapping;
514 struct metapage *mp; 811 struct metapage *mp;
515 struct page *page; 812 struct page *page;
813 unsigned int offset;
516 814
517 /* 815 /*
518 * First, mark metapages to discard. They will eventually be 816 * Mark metapages to discard. They will eventually be
519 * released, but should not be written. 817 * released, but should not be written.
520 */ 818 */
521 for (lblock = addr; lblock < addr + len; 819 for (lblock = addr & ~(BlocksPerPage - 1); lblock < addr + len;
522 lblock += 1 << l2BlocksPerPage) { 820 lblock += BlocksPerPage) {
523 hash_ptr = meta_hash(mapping, lblock); 821 page = find_lock_page(mapping, lblock >> l2BlocksPerPage);
524again: 822 if (!page)
525 spin_lock(&meta_lock); 823 continue;
526 mp = search_hash(hash_ptr, mapping, lblock); 824 for (offset = 0; offset < PAGE_CACHE_SIZE; offset += PSIZE) {
527 if (mp) { 825 mp = page_to_mp(page, offset);
528 if (test_bit(META_stale, &mp->flag)) { 826 if (!mp)
529 spin_unlock(&meta_lock); 827 continue;
530 msleep(1); 828 if (mp->index < addr)
531 goto again; 829 continue;
532 } 830 if (mp->index >= addr + len)
831 break;
533 832
534 clear_bit(META_dirty, &mp->flag); 833 clear_bit(META_dirty, &mp->flag);
535 set_bit(META_discard, &mp->flag); 834 set_bit(META_discard, &mp->flag);
536 spin_unlock(&meta_lock); 835 if (mp->lsn)
537 } else { 836 remove_from_logsync(mp);
538 spin_unlock(&meta_lock);
539 page = find_lock_page(mapping, lblock>>l2BlocksPerPage);
540 if (page) {
541 block_invalidatepage(page, 0);
542 unlock_page(page);
543 page_cache_release(page);
544 }
545 } 837 }
838 unlock_page(page);
839 page_cache_release(page);
546 } 840 }
547} 841}
548 842
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
index 0e58aba58c37..991e9fb84c75 100644
--- a/fs/jfs/jfs_metapage.h
+++ b/fs/jfs/jfs_metapage.h
@@ -33,38 +33,27 @@ struct metapage {
33 unsigned long flag; /* See Below */ 33 unsigned long flag; /* See Below */
34 unsigned long count; /* Reference count */ 34 unsigned long count; /* Reference count */
35 void *data; /* Data pointer */ 35 void *data; /* Data pointer */
36 36 sector_t index; /* block address of page */
37 /* list management stuff */
38 struct metapage *hash_prev;
39 struct metapage *hash_next; /* Also used for free list */
40
41 /*
42 * mapping & index become redundant, but we need these here to
43 * add the metapage to the hash before we have the real page
44 */
45 struct address_space *mapping;
46 unsigned long index;
47 wait_queue_head_t wait; 37 wait_queue_head_t wait;
48 38
49 /* implementation */ 39 /* implementation */
50 struct page *page; 40 struct page *page;
51 unsigned long logical_size; 41 unsigned int logical_size;
52 42
53 /* Journal management */ 43 /* Journal management */
54 int clsn; 44 int clsn;
55 atomic_t nohomeok; 45 int nohomeok;
56 struct jfs_log *log; 46 struct jfs_log *log;
57}; 47};
58 48
59/* metapage flag */ 49/* metapage flag */
60#define META_locked 0 50#define META_locked 0
61#define META_absolute 1 51#define META_free 1
62#define META_free 2 52#define META_dirty 2
63#define META_dirty 3 53#define META_sync 3
64#define META_sync 4 54#define META_discard 4
65#define META_discard 5 55#define META_forcewrite 5
66#define META_forced 6 56#define META_io 6
67#define META_stale 7
68 57
69#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag) 58#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)
70 59
@@ -80,7 +69,16 @@ extern struct metapage *__get_metapage(struct inode *inode,
80 __get_metapage(inode, lblock, size, absolute, TRUE) 69 __get_metapage(inode, lblock, size, absolute, TRUE)
81 70
82extern void release_metapage(struct metapage *); 71extern void release_metapage(struct metapage *);
83extern void hold_metapage(struct metapage *, int); 72extern void grab_metapage(struct metapage *);
73extern void force_metapage(struct metapage *);
74
75/*
76 * hold_metapage and put_metapage are used in conjuction. The page lock
77 * is not dropped between the two, so no other threads can get or release
78 * the metapage
79 */
80extern void hold_metapage(struct metapage *);
81extern void put_metapage(struct metapage *);
84 82
85static inline void write_metapage(struct metapage *mp) 83static inline void write_metapage(struct metapage *mp)
86{ 84{
@@ -101,6 +99,46 @@ static inline void discard_metapage(struct metapage *mp)
101 release_metapage(mp); 99 release_metapage(mp);
102} 100}
103 101
102static inline void metapage_nohomeok(struct metapage *mp)
103{
104 struct page *page = mp->page;
105 lock_page(page);
106 if (!mp->nohomeok++) {
107 mark_metapage_dirty(mp);
108 page_cache_get(page);
109 wait_on_page_writeback(page);
110 }
111 unlock_page(page);
112}
113
114/*
115 * This serializes access to mp->lsn when metapages are added to logsynclist
116 * without setting nohomeok. i.e. updating imap & dmap
117 */
118static inline void metapage_wait_for_io(struct metapage *mp)
119{
120 if (test_bit(META_io, &mp->flag))
121 wait_on_page_writeback(mp->page);
122}
123
124/*
125 * This is called when already holding the metapage
126 */
127static inline void _metapage_homeok(struct metapage *mp)
128{
129 if (!--mp->nohomeok)
130 page_cache_release(mp->page);
131}
132
133static inline void metapage_homeok(struct metapage *mp)
134{
135 hold_metapage(mp);
136 _metapage_homeok(mp);
137 put_metapage(mp);
138}
139
140extern struct address_space_operations jfs_metapage_aops;
141
104/* 142/*
105 * This routines invalidate all pages for an extent. 143 * This routines invalidate all pages for an extent.
106 */ 144 */
diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index c535ffd638e8..032d111bc330 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -285,11 +285,6 @@ int jfs_mount_rw(struct super_block *sb, int remount)
285 */ 285 */
286 logMOUNT(sb); 286 logMOUNT(sb);
287 287
288 /*
289 * Set page cache allocation policy
290 */
291 mapping_set_gfp_mask(sb->s_bdev->bd_inode->i_mapping, GFP_NOFS);
292
293 return rc; 288 return rc;
294} 289}
295 290
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index f40301d93f74..e93d01aa12c4 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -227,6 +227,7 @@ static lid_t txLockAlloc(void)
227 227
228static void txLockFree(lid_t lid) 228static void txLockFree(lid_t lid)
229{ 229{
230 TxLock[lid].tid = 0;
230 TxLock[lid].next = TxAnchor.freelock; 231 TxLock[lid].next = TxAnchor.freelock;
231 TxAnchor.freelock = lid; 232 TxAnchor.freelock = lid;
232 TxAnchor.tlocksInUse--; 233 TxAnchor.tlocksInUse--;
@@ -566,9 +567,6 @@ void txEnd(tid_t tid)
566 * synchronize with logsync barrier 567 * synchronize with logsync barrier
567 */ 568 */
568 if (test_bit(log_SYNCBARRIER, &log->flag)) { 569 if (test_bit(log_SYNCBARRIER, &log->flag)) {
569 /* forward log syncpt */
570 /* lmSync(log); */
571
572 jfs_info("log barrier off: 0x%x", log->lsn); 570 jfs_info("log barrier off: 0x%x", log->lsn);
573 571
574 /* enable new transactions start */ 572 /* enable new transactions start */
@@ -576,15 +574,22 @@ void txEnd(tid_t tid)
576 574
577 /* wakeup all waitors for logsync barrier */ 575 /* wakeup all waitors for logsync barrier */
578 TXN_WAKEUP(&log->syncwait); 576 TXN_WAKEUP(&log->syncwait);
577
578 TXN_UNLOCK();
579
580 /* forward log syncpt */
581 jfs_syncpt(log);
582
583 goto wakeup;
579 } 584 }
580 } 585 }
581 586
587 TXN_UNLOCK();
588wakeup:
582 /* 589 /*
583 * wakeup all waitors for a free tblock 590 * wakeup all waitors for a free tblock
584 */ 591 */
585 TXN_WAKEUP(&TxAnchor.freewait); 592 TXN_WAKEUP(&TxAnchor.freewait);
586
587 TXN_UNLOCK();
588} 593}
589 594
590 595
@@ -633,8 +638,10 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
633 638
634 /* is page locked by the requester transaction ? */ 639 /* is page locked by the requester transaction ? */
635 tlck = lid_to_tlock(lid); 640 tlck = lid_to_tlock(lid);
636 if ((xtid = tlck->tid) == tid) 641 if ((xtid = tlck->tid) == tid) {
642 TXN_UNLOCK();
637 goto grantLock; 643 goto grantLock;
644 }
638 645
639 /* 646 /*
640 * is page locked by anonymous transaction/lock ? 647 * is page locked by anonymous transaction/lock ?
@@ -649,6 +656,7 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
649 */ 656 */
650 if (xtid == 0) { 657 if (xtid == 0) {
651 tlck->tid = tid; 658 tlck->tid = tid;
659 TXN_UNLOCK();
652 tblk = tid_to_tblock(tid); 660 tblk = tid_to_tblock(tid);
653 /* 661 /*
654 * The order of the tlocks in the transaction is important 662 * The order of the tlocks in the transaction is important
@@ -706,17 +714,18 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
706 */ 714 */
707 tlck->tid = tid; 715 tlck->tid = tid;
708 716
717 TXN_UNLOCK();
718
709 /* mark tlock for meta-data page */ 719 /* mark tlock for meta-data page */
710 if (mp->xflag & COMMIT_PAGE) { 720 if (mp->xflag & COMMIT_PAGE) {
711 721
712 tlck->flag = tlckPAGELOCK; 722 tlck->flag = tlckPAGELOCK;
713 723
714 /* mark the page dirty and nohomeok */ 724 /* mark the page dirty and nohomeok */
715 mark_metapage_dirty(mp); 725 metapage_nohomeok(mp);
716 atomic_inc(&mp->nohomeok);
717 726
718 jfs_info("locking mp = 0x%p, nohomeok = %d tid = %d tlck = 0x%p", 727 jfs_info("locking mp = 0x%p, nohomeok = %d tid = %d tlck = 0x%p",
719 mp, atomic_read(&mp->nohomeok), tid, tlck); 728 mp, mp->nohomeok, tid, tlck);
720 729
721 /* if anonymous transaction, and buffer is on the group 730 /* if anonymous transaction, and buffer is on the group
722 * commit synclist, mark inode to show this. This will 731 * commit synclist, mark inode to show this. This will
@@ -762,8 +771,10 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
762 if (tlck->next == 0) { 771 if (tlck->next == 0) {
763 /* This inode's first anonymous transaction */ 772 /* This inode's first anonymous transaction */
764 jfs_ip->atltail = lid; 773 jfs_ip->atltail = lid;
774 TXN_LOCK();
765 list_add_tail(&jfs_ip->anon_inode_list, 775 list_add_tail(&jfs_ip->anon_inode_list,
766 &TxAnchor.anon_list); 776 &TxAnchor.anon_list);
777 TXN_UNLOCK();
767 } 778 }
768 } 779 }
769 780
@@ -821,8 +832,6 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
821 grantLock: 832 grantLock:
822 tlck->type |= type; 833 tlck->type |= type;
823 834
824 TXN_UNLOCK();
825
826 return tlck; 835 return tlck;
827 836
828 /* 837 /*
@@ -841,11 +850,19 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
841 BUG(); 850 BUG();
842 } 851 }
843 INCREMENT(stattx.waitlock); /* statistics */ 852 INCREMENT(stattx.waitlock); /* statistics */
853 TXN_UNLOCK();
844 release_metapage(mp); 854 release_metapage(mp);
855 TXN_LOCK();
856 xtid = tlck->tid; /* reaquire after dropping TXN_LOCK */
845 857
846 jfs_info("txLock: in waitLock, tid = %d, xtid = %d, lid = %d", 858 jfs_info("txLock: in waitLock, tid = %d, xtid = %d, lid = %d",
847 tid, xtid, lid); 859 tid, xtid, lid);
848 TXN_SLEEP_DROP_LOCK(&tid_to_tblock(xtid)->waitor); 860
861 /* Recheck everything since dropping TXN_LOCK */
862 if (xtid && (tlck->mp == mp) && (mp->lid == lid))
863 TXN_SLEEP_DROP_LOCK(&tid_to_tblock(xtid)->waitor);
864 else
865 TXN_UNLOCK();
849 jfs_info("txLock: awakened tid = %d, lid = %d", tid, lid); 866 jfs_info("txLock: awakened tid = %d, lid = %d", tid, lid);
850 867
851 return NULL; 868 return NULL;
@@ -906,6 +923,7 @@ static void txUnlock(struct tblock * tblk)
906 struct metapage *mp; 923 struct metapage *mp;
907 struct jfs_log *log; 924 struct jfs_log *log;
908 int difft, diffp; 925 int difft, diffp;
926 unsigned long flags;
909 927
910 jfs_info("txUnlock: tblk = 0x%p", tblk); 928 jfs_info("txUnlock: tblk = 0x%p", tblk);
911 log = JFS_SBI(tblk->sb)->log; 929 log = JFS_SBI(tblk->sb)->log;
@@ -925,19 +943,14 @@ static void txUnlock(struct tblock * tblk)
925 assert(mp->xflag & COMMIT_PAGE); 943 assert(mp->xflag & COMMIT_PAGE);
926 944
927 /* hold buffer 945 /* hold buffer
928 *
929 * It's possible that someone else has the metapage.
930 * The only things were changing are nohomeok, which
931 * is handled atomically, and clsn which is protected
932 * by the LOGSYNC_LOCK.
933 */ 946 */
934 hold_metapage(mp, 1); 947 hold_metapage(mp);
935 948
936 assert(atomic_read(&mp->nohomeok) > 0); 949 assert(mp->nohomeok > 0);
937 atomic_dec(&mp->nohomeok); 950 _metapage_homeok(mp);
938 951
939 /* inherit younger/larger clsn */ 952 /* inherit younger/larger clsn */
940 LOGSYNC_LOCK(log); 953 LOGSYNC_LOCK(log, flags);
941 if (mp->clsn) { 954 if (mp->clsn) {
942 logdiff(difft, tblk->clsn, log); 955 logdiff(difft, tblk->clsn, log);
943 logdiff(diffp, mp->clsn, log); 956 logdiff(diffp, mp->clsn, log);
@@ -945,16 +958,11 @@ static void txUnlock(struct tblock * tblk)
945 mp->clsn = tblk->clsn; 958 mp->clsn = tblk->clsn;
946 } else 959 } else
947 mp->clsn = tblk->clsn; 960 mp->clsn = tblk->clsn;
948 LOGSYNC_UNLOCK(log); 961 LOGSYNC_UNLOCK(log, flags);
949 962
950 assert(!(tlck->flag & tlckFREEPAGE)); 963 assert(!(tlck->flag & tlckFREEPAGE));
951 964
952 if (tlck->flag & tlckWRITEPAGE) { 965 put_metapage(mp);
953 write_metapage(mp);
954 } else {
955 /* release page which has been forced */
956 release_metapage(mp);
957 }
958 } 966 }
959 967
960 /* insert tlock, and linelock(s) of the tlock if any, 968 /* insert tlock, and linelock(s) of the tlock if any,
@@ -981,10 +989,10 @@ static void txUnlock(struct tblock * tblk)
981 * has been inserted in logsync list at txUpdateMap()) 989 * has been inserted in logsync list at txUpdateMap())
982 */ 990 */
983 if (tblk->lsn) { 991 if (tblk->lsn) {
984 LOGSYNC_LOCK(log); 992 LOGSYNC_LOCK(log, flags);
985 log->count--; 993 log->count--;
986 list_del(&tblk->synclist); 994 list_del(&tblk->synclist);
987 LOGSYNC_UNLOCK(log); 995 LOGSYNC_UNLOCK(log, flags);
988 } 996 }
989} 997}
990 998
@@ -1573,8 +1581,8 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1573 * the last entry, so don't bother logging this 1581 * the last entry, so don't bother logging this
1574 */ 1582 */
1575 mp->lid = 0; 1583 mp->lid = 0;
1576 hold_metapage(mp, 0); 1584 grab_metapage(mp);
1577 atomic_dec(&mp->nohomeok); 1585 metapage_homeok(mp);
1578 discard_metapage(mp); 1586 discard_metapage(mp);
1579 tlck->mp = NULL; 1587 tlck->mp = NULL;
1580 return 0; 1588 return 0;
@@ -1712,7 +1720,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1712 struct maplock *maplock; 1720 struct maplock *maplock;
1713 struct xdlistlock *xadlock; 1721 struct xdlistlock *xadlock;
1714 struct pxd_lock *pxdlock; 1722 struct pxd_lock *pxdlock;
1715 pxd_t *pxd; 1723 pxd_t *page_pxd;
1716 int next, lwm, hwm; 1724 int next, lwm, hwm;
1717 1725
1718 ip = tlck->ip; 1726 ip = tlck->ip;
@@ -1722,7 +1730,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1722 lrd->log.redopage.type = cpu_to_le16(LOG_XTREE); 1730 lrd->log.redopage.type = cpu_to_le16(LOG_XTREE);
1723 lrd->log.redopage.l2linesize = cpu_to_le16(L2XTSLOTSIZE); 1731 lrd->log.redopage.l2linesize = cpu_to_le16(L2XTSLOTSIZE);
1724 1732
1725 pxd = &lrd->log.redopage.pxd; 1733 page_pxd = &lrd->log.redopage.pxd;
1726 1734
1727 if (tlck->type & tlckBTROOT) { 1735 if (tlck->type & tlckBTROOT) {
1728 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); 1736 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT);
@@ -1752,9 +1760,9 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1752 * applying the after-image to the meta-data page. 1760 * applying the after-image to the meta-data page.
1753 */ 1761 */
1754 lrd->type = cpu_to_le16(LOG_REDOPAGE); 1762 lrd->type = cpu_to_le16(LOG_REDOPAGE);
1755// *pxd = mp->cm_pxd; 1763// *page_pxd = mp->cm_pxd;
1756 PXDaddress(pxd, mp->index); 1764 PXDaddress(page_pxd, mp->index);
1757 PXDlength(pxd, 1765 PXDlength(page_pxd,
1758 mp->logical_size >> tblk->sb->s_blocksize_bits); 1766 mp->logical_size >> tblk->sb->s_blocksize_bits);
1759 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); 1767 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck));
1760 1768
@@ -1776,25 +1784,31 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1776 tlck->flag |= tlckUPDATEMAP; 1784 tlck->flag |= tlckUPDATEMAP;
1777 xadlock->flag = mlckALLOCXADLIST; 1785 xadlock->flag = mlckALLOCXADLIST;
1778 xadlock->count = next - lwm; 1786 xadlock->count = next - lwm;
1779 if ((xadlock->count <= 2) && (tblk->xflag & COMMIT_LAZY)) { 1787 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) {
1780 int i; 1788 int i;
1789 pxd_t *pxd;
1781 /* 1790 /*
1782 * Lazy commit may allow xtree to be modified before 1791 * Lazy commit may allow xtree to be modified before
1783 * txUpdateMap runs. Copy xad into linelock to 1792 * txUpdateMap runs. Copy xad into linelock to
1784 * preserve correct data. 1793 * preserve correct data.
1794 *
1795 * We can fit twice as may pxd's as xads in the lock
1785 */ 1796 */
1786 xadlock->xdlist = &xtlck->pxdlock; 1797 xadlock->flag = mlckALLOCPXDLIST;
1787 memcpy(xadlock->xdlist, &p->xad[lwm], 1798 pxd = xadlock->xdlist = &xtlck->pxdlock;
1788 sizeof(xad_t) * xadlock->count); 1799 for (i = 0; i < xadlock->count; i++) {
1789 1800 PXDaddress(pxd, addressXAD(&p->xad[lwm + i]));
1790 for (i = 0; i < xadlock->count; i++) 1801 PXDlength(pxd, lengthXAD(&p->xad[lwm + i]));
1791 p->xad[lwm + i].flag &= 1802 p->xad[lwm + i].flag &=
1792 ~(XAD_NEW | XAD_EXTENDED); 1803 ~(XAD_NEW | XAD_EXTENDED);
1804 pxd++;
1805 }
1793 } else { 1806 } else {
1794 /* 1807 /*
1795 * xdlist will point to into inode's xtree, ensure 1808 * xdlist will point to into inode's xtree, ensure
1796 * that transaction is not committed lazily. 1809 * that transaction is not committed lazily.
1797 */ 1810 */
1811 xadlock->flag = mlckALLOCXADLIST;
1798 xadlock->xdlist = &p->xad[lwm]; 1812 xadlock->xdlist = &p->xad[lwm];
1799 tblk->xflag &= ~COMMIT_LAZY; 1813 tblk->xflag &= ~COMMIT_LAZY;
1800 } 1814 }
@@ -1836,8 +1850,8 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1836 if (tblk->xflag & COMMIT_TRUNCATE) { 1850 if (tblk->xflag & COMMIT_TRUNCATE) {
1837 /* write NOREDOPAGE for the page */ 1851 /* write NOREDOPAGE for the page */
1838 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); 1852 lrd->type = cpu_to_le16(LOG_NOREDOPAGE);
1839 PXDaddress(pxd, mp->index); 1853 PXDaddress(page_pxd, mp->index);
1840 PXDlength(pxd, 1854 PXDlength(page_pxd,
1841 mp->logical_size >> tblk->sb-> 1855 mp->logical_size >> tblk->sb->
1842 s_blocksize_bits); 1856 s_blocksize_bits);
1843 lrd->backchain = 1857 lrd->backchain =
@@ -1872,22 +1886,32 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1872 * deleted page itself; 1886 * deleted page itself;
1873 */ 1887 */
1874 tlck->flag |= tlckUPDATEMAP; 1888 tlck->flag |= tlckUPDATEMAP;
1875 xadlock->flag = mlckFREEXADLIST;
1876 xadlock->count = hwm - XTENTRYSTART + 1; 1889 xadlock->count = hwm - XTENTRYSTART + 1;
1877 if ((xadlock->count <= 2) && (tblk->xflag & COMMIT_LAZY)) { 1890 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) {
1891 int i;
1892 pxd_t *pxd;
1878 /* 1893 /*
1879 * Lazy commit may allow xtree to be modified before 1894 * Lazy commit may allow xtree to be modified before
1880 * txUpdateMap runs. Copy xad into linelock to 1895 * txUpdateMap runs. Copy xad into linelock to
1881 * preserve correct data. 1896 * preserve correct data.
1897 *
1898 * We can fit twice as may pxd's as xads in the lock
1882 */ 1899 */
1883 xadlock->xdlist = &xtlck->pxdlock; 1900 xadlock->flag = mlckFREEPXDLIST;
1884 memcpy(xadlock->xdlist, &p->xad[XTENTRYSTART], 1901 pxd = xadlock->xdlist = &xtlck->pxdlock;
1885 sizeof(xad_t) * xadlock->count); 1902 for (i = 0; i < xadlock->count; i++) {
1903 PXDaddress(pxd,
1904 addressXAD(&p->xad[XTENTRYSTART + i]));
1905 PXDlength(pxd,
1906 lengthXAD(&p->xad[XTENTRYSTART + i]));
1907 pxd++;
1908 }
1886 } else { 1909 } else {
1887 /* 1910 /*
1888 * xdlist will point to into inode's xtree, ensure 1911 * xdlist will point to into inode's xtree, ensure
1889 * that transaction is not committed lazily. 1912 * that transaction is not committed lazily.
1890 */ 1913 */
1914 xadlock->flag = mlckFREEXADLIST;
1891 xadlock->xdlist = &p->xad[XTENTRYSTART]; 1915 xadlock->xdlist = &p->xad[XTENTRYSTART];
1892 tblk->xflag &= ~COMMIT_LAZY; 1916 tblk->xflag &= ~COMMIT_LAZY;
1893 } 1917 }
@@ -1918,7 +1942,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1918 * header ? 1942 * header ?
1919 */ 1943 */
1920 if (tlck->type & tlckTRUNCATE) { 1944 if (tlck->type & tlckTRUNCATE) {
1921 pxd_t tpxd; /* truncated extent of xad */ 1945 pxd_t pxd; /* truncated extent of xad */
1922 int twm; 1946 int twm;
1923 1947
1924 /* 1948 /*
@@ -1947,8 +1971,9 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1947 * applying the after-image to the meta-data page. 1971 * applying the after-image to the meta-data page.
1948 */ 1972 */
1949 lrd->type = cpu_to_le16(LOG_REDOPAGE); 1973 lrd->type = cpu_to_le16(LOG_REDOPAGE);
1950 PXDaddress(pxd, mp->index); 1974 PXDaddress(page_pxd, mp->index);
1951 PXDlength(pxd, mp->logical_size >> tblk->sb->s_blocksize_bits); 1975 PXDlength(page_pxd,
1976 mp->logical_size >> tblk->sb->s_blocksize_bits);
1952 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); 1977 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck));
1953 1978
1954 /* 1979 /*
@@ -1966,7 +1991,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1966 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD); 1991 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD);
1967 lrd->log.updatemap.nxd = cpu_to_le16(1); 1992 lrd->log.updatemap.nxd = cpu_to_le16(1);
1968 lrd->log.updatemap.pxd = pxdlock->pxd; 1993 lrd->log.updatemap.pxd = pxdlock->pxd;
1969 tpxd = pxdlock->pxd; /* save to format maplock */ 1994 pxd = pxdlock->pxd; /* save to format maplock */
1970 lrd->backchain = 1995 lrd->backchain =
1971 cpu_to_le32(lmLog(log, tblk, lrd, NULL)); 1996 cpu_to_le32(lmLog(log, tblk, lrd, NULL));
1972 } 1997 }
@@ -2035,7 +2060,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
2035 pxdlock = (struct pxd_lock *) xadlock; 2060 pxdlock = (struct pxd_lock *) xadlock;
2036 pxdlock->flag = mlckFREEPXD; 2061 pxdlock->flag = mlckFREEPXD;
2037 pxdlock->count = 1; 2062 pxdlock->count = 1;
2038 pxdlock->pxd = tpxd; 2063 pxdlock->pxd = pxd;
2039 2064
2040 jfs_info("xtLog: truncate ip:0x%p mp:0x%p count:%d " 2065 jfs_info("xtLog: truncate ip:0x%p mp:0x%p count:%d "
2041 "hwm:%d", ip, mp, pxdlock->count, hwm); 2066 "hwm:%d", ip, mp, pxdlock->count, hwm);
@@ -2253,7 +2278,8 @@ void txForce(struct tblock * tblk)
2253 tlck->flag &= ~tlckWRITEPAGE; 2278 tlck->flag &= ~tlckWRITEPAGE;
2254 2279
2255 /* do not release page to freelist */ 2280 /* do not release page to freelist */
2256 2281 force_metapage(mp);
2282#if 0
2257 /* 2283 /*
2258 * The "right" thing to do here is to 2284 * The "right" thing to do here is to
2259 * synchronously write the metadata. 2285 * synchronously write the metadata.
@@ -2265,9 +2291,10 @@ void txForce(struct tblock * tblk)
2265 * we can get by with synchronously writing 2291 * we can get by with synchronously writing
2266 * the pages when they are released. 2292 * the pages when they are released.
2267 */ 2293 */
2268 assert(atomic_read(&mp->nohomeok)); 2294 assert(mp->nohomeok);
2269 set_bit(META_dirty, &mp->flag); 2295 set_bit(META_dirty, &mp->flag);
2270 set_bit(META_sync, &mp->flag); 2296 set_bit(META_sync, &mp->flag);
2297#endif
2271 } 2298 }
2272 } 2299 }
2273 } 2300 }
@@ -2327,7 +2354,7 @@ static void txUpdateMap(struct tblock * tblk)
2327 */ 2354 */
2328 mp = tlck->mp; 2355 mp = tlck->mp;
2329 ASSERT(mp->xflag & COMMIT_PAGE); 2356 ASSERT(mp->xflag & COMMIT_PAGE);
2330 hold_metapage(mp, 0); 2357 grab_metapage(mp);
2331 } 2358 }
2332 2359
2333 /* 2360 /*
@@ -2377,8 +2404,8 @@ static void txUpdateMap(struct tblock * tblk)
2377 ASSERT(mp->lid == lid); 2404 ASSERT(mp->lid == lid);
2378 tlck->mp->lid = 0; 2405 tlck->mp->lid = 0;
2379 } 2406 }
2380 assert(atomic_read(&mp->nohomeok) == 1); 2407 assert(mp->nohomeok == 1);
2381 atomic_dec(&mp->nohomeok); 2408 metapage_homeok(mp);
2382 discard_metapage(mp); 2409 discard_metapage(mp);
2383 tlck->mp = NULL; 2410 tlck->mp = NULL;
2384 } 2411 }
@@ -2844,24 +2871,9 @@ static void LogSyncRelease(struct metapage * mp)
2844{ 2871{
2845 struct jfs_log *log = mp->log; 2872 struct jfs_log *log = mp->log;
2846 2873
2847 assert(atomic_read(&mp->nohomeok)); 2874 assert(mp->nohomeok);
2848 assert(log); 2875 assert(log);
2849 atomic_dec(&mp->nohomeok); 2876 metapage_homeok(mp);
2850
2851 if (atomic_read(&mp->nohomeok))
2852 return;
2853
2854 hold_metapage(mp, 0);
2855
2856 LOGSYNC_LOCK(log);
2857 mp->log = NULL;
2858 mp->lsn = 0;
2859 mp->clsn = 0;
2860 log->count--;
2861 list_del_init(&mp->synclist);
2862 LOGSYNC_UNLOCK(log);
2863
2864 release_metapage(mp);
2865} 2877}
2866 2878
2867/* 2879/*
diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c
index f31a9e3f3fec..5cf91785b541 100644
--- a/fs/jfs/jfs_umount.c
+++ b/fs/jfs/jfs_umount.c
@@ -49,7 +49,6 @@
49 */ 49 */
50int jfs_umount(struct super_block *sb) 50int jfs_umount(struct super_block *sb)
51{ 51{
52 struct address_space *bdev_mapping = sb->s_bdev->bd_inode->i_mapping;
53 struct jfs_sb_info *sbi = JFS_SBI(sb); 52 struct jfs_sb_info *sbi = JFS_SBI(sb);
54 struct inode *ipbmap = sbi->ipbmap; 53 struct inode *ipbmap = sbi->ipbmap;
55 struct inode *ipimap = sbi->ipimap; 54 struct inode *ipimap = sbi->ipimap;
@@ -109,8 +108,8 @@ int jfs_umount(struct super_block *sb)
109 * Make sure all metadata makes it to disk before we mark 108 * Make sure all metadata makes it to disk before we mark
110 * the superblock as clean 109 * the superblock as clean
111 */ 110 */
112 filemap_fdatawrite(bdev_mapping); 111 filemap_fdatawrite(sbi->direct_inode->i_mapping);
113 filemap_fdatawait(bdev_mapping); 112 filemap_fdatawait(sbi->direct_inode->i_mapping);
114 113
115 /* 114 /*
116 * ensure all file system file pages are propagated to their 115 * ensure all file system file pages are propagated to their
@@ -123,9 +122,6 @@ int jfs_umount(struct super_block *sb)
123 if (log) { /* log = NULL if read-only mount */ 122 if (log) { /* log = NULL if read-only mount */
124 updateSuper(sb, FM_CLEAN); 123 updateSuper(sb, FM_CLEAN);
125 124
126 /* Restore default gfp_mask for bdev */
127 mapping_set_gfp_mask(bdev_mapping, GFP_USER);
128
129 /* 125 /*
130 * close log: 126 * close log:
131 * 127 *
@@ -140,7 +136,6 @@ int jfs_umount(struct super_block *sb)
140 136
141int jfs_umount_rw(struct super_block *sb) 137int jfs_umount_rw(struct super_block *sb)
142{ 138{
143 struct address_space *bdev_mapping = sb->s_bdev->bd_inode->i_mapping;
144 struct jfs_sb_info *sbi = JFS_SBI(sb); 139 struct jfs_sb_info *sbi = JFS_SBI(sb);
145 struct jfs_log *log = sbi->log; 140 struct jfs_log *log = sbi->log;
146 141
@@ -166,13 +161,10 @@ int jfs_umount_rw(struct super_block *sb)
166 * mark the superblock clean before everything is flushed to 161 * mark the superblock clean before everything is flushed to
167 * disk. 162 * disk.
168 */ 163 */
169 filemap_fdatawrite(bdev_mapping); 164 filemap_fdatawrite(sbi->direct_inode->i_mapping);
170 filemap_fdatawait(bdev_mapping); 165 filemap_fdatawait(sbi->direct_inode->i_mapping);
171 166
172 updateSuper(sb, FM_CLEAN); 167 updateSuper(sb, FM_CLEAN);
173 168
174 /* Restore default gfp_mask for bdev */
175 mapping_set_gfp_mask(bdev_mapping, GFP_USER);
176
177 return lmLogClose(sb); 169 return lmLogClose(sb);
178} 170}
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index 11c58c54b818..31b34db4519e 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) International Business Machines Corp., 2000-2004 2 * Copyright (C) International Business Machines Corp., 2000-2005
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -111,8 +111,8 @@ static struct {
111/* 111/*
112 * forward references 112 * forward references
113 */ 113 */
114static int xtSearch(struct inode *ip, 114static int xtSearch(struct inode *ip, s64 xoff, s64 *next, int *cmpp,
115 s64 xoff, int *cmpp, struct btstack * btstack, int flag); 115 struct btstack * btstack, int flag);
116 116
117static int xtSplitUp(tid_t tid, 117static int xtSplitUp(tid_t tid,
118 struct inode *ip, 118 struct inode *ip,
@@ -159,11 +159,12 @@ int xtLookup(struct inode *ip, s64 lstart,
159 xtpage_t *p; 159 xtpage_t *p;
160 int index; 160 int index;
161 xad_t *xad; 161 xad_t *xad;
162 s64 size, xoff, xend; 162 s64 next, size, xoff, xend;
163 int xlen; 163 int xlen;
164 s64 xaddr; 164 s64 xaddr;
165 165
166 *plen = 0; 166 *paddr = 0;
167 *plen = llen;
167 168
168 if (!no_check) { 169 if (!no_check) {
169 /* is lookup offset beyond eof ? */ 170 /* is lookup offset beyond eof ? */
@@ -180,7 +181,7 @@ int xtLookup(struct inode *ip, s64 lstart,
180 * search for the xad entry covering the logical extent 181 * search for the xad entry covering the logical extent
181 */ 182 */
182//search: 183//search:
183 if ((rc = xtSearch(ip, lstart, &cmp, &btstack, 0))) { 184 if ((rc = xtSearch(ip, lstart, &next, &cmp, &btstack, 0))) {
184 jfs_err("xtLookup: xtSearch returned %d", rc); 185 jfs_err("xtLookup: xtSearch returned %d", rc);
185 return rc; 186 return rc;
186 } 187 }
@@ -198,8 +199,11 @@ int xtLookup(struct inode *ip, s64 lstart,
198 * lstart is a page start address, 199 * lstart is a page start address,
199 * i.e., lstart cannot start in a hole; 200 * i.e., lstart cannot start in a hole;
200 */ 201 */
201 if (cmp) 202 if (cmp) {
203 if (next)
204 *plen = min(next - lstart, llen);
202 goto out; 205 goto out;
206 }
203 207
204 /* 208 /*
205 * lxd covered by xad 209 * lxd covered by xad
@@ -284,7 +288,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist,
284 if (lstart >= size) 288 if (lstart >= size)
285 return 0; 289 return 0;
286 290
287 if ((rc = xtSearch(ip, lstart, &cmp, &btstack, 0))) 291 if ((rc = xtSearch(ip, lstart, NULL, &cmp, &btstack, 0)))
288 return rc; 292 return rc;
289 293
290 /* 294 /*
@@ -488,6 +492,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist,
488 * parameters: 492 * parameters:
489 * ip - file object; 493 * ip - file object;
490 * xoff - extent offset; 494 * xoff - extent offset;
495 * nextp - address of next extent (if any) for search miss
491 * cmpp - comparison result: 496 * cmpp - comparison result:
492 * btstack - traverse stack; 497 * btstack - traverse stack;
493 * flag - search process flag (XT_INSERT); 498 * flag - search process flag (XT_INSERT);
@@ -497,7 +502,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist,
497 * *cmpp is set to result of comparison with the entry returned. 502 * *cmpp is set to result of comparison with the entry returned.
498 * the page containing the entry is pinned at exit. 503 * the page containing the entry is pinned at exit.
499 */ 504 */
500static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */ 505static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
501 int *cmpp, struct btstack * btstack, int flag) 506 int *cmpp, struct btstack * btstack, int flag)
502{ 507{
503 struct jfs_inode_info *jfs_ip = JFS_IP(ip); 508 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
@@ -511,6 +516,7 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
511 struct btframe *btsp; 516 struct btframe *btsp;
512 int nsplit = 0; /* number of pages to split */ 517 int nsplit = 0; /* number of pages to split */
513 s64 t64; 518 s64 t64;
519 s64 next = 0;
514 520
515 INCREMENT(xtStat.search); 521 INCREMENT(xtStat.search);
516 522
@@ -579,6 +585,7 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
579 * previous and this entry 585 * previous and this entry
580 */ 586 */
581 *cmpp = 1; 587 *cmpp = 1;
588 next = t64;
582 goto out; 589 goto out;
583 } 590 }
584 591
@@ -623,6 +630,9 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
623 /* update sequential access heuristics */ 630 /* update sequential access heuristics */
624 jfs_ip->btindex = index; 631 jfs_ip->btindex = index;
625 632
633 if (nextp)
634 *nextp = next;
635
626 INCREMENT(xtStat.fastSearch); 636 INCREMENT(xtStat.fastSearch);
627 return 0; 637 return 0;
628 } 638 }
@@ -675,10 +685,11 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
675 685
676 return 0; 686 return 0;
677 } 687 }
678
679 /* search hit - internal page: 688 /* search hit - internal page:
680 * descend/search its child page 689 * descend/search its child page
681 */ 690 */
691 if (index < le16_to_cpu(p->header.nextindex)-1)
692 next = offsetXAD(&p->xad[index + 1]);
682 goto next; 693 goto next;
683 } 694 }
684 695
@@ -694,6 +705,8 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
694 * base is the smallest index with key (Kj) greater than 705 * base is the smallest index with key (Kj) greater than
695 * search key (K) and may be zero or maxentry index. 706 * search key (K) and may be zero or maxentry index.
696 */ 707 */
708 if (base < le16_to_cpu(p->header.nextindex))
709 next = offsetXAD(&p->xad[base]);
697 /* 710 /*
698 * search miss - leaf page: 711 * search miss - leaf page:
699 * 712 *
@@ -727,6 +740,9 @@ static int xtSearch(struct inode *ip, s64 xoff, /* offset of extent */
727 jfs_ip->btorder = BT_RANDOM; 740 jfs_ip->btorder = BT_RANDOM;
728 jfs_ip->btindex = base; 741 jfs_ip->btindex = base;
729 742
743 if (nextp)
744 *nextp = next;
745
730 return 0; 746 return 0;
731 } 747 }
732 748
@@ -793,6 +809,7 @@ int xtInsert(tid_t tid, /* transaction id */
793 struct xtsplit split; /* split information */ 809 struct xtsplit split; /* split information */
794 xad_t *xad; 810 xad_t *xad;
795 int cmp; 811 int cmp;
812 s64 next;
796 struct tlock *tlck; 813 struct tlock *tlck;
797 struct xtlock *xtlck; 814 struct xtlock *xtlck;
798 815
@@ -806,7 +823,7 @@ int xtInsert(tid_t tid, /* transaction id */
806 * n.b. xtSearch() may return index of maxentry of 823 * n.b. xtSearch() may return index of maxentry of
807 * the full page. 824 * the full page.
808 */ 825 */
809 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT))) 826 if ((rc = xtSearch(ip, xoff, &next, &cmp, &btstack, XT_INSERT)))
810 return rc; 827 return rc;
811 828
812 /* retrieve search result */ 829 /* retrieve search result */
@@ -814,7 +831,7 @@ int xtInsert(tid_t tid, /* transaction id */
814 831
815 /* This test must follow XT_GETSEARCH since mp must be valid if 832 /* This test must follow XT_GETSEARCH since mp must be valid if
816 * we branch to out: */ 833 * we branch to out: */
817 if (cmp == 0) { 834 if ((cmp == 0) || (next && (xlen > next - xoff))) {
818 rc = -EEXIST; 835 rc = -EEXIST;
819 goto out; 836 goto out;
820 } 837 }
@@ -1626,7 +1643,7 @@ int xtExtend(tid_t tid, /* transaction id */
1626 jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen); 1643 jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen);
1627 1644
1628 /* there must exist extent to be extended */ 1645 /* there must exist extent to be extended */
1629 if ((rc = xtSearch(ip, xoff - 1, &cmp, &btstack, XT_INSERT))) 1646 if ((rc = xtSearch(ip, xoff - 1, NULL, &cmp, &btstack, XT_INSERT)))
1630 return rc; 1647 return rc;
1631 1648
1632 /* retrieve search result */ 1649 /* retrieve search result */
@@ -1794,7 +1811,7 @@ printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n",
1794*/ 1811*/
1795 1812
1796 /* there must exist extent to be tailgated */ 1813 /* there must exist extent to be tailgated */
1797 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT))) 1814 if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, XT_INSERT)))
1798 return rc; 1815 return rc;
1799 1816
1800 /* retrieve search result */ 1817 /* retrieve search result */
@@ -1977,7 +1994,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
1977 nxlen = lengthXAD(nxad); 1994 nxlen = lengthXAD(nxad);
1978 nxaddr = addressXAD(nxad); 1995 nxaddr = addressXAD(nxad);
1979 1996
1980 if ((rc = xtSearch(ip, nxoff, &cmp, &btstack, XT_INSERT))) 1997 if ((rc = xtSearch(ip, nxoff, NULL, &cmp, &btstack, XT_INSERT)))
1981 return rc; 1998 return rc;
1982 1999
1983 /* retrieve search result */ 2000 /* retrieve search result */
@@ -2291,7 +2308,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
2291 if (nextindex == le16_to_cpu(p->header.maxentry)) { 2308 if (nextindex == le16_to_cpu(p->header.maxentry)) {
2292 XT_PUTPAGE(mp); 2309 XT_PUTPAGE(mp);
2293 2310
2294 if ((rc = xtSearch(ip, nxoff, &cmp, &btstack, XT_INSERT))) 2311 if ((rc = xtSearch(ip, nxoff, NULL, &cmp, &btstack, XT_INSERT)))
2295 return rc; 2312 return rc;
2296 2313
2297 /* retrieve search result */ 2314 /* retrieve search result */
@@ -2438,6 +2455,7 @@ int xtAppend(tid_t tid, /* transaction id */
2438 int nsplit, nblocks, xlen; 2455 int nsplit, nblocks, xlen;
2439 struct pxdlist pxdlist; 2456 struct pxdlist pxdlist;
2440 pxd_t *pxd; 2457 pxd_t *pxd;
2458 s64 next;
2441 2459
2442 xaddr = *xaddrp; 2460 xaddr = *xaddrp;
2443 xlen = *xlenp; 2461 xlen = *xlenp;
@@ -2452,7 +2470,7 @@ int xtAppend(tid_t tid, /* transaction id */
2452 * n.b. xtSearch() may return index of maxentry of 2470 * n.b. xtSearch() may return index of maxentry of
2453 * the full page. 2471 * the full page.
2454 */ 2472 */
2455 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, XT_INSERT))) 2473 if ((rc = xtSearch(ip, xoff, &next, &cmp, &btstack, XT_INSERT)))
2456 return rc; 2474 return rc;
2457 2475
2458 /* retrieve search result */ 2476 /* retrieve search result */
@@ -2462,6 +2480,9 @@ int xtAppend(tid_t tid, /* transaction id */
2462 rc = -EEXIST; 2480 rc = -EEXIST;
2463 goto out; 2481 goto out;
2464 } 2482 }
2483
2484 if (next)
2485 xlen = min(xlen, (int)(next - xoff));
2465//insert: 2486//insert:
2466 /* 2487 /*
2467 * insert entry for new extent 2488 * insert entry for new extent
@@ -2600,7 +2621,7 @@ int xtDelete(tid_t tid, struct inode *ip, s64 xoff, s32 xlen, int flag)
2600 /* 2621 /*
2601 * find the matching entry; xtSearch() pins the page 2622 * find the matching entry; xtSearch() pins the page
2602 */ 2623 */
2603 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, 0))) 2624 if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0)))
2604 return rc; 2625 return rc;
2605 2626
2606 XT_GETSEARCH(ip, btstack.top, bn, mp, p, index); 2627 XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
@@ -2852,7 +2873,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */
2852 */ 2873 */
2853 if (xtype == DATAEXT) { 2874 if (xtype == DATAEXT) {
2854 /* search in leaf entry */ 2875 /* search in leaf entry */
2855 rc = xtSearch(ip, xoff, &cmp, &btstack, 0); 2876 rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0);
2856 if (rc) 2877 if (rc)
2857 return rc; 2878 return rc;
2858 2879
@@ -2958,7 +2979,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */
2958 } 2979 }
2959 2980
2960 /* get back parent page */ 2981 /* get back parent page */
2961 if ((rc = xtSearch(ip, xoff, &cmp, &btstack, 0))) 2982 if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0)))
2962 return rc; 2983 return rc;
2963 2984
2964 XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index); 2985 XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index);
@@ -3991,7 +4012,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
3991 4012
3992 if (committed_size) { 4013 if (committed_size) {
3993 xoff = (committed_size >> JFS_SBI(ip->i_sb)->l2bsize) - 1; 4014 xoff = (committed_size >> JFS_SBI(ip->i_sb)->l2bsize) - 1;
3994 rc = xtSearch(ip, xoff, &cmp, &btstack, 0); 4015 rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0);
3995 if (rc) 4016 if (rc)
3996 return rc; 4017 return rc;
3997 4018
diff --git a/fs/jfs/resize.c b/fs/jfs/resize.c
index 2eb6869b6e72..c6dc254d3253 100644
--- a/fs/jfs/resize.c
+++ b/fs/jfs/resize.c
@@ -209,6 +209,9 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
209 */ 209 */
210 txQuiesce(sb); 210 txQuiesce(sb);
211 211
212 /* Reset size of direct inode */
213 sbi->direct_inode->i_size = sb->s_bdev->bd_inode->i_size;
214
212 if (sbi->mntflag & JFS_INLINELOG) { 215 if (sbi->mntflag & JFS_INLINELOG) {
213 /* 216 /*
214 * deactivate old inline log 217 * deactivate old inline log
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 5856866e24fc..5e774ed7fb64 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -210,6 +210,10 @@ static void jfs_put_super(struct super_block *sb)
210 unload_nls(sbi->nls_tab); 210 unload_nls(sbi->nls_tab);
211 sbi->nls_tab = NULL; 211 sbi->nls_tab = NULL;
212 212
213 truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
214 iput(sbi->direct_inode);
215 sbi->direct_inode = NULL;
216
213 kfree(sbi); 217 kfree(sbi);
214} 218}
215 219
@@ -358,6 +362,12 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
358 } 362 }
359 363
360 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { 364 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
365 /*
366 * Invalidate any previously read metadata. fsck may have
367 * changed the on-disk data since we mounted r/o
368 */
369 truncate_inode_pages(JFS_SBI(sb)->direct_inode->i_mapping, 0);
370
361 JFS_SBI(sb)->flag = flag; 371 JFS_SBI(sb)->flag = flag;
362 return jfs_mount_rw(sb, 1); 372 return jfs_mount_rw(sb, 1);
363 } 373 }
@@ -428,12 +438,26 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
428 sb->s_op = &jfs_super_operations; 438 sb->s_op = &jfs_super_operations;
429 sb->s_export_op = &jfs_export_operations; 439 sb->s_export_op = &jfs_export_operations;
430 440
441 /*
442 * Initialize direct-mapping inode/address-space
443 */
444 inode = new_inode(sb);
445 if (inode == NULL)
446 goto out_kfree;
447 inode->i_ino = 0;
448 inode->i_nlink = 1;
449 inode->i_size = sb->s_bdev->bd_inode->i_size;
450 inode->i_mapping->a_ops = &jfs_metapage_aops;
451 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
452
453 sbi->direct_inode = inode;
454
431 rc = jfs_mount(sb); 455 rc = jfs_mount(sb);
432 if (rc) { 456 if (rc) {
433 if (!silent) { 457 if (!silent) {
434 jfs_err("jfs_mount failed w/return code = %d", rc); 458 jfs_err("jfs_mount failed w/return code = %d", rc);
435 } 459 }
436 goto out_kfree; 460 goto out_mount_failed;
437 } 461 }
438 if (sb->s_flags & MS_RDONLY) 462 if (sb->s_flags & MS_RDONLY)
439 sbi->log = NULL; 463 sbi->log = NULL;
@@ -482,6 +506,13 @@ out_no_rw:
482 if (rc) { 506 if (rc) {
483 jfs_err("jfs_umount failed with return code %d", rc); 507 jfs_err("jfs_umount failed with return code %d", rc);
484 } 508 }
509out_mount_failed:
510 filemap_fdatawrite(sbi->direct_inode->i_mapping);
511 filemap_fdatawait(sbi->direct_inode->i_mapping);
512 truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
513 make_bad_inode(sbi->direct_inode);
514 iput(sbi->direct_inode);
515 sbi->direct_inode = NULL;
485out_kfree: 516out_kfree:
486 if (sbi->nls_tab) 517 if (sbi->nls_tab)
487 unload_nls(sbi->nls_tab); 518 unload_nls(sbi->nls_tab);
@@ -527,8 +558,10 @@ static int jfs_sync_fs(struct super_block *sb, int wait)
527 struct jfs_log *log = JFS_SBI(sb)->log; 558 struct jfs_log *log = JFS_SBI(sb)->log;
528 559
529 /* log == NULL indicates read-only mount */ 560 /* log == NULL indicates read-only mount */
530 if (log) 561 if (log) {
531 jfs_flush_journal(log, wait); 562 jfs_flush_journal(log, wait);
563 jfs_syncpt(log);
564 }
532 565
533 return 0; 566 return 0;
534} 567}
diff --git a/fs/locks.c b/fs/locks.c
index 1792ce547af7..3fa6a7ce57a7 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -406,12 +406,12 @@ static void lease_release_private_callback(struct file_lock *fl)
406 fl->fl_file->f_owner.signum = 0; 406 fl->fl_file->f_owner.signum = 0;
407} 407}
408 408
409int lease_mylease_callback(struct file_lock *fl, struct file_lock *try) 409static int lease_mylease_callback(struct file_lock *fl, struct file_lock *try)
410{ 410{
411 return fl->fl_file == try->fl_file; 411 return fl->fl_file == try->fl_file;
412} 412}
413 413
414struct lock_manager_operations lease_manager_ops = { 414static struct lock_manager_operations lease_manager_ops = {
415 .fl_break = lease_break_callback, 415 .fl_break = lease_break_callback,
416 .fl_release_private = lease_release_private_callback, 416 .fl_release_private = lease_release_private_callback,
417 .fl_mylease = lease_mylease_callback, 417 .fl_mylease = lease_mylease_callback,
@@ -1274,7 +1274,7 @@ int fcntl_getlease(struct file *filp)
1274 * 1274 *
1275 * Called with kernel lock held. 1275 * Called with kernel lock held.
1276 */ 1276 */
1277int __setlease(struct file *filp, long arg, struct file_lock **flp) 1277static int __setlease(struct file *filp, long arg, struct file_lock **flp)
1278{ 1278{
1279 struct file_lock *fl, **before, **my_before = NULL, *lease = *flp; 1279 struct file_lock *fl, **before, **my_before = NULL, *lease = *flp;
1280 struct dentry *dentry = filp->f_dentry; 1280 struct dentry *dentry = filp->f_dentry;
diff --git a/fs/mbcache.c b/fs/mbcache.c
index f9e4d2700cd8..c7170b9221a3 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -57,7 +57,7 @@
57 57
58#define MB_CACHE_WRITER ((unsigned short)~0U >> 1) 58#define MB_CACHE_WRITER ((unsigned short)~0U >> 1)
59 59
60DECLARE_WAIT_QUEUE_HEAD(mb_cache_queue); 60static DECLARE_WAIT_QUEUE_HEAD(mb_cache_queue);
61 61
62MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>"); 62MODULE_AUTHOR("Andreas Gruenbacher <a.gruenbacher@computer.org>");
63MODULE_DESCRIPTION("Meta block cache (for extended attributes)"); 63MODULE_DESCRIPTION("Meta block cache (for extended attributes)");
diff --git a/fs/mpage.c b/fs/mpage.c
index e7d8d1a77606..b92c0e64aefa 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -87,7 +87,7 @@ static int mpage_end_io_write(struct bio *bio, unsigned int bytes_done, int err)
87 return 0; 87 return 0;
88} 88}
89 89
90struct bio *mpage_bio_submit(int rw, struct bio *bio) 90static struct bio *mpage_bio_submit(int rw, struct bio *bio)
91{ 91{
92 bio->bi_end_io = mpage_end_io_read; 92 bio->bi_end_io = mpage_end_io_read;
93 if (rw == WRITE) 93 if (rw == WRITE)
@@ -160,52 +160,6 @@ map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block)
160 } while (page_bh != head); 160 } while (page_bh != head);
161} 161}
162 162
163/**
164 * mpage_readpages - populate an address space with some pages, and
165 * start reads against them.
166 *
167 * @mapping: the address_space
168 * @pages: The address of a list_head which contains the target pages. These
169 * pages have their ->index populated and are otherwise uninitialised.
170 *
171 * The page at @pages->prev has the lowest file offset, and reads should be
172 * issued in @pages->prev to @pages->next order.
173 *
174 * @nr_pages: The number of pages at *@pages
175 * @get_block: The filesystem's block mapper function.
176 *
177 * This function walks the pages and the blocks within each page, building and
178 * emitting large BIOs.
179 *
180 * If anything unusual happens, such as:
181 *
182 * - encountering a page which has buffers
183 * - encountering a page which has a non-hole after a hole
184 * - encountering a page with non-contiguous blocks
185 *
186 * then this code just gives up and calls the buffer_head-based read function.
187 * It does handle a page which has holes at the end - that is a common case:
188 * the end-of-file on blocksize < PAGE_CACHE_SIZE setups.
189 *
190 * BH_Boundary explanation:
191 *
192 * There is a problem. The mpage read code assembles several pages, gets all
193 * their disk mappings, and then submits them all. That's fine, but obtaining
194 * the disk mappings may require I/O. Reads of indirect blocks, for example.
195 *
196 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be
197 * submitted in the following order:
198 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16
199 * because the indirect block has to be read to get the mappings of blocks
200 * 13,14,15,16. Obviously, this impacts performance.
201 *
202 * So what we do it to allow the filesystem's get_block() function to set
203 * BH_Boundary when it maps block 11. BH_Boundary says: mapping of the block
204 * after this one will require I/O against a block which is probably close to
205 * this one. So you should push what I/O you have currently accumulated.
206 *
207 * This all causes the disk requests to be issued in the correct order.
208 */
209static struct bio * 163static struct bio *
210do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, 164do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
211 sector_t *last_block_in_bio, get_block_t get_block) 165 sector_t *last_block_in_bio, get_block_t get_block)
@@ -320,6 +274,52 @@ confused:
320 goto out; 274 goto out;
321} 275}
322 276
277/**
278 * mpage_readpages - populate an address space with some pages, and
279 * start reads against them.
280 *
281 * @mapping: the address_space
282 * @pages: The address of a list_head which contains the target pages. These
283 * pages have their ->index populated and are otherwise uninitialised.
284 *
285 * The page at @pages->prev has the lowest file offset, and reads should be
286 * issued in @pages->prev to @pages->next order.
287 *
288 * @nr_pages: The number of pages at *@pages
289 * @get_block: The filesystem's block mapper function.
290 *
291 * This function walks the pages and the blocks within each page, building and
292 * emitting large BIOs.
293 *
294 * If anything unusual happens, such as:
295 *
296 * - encountering a page which has buffers
297 * - encountering a page which has a non-hole after a hole
298 * - encountering a page with non-contiguous blocks
299 *
300 * then this code just gives up and calls the buffer_head-based read function.
301 * It does handle a page which has holes at the end - that is a common case:
302 * the end-of-file on blocksize < PAGE_CACHE_SIZE setups.
303 *
304 * BH_Boundary explanation:
305 *
306 * There is a problem. The mpage read code assembles several pages, gets all
307 * their disk mappings, and then submits them all. That's fine, but obtaining
308 * the disk mappings may require I/O. Reads of indirect blocks, for example.
309 *
310 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be
311 * submitted in the following order:
312 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16
313 * because the indirect block has to be read to get the mappings of blocks
314 * 13,14,15,16. Obviously, this impacts performance.
315 *
316 * So what we do it to allow the filesystem's get_block() function to set
317 * BH_Boundary when it maps block 11. BH_Boundary says: mapping of the block
318 * after this one will require I/O against a block which is probably close to
319 * this one. So you should push what I/O you have currently accumulated.
320 *
321 * This all causes the disk requests to be issued in the correct order.
322 */
323int 323int
324mpage_readpages(struct address_space *mapping, struct list_head *pages, 324mpage_readpages(struct address_space *mapping, struct list_head *pages,
325 unsigned nr_pages, get_block_t get_block) 325 unsigned nr_pages, get_block_t get_block)
@@ -627,15 +627,6 @@ int
627mpage_writepages(struct address_space *mapping, 627mpage_writepages(struct address_space *mapping,
628 struct writeback_control *wbc, get_block_t get_block) 628 struct writeback_control *wbc, get_block_t get_block)
629{ 629{
630 return __mpage_writepages(mapping, wbc, get_block,
631 mapping->a_ops->writepage);
632}
633
634int
635__mpage_writepages(struct address_space *mapping,
636 struct writeback_control *wbc, get_block_t get_block,
637 writepage_t writepage_fn)
638{
639 struct backing_dev_info *bdi = mapping->backing_dev_info; 630 struct backing_dev_info *bdi = mapping->backing_dev_info;
640 struct bio *bio = NULL; 631 struct bio *bio = NULL;
641 sector_t last_block_in_bio = 0; 632 sector_t last_block_in_bio = 0;
@@ -725,8 +716,10 @@ retry:
725 } else { 716 } else {
726 bio = __mpage_writepage(bio, page, get_block, 717 bio = __mpage_writepage(bio, page, get_block,
727 &last_block_in_bio, &ret, wbc, 718 &last_block_in_bio, &ret, wbc,
728 writepage_fn); 719 page->mapping->a_ops->writepage);
729 } 720 }
721 if (unlikely(ret == WRITEPAGE_ACTIVATE))
722 unlock_page(page);
730 if (ret || (--(wbc->nr_to_write) <= 0)) 723 if (ret || (--(wbc->nr_to_write) <= 0))
731 done = 1; 724 done = 1;
732 if (wbc->nonblocking && bdi_write_congested(bdi)) { 725 if (wbc->nonblocking && bdi_write_congested(bdi)) {
@@ -753,7 +746,6 @@ retry:
753 return ret; 746 return ret;
754} 747}
755EXPORT_SYMBOL(mpage_writepages); 748EXPORT_SYMBOL(mpage_writepages);
756EXPORT_SYMBOL(__mpage_writepages);
757 749
758int mpage_writepage(struct page *page, get_block_t get_block, 750int mpage_writepage(struct page *page, get_block_t get_block,
759 struct writeback_control *wbc) 751 struct writeback_control *wbc)
diff --git a/fs/namei.c b/fs/namei.c
index 9e4aef2a1a21..defe6781e003 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -686,11 +686,11 @@ fail:
686 686
687/* 687/*
688 * Name resolution. 688 * Name resolution.
689 * This is the basic name resolution function, turning a pathname into
690 * the final dentry. We expect 'base' to be positive and a directory.
689 * 691 *
690 * This is the basic name resolution function, turning a pathname 692 * Returns 0 and nd will have valid dentry and mnt on success.
691 * into the final dentry. 693 * Returns error and drops reference to input namei data on failure.
692 *
693 * We expect 'base' to be positive and a directory.
694 */ 694 */
695static fastcall int __link_path_walk(const char * name, struct nameidata *nd) 695static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
696{ 696{
@@ -929,8 +929,10 @@ int fastcall path_walk(const char * name, struct nameidata *nd)
929 return link_path_walk(name, nd); 929 return link_path_walk(name, nd);
930} 930}
931 931
932/* SMP-safe */ 932/*
933/* returns 1 if everything is done */ 933 * SMP-safe: Returns 1 and nd will have valid dentry and mnt, if
934 * everything is done. Returns 0 and drops input nd, if lookup failed;
935 */
934static int __emul_lookup_dentry(const char *name, struct nameidata *nd) 936static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
935{ 937{
936 if (path_walk(name, nd)) 938 if (path_walk(name, nd))
@@ -994,9 +996,10 @@ set_it:
994 } 996 }
995} 997}
996 998
999/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
997int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd) 1000int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
998{ 1001{
999 int retval; 1002 int retval = 0;
1000 1003
1001 nd->last_type = LAST_ROOT; /* if there are only slashes... */ 1004 nd->last_type = LAST_ROOT; /* if there are only slashes... */
1002 nd->flags = flags; 1005 nd->flags = flags;
@@ -1009,7 +1012,7 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
1009 nd->dentry = dget(current->fs->altroot); 1012 nd->dentry = dget(current->fs->altroot);
1010 read_unlock(&current->fs->lock); 1013 read_unlock(&current->fs->lock);
1011 if (__emul_lookup_dentry(name,nd)) 1014 if (__emul_lookup_dentry(name,nd))
1012 return 0; 1015 goto out; /* found in altroot */
1013 read_lock(&current->fs->lock); 1016 read_lock(&current->fs->lock);
1014 } 1017 }
1015 nd->mnt = mntget(current->fs->rootmnt); 1018 nd->mnt = mntget(current->fs->rootmnt);
@@ -1021,6 +1024,7 @@ int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
1021 read_unlock(&current->fs->lock); 1024 read_unlock(&current->fs->lock);
1022 current->total_link_count = 0; 1025 current->total_link_count = 0;
1023 retval = link_path_walk(name, nd); 1026 retval = link_path_walk(name, nd);
1027out:
1024 if (unlikely(current->audit_context 1028 if (unlikely(current->audit_context
1025 && nd && nd->dentry && nd->dentry->d_inode)) 1029 && nd && nd->dentry && nd->dentry->d_inode))
1026 audit_inode(name, nd->dentry->d_inode); 1030 audit_inode(name, nd->dentry->d_inode);
@@ -2067,8 +2071,8 @@ exit:
2067 * ->i_sem on parents, which works but leads to some truely excessive 2071 * ->i_sem on parents, which works but leads to some truely excessive
2068 * locking]. 2072 * locking].
2069 */ 2073 */
2070int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, 2074static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
2071 struct inode *new_dir, struct dentry *new_dentry) 2075 struct inode *new_dir, struct dentry *new_dentry)
2072{ 2076{
2073 int error = 0; 2077 int error = 0;
2074 struct inode *target; 2078 struct inode *target;
@@ -2112,8 +2116,8 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
2112 return error; 2116 return error;
2113} 2117}
2114 2118
2115int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry, 2119static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
2116 struct inode *new_dir, struct dentry *new_dentry) 2120 struct inode *new_dir, struct dentry *new_dentry)
2117{ 2121{
2118 struct inode *target; 2122 struct inode *target;
2119 int error; 2123 int error;
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index b74c4e3a64e2..87f4f9aeac86 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -79,7 +79,7 @@ static ssize_t idmap_pipe_upcall(struct file *, struct rpc_pipe_msg *,
79 char __user *, size_t); 79 char __user *, size_t);
80static ssize_t idmap_pipe_downcall(struct file *, const char __user *, 80static ssize_t idmap_pipe_downcall(struct file *, const char __user *,
81 size_t); 81 size_t);
82void idmap_pipe_destroy_msg(struct rpc_pipe_msg *); 82static void idmap_pipe_destroy_msg(struct rpc_pipe_msg *);
83 83
84static unsigned int fnvhash32(const void *, size_t); 84static unsigned int fnvhash32(const void *, size_t);
85 85
@@ -434,7 +434,7 @@ out:
434 return ret; 434 return ret;
435} 435}
436 436
437void 437static void
438idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg) 438idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
439{ 439{
440 struct idmap_msg *im = msg->data; 440 struct idmap_msg *im = msg->data;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6345f26e87ee..f2317f3e29f9 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1904,7 +1904,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
1904 } 1904 }
1905} 1905}
1906 1906
1907int nfs_init_inodecache(void) 1907static int nfs_init_inodecache(void)
1908{ 1908{
1909 nfs_inode_cachep = kmem_cache_create("nfs_inode_cache", 1909 nfs_inode_cachep = kmem_cache_create("nfs_inode_cache",
1910 sizeof(struct nfs_inode), 1910 sizeof(struct nfs_inode),
@@ -1916,7 +1916,7 @@ int nfs_init_inodecache(void)
1916 return 0; 1916 return 0;
1917} 1917}
1918 1918
1919void nfs_destroy_inodecache(void) 1919static void nfs_destroy_inodecache(void)
1920{ 1920{
1921 if (kmem_cache_destroy(nfs_inode_cachep)) 1921 if (kmem_cache_destroy(nfs_inode_cachep))
1922 printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n"); 1922 printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n");
diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
index 897512796edb..a912debcd20b 100644
--- a/fs/nls/nls_base.c
+++ b/fs/nls/nls_base.c
@@ -243,7 +243,7 @@ void unload_nls(struct nls_table *nls)
243 module_put(nls->owner); 243 module_put(nls->owner);
244} 244}
245 245
246wchar_t charset2uni[256] = { 246static wchar_t charset2uni[256] = {
247 /* 0x00*/ 247 /* 0x00*/
248 0x0000, 0x0001, 0x0002, 0x0003, 248 0x0000, 0x0001, 0x0002, 0x0003,
249 0x0004, 0x0005, 0x0006, 0x0007, 249 0x0004, 0x0005, 0x0006, 0x0007,
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c
index 17ee1b4ff087..584a27b2bbd5 100644
--- a/fs/partitions/msdos.c
+++ b/fs/partitions/msdos.c
@@ -114,9 +114,6 @@ parse_extended(struct parsed_partitions *state, struct block_device *bdev,
114 */ 114 */
115 for (i=0; i<4; i++, p++) { 115 for (i=0; i<4; i++, p++) {
116 u32 offs, size, next; 116 u32 offs, size, next;
117
118 if (SYS_IND(p) == 0)
119 continue;
120 if (!NR_SECTS(p) || is_extended_partition(p)) 117 if (!NR_SECTS(p) || is_extended_partition(p))
121 continue; 118 continue;
122 119
@@ -433,8 +430,6 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
433 for (slot = 1 ; slot <= 4 ; slot++, p++) { 430 for (slot = 1 ; slot <= 4 ; slot++, p++) {
434 u32 start = START_SECT(p)*sector_size; 431 u32 start = START_SECT(p)*sector_size;
435 u32 size = NR_SECTS(p)*sector_size; 432 u32 size = NR_SECTS(p)*sector_size;
436 if (SYS_IND(p) == 0)
437 continue;
438 if (!size) 433 if (!size)
439 continue; 434 continue;
440 if (is_extended_partition(p)) { 435 if (is_extended_partition(p)) {
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 39fd336cfdb9..e31903aadd96 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -820,7 +820,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
820 goto out_free_page; 820 goto out_free_page;
821 821
822 } 822 }
823 length = audit_set_loginuid(task->audit_context, loginuid); 823 length = audit_set_loginuid(task, loginuid);
824 if (likely(length == 0)) 824 if (likely(length == 0))
825 length = count; 825 length = count;
826 826
@@ -1419,6 +1419,8 @@ static struct file_operations proc_tgid_attr_operations;
1419static struct inode_operations proc_tgid_attr_inode_operations; 1419static struct inode_operations proc_tgid_attr_inode_operations;
1420#endif 1420#endif
1421 1421
1422static int get_tid_list(int index, unsigned int *tids, struct inode *dir);
1423
1422/* SMP-safe */ 1424/* SMP-safe */
1423static struct dentry *proc_pident_lookup(struct inode *dir, 1425static struct dentry *proc_pident_lookup(struct inode *dir,
1424 struct dentry *dentry, 1426 struct dentry *dentry,
@@ -1458,7 +1460,7 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
1458 */ 1460 */
1459 switch(p->type) { 1461 switch(p->type) {
1460 case PROC_TGID_TASK: 1462 case PROC_TGID_TASK:
1461 inode->i_nlink = 3; 1463 inode->i_nlink = 2 + get_tid_list(2, NULL, dir);
1462 inode->i_op = &proc_task_inode_operations; 1464 inode->i_op = &proc_task_inode_operations;
1463 inode->i_fop = &proc_task_operations; 1465 inode->i_fop = &proc_task_operations;
1464 break; 1466 break;
@@ -1701,13 +1703,13 @@ static struct inode_operations proc_self_inode_operations = {
1701}; 1703};
1702 1704
1703/** 1705/**
1704 * proc_pid_unhash - Unhash /proc/<pid> entry from the dcache. 1706 * proc_pid_unhash - Unhash /proc/@pid entry from the dcache.
1705 * @p: task that should be flushed. 1707 * @p: task that should be flushed.
1706 * 1708 *
1707 * Drops the /proc/<pid> dcache entry from the hash chains. 1709 * Drops the /proc/@pid dcache entry from the hash chains.
1708 * 1710 *
1709 * Dropping /proc/<pid> entries and detach_pid must be synchroneous, 1711 * Dropping /proc/@pid entries and detach_pid must be synchroneous,
1710 * otherwise e.g. /proc/<pid>/exe might point to the wrong executable, 1712 * otherwise e.g. /proc/@pid/exe might point to the wrong executable,
1711 * if the pid value is immediately reused. This is enforced by 1713 * if the pid value is immediately reused. This is enforced by
1712 * - caller must acquire spin_lock(p->proc_lock) 1714 * - caller must acquire spin_lock(p->proc_lock)
1713 * - must be called before detach_pid() 1715 * - must be called before detach_pid()
@@ -1739,8 +1741,8 @@ struct dentry *proc_pid_unhash(struct task_struct *p)
1739} 1741}
1740 1742
1741/** 1743/**
1742 * proc_pid_flush - recover memory used by stale /proc/<pid>/x entries 1744 * proc_pid_flush - recover memory used by stale /proc/@pid/x entries
1743 * @proc_entry: directoy to prune. 1745 * @proc_dentry: directoy to prune.
1744 * 1746 *
1745 * Shrink the /proc directory that was used by the just killed thread. 1747 * Shrink the /proc directory that was used by the just killed thread.
1746 */ 1748 */
@@ -1800,8 +1802,12 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct
1800 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO; 1802 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
1801 inode->i_op = &proc_tgid_base_inode_operations; 1803 inode->i_op = &proc_tgid_base_inode_operations;
1802 inode->i_fop = &proc_tgid_base_operations; 1804 inode->i_fop = &proc_tgid_base_operations;
1803 inode->i_nlink = 3;
1804 inode->i_flags|=S_IMMUTABLE; 1805 inode->i_flags|=S_IMMUTABLE;
1806#ifdef CONFIG_SECURITY
1807 inode->i_nlink = 5;
1808#else
1809 inode->i_nlink = 4;
1810#endif
1805 1811
1806 dentry->d_op = &pid_base_dentry_operations; 1812 dentry->d_op = &pid_base_dentry_operations;
1807 1813
@@ -1855,8 +1861,12 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry
1855 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO; 1861 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
1856 inode->i_op = &proc_tid_base_inode_operations; 1862 inode->i_op = &proc_tid_base_inode_operations;
1857 inode->i_fop = &proc_tid_base_operations; 1863 inode->i_fop = &proc_tid_base_operations;
1858 inode->i_nlink = 3;
1859 inode->i_flags|=S_IMMUTABLE; 1864 inode->i_flags|=S_IMMUTABLE;
1865#ifdef CONFIG_SECURITY
1866 inode->i_nlink = 4;
1867#else
1868 inode->i_nlink = 3;
1869#endif
1860 1870
1861 dentry->d_op = &pid_base_dentry_operations; 1871 dentry->d_op = &pid_base_dentry_operations;
1862 1872
@@ -1935,7 +1945,8 @@ static int get_tid_list(int index, unsigned int *tids, struct inode *dir)
1935 1945
1936 if (--index >= 0) 1946 if (--index >= 0)
1937 continue; 1947 continue;
1938 tids[nr_tids] = tid; 1948 if (tids != NULL)
1949 tids[nr_tids] = tid;
1939 nr_tids++; 1950 nr_tids++;
1940 if (nr_tids >= PROC_MAXPIDS) 1951 if (nr_tids >= PROC_MAXPIDS)
1941 break; 1952 break;
@@ -2035,6 +2046,7 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
2035 } 2046 }
2036 2047
2037 nr_tids = get_tid_list(pos, tid_array, inode); 2048 nr_tids = get_tid_list(pos, tid_array, inode);
2049 inode->i_nlink = pos + nr_tids;
2038 2050
2039 for (i = 0; i < nr_tids; i++) { 2051 for (i = 0; i < nr_tids; i++) {
2040 unsigned long j = PROC_NUMBUF; 2052 unsigned long j = PROC_NUMBUF;
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index a4e2ed544bbe..49c479c9454a 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -260,8 +260,9 @@ static inline int block_group_used(struct super_block *s, u32 id) {
260/* 260/*
261 * the packing is returned in disk byte order 261 * the packing is returned in disk byte order
262 */ 262 */
263u32 reiserfs_choose_packing(struct inode *dir) { 263__le32 reiserfs_choose_packing(struct inode *dir)
264 u32 packing; 264{
265 __le32 packing;
265 if (TEST_OPTION(packing_groups, dir->i_sb)) { 266 if (TEST_OPTION(packing_groups, dir->i_sb)) {
266 u32 parent_dir = le32_to_cpu(INODE_PKEY(dir)->k_dir_id); 267 u32 parent_dir = le32_to_cpu(INODE_PKEY(dir)->k_dir_id);
267 /* 268 /*
@@ -655,7 +656,7 @@ static int get_left_neighbor(reiserfs_blocknr_hint_t *hint)
655 struct buffer_head * bh; 656 struct buffer_head * bh;
656 struct item_head * ih; 657 struct item_head * ih;
657 int pos_in_item; 658 int pos_in_item;
658 __u32 * item; 659 __le32 * item;
659 int ret = 0; 660 int ret = 0;
660 661
661 if (!hint->path) /* reiserfs code can call this function w/o pointer to path 662 if (!hint->path) /* reiserfs code can call this function w/o pointer to path
@@ -736,7 +737,7 @@ static inline int this_blocknr_allocation_would_make_it_a_large_file(reiserfs_bl
736#ifdef DISPLACE_NEW_PACKING_LOCALITIES 737#ifdef DISPLACE_NEW_PACKING_LOCALITIES
737static inline void displace_new_packing_locality (reiserfs_blocknr_hint_t *hint) 738static inline void displace_new_packing_locality (reiserfs_blocknr_hint_t *hint)
738{ 739{
739 struct reiserfs_key * key = &hint->key; 740 struct in_core_key * key = &hint->key;
740 741
741 hint->th->displace_new_blocks = 0; 742 hint->th->displace_new_blocks = 0;
742 hint->search_start = hint->beg + keyed_hash((char*)(&key->k_objectid),4) % (hint->end - hint->beg); 743 hint->search_start = hint->beg + keyed_hash((char*)(&key->k_objectid),4) % (hint->end - hint->beg);
@@ -777,7 +778,7 @@ static inline int old_way (reiserfs_blocknr_hint_t * hint)
777 778
778static inline void hundredth_slices (reiserfs_blocknr_hint_t * hint) 779static inline void hundredth_slices (reiserfs_blocknr_hint_t * hint)
779{ 780{
780 struct reiserfs_key * key = &hint->key; 781 struct in_core_key * key = &hint->key;
781 b_blocknr_t slice_start; 782 b_blocknr_t slice_start;
782 783
783 slice_start = (keyed_hash((char*)(&key->k_dir_id),4) % 100) * (hint->end / 100); 784 slice_start = (keyed_hash((char*)(&key->k_dir_id),4) % 100) * (hint->end / 100);
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index d1514a9b0514..fbde4b01a325 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -209,8 +209,8 @@ static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldi
209/* compose directory item containing "." and ".." entries (entries are 209/* compose directory item containing "." and ".." entries (entries are
210 not aligned to 4 byte boundary) */ 210 not aligned to 4 byte boundary) */
211/* the last four params are LE */ 211/* the last four params are LE */
212void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid, 212void make_empty_dir_item_v1 (char * body, __le32 dirid, __le32 objid,
213 __u32 par_dirid, __u32 par_objid) 213 __le32 par_dirid, __le32 par_objid)
214{ 214{
215 struct reiserfs_de_head * deh; 215 struct reiserfs_de_head * deh;
216 216
@@ -242,8 +242,8 @@ void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid,
242} 242}
243 243
244/* compose directory item containing "." and ".." entries */ 244/* compose directory item containing "." and ".." entries */
245void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, 245void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
246 __u32 par_dirid, __u32 par_objid) 246 __le32 par_dirid, __le32 par_objid)
247{ 247{
248 struct reiserfs_de_head * deh; 248 struct reiserfs_de_head * deh;
249 249
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 26950113af8c..2230afff1870 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -166,7 +166,7 @@ static int reiserfs_allocate_blocks_for_region(
166 struct cpu_key key; // cpu key of item that we are going to deal with 166 struct cpu_key key; // cpu key of item that we are going to deal with
167 struct item_head *ih; // pointer to item head that we are going to deal with 167 struct item_head *ih; // pointer to item head that we are going to deal with
168 struct buffer_head *bh; // Buffer head that contains items that we are going to deal with 168 struct buffer_head *bh; // Buffer head that contains items that we are going to deal with
169 __u32 * item; // pointer to item we are going to deal with 169 __le32 * item; // pointer to item we are going to deal with
170 INITIALIZE_PATH(path); // path to item, that we are going to deal with. 170 INITIALIZE_PATH(path); // path to item, that we are going to deal with.
171 b_blocknr_t *allocated_blocks; // Pointer to a place where allocated blocknumbers would be stored. 171 b_blocknr_t *allocated_blocks; // Pointer to a place where allocated blocknumbers would be stored.
172 reiserfs_blocknr_hint_t hint; // hint structure for block allocator. 172 reiserfs_blocknr_hint_t hint; // hint structure for block allocator.
@@ -891,7 +891,7 @@ static int reiserfs_prepare_file_region_for_write(
891 struct item_head *ih = NULL; // pointer to item head that we are going to deal with 891 struct item_head *ih = NULL; // pointer to item head that we are going to deal with
892 struct buffer_head *itembuf=NULL; // Buffer head that contains items that we are going to deal with 892 struct buffer_head *itembuf=NULL; // Buffer head that contains items that we are going to deal with
893 INITIALIZE_PATH(path); // path to item, that we are going to deal with. 893 INITIALIZE_PATH(path); // path to item, that we are going to deal with.
894 __u32 * item=NULL; // pointer to item we are going to deal with 894 __le32 * item=NULL; // pointer to item we are going to deal with
895 int item_pos=-1; /* Position in indirect item */ 895 int item_pos=-1; /* Position in indirect item */
896 896
897 897
@@ -1284,10 +1284,11 @@ static ssize_t reiserfs_file_write( struct file *file, /* the file we are going
1284 reiserfs_claim_blocks_to_be_allocated(inode->i_sb, num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits)); 1284 reiserfs_claim_blocks_to_be_allocated(inode->i_sb, num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits));
1285 reiserfs_write_unlock(inode->i_sb); 1285 reiserfs_write_unlock(inode->i_sb);
1286 1286
1287 if ( !num_pages ) { /* If we do not have enough space even for */ 1287 if ( !num_pages ) { /* If we do not have enough space even for a single page... */
1288 res = -ENOSPC; /* single page, return -ENOSPC */ 1288 if ( pos > inode->i_size+inode->i_sb->s_blocksize-(pos & (inode->i_sb->s_blocksize-1))) {
1289 if ( pos > (inode->i_size & (inode->i_sb->s_blocksize-1))) 1289 res = -ENOSPC;
1290 break; // In case we are writing past the file end, break. 1290 break; // In case we are writing past the end of the last file block, break.
1291 }
1291 // Otherwise we are possibly overwriting the file, so 1292 // Otherwise we are possibly overwriting the file, so
1292 // let's set write size to be equal or less than blocksize. 1293 // let's set write size to be equal or less than blocksize.
1293 // This way we get it correctly for file holes. 1294 // This way we get it correctly for file holes.
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 7543031396f4..2711dff1b7b4 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -173,7 +173,7 @@ static inline void fix_tail_page_for_writing(struct page *page) {
173 done already or non-hole position has been found in the indirect item */ 173 done already or non-hole position has been found in the indirect item */
174static inline int allocation_needed (int retval, b_blocknr_t allocated, 174static inline int allocation_needed (int retval, b_blocknr_t allocated,
175 struct item_head * ih, 175 struct item_head * ih,
176 __u32 * item, int pos_in_item) 176 __le32 * item, int pos_in_item)
177{ 177{
178 if (allocated) 178 if (allocated)
179 return 0; 179 return 0;
@@ -278,7 +278,7 @@ research:
278 bh = get_last_bh (&path); 278 bh = get_last_bh (&path);
279 ih = get_ih (&path); 279 ih = get_ih (&path);
280 if (is_indirect_le_ih (ih)) { 280 if (is_indirect_le_ih (ih)) {
281 __u32 * ind_item = (__u32 *)B_I_PITEM (bh, ih); 281 __le32 * ind_item = (__le32 *)B_I_PITEM (bh, ih);
282 282
283 /* FIXME: here we could cache indirect item or part of it in 283 /* FIXME: here we could cache indirect item or part of it in
284 the inode to avoid search_by_key in case of subsequent 284 the inode to avoid search_by_key in case of subsequent
@@ -581,7 +581,7 @@ int reiserfs_get_block (struct inode * inode, sector_t block,
581 struct cpu_key key; 581 struct cpu_key key;
582 struct buffer_head * bh, * unbh = NULL; 582 struct buffer_head * bh, * unbh = NULL;
583 struct item_head * ih, tmp_ih; 583 struct item_head * ih, tmp_ih;
584 __u32 * item; 584 __le32 * item;
585 int done; 585 int done;
586 int fs_gen; 586 int fs_gen;
587 struct reiserfs_transaction_handle *th = NULL; 587 struct reiserfs_transaction_handle *th = NULL;
@@ -746,7 +746,7 @@ start_trans:
746 done = 0; 746 done = 0;
747 do { 747 do {
748 if (is_statdata_le_ih (ih)) { 748 if (is_statdata_le_ih (ih)) {
749 __u32 unp = 0; 749 __le32 unp = 0;
750 struct cpu_key tmp_key; 750 struct cpu_key tmp_key;
751 751
752 /* indirect item has to be inserted */ 752 /* indirect item has to be inserted */
@@ -1341,8 +1341,8 @@ void reiserfs_read_locked_inode (struct inode * inode, struct reiserfs_iget_args
1341 key.version = KEY_FORMAT_3_5; 1341 key.version = KEY_FORMAT_3_5;
1342 key.on_disk_key.k_dir_id = dirino; 1342 key.on_disk_key.k_dir_id = dirino;
1343 key.on_disk_key.k_objectid = inode->i_ino; 1343 key.on_disk_key.k_objectid = inode->i_ino;
1344 key.on_disk_key.u.k_offset_v1.k_offset = SD_OFFSET; 1344 key.on_disk_key.k_offset = 0;
1345 key.on_disk_key.u.k_offset_v1.k_uniqueness = SD_UNIQUENESS; 1345 key.on_disk_key.k_type = 0;
1346 1346
1347 /* look for the object's stat data */ 1347 /* look for the object's stat data */
1348 retval = search_item (inode->i_sb, &key, &path_to_sd); 1348 retval = search_item (inode->i_sb, &key, &path_to_sd);
@@ -2067,7 +2067,7 @@ static int map_block_for_writepage(struct inode *inode,
2067 struct item_head tmp_ih ; 2067 struct item_head tmp_ih ;
2068 struct item_head *ih ; 2068 struct item_head *ih ;
2069 struct buffer_head *bh ; 2069 struct buffer_head *bh ;
2070 __u32 *item ; 2070 __le32 *item ;
2071 struct cpu_key key ; 2071 struct cpu_key key ;
2072 INITIALIZE_PATH(path) ; 2072 INITIALIZE_PATH(path) ;
2073 int pos_in_item ; 2073 int pos_in_item ;
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index 9cf7c13b120d..0ce33db1acdf 100644
--- a/fs/reiserfs/item_ops.c
+++ b/fs/reiserfs/item_ops.c
@@ -296,10 +296,11 @@ static void print_sequence (__u32 start, int len)
296static void indirect_print_item (struct item_head * ih, char * item) 296static void indirect_print_item (struct item_head * ih, char * item)
297{ 297{
298 int j; 298 int j;
299 __u32 * unp, prev = INT_MAX; 299 __le32 * unp;
300 __u32 prev = INT_MAX;
300 int num; 301 int num;
301 302
302 unp = (__u32 *)item; 303 unp = (__le32 *)item;
303 304
304 if (ih_item_len(ih) % UNFM_P_SIZE) 305 if (ih_item_len(ih) % UNFM_P_SIZE)
305 reiserfs_warning (NULL, "indirect_print_item: invalid item len"); 306 reiserfs_warning (NULL, "indirect_print_item: invalid item len");
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index c9ad3a7849f4..3072cfdee959 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2306,13 +2306,16 @@ static int journal_init_dev( struct super_block *super,
2306 if( !IS_ERR( journal -> j_dev_file ) ) { 2306 if( !IS_ERR( journal -> j_dev_file ) ) {
2307 struct inode *jdev_inode = journal->j_dev_file->f_mapping->host; 2307 struct inode *jdev_inode = journal->j_dev_file->f_mapping->host;
2308 if( !S_ISBLK( jdev_inode -> i_mode ) ) { 2308 if( !S_ISBLK( jdev_inode -> i_mode ) ) {
2309 reiserfs_warning (super, "journal_init_dev: '%s' is " 2309 reiserfs_warning(super, "journal_init_dev: '%s' is "
2310 "not a block device", jdev_name ); 2310 "not a block device", jdev_name );
2311 result = -ENOTBLK; 2311 result = -ENOTBLK;
2312 release_journal_dev( super, journal );
2312 } else { 2313 } else {
2313 /* ok */ 2314 /* ok */
2314 journal->j_dev_bd = I_BDEV(jdev_inode); 2315 journal->j_dev_bd = I_BDEV(jdev_inode);
2315 set_blocksize(journal->j_dev_bd, super->s_blocksize); 2316 set_blocksize(journal->j_dev_bd, super->s_blocksize);
2317 reiserfs_info(super, "journal_init_dev: journal device: %s\n",
2318 bdevname(journal->j_dev_bd, b));
2316 } 2319 }
2317 } else { 2320 } else {
2318 result = PTR_ERR( journal -> j_dev_file ); 2321 result = PTR_ERR( journal -> j_dev_file );
@@ -2321,11 +2324,6 @@ static int journal_init_dev( struct super_block *super,
2321 "journal_init_dev: Cannot open '%s': %i", 2324 "journal_init_dev: Cannot open '%s': %i",
2322 jdev_name, result ); 2325 jdev_name, result );
2323 } 2326 }
2324 if( result != 0 ) {
2325 release_journal_dev( super, journal );
2326 }
2327 reiserfs_info(super, "journal_init_dev: journal device: %s\n",
2328 bdevname(journal->j_dev_bd, b));
2329 return result; 2327 return result;
2330} 2328}
2331 2329
@@ -2393,7 +2391,7 @@ int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_fo
2393 jh = (struct reiserfs_journal_header *)(bhjh->b_data); 2391 jh = (struct reiserfs_journal_header *)(bhjh->b_data);
2394 2392
2395 /* make sure that journal matches to the super block */ 2393 /* make sure that journal matches to the super block */
2396 if (is_reiserfs_jr(rs) && (jh->jh_journal.jp_journal_magic != sb_jp_journal_magic(rs))) { 2394 if (is_reiserfs_jr(rs) && (le32_to_cpu(jh->jh_journal.jp_journal_magic) != sb_jp_journal_magic(rs))) {
2397 reiserfs_warning (p_s_sb, "sh-460: journal header magic %x " 2395 reiserfs_warning (p_s_sb, "sh-460: journal header magic %x "
2398 "(device %s) does not match to magic found in super " 2396 "(device %s) does not match to magic found in super "
2399 "block %x", 2397 "block %x",
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 80e92d9b81cb..7d4dc5f5aa8b 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -608,7 +608,7 @@ static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode,
608 goto out_failed; 608 goto out_failed;
609 } 609 }
610 610
611 retval = reiserfs_new_inode (&th, dir, mode, 0, 0/*i_size*/, dentry, inode); 611 retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
612 if (retval) 612 if (retval)
613 goto out_failed; 613 goto out_failed;
614 614
diff --git a/fs/reiserfs/objectid.c b/fs/reiserfs/objectid.c
index 0785c43a7486..bfe8e25ef293 100644
--- a/fs/reiserfs/objectid.c
+++ b/fs/reiserfs/objectid.c
@@ -11,13 +11,13 @@
11 11
12// find where objectid map starts 12// find where objectid map starts
13#define objectid_map(s,rs) (old_format_only (s) ? \ 13#define objectid_map(s,rs) (old_format_only (s) ? \
14 (__u32 *)((struct reiserfs_super_block_v1 *)(rs) + 1) :\ 14 (__le32 *)((struct reiserfs_super_block_v1 *)(rs) + 1) :\
15 (__u32 *)((rs) + 1)) 15 (__le32 *)((rs) + 1))
16 16
17 17
18#ifdef CONFIG_REISERFS_CHECK 18#ifdef CONFIG_REISERFS_CHECK
19 19
20static void check_objectid_map (struct super_block * s, __u32 * map) 20static void check_objectid_map (struct super_block * s, __le32 * map)
21{ 21{
22 if (le32_to_cpu (map[0]) != 1) 22 if (le32_to_cpu (map[0]) != 1)
23 reiserfs_panic (s, "vs-15010: check_objectid_map: map corrupted: %lx", 23 reiserfs_panic (s, "vs-15010: check_objectid_map: map corrupted: %lx",
@@ -27,7 +27,7 @@ static void check_objectid_map (struct super_block * s, __u32 * map)
27} 27}
28 28
29#else 29#else
30static void check_objectid_map (struct super_block * s, __u32 * map) 30static void check_objectid_map (struct super_block * s, __le32 * map)
31{;} 31{;}
32#endif 32#endif
33 33
@@ -52,7 +52,7 @@ __u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th)
52{ 52{
53 struct super_block * s = th->t_super; 53 struct super_block * s = th->t_super;
54 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s); 54 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
55 __u32 * map = objectid_map (s, rs); 55 __le32 * map = objectid_map (s, rs);
56 __u32 unused_objectid; 56 __u32 unused_objectid;
57 57
58 BUG_ON (!th->t_trans_id); 58 BUG_ON (!th->t_trans_id);
@@ -97,7 +97,7 @@ void reiserfs_release_objectid (struct reiserfs_transaction_handle *th,
97{ 97{
98 struct super_block * s = th->t_super; 98 struct super_block * s = th->t_super;
99 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s); 99 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
100 __u32 * map = objectid_map (s, rs); 100 __le32 * map = objectid_map (s, rs);
101 int i = 0; 101 int i = 0;
102 102
103 BUG_ON (!th->t_trans_id); 103 BUG_ON (!th->t_trans_id);
@@ -172,12 +172,12 @@ int reiserfs_convert_objectid_map_v1(struct super_block *s) {
172 int new_size = (s->s_blocksize - SB_SIZE) / sizeof(__u32) / 2 * 2 ; 172 int new_size = (s->s_blocksize - SB_SIZE) / sizeof(__u32) / 2 * 2 ;
173 int old_max = sb_oid_maxsize(disk_sb); 173 int old_max = sb_oid_maxsize(disk_sb);
174 struct reiserfs_super_block_v1 *disk_sb_v1 ; 174 struct reiserfs_super_block_v1 *disk_sb_v1 ;
175 __u32 *objectid_map, *new_objectid_map ; 175 __le32 *objectid_map, *new_objectid_map ;
176 int i ; 176 int i ;
177 177
178 disk_sb_v1=(struct reiserfs_super_block_v1 *)(SB_BUFFER_WITH_SB(s)->b_data); 178 disk_sb_v1=(struct reiserfs_super_block_v1 *)(SB_BUFFER_WITH_SB(s)->b_data);
179 objectid_map = (__u32 *)(disk_sb_v1 + 1) ; 179 objectid_map = (__le32 *)(disk_sb_v1 + 1) ;
180 new_objectid_map = (__u32 *)(disk_sb + 1) ; 180 new_objectid_map = (__le32 *)(disk_sb + 1) ;
181 181
182 if (cur_size > new_size) { 182 if (cur_size > new_size) {
183 /* mark everyone used that was listed as free at the end of the objectid 183 /* mark everyone used that was listed as free at the end of the objectid
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index f4ea81ae0e0f..e242ebc7f6f6 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -73,8 +73,8 @@ int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset,
73#define DFL( x ) D4C( rs -> s_v1.x ) 73#define DFL( x ) D4C( rs -> s_v1.x )
74 74
75#define objectid_map( s, rs ) (old_format_only (s) ? \ 75#define objectid_map( s, rs ) (old_format_only (s) ? \
76 (__u32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \ 76 (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \
77 (__u32 *)(rs + 1)) 77 (__le32 *)(rs + 1))
78#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] ) 78#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )
79 79
80#define DJF( x ) le32_to_cpu( rs -> x ) 80#define DJF( x ) le32_to_cpu( rs -> x )
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 73ec5212178b..da23ba75f3d5 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -87,22 +87,20 @@ inline void copy_item_head(struct item_head * p_v_to,
87inline int comp_short_keys (const struct reiserfs_key * le_key, 87inline int comp_short_keys (const struct reiserfs_key * le_key,
88 const struct cpu_key * cpu_key) 88 const struct cpu_key * cpu_key)
89{ 89{
90 __u32 * p_s_le_u32, * p_s_cpu_u32; 90 __u32 n;
91 int n_key_length = REISERFS_SHORT_KEY_LEN; 91 n = le32_to_cpu(le_key->k_dir_id);
92 92 if (n < cpu_key->on_disk_key.k_dir_id)
93 p_s_le_u32 = (__u32 *)le_key;
94 p_s_cpu_u32 = (__u32 *)&cpu_key->on_disk_key;
95 for( ; n_key_length--; ++p_s_le_u32, ++p_s_cpu_u32 ) {
96 if ( le32_to_cpu (*p_s_le_u32) < *p_s_cpu_u32 )
97 return -1; 93 return -1;
98 if ( le32_to_cpu (*p_s_le_u32) > *p_s_cpu_u32 ) 94 if (n > cpu_key->on_disk_key.k_dir_id)
95 return 1;
96 n = le32_to_cpu(le_key->k_objectid);
97 if (n < cpu_key->on_disk_key.k_objectid)
98 return -1;
99 if (n > cpu_key->on_disk_key.k_objectid)
99 return 1; 100 return 1;
100 }
101
102 return 0; 101 return 0;
103} 102}
104 103
105
106/* k1 is pointer to on-disk structure which is stored in little-endian 104/* k1 is pointer to on-disk structure which is stored in little-endian
107 form. k2 is pointer to cpu variable. 105 form. k2 is pointer to cpu variable.
108 Compare keys using all 4 key fields. 106 Compare keys using all 4 key fields.
@@ -152,18 +150,15 @@ inline int comp_short_le_keys (const struct reiserfs_key * key1, const struct re
152 150
153inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from) 151inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from)
154{ 152{
153 int version;
155 to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id); 154 to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id);
156 to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid); 155 to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid);
157 156
158 // find out version of the key 157 // find out version of the key
159 to->version = le_key_version (from); 158 version = le_key_version (from);
160 if (to->version == KEY_FORMAT_3_5) { 159 to->version = version;
161 to->on_disk_key.u.k_offset_v1.k_offset = le32_to_cpu (from->u.k_offset_v1.k_offset); 160 to->on_disk_key.k_offset = le_key_k_offset(version, from);
162 to->on_disk_key.u.k_offset_v1.k_uniqueness = le32_to_cpu (from->u.k_offset_v1.k_uniqueness); 161 to->on_disk_key.k_type = le_key_k_type(version, from);
163 } else {
164 to->on_disk_key.u.k_offset_v2.k_offset = offset_v2_k_offset(&from->u.k_offset_v2);
165 to->on_disk_key.u.k_offset_v2.k_type = offset_v2_k_type(&from->u.k_offset_v2);
166 }
167} 162}
168 163
169 164
@@ -228,8 +223,14 @@ extern struct tree_balance * cur_tb;
228const struct reiserfs_key MIN_KEY = {0, 0, {{0, 0},}}; 223const struct reiserfs_key MIN_KEY = {0, 0, {{0, 0},}};
229 224
230/* Maximal possible key. It is never in the tree. */ 225/* Maximal possible key. It is never in the tree. */
231const struct reiserfs_key MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}}; 226const struct reiserfs_key MAX_KEY = {
227 __constant_cpu_to_le32(0xffffffff),
228 __constant_cpu_to_le32(0xffffffff),
229 {{__constant_cpu_to_le32(0xffffffff),
230 __constant_cpu_to_le32(0xffffffff)},}
231};
232 232
233const struct in_core_key MAX_IN_CORE_KEY = {~0U, ~0U, ~0ULL>>4, 15};
233 234
234/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom 235/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom
235 of the path, and going upwards. We must check the path's validity at each step. If the key is not in 236 of the path, and going upwards. We must check the path's validity at each step. If the key is not in
@@ -997,7 +998,7 @@ static char prepare_for_delete_or_cut(
997 int n_unfm_number, /* Number of the item unformatted nodes. */ 998 int n_unfm_number, /* Number of the item unformatted nodes. */
998 n_counter, 999 n_counter,
999 n_blk_size; 1000 n_blk_size;
1000 __u32 * p_n_unfm_pointer; /* Pointer to the unformatted node number. */ 1001 __le32 * p_n_unfm_pointer; /* Pointer to the unformatted node number. */
1001 __u32 tmp; 1002 __u32 tmp;
1002 struct item_head s_ih; /* Item header. */ 1003 struct item_head s_ih; /* Item header. */
1003 char c_mode; /* Returned mode of the balance. */ 1004 char c_mode; /* Returned mode of the balance. */
@@ -1059,7 +1060,7 @@ static char prepare_for_delete_or_cut(
1059 /* pointers to be cut */ 1060 /* pointers to be cut */
1060 n_unfm_number -= pos_in_item (p_s_path); 1061 n_unfm_number -= pos_in_item (p_s_path);
1061 /* Set pointer to the last unformatted node pointer that is to be cut. */ 1062 /* Set pointer to the last unformatted node pointer that is to be cut. */
1062 p_n_unfm_pointer = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1 - *p_n_removed; 1063 p_n_unfm_pointer = (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1 - *p_n_removed;
1063 1064
1064 1065
1065 /* We go through the unformatted nodes pointers of the indirect 1066 /* We go through the unformatted nodes pointers of the indirect
@@ -1081,8 +1082,8 @@ static char prepare_for_delete_or_cut(
1081 need_research = 1 ; 1082 need_research = 1 ;
1082 break; 1083 break;
1083 } 1084 }
1084 RFALSE( p_n_unfm_pointer < (__u32 *)B_I_PITEM(p_s_bh, &s_ih) || 1085 RFALSE( p_n_unfm_pointer < (__le32 *)B_I_PITEM(p_s_bh, &s_ih) ||
1085 p_n_unfm_pointer > (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1, 1086 p_n_unfm_pointer > (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1,
1086 "vs-5265: pointer out of range"); 1087 "vs-5265: pointer out of range");
1087 1088
1088 /* Hole, nothing to remove. */ 1089 /* Hole, nothing to remove. */
@@ -1431,7 +1432,7 @@ int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode
1431#if defined( USE_INODE_GENERATION_COUNTER ) 1432#if defined( USE_INODE_GENERATION_COUNTER )
1432 if( !old_format_only ( th -> t_super ) ) 1433 if( !old_format_only ( th -> t_super ) )
1433 { 1434 {
1434 __u32 *inode_generation; 1435 __le32 *inode_generation;
1435 1436
1436 inode_generation = 1437 inode_generation =
1437 &REISERFS_SB(th -> t_super) -> s_rs -> s_inode_generation; 1438 &REISERFS_SB(th -> t_super) -> s_rs -> s_inode_generation;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index bcdf2438d152..31e75125f48b 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -110,7 +110,7 @@ static void reiserfs_unlockfs(struct super_block *s) {
110 reiserfs_allow_writes(s) ; 110 reiserfs_allow_writes(s) ;
111} 111}
112 112
113extern const struct reiserfs_key MAX_KEY; 113extern const struct in_core_key MAX_IN_CORE_KEY;
114 114
115 115
116/* this is used to delete "save link" when there are no items of a 116/* this is used to delete "save link" when there are no items of a
@@ -164,7 +164,7 @@ static int finish_unfinished (struct super_block * s)
164 164
165 /* compose key to look for "save" links */ 165 /* compose key to look for "save" links */
166 max_cpu_key.version = KEY_FORMAT_3_5; 166 max_cpu_key.version = KEY_FORMAT_3_5;
167 max_cpu_key.on_disk_key = MAX_KEY; 167 max_cpu_key.on_disk_key = MAX_IN_CORE_KEY;
168 max_cpu_key.key_length = 3; 168 max_cpu_key.key_length = 3;
169 169
170#ifdef CONFIG_QUOTA 170#ifdef CONFIG_QUOTA
@@ -216,10 +216,10 @@ static int finish_unfinished (struct super_block * s)
216 216
217 /* reiserfs_iget needs k_dirid and k_objectid only */ 217 /* reiserfs_iget needs k_dirid and k_objectid only */
218 item = B_I_PITEM (bh, ih); 218 item = B_I_PITEM (bh, ih);
219 obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__u32 *)item); 219 obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__le32 *)item);
220 obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid); 220 obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid);
221 obj_key.on_disk_key.u.k_offset_v1.k_offset = 0; 221 obj_key.on_disk_key.k_offset = 0;
222 obj_key.on_disk_key.u.k_offset_v1.k_uniqueness = 0; 222 obj_key.on_disk_key.k_type = 0;
223 223
224 pathrelse (&path); 224 pathrelse (&path);
225 225
@@ -304,7 +304,7 @@ void add_save_link (struct reiserfs_transaction_handle * th,
304 int retval; 304 int retval;
305 struct cpu_key key; 305 struct cpu_key key;
306 struct item_head ih; 306 struct item_head ih;
307 __u32 link; 307 __le32 link;
308 308
309 BUG_ON (!th->t_trans_id); 309 BUG_ON (!th->t_trans_id);
310 310
@@ -889,12 +889,18 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st
889 char * p; 889 char * p;
890 890
891 p = NULL; 891 p = NULL;
892 /* "resize=NNN" */ 892 /* "resize=NNN" or "resize=auto" */
893 *blocks = simple_strtoul (arg, &p, 0); 893
894 if (*p != '\0') { 894 if (!strcmp(arg, "auto")) {
895 /* NNN does not look like a number */ 895 /* From JFS code, to auto-get the size.*/
896 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg); 896 *blocks = s->s_bdev->bd_inode->i_size >> s->s_blocksize_bits;
897 return 0; 897 } else {
898 *blocks = simple_strtoul (arg, &p, 0);
899 if (*p != '\0') {
900 /* NNN does not look like a number */
901 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
902 return 0;
903 }
898 } 904 }
899 } 905 }
900 906
@@ -903,7 +909,8 @@ static int reiserfs_parse_options (struct super_block * s, char * options, /* st
903 unsigned long val = simple_strtoul (arg, &p, 0); 909 unsigned long val = simple_strtoul (arg, &p, 0);
904 /* commit=NNN (time in seconds) */ 910 /* commit=NNN (time in seconds) */
905 if ( *p != '\0' || val >= (unsigned int)-1) { 911 if ( *p != '\0' || val >= (unsigned int)-1) {
906 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg); return 0; 912 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
913 return 0;
907 } 914 }
908 *commit_max_age = (unsigned int)val; 915 *commit_max_age = (unsigned int)val;
909 } 916 }
@@ -1329,7 +1336,7 @@ static int read_super_block (struct super_block * s, int offset)
1329 return 1; 1336 return 1;
1330 } 1337 }
1331 1338
1332 if ( rs->s_v1.s_root_block == -1 ) { 1339 if ( rs->s_v1.s_root_block == cpu_to_le32(-1) ) {
1333 brelse(bh) ; 1340 brelse(bh) ;
1334 reiserfs_warning (s, "Unfinished reiserfsck --rebuild-tree run detected. Please run\n" 1341 reiserfs_warning (s, "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
1335 "reiserfsck --rebuild-tree and wait for a completion. If that fails\n" 1342 "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
diff --git a/fs/select.c b/fs/select.c
index 25b1ccac2f2c..b80e7eb0ac0d 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -55,7 +55,8 @@ struct poll_table_page {
55 * as all select/poll functions have to call it to add an entry to the 55 * as all select/poll functions have to call it to add an entry to the
56 * poll table. 56 * poll table.
57 */ 57 */
58void __pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p); 58static void __pollwait(struct file *filp, wait_queue_head_t *wait_address,
59 poll_table *p);
59 60
60void poll_initwait(struct poll_wqueues *pwq) 61void poll_initwait(struct poll_wqueues *pwq)
61{ 62{
@@ -87,7 +88,8 @@ void poll_freewait(struct poll_wqueues *pwq)
87 88
88EXPORT_SYMBOL(poll_freewait); 89EXPORT_SYMBOL(poll_freewait);
89 90
90void __pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *_p) 91static void __pollwait(struct file *filp, wait_queue_head_t *wait_address,
92 poll_table *_p)
91{ 93{
92 struct poll_wqueues *p = container_of(_p, struct poll_wqueues, pt); 94 struct poll_wqueues *p = container_of(_p, struct poll_wqueues, pt);
93 struct poll_table_page *table = p->table; 95 struct poll_table_page *table = p->table;
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 650c43ba86c4..38ef913767ff 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -51,7 +51,10 @@ EXPORT_SYMBOL(seq_open);
51 51
52/** 52/**
53 * seq_read - ->read() method for sequential files. 53 * seq_read - ->read() method for sequential files.
54 * @file, @buf, @size, @ppos: see file_operations method 54 * @file: the file to read from
55 * @buf: the buffer to read to
56 * @size: the maximum number of bytes to read
57 * @ppos: the current position in the file
55 * 58 *
56 * Ready-made ->f_op->read() 59 * Ready-made ->f_op->read()
57 */ 60 */
@@ -219,7 +222,9 @@ Eoverflow:
219 222
220/** 223/**
221 * seq_lseek - ->llseek() method for sequential files. 224 * seq_lseek - ->llseek() method for sequential files.
222 * @file, @offset, @origin: see file_operations method 225 * @file: the file in question
226 * @offset: new position
227 * @origin: 0 for absolute, 1 for relative position
223 * 228 *
224 * Ready-made ->f_op->llseek() 229 * Ready-made ->f_op->llseek()
225 */ 230 */
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index da25aeb0e062..364208071e17 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -96,7 +96,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
96/** 96/**
97 * flush_read_buffer - push buffer to userspace. 97 * flush_read_buffer - push buffer to userspace.
98 * @buffer: data buffer for file. 98 * @buffer: data buffer for file.
99 * @userbuf: user-passed buffer. 99 * @buf: user-passed buffer.
100 * @count: number of bytes requested. 100 * @count: number of bytes requested.
101 * @ppos: file position. 101 * @ppos: file position.
102 * 102 *
@@ -164,7 +164,7 @@ out:
164/** 164/**
165 * fill_write_buffer - copy buffer from userspace. 165 * fill_write_buffer - copy buffer from userspace.
166 * @buffer: data buffer for file. 166 * @buffer: data buffer for file.
167 * @userbuf: data from user. 167 * @buf: data from user.
168 * @count: number of bytes in @userbuf. 168 * @count: number of bytes in @userbuf.
169 * 169 *
170 * Allocate @buffer->page if it hasn't been already, then 170 * Allocate @buffer->page if it hasn't been already, then
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 2faa4172b9f7..bb40d63f328f 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -49,8 +49,7 @@ static int udf_adinicb_readpage(struct file *file, struct page * page)
49 struct inode *inode = page->mapping->host; 49 struct inode *inode = page->mapping->host;
50 char *kaddr; 50 char *kaddr;
51 51
52 if (!PageLocked(page)) 52 BUG_ON(!PageLocked(page));
53 PAGE_BUG(page);
54 53
55 kaddr = kmap(page); 54 kaddr = kmap(page);
56 memset(kaddr, 0, PAGE_CACHE_SIZE); 55 memset(kaddr, 0, PAGE_CACHE_SIZE);
@@ -67,8 +66,7 @@ static int udf_adinicb_writepage(struct page *page, struct writeback_control *wb
67 struct inode *inode = page->mapping->host; 66 struct inode *inode = page->mapping->host;
68 char *kaddr; 67 char *kaddr;
69 68
70 if (!PageLocked(page)) 69 BUG_ON(!PageLocked(page));
71 PAGE_BUG(page);
72 70
73 kaddr = kmap(page); 71 kaddr = kmap(page);
74 memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), kaddr, inode->i_size); 72 memcpy(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), kaddr, inode->i_size);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 0506e1173784..3d68de39fad6 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -167,8 +167,8 @@ void udf_expand_file_adinicb(struct inode * inode, int newsize, int * err)
167 } 167 }
168 168
169 page = grab_cache_page(inode->i_mapping, 0); 169 page = grab_cache_page(inode->i_mapping, 0);
170 if (!PageLocked(page)) 170 BUG_ON(!PageLocked(page));
171 PAGE_BUG(page); 171
172 if (!PageUptodate(page)) 172 if (!PageUptodate(page))
173 { 173 {
174 kaddr = kmap(page); 174 kaddr = kmap(page);
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index c2634bda6b50..457a8fe28575 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -103,7 +103,7 @@ udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
103 offset = 0; 103 offset = 0;
104 104
105 if ((src.year < EPOCH_YEAR) || 105 if ((src.year < EPOCH_YEAR) ||
106 (src.year > EPOCH_YEAR+MAX_YEAR_SECONDS)) 106 (src.year >= EPOCH_YEAR+MAX_YEAR_SECONDS))
107 { 107 {
108 *dest = -1; 108 *dest = -1;
109 *dest_usec = -1; 109 *dest_usec = -1;
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 554e4a18c152..d3ff78354638 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -49,7 +49,7 @@ ifeq ($(CONFIG_XFS_TRACE),y)
49 EXTRA_CFLAGS += -DXFS_LOG_TRACE 49 EXTRA_CFLAGS += -DXFS_LOG_TRACE
50 EXTRA_CFLAGS += -DXFS_RW_TRACE 50 EXTRA_CFLAGS += -DXFS_RW_TRACE
51 EXTRA_CFLAGS += -DPAGEBUF_TRACE 51 EXTRA_CFLAGS += -DPAGEBUF_TRACE
52 # EXTRA_CFLAGS += -DXFS_VNODE_TRACE 52 EXTRA_CFLAGS += -DXFS_VNODE_TRACE
53endif 53endif
54 54
55obj-$(CONFIG_XFS_FS) += xfs.o 55obj-$(CONFIG_XFS_FS) += xfs.o
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 76a84758073a..9278e9aba9ba 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -558,7 +558,8 @@ xfs_submit_page(
558 int i; 558 int i;
559 559
560 BUG_ON(PageWriteback(page)); 560 BUG_ON(PageWriteback(page));
561 set_page_writeback(page); 561 if (bh_count)
562 set_page_writeback(page);
562 if (clear_dirty) 563 if (clear_dirty)
563 clear_page_dirty(page); 564 clear_page_dirty(page);
564 unlock_page(page); 565 unlock_page(page);
@@ -578,9 +579,6 @@ xfs_submit_page(
578 579
579 if (probed_page && clear_dirty) 580 if (probed_page && clear_dirty)
580 wbc->nr_to_write--; /* Wrote an "extra" page */ 581 wbc->nr_to_write--; /* Wrote an "extra" page */
581 } else {
582 end_page_writeback(page);
583 wbc->pages_skipped++; /* We didn't write this page */
584 } 582 }
585} 583}
586 584
@@ -602,21 +600,26 @@ xfs_convert_page(
602{ 600{
603 struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head; 601 struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
604 xfs_iomap_t *mp = iomapp, *tmp; 602 xfs_iomap_t *mp = iomapp, *tmp;
605 unsigned long end, offset; 603 unsigned long offset, end_offset;
606 pgoff_t end_index; 604 int index = 0;
607 int i = 0, index = 0;
608 int bbits = inode->i_blkbits; 605 int bbits = inode->i_blkbits;
606 int len, page_dirty;
609 607
610 end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT; 608 end_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1));
611 if (page->index < end_index) { 609
612 end = PAGE_CACHE_SIZE; 610 /*
613 } else { 611 * page_dirty is initially a count of buffers on the page before
614 end = i_size_read(inode) & (PAGE_CACHE_SIZE-1); 612 * EOF and is decrememted as we move each into a cleanable state.
615 } 613 */
614 len = 1 << inode->i_blkbits;
615 end_offset = max(end_offset, PAGE_CACHE_SIZE);
616 end_offset = roundup(end_offset, len);
617 page_dirty = end_offset / len;
618
619 offset = 0;
616 bh = head = page_buffers(page); 620 bh = head = page_buffers(page);
617 do { 621 do {
618 offset = i << bbits; 622 if (offset >= end_offset)
619 if (offset >= end)
620 break; 623 break;
621 if (!(PageUptodate(page) || buffer_uptodate(bh))) 624 if (!(PageUptodate(page) || buffer_uptodate(bh)))
622 continue; 625 continue;
@@ -625,6 +628,7 @@ xfs_convert_page(
625 if (startio) { 628 if (startio) {
626 lock_buffer(bh); 629 lock_buffer(bh);
627 bh_arr[index++] = bh; 630 bh_arr[index++] = bh;
631 page_dirty--;
628 } 632 }
629 continue; 633 continue;
630 } 634 }
@@ -657,10 +661,11 @@ xfs_convert_page(
657 unlock_buffer(bh); 661 unlock_buffer(bh);
658 mark_buffer_dirty(bh); 662 mark_buffer_dirty(bh);
659 } 663 }
660 } while (i++, (bh = bh->b_this_page) != head); 664 page_dirty--;
665 } while (offset += len, (bh = bh->b_this_page) != head);
661 666
662 if (startio) { 667 if (startio && index) {
663 xfs_submit_page(page, wbc, bh_arr, index, 1, index == i); 668 xfs_submit_page(page, wbc, bh_arr, index, 1, !page_dirty);
664 } else { 669 } else {
665 unlock_page(page); 670 unlock_page(page);
666 } 671 }
@@ -725,8 +730,11 @@ xfs_page_state_convert(
725 __uint64_t end_offset; 730 __uint64_t end_offset;
726 pgoff_t end_index, last_index, tlast; 731 pgoff_t end_index, last_index, tlast;
727 int len, err, i, cnt = 0, uptodate = 1; 732 int len, err, i, cnt = 0, uptodate = 1;
728 int flags = startio ? 0 : BMAPI_TRYLOCK; 733 int flags;
729 int page_dirty, delalloc = 0; 734 int page_dirty;
735
736 /* wait for other IO threads? */
737 flags = (startio && wbc->sync_mode != WB_SYNC_NONE) ? 0 : BMAPI_TRYLOCK;
730 738
731 /* Is this page beyond the end of the file? */ 739 /* Is this page beyond the end of the file? */
732 offset = i_size_read(inode); 740 offset = i_size_read(inode);
@@ -740,19 +748,22 @@ xfs_page_state_convert(
740 } 748 }
741 } 749 }
742 750
743 offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
744 end_offset = min_t(unsigned long long, 751 end_offset = min_t(unsigned long long,
745 offset + PAGE_CACHE_SIZE, i_size_read(inode)); 752 (loff_t)(page->index + 1) << PAGE_CACHE_SHIFT, offset);
746 753 offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
747 bh = head = page_buffers(page);
748 iomp = NULL;
749 754
750 /* 755 /*
751 * page_dirty is initially a count of buffers on the page and 756 * page_dirty is initially a count of buffers on the page before
752 * is decrememted as we move each into a cleanable state. 757 * EOF and is decrememted as we move each into a cleanable state.
753 */ 758 */
754 len = bh->b_size; 759 len = 1 << inode->i_blkbits;
755 page_dirty = PAGE_CACHE_SIZE / len; 760 p_offset = max(p_offset, PAGE_CACHE_SIZE);
761 p_offset = roundup(p_offset, len);
762 page_dirty = p_offset / len;
763
764 iomp = NULL;
765 p_offset = 0;
766 bh = head = page_buffers(page);
756 767
757 do { 768 do {
758 if (offset >= end_offset) 769 if (offset >= end_offset)
@@ -804,7 +815,6 @@ xfs_page_state_convert(
804 */ 815 */
805 } else if (buffer_delay(bh)) { 816 } else if (buffer_delay(bh)) {
806 if (!iomp) { 817 if (!iomp) {
807 delalloc = 1;
808 err = xfs_map_blocks(inode, offset, len, &iomap, 818 err = xfs_map_blocks(inode, offset, len, &iomap,
809 BMAPI_ALLOCATE | flags); 819 BMAPI_ALLOCATE | flags);
810 if (err) { 820 if (err) {
@@ -875,14 +885,15 @@ xfs_page_state_convert(
875 if (uptodate && bh == head) 885 if (uptodate && bh == head)
876 SetPageUptodate(page); 886 SetPageUptodate(page);
877 887
878 if (startio) 888 if (startio) {
879 xfs_submit_page(page, wbc, bh_arr, cnt, 0, 1); 889 WARN_ON(page_dirty);
890 xfs_submit_page(page, wbc, bh_arr, cnt, 0, !page_dirty);
891 }
880 892
881 if (iomp) { 893 if (iomp) {
882 tlast = (iomp->iomap_offset + iomp->iomap_bsize - 1) >> 894 offset = (iomp->iomap_offset + iomp->iomap_bsize - 1) >>
883 PAGE_CACHE_SHIFT; 895 PAGE_CACHE_SHIFT;
884 if (delalloc && (tlast > last_index)) 896 tlast = min_t(pgoff_t, offset, last_index);
885 tlast = last_index;
886 xfs_cluster_write(inode, page->index + 1, iomp, wbc, 897 xfs_cluster_write(inode, page->index + 1, iomp, wbc,
887 startio, unmapped, tlast); 898 startio, unmapped, tlast);
888 } 899 }
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 23e0eb67fc25..997963e53622 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1746,13 +1746,15 @@ STATIC DECLARE_COMPLETION(pagebuf_daemon_done);
1746STATIC struct task_struct *pagebuf_daemon_task; 1746STATIC struct task_struct *pagebuf_daemon_task;
1747STATIC int pagebuf_daemon_active; 1747STATIC int pagebuf_daemon_active;
1748STATIC int force_flush; 1748STATIC int force_flush;
1749 1749STATIC int force_sleep;
1750 1750
1751STATIC int 1751STATIC int
1752pagebuf_daemon_wakeup( 1752pagebuf_daemon_wakeup(
1753 int priority, 1753 int priority,
1754 unsigned int mask) 1754 unsigned int mask)
1755{ 1755{
1756 if (force_sleep)
1757 return 0;
1756 force_flush = 1; 1758 force_flush = 1;
1757 barrier(); 1759 barrier();
1758 wake_up_process(pagebuf_daemon_task); 1760 wake_up_process(pagebuf_daemon_task);
@@ -1778,7 +1780,12 @@ pagebuf_daemon(
1778 1780
1779 INIT_LIST_HEAD(&tmp); 1781 INIT_LIST_HEAD(&tmp);
1780 do { 1782 do {
1781 try_to_freeze(PF_FREEZE); 1783 if (unlikely(current->flags & PF_FREEZE)) {
1784 force_sleep = 1;
1785 refrigerator(PF_FREEZE);
1786 } else {
1787 force_sleep = 0;
1788 }
1782 1789
1783 set_current_state(TASK_INTERRUPTIBLE); 1790 set_current_state(TASK_INTERRUPTIBLE);
1784 schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100); 1791 schedule_timeout((xfs_buf_timer_centisecs * HZ) / 100);
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 9f057a4a5b06..d0d412afd261 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -515,10 +515,49 @@ open_exec_out:
515} 515}
516#endif /* HAVE_FOP_OPEN_EXEC */ 516#endif /* HAVE_FOP_OPEN_EXEC */
517 517
518/*
519 * Temporary workaround to the AIO direct IO write problem.
520 * This code can go and we can revert to do_sync_write once
521 * the writepage(s) rework is merged.
522 */
523STATIC ssize_t
524linvfs_write(
525 struct file *filp,
526 const char __user *buf,
527 size_t len,
528 loff_t *ppos)
529{
530 struct kiocb kiocb;
531 ssize_t ret;
532
533 init_sync_kiocb(&kiocb, filp);
534 kiocb.ki_pos = *ppos;
535 ret = __linvfs_write(&kiocb, buf, 0, len, kiocb.ki_pos);
536 *ppos = kiocb.ki_pos;
537 return ret;
538}
539STATIC ssize_t
540linvfs_write_invis(
541 struct file *filp,
542 const char __user *buf,
543 size_t len,
544 loff_t *ppos)
545{
546 struct kiocb kiocb;
547 ssize_t ret;
548
549 init_sync_kiocb(&kiocb, filp);
550 kiocb.ki_pos = *ppos;
551 ret = __linvfs_write(&kiocb, buf, IO_INVIS, len, kiocb.ki_pos);
552 *ppos = kiocb.ki_pos;
553 return ret;
554}
555
556
518struct file_operations linvfs_file_operations = { 557struct file_operations linvfs_file_operations = {
519 .llseek = generic_file_llseek, 558 .llseek = generic_file_llseek,
520 .read = do_sync_read, 559 .read = do_sync_read,
521 .write = do_sync_write, 560 .write = linvfs_write,
522 .readv = linvfs_readv, 561 .readv = linvfs_readv,
523 .writev = linvfs_writev, 562 .writev = linvfs_writev,
524 .aio_read = linvfs_aio_read, 563 .aio_read = linvfs_aio_read,
@@ -540,7 +579,7 @@ struct file_operations linvfs_file_operations = {
540struct file_operations linvfs_invis_file_operations = { 579struct file_operations linvfs_invis_file_operations = {
541 .llseek = generic_file_llseek, 580 .llseek = generic_file_llseek,
542 .read = do_sync_read, 581 .read = do_sync_read,
543 .write = do_sync_write, 582 .write = linvfs_write_invis,
544 .readv = linvfs_readv_invis, 583 .readv = linvfs_readv_invis,
545 .writev = linvfs_writev_invis, 584 .writev = linvfs_writev_invis,
546 .aio_read = linvfs_aio_read_invis, 585 .aio_read = linvfs_aio_read_invis,
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index ff145fd0d1a4..aa9daaea6c34 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -683,6 +683,9 @@ xfs_write(
683 (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? 683 (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
684 mp->m_rtdev_targp : mp->m_ddev_targp; 684 mp->m_rtdev_targp : mp->m_ddev_targp;
685 685
686 if (ioflags & IO_ISAIO)
687 return XFS_ERROR(-ENOSYS);
688
686 if ((pos & target->pbr_smask) || (count & target->pbr_smask)) 689 if ((pos & target->pbr_smask) || (count & target->pbr_smask))
687 return XFS_ERROR(-EINVAL); 690 return XFS_ERROR(-EINVAL);
688 691
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 849c61c74f3c..a832d165f24f 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -156,7 +156,6 @@ vn_initialize(
156 156
157#ifdef XFS_VNODE_TRACE 157#ifdef XFS_VNODE_TRACE
158 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP); 158 vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
159 printk("Allocated VNODE_TRACE at 0x%p\n", vp->v_trace);
160#endif /* XFS_VNODE_TRACE */ 159#endif /* XFS_VNODE_TRACE */
161 160
162 vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address); 161 vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
@@ -424,13 +423,13 @@ vn_remove(
424 * Vnode tracing code. 423 * Vnode tracing code.
425 */ 424 */
426void 425void
427vn_trace_entry(vnode_t *vp, char *func, inst_t *ra) 426vn_trace_entry(vnode_t *vp, const char *func, inst_t *ra)
428{ 427{
429 KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra); 428 KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
430} 429}
431 430
432void 431void
433vn_trace_exit(vnode_t *vp, char *func, inst_t *ra) 432vn_trace_exit(vnode_t *vp, const char *func, inst_t *ra)
434{ 433{
435 KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra); 434 KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
436} 435}
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index da76c1f1e11c..00466c3194ac 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -86,10 +86,11 @@ typedef struct vnode {
86 vnumber_t v_number; /* in-core vnode number */ 86 vnumber_t v_number; /* in-core vnode number */
87 vn_bhv_head_t v_bh; /* behavior head */ 87 vn_bhv_head_t v_bh; /* behavior head */
88 spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */ 88 spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */
89 struct inode v_inode; /* Linux inode */
90#ifdef XFS_VNODE_TRACE 89#ifdef XFS_VNODE_TRACE
91 struct ktrace *v_trace; /* trace header structure */ 90 struct ktrace *v_trace; /* trace header structure */
92#endif 91#endif
92 struct inode v_inode; /* Linux inode */
93 /* inode MUST be last */
93} vnode_t; 94} vnode_t;
94 95
95#define v_fbhv v_bh.bh_first /* first behavior */ 96#define v_fbhv v_bh.bh_first /* first behavior */
@@ -409,7 +410,7 @@ typedef struct vattr {
409 int va_mask; /* bit-mask of attributes present */ 410 int va_mask; /* bit-mask of attributes present */
410 enum vtype va_type; /* vnode type (for create) */ 411 enum vtype va_type; /* vnode type (for create) */
411 mode_t va_mode; /* file access mode and type */ 412 mode_t va_mode; /* file access mode and type */
412 nlink_t va_nlink; /* number of references to file */ 413 xfs_nlink_t va_nlink; /* number of references to file */
413 uid_t va_uid; /* owner user id */ 414 uid_t va_uid; /* owner user id */
414 gid_t va_gid; /* owner group id */ 415 gid_t va_gid; /* owner group id */
415 xfs_ino_t va_nodeid; /* file id */ 416 xfs_ino_t va_nodeid; /* file id */
@@ -625,6 +626,7 @@ static inline int VN_BAD(struct vnode *vp)
625#define ATTR_DMI 0x08 /* invocation from a DMI function */ 626#define ATTR_DMI 0x08 /* invocation from a DMI function */
626#define ATTR_LAZY 0x80 /* set/get attributes lazily */ 627#define ATTR_LAZY 0x80 /* set/get attributes lazily */
627#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */ 628#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
629#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
628 630
629/* 631/*
630 * Flags to VOP_FSYNC and VOP_RECLAIM. 632 * Flags to VOP_FSYNC and VOP_RECLAIM.
@@ -646,8 +648,8 @@ static inline int VN_BAD(struct vnode *vp)
646#define VNODE_KTRACE_REF 4 648#define VNODE_KTRACE_REF 4
647#define VNODE_KTRACE_RELE 5 649#define VNODE_KTRACE_RELE 5
648 650
649extern void vn_trace_entry(struct vnode *, char *, inst_t *); 651extern void vn_trace_entry(struct vnode *, const char *, inst_t *);
650extern void vn_trace_exit(struct vnode *, char *, inst_t *); 652extern void vn_trace_exit(struct vnode *, const char *, inst_t *);
651extern void vn_trace_hold(struct vnode *, char *, int, inst_t *); 653extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
652extern void vn_trace_ref(struct vnode *, char *, int, inst_t *); 654extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
653extern void vn_trace_rele(struct vnode *, char *, int, inst_t *); 655extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index 08d551a17347..63abdc2ac7f4 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -182,7 +182,7 @@ xfs_swapext(
182 182
183 if (VN_CACHED(tvp) != 0) 183 if (VN_CACHED(tvp) != 0)
184 xfs_inval_cached_pages(XFS_ITOV(tip), &(tip->i_iocore), 184 xfs_inval_cached_pages(XFS_ITOV(tip), &(tip->i_iocore),
185 (loff_t)0, 0, 0); 185 (xfs_off_t)0, 0, 0);
186 186
187 /* Verify O_DIRECT for ftmp */ 187 /* Verify O_DIRECT for ftmp */
188 if (VN_CACHED(tvp) != 0) { 188 if (VN_CACHED(tvp) != 0) {
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 3a0ba1dfd0e8..d3da00045f26 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -136,6 +136,40 @@ xfs_chash_free(xfs_mount_t *mp)
136} 136}
137 137
138/* 138/*
139 * Try to move an inode to the front of its hash list if possible
140 * (and if its not there already). Called right after obtaining
141 * the list version number and then dropping the read_lock on the
142 * hash list in question (which is done right after looking up the
143 * inode in question...).
144 */
145STATIC void
146xfs_ihash_promote(
147 xfs_ihash_t *ih,
148 xfs_inode_t *ip,
149 ulong version)
150{
151 xfs_inode_t *iq;
152
153 if ((ip->i_prevp != &ih->ih_next) && write_trylock(&ih->ih_lock)) {
154 if (likely(version == ih->ih_version)) {
155 /* remove from list */
156 if ((iq = ip->i_next)) {
157 iq->i_prevp = ip->i_prevp;
158 }
159 *ip->i_prevp = iq;
160
161 /* insert at list head */
162 iq = ih->ih_next;
163 iq->i_prevp = &ip->i_next;
164 ip->i_next = iq;
165 ip->i_prevp = &ih->ih_next;
166 ih->ih_next = ip;
167 }
168 write_unlock(&ih->ih_lock);
169 }
170}
171
172/*
139 * Look up an inode by number in the given file system. 173 * Look up an inode by number in the given file system.
140 * The inode is looked up in the hash table for the file system 174 * The inode is looked up in the hash table for the file system
141 * represented by the mount point parameter mp. Each bucket of 175 * represented by the mount point parameter mp. Each bucket of
@@ -229,7 +263,9 @@ again:
229 XFS_STATS_INC(xs_ig_found); 263 XFS_STATS_INC(xs_ig_found);
230 264
231 ip->i_flags &= ~XFS_IRECLAIMABLE; 265 ip->i_flags &= ~XFS_IRECLAIMABLE;
266 version = ih->ih_version;
232 read_unlock(&ih->ih_lock); 267 read_unlock(&ih->ih_lock);
268 xfs_ihash_promote(ih, ip, version);
233 269
234 XFS_MOUNT_ILOCK(mp); 270 XFS_MOUNT_ILOCK(mp);
235 list_del_init(&ip->i_reclaim); 271 list_del_init(&ip->i_reclaim);
@@ -259,8 +295,15 @@ again:
259 inode_vp, vp); 295 inode_vp, vp);
260 } 296 }
261 297
298 /*
299 * Inode cache hit: if ip is not at the front of
300 * its hash chain, move it there now.
301 * Do this with the lock held for update, but
302 * do statistics after releasing the lock.
303 */
304 version = ih->ih_version;
262 read_unlock(&ih->ih_lock); 305 read_unlock(&ih->ih_lock);
263 306 xfs_ihash_promote(ih, ip, version);
264 XFS_STATS_INC(xs_ig_found); 307 XFS_STATS_INC(xs_ig_found);
265 308
266finish_inode: 309finish_inode:
@@ -547,6 +590,7 @@ xfs_inode_incore(xfs_mount_t *mp,
547{ 590{
548 xfs_ihash_t *ih; 591 xfs_ihash_t *ih;
549 xfs_inode_t *ip; 592 xfs_inode_t *ip;
593 ulong version;
550 594
551 ih = XFS_IHASH(mp, ino); 595 ih = XFS_IHASH(mp, ino);
552 read_lock(&ih->ih_lock); 596 read_lock(&ih->ih_lock);
@@ -554,11 +598,15 @@ xfs_inode_incore(xfs_mount_t *mp,
554 if (ip->i_ino == ino) { 598 if (ip->i_ino == ino) {
555 /* 599 /*
556 * If we find it and tp matches, return it. 600 * If we find it and tp matches, return it.
601 * Also move it to the front of the hash list
602 * if we find it and it is not already there.
557 * Otherwise break from the loop and return 603 * Otherwise break from the loop and return
558 * NULL. 604 * NULL.
559 */ 605 */
560 if (ip->i_transp == tp) { 606 if (ip->i_transp == tp) {
607 version = ih->ih_version;
561 read_unlock(&ih->ih_lock); 608 read_unlock(&ih->ih_lock);
609 xfs_ihash_promote(ih, ip, version);
562 return (ip); 610 return (ip);
563 } 611 }
564 break; 612 break;
@@ -685,6 +733,7 @@ xfs_iextract(
685 iq->i_prevp = ip->i_prevp; 733 iq->i_prevp = ip->i_prevp;
686 } 734 }
687 *ip->i_prevp = iq; 735 *ip->i_prevp = iq;
736 ih->ih_version++;
688 write_unlock(&ih->ih_lock); 737 write_unlock(&ih->ih_lock);
689 738
690 /* 739 /*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 43c632ab86ad..bc8c8c7f9039 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1130,7 +1130,7 @@ xfs_ialloc(
1130 xfs_trans_t *tp, 1130 xfs_trans_t *tp,
1131 xfs_inode_t *pip, 1131 xfs_inode_t *pip,
1132 mode_t mode, 1132 mode_t mode,
1133 nlink_t nlink, 1133 xfs_nlink_t nlink,
1134 xfs_dev_t rdev, 1134 xfs_dev_t rdev,
1135 cred_t *cr, 1135 cred_t *cr,
1136 xfs_prid_t prid, 1136 xfs_prid_t prid,
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index a53b1ccf6070..37e1c316f3b6 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -495,9 +495,9 @@ int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
495int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 495int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
496 xfs_inode_t **, xfs_daddr_t); 496 xfs_inode_t **, xfs_daddr_t);
497int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int); 497int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
498int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, nlink_t, 498int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
499 xfs_dev_t, struct cred *, xfs_prid_t, int, 499 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
500 struct xfs_buf **, boolean_t *, xfs_inode_t **); 500 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
501void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *, 501void xfs_xlate_dinode_core(xfs_caddr_t, struct xfs_dinode_core *,
502 int); 502 int);
503uint xfs_ip2xflags(struct xfs_inode *); 503uint xfs_ip2xflags(struct xfs_inode *);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 3826e8f0e28a..991f8a61f7c4 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -308,7 +308,8 @@ phase2:
308 break; 308 break;
309 } 309 }
310 310
311 error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, &imap, &nimaps); 311 error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, offset, count,
312 &imap, &nimaps);
312 break; 313 break;
313 case BMAPI_UNWRITTEN: 314 case BMAPI_UNWRITTEN:
314 lockmode = 0; 315 lockmode = 0;
@@ -365,7 +366,7 @@ xfs_flush_space(
365int 366int
366xfs_iomap_write_direct( 367xfs_iomap_write_direct(
367 xfs_inode_t *ip, 368 xfs_inode_t *ip,
368 loff_t offset, 369 xfs_off_t offset,
369 size_t count, 370 size_t count,
370 int flags, 371 int flags,
371 xfs_bmbt_irec_t *ret_imap, 372 xfs_bmbt_irec_t *ret_imap,
@@ -541,7 +542,7 @@ error_out:
541int 542int
542xfs_iomap_write_delay( 543xfs_iomap_write_delay(
543 xfs_inode_t *ip, 544 xfs_inode_t *ip,
544 loff_t offset, 545 xfs_off_t offset,
545 size_t count, 546 size_t count,
546 int ioflag, 547 int ioflag,
547 xfs_bmbt_irec_t *ret_imap, 548 xfs_bmbt_irec_t *ret_imap,
@@ -746,6 +747,8 @@ write_map:
746int 747int
747xfs_iomap_write_allocate( 748xfs_iomap_write_allocate(
748 xfs_inode_t *ip, 749 xfs_inode_t *ip,
750 xfs_off_t offset,
751 size_t count,
749 xfs_bmbt_irec_t *map, 752 xfs_bmbt_irec_t *map,
750 int *retmap) 753 int *retmap)
751{ 754{
@@ -770,9 +773,9 @@ xfs_iomap_write_allocate(
770 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 773 if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
771 return XFS_ERROR(error); 774 return XFS_ERROR(error);
772 775
773 offset_fsb = map->br_startoff; 776 offset_fsb = XFS_B_TO_FSBT(mp, offset);
774 count_fsb = map->br_blockcount; 777 count_fsb = map->br_blockcount;
775 map_start_fsb = offset_fsb; 778 map_start_fsb = map->br_startoff;
776 779
777 XFS_STATS_ADD(xs_xstrat_bytes, XFS_FSB_TO_B(mp, count_fsb)); 780 XFS_STATS_ADD(xs_xstrat_bytes, XFS_FSB_TO_B(mp, count_fsb));
778 781
@@ -868,9 +871,9 @@ xfs_iomap_write_allocate(
868 imap[i].br_startoff, 871 imap[i].br_startoff,
869 imap[i].br_blockcount,imap[i].br_state); 872 imap[i].br_blockcount,imap[i].br_state);
870 } 873 }
871 if ((map->br_startoff >= imap[i].br_startoff) && 874 if ((offset_fsb >= imap[i].br_startoff) &&
872 (map->br_startoff < (imap[i].br_startoff + 875 (offset_fsb < (imap[i].br_startoff +
873 imap[i].br_blockcount))) { 876 imap[i].br_blockcount))) {
874 *map = imap[i]; 877 *map = imap[i];
875 *retmap = 1; 878 *retmap = 1;
876 XFS_STATS_INC(xs_xstrat_quick); 879 XFS_STATS_INC(xs_xstrat_quick);
@@ -883,9 +886,8 @@ xfs_iomap_write_allocate(
883 * file, just surrounding data, try again. 886 * file, just surrounding data, try again.
884 */ 887 */
885 nimaps--; 888 nimaps--;
886 offset_fsb = imap[nimaps].br_startoff + 889 map_start_fsb = imap[nimaps].br_startoff +
887 imap[nimaps].br_blockcount; 890 imap[nimaps].br_blockcount;
888 map_start_fsb = offset_fsb;
889 } 891 }
890 892
891trans_cancel: 893trans_cancel:
@@ -899,7 +901,7 @@ error0:
899int 901int
900xfs_iomap_write_unwritten( 902xfs_iomap_write_unwritten(
901 xfs_inode_t *ip, 903 xfs_inode_t *ip,
902 loff_t offset, 904 xfs_off_t offset,
903 size_t count) 905 size_t count)
904{ 906{
905 xfs_mount_t *mp = ip->i_mount; 907 xfs_mount_t *mp = ip->i_mount;
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
index 31c91087cb33..4daaa5212102 100644
--- a/fs/xfs/xfs_iomap.h
+++ b/fs/xfs/xfs_iomap.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2003,2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2003-2005 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as 5 * under the terms of version 2 of the GNU General Public License as
@@ -29,9 +29,6 @@
29 * 29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ 30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 31 */
32
33
34
35#ifndef __XFS_IOMAP_H__ 32#ifndef __XFS_IOMAP_H__
36#define __XFS_IOMAP_H__ 33#define __XFS_IOMAP_H__
37 34
@@ -56,7 +53,7 @@ typedef enum {
56 BMAPI_UNWRITTEN = (1 << 3), /* unwritten extents to real extents */ 53 BMAPI_UNWRITTEN = (1 << 3), /* unwritten extents to real extents */
57 /* modifiers */ 54 /* modifiers */
58 BMAPI_IGNSTATE = (1 << 4), /* ignore unwritten state on read */ 55 BMAPI_IGNSTATE = (1 << 4), /* ignore unwritten state on read */
59 BMAPI_DIRECT = (1 << 5), /* direct instead of buffered write */ 56 BMAPI_DIRECT = (1 << 5), /* direct instead of buffered write */
60 BMAPI_MMAP = (1 << 6), /* allocate for mmap write */ 57 BMAPI_MMAP = (1 << 6), /* allocate for mmap write */
61 BMAPI_SYNC = (1 << 7), /* sync write to flush delalloc space */ 58 BMAPI_SYNC = (1 << 7), /* sync write to flush delalloc space */
62 BMAPI_TRYLOCK = (1 << 8), /* non-blocking request */ 59 BMAPI_TRYLOCK = (1 << 8), /* non-blocking request */
@@ -67,13 +64,13 @@ typedef enum {
67/* 64/*
68 * xfs_iomap_t: File system I/O map 65 * xfs_iomap_t: File system I/O map
69 * 66 *
70 * The iomap_bn field is expressed in 512-byte blocks, and is where the 67 * The iomap_bn field is expressed in 512-byte blocks, and is where the
71 * mapping starts on disk. 68 * mapping starts on disk.
72 * 69 *
73 * The iomap_offset, iomap_bsize and iomap_delta fields are in bytes. 70 * The iomap_offset, iomap_bsize and iomap_delta fields are in bytes.
74 * iomap_offset is the offset of the mapping in the file itself. 71 * iomap_offset is the offset of the mapping in the file itself.
75 * iomap_bsize is the size of the mapping, iomap_delta is the 72 * iomap_bsize is the size of the mapping, iomap_delta is the
76 * desired data's offset into the mapping, given the offset supplied 73 * desired data's offset into the mapping, given the offset supplied
77 * to the file I/O map routine. 74 * to the file I/O map routine.
78 * 75 *
79 * When a request is made to read beyond the logical end of the object, 76 * When a request is made to read beyond the logical end of the object,
@@ -84,8 +81,8 @@ typedef enum {
84typedef struct xfs_iomap { 81typedef struct xfs_iomap {
85 xfs_daddr_t iomap_bn; /* first 512b blk of mapping */ 82 xfs_daddr_t iomap_bn; /* first 512b blk of mapping */
86 xfs_buftarg_t *iomap_target; 83 xfs_buftarg_t *iomap_target;
87 loff_t iomap_offset; /* offset of mapping, bytes */ 84 xfs_off_t iomap_offset; /* offset of mapping, bytes */
88 loff_t iomap_bsize; /* size of mapping, bytes */ 85 xfs_off_t iomap_bsize; /* size of mapping, bytes */
89 size_t iomap_delta; /* offset into mapping, bytes */ 86 size_t iomap_delta; /* offset into mapping, bytes */
90 iomap_flags_t iomap_flags; 87 iomap_flags_t iomap_flags;
91} xfs_iomap_t; 88} xfs_iomap_t;
@@ -96,12 +93,12 @@ struct xfs_bmbt_irec;
96 93
97extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int, 94extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int,
98 struct xfs_iomap *, int *); 95 struct xfs_iomap *, int *);
99extern int xfs_iomap_write_direct(struct xfs_inode *, loff_t, size_t, 96extern int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t,
100 int, struct xfs_bmbt_irec *, int *, int); 97 int, struct xfs_bmbt_irec *, int *, int);
101extern int xfs_iomap_write_delay(struct xfs_inode *, loff_t, size_t, int, 98extern int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int,
102 struct xfs_bmbt_irec *, int *); 99 struct xfs_bmbt_irec *, int *);
103extern int xfs_iomap_write_allocate(struct xfs_inode *, 100extern int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t, size_t,
104 struct xfs_bmbt_irec *, int *); 101 struct xfs_bmbt_irec *, int *);
105extern int xfs_iomap_write_unwritten(struct xfs_inode *, loff_t, size_t); 102extern int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, size_t);
106 103
107#endif /* __XFS_IOMAP_H__*/ 104#endif /* __XFS_IOMAP_H__*/
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index b57423caef9b..2ec967d93e5a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -301,6 +301,15 @@ xfs_mount_validate_sb(
301 } 301 }
302 302
303 /* 303 /*
304 * Version 1 directory format has never worked on Linux.
305 */
306 if (unlikely(!XFS_SB_VERSION_HASDIRV2(sbp))) {
307 cmn_err(CE_WARN,
308 "XFS: Attempted to mount file system using version 1 directory format");
309 return XFS_ERROR(ENOSYS);
310 }
311
312 /*
304 * Until this is fixed only page-sized or smaller data blocks work. 313 * Until this is fixed only page-sized or smaller data blocks work.
305 */ 314 */
306 if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) { 315 if (unlikely(sbp->sb_blocksize > PAGE_SIZE)) {
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 5fc6201dd8e2..30dd08fb9f57 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -210,15 +210,16 @@ typedef int (*xfs_bmapi_t)(struct xfs_trans *, void *,
210 struct xfs_bmap_free *); 210 struct xfs_bmap_free *);
211typedef int (*xfs_bmap_eof_t)(void *, xfs_fileoff_t, int, int *); 211typedef int (*xfs_bmap_eof_t)(void *, xfs_fileoff_t, int, int *);
212typedef int (*xfs_iomap_write_direct_t)( 212typedef int (*xfs_iomap_write_direct_t)(
213 void *, loff_t, size_t, int, 213 void *, xfs_off_t, size_t, int,
214 struct xfs_bmbt_irec *, int *, int); 214 struct xfs_bmbt_irec *, int *, int);
215typedef int (*xfs_iomap_write_delay_t)( 215typedef int (*xfs_iomap_write_delay_t)(
216 void *, loff_t, size_t, int, 216 void *, xfs_off_t, size_t, int,
217 struct xfs_bmbt_irec *, int *); 217 struct xfs_bmbt_irec *, int *);
218typedef int (*xfs_iomap_write_allocate_t)( 218typedef int (*xfs_iomap_write_allocate_t)(
219 void *, struct xfs_bmbt_irec *, int *); 219 void *, xfs_off_t, size_t,
220 struct xfs_bmbt_irec *, int *);
220typedef int (*xfs_iomap_write_unwritten_t)( 221typedef int (*xfs_iomap_write_unwritten_t)(
221 void *, loff_t, size_t); 222 void *, xfs_off_t, size_t);
222typedef uint (*xfs_lck_map_shared_t)(void *); 223typedef uint (*xfs_lck_map_shared_t)(void *);
223typedef void (*xfs_lock_t)(void *, uint); 224typedef void (*xfs_lock_t)(void *, uint);
224typedef void (*xfs_lock_demote_t)(void *, uint); 225typedef void (*xfs_lock_demote_t)(void *, uint);
@@ -258,9 +259,9 @@ typedef struct xfs_ioops {
258#define XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, flags, mval, nmap) \ 259#define XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, flags, mval, nmap) \
259 (*(mp)->m_io_ops.xfs_iomap_write_delay) \ 260 (*(mp)->m_io_ops.xfs_iomap_write_delay) \
260 ((io)->io_obj, offset, count, flags, mval, nmap) 261 ((io)->io_obj, offset, count, flags, mval, nmap)
261#define XFS_IOMAP_WRITE_ALLOCATE(mp, io, mval, nmap) \ 262#define XFS_IOMAP_WRITE_ALLOCATE(mp, io, offset, count, mval, nmap) \
262 (*(mp)->m_io_ops.xfs_iomap_write_allocate) \ 263 (*(mp)->m_io_ops.xfs_iomap_write_allocate) \
263 ((io)->io_obj, mval, nmap) 264 ((io)->io_obj, offset, count, mval, nmap)
264#define XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count) \ 265#define XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count) \
265 (*(mp)->m_io_ops.xfs_iomap_write_unwritten) \ 266 (*(mp)->m_io_ops.xfs_iomap_write_unwritten) \
266 ((io)->io_obj, offset, count) 267 ((io)->io_obj, offset, count)
@@ -428,10 +429,10 @@ typedef struct xfs_mount {
428#define XFS_WRITEIO_LOG_LARGE 16 429#define XFS_WRITEIO_LOG_LARGE 16
429 430
430/* 431/*
431 * Max and min values for UIO and mount-option defined I/O sizes; 432 * Max and min values for mount-option defined I/O
432 * min value can't be less than a page. Currently unused. 433 * preallocation sizes.
433 */ 434 */
434#define XFS_MAX_IO_LOG 16 /* 64K */ 435#define XFS_MAX_IO_LOG 30 /* 1G */
435#define XFS_MIN_IO_LOG PAGE_SHIFT 436#define XFS_MIN_IO_LOG PAGE_SHIFT
436 437
437/* 438/*
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h
index 04609d27ea51..e4bf711e48ff 100644
--- a/fs/xfs/xfs_types.h
+++ b/fs/xfs/xfs_types.h
@@ -63,6 +63,7 @@ typedef __u64 xfs_ino_t; /* <inode> type */
63typedef __s64 xfs_daddr_t; /* <disk address> type */ 63typedef __s64 xfs_daddr_t; /* <disk address> type */
64typedef char * xfs_caddr_t; /* <core address> type */ 64typedef char * xfs_caddr_t; /* <core address> type */
65typedef __u32 xfs_dev_t; 65typedef __u32 xfs_dev_t;
66typedef __u32 xfs_nlink_t;
66 67
67/* __psint_t is the same size as a pointer */ 68/* __psint_t is the same size as a pointer */
68#if (BITS_PER_LONG == 32) 69#if (BITS_PER_LONG == 32)
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 816b945fa0ea..d1f8146a06ea 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -147,7 +147,7 @@ xfs_dir_ialloc(
147 xfs_inode_t *dp, /* directory within whose allocate 147 xfs_inode_t *dp, /* directory within whose allocate
148 the inode. */ 148 the inode. */
149 mode_t mode, 149 mode_t mode,
150 nlink_t nlink, 150 xfs_nlink_t nlink,
151 xfs_dev_t rdev, 151 xfs_dev_t rdev,
152 cred_t *credp, 152 cred_t *credp,
153 prid_t prid, /* project id */ 153 prid_t prid, /* project id */
diff --git a/fs/xfs/xfs_utils.h b/fs/xfs/xfs_utils.h
index e1ed6a588000..01d98b4b7af7 100644
--- a/fs/xfs/xfs_utils.h
+++ b/fs/xfs/xfs_utils.h
@@ -42,7 +42,7 @@ extern int xfs_get_dir_entry (vname_t *, xfs_inode_t **);
42extern int xfs_dir_lookup_int (bhv_desc_t *, uint, vname_t *, xfs_ino_t *, 42extern int xfs_dir_lookup_int (bhv_desc_t *, uint, vname_t *, xfs_ino_t *,
43 xfs_inode_t **); 43 xfs_inode_t **);
44extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *); 44extern int xfs_truncate_file (xfs_mount_t *, xfs_inode_t *);
45extern int xfs_dir_ialloc (xfs_trans_t **, xfs_inode_t *, mode_t, nlink_t, 45extern int xfs_dir_ialloc (xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t,
46 xfs_dev_t, cred_t *, prid_t, int, 46 xfs_dev_t, cred_t *, prid_t, int,
47 xfs_inode_t **, int *); 47 xfs_inode_t **, int *);
48extern int xfs_droplink (xfs_trans_t *, xfs_inode_t *); 48extern int xfs_droplink (xfs_trans_t *, xfs_inode_t *);
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 00aae9c6a904..b53736650100 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -1649,6 +1649,7 @@ xfs_vget(
1649#define MNTOPT_SWIDTH "swidth" /* data volume stripe width */ 1649#define MNTOPT_SWIDTH "swidth" /* data volume stripe width */
1650#define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */ 1650#define MNTOPT_NOUUID "nouuid" /* ignore filesystem UUID */
1651#define MNTOPT_MTPT "mtpt" /* filesystem mount point */ 1651#define MNTOPT_MTPT "mtpt" /* filesystem mount point */
1652#define MNTOPT_ALLOCSIZE "allocsize" /* preferred allocation size */
1652#define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */ 1653#define MNTOPT_IHASHSIZE "ihashsize" /* size of inode hash table */
1653#define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */ 1654#define MNTOPT_NORECOVERY "norecovery" /* don't run XFS recovery */
1654#define MNTOPT_NOLOGFLUSH "nologflush" /* don't hard flush on log writes */ 1655#define MNTOPT_NOLOGFLUSH "nologflush" /* don't hard flush on log writes */
@@ -1657,6 +1658,28 @@ xfs_vget(
1657#define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */ 1658#define MNTOPT_IKEEP "ikeep" /* do not free empty inode clusters */
1658#define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */ 1659#define MNTOPT_NOIKEEP "noikeep" /* free empty inode clusters */
1659 1660
1661STATIC unsigned long
1662suffix_strtoul(const char *cp, char **endp, unsigned int base)
1663{
1664 int last, shift_left_factor = 0;
1665 char *value = (char *)cp;
1666
1667 last = strlen(value) - 1;
1668 if (value[last] == 'K' || value[last] == 'k') {
1669 shift_left_factor = 10;
1670 value[last] = '\0';
1671 }
1672 if (value[last] == 'M' || value[last] == 'm') {
1673 shift_left_factor = 20;
1674 value[last] = '\0';
1675 }
1676 if (value[last] == 'G' || value[last] == 'g') {
1677 shift_left_factor = 30;
1678 value[last] = '\0';
1679 }
1680
1681 return simple_strtoul(cp, endp, base) << shift_left_factor;
1682}
1660 1683
1661int 1684int
1662xfs_parseargs( 1685xfs_parseargs(
@@ -1688,60 +1711,60 @@ xfs_parseargs(
1688 if (!strcmp(this_char, MNTOPT_LOGBUFS)) { 1711 if (!strcmp(this_char, MNTOPT_LOGBUFS)) {
1689 if (!value || !*value) { 1712 if (!value || !*value) {
1690 printk("XFS: %s option requires an argument\n", 1713 printk("XFS: %s option requires an argument\n",
1691 MNTOPT_LOGBUFS); 1714 this_char);
1692 return EINVAL; 1715 return EINVAL;
1693 } 1716 }
1694 args->logbufs = simple_strtoul(value, &eov, 10); 1717 args->logbufs = simple_strtoul(value, &eov, 10);
1695 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) { 1718 } else if (!strcmp(this_char, MNTOPT_LOGBSIZE)) {
1696 int last, in_kilobytes = 0;
1697
1698 if (!value || !*value) { 1719 if (!value || !*value) {
1699 printk("XFS: %s option requires an argument\n", 1720 printk("XFS: %s option requires an argument\n",
1700 MNTOPT_LOGBSIZE); 1721 this_char);
1701 return EINVAL; 1722 return EINVAL;
1702 } 1723 }
1703 last = strlen(value) - 1; 1724 args->logbufsize = suffix_strtoul(value, &eov, 10);
1704 if (value[last] == 'K' || value[last] == 'k') {
1705 in_kilobytes = 1;
1706 value[last] = '\0';
1707 }
1708 args->logbufsize = simple_strtoul(value, &eov, 10);
1709 if (in_kilobytes)
1710 args->logbufsize <<= 10;
1711 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) { 1725 } else if (!strcmp(this_char, MNTOPT_LOGDEV)) {
1712 if (!value || !*value) { 1726 if (!value || !*value) {
1713 printk("XFS: %s option requires an argument\n", 1727 printk("XFS: %s option requires an argument\n",
1714 MNTOPT_LOGDEV); 1728 this_char);
1715 return EINVAL; 1729 return EINVAL;
1716 } 1730 }
1717 strncpy(args->logname, value, MAXNAMELEN); 1731 strncpy(args->logname, value, MAXNAMELEN);
1718 } else if (!strcmp(this_char, MNTOPT_MTPT)) { 1732 } else if (!strcmp(this_char, MNTOPT_MTPT)) {
1719 if (!value || !*value) { 1733 if (!value || !*value) {
1720 printk("XFS: %s option requires an argument\n", 1734 printk("XFS: %s option requires an argument\n",
1721 MNTOPT_MTPT); 1735 this_char);
1722 return EINVAL; 1736 return EINVAL;
1723 } 1737 }
1724 strncpy(args->mtpt, value, MAXNAMELEN); 1738 strncpy(args->mtpt, value, MAXNAMELEN);
1725 } else if (!strcmp(this_char, MNTOPT_RTDEV)) { 1739 } else if (!strcmp(this_char, MNTOPT_RTDEV)) {
1726 if (!value || !*value) { 1740 if (!value || !*value) {
1727 printk("XFS: %s option requires an argument\n", 1741 printk("XFS: %s option requires an argument\n",
1728 MNTOPT_RTDEV); 1742 this_char);
1729 return EINVAL; 1743 return EINVAL;
1730 } 1744 }
1731 strncpy(args->rtname, value, MAXNAMELEN); 1745 strncpy(args->rtname, value, MAXNAMELEN);
1732 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) { 1746 } else if (!strcmp(this_char, MNTOPT_BIOSIZE)) {
1733 if (!value || !*value) { 1747 if (!value || !*value) {
1734 printk("XFS: %s option requires an argument\n", 1748 printk("XFS: %s option requires an argument\n",
1735 MNTOPT_BIOSIZE); 1749 this_char);
1736 return EINVAL; 1750 return EINVAL;
1737 } 1751 }
1738 iosize = simple_strtoul(value, &eov, 10); 1752 iosize = simple_strtoul(value, &eov, 10);
1739 args->flags |= XFSMNT_IOSIZE; 1753 args->flags |= XFSMNT_IOSIZE;
1740 args->iosizelog = (uint8_t) iosize; 1754 args->iosizelog = (uint8_t) iosize;
1755 } else if (!strcmp(this_char, MNTOPT_ALLOCSIZE)) {
1756 if (!value || !*value) {
1757 printk("XFS: %s option requires an argument\n",
1758 this_char);
1759 return EINVAL;
1760 }
1761 iosize = suffix_strtoul(value, &eov, 10);
1762 args->flags |= XFSMNT_IOSIZE;
1763 args->iosizelog = ffs(iosize) - 1;
1741 } else if (!strcmp(this_char, MNTOPT_IHASHSIZE)) { 1764 } else if (!strcmp(this_char, MNTOPT_IHASHSIZE)) {
1742 if (!value || !*value) { 1765 if (!value || !*value) {
1743 printk("XFS: %s option requires an argument\n", 1766 printk("XFS: %s option requires an argument\n",
1744 this_char); 1767 this_char);
1745 return EINVAL; 1768 return EINVAL;
1746 } 1769 }
1747 args->flags |= XFSMNT_IHASHSIZE; 1770 args->flags |= XFSMNT_IHASHSIZE;
@@ -1756,7 +1779,7 @@ xfs_parseargs(
1756 args->flags |= XFSMNT_INO64; 1779 args->flags |= XFSMNT_INO64;
1757#if !XFS_BIG_INUMS 1780#if !XFS_BIG_INUMS
1758 printk("XFS: %s option not allowed on this system\n", 1781 printk("XFS: %s option not allowed on this system\n",
1759 MNTOPT_INO64); 1782 this_char);
1760 return EINVAL; 1783 return EINVAL;
1761#endif 1784#endif
1762 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) { 1785 } else if (!strcmp(this_char, MNTOPT_NOALIGN)) {
@@ -1766,14 +1789,14 @@ xfs_parseargs(
1766 } else if (!strcmp(this_char, MNTOPT_SUNIT)) { 1789 } else if (!strcmp(this_char, MNTOPT_SUNIT)) {
1767 if (!value || !*value) { 1790 if (!value || !*value) {
1768 printk("XFS: %s option requires an argument\n", 1791 printk("XFS: %s option requires an argument\n",
1769 MNTOPT_SUNIT); 1792 this_char);
1770 return EINVAL; 1793 return EINVAL;
1771 } 1794 }
1772 dsunit = simple_strtoul(value, &eov, 10); 1795 dsunit = simple_strtoul(value, &eov, 10);
1773 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) { 1796 } else if (!strcmp(this_char, MNTOPT_SWIDTH)) {
1774 if (!value || !*value) { 1797 if (!value || !*value) {
1775 printk("XFS: %s option requires an argument\n", 1798 printk("XFS: %s option requires an argument\n",
1776 MNTOPT_SWIDTH); 1799 this_char);
1777 return EINVAL; 1800 return EINVAL;
1778 } 1801 }
1779 dswidth = simple_strtoul(value, &eov, 10); 1802 dswidth = simple_strtoul(value, &eov, 10);
@@ -1781,7 +1804,7 @@ xfs_parseargs(
1781 args->flags &= ~XFSMNT_32BITINODES; 1804 args->flags &= ~XFSMNT_32BITINODES;
1782#if !XFS_BIG_INUMS 1805#if !XFS_BIG_INUMS
1783 printk("XFS: %s option not allowed on this system\n", 1806 printk("XFS: %s option not allowed on this system\n",
1784 MNTOPT_64BITINODE); 1807 this_char);
1785 return EINVAL; 1808 return EINVAL;
1786#endif 1809#endif
1787 } else if (!strcmp(this_char, MNTOPT_NOUUID)) { 1810 } else if (!strcmp(this_char, MNTOPT_NOUUID)) {
@@ -1877,7 +1900,7 @@ xfs_showargs(
1877 seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize); 1900 seq_printf(m, "," MNTOPT_IHASHSIZE "=%d", mp->m_ihsize);
1878 1901
1879 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) 1902 if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
1880 seq_printf(m, "," MNTOPT_BIOSIZE "=%d", mp->m_writeio_log); 1903 seq_printf(m, "," MNTOPT_ALLOCSIZE "=%d", 1<<mp->m_writeio_log);
1881 1904
1882 if (mp->m_logbufs > 0) 1905 if (mp->m_logbufs > 0)
1883 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs); 1906 seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 70092963ca9e..25a526629b12 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -305,7 +305,7 @@ xfs_setattr(
305 int mandlock_before, mandlock_after; 305 int mandlock_before, mandlock_after;
306 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; 306 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
307 int file_owner; 307 int file_owner;
308 int need_iolock = (flags & ATTR_DMI) == 0; 308 int need_iolock = 1;
309 309
310 vp = BHV_TO_VNODE(bdp); 310 vp = BHV_TO_VNODE(bdp);
311 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); 311 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
@@ -384,6 +384,9 @@ xfs_setattr(
384 */ 384 */
385 tp = NULL; 385 tp = NULL;
386 lock_flags = XFS_ILOCK_EXCL; 386 lock_flags = XFS_ILOCK_EXCL;
387 ASSERT(flags & ATTR_NOLOCK ? flags & ATTR_DMI : 1);
388 if (flags & ATTR_NOLOCK)
389 need_iolock = 0;
387 if (!(mask & XFS_AT_SIZE)) { 390 if (!(mask & XFS_AT_SIZE)) {
388 if ((mask != (XFS_AT_CTIME|XFS_AT_ATIME|XFS_AT_MTIME)) || 391 if ((mask != (XFS_AT_CTIME|XFS_AT_ATIME|XFS_AT_MTIME)) ||
389 (mp->m_flags & XFS_MOUNT_WSYNC)) { 392 (mp->m_flags & XFS_MOUNT_WSYNC)) {
@@ -4320,7 +4323,7 @@ xfs_free_file_space(
4320 int rt; 4323 int rt;
4321 xfs_fileoff_t startoffset_fsb; 4324 xfs_fileoff_t startoffset_fsb;
4322 xfs_trans_t *tp; 4325 xfs_trans_t *tp;
4323 int need_iolock = (attr_flags & ATTR_DMI) == 0; 4326 int need_iolock = 1;
4324 4327
4325 vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address); 4328 vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
4326 mp = ip->i_mount; 4329 mp = ip->i_mount;
@@ -4348,8 +4351,12 @@ xfs_free_file_space(
4348 return(error); 4351 return(error);
4349 } 4352 }
4350 4353
4354 ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1);
4355 if (attr_flags & ATTR_NOLOCK)
4356 need_iolock = 0;
4351 if (need_iolock) 4357 if (need_iolock)
4352 xfs_ilock(ip, XFS_IOLOCK_EXCL); 4358 xfs_ilock(ip, XFS_IOLOCK_EXCL);
4359
4353 rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog), 4360 rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog),
4354 (__uint8_t)NBPP); 4361 (__uint8_t)NBPP);
4355 ilen = len + (offset & (rounding - 1)); 4362 ilen = len + (offset & (rounding - 1));
diff --git a/include/asm-alpha/bug.h b/include/asm-alpha/bug.h
index ae1e0a5fa492..39a3e2a5017d 100644
--- a/include/asm-alpha/bug.h
+++ b/include/asm-alpha/bug.h
@@ -1,6 +1,7 @@
1#ifndef _ALPHA_BUG_H 1#ifndef _ALPHA_BUG_H
2#define _ALPHA_BUG_H 2#define _ALPHA_BUG_H
3 3
4#ifdef CONFIG_BUG
4#include <asm/pal.h> 5#include <asm/pal.h>
5 6
6/* ??? Would be nice to use .gprel32 here, but we can't be sure that the 7/* ??? Would be nice to use .gprel32 here, but we can't be sure that the
@@ -10,6 +11,8 @@
10 : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) 11 : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__))
11 12
12#define HAVE_ARCH_BUG 13#define HAVE_ARCH_BUG
14#endif
15
13#include <asm-generic/bug.h> 16#include <asm-generic/bug.h>
14 17
15#endif 18#endif
diff --git a/include/asm-alpha/errno.h b/include/asm-alpha/errno.h
index c85ab6b9d6c6..69e2655249d2 100644
--- a/include/asm-alpha/errno.h
+++ b/include/asm-alpha/errno.h
@@ -116,4 +116,8 @@
116#define EKEYREVOKED 134 /* Key has been revoked */ 116#define EKEYREVOKED 134 /* Key has been revoked */
117#define EKEYREJECTED 135 /* Key was rejected by service */ 117#define EKEYREJECTED 135 /* Key was rejected by service */
118 118
119/* for robust mutexes */
120#define EOWNERDEAD 136 /* Owner died */
121#define ENOTRECOVERABLE 137 /* State not recoverable */
122
119#endif 123#endif
diff --git a/include/asm-alpha/siginfo.h b/include/asm-alpha/siginfo.h
index 86bcab59c52b..9822362a8424 100644
--- a/include/asm-alpha/siginfo.h
+++ b/include/asm-alpha/siginfo.h
@@ -4,8 +4,6 @@
4#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) 4#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
5#define __ARCH_SI_TRAPNO 5#define __ARCH_SI_TRAPNO
6 6
7#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
8
9#include <asm-generic/siginfo.h> 7#include <asm-generic/siginfo.h>
10 8
11#endif 9#endif
diff --git a/include/asm-alpha/signal.h b/include/asm-alpha/signal.h
index 25f98bc5576f..1a2c52a056fb 100644
--- a/include/asm-alpha/signal.h
+++ b/include/asm-alpha/signal.h
@@ -109,34 +109,11 @@ typedef unsigned long sigset_t;
109#define MINSIGSTKSZ 4096 109#define MINSIGSTKSZ 4096
110#define SIGSTKSZ 16384 110#define SIGSTKSZ 16384
111 111
112
113#ifdef __KERNEL__
114/*
115 * These values of sa_flags are used only by the kernel as part of the
116 * irq handling routines.
117 *
118 * SA_INTERRUPT is also used by the irq handling routines.
119 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
120 */
121#define SA_PROBE SA_ONESHOT
122#define SA_SAMPLE_RANDOM SA_RESTART
123#define SA_SHIRQ 0x40000000
124#endif
125
126#define SIG_BLOCK 1 /* for blocking signals */ 112#define SIG_BLOCK 1 /* for blocking signals */
127#define SIG_UNBLOCK 2 /* for unblocking signals */ 113#define SIG_UNBLOCK 2 /* for unblocking signals */
128#define SIG_SETMASK 3 /* for setting the signal mask */ 114#define SIG_SETMASK 3 /* for setting the signal mask */
129 115
130/* Type of a signal handler. */ 116#include <asm-generic/signal.h>
131typedef void __signalfn_t(int);
132typedef __signalfn_t __user *__sighandler_t;
133
134typedef void __restorefn_t(void);
135typedef __restorefn_t __user *__sigrestore_t;
136
137#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
138#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
139#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
140 117
141#ifdef __KERNEL__ 118#ifdef __KERNEL__
142struct osf_sigaction { 119struct osf_sigaction {
diff --git a/include/asm-arm/arch-cl7500/vmalloc.h b/include/asm-arm/arch-cl7500/vmalloc.h
index 91883def4889..ba8d7a84456a 100644
--- a/include/asm-arm/arch-cl7500/vmalloc.h
+++ b/include/asm-arm/arch-cl7500/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-cl7500/vmalloc.h 2 * linux/include/asm-arm/arch-cl7500/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (PAGE_OFFSET + 0x1c000000) 4#define VMALLOC_END (PAGE_OFFSET + 0x1c000000)
diff --git a/include/asm-arm/arch-clps711x/vmalloc.h b/include/asm-arm/arch-clps711x/vmalloc.h
index 42571ed5e493..a5dfe96abc96 100644
--- a/include/asm-arm/arch-clps711x/vmalloc.h
+++ b/include/asm-arm/arch-clps711x/vmalloc.h
@@ -17,15 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-ebsa110/vmalloc.h b/include/asm-arm/arch-ebsa110/vmalloc.h
index 759659be109f..26674ba4683c 100644
--- a/include/asm-arm/arch-ebsa110/vmalloc.h
+++ b/include/asm-arm/arch-ebsa110/vmalloc.h
@@ -7,15 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after the
14 * physical memory until the kernel virtual memory starts. That means that
15 * any out-of-bounds memory accesses will hopefully be caught.
16 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
17 * area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21#define VMALLOC_END (PAGE_OFFSET + 0x1f000000) 10#define VMALLOC_END (PAGE_OFFSET + 0x1f000000)
diff --git a/include/asm-arm/arch-ebsa285/vmalloc.h b/include/asm-arm/arch-ebsa285/vmalloc.h
index def705a3c209..d1ca955ce434 100644
--- a/include/asm-arm/arch-ebsa285/vmalloc.h
+++ b/include/asm-arm/arch-ebsa285/vmalloc.h
@@ -8,17 +8,6 @@
8 8
9#include <linux/config.h> 9#include <linux/config.h>
10 10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after the
14 * physical memory until the kernel virtual memory starts. That means that
15 * any out-of-bounds memory accesses will hopefully be caught.
16 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
17 * area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21
22#ifdef CONFIG_ARCH_FOOTBRIDGE 11#ifdef CONFIG_ARCH_FOOTBRIDGE
23#define VMALLOC_END (PAGE_OFFSET + 0x30000000) 12#define VMALLOC_END (PAGE_OFFSET + 0x30000000)
24#else 13#else
diff --git a/include/asm-arm/arch-epxa10db/vmalloc.h b/include/asm-arm/arch-epxa10db/vmalloc.h
index d31ef8584760..546fb7d2b6ad 100644
--- a/include/asm-arm/arch-epxa10db/vmalloc.h
+++ b/include/asm-arm/arch-epxa10db/vmalloc.h
@@ -17,15 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-h720x/vmalloc.h b/include/asm-arm/arch-h720x/vmalloc.h
index 4af523a5e189..b4693cb821ef 100644
--- a/include/asm-arm/arch-h720x/vmalloc.h
+++ b/include/asm-arm/arch-h720x/vmalloc.h
@@ -5,17 +5,6 @@
5#ifndef __ARCH_ARM_VMALLOC_H 5#ifndef __ARCH_ARM_VMALLOC_H
6#define __ARCH_ARM_VMALLOC_H 6#define __ARCH_ARM_VMALLOC_H
7 7
8/*
9 * Just any arbitrary offset to the start of the vmalloc VM area: the
10 * current 8MB value just means that there will be a 8MB "hole" after the
11 * physical memory until the kernel virtual memory starts. That means that
12 * any out-of-bounds memory accesses will hopefully be caught.
13 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
14 * area for the same reason. ;)
15 */
16#define VMALLOC_OFFSET (8*1024*1024)
17#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
18#define VMALLOC_VMADDR(x) ((unsigned long)(x))
19#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 8#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
20 9
21#endif 10#endif
diff --git a/include/asm-arm/arch-imx/imxfb.h b/include/asm-arm/arch-imx/imxfb.h
new file mode 100644
index 000000000000..2346d454ab9c
--- /dev/null
+++ b/include/asm-arm/arch-imx/imxfb.h
@@ -0,0 +1,35 @@
1/*
2 * This structure describes the machine which we are running on.
3 */
4struct imxfb_mach_info {
5 u_long pixclock;
6
7 u_short xres;
8 u_short yres;
9
10 u_char bpp;
11 u_char hsync_len;
12 u_char left_margin;
13 u_char right_margin;
14
15 u_char vsync_len;
16 u_char upper_margin;
17 u_char lower_margin;
18 u_char sync;
19
20 u_int cmap_greyscale:1,
21 cmap_inverse:1,
22 cmap_static:1,
23 unused:29;
24
25 u_int pcr;
26 u_int pwmr;
27 u_int lscr1;
28
29 u_char * fixed_screen_cpu;
30 dma_addr_t fixed_screen_dma;
31
32 void (*lcd_power)(int);
33 void (*backlight_power)(int);
34};
35void set_imx_fb_info(struct imxfb_mach_info *hard_imx_fb_info);
diff --git a/include/asm-arm/arch-imx/vmalloc.h b/include/asm-arm/arch-imx/vmalloc.h
index 252038f48163..cb6169127068 100644
--- a/include/asm-arm/arch-imx/vmalloc.h
+++ b/include/asm-arm/arch-imx/vmalloc.h
@@ -17,16 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_VMADDR(x) ((unsigned long)(x))
32#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-integrator/cm.h b/include/asm-arm/arch-integrator/cm.h
index d31c1a71f781..1ab353e23595 100644
--- a/include/asm-arm/arch-integrator/cm.h
+++ b/include/asm-arm/arch-integrator/cm.h
@@ -24,9 +24,9 @@ void cm_control(u32, u32);
24#define CM_CTRL_LCDBIASDN (1 << 10) 24#define CM_CTRL_LCDBIASDN (1 << 10)
25#define CM_CTRL_LCDMUXSEL_MASK (7 << 11) 25#define CM_CTRL_LCDMUXSEL_MASK (7 << 11)
26#define CM_CTRL_LCDMUXSEL_GENLCD (1 << 11) 26#define CM_CTRL_LCDMUXSEL_GENLCD (1 << 11)
27#define CM_CTRL_LCDMUXSEL_SHARPLCD1 (3 << 11) 27#define CM_CTRL_LCDMUXSEL_VGA_16BPP (2 << 11)
28#define CM_CTRL_LCDMUXSEL_SHARPLCD2 (4 << 11) 28#define CM_CTRL_LCDMUXSEL_SHARPLCD (3 << 11)
29#define CM_CTRL_LCDMUXSEL_VGA (7 << 11) 29#define CM_CTRL_LCDMUXSEL_VGA_8421BPP (4 << 11)
30#define CM_CTRL_LCDEN0 (1 << 14) 30#define CM_CTRL_LCDEN0 (1 << 14)
31#define CM_CTRL_LCDEN1 (1 << 15) 31#define CM_CTRL_LCDEN1 (1 << 15)
32#define CM_CTRL_STATIC1 (1 << 16) 32#define CM_CTRL_STATIC1 (1 << 16)
diff --git a/include/asm-arm/arch-integrator/platform.h b/include/asm-arm/arch-integrator/platform.h
index 6b67e41669f4..bd364f5a99bc 100644
--- a/include/asm-arm/arch-integrator/platform.h
+++ b/include/asm-arm/arch-integrator/platform.h
@@ -20,14 +20,14 @@
20 * * Copyright © ARM Limited 1998. All rights reserved. 20 * * Copyright © ARM Limited 1998. All rights reserved.
21 * ***********************************************************************/ 21 * ***********************************************************************/
22/* ************************************************************************ 22/* ************************************************************************
23 * 23 *
24 * Integrator address map 24 * Integrator address map
25 * 25 *
26 * NOTE: This is a multi-hosted header file for use with uHAL and 26 * NOTE: This is a multi-hosted header file for use with uHAL and
27 * supported debuggers. 27 * supported debuggers.
28 * 28 *
29 * $Id: platform.s,v 1.32 2000/02/18 10:51:39 asims Exp $ 29 * $Id: platform.s,v 1.32 2000/02/18 10:51:39 asims Exp $
30 * 30 *
31 * ***********************************************************************/ 31 * ***********************************************************************/
32 32
33#ifndef __address_h 33#ifndef __address_h
@@ -40,22 +40,22 @@
40 * Memory definitions 40 * Memory definitions
41 * ------------------------------------------------------------------------ 41 * ------------------------------------------------------------------------
42 * Integrator memory map 42 * Integrator memory map
43 * 43 *
44 */ 44 */
45#define INTEGRATOR_BOOT_ROM_LO 0x00000000 45#define INTEGRATOR_BOOT_ROM_LO 0x00000000
46#define INTEGRATOR_BOOT_ROM_HI 0x20000000 46#define INTEGRATOR_BOOT_ROM_HI 0x20000000
47#define INTEGRATOR_BOOT_ROM_BASE INTEGRATOR_BOOT_ROM_HI /* Normal position */ 47#define INTEGRATOR_BOOT_ROM_BASE INTEGRATOR_BOOT_ROM_HI /* Normal position */
48#define INTEGRATOR_BOOT_ROM_SIZE SZ_512K 48#define INTEGRATOR_BOOT_ROM_SIZE SZ_512K
49 49
50/* 50/*
51 * New Core Modules have different amounts of SSRAM, the amount of SSRAM 51 * New Core Modules have different amounts of SSRAM, the amount of SSRAM
52 * fitted can be found in HDR_STAT. 52 * fitted can be found in HDR_STAT.
53 * 53 *
54 * The symbol INTEGRATOR_SSRAM_SIZE is kept, however this now refers to 54 * The symbol INTEGRATOR_SSRAM_SIZE is kept, however this now refers to
55 * the minimum amount of SSRAM fitted on any core module. 55 * the minimum amount of SSRAM fitted on any core module.
56 * 56 *
57 * New Core Modules also alias the SSRAM. 57 * New Core Modules also alias the SSRAM.
58 * 58 *
59 */ 59 */
60#define INTEGRATOR_SSRAM_BASE 0x00000000 60#define INTEGRATOR_SSRAM_BASE 0x00000000
61#define INTEGRATOR_SSRAM_ALIAS_BASE 0x10800000 61#define INTEGRATOR_SSRAM_ALIAS_BASE 0x10800000
@@ -67,9 +67,9 @@
67#define INTEGRATOR_MBRD_SSRAM_BASE 0x28000000 67#define INTEGRATOR_MBRD_SSRAM_BASE 0x28000000
68#define INTEGRATOR_MBRD_SSRAM_SIZE SZ_512K 68#define INTEGRATOR_MBRD_SSRAM_SIZE SZ_512K
69 69
70/* 70/*
71 * SDRAM is a SIMM therefore the size is not known. 71 * SDRAM is a SIMM therefore the size is not known.
72 * 72 *
73 */ 73 */
74#define INTEGRATOR_SDRAM_BASE 0x00040000 74#define INTEGRATOR_SDRAM_BASE 0x00040000
75 75
@@ -79,9 +79,9 @@
79#define INTEGRATOR_HDR2_SDRAM_BASE 0xA0000000 79#define INTEGRATOR_HDR2_SDRAM_BASE 0xA0000000
80#define INTEGRATOR_HDR3_SDRAM_BASE 0xB0000000 80#define INTEGRATOR_HDR3_SDRAM_BASE 0xB0000000
81 81
82/* 82/*
83 * Logic expansion modules 83 * Logic expansion modules
84 * 84 *
85 */ 85 */
86#define INTEGRATOR_LOGIC_MODULES_BASE 0xC0000000 86#define INTEGRATOR_LOGIC_MODULES_BASE 0xC0000000
87#define INTEGRATOR_LOGIC_MODULE0_BASE 0xC0000000 87#define INTEGRATOR_LOGIC_MODULE0_BASE 0xC0000000
@@ -92,7 +92,7 @@
92/* ------------------------------------------------------------------------ 92/* ------------------------------------------------------------------------
93 * Integrator header card registers 93 * Integrator header card registers
94 * ------------------------------------------------------------------------ 94 * ------------------------------------------------------------------------
95 * 95 *
96 */ 96 */
97#define INTEGRATOR_HDR_ID_OFFSET 0x00 97#define INTEGRATOR_HDR_ID_OFFSET 0x00
98#define INTEGRATOR_HDR_PROC_OFFSET 0x04 98#define INTEGRATOR_HDR_PROC_OFFSET 0x04
@@ -185,12 +185,12 @@
185/* ------------------------------------------------------------------------ 185/* ------------------------------------------------------------------------
186 * Integrator system registers 186 * Integrator system registers
187 * ------------------------------------------------------------------------ 187 * ------------------------------------------------------------------------
188 * 188 *
189 */ 189 */
190 190
191/* 191/*
192 * System Controller 192 * System Controller
193 * 193 *
194 */ 194 */
195#define INTEGRATOR_SC_ID_OFFSET 0x00 195#define INTEGRATOR_SC_ID_OFFSET 0x00
196#define INTEGRATOR_SC_OSC_OFFSET 0x04 196#define INTEGRATOR_SC_OSC_OFFSET 0x04
@@ -230,11 +230,11 @@
230#define INTEGRATOR_SC_CTRL_URTS1 (1 << 6) 230#define INTEGRATOR_SC_CTRL_URTS1 (1 << 6)
231#define INTEGRATOR_SC_CTRL_UDTR1 (1 << 7) 231#define INTEGRATOR_SC_CTRL_UDTR1 (1 << 7)
232 232
233/* 233/*
234 * External Bus Interface 234 * External Bus Interface
235 * 235 *
236 */ 236 */
237#define INTEGRATOR_EBI_BASE 0x12000000 237#define INTEGRATOR_EBI_BASE 0x12000000
238 238
239#define INTEGRATOR_EBI_CSR0_OFFSET 0x00 239#define INTEGRATOR_EBI_CSR0_OFFSET 0x00
240#define INTEGRATOR_EBI_CSR1_OFFSET 0x04 240#define INTEGRATOR_EBI_CSR1_OFFSET 0x04
@@ -279,9 +279,9 @@
279#define INTEGRATOR_KBD_BASE 0x18000000 /* Keyboard */ 279#define INTEGRATOR_KBD_BASE 0x18000000 /* Keyboard */
280#define INTEGRATOR_MOUSE_BASE 0x19000000 /* Mouse */ 280#define INTEGRATOR_MOUSE_BASE 0x19000000 /* Mouse */
281 281
282/* 282/*
283 * LED's & Switches 283 * LED's & Switches
284 * 284 *
285 */ 285 */
286#define INTEGRATOR_DBG_ALPHA_OFFSET 0x00 286#define INTEGRATOR_DBG_ALPHA_OFFSET 0x00
287#define INTEGRATOR_DBG_LEDS_OFFSET 0x04 287#define INTEGRATOR_DBG_LEDS_OFFSET 0x04
@@ -300,7 +300,7 @@
300 * ------------------------------------------------------------------------ 300 * ------------------------------------------------------------------------
301 */ 301 */
302/* PS2 Keyboard interface */ 302/* PS2 Keyboard interface */
303#define KMI0_BASE INTEGRATOR_KBD_BASE 303#define KMI0_BASE INTEGRATOR_KBD_BASE
304 304
305/* PS2 Mouse interface */ 305/* PS2 Mouse interface */
306#define KMI1_BASE INTEGRATOR_MOUSE_BASE 306#define KMI1_BASE INTEGRATOR_MOUSE_BASE
@@ -313,7 +313,7 @@
313 * This represents a fairly liberal usage of address space. Even though 313 * This represents a fairly liberal usage of address space. Even though
314 * the V3 only has two windows (therefore we need to map stuff on the fly), 314 * the V3 only has two windows (therefore we need to map stuff on the fly),
315 * we maintain the same addresses, even if they're not mapped. 315 * we maintain the same addresses, even if they're not mapped.
316 * 316 *
317 */ 317 */
318#define PHYS_PCI_MEM_BASE 0x40000000 /* 512M to xxx */ 318#define PHYS_PCI_MEM_BASE 0x40000000 /* 512M to xxx */
319/* unused 256M from A0000000-AFFFFFFF might be used for I2O ??? 319/* unused 256M from A0000000-AFFFFFFF might be used for I2O ???
@@ -326,7 +326,7 @@
326 */ 326 */
327#define PHYS_PCI_V3_BASE 0x62000000 327#define PHYS_PCI_V3_BASE 0x62000000
328 328
329#define PCI_DRAMSIZE INTEGRATOR_SSRAM_SIZE 329#define PCI_DRAMSIZE INTEGRATOR_SSRAM_SIZE
330 330
331/* 'export' these to UHAL */ 331/* 'export' these to UHAL */
332#define UHAL_PCI_IO PCI_IO_BASE 332#define UHAL_PCI_IO PCI_IO_BASE
@@ -334,7 +334,7 @@
334#define UHAL_PCI_ALLOC_IO_BASE 0x00004000 334#define UHAL_PCI_ALLOC_IO_BASE 0x00004000
335#define UHAL_PCI_ALLOC_MEM_BASE PCI_MEM_BASE 335#define UHAL_PCI_ALLOC_MEM_BASE PCI_MEM_BASE
336#define UHAL_PCI_MAX_SLOT 20 336#define UHAL_PCI_MAX_SLOT 20
337 337
338/* ======================================================================== 338/* ========================================================================
339 * Start of uHAL definitions 339 * Start of uHAL definitions
340 * ======================================================================== 340 * ========================================================================
@@ -343,17 +343,17 @@
343/* ------------------------------------------------------------------------ 343/* ------------------------------------------------------------------------
344 * Integrator Interrupt Controllers 344 * Integrator Interrupt Controllers
345 * ------------------------------------------------------------------------ 345 * ------------------------------------------------------------------------
346 * 346 *
347 * Offsets from interrupt controller base 347 * Offsets from interrupt controller base
348 * 348 *
349 * System Controller interrupt controller base is 349 * System Controller interrupt controller base is
350 * 350 *
351 * INTEGRATOR_IC_BASE + (header_number << 6) 351 * INTEGRATOR_IC_BASE + (header_number << 6)
352 * 352 *
353 * Core Module interrupt controller base is 353 * Core Module interrupt controller base is
354 * 354 *
355 * INTEGRATOR_HDR_IC 355 * INTEGRATOR_HDR_IC
356 * 356 *
357 */ 357 */
358#define IRQ_STATUS 0 358#define IRQ_STATUS 0
359#define IRQ_RAW_STATUS 0x04 359#define IRQ_RAW_STATUS 0x04
@@ -374,22 +374,22 @@
374/* ------------------------------------------------------------------------ 374/* ------------------------------------------------------------------------
375 * Interrupts 375 * Interrupts
376 * ------------------------------------------------------------------------ 376 * ------------------------------------------------------------------------
377 * 377 *
378 * 378 *
379 * Each Core Module has two interrupts controllers, one on the core module 379 * Each Core Module has two interrupts controllers, one on the core module
380 * itself and one in the system controller on the motherboard. The 380 * itself and one in the system controller on the motherboard. The
381 * READ_INT macro in target.s reads both interrupt controllers and returns 381 * READ_INT macro in target.s reads both interrupt controllers and returns
382 * a 32 bit bitmask, bits 0 to 23 are interrupts from the system controller 382 * a 32 bit bitmask, bits 0 to 23 are interrupts from the system controller
383 * and bits 24 to 31 are from the core module. 383 * and bits 24 to 31 are from the core module.
384 * 384 *
385 * The following definitions relate to the bitmask returned by READ_INT. 385 * The following definitions relate to the bitmask returned by READ_INT.
386 * 386 *
387 */ 387 */
388 388
389/* ------------------------------------------------------------------------ 389/* ------------------------------------------------------------------------
390 * LED's - The header LED is not accessible via the uHAL API 390 * LED's - The header LED is not accessible via the uHAL API
391 * ------------------------------------------------------------------------ 391 * ------------------------------------------------------------------------
392 * 392 *
393 */ 393 */
394#define GREEN_LED 0x01 394#define GREEN_LED 0x01
395#define YELLOW_LED 0x02 395#define YELLOW_LED 0x02
@@ -399,44 +399,44 @@
399 399
400#define LED_BANK INTEGRATOR_DBG_LEDS 400#define LED_BANK INTEGRATOR_DBG_LEDS
401 401
402/* 402/*
403 * Memory definitions - run uHAL out of SSRAM. 403 * Memory definitions - run uHAL out of SSRAM.
404 * 404 *
405 */ 405 */
406#define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE 406#define uHAL_MEMORY_SIZE INTEGRATOR_SSRAM_SIZE
407 407
408/* 408/*
409 * Application Flash 409 * Application Flash
410 * 410 *
411 */ 411 */
412#define FLASH_BASE INTEGRATOR_FLASH_BASE 412#define FLASH_BASE INTEGRATOR_FLASH_BASE
413#define FLASH_SIZE INTEGRATOR_FLASH_SIZE 413#define FLASH_SIZE INTEGRATOR_FLASH_SIZE
414#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1) 414#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1)
415#define FLASH_BLOCK_SIZE SZ_128K 415#define FLASH_BLOCK_SIZE SZ_128K
416 416
417/* 417/*
418 * Boot Flash 418 * Boot Flash
419 * 419 *
420 */ 420 */
421#define EPROM_BASE INTEGRATOR_BOOT_ROM_HI 421#define EPROM_BASE INTEGRATOR_BOOT_ROM_HI
422#define EPROM_SIZE INTEGRATOR_BOOT_ROM_SIZE 422#define EPROM_SIZE INTEGRATOR_BOOT_ROM_SIZE
423#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1) 423#define EPROM_END (EPROM_BASE + EPROM_SIZE - 1)
424 424
425/* 425/*
426 * Clean base - dummy 426 * Clean base - dummy
427 * 427 *
428 */ 428 */
429#define CLEAN_BASE EPROM_BASE 429#define CLEAN_BASE EPROM_BASE
430 430
431/* 431/*
432 * Timer definitions 432 * Timer definitions
433 * 433 *
434 * Only use timer 1 & 2 434 * Only use timer 1 & 2
435 * (both run at 24MHz and will need the clock divider set to 16). 435 * (both run at 24MHz and will need the clock divider set to 16).
436 * 436 *
437 * Timer 0 runs at bus frequency and therefore could vary and currently 437 * Timer 0 runs at bus frequency and therefore could vary and currently
438 * uHAL can't handle that. 438 * uHAL can't handle that.
439 * 439 *
440 */ 440 */
441 441
442#define INTEGRATOR_TIMER0_BASE INTEGRATOR_CT_BASE 442#define INTEGRATOR_TIMER0_BASE INTEGRATOR_CT_BASE
@@ -447,9 +447,9 @@
447#define MAX_PERIOD 699050 447#define MAX_PERIOD 699050
448#define TICKS_PER_uSEC 24 448#define TICKS_PER_uSEC 24
449 449
450/* 450/*
451 * These are useconds NOT ticks. 451 * These are useconds NOT ticks.
452 * 452 *
453 */ 453 */
454#define mSEC_1 1000 454#define mSEC_1 1000
455#define mSEC_5 (mSEC_1 * 5) 455#define mSEC_5 (mSEC_1 * 5)
diff --git a/include/asm-arm/arch-integrator/vmalloc.h b/include/asm-arm/arch-integrator/vmalloc.h
index 50e9aee79486..170cccece523 100644
--- a/include/asm-arm/arch-integrator/vmalloc.h
+++ b/include/asm-arm/arch-integrator/vmalloc.h
@@ -17,15 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-iop3xx/vmalloc.h b/include/asm-arm/arch-iop3xx/vmalloc.h
index dc1d2a957164..0f2f6847f93c 100644
--- a/include/asm-arm/arch-iop3xx/vmalloc.h
+++ b/include/asm-arm/arch-iop3xx/vmalloc.h
@@ -10,9 +10,6 @@
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;) 11 * area for the same reason. ;)
12 */ 12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_VMADDR(x) ((unsigned long)(x))
16//#define VMALLOC_END (0xe8000000) 13//#define VMALLOC_END (0xe8000000)
17/* increase usable physical RAM to ~992M per RMK */ 14/* increase usable physical RAM to ~992M per RMK */
18#define VMALLOC_END (0xfe000000) 15#define VMALLOC_END (0xfe000000)
diff --git a/include/asm-arm/arch-ixp2000/platform.h b/include/asm-arm/arch-ixp2000/platform.h
index 509e44d528d8..901bba6d02b4 100644
--- a/include/asm-arm/arch-ixp2000/platform.h
+++ b/include/asm-arm/arch-ixp2000/platform.h
@@ -121,6 +121,7 @@ unsigned long ixp2000_gettimeoffset(void);
121 121
122struct pci_sys_data; 122struct pci_sys_data;
123 123
124u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);
124void ixp2000_pci_preinit(void); 125void ixp2000_pci_preinit(void);
125int ixp2000_pci_setup(int, struct pci_sys_data*); 126int ixp2000_pci_setup(int, struct pci_sys_data*);
126struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*); 127struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
diff --git a/include/asm-arm/arch-ixp2000/vmalloc.h b/include/asm-arm/arch-ixp2000/vmalloc.h
index 2e4bcbcf31f0..473dff4ec561 100644
--- a/include/asm-arm/arch-ixp2000/vmalloc.h
+++ b/include/asm-arm/arch-ixp2000/vmalloc.h
@@ -17,7 +17,4 @@
17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
18 * area for the same reason. ;) 18 * area for the same reason. ;)
19 */ 19 */
20#define VMALLOC_OFFSET (8*1024*1024)
21#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
22#define VMALLOC_VMADDR(x) ((unsigned long)(x))
23#define VMALLOC_END 0xfaffefff 20#define VMALLOC_END 0xfaffefff
diff --git a/include/asm-arm/arch-ixp4xx/vmalloc.h b/include/asm-arm/arch-ixp4xx/vmalloc.h
index da46e560ad6f..050d46e6b126 100644
--- a/include/asm-arm/arch-ixp4xx/vmalloc.h
+++ b/include/asm-arm/arch-ixp4xx/vmalloc.h
@@ -1,17 +1,5 @@
1/* 1/*
2 * linux/include/asm-arm/arch-ixp4xx/vmalloc.h 2 * linux/include/asm-arm/arch-ixp4xx/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_VMADDR(x) ((unsigned long)(x))
16#define VMALLOC_END (0xFF000000) 4#define VMALLOC_END (0xFF000000)
17 5
diff --git a/include/asm-arm/arch-l7200/vmalloc.h b/include/asm-arm/arch-l7200/vmalloc.h
index edeaebe1f14a..816231eedaac 100644
--- a/include/asm-arm/arch-l7200/vmalloc.h
+++ b/include/asm-arm/arch-l7200/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-l7200/vmalloc.h 2 * linux/include/asm-arm/arch-l7200/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 4#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-lh7a40x/vmalloc.h b/include/asm-arm/arch-lh7a40x/vmalloc.h
index 5ac607925bea..8163e45109b9 100644
--- a/include/asm-arm/arch-lh7a40x/vmalloc.h
+++ b/include/asm-arm/arch-lh7a40x/vmalloc.h
@@ -7,15 +7,4 @@
7 * version 2 as published by the Free Software Foundation. 7 * version 2 as published by the Free Software Foundation.
8 * 8 *
9 */ 9 */
10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after
14 * the physical memory until the kernel virtual memory starts. That
15 * means that any out-of-bounds memory accesses will hopefully be
16 * caught. The vmalloc() routines leaves a hole of 4kB (one page)
17 * between each vmalloced area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21#define VMALLOC_END (0xe8000000) 10#define VMALLOC_END (0xe8000000)
diff --git a/include/asm-arm/arch-omap/vmalloc.h b/include/asm-arm/arch-omap/vmalloc.h
index c6a83581a2fc..5b8bd8dae8be 100644
--- a/include/asm-arm/arch-omap/vmalloc.h
+++ b/include/asm-arm/arch-omap/vmalloc.h
@@ -17,17 +17,5 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21/*
22 * Just any arbitrary offset to the start of the vmalloc VM area: the
23 * current 8MB value just means that there will be a 8MB "hole" after the
24 * physical memory until the kernel virtual memory starts. That means that
25 * any out-of-bounds memory accesses will hopefully be caught.
26 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
27 * area for the same reason. ;)
28 */
29#define VMALLOC_OFFSET (8*1024*1024)
30#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
31#define VMALLOC_VMADDR(x) ((unsigned long)(x))
32#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
33 21
diff --git a/include/asm-arm/arch-pxa/vmalloc.h b/include/asm-arm/arch-pxa/vmalloc.h
index 3381af6ddb0d..5bb450c7aa2c 100644
--- a/include/asm-arm/arch-pxa/vmalloc.h
+++ b/include/asm-arm/arch-pxa/vmalloc.h
@@ -8,15 +8,4 @@
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11
12/*
13 * Just any arbitrary offset to the start of the vmalloc VM area: the
14 * current 8MB value just means that there will be a 8MB "hole" after the
15 * physical memory until the kernel virtual memory starts. That means that
16 * any out-of-bounds memory accesses will hopefully be caught.
17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
18 * area for the same reason. ;)
19 */
20#define VMALLOC_OFFSET (8*1024*1024)
21#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
22#define VMALLOC_END (0xe8000000) 11#define VMALLOC_END (0xe8000000)
diff --git a/include/asm-arm/arch-rpc/vmalloc.h b/include/asm-arm/arch-rpc/vmalloc.h
index a13c27f37d71..077046bb2f36 100644
--- a/include/asm-arm/arch-rpc/vmalloc.h
+++ b/include/asm-arm/arch-rpc/vmalloc.h
@@ -7,15 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10
11/*
12 * Just any arbitrary offset to the start of the vmalloc VM area: the
13 * current 8MB value just means that there will be a 8MB "hole" after the
14 * physical memory until the kernel virtual memory starts. That means that
15 * any out-of-bounds memory accesses will hopefully be caught.
16 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
17 * area for the same reason. ;)
18 */
19#define VMALLOC_OFFSET (8*1024*1024)
20#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
21#define VMALLOC_END (PAGE_OFFSET + 0x1c000000) 10#define VMALLOC_END (PAGE_OFFSET + 0x1c000000)
diff --git a/include/asm-arm/arch-s3c2410/regs-iis.h b/include/asm-arm/arch-s3c2410/regs-iis.h
index 7ae8e1f45bc1..385b07d510da 100644
--- a/include/asm-arm/arch-s3c2410/regs-iis.h
+++ b/include/asm-arm/arch-s3c2410/regs-iis.h
@@ -14,6 +14,7 @@
14 * 26-06-2003 BJD Finished off definitions for register addresses 14 * 26-06-2003 BJD Finished off definitions for register addresses
15 * 12-03-2004 BJD Updated include protection 15 * 12-03-2004 BJD Updated include protection
16 * 07-03-2005 BJD Added FIFO size flags and S3C2440 MPLL 16 * 07-03-2005 BJD Added FIFO size flags and S3C2440 MPLL
17 * 05-04-2005 LCVR Added IISFCON definitions for the S3C2400
17 */ 18 */
18 19
19#ifndef __ASM_ARCH_REGS_IIS_H 20#ifndef __ASM_ARCH_REGS_IIS_H
@@ -68,5 +69,14 @@
68#define S3C2410_IISFCON_RXMASK (0x3f) 69#define S3C2410_IISFCON_RXMASK (0x3f)
69#define S3C2410_IISFCON_RXSHIFT (0) 70#define S3C2410_IISFCON_RXSHIFT (0)
70 71
72#define S3C2400_IISFCON_TXDMA (1<<11)
73#define S3C2400_IISFCON_RXDMA (1<<10)
74#define S3C2400_IISFCON_TXENABLE (1<<9)
75#define S3C2400_IISFCON_RXENABLE (1<<8)
76#define S3C2400_IISFCON_TXMASK (0x07 << 4)
77#define S3C2400_IISFCON_TXSHIFT (4)
78#define S3C2400_IISFCON_RXMASK (0x07)
79#define S3C2400_IISFCON_RXSHIFT (0)
80
71#define S3C2410_IISFIFO (0x10) 81#define S3C2410_IISFIFO (0x10)
72#endif /* __ASM_ARCH_REGS_IIS_H */ 82#endif /* __ASM_ARCH_REGS_IIS_H */
diff --git a/include/asm-arm/arch-s3c2410/regs-mem.h b/include/asm-arm/arch-s3c2410/regs-mem.h
index 1a1328ac0d79..a2d7d0cec042 100644
--- a/include/asm-arm/arch-s3c2410/regs-mem.h
+++ b/include/asm-arm/arch-s3c2410/regs-mem.h
@@ -12,6 +12,7 @@
12 * Changelog: 12 * Changelog:
13 * 29-Sep-2004 BJD Initial include for Linux 13 * 29-Sep-2004 BJD Initial include for Linux
14 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 14 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
15 * 04-Apr-2005 LCVR Added S3C2400 DRAM/BANKSIZE_MASK definitions
15 * 16 *
16*/ 17*/
17 18
@@ -183,6 +184,12 @@
183#define S3C2410_REFRESH_TRP_3clk (1<<20) 184#define S3C2410_REFRESH_TRP_3clk (1<<20)
184#define S3C2410_REFRESH_TRP_4clk (2<<20) 185#define S3C2410_REFRESH_TRP_4clk (2<<20)
185 186
187#define S3C2400_REFRESH_DRAM_TRP_MASK (3<<20)
188#define S3C2400_REFRESH_DRAM_TRP_1_5clk (0<<20)
189#define S3C2400_REFRESH_DRAM_TRP_2_5clk (1<<20)
190#define S3C2400_REFRESH_DRAM_TRP_3_5clk (2<<20)
191#define S3C2400_REFRESH_DRAM_TRP_4_5clk (3<<20)
192
186#define S3C2410_REFRESH_TSRC_MASK (3<<18) 193#define S3C2410_REFRESH_TSRC_MASK (3<<18)
187#define S3C2410_REFRESH_TSRC_4clk (0<<18) 194#define S3C2410_REFRESH_TSRC_4clk (0<<18)
188#define S3C2410_REFRESH_TSRC_5clk (1<<18) 195#define S3C2410_REFRESH_TSRC_5clk (1<<18)
@@ -205,6 +212,7 @@
205#define S3C2410_BANKSIZE_4M (0x5 << 0) 212#define S3C2410_BANKSIZE_4M (0x5 << 0)
206#define S3C2410_BANKSIZE_2M (0x4 << 0) 213#define S3C2410_BANKSIZE_2M (0x4 << 0)
207#define S3C2410_BANKSIZE_MASK (0x7 << 0) 214#define S3C2410_BANKSIZE_MASK (0x7 << 0)
215#define S3C2400_BANKSIZE_MASK (0x4 << 0)
208#define S3C2410_BANKSIZE_SCLK_EN (1<<4) 216#define S3C2410_BANKSIZE_SCLK_EN (1<<4)
209#define S3C2410_BANKSIZE_SCKE_EN (1<<5) 217#define S3C2410_BANKSIZE_SCKE_EN (1<<5)
210#define S3C2410_BANKSIZE_BURST (1<<7) 218#define S3C2410_BANKSIZE_BURST (1<<7)
diff --git a/include/asm-arm/arch-s3c2410/regs-spi.h b/include/asm-arm/arch-s3c2410/regs-spi.h
index cb502a88158b..338217858c73 100644
--- a/include/asm-arm/arch-s3c2410/regs-spi.h
+++ b/include/asm-arm/arch-s3c2410/regs-spi.h
@@ -12,6 +12,7 @@
12 * 20-04-2004 KF Created file 12 * 20-04-2004 KF Created file
13 * 04-10-2004 BJD Removed VA address (no longer mapped) 13 * 04-10-2004 BJD Removed VA address (no longer mapped)
14 * tidied file for submission 14 * tidied file for submission
15 * 03-04-2005 LCVR Added S3C2400_SPPIN_nCS definition
15 */ 16 */
16 17
17#ifndef __ASM_ARCH_REGS_SPI_H 18#ifndef __ASM_ARCH_REGS_SPI_H
@@ -46,6 +47,7 @@
46 47
47#define S3C2410_SPPIN_ENMUL (1<<2) /* Multi Master Error detect */ 48#define S3C2410_SPPIN_ENMUL (1<<2) /* Multi Master Error detect */
48#define S3C2410_SPPIN_RESERVED (1<<1) 49#define S3C2410_SPPIN_RESERVED (1<<1)
50#define S3C2400_SPPIN_nCS (1<<1) /* SPI Card Select */
49#define S3C2410_SPPIN_KEEP (1<<0) /* Master Out keep */ 51#define S3C2410_SPPIN_KEEP (1<<0) /* Master Out keep */
50 52
51 53
diff --git a/include/asm-arm/arch-s3c2410/uncompress.h b/include/asm-arm/arch-s3c2410/uncompress.h
index ad4252e27799..d7a4a8354fa9 100644
--- a/include/asm-arm/arch-s3c2410/uncompress.h
+++ b/include/asm-arm/arch-s3c2410/uncompress.h
@@ -16,6 +16,7 @@
16 * 12-Oct-2004 BJD Take account of debug uart configuration 16 * 12-Oct-2004 BJD Take account of debug uart configuration
17 * 15-Nov-2004 BJD Fixed uart configuration 17 * 15-Nov-2004 BJD Fixed uart configuration
18 * 22-Feb-2005 BJD Added watchdog to uncompress 18 * 22-Feb-2005 BJD Added watchdog to uncompress
19 * 04-Apr-2005 LCVR Added support to S3C2400 (no cpuid at GSTATUS1)
19*/ 20*/
20 21
21#ifndef __ASM_ARCH_UNCOMPRESS_H 22#ifndef __ASM_ARCH_UNCOMPRESS_H
@@ -69,9 +70,12 @@ uart_rd(unsigned int reg)
69static void 70static void
70putc(char ch) 71putc(char ch)
71{ 72{
72 int cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1); 73 int cpuid = S3C2410_GSTATUS1_2410;
73 74
75#ifndef CONFIG_CPU_S3C2400
76 cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1);
74 cpuid &= S3C2410_GSTATUS1_IDMASK; 77 cpuid &= S3C2410_GSTATUS1_IDMASK;
78#endif
75 79
76 if (ch == '\n') 80 if (ch == '\n')
77 putc('\r'); /* expand newline to \r\n */ 81 putc('\r'); /* expand newline to \r\n */
diff --git a/include/asm-arm/arch-s3c2410/vmalloc.h b/include/asm-arm/arch-s3c2410/vmalloc.h
index 5fe72ad70904..33963cd5461b 100644
--- a/include/asm-arm/arch-s3c2410/vmalloc.h
+++ b/include/asm-arm/arch-s3c2410/vmalloc.h
@@ -19,18 +19,6 @@
19#ifndef __ASM_ARCH_VMALLOC_H 19#ifndef __ASM_ARCH_VMALLOC_H
20#define __ASM_ARCH_VMALLOC_H 20#define __ASM_ARCH_VMALLOC_H
21 21
22/*
23 * Just any arbitrary offset to the start of the vmalloc VM area: the
24 * current 8MB value just means that there will be a 8MB "hole" after the
25 * physical memory until the kernel virtual memory starts. That means that
26 * any out-of-bounds memory accesses will hopefully be caught.
27 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
28 * area for the same reason. ;)
29 */
30
31#define VMALLOC_OFFSET (8*1024*1024)
32#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
33#define VMALLOC_VMADDR(x) ((unsigned long)(x))
34#define VMALLOC_END (0xE0000000) 22#define VMALLOC_END (0xE0000000)
35 23
36#endif /* __ASM_ARCH_VMALLOC_H */ 24#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/include/asm-arm/arch-sa1100/vmalloc.h b/include/asm-arm/arch-sa1100/vmalloc.h
index 135bc9493c06..2fb1c6f3aa1b 100644
--- a/include/asm-arm/arch-sa1100/vmalloc.h
+++ b/include/asm-arm/arch-sa1100/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-sa1100/vmalloc.h 2 * linux/include/asm-arm/arch-sa1100/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (0xe8000000) 4#define VMALLOC_END (0xe8000000)
diff --git a/include/asm-arm/arch-shark/vmalloc.h b/include/asm-arm/arch-shark/vmalloc.h
index 1cc20098f690..10db5d188231 100644
--- a/include/asm-arm/arch-shark/vmalloc.h
+++ b/include/asm-arm/arch-shark/vmalloc.h
@@ -1,15 +1,4 @@
1/* 1/*
2 * linux/include/asm-arm/arch-rpc/vmalloc.h 2 * linux/include/asm-arm/arch-rpc/vmalloc.h
3 */ 3 */
4
5/*
6 * Just any arbitrary offset to the start of the vmalloc VM area: the
7 * current 8MB value just means that there will be a 8MB "hole" after the
8 * physical memory until the kernel virtual memory starts. That means that
9 * any out-of-bounds memory accesses will hopefully be caught.
10 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
11 * area for the same reason. ;)
12 */
13#define VMALLOC_OFFSET (8*1024*1024)
14#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
15#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 4#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
diff --git a/include/asm-arm/arch-versatile/vmalloc.h b/include/asm-arm/arch-versatile/vmalloc.h
index adfb34829bfc..ac780df62156 100644
--- a/include/asm-arm/arch-versatile/vmalloc.h
+++ b/include/asm-arm/arch-versatile/vmalloc.h
@@ -18,16 +18,4 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21
22/*
23 * Just any arbitrary offset to the start of the vmalloc VM area: the
24 * current 8MB value just means that there will be a 8MB "hole" after the
25 * physical memory until the kernel virtual memory starts. That means that
26 * any out-of-bounds memory accesses will hopefully be caught.
27 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
28 * area for the same reason. ;)
29 */
30#define VMALLOC_OFFSET (8*1024*1024)
31#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
32#define VMALLOC_VMADDR(x) ((unsigned long)(x))
33#define VMALLOC_END (PAGE_OFFSET + 0x18000000) 21#define VMALLOC_END (PAGE_OFFSET + 0x18000000)
diff --git a/include/asm-arm/bug.h b/include/asm-arm/bug.h
index 5e91b90a8181..24d11672eb60 100644
--- a/include/asm-arm/bug.h
+++ b/include/asm-arm/bug.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_BUG
6#ifdef CONFIG_DEBUG_BUGVERBOSE 7#ifdef CONFIG_DEBUG_BUGVERBOSE
7extern volatile void __bug(const char *file, int line, void *data); 8extern volatile void __bug(const char *file, int line, void *data);
8 9
@@ -17,6 +18,8 @@ extern volatile void __bug(const char *file, int line, void *data);
17#endif 18#endif
18 19
19#define HAVE_ARCH_BUG 20#define HAVE_ARCH_BUG
21#endif
22
20#include <asm-generic/bug.h> 23#include <asm-generic/bug.h>
21 24
22#endif 25#endif
diff --git a/include/asm-arm/hardware/amba_clcd.h b/include/asm-arm/hardware/amba_clcd.h
index 2149be7c7023..ce4cf5c1c05d 100644
--- a/include/asm-arm/hardware/amba_clcd.h
+++ b/include/asm-arm/hardware/amba_clcd.h
@@ -153,7 +153,7 @@ struct clcd_fb {
153 153
154static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs) 154static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
155{ 155{
156 u32 val; 156 u32 val, cpl;
157 157
158 /* 158 /*
159 * Program the CLCD controller registers and start the CLCD 159 * Program the CLCD controller registers and start the CLCD
@@ -164,7 +164,10 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
164 val |= (fb->fb.var.left_margin - 1) << 24; 164 val |= (fb->fb.var.left_margin - 1) << 24;
165 regs->tim0 = val; 165 regs->tim0 = val;
166 166
167 val = fb->fb.var.yres - 1; 167 val = fb->fb.var.yres;
168 if (fb->panel->cntl & CNTL_LCDDUAL)
169 val /= 2;
170 val -= 1;
168 val |= (fb->fb.var.vsync_len - 1) << 10; 171 val |= (fb->fb.var.vsync_len - 1) << 10;
169 val |= fb->fb.var.lower_margin << 16; 172 val |= fb->fb.var.lower_margin << 16;
170 val |= fb->fb.var.upper_margin << 24; 173 val |= fb->fb.var.upper_margin << 24;
@@ -174,13 +177,17 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
174 val |= fb->fb.var.sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS; 177 val |= fb->fb.var.sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS;
175 val |= fb->fb.var.sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS; 178 val |= fb->fb.var.sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS;
176 179
177 if (fb->panel->cntl & CNTL_LCDTFT) 180 cpl = fb->fb.var.xres_virtual;
178 val |= (fb->fb.var.xres_virtual - 1) << 16; 181 if (fb->panel->cntl & CNTL_LCDTFT) /* TFT */
179 else if (fb->panel->cntl & CNTL_LCDBW) 182 /* / 1 */;
180 printk("what value for CPL for stnmono panels?"); 183 else if (!fb->fb.var.grayscale) /* STN color */
181 else 184 cpl = cpl * 8 / 3;
182 val |= ((fb->fb.var.xres_virtual * 8 / 3) - 1) << 16; 185 else if (fb->panel->cntl & CNTL_LCDMONO8) /* STN monochrome, 8bit */
183 regs->tim2 = val; 186 cpl /= 8;
187 else /* STN monochrome, 4bit */
188 cpl /= 4;
189
190 regs->tim2 = val | ((cpl - 1) << 16);
184 191
185 regs->tim3 = fb->panel->tim3; 192 regs->tim3 = fb->panel->tim3;
186 193
@@ -204,7 +211,7 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
204 case 16: 211 case 16:
205 val |= CNTL_LCDBPP16; 212 val |= CNTL_LCDBPP16;
206 break; 213 break;
207 case 24: 214 case 32:
208 val |= CNTL_LCDBPP24; 215 val |= CNTL_LCDBPP24;
209 break; 216 break;
210 } 217 }
@@ -215,8 +222,8 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
215 222
216static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) 223static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var)
217{ 224{
218 var->xres_virtual = var->xres = (var->xres + 7) & ~7; 225 var->xres_virtual = var->xres = (var->xres + 15) & ~15;
219 var->yres_virtual = var->yres; 226 var->yres_virtual = var->yres = (var->yres + 1) & ~1;
220 227
221#define CHECK(e,l,h) (var->e < l || var->e > h) 228#define CHECK(e,l,h) (var->e < l || var->e > h)
222 if (CHECK(right_margin, (5+1), 256) || /* back porch */ 229 if (CHECK(right_margin, (5+1), 256) || /* back porch */
diff --git a/include/asm-arm/hardware/clock.h b/include/asm-arm/hardware/clock.h
index 4983449ff2c7..19da861e523d 100644
--- a/include/asm-arm/hardware/clock.h
+++ b/include/asm-arm/hardware/clock.h
@@ -26,10 +26,13 @@ struct clk;
26/** 26/**
27 * clk_get - lookup and obtain a reference to a clock producer. 27 * clk_get - lookup and obtain a reference to a clock producer.
28 * @dev: device for clock "consumer" 28 * @dev: device for clock "consumer"
29 * @id: device ID 29 * @id: clock comsumer ID
30 * 30 *
31 * Returns a struct clk corresponding to the clock producer, or 31 * Returns a struct clk corresponding to the clock producer, or
32 * valid IS_ERR() condition containing errno. 32 * valid IS_ERR() condition containing errno. The implementation
33 * uses @dev and @id to determine the clock consumer, and thereby
34 * the clock producer. (IOW, @id may be identical strings, but
35 * clk_get may return different clock producers depending on @dev.)
33 */ 36 */
34struct clk *clk_get(struct device *dev, const char *id); 37struct clk *clk_get(struct device *dev, const char *id);
35 38
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 69bc7a3e8160..658ffa384fda 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -99,12 +99,16 @@ extern void __readwrite_bug(const char *fn);
99 */ 99 */
100#ifdef __io 100#ifdef __io
101#define outb(v,p) __raw_writeb(v,__io(p)) 101#define outb(v,p) __raw_writeb(v,__io(p))
102#define outw(v,p) __raw_writew(cpu_to_le16(v),__io(p)) 102#define outw(v,p) __raw_writew((__force __u16) \
103#define outl(v,p) __raw_writel(cpu_to_le32(v),__io(p)) 103 cpu_to_le16(v),__io(p))
104#define outl(v,p) __raw_writel((__force __u32) \
105 cpu_to_le32(v),__io(p))
104 106
105#define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; }) 107#define inb(p) ({ __u8 __v = __raw_readb(__io(p)); __v; })
106#define inw(p) ({ unsigned int __v = le16_to_cpu(__raw_readw(__io(p))); __v; }) 108#define inw(p) ({ __u16 __v = le16_to_cpu((__force __le16) \
107#define inl(p) ({ unsigned int __v = le32_to_cpu(__raw_readl(__io(p))); __v; }) 109 __raw_readw(__io(p))); __v; })
110#define inl(p) ({ __u32 __v = le32_to_cpu((__force __le32) \
111 __raw_readl(__io(p))); __v; })
108 112
109#define outsb(p,d,l) __raw_writesb(__io(p),d,l) 113#define outsb(p,d,l) __raw_writesb(__io(p),d,l)
110#define outsw(p,d,l) __raw_writesw(__io(p),d,l) 114#define outsw(p,d,l) __raw_writesw(__io(p),d,l)
@@ -149,9 +153,11 @@ extern void _memset_io(void __iomem *, int, size_t);
149 * IO port primitives for more information. 153 * IO port primitives for more information.
150 */ 154 */
151#ifdef __mem_pci 155#ifdef __mem_pci
152#define readb(c) ({ unsigned int __v = __raw_readb(__mem_pci(c)); __v; }) 156#define readb(c) ({ __u8 __v = __raw_readb(__mem_pci(c)); __v; })
153#define readw(c) ({ unsigned int __v = le16_to_cpu(__raw_readw(__mem_pci(c))); __v; }) 157#define readw(c) ({ __u16 __v = le16_to_cpu((__force __le16) \
154#define readl(c) ({ unsigned int __v = le32_to_cpu(__raw_readl(__mem_pci(c))); __v; }) 158 __raw_readw(__mem_pci(c))); __v; })
159#define readl(c) ({ __u32 __v = le32_to_cpu((__force __le32) \
160 __raw_readl(__mem_pci(c))); __v; })
155#define readb_relaxed(addr) readb(addr) 161#define readb_relaxed(addr) readb(addr)
156#define readw_relaxed(addr) readw(addr) 162#define readw_relaxed(addr) readw(addr)
157#define readl_relaxed(addr) readl(addr) 163#define readl_relaxed(addr) readl(addr)
@@ -161,8 +167,10 @@ extern void _memset_io(void __iomem *, int, size_t);
161#define readsl(p,d,l) __raw_readsl(__mem_pci(p),d,l) 167#define readsl(p,d,l) __raw_readsl(__mem_pci(p),d,l)
162 168
163#define writeb(v,c) __raw_writeb(v,__mem_pci(c)) 169#define writeb(v,c) __raw_writeb(v,__mem_pci(c))
164#define writew(v,c) __raw_writew(cpu_to_le16(v),__mem_pci(c)) 170#define writew(v,c) __raw_writew((__force __u16) \
165#define writel(v,c) __raw_writel(cpu_to_le32(v),__mem_pci(c)) 171 cpu_to_le16(v),__mem_pci(c))
172#define writel(v,c) __raw_writel((__force __u32) \
173 cpu_to_le32(v),__mem_pci(c))
166 174
167#define writesb(p,d,l) __raw_writesb(__mem_pci(p),d,l) 175#define writesb(p,d,l) __raw_writesb(__mem_pci(p),d,l)
168#define writesw(p,d,l) __raw_writesw(__mem_pci(p),d,l) 176#define writesw(p,d,l) __raw_writesw(__mem_pci(p),d,l)
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index 2df4eacf4fa9..a9892eb42a23 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -17,6 +17,23 @@
17#include <asm/arch/vmalloc.h> 17#include <asm/arch/vmalloc.h>
18 18
19/* 19/*
20 * Just any arbitrary offset to the start of the vmalloc VM area: the
21 * current 8MB value just means that there will be a 8MB "hole" after the
22 * physical memory until the kernel virtual memory starts. That means that
23 * any out-of-bounds memory accesses will hopefully be caught.
24 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
25 * area for the same reason. ;)
26 *
27 * Note that platforms may override VMALLOC_START, but they must provide
28 * VMALLOC_END. VMALLOC_END defines the (exclusive) limit of this space,
29 * which may not overlap IO space.
30 */
31#ifndef VMALLOC_START
32#define VMALLOC_OFFSET (8*1024*1024)
33#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
34#endif
35
36/*
20 * Hardware-wise, we have a two level page table structure, where the first 37 * Hardware-wise, we have a two level page table structure, where the first
21 * level has 4096 entries, and the second level has 256 entries. Each entry 38 * level has 4096 entries, and the second level has 256 entries. Each entry
22 * is one 32-bit word. Most of the bits in the second level entry are used 39 * is one 32-bit word. Most of the bits in the second level entry are used
diff --git a/include/asm-arm/processor.h b/include/asm-arm/processor.h
index 4a9845997a75..7d4118e09054 100644
--- a/include/asm-arm/processor.h
+++ b/include/asm-arm/processor.h
@@ -23,8 +23,6 @@
23#include <asm/procinfo.h> 23#include <asm/procinfo.h>
24#include <asm/types.h> 24#include <asm/types.h>
25 25
26#define KERNEL_STACK_SIZE PAGE_SIZE
27
28union debug_insn { 26union debug_insn {
29 u32 arm; 27 u32 arm;
30 u16 thumb; 28 u16 thumb;
@@ -87,8 +85,9 @@ unsigned long get_wchan(struct task_struct *p);
87 */ 85 */
88extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 86extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
89 87
90#define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1019]) 88#define KSTK_REGS(tsk) (((struct pt_regs *)(THREAD_START_SP + (unsigned long)(tsk)->thread_info)) - 1)
91#define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1017]) 89#define KSTK_EIP(tsk) KSTK_REGS(tsk)->ARM_pc
90#define KSTK_ESP(tsk) KSTK_REGS(tsk)->ARM_sp
92 91
93/* 92/*
94 * Prefetching support - only ARMv5. 93 * Prefetching support - only ARMv5.
diff --git a/include/asm-arm/rtc.h b/include/asm-arm/rtc.h
index aa7e16b2e225..370dfe77589d 100644
--- a/include/asm-arm/rtc.h
+++ b/include/asm-arm/rtc.h
@@ -18,9 +18,9 @@ struct rtc_ops {
18 void (*release)(void); 18 void (*release)(void);
19 int (*ioctl)(unsigned int, unsigned long); 19 int (*ioctl)(unsigned int, unsigned long);
20 20
21 void (*read_time)(struct rtc_time *); 21 int (*read_time)(struct rtc_time *);
22 int (*set_time)(struct rtc_time *); 22 int (*set_time)(struct rtc_time *);
23 void (*read_alarm)(struct rtc_wkalrm *); 23 int (*read_alarm)(struct rtc_wkalrm *);
24 int (*set_alarm)(struct rtc_wkalrm *); 24 int (*set_alarm)(struct rtc_wkalrm *);
25 int (*proc)(char *buf); 25 int (*proc)(char *buf);
26}; 26};
diff --git a/include/asm-arm/signal.h b/include/asm-arm/signal.h
index b033e5fd60fa..46e69ae395af 100644
--- a/include/asm-arm/signal.h
+++ b/include/asm-arm/signal.h
@@ -114,34 +114,10 @@ typedef unsigned long sigset_t;
114#define SIGSTKSZ 8192 114#define SIGSTKSZ 8192
115 115
116#ifdef __KERNEL__ 116#ifdef __KERNEL__
117
118/*
119 * These values of sa_flags are used only by the kernel as part of the
120 * irq handling routines.
121 *
122 * SA_INTERRUPT is also used by the irq handling routines.
123 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
124 */
125#define SA_PROBE 0x80000000
126#define SA_SAMPLE_RANDOM 0x10000000
127#define SA_IRQNOMASK 0x08000000 117#define SA_IRQNOMASK 0x08000000
128#define SA_SHIRQ 0x04000000
129#endif 118#endif
130 119
131#define SIG_BLOCK 0 /* for blocking signals */ 120#include <asm-generic/signal.h>
132#define SIG_UNBLOCK 1 /* for unblocking signals */
133#define SIG_SETMASK 2 /* for setting the signal mask */
134
135/* Type of a signal handler. */
136typedef void __signalfn_t(int);
137typedef __signalfn_t __user *__sighandler_t;
138
139typedef void __restorefn_t(void);
140typedef __restorefn_t __user *__sigrestore_t;
141
142#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
143#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
144#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
145 121
146#ifdef __KERNEL__ 122#ifdef __KERNEL__
147struct old_sigaction { 123struct old_sigaction {
diff --git a/include/asm-arm/string.h b/include/asm-arm/string.h
index 2a8ab162412f..e50c4a39b699 100644
--- a/include/asm-arm/string.h
+++ b/include/asm-arm/string.h
@@ -29,15 +29,22 @@ extern void __memzero(void *ptr, __kernel_size_t n);
29 29
30#define memset(p,v,n) \ 30#define memset(p,v,n) \
31 ({ \ 31 ({ \
32 if ((n) != 0) { \ 32 void *__p = (p); size_t __n = n; \
33 if ((__n) != 0) { \
33 if (__builtin_constant_p((v)) && (v) == 0) \ 34 if (__builtin_constant_p((v)) && (v) == 0) \
34 __memzero((p),(n)); \ 35 __memzero((__p),(__n)); \
35 else \ 36 else \
36 memset((p),(v),(n)); \ 37 memset((__p),(v),(__n)); \
37 } \ 38 } \
38 (p); \ 39 (__p); \
39 }) 40 })
40 41
41#define memzero(p,n) ({ if ((n) != 0) __memzero((p),(n)); (p); }) 42#define memzero(p,n) \
43 ({ \
44 void *__p = (p); size_t __n = n; \
45 if ((__n) != 0) \
46 __memzero((__p),(__n)); \
47 (__p); \
48 })
42 49
43#endif 50#endif
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index a61618fb433c..66c585c50cf9 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -14,6 +14,10 @@
14 14
15#include <asm/fpstate.h> 15#include <asm/fpstate.h>
16 16
17#define THREAD_SIZE_ORDER 1
18#define THREAD_SIZE 8192
19#define THREAD_START_SP (THREAD_SIZE - 8)
20
17#ifndef __ASSEMBLY__ 21#ifndef __ASSEMBLY__
18 22
19struct task_struct; 23struct task_struct;
@@ -77,8 +81,6 @@ struct thread_info {
77#define init_thread_info (init_thread_union.thread_info) 81#define init_thread_info (init_thread_union.thread_info)
78#define init_stack (init_thread_union.stack) 82#define init_stack (init_thread_union.stack)
79 83
80#define THREAD_SIZE 8192
81
82/* 84/*
83 * how to get the thread information struct from C 85 * how to get the thread information struct from C
84 */ 86 */
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index a19ec09eaa01..ace27480886e 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -359,8 +359,7 @@
359#define __ARM_NR_cacheflush (__ARM_NR_BASE+2) 359#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
360#define __ARM_NR_usr26 (__ARM_NR_BASE+3) 360#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
361#define __ARM_NR_usr32 (__ARM_NR_BASE+4) 361#define __ARM_NR_usr32 (__ARM_NR_BASE+4)
362 362#define __ARM_NR_set_tls (__ARM_NR_BASE+5)
363#define __ARM_NR_set_tls (__ARM_NR_BASE+0x800)
364 363
365#define __sys2(x) #x 364#define __sys2(x) #x
366#define __sys1(x) __sys2(x) 365#define __sys1(x) __sys2(x)
diff --git a/include/asm-arm26/bug.h b/include/asm-arm26/bug.h
index 920b70533368..7177c7399967 100644
--- a/include/asm-arm26/bug.h
+++ b/include/asm-arm26/bug.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_BUG
6#ifdef CONFIG_DEBUG_BUGVERBOSE 7#ifdef CONFIG_DEBUG_BUGVERBOSE
7extern volatile void __bug(const char *file, int line, void *data); 8extern volatile void __bug(const char *file, int line, void *data);
8/* give file/line information */ 9/* give file/line information */
@@ -12,6 +13,8 @@ extern volatile void __bug(const char *file, int line, void *data);
12#endif 13#endif
13 14
14#define HAVE_ARCH_BUG 15#define HAVE_ARCH_BUG
16#endif
17
15#include <asm-generic/bug.h> 18#include <asm-generic/bug.h>
16 19
17#endif 20#endif
diff --git a/include/asm-arm26/signal.h b/include/asm-arm26/signal.h
index 6f62e51a2e5a..dedb29280303 100644
--- a/include/asm-arm26/signal.h
+++ b/include/asm-arm26/signal.h
@@ -114,30 +114,10 @@ typedef unsigned long sigset_t;
114#define SIGSTKSZ 8192 114#define SIGSTKSZ 8192
115 115
116#ifdef __KERNEL__ 116#ifdef __KERNEL__
117
118/*
119 * These values of sa_flags are used only by the kernel as part of the
120 * irq handling routines.
121 *
122 * SA_INTERRUPT is also used by the irq handling routines.
123 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
124 */
125#define SA_PROBE 0x80000000
126#define SA_SAMPLE_RANDOM 0x10000000
127#define SA_IRQNOMASK 0x08000000 117#define SA_IRQNOMASK 0x08000000
128#define SA_SHIRQ 0x04000000
129#endif 118#endif
130 119
131#define SIG_BLOCK 0 /* for blocking signals */ 120#include <asm-generic/signal.h>
132#define SIG_UNBLOCK 1 /* for unblocking signals */
133#define SIG_SETMASK 2 /* for setting the signal mask */
134
135/* Type of a signal handler. */
136typedef void (*__sighandler_t)(int);
137
138#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
139#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
140#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
141 121
142#ifdef __KERNEL__ 122#ifdef __KERNEL__
143struct old_sigaction { 123struct old_sigaction {
diff --git a/include/asm-cris/page.h b/include/asm-cris/page.h
index ddd8915e41e6..c767da1ef8f5 100644
--- a/include/asm-cris/page.h
+++ b/include/asm-cris/page.h
@@ -77,10 +77,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
77 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 77 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
78} while (0) 78} while (0)
79 79
80#define PAGE_BUG(page) do { \
81 BUG(); \
82} while (0)
83
84/* Pure 2^n version of get_order */ 80/* Pure 2^n version of get_order */
85static inline int get_order(unsigned long size) 81static inline int get_order(unsigned long size)
86{ 82{
diff --git a/include/asm-cris/signal.h b/include/asm-cris/signal.h
index 3f187ec4800a..dfe039593a78 100644
--- a/include/asm-cris/signal.h
+++ b/include/asm-cris/signal.h
@@ -108,30 +108,7 @@ typedef unsigned long sigset_t;
108#define MINSIGSTKSZ 2048 108#define MINSIGSTKSZ 2048
109#define SIGSTKSZ 8192 109#define SIGSTKSZ 8192
110 110
111#ifdef __KERNEL__ 111#include <asm-generic/signal.h>
112
113/*
114 * These values of sa_flags are used only by the kernel as part of the
115 * irq handling routines.
116 *
117 * SA_INTERRUPT is also used by the irq handling routines.
118 * SA_SHIRQ is for shared interrupt support
119 */
120#define SA_PROBE SA_ONESHOT
121#define SA_SAMPLE_RANDOM SA_RESTART
122#define SA_SHIRQ 0x04000000
123#endif
124
125#define SIG_BLOCK 0 /* for blocking signals */
126#define SIG_UNBLOCK 1 /* for unblocking signals */
127#define SIG_SETMASK 2 /* for setting the signal mask */
128
129/* Type of a signal handler. */
130typedef void (*__sighandler_t)(int);
131
132#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
133#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
134#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
135 112
136#ifdef __KERNEL__ 113#ifdef __KERNEL__
137struct old_sigaction { 114struct old_sigaction {
diff --git a/include/asm-frv/bug.h b/include/asm-frv/bug.h
index 011860b28818..074c0d5770eb 100644
--- a/include/asm-frv/bug.h
+++ b/include/asm-frv/bug.h
@@ -13,6 +13,7 @@
13 13
14#include <linux/config.h> 14#include <linux/config.h>
15 15
16#ifdef CONFIG_BUG
16/* 17/*
17 * Tell the user there is some problem. 18 * Tell the user there is some problem.
18 */ 19 */
@@ -45,6 +46,7 @@ do { \
45#define HAVE_ARCH_KGDB_BAD_PAGE 46#define HAVE_ARCH_KGDB_BAD_PAGE
46#define kgdb_bad_page(page) do { kgdb_raise(SIGABRT); } while(0) 47#define kgdb_bad_page(page) do { kgdb_raise(SIGABRT); } while(0)
47#endif 48#endif
49#endif
48 50
49#include <asm-generic/bug.h> 51#include <asm-generic/bug.h>
50 52
diff --git a/include/asm-frv/pgtable.h b/include/asm-frv/pgtable.h
index 3c6d42a22dfe..d0a9c2f9c13e 100644
--- a/include/asm-frv/pgtable.h
+++ b/include/asm-frv/pgtable.h
@@ -349,9 +349,9 @@ static inline pmd_t *pmd_offset(pud_t *dir, unsigned long address)
349 349
350/* 350/*
351 * Define this to warn about kernel memory accesses that are 351 * Define this to warn about kernel memory accesses that are
352 * done without a 'verify_area(VERIFY_WRITE,..)' 352 * done without a 'access_ok(VERIFY_WRITE,..)'
353 */ 353 */
354#undef TEST_VERIFY_AREA 354#undef TEST_ACCESS_OK
355 355
356#define pte_present(x) (pte_val(x) & _PAGE_PRESENT) 356#define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
357#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 357#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
diff --git a/include/asm-frv/signal.h b/include/asm-frv/signal.h
index f18952f86a80..d407bde57eca 100644
--- a/include/asm-frv/signal.h
+++ b/include/asm-frv/signal.h
@@ -107,30 +107,7 @@ typedef unsigned long sigset_t;
107#define MINSIGSTKSZ 2048 107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ 8192 108#define SIGSTKSZ 8192
109 109
110#ifdef __KERNEL__ 110#include <asm-generic/signal.h>
111
112/*
113 * These values of sa_flags are used only by the kernel as part of the
114 * irq handling routines.
115 *
116 * SA_INTERRUPT is also used by the irq handling routines.
117 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
118 */
119#define SA_PROBE SA_ONESHOT
120#define SA_SAMPLE_RANDOM SA_RESTART
121#define SA_SHIRQ 0x04000000
122#endif
123
124#define SIG_BLOCK 0 /* for blocking signals */
125#define SIG_UNBLOCK 1 /* for unblocking signals */
126#define SIG_SETMASK 2 /* for setting the signal mask */
127
128/* Type of a signal handler. */
129typedef void (*__sighandler_t)(int);
130
131#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
132#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
133#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
134 111
135#ifdef __KERNEL__ 112#ifdef __KERNEL__
136struct old_sigaction { 113struct old_sigaction {
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index e5913c3b715a..400c2b41896e 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -4,6 +4,7 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <linux/config.h> 5#include <linux/config.h>
6 6
7#ifdef CONFIG_BUG
7#ifndef HAVE_ARCH_BUG 8#ifndef HAVE_ARCH_BUG
8#define BUG() do { \ 9#define BUG() do { \
9 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 10 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
@@ -11,13 +12,6 @@
11} while (0) 12} while (0)
12#endif 13#endif
13 14
14#ifndef HAVE_ARCH_PAGE_BUG
15#define PAGE_BUG(page) do { \
16 printk("page BUG for page at %p\n", page); \
17 BUG(); \
18} while (0)
19#endif
20
21#ifndef HAVE_ARCH_BUG_ON 15#ifndef HAVE_ARCH_BUG_ON
22#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) 16#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
23#endif 17#endif
@@ -31,4 +25,18 @@
31} while (0) 25} while (0)
32#endif 26#endif
33 27
28#else /* !CONFIG_BUG */
29#ifndef HAVE_ARCH_BUG
30#define BUG()
31#endif
32
33#ifndef HAVE_ARCH_BUG_ON
34#define BUG_ON(condition) do { if (condition) ; } while(0)
35#endif
36
37#ifndef HAVE_ARCH_WARN_ON
38#define WARN_ON(condition) do { if (condition) ; } while(0)
39#endif
40#endif
41
34#endif 42#endif
diff --git a/include/asm-generic/errno.h b/include/asm-generic/errno.h
index 4dd2384bc38d..e8852c092fea 100644
--- a/include/asm-generic/errno.h
+++ b/include/asm-generic/errno.h
@@ -102,4 +102,8 @@
102#define EKEYREVOKED 128 /* Key has been revoked */ 102#define EKEYREVOKED 128 /* Key has been revoked */
103#define EKEYREJECTED 129 /* Key was rejected by service */ 103#define EKEYREJECTED 129 /* Key was rejected by service */
104 104
105/* for robust mutexes */
106#define EOWNERDEAD 130 /* Owner died */
107#define ENOTRECOVERABLE 131 /* State not recoverable */
108
105#endif 109#endif
diff --git a/include/asm-generic/resource.h b/include/asm-generic/resource.h
index b1fcda9eac23..cfe3692b23e5 100644
--- a/include/asm-generic/resource.h
+++ b/include/asm-generic/resource.h
@@ -41,8 +41,11 @@
41#define RLIMIT_LOCKS 10 /* maximum file locks held */ 41#define RLIMIT_LOCKS 10 /* maximum file locks held */
42#define RLIMIT_SIGPENDING 11 /* max number of pending signals */ 42#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
43#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */ 43#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
44#define RLIMIT_NICE 13 /* max nice prio allowed to raise to
45 0-39 for nice level 19 .. -20 */
46#define RLIMIT_RTPRIO 14 /* maximum realtime priority */
44 47
45#define RLIM_NLIMITS 13 48#define RLIM_NLIMITS 15
46 49
47/* 50/*
48 * SuS says limits have to be unsigned. 51 * SuS says limits have to be unsigned.
@@ -81,6 +84,8 @@
81 [RLIMIT_LOCKS] = { RLIM_INFINITY, RLIM_INFINITY }, \ 84 [RLIMIT_LOCKS] = { RLIM_INFINITY, RLIM_INFINITY }, \
82 [RLIMIT_SIGPENDING] = { 0, 0 }, \ 85 [RLIMIT_SIGPENDING] = { 0, 0 }, \
83 [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ 86 [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \
87 [RLIMIT_NICE] = { 0, 0 }, \
88 [RLIMIT_RTPRIO] = { 0, 0 }, \
84} 89}
85 90
86#endif /* __KERNEL__ */ 91#endif /* __KERNEL__ */
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 976ac29598b7..195ccdc069e6 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -8,6 +8,8 @@ extern char _data[], _sdata[], _edata[];
8extern char __bss_start[], __bss_stop[]; 8extern char __bss_start[], __bss_stop[];
9extern char __init_begin[], __init_end[]; 9extern char __init_begin[], __init_end[];
10extern char _sinittext[], _einittext[]; 10extern char _sinittext[], _einittext[];
11extern char _sextratext[] __attribute__((weak));
12extern char _eextratext[] __attribute__((weak));
11extern char _end[]; 13extern char _end[];
12 14
13#endif /* _ASM_GENERIC_SECTIONS_H_ */ 15#endif /* _ASM_GENERIC_SECTIONS_H_ */
diff --git a/include/asm-generic/siginfo.h b/include/asm-generic/siginfo.h
index 9cac8e8dde51..8786e01e0db8 100644
--- a/include/asm-generic/siginfo.h
+++ b/include/asm-generic/siginfo.h
@@ -236,11 +236,18 @@ typedef struct siginfo {
236#define SIGEV_THREAD 2 /* deliver via thread creation */ 236#define SIGEV_THREAD 2 /* deliver via thread creation */
237#define SIGEV_THREAD_ID 4 /* deliver to thread */ 237#define SIGEV_THREAD_ID 4 /* deliver to thread */
238 238
239#define SIGEV_MAX_SIZE 64 239/*
240#ifndef SIGEV_PAD_SIZE 240 * This works because the alignment is ok on all current architectures
241#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) 241 * but we leave open this being overridden in the future
242 */
243#ifndef __ARCH_SIGEV_PREAMBLE_SIZE
244#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t))
242#endif 245#endif
243 246
247#define SIGEV_MAX_SIZE 64
248#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \
249 / sizeof(int))
250
244typedef struct sigevent { 251typedef struct sigevent {
245 sigval_t sigev_value; 252 sigval_t sigev_value;
246 int sigev_signo; 253 int sigev_signo;
diff --git a/include/asm-generic/signal.h b/include/asm-generic/signal.h
new file mode 100644
index 000000000000..9418d6e9b8cd
--- /dev/null
+++ b/include/asm-generic/signal.h
@@ -0,0 +1,21 @@
1#ifndef SIG_BLOCK
2#define SIG_BLOCK 0 /* for blocking signals */
3#endif
4#ifndef SIG_UNBLOCK
5#define SIG_UNBLOCK 1 /* for unblocking signals */
6#endif
7#ifndef SIG_SETMASK
8#define SIG_SETMASK 2 /* for setting the signal mask */
9#endif
10
11#ifndef __ASSEMBLY__
12typedef void __signalfn_t(int);
13typedef __signalfn_t __user *__sighandler_t;
14
15typedef void __restorefn_t(void);
16typedef __restorefn_t __user *__sigrestore_t;
17
18#define SIG_DFL ((__force __sighandler_t)0) /* default signal handling */
19#define SIG_IGN ((__force __sighandler_t)1) /* ignore signal */
20#define SIG_ERR ((__force __sighandler_t)-1) /* error return from signal */
21#endif
diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
index c856a43e3b45..6c90f0f36eec 100644
--- a/include/asm-generic/unaligned.h
+++ b/include/asm-generic/unaligned.h
@@ -76,46 +76,47 @@ static inline void __ustw(__u16 val, __u16 *addr)
76 ptr->x = val; 76 ptr->x = val;
77} 77}
78 78
79static inline unsigned long __get_unaligned(const void *ptr, size_t size) 79#define __get_unaligned(ptr, size) ({ \
80{ 80 const void *__gu_p = ptr; \
81 unsigned long val; 81 unsigned long val; \
82 switch (size) { 82 switch (size) { \
83 case 1: 83 case 1: \
84 val = *(const __u8 *)ptr; 84 val = *(const __u8 *)__gu_p; \
85 break; 85 break; \
86 case 2: 86 case 2: \
87 val = __uldw((const __u16 *)ptr); 87 val = __uldw(__gu_p); \
88 break; 88 break; \
89 case 4: 89 case 4: \
90 val = __uldl((const __u32 *)ptr); 90 val = __uldl(__gu_p); \
91 break; 91 break; \
92 case 8: 92 case 8: \
93 val = __uldq((const __u64 *)ptr); 93 val = __uldq(__gu_p); \
94 break; 94 break; \
95 default: 95 default: \
96 bad_unaligned_access_length(); 96 bad_unaligned_access_length(); \
97 }; 97 }; \
98 return val; 98 val; \
99} 99})
100 100
101static inline void __put_unaligned(unsigned long val, void *ptr, size_t size) 101#define __put_unaligned(val, ptr, size) \
102{ 102do { \
103 switch (size) { 103 void *__gu_p = ptr; \
104 case 1: 104 switch (size) { \
105 *(__u8 *)ptr = val; 105 case 1: \
106 break; 106 *(__u8 *)__gu_p = val; \
107 case 2: 107 break; \
108 __ustw(val, (__u16 *)ptr); 108 case 2: \
109 break; 109 __ustw(val, __gu_p); \
110 case 4: 110 break; \
111 __ustl(val, (__u32 *)ptr); 111 case 4: \
112 break; 112 __ustl(val, __gu_p); \
113 case 8: 113 break; \
114 __ustq(val, (__u64 *)ptr); 114 case 8: \
115 break; 115 __ustq(val, __gu_p); \
116 default: 116 break; \
117 bad_unaligned_access_length(); 117 default: \
118 }; 118 bad_unaligned_access_length(); \
119} 119 }; \
120} while(0)
120 121
121#endif /* _ASM_GENERIC_UNALIGNED_H */ 122#endif /* _ASM_GENERIC_UNALIGNED_H */
diff --git a/include/asm-h8300/signal.h b/include/asm-h8300/signal.h
index 3a08544a473e..8eccdc176163 100644
--- a/include/asm-h8300/signal.h
+++ b/include/asm-h8300/signal.h
@@ -107,29 +107,7 @@ typedef unsigned long sigset_t;
107#define MINSIGSTKSZ 2048 107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ 8192 108#define SIGSTKSZ 8192
109 109
110#ifdef __KERNEL__ 110#include <asm-generic/signal.h>
111/*
112 * These values of sa_flags are used only by the kernel as part of the
113 * irq handling routines.
114 *
115 * SA_INTERRUPT is also used by the irq handling routines.
116 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
117 */
118#define SA_PROBE SA_ONESHOT
119#define SA_SAMPLE_RANDOM SA_RESTART
120#define SA_SHIRQ 0x04000000
121#endif
122
123#define SIG_BLOCK 0 /* for blocking signals */
124#define SIG_UNBLOCK 1 /* for unblocking signals */
125#define SIG_SETMASK 2 /* for setting the signal mask */
126
127/* Type of a signal handler. */
128typedef void (*__sighandler_t)(int);
129
130#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
131#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
132#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
133 111
134#ifdef __KERNEL__ 112#ifdef __KERNEL__
135struct old_sigaction { 113struct old_sigaction {
diff --git a/include/asm-i386/apic.h b/include/asm-i386/apic.h
index e1de67483f38..a5810cf7b578 100644
--- a/include/asm-i386/apic.h
+++ b/include/asm-i386/apic.h
@@ -109,7 +109,6 @@ extern int APIC_init_uniprocessor (void);
109extern void disable_APIC_timer(void); 109extern void disable_APIC_timer(void);
110extern void enable_APIC_timer(void); 110extern void enable_APIC_timer(void);
111 111
112extern int check_nmi_watchdog (void);
113extern void enable_NMI_through_LVT0 (void * dummy); 112extern void enable_NMI_through_LVT0 (void * dummy);
114 113
115extern unsigned int nmi_watchdog; 114extern unsigned int nmi_watchdog;
diff --git a/include/asm-i386/bug.h b/include/asm-i386/bug.h
index 706eb511c330..8f79de19eb94 100644
--- a/include/asm-i386/bug.h
+++ b/include/asm-i386/bug.h
@@ -9,6 +9,8 @@
9 * undefined" opcode for parsing in the trap handler. 9 * undefined" opcode for parsing in the trap handler.
10 */ 10 */
11 11
12#ifdef CONFIG_BUG
13#define HAVE_ARCH_BUG
12#ifdef CONFIG_DEBUG_BUGVERBOSE 14#ifdef CONFIG_DEBUG_BUGVERBOSE
13#define BUG() \ 15#define BUG() \
14 __asm__ __volatile__( "ud2\n" \ 16 __asm__ __volatile__( "ud2\n" \
@@ -18,8 +20,7 @@
18#else 20#else
19#define BUG() __asm__ __volatile__("ud2\n") 21#define BUG() __asm__ __volatile__("ud2\n")
20#endif 22#endif
23#endif
21 24
22#define HAVE_ARCH_BUG
23#include <asm-generic/bug.h> 25#include <asm-generic/bug.h>
24
25#endif 26#endif
diff --git a/include/asm-i386/checksum.h b/include/asm-i386/checksum.h
index d76a5f081c91..641342002bcd 100644
--- a/include/asm-i386/checksum.h
+++ b/include/asm-i386/checksum.h
@@ -33,7 +33,7 @@ asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsi
33 * passed in an incorrect kernel address to one of these functions. 33 * passed in an incorrect kernel address to one of these functions.
34 * 34 *
35 * If you use these functions directly please don't forget the 35 * If you use these functions directly please don't forget the
36 * verify_area(). 36 * access_ok().
37 */ 37 */
38static __inline__ 38static __inline__
39unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, 39unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst,
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index e147cabd3bfe..ff1187e80c32 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -87,8 +87,8 @@
87#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */ 87#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */
88 88
89/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */ 89/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
90#define X86_FEATURE_LAHF_LM (5*32+ 0) /* LAHF/SAHF in long mode */ 90#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
91#define X86_FEATURE_CMP_LEGACY (5*32+ 1) /* If yes HyperThreading not valid */ 91#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
92 92
93#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) 93#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
94#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability) 94#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index 5c285aee7294..edf65be21a92 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -13,7 +13,7 @@
13#define __E820_HEADER 13#define __E820_HEADER
14 14
15#define E820MAP 0x2d0 /* our map */ 15#define E820MAP 0x2d0 /* our map */
16#define E820MAX 32 /* number of entries in E820MAP */ 16#define E820MAX 128 /* number of entries in E820MAP */
17#define E820NR 0x1e8 /* # entries in E820MAP */ 17#define E820NR 0x1e8 /* # entries in E820MAP */
18 18
19#define E820_RAM 1 19#define E820_RAM 1
diff --git a/include/asm-i386/floppy.h b/include/asm-i386/floppy.h
index f4782284807a..79727afb94c9 100644
--- a/include/asm-i386/floppy.h
+++ b/include/asm-i386/floppy.h
@@ -257,7 +257,7 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
257 return 0; 257 return 0;
258} 258}
259 259
260struct fd_routine_l { 260static struct fd_routine_l {
261 int (*_request_dma)(unsigned int dmanr, const char * device_id); 261 int (*_request_dma)(unsigned int dmanr, const char * device_id);
262 void (*_free_dma)(unsigned int dmanr); 262 void (*_free_dma)(unsigned int dmanr);
263 int (*_get_dma_residue)(unsigned int dummy); 263 int (*_get_dma_residue)(unsigned int dummy);
diff --git a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
index 6e20b079f1d3..16ef9f996e3f 100644
--- a/include/asm-i386/hpet.h
+++ b/include/asm-i386/hpet.h
@@ -92,6 +92,7 @@
92 92
93extern unsigned long hpet_tick; /* hpet clks count per tick */ 93extern unsigned long hpet_tick; /* hpet clks count per tick */
94extern unsigned long hpet_address; /* hpet memory map physical address */ 94extern unsigned long hpet_address; /* hpet memory map physical address */
95extern int hpet_use_timer;
95 96
96extern int hpet_rtc_timer_init(void); 97extern int hpet_rtc_timer_init(void);
97extern int hpet_enable(void); 98extern int hpet_enable(void);
diff --git a/include/asm-i386/module.h b/include/asm-i386/module.h
index 508865e26308..eb7f2b4234aa 100644
--- a/include/asm-i386/module.h
+++ b/include/asm-i386/module.h
@@ -52,8 +52,8 @@ struct mod_arch_specific
52#define MODULE_PROC_FAMILY "CYRIXIII " 52#define MODULE_PROC_FAMILY "CYRIXIII "
53#elif defined CONFIG_MVIAC3_2 53#elif defined CONFIG_MVIAC3_2
54#define MODULE_PROC_FAMILY "VIAC3-2 " 54#define MODULE_PROC_FAMILY "VIAC3-2 "
55#elif CONFIG_MGEODE 55#elif CONFIG_MGEODEGX1
56#define MODULE_PROC_FAMILY "GEODE " 56#define MODULE_PROC_FAMILY "GEODEGX1 "
57#else 57#else
58#error unknown processor family 58#error unknown processor family
59#endif 59#endif
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index 5c725425d863..8d60c2b4b003 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -193,9 +193,9 @@ extern unsigned long long __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
193/* 193/*
194 * Define this if things work differently on an i386 and an i486: 194 * Define this if things work differently on an i386 and an i486:
195 * it will (on an i486) warn about kernel memory accesses that are 195 * it will (on an i486) warn about kernel memory accesses that are
196 * done without a 'verify_area(VERIFY_WRITE,..)' 196 * done without a 'access_ok(VERIFY_WRITE,..)'
197 */ 197 */
198#undef TEST_VERIFY_AREA 198#undef TEST_ACCESS_OK
199 199
200/* The boot page tables (all created as a single array) */ 200/* The boot page tables (all created as a single array) */
201extern unsigned long pg0[]; 201extern unsigned long pg0[];
diff --git a/include/asm-i386/setup.h b/include/asm-i386/setup.h
index 8814b54c75d4..7a32184d54bf 100644
--- a/include/asm-i386/setup.h
+++ b/include/asm-i386/setup.h
@@ -16,7 +16,7 @@
16#define MAXMEM_PFN PFN_DOWN(MAXMEM) 16#define MAXMEM_PFN PFN_DOWN(MAXMEM)
17#define MAX_NONPAE_PFN (1 << 20) 17#define MAX_NONPAE_PFN (1 << 20)
18 18
19#define PARAM_SIZE 2048 19#define PARAM_SIZE 4096
20#define COMMAND_LINE_SIZE 256 20#define COMMAND_LINE_SIZE 256
21 21
22#define OLD_CL_MAGIC_ADDR 0x90020 22#define OLD_CL_MAGIC_ADDR 0x90020
diff --git a/include/asm-i386/signal.h b/include/asm-i386/signal.h
index 7ef343b6812d..cbb47d34aa31 100644
--- a/include/asm-i386/signal.h
+++ b/include/asm-i386/signal.h
@@ -110,34 +110,7 @@ typedef unsigned long sigset_t;
110#define MINSIGSTKSZ 2048 110#define MINSIGSTKSZ 2048
111#define SIGSTKSZ 8192 111#define SIGSTKSZ 8192
112 112
113#ifdef __KERNEL__ 113#include <asm-generic/signal.h>
114
115/*
116 * These values of sa_flags are used only by the kernel as part of the
117 * irq handling routines.
118 *
119 * SA_INTERRUPT is also used by the irq handling routines.
120 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
121 */
122#define SA_PROBE SA_ONESHOT
123#define SA_SAMPLE_RANDOM SA_RESTART
124#define SA_SHIRQ 0x04000000
125#endif
126
127#define SIG_BLOCK 0 /* for blocking signals */
128#define SIG_UNBLOCK 1 /* for unblocking signals */
129#define SIG_SETMASK 2 /* for setting the signal mask */
130
131/* Type of a signal handler. */
132typedef void __signalfn_t(int);
133typedef __signalfn_t __user *__sighandler_t;
134
135typedef void __restorefn_t(void);
136typedef __restorefn_t __user *__sigrestore_t;
137
138#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
139#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
140#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
141 114
142#ifdef __KERNEL__ 115#ifdef __KERNEL__
143struct old_sigaction { 116struct old_sigaction {
diff --git a/include/asm-i386/string.h b/include/asm-i386/string.h
index 1679983d053f..6a78ac58c194 100644
--- a/include/asm-i386/string.h
+++ b/include/asm-i386/string.h
@@ -198,47 +198,80 @@ static inline void * __memcpy(void * to, const void * from, size_t n)
198int d0, d1, d2; 198int d0, d1, d2;
199__asm__ __volatile__( 199__asm__ __volatile__(
200 "rep ; movsl\n\t" 200 "rep ; movsl\n\t"
201 "testb $2,%b4\n\t" 201 "movl %4,%%ecx\n\t"
202 "je 1f\n\t" 202 "andl $3,%%ecx\n\t"
203 "movsw\n" 203#if 1 /* want to pay 2 byte penalty for a chance to skip microcoded rep? */
204 "1:\ttestb $1,%b4\n\t" 204 "jz 1f\n\t"
205 "je 2f\n\t" 205#endif
206 "movsb\n" 206 "rep ; movsb\n\t"
207 "2:" 207 "1:"
208 : "=&c" (d0), "=&D" (d1), "=&S" (d2) 208 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
209 :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) 209 : "0" (n/4), "g" (n), "1" ((long) to), "2" ((long) from)
210 : "memory"); 210 : "memory");
211return (to); 211return (to);
212} 212}
213 213
214/* 214/*
215 * This looks horribly ugly, but the compiler can optimize it totally, 215 * This looks ugly, but the compiler can optimize it totally,
216 * as the count is constant. 216 * as the count is constant.
217 */ 217 */
218static inline void * __constant_memcpy(void * to, const void * from, size_t n) 218static inline void * __constant_memcpy(void * to, const void * from, size_t n)
219{ 219{
220 if (n <= 128) 220 long esi, edi;
221 return __builtin_memcpy(to, from, n); 221 if (!n) return to;
222 222#if 1 /* want to do small copies with non-string ops? */
223#define COMMON(x) \ 223 switch (n) {
224__asm__ __volatile__( \ 224 case 1: *(char*)to = *(char*)from; return to;
225 "rep ; movsl" \ 225 case 2: *(short*)to = *(short*)from; return to;
226 x \ 226 case 4: *(int*)to = *(int*)from; return to;
227 : "=&c" (d0), "=&D" (d1), "=&S" (d2) \ 227#if 1 /* including those doable with two moves? */
228 : "0" (n/4),"1" ((long) to),"2" ((long) from) \ 228 case 3: *(short*)to = *(short*)from;
229 : "memory"); 229 *((char*)to+2) = *((char*)from+2); return to;
230{ 230 case 5: *(int*)to = *(int*)from;
231 int d0, d1, d2; 231 *((char*)to+4) = *((char*)from+4); return to;
232 case 6: *(int*)to = *(int*)from;
233 *((short*)to+2) = *((short*)from+2); return to;
234 case 8: *(int*)to = *(int*)from;
235 *((int*)to+1) = *((int*)from+1); return to;
236#endif
237 }
238#endif
239 esi = (long) from;
240 edi = (long) to;
241 if (n >= 5*4) {
242 /* large block: use rep prefix */
243 int ecx;
244 __asm__ __volatile__(
245 "rep ; movsl"
246 : "=&c" (ecx), "=&D" (edi), "=&S" (esi)
247 : "0" (n/4), "1" (edi),"2" (esi)
248 : "memory"
249 );
250 } else {
251 /* small block: don't clobber ecx + smaller code */
252 if (n >= 4*4) __asm__ __volatile__("movsl"
253 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
254 if (n >= 3*4) __asm__ __volatile__("movsl"
255 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
256 if (n >= 2*4) __asm__ __volatile__("movsl"
257 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
258 if (n >= 1*4) __asm__ __volatile__("movsl"
259 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
260 }
232 switch (n % 4) { 261 switch (n % 4) {
233 case 0: COMMON(""); return to; 262 /* tail */
234 case 1: COMMON("\n\tmovsb"); return to; 263 case 0: return to;
235 case 2: COMMON("\n\tmovsw"); return to; 264 case 1: __asm__ __volatile__("movsb"
236 default: COMMON("\n\tmovsw\n\tmovsb"); return to; 265 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
266 return to;
267 case 2: __asm__ __volatile__("movsw"
268 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
269 return to;
270 default: __asm__ __volatile__("movsw\n\tmovsb"
271 :"=&D"(edi),"=&S"(esi):"0"(edi),"1"(esi):"memory");
272 return to;
237 } 273 }
238} 274}
239
240#undef COMMON
241}
242 275
243#define __HAVE_ARCH_MEMCPY 276#define __HAVE_ARCH_MEMCPY
244 277
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index 6f74d4c44a0e..3db717a244f0 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -81,7 +81,7 @@ static inline unsigned long _get_base(char * addr)
81#define loadsegment(seg,value) \ 81#define loadsegment(seg,value) \
82 asm volatile("\n" \ 82 asm volatile("\n" \
83 "1:\t" \ 83 "1:\t" \
84 "movl %0,%%" #seg "\n" \ 84 "mov %0,%%" #seg "\n" \
85 "2:\n" \ 85 "2:\n" \
86 ".section .fixup,\"ax\"\n" \ 86 ".section .fixup,\"ax\"\n" \
87 "3:\t" \ 87 "3:\t" \
@@ -93,13 +93,13 @@ static inline unsigned long _get_base(char * addr)
93 ".align 4\n\t" \ 93 ".align 4\n\t" \
94 ".long 1b,3b\n" \ 94 ".long 1b,3b\n" \
95 ".previous" \ 95 ".previous" \
96 : :"m" (*(unsigned int *)&(value))) 96 : :"m" (value))
97 97
98/* 98/*
99 * Save a segment register away 99 * Save a segment register away
100 */ 100 */
101#define savesegment(seg, value) \ 101#define savesegment(seg, value) \
102 asm volatile("movl %%" #seg ",%0":"=m" (*(int *)&(value))) 102 asm volatile("mov %%" #seg ",%0":"=m" (value))
103 103
104/* 104/*
105 * Clear and set 'TS' bit respectively 105 * Clear and set 'TS' bit respectively
diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h
index 925d54cee475..7232528e2d0c 100644
--- a/include/asm-ia64/bitops.h
+++ b/include/asm-ia64/bitops.h
@@ -314,8 +314,8 @@ __ffs (unsigned long x)
314#ifdef __KERNEL__ 314#ifdef __KERNEL__
315 315
316/* 316/*
317 * find_last_zero_bit - find the last zero bit in a 64 bit quantity 317 * Return bit number of last (most-significant) bit set. Undefined
318 * @x: The value to search 318 * for x==0. Bits are numbered from 0..63 (e.g., ia64_fls(9) == 3).
319 */ 319 */
320static inline unsigned long 320static inline unsigned long
321ia64_fls (unsigned long x) 321ia64_fls (unsigned long x)
@@ -327,10 +327,23 @@ ia64_fls (unsigned long x)
327 return exp - 0xffff; 327 return exp - 0xffff;
328} 328}
329 329
330/*
331 * Find the last (most significant) bit set. Returns 0 for x==0 and
332 * bits are numbered from 1..32 (e.g., fls(9) == 4).
333 */
330static inline int 334static inline int
331fls (int x) 335fls (int t)
332{ 336{
333 return ia64_fls((unsigned int) x); 337 unsigned long x = t & 0xffffffffu;
338
339 if (!x)
340 return 0;
341 x |= x >> 1;
342 x |= x >> 2;
343 x |= x >> 4;
344 x |= x >> 8;
345 x |= x >> 16;
346 return ia64_popcnt(x);
334} 347}
335 348
336/* 349/*
diff --git a/include/asm-ia64/bug.h b/include/asm-ia64/bug.h
index 2c0cd51e8856..3aa0a0a5474b 100644
--- a/include/asm-ia64/bug.h
+++ b/include/asm-ia64/bug.h
@@ -1,6 +1,7 @@
1#ifndef _ASM_IA64_BUG_H 1#ifndef _ASM_IA64_BUG_H
2#define _ASM_IA64_BUG_H 2#define _ASM_IA64_BUG_H
3 3
4#ifdef CONFIG_BUG
4#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) 5#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
5# define ia64_abort() __builtin_trap() 6# define ia64_abort() __builtin_trap()
6#else 7#else
@@ -8,8 +9,10 @@
8#endif 9#endif
9#define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) 10#define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0)
10 11
11/* should this BUG should be made generic? */ 12/* should this BUG be made generic? */
12#define HAVE_ARCH_BUG 13#define HAVE_ARCH_BUG
14#endif
15
13#include <asm-generic/bug.h> 16#include <asm-generic/bug.h>
14 17
15#endif 18#endif
diff --git a/include/asm-ia64/gcc_intrin.h b/include/asm-ia64/gcc_intrin.h
index 7c357dfbae50..4fb4e439b05c 100644
--- a/include/asm-ia64/gcc_intrin.h
+++ b/include/asm-ia64/gcc_intrin.h
@@ -133,13 +133,17 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__;
133 ia64_intri_res; \ 133 ia64_intri_res; \
134}) 134})
135 135
136#define ia64_popcnt(x) \ 136#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
137({ \ 137# define ia64_popcnt(x) __builtin_popcountl(x)
138#else
139# define ia64_popcnt(x) \
140 ({ \
138 __u64 ia64_intri_res; \ 141 __u64 ia64_intri_res; \
139 asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ 142 asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \
140 \ 143 \
141 ia64_intri_res; \ 144 ia64_intri_res; \
142}) 145 })
146#endif
143 147
144#define ia64_getf_exp(x) \ 148#define ia64_getf_exp(x) \
145({ \ 149({ \
diff --git a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h
index 041ab8c51a64..cd4e06b74ab6 100644
--- a/include/asm-ia64/hw_irq.h
+++ b/include/asm-ia64/hw_irq.h
@@ -81,6 +81,7 @@ extern __u8 isa_irq_to_vector_map[16];
81 81
82extern struct hw_interrupt_type irq_type_ia64_lsapic; /* CPU-internal interrupt controller */ 82extern struct hw_interrupt_type irq_type_ia64_lsapic; /* CPU-internal interrupt controller */
83 83
84extern int assign_irq_vector_nopanic (int irq); /* allocate a free vector without panic */
84extern int assign_irq_vector (int irq); /* allocate a free vector */ 85extern int assign_irq_vector (int irq); /* allocate a free vector */
85extern void free_irq_vector (int vector); 86extern void free_irq_vector (int vector);
86extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect); 87extern void ia64_send_ipi (int cpu, int vector, int delivery_mode, int redirect);
diff --git a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
index 5dd477ffb88e..2303a10ee595 100644
--- a/include/asm-ia64/pal.h
+++ b/include/asm-ia64/pal.h
@@ -67,6 +67,7 @@
67#define PAL_REGISTER_INFO 39 /* return AR and CR register information*/ 67#define PAL_REGISTER_INFO 39 /* return AR and CR register information*/
68#define PAL_SHUTDOWN 40 /* enter processor shutdown state */ 68#define PAL_SHUTDOWN 40 /* enter processor shutdown state */
69#define PAL_PREFETCH_VISIBILITY 41 /* Make Processor Prefetches Visible */ 69#define PAL_PREFETCH_VISIBILITY 41 /* Make Processor Prefetches Visible */
70#define PAL_LOGICAL_TO_PHYSICAL 42 /* returns information on logical to physical processor mapping */
70 71
71#define PAL_COPY_PAL 256 /* relocate PAL procedures and PAL PMI */ 72#define PAL_COPY_PAL 256 /* relocate PAL procedures and PAL PMI */
72#define PAL_HALT_INFO 257 /* return the low power capabilities of processor */ 73#define PAL_HALT_INFO 257 /* return the low power capabilities of processor */
@@ -1559,6 +1560,73 @@ ia64_pal_prefetch_visibility (s64 trans_type)
1559 return iprv.status; 1560 return iprv.status;
1560} 1561}
1561 1562
1563/* data structure for getting information on logical to physical mappings */
1564typedef union pal_log_overview_u {
1565 struct {
1566 u64 num_log :16, /* Total number of logical
1567 * processors on this die
1568 */
1569 tpc :8, /* Threads per core */
1570 reserved3 :8, /* Reserved */
1571 cpp :8, /* Cores per processor */
1572 reserved2 :8, /* Reserved */
1573 ppid :8, /* Physical processor ID */
1574 reserved1 :8; /* Reserved */
1575 } overview_bits;
1576 u64 overview_data;
1577} pal_log_overview_t;
1578
1579typedef union pal_proc_n_log_info1_u{
1580 struct {
1581 u64 tid :16, /* Thread id */
1582 reserved2 :16, /* Reserved */
1583 cid :16, /* Core id */
1584 reserved1 :16; /* Reserved */
1585 } ppli1_bits;
1586 u64 ppli1_data;
1587} pal_proc_n_log_info1_t;
1588
1589typedef union pal_proc_n_log_info2_u {
1590 struct {
1591 u64 la :16, /* Logical address */
1592 reserved :48; /* Reserved */
1593 } ppli2_bits;
1594 u64 ppli2_data;
1595} pal_proc_n_log_info2_t;
1596
1597typedef struct pal_logical_to_physical_s
1598{
1599 pal_log_overview_t overview;
1600 pal_proc_n_log_info1_t ppli1;
1601 pal_proc_n_log_info2_t ppli2;
1602} pal_logical_to_physical_t;
1603
1604#define overview_num_log overview.overview_bits.num_log
1605#define overview_tpc overview.overview_bits.tpc
1606#define overview_cpp overview.overview_bits.cpp
1607#define overview_ppid overview.overview_bits.ppid
1608#define log1_tid ppli1.ppli1_bits.tid
1609#define log1_cid ppli1.ppli1_bits.cid
1610#define log2_la ppli2.ppli2_bits.la
1611
1612/* Get information on logical to physical processor mappings. */
1613static inline s64
1614ia64_pal_logical_to_phys(u64 proc_number, pal_logical_to_physical_t *mapping)
1615{
1616 struct ia64_pal_retval iprv;
1617
1618 PAL_CALL(iprv, PAL_LOGICAL_TO_PHYSICAL, proc_number, 0, 0);
1619
1620 if (iprv.status == PAL_STATUS_SUCCESS)
1621 {
1622 if (proc_number == 0)
1623 mapping->overview.overview_data = iprv.v0;
1624 mapping->ppli1.ppli1_data = iprv.v1;
1625 mapping->ppli2.ppli2_data = iprv.v2;
1626 }
1627
1628 return iprv.status;
1629}
1562#endif /* __ASSEMBLY__ */ 1630#endif /* __ASSEMBLY__ */
1563 1631
1564#endif /* _ASM_IA64_PAL_H */ 1632#endif /* _ASM_IA64_PAL_H */
diff --git a/include/asm-ia64/perfmon.h b/include/asm-ia64/perfmon.h
index 136c60e6bfcc..ed5416c5b1ac 100644
--- a/include/asm-ia64/perfmon.h
+++ b/include/asm-ia64/perfmon.h
@@ -254,6 +254,18 @@ extern int pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int
254#define PFM_CPUINFO_DCR_PP 0x2 /* if set the system wide session has started */ 254#define PFM_CPUINFO_DCR_PP 0x2 /* if set the system wide session has started */
255#define PFM_CPUINFO_EXCL_IDLE 0x4 /* the system wide session excludes the idle task */ 255#define PFM_CPUINFO_EXCL_IDLE 0x4 /* the system wide session excludes the idle task */
256 256
257/*
258 * sysctl control structure. visible to sampling formats
259 */
260typedef struct {
261 int debug; /* turn on/off debugging via syslog */
262 int debug_ovfl; /* turn on/off debug printk in overflow handler */
263 int fastctxsw; /* turn on/off fast (unsecure) ctxsw */
264 int expert_mode; /* turn on/off value checking */
265} pfm_sysctl_t;
266extern pfm_sysctl_t pfm_sysctl;
267
268
257#endif /* __KERNEL__ */ 269#endif /* __KERNEL__ */
258 270
259#endif /* _ASM_IA64_PERFMON_H */ 271#endif /* _ASM_IA64_PERFMON_H */
diff --git a/include/asm-ia64/pgalloc.h b/include/asm-ia64/pgalloc.h
index 0f05dc8bd460..a5f214554afd 100644
--- a/include/asm-ia64/pgalloc.h
+++ b/include/asm-ia64/pgalloc.h
@@ -22,146 +22,124 @@
22 22
23#include <asm/mmu_context.h> 23#include <asm/mmu_context.h>
24 24
25/* 25DECLARE_PER_CPU(unsigned long *, __pgtable_quicklist);
26 * Very stupidly, we used to get new pgd's and pmd's, init their contents 26#define pgtable_quicklist __ia64_per_cpu_var(__pgtable_quicklist)
27 * to point to the NULL versions of the next level page table, later on 27DECLARE_PER_CPU(long, __pgtable_quicklist_size);
28 * completely re-init them the same way, then free them up. This wasted 28#define pgtable_quicklist_size __ia64_per_cpu_var(__pgtable_quicklist_size)
29 * a lot of work and caused unnecessary memory traffic. How broken...
30 * We fix this by caching them.
31 */
32#define pgd_quicklist (local_cpu_data->pgd_quick)
33#define pmd_quicklist (local_cpu_data->pmd_quick)
34#define pgtable_cache_size (local_cpu_data->pgtable_cache_sz)
35 29
36static inline pgd_t* 30static inline long pgtable_quicklist_total_size(void)
37pgd_alloc_one_fast (struct mm_struct *mm) 31{
32 long ql_size = 0;
33 int cpuid;
34
35 for_each_online_cpu(cpuid) {
36 ql_size += per_cpu(__pgtable_quicklist_size, cpuid);
37 }
38 return ql_size;
39}
40
41static inline void *pgtable_quicklist_alloc(void)
38{ 42{
39 unsigned long *ret = NULL; 43 unsigned long *ret = NULL;
40 44
41 preempt_disable(); 45 preempt_disable();
42 46
43 ret = pgd_quicklist; 47 ret = pgtable_quicklist;
44 if (likely(ret != NULL)) { 48 if (likely(ret != NULL)) {
45 pgd_quicklist = (unsigned long *)(*ret); 49 pgtable_quicklist = (unsigned long *)(*ret);
46 ret[0] = 0; 50 ret[0] = 0;
47 --pgtable_cache_size; 51 --pgtable_quicklist_size;
48 } else 52 preempt_enable();
49 ret = NULL; 53 } else {
50 54 preempt_enable();
51 preempt_enable(); 55 ret = (unsigned long *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
56 }
52 57
53 return (pgd_t *) ret; 58 return ret;
54} 59}
55 60
56static inline pgd_t* 61static inline void pgtable_quicklist_free(void *pgtable_entry)
57pgd_alloc (struct mm_struct *mm)
58{ 62{
59 /* the VM system never calls pgd_alloc_one_fast(), so we do it here. */ 63#ifdef CONFIG_NUMA
60 pgd_t *pgd = pgd_alloc_one_fast(mm); 64 unsigned long nid = page_to_nid(virt_to_page(pgtable_entry));
61 65
62 if (unlikely(pgd == NULL)) { 66 if (unlikely(nid != numa_node_id())) {
63 pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); 67 free_page((unsigned long)pgtable_entry);
68 return;
64 } 69 }
65 return pgd; 70#endif
66}
67 71
68static inline void
69pgd_free (pgd_t *pgd)
70{
71 preempt_disable(); 72 preempt_disable();
72 *(unsigned long *)pgd = (unsigned long) pgd_quicklist; 73 *(unsigned long *)pgtable_entry = (unsigned long)pgtable_quicklist;
73 pgd_quicklist = (unsigned long *) pgd; 74 pgtable_quicklist = (unsigned long *)pgtable_entry;
74 ++pgtable_cache_size; 75 ++pgtable_quicklist_size;
75 preempt_enable(); 76 preempt_enable();
76} 77}
77 78
78static inline void 79static inline pgd_t *pgd_alloc(struct mm_struct *mm)
79pud_populate (struct mm_struct *mm, pud_t *pud_entry, pmd_t *pmd)
80{ 80{
81 pud_val(*pud_entry) = __pa(pmd); 81 return pgtable_quicklist_alloc();
82} 82}
83 83
84static inline pmd_t* 84static inline void pgd_free(pgd_t * pgd)
85pmd_alloc_one_fast (struct mm_struct *mm, unsigned long addr)
86{ 85{
87 unsigned long *ret = NULL; 86 pgtable_quicklist_free(pgd);
88
89 preempt_disable();
90
91 ret = (unsigned long *)pmd_quicklist;
92 if (likely(ret != NULL)) {
93 pmd_quicklist = (unsigned long *)(*ret);
94 ret[0] = 0;
95 --pgtable_cache_size;
96 }
97
98 preempt_enable();
99
100 return (pmd_t *)ret;
101} 87}
102 88
103static inline pmd_t* 89static inline void
104pmd_alloc_one (struct mm_struct *mm, unsigned long addr) 90pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
105{ 91{
106 pmd_t *pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); 92 pud_val(*pud_entry) = __pa(pmd);
93}
107 94
108 return pmd; 95static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
96{
97 return pgtable_quicklist_alloc();
109} 98}
110 99
111static inline void 100static inline void pmd_free(pmd_t * pmd)
112pmd_free (pmd_t *pmd)
113{ 101{
114 preempt_disable(); 102 pgtable_quicklist_free(pmd);
115 *(unsigned long *)pmd = (unsigned long) pmd_quicklist;
116 pmd_quicklist = (unsigned long *) pmd;
117 ++pgtable_cache_size;
118 preempt_enable();
119} 103}
120 104
121#define __pmd_free_tlb(tlb, pmd) pmd_free(pmd) 105#define __pmd_free_tlb(tlb, pmd) pmd_free(pmd)
122 106
123static inline void 107static inline void
124pmd_populate (struct mm_struct *mm, pmd_t *pmd_entry, struct page *pte) 108pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte)
125{ 109{
126 pmd_val(*pmd_entry) = page_to_phys(pte); 110 pmd_val(*pmd_entry) = page_to_phys(pte);
127} 111}
128 112
129static inline void 113static inline void
130pmd_populate_kernel (struct mm_struct *mm, pmd_t *pmd_entry, pte_t *pte) 114pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
131{ 115{
132 pmd_val(*pmd_entry) = __pa(pte); 116 pmd_val(*pmd_entry) = __pa(pte);
133} 117}
134 118
135static inline struct page * 119static inline struct page *pte_alloc_one(struct mm_struct *mm,
136pte_alloc_one (struct mm_struct *mm, unsigned long addr) 120 unsigned long addr)
137{ 121{
138 struct page *pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); 122 return virt_to_page(pgtable_quicklist_alloc());
139
140 return pte;
141} 123}
142 124
143static inline pte_t * 125static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
144pte_alloc_one_kernel (struct mm_struct *mm, unsigned long addr) 126 unsigned long addr)
145{ 127{
146 pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); 128 return pgtable_quicklist_alloc();
147
148 return pte;
149} 129}
150 130
151static inline void 131static inline void pte_free(struct page *pte)
152pte_free (struct page *pte)
153{ 132{
154 __free_page(pte); 133 pgtable_quicklist_free(page_address(pte));
155} 134}
156 135
157static inline void 136static inline void pte_free_kernel(pte_t * pte)
158pte_free_kernel (pte_t *pte)
159{ 137{
160 free_page((unsigned long) pte); 138 pgtable_quicklist_free(pte);
161} 139}
162 140
163#define __pte_free_tlb(tlb, pte) tlb_remove_page((tlb), (pte)) 141#define __pte_free_tlb(tlb, pte) pte_free(pte)
164 142
165extern void check_pgt_cache (void); 143extern void check_pgt_cache(void);
166 144
167#endif /* _ASM_IA64_PGALLOC_H */ 145#endif /* _ASM_IA64_PGALLOC_H */
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 2807f8d766d4..9e1ba8b7fb68 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -137,9 +137,6 @@ struct cpuinfo_ia64 {
137 __u64 nsec_per_cyc; /* (1000000000<<IA64_NSEC_PER_CYC_SHIFT)/itc_freq */ 137 __u64 nsec_per_cyc; /* (1000000000<<IA64_NSEC_PER_CYC_SHIFT)/itc_freq */
138 __u64 unimpl_va_mask; /* mask of unimplemented virtual address bits (from PAL) */ 138 __u64 unimpl_va_mask; /* mask of unimplemented virtual address bits (from PAL) */
139 __u64 unimpl_pa_mask; /* mask of unimplemented physical address bits (from PAL) */ 139 __u64 unimpl_pa_mask; /* mask of unimplemented physical address bits (from PAL) */
140 __u64 *pgd_quick;
141 __u64 *pmd_quick;
142 __u64 pgtable_cache_sz;
143 __u64 itc_freq; /* frequency of ITC counter */ 140 __u64 itc_freq; /* frequency of ITC counter */
144 __u64 proc_freq; /* frequency of processor */ 141 __u64 proc_freq; /* frequency of processor */
145 __u64 cyc_per_usec; /* itc_freq/1000000 */ 142 __u64 cyc_per_usec; /* itc_freq/1000000 */
@@ -151,6 +148,13 @@ struct cpuinfo_ia64 {
151#ifdef CONFIG_SMP 148#ifdef CONFIG_SMP
152 __u64 loops_per_jiffy; 149 __u64 loops_per_jiffy;
153 int cpu; 150 int cpu;
151 __u32 socket_id; /* physical processor socket id */
152 __u16 core_id; /* core id */
153 __u16 thread_id; /* thread id */
154 __u16 num_log; /* Total number of logical processors on
155 * this socket that were successfully booted */
156 __u8 cores_per_socket; /* Cores per processor socket */
157 __u8 threads_per_core; /* Threads per core */
154#endif 158#endif
155 159
156 /* CPUID-derived information: */ 160 /* CPUID-derived information: */
diff --git a/include/asm-ia64/sal.h b/include/asm-ia64/sal.h
index ea1ed377de4c..29df88bdd2bc 100644
--- a/include/asm-ia64/sal.h
+++ b/include/asm-ia64/sal.h
@@ -91,6 +91,7 @@ extern spinlock_t sal_lock;
91#define SAL_PCI_CONFIG_READ 0x01000010 91#define SAL_PCI_CONFIG_READ 0x01000010
92#define SAL_PCI_CONFIG_WRITE 0x01000011 92#define SAL_PCI_CONFIG_WRITE 0x01000011
93#define SAL_FREQ_BASE 0x01000012 93#define SAL_FREQ_BASE 0x01000012
94#define SAL_PHYSICAL_ID_INFO 0x01000013
94 95
95#define SAL_UPDATE_PAL 0x01000020 96#define SAL_UPDATE_PAL 0x01000020
96 97
@@ -815,6 +816,17 @@ ia64_sal_update_pal (u64 param_buf, u64 scratch_buf, u64 scratch_buf_size,
815 return isrv.status; 816 return isrv.status;
816} 817}
817 818
819/* Get physical processor die mapping in the platform. */
820static inline s64
821ia64_sal_physical_id_info(u16 *splid)
822{
823 struct ia64_sal_retval isrv;
824 SAL_CALL(isrv, SAL_PHYSICAL_ID_INFO, 0, 0, 0, 0, 0, 0, 0);
825 if (splid)
826 *splid = isrv.v0;
827 return isrv.status;
828}
829
818extern unsigned long sal_platform_features; 830extern unsigned long sal_platform_features;
819 831
820extern int (*salinfo_platform_oemdata)(const u8 *, u8 **, u64 *); 832extern int (*salinfo_platform_oemdata)(const u8 *, u8 **, u64 *);
@@ -832,6 +844,44 @@ extern int ia64_sal_oemcall_nolock(struct ia64_sal_retval *, u64, u64, u64,
832 u64, u64, u64, u64, u64); 844 u64, u64, u64, u64, u64);
833extern int ia64_sal_oemcall_reentrant(struct ia64_sal_retval *, u64, u64, u64, 845extern int ia64_sal_oemcall_reentrant(struct ia64_sal_retval *, u64, u64, u64,
834 u64, u64, u64, u64, u64); 846 u64, u64, u64, u64, u64);
847#ifdef CONFIG_HOTPLUG_CPU
848/*
849 * System Abstraction Layer Specification
850 * Section 3.2.5.1: OS_BOOT_RENDEZ to SAL return State.
851 * Note: region regs are stored first in head.S _start. Hence they must
852 * stay up front.
853 */
854struct sal_to_os_boot {
855 u64 rr[8]; /* Region Registers */
856 u64 br[6]; /* br0: return addr into SAL boot rendez routine */
857 u64 gr1; /* SAL:GP */
858 u64 gr12; /* SAL:SP */
859 u64 gr13; /* SAL: Task Pointer */
860 u64 fpsr;
861 u64 pfs;
862 u64 rnat;
863 u64 unat;
864 u64 bspstore;
865 u64 dcr; /* Default Control Register */
866 u64 iva;
867 u64 pta;
868 u64 itv;
869 u64 pmv;
870 u64 cmcv;
871 u64 lrr[2];
872 u64 gr[4];
873 u64 pr; /* Predicate registers */
874 u64 lc; /* Loop Count */
875 struct ia64_fpreg fp[20];
876};
877
878/*
879 * Global array allocated for NR_CPUS at boot time
880 */
881extern struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
882
883extern void ia64_jump_to_sal(struct sal_to_os_boot *);
884#endif
835 885
836extern void ia64_sal_handler_init(void *entry_point, void *gpval); 886extern void ia64_sal_handler_init(void *entry_point, void *gpval);
837 887
diff --git a/include/asm-ia64/siginfo.h b/include/asm-ia64/siginfo.h
index d55f139cbcdc..9294e4b0c8bc 100644
--- a/include/asm-ia64/siginfo.h
+++ b/include/asm-ia64/siginfo.h
@@ -8,9 +8,7 @@
8 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co 8 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
9 */ 9 */
10 10
11#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 4) 11#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
12
13#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
14 12
15#define HAVE_ARCH_SIGINFO_T 13#define HAVE_ARCH_SIGINFO_T
16#define HAVE_ARCH_COPY_SIGINFO 14#define HAVE_ARCH_COPY_SIGINFO
diff --git a/include/asm-ia64/signal.h b/include/asm-ia64/signal.h
index 660a759744dd..608168d713d3 100644
--- a/include/asm-ia64/signal.h
+++ b/include/asm-ia64/signal.h
@@ -114,27 +114,11 @@
114#define _NSIG_BPW 64 114#define _NSIG_BPW 64
115#define _NSIG_WORDS (_NSIG / _NSIG_BPW) 115#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
116 116
117/*
118 * These values of sa_flags are used only by the kernel as part of the
119 * irq handling routines.
120 *
121 * SA_INTERRUPT is also used by the irq handling routines.
122 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
123 */
124#define SA_PROBE SA_ONESHOT
125#define SA_SAMPLE_RANDOM SA_RESTART
126#define SA_SHIRQ 0x04000000
127#define SA_PERCPU_IRQ 0x02000000 117#define SA_PERCPU_IRQ 0x02000000
128 118
129#endif /* __KERNEL__ */ 119#endif /* __KERNEL__ */
130 120
131#define SIG_BLOCK 0 /* for blocking signals */ 121#include <asm-generic/signal.h>
132#define SIG_UNBLOCK 1 /* for unblocking signals */
133#define SIG_SETMASK 2 /* for setting the signal mask */
134
135#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
136#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
137#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
138 122
139# ifndef __ASSEMBLY__ 123# ifndef __ASSEMBLY__
140 124
@@ -143,9 +127,6 @@
143/* Avoid too many header ordering problems. */ 127/* Avoid too many header ordering problems. */
144struct siginfo; 128struct siginfo;
145 129
146/* Type of a signal handler. */
147typedef void __user (*__sighandler_t)(int);
148
149typedef struct sigaltstack { 130typedef struct sigaltstack {
150 void __user *ss_sp; 131 void __user *ss_sp;
151 int ss_flags; 132 int ss_flags;
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index c4a227acfeb0..3ba1a061e4ae 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -56,6 +56,10 @@ extern struct smp_boot_data {
56extern char no_int_routing __devinitdata; 56extern char no_int_routing __devinitdata;
57 57
58extern cpumask_t cpu_online_map; 58extern cpumask_t cpu_online_map;
59extern cpumask_t cpu_core_map[NR_CPUS];
60extern cpumask_t cpu_sibling_map[NR_CPUS];
61extern int smp_num_siblings;
62extern int smp_num_cpucores;
59extern void __iomem *ipi_base_addr; 63extern void __iomem *ipi_base_addr;
60extern unsigned char smp_int_redirect; 64extern unsigned char smp_int_redirect;
61 65
@@ -124,6 +128,7 @@ extern int smp_call_function_single (int cpuid, void (*func) (void *info), void
124extern void smp_send_reschedule (int cpu); 128extern void smp_send_reschedule (int cpu);
125extern void lock_ipi_calllock(void); 129extern void lock_ipi_calllock(void);
126extern void unlock_ipi_calllock(void); 130extern void unlock_ipi_calllock(void);
131extern void identify_siblings (struct cpuinfo_ia64 *);
127 132
128#else 133#else
129 134
diff --git a/include/asm-ia64/sn/addrs.h b/include/asm-ia64/sn/addrs.h
index c916bd22767a..1bfdfb4d7b01 100644
--- a/include/asm-ia64/sn/addrs.h
+++ b/include/asm-ia64/sn/addrs.h
@@ -136,6 +136,7 @@
136 */ 136 */
137#define CAC_BASE (CACHED | AS_CAC_SPACE) 137#define CAC_BASE (CACHED | AS_CAC_SPACE)
138#define AMO_BASE (UNCACHED | AS_AMO_SPACE) 138#define AMO_BASE (UNCACHED | AS_AMO_SPACE)
139#define AMO_PHYS_BASE (UNCACHED_PHYS | AS_AMO_SPACE)
139#define GET_BASE (CACHED | AS_GET_SPACE) 140#define GET_BASE (CACHED | AS_GET_SPACE)
140 141
141/* 142/*
@@ -154,12 +155,20 @@
154 * the chiplet id is zero. If we implement TIO-TIO dma, we might need 155 * the chiplet id is zero. If we implement TIO-TIO dma, we might need
155 * to insert a chiplet id into this macro. However, it is our belief 156 * to insert a chiplet id into this macro. However, it is our belief
156 * right now that this chiplet id will be ICE, which is also zero. 157 * right now that this chiplet id will be ICE, which is also zero.
158 * Nasid starts on bit 40.
157 */ 159 */
158#define PHYS_TO_TIODMA(x) ( (((u64)(x) & NASID_MASK) << 2) | NODE_OFFSET(x)) 160#define PHYS_TO_TIODMA(x) ( (((u64)(NASID_GET(x))) << 40) | NODE_OFFSET(x))
159#define PHYS_TO_DMA(x) ( (((u64)(x) & NASID_MASK) >> 2) | NODE_OFFSET(x)) 161#define PHYS_TO_DMA(x) ( (((u64)(x) & NASID_MASK) >> 2) | NODE_OFFSET(x))
160 162
161 163
162/* 164/*
165 * Macros to test for address type.
166 */
167#define IS_AMO_ADDRESS(x) (((u64)(x) & (REGION_BITS | AS_MASK)) == AMO_BASE)
168#define IS_AMO_PHYS_ADDRESS(x) (((u64)(x) & (REGION_BITS | AS_MASK)) == AMO_PHYS_BASE)
169
170
171/*
163 * The following definitions pertain to the IO special address 172 * The following definitions pertain to the IO special address
164 * space. They define the location of the big and little windows 173 * space. They define the location of the big and little windows
165 * of any given node. 174 * of any given node.
@@ -168,7 +177,10 @@
168#define TIO_BWIN_SIZE_BITS 30 /* big window size: 1G */ 177#define TIO_BWIN_SIZE_BITS 30 /* big window size: 1G */
169#define NODE_SWIN_BASE(n, w) ((w == 0) ? NODE_BWIN_BASE((n), SWIN0_BIGWIN) \ 178#define NODE_SWIN_BASE(n, w) ((w == 0) ? NODE_BWIN_BASE((n), SWIN0_BIGWIN) \
170 : RAW_NODE_SWIN_BASE(n, w)) 179 : RAW_NODE_SWIN_BASE(n, w))
180#define TIO_SWIN_BASE(n, w) (TIO_IO_BASE(n) + \
181 ((u64) (w) << TIO_SWIN_SIZE_BITS))
171#define NODE_IO_BASE(n) (GLOBAL_MMR_SPACE | NASID_SPACE(n)) 182#define NODE_IO_BASE(n) (GLOBAL_MMR_SPACE | NASID_SPACE(n))
183#define TIO_IO_BASE(n) (UNCACHED | NASID_SPACE(n))
172#define BWIN_SIZE (1UL << BWIN_SIZE_BITS) 184#define BWIN_SIZE (1UL << BWIN_SIZE_BITS)
173#define NODE_BWIN_BASE0(n) (NODE_IO_BASE(n) + BWIN_SIZE) 185#define NODE_BWIN_BASE0(n) (NODE_IO_BASE(n) + BWIN_SIZE)
174#define NODE_BWIN_BASE(n, w) (NODE_BWIN_BASE0(n) + ((u64) (w) << BWIN_SIZE_BITS)) 186#define NODE_BWIN_BASE(n, w) (NODE_BWIN_BASE0(n) + ((u64) (w) << BWIN_SIZE_BITS))
diff --git a/include/asm-ia64/sn/arch.h b/include/asm-ia64/sn/arch.h
index 7c349f07916a..635fdce854a8 100644
--- a/include/asm-ia64/sn/arch.h
+++ b/include/asm-ia64/sn/arch.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * SGI specific setup. 6 * SGI specific setup.
7 * 7 *
8 * Copyright (C) 1995-1997,1999,2001-2004 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 1995-1997,1999,2001-2005 Silicon Graphics, Inc. All rights reserved.
9 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org) 9 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org)
10 */ 10 */
11#ifndef _ASM_IA64_SN_ARCH_H 11#ifndef _ASM_IA64_SN_ARCH_H
@@ -47,6 +47,21 @@ DECLARE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
47#define MAX_COMPACT_NODES 2048 47#define MAX_COMPACT_NODES 2048
48#define CPUS_PER_NODE 4 48#define CPUS_PER_NODE 4
49 49
50
51/*
52 * Compact node ID to nasid mappings kept in the per-cpu data areas of each
53 * cpu.
54 */
55DECLARE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_NUMNODES]);
56#define sn_cnodeid_to_nasid (&__get_cpu_var(__sn_cnodeid_to_nasid[0]))
57
58
59
60extern u8 sn_partition_id;
61extern u8 sn_system_size;
62extern u8 sn_sharing_domain_size;
63extern u8 sn_region_size;
64
50extern void sn_flush_all_caches(long addr, long bytes); 65extern void sn_flush_all_caches(long addr, long bytes);
51 66
52#endif /* _ASM_IA64_SN_ARCH_H */ 67#endif /* _ASM_IA64_SN_ARCH_H */
diff --git a/include/asm-ia64/sn/bte.h b/include/asm-ia64/sn/bte.h
index 0ec27f99c181..f50da3d91d07 100644
--- a/include/asm-ia64/sn/bte.h
+++ b/include/asm-ia64/sn/bte.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9 9
@@ -13,8 +13,12 @@
13#include <linux/timer.h> 13#include <linux/timer.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/cache.h> 15#include <linux/cache.h>
16#include <asm/sn/pda.h>
16#include <asm/sn/types.h> 17#include <asm/sn/types.h>
18#include <asm/sn/shub_mmr.h>
17 19
20#define IBCT_NOTIFY (0x1UL << 4)
21#define IBCT_ZFIL_MODE (0x1UL << 0)
18 22
19/* #define BTE_DEBUG */ 23/* #define BTE_DEBUG */
20/* #define BTE_DEBUG_VERBOSE */ 24/* #define BTE_DEBUG_VERBOSE */
@@ -39,8 +43,36 @@
39 43
40 44
41/* Define hardware */ 45/* Define hardware */
42#define BTES_PER_NODE 2 46#define BTES_PER_NODE (is_shub2() ? 4 : 2)
47#define MAX_BTES_PER_NODE 4
43 48
49#define BTE2OFF_CTRL (0)
50#define BTE2OFF_SRC (SH2_BT_ENG_SRC_ADDR_0 - SH2_BT_ENG_CSR_0)
51#define BTE2OFF_DEST (SH2_BT_ENG_DEST_ADDR_0 - SH2_BT_ENG_CSR_0)
52#define BTE2OFF_NOTIFY (SH2_BT_ENG_NOTIF_ADDR_0 - SH2_BT_ENG_CSR_0)
53
54#define BTE_BASE_ADDR(interface) \
55 (is_shub2() ? (interface == 0) ? SH2_BT_ENG_CSR_0 : \
56 (interface == 1) ? SH2_BT_ENG_CSR_1 : \
57 (interface == 2) ? SH2_BT_ENG_CSR_2 : \
58 SH2_BT_ENG_CSR_3 \
59 : (interface == 0) ? IIO_IBLS0 : IIO_IBLS1)
60
61#define BTE_SOURCE_ADDR(base) \
62 (is_shub2() ? base + (BTE2OFF_SRC/8) \
63 : base + (BTEOFF_SRC/8))
64
65#define BTE_DEST_ADDR(base) \
66 (is_shub2() ? base + (BTE2OFF_DEST/8) \
67 : base + (BTEOFF_DEST/8))
68
69#define BTE_CTRL_ADDR(base) \
70 (is_shub2() ? base + (BTE2OFF_CTRL/8) \
71 : base + (BTEOFF_CTRL/8))
72
73#define BTE_NOTIF_ADDR(base) \
74 (is_shub2() ? base + (BTE2OFF_NOTIFY/8) \
75 : base + (BTEOFF_NOTIFY/8))
44 76
45/* Define hardware modes */ 77/* Define hardware modes */
46#define BTE_NOTIFY (IBCT_NOTIFY) 78#define BTE_NOTIFY (IBCT_NOTIFY)
@@ -68,14 +100,18 @@
68#define BTE_LNSTAT_STORE(_bte, _x) \ 100#define BTE_LNSTAT_STORE(_bte, _x) \
69 HUB_S(_bte->bte_base_addr, (_x)) 101 HUB_S(_bte->bte_base_addr, (_x))
70#define BTE_SRC_STORE(_bte, _x) \ 102#define BTE_SRC_STORE(_bte, _x) \
71 HUB_S(_bte->bte_base_addr + (BTEOFF_SRC/8), (_x)) 103 HUB_S(_bte->bte_source_addr, (_x))
72#define BTE_DEST_STORE(_bte, _x) \ 104#define BTE_DEST_STORE(_bte, _x) \
73 HUB_S(_bte->bte_base_addr + (BTEOFF_DEST/8), (_x)) 105 HUB_S(_bte->bte_destination_addr, (_x))
74#define BTE_CTRL_STORE(_bte, _x) \ 106#define BTE_CTRL_STORE(_bte, _x) \
75 HUB_S(_bte->bte_base_addr + (BTEOFF_CTRL/8), (_x)) 107 HUB_S(_bte->bte_control_addr, (_x))
76#define BTE_NOTIF_STORE(_bte, _x) \ 108#define BTE_NOTIF_STORE(_bte, _x) \
77 HUB_S(_bte->bte_base_addr + (BTEOFF_NOTIFY/8), (_x)) 109 HUB_S(_bte->bte_notify_addr, (_x))
78 110
111#define BTE_START_TRANSFER(_bte, _len, _mode) \
112 is_shub2() ? BTE_CTRL_STORE(_bte, IBLS_BUSY | (_mode << 24) | _len) \
113 : BTE_LNSTAT_STORE(_bte, _len); \
114 BTE_CTRL_STORE(_bte, _mode)
79 115
80/* Possible results from bte_copy and bte_unaligned_copy */ 116/* Possible results from bte_copy and bte_unaligned_copy */
81/* The following error codes map into the BTE hardware codes 117/* The following error codes map into the BTE hardware codes
@@ -110,6 +146,10 @@ typedef enum {
110struct bteinfo_s { 146struct bteinfo_s {
111 volatile u64 notify ____cacheline_aligned; 147 volatile u64 notify ____cacheline_aligned;
112 u64 *bte_base_addr ____cacheline_aligned; 148 u64 *bte_base_addr ____cacheline_aligned;
149 u64 *bte_source_addr;
150 u64 *bte_destination_addr;
151 u64 *bte_control_addr;
152 u64 *bte_notify_addr;
113 spinlock_t spinlock; 153 spinlock_t spinlock;
114 cnodeid_t bte_cnode; /* cnode */ 154 cnodeid_t bte_cnode; /* cnode */
115 int bte_error_count; /* Number of errors encountered */ 155 int bte_error_count; /* Number of errors encountered */
@@ -117,6 +157,7 @@ struct bteinfo_s {
117 int cleanup_active; /* Interface is locked for cleanup */ 157 int cleanup_active; /* Interface is locked for cleanup */
118 volatile bte_result_t bh_error; /* error while processing */ 158 volatile bte_result_t bh_error; /* error while processing */
119 volatile u64 *most_rcnt_na; 159 volatile u64 *most_rcnt_na;
160 struct bteinfo_s *btes_to_try[MAX_BTES_PER_NODE];
120}; 161};
121 162
122 163
diff --git a/include/asm-ia64/sn/fetchop.h b/include/asm-ia64/sn/fetchop.h
deleted file mode 100644
index 5f4ad8f4b5d2..000000000000
--- a/include/asm-ia64/sn/fetchop.h
+++ /dev/null
@@ -1,85 +0,0 @@
1/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All rights reserved.
8 */
9
10#ifndef _ASM_IA64_SN_FETCHOP_H
11#define _ASM_IA64_SN_FETCHOP_H
12
13#include <linux/config.h>
14
15#define FETCHOP_BASENAME "sgi_fetchop"
16#define FETCHOP_FULLNAME "/dev/sgi_fetchop"
17
18
19
20#define FETCHOP_VAR_SIZE 64 /* 64 byte per fetchop variable */
21
22#define FETCHOP_LOAD 0
23#define FETCHOP_INCREMENT 8
24#define FETCHOP_DECREMENT 16
25#define FETCHOP_CLEAR 24
26
27#define FETCHOP_STORE 0
28#define FETCHOP_AND 24
29#define FETCHOP_OR 32
30
31#define FETCHOP_CLEAR_CACHE 56
32
33#define FETCHOP_LOAD_OP(addr, op) ( \
34 *(volatile long *)((char*) (addr) + (op)))
35
36#define FETCHOP_STORE_OP(addr, op, x) ( \
37 *(volatile long *)((char*) (addr) + (op)) = (long) (x))
38
39#ifdef __KERNEL__
40
41/*
42 * Convert a region 6 (kaddr) address to the address of the fetchop variable
43 */
44#define FETCHOP_KADDR_TO_MSPEC_ADDR(kaddr) TO_MSPEC(kaddr)
45
46
47/*
48 * Each Atomic Memory Operation (AMO formerly known as fetchop)
49 * variable is 64 bytes long. The first 8 bytes are used. The
50 * remaining 56 bytes are unaddressable due to the operation taking
51 * that portion of the address.
52 *
53 * NOTE: The AMO_t _MUST_ be placed in either the first or second half
54 * of the cache line. The cache line _MUST NOT_ be used for anything
55 * other than additional AMO_t entries. This is because there are two
56 * addresses which reference the same physical cache line. One will
57 * be a cached entry with the memory type bits all set. This address
58 * may be loaded into processor cache. The AMO_t will be referenced
59 * uncached via the memory special memory type. If any portion of the
60 * cached cache-line is modified, when that line is flushed, it will
61 * overwrite the uncached value in physical memory and lead to
62 * inconsistency.
63 */
64typedef struct {
65 u64 variable;
66 u64 unused[7];
67} AMO_t;
68
69
70/*
71 * The following APIs are externalized to the kernel to allocate/free pages of
72 * fetchop variables.
73 * fetchop_kalloc_page - Allocate/initialize 1 fetchop page on the
74 * specified cnode.
75 * fetchop_kfree_page - Free a previously allocated fetchop page
76 */
77
78unsigned long fetchop_kalloc_page(int nid);
79void fetchop_kfree_page(unsigned long maddr);
80
81
82#endif /* __KERNEL__ */
83
84#endif /* _ASM_IA64_SN_FETCHOP_H */
85
diff --git a/include/asm-ia64/sn/geo.h b/include/asm-ia64/sn/geo.h
index f566343d25f8..84b254603b8d 100644
--- a/include/asm-ia64/sn/geo.h
+++ b/include/asm-ia64/sn/geo.h
@@ -18,32 +18,34 @@
18#define GEOID_SIZE 8 /* Would 16 be better? The size can 18#define GEOID_SIZE 8 /* Would 16 be better? The size can
19 be different on different platforms. */ 19 be different on different platforms. */
20 20
21#define MAX_SLABS 0xe /* slabs per module */ 21#define MAX_SLOTS 0xf /* slots per module */
22#define MAX_SLABS 0xf /* slabs per slot */
22 23
23typedef unsigned char geo_type_t; 24typedef unsigned char geo_type_t;
24 25
25/* Fields common to all substructures */ 26/* Fields common to all substructures */
26typedef struct geo_any_s { 27typedef struct geo_common_s {
27 moduleid_t module; /* The module (box) this h/w lives in */ 28 moduleid_t module; /* The module (box) this h/w lives in */
28 geo_type_t type; /* What type of h/w is named by this geoid_t */ 29 geo_type_t type; /* What type of h/w is named by this geoid_t */
29 slabid_t slab; /* The logical assembly within the module */ 30 slabid_t slab:4; /* slab (ASIC), 0 .. 15 within slot */
30} geo_any_t; 31 slotid_t slot:4; /* slot (Blade), 0 .. 15 within module */
32} geo_common_t;
31 33
32/* Additional fields for particular types of hardware */ 34/* Additional fields for particular types of hardware */
33typedef struct geo_node_s { 35typedef struct geo_node_s {
34 geo_any_t any; /* No additional fields needed */ 36 geo_common_t common; /* No additional fields needed */
35} geo_node_t; 37} geo_node_t;
36 38
37typedef struct geo_rtr_s { 39typedef struct geo_rtr_s {
38 geo_any_t any; /* No additional fields needed */ 40 geo_common_t common; /* No additional fields needed */
39} geo_rtr_t; 41} geo_rtr_t;
40 42
41typedef struct geo_iocntl_s { 43typedef struct geo_iocntl_s {
42 geo_any_t any; /* No additional fields needed */ 44 geo_common_t common; /* No additional fields needed */
43} geo_iocntl_t; 45} geo_iocntl_t;
44 46
45typedef struct geo_pcicard_s { 47typedef struct geo_pcicard_s {
46 geo_iocntl_t any; 48 geo_iocntl_t common;
47 char bus; /* Bus/widget number */ 49 char bus; /* Bus/widget number */
48 char slot; /* PCI slot number */ 50 char slot; /* PCI slot number */
49} geo_pcicard_t; 51} geo_pcicard_t;
@@ -62,14 +64,14 @@ typedef struct geo_mem_s {
62 64
63 65
64typedef union geoid_u { 66typedef union geoid_u {
65 geo_any_t any; 67 geo_common_t common;
66 geo_node_t node; 68 geo_node_t node;
67 geo_iocntl_t iocntl; 69 geo_iocntl_t iocntl;
68 geo_pcicard_t pcicard; 70 geo_pcicard_t pcicard;
69 geo_rtr_t rtr; 71 geo_rtr_t rtr;
70 geo_cpu_t cpu; 72 geo_cpu_t cpu;
71 geo_mem_t mem; 73 geo_mem_t mem;
72 char padsize[GEOID_SIZE]; 74 char padsize[GEOID_SIZE];
73} geoid_t; 75} geoid_t;
74 76
75 77
@@ -104,19 +106,26 @@ typedef union geoid_u {
104#define INVALID_CNODEID ((cnodeid_t)-1) 106#define INVALID_CNODEID ((cnodeid_t)-1)
105#define INVALID_PNODEID ((pnodeid_t)-1) 107#define INVALID_PNODEID ((pnodeid_t)-1)
106#define INVALID_SLAB (slabid_t)-1 108#define INVALID_SLAB (slabid_t)-1
109#define INVALID_SLOT (slotid_t)-1
107#define INVALID_MODULE ((moduleid_t)-1) 110#define INVALID_MODULE ((moduleid_t)-1)
108#define INVALID_PARTID ((partid_t)-1) 111#define INVALID_PARTID ((partid_t)-1)
109 112
110static inline slabid_t geo_slab(geoid_t g) 113static inline slabid_t geo_slab(geoid_t g)
111{ 114{
112 return (g.any.type == GEO_TYPE_INVALID) ? 115 return (g.common.type == GEO_TYPE_INVALID) ?
113 INVALID_SLAB : g.any.slab; 116 INVALID_SLAB : g.common.slab;
117}
118
119static inline slotid_t geo_slot(geoid_t g)
120{
121 return (g.common.type == GEO_TYPE_INVALID) ?
122 INVALID_SLOT : g.common.slot;
114} 123}
115 124
116static inline moduleid_t geo_module(geoid_t g) 125static inline moduleid_t geo_module(geoid_t g)
117{ 126{
118 return (g.any.type == GEO_TYPE_INVALID) ? 127 return (g.common.type == GEO_TYPE_INVALID) ?
119 INVALID_MODULE : g.any.module; 128 INVALID_MODULE : g.common.module;
120} 129}
121 130
122extern geoid_t cnodeid_get_geoid(cnodeid_t cnode); 131extern geoid_t cnodeid_get_geoid(cnodeid_t cnode);
diff --git a/include/asm-ia64/sn/l1.h b/include/asm-ia64/sn/l1.h
index d5dbd55e44b5..08050d37b662 100644
--- a/include/asm-ia64/sn/l1.h
+++ b/include/asm-ia64/sn/l1.h
@@ -29,8 +29,9 @@
29#define L1_BRICKTYPE_CHI_CG 0x76 /* v */ 29#define L1_BRICKTYPE_CHI_CG 0x76 /* v */
30#define L1_BRICKTYPE_X 0x78 /* x */ 30#define L1_BRICKTYPE_X 0x78 /* x */
31#define L1_BRICKTYPE_X2 0x79 /* y */ 31#define L1_BRICKTYPE_X2 0x79 /* y */
32#define L1_BRICKTYPE_SA 0x5e /* ^ */ /* TIO bringup brick */ 32#define L1_BRICKTYPE_SA 0x5e /* ^ */
33#define L1_BRICKTYPE_PA 0x6a /* j */ 33#define L1_BRICKTYPE_PA 0x6a /* j */
34#define L1_BRICKTYPE_IA 0x6b /* k */ 34#define L1_BRICKTYPE_IA 0x6b /* k */
35#define L1_BRICKTYPE_ATHENA 0x2b /* + */
35 36
36#endif /* _ASM_IA64_SN_L1_H */ 37#endif /* _ASM_IA64_SN_L1_H */
diff --git a/include/asm-ia64/sn/nodepda.h b/include/asm-ia64/sn/nodepda.h
index 2fbde33656e6..7138b1eafd6b 100644
--- a/include/asm-ia64/sn/nodepda.h
+++ b/include/asm-ia64/sn/nodepda.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8#ifndef _ASM_IA64_SN_NODEPDA_H 8#ifndef _ASM_IA64_SN_NODEPDA_H
9#define _ASM_IA64_SN_NODEPDA_H 9#define _ASM_IA64_SN_NODEPDA_H
@@ -13,7 +13,6 @@
13#include <asm/irq.h> 13#include <asm/irq.h>
14#include <asm/sn/arch.h> 14#include <asm/sn/arch.h>
15#include <asm/sn/intr.h> 15#include <asm/sn/intr.h>
16#include <asm/sn/pda.h>
17#include <asm/sn/bte.h> 16#include <asm/sn/bte.h>
18 17
19/* 18/*
@@ -43,7 +42,7 @@ struct nodepda_s {
43 /* 42 /*
44 * The BTEs on this node are shared by the local cpus 43 * The BTEs on this node are shared by the local cpus
45 */ 44 */
46 struct bteinfo_s bte_if[BTES_PER_NODE]; /* Virtual Interface */ 45 struct bteinfo_s bte_if[MAX_BTES_PER_NODE]; /* Virtual Interface */
47 struct timer_list bte_recovery_timer; 46 struct timer_list bte_recovery_timer;
48 spinlock_t bte_recovery_lock; 47 spinlock_t bte_recovery_lock;
49 48
@@ -67,20 +66,18 @@ typedef struct nodepda_s nodepda_t;
67 * The next set of definitions provides this. 66 * The next set of definitions provides this.
68 * Routines are expected to use 67 * Routines are expected to use
69 * 68 *
70 * nodepda -> to access node PDA for the node on which code is running 69 * sn_nodepda - to access node PDA for the node on which code is running
71 * subnodepda -> to access subnode PDA for the subnode on which code is running 70 * NODEPDA(cnodeid) - to access node PDA for cnodeid
72 *
73 * NODEPDA(cnode) -> to access node PDA for cnodeid
74 * SUBNODEPDA(cnode,sn) -> to access subnode PDA for cnodeid/subnode
75 */ 71 */
76 72
77#define nodepda pda->p_nodepda /* Ptr to this node's PDA */ 73DECLARE_PER_CPU(struct nodepda_s *, __sn_nodepda);
78#define NODEPDA(cnode) (nodepda->pernode_pdaindr[cnode]) 74#define sn_nodepda (__get_cpu_var(__sn_nodepda))
75#define NODEPDA(cnodeid) (sn_nodepda->pernode_pdaindr[cnodeid])
79 76
80/* 77/*
81 * Check if given a compact node id the corresponding node has all the 78 * Check if given a compact node id the corresponding node has all the
82 * cpus disabled. 79 * cpus disabled.
83 */ 80 */
84#define is_headless_node(cnode) (nr_cpus_node(cnode) == 0) 81#define is_headless_node(cnodeid) (nr_cpus_node(cnodeid) == 0)
85 82
86#endif /* _ASM_IA64_SN_NODEPDA_H */ 83#endif /* _ASM_IA64_SN_NODEPDA_H */
diff --git a/arch/ia64/sn/include/pci/pcibus_provider_defs.h b/include/asm-ia64/sn/pcibus_provider_defs.h
index 07065615bbea..04e27d5b3820 100644
--- a/arch/ia64/sn/include/pci/pcibus_provider_defs.h
+++ b/include/asm-ia64/sn/pcibus_provider_defs.h
@@ -17,6 +17,9 @@
17#define PCIIO_ASIC_TYPE_PPB 1 17#define PCIIO_ASIC_TYPE_PPB 1
18#define PCIIO_ASIC_TYPE_PIC 2 18#define PCIIO_ASIC_TYPE_PIC 2
19#define PCIIO_ASIC_TYPE_TIOCP 3 19#define PCIIO_ASIC_TYPE_TIOCP 3
20#define PCIIO_ASIC_TYPE_TIOCA 4
21
22#define PCIIO_ASIC_MAX_TYPES 5
20 23
21/* 24/*
22 * Common pciio bus provider data. There should be one of these as the 25 * Common pciio bus provider data. There should be one of these as the
@@ -35,9 +38,15 @@ struct pcibus_bussoft {
35}; 38};
36 39
37/* 40/*
38 * DMA mapping flags 41 * SN pci bus indirection
39 */ 42 */
40 43
41#define SN_PCIDMA_CONSISTENT 0x0001 44struct sn_pcibus_provider {
45 dma_addr_t (*dma_map)(struct pci_dev *, unsigned long, size_t);
46 dma_addr_t (*dma_map_consistent)(struct pci_dev *, unsigned long, size_t);
47 void (*dma_unmap)(struct pci_dev *, dma_addr_t, int);
48 void * (*bus_fixup)(struct pcibus_bussoft *);
49};
42 50
51extern struct sn_pcibus_provider *sn_pci_provider[];
43#endif /* _ASM_IA64_SN_PCI_PCIBUS_PROVIDER_H */ 52#endif /* _ASM_IA64_SN_PCI_PCIBUS_PROVIDER_H */
diff --git a/arch/ia64/sn/include/pci/pcidev.h b/include/asm-ia64/sn/pcidev.h
index 81eb95d3bf47..ed4031d80811 100644
--- a/arch/ia64/sn/include/pci/pcidev.h
+++ b/include/asm-ia64/sn/pcidev.h
@@ -32,6 +32,9 @@ extern struct sn_irq_info **sn_irq;
32#define SN_PCIDEV_BUSSOFT(pci_dev) \ 32#define SN_PCIDEV_BUSSOFT(pci_dev) \
33 (SN_PCIDEV_INFO(pci_dev)->pdi_host_pcidev_info->pdi_pcibus_info) 33 (SN_PCIDEV_INFO(pci_dev)->pdi_host_pcidev_info->pdi_pcibus_info)
34 34
35#define SN_PCIDEV_BUSPROVIDER(pci_dev) \
36 (SN_PCIDEV_INFO(pci_dev)->pdi_provider)
37
35#define PCIIO_BUS_NONE 255 /* bus 255 reserved */ 38#define PCIIO_BUS_NONE 255 /* bus 255 reserved */
36#define PCIIO_SLOT_NONE 255 39#define PCIIO_SLOT_NONE 255
37#define PCIIO_FUNC_NONE 255 40#define PCIIO_FUNC_NONE 255
@@ -46,6 +49,7 @@ struct pcidev_info {
46 struct pci_dev *pdi_linux_pcidev; /* Kernel pci_dev */ 49 struct pci_dev *pdi_linux_pcidev; /* Kernel pci_dev */
47 50
48 struct sn_irq_info *pdi_sn_irq_info; 51 struct sn_irq_info *pdi_sn_irq_info;
52 struct sn_pcibus_provider *pdi_provider; /* sn pci ops */
49}; 53};
50 54
51extern void sn_irq_fixup(struct pci_dev *pci_dev, 55extern void sn_irq_fixup(struct pci_dev *pci_dev,
diff --git a/include/asm-ia64/sn/pda.h b/include/asm-ia64/sn/pda.h
index e940d3647c80..ea5590c76ca4 100644
--- a/include/asm-ia64/sn/pda.h
+++ b/include/asm-ia64/sn/pda.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8#ifndef _ASM_IA64_SN_PDA_H 8#ifndef _ASM_IA64_SN_PDA_H
9#define _ASM_IA64_SN_PDA_H 9#define _ASM_IA64_SN_PDA_H
@@ -11,7 +11,6 @@
11#include <linux/cache.h> 11#include <linux/cache.h>
12#include <asm/percpu.h> 12#include <asm/percpu.h>
13#include <asm/system.h> 13#include <asm/system.h>
14#include <asm/sn/bte.h>
15 14
16 15
17/* 16/*
@@ -25,14 +24,6 @@
25 24
26typedef struct pda_s { 25typedef struct pda_s {
27 26
28 /* Having a pointer in the begining of PDA tends to increase
29 * the chance of having this pointer in cache. (Yes something
30 * else gets pushed out). Doing this reduces the number of memory
31 * access to all nodepda variables to be one
32 */
33 struct nodepda_s *p_nodepda; /* Pointer to Per node PDA */
34 struct subnodepda_s *p_subnodepda; /* Pointer to CPU subnode PDA */
35
36 /* 27 /*
37 * Support for SN LEDs 28 * Support for SN LEDs
38 */ 29 */
@@ -50,7 +41,6 @@ typedef struct pda_s {
50 41
51 unsigned long sn_soft_irr[4]; 42 unsigned long sn_soft_irr[4];
52 unsigned long sn_in_service_ivecs[4]; 43 unsigned long sn_in_service_ivecs[4];
53 short cnodeid_to_nasid_table[MAX_NUMNODES];
54 int sn_lb_int_war_ticks; 44 int sn_lb_int_war_ticks;
55 int sn_last_irq; 45 int sn_last_irq;
56 int sn_first_irq; 46 int sn_first_irq;
diff --git a/include/asm-ia64/sn/shub_mmr.h b/include/asm-ia64/sn/shub_mmr.h
index 5c2fcf13d5ce..323fa0cd8d83 100644
--- a/include/asm-ia64/sn/shub_mmr.h
+++ b/include/asm-ia64/sn/shub_mmr.h
@@ -4,7 +4,7 @@
4 * License. See the file "COPYING" in the main directory of this archive 4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details. 5 * for more details.
6 * 6 *
7 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All rights reserved. 7 * Copyright (c) 2001-2005 Silicon Graphics, Inc. All rights reserved.
8 */ 8 */
9 9
10#ifndef _ASM_IA64_SN_SHUB_MMR_H 10#ifndef _ASM_IA64_SN_SHUB_MMR_H
@@ -129,6 +129,23 @@
129#define SH_EVENT_OCCURRED_II_INT1_SHFT 30 129#define SH_EVENT_OCCURRED_II_INT1_SHFT 30
130#define SH_EVENT_OCCURRED_II_INT1_MASK 0x0000000040000000 130#define SH_EVENT_OCCURRED_II_INT1_MASK 0x0000000040000000
131 131
132/* SH2_EVENT_OCCURRED_EXTIO_INT2 */
133/* Description: Pending SHUB 2 EXT IO INT2 */
134#define SH2_EVENT_OCCURRED_EXTIO_INT2_SHFT 33
135#define SH2_EVENT_OCCURRED_EXTIO_INT2_MASK 0x0000000200000000
136
137/* SH2_EVENT_OCCURRED_EXTIO_INT3 */
138/* Description: Pending SHUB 2 EXT IO INT3 */
139#define SH2_EVENT_OCCURRED_EXTIO_INT3_SHFT 34
140#define SH2_EVENT_OCCURRED_EXTIO_INT3_MASK 0x0000000400000000
141
142#define SH_ALL_INT_MASK \
143 (SH_EVENT_OCCURRED_UART_INT_MASK | SH_EVENT_OCCURRED_IPI_INT_MASK | \
144 SH_EVENT_OCCURRED_II_INT0_MASK | SH_EVENT_OCCURRED_II_INT1_MASK | \
145 SH_EVENT_OCCURRED_II_INT1_MASK | SH2_EVENT_OCCURRED_EXTIO_INT2_MASK | \
146 SH2_EVENT_OCCURRED_EXTIO_INT3_MASK)
147
148
132/* ==================================================================== */ 149/* ==================================================================== */
133/* LEDS */ 150/* LEDS */
134/* ==================================================================== */ 151/* ==================================================================== */
@@ -368,6 +385,17 @@
368#define SH_EVENT_OCCURRED_RTC3_INT_MASK 0x0000000004000000 385#define SH_EVENT_OCCURRED_RTC3_INT_MASK 0x0000000004000000
369 386
370/* ==================================================================== */ 387/* ==================================================================== */
388/* Register "SH_IPI_ACCESS" */
389/* CPU interrupt Access Permission Bits */
390/* ==================================================================== */
391
392#define SH1_IPI_ACCESS 0x0000000110060480
393#define SH2_IPI_ACCESS0 0x0000000010060c00
394#define SH2_IPI_ACCESS1 0x0000000010060c80
395#define SH2_IPI_ACCESS2 0x0000000010060d00
396#define SH2_IPI_ACCESS3 0x0000000010060d80
397
398/* ==================================================================== */
371/* Register "SH_INT_CMPB" */ 399/* Register "SH_INT_CMPB" */
372/* RTC Compare Value for Processor B */ 400/* RTC Compare Value for Processor B */
373/* ==================================================================== */ 401/* ==================================================================== */
@@ -412,6 +440,19 @@
412#define SH_INT_CMPD_REAL_TIME_CMPD_SHFT 0 440#define SH_INT_CMPD_REAL_TIME_CMPD_SHFT 0
413#define SH_INT_CMPD_REAL_TIME_CMPD_MASK 0x007fffffffffffff 441#define SH_INT_CMPD_REAL_TIME_CMPD_MASK 0x007fffffffffffff
414 442
443/* ==================================================================== */
444/* Register "SH_MD_DQLP_MMR_DIR_PRIVEC0" */
445/* privilege vector for acc=0 */
446/* ==================================================================== */
447
448#define SH1_MD_DQLP_MMR_DIR_PRIVEC0 0x0000000100030300
449
450/* ==================================================================== */
451/* Register "SH_MD_DQRP_MMR_DIR_PRIVEC0" */
452/* privilege vector for acc=0 */
453/* ==================================================================== */
454
455#define SH1_MD_DQRP_MMR_DIR_PRIVEC0 0x0000000100050300
415 456
416/* ==================================================================== */ 457/* ==================================================================== */
417/* Some MMRs are functionally identical (or close enough) on both SHUB1 */ 458/* Some MMRs are functionally identical (or close enough) on both SHUB1 */
@@ -438,4 +479,22 @@
438#define SH_INT_CMPC shubmmr(SH, INT_CMPC) 479#define SH_INT_CMPC shubmmr(SH, INT_CMPC)
439#define SH_INT_CMPD shubmmr(SH, INT_CMPD) 480#define SH_INT_CMPD shubmmr(SH, INT_CMPD)
440 481
482/* ========================================================================== */
483/* Register "SH2_BT_ENG_CSR_0" */
484/* Engine 0 Control and Status Register */
485/* ========================================================================== */
486
487#define SH2_BT_ENG_CSR_0 0x0000000030040000
488#define SH2_BT_ENG_SRC_ADDR_0 0x0000000030040080
489#define SH2_BT_ENG_DEST_ADDR_0 0x0000000030040100
490#define SH2_BT_ENG_NOTIF_ADDR_0 0x0000000030040180
491
492/* ========================================================================== */
493/* BTE interfaces 1-3 */
494/* ========================================================================== */
495
496#define SH2_BT_ENG_CSR_1 0x0000000030050000
497#define SH2_BT_ENG_CSR_2 0x0000000030060000
498#define SH2_BT_ENG_CSR_3 0x0000000030070000
499
441#endif /* _ASM_IA64_SN_SHUB_MMR_H */ 500#endif /* _ASM_IA64_SN_SHUB_MMR_H */
diff --git a/include/asm-ia64/sn/shubio.h b/include/asm-ia64/sn/shubio.h
index fbd880e6bb96..831b72111fdc 100644
--- a/include/asm-ia64/sn/shubio.h
+++ b/include/asm-ia64/sn/shubio.h
@@ -3,292 +3,287 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#ifndef _ASM_IA64_SN_SHUBIO_H 9#ifndef _ASM_IA64_SN_SHUBIO_H
10#define _ASM_IA64_SN_SHUBIO_H 10#define _ASM_IA64_SN_SHUBIO_H
11 11
12#define HUB_WIDGET_ID_MAX 0xf 12#define HUB_WIDGET_ID_MAX 0xf
13#define IIO_NUM_ITTES 7 13#define IIO_NUM_ITTES 7
14#define HUB_NUM_BIG_WINDOW (IIO_NUM_ITTES - 1) 14#define HUB_NUM_BIG_WINDOW (IIO_NUM_ITTES - 1)
15 15
16#define IIO_WID 0x00400000 /* Crosstalk Widget Identification */ 16#define IIO_WID 0x00400000 /* Crosstalk Widget Identification */
17 /* This register is also accessible from 17 /* This register is also accessible from
18 * Crosstalk at address 0x0. */ 18 * Crosstalk at address 0x0. */
19#define IIO_WSTAT 0x00400008 /* Crosstalk Widget Status */ 19#define IIO_WSTAT 0x00400008 /* Crosstalk Widget Status */
20#define IIO_WCR 0x00400020 /* Crosstalk Widget Control Register */ 20#define IIO_WCR 0x00400020 /* Crosstalk Widget Control Register */
21#define IIO_ILAPR 0x00400100 /* IO Local Access Protection Register */ 21#define IIO_ILAPR 0x00400100 /* IO Local Access Protection Register */
22#define IIO_ILAPO 0x00400108 /* IO Local Access Protection Override */ 22#define IIO_ILAPO 0x00400108 /* IO Local Access Protection Override */
23#define IIO_IOWA 0x00400110 /* IO Outbound Widget Access */ 23#define IIO_IOWA 0x00400110 /* IO Outbound Widget Access */
24#define IIO_IIWA 0x00400118 /* IO Inbound Widget Access */ 24#define IIO_IIWA 0x00400118 /* IO Inbound Widget Access */
25#define IIO_IIDEM 0x00400120 /* IO Inbound Device Error Mask */ 25#define IIO_IIDEM 0x00400120 /* IO Inbound Device Error Mask */
26#define IIO_ILCSR 0x00400128 /* IO LLP Control and Status Register */ 26#define IIO_ILCSR 0x00400128 /* IO LLP Control and Status Register */
27#define IIO_ILLR 0x00400130 /* IO LLP Log Register */ 27#define IIO_ILLR 0x00400130 /* IO LLP Log Register */
28#define IIO_IIDSR 0x00400138 /* IO Interrupt Destination */ 28#define IIO_IIDSR 0x00400138 /* IO Interrupt Destination */
29 29
30#define IIO_IGFX0 0x00400140 /* IO Graphics Node-Widget Map 0 */ 30#define IIO_IGFX0 0x00400140 /* IO Graphics Node-Widget Map 0 */
31#define IIO_IGFX1 0x00400148 /* IO Graphics Node-Widget Map 1 */ 31#define IIO_IGFX1 0x00400148 /* IO Graphics Node-Widget Map 1 */
32 32
33#define IIO_ISCR0 0x00400150 /* IO Scratch Register 0 */ 33#define IIO_ISCR0 0x00400150 /* IO Scratch Register 0 */
34#define IIO_ISCR1 0x00400158 /* IO Scratch Register 1 */ 34#define IIO_ISCR1 0x00400158 /* IO Scratch Register 1 */
35 35
36#define IIO_ITTE1 0x00400160 /* IO Translation Table Entry 1 */ 36#define IIO_ITTE1 0x00400160 /* IO Translation Table Entry 1 */
37#define IIO_ITTE2 0x00400168 /* IO Translation Table Entry 2 */ 37#define IIO_ITTE2 0x00400168 /* IO Translation Table Entry 2 */
38#define IIO_ITTE3 0x00400170 /* IO Translation Table Entry 3 */ 38#define IIO_ITTE3 0x00400170 /* IO Translation Table Entry 3 */
39#define IIO_ITTE4 0x00400178 /* IO Translation Table Entry 4 */ 39#define IIO_ITTE4 0x00400178 /* IO Translation Table Entry 4 */
40#define IIO_ITTE5 0x00400180 /* IO Translation Table Entry 5 */ 40#define IIO_ITTE5 0x00400180 /* IO Translation Table Entry 5 */
41#define IIO_ITTE6 0x00400188 /* IO Translation Table Entry 6 */ 41#define IIO_ITTE6 0x00400188 /* IO Translation Table Entry 6 */
42#define IIO_ITTE7 0x00400190 /* IO Translation Table Entry 7 */ 42#define IIO_ITTE7 0x00400190 /* IO Translation Table Entry 7 */
43 43
44#define IIO_IPRB0 0x00400198 /* IO PRB Entry 0 */ 44#define IIO_IPRB0 0x00400198 /* IO PRB Entry 0 */
45#define IIO_IPRB8 0x004001A0 /* IO PRB Entry 8 */ 45#define IIO_IPRB8 0x004001A0 /* IO PRB Entry 8 */
46#define IIO_IPRB9 0x004001A8 /* IO PRB Entry 9 */ 46#define IIO_IPRB9 0x004001A8 /* IO PRB Entry 9 */
47#define IIO_IPRBA 0x004001B0 /* IO PRB Entry A */ 47#define IIO_IPRBA 0x004001B0 /* IO PRB Entry A */
48#define IIO_IPRBB 0x004001B8 /* IO PRB Entry B */ 48#define IIO_IPRBB 0x004001B8 /* IO PRB Entry B */
49#define IIO_IPRBC 0x004001C0 /* IO PRB Entry C */ 49#define IIO_IPRBC 0x004001C0 /* IO PRB Entry C */
50#define IIO_IPRBD 0x004001C8 /* IO PRB Entry D */ 50#define IIO_IPRBD 0x004001C8 /* IO PRB Entry D */
51#define IIO_IPRBE 0x004001D0 /* IO PRB Entry E */ 51#define IIO_IPRBE 0x004001D0 /* IO PRB Entry E */
52#define IIO_IPRBF 0x004001D8 /* IO PRB Entry F */ 52#define IIO_IPRBF 0x004001D8 /* IO PRB Entry F */
53 53
54#define IIO_IXCC 0x004001E0 /* IO Crosstalk Credit Count Timeout */ 54#define IIO_IXCC 0x004001E0 /* IO Crosstalk Credit Count Timeout */
55#define IIO_IMEM 0x004001E8 /* IO Miscellaneous Error Mask */ 55#define IIO_IMEM 0x004001E8 /* IO Miscellaneous Error Mask */
56#define IIO_IXTT 0x004001F0 /* IO Crosstalk Timeout Threshold */ 56#define IIO_IXTT 0x004001F0 /* IO Crosstalk Timeout Threshold */
57#define IIO_IECLR 0x004001F8 /* IO Error Clear Register */ 57#define IIO_IECLR 0x004001F8 /* IO Error Clear Register */
58#define IIO_IBCR 0x00400200 /* IO BTE Control Register */ 58#define IIO_IBCR 0x00400200 /* IO BTE Control Register */
59 59
60#define IIO_IXSM 0x00400208 /* IO Crosstalk Spurious Message */ 60#define IIO_IXSM 0x00400208 /* IO Crosstalk Spurious Message */
61#define IIO_IXSS 0x00400210 /* IO Crosstalk Spurious Sideband */ 61#define IIO_IXSS 0x00400210 /* IO Crosstalk Spurious Sideband */
62 62
63#define IIO_ILCT 0x00400218 /* IO LLP Channel Test */ 63#define IIO_ILCT 0x00400218 /* IO LLP Channel Test */
64 64
65#define IIO_IIEPH1 0x00400220 /* IO Incoming Error Packet Header, Part 1 */ 65#define IIO_IIEPH1 0x00400220 /* IO Incoming Error Packet Header, Part 1 */
66#define IIO_IIEPH2 0x00400228 /* IO Incoming Error Packet Header, Part 2 */ 66#define IIO_IIEPH2 0x00400228 /* IO Incoming Error Packet Header, Part 2 */
67 67
68 68#define IIO_ISLAPR 0x00400230 /* IO SXB Local Access Protection Regster */
69#define IIO_ISLAPR 0x00400230 /* IO SXB Local Access Protection Regster */ 69#define IIO_ISLAPO 0x00400238 /* IO SXB Local Access Protection Override */
70#define IIO_ISLAPO 0x00400238 /* IO SXB Local Access Protection Override */ 70
71 71#define IIO_IWI 0x00400240 /* IO Wrapper Interrupt Register */
72#define IIO_IWI 0x00400240 /* IO Wrapper Interrupt Register */ 72#define IIO_IWEL 0x00400248 /* IO Wrapper Error Log Register */
73#define IIO_IWEL 0x00400248 /* IO Wrapper Error Log Register */ 73#define IIO_IWC 0x00400250 /* IO Wrapper Control Register */
74#define IIO_IWC 0x00400250 /* IO Wrapper Control Register */ 74#define IIO_IWS 0x00400258 /* IO Wrapper Status Register */
75#define IIO_IWS 0x00400258 /* IO Wrapper Status Register */ 75#define IIO_IWEIM 0x00400260 /* IO Wrapper Error Interrupt Masking Register */
76#define IIO_IWEIM 0x00400260 /* IO Wrapper Error Interrupt Masking Register */ 76
77 77#define IIO_IPCA 0x00400300 /* IO PRB Counter Adjust */
78#define IIO_IPCA 0x00400300 /* IO PRB Counter Adjust */ 78
79 79#define IIO_IPRTE0_A 0x00400308 /* IO PIO Read Address Table Entry 0, Part A */
80#define IIO_IPRTE0_A 0x00400308 /* IO PIO Read Address Table Entry 0, Part A */ 80#define IIO_IPRTE1_A 0x00400310 /* IO PIO Read Address Table Entry 1, Part A */
81#define IIO_IPRTE1_A 0x00400310 /* IO PIO Read Address Table Entry 1, Part A */ 81#define IIO_IPRTE2_A 0x00400318 /* IO PIO Read Address Table Entry 2, Part A */
82#define IIO_IPRTE2_A 0x00400318 /* IO PIO Read Address Table Entry 2, Part A */ 82#define IIO_IPRTE3_A 0x00400320 /* IO PIO Read Address Table Entry 3, Part A */
83#define IIO_IPRTE3_A 0x00400320 /* IO PIO Read Address Table Entry 3, Part A */ 83#define IIO_IPRTE4_A 0x00400328 /* IO PIO Read Address Table Entry 4, Part A */
84#define IIO_IPRTE4_A 0x00400328 /* IO PIO Read Address Table Entry 4, Part A */ 84#define IIO_IPRTE5_A 0x00400330 /* IO PIO Read Address Table Entry 5, Part A */
85#define IIO_IPRTE5_A 0x00400330 /* IO PIO Read Address Table Entry 5, Part A */ 85#define IIO_IPRTE6_A 0x00400338 /* IO PIO Read Address Table Entry 6, Part A */
86#define IIO_IPRTE6_A 0x00400338 /* IO PIO Read Address Table Entry 6, Part A */ 86#define IIO_IPRTE7_A 0x00400340 /* IO PIO Read Address Table Entry 7, Part A */
87#define IIO_IPRTE7_A 0x00400340 /* IO PIO Read Address Table Entry 7, Part A */ 87
88 88#define IIO_IPRTE0_B 0x00400348 /* IO PIO Read Address Table Entry 0, Part B */
89#define IIO_IPRTE0_B 0x00400348 /* IO PIO Read Address Table Entry 0, Part B */ 89#define IIO_IPRTE1_B 0x00400350 /* IO PIO Read Address Table Entry 1, Part B */
90#define IIO_IPRTE1_B 0x00400350 /* IO PIO Read Address Table Entry 1, Part B */ 90#define IIO_IPRTE2_B 0x00400358 /* IO PIO Read Address Table Entry 2, Part B */
91#define IIO_IPRTE2_B 0x00400358 /* IO PIO Read Address Table Entry 2, Part B */ 91#define IIO_IPRTE3_B 0x00400360 /* IO PIO Read Address Table Entry 3, Part B */
92#define IIO_IPRTE3_B 0x00400360 /* IO PIO Read Address Table Entry 3, Part B */ 92#define IIO_IPRTE4_B 0x00400368 /* IO PIO Read Address Table Entry 4, Part B */
93#define IIO_IPRTE4_B 0x00400368 /* IO PIO Read Address Table Entry 4, Part B */ 93#define IIO_IPRTE5_B 0x00400370 /* IO PIO Read Address Table Entry 5, Part B */
94#define IIO_IPRTE5_B 0x00400370 /* IO PIO Read Address Table Entry 5, Part B */ 94#define IIO_IPRTE6_B 0x00400378 /* IO PIO Read Address Table Entry 6, Part B */
95#define IIO_IPRTE6_B 0x00400378 /* IO PIO Read Address Table Entry 6, Part B */ 95#define IIO_IPRTE7_B 0x00400380 /* IO PIO Read Address Table Entry 7, Part B */
96#define IIO_IPRTE7_B 0x00400380 /* IO PIO Read Address Table Entry 7, Part B */ 96
97 97#define IIO_IPDR 0x00400388 /* IO PIO Deallocation Register */
98#define IIO_IPDR 0x00400388 /* IO PIO Deallocation Register */ 98#define IIO_ICDR 0x00400390 /* IO CRB Entry Deallocation Register */
99#define IIO_ICDR 0x00400390 /* IO CRB Entry Deallocation Register */ 99#define IIO_IFDR 0x00400398 /* IO IOQ FIFO Depth Register */
100#define IIO_IFDR 0x00400398 /* IO IOQ FIFO Depth Register */ 100#define IIO_IIAP 0x004003A0 /* IO IIQ Arbitration Parameters */
101#define IIO_IIAP 0x004003A0 /* IO IIQ Arbitration Parameters */ 101#define IIO_ICMR 0x004003A8 /* IO CRB Management Register */
102#define IIO_ICMR 0x004003A8 /* IO CRB Management Register */ 102#define IIO_ICCR 0x004003B0 /* IO CRB Control Register */
103#define IIO_ICCR 0x004003B0 /* IO CRB Control Register */ 103#define IIO_ICTO 0x004003B8 /* IO CRB Timeout */
104#define IIO_ICTO 0x004003B8 /* IO CRB Timeout */ 104#define IIO_ICTP 0x004003C0 /* IO CRB Timeout Prescalar */
105#define IIO_ICTP 0x004003C0 /* IO CRB Timeout Prescalar */ 105
106 106#define IIO_ICRB0_A 0x00400400 /* IO CRB Entry 0_A */
107#define IIO_ICRB0_A 0x00400400 /* IO CRB Entry 0_A */ 107#define IIO_ICRB0_B 0x00400408 /* IO CRB Entry 0_B */
108#define IIO_ICRB0_B 0x00400408 /* IO CRB Entry 0_B */ 108#define IIO_ICRB0_C 0x00400410 /* IO CRB Entry 0_C */
109#define IIO_ICRB0_C 0x00400410 /* IO CRB Entry 0_C */ 109#define IIO_ICRB0_D 0x00400418 /* IO CRB Entry 0_D */
110#define IIO_ICRB0_D 0x00400418 /* IO CRB Entry 0_D */ 110#define IIO_ICRB0_E 0x00400420 /* IO CRB Entry 0_E */
111#define IIO_ICRB0_E 0x00400420 /* IO CRB Entry 0_E */ 111
112 112#define IIO_ICRB1_A 0x00400430 /* IO CRB Entry 1_A */
113#define IIO_ICRB1_A 0x00400430 /* IO CRB Entry 1_A */ 113#define IIO_ICRB1_B 0x00400438 /* IO CRB Entry 1_B */
114#define IIO_ICRB1_B 0x00400438 /* IO CRB Entry 1_B */ 114#define IIO_ICRB1_C 0x00400440 /* IO CRB Entry 1_C */
115#define IIO_ICRB1_C 0x00400440 /* IO CRB Entry 1_C */ 115#define IIO_ICRB1_D 0x00400448 /* IO CRB Entry 1_D */
116#define IIO_ICRB1_D 0x00400448 /* IO CRB Entry 1_D */ 116#define IIO_ICRB1_E 0x00400450 /* IO CRB Entry 1_E */
117#define IIO_ICRB1_E 0x00400450 /* IO CRB Entry 1_E */ 117
118 118#define IIO_ICRB2_A 0x00400460 /* IO CRB Entry 2_A */
119#define IIO_ICRB2_A 0x00400460 /* IO CRB Entry 2_A */ 119#define IIO_ICRB2_B 0x00400468 /* IO CRB Entry 2_B */
120#define IIO_ICRB2_B 0x00400468 /* IO CRB Entry 2_B */ 120#define IIO_ICRB2_C 0x00400470 /* IO CRB Entry 2_C */
121#define IIO_ICRB2_C 0x00400470 /* IO CRB Entry 2_C */ 121#define IIO_ICRB2_D 0x00400478 /* IO CRB Entry 2_D */
122#define IIO_ICRB2_D 0x00400478 /* IO CRB Entry 2_D */ 122#define IIO_ICRB2_E 0x00400480 /* IO CRB Entry 2_E */
123#define IIO_ICRB2_E 0x00400480 /* IO CRB Entry 2_E */ 123
124 124#define IIO_ICRB3_A 0x00400490 /* IO CRB Entry 3_A */
125#define IIO_ICRB3_A 0x00400490 /* IO CRB Entry 3_A */ 125#define IIO_ICRB3_B 0x00400498 /* IO CRB Entry 3_B */
126#define IIO_ICRB3_B 0x00400498 /* IO CRB Entry 3_B */ 126#define IIO_ICRB3_C 0x004004a0 /* IO CRB Entry 3_C */
127#define IIO_ICRB3_C 0x004004a0 /* IO CRB Entry 3_C */ 127#define IIO_ICRB3_D 0x004004a8 /* IO CRB Entry 3_D */
128#define IIO_ICRB3_D 0x004004a8 /* IO CRB Entry 3_D */ 128#define IIO_ICRB3_E 0x004004b0 /* IO CRB Entry 3_E */
129#define IIO_ICRB3_E 0x004004b0 /* IO CRB Entry 3_E */ 129
130 130#define IIO_ICRB4_A 0x004004c0 /* IO CRB Entry 4_A */
131#define IIO_ICRB4_A 0x004004c0 /* IO CRB Entry 4_A */ 131#define IIO_ICRB4_B 0x004004c8 /* IO CRB Entry 4_B */
132#define IIO_ICRB4_B 0x004004c8 /* IO CRB Entry 4_B */ 132#define IIO_ICRB4_C 0x004004d0 /* IO CRB Entry 4_C */
133#define IIO_ICRB4_C 0x004004d0 /* IO CRB Entry 4_C */ 133#define IIO_ICRB4_D 0x004004d8 /* IO CRB Entry 4_D */
134#define IIO_ICRB4_D 0x004004d8 /* IO CRB Entry 4_D */ 134#define IIO_ICRB4_E 0x004004e0 /* IO CRB Entry 4_E */
135#define IIO_ICRB4_E 0x004004e0 /* IO CRB Entry 4_E */ 135
136 136#define IIO_ICRB5_A 0x004004f0 /* IO CRB Entry 5_A */
137#define IIO_ICRB5_A 0x004004f0 /* IO CRB Entry 5_A */ 137#define IIO_ICRB5_B 0x004004f8 /* IO CRB Entry 5_B */
138#define IIO_ICRB5_B 0x004004f8 /* IO CRB Entry 5_B */ 138#define IIO_ICRB5_C 0x00400500 /* IO CRB Entry 5_C */
139#define IIO_ICRB5_C 0x00400500 /* IO CRB Entry 5_C */ 139#define IIO_ICRB5_D 0x00400508 /* IO CRB Entry 5_D */
140#define IIO_ICRB5_D 0x00400508 /* IO CRB Entry 5_D */ 140#define IIO_ICRB5_E 0x00400510 /* IO CRB Entry 5_E */
141#define IIO_ICRB5_E 0x00400510 /* IO CRB Entry 5_E */ 141
142 142#define IIO_ICRB6_A 0x00400520 /* IO CRB Entry 6_A */
143#define IIO_ICRB6_A 0x00400520 /* IO CRB Entry 6_A */ 143#define IIO_ICRB6_B 0x00400528 /* IO CRB Entry 6_B */
144#define IIO_ICRB6_B 0x00400528 /* IO CRB Entry 6_B */ 144#define IIO_ICRB6_C 0x00400530 /* IO CRB Entry 6_C */
145#define IIO_ICRB6_C 0x00400530 /* IO CRB Entry 6_C */ 145#define IIO_ICRB6_D 0x00400538 /* IO CRB Entry 6_D */
146#define IIO_ICRB6_D 0x00400538 /* IO CRB Entry 6_D */ 146#define IIO_ICRB6_E 0x00400540 /* IO CRB Entry 6_E */
147#define IIO_ICRB6_E 0x00400540 /* IO CRB Entry 6_E */ 147
148 148#define IIO_ICRB7_A 0x00400550 /* IO CRB Entry 7_A */
149#define IIO_ICRB7_A 0x00400550 /* IO CRB Entry 7_A */ 149#define IIO_ICRB7_B 0x00400558 /* IO CRB Entry 7_B */
150#define IIO_ICRB7_B 0x00400558 /* IO CRB Entry 7_B */ 150#define IIO_ICRB7_C 0x00400560 /* IO CRB Entry 7_C */
151#define IIO_ICRB7_C 0x00400560 /* IO CRB Entry 7_C */ 151#define IIO_ICRB7_D 0x00400568 /* IO CRB Entry 7_D */
152#define IIO_ICRB7_D 0x00400568 /* IO CRB Entry 7_D */ 152#define IIO_ICRB7_E 0x00400570 /* IO CRB Entry 7_E */
153#define IIO_ICRB7_E 0x00400570 /* IO CRB Entry 7_E */ 153
154 154#define IIO_ICRB8_A 0x00400580 /* IO CRB Entry 8_A */
155#define IIO_ICRB8_A 0x00400580 /* IO CRB Entry 8_A */ 155#define IIO_ICRB8_B 0x00400588 /* IO CRB Entry 8_B */
156#define IIO_ICRB8_B 0x00400588 /* IO CRB Entry 8_B */ 156#define IIO_ICRB8_C 0x00400590 /* IO CRB Entry 8_C */
157#define IIO_ICRB8_C 0x00400590 /* IO CRB Entry 8_C */ 157#define IIO_ICRB8_D 0x00400598 /* IO CRB Entry 8_D */
158#define IIO_ICRB8_D 0x00400598 /* IO CRB Entry 8_D */ 158#define IIO_ICRB8_E 0x004005a0 /* IO CRB Entry 8_E */
159#define IIO_ICRB8_E 0x004005a0 /* IO CRB Entry 8_E */ 159
160 160#define IIO_ICRB9_A 0x004005b0 /* IO CRB Entry 9_A */
161#define IIO_ICRB9_A 0x004005b0 /* IO CRB Entry 9_A */ 161#define IIO_ICRB9_B 0x004005b8 /* IO CRB Entry 9_B */
162#define IIO_ICRB9_B 0x004005b8 /* IO CRB Entry 9_B */ 162#define IIO_ICRB9_C 0x004005c0 /* IO CRB Entry 9_C */
163#define IIO_ICRB9_C 0x004005c0 /* IO CRB Entry 9_C */ 163#define IIO_ICRB9_D 0x004005c8 /* IO CRB Entry 9_D */
164#define IIO_ICRB9_D 0x004005c8 /* IO CRB Entry 9_D */ 164#define IIO_ICRB9_E 0x004005d0 /* IO CRB Entry 9_E */
165#define IIO_ICRB9_E 0x004005d0 /* IO CRB Entry 9_E */ 165
166 166#define IIO_ICRBA_A 0x004005e0 /* IO CRB Entry A_A */
167#define IIO_ICRBA_A 0x004005e0 /* IO CRB Entry A_A */ 167#define IIO_ICRBA_B 0x004005e8 /* IO CRB Entry A_B */
168#define IIO_ICRBA_B 0x004005e8 /* IO CRB Entry A_B */ 168#define IIO_ICRBA_C 0x004005f0 /* IO CRB Entry A_C */
169#define IIO_ICRBA_C 0x004005f0 /* IO CRB Entry A_C */ 169#define IIO_ICRBA_D 0x004005f8 /* IO CRB Entry A_D */
170#define IIO_ICRBA_D 0x004005f8 /* IO CRB Entry A_D */ 170#define IIO_ICRBA_E 0x00400600 /* IO CRB Entry A_E */
171#define IIO_ICRBA_E 0x00400600 /* IO CRB Entry A_E */ 171
172 172#define IIO_ICRBB_A 0x00400610 /* IO CRB Entry B_A */
173#define IIO_ICRBB_A 0x00400610 /* IO CRB Entry B_A */ 173#define IIO_ICRBB_B 0x00400618 /* IO CRB Entry B_B */
174#define IIO_ICRBB_B 0x00400618 /* IO CRB Entry B_B */ 174#define IIO_ICRBB_C 0x00400620 /* IO CRB Entry B_C */
175#define IIO_ICRBB_C 0x00400620 /* IO CRB Entry B_C */ 175#define IIO_ICRBB_D 0x00400628 /* IO CRB Entry B_D */
176#define IIO_ICRBB_D 0x00400628 /* IO CRB Entry B_D */ 176#define IIO_ICRBB_E 0x00400630 /* IO CRB Entry B_E */
177#define IIO_ICRBB_E 0x00400630 /* IO CRB Entry B_E */ 177
178 178#define IIO_ICRBC_A 0x00400640 /* IO CRB Entry C_A */
179#define IIO_ICRBC_A 0x00400640 /* IO CRB Entry C_A */ 179#define IIO_ICRBC_B 0x00400648 /* IO CRB Entry C_B */
180#define IIO_ICRBC_B 0x00400648 /* IO CRB Entry C_B */ 180#define IIO_ICRBC_C 0x00400650 /* IO CRB Entry C_C */
181#define IIO_ICRBC_C 0x00400650 /* IO CRB Entry C_C */ 181#define IIO_ICRBC_D 0x00400658 /* IO CRB Entry C_D */
182#define IIO_ICRBC_D 0x00400658 /* IO CRB Entry C_D */ 182#define IIO_ICRBC_E 0x00400660 /* IO CRB Entry C_E */
183#define IIO_ICRBC_E 0x00400660 /* IO CRB Entry C_E */ 183
184 184#define IIO_ICRBD_A 0x00400670 /* IO CRB Entry D_A */
185#define IIO_ICRBD_A 0x00400670 /* IO CRB Entry D_A */ 185#define IIO_ICRBD_B 0x00400678 /* IO CRB Entry D_B */
186#define IIO_ICRBD_B 0x00400678 /* IO CRB Entry D_B */ 186#define IIO_ICRBD_C 0x00400680 /* IO CRB Entry D_C */
187#define IIO_ICRBD_C 0x00400680 /* IO CRB Entry D_C */ 187#define IIO_ICRBD_D 0x00400688 /* IO CRB Entry D_D */
188#define IIO_ICRBD_D 0x00400688 /* IO CRB Entry D_D */ 188#define IIO_ICRBD_E 0x00400690 /* IO CRB Entry D_E */
189#define IIO_ICRBD_E 0x00400690 /* IO CRB Entry D_E */ 189
190 190#define IIO_ICRBE_A 0x004006a0 /* IO CRB Entry E_A */
191#define IIO_ICRBE_A 0x004006a0 /* IO CRB Entry E_A */ 191#define IIO_ICRBE_B 0x004006a8 /* IO CRB Entry E_B */
192#define IIO_ICRBE_B 0x004006a8 /* IO CRB Entry E_B */ 192#define IIO_ICRBE_C 0x004006b0 /* IO CRB Entry E_C */
193#define IIO_ICRBE_C 0x004006b0 /* IO CRB Entry E_C */ 193#define IIO_ICRBE_D 0x004006b8 /* IO CRB Entry E_D */
194#define IIO_ICRBE_D 0x004006b8 /* IO CRB Entry E_D */ 194#define IIO_ICRBE_E 0x004006c0 /* IO CRB Entry E_E */
195#define IIO_ICRBE_E 0x004006c0 /* IO CRB Entry E_E */ 195
196 196#define IIO_ICSML 0x00400700 /* IO CRB Spurious Message Low */
197#define IIO_ICSML 0x00400700 /* IO CRB Spurious Message Low */ 197#define IIO_ICSMM 0x00400708 /* IO CRB Spurious Message Middle */
198#define IIO_ICSMM 0x00400708 /* IO CRB Spurious Message Middle */ 198#define IIO_ICSMH 0x00400710 /* IO CRB Spurious Message High */
199#define IIO_ICSMH 0x00400710 /* IO CRB Spurious Message High */ 199
200 200#define IIO_IDBSS 0x00400718 /* IO Debug Submenu Select */
201#define IIO_IDBSS 0x00400718 /* IO Debug Submenu Select */ 201
202 202#define IIO_IBLS0 0x00410000 /* IO BTE Length Status 0 */
203#define IIO_IBLS0 0x00410000 /* IO BTE Length Status 0 */ 203#define IIO_IBSA0 0x00410008 /* IO BTE Source Address 0 */
204#define IIO_IBSA0 0x00410008 /* IO BTE Source Address 0 */ 204#define IIO_IBDA0 0x00410010 /* IO BTE Destination Address 0 */
205#define IIO_IBDA0 0x00410010 /* IO BTE Destination Address 0 */ 205#define IIO_IBCT0 0x00410018 /* IO BTE Control Terminate 0 */
206#define IIO_IBCT0 0x00410018 /* IO BTE Control Terminate 0 */ 206#define IIO_IBNA0 0x00410020 /* IO BTE Notification Address 0 */
207#define IIO_IBNA0 0x00410020 /* IO BTE Notification Address 0 */ 207#define IIO_IBIA0 0x00410028 /* IO BTE Interrupt Address 0 */
208#define IIO_IBIA0 0x00410028 /* IO BTE Interrupt Address 0 */ 208#define IIO_IBLS1 0x00420000 /* IO BTE Length Status 1 */
209#define IIO_IBLS1 0x00420000 /* IO BTE Length Status 1 */ 209#define IIO_IBSA1 0x00420008 /* IO BTE Source Address 1 */
210#define IIO_IBSA1 0x00420008 /* IO BTE Source Address 1 */ 210#define IIO_IBDA1 0x00420010 /* IO BTE Destination Address 1 */
211#define IIO_IBDA1 0x00420010 /* IO BTE Destination Address 1 */ 211#define IIO_IBCT1 0x00420018 /* IO BTE Control Terminate 1 */
212#define IIO_IBCT1 0x00420018 /* IO BTE Control Terminate 1 */ 212#define IIO_IBNA1 0x00420020 /* IO BTE Notification Address 1 */
213#define IIO_IBNA1 0x00420020 /* IO BTE Notification Address 1 */ 213#define IIO_IBIA1 0x00420028 /* IO BTE Interrupt Address 1 */
214#define IIO_IBIA1 0x00420028 /* IO BTE Interrupt Address 1 */ 214
215 215#define IIO_IPCR 0x00430000 /* IO Performance Control */
216#define IIO_IPCR 0x00430000 /* IO Performance Control */ 216#define IIO_IPPR 0x00430008 /* IO Performance Profiling */
217#define IIO_IPPR 0x00430008 /* IO Performance Profiling */ 217
218 218/************************************************************************
219 219 * *
220/************************************************************************
221 * *
222 * Description: This register echoes some information from the * 220 * Description: This register echoes some information from the *
223 * LB_REV_ID register. It is available through Crosstalk as described * 221 * LB_REV_ID register. It is available through Crosstalk as described *
224 * above. The REV_NUM and MFG_NUM fields receive their values from * 222 * above. The REV_NUM and MFG_NUM fields receive their values from *
225 * the REVISION and MANUFACTURER fields in the LB_REV_ID register. * 223 * the REVISION and MANUFACTURER fields in the LB_REV_ID register. *
226 * The PART_NUM field's value is the Crosstalk device ID number that * 224 * The PART_NUM field's value is the Crosstalk device ID number that *
227 * Steve Miller assigned to the SHub chip. * 225 * Steve Miller assigned to the SHub chip. *
228 * * 226 * *
229 ************************************************************************/ 227 ************************************************************************/
230 228
231typedef union ii_wid_u { 229typedef union ii_wid_u {
232 uint64_t ii_wid_regval; 230 uint64_t ii_wid_regval;
233 struct { 231 struct {
234 uint64_t w_rsvd_1 : 1; 232 uint64_t w_rsvd_1:1;
235 uint64_t w_mfg_num : 11; 233 uint64_t w_mfg_num:11;
236 uint64_t w_part_num : 16; 234 uint64_t w_part_num:16;
237 uint64_t w_rev_num : 4; 235 uint64_t w_rev_num:4;
238 uint64_t w_rsvd : 32; 236 uint64_t w_rsvd:32;
239 } ii_wid_fld_s; 237 } ii_wid_fld_s;
240} ii_wid_u_t; 238} ii_wid_u_t;
241 239
242
243/************************************************************************ 240/************************************************************************
244 * * 241 * *
245 * The fields in this register are set upon detection of an error * 242 * The fields in this register are set upon detection of an error *
246 * and cleared by various mechanisms, as explained in the * 243 * and cleared by various mechanisms, as explained in the *
247 * description. * 244 * description. *
248 * * 245 * *
249 ************************************************************************/ 246 ************************************************************************/
250 247
251typedef union ii_wstat_u { 248typedef union ii_wstat_u {
252 uint64_t ii_wstat_regval; 249 uint64_t ii_wstat_regval;
253 struct { 250 struct {
254 uint64_t w_pending : 4; 251 uint64_t w_pending:4;
255 uint64_t w_xt_crd_to : 1; 252 uint64_t w_xt_crd_to:1;
256 uint64_t w_xt_tail_to : 1; 253 uint64_t w_xt_tail_to:1;
257 uint64_t w_rsvd_3 : 3; 254 uint64_t w_rsvd_3:3;
258 uint64_t w_tx_mx_rty : 1; 255 uint64_t w_tx_mx_rty:1;
259 uint64_t w_rsvd_2 : 6; 256 uint64_t w_rsvd_2:6;
260 uint64_t w_llp_tx_cnt : 8; 257 uint64_t w_llp_tx_cnt:8;
261 uint64_t w_rsvd_1 : 8; 258 uint64_t w_rsvd_1:8;
262 uint64_t w_crazy : 1; 259 uint64_t w_crazy:1;
263 uint64_t w_rsvd : 31; 260 uint64_t w_rsvd:31;
264 } ii_wstat_fld_s; 261 } ii_wstat_fld_s;
265} ii_wstat_u_t; 262} ii_wstat_u_t;
266 263
267
268/************************************************************************ 264/************************************************************************
269 * * 265 * *
270 * Description: This is a read-write enabled register. It controls * 266 * Description: This is a read-write enabled register. It controls *
271 * various aspects of the Crosstalk flow control. * 267 * various aspects of the Crosstalk flow control. *
272 * * 268 * *
273 ************************************************************************/ 269 ************************************************************************/
274 270
275typedef union ii_wcr_u { 271typedef union ii_wcr_u {
276 uint64_t ii_wcr_regval; 272 uint64_t ii_wcr_regval;
277 struct { 273 struct {
278 uint64_t w_wid : 4; 274 uint64_t w_wid:4;
279 uint64_t w_tag : 1; 275 uint64_t w_tag:1;
280 uint64_t w_rsvd_1 : 8; 276 uint64_t w_rsvd_1:8;
281 uint64_t w_dst_crd : 3; 277 uint64_t w_dst_crd:3;
282 uint64_t w_f_bad_pkt : 1; 278 uint64_t w_f_bad_pkt:1;
283 uint64_t w_dir_con : 1; 279 uint64_t w_dir_con:1;
284 uint64_t w_e_thresh : 5; 280 uint64_t w_e_thresh:5;
285 uint64_t w_rsvd : 41; 281 uint64_t w_rsvd:41;
286 } ii_wcr_fld_s; 282 } ii_wcr_fld_s;
287} ii_wcr_u_t; 283} ii_wcr_u_t;
288 284
289
290/************************************************************************ 285/************************************************************************
291 * * 286 * *
292 * Description: This register's value is a bit vector that guards * 287 * Description: This register's value is a bit vector that guards *
293 * access to local registers within the II as well as to external * 288 * access to local registers within the II as well as to external *
294 * Crosstalk widgets. Each bit in the register corresponds to a * 289 * Crosstalk widgets. Each bit in the register corresponds to a *
@@ -311,21 +306,18 @@ typedef union ii_wcr_u {
311 * region ID bits are enabled in this same register. It can also be * 306 * region ID bits are enabled in this same register. It can also be *
312 * accessed through the IAlias space by the local processors. * 307 * accessed through the IAlias space by the local processors. *
313 * The reset value of this register allows access by all nodes. * 308 * The reset value of this register allows access by all nodes. *
314 * * 309 * *
315 ************************************************************************/ 310 ************************************************************************/
316 311
317typedef union ii_ilapr_u { 312typedef union ii_ilapr_u {
318 uint64_t ii_ilapr_regval; 313 uint64_t ii_ilapr_regval;
319 struct { 314 struct {
320 uint64_t i_region : 64; 315 uint64_t i_region:64;
321 } ii_ilapr_fld_s; 316 } ii_ilapr_fld_s;
322} ii_ilapr_u_t; 317} ii_ilapr_u_t;
323 318
324
325
326
327/************************************************************************ 319/************************************************************************
328 * * 320 * *
329 * Description: A write to this register of the 64-bit value * 321 * Description: A write to this register of the 64-bit value *
330 * "SGIrules" in ASCII, will cause the bit in the ILAPR register * 322 * "SGIrules" in ASCII, will cause the bit in the ILAPR register *
331 * corresponding to the region of the requestor to be set (allow * 323 * corresponding to the region of the requestor to be set (allow *
@@ -334,59 +326,54 @@ typedef union ii_ilapr_u {
334 * This register can also be accessed through the IAlias space. * 326 * This register can also be accessed through the IAlias space. *
335 * However, this access will not change the access permissions in the * 327 * However, this access will not change the access permissions in the *
336 * ILAPR. * 328 * ILAPR. *
337 * * 329 * *
338 ************************************************************************/ 330 ************************************************************************/
339 331
340typedef union ii_ilapo_u { 332typedef union ii_ilapo_u {
341 uint64_t ii_ilapo_regval; 333 uint64_t ii_ilapo_regval;
342 struct { 334 struct {
343 uint64_t i_io_ovrride : 64; 335 uint64_t i_io_ovrride:64;
344 } ii_ilapo_fld_s; 336 } ii_ilapo_fld_s;
345} ii_ilapo_u_t; 337} ii_ilapo_u_t;
346 338
347
348
349/************************************************************************ 339/************************************************************************
350 * * 340 * *
351 * This register qualifies all the PIO and Graphics writes launched * 341 * This register qualifies all the PIO and Graphics writes launched *
352 * from the SHUB towards a widget. * 342 * from the SHUB towards a widget. *
353 * * 343 * *
354 ************************************************************************/ 344 ************************************************************************/
355 345
356typedef union ii_iowa_u { 346typedef union ii_iowa_u {
357 uint64_t ii_iowa_regval; 347 uint64_t ii_iowa_regval;
358 struct { 348 struct {
359 uint64_t i_w0_oac : 1; 349 uint64_t i_w0_oac:1;
360 uint64_t i_rsvd_1 : 7; 350 uint64_t i_rsvd_1:7;
361 uint64_t i_wx_oac : 8; 351 uint64_t i_wx_oac:8;
362 uint64_t i_rsvd : 48; 352 uint64_t i_rsvd:48;
363 } ii_iowa_fld_s; 353 } ii_iowa_fld_s;
364} ii_iowa_u_t; 354} ii_iowa_u_t;
365 355
366
367/************************************************************************ 356/************************************************************************
368 * * 357 * *
369 * Description: This register qualifies all the requests launched * 358 * Description: This register qualifies all the requests launched *
370 * from a widget towards the Shub. This register is intended to be * 359 * from a widget towards the Shub. This register is intended to be *
371 * used by software in case of misbehaving widgets. * 360 * used by software in case of misbehaving widgets. *
372 * * 361 * *
373 * * 362 * *
374 ************************************************************************/ 363 ************************************************************************/
375 364
376typedef union ii_iiwa_u { 365typedef union ii_iiwa_u {
377 uint64_t ii_iiwa_regval; 366 uint64_t ii_iiwa_regval;
378 struct { 367 struct {
379 uint64_t i_w0_iac : 1; 368 uint64_t i_w0_iac:1;
380 uint64_t i_rsvd_1 : 7; 369 uint64_t i_rsvd_1:7;
381 uint64_t i_wx_iac : 8; 370 uint64_t i_wx_iac:8;
382 uint64_t i_rsvd : 48; 371 uint64_t i_rsvd:48;
383 } ii_iiwa_fld_s; 372 } ii_iiwa_fld_s;
384} ii_iiwa_u_t; 373} ii_iiwa_u_t;
385 374
386
387
388/************************************************************************ 375/************************************************************************
389 * * 376 * *
390 * Description: This register qualifies all the operations launched * 377 * Description: This register qualifies all the operations launched *
391 * from a widget towards the SHub. It allows individual access * 378 * from a widget towards the SHub. It allows individual access *
392 * control for up to 8 devices per widget. A device refers to * 379 * control for up to 8 devices per widget. A device refers to *
@@ -401,72 +388,69 @@ typedef union ii_iiwa_u {
401 * The bits in this field are set by writing a 1 to them. Incoming * 388 * The bits in this field are set by writing a 1 to them. Incoming *
402 * replies from Crosstalk are not subject to this access control * 389 * replies from Crosstalk are not subject to this access control *
403 * mechanism. * 390 * mechanism. *
404 * * 391 * *
405 ************************************************************************/ 392 ************************************************************************/
406 393
407typedef union ii_iidem_u { 394typedef union ii_iidem_u {
408 uint64_t ii_iidem_regval; 395 uint64_t ii_iidem_regval;
409 struct { 396 struct {
410 uint64_t i_w8_dxs : 8; 397 uint64_t i_w8_dxs:8;
411 uint64_t i_w9_dxs : 8; 398 uint64_t i_w9_dxs:8;
412 uint64_t i_wa_dxs : 8; 399 uint64_t i_wa_dxs:8;
413 uint64_t i_wb_dxs : 8; 400 uint64_t i_wb_dxs:8;
414 uint64_t i_wc_dxs : 8; 401 uint64_t i_wc_dxs:8;
415 uint64_t i_wd_dxs : 8; 402 uint64_t i_wd_dxs:8;
416 uint64_t i_we_dxs : 8; 403 uint64_t i_we_dxs:8;
417 uint64_t i_wf_dxs : 8; 404 uint64_t i_wf_dxs:8;
418 } ii_iidem_fld_s; 405 } ii_iidem_fld_s;
419} ii_iidem_u_t; 406} ii_iidem_u_t;
420 407
421
422/************************************************************************ 408/************************************************************************
423 * * 409 * *
424 * This register contains the various programmable fields necessary * 410 * This register contains the various programmable fields necessary *
425 * for controlling and observing the LLP signals. * 411 * for controlling and observing the LLP signals. *
426 * * 412 * *
427 ************************************************************************/ 413 ************************************************************************/
428 414
429typedef union ii_ilcsr_u { 415typedef union ii_ilcsr_u {
430 uint64_t ii_ilcsr_regval; 416 uint64_t ii_ilcsr_regval;
431 struct { 417 struct {
432 uint64_t i_nullto : 6; 418 uint64_t i_nullto:6;
433 uint64_t i_rsvd_4 : 2; 419 uint64_t i_rsvd_4:2;
434 uint64_t i_wrmrst : 1; 420 uint64_t i_wrmrst:1;
435 uint64_t i_rsvd_3 : 1; 421 uint64_t i_rsvd_3:1;
436 uint64_t i_llp_en : 1; 422 uint64_t i_llp_en:1;
437 uint64_t i_bm8 : 1; 423 uint64_t i_bm8:1;
438 uint64_t i_llp_stat : 2; 424 uint64_t i_llp_stat:2;
439 uint64_t i_remote_power : 1; 425 uint64_t i_remote_power:1;
440 uint64_t i_rsvd_2 : 1; 426 uint64_t i_rsvd_2:1;
441 uint64_t i_maxrtry : 10; 427 uint64_t i_maxrtry:10;
442 uint64_t i_d_avail_sel : 2; 428 uint64_t i_d_avail_sel:2;
443 uint64_t i_rsvd_1 : 4; 429 uint64_t i_rsvd_1:4;
444 uint64_t i_maxbrst : 10; 430 uint64_t i_maxbrst:10;
445 uint64_t i_rsvd : 22; 431 uint64_t i_rsvd:22;
446 432
447 } ii_ilcsr_fld_s; 433 } ii_ilcsr_fld_s;
448} ii_ilcsr_u_t; 434} ii_ilcsr_u_t;
449 435
450
451/************************************************************************ 436/************************************************************************
452 * * 437 * *
453 * This is simply a status registers that monitors the LLP error * 438 * This is simply a status registers that monitors the LLP error *
454 * rate. * 439 * rate. *
455 * * 440 * *
456 ************************************************************************/ 441 ************************************************************************/
457 442
458typedef union ii_illr_u { 443typedef union ii_illr_u {
459 uint64_t ii_illr_regval; 444 uint64_t ii_illr_regval;
460 struct { 445 struct {
461 uint64_t i_sn_cnt : 16; 446 uint64_t i_sn_cnt:16;
462 uint64_t i_cb_cnt : 16; 447 uint64_t i_cb_cnt:16;
463 uint64_t i_rsvd : 32; 448 uint64_t i_rsvd:32;
464 } ii_illr_fld_s; 449 } ii_illr_fld_s;
465} ii_illr_u_t; 450} ii_illr_u_t;
466 451
467
468/************************************************************************ 452/************************************************************************
469 * * 453 * *
470 * Description: All II-detected non-BTE error interrupts are * 454 * Description: All II-detected non-BTE error interrupts are *
471 * specified via this register. * 455 * specified via this register. *
472 * NOTE: The PI interrupt register address is hardcoded in the II. If * 456 * NOTE: The PI interrupt register address is hardcoded in the II. If *
@@ -476,107 +460,100 @@ typedef union ii_illr_u {
476 * PI_ID==1, then the II sends the interrupt request to address * 460 * PI_ID==1, then the II sends the interrupt request to address *
477 * offset 0x01A0_0090 within the local register address space of PI1 * 461 * offset 0x01A0_0090 within the local register address space of PI1 *
478 * on the node specified by the NODE field. * 462 * on the node specified by the NODE field. *
479 * * 463 * *
480 ************************************************************************/ 464 ************************************************************************/
481 465
482typedef union ii_iidsr_u { 466typedef union ii_iidsr_u {
483 uint64_t ii_iidsr_regval; 467 uint64_t ii_iidsr_regval;
484 struct { 468 struct {
485 uint64_t i_level : 8; 469 uint64_t i_level:8;
486 uint64_t i_pi_id : 1; 470 uint64_t i_pi_id:1;
487 uint64_t i_node : 11; 471 uint64_t i_node:11;
488 uint64_t i_rsvd_3 : 4; 472 uint64_t i_rsvd_3:4;
489 uint64_t i_enable : 1; 473 uint64_t i_enable:1;
490 uint64_t i_rsvd_2 : 3; 474 uint64_t i_rsvd_2:3;
491 uint64_t i_int_sent : 2; 475 uint64_t i_int_sent:2;
492 uint64_t i_rsvd_1 : 2; 476 uint64_t i_rsvd_1:2;
493 uint64_t i_pi0_forward_int : 1; 477 uint64_t i_pi0_forward_int:1;
494 uint64_t i_pi1_forward_int : 1; 478 uint64_t i_pi1_forward_int:1;
495 uint64_t i_rsvd : 30; 479 uint64_t i_rsvd:30;
496 } ii_iidsr_fld_s; 480 } ii_iidsr_fld_s;
497} ii_iidsr_u_t; 481} ii_iidsr_u_t;
498 482
499
500
501/************************************************************************ 483/************************************************************************
502 * * 484 * *
503 * There are two instances of this register. This register is used * 485 * There are two instances of this register. This register is used *
504 * for matching up the incoming responses from the graphics widget to * 486 * for matching up the incoming responses from the graphics widget to *
505 * the processor that initiated the graphics operation. The * 487 * the processor that initiated the graphics operation. The *
506 * write-responses are converted to graphics credits and returned to * 488 * write-responses are converted to graphics credits and returned to *
507 * the processor so that the processor interface can manage the flow * 489 * the processor so that the processor interface can manage the flow *
508 * control. * 490 * control. *
509 * * 491 * *
510 ************************************************************************/ 492 ************************************************************************/
511 493
512typedef union ii_igfx0_u { 494typedef union ii_igfx0_u {
513 uint64_t ii_igfx0_regval; 495 uint64_t ii_igfx0_regval;
514 struct { 496 struct {
515 uint64_t i_w_num : 4; 497 uint64_t i_w_num:4;
516 uint64_t i_pi_id : 1; 498 uint64_t i_pi_id:1;
517 uint64_t i_n_num : 12; 499 uint64_t i_n_num:12;
518 uint64_t i_p_num : 1; 500 uint64_t i_p_num:1;
519 uint64_t i_rsvd : 46; 501 uint64_t i_rsvd:46;
520 } ii_igfx0_fld_s; 502 } ii_igfx0_fld_s;
521} ii_igfx0_u_t; 503} ii_igfx0_u_t;
522 504
523
524/************************************************************************ 505/************************************************************************
525 * * 506 * *
526 * There are two instances of this register. This register is used * 507 * There are two instances of this register. This register is used *
527 * for matching up the incoming responses from the graphics widget to * 508 * for matching up the incoming responses from the graphics widget to *
528 * the processor that initiated the graphics operation. The * 509 * the processor that initiated the graphics operation. The *
529 * write-responses are converted to graphics credits and returned to * 510 * write-responses are converted to graphics credits and returned to *
530 * the processor so that the processor interface can manage the flow * 511 * the processor so that the processor interface can manage the flow *
531 * control. * 512 * control. *
532 * * 513 * *
533 ************************************************************************/ 514 ************************************************************************/
534 515
535typedef union ii_igfx1_u { 516typedef union ii_igfx1_u {
536 uint64_t ii_igfx1_regval; 517 uint64_t ii_igfx1_regval;
537 struct { 518 struct {
538 uint64_t i_w_num : 4; 519 uint64_t i_w_num:4;
539 uint64_t i_pi_id : 1; 520 uint64_t i_pi_id:1;
540 uint64_t i_n_num : 12; 521 uint64_t i_n_num:12;
541 uint64_t i_p_num : 1; 522 uint64_t i_p_num:1;
542 uint64_t i_rsvd : 46; 523 uint64_t i_rsvd:46;
543 } ii_igfx1_fld_s; 524 } ii_igfx1_fld_s;
544} ii_igfx1_u_t; 525} ii_igfx1_u_t;
545 526
546
547/************************************************************************ 527/************************************************************************
548 * * 528 * *
549 * There are two instances of this registers. These registers are * 529 * There are two instances of this registers. These registers are *
550 * used as scratch registers for software use. * 530 * used as scratch registers for software use. *
551 * * 531 * *
552 ************************************************************************/ 532 ************************************************************************/
553 533
554typedef union ii_iscr0_u { 534typedef union ii_iscr0_u {
555 uint64_t ii_iscr0_regval; 535 uint64_t ii_iscr0_regval;
556 struct { 536 struct {
557 uint64_t i_scratch : 64; 537 uint64_t i_scratch:64;
558 } ii_iscr0_fld_s; 538 } ii_iscr0_fld_s;
559} ii_iscr0_u_t; 539} ii_iscr0_u_t;
560 540
561
562
563/************************************************************************ 541/************************************************************************
564 * * 542 * *
565 * There are two instances of this registers. These registers are * 543 * There are two instances of this registers. These registers are *
566 * used as scratch registers for software use. * 544 * used as scratch registers for software use. *
567 * * 545 * *
568 ************************************************************************/ 546 ************************************************************************/
569 547
570typedef union ii_iscr1_u { 548typedef union ii_iscr1_u {
571 uint64_t ii_iscr1_regval; 549 uint64_t ii_iscr1_regval;
572 struct { 550 struct {
573 uint64_t i_scratch : 64; 551 uint64_t i_scratch:64;
574 } ii_iscr1_fld_s; 552 } ii_iscr1_fld_s;
575} ii_iscr1_u_t; 553} ii_iscr1_u_t;
576 554
577
578/************************************************************************ 555/************************************************************************
579 * * 556 * *
580 * Description: There are seven instances of translation table entry * 557 * Description: There are seven instances of translation table entry *
581 * registers. Each register maps a Shub Big Window to a 48-bit * 558 * registers. Each register maps a Shub Big Window to a 48-bit *
582 * address on Crosstalk. * 559 * address on Crosstalk. *
@@ -599,23 +576,22 @@ typedef union ii_iscr1_u {
599 * Crosstalk space addressable by the Shub is thus the lower * 576 * Crosstalk space addressable by the Shub is thus the lower *
600 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 577 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
601 * of this space can be accessed. * 578 * of this space can be accessed. *
602 * * 579 * *
603 ************************************************************************/ 580 ************************************************************************/
604 581
605typedef union ii_itte1_u { 582typedef union ii_itte1_u {
606 uint64_t ii_itte1_regval; 583 uint64_t ii_itte1_regval;
607 struct { 584 struct {
608 uint64_t i_offset : 5; 585 uint64_t i_offset:5;
609 uint64_t i_rsvd_1 : 3; 586 uint64_t i_rsvd_1:3;
610 uint64_t i_w_num : 4; 587 uint64_t i_w_num:4;
611 uint64_t i_iosp : 1; 588 uint64_t i_iosp:1;
612 uint64_t i_rsvd : 51; 589 uint64_t i_rsvd:51;
613 } ii_itte1_fld_s; 590 } ii_itte1_fld_s;
614} ii_itte1_u_t; 591} ii_itte1_u_t;
615 592
616
617/************************************************************************ 593/************************************************************************
618 * * 594 * *
619 * Description: There are seven instances of translation table entry * 595 * Description: There are seven instances of translation table entry *
620 * registers. Each register maps a Shub Big Window to a 48-bit * 596 * registers. Each register maps a Shub Big Window to a 48-bit *
621 * address on Crosstalk. * 597 * address on Crosstalk. *
@@ -638,23 +614,22 @@ typedef union ii_itte1_u {
638 * Crosstalk space addressable by the Shub is thus the lower * 614 * Crosstalk space addressable by the Shub is thus the lower *
639 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 615 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
640 * of this space can be accessed. * 616 * of this space can be accessed. *
641 * * 617 * *
642 ************************************************************************/ 618 ************************************************************************/
643 619
644typedef union ii_itte2_u { 620typedef union ii_itte2_u {
645 uint64_t ii_itte2_regval; 621 uint64_t ii_itte2_regval;
646 struct { 622 struct {
647 uint64_t i_offset : 5; 623 uint64_t i_offset:5;
648 uint64_t i_rsvd_1 : 3; 624 uint64_t i_rsvd_1:3;
649 uint64_t i_w_num : 4; 625 uint64_t i_w_num:4;
650 uint64_t i_iosp : 1; 626 uint64_t i_iosp:1;
651 uint64_t i_rsvd : 51; 627 uint64_t i_rsvd:51;
652 } ii_itte2_fld_s; 628 } ii_itte2_fld_s;
653} ii_itte2_u_t; 629} ii_itte2_u_t;
654 630
655
656/************************************************************************ 631/************************************************************************
657 * * 632 * *
658 * Description: There are seven instances of translation table entry * 633 * Description: There are seven instances of translation table entry *
659 * registers. Each register maps a Shub Big Window to a 48-bit * 634 * registers. Each register maps a Shub Big Window to a 48-bit *
660 * address on Crosstalk. * 635 * address on Crosstalk. *
@@ -677,23 +652,22 @@ typedef union ii_itte2_u {
677 * Crosstalk space addressable by the SHub is thus the lower * 652 * Crosstalk space addressable by the SHub is thus the lower *
678 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 653 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
679 * of this space can be accessed. * 654 * of this space can be accessed. *
680 * * 655 * *
681 ************************************************************************/ 656 ************************************************************************/
682 657
683typedef union ii_itte3_u { 658typedef union ii_itte3_u {
684 uint64_t ii_itte3_regval; 659 uint64_t ii_itte3_regval;
685 struct { 660 struct {
686 uint64_t i_offset : 5; 661 uint64_t i_offset:5;
687 uint64_t i_rsvd_1 : 3; 662 uint64_t i_rsvd_1:3;
688 uint64_t i_w_num : 4; 663 uint64_t i_w_num:4;
689 uint64_t i_iosp : 1; 664 uint64_t i_iosp:1;
690 uint64_t i_rsvd : 51; 665 uint64_t i_rsvd:51;
691 } ii_itte3_fld_s; 666 } ii_itte3_fld_s;
692} ii_itte3_u_t; 667} ii_itte3_u_t;
693 668
694
695/************************************************************************ 669/************************************************************************
696 * * 670 * *
697 * Description: There are seven instances of translation table entry * 671 * Description: There are seven instances of translation table entry *
698 * registers. Each register maps a SHub Big Window to a 48-bit * 672 * registers. Each register maps a SHub Big Window to a 48-bit *
699 * address on Crosstalk. * 673 * address on Crosstalk. *
@@ -716,23 +690,22 @@ typedef union ii_itte3_u {
716 * Crosstalk space addressable by the SHub is thus the lower * 690 * Crosstalk space addressable by the SHub is thus the lower *
717 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 691 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
718 * of this space can be accessed. * 692 * of this space can be accessed. *
719 * * 693 * *
720 ************************************************************************/ 694 ************************************************************************/
721 695
722typedef union ii_itte4_u { 696typedef union ii_itte4_u {
723 uint64_t ii_itte4_regval; 697 uint64_t ii_itte4_regval;
724 struct { 698 struct {
725 uint64_t i_offset : 5; 699 uint64_t i_offset:5;
726 uint64_t i_rsvd_1 : 3; 700 uint64_t i_rsvd_1:3;
727 uint64_t i_w_num : 4; 701 uint64_t i_w_num:4;
728 uint64_t i_iosp : 1; 702 uint64_t i_iosp:1;
729 uint64_t i_rsvd : 51; 703 uint64_t i_rsvd:51;
730 } ii_itte4_fld_s; 704 } ii_itte4_fld_s;
731} ii_itte4_u_t; 705} ii_itte4_u_t;
732 706
733
734/************************************************************************ 707/************************************************************************
735 * * 708 * *
736 * Description: There are seven instances of translation table entry * 709 * Description: There are seven instances of translation table entry *
737 * registers. Each register maps a SHub Big Window to a 48-bit * 710 * registers. Each register maps a SHub Big Window to a 48-bit *
738 * address on Crosstalk. * 711 * address on Crosstalk. *
@@ -755,23 +728,22 @@ typedef union ii_itte4_u {
755 * Crosstalk space addressable by the Shub is thus the lower * 728 * Crosstalk space addressable by the Shub is thus the lower *
756 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 729 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
757 * of this space can be accessed. * 730 * of this space can be accessed. *
758 * * 731 * *
759 ************************************************************************/ 732 ************************************************************************/
760 733
761typedef union ii_itte5_u { 734typedef union ii_itte5_u {
762 uint64_t ii_itte5_regval; 735 uint64_t ii_itte5_regval;
763 struct { 736 struct {
764 uint64_t i_offset : 5; 737 uint64_t i_offset:5;
765 uint64_t i_rsvd_1 : 3; 738 uint64_t i_rsvd_1:3;
766 uint64_t i_w_num : 4; 739 uint64_t i_w_num:4;
767 uint64_t i_iosp : 1; 740 uint64_t i_iosp:1;
768 uint64_t i_rsvd : 51; 741 uint64_t i_rsvd:51;
769 } ii_itte5_fld_s; 742 } ii_itte5_fld_s;
770} ii_itte5_u_t; 743} ii_itte5_u_t;
771 744
772
773/************************************************************************ 745/************************************************************************
774 * * 746 * *
775 * Description: There are seven instances of translation table entry * 747 * Description: There are seven instances of translation table entry *
776 * registers. Each register maps a Shub Big Window to a 48-bit * 748 * registers. Each register maps a Shub Big Window to a 48-bit *
777 * address on Crosstalk. * 749 * address on Crosstalk. *
@@ -794,23 +766,22 @@ typedef union ii_itte5_u {
794 * Crosstalk space addressable by the Shub is thus the lower * 766 * Crosstalk space addressable by the Shub is thus the lower *
795 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 767 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
796 * of this space can be accessed. * 768 * of this space can be accessed. *
797 * * 769 * *
798 ************************************************************************/ 770 ************************************************************************/
799 771
800typedef union ii_itte6_u { 772typedef union ii_itte6_u {
801 uint64_t ii_itte6_regval; 773 uint64_t ii_itte6_regval;
802 struct { 774 struct {
803 uint64_t i_offset : 5; 775 uint64_t i_offset:5;
804 uint64_t i_rsvd_1 : 3; 776 uint64_t i_rsvd_1:3;
805 uint64_t i_w_num : 4; 777 uint64_t i_w_num:4;
806 uint64_t i_iosp : 1; 778 uint64_t i_iosp:1;
807 uint64_t i_rsvd : 51; 779 uint64_t i_rsvd:51;
808 } ii_itte6_fld_s; 780 } ii_itte6_fld_s;
809} ii_itte6_u_t; 781} ii_itte6_u_t;
810 782
811
812/************************************************************************ 783/************************************************************************
813 * * 784 * *
814 * Description: There are seven instances of translation table entry * 785 * Description: There are seven instances of translation table entry *
815 * registers. Each register maps a Shub Big Window to a 48-bit * 786 * registers. Each register maps a Shub Big Window to a 48-bit *
816 * address on Crosstalk. * 787 * address on Crosstalk. *
@@ -833,23 +804,22 @@ typedef union ii_itte6_u {
833 * Crosstalk space addressable by the SHub is thus the lower * 804 * Crosstalk space addressable by the SHub is thus the lower *
834 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> * 805 * 8-GBytes per widget (N-mode), only <SUP >7</SUP>/<SUB >32nds</SUB> *
835 * of this space can be accessed. * 806 * of this space can be accessed. *
836 * * 807 * *
837 ************************************************************************/ 808 ************************************************************************/
838 809
839typedef union ii_itte7_u { 810typedef union ii_itte7_u {
840 uint64_t ii_itte7_regval; 811 uint64_t ii_itte7_regval;
841 struct { 812 struct {
842 uint64_t i_offset : 5; 813 uint64_t i_offset:5;
843 uint64_t i_rsvd_1 : 3; 814 uint64_t i_rsvd_1:3;
844 uint64_t i_w_num : 4; 815 uint64_t i_w_num:4;
845 uint64_t i_iosp : 1; 816 uint64_t i_iosp:1;
846 uint64_t i_rsvd : 51; 817 uint64_t i_rsvd:51;
847 } ii_itte7_fld_s; 818 } ii_itte7_fld_s;
848} ii_itte7_u_t; 819} ii_itte7_u_t;
849 820
850
851/************************************************************************ 821/************************************************************************
852 * * 822 * *
853 * Description: There are 9 instances of this register, one per * 823 * Description: There are 9 instances of this register, one per *
854 * actual widget in this implementation of SHub and Crossbow. * 824 * actual widget in this implementation of SHub and Crossbow. *
855 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 825 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -868,33 +838,32 @@ typedef union ii_itte7_u {
868 * register; the write will correct the C field and capture its new * 838 * register; the write will correct the C field and capture its new *
869 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 839 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
870 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 840 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
871 * . * 841 * . *
872 * * 842 * *
873 ************************************************************************/ 843 ************************************************************************/
874 844
875typedef union ii_iprb0_u { 845typedef union ii_iprb0_u {
876 uint64_t ii_iprb0_regval; 846 uint64_t ii_iprb0_regval;
877 struct { 847 struct {
878 uint64_t i_c : 8; 848 uint64_t i_c:8;
879 uint64_t i_na : 14; 849 uint64_t i_na:14;
880 uint64_t i_rsvd_2 : 2; 850 uint64_t i_rsvd_2:2;
881 uint64_t i_nb : 14; 851 uint64_t i_nb:14;
882 uint64_t i_rsvd_1 : 2; 852 uint64_t i_rsvd_1:2;
883 uint64_t i_m : 2; 853 uint64_t i_m:2;
884 uint64_t i_f : 1; 854 uint64_t i_f:1;
885 uint64_t i_of_cnt : 5; 855 uint64_t i_of_cnt:5;
886 uint64_t i_error : 1; 856 uint64_t i_error:1;
887 uint64_t i_rd_to : 1; 857 uint64_t i_rd_to:1;
888 uint64_t i_spur_wr : 1; 858 uint64_t i_spur_wr:1;
889 uint64_t i_spur_rd : 1; 859 uint64_t i_spur_rd:1;
890 uint64_t i_rsvd : 11; 860 uint64_t i_rsvd:11;
891 uint64_t i_mult_err : 1; 861 uint64_t i_mult_err:1;
892 } ii_iprb0_fld_s; 862 } ii_iprb0_fld_s;
893} ii_iprb0_u_t; 863} ii_iprb0_u_t;
894 864
895
896/************************************************************************ 865/************************************************************************
897 * * 866 * *
898 * Description: There are 9 instances of this register, one per * 867 * Description: There are 9 instances of this register, one per *
899 * actual widget in this implementation of SHub and Crossbow. * 868 * actual widget in this implementation of SHub and Crossbow. *
900 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 869 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -913,33 +882,32 @@ typedef union ii_iprb0_u {
913 * register; the write will correct the C field and capture its new * 882 * register; the write will correct the C field and capture its new *
914 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 883 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
915 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 884 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
916 * . * 885 * . *
917 * * 886 * *
918 ************************************************************************/ 887 ************************************************************************/
919 888
920typedef union ii_iprb8_u { 889typedef union ii_iprb8_u {
921 uint64_t ii_iprb8_regval; 890 uint64_t ii_iprb8_regval;
922 struct { 891 struct {
923 uint64_t i_c : 8; 892 uint64_t i_c:8;
924 uint64_t i_na : 14; 893 uint64_t i_na:14;
925 uint64_t i_rsvd_2 : 2; 894 uint64_t i_rsvd_2:2;
926 uint64_t i_nb : 14; 895 uint64_t i_nb:14;
927 uint64_t i_rsvd_1 : 2; 896 uint64_t i_rsvd_1:2;
928 uint64_t i_m : 2; 897 uint64_t i_m:2;
929 uint64_t i_f : 1; 898 uint64_t i_f:1;
930 uint64_t i_of_cnt : 5; 899 uint64_t i_of_cnt:5;
931 uint64_t i_error : 1; 900 uint64_t i_error:1;
932 uint64_t i_rd_to : 1; 901 uint64_t i_rd_to:1;
933 uint64_t i_spur_wr : 1; 902 uint64_t i_spur_wr:1;
934 uint64_t i_spur_rd : 1; 903 uint64_t i_spur_rd:1;
935 uint64_t i_rsvd : 11; 904 uint64_t i_rsvd:11;
936 uint64_t i_mult_err : 1; 905 uint64_t i_mult_err:1;
937 } ii_iprb8_fld_s; 906 } ii_iprb8_fld_s;
938} ii_iprb8_u_t; 907} ii_iprb8_u_t;
939 908
940
941/************************************************************************ 909/************************************************************************
942 * * 910 * *
943 * Description: There are 9 instances of this register, one per * 911 * Description: There are 9 instances of this register, one per *
944 * actual widget in this implementation of SHub and Crossbow. * 912 * actual widget in this implementation of SHub and Crossbow. *
945 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 913 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -958,33 +926,32 @@ typedef union ii_iprb8_u {
958 * register; the write will correct the C field and capture its new * 926 * register; the write will correct the C field and capture its new *
959 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 927 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
960 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 928 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
961 * . * 929 * . *
962 * * 930 * *
963 ************************************************************************/ 931 ************************************************************************/
964 932
965typedef union ii_iprb9_u { 933typedef union ii_iprb9_u {
966 uint64_t ii_iprb9_regval; 934 uint64_t ii_iprb9_regval;
967 struct { 935 struct {
968 uint64_t i_c : 8; 936 uint64_t i_c:8;
969 uint64_t i_na : 14; 937 uint64_t i_na:14;
970 uint64_t i_rsvd_2 : 2; 938 uint64_t i_rsvd_2:2;
971 uint64_t i_nb : 14; 939 uint64_t i_nb:14;
972 uint64_t i_rsvd_1 : 2; 940 uint64_t i_rsvd_1:2;
973 uint64_t i_m : 2; 941 uint64_t i_m:2;
974 uint64_t i_f : 1; 942 uint64_t i_f:1;
975 uint64_t i_of_cnt : 5; 943 uint64_t i_of_cnt:5;
976 uint64_t i_error : 1; 944 uint64_t i_error:1;
977 uint64_t i_rd_to : 1; 945 uint64_t i_rd_to:1;
978 uint64_t i_spur_wr : 1; 946 uint64_t i_spur_wr:1;
979 uint64_t i_spur_rd : 1; 947 uint64_t i_spur_rd:1;
980 uint64_t i_rsvd : 11; 948 uint64_t i_rsvd:11;
981 uint64_t i_mult_err : 1; 949 uint64_t i_mult_err:1;
982 } ii_iprb9_fld_s; 950 } ii_iprb9_fld_s;
983} ii_iprb9_u_t; 951} ii_iprb9_u_t;
984 952
985
986/************************************************************************ 953/************************************************************************
987 * * 954 * *
988 * Description: There are 9 instances of this register, one per * 955 * Description: There are 9 instances of this register, one per *
989 * actual widget in this implementation of SHub and Crossbow. * 956 * actual widget in this implementation of SHub and Crossbow. *
990 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 957 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -1003,33 +970,32 @@ typedef union ii_iprb9_u {
1003 * register; the write will correct the C field and capture its new * 970 * register; the write will correct the C field and capture its new *
1004 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 971 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
1005 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 972 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
1006 * * 973 * *
1007 * * 974 * *
1008 ************************************************************************/ 975 ************************************************************************/
1009 976
1010typedef union ii_iprba_u { 977typedef union ii_iprba_u {
1011 uint64_t ii_iprba_regval; 978 uint64_t ii_iprba_regval;
1012 struct { 979 struct {
1013 uint64_t i_c : 8; 980 uint64_t i_c:8;
1014 uint64_t i_na : 14; 981 uint64_t i_na:14;
1015 uint64_t i_rsvd_2 : 2; 982 uint64_t i_rsvd_2:2;
1016 uint64_t i_nb : 14; 983 uint64_t i_nb:14;
1017 uint64_t i_rsvd_1 : 2; 984 uint64_t i_rsvd_1:2;
1018 uint64_t i_m : 2; 985 uint64_t i_m:2;
1019 uint64_t i_f : 1; 986 uint64_t i_f:1;
1020 uint64_t i_of_cnt : 5; 987 uint64_t i_of_cnt:5;
1021 uint64_t i_error : 1; 988 uint64_t i_error:1;
1022 uint64_t i_rd_to : 1; 989 uint64_t i_rd_to:1;
1023 uint64_t i_spur_wr : 1; 990 uint64_t i_spur_wr:1;
1024 uint64_t i_spur_rd : 1; 991 uint64_t i_spur_rd:1;
1025 uint64_t i_rsvd : 11; 992 uint64_t i_rsvd:11;
1026 uint64_t i_mult_err : 1; 993 uint64_t i_mult_err:1;
1027 } ii_iprba_fld_s; 994 } ii_iprba_fld_s;
1028} ii_iprba_u_t; 995} ii_iprba_u_t;
1029 996
1030
1031/************************************************************************ 997/************************************************************************
1032 * * 998 * *
1033 * Description: There are 9 instances of this register, one per * 999 * Description: There are 9 instances of this register, one per *
1034 * actual widget in this implementation of SHub and Crossbow. * 1000 * actual widget in this implementation of SHub and Crossbow. *
1035 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 1001 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -1048,33 +1014,32 @@ typedef union ii_iprba_u {
1048 * register; the write will correct the C field and capture its new * 1014 * register; the write will correct the C field and capture its new *
1049 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 1015 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
1050 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 1016 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
1051 * . * 1017 * . *
1052 * * 1018 * *
1053 ************************************************************************/ 1019 ************************************************************************/
1054 1020
1055typedef union ii_iprbb_u { 1021typedef union ii_iprbb_u {
1056 uint64_t ii_iprbb_regval; 1022 uint64_t ii_iprbb_regval;
1057 struct { 1023 struct {
1058 uint64_t i_c : 8; 1024 uint64_t i_c:8;
1059 uint64_t i_na : 14; 1025 uint64_t i_na:14;
1060 uint64_t i_rsvd_2 : 2; 1026 uint64_t i_rsvd_2:2;
1061 uint64_t i_nb : 14; 1027 uint64_t i_nb:14;
1062 uint64_t i_rsvd_1 : 2; 1028 uint64_t i_rsvd_1:2;
1063 uint64_t i_m : 2; 1029 uint64_t i_m:2;
1064 uint64_t i_f : 1; 1030 uint64_t i_f:1;
1065 uint64_t i_of_cnt : 5; 1031 uint64_t i_of_cnt:5;
1066 uint64_t i_error : 1; 1032 uint64_t i_error:1;
1067 uint64_t i_rd_to : 1; 1033 uint64_t i_rd_to:1;
1068 uint64_t i_spur_wr : 1; 1034 uint64_t i_spur_wr:1;
1069 uint64_t i_spur_rd : 1; 1035 uint64_t i_spur_rd:1;
1070 uint64_t i_rsvd : 11; 1036 uint64_t i_rsvd:11;
1071 uint64_t i_mult_err : 1; 1037 uint64_t i_mult_err:1;
1072 } ii_iprbb_fld_s; 1038 } ii_iprbb_fld_s;
1073} ii_iprbb_u_t; 1039} ii_iprbb_u_t;
1074 1040
1075
1076/************************************************************************ 1041/************************************************************************
1077 * * 1042 * *
1078 * Description: There are 9 instances of this register, one per * 1043 * Description: There are 9 instances of this register, one per *
1079 * actual widget in this implementation of SHub and Crossbow. * 1044 * actual widget in this implementation of SHub and Crossbow. *
1080 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 1045 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -1093,33 +1058,32 @@ typedef union ii_iprbb_u {
1093 * register; the write will correct the C field and capture its new * 1058 * register; the write will correct the C field and capture its new *
1094 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 1059 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
1095 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 1060 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
1096 * . * 1061 * . *
1097 * * 1062 * *
1098 ************************************************************************/ 1063 ************************************************************************/
1099 1064
1100typedef union ii_iprbc_u { 1065typedef union ii_iprbc_u {
1101 uint64_t ii_iprbc_regval; 1066 uint64_t ii_iprbc_regval;
1102 struct { 1067 struct {
1103 uint64_t i_c : 8; 1068 uint64_t i_c:8;
1104 uint64_t i_na : 14; 1069 uint64_t i_na:14;
1105 uint64_t i_rsvd_2 : 2; 1070 uint64_t i_rsvd_2:2;
1106 uint64_t i_nb : 14; 1071 uint64_t i_nb:14;
1107 uint64_t i_rsvd_1 : 2; 1072 uint64_t i_rsvd_1:2;
1108 uint64_t i_m : 2; 1073 uint64_t i_m:2;
1109 uint64_t i_f : 1; 1074 uint64_t i_f:1;
1110 uint64_t i_of_cnt : 5; 1075 uint64_t i_of_cnt:5;
1111 uint64_t i_error : 1; 1076 uint64_t i_error:1;
1112 uint64_t i_rd_to : 1; 1077 uint64_t i_rd_to:1;
1113 uint64_t i_spur_wr : 1; 1078 uint64_t i_spur_wr:1;
1114 uint64_t i_spur_rd : 1; 1079 uint64_t i_spur_rd:1;
1115 uint64_t i_rsvd : 11; 1080 uint64_t i_rsvd:11;
1116 uint64_t i_mult_err : 1; 1081 uint64_t i_mult_err:1;
1117 } ii_iprbc_fld_s; 1082 } ii_iprbc_fld_s;
1118} ii_iprbc_u_t; 1083} ii_iprbc_u_t;
1119 1084
1120
1121/************************************************************************ 1085/************************************************************************
1122 * * 1086 * *
1123 * Description: There are 9 instances of this register, one per * 1087 * Description: There are 9 instances of this register, one per *
1124 * actual widget in this implementation of SHub and Crossbow. * 1088 * actual widget in this implementation of SHub and Crossbow. *
1125 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 1089 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -1138,33 +1102,32 @@ typedef union ii_iprbc_u {
1138 * register; the write will correct the C field and capture its new * 1102 * register; the write will correct the C field and capture its new *
1139 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 1103 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
1140 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 1104 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
1141 * . * 1105 * . *
1142 * * 1106 * *
1143 ************************************************************************/ 1107 ************************************************************************/
1144 1108
1145typedef union ii_iprbd_u { 1109typedef union ii_iprbd_u {
1146 uint64_t ii_iprbd_regval; 1110 uint64_t ii_iprbd_regval;
1147 struct { 1111 struct {
1148 uint64_t i_c : 8; 1112 uint64_t i_c:8;
1149 uint64_t i_na : 14; 1113 uint64_t i_na:14;
1150 uint64_t i_rsvd_2 : 2; 1114 uint64_t i_rsvd_2:2;
1151 uint64_t i_nb : 14; 1115 uint64_t i_nb:14;
1152 uint64_t i_rsvd_1 : 2; 1116 uint64_t i_rsvd_1:2;
1153 uint64_t i_m : 2; 1117 uint64_t i_m:2;
1154 uint64_t i_f : 1; 1118 uint64_t i_f:1;
1155 uint64_t i_of_cnt : 5; 1119 uint64_t i_of_cnt:5;
1156 uint64_t i_error : 1; 1120 uint64_t i_error:1;
1157 uint64_t i_rd_to : 1; 1121 uint64_t i_rd_to:1;
1158 uint64_t i_spur_wr : 1; 1122 uint64_t i_spur_wr:1;
1159 uint64_t i_spur_rd : 1; 1123 uint64_t i_spur_rd:1;
1160 uint64_t i_rsvd : 11; 1124 uint64_t i_rsvd:11;
1161 uint64_t i_mult_err : 1; 1125 uint64_t i_mult_err:1;
1162 } ii_iprbd_fld_s; 1126 } ii_iprbd_fld_s;
1163} ii_iprbd_u_t; 1127} ii_iprbd_u_t;
1164 1128
1165
1166/************************************************************************ 1129/************************************************************************
1167 * * 1130 * *
1168 * Description: There are 9 instances of this register, one per * 1131 * Description: There are 9 instances of this register, one per *
1169 * actual widget in this implementation of SHub and Crossbow. * 1132 * actual widget in this implementation of SHub and Crossbow. *
1170 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 1133 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -1183,33 +1146,32 @@ typedef union ii_iprbd_u {
1183 * register; the write will correct the C field and capture its new * 1146 * register; the write will correct the C field and capture its new *
1184 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 1147 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
1185 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 1148 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
1186 * . * 1149 * . *
1187 * * 1150 * *
1188 ************************************************************************/ 1151 ************************************************************************/
1189 1152
1190typedef union ii_iprbe_u { 1153typedef union ii_iprbe_u {
1191 uint64_t ii_iprbe_regval; 1154 uint64_t ii_iprbe_regval;
1192 struct { 1155 struct {
1193 uint64_t i_c : 8; 1156 uint64_t i_c:8;
1194 uint64_t i_na : 14; 1157 uint64_t i_na:14;
1195 uint64_t i_rsvd_2 : 2; 1158 uint64_t i_rsvd_2:2;
1196 uint64_t i_nb : 14; 1159 uint64_t i_nb:14;
1197 uint64_t i_rsvd_1 : 2; 1160 uint64_t i_rsvd_1:2;
1198 uint64_t i_m : 2; 1161 uint64_t i_m:2;
1199 uint64_t i_f : 1; 1162 uint64_t i_f:1;
1200 uint64_t i_of_cnt : 5; 1163 uint64_t i_of_cnt:5;
1201 uint64_t i_error : 1; 1164 uint64_t i_error:1;
1202 uint64_t i_rd_to : 1; 1165 uint64_t i_rd_to:1;
1203 uint64_t i_spur_wr : 1; 1166 uint64_t i_spur_wr:1;
1204 uint64_t i_spur_rd : 1; 1167 uint64_t i_spur_rd:1;
1205 uint64_t i_rsvd : 11; 1168 uint64_t i_rsvd:11;
1206 uint64_t i_mult_err : 1; 1169 uint64_t i_mult_err:1;
1207 } ii_iprbe_fld_s; 1170 } ii_iprbe_fld_s;
1208} ii_iprbe_u_t; 1171} ii_iprbe_u_t;
1209 1172
1210
1211/************************************************************************ 1173/************************************************************************
1212 * * 1174 * *
1213 * Description: There are 9 instances of this register, one per * 1175 * Description: There are 9 instances of this register, one per *
1214 * actual widget in this implementation of Shub and Crossbow. * 1176 * actual widget in this implementation of Shub and Crossbow. *
1215 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 * 1177 * Note: Crossbow only has ports for Widgets 8 through F, widget 0 *
@@ -1228,33 +1190,32 @@ typedef union ii_iprbe_u {
1228 * register; the write will correct the C field and capture its new * 1190 * register; the write will correct the C field and capture its new *
1229 * value in the internal register. Even if IECLR[E_PRB_x] is set, the * 1191 * value in the internal register. Even if IECLR[E_PRB_x] is set, the *
1230 * SPUR_WR bit will persist if IPRBx hasn't yet been written. * 1192 * SPUR_WR bit will persist if IPRBx hasn't yet been written. *
1231 * . * 1193 * . *
1232 * * 1194 * *
1233 ************************************************************************/ 1195 ************************************************************************/
1234 1196
1235typedef union ii_iprbf_u { 1197typedef union ii_iprbf_u {
1236 uint64_t ii_iprbf_regval; 1198 uint64_t ii_iprbf_regval;
1237 struct { 1199 struct {
1238 uint64_t i_c : 8; 1200 uint64_t i_c:8;
1239 uint64_t i_na : 14; 1201 uint64_t i_na:14;
1240 uint64_t i_rsvd_2 : 2; 1202 uint64_t i_rsvd_2:2;
1241 uint64_t i_nb : 14; 1203 uint64_t i_nb:14;
1242 uint64_t i_rsvd_1 : 2; 1204 uint64_t i_rsvd_1:2;
1243 uint64_t i_m : 2; 1205 uint64_t i_m:2;
1244 uint64_t i_f : 1; 1206 uint64_t i_f:1;
1245 uint64_t i_of_cnt : 5; 1207 uint64_t i_of_cnt:5;
1246 uint64_t i_error : 1; 1208 uint64_t i_error:1;
1247 uint64_t i_rd_to : 1; 1209 uint64_t i_rd_to:1;
1248 uint64_t i_spur_wr : 1; 1210 uint64_t i_spur_wr:1;
1249 uint64_t i_spur_rd : 1; 1211 uint64_t i_spur_rd:1;
1250 uint64_t i_rsvd : 11; 1212 uint64_t i_rsvd:11;
1251 uint64_t i_mult_err : 1; 1213 uint64_t i_mult_err:1;
1252 } ii_iprbe_fld_s; 1214 } ii_iprbe_fld_s;
1253} ii_iprbf_u_t; 1215} ii_iprbf_u_t;
1254 1216
1255
1256/************************************************************************ 1217/************************************************************************
1257 * * 1218 * *
1258 * This register specifies the timeout value to use for monitoring * 1219 * This register specifies the timeout value to use for monitoring *
1259 * Crosstalk credits which are used outbound to Crosstalk. An * 1220 * Crosstalk credits which are used outbound to Crosstalk. An *
1260 * internal counter called the Crosstalk Credit Timeout Counter * 1221 * internal counter called the Crosstalk Credit Timeout Counter *
@@ -1267,20 +1228,19 @@ typedef union ii_iprbf_u {
1267 * Crosstalk Credit Timeout has occurred. The internal counter is not * 1228 * Crosstalk Credit Timeout has occurred. The internal counter is not *
1268 * readable from software, and stops counting at its maximum value, * 1229 * readable from software, and stops counting at its maximum value, *
1269 * so it cannot cause more than one interrupt. * 1230 * so it cannot cause more than one interrupt. *
1270 * * 1231 * *
1271 ************************************************************************/ 1232 ************************************************************************/
1272 1233
1273typedef union ii_ixcc_u { 1234typedef union ii_ixcc_u {
1274 uint64_t ii_ixcc_regval; 1235 uint64_t ii_ixcc_regval;
1275 struct { 1236 struct {
1276 uint64_t i_time_out : 26; 1237 uint64_t i_time_out:26;
1277 uint64_t i_rsvd : 38; 1238 uint64_t i_rsvd:38;
1278 } ii_ixcc_fld_s; 1239 } ii_ixcc_fld_s;
1279} ii_ixcc_u_t; 1240} ii_ixcc_u_t;
1280 1241
1281
1282/************************************************************************ 1242/************************************************************************
1283 * * 1243 * *
1284 * Description: This register qualifies all the PIO and DMA * 1244 * Description: This register qualifies all the PIO and DMA *
1285 * operations launched from widget 0 towards the SHub. In * 1245 * operations launched from widget 0 towards the SHub. In *
1286 * addition, it also qualifies accesses by the BTE streams. * 1246 * addition, it also qualifies accesses by the BTE streams. *
@@ -1292,27 +1252,25 @@ typedef union ii_ixcc_u {
1292 * the Wx_IAC field. The bits in this field are set by writing a 1 to * 1252 * the Wx_IAC field. The bits in this field are set by writing a 1 to *
1293 * them. Incoming replies from Crosstalk are not subject to this * 1253 * them. Incoming replies from Crosstalk are not subject to this *
1294 * access control mechanism. * 1254 * access control mechanism. *
1295 * * 1255 * *
1296 ************************************************************************/ 1256 ************************************************************************/
1297 1257
1298typedef union ii_imem_u { 1258typedef union ii_imem_u {
1299 uint64_t ii_imem_regval; 1259 uint64_t ii_imem_regval;
1300 struct { 1260 struct {
1301 uint64_t i_w0_esd : 1; 1261 uint64_t i_w0_esd:1;
1302 uint64_t i_rsvd_3 : 3; 1262 uint64_t i_rsvd_3:3;
1303 uint64_t i_b0_esd : 1; 1263 uint64_t i_b0_esd:1;
1304 uint64_t i_rsvd_2 : 3; 1264 uint64_t i_rsvd_2:3;
1305 uint64_t i_b1_esd : 1; 1265 uint64_t i_b1_esd:1;
1306 uint64_t i_rsvd_1 : 3; 1266 uint64_t i_rsvd_1:3;
1307 uint64_t i_clr_precise : 1; 1267 uint64_t i_clr_precise:1;
1308 uint64_t i_rsvd : 51; 1268 uint64_t i_rsvd:51;
1309 } ii_imem_fld_s; 1269 } ii_imem_fld_s;
1310} ii_imem_u_t; 1270} ii_imem_u_t;
1311 1271
1312
1313
1314/************************************************************************ 1272/************************************************************************
1315 * * 1273 * *
1316 * Description: This register specifies the timeout value to use for * 1274 * Description: This register specifies the timeout value to use for *
1317 * monitoring Crosstalk tail flits coming into the Shub in the * 1275 * monitoring Crosstalk tail flits coming into the Shub in the *
1318 * TAIL_TO field. An internal counter associated with this register * 1276 * TAIL_TO field. An internal counter associated with this register *
@@ -1332,90 +1290,87 @@ typedef union ii_imem_u {
1332 * the value in the RRSP_TO field, a Read Response Timeout has * 1290 * the value in the RRSP_TO field, a Read Response Timeout has *
1333 * occurred, and error handling occurs as described in the Error * 1291 * occurred, and error handling occurs as described in the Error *
1334 * Handling section of this document. * 1292 * Handling section of this document. *
1335 * * 1293 * *
1336 ************************************************************************/ 1294 ************************************************************************/
1337 1295
1338typedef union ii_ixtt_u { 1296typedef union ii_ixtt_u {
1339 uint64_t ii_ixtt_regval; 1297 uint64_t ii_ixtt_regval;
1340 struct { 1298 struct {
1341 uint64_t i_tail_to : 26; 1299 uint64_t i_tail_to:26;
1342 uint64_t i_rsvd_1 : 6; 1300 uint64_t i_rsvd_1:6;
1343 uint64_t i_rrsp_ps : 23; 1301 uint64_t i_rrsp_ps:23;
1344 uint64_t i_rrsp_to : 5; 1302 uint64_t i_rrsp_to:5;
1345 uint64_t i_rsvd : 4; 1303 uint64_t i_rsvd:4;
1346 } ii_ixtt_fld_s; 1304 } ii_ixtt_fld_s;
1347} ii_ixtt_u_t; 1305} ii_ixtt_u_t;
1348 1306
1349
1350/************************************************************************ 1307/************************************************************************
1351 * * 1308 * *
1352 * Writing a 1 to the fields of this register clears the appropriate * 1309 * Writing a 1 to the fields of this register clears the appropriate *
1353 * error bits in other areas of SHub. Note that when the * 1310 * error bits in other areas of SHub. Note that when the *
1354 * E_PRB_x bits are used to clear error bits in PRB registers, * 1311 * E_PRB_x bits are used to clear error bits in PRB registers, *
1355 * SPUR_RD and SPUR_WR may persist, because they require additional * 1312 * SPUR_RD and SPUR_WR may persist, because they require additional *
1356 * action to clear them. See the IPRBx and IXSS Register * 1313 * action to clear them. See the IPRBx and IXSS Register *
1357 * specifications. * 1314 * specifications. *
1358 * * 1315 * *
1359 ************************************************************************/ 1316 ************************************************************************/
1360 1317
1361typedef union ii_ieclr_u { 1318typedef union ii_ieclr_u {
1362 uint64_t ii_ieclr_regval; 1319 uint64_t ii_ieclr_regval;
1363 struct { 1320 struct {
1364 uint64_t i_e_prb_0 : 1; 1321 uint64_t i_e_prb_0:1;
1365 uint64_t i_rsvd : 7; 1322 uint64_t i_rsvd:7;
1366 uint64_t i_e_prb_8 : 1; 1323 uint64_t i_e_prb_8:1;
1367 uint64_t i_e_prb_9 : 1; 1324 uint64_t i_e_prb_9:1;
1368 uint64_t i_e_prb_a : 1; 1325 uint64_t i_e_prb_a:1;
1369 uint64_t i_e_prb_b : 1; 1326 uint64_t i_e_prb_b:1;
1370 uint64_t i_e_prb_c : 1; 1327 uint64_t i_e_prb_c:1;
1371 uint64_t i_e_prb_d : 1; 1328 uint64_t i_e_prb_d:1;
1372 uint64_t i_e_prb_e : 1; 1329 uint64_t i_e_prb_e:1;
1373 uint64_t i_e_prb_f : 1; 1330 uint64_t i_e_prb_f:1;
1374 uint64_t i_e_crazy : 1; 1331 uint64_t i_e_crazy:1;
1375 uint64_t i_e_bte_0 : 1; 1332 uint64_t i_e_bte_0:1;
1376 uint64_t i_e_bte_1 : 1; 1333 uint64_t i_e_bte_1:1;
1377 uint64_t i_reserved_1 : 10; 1334 uint64_t i_reserved_1:10;
1378 uint64_t i_spur_rd_hdr : 1; 1335 uint64_t i_spur_rd_hdr:1;
1379 uint64_t i_cam_intr_to : 1; 1336 uint64_t i_cam_intr_to:1;
1380 uint64_t i_cam_overflow : 1; 1337 uint64_t i_cam_overflow:1;
1381 uint64_t i_cam_read_miss : 1; 1338 uint64_t i_cam_read_miss:1;
1382 uint64_t i_ioq_rep_underflow : 1; 1339 uint64_t i_ioq_rep_underflow:1;
1383 uint64_t i_ioq_req_underflow : 1; 1340 uint64_t i_ioq_req_underflow:1;
1384 uint64_t i_ioq_rep_overflow : 1; 1341 uint64_t i_ioq_rep_overflow:1;
1385 uint64_t i_ioq_req_overflow : 1; 1342 uint64_t i_ioq_req_overflow:1;
1386 uint64_t i_iiq_rep_overflow : 1; 1343 uint64_t i_iiq_rep_overflow:1;
1387 uint64_t i_iiq_req_overflow : 1; 1344 uint64_t i_iiq_req_overflow:1;
1388 uint64_t i_ii_xn_rep_cred_overflow : 1; 1345 uint64_t i_ii_xn_rep_cred_overflow:1;
1389 uint64_t i_ii_xn_req_cred_overflow : 1; 1346 uint64_t i_ii_xn_req_cred_overflow:1;
1390 uint64_t i_ii_xn_invalid_cmd : 1; 1347 uint64_t i_ii_xn_invalid_cmd:1;
1391 uint64_t i_xn_ii_invalid_cmd : 1; 1348 uint64_t i_xn_ii_invalid_cmd:1;
1392 uint64_t i_reserved_2 : 21; 1349 uint64_t i_reserved_2:21;
1393 } ii_ieclr_fld_s; 1350 } ii_ieclr_fld_s;
1394} ii_ieclr_u_t; 1351} ii_ieclr_u_t;
1395 1352
1396
1397/************************************************************************ 1353/************************************************************************
1398 * * 1354 * *
1399 * This register controls both BTEs. SOFT_RESET is intended for * 1355 * This register controls both BTEs. SOFT_RESET is intended for *
1400 * recovery after an error. COUNT controls the total number of CRBs * 1356 * recovery after an error. COUNT controls the total number of CRBs *
1401 * that both BTEs (combined) can use, which affects total BTE * 1357 * that both BTEs (combined) can use, which affects total BTE *
1402 * bandwidth. * 1358 * bandwidth. *
1403 * * 1359 * *
1404 ************************************************************************/ 1360 ************************************************************************/
1405 1361
1406typedef union ii_ibcr_u { 1362typedef union ii_ibcr_u {
1407 uint64_t ii_ibcr_regval; 1363 uint64_t ii_ibcr_regval;
1408 struct { 1364 struct {
1409 uint64_t i_count : 4; 1365 uint64_t i_count:4;
1410 uint64_t i_rsvd_1 : 4; 1366 uint64_t i_rsvd_1:4;
1411 uint64_t i_soft_reset : 1; 1367 uint64_t i_soft_reset:1;
1412 uint64_t i_rsvd : 55; 1368 uint64_t i_rsvd:55;
1413 } ii_ibcr_fld_s; 1369 } ii_ibcr_fld_s;
1414} ii_ibcr_u_t; 1370} ii_ibcr_u_t;
1415 1371
1416
1417/************************************************************************ 1372/************************************************************************
1418 * * 1373 * *
1419 * This register contains the header of a spurious read response * 1374 * This register contains the header of a spurious read response *
1420 * received from Crosstalk. A spurious read response is defined as a * 1375 * received from Crosstalk. A spurious read response is defined as a *
1421 * read response received by II from a widget for which (1) the SIDN * 1376 * read response received by II from a widget for which (1) the SIDN *
@@ -1440,49 +1395,47 @@ typedef union ii_ibcr_u {
1440 * will be set. Any SPUR_RD bits in any other PRB registers indicate * 1395 * will be set. Any SPUR_RD bits in any other PRB registers indicate *
1441 * spurious messages from other widets which were detected after the * 1396 * spurious messages from other widets which were detected after the *
1442 * header was captured.. * 1397 * header was captured.. *
1443 * * 1398 * *
1444 ************************************************************************/ 1399 ************************************************************************/
1445 1400
1446typedef union ii_ixsm_u { 1401typedef union ii_ixsm_u {
1447 uint64_t ii_ixsm_regval; 1402 uint64_t ii_ixsm_regval;
1448 struct { 1403 struct {
1449 uint64_t i_byte_en : 32; 1404 uint64_t i_byte_en:32;
1450 uint64_t i_reserved : 1; 1405 uint64_t i_reserved:1;
1451 uint64_t i_tag : 3; 1406 uint64_t i_tag:3;
1452 uint64_t i_alt_pactyp : 4; 1407 uint64_t i_alt_pactyp:4;
1453 uint64_t i_bo : 1; 1408 uint64_t i_bo:1;
1454 uint64_t i_error : 1; 1409 uint64_t i_error:1;
1455 uint64_t i_vbpm : 1; 1410 uint64_t i_vbpm:1;
1456 uint64_t i_gbr : 1; 1411 uint64_t i_gbr:1;
1457 uint64_t i_ds : 2; 1412 uint64_t i_ds:2;
1458 uint64_t i_ct : 1; 1413 uint64_t i_ct:1;
1459 uint64_t i_tnum : 5; 1414 uint64_t i_tnum:5;
1460 uint64_t i_pactyp : 4; 1415 uint64_t i_pactyp:4;
1461 uint64_t i_sidn : 4; 1416 uint64_t i_sidn:4;
1462 uint64_t i_didn : 4; 1417 uint64_t i_didn:4;
1463 } ii_ixsm_fld_s; 1418 } ii_ixsm_fld_s;
1464} ii_ixsm_u_t; 1419} ii_ixsm_u_t;
1465 1420
1466
1467/************************************************************************ 1421/************************************************************************
1468 * * 1422 * *
1469 * This register contains the sideband bits of a spurious read * 1423 * This register contains the sideband bits of a spurious read *
1470 * response received from Crosstalk. * 1424 * response received from Crosstalk. *
1471 * * 1425 * *
1472 ************************************************************************/ 1426 ************************************************************************/
1473 1427
1474typedef union ii_ixss_u { 1428typedef union ii_ixss_u {
1475 uint64_t ii_ixss_regval; 1429 uint64_t ii_ixss_regval;
1476 struct { 1430 struct {
1477 uint64_t i_sideband : 8; 1431 uint64_t i_sideband:8;
1478 uint64_t i_rsvd : 55; 1432 uint64_t i_rsvd:55;
1479 uint64_t i_valid : 1; 1433 uint64_t i_valid:1;
1480 } ii_ixss_fld_s; 1434 } ii_ixss_fld_s;
1481} ii_ixss_u_t; 1435} ii_ixss_u_t;
1482 1436
1483
1484/************************************************************************ 1437/************************************************************************
1485 * * 1438 * *
1486 * This register enables software to access the II LLP's test port. * 1439 * This register enables software to access the II LLP's test port. *
1487 * Refer to the LLP 2.5 documentation for an explanation of the test * 1440 * Refer to the LLP 2.5 documentation for an explanation of the test *
1488 * port. Software can write to this register to program the values * 1441 * port. Software can write to this register to program the values *
@@ -1490,27 +1443,26 @@ typedef union ii_ixss_u {
1490 * TestMask and TestSeed). Similarly, software can read from this * 1443 * TestMask and TestSeed). Similarly, software can read from this *
1491 * register to obtain the values of the test port's status outputs * 1444 * register to obtain the values of the test port's status outputs *
1492 * (TestCBerr, TestValid and TestData). * 1445 * (TestCBerr, TestValid and TestData). *
1493 * * 1446 * *
1494 ************************************************************************/ 1447 ************************************************************************/
1495 1448
1496typedef union ii_ilct_u { 1449typedef union ii_ilct_u {
1497 uint64_t ii_ilct_regval; 1450 uint64_t ii_ilct_regval;
1498 struct { 1451 struct {
1499 uint64_t i_test_seed : 20; 1452 uint64_t i_test_seed:20;
1500 uint64_t i_test_mask : 8; 1453 uint64_t i_test_mask:8;
1501 uint64_t i_test_data : 20; 1454 uint64_t i_test_data:20;
1502 uint64_t i_test_valid : 1; 1455 uint64_t i_test_valid:1;
1503 uint64_t i_test_cberr : 1; 1456 uint64_t i_test_cberr:1;
1504 uint64_t i_test_flit : 3; 1457 uint64_t i_test_flit:3;
1505 uint64_t i_test_clear : 1; 1458 uint64_t i_test_clear:1;
1506 uint64_t i_test_err_capture : 1; 1459 uint64_t i_test_err_capture:1;
1507 uint64_t i_rsvd : 9; 1460 uint64_t i_rsvd:9;
1508 } ii_ilct_fld_s; 1461 } ii_ilct_fld_s;
1509} ii_ilct_u_t; 1462} ii_ilct_u_t;
1510 1463
1511
1512/************************************************************************ 1464/************************************************************************
1513 * * 1465 * *
1514 * If the II detects an illegal incoming Duplonet packet (request or * 1466 * If the II detects an illegal incoming Duplonet packet (request or *
1515 * reply) when VALID==0 in the IIEPH1 register, then it saves the * 1467 * reply) when VALID==0 in the IIEPH1 register, then it saves the *
1516 * contents of the packet's header flit in the IIEPH1 and IIEPH2 * 1468 * contents of the packet's header flit in the IIEPH1 and IIEPH2 *
@@ -1526,575 +1478,549 @@ typedef union ii_ilct_u {
1526 * packet when VALID==1 in the IIEPH1 register, then it merely sets * 1478 * packet when VALID==1 in the IIEPH1 register, then it merely sets *
1527 * the OVERRUN bit to indicate that a subsequent error has happened, * 1479 * the OVERRUN bit to indicate that a subsequent error has happened, *
1528 * and does nothing further. * 1480 * and does nothing further. *
1529 * * 1481 * *
1530 ************************************************************************/ 1482 ************************************************************************/
1531 1483
1532typedef union ii_iieph1_u { 1484typedef union ii_iieph1_u {
1533 uint64_t ii_iieph1_regval; 1485 uint64_t ii_iieph1_regval;
1534 struct { 1486 struct {
1535 uint64_t i_command : 7; 1487 uint64_t i_command:7;
1536 uint64_t i_rsvd_5 : 1; 1488 uint64_t i_rsvd_5:1;
1537 uint64_t i_suppl : 14; 1489 uint64_t i_suppl:14;
1538 uint64_t i_rsvd_4 : 1; 1490 uint64_t i_rsvd_4:1;
1539 uint64_t i_source : 14; 1491 uint64_t i_source:14;
1540 uint64_t i_rsvd_3 : 1; 1492 uint64_t i_rsvd_3:1;
1541 uint64_t i_err_type : 4; 1493 uint64_t i_err_type:4;
1542 uint64_t i_rsvd_2 : 4; 1494 uint64_t i_rsvd_2:4;
1543 uint64_t i_overrun : 1; 1495 uint64_t i_overrun:1;
1544 uint64_t i_rsvd_1 : 3; 1496 uint64_t i_rsvd_1:3;
1545 uint64_t i_valid : 1; 1497 uint64_t i_valid:1;
1546 uint64_t i_rsvd : 13; 1498 uint64_t i_rsvd:13;
1547 } ii_iieph1_fld_s; 1499 } ii_iieph1_fld_s;
1548} ii_iieph1_u_t; 1500} ii_iieph1_u_t;
1549 1501
1550
1551/************************************************************************ 1502/************************************************************************
1552 * * 1503 * *
1553 * This register holds the Address field from the header flit of an * 1504 * This register holds the Address field from the header flit of an *
1554 * incoming erroneous Duplonet packet, along with the tail bit which * 1505 * incoming erroneous Duplonet packet, along with the tail bit which *
1555 * accompanied this header flit. This register is essentially an * 1506 * accompanied this header flit. This register is essentially an *
1556 * extension of IIEPH1. Two registers were necessary because the 64 * 1507 * extension of IIEPH1. Two registers were necessary because the 64 *
1557 * bits available in only a single register were insufficient to * 1508 * bits available in only a single register were insufficient to *
1558 * capture the entire header flit of an erroneous packet. * 1509 * capture the entire header flit of an erroneous packet. *
1559 * * 1510 * *
1560 ************************************************************************/ 1511 ************************************************************************/
1561 1512
1562typedef union ii_iieph2_u { 1513typedef union ii_iieph2_u {
1563 uint64_t ii_iieph2_regval; 1514 uint64_t ii_iieph2_regval;
1564 struct { 1515 struct {
1565 uint64_t i_rsvd_0 : 3; 1516 uint64_t i_rsvd_0:3;
1566 uint64_t i_address : 47; 1517 uint64_t i_address:47;
1567 uint64_t i_rsvd_1 : 10; 1518 uint64_t i_rsvd_1:10;
1568 uint64_t i_tail : 1; 1519 uint64_t i_tail:1;
1569 uint64_t i_rsvd : 3; 1520 uint64_t i_rsvd:3;
1570 } ii_iieph2_fld_s; 1521 } ii_iieph2_fld_s;
1571} ii_iieph2_u_t; 1522} ii_iieph2_u_t;
1572 1523
1573
1574/******************************/ 1524/******************************/
1575 1525
1576
1577
1578/************************************************************************ 1526/************************************************************************
1579 * * 1527 * *
1580 * This register's value is a bit vector that guards access from SXBs * 1528 * This register's value is a bit vector that guards access from SXBs *
1581 * to local registers within the II as well as to external Crosstalk * 1529 * to local registers within the II as well as to external Crosstalk *
1582 * widgets * 1530 * widgets *
1583 * * 1531 * *
1584 ************************************************************************/ 1532 ************************************************************************/
1585 1533
1586typedef union ii_islapr_u { 1534typedef union ii_islapr_u {
1587 uint64_t ii_islapr_regval; 1535 uint64_t ii_islapr_regval;
1588 struct { 1536 struct {
1589 uint64_t i_region : 64; 1537 uint64_t i_region:64;
1590 } ii_islapr_fld_s; 1538 } ii_islapr_fld_s;
1591} ii_islapr_u_t; 1539} ii_islapr_u_t;
1592 1540
1593
1594/************************************************************************ 1541/************************************************************************
1595 * * 1542 * *
1596 * A write to this register of the 56-bit value "Pup+Bun" will cause * 1543 * A write to this register of the 56-bit value "Pup+Bun" will cause *
1597 * the bit in the ISLAPR register corresponding to the region of the * 1544 * the bit in the ISLAPR register corresponding to the region of the *
1598 * requestor to be set (access allowed). ( 1545 * requestor to be set (access allowed). (
1599 * * 1546 * *
1600 ************************************************************************/ 1547 ************************************************************************/
1601 1548
1602typedef union ii_islapo_u { 1549typedef union ii_islapo_u {
1603 uint64_t ii_islapo_regval; 1550 uint64_t ii_islapo_regval;
1604 struct { 1551 struct {
1605 uint64_t i_io_sbx_ovrride : 56; 1552 uint64_t i_io_sbx_ovrride:56;
1606 uint64_t i_rsvd : 8; 1553 uint64_t i_rsvd:8;
1607 } ii_islapo_fld_s; 1554 } ii_islapo_fld_s;
1608} ii_islapo_u_t; 1555} ii_islapo_u_t;
1609 1556
1610/************************************************************************ 1557/************************************************************************
1611 * * 1558 * *
1612 * Determines how long the wrapper will wait aftr an interrupt is * 1559 * Determines how long the wrapper will wait aftr an interrupt is *
1613 * initially issued from the II before it times out the outstanding * 1560 * initially issued from the II before it times out the outstanding *
1614 * interrupt and drops it from the interrupt queue. * 1561 * interrupt and drops it from the interrupt queue. *
1615 * * 1562 * *
1616 ************************************************************************/ 1563 ************************************************************************/
1617 1564
1618typedef union ii_iwi_u { 1565typedef union ii_iwi_u {
1619 uint64_t ii_iwi_regval; 1566 uint64_t ii_iwi_regval;
1620 struct { 1567 struct {
1621 uint64_t i_prescale : 24; 1568 uint64_t i_prescale:24;
1622 uint64_t i_rsvd : 8; 1569 uint64_t i_rsvd:8;
1623 uint64_t i_timeout : 8; 1570 uint64_t i_timeout:8;
1624 uint64_t i_rsvd1 : 8; 1571 uint64_t i_rsvd1:8;
1625 uint64_t i_intrpt_retry_period : 8; 1572 uint64_t i_intrpt_retry_period:8;
1626 uint64_t i_rsvd2 : 8; 1573 uint64_t i_rsvd2:8;
1627 } ii_iwi_fld_s; 1574 } ii_iwi_fld_s;
1628} ii_iwi_u_t; 1575} ii_iwi_u_t;
1629 1576
1630/************************************************************************ 1577/************************************************************************
1631 * * 1578 * *
1632 * Log errors which have occurred in the II wrapper. The errors are * 1579 * Log errors which have occurred in the II wrapper. The errors are *
1633 * cleared by writing to the IECLR register. * 1580 * cleared by writing to the IECLR register. *
1634 * * 1581 * *
1635 ************************************************************************/ 1582 ************************************************************************/
1636 1583
1637typedef union ii_iwel_u { 1584typedef union ii_iwel_u {
1638 uint64_t ii_iwel_regval; 1585 uint64_t ii_iwel_regval;
1639 struct { 1586 struct {
1640 uint64_t i_intr_timed_out : 1; 1587 uint64_t i_intr_timed_out:1;
1641 uint64_t i_rsvd : 7; 1588 uint64_t i_rsvd:7;
1642 uint64_t i_cam_overflow : 1; 1589 uint64_t i_cam_overflow:1;
1643 uint64_t i_cam_read_miss : 1; 1590 uint64_t i_cam_read_miss:1;
1644 uint64_t i_rsvd1 : 2; 1591 uint64_t i_rsvd1:2;
1645 uint64_t i_ioq_rep_underflow : 1; 1592 uint64_t i_ioq_rep_underflow:1;
1646 uint64_t i_ioq_req_underflow : 1; 1593 uint64_t i_ioq_req_underflow:1;
1647 uint64_t i_ioq_rep_overflow : 1; 1594 uint64_t i_ioq_rep_overflow:1;
1648 uint64_t i_ioq_req_overflow : 1; 1595 uint64_t i_ioq_req_overflow:1;
1649 uint64_t i_iiq_rep_overflow : 1; 1596 uint64_t i_iiq_rep_overflow:1;
1650 uint64_t i_iiq_req_overflow : 1; 1597 uint64_t i_iiq_req_overflow:1;
1651 uint64_t i_rsvd2 : 6; 1598 uint64_t i_rsvd2:6;
1652 uint64_t i_ii_xn_rep_cred_over_under: 1; 1599 uint64_t i_ii_xn_rep_cred_over_under:1;
1653 uint64_t i_ii_xn_req_cred_over_under: 1; 1600 uint64_t i_ii_xn_req_cred_over_under:1;
1654 uint64_t i_rsvd3 : 6; 1601 uint64_t i_rsvd3:6;
1655 uint64_t i_ii_xn_invalid_cmd : 1; 1602 uint64_t i_ii_xn_invalid_cmd:1;
1656 uint64_t i_xn_ii_invalid_cmd : 1; 1603 uint64_t i_xn_ii_invalid_cmd:1;
1657 uint64_t i_rsvd4 : 30; 1604 uint64_t i_rsvd4:30;
1658 } ii_iwel_fld_s; 1605 } ii_iwel_fld_s;
1659} ii_iwel_u_t; 1606} ii_iwel_u_t;
1660 1607
1661/************************************************************************ 1608/************************************************************************
1662 * * 1609 * *
1663 * Controls the II wrapper. * 1610 * Controls the II wrapper. *
1664 * * 1611 * *
1665 ************************************************************************/ 1612 ************************************************************************/
1666 1613
1667typedef union ii_iwc_u { 1614typedef union ii_iwc_u {
1668 uint64_t ii_iwc_regval; 1615 uint64_t ii_iwc_regval;
1669 struct { 1616 struct {
1670 uint64_t i_dma_byte_swap : 1; 1617 uint64_t i_dma_byte_swap:1;
1671 uint64_t i_rsvd : 3; 1618 uint64_t i_rsvd:3;
1672 uint64_t i_cam_read_lines_reset : 1; 1619 uint64_t i_cam_read_lines_reset:1;
1673 uint64_t i_rsvd1 : 3; 1620 uint64_t i_rsvd1:3;
1674 uint64_t i_ii_xn_cred_over_under_log: 1; 1621 uint64_t i_ii_xn_cred_over_under_log:1;
1675 uint64_t i_rsvd2 : 19; 1622 uint64_t i_rsvd2:19;
1676 uint64_t i_xn_rep_iq_depth : 5; 1623 uint64_t i_xn_rep_iq_depth:5;
1677 uint64_t i_rsvd3 : 3; 1624 uint64_t i_rsvd3:3;
1678 uint64_t i_xn_req_iq_depth : 5; 1625 uint64_t i_xn_req_iq_depth:5;
1679 uint64_t i_rsvd4 : 3; 1626 uint64_t i_rsvd4:3;
1680 uint64_t i_iiq_depth : 6; 1627 uint64_t i_iiq_depth:6;
1681 uint64_t i_rsvd5 : 12; 1628 uint64_t i_rsvd5:12;
1682 uint64_t i_force_rep_cred : 1; 1629 uint64_t i_force_rep_cred:1;
1683 uint64_t i_force_req_cred : 1; 1630 uint64_t i_force_req_cred:1;
1684 } ii_iwc_fld_s; 1631 } ii_iwc_fld_s;
1685} ii_iwc_u_t; 1632} ii_iwc_u_t;
1686 1633
1687/************************************************************************ 1634/************************************************************************
1688 * * 1635 * *
1689 * Status in the II wrapper. * 1636 * Status in the II wrapper. *
1690 * * 1637 * *
1691 ************************************************************************/ 1638 ************************************************************************/
1692 1639
1693typedef union ii_iws_u { 1640typedef union ii_iws_u {
1694 uint64_t ii_iws_regval; 1641 uint64_t ii_iws_regval;
1695 struct { 1642 struct {
1696 uint64_t i_xn_rep_iq_credits : 5; 1643 uint64_t i_xn_rep_iq_credits:5;
1697 uint64_t i_rsvd : 3; 1644 uint64_t i_rsvd:3;
1698 uint64_t i_xn_req_iq_credits : 5; 1645 uint64_t i_xn_req_iq_credits:5;
1699 uint64_t i_rsvd1 : 51; 1646 uint64_t i_rsvd1:51;
1700 } ii_iws_fld_s; 1647 } ii_iws_fld_s;
1701} ii_iws_u_t; 1648} ii_iws_u_t;
1702 1649
1703/************************************************************************ 1650/************************************************************************
1704 * * 1651 * *
1705 * Masks errors in the IWEL register. * 1652 * Masks errors in the IWEL register. *
1706 * * 1653 * *
1707 ************************************************************************/ 1654 ************************************************************************/
1708 1655
1709typedef union ii_iweim_u { 1656typedef union ii_iweim_u {
1710 uint64_t ii_iweim_regval; 1657 uint64_t ii_iweim_regval;
1711 struct { 1658 struct {
1712 uint64_t i_intr_timed_out : 1; 1659 uint64_t i_intr_timed_out:1;
1713 uint64_t i_rsvd : 7; 1660 uint64_t i_rsvd:7;
1714 uint64_t i_cam_overflow : 1; 1661 uint64_t i_cam_overflow:1;
1715 uint64_t i_cam_read_miss : 1; 1662 uint64_t i_cam_read_miss:1;
1716 uint64_t i_rsvd1 : 2; 1663 uint64_t i_rsvd1:2;
1717 uint64_t i_ioq_rep_underflow : 1; 1664 uint64_t i_ioq_rep_underflow:1;
1718 uint64_t i_ioq_req_underflow : 1; 1665 uint64_t i_ioq_req_underflow:1;
1719 uint64_t i_ioq_rep_overflow : 1; 1666 uint64_t i_ioq_rep_overflow:1;
1720 uint64_t i_ioq_req_overflow : 1; 1667 uint64_t i_ioq_req_overflow:1;
1721 uint64_t i_iiq_rep_overflow : 1; 1668 uint64_t i_iiq_rep_overflow:1;
1722 uint64_t i_iiq_req_overflow : 1; 1669 uint64_t i_iiq_req_overflow:1;
1723 uint64_t i_rsvd2 : 6; 1670 uint64_t i_rsvd2:6;
1724 uint64_t i_ii_xn_rep_cred_overflow : 1; 1671 uint64_t i_ii_xn_rep_cred_overflow:1;
1725 uint64_t i_ii_xn_req_cred_overflow : 1; 1672 uint64_t i_ii_xn_req_cred_overflow:1;
1726 uint64_t i_rsvd3 : 6; 1673 uint64_t i_rsvd3:6;
1727 uint64_t i_ii_xn_invalid_cmd : 1; 1674 uint64_t i_ii_xn_invalid_cmd:1;
1728 uint64_t i_xn_ii_invalid_cmd : 1; 1675 uint64_t i_xn_ii_invalid_cmd:1;
1729 uint64_t i_rsvd4 : 30; 1676 uint64_t i_rsvd4:30;
1730 } ii_iweim_fld_s; 1677 } ii_iweim_fld_s;
1731} ii_iweim_u_t; 1678} ii_iweim_u_t;
1732 1679
1733
1734/************************************************************************ 1680/************************************************************************
1735 * * 1681 * *
1736 * A write to this register causes a particular field in the * 1682 * A write to this register causes a particular field in the *
1737 * corresponding widget's PRB entry to be adjusted up or down by 1. * 1683 * corresponding widget's PRB entry to be adjusted up or down by 1. *
1738 * This counter should be used when recovering from error and reset * 1684 * This counter should be used when recovering from error and reset *
1739 * conditions. Note that software would be capable of causing * 1685 * conditions. Note that software would be capable of causing *
1740 * inadvertent overflow or underflow of these counters. * 1686 * inadvertent overflow or underflow of these counters. *
1741 * * 1687 * *
1742 ************************************************************************/ 1688 ************************************************************************/
1743 1689
1744typedef union ii_ipca_u { 1690typedef union ii_ipca_u {
1745 uint64_t ii_ipca_regval; 1691 uint64_t ii_ipca_regval;
1746 struct { 1692 struct {
1747 uint64_t i_wid : 4; 1693 uint64_t i_wid:4;
1748 uint64_t i_adjust : 1; 1694 uint64_t i_adjust:1;
1749 uint64_t i_rsvd_1 : 3; 1695 uint64_t i_rsvd_1:3;
1750 uint64_t i_field : 2; 1696 uint64_t i_field:2;
1751 uint64_t i_rsvd : 54; 1697 uint64_t i_rsvd:54;
1752 } ii_ipca_fld_s; 1698 } ii_ipca_fld_s;
1753} ii_ipca_u_t; 1699} ii_ipca_u_t;
1754 1700
1755
1756/************************************************************************ 1701/************************************************************************
1757 * * 1702 * *
1758 * There are 8 instances of this register. This register contains * 1703 * There are 8 instances of this register. This register contains *
1759 * the information that the II has to remember once it has launched a * 1704 * the information that the II has to remember once it has launched a *
1760 * PIO Read operation. The contents are used to form the correct * 1705 * PIO Read operation. The contents are used to form the correct *
1761 * Router Network packet and direct the Crosstalk reply to the * 1706 * Router Network packet and direct the Crosstalk reply to the *
1762 * appropriate processor. * 1707 * appropriate processor. *
1763 * * 1708 * *
1764 ************************************************************************/ 1709 ************************************************************************/
1765 1710
1766
1767typedef union ii_iprte0a_u { 1711typedef union ii_iprte0a_u {
1768 uint64_t ii_iprte0a_regval; 1712 uint64_t ii_iprte0a_regval;
1769 struct { 1713 struct {
1770 uint64_t i_rsvd_1 : 54; 1714 uint64_t i_rsvd_1:54;
1771 uint64_t i_widget : 4; 1715 uint64_t i_widget:4;
1772 uint64_t i_to_cnt : 5; 1716 uint64_t i_to_cnt:5;
1773 uint64_t i_vld : 1; 1717 uint64_t i_vld:1;
1774 } ii_iprte0a_fld_s; 1718 } ii_iprte0a_fld_s;
1775} ii_iprte0a_u_t; 1719} ii_iprte0a_u_t;
1776 1720
1777
1778/************************************************************************ 1721/************************************************************************
1779 * * 1722 * *
1780 * There are 8 instances of this register. This register contains * 1723 * There are 8 instances of this register. This register contains *
1781 * the information that the II has to remember once it has launched a * 1724 * the information that the II has to remember once it has launched a *
1782 * PIO Read operation. The contents are used to form the correct * 1725 * PIO Read operation. The contents are used to form the correct *
1783 * Router Network packet and direct the Crosstalk reply to the * 1726 * Router Network packet and direct the Crosstalk reply to the *
1784 * appropriate processor. * 1727 * appropriate processor. *
1785 * * 1728 * *
1786 ************************************************************************/ 1729 ************************************************************************/
1787 1730
1788typedef union ii_iprte1a_u { 1731typedef union ii_iprte1a_u {
1789 uint64_t ii_iprte1a_regval; 1732 uint64_t ii_iprte1a_regval;
1790 struct { 1733 struct {
1791 uint64_t i_rsvd_1 : 54; 1734 uint64_t i_rsvd_1:54;
1792 uint64_t i_widget : 4; 1735 uint64_t i_widget:4;
1793 uint64_t i_to_cnt : 5; 1736 uint64_t i_to_cnt:5;
1794 uint64_t i_vld : 1; 1737 uint64_t i_vld:1;
1795 } ii_iprte1a_fld_s; 1738 } ii_iprte1a_fld_s;
1796} ii_iprte1a_u_t; 1739} ii_iprte1a_u_t;
1797 1740
1798
1799/************************************************************************ 1741/************************************************************************
1800 * * 1742 * *
1801 * There are 8 instances of this register. This register contains * 1743 * There are 8 instances of this register. This register contains *
1802 * the information that the II has to remember once it has launched a * 1744 * the information that the II has to remember once it has launched a *
1803 * PIO Read operation. The contents are used to form the correct * 1745 * PIO Read operation. The contents are used to form the correct *
1804 * Router Network packet and direct the Crosstalk reply to the * 1746 * Router Network packet and direct the Crosstalk reply to the *
1805 * appropriate processor. * 1747 * appropriate processor. *
1806 * * 1748 * *
1807 ************************************************************************/ 1749 ************************************************************************/
1808 1750
1809typedef union ii_iprte2a_u { 1751typedef union ii_iprte2a_u {
1810 uint64_t ii_iprte2a_regval; 1752 uint64_t ii_iprte2a_regval;
1811 struct { 1753 struct {
1812 uint64_t i_rsvd_1 : 54; 1754 uint64_t i_rsvd_1:54;
1813 uint64_t i_widget : 4; 1755 uint64_t i_widget:4;
1814 uint64_t i_to_cnt : 5; 1756 uint64_t i_to_cnt:5;
1815 uint64_t i_vld : 1; 1757 uint64_t i_vld:1;
1816 } ii_iprte2a_fld_s; 1758 } ii_iprte2a_fld_s;
1817} ii_iprte2a_u_t; 1759} ii_iprte2a_u_t;
1818 1760
1819
1820/************************************************************************ 1761/************************************************************************
1821 * * 1762 * *
1822 * There are 8 instances of this register. This register contains * 1763 * There are 8 instances of this register. This register contains *
1823 * the information that the II has to remember once it has launched a * 1764 * the information that the II has to remember once it has launched a *
1824 * PIO Read operation. The contents are used to form the correct * 1765 * PIO Read operation. The contents are used to form the correct *
1825 * Router Network packet and direct the Crosstalk reply to the * 1766 * Router Network packet and direct the Crosstalk reply to the *
1826 * appropriate processor. * 1767 * appropriate processor. *
1827 * * 1768 * *
1828 ************************************************************************/ 1769 ************************************************************************/
1829 1770
1830typedef union ii_iprte3a_u { 1771typedef union ii_iprte3a_u {
1831 uint64_t ii_iprte3a_regval; 1772 uint64_t ii_iprte3a_regval;
1832 struct { 1773 struct {
1833 uint64_t i_rsvd_1 : 54; 1774 uint64_t i_rsvd_1:54;
1834 uint64_t i_widget : 4; 1775 uint64_t i_widget:4;
1835 uint64_t i_to_cnt : 5; 1776 uint64_t i_to_cnt:5;
1836 uint64_t i_vld : 1; 1777 uint64_t i_vld:1;
1837 } ii_iprte3a_fld_s; 1778 } ii_iprte3a_fld_s;
1838} ii_iprte3a_u_t; 1779} ii_iprte3a_u_t;
1839 1780
1840
1841/************************************************************************ 1781/************************************************************************
1842 * * 1782 * *
1843 * There are 8 instances of this register. This register contains * 1783 * There are 8 instances of this register. This register contains *
1844 * the information that the II has to remember once it has launched a * 1784 * the information that the II has to remember once it has launched a *
1845 * PIO Read operation. The contents are used to form the correct * 1785 * PIO Read operation. The contents are used to form the correct *
1846 * Router Network packet and direct the Crosstalk reply to the * 1786 * Router Network packet and direct the Crosstalk reply to the *
1847 * appropriate processor. * 1787 * appropriate processor. *
1848 * * 1788 * *
1849 ************************************************************************/ 1789 ************************************************************************/
1850 1790
1851typedef union ii_iprte4a_u { 1791typedef union ii_iprte4a_u {
1852 uint64_t ii_iprte4a_regval; 1792 uint64_t ii_iprte4a_regval;
1853 struct { 1793 struct {
1854 uint64_t i_rsvd_1 : 54; 1794 uint64_t i_rsvd_1:54;
1855 uint64_t i_widget : 4; 1795 uint64_t i_widget:4;
1856 uint64_t i_to_cnt : 5; 1796 uint64_t i_to_cnt:5;
1857 uint64_t i_vld : 1; 1797 uint64_t i_vld:1;
1858 } ii_iprte4a_fld_s; 1798 } ii_iprte4a_fld_s;
1859} ii_iprte4a_u_t; 1799} ii_iprte4a_u_t;
1860 1800
1861
1862/************************************************************************ 1801/************************************************************************
1863 * * 1802 * *
1864 * There are 8 instances of this register. This register contains * 1803 * There are 8 instances of this register. This register contains *
1865 * the information that the II has to remember once it has launched a * 1804 * the information that the II has to remember once it has launched a *
1866 * PIO Read operation. The contents are used to form the correct * 1805 * PIO Read operation. The contents are used to form the correct *
1867 * Router Network packet and direct the Crosstalk reply to the * 1806 * Router Network packet and direct the Crosstalk reply to the *
1868 * appropriate processor. * 1807 * appropriate processor. *
1869 * * 1808 * *
1870 ************************************************************************/ 1809 ************************************************************************/
1871 1810
1872typedef union ii_iprte5a_u { 1811typedef union ii_iprte5a_u {
1873 uint64_t ii_iprte5a_regval; 1812 uint64_t ii_iprte5a_regval;
1874 struct { 1813 struct {
1875 uint64_t i_rsvd_1 : 54; 1814 uint64_t i_rsvd_1:54;
1876 uint64_t i_widget : 4; 1815 uint64_t i_widget:4;
1877 uint64_t i_to_cnt : 5; 1816 uint64_t i_to_cnt:5;
1878 uint64_t i_vld : 1; 1817 uint64_t i_vld:1;
1879 } ii_iprte5a_fld_s; 1818 } ii_iprte5a_fld_s;
1880} ii_iprte5a_u_t; 1819} ii_iprte5a_u_t;
1881 1820
1882
1883/************************************************************************ 1821/************************************************************************
1884 * * 1822 * *
1885 * There are 8 instances of this register. This register contains * 1823 * There are 8 instances of this register. This register contains *
1886 * the information that the II has to remember once it has launched a * 1824 * the information that the II has to remember once it has launched a *
1887 * PIO Read operation. The contents are used to form the correct * 1825 * PIO Read operation. The contents are used to form the correct *
1888 * Router Network packet and direct the Crosstalk reply to the * 1826 * Router Network packet and direct the Crosstalk reply to the *
1889 * appropriate processor. * 1827 * appropriate processor. *
1890 * * 1828 * *
1891 ************************************************************************/ 1829 ************************************************************************/
1892 1830
1893typedef union ii_iprte6a_u { 1831typedef union ii_iprte6a_u {
1894 uint64_t ii_iprte6a_regval; 1832 uint64_t ii_iprte6a_regval;
1895 struct { 1833 struct {
1896 uint64_t i_rsvd_1 : 54; 1834 uint64_t i_rsvd_1:54;
1897 uint64_t i_widget : 4; 1835 uint64_t i_widget:4;
1898 uint64_t i_to_cnt : 5; 1836 uint64_t i_to_cnt:5;
1899 uint64_t i_vld : 1; 1837 uint64_t i_vld:1;
1900 } ii_iprte6a_fld_s; 1838 } ii_iprte6a_fld_s;
1901} ii_iprte6a_u_t; 1839} ii_iprte6a_u_t;
1902 1840
1903
1904/************************************************************************ 1841/************************************************************************
1905 * * 1842 * *
1906 * There are 8 instances of this register. This register contains * 1843 * There are 8 instances of this register. This register contains *
1907 * the information that the II has to remember once it has launched a * 1844 * the information that the II has to remember once it has launched a *
1908 * PIO Read operation. The contents are used to form the correct * 1845 * PIO Read operation. The contents are used to form the correct *
1909 * Router Network packet and direct the Crosstalk reply to the * 1846 * Router Network packet and direct the Crosstalk reply to the *
1910 * appropriate processor. * 1847 * appropriate processor. *
1911 * * 1848 * *
1912 ************************************************************************/ 1849 ************************************************************************/
1913 1850
1914typedef union ii_iprte7a_u { 1851typedef union ii_iprte7a_u {
1915 uint64_t ii_iprte7a_regval; 1852 uint64_t ii_iprte7a_regval;
1916 struct { 1853 struct {
1917 uint64_t i_rsvd_1 : 54; 1854 uint64_t i_rsvd_1:54;
1918 uint64_t i_widget : 4; 1855 uint64_t i_widget:4;
1919 uint64_t i_to_cnt : 5; 1856 uint64_t i_to_cnt:5;
1920 uint64_t i_vld : 1; 1857 uint64_t i_vld:1;
1921 } ii_iprtea7_fld_s; 1858 } ii_iprtea7_fld_s;
1922} ii_iprte7a_u_t; 1859} ii_iprte7a_u_t;
1923 1860
1924
1925
1926/************************************************************************ 1861/************************************************************************
1927 * * 1862 * *
1928 * There are 8 instances of this register. This register contains * 1863 * There are 8 instances of this register. This register contains *
1929 * the information that the II has to remember once it has launched a * 1864 * the information that the II has to remember once it has launched a *
1930 * PIO Read operation. The contents are used to form the correct * 1865 * PIO Read operation. The contents are used to form the correct *
1931 * Router Network packet and direct the Crosstalk reply to the * 1866 * Router Network packet and direct the Crosstalk reply to the *
1932 * appropriate processor. * 1867 * appropriate processor. *
1933 * * 1868 * *
1934 ************************************************************************/ 1869 ************************************************************************/
1935 1870
1936
1937typedef union ii_iprte0b_u { 1871typedef union ii_iprte0b_u {
1938 uint64_t ii_iprte0b_regval; 1872 uint64_t ii_iprte0b_regval;
1939 struct { 1873 struct {
1940 uint64_t i_rsvd_1 : 3; 1874 uint64_t i_rsvd_1:3;
1941 uint64_t i_address : 47; 1875 uint64_t i_address:47;
1942 uint64_t i_init : 3; 1876 uint64_t i_init:3;
1943 uint64_t i_source : 11; 1877 uint64_t i_source:11;
1944 } ii_iprte0b_fld_s; 1878 } ii_iprte0b_fld_s;
1945} ii_iprte0b_u_t; 1879} ii_iprte0b_u_t;
1946 1880
1947
1948/************************************************************************ 1881/************************************************************************
1949 * * 1882 * *
1950 * There are 8 instances of this register. This register contains * 1883 * There are 8 instances of this register. This register contains *
1951 * the information that the II has to remember once it has launched a * 1884 * the information that the II has to remember once it has launched a *
1952 * PIO Read operation. The contents are used to form the correct * 1885 * PIO Read operation. The contents are used to form the correct *
1953 * Router Network packet and direct the Crosstalk reply to the * 1886 * Router Network packet and direct the Crosstalk reply to the *
1954 * appropriate processor. * 1887 * appropriate processor. *
1955 * * 1888 * *
1956 ************************************************************************/ 1889 ************************************************************************/
1957 1890
1958typedef union ii_iprte1b_u { 1891typedef union ii_iprte1b_u {
1959 uint64_t ii_iprte1b_regval; 1892 uint64_t ii_iprte1b_regval;
1960 struct { 1893 struct {
1961 uint64_t i_rsvd_1 : 3; 1894 uint64_t i_rsvd_1:3;
1962 uint64_t i_address : 47; 1895 uint64_t i_address:47;
1963 uint64_t i_init : 3; 1896 uint64_t i_init:3;
1964 uint64_t i_source : 11; 1897 uint64_t i_source:11;
1965 } ii_iprte1b_fld_s; 1898 } ii_iprte1b_fld_s;
1966} ii_iprte1b_u_t; 1899} ii_iprte1b_u_t;
1967 1900
1968
1969/************************************************************************ 1901/************************************************************************
1970 * * 1902 * *
1971 * There are 8 instances of this register. This register contains * 1903 * There are 8 instances of this register. This register contains *
1972 * the information that the II has to remember once it has launched a * 1904 * the information that the II has to remember once it has launched a *
1973 * PIO Read operation. The contents are used to form the correct * 1905 * PIO Read operation. The contents are used to form the correct *
1974 * Router Network packet and direct the Crosstalk reply to the * 1906 * Router Network packet and direct the Crosstalk reply to the *
1975 * appropriate processor. * 1907 * appropriate processor. *
1976 * * 1908 * *
1977 ************************************************************************/ 1909 ************************************************************************/
1978 1910
1979typedef union ii_iprte2b_u { 1911typedef union ii_iprte2b_u {
1980 uint64_t ii_iprte2b_regval; 1912 uint64_t ii_iprte2b_regval;
1981 struct { 1913 struct {
1982 uint64_t i_rsvd_1 : 3; 1914 uint64_t i_rsvd_1:3;
1983 uint64_t i_address : 47; 1915 uint64_t i_address:47;
1984 uint64_t i_init : 3; 1916 uint64_t i_init:3;
1985 uint64_t i_source : 11; 1917 uint64_t i_source:11;
1986 } ii_iprte2b_fld_s; 1918 } ii_iprte2b_fld_s;
1987} ii_iprte2b_u_t; 1919} ii_iprte2b_u_t;
1988 1920
1989
1990/************************************************************************ 1921/************************************************************************
1991 * * 1922 * *
1992 * There are 8 instances of this register. This register contains * 1923 * There are 8 instances of this register. This register contains *
1993 * the information that the II has to remember once it has launched a * 1924 * the information that the II has to remember once it has launched a *
1994 * PIO Read operation. The contents are used to form the correct * 1925 * PIO Read operation. The contents are used to form the correct *
1995 * Router Network packet and direct the Crosstalk reply to the * 1926 * Router Network packet and direct the Crosstalk reply to the *
1996 * appropriate processor. * 1927 * appropriate processor. *
1997 * * 1928 * *
1998 ************************************************************************/ 1929 ************************************************************************/
1999 1930
2000typedef union ii_iprte3b_u { 1931typedef union ii_iprte3b_u {
2001 uint64_t ii_iprte3b_regval; 1932 uint64_t ii_iprte3b_regval;
2002 struct { 1933 struct {
2003 uint64_t i_rsvd_1 : 3; 1934 uint64_t i_rsvd_1:3;
2004 uint64_t i_address : 47; 1935 uint64_t i_address:47;
2005 uint64_t i_init : 3; 1936 uint64_t i_init:3;
2006 uint64_t i_source : 11; 1937 uint64_t i_source:11;
2007 } ii_iprte3b_fld_s; 1938 } ii_iprte3b_fld_s;
2008} ii_iprte3b_u_t; 1939} ii_iprte3b_u_t;
2009 1940
2010
2011/************************************************************************ 1941/************************************************************************
2012 * * 1942 * *
2013 * There are 8 instances of this register. This register contains * 1943 * There are 8 instances of this register. This register contains *
2014 * the information that the II has to remember once it has launched a * 1944 * the information that the II has to remember once it has launched a *
2015 * PIO Read operation. The contents are used to form the correct * 1945 * PIO Read operation. The contents are used to form the correct *
2016 * Router Network packet and direct the Crosstalk reply to the * 1946 * Router Network packet and direct the Crosstalk reply to the *
2017 * appropriate processor. * 1947 * appropriate processor. *
2018 * * 1948 * *
2019 ************************************************************************/ 1949 ************************************************************************/
2020 1950
2021typedef union ii_iprte4b_u { 1951typedef union ii_iprte4b_u {
2022 uint64_t ii_iprte4b_regval; 1952 uint64_t ii_iprte4b_regval;
2023 struct { 1953 struct {
2024 uint64_t i_rsvd_1 : 3; 1954 uint64_t i_rsvd_1:3;
2025 uint64_t i_address : 47; 1955 uint64_t i_address:47;
2026 uint64_t i_init : 3; 1956 uint64_t i_init:3;
2027 uint64_t i_source : 11; 1957 uint64_t i_source:11;
2028 } ii_iprte4b_fld_s; 1958 } ii_iprte4b_fld_s;
2029} ii_iprte4b_u_t; 1959} ii_iprte4b_u_t;
2030 1960
2031
2032/************************************************************************ 1961/************************************************************************
2033 * * 1962 * *
2034 * There are 8 instances of this register. This register contains * 1963 * There are 8 instances of this register. This register contains *
2035 * the information that the II has to remember once it has launched a * 1964 * the information that the II has to remember once it has launched a *
2036 * PIO Read operation. The contents are used to form the correct * 1965 * PIO Read operation. The contents are used to form the correct *
2037 * Router Network packet and direct the Crosstalk reply to the * 1966 * Router Network packet and direct the Crosstalk reply to the *
2038 * appropriate processor. * 1967 * appropriate processor. *
2039 * * 1968 * *
2040 ************************************************************************/ 1969 ************************************************************************/
2041 1970
2042typedef union ii_iprte5b_u { 1971typedef union ii_iprte5b_u {
2043 uint64_t ii_iprte5b_regval; 1972 uint64_t ii_iprte5b_regval;
2044 struct { 1973 struct {
2045 uint64_t i_rsvd_1 : 3; 1974 uint64_t i_rsvd_1:3;
2046 uint64_t i_address : 47; 1975 uint64_t i_address:47;
2047 uint64_t i_init : 3; 1976 uint64_t i_init:3;
2048 uint64_t i_source : 11; 1977 uint64_t i_source:11;
2049 } ii_iprte5b_fld_s; 1978 } ii_iprte5b_fld_s;
2050} ii_iprte5b_u_t; 1979} ii_iprte5b_u_t;
2051 1980
2052
2053/************************************************************************ 1981/************************************************************************
2054 * * 1982 * *
2055 * There are 8 instances of this register. This register contains * 1983 * There are 8 instances of this register. This register contains *
2056 * the information that the II has to remember once it has launched a * 1984 * the information that the II has to remember once it has launched a *
2057 * PIO Read operation. The contents are used to form the correct * 1985 * PIO Read operation. The contents are used to form the correct *
2058 * Router Network packet and direct the Crosstalk reply to the * 1986 * Router Network packet and direct the Crosstalk reply to the *
2059 * appropriate processor. * 1987 * appropriate processor. *
2060 * * 1988 * *
2061 ************************************************************************/ 1989 ************************************************************************/
2062 1990
2063typedef union ii_iprte6b_u { 1991typedef union ii_iprte6b_u {
2064 uint64_t ii_iprte6b_regval; 1992 uint64_t ii_iprte6b_regval;
2065 struct { 1993 struct {
2066 uint64_t i_rsvd_1 : 3; 1994 uint64_t i_rsvd_1:3;
2067 uint64_t i_address : 47; 1995 uint64_t i_address:47;
2068 uint64_t i_init : 3; 1996 uint64_t i_init:3;
2069 uint64_t i_source : 11; 1997 uint64_t i_source:11;
2070 1998
2071 } ii_iprte6b_fld_s; 1999 } ii_iprte6b_fld_s;
2072} ii_iprte6b_u_t; 2000} ii_iprte6b_u_t;
2073 2001
2074
2075/************************************************************************ 2002/************************************************************************
2076 * * 2003 * *
2077 * There are 8 instances of this register. This register contains * 2004 * There are 8 instances of this register. This register contains *
2078 * the information that the II has to remember once it has launched a * 2005 * the information that the II has to remember once it has launched a *
2079 * PIO Read operation. The contents are used to form the correct * 2006 * PIO Read operation. The contents are used to form the correct *
2080 * Router Network packet and direct the Crosstalk reply to the * 2007 * Router Network packet and direct the Crosstalk reply to the *
2081 * appropriate processor. * 2008 * appropriate processor. *
2082 * * 2009 * *
2083 ************************************************************************/ 2010 ************************************************************************/
2084 2011
2085typedef union ii_iprte7b_u { 2012typedef union ii_iprte7b_u {
2086 uint64_t ii_iprte7b_regval; 2013 uint64_t ii_iprte7b_regval;
2087 struct { 2014 struct {
2088 uint64_t i_rsvd_1 : 3; 2015 uint64_t i_rsvd_1:3;
2089 uint64_t i_address : 47; 2016 uint64_t i_address:47;
2090 uint64_t i_init : 3; 2017 uint64_t i_init:3;
2091 uint64_t i_source : 11; 2018 uint64_t i_source:11;
2092 } ii_iprte7b_fld_s; 2019 } ii_iprte7b_fld_s;
2093} ii_iprte7b_u_t; 2020} ii_iprte7b_u_t;
2094 2021
2095
2096/************************************************************************ 2022/************************************************************************
2097 * * 2023 * *
2098 * Description: SHub II contains a feature which did not exist in * 2024 * Description: SHub II contains a feature which did not exist in *
2099 * the Hub which automatically cleans up after a Read Response * 2025 * the Hub which automatically cleans up after a Read Response *
2100 * timeout, including deallocation of the IPRTE and recovery of IBuf * 2026 * timeout, including deallocation of the IPRTE and recovery of IBuf *
@@ -2108,23 +2034,22 @@ typedef union ii_iprte7b_u {
2108 * Note that this register does not affect the contents of the IPRTE * 2034 * Note that this register does not affect the contents of the IPRTE *
2109 * registers. The Valid bits in those registers have to be * 2035 * registers. The Valid bits in those registers have to be *
2110 * specifically turned off by software. * 2036 * specifically turned off by software. *
2111 * * 2037 * *
2112 ************************************************************************/ 2038 ************************************************************************/
2113 2039
2114typedef union ii_ipdr_u { 2040typedef union ii_ipdr_u {
2115 uint64_t ii_ipdr_regval; 2041 uint64_t ii_ipdr_regval;
2116 struct { 2042 struct {
2117 uint64_t i_te : 3; 2043 uint64_t i_te:3;
2118 uint64_t i_rsvd_1 : 1; 2044 uint64_t i_rsvd_1:1;
2119 uint64_t i_pnd : 1; 2045 uint64_t i_pnd:1;
2120 uint64_t i_init_rpcnt : 1; 2046 uint64_t i_init_rpcnt:1;
2121 uint64_t i_rsvd : 58; 2047 uint64_t i_rsvd:58;
2122 } ii_ipdr_fld_s; 2048 } ii_ipdr_fld_s;
2123} ii_ipdr_u_t; 2049} ii_ipdr_u_t;
2124 2050
2125
2126/************************************************************************ 2051/************************************************************************
2127 * * 2052 * *
2128 * A write to this register causes a CRB entry to be returned to the * 2053 * A write to this register causes a CRB entry to be returned to the *
2129 * queue of free CRBs. The entry should have previously been cleared * 2054 * queue of free CRBs. The entry should have previously been cleared *
2130 * (mark bit) via backdoor access to the pertinent CRB entry. This * 2055 * (mark bit) via backdoor access to the pertinent CRB entry. This *
@@ -2137,21 +2062,20 @@ typedef union ii_ipdr_u {
2137 * software clears the mark bit, and finally 4) software writes to * 2062 * software clears the mark bit, and finally 4) software writes to *
2138 * the ICDR register to return the CRB entry to the list of free CRB * 2063 * the ICDR register to return the CRB entry to the list of free CRB *
2139 * entries. * 2064 * entries. *
2140 * * 2065 * *
2141 ************************************************************************/ 2066 ************************************************************************/
2142 2067
2143typedef union ii_icdr_u { 2068typedef union ii_icdr_u {
2144 uint64_t ii_icdr_regval; 2069 uint64_t ii_icdr_regval;
2145 struct { 2070 struct {
2146 uint64_t i_crb_num : 4; 2071 uint64_t i_crb_num:4;
2147 uint64_t i_pnd : 1; 2072 uint64_t i_pnd:1;
2148 uint64_t i_rsvd : 59; 2073 uint64_t i_rsvd:59;
2149 } ii_icdr_fld_s; 2074 } ii_icdr_fld_s;
2150} ii_icdr_u_t; 2075} ii_icdr_u_t;
2151 2076
2152
2153/************************************************************************ 2077/************************************************************************
2154 * * 2078 * *
2155 * This register provides debug access to two FIFOs inside of II. * 2079 * This register provides debug access to two FIFOs inside of II. *
2156 * Both IOQ_MAX* fields of this register contain the instantaneous * 2080 * Both IOQ_MAX* fields of this register contain the instantaneous *
2157 * depth (in units of the number of available entries) of the * 2081 * depth (in units of the number of available entries) of the *
@@ -2164,130 +2088,124 @@ typedef union ii_icdr_u {
2164 * this register is written. If there are any active entries in any * 2088 * this register is written. If there are any active entries in any *
2165 * of these FIFOs when this register is written, the results are * 2089 * of these FIFOs when this register is written, the results are *
2166 * undefined. * 2090 * undefined. *
2167 * * 2091 * *
2168 ************************************************************************/ 2092 ************************************************************************/
2169 2093
2170typedef union ii_ifdr_u { 2094typedef union ii_ifdr_u {
2171 uint64_t ii_ifdr_regval; 2095 uint64_t ii_ifdr_regval;
2172 struct { 2096 struct {
2173 uint64_t i_ioq_max_rq : 7; 2097 uint64_t i_ioq_max_rq:7;
2174 uint64_t i_set_ioq_rq : 1; 2098 uint64_t i_set_ioq_rq:1;
2175 uint64_t i_ioq_max_rp : 7; 2099 uint64_t i_ioq_max_rp:7;
2176 uint64_t i_set_ioq_rp : 1; 2100 uint64_t i_set_ioq_rp:1;
2177 uint64_t i_rsvd : 48; 2101 uint64_t i_rsvd:48;
2178 } ii_ifdr_fld_s; 2102 } ii_ifdr_fld_s;
2179} ii_ifdr_u_t; 2103} ii_ifdr_u_t;
2180 2104
2181
2182/************************************************************************ 2105/************************************************************************
2183 * * 2106 * *
2184 * This register allows the II to become sluggish in removing * 2107 * This register allows the II to become sluggish in removing *
2185 * messages from its inbound queue (IIQ). This will cause messages to * 2108 * messages from its inbound queue (IIQ). This will cause messages to *
2186 * back up in either virtual channel. Disabling the "molasses" mode * 2109 * back up in either virtual channel. Disabling the "molasses" mode *
2187 * subsequently allows the II to be tested under stress. In the * 2110 * subsequently allows the II to be tested under stress. In the *
2188 * sluggish ("Molasses") mode, the localized effects of congestion * 2111 * sluggish ("Molasses") mode, the localized effects of congestion *
2189 * can be observed. * 2112 * can be observed. *
2190 * * 2113 * *
2191 ************************************************************************/ 2114 ************************************************************************/
2192 2115
2193typedef union ii_iiap_u { 2116typedef union ii_iiap_u {
2194 uint64_t ii_iiap_regval; 2117 uint64_t ii_iiap_regval;
2195 struct { 2118 struct {
2196 uint64_t i_rq_mls : 6; 2119 uint64_t i_rq_mls:6;
2197 uint64_t i_rsvd_1 : 2; 2120 uint64_t i_rsvd_1:2;
2198 uint64_t i_rp_mls : 6; 2121 uint64_t i_rp_mls:6;
2199 uint64_t i_rsvd : 50; 2122 uint64_t i_rsvd:50;
2200 } ii_iiap_fld_s; 2123 } ii_iiap_fld_s;
2201} ii_iiap_u_t; 2124} ii_iiap_u_t;
2202 2125
2203
2204/************************************************************************ 2126/************************************************************************
2205 * * 2127 * *
2206 * This register allows several parameters of CRB operation to be * 2128 * This register allows several parameters of CRB operation to be *
2207 * set. Note that writing to this register can have catastrophic side * 2129 * set. Note that writing to this register can have catastrophic side *
2208 * effects, if the CRB is not quiescent, i.e. if the CRB is * 2130 * effects, if the CRB is not quiescent, i.e. if the CRB is *
2209 * processing protocol messages when the write occurs. * 2131 * processing protocol messages when the write occurs. *
2210 * * 2132 * *
2211 ************************************************************************/ 2133 ************************************************************************/
2212 2134
2213typedef union ii_icmr_u { 2135typedef union ii_icmr_u {
2214 uint64_t ii_icmr_regval; 2136 uint64_t ii_icmr_regval;
2215 struct { 2137 struct {
2216 uint64_t i_sp_msg : 1; 2138 uint64_t i_sp_msg:1;
2217 uint64_t i_rd_hdr : 1; 2139 uint64_t i_rd_hdr:1;
2218 uint64_t i_rsvd_4 : 2; 2140 uint64_t i_rsvd_4:2;
2219 uint64_t i_c_cnt : 4; 2141 uint64_t i_c_cnt:4;
2220 uint64_t i_rsvd_3 : 4; 2142 uint64_t i_rsvd_3:4;
2221 uint64_t i_clr_rqpd : 1; 2143 uint64_t i_clr_rqpd:1;
2222 uint64_t i_clr_rppd : 1; 2144 uint64_t i_clr_rppd:1;
2223 uint64_t i_rsvd_2 : 2; 2145 uint64_t i_rsvd_2:2;
2224 uint64_t i_fc_cnt : 4; 2146 uint64_t i_fc_cnt:4;
2225 uint64_t i_crb_vld : 15; 2147 uint64_t i_crb_vld:15;
2226 uint64_t i_crb_mark : 15; 2148 uint64_t i_crb_mark:15;
2227 uint64_t i_rsvd_1 : 2; 2149 uint64_t i_rsvd_1:2;
2228 uint64_t i_precise : 1; 2150 uint64_t i_precise:1;
2229 uint64_t i_rsvd : 11; 2151 uint64_t i_rsvd:11;
2230 } ii_icmr_fld_s; 2152 } ii_icmr_fld_s;
2231} ii_icmr_u_t; 2153} ii_icmr_u_t;
2232 2154
2233
2234/************************************************************************ 2155/************************************************************************
2235 * * 2156 * *
2236 * This register allows control of the table portion of the CRB * 2157 * This register allows control of the table portion of the CRB *
2237 * logic via software. Control operations from this register have * 2158 * logic via software. Control operations from this register have *
2238 * priority over all incoming Crosstalk or BTE requests. * 2159 * priority over all incoming Crosstalk or BTE requests. *
2239 * * 2160 * *
2240 ************************************************************************/ 2161 ************************************************************************/
2241 2162
2242typedef union ii_iccr_u { 2163typedef union ii_iccr_u {
2243 uint64_t ii_iccr_regval; 2164 uint64_t ii_iccr_regval;
2244 struct { 2165 struct {
2245 uint64_t i_crb_num : 4; 2166 uint64_t i_crb_num:4;
2246 uint64_t i_rsvd_1 : 4; 2167 uint64_t i_rsvd_1:4;
2247 uint64_t i_cmd : 8; 2168 uint64_t i_cmd:8;
2248 uint64_t i_pending : 1; 2169 uint64_t i_pending:1;
2249 uint64_t i_rsvd : 47; 2170 uint64_t i_rsvd:47;
2250 } ii_iccr_fld_s; 2171 } ii_iccr_fld_s;
2251} ii_iccr_u_t; 2172} ii_iccr_u_t;
2252 2173
2253
2254/************************************************************************ 2174/************************************************************************
2255 * * 2175 * *
2256 * This register allows the maximum timeout value to be programmed. * 2176 * This register allows the maximum timeout value to be programmed. *
2257 * * 2177 * *
2258 ************************************************************************/ 2178 ************************************************************************/
2259 2179
2260typedef union ii_icto_u { 2180typedef union ii_icto_u {
2261 uint64_t ii_icto_regval; 2181 uint64_t ii_icto_regval;
2262 struct { 2182 struct {
2263 uint64_t i_timeout : 8; 2183 uint64_t i_timeout:8;
2264 uint64_t i_rsvd : 56; 2184 uint64_t i_rsvd:56;
2265 } ii_icto_fld_s; 2185 } ii_icto_fld_s;
2266} ii_icto_u_t; 2186} ii_icto_u_t;
2267 2187
2268
2269/************************************************************************ 2188/************************************************************************
2270 * * 2189 * *
2271 * This register allows the timeout prescalar to be programmed. An * 2190 * This register allows the timeout prescalar to be programmed. An *
2272 * internal counter is associated with this register. When the * 2191 * internal counter is associated with this register. When the *
2273 * internal counter reaches the value of the PRESCALE field, the * 2192 * internal counter reaches the value of the PRESCALE field, the *
2274 * timer registers in all valid CRBs are incremented (CRBx_D[TIMEOUT] * 2193 * timer registers in all valid CRBs are incremented (CRBx_D[TIMEOUT] *
2275 * field). The internal counter resets to zero, and then continues * 2194 * field). The internal counter resets to zero, and then continues *
2276 * counting. * 2195 * counting. *
2277 * * 2196 * *
2278 ************************************************************************/ 2197 ************************************************************************/
2279 2198
2280typedef union ii_ictp_u { 2199typedef union ii_ictp_u {
2281 uint64_t ii_ictp_regval; 2200 uint64_t ii_ictp_regval;
2282 struct { 2201 struct {
2283 uint64_t i_prescale : 24; 2202 uint64_t i_prescale:24;
2284 uint64_t i_rsvd : 40; 2203 uint64_t i_rsvd:40;
2285 } ii_ictp_fld_s; 2204 } ii_ictp_fld_s;
2286} ii_ictp_u_t; 2205} ii_ictp_u_t;
2287 2206
2288
2289/************************************************************************ 2207/************************************************************************
2290 * * 2208 * *
2291 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are * 2209 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are *
2292 * used for Crosstalk operations (both cacheline and partial * 2210 * used for Crosstalk operations (both cacheline and partial *
2293 * operations) or BTE/IO. Because the CRB entries are very wide, five * 2211 * operations) or BTE/IO. Because the CRB entries are very wide, five *
@@ -2306,243 +2224,234 @@ typedef union ii_ictp_u {
2306 * recovering any potential error state from before the reset). * 2224 * recovering any potential error state from before the reset). *
2307 * The following four tables summarize the format for the four * 2225 * The following four tables summarize the format for the four *
2308 * registers that are used for each ICRB# Entry. * 2226 * registers that are used for each ICRB# Entry. *
2309 * * 2227 * *
2310 ************************************************************************/ 2228 ************************************************************************/
2311 2229
2312typedef union ii_icrb0_a_u { 2230typedef union ii_icrb0_a_u {
2313 uint64_t ii_icrb0_a_regval; 2231 uint64_t ii_icrb0_a_regval;
2314 struct { 2232 struct {
2315 uint64_t ia_iow : 1; 2233 uint64_t ia_iow:1;
2316 uint64_t ia_vld : 1; 2234 uint64_t ia_vld:1;
2317 uint64_t ia_addr : 47; 2235 uint64_t ia_addr:47;
2318 uint64_t ia_tnum : 5; 2236 uint64_t ia_tnum:5;
2319 uint64_t ia_sidn : 4; 2237 uint64_t ia_sidn:4;
2320 uint64_t ia_rsvd : 6; 2238 uint64_t ia_rsvd:6;
2321 } ii_icrb0_a_fld_s; 2239 } ii_icrb0_a_fld_s;
2322} ii_icrb0_a_u_t; 2240} ii_icrb0_a_u_t;
2323 2241
2324
2325/************************************************************************ 2242/************************************************************************
2326 * * 2243 * *
2327 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are * 2244 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are *
2328 * used for Crosstalk operations (both cacheline and partial * 2245 * used for Crosstalk operations (both cacheline and partial *
2329 * operations) or BTE/IO. Because the CRB entries are very wide, five * 2246 * operations) or BTE/IO. Because the CRB entries are very wide, five *
2330 * registers (_A to _E) are required to read and write each entry. * 2247 * registers (_A to _E) are required to read and write each entry. *
2331 * * 2248 * *
2332 ************************************************************************/ 2249 ************************************************************************/
2333 2250
2334typedef union ii_icrb0_b_u { 2251typedef union ii_icrb0_b_u {
2335 uint64_t ii_icrb0_b_regval; 2252 uint64_t ii_icrb0_b_regval;
2336 struct { 2253 struct {
2337 uint64_t ib_xt_err : 1; 2254 uint64_t ib_xt_err:1;
2338 uint64_t ib_mark : 1; 2255 uint64_t ib_mark:1;
2339 uint64_t ib_ln_uce : 1; 2256 uint64_t ib_ln_uce:1;
2340 uint64_t ib_errcode : 3; 2257 uint64_t ib_errcode:3;
2341 uint64_t ib_error : 1; 2258 uint64_t ib_error:1;
2342 uint64_t ib_stall__bte_1 : 1; 2259 uint64_t ib_stall__bte_1:1;
2343 uint64_t ib_stall__bte_0 : 1; 2260 uint64_t ib_stall__bte_0:1;
2344 uint64_t ib_stall__intr : 1; 2261 uint64_t ib_stall__intr:1;
2345 uint64_t ib_stall_ib : 1; 2262 uint64_t ib_stall_ib:1;
2346 uint64_t ib_intvn : 1; 2263 uint64_t ib_intvn:1;
2347 uint64_t ib_wb : 1; 2264 uint64_t ib_wb:1;
2348 uint64_t ib_hold : 1; 2265 uint64_t ib_hold:1;
2349 uint64_t ib_ack : 1; 2266 uint64_t ib_ack:1;
2350 uint64_t ib_resp : 1; 2267 uint64_t ib_resp:1;
2351 uint64_t ib_ack_cnt : 11; 2268 uint64_t ib_ack_cnt:11;
2352 uint64_t ib_rsvd : 7; 2269 uint64_t ib_rsvd:7;
2353 uint64_t ib_exc : 5; 2270 uint64_t ib_exc:5;
2354 uint64_t ib_init : 3; 2271 uint64_t ib_init:3;
2355 uint64_t ib_imsg : 8; 2272 uint64_t ib_imsg:8;
2356 uint64_t ib_imsgtype : 2; 2273 uint64_t ib_imsgtype:2;
2357 uint64_t ib_use_old : 1; 2274 uint64_t ib_use_old:1;
2358 uint64_t ib_rsvd_1 : 11; 2275 uint64_t ib_rsvd_1:11;
2359 } ii_icrb0_b_fld_s; 2276 } ii_icrb0_b_fld_s;
2360} ii_icrb0_b_u_t; 2277} ii_icrb0_b_u_t;
2361 2278
2362
2363/************************************************************************ 2279/************************************************************************
2364 * * 2280 * *
2365 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are * 2281 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are *
2366 * used for Crosstalk operations (both cacheline and partial * 2282 * used for Crosstalk operations (both cacheline and partial *
2367 * operations) or BTE/IO. Because the CRB entries are very wide, five * 2283 * operations) or BTE/IO. Because the CRB entries are very wide, five *
2368 * registers (_A to _E) are required to read and write each entry. * 2284 * registers (_A to _E) are required to read and write each entry. *
2369 * * 2285 * *
2370 ************************************************************************/ 2286 ************************************************************************/
2371 2287
2372typedef union ii_icrb0_c_u { 2288typedef union ii_icrb0_c_u {
2373 uint64_t ii_icrb0_c_regval; 2289 uint64_t ii_icrb0_c_regval;
2374 struct { 2290 struct {
2375 uint64_t ic_source : 15; 2291 uint64_t ic_source:15;
2376 uint64_t ic_size : 2; 2292 uint64_t ic_size:2;
2377 uint64_t ic_ct : 1; 2293 uint64_t ic_ct:1;
2378 uint64_t ic_bte_num : 1; 2294 uint64_t ic_bte_num:1;
2379 uint64_t ic_gbr : 1; 2295 uint64_t ic_gbr:1;
2380 uint64_t ic_resprqd : 1; 2296 uint64_t ic_resprqd:1;
2381 uint64_t ic_bo : 1; 2297 uint64_t ic_bo:1;
2382 uint64_t ic_suppl : 15; 2298 uint64_t ic_suppl:15;
2383 uint64_t ic_rsvd : 27; 2299 uint64_t ic_rsvd:27;
2384 } ii_icrb0_c_fld_s; 2300 } ii_icrb0_c_fld_s;
2385} ii_icrb0_c_u_t; 2301} ii_icrb0_c_u_t;
2386 2302
2387
2388/************************************************************************ 2303/************************************************************************
2389 * * 2304 * *
2390 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are * 2305 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are *
2391 * used for Crosstalk operations (both cacheline and partial * 2306 * used for Crosstalk operations (both cacheline and partial *
2392 * operations) or BTE/IO. Because the CRB entries are very wide, five * 2307 * operations) or BTE/IO. Because the CRB entries are very wide, five *
2393 * registers (_A to _E) are required to read and write each entry. * 2308 * registers (_A to _E) are required to read and write each entry. *
2394 * * 2309 * *
2395 ************************************************************************/ 2310 ************************************************************************/
2396 2311
2397typedef union ii_icrb0_d_u { 2312typedef union ii_icrb0_d_u {
2398 uint64_t ii_icrb0_d_regval; 2313 uint64_t ii_icrb0_d_regval;
2399 struct { 2314 struct {
2400 uint64_t id_pa_be : 43; 2315 uint64_t id_pa_be:43;
2401 uint64_t id_bte_op : 1; 2316 uint64_t id_bte_op:1;
2402 uint64_t id_pr_psc : 4; 2317 uint64_t id_pr_psc:4;
2403 uint64_t id_pr_cnt : 4; 2318 uint64_t id_pr_cnt:4;
2404 uint64_t id_sleep : 1; 2319 uint64_t id_sleep:1;
2405 uint64_t id_rsvd : 11; 2320 uint64_t id_rsvd:11;
2406 } ii_icrb0_d_fld_s; 2321 } ii_icrb0_d_fld_s;
2407} ii_icrb0_d_u_t; 2322} ii_icrb0_d_u_t;
2408 2323
2409
2410/************************************************************************ 2324/************************************************************************
2411 * * 2325 * *
2412 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are * 2326 * Description: There are 15 CRB Entries (ICRB0 to ICRBE) that are *
2413 * used for Crosstalk operations (both cacheline and partial * 2327 * used for Crosstalk operations (both cacheline and partial *
2414 * operations) or BTE/IO. Because the CRB entries are very wide, five * 2328 * operations) or BTE/IO. Because the CRB entries are very wide, five *
2415 * registers (_A to _E) are required to read and write each entry. * 2329 * registers (_A to _E) are required to read and write each entry. *
2416 * * 2330 * *
2417 ************************************************************************/ 2331 ************************************************************************/
2418 2332
2419typedef union ii_icrb0_e_u { 2333typedef union ii_icrb0_e_u {
2420 uint64_t ii_icrb0_e_regval; 2334 uint64_t ii_icrb0_e_regval;
2421 struct { 2335 struct {
2422 uint64_t ie_timeout : 8; 2336 uint64_t ie_timeout:8;
2423 uint64_t ie_context : 15; 2337 uint64_t ie_context:15;
2424 uint64_t ie_rsvd : 1; 2338 uint64_t ie_rsvd:1;
2425 uint64_t ie_tvld : 1; 2339 uint64_t ie_tvld:1;
2426 uint64_t ie_cvld : 1; 2340 uint64_t ie_cvld:1;
2427 uint64_t ie_rsvd_0 : 38; 2341 uint64_t ie_rsvd_0:38;
2428 } ii_icrb0_e_fld_s; 2342 } ii_icrb0_e_fld_s;
2429} ii_icrb0_e_u_t; 2343} ii_icrb0_e_u_t;
2430 2344
2431
2432/************************************************************************ 2345/************************************************************************
2433 * * 2346 * *
2434 * This register contains the lower 64 bits of the header of the * 2347 * This register contains the lower 64 bits of the header of the *
2435 * spurious message captured by II. Valid when the SP_MSG bit in ICMR * 2348 * spurious message captured by II. Valid when the SP_MSG bit in ICMR *
2436 * register is set. * 2349 * register is set. *
2437 * * 2350 * *
2438 ************************************************************************/ 2351 ************************************************************************/
2439 2352
2440typedef union ii_icsml_u { 2353typedef union ii_icsml_u {
2441 uint64_t ii_icsml_regval; 2354 uint64_t ii_icsml_regval;
2442 struct { 2355 struct {
2443 uint64_t i_tt_addr : 47; 2356 uint64_t i_tt_addr:47;
2444 uint64_t i_newsuppl_ex : 14; 2357 uint64_t i_newsuppl_ex:14;
2445 uint64_t i_reserved : 2; 2358 uint64_t i_reserved:2;
2446 uint64_t i_overflow : 1; 2359 uint64_t i_overflow:1;
2447 } ii_icsml_fld_s; 2360 } ii_icsml_fld_s;
2448} ii_icsml_u_t; 2361} ii_icsml_u_t;
2449 2362
2450
2451/************************************************************************ 2363/************************************************************************
2452 * * 2364 * *
2453 * This register contains the middle 64 bits of the header of the * 2365 * This register contains the middle 64 bits of the header of the *
2454 * spurious message captured by II. Valid when the SP_MSG bit in ICMR * 2366 * spurious message captured by II. Valid when the SP_MSG bit in ICMR *
2455 * register is set. * 2367 * register is set. *
2456 * * 2368 * *
2457 ************************************************************************/ 2369 ************************************************************************/
2458 2370
2459typedef union ii_icsmm_u { 2371typedef union ii_icsmm_u {
2460 uint64_t ii_icsmm_regval; 2372 uint64_t ii_icsmm_regval;
2461 struct { 2373 struct {
2462 uint64_t i_tt_ack_cnt : 11; 2374 uint64_t i_tt_ack_cnt:11;
2463 uint64_t i_reserved : 53; 2375 uint64_t i_reserved:53;
2464 } ii_icsmm_fld_s; 2376 } ii_icsmm_fld_s;
2465} ii_icsmm_u_t; 2377} ii_icsmm_u_t;
2466 2378
2467
2468/************************************************************************ 2379/************************************************************************
2469 * * 2380 * *
2470 * This register contains the microscopic state, all the inputs to * 2381 * This register contains the microscopic state, all the inputs to *
2471 * the protocol table, captured with the spurious message. Valid when * 2382 * the protocol table, captured with the spurious message. Valid when *
2472 * the SP_MSG bit in the ICMR register is set. * 2383 * the SP_MSG bit in the ICMR register is set. *
2473 * * 2384 * *
2474 ************************************************************************/ 2385 ************************************************************************/
2475 2386
2476typedef union ii_icsmh_u { 2387typedef union ii_icsmh_u {
2477 uint64_t ii_icsmh_regval; 2388 uint64_t ii_icsmh_regval;
2478 struct { 2389 struct {
2479 uint64_t i_tt_vld : 1; 2390 uint64_t i_tt_vld:1;
2480 uint64_t i_xerr : 1; 2391 uint64_t i_xerr:1;
2481 uint64_t i_ft_cwact_o : 1; 2392 uint64_t i_ft_cwact_o:1;
2482 uint64_t i_ft_wact_o : 1; 2393 uint64_t i_ft_wact_o:1;
2483 uint64_t i_ft_active_o : 1; 2394 uint64_t i_ft_active_o:1;
2484 uint64_t i_sync : 1; 2395 uint64_t i_sync:1;
2485 uint64_t i_mnusg : 1; 2396 uint64_t i_mnusg:1;
2486 uint64_t i_mnusz : 1; 2397 uint64_t i_mnusz:1;
2487 uint64_t i_plusz : 1; 2398 uint64_t i_plusz:1;
2488 uint64_t i_plusg : 1; 2399 uint64_t i_plusg:1;
2489 uint64_t i_tt_exc : 5; 2400 uint64_t i_tt_exc:5;
2490 uint64_t i_tt_wb : 1; 2401 uint64_t i_tt_wb:1;
2491 uint64_t i_tt_hold : 1; 2402 uint64_t i_tt_hold:1;
2492 uint64_t i_tt_ack : 1; 2403 uint64_t i_tt_ack:1;
2493 uint64_t i_tt_resp : 1; 2404 uint64_t i_tt_resp:1;
2494 uint64_t i_tt_intvn : 1; 2405 uint64_t i_tt_intvn:1;
2495 uint64_t i_g_stall_bte1 : 1; 2406 uint64_t i_g_stall_bte1:1;
2496 uint64_t i_g_stall_bte0 : 1; 2407 uint64_t i_g_stall_bte0:1;
2497 uint64_t i_g_stall_il : 1; 2408 uint64_t i_g_stall_il:1;
2498 uint64_t i_g_stall_ib : 1; 2409 uint64_t i_g_stall_ib:1;
2499 uint64_t i_tt_imsg : 8; 2410 uint64_t i_tt_imsg:8;
2500 uint64_t i_tt_imsgtype : 2; 2411 uint64_t i_tt_imsgtype:2;
2501 uint64_t i_tt_use_old : 1; 2412 uint64_t i_tt_use_old:1;
2502 uint64_t i_tt_respreqd : 1; 2413 uint64_t i_tt_respreqd:1;
2503 uint64_t i_tt_bte_num : 1; 2414 uint64_t i_tt_bte_num:1;
2504 uint64_t i_cbn : 1; 2415 uint64_t i_cbn:1;
2505 uint64_t i_match : 1; 2416 uint64_t i_match:1;
2506 uint64_t i_rpcnt_lt_34 : 1; 2417 uint64_t i_rpcnt_lt_34:1;
2507 uint64_t i_rpcnt_ge_34 : 1; 2418 uint64_t i_rpcnt_ge_34:1;
2508 uint64_t i_rpcnt_lt_18 : 1; 2419 uint64_t i_rpcnt_lt_18:1;
2509 uint64_t i_rpcnt_ge_18 : 1; 2420 uint64_t i_rpcnt_ge_18:1;
2510 uint64_t i_rpcnt_lt_2 : 1; 2421 uint64_t i_rpcnt_lt_2:1;
2511 uint64_t i_rpcnt_ge_2 : 1; 2422 uint64_t i_rpcnt_ge_2:1;
2512 uint64_t i_rqcnt_lt_18 : 1; 2423 uint64_t i_rqcnt_lt_18:1;
2513 uint64_t i_rqcnt_ge_18 : 1; 2424 uint64_t i_rqcnt_ge_18:1;
2514 uint64_t i_rqcnt_lt_2 : 1; 2425 uint64_t i_rqcnt_lt_2:1;
2515 uint64_t i_rqcnt_ge_2 : 1; 2426 uint64_t i_rqcnt_ge_2:1;
2516 uint64_t i_tt_device : 7; 2427 uint64_t i_tt_device:7;
2517 uint64_t i_tt_init : 3; 2428 uint64_t i_tt_init:3;
2518 uint64_t i_reserved : 5; 2429 uint64_t i_reserved:5;
2519 } ii_icsmh_fld_s; 2430 } ii_icsmh_fld_s;
2520} ii_icsmh_u_t; 2431} ii_icsmh_u_t;
2521 2432
2522
2523/************************************************************************ 2433/************************************************************************
2524 * * 2434 * *
2525 * The Shub DEBUG unit provides a 3-bit selection signal to the * 2435 * The Shub DEBUG unit provides a 3-bit selection signal to the *
2526 * II core and a 3-bit selection signal to the fsbclk domain in the II * 2436 * II core and a 3-bit selection signal to the fsbclk domain in the II *
2527 * wrapper. * 2437 * wrapper. *
2528 * * 2438 * *
2529 ************************************************************************/ 2439 ************************************************************************/
2530 2440
2531typedef union ii_idbss_u { 2441typedef union ii_idbss_u {
2532 uint64_t ii_idbss_regval; 2442 uint64_t ii_idbss_regval;
2533 struct { 2443 struct {
2534 uint64_t i_iioclk_core_submenu : 3; 2444 uint64_t i_iioclk_core_submenu:3;
2535 uint64_t i_rsvd : 5; 2445 uint64_t i_rsvd:5;
2536 uint64_t i_fsbclk_wrapper_submenu : 3; 2446 uint64_t i_fsbclk_wrapper_submenu:3;
2537 uint64_t i_rsvd_1 : 5; 2447 uint64_t i_rsvd_1:5;
2538 uint64_t i_iioclk_menu : 5; 2448 uint64_t i_iioclk_menu:5;
2539 uint64_t i_rsvd_2 : 43; 2449 uint64_t i_rsvd_2:43;
2540 } ii_idbss_fld_s; 2450 } ii_idbss_fld_s;
2541} ii_idbss_u_t; 2451} ii_idbss_u_t;
2542 2452
2543
2544/************************************************************************ 2453/************************************************************************
2545 * * 2454 * *
2546 * Description: This register is used to set up the length for a * 2455 * Description: This register is used to set up the length for a *
2547 * transfer and then to monitor the progress of that transfer. This * 2456 * transfer and then to monitor the progress of that transfer. This *
2548 * register needs to be initialized before a transfer is started. A * 2457 * register needs to be initialized before a transfer is started. A *
@@ -2553,63 +2462,60 @@ typedef union ii_idbss_u {
2553 * transfer completes, hardware will clear the Busy bit. The length * 2462 * transfer completes, hardware will clear the Busy bit. The length *
2554 * field will also contain the number of cache lines left to be * 2463 * field will also contain the number of cache lines left to be *
2555 * transferred. * 2464 * transferred. *
2556 * * 2465 * *
2557 ************************************************************************/ 2466 ************************************************************************/
2558 2467
2559typedef union ii_ibls0_u { 2468typedef union ii_ibls0_u {
2560 uint64_t ii_ibls0_regval; 2469 uint64_t ii_ibls0_regval;
2561 struct { 2470 struct {
2562 uint64_t i_length : 16; 2471 uint64_t i_length:16;
2563 uint64_t i_error : 1; 2472 uint64_t i_error:1;
2564 uint64_t i_rsvd_1 : 3; 2473 uint64_t i_rsvd_1:3;
2565 uint64_t i_busy : 1; 2474 uint64_t i_busy:1;
2566 uint64_t i_rsvd : 43; 2475 uint64_t i_rsvd:43;
2567 } ii_ibls0_fld_s; 2476 } ii_ibls0_fld_s;
2568} ii_ibls0_u_t; 2477} ii_ibls0_u_t;
2569 2478
2570
2571/************************************************************************ 2479/************************************************************************
2572 * * 2480 * *
2573 * This register should be loaded before a transfer is started. The * 2481 * This register should be loaded before a transfer is started. The *
2574 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical * 2482 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical *
2575 * address as described in Section 1.3, Figure2 and Figure3. Since * 2483 * address as described in Section 1.3, Figure2 and Figure3. Since *
2576 * the bottom 7 bits of the address are always taken to be zero, BTE * 2484 * the bottom 7 bits of the address are always taken to be zero, BTE *
2577 * transfers are always cacheline-aligned. * 2485 * transfers are always cacheline-aligned. *
2578 * * 2486 * *
2579 ************************************************************************/ 2487 ************************************************************************/
2580 2488
2581typedef union ii_ibsa0_u { 2489typedef union ii_ibsa0_u {
2582 uint64_t ii_ibsa0_regval; 2490 uint64_t ii_ibsa0_regval;
2583 struct { 2491 struct {
2584 uint64_t i_rsvd_1 : 7; 2492 uint64_t i_rsvd_1:7;
2585 uint64_t i_addr : 42; 2493 uint64_t i_addr:42;
2586 uint64_t i_rsvd : 15; 2494 uint64_t i_rsvd:15;
2587 } ii_ibsa0_fld_s; 2495 } ii_ibsa0_fld_s;
2588} ii_ibsa0_u_t; 2496} ii_ibsa0_u_t;
2589 2497
2590
2591/************************************************************************ 2498/************************************************************************
2592 * * 2499 * *
2593 * This register should be loaded before a transfer is started. The * 2500 * This register should be loaded before a transfer is started. The *
2594 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical * 2501 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical *
2595 * address as described in Section 1.3, Figure2 and Figure3. Since * 2502 * address as described in Section 1.3, Figure2 and Figure3. Since *
2596 * the bottom 7 bits of the address are always taken to be zero, BTE * 2503 * the bottom 7 bits of the address are always taken to be zero, BTE *
2597 * transfers are always cacheline-aligned. * 2504 * transfers are always cacheline-aligned. *
2598 * * 2505 * *
2599 ************************************************************************/ 2506 ************************************************************************/
2600 2507
2601typedef union ii_ibda0_u { 2508typedef union ii_ibda0_u {
2602 uint64_t ii_ibda0_regval; 2509 uint64_t ii_ibda0_regval;
2603 struct { 2510 struct {
2604 uint64_t i_rsvd_1 : 7; 2511 uint64_t i_rsvd_1:7;
2605 uint64_t i_addr : 42; 2512 uint64_t i_addr:42;
2606 uint64_t i_rsvd : 15; 2513 uint64_t i_rsvd:15;
2607 } ii_ibda0_fld_s; 2514 } ii_ibda0_fld_s;
2608} ii_ibda0_u_t; 2515} ii_ibda0_u_t;
2609 2516
2610
2611/************************************************************************ 2517/************************************************************************
2612 * * 2518 * *
2613 * Writing to this register sets up the attributes of the transfer * 2519 * Writing to this register sets up the attributes of the transfer *
2614 * and initiates the transfer operation. Reading this register has * 2520 * and initiates the transfer operation. Reading this register has *
2615 * the side effect of terminating any transfer in progress. Note: * 2521 * the side effect of terminating any transfer in progress. Note: *
@@ -2617,61 +2523,58 @@ typedef union ii_ibda0_u {
2617 * other BTE. If a BTE stream has to be stopped (due to error * 2523 * other BTE. If a BTE stream has to be stopped (due to error *
2618 * handling for example), both BTE streams should be stopped and * 2524 * handling for example), both BTE streams should be stopped and *
2619 * their transfers discarded. * 2525 * their transfers discarded. *
2620 * * 2526 * *
2621 ************************************************************************/ 2527 ************************************************************************/
2622 2528
2623typedef union ii_ibct0_u { 2529typedef union ii_ibct0_u {
2624 uint64_t ii_ibct0_regval; 2530 uint64_t ii_ibct0_regval;
2625 struct { 2531 struct {
2626 uint64_t i_zerofill : 1; 2532 uint64_t i_zerofill:1;
2627 uint64_t i_rsvd_2 : 3; 2533 uint64_t i_rsvd_2:3;
2628 uint64_t i_notify : 1; 2534 uint64_t i_notify:1;
2629 uint64_t i_rsvd_1 : 3; 2535 uint64_t i_rsvd_1:3;
2630 uint64_t i_poison : 1; 2536 uint64_t i_poison:1;
2631 uint64_t i_rsvd : 55; 2537 uint64_t i_rsvd:55;
2632 } ii_ibct0_fld_s; 2538 } ii_ibct0_fld_s;
2633} ii_ibct0_u_t; 2539} ii_ibct0_u_t;
2634 2540
2635
2636/************************************************************************ 2541/************************************************************************
2637 * * 2542 * *
2638 * This register contains the address to which the WINV is sent. * 2543 * This register contains the address to which the WINV is sent. *
2639 * This address has to be cache line aligned. * 2544 * This address has to be cache line aligned. *
2640 * * 2545 * *
2641 ************************************************************************/ 2546 ************************************************************************/
2642 2547
2643typedef union ii_ibna0_u { 2548typedef union ii_ibna0_u {
2644 uint64_t ii_ibna0_regval; 2549 uint64_t ii_ibna0_regval;
2645 struct { 2550 struct {
2646 uint64_t i_rsvd_1 : 7; 2551 uint64_t i_rsvd_1:7;
2647 uint64_t i_addr : 42; 2552 uint64_t i_addr:42;
2648 uint64_t i_rsvd : 15; 2553 uint64_t i_rsvd:15;
2649 } ii_ibna0_fld_s; 2554 } ii_ibna0_fld_s;
2650} ii_ibna0_u_t; 2555} ii_ibna0_u_t;
2651 2556
2652
2653/************************************************************************ 2557/************************************************************************
2654 * * 2558 * *
2655 * This register contains the programmable level as well as the node * 2559 * This register contains the programmable level as well as the node *
2656 * ID and PI unit of the processor to which the interrupt will be * 2560 * ID and PI unit of the processor to which the interrupt will be *
2657 * sent. * 2561 * sent. *
2658 * * 2562 * *
2659 ************************************************************************/ 2563 ************************************************************************/
2660 2564
2661typedef union ii_ibia0_u { 2565typedef union ii_ibia0_u {
2662 uint64_t ii_ibia0_regval; 2566 uint64_t ii_ibia0_regval;
2663 struct { 2567 struct {
2664 uint64_t i_rsvd_2 : 1; 2568 uint64_t i_rsvd_2:1;
2665 uint64_t i_node_id : 11; 2569 uint64_t i_node_id:11;
2666 uint64_t i_rsvd_1 : 4; 2570 uint64_t i_rsvd_1:4;
2667 uint64_t i_level : 7; 2571 uint64_t i_level:7;
2668 uint64_t i_rsvd : 41; 2572 uint64_t i_rsvd:41;
2669 } ii_ibia0_fld_s; 2573 } ii_ibia0_fld_s;
2670} ii_ibia0_u_t; 2574} ii_ibia0_u_t;
2671 2575
2672
2673/************************************************************************ 2576/************************************************************************
2674 * * 2577 * *
2675 * Description: This register is used to set up the length for a * 2578 * Description: This register is used to set up the length for a *
2676 * transfer and then to monitor the progress of that transfer. This * 2579 * transfer and then to monitor the progress of that transfer. This *
2677 * register needs to be initialized before a transfer is started. A * 2580 * register needs to be initialized before a transfer is started. A *
@@ -2682,63 +2585,60 @@ typedef union ii_ibia0_u {
2682 * transfer completes, hardware will clear the Busy bit. The length * 2585 * transfer completes, hardware will clear the Busy bit. The length *
2683 * field will also contain the number of cache lines left to be * 2586 * field will also contain the number of cache lines left to be *
2684 * transferred. * 2587 * transferred. *
2685 * * 2588 * *
2686 ************************************************************************/ 2589 ************************************************************************/
2687 2590
2688typedef union ii_ibls1_u { 2591typedef union ii_ibls1_u {
2689 uint64_t ii_ibls1_regval; 2592 uint64_t ii_ibls1_regval;
2690 struct { 2593 struct {
2691 uint64_t i_length : 16; 2594 uint64_t i_length:16;
2692 uint64_t i_error : 1; 2595 uint64_t i_error:1;
2693 uint64_t i_rsvd_1 : 3; 2596 uint64_t i_rsvd_1:3;
2694 uint64_t i_busy : 1; 2597 uint64_t i_busy:1;
2695 uint64_t i_rsvd : 43; 2598 uint64_t i_rsvd:43;
2696 } ii_ibls1_fld_s; 2599 } ii_ibls1_fld_s;
2697} ii_ibls1_u_t; 2600} ii_ibls1_u_t;
2698 2601
2699
2700/************************************************************************ 2602/************************************************************************
2701 * * 2603 * *
2702 * This register should be loaded before a transfer is started. The * 2604 * This register should be loaded before a transfer is started. The *
2703 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical * 2605 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical *
2704 * address as described in Section 1.3, Figure2 and Figure3. Since * 2606 * address as described in Section 1.3, Figure2 and Figure3. Since *
2705 * the bottom 7 bits of the address are always taken to be zero, BTE * 2607 * the bottom 7 bits of the address are always taken to be zero, BTE *
2706 * transfers are always cacheline-aligned. * 2608 * transfers are always cacheline-aligned. *
2707 * * 2609 * *
2708 ************************************************************************/ 2610 ************************************************************************/
2709 2611
2710typedef union ii_ibsa1_u { 2612typedef union ii_ibsa1_u {
2711 uint64_t ii_ibsa1_regval; 2613 uint64_t ii_ibsa1_regval;
2712 struct { 2614 struct {
2713 uint64_t i_rsvd_1 : 7; 2615 uint64_t i_rsvd_1:7;
2714 uint64_t i_addr : 33; 2616 uint64_t i_addr:33;
2715 uint64_t i_rsvd : 24; 2617 uint64_t i_rsvd:24;
2716 } ii_ibsa1_fld_s; 2618 } ii_ibsa1_fld_s;
2717} ii_ibsa1_u_t; 2619} ii_ibsa1_u_t;
2718 2620
2719
2720/************************************************************************ 2621/************************************************************************
2721 * * 2622 * *
2722 * This register should be loaded before a transfer is started. The * 2623 * This register should be loaded before a transfer is started. The *
2723 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical * 2624 * address to be loaded in bits 39:0 is the 40-bit TRex+ physical *
2724 * address as described in Section 1.3, Figure2 and Figure3. Since * 2625 * address as described in Section 1.3, Figure2 and Figure3. Since *
2725 * the bottom 7 bits of the address are always taken to be zero, BTE * 2626 * the bottom 7 bits of the address are always taken to be zero, BTE *
2726 * transfers are always cacheline-aligned. * 2627 * transfers are always cacheline-aligned. *
2727 * * 2628 * *
2728 ************************************************************************/ 2629 ************************************************************************/
2729 2630
2730typedef union ii_ibda1_u { 2631typedef union ii_ibda1_u {
2731 uint64_t ii_ibda1_regval; 2632 uint64_t ii_ibda1_regval;
2732 struct { 2633 struct {
2733 uint64_t i_rsvd_1 : 7; 2634 uint64_t i_rsvd_1:7;
2734 uint64_t i_addr : 33; 2635 uint64_t i_addr:33;
2735 uint64_t i_rsvd : 24; 2636 uint64_t i_rsvd:24;
2736 } ii_ibda1_fld_s; 2637 } ii_ibda1_fld_s;
2737} ii_ibda1_u_t; 2638} ii_ibda1_u_t;
2738 2639
2739
2740/************************************************************************ 2640/************************************************************************
2741 * * 2641 * *
2742 * Writing to this register sets up the attributes of the transfer * 2642 * Writing to this register sets up the attributes of the transfer *
2743 * and initiates the transfer operation. Reading this register has * 2643 * and initiates the transfer operation. Reading this register has *
2744 * the side effect of terminating any transfer in progress. Note: * 2644 * the side effect of terminating any transfer in progress. Note: *
@@ -2746,61 +2646,58 @@ typedef union ii_ibda1_u {
2746 * other BTE. If a BTE stream has to be stopped (due to error * 2646 * other BTE. If a BTE stream has to be stopped (due to error *
2747 * handling for example), both BTE streams should be stopped and * 2647 * handling for example), both BTE streams should be stopped and *
2748 * their transfers discarded. * 2648 * their transfers discarded. *
2749 * * 2649 * *
2750 ************************************************************************/ 2650 ************************************************************************/
2751 2651
2752typedef union ii_ibct1_u { 2652typedef union ii_ibct1_u {
2753 uint64_t ii_ibct1_regval; 2653 uint64_t ii_ibct1_regval;
2754 struct { 2654 struct {
2755 uint64_t i_zerofill : 1; 2655 uint64_t i_zerofill:1;
2756 uint64_t i_rsvd_2 : 3; 2656 uint64_t i_rsvd_2:3;
2757 uint64_t i_notify : 1; 2657 uint64_t i_notify:1;
2758 uint64_t i_rsvd_1 : 3; 2658 uint64_t i_rsvd_1:3;
2759 uint64_t i_poison : 1; 2659 uint64_t i_poison:1;
2760 uint64_t i_rsvd : 55; 2660 uint64_t i_rsvd:55;
2761 } ii_ibct1_fld_s; 2661 } ii_ibct1_fld_s;
2762} ii_ibct1_u_t; 2662} ii_ibct1_u_t;
2763 2663
2764
2765/************************************************************************ 2664/************************************************************************
2766 * * 2665 * *
2767 * This register contains the address to which the WINV is sent. * 2666 * This register contains the address to which the WINV is sent. *
2768 * This address has to be cache line aligned. * 2667 * This address has to be cache line aligned. *
2769 * * 2668 * *
2770 ************************************************************************/ 2669 ************************************************************************/
2771 2670
2772typedef union ii_ibna1_u { 2671typedef union ii_ibna1_u {
2773 uint64_t ii_ibna1_regval; 2672 uint64_t ii_ibna1_regval;
2774 struct { 2673 struct {
2775 uint64_t i_rsvd_1 : 7; 2674 uint64_t i_rsvd_1:7;
2776 uint64_t i_addr : 33; 2675 uint64_t i_addr:33;
2777 uint64_t i_rsvd : 24; 2676 uint64_t i_rsvd:24;
2778 } ii_ibna1_fld_s; 2677 } ii_ibna1_fld_s;
2779} ii_ibna1_u_t; 2678} ii_ibna1_u_t;
2780 2679
2781
2782/************************************************************************ 2680/************************************************************************
2783 * * 2681 * *
2784 * This register contains the programmable level as well as the node * 2682 * This register contains the programmable level as well as the node *
2785 * ID and PI unit of the processor to which the interrupt will be * 2683 * ID and PI unit of the processor to which the interrupt will be *
2786 * sent. * 2684 * sent. *
2787 * * 2685 * *
2788 ************************************************************************/ 2686 ************************************************************************/
2789 2687
2790typedef union ii_ibia1_u { 2688typedef union ii_ibia1_u {
2791 uint64_t ii_ibia1_regval; 2689 uint64_t ii_ibia1_regval;
2792 struct { 2690 struct {
2793 uint64_t i_pi_id : 1; 2691 uint64_t i_pi_id:1;
2794 uint64_t i_node_id : 8; 2692 uint64_t i_node_id:8;
2795 uint64_t i_rsvd_1 : 7; 2693 uint64_t i_rsvd_1:7;
2796 uint64_t i_level : 7; 2694 uint64_t i_level:7;
2797 uint64_t i_rsvd : 41; 2695 uint64_t i_rsvd:41;
2798 } ii_ibia1_fld_s; 2696 } ii_ibia1_fld_s;
2799} ii_ibia1_u_t; 2697} ii_ibia1_u_t;
2800 2698
2801
2802/************************************************************************ 2699/************************************************************************
2803 * * 2700 * *
2804 * This register defines the resources that feed information into * 2701 * This register defines the resources that feed information into *
2805 * the two performance counters located in the IO Performance * 2702 * the two performance counters located in the IO Performance *
2806 * Profiling Register. There are 17 different quantities that can be * 2703 * Profiling Register. There are 17 different quantities that can be *
@@ -2811,133 +2708,129 @@ typedef union ii_ibia1_u {
2811 * other is available from the other performance counter. Hence, the * 2708 * other is available from the other performance counter. Hence, the *
2812 * II supports all 17*16=272 possible combinations of quantities to * 2709 * II supports all 17*16=272 possible combinations of quantities to *
2813 * measure. * 2710 * measure. *
2814 * * 2711 * *
2815 ************************************************************************/ 2712 ************************************************************************/
2816 2713
2817typedef union ii_ipcr_u { 2714typedef union ii_ipcr_u {
2818 uint64_t ii_ipcr_regval; 2715 uint64_t ii_ipcr_regval;
2819 struct { 2716 struct {
2820 uint64_t i_ippr0_c : 4; 2717 uint64_t i_ippr0_c:4;
2821 uint64_t i_ippr1_c : 4; 2718 uint64_t i_ippr1_c:4;
2822 uint64_t i_icct : 8; 2719 uint64_t i_icct:8;
2823 uint64_t i_rsvd : 48; 2720 uint64_t i_rsvd:48;
2824 } ii_ipcr_fld_s; 2721 } ii_ipcr_fld_s;
2825} ii_ipcr_u_t; 2722} ii_ipcr_u_t;
2826 2723
2827
2828/************************************************************************ 2724/************************************************************************
2829 * * 2725 * *
2830 * * 2726 * *
2831 * * 2727 * *
2832 ************************************************************************/ 2728 ************************************************************************/
2833 2729
2834typedef union ii_ippr_u { 2730typedef union ii_ippr_u {
2835 uint64_t ii_ippr_regval; 2731 uint64_t ii_ippr_regval;
2836 struct { 2732 struct {
2837 uint64_t i_ippr0 : 32; 2733 uint64_t i_ippr0:32;
2838 uint64_t i_ippr1 : 32; 2734 uint64_t i_ippr1:32;
2839 } ii_ippr_fld_s; 2735 } ii_ippr_fld_s;
2840} ii_ippr_u_t; 2736} ii_ippr_u_t;
2841 2737
2842 2738/************************************************************************
2843 2739 * *
2844/************************************************************************** 2740 * The following defines which were not formed into structures are *
2845 * * 2741 * probably indentical to another register, and the name of the *
2846 * The following defines which were not formed into structures are * 2742 * register is provided against each of these registers. This *
2847 * probably indentical to another register, and the name of the * 2743 * information needs to be checked carefully *
2848 * register is provided against each of these registers. This * 2744 * *
2849 * information needs to be checked carefully * 2745 * IIO_ICRB1_A IIO_ICRB0_A *
2850 * * 2746 * IIO_ICRB1_B IIO_ICRB0_B *
2851 * IIO_ICRB1_A IIO_ICRB0_A * 2747 * IIO_ICRB1_C IIO_ICRB0_C *
2852 * IIO_ICRB1_B IIO_ICRB0_B * 2748 * IIO_ICRB1_D IIO_ICRB0_D *
2853 * IIO_ICRB1_C IIO_ICRB0_C * 2749 * IIO_ICRB1_E IIO_ICRB0_E *
2854 * IIO_ICRB1_D IIO_ICRB0_D * 2750 * IIO_ICRB2_A IIO_ICRB0_A *
2855 * IIO_ICRB1_E IIO_ICRB0_E * 2751 * IIO_ICRB2_B IIO_ICRB0_B *
2856 * IIO_ICRB2_A IIO_ICRB0_A * 2752 * IIO_ICRB2_C IIO_ICRB0_C *
2857 * IIO_ICRB2_B IIO_ICRB0_B * 2753 * IIO_ICRB2_D IIO_ICRB0_D *
2858 * IIO_ICRB2_C IIO_ICRB0_C * 2754 * IIO_ICRB2_E IIO_ICRB0_E *
2859 * IIO_ICRB2_D IIO_ICRB0_D * 2755 * IIO_ICRB3_A IIO_ICRB0_A *
2860 * IIO_ICRB2_E IIO_ICRB0_E * 2756 * IIO_ICRB3_B IIO_ICRB0_B *
2861 * IIO_ICRB3_A IIO_ICRB0_A * 2757 * IIO_ICRB3_C IIO_ICRB0_C *
2862 * IIO_ICRB3_B IIO_ICRB0_B * 2758 * IIO_ICRB3_D IIO_ICRB0_D *
2863 * IIO_ICRB3_C IIO_ICRB0_C * 2759 * IIO_ICRB3_E IIO_ICRB0_E *
2864 * IIO_ICRB3_D IIO_ICRB0_D * 2760 * IIO_ICRB4_A IIO_ICRB0_A *
2865 * IIO_ICRB3_E IIO_ICRB0_E * 2761 * IIO_ICRB4_B IIO_ICRB0_B *
2866 * IIO_ICRB4_A IIO_ICRB0_A * 2762 * IIO_ICRB4_C IIO_ICRB0_C *
2867 * IIO_ICRB4_B IIO_ICRB0_B * 2763 * IIO_ICRB4_D IIO_ICRB0_D *
2868 * IIO_ICRB4_C IIO_ICRB0_C * 2764 * IIO_ICRB4_E IIO_ICRB0_E *
2869 * IIO_ICRB4_D IIO_ICRB0_D * 2765 * IIO_ICRB5_A IIO_ICRB0_A *
2870 * IIO_ICRB4_E IIO_ICRB0_E * 2766 * IIO_ICRB5_B IIO_ICRB0_B *
2871 * IIO_ICRB5_A IIO_ICRB0_A * 2767 * IIO_ICRB5_C IIO_ICRB0_C *
2872 * IIO_ICRB5_B IIO_ICRB0_B * 2768 * IIO_ICRB5_D IIO_ICRB0_D *
2873 * IIO_ICRB5_C IIO_ICRB0_C * 2769 * IIO_ICRB5_E IIO_ICRB0_E *
2874 * IIO_ICRB5_D IIO_ICRB0_D * 2770 * IIO_ICRB6_A IIO_ICRB0_A *
2875 * IIO_ICRB5_E IIO_ICRB0_E * 2771 * IIO_ICRB6_B IIO_ICRB0_B *
2876 * IIO_ICRB6_A IIO_ICRB0_A * 2772 * IIO_ICRB6_C IIO_ICRB0_C *
2877 * IIO_ICRB6_B IIO_ICRB0_B * 2773 * IIO_ICRB6_D IIO_ICRB0_D *
2878 * IIO_ICRB6_C IIO_ICRB0_C * 2774 * IIO_ICRB6_E IIO_ICRB0_E *
2879 * IIO_ICRB6_D IIO_ICRB0_D * 2775 * IIO_ICRB7_A IIO_ICRB0_A *
2880 * IIO_ICRB6_E IIO_ICRB0_E * 2776 * IIO_ICRB7_B IIO_ICRB0_B *
2881 * IIO_ICRB7_A IIO_ICRB0_A * 2777 * IIO_ICRB7_C IIO_ICRB0_C *
2882 * IIO_ICRB7_B IIO_ICRB0_B * 2778 * IIO_ICRB7_D IIO_ICRB0_D *
2883 * IIO_ICRB7_C IIO_ICRB0_C * 2779 * IIO_ICRB7_E IIO_ICRB0_E *
2884 * IIO_ICRB7_D IIO_ICRB0_D * 2780 * IIO_ICRB8_A IIO_ICRB0_A *
2885 * IIO_ICRB7_E IIO_ICRB0_E * 2781 * IIO_ICRB8_B IIO_ICRB0_B *
2886 * IIO_ICRB8_A IIO_ICRB0_A * 2782 * IIO_ICRB8_C IIO_ICRB0_C *
2887 * IIO_ICRB8_B IIO_ICRB0_B * 2783 * IIO_ICRB8_D IIO_ICRB0_D *
2888 * IIO_ICRB8_C IIO_ICRB0_C * 2784 * IIO_ICRB8_E IIO_ICRB0_E *
2889 * IIO_ICRB8_D IIO_ICRB0_D * 2785 * IIO_ICRB9_A IIO_ICRB0_A *
2890 * IIO_ICRB8_E IIO_ICRB0_E * 2786 * IIO_ICRB9_B IIO_ICRB0_B *
2891 * IIO_ICRB9_A IIO_ICRB0_A * 2787 * IIO_ICRB9_C IIO_ICRB0_C *
2892 * IIO_ICRB9_B IIO_ICRB0_B * 2788 * IIO_ICRB9_D IIO_ICRB0_D *
2893 * IIO_ICRB9_C IIO_ICRB0_C * 2789 * IIO_ICRB9_E IIO_ICRB0_E *
2894 * IIO_ICRB9_D IIO_ICRB0_D * 2790 * IIO_ICRBA_A IIO_ICRB0_A *
2895 * IIO_ICRB9_E IIO_ICRB0_E * 2791 * IIO_ICRBA_B IIO_ICRB0_B *
2896 * IIO_ICRBA_A IIO_ICRB0_A * 2792 * IIO_ICRBA_C IIO_ICRB0_C *
2897 * IIO_ICRBA_B IIO_ICRB0_B * 2793 * IIO_ICRBA_D IIO_ICRB0_D *
2898 * IIO_ICRBA_C IIO_ICRB0_C * 2794 * IIO_ICRBA_E IIO_ICRB0_E *
2899 * IIO_ICRBA_D IIO_ICRB0_D * 2795 * IIO_ICRBB_A IIO_ICRB0_A *
2900 * IIO_ICRBA_E IIO_ICRB0_E * 2796 * IIO_ICRBB_B IIO_ICRB0_B *
2901 * IIO_ICRBB_A IIO_ICRB0_A * 2797 * IIO_ICRBB_C IIO_ICRB0_C *
2902 * IIO_ICRBB_B IIO_ICRB0_B * 2798 * IIO_ICRBB_D IIO_ICRB0_D *
2903 * IIO_ICRBB_C IIO_ICRB0_C * 2799 * IIO_ICRBB_E IIO_ICRB0_E *
2904 * IIO_ICRBB_D IIO_ICRB0_D * 2800 * IIO_ICRBC_A IIO_ICRB0_A *
2905 * IIO_ICRBB_E IIO_ICRB0_E * 2801 * IIO_ICRBC_B IIO_ICRB0_B *
2906 * IIO_ICRBC_A IIO_ICRB0_A * 2802 * IIO_ICRBC_C IIO_ICRB0_C *
2907 * IIO_ICRBC_B IIO_ICRB0_B * 2803 * IIO_ICRBC_D IIO_ICRB0_D *
2908 * IIO_ICRBC_C IIO_ICRB0_C * 2804 * IIO_ICRBC_E IIO_ICRB0_E *
2909 * IIO_ICRBC_D IIO_ICRB0_D * 2805 * IIO_ICRBD_A IIO_ICRB0_A *
2910 * IIO_ICRBC_E IIO_ICRB0_E * 2806 * IIO_ICRBD_B IIO_ICRB0_B *
2911 * IIO_ICRBD_A IIO_ICRB0_A * 2807 * IIO_ICRBD_C IIO_ICRB0_C *
2912 * IIO_ICRBD_B IIO_ICRB0_B * 2808 * IIO_ICRBD_D IIO_ICRB0_D *
2913 * IIO_ICRBD_C IIO_ICRB0_C * 2809 * IIO_ICRBD_E IIO_ICRB0_E *
2914 * IIO_ICRBD_D IIO_ICRB0_D * 2810 * IIO_ICRBE_A IIO_ICRB0_A *
2915 * IIO_ICRBD_E IIO_ICRB0_E * 2811 * IIO_ICRBE_B IIO_ICRB0_B *
2916 * IIO_ICRBE_A IIO_ICRB0_A * 2812 * IIO_ICRBE_C IIO_ICRB0_C *
2917 * IIO_ICRBE_B IIO_ICRB0_B * 2813 * IIO_ICRBE_D IIO_ICRB0_D *
2918 * IIO_ICRBE_C IIO_ICRB0_C * 2814 * IIO_ICRBE_E IIO_ICRB0_E *
2919 * IIO_ICRBE_D IIO_ICRB0_D * 2815 * *
2920 * IIO_ICRBE_E IIO_ICRB0_E * 2816 ************************************************************************/
2921 * *
2922 **************************************************************************/
2923
2924 2817
2925/* 2818/*
2926 * Slightly friendlier names for some common registers. 2819 * Slightly friendlier names for some common registers.
2927 */ 2820 */
2928#define IIO_WIDGET IIO_WID /* Widget identification */ 2821#define IIO_WIDGET IIO_WID /* Widget identification */
2929#define IIO_WIDGET_STAT IIO_WSTAT /* Widget status register */ 2822#define IIO_WIDGET_STAT IIO_WSTAT /* Widget status register */
2930#define IIO_WIDGET_CTRL IIO_WCR /* Widget control register */ 2823#define IIO_WIDGET_CTRL IIO_WCR /* Widget control register */
2931#define IIO_PROTECT IIO_ILAPR /* IO interface protection */ 2824#define IIO_PROTECT IIO_ILAPR /* IO interface protection */
2932#define IIO_PROTECT_OVRRD IIO_ILAPO /* IO protect override */ 2825#define IIO_PROTECT_OVRRD IIO_ILAPO /* IO protect override */
2933#define IIO_OUTWIDGET_ACCESS IIO_IOWA /* Outbound widget access */ 2826#define IIO_OUTWIDGET_ACCESS IIO_IOWA /* Outbound widget access */
2934#define IIO_INWIDGET_ACCESS IIO_IIWA /* Inbound widget access */ 2827#define IIO_INWIDGET_ACCESS IIO_IIWA /* Inbound widget access */
2935#define IIO_INDEV_ERR_MASK IIO_IIDEM /* Inbound device error mask */ 2828#define IIO_INDEV_ERR_MASK IIO_IIDEM /* Inbound device error mask */
2936#define IIO_LLP_CSR IIO_ILCSR /* LLP control and status */ 2829#define IIO_LLP_CSR IIO_ILCSR /* LLP control and status */
2937#define IIO_LLP_LOG IIO_ILLR /* LLP log */ 2830#define IIO_LLP_LOG IIO_ILLR /* LLP log */
2938#define IIO_XTALKCC_TOUT IIO_IXCC /* Xtalk credit count timeout*/ 2831#define IIO_XTALKCC_TOUT IIO_IXCC /* Xtalk credit count timeout */
2939#define IIO_XTALKTT_TOUT IIO_IXTT /* Xtalk tail timeout */ 2832#define IIO_XTALKTT_TOUT IIO_IXTT /* Xtalk tail timeout */
2940#define IIO_IO_ERR_CLR IIO_IECLR /* IO error clear */ 2833#define IIO_IO_ERR_CLR IIO_IECLR /* IO error clear */
2941#define IIO_IGFX_0 IIO_IGFX0 2834#define IIO_IGFX_0 IIO_IGFX0
2942#define IIO_IGFX_1 IIO_IGFX1 2835#define IIO_IGFX_1 IIO_IGFX1
2943#define IIO_IBCT_0 IIO_IBCT0 2836#define IIO_IBCT_0 IIO_IBCT0
@@ -2957,12 +2850,12 @@ typedef union ii_ippr_u {
2957#define IIO_PRTE_A(_x) (IIO_IPRTE0_A + (8 * (_x))) 2850#define IIO_PRTE_A(_x) (IIO_IPRTE0_A + (8 * (_x)))
2958#define IIO_PRTE_B(_x) (IIO_IPRTE0_B + (8 * (_x))) 2851#define IIO_PRTE_B(_x) (IIO_IPRTE0_B + (8 * (_x)))
2959#define IIO_NUM_PRTES 8 /* Total number of PRB table entries */ 2852#define IIO_NUM_PRTES 8 /* Total number of PRB table entries */
2960#define IIO_WIDPRTE_A(x) IIO_PRTE_A(((x) - 8)) /* widget ID to its PRTE num */ 2853#define IIO_WIDPRTE_A(x) IIO_PRTE_A(((x) - 8)) /* widget ID to its PRTE num */
2961#define IIO_WIDPRTE_B(x) IIO_PRTE_B(((x) - 8)) /* widget ID to its PRTE num */ 2854#define IIO_WIDPRTE_B(x) IIO_PRTE_B(((x) - 8)) /* widget ID to its PRTE num */
2962 2855
2963#define IIO_NUM_IPRBS (9) 2856#define IIO_NUM_IPRBS 9
2964 2857
2965#define IIO_LLP_CSR_IS_UP 0x00002000 2858#define IIO_LLP_CSR_IS_UP 0x00002000
2966#define IIO_LLP_CSR_LLP_STAT_MASK 0x00003000 2859#define IIO_LLP_CSR_LLP_STAT_MASK 0x00003000
2967#define IIO_LLP_CSR_LLP_STAT_SHFT 12 2860#define IIO_LLP_CSR_LLP_STAT_SHFT 12
2968 2861
@@ -2970,30 +2863,29 @@ typedef union ii_ippr_u {
2970#define IIO_LLP_SN_MAX 0xffff /* in ILLR SN_CNT, Max Sequence Number errors */ 2863#define IIO_LLP_SN_MAX 0xffff /* in ILLR SN_CNT, Max Sequence Number errors */
2971 2864
2972/* key to IIO_PROTECT_OVRRD */ 2865/* key to IIO_PROTECT_OVRRD */
2973#define IIO_PROTECT_OVRRD_KEY 0x53474972756c6573ull /* "SGIrules" */ 2866#define IIO_PROTECT_OVRRD_KEY 0x53474972756c6573ull /* "SGIrules" */
2974 2867
2975/* BTE register names */ 2868/* BTE register names */
2976#define IIO_BTE_STAT_0 IIO_IBLS_0 /* Also BTE length/status 0 */ 2869#define IIO_BTE_STAT_0 IIO_IBLS_0 /* Also BTE length/status 0 */
2977#define IIO_BTE_SRC_0 IIO_IBSA_0 /* Also BTE source address 0 */ 2870#define IIO_BTE_SRC_0 IIO_IBSA_0 /* Also BTE source address 0 */
2978#define IIO_BTE_DEST_0 IIO_IBDA_0 /* Also BTE dest. address 0 */ 2871#define IIO_BTE_DEST_0 IIO_IBDA_0 /* Also BTE dest. address 0 */
2979#define IIO_BTE_CTRL_0 IIO_IBCT_0 /* Also BTE control/terminate 0 */ 2872#define IIO_BTE_CTRL_0 IIO_IBCT_0 /* Also BTE control/terminate 0 */
2980#define IIO_BTE_NOTIFY_0 IIO_IBNA_0 /* Also BTE notification 0 */ 2873#define IIO_BTE_NOTIFY_0 IIO_IBNA_0 /* Also BTE notification 0 */
2981#define IIO_BTE_INT_0 IIO_IBIA_0 /* Also BTE interrupt 0 */ 2874#define IIO_BTE_INT_0 IIO_IBIA_0 /* Also BTE interrupt 0 */
2982#define IIO_BTE_OFF_0 0 /* Base offset from BTE 0 regs. */ 2875#define IIO_BTE_OFF_0 0 /* Base offset from BTE 0 regs. */
2983#define IIO_BTE_OFF_1 (IIO_IBLS_1 - IIO_IBLS_0) /* Offset from base to BTE 1 */ 2876#define IIO_BTE_OFF_1 (IIO_IBLS_1 - IIO_IBLS_0) /* Offset from base to BTE 1 */
2984 2877
2985/* BTE register offsets from base */ 2878/* BTE register offsets from base */
2986#define BTEOFF_STAT 0 2879#define BTEOFF_STAT 0
2987#define BTEOFF_SRC (IIO_BTE_SRC_0 - IIO_BTE_STAT_0) 2880#define BTEOFF_SRC (IIO_BTE_SRC_0 - IIO_BTE_STAT_0)
2988#define BTEOFF_DEST (IIO_BTE_DEST_0 - IIO_BTE_STAT_0) 2881#define BTEOFF_DEST (IIO_BTE_DEST_0 - IIO_BTE_STAT_0)
2989#define BTEOFF_CTRL (IIO_BTE_CTRL_0 - IIO_BTE_STAT_0) 2882#define BTEOFF_CTRL (IIO_BTE_CTRL_0 - IIO_BTE_STAT_0)
2990#define BTEOFF_NOTIFY (IIO_BTE_NOTIFY_0 - IIO_BTE_STAT_0) 2883#define BTEOFF_NOTIFY (IIO_BTE_NOTIFY_0 - IIO_BTE_STAT_0)
2991#define BTEOFF_INT (IIO_BTE_INT_0 - IIO_BTE_STAT_0) 2884#define BTEOFF_INT (IIO_BTE_INT_0 - IIO_BTE_STAT_0)
2992
2993 2885
2994/* names used in shub diags */ 2886/* names used in shub diags */
2995#define IIO_BASE_BTE0 IIO_IBLS_0 2887#define IIO_BASE_BTE0 IIO_IBLS_0
2996#define IIO_BASE_BTE1 IIO_IBLS_1 2888#define IIO_BASE_BTE1 IIO_IBLS_1
2997 2889
2998/* 2890/*
2999 * Macro which takes the widget number, and returns the 2891 * Macro which takes the widget number, and returns the
@@ -3001,10 +2893,9 @@ typedef union ii_ippr_u {
3001 * value _x is expected to be a widget number in the range 2893 * value _x is expected to be a widget number in the range
3002 * 0, 8 - 0xF 2894 * 0, 8 - 0xF
3003 */ 2895 */
3004#define IIO_IOPRB(_x) (IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \ 2896#define IIO_IOPRB(_x) (IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \
3005 (_x) : \ 2897 (_x) : \
3006 (_x) - (HUB_WIDGET_ID_MIN-1)) << 3) ) 2898 (_x) - (HUB_WIDGET_ID_MIN-1)) << 3) )
3007
3008 2899
3009/* GFX Flow Control Node/Widget Register */ 2900/* GFX Flow Control Node/Widget Register */
3010#define IIO_IGFX_W_NUM_BITS 4 /* size of widget num field */ 2901#define IIO_IGFX_W_NUM_BITS 4 /* size of widget num field */
@@ -3025,7 +2916,6 @@ typedef union ii_ippr_u {
3025 (((node) & IIO_IGFX_N_NUM_MASK) << IIO_IGFX_N_NUM_SHIFT) | \ 2916 (((node) & IIO_IGFX_N_NUM_MASK) << IIO_IGFX_N_NUM_SHIFT) | \
3026 (((cpu) & IIO_IGFX_P_NUM_MASK) << IIO_IGFX_P_NUM_SHIFT)) 2917 (((cpu) & IIO_IGFX_P_NUM_MASK) << IIO_IGFX_P_NUM_SHIFT))
3027 2918
3028
3029/* Scratch registers (all bits available) */ 2919/* Scratch registers (all bits available) */
3030#define IIO_SCRATCH_REG0 IIO_ISCR0 2920#define IIO_SCRATCH_REG0 IIO_ISCR0
3031#define IIO_SCRATCH_REG1 IIO_ISCR1 2921#define IIO_SCRATCH_REG1 IIO_ISCR1
@@ -3046,21 +2936,21 @@ typedef union ii_ippr_u {
3046#define IIO_SCRATCH_BIT1_0 0x0000000000000001UL 2936#define IIO_SCRATCH_BIT1_0 0x0000000000000001UL
3047#define IIO_SCRATCH_BIT1_1 0x0000000000000002UL 2937#define IIO_SCRATCH_BIT1_1 0x0000000000000002UL
3048/* IO Translation Table Entries */ 2938/* IO Translation Table Entries */
3049#define IIO_NUM_ITTES 7 /* ITTEs numbered 0..6 */ 2939#define IIO_NUM_ITTES 7 /* ITTEs numbered 0..6 */
3050 /* Hw manuals number them 1..7! */ 2940 /* Hw manuals number them 1..7! */
3051/* 2941/*
3052 * IIO_IMEM Register fields. 2942 * IIO_IMEM Register fields.
3053 */ 2943 */
3054#define IIO_IMEM_W0ESD 0x1UL /* Widget 0 shut down due to error */ 2944#define IIO_IMEM_W0ESD 0x1UL /* Widget 0 shut down due to error */
3055#define IIO_IMEM_B0ESD (1UL << 4) /* BTE 0 shut down due to error */ 2945#define IIO_IMEM_B0ESD (1UL << 4) /* BTE 0 shut down due to error */
3056#define IIO_IMEM_B1ESD (1UL << 8) /* BTE 1 Shut down due to error */ 2946#define IIO_IMEM_B1ESD (1UL << 8) /* BTE 1 Shut down due to error */
3057 2947
3058/* 2948/*
3059 * As a permanent workaround for a bug in the PI side of the shub, we've 2949 * As a permanent workaround for a bug in the PI side of the shub, we've
3060 * redefined big window 7 as small window 0. 2950 * redefined big window 7 as small window 0.
3061 XXX does this still apply for SN1?? 2951 XXX does this still apply for SN1??
3062 */ 2952 */
3063#define HUB_NUM_BIG_WINDOW (IIO_NUM_ITTES - 1) 2953#define HUB_NUM_BIG_WINDOW (IIO_NUM_ITTES - 1)
3064 2954
3065/* 2955/*
3066 * Use the top big window as a surrogate for the first small window 2956 * Use the top big window as a surrogate for the first small window
@@ -3071,11 +2961,11 @@ typedef union ii_ippr_u {
3071 2961
3072/* 2962/*
3073 * CRB manipulation macros 2963 * CRB manipulation macros
3074 * The CRB macros are slightly complicated, since there are up to 2964 * The CRB macros are slightly complicated, since there are up to
3075 * four registers associated with each CRB entry. 2965 * four registers associated with each CRB entry.
3076 */ 2966 */
3077#define IIO_NUM_CRBS 15 /* Number of CRBs */ 2967#define IIO_NUM_CRBS 15 /* Number of CRBs */
3078#define IIO_NUM_PC_CRBS 4 /* Number of partial cache CRBs */ 2968#define IIO_NUM_PC_CRBS 4 /* Number of partial cache CRBs */
3079#define IIO_ICRB_OFFSET 8 2969#define IIO_ICRB_OFFSET 8
3080#define IIO_ICRB_0 IIO_ICRB0_A 2970#define IIO_ICRB_0 IIO_ICRB0_A
3081#define IIO_ICRB_ADDR_SHFT 2 /* Shift to get proper address */ 2971#define IIO_ICRB_ADDR_SHFT 2 /* Shift to get proper address */
@@ -3083,43 +2973,43 @@ typedef union ii_ippr_u {
3083 #define IIO_FIRST_PC_ENTRY 12 2973 #define IIO_FIRST_PC_ENTRY 12
3084 */ 2974 */
3085 2975
3086#define IIO_ICRB_A(_x) ((u64)(IIO_ICRB_0 + (6 * IIO_ICRB_OFFSET * (_x)))) 2976#define IIO_ICRB_A(_x) ((u64)(IIO_ICRB_0 + (6 * IIO_ICRB_OFFSET * (_x))))
3087#define IIO_ICRB_B(_x) ((u64)((char *)IIO_ICRB_A(_x) + 1*IIO_ICRB_OFFSET)) 2977#define IIO_ICRB_B(_x) ((u64)((char *)IIO_ICRB_A(_x) + 1*IIO_ICRB_OFFSET))
3088#define IIO_ICRB_C(_x) ((u64)((char *)IIO_ICRB_A(_x) + 2*IIO_ICRB_OFFSET)) 2978#define IIO_ICRB_C(_x) ((u64)((char *)IIO_ICRB_A(_x) + 2*IIO_ICRB_OFFSET))
3089#define IIO_ICRB_D(_x) ((u64)((char *)IIO_ICRB_A(_x) + 3*IIO_ICRB_OFFSET)) 2979#define IIO_ICRB_D(_x) ((u64)((char *)IIO_ICRB_A(_x) + 3*IIO_ICRB_OFFSET))
3090#define IIO_ICRB_E(_x) ((u64)((char *)IIO_ICRB_A(_x) + 4*IIO_ICRB_OFFSET)) 2980#define IIO_ICRB_E(_x) ((u64)((char *)IIO_ICRB_A(_x) + 4*IIO_ICRB_OFFSET))
3091 2981
3092#define TNUM_TO_WIDGET_DEV(_tnum) (_tnum & 0x7) 2982#define TNUM_TO_WIDGET_DEV(_tnum) (_tnum & 0x7)
3093 2983
3094/* 2984/*
3095 * values for "ecode" field 2985 * values for "ecode" field
3096 */ 2986 */
3097#define IIO_ICRB_ECODE_DERR 0 /* Directory error due to IIO access */ 2987#define IIO_ICRB_ECODE_DERR 0 /* Directory error due to IIO access */
3098#define IIO_ICRB_ECODE_PERR 1 /* Poison error on IO access */ 2988#define IIO_ICRB_ECODE_PERR 1 /* Poison error on IO access */
3099#define IIO_ICRB_ECODE_WERR 2 /* Write error by IIO access 2989#define IIO_ICRB_ECODE_WERR 2 /* Write error by IIO access
3100 * e.g. WINV to a Read only line. */ 2990 * e.g. WINV to a Read only line. */
3101#define IIO_ICRB_ECODE_AERR 3 /* Access error caused by IIO access */ 2991#define IIO_ICRB_ECODE_AERR 3 /* Access error caused by IIO access */
3102#define IIO_ICRB_ECODE_PWERR 4 /* Error on partial write */ 2992#define IIO_ICRB_ECODE_PWERR 4 /* Error on partial write */
3103#define IIO_ICRB_ECODE_PRERR 5 /* Error on partial read */ 2993#define IIO_ICRB_ECODE_PRERR 5 /* Error on partial read */
3104#define IIO_ICRB_ECODE_TOUT 6 /* CRB timeout before deallocating */ 2994#define IIO_ICRB_ECODE_TOUT 6 /* CRB timeout before deallocating */
3105#define IIO_ICRB_ECODE_XTERR 7 /* Incoming xtalk pkt had error bit */ 2995#define IIO_ICRB_ECODE_XTERR 7 /* Incoming xtalk pkt had error bit */
3106 2996
3107/* 2997/*
3108 * Values for field imsgtype 2998 * Values for field imsgtype
3109 */ 2999 */
3110#define IIO_ICRB_IMSGT_XTALK 0 /* Incoming Meessage from Xtalk */ 3000#define IIO_ICRB_IMSGT_XTALK 0 /* Incoming Meessage from Xtalk */
3111#define IIO_ICRB_IMSGT_BTE 1 /* Incoming message from BTE */ 3001#define IIO_ICRB_IMSGT_BTE 1 /* Incoming message from BTE */
3112#define IIO_ICRB_IMSGT_SN1NET 2 /* Incoming message from SN1 net */ 3002#define IIO_ICRB_IMSGT_SN1NET 2 /* Incoming message from SN1 net */
3113#define IIO_ICRB_IMSGT_CRB 3 /* Incoming message from CRB ??? */ 3003#define IIO_ICRB_IMSGT_CRB 3 /* Incoming message from CRB ??? */
3114 3004
3115/* 3005/*
3116 * values for field initiator. 3006 * values for field initiator.
3117 */ 3007 */
3118#define IIO_ICRB_INIT_XTALK 0 /* Message originated in xtalk */ 3008#define IIO_ICRB_INIT_XTALK 0 /* Message originated in xtalk */
3119#define IIO_ICRB_INIT_BTE0 0x1 /* Message originated in BTE 0 */ 3009#define IIO_ICRB_INIT_BTE0 0x1 /* Message originated in BTE 0 */
3120#define IIO_ICRB_INIT_SN1NET 0x2 /* Message originated in SN1net */ 3010#define IIO_ICRB_INIT_SN1NET 0x2 /* Message originated in SN1net */
3121#define IIO_ICRB_INIT_CRB 0x3 /* Message originated in CRB ? */ 3011#define IIO_ICRB_INIT_CRB 0x3 /* Message originated in CRB ? */
3122#define IIO_ICRB_INIT_BTE1 0x5 /* MEssage originated in BTE 1 */ 3012#define IIO_ICRB_INIT_BTE1 0x5 /* MEssage originated in BTE 1 */
3123 3013
3124/* 3014/*
3125 * Number of credits Hub widget has while sending req/response to 3015 * Number of credits Hub widget has while sending req/response to
@@ -3127,8 +3017,8 @@ typedef union ii_ippr_u {
3127 * Value of 3 is required by Xbow 1.1 3017 * Value of 3 is required by Xbow 1.1
3128 * We may be able to increase this to 4 with Xbow 1.2. 3018 * We may be able to increase this to 4 with Xbow 1.2.
3129 */ 3019 */
3130#define HUBII_XBOW_CREDIT 3 3020#define HUBII_XBOW_CREDIT 3
3131#define HUBII_XBOW_REV2_CREDIT 4 3021#define HUBII_XBOW_REV2_CREDIT 4
3132 3022
3133/* 3023/*
3134 * Number of credits that xtalk devices should use when communicating 3024 * Number of credits that xtalk devices should use when communicating
@@ -3159,28 +3049,28 @@ typedef union ii_ippr_u {
3159 */ 3049 */
3160 3050
3161#define IIO_ICMR_CRB_VLD_SHFT 20 3051#define IIO_ICMR_CRB_VLD_SHFT 20
3162#define IIO_ICMR_CRB_VLD_MASK (0x7fffUL << IIO_ICMR_CRB_VLD_SHFT) 3052#define IIO_ICMR_CRB_VLD_MASK (0x7fffUL << IIO_ICMR_CRB_VLD_SHFT)
3163 3053
3164#define IIO_ICMR_FC_CNT_SHFT 16 3054#define IIO_ICMR_FC_CNT_SHFT 16
3165#define IIO_ICMR_FC_CNT_MASK (0xf << IIO_ICMR_FC_CNT_SHFT) 3055#define IIO_ICMR_FC_CNT_MASK (0xf << IIO_ICMR_FC_CNT_SHFT)
3166 3056
3167#define IIO_ICMR_C_CNT_SHFT 4 3057#define IIO_ICMR_C_CNT_SHFT 4
3168#define IIO_ICMR_C_CNT_MASK (0xf << IIO_ICMR_C_CNT_SHFT) 3058#define IIO_ICMR_C_CNT_MASK (0xf << IIO_ICMR_C_CNT_SHFT)
3169 3059
3170#define IIO_ICMR_PRECISE (1UL << 52) 3060#define IIO_ICMR_PRECISE (1UL << 52)
3171#define IIO_ICMR_CLR_RPPD (1UL << 13) 3061#define IIO_ICMR_CLR_RPPD (1UL << 13)
3172#define IIO_ICMR_CLR_RQPD (1UL << 12) 3062#define IIO_ICMR_CLR_RQPD (1UL << 12)
3173 3063
3174/* 3064/*
3175 * IIO PIO Deallocation register field masks : (IIO_IPDR) 3065 * IIO PIO Deallocation register field masks : (IIO_IPDR)
3176 XXX present but not needed in bedrock? See the manual. 3066 XXX present but not needed in bedrock? See the manual.
3177 */ 3067 */
3178#define IIO_IPDR_PND (1 << 4) 3068#define IIO_IPDR_PND (1 << 4)
3179 3069
3180/* 3070/*
3181 * IIO CRB deallocation register field masks: (IIO_ICDR) 3071 * IIO CRB deallocation register field masks: (IIO_ICDR)
3182 */ 3072 */
3183#define IIO_ICDR_PND (1 << 4) 3073#define IIO_ICDR_PND (1 << 4)
3184 3074
3185/* 3075/*
3186 * IO BTE Length/Status (IIO_IBLS) register bit field definitions 3076 * IO BTE Length/Status (IIO_IBLS) register bit field definitions
@@ -3223,35 +3113,35 @@ typedef union ii_ippr_u {
3223/* 3113/*
3224 * IO Error Clear register bit field definitions 3114 * IO Error Clear register bit field definitions
3225 */ 3115 */
3226#define IECLR_PI1_FWD_INT (1UL << 31) /* clear PI1_FORWARD_INT in iidsr */ 3116#define IECLR_PI1_FWD_INT (1UL << 31) /* clear PI1_FORWARD_INT in iidsr */
3227#define IECLR_PI0_FWD_INT (1UL << 30) /* clear PI0_FORWARD_INT in iidsr */ 3117#define IECLR_PI0_FWD_INT (1UL << 30) /* clear PI0_FORWARD_INT in iidsr */
3228#define IECLR_SPUR_RD_HDR (1UL << 29) /* clear valid bit in ixss reg */ 3118#define IECLR_SPUR_RD_HDR (1UL << 29) /* clear valid bit in ixss reg */
3229#define IECLR_BTE1 (1UL << 18) /* clear bte error 1 */ 3119#define IECLR_BTE1 (1UL << 18) /* clear bte error 1 */
3230#define IECLR_BTE0 (1UL << 17) /* clear bte error 0 */ 3120#define IECLR_BTE0 (1UL << 17) /* clear bte error 0 */
3231#define IECLR_CRAZY (1UL << 16) /* clear crazy bit in wstat reg */ 3121#define IECLR_CRAZY (1UL << 16) /* clear crazy bit in wstat reg */
3232#define IECLR_PRB_F (1UL << 15) /* clear err bit in PRB_F reg */ 3122#define IECLR_PRB_F (1UL << 15) /* clear err bit in PRB_F reg */
3233#define IECLR_PRB_E (1UL << 14) /* clear err bit in PRB_E reg */ 3123#define IECLR_PRB_E (1UL << 14) /* clear err bit in PRB_E reg */
3234#define IECLR_PRB_D (1UL << 13) /* clear err bit in PRB_D reg */ 3124#define IECLR_PRB_D (1UL << 13) /* clear err bit in PRB_D reg */
3235#define IECLR_PRB_C (1UL << 12) /* clear err bit in PRB_C reg */ 3125#define IECLR_PRB_C (1UL << 12) /* clear err bit in PRB_C reg */
3236#define IECLR_PRB_B (1UL << 11) /* clear err bit in PRB_B reg */ 3126#define IECLR_PRB_B (1UL << 11) /* clear err bit in PRB_B reg */
3237#define IECLR_PRB_A (1UL << 10) /* clear err bit in PRB_A reg */ 3127#define IECLR_PRB_A (1UL << 10) /* clear err bit in PRB_A reg */
3238#define IECLR_PRB_9 (1UL << 9) /* clear err bit in PRB_9 reg */ 3128#define IECLR_PRB_9 (1UL << 9) /* clear err bit in PRB_9 reg */
3239#define IECLR_PRB_8 (1UL << 8) /* clear err bit in PRB_8 reg */ 3129#define IECLR_PRB_8 (1UL << 8) /* clear err bit in PRB_8 reg */
3240#define IECLR_PRB_0 (1UL << 0) /* clear err bit in PRB_0 reg */ 3130#define IECLR_PRB_0 (1UL << 0) /* clear err bit in PRB_0 reg */
3241 3131
3242/* 3132/*
3243 * IIO CRB control register Fields: IIO_ICCR 3133 * IIO CRB control register Fields: IIO_ICCR
3244 */ 3134 */
3245#define IIO_ICCR_PENDING (0x10000) 3135#define IIO_ICCR_PENDING 0x10000
3246#define IIO_ICCR_CMD_MASK (0xFF) 3136#define IIO_ICCR_CMD_MASK 0xFF
3247#define IIO_ICCR_CMD_SHFT (7) 3137#define IIO_ICCR_CMD_SHFT 7
3248#define IIO_ICCR_CMD_NOP (0x0) /* No Op */ 3138#define IIO_ICCR_CMD_NOP 0x0 /* No Op */
3249#define IIO_ICCR_CMD_WAKE (0x100) /* Reactivate CRB entry and process */ 3139#define IIO_ICCR_CMD_WAKE 0x100 /* Reactivate CRB entry and process */
3250#define IIO_ICCR_CMD_TIMEOUT (0x200) /* Make CRB timeout & mark invalid */ 3140#define IIO_ICCR_CMD_TIMEOUT 0x200 /* Make CRB timeout & mark invalid */
3251#define IIO_ICCR_CMD_EJECT (0x400) /* Contents of entry written to memory 3141#define IIO_ICCR_CMD_EJECT 0x400 /* Contents of entry written to memory
3252 * via a WB 3142 * via a WB
3253 */ 3143 */
3254#define IIO_ICCR_CMD_FLUSH (0x800) 3144#define IIO_ICCR_CMD_FLUSH 0x800
3255 3145
3256/* 3146/*
3257 * 3147 *
@@ -3283,8 +3173,8 @@ typedef union ii_ippr_u {
3283 * Easy access macros for CRBs, all 5 registers (A-E) 3173 * Easy access macros for CRBs, all 5 registers (A-E)
3284 */ 3174 */
3285typedef ii_icrb0_a_u_t icrba_t; 3175typedef ii_icrb0_a_u_t icrba_t;
3286#define a_sidn ii_icrb0_a_fld_s.ia_sidn 3176#define a_sidn ii_icrb0_a_fld_s.ia_sidn
3287#define a_tnum ii_icrb0_a_fld_s.ia_tnum 3177#define a_tnum ii_icrb0_a_fld_s.ia_tnum
3288#define a_addr ii_icrb0_a_fld_s.ia_addr 3178#define a_addr ii_icrb0_a_fld_s.ia_addr
3289#define a_valid ii_icrb0_a_fld_s.ia_vld 3179#define a_valid ii_icrb0_a_fld_s.ia_vld
3290#define a_iow ii_icrb0_a_fld_s.ia_iow 3180#define a_iow ii_icrb0_a_fld_s.ia_iow
@@ -3324,14 +3214,13 @@ typedef ii_icrb0_c_u_t icrbc_t;
3324#define c_source ii_icrb0_c_fld_s.ic_source 3214#define c_source ii_icrb0_c_fld_s.ic_source
3325#define c_regvalue ii_icrb0_c_regval 3215#define c_regvalue ii_icrb0_c_regval
3326 3216
3327
3328typedef ii_icrb0_d_u_t icrbd_t; 3217typedef ii_icrb0_d_u_t icrbd_t;
3329#define d_sleep ii_icrb0_d_fld_s.id_sleep 3218#define d_sleep ii_icrb0_d_fld_s.id_sleep
3330#define d_pricnt ii_icrb0_d_fld_s.id_pr_cnt 3219#define d_pricnt ii_icrb0_d_fld_s.id_pr_cnt
3331#define d_pripsc ii_icrb0_d_fld_s.id_pr_psc 3220#define d_pripsc ii_icrb0_d_fld_s.id_pr_psc
3332#define d_bteop ii_icrb0_d_fld_s.id_bte_op 3221#define d_bteop ii_icrb0_d_fld_s.id_bte_op
3333#define d_bteaddr ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names*/ 3222#define d_bteaddr ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names */
3334#define d_benable ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names*/ 3223#define d_benable ii_icrb0_d_fld_s.id_pa_be /* ic_pa_be fld has 2 names */
3335#define d_regvalue ii_icrb0_d_regval 3224#define d_regvalue ii_icrb0_d_regval
3336 3225
3337typedef ii_icrb0_e_u_t icrbe_t; 3226typedef ii_icrb0_e_u_t icrbe_t;
@@ -3341,7 +3230,6 @@ typedef ii_icrb0_e_u_t icrbe_t;
3341#define icrbe_timeout ii_icrb0_e_fld_s.ie_timeout 3230#define icrbe_timeout ii_icrb0_e_fld_s.ie_timeout
3342#define e_regvalue ii_icrb0_e_regval 3231#define e_regvalue ii_icrb0_e_regval
3343 3232
3344
3345/* Number of widgets supported by shub */ 3233/* Number of widgets supported by shub */
3346#define HUB_NUM_WIDGET 9 3234#define HUB_NUM_WIDGET 9
3347#define HUB_WIDGET_ID_MIN 0x8 3235#define HUB_WIDGET_ID_MIN 0x8
@@ -3367,27 +3255,27 @@ typedef ii_icrb0_e_u_t icrbe_t;
3367 3255
3368#define LNK_STAT_WORKING 0x2 /* LLP is working */ 3256#define LNK_STAT_WORKING 0x2 /* LLP is working */
3369 3257
3370#define IIO_WSTAT_ECRAZY (1ULL << 32) /* Hub gone crazy */ 3258#define IIO_WSTAT_ECRAZY (1ULL << 32) /* Hub gone crazy */
3371#define IIO_WSTAT_TXRETRY (1ULL << 9) /* Hub Tx Retry timeout */ 3259#define IIO_WSTAT_TXRETRY (1ULL << 9) /* Hub Tx Retry timeout */
3372#define IIO_WSTAT_TXRETRY_MASK (0x7F) /* should be 0xFF?? */ 3260#define IIO_WSTAT_TXRETRY_MASK 0x7F /* should be 0xFF?? */
3373#define IIO_WSTAT_TXRETRY_SHFT (16) 3261#define IIO_WSTAT_TXRETRY_SHFT 16
3374#define IIO_WSTAT_TXRETRY_CNT(w) (((w) >> IIO_WSTAT_TXRETRY_SHFT) & \ 3262#define IIO_WSTAT_TXRETRY_CNT(w) (((w) >> IIO_WSTAT_TXRETRY_SHFT) & \
3375 IIO_WSTAT_TXRETRY_MASK) 3263 IIO_WSTAT_TXRETRY_MASK)
3376 3264
3377/* Number of II perf. counters we can multiplex at once */ 3265/* Number of II perf. counters we can multiplex at once */
3378 3266
3379#define IO_PERF_SETS 32 3267#define IO_PERF_SETS 32
3380 3268
3381/* Bit for the widget in inbound access register */ 3269/* Bit for the widget in inbound access register */
3382#define IIO_IIWA_WIDGET(_w) ((uint64_t)(1ULL << _w)) 3270#define IIO_IIWA_WIDGET(_w) ((uint64_t)(1ULL << _w))
3383/* Bit for the widget in outbound access register */ 3271/* Bit for the widget in outbound access register */
3384#define IIO_IOWA_WIDGET(_w) ((uint64_t)(1ULL << _w)) 3272#define IIO_IOWA_WIDGET(_w) ((uint64_t)(1ULL << _w))
3385 3273
3386/* NOTE: The following define assumes that we are going to get 3274/* NOTE: The following define assumes that we are going to get
3387 * widget numbers from 8 thru F and the device numbers within 3275 * widget numbers from 8 thru F and the device numbers within
3388 * widget from 0 thru 7. 3276 * widget from 0 thru 7.
3389 */ 3277 */
3390#define IIO_IIDEM_WIDGETDEV_MASK(w, d) ((uint64_t)(1ULL << (8 * ((w) - 8) + (d)))) 3278#define IIO_IIDEM_WIDGETDEV_MASK(w, d) ((uint64_t)(1ULL << (8 * ((w) - 8) + (d))))
3391 3279
3392/* IO Interrupt Destination Register */ 3280/* IO Interrupt Destination Register */
3393#define IIO_IIDSR_SENT_SHIFT 28 3281#define IIO_IIDSR_SENT_SHIFT 28
@@ -3402,11 +3290,11 @@ typedef ii_icrb0_e_u_t icrbe_t;
3402#define IIO_IIDSR_LVL_MASK 0x000000ff 3290#define IIO_IIDSR_LVL_MASK 0x000000ff
3403 3291
3404/* Xtalk timeout threshhold register (IIO_IXTT) */ 3292/* Xtalk timeout threshhold register (IIO_IXTT) */
3405#define IXTT_RRSP_TO_SHFT 55 /* read response timeout */ 3293#define IXTT_RRSP_TO_SHFT 55 /* read response timeout */
3406#define IXTT_RRSP_TO_MASK (0x1FULL << IXTT_RRSP_TO_SHFT) 3294#define IXTT_RRSP_TO_MASK (0x1FULL << IXTT_RRSP_TO_SHFT)
3407#define IXTT_RRSP_PS_SHFT 32 /* read responsed TO prescalar */ 3295#define IXTT_RRSP_PS_SHFT 32 /* read responsed TO prescalar */
3408#define IXTT_RRSP_PS_MASK (0x7FFFFFULL << IXTT_RRSP_PS_SHFT) 3296#define IXTT_RRSP_PS_MASK (0x7FFFFFULL << IXTT_RRSP_PS_SHFT)
3409#define IXTT_TAIL_TO_SHFT 0 /* tail timeout counter threshold */ 3297#define IXTT_TAIL_TO_SHFT 0 /* tail timeout counter threshold */
3410#define IXTT_TAIL_TO_MASK (0x3FFFFFFULL << IXTT_TAIL_TO_SHFT) 3298#define IXTT_TAIL_TO_MASK (0x3FFFFFFULL << IXTT_TAIL_TO_SHFT)
3411 3299
3412/* 3300/*
@@ -3414,17 +3302,17 @@ typedef ii_icrb0_e_u_t icrbe_t;
3414 */ 3302 */
3415 3303
3416typedef union hubii_wcr_u { 3304typedef union hubii_wcr_u {
3417 uint64_t wcr_reg_value; 3305 uint64_t wcr_reg_value;
3418 struct { 3306 struct {
3419 uint64_t wcr_widget_id: 4, /* LLP crossbar credit */ 3307 uint64_t wcr_widget_id:4, /* LLP crossbar credit */
3420 wcr_tag_mode: 1, /* Tag mode */ 3308 wcr_tag_mode:1, /* Tag mode */
3421 wcr_rsvd1: 8, /* Reserved */ 3309 wcr_rsvd1:8, /* Reserved */
3422 wcr_xbar_crd: 3, /* LLP crossbar credit */ 3310 wcr_xbar_crd:3, /* LLP crossbar credit */
3423 wcr_f_bad_pkt: 1, /* Force bad llp pkt enable */ 3311 wcr_f_bad_pkt:1, /* Force bad llp pkt enable */
3424 wcr_dir_con: 1, /* widget direct connect */ 3312 wcr_dir_con:1, /* widget direct connect */
3425 wcr_e_thresh: 5, /* elasticity threshold */ 3313 wcr_e_thresh:5, /* elasticity threshold */
3426 wcr_rsvd: 41; /* unused */ 3314 wcr_rsvd:41; /* unused */
3427 } wcr_fields_s; 3315 } wcr_fields_s;
3428} hubii_wcr_t; 3316} hubii_wcr_t;
3429 3317
3430#define iwcr_dir_con wcr_fields_s.wcr_dir_con 3318#define iwcr_dir_con wcr_fields_s.wcr_dir_con
@@ -3436,41 +3324,35 @@ performance registers */
3436 performed */ 3324 performed */
3437 3325
3438typedef union io_perf_sel { 3326typedef union io_perf_sel {
3439 uint64_t perf_sel_reg; 3327 uint64_t perf_sel_reg;
3440 struct { 3328 struct {
3441 uint64_t perf_ippr0 : 4, 3329 uint64_t perf_ippr0:4, perf_ippr1:4, perf_icct:8, perf_rsvd:48;
3442 perf_ippr1 : 4, 3330 } perf_sel_bits;
3443 perf_icct : 8,
3444 perf_rsvd : 48;
3445 } perf_sel_bits;
3446} io_perf_sel_t; 3331} io_perf_sel_t;
3447 3332
3448/* io_perf_cnt is to extract the count from the shub registers. Due to 3333/* io_perf_cnt is to extract the count from the shub registers. Due to
3449 hardware problems there is only one counter, not two. */ 3334 hardware problems there is only one counter, not two. */
3450 3335
3451typedef union io_perf_cnt { 3336typedef union io_perf_cnt {
3452 uint64_t perf_cnt; 3337 uint64_t perf_cnt;
3453 struct { 3338 struct {
3454 uint64_t perf_cnt : 20, 3339 uint64_t perf_cnt:20, perf_rsvd2:12, perf_rsvd1:32;
3455 perf_rsvd2 : 12, 3340 } perf_cnt_bits;
3456 perf_rsvd1 : 32;
3457 } perf_cnt_bits;
3458 3341
3459} io_perf_cnt_t; 3342} io_perf_cnt_t;
3460 3343
3461typedef union iprte_a { 3344typedef union iprte_a {
3462 uint64_t entry; 3345 uint64_t entry;
3463 struct { 3346 struct {
3464 uint64_t i_rsvd_1 : 3; 3347 uint64_t i_rsvd_1:3;
3465 uint64_t i_addr : 38; 3348 uint64_t i_addr:38;
3466 uint64_t i_init : 3; 3349 uint64_t i_init:3;
3467 uint64_t i_source : 8; 3350 uint64_t i_source:8;
3468 uint64_t i_rsvd : 2; 3351 uint64_t i_rsvd:2;
3469 uint64_t i_widget : 4; 3352 uint64_t i_widget:4;
3470 uint64_t i_to_cnt : 5; 3353 uint64_t i_to_cnt:5;
3471 uint64_t i_vld : 1; 3354 uint64_t i_vld:1;
3472 } iprte_fields; 3355 } iprte_fields;
3473} iprte_a_t; 3356} iprte_a_t;
3474 3357
3475#endif /* _ASM_IA64_SN_SHUBIO_H */ 3358#endif /* _ASM_IA64_SN_SHUBIO_H */
3476
diff --git a/include/asm-ia64/sn/sn_cpuid.h b/include/asm-ia64/sn/sn_cpuid.h
index 685435af170d..20b300187669 100644
--- a/include/asm-ia64/sn/sn_cpuid.h
+++ b/include/asm-ia64/sn/sn_cpuid.h
@@ -4,7 +4,7 @@
4 * License. See the file "COPYING" in the main directory of this archive 4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details. 5 * for more details.
6 * 6 *
7 * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved. 7 * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
8 */ 8 */
9 9
10 10
@@ -92,24 +92,24 @@
92 * NOTE: on non-MP systems, only cpuid 0 exists 92 * NOTE: on non-MP systems, only cpuid 0 exists
93 */ 93 */
94 94
95extern short physical_node_map[]; /* indexed by nasid to get cnode */ 95extern short physical_node_map[]; /* indexed by nasid to get cnode */
96 96
97/* 97/*
98 * Macros for retrieving info about current cpu 98 * Macros for retrieving info about current cpu
99 */ 99 */
100#define get_nasid() (nodepda->phys_cpuid[smp_processor_id()].nasid) 100#define get_nasid() (sn_nodepda->phys_cpuid[smp_processor_id()].nasid)
101#define get_subnode() (nodepda->phys_cpuid[smp_processor_id()].subnode) 101#define get_subnode() (sn_nodepda->phys_cpuid[smp_processor_id()].subnode)
102#define get_slice() (nodepda->phys_cpuid[smp_processor_id()].slice) 102#define get_slice() (sn_nodepda->phys_cpuid[smp_processor_id()].slice)
103#define get_cnode() (nodepda->phys_cpuid[smp_processor_id()].cnode) 103#define get_cnode() (sn_nodepda->phys_cpuid[smp_processor_id()].cnode)
104#define get_sapicid() ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff) 104#define get_sapicid() ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
105 105
106/* 106/*
107 * Macros for retrieving info about an arbitrary cpu 107 * Macros for retrieving info about an arbitrary cpu
108 * cpuid - logical cpu id 108 * cpuid - logical cpu id
109 */ 109 */
110#define cpuid_to_nasid(cpuid) (nodepda->phys_cpuid[cpuid].nasid) 110#define cpuid_to_nasid(cpuid) (sn_nodepda->phys_cpuid[cpuid].nasid)
111#define cpuid_to_subnode(cpuid) (nodepda->phys_cpuid[cpuid].subnode) 111#define cpuid_to_subnode(cpuid) (sn_nodepda->phys_cpuid[cpuid].subnode)
112#define cpuid_to_slice(cpuid) (nodepda->phys_cpuid[cpuid].slice) 112#define cpuid_to_slice(cpuid) (sn_nodepda->phys_cpuid[cpuid].slice)
113#define cpuid_to_cnodeid(cpuid) (physical_node_map[cpuid_to_nasid(cpuid)]) 113#define cpuid_to_cnodeid(cpuid) (physical_node_map[cpuid_to_nasid(cpuid)])
114 114
115 115
@@ -123,11 +123,8 @@ extern int nasid_slice_to_cpuid(int, int);
123 123
124/* 124/*
125 * cnodeid_to_nasid - convert a cnodeid to a NASID 125 * cnodeid_to_nasid - convert a cnodeid to a NASID
126 * Macro relies on pg_data for a node being on the node itself.
127 * Just extract the NASID from the pointer.
128 *
129 */ 126 */
130#define cnodeid_to_nasid(cnodeid) pda->cnodeid_to_nasid_table[cnodeid] 127#define cnodeid_to_nasid(cnodeid) (sn_cnodeid_to_nasid[cnodeid])
131 128
132/* 129/*
133 * nasid_to_cnodeid - convert a NASID to a cnodeid 130 * nasid_to_cnodeid - convert a NASID to a cnodeid
diff --git a/include/asm-ia64/sn/sn_fru.h b/include/asm-ia64/sn/sn_fru.h
deleted file mode 100644
index 8c21ac3f0156..000000000000
--- a/include/asm-ia64/sn/sn_fru.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1992-1997,1999-2004 Silicon Graphics, Inc. All rights reserved.
7 */
8#ifndef _ASM_IA64_SN_SN_FRU_H
9#define _ASM_IA64_SN_SN_FRU_H
10
11#define MAX_DIMMS 8 /* max # of dimm banks */
12#define MAX_PCIDEV 8 /* max # of pci devices on a pci bus */
13
14typedef unsigned char confidence_t;
15
16typedef struct kf_mem_s {
17 confidence_t km_confidence; /* confidence level that the memory is bad
18 * is this necessary ?
19 */
20 confidence_t km_dimm[MAX_DIMMS];
21 /* confidence level that dimm[i] is bad
22 *I think this is the right number
23 */
24
25} kf_mem_t;
26
27typedef struct kf_cpu_s {
28 confidence_t kc_confidence; /* confidence level that cpu is bad */
29 confidence_t kc_icache; /* confidence level that instr. cache is bad */
30 confidence_t kc_dcache; /* confidence level that data cache is bad */
31 confidence_t kc_scache; /* confidence level that sec. cache is bad */
32 confidence_t kc_sysbus; /* confidence level that sysad/cmd/state bus is bad */
33} kf_cpu_t;
34
35
36typedef struct kf_pci_bus_s {
37 confidence_t kpb_belief; /* confidence level that the pci bus is bad */
38 confidence_t kpb_pcidev_belief[MAX_PCIDEV];
39 /* confidence level that the pci dev is bad */
40} kf_pci_bus_t;
41
42
43#endif /* _ASM_IA64_SN_SN_FRU_H */
44
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
index 88c31b53dc09..56d74ca76b5d 100644
--- a/include/asm-ia64/sn/sn_sal.h
+++ b/include/asm-ia64/sn/sn_sal.h
@@ -8,7 +8,7 @@
8 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details. 9 * for more details.
10 * 10 *
11 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All rights reserved. 11 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All rights reserved.
12 */ 12 */
13 13
14 14
@@ -35,8 +35,8 @@
35#define SN_SAL_PRINT_ERROR 0x02000012 35#define SN_SAL_PRINT_ERROR 0x02000012
36#define SN_SAL_SET_ERROR_HANDLING_FEATURES 0x0200001a // reentrant 36#define SN_SAL_SET_ERROR_HANDLING_FEATURES 0x0200001a // reentrant
37#define SN_SAL_GET_FIT_COMPT 0x0200001b // reentrant 37#define SN_SAL_GET_FIT_COMPT 0x0200001b // reentrant
38#define SN_SAL_GET_SN_INFO 0x0200001c
39#define SN_SAL_GET_SAPIC_INFO 0x0200001d 38#define SN_SAL_GET_SAPIC_INFO 0x0200001d
39#define SN_SAL_GET_SN_INFO 0x0200001e
40#define SN_SAL_CONSOLE_PUTC 0x02000021 40#define SN_SAL_CONSOLE_PUTC 0x02000021
41#define SN_SAL_CONSOLE_GETC 0x02000022 41#define SN_SAL_CONSOLE_GETC 0x02000022
42#define SN_SAL_CONSOLE_PUTS 0x02000023 42#define SN_SAL_CONSOLE_PUTS 0x02000023
@@ -64,6 +64,7 @@
64 64
65#define SN_SAL_SYSCTL_IOBRICK_PCI_OP 0x02000042 // reentrant 65#define SN_SAL_SYSCTL_IOBRICK_PCI_OP 0x02000042 // reentrant
66#define SN_SAL_IROUTER_OP 0x02000043 66#define SN_SAL_IROUTER_OP 0x02000043
67#define SN_SAL_SYSCTL_EVENT 0x02000044
67#define SN_SAL_IOIF_INTERRUPT 0x0200004a 68#define SN_SAL_IOIF_INTERRUPT 0x0200004a
68#define SN_SAL_HWPERF_OP 0x02000050 // lock 69#define SN_SAL_HWPERF_OP 0x02000050 // lock
69#define SN_SAL_IOIF_ERROR_INTERRUPT 0x02000051 70#define SN_SAL_IOIF_ERROR_INTERRUPT 0x02000051
@@ -76,7 +77,8 @@
76#define SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST 0x02000058 77#define SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST 0x02000058
77 78
78#define SN_SAL_HUB_ERROR_INTERRUPT 0x02000060 79#define SN_SAL_HUB_ERROR_INTERRUPT 0x02000060
79 80#define SN_SAL_BTE_RECOVER 0x02000061
81#define SN_SAL_IOIF_GET_PCI_TOPOLOGY 0x02000062
80 82
81/* 83/*
82 * Service-specific constants 84 * Service-specific constants
@@ -555,7 +557,8 @@ static inline u64
555ia64_sn_partition_serial_get(void) 557ia64_sn_partition_serial_get(void)
556{ 558{
557 struct ia64_sal_retval ret_stuff; 559 struct ia64_sal_retval ret_stuff;
558 SAL_CALL(ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0, 0, 0, 0, 0, 0, 0); 560 ia64_sal_oemcall_reentrant(&ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0,
561 0, 0, 0, 0, 0, 0);
559 if (ret_stuff.status != 0) 562 if (ret_stuff.status != 0)
560 return 0; 563 return 0;
561 return ret_stuff.v0; 564 return ret_stuff.v0;
@@ -563,11 +566,10 @@ ia64_sn_partition_serial_get(void)
563 566
564static inline u64 567static inline u64
565sn_partition_serial_number_val(void) { 568sn_partition_serial_number_val(void) {
566 if (sn_partition_serial_number) { 569 if (unlikely(sn_partition_serial_number == 0)) {
567 return(sn_partition_serial_number); 570 sn_partition_serial_number = ia64_sn_partition_serial_get();
568 } else {
569 return(sn_partition_serial_number = ia64_sn_partition_serial_get());
570 } 571 }
572 return sn_partition_serial_number;
571} 573}
572 574
573/* 575/*
@@ -578,8 +580,8 @@ static inline partid_t
578ia64_sn_sysctl_partition_get(nasid_t nasid) 580ia64_sn_sysctl_partition_get(nasid_t nasid)
579{ 581{
580 struct ia64_sal_retval ret_stuff; 582 struct ia64_sal_retval ret_stuff;
581 SAL_CALL(ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid, 583 ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_SYSCTL_PARTITION_GET, nasid,
582 0, 0, 0, 0, 0, 0); 584 0, 0, 0, 0, 0, 0);
583 if (ret_stuff.status != 0) 585 if (ret_stuff.status != 0)
584 return INVALID_PARTID; 586 return INVALID_PARTID;
585 return ((partid_t)ret_stuff.v0); 587 return ((partid_t)ret_stuff.v0);
@@ -593,11 +595,38 @@ extern partid_t sn_partid;
593 595
594static inline partid_t 596static inline partid_t
595sn_local_partid(void) { 597sn_local_partid(void) {
596 if (sn_partid < 0) { 598 if (unlikely(sn_partid < 0)) {
597 return (sn_partid = ia64_sn_sysctl_partition_get(cpuid_to_nasid(smp_processor_id()))); 599 sn_partid = ia64_sn_sysctl_partition_get(cpuid_to_nasid(smp_processor_id()));
598 } else {
599 return sn_partid;
600 } 600 }
601 return sn_partid;
602}
603
604/*
605 * Returns the physical address of the partition's reserved page through
606 * an iterative number of calls.
607 *
608 * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
609 * set to the nasid of the partition whose reserved page's address is
610 * being sought.
611 * On subsequent calls, pass the values, that were passed back on the
612 * previous call.
613 *
614 * While the return status equals SALRET_MORE_PASSES, keep calling
615 * this function after first copying 'len' bytes starting at 'addr'
616 * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
617 * be the physical address of the partition's reserved page. If the
618 * return status equals neither of these, an error as occurred.
619 */
620static inline s64
621sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
622{
623 struct ia64_sal_retval rv;
624 ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
625 *addr, buf, *len, 0, 0, 0);
626 *cookie = rv.v0;
627 *addr = rv.v1;
628 *len = rv.v2;
629 return rv.status;
601} 630}
602 631
603/* 632/*
@@ -619,8 +648,8 @@ static inline int
619sn_register_xp_addr_region(u64 paddr, u64 len, int operation) 648sn_register_xp_addr_region(u64 paddr, u64 len, int operation)
620{ 649{
621 struct ia64_sal_retval ret_stuff; 650 struct ia64_sal_retval ret_stuff;
622 SAL_CALL(ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len, (u64)operation, 651 ia64_sal_oemcall(&ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len,
623 0, 0, 0, 0); 652 (u64)operation, 0, 0, 0, 0);
624 return ret_stuff.status; 653 return ret_stuff.status;
625} 654}
626 655
@@ -644,8 +673,8 @@ sn_register_nofault_code(u64 start_addr, u64 end_addr, u64 return_addr,
644 } else { 673 } else {
645 call = SN_SAL_NO_FAULT_ZONE_PHYSICAL; 674 call = SN_SAL_NO_FAULT_ZONE_PHYSICAL;
646 } 675 }
647 SAL_CALL(ret_stuff, call, start_addr, end_addr, return_addr, (u64)1, 676 ia64_sal_oemcall(&ret_stuff, call, start_addr, end_addr, return_addr,
648 0, 0, 0); 677 (u64)1, 0, 0, 0);
649 return ret_stuff.status; 678 return ret_stuff.status;
650} 679}
651 680
@@ -666,8 +695,8 @@ static inline int
666sn_change_coherence(u64 *new_domain, u64 *old_domain) 695sn_change_coherence(u64 *new_domain, u64 *old_domain)
667{ 696{
668 struct ia64_sal_retval ret_stuff; 697 struct ia64_sal_retval ret_stuff;
669 SAL_CALL(ret_stuff, SN_SAL_COHERENCE, new_domain, old_domain, 0, 0, 698 ia64_sal_oemcall(&ret_stuff, SN_SAL_COHERENCE, (u64)new_domain,
670 0, 0, 0); 699 (u64)old_domain, 0, 0, 0, 0, 0);
671 return ret_stuff.status; 700 return ret_stuff.status;
672} 701}
673 702
@@ -686,8 +715,8 @@ sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
686 cnodeid = nasid_to_cnodeid(get_node_number(paddr)); 715 cnodeid = nasid_to_cnodeid(get_node_number(paddr));
687 // spin_lock(&NODEPDA(cnodeid)->bist_lock); 716 // spin_lock(&NODEPDA(cnodeid)->bist_lock);
688 local_irq_save(irq_flags); 717 local_irq_save(irq_flags);
689 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_MEMPROTECT, paddr, len, nasid_array, 718 ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
690 perms, 0, 0, 0); 719 (u64)nasid_array, perms, 0, 0, 0);
691 local_irq_restore(irq_flags); 720 local_irq_restore(irq_flags);
692 // spin_unlock(&NODEPDA(cnodeid)->bist_lock); 721 // spin_unlock(&NODEPDA(cnodeid)->bist_lock);
693 return ret_stuff.status; 722 return ret_stuff.status;
@@ -849,6 +878,19 @@ ia64_sn_irtr_intr_disable(nasid_t nasid, int subch, u64 intr)
849 return (int) rv.v0; 878 return (int) rv.v0;
850} 879}
851 880
881/*
882 * Set up a node as the point of contact for system controller
883 * environmental event delivery.
884 */
885static inline int
886ia64_sn_sysctl_event_init(nasid_t nasid)
887{
888 struct ia64_sal_retval rv;
889 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_EVENT, (u64) nasid,
890 0, 0, 0, 0, 0, 0);
891 return (int) rv.v0;
892}
893
852/** 894/**
853 * ia64_sn_get_fit_compt - read a FIT entry from the PROM header 895 * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
854 * @nasid: NASID of node to read 896 * @nasid: NASID of node to read
@@ -1012,4 +1054,29 @@ ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
1012 return (int) rv.status; 1054 return (int) rv.status;
1013} 1055}
1014 1056
1057static inline int
1058ia64_sn_ioif_get_pci_topology(u64 rack, u64 bay, u64 slot, u64 slab,
1059 u64 buf, u64 len)
1060{
1061 struct ia64_sal_retval rv;
1062 SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY,
1063 rack, bay, slot, slab, buf, len, 0);
1064 return (int) rv.status;
1065}
1066
1067/*
1068 * BTE error recovery is implemented in SAL
1069 */
1070static inline int
1071ia64_sn_bte_recovery(nasid_t nasid)
1072{
1073 struct ia64_sal_retval rv;
1074
1075 rv.status = 0;
1076 SAL_CALL_NOLOCK(rv, SN_SAL_BTE_RECOVER, 0, 0, 0, 0, 0, 0, 0);
1077 if (rv.status == SALRET_NOT_IMPLEMENTED)
1078 return 0;
1079 return (int) rv.status;
1080}
1081
1015#endif /* _ASM_IA64_SN_SN_SAL_H */ 1082#endif /* _ASM_IA64_SN_SN_SAL_H */
diff --git a/include/asm-ia64/sn/sndrv.h b/include/asm-ia64/sn/sndrv.h
deleted file mode 100644
index aa00d42cde32..000000000000
--- a/include/asm-ia64/sn/sndrv.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2002-2004 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9#ifndef _ASM_IA64_SN_SNDRV_H
10#define _ASM_IA64_SN_SNDRV_H
11
12/* ioctl commands */
13#define SNDRV_GET_ROUTERINFO 1
14#define SNDRV_GET_INFOSIZE 2
15#define SNDRV_GET_HUBINFO 3
16#define SNDRV_GET_FLASHLOGSIZE 4
17#define SNDRV_SET_FLASHSYNC 5
18#define SNDRV_GET_FLASHLOGDATA 6
19#define SNDRV_GET_FLASHLOGALL 7
20
21#define SNDRV_SET_HISTOGRAM_TYPE 14
22
23#define SNDRV_ELSC_COMMAND 19
24#define SNDRV_CLEAR_LOG 20
25#define SNDRV_INIT_LOG 21
26#define SNDRV_GET_PIMM_PSC 22
27#define SNDRV_SET_PARTITION 23
28#define SNDRV_GET_PARTITION 24
29
30/* see synergy_perf_ioctl() */
31#define SNDRV_GET_SYNERGY_VERSION 30
32#define SNDRV_GET_SYNERGY_STATUS 31
33#define SNDRV_GET_SYNERGYINFO 32
34#define SNDRV_SYNERGY_APPEND 33
35#define SNDRV_SYNERGY_ENABLE 34
36#define SNDRV_SYNERGY_FREQ 35
37
38/* Devices */
39#define SNDRV_UKNOWN_DEVICE -1
40#define SNDRV_ROUTER_DEVICE 1
41#define SNDRV_HUB_DEVICE 2
42#define SNDRV_ELSC_NVRAM_DEVICE 3
43#define SNDRV_ELSC_CONTROLLER_DEVICE 4
44#define SNDRV_SYSCTL_SUBCH 5
45#define SNDRV_SYNERGY_DEVICE 6
46
47#endif /* _ASM_IA64_SN_SNDRV_H */
diff --git a/include/asm-ia64/sn/tioca.h b/include/asm-ia64/sn/tioca.h
new file mode 100644
index 000000000000..bc1aacfb9483
--- /dev/null
+++ b/include/asm-ia64/sn/tioca.h
@@ -0,0 +1,596 @@
1#ifndef _ASM_IA64_SN_TIO_TIOCA_H
2#define _ASM_IA64_SN_TIO_TIOCA_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (c) 2003-2005 Silicon Graphics, Inc. All rights reserved.
10 */
11
12
13#define TIOCA_PART_NUM 0xE020
14#define TIOCA_MFGR_NUM 0x24
15#define TIOCA_REV_A 0x1
16
17/*
18 * Register layout for TIO:CA. See below for bitmasks for each register.
19 */
20
21struct tioca {
22 uint64_t ca_id; /* 0x000000 */
23 uint64_t ca_control1; /* 0x000008 */
24 uint64_t ca_control2; /* 0x000010 */
25 uint64_t ca_status1; /* 0x000018 */
26 uint64_t ca_status2; /* 0x000020 */
27 uint64_t ca_gart_aperature; /* 0x000028 */
28 uint64_t ca_gfx_detach; /* 0x000030 */
29 uint64_t ca_inta_dest_addr; /* 0x000038 */
30 uint64_t ca_intb_dest_addr; /* 0x000040 */
31 uint64_t ca_err_int_dest_addr; /* 0x000048 */
32 uint64_t ca_int_status; /* 0x000050 */
33 uint64_t ca_int_status_alias; /* 0x000058 */
34 uint64_t ca_mult_error; /* 0x000060 */
35 uint64_t ca_mult_error_alias; /* 0x000068 */
36 uint64_t ca_first_error; /* 0x000070 */
37 uint64_t ca_int_mask; /* 0x000078 */
38 uint64_t ca_crm_pkterr_type; /* 0x000080 */
39 uint64_t ca_crm_pkterr_type_alias; /* 0x000088 */
40 uint64_t ca_crm_ct_error_detail_1; /* 0x000090 */
41 uint64_t ca_crm_ct_error_detail_2; /* 0x000098 */
42 uint64_t ca_crm_tnumto; /* 0x0000A0 */
43 uint64_t ca_gart_err; /* 0x0000A8 */
44 uint64_t ca_pcierr_type; /* 0x0000B0 */
45 uint64_t ca_pcierr_addr; /* 0x0000B8 */
46
47 uint64_t ca_pad_0000C0[3]; /* 0x0000{C0..D0} */
48
49 uint64_t ca_pci_rd_buf_flush; /* 0x0000D8 */
50 uint64_t ca_pci_dma_addr_extn; /* 0x0000E0 */
51 uint64_t ca_agp_dma_addr_extn; /* 0x0000E8 */
52 uint64_t ca_force_inta; /* 0x0000F0 */
53 uint64_t ca_force_intb; /* 0x0000F8 */
54 uint64_t ca_debug_vector_sel; /* 0x000100 */
55 uint64_t ca_debug_mux_core_sel; /* 0x000108 */
56 uint64_t ca_debug_mux_pci_sel; /* 0x000110 */
57 uint64_t ca_debug_domain_sel; /* 0x000118 */
58
59 uint64_t ca_pad_000120[28]; /* 0x0001{20..F8} */
60
61 uint64_t ca_gart_ptr_table; /* 0x200 */
62 uint64_t ca_gart_tlb_addr[8]; /* 0x2{08..40} */
63};
64
65/*
66 * Mask/shift definitions for TIO:CA registers. The convention here is
67 * to mainly use the names as they appear in the "TIO AEGIS Programmers'
68 * Reference" with a CA_ prefix added. Some exceptions were made to fix
69 * duplicate field names or to generalize fields that are common to
70 * different registers (ca_debug_mux_core_sel and ca_debug_mux_pci_sel for
71 * example).
72 *
73 * Fields consisting of a single bit have a single #define have a single
74 * macro declaration to mask the bit. Fields consisting of multiple bits
75 * have two declarations: one to mask the proper bits in a register, and
76 * a second with the suffix "_SHFT" to identify how far the mask needs to
77 * be shifted right to get its base value.
78 */
79
80/* ==== ca_control1 */
81#define CA_SYS_BIG_END (1ull << 0)
82#define CA_DMA_AGP_SWAP (1ull << 1)
83#define CA_DMA_PCI_SWAP (1ull << 2)
84#define CA_PIO_IO_SWAP (1ull << 3)
85#define CA_PIO_MEM_SWAP (1ull << 4)
86#define CA_GFX_WR_SWAP (1ull << 5)
87#define CA_AGP_FW_ENABLE (1ull << 6)
88#define CA_AGP_CAL_CYCLE (0x7ull << 7)
89#define CA_AGP_CAL_CYCLE_SHFT 7
90#define CA_AGP_CAL_PRSCL_BYP (1ull << 10)
91#define CA_AGP_INIT_CAL_ENB (1ull << 11)
92#define CA_INJ_ADDR_PERR (1ull << 12)
93#define CA_INJ_DATA_PERR (1ull << 13)
94 /* bits 15:14 unused */
95#define CA_PCIM_IO_NBE_AD (0x7ull << 16)
96#define CA_PCIM_IO_NBE_AD_SHFT 16
97#define CA_PCIM_FAST_BTB_ENB (1ull << 19)
98 /* bits 23:20 unused */
99#define CA_PIO_ADDR_OFFSET (0xffull << 24)
100#define CA_PIO_ADDR_OFFSET_SHFT 24
101 /* bits 35:32 unused */
102#define CA_AGPDMA_OP_COMBDELAY (0x1full << 36)
103#define CA_AGPDMA_OP_COMBDELAY_SHFT 36
104 /* bit 41 unused */
105#define CA_AGPDMA_OP_ENB_COMBDELAY (1ull << 42)
106#define CA_PCI_INT_LPCNT (0xffull << 44)
107#define CA_PCI_INT_LPCNT_SHFT 44
108 /* bits 63:52 unused */
109
110/* ==== ca_control2 */
111#define CA_AGP_LATENCY_TO (0xffull << 0)
112#define CA_AGP_LATENCY_TO_SHFT 0
113#define CA_PCI_LATENCY_TO (0xffull << 8)
114#define CA_PCI_LATENCY_TO_SHFT 8
115#define CA_PCI_MAX_RETRY (0x3ffull << 16)
116#define CA_PCI_MAX_RETRY_SHFT 16
117 /* bits 27:26 unused */
118#define CA_RT_INT_EN (0x3ull << 28)
119#define CA_RT_INT_EN_SHFT 28
120#define CA_MSI_INT_ENB (1ull << 30)
121#define CA_PCI_ARB_ERR_ENB (1ull << 31)
122#define CA_GART_MEM_PARAM (0x3ull << 32)
123#define CA_GART_MEM_PARAM_SHFT 32
124#define CA_GART_RD_PREFETCH_ENB (1ull << 34)
125#define CA_GART_WR_PREFETCH_ENB (1ull << 35)
126#define CA_GART_FLUSH_TLB (1ull << 36)
127 /* bits 39:37 unused */
128#define CA_CRM_TNUMTO_PERIOD (0x1fffull << 40)
129#define CA_CRM_TNUMTO_PERIOD_SHFT 40
130 /* bits 55:53 unused */
131#define CA_CRM_TNUMTO_ENB (1ull << 56)
132#define CA_CRM_PRESCALER_BYP (1ull << 57)
133 /* bits 59:58 unused */
134#define CA_CRM_MAX_CREDIT (0x7ull << 60)
135#define CA_CRM_MAX_CREDIT_SHFT 60
136 /* bit 63 unused */
137
138/* ==== ca_status1 */
139#define CA_CORELET_ID (0x3ull << 0)
140#define CA_CORELET_ID_SHFT 0
141#define CA_INTA_N (1ull << 2)
142#define CA_INTB_N (1ull << 3)
143#define CA_CRM_CREDIT_AVAIL (0x7ull << 4)
144#define CA_CRM_CREDIT_AVAIL_SHFT 4
145 /* bit 7 unused */
146#define CA_CRM_SPACE_AVAIL (0x7full << 8)
147#define CA_CRM_SPACE_AVAIL_SHFT 8
148 /* bit 15 unused */
149#define CA_GART_TLB_VAL (0xffull << 16)
150#define CA_GART_TLB_VAL_SHFT 16
151 /* bits 63:24 unused */
152
153/* ==== ca_status2 */
154#define CA_GFX_CREDIT_AVAIL (0xffull << 0)
155#define CA_GFX_CREDIT_AVAIL_SHFT 0
156#define CA_GFX_OPQ_AVAIL (0xffull << 8)
157#define CA_GFX_OPQ_AVAIL_SHFT 8
158#define CA_GFX_WRBUFF_AVAIL (0xffull << 16)
159#define CA_GFX_WRBUFF_AVAIL_SHFT 16
160#define CA_ADMA_OPQ_AVAIL (0xffull << 24)
161#define CA_ADMA_OPQ_AVAIL_SHFT 24
162#define CA_ADMA_WRBUFF_AVAIL (0xffull << 32)
163#define CA_ADMA_WRBUFF_AVAIL_SHFT 32
164#define CA_ADMA_RDBUFF_AVAIL (0x7full << 40)
165#define CA_ADMA_RDBUFF_AVAIL_SHFT 40
166#define CA_PCI_PIO_OP_STAT (1ull << 47)
167#define CA_PDMA_OPQ_AVAIL (0xfull << 48)
168#define CA_PDMA_OPQ_AVAIL_SHFT 48
169#define CA_PDMA_WRBUFF_AVAIL (0xfull << 52)
170#define CA_PDMA_WRBUFF_AVAIL_SHFT 52
171#define CA_PDMA_RDBUFF_AVAIL (0x3ull << 56)
172#define CA_PDMA_RDBUFF_AVAIL_SHFT 56
173 /* bits 63:58 unused */
174
175/* ==== ca_gart_aperature */
176#define CA_GART_AP_ENB_AGP (1ull << 0)
177#define CA_GART_PAGE_SIZE (1ull << 1)
178#define CA_GART_AP_ENB_PCI (1ull << 2)
179 /* bits 11:3 unused */
180#define CA_GART_AP_SIZE (0x3ffull << 12)
181#define CA_GART_AP_SIZE_SHFT 12
182#define CA_GART_AP_BASE (0x3ffffffffffull << 22)
183#define CA_GART_AP_BASE_SHFT 22
184
185/* ==== ca_inta_dest_addr
186 ==== ca_intb_dest_addr
187 ==== ca_err_int_dest_addr */
188 /* bits 2:0 unused */
189#define CA_INT_DEST_ADDR (0x7ffffffffffffull << 3)
190#define CA_INT_DEST_ADDR_SHFT 3
191 /* bits 55:54 unused */
192#define CA_INT_DEST_VECT (0xffull << 56)
193#define CA_INT_DEST_VECT_SHFT 56
194
195/* ==== ca_int_status */
196/* ==== ca_int_status_alias */
197/* ==== ca_mult_error */
198/* ==== ca_mult_error_alias */
199/* ==== ca_first_error */
200/* ==== ca_int_mask */
201#define CA_PCI_ERR (1ull << 0)
202 /* bits 3:1 unused */
203#define CA_GART_FETCH_ERR (1ull << 4)
204#define CA_GFX_WR_OVFLW (1ull << 5)
205#define CA_PIO_REQ_OVFLW (1ull << 6)
206#define CA_CRM_PKTERR (1ull << 7)
207#define CA_CRM_DVERR (1ull << 8)
208#define CA_TNUMTO (1ull << 9)
209#define CA_CXM_RSP_CRED_OVFLW (1ull << 10)
210#define CA_CXM_REQ_CRED_OVFLW (1ull << 11)
211#define CA_PIO_INVALID_ADDR (1ull << 12)
212#define CA_PCI_ARB_TO (1ull << 13)
213#define CA_AGP_REQ_OFLOW (1ull << 14)
214#define CA_SBA_TYPE1_ERR (1ull << 15)
215 /* bit 16 unused */
216#define CA_INTA (1ull << 17)
217#define CA_INTB (1ull << 18)
218#define CA_MULT_INTA (1ull << 19)
219#define CA_MULT_INTB (1ull << 20)
220#define CA_GFX_CREDIT_OVFLW (1ull << 21)
221 /* bits 63:22 unused */
222
223/* ==== ca_crm_pkterr_type */
224/* ==== ca_crm_pkterr_type_alias */
225#define CA_CRM_PKTERR_SBERR_HDR (1ull << 0)
226#define CA_CRM_PKTERR_DIDN (1ull << 1)
227#define CA_CRM_PKTERR_PACTYPE (1ull << 2)
228#define CA_CRM_PKTERR_INV_TNUM (1ull << 3)
229#define CA_CRM_PKTERR_ADDR_RNG (1ull << 4)
230#define CA_CRM_PKTERR_ADDR_ALGN (1ull << 5)
231#define CA_CRM_PKTERR_HDR_PARAM (1ull << 6)
232#define CA_CRM_PKTERR_CW_ERR (1ull << 7)
233#define CA_CRM_PKTERR_SBERR_NH (1ull << 8)
234#define CA_CRM_PKTERR_EARLY_TERM (1ull << 9)
235#define CA_CRM_PKTERR_EARLY_TAIL (1ull << 10)
236#define CA_CRM_PKTERR_MSSNG_TAIL (1ull << 11)
237#define CA_CRM_PKTERR_MSSNG_HDR (1ull << 12)
238 /* bits 15:13 unused */
239#define CA_FIRST_CRM_PKTERR_SBERR_HDR (1ull << 16)
240#define CA_FIRST_CRM_PKTERR_DIDN (1ull << 17)
241#define CA_FIRST_CRM_PKTERR_PACTYPE (1ull << 18)
242#define CA_FIRST_CRM_PKTERR_INV_TNUM (1ull << 19)
243#define CA_FIRST_CRM_PKTERR_ADDR_RNG (1ull << 20)
244#define CA_FIRST_CRM_PKTERR_ADDR_ALGN (1ull << 21)
245#define CA_FIRST_CRM_PKTERR_HDR_PARAM (1ull << 22)
246#define CA_FIRST_CRM_PKTERR_CW_ERR (1ull << 23)
247#define CA_FIRST_CRM_PKTERR_SBERR_NH (1ull << 24)
248#define CA_FIRST_CRM_PKTERR_EARLY_TERM (1ull << 25)
249#define CA_FIRST_CRM_PKTERR_EARLY_TAIL (1ull << 26)
250#define CA_FIRST_CRM_PKTERR_MSSNG_TAIL (1ull << 27)
251#define CA_FIRST_CRM_PKTERR_MSSNG_HDR (1ull << 28)
252 /* bits 63:29 unused */
253
254/* ==== ca_crm_ct_error_detail_1 */
255#define CA_PKT_TYPE (0xfull << 0)
256#define CA_PKT_TYPE_SHFT 0
257#define CA_SRC_ID (0x3ull << 4)
258#define CA_SRC_ID_SHFT 4
259#define CA_DATA_SZ (0x3ull << 6)
260#define CA_DATA_SZ_SHFT 6
261#define CA_TNUM (0xffull << 8)
262#define CA_TNUM_SHFT 8
263#define CA_DW_DATA_EN (0xffull << 16)
264#define CA_DW_DATA_EN_SHFT 16
265#define CA_GFX_CRED (0xffull << 24)
266#define CA_GFX_CRED_SHFT 24
267#define CA_MEM_RD_PARAM (0x3ull << 32)
268#define CA_MEM_RD_PARAM_SHFT 32
269#define CA_PIO_OP (1ull << 34)
270#define CA_CW_ERR (1ull << 35)
271 /* bits 62:36 unused */
272#define CA_VALID (1ull << 63)
273
274/* ==== ca_crm_ct_error_detail_2 */
275 /* bits 2:0 unused */
276#define CA_PKT_ADDR (0x1fffffffffffffull << 3)
277#define CA_PKT_ADDR_SHFT 3
278 /* bits 63:56 unused */
279
280/* ==== ca_crm_tnumto */
281#define CA_CRM_TNUMTO_VAL (0xffull << 0)
282#define CA_CRM_TNUMTO_VAL_SHFT 0
283#define CA_CRM_TNUMTO_WR (1ull << 8)
284 /* bits 63:9 unused */
285
286/* ==== ca_gart_err */
287#define CA_GART_ERR_SOURCE (0x3ull << 0)
288#define CA_GART_ERR_SOURCE_SHFT 0
289 /* bits 3:2 unused */
290#define CA_GART_ERR_ADDR (0xfffffffffull << 4)
291#define CA_GART_ERR_ADDR_SHFT 4
292 /* bits 63:40 unused */
293
294/* ==== ca_pcierr_type */
295#define CA_PCIERR_DATA (0xffffffffull << 0)
296#define CA_PCIERR_DATA_SHFT 0
297#define CA_PCIERR_ENB (0xfull << 32)
298#define CA_PCIERR_ENB_SHFT 32
299#define CA_PCIERR_CMD (0xfull << 36)
300#define CA_PCIERR_CMD_SHFT 36
301#define CA_PCIERR_A64 (1ull << 40)
302#define CA_PCIERR_SLV_SERR (1ull << 41)
303#define CA_PCIERR_SLV_WR_PERR (1ull << 42)
304#define CA_PCIERR_SLV_RD_PERR (1ull << 43)
305#define CA_PCIERR_MST_SERR (1ull << 44)
306#define CA_PCIERR_MST_WR_PERR (1ull << 45)
307#define CA_PCIERR_MST_RD_PERR (1ull << 46)
308#define CA_PCIERR_MST_MABT (1ull << 47)
309#define CA_PCIERR_MST_TABT (1ull << 48)
310#define CA_PCIERR_MST_RETRY_TOUT (1ull << 49)
311
312#define CA_PCIERR_TYPES \
313 (CA_PCIERR_A64|CA_PCIERR_SLV_SERR| \
314 CA_PCIERR_SLV_WR_PERR|CA_PCIERR_SLV_RD_PERR| \
315 CA_PCIERR_MST_SERR|CA_PCIERR_MST_WR_PERR|CA_PCIERR_MST_RD_PERR| \
316 CA_PCIERR_MST_MABT|CA_PCIERR_MST_TABT|CA_PCIERR_MST_RETRY_TOUT)
317
318 /* bits 63:50 unused */
319
320/* ==== ca_pci_dma_addr_extn */
321#define CA_UPPER_NODE_OFFSET (0x3full << 0)
322#define CA_UPPER_NODE_OFFSET_SHFT 0
323 /* bits 7:6 unused */
324#define CA_CHIPLET_ID (0x3ull << 8)
325#define CA_CHIPLET_ID_SHFT 8
326 /* bits 11:10 unused */
327#define CA_PCI_DMA_NODE_ID (0xffffull << 12)
328#define CA_PCI_DMA_NODE_ID_SHFT 12
329 /* bits 27:26 unused */
330#define CA_PCI_DMA_PIO_MEM_TYPE (1ull << 28)
331 /* bits 63:29 unused */
332
333
334/* ==== ca_agp_dma_addr_extn */
335 /* bits 19:0 unused */
336#define CA_AGP_DMA_NODE_ID (0xffffull << 20)
337#define CA_AGP_DMA_NODE_ID_SHFT 20
338 /* bits 27:26 unused */
339#define CA_AGP_DMA_PIO_MEM_TYPE (1ull << 28)
340 /* bits 63:29 unused */
341
342/* ==== ca_debug_vector_sel */
343#define CA_DEBUG_MN_VSEL (0xfull << 0)
344#define CA_DEBUG_MN_VSEL_SHFT 0
345#define CA_DEBUG_PP_VSEL (0xfull << 4)
346#define CA_DEBUG_PP_VSEL_SHFT 4
347#define CA_DEBUG_GW_VSEL (0xfull << 8)
348#define CA_DEBUG_GW_VSEL_SHFT 8
349#define CA_DEBUG_GT_VSEL (0xfull << 12)
350#define CA_DEBUG_GT_VSEL_SHFT 12
351#define CA_DEBUG_PD_VSEL (0xfull << 16)
352#define CA_DEBUG_PD_VSEL_SHFT 16
353#define CA_DEBUG_AD_VSEL (0xfull << 20)
354#define CA_DEBUG_AD_VSEL_SHFT 20
355#define CA_DEBUG_CX_VSEL (0xfull << 24)
356#define CA_DEBUG_CX_VSEL_SHFT 24
357#define CA_DEBUG_CR_VSEL (0xfull << 28)
358#define CA_DEBUG_CR_VSEL_SHFT 28
359#define CA_DEBUG_BA_VSEL (0xfull << 32)
360#define CA_DEBUG_BA_VSEL_SHFT 32
361#define CA_DEBUG_PE_VSEL (0xfull << 36)
362#define CA_DEBUG_PE_VSEL_SHFT 36
363#define CA_DEBUG_BO_VSEL (0xfull << 40)
364#define CA_DEBUG_BO_VSEL_SHFT 40
365#define CA_DEBUG_BI_VSEL (0xfull << 44)
366#define CA_DEBUG_BI_VSEL_SHFT 44
367#define CA_DEBUG_AS_VSEL (0xfull << 48)
368#define CA_DEBUG_AS_VSEL_SHFT 48
369#define CA_DEBUG_PS_VSEL (0xfull << 52)
370#define CA_DEBUG_PS_VSEL_SHFT 52
371#define CA_DEBUG_PM_VSEL (0xfull << 56)
372#define CA_DEBUG_PM_VSEL_SHFT 56
373 /* bits 63:60 unused */
374
375/* ==== ca_debug_mux_core_sel */
376/* ==== ca_debug_mux_pci_sel */
377#define CA_DEBUG_MSEL0 (0x7ull << 0)
378#define CA_DEBUG_MSEL0_SHFT 0
379 /* bit 3 unused */
380#define CA_DEBUG_NSEL0 (0x7ull << 4)
381#define CA_DEBUG_NSEL0_SHFT 4
382 /* bit 7 unused */
383#define CA_DEBUG_MSEL1 (0x7ull << 8)
384#define CA_DEBUG_MSEL1_SHFT 8
385 /* bit 11 unused */
386#define CA_DEBUG_NSEL1 (0x7ull << 12)
387#define CA_DEBUG_NSEL1_SHFT 12
388 /* bit 15 unused */
389#define CA_DEBUG_MSEL2 (0x7ull << 16)
390#define CA_DEBUG_MSEL2_SHFT 16
391 /* bit 19 unused */
392#define CA_DEBUG_NSEL2 (0x7ull << 20)
393#define CA_DEBUG_NSEL2_SHFT 20
394 /* bit 23 unused */
395#define CA_DEBUG_MSEL3 (0x7ull << 24)
396#define CA_DEBUG_MSEL3_SHFT 24
397 /* bit 27 unused */
398#define CA_DEBUG_NSEL3 (0x7ull << 28)
399#define CA_DEBUG_NSEL3_SHFT 28
400 /* bit 31 unused */
401#define CA_DEBUG_MSEL4 (0x7ull << 32)
402#define CA_DEBUG_MSEL4_SHFT 32
403 /* bit 35 unused */
404#define CA_DEBUG_NSEL4 (0x7ull << 36)
405#define CA_DEBUG_NSEL4_SHFT 36
406 /* bit 39 unused */
407#define CA_DEBUG_MSEL5 (0x7ull << 40)
408#define CA_DEBUG_MSEL5_SHFT 40
409 /* bit 43 unused */
410#define CA_DEBUG_NSEL5 (0x7ull << 44)
411#define CA_DEBUG_NSEL5_SHFT 44
412 /* bit 47 unused */
413#define CA_DEBUG_MSEL6 (0x7ull << 48)
414#define CA_DEBUG_MSEL6_SHFT 48
415 /* bit 51 unused */
416#define CA_DEBUG_NSEL6 (0x7ull << 52)
417#define CA_DEBUG_NSEL6_SHFT 52
418 /* bit 55 unused */
419#define CA_DEBUG_MSEL7 (0x7ull << 56)
420#define CA_DEBUG_MSEL7_SHFT 56
421 /* bit 59 unused */
422#define CA_DEBUG_NSEL7 (0x7ull << 60)
423#define CA_DEBUG_NSEL7_SHFT 60
424 /* bit 63 unused */
425
426
427/* ==== ca_debug_domain_sel */
428#define CA_DEBUG_DOMAIN_L (1ull << 0)
429#define CA_DEBUG_DOMAIN_H (1ull << 1)
430 /* bits 63:2 unused */
431
432/* ==== ca_gart_ptr_table */
433#define CA_GART_PTR_VAL (1ull << 0)
434 /* bits 11:1 unused */
435#define CA_GART_PTR_ADDR (0xfffffffffffull << 12)
436#define CA_GART_PTR_ADDR_SHFT 12
437 /* bits 63:56 unused */
438
439/* ==== ca_gart_tlb_addr[0-7] */
440#define CA_GART_TLB_ADDR (0xffffffffffffffull << 0)
441#define CA_GART_TLB_ADDR_SHFT 0
442 /* bits 62:56 unused */
443#define CA_GART_TLB_ENTRY_VAL (1ull << 63)
444
445/*
446 * PIO address space ranges for TIO:CA
447 */
448
449/* CA internal registers */
450#define CA_PIO_ADMIN 0x00000000
451#define CA_PIO_ADMIN_LEN 0x00010000
452
453/* GFX Write Buffer - Diagnostics */
454#define CA_PIO_GFX 0x00010000
455#define CA_PIO_GFX_LEN 0x00010000
456
457/* AGP DMA Write Buffer - Diagnostics */
458#define CA_PIO_AGP_DMAWRITE 0x00020000
459#define CA_PIO_AGP_DMAWRITE_LEN 0x00010000
460
461/* AGP DMA READ Buffer - Diagnostics */
462#define CA_PIO_AGP_DMAREAD 0x00030000
463#define CA_PIO_AGP_DMAREAD_LEN 0x00010000
464
465/* PCI Config Type 0 */
466#define CA_PIO_PCI_TYPE0_CONFIG 0x01000000
467#define CA_PIO_PCI_TYPE0_CONFIG_LEN 0x01000000
468
469/* PCI Config Type 1 */
470#define CA_PIO_PCI_TYPE1_CONFIG 0x02000000
471#define CA_PIO_PCI_TYPE1_CONFIG_LEN 0x01000000
472
473/* PCI I/O Cycles - mapped to PCI Address 0x00000000-0x04ffffff */
474#define CA_PIO_PCI_IO 0x03000000
475#define CA_PIO_PCI_IO_LEN 0x05000000
476
477/* PCI MEM Cycles - mapped to PCI with CA_PIO_ADDR_OFFSET of ca_control1 */
478/* use Fast Write if enabled and coretalk packet type is a GFX request */
479#define CA_PIO_PCI_MEM_OFFSET 0x08000000
480#define CA_PIO_PCI_MEM_OFFSET_LEN 0x08000000
481
482/* PCI MEM Cycles - mapped to PCI Address 0x00000000-0xbfffffff */
483/* use Fast Write if enabled and coretalk packet type is a GFX request */
484#define CA_PIO_PCI_MEM 0x40000000
485#define CA_PIO_PCI_MEM_LEN 0xc0000000
486
487/*
488 * DMA space
489 *
490 * The CA aperature (ie. bus address range) mapped by the GART is segmented into
491 * two parts. The lower portion of the aperature is used for mapping 32 bit
492 * PCI addresses which are managed by the dma interfaces in this file. The
493 * upper poprtion of the aperature is used for mapping 48 bit AGP addresses.
494 * The AGP portion of the aperature is managed by the agpgart_be.c driver
495 * in drivers/linux/agp. There are ca-specific hooks in that driver to
496 * manipulate the gart, but management of the AGP portion of the aperature
497 * is the responsibility of that driver.
498 *
499 * CA allows three main types of DMA mapping:
500 *
501 * PCI 64-bit Managed by this driver
502 * PCI 32-bit Managed by this driver
503 * AGP 48-bit Managed by hooks in the /dev/agpgart driver
504 *
505 * All of the above can optionally be remapped through the GART. The following
506 * table lists the combinations of addressing types and GART remapping that
507 * is currently supported by the driver (h/w supports all, s/w limits this):
508 *
509 * PCI64 PCI32 AGP48
510 * GART no yes yes
511 * Direct yes yes no
512 *
513 * GART remapping of PCI64 is not done because there is no need to. The
514 * 64 bit PCI address holds all of the information necessary to target any
515 * memory in the system.
516 *
517 * AGP48 is always mapped through the GART. Management of the AGP48 portion
518 * of the aperature is the responsibility of code in the agpgart_be driver.
519 *
520 * The non-64 bit bus address space will currently be partitioned like this:
521 *
522 * 0xffff_ffff_ffff +--------
523 * | AGP48 direct
524 * | Space managed by this driver
525 * CA_AGP_DIRECT_BASE +--------
526 * | AGP GART mapped (gfx aperature)
527 * | Space managed by /dev/agpgart driver
528 * | This range is exposed to the agpgart
529 * | driver as the "graphics aperature"
530 * CA_AGP_MAPPED_BASE +-----
531 * | PCI GART mapped
532 * | Space managed by this driver
533 * CA_PCI32_MAPPED_BASE +----
534 * | PCI32 direct
535 * | Space managed by this driver
536 * 0xC000_0000 +--------
537 * (CA_PCI32_DIRECT_BASE)
538 *
539 * The bus address range CA_PCI32_MAPPED_BASE through CA_AGP_DIRECT_BASE
540 * is what we call the CA aperature. Addresses falling in this range will
541 * be remapped using the GART.
542 *
543 * The bus address range CA_AGP_MAPPED_BASE through CA_AGP_DIRECT_BASE
544 * is what we call the graphics aperature. This is a subset of the CA
545 * aperature and is under the control of the agpgart_be driver.
546 *
547 * CA_PCI32_MAPPED_BASE, CA_AGP_MAPPED_BASE, and CA_AGP_DIRECT_BASE are
548 * somewhat arbitrary values. The known constraints on choosing these is:
549 *
550 * 1) CA_AGP_DIRECT_BASE-CA_PCI32_MAPPED_BASE+1 (the CA aperature size)
551 * must be one of the values supported by the ca_gart_aperature register.
552 * Currently valid values are: 4MB through 4096MB in powers of 2 increments
553 *
554 * 2) CA_AGP_DIRECT_BASE-CA_AGP_MAPPED_BASE+1 (the gfx aperature size)
555 * must be in MB units since that's what the agpgart driver assumes.
556 */
557
558/*
559 * Define Bus DMA ranges. These are configurable (see constraints above)
560 * and will probably need tuning based on experience.
561 */
562
563
564/*
565 * 11/24/03
566 * CA has an addressing glitch w.r.t. PCI direct 32 bit DMA that makes it
567 * generally unusable. The problem is that for PCI direct 32
568 * DMA's, all 32 bits of the bus address are used to form the lower 32 bits
569 * of the coretalk address, and coretalk bits 38:32 come from a register.
570 * Since only PCI bus addresses 0xC0000000-0xFFFFFFFF (1GB) are available
571 * for DMA (the rest is allocated to PIO), host node addresses need to be
572 * such that their lower 32 bits fall in the 0xC0000000-0xffffffff range
573 * as well. So there can be no PCI32 direct DMA below 3GB!! For this
574 * reason we set the CA_PCI32_DIRECT_SIZE to 0 which essentially makes
575 * tioca_dma_direct32() a noop but preserves the code flow should this issue
576 * be fixed in a respin.
577 *
578 * For now, all PCI32 DMA's must be mapped through the GART.
579 */
580
581#define CA_PCI32_DIRECT_BASE 0xC0000000UL /* BASE not configurable */
582#define CA_PCI32_DIRECT_SIZE 0x00000000UL /* 0 MB */
583
584#define CA_PCI32_MAPPED_BASE 0xC0000000UL
585#define CA_PCI32_MAPPED_SIZE 0x40000000UL /* 2GB */
586
587#define CA_AGP_MAPPED_BASE 0x80000000UL
588#define CA_AGP_MAPPED_SIZE 0x40000000UL /* 2GB */
589
590#define CA_AGP_DIRECT_BASE 0x40000000UL /* 2GB */
591#define CA_AGP_DIRECT_SIZE 0x40000000UL
592
593#define CA_APERATURE_BASE (CA_AGP_MAPPED_BASE)
594#define CA_APERATURE_SIZE (CA_AGP_MAPPED_SIZE+CA_PCI32_MAPPED_SIZE)
595
596#endif /* _ASM_IA64_SN_TIO_TIOCA_H */
diff --git a/include/asm-ia64/sn/tioca_provider.h b/include/asm-ia64/sn/tioca_provider.h
new file mode 100644
index 000000000000..b6acc22ab239
--- /dev/null
+++ b/include/asm-ia64/sn/tioca_provider.h
@@ -0,0 +1,206 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2003-2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#ifndef _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H
10#define _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H
11
12#include <asm/sn/tioca.h>
13
14/*
15 * WAR enables
16 * Defines for individual WARs. Each is a bitmask of applicable
17 * part revision numbers. (1 << 1) == rev A, (1 << 2) == rev B,
18 * (3 << 1) == (rev A or rev B), etc
19 */
20
21#define TIOCA_WAR_ENABLED(pv, tioca_common) \
22 ((1 << tioca_common->ca_rev) & pv)
23
24 /* TIO:ICE:FRZ:Freezer loses a PIO data ucred on PIO RD RSP with CW error */
25#define PV907908 (1 << 1)
26 /* ATI config space problems after BIOS execution starts */
27#define PV908234 (1 << 1)
28 /* CA:AGPDMA write request data mismatch with ABC1CL merge */
29#define PV895469 (1 << 1)
30 /* TIO:CA TLB invalidate of written GART entries possibly not occuring in CA*/
31#define PV910244 (1 << 1)
32
33struct tioca_dmamap{
34 struct list_head cad_list; /* headed by ca_list */
35
36 dma_addr_t cad_dma_addr; /* Linux dma handle */
37 uint cad_gart_entry; /* start entry in ca_gart_pagemap */
38 uint cad_gart_size; /* #entries for this map */
39};
40
41/*
42 * Kernel only fields. Prom may look at this stuff for debugging only.
43 * Access this structure through the ca_kernel_private ptr.
44 */
45
46struct tioca_common ;
47
48struct tioca_kernel {
49 struct tioca_common *ca_common; /* tioca this belongs to */
50 struct list_head ca_list; /* list of all ca's */
51 struct list_head ca_dmamaps;
52 spinlock_t ca_lock; /* Kernel lock */
53 cnodeid_t ca_closest_node;
54 struct list_head *ca_devices; /* bus->devices */
55
56 /*
57 * General GART stuff
58 */
59 uint64_t ca_ap_size; /* size of aperature in bytes */
60 uint32_t ca_gart_entries; /* # uint64_t entries in gart */
61 uint32_t ca_ap_pagesize; /* aperature page size in bytes */
62 uint64_t ca_ap_bus_base; /* bus address of CA aperature */
63 uint64_t ca_gart_size; /* gart size in bytes */
64 uint64_t *ca_gart; /* gart table vaddr */
65 uint64_t ca_gart_coretalk_addr; /* gart coretalk addr */
66 uint8_t ca_gart_iscoherent; /* used in tioca_tlbflush */
67
68 /* PCI GART convenience values */
69 uint64_t ca_pciap_base; /* pci aperature bus base address */
70 uint64_t ca_pciap_size; /* pci aperature size (bytes) */
71 uint64_t ca_pcigart_base; /* gfx GART bus base address */
72 uint64_t *ca_pcigart; /* gfx GART vm address */
73 uint32_t ca_pcigart_entries;
74 uint32_t ca_pcigart_start; /* PCI start index in ca_gart */
75 void *ca_pcigart_pagemap;
76
77 /* AGP GART convenience values */
78 uint64_t ca_gfxap_base; /* gfx aperature bus base address */
79 uint64_t ca_gfxap_size; /* gfx aperature size (bytes) */
80 uint64_t ca_gfxgart_base; /* gfx GART bus base address */
81 uint64_t *ca_gfxgart; /* gfx GART vm address */
82 uint32_t ca_gfxgart_entries;
83 uint32_t ca_gfxgart_start; /* agpgart start index in ca_gart */
84};
85
86/*
87 * Common tioca info shared between kernel and prom
88 *
89 * DO NOT CHANGE THIS STRUCT WITHOUT MAKING CORRESPONDING CHANGES
90 * TO THE PROM VERSION.
91 */
92
93struct tioca_common {
94 struct pcibus_bussoft ca_common; /* common pciio header */
95
96 uint32_t ca_rev;
97 uint32_t ca_closest_nasid;
98
99 uint64_t ca_prom_private;
100 uint64_t ca_kernel_private;
101};
102
103/**
104 * tioca_paddr_to_gart - Convert an SGI coretalk address to a CA GART entry
105 * @paddr: page address to convert
106 *
107 * Convert a system [coretalk] address to a GART entry. GART entries are
108 * formed using the following:
109 *
110 * data = ( (1<<63) | ( (REMAP_NODE_ID << 40) | (MD_CHIPLET_ID << 38) |
111 * (REMAP_SYS_ADDR) ) >> 12 )
112 *
113 * DATA written to 1 GART TABLE Entry in system memory is remapped system
114 * addr for 1 page
115 *
116 * The data is for coretalk address format right shifted 12 bits with a
117 * valid bit.
118 *
119 * GART_TABLE_ENTRY [ 25:0 ] -- REMAP_SYS_ADDRESS[37:12].
120 * GART_TABLE_ENTRY [ 27:26 ] -- SHUB MD chiplet id.
121 * GART_TABLE_ENTRY [ 41:28 ] -- REMAP_NODE_ID.
122 * GART_TABLE_ENTRY [ 63 ] -- Valid Bit
123 */
124static inline u64
125tioca_paddr_to_gart(unsigned long paddr)
126{
127 /*
128 * We are assuming right now that paddr already has the correct
129 * format since the address from xtalk_dmaXXX should already have
130 * NODE_ID, CHIPLET_ID, and SYS_ADDR in the correct locations.
131 */
132
133 return ((paddr) >> 12) | (1UL << 63);
134}
135
136/**
137 * tioca_physpage_to_gart - Map a host physical page for SGI CA based DMA
138 * @page_addr: system page address to map
139 */
140
141static inline unsigned long
142tioca_physpage_to_gart(uint64_t page_addr)
143{
144 uint64_t coretalk_addr;
145
146 coretalk_addr = PHYS_TO_TIODMA(page_addr);
147 if (!coretalk_addr) {
148 return 0;
149 }
150
151 return tioca_paddr_to_gart(coretalk_addr);
152}
153
154/**
155 * tioca_tlbflush - invalidate cached SGI CA GART TLB entries
156 * @tioca_kernel: CA context
157 *
158 * Invalidate tlb entries for a given CA GART. Main complexity is to account
159 * for revA bug.
160 */
161static inline void
162tioca_tlbflush(struct tioca_kernel *tioca_kernel)
163{
164 volatile uint64_t tmp;
165 volatile struct tioca *ca_base;
166 struct tioca_common *tioca_common;
167
168 tioca_common = tioca_kernel->ca_common;
169 ca_base = (struct tioca *)tioca_common->ca_common.bs_base;
170
171 /*
172 * Explicit flushes not needed if GART is in cached mode
173 */
174 if (tioca_kernel->ca_gart_iscoherent) {
175 if (TIOCA_WAR_ENABLED(PV910244, tioca_common)) {
176 /*
177 * PV910244: RevA CA needs explicit flushes.
178 * Need to put GART into uncached mode before
179 * flushing otherwise the explicit flush is ignored.
180 *
181 * Alternate WAR would be to leave GART cached and
182 * touch every CL aligned GART entry.
183 */
184
185 ca_base->ca_control2 &= ~(CA_GART_MEM_PARAM);
186 ca_base->ca_control2 |= CA_GART_FLUSH_TLB;
187 ca_base->ca_control2 |=
188 (0x2ull << CA_GART_MEM_PARAM_SHFT);
189 tmp = ca_base->ca_control2;
190 }
191
192 return;
193 }
194
195 /*
196 * Gart in uncached mode ... need an explicit flush.
197 */
198
199 ca_base->ca_control2 |= CA_GART_FLUSH_TLB;
200 tmp = ca_base->ca_control2;
201}
202
203extern uint32_t tioca_gart_found;
204extern int tioca_init_provider(void);
205extern void tioca_fastwrite_enable(struct tioca_kernel *tioca_kern);
206#endif /* _ASM_IA64_SN_TIO_CA_AGP_PROVIDER_H */
diff --git a/include/asm-ia64/sn/tiocx.h b/include/asm-ia64/sn/tiocx.h
new file mode 100644
index 000000000000..c5447a504509
--- /dev/null
+++ b/include/asm-ia64/sn/tiocx.h
@@ -0,0 +1,71 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#ifndef _ASM_IA64_SN_TIO_TIOCX_H
10#define _ASM_IA64_SN_TIO_TIOCX_H
11
12#ifdef __KERNEL__
13
14struct cx_id_s {
15 unsigned int part_num;
16 unsigned int mfg_num;
17 int nasid;
18};
19
20struct cx_dev {
21 struct cx_id_s cx_id;
22 void *soft; /* driver specific */
23 struct hubdev_info *hubdev;
24 struct device dev;
25 struct cx_drv *driver;
26};
27
28struct cx_device_id {
29 unsigned int part_num;
30 unsigned int mfg_num;
31};
32
33struct cx_drv {
34 char *name;
35 const struct cx_device_id *id_table;
36 struct device_driver driver;
37 int (*probe) (struct cx_dev * dev, const struct cx_device_id * id);
38 int (*remove) (struct cx_dev * dev);
39};
40
41/* create DMA address by stripping AS bits */
42#define TIOCX_DMA_ADDR(a) (uint64_t)((uint64_t)(a) & 0xffffcfffffffffUL)
43
44#define TIOCX_TO_TIOCX_DMA_ADDR(a) (uint64_t)(((uint64_t)(a) & 0xfffffffff) | \
45 ((((uint64_t)(a)) & 0xffffc000000000UL) <<2))
46
47#define TIO_CE_ASIC_PARTNUM 0xce00
48#define TIOCX_CORELET 3
49
50/* These are taken from tio_mmr_as.h */
51#define TIO_ICE_FRZ_CFG TIO_MMR_ADDR_MOD(0x00000000b0008100UL)
52#define TIO_ICE_PMI_TX_CFG TIO_MMR_ADDR_MOD(0x00000000b000b100UL)
53#define TIO_ICE_PMI_TX_DYN_CREDIT_STAT_CB3 TIO_MMR_ADDR_MOD(0x00000000b000be18UL)
54#define TIO_ICE_PMI_TX_DYN_CREDIT_STAT_CB3_CREDIT_CNT_MASK 0x000000000000000fUL
55
56#define to_cx_dev(n) container_of(n, struct cx_dev, dev)
57#define to_cx_driver(drv) container_of(drv, struct cx_drv, driver)
58
59extern struct sn_irq_info *tiocx_irq_alloc(nasid_t, int, int, nasid_t, int);
60extern void tiocx_irq_free(struct sn_irq_info *);
61extern int cx_device_unregister(struct cx_dev *);
62extern int cx_device_register(nasid_t, int, int, struct hubdev_info *);
63extern int cx_driver_unregister(struct cx_drv *);
64extern int cx_driver_register(struct cx_drv *);
65extern uint64_t tiocx_dma_addr(uint64_t addr);
66extern uint64_t tiocx_swin_base(int nasid);
67extern void tiocx_mmr_store(int nasid, uint64_t offset, uint64_t value);
68extern uint64_t tiocx_mmr_load(int nasid, uint64_t offset);
69
70#endif // __KERNEL__
71#endif // _ASM_IA64_SN_TIO_TIOCX__
diff --git a/include/asm-ia64/sn/types.h b/include/asm-ia64/sn/types.h
index 586ed47cae9c..8e04ee211e59 100644
--- a/include/asm-ia64/sn/types.h
+++ b/include/asm-ia64/sn/types.h
@@ -16,7 +16,8 @@ typedef signed short nasid_t; /* node id in numa-as-id space */
16typedef signed char partid_t; /* partition ID type */ 16typedef signed char partid_t; /* partition ID type */
17typedef unsigned int moduleid_t; /* user-visible module number type */ 17typedef unsigned int moduleid_t; /* user-visible module number type */
18typedef unsigned int cmoduleid_t; /* kernel compact module id type */ 18typedef unsigned int cmoduleid_t; /* kernel compact module id type */
19typedef signed char slabid_t; 19typedef unsigned char slotid_t; /* slot (blade) within module */
20typedef unsigned char slabid_t; /* slab (asic) within slot */
20typedef u64 nic_t; 21typedef u64 nic_t;
21typedef unsigned long iopaddr_t; 22typedef unsigned long iopaddr_t;
22typedef unsigned long paddr_t; 23typedef unsigned long paddr_t;
diff --git a/include/asm-ia64/sn/xp.h b/include/asm-ia64/sn/xp.h
new file mode 100644
index 000000000000..9902185c0288
--- /dev/null
+++ b/include/asm-ia64/sn/xp.h
@@ -0,0 +1,436 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2004-2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9
10/*
11 * External Cross Partition (XP) structures and defines.
12 */
13
14
15#ifndef _ASM_IA64_SN_XP_H
16#define _ASM_IA64_SN_XP_H
17
18
19#include <linux/version.h>
20#include <linux/cache.h>
21#include <linux/hardirq.h>
22#include <asm/sn/types.h>
23#include <asm/sn/bte.h>
24
25
26#ifdef USE_DBUG_ON
27#define DBUG_ON(condition) BUG_ON(condition)
28#else
29#define DBUG_ON(condition)
30#endif
31
32
33/*
34 * Define the maximum number of logically defined partitions the system
35 * can support. It is constrained by the maximum number of hardware
36 * partitionable regions. The term 'region' in this context refers to the
37 * minimum number of nodes that can comprise an access protection grouping.
38 * The access protection is in regards to memory, IPI and IOI.
39 *
40 * The maximum number of hardware partitionable regions is equal to the
41 * maximum number of nodes in the entire system divided by the minimum number
42 * of nodes that comprise an access protection grouping.
43 */
44#define XP_MAX_PARTITIONS 64
45
46
47/*
48 * Define the number of u64s required to represent all the C-brick nasids
49 * as a bitmap. The cross-partition kernel modules deal only with
50 * C-brick nasids, thus the need for bitmaps which don't account for
51 * odd-numbered (non C-brick) nasids.
52 */
53#define XP_MAX_PHYSNODE_ID (MAX_PHYSNODE_ID / 2)
54#define XP_NASID_MASK_BYTES ((XP_MAX_PHYSNODE_ID + 7) / 8)
55#define XP_NASID_MASK_WORDS ((XP_MAX_PHYSNODE_ID + 63) / 64)
56
57
58/*
59 * Wrapper for bte_copy() that should it return a failure status will retry
60 * the bte_copy() once in the hope that the failure was due to a temporary
61 * aberration (i.e., the link going down temporarily).
62 *
63 * See bte_copy for definition of the input parameters.
64 *
65 * Note: xp_bte_copy() should never be called while holding a spinlock.
66 */
67static inline bte_result_t
68xp_bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
69{
70 bte_result_t ret;
71
72
73 ret = bte_copy(src, dest, len, mode, notification);
74
75 if (ret != BTE_SUCCESS) {
76 if (!in_interrupt()) {
77 cond_resched();
78 }
79 ret = bte_copy(src, dest, len, mode, notification);
80 }
81
82 return ret;
83}
84
85
86/*
87 * XPC establishes channel connections between the local partition and any
88 * other partition that is currently up. Over these channels, kernel-level
89 * `users' can communicate with their counterparts on the other partitions.
90 *
91 * The maxinum number of channels is limited to eight. For performance reasons,
92 * the internal cross partition structures require sixteen bytes per channel,
93 * and eight allows all of this interface-shared info to fit in one cache line.
94 *
95 * XPC_NCHANNELS reflects the total number of channels currently defined.
96 * If the need for additional channels arises, one can simply increase
97 * XPC_NCHANNELS accordingly. If the day should come where that number
98 * exceeds the MAXIMUM number of channels allowed (eight), then one will need
99 * to make changes to the XPC code to allow for this.
100 */
101#define XPC_MEM_CHANNEL 0 /* memory channel number */
102#define XPC_NET_CHANNEL 1 /* network channel number */
103
104#define XPC_NCHANNELS 2 /* #of defined channels */
105#define XPC_MAX_NCHANNELS 8 /* max #of channels allowed */
106
107#if XPC_NCHANNELS > XPC_MAX_NCHANNELS
108#error XPC_NCHANNELS exceeds MAXIMUM allowed.
109#endif
110
111
112/*
113 * The format of an XPC message is as follows:
114 *
115 * +-------+--------------------------------+
116 * | flags |////////////////////////////////|
117 * +-------+--------------------------------+
118 * | message # |
119 * +----------------------------------------+
120 * | payload (user-defined message) |
121 * | |
122 * :
123 * | |
124 * +----------------------------------------+
125 *
126 * The size of the payload is defined by the user via xpc_connect(). A user-
127 * defined message resides in the payload area.
128 *
129 * The user should have no dealings with the message header, but only the
130 * message's payload. When a message entry is allocated (via xpc_allocate())
131 * a pointer to the payload area is returned and not the actual beginning of
132 * the XPC message. The user then constructs a message in the payload area
133 * and passes that pointer as an argument on xpc_send() or xpc_send_notify().
134 *
135 * The size of a message entry (within a message queue) must be a cacheline
136 * sized multiple in order to facilitate the BTE transfer of messages from one
137 * message queue to another. A macro, XPC_MSG_SIZE(), is provided for the user
138 * that wants to fit as many msg entries as possible in a given memory size
139 * (e.g. a memory page).
140 */
141struct xpc_msg {
142 u8 flags; /* FOR XPC INTERNAL USE ONLY */
143 u8 reserved[7]; /* FOR XPC INTERNAL USE ONLY */
144 s64 number; /* FOR XPC INTERNAL USE ONLY */
145
146 u64 payload; /* user defined portion of message */
147};
148
149
150#define XPC_MSG_PAYLOAD_OFFSET (u64) (&((struct xpc_msg *)0)->payload)
151#define XPC_MSG_SIZE(_payload_size) \
152 L1_CACHE_ALIGN(XPC_MSG_PAYLOAD_OFFSET + (_payload_size))
153
154
155/*
156 * Define the return values and values passed to user's callout functions.
157 * (It is important to add new value codes at the end just preceding
158 * xpcUnknownReason, which must have the highest numerical value.)
159 */
160enum xpc_retval {
161 xpcSuccess = 0,
162
163 xpcNotConnected, /* 1: channel is not connected */
164 xpcConnected, /* 2: channel connected (opened) */
165 xpcRETIRED1, /* 3: (formerly xpcDisconnected) */
166
167 xpcMsgReceived, /* 4: message received */
168 xpcMsgDelivered, /* 5: message delivered and acknowledged */
169
170 xpcRETIRED2, /* 6: (formerly xpcTransferFailed) */
171
172 xpcNoWait, /* 7: operation would require wait */
173 xpcRetry, /* 8: retry operation */
174 xpcTimeout, /* 9: timeout in xpc_allocate_msg_wait() */
175 xpcInterrupted, /* 10: interrupted wait */
176
177 xpcUnequalMsgSizes, /* 11: message size disparity between sides */
178 xpcInvalidAddress, /* 12: invalid address */
179
180 xpcNoMemory, /* 13: no memory available for XPC structures */
181 xpcLackOfResources, /* 14: insufficient resources for operation */
182 xpcUnregistered, /* 15: channel is not registered */
183 xpcAlreadyRegistered, /* 16: channel is already registered */
184
185 xpcPartitionDown, /* 17: remote partition is down */
186 xpcNotLoaded, /* 18: XPC module is not loaded */
187 xpcUnloading, /* 19: this side is unloading XPC module */
188
189 xpcBadMagic, /* 20: XPC MAGIC string not found */
190
191 xpcReactivating, /* 21: remote partition was reactivated */
192
193 xpcUnregistering, /* 22: this side is unregistering channel */
194 xpcOtherUnregistering, /* 23: other side is unregistering channel */
195
196 xpcCloneKThread, /* 24: cloning kernel thread */
197 xpcCloneKThreadFailed, /* 25: cloning kernel thread failed */
198
199 xpcNoHeartbeat, /* 26: remote partition has no heartbeat */
200
201 xpcPioReadError, /* 27: PIO read error */
202 xpcPhysAddrRegFailed, /* 28: registration of phys addr range failed */
203
204 xpcBteDirectoryError, /* 29: maps to BTEFAIL_DIR */
205 xpcBtePoisonError, /* 30: maps to BTEFAIL_POISON */
206 xpcBteWriteError, /* 31: maps to BTEFAIL_WERR */
207 xpcBteAccessError, /* 32: maps to BTEFAIL_ACCESS */
208 xpcBtePWriteError, /* 33: maps to BTEFAIL_PWERR */
209 xpcBtePReadError, /* 34: maps to BTEFAIL_PRERR */
210 xpcBteTimeOutError, /* 35: maps to BTEFAIL_TOUT */
211 xpcBteXtalkError, /* 36: maps to BTEFAIL_XTERR */
212 xpcBteNotAvailable, /* 37: maps to BTEFAIL_NOTAVAIL */
213 xpcBteUnmappedError, /* 38: unmapped BTEFAIL_ error */
214
215 xpcBadVersion, /* 39: bad version number */
216 xpcVarsNotSet, /* 40: the XPC variables are not set up */
217 xpcNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */
218 xpcInvalidPartid, /* 42: invalid partition ID */
219 xpcLocalPartid, /* 43: local partition ID */
220
221 xpcUnknownReason /* 44: unknown reason -- must be last in list */
222};
223
224
225/*
226 * Define the callout function types used by XPC to update the user on
227 * connection activity and state changes (via the user function registered by
228 * xpc_connect()) and to notify them of messages received and delivered (via
229 * the user function registered by xpc_send_notify()).
230 *
231 * The two function types are xpc_channel_func and xpc_notify_func and
232 * both share the following arguments, with the exception of "data", which
233 * only xpc_channel_func has.
234 *
235 * Arguments:
236 *
237 * reason - reason code. (See following table.)
238 * partid - partition ID associated with condition.
239 * ch_number - channel # associated with condition.
240 * data - pointer to optional data. (See following table.)
241 * key - pointer to optional user-defined value provided as the "key"
242 * argument to xpc_connect() or xpc_send_notify().
243 *
244 * In the following table the "Optional Data" column applies to callouts made
245 * to functions registered by xpc_connect(). A "NA" in that column indicates
246 * that this reason code can be passed to functions registered by
247 * xpc_send_notify() (i.e. they don't have data arguments).
248 *
249 * Also, the first three reason codes in the following table indicate
250 * success, whereas the others indicate failure. When a failure reason code
251 * is received, one can assume that the channel is not connected.
252 *
253 *
254 * Reason Code | Cause | Optional Data
255 * =====================+================================+=====================
256 * xpcConnected | connection has been established| max #of entries
257 * | to the specified partition on | allowed in message
258 * | the specified channel | queue
259 * ---------------------+--------------------------------+---------------------
260 * xpcMsgReceived | an XPC message arrived from | address of payload
261 * | the specified partition on the |
262 * | specified channel | [the user must call
263 * | | xpc_received() when
264 * | | finished with the
265 * | | payload]
266 * ---------------------+--------------------------------+---------------------
267 * xpcMsgDelivered | notification that the message | NA
268 * | was delivered to the intended |
269 * | recipient and that they have |
270 * | acknowledged its receipt by |
271 * | calling xpc_received() |
272 * =====================+================================+=====================
273 * xpcUnequalMsgSizes | can't connect to the specified | NULL
274 * | partition on the specified |
275 * | channel because of mismatched |
276 * | message sizes |
277 * ---------------------+--------------------------------+---------------------
278 * xpcNoMemory | insufficient memory avaiable | NULL
279 * | to allocate message queue |
280 * ---------------------+--------------------------------+---------------------
281 * xpcLackOfResources | lack of resources to create | NULL
282 * | the necessary kthreads to |
283 * | support the channel |
284 * ---------------------+--------------------------------+---------------------
285 * xpcUnregistering | this side's user has | NULL or NA
286 * | unregistered by calling |
287 * | xpc_disconnect() |
288 * ---------------------+--------------------------------+---------------------
289 * xpcOtherUnregistering| the other side's user has | NULL or NA
290 * | unregistered by calling |
291 * | xpc_disconnect() |
292 * ---------------------+--------------------------------+---------------------
293 * xpcNoHeartbeat | the other side's XPC is no | NULL or NA
294 * | longer heartbeating |
295 * | |
296 * ---------------------+--------------------------------+---------------------
297 * xpcUnloading | this side's XPC module is | NULL or NA
298 * | being unloaded |
299 * | |
300 * ---------------------+--------------------------------+---------------------
301 * xpcOtherUnloading | the other side's XPC module is | NULL or NA
302 * | is being unloaded |
303 * | |
304 * ---------------------+--------------------------------+---------------------
305 * xpcPioReadError | xp_nofault_PIOR() returned an | NULL or NA
306 * | error while sending an IPI |
307 * | |
308 * ---------------------+--------------------------------+---------------------
309 * xpcInvalidAddress | the address either received or | NULL or NA
310 * | sent by the specified partition|
311 * | is invalid |
312 * ---------------------+--------------------------------+---------------------
313 * xpcBteNotAvailable | attempt to pull data from the | NULL or NA
314 * xpcBtePoisonError | specified partition over the |
315 * xpcBteWriteError | specified channel via a |
316 * xpcBteAccessError | bte_copy() failed |
317 * xpcBteTimeOutError | |
318 * xpcBteXtalkError | |
319 * xpcBteDirectoryError | |
320 * xpcBteGenericError | |
321 * xpcBteUnmappedError | |
322 * ---------------------+--------------------------------+---------------------
323 * xpcUnknownReason | the specified channel to the | NULL or NA
324 * | specified partition was |
325 * | unavailable for unknown reasons|
326 * =====================+================================+=====================
327 */
328
329typedef void (*xpc_channel_func)(enum xpc_retval reason, partid_t partid,
330 int ch_number, void *data, void *key);
331
332typedef void (*xpc_notify_func)(enum xpc_retval reason, partid_t partid,
333 int ch_number, void *key);
334
335
336/*
337 * The following is a registration entry. There is a global array of these,
338 * one per channel. It is used to record the connection registration made
339 * by the users of XPC. As long as a registration entry exists, for any
340 * partition that comes up, XPC will attempt to establish a connection on
341 * that channel. Notification that a connection has been made will occur via
342 * the xpc_channel_func function.
343 *
344 * The 'func' field points to the function to call when aynchronous
345 * notification is required for such events as: a connection established/lost,
346 * or an incomming message received, or an error condition encountered. A
347 * non-NULL 'func' field indicates that there is an active registration for
348 * the channel.
349 */
350struct xpc_registration {
351 struct semaphore sema;
352 xpc_channel_func func; /* function to call */
353 void *key; /* pointer to user's key */
354 u16 nentries; /* #of msg entries in local msg queue */
355 u16 msg_size; /* message queue's message size */
356 u32 assigned_limit; /* limit on #of assigned kthreads */
357 u32 idle_limit; /* limit on #of idle kthreads */
358} ____cacheline_aligned;
359
360
361#define XPC_CHANNEL_REGISTERED(_c) (xpc_registrations[_c].func != NULL)
362
363
364/* the following are valid xpc_allocate() flags */
365#define XPC_WAIT 0 /* wait flag */
366#define XPC_NOWAIT 1 /* no wait flag */
367
368
369struct xpc_interface {
370 void (*connect)(int);
371 void (*disconnect)(int);
372 enum xpc_retval (*allocate)(partid_t, int, u32, void **);
373 enum xpc_retval (*send)(partid_t, int, void *);
374 enum xpc_retval (*send_notify)(partid_t, int, void *,
375 xpc_notify_func, void *);
376 void (*received)(partid_t, int, void *);
377 enum xpc_retval (*partid_to_nasids)(partid_t, void *);
378};
379
380
381extern struct xpc_interface xpc_interface;
382
383extern void xpc_set_interface(void (*)(int),
384 void (*)(int),
385 enum xpc_retval (*)(partid_t, int, u32, void **),
386 enum xpc_retval (*)(partid_t, int, void *),
387 enum xpc_retval (*)(partid_t, int, void *, xpc_notify_func,
388 void *),
389 void (*)(partid_t, int, void *),
390 enum xpc_retval (*)(partid_t, void *));
391extern void xpc_clear_interface(void);
392
393
394extern enum xpc_retval xpc_connect(int, xpc_channel_func, void *, u16,
395 u16, u32, u32);
396extern void xpc_disconnect(int);
397
398static inline enum xpc_retval
399xpc_allocate(partid_t partid, int ch_number, u32 flags, void **payload)
400{
401 return xpc_interface.allocate(partid, ch_number, flags, payload);
402}
403
404static inline enum xpc_retval
405xpc_send(partid_t partid, int ch_number, void *payload)
406{
407 return xpc_interface.send(partid, ch_number, payload);
408}
409
410static inline enum xpc_retval
411xpc_send_notify(partid_t partid, int ch_number, void *payload,
412 xpc_notify_func func, void *key)
413{
414 return xpc_interface.send_notify(partid, ch_number, payload, func, key);
415}
416
417static inline void
418xpc_received(partid_t partid, int ch_number, void *payload)
419{
420 return xpc_interface.received(partid, ch_number, payload);
421}
422
423static inline enum xpc_retval
424xpc_partid_to_nasids(partid_t partid, void *nasids)
425{
426 return xpc_interface.partid_to_nasids(partid, nasids);
427}
428
429
430extern u64 xp_nofault_PIOR_target;
431extern int xp_nofault_PIOR(void *);
432extern int xp_error_PIOR(void);
433
434
435#endif /* _ASM_IA64_SN_XP_H */
436
diff --git a/include/asm-m32r/signal.h b/include/asm-m32r/signal.h
index ce46eaea4494..95f69b191953 100644
--- a/include/asm-m32r/signal.h
+++ b/include/asm-m32r/signal.h
@@ -114,34 +114,7 @@ typedef unsigned long sigset_t;
114#define MINSIGSTKSZ 2048 114#define MINSIGSTKSZ 2048
115#define SIGSTKSZ 8192 115#define SIGSTKSZ 8192
116 116
117#ifdef __KERNEL__ 117#include <asm-generic/signal.h>
118
119/*
120 * These values of sa_flags are used only by the kernel as part of the
121 * irq handling routines.
122 *
123 * SA_INTERRUPT is also used by the irq handling routines.
124 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
125 */
126#define SA_PROBE SA_ONESHOT
127#define SA_SAMPLE_RANDOM SA_RESTART
128#define SA_SHIRQ 0x04000000
129#endif
130
131#define SIG_BLOCK 0 /* for blocking signals */
132#define SIG_UNBLOCK 1 /* for unblocking signals */
133#define SIG_SETMASK 2 /* for setting the signal mask */
134
135/* Type of a signal handler. */
136typedef void __signalfn_t(int);
137typedef __signalfn_t __user *__sighandler_t;
138
139typedef void __restorefn_t(void);
140typedef __restorefn_t __user *__sigrestore_t;
141
142#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
143#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
144#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
145 118
146#ifdef __KERNEL__ 119#ifdef __KERNEL__
147struct old_sigaction { 120struct old_sigaction {
diff --git a/include/asm-m68k/bug.h b/include/asm-m68k/bug.h
index 3e1d2266fa69..072ce274d537 100644
--- a/include/asm-m68k/bug.h
+++ b/include/asm-m68k/bug.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_BUG
6#ifdef CONFIG_DEBUG_BUGVERBOSE 7#ifdef CONFIG_DEBUG_BUGVERBOSE
7#ifndef CONFIG_SUN3 8#ifndef CONFIG_SUN3
8#define BUG() do { \ 9#define BUG() do { \
@@ -22,6 +23,8 @@
22#endif 23#endif
23 24
24#define HAVE_ARCH_BUG 25#define HAVE_ARCH_BUG
26#endif
27
25#include <asm-generic/bug.h> 28#include <asm-generic/bug.h>
26 29
27#endif 30#endif
diff --git a/include/asm-m68k/signal.h b/include/asm-m68k/signal.h
index 6681bb6a5523..a0cdf9082372 100644
--- a/include/asm-m68k/signal.h
+++ b/include/asm-m68k/signal.h
@@ -105,42 +105,20 @@ typedef unsigned long sigset_t;
105#define MINSIGSTKSZ 2048 105#define MINSIGSTKSZ 2048
106#define SIGSTKSZ 8192 106#define SIGSTKSZ 8192
107 107
108#ifdef __KERNEL__ 108#include <asm-generic/signal.h>
109/*
110 * These values of sa_flags are used only by the kernel as part of the
111 * irq handling routines.
112 *
113 * SA_INTERRUPT is also used by the irq handling routines.
114 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
115 */
116#define SA_PROBE SA_ONESHOT
117#define SA_SAMPLE_RANDOM SA_RESTART
118#define SA_SHIRQ 0x04000000
119#endif
120
121#define SIG_BLOCK 0 /* for blocking signals */
122#define SIG_UNBLOCK 1 /* for unblocking signals */
123#define SIG_SETMASK 2 /* for setting the signal mask */
124
125/* Type of a signal handler. */
126typedef void (*__sighandler_t)(int);
127
128#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
129#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
130#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
131 109
132#ifdef __KERNEL__ 110#ifdef __KERNEL__
133struct old_sigaction { 111struct old_sigaction {
134 __sighandler_t sa_handler; 112 __sighandler_t sa_handler;
135 old_sigset_t sa_mask; 113 old_sigset_t sa_mask;
136 unsigned long sa_flags; 114 unsigned long sa_flags;
137 void (*sa_restorer)(void); 115 __sigrestore_t sa_restorer;
138}; 116};
139 117
140struct sigaction { 118struct sigaction {
141 __sighandler_t sa_handler; 119 __sighandler_t sa_handler;
142 unsigned long sa_flags; 120 unsigned long sa_flags;
143 void (*sa_restorer)(void); 121 __sigrestore_t sa_restorer;
144 sigset_t sa_mask; /* mask last for extensibility */ 122 sigset_t sa_mask; /* mask last for extensibility */
145}; 123};
146 124
diff --git a/include/asm-m68knommu/MC68328.h b/include/asm-m68knommu/MC68328.h
index 4f5a9845f5be..a337e56d09bf 100644
--- a/include/asm-m68knommu/MC68328.h
+++ b/include/asm-m68knommu/MC68328.h
@@ -993,7 +993,7 @@ typedef volatile struct {
993 volatile unsigned short int pad1; 993 volatile unsigned short int pad1;
994 volatile unsigned short int pad2; 994 volatile unsigned short int pad2;
995 volatile unsigned short int pad3; 995 volatile unsigned short int pad3;
996} m68328_uart __attribute__((packed)); 996} __attribute__((packed)) m68328_uart;
997 997
998 998
999/********** 999/**********
diff --git a/include/asm-m68knommu/MC68EZ328.h b/include/asm-m68knommu/MC68EZ328.h
index 801933da4c70..69b7f9139e5e 100644
--- a/include/asm-m68knommu/MC68EZ328.h
+++ b/include/asm-m68knommu/MC68EZ328.h
@@ -815,7 +815,7 @@ typedef volatile struct {
815 volatile unsigned short int nipr; 815 volatile unsigned short int nipr;
816 volatile unsigned short int pad1; 816 volatile unsigned short int pad1;
817 volatile unsigned short int pad2; 817 volatile unsigned short int pad2;
818} m68328_uart __attribute__((packed)); 818} __attribute__((packed)) m68328_uart;
819 819
820 820
821/********** 821/**********
diff --git a/include/asm-m68knommu/MC68VZ328.h b/include/asm-m68knommu/MC68VZ328.h
index df74322f37ed..2b9bf626a0a5 100644
--- a/include/asm-m68knommu/MC68VZ328.h
+++ b/include/asm-m68knommu/MC68VZ328.h
@@ -909,7 +909,7 @@ typedef struct {
909 volatile unsigned short int nipr; 909 volatile unsigned short int nipr;
910 volatile unsigned short int hmark; 910 volatile unsigned short int hmark;
911 volatile unsigned short int unused; 911 volatile unsigned short int unused;
912} m68328_uart __attribute__((packed)); 912} __attribute__((packed)) m68328_uart;
913 913
914 914
915 915
diff --git a/include/asm-m68knommu/signal.h b/include/asm-m68knommu/signal.h
index 486cbb0dc088..1d13187f6062 100644
--- a/include/asm-m68knommu/signal.h
+++ b/include/asm-m68knommu/signal.h
@@ -105,29 +105,7 @@ typedef unsigned long sigset_t;
105#define MINSIGSTKSZ 2048 105#define MINSIGSTKSZ 2048
106#define SIGSTKSZ 8192 106#define SIGSTKSZ 8192
107 107
108#ifdef __KERNEL__ 108#include <asm-generic/signal.h>
109/*
110 * These values of sa_flags are used only by the kernel as part of the
111 * irq handling routines.
112 *
113 * SA_INTERRUPT is also used by the irq handling routines.
114 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
115 */
116#define SA_PROBE SA_ONESHOT
117#define SA_SAMPLE_RANDOM SA_RESTART
118#define SA_SHIRQ 0x04000000
119#endif
120
121#define SIG_BLOCK 0 /* for blocking signals */
122#define SIG_UNBLOCK 1 /* for unblocking signals */
123#define SIG_SETMASK 2 /* for setting the signal mask */
124
125/* Type of a signal handler. */
126typedef void (*__sighandler_t)(int);
127
128#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
129#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
130#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
131 109
132#ifdef __KERNEL__ 110#ifdef __KERNEL__
133struct old_sigaction { 111struct old_sigaction {
diff --git a/include/asm-mips/bug.h b/include/asm-mips/bug.h
index eb94bb96cfbc..3f594b440abc 100644
--- a/include/asm-mips/bug.h
+++ b/include/asm-mips/bug.h
@@ -3,12 +3,14 @@
3 3
4#include <asm/break.h> 4#include <asm/break.h>
5 5
6#ifdef CONFIG_BUG
7#define HAVE_ARCH_BUG
6#define BUG() \ 8#define BUG() \
7do { \ 9do { \
8 __asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \ 10 __asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \
9} while (0) 11} while (0)
12#endif
10 13
11#define HAVE_ARCH_BUG
12#include <asm-generic/bug.h> 14#include <asm-generic/bug.h>
13 15
14#endif 16#endif
diff --git a/include/asm-mips/errno.h b/include/asm-mips/errno.h
index 2b458f9538cd..3c0d840e4577 100644
--- a/include/asm-mips/errno.h
+++ b/include/asm-mips/errno.h
@@ -115,6 +115,10 @@
115#define EKEYREVOKED 163 /* Key has been revoked */ 115#define EKEYREVOKED 163 /* Key has been revoked */
116#define EKEYREJECTED 164 /* Key was rejected by service */ 116#define EKEYREJECTED 164 /* Key was rejected by service */
117 117
118/* for robust mutexes */
119#define EOWNERDEAD 165 /* Owner died */
120#define ENOTRECOVERABLE 166 /* State not recoverable */
121
118#define EDQUOT 1133 /* Quota exceeded */ 122#define EDQUOT 1133 /* Quota exceeded */
119 123
120#ifdef __KERNEL__ 124#ifdef __KERNEL__
diff --git a/include/asm-mips/siginfo.h b/include/asm-mips/siginfo.h
index 8ddd3c99bcf7..a0e26e6c994d 100644
--- a/include/asm-mips/siginfo.h
+++ b/include/asm-mips/siginfo.h
@@ -11,8 +11,6 @@
11 11
12#include <linux/config.h> 12#include <linux/config.h>
13 13
14#define SIGEV_HEAD_SIZE (sizeof(long) + 2*sizeof(int))
15#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE-SIGEV_HEAD_SIZE) / sizeof(int))
16#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */ 14#undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */
17 15
18#define HAVE_ARCH_SIGINFO_T 16#define HAVE_ARCH_SIGINFO_T
diff --git a/include/asm-mips/signal.h b/include/asm-mips/signal.h
index 994987db61be..f2c470f1d369 100644
--- a/include/asm-mips/signal.h
+++ b/include/asm-mips/signal.h
@@ -98,34 +98,12 @@ typedef unsigned long old_sigset_t; /* at least 32 bits */
98#define MINSIGSTKSZ 2048 98#define MINSIGSTKSZ 2048
99#define SIGSTKSZ 8192 99#define SIGSTKSZ 8192
100 100
101#ifdef __KERNEL__
102
103/*
104 * These values of sa_flags are used only by the kernel as part of the
105 * irq handling routines.
106 *
107 * SA_INTERRUPT is also used by the irq handling routines.
108 * SA_SHIRQ flag is for shared interrupt support on PCI and EISA.
109 */
110#define SA_PROBE SA_ONESHOT
111#define SA_SAMPLE_RANDOM SA_RESTART
112#define SA_SHIRQ 0x02000000
113
114#endif /* __KERNEL__ */
115
116#define SIG_BLOCK 1 /* for blocking signals */ 101#define SIG_BLOCK 1 /* for blocking signals */
117#define SIG_UNBLOCK 2 /* for unblocking signals */ 102#define SIG_UNBLOCK 2 /* for unblocking signals */
118#define SIG_SETMASK 3 /* for setting the signal mask */ 103#define SIG_SETMASK 3 /* for setting the signal mask */
119#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility: 104#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
120 set only the low 32 bit of the sigset. */ 105 set only the low 32 bit of the sigset. */
121 106#include <asm-generic/signal.h>
122/* Type of a signal handler. */
123typedef void (*__sighandler_t)(int);
124
125/* Fake signal functions */
126#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
127#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
128#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
129 107
130struct sigaction { 108struct sigaction {
131 unsigned int sa_flags; 109 unsigned int sa_flags;
diff --git a/include/asm-parisc/bug.h b/include/asm-parisc/bug.h
index e72f6e2b4b9f..695588da41f8 100644
--- a/include/asm-parisc/bug.h
+++ b/include/asm-parisc/bug.h
@@ -1,12 +1,14 @@
1#ifndef _PARISC_BUG_H 1#ifndef _PARISC_BUG_H
2#define _PARISC_BUG_H 2#define _PARISC_BUG_H
3 3
4#ifdef CONFIG_BUG
4#define HAVE_ARCH_BUG 5#define HAVE_ARCH_BUG
5#define BUG() do { \ 6#define BUG() do { \
6 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 7 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
7 dump_stack(); \ 8 dump_stack(); \
8 panic("BUG!"); \ 9 panic("BUG!"); \
9} while (0) 10} while (0)
11#endif
10 12
11#include <asm-generic/bug.h> 13#include <asm-generic/bug.h>
12#endif 14#endif
diff --git a/include/asm-parisc/errno.h b/include/asm-parisc/errno.h
index a10f109770f1..08464c405471 100644
--- a/include/asm-parisc/errno.h
+++ b/include/asm-parisc/errno.h
@@ -115,5 +115,9 @@
115#define ENOTSUP 252 /* Function not implemented (POSIX.4 / HPUX) */ 115#define ENOTSUP 252 /* Function not implemented (POSIX.4 / HPUX) */
116#define ECANCELLED 253 /* aio request was canceled before complete (POSIX.4 / HPUX) */ 116#define ECANCELLED 253 /* aio request was canceled before complete (POSIX.4 / HPUX) */
117 117
118/* for robust mutexes */
119#define EOWNERDEAD 254 /* Owner died */
120#define ENOTRECOVERABLE 255 /* State not recoverable */
121
118 122
119#endif 123#endif
diff --git a/include/asm-parisc/floppy.h b/include/asm-parisc/floppy.h
index 47f53df2cef5..ca3aed768cdc 100644
--- a/include/asm-parisc/floppy.h
+++ b/include/asm-parisc/floppy.h
@@ -235,7 +235,7 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
235 return 0; 235 return 0;
236} 236}
237 237
238struct fd_routine_l { 238static struct fd_routine_l {
239 int (*_request_dma)(unsigned int dmanr, const char * device_id); 239 int (*_request_dma)(unsigned int dmanr, const char * device_id);
240 void (*_free_dma)(unsigned int dmanr); 240 void (*_free_dma)(unsigned int dmanr);
241 int (*_get_dma_residue)(unsigned int dummy); 241 int (*_get_dma_residue)(unsigned int dummy);
diff --git a/include/asm-parisc/signal.h b/include/asm-parisc/signal.h
index 358f577c8eb8..25cb23ef7dd1 100644
--- a/include/asm-parisc/signal.h
+++ b/include/asm-parisc/signal.h
@@ -89,17 +89,6 @@
89#define _NSIG_BPW BITS_PER_LONG 89#define _NSIG_BPW BITS_PER_LONG
90#define _NSIG_WORDS (_NSIG / _NSIG_BPW) 90#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
91 91
92/*
93 * These values of sa_flags are used only by the kernel as part of the
94 * irq handling routines.
95 *
96 * SA_INTERRUPT is also used by the irq handling routines.
97 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
98 */
99#define SA_PROBE SA_ONESHOT
100#define SA_SAMPLE_RANDOM SA_RESTART
101#define SA_SHIRQ 0x04000000
102
103#endif /* __KERNEL__ */ 92#endif /* __KERNEL__ */
104 93
105#define SIG_BLOCK 0 /* for blocking signals */ 94#define SIG_BLOCK 0 /* for blocking signals */
diff --git a/include/asm-parisc/uaccess.h b/include/asm-parisc/uaccess.h
index 8a08423b7570..c1b5bdea53ee 100644
--- a/include/asm-parisc/uaccess.h
+++ b/include/asm-parisc/uaccess.h
@@ -24,7 +24,7 @@
24 24
25/* 25/*
26 * Note that since kernel addresses are in a separate address space on 26 * Note that since kernel addresses are in a separate address space on
27 * parisc, we don't need to do anything for access_ok() or verify_area(). 27 * parisc, we don't need to do anything for access_ok().
28 * We just let the page fault handler do the right thing. This also means 28 * We just let the page fault handler do the right thing. This also means
29 * that put_user is the same as __put_user, etc. 29 * that put_user is the same as __put_user, etc.
30 */ 30 */
diff --git a/include/asm-ppc/bug.h b/include/asm-ppc/bug.h
index e99c6cb9d618..8b34fd682b0d 100644
--- a/include/asm-ppc/bug.h
+++ b/include/asm-ppc/bug.h
@@ -14,6 +14,7 @@ struct bug_entry {
14 */ 14 */
15#define BUG_WARNING_TRAP 0x1000000 15#define BUG_WARNING_TRAP 0x1000000
16 16
17#ifdef CONFIG_BUG
17#define BUG() do { \ 18#define BUG() do { \
18 __asm__ __volatile__( \ 19 __asm__ __volatile__( \
19 "1: twi 31,0,0\n" \ 20 "1: twi 31,0,0\n" \
@@ -50,6 +51,8 @@ struct bug_entry {
50#define HAVE_ARCH_BUG 51#define HAVE_ARCH_BUG
51#define HAVE_ARCH_BUG_ON 52#define HAVE_ARCH_BUG_ON
52#define HAVE_ARCH_WARN_ON 53#define HAVE_ARCH_WARN_ON
54#endif
55
53#include <asm-generic/bug.h> 56#include <asm-generic/bug.h>
54 57
55#endif 58#endif
diff --git a/include/asm-ppc/hydra.h b/include/asm-ppc/hydra.h
index 1134431431da..833a8aff2a80 100644
--- a/include/asm-ppc/hydra.h
+++ b/include/asm-ppc/hydra.h
@@ -51,7 +51,7 @@ struct Hydra {
51 char OpenPIC[0x40000]; 51 char OpenPIC[0x40000];
52}; 52};
53 53
54extern volatile struct Hydra *Hydra; 54extern volatile struct Hydra __iomem *Hydra;
55 55
56 56
57 /* 57 /*
diff --git a/include/asm-ppc/pci-bridge.h b/include/asm-ppc/pci-bridge.h
index 78e9be619f14..ffa423456c2b 100644
--- a/include/asm-ppc/pci-bridge.h
+++ b/include/asm-ppc/pci-bridge.h
@@ -12,7 +12,7 @@ struct pci_controller;
12 * pci_io_base returns the memory address at which you can access 12 * pci_io_base returns the memory address at which you can access
13 * the I/O space for PCI bus number `bus' (or NULL on error). 13 * the I/O space for PCI bus number `bus' (or NULL on error).
14 */ 14 */
15extern void *pci_bus_io_base(unsigned int bus); 15extern void __iomem *pci_bus_io_base(unsigned int bus);
16extern unsigned long pci_bus_io_base_phys(unsigned int bus); 16extern unsigned long pci_bus_io_base_phys(unsigned int bus);
17extern unsigned long pci_bus_mem_base_phys(unsigned int bus); 17extern unsigned long pci_bus_mem_base_phys(unsigned int bus);
18 18
@@ -48,7 +48,7 @@ struct pci_controller {
48 int last_busno; 48 int last_busno;
49 int bus_offset; 49 int bus_offset;
50 50
51 void *io_base_virt; 51 void __iomem *io_base_virt;
52 unsigned long io_base_phys; 52 unsigned long io_base_phys;
53 53
54 /* Some machines (PReP) have a non 1:1 mapping of 54 /* Some machines (PReP) have a non 1:1 mapping of
diff --git a/include/asm-ppc/pmac_feature.h b/include/asm-ppc/pmac_feature.h
index 639b690ce6f7..8beb162873f4 100644
--- a/include/asm-ppc/pmac_feature.h
+++ b/include/asm-ppc/pmac_feature.h
@@ -316,6 +316,9 @@ extern void pmac_register_agp_pm(struct pci_dev *bridge,
316extern void pmac_suspend_agp_for_card(struct pci_dev *dev); 316extern void pmac_suspend_agp_for_card(struct pci_dev *dev);
317extern void pmac_resume_agp_for_card(struct pci_dev *dev); 317extern void pmac_resume_agp_for_card(struct pci_dev *dev);
318 318
319/* Used by the via-pmu driver for suspend/resume
320 */
321extern void pmac_tweak_clock_spreading(int enable);
319 322
320/* 323/*
321 * The part below is for use by macio_asic.c only, do not rely 324 * The part below is for use by macio_asic.c only, do not rely
diff --git a/include/asm-ppc/reg_booke.h b/include/asm-ppc/reg_booke.h
index e70c25f3c339..45c5e6f2b7ab 100644
--- a/include/asm-ppc/reg_booke.h
+++ b/include/asm-ppc/reg_booke.h
@@ -305,6 +305,7 @@ do { \
305#define ESR_PIL 0x08000000 /* Program Exception - Illegal */ 305#define ESR_PIL 0x08000000 /* Program Exception - Illegal */
306#define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ 306#define ESR_PPR 0x04000000 /* Program Exception - Priveleged */
307#define ESR_PTR 0x02000000 /* Program Exception - Trap */ 307#define ESR_PTR 0x02000000 /* Program Exception - Trap */
308#define ESR_FP 0x01000000 /* Floating Point Operation */
308#define ESR_DST 0x00800000 /* Storage Exception - Data miss */ 309#define ESR_DST 0x00800000 /* Storage Exception - Data miss */
309#define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */ 310#define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */
310#define ESR_ST 0x00800000 /* Store Operation */ 311#define ESR_ST 0x00800000 /* Store Operation */
diff --git a/include/asm-ppc/sigcontext.h b/include/asm-ppc/sigcontext.h
index fc5e358c65f1..f82dcccdee1e 100644
--- a/include/asm-ppc/sigcontext.h
+++ b/include/asm-ppc/sigcontext.h
@@ -9,7 +9,7 @@ struct sigcontext {
9 int signal; 9 int signal;
10 unsigned long handler; 10 unsigned long handler;
11 unsigned long oldmask; 11 unsigned long oldmask;
12 struct pt_regs *regs; 12 struct pt_regs __user *regs;
13}; 13};
14 14
15#endif 15#endif
diff --git a/include/asm-ppc/signal.h b/include/asm-ppc/signal.h
index 8cc8b88d4edd..caf6ede3710f 100644
--- a/include/asm-ppc/signal.h
+++ b/include/asm-ppc/signal.h
@@ -99,34 +99,8 @@ typedef struct {
99 99
100#define MINSIGSTKSZ 2048 100#define MINSIGSTKSZ 2048
101#define SIGSTKSZ 8192 101#define SIGSTKSZ 8192
102#ifdef __KERNEL__
103
104/*
105 * These values of sa_flags are used only by the kernel as part of the
106 * irq handling routines.
107 *
108 * SA_INTERRUPT is also used by the irq handling routines.
109 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
110 */
111#define SA_PROBE SA_ONESHOT
112#define SA_SAMPLE_RANDOM SA_RESTART
113#define SA_SHIRQ 0x04000000
114#endif /* __KERNEL__ */
115
116#define SIG_BLOCK 0 /* for blocking signals */
117#define SIG_UNBLOCK 1 /* for unblocking signals */
118#define SIG_SETMASK 2 /* for setting the signal mask */
119
120/* Type of a signal handler. */
121typedef void __signalfn_t(int);
122typedef __signalfn_t __user *__sighandler_t;
123
124typedef void __restorefn_t(void);
125typedef __restorefn_t __user *__sigrestore_t;
126 102
127#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ 103#include <asm-generic/signal.h>
128#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
129#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
130 104
131struct old_sigaction { 105struct old_sigaction {
132 __sighandler_t sa_handler; 106 __sighandler_t sa_handler;
diff --git a/include/asm-ppc64/a.out.h b/include/asm-ppc64/a.out.h
index 802338efcb19..3871e252a6f1 100644
--- a/include/asm-ppc64/a.out.h
+++ b/include/asm-ppc64/a.out.h
@@ -1,8 +1,6 @@
1#ifndef __PPC64_A_OUT_H__ 1#ifndef __PPC64_A_OUT_H__
2#define __PPC64_A_OUT_H__ 2#define __PPC64_A_OUT_H__
3 3
4#include <asm/ppcdebug.h>
5
6/* 4/*
7 * c 2001 PPC 64 Team, IBM Corp 5 * c 2001 PPC 64 Team, IBM Corp
8 * 6 *
diff --git a/include/asm-ppc64/bug.h b/include/asm-ppc64/bug.h
index db31dd22233c..169868fa307d 100644
--- a/include/asm-ppc64/bug.h
+++ b/include/asm-ppc64/bug.h
@@ -26,6 +26,8 @@ struct bug_entry *find_bug(unsigned long bugaddr);
26 */ 26 */
27#define BUG_WARNING_TRAP 0x1000000 27#define BUG_WARNING_TRAP 0x1000000
28 28
29#ifdef CONFIG_BUG
30
29#define BUG() do { \ 31#define BUG() do { \
30 __asm__ __volatile__( \ 32 __asm__ __volatile__( \
31 "1: twi 31,0,0\n" \ 33 "1: twi 31,0,0\n" \
@@ -55,11 +57,12 @@ struct bug_entry *find_bug(unsigned long bugaddr);
55 "i" (__FILE__), "i" (__FUNCTION__)); \ 57 "i" (__FILE__), "i" (__FUNCTION__)); \
56} while (0) 58} while (0)
57 59
58#endif
59
60#define HAVE_ARCH_BUG 60#define HAVE_ARCH_BUG
61#define HAVE_ARCH_BUG_ON 61#define HAVE_ARCH_BUG_ON
62#define HAVE_ARCH_WARN_ON 62#define HAVE_ARCH_WARN_ON
63#endif
64#endif
65
63#include <asm-generic/bug.h> 66#include <asm-generic/bug.h>
64 67
65#endif 68#endif
diff --git a/include/asm-ppc64/elf.h b/include/asm-ppc64/elf.h
index 8457d90244fb..6c42d61bedd1 100644
--- a/include/asm-ppc64/elf.h
+++ b/include/asm-ppc64/elf.h
@@ -229,9 +229,13 @@ do { \
229 229
230/* 230/*
231 * An executable for which elf_read_implies_exec() returns TRUE will 231 * An executable for which elf_read_implies_exec() returns TRUE will
232 * have the READ_IMPLIES_EXEC personality flag set automatically. 232 * have the READ_IMPLIES_EXEC personality flag set automatically. This
233 * is only required to work around bugs in old 32bit toolchains. Since
234 * the 64bit ABI has never had these issues dont enable the workaround
235 * even if we have an executable stack.
233 */ 236 */
234#define elf_read_implies_exec(ex, exec_stk) (exec_stk != EXSTACK_DISABLE_X) 237#define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \
238 (exec_stk != EXSTACK_DISABLE_X) : 0)
235 239
236#endif 240#endif
237 241
diff --git a/include/asm-ppc64/imalloc.h b/include/asm-ppc64/imalloc.h
new file mode 100644
index 000000000000..3a45e918bf16
--- /dev/null
+++ b/include/asm-ppc64/imalloc.h
@@ -0,0 +1,24 @@
1#ifndef _PPC64_IMALLOC_H
2#define _PPC64_IMALLOC_H
3
4/*
5 * Define the address range of the imalloc VM area.
6 */
7#define PHBS_IO_BASE IOREGIONBASE
8#define IMALLOC_BASE (IOREGIONBASE + 0x80000000ul) /* Reserve 2 gigs for PHBs */
9#define IMALLOC_END (IOREGIONBASE + EADDR_MASK)
10
11
12/* imalloc region types */
13#define IM_REGION_UNUSED 0x1
14#define IM_REGION_SUBSET 0x2
15#define IM_REGION_EXISTS 0x4
16#define IM_REGION_OVERLAP 0x8
17#define IM_REGION_SUPERSET 0x10
18
19extern struct vm_struct * im_get_free_area(unsigned long size);
20extern struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
21 int region_type);
22unsigned long im_free(void *addr);
23
24#endif /* _PPC64_IMALLOC_H */
diff --git a/include/asm-ppc64/mmu.h b/include/asm-ppc64/mmu.h
index 188987e9d9d4..c78282a67d8e 100644
--- a/include/asm-ppc64/mmu.h
+++ b/include/asm-ppc64/mmu.h
@@ -15,19 +15,10 @@
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17#include <asm/page.h> 17#include <asm/page.h>
18#include <linux/stringify.h>
19 18
20#ifndef __ASSEMBLY__ 19/*
21 20 * Segment table
22/* Time to allow for more things here */ 21 */
23typedef unsigned long mm_context_id_t;
24typedef struct {
25 mm_context_id_t id;
26#ifdef CONFIG_HUGETLB_PAGE
27 pgd_t *huge_pgdir;
28 u16 htlb_segs; /* bitmask */
29#endif
30} mm_context_t;
31 22
32#define STE_ESID_V 0x80 23#define STE_ESID_V 0x80
33#define STE_ESID_KS 0x20 24#define STE_ESID_KS 0x20
@@ -36,15 +27,48 @@ typedef struct {
36 27
37#define STE_VSID_SHIFT 12 28#define STE_VSID_SHIFT 12
38 29
39struct stab_entry { 30/* Location of cpu0's segment table */
40 unsigned long esid_data; 31#define STAB0_PAGE 0x9
41 unsigned long vsid_data; 32#define STAB0_PHYS_ADDR (STAB0_PAGE<<PAGE_SHIFT)
42}; 33#define STAB0_VIRT_ADDR (KERNELBASE+STAB0_PHYS_ADDR)
34
35/*
36 * SLB
37 */
43 38
44/* Hardware Page Table Entry */ 39#define SLB_NUM_BOLTED 3
40#define SLB_CACHE_ENTRIES 8
41
42/* Bits in the SLB ESID word */
43#define SLB_ESID_V ASM_CONST(0x0000000008000000) /* valid */
44
45/* Bits in the SLB VSID word */
46#define SLB_VSID_SHIFT 12
47#define SLB_VSID_KS ASM_CONST(0x0000000000000800)
48#define SLB_VSID_KP ASM_CONST(0x0000000000000400)
49#define SLB_VSID_N ASM_CONST(0x0000000000000200) /* no-execute */
50#define SLB_VSID_L ASM_CONST(0x0000000000000100) /* largepage 16M */
51#define SLB_VSID_C ASM_CONST(0x0000000000000080) /* class */
52
53#define SLB_VSID_KERNEL (SLB_VSID_KP|SLB_VSID_C)
54#define SLB_VSID_USER (SLB_VSID_KP|SLB_VSID_KS)
55
56/*
57 * Hash table
58 */
45 59
46#define HPTES_PER_GROUP 8 60#define HPTES_PER_GROUP 8
47 61
62/* Values for PP (assumes Ks=0, Kp=1) */
63/* pp0 will always be 0 for linux */
64#define PP_RWXX 0 /* Supervisor read/write, User none */
65#define PP_RWRX 1 /* Supervisor read/write, User read */
66#define PP_RWRW 2 /* Supervisor read/write, User read/write */
67#define PP_RXRX 3 /* Supervisor read, User read */
68
69#ifndef __ASSEMBLY__
70
71/* Hardware Page Table Entry */
48typedef struct { 72typedef struct {
49 unsigned long avpn:57; /* vsid | api == avpn */ 73 unsigned long avpn:57; /* vsid | api == avpn */
50 unsigned long : 2; /* Software use */ 74 unsigned long : 2; /* Software use */
@@ -90,14 +114,6 @@ typedef struct {
90 } dw1; 114 } dw1;
91} HPTE; 115} HPTE;
92 116
93/* Values for PP (assumes Ks=0, Kp=1) */
94/* pp0 will always be 0 for linux */
95#define PP_RWXX 0 /* Supervisor read/write, User none */
96#define PP_RWRX 1 /* Supervisor read/write, User read */
97#define PP_RWRW 2 /* Supervisor read/write, User read/write */
98#define PP_RXRX 3 /* Supervisor read, User read */
99
100
101extern HPTE * htab_address; 117extern HPTE * htab_address;
102extern unsigned long htab_hash_mask; 118extern unsigned long htab_hash_mask;
103 119
@@ -174,31 +190,70 @@ extern int __hash_page(unsigned long ea, unsigned long access,
174 190
175extern void htab_finish_init(void); 191extern void htab_finish_init(void);
176 192
193extern void hpte_init_native(void);
194extern void hpte_init_lpar(void);
195extern void hpte_init_iSeries(void);
196
197extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
198 unsigned long va, unsigned long prpn,
199 int secondary, unsigned long hpteflags,
200 int bolted, int large);
201extern long native_hpte_insert(unsigned long hpte_group, unsigned long va,
202 unsigned long prpn, int secondary,
203 unsigned long hpteflags, int bolted, int large);
204
177#endif /* __ASSEMBLY__ */ 205#endif /* __ASSEMBLY__ */
178 206
179/* 207/*
180 * Location of cpu0's segment table 208 * VSID allocation
209 *
210 * We first generate a 36-bit "proto-VSID". For kernel addresses this
211 * is equal to the ESID, for user addresses it is:
212 * (context << 15) | (esid & 0x7fff)
213 *
214 * The two forms are distinguishable because the top bit is 0 for user
215 * addresses, whereas the top two bits are 1 for kernel addresses.
216 * Proto-VSIDs with the top two bits equal to 0b10 are reserved for
217 * now.
218 *
219 * The proto-VSIDs are then scrambled into real VSIDs with the
220 * multiplicative hash:
221 *
222 * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS
223 * where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7
224 * VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF
225 *
226 * This scramble is only well defined for proto-VSIDs below
227 * 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are
228 * reserved. VSID_MULTIPLIER is prime, so in particular it is
229 * co-prime to VSID_MODULUS, making this a 1:1 scrambling function.
230 * Because the modulus is 2^n-1 we can compute it efficiently without
231 * a divide or extra multiply (see below).
232 *
233 * This scheme has several advantages over older methods:
234 *
235 * - We have VSIDs allocated for every kernel address
236 * (i.e. everything above 0xC000000000000000), except the very top
237 * segment, which simplifies several things.
238 *
239 * - We allow for 15 significant bits of ESID and 20 bits of
240 * context for user addresses. i.e. 8T (43 bits) of address space for
241 * up to 1M contexts (although the page table structure and context
242 * allocation will need changes to take advantage of this).
243 *
244 * - The scramble function gives robust scattering in the hash
245 * table (at least based on some initial results). The previous
246 * method was more susceptible to pathological cases giving excessive
247 * hash collisions.
248 */
249/*
250 * WARNING - If you change these you must make sure the asm
251 * implementations in slb_allocate (slb_low.S), do_stab_bolted
252 * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly.
253 *
254 * You'll also need to change the precomputed VSID values in head.S
255 * which are used by the iSeries firmware.
181 */ 256 */
182#define STAB0_PAGE 0x9
183#define STAB0_PHYS_ADDR (STAB0_PAGE<<PAGE_SHIFT)
184#define STAB0_VIRT_ADDR (KERNELBASE+STAB0_PHYS_ADDR)
185
186#define SLB_NUM_BOLTED 3
187#define SLB_CACHE_ENTRIES 8
188
189/* Bits in the SLB ESID word */
190#define SLB_ESID_V 0x0000000008000000 /* entry is valid */
191
192/* Bits in the SLB VSID word */
193#define SLB_VSID_SHIFT 12
194#define SLB_VSID_KS 0x0000000000000800
195#define SLB_VSID_KP 0x0000000000000400
196#define SLB_VSID_N 0x0000000000000200 /* no-execute */
197#define SLB_VSID_L 0x0000000000000100 /* largepage (4M) */
198#define SLB_VSID_C 0x0000000000000080 /* class */
199
200#define SLB_VSID_KERNEL (SLB_VSID_KP|SLB_VSID_C)
201#define SLB_VSID_USER (SLB_VSID_KP|SLB_VSID_KS)
202 257
203#define VSID_MULTIPLIER ASM_CONST(200730139) /* 28-bit prime */ 258#define VSID_MULTIPLIER ASM_CONST(200730139) /* 28-bit prime */
204#define VSID_BITS 36 259#define VSID_BITS 36
@@ -239,4 +294,50 @@ extern void htab_finish_init(void);
239 srdi rx,rx,VSID_BITS; /* extract 2^36 bit */ \ 294 srdi rx,rx,VSID_BITS; /* extract 2^36 bit */ \
240 add rt,rt,rx 295 add rt,rt,rx
241 296
297
298#ifndef __ASSEMBLY__
299
300typedef unsigned long mm_context_id_t;
301
302typedef struct {
303 mm_context_id_t id;
304#ifdef CONFIG_HUGETLB_PAGE
305 pgd_t *huge_pgdir;
306 u16 htlb_segs; /* bitmask */
307#endif
308} mm_context_t;
309
310
311static inline unsigned long vsid_scramble(unsigned long protovsid)
312{
313#if 0
314 /* The code below is equivalent to this function for arguments
315 * < 2^VSID_BITS, which is all this should ever be called
316 * with. However gcc is not clever enough to compute the
317 * modulus (2^n-1) without a second multiply. */
318 return ((protovsid * VSID_MULTIPLIER) % VSID_MODULUS);
319#else /* 1 */
320 unsigned long x;
321
322 x = protovsid * VSID_MULTIPLIER;
323 x = (x >> VSID_BITS) + (x & VSID_MODULUS);
324 return (x + ((x+1) >> VSID_BITS)) & VSID_MODULUS;
325#endif /* 1 */
326}
327
328/* This is only valid for addresses >= KERNELBASE */
329static inline unsigned long get_kernel_vsid(unsigned long ea)
330{
331 return vsid_scramble(ea >> SID_SHIFT);
332}
333
334/* This is only valid for user addresses (which are below 2^41) */
335static inline unsigned long get_vsid(unsigned long context, unsigned long ea)
336{
337 return vsid_scramble((context << USER_ESID_BITS)
338 | (ea >> SID_SHIFT));
339}
340
341#endif /* __ASSEMBLY */
342
242#endif /* _PPC64_MMU_H_ */ 343#endif /* _PPC64_MMU_H_ */
diff --git a/include/asm-ppc64/mmu_context.h b/include/asm-ppc64/mmu_context.h
index c2e8e0466383..77a743402db4 100644
--- a/include/asm-ppc64/mmu_context.h
+++ b/include/asm-ppc64/mmu_context.h
@@ -84,86 +84,4 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
84 local_irq_restore(flags); 84 local_irq_restore(flags);
85} 85}
86 86
87/* VSID allocation
88 * ===============
89 *
90 * We first generate a 36-bit "proto-VSID". For kernel addresses this
91 * is equal to the ESID, for user addresses it is:
92 * (context << 15) | (esid & 0x7fff)
93 *
94 * The two forms are distinguishable because the top bit is 0 for user
95 * addresses, whereas the top two bits are 1 for kernel addresses.
96 * Proto-VSIDs with the top two bits equal to 0b10 are reserved for
97 * now.
98 *
99 * The proto-VSIDs are then scrambled into real VSIDs with the
100 * multiplicative hash:
101 *
102 * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS
103 * where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7
104 * VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF
105 *
106 * This scramble is only well defined for proto-VSIDs below
107 * 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are
108 * reserved. VSID_MULTIPLIER is prime, so in particular it is
109 * co-prime to VSID_MODULUS, making this a 1:1 scrambling function.
110 * Because the modulus is 2^n-1 we can compute it efficiently without
111 * a divide or extra multiply (see below).
112 *
113 * This scheme has several advantages over older methods:
114 *
115 * - We have VSIDs allocated for every kernel address
116 * (i.e. everything above 0xC000000000000000), except the very top
117 * segment, which simplifies several things.
118 *
119 * - We allow for 15 significant bits of ESID and 20 bits of
120 * context for user addresses. i.e. 8T (43 bits) of address space for
121 * up to 1M contexts (although the page table structure and context
122 * allocation will need changes to take advantage of this).
123 *
124 * - The scramble function gives robust scattering in the hash
125 * table (at least based on some initial results). The previous
126 * method was more susceptible to pathological cases giving excessive
127 * hash collisions.
128 */
129
130/*
131 * WARNING - If you change these you must make sure the asm
132 * implementations in slb_allocate(), do_stab_bolted and mmu.h
133 * (ASM_VSID_SCRAMBLE macro) are changed accordingly.
134 *
135 * You'll also need to change the precomputed VSID values in head.S
136 * which are used by the iSeries firmware.
137 */
138
139static inline unsigned long vsid_scramble(unsigned long protovsid)
140{
141#if 0
142 /* The code below is equivalent to this function for arguments
143 * < 2^VSID_BITS, which is all this should ever be called
144 * with. However gcc is not clever enough to compute the
145 * modulus (2^n-1) without a second multiply. */
146 return ((protovsid * VSID_MULTIPLIER) % VSID_MODULUS);
147#else /* 1 */
148 unsigned long x;
149
150 x = protovsid * VSID_MULTIPLIER;
151 x = (x >> VSID_BITS) + (x & VSID_MODULUS);
152 return (x + ((x+1) >> VSID_BITS)) & VSID_MODULUS;
153#endif /* 1 */
154}
155
156/* This is only valid for addresses >= KERNELBASE */
157static inline unsigned long get_kernel_vsid(unsigned long ea)
158{
159 return vsid_scramble(ea >> SID_SHIFT);
160}
161
162/* This is only valid for user addresses (which are below 2^41) */
163static inline unsigned long get_vsid(unsigned long context, unsigned long ea)
164{
165 return vsid_scramble((context << USER_ESID_BITS)
166 | (ea >> SID_SHIFT));
167}
168
169#endif /* __PPC64_MMU_CONTEXT_H */ 87#endif /* __PPC64_MMU_CONTEXT_H */
diff --git a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h
index 20e0f19324e8..bcd21789d3b7 100644
--- a/include/asm-ppc64/page.h
+++ b/include/asm-ppc64/page.h
@@ -23,7 +23,6 @@
23#define PAGE_SHIFT 12 23#define PAGE_SHIFT 12
24#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT) 24#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
25#define PAGE_MASK (~(PAGE_SIZE-1)) 25#define PAGE_MASK (~(PAGE_SIZE-1))
26#define PAGE_OFFSET_MASK (PAGE_SIZE-1)
27 26
28#define SID_SHIFT 28 27#define SID_SHIFT 28
29#define SID_MASK 0xfffffffffUL 28#define SID_MASK 0xfffffffffUL
@@ -85,9 +84,6 @@
85/* align addr on a size boundary - adjust address up if needed */ 84/* align addr on a size boundary - adjust address up if needed */
86#define _ALIGN(addr,size) _ALIGN_UP(addr,size) 85#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
87 86
88/* to align the pointer to the (next) double word boundary */
89#define DOUBLEWORD_ALIGN(addr) _ALIGN(addr,sizeof(unsigned long))
90
91/* to align the pointer to the (next) page boundary */ 87/* to align the pointer to the (next) page boundary */
92#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE) 88#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE)
93 89
@@ -100,7 +96,6 @@
100#define REGION_SIZE 4UL 96#define REGION_SIZE 4UL
101#define REGION_SHIFT 60UL 97#define REGION_SHIFT 60UL
102#define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT) 98#define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT)
103#define REGION_STRIDE (1UL << REGION_SHIFT)
104 99
105static __inline__ void clear_page(void *addr) 100static __inline__ void clear_page(void *addr)
106{ 101{
@@ -209,13 +204,13 @@ extern u64 ppc64_pft_size; /* Log 2 of page table size */
209#define VMALLOCBASE ASM_CONST(0xD000000000000000) 204#define VMALLOCBASE ASM_CONST(0xD000000000000000)
210#define IOREGIONBASE ASM_CONST(0xE000000000000000) 205#define IOREGIONBASE ASM_CONST(0xE000000000000000)
211 206
212#define IO_REGION_ID (IOREGIONBASE>>REGION_SHIFT) 207#define IO_REGION_ID (IOREGIONBASE >> REGION_SHIFT)
213#define VMALLOC_REGION_ID (VMALLOCBASE>>REGION_SHIFT) 208#define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT)
214#define KERNEL_REGION_ID (KERNELBASE>>REGION_SHIFT) 209#define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT)
215#define USER_REGION_ID (0UL) 210#define USER_REGION_ID (0UL)
216#define REGION_ID(X) (((unsigned long)(X))>>REGION_SHIFT) 211#define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT)
217 212
218#define __bpn_to_ba(x) ((((unsigned long)(x))<<PAGE_SHIFT) + KERNELBASE) 213#define __bpn_to_ba(x) ((((unsigned long)(x)) << PAGE_SHIFT) + KERNELBASE)
219#define __ba_to_bpn(x) ((((unsigned long)(x)) & ~REGION_MASK) >> PAGE_SHIFT) 214#define __ba_to_bpn(x) ((((unsigned long)(x)) & ~REGION_MASK) >> PAGE_SHIFT)
220 215
221#define __va(x) ((void *)((unsigned long)(x) + KERNELBASE)) 216#define __va(x) ((void *)((unsigned long)(x) + KERNELBASE))
@@ -252,10 +247,19 @@ extern u64 ppc64_pft_size; /* Log 2 of page table size */
252 247
253/* 248/*
254 * This is the default if a program doesn't have a PT_GNU_STACK 249 * This is the default if a program doesn't have a PT_GNU_STACK
255 * program header entry. 250 * program header entry. The PPC64 ELF ABI has a non executable stack
251 * stack by default, so in the absense of a PT_GNU_STACK program header
252 * we turn execute permission off.
256 */ 253 */
257#define VM_STACK_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 254#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
258 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 255 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
256
257#define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
258 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
259
260#define VM_STACK_DEFAULT_FLAGS \
261 (test_thread_flag(TIF_32BIT) ? \
262 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
259 263
260#endif /* __KERNEL__ */ 264#endif /* __KERNEL__ */
261#endif /* _PPC64_PAGE_H */ 265#endif /* _PPC64_PAGE_H */
diff --git a/include/asm-ppc64/pgalloc.h b/include/asm-ppc64/pgalloc.h
index 16232d740173..4fc4b739b380 100644
--- a/include/asm-ppc64/pgalloc.h
+++ b/include/asm-ppc64/pgalloc.h
@@ -27,7 +27,7 @@ pgd_free(pgd_t *pgd)
27 kmem_cache_free(zero_cache, pgd); 27 kmem_cache_free(zero_cache, pgd);
28} 28}
29 29
30#define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD) 30#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
31 31
32static inline pmd_t * 32static inline pmd_t *
33pmd_alloc_one(struct mm_struct *mm, unsigned long addr) 33pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
diff --git a/include/asm-ppc64/pgtable.h b/include/asm-ppc64/pgtable.h
index a26120517c54..264c4f7993be 100644
--- a/include/asm-ppc64/pgtable.h
+++ b/include/asm-ppc64/pgtable.h
@@ -1,8 +1,6 @@
1#ifndef _PPC64_PGTABLE_H 1#ifndef _PPC64_PGTABLE_H
2#define _PPC64_PGTABLE_H 2#define _PPC64_PGTABLE_H
3 3
4#include <asm-generic/4level-fixup.h>
5
6/* 4/*
7 * This file contains the functions and defines necessary to modify and use 5 * This file contains the functions and defines necessary to modify and use
8 * the ppc64 hashed page table. 6 * the ppc64 hashed page table.
@@ -17,15 +15,7 @@
17#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
18#endif /* __ASSEMBLY__ */ 16#endif /* __ASSEMBLY__ */
19 17
20/* PMD_SHIFT determines what a second-level page table entry can map */ 18#include <asm-generic/pgtable-nopud.h>
21#define PMD_SHIFT (PAGE_SHIFT + PAGE_SHIFT - 3)
22#define PMD_SIZE (1UL << PMD_SHIFT)
23#define PMD_MASK (~(PMD_SIZE-1))
24
25/* PGDIR_SHIFT determines what a third-level page table entry can map */
26#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT - 3) + (PAGE_SHIFT - 2))
27#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
28#define PGDIR_MASK (~(PGDIR_SIZE-1))
29 19
30/* 20/*
31 * Entries per page directory level. The PTE level must use a 64b record 21 * Entries per page directory level. The PTE level must use a 64b record
@@ -40,40 +30,30 @@
40#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE) 30#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
41#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE) 31#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
42 32
43#define USER_PTRS_PER_PGD (1024) 33/* PMD_SHIFT determines what a second-level page table entry can map */
44#define FIRST_USER_ADDRESS 0 34#define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
35#define PMD_SIZE (1UL << PMD_SHIFT)
36#define PMD_MASK (~(PMD_SIZE-1))
45 37
46#define EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \ 38/* PGDIR_SHIFT determines what a third-level page table entry can map */
47 PGD_INDEX_SIZE + PAGE_SHIFT) 39#define PGDIR_SHIFT (PMD_SHIFT + PMD_INDEX_SIZE)
40#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
41#define PGDIR_MASK (~(PGDIR_SIZE-1))
42
43#define FIRST_USER_ADDRESS 0
48 44
49/* 45/*
50 * Size of EA range mapped by our pagetables. 46 * Size of EA range mapped by our pagetables.
51 */ 47 */
52#define PGTABLE_EA_BITS 41 48#define EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
53#define PGTABLE_EA_MASK ((1UL<<PGTABLE_EA_BITS)-1) 49 PGD_INDEX_SIZE + PAGE_SHIFT)
50#define EADDR_MASK ((1UL << EADDR_SIZE) - 1)
54 51
55/* 52/*
56 * Define the address range of the vmalloc VM area. 53 * Define the address range of the vmalloc VM area.
57 */ 54 */
58#define VMALLOC_START (0xD000000000000000ul) 55#define VMALLOC_START (0xD000000000000000ul)
59#define VMALLOC_END (VMALLOC_START + PGTABLE_EA_MASK) 56#define VMALLOC_END (VMALLOC_START + EADDR_MASK)
60
61/*
62 * Define the address range of the imalloc VM area.
63 * (used for ioremap)
64 */
65#define IMALLOC_START (ioremap_bot)
66#define IMALLOC_VMADDR(x) ((unsigned long)(x))
67#define PHBS_IO_BASE (0xE000000000000000ul) /* Reserve 2 gigs for PHBs */
68#define IMALLOC_BASE (0xE000000080000000ul)
69#define IMALLOC_END (IMALLOC_BASE + PGTABLE_EA_MASK)
70
71/*
72 * Define the user address range
73 */
74#define USER_START (0UL)
75#define USER_END (USER_START + PGTABLE_EA_MASK)
76
77 57
78/* 58/*
79 * Bits in a linux-style PTE. These match the bits in the 59 * Bits in a linux-style PTE. These match the bits in the
@@ -168,10 +148,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
168/* shift to put page number into pte */ 148/* shift to put page number into pte */
169#define PTE_SHIFT (17) 149#define PTE_SHIFT (17)
170 150
171/* We allow 2^41 bytes of real memory, so we need 29 bits in the PMD
172 * to give the PTE page number. The bottom two bits are for flags. */
173#define PMD_TO_PTEPAGE_SHIFT (2)
174
175#ifdef CONFIG_HUGETLB_PAGE 151#ifdef CONFIG_HUGETLB_PAGE
176 152
177#ifndef __ASSEMBLY__ 153#ifndef __ASSEMBLY__
@@ -200,13 +176,14 @@ void hugetlb_mm_free_pgd(struct mm_struct *mm);
200 */ 176 */
201#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 177#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
202 178
203#define pfn_pte(pfn,pgprot) \ 179static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
204({ \ 180{
205 pte_t pte; \ 181 pte_t pte;
206 pte_val(pte) = ((unsigned long)(pfn) << PTE_SHIFT) | \ 182
207 pgprot_val(pgprot); \ 183
208 pte; \ 184 pte_val(pte) = (pfn << PTE_SHIFT) | pgprot_val(pgprot);
209}) 185 return pte;
186}
210 187
211#define pte_modify(_pte, newprot) \ 188#define pte_modify(_pte, newprot) \
212 (__pte((pte_val(_pte) & _PAGE_CHG_MASK) | pgprot_val(newprot))) 189 (__pte((pte_val(_pte) & _PAGE_CHG_MASK) | pgprot_val(newprot)))
@@ -220,20 +197,20 @@ void hugetlb_mm_free_pgd(struct mm_struct *mm);
220#define pte_page(x) pfn_to_page(pte_pfn(x)) 197#define pte_page(x) pfn_to_page(pte_pfn(x))
221 198
222#define pmd_set(pmdp, ptep) \ 199#define pmd_set(pmdp, ptep) \
223 (pmd_val(*(pmdp)) = (__ba_to_bpn(ptep) << PMD_TO_PTEPAGE_SHIFT)) 200 (pmd_val(*(pmdp)) = __ba_to_bpn(ptep))
224#define pmd_none(pmd) (!pmd_val(pmd)) 201#define pmd_none(pmd) (!pmd_val(pmd))
225#define pmd_bad(pmd) (pmd_val(pmd) == 0) 202#define pmd_bad(pmd) (pmd_val(pmd) == 0)
226#define pmd_present(pmd) (pmd_val(pmd) != 0) 203#define pmd_present(pmd) (pmd_val(pmd) != 0)
227#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0) 204#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
228#define pmd_page_kernel(pmd) \ 205#define pmd_page_kernel(pmd) (__bpn_to_ba(pmd_val(pmd)))
229 (__bpn_to_ba(pmd_val(pmd) >> PMD_TO_PTEPAGE_SHIFT))
230#define pmd_page(pmd) virt_to_page(pmd_page_kernel(pmd)) 206#define pmd_page(pmd) virt_to_page(pmd_page_kernel(pmd))
231#define pgd_set(pgdp, pmdp) (pgd_val(*(pgdp)) = (__ba_to_bpn(pmdp))) 207
232#define pgd_none(pgd) (!pgd_val(pgd)) 208#define pud_set(pudp, pmdp) (pud_val(*(pudp)) = (__ba_to_bpn(pmdp)))
233#define pgd_bad(pgd) ((pgd_val(pgd)) == 0) 209#define pud_none(pud) (!pud_val(pud))
234#define pgd_present(pgd) (pgd_val(pgd) != 0UL) 210#define pud_bad(pud) ((pud_val(pud)) == 0UL)
235#define pgd_clear(pgdp) (pgd_val(*(pgdp)) = 0UL) 211#define pud_present(pud) (pud_val(pud) != 0UL)
236#define pgd_page(pgd) (__bpn_to_ba(pgd_val(pgd))) 212#define pud_clear(pudp) (pud_val(*(pudp)) = 0UL)
213#define pud_page(pud) (__bpn_to_ba(pud_val(pud)))
237 214
238/* 215/*
239 * Find an entry in a page-table-directory. We combine the address region 216 * Find an entry in a page-table-directory. We combine the address region
@@ -245,12 +222,13 @@ void hugetlb_mm_free_pgd(struct mm_struct *mm);
245#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address)) 222#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
246 223
247/* Find an entry in the second-level page table.. */ 224/* Find an entry in the second-level page table.. */
248#define pmd_offset(dir,addr) \ 225#define pmd_offset(pudp,addr) \
249 ((pmd_t *) pgd_page(*(dir)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))) 226 ((pmd_t *) pud_page(*(pudp)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
250 227
251/* Find an entry in the third-level page table.. */ 228/* Find an entry in the third-level page table.. */
252#define pte_offset_kernel(dir,addr) \ 229#define pte_offset_kernel(dir,addr) \
253 ((pte_t *) pmd_page_kernel(*(dir)) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) 230 ((pte_t *) pmd_page_kernel(*(dir)) \
231 + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
254 232
255#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr)) 233#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
256#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr)) 234#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
@@ -264,8 +242,6 @@ void hugetlb_mm_free_pgd(struct mm_struct *mm);
264/* to find an entry in the ioremap page-table-directory */ 242/* to find an entry in the ioremap page-table-directory */
265#define pgd_offset_i(address) (ioremap_pgd + pgd_index(address)) 243#define pgd_offset_i(address) (ioremap_pgd + pgd_index(address))
266 244
267#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
268
269/* 245/*
270 * The following only work if pte_present() is true. 246 * The following only work if pte_present() is true.
271 * Undefined behaviour if not.. 247 * Undefined behaviour if not..
@@ -440,7 +416,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
440 pte_clear(mm, addr, ptep); 416 pte_clear(mm, addr, ptep);
441 flush_tlb_pending(); 417 flush_tlb_pending();
442 } 418 }
443 *ptep = __pte(pte_val(pte)) & ~_PAGE_HPTEFLAGS; 419 *ptep = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
444} 420}
445 421
446/* Set the dirty and/or accessed bits atomically in a linux PTE, this 422/* Set the dirty and/or accessed bits atomically in a linux PTE, this
@@ -485,18 +461,13 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long addr,
485 461
486extern unsigned long ioremap_bot, ioremap_base; 462extern unsigned long ioremap_bot, ioremap_base;
487 463
488#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
489#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
490
491#define pte_ERROR(e) \
492 printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
493#define pmd_ERROR(e) \ 464#define pmd_ERROR(e) \
494 printk("%s:%d: bad pmd %08x.\n", __FILE__, __LINE__, pmd_val(e)) 465 printk("%s:%d: bad pmd %08x.\n", __FILE__, __LINE__, pmd_val(e))
495#define pgd_ERROR(e) \ 466#define pgd_ERROR(e) \
496 printk("%s:%d: bad pgd %08x.\n", __FILE__, __LINE__, pgd_val(e)) 467 printk("%s:%d: bad pgd %08x.\n", __FILE__, __LINE__, pgd_val(e))
497 468
498extern pgd_t swapper_pg_dir[1024]; 469extern pgd_t swapper_pg_dir[];
499extern pgd_t ioremap_dir[1024]; 470extern pgd_t ioremap_dir[];
500 471
501extern void paging_init(void); 472extern void paging_init(void);
502 473
@@ -538,43 +509,11 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
538 */ 509 */
539#define kern_addr_valid(addr) (1) 510#define kern_addr_valid(addr) (1)
540 511
541#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
542 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
543
544#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 512#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
545 remap_pfn_range(vma, vaddr, pfn, size, prot) 513 remap_pfn_range(vma, vaddr, pfn, size, prot)
546 514
547#define MK_IOSPACE_PFN(space, pfn) (pfn)
548#define GET_IOSPACE(pfn) 0
549#define GET_PFN(pfn) (pfn)
550
551void pgtable_cache_init(void); 515void pgtable_cache_init(void);
552 516
553extern void hpte_init_native(void);
554extern void hpte_init_lpar(void);
555extern void hpte_init_iSeries(void);
556
557/* imalloc region types */
558#define IM_REGION_UNUSED 0x1
559#define IM_REGION_SUBSET 0x2
560#define IM_REGION_EXISTS 0x4
561#define IM_REGION_OVERLAP 0x8
562#define IM_REGION_SUPERSET 0x10
563
564extern struct vm_struct * im_get_free_area(unsigned long size);
565extern struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
566 int region_type);
567unsigned long im_free(void *addr);
568
569extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
570 unsigned long va, unsigned long prpn,
571 int secondary, unsigned long hpteflags,
572 int bolted, int large);
573
574extern long native_hpte_insert(unsigned long hpte_group, unsigned long va,
575 unsigned long prpn, int secondary,
576 unsigned long hpteflags, int bolted, int large);
577
578/* 517/*
579 * find_linux_pte returns the address of a linux pte for a given 518 * find_linux_pte returns the address of a linux pte for a given
580 * effective address and directory. If not found, it returns zero. 519 * effective address and directory. If not found, it returns zero.
@@ -582,19 +521,22 @@ extern long native_hpte_insert(unsigned long hpte_group, unsigned long va,
582static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea) 521static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
583{ 522{
584 pgd_t *pg; 523 pgd_t *pg;
524 pud_t *pu;
585 pmd_t *pm; 525 pmd_t *pm;
586 pte_t *pt = NULL; 526 pte_t *pt = NULL;
587 pte_t pte; 527 pte_t pte;
588 528
589 pg = pgdir + pgd_index(ea); 529 pg = pgdir + pgd_index(ea);
590 if (!pgd_none(*pg)) { 530 if (!pgd_none(*pg)) {
591 531 pu = pud_offset(pg, ea);
592 pm = pmd_offset(pg, ea); 532 if (!pud_none(*pu)) {
593 if (pmd_present(*pm)) { 533 pm = pmd_offset(pu, ea);
594 pt = pte_offset_kernel(pm, ea); 534 if (pmd_present(*pm)) {
595 pte = *pt; 535 pt = pte_offset_kernel(pm, ea);
596 if (!pte_present(pte)) 536 pte = *pt;
597 pt = NULL; 537 if (!pte_present(pte))
538 pt = NULL;
539 }
598 } 540 }
599 } 541 }
600 542
diff --git a/include/asm-ppc64/signal.h b/include/asm-ppc64/signal.h
index fe5401adb41b..432df7dd355d 100644
--- a/include/asm-ppc64/signal.h
+++ b/include/asm-ppc64/signal.h
@@ -96,47 +96,20 @@ typedef struct {
96 96
97#define MINSIGSTKSZ 2048 97#define MINSIGSTKSZ 2048
98#define SIGSTKSZ 8192 98#define SIGSTKSZ 8192
99#ifdef __KERNEL__
100 99
101/* 100#include <asm-generic/signal.h>
102 * These values of sa_flags are used only by the kernel as part of the
103 * irq handling routines.
104 *
105 * SA_INTERRUPT is also used by the irq handling routines.
106 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
107 */
108#define SA_PROBE SA_ONESHOT
109#define SA_SAMPLE_RANDOM SA_RESTART
110#define SA_SHIRQ 0x04000000
111#endif
112
113#define SIG_BLOCK 0 /* for blocking signals */
114#define SIG_UNBLOCK 1 /* for unblocking signals */
115#define SIG_SETMASK 2 /* for setting the signal mask */
116
117/* Type of a signal handler. */
118typedef void __sigfunction(int);
119typedef __sigfunction __user * __sighandler_t;
120
121/* Type of the restorer function */
122typedef void __sigrestorer(void);
123typedef __sigrestorer __user * __sigrestorer_t;
124
125#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
126#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
127#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
128 101
129struct old_sigaction { 102struct old_sigaction {
130 __sighandler_t sa_handler; 103 __sighandler_t sa_handler;
131 old_sigset_t sa_mask; 104 old_sigset_t sa_mask;
132 unsigned long sa_flags; 105 unsigned long sa_flags;
133 __sigrestorer_t sa_restorer; 106 __sigrestore_t sa_restorer;
134}; 107};
135 108
136struct sigaction { 109struct sigaction {
137 __sighandler_t sa_handler; 110 __sighandler_t sa_handler;
138 unsigned long sa_flags; 111 unsigned long sa_flags;
139 __sigrestorer_t sa_restorer; 112 __sigrestore_t sa_restorer;
140 sigset_t sa_mask; /* mask last for extensibility */ 113 sigset_t sa_mask; /* mask last for extensibility */
141}; 114};
142 115
diff --git a/include/asm-ppc64/spinlock.h b/include/asm-ppc64/spinlock.h
index a9b2a1162cf7..acd11564dd75 100644
--- a/include/asm-ppc64/spinlock.h
+++ b/include/asm-ppc64/spinlock.h
@@ -110,7 +110,7 @@ static void __inline__ _raw_spin_lock(spinlock_t *lock)
110 HMT_low(); 110 HMT_low();
111 if (SHARED_PROCESSOR) 111 if (SHARED_PROCESSOR)
112 __spin_yield(lock); 112 __spin_yield(lock);
113 } while (likely(lock->lock != 0)); 113 } while (unlikely(lock->lock != 0));
114 HMT_medium(); 114 HMT_medium();
115 } 115 }
116} 116}
@@ -128,7 +128,7 @@ static void __inline__ _raw_spin_lock_flags(spinlock_t *lock, unsigned long flag
128 HMT_low(); 128 HMT_low();
129 if (SHARED_PROCESSOR) 129 if (SHARED_PROCESSOR)
130 __spin_yield(lock); 130 __spin_yield(lock);
131 } while (likely(lock->lock != 0)); 131 } while (unlikely(lock->lock != 0));
132 HMT_medium(); 132 HMT_medium();
133 local_irq_restore(flags_dis); 133 local_irq_restore(flags_dis);
134 } 134 }
@@ -194,7 +194,7 @@ static void __inline__ _raw_read_lock(rwlock_t *rw)
194 HMT_low(); 194 HMT_low();
195 if (SHARED_PROCESSOR) 195 if (SHARED_PROCESSOR)
196 __rw_yield(rw); 196 __rw_yield(rw);
197 } while (likely(rw->lock < 0)); 197 } while (unlikely(rw->lock < 0));
198 HMT_medium(); 198 HMT_medium();
199 } 199 }
200} 200}
@@ -251,7 +251,7 @@ static void __inline__ _raw_write_lock(rwlock_t *rw)
251 HMT_low(); 251 HMT_low();
252 if (SHARED_PROCESSOR) 252 if (SHARED_PROCESSOR)
253 __rw_yield(rw); 253 __rw_yield(rw);
254 } while (likely(rw->lock != 0)); 254 } while (unlikely(rw->lock != 0));
255 HMT_medium(); 255 HMT_medium();
256 } 256 }
257} 257}
diff --git a/include/asm-ppc64/xics.h b/include/asm-ppc64/xics.h
index 0027da4364ac..fdec5e7a7af6 100644
--- a/include/asm-ppc64/xics.h
+++ b/include/asm-ppc64/xics.h
@@ -30,7 +30,4 @@ struct xics_ipi_struct {
30 30
31extern struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned; 31extern struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;
32 32
33extern unsigned int default_distrib_server;
34extern unsigned int interrupt_server_size;
35
36#endif /* _PPC64_KERNEL_XICS_H */ 33#endif /* _PPC64_KERNEL_XICS_H */
diff --git a/include/asm-s390/bug.h b/include/asm-s390/bug.h
index 2b8d6d4dffcf..a2e7430aafa6 100644
--- a/include/asm-s390/bug.h
+++ b/include/asm-s390/bug.h
@@ -3,12 +3,15 @@
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5 5
6#ifdef CONFIG_BUG
6#define BUG() do { \ 7#define BUG() do { \
7 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ 8 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
8 __asm__ __volatile__(".long 0"); \ 9 __asm__ __volatile__(".long 0"); \
9} while (0) 10} while (0)
10 11
11#define HAVE_ARCH_BUG 12#define HAVE_ARCH_BUG
13#endif
14
12#include <asm-generic/bug.h> 15#include <asm-generic/bug.h>
13 16
14#endif 17#endif
diff --git a/include/asm-s390/cmb.h b/include/asm-s390/cmb.h
index 1bfe2bd630b5..dae1dd4fb937 100644
--- a/include/asm-s390/cmb.h
+++ b/include/asm-s390/cmb.h
@@ -52,7 +52,7 @@ struct cmbdata {
52#define BIODASDREADALLCMB _IOWR(DASD_IOCTL_LETTER,33,struct cmbdata) 52#define BIODASDREADALLCMB _IOWR(DASD_IOCTL_LETTER,33,struct cmbdata)
53 53
54#ifdef __KERNEL__ 54#ifdef __KERNEL__
55 55struct ccw_device;
56/** 56/**
57 * enable_cmf() - switch on the channel measurement for a specific device 57 * enable_cmf() - switch on the channel measurement for a specific device
58 * @cdev: The ccw device to be enabled 58 * @cdev: The ccw device to be enabled
diff --git a/include/asm-s390/debug.h b/include/asm-s390/debug.h
index 28ef2354b1b2..6bbcdea42a86 100644
--- a/include/asm-s390/debug.h
+++ b/include/asm-s390/debug.h
@@ -43,7 +43,7 @@ struct __debug_entry{
43#define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */ 43#define DEBUG_OFF_LEVEL -1 /* level where debug is switched off */
44#define DEBUG_FLUSH_ALL -1 /* parameter to flush all areas */ 44#define DEBUG_FLUSH_ALL -1 /* parameter to flush all areas */
45#define DEBUG_MAX_VIEWS 10 /* max number of views in proc fs */ 45#define DEBUG_MAX_VIEWS 10 /* max number of views in proc fs */
46#define DEBUG_MAX_PROCF_LEN 16 /* max length for a proc file name */ 46#define DEBUG_MAX_PROCF_LEN 64 /* max length for a proc file name */
47#define DEBUG_DEFAULT_LEVEL 3 /* initial debug level */ 47#define DEBUG_DEFAULT_LEVEL 3 /* initial debug level */
48 48
49#define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */ 49#define DEBUG_DIR_ROOT "s390dbf" /* name of debug root directory in proc fs */
diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h
index 614e2a93c703..2be287b9df88 100644
--- a/include/asm-s390/page.h
+++ b/include/asm-s390/page.h
@@ -16,6 +16,8 @@
16#define PAGE_SHIFT 12 16#define PAGE_SHIFT 12
17#define PAGE_SIZE (1UL << PAGE_SHIFT) 17#define PAGE_SIZE (1UL << PAGE_SHIFT)
18#define PAGE_MASK (~(PAGE_SIZE-1)) 18#define PAGE_MASK (~(PAGE_SIZE-1))
19#define PAGE_DEFAULT_ACC 0
20#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
19 21
20#ifdef __KERNEL__ 22#ifdef __KERNEL__
21#ifndef __ASSEMBLY__ 23#ifndef __ASSEMBLY__
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h
index 88c272ca48bf..fb46e9090b50 100644
--- a/include/asm-s390/processor.h
+++ b/include/asm-s390/processor.h
@@ -245,7 +245,7 @@ static inline void enabled_wait(void)
245 psw_t wait_psw; 245 psw_t wait_psw;
246 246
247 wait_psw.mask = PSW_BASE_BITS | PSW_MASK_IO | PSW_MASK_EXT | 247 wait_psw.mask = PSW_BASE_BITS | PSW_MASK_IO | PSW_MASK_EXT |
248 PSW_MASK_MCHECK | PSW_MASK_WAIT; 248 PSW_MASK_MCHECK | PSW_MASK_WAIT | PSW_DEFAULT_KEY;
249#ifndef __s390x__ 249#ifndef __s390x__
250 asm volatile ( 250 asm volatile (
251 " basr %0,0\n" 251 " basr %0,0\n"
diff --git a/include/asm-s390/ptrace.h b/include/asm-s390/ptrace.h
index 1dc80666e97e..4eff8f2e3bf1 100644
--- a/include/asm-s390/ptrace.h
+++ b/include/asm-s390/ptrace.h
@@ -185,6 +185,7 @@
185#include <linux/stddef.h> 185#include <linux/stddef.h>
186#include <linux/types.h> 186#include <linux/types.h>
187#include <asm/setup.h> 187#include <asm/setup.h>
188#include <asm/page.h>
188 189
189typedef union 190typedef union
190{ 191{
@@ -235,6 +236,7 @@ typedef struct
235#define PSW_ADDR_INSN 0x7FFFFFFFUL 236#define PSW_ADDR_INSN 0x7FFFFFFFUL
236 237
237#define PSW_BASE_BITS 0x00080000UL 238#define PSW_BASE_BITS 0x00080000UL
239#define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 20)
238 240
239#define PSW_ASC_PRIMARY 0x00000000UL 241#define PSW_ASC_PRIMARY 0x00000000UL
240#define PSW_ASC_ACCREG 0x00004000UL 242#define PSW_ASC_ACCREG 0x00004000UL
@@ -260,6 +262,7 @@ typedef struct
260 262
261#define PSW_BASE_BITS 0x0000000180000000UL 263#define PSW_BASE_BITS 0x0000000180000000UL
262#define PSW_BASE32_BITS 0x0000000080000000UL 264#define PSW_BASE32_BITS 0x0000000080000000UL
265#define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 52)
263 266
264#define PSW_ASC_PRIMARY 0x0000000000000000UL 267#define PSW_ASC_PRIMARY 0x0000000000000000UL
265#define PSW_ASC_ACCREG 0x0000400000000000UL 268#define PSW_ASC_ACCREG 0x0000400000000000UL
@@ -268,14 +271,15 @@ typedef struct
268 271
269#define PSW_USER32_BITS (PSW_BASE32_BITS | PSW_MASK_DAT | PSW_ASC_HOME | \ 272#define PSW_USER32_BITS (PSW_BASE32_BITS | PSW_MASK_DAT | PSW_ASC_HOME | \
270 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | \ 273 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | \
271 PSW_MASK_PSTATE) 274 PSW_MASK_PSTATE | PSW_DEFAULT_KEY)
272 275
273#endif /* __s390x__ */ 276#endif /* __s390x__ */
274 277
275#define PSW_KERNEL_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY) 278#define PSW_KERNEL_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY | \
279 PSW_DEFAULT_KEY)
276#define PSW_USER_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_HOME | \ 280#define PSW_USER_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_HOME | \
277 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | \ 281 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | \
278 PSW_MASK_PSTATE) 282 PSW_MASK_PSTATE | PSW_DEFAULT_KEY)
279 283
280/* This macro merges a NEW PSW mask specified by the user into 284/* This macro merges a NEW PSW mask specified by the user into
281 the currently active PSW mask CURRENT, modifying only those 285 the currently active PSW mask CURRENT, modifying only those
@@ -470,6 +474,12 @@ struct user_regs_struct
470extern void show_regs(struct pt_regs * regs); 474extern void show_regs(struct pt_regs * regs);
471#endif 475#endif
472 476
477static inline void
478psw_set_key(unsigned int key)
479{
480 asm volatile ( "spka 0(%0)" : : "d" (key) );
481}
482
473#endif /* __ASSEMBLY__ */ 483#endif /* __ASSEMBLY__ */
474 484
475#endif /* _S390_PTRACE_H */ 485#endif /* _S390_PTRACE_H */
diff --git a/include/asm-s390/siginfo.h b/include/asm-s390/siginfo.h
index 72303537b732..e0ff1ab054be 100644
--- a/include/asm-s390/siginfo.h
+++ b/include/asm-s390/siginfo.h
@@ -13,12 +13,6 @@
13#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) 13#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
14#endif 14#endif
15 15
16#ifdef CONFIG_ARCH_S390X
17#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
18#else
19#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
20#endif
21
22#include <asm-generic/siginfo.h> 16#include <asm-generic/siginfo.h>
23 17
24#endif 18#endif
diff --git a/include/asm-s390/signal.h b/include/asm-s390/signal.h
index f273cdcd1cf6..3d6e11c6c1fd 100644
--- a/include/asm-s390/signal.h
+++ b/include/asm-s390/signal.h
@@ -117,30 +117,7 @@ typedef unsigned long sigset_t;
117#define MINSIGSTKSZ 2048 117#define MINSIGSTKSZ 2048
118#define SIGSTKSZ 8192 118#define SIGSTKSZ 8192
119 119
120#ifdef __KERNEL__ 120#include <asm-generic/signal.h>
121
122/*
123 * These values of sa_flags are used only by the kernel as part of the
124 * irq handling routines.
125 *
126 * SA_INTERRUPT is also used by the irq handling routines.
127 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
128 */
129#define SA_PROBE SA_ONESHOT
130#define SA_SAMPLE_RANDOM SA_RESTART
131#define SA_SHIRQ 0x04000000
132#endif
133
134#define SIG_BLOCK 0 /* for blocking signals */
135#define SIG_UNBLOCK 1 /* for unblocking signals */
136#define SIG_SETMASK 2 /* for setting the signal mask */
137
138/* Type of a signal handler. */
139typedef void (*__sighandler_t)(int);
140
141#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
142#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
143#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
144 121
145#ifdef __KERNEL__ 122#ifdef __KERNEL__
146struct old_sigaction { 123struct old_sigaction {
diff --git a/include/asm-sh/bug.h b/include/asm-sh/bug.h
index 70172217140f..70508a360cd6 100644
--- a/include/asm-sh/bug.h
+++ b/include/asm-sh/bug.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5 5
6#ifdef CONFIG_BUG
6/* 7/*
7 * Tell the user there is some problem. 8 * Tell the user there is some problem.
8 */ 9 */
@@ -12,6 +13,8 @@
12} while (0) 13} while (0)
13 14
14#define HAVE_ARCH_BUG 15#define HAVE_ARCH_BUG
16#endif
17
15#include <asm-generic/bug.h> 18#include <asm-generic/bug.h>
16 19
17#endif 20#endif
diff --git a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h
index 5113c7f8a739..5ebd0f24299e 100644
--- a/include/asm-sh/checksum.h
+++ b/include/asm-sh/checksum.h
@@ -42,7 +42,7 @@ asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsi
42 * passed in an incorrect kernel address to one of these functions. 42 * passed in an incorrect kernel address to one of these functions.
43 * 43 *
44 * If you use these functions directly please don't forget the 44 * If you use these functions directly please don't forget the
45 * verify_area(). 45 * access_ok().
46 */ 46 */
47static __inline__ 47static __inline__
48unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, 48unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst,
diff --git a/include/asm-sh/floppy.h b/include/asm-sh/floppy.h
index f030ca08052b..38d7a2942476 100644
--- a/include/asm-sh/floppy.h
+++ b/include/asm-sh/floppy.h
@@ -227,7 +227,7 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
227 return 0; 227 return 0;
228} 228}
229 229
230struct fd_routine_l { 230static struct fd_routine_l {
231 int (*_request_dma)(unsigned int dmanr, const char * device_id); 231 int (*_request_dma)(unsigned int dmanr, const char * device_id);
232 void (*_free_dma)(unsigned int dmanr); 232 void (*_free_dma)(unsigned int dmanr);
233 int (*_get_dma_residue)(unsigned int dummy); 233 int (*_get_dma_residue)(unsigned int dummy);
diff --git a/include/asm-sh/signal.h b/include/asm-sh/signal.h
index 0a7ff717c245..d6e8eb0e65c7 100644
--- a/include/asm-sh/signal.h
+++ b/include/asm-sh/signal.h
@@ -108,30 +108,7 @@ typedef unsigned long sigset_t;
108#define MINSIGSTKSZ 2048 108#define MINSIGSTKSZ 2048
109#define SIGSTKSZ 8192 109#define SIGSTKSZ 8192
110 110
111#ifdef __KERNEL__ 111#include <asm-generic/signal.h>
112
113/*
114 * These values of sa_flags are used only by the kernel as part of the
115 * irq handling routines.
116 *
117 * SA_INTERRUPT is also used by the irq handling routines.
118 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
119 */
120#define SA_PROBE SA_ONESHOT
121#define SA_SAMPLE_RANDOM SA_RESTART
122#define SA_SHIRQ 0x04000000
123#endif
124
125#define SIG_BLOCK 0 /* for blocking signals */
126#define SIG_UNBLOCK 1 /* for unblocking signals */
127#define SIG_SETMASK 2 /* for setting the signal mask */
128
129/* Type of a signal handler. */
130typedef void (*__sighandler_t)(int);
131
132#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
133#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
134#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
135 112
136#ifdef __KERNEL__ 113#ifdef __KERNEL__
137struct old_sigaction { 114struct old_sigaction {
diff --git a/include/asm-sh64/bug.h b/include/asm-sh64/bug.h
index 3acd54d59566..5d659ec28e10 100644
--- a/include/asm-sh64/bug.h
+++ b/include/asm-sh64/bug.h
@@ -17,10 +17,6 @@
17 BUG(); \ 17 BUG(); \
18} while(0) 18} while(0)
19 19
20#define PAGE_BUG(page) do { \
21 BUG(); \
22} while (0)
23
24#define WARN_ON(condition) do { \ 20#define WARN_ON(condition) do { \
25 if (unlikely((condition)!=0)) { \ 21 if (unlikely((condition)!=0)) { \
26 printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ 22 printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
diff --git a/include/asm-sh64/checksum.h b/include/asm-sh64/checksum.h
index aa3911a99490..fd034e9ae6e3 100644
--- a/include/asm-sh64/checksum.h
+++ b/include/asm-sh64/checksum.h
@@ -34,7 +34,7 @@ asmlinkage unsigned int csum_partial(const unsigned char *buff, int len,
34 * passed in an incorrect kernel address to one of these functions. 34 * passed in an incorrect kernel address to one of these functions.
35 * 35 *
36 * If you use these functions directly please don't forget the 36 * If you use these functions directly please don't forget the
37 * verify_area(). 37 * access_ok().
38 */ 38 */
39 39
40 40
diff --git a/include/asm-sh64/signal.h b/include/asm-sh64/signal.h
index 77957e9b92d9..2400dc688a65 100644
--- a/include/asm-sh64/signal.h
+++ b/include/asm-sh64/signal.h
@@ -107,30 +107,7 @@ typedef struct {
107#define MINSIGSTKSZ 2048 107#define MINSIGSTKSZ 2048
108#define SIGSTKSZ THREAD_SIZE 108#define SIGSTKSZ THREAD_SIZE
109 109
110#ifdef __KERNEL__ 110#include <asm-generic/signal.h>
111
112/*
113 * These values of sa_flags are used only by the kernel as part of the
114 * irq handling routines.
115 *
116 * SA_INTERRUPT is also used by the irq handling routines.
117 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
118 */
119#define SA_PROBE SA_ONESHOT
120#define SA_SAMPLE_RANDOM SA_RESTART
121#define SA_SHIRQ 0x04000000
122#endif
123
124#define SIG_BLOCK 0 /* for blocking signals */
125#define SIG_UNBLOCK 1 /* for unblocking signals */
126#define SIG_SETMASK 2 /* for setting the signal mask */
127
128/* Type of a signal handler. */
129typedef void (*__sighandler_t)(int);
130
131#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
132#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
133#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
134 111
135#ifdef __KERNEL__ 112#ifdef __KERNEL__
136struct old_sigaction { 113struct old_sigaction {
diff --git a/include/asm-sparc/bug.h b/include/asm-sparc/bug.h
index 0d30a67d87a3..04151208189f 100644
--- a/include/asm-sparc/bug.h
+++ b/include/asm-sparc/bug.h
@@ -1,6 +1,7 @@
1#ifndef _SPARC_BUG_H 1#ifndef _SPARC_BUG_H
2#define _SPARC_BUG_H 2#define _SPARC_BUG_H
3 3
4#ifdef CONFIG_BUG
4/* Only use the inline asm until a gcc release that can handle __builtin_trap 5/* Only use the inline asm until a gcc release that can handle __builtin_trap
5 * -rob 2003-06-25 6 * -rob 2003-06-25
6 * 7 *
@@ -26,6 +27,8 @@ extern void do_BUG(const char *file, int line);
26#endif 27#endif
27 28
28#define HAVE_ARCH_BUG 29#define HAVE_ARCH_BUG
30#endif
31
29#include <asm-generic/bug.h> 32#include <asm-generic/bug.h>
30 33
31#endif 34#endif
diff --git a/include/asm-sparc/errno.h b/include/asm-sparc/errno.h
index 8c01c5f3b06d..ed41c8bac1fa 100644
--- a/include/asm-sparc/errno.h
+++ b/include/asm-sparc/errno.h
@@ -107,4 +107,8 @@
107#define EKEYREVOKED 130 /* Key has been revoked */ 107#define EKEYREVOKED 130 /* Key has been revoked */
108#define EKEYREJECTED 131 /* Key was rejected by service */ 108#define EKEYREJECTED 131 /* Key was rejected by service */
109 109
110/* for robust mutexes */
111#define EOWNERDEAD 132 /* Owner died */
112#define ENOTRECOVERABLE 133 /* State not recoverable */
113
110#endif 114#endif
diff --git a/include/asm-sparc/floppy.h b/include/asm-sparc/floppy.h
index 780ee7ff9dc3..caf926116506 100644
--- a/include/asm-sparc/floppy.h
+++ b/include/asm-sparc/floppy.h
@@ -227,7 +227,7 @@ static __inline__ void sun_fd_disable_dma(void)
227 doing_pdma = 0; 227 doing_pdma = 0;
228 if (pdma_base) { 228 if (pdma_base) {
229 mmu_unlockarea(pdma_base, pdma_areasize); 229 mmu_unlockarea(pdma_base, pdma_areasize);
230 pdma_base = 0; 230 pdma_base = NULL;
231 } 231 }
232} 232}
233 233
diff --git a/include/asm-sparc/mxcc.h b/include/asm-sparc/mxcc.h
index efe4e843122d..60ef9d6fe7bc 100644
--- a/include/asm-sparc/mxcc.h
+++ b/include/asm-sparc/mxcc.h
@@ -115,8 +115,8 @@ extern __inline__ unsigned long mxcc_get_creg(void)
115{ 115{
116 unsigned long mxcc_control; 116 unsigned long mxcc_control;
117 117
118 __asm__ __volatile__("set -1, %%g2\n\t" 118 __asm__ __volatile__("set 0xffffffff, %%g2\n\t"
119 "set -1, %%g3\n\t" 119 "set 0xffffffff, %%g3\n\t"
120 "stda %%g2, [%1] %2\n\t" 120 "stda %%g2, [%1] %2\n\t"
121 "lda [%3] %2, %0\n\t" : 121 "lda [%3] %2, %0\n\t" :
122 "=r" (mxcc_control) : 122 "=r" (mxcc_control) :
diff --git a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h
index d8211cb6e6b4..aa9960ad0ca9 100644
--- a/include/asm-sparc/signal.h
+++ b/include/asm-sparc/signal.h
@@ -143,7 +143,6 @@ struct sigstack {
143#define SA_ONESHOT _SV_RESET 143#define SA_ONESHOT _SV_RESET
144#define SA_INTERRUPT 0x10u 144#define SA_INTERRUPT 0x10u
145#define SA_NOMASK 0x20u 145#define SA_NOMASK 0x20u
146#define SA_SHIRQ 0x40u
147#define SA_NOCLDWAIT 0x100u 146#define SA_NOCLDWAIT 0x100u
148#define SA_SIGINFO 0x200u 147#define SA_SIGINFO 0x200u
149 148
@@ -162,11 +161,6 @@ struct sigstack {
162 161
163#ifdef __KERNEL__ 162#ifdef __KERNEL__
164/* 163/*
165 * These values of sa_flags are used only by the kernel as part of the
166 * irq handling routines.
167 *
168 * SA_INTERRUPT is also used by the irq handling routines.
169 *
170 * DJHR 164 * DJHR
171 * SA_STATIC_ALLOC is used for the SPARC system to indicate that this 165 * SA_STATIC_ALLOC is used for the SPARC system to indicate that this
172 * interrupt handler's irq structure should be statically allocated 166 * interrupt handler's irq structure should be statically allocated
@@ -177,21 +171,10 @@ struct sigstack {
177 * statically allocated data.. which is NOT GOOD. 171 * statically allocated data.. which is NOT GOOD.
178 * 172 *
179 */ 173 */
180#define SA_PROBE SA_ONESHOT
181#define SA_SAMPLE_RANDOM SA_RESTART
182#define SA_STATIC_ALLOC 0x80 174#define SA_STATIC_ALLOC 0x80
183#endif 175#endif
184 176
185/* Type of a signal handler. */ 177#include <asm-generic/signal.h>
186#ifdef __KERNEL__
187typedef void (*__sighandler_t)(int, int, struct sigcontext *, char *);
188#else
189typedef void (*__sighandler_t)(int);
190#endif
191
192#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
193#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
194#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
195 178
196#ifdef __KERNEL__ 179#ifdef __KERNEL__
197struct __new_sigaction { 180struct __new_sigaction {
diff --git a/include/asm-sparc/uaccess.h b/include/asm-sparc/uaccess.h
index 3f47889883b7..f461144067ee 100644
--- a/include/asm-sparc/uaccess.h
+++ b/include/asm-sparc/uaccess.h
@@ -18,7 +18,7 @@
18 18
19#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
20 20
21/* Sparc is not segmented, however we need to be able to fool verify_area() 21/* Sparc is not segmented, however we need to be able to fool access_ok()
22 * when doing system calls from kernel mode legitimately. 22 * when doing system calls from kernel mode legitimately.
23 * 23 *
24 * "For historical reasons, these macros are grossly misnamed." -Linus 24 * "For historical reasons, these macros are grossly misnamed." -Linus
diff --git a/include/asm-sparc64/bug.h b/include/asm-sparc64/bug.h
index 25c5b1dfe378..516bb27f3fc4 100644
--- a/include/asm-sparc64/bug.h
+++ b/include/asm-sparc64/bug.h
@@ -1,6 +1,7 @@
1#ifndef _SPARC64_BUG_H 1#ifndef _SPARC64_BUG_H
2#define _SPARC64_BUG_H 2#define _SPARC64_BUG_H
3 3
4#ifdef CONFIG_BUG
4#include <linux/compiler.h> 5#include <linux/compiler.h>
5 6
6#ifdef CONFIG_DEBUG_BUGVERBOSE 7#ifdef CONFIG_DEBUG_BUGVERBOSE
@@ -14,6 +15,8 @@ extern void do_BUG(const char *file, int line);
14#endif 15#endif
15 16
16#define HAVE_ARCH_BUG 17#define HAVE_ARCH_BUG
18#endif
19
17#include <asm-generic/bug.h> 20#include <asm-generic/bug.h>
18 21
19#endif 22#endif
diff --git a/include/asm-sparc64/errno.h b/include/asm-sparc64/errno.h
index cc98a73b55a7..ea3509ee1b0b 100644
--- a/include/asm-sparc64/errno.h
+++ b/include/asm-sparc64/errno.h
@@ -107,4 +107,8 @@
107#define EKEYREVOKED 130 /* Key has been revoked */ 107#define EKEYREVOKED 130 /* Key has been revoked */
108#define EKEYREJECTED 131 /* Key was rejected by service */ 108#define EKEYREJECTED 131 /* Key was rejected by service */
109 109
110/* for robust mutexes */
111#define EOWNERDEAD 132 /* Owner died */
112#define ENOTRECOVERABLE 133 /* State not recoverable */
113
110#endif /* !(_SPARC64_ERRNO_H) */ 114#endif /* !(_SPARC64_ERRNO_H) */
diff --git a/include/asm-sparc64/mostek.h b/include/asm-sparc64/mostek.h
index ccf2f5f82d7f..09b5aba6678a 100644
--- a/include/asm-sparc64/mostek.h
+++ b/include/asm-sparc64/mostek.h
@@ -38,7 +38,7 @@
38 * 38 *
39 * We now deal with physical addresses for I/O to the chip. -DaveM 39 * We now deal with physical addresses for I/O to the chip. -DaveM
40 */ 40 */
41static __inline__ u8 mostek_read(unsigned long addr) 41static __inline__ u8 mostek_read(void __iomem *addr)
42{ 42{
43 u8 ret; 43 u8 ret;
44 44
@@ -48,7 +48,7 @@ static __inline__ u8 mostek_read(unsigned long addr)
48 return ret; 48 return ret;
49} 49}
50 50
51static __inline__ void mostek_write(unsigned long addr, u8 val) 51static __inline__ void mostek_write(void __iomem *addr, u8 val)
52{ 52{
53 __asm__ __volatile__("stba %0, [%1] %2" 53 __asm__ __volatile__("stba %0, [%1] %2"
54 : /* no outputs */ 54 : /* no outputs */
@@ -67,7 +67,7 @@ static __inline__ void mostek_write(unsigned long addr, u8 val)
67#define MOSTEK_YEAR 0x07ffUL 67#define MOSTEK_YEAR 0x07ffUL
68 68
69extern spinlock_t mostek_lock; 69extern spinlock_t mostek_lock;
70extern unsigned long mstk48t02_regs; 70extern void __iomem *mstk48t02_regs;
71 71
72/* Control register values. */ 72/* Control register values. */
73#define MSTK_CREG_WRITE 0x80 /* Must set this before placing values. */ 73#define MSTK_CREG_WRITE 0x80 /* Must set this before placing values. */
diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h
index ab88349ddadc..b7e635544cec 100644
--- a/include/asm-sparc64/parport.h
+++ b/include/asm-sparc64/parport.h
@@ -13,6 +13,12 @@
13 13
14#define PARPORT_PC_MAX_PORTS PARPORT_MAX 14#define PARPORT_PC_MAX_PORTS PARPORT_MAX
15 15
16/*
17 * While sparc64 doesn't have an ISA DMA API, we provide something that looks
18 * close enough to make parport_pc happy
19 */
20#define HAS_DMA
21
16static struct sparc_ebus_info { 22static struct sparc_ebus_info {
17 struct ebus_dma_info info; 23 struct ebus_dma_info info;
18 unsigned int addr; 24 unsigned int addr;
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
index 2c28e1f605b7..b9b1914aae63 100644
--- a/include/asm-sparc64/pgalloc.h
+++ b/include/asm-sparc64/pgalloc.h
@@ -122,17 +122,12 @@ static __inline__ void free_pmd_slow(pmd_t *pmd)
122#define pmd_populate(MM,PMD,PTE_PAGE) \ 122#define pmd_populate(MM,PMD,PTE_PAGE) \
123 pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) 123 pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
124 124
125extern pte_t *__pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address); 125extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address);
126
127static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
128{
129 return __pte_alloc_one_kernel(mm, address);
130}
131 126
132static inline struct page * 127static inline struct page *
133pte_alloc_one(struct mm_struct *mm, unsigned long addr) 128pte_alloc_one(struct mm_struct *mm, unsigned long addr)
134{ 129{
135 pte_t *pte = __pte_alloc_one_kernel(mm, addr); 130 pte_t *pte = pte_alloc_one_kernel(mm, addr);
136 131
137 if (pte) 132 if (pte)
138 return virt_to_page(pte); 133 return virt_to_page(pte);
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
index af9bf175a223..ae2cd5b09a7c 100644
--- a/include/asm-sparc64/pgtable.h
+++ b/include/asm-sparc64/pgtable.h
@@ -416,6 +416,11 @@ extern int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
416 unsigned long pfn, 416 unsigned long pfn,
417 unsigned long size, pgprot_t prot); 417 unsigned long size, pgprot_t prot);
418 418
419/* Clear virtual and physical cachability, set side-effect bit. */
420#define pgprot_noncached(prot) \
421 (__pgprot((pgprot_val(prot) & ~(_PAGE_CP | _PAGE_CV)) | \
422 _PAGE_E))
423
419/* 424/*
420 * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in 425 * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in
421 * its high 4 bits. These macros/functions put it there or get it from there. 426 * its high 4 bits. These macros/functions put it there or get it from there.
diff --git a/include/asm-sparc64/siginfo.h b/include/asm-sparc64/siginfo.h
index 7160449e7cab..df17e47abc1c 100644
--- a/include/asm-sparc64/siginfo.h
+++ b/include/asm-sparc64/siginfo.h
@@ -3,8 +3,6 @@
3 3
4#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3) 4#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
5 5
6#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
7
8#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) 6#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
9#define __ARCH_SI_TRAPNO 7#define __ARCH_SI_TRAPNO
10#define __ARCH_SI_BAND_T int 8#define __ARCH_SI_BAND_T int
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
index 6428e366c38c..becdf1bc5924 100644
--- a/include/asm-sparc64/signal.h
+++ b/include/asm-sparc64/signal.h
@@ -145,7 +145,6 @@ struct sigstack {
145#define SA_ONESHOT _SV_RESET 145#define SA_ONESHOT _SV_RESET
146#define SA_INTERRUPT 0x10u 146#define SA_INTERRUPT 0x10u
147#define SA_NOMASK 0x20u 147#define SA_NOMASK 0x20u
148#define SA_SHIRQ 0x40u
149#define SA_NOCLDWAIT 0x100u 148#define SA_NOCLDWAIT 0x100u
150#define SA_SIGINFO 0x200u 149#define SA_SIGINFO 0x200u
151 150
@@ -165,11 +164,6 @@ struct sigstack {
165 164
166#ifdef __KERNEL__ 165#ifdef __KERNEL__
167/* 166/*
168 * These values of sa_flags are used only by the kernel as part of the
169 * irq handling routines.
170 *
171 * SA_INTERRUPT is also used by the irq handling routines.
172 *
173 * DJHR 167 * DJHR
174 * SA_STATIC_ALLOC is used for the SPARC system to indicate that this 168 * SA_STATIC_ALLOC is used for the SPARC system to indicate that this
175 * interrupt handler's irq structure should be statically allocated 169 * interrupt handler's irq structure should be statically allocated
@@ -180,26 +174,10 @@ struct sigstack {
180 * statically allocated data.. which is NOT GOOD. 174 * statically allocated data.. which is NOT GOOD.
181 * 175 *
182 */ 176 */
183#define SA_PROBE SA_ONESHOT
184#define SA_SAMPLE_RANDOM SA_RESTART
185#define SA_STATIC_ALLOC 0x80 177#define SA_STATIC_ALLOC 0x80
186#endif 178#endif
187 179
188/* Type of a signal handler. */ 180#include <asm-generic/signal.h>
189#ifdef __KERNEL__
190typedef void __signalfn_t(int);
191typedef __signalfn_t __user *__sighandler_t;
192
193typedef void __restorefn_t(void);
194typedef __restorefn_t __user *__sigrestore_t;
195#else
196typedef void (*__sighandler_t)(int);
197typedef void (*__sigrestore_t)(void);
198#endif
199
200#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
201#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
202#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
203 181
204struct __new_sigaction { 182struct __new_sigaction {
205 __sighandler_t sa_handler; 183 __sighandler_t sa_handler;
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h
index d1f91a4f24ae..db7581bdb531 100644
--- a/include/asm-sparc64/spinlock.h
+++ b/include/asm-sparc64/spinlock.h
@@ -44,7 +44,7 @@ typedef struct {
44 44
45#define spin_unlock_wait(lp) \ 45#define spin_unlock_wait(lp) \
46do { membar("#LoadLoad"); \ 46do { membar("#LoadLoad"); \
47} while(lp->lock) 47} while((lp)->lock)
48 48
49static inline void _raw_spin_lock(spinlock_t *lock) 49static inline void _raw_spin_lock(spinlock_t *lock)
50{ 50{
@@ -149,7 +149,7 @@ typedef struct {
149 unsigned int break_lock; 149 unsigned int break_lock;
150#endif 150#endif
151} rwlock_t; 151} rwlock_t;
152#define RW_LOCK_UNLOCKED {0,} 152#define RW_LOCK_UNLOCKED (rwlock_t) {0,}
153#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) 153#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
154 154
155static void inline __read_lock(rwlock_t *lock) 155static void inline __read_lock(rwlock_t *lock)
diff --git a/include/asm-um/arch-signal-i386.h b/include/asm-um/arch-signal-i386.h
index 99a9de4728da..e69de29bb2d1 100644
--- a/include/asm-um/arch-signal-i386.h
+++ b/include/asm-um/arch-signal-i386.h
@@ -1,24 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __UM_ARCH_SIGNAL_I386_H
7#define __UM_ARCH_SIGNAL_I386_H
8
9struct arch_signal_context {
10 unsigned long extrasigs[_NSIG_WORDS];
11};
12
13#endif
14
15/*
16 * Overrides for Emacs so that we follow Linus's tabbing style.
17 * Emacs will notice this stuff at the end of the file and automatically
18 * adjust the settings for this buffer only. This must remain at the end
19 * of the file.
20 * ---------------------------------------------------------------------------
21 * Local variables:
22 * c-file-style: "linux"
23 * End:
24 */
diff --git a/include/asm-um/archparam-i386.h b/include/asm-um/archparam-i386.h
index 6f78de5b621b..49e89b8d7e58 100644
--- a/include/asm-um/archparam-i386.h
+++ b/include/asm-um/archparam-i386.h
@@ -6,143 +6,6 @@
6#ifndef __UM_ARCHPARAM_I386_H 6#ifndef __UM_ARCHPARAM_I386_H
7#define __UM_ARCHPARAM_I386_H 7#define __UM_ARCHPARAM_I386_H
8 8
9/********* Bits for asm-um/elf.h ************/
10
11#include <asm/user.h>
12
13extern char * elf_aux_platform;
14#define ELF_PLATFORM (elf_aux_platform)
15
16#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
17
18typedef struct user_i387_struct elf_fpregset_t;
19typedef unsigned long elf_greg_t;
20
21#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
22typedef elf_greg_t elf_gregset_t[ELF_NGREG];
23
24#define ELF_DATA ELFDATA2LSB
25#define ELF_ARCH EM_386
26
27#define ELF_PLAT_INIT(regs, load_addr) do { \
28 PT_REGS_EBX(regs) = 0; \
29 PT_REGS_ECX(regs) = 0; \
30 PT_REGS_EDX(regs) = 0; \
31 PT_REGS_ESI(regs) = 0; \
32 PT_REGS_EDI(regs) = 0; \
33 PT_REGS_EBP(regs) = 0; \
34 PT_REGS_EAX(regs) = 0; \
35} while(0)
36
37/* Shamelessly stolen from include/asm-i386/elf.h */
38
39#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
40 pr_reg[0] = PT_REGS_EBX(regs); \
41 pr_reg[1] = PT_REGS_ECX(regs); \
42 pr_reg[2] = PT_REGS_EDX(regs); \
43 pr_reg[3] = PT_REGS_ESI(regs); \
44 pr_reg[4] = PT_REGS_EDI(regs); \
45 pr_reg[5] = PT_REGS_EBP(regs); \
46 pr_reg[6] = PT_REGS_EAX(regs); \
47 pr_reg[7] = PT_REGS_DS(regs); \
48 pr_reg[8] = PT_REGS_ES(regs); \
49 /* fake once used fs and gs selectors? */ \
50 pr_reg[9] = PT_REGS_DS(regs); \
51 pr_reg[10] = PT_REGS_DS(regs); \
52 pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \
53 pr_reg[12] = PT_REGS_IP(regs); \
54 pr_reg[13] = PT_REGS_CS(regs); \
55 pr_reg[14] = PT_REGS_EFLAGS(regs); \
56 pr_reg[15] = PT_REGS_SP(regs); \
57 pr_reg[16] = PT_REGS_SS(regs); \
58} while(0);
59
60
61extern unsigned long vsyscall_ehdr;
62extern unsigned long vsyscall_end;
63extern unsigned long __kernel_vsyscall;
64
65#define VSYSCALL_BASE vsyscall_ehdr
66#define VSYSCALL_END vsyscall_end
67
68/*
69 * This is the range that is readable by user mode, and things
70 * acting like user mode such as get_user_pages.
71 */
72#define FIXADDR_USER_START VSYSCALL_BASE
73#define FIXADDR_USER_END VSYSCALL_END
74
75/*
76 * Architecture-neutral AT_ values in 0-17, leave some room
77 * for more of them, start the x86-specific ones at 32.
78 */
79#define AT_SYSINFO 32
80#define AT_SYSINFO_EHDR 33
81
82#define ARCH_DLINFO \
83do { \
84 if ( vsyscall_ehdr ) { \
85 NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \
86 NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr); \
87 } \
88} while (0)
89
90/*
91 * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
92 * extra segments containing the vsyscall DSO contents. Dumping its
93 * contents makes post-mortem fully interpretable later without matching up
94 * the same kernel and hardware config to see what PC values meant.
95 * Dumping its extra ELF program headers includes all the other information
96 * a debugger needs to easily find how the vsyscall DSO was being used.
97 */
98#define ELF_CORE_EXTRA_PHDRS \
99 (vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0 )
100
101#define ELF_CORE_WRITE_EXTRA_PHDRS \
102if ( vsyscall_ehdr ) { \
103 const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \
104 const struct elf_phdr *const phdrp = \
105 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \
106 int i; \
107 Elf32_Off ofs = 0; \
108 for (i = 0; i < ehdrp->e_phnum; ++i) { \
109 struct elf_phdr phdr = phdrp[i]; \
110 if (phdr.p_type == PT_LOAD) { \
111 ofs = phdr.p_offset = offset; \
112 offset += phdr.p_filesz; \
113 } \
114 else \
115 phdr.p_offset += ofs; \
116 phdr.p_paddr = 0; /* match other core phdrs */ \
117 DUMP_WRITE(&phdr, sizeof(phdr)); \
118 } \
119}
120#define ELF_CORE_WRITE_EXTRA_DATA \
121if ( vsyscall_ehdr ) { \
122 const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \
123 const struct elf_phdr *const phdrp = \
124 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \
125 int i; \
126 for (i = 0; i < ehdrp->e_phnum; ++i) { \
127 if (phdrp[i].p_type == PT_LOAD) \
128 DUMP_WRITE((void *) phdrp[i].p_vaddr, \
129 phdrp[i].p_filesz); \
130 } \
131}
132
133#define R_386_NONE 0
134#define R_386_32 1
135#define R_386_PC32 2
136#define R_386_GOT32 3
137#define R_386_PLT32 4
138#define R_386_COPY 5
139#define R_386_GLOB_DAT 6
140#define R_386_JMP_SLOT 7
141#define R_386_RELATIVE 8
142#define R_386_GOTOFF 9
143#define R_386_GOTPC 10
144#define R_386_NUM 11
145
146/********* Nothing for asm-um/hardirq.h **********/ 9/********* Nothing for asm-um/hardirq.h **********/
147 10
148/********* Nothing for asm-um/hw_irq.h **********/ 11/********* Nothing for asm-um/hw_irq.h **********/
diff --git a/include/asm-um/archparam-ppc.h b/include/asm-um/archparam-ppc.h
index 0ebced92a762..172cd6ffacc4 100644
--- a/include/asm-um/archparam-ppc.h
+++ b/include/asm-um/archparam-ppc.h
@@ -1,26 +1,6 @@
1#ifndef __UM_ARCHPARAM_PPC_H 1#ifndef __UM_ARCHPARAM_PPC_H
2#define __UM_ARCHPARAM_PPC_H 2#define __UM_ARCHPARAM_PPC_H
3 3
4/********* Bits for asm-um/elf.h ************/
5
6#define ELF_PLATFORM (0)
7
8#define ELF_ET_DYN_BASE (0x08000000)
9
10/* the following stolen from asm-ppc/elf.h */
11#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */
12#define ELF_NFPREG 33 /* includes fpscr */
13/* General registers */
14typedef unsigned long elf_greg_t;
15typedef elf_greg_t elf_gregset_t[ELF_NGREG];
16
17/* Floating point registers */
18typedef double elf_fpreg_t;
19typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
20
21#define ELF_DATA ELFDATA2MSB
22#define ELF_ARCH EM_PPC
23
24/********* Bits for asm-um/hw_irq.h **********/ 4/********* Bits for asm-um/hw_irq.h **********/
25 5
26struct hw_interrupt_type; 6struct hw_interrupt_type;
diff --git a/include/asm-um/archparam-x86_64.h b/include/asm-um/archparam-x86_64.h
index 96321c4892f1..270ed9586b68 100644
--- a/include/asm-um/archparam-x86_64.h
+++ b/include/asm-um/archparam-x86_64.h
@@ -7,42 +7,6 @@
7#ifndef __UM_ARCHPARAM_X86_64_H 7#ifndef __UM_ARCHPARAM_X86_64_H
8#define __UM_ARCHPARAM_X86_64_H 8#define __UM_ARCHPARAM_X86_64_H
9 9
10#include <asm/user.h>
11
12#define ELF_PLATFORM "x86_64"
13
14#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
15
16typedef unsigned long elf_greg_t;
17typedef struct { } elf_fpregset_t;
18
19#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
20typedef elf_greg_t elf_gregset_t[ELF_NGREG];
21
22#define ELF_DATA ELFDATA2LSB
23#define ELF_ARCH EM_X86_64
24
25#define ELF_PLAT_INIT(regs, load_addr) do { \
26 PT_REGS_RBX(regs) = 0; \
27 PT_REGS_RCX(regs) = 0; \
28 PT_REGS_RDX(regs) = 0; \
29 PT_REGS_RSI(regs) = 0; \
30 PT_REGS_RDI(regs) = 0; \
31 PT_REGS_RBP(regs) = 0; \
32 PT_REGS_RAX(regs) = 0; \
33 PT_REGS_R8(regs) = 0; \
34 PT_REGS_R9(regs) = 0; \
35 PT_REGS_R10(regs) = 0; \
36 PT_REGS_R11(regs) = 0; \
37 PT_REGS_R12(regs) = 0; \
38 PT_REGS_R13(regs) = 0; \
39 PT_REGS_R14(regs) = 0; \
40 PT_REGS_R15(regs) = 0; \
41} while (0)
42
43#ifdef TIF_IA32 /* XXX */
44 clear_thread_flag(TIF_IA32);
45#endif
46 10
47/* No user-accessible fixmap addresses, i.e. vsyscall */ 11/* No user-accessible fixmap addresses, i.e. vsyscall */
48#define FIXADDR_USER_START 0 12#define FIXADDR_USER_START 0
diff --git a/include/asm-um/common.lds.S b/include/asm-um/common.lds.S
index a3d6aab0e74d..1010153faaf9 100644
--- a/include/asm-um/common.lds.S
+++ b/include/asm-um/common.lds.S
@@ -8,11 +8,6 @@
8 _sdata = .; 8 _sdata = .;
9 PROVIDE (sdata = .); 9 PROVIDE (sdata = .);
10 10
11 . = ALIGN(16); /* Exception table */
12 __start___ex_table = .;
13 __ex_table : { *(__ex_table) }
14 __stop___ex_table = .;
15
16 RODATA 11 RODATA
17 12
18 .unprotected : { *(.unprotected) } 13 .unprotected : { *(.unprotected) }
@@ -20,6 +15,10 @@
20 PROVIDE (_unprotected_end = .); 15 PROVIDE (_unprotected_end = .);
21 16
22 . = ALIGN(4096); 17 . = ALIGN(4096);
18 __start___ex_table = .;
19 __ex_table : { *(__ex_table) }
20 __stop___ex_table = .;
21
23 __uml_setup_start = .; 22 __uml_setup_start = .;
24 .uml.setup.init : { *(.uml.setup.init) } 23 .uml.setup.init : { *(.uml.setup.init) }
25 __uml_setup_end = .; 24 __uml_setup_end = .;
diff --git a/include/asm-um/delay.h b/include/asm-um/delay.h
index 40695576ca60..0985bda66750 100644
--- a/include/asm-um/delay.h
+++ b/include/asm-um/delay.h
@@ -4,4 +4,6 @@
4#include "asm/arch/delay.h" 4#include "asm/arch/delay.h"
5#include "asm/archparam.h" 5#include "asm/archparam.h"
6 6
7#define MILLION 1000000
8
7#endif 9#endif
diff --git a/include/asm-um/elf-i386.h b/include/asm-um/elf-i386.h
new file mode 100644
index 000000000000..b72e23519e00
--- /dev/null
+++ b/include/asm-um/elf-i386.h
@@ -0,0 +1,169 @@
1/*
2 * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5#ifndef __UM_ELF_I386_H
6#define __UM_ELF_I386_H
7
8#include "user.h"
9
10#define R_386_NONE 0
11#define R_386_32 1
12#define R_386_PC32 2
13#define R_386_GOT32 3
14#define R_386_PLT32 4
15#define R_386_COPY 5
16#define R_386_GLOB_DAT 6
17#define R_386_JMP_SLOT 7
18#define R_386_RELATIVE 8
19#define R_386_GOTOFF 9
20#define R_386_GOTPC 10
21#define R_386_NUM 11
22
23typedef unsigned long elf_greg_t;
24
25#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
26typedef elf_greg_t elf_gregset_t[ELF_NGREG];
27
28typedef struct user_i387_struct elf_fpregset_t;
29
30/*
31 * This is used to ensure we don't load something for the wrong architecture.
32 */
33#define elf_check_arch(x) \
34 (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
35
36#define ELF_CLASS ELFCLASS32
37#define ELF_DATA ELFDATA2LSB
38#define ELF_ARCH EM_386
39
40#define ELF_PLAT_INIT(regs, load_addr) do { \
41 PT_REGS_EBX(regs) = 0; \
42 PT_REGS_ECX(regs) = 0; \
43 PT_REGS_EDX(regs) = 0; \
44 PT_REGS_ESI(regs) = 0; \
45 PT_REGS_EDI(regs) = 0; \
46 PT_REGS_EBP(regs) = 0; \
47 PT_REGS_EAX(regs) = 0; \
48} while(0)
49
50#define USE_ELF_CORE_DUMP
51#define ELF_EXEC_PAGESIZE 4096
52
53#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
54
55/* Shamelessly stolen from include/asm-i386/elf.h */
56
57#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
58 pr_reg[0] = PT_REGS_EBX(regs); \
59 pr_reg[1] = PT_REGS_ECX(regs); \
60 pr_reg[2] = PT_REGS_EDX(regs); \
61 pr_reg[3] = PT_REGS_ESI(regs); \
62 pr_reg[4] = PT_REGS_EDI(regs); \
63 pr_reg[5] = PT_REGS_EBP(regs); \
64 pr_reg[6] = PT_REGS_EAX(regs); \
65 pr_reg[7] = PT_REGS_DS(regs); \
66 pr_reg[8] = PT_REGS_ES(regs); \
67 /* fake once used fs and gs selectors? */ \
68 pr_reg[9] = PT_REGS_DS(regs); \
69 pr_reg[10] = PT_REGS_DS(regs); \
70 pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \
71 pr_reg[12] = PT_REGS_IP(regs); \
72 pr_reg[13] = PT_REGS_CS(regs); \
73 pr_reg[14] = PT_REGS_EFLAGS(regs); \
74 pr_reg[15] = PT_REGS_SP(regs); \
75 pr_reg[16] = PT_REGS_SS(regs); \
76} while(0);
77
78extern long elf_aux_hwcap;
79#define ELF_HWCAP (elf_aux_hwcap)
80
81extern char * elf_aux_platform;
82#define ELF_PLATFORM (elf_aux_platform)
83
84#define SET_PERSONALITY(ex, ibcs2) do ; while(0)
85
86extern unsigned long vsyscall_ehdr;
87extern unsigned long vsyscall_end;
88extern unsigned long __kernel_vsyscall;
89
90#define VSYSCALL_BASE vsyscall_ehdr
91#define VSYSCALL_END vsyscall_end
92
93/*
94 * This is the range that is readable by user mode, and things
95 * acting like user mode such as get_user_pages.
96 */
97#define FIXADDR_USER_START VSYSCALL_BASE
98#define FIXADDR_USER_END VSYSCALL_END
99
100/*
101 * Architecture-neutral AT_ values in 0-17, leave some room
102 * for more of them, start the x86-specific ones at 32.
103 */
104#define AT_SYSINFO 32
105#define AT_SYSINFO_EHDR 33
106
107#define ARCH_DLINFO \
108do { \
109 if ( vsyscall_ehdr ) { \
110 NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \
111 NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr); \
112 } \
113} while (0)
114
115/*
116 * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
117 * extra segments containing the vsyscall DSO contents. Dumping its
118 * contents makes post-mortem fully interpretable later without matching up
119 * the same kernel and hardware config to see what PC values meant.
120 * Dumping its extra ELF program headers includes all the other information
121 * a debugger needs to easily find how the vsyscall DSO was being used.
122 */
123#define ELF_CORE_EXTRA_PHDRS \
124 (vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0 )
125
126#define ELF_CORE_WRITE_EXTRA_PHDRS \
127if ( vsyscall_ehdr ) { \
128 const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \
129 const struct elf_phdr *const phdrp = \
130 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \
131 int i; \
132 Elf32_Off ofs = 0; \
133 for (i = 0; i < ehdrp->e_phnum; ++i) { \
134 struct elf_phdr phdr = phdrp[i]; \
135 if (phdr.p_type == PT_LOAD) { \
136 ofs = phdr.p_offset = offset; \
137 offset += phdr.p_filesz; \
138 } \
139 else \
140 phdr.p_offset += ofs; \
141 phdr.p_paddr = 0; /* match other core phdrs */ \
142 DUMP_WRITE(&phdr, sizeof(phdr)); \
143 } \
144}
145#define ELF_CORE_WRITE_EXTRA_DATA \
146if ( vsyscall_ehdr ) { \
147 const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \
148 const struct elf_phdr *const phdrp = \
149 (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \
150 int i; \
151 for (i = 0; i < ehdrp->e_phnum; ++i) { \
152 if (phdrp[i].p_type == PT_LOAD) \
153 DUMP_WRITE((void *) phdrp[i].p_vaddr, \
154 phdrp[i].p_filesz); \
155 } \
156}
157
158#endif
159
160/*
161 * Overrides for Emacs so that we follow Linus's tabbing style.
162 * Emacs will notice this stuff at the end of the file and automatically
163 * adjust the settings for this buffer only. This must remain at the end
164 * of the file.
165 * ---------------------------------------------------------------------------
166 * Local variables:
167 * c-file-style: "linux"
168 * End:
169 */
diff --git a/include/asm-um/elf-ppc.h b/include/asm-um/elf-ppc.h
new file mode 100644
index 000000000000..2998cf925042
--- /dev/null
+++ b/include/asm-um/elf-ppc.h
@@ -0,0 +1,54 @@
1#ifndef __UM_ELF_PPC_H
2#define __UM_ELF_PPC_H
3
4#include "linux/config.h"
5
6extern long elf_aux_hwcap;
7#define ELF_HWCAP (elf_aux_hwcap)
8
9#define SET_PERSONALITY(ex, ibcs2) do ; while(0)
10
11#define ELF_EXEC_PAGESIZE 4096
12
13#define elf_check_arch(x) (1)
14
15#ifdef CONFIG_64_BIT
16#define ELF_CLASS ELFCLASS64
17#else
18#define ELF_CLASS ELFCLASS32
19#endif
20
21#define USE_ELF_CORE_DUMP
22
23#define R_386_NONE 0
24#define R_386_32 1
25#define R_386_PC32 2
26#define R_386_GOT32 3
27#define R_386_PLT32 4
28#define R_386_COPY 5
29#define R_386_GLOB_DAT 6
30#define R_386_JMP_SLOT 7
31#define R_386_RELATIVE 8
32#define R_386_GOTOFF 9
33#define R_386_GOTPC 10
34#define R_386_NUM 11
35
36#define ELF_PLATFORM (0)
37
38#define ELF_ET_DYN_BASE (0x08000000)
39
40/* the following stolen from asm-ppc/elf.h */
41#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */
42#define ELF_NFPREG 33 /* includes fpscr */
43/* General registers */
44typedef unsigned long elf_greg_t;
45typedef elf_greg_t elf_gregset_t[ELF_NGREG];
46
47/* Floating point registers */
48typedef double elf_fpreg_t;
49typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
50
51#define ELF_DATA ELFDATA2MSB
52#define ELF_ARCH EM_PPC
53
54#endif
diff --git a/include/asm-um/elf-x86_64.h b/include/asm-um/elf-x86_64.h
new file mode 100644
index 000000000000..19309d001aa0
--- /dev/null
+++ b/include/asm-um/elf-x86_64.h
@@ -0,0 +1,73 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6#ifndef __UM_ELF_X86_64_H
7#define __UM_ELF_X86_64_H
8
9#include <asm/user.h>
10
11typedef unsigned long elf_greg_t;
12
13#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
14typedef elf_greg_t elf_gregset_t[ELF_NGREG];
15
16typedef struct { } elf_fpregset_t;
17
18/*
19 * This is used to ensure we don't load something for the wrong architecture.
20 */
21#define elf_check_arch(x) \
22 ((x)->e_machine == EM_X86_64)
23
24#define ELF_CLASS ELFCLASS64
25#define ELF_DATA ELFDATA2LSB
26#define ELF_ARCH EM_X86_64
27
28#define ELF_PLAT_INIT(regs, load_addr) do { \
29 PT_REGS_RBX(regs) = 0; \
30 PT_REGS_RCX(regs) = 0; \
31 PT_REGS_RDX(regs) = 0; \
32 PT_REGS_RSI(regs) = 0; \
33 PT_REGS_RDI(regs) = 0; \
34 PT_REGS_RBP(regs) = 0; \
35 PT_REGS_RAX(regs) = 0; \
36 PT_REGS_R8(regs) = 0; \
37 PT_REGS_R9(regs) = 0; \
38 PT_REGS_R10(regs) = 0; \
39 PT_REGS_R11(regs) = 0; \
40 PT_REGS_R12(regs) = 0; \
41 PT_REGS_R13(regs) = 0; \
42 PT_REGS_R14(regs) = 0; \
43 PT_REGS_R15(regs) = 0; \
44} while (0)
45
46#ifdef TIF_IA32 /* XXX */
47 clear_thread_flag(TIF_IA32); \
48#endif
49
50#define USE_ELF_CORE_DUMP
51#define ELF_EXEC_PAGESIZE 4096
52
53#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
54
55extern long elf_aux_hwcap;
56#define ELF_HWCAP (elf_aux_hwcap)
57
58#define ELF_PLATFORM "x86_64"
59
60#define SET_PERSONALITY(ex, ibcs2) do ; while(0)
61
62#endif
63
64/*
65 * Overrides for Emacs so that we follow Linus's tabbing style.
66 * Emacs will notice this stuff at the end of the file and automatically
67 * adjust the settings for this buffer only. This must remain at the end
68 * of the file.
69 * ---------------------------------------------------------------------------
70 * Local variables:
71 * c-file-style: "linux"
72 * End:
73 */
diff --git a/include/asm-um/elf.h b/include/asm-um/elf.h
index b3a7258f9971..e69de29bb2d1 100644
--- a/include/asm-um/elf.h
+++ b/include/asm-um/elf.h
@@ -1,37 +0,0 @@
1#ifndef __UM_ELF_H
2#define __UM_ELF_H
3
4#include "linux/config.h"
5#include "asm/archparam.h"
6
7extern long elf_aux_hwcap;
8#define ELF_HWCAP (elf_aux_hwcap)
9
10#define SET_PERSONALITY(ex, ibcs2) do ; while(0)
11
12#define ELF_EXEC_PAGESIZE 4096
13
14#define elf_check_arch(x) (1)
15
16#ifdef CONFIG_64_BIT
17#define ELF_CLASS ELFCLASS64
18#else
19#define ELF_CLASS ELFCLASS32
20#endif
21
22#define USE_ELF_CORE_DUMP
23
24#define R_386_NONE 0
25#define R_386_32 1
26#define R_386_PC32 2
27#define R_386_GOT32 3
28#define R_386_PLT32 4
29#define R_386_COPY 5
30#define R_386_GLOB_DAT 6
31#define R_386_JMP_SLOT 7
32#define R_386_RELATIVE 8
33#define R_386_GOTOFF 9
34#define R_386_GOTPC 10
35#define R_386_NUM 11
36
37#endif
diff --git a/include/asm-um/fixmap.h b/include/asm-um/fixmap.h
index 900f3fbb9fab..ae0ca3932d50 100644
--- a/include/asm-um/fixmap.h
+++ b/include/asm-um/fixmap.h
@@ -4,6 +4,7 @@
4#include <linux/config.h> 4#include <linux/config.h>
5#include <asm/kmap_types.h> 5#include <asm/kmap_types.h>
6#include <asm/archparam.h> 6#include <asm/archparam.h>
7#include <asm/elf.h>
7 8
8/* 9/*
9 * Here we define all the compile-time 'special' virtual 10 * Here we define all the compile-time 'special' virtual
diff --git a/include/asm-um/ipc.h b/include/asm-um/ipc.h
index e2ddc47f3e52..a46e3d9c2a3f 100644
--- a/include/asm-um/ipc.h
+++ b/include/asm-um/ipc.h
@@ -1,6 +1 @@
1#ifndef __UM_IPC_H #include <asm-generic/ipc.h>
2#define __UM_IPC_H
3
4#include "asm/arch/ipc.h"
5
6#endif
diff --git a/include/asm-um/linkage.h b/include/asm-um/linkage.h
index 27011652b015..7dfce37adc8b 100644
--- a/include/asm-um/linkage.h
+++ b/include/asm-um/linkage.h
@@ -1,7 +1,6 @@
1#ifndef __ASM_LINKAGE_H 1#ifndef __ASM_UM_LINKAGE_H
2#define __ASM_LINKAGE_H 2#define __ASM_UM_LINKAGE_H
3 3
4#define FASTCALL(x) x __attribute__((regparm(3))) 4#include "asm/arch/linkage.h"
5#define fastcall __attribute__((regparm(3)))
6 5
7#endif 6#endif
diff --git a/include/asm-um/page.h b/include/asm-um/page.h
index 3620a08dc9f3..504ea8e486b0 100644
--- a/include/asm-um/page.h
+++ b/include/asm-um/page.h
@@ -27,7 +27,7 @@ struct page;
27#define clear_user_page(page, vaddr, pg) clear_page(page) 27#define clear_user_page(page, vaddr, pg) clear_page(page)
28#define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 28#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
29 29
30#if defined(CONFIG_3_LEVEL_PGTABLES) && !defined(CONFIG_64_BIT) 30#if defined(CONFIG_3_LEVEL_PGTABLES) && !defined(CONFIG_64BIT)
31 31
32typedef struct { unsigned long pte_low, pte_high; } pte_t; 32typedef struct { unsigned long pte_low, pte_high; } pte_t;
33typedef struct { unsigned long long pmd; } pmd_t; 33typedef struct { unsigned long long pmd; } pmd_t;
@@ -45,6 +45,9 @@ typedef struct { unsigned long pgd; } pgd_t;
45 ({ (pte).pte_high = (phys) >> 32; \ 45 ({ (pte).pte_high = (phys) >> 32; \
46 (pte).pte_low = (phys) | pgprot_val(prot); }) 46 (pte).pte_low = (phys) | pgprot_val(prot); })
47 47
48#define pmd_val(x) ((x).pmd)
49#define __pmd(x) ((pmd_t) { (x) } )
50
48typedef unsigned long long pfn_t; 51typedef unsigned long long pfn_t;
49typedef unsigned long long phys_t; 52typedef unsigned long long phys_t;
50 53
diff --git a/include/asm-um/pgtable-3level.h b/include/asm-um/pgtable-3level.h
index bdbc3f97e20b..65e8bfc55fc4 100644
--- a/include/asm-um/pgtable-3level.h
+++ b/include/asm-um/pgtable-3level.h
@@ -145,11 +145,11 @@ static inline pmd_t pfn_pmd(pfn_t page_nr, pgprot_t pgprot)
145 */ 145 */
146#define PTE_FILE_MAX_BITS 32 146#define PTE_FILE_MAX_BITS 32
147 147
148#ifdef CONFIG_64_BIT 148#ifdef CONFIG_64BIT
149 149
150#define pte_to_pgoff(p) ((p).pte >> 32) 150#define pte_to_pgoff(p) ((p).pte >> 32)
151 151
152#define pgoff_to_pte(off) ((pte_t) { ((off) < 32) | _PAGE_FILE }) 152#define pgoff_to_pte(off) ((pte_t) { ((off) << 32) | _PAGE_FILE })
153 153
154#else 154#else
155 155
diff --git a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h
index 71f9c0c78c0c..510e513c7f88 100644
--- a/include/asm-um/pgtable.h
+++ b/include/asm-um/pgtable.h
@@ -106,7 +106,7 @@ extern unsigned long end_iomem;
106/* 106/*
107 * Define this if things work differently on an i386 and an i486: 107 * Define this if things work differently on an i386 and an i486:
108 * it will (on an i486) warn about kernel memory accesses that are 108 * it will (on an i486) warn about kernel memory accesses that are
109 * done without a 'verify_area(VERIFY_WRITE,..)' 109 * done without a 'access_ok(VERIFY_WRITE,..)'
110 */ 110 */
111#undef TEST_VERIFY_AREA 111#undef TEST_VERIFY_AREA
112 112
diff --git a/include/asm-um/processor-generic.h b/include/asm-um/processor-generic.h
index 038ba6fc88b8..b2fc94fbc2d9 100644
--- a/include/asm-um/processor-generic.h
+++ b/include/asm-um/processor-generic.h
@@ -17,12 +17,13 @@ struct task_struct;
17struct mm_struct; 17struct mm_struct;
18 18
19struct thread_struct { 19struct thread_struct {
20 /* This flag is set to 1 before calling do_fork (and analyzed in
21 * 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 * from kernelspace (i.e. kernel_thread() or fork_idle(), as of 2.6.11). */
20 int forking; 24 int forking;
21 int nsyscalls; 25 int nsyscalls;
22 struct pt_regs regs; 26 struct pt_regs regs;
23 unsigned long cr2;
24 int err;
25 unsigned long trap_no;
26 int singlestep_syscall; 27 int singlestep_syscall;
27 void *fault_addr; 28 void *fault_addr;
28 void *fault_catcher; 29 void *fault_catcher;
@@ -70,8 +71,6 @@ struct thread_struct {
70 .forking = 0, \ 71 .forking = 0, \
71 .nsyscalls = 0, \ 72 .nsyscalls = 0, \
72 .regs = EMPTY_REGS, \ 73 .regs = EMPTY_REGS, \
73 .cr2 = 0, \
74 .err = 0, \
75 .fault_addr = NULL, \ 74 .fault_addr = NULL, \
76 .prev_sched = NULL, \ 75 .prev_sched = NULL, \
77 .temp_stack = 0, \ 76 .temp_stack = 0, \
@@ -89,7 +88,11 @@ extern struct task_struct *alloc_task_struct(void);
89extern void release_thread(struct task_struct *); 88extern void release_thread(struct task_struct *);
90extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); 89extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
91extern void dump_thread(struct pt_regs *regs, struct user *u); 90extern void dump_thread(struct pt_regs *regs, struct user *u);
92extern void prepare_to_copy(struct task_struct *tsk); 91
92static inline void prepare_to_copy(struct task_struct *tsk)
93{
94}
95
93 96
94extern unsigned long thread_saved_pc(struct task_struct *t); 97extern unsigned long thread_saved_pc(struct task_struct *t);
95 98
diff --git a/include/asm-um/processor-i386.h b/include/asm-um/processor-i386.h
index 2deb8f1adbf1..431bad3ae9d7 100644
--- a/include/asm-um/processor-i386.h
+++ b/include/asm-um/processor-i386.h
@@ -9,13 +9,18 @@
9extern int host_has_xmm; 9extern int host_has_xmm;
10extern int host_has_cmov; 10extern int host_has_cmov;
11 11
12/* include faultinfo structure */
13#include "sysdep/faultinfo.h"
14
12struct arch_thread { 15struct arch_thread {
13 unsigned long debugregs[8]; 16 unsigned long debugregs[8];
14 int debugregs_seq; 17 int debugregs_seq;
18 struct faultinfo faultinfo;
15}; 19};
16 20
17#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \ 21#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \
18 .debugregs_seq = 0 } 22 .debugregs_seq = 0, \
23 .faultinfo = { 0, 0, 0 } }
19 24
20#include "asm/arch/user.h" 25#include "asm/arch/user.h"
21 26
diff --git a/include/asm-um/processor-x86_64.h b/include/asm-um/processor-x86_64.h
index a1ae3a4cd938..0beb9a42ae05 100644
--- a/include/asm-um/processor-x86_64.h
+++ b/include/asm-um/processor-x86_64.h
@@ -7,9 +7,13 @@
7#ifndef __UM_PROCESSOR_X86_64_H 7#ifndef __UM_PROCESSOR_X86_64_H
8#define __UM_PROCESSOR_X86_64_H 8#define __UM_PROCESSOR_X86_64_H
9 9
10#include "asm/arch/user.h" 10/* include faultinfo structure */
11#include "sysdep/faultinfo.h"
11 12
12struct arch_thread { 13struct arch_thread {
14 unsigned long debugregs[8];
15 int debugregs_seq;
16 struct faultinfo faultinfo;
13}; 17};
14 18
15/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ 19/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
@@ -20,7 +24,11 @@ extern inline void rep_nop(void)
20 24
21#define cpu_relax() rep_nop() 25#define cpu_relax() rep_nop()
22 26
23#define INIT_ARCH_THREAD { } 27#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \
28 .debugregs_seq = 0, \
29 .faultinfo = { 0, 0, 0 } }
30
31#include "asm/arch/user.h"
24 32
25#define current_text_addr() \ 33#define current_text_addr() \
26 ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; }) 34 ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
diff --git a/include/asm-um/ptrace-i386.h b/include/asm-um/ptrace-i386.h
index 9e47590ec293..04222f35c43e 100644
--- a/include/asm-um/ptrace-i386.h
+++ b/include/asm-um/ptrace-i386.h
@@ -6,6 +6,8 @@
6#ifndef __UM_PTRACE_I386_H 6#ifndef __UM_PTRACE_I386_H
7#define __UM_PTRACE_I386_H 7#define __UM_PTRACE_I386_H
8 8
9#define HOST_AUDIT_ARCH AUDIT_ARCH_I386
10
9#include "sysdep/ptrace.h" 11#include "sysdep/ptrace.h"
10#include "asm/ptrace-generic.h" 12#include "asm/ptrace-generic.h"
11 13
diff --git a/include/asm-um/ptrace-x86_64.h b/include/asm-um/ptrace-x86_64.h
index c34be39b78b2..be51219a8ffe 100644
--- a/include/asm-um/ptrace-x86_64.h
+++ b/include/asm-um/ptrace-x86_64.h
@@ -14,6 +14,8 @@
14#include "asm/ptrace-generic.h" 14#include "asm/ptrace-generic.h"
15#undef signal_fault 15#undef signal_fault
16 16
17#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
18
17void signal_fault(struct pt_regs_subarch *regs, void *frame, char *where); 19void signal_fault(struct pt_regs_subarch *regs, void *frame, char *where);
18 20
19#define FS_BASE (21 * sizeof(unsigned long)) 21#define FS_BASE (21 * sizeof(unsigned long))
diff --git a/include/asm-um/setup.h b/include/asm-um/setup.h
index c85252e803c1..99f086301f4c 100644
--- a/include/asm-um/setup.h
+++ b/include/asm-um/setup.h
@@ -2,7 +2,8 @@
2#define SETUP_H_INCLUDED 2#define SETUP_H_INCLUDED
3 3
4/* POSIX mandated with _POSIX_ARG_MAX that we can rely on 4096 chars in the 4/* POSIX mandated with _POSIX_ARG_MAX that we can rely on 4096 chars in the
5 * command line, so this choice is ok.*/ 5 * command line, so this choice is ok.
6 */
6 7
7#define COMMAND_LINE_SIZE 4096 8#define COMMAND_LINE_SIZE 4096
8 9
diff --git a/include/asm-um/thread_info.h b/include/asm-um/thread_info.h
index bffb577bc54e..a10ea155907e 100644
--- a/include/asm-um/thread_info.h
+++ b/include/asm-um/thread_info.h
@@ -72,12 +72,14 @@ static inline struct thread_info *current_thread_info(void)
72 */ 72 */
73#define TIF_RESTART_BLOCK 4 73#define TIF_RESTART_BLOCK 4
74#define TIF_MEMDIE 5 74#define TIF_MEMDIE 5
75#define TIF_SYSCALL_AUDIT 6
75 76
76#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 77#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
77#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 78#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
78#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 79#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
79#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 80#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
80#define _TIF_RESTART_BLOCK (1 << TIF_RESTART_BLOCK) 81#define _TIF_MEMDIE (1 << TIF_MEMDIE)
82#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
81 83
82#endif 84#endif
83 85
diff --git a/include/asm-v850/bug.h b/include/asm-v850/bug.h
index c778916bf7f2..b0ed2d35f3e8 100644
--- a/include/asm-v850/bug.h
+++ b/include/asm-v850/bug.h
@@ -14,9 +14,12 @@
14#ifndef __V850_BUG_H__ 14#ifndef __V850_BUG_H__
15#define __V850_BUG_H__ 15#define __V850_BUG_H__
16 16
17#ifdef CONFIG_BUG
17extern void __bug (void) __attribute__ ((noreturn)); 18extern void __bug (void) __attribute__ ((noreturn));
18#define BUG() __bug() 19#define BUG() __bug()
19#define HAVE_ARCH_BUG 20#define HAVE_ARCH_BUG
21#endif
22
20#include <asm-generic/bug.h> 23#include <asm-generic/bug.h>
21 24
22#endif /* __V850_BUG_H__ */ 25#endif /* __V850_BUG_H__ */
diff --git a/include/asm-v850/signal.h b/include/asm-v850/signal.h
index 407db875899c..cb52caa69925 100644
--- a/include/asm-v850/signal.h
+++ b/include/asm-v850/signal.h
@@ -110,32 +110,7 @@ typedef unsigned long sigset_t;
110#define MINSIGSTKSZ 2048 110#define MINSIGSTKSZ 2048
111#define SIGSTKSZ 8192 111#define SIGSTKSZ 8192
112 112
113 113#include <asm-generic/signal.h>
114#ifdef __KERNEL__
115/*
116 * These values of sa_flags are used only by the kernel as part of the
117 * irq handling routines.
118 *
119 * SA_INTERRUPT is also used by the irq handling routines.
120 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
121 */
122#define SA_PROBE SA_ONESHOT
123#define SA_SAMPLE_RANDOM SA_RESTART
124#define SA_SHIRQ 0x04000000
125#endif /* __KERNEL__ */
126
127
128#define SIG_BLOCK 0 /* for blocking signals */
129#define SIG_UNBLOCK 1 /* for unblocking signals */
130#define SIG_SETMASK 2 /* for setting the signal mask */
131
132/* Type of a signal handler. */
133typedef void (*__sighandler_t)(int);
134
135#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
136#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
137#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
138
139 114
140#ifdef __KERNEL__ 115#ifdef __KERNEL__
141 116
diff --git a/include/asm-x86_64/apic.h b/include/asm-x86_64/apic.h
index c025cc3ef789..e4b1017b8b2b 100644
--- a/include/asm-x86_64/apic.h
+++ b/include/asm-x86_64/apic.h
@@ -99,7 +99,6 @@ extern void disable_APIC_timer(void);
99extern void enable_APIC_timer(void); 99extern void enable_APIC_timer(void);
100extern void clustered_apic_check(void); 100extern void clustered_apic_check(void);
101 101
102extern int check_nmi_watchdog(void);
103extern void nmi_watchdog_default(void); 102extern void nmi_watchdog_default(void);
104extern int setup_nmi_watchdog(char *); 103extern int setup_nmi_watchdog(char *);
105 104
diff --git a/include/asm-x86_64/bootsetup.h b/include/asm-x86_64/bootsetup.h
index b570a484dc50..b829f7b534be 100644
--- a/include/asm-x86_64/bootsetup.h
+++ b/include/asm-x86_64/bootsetup.h
@@ -2,7 +2,8 @@
2#ifndef _X86_64_BOOTSETUP_H 2#ifndef _X86_64_BOOTSETUP_H
3#define _X86_64_BOOTSETUP_H 1 3#define _X86_64_BOOTSETUP_H 1
4 4
5extern char x86_boot_params[2048]; 5#define BOOT_PARAM_SIZE 4096
6extern char x86_boot_params[BOOT_PARAM_SIZE];
6 7
7/* 8/*
8 * This is set up by the setup-routine at boot-time 9 * This is set up by the setup-routine at boot-time
diff --git a/include/asm-x86_64/bug.h b/include/asm-x86_64/bug.h
index 19aed6e78fec..bdbf66eab6ee 100644
--- a/include/asm-x86_64/bug.h
+++ b/include/asm-x86_64/bug.h
@@ -15,11 +15,13 @@ struct bug_frame {
15 unsigned short line; 15 unsigned short line;
16} __attribute__((packed)); 16} __attribute__((packed));
17 17
18#ifdef CONFIG_BUG
18#define HAVE_ARCH_BUG 19#define HAVE_ARCH_BUG
19#define BUG() \ 20#define BUG() \
20 asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ 21 asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \
21 "i"(__LINE__), "i" (__stringify(__FILE__))) 22 "i"(__LINE__), "i" (__stringify(__FILE__)))
22void out_of_line_bug(void); 23void out_of_line_bug(void);
23#include <asm-generic/bug.h> 24#endif
24 25
26#include <asm-generic/bug.h>
25#endif 27#endif
diff --git a/include/asm-x86_64/cpufeature.h b/include/asm-x86_64/cpufeature.h
index e68ad97a6319..aea308c65709 100644
--- a/include/asm-x86_64/cpufeature.h
+++ b/include/asm-x86_64/cpufeature.h
@@ -7,7 +7,7 @@
7#ifndef __ASM_X8664_CPUFEATURE_H 7#ifndef __ASM_X8664_CPUFEATURE_H
8#define __ASM_X8664_CPUFEATURE_H 8#define __ASM_X8664_CPUFEATURE_H
9 9
10#define NCAPINTS 6 10#define NCAPINTS 7 /* N 32-bit words worth of info */
11 11
12/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */ 12/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
13#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */ 13#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
@@ -74,9 +74,15 @@
74#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */ 74#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */
75#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */ 75#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */
76 76
77/* More extended AMD flags: CPUID level 0x80000001, ecx, word 5 */ 77/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
78#define X86_FEATURE_LAHF_LM (5*32+ 0) /* LAHF/SAHF in long mode */ 78#define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */
79#define X86_FEATURE_CMP_LEGACY (5*32+ 1) /* If yes HyperThreading not valid */ 79#define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */
80#define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */
81#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */
82
83/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
84#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
85#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
80 86
81#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) 87#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability)
82#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability) 88#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability)
diff --git a/include/asm-x86_64/e820.h b/include/asm-x86_64/e820.h
index 08f83a4b4f4a..8e94edf0b984 100644
--- a/include/asm-x86_64/e820.h
+++ b/include/asm-x86_64/e820.h
@@ -14,7 +14,7 @@
14#include <linux/mmzone.h> 14#include <linux/mmzone.h>
15 15
16#define E820MAP 0x2d0 /* our map */ 16#define E820MAP 0x2d0 /* our map */
17#define E820MAX 32 /* number of entries in E820MAP */ 17#define E820MAX 128 /* number of entries in E820MAP */
18#define E820NR 0x1e8 /* # entries in E820MAP */ 18#define E820NR 0x1e8 /* # entries in E820MAP */
19 19
20#define E820_RAM 1 20#define E820_RAM 1
diff --git a/include/asm-x86_64/floppy.h b/include/asm-x86_64/floppy.h
index bca9b28a1a0a..af7ded63b517 100644
--- a/include/asm-x86_64/floppy.h
+++ b/include/asm-x86_64/floppy.h
@@ -223,7 +223,7 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
223 return 0; 223 return 0;
224} 224}
225 225
226struct fd_routine_l { 226static struct fd_routine_l {
227 int (*_request_dma)(unsigned int dmanr, const char * device_id); 227 int (*_request_dma)(unsigned int dmanr, const char * device_id);
228 void (*_free_dma)(unsigned int dmanr); 228 void (*_free_dma)(unsigned int dmanr);
229 int (*_get_dma_residue)(unsigned int dummy); 229 int (*_get_dma_residue)(unsigned int dummy);
diff --git a/include/asm-x86_64/siginfo.h b/include/asm-x86_64/siginfo.h
index 7bc15985f124..d09a1e6e7246 100644
--- a/include/asm-x86_64/siginfo.h
+++ b/include/asm-x86_64/siginfo.h
@@ -3,8 +3,6 @@
3 3
4#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) 4#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
5 5
6#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
7
8#include <asm-generic/siginfo.h> 6#include <asm-generic/siginfo.h>
9 7
10#endif 8#endif
diff --git a/include/asm-x86_64/signal.h b/include/asm-x86_64/signal.h
index 643a20d73765..fe9b96d94815 100644
--- a/include/asm-x86_64/signal.h
+++ b/include/asm-x86_64/signal.h
@@ -116,35 +116,9 @@ typedef unsigned long sigset_t;
116#define MINSIGSTKSZ 2048 116#define MINSIGSTKSZ 2048
117#define SIGSTKSZ 8192 117#define SIGSTKSZ 8192
118 118
119#ifdef __KERNEL__ 119#include <asm-generic/signal.h>
120
121/*
122 * These values of sa_flags are used only by the kernel as part of the
123 * irq handling routines.
124 *
125 * SA_INTERRUPT is also used by the irq handling routines.
126 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
127 */
128#define SA_PROBE SA_ONESHOT
129#define SA_SAMPLE_RANDOM SA_RESTART
130#define SA_SHIRQ 0x04000000
131#endif
132
133#define SIG_BLOCK 0 /* for blocking signals */
134#define SIG_UNBLOCK 1 /* for unblocking signals */
135#define SIG_SETMASK 2 /* for setting the signal mask */
136 120
137#ifndef __ASSEMBLY__ 121#ifndef __ASSEMBLY__
138/* Type of a signal handler. */
139typedef void __signalfn_t(int);
140typedef __signalfn_t __user *__sighandler_t;
141
142typedef void __restorefn_t(void);
143typedef __restorefn_t __user *__sigrestore_t;
144
145#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
146#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
147#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
148 122
149struct sigaction { 123struct sigaction {
150 __sighandler_t sa_handler; 124 __sighandler_t sa_handler;
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h
index 3d65d240dc95..3c9af6fd4332 100644
--- a/include/asm-x86_64/unistd.h
+++ b/include/asm-x86_64/unistd.h
@@ -76,7 +76,7 @@ __SYSCALL(__NR_madvise, sys_madvise)
76#define __NR_shmget 29 76#define __NR_shmget 29
77__SYSCALL(__NR_shmget, sys_shmget) 77__SYSCALL(__NR_shmget, sys_shmget)
78#define __NR_shmat 30 78#define __NR_shmat 30
79__SYSCALL(__NR_shmat, wrap_sys_shmat) 79__SYSCALL(__NR_shmat, sys_shmat)
80#define __NR_shmctl 31 80#define __NR_shmctl 31
81__SYSCALL(__NR_shmctl, sys_shmctl) 81__SYSCALL(__NR_shmctl, sys_shmctl)
82 82
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 3628f7cfb178..19f04b049798 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -1,4 +1,4 @@
1/* audit.h -- Auditing support -*- linux-c -*- 1/* audit.h -- Auditing support
2 * 2 *
3 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. 3 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
4 * All Rights Reserved. 4 * All Rights Reserved.
@@ -24,6 +24,9 @@
24#ifndef _LINUX_AUDIT_H_ 24#ifndef _LINUX_AUDIT_H_
25#define _LINUX_AUDIT_H_ 25#define _LINUX_AUDIT_H_
26 26
27#include <linux/sched.h>
28#include <linux/elf.h>
29
27/* Request and reply types */ 30/* Request and reply types */
28#define AUDIT_GET 1000 /* Get status */ 31#define AUDIT_GET 1000 /* Get status */
29#define AUDIT_SET 1001 /* Set status (enable/disable/auditd) */ 32#define AUDIT_SET 1001 /* Set status (enable/disable/auditd) */
@@ -67,6 +70,7 @@
67#define AUDIT_FSGID 8 70#define AUDIT_FSGID 8
68#define AUDIT_LOGINUID 9 71#define AUDIT_LOGINUID 9
69#define AUDIT_PERS 10 72#define AUDIT_PERS 10
73#define AUDIT_ARCH 11
70 74
71 /* These are ONLY useful when checking 75 /* These are ONLY useful when checking
72 * at syscall exit time (AUDIT_AT_EXIT). */ 76 * at syscall exit time (AUDIT_AT_EXIT). */
@@ -96,6 +100,38 @@
96#define AUDIT_FAIL_PRINTK 1 100#define AUDIT_FAIL_PRINTK 1
97#define AUDIT_FAIL_PANIC 2 101#define AUDIT_FAIL_PANIC 2
98 102
103/* distinguish syscall tables */
104#define __AUDIT_ARCH_64BIT 0x80000000
105#define __AUDIT_ARCH_LE 0x40000000
106#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
107#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)
108#define AUDIT_ARCH_ARMEB (EM_ARM)
109#define AUDIT_ARCH_CRIS (EM_CRIS|__AUDIT_ARCH_LE)
110#define AUDIT_ARCH_FRV (EM_FRV)
111#define AUDIT_ARCH_H8300 (EM_H8_300)
112#define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
113#define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
114#define AUDIT_ARCH_M32R (EM_M32R)
115#define AUDIT_ARCH_M68K (EM_68K)
116#define AUDIT_ARCH_MIPS (EM_MIPS)
117#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE)
118#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT)
119#define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
120#define AUDIT_ARCH_PARISC (EM_PARISC)
121#define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT)
122#define AUDIT_ARCH_PPC (EM_PPC)
123#define AUDIT_ARCH_PPC64 (EM_PPC64|__AUDIT_ARCH_64BIT)
124#define AUDIT_ARCH_S390 (EM_S390)
125#define AUDIT_ARCH_S390X (EM_S390|__AUDIT_ARCH_64BIT)
126#define AUDIT_ARCH_SH (EM_SH)
127#define AUDIT_ARCH_SHEL (EM_SH|__AUDIT_ARCH_LE)
128#define AUDIT_ARCH_SH64 (EM_SH|__AUDIT_ARCH_64BIT)
129#define AUDIT_ARCH_SHEL64 (EM_SH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
130#define AUDIT_ARCH_SPARC (EM_SPARC)
131#define AUDIT_ARCH_SPARC64 (EM_SPARC64|__AUDIT_ARCH_64BIT)
132#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE)
133#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
134
99#ifndef __KERNEL__ 135#ifndef __KERNEL__
100struct audit_message { 136struct audit_message {
101 struct nlmsghdr nlh; 137 struct nlmsghdr nlh;
@@ -129,32 +165,36 @@ struct audit_buffer;
129struct audit_context; 165struct audit_context;
130struct inode; 166struct inode;
131 167
168#define AUDITSC_INVALID 0
169#define AUDITSC_SUCCESS 1
170#define AUDITSC_FAILURE 2
171#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
132#ifdef CONFIG_AUDITSYSCALL 172#ifdef CONFIG_AUDITSYSCALL
133/* These are defined in auditsc.c */ 173/* These are defined in auditsc.c */
134 /* Public API */ 174 /* Public API */
135extern int audit_alloc(struct task_struct *task); 175extern int audit_alloc(struct task_struct *task);
136extern void audit_free(struct task_struct *task); 176extern void audit_free(struct task_struct *task);
137extern void audit_syscall_entry(struct task_struct *task, 177extern void audit_syscall_entry(struct task_struct *task, int arch,
138 int major, unsigned long a0, unsigned long a1, 178 int major, unsigned long a0, unsigned long a1,
139 unsigned long a2, unsigned long a3); 179 unsigned long a2, unsigned long a3);
140extern void audit_syscall_exit(struct task_struct *task, int return_code); 180extern void audit_syscall_exit(struct task_struct *task, int failed, long return_code);
141extern void audit_getname(const char *name); 181extern void audit_getname(const char *name);
142extern void audit_putname(const char *name); 182extern void audit_putname(const char *name);
143extern void audit_inode(const char *name, const struct inode *inode); 183extern void audit_inode(const char *name, const struct inode *inode);
144 184
145 /* Private API (for audit.c only) */ 185 /* Private API (for audit.c only) */
146extern int audit_receive_filter(int type, int pid, int uid, int seq, 186extern int audit_receive_filter(int type, int pid, int uid, int seq,
147 void *data); 187 void *data, uid_t loginuid);
148extern void audit_get_stamp(struct audit_context *ctx, 188extern void audit_get_stamp(struct audit_context *ctx,
149 struct timespec *t, int *serial); 189 struct timespec *t, unsigned int *serial);
150extern int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid); 190extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid);
151extern uid_t audit_get_loginuid(struct audit_context *ctx); 191extern uid_t audit_get_loginuid(struct audit_context *ctx);
152extern int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode); 192extern int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
153#else 193#else
154#define audit_alloc(t) ({ 0; }) 194#define audit_alloc(t) ({ 0; })
155#define audit_free(t) do { ; } while (0) 195#define audit_free(t) do { ; } while (0)
156#define audit_syscall_entry(t,a,b,c,d,e) do { ; } while (0) 196#define audit_syscall_entry(t,ta,a,b,c,d,e) do { ; } while (0)
157#define audit_syscall_exit(t,r) do { ; } while (0) 197#define audit_syscall_exit(t,f,r) do { ; } while (0)
158#define audit_getname(n) do { ; } while (0) 198#define audit_getname(n) do { ; } while (0)
159#define audit_putname(n) do { ; } while (0) 199#define audit_putname(n) do { ; } while (0)
160#define audit_inode(n,i) do { ; } while (0) 200#define audit_inode(n,i) do { ; } while (0)
@@ -174,11 +214,15 @@ extern void audit_log_format(struct audit_buffer *ab,
174 const char *fmt, ...) 214 const char *fmt, ...)
175 __attribute__((format(printf,2,3))); 215 __attribute__((format(printf,2,3)));
176extern void audit_log_end(struct audit_buffer *ab); 216extern void audit_log_end(struct audit_buffer *ab);
217extern void audit_log_hex(struct audit_buffer *ab,
218 const unsigned char *buf,
219 size_t len);
220extern void audit_log_untrustedstring(struct audit_buffer *ab,
221 const char *string);
177extern void audit_log_d_path(struct audit_buffer *ab, 222extern void audit_log_d_path(struct audit_buffer *ab,
178 const char *prefix, 223 const char *prefix,
179 struct dentry *dentry, 224 struct dentry *dentry,
180 struct vfsmount *vfsmnt); 225 struct vfsmount *vfsmnt);
181
182 /* Private API (for auditsc.c only) */ 226 /* Private API (for auditsc.c only) */
183extern void audit_send_reply(int pid, int seq, int type, 227extern void audit_send_reply(int pid, int seq, int type,
184 int done, int multi, 228 int done, int multi,
@@ -190,6 +234,8 @@ extern void audit_log_lost(const char *message);
190#define audit_log_vformat(b,f,a) do { ; } while (0) 234#define audit_log_vformat(b,f,a) do { ; } while (0)
191#define audit_log_format(b,f,...) do { ; } while (0) 235#define audit_log_format(b,f,...) do { ; } while (0)
192#define audit_log_end(b) do { ; } while (0) 236#define audit_log_end(b) do { ; } while (0)
237#define audit_log_hex(a,b,l) do { ; } while (0)
238#define audit_log_untrustedstring(a,s) do { ; } while (0)
193#define audit_log_d_path(b,p,d,v) do { ; } while (0) 239#define audit_log_d_path(b,p,d,v) do { ; } while (0)
194#endif 240#endif
195#endif 241#endif
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
index d1c7b0ec7c22..a1657fb99516 100644
--- a/include/linux/auto_fs4.h
+++ b/include/linux/auto_fs4.h
@@ -23,7 +23,7 @@
23#define AUTOFS_MIN_PROTO_VERSION 3 23#define AUTOFS_MIN_PROTO_VERSION 3
24#define AUTOFS_MAX_PROTO_VERSION 4 24#define AUTOFS_MAX_PROTO_VERSION 4
25 25
26#define AUTOFS_PROTO_SUBVERSION 5 26#define AUTOFS_PROTO_SUBVERSION 6
27 27
28/* Mask for expire behaviour */ 28/* Mask for expire behaviour */
29#define AUTOFS_EXP_IMMEDIATE 1 29#define AUTOFS_EXP_IMMEDIATE 1
diff --git a/include/linux/awe_voice.h b/include/linux/awe_voice.h
index da0e27de752c..4bf9f33048e2 100644
--- a/include/linux/awe_voice.h
+++ b/include/linux/awe_voice.h
@@ -29,9 +29,9 @@
29#define SAMPLE_TYPE_AWE32 0x20 29#define SAMPLE_TYPE_AWE32 0x20
30#endif 30#endif
31 31
32#ifndef _PATCHKEY 32#define _LINUX_PATCHKEY_H_INDIRECT
33#define _PATCHKEY(id) ((id<<8)|0xfd) 33#include <linux/patchkey.h>
34#endif 34#undef _LINUX_PATCHKEY_H_INDIRECT
35 35
36/*---------------------------------------------------------------- 36/*----------------------------------------------------------------
37 * patch information record 37 * patch information record
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index 54f820832c73..7e736e201c46 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -77,7 +77,6 @@ extern int flush_old_exec(struct linux_binprm * bprm);
77extern int setup_arg_pages(struct linux_binprm * bprm, 77extern int setup_arg_pages(struct linux_binprm * bprm,
78 unsigned long stack_top, 78 unsigned long stack_top,
79 int executable_stack); 79 int executable_stack);
80extern int copy_strings(int argc,char __user * __user * argv,struct linux_binprm *bprm);
81extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); 80extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm);
82extern void compute_creds(struct linux_binprm *binprm); 81extern void compute_creds(struct linux_binprm *binprm);
83extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); 82extern int do_coredump(long signr, int exit_code, struct pt_regs * regs);
diff --git a/include/linux/compiler-gcc2.h b/include/linux/compiler-gcc2.h
index 5a359153ffd9..ebed17660c5f 100644
--- a/include/linux/compiler-gcc2.h
+++ b/include/linux/compiler-gcc2.h
@@ -22,3 +22,8 @@
22# define __attribute_pure__ __attribute__((pure)) 22# define __attribute_pure__ __attribute__((pure))
23# define __attribute_const__ __attribute__((__const__)) 23# define __attribute_const__ __attribute__((__const__))
24#endif 24#endif
25
26/* GCC 2.95.x/2.96 recognize __va_copy, but not va_copy. Actually later GCC's
27 * define both va_copy and __va_copy, but the latter may go away, so limit this
28 * to this header */
29#define va_copy __va_copy
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 487725cf0d0d..d7378215b851 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -90,6 +90,12 @@ extern void __chk_io_ptr(void __iomem *);
90# define __deprecated /* unimplemented */ 90# define __deprecated /* unimplemented */
91#endif 91#endif
92 92
93#ifdef MODULE
94#define __deprecated_for_modules __deprecated
95#else
96#define __deprecated_for_modules
97#endif
98
93#ifndef __must_check 99#ifndef __must_check
94#define __must_check 100#define __must_check
95#endif 101#endif
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 910eca35583d..f21af067d015 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -103,6 +103,7 @@ struct cpufreq_policy {
103#define CPUFREQ_PRECHANGE (0) 103#define CPUFREQ_PRECHANGE (0)
104#define CPUFREQ_POSTCHANGE (1) 104#define CPUFREQ_POSTCHANGE (1)
105#define CPUFREQ_RESUMECHANGE (8) 105#define CPUFREQ_RESUMECHANGE (8)
106#define CPUFREQ_SUSPENDCHANGE (9)
106 107
107struct cpufreq_freqs { 108struct cpufreq_freqs {
108 unsigned int cpu; /* cpu nr */ 109 unsigned int cpu; /* cpu nr */
@@ -200,6 +201,7 @@ struct cpufreq_driver {
200 201
201 /* optional */ 202 /* optional */
202 int (*exit) (struct cpufreq_policy *policy); 203 int (*exit) (struct cpufreq_policy *policy);
204 int (*suspend) (struct cpufreq_policy *policy, u32 state);
203 int (*resume) (struct cpufreq_policy *policy); 205 int (*resume) (struct cpufreq_policy *policy);
204 struct freq_attr **attr; 206 struct freq_attr **attr;
205}; 207};
@@ -211,7 +213,8 @@ struct cpufreq_driver {
211#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel 213#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel
212 * "constants" aren't affected by 214 * "constants" aren't affected by
213 * frequency transitions */ 215 * frequency transitions */
214 216#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed
217 * mismatches */
215 218
216int cpufreq_register_driver(struct cpufreq_driver *driver_data); 219int cpufreq_register_driver(struct cpufreq_driver *driver_data);
217int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); 220int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
diff --git a/include/linux/edd.h b/include/linux/edd.h
index c6e6747a401d..162512b886f7 100644
--- a/include/linux/edd.h
+++ b/include/linux/edd.h
@@ -32,7 +32,7 @@
32 32
33#define EDDNR 0x1e9 /* addr of number of edd_info structs at EDDBUF 33#define EDDNR 0x1e9 /* addr of number of edd_info structs at EDDBUF
34 in boot_params - treat this as 1 byte */ 34 in boot_params - treat this as 1 byte */
35#define EDDBUF 0x600 /* addr of edd_info structs in boot_params */ 35#define EDDBUF 0xd00 /* addr of edd_info structs in boot_params */
36#define EDDMAXNR 6 /* number of edd_info structs starting at EDDBUF */ 36#define EDDMAXNR 6 /* number of edd_info structs starting at EDDBUF */
37#define EDDEXTSIZE 8 /* change these if you muck with the structures */ 37#define EDDEXTSIZE 8 /* change these if you muck with the structures */
38#define EDDPARMSIZE 74 38#define EDDPARMSIZE 74
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 396c48cbaeb1..220748b7abea 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)eth.h 1.0.4 05/13/93 8 * Version: @(#)eth.h 1.0.4 05/13/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * Relocated to include/linux where it belongs by Alan Cox 13 * Relocated to include/linux where it belongs by Alan Cox
diff --git a/include/linux/fb.h b/include/linux/fb.h
index b45d3e2d711a..b468bf496547 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -563,6 +563,9 @@ struct fb_ops {
563 int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green, 563 int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
564 unsigned blue, unsigned transp, struct fb_info *info); 564 unsigned blue, unsigned transp, struct fb_info *info);
565 565
566 /* set color registers in batch */
567 int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info);
568
566 /* blank display */ 569 /* blank display */
567 int (*fb_blank)(int blank, struct fb_info *info); 570 int (*fb_blank)(int blank, struct fb_info *info);
568 571
diff --git a/include/linux/fddidevice.h b/include/linux/fddidevice.h
index 2e5ee47f3e1e..002f6367697d 100644
--- a/include/linux/fddidevice.h
+++ b/include/linux/fddidevice.h
@@ -10,7 +10,7 @@
10 * Author: Lawrence V. Stefani, <stefani@lkg.dec.com> 10 * Author: Lawrence V. Stefani, <stefani@lkg.dec.com>
11 * 11 *
12 * fddidevice.h is based on previous trdevice.h work by 12 * fddidevice.h is based on previous trdevice.h work by
13 * Ross Biro, <bir7@leland.Stanford.Edu> 13 * Ross Biro
14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
15 * Alan Cox, <gw4pts@gw4pts.ampr.org> 15 * Alan Cox, <gw4pts@gw4pts.ampr.org>
16 * 16 *
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5df687d940fa..0180102dace1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1053,83 +1053,87 @@ static inline void file_accessed(struct file *file)
1053int sync_inode(struct inode *inode, struct writeback_control *wbc); 1053int sync_inode(struct inode *inode, struct writeback_control *wbc);
1054 1054
1055/** 1055/**
1056 * &export_operations - for nfsd to communicate with file systems 1056 * struct export_operations - for nfsd to communicate with file systems
1057 * decode_fh: decode a file handle fragment and return a &struct dentry 1057 * @decode_fh: decode a file handle fragment and return a &struct dentry
1058 * encode_fh: encode a file handle fragment from a dentry 1058 * @encode_fh: encode a file handle fragment from a dentry
1059 * get_name: find the name for a given inode in a given directory 1059 * @get_name: find the name for a given inode in a given directory
1060 * get_parent: find the parent of a given directory 1060 * @get_parent: find the parent of a given directory
1061 * get_dentry: find a dentry for the inode given a file handle sub-fragment 1061 * @get_dentry: find a dentry for the inode given a file handle sub-fragment
1062 * 1062 *
1063 * Description: 1063 * Description:
1064 * The export_operations structure provides a means for nfsd to communicate 1064 * The export_operations structure provides a means for nfsd to communicate
1065 * with a particular exported file system - particularly enabling nfsd and 1065 * with a particular exported file system - particularly enabling nfsd and
1066 * the filesystem to co-operate when dealing with file handles. 1066 * the filesystem to co-operate when dealing with file handles.
1067 * 1067 *
1068 * export_operations contains two basic operation for dealing with file handles, 1068 * export_operations contains two basic operation for dealing with file
1069 * decode_fh() and encode_fh(), and allows for some other operations to be defined 1069 * handles, decode_fh() and encode_fh(), and allows for some other
1070 * which standard helper routines use to get specific information from the 1070 * operations to be defined which standard helper routines use to get
1071 * filesystem. 1071 * specific information from the filesystem.
1072 * 1072 *
1073 * nfsd encodes information use to determine which filesystem a filehandle 1073 * nfsd encodes information use to determine which filesystem a filehandle
1074 * applies to in the initial part of the file handle. The remainder, termed a 1074 * applies to in the initial part of the file handle. The remainder, termed
1075 * file handle fragment, is controlled completely by the filesystem. 1075 * a file handle fragment, is controlled completely by the filesystem. The
1076 * The standard helper routines assume that this fragment will contain one or two 1076 * standard helper routines assume that this fragment will contain one or
1077 * sub-fragments, one which identifies the file, and one which may be used to 1077 * two sub-fragments, one which identifies the file, and one which may be
1078 * identify the (a) directory containing the file. 1078 * used to identify the (a) directory containing the file.
1079 * 1079 *
1080 * In some situations, nfsd needs to get a dentry which is connected into a 1080 * In some situations, nfsd needs to get a dentry which is connected into a
1081 * specific part of the file tree. To allow for this, it passes the function 1081 * specific part of the file tree. To allow for this, it passes the
1082 * acceptable() together with a @context which can be used to see if the dentry 1082 * function acceptable() together with a @context which can be used to see
1083 * is acceptable. As there can be multiple dentrys for a given file, the filesystem 1083 * if the dentry is acceptable. As there can be multiple dentrys for a
1084 * should check each one for acceptability before looking for the next. As soon 1084 * given file, the filesystem should check each one for acceptability before
1085 * as an acceptable one is found, it should be returned. 1085 * looking for the next. As soon as an acceptable one is found, it should
1086 * be returned.
1086 * 1087 *
1087 * decode_fh: 1088 * decode_fh:
1088 * @decode_fh is given a &struct super_block (@sb), a file handle fragment (@fh, @fh_len) 1089 * @decode_fh is given a &struct super_block (@sb), a file handle fragment
1089 * and an acceptability testing function (@acceptable, @context). It should return 1090 * (@fh, @fh_len) and an acceptability testing function (@acceptable,
1090 * a &struct dentry which refers to the same file that the file handle fragment refers 1091 * @context). It should return a &struct dentry which refers to the same
1091 * to, and which passes the acceptability test. If it cannot, it should return 1092 * file that the file handle fragment refers to, and which passes the
1092 * a %NULL pointer if the file was found but no acceptable &dentries were available, or 1093 * acceptability test. If it cannot, it should return a %NULL pointer if
1093 * a %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or %ENOMEM). 1094 * the file was found but no acceptable &dentries were available, or a
1095 * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or
1096 * %ENOMEM).
1094 * 1097 *
1095 * encode_fh: 1098 * encode_fh:
1096 * @encode_fh should store in the file handle fragment @fh (using at most @max_len bytes) 1099 * @encode_fh should store in the file handle fragment @fh (using at most
1097 * information that can be used by @decode_fh to recover the file refered to by the 1100 * @max_len bytes) information that can be used by @decode_fh to recover the
1098 * &struct dentry @de. If the @connectable flag is set, the encode_fh() should store 1101 * file refered to by the &struct dentry @de. If the @connectable flag is
1099 * sufficient information so that a good attempt can be made to find not only 1102 * set, the encode_fh() should store sufficient information so that a good
1100 * the file but also it's place in the filesystem. This typically means storing 1103 * attempt can be made to find not only the file but also it's place in the
1101 * a reference to de->d_parent in the filehandle fragment. 1104 * filesystem. This typically means storing a reference to de->d_parent in
1102 * encode_fh() should return the number of bytes stored or a negative error code 1105 * the filehandle fragment. encode_fh() should return the number of bytes
1103 * such as %-ENOSPC 1106 * stored or a negative error code such as %-ENOSPC
1104 * 1107 *
1105 * get_name: 1108 * get_name:
1106 * @get_name should find a name for the given @child in the given @parent directory. 1109 * @get_name should find a name for the given @child in the given @parent
1107 * The name should be stored in the @name (with the understanding that it is already 1110 * directory. The name should be stored in the @name (with the
1108 * pointing to a a %NAME_MAX+1 sized buffer. get_name() should return %0 on success, 1111 * understanding that it is already pointing to a a %NAME_MAX+1 sized
1109 * a negative error code or error. 1112 * buffer. get_name() should return %0 on success, a negative error code
1110 * @get_name will be called without @parent->i_sem held. 1113 * or error. @get_name will be called without @parent->i_sem held.
1111 * 1114 *
1112 * get_parent: 1115 * get_parent:
1113 * @get_parent should find the parent directory for the given @child which is also 1116 * @get_parent should find the parent directory for the given @child which
1114 * a directory. In the event that it cannot be found, or storage space cannot be 1117 * is also a directory. In the event that it cannot be found, or storage
1115 * allocated, a %ERR_PTR should be returned. 1118 * space cannot be allocated, a %ERR_PTR should be returned.
1116 * 1119 *
1117 * get_dentry: 1120 * get_dentry:
1118 * Given a &super_block (@sb) and a pointer to a file-system specific inode identifier, 1121 * Given a &super_block (@sb) and a pointer to a file-system specific inode
1119 * possibly an inode number, (@inump) get_dentry() should find the identified inode and 1122 * identifier, possibly an inode number, (@inump) get_dentry() should find
1120 * return a dentry for that inode. 1123 * the identified inode and return a dentry for that inode. Any suitable
1121 * Any suitable dentry can be returned including, if necessary, a new dentry created 1124 * dentry can be returned including, if necessary, a new dentry created with
1122 * with d_alloc_root. The caller can then find any other extant dentrys by following the 1125 * d_alloc_root. The caller can then find any other extant dentrys by
1123 * d_alias links. If a new dentry was created using d_alloc_root, DCACHE_NFSD_DISCONNECTED 1126 * following the d_alias links. If a new dentry was created using
1124 * should be set, and the dentry should be d_rehash()ed. 1127 * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry
1128 * should be d_rehash()ed.
1125 * 1129 *
1126 * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code can be returned. 1130 * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code
1127 * The @inump will be whatever was passed to nfsd_find_fh_dentry() in either the 1131 * can be returned. The @inump will be whatever was passed to
1128 * @obj or @parent parameters. 1132 * nfsd_find_fh_dentry() in either the @obj or @parent parameters.
1129 * 1133 *
1130 * Locking rules: 1134 * Locking rules:
1131 * get_parent is called with child->d_inode->i_sem down 1135 * get_parent is called with child->d_inode->i_sem down
1132 * get_name is not (which is possibly inconsistent) 1136 * get_name is not (which is possibly inconsistent)
1133 */ 1137 */
1134 1138
1135struct export_operations { 1139struct export_operations {
@@ -1337,7 +1341,7 @@ extern int fs_may_remount_ro(struct super_block *);
1337 1341
1338extern int check_disk_change(struct block_device *); 1342extern int check_disk_change(struct block_device *);
1339extern int invalidate_inodes(struct super_block *); 1343extern int invalidate_inodes(struct super_block *);
1340extern int __invalidate_device(struct block_device *, int); 1344extern int __invalidate_device(struct block_device *);
1341extern int invalidate_partition(struct gendisk *, int); 1345extern int invalidate_partition(struct gendisk *, int);
1342unsigned long invalidate_mapping_pages(struct address_space *mapping, 1346unsigned long invalidate_mapping_pages(struct address_space *mapping,
1343 pgoff_t start, pgoff_t end); 1347 pgoff_t start, pgoff_t end);
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 848a1baac079..af7407e8cfc5 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -38,14 +38,16 @@ struct vm_area_struct;
38#define __GFP_NO_GROW 0x2000u /* Slab internal usage */ 38#define __GFP_NO_GROW 0x2000u /* Slab internal usage */
39#define __GFP_COMP 0x4000u /* Add compound page metadata */ 39#define __GFP_COMP 0x4000u /* Add compound page metadata */
40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */ 40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */
41#define __GFP_NOMEMALLOC 0x10000u /* Don't use emergency reserves */
41 42
42#define __GFP_BITS_SHIFT 16 /* Room for 16 __GFP_FOO bits */ 43#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */
43#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1) 44#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1)
44 45
45/* if you forget to add the bitmask here kernel will crash, period */ 46/* if you forget to add the bitmask here kernel will crash, period */
46#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ 47#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
47 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ 48 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
48 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP) 49 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
50 __GFP_NOMEMALLOC)
49 51
50#define GFP_ATOMIC (__GFP_HIGH) 52#define GFP_ATOMIC (__GFP_HIGH)
51#define GFP_NOIO (__GFP_WAIT) 53#define GFP_NOIO (__GFP_WAIT)
diff --git a/include/linux/hippidevice.h b/include/linux/hippidevice.h
index 89b3a4a5b761..9debe6bbe5f0 100644
--- a/include/linux/hippidevice.h
+++ b/include/linux/hippidevice.h
@@ -10,7 +10,7 @@
10 * Author: Jes Sorensen, <Jes.Sorensen@cern.ch> 10 * Author: Jes Sorensen, <Jes.Sorensen@cern.ch>
11 * 11 *
12 * hippidevice.h is based on previous fddidevice.h work by 12 * hippidevice.h is based on previous fddidevice.h work by
13 * Ross Biro, <bir7@leland.Stanford.Edu> 13 * Ross Biro
14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
15 * Alan Cox, <gw4pts@gw4pts.ampr.org> 15 * Alan Cox, <gw4pts@gw4pts.ampr.org>
16 * Lawrence V. Stefani, <stefani@lkg.dec.com> 16 * Lawrence V. Stefani, <stefani@lkg.dec.com>
diff --git a/include/linux/if.h b/include/linux/if.h
index 110282dbd3e0..d73a9d62f208 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -8,7 +8,7 @@
8 * Version: @(#)if.h 1.0.2 04/18/93 8 * Version: @(#)if.h 1.0.2 04/18/93
9 * 9 *
10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988 10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988
11 * Ross Biro, <bir7@leland.Stanford.Edu> 11 * Ross Biro
12 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 12 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
13 * 13 *
14 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index bbf49bcd7705..0856548a2a08 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988 10 * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
11 * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source. 11 * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source.
12 * Ross Biro, <bir7@leland.Stanford.Edu> 12 * Ross Biro
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Florian La Roche, 14 * Florian La Roche,
15 * Jonathan Layes <layes@loran.com> 15 * Jonathan Layes <layes@loran.com>
diff --git a/include/linux/if_ltalk.h b/include/linux/if_ltalk.h
index e75e832b7ff0..76525760ba48 100644
--- a/include/linux/if_ltalk.h
+++ b/include/linux/if_ltalk.h
@@ -6,7 +6,7 @@
6#define LTALK_ALEN 1 6#define LTALK_ALEN 1
7 7
8#ifdef __KERNEL__ 8#ifdef __KERNEL__
9extern void ltalk_setup(struct net_device *); 9extern struct net_device *alloc_ltalkdev(int sizeof_priv);
10#endif 10#endif
11 11
12#endif 12#endif
diff --git a/include/linux/input.h b/include/linux/input.h
index b70df8fe60e6..72731d7d189e 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -328,6 +328,11 @@ struct input_absinfo {
328#define KEY_BRIGHTNESSUP 225 328#define KEY_BRIGHTNESSUP 225
329#define KEY_MEDIA 226 329#define KEY_MEDIA 226
330 330
331#define KEY_SWITCHVIDEOMODE 227
332#define KEY_KBDILLUMTOGGLE 228
333#define KEY_KBDILLUMDOWN 229
334#define KEY_KBDILLUMUP 230
335
331#define KEY_UNKNOWN 240 336#define KEY_UNKNOWN 240
332 337
333#define BTN_MISC 0x100 338#define BTN_MISC 0x100
diff --git a/include/linux/iso_fs.h b/include/linux/iso_fs.h
index 099039d4b10d..47967878bfef 100644
--- a/include/linux/iso_fs.h
+++ b/include/linux/iso_fs.h
@@ -1,4 +1,3 @@
1
2#ifndef _ISOFS_FS_H 1#ifndef _ISOFS_FS_H
3#define _ISOFS_FS_H 2#define _ISOFS_FS_H
4 3
@@ -163,150 +162,4 @@ struct iso_directory_record {
163 162
164#define ISOFS_SUPER_MAGIC 0x9660 163#define ISOFS_SUPER_MAGIC 0x9660
165 164
166#ifdef __KERNEL__
167/* Number conversion inlines, named after the section in ISO 9660
168 they correspond to. */
169
170#include <asm/byteorder.h>
171#include <asm/unaligned.h>
172#include <linux/iso_fs_i.h>
173#include <linux/iso_fs_sb.h>
174
175static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb)
176{
177 return sb->s_fs_info;
178}
179
180static inline struct iso_inode_info *ISOFS_I(struct inode *inode)
181{
182 return container_of(inode, struct iso_inode_info, vfs_inode);
183}
184
185static inline int isonum_711(char *p)
186{
187 return *(u8 *)p;
188}
189static inline int isonum_712(char *p)
190{
191 return *(s8 *)p;
192}
193static inline unsigned int isonum_721(char *p)
194{
195 return le16_to_cpu(get_unaligned((__le16 *)p));
196}
197static inline unsigned int isonum_722(char *p)
198{
199 return be16_to_cpu(get_unaligned((__le16 *)p));
200}
201static inline unsigned int isonum_723(char *p)
202{
203 /* Ignore bigendian datum due to broken mastering programs */
204 return le16_to_cpu(get_unaligned((__le16 *)p));
205}
206static inline unsigned int isonum_731(char *p)
207{
208 return le32_to_cpu(get_unaligned((__le32 *)p));
209}
210static inline unsigned int isonum_732(char *p)
211{
212 return be32_to_cpu(get_unaligned((__le32 *)p));
213}
214static inline unsigned int isonum_733(char *p)
215{
216 /* Ignore bigendian datum due to broken mastering programs */
217 return le32_to_cpu(get_unaligned((__le32 *)p));
218}
219extern int iso_date(char *, int);
220
221struct inode; /* To make gcc happy */
222
223extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *);
224extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
225extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
226
227int get_joliet_filename(struct iso_directory_record *, unsigned char *, struct inode *);
228int get_acorn_filename(struct iso_directory_record *, char *, struct inode *);
229
230extern struct dentry *isofs_lookup(struct inode *, struct dentry *, struct nameidata *);
231extern struct buffer_head *isofs_bread(struct inode *, sector_t);
232extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long);
233
234extern struct inode *isofs_iget(struct super_block *sb,
235 unsigned long block,
236 unsigned long offset);
237
238/* Because the inode number is no longer relevant to finding the
239 * underlying meta-data for an inode, we are free to choose a more
240 * convenient 32-bit number as the inode number. The inode numbering
241 * scheme was recommended by Sergey Vlasov and Eric Lammerts. */
242static inline unsigned long isofs_get_ino(unsigned long block,
243 unsigned long offset,
244 unsigned long bufbits)
245{
246 return (block << (bufbits - 5)) | (offset >> 5);
247}
248
249/* Every directory can have many redundant directory entries scattered
250 * throughout the directory tree. First there is the directory entry
251 * with the name of the directory stored in the parent directory.
252 * Then, there is the "." directory entry stored in the directory
253 * itself. Finally, there are possibly many ".." directory entries
254 * stored in all the subdirectories.
255 *
256 * In order for the NFS get_parent() method to work and for the
257 * general consistency of the dcache, we need to make sure the
258 * "i_iget5_block" and "i_iget5_offset" all point to exactly one of
259 * the many redundant entries for each directory. We normalize the
260 * block and offset by always making them point to the "." directory.
261 *
262 * Notice that we do not use the entry for the directory with the name
263 * that is located in the parent directory. Even though choosing this
264 * first directory is more natural, it is much easier to find the "."
265 * entry in the NFS get_parent() method because it is implicitly
266 * encoded in the "extent + ext_attr_length" fields of _all_ the
267 * redundant entries for the directory. Thus, it can always be
268 * reached regardless of which directory entry you have in hand.
269 *
270 * This works because the "." entry is simply the first directory
271 * record when you start reading the file that holds all the directory
272 * records, and this file starts at "extent + ext_attr_length" blocks.
273 * Because the "." entry is always the first entry listed in the
274 * directories file, the normalized "offset" value is always 0.
275 *
276 * You should pass the directory entry in "de". On return, "block"
277 * and "offset" will hold normalized values. Only directories are
278 * affected making it safe to call even for non-directory file
279 * types. */
280static inline void
281isofs_normalize_block_and_offset(struct iso_directory_record* de,
282 unsigned long *block,
283 unsigned long *offset)
284{
285 /* Only directories are normalized. */
286 if (de->flags[0] & 2) {
287 *offset = 0;
288 *block = (unsigned long)isonum_733(de->extent)
289 + (unsigned long)isonum_711(de->ext_attr_length);
290 }
291}
292
293extern struct inode_operations isofs_dir_inode_operations;
294extern struct file_operations isofs_dir_operations;
295extern struct address_space_operations isofs_symlink_aops;
296extern struct export_operations isofs_export_ops;
297
298/* The following macros are used to check for memory leaks. */
299#ifdef LEAK_CHECK
300#define free_s leak_check_free_s
301#define malloc leak_check_malloc
302#define sb_bread leak_check_bread
303#define brelse leak_check_brelse
304extern void * leak_check_malloc(unsigned int size);
305extern void leak_check_free_s(void * obj, int size);
306extern struct buffer_head * leak_check_bread(struct super_block *sb, int block);
307extern void leak_check_brelse(struct buffer_head * bh);
308#endif /* LEAK_CHECK */
309
310#endif /* __KERNEL__ */
311
312#endif 165#endif
diff --git a/include/linux/iso_fs_i.h b/include/linux/iso_fs_i.h
deleted file mode 100644
index 59065e939eaa..000000000000
--- a/include/linux/iso_fs_i.h
+++ /dev/null
@@ -1,27 +0,0 @@
1#ifndef _ISO_FS_I
2#define _ISO_FS_I
3
4#include <linux/fs.h>
5
6enum isofs_file_format {
7 isofs_file_normal = 0,
8 isofs_file_sparse = 1,
9 isofs_file_compressed = 2,
10};
11
12/*
13 * iso fs inode data in memory
14 */
15struct iso_inode_info {
16 unsigned long i_iget5_block;
17 unsigned long i_iget5_offset;
18 unsigned int i_first_extent;
19 unsigned char i_file_format;
20 unsigned char i_format_parm[3];
21 unsigned long i_next_section_block;
22 unsigned long i_next_section_offset;
23 off_t i_section_size;
24 struct inode vfs_inode;
25};
26
27#endif
diff --git a/include/linux/iso_fs_sb.h b/include/linux/iso_fs_sb.h
deleted file mode 100644
index 043b97b55b8d..000000000000
--- a/include/linux/iso_fs_sb.h
+++ /dev/null
@@ -1,34 +0,0 @@
1#ifndef _ISOFS_FS_SB
2#define _ISOFS_FS_SB
3
4/*
5 * iso9660 super-block data in memory
6 */
7struct isofs_sb_info {
8 unsigned long s_ninodes;
9 unsigned long s_nzones;
10 unsigned long s_firstdatazone;
11 unsigned long s_log_zone_size;
12 unsigned long s_max_size;
13
14 unsigned char s_high_sierra; /* A simple flag */
15 unsigned char s_mapping;
16 int s_rock_offset; /* offset of SUSP fields within SU area */
17 unsigned char s_rock;
18 unsigned char s_joliet_level;
19 unsigned char s_utf8;
20 unsigned char s_cruft; /* Broken disks with high
21 byte of length containing
22 junk */
23 unsigned char s_unhide;
24 unsigned char s_nosuid;
25 unsigned char s_nodev;
26 unsigned char s_nocompress;
27
28 mode_t s_mode;
29 gid_t s_gid;
30 uid_t s_uid;
31 struct nls_table *s_nls_iocharset; /* Native language support table */
32};
33
34#endif
diff --git a/include/linux/ixjuser.h b/include/linux/ixjuser.h
index 88121166d715..fd1756d3a47e 100644
--- a/include/linux/ixjuser.h
+++ b/include/linux/ixjuser.h
@@ -42,8 +42,6 @@
42 * 42 *
43 *****************************************************************************/ 43 *****************************************************************************/
44 44
45static char ixjuser_h_rcsid[] = "$Id: ixjuser.h,v 4.1 2001/08/05 00:17:37 craigs Exp $";
46
47#include <linux/telephony.h> 45#include <linux/telephony.h>
48 46
49 47
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 7c1cba4a5278..e25b97062ce1 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -115,10 +115,19 @@ extern int __kernel_text_address(unsigned long addr);
115extern int kernel_text_address(unsigned long addr); 115extern int kernel_text_address(unsigned long addr);
116extern int session_of_pgrp(int pgrp); 116extern int session_of_pgrp(int pgrp);
117 117
118#ifdef CONFIG_PRINTK
118asmlinkage int vprintk(const char *fmt, va_list args) 119asmlinkage int vprintk(const char *fmt, va_list args)
119 __attribute__ ((format (printf, 1, 0))); 120 __attribute__ ((format (printf, 1, 0)));
120asmlinkage int printk(const char * fmt, ...) 121asmlinkage int printk(const char * fmt, ...)
121 __attribute__ ((format (printf, 1, 2))); 122 __attribute__ ((format (printf, 1, 2)));
123#else
124static inline int vprintk(const char *s, va_list args)
125 __attribute__ ((format (printf, 1, 0)));
126static inline int vprintk(const char *s, va_list args) { return 0; }
127static inline int printk(const char *s, ...)
128 __attribute__ ((format (printf, 1, 2)));
129static inline int printk(const char *s, ...) { return 0; }
130#endif
122 131
123unsigned long int_sqrt(unsigned long); 132unsigned long int_sqrt(unsigned long);
124 133
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index f20c163de4f5..99ddba5a4e00 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -43,6 +43,9 @@ typedef int (*kprobe_fault_handler_t) (struct kprobe *, struct pt_regs *,
43struct kprobe { 43struct kprobe {
44 struct hlist_node hlist; 44 struct hlist_node hlist;
45 45
46 /* list of kprobes for multi-handler support */
47 struct list_head list;
48
46 /* location of the probe point */ 49 /* location of the probe point */
47 kprobe_opcode_t *addr; 50 kprobe_opcode_t *addr;
48 51
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c74a74ca401d..17518fe0b311 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -637,9 +637,9 @@ extern unsigned long do_mremap(unsigned long addr,
637 * These functions are passed a count `nr_to_scan' and a gfpmask. They should 637 * These functions are passed a count `nr_to_scan' and a gfpmask. They should
638 * scan `nr_to_scan' objects, attempting to free them. 638 * scan `nr_to_scan' objects, attempting to free them.
639 * 639 *
640 * The callback must the number of objects which remain in the cache. 640 * The callback must return the number of objects which remain in the cache.
641 * 641 *
642 * The callback will be passes nr_to_scan == 0 when the VM is querying the 642 * The callback will be passed nr_to_scan == 0 when the VM is querying the
643 * cache size, so a fastpath for that case is appropriate. 643 * cache size, so a fastpath for that case is appropriate.
644 */ 644 */
645typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask); 645typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask);
@@ -726,6 +726,7 @@ extern void __vma_link_rb(struct mm_struct *, struct vm_area_struct *,
726extern struct vm_area_struct *copy_vma(struct vm_area_struct **, 726extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
727 unsigned long addr, unsigned long len, pgoff_t pgoff); 727 unsigned long addr, unsigned long len, pgoff_t pgoff);
728extern void exit_mmap(struct mm_struct *); 728extern void exit_mmap(struct mm_struct *);
729extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
729 730
730extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 731extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
731 732
diff --git a/include/linux/mpage.h b/include/linux/mpage.h
index dea1b0083661..3ca880463c47 100644
--- a/include/linux/mpage.h
+++ b/include/linux/mpage.h
@@ -20,9 +20,6 @@ int mpage_writepages(struct address_space *mapping,
20 struct writeback_control *wbc, get_block_t get_block); 20 struct writeback_control *wbc, get_block_t get_block);
21int mpage_writepage(struct page *page, get_block_t *get_block, 21int mpage_writepage(struct page *page, get_block_t *get_block,
22 struct writeback_control *wbc); 22 struct writeback_control *wbc);
23int __mpage_writepages(struct address_space *mapping,
24 struct writeback_control *wbc, get_block_t get_block,
25 writepage_t writepage);
26 23
27static inline int 24static inline int
28generic_writepages(struct address_space *mapping, struct writeback_control *wbc) 25generic_writepages(struct address_space *mapping, struct writeback_control *wbc)
diff --git a/include/linux/net.h b/include/linux/net.h
index 7823b3482506..6d997ff3f103 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -7,7 +7,7 @@
7 * Version: @(#)net.h 1.0.3 05/25/93 7 * Version: @(#)net.h 1.0.3 05/25/93
8 * 8 *
9 * Authors: Orest Zborowski, <obz@Kodak.COM> 9 * Authors: Orest Zborowski, <obz@Kodak.COM>
10 * Ross Biro, <bir7@leland.Stanford.Edu> 10 * Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
@@ -64,19 +64,19 @@ typedef enum {
64#define SOCK_PASSCRED 3 64#define SOCK_PASSCRED 3
65 65
66#ifndef ARCH_HAS_SOCKET_TYPES 66#ifndef ARCH_HAS_SOCKET_TYPES
67/** sock_type - Socket types 67/**
68 * 68 * enum sock_type - Socket types
69 * @SOCK_STREAM: stream (connection) socket
70 * @SOCK_DGRAM: datagram (conn.less) socket
71 * @SOCK_RAW: raw socket
72 * @SOCK_RDM: reliably-delivered message
73 * @SOCK_SEQPACKET: sequential packet socket
74 * @SOCK_PACKET: linux specific way of getting packets at the dev level.
75 * For writing rarp and other similar things on the user level.
76 *
69 * When adding some new socket type please 77 * When adding some new socket type please
70 * grep ARCH_HAS_SOCKET_TYPE include/asm-* /socket.h, at least MIPS 78 * grep ARCH_HAS_SOCKET_TYPE include/asm-* /socket.h, at least MIPS
71 * overrides this enum for binary compat reasons. 79 * overrides this enum for binary compat reasons.
72 *
73 * @SOCK_STREAM - stream (connection) socket
74 * @SOCK_DGRAM - datagram (conn.less) socket
75 * @SOCK_RAW - raw socket
76 * @SOCK_RDM - reliably-delivered message
77 * @SOCK_SEQPACKET - sequential packet socket
78 * @SOCK_PACKET - linux specific way of getting packets at the dev level.
79 * For writing rarp and other similar things on the user level.
80 */ 80 */
81enum sock_type { 81enum sock_type {
82 SOCK_STREAM = 1, 82 SOCK_STREAM = 1,
@@ -93,15 +93,15 @@ enum sock_type {
93 93
94/** 94/**
95 * struct socket - general BSD socket 95 * struct socket - general BSD socket
96 * @state - socket state (%SS_CONNECTED, etc) 96 * @state: socket state (%SS_CONNECTED, etc)
97 * @flags - socket flags (%SOCK_ASYNC_NOSPACE, etc) 97 * @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc)
98 * @ops - protocol specific socket operations 98 * @ops: protocol specific socket operations
99 * @fasync_list - Asynchronous wake up list 99 * @fasync_list: Asynchronous wake up list
100 * @file - File back pointer for gc 100 * @file: File back pointer for gc
101 * @sk - internal networking protocol agnostic socket representation 101 * @sk: internal networking protocol agnostic socket representation
102 * @wait - wait queue for several uses 102 * @wait: wait queue for several uses
103 * @type - socket type (%SOCK_STREAM, etc) 103 * @type: socket type (%SOCK_STREAM, etc)
104 * @passcred - credentials (used only in Unix Sockets (aka PF_LOCAL)) 104 * @passcred: credentials (used only in Unix Sockets (aka PF_LOCAL))
105 */ 105 */
106struct socket { 106struct socket {
107 socket_state state; 107 socket_state state;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8d775be67833..ac11d73be4ce 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)dev.h 1.0.10 08/12/93 8 * Version: @(#)dev.h 1.0.10 08/12/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Corey Minyard <wf-rch!minyard@relay.EU.net> 12 * Corey Minyard <wf-rch!minyard@relay.EU.net>
13 * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov> 13 * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov>
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index c9bacf9b2431..9e5750079e09 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -62,6 +62,9 @@ enum nf_ip_hook_priorities {
62 NF_IP_PRI_FILTER = 0, 62 NF_IP_PRI_FILTER = 0,
63 NF_IP_PRI_NAT_SRC = 100, 63 NF_IP_PRI_NAT_SRC = 100,
64 NF_IP_PRI_SELINUX_LAST = 225, 64 NF_IP_PRI_SELINUX_LAST = 225,
65 NF_IP_PRI_CONNTRACK_HELPER = INT_MAX - 2,
66 NF_IP_PRI_NAT_SEQ_ADJUST = INT_MAX - 1,
67 NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX,
65 NF_IP_PRI_LAST = INT_MAX, 68 NF_IP_PRI_LAST = INT_MAX,
66}; 69};
67 70
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index f731abdc1a29..b2738ac8bc99 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -110,6 +110,7 @@ struct netlink_skb_parms
110 __u32 dst_pid; 110 __u32 dst_pid;
111 __u32 dst_groups; 111 __u32 dst_groups;
112 kernel_cap_t eff_cap; 112 kernel_cap_t eff_cap;
113 __u32 loginuid; /* Login (audit) uid */
113}; 114};
114 115
115#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb)) 116#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 6b74fcf5bb63..39ab8c6b5652 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -131,6 +131,7 @@ struct page_state {
131 unsigned long allocstall; /* direct reclaim calls */ 131 unsigned long allocstall; /* direct reclaim calls */
132 132
133 unsigned long pgrotated; /* pages rotated to tail of the LRU */ 133 unsigned long pgrotated; /* pages rotated to tail of the LRU */
134 unsigned long nr_bounce; /* pages for bounce buffers */
134}; 135};
135 136
136extern void get_page_state(struct page_state *ret); 137extern void get_page_state(struct page_state *ret);
diff --git a/include/linux/patchkey.h b/include/linux/patchkey.h
new file mode 100644
index 000000000000..d974a6e92372
--- /dev/null
+++ b/include/linux/patchkey.h
@@ -0,0 +1,45 @@
1/*
2 * <linux/patchkey.h> -- definition of _PATCHKEY macro
3 *
4 * Copyright (C) 2005 Stuart Brady
5 *
6 * This exists because awe_voice.h defined its own _PATCHKEY and it wasn't
7 * clear whether removing this would break anything in userspace.
8 *
9 * Do not include this file directly. Please use <sys/soundcard.h> instead.
10 * For kernel code, use <linux/soundcard.h>
11 */
12
13#ifndef _LINUX_PATCHKEY_H_INDIRECT
14#error "patchkey.h included directly"
15#endif
16
17#ifndef _LINUX_PATCHKEY_H
18#define _LINUX_PATCHKEY_H
19
20/* Endian macros. */
21#ifdef __KERNEL__
22# include <asm/byteorder.h>
23#else
24# include <endian.h>
25#endif
26
27#if defined(__KERNEL__)
28# if defined(__BIG_ENDIAN)
29# define _PATCHKEY(id) (0xfd00|id)
30# elif defined(__LITTLE_ENDIAN)
31# define _PATCHKEY(id) ((id<<8)|0x00fd)
32# else
33# error "could not determine byte order"
34# endif
35#elif defined(__BYTE_ORDER)
36# if __BYTE_ORDER == __BIG_ENDIAN
37# define _PATCHKEY(id) (0xfd00|id)
38# elif __BYTE_ORDER == __LITTLE_ENDIAN
39# define _PATCHKEY(id) ((id<<8)|0x00fd)
40# else
41# error "could not determine byte order"
42# endif
43#endif
44
45#endif /* _LINUX_PATCHKEY_H */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3c89148ae28a..b5238bd18830 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -671,6 +671,7 @@ struct pci_driver {
671 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ 671 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
672 int (*resume) (struct pci_dev *dev); /* Device woken up */ 672 int (*resume) (struct pci_dev *dev); /* Device woken up */
673 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ 673 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */
674 void (*shutdown) (struct pci_dev *dev);
674 675
675 struct device_driver driver; 676 struct device_driver driver;
676 struct pci_dynids dynids; 677 struct pci_dynids dynids;
@@ -810,7 +811,6 @@ void pci_set_master(struct pci_dev *dev);
810int pci_set_mwi(struct pci_dev *dev); 811int pci_set_mwi(struct pci_dev *dev);
811void pci_clear_mwi(struct pci_dev *dev); 812void pci_clear_mwi(struct pci_dev *dev);
812int pci_set_dma_mask(struct pci_dev *dev, u64 mask); 813int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
813int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask);
814int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); 814int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
815int pci_assign_resource(struct pci_dev *dev, int i); 815int pci_assign_resource(struct pci_dev *dev, int i);
816 816
@@ -941,7 +941,6 @@ static inline void pci_set_master(struct pci_dev *dev) { }
941static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } 941static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
942static inline void pci_disable_device(struct pci_dev *dev) { } 942static inline void pci_disable_device(struct pci_dev *dev) { }
943static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } 943static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
944static inline int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; }
945static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} 944static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;}
946static inline int pci_register_driver(struct pci_driver *drv) { return 0;} 945static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
947static inline void pci_unregister_driver(struct pci_driver *drv) { } 946static inline void pci_unregister_driver(struct pci_driver *drv) { }
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index f1f75fde8cd4..ae27792b5aa4 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -854,6 +854,7 @@
854#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020 854#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020
855#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050 855#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050
856#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56 856#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56
857#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166
857 858
858#define PCI_VENDOR_ID_PICOP 0x1066 859#define PCI_VENDOR_ID_PICOP 0x1066
859#define PCI_DEVICE_ID_PICOP_PT86C52X 0x0001 860#define PCI_DEVICE_ID_PICOP_PT86C52X 0x0001
@@ -2062,6 +2063,7 @@
2062#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 2063#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182
2063 2064
2064#define PCI_VENDOR_ID_BROADCOM 0x14e4 2065#define PCI_VENDOR_ID_BROADCOM 0x14e4
2066#define PCI_DEVICE_ID_TIGON3_5752 0x1600
2065#define PCI_DEVICE_ID_TIGON3_5700 0x1644 2067#define PCI_DEVICE_ID_TIGON3_5700 0x1644
2066#define PCI_DEVICE_ID_TIGON3_5701 0x1645 2068#define PCI_DEVICE_ID_TIGON3_5701 0x1645
2067#define PCI_DEVICE_ID_TIGON3_5702 0x1646 2069#define PCI_DEVICE_ID_TIGON3_5702 0x1646
@@ -2414,6 +2416,8 @@
2414#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 2416#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9
2415#define PCI_DEVICE_ID_INTEL_ICH7_2 0x27c0 2417#define PCI_DEVICE_ID_INTEL_ICH7_2 0x27c0
2416#define PCI_DEVICE_ID_INTEL_ICH7_3 0x27c1 2418#define PCI_DEVICE_ID_INTEL_ICH7_3 0x27c1
2419#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0
2420#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd
2417#define PCI_DEVICE_ID_INTEL_ICH7_5 0x27c4 2421#define PCI_DEVICE_ID_INTEL_ICH7_5 0x27c4
2418#define PCI_DEVICE_ID_INTEL_ICH7_6 0x27c5 2422#define PCI_DEVICE_ID_INTEL_ICH7_6 0x27c5
2419#define PCI_DEVICE_ID_INTEL_ICH7_7 0x27c8 2423#define PCI_DEVICE_ID_INTEL_ICH7_7 0x27c8
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 4d747433916b..fd276adf0fd5 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -157,9 +157,9 @@ static inline int rcu_pending(int cpu)
157/** 157/**
158 * rcu_read_lock - mark the beginning of an RCU read-side critical section. 158 * rcu_read_lock - mark the beginning of an RCU read-side critical section.
159 * 159 *
160 * When synchronize_kernel() is invoked on one CPU while other CPUs 160 * When synchronize_rcu() is invoked on one CPU while other CPUs
161 * are within RCU read-side critical sections, then the 161 * are within RCU read-side critical sections, then the
162 * synchronize_kernel() is guaranteed to block until after all the other 162 * synchronize_rcu() is guaranteed to block until after all the other
163 * CPUs exit their critical sections. Similarly, if call_rcu() is invoked 163 * CPUs exit their critical sections. Similarly, if call_rcu() is invoked
164 * on one CPU while other CPUs are within RCU read-side critical 164 * on one CPU while other CPUs are within RCU read-side critical
165 * sections, invocation of the corresponding RCU callback is deferred 165 * sections, invocation of the corresponding RCU callback is deferred
@@ -256,6 +256,21 @@ static inline int rcu_pending(int cpu)
256 (p) = (v); \ 256 (p) = (v); \
257 }) 257 })
258 258
259/**
260 * synchronize_sched - block until all CPUs have exited any non-preemptive
261 * kernel code sequences.
262 *
263 * This means that all preempt_disable code sequences, including NMI and
264 * hardware-interrupt handlers, in progress on entry will have completed
265 * before this primitive returns. However, this does not guarantee that
266 * softirq handlers will have completed, since in some kernels
267 *
268 * This primitive provides the guarantees made by the (deprecated)
269 * synchronize_kernel() API. In contrast, synchronize_rcu() only
270 * guarantees that rcu_read_lock() sections will have completed.
271 */
272#define synchronize_sched() synchronize_rcu()
273
259extern void rcu_init(void); 274extern void rcu_init(void);
260extern void rcu_check_callbacks(int cpu, int user); 275extern void rcu_check_callbacks(int cpu, int user);
261extern void rcu_restart_cpu(int cpu); 276extern void rcu_restart_cpu(int cpu);
@@ -265,7 +280,9 @@ extern void FASTCALL(call_rcu(struct rcu_head *head,
265 void (*func)(struct rcu_head *head))); 280 void (*func)(struct rcu_head *head)));
266extern void FASTCALL(call_rcu_bh(struct rcu_head *head, 281extern void FASTCALL(call_rcu_bh(struct rcu_head *head,
267 void (*func)(struct rcu_head *head))); 282 void (*func)(struct rcu_head *head)));
268extern void synchronize_kernel(void); 283extern __deprecated_for_modules void synchronize_kernel(void);
284extern void synchronize_rcu(void);
285void synchronize_idle(void);
269 286
270#endif /* __KERNEL__ */ 287#endif /* __KERNEL__ */
271#endif /* __LINUX_RCUPDATE_H */ 288#endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/reboot_fixups.h b/include/linux/reboot_fixups.h
new file mode 100644
index 000000000000..480ea2d489d8
--- /dev/null
+++ b/include/linux/reboot_fixups.h
@@ -0,0 +1,10 @@
1#ifndef _LINUX_REBOOT_FIXUPS_H
2#define _LINUX_REBOOT_FIXUPS_H
3
4#ifdef CONFIG_X86_REBOOTFIXUPS
5extern void mach_reboot_fixups(void);
6#else
7#define mach_reboot_fixups() ((void)(0))
8#endif
9
10#endif /* _LINUX_REBOOT_FIXUPS_H */
diff --git a/include/linux/reiserfs_acl.h b/include/linux/reiserfs_acl.h
index a57e973af0bd..2aef9c3f5ce8 100644
--- a/include/linux/reiserfs_acl.h
+++ b/include/linux/reiserfs_acl.h
@@ -5,18 +5,18 @@
5#define REISERFS_ACL_VERSION 0x0001 5#define REISERFS_ACL_VERSION 0x0001
6 6
7typedef struct { 7typedef struct {
8 __u16 e_tag; 8 __le16 e_tag;
9 __u16 e_perm; 9 __le16 e_perm;
10 __u32 e_id; 10 __le32 e_id;
11} reiserfs_acl_entry; 11} reiserfs_acl_entry;
12 12
13typedef struct { 13typedef struct {
14 __u16 e_tag; 14 __le16 e_tag;
15 __u16 e_perm; 15 __le16 e_perm;
16} reiserfs_acl_entry_short; 16} reiserfs_acl_entry_short;
17 17
18typedef struct { 18typedef struct {
19 __u32 a_version; 19 __le32 a_version;
20} reiserfs_acl_header; 20} reiserfs_acl_header;
21 21
22static inline size_t reiserfs_acl_size(int count) 22static inline size_t reiserfs_acl_size(int count)
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index bccff8b17dc4..32148625fc2f 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -114,47 +114,47 @@ if( !( cond ) ) \
114 114
115 115
116struct journal_params { 116struct journal_params {
117 __u32 jp_journal_1st_block; /* where does journal start from on its 117 __le32 jp_journal_1st_block; /* where does journal start from on its
118 * device */ 118 * device */
119 __u32 jp_journal_dev; /* journal device st_rdev */ 119 __le32 jp_journal_dev; /* journal device st_rdev */
120 __u32 jp_journal_size; /* size of the journal */ 120 __le32 jp_journal_size; /* size of the journal */
121 __u32 jp_journal_trans_max; /* max number of blocks in a transaction. */ 121 __le32 jp_journal_trans_max; /* max number of blocks in a transaction. */
122 __u32 jp_journal_magic; /* random value made on fs creation (this 122 __le32 jp_journal_magic; /* random value made on fs creation (this
123 * was sb_journal_block_count) */ 123 * was sb_journal_block_count) */
124 __u32 jp_journal_max_batch; /* max number of blocks to batch into a 124 __le32 jp_journal_max_batch; /* max number of blocks to batch into a
125 * trans */ 125 * trans */
126 __u32 jp_journal_max_commit_age; /* in seconds, how old can an async 126 __le32 jp_journal_max_commit_age; /* in seconds, how old can an async
127 * commit be */ 127 * commit be */
128 __u32 jp_journal_max_trans_age; /* in seconds, how old can a transaction 128 __le32 jp_journal_max_trans_age; /* in seconds, how old can a transaction
129 * be */ 129 * be */
130}; 130};
131 131
132/* this is the super from 3.5.X, where X >= 10 */ 132/* this is the super from 3.5.X, where X >= 10 */
133struct reiserfs_super_block_v1 133struct reiserfs_super_block_v1
134{ 134{
135 __u32 s_block_count; /* blocks count */ 135 __le32 s_block_count; /* blocks count */
136 __u32 s_free_blocks; /* free blocks count */ 136 __le32 s_free_blocks; /* free blocks count */
137 __u32 s_root_block; /* root block number */ 137 __le32 s_root_block; /* root block number */
138 struct journal_params s_journal; 138 struct journal_params s_journal;
139 __u16 s_blocksize; /* block size */ 139 __le16 s_blocksize; /* block size */
140 __u16 s_oid_maxsize; /* max size of object id array, see 140 __le16 s_oid_maxsize; /* max size of object id array, see
141 * get_objectid() commentary */ 141 * get_objectid() commentary */
142 __u16 s_oid_cursize; /* current size of object id array */ 142 __le16 s_oid_cursize; /* current size of object id array */
143 __u16 s_umount_state; /* this is set to 1 when filesystem was 143 __le16 s_umount_state; /* this is set to 1 when filesystem was
144 * umounted, to 2 - when not */ 144 * umounted, to 2 - when not */
145 char s_magic[10]; /* reiserfs magic string indicates that 145 char s_magic[10]; /* reiserfs magic string indicates that
146 * file system is reiserfs: 146 * file system is reiserfs:
147 * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */ 147 * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
148 __u16 s_fs_state; /* it is set to used by fsck to mark which 148 __le16 s_fs_state; /* it is set to used by fsck to mark which
149 * phase of rebuilding is done */ 149 * phase of rebuilding is done */
150 __u32 s_hash_function_code; /* indicate, what hash function is being use 150 __le32 s_hash_function_code; /* indicate, what hash function is being use
151 * to sort names in a directory*/ 151 * to sort names in a directory*/
152 __u16 s_tree_height; /* height of disk tree */ 152 __le16 s_tree_height; /* height of disk tree */
153 __u16 s_bmap_nr; /* amount of bitmap blocks needed to address 153 __le16 s_bmap_nr; /* amount of bitmap blocks needed to address
154 * each block of file system */ 154 * each block of file system */
155 __u16 s_version; /* this field is only reliable on filesystem 155 __le16 s_version; /* this field is only reliable on filesystem
156 * with non-standard journal */ 156 * with non-standard journal */
157 __u16 s_reserved_for_journal; /* size in blocks of journal area on main 157 __le16 s_reserved_for_journal; /* size in blocks of journal area on main
158 * device, we need to keep after 158 * device, we need to keep after
159 * making fs with non-standard journal */ 159 * making fs with non-standard journal */
160} __attribute__ ((__packed__)); 160} __attribute__ ((__packed__));
@@ -165,8 +165,8 @@ struct reiserfs_super_block_v1
165struct reiserfs_super_block 165struct reiserfs_super_block
166{ 166{
167 struct reiserfs_super_block_v1 s_v1; 167 struct reiserfs_super_block_v1 s_v1;
168 __u32 s_inode_generation; 168 __le32 s_inode_generation;
169 __u32 s_flags; /* Right now used only by inode-attributes, if enabled */ 169 __le32 s_flags; /* Right now used only by inode-attributes, if enabled */
170 unsigned char s_uuid[16]; /* filesystem unique identifier */ 170 unsigned char s_uuid[16]; /* filesystem unique identifier */
171 unsigned char s_label[16]; /* filesystem volume label */ 171 unsigned char s_label[16]; /* filesystem volume label */
172 char s_unused[88] ; /* zero filled by mkreiserfs and 172 char s_unused[88] ; /* zero filled by mkreiserfs and
@@ -225,7 +225,7 @@ struct reiserfs_super_block
225#define SB_ONDISK_JOURNAL_DEVICE(s) \ 225#define SB_ONDISK_JOURNAL_DEVICE(s) \
226 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_dev)) 226 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_dev))
227#define SB_ONDISK_RESERVED_FOR_JOURNAL(s) \ 227#define SB_ONDISK_RESERVED_FOR_JOURNAL(s) \
228 le32_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_reserved_for_journal)) 228 le16_to_cpu ((SB_V1_DISK_SUPER_BLOCK(s)->s_reserved_for_journal))
229 229
230#define is_block_in_log_or_reserved_area(s, block) \ 230#define is_block_in_log_or_reserved_area(s, block) \
231 block >= SB_JOURNAL_1st_RESERVED_BLOCK(s) \ 231 block >= SB_JOURNAL_1st_RESERVED_BLOCK(s) \
@@ -269,7 +269,7 @@ int is_reiserfs_jr (struct reiserfs_super_block * rs);
269#define QUOTA_EXCEEDED -6 269#define QUOTA_EXCEEDED -6
270 270
271typedef __u32 b_blocknr_t; 271typedef __u32 b_blocknr_t;
272typedef __u32 unp_t; 272typedef __le32 unp_t;
273 273
274struct unfm_nodeinfo { 274struct unfm_nodeinfo {
275 unp_t unfm_nodenum; 275 unp_t unfm_nodenum;
@@ -376,78 +376,57 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
376// directories use this key as well as old files 376// directories use this key as well as old files
377// 377//
378struct offset_v1 { 378struct offset_v1 {
379 __u32 k_offset; 379 __le32 k_offset;
380 __u32 k_uniqueness; 380 __le32 k_uniqueness;
381} __attribute__ ((__packed__)); 381} __attribute__ ((__packed__));
382 382
383struct offset_v2 { 383struct offset_v2 {
384#ifdef __LITTLE_ENDIAN 384 __le64 v;
385 /* little endian version */
386 __u64 k_offset:60;
387 __u64 k_type: 4;
388#else
389 /* big endian version */
390 __u64 k_type: 4;
391 __u64 k_offset:60;
392#endif
393} __attribute__ ((__packed__)); 385} __attribute__ ((__packed__));
394 386
395#ifndef __LITTLE_ENDIAN
396typedef union {
397 struct offset_v2 offset_v2;
398 __u64 linear;
399} __attribute__ ((__packed__)) offset_v2_esafe_overlay;
400
401static inline __u16 offset_v2_k_type( const struct offset_v2 *v2 ) 387static inline __u16 offset_v2_k_type( const struct offset_v2 *v2 )
402{ 388{
403 offset_v2_esafe_overlay tmp = *(const offset_v2_esafe_overlay *)v2; 389 __u8 type = le64_to_cpu(v2->v) >> 60;
404 tmp.linear = le64_to_cpu( tmp.linear ); 390 return (type <= TYPE_MAXTYPE)?type:TYPE_ANY;
405 return (tmp.offset_v2.k_type <= TYPE_MAXTYPE)?tmp.offset_v2.k_type:TYPE_ANY;
406} 391}
407 392
408static inline void set_offset_v2_k_type( struct offset_v2 *v2, int type ) 393static inline void set_offset_v2_k_type( struct offset_v2 *v2, int type )
409{ 394{
410 offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2; 395 v2->v = (v2->v & cpu_to_le64(~0ULL>>4)) | cpu_to_le64((__u64)type<<60);
411 tmp->linear = le64_to_cpu(tmp->linear);
412 tmp->offset_v2.k_type = type;
413 tmp->linear = cpu_to_le64(tmp->linear);
414} 396}
415 397
416static inline loff_t offset_v2_k_offset( const struct offset_v2 *v2 ) 398static inline loff_t offset_v2_k_offset( const struct offset_v2 *v2 )
417{ 399{
418 offset_v2_esafe_overlay tmp = *(const offset_v2_esafe_overlay *)v2; 400 return le64_to_cpu(v2->v) & (~0ULL>>4);
419 tmp.linear = le64_to_cpu( tmp.linear );
420 return tmp.offset_v2.k_offset;
421} 401}
422 402
423static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){ 403static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){
424 offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2; 404 offset &= (~0ULL>>4);
425 tmp->linear = le64_to_cpu(tmp->linear); 405 v2->v = (v2->v & cpu_to_le64(15ULL<<60)) | cpu_to_le64(offset);
426 tmp->offset_v2.k_offset = offset;
427 tmp->linear = cpu_to_le64(tmp->linear);
428} 406}
429#else
430# define offset_v2_k_type(v2) ((v2)->k_type)
431# define set_offset_v2_k_type(v2,val) (offset_v2_k_type(v2) = (val))
432# define offset_v2_k_offset(v2) ((v2)->k_offset)
433# define set_offset_v2_k_offset(v2,val) (offset_v2_k_offset(v2) = (val))
434#endif
435 407
436/* Key of an item determines its location in the S+tree, and 408/* Key of an item determines its location in the S+tree, and
437 is composed of 4 components */ 409 is composed of 4 components */
438struct reiserfs_key { 410struct reiserfs_key {
439 __u32 k_dir_id; /* packing locality: by default parent 411 __le32 k_dir_id; /* packing locality: by default parent
440 directory object id */ 412 directory object id */
441 __u32 k_objectid; /* object identifier */ 413 __le32 k_objectid; /* object identifier */
442 union { 414 union {
443 struct offset_v1 k_offset_v1; 415 struct offset_v1 k_offset_v1;
444 struct offset_v2 k_offset_v2; 416 struct offset_v2 k_offset_v2;
445 } __attribute__ ((__packed__)) u; 417 } __attribute__ ((__packed__)) u;
446} __attribute__ ((__packed__)); 418} __attribute__ ((__packed__));
447 419
420struct in_core_key {
421 __u32 k_dir_id; /* packing locality: by default parent
422 directory object id */
423 __u32 k_objectid; /* object identifier */
424 __u64 k_offset;
425 __u8 k_type;
426};
448 427
449struct cpu_key { 428struct cpu_key {
450 struct reiserfs_key on_disk_key; 429 struct in_core_key on_disk_key;
451 int version; 430 int version;
452 int key_length; /* 3 in all cases but direct2indirect and 431 int key_length; /* 3 in all cases but direct2indirect and
453 indirect2direct conversion */ 432 indirect2direct conversion */
@@ -508,15 +487,15 @@ struct item_head
508 item. Note that the key, not this field, is used to 487 item. Note that the key, not this field, is used to
509 determine the item type, and thus which field this 488 determine the item type, and thus which field this
510 union contains. */ 489 union contains. */
511 __u16 ih_free_space_reserved; 490 __le16 ih_free_space_reserved;
512 /* Iff this is a directory item, this field equals the 491 /* Iff this is a directory item, this field equals the
513 number of directory entries in the directory item. */ 492 number of directory entries in the directory item. */
514 __u16 ih_entry_count; 493 __le16 ih_entry_count;
515 } __attribute__ ((__packed__)) u; 494 } __attribute__ ((__packed__)) u;
516 __u16 ih_item_len; /* total size of the item body */ 495 __le16 ih_item_len; /* total size of the item body */
517 __u16 ih_item_location; /* an offset to the item body 496 __le16 ih_item_location; /* an offset to the item body
518 * within the block */ 497 * within the block */
519 __u16 ih_version; /* 0 for all old items, 2 for new 498 __le16 ih_version; /* 0 for all old items, 2 for new
520 ones. Highest bit is set by fsck 499 ones. Highest bit is set by fsck
521 temporary, cleaned after all 500 temporary, cleaned after all
522 done */ 501 done */
@@ -670,43 +649,29 @@ static inline void set_le_ih_k_type (struct item_head * ih, int type)
670// 649//
671static inline loff_t cpu_key_k_offset (const struct cpu_key * key) 650static inline loff_t cpu_key_k_offset (const struct cpu_key * key)
672{ 651{
673 return (key->version == KEY_FORMAT_3_5) ? 652 return key->on_disk_key.k_offset;
674 key->on_disk_key.u.k_offset_v1.k_offset :
675 key->on_disk_key.u.k_offset_v2.k_offset;
676} 653}
677 654
678static inline loff_t cpu_key_k_type (const struct cpu_key * key) 655static inline loff_t cpu_key_k_type (const struct cpu_key * key)
679{ 656{
680 return (key->version == KEY_FORMAT_3_5) ? 657 return key->on_disk_key.k_type;
681 uniqueness2type (key->on_disk_key.u.k_offset_v1.k_uniqueness) :
682 key->on_disk_key.u.k_offset_v2.k_type;
683} 658}
684 659
685static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset) 660static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset)
686{ 661{
687 (key->version == KEY_FORMAT_3_5) ? 662 key->on_disk_key.k_offset = offset;
688 (key->on_disk_key.u.k_offset_v1.k_offset = offset) :
689 (key->on_disk_key.u.k_offset_v2.k_offset = offset);
690} 663}
691 664
692
693static inline void set_cpu_key_k_type (struct cpu_key * key, int type) 665static inline void set_cpu_key_k_type (struct cpu_key * key, int type)
694{ 666{
695 (key->version == KEY_FORMAT_3_5) ? 667 key->on_disk_key.k_type = type;
696 (key->on_disk_key.u.k_offset_v1.k_uniqueness = type2uniqueness (type)):
697 (key->on_disk_key.u.k_offset_v2.k_type = type);
698} 668}
699 669
700
701static inline void cpu_key_k_offset_dec (struct cpu_key * key) 670static inline void cpu_key_k_offset_dec (struct cpu_key * key)
702{ 671{
703 if (key->version == KEY_FORMAT_3_5) 672 key->on_disk_key.k_offset --;
704 key->on_disk_key.u.k_offset_v1.k_offset --;
705 else
706 key->on_disk_key.u.k_offset_v2.k_offset --;
707} 673}
708 674
709
710#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY) 675#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY)
711#define is_direct_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRECT) 676#define is_direct_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRECT)
712#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT) 677#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)
@@ -752,10 +717,10 @@ extern struct reiserfs_key root_key;
752/* Header of a disk block. More precisely, header of a formatted leaf 717/* Header of a disk block. More precisely, header of a formatted leaf
753 or internal node, and not the header of an unformatted node. */ 718 or internal node, and not the header of an unformatted node. */
754struct block_head { 719struct block_head {
755 __u16 blk_level; /* Level of a block in the tree. */ 720 __le16 blk_level; /* Level of a block in the tree. */
756 __u16 blk_nr_item; /* Number of keys/items in a block. */ 721 __le16 blk_nr_item; /* Number of keys/items in a block. */
757 __u16 blk_free_space; /* Block free space in bytes. */ 722 __le16 blk_free_space; /* Block free space in bytes. */
758 __u16 blk_reserved; 723 __le16 blk_reserved;
759 /* dump this in v4/planA */ 724 /* dump this in v4/planA */
760 struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */ 725 struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */
761}; 726};
@@ -819,19 +784,19 @@ struct block_head {
819// 784//
820struct stat_data_v1 785struct stat_data_v1
821{ 786{
822 __u16 sd_mode; /* file type, permissions */ 787 __le16 sd_mode; /* file type, permissions */
823 __u16 sd_nlink; /* number of hard links */ 788 __le16 sd_nlink; /* number of hard links */
824 __u16 sd_uid; /* owner */ 789 __le16 sd_uid; /* owner */
825 __u16 sd_gid; /* group */ 790 __le16 sd_gid; /* group */
826 __u32 sd_size; /* file size */ 791 __le32 sd_size; /* file size */
827 __u32 sd_atime; /* time of last access */ 792 __le32 sd_atime; /* time of last access */
828 __u32 sd_mtime; /* time file was last modified */ 793 __le32 sd_mtime; /* time file was last modified */
829 __u32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */ 794 __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
830 union { 795 union {
831 __u32 sd_rdev; 796 __le32 sd_rdev;
832 __u32 sd_blocks; /* number of blocks file uses */ 797 __le32 sd_blocks; /* number of blocks file uses */
833 } __attribute__ ((__packed__)) u; 798 } __attribute__ ((__packed__)) u;
834 __u32 sd_first_direct_byte; /* first byte of file which is stored 799 __le32 sd_first_direct_byte; /* first byte of file which is stored
835 in a direct item: except that if it 800 in a direct item: except that if it
836 equals 1 it is a symlink and if it 801 equals 1 it is a symlink and if it
837 equals ~(__u32)0 there is no 802 equals ~(__u32)0 there is no
@@ -897,20 +862,20 @@ struct stat_data_v1
897/* Stat Data on disk (reiserfs version of UFS disk inode minus the 862/* Stat Data on disk (reiserfs version of UFS disk inode minus the
898 address blocks) */ 863 address blocks) */
899struct stat_data { 864struct stat_data {
900 __u16 sd_mode; /* file type, permissions */ 865 __le16 sd_mode; /* file type, permissions */
901 __u16 sd_attrs; /* persistent inode flags */ 866 __le16 sd_attrs; /* persistent inode flags */
902 __u32 sd_nlink; /* number of hard links */ 867 __le32 sd_nlink; /* number of hard links */
903 __u64 sd_size; /* file size */ 868 __le64 sd_size; /* file size */
904 __u32 sd_uid; /* owner */ 869 __le32 sd_uid; /* owner */
905 __u32 sd_gid; /* group */ 870 __le32 sd_gid; /* group */
906 __u32 sd_atime; /* time of last access */ 871 __le32 sd_atime; /* time of last access */
907 __u32 sd_mtime; /* time file was last modified */ 872 __le32 sd_mtime; /* time file was last modified */
908 __u32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */ 873 __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
909 __u32 sd_blocks; 874 __le32 sd_blocks;
910 union { 875 union {
911 __u32 sd_rdev; 876 __le32 sd_rdev;
912 __u32 sd_generation; 877 __le32 sd_generation;
913 //__u32 sd_first_direct_byte; 878 //__le32 sd_first_direct_byte;
914 /* first byte of file which is stored in a 879 /* first byte of file which is stored in a
915 direct item: except that if it equals 1 880 direct item: except that if it equals 1
916 it is a symlink and if it equals 881 it is a symlink and if it equals
@@ -993,12 +958,12 @@ struct stat_data {
993 958
994struct reiserfs_de_head 959struct reiserfs_de_head
995{ 960{
996 __u32 deh_offset; /* third component of the directory entry key */ 961 __le32 deh_offset; /* third component of the directory entry key */
997 __u32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced 962 __le32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced
998 by directory entry */ 963 by directory entry */
999 __u32 deh_objectid; /* objectid of the object, that is referenced by directory entry */ 964 __le32 deh_objectid; /* objectid of the object, that is referenced by directory entry */
1000 __u16 deh_location; /* offset of name in the whole item */ 965 __le16 deh_location; /* offset of name in the whole item */
1001 __u16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether 966 __le16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether
1002 entry is hidden (unlinked) */ 967 entry is hidden (unlinked) */
1003} __attribute__ ((__packed__)); 968} __attribute__ ((__packed__));
1004#define DEH_SIZE sizeof(struct reiserfs_de_head) 969#define DEH_SIZE sizeof(struct reiserfs_de_head)
@@ -1058,10 +1023,10 @@ struct reiserfs_de_head
1058#define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state)) 1023#define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1059#define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state)) 1024#define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1060 1025
1061extern void make_empty_dir_item_v1 (char * body, __u32 dirid, __u32 objid, 1026extern void make_empty_dir_item_v1 (char * body, __le32 dirid, __le32 objid,
1062 __u32 par_dirid, __u32 par_objid); 1027 __le32 par_dirid, __le32 par_objid);
1063extern void make_empty_dir_item (char * body, __u32 dirid, __u32 objid, 1028extern void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
1064 __u32 par_dirid, __u32 par_objid); 1029 __le32 par_dirid, __le32 par_objid);
1065 1030
1066/* array of the entry headers */ 1031/* array of the entry headers */
1067 /* get item body */ 1032 /* get item body */
@@ -1160,9 +1125,9 @@ struct reiserfs_dir_entry
1160/* Disk child pointer: The pointer from an internal node of the tree 1125/* Disk child pointer: The pointer from an internal node of the tree
1161 to a node that is on disk. */ 1126 to a node that is on disk. */
1162struct disk_child { 1127struct disk_child {
1163 __u32 dc_block_number; /* Disk child's block number. */ 1128 __le32 dc_block_number; /* Disk child's block number. */
1164 __u16 dc_size; /* Disk child's used space. */ 1129 __le16 dc_size; /* Disk child's used space. */
1165 __u16 dc_reserved; 1130 __le16 dc_reserved;
1166}; 1131};
1167 1132
1168#define DC_SIZE (sizeof(struct disk_child)) 1133#define DC_SIZE (sizeof(struct disk_child))
@@ -1476,7 +1441,7 @@ struct tree_balance
1476 int fs_gen; /* saved value of `reiserfs_generation' counter 1441 int fs_gen; /* saved value of `reiserfs_generation' counter
1477 see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */ 1442 see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */
1478#ifdef DISPLACE_NEW_PACKING_LOCALITIES 1443#ifdef DISPLACE_NEW_PACKING_LOCALITIES
1479 struct reiserfs_key key; /* key pointer, to pass to block allocator or 1444 struct in_core_key key; /* key pointer, to pass to block allocator or
1480 another low-level subsystem */ 1445 another low-level subsystem */
1481#endif 1446#endif
1482} ; 1447} ;
@@ -1630,10 +1595,10 @@ struct reiserfs_iget_args {
1630 1595
1631/* first block written in a commit. */ 1596/* first block written in a commit. */
1632struct reiserfs_journal_desc { 1597struct reiserfs_journal_desc {
1633 __u32 j_trans_id ; /* id of commit */ 1598 __le32 j_trans_id ; /* id of commit */
1634 __u32 j_len ; /* length of commit. len +1 is the commit block */ 1599 __le32 j_len ; /* length of commit. len +1 is the commit block */
1635 __u32 j_mount_id ; /* mount id of this trans*/ 1600 __le32 j_mount_id ; /* mount id of this trans*/
1636 __u32 j_realblock[1] ; /* real locations for each block */ 1601 __le32 j_realblock[1] ; /* real locations for each block */
1637} ; 1602} ;
1638 1603
1639#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id) 1604#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id)
@@ -1646,9 +1611,9 @@ struct reiserfs_journal_desc {
1646 1611
1647/* last block written in a commit */ 1612/* last block written in a commit */
1648struct reiserfs_journal_commit { 1613struct reiserfs_journal_commit {
1649 __u32 j_trans_id ; /* must match j_trans_id from the desc block */ 1614 __le32 j_trans_id ; /* must match j_trans_id from the desc block */
1650 __u32 j_len ; /* ditto */ 1615 __le32 j_len ; /* ditto */
1651 __u32 j_realblock[1] ; /* real locations for each block */ 1616 __le32 j_realblock[1] ; /* real locations for each block */
1652} ; 1617} ;
1653 1618
1654#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id) 1619#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id)
@@ -1663,9 +1628,9 @@ struct reiserfs_journal_commit {
1663** and this transaction does not need to be replayed. 1628** and this transaction does not need to be replayed.
1664*/ 1629*/
1665struct reiserfs_journal_header { 1630struct reiserfs_journal_header {
1666 __u32 j_last_flush_trans_id ; /* id of last fully flushed transaction */ 1631 __le32 j_last_flush_trans_id ; /* id of last fully flushed transaction */
1667 __u32 j_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */ 1632 __le32 j_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */
1668 __u32 j_mount_id ; 1633 __le32 j_mount_id ;
1669 /* 12 */ struct journal_params jh_journal; 1634 /* 12 */ struct journal_params jh_journal;
1670} ; 1635} ;
1671 1636
@@ -2117,7 +2082,7 @@ struct buffer_head * get_FEB (struct tree_balance *);
2117 struct __reiserfs_blocknr_hint { 2082 struct __reiserfs_blocknr_hint {
2118 struct inode * inode; /* inode passed to allocator, if we allocate unf. nodes */ 2083 struct inode * inode; /* inode passed to allocator, if we allocate unf. nodes */
2119 long block; /* file offset, in blocks */ 2084 long block; /* file offset, in blocks */
2120 struct reiserfs_key key; 2085 struct in_core_key key;
2121 struct path * path; /* search path, used by allocator to deternine search_start by 2086 struct path * path; /* search path, used by allocator to deternine search_start by
2122 * various ways */ 2087 * various ways */
2123 struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and 2088 struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and
@@ -2144,7 +2109,7 @@ void reiserfs_init_alloc_options (struct super_block *s);
2144 * to use for a new object underneat it. The locality is returned 2109 * to use for a new object underneat it. The locality is returned
2145 * in disk byte order (le). 2110 * in disk byte order (le).
2146 */ 2111 */
2147u32 reiserfs_choose_packing(struct inode *dir); 2112__le32 reiserfs_choose_packing(struct inode *dir);
2148 2113
2149int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value); 2114int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value);
2150void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted); 2115void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted);
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index 1eaa48eca811..9244c5748820 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -10,8 +10,8 @@
10#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */ 10#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
11 11
12struct reiserfs_xattr_header { 12struct reiserfs_xattr_header {
13 __u32 h_magic; /* magic number for identification */ 13 __le32 h_magic; /* magic number for identification */
14 __u32 h_hash; /* hash of the value */ 14 __le32 h_hash; /* hash of the value */
15}; 15};
16 16
17#ifdef __KERNEL__ 17#ifdef __KERNEL__
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 32e52769a00b..91ac97c20777 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -89,10 +89,14 @@ enum {
89 RTM_GETANYCAST = 62, 89 RTM_GETANYCAST = 62,
90#define RTM_GETANYCAST RTM_GETANYCAST 90#define RTM_GETANYCAST RTM_GETANYCAST
91 91
92 RTM_MAX, 92 __RTM_MAX,
93#define RTM_MAX RTM_MAX 93#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
94}; 94};
95 95
96#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
97#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
98#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
99
96/* 100/*
97 Generic structure for encapsulation of optional route information. 101 Generic structure for encapsulation of optional route information.
98 It is reminiscent of sockaddr, but with sa_family replaced 102 It is reminiscent of sockaddr, but with sa_family replaced
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1cced971232c..4dbb109022f3 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -578,7 +578,7 @@ struct task_struct {
578 unsigned long flags; /* per process flags, defined below */ 578 unsigned long flags; /* per process flags, defined below */
579 unsigned long ptrace; 579 unsigned long ptrace;
580 580
581 int lock_depth; /* Lock depth */ 581 int lock_depth; /* BKL lock depth */
582 582
583 int prio, static_prio; 583 int prio, static_prio;
584 struct list_head run_list; 584 struct list_head run_list;
@@ -661,7 +661,10 @@ struct task_struct {
661 struct key *thread_keyring; /* keyring private to this thread */ 661 struct key *thread_keyring; /* keyring private to this thread */
662#endif 662#endif
663 int oomkilladj; /* OOM kill score adjustment (bit shift). */ 663 int oomkilladj; /* OOM kill score adjustment (bit shift). */
664 char comm[TASK_COMM_LEN]; 664 char comm[TASK_COMM_LEN]; /* executable name excluding path
665 - access with [gs]et_task_comm (which lock
666 it with task_lock())
667 - initialized normally by flush_old_exec */
665/* file system info */ 668/* file system info */
666 int link_count, total_link_count; 669 int link_count, total_link_count;
667/* ipc stuff */ 670/* ipc stuff */
@@ -845,6 +848,7 @@ extern void sched_idle_next(void);
845extern void set_user_nice(task_t *p, long nice); 848extern void set_user_nice(task_t *p, long nice);
846extern int task_prio(const task_t *p); 849extern int task_prio(const task_t *p);
847extern int task_nice(const task_t *p); 850extern int task_nice(const task_t *p);
851extern int can_nice(const task_t *p, const int nice);
848extern int task_curr(const task_t *p); 852extern int task_curr(const task_t *p);
849extern int idle_cpu(int cpu); 853extern int idle_cpu(int cpu);
850extern int sched_setscheduler(struct task_struct *, int, struct sched_param *); 854extern int sched_setscheduler(struct task_struct *, int, struct sched_param *);
@@ -1011,7 +1015,6 @@ extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct
1011extern void flush_thread(void); 1015extern void flush_thread(void);
1012extern void exit_thread(void); 1016extern void exit_thread(void);
1013 1017
1014extern void exit_mm(struct task_struct *);
1015extern void exit_files(struct task_struct *); 1018extern void exit_files(struct task_struct *);
1016extern void exit_signal(struct task_struct *); 1019extern void exit_signal(struct task_struct *);
1017extern void __exit_signal(struct task_struct *); 1020extern void __exit_signal(struct task_struct *);
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 99c97ad026c8..0a98f5ec5cae 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -9,6 +9,17 @@
9#ifdef __KERNEL__ 9#ifdef __KERNEL__
10 10
11/* 11/*
12 * These values of sa_flags are used only by the kernel as part of the
13 * irq handling routines.
14 *
15 * SA_INTERRUPT is also used by the irq handling routines.
16 * SA_SHIRQ is for shared interrupt support on PCI and EISA.
17 */
18#define SA_PROBE SA_ONESHOT
19#define SA_SAMPLE_RANDOM SA_RESTART
20#define SA_SHIRQ 0x04000000
21
22/*
12 * Real Time signals may be queued. 23 * Real Time signals may be queued.
13 */ 24 */
14 25
@@ -209,6 +220,12 @@ static inline void init_sigpending(struct sigpending *sig)
209 INIT_LIST_HEAD(&sig->list); 220 INIT_LIST_HEAD(&sig->list);
210} 221}
211 222
223/* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
224static inline int valid_signal(unsigned long sig)
225{
226 return sig <= _NSIG ? 1 : 0;
227}
228
212extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p); 229extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
213extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); 230extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
214extern long do_sigpending(void __user *, unsigned long); 231extern long do_sigpending(void __user *, unsigned long);
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 22b701819619..cc04f5cd2286 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -167,13 +167,14 @@ struct skb_shared_info {
167 * @h: Transport layer header 167 * @h: Transport layer header
168 * @nh: Network layer header 168 * @nh: Network layer header
169 * @mac: Link layer header 169 * @mac: Link layer header
170 * @dst: FIXME: Describe this field 170 * @dst: destination entry
171 * @sp: the security path, used for xfrm
171 * @cb: Control buffer. Free for use by every layer. Put private vars here 172 * @cb: Control buffer. Free for use by every layer. Put private vars here
172 * @len: Length of actual data 173 * @len: Length of actual data
173 * @data_len: Data length 174 * @data_len: Data length
174 * @mac_len: Length of link layer header 175 * @mac_len: Length of link layer header
175 * @csum: Checksum 176 * @csum: Checksum
176 * @__unused: Dead field, may be reused 177 * @local_df: allow local fragmentation
177 * @cloned: Head may be cloned (check refcnt to be sure) 178 * @cloned: Head may be cloned (check refcnt to be sure)
178 * @nohdr: Payload reference only, must not modify header 179 * @nohdr: Payload reference only, must not modify header
179 * @pkt_type: Packet class 180 * @pkt_type: Packet class
@@ -968,6 +969,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
968 kfree_skb(skb); 969 kfree_skb(skb);
969} 970}
970 971
972#ifndef CONFIG_HAVE_ARCH_DEV_ALLOC_SKB
971/** 973/**
972 * __dev_alloc_skb - allocate an skbuff for sending 974 * __dev_alloc_skb - allocate an skbuff for sending
973 * @length: length to allocate 975 * @length: length to allocate
@@ -980,7 +982,6 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
980 * 982 *
981 * %NULL is returned in there is no free memory. 983 * %NULL is returned in there is no free memory.
982 */ 984 */
983#ifndef CONFIG_HAVE_ARCH_DEV_ALLOC_SKB
984static inline struct sk_buff *__dev_alloc_skb(unsigned int length, 985static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
985 int gfp_mask) 986 int gfp_mask)
986{ 987{
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 3e3c3ab8ff94..7d66385ae750 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -62,16 +62,9 @@ extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned lo
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 *, unsigned int __nocast);
65#ifdef CONFIG_NUMA
66extern void *kmem_cache_alloc_node(kmem_cache_t *, int);
67#else
68static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int node)
69{
70 return kmem_cache_alloc(cachep, GFP_KERNEL);
71}
72#endif
73extern void kmem_cache_free(kmem_cache_t *, void *); 65extern void kmem_cache_free(kmem_cache_t *, void *);
74extern unsigned int kmem_cache_size(kmem_cache_t *); 66extern unsigned int kmem_cache_size(kmem_cache_t *);
67extern kmem_cache_t *kmem_find_general_cachep(size_t size, int gfpflags);
75 68
76/* Size description struct for general caches. */ 69/* Size description struct for general caches. */
77struct cache_sizes { 70struct cache_sizes {
@@ -109,6 +102,20 @@ extern void *kcalloc(size_t, size_t, unsigned int __nocast);
109extern void kfree(const void *); 102extern void kfree(const void *);
110extern unsigned int ksize(const void *); 103extern unsigned int ksize(const void *);
111 104
105#ifdef CONFIG_NUMA
106extern void *kmem_cache_alloc_node(kmem_cache_t *, int flags, int node);
107extern void *kmalloc_node(size_t size, int flags, int node);
108#else
109static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node)
110{
111 return kmem_cache_alloc(cachep, flags);
112}
113static inline void *kmalloc_node(size_t size, int flags, int node)
114{
115 return kmalloc(size, flags);
116}
117#endif
118
112extern int FASTCALL(kmem_cache_reap(int)); 119extern int FASTCALL(kmem_cache_reap(int));
113extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr)); 120extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr));
114 121
diff --git a/include/linux/sockios.h b/include/linux/sockios.h
index 5eb33205cc04..e6b9d1d36ea2 100644
--- a/include/linux/sockios.h
+++ b/include/linux/sockios.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)sockios.h 1.0.2 03/09/93 8 * Version: @(#)sockios.h 1.0.2 03/09/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
diff --git a/include/linux/soundcard.h b/include/linux/soundcard.h
index 28d2d1881978..523d069c862c 100644
--- a/include/linux/soundcard.h
+++ b/include/linux/soundcard.h
@@ -39,6 +39,13 @@
39/* In Linux we need to be prepared for cross compiling */ 39/* In Linux we need to be prepared for cross compiling */
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41 41
42/* Endian macros. */
43#ifdef __KERNEL__
44# include <asm/byteorder.h>
45#else
46# include <endian.h>
47#endif
48
42/* 49/*
43 * Supported card ID numbers (Should be somewhere else?) 50 * Supported card ID numbers (Should be somewhere else?)
44 */ 51 */
@@ -179,13 +186,26 @@ typedef struct seq_event_rec {
179 * Some big endian/little endian handling macros 186 * Some big endian/little endian handling macros
180 */ 187 */
181 188
182#if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__sparc__) || defined(HPPA) || defined(PPC) || defined(__mc68000__) 189#define _LINUX_PATCHKEY_H_INDIRECT
183/* Big endian machines */ 190#include <linux/patchkey.h>
184# define _PATCHKEY(id) (0xfd00|id) 191#undef _LINUX_PATCHKEY_H_INDIRECT
185# define AFMT_S16_NE AFMT_S16_BE 192
186#else 193#if defined(__KERNEL__)
187# define _PATCHKEY(id) ((id<<8)|0xfd) 194# if defined(__BIG_ENDIAN)
188# define AFMT_S16_NE AFMT_S16_LE 195# define AFMT_S16_NE AFMT_S16_BE
196# elif defined(__LITTLE_ENDIAN)
197# define AFMT_S16_NE AFMT_S16_LE
198# else
199# error "could not determine byte order"
200# endif
201#elif defined(__BYTE_ORDER)
202# if __BYTE_ORDER == __BIG_ENDIAN
203# define AFMT_S16_NE AFMT_S16_BE
204# elif __BYTE_ORDER == __LITTLE_ENDIAN
205# define AFMT_S16_NE AFMT_S16_LE
206# else
207# error "could not determine byte order"
208# endif
189#endif 209#endif
190 210
191/* 211/*
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 757cd9be7743..c39f6f72cbbc 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -456,8 +456,7 @@ asmlinkage long sys_semctl(int semid, int semnum, int cmd, union semun arg);
456asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops, 456asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
457 unsigned nsops, 457 unsigned nsops,
458 const struct timespec __user *timeout); 458 const struct timespec __user *timeout);
459asmlinkage long sys_shmat(int shmid, char __user *shmaddr, 459asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
460 int shmflg, unsigned long __user *addr);
461asmlinkage long sys_shmget(key_t key, size_t size, int flag); 460asmlinkage long sys_shmget(key_t key, size_t size, int flag);
462asmlinkage long sys_shmdt(char __user *shmaddr); 461asmlinkage long sys_shmdt(char __user *shmaddr);
463asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf); 462asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 358d52b0c445..772998147e3e 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -643,6 +643,7 @@ enum {
643 NET_SCTP_MAX_BURST = 12, 643 NET_SCTP_MAX_BURST = 12,
644 NET_SCTP_ADDIP_ENABLE = 13, 644 NET_SCTP_ADDIP_ENABLE = 13,
645 NET_SCTP_PRSCTP_ENABLE = 14, 645 NET_SCTP_PRSCTP_ENABLE = 14,
646 NET_SCTP_SNDBUF_POLICY = 15,
646}; 647};
647 648
648/* /proc/sys/net/bridge */ 649/* /proc/sys/net/bridge */
diff --git a/include/linux/tc_act/tc_defact.h b/include/linux/tc_act/tc_defact.h
new file mode 100644
index 000000000000..964f473af0f0
--- /dev/null
+++ b/include/linux/tc_act/tc_defact.h
@@ -0,0 +1,21 @@
1#ifndef __LINUX_TC_DEF_H
2#define __LINUX_TC_DEF_H
3
4#include <linux/pkt_cls.h>
5
6struct tc_defact
7{
8 tc_gen;
9};
10
11enum
12{
13 TCA_DEF_UNSPEC,
14 TCA_DEF_TM,
15 TCA_DEF_PARMS,
16 TCA_DEF_DATA,
17 __TCA_DEF_MAX
18};
19#define TCA_DEF_MAX (__TCA_DEF_MAX - 1)
20
21#endif
diff --git a/include/linux/trdevice.h b/include/linux/trdevice.h
index aaa1f337edcb..99e02ef54c47 100644
--- a/include/linux/trdevice.h
+++ b/include/linux/trdevice.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)eth.h 1.0.4 05/13/93 8 * Version: @(#)eth.h 1.0.4 05/13/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * Relocated to include/linux where it belongs by Alan Cox 13 * Relocated to include/linux where it belongs by Alan Cox
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index f0df02ae68a4..fd2ef742a9fd 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -140,8 +140,11 @@ enum {
140 XFRM_MSG_FLUSHPOLICY, 140 XFRM_MSG_FLUSHPOLICY,
141#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY 141#define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
142 142
143 XFRM_MSG_MAX 143 __XFRM_MSG_MAX
144}; 144};
145#define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
146
147#define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
145 148
146struct xfrm_user_tmpl { 149struct xfrm_user_tmpl {
147 struct xfrm_id id; 150 struct xfrm_id id;
diff --git a/include/net/act_generic.h b/include/net/act_generic.h
new file mode 100644
index 000000000000..95b120781c14
--- /dev/null
+++ b/include/net/act_generic.h
@@ -0,0 +1,142 @@
1/*
2 * include/net/act_generic.h
3 *
4*/
5#ifndef ACT_GENERIC_H
6#define ACT_GENERIC_H
7static inline int tcf_defact_release(struct tcf_defact *p, int bind)
8{
9 int ret = 0;
10 if (p) {
11 if (bind) {
12 p->bindcnt--;
13 }
14 p->refcnt--;
15 if (p->bindcnt <= 0 && p->refcnt <= 0) {
16 kfree(p->defdata);
17 tcf_hash_destroy(p);
18 ret = 1;
19 }
20 }
21 return ret;
22}
23
24static inline int
25alloc_defdata(struct tcf_defact *p, u32 datalen, void *defdata)
26{
27 p->defdata = kmalloc(datalen, GFP_KERNEL);
28 if (p->defdata == NULL)
29 return -ENOMEM;
30 p->datalen = datalen;
31 memcpy(p->defdata, defdata, datalen);
32 return 0;
33}
34
35static inline int
36realloc_defdata(struct tcf_defact *p, u32 datalen, void *defdata)
37{
38 /* safer to be just brute force for now */
39 kfree(p->defdata);
40 return alloc_defdata(p, datalen, defdata);
41}
42
43static inline int
44tcf_defact_init(struct rtattr *rta, struct rtattr *est,
45 struct tc_action *a, int ovr, int bind)
46{
47 struct rtattr *tb[TCA_DEF_MAX];
48 struct tc_defact *parm;
49 struct tcf_defact *p;
50 void *defdata;
51 u32 datalen = 0;
52 int ret = 0;
53
54 if (rta == NULL || rtattr_parse_nested(tb, TCA_DEF_MAX, rta) < 0)
55 return -EINVAL;
56
57 if (tb[TCA_DEF_PARMS - 1] == NULL ||
58 RTA_PAYLOAD(tb[TCA_DEF_PARMS - 1]) < sizeof(*parm))
59 return -EINVAL;
60
61 parm = RTA_DATA(tb[TCA_DEF_PARMS - 1]);
62 defdata = RTA_DATA(tb[TCA_DEF_DATA - 1]);
63 if (defdata == NULL)
64 return -EINVAL;
65
66 datalen = RTA_PAYLOAD(tb[TCA_DEF_DATA - 1]);
67 if (datalen <= 0)
68 return -EINVAL;
69
70 p = tcf_hash_check(parm->index, a, ovr, bind);
71 if (p == NULL) {
72 p = tcf_hash_create(parm->index, est, a, sizeof(*p), ovr, bind);
73 if (p == NULL)
74 return -ENOMEM;
75
76 ret = alloc_defdata(p, datalen, defdata);
77 if (ret < 0) {
78 kfree(p);
79 return ret;
80 }
81 ret = ACT_P_CREATED;
82 } else {
83 if (!ovr) {
84 tcf_defact_release(p, bind);
85 return -EEXIST;
86 }
87 realloc_defdata(p, datalen, defdata);
88 }
89
90 spin_lock_bh(&p->lock);
91 p->action = parm->action;
92 spin_unlock_bh(&p->lock);
93 if (ret == ACT_P_CREATED)
94 tcf_hash_insert(p);
95 return ret;
96}
97
98static inline int tcf_defact_cleanup(struct tc_action *a, int bind)
99{
100 struct tcf_defact *p = PRIV(a, defact);
101
102 if (p != NULL)
103 return tcf_defact_release(p, bind);
104 return 0;
105}
106
107static inline int
108tcf_defact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
109{
110 unsigned char *b = skb->tail;
111 struct tc_defact opt;
112 struct tcf_defact *p = PRIV(a, defact);
113 struct tcf_t t;
114
115 opt.index = p->index;
116 opt.refcnt = p->refcnt - ref;
117 opt.bindcnt = p->bindcnt - bind;
118 opt.action = p->action;
119 RTA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt);
120 RTA_PUT(skb, TCA_DEF_DATA, p->datalen, p->defdata);
121 t.install = jiffies_to_clock_t(jiffies - p->tm.install);
122 t.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
123 t.expires = jiffies_to_clock_t(p->tm.expires);
124 RTA_PUT(skb, TCA_DEF_TM, sizeof(t), &t);
125 return skb->len;
126
127rtattr_failure:
128 skb_trim(skb, b - skb->data);
129 return -1;
130}
131
132#define tca_use_default_ops \
133 .dump = tcf_defact_dump, \
134 .cleanup = tcf_defact_cleanup, \
135 .init = tcf_defact_init, \
136 .walk = tcf_generic_walker, \
137
138#define tca_use_default_defines(name) \
139 static u32 idx_gen; \
140 static struct tcf_defact *tcf_##name_ht[MY_TAB_SIZE]; \
141 static DEFINE_RWLOCK(##name_lock);
142#endif /* _NET_ACT_GENERIC_H */
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 7af9a13cb9be..a0ed93672176 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -17,6 +17,8 @@
17 17
18#define IPV6_MAX_ADDRESSES 16 18#define IPV6_MAX_ADDRESSES 16
19 19
20#include <linux/in6.h>
21
20struct prefix_info { 22struct prefix_info {
21 __u8 type; 23 __u8 type;
22 __u8 length; 24 __u8 length;
@@ -43,9 +45,9 @@ struct prefix_info {
43 45
44#ifdef __KERNEL__ 46#ifdef __KERNEL__
45 47
46#include <linux/in6.h>
47#include <linux/netdevice.h> 48#include <linux/netdevice.h>
48#include <net/if_inet6.h> 49#include <net/if_inet6.h>
50#include <net/ipv6.h>
49 51
50#define IN6_ADDR_HSIZE 16 52#define IN6_ADDR_HSIZE 16
51 53
diff --git a/include/net/ax25.h b/include/net/ax25.h
index fb95ecb6fe03..9e6368a54547 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -220,6 +220,14 @@ static __inline__ void ax25_cb_put(ax25_cb *ax25)
220 } 220 }
221} 221}
222 222
223static inline unsigned short ax25_type_trans(struct sk_buff *skb, struct net_device *dev)
224{
225 skb->dev = dev;
226 skb->pkt_type = PACKET_HOST;
227 skb->mac.raw = skb->data;
228 return htons(ETH_P_AX25);
229}
230
223/* af_ax25.c */ 231/* af_ax25.c */
224extern struct hlist_head ax25_list; 232extern struct hlist_head ax25_list;
225extern spinlock_t ax25_list_lock; 233extern spinlock_t ax25_list_lock;
@@ -305,7 +313,7 @@ extern ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_addr
305extern void ax25_output(ax25_cb *, int, struct sk_buff *); 313extern void ax25_output(ax25_cb *, int, struct sk_buff *);
306extern void ax25_kick(ax25_cb *); 314extern void ax25_kick(ax25_cb *);
307extern void ax25_transmit_buffer(ax25_cb *, struct sk_buff *, int); 315extern void ax25_transmit_buffer(ax25_cb *, struct sk_buff *, int);
308extern void ax25_queue_xmit(struct sk_buff *); 316extern void ax25_queue_xmit(struct sk_buff *skb, struct net_device *dev);
309extern int ax25_check_iframes_acked(ax25_cb *, unsigned short); 317extern int ax25_check_iframes_acked(ax25_cb *, unsigned short);
310 318
311/* ax25_route.c */ 319/* ax25_route.c */
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 3fc192478aa2..e5ef0d15fb45 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)icmp.h 1.0.4 05/13/93 8 * Version: @(#)icmp.h 1.0.4 05/13/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
diff --git a/include/net/ip.h b/include/net/ip.h
index b4db1375da2c..3f63992eb712 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)ip.h 1.0.2 05/07/93 8 * Version: @(#)ip.h 1.0.2 05/07/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Alan Cox, <gw4pts@gw4pts.ampr.org> 12 * Alan Cox, <gw4pts@gw4pts.ampr.org>
13 * 13 *
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 87c45cbfbaf6..771b47e30f86 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -416,7 +416,7 @@ extern void ipv6_push_frag_opts(struct sk_buff *skb,
416 u8 *proto); 416 u8 *proto);
417 417
418extern int ipv6_skip_exthdr(const struct sk_buff *, int start, 418extern int ipv6_skip_exthdr(const struct sk_buff *, int start,
419 u8 *nexthdrp, int len); 419 u8 *nexthdrp);
420 420
421extern int ipv6_ext_hdr(u8 nexthdr); 421extern int ipv6_ext_hdr(u8 nexthdr);
422 422
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 87496e3aa330..fcb05a387dbe 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -140,7 +140,7 @@ psched_tod_diff(int delta_sec, int bound)
140 if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1) 140 if (bound <= 1000000 || delta_sec > (0x7FFFFFFF/1000000)-1)
141 return bound; 141 return bound;
142 delta = delta_sec * 1000000; 142 delta = delta_sec * 1000000;
143 if (delta > bound) 143 if (delta > bound || delta < 0)
144 delta = bound; 144 delta = bound;
145 return delta; 145 return delta;
146} 146}
@@ -156,7 +156,9 @@ psched_tod_diff(int delta_sec, int bound)
156 __delta += 1000000; \ 156 __delta += 1000000; \
157 case 1: \ 157 case 1: \
158 __delta += 1000000; \ 158 __delta += 1000000; \
159 case 0: ; \ 159 case 0: \
160 if (__delta > bound || __delta < 0) \
161 __delta = bound; \
160 } \ 162 } \
161 __delta; \ 163 __delta; \
162}) 164})
diff --git a/include/net/route.h b/include/net/route.h
index 22da7579d5de..efe92b239ef1 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)route.h 1.0.4 05/27/93 8 * Version: @(#)route.h 1.0.4 05/27/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Fixes: 12 * Fixes:
13 * Alan Cox : Reformatted. Added ip_rt_local() 13 * Alan Cox : Reformatted. Added ip_rt_local()
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 5576db56324d..f4fcee104707 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -407,32 +407,38 @@ sctp_vtag_verify(const struct sctp_chunk *chunk,
407 return 0; 407 return 0;
408} 408}
409 409
410/* Check VTAG of the packet matches the sender's own tag OR its peer's 410/* Check VTAG of the packet matches the sender's own tag and the T bit is
411 * tag and the T bit is set in the Chunk Flags. 411 * not set, OR its peer's tag and the T bit is set in the Chunk Flags.
412 */ 412 */
413static inline int 413static inline int
414sctp_vtag_verify_either(const struct sctp_chunk *chunk, 414sctp_vtag_verify_either(const struct sctp_chunk *chunk,
415 const struct sctp_association *asoc) 415 const struct sctp_association *asoc)
416{ 416{
417 /* RFC 2960 Section 8.5.1, sctpimpguide-06 Section 2.13.2 417 /* RFC 2960 Section 8.5.1, sctpimpguide Section 2.41
418 * 418 *
419 * B) The receiver of a ABORT shall accept the packet if the 419 * B) The receiver of a ABORT MUST accept the packet
420 * Verification Tag field of the packet matches its own tag OR it 420 * if the Verification Tag field of the packet matches its own tag
421 * is set to its peer's tag and the T bit is set in the Chunk 421 * and the T bit is not set
422 * Flags. Otherwise, the receiver MUST silently discard the packet 422 * OR
423 * and take no further action. 423 * it is set to its peer's tag and the T bit is set in the Chunk
424 * 424 * Flags.
425 * (C) The receiver of a SHUTDOWN COMPLETE shall accept the 425 * Otherwise, the receiver MUST silently discard the packet
426 * packet if the Verification Tag field of the packet 426 * and take no further action.
427 * matches its own tag OR it is set to its peer's tag and
428 * the T bit is set in the Chunk Flags. Otherwise, the
429 * receiver MUST silently discard the packet and take no
430 * further action....
431 * 427 *
428 * C) The receiver of a SHUTDOWN COMPLETE shall accept the packet
429 * if the Verification Tag field of the packet matches its own tag
430 * and the T bit is not set
431 * OR
432 * it is set to its peer's tag and the T bit is set in the Chunk
433 * Flags.
434 * Otherwise, the receiver MUST silently discard the packet
435 * and take no further action. An endpoint MUST ignore the
436 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
432 */ 437 */
433 if ((ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag) || 438 if ((!sctp_test_T_bit(chunk) &&
434 (sctp_test_T_bit(chunk) && (ntohl(chunk->sctp_hdr->vtag) 439 (ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag)) ||
435 == asoc->c.peer_vtag))) { 440 (sctp_test_T_bit(chunk) &&
441 (ntohl(chunk->sctp_hdr->vtag) == asoc->c.peer_vtag))) {
436 return 1; 442 return 1;
437 } 443 }
438 444
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 7e64cf6bda1e..6c24d9cd3d66 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -154,6 +154,13 @@ extern struct sctp_globals {
154 int max_retrans_path; 154 int max_retrans_path;
155 int max_retrans_init; 155 int max_retrans_init;
156 156
157 /*
158 * Policy for preforming sctp/socket accounting
159 * 0 - do socket level accounting, all assocs share sk_sndbuf
160 * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
161 */
162 int sndbuf_policy;
163
157 /* HB.interval - 30 seconds */ 164 /* HB.interval - 30 seconds */
158 int hb_interval; 165 int hb_interval;
159 166
@@ -207,6 +214,7 @@ extern struct sctp_globals {
207#define sctp_valid_cookie_life (sctp_globals.valid_cookie_life) 214#define sctp_valid_cookie_life (sctp_globals.valid_cookie_life)
208#define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable) 215#define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable)
209#define sctp_max_retrans_association (sctp_globals.max_retrans_association) 216#define sctp_max_retrans_association (sctp_globals.max_retrans_association)
217#define sctp_sndbuf_policy (sctp_globals.sndbuf_policy)
210#define sctp_max_retrans_path (sctp_globals.max_retrans_path) 218#define sctp_max_retrans_path (sctp_globals.max_retrans_path)
211#define sctp_max_retrans_init (sctp_globals.max_retrans_init) 219#define sctp_max_retrans_init (sctp_globals.max_retrans_init)
212#define sctp_hb_interval (sctp_globals.hb_interval) 220#define sctp_hb_interval (sctp_globals.hb_interval)
@@ -1212,7 +1220,8 @@ struct sctp_endpoint {
1212 /* Default timeouts. */ 1220 /* Default timeouts. */
1213 int timeouts[SCTP_NUM_TIMEOUT_TYPES]; 1221 int timeouts[SCTP_NUM_TIMEOUT_TYPES];
1214 1222
1215 /* Various thresholds. */ 1223 /* sendbuf acct. policy. */
1224 __u32 sndbuf_policy;
1216 1225
1217 /* Name for debugging output... */ 1226 /* Name for debugging output... */
1218 char *debug_name; 1227 char *debug_name;
diff --git a/include/net/sock.h b/include/net/sock.h
index be81cabd0da3..a9ef3a6a13f3 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)sock.h 1.0.4 05/13/93 8 * Version: @(#)sock.h 1.0.4 05/13/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Corey Minyard <wf-rch!minyard@relay.EU.net> 12 * Corey Minyard <wf-rch!minyard@relay.EU.net>
13 * Florian La Roche <flla@stud.uni-sb.de> 13 * Florian La Roche <flla@stud.uni-sb.de>
@@ -90,17 +90,17 @@ do { spin_lock_init(&((__sk)->sk_lock.slock)); \
90struct sock; 90struct sock;
91 91
92/** 92/**
93 * struct sock_common - minimal network layer representation of sockets 93 * struct sock_common - minimal network layer representation of sockets
94 * @skc_family - network address family 94 * @skc_family: network address family
95 * @skc_state - Connection state 95 * @skc_state: Connection state
96 * @skc_reuse - %SO_REUSEADDR setting 96 * @skc_reuse: %SO_REUSEADDR setting
97 * @skc_bound_dev_if - bound device index if != 0 97 * @skc_bound_dev_if: bound device index if != 0
98 * @skc_node - main hash linkage for various protocol lookup tables 98 * @skc_node: main hash linkage for various protocol lookup tables
99 * @skc_bind_node - bind hash linkage for various protocol lookup tables 99 * @skc_bind_node: bind hash linkage for various protocol lookup tables
100 * @skc_refcnt - reference count 100 * @skc_refcnt: reference count
101 * 101 *
102 * This is the minimal network layer representation of sockets, the header 102 * This is the minimal network layer representation of sockets, the header
103 * for struct sock and struct tcp_tw_bucket. 103 * for struct sock and struct tcp_tw_bucket.
104 */ 104 */
105struct sock_common { 105struct sock_common {
106 unsigned short skc_family; 106 unsigned short skc_family;
@@ -114,60 +114,62 @@ struct sock_common {
114 114
115/** 115/**
116 * struct sock - network layer representation of sockets 116 * struct sock - network layer representation of sockets
117 * @__sk_common - shared layout with tcp_tw_bucket 117 * @__sk_common: shared layout with tcp_tw_bucket
118 * @sk_shutdown - mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN 118 * @sk_shutdown: mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN
119 * @sk_userlocks - %SO_SNDBUF and %SO_RCVBUF settings 119 * @sk_userlocks: %SO_SNDBUF and %SO_RCVBUF settings
120 * @sk_lock - synchronizer 120 * @sk_lock: synchronizer
121 * @sk_rcvbuf - size of receive buffer in bytes 121 * @sk_rcvbuf: size of receive buffer in bytes
122 * @sk_sleep - sock wait queue 122 * @sk_sleep: sock wait queue
123 * @sk_dst_cache - destination cache 123 * @sk_dst_cache: destination cache
124 * @sk_dst_lock - destination cache lock 124 * @sk_dst_lock: destination cache lock
125 * @sk_policy - flow policy 125 * @sk_policy: flow policy
126 * @sk_rmem_alloc - receive queue bytes committed 126 * @sk_rmem_alloc: receive queue bytes committed
127 * @sk_receive_queue - incoming packets 127 * @sk_receive_queue: incoming packets
128 * @sk_wmem_alloc - transmit queue bytes committed 128 * @sk_wmem_alloc: transmit queue bytes committed
129 * @sk_write_queue - Packet sending queue 129 * @sk_write_queue: Packet sending queue
130 * @sk_omem_alloc - "o" is "option" or "other" 130 * @sk_omem_alloc: "o" is "option" or "other"
131 * @sk_wmem_queued - persistent queue size 131 * @sk_wmem_queued: persistent queue size
132 * @sk_forward_alloc - space allocated forward 132 * @sk_forward_alloc: space allocated forward
133 * @sk_allocation - allocation mode 133 * @sk_allocation: allocation mode
134 * @sk_sndbuf - size of send buffer in bytes 134 * @sk_sndbuf: size of send buffer in bytes
135 * @sk_flags - %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings 135 * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings
136 * @sk_no_check - %SO_NO_CHECK setting, wether or not checkup packets 136 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
137 * @sk_route_caps - route capabilities (e.g. %NETIF_F_TSO) 137 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
138 * @sk_lingertime - %SO_LINGER l_linger setting 138 * @sk_lingertime: %SO_LINGER l_linger setting
139 * @sk_hashent - hash entry in several tables (e.g. tcp_ehash) 139 * @sk_hashent: hash entry in several tables (e.g. tcp_ehash)
140 * @sk_backlog - always used with the per-socket spinlock held 140 * @sk_backlog: always used with the per-socket spinlock held
141 * @sk_callback_lock - used with the callbacks in the end of this struct 141 * @sk_callback_lock: used with the callbacks in the end of this struct
142 * @sk_error_queue - rarely used 142 * @sk_error_queue: rarely used
143 * @sk_prot - protocol handlers inside a network family 143 * @sk_prot: protocol handlers inside a network family
144 * @sk_err - last error 144 * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
145 * @sk_err_soft - errors that don't cause failure but are the cause of a persistent failure not just 'timed out' 145 * @sk_err: last error
146 * @sk_ack_backlog - current listen backlog 146 * @sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
147 * @sk_max_ack_backlog - listen backlog set in listen() 147 * @sk_ack_backlog: current listen backlog
148 * @sk_priority - %SO_PRIORITY setting 148 * @sk_max_ack_backlog: listen backlog set in listen()
149 * @sk_type - socket type (%SOCK_STREAM, etc) 149 * @sk_priority: %SO_PRIORITY setting
150 * @sk_protocol - which protocol this socket belongs in this network family 150 * @sk_type: socket type (%SOCK_STREAM, etc)
151 * @sk_peercred - %SO_PEERCRED setting 151 * @sk_protocol: which protocol this socket belongs in this network family
152 * @sk_rcvlowat - %SO_RCVLOWAT setting 152 * @sk_peercred: %SO_PEERCRED setting
153 * @sk_rcvtimeo - %SO_RCVTIMEO setting 153 * @sk_rcvlowat: %SO_RCVLOWAT setting
154 * @sk_sndtimeo - %SO_SNDTIMEO setting 154 * @sk_rcvtimeo: %SO_RCVTIMEO setting
155 * @sk_filter - socket filtering instructions 155 * @sk_sndtimeo: %SO_SNDTIMEO setting
156 * @sk_protinfo - private area, net family specific, when not using slab 156 * @sk_filter: socket filtering instructions
157 * @sk_timer - sock cleanup timer 157 * @sk_protinfo: private area, net family specific, when not using slab
158 * @sk_stamp - time stamp of last packet received 158 * @sk_timer: sock cleanup timer
159 * @sk_socket - Identd and reporting IO signals 159 * @sk_stamp: time stamp of last packet received
160 * @sk_user_data - RPC layer private data 160 * @sk_socket: Identd and reporting IO signals
161 * @sk_sndmsg_page - cached page for sendmsg 161 * @sk_user_data: RPC layer private data
162 * @sk_sndmsg_off - cached offset for sendmsg 162 * @sk_sndmsg_page: cached page for sendmsg
163 * @sk_send_head - front of stuff to transmit 163 * @sk_sndmsg_off: cached offset for sendmsg
164 * @sk_write_pending - a write to stream socket waits to start 164 * @sk_send_head: front of stuff to transmit
165 * @sk_state_change - callback to indicate change in the state of the sock 165 * @sk_security: used by security modules
166 * @sk_data_ready - callback to indicate there is data to be processed 166 * @sk_write_pending: a write to stream socket waits to start
167 * @sk_write_space - callback to indicate there is bf sending space available 167 * @sk_state_change: callback to indicate change in the state of the sock
168 * @sk_error_report - callback to indicate errors (e.g. %MSG_ERRQUEUE) 168 * @sk_data_ready: callback to indicate there is data to be processed
169 * @sk_backlog_rcv - callback to process the backlog 169 * @sk_write_space: callback to indicate there is bf sending space available
170 * @sk_destruct - called at sock freeing time, i.e. when all refcnt == 0 170 * @sk_error_report: callback to indicate errors (e.g. %MSG_ERRQUEUE)
171 * @sk_backlog_rcv: callback to process the backlog
172 * @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0
171 */ 173 */
172struct sock { 174struct sock {
173 /* 175 /*
@@ -217,6 +219,7 @@ struct sock {
217 } sk_backlog; 219 } sk_backlog;
218 struct sk_buff_head sk_error_queue; 220 struct sk_buff_head sk_error_queue;
219 struct proto *sk_prot; 221 struct proto *sk_prot;
222 struct proto *sk_prot_creator;
220 rwlock_t sk_callback_lock; 223 rwlock_t sk_callback_lock;
221 int sk_err, 224 int sk_err,
222 sk_err_soft; 225 sk_err_soft;
@@ -1223,8 +1226,8 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
1223 1226
1224/** 1227/**
1225 * sk_eat_skb - Release a skb if it is no longer needed 1228 * sk_eat_skb - Release a skb if it is no longer needed
1226 * @sk - socket to eat this skb from 1229 * @sk: socket to eat this skb from
1227 * @skb - socket buffer to eat 1230 * @skb: socket buffer to eat
1228 * 1231 *
1229 * This routine must be called with interrupts disabled or with the socket 1232 * This routine must be called with interrupts disabled or with the socket
1230 * locked so that the sk_buff queue operation is ok. 1233 * locked so that the sk_buff queue operation is ok.
diff --git a/include/net/tc_act/tc_defact.h b/include/net/tc_act/tc_defact.h
new file mode 100644
index 000000000000..463aa671f95d
--- /dev/null
+++ b/include/net/tc_act/tc_defact.h
@@ -0,0 +1,13 @@
1#ifndef __NET_TC_DEF_H
2#define __NET_TC_DEF_H
3
4#include <net/act_api.h>
5
6struct tcf_defact
7{
8 tca_gen(defact);
9 u32 datalen;
10 void *defdata;
11};
12
13#endif
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 503810a70e21..e71f8ba3e101 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)tcp.h 1.0.5 05/23/93 8 * Version: @(#)tcp.h 1.0.5 05/23/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
@@ -1417,19 +1417,20 @@ tcp_nagle_check(const struct tcp_sock *tp, const struct sk_buff *skb,
1417 tcp_minshall_check(tp)))); 1417 tcp_minshall_check(tp))));
1418} 1418}
1419 1419
1420extern void tcp_set_skb_tso_segs(struct sk_buff *, unsigned int); 1420extern void tcp_set_skb_tso_segs(struct sock *, struct sk_buff *);
1421 1421
1422/* This checks if the data bearing packet SKB (usually sk->sk_send_head) 1422/* This checks if the data bearing packet SKB (usually sk->sk_send_head)
1423 * should be put on the wire right now. 1423 * should be put on the wire right now.
1424 */ 1424 */
1425static __inline__ int tcp_snd_test(const struct tcp_sock *tp, 1425static __inline__ int tcp_snd_test(struct sock *sk,
1426 struct sk_buff *skb, 1426 struct sk_buff *skb,
1427 unsigned cur_mss, int nonagle) 1427 unsigned cur_mss, int nonagle)
1428{ 1428{
1429 struct tcp_sock *tp = tcp_sk(sk);
1429 int pkts = tcp_skb_pcount(skb); 1430 int pkts = tcp_skb_pcount(skb);
1430 1431
1431 if (!pkts) { 1432 if (!pkts) {
1432 tcp_set_skb_tso_segs(skb, tp->mss_cache_std); 1433 tcp_set_skb_tso_segs(sk, skb);
1433 pkts = tcp_skb_pcount(skb); 1434 pkts = tcp_skb_pcount(skb);
1434 } 1435 }
1435 1436
@@ -1490,7 +1491,7 @@ static __inline__ void __tcp_push_pending_frames(struct sock *sk,
1490 if (skb) { 1491 if (skb) {
1491 if (!tcp_skb_is_last(sk, skb)) 1492 if (!tcp_skb_is_last(sk, skb))
1492 nonagle = TCP_NAGLE_PUSH; 1493 nonagle = TCP_NAGLE_PUSH;
1493 if (!tcp_snd_test(tp, skb, cur_mss, nonagle) || 1494 if (!tcp_snd_test(sk, skb, cur_mss, nonagle) ||
1494 tcp_write_xmit(sk, nonagle)) 1495 tcp_write_xmit(sk, nonagle))
1495 tcp_check_probe_timer(sk, tp); 1496 tcp_check_probe_timer(sk, tp);
1496 } 1497 }
@@ -1508,7 +1509,7 @@ static __inline__ int tcp_may_send_now(struct sock *sk, struct tcp_sock *tp)
1508 struct sk_buff *skb = sk->sk_send_head; 1509 struct sk_buff *skb = sk->sk_send_head;
1509 1510
1510 return (skb && 1511 return (skb &&
1511 tcp_snd_test(tp, skb, tcp_current_mss(sk, 1), 1512 tcp_snd_test(sk, skb, tcp_current_mss(sk, 1),
1512 tcp_skb_is_last(sk, skb) ? TCP_NAGLE_PUSH : tp->nonagle)); 1513 tcp_skb_is_last(sk, skb) ? TCP_NAGLE_PUSH : tp->nonagle));
1513} 1514}
1514 1515
diff --git a/include/net/udp.h b/include/net/udp.h
index c496d10101db..ac229b761dbc 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)udp.h 1.0.2 05/07/93 8 * Version: @(#)udp.h 1.0.2 05/07/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * Fixes: 13 * Fixes:
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 73e9a8ca3d3b..e142a256d5dc 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1,6 +1,7 @@
1#ifndef _NET_XFRM_H 1#ifndef _NET_XFRM_H
2#define _NET_XFRM_H 2#define _NET_XFRM_H
3 3
4#include <linux/compiler.h>
4#include <linux/xfrm.h> 5#include <linux/xfrm.h>
5#include <linux/spinlock.h> 6#include <linux/spinlock.h>
6#include <linux/list.h> 7#include <linux/list.h>
@@ -516,6 +517,15 @@ struct xfrm_dst
516 u32 child_mtu_cached; 517 u32 child_mtu_cached;
517}; 518};
518 519
520static inline void xfrm_dst_destroy(struct xfrm_dst *xdst)
521{
522 dst_release(xdst->route);
523 if (likely(xdst->u.dst.xfrm))
524 xfrm_state_put(xdst->u.dst.xfrm);
525}
526
527extern void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev);
528
519/* Decapsulation state, used by the input to store data during 529/* Decapsulation state, used by the input to store data during
520 * decapsulation procedure, to be used later (during the policy 530 * decapsulation procedure, to be used later (during the policy
521 * check 531 * check
diff --git a/include/video/edid.h b/include/video/edid.h
index abc1b489c0db..b913f196131d 100644
--- a/include/video/edid.h
+++ b/include/video/edid.h
@@ -4,9 +4,6 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/config.h> 6#include <linux/config.h>
7#ifdef CONFIG_PPC_OF
8#include <linux/pci.h>
9#endif
10 7
11#ifdef CONFIG_X86 8#ifdef CONFIG_X86
12struct edid_info { 9struct edid_info {
@@ -14,14 +11,8 @@ struct edid_info {
14}; 11};
15 12
16extern struct edid_info edid_info; 13extern struct edid_info edid_info;
17extern char *get_EDID_from_BIOS(void *);
18
19#endif /* CONFIG_X86 */ 14#endif /* CONFIG_X86 */
20 15
21#ifdef CONFIG_PPC_OF
22extern char *get_EDID_from_OF(struct pci_dev *pdev);
23#endif
24
25#endif /* __KERNEL__ */ 16#endif /* __KERNEL__ */
26 17
27#endif /* __linux_video_edid_h__ */ 18#endif /* __linux_video_edid_h__ */
diff --git a/include/video/tdfx.h b/include/video/tdfx.h
index a896e4442060..04237676b17c 100644
--- a/include/video/tdfx.h
+++ b/include/video/tdfx.h
@@ -99,6 +99,8 @@
99#define MISCINIT1_2DBLOCK_DIS BIT(15) 99#define MISCINIT1_2DBLOCK_DIS BIT(15)
100#define DRAMINIT0_SGRAM_NUM BIT(26) 100#define DRAMINIT0_SGRAM_NUM BIT(26)
101#define DRAMINIT0_SGRAM_TYPE BIT(27) 101#define DRAMINIT0_SGRAM_TYPE BIT(27)
102#define DRAMINIT0_SGRAM_TYPE_MASK (BIT(27)|BIT(28)|BIT(29))
103#define DRAMINIT0_SGRAM_TYPE_SHIFT 27
102#define DRAMINIT1_MEM_SDRAM BIT(30) 104#define DRAMINIT1_MEM_SDRAM BIT(30)
103#define VGAINIT0_VGA_DISABLE BIT(0) 105#define VGAINIT0_VGA_DISABLE BIT(0)
104#define VGAINIT0_EXT_TIMING BIT(1) 106#define VGAINIT0_EXT_TIMING BIT(1)
diff --git a/init/Kconfig b/init/Kconfig
index abe2682a6ca6..d920baed109a 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -173,7 +173,7 @@ config AUDIT
173 173
174config AUDITSYSCALL 174config AUDITSYSCALL
175 bool "Enable system-call auditing support" 175 bool "Enable system-call auditing support"
176 depends on AUDIT && (X86 || PPC64 || ARCH_S390 || IA64) 176 depends on AUDIT && (X86 || PPC64 || ARCH_S390 || IA64 || UML)
177 default y if SECURITY_SELINUX 177 default y if SECURITY_SELINUX
178 help 178 help
179 Enable low-overhead system-call auditing infrastructure that 179 Enable low-overhead system-call auditing infrastructure that
@@ -275,6 +275,27 @@ config KALLSYMS_EXTRA_PASS
275 reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while 275 reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while
276 you wait for kallsyms to be fixed. 276 you wait for kallsyms to be fixed.
277 277
278
279config PRINTK
280 default y
281 bool "Enable support for printk" if EMBEDDED
282 help
283 This option enables normal printk support. Removing it
284 eliminates most of the message strings from the kernel image
285 and makes the kernel more or less silent. As this makes it
286 very difficult to diagnose system problems, saying N here is
287 strongly discouraged.
288
289config BUG
290 bool "BUG() support" if EMBEDDED
291 default y
292 help
293 Disabling this option eliminates support for BUG and WARN, reducing
294 the size of your kernel image and potentially quietly ignoring
295 numerous fatal conditions. You should only consider disabling this
296 option for embedded systems with no facilities for reporting errors.
297 Just say Y.
298
278config BASE_FULL 299config BASE_FULL
279 default y 300 default y
280 bool "Enable full-sized data structures for core" if EMBEDDED 301 bool "Enable full-sized data structures for core" if EMBEDDED
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index cb0cd3cf3b5a..0acf245f441d 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -23,6 +23,7 @@
23#include <linux/skbuff.h> 23#include <linux/skbuff.h>
24#include <linux/netlink.h> 24#include <linux/netlink.h>
25#include <linux/syscalls.h> 25#include <linux/syscalls.h>
26#include <linux/signal.h>
26#include <net/sock.h> 27#include <net/sock.h>
27#include "util.h" 28#include "util.h"
28 29
@@ -767,7 +768,7 @@ static inline void pipelined_send(struct mqueue_inode_info *info,
767 list_del(&receiver->list); 768 list_del(&receiver->list);
768 receiver->state = STATE_PENDING; 769 receiver->state = STATE_PENDING;
769 wake_up_process(receiver->task); 770 wake_up_process(receiver->task);
770 wmb(); 771 smp_wmb();
771 receiver->state = STATE_READY; 772 receiver->state = STATE_READY;
772} 773}
773 774
@@ -786,7 +787,7 @@ static inline void pipelined_receive(struct mqueue_inode_info *info)
786 list_del(&sender->list); 787 list_del(&sender->list);
787 sender->state = STATE_PENDING; 788 sender->state = STATE_PENDING;
788 wake_up_process(sender->task); 789 wake_up_process(sender->task);
789 wmb(); 790 smp_wmb();
790 sender->state = STATE_READY; 791 sender->state = STATE_READY;
791} 792}
792 793
@@ -976,8 +977,7 @@ asmlinkage long sys_mq_notify(mqd_t mqdes,
976 notification.sigev_notify != SIGEV_THREAD)) 977 notification.sigev_notify != SIGEV_THREAD))
977 return -EINVAL; 978 return -EINVAL;
978 if (notification.sigev_notify == SIGEV_SIGNAL && 979 if (notification.sigev_notify == SIGEV_SIGNAL &&
979 (notification.sigev_signo < 0 || 980 !valid_signal(notification.sigev_signo)) {
980 notification.sigev_signo > _NSIG)) {
981 return -EINVAL; 981 return -EINVAL;
982 } 982 }
983 if (notification.sigev_notify == SIGEV_THREAD) { 983 if (notification.sigev_notify == SIGEV_THREAD) {
diff --git a/ipc/shm.c b/ipc/shm.c
index 06cd5c91056f..cce022435dbc 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -28,6 +28,8 @@
28#include <linux/security.h> 28#include <linux/security.h>
29#include <linux/syscalls.h> 29#include <linux/syscalls.h>
30#include <linux/audit.h> 30#include <linux/audit.h>
31#include <linux/ptrace.h>
32
31#include <asm/uaccess.h> 33#include <asm/uaccess.h>
32 34
33#include "util.h" 35#include "util.h"
@@ -771,6 +773,18 @@ out:
771 return err; 773 return err;
772} 774}
773 775
776asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg)
777{
778 unsigned long ret;
779 long err;
780
781 err = do_shmat(shmid, shmaddr, shmflg, &ret);
782 if (err)
783 return err;
784 force_successful_syscall_return();
785 return (long)ret;
786}
787
774/* 788/*
775 * detach and kill segment if marked destroyed. 789 * detach and kill segment if marked destroyed.
776 * The work is done in shm_close. 790 * The work is done in shm_close.
diff --git a/kernel/Makefile b/kernel/Makefile
index eb88b446c2cc..b01d26fe8db7 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -29,7 +29,7 @@ obj-$(CONFIG_SYSFS) += ksysfs.o
29obj-$(CONFIG_GENERIC_HARDIRQS) += irq/ 29obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
30obj-$(CONFIG_SECCOMP) += seccomp.o 30obj-$(CONFIG_SECCOMP) += seccomp.o
31 31
32ifneq ($(CONFIG_IA64),y) 32ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
33# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is 33# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
34# needed for x86 only. Why this used to be enabled for all architectures is beyond 34# needed for x86 only. Why this used to be enabled for all architectures is beyond
35# me. I suspect most platforms don't need this, but until we know that for sure 35# me. I suspect most platforms don't need this, but until we know that for sure
diff --git a/kernel/audit.c b/kernel/audit.c
index 0f84dd7af2c8..9c4f1af0c794 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1,4 +1,4 @@
1/* audit.c -- Auditing support -*- linux-c -*- 1/* audit.c -- Auditing support
2 * Gateway between the kernel (e.g., selinux) and the user-space audit daemon. 2 * Gateway between the kernel (e.g., selinux) and the user-space audit daemon.
3 * System-call specific features have moved to auditsc.c 3 * System-call specific features have moved to auditsc.c
4 * 4 *
@@ -38,7 +38,7 @@
38 * 6) Support low-overhead kernel-based filtering to minimize the 38 * 6) Support low-overhead kernel-based filtering to minimize the
39 * information that must be passed to user-space. 39 * information that must be passed to user-space.
40 * 40 *
41 * Example user-space utilities: http://people.redhat.com/faith/audit/ 41 * Example user-space utilities: http://people.redhat.com/sgrubb/audit/
42 */ 42 */
43 43
44#include <linux/init.h> 44#include <linux/init.h>
@@ -142,7 +142,6 @@ struct audit_buffer {
142 int total; 142 int total;
143 int type; 143 int type;
144 int pid; 144 int pid;
145 int count; /* Times requeued */
146}; 145};
147 146
148void audit_set_type(struct audit_buffer *ab, int type) 147void audit_set_type(struct audit_buffer *ab, int type)
@@ -239,36 +238,36 @@ void audit_log_lost(const char *message)
239 238
240} 239}
241 240
242static int audit_set_rate_limit(int limit) 241static int audit_set_rate_limit(int limit, uid_t loginuid)
243{ 242{
244 int old = audit_rate_limit; 243 int old = audit_rate_limit;
245 audit_rate_limit = limit; 244 audit_rate_limit = limit;
246 audit_log(current->audit_context, "audit_rate_limit=%d old=%d", 245 audit_log(NULL, "audit_rate_limit=%d old=%d by auid %u",
247 audit_rate_limit, old); 246 audit_rate_limit, old, loginuid);
248 return old; 247 return old;
249} 248}
250 249
251static int audit_set_backlog_limit(int limit) 250static int audit_set_backlog_limit(int limit, uid_t loginuid)
252{ 251{
253 int old = audit_backlog_limit; 252 int old = audit_backlog_limit;
254 audit_backlog_limit = limit; 253 audit_backlog_limit = limit;
255 audit_log(current->audit_context, "audit_backlog_limit=%d old=%d", 254 audit_log(NULL, "audit_backlog_limit=%d old=%d by auid %u",
256 audit_backlog_limit, old); 255 audit_backlog_limit, old, loginuid);
257 return old; 256 return old;
258} 257}
259 258
260static int audit_set_enabled(int state) 259static int audit_set_enabled(int state, uid_t loginuid)
261{ 260{
262 int old = audit_enabled; 261 int old = audit_enabled;
263 if (state != 0 && state != 1) 262 if (state != 0 && state != 1)
264 return -EINVAL; 263 return -EINVAL;
265 audit_enabled = state; 264 audit_enabled = state;
266 audit_log(current->audit_context, "audit_enabled=%d old=%d", 265 audit_log(NULL, "audit_enabled=%d old=%d by auid %u",
267 audit_enabled, old); 266 audit_enabled, old, loginuid);
268 return old; 267 return old;
269} 268}
270 269
271static int audit_set_failure(int state) 270static int audit_set_failure(int state, uid_t loginuid)
272{ 271{
273 int old = audit_failure; 272 int old = audit_failure;
274 if (state != AUDIT_FAIL_SILENT 273 if (state != AUDIT_FAIL_SILENT
@@ -276,8 +275,8 @@ static int audit_set_failure(int state)
276 && state != AUDIT_FAIL_PANIC) 275 && state != AUDIT_FAIL_PANIC)
277 return -EINVAL; 276 return -EINVAL;
278 audit_failure = state; 277 audit_failure = state;
279 audit_log(current->audit_context, "audit_failure=%d old=%d", 278 audit_log(NULL, "audit_failure=%d old=%d by auid %u",
280 audit_failure, old); 279 audit_failure, old, loginuid);
281 return old; 280 return old;
282} 281}
283 282
@@ -344,6 +343,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
344 int err; 343 int err;
345 struct audit_buffer *ab; 344 struct audit_buffer *ab;
346 u16 msg_type = nlh->nlmsg_type; 345 u16 msg_type = nlh->nlmsg_type;
346 uid_t loginuid; /* loginuid of sender */
347 347
348 err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type); 348 err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type);
349 if (err) 349 if (err)
@@ -351,6 +351,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
351 351
352 pid = NETLINK_CREDS(skb)->pid; 352 pid = NETLINK_CREDS(skb)->pid;
353 uid = NETLINK_CREDS(skb)->uid; 353 uid = NETLINK_CREDS(skb)->uid;
354 loginuid = NETLINK_CB(skb).loginuid;
354 seq = nlh->nlmsg_seq; 355 seq = nlh->nlmsg_seq;
355 data = NLMSG_DATA(nlh); 356 data = NLMSG_DATA(nlh);
356 357
@@ -371,34 +372,36 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
371 return -EINVAL; 372 return -EINVAL;
372 status_get = (struct audit_status *)data; 373 status_get = (struct audit_status *)data;
373 if (status_get->mask & AUDIT_STATUS_ENABLED) { 374 if (status_get->mask & AUDIT_STATUS_ENABLED) {
374 err = audit_set_enabled(status_get->enabled); 375 err = audit_set_enabled(status_get->enabled, loginuid);
375 if (err < 0) return err; 376 if (err < 0) return err;
376 } 377 }
377 if (status_get->mask & AUDIT_STATUS_FAILURE) { 378 if (status_get->mask & AUDIT_STATUS_FAILURE) {
378 err = audit_set_failure(status_get->failure); 379 err = audit_set_failure(status_get->failure, loginuid);
379 if (err < 0) return err; 380 if (err < 0) return err;
380 } 381 }
381 if (status_get->mask & AUDIT_STATUS_PID) { 382 if (status_get->mask & AUDIT_STATUS_PID) {
382 int old = audit_pid; 383 int old = audit_pid;
383 audit_pid = status_get->pid; 384 audit_pid = status_get->pid;
384 audit_log(current->audit_context, 385 audit_log(NULL, "audit_pid=%d old=%d by auid %u",
385 "audit_pid=%d old=%d", audit_pid, old); 386 audit_pid, old, loginuid);
386 } 387 }
387 if (status_get->mask & AUDIT_STATUS_RATE_LIMIT) 388 if (status_get->mask & AUDIT_STATUS_RATE_LIMIT)
388 audit_set_rate_limit(status_get->rate_limit); 389 audit_set_rate_limit(status_get->rate_limit, loginuid);
389 if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT) 390 if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT)
390 audit_set_backlog_limit(status_get->backlog_limit); 391 audit_set_backlog_limit(status_get->backlog_limit,
392 loginuid);
391 break; 393 break;
392 case AUDIT_USER: 394 case AUDIT_USER:
393 ab = audit_log_start(NULL); 395 ab = audit_log_start(NULL);
394 if (!ab) 396 if (!ab)
395 break; /* audit_panic has been called */ 397 break; /* audit_panic has been called */
396 audit_log_format(ab, 398 audit_log_format(ab,
397 "user pid=%d uid=%d length=%d msg='%.1024s'", 399 "user pid=%d uid=%d length=%d loginuid=%u"
400 " msg='%.1024s'",
398 pid, uid, 401 pid, uid,
399 (int)(nlh->nlmsg_len 402 (int)(nlh->nlmsg_len
400 - ((char *)data - (char *)nlh)), 403 - ((char *)data - (char *)nlh)),
401 (char *)data); 404 loginuid, (char *)data);
402 ab->type = AUDIT_USER; 405 ab->type = AUDIT_USER;
403 ab->pid = pid; 406 ab->pid = pid;
404 audit_log_end(ab); 407 audit_log_end(ab);
@@ -411,7 +414,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
411 case AUDIT_LIST: 414 case AUDIT_LIST:
412#ifdef CONFIG_AUDITSYSCALL 415#ifdef CONFIG_AUDITSYSCALL
413 err = audit_receive_filter(nlh->nlmsg_type, NETLINK_CB(skb).pid, 416 err = audit_receive_filter(nlh->nlmsg_type, NETLINK_CB(skb).pid,
414 uid, seq, data); 417 uid, seq, data, loginuid);
415#else 418#else
416 err = -EOPNOTSUPP; 419 err = -EOPNOTSUPP;
417#endif 420#endif
@@ -427,7 +430,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
427/* Get message from skb (based on rtnetlink_rcv_skb). Each message is 430/* Get message from skb (based on rtnetlink_rcv_skb). Each message is
428 * processed by audit_receive_msg. Malformed skbs with wrong length are 431 * processed by audit_receive_msg. Malformed skbs with wrong length are
429 * discarded silently. */ 432 * discarded silently. */
430static int audit_receive_skb(struct sk_buff *skb) 433static void audit_receive_skb(struct sk_buff *skb)
431{ 434{
432 int err; 435 int err;
433 struct nlmsghdr *nlh; 436 struct nlmsghdr *nlh;
@@ -436,7 +439,7 @@ static int audit_receive_skb(struct sk_buff *skb)
436 while (skb->len >= NLMSG_SPACE(0)) { 439 while (skb->len >= NLMSG_SPACE(0)) {
437 nlh = (struct nlmsghdr *)skb->data; 440 nlh = (struct nlmsghdr *)skb->data;
438 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) 441 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
439 return 0; 442 return;
440 rlen = NLMSG_ALIGN(nlh->nlmsg_len); 443 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
441 if (rlen > skb->len) 444 if (rlen > skb->len)
442 rlen = skb->len; 445 rlen = skb->len;
@@ -446,23 +449,20 @@ static int audit_receive_skb(struct sk_buff *skb)
446 netlink_ack(skb, nlh, 0); 449 netlink_ack(skb, nlh, 0);
447 skb_pull(skb, rlen); 450 skb_pull(skb, rlen);
448 } 451 }
449 return 0;
450} 452}
451 453
452/* Receive messages from netlink socket. */ 454/* Receive messages from netlink socket. */
453static void audit_receive(struct sock *sk, int length) 455static void audit_receive(struct sock *sk, int length)
454{ 456{
455 struct sk_buff *skb; 457 struct sk_buff *skb;
458 unsigned int qlen;
456 459
457 if (down_trylock(&audit_netlink_sem)) 460 down(&audit_netlink_sem);
458 return;
459 461
460 /* FIXME: this must not cause starvation */ 462 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
461 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { 463 skb = skb_dequeue(&sk->sk_receive_queue);
462 if (audit_receive_skb(skb) && skb->len) 464 audit_receive_skb(skb);
463 skb_queue_head(&sk->sk_receive_queue, skb); 465 kfree_skb(skb);
464 else
465 kfree_skb(skb);
466 } 466 }
467 up(&audit_netlink_sem); 467 up(&audit_netlink_sem);
468} 468}
@@ -483,7 +483,7 @@ static void audit_log_move(struct audit_buffer *ab)
483 if (ab->len == 0) 483 if (ab->len == 0)
484 return; 484 return;
485 485
486 skb = skb_peek(&ab->sklist); 486 skb = skb_peek_tail(&ab->sklist);
487 if (!skb || skb_tailroom(skb) <= ab->len + extra) { 487 if (!skb || skb_tailroom(skb) <= ab->len + extra) {
488 skb = alloc_skb(2 * ab->len + extra, GFP_ATOMIC); 488 skb = alloc_skb(2 * ab->len + extra, GFP_ATOMIC);
489 if (!skb) { 489 if (!skb) {
@@ -522,9 +522,9 @@ static inline int audit_log_drain(struct audit_buffer *ab)
522 retval = netlink_unicast(audit_sock, skb, audit_pid, 522 retval = netlink_unicast(audit_sock, skb, audit_pid,
523 MSG_DONTWAIT); 523 MSG_DONTWAIT);
524 } 524 }
525 if (retval == -EAGAIN && ab->count < 5) { 525 if (retval == -EAGAIN &&
526 ++ab->count; 526 (atomic_read(&audit_backlog)) < audit_backlog_limit) {
527 skb_queue_tail(&ab->sklist, skb); 527 skb_queue_head(&ab->sklist, skb);
528 audit_log_end_irq(ab); 528 audit_log_end_irq(ab);
529 return 1; 529 return 1;
530 } 530 }
@@ -540,8 +540,8 @@ static inline int audit_log_drain(struct audit_buffer *ab)
540 if (!audit_pid) { /* No daemon */ 540 if (!audit_pid) { /* No daemon */
541 int offset = ab->nlh ? NLMSG_SPACE(0) : 0; 541 int offset = ab->nlh ? NLMSG_SPACE(0) : 0;
542 int len = skb->len - offset; 542 int len = skb->len - offset;
543 printk(KERN_ERR "%*.*s\n", 543 skb->data[offset + len] = '\0';
544 len, len, skb->data + offset); 544 printk(KERN_ERR "%s\n", skb->data + offset);
545 } 545 }
546 kfree_skb(skb); 546 kfree_skb(skb);
547 ab->nlh = NULL; 547 ab->nlh = NULL;
@@ -620,7 +620,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx)
620 struct audit_buffer *ab = NULL; 620 struct audit_buffer *ab = NULL;
621 unsigned long flags; 621 unsigned long flags;
622 struct timespec t; 622 struct timespec t;
623 int serial = 0; 623 unsigned int serial;
624 624
625 if (!audit_initialized) 625 if (!audit_initialized)
626 return NULL; 626 return NULL;
@@ -662,15 +662,16 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx)
662 ab->total = 0; 662 ab->total = 0;
663 ab->type = AUDIT_KERNEL; 663 ab->type = AUDIT_KERNEL;
664 ab->pid = 0; 664 ab->pid = 0;
665 ab->count = 0;
666 665
667#ifdef CONFIG_AUDITSYSCALL 666#ifdef CONFIG_AUDITSYSCALL
668 if (ab->ctx) 667 if (ab->ctx)
669 audit_get_stamp(ab->ctx, &t, &serial); 668 audit_get_stamp(ab->ctx, &t, &serial);
670 else 669 else
671#endif 670#endif
671 {
672 t = CURRENT_TIME; 672 t = CURRENT_TIME;
673 673 serial = 0;
674 }
674 audit_log_format(ab, "audit(%lu.%03lu:%u): ", 675 audit_log_format(ab, "audit(%lu.%03lu:%u): ",
675 t.tv_sec, t.tv_nsec/1000000, serial); 676 t.tv_sec, t.tv_nsec/1000000, serial);
676 return ab; 677 return ab;
@@ -720,6 +721,29 @@ void audit_log_format(struct audit_buffer *ab, const char *fmt, ...)
720 va_end(args); 721 va_end(args);
721} 722}
722 723
724void audit_log_hex(struct audit_buffer *ab, const unsigned char *buf, size_t len)
725{
726 int i;
727
728 for (i=0; i<len; i++)
729 audit_log_format(ab, "%02x", buf[i]);
730}
731
732void audit_log_untrustedstring(struct audit_buffer *ab, const char *string)
733{
734 const unsigned char *p = string;
735
736 while (*p) {
737 if (*p == '"' || *p == ' ' || *p < 0x20 || *p > 0x7f) {
738 audit_log_hex(ab, string, strlen(string));
739 return;
740 }
741 p++;
742 }
743 audit_log_format(ab, "\"%s\"", string);
744}
745
746
723/* This is a helper-function to print the d_path without using a static 747/* This is a helper-function to print the d_path without using a static
724 * buffer or allocating another buffer in addition to the one in 748 * buffer or allocating another buffer in addition to the one in
725 * audit_buffer. */ 749 * audit_buffer. */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 6f1931381bc9..37b3ac94bc47 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1,4 +1,4 @@
1/* auditsc.c -- System-call auditing support -*- linux-c -*- 1/* auditsc.c -- System-call auditing support
2 * Handles all system-call specific auditing features. 2 * Handles all system-call specific auditing features.
3 * 3 *
4 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. 4 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
@@ -123,7 +123,7 @@ struct audit_context {
123 int major; /* syscall number */ 123 int major; /* syscall number */
124 unsigned long argv[4]; /* syscall arguments */ 124 unsigned long argv[4]; /* syscall arguments */
125 int return_valid; /* return code is valid */ 125 int return_valid; /* return code is valid */
126 int return_code;/* syscall return code */ 126 long return_code;/* syscall return code */
127 int auditable; /* 1 if record should be written */ 127 int auditable; /* 1 if record should be written */
128 int name_count; 128 int name_count;
129 struct audit_names names[AUDIT_NAMES]; 129 struct audit_names names[AUDIT_NAMES];
@@ -135,6 +135,7 @@ struct audit_context {
135 uid_t uid, euid, suid, fsuid; 135 uid_t uid, euid, suid, fsuid;
136 gid_t gid, egid, sgid, fsgid; 136 gid_t gid, egid, sgid, fsgid;
137 unsigned long personality; 137 unsigned long personality;
138 int arch;
138 139
139#if AUDIT_DEBUG 140#if AUDIT_DEBUG
140 int put_count; 141 int put_count;
@@ -250,7 +251,8 @@ static int audit_copy_rule(struct audit_rule *d, struct audit_rule *s)
250 return 0; 251 return 0;
251} 252}
252 253
253int audit_receive_filter(int type, int pid, int uid, int seq, void *data) 254int audit_receive_filter(int type, int pid, int uid, int seq, void *data,
255 uid_t loginuid)
254{ 256{
255 u32 flags; 257 u32 flags;
256 struct audit_entry *entry; 258 struct audit_entry *entry;
@@ -285,6 +287,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data)
285 err = audit_add_rule(entry, &audit_entlist); 287 err = audit_add_rule(entry, &audit_entlist);
286 if (!err && (flags & AUDIT_AT_EXIT)) 288 if (!err && (flags & AUDIT_AT_EXIT))
287 err = audit_add_rule(entry, &audit_extlist); 289 err = audit_add_rule(entry, &audit_extlist);
290 audit_log(NULL, "auid %u added an audit rule\n", loginuid);
288 break; 291 break;
289 case AUDIT_DEL: 292 case AUDIT_DEL:
290 flags =((struct audit_rule *)data)->flags; 293 flags =((struct audit_rule *)data)->flags;
@@ -294,6 +297,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data)
294 err = audit_del_rule(data, &audit_entlist); 297 err = audit_del_rule(data, &audit_entlist);
295 if (!err && (flags & AUDIT_AT_EXIT)) 298 if (!err && (flags & AUDIT_AT_EXIT))
296 err = audit_del_rule(data, &audit_extlist); 299 err = audit_del_rule(data, &audit_extlist);
300 audit_log(NULL, "auid %u removed an audit rule\n", loginuid);
297 break; 301 break;
298 default: 302 default:
299 return -EINVAL; 303 return -EINVAL;
@@ -348,6 +352,10 @@ static int audit_filter_rules(struct task_struct *tsk,
348 case AUDIT_PERS: 352 case AUDIT_PERS:
349 result = (tsk->personality == value); 353 result = (tsk->personality == value);
350 break; 354 break;
355 case AUDIT_ARCH:
356 if (ctx)
357 result = (ctx->arch == value);
358 break;
351 359
352 case AUDIT_EXIT: 360 case AUDIT_EXIT:
353 if (ctx && ctx->return_valid) 361 if (ctx && ctx->return_valid)
@@ -355,7 +363,7 @@ static int audit_filter_rules(struct task_struct *tsk,
355 break; 363 break;
356 case AUDIT_SUCCESS: 364 case AUDIT_SUCCESS:
357 if (ctx && ctx->return_valid) 365 if (ctx && ctx->return_valid)
358 result = (ctx->return_code >= 0); 366 result = (ctx->return_valid == AUDITSC_SUCCESS);
359 break; 367 break;
360 case AUDIT_DEVMAJOR: 368 case AUDIT_DEVMAJOR:
361 if (ctx) { 369 if (ctx) {
@@ -648,8 +656,11 @@ static void audit_log_exit(struct audit_context *context)
648 audit_log_format(ab, "syscall=%d", context->major); 656 audit_log_format(ab, "syscall=%d", context->major);
649 if (context->personality != PER_LINUX) 657 if (context->personality != PER_LINUX)
650 audit_log_format(ab, " per=%lx", context->personality); 658 audit_log_format(ab, " per=%lx", context->personality);
659 audit_log_format(ab, " arch=%x", context->arch);
651 if (context->return_valid) 660 if (context->return_valid)
652 audit_log_format(ab, " exit=%d", context->return_code); 661 audit_log_format(ab, " success=%s exit=%ld",
662 (context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
663 context->return_code);
653 audit_log_format(ab, 664 audit_log_format(ab,
654 " a0=%lx a1=%lx a2=%lx a3=%lx items=%d" 665 " a0=%lx a1=%lx a2=%lx a3=%lx items=%d"
655 " pid=%d loginuid=%d uid=%d gid=%d" 666 " pid=%d loginuid=%d uid=%d gid=%d"
@@ -696,9 +707,10 @@ static void audit_log_exit(struct audit_context *context)
696 if (!ab) 707 if (!ab)
697 continue; /* audit_panic has been called */ 708 continue; /* audit_panic has been called */
698 audit_log_format(ab, "item=%d", i); 709 audit_log_format(ab, "item=%d", i);
699 if (context->names[i].name) 710 if (context->names[i].name) {
700 audit_log_format(ab, " name=%s", 711 audit_log_format(ab, " name=");
701 context->names[i].name); 712 audit_log_untrustedstring(ab, context->names[i].name);
713 }
702 if (context->names[i].ino != (unsigned long)-1) 714 if (context->names[i].ino != (unsigned long)-1)
703 audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o" 715 audit_log_format(ab, " inode=%lu dev=%02x:%02x mode=%#o"
704 " uid=%d gid=%d rdev=%02x:%02x", 716 " uid=%d gid=%d rdev=%02x:%02x",
@@ -772,7 +784,7 @@ static inline unsigned int audit_serial(void)
772 * then the record will be written at syscall exit time (otherwise, it 784 * then the record will be written at syscall exit time (otherwise, it
773 * will only be written if another part of the kernel requests that it 785 * will only be written if another part of the kernel requests that it
774 * be written). */ 786 * be written). */
775void audit_syscall_entry(struct task_struct *tsk, int major, 787void audit_syscall_entry(struct task_struct *tsk, int arch, int major,
776 unsigned long a1, unsigned long a2, 788 unsigned long a1, unsigned long a2,
777 unsigned long a3, unsigned long a4) 789 unsigned long a3, unsigned long a4)
778{ 790{
@@ -826,6 +838,7 @@ void audit_syscall_entry(struct task_struct *tsk, int major,
826 if (!audit_enabled) 838 if (!audit_enabled)
827 return; 839 return;
828 840
841 context->arch = arch;
829 context->major = major; 842 context->major = major;
830 context->argv[0] = a1; 843 context->argv[0] = a1;
831 context->argv[1] = a2; 844 context->argv[1] = a2;
@@ -849,13 +862,13 @@ void audit_syscall_entry(struct task_struct *tsk, int major,
849 * filtering, or because some other part of the kernel write an audit 862 * filtering, or because some other part of the kernel write an audit
850 * message), then write out the syscall information. In call cases, 863 * message), then write out the syscall information. In call cases,
851 * free the names stored from getname(). */ 864 * free the names stored from getname(). */
852void audit_syscall_exit(struct task_struct *tsk, int return_code) 865void audit_syscall_exit(struct task_struct *tsk, int valid, long return_code)
853{ 866{
854 struct audit_context *context; 867 struct audit_context *context;
855 868
856 get_task_struct(tsk); 869 get_task_struct(tsk);
857 task_lock(tsk); 870 task_lock(tsk);
858 context = audit_get_context(tsk, 1, return_code); 871 context = audit_get_context(tsk, valid, return_code);
859 task_unlock(tsk); 872 task_unlock(tsk);
860 873
861 /* Not having a context here is ok, since the parent may have 874 /* Not having a context here is ok, since the parent may have
@@ -868,6 +881,7 @@ void audit_syscall_exit(struct task_struct *tsk, int return_code)
868 881
869 context->in_syscall = 0; 882 context->in_syscall = 0;
870 context->auditable = 0; 883 context->auditable = 0;
884
871 if (context->previous) { 885 if (context->previous) {
872 struct audit_context *new_context = context->previous; 886 struct audit_context *new_context = context->previous;
873 context->previous = NULL; 887 context->previous = NULL;
@@ -981,7 +995,7 @@ void audit_inode(const char *name, const struct inode *inode)
981} 995}
982 996
983void audit_get_stamp(struct audit_context *ctx, 997void audit_get_stamp(struct audit_context *ctx,
984 struct timespec *t, int *serial) 998 struct timespec *t, unsigned int *serial)
985{ 999{
986 if (ctx) { 1000 if (ctx) {
987 t->tv_sec = ctx->ctime.tv_sec; 1001 t->tv_sec = ctx->ctime.tv_sec;
@@ -996,20 +1010,21 @@ void audit_get_stamp(struct audit_context *ctx,
996 1010
997extern int audit_set_type(struct audit_buffer *ab, int type); 1011extern int audit_set_type(struct audit_buffer *ab, int type);
998 1012
999int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid) 1013int audit_set_loginuid(struct task_struct *task, uid_t loginuid)
1000{ 1014{
1001 if (ctx) { 1015 if (task->audit_context) {
1002 struct audit_buffer *ab; 1016 struct audit_buffer *ab;
1003 1017
1004 ab = audit_log_start(NULL); 1018 ab = audit_log_start(NULL);
1005 if (ab) { 1019 if (ab) {
1006 audit_log_format(ab, "login pid=%d uid=%u " 1020 audit_log_format(ab, "login pid=%d uid=%u "
1007 "old loginuid=%u new loginuid=%u", 1021 "old loginuid=%u new loginuid=%u",
1008 ctx->pid, ctx->uid, ctx->loginuid, loginuid); 1022 task->pid, task->uid,
1023 task->audit_context->loginuid, loginuid);
1009 audit_set_type(ab, AUDIT_LOGIN); 1024 audit_set_type(ab, AUDIT_LOGIN);
1010 audit_log_end(ab); 1025 audit_log_end(ab);
1011 } 1026 }
1012 ctx->loginuid = loginuid; 1027 task->audit_context->loginuid = loginuid;
1013 } 1028 }
1014 return 0; 1029 return 0;
1015} 1030}
diff --git a/kernel/exit.c b/kernel/exit.c
index 39d35935b371..edaa50b5bbfa 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -27,6 +27,7 @@
27#include <linux/mempolicy.h> 27#include <linux/mempolicy.h>
28#include <linux/cpuset.h> 28#include <linux/cpuset.h>
29#include <linux/syscalls.h> 29#include <linux/syscalls.h>
30#include <linux/signal.h>
30 31
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/unistd.h> 33#include <asm/unistd.h>
@@ -38,6 +39,8 @@ extern struct task_struct *child_reaper;
38 39
39int getrusage(struct task_struct *, int, struct rusage __user *); 40int getrusage(struct task_struct *, int, struct rusage __user *);
40 41
42static void exit_mm(struct task_struct * tsk);
43
41static void __unhash_process(struct task_struct *p) 44static void __unhash_process(struct task_struct *p)
42{ 45{
43 nr_threads--; 46 nr_threads--;
@@ -209,7 +212,7 @@ static inline int has_stopped_jobs(int pgrp)
209} 212}
210 213
211/** 214/**
212 * reparent_to_init() - Reparent the calling kernel thread to the init task. 215 * reparent_to_init - Reparent the calling kernel thread to the init task.
213 * 216 *
214 * If a kernel thread is launched as a result of a system call, or if 217 * If a kernel thread is launched as a result of a system call, or if
215 * it ever exits, it should generally reparent itself to init so that 218 * it ever exits, it should generally reparent itself to init so that
@@ -277,7 +280,7 @@ void set_special_pids(pid_t session, pid_t pgrp)
277 */ 280 */
278int allow_signal(int sig) 281int allow_signal(int sig)
279{ 282{
280 if (sig < 1 || sig > _NSIG) 283 if (!valid_signal(sig) || sig < 1)
281 return -EINVAL; 284 return -EINVAL;
282 285
283 spin_lock_irq(&current->sighand->siglock); 286 spin_lock_irq(&current->sighand->siglock);
@@ -298,7 +301,7 @@ EXPORT_SYMBOL(allow_signal);
298 301
299int disallow_signal(int sig) 302int disallow_signal(int sig)
300{ 303{
301 if (sig < 1 || sig > _NSIG) 304 if (!valid_signal(sig) || sig < 1)
302 return -EINVAL; 305 return -EINVAL;
303 306
304 spin_lock_irq(&current->sighand->siglock); 307 spin_lock_irq(&current->sighand->siglock);
@@ -473,7 +476,7 @@ EXPORT_SYMBOL_GPL(exit_fs);
473 * Turn us into a lazy TLB process if we 476 * Turn us into a lazy TLB process if we
474 * aren't already.. 477 * aren't already..
475 */ 478 */
476void exit_mm(struct task_struct * tsk) 479static void exit_mm(struct task_struct * tsk)
477{ 480{
478 struct mm_struct *mm = tsk->mm; 481 struct mm_struct *mm = tsk->mm;
479 482
@@ -517,8 +520,6 @@ static inline void choose_new_parent(task_t *p, task_t *reaper, task_t *child_re
517 */ 520 */
518 BUG_ON(p == reaper || reaper->exit_state >= EXIT_ZOMBIE); 521 BUG_ON(p == reaper || reaper->exit_state >= EXIT_ZOMBIE);
519 p->real_parent = reaper; 522 p->real_parent = reaper;
520 if (p->parent == p->real_parent)
521 BUG();
522} 523}
523 524
524static inline void reparent_thread(task_t *p, task_t *father, int traced) 525static inline void reparent_thread(task_t *p, task_t *father, int traced)
@@ -845,6 +846,8 @@ fastcall NORET_TYPE void do_exit(long code)
845 for (;;) ; 846 for (;;) ;
846} 847}
847 848
849EXPORT_SYMBOL_GPL(do_exit);
850
848NORET_TYPE void complete_and_exit(struct completion *comp, long code) 851NORET_TYPE void complete_and_exit(struct completion *comp, long code)
849{ 852{
850 if (comp) 853 if (comp)
diff --git a/kernel/futex.c b/kernel/futex.c
index 7b54a672d0ad..c7130f86106c 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -39,6 +39,7 @@
39#include <linux/mount.h> 39#include <linux/mount.h>
40#include <linux/pagemap.h> 40#include <linux/pagemap.h>
41#include <linux/syscalls.h> 41#include <linux/syscalls.h>
42#include <linux/signal.h>
42 43
43#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8) 44#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8)
44 45
@@ -654,7 +655,7 @@ static int futex_fd(unsigned long uaddr, int signal)
654 int ret, err; 655 int ret, err;
655 656
656 ret = -EINVAL; 657 ret = -EINVAL;
657 if (signal < 0 || signal > _NSIG) 658 if (!valid_signal(signal))
658 goto out; 659 goto out;
659 660
660 ret = get_unused_fd(); 661 ret = get_unused_fd();
diff --git a/kernel/itimer.c b/kernel/itimer.c
index e9a40e947e07..1dc988e0d2c7 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -123,7 +123,11 @@ static inline void it_real_arm(struct task_struct *p, unsigned long interval)
123 return; 123 return;
124 if (interval > (unsigned long) LONG_MAX) 124 if (interval > (unsigned long) LONG_MAX)
125 interval = LONG_MAX; 125 interval = LONG_MAX;
126 p->signal->real_timer.expires = jiffies + interval; 126 /* the "+ 1" below makes sure that the timer doesn't go off before
127 * the interval requested. This could happen if
128 * time requested % (usecs per jiffy) is more than the usecs left
129 * in the current jiffy */
130 p->signal->real_timer.expires = jiffies + interval + 1;
127 add_timer(&p->signal->real_timer); 131 add_timer(&p->signal->real_timer);
128} 132}
129 133
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 1627f8d6e0cd..13bcec151b57 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -46,6 +46,14 @@ static inline int is_kernel_inittext(unsigned long addr)
46 return 0; 46 return 0;
47} 47}
48 48
49static inline int is_kernel_extratext(unsigned long addr)
50{
51 if (addr >= (unsigned long)_sextratext
52 && addr <= (unsigned long)_eextratext)
53 return 1;
54 return 0;
55}
56
49static inline int is_kernel_text(unsigned long addr) 57static inline int is_kernel_text(unsigned long addr)
50{ 58{
51 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) 59 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext)
@@ -169,8 +177,9 @@ const char *kallsyms_lookup(unsigned long addr,
169 namebuf[0] = 0; 177 namebuf[0] = 0;
170 178
171 if ((all_var && is_kernel(addr)) || 179 if ((all_var && is_kernel(addr)) ||
172 (!all_var && (is_kernel_text(addr) || is_kernel_inittext(addr)))) { 180 (!all_var && (is_kernel_text(addr) || is_kernel_inittext(addr) ||
173 unsigned long symbol_end=0; 181 is_kernel_extratext(addr)))) {
182 unsigned long symbol_end = 0;
174 183
175 /* do a binary search on the sorted kallsyms_addresses array */ 184 /* do a binary search on the sorted kallsyms_addresses array */
176 low = 0; 185 low = 0;
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 1d5dd1337bd1..037142b72a49 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -44,6 +44,7 @@ static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
44 44
45unsigned int kprobe_cpu = NR_CPUS; 45unsigned int kprobe_cpu = NR_CPUS;
46static DEFINE_SPINLOCK(kprobe_lock); 46static DEFINE_SPINLOCK(kprobe_lock);
47static struct kprobe *curr_kprobe;
47 48
48/* Locks kprobe: irqs must be disabled */ 49/* Locks kprobe: irqs must be disabled */
49void lock_kprobes(void) 50void lock_kprobes(void)
@@ -73,22 +74,139 @@ struct kprobe *get_kprobe(void *addr)
73 return NULL; 74 return NULL;
74} 75}
75 76
77/*
78 * Aggregate handlers for multiple kprobes support - these handlers
79 * take care of invoking the individual kprobe handlers on p->list
80 */
81int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs)
82{
83 struct kprobe *kp;
84
85 list_for_each_entry(kp, &p->list, list) {
86 if (kp->pre_handler) {
87 curr_kprobe = kp;
88 kp->pre_handler(kp, regs);
89 curr_kprobe = NULL;
90 }
91 }
92 return 0;
93}
94
95void aggr_post_handler(struct kprobe *p, struct pt_regs *regs,
96 unsigned long flags)
97{
98 struct kprobe *kp;
99
100 list_for_each_entry(kp, &p->list, list) {
101 if (kp->post_handler) {
102 curr_kprobe = kp;
103 kp->post_handler(kp, regs, flags);
104 curr_kprobe = NULL;
105 }
106 }
107 return;
108}
109
110int aggr_fault_handler(struct kprobe *p, struct pt_regs *regs, int trapnr)
111{
112 /*
113 * if we faulted "during" the execution of a user specified
114 * probe handler, invoke just that probe's fault handler
115 */
116 if (curr_kprobe && curr_kprobe->fault_handler) {
117 if (curr_kprobe->fault_handler(curr_kprobe, regs, trapnr))
118 return 1;
119 }
120 return 0;
121}
122
123/*
124 * Fill in the required fields of the "manager kprobe". Replace the
125 * earlier kprobe in the hlist with the manager kprobe
126 */
127static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
128{
129 ap->addr = p->addr;
130 ap->opcode = p->opcode;
131 memcpy(&ap->ainsn, &p->ainsn, sizeof(struct arch_specific_insn));
132
133 ap->pre_handler = aggr_pre_handler;
134 ap->post_handler = aggr_post_handler;
135 ap->fault_handler = aggr_fault_handler;
136
137 INIT_LIST_HEAD(&ap->list);
138 list_add(&p->list, &ap->list);
139
140 INIT_HLIST_NODE(&ap->hlist);
141 hlist_del(&p->hlist);
142 hlist_add_head(&ap->hlist,
143 &kprobe_table[hash_ptr(ap->addr, KPROBE_HASH_BITS)]);
144}
145
146/*
147 * This is the second or subsequent kprobe at the address - handle
148 * the intricacies
149 * TODO: Move kcalloc outside the spinlock
150 */
151static int register_aggr_kprobe(struct kprobe *old_p, struct kprobe *p)
152{
153 int ret = 0;
154 struct kprobe *ap;
155
156 if (old_p->break_handler || p->break_handler) {
157 ret = -EEXIST; /* kprobe and jprobe can't (yet) coexist */
158 } else if (old_p->pre_handler == aggr_pre_handler) {
159 list_add(&p->list, &old_p->list);
160 } else {
161 ap = kcalloc(1, sizeof(struct kprobe), GFP_ATOMIC);
162 if (!ap)
163 return -ENOMEM;
164 add_aggr_kprobe(ap, old_p);
165 list_add(&p->list, &ap->list);
166 }
167 return ret;
168}
169
170/* kprobe removal house-keeping routines */
171static inline void cleanup_kprobe(struct kprobe *p, unsigned long flags)
172{
173 *p->addr = p->opcode;
174 hlist_del(&p->hlist);
175 flush_icache_range((unsigned long) p->addr,
176 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
177 spin_unlock_irqrestore(&kprobe_lock, flags);
178 arch_remove_kprobe(p);
179}
180
181static inline void cleanup_aggr_kprobe(struct kprobe *old_p,
182 struct kprobe *p, unsigned long flags)
183{
184 list_del(&p->list);
185 if (list_empty(&old_p->list)) {
186 cleanup_kprobe(old_p, flags);
187 kfree(old_p);
188 } else
189 spin_unlock_irqrestore(&kprobe_lock, flags);
190}
191
76int register_kprobe(struct kprobe *p) 192int register_kprobe(struct kprobe *p)
77{ 193{
78 int ret = 0; 194 int ret = 0;
79 unsigned long flags = 0; 195 unsigned long flags = 0;
196 struct kprobe *old_p;
80 197
81 if ((ret = arch_prepare_kprobe(p)) != 0) { 198 if ((ret = arch_prepare_kprobe(p)) != 0) {
82 goto rm_kprobe; 199 goto rm_kprobe;
83 } 200 }
84 spin_lock_irqsave(&kprobe_lock, flags); 201 spin_lock_irqsave(&kprobe_lock, flags);
85 INIT_HLIST_NODE(&p->hlist); 202 old_p = get_kprobe(p->addr);
86 if (get_kprobe(p->addr)) { 203 if (old_p) {
87 ret = -EEXIST; 204 ret = register_aggr_kprobe(old_p, p);
88 goto out; 205 goto out;
89 } 206 }
90 arch_copy_kprobe(p);
91 207
208 arch_copy_kprobe(p);
209 INIT_HLIST_NODE(&p->hlist);
92 hlist_add_head(&p->hlist, 210 hlist_add_head(&p->hlist,
93 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); 211 &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]);
94 212
@@ -107,13 +225,17 @@ rm_kprobe:
107void unregister_kprobe(struct kprobe *p) 225void unregister_kprobe(struct kprobe *p)
108{ 226{
109 unsigned long flags; 227 unsigned long flags;
110 arch_remove_kprobe(p); 228 struct kprobe *old_p;
229
111 spin_lock_irqsave(&kprobe_lock, flags); 230 spin_lock_irqsave(&kprobe_lock, flags);
112 *p->addr = p->opcode; 231 old_p = get_kprobe(p->addr);
113 hlist_del(&p->hlist); 232 if (old_p) {
114 flush_icache_range((unsigned long) p->addr, 233 if (old_p->pre_handler == aggr_pre_handler)
115 (unsigned long) p->addr + sizeof(kprobe_opcode_t)); 234 cleanup_aggr_kprobe(old_p, p, flags);
116 spin_unlock_irqrestore(&kprobe_lock, flags); 235 else
236 cleanup_kprobe(p, flags);
237 } else
238 spin_unlock_irqrestore(&kprobe_lock, flags);
117} 239}
118 240
119static struct notifier_block kprobe_exceptions_nb = { 241static struct notifier_block kprobe_exceptions_nb = {
diff --git a/kernel/kthread.c b/kernel/kthread.c
index e377e2244103..f50f174e92da 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -174,7 +174,7 @@ int kthread_stop(struct task_struct *k)
174 174
175 /* Must init completion *before* thread sees kthread_stop_info.k */ 175 /* Must init completion *before* thread sees kthread_stop_info.k */
176 init_completion(&kthread_stop_info.done); 176 init_completion(&kthread_stop_info.done);
177 wmb(); 177 smp_wmb();
178 178
179 /* Now set kthread_should_stop() to true, and wake it up. */ 179 /* Now set kthread_should_stop() to true, and wake it up. */
180 kthread_stop_info.k = k; 180 kthread_stop_info.k = k;
diff --git a/kernel/module.c b/kernel/module.c
index 2dbfa0773faf..5734ab09d3f9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1801,7 +1801,7 @@ sys_init_module(void __user *umod,
1801 /* Init routine failed: abort. Try to protect us from 1801 /* Init routine failed: abort. Try to protect us from
1802 buggy refcounters. */ 1802 buggy refcounters. */
1803 mod->state = MODULE_STATE_GOING; 1803 mod->state = MODULE_STATE_GOING;
1804 synchronize_kernel(); 1804 synchronize_sched();
1805 if (mod->unsafe) 1805 if (mod->unsafe)
1806 printk(KERN_ERR "%s: module is now stuck!\n", 1806 printk(KERN_ERR "%s: module is now stuck!\n",
1807 mod->name); 1807 mod->name);
diff --git a/kernel/panic.c b/kernel/panic.c
index 0fa3f3a66fb6..081f7465fc8d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -102,9 +102,9 @@ NORET_TYPE void panic(const char * fmt, ...)
102#ifdef __sparc__ 102#ifdef __sparc__
103 { 103 {
104 extern int stop_a_enabled; 104 extern int stop_a_enabled;
105 /* Make sure the user can actually press L1-A */ 105 /* Make sure the user can actually press Stop-A (L1-A) */
106 stop_a_enabled = 1; 106 stop_a_enabled = 1;
107 printk(KERN_EMERG "Press L1-A to return to the boot prom\n"); 107 printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n");
108 } 108 }
109#endif 109#endif
110#if defined(CONFIG_ARCH_S390) 110#if defined(CONFIG_ARCH_S390)
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index ae5bebc3b18f..90b3b68dee3f 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -1099,7 +1099,7 @@ static struct pbe * swsusp_pagedir_relocate(struct pbe *pblist)
1099 return pblist; 1099 return pblist;
1100} 1100}
1101 1101
1102/** 1102/*
1103 * Using bio to read from swap. 1103 * Using bio to read from swap.
1104 * This code requires a bit more work than just using buffer heads 1104 * This code requires a bit more work than just using buffer heads
1105 * but, it is the recommended way for 2.5/2.6. 1105 * but, it is the recommended way for 2.5/2.6.
diff --git a/kernel/printk.c b/kernel/printk.c
index 1498689548d1..290a07ce2c8a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -85,10 +85,6 @@ static int console_locked;
85 */ 85 */
86static DEFINE_SPINLOCK(logbuf_lock); 86static DEFINE_SPINLOCK(logbuf_lock);
87 87
88static char __log_buf[__LOG_BUF_LEN];
89static char *log_buf = __log_buf;
90static int log_buf_len = __LOG_BUF_LEN;
91
92#define LOG_BUF_MASK (log_buf_len-1) 88#define LOG_BUF_MASK (log_buf_len-1)
93#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) 89#define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
94 90
@@ -99,7 +95,6 @@ static int log_buf_len = __LOG_BUF_LEN;
99static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */ 95static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */
100static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */ 96static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */
101static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */ 97static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */
102static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
103 98
104/* 99/*
105 * Array of consoles built from command line options (console=) 100 * Array of consoles built from command line options (console=)
@@ -120,6 +115,13 @@ static int preferred_console = -1;
120/* Flag: console code may call schedule() */ 115/* Flag: console code may call schedule() */
121static int console_may_schedule; 116static int console_may_schedule;
122 117
118#ifdef CONFIG_PRINTK
119
120static char __log_buf[__LOG_BUF_LEN];
121static char *log_buf = __log_buf;
122static int log_buf_len = __LOG_BUF_LEN;
123static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
124
123/* 125/*
124 * Setup a list of consoles. Called from init/main.c 126 * Setup a list of consoles. Called from init/main.c
125 */ 127 */
@@ -535,6 +537,7 @@ __setup("time", printk_time_setup);
535 * then changes console_loglevel may break. This is because console_loglevel 537 * then changes console_loglevel may break. This is because console_loglevel
536 * is inspected when the actual printing occurs. 538 * is inspected when the actual printing occurs.
537 */ 539 */
540
538asmlinkage int printk(const char *fmt, ...) 541asmlinkage int printk(const char *fmt, ...)
539{ 542{
540 va_list args; 543 va_list args;
@@ -655,6 +658,18 @@ out:
655EXPORT_SYMBOL(printk); 658EXPORT_SYMBOL(printk);
656EXPORT_SYMBOL(vprintk); 659EXPORT_SYMBOL(vprintk);
657 660
661#else
662
663asmlinkage long sys_syslog(int type, char __user * buf, int len)
664{
665 return 0;
666}
667
668int do_syslog(int type, char __user * buf, int len) { return 0; }
669static void call_console_drivers(unsigned long start, unsigned long end) {}
670
671#endif
672
658/** 673/**
659 * acquire_console_sem - lock the console system for exclusive use. 674 * acquire_console_sem - lock the console system for exclusive use.
660 * 675 *
@@ -931,7 +946,7 @@ int unregister_console(struct console * console)
931 return res; 946 return res;
932} 947}
933EXPORT_SYMBOL(unregister_console); 948EXPORT_SYMBOL(unregister_console);
934 949
935/** 950/**
936 * tty_write_message - write a message to a certain tty, not just the console. 951 * tty_write_message - write a message to a certain tty, not just the console.
937 * 952 *
diff --git a/kernel/profile.c b/kernel/profile.c
index a38fa70075fe..0221a50ca867 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -184,7 +184,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
184 WARN_ON(hook != timer_hook); 184 WARN_ON(hook != timer_hook);
185 timer_hook = NULL; 185 timer_hook = NULL;
186 /* make sure all CPUs see the NULL hook */ 186 /* make sure all CPUs see the NULL hook */
187 synchronize_kernel(); 187 synchronize_sched(); /* Allow ongoing interrupts to complete. */
188} 188}
189 189
190EXPORT_SYMBOL_GPL(register_timer_hook); 190EXPORT_SYMBOL_GPL(register_timer_hook);
@@ -522,7 +522,7 @@ static int __init create_hash_tables(void)
522 return 0; 522 return 0;
523out_cleanup: 523out_cleanup:
524 prof_on = 0; 524 prof_on = 0;
525 mb(); 525 smp_mb();
526 on_each_cpu(profile_nop, NULL, 0, 1); 526 on_each_cpu(profile_nop, NULL, 0, 1);
527 for_each_online_cpu(cpu) { 527 for_each_online_cpu(cpu) {
528 struct page *page; 528 struct page *page;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 88b306c4e841..8dcb8f6288bc 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -16,6 +16,7 @@
16#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/signal.h>
19 20
20#include <asm/pgtable.h> 21#include <asm/pgtable.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
@@ -135,7 +136,7 @@ int ptrace_attach(struct task_struct *task)
135 (current->gid != task->sgid) || 136 (current->gid != task->sgid) ||
136 (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) 137 (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE))
137 goto bad; 138 goto bad;
138 rmb(); 139 smp_rmb();
139 if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) 140 if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE))
140 goto bad; 141 goto bad;
141 /* the same process cannot be attached many times */ 142 /* the same process cannot be attached many times */
@@ -166,7 +167,7 @@ bad:
166 167
167int ptrace_detach(struct task_struct *child, unsigned int data) 168int ptrace_detach(struct task_struct *child, unsigned int data)
168{ 169{
169 if ((unsigned long) data > _NSIG) 170 if (!valid_signal(data))
170 return -EIO; 171 return -EIO;
171 172
172 /* Architecture-specific hardware disable .. */ 173 /* Architecture-specific hardware disable .. */
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index d00eded75d71..f436993bd590 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -444,15 +444,18 @@ static void wakeme_after_rcu(struct rcu_head *head)
444} 444}
445 445
446/** 446/**
447 * synchronize_kernel - wait until a grace period has elapsed. 447 * synchronize_rcu - wait until a grace period has elapsed.
448 * 448 *
449 * Control will return to the caller some time after a full grace 449 * Control will return to the caller some time after a full grace
450 * period has elapsed, in other words after all currently executing RCU 450 * period has elapsed, in other words after all currently executing RCU
451 * read-side critical sections have completed. RCU read-side critical 451 * read-side critical sections have completed. RCU read-side critical
452 * sections are delimited by rcu_read_lock() and rcu_read_unlock(), 452 * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
453 * and may be nested. 453 * and may be nested.
454 *
455 * If your read-side code is not protected by rcu_read_lock(), do -not-
456 * use synchronize_rcu().
454 */ 457 */
455void synchronize_kernel(void) 458void synchronize_rcu(void)
456{ 459{
457 struct rcu_synchronize rcu; 460 struct rcu_synchronize rcu;
458 461
@@ -464,7 +467,16 @@ void synchronize_kernel(void)
464 wait_for_completion(&rcu.completion); 467 wait_for_completion(&rcu.completion);
465} 468}
466 469
470/*
471 * Deprecated, use synchronize_rcu() or synchronize_sched() instead.
472 */
473void synchronize_kernel(void)
474{
475 synchronize_rcu();
476}
477
467module_param(maxbatch, int, 0); 478module_param(maxbatch, int, 0);
468EXPORT_SYMBOL_GPL(call_rcu); 479EXPORT_SYMBOL(call_rcu); /* WARNING: GPL-only in April 2006. */
469EXPORT_SYMBOL_GPL(call_rcu_bh); 480EXPORT_SYMBOL(call_rcu_bh); /* WARNING: GPL-only in April 2006. */
470EXPORT_SYMBOL_GPL(synchronize_kernel); 481EXPORT_SYMBOL_GPL(synchronize_rcu);
482EXPORT_SYMBOL(synchronize_kernel); /* WARNING: GPL-only in April 2006. */
diff --git a/kernel/sched.c b/kernel/sched.c
index 9bb7489ee645..0dc3158667a2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2906,6 +2906,7 @@ static void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
2906 * @q: the waitqueue 2906 * @q: the waitqueue
2907 * @mode: which threads 2907 * @mode: which threads
2908 * @nr_exclusive: how many wake-one or wake-many threads to wake up 2908 * @nr_exclusive: how many wake-one or wake-many threads to wake up
2909 * @key: is directly passed to the wakeup function
2909 */ 2910 */
2910void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode, 2911void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode,
2911 int nr_exclusive, void *key) 2912 int nr_exclusive, void *key)
@@ -2928,7 +2929,7 @@ void fastcall __wake_up_locked(wait_queue_head_t *q, unsigned int mode)
2928} 2929}
2929 2930
2930/** 2931/**
2931 * __wake_up - sync- wake up threads blocked on a waitqueue. 2932 * __wake_up_sync - wake up threads blocked on a waitqueue.
2932 * @q: the waitqueue 2933 * @q: the waitqueue
2933 * @mode: which threads 2934 * @mode: which threads
2934 * @nr_exclusive: how many wake-one or wake-many threads to wake up 2935 * @nr_exclusive: how many wake-one or wake-many threads to wake up
@@ -3223,6 +3224,19 @@ out_unlock:
3223 3224
3224EXPORT_SYMBOL(set_user_nice); 3225EXPORT_SYMBOL(set_user_nice);
3225 3226
3227/*
3228 * can_nice - check if a task can reduce its nice value
3229 * @p: task
3230 * @nice: nice value
3231 */
3232int can_nice(const task_t *p, const int nice)
3233{
3234 /* convert nice value [19,-20] to rlimit style value [0,39] */
3235 int nice_rlim = 19 - nice;
3236 return (nice_rlim <= p->signal->rlim[RLIMIT_NICE].rlim_cur ||
3237 capable(CAP_SYS_NICE));
3238}
3239
3226#ifdef __ARCH_WANT_SYS_NICE 3240#ifdef __ARCH_WANT_SYS_NICE
3227 3241
3228/* 3242/*
@@ -3242,12 +3256,8 @@ asmlinkage long sys_nice(int increment)
3242 * We don't have to worry. Conceptually one call occurs first 3256 * We don't have to worry. Conceptually one call occurs first
3243 * and we have a single winner. 3257 * and we have a single winner.
3244 */ 3258 */
3245 if (increment < 0) { 3259 if (increment < -40)
3246 if (!capable(CAP_SYS_NICE)) 3260 increment = -40;
3247 return -EPERM;
3248 if (increment < -40)
3249 increment = -40;
3250 }
3251 if (increment > 40) 3261 if (increment > 40)
3252 increment = 40; 3262 increment = 40;
3253 3263
@@ -3257,6 +3267,9 @@ asmlinkage long sys_nice(int increment)
3257 if (nice > 19) 3267 if (nice > 19)
3258 nice = 19; 3268 nice = 19;
3259 3269
3270 if (increment < 0 && !can_nice(current, nice))
3271 return -EPERM;
3272
3260 retval = security_task_setnice(current, nice); 3273 retval = security_task_setnice(current, nice);
3261 if (retval) 3274 if (retval)
3262 return retval; 3275 return retval;
@@ -3372,6 +3385,7 @@ recheck:
3372 return -EINVAL; 3385 return -EINVAL;
3373 3386
3374 if ((policy == SCHED_FIFO || policy == SCHED_RR) && 3387 if ((policy == SCHED_FIFO || policy == SCHED_RR) &&
3388 param->sched_priority > p->signal->rlim[RLIMIT_RTPRIO].rlim_cur &&
3375 !capable(CAP_SYS_NICE)) 3389 !capable(CAP_SYS_NICE))
3376 return -EPERM; 3390 return -EPERM;
3377 if ((current->euid != p->euid) && (current->euid != p->uid) && 3391 if ((current->euid != p->euid) && (current->euid != p->uid) &&
diff --git a/kernel/signal.c b/kernel/signal.c
index e6567d7f2b62..8f3debc77c5b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/syscalls.h> 23#include <linux/syscalls.h>
24#include <linux/ptrace.h> 24#include <linux/ptrace.h>
25#include <linux/posix-timers.h> 25#include <linux/posix-timers.h>
26#include <linux/signal.h>
26#include <asm/param.h> 27#include <asm/param.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <asm/unistd.h> 29#include <asm/unistd.h>
@@ -646,7 +647,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
646 struct task_struct *t) 647 struct task_struct *t)
647{ 648{
648 int error = -EINVAL; 649 int error = -EINVAL;
649 if (sig < 0 || sig > _NSIG) 650 if (!valid_signal(sig))
650 return error; 651 return error;
651 error = -EPERM; 652 error = -EPERM;
652 if ((!info || ((unsigned long)info != 1 && 653 if ((!info || ((unsigned long)info != 1 &&
@@ -1245,7 +1246,7 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
1245 * Make sure legacy kernel users don't send in bad values 1246 * Make sure legacy kernel users don't send in bad values
1246 * (normal paths check this in check_kill_permission). 1247 * (normal paths check this in check_kill_permission).
1247 */ 1248 */
1248 if (sig < 0 || sig > _NSIG) 1249 if (!valid_signal(sig))
1249 return -EINVAL; 1250 return -EINVAL;
1250 1251
1251 /* 1252 /*
@@ -1520,7 +1521,7 @@ void do_notify_parent(struct task_struct *tsk, int sig)
1520 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) 1521 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN)
1521 sig = 0; 1522 sig = 0;
1522 } 1523 }
1523 if (sig > 0 && sig <= _NSIG) 1524 if (valid_signal(sig) && sig > 0)
1524 __group_send_sig_info(sig, &info, tsk->parent); 1525 __group_send_sig_info(sig, &info, tsk->parent);
1525 __wake_up_parent(tsk, tsk->parent); 1526 __wake_up_parent(tsk, tsk->parent);
1526 spin_unlock_irqrestore(&psig->siglock, flags); 1527 spin_unlock_irqrestore(&psig->siglock, flags);
@@ -2364,7 +2365,7 @@ do_sigaction(int sig, const struct k_sigaction *act, struct k_sigaction *oact)
2364{ 2365{
2365 struct k_sigaction *k; 2366 struct k_sigaction *k;
2366 2367
2367 if (sig < 1 || sig > _NSIG || (act && sig_kernel_only(sig))) 2368 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
2368 return -EINVAL; 2369 return -EINVAL;
2369 2370
2370 k = &current->sighand->action[sig-1]; 2371 k = &current->sighand->action[sig-1];
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index c39ed70af174..6116b25aa7cf 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -33,7 +33,7 @@ static int stopmachine(void *cpu)
33 set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); 33 set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu));
34 34
35 /* Ack: we are alive */ 35 /* Ack: we are alive */
36 mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ 36 smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */
37 atomic_inc(&stopmachine_thread_ack); 37 atomic_inc(&stopmachine_thread_ack);
38 38
39 /* Simple state machine */ 39 /* Simple state machine */
@@ -43,14 +43,14 @@ static int stopmachine(void *cpu)
43 local_irq_disable(); 43 local_irq_disable();
44 irqs_disabled = 1; 44 irqs_disabled = 1;
45 /* Ack: irqs disabled. */ 45 /* Ack: irqs disabled. */
46 mb(); /* Must read state first. */ 46 smp_mb(); /* Must read state first. */
47 atomic_inc(&stopmachine_thread_ack); 47 atomic_inc(&stopmachine_thread_ack);
48 } else if (stopmachine_state == STOPMACHINE_PREPARE 48 } else if (stopmachine_state == STOPMACHINE_PREPARE
49 && !prepared) { 49 && !prepared) {
50 /* Everyone is in place, hold CPU. */ 50 /* Everyone is in place, hold CPU. */
51 preempt_disable(); 51 preempt_disable();
52 prepared = 1; 52 prepared = 1;
53 mb(); /* Must read state first. */ 53 smp_mb(); /* Must read state first. */
54 atomic_inc(&stopmachine_thread_ack); 54 atomic_inc(&stopmachine_thread_ack);
55 } 55 }
56 /* Yield in first stage: migration threads need to 56 /* Yield in first stage: migration threads need to
@@ -62,7 +62,7 @@ static int stopmachine(void *cpu)
62 } 62 }
63 63
64 /* Ack: we are exiting. */ 64 /* Ack: we are exiting. */
65 mb(); /* Must read state first. */ 65 smp_mb(); /* Must read state first. */
66 atomic_inc(&stopmachine_thread_ack); 66 atomic_inc(&stopmachine_thread_ack);
67 67
68 if (irqs_disabled) 68 if (irqs_disabled)
@@ -77,7 +77,7 @@ static int stopmachine(void *cpu)
77static void stopmachine_set_state(enum stopmachine_state state) 77static void stopmachine_set_state(enum stopmachine_state state)
78{ 78{
79 atomic_set(&stopmachine_thread_ack, 0); 79 atomic_set(&stopmachine_thread_ack, 0);
80 wmb(); 80 smp_wmb();
81 stopmachine_state = state; 81 stopmachine_state = state;
82 while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) 82 while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads)
83 cpu_relax(); 83 cpu_relax();
diff --git a/kernel/sys.c b/kernel/sys.c
index 462d78d55895..f006632c2ba7 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -25,6 +25,7 @@
25#include <linux/dcookies.h> 25#include <linux/dcookies.h>
26#include <linux/suspend.h> 26#include <linux/suspend.h>
27#include <linux/tty.h> 27#include <linux/tty.h>
28#include <linux/signal.h>
28 29
29#include <linux/compat.h> 30#include <linux/compat.h>
30#include <linux/syscalls.h> 31#include <linux/syscalls.h>
@@ -227,7 +228,7 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
227 error = -EPERM; 228 error = -EPERM;
228 goto out; 229 goto out;
229 } 230 }
230 if (niceval < task_nice(p) && !capable(CAP_SYS_NICE)) { 231 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
231 error = -EACCES; 232 error = -EACCES;
232 goto out; 233 goto out;
233 } 234 }
@@ -525,7 +526,7 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid)
525 if (new_egid != old_egid) 526 if (new_egid != old_egid)
526 { 527 {
527 current->mm->dumpable = 0; 528 current->mm->dumpable = 0;
528 wmb(); 529 smp_wmb();
529 } 530 }
530 if (rgid != (gid_t) -1 || 531 if (rgid != (gid_t) -1 ||
531 (egid != (gid_t) -1 && egid != old_rgid)) 532 (egid != (gid_t) -1 && egid != old_rgid))
@@ -556,7 +557,7 @@ asmlinkage long sys_setgid(gid_t gid)
556 if(old_egid != gid) 557 if(old_egid != gid)
557 { 558 {
558 current->mm->dumpable=0; 559 current->mm->dumpable=0;
559 wmb(); 560 smp_wmb();
560 } 561 }
561 current->gid = current->egid = current->sgid = current->fsgid = gid; 562 current->gid = current->egid = current->sgid = current->fsgid = gid;
562 } 563 }
@@ -565,7 +566,7 @@ asmlinkage long sys_setgid(gid_t gid)
565 if(old_egid != gid) 566 if(old_egid != gid)
566 { 567 {
567 current->mm->dumpable=0; 568 current->mm->dumpable=0;
568 wmb(); 569 smp_wmb();
569 } 570 }
570 current->egid = current->fsgid = gid; 571 current->egid = current->fsgid = gid;
571 } 572 }
@@ -596,7 +597,7 @@ static int set_user(uid_t new_ruid, int dumpclear)
596 if(dumpclear) 597 if(dumpclear)
597 { 598 {
598 current->mm->dumpable = 0; 599 current->mm->dumpable = 0;
599 wmb(); 600 smp_wmb();
600 } 601 }
601 current->uid = new_ruid; 602 current->uid = new_ruid;
602 return 0; 603 return 0;
@@ -653,7 +654,7 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
653 if (new_euid != old_euid) 654 if (new_euid != old_euid)
654 { 655 {
655 current->mm->dumpable=0; 656 current->mm->dumpable=0;
656 wmb(); 657 smp_wmb();
657 } 658 }
658 current->fsuid = current->euid = new_euid; 659 current->fsuid = current->euid = new_euid;
659 if (ruid != (uid_t) -1 || 660 if (ruid != (uid_t) -1 ||
@@ -703,7 +704,7 @@ asmlinkage long sys_setuid(uid_t uid)
703 if (old_euid != uid) 704 if (old_euid != uid)
704 { 705 {
705 current->mm->dumpable = 0; 706 current->mm->dumpable = 0;
706 wmb(); 707 smp_wmb();
707 } 708 }
708 current->fsuid = current->euid = uid; 709 current->fsuid = current->euid = uid;
709 current->suid = new_suid; 710 current->suid = new_suid;
@@ -748,7 +749,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
748 if (euid != current->euid) 749 if (euid != current->euid)
749 { 750 {
750 current->mm->dumpable = 0; 751 current->mm->dumpable = 0;
751 wmb(); 752 smp_wmb();
752 } 753 }
753 current->euid = euid; 754 current->euid = euid;
754 } 755 }
@@ -798,7 +799,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
798 if (egid != current->egid) 799 if (egid != current->egid)
799 { 800 {
800 current->mm->dumpable = 0; 801 current->mm->dumpable = 0;
801 wmb(); 802 smp_wmb();
802 } 803 }
803 current->egid = egid; 804 current->egid = egid;
804 } 805 }
@@ -845,7 +846,7 @@ asmlinkage long sys_setfsuid(uid_t uid)
845 if (uid != old_fsuid) 846 if (uid != old_fsuid)
846 { 847 {
847 current->mm->dumpable = 0; 848 current->mm->dumpable = 0;
848 wmb(); 849 smp_wmb();
849 } 850 }
850 current->fsuid = uid; 851 current->fsuid = uid;
851 } 852 }
@@ -875,7 +876,7 @@ asmlinkage long sys_setfsgid(gid_t gid)
875 if (gid != old_fsgid) 876 if (gid != old_fsgid)
876 { 877 {
877 current->mm->dumpable = 0; 878 current->mm->dumpable = 0;
878 wmb(); 879 smp_wmb();
879 } 880 }
880 current->fsgid = gid; 881 current->fsgid = gid;
881 key_fsgid_changed(current); 882 key_fsgid_changed(current);
@@ -1194,7 +1195,7 @@ static int groups_from_user(struct group_info *group_info,
1194 return 0; 1195 return 0;
1195} 1196}
1196 1197
1197/* a simple shell-metzner sort */ 1198/* a simple Shell sort */
1198static void groups_sort(struct group_info *group_info) 1199static void groups_sort(struct group_info *group_info)
1199{ 1200{
1200 int base, max, stride; 1201 int base, max, stride;
@@ -1637,7 +1638,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
1637 switch (option) { 1638 switch (option) {
1638 case PR_SET_PDEATHSIG: 1639 case PR_SET_PDEATHSIG:
1639 sig = arg2; 1640 sig = arg2;
1640 if (sig < 0 || sig > _NSIG) { 1641 if (!valid_signal(sig)) {
1641 error = -EINVAL; 1642 error = -EINVAL;
1642 break; 1643 break;
1643 } 1644 }
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 1802a311dd3f..0dda70ed1f98 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -52,6 +52,7 @@ cond_syscall(sys_msgsnd);
52cond_syscall(sys_msgrcv); 52cond_syscall(sys_msgrcv);
53cond_syscall(sys_msgctl); 53cond_syscall(sys_msgctl);
54cond_syscall(sys_shmget); 54cond_syscall(sys_shmget);
55cond_syscall(sys_shmat);
55cond_syscall(sys_shmdt); 56cond_syscall(sys_shmdt);
56cond_syscall(sys_shmctl); 57cond_syscall(sys_shmctl);
57cond_syscall(sys_mq_open); 58cond_syscall(sys_mq_open);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 79dbd93bd697..701d12c63068 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1991,6 +1991,8 @@ int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
1991 * @filp: the file structure 1991 * @filp: the file structure
1992 * @buffer: the user buffer 1992 * @buffer: the user buffer
1993 * @lenp: the size of the user buffer 1993 * @lenp: the size of the user buffer
1994 * @ppos: file position
1995 * @ppos: the current position in the file
1994 * 1996 *
1995 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 1997 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1996 * values from/to the user buffer, treated as an ASCII string. 1998 * values from/to the user buffer, treated as an ASCII string.
diff --git a/kernel/time.c b/kernel/time.c
index 96fd0f499631..d4335c1c884c 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -516,14 +516,6 @@ int do_settimeofday (struct timespec *tv)
516 516
517 write_seqlock_irq(&xtime_lock); 517 write_seqlock_irq(&xtime_lock);
518 { 518 {
519 /*
520 * This is revolting. We need to set "xtime" correctly. However, the value
521 * in this location is the value at the most recent update of wall time.
522 * Discover what correction gettimeofday would have done, and then undo
523 * it!
524 */
525 nsec -= time_interpolator_get_offset();
526
527 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); 519 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
528 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); 520 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
529 521
diff --git a/kernel/timer.c b/kernel/timer.c
index ecb3d67c0e14..207aa4f0aa10 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1007,7 +1007,7 @@ asmlinkage long sys_getppid(void)
1007 * Make sure we read the pid before re-reading the 1007 * Make sure we read the pid before re-reading the
1008 * parent pointer: 1008 * parent pointer:
1009 */ 1009 */
1010 rmb(); 1010 smp_rmb();
1011 parent = me->group_leader->real_parent; 1011 parent = me->group_leader->real_parent;
1012 if (old != parent) 1012 if (old != parent)
1013 continue; 1013 continue;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 426a0cf7b11c..ac23847ce0e3 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -108,6 +108,7 @@ config DEBUG_HIGHMEM
108 108
109config DEBUG_BUGVERBOSE 109config DEBUG_BUGVERBOSE
110 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED 110 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
111 depends on BUG
111 depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || (X86 && !X86_64) || FRV 112 depends on ARM || ARM26 || M32R || M68K || SPARC32 || SPARC64 || (X86 && !X86_64) || FRV
112 default !EMBEDDED 113 default !EMBEDDED
113 help 114 help
diff --git a/lib/kobject.c b/lib/kobject.c
index 5df8441c44e7..94048826624c 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -216,13 +216,12 @@ int kobject_register(struct kobject * kobj)
216/** 216/**
217 * kobject_set_name - Set the name of an object 217 * kobject_set_name - Set the name of an object
218 * @kobj: object. 218 * @kobj: object.
219 * @name: name. 219 * @fmt: format string used to build the name
220 * 220 *
221 * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated 221 * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated
222 * string that @kobj->k_name points to. Otherwise, use the static 222 * string that @kobj->k_name points to. Otherwise, use the static
223 * @kobj->name array. 223 * @kobj->name array.
224 */ 224 */
225
226int kobject_set_name(struct kobject * kobj, const char * fmt, ...) 225int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
227{ 226{
228 int error = 0; 227 int error = 0;
diff --git a/lib/rwsem-spinlock.c b/lib/rwsem-spinlock.c
index 21f0db2c9711..40ffde940a86 100644
--- a/lib/rwsem-spinlock.c
+++ b/lib/rwsem-spinlock.c
@@ -76,7 +76,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, int wakewrite)
76 list_del(&waiter->list); 76 list_del(&waiter->list);
77 tsk = waiter->task; 77 tsk = waiter->task;
78 /* Don't touch waiter after ->task has been NULLed */ 78 /* Don't touch waiter after ->task has been NULLed */
79 mb(); 79 smp_mb();
80 waiter->task = NULL; 80 waiter->task = NULL;
81 wake_up_process(tsk); 81 wake_up_process(tsk);
82 put_task_struct(tsk); 82 put_task_struct(tsk);
@@ -91,7 +91,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, int wakewrite)
91 91
92 list_del(&waiter->list); 92 list_del(&waiter->list);
93 tsk = waiter->task; 93 tsk = waiter->task;
94 mb(); 94 smp_mb();
95 waiter->task = NULL; 95 waiter->task = NULL;
96 wake_up_process(tsk); 96 wake_up_process(tsk);
97 put_task_struct(tsk); 97 put_task_struct(tsk);
@@ -123,7 +123,7 @@ __rwsem_wake_one_writer(struct rw_semaphore *sem)
123 list_del(&waiter->list); 123 list_del(&waiter->list);
124 124
125 tsk = waiter->task; 125 tsk = waiter->task;
126 mb(); 126 smp_mb();
127 waiter->task = NULL; 127 waiter->task = NULL;
128 wake_up_process(tsk); 128 wake_up_process(tsk);
129 put_task_struct(tsk); 129 put_task_struct(tsk);
diff --git a/lib/rwsem.c b/lib/rwsem.c
index 7644089ec8fa..62fa4eba9ffe 100644
--- a/lib/rwsem.c
+++ b/lib/rwsem.c
@@ -74,7 +74,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, int downgrading)
74 */ 74 */
75 list_del(&waiter->list); 75 list_del(&waiter->list);
76 tsk = waiter->task; 76 tsk = waiter->task;
77 mb(); 77 smp_mb();
78 waiter->task = NULL; 78 waiter->task = NULL;
79 wake_up_process(tsk); 79 wake_up_process(tsk);
80 put_task_struct(tsk); 80 put_task_struct(tsk);
@@ -117,7 +117,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, int downgrading)
117 waiter = list_entry(next, struct rwsem_waiter, list); 117 waiter = list_entry(next, struct rwsem_waiter, list);
118 next = waiter->list.next; 118 next = waiter->list.next;
119 tsk = waiter->task; 119 tsk = waiter->task;
120 mb(); 120 smp_mb();
121 waiter->task = NULL; 121 waiter->task = NULL;
122 wake_up_process(tsk); 122 wake_up_process(tsk);
123 put_task_struct(tsk); 123 put_task_struct(tsk);
diff --git a/lib/sort.c b/lib/sort.c
index ea3caedeabdb..b73dbb0e7c83 100644
--- a/lib/sort.c
+++ b/lib/sort.c
@@ -90,7 +90,7 @@ int cmpint(const void *a, const void *b)
90 90
91static int sort_test(void) 91static int sort_test(void)
92{ 92{
93 int *a, i, r = 0; 93 int *a, i, r = 1;
94 94
95 a = kmalloc(1000 * sizeof(int), GFP_KERNEL); 95 a = kmalloc(1000 * sizeof(int), GFP_KERNEL);
96 BUG_ON(!a); 96 BUG_ON(!a);
diff --git a/lib/string.c b/lib/string.c
index 4bb93ad23c60..d886ef157c12 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -65,6 +65,7 @@ EXPORT_SYMBOL(strnicmp);
65 * @dest: Where to copy the string to 65 * @dest: Where to copy the string to
66 * @src: Where to copy the string from 66 * @src: Where to copy the string from
67 */ 67 */
68#undef strcpy
68char * strcpy(char * dest,const char *src) 69char * strcpy(char * dest,const char *src)
69{ 70{
70 char *tmp = dest; 71 char *tmp = dest;
@@ -85,6 +86,10 @@ EXPORT_SYMBOL(strcpy);
85 * 86 *
86 * The result is not %NUL-terminated if the source exceeds 87 * The result is not %NUL-terminated if the source exceeds
87 * @count bytes. 88 * @count bytes.
89 *
90 * In the case where the length of @src is less than that of
91 * count, the remainder of @dest will be padded with %NUL.
92 *
88 */ 93 */
89char * strncpy(char * dest,const char *src,size_t count) 94char * strncpy(char * dest,const char *src,size_t count)
90{ 95{
@@ -132,6 +137,7 @@ EXPORT_SYMBOL(strlcpy);
132 * @dest: The string to be appended to 137 * @dest: The string to be appended to
133 * @src: The string to append to it 138 * @src: The string to append to it
134 */ 139 */
140#undef strcat
135char * strcat(char * dest, const char * src) 141char * strcat(char * dest, const char * src)
136{ 142{
137 char *tmp = dest; 143 char *tmp = dest;
@@ -209,6 +215,7 @@ EXPORT_SYMBOL(strlcat);
209 * @cs: One string 215 * @cs: One string
210 * @ct: Another string 216 * @ct: Another string
211 */ 217 */
218#undef strcmp
212int strcmp(const char * cs,const char * ct) 219int strcmp(const char * cs,const char * ct)
213{ 220{
214 register signed char __res; 221 register signed char __res;
@@ -514,6 +521,7 @@ EXPORT_SYMBOL(memmove);
514 * @ct: Another area of memory 521 * @ct: Another area of memory
515 * @count: The size of the area. 522 * @count: The size of the area.
516 */ 523 */
524#undef memcmp
517int memcmp(const void * cs,const void * ct,size_t count) 525int memcmp(const void * cs,const void * ct,size_t count)
518{ 526{
519 const unsigned char *su1, *su2; 527 const unsigned char *su1, *su2;
diff --git a/mm/filemap.c b/mm/filemap.c
index 93595c327bbd..47263ac3e4ea 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -29,11 +29,6 @@
29#include <linux/security.h> 29#include <linux/security.h>
30#include <linux/syscalls.h> 30#include <linux/syscalls.h>
31/* 31/*
32 * This is needed for the following functions:
33 * - try_to_release_page
34 * - block_invalidatepage
35 * - generic_osync_inode
36 *
37 * FIXME: remove all knowledge of the buffer layer from the core VM 32 * FIXME: remove all knowledge of the buffer layer from the core VM
38 */ 33 */
39#include <linux/buffer_head.h> /* for generic_osync_inode */ 34#include <linux/buffer_head.h> /* for generic_osync_inode */
@@ -123,8 +118,7 @@ void remove_from_page_cache(struct page *page)
123{ 118{
124 struct address_space *mapping = page->mapping; 119 struct address_space *mapping = page->mapping;
125 120
126 if (unlikely(!PageLocked(page))) 121 BUG_ON(!PageLocked(page));
127 PAGE_BUG(page);
128 122
129 write_lock_irq(&mapping->tree_lock); 123 write_lock_irq(&mapping->tree_lock);
130 __remove_from_page_cache(page); 124 __remove_from_page_cache(page);
@@ -139,7 +133,25 @@ static int sync_page(void *word)
139 page = container_of((page_flags_t *)word, struct page, flags); 133 page = container_of((page_flags_t *)word, struct page, flags);
140 134
141 /* 135 /*
142 * FIXME, fercrissake. What is this barrier here for? 136 * page_mapping() is being called without PG_locked held.
137 * Some knowledge of the state and use of the page is used to
138 * reduce the requirements down to a memory barrier.
139 * The danger here is of a stale page_mapping() return value
140 * indicating a struct address_space different from the one it's
141 * associated with when it is associated with one.
142 * After smp_mb(), it's either the correct page_mapping() for
143 * the page, or an old page_mapping() and the page's own
144 * page_mapping() has gone NULL.
145 * The ->sync_page() address_space operation must tolerate
146 * page_mapping() going NULL. By an amazing coincidence,
147 * this comes about because none of the users of the page
148 * in the ->sync_page() methods make essential use of the
149 * page_mapping(), merely passing the page down to the backing
150 * device's unplug functions when it's non-NULL, which in turn
151 * ignore it for all cases but swap, where only page->private is
152 * of interest. When page_mapping() does go NULL, the entire
153 * call stack gracefully ignores the page and returns.
154 * -- wli
143 */ 155 */
144 smp_mb(); 156 smp_mb();
145 mapping = page_mapping(page); 157 mapping = page_mapping(page);
@@ -152,9 +164,10 @@ static int sync_page(void *word)
152/** 164/**
153 * filemap_fdatawrite_range - start writeback against all of a mapping's 165 * filemap_fdatawrite_range - start writeback against all of a mapping's
154 * dirty pages that lie within the byte offsets <start, end> 166 * dirty pages that lie within the byte offsets <start, end>
155 * @mapping: address space structure to write 167 * @mapping: address space structure to write
156 * @start: offset in bytes where the range starts 168 * @start: offset in bytes where the range starts
157 * @end : offset in bytes where the range ends 169 * @end: offset in bytes where the range ends
170 * @sync_mode: enable synchronous operation
158 * 171 *
159 * If sync_mode is WB_SYNC_ALL then this is a "data integrity" operation, as 172 * If sync_mode is WB_SYNC_ALL then this is a "data integrity" operation, as
160 * opposed to a regular memory * cleansing writeback. The difference between 173 * opposed to a regular memory * cleansing writeback. The difference between
@@ -518,8 +531,8 @@ EXPORT_SYMBOL(find_trylock_page);
518/** 531/**
519 * find_lock_page - locate, pin and lock a pagecache page 532 * find_lock_page - locate, pin and lock a pagecache page
520 * 533 *
521 * @mapping - the address_space to search 534 * @mapping: the address_space to search
522 * @offset - the page index 535 * @offset: the page index
523 * 536 *
524 * Locates the desired pagecache page, locks it, increments its reference 537 * Locates the desired pagecache page, locks it, increments its reference
525 * count and returns its address. 538 * count and returns its address.
@@ -558,9 +571,9 @@ EXPORT_SYMBOL(find_lock_page);
558/** 571/**
559 * find_or_create_page - locate or add a pagecache page 572 * find_or_create_page - locate or add a pagecache page
560 * 573 *
561 * @mapping - the page's address_space 574 * @mapping: the page's address_space
562 * @index - the page's index into the mapping 575 * @index: the page's index into the mapping
563 * @gfp_mask - page allocation mode 576 * @gfp_mask: page allocation mode
564 * 577 *
565 * Locates a page in the pagecache. If the page is not present, a new page 578 * Locates a page in the pagecache. If the page is not present, a new page
566 * is allocated using @gfp_mask and is added to the pagecache and to the VM's 579 * is allocated using @gfp_mask and is added to the pagecache and to the VM's
@@ -1949,7 +1962,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
1949 buf = iov->iov_base + written; 1962 buf = iov->iov_base + written;
1950 else { 1963 else {
1951 filemap_set_next_iovec(&cur_iov, &iov_base, written); 1964 filemap_set_next_iovec(&cur_iov, &iov_base, written);
1952 buf = iov->iov_base + iov_base; 1965 buf = cur_iov->iov_base + iov_base;
1953 } 1966 }
1954 1967
1955 do { 1968 do {
@@ -2007,9 +2020,11 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2007 count -= status; 2020 count -= status;
2008 pos += status; 2021 pos += status;
2009 buf += status; 2022 buf += status;
2010 if (unlikely(nr_segs > 1)) 2023 if (unlikely(nr_segs > 1)) {
2011 filemap_set_next_iovec(&cur_iov, 2024 filemap_set_next_iovec(&cur_iov,
2012 &iov_base, status); 2025 &iov_base, status);
2026 buf = cur_iov->iov_base + iov_base;
2027 }
2013 } 2028 }
2014 } 2029 }
2015 if (unlikely(copied != bytes)) 2030 if (unlikely(copied != bytes))
diff --git a/mm/highmem.c b/mm/highmem.c
index d01276506b00..400911599468 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -325,6 +325,7 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool, int err)
325 continue; 325 continue;
326 326
327 mempool_free(bvec->bv_page, pool); 327 mempool_free(bvec->bv_page, pool);
328 dec_page_state(nr_bounce);
328 } 329 }
329 330
330 bio_endio(bio_orig, bio_orig->bi_size, err); 331 bio_endio(bio_orig, bio_orig->bi_size, err);
@@ -405,6 +406,7 @@ static void __blk_queue_bounce(request_queue_t *q, struct bio **bio_orig,
405 to->bv_page = mempool_alloc(pool, q->bounce_gfp); 406 to->bv_page = mempool_alloc(pool, q->bounce_gfp);
406 to->bv_len = from->bv_len; 407 to->bv_len = from->bv_len;
407 to->bv_offset = from->bv_offset; 408 to->bv_offset = from->bv_offset;
409 inc_page_state(nr_bounce);
408 410
409 if (rw == WRITE) { 411 if (rw == WRITE) {
410 char *vto, *vfrom; 412 char *vto, *vfrom;
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index a3b44a671cec..08c41da429cf 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -661,7 +661,7 @@ static struct zonelist *zonelist_policy(unsigned int __nocast gfp, struct mempol
661 case MPOL_BIND: 661 case MPOL_BIND:
662 /* Lower zones don't get a policy applied */ 662 /* Lower zones don't get a policy applied */
663 /* Careful: current->mems_allowed might have moved */ 663 /* Careful: current->mems_allowed might have moved */
664 if (gfp >= policy_zone) 664 if ((gfp & GFP_ZONEMASK) >= policy_zone)
665 if (cpuset_zonelist_valid_mems_allowed(policy->v.zonelist)) 665 if (cpuset_zonelist_valid_mems_allowed(policy->v.zonelist))
666 return policy->v.zonelist; 666 return policy->v.zonelist;
667 /*FALL THROUGH*/ 667 /*FALL THROUGH*/
diff --git a/mm/mempool.c b/mm/mempool.c
index b014ffeaa413..c9f3d4620428 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -198,31 +198,22 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
198 void *element; 198 void *element;
199 unsigned long flags; 199 unsigned long flags;
200 DEFINE_WAIT(wait); 200 DEFINE_WAIT(wait);
201 int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO); 201 int gfp_temp;
202 202
203 might_sleep_if(gfp_mask & __GFP_WAIT); 203 might_sleep_if(gfp_mask & __GFP_WAIT);
204
205 gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */
206 gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */
207 gfp_mask |= __GFP_NOWARN; /* failures are OK */
208
209 gfp_temp = gfp_mask & ~(__GFP_WAIT|__GFP_IO);
210
204repeat_alloc: 211repeat_alloc:
205 element = pool->alloc(gfp_nowait|__GFP_NOWARN, pool->pool_data); 212
213 element = pool->alloc(gfp_temp, pool->pool_data);
206 if (likely(element != NULL)) 214 if (likely(element != NULL))
207 return element; 215 return element;
208 216
209 /*
210 * If the pool is less than 50% full and we can perform effective
211 * page reclaim then try harder to allocate an element.
212 */
213 mb();
214 if ((gfp_mask & __GFP_FS) && (gfp_mask != gfp_nowait) &&
215 (pool->curr_nr <= pool->min_nr/2)) {
216 element = pool->alloc(gfp_mask, pool->pool_data);
217 if (likely(element != NULL))
218 return element;
219 }
220
221 /*
222 * Kick the VM at this point.
223 */
224 wakeup_bdflush(0);
225
226 spin_lock_irqsave(&pool->lock, flags); 217 spin_lock_irqsave(&pool->lock, flags);
227 if (likely(pool->curr_nr)) { 218 if (likely(pool->curr_nr)) {
228 element = remove_element(pool); 219 element = remove_element(pool);
@@ -235,8 +226,10 @@ repeat_alloc:
235 if (!(gfp_mask & __GFP_WAIT)) 226 if (!(gfp_mask & __GFP_WAIT))
236 return NULL; 227 return NULL;
237 228
229 /* Now start performing page reclaim */
230 gfp_temp = gfp_mask;
238 prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE); 231 prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
239 mb(); 232 smp_mb();
240 if (!pool->curr_nr) 233 if (!pool->curr_nr)
241 io_schedule(); 234 io_schedule();
242 finish_wait(&pool->wait, &wait); 235 finish_wait(&pool->wait, &wait);
@@ -257,7 +250,7 @@ void mempool_free(void *element, mempool_t *pool)
257{ 250{
258 unsigned long flags; 251 unsigned long flags;
259 252
260 mb(); 253 smp_mb();
261 if (pool->curr_nr < pool->min_nr) { 254 if (pool->curr_nr < pool->min_nr) {
262 spin_lock_irqsave(&pool->lock, flags); 255 spin_lock_irqsave(&pool->lock, flags);
263 if (pool->curr_nr < pool->min_nr) { 256 if (pool->curr_nr < pool->min_nr) {
diff --git a/mm/mmap.c b/mm/mmap.c
index 6ea204cc751e..01f9793591f6 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -937,9 +937,10 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
937 /* mlock MCL_FUTURE? */ 937 /* mlock MCL_FUTURE? */
938 if (vm_flags & VM_LOCKED) { 938 if (vm_flags & VM_LOCKED) {
939 unsigned long locked, lock_limit; 939 unsigned long locked, lock_limit;
940 locked = mm->locked_vm << PAGE_SHIFT; 940 locked = len >> PAGE_SHIFT;
941 locked += mm->locked_vm;
941 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; 942 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
942 locked += len; 943 lock_limit >>= PAGE_SHIFT;
943 if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 944 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
944 return -EAGAIN; 945 return -EAGAIN;
945 } 946 }
@@ -1009,8 +1010,7 @@ munmap_back:
1009 } 1010 }
1010 1011
1011 /* Check against address space limit. */ 1012 /* Check against address space limit. */
1012 if ((mm->total_vm << PAGE_SHIFT) + len 1013 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
1013 > current->signal->rlim[RLIMIT_AS].rlim_cur)
1014 return -ENOMEM; 1014 return -ENOMEM;
1015 1015
1016 if (accountable && (!(flags & MAP_NORESERVE) || 1016 if (accountable && (!(flags & MAP_NORESERVE) ||
@@ -1421,7 +1421,7 @@ static int acct_stack_growth(struct vm_area_struct * vma, unsigned long size, un
1421 struct rlimit *rlim = current->signal->rlim; 1421 struct rlimit *rlim = current->signal->rlim;
1422 1422
1423 /* address space limit tests */ 1423 /* address space limit tests */
1424 if (mm->total_vm + grow > rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT) 1424 if (!may_expand_vm(mm, grow))
1425 return -ENOMEM; 1425 return -ENOMEM;
1426 1426
1427 /* Stack limit test */ 1427 /* Stack limit test */
@@ -1823,9 +1823,10 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
1823 */ 1823 */
1824 if (mm->def_flags & VM_LOCKED) { 1824 if (mm->def_flags & VM_LOCKED) {
1825 unsigned long locked, lock_limit; 1825 unsigned long locked, lock_limit;
1826 locked = mm->locked_vm << PAGE_SHIFT; 1826 locked = len >> PAGE_SHIFT;
1827 locked += mm->locked_vm;
1827 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; 1828 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
1828 locked += len; 1829 lock_limit >>= PAGE_SHIFT;
1829 if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 1830 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
1830 return -EAGAIN; 1831 return -EAGAIN;
1831 } 1832 }
@@ -1848,8 +1849,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
1848 } 1849 }
1849 1850
1850 /* Check against address space limits *after* clearing old maps... */ 1851 /* Check against address space limits *after* clearing old maps... */
1851 if ((mm->total_vm << PAGE_SHIFT) + len 1852 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
1852 > current->signal->rlim[RLIMIT_AS].rlim_cur)
1853 return -ENOMEM; 1853 return -ENOMEM;
1854 1854
1855 if (mm->map_count > sysctl_max_map_count) 1855 if (mm->map_count > sysctl_max_map_count)
@@ -2019,3 +2019,19 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
2019 } 2019 }
2020 return new_vma; 2020 return new_vma;
2021} 2021}
2022
2023/*
2024 * Return true if the calling process may expand its vm space by the passed
2025 * number of pages
2026 */
2027int may_expand_vm(struct mm_struct *mm, unsigned long npages)
2028{
2029 unsigned long cur = mm->total_vm; /* pages */
2030 unsigned long lim;
2031
2032 lim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
2033
2034 if (cur + npages > lim)
2035 return 0;
2036 return 1;
2037}
diff --git a/mm/mremap.c b/mm/mremap.c
index 0d1c1b9c7a0a..0dd7ace94e51 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -347,10 +347,10 @@ unsigned long do_mremap(unsigned long addr,
347 if (locked > lock_limit && !capable(CAP_IPC_LOCK)) 347 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
348 goto out; 348 goto out;
349 } 349 }
350 ret = -ENOMEM; 350 if (!may_expand_vm(current->mm, (new_len - old_len) >> PAGE_SHIFT)) {
351 if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len) 351 ret = -ENOMEM;
352 > current->signal->rlim[RLIMIT_AS].rlim_cur)
353 goto out; 352 goto out;
353 }
354 354
355 if (vma->vm_flags & VM_ACCOUNT) { 355 if (vma->vm_flags & VM_ACCOUNT) {
356 charged = (new_len - old_len) >> PAGE_SHIFT; 356 charged = (new_len - old_len) >> PAGE_SHIFT;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 6ddd6a29c73b..613b99a55917 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -255,7 +255,7 @@ static void balance_dirty_pages(struct address_space *mapping)
255 255
256/** 256/**
257 * balance_dirty_pages_ratelimited - balance dirty memory state 257 * balance_dirty_pages_ratelimited - balance dirty memory state
258 * @mapping - address_space which was dirtied 258 * @mapping: address_space which was dirtied
259 * 259 *
260 * Processes which are dirtying memory should call in here once for each page 260 * Processes which are dirtying memory should call in here once for each page
261 * which was newly dirtied. The function will periodically check the system's 261 * which was newly dirtied. The function will periodically check the system's
@@ -562,8 +562,8 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
562/** 562/**
563 * write_one_page - write out a single page and optionally wait on I/O 563 * write_one_page - write out a single page and optionally wait on I/O
564 * 564 *
565 * @page - the page to write 565 * @page: the page to write
566 * @wait - if true, wait on writeout 566 * @wait: if true, wait on writeout
567 * 567 *
568 * The page must be locked by the caller and will be unlocked upon return. 568 * The page must be locked by the caller and will be unlocked upon return.
569 * 569 *
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c73dbbc1cd8f..b1061b1962f8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -43,7 +43,9 @@
43 * initializer cleaner 43 * initializer cleaner
44 */ 44 */
45nodemask_t node_online_map = { { [0] = 1UL } }; 45nodemask_t node_online_map = { { [0] = 1UL } };
46EXPORT_SYMBOL(node_online_map);
46nodemask_t node_possible_map = NODE_MASK_ALL; 47nodemask_t node_possible_map = NODE_MASK_ALL;
48EXPORT_SYMBOL(node_possible_map);
47struct pglist_data *pgdat_list; 49struct pglist_data *pgdat_list;
48unsigned long totalram_pages; 50unsigned long totalram_pages;
49unsigned long totalhigh_pages; 51unsigned long totalhigh_pages;
@@ -799,14 +801,18 @@ __alloc_pages(unsigned int __nocast gfp_mask, unsigned int order,
799 } 801 }
800 802
801 /* This allocation should allow future memory freeing. */ 803 /* This allocation should allow future memory freeing. */
802 if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) && !in_interrupt()) { 804
803 /* go through the zonelist yet again, ignoring mins */ 805 if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
804 for (i = 0; (z = zones[i]) != NULL; i++) { 806 && !in_interrupt()) {
805 if (!cpuset_zone_allowed(z)) 807 if (!(gfp_mask & __GFP_NOMEMALLOC)) {
806 continue; 808 /* go through the zonelist yet again, ignoring mins */
807 page = buffered_rmqueue(z, order, gfp_mask); 809 for (i = 0; (z = zones[i]) != NULL; i++) {
808 if (page) 810 if (!cpuset_zone_allowed(z))
809 goto got_pg; 811 continue;
812 page = buffered_rmqueue(z, order, gfp_mask);
813 if (page)
814 goto got_pg;
815 }
810 } 816 }
811 goto nopage; 817 goto nopage;
812 } 818 }
@@ -1351,8 +1357,7 @@ static int __init build_zonelists_node(pg_data_t *pgdat, struct zonelist *zoneli
1351#define MAX_NODE_LOAD (num_online_nodes()) 1357#define MAX_NODE_LOAD (num_online_nodes())
1352static int __initdata node_load[MAX_NUMNODES]; 1358static int __initdata node_load[MAX_NUMNODES];
1353/** 1359/**
1354 * find_next_best_node - find the next node that should appear in a given 1360 * find_next_best_node - find the next node that should appear in a given node's fallback list
1355 * node's fallback list
1356 * @node: node whose fallback list we're appending 1361 * @node: node whose fallback list we're appending
1357 * @used_node_mask: nodemask_t of already used nodes 1362 * @used_node_mask: nodemask_t of already used nodes
1358 * 1363 *
@@ -1671,6 +1676,18 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1671 if (batch < 1) 1676 if (batch < 1)
1672 batch = 1; 1677 batch = 1;
1673 1678
1679 /*
1680 * Clamp the batch to a 2^n - 1 value. Having a power
1681 * of 2 value was found to be more likely to have
1682 * suboptimal cache aliasing properties in some cases.
1683 *
1684 * For example if 2 tasks are alternately allocating
1685 * batches of pages, one task can end up with a lot
1686 * of pages of one half of the possible page colors
1687 * and the other with pages of the other colors.
1688 */
1689 batch = (1 << fls(batch + batch/2)) - 1;
1690
1674 for (cpu = 0; cpu < NR_CPUS; cpu++) { 1691 for (cpu = 0; cpu < NR_CPUS; cpu++) {
1675 struct per_cpu_pages *pcp; 1692 struct per_cpu_pages *pcp;
1676 1693
@@ -1881,6 +1898,7 @@ static char *vmstat_text[] = {
1881 "allocstall", 1898 "allocstall",
1882 1899
1883 "pgrotated", 1900 "pgrotated",
1901 "nr_bounce",
1884}; 1902};
1885 1903
1886static void *vmstat_start(struct seq_file *m, loff_t *pos) 1904static void *vmstat_start(struct seq_file *m, loff_t *pos)
diff --git a/mm/rmap.c b/mm/rmap.c
index 884d6d1928bc..378de234c12b 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -243,6 +243,42 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
243} 243}
244 244
245/* 245/*
246 * Check that @page is mapped at @address into @mm.
247 *
248 * On success returns with mapped pte and locked mm->page_table_lock.
249 */
250static pte_t *page_check_address(struct page *page, struct mm_struct *mm,
251 unsigned long address)
252{
253 pgd_t *pgd;
254 pud_t *pud;
255 pmd_t *pmd;
256 pte_t *pte;
257
258 /*
259 * We need the page_table_lock to protect us from page faults,
260 * munmap, fork, etc...
261 */
262 spin_lock(&mm->page_table_lock);
263 pgd = pgd_offset(mm, address);
264 if (likely(pgd_present(*pgd))) {
265 pud = pud_offset(pgd, address);
266 if (likely(pud_present(*pud))) {
267 pmd = pmd_offset(pud, address);
268 if (likely(pmd_present(*pmd))) {
269 pte = pte_offset_map(pmd, address);
270 if (likely(pte_present(*pte) &&
271 page_to_pfn(page) == pte_pfn(*pte)))
272 return pte;
273 pte_unmap(pte);
274 }
275 }
276 }
277 spin_unlock(&mm->page_table_lock);
278 return ERR_PTR(-ENOENT);
279}
280
281/*
246 * Subfunctions of page_referenced: page_referenced_one called 282 * Subfunctions of page_referenced: page_referenced_one called
247 * repeatedly from either page_referenced_anon or page_referenced_file. 283 * repeatedly from either page_referenced_anon or page_referenced_file.
248 */ 284 */
@@ -251,9 +287,6 @@ static int page_referenced_one(struct page *page,
251{ 287{
252 struct mm_struct *mm = vma->vm_mm; 288 struct mm_struct *mm = vma->vm_mm;
253 unsigned long address; 289 unsigned long address;
254 pgd_t *pgd;
255 pud_t *pud;
256 pmd_t *pmd;
257 pte_t *pte; 290 pte_t *pte;
258 int referenced = 0; 291 int referenced = 0;
259 292
@@ -263,39 +296,18 @@ static int page_referenced_one(struct page *page,
263 if (address == -EFAULT) 296 if (address == -EFAULT)
264 goto out; 297 goto out;
265 298
266 spin_lock(&mm->page_table_lock); 299 pte = page_check_address(page, mm, address);
267 300 if (!IS_ERR(pte)) {
268 pgd = pgd_offset(mm, address); 301 if (ptep_clear_flush_young(vma, address, pte))
269 if (!pgd_present(*pgd)) 302 referenced++;
270 goto out_unlock;
271
272 pud = pud_offset(pgd, address);
273 if (!pud_present(*pud))
274 goto out_unlock;
275
276 pmd = pmd_offset(pud, address);
277 if (!pmd_present(*pmd))
278 goto out_unlock;
279
280 pte = pte_offset_map(pmd, address);
281 if (!pte_present(*pte))
282 goto out_unmap;
283
284 if (page_to_pfn(page) != pte_pfn(*pte))
285 goto out_unmap;
286
287 if (ptep_clear_flush_young(vma, address, pte))
288 referenced++;
289
290 if (mm != current->mm && !ignore_token && has_swap_token(mm))
291 referenced++;
292 303
293 (*mapcount)--; 304 if (mm != current->mm && !ignore_token && has_swap_token(mm))
305 referenced++;
294 306
295out_unmap: 307 (*mapcount)--;
296 pte_unmap(pte); 308 pte_unmap(pte);
297out_unlock: 309 spin_unlock(&mm->page_table_lock);
298 spin_unlock(&mm->page_table_lock); 310 }
299out: 311out:
300 return referenced; 312 return referenced;
301} 313}
@@ -502,9 +514,6 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
502{ 514{
503 struct mm_struct *mm = vma->vm_mm; 515 struct mm_struct *mm = vma->vm_mm;
504 unsigned long address; 516 unsigned long address;
505 pgd_t *pgd;
506 pud_t *pud;
507 pmd_t *pmd;
508 pte_t *pte; 517 pte_t *pte;
509 pte_t pteval; 518 pte_t pteval;
510 int ret = SWAP_AGAIN; 519 int ret = SWAP_AGAIN;
@@ -515,30 +524,9 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
515 if (address == -EFAULT) 524 if (address == -EFAULT)
516 goto out; 525 goto out;
517 526
518 /* 527 pte = page_check_address(page, mm, address);
519 * We need the page_table_lock to protect us from page faults, 528 if (IS_ERR(pte))
520 * munmap, fork, etc... 529 goto out;
521 */
522 spin_lock(&mm->page_table_lock);
523
524 pgd = pgd_offset(mm, address);
525 if (!pgd_present(*pgd))
526 goto out_unlock;
527
528 pud = pud_offset(pgd, address);
529 if (!pud_present(*pud))
530 goto out_unlock;
531
532 pmd = pmd_offset(pud, address);
533 if (!pmd_present(*pmd))
534 goto out_unlock;
535
536 pte = pte_offset_map(pmd, address);
537 if (!pte_present(*pte))
538 goto out_unmap;
539
540 if (page_to_pfn(page) != pte_pfn(*pte))
541 goto out_unmap;
542 530
543 /* 531 /*
544 * If the page is mlock()d, we cannot swap it out. 532 * If the page is mlock()d, we cannot swap it out.
@@ -604,7 +592,6 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
604 592
605out_unmap: 593out_unmap:
606 pte_unmap(pte); 594 pte_unmap(pte);
607out_unlock:
608 spin_unlock(&mm->page_table_lock); 595 spin_unlock(&mm->page_table_lock);
609out: 596out:
610 return ret; 597 return ret;
@@ -708,7 +695,6 @@ static void try_to_unmap_cluster(unsigned long cursor,
708 } 695 }
709 696
710 pte_unmap(pte); 697 pte_unmap(pte);
711
712out_unlock: 698out_unlock:
713 spin_unlock(&mm->page_table_lock); 699 spin_unlock(&mm->page_table_lock);
714} 700}
@@ -860,3 +846,4 @@ int try_to_unmap(struct page *page)
860 ret = SWAP_SUCCESS; 846 ret = SWAP_SUCCESS;
861 return ret; 847 return ret;
862} 848}
849
diff --git a/mm/slab.c b/mm/slab.c
index ec660d85ddd7..840742641152 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -583,7 +583,7 @@ static inline struct array_cache *ac_data(kmem_cache_t *cachep)
583 return cachep->array[smp_processor_id()]; 583 return cachep->array[smp_processor_id()];
584} 584}
585 585
586static inline kmem_cache_t *kmem_find_general_cachep(size_t size, int gfpflags) 586static inline kmem_cache_t *__find_general_cachep(size_t size, int gfpflags)
587{ 587{
588 struct cache_sizes *csizep = malloc_sizes; 588 struct cache_sizes *csizep = malloc_sizes;
589 589
@@ -607,6 +607,12 @@ static inline kmem_cache_t *kmem_find_general_cachep(size_t size, int gfpflags)
607 return csizep->cs_cachep; 607 return csizep->cs_cachep;
608} 608}
609 609
610kmem_cache_t *kmem_find_general_cachep(size_t size, int gfpflags)
611{
612 return __find_general_cachep(size, gfpflags);
613}
614EXPORT_SYMBOL(kmem_find_general_cachep);
615
610/* Cal the num objs, wastage, and bytes left over for a given slab size. */ 616/* Cal the num objs, wastage, and bytes left over for a given slab size. */
611static void cache_estimate(unsigned long gfporder, size_t size, size_t align, 617static void cache_estimate(unsigned long gfporder, size_t size, size_t align,
612 int flags, size_t *left_over, unsigned int *num) 618 int flags, size_t *left_over, unsigned int *num)
@@ -672,14 +678,11 @@ static struct array_cache *alloc_arraycache(int cpu, int entries,
672 int memsize = sizeof(void*)*entries+sizeof(struct array_cache); 678 int memsize = sizeof(void*)*entries+sizeof(struct array_cache);
673 struct array_cache *nc = NULL; 679 struct array_cache *nc = NULL;
674 680
675 if (cpu != -1) { 681 if (cpu == -1)
676 kmem_cache_t *cachep;
677 cachep = kmem_find_general_cachep(memsize, GFP_KERNEL);
678 if (cachep)
679 nc = kmem_cache_alloc_node(cachep, cpu_to_node(cpu));
680 }
681 if (!nc)
682 nc = kmalloc(memsize, GFP_KERNEL); 682 nc = kmalloc(memsize, GFP_KERNEL);
683 else
684 nc = kmalloc_node(memsize, GFP_KERNEL, cpu_to_node(cpu));
685
683 if (nc) { 686 if (nc) {
684 nc->avail = 0; 687 nc->avail = 0;
685 nc->limit = entries; 688 nc->limit = entries;
@@ -1663,7 +1666,7 @@ int kmem_cache_destroy(kmem_cache_t * cachep)
1663 } 1666 }
1664 1667
1665 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) 1668 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU))
1666 synchronize_kernel(); 1669 synchronize_rcu();
1667 1670
1668 /* no cpu_online check required here since we clear the percpu 1671 /* no cpu_online check required here since we clear the percpu
1669 * array on cpu offline and set this to NULL. 1672 * array on cpu offline and set this to NULL.
@@ -2361,7 +2364,7 @@ out:
2361 * and can sleep. And it will allocate memory on the given node, which 2364 * and can sleep. And it will allocate memory on the given node, which
2362 * can improve the performance for cpu bound structures. 2365 * can improve the performance for cpu bound structures.
2363 */ 2366 */
2364void *kmem_cache_alloc_node(kmem_cache_t *cachep, int nodeid) 2367void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int nodeid)
2365{ 2368{
2366 int loop; 2369 int loop;
2367 void *objp; 2370 void *objp;
@@ -2393,7 +2396,7 @@ void *kmem_cache_alloc_node(kmem_cache_t *cachep, int nodeid)
2393 spin_unlock_irq(&cachep->spinlock); 2396 spin_unlock_irq(&cachep->spinlock);
2394 2397
2395 local_irq_disable(); 2398 local_irq_disable();
2396 if (!cache_grow(cachep, GFP_KERNEL, nodeid)) { 2399 if (!cache_grow(cachep, flags, nodeid)) {
2397 local_irq_enable(); 2400 local_irq_enable();
2398 return NULL; 2401 return NULL;
2399 } 2402 }
@@ -2435,6 +2438,16 @@ got_slabp:
2435} 2438}
2436EXPORT_SYMBOL(kmem_cache_alloc_node); 2439EXPORT_SYMBOL(kmem_cache_alloc_node);
2437 2440
2441void *kmalloc_node(size_t size, int flags, int node)
2442{
2443 kmem_cache_t *cachep;
2444
2445 cachep = kmem_find_general_cachep(size, flags);
2446 if (unlikely(cachep == NULL))
2447 return NULL;
2448 return kmem_cache_alloc_node(cachep, flags, node);
2449}
2450EXPORT_SYMBOL(kmalloc_node);
2438#endif 2451#endif
2439 2452
2440/** 2453/**
@@ -2462,7 +2475,12 @@ void *__kmalloc(size_t size, unsigned int __nocast flags)
2462{ 2475{
2463 kmem_cache_t *cachep; 2476 kmem_cache_t *cachep;
2464 2477
2465 cachep = kmem_find_general_cachep(size, flags); 2478 /* If you want to save a few bytes .text space: replace
2479 * __ with kmem_.
2480 * Then kmalloc uses the uninlined functions instead of the inline
2481 * functions.
2482 */
2483 cachep = __find_general_cachep(size, flags);
2466 if (unlikely(cachep == NULL)) 2484 if (unlikely(cachep == NULL))
2467 return NULL; 2485 return NULL;
2468 return __cache_alloc(cachep, flags); 2486 return __cache_alloc(cachep, flags);
@@ -2489,9 +2507,8 @@ void *__alloc_percpu(size_t size, size_t align)
2489 for (i = 0; i < NR_CPUS; i++) { 2507 for (i = 0; i < NR_CPUS; i++) {
2490 if (!cpu_possible(i)) 2508 if (!cpu_possible(i))
2491 continue; 2509 continue;
2492 pdata->ptrs[i] = kmem_cache_alloc_node( 2510 pdata->ptrs[i] = kmalloc_node(size, GFP_KERNEL,
2493 kmem_find_general_cachep(size, GFP_KERNEL), 2511 cpu_to_node(i));
2494 cpu_to_node(i));
2495 2512
2496 if (!pdata->ptrs[i]) 2513 if (!pdata->ptrs[i])
2497 goto unwind_oom; 2514 goto unwind_oom;
diff --git a/mm/swap_state.c b/mm/swap_state.c
index a063a902ed03..4f251775ef90 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -143,7 +143,6 @@ void __delete_from_swap_cache(struct page *page)
143int add_to_swap(struct page * page) 143int add_to_swap(struct page * page)
144{ 144{
145 swp_entry_t entry; 145 swp_entry_t entry;
146 int pf_flags;
147 int err; 146 int err;
148 147
149 if (!PageLocked(page)) 148 if (!PageLocked(page))
@@ -154,29 +153,19 @@ int add_to_swap(struct page * page)
154 if (!entry.val) 153 if (!entry.val)
155 return 0; 154 return 0;
156 155
157 /* Radix-tree node allocations are performing 156 /*
158 * GFP_ATOMIC allocations under PF_MEMALLOC. 157 * Radix-tree node allocations from PF_MEMALLOC contexts could
159 * They can completely exhaust the page allocator. 158 * completely exhaust the page allocator. __GFP_NOMEMALLOC
160 * 159 * stops emergency reserves from being allocated.
161 * So PF_MEMALLOC is dropped here. This causes the slab
162 * allocations to fail earlier, so radix-tree nodes will
163 * then be allocated from the mempool reserves.
164 * 160 *
165 * We're still using __GFP_HIGH for radix-tree node 161 * TODO: this could cause a theoretical memory reclaim
166 * allocations, so some of the emergency pools are available, 162 * deadlock in the swap out path.
167 * just not all of them.
168 */ 163 */
169
170 pf_flags = current->flags;
171 current->flags &= ~PF_MEMALLOC;
172
173 /* 164 /*
174 * Add it to the swap cache and mark it dirty 165 * Add it to the swap cache and mark it dirty
175 */ 166 */
176 err = __add_to_swap_cache(page, entry, GFP_ATOMIC|__GFP_NOWARN); 167 err = __add_to_swap_cache(page, entry,
177 168 GFP_ATOMIC|__GFP_NOMEMALLOC|__GFP_NOWARN);
178 if (pf_flags & PF_MEMALLOC)
179 current->flags |= PF_MEMALLOC;
180 169
181 switch (err) { 170 switch (err) {
182 case 0: /* Success */ 171 case 0: /* Success */
diff --git a/mm/truncate.c b/mm/truncate.c
index c9a63f0b69a2..60c8764bfac2 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -242,7 +242,7 @@ EXPORT_SYMBOL(invalidate_inode_pages);
242 242
243/** 243/**
244 * invalidate_inode_pages2_range - remove range of pages from an address_space 244 * invalidate_inode_pages2_range - remove range of pages from an address_space
245 * @mapping - the address_space 245 * @mapping: the address_space
246 * @start: the page offset 'from' which to invalidate 246 * @start: the page offset 'from' which to invalidate
247 * @end: the page offset 'to' which to invalidate (inclusive) 247 * @end: the page offset 'to' which to invalidate (inclusive)
248 * 248 *
@@ -322,7 +322,7 @@ EXPORT_SYMBOL_GPL(invalidate_inode_pages2_range);
322 322
323/** 323/**
324 * invalidate_inode_pages2 - remove all pages from an address_space 324 * invalidate_inode_pages2 - remove all pages from an address_space
325 * @mapping - the address_space 325 * @mapping: the address_space
326 * 326 *
327 * Any pages which are found to be mapped into pagetables are unmapped prior to 327 * Any pages which are found to be mapped into pagetables are unmapped prior to
328 * invalidation. 328 * invalidation.
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index c6182f6f1305..2bd83e5c2bbf 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -475,6 +475,10 @@ void *vmalloc(unsigned long size)
475 475
476EXPORT_SYMBOL(vmalloc); 476EXPORT_SYMBOL(vmalloc);
477 477
478#ifndef PAGE_KERNEL_EXEC
479# define PAGE_KERNEL_EXEC PAGE_KERNEL
480#endif
481
478/** 482/**
479 * vmalloc_exec - allocate virtually contiguous, executable memory 483 * vmalloc_exec - allocate virtually contiguous, executable memory
480 * 484 *
@@ -488,10 +492,6 @@ EXPORT_SYMBOL(vmalloc);
488 * use __vmalloc() instead. 492 * use __vmalloc() instead.
489 */ 493 */
490 494
491#ifndef PAGE_KERNEL_EXEC
492# define PAGE_KERNEL_EXEC PAGE_KERNEL
493#endif
494
495void *vmalloc_exec(unsigned long size) 495void *vmalloc_exec(unsigned long size)
496{ 496{
497 return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC); 497 return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC);
diff --git a/net/802/fddi.c b/net/802/fddi.c
index f9a31a9f70f1..ebcf4830d6f1 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -10,7 +10,7 @@
10 * Authors: Lawrence V. Stefani, <stefani@lkg.dec.com> 10 * Authors: Lawrence V. Stefani, <stefani@lkg.dec.com>
11 * 11 *
12 * fddi.c is based on previous eth.c and tr.c work by 12 * fddi.c is based on previous eth.c and tr.c work by
13 * Ross Biro, <bir7@leland.Stanford.Edu> 13 * Ross Biro
14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 14 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
15 * Mark Evans, <evansmp@uhura.aston.ac.uk> 15 * Mark Evans, <evansmp@uhura.aston.ac.uk>
16 * Florian La Roche, <rzsfl@rz.uni-sb.de> 16 * Florian La Roche, <rzsfl@rz.uni-sb.de>
diff --git a/net/802/hippi.c b/net/802/hippi.c
index 4eb135c0afbb..051e8af56a77 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)hippi.c 1.0.0 05/29/97 8 * Version: @(#)hippi.c 1.0.0 05/29/97
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Florian La Roche, <rzsfl@rz.uni-sb.de> 13 * Florian La Roche, <rzsfl@rz.uni-sb.de>
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index c32d27af0a3f..7b214cffc956 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -23,7 +23,7 @@
23#include <linux/errno.h> /* return codes */ 23#include <linux/errno.h> /* return codes */
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/slab.h> /* kmalloc(), kfree() */ 25#include <linux/slab.h> /* kmalloc(), kfree() */
26#include <linux/mm.h> /* verify_area(), etc. */ 26#include <linux/mm.h>
27#include <linux/string.h> /* inline mem*, str* functions */ 27#include <linux/string.h> /* inline mem*, str* functions */
28#include <linux/init.h> /* __initfunc et al. */ 28#include <linux/init.h> /* __initfunc et al. */
29#include <asm/byteorder.h> /* htons(), etc. */ 29#include <asm/byteorder.h> /* htons(), etc. */
diff --git a/net/appletalk/dev.c b/net/appletalk/dev.c
index 76598445d84b..1237e208e246 100644
--- a/net/appletalk/dev.c
+++ b/net/appletalk/dev.c
@@ -19,7 +19,7 @@ static int ltalk_mac_addr(struct net_device *dev, void *addr)
19 return -EINVAL; 19 return -EINVAL;
20} 20}
21 21
22void ltalk_setup(struct net_device *dev) 22static void ltalk_setup(struct net_device *dev)
23{ 23{
24 /* Fill in the fields of the device structure with localtalk-generic values. */ 24 /* Fill in the fields of the device structure with localtalk-generic values. */
25 25
@@ -40,4 +40,22 @@ void ltalk_setup(struct net_device *dev)
40 40
41 dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP; 41 dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
42} 42}
43EXPORT_SYMBOL(ltalk_setup); 43
44/**
45 * alloc_ltalkdev - Allocates and sets up an localtalk device
46 * @sizeof_priv: Size of additional driver-private structure to be allocated
47 * for this localtalk device
48 *
49 * Fill in the fields of the device structure with localtalk-generic
50 * values. Basically does everything except registering the device.
51 *
52 * Constructs a new net device, complete with a private data area of
53 * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for
54 * this private data area.
55 */
56
57struct net_device *alloc_ltalkdev(int sizeof_priv)
58{
59 return alloc_netdev(sizeof_priv, "lt%d", ltalk_setup);
60}
61EXPORT_SYMBOL(alloc_ltalkdev);
diff --git a/net/atm/common.c b/net/atm/common.c
index 6d16be334ea0..e93e838069e8 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -12,7 +12,7 @@
12#include <linux/socket.h> /* SOL_SOCKET */ 12#include <linux/socket.h> /* SOL_SOCKET */
13#include <linux/errno.h> /* error codes */ 13#include <linux/errno.h> /* error codes */
14#include <linux/capability.h> 14#include <linux/capability.h>
15#include <linux/mm.h> /* verify_area */ 15#include <linux/mm.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/time.h> /* struct timeval */ 17#include <linux/time.h> /* struct timeval */
18#include <linux/skbuff.h> 18#include <linux/skbuff.h>
@@ -540,7 +540,7 @@ int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
540 error = -EMSGSIZE; 540 error = -EMSGSIZE;
541 goto out; 541 goto out;
542 } 542 }
543 /* verify_area is done by net/socket.c */ 543
544 eff = (size+3) & ~3; /* align to word boundary */ 544 eff = (size+3) & ~3; /* align to word boundary */
545 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 545 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
546 error = 0; 546 error = 0;
diff --git a/net/atm/resources.c b/net/atm/resources.c
index 33f1685dbb77..a57a9268bd24 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -44,11 +44,6 @@ static struct atm_dev *__alloc_atm_dev(const char *type)
44 return dev; 44 return dev;
45} 45}
46 46
47static void __free_atm_dev(struct atm_dev *dev)
48{
49 kfree(dev);
50}
51
52static struct atm_dev *__atm_dev_lookup(int number) 47static struct atm_dev *__atm_dev_lookup(int number)
53{ 48{
54 struct atm_dev *dev; 49 struct atm_dev *dev;
@@ -90,7 +85,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
90 if ((inuse = __atm_dev_lookup(number))) { 85 if ((inuse = __atm_dev_lookup(number))) {
91 atm_dev_put(inuse); 86 atm_dev_put(inuse);
92 spin_unlock(&atm_dev_lock); 87 spin_unlock(&atm_dev_lock);
93 __free_atm_dev(dev); 88 kfree(dev);
94 return NULL; 89 return NULL;
95 } 90 }
96 dev->number = number; 91 dev->number = number;
@@ -119,7 +114,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
119 spin_lock(&atm_dev_lock); 114 spin_lock(&atm_dev_lock);
120 list_del(&dev->dev_list); 115 list_del(&dev->dev_list);
121 spin_unlock(&atm_dev_lock); 116 spin_unlock(&atm_dev_lock);
122 __free_atm_dev(dev); 117 kfree(dev);
123 return NULL; 118 return NULL;
124 } 119 }
125 120
@@ -148,7 +143,7 @@ void atm_dev_deregister(struct atm_dev *dev)
148 } 143 }
149 } 144 }
150 145
151 __free_atm_dev(dev); 146 kfree(dev);
152} 147}
153 148
154void shutdown_atm_dev(struct atm_dev *dev) 149void shutdown_atm_dev(struct atm_dev *dev)
diff --git a/net/atm/signaling.c b/net/atm/signaling.c
index 6ff803154c04..f7c449ac1800 100644
--- a/net/atm/signaling.c
+++ b/net/atm/signaling.c
@@ -134,6 +134,7 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb)
134 break; 134 break;
135 case as_indicate: 135 case as_indicate:
136 vcc = *(struct atm_vcc **) &msg->listen_vcc; 136 vcc = *(struct atm_vcc **) &msg->listen_vcc;
137 sk = sk_atm(vcc);
137 DPRINTK("as_indicate!!!\n"); 138 DPRINTK("as_indicate!!!\n");
138 lock_sock(sk); 139 lock_sock(sk);
139 if (sk_acceptq_is_full(sk)) { 140 if (sk_acceptq_is_full(sk)) {
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 33b1a3763027..707097deac3d 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1587,9 +1587,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
1587 *asmptr = AX25_UI; 1587 *asmptr = AX25_UI;
1588 1588
1589 /* Datagram frames go straight out of the door as UI */ 1589 /* Datagram frames go straight out of the door as UI */
1590 skb->dev = ax25->ax25_dev->dev; 1590 ax25_queue_xmit(skb, ax25->ax25_dev->dev);
1591
1592 ax25_queue_xmit(skb);
1593 1591
1594 err = len; 1592 err = len;
1595 1593
diff --git a/net/ax25/ax25_ds_subr.c b/net/ax25/ax25_ds_subr.c
index 10ffd2beba3f..1d4ab641f82b 100644
--- a/net/ax25/ax25_ds_subr.c
+++ b/net/ax25/ax25_ds_subr.c
@@ -143,8 +143,7 @@ static void ax25_kiss_cmd(ax25_dev *ax25_dev, unsigned char cmd, unsigned char p
143 *p++ = cmd; 143 *p++ = cmd;
144 *p++ = param; 144 *p++ = param;
145 145
146 skb->dev = ax25_dev->dev; 146 skb->protocol = ax25_type_trans(skb, ax25_dev->dev);
147 skb->protocol = htons(ETH_P_AX25);
148 147
149 dev_queue_xmit(skb); 148 dev_queue_xmit(skb);
150} 149}
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c
index 04d711344d55..bba0173e2d65 100644
--- a/net/ax25/ax25_ip.c
+++ b/net/ax25/ax25_ip.c
@@ -199,9 +199,7 @@ int ax25_rebuild_header(struct sk_buff *skb)
199 skb = ourskb; 199 skb = ourskb;
200 } 200 }
201 201
202 skb->dev = dev; 202 ax25_queue_xmit(skb, dev);
203
204 ax25_queue_xmit(skb);
205 203
206put: 204put:
207 ax25_put_route(route); 205 ax25_put_route(route);
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index 3475a3ac9343..5fc048dcd39a 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -340,21 +340,18 @@ void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type)
340 340
341 ax25_addr_build(ptr, &ax25->source_addr, &ax25->dest_addr, ax25->digipeat, type, ax25->modulus); 341 ax25_addr_build(ptr, &ax25->source_addr, &ax25->dest_addr, ax25->digipeat, type, ax25->modulus);
342 342
343 skb->dev = ax25->ax25_dev->dev; 343 ax25_queue_xmit(skb, ax25->ax25_dev->dev);
344
345 ax25_queue_xmit(skb);
346} 344}
347 345
348/* 346/*
349 * A small shim to dev_queue_xmit to add the KISS control byte, and do 347 * A small shim to dev_queue_xmit to add the KISS control byte, and do
350 * any packet forwarding in operation. 348 * any packet forwarding in operation.
351 */ 349 */
352void ax25_queue_xmit(struct sk_buff *skb) 350void ax25_queue_xmit(struct sk_buff *skb, struct net_device *dev)
353{ 351{
354 unsigned char *ptr; 352 unsigned char *ptr;
355 353
356 skb->protocol = htons(ETH_P_AX25); 354 skb->protocol = ax25_type_trans(skb, ax25_fwd_dev(dev));
357 skb->dev = ax25_fwd_dev(skb->dev);
358 355
359 ptr = skb_push(skb, 1); 356 ptr = skb_push(skb, 1);
360 *ptr = 0x00; /* KISS */ 357 *ptr = 0x00; /* KISS */
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 8cf72707af8b..99694b57f6f5 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -220,9 +220,7 @@ void ax25_return_dm(struct net_device *dev, ax25_address *src, ax25_address *des
220 dptr = skb_push(skb, ax25_addr_size(digi)); 220 dptr = skb_push(skb, ax25_addr_size(digi));
221 dptr += ax25_addr_build(dptr, dest, src, &retdigi, AX25_RESPONSE, AX25_MODULUS); 221 dptr += ax25_addr_build(dptr, dest, src, &retdigi, AX25_RESPONSE, AX25_MODULUS);
222 222
223 skb->dev = dev; 223 ax25_queue_xmit(skb, dev);
224
225 ax25_queue_xmit(skb);
226} 224}
227 225
228/* 226/*
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 1650c6bf6997..12b43345b54f 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -31,7 +31,6 @@
31#include <linux/list.h> 31#include <linux/list.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/major.h>
35#include <linux/sched.h> 34#include <linux/sched.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/skbuff.h> 36#include <linux/skbuff.h>
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index 9a8d99a39b6d..9778c6acd53b 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -34,7 +34,6 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/errno.h> 35#include <linux/errno.h>
36#include <linux/kernel.h> 36#include <linux/kernel.h>
37#include <linux/major.h>
38#include <linux/sched.h> 37#include <linux/sched.h>
39#include <linux/slab.h> 38#include <linux/slab.h>
40#include <linux/poll.h> 39#include <linux/poll.h>
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 1e5c030b72ad..b2e7e38531c6 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -26,7 +26,6 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/major.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include <linux/poll.h> 31#include <linux/poll.h>
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 20ce04f2be8b..2e341de3e763 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -26,7 +26,6 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/major.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include <linux/poll.h> 31#include <linux/poll.h>
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 4c7f9e20dade..beb045bf5714 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -26,7 +26,6 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/major.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include <linux/poll.h> 31#include <linux/poll.h>
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 71762d7e9970..a31244e58888 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -30,7 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/major.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/poll.h> 35#include <linux/poll.h>
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 860dba7bdd89..fb5524365bc2 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -31,7 +31,6 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/major.h>
35#include <linux/sched.h> 34#include <linux/sched.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/poll.h> 36#include <linux/poll.h>
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 8ccba8ee9979..c4b592b4ef10 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -30,7 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/major.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/poll.h> 35#include <linux/poll.h>
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index c9792ba75122..ebdcce5e7ca0 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -30,7 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/major.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/poll.h> 35#include <linux/poll.h>
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 2cf98ceabcc7..affbc55462e8 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -26,7 +26,6 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/major.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include <linux/poll.h> 31#include <linux/poll.h>
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index fabb36d4666b..f8986f881431 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -26,7 +26,6 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/major.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include <linux/poll.h> 31#include <linux/poll.h>
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c12babcf0b3c..32fccfb5bfa5 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -30,7 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/major.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/poll.h> 35#include <linux/poll.h>
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 640028a2183c..f3f6355a2786 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -33,7 +33,6 @@
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/major.h>
37#include <linux/sched.h> 36#include <linux/sched.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <linux/poll.h> 38#include <linux/poll.h>
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 3e750ef09e60..746c11fc017e 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -30,7 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/major.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/poll.h> 35#include <linux/poll.h>
diff --git a/net/core/datagram.c b/net/core/datagram.c
index d1bfd279cc1a..fcee054b6f75 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -115,10 +115,10 @@ out_noerr:
115 115
116/** 116/**
117 * skb_recv_datagram - Receive a datagram skbuff 117 * skb_recv_datagram - Receive a datagram skbuff
118 * @sk - socket 118 * @sk: socket
119 * @flags - MSG_ flags 119 * @flags: MSG_ flags
120 * @noblock - blocking operation? 120 * @noblock: blocking operation?
121 * @err - error code returned 121 * @err: error code returned
122 * 122 *
123 * Get a datagram skbuff, understands the peeking, nonblocking wakeups 123 * Get a datagram skbuff, understands the peeking, nonblocking wakeups
124 * and possible races. This replaces identical code in packet, raw and 124 * and possible races. This replaces identical code in packet, raw and
@@ -201,10 +201,10 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
201 201
202/** 202/**
203 * skb_copy_datagram_iovec - Copy a datagram to an iovec. 203 * skb_copy_datagram_iovec - Copy a datagram to an iovec.
204 * @skb - buffer to copy 204 * @skb: buffer to copy
205 * @offset - offset in the buffer to start copying from 205 * @offset: offset in the buffer to start copying from
206 * @iovec - io vector to copy to 206 * @to: io vector to copy to
207 * @len - amount of data to copy from buffer to iovec 207 * @len: amount of data to copy from buffer to iovec
208 * 208 *
209 * Note: the iovec is modified during the copy. 209 * Note: the iovec is modified during the copy.
210 */ 210 */
@@ -377,9 +377,9 @@ fault:
377 377
378/** 378/**
379 * skb_copy_and_csum_datagram_iovec - Copy and checkum skb to user iovec. 379 * skb_copy_and_csum_datagram_iovec - Copy and checkum skb to user iovec.
380 * @skb - skbuff 380 * @skb: skbuff
381 * @hlen - hardware length 381 * @hlen: hardware length
382 * @iovec - io vector 382 * @iov: io vector
383 * 383 *
384 * Caller _must_ check that skb will fit to this iovec. 384 * Caller _must_ check that skb will fit to this iovec.
385 * 385 *
@@ -425,9 +425,9 @@ fault:
425 425
426/** 426/**
427 * datagram_poll - generic datagram poll 427 * datagram_poll - generic datagram poll
428 * @file - file struct 428 * @file: file struct
429 * @sock - socket 429 * @sock: socket
430 * @wait - poll table 430 * @wait: poll table
431 * 431 *
432 * Datagram poll: Again totally generic. This also handles 432 * Datagram poll: Again totally generic. This also handles
433 * sequenced packet sockets providing the socket receive queue 433 * sequenced packet sockets providing the socket receive queue
diff --git a/net/core/dev.c b/net/core/dev.c
index 42344d903692..d4d9e2680adb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7,7 +7,7 @@
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 * 8 *
9 * Derived from the non IP parts of dev.c 1.0.19 9 * Derived from the non IP parts of dev.c 1.0.19
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * 13 *
@@ -1214,6 +1214,19 @@ int __skb_linearize(struct sk_buff *skb, int gfp_mask)
1214 * A negative errno code is returned on a failure. A success does not 1214 * A negative errno code is returned on a failure. A success does not
1215 * guarantee the frame will be transmitted as it may be dropped due 1215 * guarantee the frame will be transmitted as it may be dropped due
1216 * to congestion or traffic shaping. 1216 * to congestion or traffic shaping.
1217 *
1218 * -----------------------------------------------------------------------------------
1219 * I notice this method can also return errors from the queue disciplines,
1220 * including NET_XMIT_DROP, which is a positive value. So, errors can also
1221 * be positive.
1222 *
1223 * Regardless of the return value, the skb is consumed, so it is currently
1224 * difficult to retry a send to this method. (You can bump the ref count
1225 * before sending to hold a reference for retry if you are careful.)
1226 *
1227 * When calling this method, interrupts MUST be enabled. This is because
1228 * the BH enable code must have IRQs enabled so that it will not deadlock.
1229 * --BLG
1217 */ 1230 */
1218 1231
1219int dev_queue_xmit(struct sk_buff *skb) 1232int dev_queue_xmit(struct sk_buff *skb)
@@ -3078,7 +3091,7 @@ void free_netdev(struct net_device *dev)
3078void synchronize_net(void) 3091void synchronize_net(void)
3079{ 3092{
3080 might_sleep(); 3093 might_sleep();
3081 synchronize_kernel(); 3094 synchronize_rcu();
3082} 3095}
3083 3096
3084/** 3097/**
diff --git a/net/core/iovec.c b/net/core/iovec.c
index d57ace949ab8..65e4b56fbc77 100644
--- a/net/core/iovec.c
+++ b/net/core/iovec.c
@@ -33,7 +33,7 @@
33 * Verify iovec. The caller must ensure that the iovec is big enough 33 * Verify iovec. The caller must ensure that the iovec is big enough
34 * to hold the message iovec. 34 * to hold the message iovec.
35 * 35 *
36 * Save time not doing verify_area. copy_*_user will make this work 36 * Save time not doing access_ok. copy_*_user will make this work
37 * in any case. 37 * in any case.
38 */ 38 */
39 39
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 4859b7446c6f..d43d1201275c 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -16,6 +16,7 @@
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/if.h> 17#include <linux/if.h>
18#include <net/sock.h> 18#include <net/sock.h>
19#include <net/pkt_sched.h>
19#include <linux/rtnetlink.h> 20#include <linux/rtnetlink.h>
20#include <linux/jiffies.h> 21#include <linux/jiffies.h>
21#include <linux/spinlock.h> 22#include <linux/spinlock.h>
@@ -74,6 +75,12 @@ void linkwatch_run_queue(void)
74 clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state); 75 clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state);
75 76
76 if (dev->flags & IFF_UP) { 77 if (dev->flags & IFF_UP) {
78 if (netif_carrier_ok(dev)) {
79 WARN_ON(dev->qdisc_sleeping == &noop_qdisc);
80 dev_activate(dev);
81 } else
82 dev_deactivate(dev);
83
77 netdev_state_change(dev); 84 netdev_state_change(dev);
78 } 85 }
79 86
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 0a2f67bbef2e..43bdc521e20d 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1953,7 +1953,7 @@ static int neigh_stat_seq_show(struct seq_file *seq, void *v)
1953 struct neigh_statistics *st = v; 1953 struct neigh_statistics *st = v;
1954 1954
1955 if (v == SEQ_START_TOKEN) { 1955 if (v == SEQ_START_TOKEN) {
1956 seq_printf(seq, "entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs forced_gc_goal_miss\n"); 1956 seq_printf(seq, "entries allocs destroys hash_grows lookups hits res_failed rcv_probes_mcast rcv_probes_ucast periodic_gc_runs forced_gc_runs\n");
1957 return 0; 1957 return 0;
1958 } 1958 }
1959 1959
diff --git a/net/core/netfilter.c b/net/core/netfilter.c
index e51cfa46950c..22a8f127c4aa 100644
--- a/net/core/netfilter.c
+++ b/net/core/netfilter.c
@@ -217,21 +217,10 @@ void nf_debug_ip_local_deliver(struct sk_buff *skb)
217 * NF_IP_RAW_INPUT and NF_IP_PRE_ROUTING. */ 217 * NF_IP_RAW_INPUT and NF_IP_PRE_ROUTING. */
218 if (!skb->dev) { 218 if (!skb->dev) {
219 printk("ip_local_deliver: skb->dev is NULL.\n"); 219 printk("ip_local_deliver: skb->dev is NULL.\n");
220 } 220 } else {
221 else if (strcmp(skb->dev->name, "lo") == 0) {
222 if (skb->nf_debug != ((1 << NF_IP_LOCAL_OUT)
223 | (1 << NF_IP_POST_ROUTING)
224 | (1 << NF_IP_PRE_ROUTING)
225 | (1 << NF_IP_LOCAL_IN))) {
226 printk("ip_local_deliver: bad loopback skb: ");
227 debug_print_hooks_ip(skb->nf_debug);
228 nf_dump_skb(PF_INET, skb);
229 }
230 }
231 else {
232 if (skb->nf_debug != ((1<<NF_IP_PRE_ROUTING) 221 if (skb->nf_debug != ((1<<NF_IP_PRE_ROUTING)
233 | (1<<NF_IP_LOCAL_IN))) { 222 | (1<<NF_IP_LOCAL_IN))) {
234 printk("ip_local_deliver: bad non-lo skb: "); 223 printk("ip_local_deliver: bad skb: ");
235 debug_print_hooks_ip(skb->nf_debug); 224 debug_print_hooks_ip(skb->nf_debug);
236 nf_dump_skb(PF_INET, skb); 225 nf_dump_skb(PF_INET, skb);
237 } 226 }
@@ -247,8 +236,6 @@ void nf_debug_ip_loopback_xmit(struct sk_buff *newskb)
247 debug_print_hooks_ip(newskb->nf_debug); 236 debug_print_hooks_ip(newskb->nf_debug);
248 nf_dump_skb(PF_INET, newskb); 237 nf_dump_skb(PF_INET, newskb);
249 } 238 }
250 /* Clear to avoid confusing input check */
251 newskb->nf_debug = 0;
252} 239}
253 240
254void nf_debug_ip_finish_output2(struct sk_buff *skb) 241void nf_debug_ip_finish_output2(struct sk_buff *skb)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 44dfaf8f04af..00caf4b318b2 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -22,7 +22,6 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/socket.h> 23#include <linux/socket.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/major.h>
26#include <linux/sched.h> 25#include <linux/sched.h>
27#include <linux/timer.h> 26#include <linux/timer.h>
28#include <linux/string.h> 27#include <linux/string.h>
@@ -87,30 +86,33 @@ struct sock *rtnl;
87 86
88struct rtnetlink_link * rtnetlink_links[NPROTO]; 87struct rtnetlink_link * rtnetlink_links[NPROTO];
89 88
90static const int rtm_min[(RTM_MAX+1-RTM_BASE)/4] = 89static const int rtm_min[RTM_NR_FAMILIES] =
91{ 90{
92 NLMSG_LENGTH(sizeof(struct ifinfomsg)), 91 [RTM_FAM(RTM_NEWLINK)] = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
93 NLMSG_LENGTH(sizeof(struct ifaddrmsg)), 92 [RTM_FAM(RTM_NEWADDR)] = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
94 NLMSG_LENGTH(sizeof(struct rtmsg)), 93 [RTM_FAM(RTM_NEWROUTE)] = NLMSG_LENGTH(sizeof(struct rtmsg)),
95 NLMSG_LENGTH(sizeof(struct ndmsg)), 94 [RTM_FAM(RTM_NEWNEIGH)] = NLMSG_LENGTH(sizeof(struct ndmsg)),
96 NLMSG_LENGTH(sizeof(struct rtmsg)), 95 [RTM_FAM(RTM_NEWRULE)] = NLMSG_LENGTH(sizeof(struct rtmsg)),
97 NLMSG_LENGTH(sizeof(struct tcmsg)), 96 [RTM_FAM(RTM_NEWQDISC)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
98 NLMSG_LENGTH(sizeof(struct tcmsg)), 97 [RTM_FAM(RTM_NEWTCLASS)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
99 NLMSG_LENGTH(sizeof(struct tcmsg)), 98 [RTM_FAM(RTM_NEWTFILTER)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
100 NLMSG_LENGTH(sizeof(struct tcamsg)) 99 [RTM_FAM(RTM_NEWACTION)] = NLMSG_LENGTH(sizeof(struct tcamsg)),
100 [RTM_FAM(RTM_NEWPREFIX)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
101 [RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
102 [RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
101}; 103};
102 104
103static const int rta_max[(RTM_MAX+1-RTM_BASE)/4] = 105static const int rta_max[RTM_NR_FAMILIES] =
104{ 106{
105 IFLA_MAX, 107 [RTM_FAM(RTM_NEWLINK)] = IFLA_MAX,
106 IFA_MAX, 108 [RTM_FAM(RTM_NEWADDR)] = IFA_MAX,
107 RTA_MAX, 109 [RTM_FAM(RTM_NEWROUTE)] = RTA_MAX,
108 NDA_MAX, 110 [RTM_FAM(RTM_NEWNEIGH)] = NDA_MAX,
109 RTA_MAX, 111 [RTM_FAM(RTM_NEWRULE)] = RTA_MAX,
110 TCA_MAX, 112 [RTM_FAM(RTM_NEWQDISC)] = TCA_MAX,
111 TCA_MAX, 113 [RTM_FAM(RTM_NEWTCLASS)] = TCA_MAX,
112 TCA_MAX, 114 [RTM_FAM(RTM_NEWTFILTER)] = TCA_MAX,
113 TCAA_MAX 115 [RTM_FAM(RTM_NEWACTION)] = TCAA_MAX,
114}; 116};
115 117
116void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data) 118void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
@@ -607,27 +609,33 @@ static inline int rtnetlink_rcv_skb(struct sk_buff *skb)
607 609
608/* 610/*
609 * rtnetlink input queue processing routine: 611 * rtnetlink input queue processing routine:
610 * - try to acquire shared lock. If it is failed, defer processing. 612 * - process as much as there was in the queue upon entry.
611 * - feed skbs to rtnetlink_rcv_skb, until it refuse a message, 613 * - feed skbs to rtnetlink_rcv_skb, until it refuse a message,
612 * that will occur, when a dump started and/or acquisition of 614 * that will occur, when a dump started.
613 * exclusive lock failed.
614 */ 615 */
615 616
616static void rtnetlink_rcv(struct sock *sk, int len) 617static void rtnetlink_rcv(struct sock *sk, int len)
617{ 618{
619 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
620
618 do { 621 do {
619 struct sk_buff *skb; 622 struct sk_buff *skb;
620 623
621 if (rtnl_shlock_nowait()) 624 rtnl_lock();
622 return; 625
626 if (qlen > skb_queue_len(&sk->sk_receive_queue))
627 qlen = skb_queue_len(&sk->sk_receive_queue);
623 628
624 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 629 for (; qlen; qlen--) {
630 skb = skb_dequeue(&sk->sk_receive_queue);
625 if (rtnetlink_rcv_skb(skb)) { 631 if (rtnetlink_rcv_skb(skb)) {
626 if (skb->len) 632 if (skb->len)
627 skb_queue_head(&sk->sk_receive_queue, 633 skb_queue_head(&sk->sk_receive_queue,
628 skb); 634 skb);
629 else 635 else {
630 kfree_skb(skb); 636 kfree_skb(skb);
637 qlen--;
638 }
631 break; 639 break;
632 } 640 }
633 kfree_skb(skb); 641 kfree_skb(skb);
@@ -636,10 +644,10 @@ static void rtnetlink_rcv(struct sock *sk, int len)
636 up(&rtnl_sem); 644 up(&rtnl_sem);
637 645
638 netdev_run_todo(); 646 netdev_run_todo();
639 } while (rtnl && rtnl->sk_receive_queue.qlen); 647 } while (qlen);
640} 648}
641 649
642static struct rtnetlink_link link_rtnetlink_table[RTM_MAX-RTM_BASE+1] = 650static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
643{ 651{
644 [RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo }, 652 [RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo },
645 [RTM_SETLINK - RTM_BASE] = { .doit = do_setlink }, 653 [RTM_SETLINK - RTM_BASE] = { .doit = do_setlink },
diff --git a/net/core/scm.c b/net/core/scm.c
index a2ebf30f6aa8..e887d19be506 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -15,7 +15,6 @@
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/major.h>
19#include <linux/stat.h> 18#include <linux/stat.h>
20#include <linux/socket.h> 19#include <linux/socket.h>
21#include <linux/file.h> 20#include <linux/file.h>
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1b64817d7de6..f65b3de590a9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -86,8 +86,10 @@ static kmem_cache_t *skbuff_head_cache;
86 */ 86 */
87void skb_over_panic(struct sk_buff *skb, int sz, void *here) 87void skb_over_panic(struct sk_buff *skb, int sz, void *here)
88{ 88{
89 printk(KERN_INFO "skput:over: %p:%d put:%d dev:%s", 89 printk(KERN_EMERG "skb_over_panic: text:%p len:%d put:%d head:%p "
90 here, skb->len, sz, skb->dev ? skb->dev->name : "<NULL>"); 90 "data:%p tail:%p end:%p dev:%s\n",
91 here, skb->len, sz, skb->head, skb->data, skb->tail, skb->end,
92 skb->dev ? skb->dev->name : "<NULL>");
91 BUG(); 93 BUG();
92} 94}
93 95
@@ -102,8 +104,10 @@ void skb_over_panic(struct sk_buff *skb, int sz, void *here)
102 104
103void skb_under_panic(struct sk_buff *skb, int sz, void *here) 105void skb_under_panic(struct sk_buff *skb, int sz, void *here)
104{ 106{
105 printk(KERN_INFO "skput:under: %p:%d put:%d dev:%s", 107 printk(KERN_EMERG "skb_under_panic: text:%p len:%d put:%d head:%p "
106 here, skb->len, sz, skb->dev ? skb->dev->name : "<NULL>"); 108 "data:%p tail:%p end:%p dev:%s\n",
109 here, skb->len, sz, skb->head, skb->data, skb->tail, skb->end,
110 skb->dev ? skb->dev->name : "<NULL>");
107 BUG(); 111 BUG();
108} 112}
109 113
diff --git a/net/core/sock.c b/net/core/sock.c
index 4df4fa3c5de0..96e00b08698f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * Version: $Id: sock.c,v 1.117 2002/02/01 22:01:03 davem Exp $ 10 * Version: $Id: sock.c,v 1.117 2002/02/01 22:01:03 davem Exp $
11 * 11 *
12 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 12 * Authors: Ross Biro
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Florian La Roche, <flla@stud.uni-sb.de> 14 * Florian La Roche, <flla@stud.uni-sb.de>
15 * Alan Cox, <A.Cox@swansea.ac.uk> 15 * Alan Cox, <A.Cox@swansea.ac.uk>
@@ -97,7 +97,6 @@
97#include <linux/socket.h> 97#include <linux/socket.h>
98#include <linux/in.h> 98#include <linux/in.h>
99#include <linux/kernel.h> 99#include <linux/kernel.h>
100#include <linux/major.h>
101#include <linux/module.h> 100#include <linux/module.h>
102#include <linux/proc_fs.h> 101#include <linux/proc_fs.h>
103#include <linux/seq_file.h> 102#include <linux/seq_file.h>
@@ -617,10 +616,10 @@ lenout:
617 616
618/** 617/**
619 * sk_alloc - All socket objects are allocated here 618 * sk_alloc - All socket objects are allocated here
620 * @family - protocol family 619 * @family: protocol family
621 * @priority - for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc) 620 * @priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc)
622 * @prot - struct proto associated with this new sock instance 621 * @prot: struct proto associated with this new sock instance
623 * @zero_it - if we should zero the newly allocated sock 622 * @zero_it: if we should zero the newly allocated sock
624 */ 623 */
625struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it) 624struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
626{ 625{
@@ -636,7 +635,11 @@ struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
636 if (zero_it) { 635 if (zero_it) {
637 memset(sk, 0, prot->obj_size); 636 memset(sk, 0, prot->obj_size);
638 sk->sk_family = family; 637 sk->sk_family = family;
639 sk->sk_prot = prot; 638 /*
639 * See comment in struct sock definition to understand
640 * why we need sk_prot_creator -acme
641 */
642 sk->sk_prot = sk->sk_prot_creator = prot;
640 sock_lock_init(sk); 643 sock_lock_init(sk);
641 } 644 }
642 645
@@ -655,7 +658,7 @@ struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
655void sk_free(struct sock *sk) 658void sk_free(struct sock *sk)
656{ 659{
657 struct sk_filter *filter; 660 struct sk_filter *filter;
658 struct module *owner = sk->sk_prot->owner; 661 struct module *owner = sk->sk_prot_creator->owner;
659 662
660 if (sk->sk_destruct) 663 if (sk->sk_destruct)
661 sk->sk_destruct(sk); 664 sk->sk_destruct(sk);
@@ -673,8 +676,8 @@ void sk_free(struct sock *sk)
673 __FUNCTION__, atomic_read(&sk->sk_omem_alloc)); 676 __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
674 677
675 security_sk_free(sk); 678 security_sk_free(sk);
676 if (sk->sk_prot->slab != NULL) 679 if (sk->sk_prot_creator->slab != NULL)
677 kmem_cache_free(sk->sk_prot->slab, sk); 680 kmem_cache_free(sk->sk_prot_creator->slab, sk);
678 else 681 else
679 kfree(sk); 682 kfree(sk);
680 module_put(owner); 683 module_put(owner);
@@ -971,8 +974,8 @@ static void __release_sock(struct sock *sk)
971 974
972/** 975/**
973 * sk_wait_data - wait for data to arrive at sk_receive_queue 976 * sk_wait_data - wait for data to arrive at sk_receive_queue
974 * sk - sock to wait on 977 * @sk: sock to wait on
975 * timeo - for how long 978 * @timeo: for how long
976 * 979 *
977 * Now socket state including sk->sk_err is changed only under lock, 980 * Now socket state including sk->sk_err is changed only under lock,
978 * hence we may omit checks after joining wait queue. 981 * hence we may omit checks after joining wait queue.
diff --git a/net/core/stream.c b/net/core/stream.c
index 1e27a57b5a97..ac9edfdf8742 100644
--- a/net/core/stream.c
+++ b/net/core/stream.c
@@ -21,7 +21,7 @@
21 21
22/** 22/**
23 * sk_stream_write_space - stream socket write_space callback. 23 * sk_stream_write_space - stream socket write_space callback.
24 * sk - socket 24 * @sk: socket
25 * 25 *
26 * FIXME: write proper description 26 * FIXME: write proper description
27 */ 27 */
@@ -43,8 +43,8 @@ EXPORT_SYMBOL(sk_stream_write_space);
43 43
44/** 44/**
45 * sk_stream_wait_connect - Wait for a socket to get into the connected state 45 * sk_stream_wait_connect - Wait for a socket to get into the connected state
46 * @sk - sock to wait on 46 * @sk: sock to wait on
47 * @timeo_p - for how long to wait 47 * @timeo_p: for how long to wait
48 * 48 *
49 * Must be called with the socket locked. 49 * Must be called with the socket locked.
50 */ 50 */
@@ -79,7 +79,7 @@ EXPORT_SYMBOL(sk_stream_wait_connect);
79 79
80/** 80/**
81 * sk_stream_closing - Return 1 if we still have things to send in our buffers. 81 * sk_stream_closing - Return 1 if we still have things to send in our buffers.
82 * @sk - socket to verify 82 * @sk: socket to verify
83 */ 83 */
84static inline int sk_stream_closing(struct sock *sk) 84static inline int sk_stream_closing(struct sock *sk)
85{ 85{
@@ -107,8 +107,8 @@ EXPORT_SYMBOL(sk_stream_wait_close);
107 107
108/** 108/**
109 * sk_stream_wait_memory - Wait for more memory for a socket 109 * sk_stream_wait_memory - Wait for more memory for a socket
110 * @sk - socket to wait for memory 110 * @sk: socket to wait for memory
111 * @timeo_p - for how long 111 * @timeo_p: for how long
112 */ 112 */
113int sk_stream_wait_memory(struct sock *sk, long *timeo_p) 113int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
114{ 114{
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index c2a0346f423b..ee7bf46eb78a 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -1411,21 +1411,22 @@ static struct file_operations dn_dev_seq_fops = {
1411 1411
1412#endif /* CONFIG_PROC_FS */ 1412#endif /* CONFIG_PROC_FS */
1413 1413
1414static struct rtnetlink_link dnet_rtnetlink_table[RTM_MAX-RTM_BASE+1] = 1414static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] =
1415{ 1415{
1416 [4] = { .doit = dn_dev_rtm_newaddr, }, 1416 [RTM_NEWADDR - RTM_BASE] = { .doit = dn_dev_rtm_newaddr, },
1417 [5] = { .doit = dn_dev_rtm_deladdr, }, 1417 [RTM_DELADDR - RTM_BASE] = { .doit = dn_dev_rtm_deladdr, },
1418 [6] = { .dumpit = dn_dev_dump_ifaddr, }, 1418 [RTM_GETADDR - RTM_BASE] = { .dumpit = dn_dev_dump_ifaddr, },
1419
1420#ifdef CONFIG_DECNET_ROUTER 1419#ifdef CONFIG_DECNET_ROUTER
1421 [8] = { .doit = dn_fib_rtm_newroute, }, 1420 [RTM_NEWROUTE - RTM_BASE] = { .doit = dn_fib_rtm_newroute, },
1422 [9] = { .doit = dn_fib_rtm_delroute, }, 1421 [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, },
1423 [10] = { .doit = dn_cache_getroute, .dumpit = dn_fib_dump, }, 1422 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
1424 [16] = { .doit = dn_fib_rtm_newrule, }, 1423 .dumpit = dn_fib_dump, },
1425 [17] = { .doit = dn_fib_rtm_delrule, }, 1424 [RTM_NEWRULE - RTM_BASE] = { .doit = dn_fib_rtm_newrule, },
1426 [18] = { .dumpit = dn_fib_dump_rules, }, 1425 [RTM_DELRULE - RTM_BASE] = { .doit = dn_fib_rtm_delrule, },
1426 [RTM_GETRULE - RTM_BASE] = { .dumpit = dn_fib_dump_rules, },
1427#else 1427#else
1428 [10] = { .doit = dn_cache_getroute, .dumpit = dn_cache_dump, }, 1428 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
1429 .dumpit = dn_cache_dump, },
1429#endif 1430#endif
1430 1431
1431}; 1432};
diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
index f86a6259fd12..284a9998e53d 100644
--- a/net/decnet/netfilter/dn_rtmsg.c
+++ b/net/decnet/netfilter/dn_rtmsg.c
@@ -119,8 +119,9 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
119static void dnrmg_receive_user_sk(struct sock *sk, int len) 119static void dnrmg_receive_user_sk(struct sock *sk, int len)
120{ 120{
121 struct sk_buff *skb; 121 struct sk_buff *skb;
122 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
122 123
123 while((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 124 for (; qlen && (skb = skb_dequeue(&sk->sk_receive_queue)); qlen--) {
124 dnrmg_receive_user_skb(skb); 125 dnrmg_receive_user_skb(skb);
125 kfree_skb(skb); 126 kfree_skb(skb);
126 } 127 }
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 16c4234cbe12..6617ea47d365 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)eth.c 1.0.7 05/25/93 8 * Version: @(#)eth.c 1.0.7 05/25/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Florian La Roche, <rzsfl@rz.uni-sb.de> 13 * Florian La Roche, <rzsfl@rz.uni-sb.de>
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index c34dab67e461..b3cb49ce5fad 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: af_inet.c,v 1.137 2002/02/01 22:01:03 davem Exp $ 8 * Version: $Id: af_inet.c,v 1.137 2002/02/01 22:01:03 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Florian La Roche, <flla@stud.uni-sb.de> 12 * Florian La Roche, <flla@stud.uni-sb.de>
13 * Alan Cox, <A.Cox@swansea.ac.uk> 13 * Alan Cox, <A.Cox@swansea.ac.uk>
@@ -73,7 +73,6 @@
73#include <linux/socket.h> 73#include <linux/socket.h>
74#include <linux/in.h> 74#include <linux/in.h>
75#include <linux/kernel.h> 75#include <linux/kernel.h>
76#include <linux/major.h>
77#include <linux/module.h> 76#include <linux/module.h>
78#include <linux/sched.h> 77#include <linux/sched.h>
79#include <linux/timer.h> 78#include <linux/timer.h>
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index eea7ef010776..3cc96730c4ed 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -9,7 +9,7 @@
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 * 10 *
11 * Derived from the IP parts of dev.c 1.0.19 11 * Derived from the IP parts of dev.c 1.0.19
12 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 12 * Authors: Ross Biro
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Mark Evans, <evansmp@uhura.aston.ac.uk> 14 * Mark Evans, <evansmp@uhura.aston.ac.uk>
15 * 15 *
@@ -1107,17 +1107,18 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa)
1107 } 1107 }
1108} 1108}
1109 1109
1110static struct rtnetlink_link inet_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = { 1110static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = {
1111 [4] = { .doit = inet_rtm_newaddr, }, 1111 [RTM_NEWADDR - RTM_BASE] = { .doit = inet_rtm_newaddr, },
1112 [5] = { .doit = inet_rtm_deladdr, }, 1112 [RTM_DELADDR - RTM_BASE] = { .doit = inet_rtm_deladdr, },
1113 [6] = { .dumpit = inet_dump_ifaddr, }, 1113 [RTM_GETADDR - RTM_BASE] = { .dumpit = inet_dump_ifaddr, },
1114 [8] = { .doit = inet_rtm_newroute, }, 1114 [RTM_NEWROUTE - RTM_BASE] = { .doit = inet_rtm_newroute, },
1115 [9] = { .doit = inet_rtm_delroute, }, 1115 [RTM_DELROUTE - RTM_BASE] = { .doit = inet_rtm_delroute, },
1116 [10] = { .doit = inet_rtm_getroute, .dumpit = inet_dump_fib, }, 1116 [RTM_GETROUTE - RTM_BASE] = { .doit = inet_rtm_getroute,
1117 .dumpit = inet_dump_fib, },
1117#ifdef CONFIG_IP_MULTIPLE_TABLES 1118#ifdef CONFIG_IP_MULTIPLE_TABLES
1118 [16] = { .doit = inet_rtm_newrule, }, 1119 [RTM_NEWRULE - RTM_BASE] = { .doit = inet_rtm_newrule, },
1119 [17] = { .doit = inet_rtm_delrule, }, 1120 [RTM_DELRULE - RTM_BASE] = { .doit = inet_rtm_delrule, },
1120 [18] = { .dumpit = inet_dump_rules, }, 1121 [RTM_GETRULE - RTM_BASE] = { .dumpit = inet_dump_rules, },
1121#endif 1122#endif
1122}; 1123};
1123 1124
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index a0d0833034be..4e47a2658c7c 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: ip_input.c,v 1.55 2002/01/12 07:39:45 davem Exp $ 8 * Version: $Id: ip_input.c,v 1.55 2002/01/12 07:39:45 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald Becker, <becker@super.org> 12 * Donald Becker, <becker@super.org>
13 * Alan Cox, <Alan.Cox@linux.org> 13 * Alan Cox, <Alan.Cox@linux.org>
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 30ab7b6ab761..daebd93fd8a0 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: ip_output.c,v 1.100 2002/02/01 22:01:03 davem Exp $ 8 * Version: $Id: ip_output.c,v 1.100 2002/02/01 22:01:03 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald Becker, <becker@super.org> 12 * Donald Becker, <becker@super.org>
13 * Alan Cox, <Alan.Cox@linux.org> 13 * Alan Cox, <Alan.Cox@linux.org>
@@ -111,6 +111,7 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb)
111#ifdef CONFIG_NETFILTER_DEBUG 111#ifdef CONFIG_NETFILTER_DEBUG
112 nf_debug_ip_loopback_xmit(newskb); 112 nf_debug_ip_loopback_xmit(newskb);
113#endif 113#endif
114 nf_reset(newskb);
114 netif_rx(newskb); 115 netif_rx(newskb);
115 return 0; 116 return 0;
116} 117}
@@ -195,6 +196,8 @@ static inline int ip_finish_output2(struct sk_buff *skb)
195 nf_debug_ip_finish_output2(skb); 196 nf_debug_ip_finish_output2(skb);
196#endif /*CONFIG_NETFILTER_DEBUG*/ 197#endif /*CONFIG_NETFILTER_DEBUG*/
197 198
199 nf_reset(skb);
200
198 if (hh) { 201 if (hh) {
199 int hh_alen; 202 int hh_alen;
200 203
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
index 10b23e1bece6..c3d2ca1a6781 100644
--- a/net/ipv4/multipath_wrandom.c
+++ b/net/ipv4/multipath_wrandom.c
@@ -172,7 +172,7 @@ static void wrandom_select_route(const struct flowi *flp,
172 multipath_comparekeys(&rt->fl, flp)) { 172 multipath_comparekeys(&rt->fl, flp)) {
173 struct multipath_candidate* mpc = 173 struct multipath_candidate* mpc =
174 (struct multipath_candidate*) 174 (struct multipath_candidate*)
175 kmalloc(size_mpc, GFP_KERNEL); 175 kmalloc(size_mpc, GFP_ATOMIC);
176 176
177 if (!mpc) 177 if (!mpc)
178 return; 178 return;
@@ -244,7 +244,7 @@ static void wrandom_set_nhinfo(__u32 network,
244 if (!target_route) { 244 if (!target_route) {
245 const size_t size_rt = sizeof(struct multipath_route); 245 const size_t size_rt = sizeof(struct multipath_route);
246 target_route = (struct multipath_route *) 246 target_route = (struct multipath_route *)
247 kmalloc(size_rt, GFP_KERNEL); 247 kmalloc(size_rt, GFP_ATOMIC);
248 248
249 target_route->gw = nh->nh_gw; 249 target_route->gw = nh->nh_gw;
250 target_route->oif = nh->nh_oif; 250 target_route->oif = nh->nh_oif;
@@ -265,7 +265,7 @@ static void wrandom_set_nhinfo(__u32 network,
265 if (!target_dest) { 265 if (!target_dest) {
266 const size_t size_dst = sizeof(struct multipath_dest); 266 const size_t size_dst = sizeof(struct multipath_dest);
267 target_dest = (struct multipath_dest*) 267 target_dest = (struct multipath_dest*)
268 kmalloc(size_dst, GFP_KERNEL); 268 kmalloc(size_dst, GFP_ATOMIC);
269 269
270 target_dest->nh_info = nh; 270 target_dest->nh_info = nh;
271 target_dest->network = network; 271 target_dest->network = network;
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index 12b88cbb11db..dd86503aa788 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -252,7 +252,7 @@ static int find_pattern(const char *data, size_t dlen,
252} 252}
253 253
254/* Look up to see if we're just after a \n. */ 254/* Look up to see if we're just after a \n. */
255static int find_nl_seq(u16 seq, const struct ip_ct_ftp_master *info, int dir) 255static int find_nl_seq(u32 seq, const struct ip_ct_ftp_master *info, int dir)
256{ 256{
257 unsigned int i; 257 unsigned int i;
258 258
@@ -263,7 +263,7 @@ static int find_nl_seq(u16 seq, const struct ip_ct_ftp_master *info, int dir)
263} 263}
264 264
265/* We don't update if it's older than what we have. */ 265/* We don't update if it's older than what we have. */
266static void update_nl_seq(u16 nl_seq, struct ip_ct_ftp_master *info, int dir) 266static void update_nl_seq(u32 nl_seq, struct ip_ct_ftp_master *info, int dir)
267{ 267{
268 unsigned int i, oldest = NUM_SEQ_TO_REMEMBER; 268 unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
269 269
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index e800b16fc920..721ddbf522b4 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -770,6 +770,7 @@ static u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] =
770{ 770{
771 [TH_SYN] = 1, 771 [TH_SYN] = 1,
772 [TH_SYN|TH_ACK] = 1, 772 [TH_SYN|TH_ACK] = 1,
773 [TH_SYN|TH_ACK|TH_PUSH] = 1,
773 [TH_RST] = 1, 774 [TH_RST] = 1,
774 [TH_RST|TH_ACK] = 1, 775 [TH_RST|TH_ACK] = 1,
775 [TH_RST|TH_ACK|TH_PUSH] = 1, 776 [TH_RST|TH_ACK|TH_PUSH] = 1,
@@ -818,6 +819,7 @@ static int tcp_error(struct sk_buff *skb,
818 */ 819 */
819 /* FIXME: Source route IP option packets --RR */ 820 /* FIXME: Source route IP option packets --RR */
820 if (hooknum == NF_IP_PRE_ROUTING 821 if (hooknum == NF_IP_PRE_ROUTING
822 && skb->ip_summed != CHECKSUM_UNNECESSARY
821 && csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP, 823 && csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP,
822 skb->ip_summed == CHECKSUM_HW ? skb->csum 824 skb->ip_summed == CHECKSUM_HW ? skb->csum
823 : skb_checksum(skb, iph->ihl*4, tcplen, 0))) { 825 : skb_checksum(skb, iph->ihl*4, tcplen, 0))) {
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 80a7bde2a57a..46ca45f74d85 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -401,6 +401,16 @@ static unsigned int ip_confirm(unsigned int hooknum,
401 const struct net_device *out, 401 const struct net_device *out,
402 int (*okfn)(struct sk_buff *)) 402 int (*okfn)(struct sk_buff *))
403{ 403{
404 /* We've seen it coming out the other side: confirm it */
405 return ip_conntrack_confirm(pskb);
406}
407
408static unsigned int ip_conntrack_help(unsigned int hooknum,
409 struct sk_buff **pskb,
410 const struct net_device *in,
411 const struct net_device *out,
412 int (*okfn)(struct sk_buff *))
413{
404 struct ip_conntrack *ct; 414 struct ip_conntrack *ct;
405 enum ip_conntrack_info ctinfo; 415 enum ip_conntrack_info ctinfo;
406 416
@@ -412,9 +422,7 @@ static unsigned int ip_confirm(unsigned int hooknum,
412 if (ret != NF_ACCEPT) 422 if (ret != NF_ACCEPT)
413 return ret; 423 return ret;
414 } 424 }
415 425 return NF_ACCEPT;
416 /* We've seen it coming out the other side: confirm it */
417 return ip_conntrack_confirm(pskb);
418} 426}
419 427
420static unsigned int ip_conntrack_defrag(unsigned int hooknum, 428static unsigned int ip_conntrack_defrag(unsigned int hooknum,
@@ -423,13 +431,6 @@ static unsigned int ip_conntrack_defrag(unsigned int hooknum,
423 const struct net_device *out, 431 const struct net_device *out,
424 int (*okfn)(struct sk_buff *)) 432 int (*okfn)(struct sk_buff *))
425{ 433{
426#if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
427 /* Previously seen (loopback)? Ignore. Do this before
428 fragment check. */
429 if ((*pskb)->nfct)
430 return NF_ACCEPT;
431#endif
432
433 /* Gather fragments. */ 434 /* Gather fragments. */
434 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) { 435 if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
435 *pskb = ip_ct_gather_frags(*pskb, 436 *pskb = ip_ct_gather_frags(*pskb,
@@ -516,13 +517,30 @@ static struct nf_hook_ops ip_conntrack_local_out_ops = {
516 .priority = NF_IP_PRI_CONNTRACK, 517 .priority = NF_IP_PRI_CONNTRACK,
517}; 518};
518 519
520/* helpers */
521static struct nf_hook_ops ip_conntrack_helper_out_ops = {
522 .hook = ip_conntrack_help,
523 .owner = THIS_MODULE,
524 .pf = PF_INET,
525 .hooknum = NF_IP_POST_ROUTING,
526 .priority = NF_IP_PRI_CONNTRACK_HELPER,
527};
528
529static struct nf_hook_ops ip_conntrack_helper_in_ops = {
530 .hook = ip_conntrack_help,
531 .owner = THIS_MODULE,
532 .pf = PF_INET,
533 .hooknum = NF_IP_LOCAL_IN,
534 .priority = NF_IP_PRI_CONNTRACK_HELPER,
535};
536
519/* Refragmenter; last chance. */ 537/* Refragmenter; last chance. */
520static struct nf_hook_ops ip_conntrack_out_ops = { 538static struct nf_hook_ops ip_conntrack_out_ops = {
521 .hook = ip_refrag, 539 .hook = ip_refrag,
522 .owner = THIS_MODULE, 540 .owner = THIS_MODULE,
523 .pf = PF_INET, 541 .pf = PF_INET,
524 .hooknum = NF_IP_POST_ROUTING, 542 .hooknum = NF_IP_POST_ROUTING,
525 .priority = NF_IP_PRI_LAST, 543 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
526}; 544};
527 545
528static struct nf_hook_ops ip_conntrack_local_in_ops = { 546static struct nf_hook_ops ip_conntrack_local_in_ops = {
@@ -530,7 +548,7 @@ static struct nf_hook_ops ip_conntrack_local_in_ops = {
530 .owner = THIS_MODULE, 548 .owner = THIS_MODULE,
531 .pf = PF_INET, 549 .pf = PF_INET,
532 .hooknum = NF_IP_LOCAL_IN, 550 .hooknum = NF_IP_LOCAL_IN,
533 .priority = NF_IP_PRI_LAST-1, 551 .priority = NF_IP_PRI_CONNTRACK_CONFIRM,
534}; 552};
535 553
536/* Sysctl support */ 554/* Sysctl support */
@@ -831,10 +849,20 @@ static int init_or_cleanup(int init)
831 printk("ip_conntrack: can't register local out hook.\n"); 849 printk("ip_conntrack: can't register local out hook.\n");
832 goto cleanup_inops; 850 goto cleanup_inops;
833 } 851 }
852 ret = nf_register_hook(&ip_conntrack_helper_in_ops);
853 if (ret < 0) {
854 printk("ip_conntrack: can't register local in helper hook.\n");
855 goto cleanup_inandlocalops;
856 }
857 ret = nf_register_hook(&ip_conntrack_helper_out_ops);
858 if (ret < 0) {
859 printk("ip_conntrack: can't register postrouting helper hook.\n");
860 goto cleanup_helperinops;
861 }
834 ret = nf_register_hook(&ip_conntrack_out_ops); 862 ret = nf_register_hook(&ip_conntrack_out_ops);
835 if (ret < 0) { 863 if (ret < 0) {
836 printk("ip_conntrack: can't register post-routing hook.\n"); 864 printk("ip_conntrack: can't register post-routing hook.\n");
837 goto cleanup_inandlocalops; 865 goto cleanup_helperoutops;
838 } 866 }
839 ret = nf_register_hook(&ip_conntrack_local_in_ops); 867 ret = nf_register_hook(&ip_conntrack_local_in_ops);
840 if (ret < 0) { 868 if (ret < 0) {
@@ -860,6 +888,10 @@ static int init_or_cleanup(int init)
860 nf_unregister_hook(&ip_conntrack_local_in_ops); 888 nf_unregister_hook(&ip_conntrack_local_in_ops);
861 cleanup_inoutandlocalops: 889 cleanup_inoutandlocalops:
862 nf_unregister_hook(&ip_conntrack_out_ops); 890 nf_unregister_hook(&ip_conntrack_out_ops);
891 cleanup_helperoutops:
892 nf_unregister_hook(&ip_conntrack_helper_out_ops);
893 cleanup_helperinops:
894 nf_unregister_hook(&ip_conntrack_helper_in_ops);
863 cleanup_inandlocalops: 895 cleanup_inandlocalops:
864 nf_unregister_hook(&ip_conntrack_local_out_ops); 896 nf_unregister_hook(&ip_conntrack_local_out_ops);
865 cleanup_inops: 897 cleanup_inops:
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
index 162ceacfc29a..9fc6f93af0dd 100644
--- a/net/ipv4/netfilter/ip_nat_core.c
+++ b/net/ipv4/netfilter/ip_nat_core.c
@@ -356,15 +356,6 @@ unsigned int nat_packet(struct ip_conntrack *ct,
356 unsigned long statusbit; 356 unsigned long statusbit;
357 enum ip_nat_manip_type mtype = HOOK2MANIP(hooknum); 357 enum ip_nat_manip_type mtype = HOOK2MANIP(hooknum);
358 358
359 if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)
360 && (hooknum == NF_IP_POST_ROUTING || hooknum == NF_IP_LOCAL_IN)) {
361 DEBUGP("ip_nat_core: adjusting sequence number\n");
362 /* future: put this in a l4-proto specific function,
363 * and call this function here. */
364 if (!ip_nat_seq_adjust(pskb, ct, ctinfo))
365 return NF_DROP;
366 }
367
368 if (mtype == IP_NAT_MANIP_SRC) 359 if (mtype == IP_NAT_MANIP_SRC)
369 statusbit = IPS_SRC_NAT; 360 statusbit = IPS_SRC_NAT;
370 else 361 else
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index dec4a74212cd..79f56f662b33 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -230,6 +230,25 @@ ip_nat_local_fn(unsigned int hooknum,
230 return ret; 230 return ret;
231} 231}
232 232
233static unsigned int
234ip_nat_adjust(unsigned int hooknum,
235 struct sk_buff **pskb,
236 const struct net_device *in,
237 const struct net_device *out,
238 int (*okfn)(struct sk_buff *))
239{
240 struct ip_conntrack *ct;
241 enum ip_conntrack_info ctinfo;
242
243 ct = ip_conntrack_get(*pskb, &ctinfo);
244 if (ct && test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)) {
245 DEBUGP("ip_nat_standalone: adjusting sequence number\n");
246 if (!ip_nat_seq_adjust(pskb, ct, ctinfo))
247 return NF_DROP;
248 }
249 return NF_ACCEPT;
250}
251
233/* We must be after connection tracking and before packet filtering. */ 252/* We must be after connection tracking and before packet filtering. */
234 253
235/* Before packet filtering, change destination */ 254/* Before packet filtering, change destination */
@@ -250,6 +269,15 @@ static struct nf_hook_ops ip_nat_out_ops = {
250 .priority = NF_IP_PRI_NAT_SRC, 269 .priority = NF_IP_PRI_NAT_SRC,
251}; 270};
252 271
272/* After conntrack, adjust sequence number */
273static struct nf_hook_ops ip_nat_adjust_out_ops = {
274 .hook = ip_nat_adjust,
275 .owner = THIS_MODULE,
276 .pf = PF_INET,
277 .hooknum = NF_IP_POST_ROUTING,
278 .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
279};
280
253/* Before packet filtering, change destination */ 281/* Before packet filtering, change destination */
254static struct nf_hook_ops ip_nat_local_out_ops = { 282static struct nf_hook_ops ip_nat_local_out_ops = {
255 .hook = ip_nat_local_fn, 283 .hook = ip_nat_local_fn,
@@ -268,6 +296,16 @@ static struct nf_hook_ops ip_nat_local_in_ops = {
268 .priority = NF_IP_PRI_NAT_SRC, 296 .priority = NF_IP_PRI_NAT_SRC,
269}; 297};
270 298
299/* After conntrack, adjust sequence number */
300static struct nf_hook_ops ip_nat_adjust_in_ops = {
301 .hook = ip_nat_adjust,
302 .owner = THIS_MODULE,
303 .pf = PF_INET,
304 .hooknum = NF_IP_LOCAL_IN,
305 .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
306};
307
308
271static int init_or_cleanup(int init) 309static int init_or_cleanup(int init)
272{ 310{
273 int ret = 0; 311 int ret = 0;
@@ -296,10 +334,20 @@ static int init_or_cleanup(int init)
296 printk("ip_nat_init: can't register out hook.\n"); 334 printk("ip_nat_init: can't register out hook.\n");
297 goto cleanup_inops; 335 goto cleanup_inops;
298 } 336 }
337 ret = nf_register_hook(&ip_nat_adjust_in_ops);
338 if (ret < 0) {
339 printk("ip_nat_init: can't register adjust in hook.\n");
340 goto cleanup_outops;
341 }
342 ret = nf_register_hook(&ip_nat_adjust_out_ops);
343 if (ret < 0) {
344 printk("ip_nat_init: can't register adjust out hook.\n");
345 goto cleanup_adjustin_ops;
346 }
299 ret = nf_register_hook(&ip_nat_local_out_ops); 347 ret = nf_register_hook(&ip_nat_local_out_ops);
300 if (ret < 0) { 348 if (ret < 0) {
301 printk("ip_nat_init: can't register local out hook.\n"); 349 printk("ip_nat_init: can't register local out hook.\n");
302 goto cleanup_outops; 350 goto cleanup_adjustout_ops;;
303 } 351 }
304 ret = nf_register_hook(&ip_nat_local_in_ops); 352 ret = nf_register_hook(&ip_nat_local_in_ops);
305 if (ret < 0) { 353 if (ret < 0) {
@@ -312,6 +360,10 @@ static int init_or_cleanup(int init)
312 nf_unregister_hook(&ip_nat_local_in_ops); 360 nf_unregister_hook(&ip_nat_local_in_ops);
313 cleanup_localoutops: 361 cleanup_localoutops:
314 nf_unregister_hook(&ip_nat_local_out_ops); 362 nf_unregister_hook(&ip_nat_local_out_ops);
363 cleanup_adjustout_ops:
364 nf_unregister_hook(&ip_nat_adjust_out_ops);
365 cleanup_adjustin_ops:
366 nf_unregister_hook(&ip_nat_adjust_in_ops);
315 cleanup_outops: 367 cleanup_outops:
316 nf_unregister_hook(&ip_nat_out_ops); 368 nf_unregister_hook(&ip_nat_out_ops);
317 cleanup_inops: 369 cleanup_inops:
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 9e40dffc204f..e5746b674413 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -546,20 +546,18 @@ ipq_rcv_skb(struct sk_buff *skb)
546static void 546static void
547ipq_rcv_sk(struct sock *sk, int len) 547ipq_rcv_sk(struct sock *sk, int len)
548{ 548{
549 do { 549 struct sk_buff *skb;
550 struct sk_buff *skb; 550 unsigned int qlen;
551 551
552 if (down_trylock(&ipqnl_sem)) 552 down(&ipqnl_sem);
553 return;
554 553
555 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 554 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
556 ipq_rcv_skb(skb); 555 skb = skb_dequeue(&sk->sk_receive_queue);
557 kfree_skb(skb); 556 ipq_rcv_skb(skb);
558 } 557 kfree_skb(skb);
558 }
559 559
560 up(&ipqnl_sem); 560 up(&ipqnl_sem);
561
562 } while (ipqnl && ipqnl->sk_receive_queue.qlen);
563} 561}
564 562
565static int 563static int
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 01b4a3c814d3..47449ba83eb9 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -103,13 +103,15 @@ static struct nf_hook_ops ipt_ops[] = {
103 .hook = ipt_hook, 103 .hook = ipt_hook,
104 .pf = PF_INET, 104 .pf = PF_INET,
105 .hooknum = NF_IP_PRE_ROUTING, 105 .hooknum = NF_IP_PRE_ROUTING,
106 .priority = NF_IP_PRI_RAW 106 .priority = NF_IP_PRI_RAW,
107 .owner = THIS_MODULE,
107 }, 108 },
108 { 109 {
109 .hook = ipt_hook, 110 .hook = ipt_hook,
110 .pf = PF_INET, 111 .pf = PF_INET,
111 .hooknum = NF_IP_LOCAL_OUT, 112 .hooknum = NF_IP_LOCAL_OUT,
112 .priority = NF_IP_PRI_RAW 113 .priority = NF_IP_PRI_RAW,
114 .owner = THIS_MODULE,
113 }, 115 },
114}; 116};
115 117
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c
index 90a587cacaa4..0db405a869f2 100644
--- a/net/ipv4/protocol.c
+++ b/net/ipv4/protocol.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: protocol.c,v 1.14 2001/05/18 02:25:49 davem Exp $ 8 * Version: $Id: protocol.c,v 1.14 2001/05/18 02:25:49 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * Fixes: 13 * Fixes:
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 93624a32eb9a..5b1ec586bae6 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: raw.c,v 1.64 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: raw.c,v 1.64 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * 12 *
13 * Fixes: 13 * Fixes:
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index bb90a0c3a91e..a682d28e247b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: route.c,v 1.103 2002/01/12 07:44:09 davem Exp $ 8 * Version: $Id: route.c,v 1.103 2002/01/12 07:44:09 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Alan Cox, <gw4pts@gw4pts.ampr.org> 12 * Alan Cox, <gw4pts@gw4pts.ampr.org>
13 * Linus Torvalds, <Linus.Torvalds@helsinki.fi> 13 * Linus Torvalds, <Linus.Torvalds@helsinki.fi>
@@ -397,7 +397,7 @@ static int rt_cpu_seq_show(struct seq_file *seq, void *v)
397 struct rt_cache_stat *st = v; 397 struct rt_cache_stat *st = v;
398 398
399 if (v == SEQ_START_TOKEN) { 399 if (v == SEQ_START_TOKEN) {
400 seq_printf(seq, "entries in_hit in_slow_tot in_no_route in_brd in_martian_dst in_martian_src out_hit out_slow_tot out_slow_mc gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search\n"); 400 seq_printf(seq, "entries in_hit in_slow_tot in_slow_mc in_no_route in_brd in_martian_dst in_martian_src out_hit out_slow_tot out_slow_mc gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search\n");
401 return 0; 401 return 0;
402 } 402 }
403 403
@@ -2843,7 +2843,7 @@ ctl_table ipv4_route_table[] = {
2843 .procname = "flush", 2843 .procname = "flush",
2844 .data = &flush_delay, 2844 .data = &flush_delay,
2845 .maxlen = sizeof(int), 2845 .maxlen = sizeof(int),
2846 .mode = 0644, 2846 .mode = 0200,
2847 .proc_handler = &ipv4_sysctl_rtcache_flush, 2847 .proc_handler = &ipv4_sysctl_rtcache_flush,
2848 .strategy = &ipv4_sysctl_rtcache_flush_strategy, 2848 .strategy = &ipv4_sysctl_rtcache_flush_strategy,
2849 }, 2849 },
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5cff56af7855..a037bafcba3c 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: tcp.c,v 1.216 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: tcp.c,v 1.216 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Corey Minyard <wf-rch!minyard@relay.EU.net> 13 * Corey Minyard <wf-rch!minyard@relay.EU.net>
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 313c1408da33..8faa8948f75c 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -777,8 +777,9 @@ static inline void tcpdiag_rcv_skb(struct sk_buff *skb)
777static void tcpdiag_rcv(struct sock *sk, int len) 777static void tcpdiag_rcv(struct sock *sk, int len)
778{ 778{
779 struct sk_buff *skb; 779 struct sk_buff *skb;
780 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
780 781
781 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 782 while (qlen-- && (skb = skb_dequeue(&sk->sk_receive_queue))) {
782 tcpdiag_rcv_skb(skb); 783 tcpdiag_rcv_skb(skb);
783 kfree_skb(skb); 784 kfree_skb(skb);
784 } 785 }
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 250492735902..79835a67a274 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: tcp_input.c,v 1.243 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: tcp_input.c,v 1.243 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Corey Minyard <wf-rch!minyard@relay.EU.net> 13 * Corey Minyard <wf-rch!minyard@relay.EU.net>
@@ -3517,7 +3517,6 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
3517 if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) 3517 if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq)
3518 goto drop; 3518 goto drop;
3519 3519
3520 th = skb->h.th;
3521 __skb_pull(skb, th->doff*4); 3520 __skb_pull(skb, th->doff*4);
3522 3521
3523 TCP_ECN_accept_cwr(tp, skb); 3522 TCP_ECN_accept_cwr(tp, skb);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3ac6659869c4..dad98e4a5043 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -222,10 +222,13 @@ static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
222 int rover; 222 int rover;
223 223
224 spin_lock(&tcp_portalloc_lock); 224 spin_lock(&tcp_portalloc_lock);
225 rover = tcp_port_rover; 225 if (tcp_port_rover < low)
226 rover = low;
227 else
228 rover = tcp_port_rover;
226 do { 229 do {
227 rover++; 230 rover++;
228 if (rover < low || rover > high) 231 if (rover > high)
229 rover = low; 232 rover = low;
230 head = &tcp_bhash[tcp_bhashfn(rover)]; 233 head = &tcp_bhash[tcp_bhashfn(rover)];
231 spin_lock(&head->lock); 234 spin_lock(&head->lock);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index fd70509f0d53..eea1a17a9ac2 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: tcp_minisocks.c,v 1.15 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: tcp_minisocks.c,v 1.15 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Corey Minyard <wf-rch!minyard@relay.EU.net> 13 * Corey Minyard <wf-rch!minyard@relay.EU.net>
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 13c14cb6dee4..fa24e7ae1f40 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: tcp_output.c,v 1.146 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: tcp_output.c,v 1.146 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Corey Minyard <wf-rch!minyard@relay.EU.net> 13 * Corey Minyard <wf-rch!minyard@relay.EU.net>
@@ -427,7 +427,7 @@ void tcp_push_one(struct sock *sk, unsigned cur_mss)
427 struct tcp_sock *tp = tcp_sk(sk); 427 struct tcp_sock *tp = tcp_sk(sk);
428 struct sk_buff *skb = sk->sk_send_head; 428 struct sk_buff *skb = sk->sk_send_head;
429 429
430 if (tcp_snd_test(tp, skb, cur_mss, TCP_NAGLE_PUSH)) { 430 if (tcp_snd_test(sk, skb, cur_mss, TCP_NAGLE_PUSH)) {
431 /* Send it out now. */ 431 /* Send it out now. */
432 TCP_SKB_CB(skb)->when = tcp_time_stamp; 432 TCP_SKB_CB(skb)->when = tcp_time_stamp;
433 tcp_tso_set_push(skb); 433 tcp_tso_set_push(skb);
@@ -440,9 +440,12 @@ void tcp_push_one(struct sock *sk, unsigned cur_mss)
440 } 440 }
441} 441}
442 442
443void tcp_set_skb_tso_segs(struct sk_buff *skb, unsigned int mss_std) 443void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb)
444{ 444{
445 if (skb->len <= mss_std) { 445 struct tcp_sock *tp = tcp_sk(sk);
446
447 if (skb->len <= tp->mss_cache_std ||
448 !(sk->sk_route_caps & NETIF_F_TSO)) {
446 /* Avoid the costly divide in the normal 449 /* Avoid the costly divide in the normal
447 * non-TSO case. 450 * non-TSO case.
448 */ 451 */
@@ -451,10 +454,10 @@ void tcp_set_skb_tso_segs(struct sk_buff *skb, unsigned int mss_std)
451 } else { 454 } else {
452 unsigned int factor; 455 unsigned int factor;
453 456
454 factor = skb->len + (mss_std - 1); 457 factor = skb->len + (tp->mss_cache_std - 1);
455 factor /= mss_std; 458 factor /= tp->mss_cache_std;
456 skb_shinfo(skb)->tso_segs = factor; 459 skb_shinfo(skb)->tso_segs = factor;
457 skb_shinfo(skb)->tso_size = mss_std; 460 skb_shinfo(skb)->tso_size = tp->mss_cache_std;
458 } 461 }
459} 462}
460 463
@@ -525,8 +528,8 @@ static int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len)
525 } 528 }
526 529
527 /* Fix up tso_factor for both original and new SKB. */ 530 /* Fix up tso_factor for both original and new SKB. */
528 tcp_set_skb_tso_segs(skb, tp->mss_cache_std); 531 tcp_set_skb_tso_segs(sk, skb);
529 tcp_set_skb_tso_segs(buff, tp->mss_cache_std); 532 tcp_set_skb_tso_segs(sk, buff);
530 533
531 if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) { 534 if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST) {
532 tp->lost_out += tcp_skb_pcount(skb); 535 tp->lost_out += tcp_skb_pcount(skb);
@@ -601,7 +604,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
601 * factor and mss. 604 * factor and mss.
602 */ 605 */
603 if (tcp_skb_pcount(skb) > 1) 606 if (tcp_skb_pcount(skb) > 1)
604 tcp_set_skb_tso_segs(skb, tcp_skb_mss(skb)); 607 tcp_set_skb_tso_segs(sk, skb);
605 608
606 return 0; 609 return 0;
607} 610}
@@ -752,7 +755,7 @@ int tcp_write_xmit(struct sock *sk, int nonagle)
752 mss_now = tcp_current_mss(sk, 1); 755 mss_now = tcp_current_mss(sk, 1);
753 756
754 while ((skb = sk->sk_send_head) && 757 while ((skb = sk->sk_send_head) &&
755 tcp_snd_test(tp, skb, mss_now, 758 tcp_snd_test(sk, skb, mss_now,
756 tcp_skb_is_last(sk, skb) ? nonagle : 759 tcp_skb_is_last(sk, skb) ? nonagle :
757 TCP_NAGLE_PUSH)) { 760 TCP_NAGLE_PUSH)) {
758 if (skb->len > mss_now) { 761 if (skb->len > mss_now) {
@@ -1676,7 +1679,7 @@ int tcp_write_wakeup(struct sock *sk)
1676 tp->mss_cache = tp->mss_cache_std; 1679 tp->mss_cache = tp->mss_cache_std;
1677 } 1680 }
1678 } else if (!tcp_skb_pcount(skb)) 1681 } else if (!tcp_skb_pcount(skb))
1679 tcp_set_skb_tso_segs(skb, tp->mss_cache_std); 1682 tcp_set_skb_tso_segs(sk, skb);
1680 1683
1681 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH; 1684 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH;
1682 TCP_SKB_CB(skb)->when = tcp_time_stamp; 1685 TCP_SKB_CB(skb)->when = tcp_time_stamp;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 85b279f1e935..799ebe061e2c 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: tcp_timer.c,v 1.88 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: tcp_timer.c,v 1.88 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Mark Evans, <evansmp@uhura.aston.ac.uk> 12 * Mark Evans, <evansmp@uhura.aston.ac.uk>
13 * Corey Minyard <wf-rch!minyard@relay.EU.net> 13 * Corey Minyard <wf-rch!minyard@relay.EU.net>
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 8a213238f287..4a6952e3fee9 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: udp.c,v 1.102 2002/02/01 22:01:04 davem Exp $ 8 * Version: $Id: udp.c,v 1.102 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Arnt Gulbrandsen, <agulbra@nvg.unit.no> 12 * Arnt Gulbrandsen, <agulbra@nvg.unit.no>
13 * Alan Cox, <Alan.Cox@linux.org> 13 * Alan Cox, <Alan.Cox@linux.org>
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 7fe2afd2e669..b2b60f3e9cdd 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -8,7 +8,10 @@
8 * 8 *
9 */ 9 */
10 10
11#include <asm/bug.h>
12#include <linux/compiler.h>
11#include <linux/config.h> 13#include <linux/config.h>
14#include <linux/inetdevice.h>
12#include <net/xfrm.h> 15#include <net/xfrm.h>
13#include <net/ip.h> 16#include <net/ip.h>
14 17
@@ -152,6 +155,8 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
152 x->u.rt.rt_dst = rt0->rt_dst; 155 x->u.rt.rt_dst = rt0->rt_dst;
153 x->u.rt.rt_gateway = rt->rt_gateway; 156 x->u.rt.rt_gateway = rt->rt_gateway;
154 x->u.rt.rt_spec_dst = rt0->rt_spec_dst; 157 x->u.rt.rt_spec_dst = rt0->rt_spec_dst;
158 x->u.rt.idev = rt0->idev;
159 in_dev_hold(rt0->idev);
155 header_len -= x->u.dst.xfrm->props.header_len; 160 header_len -= x->u.dst.xfrm->props.header_len;
156 trailer_len -= x->u.dst.xfrm->props.trailer_len; 161 trailer_len -= x->u.dst.xfrm->props.trailer_len;
157 } 162 }
@@ -243,11 +248,48 @@ static void xfrm4_update_pmtu(struct dst_entry *dst, u32 mtu)
243 path->ops->update_pmtu(path, mtu); 248 path->ops->update_pmtu(path, mtu);
244} 249}
245 250
251static void xfrm4_dst_destroy(struct dst_entry *dst)
252{
253 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
254
255 if (likely(xdst->u.rt.idev))
256 in_dev_put(xdst->u.rt.idev);
257 xfrm_dst_destroy(xdst);
258}
259
260static void xfrm4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
261 int unregister)
262{
263 struct xfrm_dst *xdst;
264
265 if (!unregister)
266 return;
267
268 xdst = (struct xfrm_dst *)dst;
269 if (xdst->u.rt.idev->dev == dev) {
270 struct in_device *loopback_idev = in_dev_get(&loopback_dev);
271 BUG_ON(!loopback_idev);
272
273 do {
274 in_dev_put(xdst->u.rt.idev);
275 xdst->u.rt.idev = loopback_idev;
276 in_dev_hold(loopback_idev);
277 xdst = (struct xfrm_dst *)xdst->u.dst.child;
278 } while (xdst->u.dst.xfrm);
279
280 __in_dev_put(loopback_idev);
281 }
282
283 xfrm_dst_ifdown(dst, dev);
284}
285
246static struct dst_ops xfrm4_dst_ops = { 286static struct dst_ops xfrm4_dst_ops = {
247 .family = AF_INET, 287 .family = AF_INET,
248 .protocol = __constant_htons(ETH_P_IP), 288 .protocol = __constant_htons(ETH_P_IP),
249 .gc = xfrm4_garbage_collect, 289 .gc = xfrm4_garbage_collect,
250 .update_pmtu = xfrm4_update_pmtu, 290 .update_pmtu = xfrm4_update_pmtu,
291 .destroy = xfrm4_dst_destroy,
292 .ifdown = xfrm4_dst_ifdown,
251 .gc_thresh = 1024, 293 .gc_thresh = 1024,
252 .entry_size = sizeof(struct xfrm_dst), 294 .entry_size = sizeof(struct xfrm_dst),
253}; 295};
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7196ac2f2d16..7744a2592693 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3076,7 +3076,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3076 netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC); 3076 netlink_broadcast(rtnl, skb, 0, RTMGRP_IPV6_PREFIX, GFP_ATOMIC);
3077} 3077}
3078 3078
3079static struct rtnetlink_link inet6_rtnetlink_table[RTM_MAX - RTM_BASE + 1] = { 3079static struct rtnetlink_link inet6_rtnetlink_table[RTM_NR_MSGTYPES] = {
3080 [RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, }, 3080 [RTM_GETLINK - RTM_BASE] = { .dumpit = inet6_dump_ifinfo, },
3081 [RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, }, 3081 [RTM_NEWADDR - RTM_BASE] = { .doit = inet6_rtm_newaddr, },
3082 [RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, }, 3082 [RTM_DELADDR - RTM_BASE] = { .doit = inet6_rtm_deladdr, },
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 768b11703daf..2b193e3df49a 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -28,7 +28,6 @@
28#include <linux/socket.h> 28#include <linux/socket.h>
29#include <linux/in.h> 29#include <linux/in.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/major.h>
32#include <linux/sched.h> 31#include <linux/sched.h>
33#include <linux/timer.h> 32#include <linux/timer.h>
34#include <linux/string.h> 33#include <linux/string.h>
@@ -88,6 +87,7 @@ int sysctl_ipv6_bindv6only;
88 87
89#ifdef INET_REFCNT_DEBUG 88#ifdef INET_REFCNT_DEBUG
90atomic_t inet6_sock_nr; 89atomic_t inet6_sock_nr;
90EXPORT_SYMBOL(inet6_sock_nr);
91#endif 91#endif
92 92
93/* The inetsw table contains everything that inet_create needs to 93/* The inetsw table contains everything that inet_create needs to
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 6dda815c013f..315bc1fbec3f 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -41,8 +41,8 @@ int ipv6_ext_hdr(u8 nexthdr)
41 * when Linux implements ESP (and maybe AUTH) headers. 41 * when Linux implements ESP (and maybe AUTH) headers.
42 * --AK 42 * --AK
43 * 43 *
44 * This function parses (probably truncated) exthdr set "hdr" 44 * This function parses (probably truncated) exthdr set "hdr".
45 * of length "len". "nexthdrp" initially points to some place, 45 * "nexthdrp" initially points to some place,
46 * where type of the first header can be found. 46 * where type of the first header can be found.
47 * 47 *
48 * It skips all well-known exthdrs, and returns pointer to the start 48 * It skips all well-known exthdrs, and returns pointer to the start
@@ -63,7 +63,7 @@ int ipv6_ext_hdr(u8 nexthdr)
63 * --ANK (980726) 63 * --ANK (980726)
64 */ 64 */
65 65
66int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp, int len) 66int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp)
67{ 67{
68 u8 nexthdr = *nexthdrp; 68 u8 nexthdr = *nexthdrp;
69 69
@@ -71,13 +71,11 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp, int len
71 struct ipv6_opt_hdr _hdr, *hp; 71 struct ipv6_opt_hdr _hdr, *hp;
72 int hdrlen; 72 int hdrlen;
73 73
74 if (len < (int)sizeof(struct ipv6_opt_hdr))
75 return -1;
76 if (nexthdr == NEXTHDR_NONE) 74 if (nexthdr == NEXTHDR_NONE)
77 return -1; 75 return -1;
78 hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr); 76 hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
79 if (hp == NULL) 77 if (hp == NULL)
80 BUG(); 78 return -1;
81 if (nexthdr == NEXTHDR_FRAGMENT) { 79 if (nexthdr == NEXTHDR_FRAGMENT) {
82 unsigned short _frag_off, *fp; 80 unsigned short _frag_off, *fp;
83 fp = skb_header_pointer(skb, 81 fp = skb_header_pointer(skb,
@@ -97,7 +95,6 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp, int len
97 hdrlen = ipv6_optlen(hp); 95 hdrlen = ipv6_optlen(hp);
98 96
99 nexthdr = hp->nexthdr; 97 nexthdr = hp->nexthdr;
100 len -= hdrlen;
101 start += hdrlen; 98 start += hdrlen;
102 } 99 }
103 100
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 87b9082ceab2..8e0f569b883e 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -135,7 +135,7 @@ static int is_ineligible(struct sk_buff *skb)
135 if (len < 0) 135 if (len < 0)
136 return 1; 136 return 1;
137 137
138 ptr = ipv6_skip_exthdr(skb, ptr, &nexthdr, len); 138 ptr = ipv6_skip_exthdr(skb, ptr, &nexthdr);
139 if (ptr < 0) 139 if (ptr < 0)
140 return 0; 140 return 0;
141 if (nexthdr == IPPROTO_ICMPV6) { 141 if (nexthdr == IPPROTO_ICMPV6) {
@@ -514,7 +514,7 @@ static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info)
514 nexthdr = ((struct ipv6hdr *)skb->data)->nexthdr; 514 nexthdr = ((struct ipv6hdr *)skb->data)->nexthdr;
515 if (ipv6_ext_hdr(nexthdr)) { 515 if (ipv6_ext_hdr(nexthdr)) {
516 /* now skip over extension headers */ 516 /* now skip over extension headers */
517 inner_offset = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr, skb->len - sizeof(struct ipv6hdr)); 517 inner_offset = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr);
518 if (inner_offset<0) 518 if (inner_offset<0)
519 return; 519 return;
520 } else { 520 } else {
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index c54830b89593..750943e2d34e 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -549,20 +549,18 @@ ipq_rcv_skb(struct sk_buff *skb)
549static void 549static void
550ipq_rcv_sk(struct sock *sk, int len) 550ipq_rcv_sk(struct sock *sk, int len)
551{ 551{
552 do { 552 struct sk_buff *skb;
553 struct sk_buff *skb; 553 unsigned int qlen;
554 554
555 if (down_trylock(&ipqnl_sem)) 555 down(&ipqnl_sem);
556 return;
557 556
558 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 557 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
559 ipq_rcv_skb(skb); 558 skb = skb_dequeue(&sk->sk_receive_queue);
560 kfree_skb(skb); 559 ipq_rcv_skb(skb);
561 } 560 kfree_skb(skb);
561 }
562 562
563 up(&ipqnl_sem); 563 up(&ipqnl_sem);
564
565 } while (ipqnl && ipqnl->sk_receive_queue.qlen);
566} 564}
567 565
568static int 566static int
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 1352c1d9bf4d..617645bc5ed6 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -455,11 +455,11 @@ csum_copy_err:
455static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, 455static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
456 struct raw6_sock *rp) 456 struct raw6_sock *rp)
457{ 457{
458 struct inet_sock *inet = inet_sk(sk);
459 struct sk_buff *skb; 458 struct sk_buff *skb;
460 int err = 0; 459 int err = 0;
461 int offset; 460 int offset;
462 int len; 461 int len;
462 int total_len;
463 u32 tmp_csum; 463 u32 tmp_csum;
464 u16 csum; 464 u16 csum;
465 465
@@ -470,7 +470,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
470 goto out; 470 goto out;
471 471
472 offset = rp->offset; 472 offset = rp->offset;
473 if (offset >= inet->cork.length - 1) { 473 total_len = inet_sk(sk)->cork.length - (skb->nh.raw - skb->data);
474 if (offset >= total_len - 1) {
474 err = -EINVAL; 475 err = -EINVAL;
475 ip6_flush_pending_frames(sk); 476 ip6_flush_pending_frames(sk);
476 goto out; 477 goto out;
@@ -514,7 +515,7 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
514 515
515 tmp_csum = csum_ipv6_magic(&fl->fl6_src, 516 tmp_csum = csum_ipv6_magic(&fl->fl6_src,
516 &fl->fl6_dst, 517 &fl->fl6_dst,
517 inet->cork.length, fl->proto, tmp_csum); 518 total_len, fl->proto, tmp_csum);
518 519
519 if (tmp_csum == 0) 520 if (tmp_csum == 0)
520 tmp_csum = -1; 521 tmp_csum = -1;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 183802902c02..3bf8a0254f81 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2005,7 +2005,7 @@ ctl_table ipv6_route_table[] = {
2005 .procname = "flush", 2005 .procname = "flush",
2006 .data = &flush_delay, 2006 .data = &flush_delay,
2007 .maxlen = sizeof(int), 2007 .maxlen = sizeof(int),
2008 .mode = 0644, 2008 .mode = 0200,
2009 .proc_handler = &ipv6_sysctl_rtcache_flush 2009 .proc_handler = &ipv6_sysctl_rtcache_flush
2010 }, 2010 },
2011 { 2011 {
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4760c85e19db..0f69e800a0ad 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -139,9 +139,12 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
139 int rover; 139 int rover;
140 140
141 spin_lock(&tcp_portalloc_lock); 141 spin_lock(&tcp_portalloc_lock);
142 rover = tcp_port_rover; 142 if (tcp_port_rover < low)
143 rover = low;
144 else
145 rover = tcp_port_rover;
143 do { rover++; 146 do { rover++;
144 if ((rover < low) || (rover > high)) 147 if (rover > high)
145 rover = low; 148 rover = low;
146 head = &tcp_bhash[tcp_bhashfn(rover)]; 149 head = &tcp_bhash[tcp_bhashfn(rover)];
147 spin_lock(&head->lock); 150 spin_lock(&head->lock);
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 8a4f37de4d2d..4429b1a1fe5f 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -11,7 +11,11 @@
11 * 11 *
12 */ 12 */
13 13
14#include <asm/bug.h>
15#include <linux/compiler.h>
14#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/netdevice.h>
18#include <net/addrconf.h>
15#include <net/xfrm.h> 19#include <net/xfrm.h>
16#include <net/ip.h> 20#include <net/ip.h>
17#include <net/ipv6.h> 21#include <net/ipv6.h>
@@ -166,6 +170,8 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
166 memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway)); 170 memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway));
167 x->u.rt6.rt6i_dst = rt0->rt6i_dst; 171 x->u.rt6.rt6i_dst = rt0->rt6i_dst;
168 x->u.rt6.rt6i_src = rt0->rt6i_src; 172 x->u.rt6.rt6i_src = rt0->rt6i_src;
173 x->u.rt6.rt6i_idev = rt0->rt6i_idev;
174 in6_dev_hold(rt0->rt6i_idev);
169 header_len -= x->u.dst.xfrm->props.header_len; 175 header_len -= x->u.dst.xfrm->props.header_len;
170 trailer_len -= x->u.dst.xfrm->props.trailer_len; 176 trailer_len -= x->u.dst.xfrm->props.trailer_len;
171 } 177 }
@@ -251,11 +257,48 @@ static void xfrm6_update_pmtu(struct dst_entry *dst, u32 mtu)
251 path->ops->update_pmtu(path, mtu); 257 path->ops->update_pmtu(path, mtu);
252} 258}
253 259
260static void xfrm6_dst_destroy(struct dst_entry *dst)
261{
262 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
263
264 if (likely(xdst->u.rt6.rt6i_idev))
265 in6_dev_put(xdst->u.rt6.rt6i_idev);
266 xfrm_dst_destroy(xdst);
267}
268
269static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
270 int unregister)
271{
272 struct xfrm_dst *xdst;
273
274 if (!unregister)
275 return;
276
277 xdst = (struct xfrm_dst *)dst;
278 if (xdst->u.rt6.rt6i_idev->dev == dev) {
279 struct inet6_dev *loopback_idev = in6_dev_get(&loopback_dev);
280 BUG_ON(!loopback_idev);
281
282 do {
283 in6_dev_put(xdst->u.rt6.rt6i_idev);
284 xdst->u.rt6.rt6i_idev = loopback_idev;
285 in6_dev_hold(loopback_idev);
286 xdst = (struct xfrm_dst *)xdst->u.dst.child;
287 } while (xdst->u.dst.xfrm);
288
289 __in6_dev_put(loopback_idev);
290 }
291
292 xfrm_dst_ifdown(dst, dev);
293}
294
254static struct dst_ops xfrm6_dst_ops = { 295static struct dst_ops xfrm6_dst_ops = {
255 .family = AF_INET6, 296 .family = AF_INET6,
256 .protocol = __constant_htons(ETH_P_IPV6), 297 .protocol = __constant_htons(ETH_P_IPV6),
257 .gc = xfrm6_garbage_collect, 298 .gc = xfrm6_garbage_collect,
258 .update_pmtu = xfrm6_update_pmtu, 299 .update_pmtu = xfrm6_update_pmtu,
300 .destroy = xfrm6_dst_destroy,
301 .ifdown = xfrm6_dst_ifdown,
259 .gc_thresh = 1024, 302 .gc_thresh = 1024,
260 .entry_size = sizeof(struct xfrm_dst), 303 .entry_size = sizeof(struct xfrm_dst),
261}; 304};
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index d6ccd3239dcf..70543d89438b 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -470,6 +470,7 @@ void irda_device_unregister_dongle(struct dongle_reg *dongle)
470} 470}
471EXPORT_SYMBOL(irda_device_unregister_dongle); 471EXPORT_SYMBOL(irda_device_unregister_dongle);
472 472
473#ifdef CONFIG_ISA_DMA_API
473/* 474/*
474 * Function setup_dma (idev, buffer, count, mode) 475 * Function setup_dma (idev, buffer, count, mode)
475 * 476 *
@@ -492,3 +493,4 @@ void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode)
492 release_dma_lock(flags); 493 release_dma_lock(flags);
493} 494}
494EXPORT_SYMBOL(irda_setup_dma); 495EXPORT_SYMBOL(irda_setup_dma);
496#endif
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 1d5905c90cd4..733bf52cef3e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/major.h>
25#include <linux/signal.h> 24#include <linux/signal.h>
26#include <linux/sched.h> 25#include <linux/sched.h>
27#include <linux/errno.h> 26#include <linux/errno.h>
@@ -50,6 +49,8 @@
50#include <linux/bitops.h> 49#include <linux/bitops.h>
51#include <linux/mm.h> 50#include <linux/mm.h>
52#include <linux/types.h> 51#include <linux/types.h>
52#include <linux/audit.h>
53
53#include <net/sock.h> 54#include <net/sock.h>
54#include <net/scm.h> 55#include <net/scm.h>
55 56
@@ -374,7 +375,6 @@ static int netlink_release(struct socket *sock)
374 nlk->cb->done(nlk->cb); 375 nlk->cb->done(nlk->cb);
375 netlink_destroy_callback(nlk->cb); 376 netlink_destroy_callback(nlk->cb);
376 nlk->cb = NULL; 377 nlk->cb = NULL;
377 __sock_put(sk);
378 } 378 }
379 spin_unlock(&nlk->cb_lock); 379 spin_unlock(&nlk->cb_lock);
380 380
@@ -906,6 +906,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
906 NETLINK_CB(skb).groups = nlk->groups; 906 NETLINK_CB(skb).groups = nlk->groups;
907 NETLINK_CB(skb).dst_pid = dst_pid; 907 NETLINK_CB(skb).dst_pid = dst_pid;
908 NETLINK_CB(skb).dst_groups = dst_groups; 908 NETLINK_CB(skb).dst_groups = dst_groups;
909 NETLINK_CB(skb).loginuid = audit_get_loginuid(current->audit_context);
909 memcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); 910 memcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
910 911
911 /* What can I do? Netlink is asynchronous, so that 912 /* What can I do? Netlink is asynchronous, so that
@@ -1100,7 +1101,6 @@ static int netlink_dump(struct sock *sk)
1100 spin_unlock(&nlk->cb_lock); 1101 spin_unlock(&nlk->cb_lock);
1101 1102
1102 netlink_destroy_callback(cb); 1103 netlink_destroy_callback(cb);
1103 __sock_put(sk);
1104 return 0; 1104 return 0;
1105} 1105}
1106 1106
@@ -1139,7 +1139,6 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
1139 return -EBUSY; 1139 return -EBUSY;
1140 } 1140 }
1141 nlk->cb = cb; 1141 nlk->cb = cb;
1142 sock_hold(sk);
1143 spin_unlock(&nlk->cb_lock); 1142 spin_unlock(&nlk->cb_lock);
1144 1143
1145 netlink_dump(sk); 1144 netlink_dump(sk);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 64acea0adaae..0269616e75a1 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: $Id: af_packet.c,v 1.61 2002/02/08 03:57:19 davem Exp $ 8 * Version: $Id: af_packet.c,v 1.61 2002/02/08 03:57:19 davem Exp $
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Alan Cox, <gw4pts@gw4pts.ampr.org> 12 * Alan Cox, <gw4pts@gw4pts.ampr.org>
13 * 13 *
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 3d1d902dd1a1..b0941186f867 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -185,7 +185,7 @@ config NET_SCH_GRED
185 depends on NET_SCHED 185 depends on NET_SCHED
186 help 186 help
187 Say Y here if you want to use the Generic Random Early Detection 187 Say Y here if you want to use the Generic Random Early Detection
188 (RED) packet scheduling algorithm for some of your network devices 188 (GRED) packet scheduling algorithm for some of your network devices
189 (see the top of <file:net/sched/sch_red.c> for details and 189 (see the top of <file:net/sched/sch_red.c> for details and
190 references about the algorithm). 190 references about the algorithm).
191 191
@@ -506,3 +506,13 @@ config NET_CLS_POLICE
506 Say Y to support traffic policing (bandwidth limits). Needed for 506 Say Y to support traffic policing (bandwidth limits). Needed for
507 ingress and egress rate limiting. 507 ingress and egress rate limiting.
508 508
509config NET_ACT_SIMP
510 tristate "Simple action"
511 depends on NET_CLS_ACT
512 ---help---
513 You must have new iproute2 to use this feature.
514 This adds a very simple action for demonstration purposes
515 The idea is to give action authors a basic example to look at.
516 All this action will do is print on the console the configured
517 policy string followed by _ then packet count.
518
diff --git a/net/sched/Makefile b/net/sched/Makefile
index 431e55786efd..eb3fe583eba8 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -6,13 +6,14 @@ obj-y := sch_generic.o
6 6
7obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o 7obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o
8obj-$(CONFIG_NET_CLS) += cls_api.o 8obj-$(CONFIG_NET_CLS) += cls_api.o
9obj-$(CONFIG_NET_CLS_ACT) += act_api.o 9obj-$(CONFIG_NET_CLS_ACT) += act_api.o
10obj-$(CONFIG_NET_ACT_POLICE) += police.o 10obj-$(CONFIG_NET_ACT_POLICE) += police.o
11obj-$(CONFIG_NET_CLS_POLICE) += police.o 11obj-$(CONFIG_NET_CLS_POLICE) += police.o
12obj-$(CONFIG_NET_ACT_GACT) += gact.o 12obj-$(CONFIG_NET_ACT_GACT) += gact.o
13obj-$(CONFIG_NET_ACT_MIRRED) += mirred.o 13obj-$(CONFIG_NET_ACT_MIRRED) += mirred.o
14obj-$(CONFIG_NET_ACT_IPT) += ipt.o 14obj-$(CONFIG_NET_ACT_IPT) += ipt.o
15obj-$(CONFIG_NET_ACT_PEDIT) += pedit.o 15obj-$(CONFIG_NET_ACT_PEDIT) += pedit.o
16obj-$(CONFIG_NET_ACT_SIMP) += simple.o
16obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o 17obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
17obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o 18obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
18obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o 19obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 5e6cc371b39e..cafcb084098d 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -171,10 +171,10 @@ repeat:
171 skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd); 171 skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd);
172 skb->tc_verd = CLR_TC_MUNGED(skb->tc_verd); 172 skb->tc_verd = CLR_TC_MUNGED(skb->tc_verd);
173 } 173 }
174 if (ret != TC_ACT_PIPE)
175 goto exec_done;
176 if (ret == TC_ACT_REPEAT) 174 if (ret == TC_ACT_REPEAT)
177 goto repeat; /* we need a ttl - JHS */ 175 goto repeat; /* we need a ttl - JHS */
176 if (ret != TC_ACT_PIPE)
177 goto exec_done;
178 } 178 }
179 act = a->next; 179 act = a->next;
180 } 180 }
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index fdfc83af3d1f..29d8b9a4d162 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -46,9 +46,11 @@
46#include <net/act_api.h> 46#include <net/act_api.h>
47#include <net/pkt_cls.h> 47#include <net/pkt_cls.h>
48 48
49#define HTSIZE (PAGE_SIZE/sizeof(struct fw_filter *))
50
49struct fw_head 51struct fw_head
50{ 52{
51 struct fw_filter *ht[256]; 53 struct fw_filter *ht[HTSIZE];
52}; 54};
53 55
54struct fw_filter 56struct fw_filter
@@ -69,7 +71,28 @@ static struct tcf_ext_map fw_ext_map = {
69 71
70static __inline__ int fw_hash(u32 handle) 72static __inline__ int fw_hash(u32 handle)
71{ 73{
72 return handle&0xFF; 74 if (HTSIZE == 4096)
75 return ((handle >> 24) & 0xFFF) ^
76 ((handle >> 12) & 0xFFF) ^
77 (handle & 0xFFF);
78 else if (HTSIZE == 2048)
79 return ((handle >> 22) & 0x7FF) ^
80 ((handle >> 11) & 0x7FF) ^
81 (handle & 0x7FF);
82 else if (HTSIZE == 1024)
83 return ((handle >> 20) & 0x3FF) ^
84 ((handle >> 10) & 0x3FF) ^
85 (handle & 0x3FF);
86 else if (HTSIZE == 512)
87 return (handle >> 27) ^
88 ((handle >> 18) & 0x1FF) ^
89 ((handle >> 9) & 0x1FF) ^
90 (handle & 0x1FF);
91 else if (HTSIZE == 256) {
92 u8 *t = (u8 *) &handle;
93 return t[0] ^ t[1] ^ t[2] ^ t[3];
94 } else
95 return handle & (HTSIZE - 1);
73} 96}
74 97
75static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp, 98static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp,
@@ -152,7 +175,7 @@ static void fw_destroy(struct tcf_proto *tp)
152 if (head == NULL) 175 if (head == NULL)
153 return; 176 return;
154 177
155 for (h=0; h<256; h++) { 178 for (h=0; h<HTSIZE; h++) {
156 while ((f=head->ht[h]) != NULL) { 179 while ((f=head->ht[h]) != NULL) {
157 head->ht[h] = f->next; 180 head->ht[h] = f->next;
158 fw_delete_filter(tp, f); 181 fw_delete_filter(tp, f);
@@ -291,7 +314,7 @@ static void fw_walk(struct tcf_proto *tp, struct tcf_walker *arg)
291 if (arg->stop) 314 if (arg->stop)
292 return; 315 return;
293 316
294 for (h = 0; h < 256; h++) { 317 for (h = 0; h < HTSIZE; h++) {
295 struct fw_filter *f; 318 struct fw_filter *f;
296 319
297 for (f = head->ht[h]; f; f = f->next) { 320 for (f = head->ht[h]; f; f = f->next) {
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 4323a74eea30..07977f8f2679 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1289,6 +1289,7 @@ static int __init pktsched_init(void)
1289 1289
1290subsys_initcall(pktsched_init); 1290subsys_initcall(pktsched_init);
1291 1291
1292EXPORT_SYMBOL(qdisc_lookup);
1292EXPORT_SYMBOL(qdisc_get_rtab); 1293EXPORT_SYMBOL(qdisc_get_rtab);
1293EXPORT_SYMBOL(qdisc_put_rtab); 1294EXPORT_SYMBOL(qdisc_put_rtab);
1294EXPORT_SYMBOL(register_qdisc); 1295EXPORT_SYMBOL(register_qdisc);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 8c01e023f02e..87e48a4e1051 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -179,6 +179,7 @@ requeue:
179 netif_schedule(dev); 179 netif_schedule(dev);
180 return 1; 180 return 1;
181 } 181 }
182 BUG_ON((int) q->q.qlen < 0);
182 return q->q.qlen; 183 return q->q.qlen;
183} 184}
184 185
@@ -539,6 +540,10 @@ void dev_activate(struct net_device *dev)
539 write_unlock_bh(&qdisc_tree_lock); 540 write_unlock_bh(&qdisc_tree_lock);
540 } 541 }
541 542
543 if (!netif_carrier_ok(dev))
544 /* Delay activation until next carrier-on event */
545 return;
546
542 spin_lock_bh(&dev->queue_lock); 547 spin_lock_bh(&dev->queue_lock);
543 rcu_assign_pointer(dev->qdisc, dev->qdisc_sleeping); 548 rcu_assign_pointer(dev->qdisc, dev->qdisc_sleeping);
544 if (dev->qdisc != &noqueue_qdisc) { 549 if (dev->qdisc != &noqueue_qdisc) {
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index a85935e7d53d..558cc087e602 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -717,6 +717,10 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch)
717 if (q->direct_queue.qlen < q->direct_qlen) { 717 if (q->direct_queue.qlen < q->direct_qlen) {
718 __skb_queue_tail(&q->direct_queue, skb); 718 __skb_queue_tail(&q->direct_queue, skb);
719 q->direct_pkts++; 719 q->direct_pkts++;
720 } else {
721 kfree_skb(skb);
722 sch->qstats.drops++;
723 return NET_XMIT_DROP;
720 } 724 }
721#ifdef CONFIG_NET_CLS_ACT 725#ifdef CONFIG_NET_CLS_ACT
722 } else if (!cl) { 726 } else if (!cl) {
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 31c29deb139d..e0c9fbe73b15 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -138,38 +138,77 @@ static long tabledist(unsigned long mu, long sigma,
138} 138}
139 139
140/* Put skb in the private delayed queue. */ 140/* Put skb in the private delayed queue. */
141static int delay_skb(struct Qdisc *sch, struct sk_buff *skb) 141static int netem_delay(struct Qdisc *sch, struct sk_buff *skb)
142{ 142{
143 struct netem_sched_data *q = qdisc_priv(sch); 143 struct netem_sched_data *q = qdisc_priv(sch);
144 struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
145 psched_tdiff_t td; 144 psched_tdiff_t td;
146 psched_time_t now; 145 psched_time_t now;
147 146
148 PSCHED_GET_TIME(now); 147 PSCHED_GET_TIME(now);
149 td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist); 148 td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
150 PSCHED_TADD2(now, td, cb->time_to_send);
151 149
152 /* Always queue at tail to keep packets in order */ 150 /* Always queue at tail to keep packets in order */
153 if (likely(q->delayed.qlen < q->limit)) { 151 if (likely(q->delayed.qlen < q->limit)) {
152 struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
153
154 PSCHED_TADD2(now, td, cb->time_to_send);
155
156 pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb,
157 now, cb->time_to_send);
158
154 __skb_queue_tail(&q->delayed, skb); 159 __skb_queue_tail(&q->delayed, skb);
155 if (!timer_pending(&q->timer)) {
156 q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
157 add_timer(&q->timer);
158 }
159 return NET_XMIT_SUCCESS; 160 return NET_XMIT_SUCCESS;
160 } 161 }
161 162
163 pr_debug("netem_delay: queue over limit %d\n", q->limit);
164 sch->qstats.overlimits++;
162 kfree_skb(skb); 165 kfree_skb(skb);
163 return NET_XMIT_DROP; 166 return NET_XMIT_DROP;
164} 167}
165 168
169/*
170 * Move a packet that is ready to send from the delay holding
171 * list to the underlying qdisc.
172 */
173static int netem_run(struct Qdisc *sch)
174{
175 struct netem_sched_data *q = qdisc_priv(sch);
176 struct sk_buff *skb;
177 psched_time_t now;
178
179 PSCHED_GET_TIME(now);
180
181 skb = skb_peek(&q->delayed);
182 if (skb) {
183 const struct netem_skb_cb *cb
184 = (const struct netem_skb_cb *)skb->cb;
185 long delay
186 = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
187 pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
188
189 /* if more time remaining? */
190 if (delay > 0) {
191 mod_timer(&q->timer, jiffies + delay);
192 return 1;
193 }
194
195 __skb_unlink(skb, &q->delayed);
196
197 if (q->qdisc->enqueue(skb, q->qdisc)) {
198 sch->q.qlen--;
199 sch->qstats.drops++;
200 }
201 }
202
203 return 0;
204}
205
166static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) 206static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
167{ 207{
168 struct netem_sched_data *q = qdisc_priv(sch); 208 struct netem_sched_data *q = qdisc_priv(sch);
169 struct sk_buff *skb2;
170 int ret; 209 int ret;
171 210
172 pr_debug("netem_enqueue skb=%p @%lu\n", skb, jiffies); 211 pr_debug("netem_enqueue skb=%p\n", skb);
173 212
174 /* Random packet drop 0 => none, ~0 => all */ 213 /* Random packet drop 0 => none, ~0 => all */
175 if (q->loss && q->loss >= get_crandom(&q->loss_cor)) { 214 if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
@@ -180,11 +219,21 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
180 } 219 }
181 220
182 /* Random duplication */ 221 /* Random duplication */
183 if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor) 222 if (q->duplicate && q->duplicate >= get_crandom(&q->dup_cor)) {
184 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) { 223 struct sk_buff *skb2;
185 pr_debug("netem_enqueue: dup %p\n", skb2); 224
225 skb2 = skb_clone(skb, GFP_ATOMIC);
226 if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
227 struct Qdisc *qp;
228
229 /* Since one packet can generate two packets in the
230 * queue, the parent's qlen accounting gets confused,
231 * so fix it.
232 */
233 qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
234 if (qp)
235 qp->q.qlen++;
186 236
187 if (delay_skb(sch, skb2)) {
188 sch->q.qlen++; 237 sch->q.qlen++;
189 sch->bstats.bytes += skb2->len; 238 sch->bstats.bytes += skb2->len;
190 sch->bstats.packets++; 239 sch->bstats.packets++;
@@ -202,7 +251,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
202 ret = q->qdisc->enqueue(skb, q->qdisc); 251 ret = q->qdisc->enqueue(skb, q->qdisc);
203 } else { 252 } else {
204 q->counter = 0; 253 q->counter = 0;
205 ret = delay_skb(sch, skb); 254 ret = netem_delay(sch, skb);
255 netem_run(sch);
206 } 256 }
207 257
208 if (likely(ret == NET_XMIT_SUCCESS)) { 258 if (likely(ret == NET_XMIT_SUCCESS)) {
@@ -212,6 +262,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
212 } else 262 } else
213 sch->qstats.drops++; 263 sch->qstats.drops++;
214 264
265 pr_debug("netem: enqueue ret %d\n", ret);
215 return ret; 266 return ret;
216} 267}
217 268
@@ -241,56 +292,35 @@ static unsigned int netem_drop(struct Qdisc* sch)
241 return len; 292 return len;
242} 293}
243 294
244/* Dequeue packet.
245 * Move all packets that are ready to send from the delay holding
246 * list to the underlying qdisc, then just call dequeue
247 */
248static struct sk_buff *netem_dequeue(struct Qdisc *sch) 295static struct sk_buff *netem_dequeue(struct Qdisc *sch)
249{ 296{
250 struct netem_sched_data *q = qdisc_priv(sch); 297 struct netem_sched_data *q = qdisc_priv(sch);
251 struct sk_buff *skb; 298 struct sk_buff *skb;
299 int pending;
300
301 pending = netem_run(sch);
252 302
253 skb = q->qdisc->dequeue(q->qdisc); 303 skb = q->qdisc->dequeue(q->qdisc);
254 if (skb) 304 if (skb) {
305 pr_debug("netem_dequeue: return skb=%p\n", skb);
255 sch->q.qlen--; 306 sch->q.qlen--;
307 sch->flags &= ~TCQ_F_THROTTLED;
308 }
309 else if (pending) {
310 pr_debug("netem_dequeue: throttling\n");
311 sch->flags |= TCQ_F_THROTTLED;
312 }
313
256 return skb; 314 return skb;
257} 315}
258 316
259static void netem_watchdog(unsigned long arg) 317static void netem_watchdog(unsigned long arg)
260{ 318{
261 struct Qdisc *sch = (struct Qdisc *)arg; 319 struct Qdisc *sch = (struct Qdisc *)arg;
262 struct netem_sched_data *q = qdisc_priv(sch);
263 struct net_device *dev = sch->dev;
264 struct sk_buff *skb;
265 psched_time_t now;
266
267 pr_debug("netem_watchdog: fired @%lu\n", jiffies);
268
269 spin_lock_bh(&dev->queue_lock);
270 PSCHED_GET_TIME(now);
271
272 while ((skb = skb_peek(&q->delayed)) != NULL) {
273 const struct netem_skb_cb *cb
274 = (const struct netem_skb_cb *)skb->cb;
275 long delay
276 = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
277 pr_debug("netem_watchdog: skb %p@%lu %ld\n",
278 skb, jiffies, delay);
279 320
280 /* if more time remaining? */ 321 pr_debug("netem_watchdog qlen=%d\n", sch->q.qlen);
281 if (delay > 0) { 322 sch->flags &= ~TCQ_F_THROTTLED;
282 mod_timer(&q->timer, jiffies + delay); 323 netif_schedule(sch->dev);
283 break;
284 }
285 __skb_unlink(skb, &q->delayed);
286
287 if (q->qdisc->enqueue(skb, q->qdisc)) {
288 sch->q.qlen--;
289 sch->qstats.drops++;
290 }
291 }
292 qdisc_run(dev);
293 spin_unlock_bh(&dev->queue_lock);
294} 324}
295 325
296static void netem_reset(struct Qdisc *sch) 326static void netem_reset(struct Qdisc *sch)
@@ -301,6 +331,7 @@ static void netem_reset(struct Qdisc *sch)
301 skb_queue_purge(&q->delayed); 331 skb_queue_purge(&q->delayed);
302 332
303 sch->q.qlen = 0; 333 sch->q.qlen = 0;
334 sch->flags &= ~TCQ_F_THROTTLED;
304 del_timer_sync(&q->timer); 335 del_timer_sync(&q->timer);
305} 336}
306 337
diff --git a/net/sched/simple.c b/net/sched/simple.c
new file mode 100644
index 000000000000..3ab4c675ab5d
--- /dev/null
+++ b/net/sched/simple.c
@@ -0,0 +1,93 @@
1/*
2 * net/sched/simp.c Simple example of an action
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Jamal Hadi Salim (2005)
10 *
11 */
12
13#include <linux/config.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/netdevice.h>
18#include <linux/skbuff.h>
19#include <linux/rtnetlink.h>
20#include <net/pkt_sched.h>
21
22#define TCA_ACT_SIMP 22
23
24/* XXX: Hide all these common elements under some macro
25 * probably
26*/
27#include <linux/tc_act/tc_defact.h>
28#include <net/tc_act/tc_defact.h>
29
30/* use generic hash table with 8 buckets */
31#define MY_TAB_SIZE 8
32#define MY_TAB_MASK (MY_TAB_SIZE - 1)
33static u32 idx_gen;
34static struct tcf_defact *tcf_simp_ht[MY_TAB_SIZE];
35static DEFINE_RWLOCK(simp_lock);
36
37/* override the defaults */
38#define tcf_st tcf_defact
39#define tc_st tc_defact
40#define tcf_t_lock simp_lock
41#define tcf_ht tcf_simp_ht
42
43#define CONFIG_NET_ACT_INIT 1
44#include <net/pkt_act.h>
45#include <net/act_generic.h>
46
47static int tcf_simp(struct sk_buff **pskb, struct tc_action *a)
48{
49 struct sk_buff *skb = *pskb;
50 struct tcf_defact *p = PRIV(a, defact);
51
52 spin_lock(&p->lock);
53 p->tm.lastuse = jiffies;
54 p->bstats.bytes += skb->len;
55 p->bstats.packets++;
56
57 /* print policy string followed by _ then packet count
58 * Example if this was the 3rd packet and the string was "hello"
59 * then it would look like "hello_3" (without quotes)
60 **/
61 printk("simple: %s_%d\n", (char *)p->defdata, p->bstats.packets);
62 spin_unlock(&p->lock);
63 return p->action;
64}
65
66static struct tc_action_ops act_simp_ops = {
67 .kind = "simple",
68 .type = TCA_ACT_SIMP,
69 .capab = TCA_CAP_NONE,
70 .owner = THIS_MODULE,
71 .act = tcf_simp,
72 tca_use_default_ops
73};
74
75MODULE_AUTHOR("Jamal Hadi Salim(2005)");
76MODULE_DESCRIPTION("Simple example action");
77MODULE_LICENSE("GPL");
78
79static int __init simp_init_module(void)
80{
81 int ret = tcf_register_action(&act_simp_ops);
82 if (!ret)
83 printk("Simple TC action Loaded\n");
84 return ret;
85}
86
87static void __exit simp_cleanup_module(void)
88{
89 tcf_unregister_action(&act_simp_ops);
90}
91
92module_init(simp_init_module);
93module_exit(simp_cleanup_module);
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 544b75077dbd..334f61773e6d 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -125,6 +125,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
125 sp->autoclose * HZ; 125 sp->autoclose * HZ;
126 126
127 /* Use SCTP specific send buffer space queues. */ 127 /* Use SCTP specific send buffer space queues. */
128 ep->sndbuf_policy = sctp_sndbuf_policy;
128 sk->sk_write_space = sctp_write_space; 129 sk->sk_write_space = sctp_write_space;
129 sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); 130 sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
130 131
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index e42c74e3ec1e..c9d9ea064734 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -496,9 +496,7 @@ static void sctp_v6_inaddr_any(union sctp_addr *addr, unsigned short port)
496/* Is this a wildcard address? */ 496/* Is this a wildcard address? */
497static int sctp_v6_is_any(const union sctp_addr *addr) 497static int sctp_v6_is_any(const union sctp_addr *addr)
498{ 498{
499 int type; 499 return ipv6_addr_any(&addr->v6.sin6_addr);
500 type = ipv6_addr_type((struct in6_addr *)&addr->v6.sin6_addr);
501 return IPV6_ADDR_ANY == type;
502} 500}
503 501
504/* Should this be available for binding? */ 502/* Should this be available for binding? */
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 9013f64f5219..84b5b370b09d 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -313,12 +313,12 @@ int sctp_packet_transmit(struct sctp_packet *packet)
313 sk = chunk->skb->sk; 313 sk = chunk->skb->sk;
314 314
315 /* Allocate the new skb. */ 315 /* Allocate the new skb. */
316 nskb = dev_alloc_skb(packet->size); 316 nskb = alloc_skb(packet->size + LL_MAX_HEADER, GFP_ATOMIC);
317 if (!nskb) 317 if (!nskb)
318 goto nomem; 318 goto nomem;
319 319
320 /* Make sure the outbound skb has enough header room reserved. */ 320 /* Make sure the outbound skb has enough header room reserved. */
321 skb_reserve(nskb, packet->overhead); 321 skb_reserve(nskb, packet->overhead + LL_MAX_HEADER);
322 322
323 /* Set the owning socket so that we know where to get the 323 /* Set the owning socket so that we know where to get the
324 * destination IP address. 324 * destination IP address.
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index b9813cf3d91c..2e1f9c3556f5 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1043,6 +1043,9 @@ SCTP_STATIC __init int sctp_init(void)
1043 sctp_max_retrans_path = 5; 1043 sctp_max_retrans_path = 5;
1044 sctp_max_retrans_init = 8; 1044 sctp_max_retrans_init = 8;
1045 1045
1046 /* Sendbuffer growth - do per-socket accounting */
1047 sctp_sndbuf_policy = 0;
1048
1046 /* HB.interval - 30 seconds */ 1049 /* HB.interval - 30 seconds */
1047 sctp_hb_interval = 30 * HZ; 1050 sctp_hb_interval = 30 * HZ;
1048 1051
@@ -1159,8 +1162,6 @@ SCTP_STATIC __init int sctp_init(void)
1159 status = 0; 1162 status = 0;
1160out: 1163out:
1161 return status; 1164 return status;
1162err_add_protocol:
1163 proto_unregister(&sctp_prot);
1164err_ctl_sock_init: 1165err_ctl_sock_init:
1165 sctp_v6_exit(); 1166 sctp_v6_exit();
1166err_v6_init: 1167err_v6_init:
@@ -1188,6 +1189,8 @@ err_bucket_cachep:
1188 inet_del_protocol(&sctp_protocol, IPPROTO_SCTP); 1189 inet_del_protocol(&sctp_protocol, IPPROTO_SCTP);
1189 inet_unregister_protosw(&sctp_seqpacket_protosw); 1190 inet_unregister_protosw(&sctp_seqpacket_protosw);
1190 inet_unregister_protosw(&sctp_stream_protosw); 1191 inet_unregister_protosw(&sctp_stream_protosw);
1192err_add_protocol:
1193 proto_unregister(&sctp_prot);
1191 goto out; 1194 goto out;
1192} 1195}
1193 1196
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 1db12cc18cf7..33ac8bf47b0e 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -710,7 +710,9 @@ struct sctp_chunk *sctp_make_shutdown_complete(
710 struct sctp_chunk *retval; 710 struct sctp_chunk *retval;
711 __u8 flags = 0; 711 __u8 flags = 0;
712 712
713 /* Maybe set the T-bit if we have no association. */ 713 /* Set the T-bit if we have no association (vtag will be
714 * reflected)
715 */
714 flags |= asoc ? 0 : SCTP_CHUNK_FLAG_T; 716 flags |= asoc ? 0 : SCTP_CHUNK_FLAG_T;
715 717
716 retval = sctp_make_chunk(asoc, SCTP_CID_SHUTDOWN_COMPLETE, flags, 0); 718 retval = sctp_make_chunk(asoc, SCTP_CID_SHUTDOWN_COMPLETE, flags, 0);
@@ -732,7 +734,7 @@ struct sctp_chunk *sctp_make_shutdown_complete(
732} 734}
733 735
734/* Create an ABORT. Note that we set the T bit if we have no 736/* Create an ABORT. Note that we set the T bit if we have no
735 * association. 737 * association, except when responding to an INIT (sctpimpguide 2.41).
736 */ 738 */
737struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc, 739struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc,
738 const struct sctp_chunk *chunk, 740 const struct sctp_chunk *chunk,
@@ -741,8 +743,16 @@ struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc,
741 struct sctp_chunk *retval; 743 struct sctp_chunk *retval;
742 __u8 flags = 0; 744 __u8 flags = 0;
743 745
744 /* Maybe set the T-bit if we have no association. */ 746 /* Set the T-bit if we have no association and 'chunk' is not
745 flags |= asoc ? 0 : SCTP_CHUNK_FLAG_T; 747 * an INIT (vtag will be reflected).
748 */
749 if (!asoc) {
750 if (chunk && chunk->chunk_hdr &&
751 chunk->chunk_hdr->type == SCTP_CID_INIT)
752 flags = 0;
753 else
754 flags = SCTP_CHUNK_FLAG_T;
755 }
746 756
747 retval = sctp_make_chunk(asoc, SCTP_CID_ABORT, flags, hint); 757 retval = sctp_make_chunk(asoc, SCTP_CID_ABORT, flags, hint);
748 758
@@ -2744,7 +2754,6 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
2744 2754
2745 hint = (nstreams + 1) * sizeof(__u32); 2755 hint = (nstreams + 1) * sizeof(__u32);
2746 2756
2747 /* Maybe set the T-bit if we have no association. */
2748 retval = sctp_make_chunk(asoc, SCTP_CID_FWD_TSN, 0, hint); 2757 retval = sctp_make_chunk(asoc, SCTP_CID_FWD_TSN, 0, hint);
2749 2758
2750 if (!retval) 2759 if (!retval)
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 278c56a2d076..8e01b8f09ac2 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -126,15 +126,18 @@ sctp_chunk_length_valid(struct sctp_chunk *chunk,
126 * should stop the T2-shutdown timer and remove all knowledge of the 126 * should stop the T2-shutdown timer and remove all knowledge of the
127 * association (and thus the association enters the CLOSED state). 127 * association (and thus the association enters the CLOSED state).
128 * 128 *
129 * Verification Tag: 8.5.1(C) 129 * Verification Tag: 8.5.1(C), sctpimpguide 2.41.
130 * C) Rules for packet carrying SHUTDOWN COMPLETE: 130 * C) Rules for packet carrying SHUTDOWN COMPLETE:
131 * ... 131 * ...
132 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet if the 132 * - The receiver of a SHUTDOWN COMPLETE shall accept the packet
133 * Verification Tag field of the packet matches its own tag OR it is 133 * if the Verification Tag field of the packet matches its own tag and
134 * set to its peer's tag and the T bit is set in the Chunk Flags. 134 * the T bit is not set
135 * Otherwise, the receiver MUST silently discard the packet and take 135 * OR
136 * no further action. An endpoint MUST ignore the SHUTDOWN COMPLETE if 136 * it is set to its peer's tag and the T bit is set in the Chunk
137 * it is not in the SHUTDOWN-ACK-SENT state. 137 * Flags.
138 * Otherwise, the receiver MUST silently discard the packet
139 * and take no further action. An endpoint MUST ignore the
140 * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
138 * 141 *
139 * Inputs 142 * Inputs
140 * (endpoint, asoc, chunk) 143 * (endpoint, asoc, chunk)
@@ -2858,16 +2861,16 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep,
2858/* 2861/*
2859 * Generate an ABORT in response to a packet. 2862 * Generate an ABORT in response to a packet.
2860 * 2863 *
2861 * Section: 8.4 Handle "Out of the blue" Packets 2864 * Section: 8.4 Handle "Out of the blue" Packets, sctpimpguide 2.41
2862 * 2865 *
2863 * 8) The receiver should respond to the sender of the OOTB packet 2866 * 8) The receiver should respond to the sender of the OOTB packet with
2864 * with an ABORT. When sending the ABORT, the receiver of the 2867 * an ABORT. When sending the ABORT, the receiver of the OOTB packet
2865 * OOTB packet MUST fill in the Verification Tag field of the 2868 * MUST fill in the Verification Tag field of the outbound packet
2866 * outbound packet with the value found in the Verification Tag 2869 * with the value found in the Verification Tag field of the OOTB
2867 * field of the OOTB packet and set the T-bit in the Chunk Flags 2870 * packet and set the T-bit in the Chunk Flags to indicate that the
2868 * to indicate that no TCB was found. After sending this ABORT, 2871 * Verification Tag is reflected. After sending this ABORT, the
2869 * the receiver of the OOTB packet shall discard the OOTB packet 2872 * receiver of the OOTB packet shall discard the OOTB packet and take
2870 * and take no further action. 2873 * no further action.
2871 * 2874 *
2872 * Verification Tag: 2875 * Verification Tag:
2873 * 2876 *
@@ -2895,6 +2898,10 @@ sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep,
2895 return SCTP_DISPOSITION_NOMEM; 2898 return SCTP_DISPOSITION_NOMEM;
2896 } 2899 }
2897 2900
2901 /* Reflect vtag if T-Bit is set */
2902 if (sctp_test_T_bit(abort))
2903 packet->vtag = ntohl(chunk->sctp_hdr->vtag);
2904
2898 /* Set the skb to the belonging sock for accounting. */ 2905 /* Set the skb to the belonging sock for accounting. */
2899 abort->skb->sk = ep->base.sk; 2906 abort->skb->sk = ep->base.sk;
2900 2907
@@ -3026,22 +3033,24 @@ nomem:
3026} 3033}
3027 3034
3028/* 3035/*
3029 * RFC 2960, 8.4 - Handle "Out of the blue" Packets 3036 * RFC 2960, 8.4 - Handle "Out of the blue" Packets, sctpimpguide 2.41.
3037 *
3030 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should 3038 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should
3031 * respond to the sender of the OOTB packet with a SHUTDOWN COMPLETE. 3039 * respond to the sender of the OOTB packet with a SHUTDOWN COMPLETE.
3032 * When sending the SHUTDOWN COMPLETE, the receiver of the OOTB 3040 * When sending the SHUTDOWN COMPLETE, the receiver of the OOTB
3033 * packet must fill in the Verification Tag field of the outbound 3041 * packet must fill in the Verification Tag field of the outbound
3034 * packet with the Verification Tag received in the SHUTDOWN ACK and 3042 * packet with the Verification Tag received in the SHUTDOWN ACK and
3035 * set the T-bit in the Chunk Flags to indicate that no TCB was 3043 * set the T-bit in the Chunk Flags to indicate that the Verification
3036 * found. Otherwise, 3044 * Tag is reflected.
3037 * 3045 *
3038 * 8) The receiver should respond to the sender of the OOTB packet with 3046 * 8) The receiver should respond to the sender of the OOTB packet with
3039 * an ABORT. When sending the ABORT, the receiver of the OOTB packet 3047 * an ABORT. When sending the ABORT, the receiver of the OOTB packet
3040 * MUST fill in the Verification Tag field of the outbound packet 3048 * MUST fill in the Verification Tag field of the outbound packet
3041 * with the value found in the Verification Tag field of the OOTB 3049 * with the value found in the Verification Tag field of the OOTB
3042 * packet and set the T-bit in the Chunk Flags to indicate that no 3050 * packet and set the T-bit in the Chunk Flags to indicate that the
3043 * TCB was found. After sending this ABORT, the receiver of the OOTB 3051 * Verification Tag is reflected. After sending this ABORT, the
3044 * packet shall discard the OOTB packet and take no further action. 3052 * receiver of the OOTB packet shall discard the OOTB packet and take
3053 * no further action.
3045 */ 3054 */
3046sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, 3055sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
3047 const struct sctp_association *asoc, 3056 const struct sctp_association *asoc,
@@ -3090,13 +3099,15 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
3090/* 3099/*
3091 * Handle an "Out of the blue" SHUTDOWN ACK. 3100 * Handle an "Out of the blue" SHUTDOWN ACK.
3092 * 3101 *
3093 * Section: 8.4 5) 3102 * Section: 8.4 5, sctpimpguide 2.41.
3103 *
3094 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should 3104 * 5) If the packet contains a SHUTDOWN ACK chunk, the receiver should
3095 * respond to the sender of the OOTB packet with a SHUTDOWN COMPLETE. 3105 * respond to the sender of the OOTB packet with a SHUTDOWN COMPLETE.
3096 * When sending the SHUTDOWN COMPLETE, the receiver of the OOTB packet 3106 * When sending the SHUTDOWN COMPLETE, the receiver of the OOTB
3097 * must fill in the Verification Tag field of the outbound packet with 3107 * packet must fill in the Verification Tag field of the outbound
3098 * the Verification Tag received in the SHUTDOWN ACK and set the 3108 * packet with the Verification Tag received in the SHUTDOWN ACK and
3099 * T-bit in the Chunk Flags to indicate that no TCB was found. 3109 * set the T-bit in the Chunk Flags to indicate that the Verification
3110 * Tag is reflected.
3100 * 3111 *
3101 * Inputs 3112 * Inputs
3102 * (endpoint, asoc, type, arg, commands) 3113 * (endpoint, asoc, type, arg, commands)
@@ -3128,6 +3139,10 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep,
3128 return SCTP_DISPOSITION_NOMEM; 3139 return SCTP_DISPOSITION_NOMEM;
3129 } 3140 }
3130 3141
3142 /* Reflect vtag if T-Bit is set */
3143 if (sctp_test_T_bit(shut))
3144 packet->vtag = ntohl(chunk->sctp_hdr->vtag);
3145
3131 /* Set the skb to the belonging sock for accounting. */ 3146 /* Set the skb to the belonging sock for accounting. */
3132 shut->skb->sk = ep->base.sk; 3147 shut->skb->sk = ep->base.sk;
3133 3148
@@ -3591,7 +3606,6 @@ sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep,
3591 * 3606 *
3592 * 2) If the OOTB packet contains an ABORT chunk, the receiver MUST 3607 * 2) If the OOTB packet contains an ABORT chunk, the receiver MUST
3593 * silently discard the OOTB packet and take no further action. 3608 * silently discard the OOTB packet and take no further action.
3594 * Otherwise,
3595 * 3609 *
3596 * Verification Tag: No verification necessary 3610 * Verification Tag: No verification necessary
3597 * 3611 *
@@ -4961,6 +4975,11 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep,
4961 sctp_ootb_pkt_free(packet); 4975 sctp_ootb_pkt_free(packet);
4962 return NULL; 4976 return NULL;
4963 } 4977 }
4978
4979 /* Reflect vtag if T-Bit is set */
4980 if (sctp_test_T_bit(abort))
4981 packet->vtag = ntohl(chunk->sctp_hdr->vtag);
4982
4964 /* Add specified error causes, i.e., payload, to the 4983 /* Add specified error causes, i.e., payload, to the
4965 * end of the chunk. 4984 * end of the chunk.
4966 */ 4985 */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e8c210182571..0b338eca6dc0 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -115,9 +115,17 @@ static inline int sctp_wspace(struct sctp_association *asoc)
115 struct sock *sk = asoc->base.sk; 115 struct sock *sk = asoc->base.sk;
116 int amt = 0; 116 int amt = 0;
117 117
118 amt = sk->sk_sndbuf - asoc->sndbuf_used; 118 if (asoc->ep->sndbuf_policy) {
119 /* make sure that no association uses more than sk_sndbuf */
120 amt = sk->sk_sndbuf - asoc->sndbuf_used;
121 } else {
122 /* do socket level accounting */
123 amt = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
124 }
125
119 if (amt < 0) 126 if (amt < 0)
120 amt = 0; 127 amt = 0;
128
121 return amt; 129 return amt;
122} 130}
123 131
@@ -138,12 +146,21 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)
138 /* The sndbuf space is tracked per association. */ 146 /* The sndbuf space is tracked per association. */
139 sctp_association_hold(asoc); 147 sctp_association_hold(asoc);
140 148
149 skb_set_owner_w(chunk->skb, sk);
150
141 chunk->skb->destructor = sctp_wfree; 151 chunk->skb->destructor = sctp_wfree;
142 /* Save the chunk pointer in skb for sctp_wfree to use later. */ 152 /* Save the chunk pointer in skb for sctp_wfree to use later. */
143 *((struct sctp_chunk **)(chunk->skb->cb)) = chunk; 153 *((struct sctp_chunk **)(chunk->skb->cb)) = chunk;
144 154
145 asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk); 155 asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk) +
146 sk->sk_wmem_queued += SCTP_DATA_SNDSIZE(chunk); 156 sizeof(struct sk_buff) +
157 sizeof(struct sctp_chunk);
158
159 sk->sk_wmem_queued += SCTP_DATA_SNDSIZE(chunk) +
160 sizeof(struct sk_buff) +
161 sizeof(struct sctp_chunk);
162
163 atomic_add(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc);
147} 164}
148 165
149/* Verify that this is a valid address. */ 166/* Verify that this is a valid address. */
@@ -3473,7 +3490,7 @@ static int sctp_getsockopt_associnfo(struct sock *sk, int len,
3473 return -EINVAL; 3490 return -EINVAL;
3474 3491
3475 /* Values correspoinding to the specific association */ 3492 /* Values correspoinding to the specific association */
3476 if (assocparams.sasoc_assoc_id != 0) { 3493 if (asoc) {
3477 assocparams.sasoc_asocmaxrxt = asoc->max_retrans; 3494 assocparams.sasoc_asocmaxrxt = asoc->max_retrans;
3478 assocparams.sasoc_peer_rwnd = asoc->peer.rwnd; 3495 assocparams.sasoc_peer_rwnd = asoc->peer.rwnd;
3479 assocparams.sasoc_local_rwnd = asoc->a_rwnd; 3496 assocparams.sasoc_local_rwnd = asoc->a_rwnd;
@@ -4422,8 +4439,17 @@ static void sctp_wfree(struct sk_buff *skb)
4422 chunk = *((struct sctp_chunk **)(skb->cb)); 4439 chunk = *((struct sctp_chunk **)(skb->cb));
4423 asoc = chunk->asoc; 4440 asoc = chunk->asoc;
4424 sk = asoc->base.sk; 4441 sk = asoc->base.sk;
4425 asoc->sndbuf_used -= SCTP_DATA_SNDSIZE(chunk); 4442 asoc->sndbuf_used -= SCTP_DATA_SNDSIZE(chunk) +
4426 sk->sk_wmem_queued -= SCTP_DATA_SNDSIZE(chunk); 4443 sizeof(struct sk_buff) +
4444 sizeof(struct sctp_chunk);
4445
4446 sk->sk_wmem_queued -= SCTP_DATA_SNDSIZE(chunk) +
4447 sizeof(struct sk_buff) +
4448 sizeof(struct sctp_chunk);
4449
4450 atomic_sub(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc);
4451
4452 sock_wfree(skb);
4427 __sctp_write_space(asoc); 4453 __sctp_write_space(asoc);
4428 4454
4429 sctp_association_put(asoc); 4455 sctp_association_put(asoc);
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 89fa20c73a5c..7fc31849312b 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -110,6 +110,14 @@ static ctl_table sctp_table[] = {
110 .proc_handler = &proc_dointvec 110 .proc_handler = &proc_dointvec
111 }, 111 },
112 { 112 {
113 .ctl_name = NET_SCTP_SNDBUF_POLICY,
114 .procname = "sndbuf_policy",
115 .data = &sctp_sndbuf_policy,
116 .maxlen = sizeof(int),
117 .mode = 0644,
118 .proc_handler = &proc_dointvec
119 },
120 {
113 .ctl_name = NET_SCTP_PATH_MAX_RETRANS, 121 .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
114 .procname = "path_max_retrans", 122 .procname = "path_max_retrans",
115 .data = &sctp_max_retrans_path, 123 .data = &sctp_max_retrans_path,
diff --git a/net/socket.c b/net/socket.c
index 2cd44990d8d3..cec0cb38b9ce 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -4,7 +4,7 @@
4 * Version: @(#)socket.c 1.1.93 18/02/95 4 * Version: @(#)socket.c 1.1.93 18/02/95
5 * 5 *
6 * Authors: Orest Zborowski, <obz@Kodak.COM> 6 * Authors: Orest Zborowski, <obz@Kodak.COM>
7 * Ross Biro, <bir7@leland.Stanford.Edu> 7 * Ross Biro
8 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 8 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
9 * 9 *
10 * Fixes: 10 * Fixes:
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 4484931018eb..67b9f035ba86 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -46,9 +46,9 @@ xdr_decode_netobj(u32 *p, struct xdr_netobj *obj)
46 46
47/** 47/**
48 * xdr_encode_opaque_fixed - Encode fixed length opaque data 48 * xdr_encode_opaque_fixed - Encode fixed length opaque data
49 * @p - pointer to current position in XDR buffer. 49 * @p: pointer to current position in XDR buffer.
50 * @ptr - pointer to data to encode (or NULL) 50 * @ptr: pointer to data to encode (or NULL)
51 * @nbytes - size of data. 51 * @nbytes: size of data.
52 * 52 *
53 * Copy the array of data of length nbytes at ptr to the XDR buffer 53 * Copy the array of data of length nbytes at ptr to the XDR buffer
54 * at position p, then align to the next 32-bit boundary by padding 54 * at position p, then align to the next 32-bit boundary by padding
@@ -76,9 +76,9 @@ EXPORT_SYMBOL(xdr_encode_opaque_fixed);
76 76
77/** 77/**
78 * xdr_encode_opaque - Encode variable length opaque data 78 * xdr_encode_opaque - Encode variable length opaque data
79 * @p - pointer to current position in XDR buffer. 79 * @p: pointer to current position in XDR buffer.
80 * @ptr - pointer to data to encode (or NULL) 80 * @ptr: pointer to data to encode (or NULL)
81 * @nbytes - size of data. 81 * @nbytes: size of data.
82 * 82 *
83 * Returns the updated current XDR buffer position 83 * Returns the updated current XDR buffer position
84 */ 84 */
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index acc73fe68698..c478fc8db776 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -85,7 +85,6 @@
85#include <linux/module.h> 85#include <linux/module.h>
86#include <linux/config.h> 86#include <linux/config.h>
87#include <linux/kernel.h> 87#include <linux/kernel.h>
88#include <linux/major.h>
89#include <linux/signal.h> 88#include <linux/signal.h>
90#include <linux/sched.h> 89#include <linux/sched.h>
91#include <linux/errno.h> 90#include <linux/errno.h>
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 956c17f6c548..d6844ac226f5 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -48,8 +48,8 @@
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/module.h> /* support for loadable modules */ 50#include <linux/module.h> /* support for loadable modules */
51#include <linux/slab.h> /* kmalloc(), kfree() */ 51#include <linux/slab.h> /* kmalloc(), kfree() */
52#include <linux/mm.h> /* verify_area(), etc. */ 52#include <linux/mm.h>
53#include <linux/string.h> /* inline mem*, str* functions */ 53#include <linux/string.h> /* inline mem*, str* functions */
54 54
55#include <asm/byteorder.h> /* htons(), etc. */ 55#include <asm/byteorder.h> /* htons(), etc. */
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 80828078733d..55ed979db144 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1028,30 +1028,15 @@ static int stale_bundle(struct dst_entry *dst)
1028 return !xfrm_bundle_ok((struct xfrm_dst *)dst, NULL, AF_UNSPEC); 1028 return !xfrm_bundle_ok((struct xfrm_dst *)dst, NULL, AF_UNSPEC);
1029} 1029}
1030 1030
1031static void xfrm_dst_destroy(struct dst_entry *dst) 1031void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
1032{ 1032{
1033 struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
1034
1035 dst_release(xdst->route);
1036
1037 if (!dst->xfrm)
1038 return;
1039 xfrm_state_put(dst->xfrm);
1040 dst->xfrm = NULL;
1041}
1042
1043static void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
1044 int unregister)
1045{
1046 if (!unregister)
1047 return;
1048
1049 while ((dst = dst->child) && dst->xfrm && dst->dev == dev) { 1033 while ((dst = dst->child) && dst->xfrm && dst->dev == dev) {
1050 dst->dev = &loopback_dev; 1034 dst->dev = &loopback_dev;
1051 dev_hold(&loopback_dev); 1035 dev_hold(&loopback_dev);
1052 dev_put(dev); 1036 dev_put(dev);
1053 } 1037 }
1054} 1038}
1039EXPORT_SYMBOL(xfrm_dst_ifdown);
1055 1040
1056static void xfrm_link_failure(struct sk_buff *skb) 1041static void xfrm_link_failure(struct sk_buff *skb)
1057{ 1042{
@@ -1262,10 +1247,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
1262 dst_ops->kmem_cachep = xfrm_dst_cache; 1247 dst_ops->kmem_cachep = xfrm_dst_cache;
1263 if (likely(dst_ops->check == NULL)) 1248 if (likely(dst_ops->check == NULL))
1264 dst_ops->check = xfrm_dst_check; 1249 dst_ops->check = xfrm_dst_check;
1265 if (likely(dst_ops->destroy == NULL))
1266 dst_ops->destroy = xfrm_dst_destroy;
1267 if (likely(dst_ops->ifdown == NULL))
1268 dst_ops->ifdown = xfrm_dst_ifdown;
1269 if (likely(dst_ops->negative_advice == NULL)) 1250 if (likely(dst_ops->negative_advice == NULL))
1270 dst_ops->negative_advice = xfrm_negative_advice; 1251 dst_ops->negative_advice = xfrm_negative_advice;
1271 if (likely(dst_ops->link_failure == NULL)) 1252 if (likely(dst_ops->link_failure == NULL))
@@ -1297,8 +1278,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
1297 xfrm_policy_afinfo[afinfo->family] = NULL; 1278 xfrm_policy_afinfo[afinfo->family] = NULL;
1298 dst_ops->kmem_cachep = NULL; 1279 dst_ops->kmem_cachep = NULL;
1299 dst_ops->check = NULL; 1280 dst_ops->check = NULL;
1300 dst_ops->destroy = NULL;
1301 dst_ops->ifdown = NULL;
1302 dst_ops->negative_advice = NULL; 1281 dst_ops->negative_advice = NULL;
1303 dst_ops->link_failure = NULL; 1282 dst_ops->link_failure = NULL;
1304 dst_ops->get_mss = NULL; 1283 dst_ops->get_mss = NULL;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 1db59f11f37d..d11747c2a763 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -357,8 +357,9 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
357 357
358 x = best; 358 x = best;
359 if (!x && !error && !acquire_in_progress) { 359 if (!x && !error && !acquire_in_progress) {
360 x0 = afinfo->state_lookup(&tmpl->id.daddr, tmpl->id.spi, tmpl->id.proto); 360 if (tmpl->id.spi &&
361 if (x0 != NULL) { 361 (x0 = afinfo->state_lookup(daddr, tmpl->id.spi,
362 tmpl->id.proto)) != NULL) {
362 xfrm_state_put(x0); 363 xfrm_state_put(x0);
363 error = -EEXIST; 364 error = -EEXIST;
364 goto out; 365 goto out;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 63661b0fd736..5ddda2c98af9 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -855,47 +855,44 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
855 return 0; 855 return 0;
856} 856}
857 857
858static const int xfrm_msg_min[(XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)] = { 858#define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type))
859 NLMSG_LENGTH(sizeof(struct xfrm_usersa_info)), /* NEW SA */ 859
860 NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)), /* DEL SA */ 860static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
861 NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)), /* GET SA */ 861 [XFRM_MSG_NEWSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
862 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_info)),/* NEW POLICY */ 862 [XFRM_MSG_DELSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
863 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_id)), /* DEL POLICY */ 863 [XFRM_MSG_GETSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
864 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_id)), /* GET POLICY */ 864 [XFRM_MSG_NEWPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
865 NLMSG_LENGTH(sizeof(struct xfrm_userspi_info)), /* ALLOC SPI */ 865 [XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
866 NLMSG_LENGTH(sizeof(struct xfrm_user_acquire)), /* ACQUIRE */ 866 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
867 NLMSG_LENGTH(sizeof(struct xfrm_user_expire)), /* EXPIRE */ 867 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userspi_info),
868 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_info)),/* UPD POLICY */ 868 [XFRM_MSG_ACQUIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_acquire),
869 NLMSG_LENGTH(sizeof(struct xfrm_usersa_info)), /* UPD SA */ 869 [XFRM_MSG_EXPIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_expire),
870 NLMSG_LENGTH(sizeof(struct xfrm_user_polexpire)), /* POLEXPIRE */ 870 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
871 NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush)), /* FLUSH SA */ 871 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
872 NLMSG_LENGTH(0), /* FLUSH POLICY */ 872 [XFRM_MSG_POLEXPIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_polexpire),
873 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush),
874 [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = NLMSG_LENGTH(0),
873}; 875};
874 876
877#undef XMSGSIZE
878
875static struct xfrm_link { 879static struct xfrm_link {
876 int (*doit)(struct sk_buff *, struct nlmsghdr *, void **); 880 int (*doit)(struct sk_buff *, struct nlmsghdr *, void **);
877 int (*dump)(struct sk_buff *, struct netlink_callback *); 881 int (*dump)(struct sk_buff *, struct netlink_callback *);
878} xfrm_dispatch[] = { 882} xfrm_dispatch[XFRM_NR_MSGTYPES] = {
879 { .doit = xfrm_add_sa, }, 883 [XFRM_MSG_NEWSA - XFRM_MSG_BASE] = { .doit = xfrm_add_sa },
880 { .doit = xfrm_del_sa, }, 884 [XFRM_MSG_DELSA - XFRM_MSG_BASE] = { .doit = xfrm_del_sa },
881 { 885 [XFRM_MSG_GETSA - XFRM_MSG_BASE] = { .doit = xfrm_get_sa,
882 .doit = xfrm_get_sa, 886 .dump = xfrm_dump_sa },
883 .dump = xfrm_dump_sa, 887 [XFRM_MSG_NEWPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy },
884 }, 888 [XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_get_policy },
885 { .doit = xfrm_add_policy }, 889 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_get_policy,
886 { .doit = xfrm_get_policy }, 890 .dump = xfrm_dump_policy },
887 { 891 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = { .doit = xfrm_alloc_userspi },
888 .doit = xfrm_get_policy, 892 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy },
889 .dump = xfrm_dump_policy, 893 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = { .doit = xfrm_add_sa },
890 }, 894 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = { .doit = xfrm_flush_sa },
891 { .doit = xfrm_alloc_userspi }, 895 [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_flush_policy },
892 {},
893 {},
894 { .doit = xfrm_add_policy },
895 { .doit = xfrm_add_sa, },
896 {},
897 { .doit = xfrm_flush_sa },
898 { .doit = xfrm_flush_policy },
899}; 896};
900 897
901static int xfrm_done(struct netlink_callback *cb) 898static int xfrm_done(struct netlink_callback *cb)
@@ -931,7 +928,9 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *err
931 return -1; 928 return -1;
932 } 929 }
933 930
934 if ((type == 2 || type == 5) && (nlh->nlmsg_flags & NLM_F_DUMP)) { 931 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
932 type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
933 (nlh->nlmsg_flags & NLM_F_DUMP)) {
935 u32 rlen; 934 u32 rlen;
936 935
937 if (link->dump == NULL) 936 if (link->dump == NULL)
@@ -1009,18 +1008,26 @@ static int xfrm_user_rcv_skb(struct sk_buff *skb)
1009 1008
1010static void xfrm_netlink_rcv(struct sock *sk, int len) 1009static void xfrm_netlink_rcv(struct sock *sk, int len)
1011{ 1010{
1011 unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
1012
1012 do { 1013 do {
1013 struct sk_buff *skb; 1014 struct sk_buff *skb;
1014 1015
1015 down(&xfrm_cfg_sem); 1016 down(&xfrm_cfg_sem);
1016 1017
1017 while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { 1018 if (qlen > skb_queue_len(&sk->sk_receive_queue))
1019 qlen = skb_queue_len(&sk->sk_receive_queue);
1020
1021 for (; qlen; qlen--) {
1022 skb = skb_dequeue(&sk->sk_receive_queue);
1018 if (xfrm_user_rcv_skb(skb)) { 1023 if (xfrm_user_rcv_skb(skb)) {
1019 if (skb->len) 1024 if (skb->len)
1020 skb_queue_head(&sk->sk_receive_queue, 1025 skb_queue_head(&sk->sk_receive_queue,
1021 skb); 1026 skb);
1022 else 1027 else {
1023 kfree_skb(skb); 1028 kfree_skb(skb);
1029 qlen--;
1030 }
1024 break; 1031 break;
1025 } 1032 }
1026 kfree_skb(skb); 1033 kfree_skb(skb);
@@ -1028,7 +1035,7 @@ static void xfrm_netlink_rcv(struct sock *sk, int len)
1028 1035
1029 up(&xfrm_cfg_sem); 1036 up(&xfrm_cfg_sem);
1030 1037
1031 } while (xfrm_nl && xfrm_nl->sk_receive_queue.qlen); 1038 } while (qlen);
1032} 1039}
1033 1040
1034static int build_expire(struct sk_buff *skb, struct xfrm_state *x, int hard) 1041static int build_expire(struct sk_buff *skb, struct xfrm_state *x, int hard)
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 090ffda4adbc..d3d2e5341051 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -67,8 +67,9 @@ struct sym_entry {
67 67
68static struct sym_entry *table; 68static struct sym_entry *table;
69static int size, cnt; 69static int size, cnt;
70static unsigned long long _stext, _etext, _sinittext, _einittext; 70static unsigned long long _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
71static int all_symbols = 0; 71static int all_symbols = 0;
72static char symbol_prefix_char = '\0';
72 73
73struct token { 74struct token {
74 unsigned char data[MAX_TOK_SIZE]; 75 unsigned char data[MAX_TOK_SIZE];
@@ -93,7 +94,7 @@ unsigned char best_table_len[256];
93static void 94static void
94usage(void) 95usage(void)
95{ 96{
96 fprintf(stderr, "Usage: kallsyms [--all-symbols] < in.map > out.S\n"); 97 fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n");
97 exit(1); 98 exit(1);
98} 99}
99 100
@@ -112,6 +113,7 @@ static int
112read_symbol(FILE *in, struct sym_entry *s) 113read_symbol(FILE *in, struct sym_entry *s)
113{ 114{
114 char str[500]; 115 char str[500];
116 char *sym;
115 int rc; 117 int rc;
116 118
117 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &s->type, str); 119 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &s->type, str);
@@ -123,27 +125,36 @@ read_symbol(FILE *in, struct sym_entry *s)
123 return -1; 125 return -1;
124 } 126 }
125 127
128 sym = str;
129 /* skip prefix char */
130 if (symbol_prefix_char && str[0] == symbol_prefix_char)
131 sym++;
132
126 /* Ignore most absolute/undefined (?) symbols. */ 133 /* Ignore most absolute/undefined (?) symbols. */
127 if (strcmp(str, "_stext") == 0) 134 if (strcmp(sym, "_stext") == 0)
128 _stext = s->addr; 135 _stext = s->addr;
129 else if (strcmp(str, "_etext") == 0) 136 else if (strcmp(sym, "_etext") == 0)
130 _etext = s->addr; 137 _etext = s->addr;
131 else if (strcmp(str, "_sinittext") == 0) 138 else if (strcmp(sym, "_sinittext") == 0)
132 _sinittext = s->addr; 139 _sinittext = s->addr;
133 else if (strcmp(str, "_einittext") == 0) 140 else if (strcmp(sym, "_einittext") == 0)
134 _einittext = s->addr; 141 _einittext = s->addr;
142 else if (strcmp(sym, "_sextratext") == 0)
143 _sextratext = s->addr;
144 else if (strcmp(sym, "_eextratext") == 0)
145 _eextratext = s->addr;
135 else if (toupper(s->type) == 'A') 146 else if (toupper(s->type) == 'A')
136 { 147 {
137 /* Keep these useful absolute symbols */ 148 /* Keep these useful absolute symbols */
138 if (strcmp(str, "__kernel_syscall_via_break") && 149 if (strcmp(sym, "__kernel_syscall_via_break") &&
139 strcmp(str, "__kernel_syscall_via_epc") && 150 strcmp(sym, "__kernel_syscall_via_epc") &&
140 strcmp(str, "__kernel_sigtramp") && 151 strcmp(sym, "__kernel_sigtramp") &&
141 strcmp(str, "__gp")) 152 strcmp(sym, "__gp"))
142 return -1; 153 return -1;
143 154
144 } 155 }
145 else if (toupper(s->type) == 'U' || 156 else if (toupper(s->type) == 'U' ||
146 is_arm_mapping_symbol(str)) 157 is_arm_mapping_symbol(sym))
147 return -1; 158 return -1;
148 159
149 /* include the type field in the symbol name, so that it gets 160 /* include the type field in the symbol name, so that it gets
@@ -177,30 +188,37 @@ symbol_valid(struct sym_entry *s)
177 "_SDA2_BASE_", /* ppc */ 188 "_SDA2_BASE_", /* ppc */
178 NULL }; 189 NULL };
179 int i; 190 int i;
191 int offset = 1;
192
193 /* skip prefix char */
194 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char)
195 offset++;
180 196
181 /* if --all-symbols is not specified, then symbols outside the text 197 /* if --all-symbols is not specified, then symbols outside the text
182 * and inittext sections are discarded */ 198 * and inittext sections are discarded */
183 if (!all_symbols) { 199 if (!all_symbols) {
184 if ((s->addr < _stext || s->addr > _etext) 200 if ((s->addr < _stext || s->addr > _etext)
185 && (s->addr < _sinittext || s->addr > _einittext)) 201 && (s->addr < _sinittext || s->addr > _einittext)
202 && (s->addr < _sextratext || s->addr > _eextratext))
186 return 0; 203 return 0;
187 /* Corner case. Discard any symbols with the same value as 204 /* Corner case. Discard any symbols with the same value as
188 * _etext or _einittext, they can move between pass 1 and 2 205 * _etext _einittext or _eextratext; they can move between pass
189 * when the kallsyms data is added. If these symbols move then 206 * 1 and 2 when the kallsyms data are added. If these symbols
190 * they may get dropped in pass 2, which breaks the kallsyms 207 * move then they may get dropped in pass 2, which breaks the
191 * rules. 208 * kallsyms rules.
192 */ 209 */
193 if ((s->addr == _etext && strcmp(s->sym + 1, "_etext")) || 210 if ((s->addr == _etext && strcmp(s->sym + offset, "_etext")) ||
194 (s->addr == _einittext && strcmp(s->sym + 1, "_einittext"))) 211 (s->addr == _einittext && strcmp(s->sym + offset, "_einittext")) ||
212 (s->addr == _eextratext && strcmp(s->sym + offset, "_eextratext")))
195 return 0; 213 return 0;
196 } 214 }
197 215
198 /* Exclude symbols which vary between passes. */ 216 /* Exclude symbols which vary between passes. */
199 if (strstr(s->sym + 1, "_compiled.")) 217 if (strstr(s->sym + offset, "_compiled."))
200 return 0; 218 return 0;
201 219
202 for (i = 0; special_symbols[i]; i++) 220 for (i = 0; special_symbols[i]; i++)
203 if( strcmp(s->sym + 1, special_symbols[i]) == 0 ) 221 if( strcmp(s->sym + offset, special_symbols[i]) == 0 )
204 return 0; 222 return 0;
205 223
206 return 1; 224 return 1;
@@ -225,9 +243,15 @@ read_map(FILE *in)
225 243
226static void output_label(char *label) 244static void output_label(char *label)
227{ 245{
228 printf(".globl %s\n",label); 246 if (symbol_prefix_char)
247 printf(".globl %c%s\n", symbol_prefix_char, label);
248 else
249 printf(".globl %s\n", label);
229 printf("\tALGN\n"); 250 printf("\tALGN\n");
230 printf("%s:\n",label); 251 if (symbol_prefix_char)
252 printf("%c%s:\n", symbol_prefix_char, label);
253 else
254 printf("%s:\n", label);
231} 255}
232 256
233/* uncompress a compressed symbol. When this function is called, the best table 257/* uncompress a compressed symbol. When this function is called, the best table
@@ -665,6 +689,13 @@ static void optimize_token_table(void)
665 689
666 insert_real_symbols_in_table(); 690 insert_real_symbols_in_table();
667 691
692 /* When valid symbol is not registered, exit to error */
693 if (good_head.left == good_head.right &&
694 bad_head.left == bad_head.right) {
695 fprintf(stderr, "No valid symbol.\n");
696 exit(1);
697 }
698
668 optimize_result(); 699 optimize_result();
669} 700}
670 701
@@ -672,9 +703,21 @@ static void optimize_token_table(void)
672int 703int
673main(int argc, char **argv) 704main(int argc, char **argv)
674{ 705{
675 if (argc == 2 && strcmp(argv[1], "--all-symbols") == 0) 706 if (argc >= 2) {
676 all_symbols = 1; 707 int i;
677 else if (argc != 1) 708 for (i = 1; i < argc; i++) {
709 if(strcmp(argv[i], "--all-symbols") == 0)
710 all_symbols = 1;
711 else if (strncmp(argv[i], "--symbol-prefix=", 16) == 0) {
712 char *p = &argv[i][16];
713 /* skip quote */
714 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
715 p++;
716 symbol_prefix_char = *p;
717 } else
718 usage();
719 }
720 } else if (argc != 1)
678 usage(); 721 usage();
679 722
680 read_map(stdin); 723 read_map(stdin);
@@ -683,4 +726,3 @@ main(int argc, char **argv)
683 726
684 return 0; 727 return 0;
685} 728}
686
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5a5ddc40f36c..09abb891d11f 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,7 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig 5.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6 6
7xconfig: $(obj)/qconf 7xconfig: $(obj)/qconf
8 $< arch/$(ARCH)/Kconfig 8 $< arch/$(ARCH)/Kconfig
@@ -23,6 +23,13 @@ oldconfig: $(obj)/conf
23silentoldconfig: $(obj)/conf 23silentoldconfig: $(obj)/conf
24 $< -s arch/$(ARCH)/Kconfig 24 $< -s arch/$(ARCH)/Kconfig
25 25
26update-po-config: $(obj)/kxgettext
27 xgettext --default-domain=linux \
28 --add-comments --keyword=_ --keyword=N_ \
29 --files-from=scripts/kconfig/POTFILES.in \
30 -o scripts/kconfig/linux.pot
31 scripts/kconfig/kxgettext arch/$(ARCH)/Kconfig >> scripts/kconfig/linux.pot
32
26.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig 33.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
27 34
28randconfig: $(obj)/conf 35randconfig: $(obj)/conf
@@ -72,9 +79,10 @@ help:
72# Based on GTK which needs to be installed to compile it 79# Based on GTK which needs to be installed to compile it
73# object files used by all kconfig flavours 80# object files used by all kconfig flavours
74 81
75hostprogs-y := conf mconf qconf gconf 82hostprogs-y := conf mconf qconf gconf kxgettext
76conf-objs := conf.o zconf.tab.o 83conf-objs := conf.o zconf.tab.o
77mconf-objs := mconf.o zconf.tab.o 84mconf-objs := mconf.o zconf.tab.o
85kxgettext-objs := kxgettext.o zconf.tab.o
78 86
79ifeq ($(MAKECMDGOALS),xconfig) 87ifeq ($(MAKECMDGOALS),xconfig)
80 qconf-target := 1 88 qconf-target := 1
@@ -107,7 +115,7 @@ HOSTLOADLIBES_gconf = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --libs`
107HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \ 115HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \
108 -D LKC_DIRECT_LINK 116 -D LKC_DIRECT_LINK
109 117
110$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h 118$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o $(obj)/kxgettext: $(obj)/zconf.tab.h
111 119
112$(obj)/zconf.tab.h: $(src)/zconf.tab.h_shipped 120$(obj)/zconf.tab.h: $(src)/zconf.tab.h_shipped
113$(obj)/zconf.tab.c: $(src)/zconf.tab.c_shipped 121$(obj)/zconf.tab.c: $(src)/zconf.tab.c_shipped
diff --git a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in
new file mode 100644
index 000000000000..cc94e46a79e8
--- /dev/null
+++ b/scripts/kconfig/POTFILES.in
@@ -0,0 +1,5 @@
1scripts/kconfig/mconf.c
2scripts/kconfig/conf.c
3scripts/kconfig/confdata.c
4scripts/kconfig/gconf.c
5scripts/kconfig/qconf.cc
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index a494d1aeb9f9..70e7264c6942 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -34,7 +34,7 @@ static int conf_cnt;
34static signed char line[128]; 34static signed char line[128];
35static struct menu *rootEntry; 35static struct menu *rootEntry;
36 36
37static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; 37static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
38 38
39static void strip(signed char *str) 39static void strip(signed char *str)
40{ 40{
@@ -56,9 +56,9 @@ static void strip(signed char *str)
56static void check_stdin(void) 56static void check_stdin(void)
57{ 57{
58 if (!valid_stdin && input_mode == ask_silent) { 58 if (!valid_stdin && input_mode == ask_silent) {
59 printf("aborted!\n\n"); 59 printf(_("aborted!\n\n"));
60 printf("Console input/output is redirected. "); 60 printf(_("Console input/output is redirected. "));
61 printf("Run 'make oldconfig' to update configuration.\n\n"); 61 printf(_("Run 'make oldconfig' to update configuration.\n\n"));
62 exit(1); 62 exit(1);
63 } 63 }
64} 64}
@@ -470,7 +470,7 @@ static void check_conf(struct menu *menu)
470 if (sym) { 470 if (sym) {
471 if (sym_is_changable(sym) && !sym_has_value(sym)) { 471 if (sym_is_changable(sym) && !sym_has_value(sym)) {
472 if (!conf_cnt++) 472 if (!conf_cnt++)
473 printf("*\n* Restart config...\n*\n"); 473 printf(_("*\n* Restart config...\n*\n"));
474 rootEntry = menu_get_parent_menu(menu); 474 rootEntry = menu_get_parent_menu(menu);
475 conf(rootEntry); 475 conf(rootEntry);
476 } 476 }
@@ -504,7 +504,7 @@ int main(int ac, char **av)
504 input_mode = set_default; 504 input_mode = set_default;
505 defconfig_file = av[i++]; 505 defconfig_file = av[i++];
506 if (!defconfig_file) { 506 if (!defconfig_file) {
507 printf("%s: No default config file specified\n", 507 printf(_("%s: No default config file specified\n"),
508 av[0]); 508 av[0]);
509 exit(1); 509 exit(1);
510 } 510 }
@@ -530,7 +530,7 @@ int main(int ac, char **av)
530 } 530 }
531 name = av[i]; 531 name = av[i];
532 if (!name) { 532 if (!name) {
533 printf("%s: Kconfig file missing\n", av[0]); 533 printf(_("%s: Kconfig file missing\n"), av[0]);
534 } 534 }
535 conf_parse(name); 535 conf_parse(name);
536 //zconfdump(stdout); 536 //zconfdump(stdout);
@@ -547,12 +547,12 @@ int main(int ac, char **av)
547 break; 547 break;
548 case ask_silent: 548 case ask_silent:
549 if (stat(".config", &tmpstat)) { 549 if (stat(".config", &tmpstat)) {
550 printf("***\n" 550 printf(_("***\n"
551 "*** You have not yet configured your kernel!\n" 551 "*** You have not yet configured your kernel!\n"
552 "***\n" 552 "***\n"
553 "*** Please run some configurator (e.g. \"make oldconfig\" or\n" 553 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
554 "*** \"make menuconfig\" or \"make xconfig\").\n" 554 "*** \"make menuconfig\" or \"make xconfig\").\n"
555 "***\n"); 555 "***\n"));
556 exit(1); 556 exit(1);
557 } 557 }
558 case ask_all: 558 case ask_all:
@@ -576,7 +576,7 @@ int main(int ac, char **av)
576 check_conf(&rootmenu); 576 check_conf(&rootmenu);
577 } while (conf_cnt); 577 } while (conf_cnt);
578 if (conf_write(NULL)) { 578 if (conf_write(NULL)) {
579 fprintf(stderr, "\n*** Error during writing of the kernel configuration.\n\n"); 579 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
580 return 1; 580 return 1;
581 } 581 }
582 return 0; 582 return 0;
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 1e82ae390a69..2755c459d780 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -88,9 +88,9 @@ int conf_read(const char *name)
88 name = conf_expand_value(name); 88 name = conf_expand_value(name);
89 in = zconf_fopen(name); 89 in = zconf_fopen(name);
90 if (in) { 90 if (in) {
91 printf("#\n" 91 printf(_("#\n"
92 "# using defaults found in %s\n" 92 "# using defaults found in %s\n"
93 "#\n", name); 93 "#\n"), name);
94 break; 94 break;
95 } 95 }
96 } 96 }
@@ -312,11 +312,11 @@ int conf_write(const char *name)
312 if (env && *env) 312 if (env && *env)
313 use_timestamp = 0; 313 use_timestamp = 0;
314 314
315 fprintf(out, "#\n" 315 fprintf(out, _("#\n"
316 "# Automatically generated make config: don't edit\n" 316 "# Automatically generated make config: don't edit\n"
317 "# Linux kernel version: %s\n" 317 "# Linux kernel version: %s\n"
318 "%s%s" 318 "%s%s"
319 "#\n", 319 "#\n"),
320 sym_get_string_value(sym), 320 sym_get_string_value(sym),
321 use_timestamp ? "# " : "", 321 use_timestamp ? "# " : "",
322 use_timestamp ? ctime(&now) : ""); 322 use_timestamp ? ctime(&now) : "");
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 6fdbe6e3ce0d..ad6b12043874 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -41,7 +41,7 @@ static gboolean resizeable = FALSE;
41static gboolean config_changed = FALSE; 41static gboolean config_changed = FALSE;
42 42
43static char nohelp_text[] = 43static char nohelp_text[] =
44 "Sorry, no help available for this option yet.\n"; 44 N_("Sorry, no help available for this option yet.\n");
45 45
46GtkWidget *main_wnd = NULL; 46GtkWidget *main_wnd = NULL;
47GtkWidget *tree1_w = NULL; // left frame 47GtkWidget *tree1_w = NULL; // left frame
@@ -193,7 +193,7 @@ void init_main_window(const gchar * glade_file)
193 193
194 xml = glade_xml_new(glade_file, "window1", NULL); 194 xml = glade_xml_new(glade_file, "window1", NULL);
195 if (!xml) 195 if (!xml)
196 g_error("GUI loading failed !\n"); 196 g_error(_("GUI loading failed !\n"));
197 glade_xml_signal_autoconnect(xml); 197 glade_xml_signal_autoconnect(xml);
198 198
199 main_wnd = glade_xml_get_widget(xml, "window1"); 199 main_wnd = glade_xml_get_widget(xml, "window1");
@@ -275,7 +275,7 @@ void init_main_window(const gchar * glade_file)
275 /*"style", PANGO_STYLE_OBLIQUE, */ 275 /*"style", PANGO_STYLE_OBLIQUE, */
276 NULL); 276 NULL);
277 277
278 sprintf(title, "Linux Kernel v%s Configuration", 278 sprintf(title, _("Linux Kernel v%s Configuration"),
279 getenv("KERNELRELEASE")); 279 getenv("KERNELRELEASE"));
280 gtk_window_set_title(GTK_WINDOW(main_wnd), title); 280 gtk_window_set_title(GTK_WINDOW(main_wnd), title);
281 281
@@ -325,7 +325,7 @@ void init_left_tree(void)
325 325
326 column = gtk_tree_view_column_new(); 326 column = gtk_tree_view_column_new();
327 gtk_tree_view_append_column(view, column); 327 gtk_tree_view_append_column(view, column);
328 gtk_tree_view_column_set_title(column, "Options"); 328 gtk_tree_view_column_set_title(column, _("Options"));
329 329
330 renderer = gtk_cell_renderer_toggle_new(); 330 renderer = gtk_cell_renderer_toggle_new();
331 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), 331 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
@@ -370,7 +370,7 @@ void init_right_tree(void)
370 370
371 column = gtk_tree_view_column_new(); 371 column = gtk_tree_view_column_new();
372 gtk_tree_view_append_column(view, column); 372 gtk_tree_view_append_column(view, column);
373 gtk_tree_view_column_set_title(column, "Options"); 373 gtk_tree_view_column_set_title(column, _("Options"));
374 374
375 renderer = gtk_cell_renderer_pixbuf_new(); 375 renderer = gtk_cell_renderer_pixbuf_new();
376 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), 376 gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
@@ -401,7 +401,7 @@ void init_right_tree(void)
401 401
402 renderer = gtk_cell_renderer_text_new(); 402 renderer = gtk_cell_renderer_text_new();
403 gtk_tree_view_insert_column_with_attributes(view, -1, 403 gtk_tree_view_insert_column_with_attributes(view, -1,
404 "Name", renderer, 404 _("Name"), renderer,
405 "text", COL_NAME, 405 "text", COL_NAME,
406 "foreground-gdk", 406 "foreground-gdk",
407 COL_COLOR, NULL); 407 COL_COLOR, NULL);
@@ -425,7 +425,7 @@ void init_right_tree(void)
425 COL_COLOR, NULL); 425 COL_COLOR, NULL);
426 renderer = gtk_cell_renderer_text_new(); 426 renderer = gtk_cell_renderer_text_new();
427 gtk_tree_view_insert_column_with_attributes(view, -1, 427 gtk_tree_view_insert_column_with_attributes(view, -1,
428 "Value", renderer, 428 _("Value"), renderer,
429 "text", COL_VALUE, 429 "text", COL_VALUE,
430 "editable", 430 "editable",
431 COL_EDIT, 431 COL_EDIT,
@@ -466,15 +466,15 @@ static void text_insert_help(struct menu *menu)
466 GtkTextIter start, end; 466 GtkTextIter start, end;
467 const char *prompt = menu_get_prompt(menu); 467 const char *prompt = menu_get_prompt(menu);
468 gchar *name; 468 gchar *name;
469 const char *help = nohelp_text; 469 const char *help = _(nohelp_text);
470 470
471 if (!menu->sym) 471 if (!menu->sym)
472 help = ""; 472 help = "";
473 else if (menu->sym->help) 473 else if (menu->sym->help)
474 help = menu->sym->help; 474 help = _(menu->sym->help);
475 475
476 if (menu->sym && menu->sym->name) 476 if (menu->sym && menu->sym->name)
477 name = g_strdup_printf(menu->sym->name); 477 name = g_strdup_printf(_(menu->sym->name));
478 else 478 else
479 name = g_strdup(""); 479 name = g_strdup("");
480 480
@@ -530,7 +530,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
530 if (config_changed == FALSE) 530 if (config_changed == FALSE)
531 return FALSE; 531 return FALSE;
532 532
533 dialog = gtk_dialog_new_with_buttons("Warning !", 533 dialog = gtk_dialog_new_with_buttons(_("Warning !"),
534 GTK_WINDOW(main_wnd), 534 GTK_WINDOW(main_wnd),
535 (GtkDialogFlags) 535 (GtkDialogFlags)
536 (GTK_DIALOG_MODAL | 536 (GTK_DIALOG_MODAL |
@@ -544,7 +544,7 @@ gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
544 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 544 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
545 GTK_RESPONSE_CANCEL); 545 GTK_RESPONSE_CANCEL);
546 546
547 label = gtk_label_new("\nSave configuration ?\n"); 547 label = gtk_label_new(_("\nSave configuration ?\n"));
548 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); 548 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
549 gtk_widget_show(label); 549 gtk_widget_show(label);
550 550
@@ -604,7 +604,7 @@ load_filename(GtkFileSelection * file_selector, gpointer user_data)
604 (user_data)); 604 (user_data));
605 605
606 if (conf_read(fn)) 606 if (conf_read(fn))
607 text_insert_msg("Error", "Unable to load configuration !"); 607 text_insert_msg(_("Error"), _("Unable to load configuration !"));
608 else 608 else
609 display_tree(&rootmenu); 609 display_tree(&rootmenu);
610} 610}
@@ -613,7 +613,7 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
613{ 613{
614 GtkWidget *fs; 614 GtkWidget *fs;
615 615
616 fs = gtk_file_selection_new("Load file..."); 616 fs = gtk_file_selection_new(_("Load file..."));
617 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), 617 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
618 "clicked", 618 "clicked",
619 G_CALLBACK(load_filename), (gpointer) fs); 619 G_CALLBACK(load_filename), (gpointer) fs);
@@ -632,7 +632,7 @@ void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
632void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data) 632void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data)
633{ 633{
634 if (conf_write(NULL)) 634 if (conf_write(NULL))
635 text_insert_msg("Error", "Unable to save configuration !"); 635 text_insert_msg(_("Error"), _("Unable to save configuration !"));
636 636
637 config_changed = FALSE; 637 config_changed = FALSE;
638} 638}
@@ -647,7 +647,7 @@ store_filename(GtkFileSelection * file_selector, gpointer user_data)
647 (user_data)); 647 (user_data));
648 648
649 if (conf_write(fn)) 649 if (conf_write(fn))
650 text_insert_msg("Error", "Unable to save configuration !"); 650 text_insert_msg(_("Error"), _("Unable to save configuration !"));
651 651
652 gtk_widget_destroy(GTK_WIDGET(user_data)); 652 gtk_widget_destroy(GTK_WIDGET(user_data));
653} 653}
@@ -656,7 +656,7 @@ void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
656{ 656{
657 GtkWidget *fs; 657 GtkWidget *fs;
658 658
659 fs = gtk_file_selection_new("Save file as..."); 659 fs = gtk_file_selection_new(_("Save file as..."));
660 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), 660 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
661 "clicked", 661 "clicked",
662 G_CALLBACK(store_filename), (gpointer) fs); 662 G_CALLBACK(store_filename), (gpointer) fs);
@@ -740,7 +740,7 @@ on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data)
740void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) 740void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
741{ 741{
742 GtkWidget *dialog; 742 GtkWidget *dialog;
743 const gchar *intro_text = 743 const gchar *intro_text = _(
744 "Welcome to gkc, the GTK+ graphical kernel configuration tool\n" 744 "Welcome to gkc, the GTK+ graphical kernel configuration tool\n"
745 "for Linux.\n" 745 "for Linux.\n"
746 "For each option, a blank box indicates the feature is disabled, a\n" 746 "For each option, a blank box indicates the feature is disabled, a\n"
@@ -756,7 +756,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
756 "option.\n" 756 "option.\n"
757 "\n" 757 "\n"
758 "Toggling Show Debug Info under the Options menu will show \n" 758 "Toggling Show Debug Info under the Options menu will show \n"
759 "the dependencies, which you can then match by examining other options."; 759 "the dependencies, which you can then match by examining other options.");
760 760
761 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), 761 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
762 GTK_DIALOG_DESTROY_WITH_PARENT, 762 GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -773,8 +773,8 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
773{ 773{
774 GtkWidget *dialog; 774 GtkWidget *dialog;
775 const gchar *about_text = 775 const gchar *about_text =
776 "gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n" 776 _("gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
777 "Based on the source code from Roman Zippel.\n"; 777 "Based on the source code from Roman Zippel.\n");
778 778
779 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), 779 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
780 GTK_DIALOG_DESTROY_WITH_PARENT, 780 GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -791,9 +791,9 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
791{ 791{
792 GtkWidget *dialog; 792 GtkWidget *dialog;
793 const gchar *license_text = 793 const gchar *license_text =
794 "gkc is released under the terms of the GNU GPL v2.\n" 794 _("gkc is released under the terms of the GNU GPL v2.\n"
795 "For more information, please see the source code or\n" 795 "For more information, please see the source code or\n"
796 "visit http://www.fsf.org/licenses/licenses.html\n"; 796 "visit http://www.fsf.org/licenses/licenses.html\n");
797 797
798 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), 798 dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
799 GTK_DIALOG_DESTROY_WITH_PARENT, 799 GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1579,6 +1579,10 @@ int main(int ac, char *av[])
1579 kconfig_load(); 1579 kconfig_load();
1580#endif 1580#endif
1581 1581
1582 bindtextdomain(PACKAGE, LOCALEDIR);
1583 bind_textdomain_codeset(PACKAGE, "UTF-8");
1584 textdomain(PACKAGE);
1585
1582 /* GTK stuffs */ 1586 /* GTK stuffs */
1583 gtk_set_locale(); 1587 gtk_set_locale();
1584 gtk_init(&ac, &av); 1588 gtk_init(&ac, &av);
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
new file mode 100644
index 000000000000..1c88d7c6d5a7
--- /dev/null
+++ b/scripts/kconfig/kxgettext.c
@@ -0,0 +1,221 @@
1/*
2 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 2005
3 *
4 * Released under the terms of the GNU GPL v2.0
5 */
6
7#include <stdlib.h>
8#include <string.h>
9
10#define LKC_DIRECT_LINK
11#include "lkc.h"
12
13static char *escape(const char* text, char *bf, int len)
14{
15 char *bfp = bf;
16 int multiline = strchr(text, '\n') != NULL;
17
18 *bfp++ = '"';
19 --len;
20
21 if (multiline) {
22 *bfp++ = '"';
23 *bfp++ = '\n';
24 *bfp++ = '"';
25 len -= 3;
26 }
27
28 while (*text != '\0' && len > 1) {
29 if (*text == '"')
30 *bfp++ = '\\';
31 else if (*text == '\n') {
32 *bfp++ = '\\';
33 *bfp++ = 'n';
34 *bfp++ = '"';
35 *bfp++ = '\n';
36 *bfp++ = '"';
37 len -= 5;
38 ++text;
39 goto next;
40 }
41 *bfp++ = *text++;
42next:
43 --len;
44 }
45
46 if (multiline)
47 bfp -= 3;
48
49 *bfp++ = '"';
50 *bfp = '\0';
51
52 return bf;
53}
54
55struct file_line {
56 struct file_line *next;
57 char* file;
58 int lineno;
59};
60
61static struct file_line *file_line__new(char *file, int lineno)
62{
63 struct file_line *self = malloc(sizeof(*self));
64
65 if (self == NULL)
66 goto out;
67
68 self->file = file;
69 self->lineno = lineno;
70 self->next = NULL;
71out:
72 return self;
73}
74
75struct message {
76 const char *msg;
77 const char *option;
78 struct message *next;
79 struct file_line *files;
80};
81
82static struct message *message__list;
83
84static struct message *message__new(const char *msg, char *option, char *file, int lineno)
85{
86 struct message *self = malloc(sizeof(*self));
87
88 if (self == NULL)
89 goto out;
90
91 self->files = file_line__new(file, lineno);
92 if (self->files == NULL)
93 goto out_fail;
94
95 self->msg = strdup(msg);
96 if (self->msg == NULL)
97 goto out_fail_msg;
98
99 self->option = option;
100 self->next = NULL;
101out:
102 return self;
103out_fail_msg:
104 free(self->files);
105out_fail:
106 free(self);
107 self = NULL;
108 goto out;
109}
110
111static struct message *mesage__find(const char *msg)
112{
113 struct message *m = message__list;
114
115 while (m != NULL) {
116 if (strcmp(m->msg, msg) == 0)
117 break;
118 m = m->next;
119 }
120
121 return m;
122}
123
124static int message__add_file_line(struct message *self, char *file, int lineno)
125{
126 int rc = -1;
127 struct file_line *fl = file_line__new(file, lineno);
128
129 if (fl == NULL)
130 goto out;
131
132 fl->next = self->files;
133 self->files = fl;
134 rc = 0;
135out:
136 return rc;
137}
138
139static int message__add(const char *msg, char *option, char *file, int lineno)
140{
141 int rc = 0;
142 char bf[16384];
143 char *escaped = escape(msg, bf, sizeof(bf));
144 struct message *m = mesage__find(escaped);
145
146 if (m != NULL)
147 rc = message__add_file_line(m, file, lineno);
148 else {
149 m = message__new(escaped, option, file, lineno);
150
151 if (m != NULL) {
152 m->next = message__list;
153 message__list = m;
154 } else
155 rc = -1;
156 }
157 return rc;
158}
159
160void menu_build_message_list(struct menu *menu)
161{
162 struct menu *child;
163
164 message__add(menu_get_prompt(menu), NULL,
165 menu->file == NULL ? "Root Menu" : menu->file->name,
166 menu->lineno);
167
168 if (menu->sym != NULL && menu->sym->help != NULL)
169 message__add(menu->sym->help, menu->sym->name,
170 menu->file == NULL ? "Root Menu" : menu->file->name,
171 menu->lineno);
172
173 for (child = menu->list; child != NULL; child = child->next)
174 if (child->prompt != NULL)
175 menu_build_message_list(child);
176}
177
178static void message__print_file_lineno(struct message *self)
179{
180 struct file_line *fl = self->files;
181
182 printf("\n#: %s:%d", fl->file, fl->lineno);
183 fl = fl->next;
184
185 while (fl != NULL) {
186 printf(", %s:%d", fl->file, fl->lineno);
187 fl = fl->next;
188 }
189
190 if (self->option != NULL)
191 printf(", %s:00000", self->option);
192
193 putchar('\n');
194}
195
196static void message__print_gettext_msgid_msgstr(struct message *self)
197{
198 message__print_file_lineno(self);
199
200 printf("msgid %s\n"
201 "msgstr \"\"\n", self->msg);
202}
203
204void menu__xgettext(void)
205{
206 struct message *m = message__list;
207
208 while (m != NULL) {
209 message__print_gettext_msgid_msgstr(m);
210 m = m->next;
211 }
212}
213
214int main(int ac, char **av)
215{
216 conf_parse(av[1]);
217
218 menu_build_message_list(menu_get_root_menu(NULL));
219 menu__xgettext();
220 return 0;
221}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index b8a67fc9d647..8b84c42b49b5 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -8,6 +8,8 @@
8 8
9#include "expr.h" 9#include "expr.h"
10 10
11#include <libintl.h>
12
11#ifdef __cplusplus 13#ifdef __cplusplus
12extern "C" { 14extern "C" {
13#endif 15#endif
@@ -23,6 +25,12 @@ extern "C" {
23 25
24#define SRCTREE "srctree" 26#define SRCTREE "srctree"
25 27
28#define PACKAGE "linux"
29#define LOCALEDIR "/usr/share/locale"
30
31#define _(text) gettext(text)
32#define N_(text) (text)
33
26int zconfparse(void); 34int zconfparse(void);
27void zconfdump(FILE *out); 35void zconfdump(FILE *out);
28 36
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 730d316fe7fe..e5db10ca9564 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -4,6 +4,8 @@
4 * 4 *
5 * Introduced single menu mode (show all sub-menus in one large tree). 5 * Introduced single menu mode (show all sub-menus in one large tree).
6 * 2002-11-06 Petr Baudis <pasky@ucw.cz> 6 * 2002-11-06 Petr Baudis <pasky@ucw.cz>
7 *
8 * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
7 */ 9 */
8 10
9#include <sys/ioctl.h> 11#include <sys/ioctl.h>
@@ -23,7 +25,7 @@
23#include "lkc.h" 25#include "lkc.h"
24 26
25static char menu_backtitle[128]; 27static char menu_backtitle[128];
26static const char mconf_readme[] = 28static const char mconf_readme[] = N_(
27"Overview\n" 29"Overview\n"
28"--------\n" 30"--------\n"
29"Some kernel features may be built directly into the kernel.\n" 31"Some kernel features may be built directly into the kernel.\n"
@@ -156,39 +158,39 @@ static const char mconf_readme[] =
156"\n" 158"\n"
157"Note that this mode can eventually be a little more CPU expensive\n" 159"Note that this mode can eventually be a little more CPU expensive\n"
158"(especially with a larger number of unrolled categories) than the\n" 160"(especially with a larger number of unrolled categories) than the\n"
159"default mode.\n", 161"default mode.\n"),
160menu_instructions[] = 162menu_instructions[] = N_(
161 "Arrow keys navigate the menu. " 163 "Arrow keys navigate the menu. "
162 "<Enter> selects submenus --->. " 164 "<Enter> selects submenus --->. "
163 "Highlighted letters are hotkeys. " 165 "Highlighted letters are hotkeys. "
164 "Pressing <Y> includes, <N> excludes, <M> modularizes features. " 166 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
165 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " 167 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
166 "Legend: [*] built-in [ ] excluded <M> module < > module capable", 168 "Legend: [*] built-in [ ] excluded <M> module < > module capable"),
167radiolist_instructions[] = 169radiolist_instructions[] = N_(
168 "Use the arrow keys to navigate this window or " 170 "Use the arrow keys to navigate this window or "
169 "press the hotkey of the item you wish to select " 171 "press the hotkey of the item you wish to select "
170 "followed by the <SPACE BAR>. " 172 "followed by the <SPACE BAR>. "
171 "Press <?> for additional information about this option.", 173 "Press <?> for additional information about this option."),
172inputbox_instructions_int[] = 174inputbox_instructions_int[] = N_(
173 "Please enter a decimal value. " 175 "Please enter a decimal value. "
174 "Fractions will not be accepted. " 176 "Fractions will not be accepted. "
175 "Use the <TAB> key to move from the input field to the buttons below it.", 177 "Use the <TAB> key to move from the input field to the buttons below it."),
176inputbox_instructions_hex[] = 178inputbox_instructions_hex[] = N_(
177 "Please enter a hexadecimal value. " 179 "Please enter a hexadecimal value. "
178 "Use the <TAB> key to move from the input field to the buttons below it.", 180 "Use the <TAB> key to move from the input field to the buttons below it."),
179inputbox_instructions_string[] = 181inputbox_instructions_string[] = N_(
180 "Please enter a string value. " 182 "Please enter a string value. "
181 "Use the <TAB> key to move from the input field to the buttons below it.", 183 "Use the <TAB> key to move from the input field to the buttons below it."),
182setmod_text[] = 184setmod_text[] = N_(
183 "This feature depends on another which has been configured as a module.\n" 185 "This feature depends on another which has been configured as a module.\n"
184 "As a result, this feature will be built as a module.", 186 "As a result, this feature will be built as a module."),
185nohelp_text[] = 187nohelp_text[] = N_(
186 "There is no help available for this kernel option.\n", 188 "There is no help available for this kernel option.\n"),
187load_config_text[] = 189load_config_text[] = N_(
188 "Enter the name of the configuration file you wish to load. " 190 "Enter the name of the configuration file you wish to load. "
189 "Accept the name shown to restore the configuration you " 191 "Accept the name shown to restore the configuration you "
190 "last retrieved. Leave blank to abort.", 192 "last retrieved. Leave blank to abort."),
191load_config_help[] = 193load_config_help[] = N_(
192 "\n" 194 "\n"
193 "For various reasons, one may wish to keep several different kernel\n" 195 "For various reasons, one may wish to keep several different kernel\n"
194 "configurations available on a single machine.\n" 196 "configurations available on a single machine.\n"
@@ -198,11 +200,11 @@ load_config_help[] =
198 "to modify that configuration.\n" 200 "to modify that configuration.\n"
199 "\n" 201 "\n"
200 "If you are uncertain, then you have probably never used alternate\n" 202 "If you are uncertain, then you have probably never used alternate\n"
201 "configuration files. You should therefor leave this blank to abort.\n", 203 "configuration files. You should therefor leave this blank to abort.\n"),
202save_config_text[] = 204save_config_text[] = N_(
203 "Enter a filename to which this configuration should be saved " 205 "Enter a filename to which this configuration should be saved "
204 "as an alternate. Leave blank to abort.", 206 "as an alternate. Leave blank to abort."),
205save_config_help[] = 207save_config_help[] = N_(
206 "\n" 208 "\n"
207 "For various reasons, one may wish to keep different kernel\n" 209 "For various reasons, one may wish to keep different kernel\n"
208 "configurations available on a single machine.\n" 210 "configurations available on a single machine.\n"
@@ -212,8 +214,8 @@ save_config_help[] =
212 "configuration options you have selected at that time.\n" 214 "configuration options you have selected at that time.\n"
213 "\n" 215 "\n"
214 "If you are uncertain what all this means then you should probably\n" 216 "If you are uncertain what all this means then you should probably\n"
215 "leave this blank.\n", 217 "leave this blank.\n"),
216search_help[] = 218search_help[] = N_(
217 "\n" 219 "\n"
218 "Search for CONFIG_ symbols and display their relations.\n" 220 "Search for CONFIG_ symbols and display their relations.\n"
219 "Example: search for \"^FOO\"\n" 221 "Example: search for \"^FOO\"\n"
@@ -250,7 +252,7 @@ search_help[] =
250 "Examples: USB => find all CONFIG_ symbols containing USB\n" 252 "Examples: USB => find all CONFIG_ symbols containing USB\n"
251 " ^USB => find all CONFIG_ symbols starting with USB\n" 253 " ^USB => find all CONFIG_ symbols starting with USB\n"
252 " USB$ => find all CONFIG_ symbols ending with USB\n" 254 " USB$ => find all CONFIG_ symbols ending with USB\n"
253 "\n"; 255 "\n");
254 256
255static signed char buf[4096], *bufptr = buf; 257static signed char buf[4096], *bufptr = buf;
256static signed char input_buf[4096]; 258static signed char input_buf[4096];
@@ -305,8 +307,8 @@ static void init_wsize(void)
305 } 307 }
306 308
307 if (rows < 19 || cols < 80) { 309 if (rows < 19 || cols < 80) {
308 fprintf(stderr, "Your display is too small to run Menuconfig!\n"); 310 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
309 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); 311 fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
310 exit(1); 312 exit(1);
311 } 313 }
312 314
@@ -526,9 +528,9 @@ static void search_conf(void)
526again: 528again:
527 cprint_init(); 529 cprint_init();
528 cprint("--title"); 530 cprint("--title");
529 cprint("Search Configuration Parameter"); 531 cprint(_("Search Configuration Parameter"));
530 cprint("--inputbox"); 532 cprint("--inputbox");
531 cprint("Enter Keyword"); 533 cprint(_("Enter Keyword"));
532 cprint("10"); 534 cprint("10");
533 cprint("75"); 535 cprint("75");
534 cprint(""); 536 cprint("");
@@ -539,7 +541,7 @@ again:
539 case 0: 541 case 0:
540 break; 542 break;
541 case 1: 543 case 1:
542 show_helptext("Search Configuration", search_help); 544 show_helptext(_("Search Configuration"), search_help);
543 goto again; 545 goto again;
544 default: 546 default:
545 return; 547 return;
@@ -548,7 +550,7 @@ again:
548 sym_arr = sym_re_search(input_buf); 550 sym_arr = sym_re_search(input_buf);
549 res = get_relations_str(sym_arr); 551 res = get_relations_str(sym_arr);
550 free(sym_arr); 552 free(sym_arr);
551 show_textbox("Search Results", str_get(&res), 0, 0); 553 show_textbox(_("Search Results"), str_get(&res), 0, 0);
552 str_free(&res); 554 str_free(&res);
553} 555}
554 556
@@ -721,9 +723,9 @@ static void conf(struct menu *menu)
721 while (1) { 723 while (1) {
722 cprint_init(); 724 cprint_init();
723 cprint("--title"); 725 cprint("--title");
724 cprint("%s", prompt ? prompt : "Main Menu"); 726 cprint("%s", prompt ? prompt : _("Main Menu"));
725 cprint("--menu"); 727 cprint("--menu");
726 cprint(menu_instructions); 728 cprint(_(menu_instructions));
727 cprint("%d", rows); 729 cprint("%d", rows);
728 cprint("%d", cols); 730 cprint("%d", cols);
729 cprint("%d", rows - 10); 731 cprint("%d", rows - 10);
@@ -736,9 +738,9 @@ static void conf(struct menu *menu)
736 cprint(":"); 738 cprint(":");
737 cprint("--- "); 739 cprint("--- ");
738 cprint("L"); 740 cprint("L");
739 cprint(" Load an Alternate Configuration File"); 741 cprint(_(" Load an Alternate Configuration File"));
740 cprint("S"); 742 cprint("S");
741 cprint(" Save Configuration to an Alternate File"); 743 cprint(_(" Save Configuration to an Alternate File"));
742 } 744 }
743 stat = exec_conf(); 745 stat = exec_conf();
744 if (stat < 0) 746 if (stat < 0)
@@ -793,7 +795,7 @@ static void conf(struct menu *menu)
793 if (sym) 795 if (sym)
794 show_help(submenu); 796 show_help(submenu);
795 else 797 else
796 show_helptext("README", mconf_readme); 798 show_helptext("README", _(mconf_readme));
797 break; 799 break;
798 case 3: 800 case 3:
799 if (type == 't') { 801 if (type == 't') {
@@ -849,7 +851,7 @@ static void show_help(struct menu *menu)
849 { 851 {
850 if (sym->name) { 852 if (sym->name) {
851 str_printf(&help, "CONFIG_%s:\n\n", sym->name); 853 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
852 str_append(&help, sym->help); 854 str_append(&help, _(sym->help));
853 str_append(&help, "\n"); 855 str_append(&help, "\n");
854 } 856 }
855 } else { 857 } else {
@@ -886,9 +888,9 @@ static void conf_choice(struct menu *menu)
886 while (1) { 888 while (1) {
887 cprint_init(); 889 cprint_init();
888 cprint("--title"); 890 cprint("--title");
889 cprint("%s", prompt ? prompt : "Main Menu"); 891 cprint("%s", prompt ? prompt : _("Main Menu"));
890 cprint("--radiolist"); 892 cprint("--radiolist");
891 cprint(radiolist_instructions); 893 cprint(_(radiolist_instructions));
892 cprint("15"); 894 cprint("15");
893 cprint("70"); 895 cprint("70");
894 cprint("6"); 896 cprint("6");
@@ -935,17 +937,17 @@ static void conf_string(struct menu *menu)
935 while (1) { 937 while (1) {
936 cprint_init(); 938 cprint_init();
937 cprint("--title"); 939 cprint("--title");
938 cprint("%s", prompt ? prompt : "Main Menu"); 940 cprint("%s", prompt ? prompt : _("Main Menu"));
939 cprint("--inputbox"); 941 cprint("--inputbox");
940 switch (sym_get_type(menu->sym)) { 942 switch (sym_get_type(menu->sym)) {
941 case S_INT: 943 case S_INT:
942 cprint(inputbox_instructions_int); 944 cprint(_(inputbox_instructions_int));
943 break; 945 break;
944 case S_HEX: 946 case S_HEX:
945 cprint(inputbox_instructions_hex); 947 cprint(_(inputbox_instructions_hex));
946 break; 948 break;
947 case S_STRING: 949 case S_STRING:
948 cprint(inputbox_instructions_string); 950 cprint(_(inputbox_instructions_string));
949 break; 951 break;
950 default: 952 default:
951 /* panic? */; 953 /* panic? */;
@@ -958,7 +960,7 @@ static void conf_string(struct menu *menu)
958 case 0: 960 case 0:
959 if (sym_set_string_value(menu->sym, input_buf)) 961 if (sym_set_string_value(menu->sym, input_buf))
960 return; 962 return;
961 show_textbox(NULL, "You have made an invalid entry.", 5, 43); 963 show_textbox(NULL, _("You have made an invalid entry."), 5, 43);
962 break; 964 break;
963 case 1: 965 case 1:
964 show_help(menu); 966 show_help(menu);
@@ -987,10 +989,10 @@ static void conf_load(void)
987 return; 989 return;
988 if (!conf_read(input_buf)) 990 if (!conf_read(input_buf))
989 return; 991 return;
990 show_textbox(NULL, "File does not exist!", 5, 38); 992 show_textbox(NULL, _("File does not exist!"), 5, 38);
991 break; 993 break;
992 case 1: 994 case 1:
993 show_helptext("Load Alternate Configuration", load_config_help); 995 show_helptext(_("Load Alternate Configuration"), load_config_help);
994 break; 996 break;
995 case 255: 997 case 255:
996 return; 998 return;
@@ -1016,10 +1018,10 @@ static void conf_save(void)
1016 return; 1018 return;
1017 if (!conf_write(input_buf)) 1019 if (!conf_write(input_buf))
1018 return; 1020 return;
1019 show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); 1021 show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60);
1020 break; 1022 break;
1021 case 1: 1023 case 1:
1022 show_helptext("Save Alternate Configuration", save_config_help); 1024 show_helptext(_("Save Alternate Configuration"), save_config_help);
1023 break; 1025 break;
1024 case 255: 1026 case 255:
1025 return; 1027 return;
@@ -1040,12 +1042,16 @@ int main(int ac, char **av)
1040 char *mode; 1042 char *mode;
1041 int stat; 1043 int stat;
1042 1044
1045 setlocale(LC_ALL, "");
1046 bindtextdomain(PACKAGE, LOCALEDIR);
1047 textdomain(PACKAGE);
1048
1043 conf_parse(av[1]); 1049 conf_parse(av[1]);
1044 conf_read(NULL); 1050 conf_read(NULL);
1045 1051
1046 sym = sym_lookup("KERNELRELEASE", 0); 1052 sym = sym_lookup("KERNELRELEASE", 0);
1047 sym_calc_value(sym); 1053 sym_calc_value(sym);
1048 sprintf(menu_backtitle, "Linux Kernel v%s Configuration", 1054 sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"),
1049 sym_get_string_value(sym)); 1055 sym_get_string_value(sym));
1050 1056
1051 mode = getenv("MENUCONFIG_MODE"); 1057 mode = getenv("MENUCONFIG_MODE");
@@ -1062,7 +1068,7 @@ int main(int ac, char **av)
1062 do { 1068 do {
1063 cprint_init(); 1069 cprint_init();
1064 cprint("--yesno"); 1070 cprint("--yesno");
1065 cprint("Do you wish to save your new kernel configuration?"); 1071 cprint(_("Do you wish to save your new kernel configuration?"));
1066 cprint("5"); 1072 cprint("5");
1067 cprint("60"); 1073 cprint("60");
1068 stat = exec_conf(); 1074 stat = exec_conf();
@@ -1070,20 +1076,20 @@ int main(int ac, char **av)
1070 1076
1071 if (stat == 0) { 1077 if (stat == 0) {
1072 if (conf_write(NULL)) { 1078 if (conf_write(NULL)) {
1073 fprintf(stderr, "\n\n" 1079 fprintf(stderr, _("\n\n"
1074 "Error during writing of the kernel configuration.\n" 1080 "Error during writing of the kernel configuration.\n"
1075 "Your kernel configuration changes were NOT saved." 1081 "Your kernel configuration changes were NOT saved."
1076 "\n\n"); 1082 "\n\n"));
1077 return 1; 1083 return 1;
1078 } 1084 }
1079 printf("\n\n" 1085 printf(_("\n\n"
1080 "*** End of Linux kernel configuration.\n" 1086 "*** End of Linux kernel configuration.\n"
1081 "*** Execute 'make' to build the kernel or try 'make help'." 1087 "*** Execute 'make' to build the kernel or try 'make help'."
1082 "\n\n"); 1088 "\n\n"));
1083 } else { 1089 } else {
1084 fprintf(stderr, "\n\n" 1090 fprintf(stderr, _("\n\n"
1085 "Your kernel configuration changes were NOT saved." 1091 "Your kernel configuration changes were NOT saved."
1086 "\n\n"); 1092 "\n\n"));
1087 } 1093 }
1088 1094
1089 return 0; 1095 return 0;
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 0c13156f3344..8c59b212722d 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -365,9 +365,9 @@ bool menu_is_visible(struct menu *menu)
365const char *menu_get_prompt(struct menu *menu) 365const char *menu_get_prompt(struct menu *menu)
366{ 366{
367 if (menu->prompt) 367 if (menu->prompt)
368 return menu->prompt->text; 368 return _(menu->prompt->text);
369 else if (menu->sym) 369 else if (menu->sym)
370 return menu->sym->name; 370 return _(menu->sym->name);
371 return NULL; 371 return NULL;
372} 372}
373 373
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 0cdbf9dbbd51..4590cd31623f 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -26,8 +26,23 @@
26#include "qconf.moc" 26#include "qconf.moc"
27#include "images.c" 27#include "images.c"
28 28
29#ifdef _
30# undef _
31# define _ qgettext
32#endif
33
29static QApplication *configApp; 34static QApplication *configApp;
30 35
36static inline QString qgettext(const char* str)
37{
38 return QString::fromLocal8Bit(gettext(str));
39}
40
41static inline QString qgettext(const QString& str)
42{
43 return QString::fromLocal8Bit(gettext(str.latin1()));
44}
45
31ConfigSettings::ConfigSettings() 46ConfigSettings::ConfigSettings()
32 : showAll(false), showName(false), showRange(false), showData(false) 47 : showAll(false), showName(false), showRange(false), showData(false)
33{ 48{
@@ -177,7 +192,7 @@ void ConfigItem::updateMenu(void)
177 192
178 sym = menu->sym; 193 sym = menu->sym;
179 prop = menu->prompt; 194 prop = menu->prompt;
180 prompt = menu_get_prompt(menu); 195 prompt = QString::fromLocal8Bit(menu_get_prompt(menu));
181 196
182 if (prop) switch (prop->type) { 197 if (prop) switch (prop->type) {
183 case P_MENU: 198 case P_MENU:
@@ -203,7 +218,7 @@ void ConfigItem::updateMenu(void)
203 if (!sym) 218 if (!sym)
204 goto set_prompt; 219 goto set_prompt;
205 220
206 setText(nameColIdx, sym->name); 221 setText(nameColIdx, QString::fromLocal8Bit(sym->name));
207 222
208 type = sym_get_type(sym); 223 type = sym_get_type(sym);
209 switch (type) { 224 switch (type) {
@@ -213,9 +228,9 @@ void ConfigItem::updateMenu(void)
213 228
214 if (!sym_is_changable(sym) && !list->showAll) { 229 if (!sym_is_changable(sym) && !list->showAll) {
215 setPixmap(promptColIdx, 0); 230 setPixmap(promptColIdx, 0);
216 setText(noColIdx, 0); 231 setText(noColIdx, QString::null);
217 setText(modColIdx, 0); 232 setText(modColIdx, QString::null);
218 setText(yesColIdx, 0); 233 setText(yesColIdx, QString::null);
219 break; 234 break;
220 } 235 }
221 expr = sym_get_tristate_value(sym); 236 expr = sym_get_tristate_value(sym);
@@ -257,6 +272,7 @@ void ConfigItem::updateMenu(void)
257 const char* data; 272 const char* data;
258 273
259 data = sym_get_string_value(sym); 274 data = sym_get_string_value(sym);
275
260#if QT_VERSION >= 300 276#if QT_VERSION >= 300
261 int i = list->mapIdx(dataColIdx); 277 int i = list->mapIdx(dataColIdx);
262 if (i >= 0) 278 if (i >= 0)
@@ -264,9 +280,9 @@ void ConfigItem::updateMenu(void)
264#endif 280#endif
265 setText(dataColIdx, data); 281 setText(dataColIdx, data);
266 if (type == S_STRING) 282 if (type == S_STRING)
267 prompt.sprintf("%s: %s", prompt.latin1(), data); 283 prompt = QString("%1: %2").arg(prompt).arg(data);
268 else 284 else
269 prompt.sprintf("(%s) %s", data, prompt.latin1()); 285 prompt = QString("(%2) %1").arg(prompt).arg(data);
270 break; 286 break;
271 } 287 }
272 if (!sym_has_value(sym) && visible) 288 if (!sym_has_value(sym) && visible)
@@ -343,9 +359,9 @@ void ConfigLineEdit::show(ConfigItem* i)
343{ 359{
344 item = i; 360 item = i;
345 if (sym_get_string_value(item->menu->sym)) 361 if (sym_get_string_value(item->menu->sym))
346 setText(sym_get_string_value(item->menu->sym)); 362 setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));
347 else 363 else
348 setText(0); 364 setText(QString::null);
349 Parent::show(); 365 Parent::show();
350 setFocus(); 366 setFocus();
351} 367}
@@ -961,7 +977,7 @@ ConfigMainWindow::ConfigMainWindow(void)
961 delete configSettings; 977 delete configSettings;
962} 978}
963 979
964static QString print_filter(const char *str) 980static QString print_filter(const QString &str)
965{ 981{
966 QRegExp re("[<>&\"\\n]"); 982 QRegExp re("[<>&\"\\n]");
967 QString res = str; 983 QString res = str;
@@ -994,7 +1010,7 @@ static QString print_filter(const char *str)
994 1010
995static void expr_print_help(void *data, const char *str) 1011static void expr_print_help(void *data, const char *str)
996{ 1012{
997 ((QString*)data)->append(print_filter(str)); 1013 reinterpret_cast<QString*>(data)->append(print_filter(str));
998} 1014}
999 1015
1000/* 1016/*
@@ -1009,7 +1025,7 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
1009 if (item) 1025 if (item)
1010 menu = ((ConfigItem*)item)->menu; 1026 menu = ((ConfigItem*)item)->menu;
1011 if (!menu) { 1027 if (!menu) {
1012 helpText->setText(NULL); 1028 helpText->setText(QString::null);
1013 return; 1029 return;
1014 } 1030 }
1015 1031
@@ -1019,16 +1035,16 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
1019 if (sym) { 1035 if (sym) {
1020 if (menu->prompt) { 1036 if (menu->prompt) {
1021 head += "<big><b>"; 1037 head += "<big><b>";
1022 head += print_filter(menu->prompt->text); 1038 head += print_filter(_(menu->prompt->text));
1023 head += "</b></big>"; 1039 head += "</b></big>";
1024 if (sym->name) { 1040 if (sym->name) {
1025 head += " ("; 1041 head += " (";
1026 head += print_filter(sym->name); 1042 head += print_filter(_(sym->name));
1027 head += ")"; 1043 head += ")";
1028 } 1044 }
1029 } else if (sym->name) { 1045 } else if (sym->name) {
1030 head += "<big><b>"; 1046 head += "<big><b>";
1031 head += print_filter(sym->name); 1047 head += print_filter(_(sym->name));
1032 head += "</b></big>"; 1048 head += "</b></big>";
1033 } 1049 }
1034 head += "<br><br>"; 1050 head += "<br><br>";
@@ -1049,7 +1065,7 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
1049 case P_PROMPT: 1065 case P_PROMPT:
1050 case P_MENU: 1066 case P_MENU:
1051 debug += "prompt: "; 1067 debug += "prompt: ";
1052 debug += print_filter(prop->text); 1068 debug += print_filter(_(prop->text));
1053 debug += "<br>"; 1069 debug += "<br>";
1054 break; 1070 break;
1055 case P_DEFAULT: 1071 case P_DEFAULT:
@@ -1088,10 +1104,10 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
1088 debug += "<br>"; 1104 debug += "<br>";
1089 } 1105 }
1090 1106
1091 help = print_filter(sym->help); 1107 help = print_filter(_(sym->help));
1092 } else if (menu->prompt) { 1108 } else if (menu->prompt) {
1093 head += "<big><b>"; 1109 head += "<big><b>";
1094 head += print_filter(menu->prompt->text); 1110 head += print_filter(_(menu->prompt->text));
1095 head += "</b></big><br><br>"; 1111 head += "</b></big><br><br>";
1096 if (showDebug) { 1112 if (showDebug) {
1097 if (menu->prompt->visible.expr) { 1113 if (menu->prompt->visible.expr) {
@@ -1111,7 +1127,7 @@ void ConfigMainWindow::loadConfig(void)
1111 QString s = QFileDialog::getOpenFileName(".config", NULL, this); 1127 QString s = QFileDialog::getOpenFileName(".config", NULL, this);
1112 if (s.isNull()) 1128 if (s.isNull())
1113 return; 1129 return;
1114 if (conf_read(s.latin1())) 1130 if (conf_read(QFile::encodeName(s)))
1115 QMessageBox::information(this, "qconf", "Unable to load configuration!"); 1131 QMessageBox::information(this, "qconf", "Unable to load configuration!");
1116 ConfigView::updateListAll(); 1132 ConfigView::updateListAll();
1117} 1133}
@@ -1127,7 +1143,7 @@ void ConfigMainWindow::saveConfigAs(void)
1127 QString s = QFileDialog::getSaveFileName(".config", NULL, this); 1143 QString s = QFileDialog::getSaveFileName(".config", NULL, this);
1128 if (s.isNull()) 1144 if (s.isNull())
1129 return; 1145 return;
1130 if (conf_write(s.latin1())) 1146 if (conf_write(QFile::encodeName(s)))
1131 QMessageBox::information(this, "qconf", "Unable to save configuration!"); 1147 QMessageBox::information(this, "qconf", "Unable to save configuration!");
1132} 1148}
1133 1149
@@ -1372,6 +1388,9 @@ int main(int ac, char** av)
1372 ConfigMainWindow* v; 1388 ConfigMainWindow* v;
1373 const char *name; 1389 const char *name;
1374 1390
1391 bindtextdomain(PACKAGE, LOCALEDIR);
1392 textdomain(PACKAGE);
1393
1375#ifndef LKC_DIRECT_LINK 1394#ifndef LKC_DIRECT_LINK
1376 kconfig_load(); 1395 kconfig_load();
1377#endif 1396#endif
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 8b1dab63f11c..0835dc2a8aa9 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -553,15 +553,20 @@ sub output_section_xml(%) {
553 # print out each section 553 # print out each section
554 $lineprefix=" "; 554 $lineprefix=" ";
555 foreach $section (@{$args{'sectionlist'}}) { 555 foreach $section (@{$args{'sectionlist'}}) {
556 print "<refsect1>\n <title>$section</title>\n <para>\n"; 556 print "<refsect1>\n";
557 print "<title>$section</title>\n";
557 if ($section =~ m/EXAMPLE/i) { 558 if ($section =~ m/EXAMPLE/i) {
558 print "<example><para>\n"; 559 print "<informalexample><programlisting>\n";
560 } else {
561 print "<para>\n";
559 } 562 }
560 output_highlight($args{'sections'}{$section}); 563 output_highlight($args{'sections'}{$section});
561 if ($section =~ m/EXAMPLE/i) { 564 if ($section =~ m/EXAMPLE/i) {
562 print "</para></example>\n"; 565 print "</programlisting></informalexample>\n";
566 } else {
567 print "</para>\n";
563 } 568 }
564 print " </para>\n</refsect1>\n"; 569 print "</refsect1>\n";
565 } 570 }
566} 571}
567 572
@@ -576,8 +581,14 @@ sub output_function_xml(%) {
576 $id =~ s/[^A-Za-z0-9]/-/g; 581 $id =~ s/[^A-Za-z0-9]/-/g;
577 582
578 print "<refentry>\n"; 583 print "<refentry>\n";
584 print "<refentryinfo>\n";
585 print " <title>LINUX</title>\n";
586 print " <productname>Kernel Hackers Manual</productname>\n";
587 print " <date>$man_date</date>\n";
588 print "</refentryinfo>\n";
579 print "<refmeta>\n"; 589 print "<refmeta>\n";
580 print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n"; 590 print " <refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n";
591 print " <manvolnum>9</manvolnum>\n";
581 print "</refmeta>\n"; 592 print "</refmeta>\n";
582 print "<refnamediv>\n"; 593 print "<refnamediv>\n";
583 print " <refname>".$args{'function'}."</refname>\n"; 594 print " <refname>".$args{'function'}."</refname>\n";
@@ -607,7 +618,7 @@ sub output_function_xml(%) {
607 } 618 }
608 } 619 }
609 } else { 620 } else {
610 print " <void>\n"; 621 print " <void/>\n";
611 } 622 }
612 print " </funcprototype></funcsynopsis>\n"; 623 print " </funcprototype></funcsynopsis>\n";
613 print "</refsynopsisdiv>\n"; 624 print "</refsynopsisdiv>\n";
@@ -646,8 +657,14 @@ sub output_struct_xml(%) {
646 $id =~ s/[^A-Za-z0-9]/-/g; 657 $id =~ s/[^A-Za-z0-9]/-/g;
647 658
648 print "<refentry>\n"; 659 print "<refentry>\n";
660 print "<refentryinfo>\n";
661 print " <title>LINUX</title>\n";
662 print " <productname>Kernel Hackers Manual</productname>\n";
663 print " <date>$man_date</date>\n";
664 print "</refentryinfo>\n";
649 print "<refmeta>\n"; 665 print "<refmeta>\n";
650 print "<refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n"; 666 print " <refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
667 print " <manvolnum>9</manvolnum>\n";
651 print "</refmeta>\n"; 668 print "</refmeta>\n";
652 print "<refnamediv>\n"; 669 print "<refnamediv>\n";
653 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n"; 670 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
@@ -724,8 +741,14 @@ sub output_enum_xml(%) {
724 $id =~ s/[^A-Za-z0-9]/-/g; 741 $id =~ s/[^A-Za-z0-9]/-/g;
725 742
726 print "<refentry>\n"; 743 print "<refentry>\n";
744 print "<refentryinfo>\n";
745 print " <title>LINUX</title>\n";
746 print " <productname>Kernel Hackers Manual</productname>\n";
747 print " <date>$man_date</date>\n";
748 print "</refentryinfo>\n";
727 print "<refmeta>\n"; 749 print "<refmeta>\n";
728 print "<refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n"; 750 print " <refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n";
751 print " <manvolnum>9</manvolnum>\n";
729 print "</refmeta>\n"; 752 print "</refmeta>\n";
730 print "<refnamediv>\n"; 753 print "<refnamediv>\n";
731 print " <refname>enum ".$args{'enum'}."</refname>\n"; 754 print " <refname>enum ".$args{'enum'}."</refname>\n";
@@ -784,8 +807,14 @@ sub output_typedef_xml(%) {
784 $id =~ s/[^A-Za-z0-9]/-/g; 807 $id =~ s/[^A-Za-z0-9]/-/g;
785 808
786 print "<refentry>\n"; 809 print "<refentry>\n";
810 print "<refentryinfo>\n";
811 print " <title>LINUX</title>\n";
812 print " <productname>Kernel Hackers Manual</productname>\n";
813 print " <date>$man_date</date>\n";
814 print "</refentryinfo>\n";
787 print "<refmeta>\n"; 815 print "<refmeta>\n";
788 print "<refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n"; 816 print " <refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
817 print " <manvolnum>9</manvolnum>\n";
789 print "</refmeta>\n"; 818 print "</refmeta>\n";
790 print "<refnamediv>\n"; 819 print "<refnamediv>\n";
791 print " <refname>typedef ".$args{'typedef'}."</refname>\n"; 820 print " <refname>typedef ".$args{'typedef'}."</refname>\n";
@@ -1465,6 +1494,8 @@ sub dump_function($$) {
1465 1494
1466 $prototype =~ s/^static +//; 1495 $prototype =~ s/^static +//;
1467 $prototype =~ s/^extern +//; 1496 $prototype =~ s/^extern +//;
1497 $prototype =~ s/^fastcall +//;
1498 $prototype =~ s/^asmlinkage +//;
1468 $prototype =~ s/^inline +//; 1499 $prototype =~ s/^inline +//;
1469 $prototype =~ s/^__inline__ +//; 1500 $prototype =~ s/^__inline__ +//;
1470 $prototype =~ s/^#define +//; #ak added 1501 $prototype =~ s/^#define +//; #ak added
diff --git a/scripts/makeman b/scripts/makeman
deleted file mode 100755
index db3af647ee17..000000000000
--- a/scripts/makeman
+++ /dev/null
@@ -1,185 +0,0 @@
1#!/usr/bin/perl
2
3use strict;
4
5## Copyright (C) Michael Still (mikal@stillhq.com)
6## Released under the terms of the GNU GPL
7##
8## A script to make or install the manpages extracted by split-man
9##
10## Arguements: $1 -- the word "convert" or "install"
11## $2 -- the directory containing the SGML files for the manpages
12## $3 -- the filename which contained the sgmldoc output
13## (I need this so I know which manpages to convert)
14
15my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename, $tmpdir);
16
17if($ARGV[0] eq ""){
18 die "Usage: makeman [convert | install] <dir> <file>\n";
19}
20
21if( ! -d "$ARGV[1]" ){
22 die "Output directory \"$ARGV[1]\" does not exist\n";
23}
24
25if($ENV{"TMPDIR"} ne ""){
26 $tmpdir = $ENV{"TMPDIR"};
27}
28else{
29 $tmpdir = "/tmp";
30}
31
32if($ARGV[0] eq "convert"){
33 open LISTING, "grep \"<refentrytitle>\" $ARGV[2] |";
34 while(<LISTING>){
35 s/<\/.*$//;
36 s/^.*>//;
37 s/\.sgml//;
38 s/struct //;
39 s/typedef //;
40
41 chomp;
42 $filename = $_;
43 print "Processing $filename\n";
44
45 # Open the input file to extract the front matter, generate the man page,
46 # and open it, and the rearrange everything until it is happy
47 open INPUT, "< $ARGV[1]/$filename.sgml";
48 $front = "";
49 $mode = 0;
50
51 # The modes used here are:
52 # mode = 0
53 # <!-- BEGINFRONTTAG -->
54 # <!-- <bookinfo> mode = 1
55 # <!-- <legalnotice> mode = 2
56 # <!-- ...GPL or whatever...
57 # <!-- </legalnotice> mode = 4
58 # <!-- </bookinfo> mode = 3
59 # <!-- ENDFRONTTAG -->
60 #
61 # ...doco...
62
63 # I know that some of the if statements in this while loop are in a funny
64 # order, but that is deliberate...
65 while(<INPUT>){
66 if($mode > 0){
67 s/<!-- //;
68 s/ -->//;
69 s/<docinfo>//i;
70 s<\/docinfo>//i;
71 s/^[ \t]*//i;
72 }
73
74 if($mode == 2){
75 if(/<para>/i){
76 }
77 elsif(/<\/para>/i){
78 $front = "$front.\\\" \n";
79 }
80 elsif(/<\/legalnotice>/i){
81 $mode = 4;
82 }
83 elsif(/^[ \t]*$/){
84 }
85 else{
86 $front = "$front.\\\" $_";
87 }
88 }
89
90 if($mode == 1){
91 if(/<title>(.*)<\/title>/i){
92 $front = "$front.\\\" This documentation was generated from the book titled \"$1\", which is part of the Linux kernel source.\n.\\\" \n";
93 }
94 elsif(/<legalnotice>/i){
95 $front = "$front.\\\" This documentation comes with the following legal notice:\n.\\\" \n";
96 $mode = 2;
97 }
98
99 elsif(/<author>/i){
100 $front = "$front.\\\" Documentation by: ";
101 }
102 elsif(/<firstname>(.*)<\/firstname>/i){
103 $front = "$front$1 ";
104 }
105 elsif(/<surname>(.*)<\/surname>/i){
106 $front = "$front$1 ";
107 }
108 elsif(/<email>(.*)<\/email>/i){
109 $front = "$front($1)";
110 }
111 elsif(/\/author>/i){
112 $front = "$front\n";
113 }
114
115 elsif(/<copyright>/i){
116 $front = "$front.\\\" Documentation copyright: ";
117 }
118 elsif(/<holder>(.*)<\/holder>/i){
119 $front = "$front$1 ";
120 }
121 elsif(/<year>(.*)<\/year>/i){
122 $front = "$front$1 ";
123 }
124 elsif(/\/copyright>/i){
125 $front = "$front\n";
126 }
127
128 elsif(/^[ \t]*$/
129 || /<affiliation>/i
130 || /<\/affiliation>/i
131 || /<address>/i
132 || /<\/address>/i
133 || /<authorgroup>/i
134 || /<\/authorgroup>/i
135 || /<\/legalnotice>/i
136 || /<date>/i
137 || /<\/date>/i
138 || /<edition>/i
139 || /<\/edition>/i
140 || /<pubdate>/i
141 || /<\/pubdate>/i){
142 }
143 else{
144 print "Unknown tag in manpage conversion: $_";
145 }
146 }
147
148 if($mode == 0){
149 if(/<bookinfo>/i){
150 $mode = 1;
151 }
152 }
153
154 if($mode == 4){
155 if(/<\/bookinfo>/i){
156 $mode = 3;
157 }
158 }
159 }
160 close INPUT;
161
162 system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 $tmpdir/$$.9\n");
163 open GENERATED, "< $tmpdir/$$.9";
164 open OUTPUT, "> $ARGV[1]/$filename.9";
165
166 print OUTPUT "$front";
167 print OUTPUT ".\\\" For comments on the formatting of this manpage, please contact Michael Still <mikal\@stillhq.com>\n\n";
168 while(<GENERATED>){
169 print OUTPUT "$_";
170 }
171 close OUTPUT;
172 close GENERATED;
173
174 system("gzip -f $ARGV[1]/$filename.9\n");
175 unlink("$tmpdir/$$.9");
176 }
177}
178elsif($ARGV[0] eq "install"){
179 system("mkdir -p /usr/local/man/man9/; install $ARGV[1]/*.9.gz /usr/local/man/man9/");
180}
181else{
182 die "Usage: makeman [convert | install] <dir> <file>\n";
183}
184
185print "Done\n";
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index d54b52d3bb6f..32197efe67ed 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -47,32 +47,31 @@ do { \
47 sprintf(str + strlen(str), "*"); \ 47 sprintf(str + strlen(str), "*"); \
48} while(0) 48} while(0)
49 49
50/* Looks like "usb:vNpNdlNdhNdcNdscNdpNicNiscNipN" */ 50/* USB is special because the bcdDevice can be matched against a numeric range */
51static int do_usb_entry(const char *filename, 51/* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
52 struct usb_device_id *id, char *alias) 52static void do_usb_entry(struct usb_device_id *id,
53 unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
54 unsigned char range_lo, unsigned char range_hi,
55 struct module *mod)
53{ 56{
54 id->match_flags = TO_NATIVE(id->match_flags); 57 char alias[500];
55 id->idVendor = TO_NATIVE(id->idVendor);
56 id->idProduct = TO_NATIVE(id->idProduct);
57 id->bcdDevice_lo = TO_NATIVE(id->bcdDevice_lo);
58 id->bcdDevice_hi = TO_NATIVE(id->bcdDevice_hi);
59
60 /*
61 * Some modules (visor) have empty slots as placeholder for
62 * run-time specification that results in catch-all alias
63 */
64 if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
65 return 1;
66
67 strcpy(alias, "usb:"); 58 strcpy(alias, "usb:");
68 ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR, 59 ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
69 id->idVendor); 60 id->idVendor);
70 ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT, 61 ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
71 id->idProduct); 62 id->idProduct);
72 ADD(alias, "dl", id->match_flags&USB_DEVICE_ID_MATCH_DEV_LO, 63
73 id->bcdDevice_lo); 64 strcat(alias, "d");
74 ADD(alias, "dh", id->match_flags&USB_DEVICE_ID_MATCH_DEV_HI, 65 if (bcdDevice_initial_digits)
75 id->bcdDevice_hi); 66 sprintf(alias + strlen(alias), "%0*X",
67 bcdDevice_initial_digits, bcdDevice_initial);
68 if (range_lo == range_hi)
69 sprintf(alias + strlen(alias), "%u", range_lo);
70 else if (range_lo > 0 || range_hi < 9)
71 sprintf(alias + strlen(alias), "[%u-%u]", range_lo, range_hi);
72 if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
73 strcat(alias, "*");
74
76 ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS, 75 ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
77 id->bDeviceClass); 76 id->bDeviceClass);
78 ADD(alias, "dsc", 77 ADD(alias, "dsc",
@@ -90,7 +89,73 @@ static int do_usb_entry(const char *filename,
90 ADD(alias, "ip", 89 ADD(alias, "ip",
91 id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL, 90 id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
92 id->bInterfaceProtocol); 91 id->bInterfaceProtocol);
93 return 1; 92
93 /* Always end in a wildcard, for future extension */
94 if (alias[strlen(alias)-1] != '*')
95 strcat(alias, "*");
96 buf_printf(&mod->dev_table_buf,
97 "MODULE_ALIAS(\"%s\");\n", alias);
98}
99
100static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
101{
102 unsigned int devlo, devhi;
103 unsigned char chi, clo;
104 int ndigits;
105
106 id->match_flags = TO_NATIVE(id->match_flags);
107 id->idVendor = TO_NATIVE(id->idVendor);
108 id->idProduct = TO_NATIVE(id->idProduct);
109
110 devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ?
111 TO_NATIVE(id->bcdDevice_lo) : 0x0U;
112 devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ?
113 TO_NATIVE(id->bcdDevice_hi) : ~0x0U;
114
115 /*
116 * Some modules (visor) have empty slots as placeholder for
117 * run-time specification that results in catch-all alias
118 */
119 if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
120 return;
121
122 /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */
123 for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) {
124 clo = devlo & 0xf;
125 chi = devhi & 0xf;
126 if (chi > 9) /* it's bcd not hex */
127 chi = 9;
128 devlo >>= 4;
129 devhi >>= 4;
130
131 if (devlo == devhi || !ndigits) {
132 do_usb_entry(id, devlo, ndigits, clo, chi, mod);
133 break;
134 }
135
136 if (clo > 0)
137 do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
138
139 if (chi < 9)
140 do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
141 }
142}
143
144static void do_usb_table(void *symval, unsigned long size,
145 struct module *mod)
146{
147 unsigned int i;
148 const unsigned long id_size = sizeof(struct usb_device_id);
149
150 if (size % id_size || size < id_size) {
151 fprintf(stderr, "*** Warning: %s ids %lu bad size "
152 "(each on %lu)\n", mod->name, size, id_size);
153 }
154 /* Leave last one: it's the terminator. */
155 size -= id_size;
156
157 for (i = 0; i < size; i += id_size)
158 do_usb_entry_multi(symval + i, mod);
94} 159}
95 160
96/* Looks like: ieee1394:venNmoNspNverN */ 161/* Looks like: ieee1394:venNmoNspNverN */
@@ -280,8 +345,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
280 do_table(symval, sym->st_size, sizeof(struct pci_device_id), 345 do_table(symval, sym->st_size, sizeof(struct pci_device_id),
281 do_pci_entry, mod); 346 do_pci_entry, mod);
282 else if (sym_is(symname, "__mod_usb_device_table")) 347 else if (sym_is(symname, "__mod_usb_device_table"))
283 do_table(symval, sym->st_size, sizeof(struct usb_device_id), 348 /* special case to handle bcdDevice ranges */
284 do_usb_entry, mod); 349 do_usb_table(symval, sym->st_size, mod);
285 else if (sym_is(symname, "__mod_ieee1394_device_table")) 350 else if (sym_is(symname, "__mod_ieee1394_device_table"))
286 do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id), 351 do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
287 do_ieee1394_entry, mod); 352 do_ieee1394_entry, mod);
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index 43af01075612..f2d47ca9c8fa 100755
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -46,6 +46,19 @@
46# fix some whitespace damage; 46# fix some whitespace damage;
47# be smarter about stopping when current version is larger than requested; 47# be smarter about stopping when current version is larger than requested;
48# Randy Dunlap <rddunlap@osdl.org>, 2004-AUG-18. 48# Randy Dunlap <rddunlap@osdl.org>, 2004-AUG-18.
49#
50# Add better support for (non-incremental) 2.6.x.y patches;
51# If an ending version number if not specified, the script automatically
52# increments the SUBLEVEL (x in 2.6.x.y) until no more patch files are found;
53# however, EXTRAVERSION (y in 2.6.x.y) is never automatically incremented
54# but must be specified fully.
55#
56# patch-kernel does not normally support reverse patching, but does so when
57# applying EXTRAVERSION (x.y) patches, so that moving from 2.6.11.y to 2.6.11.z
58# is easy and handled by the script (reverse 2.6.11.y and apply 2.6.11.z).
59# Randy Dunlap <rddunlap@osdl.org>, 2005-APR-08.
60
61PNAME=patch-kernel
49 62
50# Set directories from arguments, or use defaults. 63# Set directories from arguments, or use defaults.
51sourcedir=${1-/usr/src/linux} 64sourcedir=${1-/usr/src/linux}
@@ -54,7 +67,7 @@ stopvers=${3-default}
54 67
55if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then 68if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then
56cat << USAGE 69cat << USAGE
57usage: patch-kernel [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ] 70usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
58 source directory defaults to /usr/src/linux, 71 source directory defaults to /usr/src/linux,
59 patch directory defaults to the current directory, 72 patch directory defaults to the current directory,
60 stopversion defaults to <all in patchdir>. 73 stopversion defaults to <all in patchdir>.
@@ -73,6 +86,19 @@ do
73done 86done
74 87
75# --------------------------------------------------------------------------- 88# ---------------------------------------------------------------------------
89# arg1 is filename
90noFile () {
91 echo "cannot find patch file: ${patch}"
92 exit 1
93}
94
95# ---------------------------------------------------------------------------
96backwards () {
97 echo "$PNAME does not support reverse patching"
98 exit 1
99}
100
101# ---------------------------------------------------------------------------
76# Find a file, first parameter is basename of file 102# Find a file, first parameter is basename of file
77# it tries many compression mechanisms and sets variables to say how to get it 103# it tries many compression mechanisms and sets variables to say how to get it
78findFile () { 104findFile () {
@@ -133,6 +159,28 @@ applyPatch () {
133 return 0; 159 return 0;
134} 160}
135 161
162# ---------------------------------------------------------------------------
163# arg1 is patch filename
164reversePatch () {
165 echo -n "Reversing $1 (${name}) ... "
166 if $uncomp ${patchdir}/"$1"${ext} | patch -p1 -Rs -N -E -d $sourcedir
167 then
168 echo "done."
169 else
170 echo "failed. Clean it up."
171 exit 1
172 fi
173 if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ]
174 then
175 echo "Aborting. Reject files found."
176 return 1
177 fi
178 # Remove backup files
179 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
180
181 return 0
182}
183
136# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION 184# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
137TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; } 185TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
138grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE 186grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
@@ -160,53 +208,57 @@ then
160 EXTRAVER=$EXTRAVERSION 208 EXTRAVER=$EXTRAVERSION
161 fi 209 fi
162 EXTRAVER=${EXTRAVER%%[[:punct:]]*} 210 EXTRAVER=${EXTRAVER%%[[:punct:]]*}
163 #echo "patch-kernel: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER" 211 #echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
164fi 212fi
165 213
166#echo "stopvers=$stopvers" 214#echo "stopvers=$stopvers"
167if [ $stopvers != "default" ]; then 215if [ $stopvers != "default" ]; then
168 STOPSUBLEVEL=`echo $stopvers | cut -d. -f3` 216 STOPSUBLEVEL=`echo $stopvers | cut -d. -f3`
169 STOPEXTRA=`echo $stopvers | cut -d. -f4` 217 STOPEXTRA=`echo $stopvers | cut -d. -f4`
170 #echo "STOPSUBLEVEL=$STOPSUBLEVEL, STOPEXTRA=$STOPEXTRA" 218 #echo "#___STOPSUBLEVEL=/$STOPSUBLEVEL/, STOPEXTRA=/$STOPEXTRA/"
171else 219else
172 STOPSUBLEVEL=9999 220 STOPSUBLEVEL=9999
173 STOPEXTRA=9999 221 STOPEXTRA=9999
174fi 222fi
175 223
176while : # incrementing SUBLEVEL (s in v.p.s) 224# This all assumes a 2.6.x[.y] kernel tree.
177do 225# Don't allow backwards/reverse patching.
178 if [ x$EXTRAVER != "x" ]; then 226if [ $STOPSUBLEVEL -lt $SUBLEVEL ]; then
227 backwards
228fi
229
230if [ x$EXTRAVER != "x" ]; then
179 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER" 231 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER"
180 else 232else
181 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 233 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
182 fi 234fi
235
236if [ x$EXTRAVER != "x" ]; then
237 echo "backing up to: $VERSION.$PATCHLEVEL.$SUBLEVEL"
238 patch="patch-${CURRENTFULLVERSION}"
239 findFile $patchdir/${patch} || noFile ${patch}
240 reversePatch ${patch} || exit 1
241fi
183 242
243# now current is 2.6.x, with no EXTRA applied,
244# so update to target SUBLEVEL (2.6.SUBLEVEL)
245# and then to target EXTRAVER (2.6.SUB.EXTRAVER) if requested.
246# If not ending sublevel is specified, it is incremented until
247# no further sublevels are found.
248
249if [ $STOPSUBLEVEL -gt $SUBLEVEL ]; then
250while : # incrementing SUBLEVEL (s in v.p.s)
251do
252 CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
253 EXTRAVER=
184 if [ $stopvers == $CURRENTFULLVERSION ]; then 254 if [ $stopvers == $CURRENTFULLVERSION ]; then
185 echo "Stopping at $CURRENTFULLVERSION base as requested." 255 echo "Stopping at $CURRENTFULLVERSION base as requested."
186 break 256 break
187 fi 257 fi
188 258
189 while : # incrementing EXTRAVER (x in v.p.s.x)
190 do
191 EXTRAVER=$((EXTRAVER + 1))
192 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$EXTRAVER"
193 #echo "... trying $FULLVERSION ..."
194
195 patch=patch-$FULLVERSION
196
197 # See if the file exists and find extension
198 findFile $patchdir/${patch} || break
199
200 # Apply the patch and check all is OK
201 applyPatch $patch || break
202
203 continue 2
204 done
205
206 EXTRAVER=
207 SUBLEVEL=$((SUBLEVEL + 1)) 259 SUBLEVEL=$((SUBLEVEL + 1))
208 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" 260 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
209 #echo "___ trying $FULLVERSION ___" 261 #echo "#___ trying $FULLVERSION ___"
210 262
211 if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then 263 if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then
212 echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)" 264 echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
@@ -214,14 +266,33 @@ do
214 fi 266 fi
215 267
216 patch=patch-$FULLVERSION 268 patch=patch-$FULLVERSION
217
218 # See if the file exists and find extension 269 # See if the file exists and find extension
219 findFile $patchdir/${patch} || break 270 findFile $patchdir/${patch} || noFile ${patch}
220 271
221 # Apply the patch and check all is OK 272 # Apply the patch and check all is OK
222 applyPatch $patch || break 273 applyPatch $patch || break
223done 274done
224#echo "base all done" 275#echo "#___sublevel all done"
276fi
277
278# There is no incremental searching for extraversion...
279if [ "$STOPEXTRA" != "" ]; then
280while : # just to allow break
281do
282# apply STOPEXTRA directly (not incrementally) (x in v.p.s.x)
283 FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL.$STOPEXTRA"
284 #echo "#... trying $FULLVERSION ..."
285 patch=patch-$FULLVERSION
286
287 # See if the file exists and find extension
288 findFile $patchdir/${patch} || noFile ${patch}
289
290 # Apply the patch and check all is OK
291 applyPatch $patch || break
292 #echo "#___extraver all done"
293 break
294done
295fi
225 296
226if [ x$gotac != x ]; then 297if [ x$gotac != x ]; then
227 # Out great user wants the -ac patches 298 # Out great user wants the -ac patches
diff --git a/scripts/split-man b/scripts/split-man
deleted file mode 100755
index 03897fe6a75d..000000000000
--- a/scripts/split-man
+++ /dev/null
@@ -1,112 +0,0 @@
1#!/usr/bin/perl
2
3use strict;
4
5## Copyright (C) Michael Still (mikal@stillhq.com)
6## Released under the terms of the GNU GPL
7##
8## Hoon through the specified DocBook SGML file, and split out the
9## man pages. These can then be processed into groff format, and
10## installed if desired...
11##
12## Arguements: $1 -- the name of the sgml file
13## $2 -- the directory to put the generated SGML files in
14## $3 -- kernel version
15
16my($SGML, $REF, $front, $refdata, $mode, $filename);
17
18if(($ARGV[0] eq "") || ($ARGV[1] eq "") || ($ARGV[2] eq "")){
19 die "Usage: split-man <sgml file> <output dir> <kernel version>\n";
20}
21
22open SGML, "< $ARGV[0]" or die "Could not open input file \"$ARGV[0]\"\n";
23if( ! -d "$ARGV[1]" ){
24 die "Output directory \"$ARGV[1]\" does not exist\n";
25}
26
27# Possible modes:
28# 0: Looking for input I care about
29# 1: Inside book front matter
30# 2: Inside a refentry
31# 3: Inside a refentry, and we know the filename
32
33$mode = 0;
34$refdata = "";
35$front = "";
36while(<SGML>){
37 # Starting modes
38 if(/<bookinfo>/ || /<docinfo>/){
39 $mode = 1;
40 }
41 elsif(/<refentry>/){
42 $mode = 2;
43 }
44 elsif(/<refentrytitle><phrase[^>]*>([^<]*)<.*$/){
45 $mode = 3;
46 $filename = $1;
47
48 $filename =~ s/struct //;
49 $filename =~ s/typedef //;
50
51 print "Found manpage for $filename\n";
52 open REF, "> $ARGV[1]/$filename.sgml" or
53 die "Couldn't open output file \"$ARGV[1]/$filename.sgml\": $!\n";
54 print REF <<EOF;
55<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
56
57<!-- BEGINFRONTTAG: The following is front matter for the parent book -->
58$front
59<!-- ENDFRONTTAG: End front matter -->
60
61$refdata
62EOF
63 $refdata = "";
64 }
65
66 # Extraction
67 if($mode == 1){
68 chomp $_;
69 $front = "$front<!-- $_ -->\n";
70 }
71 elsif($mode == 2){
72 $refdata = "$refdata$_";
73 }
74 elsif($mode == 3){
75 # There are some fixups which need to be applied
76 if(/<\/refmeta>/){
77 print REF "<manvolnum>9</manvolnum>\n";
78 }
79 if(/<\/refentry>/){
80 print REF <<EOF;
81<refsect1><title>About this document</title>
82<para>
83This documentation was generated with kernel version $ARGV[2].
84</para>
85</refsect1>
86EOF
87 }
88
89 # For some reason, we title the synopsis twice in the main DocBook
90 if(! /<title>Synopsis<\/title>/){
91 if(/<refentrytitle>/){
92 s/struct //;
93 s/typedef //;
94 }
95
96 print REF "$_";
97 }
98 }
99
100 # Ending modes
101 if(/<\/bookinfo>/ || /<\/docinfo>/){
102 $mode = 0;
103 }
104 elsif(/<\/refentry>/){
105 $mode = 0;
106 close REF;
107 }
108}
109
110# And make sure we don't process this unnessesarily
111$ARGV[0] =~ s/\.sgml/.9/;
112`touch $ARGV[0]`;
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 2ae7d3cb8df4..aae1e794fe48 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2855,8 +2855,7 @@ static int selinux_parse_skb_ipv6(struct sk_buff *skb, struct avc_audit_data *ad
2855 2855
2856 nexthdr = ip6->nexthdr; 2856 nexthdr = ip6->nexthdr;
2857 offset += sizeof(_ipv6h); 2857 offset += sizeof(_ipv6h);
2858 offset = ipv6_skip_exthdr(skb, offset, &nexthdr, 2858 offset = ipv6_skip_exthdr(skb, offset, &nexthdr);
2859 skb->tail - skb->head - offset);
2860 if (offset < 0) 2859 if (offset < 0)
2861 goto out; 2860 goto out;
2862 2861
@@ -3668,7 +3667,7 @@ static void msg_msg_free_security(struct msg_msg *msg)
3668} 3667}
3669 3668
3670static int ipc_has_perm(struct kern_ipc_perm *ipc_perms, 3669static int ipc_has_perm(struct kern_ipc_perm *ipc_perms,
3671 u16 sclass, u32 perms) 3670 u32 perms)
3672{ 3671{
3673 struct task_security_struct *tsec; 3672 struct task_security_struct *tsec;
3674 struct ipc_security_struct *isec; 3673 struct ipc_security_struct *isec;
@@ -3680,7 +3679,7 @@ static int ipc_has_perm(struct kern_ipc_perm *ipc_perms,
3680 AVC_AUDIT_DATA_INIT(&ad, IPC); 3679 AVC_AUDIT_DATA_INIT(&ad, IPC);
3681 ad.u.ipc_id = ipc_perms->key; 3680 ad.u.ipc_id = ipc_perms->key;
3682 3681
3683 return avc_has_perm(tsec->sid, isec->sid, sclass, perms, &ad); 3682 return avc_has_perm(tsec->sid, isec->sid, isec->sclass, perms, &ad);
3684} 3683}
3685 3684
3686static int selinux_msg_msg_alloc_security(struct msg_msg *msg) 3685static int selinux_msg_msg_alloc_security(struct msg_msg *msg)
@@ -3765,7 +3764,7 @@ static int selinux_msg_queue_msgctl(struct msg_queue *msq, int cmd)
3765 return 0; 3764 return 0;
3766 } 3765 }
3767 3766
3768 err = ipc_has_perm(&msq->q_perm, SECCLASS_MSGQ, perms); 3767 err = ipc_has_perm(&msq->q_perm, perms);
3769 return err; 3768 return err;
3770} 3769}
3771 3770
@@ -3917,7 +3916,7 @@ static int selinux_shm_shmctl(struct shmid_kernel *shp, int cmd)
3917 return 0; 3916 return 0;
3918 } 3917 }
3919 3918
3920 err = ipc_has_perm(&shp->shm_perm, SECCLASS_SHM, perms); 3919 err = ipc_has_perm(&shp->shm_perm, perms);
3921 return err; 3920 return err;
3922} 3921}
3923 3922
@@ -3936,7 +3935,7 @@ static int selinux_shm_shmat(struct shmid_kernel *shp,
3936 else 3935 else
3937 perms = SHM__READ | SHM__WRITE; 3936 perms = SHM__READ | SHM__WRITE;
3938 3937
3939 return ipc_has_perm(&shp->shm_perm, SECCLASS_SHM, perms); 3938 return ipc_has_perm(&shp->shm_perm, perms);
3940} 3939}
3941 3940
3942/* Semaphore security operations */ 3941/* Semaphore security operations */
@@ -4025,7 +4024,7 @@ static int selinux_sem_semctl(struct sem_array *sma, int cmd)
4025 return 0; 4024 return 0;
4026 } 4025 }
4027 4026
4028 err = ipc_has_perm(&sma->sem_perm, SECCLASS_SEM, perms); 4027 err = ipc_has_perm(&sma->sem_perm, perms);
4029 return err; 4028 return err;
4030} 4029}
4031 4030
@@ -4039,18 +4038,13 @@ static int selinux_sem_semop(struct sem_array *sma,
4039 else 4038 else
4040 perms = SEM__READ; 4039 perms = SEM__READ;
4041 4040
4042 return ipc_has_perm(&sma->sem_perm, SECCLASS_SEM, perms); 4041 return ipc_has_perm(&sma->sem_perm, perms);
4043} 4042}
4044 4043
4045static int selinux_ipc_permission(struct kern_ipc_perm *ipcp, short flag) 4044static int selinux_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
4046{ 4045{
4047 struct ipc_security_struct *isec = ipcp->security;
4048 u16 sclass = SECCLASS_IPC;
4049 u32 av = 0; 4046 u32 av = 0;
4050 4047
4051 if (isec && isec->magic == SELINUX_MAGIC)
4052 sclass = isec->sclass;
4053
4054 av = 0; 4048 av = 0;
4055 if (flag & S_IRUGO) 4049 if (flag & S_IRUGO)
4056 av |= IPC__UNIX_READ; 4050 av |= IPC__UNIX_READ;
@@ -4060,7 +4054,7 @@ static int selinux_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
4060 if (av == 0) 4054 if (av == 0)
4061 return 0; 4055 return 0;
4062 4056
4063 return ipc_has_perm(ipcp, sclass, av); 4057 return ipc_has_perm(ipcp, av);
4064} 4058}
4065 4059
4066/* module stacking operations */ 4060/* module stacking operations */
diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h
index eb340b45bc6f..8928bb4d3c53 100644
--- a/security/selinux/include/av_perm_to_string.h
+++ b/security/selinux/include/av_perm_to_string.h
@@ -220,6 +220,8 @@
220 S_(SECCLASS_NETLINK_XFRM_SOCKET, NETLINK_XFRM_SOCKET__NLMSG_WRITE, "nlmsg_write") 220 S_(SECCLASS_NETLINK_XFRM_SOCKET, NETLINK_XFRM_SOCKET__NLMSG_WRITE, "nlmsg_write")
221 S_(SECCLASS_NETLINK_AUDIT_SOCKET, NETLINK_AUDIT_SOCKET__NLMSG_READ, "nlmsg_read") 221 S_(SECCLASS_NETLINK_AUDIT_SOCKET, NETLINK_AUDIT_SOCKET__NLMSG_READ, "nlmsg_read")
222 S_(SECCLASS_NETLINK_AUDIT_SOCKET, NETLINK_AUDIT_SOCKET__NLMSG_WRITE, "nlmsg_write") 222 S_(SECCLASS_NETLINK_AUDIT_SOCKET, NETLINK_AUDIT_SOCKET__NLMSG_WRITE, "nlmsg_write")
223 S_(SECCLASS_NETLINK_AUDIT_SOCKET, NETLINK_AUDIT_SOCKET__NLMSG_RELAY, "nlmsg_relay")
224 S_(SECCLASS_NETLINK_AUDIT_SOCKET, NETLINK_AUDIT_SOCKET__NLMSG_READPRIV, "nlmsg_readpriv")
223 S_(SECCLASS_NETLINK_IP6FW_SOCKET, NETLINK_IP6FW_SOCKET__NLMSG_READ, "nlmsg_read") 225 S_(SECCLASS_NETLINK_IP6FW_SOCKET, NETLINK_IP6FW_SOCKET__NLMSG_READ, "nlmsg_read")
224 S_(SECCLASS_NETLINK_IP6FW_SOCKET, NETLINK_IP6FW_SOCKET__NLMSG_WRITE, "nlmsg_write") 226 S_(SECCLASS_NETLINK_IP6FW_SOCKET, NETLINK_IP6FW_SOCKET__NLMSG_WRITE, "nlmsg_write")
225 S_(SECCLASS_DBUS, DBUS__ACQUIRE_SVC, "acquire_svc") 227 S_(SECCLASS_DBUS, DBUS__ACQUIRE_SVC, "acquire_svc")
diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h
index f9de0f966559..bdfce4ca8f8e 100644
--- a/security/selinux/include/av_permissions.h
+++ b/security/selinux/include/av_permissions.h
@@ -840,6 +840,8 @@
840 840
841#define NETLINK_AUDIT_SOCKET__NLMSG_READ 0x00400000UL 841#define NETLINK_AUDIT_SOCKET__NLMSG_READ 0x00400000UL
842#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE 0x00800000UL 842#define NETLINK_AUDIT_SOCKET__NLMSG_WRITE 0x00800000UL
843#define NETLINK_AUDIT_SOCKET__NLMSG_RELAY 0x01000000UL
844#define NETLINK_AUDIT_SOCKET__NLMSG_READPRIV 0x02000000UL
843 845
844#define NETLINK_IP6FW_SOCKET__IOCTL 0x00000001UL 846#define NETLINK_IP6FW_SOCKET__IOCTL 0x00000001UL
845#define NETLINK_IP6FW_SOCKET__READ 0x00000002UL 847#define NETLINK_IP6FW_SOCKET__READ 0x00000002UL
diff --git a/security/selinux/nlmsgtab.c b/security/selinux/nlmsgtab.c
index f79408252730..b3adb481bc25 100644
--- a/security/selinux/nlmsgtab.c
+++ b/security/selinux/nlmsgtab.c
@@ -91,13 +91,12 @@ static struct nlmsg_perm nlmsg_xfrm_perms[] =
91 91
92static struct nlmsg_perm nlmsg_audit_perms[] = 92static struct nlmsg_perm nlmsg_audit_perms[] =
93{ 93{
94 { AUDIT_GET, NETLINK_AUDIT_SOCKET__NLMSG_READ }, 94 { AUDIT_GET, NETLINK_AUDIT_SOCKET__NLMSG_READ },
95 { AUDIT_SET, NETLINK_AUDIT_SOCKET__NLMSG_WRITE }, 95 { AUDIT_SET, NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
96 { AUDIT_LIST, NETLINK_AUDIT_SOCKET__NLMSG_READ }, 96 { AUDIT_LIST, NETLINK_AUDIT_SOCKET__NLMSG_READPRIV },
97 { AUDIT_ADD, NETLINK_AUDIT_SOCKET__NLMSG_WRITE }, 97 { AUDIT_ADD, NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
98 { AUDIT_DEL, NETLINK_AUDIT_SOCKET__NLMSG_WRITE }, 98 { AUDIT_DEL, NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
99 { AUDIT_USER, NETLINK_AUDIT_SOCKET__NLMSG_WRITE }, 99 { AUDIT_USER, NETLINK_AUDIT_SOCKET__NLMSG_RELAY },
100 { AUDIT_LOGIN, NETLINK_AUDIT_SOCKET__NLMSG_WRITE },
101}; 100};
102 101
103 102
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 4a6be966bd9f..3a3228b18726 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -164,6 +164,7 @@ config SND_INTERWAVE
164 select SND_RAWMIDI 164 select SND_RAWMIDI
165 select SND_CS4231_LIB 165 select SND_CS4231_LIB
166 select SND_GUS_SYNTH 166 select SND_GUS_SYNTH
167 select ISAPNP
167 help 168 help
168 Say Y here to include support for AMD InterWave based 169 Say Y here to include support for AMD InterWave based
169 soundcards (Gravis UltraSound Plug & Play, STB SoundRage32, 170 soundcards (Gravis UltraSound Plug & Play, STB SoundRage32,
diff --git a/sound/oss/ac97_codec.c b/sound/oss/ac97_codec.c
index 124b1e10a13d..3ecef4689f1b 100644
--- a/sound/oss/ac97_codec.c
+++ b/sound/oss/ac97_codec.c
@@ -155,6 +155,7 @@ static const struct {
155 {0x43525931, "Cirrus Logic CS4299 rev A", &crystal_digital_ops}, 155 {0x43525931, "Cirrus Logic CS4299 rev A", &crystal_digital_ops},
156 {0x43525933, "Cirrus Logic CS4299 rev C", &crystal_digital_ops}, 156 {0x43525933, "Cirrus Logic CS4299 rev C", &crystal_digital_ops},
157 {0x43525934, "Cirrus Logic CS4299 rev D", &crystal_digital_ops}, 157 {0x43525934, "Cirrus Logic CS4299 rev D", &crystal_digital_ops},
158 {0x43585430, "CXT48", &default_ops, AC97_DELUDED_MODEM },
158 {0x43585442, "CXT66", &default_ops, AC97_DELUDED_MODEM }, 159 {0x43585442, "CXT66", &default_ops, AC97_DELUDED_MODEM },
159 {0x44543031, "Diamond Technology DT0893", &default_ops}, 160 {0x44543031, "Diamond Technology DT0893", &default_ops},
160 {0x45838308, "ESS Allegro ES1988", &null_ops}, 161 {0x45838308, "ESS Allegro ES1988", &null_ops},
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
index 6ba03f89fc43..0c2db657badd 100644
--- a/sound/oss/msnd_pinnacle.c
+++ b/sound/oss/msnd_pinnacle.c
@@ -892,7 +892,7 @@ static __inline__ int pack_DAPF_to_DAPQ(register int start)
892static int dsp_read(char __user *buf, size_t len) 892static int dsp_read(char __user *buf, size_t len)
893{ 893{
894 int count = len; 894 int count = len;
895 char *page = (char *)__get_free_page(PAGE_SIZE); 895 char *page = (char *)__get_free_page(GFP_KERNEL);
896 896
897 if (!page) 897 if (!page)
898 return -ENOMEM; 898 return -ENOMEM;
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index e1d69611a257..06047e7979af 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -1149,7 +1149,7 @@ static int mixer_ioctl(struct sv_state *s, unsigned int cmd, unsigned long arg)
1149 if (mixtable[i].rec) 1149 if (mixtable[i].rec)
1150 break; 1150 break;
1151 } 1151 }
1152 if (!mixtable[i].rec) 1152 if (i == SOUND_MIXER_NRDEVICES)
1153 return 0; 1153 return 0;
1154 spin_lock_irqsave(&s->lock, flags); 1154 spin_lock_irqsave(&s->lock, flags);
1155 frobindir(s, SV_CIMIX_ADCINL, 0x1f, mixtable[i].rec << 5); 1155 frobindir(s, SV_CIMIX_ADCINL, 0x1f, mixtable[i].rec << 5);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index d89647a3d449..959953ca320a 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -64,7 +64,8 @@ MODULE_PARM_DESC(model, "Use the given board model.");
64MODULE_LICENSE("GPL"); 64MODULE_LICENSE("GPL");
65MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 65MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
66 "{Intel, ICH6M}," 66 "{Intel, ICH6M},"
67 "{Intel, ICH7}}"); 67 "{Intel, ICH7},"
68 "{Intel, ESB2}}");
68MODULE_DESCRIPTION("Intel HDA driver"); 69MODULE_DESCRIPTION("Intel HDA driver");
69 70
70#define SFX "hda-intel: " 71#define SFX "hda-intel: "
@@ -1422,6 +1423,7 @@ static void __devexit azx_remove(struct pci_dev *pci)
1422static struct pci_device_id azx_ids[] = { 1423static struct pci_device_id azx_ids[] = {
1423 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ 1424 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */
1424 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ 1425 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */
1426 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */
1425 { 0, } 1427 { 0, }
1426}; 1428};
1427MODULE_DEVICE_TABLE(pci, azx_ids); 1429MODULE_DEVICE_TABLE(pci, azx_ids);
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index d143d2c78988..8b33b12fa5dc 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -125,8 +125,8 @@ MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 c
125#ifndef PCI_DEVICE_ID_INTEL_ICH7_20 125#ifndef PCI_DEVICE_ID_INTEL_ICH7_20
126#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de 126#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de
127#endif 127#endif
128#ifndef PCI_DEVICE_ID_INTEL_ESB2_13 128#ifndef PCI_DEVICE_ID_INTEL_ESB2_14
129#define PCI_DEVICE_ID_INTEL_ESB2_13 0x2698 129#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698
130#endif 130#endif
131#ifndef PCI_DEVICE_ID_SI_7012 131#ifndef PCI_DEVICE_ID_SI_7012
132#define PCI_DEVICE_ID_SI_7012 0x7012 132#define PCI_DEVICE_ID_SI_7012 0x7012
@@ -2741,7 +2741,7 @@ static struct shortname_table {
2741 { PCI_DEVICE_ID_INTEL_ESB_5, "Intel 6300ESB" }, 2741 { PCI_DEVICE_ID_INTEL_ESB_5, "Intel 6300ESB" },
2742 { PCI_DEVICE_ID_INTEL_ICH6_18, "Intel ICH6" }, 2742 { PCI_DEVICE_ID_INTEL_ICH6_18, "Intel ICH6" },
2743 { PCI_DEVICE_ID_INTEL_ICH7_20, "Intel ICH7" }, 2743 { PCI_DEVICE_ID_INTEL_ICH7_20, "Intel ICH7" },
2744 { PCI_DEVICE_ID_INTEL_ESB2_13, "Intel ESB2" }, 2744 { PCI_DEVICE_ID_INTEL_ESB2_14, "Intel ESB2" },
2745 { PCI_DEVICE_ID_SI_7012, "SiS SI7012" }, 2745 { PCI_DEVICE_ID_SI_7012, "SiS SI7012" },
2746 { PCI_DEVICE_ID_NVIDIA_MCP_AUDIO, "NVidia nForce" }, 2746 { PCI_DEVICE_ID_NVIDIA_MCP_AUDIO, "NVidia nForce" },
2747 { PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO, "NVidia nForce2" }, 2747 { PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO, "NVidia nForce2" },
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index f1ce808501da..9b4d74d49f98 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -1836,7 +1836,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip)
1836 * 1836 *
1837 */ 1837 */
1838 1838
1839static int __devinit snd_via82xx_chip_init(via82xx_t *chip) 1839static int snd_via82xx_chip_init(via82xx_t *chip)
1840{ 1840{
1841 unsigned int val; 1841 unsigned int val;
1842 int max_count; 1842 int max_count;
diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig
index b0a9ebf8bf3b..75213bf4d567 100644
--- a/sound/ppc/Kconfig
+++ b/sound/ppc/Kconfig
@@ -11,7 +11,7 @@ comment "ALSA PowerMac requires INPUT"
11 11
12config SND_POWERMAC 12config SND_POWERMAC
13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" 13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
14 depends on SND && I2C && INPUT 14 depends on SND && I2C && INPUT && PPC_PMAC
15 select SND_PCM 15 select SND_PCM
16 help 16 help
17 Say Y here to include support for the integrated sound device. 17 Say Y here to include support for the integrated sound device.
diff --git a/sound/ppc/Makefile b/sound/ppc/Makefile
index 4d95c652c8ca..d6ba9959097b 100644
--- a/sound/ppc/Makefile
+++ b/sound/ppc/Makefile
@@ -3,7 +3,7 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o keywest.o beep.o 6snd-powermac-objs := powermac.o pmac.o awacs.o burgundy.o daca.o tumbler.o toonie.o keywest.o beep.o
7 7
8# Toplevel Module Dependency 8# Toplevel Module Dependency
9obj-$(CONFIG_SND_POWERMAC) += snd-powermac.o 9obj-$(CONFIG_SND_POWERMAC) += snd-powermac.o
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 3bf5f069a03d..32d94754acf8 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -986,7 +986,13 @@ static int __init snd_pmac_detect(pmac_t *chip)
986 chip->num_freqs = ARRAY_SIZE(tumbler_freqs); 986 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
987 chip->model = PMAC_SNAPPER; 987 chip->model = PMAC_SNAPPER;
988 chip->can_byte_swap = 0; /* FIXME: check this */ 988 chip->can_byte_swap = 0; /* FIXME: check this */
989 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ 989 chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */
990 break;
991 case 0x3a:
992 chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
993 chip->model = PMAC_TOONIE;
994 chip->can_byte_swap = 0; /* FIXME: check this */
995 chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */
990 break; 996 break;
991 } 997 }
992 } 998 }
diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h
index dc6c99dd14e7..0a84c05f714b 100644
--- a/sound/ppc/pmac.h
+++ b/sound/ppc/pmac.h
@@ -94,7 +94,8 @@ struct snd_pmac_stream {
94 */ 94 */
95 95
96enum snd_pmac_model { 96enum snd_pmac_model {
97 PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER, PMAC_SNAPPER 97 PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
98 PMAC_SNAPPER, PMAC_TOONIE
98}; 99};
99 100
100struct snd_pmac { 101struct snd_pmac {
@@ -191,6 +192,7 @@ int snd_pmac_burgundy_init(pmac_t *chip);
191int snd_pmac_daca_init(pmac_t *chip); 192int snd_pmac_daca_init(pmac_t *chip);
192int snd_pmac_tumbler_init(pmac_t *chip); 193int snd_pmac_tumbler_init(pmac_t *chip);
193int snd_pmac_tumbler_post_init(void); 194int snd_pmac_tumbler_post_init(void);
195int snd_pmac_toonie_init(pmac_t *chip);
194 196
195/* i2c functions */ 197/* i2c functions */
196typedef struct snd_pmac_keywest { 198typedef struct snd_pmac_keywest {
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index 8f1953a8e290..231f6432ea6d 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -95,6 +95,13 @@ static int __init snd_pmac_probe(void)
95 if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0) 95 if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0)
96 goto __error; 96 goto __error;
97 break; 97 break;
98 case PMAC_TOONIE:
99 strcpy(card->driver, "PMac Toonie");
100 strcpy(card->shortname, "PowerMac Toonie");
101 strcpy(card->longname, card->shortname);
102 if ((err = snd_pmac_toonie_init(chip)) < 0)
103 goto __error;
104 break;
98 case PMAC_AWACS: 105 case PMAC_AWACS:
99 case PMAC_SCREAMER: 106 case PMAC_SCREAMER:
100 name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS"; 107 name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS";
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c
new file mode 100644
index 000000000000..082bc4babab5
--- /dev/null
+++ b/sound/ppc/toonie.c
@@ -0,0 +1,379 @@
1/*
2 * Mac Mini "toonie" mixer control
3 *
4 * Copyright (c) 2005 by Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 *
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
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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 02111-1307 USA
19 */
20
21#include <sound/driver.h>
22#include <linux/init.h>
23#include <linux/delay.h>
24#include <linux/i2c.h>
25#include <linux/i2c-dev.h>
26#include <linux/kmod.h>
27#include <linux/slab.h>
28#include <linux/interrupt.h>
29#include <sound/core.h>
30#include <asm/io.h>
31#include <asm/irq.h>
32#include <asm/machdep.h>
33#include <asm/pmac_feature.h>
34#include "pmac.h"
35
36#undef DEBUG
37
38#ifdef DEBUG
39#define DBG(fmt...) printk(fmt)
40#else
41#define DBG(fmt...)
42#endif
43
44struct pmac_gpio {
45 unsigned int addr;
46 u8 active_val;
47 u8 inactive_val;
48 u8 active_state;
49};
50
51struct pmac_toonie
52{
53 struct pmac_gpio hp_detect_gpio;
54 struct pmac_gpio hp_mute_gpio;
55 struct pmac_gpio amp_mute_gpio;
56 int hp_detect_irq;
57 int auto_mute_notify;
58 struct work_struct detect_work;
59};
60
61
62/*
63 * gpio access
64 */
65#define do_gpio_write(gp, val) \
66 pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, (gp)->addr, val)
67#define do_gpio_read(gp) \
68 pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, (gp)->addr, 0)
69#define tumbler_gpio_free(gp) /* NOP */
70
71static void write_audio_gpio(struct pmac_gpio *gp, int active)
72{
73 if (! gp->addr)
74 return;
75 active = active ? gp->active_val : gp->inactive_val;
76 do_gpio_write(gp, active);
77 DBG("(I) gpio %x write %d\n", gp->addr, active);
78}
79
80static int check_audio_gpio(struct pmac_gpio *gp)
81{
82 int ret;
83
84 if (! gp->addr)
85 return 0;
86
87 ret = do_gpio_read(gp);
88
89 return (ret & 0xd) == (gp->active_val & 0xd);
90}
91
92static int read_audio_gpio(struct pmac_gpio *gp)
93{
94 int ret;
95 if (! gp->addr)
96 return 0;
97 ret = ((do_gpio_read(gp) & 0x02) !=0);
98 return ret == gp->active_state;
99}
100
101
102enum { TOONIE_MUTE_HP, TOONIE_MUTE_AMP };
103
104static int toonie_get_mute_switch(snd_kcontrol_t *kcontrol,
105 snd_ctl_elem_value_t *ucontrol)
106{
107 pmac_t *chip = snd_kcontrol_chip(kcontrol);
108 struct pmac_toonie *mix = chip->mixer_data;
109 struct pmac_gpio *gp;
110
111 if (mix == NULL)
112 return -ENODEV;
113 switch(kcontrol->private_value) {
114 case TOONIE_MUTE_HP:
115 gp = &mix->hp_mute_gpio;
116 break;
117 case TOONIE_MUTE_AMP:
118 gp = &mix->amp_mute_gpio;
119 break;
120 default:
121 return -EINVAL;;
122 }
123 ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
124 return 0;
125}
126
127static int toonie_put_mute_switch(snd_kcontrol_t *kcontrol,
128 snd_ctl_elem_value_t *ucontrol)
129{
130 pmac_t *chip = snd_kcontrol_chip(kcontrol);
131 struct pmac_toonie *mix = chip->mixer_data;
132 struct pmac_gpio *gp;
133 int val;
134
135 if (chip->update_automute && chip->auto_mute)
136 return 0; /* don't touch in the auto-mute mode */
137
138 if (mix == NULL)
139 return -ENODEV;
140
141 switch(kcontrol->private_value) {
142 case TOONIE_MUTE_HP:
143 gp = &mix->hp_mute_gpio;
144 break;
145 case TOONIE_MUTE_AMP:
146 gp = &mix->amp_mute_gpio;
147 break;
148 default:
149 return -EINVAL;;
150 }
151 val = ! check_audio_gpio(gp);
152 if (val != ucontrol->value.integer.value[0]) {
153 write_audio_gpio(gp, ! ucontrol->value.integer.value[0]);
154 return 1;
155 }
156 return 0;
157}
158
159static snd_kcontrol_new_t toonie_hp_sw __initdata = {
160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
161 .name = "Headphone Playback Switch",
162 .info = snd_pmac_boolean_mono_info,
163 .get = toonie_get_mute_switch,
164 .put = toonie_put_mute_switch,
165 .private_value = TOONIE_MUTE_HP,
166};
167static snd_kcontrol_new_t toonie_speaker_sw __initdata = {
168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
169 .name = "PC Speaker Playback Switch",
170 .info = snd_pmac_boolean_mono_info,
171 .get = toonie_get_mute_switch,
172 .put = toonie_put_mute_switch,
173 .private_value = TOONIE_MUTE_AMP,
174};
175
176/*
177 * auto-mute stuffs
178 */
179static int toonie_detect_headphone(pmac_t *chip)
180{
181 struct pmac_toonie *mix = chip->mixer_data;
182 int detect = 0;
183
184 if (mix->hp_detect_gpio.addr)
185 detect |= read_audio_gpio(&mix->hp_detect_gpio);
186 return detect;
187}
188
189static void toonie_check_mute(pmac_t *chip, struct pmac_gpio *gp, int val,
190 int do_notify, snd_kcontrol_t *sw)
191{
192 if (check_audio_gpio(gp) != val) {
193 write_audio_gpio(gp, val);
194 if (do_notify)
195 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
196 &sw->id);
197 }
198}
199
200static void toonie_detect_handler(void *self)
201{
202 pmac_t *chip = (pmac_t*) self;
203 struct pmac_toonie *mix;
204 int headphone;
205
206 if (!chip)
207 return;
208
209 mix = chip->mixer_data;
210 snd_assert(mix, return);
211
212 headphone = toonie_detect_headphone(chip);
213
214 DBG("headphone: %d, lineout: %d\n", headphone, lineout);
215
216 if (headphone) {
217 /* unmute headphone/lineout & mute speaker */
218 toonie_check_mute(chip, &mix->hp_mute_gpio, 0,
219 mix->auto_mute_notify, chip->master_sw_ctl);
220 toonie_check_mute(chip, &mix->amp_mute_gpio, 1,
221 mix->auto_mute_notify, chip->speaker_sw_ctl);
222 } else {
223 /* unmute speaker, mute others */
224 toonie_check_mute(chip, &mix->amp_mute_gpio, 0,
225 mix->auto_mute_notify, chip->speaker_sw_ctl);
226 toonie_check_mute(chip, &mix->hp_mute_gpio, 1,
227 mix->auto_mute_notify, chip->master_sw_ctl);
228 }
229 if (mix->auto_mute_notify) {
230 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
231 &chip->hp_detect_ctl->id);
232 }
233}
234
235static void toonie_update_automute(pmac_t *chip, int do_notify)
236{
237 if (chip->auto_mute) {
238 struct pmac_toonie *mix;
239 mix = chip->mixer_data;
240 snd_assert(mix, return);
241 mix->auto_mute_notify = do_notify;
242 schedule_work(&mix->detect_work);
243 }
244}
245
246/* interrupt - headphone plug changed */
247static irqreturn_t toonie_hp_intr(int irq, void *devid, struct pt_regs *regs)
248{
249 pmac_t *chip = devid;
250
251 if (chip->update_automute && chip->initialized) {
252 chip->update_automute(chip, 1);
253 return IRQ_HANDLED;
254 }
255 return IRQ_NONE;
256}
257
258/* look for audio gpio device */
259static int find_audio_gpio(const char *name, const char *platform,
260 struct pmac_gpio *gp)
261{
262 struct device_node *np;
263 u32 *base, addr;
264
265 if (! (np = find_devices("gpio")))
266 return -ENODEV;
267
268 for (np = np->child; np; np = np->sibling) {
269 char *property = get_property(np, "audio-gpio", NULL);
270 if (property && strcmp(property, name) == 0)
271 break;
272 if (device_is_compatible(np, name))
273 break;
274 }
275 if (np == NULL)
276 return -ENODEV;
277
278 base = (u32 *)get_property(np, "AAPL,address", NULL);
279 if (! base) {
280 base = (u32 *)get_property(np, "reg", NULL);
281 if (!base) {
282 DBG("(E) cannot find address for device %s !\n", name);
283 return -ENODEV;
284 }
285 addr = *base;
286 if (addr < 0x50)
287 addr += 0x50;
288 } else
289 addr = *base;
290
291 gp->addr = addr & 0x0000ffff;
292
293 /* Try to find the active state, default to 0 ! */
294 base = (u32 *)get_property(np, "audio-gpio-active-state", NULL);
295 if (base) {
296 gp->active_state = *base;
297 gp->active_val = (*base) ? 0x5 : 0x4;
298 gp->inactive_val = (*base) ? 0x4 : 0x5;
299 } else {
300 u32 *prop = NULL;
301 gp->active_state = 0;
302 gp->active_val = 0x4;
303 gp->inactive_val = 0x5;
304 /* Here are some crude hacks to extract the GPIO polarity and
305 * open collector informations out of the do-platform script
306 * as we don't yet have an interpreter for these things
307 */
308 if (platform)
309 prop = (u32 *)get_property(np, platform, NULL);
310 if (prop) {
311 if (prop[3] == 0x9 && prop[4] == 0x9) {
312 gp->active_val = 0xd;
313 gp->inactive_val = 0xc;
314 }
315 if (prop[3] == 0x1 && prop[4] == 0x1) {
316 gp->active_val = 0x5;
317 gp->inactive_val = 0x4;
318 }
319 }
320 }
321
322 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n",
323 name, gp->addr, gp->active_state);
324
325 return (np->n_intrs > 0) ? np->intrs[0].line : 0;
326}
327
328static void toonie_cleanup(pmac_t *chip)
329{
330 struct pmac_toonie *mix = chip->mixer_data;
331 if (! mix)
332 return;
333 if (mix->hp_detect_irq >= 0)
334 free_irq(mix->hp_detect_irq, chip);
335 kfree(mix);
336 chip->mixer_data = NULL;
337}
338
339int snd_pmac_toonie_init(pmac_t *chip)
340{
341 struct pmac_toonie *mix;
342
343 mix = kmalloc(sizeof(*mix), GFP_KERNEL);
344 if (! mix)
345 return -ENOMEM;
346
347 chip->mixer_data = mix;
348 chip->mixer_free = toonie_cleanup;
349
350 find_audio_gpio("headphone-mute", NULL, &mix->hp_mute_gpio);
351 find_audio_gpio("amp-mute", NULL, &mix->amp_mute_gpio);
352 mix->hp_detect_irq = find_audio_gpio("headphone-detect",
353 NULL, &mix->hp_detect_gpio);
354
355 strcpy(chip->card->mixername, "PowerMac Toonie");
356
357 chip->master_sw_ctl = snd_ctl_new1(&toonie_hp_sw, chip);
358 snd_ctl_add(chip->card, chip->master_sw_ctl);
359
360 chip->speaker_sw_ctl = snd_ctl_new1(&toonie_speaker_sw, chip);
361 snd_ctl_add(chip->card, chip->speaker_sw_ctl);
362
363 INIT_WORK(&mix->detect_work, toonie_detect_handler, (void *)chip);
364
365 if (mix->hp_detect_irq >= 0) {
366 snd_pmac_add_automute(chip);
367
368 chip->detect_headphone = toonie_detect_headphone;
369 chip->update_automute = toonie_update_automute;
370 toonie_update_automute(chip, 0);
371
372 if (request_irq(mix->hp_detect_irq, toonie_hp_intr, 0,
373 "Sound Headphone Detection", chip) < 0)
374 mix->hp_detect_irq = -1;
375 }
376
377 return 0;
378}
379
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index c71807e069ee..9332237cb6a4 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -99,6 +99,7 @@ typedef struct pmac_tumbler_t {
99 pmac_gpio_t hp_detect; 99 pmac_gpio_t hp_detect;
100 int headphone_irq; 100 int headphone_irq;
101 int lineout_irq; 101 int lineout_irq;
102 unsigned int save_master_vol[2];
102 unsigned int master_vol[2]; 103 unsigned int master_vol[2];
103 unsigned int save_master_switch[2]; 104 unsigned int save_master_switch[2];
104 unsigned int master_switch[2]; 105 unsigned int master_switch[2];
@@ -177,11 +178,22 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active)
177 if (! gp->addr) 178 if (! gp->addr)
178 return; 179 return;
179 active = active ? gp->active_val : gp->inactive_val; 180 active = active ? gp->active_val : gp->inactive_val;
180
181 do_gpio_write(gp, active); 181 do_gpio_write(gp, active);
182 DBG("(I) gpio %x write %d\n", gp->addr, active); 182 DBG("(I) gpio %x write %d\n", gp->addr, active);
183} 183}
184 184
185static int check_audio_gpio(pmac_gpio_t *gp)
186{
187 int ret;
188
189 if (! gp->addr)
190 return 0;
191
192 ret = do_gpio_read(gp);
193
194 return (ret & 0xd) == (gp->active_val & 0xd);
195}
196
185static int read_audio_gpio(pmac_gpio_t *gp) 197static int read_audio_gpio(pmac_gpio_t *gp)
186{ 198{
187 int ret; 199 int ret;
@@ -683,7 +695,7 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
683 } 695 }
684 if (gp == NULL) 696 if (gp == NULL)
685 return -EINVAL; 697 return -EINVAL;
686 ucontrol->value.integer.value[0] = ! read_audio_gpio(gp); 698 ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
687 return 0; 699 return 0;
688} 700}
689 701
@@ -711,7 +723,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
711 } 723 }
712 if (gp == NULL) 724 if (gp == NULL)
713 return -EINVAL; 725 return -EINVAL;
714 val = ! read_audio_gpio(gp); 726 val = ! check_audio_gpio(gp);
715 if (val != ucontrol->value.integer.value[0]) { 727 if (val != ucontrol->value.integer.value[0]) {
716 write_audio_gpio(gp, ! ucontrol->value.integer.value[0]); 728 write_audio_gpio(gp, ! ucontrol->value.integer.value[0]);
717 return 1; 729 return 1;
@@ -897,11 +909,11 @@ static int tumbler_detect_lineout(pmac_t *chip)
897 909
898static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw) 910static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw)
899{ 911{
900 //pmac_tumbler_t *mix = chip->mixer_data; 912 if (check_audio_gpio(gp) != val) {
901 if (val != read_audio_gpio(gp)) {
902 write_audio_gpio(gp, val); 913 write_audio_gpio(gp, val);
903 if (do_notify) 914 if (do_notify)
904 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &sw->id); 915 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
916 &sw->id);
905 } 917 }
906} 918}
907 919
@@ -1128,6 +1140,8 @@ static void tumbler_suspend(pmac_t *chip)
1128 disable_irq(mix->lineout_irq); 1140 disable_irq(mix->lineout_irq);
1129 mix->save_master_switch[0] = mix->master_switch[0]; 1141 mix->save_master_switch[0] = mix->master_switch[0];
1130 mix->save_master_switch[1] = mix->master_switch[1]; 1142 mix->save_master_switch[1] = mix->master_switch[1];
1143 mix->save_master_vol[0] = mix->master_vol[0];
1144 mix->save_master_vol[1] = mix->master_vol[1];
1131 mix->master_switch[0] = mix->master_switch[1] = 0; 1145 mix->master_switch[0] = mix->master_switch[1] = 0;
1132 tumbler_set_master_volume(mix); 1146 tumbler_set_master_volume(mix);
1133 if (!mix->anded_reset) { 1147 if (!mix->anded_reset) {
@@ -1155,6 +1169,8 @@ static void tumbler_resume(pmac_t *chip)
1155 mix->acs &= ~1; 1169 mix->acs &= ~1;
1156 mix->master_switch[0] = mix->save_master_switch[0]; 1170 mix->master_switch[0] = mix->save_master_switch[0];
1157 mix->master_switch[1] = mix->save_master_switch[1]; 1171 mix->master_switch[1] = mix->save_master_switch[1];
1172 mix->master_vol[0] = mix->save_master_vol[0];
1173 mix->master_vol[1] = mix->save_master_vol[1];
1158 tumbler_reset_audio(chip); 1174 tumbler_reset_audio(chip);
1159 if (mix->i2c.client && mix->i2c.init_client) { 1175 if (mix->i2c.client && mix->i2c.init_client) {
1160 if (mix->i2c.init_client(&mix->i2c) < 0) 1176 if (mix->i2c.init_client(&mix->i2c) < 0)